summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/textboxhelper.hxx2
-rw-r--r--sw/qa/extras/uiwriter/data/shape-textbox.odt (renamed from sw/qa/extras/uiwriter/data/shape-textbox-delete.odt)bin10723 -> 10723 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx24
-rw-r--r--sw/source/core/doc/textboxhelper.cxx15
-rw-r--r--sw/source/core/frmedt/feshview.cxx17
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx19
6 files changed, 74 insertions, 3 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index c7ba2f466b6b..8b4856415245 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -69,6 +69,8 @@ public:
/// Look up TextFrames in a document, which are in fact TextBoxes.
static std::list<SwFrmFmt*> findTextBoxes(const SwDoc* pDoc);
+ /// Build a textbox -> shape format map.
+ static std::map<SwFrmFmt*, SwFrmFmt*> findShapes(const SwDoc* pDoc);
/// Count number of shapes in the document, excluding TextBoxes.
static sal_Int32 getCount(SdrPage* pPage, std::list<SwFrmFmt*>& rTextBoxes);
/// Get a shape by index, excluding TextBoxes.
diff --git a/sw/qa/extras/uiwriter/data/shape-textbox-delete.odt b/sw/qa/extras/uiwriter/data/shape-textbox.odt
index 0fe0e9b9cb89..0fe0e9b9cb89 100644
--- a/sw/qa/extras/uiwriter/data/shape-textbox-delete.odt
+++ b/sw/qa/extras/uiwriter/data/shape-textbox.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2bf8d5ac7598..9ec5a76d8022 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -17,8 +17,10 @@
#include <redline.hxx>
#include <section.hxx>
#include <fmtclds.hxx>
+#include <dcontact.hxx>
#include <svx/svdpage.hxx>
+#include <svx/svdview.hxx>
#include "UndoManager.hxx"
@@ -39,6 +41,7 @@ public:
void testFdo75110();
void testFdo75898();
void testFdo74981();
+ void testShapeTextboxSelect();
void testShapeTextboxDelete();
void testCp1000071();
@@ -52,6 +55,7 @@ public:
CPPUNIT_TEST(testFdo75110);
CPPUNIT_TEST(testFdo75898);
CPPUNIT_TEST(testFdo74981);
+ CPPUNIT_TEST(testShapeTextboxSelect);
CPPUNIT_TEST(testShapeTextboxDelete);
CPPUNIT_TEST(testCp1000071);
CPPUNIT_TEST_SUITE_END();
@@ -282,9 +286,27 @@ void SwUiWriterTest::testFdo74981()
CPPUNIT_ASSERT(!pTxtNode->HasHints());
}
+void SwUiWriterTest::testShapeTextboxSelect()
+{
+ SwDoc* pDoc = createDoc("shape-textbox.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ SdrObject* pObject = pPage->GetObj(1);
+ SwDrawContact* pTextBox = static_cast<SwDrawContact*>(pObject->GetUserCall());
+ // First, make sure that pTextBox is a fly frame (textbox of a shape).
+ CPPUNIT_ASSERT_EQUAL(RES_FLYFRMFMT, static_cast<RES_FMT>(pTextBox->GetFmt()->Which()));
+
+ // Then select it.
+ pWrtShell->SelectObj(Point(), 0, pObject);
+ const SdrMarkList& rMarkList = pWrtShell->GetDrawView()->GetMarkedObjectList();
+ SwDrawContact* pShape = static_cast<SwDrawContact*>(rMarkList.GetMark(0)->GetMarkedSdrObj()->GetUserCall());
+ // And finally make sure the shape got selected, not just the textbox itself.
+ CPPUNIT_ASSERT_EQUAL(RES_DRAWFRMFMT, static_cast<RES_FMT>(pShape->GetFmt()->Which()));
+}
+
void SwUiWriterTest::testShapeTextboxDelete()
{
- SwDoc* pDoc = createDoc("shape-textbox-delete.odt");
+ SwDoc* pDoc = createDoc("shape-textbox.odt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 8e6bfd5b152c..90d2b5446beb 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -126,6 +126,21 @@ std::list<SwFrmFmt*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc)
return aRet;
}
+std::map<SwFrmFmt*, SwFrmFmt*> SwTextBoxHelper::findShapes(const SwDoc* pDoc)
+{
+ std::map<SwFrmFmt*, SwFrmFmt*> aRet;
+
+ const SwFrmFmts& rSpzFrmFmts = *pDoc->GetSpzFrmFmts();
+ for (SwFrmFmts::const_iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it)
+ {
+ SwFrmFmt* pTextBox = findTextBox(*it);
+ if (pTextBox)
+ aRet[pTextBox] = *it;
+ }
+
+ return aRet;
+}
+
/// If the passed SdrObject is in fact a TextFrame, that is used as a TextBox.
bool lcl_isTextBox(SdrObject* pSdrObject, std::list<SwFrmFmt*>& rTextBoxes)
{
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index e1655e84112d..6ff58cc8c322 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -40,6 +40,7 @@
#include <DocumentSettingManager.hxx>
#include <cmdid.h>
#include <drawdoc.hxx>
+#include <textboxhelper.hxx>
#include <poolfmt.hrc>
#include <frmfmt.hxx>
#include <frmatr.hxx>
@@ -220,6 +221,22 @@ bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj )
}
}
+ // If the fly frame is a textbox of a shape, then select the shape instead.
+ std::map<SwFrmFmt*, SwFrmFmt*> aTextBoxShapes = SwTextBoxHelper::findShapes(mpDoc);
+ for (sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i)
+ {
+ SdrObject* pObject = rMrkList.GetMark(i)->GetMarkedSdrObj();
+ SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall(pObject));
+ SwFrmFmt* pFmt = pDrawContact->GetFmt();
+ if (aTextBoxShapes.find(pFmt) != aTextBoxShapes.end())
+ {
+ SdrObject* pShape = aTextBoxShapes[pFmt]->FindSdrObject();
+ pDView->UnmarkAll();
+ pDView->MarkObj(pShape, Imp()->GetPageView(), bAddSelect, bEnterGroup);
+ break;
+ }
+ }
+
if ( bRet )
{
::lcl_GrabCursor(this, pOldSelFly);
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index e1fda396a3a2..6887cd06b1c1 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -76,6 +76,8 @@
#include <wrtsh.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
+#include <textboxhelper.hxx>
+#include <dcontact.hxx>
#include <fldbas.hxx>
#include <swmodule.hxx>
#include <docsh.hxx>
@@ -4241,8 +4243,21 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
SdrPageView* pPV;
if (pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER ))
{
- pSdrView->UnmarkAllObj();
- pSdrView->MarkObj(pObj,pPV,false,false);
+ std::map<SwFrmFmt*, SwFrmFmt*> aTextBoxShapes = SwTextBoxHelper::findShapes(rSh.GetDoc());
+ SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
+ SwFrmFmt* pFmt = pDrawContact->GetFmt();
+ if (aTextBoxShapes.find(pFmt) == aTextBoxShapes.end())
+ {
+ pSdrView->UnmarkAllObj();
+ pSdrView->MarkObj(pObj,pPV,false,false);
+ }
+ else
+ {
+ // If the fly frame is a textbox of a shape, then select the shape instead.
+ SdrObject* pShape = aTextBoxShapes[pFmt]->FindSdrObject();
+ pSdrView->UnmarkAllObj();
+ pSdrView->MarkObj(pShape, pPV, false, false);
+ }
}
}
ReleaseMouse();