Blame SOURCES/0001-Resolves-rhbz-1193971-clear-hard-coded-char-props-in.patch

ebc4bd
From dffb7a52ddba02b725d0f1d2438931e20655475f Mon Sep 17 00:00:00 2001
ebc4bd
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
ebc4bd
Date: Wed, 18 Feb 2015 15:04:45 +0000
ebc4bd
Subject: [PATCH] Resolves: rhbz#1193971 clear hard-coded char props in table
ebc4bd
 cells...
ebc4bd
MIME-Version: 1.0
ebc4bd
Content-Type: text/plain; charset=UTF-8
ebc4bd
Content-Transfer-Encoding: 8bit
ebc4bd
ebc4bd
like we do already for shapes. So now when attempting to set replacement char
ebc4bd
properties on the entire cell, clear any hard-coded sub ranges within the
ebc4bd
existing paragraphs.
ebc4bd
ebc4bd
This extends the effort of
ebc4bd
commit a217f3cb2dce71a4322f78ceb45edb6f171b2b65
ebc4bd
Author: Matúš Kukan <matus.kukan@collabora.com>
ebc4bd
Date:   Tue Aug 26 10:16:34 2014 +0200
ebc4bd
ebc4bd
    bnc#770711: Make changing table text color in impress always work
ebc4bd
ebc4bd
to encompass all character properties, not just color
ebc4bd
ebc4bd
(cherry picked from commit b14259b946686c753c0df42c519fc2537e871601)
ebc4bd
ebc4bd
Conflicts:
ebc4bd
	svx/source/table/cell.cxx
ebc4bd
ebc4bd
Change-Id: If8b426c3531b4678868d8351426db32c3c558650
ebc4bd
---
ebc4bd
 svx/source/svdraw/svdedtv1.cxx | 38 ++++++++++++++++++++++----------------
ebc4bd
 svx/source/table/cell.cxx      | 15 +++++++++++++--
ebc4bd
 2 files changed, 35 insertions(+), 18 deletions(-)
ebc4bd
ebc4bd
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
ebc4bd
index 7945d2c..928f9e2 100644
ebc4bd
--- a/svx/source/svdraw/svdedtv1.cxx
ebc4bd
+++ b/svx/source/svdraw/svdedtv1.cxx
ebc4bd
@@ -953,6 +953,26 @@ void SdrEditView::MergeAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) con
ebc4bd
     }
ebc4bd
 }
ebc4bd
 
ebc4bd
+std::vector<sal_uInt16> GetAllCharPropIds(const SfxItemSet& rSet)
ebc4bd
+{
ebc4bd
+    std::vector<sal_uInt16> aCharWhichIds;
ebc4bd
+    {
ebc4bd
+        SfxItemIter aIter(rSet);
ebc4bd
+        const SfxPoolItem* pItem=aIter.FirstItem();
ebc4bd
+        while (pItem!=NULL)
ebc4bd
+        {
ebc4bd
+            if (!IsInvalidItem(pItem))
ebc4bd
+            {
ebc4bd
+                sal_uInt16 nWhich = pItem->Which();
ebc4bd
+                if (nWhich>=EE_CHAR_START && nWhich<=EE_CHAR_END)
ebc4bd
+                    aCharWhichIds.push_back( nWhich );
ebc4bd
+            }
ebc4bd
+            pItem=aIter.NextItem();
ebc4bd
+        }
ebc4bd
+    }
ebc4bd
+    return aCharWhichIds;
ebc4bd
+}
ebc4bd
+
ebc4bd
 void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
ebc4bd
 {
ebc4bd
     if (AreObjectsMarked())
ebc4bd
@@ -977,25 +997,11 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
ebc4bd
         }
ebc4bd
 #endif
ebc4bd
 
ebc4bd
-        // #103836# if the user thets character attributes to the complete shape,
ebc4bd
+        // #103836# if the user sets character attributes to the complete shape,
ebc4bd
         //          we want to remove all hard set character attributes with same
ebc4bd
         //          which ids from the text. We do that later but here we remember
ebc4bd
         //          all character attribute which id's that are set.
ebc4bd
-        std::vector<sal_uInt16> aCharWhichIds;
ebc4bd
-        {
ebc4bd
-            SfxItemIter aIter(rAttr);
ebc4bd
-            const SfxPoolItem* pItem=aIter.FirstItem();
ebc4bd
-            while( pItem!=NULL )
ebc4bd
-            {
ebc4bd
-                if (!IsInvalidItem(pItem))
ebc4bd
-                {
ebc4bd
-                    sal_uInt16 nWhich = pItem->Which();
ebc4bd
-                    if (nWhich>=EE_CHAR_START && nWhich<=EE_CHAR_END)
ebc4bd
-                        aCharWhichIds.push_back( nWhich );
ebc4bd
-                }
ebc4bd
-                pItem=aIter.NextItem();
ebc4bd
-            }
ebc4bd
-        }
ebc4bd
+        std::vector<sal_uInt16> aCharWhichIds(GetAllCharPropIds(rAttr));
ebc4bd
 
ebc4bd
         // To make Undo reconstruct text attributes correctly after Format.Standard
ebc4bd
         bool bHasEEItems=SearchOutlinerItems(rAttr,bReplaceAll);
ebc4bd
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
ebc4bd
index 8d64dbc..7c2e5eb 100644
ebc4bd
--- a/svx/source/table/cell.cxx
ebc4bd
+++ b/svx/source/table/cell.cxx
ebc4bd
@@ -139,6 +139,8 @@ SdrText* CellTextProvider::getText(sal_Int32 nIndex) const
ebc4bd
 
ebc4bd
 }
ebc4bd
 
ebc4bd
+extern std::vector<sal_uInt16> GetAllCharPropIds(const SfxItemSet& rSet);
ebc4bd
+
ebc4bd
 namespace sdr
ebc4bd
 {
ebc4bd
     namespace properties
ebc4bd
@@ -261,12 +263,21 @@ namespace sdr
ebc4bd
 
ebc4bd
                     sal_Int32 nParaCount(pOutliner->GetParagraphCount());
ebc4bd
 
ebc4bd
+                    // if the user sets character attributes to the complete
ebc4bd
+                    // cell we want to remove all hard set character attributes
ebc4bd
+                    // with same which ids from the text
ebc4bd
+                    std::vector<sal_uInt16> aCharWhichIds(GetAllCharPropIds(rSet));
ebc4bd
+
ebc4bd
                     for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
ebc4bd
                     {
ebc4bd
                         SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
ebc4bd
                         aSet.Put(rSet);
ebc4bd
-                        if (aSet.GetItemState(EE_CHAR_COLOR, false) == SFX_ITEM_ON)
ebc4bd
-                            pOutliner->QuickRemoveCharAttribs( nPara, EE_CHAR_COLOR );
ebc4bd
+
ebc4bd
+                        for (std::vector<sal_uInt16>::const_iterator aI = aCharWhichIds.begin(); aI != aCharWhichIds.end(); ++aI)
ebc4bd
+                        {
ebc4bd
+                            pOutliner->QuickRemoveCharAttribs(nPara, *aI);
ebc4bd
+                        }
ebc4bd
+
ebc4bd
                         pOutliner->SetParaAttribs(nPara, aSet);
ebc4bd
                     }
ebc4bd
 
ebc4bd
-- 
ebc4bd
1.9.3
ebc4bd