src/org/jopendocument/examples/SimpleOdt2.java

437 views
Skip to first unread message

yambo

unread,
Jul 23, 2013, 3:49:48 PM7/23/13
to jopend...@googlegroups.com
Hi,

When I try to compile src/org/jopendocument/examples/SimpleOdt2.java with the version 1.3 this fails, compiling with 1.2 seems to work.
I am using java 1.7.0.17.
What am I doing wrong ?

kind regards

willy

Errors :
javac src/org/jopendocument/examples/SimpleOdt2.java
src/org/jopendocument/examples/SimpleOdt2.java:72: error: cannot find symbol
        heading.setStyle("Movie_20_Heading");
               ^
  symbol:   method setStyle(String)
  location: variable heading of type Heading
src/org/jopendocument/examples/SimpleOdt2.java:76: error: no suitable method found for add(Heading)
        contentDom.add(heading);
                  ^
    method ODSingleXMLDocument.add(Element,int,ODSingleXMLDocument) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument,boolean) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument) is not applicable
      (actual argument Heading cannot be converted to ODSingleXMLDocument by method invocation conversion)
    method ODXMLDocument.add(IFactory<Element>,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(Element,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(String,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
src/org/jopendocument/examples/SimpleOdt2.java:88: error: cannot find symbol
            paragraph.setStyle("Synopsis_20_Para");
                     ^
  symbol:   method setStyle(String)
  location: variable paragraph of type Paragraph
src/org/jopendocument/examples/SimpleOdt2.java:90: error: no suitable method found for add(Paragraph)
            contentDom.add(paragraph);
                      ^
    method ODSingleXMLDocument.add(Element,int,ODSingleXMLDocument) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument,boolean) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument) is not applicable
      (actual argument Paragraph cannot be converted to ODSingleXMLDocument by method invocation conversion)
    method ODXMLDocument.add(IFactory<Element>,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(Element,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(String,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
src/org/jopendocument/examples/SimpleOdt2.java:99: error: cannot find symbol
        heading.setStyle("Cast_20_Heading");
               ^
  symbol:   method setStyle(String)
  location: variable heading of type Heading
src/org/jopendocument/examples/SimpleOdt2.java:100: error: no suitable method found for add(Heading)
        contentDom.add(heading);
                  ^
    method ODSingleXMLDocument.add(Element,int,ODSingleXMLDocument) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument,boolean) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument) is not applicable
      (actual argument Heading cannot be converted to ODSingleXMLDocument by method invocation conversion)
    method ODXMLDocument.add(IFactory<Element>,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(Element,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(String,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
src/org/jopendocument/examples/SimpleOdt2.java:109: error: cannot find symbol
            actor.setStyle("Cast_20_Para");
                 ^
  symbol:   method setStyle(String)
  location: variable actor of type Paragraph
src/org/jopendocument/examples/SimpleOdt2.java:115: error: no suitable method found for add(Paragraph)
            contentDom.add(actor);
                      ^
    method ODSingleXMLDocument.add(Element,int,ODSingleXMLDocument) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument,boolean) is not applicable
      (actual and formal argument lists differ in length)
    method ODSingleXMLDocument.add(ODSingleXMLDocument) is not applicable
      (actual argument Paragraph cannot be converted to ODSingleXMLDocument by method invocation conversion)
    method ODXMLDocument.add(IFactory<Element>,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(Element,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
    method ODXMLDocument.add(String,int,ODXMLDocument,String,ElementTransformer) is not applicable
      (actual and formal argument lists differ in length)
Note: src/org/jopendocument/examples/SimpleOdt2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
8 errors

Sylvain Cuaz

unread,
Jul 24, 2013, 3:36:07 AM7/24/13
to jopend...@googlegroups.com
Le 23/07/2013 21:49, yambo a �crit :
> Hi,
>
> When I try to compile src/org/jopendocument/examples/SimpleOdt2.java with
> the version 1.3 this fails, compiling with 1.2 seems to work.
> I am using java 1.7.0.17.
> What am I doing wrong ?

Nothing, as stated on http://www.jopendocument.org/doc_benchmark.html the code was used against 1.2
and it wasn't updated.

Cheers,
Sylvain

yambo

unread,
Jul 24, 2013, 4:24:38 AM7/24/13
to jopend...@googlegroups.com
Hi,

ok fine,

This code does not work anymore :

ODPackage outputDocument = new ODPackage(new File("styles.odt"));
contentDom = outputDocument.toSingle();
final Paragraph paragraph = new Paragraph();
contentDom.add(paragraph);

What is the correct way to do it in version 1.3 ?

kind regards

willy

Op dinsdag 23 juli 2013 21:49:48 UTC+2 schreef yambo het volgende:

Gmail

unread,
Jul 24, 2013, 3:50:20 AM7/24/13
to jopend...@googlegroups.com, Sylvain Cuaz
Hi,

ok fine,

This code does not work anymore :

ODPackage outputDocument = new ODPackage(new File("styles.odt"));
contentDom = outputDocument.toSingle();
final Paragraph paragraph = new Paragraph();
contentDom.add(paragraph);

What is the correct way to do it in version 1.3 ?

kind regards

willy

Sylvain Cuaz

unread,
Aug 1, 2013, 11:10:57 AM8/1/13
to jopend...@googlegroups.com
Le 24/07/2013 09:50, Gmail a �crit :
> Hi,
>
> ok fine,
>
> This code does not work anymore :
>
> ODPackage outputDocument = new ODPackage(new File("styles.odt"));
> contentDom = outputDocument.toSingle();
> final Paragraph paragraph = new Paragraph();
> contentDom.add(paragraph);
>
> What is the correct way to do it in version 1.3 ?

The add() method is now in TextDocument. So your second line should be

TextDocument contentDom = outputDocument.getTextDocument();


HTH,
Sylvain

theminor

unread,
Mar 4, 2015, 4:29:18 AM3/4/15
to jopend...@googlegroups.com
I've gotten this to work now with add() under TextDocument - thanks!  But can someone point out how to use addStyledContent() instead of addContent() on a Paragraph?

When I use addStyledContent() it just adds content just like add(), with the Default style in the document. For example, if addStyledContent("Added Text", "Title"), where Title is a paragraph style defined in my styles.odt document...

Any ideas? I can't get this to work...

Sylvain Cuaz

unread,
Mar 4, 2015, 6:37:04 AM3/4/15
to jopend...@googlegroups.com
Le 03/03/2015 22:15, theminor a écrit :
> I've gotten this to work now with add() under TextDocument - thanks! But
> can someone point out how to use addStyledContent() instead of addContent()
> on a Paragraph?
>
> When I use addStyledContent() it just adds content just like add(), with
> the Default style in the document. For example, if addStyledContent("Added
> Text", "Title"), where Title is a paragraph style defined in my styles.odt
> document...
>
> Any ideas? I can't get this to work...

Hi,

addStyledContent() adds content inside an existing paragraph so I think you need to pass a text
style name, not a paragraph style.

Cheers,
Sylvain

theminor

unread,
Mar 4, 2015, 10:03:12 PM3/4/15
to jopend...@googlegroups.com
Thanks - that is helpful - I've been looking for a way to change character styles in the middle of a paragraph. However, I still can't make it work. When I add addStyledContent() the paragraph can't be added to the document anymore. For example, if I have a character style in my file called "Emphasis", if I call addContent("Text here") everything works as expected. But if I call paragraph.addStyledContent("Text here", "Emphasis") the whole paragraph doesn't show up. I don't get an error, it just makes it so the paragraph doesn't show up in the document.

Also, I've found that Paragraph.setStyle() doesn't work in jopendocument 1.3 or higher. If I revert back to jopendocument 1.2 it works fine, but 1.3 complains that it can't find the setStyle() method.

Thanks!
Reply all
Reply to author
Forward
0 new messages