summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2015-12-16 17:13:06 -0400
committerHenry Castro <hcastro@collabora.com>2015-12-17 14:08:39 +0000
commit348d7f6170d6ab83c8086f097aed7bdb1b64930a (patch)
treefda36948c65cf895d4fd840efed6d95bc5a9e8a2 /sd
parenteaa7f30102df4df01171e5daf83cdddae1bb0cda (diff)
sd: enable insert graphic when UNO command has URL file argument
When LOOL requires to insert a graphic, it uses UNO command ".uno:InsertGraphic", and the corresponding URL file image argument. However Impress, ignores URL file image argument, and by default pop up a dialog, so no image is inserted in LOOL. Change-Id: If1939247f5df0bb4e7daf8816a2306e34419ae2f Reviewed-on: https://gerrit.libreoffice.org/20747 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/func/fuinsert.cxx127
1 files changed, 77 insertions, 50 deletions
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 2b510f140d83..be90f49dd3cb 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -109,69 +109,96 @@ rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window
return xFunc;
}
-void FuInsertGraphic::DoExecute( SfxRequest& )
+void FuInsertGraphic::DoExecute( SfxRequest& rReq )
{
- SvxOpenGraphicDialog aDlg(SdResId(STR_INSERTGRAPHIC));
+ OUString aFileName;
+ OUString aFilterName;
+ Graphic aGraphic;
- if( aDlg.Execute() == GRFILTER_OK )
+ bool bAsLink = false;
+ int nError = GRFILTER_OPENERROR;
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if ( pArgs &&
+ pArgs->GetItemState( SID_INSERT_GRAPHIC, true, &pItem ) == SfxItemState::SET )
{
- Graphic aGraphic;
- int nError = aDlg.GetGraphic(aGraphic);
- if( nError == GRFILTER_OK )
+ aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+
+ if ( pArgs->GetItemState( FN_PARAM_FILTER, true, &pItem ) == SfxItemState::SET )
+ aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+
+ if ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
+ bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+
+ nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, &GraphicFilter::GetGraphicFilter() );
+ }
+ else
+ {
+ SvxOpenGraphicDialog aDlg(SdResId(STR_INSERTGRAPHIC));
+
+ if( aDlg.Execute() == GRFILTER_OK )
{
- if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr)
- {
- sal_Int8 nAction = DND_ACTION_COPY;
- SdrObject* pPickObj;
- bool bSelectionReplaced(false);
+ nError = aDlg.GetGraphic(aGraphic);
+ bAsLink = aDlg.IsAsLink();
+ aFileName = aDlg.GetPath();
+ aFilterName = aDlg.GetCurrentFilter();
+ }
+ }
- if( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) || ( pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) )
- {
- nAction = DND_ACTION_LINK;
- }
- else if(1 == mpView->GetMarkedObjectCount())
- {
- pPickObj = mpView->GetMarkedObjectByIndex(0);
- nAction = DND_ACTION_MOVE;
- bSelectionReplaced = true;
- }
+ if( nError == GRFILTER_OK )
+ {
+ if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr)
+ {
+ sal_Int8 nAction = DND_ACTION_COPY;
+ SdrObject* pPickObj;
+ bool bSelectionReplaced(false);
- Point aPos;
- Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() );
- aPos = aRect.Center();
- aPos = mpWindow->PixelToLogic(aPos);
- SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, nullptr);
+ if( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) || ( pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) )
+ {
+ nAction = DND_ACTION_LINK;
+ }
+ else if(1 == mpView->GetMarkedObjectCount())
+ {
+ pPickObj = mpView->GetMarkedObjectByIndex(0);
+ nAction = DND_ACTION_MOVE;
+ bSelectionReplaced = true;
+ }
- if(pGrafObj && aDlg.IsAsLink())
- {
- // really store as link only?
- if( SvtMiscOptions().ShowLinkWarningDialog() )
- {
- ScopedVclPtrInstance< SvxLinkWarningDialog > aWarnDlg(mpWindow,aDlg.GetPath());
- if( aWarnDlg->Execute() != RET_OK )
- return; // don't store as link
- }
+ Point aPos;
+ Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() );
+ aPos = aRect.Center();
+ aPos = mpWindow->PixelToLogic(aPos);
+ SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, nullptr);
- // store as link
- OUString aFltName(aDlg.GetCurrentFilter());
- OUString aPath(aDlg.GetPath());
- OUString aReferer;
- if (mpDocSh->HasName()) {
- aReferer = mpDocSh->GetMedium()->GetName();
- }
- pGrafObj->SetGraphicLink(aPath, aReferer, aFltName);
+ if(pGrafObj && bAsLink )
+ {
+ // really store as link only?
+ if( SvtMiscOptions().ShowLinkWarningDialog() )
+ {
+ ScopedVclPtrInstance< SvxLinkWarningDialog > aWarnDlg(mpWindow, aFileName);
+ if( aWarnDlg->Execute() != RET_OK )
+ return; // don't store as link
}
- if(bSelectionReplaced && pGrafObj)
- {
- mpView->MarkObj(pGrafObj, mpView->GetSdrPageView());
+ // store as link
+ OUString aReferer;
+ if (mpDocSh->HasName()) {
+ aReferer = mpDocSh->GetMedium()->GetName();
}
+ pGrafObj->SetGraphicLink(aFileName, aReferer, aFilterName);
+ }
+
+ if(bSelectionReplaced && pGrafObj)
+ {
+ mpView->MarkObj(pGrafObj, mpView->GetSdrPageView());
}
}
- else
- {
- SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
- }
+ }
+ else
+ {
+ SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
}
}