Kaydet (Commit) c4820200 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Eike Rathke

fdo#59056: Re-calculate cell anchor position of a pasted drawing object.

Else it would re-use the anchor position of the original one (minus the
sheet index which is correctly adjusted).

Change-Id: I52d11eb9953ee7539c9d5da41edd7dd28604587c
Reviewed-on: https://gerrit.libreoffice.org/1869Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 04f2233c
......@@ -166,6 +166,7 @@ public:
String GetNewGraphicName( long* pnCounter = NULL ) const;
void EnsureGraphicNames();
static bool IsCellAnchored( const SdrObject& rObj );
static void SetPageAnchored( SdrObject& );
static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor );
// Updates rAnchor based on position of rObj
......
......@@ -1787,6 +1787,13 @@ void ScDrawLayer::UpdateCellAnchorFromPositionEnd( SdrObject &rObj, const ScDocu
pAnchor->maEndOffset.X() = aCellRect.Right()-aObjRect.Left();
}
bool ScDrawLayer::IsCellAnchored( const SdrObject& rObj )
{
// Cell anchored object always has a user data, to store the anchor cell
// info. If it doesn't then it's page-anchored.
return GetFirstUserDataOfType(&rObj, SC_UD_OBJDATA) != NULL;
}
void ScDrawLayer::SetPageAnchored( SdrObject &rObj )
{
DeleteFirstUserDataOfType(&rObj, SC_UD_OBJDATA);
......
......@@ -172,8 +172,8 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
pDestPage->InsertObject( pNeuObj );
pScDrawView->AddUndo(new SdrUndoInsertObj( *pNeuObj ));
// Chart braucht nicht mehr getrennt behandelt zu werden,
// weil es seine Daten jetzt selber hat
if (ScDrawLayer::IsCellAnchored(*pNeuObj))
ScDrawLayer::SetCellAnchoredFromPosition(*pNeuObj, *GetViewData()->GetDocument(), nTab);
}
}
......@@ -238,6 +238,10 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
{
if ( pObject->ISA(SdrUnoObj) && pObject->GetLayer() != SC_LAYER_CONTROLS )
pObject->NbcSetLayer(SC_LAYER_CONTROLS);
if (ScDrawLayer::IsCellAnchored(*pObject))
ScDrawLayer::SetCellAnchoredFromPosition(*pObject, *GetViewData()->GetDocument(), nTab);
pObject = aIter.Next();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment