[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 4 commits - sw/qa sw/source

Zolnai Tamás tamas.zolnai at collabora.com
Sun Jan 5 17:40:40 PST 2014


 dev/null                                    |binary
 sw/qa/extras/ww8export/data/fdo59530.doc    |binary
 sw/qa/extras/ww8export/ww8export.cxx        |   40 +++++++
 sw/qa/extras/ww8import/ww8import.cxx        |   27 ----
 sw/source/filter/ww8/wrtw8sty.cxx           |  159 ++++++++++++++++++++++------
 sw/source/filter/ww8/wrtww8.hxx             |    9 +
 sw/source/filter/ww8/ww8atr.cxx             |    5 
 sw/source/filter/ww8/ww8attributeoutput.hxx |    2 
 sw/source/filter/ww8/ww8par.cxx             |   56 ++++++++-
 9 files changed, 231 insertions(+), 67 deletions(-)

New commits:
commit 17f7655b6dedb7349c3ecd8445f119c4d14641b0
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Jan 3 00:41:56 2014 +0100

    cp#2013101510000026: doc import of comments affecting more text nodes
    
    Change-Id: I3932d82cb4cd640b19957b93cc7e59711af1b564
    (cherry picked from commit f2945255df273404ee2457dcf761cb8f334b732b)
    (cherry picked from commit e0bd7b01f31bfbaeac3bce86403bf25929c61c84)

diff --git a/sw/qa/extras/ww8export/data/fdo59530.doc b/sw/qa/extras/ww8export/data/fdo59530.doc
index 60cfe84..921fbca 100644
Binary files a/sw/qa/extras/ww8export/data/fdo59530.doc and b/sw/qa/extras/ww8export/data/fdo59530.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 29e2df5..d34a46d 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -164,7 +164,6 @@ void Test::testFdo59530()
     uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     xRunEnum->nextElement();
-    xRunEnum->nextElement();
     xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
 
@@ -174,6 +173,20 @@ void Test::testFdo59530()
     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
+
+    // Test commented text range which spans over more text nodes
+    // Comment starts in the second paragraph
+    xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xRunEnum = xRunEnumAccess->createEnumeration();
+    xRunEnum->nextElement();
+    xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
+    // Comment ends in the third paragraph
+    xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xRunEnum = xRunEnumAccess->createEnumeration();
+    xRunEnum->nextElement();
+    xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 56040b7..645d246 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1825,11 +1825,50 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
                 WW8_CP nStart = GetAnnotationStart(nAtnIndex);
                 WW8_CP nEnd = GetAnnotationEnd(nAtnIndex);
                 sal_Int32 nLen = nEnd - nStart;
-                // Don't support ranges affecting multiple SwTxtNode for now.
-                if (nLen && pPaM->GetPoint()->nContent.GetIndex() >= nLen)
-                {
-                    pPaM->SetMark();
-                    pPaM->GetPoint()->nContent -= nLen;
+                if( nLen )
+                 {
+                    if (pPaM->GetPoint()->nContent.GetIndex() >= nLen)
+                    {
+                        pPaM->SetMark();
+                        pPaM->GetPoint()->nContent -= nLen;
+                    }
+                    else if (pPaM->GetPoint()->nNode.GetNode().IsTxtNode() )
+                    {
+                        pPaM->SetMark();
+                        nLen -= pPaM->GetPoint()->nContent.GetIndex();
+
+                        SwTxtNode* pTxtNode = 0;
+                        // Find first text node which affected by the comment
+                        while( pPaM->GetPoint()->nNode >= 0 )
+                        {
+                            SwNode* pNode = 0;
+                            // Find previous text node
+                            do
+                            {
+                                pPaM->GetPoint()->nNode--;
+                                nLen--; // End line character
+                                pNode = &pPaM->GetPoint()->nNode.GetNode();
+                            }
+                            while( !pNode->IsTxtNode() && pPaM->GetPoint()->nNode >= 0 );
+
+                            // Subtrackt previous text node's length
+                            if( pNode && pNode->IsTxtNode() )
+                            {
+                                pTxtNode = pNode->GetTxtNode();
+                                if( nLen < pTxtNode->Len() )
+                                    break;
+                                else
+                                    nLen -= pTxtNode->Len();
+                            }
+                        }
+
+                        // Set postion of the text range's first character
+                        if( pTxtNode )
+                        {
+                            pTxtNode->MakeStartIndex(&pPaM->GetPoint()->nContent);
+                            pPaM->GetPoint()->nContent += pTxtNode->Len() - nLen;
+                        }
+                    }
                 }
             }
         }
