[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Sep 27 02:23:11 PDT 2013


 sw/qa/extras/ooxmlexport/data/fdo69636.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   35 +++++++++++++++++++++----
 sw/source/filter/ww8/docxattributeoutput.cxx |   37 +++++++++++++++++++++++++--
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 +
 4 files changed, 66 insertions(+), 8 deletions(-)

New commits:
commit 3da8490e6ca18072ce537bc6e00c198007df229b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 27 10:49:07 2013 +0200

    fdo#69636 VML export: handle mso-layout-flow-alt shape prop for sw frames
    
    Change-Id: Iec798b3db23883d34bfbaff0003330f013df1a3e

diff --git a/sw/qa/extras/ooxmlexport/data/fdo69636.docx b/sw/qa/extras/ooxmlexport/data/fdo69636.docx
new file mode 100644
index 0000000..b2f3069
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo69636.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index e252353..cc4131e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -120,6 +120,7 @@ public:
     void testCharacterBorder();
     void testStyleInheritance();
     void testSmartart();
+    void testFdo69636();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -154,6 +155,11 @@ private:
      * Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
      */
     void assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes);
+
+    /**
+     * Same as the assertXPath(), but don't assert: return the string instead.
+     */
+    OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
 };
 
 void Test::run()
@@ -232,6 +238,7 @@ void Test::run()
         {"charborder.odt", &Test::testCharacterBorder},
         {"style-inheritance.docx", &Test::testStyleInheritance},
         {"smartart.docx", &Test::testSmartart},
+        {"fdo69636.docx", &Test::testFdo69636},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -289,12 +296,7 @@ xmlNodeSetPtr Test::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath)
 
 void Test::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute, const OUString& rExpectedValue)
 {
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-    CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
-    if (rAttribute.isEmpty())
-        return;
-    xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
-    OUString aValue = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
+    OUString aValue = getXPath(pXmlDoc, rXPath, rAttribute);
     CPPUNIT_ASSERT_EQUAL(rExpectedValue, aValue);
 }
 
@@ -304,6 +306,16 @@ void Test::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNo
     CPPUNIT_ASSERT_EQUAL(nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes));
 }
 
+OUString Test::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
+{
+    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
+    CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
+    if (rAttribute.isEmpty())
+        return OUString();
+    xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
+    return OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
+}
+
 void Test::testZoom()
 {
     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
@@ -1469,6 +1481,17 @@ void Test::testSmartart()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
 }
 
+void Test::testFdo69636()
+{
+    /*
+     * The problem was that the exporter didn't mirror the workaround of the
+     * importer, regarding the btLr text frame direction: the
+     * mso-layout-flow-alt property was completely missing in the output.
+     */
+    xmlDocPtr pXmlDoc = parseExport();
+    CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:pict/v:rect/v:textbox", "style").match("mso-layout-flow-alt:bottom-to-top"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2e01341..42d178a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -100,6 +100,7 @@
 #include <swtable.hxx>
 #include <txtftn.hxx>
 #include <txtinet.hxx>
+#include <fmtautofmt.hxx>
 
 #include <osl/file.hxx>
 #include <rtl/tencinfo.h>
@@ -313,6 +314,35 @@ public:
     }
 };
 
+// Undo the text direction mangling done by the frame btLr handler in writerfilter::dmapper::DomainMapper::lcl_startCharacterGroup()
+bool lcl_checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttributeList* pTextboxAttrList)
+{
+    if (!pStartNode->IsTxtNode())
+        return false;
+
+    SwTxtNode* pTxtNode = static_cast<SwTxtNode*>(pStartNode);
+    if (!pTxtNode->HasHints())
+        return false;
+
+    SwTxtAttr* pTxtAttr = pTxtNode->GetSwpHints().GetStart(0);
+
+    if (!pTxtAttr)
+        return false;
+
+    boost::shared_ptr<SfxItemSet> pItemSet = pTxtAttr->GetAutoFmt().GetStyleHandle();
+    const SfxPoolItem* pItem;
+    if (pItemSet->GetItemState(RES_CHRATR_ROTATE, true, &pItem) == SFX_ITEM_SET)
+    {
+        const SvxCharRotateItem& rCharRotate = static_cast<const SvxCharRotateItem&>(*pItem);
+        if (rCharRotate.GetValue() == 900)
+        {
+            pTextboxAttrList->add(XML_style, "mso-layout-flow-alt:bottom-to-top");
+            return true;
+        }
+    }
+    return false;
+}
+
 void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
 {
     // write the paragraph properties + the run, already in the correct order
@@ -349,6 +379,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
         m_pFlyAttrList->add(XML_style, m_aTextFrameStyle.makeStringAndClear());
         XFastAttributeListRef xFlyAttrList( m_pFlyAttrList );
         m_pFlyAttrList = NULL;
+        m_bFrameBtLr = lcl_checkFrameBtlr(m_rExport.pDoc->GetNodes()[nStt], m_pTextboxAttrList);
         XFastAttributeListRef xTextboxAttrList(m_pTextboxAttrList);
         m_pTextboxAttrList = NULL;
         m_bTextFrameSyntax = false;
@@ -381,6 +412,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
         m_pSerializer->endElementNS( XML_v, XML_rect );
         m_pSerializer->endElementNS( XML_w, XML_pict );
         m_pSerializer->endElementNS( XML_w, XML_r );
+        m_bFrameBtLr = false;
     }
 
     m_pSerializer->endElementNS( XML_w, XML_p );
@@ -4264,7 +4296,7 @@ void DocxAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
 void DocxAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate)
 {
     // Not rorated or we the rotation already handled?
-    if ( !rRotate.GetValue() || m_bBtLr)
+    if ( !rRotate.GetValue() || m_bBtLr || m_bFrameBtLr)
         return;
 
     if (!m_pEastAsianLayoutAttrList)
@@ -5691,7 +5723,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_postitFieldsMaxId( 0 ),
       m_anchorId( 0 ),
       m_nextFontId( 1 ),
-      m_bBtLr(false)
+      m_bBtLr(false),
+      m_bFrameBtLr(false)
 {
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 01ea79a..5abb063 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -725,6 +725,8 @@ private:
 
     /// Is fake rotation detected, so rotation with 90 degrees should be ignored in this cell?
     bool m_bBtLr;
+    /// Same, but for textframe rotation.
+    bool m_bFrameBtLr;
 
     PageMargins m_pageMargins;
 


More information about the Libreoffice-commits mailing list