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

Miklos Vajna vmiklos at suse.cz
Thu Jul 11 02:27:21 PDT 2013


 sw/qa/extras/ooxmlexport/data/fdo58577.odt   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   10 ++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   15 +++++++--------
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 +-
 4 files changed, 18 insertions(+), 9 deletions(-)

New commits:
commit e5b145a46cd29c9428e6e1894f7b0bb8248a412f
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jul 11 10:43:07 2013 +0200

    fdo#58577 DOCX export: handle multiple textframes anchored to the same para
    
    Also fixes ~SwIndexReg assertion on closing the document.
    
    Change-Id: I7c1a9d3d646f2dacdbced2af355c076c1a1063ec

diff --git a/sw/qa/extras/ooxmlexport/data/fdo58577.odt b/sw/qa/extras/ooxmlexport/data/fdo58577.odt
new file mode 100644
index 0000000..4c8656d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo58577.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 4af6477..9535083 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -93,6 +93,7 @@ public:
     void testN822175();
     void testFdo66688();
     void testFdo66773();
+    void testFdo58577();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -156,6 +157,7 @@ void Test::run()
         {"n822175.odt", &Test::testN822175},
         {"fdo66688.docx", &Test::testFdo66688},
         {"fdo66773.docx", &Test::testFdo66773},
+        {"fdo58577.odt", &Test::testFdo58577},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -933,6 +935,14 @@ void Test::testFdo66773()
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(100), static_cast<sal_Int32>(alineSpacing.Height));
 }
 
+void Test::testFdo58577()
+{
+    // The second frame was simply missing, so let's check if both 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(2), xIndexAccess->getCount());
+}
+
 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 cab5cdf..9957ff4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -293,10 +293,13 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
     m_pSerializer->mergeTopMarks();
 
     // Write the anchored frame if any
-    if ( m_pParentFrame )
+    // Make a copy and clear the original early, as this method is called
+    // recursively for in-frame paragraphs
+    std::vector<sw::Frame> aParentFrames = m_aParentFrames;
+    m_aParentFrames.clear();
+    for (size_t i = 0; i < aParentFrames.size(); ++i)
     {
-        sw::Frame *pParentFrame = m_pParentFrame;
-        m_pParentFrame = NULL;
+        sw::Frame* pParentFrame = &aParentFrames[i];
 
         const SwFrmFmt& rFrmFmt = pParentFrame->GetFrmFmt( );
         const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
@@ -356,8 +359,6 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
         m_rExport.RestoreData();
 
         m_rExport.mpParentFrame = NULL;
-
-        delete pParentFrame;
     }
 
     m_pSerializer->endElementNS( XML_w, XML_p );
@@ -2772,7 +2773,7 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po
         case sw::Frame::eTxtBox:
             {
                 // The frame output is postponed to the end of the anchor paragraph
-                m_pParentFrame = new sw::Frame(rFrame);
+                m_aParentFrames.push_back(sw::Frame(rFrame));
             }
             break;
         case sw::Frame::eOle:
@@ -5162,7 +5163,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_nTableDepth( 0 ),
       m_bParagraphOpened( false ),
       m_nColBreakStatus( COLBRK_NONE ),
-      m_pParentFrame( NULL ),
       m_bTextFrameSyntax( false ),
       m_closeHyperlinkInThisRun( false ),
       m_closeHyperlinkInPreviousRun( false ),
@@ -5192,7 +5192,6 @@ DocxAttributeOutput::~DocxAttributeOutput()
     delete m_pEndnotesList, m_pEndnotesList = NULL;
 
     delete m_pTableWrt, m_pTableWrt = NULL;
-    delete m_pParentFrame;
 }
 
 DocxExport& DocxAttributeOutput::GetExport()
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index c423275..06f12fa 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -642,7 +642,7 @@ private:
     // beginning of the next paragraph
     DocxColBreakStatus m_nColBreakStatus;
 
-    sw::Frame *m_pParentFrame;
+    std::vector<sw::Frame> m_aParentFrames;
     bool m_bTextFrameSyntax;
     OStringBuffer m_aTextFrameStyle;
     // close of hyperlink needed


More information about the Libreoffice-commits mailing list