[Libreoffice-commits] core.git: sw/CppunitTest_sw_uiwriter.mk sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Jun 23 08:08:22 PDT 2014
sw/CppunitTest_sw_uiwriter.mk | 1
sw/qa/extras/uiwriter/data/shape-textbox-delete.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 22 ++++++++++++++++++++
sw/source/core/draw/dview.cxx | 18 ++++++++++++++++
4 files changed, 41 insertions(+)
New commits:
commit 33141f999b22ce10cdbfbd76081fff211c4b5067
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jun 23 15:40:45 2014 +0200
SwDrawView::DeleteMarked: delete textbox of shape as well
If we delete a shape that had a textbox, then delete that textbox as
well. Without that, the doc model would be still consistent, but most
probably would not be what the user expects.
Change-Id: Id5075233ce66d7a398c88ff3e63b05a6b2133571
diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index 7bfa0ea..4ddff3a 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \
cppuhelper \
sal \
svt \
+ svxcore \
sw \
test \
unotest \
diff --git a/sw/qa/extras/uiwriter/data/shape-textbox-delete.odt b/sw/qa/extras/uiwriter/data/shape-textbox-delete.odt
new file mode 100644
index 0000000..0fe0e9b
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/shape-textbox-delete.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 11fa7df..7fd4a70 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -12,6 +12,9 @@
#include <crsskip.hxx>
#include <shellio.hxx>
#include <expfld.hxx>
+#include <drawdoc.hxx>
+
+#include <svx/svdpage.hxx>
#include "UndoManager.hxx"
@@ -32,6 +35,7 @@ public:
void testFdo75110();
void testFdo75898();
void testFdo74981();
+ void testShapeTextboxDelete();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -43,6 +47,7 @@ public:
CPPUNIT_TEST(testFdo75110);
CPPUNIT_TEST(testFdo75898);
CPPUNIT_TEST(testFdo74981);
+ CPPUNIT_TEST(testShapeTextboxDelete);
CPPUNIT_TEST_SUITE_END();
private:
@@ -271,6 +276,23 @@ void SwUiWriterTest::testFdo74981()
CPPUNIT_ASSERT(!pTxtNode->HasHints());
}
+void SwUiWriterTest::testShapeTextboxDelete()
+{
+ SwDoc* pDoc = createDoc("shape-textbox-delete.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ SdrObject* pObject = pPage->GetObj(0);
+ pWrtShell->SelectObj(Point(), 0, pObject);
+ sal_Int32 nActual = pPage->GetObjCount();
+ // Two objects on the draw page: the shape and its textbox.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nActual);
+
+ pWrtShell->DelSelectedObj();
+ nActual = pPage->GetObjCount();
+ // Both (not only the shape) should be removed by now (the textbox wasn't removed, so this was 1).
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nActual);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 9446343..299d244 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -34,6 +34,7 @@
#include "frmfmt.hxx"
#include "dflyobj.hxx"
#include "dcontact.hxx"
+#include "textboxhelper.hxx"
#include "frmatr.hxx"
#include "viewsh.hxx"
#include "viewimp.hxx"
@@ -939,10 +940,27 @@ void SwDrawView::DeleteMarked()
}
}
}
+
+ // Check what textboxes have to be deleted afterwards.
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ std::vector<SwFrmFmt*> aTextBoxesToDelete;
+ for (sal_uInt16 i = 0; i < rMarkList.GetMarkCount(); ++i)
+ {
+ SdrObject *pObject = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall(pObject));
+ SwFrmFmt* pFmt = pDrawContact->GetFmt();
+ if (SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(pFmt))
+ aTextBoxesToDelete.push_back(pTextBox);
+ }
+
if ( pDoc->DeleteSelection( *this ) )
{
FmFormView::DeleteMarked();
::FrameNotify( Imp().GetShell(), FLY_DRAG_END );
+
+ // Only delete these now: earlier deletion would clear the mark list as well.
+ for (std::vector<SwFrmFmt*>::iterator i = aTextBoxesToDelete.begin(); i != aTextBoxesToDelete.end(); ++i)
+ pDoc->DelLayoutFmt(*i);
}
pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
if( pTmpRoot )
More information about the Libreoffice-commits
mailing list