summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-07-28 00:35:14 +0200
committerMichael Stahl <mstahl@redhat.com>2012-07-28 00:48:22 +0200
commitce66ded6fe2a291301c8e075be67347211d4309d (patch)
tree573477a0d310ea844bc066bc041a9ddbf8ae3fe0 /filter
parent8a05f1265e6307c34b2ffdb5fc5279870c8397b7 (diff)
fix STL conversion 3ae618f9e4c34d5f6f10d953e3fb074018001748:
It turns out that this SvxMSDffShapeInfos has some, shall we say, non-obvious properties, including a split personality that changes its nature from checking for pointer equality to not doing so; symptoms of this include a failing sw_subsequent_ww8export test. Try to cure this madness by splitting the personalities into distinct types, a set and a multiset. Change-Id: Ib87368564b8e1f61379703034c0965422c6dcd0e
Diffstat (limited to 'filter')
-rw-r--r--filter/inc/filter/msfilter/msdffimp.hxx78
-rw-r--r--filter/source/msfilter/msdffimp.cxx82
2 files changed, 93 insertions, 67 deletions
diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index 6b20aaa7aa28..f69f076a28f3 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -26,26 +26,36 @@
*
************************************************************************/
-#ifndef _MSDFFIMP_HXX
-#define _MSDFFIMP_HXX
+#ifndef FLT_MSDFFIMP_HXX
+#define FLT_MSDFFIMP_HXX
+
+#include <string.h>
+
+#include <map>
+#include <vector>
+#include <set>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/ptr_container/ptr_set.hpp>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
#include <tools/solar.h>
#include <tools/color.hxx>
#include <tools/gen.hxx>
-#include <svx/msdffdef.hxx>
+
+#include <sot/storage.hxx>
+
#include <vcl/graph.hxx>
-#include <string.h>
-#include <map>
-#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <svx/msdffdef.hxx>
+
#include <filter/msfilter/msfilterdllapi.h>
-#include <sot/storage.hxx>
-#include <vector>
-#include <set>
-#include <boost/ptr_container/ptr_vector.hpp>
-#include <boost/ptr_container/ptr_set.hpp>
-#include <o3tl/sorted_vector.hxx>
+
class Graphic;
class SvStream;
@@ -189,18 +199,23 @@ public:
~SvxMSDffShapeOrders();
};
-// the following will be sorted explicitly:
-class SvxMSDffShapeInfos
- : public o3tl::sorted_vector<SvxMSDffShapeInfo*,
- o3tl::less_ptr_to<SvxMSDffShapeInfo> >
+struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoById
{
-public:
- ~SvxMSDffShapeInfos()
- {
- DeleteAndDestroyAll();
- }
+ bool operator()(::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const;
+};
+struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoByTxBxComp
+{
+ bool operator()(::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const;
};
+// the following will be sorted explicitly:
+typedef ::std::set< ::boost::shared_ptr<SvxMSDffShapeInfo>,
+ CompareSvxMSDffShapeInfoById > SvxMSDffShapeInfos_ById;
+typedef ::std::multiset< ::boost::shared_ptr<SvxMSDffShapeInfo>,
+ CompareSvxMSDffShapeInfoByTxBxComp> SvxMSDffShapeInfos_ByTxBxComp;
+
#define SVXMSDFF_SETTINGS_CROP_BITMAPS 1
#define SVXMSDFF_SETTINGS_IMPORT_PPT 2
#define SVXMSDFF_SETTINGS_IMPORT_EXCEL 4
@@ -463,7 +478,8 @@ class MSFILTER_DLLPUBLIC SvxMSDffManager : public DffPropertyReader
{
FmFormModel* pFormModel;
SvxMSDffBLIPInfos* pBLIPInfos;
- SvxMSDffShapeInfos* pShapeInfos;
+ ::boost::scoped_ptr<SvxMSDffShapeInfos_ByTxBxComp> m_pShapeInfosByTxBxComp;
+ ::boost::scoped_ptr<SvxMSDffShapeInfos_ById> m_pShapeInfosById;
SvxMSDffShapeOrders* pShapeOrders;
sal_uLong nDefaultFontHeight;
sal_uInt32 nOffsDgg;
@@ -751,8 +767,8 @@ public:
const Rectangle& rClientRect,
const Rectangle& rGlobalChildRect );
- inline const SvxMSDffShapeInfos* GetShapeInfos( void ) const
- { return pShapeInfos; }
+ inline const SvxMSDffShapeInfos_ById* GetShapeInfos( void ) const
+ { return m_pShapeInfosById.get(); }
inline const SvxMSDffShapeOrders* GetShapeOrders( void ) const
{ return pShapeOrders; }
@@ -820,7 +836,6 @@ struct SvxMSDffShapeInfo
sal_uInt32 nTxBxComp;
sal_Bool bReplaceByFly :1; ///< shape can be replaced by a frame in Writer
- sal_Bool bSortByShapeId :1;
sal_Bool bLastBoxInChain:1;
explicit SvxMSDffShapeInfo(sal_uLong nFPos, sal_uInt32 nId=0, // sal_uLong nBIdx=0,
@@ -830,7 +845,6 @@ struct SvxMSDffShapeInfo
nTxBxComp( (nSeqId << 16) + nBoxId )
{
bReplaceByFly = sal_False;
- bSortByShapeId = sal_False;
bLastBoxInChain = sal_True;
}
SvxMSDffShapeInfo(SvxMSDffShapeInfo& rInfo):
@@ -839,21 +853,11 @@ struct SvxMSDffShapeInfo
nTxBxComp( rInfo.nTxBxComp )
{
bReplaceByFly = rInfo.bReplaceByFly;
- bSortByShapeId = rInfo.bSortByShapeId;
bLastBoxInChain = rInfo.bLastBoxInChain;
}
- sal_Bool operator==( const SvxMSDffShapeInfo& rEntry ) const
- {
- return bSortByShapeId ? (nShapeId == rEntry.nShapeId)
- : (nTxBxComp == rEntry.nTxBxComp && this == &rEntry);
- }
- sal_Bool operator<( const SvxMSDffShapeInfo& rEntry ) const
- {
- return bSortByShapeId ? (nShapeId < rEntry.nShapeId)
- : (nTxBxComp < rEntry.nTxBxComp);
- }
};
+
struct SvxMSDffShapeOrder
{
sal_uLong nShapeId; ///< shape id used in PLCF SPA and in mso_fbtSp (FSP)
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 9e10b63b335a..01ccaca71476 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3225,6 +3225,20 @@ DffRecordHeader* DffRecordManager::GetRecordHeader( sal_uInt16 nRecId, DffSeekTo
// private Methoden
//---------------------------------------------------------------------------
+bool CompareSvxMSDffShapeInfoById::operator() (
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const
+{
+ return lhs->nShapeId < rhs->nShapeId;
+}
+
+bool CompareSvxMSDffShapeInfoByTxBxComp::operator() (
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const
+{
+ return lhs->nTxBxComp < rhs->nTxBxComp;
+}
+
void SvxMSDffManager::Scale( sal_Int32& rVal ) const
{
if ( bNeedMap )
@@ -5359,11 +5373,12 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
// das Objekt durch einen Rahmen ersetzen, ansonsten
if( bTextFrame )
{
- SvxMSDffShapeInfo aTmpRec( 0, pImpRec->nShapeId );
- aTmpRec.bSortByShapeId = sal_True;
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const pTmpRec(
+ new SvxMSDffShapeInfo(0, pImpRec->nShapeId));
- SvxMSDffShapeInfos::const_iterator it = pShapeInfos->find( &aTmpRec );
- if( it != pShapeInfos->end() )
+ SvxMSDffShapeInfos_ById::const_iterator const it =
+ m_pShapeInfosById->find(pTmpRec);
+ if (it != m_pShapeInfosById->end())
{
SvxMSDffShapeInfo& rInfo = **it;
pTextImpRec->bReplaceByFly = rInfo.bReplaceByFly;
@@ -5730,7 +5745,7 @@ SvxMSDffManager::SvxMSDffManager(SvStream& rStCtrl_,
:DffPropertyReader( *this ),
pFormModel( NULL ),
pBLIPInfos( new SvxMSDffBLIPInfos ),
- pShapeInfos( new SvxMSDffShapeInfos ),
+ m_pShapeInfosByTxBxComp( new SvxMSDffShapeInfos_ByTxBxComp ),
pShapeOrders( new SvxMSDffShapeOrders ),
nDefaultFontHeight( nDefaultFontHeight_),
nOffsDgg( nOffsDgg_ ),
@@ -5776,7 +5791,7 @@ SvxMSDffManager::SvxMSDffManager( SvStream& rStCtrl_, const String& rBaseURL )
:DffPropertyReader( *this ),
pFormModel( NULL ),
pBLIPInfos( new SvxMSDffBLIPInfos ),
- pShapeInfos( new SvxMSDffShapeInfos ),
+ m_pShapeInfosByTxBxComp( new SvxMSDffShapeInfos_ByTxBxComp ),
pShapeOrders( new SvxMSDffShapeOrders ),
nDefaultFontHeight( 24 ),
nOffsDgg( 0 ),
@@ -5797,7 +5812,6 @@ SvxMSDffManager::SvxMSDffManager( SvStream& rStCtrl_, const String& rBaseURL )
SvxMSDffManager::~SvxMSDffManager()
{
delete pBLIPInfos;
- delete pShapeInfos;
delete pShapeOrders;
delete pFormModel;
}
@@ -5888,18 +5902,17 @@ void SvxMSDffManager::GetFidclData( sal_uInt32 nOffsDggL )
void SvxMSDffManager::CheckTxBxStoryChain()
{
- SvxMSDffShapeInfos* pOld = pShapeInfos;
- sal_uInt16 nCnt = pOld->size();
- pShapeInfos = new SvxMSDffShapeInfos;
+ m_pShapeInfosById.reset(new SvxMSDffShapeInfos_ById);
// altes Info-Array ueberarbeiten
// (ist sortiert nach nTxBxComp)
sal_uLong nChain = ULONG_MAX;
- sal_uInt16 nObjMark = 0;
sal_Bool bSetReplaceFALSE = sal_False;
- sal_uInt16 nObj;
- for( nObj = 0; nObj < nCnt; ++nObj )
+ for (SvxMSDffShapeInfos_ByTxBxComp::iterator iter =
+ m_pShapeInfosByTxBxComp->begin(),
+ mark = m_pShapeInfosByTxBxComp->begin();
+ iter != m_pShapeInfosByTxBxComp->end(); ++iter)
{
- SvxMSDffShapeInfo* pObj = (*pOld)[nObj];
+ boost::shared_ptr<SvxMSDffShapeInfo> const pObj = *iter;
if( pObj->nTxBxComp )
{
pObj->bLastBoxInChain = sal_False;
@@ -5911,10 +5924,14 @@ void SvxMSDffManager::CheckTxBxStoryChain()
if( nChain != pObj->nTxBxComp )
{
// voriger war letzter seiner Gruppe
- if( nObj )
- (*pOld)[ nObj-1 ]->bLastBoxInChain = sal_True;
+ if (iter != m_pShapeInfosByTxBxComp->begin())
+ {
+ SvxMSDffShapeInfos_ByTxBxComp::iterator prev(iter);
+ --prev;
+ (*prev)->bLastBoxInChain = true;
+ }
// Merker und Hilfs-Flag zuruecksetzen
- nObjMark = nObj;
+ mark = iter;
nChain = pObj->nTxBxComp;
bSetReplaceFALSE = !pObj->bReplaceByFly;
}
@@ -5925,8 +5942,11 @@ void SvxMSDffManager::CheckTxBxStoryChain()
// Hilfs-Flag setzen
bSetReplaceFALSE = sal_True;
// ggfs Flag in Anfang der Gruppe austragen
- for( sal_uInt16 nObj2 = nObjMark; nObj2 < nObj; ++nObj2 )
- (*pOld)[ nObj2 ]->bReplaceByFly = sal_False;
+ for (SvxMSDffShapeInfos_ByTxBxComp::iterator itemp = mark;
+ itemp != iter; ++itemp)
+ {
+ (*itemp)->bReplaceByFly = false;
+ }
}
if( bSetReplaceFALSE )
@@ -5936,16 +5956,16 @@ void SvxMSDffManager::CheckTxBxStoryChain()
}
// alle Shape-Info-Objekte in pShapeInfos umkopieren
// (aber nach nShapeId sortieren)
- pObj->bSortByShapeId = sal_True;
pObj->nTxBxComp = pObj->nTxBxComp & 0xFFFF0000;
- pShapeInfos->insert( pObj );
+ m_pShapeInfosById->insert( pObj );
}
// voriger war letzter seiner Gruppe
- if( nObj )
- (*pOld)[ nObj-1 ]->bLastBoxInChain = sal_True;
+ if (!m_pShapeInfosByTxBxComp->empty())
+ {
+ (*m_pShapeInfosByTxBxComp->rbegin())->bLastBoxInChain = true;
+ }
// urspruengliches Array freigeben, ohne Objekte zu zerstoeren
- pOld->clear();
- delete pOld;
+ m_pShapeInfosByTxBxComp.reset();
}
@@ -6348,7 +6368,8 @@ sal_Bool SvxMSDffManager::GetShapeContainerData( SvStream& rSt,
{
aInfo.bReplaceByFly = sal_True;
}
- pShapeInfos->insert( new SvxMSDffShapeInfo( aInfo ) );
+ m_pShapeInfosByTxBxComp->insert(::boost::shared_ptr<SvxMSDffShapeInfo>(
+ new SvxMSDffShapeInfo(aInfo)));
pShapeOrders->push_back( new SvxMSDffShapeOrder( aInfo.nShapeId ) );
}
@@ -6367,11 +6388,12 @@ sal_Bool SvxMSDffManager::GetShapeContainerData( SvStream& rSt,
sal_Bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*& rpShape,
SvxMSDffImportData& rData)
{
- SvxMSDffShapeInfo aTmpRec(0, nId);
- aTmpRec.bSortByShapeId = sal_True;
+ ::boost::shared_ptr<SvxMSDffShapeInfo> const pTmpRec(
+ new SvxMSDffShapeInfo(0, nId));
- SvxMSDffShapeInfos::const_iterator it = pShapeInfos->find( &aTmpRec );
- if( it != pShapeInfos->end() )
+ SvxMSDffShapeInfos_ById::const_iterator const it =
+ m_pShapeInfosById->find(pTmpRec);
+ if (it != m_pShapeInfosById->end())
{
// eventuell altes Errorflag loeschen
if( rStCtrl.GetError() )