[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source
Caolán McNamara
caolanm at redhat.com
Fri Jul 3 05:32:44 PDT 2015
sw/qa/extras/uiwriter/data/draw-anchor-undo.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 27 ++++++++++++++++++++++++
sw/source/core/undo/unattr.cxx | 11 +++++++--
3 files changed, 35 insertions(+), 3 deletions(-)
New commits:
commit b5a4e6974a5473c44fc239b6a9ae21f233111c2a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 3 12:47:41 2015 +0100
add a shape resize undo test
Change-Id: I88c2d7de243660ba727f057d6a2d67726b41b982
diff --git a/sw/qa/extras/uiwriter/data/draw-anchor-undo.odt b/sw/qa/extras/uiwriter/data/draw-anchor-undo.odt
new file mode 100644
index 0000000..370799c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/draw-anchor-undo.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6138ed2..a0c1bfe 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -113,6 +113,7 @@ public:
void testEmbeddedDataSource();
void testUnoCursorPointer();
void testTextTableCellNames();
+ void testShapeAnchorUndo();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -163,6 +164,7 @@ public:
CPPUNIT_TEST(testEmbeddedDataSource);
CPPUNIT_TEST(testUnoCursorPointer);
CPPUNIT_TEST(testTextTableCellNames);
+ CPPUNIT_TEST(testShapeAnchorUndo);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1476,6 +1478,31 @@ void SwUiWriterTest::testTextTableCellNames()
CPPUNIT_ASSERT(nCol == 105);
}
+void SwUiWriterTest::testShapeAnchorUndo()
+{
+ SwDoc* pDoc = createDoc("draw-anchor-undo.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ SdrObject* pObject = pPage->GetObj(0);
+ Rectangle aOrigLogicRect(pObject->GetLogicRect());
+
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ rUndoManager.StartUndo(UNDO_START, NULL);
+
+ pWrtShell->SelectObj(Point(), 0, pObject);
+
+ pWrtShell->GetDrawView()->MoveMarkedObj(Size(100, 100), false);
+ pWrtShell->ChgAnchor(0, true, true);
+
+ rUndoManager.EndUndo(UNDO_END, NULL);
+
+ CPPUNIT_ASSERT(aOrigLogicRect != pObject->GetLogicRect());
+
+ rUndoManager.Undo();
+
+ CPPUNIT_ASSERT(aOrigLogicRect == pObject->GetLogicRect());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit f1256611054701a2bba20225fb654814eecbf559
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 3 11:46:18 2015 +0100
Resolves: tdf#92137 drawing layer resize undo in writer fails...
to restore location correctly
if SwFEShell::EndDrag is tweaked to not group the anchor change
undo and the draw size/pos change undo together and then you
undo each step in the ui one at a time this works fine.
The first undo occurs, then the layout kicks in on idle and calls MakeObjPos
on the drawing item and updates it for the new anchor pos
Then on triggering size undo the anchor is correct so the new
pos is set correctly.
If they are bundled together however, the layout at idle doesn't occur
until after the anchor and size have been set, so the adjustment is
too late
Change-Id: I5402d851fcae7f240cc6e9a0e15159115bb663ce
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index ec5770d..9283ae2 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -480,9 +480,9 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
}
}
+ SwDrawContact *pCont = NULL;
if ( RES_DRAWFRMFMT == pFrameFormat->Which() ) {
- SwDrawContact *pCont =
- static_cast<SwDrawContact*>(pFrameFormat->FindContactObj());
+ pCont = static_cast<SwDrawContact*>(pFrameFormat->FindContactObj());
// The Draw model also prepared an Undo object for its right positioning
// which unfortunately is relative. Therefore block here a position
// change of the Contact object by setting the anchor.
@@ -508,8 +508,13 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
pTextNd->InsertItem( aFormat, pPos->nContent.GetIndex(), 0 );
}
- if( RES_DRAWFRMFMT != pFrameFormat->Which() )
+ if (RES_DRAWFRMFMT != pFrameFormat->Which())
pFrameFormat->MakeFrms();
+ else
+ {
+ SdrObject* pSdrObj = pFrameFormat->FindSdrObject();
+ pCont->GetAnchoredObj(pSdrObj)->MakeObjPos();
+ }
rContext.SetSelections(pFrameFormat, 0);
More information about the Libreoffice-commits
mailing list