sd/source/ui/sidebar/SlideBackground.cxx |   94 +++++++++++++++++++++++++++++--
 sd/source/ui/sidebar/SlideBackground.hxx |    4 +
 sd/source/ui/view/drviews7.cxx           |   18 ++---
 3 files changed, 102 insertions(+), 14 deletions(-)

New commits:
commit d7859f40b0b51c88ea78967ace3f62f76d9786c1
Author: Katarina Behrens <katarina.behr...@cib.de>
Date:   Fri May 6 18:54:18 2016 +0200

    tdf#89466: Switching between different fill types work now
    
    ... somehow ...
    
    Change-Id: I6a9ccc60f35a2be092a60c01db04018b736a18b7
    Reviewed-on: https://gerrit.libreoffice.org/24706
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Katarina Behrens <katarina.behr...@cib.de>

diff --git a/sd/source/ui/sidebar/SlideBackground.cxx 
b/sd/source/ui/sidebar/SlideBackground.cxx
index 67ab9fc..8a37213 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -220,7 +220,7 @@ void SlideBackground::Update()
             const SvxColorListItem aItem( *static_cast<const 
SvxColorListItem*>(pSh->GetItem(SID_COLOR_TABLE)));
             mpFillLB->Fill(aItem.GetColorList());
 
-            const Color aColor = mpColorItem->GetColorValue();
+            const Color aColor = GetColorSetOrDefault();
             mpFillLB->SelectEntry( aColor );
 
             if(mpFillLB->GetSelectEntryCount() == 0)
@@ -241,7 +241,7 @@ void SlideBackground::Update()
             mpFillLB->Fill(aItem.GetColorList());
             mpFillGrad->Fill(aItem.GetColorList());
 
-            const XGradient xGradient = mpGradientItem->GetGradientValue();
+            const XGradient xGradient = GetGradientSetOrDefault();
             const Color aStartColor = xGradient.GetStartColor();
             const Color aEndColor = xGradient.GetEndColor();
             mpFillLB->SelectEntry( aStartColor );
@@ -270,7 +270,7 @@ void SlideBackground::Update()
             mpFillAttr->Fill(aItem.GetHatchList());
             mpFillGrad->Hide();
 
-            const OUString aHatchName = mpHatchItem->GetName();
+            const OUString aHatchName = GetHatchingSetOrDefault();
             mpFillAttr->SelectEntry( aHatchName );
         }
         break;
@@ -284,7 +284,7 @@ void SlideBackground::Update()
             mpFillAttr->Fill(aItem.GetBitmapList());
             mpFillGrad->Hide();
 
-            const OUString aBitmapName = mpBitmapItem->GetName();
+            const OUString aBitmapName = GetBitmapSetOrDefault();
             mpFillAttr->SelectEntry( aBitmapName );
         }
         break;
@@ -321,10 +321,65 @@ void SlideBackground::dispose()
     PanelLayout::dispose();
 }
 
+Color SlideBackground::GetColorSetOrDefault()
+{
+   // Tango Sky Blue 1, to be consistent w/ area fill panel (b/c COL_AUTO for 
slides is transparent)
+   if ( !mpColorItem )
+        mpColorItem.reset( new XFillColorItem( OUString(), Color(0x72, 0x9f, 
0xcf) ) );
+
+   return mpColorItem->GetColorValue();
+}
+
+XGradient SlideBackground::GetGradientSetOrDefault()
+{
+    if( !mpGradientItem )
+    {
+        SfxObjectShell* pSh = SfxObjectShell::Current();
+        const SvxGradientListItem aGradListItem(*static_cast<const 
SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST)));
+        const XGradient aGradient = 
aGradListItem.GetGradientList()->GetGradient(0)->GetGradient();
+        const OUString aGradientName = 
aGradListItem.GetGradientList()->GetGradient(0)->GetName();
+
+        mpGradientItem.reset( new XFillGradientItem( aGradientName, aGradient 
) );
+    }
+
+    return mpGradientItem->GetGradientValue();
+}
+
+const OUString SlideBackground::GetHatchingSetOrDefault()
+{
+    if( !mpHatchItem )
+    {
+        SfxObjectShell* pSh = SfxObjectShell::Current();
+        const SvxHatchListItem aHatchListItem(*static_cast<const 
SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST)));
+        const XHatch aHatch = 
aHatchListItem.GetHatchList()->GetHatch(0)->GetHatch();
+        const OUString aHatchName = 
aHatchListItem.GetHatchList()->GetHatch(0)->GetName();
+
+        mpHatchItem.reset( new XFillHatchItem( aHatchName, aHatch ) );
+    }
+
+    return mpHatchItem->GetName();
+}
+
+const OUString SlideBackground::GetBitmapSetOrDefault()
+{
+    if( !mpBitmapItem )
+    {
+        SfxObjectShell* pSh = SfxObjectShell::Current();
+        const SvxBitmapListItem aBmpListItem(*static_cast<const 
SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST)));
+        const GraphicObject aGraphObj = 
aBmpListItem.GetBitmapList()->GetBitmap(0)->GetGraphicObject();
+        const OUString aBmpName = 
aBmpListItem.GetBitmapList()->GetBitmap(0)->GetName();
+
+        mpBitmapItem.reset( new XFillBitmapItem( aBmpName, aGraphObj ) );
+    }
+
+    return mpBitmapItem->GetName();
+}
+
 void SlideBackground::DataChanged (const DataChangedEvent& /*rEvent*/)
 {
 
 }
