sw/inc/doc.hxx | 4 ++-- sw/inc/textboxhelper.hxx | 2 +- sw/source/core/doc/docfly.cxx | 23 +++++++++++++++++++++-- sw/source/core/doc/textboxhelper.cxx | 10 ++++++---- sw/source/core/unocore/unocoll.cxx | 12 +++++++++--- 5 files changed, 39 insertions(+), 12 deletions(-)
New commits: commit f7f16dd245ea73cfd198684fb33abe968380768b Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 22 15:12:03 2014 +0200 SwXFrameEnumeration: ignore textboxes Change-Id: Ifd8ff27bfb11b1162197e7a159c5bbe25b7d9bc3 diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 95fe53e..99a6146 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -49,6 +49,7 @@ #include <unofield.hxx> #include <unoidx.hxx> #include <unoframe.hxx> +#include <textboxhelper.hxx> #include <unofootnote.hxx> #include <vcl/svapp.hxx> #include <fmtcntnt.hxx> @@ -1087,12 +1088,15 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc) ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin()); // #i104937# SwFrmFmt* pFmt( 0 ); + + std::list<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); + for( sal_uInt16 i = 0; i < nSize; ++i ) // for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt) { // #i104937# pFmt = (*pFmts)[i]; - if(pFmt->Which() != RES_FLYFRMFMT) + if(pFmt->Which() != RES_FLYFRMFMT || std::find(aTextBoxes.begin(), aTextBoxes.end(), pFmt) != aTextBoxes.end()) continue; const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(!pIdx || !pIdx->GetNodes().IsDocNodes()) commit 18824d52c4a326c2b31c30c2153e05adbaf27faa Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 22 14:51:41 2014 +0200 SwXFrames::getByIndex: ignore textboxes Change-Id: I0d0f16e147092402b85d84e90fe8ee9812a2937f diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index bccd5dd..8bab97a 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1233,7 +1233,7 @@ public: /** Access to frames. Iterate over Flys - forr Basic-Collections. */ sal_uInt16 GetFlyCount( FlyCntType eType = FLYCNTTYPE_ALL, bool bIgnoreTextBoxes = false ) const; - SwFrmFmt* GetFlyNum(sal_uInt16 nIdx, FlyCntType eType = FLYCNTTYPE_ALL); + SwFrmFmt* GetFlyNum(sal_uInt16 nIdx, FlyCntType eType = FLYCNTTYPE_ALL, bool bIgnoreTextBoxes = false ); // Copy formats in own arrays and return them. SwFrmFmt *CopyFrmFmt ( const SwFrmFmt& ); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index c657db0..4755251 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -120,16 +120,25 @@ sal_uInt16 SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const } /// @attention If you change this, also update SwXFrameEnumeration in unocoll. -SwFrmFmt* SwDoc::GetFlyNum( sal_uInt16 nIdx, FlyCntType eType ) +SwFrmFmt* SwDoc::GetFlyNum( sal_uInt16 nIdx, FlyCntType eType, bool bIgnoreTextBoxes ) { SwFrmFmts& rFmts = *GetSpzFrmFmts(); SwFrmFmt* pRetFmt = 0; sal_uInt16 nSize = rFmts.size(); const SwNodeIndex* pIdx; sal_uInt16 nCount = 0; + + std::list<SwFrmFmt*> aTextBoxes; + if (bIgnoreTextBoxes) + aTextBoxes = SwTextBoxHelper::findTextBoxes(this); + for( sal_uInt16 i = 0; !pRetFmt && i < nSize; ++i ) { SwFrmFmt* pFlyFmt = rFmts[ i ]; + + if (bIgnoreTextBoxes && std::find(aTextBoxes.begin(), aTextBoxes.end(), pFlyFmt) != aTextBoxes.end()) + continue; + if( RES_FLYFRMFMT == pFlyFmt->Which() && 0 != ( pIdx = pFlyFmt->GetCntnt().GetCntntIdx() ) && pIdx->GetNodes().IsDocNodes() diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index d0d1a32..95fe53e 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1200,7 +1200,8 @@ uno::Any SwXFrames::getByIndex(sal_Int32 nIndex) throw uno::RuntimeException(); if(nIndex < 0 || nIndex >= USHRT_MAX) throw IndexOutOfBoundsException(); - SwFrmFmt* pFmt = GetDoc()->GetFlyNum(static_cast<sal_uInt16>(nIndex), eType); + // Ignore TextBoxes for TextFrames. + SwFrmFmt* pFmt = GetDoc()->GetFlyNum(static_cast<sal_uInt16>(nIndex), eType, /*bIgnoreTextBoxes=*/eType == FLYCNTTYPE_FRM); if(!pFmt) throw IndexOutOfBoundsException(); return lcl_UnoWrapFrame(pFmt, eType); commit d41fdbdb56dc1a27b83753f2facd50e12add9b77 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 22 14:21:38 2014 +0200 SwXFrames::getCount: ignore TextFrames, which are TextBoxes Change-Id: I39fb4fcff2a55cef658d93c80c1cf448bd2e7c86 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 4e833d8..bccd5dd 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1232,7 +1232,7 @@ public: /** Access to frames. Iterate over Flys - forr Basic-Collections. */ - sal_uInt16 GetFlyCount( FlyCntType eType = FLYCNTTYPE_ALL) const; + sal_uInt16 GetFlyCount( FlyCntType eType = FLYCNTTYPE_ALL, bool bIgnoreTextBoxes = false ) const; SwFrmFmt* GetFlyNum(sal_uInt16 nIdx, FlyCntType eType = FLYCNTTYPE_ALL); // Copy formats in own arrays and return them. diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index e306eb8..c657db0 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -42,6 +42,7 @@ #include <pagefrm.hxx> #include <rootfrm.hxx> #include <flyfrms.hxx> +#include <textboxhelper.hxx> #include <frmtool.hxx> #include <frmfmt.hxx> #include <ndtxt.hxx> @@ -68,15 +69,24 @@ using namespace ::com::sun::star; -sal_uInt16 SwDoc::GetFlyCount( FlyCntType eType ) const +sal_uInt16 SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const { const SwFrmFmts& rFmts = *GetSpzFrmFmts(); sal_uInt16 nSize = rFmts.size(); sal_uInt16 nCount = 0; const SwNodeIndex* pIdx; + + std::list<SwFrmFmt*> aTextBoxes; + if (bIgnoreTextBoxes) + aTextBoxes = SwTextBoxHelper::findTextBoxes(this); + for ( sal_uInt16 i = 0; i < nSize; i++) { const SwFrmFmt* pFlyFmt = rFmts[ i ]; + + if (bIgnoreTextBoxes && std::find(aTextBoxes.begin(), aTextBoxes.end(), pFlyFmt) != aTextBoxes.end()) + continue; + if( RES_FLYFRMFMT == pFlyFmt->Which() && 0 != ( pIdx = pFlyFmt->GetCntnt().GetCntntIdx() ) && pIdx->GetNodes().IsDocNodes() diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 7229102..d0d1a32 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1188,7 +1188,8 @@ sal_Int32 SwXFrames::getCount(void) throw(uno::RuntimeException, std::exception) SolarMutexGuard aGuard; if(!IsValid()) throw uno::RuntimeException(); - return GetDoc()->GetFlyCount(eType); + // Ignore TextBoxes for TextFrames. + return GetDoc()->GetFlyCount(eType, /*bIgnoreTextBoxes=*/eType == FLYCNTTYPE_FRM); } uno::Any SwXFrames::getByIndex(sal_Int32 nIndex) commit e6d1ef3eb34f3dc43698042b9c05d01aceaa0161 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 22 13:58:35 2014 +0200 SwTextBoxHelper::findTextBox: only draw frames can have textboxes Change-Id: Id351b96d616eecc780e987a1d0e99ca3f40e4b7c diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 36c302a..56b4e0e 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -143,13 +143,15 @@ SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape) { SwFrmFmt* pRet = 0; - if (pShape->GetAttrSet().HasItem(RES_CNTNT)) + // Only draw frames can have TextBoxes. + if (pShape->Which() == RES_DRAWFRMFMT && pShape->GetAttrSet().HasItem(RES_CNTNT)) { const SwFmtCntnt& rCntnt = pShape->GetCntnt(); SwFrmFmts& rSpzFrmFmts = *pShape->GetDoc()->GetSpzFrmFmts(); for (SwFrmFmts::iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it) { SwFrmFmt* pFmt = *it; + // Only a fly frame can be a TextBox. if (pFmt->Which() == RES_FLYFRMFMT && pFmt->GetAttrSet().HasItem(RES_CNTNT) && pFmt->GetCntnt() == rCntnt) { pRet = pFmt; commit 3d5ecdfd3f30ea6e70848f9e110e208991dd7676 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 22 13:47:43 2014 +0200 let SwTextBoxHelper::findTextBoxes() take a const SwDoc Change-Id: I173b85c15fb59f4fb0bbdf5befdc998aabc27565 diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index d3532c0..28f8d71 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -41,7 +41,7 @@ public: static SwFrmFmt* findTextBox(SwFrmFmt* pShape); /// Look up TextFrames in a document, which are in fact TextBoxes. - static std::list<SwFrmFmt*> findTextBoxes(SwDoc* pDoc); + static std::list<SwFrmFmt*> findTextBoxes(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/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index d2cd4d7..36c302a 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -83,12 +83,12 @@ void SwTextBoxHelper::destroy(SwFrmFmt* pShape) } } -std::list<SwFrmFmt*> SwTextBoxHelper::findTextBoxes(SwDoc* pDoc) +std::list<SwFrmFmt*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc) { std::list<SwFrmFmt*> aRet; - SwFrmFmts& rSpzFrmFmts = *pDoc->GetSpzFrmFmts(); - for (SwFrmFmts::iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it) + const SwFrmFmts& rSpzFrmFmts = *pDoc->GetSpzFrmFmts(); + for (SwFrmFmts::const_iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it) { SwFrmFmt* pTextBox = findTextBox(*it); if (pTextBox) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits