[Libreoffice-commits] core.git: Branch 'feature/textbox' - sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue May 20 09:35:39 PDT 2014
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 <vmiklos at 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::list<SwFrmFmt*> findTextBoxes(SwDoc* pDoc);
+ /// Count number of shapes in the document, excluding TextBoxes.
+ static sal_Int32 getCount(SdrPage* pPage, std::list<SwFrmFmt*>& 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::list<SwFrmFmt*> SwTextBoxHelper::findTextBoxes(SwDoc* pDoc)
+{
+ std::list<SwFrmFmt*> 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::list<SwFrmFmt*>& 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::list<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+
+ if (aTextBoxes.empty())
+ return pDrawPage->getCount();
+ else
+ return SwTextBoxHelper::getCount(pDrawPage->GetSdrPage(), aTextBoxes);
}
}
More information about the Libreoffice-commits
mailing list