sw/qa/extras/ooxmlexport/data/textframes.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 +++ sw/source/filter/ww8/docxattributeoutput.cxx | 68 ++++++++++++++++++++++----- sw/source/filter/ww8/docxattributeoutput.hxx | 2 4 files changed, 68 insertions(+), 12 deletions(-)
New commits: commit 4a787e2078ca1a19e065cb356fc80f421213ad87 Author: Miklos Vajna <[email protected]> Date: Tue Jan 22 09:36:00 2013 +0100 sw: DOCX export of TextFrames testcase Change-Id: Ie46a2627d247fb293606c6deab3254113b741336 diff --git a/sw/qa/extras/ooxmlexport/data/textframes.odt b/sw/qa/extras/ooxmlexport/data/textframes.odt new file mode 100644 index 0000000..301744a Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/textframes.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index a6a7783..c1fd412 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -68,6 +68,7 @@ public: void testFdo51550(); void testN789482(); void test1Table1Page(); + void testTextFrames(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -107,6 +108,7 @@ void Test::run() {"fdo51550.odt", &Test::testFdo51550}, {"n789482.docx", &Test::testN789482}, // {"1-table-1-page.docx", &Test::test1Table1Page}, // doesn't work on openSUSE12.2 at least + {"textframes.odt", &Test::testTextFrames}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -509,6 +511,14 @@ void Test::test1Table1Page() CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); } +void Test::testTextFrames() +{ + // The frames were simply missing, so let's check if all 3 frames were imported back. + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit a2bee4547a4997759e41aed8de0f2af95460a732 Author: Miklos Vajna <[email protected]> Date: Mon Jan 21 16:47:34 2013 +0100 sw: DOCX export of TextFrame size/position Change-Id: Ie830fe9f7276fbc8f20e7d37424116d6653a6931 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ca11d99..416063a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -272,9 +272,14 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT m_rExport.mpParentFrame = pParentFrame; + m_bTextFrameSyntax = true; + m_aTextFrameStyle = "position:absolute"; + m_rExport.OutputFormat( pParentFrame->GetFrmFmt(), false, false, true ); + m_bTextFrameSyntax = false; + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); m_pSerializer->startElementNS( XML_w, XML_pict, FSEND ); - m_pSerializer->startElementNS( XML_v, XML_rect, FSEND ); + m_pSerializer->startElementNS( XML_v, XML_rect, XML_style, m_aTextFrameStyle.makeStringAndClear(), FSEND ); m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND ); m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND ); m_rExport.WriteText( ); @@ -4168,7 +4173,12 @@ void DocxAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid ) void DocxAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) { - if ( m_rExport.bOutFlyFrmAttrs ) + if (m_bTextFrameSyntax) + { + m_aTextFrameStyle.append(";width:").append(double(rSize.GetWidth()) / 20); + m_aTextFrameStyle.append("pt;height:").append(double(rSize.GetHeight()) / 20).append("pt"); + } + else if ( m_rExport.bOutFlyFrmAttrs ) { if ( !m_pFlyAttrList ) m_pFlyAttrList = m_pSerializer->createAttrList( ); @@ -4212,7 +4222,10 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) { bool bEcma = m_rExport.GetFilter().getVersion( ) == oox::core::ECMA_DIALECT; - if ( m_rExport.bOutFlyFrmAttrs ) + if (m_bTextFrameSyntax) + { + } + else if ( m_rExport.bOutFlyFrmAttrs ) { if ( !m_pFlyAttrList ) m_pFlyAttrList = m_pSerializer->createAttrList(); @@ -4260,7 +4273,10 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) { - if ( m_rExport.bOutFlyFrmAttrs ) + if (m_bTextFrameSyntax) + { + } + else if ( m_rExport.bOutFlyFrmAttrs ) { if ( !m_pFlyAttrList ) m_pFlyAttrList = m_pSerializer->createAttrList(); @@ -4320,7 +4336,10 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) { - if ( m_rExport.bOutFlyFrmAttrs ) + if (m_bTextFrameSyntax) + { + } + else if ( m_rExport.bOutFlyFrmAttrs ) { if ( !m_pFlyAttrList ) m_pFlyAttrList = m_pSerializer->createAttrList(); @@ -4348,7 +4367,11 @@ void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert ) { - if ( m_rExport.bOutFlyFrmAttrs ) + if (m_bTextFrameSyntax) + { + m_aTextFrameStyle.append(";margin-top:").append(double(rFlyVert.GetPos()) / 20).append("pt"); + } + else if ( m_rExport.bOutFlyFrmAttrs ) { if ( !m_pFlyAttrList ) m_pFlyAttrList = m_pSerializer->createAttrList(); @@ -4406,7 +4429,11 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori ) { - if ( m_rExport.bOutFlyFrmAttrs ) + if (m_bTextFrameSyntax) + { + m_aTextFrameStyle.append(";margin-left:").append(double(rFlyHori.GetPos()) / 20).append("pt"); + } + else if ( m_rExport.bOutFlyFrmAttrs ) { if ( !m_pFlyAttrList ) m_pFlyAttrList = m_pSerializer->createAttrList(); @@ -4478,6 +4505,8 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) { + if (m_bTextFrameSyntax) + return; if ( !m_bOpenedSectPr ) { @@ -4663,6 +4692,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_bParagraphOpened( false ), m_nColBreakStatus( COLBRK_NONE ), m_pParentFrame( NULL ), + m_bTextFrameSyntax( false ), m_closeHyperlinkInThisRun( false ), m_closeHyperlinkInPreviousRun( false ), m_startedHyperlink( false ), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index f42ffdf..26b43ac 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -601,6 +601,8 @@ private: DocxColBreakStatus m_nColBreakStatus; sw::Frame *m_pParentFrame; + bool m_bTextFrameSyntax; + OStringBuffer m_aTextFrameStyle; // close of hyperlink needed bool m_closeHyperlinkInThisRun; bool m_closeHyperlinkInPreviousRun; commit 736c25a9d372dd1761d3352240164c969fd3ed1d Author: Miklos Vajna <[email protected]> Date: Mon Jan 21 12:48:19 2013 +0100 sw: initial DOCX export of TextFrames as VML rectangles Change-Id: I0b204e9a81aad3e4f5fafc17bbd0c3935eb5cdb5 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ae4770a..ca11d99 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -255,12 +255,6 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT { // write the paragraph properties + the run, already in the correct order m_pSerializer->mergeTopMarks(); - m_pSerializer->endElementNS( XML_w, XML_p ); - - // Check for end of cell, rows, tables here - FinishTableRowCell( pTextNodeInfoInner ); - - m_bParagraphOpened = false; // Write the anchored frame if any if ( m_pParentFrame ) @@ -278,12 +272,32 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT m_rExport.mpParentFrame = pParentFrame; + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->startElementNS( XML_w, XML_pict, FSEND ); + m_pSerializer->startElementNS( XML_v, XML_rect, FSEND ); + m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND ); + m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND ); m_rExport.WriteText( ); + m_pSerializer->endElementNS( XML_w, XML_txbxContent ); + m_pSerializer->endElementNS( XML_v, XML_textbox ); + m_pSerializer->endElementNS( XML_v, XML_rect ); + m_pSerializer->endElementNS( XML_w, XML_pict ); + m_pSerializer->endElementNS( XML_w, XML_r ); m_rExport.RestoreData(); + m_rExport.mpParentFrame = NULL; + delete pParentFrame; } + + m_pSerializer->endElementNS( XML_w, XML_p ); + + // Check for end of cell, rows, tables here + FinishTableRowCell( pTextNodeInfoInner ); + + m_bParagraphOpened = false; + } void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph ) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
