summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-01-25 12:57:14 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-01-25 13:00:28 -0500
commit545737df40880875304bffc3f49800d1d2e99723 (patch)
tree57f56f71d51db66e0589ae815bc4d31ba8e9cff8
parent67d23e3a99bbaaa5a4dff1f8f3a10bd8abd198fb (diff)
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
-rw-r--r--sc/inc/drwlayer.hxx1
-rw-r--r--sc/source/core/data/drwlayer.cxx7
-rw-r--r--sc/source/ui/view/viewfun7.cxx8
3 files changed, 14 insertions, 2 deletions
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 298d619010af..72b980d5fea7 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -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
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 76d67944a161..8ea4fcaa4b9f 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -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);
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index aea107fd0de3..07e4f1f7f83b 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -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();
}
}