[Libreoffice-commits] .: 3 commits - sw/qa sw/source

Lubos Lunak llunak at kemper.freedesktop.org
Wed May 23 06:54:17 PDT 2012


 sw/qa/extras/ooxmltok/data/n747461.docx      |binary
 sw/qa/extras/ooxmltok/ooxmltok.cxx           |   36 +++++++++++++++++++++++++++
 sw/source/core/unocore/unoframe.cxx          |    4 ++-
 sw/source/filter/ww8/docxattributeoutput.cxx |   24 ++++++++----------
 4 files changed, 50 insertions(+), 14 deletions(-)

New commits:
commit 10bdf6aa45f26f09e83f4c0035d27a4ddcd9151a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed May 23 15:51:41 2012 +0200

    testcase for proper .docx ZOrder import
    
    Change-Id: I0f025114af5f79f5bd04637ffdf864cef75eb821

diff --git a/sw/qa/extras/ooxmltok/data/n747461.docx b/sw/qa/extras/ooxmltok/data/n747461.docx
new file mode 100644
index 0000000..1064e5d
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n747461.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 4defe5d..da85c14 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -58,6 +58,7 @@ public:
     void testN751077();
     void testN705956_1();
     void testN705956_2();
+    void testN747461();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -70,6 +71,7 @@ public:
     CPPUNIT_TEST(testN751077);
     CPPUNIT_TEST(testN705956_1);
     CPPUNIT_TEST(testN705956_2);
+    CPPUNIT_TEST(testN747461);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -285,6 +287,40 @@ xray image.FillColor
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xc0504d ), fillColor );
 }
 
+void Test::testN747461()
+{
+    load( "n747461.docx" );
+/*
+The document contains 3 images (Red, Black, Green, in this order), with explicit
+w:relativeHeight (300, 0, 225763766). Check that they are in the right ZOrder
+after they are loaded.
+*/
+    uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPageSupplier> drawPageSupplier(textDocument, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> drawPage = drawPageSupplier->getDrawPage();
+    uno::Reference<drawing::XShape> image1, image2, image3;
+    drawPage->getByIndex( 0 ) >>= image1;
+    drawPage->getByIndex( 1 ) >>= image2;
+    drawPage->getByIndex( 2 ) >>= image3;
+    sal_Int32 zOrder1, zOrder2, zOrder3;
+    OUString descr1, descr2, descr3;
+    uno::Reference<beans::XPropertySet> imageProperties1(image1, uno::UNO_QUERY);
+    imageProperties1->getPropertyValue( "ZOrder" ) >>= zOrder1;
+    imageProperties1->getPropertyValue( "Description" ) >>= descr1;
+    uno::Reference<beans::XPropertySet> imageProperties2(image2, uno::UNO_QUERY);
+    imageProperties2->getPropertyValue( "ZOrder" ) >>= zOrder2;
+    imageProperties2->getPropertyValue( "Description" ) >>= descr2;
+    uno::Reference<beans::XPropertySet> imageProperties3(image3, uno::UNO_QUERY);
+    imageProperties3->getPropertyValue( "ZOrder" ) >>= zOrder3;
+    imageProperties3->getPropertyValue( "Description" ) >>= descr3;
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), zOrder1 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), zOrder2 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 2 ), zOrder3 );
+    CPPUNIT_ASSERT_EQUAL( OUString( "Black" ), descr1 );
+    CPPUNIT_ASSERT_EQUAL( OUString( "Red" ), descr2 );
+    CPPUNIT_ASSERT_EQUAL( OUString( "Green" ), descr3 );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 9365a3255875eb75923903c8b3d47066aa679c3b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed May 23 15:44:02 2012 +0200

    fix UNO ZOrder reading, take #2
    
    This is almost a revert of e05e77f4b7373b686f02cc51c7003e72efb07053.
    It turns out FindRealSdrObject() is mostly the right method to call
    (possibly except when creating the document, which is what lead
    to the first commit).
    
    Change-Id: Iea9ccc99e785fbff47f2d41187326d4e6d355494

diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 91c8d89..6b9c92a 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1598,7 +1598,9 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
         }
         else if(FN_UNO_Z_ORDER == pEntry->nWID)
         {
-            const SdrObject* pObj = pFmt->FindSdrObject();
+            const SdrObject* pObj = pFmt->FindRealSdrObject();
+            if( pObj == NULL )
+                pObj = pFmt->FindSdrObject();
             if( pObj )
             {
                 aAny <<= (sal_Int32)pObj->GetOrdNum();
commit 597000c2edc3c3fb40134e892a5e9ceec0d83296
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed May 23 14:33:55 2012 +0200

    write out the same data to pic:cNvPr like to wp:docPr
    
    Change-Id: I4180b4d291b7a4ed496c7c57ca0fd0034dc2ed94

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 15b7153..6fa3ae1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2102,14 +2102,15 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
                 break;
         }
     }
-    // picture description
-    ::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList();
-    attrList->add( XML_id, OString::valueOf( sal_Int32( m_anchorId++ )).getStr());
-    attrList->add( XML_name, "Picture" );
-    attrList->add( XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr());
+    // picture description (used for pic:cNvPr later too)
+    ::sax_fastparser::FastAttributeList* docPrattrList = m_pSerializer->createAttrList();
+    docPrattrList->add( XML_id, OString::valueOf( sal_Int32( m_anchorId++ )).getStr());
+    docPrattrList->add( XML_name, "Picture" );
+    docPrattrList->add( XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr());
     if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
-        attrList->add( XML_title, OUStringToOString( rGrfNode.GetTitle(), RTL_TEXTENCODING_UTF8 ).getStr());
-    m_pSerializer->startElementNS( XML_wp, XML_docPr, XFastAttributeListRef( attrList ));
+        docPrattrList->add( XML_title, OUStringToOString( rGrfNode.GetTitle(), RTL_TEXTENCODING_UTF8 ).getStr());
+    XFastAttributeListRef docPrAttrListRef( docPrattrList );
+    m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrAttrListRef );
     // TODO hyperlink
     // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick,
     //         FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
@@ -2139,12 +2140,9 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
 
     m_pSerializer->startElementNS( XML_pic, XML_nvPicPr,
             FSEND );
-    // TODO the right image description
-    m_pSerializer->startElementNS( XML_pic, XML_cNvPr,
-            XML_id, "0",
-            XML_name, "Picture",
-            XML_descr, "A description...",
-            FSEND );
+    // It seems pic:cNvpr and wp:docPr are pretty much the same thing with the same attributes
+    m_pSerializer->startElementNS( XML_pic, XML_cNvPr, docPrAttrListRef );
+
     // TODO hyperlink
     // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick,
     //     FSNS( XML_r, XML_id ), "rId4",


More information about the Libreoffice-commits mailing list