[Libreoffice-commits] core.git: sd/source

Rohan Kumar rohankanojia420 at gmail.com
Tue May 30 17:08:42 UTC 2017


 sd/source/ui/dlg/prltempl.cxx |   44 ++++++++++++++++++++++++++++++++++++++----
 sd/source/ui/func/futempl.cxx |   27 +++++++------------------
 2 files changed, 48 insertions(+), 23 deletions(-)

New commits:
commit 4c5ce12608526e76d90a400fa3f499ab83528e90
Author: Rohan Kumar <rohankanojia420 at gmail.com>
Date:   Sun Apr 9 03:43:38 2017 +0530

    Fix highlighting in sd::FuTemplate
    
    sd::FuTemplate Highlighting tab's colors don't stick anymore.
    
    Change-Id: Idb1701ddf1f7d47758a4ef8ebe6705ee6ff16c11
    Reviewed-on: https://gerrit.libreoffice.org/35800
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/sd/source/ui/dlg/prltempl.cxx b/sd/source/ui/dlg/prltempl.cxx
index 3573b27bd929..0f5e3db0c55b 100644
--- a/sd/source/ui/dlg/prltempl.cxx
+++ b/sd/source/ui/dlg/prltempl.cxx
@@ -31,6 +31,7 @@
 #include <vcl/graph.hxx>
 #include <editeng/lrspitem.hxx>
 #include <editeng/numitem.hxx>
+#include <editeng/colritem.hxx>
 #include <svl/cjkoptions.hxx>
 
 #include "DrawDocShell.hxx"
@@ -63,6 +64,8 @@ SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
         pOutSet             ( nullptr ),
         pOrgSet             ( &rStyleBase.GetItemSet() )
 {
+    const SfxPoolItem *pItem = nullptr;
+
     if( IS_OUTLINE(ePO))
     {
         // Unfortunately, the Itemsets of our style sheets are not discreet..
@@ -93,7 +96,6 @@ SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
         pOutSet = new SfxItemSet( rStyleBase.GetItemSet() );
         pOutSet->ClearItem();
 
-        const SfxPoolItem *pItem = nullptr;
 
         // If there is no bullet item in this stylesheet, we get it
         // from 'Outline 1' style sheet.
@@ -110,10 +112,44 @@ SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
         // preselect selected layer in dialog
         aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
 
-        SetInputSet( &aInputSet );
+        /*
+         * Adjusting item set since background tabpage can only work
+         * with SvxBrushItems, EE_CHAR_BKGCOLOR is SvxBackgroundColorItem.
+         */
+        aInputSet.MergeRange(SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR);
+        pOutSet->MergeRange(SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR);
+        if ( aInputSet.GetItemState( EE_CHAR_BKGCOLOR, true, &pItem ) == SfxItemState::SET )
+        {
+            /* extract Color outta SvxBackColorItem */
+            Color aBackColor = static_cast<const SvxBackgroundColorItem*>(pItem)->GetValue();
+            /* make new SvxBrushItem with this Color */
+            SvxBrushItem aBrushItem( aBackColor, SID_ATTR_BRUSH_CHAR );
+
+            aInputSet.ClearItem( EE_CHAR_BKGCOLOR );
+            /* and stick it into the set */
+            aInputSet.Put( aBrushItem );
+        }
     }
-    else
-        SetInputSet( pOrgSet );
+    else {
+        /*
+         * same here
+         */
+        aInputSet.SetRanges(pOrgSet->GetRanges());
+        aInputSet.MergeRange(SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR);
+        aInputSet.Put(*pOrgSet, false);
+        if ( pOrgSet->GetItemState( EE_CHAR_BKGCOLOR, true, &pItem ) == SfxItemState::SET )
+        {
+            /* extract Color outta SvxBackColorItem */
+            Color aBackColor = static_cast<const SvxBackgroundColorItem*>(pItem)->GetValue();
+            /* make new SvxBrushItem with this Color */
+            SvxBrushItem aBrushItem( aBackColor, SID_ATTR_BRUSH_CHAR );
+
+            aInputSet.ClearItem( EE_CHAR_BKGCOLOR );
+            /* and stick it into the set */
+            aInputSet.Put( aBrushItem );
+        }
+    }
+    SetInputSet( &aInputSet );
 
     SvxColorListItem aColorListItem(*static_cast<const SvxColorListItem*>( mpDocShell->GetItem( SID_COLOR_TABLE ) ) );
     SvxGradientListItem aGradientListItem(*static_cast<const SvxGradientListItem*>( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) );
diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx
index 51a074342c25..3a5ce9adb82e 100644
--- a/sd/source/ui/func/futempl.cxx
+++ b/sd/source/ui/func/futempl.cxx
@@ -105,10 +105,6 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
     SfxStyleSheetBase* pStyleSheet = nullptr;
 
     const SfxPoolItem* pItem;
-    static const sal_uInt16 aRanges[] = {
-        EE_ITEMS_START, EE_ITEMS_END,
-        SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR
-    };
     SfxStyleFamily nFamily = (SfxStyleFamily)USHRT_MAX;
     if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY,
         false, &pItem ))
@@ -305,15 +301,6 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
                 ScopedVclPtr<SfxAbstractTabDialog> pPresDlg;
                 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
                 bool bOldDocInOtherLanguage = false;
-                SfxItemSet aNewAttr(mpViewShell->GetPool(), aRanges);
-
-                if( aNewAttr.GetItemState( XATTR_FILLBACKGROUND, true, &pItem ) == SfxItemState::SET)
-                {
-                    Color aBackColor = static_cast<const SvxBackgroundColorItem*>(pItem)->GetValue();
-                    SvxBrushItem aBrushItem(aBackColor, XATTR_FILLBACKGROUND);
-                    aNewAttr.ClearItem(XATTR_FILLBACKGROUND);
-                    aNewAttr.Put(aBrushItem);
-                }
 
                 SfxStyleFamily eFamily = pStyleSheet->GetFamily();
 
@@ -412,15 +399,17 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
                         if (eFamily == SD_STYLE_FAMILY_PSEUDO)
                         {
                             SfxItemSet aTempSet(*pOutSet);
-                            static_cast<SdStyleSheet*>(pStyleSheet)->AdjustToFontHeight(aTempSet);
+                            /* Extract SvxBrushItem out of set and insert SvxBackgroundColorItem */
+                            const SvxBrushItem* pBrushItem = aTempSet.GetItem<SvxBrushItem>( SID_ATTR_BRUSH_CHAR );
 
-                            const SvxBrushItem* pBrushItem = aTempSet.GetItem<SvxBrushItem>(XATTR_FILLBACKGROUND);
-                            if( pBrushItem )
+                            if ( pBrushItem )
                             {
-                               SvxBackgroundColorItem aBackColorItem( pBrushItem->GetColor(), EE_CHAR_BKGCOLOR);
-                               aTempSet.ClearItem(XATTR_FILLBACKGROUND);
-                               aTempSet.Put(aBackColorItem);
+                                SvxBackgroundColorItem aBackColorItem(pBrushItem->GetColor(), EE_CHAR_BKGCOLOR);
+                                aTempSet.ClearItem( EE_CHAR_BKGCOLOR );
+                                aTempSet.Put( aBackColorItem );
                             }
+                            static_cast<SdStyleSheet*>(pStyleSheet)->AdjustToFontHeight(aTempSet);
+
                             /* Special treatment: reset the INVALIDS to
                                NULL-Pointer (otherwise INVALIDs or pointer point
                                to DefaultItems in the template; both would


More information about the Libreoffice-commits mailing list