[PATCH libreoffice-4-0] fdo#53442 SwTxtPaintInfo::_DrawBackBrush: color multi-para c...

Miklos Vajna (via Code Review) gerrit at gerrit.libreoffice.org
Wed Mar 27 09:29:02 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3094

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/94/3094/1

fdo#53442 SwTxtPaintInfo::_DrawBackBrush: color multi-para comment ranges

(cherry picked from commits 82b29b9d384211061653f35695287be60dbc99b8 and
5ddcaa86003c6a28c4a9b307cdf3b37deabaa5a4)

Change-Id: Ieb9a33cda8297b432e1d0ea8224ba9231b6ac2c1
---
M sw/inc/docufld.hxx
M sw/source/core/fields/docufld.cxx
M sw/source/core/text/inftxt.cxx
M sw/source/core/unocore/unoportenum.cxx
4 files changed, 33 insertions(+), 31 deletions(-)



diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index 0779b25..35ea4c1 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -34,6 +34,7 @@
 class SwFrm;
 class OutlinerParaObject;
 class SwTextAPIObject;
+class SwFmtFld;
 
 enum SwAuthorFormat
 {
@@ -530,6 +531,9 @@
                    const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDate);
     ~SwPostItField();
 
+    /// Looks up a field identified by its unique name (used to get the postit field of a comment fieldmark)
+    static const SwFmtFld* GetByName(SwDoc* pDoc, const OUString& rName);
+
     virtual String          Expand() const;
     virtual SwField*        Copy() const;
 
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index de0d3a8..ebee259 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -92,6 +92,7 @@
 #include <editeng/outliner.hxx>
 #include <editeng/outlobj.hxx>
 #include <switerator.hxx>
+#include <docary.hxx>
 
 #define URL_DECODE  INetURLObject::DECODE_UNAMBIGUOUS
 
@@ -1753,6 +1754,27 @@
     }
 }
 
+const SwFmtFld* SwPostItField::GetByName(SwDoc* pDoc, const OUString& rName)
+{
+    const SwFldTypes* pFldTypes = pDoc->GetFldTypes();
+    sal_uInt16 nCount = pFldTypes->size();
+    for (sal_uInt16 nType = 0; nType < nCount; ++nType)
+    {
+        const SwFieldType *pCurType = (*pFldTypes)[nType];
+        SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType);
+        for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next())
+        {
+            // Ignore the field if it's not an annotation or it doesn't have an anchor.
+            if (pCurFldFmt->GetFld()->GetTyp()->Which() != RES_POSTITFLD || !pCurFldFmt->GetTxtFld())
+                continue;
+
+            const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetFld());
+            if (pField->GetName() == rName)
+                return pCurFldFmt;
+        }
+    }
+    return 0;
+}
 
 String SwPostItField::Expand() const
 {
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 2785e92..42cdbe2 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -66,6 +66,7 @@
 #include <cstdio>
 // #i12836# enhanced pdf export
 #include <EnhancedPDFExportHelper.hxx>
+#include <docufld.hxx>
 
 #include <unomid.h>
 
@@ -1106,17 +1107,14 @@
                 // If this is a comment range, need to look up the color of the comment author.
                 if (pFieldmark->GetFieldname() == ODF_COMMENTRANGE)
                 {
-                    // Search for the position of the postit field
-                    const sal_Unicode fld[] = { CH_TXTATR_INWORD, 0 };
-                    xub_StrLen nEndIdx = GetTxt().SearchChar(fld, GetIdx());
-                    if (nEndIdx != STRING_NOTFOUND)
+                    // Search for the postit field
+                    const SwFmtFld* pField = SwPostItField::GetByName(pNd->GetDoc(), pFieldmark->GetName());
+                    if (pField)
                     {
-                        SwTxtAttr* pTxtAttr = pNd->GetTxtAttrForCharAt(nEndIdx, RES_TXTATR_FIELD);
-                        const SwFmtFld& rPostItField = pTxtAttr->GetFld();
                         // Look up the author name
-                        const OUString& rAuthor = rPostItField.GetFld()->GetPar1();
+                        const OUString& rAuthor = pField->GetFld()->GetPar1();
                         sal_uInt16 nIndex = pNd->GetDoc()->InsertRedlineAuthor(rAuthor);
-                        pOutDev->SetFillColor( SwPostItMgr::GetColorLight(nIndex) );
+                        pOutDev->SetFillColor(SwPostItMgr::GetColorLight(nIndex));
                         bFilled = true;
                     }
                 }
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 2829d3f..788965a 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -320,28 +320,6 @@
     }
 }
 
-static const SwFmtFld* lcl_getFieldByName(SwDoc* pDoc, const OUString& rName)
-{
-    const SwFldTypes* pFldTypes = pDoc->GetFldTypes();
-    sal_uInt16 nCount = pFldTypes->size();
-    for (sal_uInt16 nType = 0; nType < nCount; ++nType)
-    {
-        const SwFieldType *pCurType = (*pFldTypes)[nType];
-        SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType);
-        for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next())
-        {
-            // Ignore the field if it's not an annotation or it doesn't have an anchor.
-            if (pCurFldFmt->GetFld()->GetTyp()->Which() != RES_POSTITFLD || !pCurFldFmt->GetTxtFld())
-                continue;
-
-            const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetFld());
-            if (pField->GetName() == rName)
-                return pCurFldFmt;
-        }
-    }
-    return 0;
-}
-
 static uno::Reference<text::XTextRange>
 lcl_ExportFieldMark(
         uno::Reference< text::XText > const & i_xParentText,
@@ -378,7 +356,7 @@
         {
             pPortion->SetBookmark( SwXFieldmark::CreateXFieldmark( *pDoc, *pFieldmark ) );
             Reference<XTextField> xField;
-            const SwFmtFld* pField = lcl_getFieldByName(pDoc, pFieldmark->GetName());
+            const SwFmtFld* pField = SwPostItField::GetByName(pDoc, pFieldmark->GetName());
             if (pField)
                 xField = SwXTextField::CreateSwXTextField(*pDoc, *pField);
             pPortion->SetTextField(xField);

-- 
To view, visit https://gerrit.libreoffice.org/3094
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb9a33cda8297b432e1d0ea8224ba9231b6ac2c1
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos at suse.cz>



More information about the LibreOffice mailing list