Blame SOURCES/0001-implement-save-slide-background-for-impress.patch

f325b2
From 402f64fc8464366015259d44e238a77cb7d9d776 Mon Sep 17 00:00:00 2001
f325b2
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f325b2
Date: Wed, 30 Sep 2015 13:30:36 +0100
f325b2
Subject: [PATCH] implement save slide background for impress
f325b2
f325b2
to go along with the existing "set background",
f325b2
same sort of thing as the competitor's effort
f325b2
f325b2
(cherry picked from commit ed25a000ab67324075e68d9a7f3ca657b4e6a573)
f325b2
f325b2
Change-Id: I2a1106771ead2cd926f3d631850447499340697c
f325b2
---
f325b2
 sd/inc/app.hrc                     |  3 +-
f325b2
 sd/inc/sdcommands.h                |  1 +
f325b2
 sd/sdi/_drvwsh.sdi                 |  5 +++
f325b2
 sd/sdi/sdraw.sdi                   | 24 +++++++++++
f325b2
 sd/source/ui/app/menuids_tmpl.src  | 11 ++++-
f325b2
 sd/source/ui/func/fupage.cxx       | 85 +++++++++++++++++++++++---------------
f325b2
 sd/source/ui/inc/DrawViewShell.hxx |  4 ++
f325b2
 sd/source/ui/view/drviews2.cxx     |  1 +
f325b2
 sd/source/ui/view/drviews7.cxx     | 25 ++++++++++-
f325b2
 9 files changed, 122 insertions(+), 37 deletions(-)
f325b2
f325b2
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc
f325b2
index 4f3d82e..956c7d4 100644
f325b2
--- a/sd/inc/app.hrc
f325b2
+++ b/sd/inc/app.hrc
f325b2
@@ -421,7 +421,8 @@
f325b2
 #define SID_SLIDE_SORTER_MULTI_PANE_GUI     (SID_SD_START+421)
f325b2
 
f325b2
 #define SID_SELECT_BACKGROUND               (SID_SD_START+422)
f325b2
-
f325b2
+#define SID_SAVE_BACKGROUND                 (SID_SD_START+423)
f325b2
+        // FREE
f325b2
 // Slots for the tool pane popup
f325b2
 #define SID_TP_APPLY_TO_ALL_SLIDES          (SID_SD_START+425)
f325b2
 #define SID_TP_APPLY_TO_SELECTED_SLIDES     (SID_SD_START+426)
f325b2
diff --git a/sd/inc/sdcommands.h b/sd/inc/sdcommands.h
f325b2
index 2f4bf56..1d3502f 100644
f325b2
--- a/sd/inc/sdcommands.h
f325b2
+++ b/sd/inc/sdcommands.h
f325b2
@@ -90,6 +90,7 @@
f325b2
 #define CMD_SID_DELETE_MASTER_PAGE                  ".uno:DeleteMasterPage"
f325b2
 #define CMD_SID_RENAME_MASTER_PAGE                  ".uno:RenameMasterPage"
f325b2
 #define CMD_SID_SELECT_BACKGROUND                   ".uno:SelectBackground"
f325b2
+#define CMD_SID_SAVE_BACKGROUND                     ".uno:SaveBackground"
f325b2
 #define CMD_SID_DISPLAY_MASTER_BACKGROUND           ".uno:DisplayMasterBackground"
f325b2
 #define CMD_SID_DISPLAY_MASTER_OBJECTS              ".uno:DisplayMasterObjects"
f325b2
 #define CMD_SID_TABLE_DISTRIBUTE_COLUMNS            ".uno:DistributeColumns"
f325b2
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
f325b2
index 263a8ed..28ee22c 100644
f325b2
--- a/sd/sdi/_drvwsh.sdi
f325b2
+++ b/sd/sdi/_drvwsh.sdi
f325b2
@@ -2662,6 +2662,11 @@ interface DrawView
f325b2
         ExecMethod = FuTemporary ;
f325b2
         StateMethod = GetMenuState ;
f325b2
     ]
f325b2
+    SID_SAVE_BACKGROUND
f325b2
+    [
f325b2
+        ExecMethod = FuTemporary ;
f325b2
+        StateMethod = GetMenuState ;
f325b2
+    ]
f325b2
     SID_DISPLAY_MASTER_BACKGROUND
f325b2
     [
f325b2
         ExecMethod = FuTemporary ;
f325b2
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
f325b2
index 7297c1f..d2d5d28 100644
f325b2
--- a/sd/sdi/sdraw.sdi
f325b2
+++ b/sd/sdi/sdraw.sdi
f325b2
@@ -6439,6 +6439,30 @@ SfxVoidItem SelectBackground SID_SELECT_BACKGROUND
f325b2
     GroupId = GID_OPTIONS;
f325b2
 ]
