kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0101-cp-2013101510000026-fix-doc-export-of-comments-initi.patch

f0633d
From e3f729cbe49baccc9d40c41af183529e494dd1d9 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:26:21 +0100
f0633d
Subject: [PATCH 101/109] cp#2013101510000026: fix doc export of comments
f0633d
 initials
f0633d
f0633d
It seems comments' authers were exported twice. Once istead
f0633d
of initials.
f0633d
f0633d
(cherry picked from commit 0127e3dbabaf24c6c0d828e6d26357ff0b63c3fb)
f0633d
f0633d
Conflicts:
f0633d
	sw/source/filter/ww8/wrtw8sty.cxx
f0633d
	sw/source/filter/ww8/wrtww8.hxx
f0633d
f0633d
Change-Id: I082fb5caea99df013922e16c5d8d4ef29e866665
f0633d
(cherry picked from commit 7d12ed75718fcee74a731113928a12af0bb0e2f5)
f0633d
---
f0633d
 sw/source/filter/ww8/wrtw8sty.cxx | 55 ++++++++++++++++++++++-----------------
f0633d
 sw/source/filter/ww8/wrtww8.hxx   |  1 +
f0633d
 2 files changed, 32 insertions(+), 24 deletions(-)
f0633d
f0633d
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
index bc08a72..17aad68 100644
f0633d
--- a/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
@@ -1953,6 +1953,7 @@ WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt)
f0633d
     if (!mpRichText)
f0633d
         msSimpleText = pPostIt->GetTxt();
f0633d
     msOwner = pPostIt->GetPar1();
f0633d
+    m_sInitials = pPostIt->GetInitials();
f0633d
     maDateTime = DateTime(pPostIt->GetDate(), pPostIt->GetTime());
f0633d
 }
f0633d
 
f0633d
@@ -2118,11 +2119,14 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
     return ( rCount != 0 );
f0633d
 }
f0633d
 
f0633d
+static bool lcl_AuthorComp( const std::pair<String,String>& aFirst, const std::pair<String,String>& aSecond)
f0633d
+{
f0633d
+    return aFirst.first < aSecond.first;
f0633d
+}
f0633d
+
f0633d
 void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
     WW8_FC& rTxtStart, sal_Int32& rTxtCount, WW8_FC& rRefStart, sal_Int32& rRefCount ) const
f0633d
 {
f0633d
-    typedef ::std::vector<String>::iterator myiter;
f0633d
-
f0633d
     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
f0633d
     sal_uInt16 nLen = aCps.size();
f0633d
     if ( !nLen )
f0633d
@@ -2130,7 +2134,8 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
 
f0633d
     OSL_ENSURE( aCps.size() + 2 == pTxtPos->Count(), "WritePlc: DeSync" );
f0633d
 
f0633d
-    ::std::vector<String> aStrArr;
f0633d
+    ::std::vector<std::pair<String,String> > aStrArr;
f0633d
+    typedef ::std::vector<std::pair<String,String> >::iterator myiter;
f0633d
     WW8Fib& rFib = *rWrt.pFib;              // n+1-te CP-Pos nach Handbuch
f0633d
     sal_uInt16 i;
f0633d
     bool bWriteCP = true;
f0633d
@@ -2143,11 +2148,11 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
                 for ( i = 0; i < nLen; ++i )
f0633d
                 {
f0633d
                     const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
f0633d
-                    aStrArr.push_back(rAtn.msOwner);
f0633d
+                    aStrArr.push_back(std::pair<String,String>(rAtn.msOwner,rAtn.m_sInitials));
f0633d
                 }
f0633d
 
f0633d
                 //sort and remove duplicates
f0633d
-                ::std::sort(aStrArr.begin(), aStrArr.end());
f0633d
+                ::std::sort(aStrArr.begin(), aStrArr.end(),&lcl_AuthorComp);
f0633d
                 myiter aIter = ::std::unique(aStrArr.begin(), aStrArr.end());
f0633d
                 aStrArr.erase(aIter, aStrArr.end());
f0633d
 
f0633d
@@ -2155,9 +2160,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
                 {
f0633d
                     for ( i = 0; i < aStrArr.size(); ++i )
f0633d
                     {
f0633d
-                        const String& rStr = aStrArr[i];
f0633d
-                        SwWW8Writer::WriteShort(*rWrt.pTableStrm, rStr.Len());
f0633d
-                        SwWW8Writer::WriteString16(*rWrt.pTableStrm, rStr,
f0633d
+                        const String& sAuthor = aStrArr[i].first;
f0633d
+                        SwWW8Writer::WriteShort(*rWrt.pTableStrm, sAuthor.Len());
f0633d
+                        SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
f0633d
                                 false);
f0633d
                     }
f0633d
                 }
f0633d
@@ -2165,9 +2170,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
                 {
f0633d
                     for ( i = 0; i < aStrArr.size(); ++i )
f0633d
                     {
f0633d
-                        const String& rStr = aStrArr[i];
f0633d
-                        *rWrt.pTableStrm << (sal_uInt8)rStr.Len();
f0633d
-                        SwWW8Writer::WriteString8(*rWrt.pTableStrm, rStr, false,
f0633d
+                        const String& sAuthor = aStrArr[i].first;
f0633d
+                        *rWrt.pTableStrm << (sal_uInt8)sAuthor.Len();
f0633d
+                        SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor, false,
f0633d
                                 RTL_TEXTENCODING_MS_1252);
f0633d
                     }
f0633d
                 }
f0633d
@@ -2266,35 +2271,37 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
f0633d
 
f0633d
                 //aStrArr is sorted
f0633d
                 myiter aIter = ::std::lower_bound(aStrArr.begin(),
f0633d
-                        aStrArr.end(), rAtn.msOwner);
f0633d
-                OSL_ENSURE(aIter != aStrArr.end() && *aIter == rAtn.msOwner,
f0633d
+                        aStrArr.end(), std::pair<String,String>(rAtn.msOwner,String()),
f0633d
+                        &lcl_AuthorComp);
f0633d
+                OSL_ENSURE(aIter != aStrArr.end() && aIter->first == rAtn.msOwner,
f0633d
                         "Impossible");
f0633d
                 sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin());
