20 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
21 #include <com/sun/star/embed/XEmbeddedObject.hpp>
34 #include <com/sun/star/embed/Aspects.hpp>
36 #include <document.hxx>
37 #include <viewfunc.hxx>
39 #include <drawview.hxx>
43 #include <globstr.hrc>
57 OSL_ENSURE(pPage,
"pPage ???");
59 if (aPgSize.Width() < 0)
60 aPgSize.
setWidth( -aPgSize.Width() );
65 rPos.AdjustX(x + 80 );
67 rPos.AdjustY(y + 200 );
68 rPos.AdjustX(rSize.
Width() / 2 );
69 rPos.AdjustY(rSize.
Height() / 2 );
73 bool bGroup, std::u16string_view rSrcShellID, std::u16string_view rDestShellID )
75 bool bSameDocClipboard = rSrcShellID == rDestShellID;
78 Point aPos( rLogicPos );
83 OutputDevice* pRef = GetViewData().GetDocument().GetDrawLayer()->GetRefDevice();
90 bool bNegativePage = GetViewData().GetDocument().IsNegativePage( GetViewData().GetTabNo() );
92 SdrView* pDragEditView =
nullptr;
103 if (aPos.X() > 0) aPos.setX( 0 );
107 if (aPos.X() < 0) aPos.setX( 0 );
109 if (aPos.Y() < 0) aPos.setY( 0 );
116 bool bSameDoc = ( pDragEditView && pDragEditView->
GetModel() == pScDrawView->
GetModel() );
131 if ( nDiffX != 0 || nDiffY != 0 )
137 SCTAB nTab = GetViewData().GetTabNo();
138 SdrPage* pDestPage = pDrawModel->
GetPage( static_cast< sal_uInt16 >( nTab ) );
139 OSL_ENSURE(pDestPage,
"who is this, Page?");
141 ::std::vector< OUString > aExcludedChartNames;
150 for (
size_t nm=0; nm<nMarkCnt; ++nm) {
157 if (pNewObj!=
nullptr)
160 if ( dynamic_cast<const SdrGrafObj*>( pNewObj) !=
nullptr && !
bPasteIsMove )
161 pNewObj->SetName(static_cast<ScDrawLayer*>(pDrawModel)->GetNewGraphicName());
163 if (nDiffX!=0 || nDiffY!=0)
164 pNewObj->NbcMove(
Size(nDiffX,nDiffY));
167 pScDrawView->
AddUndo(std::make_unique<SdrUndoInsertObj>( *pNewObj ));
178 ScDocument& rDocument = GetViewData().GetDocument();
179 ScDocShell* pDocShell = GetViewData().GetDocShell();
180 ScModelObj* pModelObj = ( pDocShell ? comphelper::getUnoTunnelImplementation<ScModelObj>( pDocShell->
GetModel() ) :
nullptr );
181 if ( pDestPage && pModelObj && pDrawTrans )
185 rProtectedChartRangesVector, aExcludedChartNames, bSameDoc );
204 nOptions |= SdrInsertFlags::DONTMARK;
206 ::std::vector< OUString > aExcludedChartNames;
207 SCTAB nTab = GetViewData().GetTabNo();
209 OSL_ENSURE( pPage,
"Page?" );
217 if ( !bSameDocClipboard )
218 GetViewData().GetDocument().SetPastingDrawFromOtherDoc(
true );
220 pScDrawView->
Paste(*pModel, aPos,
nullptr, nOptions);
222 if ( !bSameDocClipboard )
223 GetViewData().GetDocument().SetPastingDrawFromOtherDoc(
false );
240 pObject = aIter.
Next();
245 GetViewData().GetDocument().EnsureGraphicNames();
247 ScDocument& rDocument = GetViewData().GetDocument();
248 ScDocShell* pDocShell = GetViewData().GetDocShell();
249 ScModelObj* pModelObj = ( pDocShell ? comphelper::getUnoTunnelImplementation<ScModelObj>( pDocShell->
GetModel() ) :
nullptr );
251 if ( pPage && pModelObj && ( pTransferObj || pDrawTrans ) )
256 rProtectedChartRangesVector, aExcludedChartNames, bSameDocClipboard );
279 const Size* pDescSize,
const Graphic* pReplGraph,
const OUString& aMediaType, sal_Int64 nAspect )
294 aObjRef.
SetGraphic( *pReplGraph, aMediaType );
297 if ( nAspect == embed::Aspects::MSOLE_ICON )
299 MapMode aMapMode( MapUnit::Map100thMM );
300 aSize = aObjRef.
GetSize( &aMapMode );
306 MapUnit aMap100 = MapUnit::Map100thMM;
308 if ( pDescSize && pDescSize->
Width() && pDescSize->
Height() )
313 aSz.Width = aSize.
Width();
314 aSz.Height = aSize.
Height();
315 xObj->setVisualAreaSize( nAspect, aSz );
321 aSz = xObj->getVisualAreaSize( nAspect );
323 catch ( embed::NoVisualAreaSizeException& )
328 aSize =
Size( aSz.Width, aSz.Height );
333 OSL_FAIL(
"SvObjectDescriptor::GetSize == 0");
337 aSz.Width = aSize.
Width();
338 aSz.Height = aSize.
Height();
339 xObj->setVisualAreaSize( nAspect, aSz );
344 Point aInsPos = rPos;
345 if ( GetViewData().GetDocument().IsNegativePage( GetViewData().GetTabNo() ) )
346 aInsPos.AdjustX( -(aSize.
Width()) );
358 GetViewData().GetViewShell()->SetDrawShell(
true );
368 return PasteGraphic( rPos, aGraphic,
"" );
374 return PasteGraphic( rPos, aGraphic,
"" );
378 const OUString& rFile )
395 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
414 MapMode aDestMap( MapUnit::Map100thMM );
416 if (aSourceMap.
GetMapUnit() == MapUnit::MapPixel)
427 if ( GetViewData().GetDocument().IsNegativePage( GetViewData().GetTabNo() ) )
428 aPos.AdjustX( -(aSize.
Width()) );
430 GetViewData().GetViewShell()->SetDrawShell(
true );
440 OUString
aName = pLayer->GetNewGraphicName();
449 if (bSuccess && !rFile.isEmpty())
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
size_t GetMarkCount() const
void setWidth(tools::Long nWidth)
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
void SetName(const OUString &rStr, const bool bSetChanged=true)
bool IsObjectInPlaceActive() const
void CalcNormScale(Fraction &rFractX, Fraction &rFractY) const
bool PasteGraphic(const Point &rPos, const Graphic &rGraphic, const OUString &rFile)
static bool IsCellAnchored(const SdrObject &rObj)
const ContentProperties & rData
const MapMode & GetMapMode() const
bool HasEmbeddedObject(const OUString &)
SdrMark * GetMark(size_t nNum) const
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
css::uno::Reference< css::frame::XModel > GetModel() const
const ScDragData & GetDragData() const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
EmbeddedObjectRef * pObject
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 lcl_AdjustInsertPos(ScViewData &rData, Point &rPos, const Size &rSize)
ScDrawTransferObj * pDrawTransfer
SdrPageView * ShowSdrPage(SdrPage *pPage) override
ScDrawView * GetScDrawView()
SdrObject * GetMarkedSdrObj() const
void MarkAllObj(SdrPageView *pPV=nullptr)
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
static void GetChartNames(::std::vector< OUString > &rChartNames, const SdrPage *pPage)
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
virtual void MarkListHasChanged() override
void SetScaleX(const Fraction &rScaleX)
static void SetCellAnchoredFromPosition(SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab, bool bResizeWithCell)
bool PasteBitmapEx(const Point &, const BitmapEx &)
const SdrMarkList & GetMarkedObjectList() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
tools::Long Width() const
OUString ScResId(const char *pId)
void SetScaleY(const Fraction &rScaleY)
MapUnit GetMapUnit() const
const tools::Rectangle & GetAllMarkedRect() const
void SetGraphicLink(const OUString &rFileName)
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions) override
virtual SdrLayerID GetLayer() const
::std::vector< ScRangeList > ScRangeListVector
OUString GetEmbeddedObjectName(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
bool InsertObjectSafe(SdrObject *pObj, SdrPageView &rPV)
SfxViewShell * GetViewShell() const
SfxInPlaceClient * GetIPClient() const
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
MapMode GetPrefMapMode() const
SdrPage * GetPage() const
virtual void DeleteMarked()
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
tools::Long Height() const
Size GetSize(MapMode const *pTargetMapMode) const
void SetGraphic(const Graphic &rGraphic, const OUString &rMediaType)
SdrView * GetDragSourceView()
bool PasteMetaFile(const Point &, const GDIMetaFile &)
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
SdrPageView * GetSdrPageView() const
SdrObject * ApplyGraphicToObject(SdrObject &rHitObject, const Graphic &rGraphic, const OUString &rBeginUndoText, const OUString &rFile)
void setHeight(tools::Long nHeight)
SdrModel & getSdrModelFromSdrView() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
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 MoveAllMarked(const Size &rSiz, bool bCopy=false)
sal_uInt16 getHitTolLog() const
SdrModel * GetModel() const
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
static bool IsResizeWithCell(const SdrObject &rObj)
const ScRangeListVector & GetProtectedChartRangesVector() const
virtual void NbcSetLayer(SdrLayerID nLayer)