Date: prev next · Thread: first prev next last


Hej Maike,

The easiest way would be to add the previous functionality from the Simple
API to the DOC API.
What is the information that is not accessible (and/or what were the old
functions)?
The answers might indicate if we need to alter (likely separate) the
information (previous API) in addition to a high-level semantic (common
end-user knowledge) and underlying specific syntax (XML) access.

Best regards,
Svante

PS: Sorry for the delay in answering your email, had been on Eastern
vacation! :-)

Am Do., 21. Apr. 2022 um 13:42 Uhr schrieb Maike Keune-Staab <
keunem@gmail.com>:

Hey there,
i am currently migrating a project, that is using a very old version of the
odftoolkit.

There are methods that should place an image inside an odt file. Some of
the classes and methods are no longer available in the new odftoolkit
0.10.0. Do you have any suggestion how i can solve that?

Thank you so much.

Maike

/**
     * Austauschen (Art 1) des Platzhalters gegen eine Bilddatei.
     *
     * @param odt              Template im Format ODT.
     * @param picPlaceHolder   Platzhalter-Name für das einzufügende Bild.
z.B. "Bild1"
     * @param uriImgageFile    URI zur Bilddatei, die eingefügt werden
soll.
     */
    public static void imageFileIntegration(TextDocument odt, String
picPlaceHolder, URI uriImgageFile, double picHeight, double picWidth) {

        final TextNavigation textNav = new TextNavigation(picPlaceHolder,
odt);
        while (textNav.hasNext()) {
            final TextSelection item1 = (TextSelection)
textNav.nextSelection();

            try {
                org.odftoolkit.simple.draw.Image imgReplace =
item1.replaceWith(uriImgageFile);
                FrameRectangle rect1 = imgReplace.getRectangle();
                rect1.setLinearMeasure(
StyleTypeDefinitions.SupportedLinearMeasure.PT
<http://styletypedefinitions.supportedlinearmeasure.pt/>);
                rect1.setHeight(picHeight);
                rect1.setWidth(picWidth);
                imgReplace.setRectangle(rect1);
            } catch (InvalidNavigationException e) {
                e.printStackTrace();
            }
        }
    }

  /**
     * Austauschen (Art 1) des Platzhalters gegen eine Bilddatei.
     *
     * @param textSelection    Textausschnitt aus dem ODT-Dokument, der
durch das Bild ersetzt werden soll
     * @param uriImgageFile    URI zur Bilddatei, die eingefügt werden
soll.
     * @param picWidth         Breite
     * @param picHeight        Höhe
     */
    public static void imageFileReplaceTextSelection(TextSelection
textSelection, URI uriImgageFile, double picHeight, double picWidth ) {
            try {
                org.odftoolkit.simple.draw.Image imgReplace =
textSelection.replaceWith(uriImgageFile);
                FrameRectangle rect1 = imgReplace.getRectangle();
                rect1.setLinearMeasure(
StyleTypeDefinitions.SupportedLinearMeasure.PT
<http://styletypedefinitions.supportedlinearmeasure.pt/>); // Angabe soll
in Punkten erfolgen
                rect1.setHeight(picHeight);
                rect1.setWidth(picWidth);
                imgReplace.setRectangle(rect1);
            } catch (InvalidNavigationException e) {
                e.printStackTrace();
            }
    }

--
To unsubscribe e-mail to: dev+unsubscribe@odftoolkit.org
Problems?
https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.odftoolkit.org/dev/
Privacy Policy: https://www.documentfoundation.org/privacy


-- 
To unsubscribe e-mail to: dev+unsubscribe@odftoolkit.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.odftoolkit.org/dev/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.