[Libreoffice-commits] core.git: Branch 'feature/textbox' - sw/inc sw/source
sw/inc/textboxhelper.hxx |9 + sw/source/core/doc/textboxhelper.cxx | 30 ++ sw/source/core/unocore/unodraw.cxx |9 - 3 files changed, 47 insertions(+), 1 deletion(-) New commits: commit f1889b1a4cdd9d175103bbf9074c75690547e70f Author: Miklos Vajna vmik...@collabora.co.uk Date: Tue May 20 18:33:05 2014 +0200 SwXDrawPage::getCount(): ignore textboxes Change-Id: Ie011f808b35d6f5176965889eeda5cc120974f88 diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index f7750b3..bac2dcc 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -10,10 +10,14 @@ #ifndef INCLUDED_SW_INC_TEXTBOXHELPER_HXX #define INCLUDED_SW_INC_TEXTBOXHELPER_HXX +#include list + #include com/sun/star/uno/Any.h #include com/sun/star/uno/Type.h +class SdrPage; class SwFrmFmt; +class SwDoc; /** * A TextBox is a TextFrame, that is tied to a drawinglayer shape. @@ -34,6 +38,11 @@ public: static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const OUString rPropertyName, const css::uno::Any rValue); /// If we have an associated TextFrame, then return that. static SwFrmFmt* findTextBox(SwFrmFmt* pShape); + +/// Look up TextFrames in a document, which are in fact TextBoxes. +static std::listSwFrmFmt* findTextBoxes(SwDoc* pDoc); +/// Count number of shapes in the document, excluding TextBoxes. +static sal_Int32 getCount(SdrPage* pPage, std::listSwFrmFmt* rTextBoxes); }; #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 85b18b9..4671580 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -18,9 +18,11 @@ #include unotextbodyhf.hxx #include unotextrange.hxx #include unomid.h +#include dflyobj.hxx #include svx/svdoashp.hxx #include svx/unopage.hxx +#include svx/svdpage.hxx #include com/sun/star/table/BorderLine2.hpp #include com/sun/star/text/SizeType.hpp @@ -81,6 +83,34 @@ void SwTextBoxHelper::destroy(SwFrmFmt* pShape) } } +std::listSwFrmFmt* SwTextBoxHelper::findTextBoxes(SwDoc* pDoc) +{ +std::listSwFrmFmt* aRet; + +SwFrmFmts rSpzFrmFmts = *pDoc-GetSpzFrmFmts(); +for (SwFrmFmts::iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it) +{ +SwFrmFmt* pTextBox = findTextBox(*it); +if (pTextBox) +aRet.push_back(pTextBox); +} + +return aRet; +} + +sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage, std::listSwFrmFmt* rTextBoxes) +{ +sal_Int32 nRet = 0; +for (size_t i = 0; i pPage-GetObjCount(); ++i) +{ +SwVirtFlyDrawObj* pObject = PTR_CAST(SwVirtFlyDrawObj, pPage-GetObj(i)); +if (pObject std::find(rTextBoxes.begin(), rTextBoxes.end(), pObject-GetFmt()) != rTextBoxes.end()) +continue; +++nRet; +} +return nRet; +} + SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape) { SwFrmFmt* pRet = 0; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 6cef384..0c639fa 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -30,6 +30,7 @@ #include swunohelper.hxx #include textboxhelper.hxx #include doc.hxx +#include docary.hxx #include IDocumentUndoRedo.hxx #include fmtcntnt.hxx #include fmtflcnt.hxx @@ -516,7 +517,13 @@ sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException, std::excepti else { ((SwXDrawPage*)this)-GetSvxPage(); -return pDrawPage-getCount(); + +std::listSwFrmFmt* aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); + +if (aTextBoxes.empty()) +return pDrawPage-getCount(); +else +return SwTextBoxHelper::getCount(pDrawPage-GetSdrPage(), aTextBoxes); } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/textbox' - sw/inc sw/source
sw/inc/textboxhelper.hxx |3 +++ sw/source/core/doc/textboxhelper.cxx | 32 ++-- sw/source/core/unocore/unodraw.cxx |6 +- 3 files changed, 38 insertions(+), 3 deletions(-) New commits: commit 83857d750b9205db02d4b8bfc3c304364fae0619 Author: Miklos Vajna vmik...@collabora.co.uk Date: Tue May 20 19:15:29 2014 +0200 SwXDrawPage::getByIndex(): ignore textboxes Change-Id: Ie91619e1f44694a547bfbbc5ff8110099c8002e6 diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index bac2dcc..d3532c0 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -14,6 +14,7 @@ #include com/sun/star/uno/Any.h #include com/sun/star/uno/Type.h +#include com/sun/star/lang/IndexOutOfBoundsException.hpp class SdrPage; class SwFrmFmt; @@ -43,6 +44,8 @@ public: static std::listSwFrmFmt* findTextBoxes(SwDoc* pDoc); /// Count number of shapes in the document, excluding TextBoxes. static sal_Int32 getCount(SdrPage* pPage, std::listSwFrmFmt* rTextBoxes); +/// Get a shape by index, excluding TextBoxes. +static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::listSwFrmFmt* rTextBoxes) throw(css::lang::IndexOutOfBoundsException); }; #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 4671580..d2cd4d7 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -98,19 +98,47 @@ std::listSwFrmFmt* SwTextBoxHelper::findTextBoxes(SwDoc* pDoc) return aRet; } +/// If the passed SdrObject is in fact a TextFrame, that is used as a TextBox. +bool lcl_isTextBox(SdrObject* pSdrObject, std::listSwFrmFmt* rTextBoxes) +{ +SwVirtFlyDrawObj* pObject = PTR_CAST(SwVirtFlyDrawObj, pSdrObject); +return pObject std::find(rTextBoxes.begin(), rTextBoxes.end(), pObject-GetFmt()) != rTextBoxes.end(); +} + sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage, std::listSwFrmFmt* rTextBoxes) { sal_Int32 nRet = 0; for (size_t i = 0; i pPage-GetObjCount(); ++i) { -SwVirtFlyDrawObj* pObject = PTR_CAST(SwVirtFlyDrawObj, pPage-GetObj(i)); -if (pObject std::find(rTextBoxes.begin(), rTextBoxes.end(), pObject-GetFmt()) != rTextBoxes.end()) +if (lcl_isTextBox(pPage-GetObj(i), rTextBoxes)) continue; ++nRet; } return nRet; } +uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::listSwFrmFmt* rTextBoxes) throw(lang::IndexOutOfBoundsException) +{ +if (nIndex 0 || nIndex = getCount(pPage, rTextBoxes)) +throw lang::IndexOutOfBoundsException(); + +SdrObject* pRet = 0; +sal_Int32 nCount = 0; // Current logical index. +for (size_t i = 0; i pPage-GetObjCount(); ++i) +{ +if (lcl_isTextBox(pPage-GetObj(i), rTextBoxes)) +continue; +if (nCount == nIndex) +{ +pRet = pPage-GetObj(i); +break; +} +++nCount; +} +assert(pRet); +return uno::makeAny(uno::Referencedrawing::XShape(pRet-getUnoShape(), uno::UNO_QUERY)); +} + SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape) { SwFrmFmt* pRet = 0; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 0c639fa..f3851d9 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -538,7 +538,11 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex) throw lang::IndexOutOfBoundsException(); ((SwXDrawPage*)this)-GetSvxPage(); -return pDrawPage-getByIndex( nIndex ); +std::listSwFrmFmt* aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); +if (aTextBoxes.empty()) +return pDrawPage-getByIndex( nIndex ); +else +return SwTextBoxHelper::getByIndex(pDrawPage-GetSdrPage(), nIndex, aTextBoxes); } uno::Type SwXDrawPage::getElementType(void) throw( uno::RuntimeException, std::exception ) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/textbox' - sw/inc sw/source
sw/inc/textboxhelper.hxx |2 ++ sw/source/core/doc/textboxhelper.cxx | 16 sw/source/core/unocore/unodraw.cxx |3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) New commits: commit f5731a1e78896bf32fe5e7fd36b38cc21553db5a Author: Miklos Vajna vmik...@collabora.co.uk Date: Wed May 14 17:03:45 2014 +0200 SwXShape: allow setting TextBox property to false Change-Id: I3b501d6928cded0f4684817c24674423c1d6c2da diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 93a459d..0c992dc 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -26,6 +26,8 @@ class SwTextBoxHelper public: /// Create a TextBox for a shape. static void create(SwFrmFmt* pShape); +/// Destroy a TextBox for a shape. +static void destroy(SwFrmFmt* pShape); /// Get XTextAppend of a shape's TextBox, if there is any. static css::uno::Any getXTextAppend(SwFrmFmt* pShape, const css::uno::Type rType); /// Sync property of TextBox with the one of the shape. diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 9937778..faadb5f 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -65,6 +65,22 @@ void SwTextBoxHelper::create(SwFrmFmt* pShape) } } +void SwTextBoxHelper::destroy(SwFrmFmt* pShape) +{ +// If a TextBox was enabled previously +if (pShape-GetAttrSet().HasItem(RES_CNTNT)) +{ +SwFrmFmt* pFmt = findTextBox(pShape); + +// Unlink the TextBox's text range from the original shape. +pShape-ResetFmtAttr(RES_CNTNT); + +// Delete the associated TextFrame. +if (pFmt) +pShape-GetDoc()-DelLayoutFmt(pFmt); +} +} + SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape) { SwFrmFmt* pRet = 0; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 5ece513..6a3261b 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1182,9 +1182,10 @@ void SwXShape::setPropertyValue(const OUString rPropertyName, const uno::Any a { bool bValue; aValue = bValue; -// If TextBox is to be enabled. if (bValue) SwTextBoxHelper::create(pFmt); +else +SwTextBoxHelper::destroy(pFmt); } // #i28749# ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits