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>
58 OSL_ENSURE(pPage,
"pPage ???");
60 if (aPgSize.
Width() < 0)
66 rPos.AdjustX(
x + 80 );
68 rPos.AdjustY(
y + 200 );
69 rPos.AdjustX(rSize.
Width() / 2 );
70 rPos.AdjustY(rSize.
Height() / 2 );
74 bool bGroup, std::u16string_view rSrcShellID, std::u16string_view rDestShellID )
76 bool bSameDocClipboard = rSrcShellID == rDestShellID;
79 Point aPos( rLogicPos );
93 SdrView* pDragEditView =
nullptr;
104 if (aPos.X() > 0) aPos.setX( 0 );
108 if (aPos.X() < 0) aPos.setX( 0 );
110 if (aPos.Y() < 0) aPos.setY( 0 );
117 bool bSameDoc = ( pDragEditView && &pDragEditView->
GetModel() == &pScDrawView->
GetModel() );
132 if ( nDiffX != 0 || nDiffY != 0 )
139 SdrPage* pDestPage = rDrawModel.
GetPage(
static_cast< sal_uInt16
>( nTab ) );
140 OSL_ENSURE(pDestPage,
"who is this, Page?");
142 ::std::vector< OUString > aExcludedChartNames;
151 for (
size_t nm=0; nm<nMarkCnt; ++nm) {
158 if (pNewObj!=
nullptr)
162 pNewObj->SetName(
static_cast<ScDrawLayer*
>(&rDrawModel)->GetNewGraphicName());
164 if (nDiffX!=0 || nDiffY!=0)
165 pNewObj->NbcMove(
Size(nDiffX,nDiffY));
168 pScDrawView->
AddUndo(std::make_unique<SdrUndoInsertObj>( *pNewObj ));
182 if ( pDestPage && pModelObj && pDrawTrans )
186 rProtectedChartRangesVector, aExcludedChartNames, bSameDoc );
205 nOptions |= SdrInsertFlags::DONTMARK;
207 ::std::vector< OUString > aExcludedChartNames;
210 OSL_ENSURE( pPage,
"Page?" );
218 if ( !bSameDocClipboard )
221 pScDrawView->
Paste(*pModel, aPos,
nullptr, nOptions);
223 if ( !bSameDocClipboard )
252 if ( pPage && pModelObj && ( pTransferObj || pDrawTrans ) )
257 rProtectedChartRangesVector, aExcludedChartNames, bSameDocClipboard );
280 const Size* pDescSize,
const Graphic* pReplGraph,
const OUString& aMediaType, sal_Int64 nAspect )
295 aObjRef.
SetGraphic( *pReplGraph, aMediaType );
298 if ( nAspect == embed::Aspects::MSOLE_ICON )
300 MapMode aMapMode( MapUnit::Map100thMM );
301 aSize = aObjRef.
GetSize( &aMapMode );
307 MapUnit aMap100 = MapUnit::Map100thMM;
309 if ( pDescSize && pDescSize->
Width() && pDescSize->
Height() )
314 aSz.Width = aSize.
Width();
315 aSz.Height = aSize.
Height();
316 xObj->setVisualAreaSize( nAspect, aSz );
322 aSz = xObj->getVisualAreaSize( nAspect );
324 catch ( embed::NoVisualAreaSizeException& )
329 aSize =
Size( aSz.Width, aSz.Height );
334 OSL_FAIL(
"SvObjectDescriptor::GetSize == 0");
338 aSz.Width = aSize.
Width();
339 aSz.Height = aSize.
Height();
340 xObj->setVisualAreaSize( nAspect, aSz );
345 Point aInsPos = rPos;
347 aInsPos.AdjustX( -(aSize.
Width()) );
379 const OUString& rFile )
396 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
415 MapMode aDestMap( MapUnit::Map100thMM );
417 if (aSourceMap.
GetMapUnit() == MapUnit::MapPixel)
429 aPos.AdjustX( -(aSize.
Width()) );
442 pGrafObj->SetName(
aName);
450 if (bSuccess && !rFile.isEmpty())
451 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
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
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
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)