incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benson Margulies <ben...@basistech.com>
Subject Re: Looking for help upgrading from older toolkit
Date Wed, 16 Oct 2013 14:26:05 GMT
On Wed, Oct 16, 2013 at 10:14 AM, Svante Schubert <svante.schubert@gmail.com
> wrote:

> Am 16.10.2013 14:33, schrieb Benson Margulies:
> > In the following, all the setAttributeNS calls are broken because that
> > method no longer exists, and the class OdfFontFace no longer exists.
> In the very beginning we had for every generated element, a generated
> convenient element.
> But a convenient element does only exist for a few elements, the root
> elements of components.
> This is because often only a group of XML elements represent a
> component, like draw:frame and draw:image is an image and sometimes
> there is even only boilerplate XML, like the office:body element is only
> an internal grouping element within the XML file.
>

OK, but do you see my overall goal here, which is to change the default
styles? It's not at all obvious to me how to go about doing that now given
what you've written.


>
> Long story short, instead of OdfFontFace you need the element class,
> which is in this case
> StyleFontFaceElement
>
> If you are not aware of the prefix (here style), just search within the
> online ODF documentation:
> http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html
>
> > stylesDom = outputDocument.getStylesDom();
> >
> >         XPath xpath = XPathFactory.newInstance().newXPath();
> >         xpath.setNamespaceContext(stylesDom);
> >         OdfTextProperties defaultTp =
> >             (OdfTextProperties)
> >                 xpath.
> >
> >
> evaluate("/office:document-styles/office:styles/style:default-style/style:text-properties",
> >                          stylesDom,
> >                          XPathConstants.NODE);
> >         if (language == LanguageCode.ARABIC || language ==
> > LanguageCode.PERSIAN || language == LanguageCode.PUSHTO) {
> >             defaultTp.setAttributeNS(OdfDocumentNamespace.STYLE.getUri(),
> > "language-complex", language.ISO639_1());
> >             defaultTp.setAttributeNS(OdfDocumentNamespace.STYLE.getUri(),
> > "font-name-complex", ARABIC_FONT_NAME);
> >             OdfFontFaceDecls fontFaceDecls = (OdfFontFaceDecls)
> >
> > xpath.evaluate("/office:document-content/office:font-face-decls",
> >                                    contentDom,
> >                                    XPathConstants.NODE);
> >             OdfFontFace face = new OdfFontFace(contentDom);
> >             face.setName(ARABIC_FONT_NAME);
> >             face.setFontFamily(ARABIC_FONT_NAME);
> >             face.setFontPitch(OdfFontPitchType.VARIABLE);
> >             face.setFontSize("20");
> >             fontFaceDecls.appendChild(face);
> >         }
> >
> >
> > On Wed, Oct 16, 2013 at 8:21 AM, Benson Margulies <benson@basistech.com
> >wrote:
> >
> >> most of the classes in there are not just deprecated but deleted.
> >> details to follow.
> >>
> >>> On Oct 16, 2013, at 4:36 AM, Svante Schubert <
> svante.schubert@gmail.com>
> >> wrote:
> >>> Uncertain what's the problem. Is it some deprecation?
> >>> In this case it is due to the Simple API, introduced by the IBM team.
> >>> I still work with the deprecated parts as I am free to change/refactor
> >>> more radical.
> >>> Name the problem and I will try to help.
> >>>
> >>> Best regards,
> >>> Svante
> >>>
> >>> Am 15.10.2013 21:22, schrieb Benson Margulies:
> >>>> Can someone help me out with the modern equivalent of the following?
> >>>>
> >>>>
> >>>> OdfTextProperties defaultTp =
> >>>>            (OdfTextProperties)
> >>>>                xpath.
> >>>>
> >>>>
> >>
> evaluate("/office:document-styles/office:styles/style:default-style/style:text-properties",
> >>>>                         stylesDom,
> >>>>                         XPathConstants.NODE);
> >>>>        if (language == LanguageCode.ARABIC || language ==
> >>>> LanguageCode.PERSIAN || language == LanguageCode.PUSHTO) {
> >>>>
>  defaultTp.setAttributeNS(OdfDocumentNamespace.STYLE.getUri(),
> >>>> "language-complex", language.ISO639_1());
> >>>>
>  defaultTp.setAttributeNS(OdfDocumentNamespace.STYLE.getUri(),
> >>>> "font-name-complex", ARABIC_FONT_NAME);
> >>>>            OdfFontFaceDecls fontFaceDecls = (OdfFontFaceDecls)
> >>>>
> >>>> xpath.evaluate("/office:document-content/office:font-face-decls",
> >>>>                                   contentDom,
> >>>>                                   XPathConstants.NODE);
> >>>>            OdfFontFace face = new OdfFontFace(contentDom);
> >>>>            face.setName(ARABIC_FONT_NAME);
> >>>>            face.setFontFamily(ARABIC_FONT_NAME);
> >>>>            face.setFontPitch(OdfFontPitchType.VARIABLE);
> >>>>            face.setFontSize("20");
> >>>>            fontFaceDecls.appendChild(face);
> >>>>        }
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message