kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0102-cp-2013101510000026-doc-export-of-commented-text-ran.patch

f0633d
From d3a5776b00ee07ac371dd180a6d962d50da4baf5 Mon Sep 17 00:00:00 2001
f0633d
From: =?UTF-8?q?Zolnai=20Tam=C3=A1s?= <tamas.zolnai@collabora.com>
f0633d
Date: Fri, 3 Jan 2014 15:21:32 +0100
f0633d
Subject: [PATCH 102/109] cp#2013101510000026: doc export of commented text
f0633d
 ranges
f0633d
f0633d
(cherry picked from commit 5969eec0e998804eba77338b17de90737e2acb43)
f0633d
f0633d
Conflicts:
f0633d
	sw/qa/extras/ww8export/ww8export.cxx
f0633d
	sw/qa/extras/ww8import/ww8import.cxx
f0633d
	sw/source/filter/ww8/wrtw8sty.cxx
f0633d
	sw/source/filter/ww8/ww8attributeoutput.hxx
f0633d
f0633d
(cherry picked from commit 765d89aa149e9afc78382e24bf7c86f70b1584ff)
f0633d
f0633d
Change-Id: I2d31da5d659edcbebc682d5604d2db24b5e341fb
f0633d
---
f0633d
 sw/qa/extras/ww8export/data/fdo59530.doc    | Bin 0 -> 9728 bytes
f0633d
 sw/qa/extras/ww8export/ww8export.cxx        |  27 ++++++++
f0633d
 sw/qa/extras/ww8import/data/fdo59530.doc    | Bin 22528 -> 0 bytes
f0633d
 sw/qa/extras/ww8import/ww8import.cxx        |  26 -------
f0633d
 sw/source/filter/ww8/wrtw8sty.cxx           | 104 ++++++++++++++++++++++++++--
f0633d
 sw/source/filter/ww8/wrtww8.hxx             |   8 ++-
f0633d
 sw/source/filter/ww8/ww8atr.cxx             |   5 ++
f0633d
 sw/source/filter/ww8/ww8attributeoutput.hxx |   2 +
f0633d
 8 files changed, 139 insertions(+), 33 deletions(-)
f0633d
 create mode 100644 sw/qa/extras/ww8export/data/fdo59530.doc
f0633d
 delete mode 100755 sw/qa/extras/ww8import/data/fdo59530.doc
f0633d
f0633d
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
f0633d
index 50ef934..3311563 100644
f0633d
--- a/sw/qa/extras/ww8import/ww8import.cxx
f0633d
+++ b/sw/qa/extras/ww8import/ww8import.cxx
f0633d
@@ -30,7 +30,6 @@ public:
f0633d
     void testN757118();
f0633d
     void testN757905();
f0633d
     void testAllGapsWord();
f0633d
-    void testFdo59530();
f0633d
     void testI120158();
f0633d
     void testN816603();
f0633d
     void testN816593();
f0633d
@@ -57,7 +56,6 @@ void Test::run()
f0633d
         {"n757118.doc", &Test::testN757118},
f0633d
         {"n757905.doc", &Test::testN757905},
f0633d
         {"all_gaps_word.doc", &Test::testAllGapsWord},
f0633d
-        {"fdo59530.doc", &Test::testFdo59530},
f0633d
         {"i120158.doc", &Test::testI120158},
f0633d
         {"n816603.doc", &Test::testN816603},
f0633d
         {"n816593.doc", &Test::testN816593},
f0633d
@@ -221,30 +219,6 @@ void Test::testAllGapsWord()
f0633d
     borderTest.testTheBorders(mxComponent);
f0633d
 }
f0633d
 
f0633d
-void Test::testFdo59530()
f0633d
-{
f0633d
-    // See ooxmlexport's testFdo38244().
f0633d
-    // Test comment range feature.
f0633d
-    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
f0633d
-    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
f0633d
-    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
f0633d
-    uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
f0633d
-    uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
f0633d
-    xRunEnum->nextElement();
f0633d
-    uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
f0633d
-    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
f0633d
-    xRunEnum->nextElement();
f0633d
-    xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
f0633d
-    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
f0633d
-
f0633d
-    // Test initials.
f0633d
-    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
f0633d
-    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
f0633d
-    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
f0633d
-    xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
f0633d
-    CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
f0633d
-}
f0633d
-
f0633d
 void Test::testI120158()
f0633d
 {
f0633d
     // See https://issues.apache.org/ooo/show_bug.cgi?id=120158
f0633d
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
index 17aad68..0b5422c 100644
f0633d
--- a/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
@@ -1945,9 +1945,11 @@ void WW8_WrPlcFtnEdn::Append( WW8_CP nCp, const SwFmtFtn& rFtn )
f0633d
     aCntnt.push_back( &rFtn );
f0633d
 }
f0633d
 
f0633d
-WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt)
f0633d
+WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd)
f0633d
     :
f0633d
-        maDateTime( DateTime::EMPTY )
f0633d
+        maDateTime( DateTime::EMPTY ),
f0633d
+        m_nRangeStart(nRangeStart),
f0633d
+        m_nRangeEnd(nRangeEnd)
f0633d
 {
f0633d
     mpRichText = pPostIt->GetTextObject();
f0633d
     if (!mpRichText)
f0633d
@@ -1960,17 +1962,33 @@ WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt)
f0633d
 WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline)
f0633d
     :
f0633d
         mpRichText(0),
f0633d
-        maDateTime( DateTime::EMPTY )
f0633d
+        maDateTime( DateTime::EMPTY ),
f0633d
+        m_nRangeStart(0),
f0633d
+        m_nRangeEnd(0)
f0633d
 {
f0633d
     msSimpleText = pRedline->GetComment();
f0633d
     msOwner = SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor());
f0633d
     maDateTime = pRedline->GetTimeStamp();
f0633d
 }
f0633d
 
f0633d
+void WW8_WrPlcAnnotations::AddRangeStartPosition( WW8_CP nStartCp)
f0633d
+{
f0633d
+    m_nLastRangeStartPos = nStartCp;
f0633d
+}
f0633d
+
f0633d
 void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
f0633d
 {
f0633d
     aCps.push_back( nCp );
f0633d
-    WW8_Annotation* p = new WW8_Annotation(pPostIt);
f0633d
+    WW8_Annotation* p;
f0633d
+    if( m_nLastRangeStartPos != -1 )
f0633d
+    {
f0633d
+        p = new WW8_Annotation(pPostIt, m_nLastRangeStartPos, nCp);
f0633d
+        m_nLastRangeStartPos = -1;
f0633d
+    }
f0633d
+    else
f0633d
+    {
f0633d
+        p = new WW8_Annotation(pPostIt, nCp, nCp);
f0633d
+    }
f0633d
     aCntnt.push_back( p );
f0633d
 }
f0633d
 
f0633d
@@ -2144,11 +2162,19 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
     {
f0633d
         case TXT_ATN:
f0633d
             {
f0633d
+                std::vector<WW8_CP> aRangeStartPos;
f0633d
+                std::vector<WW8_CP> aRangeEndPos;
f0633d
                 // then write first the GrpXstAtnOwners
f0633d
                 for ( i = 0; i < nLen; ++i )
f0633d
                 {
f0633d
                     const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
f0633d
+
f0633d
                     aStrArr.push_back(std::pair<String,String>(rAtn.msOwner,rAtn.m_sInitials));
f0633d
+                    if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
f0633d
+                    {
f0633d
+                        aRangeStartPos.push_back(rAtn.m_nRangeStart);
f0633d
+                        aRangeEndPos.push_back(rAtn.m_nRangeEnd);
f0633d
+                    }
f0633d
                 }
f0633d
 
f0633d
                 //sort and remove duplicates
f0633d
@@ -2181,6 +2207,67 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
                 nFcStart = rWrt.pTableStrm->Tell();
f0633d
                 rFib.lcbGrpStAtnOwners = nFcStart - rFib.fcGrpStAtnOwners;
f0633d
 
f0633d
+                // Commented text ranges
f0633d
+                if ( rWrt.bWrtWW8 )
f0633d
+                {
f0633d
+                    if( aRangeStartPos.size() > 0 )
f0633d
+                    {
f0633d
+                        // Commented text ranges starting positions (Plcfbkf.aCP)
f0633d
+                        rFib.fcPlcfAtnbkf = nFcStart;
f0633d
+                        for ( i = 0; i < aRangeStartPos.size(); ++i )
f0633d
+                        {
f0633d
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i] );
f0633d
+                        }
f0633d
+                        SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i-1] + 1);
f0633d
+
f0633d
+                        // Commented text ranges additional informations (Plcfbkf.aFBKF)
f0633d
+                        for ( i = 0; i < aRangeStartPos.size(); ++i )
f0633d
+                        {
f0633d
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, i ); // FBKF.ibkl
f0633d
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc
f0633d
+                        }
f0633d
+
f0633d
+                        nFcStart = rWrt.pTableStrm->Tell();
f0633d
+                        rFib.lcbPlcfAtnbkf = nFcStart - rFib.fcPlcfAtnbkf;
f0633d
+
f0633d
+                        // Commented text ranges ending positions (PlcfBkl.aCP)
f0633d
+                        rFib.fcPlcfAtnbkl = nFcStart;
f0633d
+                        for ( i = 0; i < aRangeEndPos.size(); ++i )
f0633d
+                        {
f0633d
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i] );
f0633d
+                        }
f0633d
+                        SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i-1] + 1);
f0633d
+
f0633d
+                        // Commented text ranges additional informations (Plcfbkl.aFBKF)
f0633d
+                        for ( i = 0; i < aRangeEndPos.size(); ++i )
f0633d
+                        {
f0633d
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, i ); // FBKF.ibkl
f0633d
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc
f0633d
+                        }
f0633d
+
f0633d
+                        nFcStart = rWrt.pTableStrm->Tell();
f0633d
+                        rFib.lcbPlcfAtnbkl = nFcStart - rFib.fcPlcfAtnbkl;
f0633d
+
f0633d
+                        // Commented text ranges as bookmarks (SttbfAtnBkmk)
f0633d
+                        rFib.fcSttbfAtnbkmk = nFcStart;
f0633d
+                        SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xFFFF );                // SttbfAtnBkmk.fExtend
f0633d
+                        SwWW8Writer::WriteShort( *rWrt.pTableStrm, aRangeStartPos.size() ); // SttbfAtnBkmk.cData
f0633d
+                        SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xA );                   // SttbfAtnBkmk.cbExtra
f0633d
+
f0633d
+                        for ( i = 0; i < aRangeStartPos.size(); ++i )
f0633d
+                        {
f0633d
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );         // SttbfAtnBkmk.cchData
f0633d
+                            // One ATNBE structure for all text ranges
f0633d
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x0100 );    // ATNBE.bmc
f0633d
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, i );          // ATNBE.lTag
f0633d
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );         // ATNBE.lTagOld
f0633d
+                        }
f0633d
+
f0633d
+                        nFcStart = rWrt.pTableStrm->Tell();
f0633d
+                        rFib.lcbSttbfAtnbkmk = nFcStart - rFib.fcSttbfAtnbkmk;
f0633d
+                    }
f0633d
+                }
f0633d
+
f0633d
                 // Write the extended >= Word XP ATLD records
f0633d
                 if( rWrt.bWrtWW8 )
f0633d
                 {
f0633d
@@ -2265,6 +2352,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
 
f0633d
         if ( TXT_ATN == nTTyp )
f0633d
         {
f0633d
+            sal_uInt16 nlTag = 0;
f0633d
             for ( i = 0; i < nLen; ++i )
f0633d
             {
f0633d
                 const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
f0633d
@@ -2314,7 +2402,13 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos );
f0633d
                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
f0633d
                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
f0633d
-                SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
f0633d
+                if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
f0633d
+                {
f0633d
+                    SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag );
f0633d
+                    ++nlTag;
f0633d
+                }
f0633d
+                else
f0633d
+                    SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
f0633d
             }
f0633d
         }
f0633d
         else
f0633d
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
f0633d
index bfbbe03..9c4b267 100644
f0633d
--- a/sw/source/filter/ww8/wrtww8.hxx
f0633d
+++ b/sw/source/filter/ww8/wrtww8.hxx
f0633d
@@ -1189,7 +1189,8 @@ struct WW8_Annotation
f0633d
     String msOwner;
f0633d
     String m_sInitials;
f0633d
     DateTime maDateTime;
f0633d
-    WW8_Annotation(const SwPostItField* pPostIt);
f0633d
+    WW8_CP m_nRangeStart, m_nRangeEnd;
f0633d
+    WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd);
f0633d
     WW8_Annotation(const SwRedlineData* pRedline);
f0633d
 };
f0633d
 
f0633d
@@ -1200,10 +1201,13 @@ private:
f0633d
     WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&);
f0633d
     WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&);
f0633d
     std::set<const SwRedlineData*> maProcessedRedlines;
f0633d
+
f0633d
+    WW8_CP  m_nLastRangeStartPos;
f0633d
 public:
f0633d
-    WW8_WrPlcAnnotations() {}
f0633d
+    WW8_WrPlcAnnotations(): m_nLastRangeStartPos(-1){}
f0633d
     ~WW8_WrPlcAnnotations();
f0633d
 
f0633d
+    void AddRangeStartPosition( WW8_CP nStartCp );
f0633d
     void Append( WW8_CP nCp, const SwPostItField* pPostIt );
f0633d
     void Append( WW8_CP nCp, const SwRedlineData* pRedLine );
f0633d
     bool IsNewRedlineComment( const SwRedlineData* pRedLine );
f0633d
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
f0633d
index d211344..fa1a3be 100644
f0633d
--- a/sw/source/filter/ww8/ww8atr.cxx
f0633d
+++ b/sw/source/filter/ww8/ww8atr.cxx
f0633d
@@ -2465,6 +2465,11 @@ void WW8AttributeOutput::PostitField( const SwField* pFld )
f0633d
     m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
f0633d
 }
f0633d
 
f0633d
+void WW8AttributeOutput::WritePostitFieldStart()
f0633d
+{
f0633d
+    m_rWW8Export.pAtn->AddRangeStartPosition( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ) );
f0633d
+}
f0633d
+
f0633d
 bool WW8AttributeOutput::DropdownField( const SwField* pFld )
f0633d
 {
f0633d
     bool bExpand = true;
f0633d
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
f0633d
index 4c64635..a9693ad 100644
f0633d
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
f0633d
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
f0633d
@@ -393,6 +393,8 @@ protected:
f0633d
     virtual bool DropdownField( const SwField* pFld );
f0633d
     virtual bool PlaceholderField( const SwField* pFld );
f0633d
 
f0633d
+    virtual void WritePostitFieldStart();
f0633d
+
f0633d
     virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark );
f0633d
 
f0633d
     /// Reference to the export, where to get the data from
f0633d
-- 
f0633d
1.8.4.2
f0633d