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

sushil_shinde sushil.shinde at synerzip.com
Mon Nov 11 02:19:44 PST 2013


 sw/qa/extras/ooxmlexport/data/TestVMLData.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx       |    8 ++
 sw/source/filter/ww8/docxattributeoutput.cxx   |   89 +++++++++++++++++--------
 sw/source/filter/ww8/docxattributeoutput.hxx   |   13 +++
 4 files changed, 82 insertions(+), 28 deletions(-)

New commits:
commit 7944301424aac0943e4ecc0410f495b210ad3b79
Author: sushil_shinde <sushil.shinde at synerzip.com>
Date:   Mon Oct 21 16:19:50 2013 +0530

    w:pict element was wrongly exported as child of w:rPr element.
    
    -added postpone method for vml export in docxattributeoutput
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    Reviewed on:
            https://gerrit.libreoffice.org/6366
    
    Change-Id: I37586447547e2e09028f7ae5009bcfaa87a35678

diff --git a/sw/qa/extras/ooxmlexport/data/TestVMLData.docx b/sw/qa/extras/ooxmlexport/data/TestVMLData.docx
new file mode 100644
index 0000000..a2f89b1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/TestVMLData.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ecbabb4..c19a70a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1580,6 +1580,14 @@ DECLARE_OOXML_TEST(testPgMargin, "testPgMargin.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgMar", "left", "1440");
 }
 
+DECLARE_OOXML_TEST(testVMLData, "TestVMLData.docx")
+{
+    // The problem was exporter was exporting vml data for shape in w:rPr element.
+    // vml data shoud not come under w:rPr element.
+    xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
+    CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/w:pict/v:shape", "stroked").match("f"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2ff5e61..19f80e7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1038,6 +1038,9 @@ void DocxAttributeOutput::StartRunProperties()
 
     OSL_ASSERT( m_postponedDiagram == NULL );
     m_postponedDiagram = new std::list< PostponedDiagram >;
+
+    OSL_ASSERT( m_postponedVMLDrawing == NULL );
+    m_postponedVMLDrawing = new std::list< PostponedVMLDrawing >;
 }
 
 void DocxAttributeOutput::InitCollectedRunProperties()
@@ -1155,6 +1158,9 @@ void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
     //We need to write w:drawing tag after the w:rPr.
     WritePostponedChart();
 
+    //We need to write w:drawing tag after the w:rPr.
+    WritePostponedVMLDrawing();
+
     // merge the properties _before_ the run text (strictly speaking, just
     // after the start of the run)
     m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
@@ -3220,6 +3226,55 @@ void DocxAttributeOutput::WritePostponedMath()
     m_postponedMath = NULL;
 }
 
