20#include <config_features.h>
25#include <osl/file.hxx>
31#include <sfx2/sfxsids.hrc>
60#include <com/sun/star/embed/XEmbedPersist.hpp>
61#include <com/sun/star/embed/Aspects.hpp>
62#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
63#include <com/sun/star/embed/XEmbeddedObject.hpp>
64#include <com/sun/star/media/XPlayer.hpp>
96 if( !pPickObj && pPV )
102 const bool bIsGraphic(
dynamic_cast< const SdrGrafObj*
>(pPickObj) !=
nullptr);
119 pNewGrafObj->SetGraphic(rGraphic);
127 pNewGrafObj->SetEmptyPresObj(
true);
130 if ( pNewGrafObj->IsEmptyPresObj() )
133 pNewGrafObj->AdjustToMaxRect( aRect );
134 pNewGrafObj->SetOutlinerParaObject(std::nullopt);
135 pNewGrafObj->SetEmptyPresObj(
false);
146 pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(
new SvxIMapInfo(*pImageMap)));
157 && !
dynamic_cast< const SdrOle2Obj*
>(pPickObj))
164 AddUndo(
GetModel().GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
198 MapMode( MapUnit::Map100thMM ) );
206 if (nPreferredDPI > 0)
210 if (nWidth > 0 && nHeight > 0)
211 aSize =
Size(nWidth, nHeight);
216 if (nPreferredDPI > 0)
231 bool bIsPresTarget =
false;
238 nOptions |= SdrInsertFlags::DONTMARK;
252 pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(
new SvxIMapInfo(*pImageMap)));
261 pNewGrafObj->NbcResize(aObjRect.
TopLeft(), aScaleWidth, aScaleHeight);
264 pNewGrafObj->NbcMove(
Size(aVec.
X(), aVec.
Y()));
270 pNewGrafObj->NbcSetLayer(pPickObj->
GetLayer());
290 pNewGrafObj =
nullptr;
292 pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(
new SvxIMapInfo(*pImageMap)));
298 return pNewGrafObj.get();
312 uno::Reference<frame::XModel>
const xModel(
314#if HAVE_FEATURE_AVMEDIA
315 bool const bRet = ::avmedia::EmbedMedia(
xModel, rMediaURL, realURL);
316 if (!bRet) {
return; }
344 pNewMediaObj->setURL(rMediaURL,
"");
364 bool bIsPres =
false;
368 bIsPres = pPage && pPage->
IsPresObj(pPickObj);
380 pNewMediaObj =
nullptr;
385 if (sh !=
nullptr && sh->
HasName()) {
391 pNewMediaObj->setURL(rMediaURL, referer);
395 pNewMediaObj->AdjustToMaxRect( aRect );
397 pNewMediaObj->SetUserCall( pUserCall );
404 return pNewMediaObj.get();
412 DBG_ASSERT( mpViewSh,
"sd::View::DropInsertFileHdl(), I need a view shell to work!" );
419 ::std::vector< OUString >::const_iterator aIter( maDropFileVector.begin() );
421 while( (aIter != maDropFileVector.end()) && !nError )
423 OUString aCurrentDropFile( *aIter );
425 bool bHandled =
false;
427 if(
aURL.GetProtocol() == INetProtocol::NotValid )
430 osl::FileBase::getFileURLFromSystemPath( aCurrentDropFile, aURLStr );
439#if HAVE_FEATURE_AVMEDIA
446 sal_Int8 nTempAction = ( aIter == maDropFileVector.begin() ) ? mnAction : 0;
449 if(pGrafObj && bLink)
455 if( aIter == maDropFileVector.begin() )
456 mnAction = nTempAction;
462 std::shared_ptr<const SfxFilter> pFoundFilter;
463 SfxMedium aSfxMedium( aCurrentDropFile, StreamMode::READ | StreamMode::SHARE_DENYNONE );
466 if( pFoundFilter && !nErr )
468 ::std::vector< OUString > aFilterVector;
469 OUString aFilterName = pFoundFilter->GetFilterName();
470 OUString aLowerAsciiFileName = aCurrentDropFile.toAsciiLowerCase();
474 if( ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFoundFilter->GetMimeType() ) != aFilterVector.end() ) ||
475 aFilterName.indexOf(
"Text" ) != -1 ||
476 aFilterName.indexOf(
"Rich" ) != -1 ||
477 aFilterName.indexOf(
"RTF" ) != -1 ||
478 aFilterName.indexOf(
"HTML" ) != -1 ||
479 aLowerAsciiFileName.indexOf(
".sdd") != -1 ||
480 aLowerAsciiFileName.indexOf(
".sda") != -1 ||
481 aLowerAsciiFileName.indexOf(
".sxd") != -1 ||
482 aLowerAsciiFileName.indexOf(
".sxi") != -1 ||
483 aLowerAsciiFileName.indexOf(
".std") != -1 ||
484 aLowerAsciiFileName.indexOf(
".sti") != -1 )
487 SfxRequest aReq(SID_INSERTFILE, ::SfxCallMode::SLOT, mrDoc.GetItemPool());
488 SfxStringItem aItem1( ID_VAL_DUMMY0, aCurrentDropFile ), aItem2( ID_VAL_DUMMY1, pFoundFilter->GetFilterName() );
499#if HAVE_FEATURE_AVMEDIA
506 [
this, aCurrentDropFile](
const css::uno::Reference<css::media::XPlayer>& rPlayer){
509 css::awt::Size aSize = rPlayer->getPreferredPlayerWindowSize();
510 Size aPrefSize(aSize.Width, aSize.Height);
522 aPrefSize =
Size( 5000, 5000 );
524 InsertMediaURL(aCurrentDropFile, mnAction, maDropPos, aPrefSize,
true);
526 mxDropMediaSizeListener.clear();
536 static_cast< DrawViewShell*
>( mpViewSh )->InsertURLButton( aCurrentDropFile, aCurrentDropFile, OUString(), &maDropPos );
546 "URL", aCurrentDropFile) };
548 uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().
549 InsertEmbeddedObject( aMedium,
aName );
551 uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
555 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
557 xPersist->storeOwn();
562 aSz = xObj->getVisualAreaSize( nAspect );
564 catch( embed::NoVisualAreaSizeException& )
569 Size aSize( aSz.Width, aSz.Height );
581 getSdrModelFromSdrView(),
587 if (mpViewSh !=
nullptr)
589 OSL_ASSERT (mpViewSh->GetViewShell()!=
nullptr);
593 nOptions |= SdrInsertFlags::DONTMARK;
596 if (InsertObjectAtView( pOleObj.get(), *GetSdrPageView(), nOptions ))
597 pOleObj->SetLogicRect( aRect );
600 xObj->setVisualAreaSize( nAspect,aSz );
603 catch( uno::Exception& )
624 vcl::Window* pWin = mpViewSh ? mpViewSh->GetActiveWindow() :
nullptr;
626 VclMessageType::Info, VclButtonsType::Ok,
627 SdResId(STR_ACTION_NOTPOSSIBLE)));
SfxApplication * SfxGetpApp()
static OutputDevice * GetDefaultDevice()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
GfxLinkType GetType() const
static GraphicFilter & GetGraphicFilter()
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
GfxLink GetGfxLink() const
MapMode GetPrefMapMode() const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
MapUnit GetMapUnit() const
SAL_DLLPRIVATE sal_Int32 GetDPIX() 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
constexpr tools::Long Y() const
constexpr tools::Long X() const
sal_Int32 getImagePreferredDPI() const override
bool IsPresObj(const SdrObject *pObj)
void InsertPresObj(SdrObject *pObj, PresObjKind eKind)
inserts the given SdrObject into the presentation object list
SfxStyleSheet * GetStyleSheet() const
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
bool IsUndoEnabled() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
void SetGraphicLink(const OUString &rFileName)
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
SdrUndoFactory & GetSdrUndoFactory() const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
SdrObjUserCall * GetUserCall() const
sal_uInt32 GetOrdNum() const
bool IsEmptyPresObj() const
static rtl::Reference< T > Clone(T const &rObj, SdrModel &rTargetModel)
virtual const tools::Rectangle & GetCurrentBoundRect() const
SdrModel & getSdrModelFromSdrObject() const
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrPage * getSdrPageFromSdrObject() const
virtual SdrLayerID GetLayer() const
virtual const tools::Rectangle & GetLogicRect() const
tools::Rectangle GetPageRect() const
SdrPage * GetPage() const
bool IsMasterPage() const
sal_Int32 GetUpperBorder() const
sal_Int32 GetRightBorder() const
sal_Int32 GetLeftBorder() const
sal_Int32 GetLowerBorder() const
SdrModel & getSdrModelFromSdrView() const
friend friend class SdrGrafObj
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
sal_uInt16 getHitTolLog() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoNewObject(SdrObject &rObject, bool bOrdNumDirect=false)
virtual std::unique_ptr< SdrUndoAction > CreateUndoDeleteObject(SdrObject &rObject, bool bOrdNumDirect=false)
SfxFilterMatcher & GetFilterMatcher()
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
bool IsObjectInPlaceActive() const
SfxViewShell * GetViewShell() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const OUString & GetName() const
SfxMedium * GetMedium() const
void AppendItem(const SfxPoolItem &)
SfxItemPool & GetPool() const
SfxViewShell * GetViewShell() const
SfxInPlaceClient * GetIPClient() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
static void GetSupportedFilterVector(::std::vector< OUString > &rFilterVector)
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
DrawDocShell * GetDocSh() const
SdrMediaObj * InsertMediaObj(const OUString &rURL, sal_Int8 &rAction, const Point &rPos, const Size &rSize)
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.
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
SdrObject * GetEmptyPresentationObject(PresObjKind eKind)
virtual SfxStyleSheet * GetStyleSheet() const
void InsertMediaURL(const OUString &rMediaURL, sal_Int8 &rAction, const Point &rPos, const Size &rSize, bool const bLink)
SdDrawDocument & GetDoc() const
An SdWindow contains the actual working area of ViewShell.
::OutputDevice const * GetOutDev() const
Point PixelToLogic(const Point &rDevicePt) const
weld::Window * GetFrameWeld() const
#define DBG_ASSERT(sCon, aError)
#define ERRCODE_IO_GENERAL
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
constexpr int PDF_INSERT_MAGIC_SCALE_FACTOR
OUString SdResId(TranslateId aId)
SVT_DLLPUBLIC const ErrMsgCode RID_SO_ERRCTX[]
Reference< XModel > xModel