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

Rohit Deshmukh rohit.deshmukh at synerzip.com
Wed Jan 8 01:17:34 PST 2014


 sw/qa/extras/ooxmlexport/data/FDO73034.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |    8 +++++
 sw/source/filter/ww8/attributeoutputbase.hxx |    2 -
 sw/source/filter/ww8/docxattributeoutput.cxx |   41 +++++++++++++++++++++++++--
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 -
 sw/source/filter/ww8/rtfattributeoutput.cxx  |    2 -
 sw/source/filter/ww8/rtfattributeoutput.hxx  |    2 -
 sw/source/filter/ww8/wrtw8nds.cxx            |   27 ++++++++++++++++-
 sw/source/filter/ww8/ww8attributeoutput.hxx  |    2 -
 9 files changed, 76 insertions(+), 10 deletions(-)

New commits:
commit 5201aa548165fb043b367fd58c647696942ae8df
Author: Rohit Deshmukh <rohit.deshmukh at synerzip.com>
Date:   Fri Dec 27 12:07:59 2013 +0530

    fdo#73034: Fix for Extra spacing in document.
    
    Cause:
     - Extra space gets added in document due to default <rPr>
       is getting removed from <pPr>.
    Implementation:
     - The 'rPr' inside 'pPr' means the properties of the 'paragraph marker'.
     - In that case - the paragraph marker will have different formatting then
       the rest of the runs in the paragraph.
     - Added default rpr tag in pPr.
    
    Reviewed on:
    	https://gerrit.libreoffice.org/7216
    
    Change-Id: I5a1a1f251ccc5b555ea6bf3bac3e69af8b2b69b5

diff --git a/sw/qa/extras/ooxmlexport/data/FDO73034.docx b/sw/qa/extras/ooxmlexport/data/FDO73034.docx
new file mode 100644
index 0000000..c3f8c92
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/FDO73034.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index fc7079a..eca2519 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2266,6 +2266,14 @@ DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, "textbox_picturefill.docx")
     CPPUNIT_ASSERT(!(getProperty<OUString>(xFrame,"BackGraphicURL")).isEmpty());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFDO73034, "FDO73034.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+    CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index d8b83e1..07a800f 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -161,7 +161,7 @@ public:
     virtual void StartParagraphProperties() = 0;
 
     /// Called after we end outputting the attributes.
-    virtual void EndParagraphProperties( const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted ) = 0;
+    virtual void EndParagraphProperties(const boost::shared_ptr<SfxItemSet> pParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted) = 0;
 
     /// Empty paragraph.
     virtual void EmptyParagraph() = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 020c84d..93370ea 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -80,6 +80,7 @@
 #include <svl/grabbagitem.hxx>
 #include <sfx2/sfxbasemodel.hxx>
 #include <tools/datetimeutils.hxx>
+#include <svl/whiter.hxx>
 
 #include <docufld.hxx>
 #include <flddropdown.hxx>
@@ -554,7 +555,7 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties()
     }
 }
 
-void DocxAttributeOutput::EndParagraphProperties( const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted )
+void DocxAttributeOutput::EndParagraphProperties( const boost::shared_ptr<SfxItemSet> pParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted)
 {
     // Call the 'Redline' function. This will add redline (change-tracking) information that regards to paragraph properties.
     // This includes changes like 'Bold', 'Underline', 'Strikethrough' etc.
@@ -563,11 +564,45 @@ void DocxAttributeOutput::EndParagraphProperties( const SwRedlineData* pRedlineD
     WriteCollectedParagraphProperties();
 
     // Write 'Paragraph Mark' properties
-    bool bIsParagraphMarkProperties = false; // In future - get the 'paragraph marker' properties as a parameter
-    if (bIsParagraphMarkProperties || pRedlineParagraphMarkerDeleted || pRedlineParagraphMarkerInserted)
+    if ( pRedlineParagraphMarkerDeleted || pRedlineParagraphMarkerInserted || pParagraphMarkerProperties)
     {
         m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
 
+        if(pParagraphMarkerProperties)
+        {
+            SfxWhichIter aIter( *pParagraphMarkerProperties );
+            sal_uInt16 nWhichId = aIter.FirstWhich();
+            const SfxPoolItem* pItem = 0;
+            while( nWhichId )
+            {
+                if( SFX_ITEM_SET == pParagraphMarkerProperties->GetItemState( nWhichId, sal_True, &pItem ))
+                {
+                    SAL_INFO( "sw.ww8", "nWhichId " << nWhichId);
+                    OutputItem( *pItem );
+                }
+                nWhichId = aIter.NextWhich();
+            }
+
+            // The 'm_pFontsAttrList', 'm_pEastAsianLayoutAttrList', 'm_pCharLangAttrList' are used to hold information
+            // that should be collected by different properties in the core, and are all flushed together
+            // to the DOCX when the function 'WriteCollectedRunProperties' gets called.
+            // So we need to store the current status of these lists, so that we can revert back to them when
+            // we are done exporting the redline attributes.
+            ::sax_fastparser::FastAttributeList *pFontsAttrList_Original           = m_pFontsAttrList;
+            ::sax_fastparser::FastAttributeList *pEastAsianLayoutAttrList_Original = m_pEastAsianLayoutAttrList;
+            ::sax_fastparser::FastAttributeList *pCharLangAttrList_Original        = m_pCharLangAttrList;
+            m_pFontsAttrList           = NULL;
+            m_pEastAsianLayoutAttrList = NULL;
+            m_pCharLangAttrList        = NULL;
+
+            // Write the collected run properties that are stored in 'm_pFontsAttrList', 'm_pEastAsianLayoutAttrList', 'm_pCharLangAttrList'
+            WriteCollectedRunProperties();
+
+            // Revert back the original values that were stored in 'm_pFontsAttrList', 'm_pEastAsianLayoutAttrList', 'm_pCharLangAttrList'
+            m_pFontsAttrList           = pFontsAttrList_Original;
+            m_pEastAsianLayoutAttrList = pEastAsianLayoutAttrList_Original;
+            m_pCharLangAttrList        = pCharLangAttrList_Original;
+        }
         if ( pRedlineParagraphMarkerDeleted )
         {
             StartRedline( pRedlineParagraphMarkerDeleted );
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 998f06f..2ceab5a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -141,7 +141,7 @@ public:
     virtual void StartParagraphProperties();
 
     /// Called after we end outputting the attributes.
-    virtual void EndParagraphProperties( const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted );
+    virtual void EndParagraphProperties( const boost::shared_ptr<SfxItemSet> pParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted);
 
     /// Start of the text run.
     virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index ed09334..b09440e 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -388,7 +388,7 @@ void RtfAttributeOutput::StartParagraphProperties()
         m_aSectionHeaders.append(aPar.makeStringAndClear());
 }
 
-void RtfAttributeOutput::EndParagraphProperties( const SwRedlineData* /*pRedlineData*/, const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData* /*pRedlineParagraphMarkerInserted*/ )
+void RtfAttributeOutput::EndParagraphProperties( const boost::shared_ptr<SfxItemSet> /*pParagraphMarkerProperties*/, const SwRedlineData* /*pRedlineData*/, const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData* /*pRedlineParagraphMarkerInserted*/)
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index b616f62..426f643 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -57,7 +57,7 @@ public:
     virtual void StartParagraphProperties();
 
     /// Called after we end outputting the attributes.
-    virtual void EndParagraphProperties( const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted );
+    virtual void EndParagraphProperties( const boost::shared_ptr<SfxItemSet> pParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted );
 
     /// Start of the text run.
     virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 967ad08..747d1ac 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2426,11 +2426,34 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
                 delete pNewSet;
         }
     }
-
+    boost::shared_ptr<SfxItemSet> sfxItemSet ;
+    if(const SwpHints* pTxtAttrs = rNode.GetpSwpHints())
+    {
+        for( sal_uInt16 i = 0; i < pTxtAttrs->Count(); i++ )
+        {
+            const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+            const sal_Int32* startPos = pHt->GetStart();    // first Attr characters
+            const sal_Int32* endPos = pHt->End();    // end Attr characters
+            // Check if these attributes are for the last character in the paragraph
+            // - which means the paragraph marker. If a paragraph has 7 characters,
+            // then properties on character 8 are for the paragraph marker
+            if( (startPos && endPos) && (*startPos == *endPos ) && (*endPos == rNode.GetTxt().getLength()) )
+            {
+                SAL_INFO( "sw.ww8", *startPos << "startPos == endPos" << *endPos);
+                sal_uInt16 nWhich = pHt->GetAttr().Which();
+                SAL_INFO( "sw.ww8", "nWhich" << nWhich);
+                if (nWhich == RES_TXTATR_AUTOFMT)
+                {
+                    const SwFmtAutoFmt& rAutoFmt = static_cast<const SwFmtAutoFmt&>(pHt->GetAttr());
+                    sfxItemSet = rAutoFmt.GetStyleHandle();
+                }
+            }
+        }
+    }
     const SwRedlineData* pRedlineParagraphMarkerDelete = AttrOutput().GetParagraphMarkerRedline( rNode, nsRedlineType_t::REDLINE_DELETE );
     const SwRedlineData* pRedlineParagraphMarkerInsert = AttrOutput().GetParagraphMarkerRedline( rNode, nsRedlineType_t::REDLINE_INSERT );
     const SwRedlineData* pParagraphRedlineData = aAttrIter.GetParagraphLevelRedline( );
-    AttrOutput().EndParagraphProperties( pParagraphRedlineData, pRedlineParagraphMarkerDelete, pRedlineParagraphMarkerInsert );
+    AttrOutput().EndParagraphProperties( sfxItemSet, pParagraphRedlineData, pRedlineParagraphMarkerDelete, pRedlineParagraphMarkerInsert);
 
     AttrOutput().EndParagraph( pTextNodeInfoInner );
 
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 72be7ae..924060b 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -42,7 +42,7 @@ public:
     virtual void StartParagraphProperties() {}
 
     /// Called after we end outputting the attributes.
-    virtual void EndParagraphProperties( const SwRedlineData* /*pRedlineData*/, const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData* /*pRedlineParagraphMarkerInserted*/ ) {}
+    virtual void EndParagraphProperties( const boost::shared_ptr<SfxItemSet> /*pParagraphMarkerProperties*/, const SwRedlineData* /*pRedlineData*/, const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData* /*pRedlineParagraphMarkerInserted*/) {}
 
     /// Empty paragraph.
     virtual void EmptyParagraph();


More information about the Libreoffice-commits mailing list