summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-09-12 20:03:11 -0400
committerAndras Timar <andras.timar@collabora.com>2018-12-06 09:08:16 +0100
commitd581c7723550187f5185ccd22b8c42d34cab64b4 (patch)
tree4a68ba9ed98257dd3559f94c4873613bbb031eba /sd/source
parentbfacba6b23ab90fde3303409976809c0e1624a65 (diff)
sd: support inserting background image from file via .uno:SelectBackground
The UNO command always prompted the user via file open dialog. This change allows for passing the filename as an argument to allow for inserting slide background programatically. Also, hide the Insert Image button in the sidebar since we can't use that (just yet), because it invokes .uno:SelectBackground directly. We would need to send LOOL a notification to invoke this on its own end to first prompt the user for a file. Change-Id: I20c0e33d66f8bcd72a6388e39c4ac92e64978f45 (cherry picked from commit 2118143bdd246921439ba9e835207585203dd45f)
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/ui/func/fupage.cxx68
-rw-r--r--sd/source/ui/inc/fupage.hxx2
-rw-r--r--sd/source/ui/sidebar/MasterPageDescriptor.cxx1
-rw-r--r--sd/source/ui/sidebar/SlideBackground.cxx10
-rw-r--r--sd/source/ui/slidesorter/controller/SlsClipboard.cxx10
5 files changed, 64 insertions, 27 deletions
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 8f05c7b90727..155d8a3e5d86 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -125,7 +125,7 @@ rtl::Reference<FuPoor> FuPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, :
return xFunc;
}
-void FuPage::DoExecute( SfxRequest& )
+void FuPage::DoExecute(SfxRequest& rReq)
{
mpDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a current DrawViewShell!" );
@@ -141,11 +141,12 @@ void FuPage::DoExecute( SfxRequest& )
if( mpPage )
{
- // if there are no arguments given, open the dialog
- if( !mpArgs )
+ // If there are no arguments given, open the dialog, or if we have SelectBackground params, process first.
+ const SfxPoolItem* pItem;
+ if (!mpArgs || mpArgs->GetItemState(SID_SELECT_BACKGROUND, true, &pItem) == SfxItemState::SET)
{
mpView->SdrEndTextEdit();
- mpArgs = ExecuteDialog(mpWindow);
+ mpArgs = ExecuteDialog(mpWindow, rReq);
}
// if we now have arguments, apply them to current page
@@ -203,7 +204,7 @@ void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool b
}
}
-const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
+const SfxItemSet* FuPage::ExecuteDialog(vcl::Window* pParent, SfxRequest& rReq)
{
if (!mpDrawViewShell)
return nullptr;
@@ -302,27 +303,56 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
}
else if (nId == SID_SELECT_BACKGROUND)
{
- SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), pParent);
+ OUString aFileName;
+ OUString aFilterName;
+ Graphic aGraphic;
+ ErrCode nError = ERRCODE_GRFILTER_OPENERROR;
+ bool bAsLink = false;
- if( aDlg.Execute() == ERRCODE_NONE )
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if (pArgs && pArgs->GetItemState(SID_SELECT_BACKGROUND, true, &pItem) == SfxItemState::SET)
{
- Graphic aGraphic;
- ErrCode nError = aDlg.GetGraphic(aGraphic);
- if( nError == ERRCODE_NONE )
- {
- pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
+ aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
- pTempSet->Put( XFillStyleItem( drawing::FillStyle_BITMAP ) );
+ if (pArgs->GetItemState(FN_PARAM_FILTER, true, &pItem) == SfxItemState::SET)
+ aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
- // MigrateItemSet makes sure the XFillBitmapItem will have a unique name
- SfxItemSet aMigrateSet( mpDoc->GetPool(), svl::Items<XATTR_FILLBITMAP, XATTR_FILLBITMAP>{} );
- aMigrateSet.Put(XFillBitmapItem("background", aGraphic));
- SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc );
+ if (pArgs->GetItemState(FN_PARAM_1, true, &pItem) == SfxItemState::SET)
+ bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- pTempSet->Put( XFillBmpStretchItem( true ));
- pTempSet->Put( XFillBmpTileItem( false ));
+ nError = GraphicFilter::LoadGraphic(aFileName, aFilterName, aGraphic,
+ &GraphicFilter::GetGraphicFilter());
+ }
+ else
+ {
+ SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), pParent);
+
+ nError = aDlg.Execute();
+ if (nError != ERRCODE_NONE)
+ {
+ nError = aDlg.GetGraphic(aGraphic);
+ bAsLink = aDlg.IsAsLink();
+ aFileName = aDlg.GetPath();
+ aFilterName = aDlg.GetDetectedFilter();
}
}
+
+ if (nError == ERRCODE_NONE)
+ {
+ pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
+
+ pTempSet->Put( XFillStyleItem( drawing::FillStyle_BITMAP ) );
+
+ // MigrateItemSet makes sure the XFillBitmapItem will have a unique name
+ SfxItemSet aMigrateSet( mpDoc->GetPool(), svl::Items<XATTR_FILLBITMAP, XATTR_FILLBITMAP>{} );
+ aMigrateSet.Put(XFillBitmapItem("background", aGraphic));
+ SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc );
+
+ pTempSet->Put( XFillBmpStretchItem( true ));
+ pTempSet->Put( XFillBmpTileItem( false ));
+ }
}
else
diff --git a/sd/source/ui/inc/fupage.hxx b/sd/source/ui/inc/fupage.hxx
index 03721ea41e2e..3a6526b7314a 100644
--- a/sd/source/ui/inc/fupage.hxx
+++ b/sd/source/ui/inc/fupage.hxx
@@ -41,7 +41,7 @@ class FuPage
virtual void Activate() override;
virtual void Deactivate() override;
- const SfxItemSet* ExecuteDialog( vcl::Window* pParent );
+ const SfxItemSet* ExecuteDialog(vcl::Window* pParent, SfxRequest& rReq);
protected:
virtual ~FuPage() override;
diff --git a/sd/source/ui/sidebar/MasterPageDescriptor.cxx b/sd/source/ui/sidebar/MasterPageDescriptor.cxx
index 26e44eff0f7e..e84d0d2b58c9 100644
--- a/sd/source/ui/sidebar/MasterPageDescriptor.cxx
+++ b/sd/source/ui/sidebar/MasterPageDescriptor.cxx
@@ -229,6 +229,7 @@ bool MasterPageDescriptor::UpdatePreview (
{
pPage = mpMasterPage;
}
+ //TODO: Notify LOOL of preview updates.
maLargePreview = (*mpPreviewProvider)(
rLargeSize.Width(),
pPage,
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx
index c4f271487762..ead02f86eb4e 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -69,6 +69,7 @@
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
#include <svl/itemset.hxx>
+#include <comphelper/lok.hxx>
using namespace ::com::sun::star;
@@ -292,6 +293,15 @@ void SlideBackground::HandleContextChange(
mpBackgroundLabel->Show();
mpInsertImage->Hide();
}
+
+ // The Insert Image button in the sidebar issues .uno:SelectBackground,
+ // which when invoked without arguments will open the file-open-dialog
+ // to prompt the user to select a file. This is useless in LOOL.
+ // Hide for now so the user will only be able to use the menu to insert
+ // background image, which prompts the user for file selection in the browser.
+ if (comphelper::LibreOfficeKit::isActive())
+ mpInsertImage->Hide();
+
// Need to do a relayouting, otherwise the panel size is not updated after show / hide controls
sfx2::sidebar::Panel* pPanel = dynamic_cast<sfx2::sidebar::Panel*>(GetParent());
if(pPanel)
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index b65926d52844..4e5ec9a259c6 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -608,13 +608,9 @@ IMPL_LINK(Clipboard, ProcessDragFinished, void*, pUserData, void)
// Remove the pages that have been moved to another place (possibly
// in the same document.)
rSelector.DeselectAllPages();
- PageList::iterator aDraggedPage;
- for (aDraggedPage=maPagesToRemove.begin();
- aDraggedPage!=maPagesToRemove.end();
- ++aDraggedPage)
- {
- rSelector.SelectPage(*aDraggedPage);
- }
+ for (const auto& aDraggedPage : maPagesToRemove)
+ rSelector.SelectPage(aDraggedPage);
+
mrController.GetSelectionManager()->DeleteSelectedPages();
}
mxUndoContext.reset();