20#include <config_features.h>
22#include <fuinsert.hxx>
26#include <officecfg/Office/Common.hxx>
29#include <com/sun/star/chart2/XChartDocument.hpp>
30#include <com/sun/star/embed/EmbedVerbs.hpp>
31#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
32#include <com/sun/star/embed/Aspects.hpp>
33#include <com/sun/star/embed/XEmbeddedObject.hpp>
34#include <com/sun/star/frame/XDispatchProvider.hpp>
35#include <com/sun/star/media/XPlayer.hpp>
59#include <svx/svxids.hrc>
93 bool replaceExistingImage)
94 :
FuPoor(pViewSh, pWin, pView, pDoc, rReq),
95 mbReplaceExistingImage(replaceExistingImage)
103 xFunc->DoExecute(rReq);
112 bool bAsLink =
false;
119 pArgs->
GetItemState( SID_INSERT_GRAPHIC,
true, &pItem ) == SfxItemState::SET )
123 OUString aFilterName;
125 aFilterName = pFilterItem->GetValue();
127 if ( pArgs->
GetItemState( FN_PARAM_1,
true, &pItem ) == SfxItemState::SET )
147 if ( aMetadata.
read(aGraphic) )
153 aTransform.
rotate( aRotation );
174 if(pGrafObj && bAsLink )
177 if( officecfg::Office::Common::Misc::ShowLinkWarningDialog::get() )
180 if (aWarnDlg.run() !=
RET_OK)
201 :
FuPoor(pViewSh, pWin, pView, pDoc, rReq)
208 xFunc->DoExecute(rReq);
219 pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, OUString() );
220 pDlg->Insert( SotClipboardFormatId::LINK_SOURCE, OUString() );
221 pDlg->Insert( SotClipboardFormatId::DRAWING, OUString() );
222 pDlg->Insert( SotClipboardFormatId::SVXB, OUString() );
223 pDlg->Insert( SotClipboardFormatId::GDIMETAFILE, OUString() );
224 pDlg->Insert( SotClipboardFormatId::BITMAP, OUString() );
225 pDlg->Insert( SotClipboardFormatId::NETSCAPE_BOOKMARK, OUString() );
226 pDlg->Insert( SotClipboardFormatId::STRING, OUString() );
227 pDlg->Insert( SotClipboardFormatId::HTML, OUString() );
228 pDlg->Insert( SotClipboardFormatId::RTF, OUString() );
229 pDlg->Insert( SotClipboardFormatId::RICHTEXT, OUString() );
230 pDlg->Insert( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT, OUString() );
233 nFormatId = pDlg->GetFormat( aDataHelper );
234 if( nFormatId == SotClipboardFormatId::NONE || !aDataHelper.
GetTransferable().is() )
242 nAction,
false, nFormatId ))
252 if( ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
253 aDataHelper.
GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
254 ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) &&
255 aDataHelper.
GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
256 ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) &&
257 aDataHelper.
GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
269 :
FuPoor(pViewSh, pWin, pView, pDoc, rReq)
276 xFunc->DoExecute(rReq);
282 if (
nSlotId == SID_ATTR_TABLE ||
283 nSlotId == SID_INSERT_DIAGRAM ||
293 if (
nSlotId == SID_INSERT_DIAGRAM)
295 else if (
nSlotId == SID_ATTR_TABLE)
297 else if (
nSlotId == SID_INSERT_MATH)
301 GetEmbeddedObjectContainer().CreateEmbeddedObject(
aName.GetByteSequence(), aObjName );
305 uno::Reference<chart2::XChartDocument> xChartDoc(xObj->getComponent(), uno::UNO_QUERY);
307 xChartDoc->createDefaultChart();
309 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
321 xObj->setVisualAreaSize( nAspect, aSz );
328 aSz = xObj->getVisualAreaSize( nAspect );
330 catch ( embed::NoVisualAreaSizeException& )
335 Size aSize( aSz.Width, aSz.Height );
343 aSz.Width = aTmp.
Width();
344 aSz.Height = aTmp.
Height();
345 xObj->setVisualAreaSize( nAspect, aSz );
394 if (
nSlotId == SID_INSERT_DIAGRAM)
396 pOleObj->SetProgName(
"StarChart");
398 else if (
nSlotId == SID_ATTR_TABLE)
400 pOleObj->SetProgName(
"StarCalc" );
402 else if (
nSlotId == SID_INSERT_MATH)
404 pOleObj->SetProgName(
"StarMath" );
407 pOleObj->SetLogicRect(aRect);
409 awt::Size aVisualSize;
410 aVisualSize.Width = aTmp.
Width();
411 aVisualSize.Height = aTmp.
Height();
412 xObj->setVisualAreaSize( nAspect, aVisualSize );
415 if (
nSlotId == SID_INSERT_DIAGRAM)
433 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
434 bool bCreateNew =
false;
435 uno::Reference < embed::XEmbeddedObject > xObj;
440 OUString aIconMediaType;
441 uno::Reference< io::XInputStream > xIconMetaFile;
444 if (
nSlotId == SID_INSERT_OBJECT && pNameItem )
454 case SID_INSERT_OBJECT :
459 aServerLst.
Remove( GraphicDocShell::Factory().GetClassId() );
463 aServerLst.
Remove( DrawDocShell::Factory().GetClassId() );
468 case SID_INSERT_FLOATINGFRAME :
473 xStorage, &aServerLst ));
475 bCreateNew = pDlg->IsCreateNew();
476 xObj = pDlg->GetObject();
478 xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
479 if ( xIconMetaFile.is() )
480 nAspect = embed::Aspects::MSOLE_ICON;
494 bool bInsertNewObject =
true;
497 MapUnit aMapUnit = MapUnit::Map100thMM;
498 if ( nAspect != embed::Aspects::MSOLE_ICON )
503 aSz = xObj->getVisualAreaSize( nAspect );
505 catch( embed::NoVisualAreaSizeException& )
510 aSize =
Size( aSz.Width, aSz.Height );
519 aSz.Width = aTmp.
Width();
520 aSz.Height = aTmp.
Height();
521 xObj->setVisualAreaSize( nAspect, aSz );
542 if ( !
static_cast<SdrOle2Obj*
>(pObj)->GetObjRef().is() )
545 bInsertNewObject =
false;
547 static_cast<SdrOle2Obj*
>(pObj)->SetOutlinerParaObject(std::nullopt);
548 static_cast<SdrOle2Obj*
>(pObj)->SetObjRef(xObj);
551 static_cast<SdrOle2Obj*
>(pObj)->SetAspect(nAspect);
554 if ( nAspect == embed::Aspects::MSOLE_ICON )
556 if( xIconMetaFile.is() )
563 xObj->setVisualAreaSize( nAspect, aSz );
570 if (bInsertNewObject)
578 if ( nAspect == embed::Aspects::MSOLE_ICON )
581 MapMode aMapMode( MapUnit::Map100thMM );
582 aSize = aObjRef.
GetSize( &aMapMode );
600 if ( nAspect != embed::Aspects::MSOLE_ICON )
604 awt::Size aSz = xObj->getVisualAreaSize( nAspect );
608 if ( aNewSize != aSize )
611 pObj->SetLogicRect( aRect );
614 catch( embed::NoVisualAreaSizeException& )
620 pObj->SetLogicRect(aRect);
622 if ( nAspect != embed::Aspects::MSOLE_ICON )
626 xObj->setVisualAreaSize( nAspect, aSz );
640 catch (uno::Exception&)
654 :
FuPoor(pViewSh, pWin, pView, pDoc, rReq)
661 xFunc->DoExecute(rReq);
667#if HAVE_FEATURE_AVMEDIA
674 const bool bSizeUnknown = !pSizeItem;
684 bAPI = !
aURL.isEmpty();
688 bool bLink(pLinkItem ? pLinkItem->GetValue() :
true);
696 aPrefSize = pSizeItem->
GetSize();
708 [xDispatchProvider,
aURL, bLink](
const css::uno::Reference<css::media::XPlayer>& rPlayer){
709 css::awt::Size aSize = rPlayer->getPreferredPlayerWindowSize();
718 if (!bIsMediaURL && !bAPI)
724 InsertMediaURL(
aURL, aPrefSize, bLink);
731#if HAVE_FEATURE_AVMEDIA
732void FuInsertAVMedia::InsertMediaURL(
const OUString& rURL,
const Size& rPrefSize,
bool bLink)
744 aSize =
mpWindow->PixelToLogic(rPrefSize,
MapMode(MapUnit::Map100thMM));
749 aSize =
Size( 5000, 5000 );
static OutputDevice * GetDefaultDevice()
static void AdaptDefaultsForChart(const css::uno::Reference< css::embed::XEmbeddedObject > &xEmbObj)
const OUString & GetValue() const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static GraphicFilter & GetGraphicFilter()
static ErrCode LoadGraphic(const OUString &rPath, const OUString &rFilter, Graphic &rGraphic, GraphicFilter *pFilter=nullptr, sal_uInt16 *pDeterminedFormat=nullptr)
const OUString & GetDescription() const
const OUString & GetURL() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
SAL_DLLPRIVATE DocumentType GetDocumentType() const
static void HandleGraphicFilterError(ErrCode nFilterError, ErrCode nStreamError)
bool IsPresObj(const SdrObject *pObj)
void InsertPresObj(SdrObject *pObj, PresObjKind eKind)
inserts the given SdrObject into the presentation object list
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
void SetGraphicLink(const OUString &rFileName)
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
SdrObject * GetMarkedSdrObj() const
virtual bool IsTextEdit() const final override
SdrObjUserCall * GetUserCall() const
void SetEmptyPresObj(bool bEpt)
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage * getSdrPageFromSdrObject() const
virtual const tools::Rectangle & GetLogicRect() const
void SetGraphicToObj(const Graphic &aGraphic)
SdrPage * GetPage() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const SvGlobalName & GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
virtual void SetVisArea(const tools::Rectangle &rVisArea)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
virtual SfxObjectShell * GetObjectShell()
SfxFrame & GetFrame() const
virtual SfxObjectShell * GetObjectShell() override
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
css::uno::Sequence< sal_Int8 > GetByteSequence() const
void Remove(const SvGlobalName &)
static SvxAbstractDialogFactory * Create()
ErrCode GetGraphic(Graphic &) const
const Size & GetSize() const
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk) const
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
void InsertURLField(const OUString &rURL, const OUString &rText, const OUString &rTarget)
virtual void DoExecute(SfxRequest &rReq) override
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
FuInsertClipboard(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
FuInsertGraphic(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq, bool replaceExistingImage)
bool mbReplaceExistingImage
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq, bool replaceExistingImage)
virtual void DoExecute(SfxRequest &rReq) override
FuInsertOLE(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
virtual void DoExecute(SfxRequest &rReq) override
Base class for all functions.
VclPtr< ::sd::Window > mpWindow
Base class of the stacked shell hierarchy.
virtual bool ActivateObject(SdrOle2Obj *pObj, sal_Int32 nVerb)
virtual void VisAreaChanged(const ::tools::Rectangle &rRect)
this method is called when the visible area of the view from this viewshell is changed
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
SdrGrafObj * InsertGraphic(const Graphic &rGraphic, sal_Int8 &rAction, const Point &rPos, SdrObject *pSelectedObj, ImageMap const *pImageMap)
If an empty graphic object is provided, we fill it.
SdrObject * GetSelectedSingleObject(SdPage const *pPage)
bool InsertData(const TransferableDataHelper &rDataHelper, const Point &rPos, sal_Int8 &rDnDAction, bool bDrag, SotClipboardFormatId nFormat=SotClipboardFormatId::NONE, sal_uInt16 nPage=SDRPAGE_NOTFOUND, SdrLayerID nLayer=SDRLAYER_NOTFOUND)
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
SdrObject * GetEmptyPresentationObject(PresObjKind eKind)
void InsertMediaURL(const OUString &rMediaURL, sal_Int8 &rAction, const Point &rPos, const Size &rSize, bool const bLink)
An SdWindow contains the actual working area of ViewShell.
void SetGraphicStream(const css::uno::Reference< css::io::XInputStream > &xInGrStream, const OUString &rMediaType)
Size GetSize(MapMode const *pTargetMapMode) const
#define ERRCODE_GRFILTER_OPENERROR
OUString SdResId(TranslateId aId)
#define ERRCODE_SFX_OLEGENERAL