sw/qa/extras/ooxmlexport/data/fdo83057.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx    |   16 ++++++++++++++++
 sw/source/filter/ww8/attributeoutputbase.hxx |    2 ++
 sw/source/filter/ww8/docxattributeoutput.cxx |    8 +++++++-
 sw/source/filter/ww8/docxattributeoutput.hxx |    3 +++
 sw/source/filter/ww8/wrtw8nds.cxx            |    1 +
 6 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit e6b295e55d82f236206c24f5cf1dcc314c34b20f
Author: Vinaya Mandke <vinaya.man...@synerzip.com>
Date:   Thu Aug 28 11:29:06 2014 +0530

    fdo#83057 File corrupts on save, as SDT is added incorrectly
    
    A fly frame was attached to a para which started within a hint (run) 
containing an SDT.
    This SDT was handled while exporting the FLYFRAME and also the text of the 
run.
    So, eventhough the original file had only one sdt in the header, the RT 
file had two;
    one for a seperate run as expected, and one incorrectly exported in the 
alternateContent (FLYFRAME)
    
    So don't collect SDTPr from grabbag if the FLY is not processed.
    As, the SDT will be handled when the run is exported.
    
    Change-Id: I7b3c94208c171afbec54467fd6b756a6e30c816b
    Reviewed-on: https://gerrit.libreoffice.org/11161
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/fdo83057.docx 
b/sw/qa/extras/ooxmlexport/data/fdo83057.docx
new file mode 100644
index 0000000..d4d4232
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo83057.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 27de7ee..21b8976 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -684,6 +684,22 @@ DECLARE_OOXMLEXPORT_TEST(testSdt2Run, "sdt-2-run.docx")
     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFD083057, "fdo83057.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
+    if (!pXmlDoc)
+        return;
+
+    // A fly frame was attached to a para which started with a hint (run) 
containing an SDT.
+    // This SDT was handled while exporting the FLYFRAME and also the text of 
the run.
+    // So, eventhough the original file had only one sdt in the header, the RT 
file had two;
+    // one for a seperate run as expected, and one incorrectly exported in the 
alternateContent (FLYFRAME)
+
+    // Assert that the file has only one sdt, in a seperate run
+    assertXPath(pXmlDoc, "//w:sdt", 1);
+    assertXPath(pXmlDoc, "//mc:AlternateContent//w:sdt", 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx 
b/sw/source/filter/ww8/attributeoutputbase.hxx
index a32a4ba..93b6aaa 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -309,6 +309,8 @@ public:
     /// Has different headers/footers for the title page.
     virtual void SectionTitlePage() = 0;
 
+    /// Set the state of the Fly at current position
+    virtual void SetStateOfFlyFrame( sal_Int16 /*nStateOfFlyFrame*/ ){};
     /// If the node has an anchor linked.
     virtual void SetAnchorIsLinkedToNode( bool /*bAnchorLinkedToNode*/){};
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index b4587e8..518ce24 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -969,6 +969,11 @@ void DocxAttributeOutput::EndParagraphProperties( const 
SfxItemSet* pParagraphMa
     m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
 }
 
+void DocxAttributeOutput::SetStateOfFlyFrame( sal_Int16 nStateOfFlyFrame )
+{
+    m_nStateOfFlyFrame = nStateOfFlyFrame;
+}
+
 void DocxAttributeOutput::SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode )
 {
     m_bAnchorLinkedToNode = bAnchorLinkedToNode ;
@@ -8145,7 +8150,7 @@ void DocxAttributeOutput::CharGrabBag( const 
SfxGrabBagItem& rItem )
             if (m_bStartedCharSdt)
                 m_bEndCharSdt = true;
         }
-        else if (i->first == "SdtPr")
+        else if (i->first == "SdtPr" && FLY_NOT_PROCESSED != 
m_nStateOfFlyFrame )
         {
             uno::Sequence<beans::PropertyValue> aGrabBagSdt =
                     i->second.get< uno::Sequence<beans::PropertyValue> >();
@@ -8286,6 +8291,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport 
&rExport, FSHelperPtr pSeri
     , m_pParagraphSdtPrTokenAttributes(NULL)
     , m_pParagraphSdtPrDataBindingAttrs(NULL)
     , m_nRunSdtPrToken(0)
+    , m_nStateOfFlyFrame( FLY_NOT_PROCESSED )
     , m_pRunSdtPrTokenChildren(NULL)
     , m_pRunSdtPrDataBindingAttrs(NULL)
     , m_bParagraphSdtHasId(false)
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 1277203..51f775c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -215,6 +215,7 @@ public:
     /// End of the tag that encloses the run.
     void EndRedline( const SwRedlineData * pRedlineData );
 
+    virtual void SetStateOfFlyFrame( sal_Int16 nStateOfFlyFrame ) SAL_OVERRIDE;
     virtual void SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode = false ) 
SAL_OVERRIDE;
     virtual bool IsFlyProcessingPostponed() SAL_OVERRIDE;
     virtual void ResetFlyProcessingFlag() SAL_OVERRIDE;
@@ -907,6 +908,8 @@ private:
     ::sax_fastparser::FastAttributeList *m_pParagraphSdtPrDataBindingAttrs;
     /// members to control the existence of grabbagged SDT properties in the 
text run
     sal_Int32 m_nRunSdtPrToken;
+    /// State of the Fly at current position
+    sal_Int16 m_nStateOfFlyFrame;
     ::sax_fastparser::FastAttributeList *m_pRunSdtPrTokenChildren;
     ::sax_fastparser::FastAttributeList *m_pRunSdtPrDataBindingAttrs;
     /// Value of the <w:alias> paragraph SDT element.
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index c51d4ca..d03b1b4 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2077,6 +2077,7 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& 
rNode )
             bPostponeWritingText = true ;
 
         nStateOfFlyFrame = aAttrIter.OutFlys( nAktPos );
+        AttrOutput().SetStateOfFlyFrame( nStateOfFlyFrame );
         AttrOutput().SetAnchorIsLinkedToNode( bPostponeWritingText && 
(FLY_POSTPONED != nStateOfFlyFrame) );
         // Append bookmarks in this range after flys, exclusive of final
         // position of this range
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to