Kaydet (Commit) f1dae10c authored tarafından Miklos Vajna's avatar Miklos Vajna

SwXDrawPage::getCount(): ignore textboxes

Change-Id: I579cc0242f6901175162b169813e4465d52952a0
üst ae59502b
...@@ -10,10 +10,14 @@ ...@@ -10,10 +10,14 @@
#ifndef INCLUDED_SW_INC_TEXTBOXHELPER_HXX #ifndef INCLUDED_SW_INC_TEXTBOXHELPER_HXX
#define 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/Any.h>
#include <com/sun/star/uno/Type.h> #include <com/sun/star/uno/Type.h>
class SdrPage;
class SwFrmFmt; class SwFrmFmt;
class SwDoc;
/** /**
* A TextBox is a TextFrame, that is tied to a drawinglayer shape. * A TextBox is a TextFrame, that is tied to a drawinglayer shape.
...@@ -34,6 +38,11 @@ public: ...@@ -34,6 +38,11 @@ public:
static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const OUString& rPropertyName, const css::uno::Any& rValue); 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. /// If we have an associated TextFrame, then return that.
static SwFrmFmt* findTextBox(SwFrmFmt* pShape); 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 #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
......
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
#include <unotextbodyhf.hxx> #include <unotextbodyhf.hxx>
#include <unotextrange.hxx> #include <unotextrange.hxx>
#include <unomid.h> #include <unomid.h>
#include <dflyobj.hxx>
#include <svx/svdoashp.hxx> #include <svx/svdoashp.hxx>
#include <svx/unopage.hxx> #include <svx/unopage.hxx>
#include <svx/svdpage.hxx>
#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/SizeType.hpp> #include <com/sun/star/text/SizeType.hpp>
...@@ -81,6 +83,34 @@ void SwTextBoxHelper::destroy(SwFrmFmt* pShape) ...@@ -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* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape)
{ {
SwFrmFmt* pRet = 0; SwFrmFmt* pRet = 0;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <swunohelper.hxx> #include <swunohelper.hxx>
#include <textboxhelper.hxx> #include <textboxhelper.hxx>
#include <doc.hxx> #include <doc.hxx>
#include <docary.hxx>
#include <IDocumentUndoRedo.hxx> #include <IDocumentUndoRedo.hxx>
#include <fmtcntnt.hxx> #include <fmtcntnt.hxx>
#include <fmtflcnt.hxx> #include <fmtflcnt.hxx>
...@@ -516,7 +517,13 @@ sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException, std::excepti ...@@ -516,7 +517,13 @@ sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException, std::excepti
else else
{ {
((SwXDrawPage*)this)->GetSvxPage(); ((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);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment