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

Zolnai Tamás tamas.zolnai at collabora.com
Fri Jan 3 07:57:09 PST 2014


 dev/null                                    |binary
 sw/qa/extras/ww8export/data/fdo59530.doc    |binary
 sw/qa/extras/ww8export/ww8export.cxx        |   38 ++++++
 sw/qa/extras/ww8import/ww8import.cxx        |   25 ----
 sw/source/filter/ww8/wrtw8sty.cxx           |  156 ++++++++++++++++++++++------
 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, 227 insertions(+), 64 deletions(-)

New commits:
commit f2945255df273404ee2457dcf761cb8f334b732b
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

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 c835c59..111af79 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -163,7 +163,6 @@ DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
     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"));
 
@@ -173,6 +172,20 @@ DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
     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"));
 }
 
 #endif
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 1eba247..5c4a3b0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2162,11 +2162,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 5969eec0e998804eba77338b17de90737e2acb43
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
    
    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 257510b..c835c59 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -150,6 +150,31 @@ DECLARE_WW8EXPORT_TEST(testCharacterBorder, "charborder.odt")
     }
 }
 
+DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
+{
+    // 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"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ww8import/data/fdo59530.doc b/sw/qa/extras/ww8import/data/fdo59530.doc
deleted file mode 100644
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 6b6ae44..0c3e1fc 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -173,30 +173,6 @@ DECLARE_WW8IMPORT_TEST(testAllGapsWord, "all_gaps_word.doc")
     borderTest.testTheBorders(mxComponent);
 }
 
-DECLARE_WW8IMPORT_TEST(testFdo59530, "fdo59530.doc")
-{
-    // 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"));
-}
-
 DECLARE_WW8IMPORT_TEST(testI120158, "i120158.doc")
 {
     // 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 865f420..0ed970c 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -2061,9 +2061,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)
@@ -2076,17 +2078,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 );
 }
 
@@ -2272,11 +2290,18 @@ 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<OUString,OUString>(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
@@ -2309,6 +2334,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 )
                 {
@@ -2409,6 +2495,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];
@@ -2457,7 +2544,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 d0d7cb0..fb21b25 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1194,7 +1194,8 @@ struct WW8_Annotation
     OUString msOwner;
     OUString 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);
 };
 
@@ -1205,10 +1206,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 bab4497..11a3161 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2488,6 +2488,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 2860f0b..72be7ae 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -418,6 +418,8 @@ protected:
     virtual bool DropdownField( const SwField* pFld );
     virtual bool PlaceholderField( const SwField* pFld );
 
+    virtual void WritePostitFieldStart();
+
     virtual bool AnalyzeURL( const OUString& rURL, const OUString& rTarget, OUString* pLinkURL, OUString* pMark );
 
     /// Reference to the export, where to get the data from
commit 0127e3dbabaf24c6c0d828e6d26357ff0b63c3fb
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.
    
    Change-Id: I082fb5caea99df013922e16c5d8d4ef29e866665

diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index e131dab..865f420 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -2069,6 +2069,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());
 }
 
@@ -2245,10 +2246,14 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
     return ( rCount != 0 );
 }
 
+static bool lcl_AuthorComp( const std::pair<OUString,OUString>& aFirst, const std::pair<OUString,OUString>& 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<OUString>::iterator myiter;
 
     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
     sal_uInt16 nLen = aCps.size();
@@ -2257,7 +2262,8 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
 
     OSL_ENSURE( aCps.size() + 2 == pTxtPos->Count(), "WritePlc: DeSync" );
 
-    ::std::vector<OUString> aStrArr;
+    ::std::vector<std::pair<OUString,OUString> > aStrArr;
+    typedef ::std::vector<std::pair<OUString,OUString> >::iterator myiter;
     WW8Fib& rFib = *rWrt.pFib;              // n+1-te CP-Pos nach Handbuch
     sal_uInt16 i;
     bool bWriteCP = true;
@@ -2270,11 +2276,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<OUString,OUString>(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());
 
@@ -2282,9 +2288,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 {
                     for ( i = 0; i < aStrArr.size(); ++i )
                     {
-                        const OUString& rStr = aStrArr[i];
-                        SwWW8Writer::WriteShort(*rWrt.pTableStrm, rStr.getLength());
-                        SwWW8Writer::WriteString16(*rWrt.pTableStrm, rStr,
+                        const OUString& sAuthor = aStrArr[i].first;
+                        SwWW8Writer::WriteShort(*rWrt.pTableStrm, sAuthor.getLength());
+                        SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
                                 false);
                     }
                 }
@@ -2292,9 +2298,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                 {
                     for ( i = 0; i < aStrArr.size(); ++i )
                     {
-                        const OUString& rStr = aStrArr[i];
-                        *rWrt.pTableStrm << (sal_uInt8)rStr.getLength();
-                        SwWW8Writer::WriteString8(*rWrt.pTableStrm, rStr, false,
+                        const OUString& sAuthor = aStrArr[i].first;
+                        *rWrt.pTableStrm << (sal_uInt8)sAuthor.getLength();
+                        SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor, false,
                                 RTL_TEXTENCODING_MS_1252);
                     }
                 }
@@ -2409,35 +2415,36 @@ 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<OUString,OUString>(rAtn.msOwner,OUString()),
+                        &lcl_AuthorComp);
+                OSL_ENSURE(aIter != aStrArr.end() && aIter->first == rAtn.msOwner,
                         "Impossible");
                 sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin());
-                OUString sAuthor(*aIter);
-                sal_uInt8 nNameLen = (sal_uInt8)sAuthor.getLength();
-                if ( nNameLen > 9 )
+                OUString sInitials( aIter->second );
+                sal_uInt8 nInitalsLen = (sal_uInt8)sInitials.getLength();
+                if ( nInitalsLen > 9 )
                 {
-                    sAuthor = sAuthor.copy( 0, 9 );
-                    nNameLen = 9;
+                    sInitials = sInitials.copy( 0, 9 );
+                    nInitalsLen = 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, nInitalsLen);
+                    SwWW8Writer::WriteString16(*rWrt.pTableStrm, sInitials,
                             false);
                     SwWW8Writer::FillCount( *rWrt.pTableStrm,
-                            (9 - nNameLen) * 2 );
+                            (9 - nInitalsLen) * 2 );
 
                 }
                 else
                 {
-                    *rWrt.pTableStrm << nNameLen;
-                    SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor,
+                    *rWrt.pTableStrm << nInitalsLen;
+                    SwWW8Writer::WriteString8(*rWrt.pTableStrm, sInitials,
                             false, RTL_TEXTENCODING_MS_1252);
-                    SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nNameLen);
+                    SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nInitalsLen);
                 }
 
                 // documents layout of WriteShort's below:
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 2a1f052..d0d7cb0 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1192,6 +1192,7 @@ struct WW8_Annotation
     const OutlinerParaObject* mpRichText;
     OUString msSimpleText;
     OUString msOwner;
+    OUString m_sInitials;
     DateTime maDateTime;
     WW8_Annotation(const SwPostItField* pPostIt);
     WW8_Annotation(const SwRedlineData* pRedline);
commit 12e287220ebaf3a8f5eaf7bf526dce2c47f45a20
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.
    
    Change-Id: I499abdcce1be0563c308bcf9f5c0a959a07f858b

diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index f7c5b6d..6b6ae44 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -194,7 +194,6 @@ DECLARE_WW8IMPORT_TEST(testFdo59530, "fdo59530.doc")
     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 ce10d21..1eba247 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2124,7 +2124,6 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
 
     OUString sAuthor;
     OUString sInitials;
-    OUString sName;
     if( bVer67 )
     {
         const WW67_ATRD* pDescri = (const WW67_ATRD*)pSD->GetData();
@@ -2157,7 +2156,6 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
         sal_uInt32 nTagBkmk = SVBT32ToUInt32(pDescri->ITagBkmk);
         if (nTagBkmk != 0xFFFFFFFF)
         {
-            sName = OUString::number(nTagBkmk);
             int nAtnIndex = GetAnnotationIndex(nTagBkmk);
             if (nAtnIndex != -1)
             {
@@ -2192,14 +2190,15 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
     this->pFmtOfJustInsertedApo = 0;
     SwPostItField aPostIt(
         (SwPostItFieldType*)rDoc.GetSysFldType(RES_POSTITFLD), sAuthor,
-        sTxt, sInitials, sName, aDate );
+        sTxt, sInitials, OUString(), 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