Date: prev next · Thread: first prev next last
2018 Archives by date, by thread · List index


Hi Tomaž,

Tomaž Vajngerl schrieb am 23-Aug-18 um 17:26:
Hi Regina,

On Thu, Aug 23, 2018 at 3:26 PM Regina Henschel <rb.henschel@t-online.de> wrote:
[..]

I have tried a start like
void SdMiscTest::testTdf101242_ODF2ODF()
{
     ::sd::DrawDocShellRef xDocShRef =
Load(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf101242_without_settings.odg"),
ODG);

I would do it like it is done in test SdExportTest::testTdf113822 in
export-tests.cxx and SdExportTest::testEmbeddedText().

    utl::TempFile tempFile;
    sd::DrawDocShellRef xShell =
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf101242_without_settings.odg"),
ODG);
    xShell = saveAndReload(xShell.get(), ODG, &tempFile);
    xmlDocPtr pXmlDoc = parseExport(tempFile, "styles.xml");
    assert with xpath ...
    xDocShRef->DoClose();

I see a temp file in C:\cygwin64\tmp\. But it has mimetype
application/vnd.oasis.opendocument.presentation and the attributes in
the <draw:layer> elements are wrong.

That's weird - I hope it works with my example.

It turns out, that loadURL is not enough. Using 'Load' works now, I guess because it generates a Frame, which is needed for layers.

I have changed SdModelTestBase to use "private:factory/sdraw*" for odg documents and that gives now the correct mimetype.

The resaved file is now the same as I get from a running LO with UI.


My idea was to use something like
xmlDocPtr pXmlDoc = parseExport(aTempFile, "styles.xml");
OString
sPathStart("/office:document-styles/office:master-styles/draw:layer-set/draw:layer");
     assertXPath(pXmlDoc, sPathStart +
"[@draw:name='backgroundobjects']", "draw:protected", "true" );
I get something in pXmlDoc. How can I see, what I have got? I cannot get
nodes from it, e.g
getXPathNode(pXmlDoc,OString("/office:document-styles")) or
getXPathNode(pXmlDoc,"/office:document-styles") is already empty.

I solve this by constructing the path step by step, until it is what I want.
For example:

first try:
assertPath("/office:document-styles/");

second try I would add : master-styles:
assertPath("/office:document-styles/office:master-styles/");

third try I would add layer-set:
assertPath("/office:document-styles/office:master-styles/draw:layer-set/");

I have found the reason of my problem. assertXPath evaluates the attribute in the second parameter by calling method xmlGetProp. But that cannot handle attributes with prefix. So my solution is now to put the test into the predicate, e.g. assertXPath(pXmlDoc, sPathStart + "[@draw:name='backgroundobjects' and @draw:protected='true']");

It works basically now.

Kind regards
Regina

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.