f325b2
 
f325b2
+SfxVoidItem SaveBackground SID_SAVE_BACKGROUND
f325b2
+()
f325b2
+[
f325b2
+    /* flags: */
f325b2
+    AutoUpdate = FALSE,
f325b2
+    Cachable = Cachable,
f325b2
+    FastCall = FALSE,
f325b2
+    HasCoreId = FALSE,
f325b2
+    HasDialog = TRUE,
f325b2
+    ReadOnlyDoc = TRUE,
f325b2
+    Toggle = FALSE,
f325b2
+    Container = FALSE,
f325b2
+    RecordAbsolute = FALSE,
f325b2
+    RecordPerSet;
f325b2
+    Synchron;
f325b2
+
f325b2
+    /* config: */
f325b2
+    AccelConfig = FALSE,
f325b2
+    MenuConfig = FALSE,
f325b2
+    StatusBarConfig = FALSE,
f325b2
+    ToolBoxConfig = FALSE,
f325b2
+    GroupId = GID_OPTIONS;
f325b2
+]
f325b2
+
f325b2
 SfxBoolItem DisplayMasterBackground SID_DISPLAY_MASTER_BACKGROUND
f325b2
 [
f325b2
     /* flags: */
f325b2
diff --git a/sd/source/ui/app/menuids_tmpl.src b/sd/source/ui/app/menuids_tmpl.src
f325b2
index bf30830..6917de2 100644
f325b2
--- a/sd/source/ui/app/menuids_tmpl.src
f325b2
+++ b/sd/source/ui/app/menuids_tmpl.src
f325b2
@@ -138,6 +138,13 @@
f325b2
         HelpId = CMD_SID_SELECT_BACKGROUND ; \
f325b2
         Text [ en-US ] = "Set Background Image..." ; \
f325b2
     };
f325b2
+#define MN_SAVE_BACKGROUND \
f325b2
+    MenuItem\
f325b2
+    {\
f325b2
+        Identifier = SID_SAVE_BACKGROUND ; \
f325b2
+        HelpId = CMD_SID_SAVE_BACKGROUND ; \
f325b2
+        Text [ en-US ] = "Save Background Image..." ; \
f325b2
+    };
f325b2
 #define MN_DISPLAY_MASTER_BACKGROUND \
f325b2
     MenuItem\
f325b2
     {\
f325b2
@@ -169,6 +176,7 @@
f325b2
                 MN_SELECT_BACKGROUND\
f325b2
                 MN_PAGE_DESIGN\
f325b2
                 MN_RENAME_PAGE\
f325b2
+                MN_SAVE_BACKGROUND\
f325b2
             };\
f325b2
         };\
f325b2
         Text [ en-US ] = "Pag~e" ; \
f325b2
@@ -200,7 +208,8 @@
f325b2
                 MN_DISPLAY_MASTER_OBJECTS\
f325b2
             };\
f325b2
         };\
f325b2
-    };
f325b2
+    }; \
f325b2
+    MN_SAVE_BACKGROUND
f325b2
 
f325b2
  // Layer
f325b2
 #define MN_RENAME_LAYER \
f325b2
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
f325b2
index 83146e4..d3a053f 100644
f325b2
--- a/sd/source/ui/func/fupage.cxx
f325b2
+++ b/sd/source/ui/func/fupage.cxx
f325b2
@@ -36,6 +36,7 @@
f325b2
 #include <svx/svdundo.hxx>
f325b2
 #include <editeng/eeitem.hxx>
f325b2
 #include <editeng/frmdiritem.hxx>
f325b2
+#include <svx/graphichelper.hxx>
f325b2
 #include <svx/xbtmpit.hxx>
f325b2
 #include <svx/xsetit.hxx>
f325b2
 #include <editeng/ulspitem.hxx>
f325b2
@@ -164,6 +165,41 @@ void FuPage::Deactivate()
f325b2
 {
f325b2
 }
f325b2
 