+/*
+ * Write w:pict hierarchy  end element of w:rPr tag.
+ */
+void DocxAttributeOutput::WritePostponedVMLDrawing()
+{
+    if(m_postponedVMLDrawing == NULL)
+        return;
+
+    for( std::list< PostponedVMLDrawing >::iterator it = m_postponedVMLDrawing->begin();
+         it != m_postponedVMLDrawing->end();
+         ++it )
+    {
+        WriteVMLDrawing(it->object, *(it->frame), *(it->vpt));
+    }
+    delete m_postponedVMLDrawing;
+    m_postponedVMLDrawing = NULL;
+}
+
+void DocxAttributeOutput::WriteVMLDrawing( const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft )
+{
+   bool bSwapInPage = false;
+   if ( !(sdrObj)->GetPage() )
+   {
+       if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
+       {
+           if ( SdrPage *pPage = pModel->GetPage( 0 ) )
+           {
+               bSwapInPage = true;
+               const_cast< SdrObject* >( sdrObj )->SetPage( pPage );
+           }
+       }
+   }
+
+   m_pSerializer->startElementNS( XML_w, XML_pict, FSEND );
+
+   // See WinwordAnchoring::SetAnchoring(), these are not part of the SdrObject, have to be passed around manually.
+
+   SwFmtHoriOrient rHoriOri = (rFrmFmt).GetHoriOrient();
+   SwFmtVertOrient rVertOri = (rFrmFmt).GetVertOrient();
+   m_rExport.VMLExporter().AddSdrObject( *(sdrObj),
+        rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(),
+        rHoriOri.GetRelationOrient(),
+        rVertOri.GetRelationOrient(), (&rNdTopLeft) );
+   m_pSerializer->endElementNS( XML_w, XML_pict );
+
+   if ( bSwapInPage )
+       const_cast< SdrObject* >( sdrObj )->SetPage( 0 );
+}
+
 void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Point& rNdTopLeft )
 {
     m_pSerializer->mark();
@@ -3257,35 +3312,12 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po
                     }
                     else
                     {
-                        bool bSwapInPage = false;
-                        if ( !pSdrObj->GetPage() )
-                        {
-                            if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
-                            {
-                                if ( SdrPage *pPage = pModel->GetPage( 0 ) )
-                                {
-                                    bSwapInPage = true;
-                                    const_cast< SdrObject* >( pSdrObj )->SetPage( pPage );
-                                }
-                            }
+                        if ( m_postponedVMLDrawing == NULL )
+                            WriteVMLDrawing( pSdrObj, rFrame.GetFrmFmt(), rNdTopLeft);
+                        else // we are writing out attributes, but w:pict should not be inside w:rPr,
+                        {    // so write it out later
+                             m_postponedVMLDrawing->push_back( PostponedVMLDrawing( pSdrObj, &(rFrame.GetFrmFmt()), &rNdTopLeft ) );
                         }
-
-                        m_pSerializer->startElementNS( XML_w, XML_pict,
-                                FSEND );
-
-                        // See WinwordAnchoring::SetAnchoring(), these are not part of the SdrObject, have to be passed around manually.
-                        const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt();
-                        SwFmtHoriOrient rHoriOri = rFrmFmt.GetHoriOrient();
-                        SwFmtVertOrient rVertOri = rFrmFmt.GetVertOrient();
-                        m_rExport.VMLExporter().AddSdrObject( *pSdrObj,
-                                rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(),
-                                rHoriOri.GetRelationOrient(),
-                                rVertOri.GetRelationOrient(), &rNdTopLeft );
-
-                        m_pSerializer->endElementNS( XML_w, XML_pict );
-
-                        if ( bSwapInPage )
-                            const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
                     }
                 }
             }
@@ -6120,6 +6152,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_startedHyperlink( false ),
       m_postponedGraphic( NULL ),
       m_postponedDiagram( NULL ),
+      m_postponedVMLDrawing(NULL),
       m_postponedMath( NULL ),
       m_postponedChart( NULL ),
       pendingPlaceholder( NULL ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 9cb14f5..02f7761 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -371,6 +371,8 @@ private:
     /// writes a diagram
     void WriteDiagram(const SdrObject* sdrObject, const Size& size);
 
+    /// writes VML data
+    void WriteVMLDrawing( const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft );
     void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
     void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
     void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
@@ -637,6 +639,7 @@ private:
     void WritePostponedMath();
     void WritePostponedDiagram();
     void WritePostponedChart();
+    void WritePostponedVMLDrawing();
     void WriteCommentRanges();
 
     void StartField_Impl( FieldInfos& rInfos, bool bWriteRun = sal_False );
@@ -736,6 +739,16 @@ private:
         Size size;
     };
     std::list< PostponedDiagram >* m_postponedDiagram;
+
+    struct PostponedVMLDrawing
+    {
+        PostponedVMLDrawing( const SdrObject* sdrObj, const SwFrmFmt* frm, const Point* pt ) : object( sdrObj ), frame( frm ), vpt( pt ) {};
+        const SdrObject* object;
+        const SwFrmFmt* frame;
+        const Point* vpt;
+    };
+    std::list< PostponedVMLDrawing >* m_postponedVMLDrawing;
+
     const SwOLENode* m_postponedMath;
     const SdrObject* m_postponedChart;
     Size m_postponedChartSize;


More information about the Libreoffice-commits mailing list