20#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
21#include <com/sun/star/embed/XEmbeddedObject.hpp>
34#include <com/sun/star/embed/Aspects.hpp>
35#include <osl/diagnose.h>
37#include <document.hxx>
38#include <viewfunc.hxx>
40#include <drawview.hxx>
59 OSL_ENSURE(pPage,
"pPage ???");
61 if (aPgSize.
Width() < 0)
75 bool bGroup, std::u16string_view rSrcShellID, std::u16string_view rDestShellID )
77 bool bSameDocClipboard = rSrcShellID == rDestShellID;
80 Point aPos( rLogicPos );
94 SdrView* pDragEditView =
nullptr;
105 if (aPos.
X() > 0) aPos.
setX( 0 );
109 if (aPos.
X() < 0) aPos.
setX( 0 );
111 if (aPos.
Y() < 0) aPos.
setY( 0 );
118 bool bSameDoc = ( pDragEditView && &pDragEditView->
GetModel() == &pScDrawView->
GetModel() );
133 if ( nDiffX != 0 || nDiffY != 0 )
140 SdrPage* pDestPage = rDrawModel.
GetPage(
static_cast< sal_uInt16
>( nTab ) );
141 OSL_ENSURE(pDestPage,
"who is this, Page?");
143 ::std::vector< OUString > aExcludedChartNames;
152 for (
size_t nm=0; nm<nMarkCnt; ++nm) {
159 if (pNewObj!=
nullptr)
163 pNewObj->SetName(
static_cast<ScDrawLayer*
>(&rDrawModel)->GetNewGraphicName());
165 if (nDiffX!=0 || nDiffY!=0)
166 pNewObj->NbcMove(
Size(nDiffX,nDiffY));
169 pScDrawView->
AddUndo(std::make_unique<SdrUndoInsertObj>( *pNewObj ));
183 if ( pDestPage && pModelObj && pDrawTrans )
187 rProtectedChartRangesVector, aExcludedChartNames, bSameDoc );
206 nOptions |= SdrInsertFlags::DONTMARK;
208 ::std::vector< OUString > aExcludedChartNames;
211 OSL_ENSURE( pPage,
"Page?" );
217 if ( !bSameDocClipboard )
227 pScDrawView->
Paste(*pModel, aPos,
nullptr, nOptions);
229 if ( !bSameDocClipboard )
258 if ( pPage && pModelObj && ( pTransferObj || pDrawTrans ) )
263 rProtectedChartRangesVector, aExcludedChartNames, bSameDocClipboard );
286 const Size* pDescSize,
const Graphic* pReplGraph,
const OUString& aMediaType, sal_Int64 nAspect )
301 aObjRef.
SetGraphic( *pReplGraph, aMediaType );
304 if ( nAspect == embed::Aspects::MSOLE_ICON )
306 MapMode aMapMode( MapUnit::Map100thMM );
307 aSize = aObjRef.
GetSize( &aMapMode );
313 MapUnit aMap100 = MapUnit::Map100thMM;
315 if ( pDescSize && pDescSize->
Width() && pDescSize->
Height() )
320 aSz.Width = aSize.
Width();
321 aSz.Height = aSize.
Height();
322 xObj->setVisualAreaSize( nAspect, aSz );
328 aSz = xObj->getVisualAreaSize( nAspect );
330 catch ( embed::NoVisualAreaSizeException& )
335 aSize =
Size( aSz.Width, aSz.Height );
340 OSL_FAIL(
"SvObjectDescriptor::GetSize == 0");
344 aSz.Width = aSize.
Width();
345 aSz.Height = aSize.
Height();
346 xObj->setVisualAreaSize( nAspect, aSz );
351 Point aInsPos = rPos;
385 const OUString& rFile )
402 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
421 MapMode aDestMap( MapUnit::Map100thMM );
423 if (aSourceMap.
GetMapUnit() == MapUnit::MapPixel)
448 pGrafObj->SetName(
aName);
456 if (bSuccess && !rFile.isEmpty())
457 pGrafObj->SetGraphicLink( rFile );
::std::vector< ScRangeList > ScRangeListVector
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions) override
MapMode GetPrefMapMode() const
void SetScaleY(const Fraction &rScaleY)
MapUnit GetMapUnit() const
void SetScaleX(const Fraction &rScaleX)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const MapMode & GetMapMode() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
static void CreateProtectedChartListenersAndNotify(ScDocument &rDoc, const SdrPage *pPage, ScModelObj *pModelObj, SCTAB nTab, const ScRangeListVector &rRangesVector, const ::std::vector< OUString > &rExcludedChartNames, bool bSameDoc=true)
static void GetChartNames(::std::vector< OUString > &rChartNames, const SdrPage *pPage)
ScModelObj * GetModel() const
void EnsureGraphicNames()
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
void SetPastingDrawFromOtherDoc(bool bVal)
static void SetCellAnchoredFromPosition(SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab, bool bResizeWithCell)
static bool IsResizeWithCell(const SdrObject &rObj)
static bool IsCellAnchored(const SdrObject &rObj)
OUString GetNewGraphicName(tools::Long *pnCounter=nullptr) const
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
const ScRangeListVector & GetProtectedChartRangesVector() const
SdrView * GetDragSourceView()
SdrObject * ApplyGraphicToObject(SdrObject &rHitObject, const Graphic &rGraphic, const OUString &rBeginUndoText, const OUString &rFile)
void CalcNormScale(Fraction &rFractX, Fraction &rFractY) const
bool InsertObjectSafe(SdrObject *pObj, SdrPageView &rPV)
virtual void MarkListHasChanged() override
const ScDragData & GetDragData() const
void CopyUsedGraphicStylesFrom(SfxStyleSheetBasePool *pSrcPool)
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
void SetDrawShell(bool bActive)
ScViewData & GetViewData()
ScGridWindow * GetActiveWin()
ScDrawView * GetScDrawView()
ScDocument & GetDocument() const
ScDocShell * GetDocShell() const
ScTabViewShell * GetViewShell() const
ScDrawView * GetScDrawView()
bool PasteGraphic(const Point &rPos, const Graphic &rGraphic, const OUString &rFile)
bool PasteMetaFile(const Point &, const GDIMetaFile &)
bool PasteBitmapEx(const Point &, const BitmapEx &)
bool PasteObject(const Point &, const css::uno::Reference< css::embed::XEmbeddedObject > &, const Size *, const Graphic *=nullptr, const OUString &=OUString(), sal_Int64 nAspect=css::embed::Aspects::MSOLE_CONTENT)
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
void MoveAllMarked(const Size &rSiz, bool bCopy=false)
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
void MarkAllObj(SdrPageView *pPV=nullptr)
const tools::Rectangle & GetAllMarkedRect() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
SfxStyleSheetBasePool * GetStyleSheetPool() const
OutputDevice * GetRefDevice() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrPageView * ShowSdrPage(SdrPage *pPage) override
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const=0
SdrPage * GetPage() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
sal_uInt16 getHitTolLog() const
virtual void DeleteMarked()
bool IsObjectInPlaceActive() const
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
virtual SfxObjectShell * GetObjectShell() override
SfxInPlaceClient * GetIPClient() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
bool HasEmbeddedObject(const OUString &)
OUString GetEmbeddedObjectName(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
void SetGraphic(const Graphic &rGraphic, const OUString &rMediaType)
Size GetSize(MapMode const *pTargetMapMode) const
Size LogicToLogic(const Size &rSzSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
EmbeddedObjectRef * pObject
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
OUString ScResId(TranslateId aId)
ScDrawTransferObj * pDrawTransfer
static void lcl_AdjustInsertPos(ScViewData &rData, Point &rPos, const Size &rSize)