f325b2
+void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr)
f325b2
+{
f325b2
+    if (bMasterPage)
f325b2
+    {
f325b2
+        if (pStyleSheet)
f325b2
+            mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
f325b2
+    }
f325b2
+    else
f325b2
+    {
f325b2
+        // Only this page, get attributes for background fill
f325b2
+        const SfxItemSet& rBackgroundAttributes = pPage->getSdrPageProperties().GetItemSet();
f325b2
+
f325b2
+        if(drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue())
f325b2
+        {
f325b2
+            // page attributes are used, take them
f325b2
+            rMergedAttr.Put(rBackgroundAttributes);
f325b2
+        }
f325b2
+        else
f325b2
+        {
f325b2
+            if(pStyleSheet
f325b2
+                && drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
f325b2
+            {
f325b2
+                // if the page has no fill style, use the settings from the
f325b2
+                // background stylesheet (if used)
f325b2
+                mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
f325b2
+            }
f325b2
+            else
f325b2
+            {
f325b2
+                // no fill style from page, start with no fill style
f325b2
+                rMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
f325b2
+            }
f325b2
+        }
f325b2
+    }
f325b2
+}
f325b2
+
f325b2
 const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
f325b2
 {
f325b2
     if (!mpDrawViewShell)
f325b2
@@ -247,44 +283,27 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
f325b2
     // merge page background filling to the dialogs input set
f325b2
     if( mbDisplayBackgroundTabPage )
f325b2
     {
f325b2
-        if( mbMasterPage )
f325b2
-        {
f325b2
-            if(pStyleSheet)
f325b2
-                mergeItemSetsImpl( aMergedAttr, pStyleSheet->GetItemSet() );
f325b2
-        }
f325b2
-        else
f325b2
-        {
f325b2
-            // Only this page, get attributes for background fill
f325b2
-            const SfxItemSet& rBackgroundAttributes = mpPage->getSdrPageProperties().GetItemSet();
f325b2
-
f325b2
-            if(drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue())
f325b2
-            {
f325b2
-                // page attributes are used, take them
f325b2
-                aMergedAttr.Put(rBackgroundAttributes);
f325b2
-            }
f325b2
-            else
f325b2
-            {
f325b2
-                if(pStyleSheet
f325b2
-                    && drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
f325b2
-                {
f325b2
-                    // if the page has no fill style, use the settings from the
f325b2
-                    // background stylesheet (if used)
f325b2
-                    mergeItemSetsImpl(aMergedAttr, pStyleSheet->GetItemSet());
f325b2
-                }
f325b2
-                else
f325b2
-                {
f325b2
-                    // no fill style from page, start with no fill style
f325b2
-                    aMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
f325b2
-                }
f325b2
-            }
f325b2
-        }
f325b2
+        MergePageBackgroundFilling(mpPage, pStyleSheet, mbMasterPage, aMergedAttr);
f325b2
     }
f325b2
 
f325b2
     boost::scoped_ptr< SfxItemSet > pTempSet;
f325b2
 
f325b2
-    if( GetSlotID() == SID_SELECT_BACKGROUND )
f325b2
+    const sal_uInt16 nId = GetSlotID();
f325b2
+    if (nId == SID_SAVE_BACKGROUND)
f325b2
+    {
f325b2
+        const XFillStyleItem& rStyleItem =
f325b2
+            static_cast<const XFillStyleItem&>(aMergedAttr.Get(XATTR_FILLSTYLE));
f325b2
+        if (drawing::FillStyle_BITMAP == (drawing::FillStyle)rStyleItem.GetValue())
f325b2
+        {
f325b2
+            const XFillBitmapItem& rBitmap =
f325b2
+                static_cast<const XFillBitmapItem&>(aMergedAttr.Get(XATTR_FILLBITMAP));
f325b2
+            const GraphicObject& rGraphicObj = rBitmap.GetGraphicObject();
f325b2
+            GraphicHelper::ExportGraphic(rGraphicObj.GetGraphic(), "");
f325b2
+        }
f325b2
+    }
f325b2
+    else if (nId == SID_SELECT_BACKGROUND)
f325b2
     {
f325b2
-        SvxOpenGraphicDialog    aDlg(SdResId(STR_SET_BACKGROUND_PICTURE));
f325b2
+        SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE));
f325b2
 
f325b2
         if( aDlg.Execute() == GRFILTER_OK )
f325b2
         {
f325b2
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
f325b2
index 405e7af..5ec628c 100644
f325b2
--- a/sd/source/ui/inc/DrawViewShell.hxx
f325b2
+++ b/sd/source/ui/inc/DrawViewShell.hxx
f325b2
@@ -33,6 +33,7 @@
f325b2
 
f325b2
 class Outliner;
f325b2
 class SdPage;
f325b2
+class SdStyleSheet;
f325b2
 class SdrExternalToolEdit;
f325b2
 class DrawDocShell;
f325b2
 class TabBar;
f325b2
@@ -509,6 +510,9 @@ private:
f325b2
     std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits;
f325b2
 };
f325b2
 
f325b2
+    /// Merge the background properties together and deposit the result in rMergeAttr
f325b2
+    void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr);
f325b2
+
f325b2
 } // end of namespace sd
