/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// MapMode at Outliner-RefDevice has to be right (as in FuText::MakeOutliner) //! merge with FuText::MakeOutliner?
MapMode aOldMapMode;
OutputDevice* pRef = GetViewData().GetDocument().GetDrawLayer()->GetRefDevice(); if (pRef)
{
aOldMapMode = pRef->GetMapMode();
pRef->SetMapMode( MapMode(MapUnit::Map100thMM) );
}
// Directly Clone to target SdrModel
rtl::Reference<SdrObject> pNewObj(pObj->CloneSdrObject(rDrawModel));
if (pNewObj!=nullptr)
{ // copy graphics within the same model - always needs new name if ( dynamic_cast<const SdrGrafObj*>( pNewObj.get()) != nullptr && !bPasteIsMove )
pNewObj->SetName(static_cast<ScDrawLayer*>(&rDrawModel)->GetNewGraphicName());
if (nDiffX!=0 || nDiffY!=0)
pNewObj->NbcMove(Size(nDiffX,nDiffY)); if (pDestPage)
pDestPage->InsertObject( pNewObj.get() );
pScDrawView->AddUndo(std::make_unique<SdrUndoInsertObj>( *pNewObj ));
if (ScDrawLayer::IsCellAnchored(*pNewObj))
ScDrawLayer::SetCellAnchoredFromPosition(*pNewObj, GetViewData().GetDocument(), nTab,
ScDrawLayer::IsResizeWithCell(*pNewObj));
}
}
if ( !bSameDocClipboard )
{ auto pPool = static_cast<ScStyleSheetPool*>(pScDrawView->GetModel().GetStyleSheetPool());
pPool->CopyUsedGraphicStylesFrom(pModel->GetStyleSheetPool());
// #89247# Set flag for ScDocument::UpdateChartListeners() which is // called during paste.
GetViewData().GetDocument().SetPastingDrawFromOtherDoc( true );
}
if ( !bSameDocClipboard )
GetViewData().GetDocument().SetPastingDrawFromOtherDoc( false );
// Paste puts all objects on the active (front) layer // controls must be on SC_LAYER_CONTROLS if (pPage)
{
SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
SdrObject* pObject = aIter.Next(); while (pObject)
{ if ( dynamic_cast<const SdrUnoObj*>( pObject) != nullptr && pObject->GetLayer() != SC_LAYER_CONTROLS )
pObject->NbcSetLayer(SC_LAYER_CONTROLS);
if (ScDrawLayer::IsCellAnchored(*pObject))
ScDrawLayer::SetCellAnchoredFromPosition(*pObject, GetViewData().GetDocument(), nTab,
ScDrawLayer::IsResizeWithCell(*pObject));
pObject = aIter.Next();
}
}
// all graphics objects must have names
GetViewData().GetDocument().EnsureGraphicNames();
if (bGroup)
{
pScDrawView->GroupMarked();
pScDrawView->EndUndo();
}
if (pRef)
pRef->SetMapMode( aOldMapMode );
// GetViewData().GetViewShell()->SetDrawShell( true ); // It is not sufficient to just set the DrawShell if we pasted, for // example, a chart. SetDrawShellOrSub() would only work for D&D in the // same document but not if inserting from the clipboard, therefore // MarkListHasChanged() is what we need.
pScDrawView->MarkListHasChanged();
// #i123922# check if the drop was over an existing object; if yes, evtl. replace // the graphic for a SdrGraphObj (including link state updates) or adapt the fill // style for other objects
SdrPageView* pPageView = pScDrawView->GetSdrPageView(); if (pPageView)
{
SdrObject* pPickObj = pScDrawView->PickObj(rPos, pScDrawView->getHitTolLog(), pPageView); if (pPickObj)
{ const OUString aBeginUndo(ScResId(STR_UNDO_DRAGDROP));
SdrObject* pResult = pScDrawView->ApplyGraphicToObject(
*pPickObj,
rGraphic,
aBeginUndo,
rFile);
if (pResult)
{ // we are done; mark the modified/new object
pScDrawView->MarkObj(pResult, pScDrawView->GetSdrPageView()); returntrue;
}
}
}
// don't mark if OLE bool bSuccess = pScDrawView->InsertObjectSafe(pGrafObj.get(), *pScDrawView->GetSdrPageView());
// SetGraphicLink has to be used after inserting the object, // otherwise an empty graphic is swapped in and the contact stuff crashes. // See #i37444#. if (bSuccess && !rFile.isEmpty())
pGrafObj->SetGraphicLink( rFile );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.