commit d3a5776b00ee07ac371dd180a6d962d50da4baf5
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Jan 3 15:21:32 2014 +0100

    cp#2013101510000026: doc export of commented text ranges
    
    (cherry picked from commit 5969eec0e998804eba77338b17de90737e2acb43)
    
    Conflicts:
    	sw/qa/extras/ww8export/ww8export.cxx
    	sw/qa/extras/ww8import/ww8import.cxx
    	sw/source/filter/ww8/wrtw8sty.cxx
    	sw/source/filter/ww8/ww8attributeoutput.hxx
    
    (cherry picked from commit 765d89aa149e9afc78382e24bf7c86f70b1584ff)
    
    Change-Id: I2d31da5d659edcbebc682d5604d2db24b5e341fb

diff --git a/sw/qa/extras/ww8export/data/fdo59530.doc b/sw/qa/extras/ww8export/data/fdo59530.doc
new file mode 100644
index 0000000..60cfe84
Binary files /dev/null and b/sw/qa/extras/ww8export/data/fdo59530.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 0c2f769..29e2df5 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -26,6 +26,7 @@ public:
     void test56513();
     void testNewPageStylesTable();
     void testFdo42144();
+    void testFdo59530();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -48,6 +49,7 @@ void Test::run()
         {"fdo56513.doc", &Test::test56513},
         {"new-page-styles.doc", &Test::testNewPageStylesTable},
         {"fdo42144.odt", &Test::testFdo42144},
+        {"fdo59530.doc", &Test::testFdo59530},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -149,6 +151,31 @@ void Test::testFdo42144()
     CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xStyle, "FooterIsOn")));
 }
 
+void Test::testFdo59530()
+{
+    // See ooxmlexport's testFdo38244().
+    // Test comment range feature.
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+    uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+    xRunEnum->nextElement();
+    uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
+    xRunEnum->nextElement();
+    xRunEnum->nextElement();
+    xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
+
+    // Test initials.
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+    xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ww8import/data/fdo59530.doc b/sw/qa/extras/ww8import/data/fdo59530.doc
deleted file mode 100755
index 4e41cb8..0000000
Binary files a/sw/qa/extras/ww8import/data/fdo59530.doc and /dev/null differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 50ef934..3311563 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -30,7 +30,6 @@ public:
     void testN757118();
     void testN757905();
     void testAllGapsWord();
-    void testFdo59530();
     void testI120158();
     void testN816603();
     void testN816593();
@@ -57,7 +56,6 @@ void Test::run()
         {"n757118.doc", &Test::testN757118},
         {"n757905.doc", &Test::testN757905},
         {"all_gaps_word.doc", &Test::testAllGapsWord},
-        {"fdo59530.doc", &Test::testFdo59530},
         {"i120158.doc", &Test::testI120158},
         {"n816603.doc", &Test::testN816603},
         {"n816593.doc", &Test::testN816593},
@@ -221,30 +219,6 @@ void Test::testAllGapsWord()
     borderTest.testTheBorders(mxComponent);
 }
 
-void Test::testFdo59530()
-{
-    // See ooxmlexport's testFdo38244().
-    // Test comment range feature.
-    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
-    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
-    uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
-    uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
-    xRunEnum->nextElement();
-    uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
-    xRunEnum->nextElement();
-    xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
-
-    // Test initials.
-    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
-    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
-    xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
-}
-
 void Test::testI120158()
 {
     // See https://issues.apache.org/ooo/show_bug.cgi?id=120158
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 17aad68..0b5422c 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1945,9 +1945,11 @@ void WW8_WrPlcFtnEdn::Append( WW8_CP nCp, const SwFmtFtn& rFtn )
     aCntnt.push_back( &rFtn );
 }
 
-WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt)
+WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd)
     :
-        maDateTime( DateTime::EMPTY )
+        maDateTime( DateTime::EMPTY ),
+        m_nRangeStart(nRangeStart),
+        m_nRangeEnd(nRangeEnd)
 {
     mpRichText = pPostIt->GetTextObject();
     if (!mpRichText)
@@ -1960,17 +1962,33 @@ WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt)
 WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline)
     :
         mpRichText(0),
-        maDateTime( DateTime::EMPTY )
+        maDateTime( DateTime::EMPTY ),
+        m_nRangeStart(0),
+        m_nRangeEnd(0)
 {
     msSimpleText = pRedline->GetComment();
     msOwner = SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor());
     maDateTime = pRedline->GetTimeStamp();
 }
 
+void WW8_WrPlcAnnotations::AddRangeStartPosition( WW8_CP nStartCp)
+{
+    m_nLastRangeStartPos = nStartCp;
+}
+
 void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
 {
     aCps.push_back( nCp );
-    WW8_Annotation* p = new WW8_Annotation(pPostIt);
+    WW8_Annotation* p;
+    if( m_nLastRangeStartPos != -1 )
+    {
+        p = new WW8_Annotation(pPostIt, m_nLastRangeStartPos, nCp);
+        m_nLastRangeStartPos = -1;
+    }
+    else
+    {
+        p = new WW8_Annotation(pPostIt, nCp, nCp);
+    }
     aCntnt.push_back( p );
 }
 
@@ -2144,11 +2162,19 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
     {
         case TXT_ATN:
             {
+                std::vector<WW8_CP> aRangeStartPos;
+                std::vector<WW8_CP> aRangeEndPos;
                 // then write first the GrpXstAtnOwners
                 for ( i = 0; i < nLen; ++i )
                 {
                     const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
+
                     aStrArr.push_back(std::pair<String,String>(rAtn.msOwner,rAtn.m_sInitials));
+                    if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
+                    {
+                        aRangeStartPos.push_back(rAtn.m_nRangeStart);
+                        aRangeEndPos.push_back(rAtn.m_nRangeEnd);
+                    }
                 }
 
                 //sort and remove duplicates
@@ -2181,6 +2207,67 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 nFcStart = rWrt.pTableStrm->Tell();
                 rFib.lcbGrpStAtnOwners = nFcStart - rFib.fcGrpStAtnOwners;
 
+                // Commented text ranges
+                if ( rWrt.bWrtWW8 )
+                {
+                    if( aRangeStartPos.size() > 0 )
+                    {
+                        // Commented text ranges starting positions (Plcfbkf.aCP)
+                        rFib.fcPlcfAtnbkf = nFcStart;
+                        for ( i = 0; i < aRangeStartPos.size(); ++i )
+                        {
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i] );
+                        }
+                        SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i-1] + 1);
+
+                        // Commented text ranges additional informations (Plcfbkf.aFBKF)
+                        for ( i = 0; i < aRangeStartPos.size(); ++i )
+                        {
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, i ); // FBKF.ibkl
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc
+                        }
+
+                        nFcStart = rWrt.pTableStrm->Tell();
+                        rFib.lcbPlcfAtnbkf = nFcStart - rFib.fcPlcfAtnbkf;
+
+                        // Commented text ranges ending positions (PlcfBkl.aCP)
+                        rFib.fcPlcfAtnbkl = nFcStart;
+                        for ( i = 0; i < aRangeEndPos.size(); ++i )
+                        {
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i] );
+                        }
+                        SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i-1] + 1);
+
+                        // Commented text ranges additional informations (Plcfbkl.aFBKF)
+                        for ( i = 0; i < aRangeEndPos.size(); ++i )
+                        {
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, i ); // FBKF.ibkl
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc
+                        }
+
+                        nFcStart = rWrt.pTableStrm->Tell();
+                        rFib.lcbPlcfAtnbkl = nFcStart - rFib.fcPlcfAtnbkl;
+
+                        // Commented text ranges as bookmarks (SttbfAtnBkmk)
+                        rFib.fcSttbfAtnbkmk = nFcStart;
+                        SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xFFFF );                // SttbfAtnBkmk.fExtend
+                        SwWW8Writer::WriteShort( *rWrt.pTableStrm, aRangeStartPos.size() ); // SttbfAtnBkmk.cData
+                        SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xA );                   // SttbfAtnBkmk.cbExtra
+
+                        for ( i = 0; i < aRangeStartPos.size(); ++i )
+                        {
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );         // SttbfAtnBkmk.cchData
+                            // One ATNBE structure for all text ranges
+                            SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x0100 );    // ATNBE.bmc
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, i );          // ATNBE.lTag
+                            SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );         // ATNBE.lTagOld
+                        }
+
+                        nFcStart = rWrt.pTableStrm->Tell();
+                        rFib.lcbSttbfAtnbkmk = nFcStart - rFib.fcSttbfAtnbkmk;
+                    }
+                }
+
                 // Write the extended >= Word XP ATLD records
                 if( rWrt.bWrtWW8 )
                 {
@@ -2265,6 +2352,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
 
         if ( TXT_ATN == nTTyp )
         {
+            sal_uInt16 nlTag = 0;
             for ( i = 0; i < nLen; ++i )
             {
                 const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
@@ -2314,7 +2402,13 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos );
                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
-                SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
+                if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
+                {
+                    SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag );
+                    ++nlTag;
+                }
+                else
+                    SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
             }
         }
         else
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index bfbbe03..9c4b267 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1189,7 +1189,8 @@ struct WW8_Annotation
     String msOwner;
     String m_sInitials;
     DateTime maDateTime;
-    WW8_Annotation(const SwPostItField* pPostIt);
+    WW8_CP m_nRangeStart, m_nRangeEnd;
+    WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd);
     WW8_Annotation(const SwRedlineData* pRedline);
 };
 
@@ -1200,10 +1201,13 @@ private:
     WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&);
     WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&);
     std::set<const SwRedlineData*> maProcessedRedlines;
+
+    WW8_CP  m_nLastRangeStartPos;
 public:
-    WW8_WrPlcAnnotations() {}
+    WW8_WrPlcAnnotations(): m_nLastRangeStartPos(-1){}
     ~WW8_WrPlcAnnotations();
 
+    void AddRangeStartPosition( WW8_CP nStartCp );
     void Append( WW8_CP nCp, const SwPostItField* pPostIt );
     void Append( WW8_CP nCp, const SwRedlineData* pRedLine );
     bool IsNewRedlineComment( const SwRedlineData* pRedLine );
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index d211344..fa1a3be 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2465,6 +2465,11 @@ void WW8AttributeOutput::PostitField( const SwField* pFld )
     m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
 }
 
+void WW8AttributeOutput::WritePostitFieldStart()
+{
+    m_rWW8Export.pAtn->AddRangeStartPosition( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ) );
+}
+
 bool WW8AttributeOutput::DropdownField( const SwField* pFld )
 {
     bool bExpand = true;
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 4c64635..a9693ad 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -393,6 +393,8 @@ protected:
     virtual bool DropdownField( const SwField* pFld );
     virtual bool PlaceholderField( const SwField* pFld );
 
+    virtual void WritePostitFieldStart();
+
     virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark );
 
     /// Reference to the export, where to get the data from
commit e3f729cbe49baccc9d40c41af183529e494dd1d9
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Jan 3 15:26:21 2014 +0100

    cp#2013101510000026: fix doc export of comments initials
    
    It seems comments' authers were exported twice. Once istead
    of initials.
    
    (cherry picked from commit 0127e3dbabaf24c6c0d828e6d26357ff0b63c3fb)
    
    Conflicts:
    	sw/source/filter/ww8/wrtw8sty.cxx
    	sw/source/filter/ww8/wrtww8.hxx
    
    Change-Id: I082fb5caea99df013922e16c5d8d4ef29e866665
    (cherry picked from commit 7d12ed75718fcee74a731113928a12af0bb0e2f5)

diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index bc08a72..17aad68 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1953,6 +1953,7 @@ WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt)
     if (!mpRichText)
         msSimpleText = pPostIt->GetTxt();
     msOwner = pPostIt->GetPar1();
+    m_sInitials = pPostIt->GetInitials();
     maDateTime = DateTime(pPostIt->GetDate(), pPostIt->GetTime());
 }
 
@@ -2118,11 +2119,14 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
     return ( rCount != 0 );
 }
 
+static bool lcl_AuthorComp( const std::pair<String,String>& aFirst, const std::pair<String,String>& aSecond)
+{
+    return aFirst.first < aSecond.first;
+}
+
 void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
     WW8_FC& rTxtStart, sal_Int32& rTxtCount, WW8_FC& rRefStart, sal_Int32& rRefCount ) const
 {
-    typedef ::std::vector<String>::iterator myiter;
-
     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
     sal_uInt16 nLen = aCps.size();
     if ( !nLen )
@@ -2130,7 +2134,8 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
 
     OSL_ENSURE( aCps.size() + 2 == pTxtPos->Count(), "WritePlc: DeSync" );
 
-    ::std::vector<String> aStrArr;
+    ::std::vector<std::pair<String,String> > aStrArr;
+    typedef ::std::vector<std::pair<String,String> >::iterator myiter;
     WW8Fib& rFib = *rWrt.pFib;              // n+1-te CP-Pos nach Handbuch
     sal_uInt16 i;
     bool bWriteCP = true;
@@ -2143,11 +2148,11 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 for ( i = 0; i < nLen; ++i )
                 {
                     const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
-                    aStrArr.push_back(rAtn.msOwner);
+                    aStrArr.push_back(std::pair<String,String>(rAtn.msOwner,rAtn.m_sInitials));
                 }
 
                 //sort and remove duplicates
-                ::std::sort(aStrArr.begin(), aStrArr.end());
+                ::std::sort(aStrArr.begin(), aStrArr.end(),&lcl_AuthorComp);
                 myiter aIter = ::std::unique(aStrArr.begin(), aStrArr.end());
                 aStrArr.erase(aIter, aStrArr.end());
 
@@ -2155,9 +2160,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 {
                     for ( i = 0; i < aStrArr.size(); ++i )
                     {
-                        const String& rStr = aStrArr[i];
-                        SwWW8Writer::WriteShort(*rWrt.pTableStrm, rStr.Len());
-                        SwWW8Writer::WriteString16(*rWrt.pTableStrm, rStr,
+                        const String& sAuthor = aStrArr[i].first;
+                        SwWW8Writer::WriteShort(*rWrt.pTableStrm, sAuthor.Len());
+                        SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
                                 false);
                     }
                 }
@@ -2165,9 +2170,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 {
                     for ( i = 0; i < aStrArr.size(); ++i )
                     {
-                        const String& rStr = aStrArr[i];
-                        *rWrt.pTableStrm << (sal_uInt8)rStr.Len();
-                        SwWW8Writer::WriteString8(*rWrt.pTableStrm, rStr, false,
+                        const String& sAuthor = aStrArr[i].first;
+                        *rWrt.pTableStrm << (sal_uInt8)sAuthor.Len();
+                        SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor, false,
                                 RTL_TEXTENCODING_MS_1252);
                     }
                 }
@@ -2266,35 +2271,37 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
 
                 //aStrArr is sorted
                 myiter aIter = ::std::lower_bound(aStrArr.begin(),
-                        aStrArr.end(), rAtn.msOwner);
-                OSL_ENSURE(aIter != aStrArr.end() && *aIter == rAtn.msOwner,
+                        aStrArr.end(), std::pair<String,String>(rAtn.msOwner,String()),
+                        &lcl_AuthorComp);
+                OSL_ENSURE(aIter != aStrArr.end() && aIter->first == rAtn.msOwner,
                         "Impossible");
                 sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin());