f0633d
-                String sAuthor(*aIter);
f0633d
-                sal_uInt8 nNameLen = (sal_uInt8)sAuthor.Len();
f0633d
-                if ( nNameLen > 9 )
f0633d
+
f0633d
+                String sInitials( aIter->second );
f0633d
+                sal_uInt8 nInitialsLen = (sal_uInt8)sInitials.Len();
f0633d
+                if ( nInitialsLen > 9 )
f0633d
                 {
f0633d
-                    sAuthor.Erase( 9 );
f0633d
-                    nNameLen = 9;
f0633d
+                    sInitials.Erase( 9 );
f0633d
+                    nInitialsLen = 9;
f0633d
                 }
f0633d
 
f0633d
                 // xstUsrInitl[ 10 ] pascal-style String holding initials
f0633d
                 // of annotation author
f0633d
                 if ( rWrt.bWrtWW8 )
f0633d
                 {
f0633d
-                    SwWW8Writer::WriteShort(*rWrt.pTableStrm, nNameLen);
f0633d
-                    SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
f0633d
+                    SwWW8Writer::WriteShort(*rWrt.pTableStrm, nInitialsLen);
f0633d
+                    SwWW8Writer::WriteString16(*rWrt.pTableStrm, sInitials,
f0633d
                             false);
f0633d
                     SwWW8Writer::FillCount( *rWrt.pTableStrm,
f0633d
-                            (9 - nNameLen) * 2 );
f0633d
+                            (9 - nInitialsLen) * 2 );
f0633d
 
f0633d
                 }
f0633d
                 else
f0633d
                 {
f0633d
-                    *rWrt.pTableStrm << nNameLen;
f0633d
-                    SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor,
f0633d
+                    *rWrt.pTableStrm << nInitialsLen;
f0633d
+                    SwWW8Writer::WriteString8(*rWrt.pTableStrm, sInitials,
f0633d
                             false, RTL_TEXTENCODING_MS_1252);
f0633d
-                    SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nNameLen);
f0633d
+                    SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nInitialsLen);
f0633d
                 }
f0633d
 
f0633d
                 // documents layout of WriteShort's below:
f0633d
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
f0633d
index c48e101..bfbbe03 100644
f0633d
--- a/sw/source/filter/ww8/wrtww8.hxx
f0633d
+++ b/sw/source/filter/ww8/wrtww8.hxx
f0633d
@@ -1187,6 +1187,7 @@ struct WW8_Annotation
f0633d
     const OutlinerParaObject* mpRichText;
f0633d
     String msSimpleText;
f0633d
     String msOwner;
f0633d
+    String m_sInitials;
f0633d
     DateTime maDateTime;
f0633d
     WW8_Annotation(const SwPostItField* pPostIt);
f0633d
     WW8_Annotation(const SwRedlineData* pRedline);
f0633d
-- 
f0633d
1.8.4.2
f0633d