diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-09-27 10:49:07 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-09-27 11:25:09 +0200 |
commit | 3da8490e6ca18072ce537bc6e00c198007df229b (patch) | |
tree | d5886807ec5f7ab7fa68155d80b35383d7e8eabe | |
parent | 13ef725dfc798aa10f7b370f016d0cd4147d83ba (diff) |
fdo#69636 VML export: handle mso-layout-flow-alt shape prop for sw frames
Change-Id: Iec798b3db23883d34bfbaff0003330f013df1a3e
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo69636.docx | bin | 0 -> 23779 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 35 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 37 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 |
4 files changed, 66 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo69636.docx b/sw/qa/extras/ooxmlexport/data/fdo69636.docx Binary files differnew file mode 100644 index 000000000000..b2f3069b5020 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo69636.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index e2523532f484..cc4131e0fbc9 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 2e01341c81ed..42d178aa633f 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 01ea79a1a202..5abb0632074b 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; |