Kaydet (Commit) 3ecc2b1f authored tarafından Henry Castro's avatar Henry Castro

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: I31dd1b1536307ef2dbb6b3d49812b310560c919f
üst 5ae9e844
...@@ -113,17 +113,47 @@ rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window ...@@ -113,17 +113,47 @@ rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window
return xFunc; return xFunc;
} }
void FuInsertGraphic::DoExecute( SfxRequest& ) void FuInsertGraphic::DoExecute( SfxRequest& rReq )
{ {
OUString aFileName;
OUString aFilterName;
Graphic aGraphic;
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 )
{
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)); SvxOpenGraphicDialog aDlg(SdResId(STR_INSERTGRAPHIC));
if( aDlg.Execute() == GRFILTER_OK ) if( aDlg.Execute() == GRFILTER_OK )
{ {
Graphic aGraphic; nError = aDlg.GetGraphic(aGraphic);
int nError = aDlg.GetGraphic(aGraphic); bAsLink = aDlg.IsAsLink();
aFileName = aDlg.GetPath();
aFilterName = aDlg.GetCurrentFilter();
}
}
if( nError == GRFILTER_OK ) if( nError == GRFILTER_OK )
{ {
if( mpViewShell && mpViewShell->ISA(DrawViewShell)) if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr)
{ {
sal_Int8 nAction = DND_ACTION_COPY; sal_Int8 nAction = DND_ACTION_COPY;
SdrObject* pPickObj; SdrObject* pPickObj;
...@@ -144,26 +174,24 @@ void FuInsertGraphic::DoExecute( SfxRequest& ) ...@@ -144,26 +174,24 @@ void FuInsertGraphic::DoExecute( SfxRequest& )
Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() ); Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() );
aPos = aRect.Center(); aPos = aRect.Center();
aPos = mpWindow->PixelToLogic(aPos); aPos = mpWindow->PixelToLogic(aPos);
SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, NULL); SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, nullptr);
if(pGrafObj && aDlg.IsAsLink()) if(pGrafObj && bAsLink )
{ {
// really store as link only? // really store as link only?
if( SvtMiscOptions().ShowLinkWarningDialog() ) if( SvtMiscOptions().ShowLinkWarningDialog() )
{ {
ScopedVclPtrInstance< SvxLinkWarningDialog > aWarnDlg(mpWindow,aDlg.GetPath()); ScopedVclPtrInstance< SvxLinkWarningDialog > aWarnDlg(mpWindow, aFileName);
if( aWarnDlg->Execute() != RET_OK ) if( aWarnDlg->Execute() != RET_OK )
return; // don't store as link return; // don't store as link
} }
// store as link // store as link
OUString aFltName(aDlg.GetCurrentFilter());
OUString aPath(aDlg.GetPath());
OUString aReferer; OUString aReferer;
if (mpDocSh->HasName()) { if (mpDocSh->HasName()) {
aReferer = mpDocSh->GetMedium()->GetName(); aReferer = mpDocSh->GetMedium()->GetName();
} }
pGrafObj->SetGraphicLink(aPath, aReferer, aFltName); pGrafObj->SetGraphicLink(aFileName, aReferer, aFilterName);
} }
if(bSelectionReplaced && pGrafObj) if(bSelectionReplaced && pGrafObj)
...@@ -176,7 +204,6 @@ void FuInsertGraphic::DoExecute( SfxRequest& ) ...@@ -176,7 +204,6 @@ void FuInsertGraphic::DoExecute( SfxRequest& )
{ {
SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError ); SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
} }
}
} }
FuInsertClipboard::FuInsertClipboard ( FuInsertClipboard::FuInsertClipboard (
......
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