+
 void SlideBackground::NotifyItemUpdate(
     const sal_uInt16 nSID,
     const SfxItemState eState,
@@ -492,7 +547,33 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, FillStyleModifyHdl, 
ListBox&, void)
     const drawing::FillStyle eXFS = 
(drawing::FillStyle)mpFillStyle->GetSelectEntryPos();
     const XFillStyleItem aXFillStyleItem(eXFS);
     Update();
-    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_FILLSTYLE, 
SfxCallMode::RECORD, { &aXFillStyleItem });
+
+    switch (eXFS)
+    {
+        case drawing::FillStyle_SOLID:
+        {
+            XFillColorItem aItem( OUString(), mpColorItem->GetColorValue() );
+            GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, 
SfxCallMode::RECORD, { &aItem });
+        }
+        break;
+
+        case drawing::FillStyle_GRADIENT:
+        {
+            XFillGradientItem aItem( mpGradientItem->GetName(), 
mpGradientItem->GetGradientValue() );
+            
GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, 
SfxCallMode::RECORD, { &aItem });
+        }
+        break;
+
+        case drawing::FillStyle_HATCH:
+        {
+            XFillHatchItem aItem( mpHatchItem->GetName(), 
mpHatchItem->GetHatchValue() );
+            GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, 
SfxCallMode::RECORD, { &aItem });
+        }
+        break;
+
+        default:
+        break;
+    }
 }
 
 IMPL_LINK_NOARG_TYPED(SlideBackground, PaperSizeModifyHdl, ListBox&, void)
@@ -532,6 +613,7 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, FillColorHdl, 
ListBox&, void)
             XGradient aGradient;
             aGradient.SetStartColor(mpFillLB->GetSelectEntryColor());
             aGradient.SetEndColor(mpFillGrad->GetSelectEntryColor());
+
             XFillGradientItem aItem(aGradient);
             
GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, 
SfxCallMode::RECORD, { &aItem });
         }
@@ -554,6 +636,7 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, FillBackgroundHdl, 
ListBox&, void)
             sal_uInt16 nPos = mpFillAttr->GetSelectEntryPos();
             XHatch aHatch = 
aHatchListItem.GetHatchList()->GetHatch(nPos)->GetHatch();
             const OUString aHatchName = 
aHatchListItem.GetHatchList()->GetHatch(nPos)->GetName();
+
             XFillHatchItem aItem(aHatchName, aHatch);
             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, 
SfxCallMode::RECORD, { &aItem });
         }
@@ -565,6 +648,7 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, FillBackgroundHdl, 
ListBox&, void)
             sal_Int16 nPos = mpFillAttr->GetSelectEntryPos();
             GraphicObject aBitmap = 
aBitmapListItem.GetBitmapList()->GetBitmap(nPos)->GetGraphicObject();
             OUString aBitmapName = 
aBitmapListItem.GetBitmapList()->GetBitmap(nPos)->GetName();
+
             XFillBitmapItem aItem(aBitmapName, aBitmap);
             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, 
SfxCallMode::RECORD, { &aItem });
         }
diff --git a/sd/source/ui/sidebar/SlideBackground.hxx 
b/sd/source/ui/sidebar/SlideBackground.hxx
index 89a71ba..1497029 100644
--- a/sd/source/ui/sidebar/SlideBackground.hxx
+++ b/sd/source/ui/sidebar/SlideBackground.hxx
@@ -112,6 +112,10 @@ private:
 
     void Initialize();
     void Update();
+    Color GetColorSetOrDefault();
+    XGradient GetGradientSetOrDefault();
+    const OUString GetHatchingSetOrDefault();
+    const OUString GetBitmapSetOrDefault();
 };
 
 }}
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index fbc9ef5b..9737d97 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1649,11 +1649,8 @@ void DrawViewShell::GetPageProperties( SfxItemSet &rSet )
         rSet.Put(SvxSizeItem( SID_ATTR_PAGE_SIZE, pPage->GetSize() ));
         rSet.Put(aPageItem);
 
-        SfxItemSet aMergedAttr(GetDoc()->GetPool(), XATTR_FILL_FIRST, 
XATTR_FILL_LAST, 0);
-        SdStyleSheet* pStyleSheet = 
pPage->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND);
-        MergePageBackgroundFilling(pPage, pStyleSheet, meEditMode == 
EM_MASTERPAGE, aMergedAttr);
-
-        drawing::FillStyle eXFS = (drawing::FillStyle) static_cast<const 
XFillStyleItem*>( aMergedAttr.GetItem( XATTR_FILLSTYLE ) )->GetValue();
+        const SfxItemSet &rPageAttr = 
pPage->getSdrPageProperties().GetItemSet();
+        drawing::FillStyle eXFS = (drawing::FillStyle) static_cast<const 
XFillStyleItem*>( rPageAttr.GetItem( XATTR_FILLSTYLE ) )->GetValue();
         XFillStyleItem aFillStyleItem( eXFS );
         aFillStyleItem.SetWhich( SID_ATTR_PAGE_FILLSTYLE );
         rSet.Put(aFillStyleItem);
@@ -1662,7 +1659,7 @@ void DrawViewShell::GetPageProperties( SfxItemSet &rSet )
         {
             case (drawing::FillStyle_SOLID):
             {
-                Color aColor =  static_cast<const XFillColorItem*>( 
aMergedAttr.GetItem( XATTR_FILLCOLOR ) )->GetColorValue();
+                Color aColor =  static_cast<const XFillColorItem*>( 
rPageAttr.GetItem( XATTR_FILLCOLOR ) )->GetColorValue();
                 XFillColorItem aFillColorItem( OUString(), aColor );
                 aFillColorItem.SetWhich( SID_ATTR_PAGE_COLOR );
                 rSet.Put( aFillColorItem );
@@ -1671,26 +1668,29 @@ void DrawViewShell::GetPageProperties( SfxItemSet &rSet 
)
 
             case (drawing::FillStyle_GRADIENT):
             {
-                const XGradient& xGradient =  static_cast<const 
XFillGradientItem*>( aMergedAttr.GetItem( XATTR_FILLGRADIENT ) 
)->GetGradientValue();
+                const XGradient& xGradient =  static_cast<const 
XFillGradientItem*>( rPageAttr.GetItem( XATTR_FILLGRADIENT ) 
)->GetGradientValue();
                 XFillGradientItem aFillGradientItem( OUString(), xGradient, 
SID_ATTR_PAGE_GRADIENT  );
                 rSet.Put( aFillGradientItem );
             }
+            break;
 
             case (drawing::FillStyle_HATCH):
             {
-                const XFillHatchItem *pFillHatchItem( static_cast<const 
XFillHatchItem*>( aMergedAttr.GetItem( XATTR_FILLHATCH ) ) );
+                const XFillHatchItem *pFillHatchItem( static_cast<const 
XFillHatchItem*>( rPageAttr.GetItem( XATTR_FILLHATCH ) ) );
                 XFillHatchItem aFillHatchItem( pFillHatchItem->GetName(), 
pFillHatchItem->GetHatchValue());
                 aFillHatchItem.SetWhich( SID_ATTR_PAGE_HATCH );
                 rSet.Put( aFillHatchItem );
             }
+            break;
 
             case (drawing::FillStyle_BITMAP):
             {
-                const XFillBitmapItem *pFillBitmapItem = static_cast<const 
XFillBitmapItem*>( aMergedAttr.GetItem( XATTR_FILLBITMAP ) );
+                const XFillBitmapItem *pFillBitmapItem = static_cast<const 
XFillBitmapItem*>( rPageAttr.GetItem( XATTR_FILLBITMAP ) );
                 XFillBitmapItem aFillBitmapItem( pFillBitmapItem->GetName(), 
pFillBitmapItem->GetGraphicObject() );
                 aFillBitmapItem.SetWhich( SID_ATTR_PAGE_BITMAP );
                 rSet.Put( aFillBitmapItem );
             }
+            break;
 
             default:
             break;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to