From 1ca19a345a948e37f2457326b6d5f7e92d5812a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> Date: Wed, 30 Sep 2015 13:30:36 +0100 Subject: [PATCH] implement save slide background for impress to go along with the existing "set background", same sort of thing as the competitor's effort (cherry picked from commit ed25a000ab67324075e68d9a7f3ca657b4e6a573) Change-Id: I2a1106771ead2cd926f3d631850447499340697c --- sd/inc/app.hrc | 2 +- sd/inc/sdcommands.h | 1 + sd/sdi/_drvwsh.sdi | 5 +++ sd/sdi/sdraw.sdi | 24 +++++++++++ sd/source/ui/app/menuids_tmpl.src | 11 ++++- sd/source/ui/func/fupage.cxx | 85 +++++++++++++++++++++++--------------- sd/source/ui/inc/DrawViewShell.hxx | 4 ++ sd/source/ui/view/drviews2.cxx | 1 + sd/source/ui/view/drviews7.cxx | 25 ++++++++++- 9 files changed, 121 insertions(+), 37 deletions(-) diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc index 2130577..8effdac 100644 --- a/sd/inc/app.hrc +++ b/sd/inc/app.hrc @@ -423,7 +423,7 @@ #define SID_SELECT_BACKGROUND (SID_SD_START+422) #define SID_OBJECT_CROP (SID_SD_START+423) - +#define SID_SAVE_BACKGROUND (SID_SD_START+424) // Slots for the tool pane popup #define SID_TP_APPLY_TO_ALL_SLIDES (SID_SD_START+425) #define SID_TP_APPLY_TO_SELECTED_SLIDES (SID_SD_START+426) diff --git a/sd/inc/sdcommands.h b/sd/inc/sdcommands.h index 276bf6d..d49fed8 100644 --- a/sd/inc/sdcommands.h +++ b/sd/inc/sdcommands.h @@ -107,6 +107,7 @@ #define CMD_SID_DELETE_MASTER_PAGE ".uno:DeleteMasterPage" #define CMD_SID_RENAME_MASTER_PAGE ".uno:RenameMasterPage" #define CMD_SID_SELECT_BACKGROUND ".uno:SelectBackground" +#define CMD_SID_SAVE_BACKGROUND ".uno:SaveBackground" #define CMD_SID_DISPLAY_MASTER_BACKGROUND ".uno:DisplayMasterBackground" #define CMD_SID_DISPLAY_MASTER_OBJECTS ".uno:DisplayMasterObjects" #define CMD_SID_TABLE_DISTRIBUTE_COLUMNS ".uno:DistributeColumns" diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index 38953ca..f7e07f2 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -2662,6 +2662,11 @@ interface DrawView ExecMethod = FuTemporary ; StateMethod = GetMenuState ; ] + SID_SAVE_BACKGROUND + [ + ExecMethod = FuTemporary ; + StateMethod = GetMenuState ; + ] SID_DISPLAY_MASTER_BACKGROUND [ ExecMethod = FuTemporary ; diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi index a397d02..ad6174e 100644 --- a/sd/sdi/sdraw.sdi +++ b/sd/sdi/sdraw.sdi @@ -6518,6 +6518,30 @@ SfxVoidItem SelectBackground SID_SELECT_BACKGROUND GroupId = GID_OPTIONS; ] +SfxVoidItem SaveBackground SID_SAVE_BACKGROUND +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_OPTIONS; +] + SfxBoolItem DisplayMasterBackground SID_DISPLAY_MASTER_BACKGROUND [ /* flags: */ diff --git a/sd/source/ui/app/menuids_tmpl.src b/sd/source/ui/app/menuids_tmpl.src index 7944b1c..a61a1d0 100644 --- a/sd/source/ui/app/menuids_tmpl.src +++ b/sd/source/ui/app/menuids_tmpl.src @@ -114,6 +114,13 @@ HelpId = CMD_SID_SELECT_BACKGROUND ; \ Text [ en-US ] = "Set Background Image for Slide ..." ; \ }; +#define MN_SAVE_BACKGROUND \ + MenuItem\ + {\ + Identifier = SID_SAVE_BACKGROUND ; \ + HelpId = CMD_SID_SAVE_BACKGROUND ; \ + Text [ en-US ] = "Save Background Image..." ; \ + }; #define MN_DISPLAY_MASTER_BACKGROUND \ MenuItem\ {\ @@ -144,6 +151,7 @@ MN_FORMAT_PAGE\ MN_PRESENTATION_LAYOUT\ MN_RENAME_PAGE\ + MN_SAVE_BACKGROUND\ };\ };\ Text [ en-US ] = "Pag~e" ; \ @@ -172,7 +180,8 @@ MN_DISPLAY_MASTER_OBJECTS\ };\ };\ - }; + }; \ + MN_SAVE_BACKGROUND // Layer #define MN_RENAME_LAYER \ diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index 8253ee5..2277c19 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -36,6 +36,7 @@ #include <svx/svdundo.hxx> #include <editeng/eeitem.hxx> #include <editeng/frmdiritem.hxx> +#include <svx/graphichelper.hxx> #include <svx/xbtmpit.hxx> #include <svx/xsetit.hxx> #include <editeng/ulspitem.hxx> @@ -164,6 +165,41 @@ void FuPage::Deactivate() { } +void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr) +{ + if (bMasterPage) + { + if (pStyleSheet) + mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet()); + } + else + { + // Only this page, get attributes for background fill + const SfxItemSet& rBackgroundAttributes = pPage->getSdrPageProperties().GetItemSet(); + + if(drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue()) + { + // page attributes are used, take them + rMergedAttr.Put(rBackgroundAttributes); + } + else + { + if(pStyleSheet + && drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue()) + { + // if the page has no fill style, use the settings from the + // background stylesheet (if used) + mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet()); + } + else + { + // no fill style from page, start with no fill style + rMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE)); + } + } + } +} + const SfxItemSet* FuPage::ExecuteDialog( ::vcl::Window* pParent ) { if (!mpDrawViewShell) @@ -247,44 +283,27 @@ const SfxItemSet* FuPage::ExecuteDialog( ::vcl::Window* pParent ) // merge page background filling to the dialogs input set if( mbDisplayBackgroundTabPage ) { - if( mbMasterPage ) - { - if(pStyleSheet) - mergeItemSetsImpl( aMergedAttr, pStyleSheet->GetItemSet() ); - } - else - { - // Only this page, get attributes for background fill - const SfxItemSet& rBackgroundAttributes = mpPage->getSdrPageProperties().GetItemSet(); - - if(drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue()) - { - // page attributes are used, take them - aMergedAttr.Put(rBackgroundAttributes); - } - else - { - if(pStyleSheet - && drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue()) - { - // if the page has no fill style, use the settings from the - // background stylesheet (if used) - mergeItemSetsImpl(aMergedAttr, pStyleSheet->GetItemSet()); - } - else - { - // no fill style from page, start with no fill style - aMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE)); - } - } - } + MergePageBackgroundFilling(mpPage, pStyleSheet, mbMasterPage, aMergedAttr); } boost::scoped_ptr< SfxItemSet > pTempSet; - if( GetSlotID() == SID_SELECT_BACKGROUND ) + const sal_uInt16 nId = GetSlotID(); + if (nId == SID_SAVE_BACKGROUND) + { + const XFillStyleItem& rStyleItem = + static_cast<const XFillStyleItem&>(aMergedAttr.Get(XATTR_FILLSTYLE)); + if (drawing::FillStyle_BITMAP == (drawing::FillStyle)rStyleItem.GetValue()) + { + const XFillBitmapItem& rBitmap = + static_cast<const XFillBitmapItem&>(aMergedAttr.Get(XATTR_FILLBITMAP)); + const GraphicObject& rGraphicObj = rBitmap.GetGraphicObject(); + GraphicHelper::ExportGraphic(rGraphicObj.GetGraphic(), ""); + } + } + else if (nId == SID_SELECT_BACKGROUND) { - SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE)); + SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE)); if( aDlg.Execute() == GRFILTER_OK ) { diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 8a92f42..6a56a4f 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -33,6 +33,7 @@ class Outliner; class SdPage; +class SdStyleSheet; class SdrExternalToolEdit; class DrawDocShell; class TabBar; @@ -512,6 +513,9 @@ private: std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits; }; + /// Merge the background properties together and deposit the result in rMergeAttr + void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr); + } // end of namespace sd #endif diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 59a42d8..4b8cea1 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1191,6 +1191,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) break; case SID_SELECT_BACKGROUND: + case SID_SAVE_BACKGROUND: case SID_PAGESETUP: // BASIC ?? { SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 37e8a31..48e6607 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -83,6 +83,7 @@ #include "fuediglu.hxx" #include "fubullet.hxx" #include "fuformatpaintbrush.hxx" +#include "stlsheet.hxx" #include <config_features.h> @@ -713,6 +714,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) { rSet.DisableItem(SID_PRESENTATION_LAYOUT); rSet.DisableItem(SID_SELECT_BACKGROUND); + rSet.DisableItem(SID_SAVE_BACKGROUND); } if (mePageKind == PK_NOTES) @@ -729,6 +731,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) rSet.DisableItem(SID_MODIFYPAGE); rSet.DisableItem(SID_SELECT_BACKGROUND); + rSet.DisableItem(SID_SAVE_BACKGROUND); rSet.DisableItem(SID_INSERTLAYER); rSet.DisableItem(SID_LAYERMODE); rSet.DisableItem(SID_INSERTFILE); @@ -749,6 +752,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) rSet.DisableItem(SID_INSERTFILE); rSet.DisableItem(SID_PAGEMODE); rSet.DisableItem(SID_SELECT_BACKGROUND); + rSet.DisableItem(SID_SAVE_BACKGROUND); } else { @@ -1645,8 +1649,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) || rSet.GetItemState(SID_DISPLAY_MASTER_OBJECTS) == SfxItemState::DEFAULT) { SdPage* pPage = GetActualPage(); - if (pPage != NULL - && GetDoc() != NULL) + if (pPage != NULL && GetDoc() != NULL) { SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); @@ -1667,6 +1670,24 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) } #endif + if (rSet.GetItemState(SID_SAVE_BACKGROUND) == SfxItemState::DEFAULT) + { + bool bDisableSaveBackground = true; + SdPage* pPage = GetActualPage(); + if (pPage != NULL && GetDoc() != NULL) + { + 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); + if (drawing::FillStyle_BITMAP == static_cast<const XFillStyleItem&>(aMergedAttr.Get(XATTR_FILLSTYLE)).GetValue()) + { + bDisableSaveBackground = false; + } + } + if (bDisableSaveBackground) + rSet.DisableItem(SID_SAVE_BACKGROUND); + } + GetModeSwitchingMenuState (rSet); } -- 2.4.3