If everything fails and no other is able to help you earlier, I might be
able to take a look at the weekend, but currently, I have my own windmills
I am riding against ;)

Good luck,
Svante

PS: To be able to test your use case, you might provide a start document
and the version of Word it should work with. Currently, I got MS Office
2016 installed and various Libre- and OpenOffice versions.
ᐧ

2018-01-09 13:44 GMT+01:00 Joseph D. Wagner <[email protected]>:

> Trying to chase down the differences between LibreOffice and Word has been
> frustrating, to say the least.
>
> To be honest, I am even more lost in ODFDOM than I am in Simple API.  I
> will try to take a look at the regression tests, but you may be
> overestimating my caliber as a programmer.
>
> I was hoping for just a little more help, but I'll try.
>
> Joseph D. Wagner
>
> -----Original Message-----
> From: Svante Schubert [mailto:[email protected]]
> Sent: Tuesday, January 9, 2018 1:50 AM
> To: [email protected]
> Subject: Re: Trouble with Footer Font Size - Adding Page X of Y to Footer
>
> Hello Joeseph,
>
> the first interesting thing to mention from ODF perspective is that the
> text of a footer and header is part of the page style within the styles.xml.
> Therefore any automatic styles being used for header and footer are not
> within the content.xml, but styles.xml - and only those.
> Let us not discuss the pro and con of this design, let me simply state,
> that I am not a fan of it of the overall result :)
>
> In your example, it seems that the LibreOffice styles are not connecting
> to each other, ie. a32e835 at the paragraph and a2b0e5e at the paragraph
> style should be the same string, but this might be as well a copy paste
> error from different files.
> To alter the ODF styles, you might want to go a level deeper into the
> ODFDOM project <http://incubator.apache.org/odftoolkit/odfdom/
> ProjectOverview.html>.
> Again take a look at the regression tests, where to find the desired
> elements.
>
> In general, every XML element has a generated DOM class with the prefix
> local name and either Attribute or Element suffix, for instance,
> TextSpanElement class.
>
> Hope it helps!
>
> Cheers,
> Svante
> ᐧ
>
> 2018-01-09 3:32 GMT+01:00 Joseph D. Wagner <[email protected]>:
>
> > I am trying to add a "Page X of Y" footer to the bottom of a text
> > document.  I got everything working *EXCEPT* the font size.
> >
> > I wrote this code:
> >
> >         // Adds Page X of Y to the footer
> >         Font fontsmaller = new Font("Arial",
> > StyleTypeDefinitions.FontStyle.REGULAR,
> > 8);
> >         Footer footer = doc.getFooter();
> >         Section footersection = footer.appendSection("Page Numbers");
> >         Paragraph footerparagraph = footersection.addParagraph("Pa
> > ge\u00A0");
> >         footerparagraph.setFont(fontsmaller); // Doesn't work here
> > either Fields.createCurrentPageNumberField(
> footerparagraph.getOdfElement());
> >         footerparagraph.appendTextContent("\u00A0of\u00A0");
> > Fields.createPageCountField(footerparagraph.getOdfElement());
> >         footerparagraph.setFont(fontsmaller); // Doesn't work here
> > either
> >
> > It seems to work EXCEPT the part of changing the font size.  In Word,
> > the font ends up being the default size of 12.  (Works as expected in
> > LibreOffice.)
> >
> > Interesting, counterexample.  It works when I set the font larger,
> > like 16, but it doesn't work when I set the font smaller, like 10 or 8.
> >
> > I performed a diff comparison on the output form odftoolkit(-) and the
> > output from Word(+).  It seems the key difference is lines like these
> > in
> > styles.xml:
> >
> > -    <style:style style:family="paragraph" style:name="a2b0e5e">
> > -      <style:paragraph-properties fo:text-align="center"
> > style:line-break="strict" style:punctuation-wrap="hanging"
> > style:text-autospace="ideograph-alpha" style:writing-mode="page"/>
> > -      <style:text-properties fo:color="#000000" fo:country="US"
> > fo:font-size="10.0pt" fo:language="en" style:font-name="Courier New"
> > style:font-name-asian="Lucida Sans Unicode"
> > style:font-name-complex="Tahom a"
> > style:font-size-asian="12pt" style:font-size-complex="12pt"/>
> > +    <style:style style:name="P2" style:parent-style-name="Normal"
> > style:family="paragraph">
> > +      <style:paragraph-properties fo:text-align="center"/>
> > +      <style:text-properties style:font-name="Courier New"/>
> > +    </style:style>
> > +    <style:style style:name="T3" style:parent-style-name="
> DefaultParagraphFont"
> > style:family="text">
> > +      <style:text-properties style:font-name="Courier New"
> > fo:color="#FF0000" fo:font-size="8pt" style:font-size-asian="8pt"
> > style:font-size-complex="8pt"/>
> > +    </style:style>
> > +    <style:style style:name="T4" style:parent-style-name="
> DefaultParagraphFont"
> > style:family="text">
> > +      <style:text-properties style:font-name="Courier New"
> > fo:color="#FF0000" fo:font-size="8pt" style:font-size-asian="8pt"
> > style:font-size-complex="8pt"/>
> > +    </style:style>
> > +    <style:style style:name="T5" style:parent-style-name="
> DefaultParagraphFont"
> > style:family="text">
> > +      <style:text-properties style:font-name="Courier New"
> > fo:color="#FF0000" fo:font-size="8pt" style:font-size-asian="8pt"
> > style:font-size-complex="8pt"/>
> > +    </style:style>
> > +    <style:style style:name="T6" style:parent-style-name="
> DefaultParagraphFont"
> > style:family="text">
> > +      <style:text-properties style:font-name="Courier New"
> > fo:color="#FF0000" fo:font-size="8pt" style:font-size-asian="8pt"
> > style:font-size-complex="8pt"/>
> >      </style:style>
> >
> >
> > -      <style:footer>
> > -        <text:section text:display="true" text:name="Page Numbers"
> > text:style-name="aec74e3">
> > -          <text:p text:style-name="a32e835">Page
> <text:span><text:page-number
> > style:num-format="" text:select-page="current"/> o f
> > </text:span><text:span><text:page-count style:num-format=""/></text:sp
> > an></text:p>
> > -        </text:section>
> > -      </style:footer>
> >
> > +      <style:footer>
> > +        <text:p text:style-name="Normal">
> > +          <text:span text:style-name="T3">Page </text:span>
> > +          <text:span text:style-name="T4">
> > +            <text:page-number text:fixed="false">1</text:page-number>
> > +          </text:span>
> > +          <text:span text:style-name="T5"> of </text:span>
> > +          <text:span text:style-name="T6">
> > +            <text:page-count>14</text:page-count>
> > +          </text:span>
> > +        </text:p>
> > +      </style:footer>
> >
> > Unfortunately, I don't know what code I should write to force
> > odftoolkit to generate appropriate styles and text properties fields.
> >
> > Could someone please help me figure this one out?
> >
> > Thanks.
> >
> > Joseph D. Wagner
> >
> >
>
>

Reply via email to