dev/null |binary sw/inc/hintids.hxx | 66 +++++++++++++-------------- sw/inc/textboxhelper.hxx | 2 sw/qa/extras/uiwriter/data/shape-textbox.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 24 +++++++++ sw/source/core/doc/textboxhelper.cxx | 15 ++++++ sw/source/core/frmedt/feshview.cxx | 17 ++++++ sw/source/uibase/docvw/edtwin.cxx | 19 ++++++- 8 files changed, 107 insertions(+), 36 deletions(-)
New commits: commit de00dd0a4e9c10e283f5b8093ac1771545cbe243 Author: Miklos Vajna <[email protected]> Date: Tue Jun 24 17:51:05 2014 +0200 sw: update hintid comments to match reality Change-Id: I9c7f620e08865531c70b1c4e655ed9f0aed9d319 diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index e0a6685..4a0840d 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -230,49 +230,49 @@ RES_FRMATR_BEGIN = RES_PARATR_LIST_END, RES_AUTO_STYLE, // 125 RES_FRMATR_STYLE_NAME, // 126 RES_FRMATR_CONDITIONAL_STYLE_NAME, // 127 - RES_FRMATR_GRABBAG, // 130 - RES_TEXT_VERT_ADJUST, // 131 + RES_FRMATR_GRABBAG, // 128 + RES_TEXT_VERT_ADJUST, // 129 RES_FRMATR_END }; enum RES_GRFATR { RES_GRFATR_BEGIN = RES_FRMATR_END, - RES_GRFATR_MIRRORGRF = RES_GRFATR_BEGIN, // 132 - RES_GRFATR_CROPGRF, // 133 - - RES_GRFATR_ROTATION, // 134 - RES_GRFATR_LUMINANCE, // 135 - RES_GRFATR_CONTRAST, // 136 - RES_GRFATR_CHANNELR, // 137 - RES_GRFATR_CHANNELG, // 138 - RES_GRFATR_CHANNELB, // 139 - RES_GRFATR_GAMMA, // 140 - RES_GRFATR_INVERT, // 141 - RES_GRFATR_TRANSPARENCY, // 142 - RES_GRFATR_DRAWMODE, // 143 - - RES_GRFATR_DUMMY1, // 144 - RES_GRFATR_DUMMY2, // 145 - RES_GRFATR_DUMMY3, // 146 - RES_GRFATR_DUMMY4, // 147 - RES_GRFATR_DUMMY5, // 148 + RES_GRFATR_MIRRORGRF = RES_GRFATR_BEGIN, // 130 + RES_GRFATR_CROPGRF, // 131 + + RES_GRFATR_ROTATION, // 132 + RES_GRFATR_LUMINANCE, // 133 + RES_GRFATR_CONTRAST, // 134 + RES_GRFATR_CHANNELR, // 135 + RES_GRFATR_CHANNELG, // 136 + RES_GRFATR_CHANNELB, // 137 + RES_GRFATR_GAMMA, // 138 + RES_GRFATR_INVERT, // 139 + RES_GRFATR_TRANSPARENCY, // 140 + RES_GRFATR_DRAWMODE, // 141 + + RES_GRFATR_DUMMY1, // 142 + RES_GRFATR_DUMMY2, // 143 + RES_GRFATR_DUMMY3, // 144 + RES_GRFATR_DUMMY4, // 145 + RES_GRFATR_DUMMY5, // 146 RES_GRFATR_END }; enum RES_BOXATR { RES_BOXATR_BEGIN = RES_GRFATR_END, - RES_BOXATR_FORMAT = RES_BOXATR_BEGIN, // 149 - RES_BOXATR_FORMULA, // 150 - RES_BOXATR_VALUE, // 151 + RES_BOXATR_FORMAT = RES_BOXATR_BEGIN, // 147 + RES_BOXATR_FORMULA, // 148 + RES_BOXATR_VALUE, // 149 RES_BOXATR_END }; enum RES_UNKNOWNATR { RES_UNKNOWNATR_BEGIN = RES_BOXATR_END, - RES_UNKNOWNATR_CONTAINER = RES_UNKNOWNATR_BEGIN,// 152 + RES_UNKNOWNATR_CONTAINER = RES_UNKNOWNATR_BEGIN,// 150 RES_UNKNOWNATR_END }; @@ -280,13 +280,13 @@ RES_UNKNOWNATR_END enum RES_FMT { RES_FMT_BEGIN = RES_UNKNOWNATR_END, - RES_CHRFMT = RES_FMT_BEGIN, // 144 - RES_FRMFMT, // 145 - RES_FLYFRMFMT, // 146 - RES_TXTFMTCOLL, // 147 - RES_GRFFMTCOLL, // 148 - RES_DRAWFRMFMT, // 149 - RES_CONDTXTFMTCOLL, // 150 + RES_CHRFMT = RES_FMT_BEGIN, // 151 + RES_FRMFMT, // 152 + RES_FLYFRMFMT, // 153 + RES_TXTFMTCOLL, // 154 + RES_GRFFMTCOLL, // 155 + RES_DRAWFRMFMT, // 156 + RES_CONDTXTFMTCOLL, // 157 RES_FMT_END }; @@ -294,7 +294,7 @@ RES_FMT_END enum RES_MSG { RES_MSG_BEGIN = RES_FMT_END, - RES_OBJECTDYING = RES_MSG_BEGIN, // 151 + RES_OBJECTDYING = RES_MSG_BEGIN, // 158 RES_FMT_CHG, RES_ATTRSET_CHG, RES_FRM_SIZECHG, commit 7596e26fd259ce5445212949403e7cd32303b2bd Author: Miklos Vajna <[email protected]> Date: Tue Jun 24 17:11:25 2014 +0200 Add SwTextBoxHelper::findShapes It builds a textbox -> shape map, so methods interested to pick the shape instead of a shape's textbox can call it and act accordingly if their textbox is in the map. Change-Id: I0f30d64a284eb461f462ed6c0a36c88271153f04 diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index c7ba2f4..8b48564 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 similarity index 100% rename from sw/qa/extras/uiwriter/data/shape-textbox-delete.odt rename to sw/qa/extras/uiwriter/data/shape-textbox.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 2bf8d5a..9ec5a76 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 8e6bfd5..90d2b54 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 e1655e8..6ff58cc 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 e1fda39..6887cd0 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(); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