-                String sAuthor(*aIter);
-                sal_uInt8 nNameLen = (sal_uInt8)sAuthor.Len();
-                if ( nNameLen > 9 )
+
+                String sInitials( aIter->second );
+                sal_uInt8 nInitialsLen = (sal_uInt8)sInitials.Len();
+                if ( nInitialsLen > 9 )
                 {
-                    sAuthor.Erase( 9 );
-                    nNameLen = 9;
+                    sInitials.Erase( 9 );
+                    nInitialsLen = 9;
                 }
 
                 // xstUsrInitl[ 10 ] pascal-style String holding initials
                 // of annotation author
                 if ( rWrt.bWrtWW8 )
                 {
-                    SwWW8Writer::WriteShort(*rWrt.pTableStrm, nNameLen);
-                    SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
+                    SwWW8Writer::WriteShort(*rWrt.pTableStrm, nInitialsLen);
+                    SwWW8Writer::WriteString16(*rWrt.pTableStrm, sInitials,
                             false);
                     SwWW8Writer::FillCount( *rWrt.pTableStrm,
-                            (9 - nNameLen) * 2 );
+                            (9 - nInitialsLen) * 2 );
 
                 }
                 else
                 {
-                    *rWrt.pTableStrm << nNameLen;
-                    SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor,
+                    *rWrt.pTableStrm << nInitialsLen;
+                    SwWW8Writer::WriteString8(*rWrt.pTableStrm, sInitials,
                             false, RTL_TEXTENCODING_MS_1252);
-                    SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nNameLen);
+                    SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nInitialsLen);
                 }
 
                 // documents layout of WriteShort's below:
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index c48e101..bfbbe03 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1187,6 +1187,7 @@ struct WW8_Annotation
     const OutlinerParaObject* mpRichText;
     String msSimpleText;
     String msOwner;
+    String m_sInitials;
     DateTime maDateTime;
     WW8_Annotation(const SwPostItField* pPostIt);
     WW8_Annotation(const SwRedlineData* pRedline);
commit 28d59a1a48d633f438e344f247362af0858d8911
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Jan 3 11:38:05 2014 +0100

    cp#2013101510000026: wrong highlight of commented text range imported from doc
    
    When makeFieldBookmark() method is called with
    ODF_COMMENTRANGE it will ignore the added field name and
    generate an own one. We have to set the name of the
    SwPostItField to this generated name so these two names will match.
    
    Note: lTagBkmk is only an identifier but not the exported name
    of the fieldmark so we don't need to stick to use it as
    a name.
    
    (cherry picked from commit 12e287220ebaf3a8f5eaf7bf526dce2c47f45a20)
    
    Conflicts:
    	sw/source/filter/ww8/ww8par.cxx
    
    (cherry picked from commit d6fc6624e1319257945f49388d635c36685108d5)
    
    Change-Id: I499abdcce1be0563c308bcf9f5c0a959a07f858b

diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index ef68da6..50ef934 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -242,7 +242,6 @@ void Test::testFdo59530()
     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("346376201"), getProperty<OUString>(xPropertySet, "Name"));
     CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
 }
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index b34b966..56040b7 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1790,7 +1790,6 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
 
     String sAuthor;
     String sInitials;
-    String sName;
     if( bVer67 )
     {
         const WW67_ATRD* pDescri = (const WW67_ATRD*)pSD->GetData();
@@ -1820,7 +1819,6 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
         sal_uInt32 nTagBkmk = SVBT32ToUInt32(pDescri->ITagBkmk);
         if (nTagBkmk != 0xFFFFFFFF)
         {
-            sName = OUString::valueOf(sal_Int32(nTagBkmk));
             int nAtnIndex = GetAnnotationIndex(nTagBkmk);
             if (nAtnIndex != -1)
             {
@@ -1855,14 +1853,15 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
     this->pFmtOfJustInsertedApo = 0;
     SwPostItField aPostIt(
         (SwPostItFieldType*)rDoc.GetSysFldType(RES_POSTITFLD), sAuthor,
-        sTxt, sInitials, sName, aDate );
+        sTxt, sInitials, String(), aDate );
     aPostIt.SetTextObject(pOutliner);
 
     // If this is a range, create the associated fieldmark.
     if (pPaM->HasMark())
     {
         IDocumentMarkAccess* pMarksAccess = rDoc.getIDocumentMarkAccess();
-        pMarksAccess->makeFieldBookmark(*pPaM, aPostIt.GetName(), ODF_COMMENTRANGE);
+        sw::mark::IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark(*pPaM, OUString(), ODF_COMMENTRANGE);
+        aPostIt.SetName(pFieldmark->GetName());
         pPaM->Exchange();
         pPaM->DeleteMark();
     }


More information about the Libreoffice-commits mailing list