f325b2
 
f325b2
 #endif
f325b2
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
f325b2
index e9c5f00..5c26c55 100644
f325b2
--- a/sd/source/ui/view/drviews2.cxx
f325b2
+++ b/sd/source/ui/view/drviews2.cxx
f325b2
@@ -1190,6 +1190,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
f325b2
         break;
f325b2
 
f325b2
         case SID_SELECT_BACKGROUND:
f325b2
+        case SID_SAVE_BACKGROUND:
f325b2
         case SID_PAGESETUP:  // BASIC ??
f325b2
         {
f325b2
             SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
f325b2
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
f325b2
index 8b6d968..fba8bc1 100644
f325b2
--- a/sd/source/ui/view/drviews7.cxx
f325b2
+++ b/sd/source/ui/view/drviews7.cxx
f325b2
@@ -83,6 +83,7 @@
f325b2
 #include "fuediglu.hxx"
f325b2
 #include "fubullet.hxx"
f325b2
 #include "fuformatpaintbrush.hxx"
f325b2
+#include "stlsheet.hxx"
f325b2
 
f325b2
 #include <config_features.h>
f325b2
 
f325b2
@@ -714,6 +715,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
f325b2
     {
f325b2
         rSet.DisableItem(SID_PRESENTATION_LAYOUT);
f325b2
         rSet.DisableItem(SID_SELECT_BACKGROUND);
f325b2
+        rSet.DisableItem(SID_SAVE_BACKGROUND);
f325b2
     }
f325b2
 
f325b2
     if (mePageKind == PK_NOTES)
f325b2
@@ -730,6 +732,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
f325b2
             rSet.DisableItem(SID_MODIFYPAGE);
f325b2
 
f325b2
         rSet.DisableItem(SID_SELECT_BACKGROUND);
f325b2
+        rSet.DisableItem(SID_SAVE_BACKGROUND);
f325b2
         rSet.DisableItem(SID_INSERTLAYER);
f325b2
         rSet.DisableItem(SID_LAYERMODE);
f325b2
         rSet.DisableItem(SID_INSERTFILE);
f325b2
@@ -750,6 +753,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
f325b2
         rSet.DisableItem(SID_INSERTFILE);
f325b2
         rSet.DisableItem(SID_PAGEMODE);
f325b2
         rSet.DisableItem(SID_SELECT_BACKGROUND);
f325b2
+        rSet.DisableItem(SID_SAVE_BACKGROUND);
f325b2
     }
f325b2
     else
f325b2
     {
f325b2
@@ -1646,8 +1650,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
f325b2
         || rSet.GetItemState(SID_DISPLAY_MASTER_OBJECTS) == SfxItemState::DEFAULT)
f325b2
     {
f325b2
         SdPage* pPage = GetActualPage();
f325b2
-        if (pPage != NULL
f325b2
-            && GetDoc() != NULL)
f325b2
+        if (pPage != NULL && GetDoc() != NULL)
f325b2
         {
f325b2
             SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
f325b2
             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
f325b2
@@ -1668,6 +1671,24 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
f325b2
     }
f325b2
 #endif
f325b2
 
f325b2
+    if (rSet.GetItemState(SID_SAVE_BACKGROUND) == SfxItemState::DEFAULT)
f325b2
+    {
f325b2
+        bool bDisableSaveBackground = true;
f325b2
+        SdPage* pPage = GetActualPage();
f325b2
+        if (pPage != NULL && GetDoc() != NULL)
f325b2
+        {
f325b2
+            SfxItemSet aMergedAttr(GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0);
f325b2
+            SdStyleSheet* pStyleSheet = pPage->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND);
f325b2
+            MergePageBackgroundFilling(pPage, pStyleSheet, meEditMode == EM_MASTERPAGE, aMergedAttr);
f325b2
+            if (drawing::FillStyle_BITMAP == static_cast<const XFillStyleItem&>(aMergedAttr.Get(XATTR_FILLSTYLE)).GetValue())
f325b2
+            {
f325b2
+                bDisableSaveBackground = false;
f325b2
+            }
f325b2
+        }
f325b2
+        if (bDisableSaveBackground)
f325b2
+            rSet.DisableItem(SID_SAVE_BACKGROUND);
f325b2
+    }
f325b2
+
f325b2
     GetModeSwitchingMenuState (rSet);
f325b2
 }
f325b2
 
f325b2
-- 
f325b2
2.4.3
f325b2