Kaydet (Commit) 905e6bd3 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Jan Holesovsky

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.

(cherry picked from commit 2118143bdd246921439ba9e835207585203dd45f)

Change-Id: I20c0e33d66f8bcd72a6388e39c4ac92e64978f45
Reviewed-on: https://gerrit.libreoffice.org/73481
Tested-by: Jenkins
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst fd95fb97
...@@ -4025,7 +4025,7 @@ SfxVoidItem CloseMasterView SID_CLOSE_MASTER_VIEW() ...@@ -4025,7 +4025,7 @@ SfxVoidItem CloseMasterView SID_CLOSE_MASTER_VIEW()
] ]
SfxVoidItem SelectBackground SID_SELECT_BACKGROUND SfxVoidItem SelectBackground SID_SELECT_BACKGROUND
() (SfxStringItem FileName SID_SELECT_BACKGROUND,SfxStringItem FilterName FN_PARAM_FILTER,SfxBoolItem AsLink FN_PARAM_1,SfxStringItem Style FN_PARAM_2)
[ [
AutoUpdate = FALSE, AutoUpdate = FALSE,
FastCall = FALSE, FastCall = FALSE,
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <svl/itempool.hxx> #include <svl/itempool.hxx>
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <vcl/prntypes.hxx> #include <vcl/prntypes.hxx>
#include <vcl/graphicfilter.hxx>
#include <stlsheet.hxx> #include <stlsheet.hxx>
#include <editeng/eeitem.hxx> #include <editeng/eeitem.hxx>
#include <editeng/frmdiritem.hxx> #include <editeng/frmdiritem.hxx>
...@@ -111,7 +112,7 @@ rtl::Reference<FuPoor> FuPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, : ...@@ -111,7 +112,7 @@ rtl::Reference<FuPoor> FuPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, :
return xFunc; return xFunc;
} }
void FuPage::DoExecute( SfxRequest& ) void FuPage::DoExecute(SfxRequest& rReq)
{ {
mpDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell); mpDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a current DrawViewShell!" ); DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a current DrawViewShell!" );
...@@ -129,10 +130,11 @@ void FuPage::DoExecute( SfxRequest& ) ...@@ -129,10 +130,11 @@ void FuPage::DoExecute( SfxRequest& )
return; return;
// if there are no arguments given, open the dialog // if there are no arguments given, open the dialog
if( !mpArgs ) const SfxPoolItem* pItem;
if (!mpArgs || mpArgs->GetItemState(SID_SELECT_BACKGROUND, true, &pItem) == SfxItemState::SET)
{ {
mpView->SdrEndTextEdit(); mpView->SdrEndTextEdit();
mpArgs = ExecuteDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr); mpArgs = ExecuteDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, rReq);
} }
// if we now have arguments, apply them to current page // if we now have arguments, apply them to current page
...@@ -189,7 +191,7 @@ void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool b ...@@ -189,7 +191,7 @@ void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool b
} }
} }
const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent) const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, SfxRequest& rReq)
{ {
if (!mpDrawViewShell) if (!mpDrawViewShell)
return nullptr; return nullptr;
...@@ -287,14 +289,39 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent) ...@@ -287,14 +289,39 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent)
} }
} }
else if (nId == SID_SELECT_BACKGROUND) else if (nId == SID_SELECT_BACKGROUND)
{
OUString aFileName;
OUString aFilterName;
Graphic aGraphic;
ErrCode nError = ERRCODE_GRFILTER_OPENERROR;
const SfxItemSet* pArgs = rReq.GetArgs();
const SfxPoolItem* pItem;
if (pArgs && pArgs->GetItemState(SID_SELECT_BACKGROUND, true, &pItem) == SfxItemState::SET)
{
aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
if (pArgs->GetItemState(FN_PARAM_FILTER, true, &pItem) == SfxItemState::SET)
aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
nError = GraphicFilter::LoadGraphic(aFileName, aFilterName, aGraphic,
&GraphicFilter::GetGraphicFilter());
}
else
{ {
SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), pParent); SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), pParent);
if( aDlg.Execute() == ERRCODE_NONE ) nError = aDlg.Execute();
if (nError != ERRCODE_NONE)
{ {
Graphic aGraphic; nError = aDlg.GetGraphic(aGraphic);
ErrCode nError = aDlg.GetGraphic(aGraphic); aFileName = aDlg.GetPath();
if( nError == ERRCODE_NONE ) aFilterName = aDlg.GetDetectedFilter();
}
}
if (nError == ERRCODE_NONE)
{ {
pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) ); pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
...@@ -309,7 +336,6 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent) ...@@ -309,7 +336,6 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent)
pTempSet->Put( XFillBmpTileItem( false )); pTempSet->Put( XFillBmpTileItem( false ));
} }
} }
}
else else
{ {
......
...@@ -42,7 +42,7 @@ class FuPage ...@@ -42,7 +42,7 @@ class FuPage
virtual void Activate() override; virtual void Activate() override;
virtual void Deactivate() override; virtual void Deactivate() override;
const SfxItemSet* ExecuteDialog(weld::Window* pParent); const SfxItemSet* ExecuteDialog(weld::Window* pParent, SfxRequest& rReq);
protected: protected:
virtual ~FuPage() override; virtual ~FuPage() override;
......
...@@ -207,6 +207,7 @@ bool MasterPageDescriptor::UpdatePreview ( ...@@ -207,6 +207,7 @@ bool MasterPageDescriptor::UpdatePreview (
{ {
pPage = mpMasterPage; pPage = mpMasterPage;
} }
//TODO: Notify LOOL of preview updates.
maLargePreview = (*mpPreviewProvider)( maLargePreview = (*mpPreviewProvider)(
rLargeSize.Width(), rLargeSize.Width(),
pPage, pPage,
......
...@@ -298,6 +298,14 @@ void SlideBackground::HandleContextChange( ...@@ -298,6 +298,14 @@ void SlideBackground::HandleContextChange(
mpInsertImage->Show(); mpInsertImage->Show();
} }
// 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 // 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()); sfx2::sidebar::Panel* pPanel = dynamic_cast<sfx2::sidebar::Panel*>(GetParent());
if(pPanel) if(pPanel)
...@@ -864,7 +872,7 @@ void SlideBackground::NotifyItemUpdate( ...@@ -864,7 +872,7 @@ void SlideBackground::NotifyItemUpdate(
if (pSizeItem) if (pSizeItem)
{ {
Size aPaperSize = pSizeItem->GetSize(); Size aPaperSize = pSizeItem->GetSize();
if(mpPaperOrientation->GetSelectedEntryPos() == 0) if (mpPaperOrientation->GetSelectedEntryPos() == 0)
Swap(aPaperSize); Swap(aPaperSize);
Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, meUnit); Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, meUnit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment