summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-05-27 09:06:11 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-05-27 09:32:44 +0200
commitf1dae10ca512084a04d08e3f0268723223a92e38 (patch)
tree650fd9b3425f0348726ba5f4e38ec5a231fcc880
parentae59502b20b52aaf34f8f4d89e354f28a7dbe453 (diff)
SwXDrawPage::getCount(): ignore textboxes
Change-Id: I579cc0242f6901175162b169813e4465d52952a0
-rw-r--r--sw/inc/textboxhelper.hxx9
-rw-r--r--sw/source/core/doc/textboxhelper.cxx30
-rw-r--r--sw/source/core/unocore/unodraw.cxx9
3 files changed, 47 insertions, 1 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index f7750b388148..bac2dcc0463b 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 85b18b989ffa..4671580507a4 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 b01ae9cb38ff..c720e996d913 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);
}
}