Kaydet (Commit) d707d025 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Michael Stahl

fdo#75757: remove inheritance to std::vector

from ParagraphObj, by using boost::ptr_vector.

This is also a supposed fix for ParagraphObj::operator=(),
because ParagraphObj::ImplClear() now makes the vector empty
while its original code kept deleted pointers.

Change-Id: I7710eb33fc05bed55474ff00baaeb8e19cd79f3d
Reviewed-on: https://gerrit.libreoffice.org/11379Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 997d1387
...@@ -648,7 +648,10 @@ PortionObj& PortionObj::operator=( const PortionObj& rPortionObj ) ...@@ -648,7 +648,10 @@ PortionObj& PortionObj::operator=( const PortionObj& rPortionObj )
ParagraphObj::ParagraphObj(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet, ParagraphObj::ParagraphObj(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
PPTExBulletProvider& rProv) PPTExBulletProvider& rProv)
: maMapModeSrc(MAP_100TH_MM) : PropStateValue()
, SOParagraph()
, mvPortions()
, maMapModeSrc(MAP_100TH_MM)
, maMapModeDest(MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 )) , maMapModeDest(MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ))
, mnTextSize(0) , mnTextSize(0)
, mbFirstParagraph(false) , mbFirstParagraph(false)
...@@ -675,7 +678,10 @@ ParagraphObj::ParagraphObj(const ::com::sun::star::uno::Reference< ::com::sun::s ...@@ -675,7 +678,10 @@ ParagraphObj::ParagraphObj(const ::com::sun::star::uno::Reference< ::com::sun::s
ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & rXTextContent, ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & rXTextContent,
ParaFlags aParaFlags, FontCollection& rFontCollection, PPTExBulletProvider& rProv ) ParaFlags aParaFlags, FontCollection& rFontCollection, PPTExBulletProvider& rProv )
: maMapModeSrc(MAP_100TH_MM) : PropStateValue()
, SOParagraph()
, mvPortions()
, maMapModeSrc(MAP_100TH_MM)
, maMapModeDest(MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 )) , maMapModeDest(MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ))
, mnTextSize(0) , mnTextSize(0)
, mbIsBullet(false) , mbIsBullet(false)
...@@ -730,7 +736,7 @@ ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::t ...@@ -730,7 +736,7 @@ ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::t
{ {
PortionObj* pPortionObj = new PortionObj( aXCursorText, !aXTextPortionE->hasMoreElements(), rFontCollection ); PortionObj* pPortionObj = new PortionObj( aXCursorText, !aXTextPortionE->hasMoreElements(), rFontCollection );
if ( pPortionObj->Count() ) if ( pPortionObj->Count() )
push_back( pPortionObj ); mvPortions.push_back( pPortionObj );
else else
delete pPortionObj; delete pPortionObj;
} }
...@@ -742,9 +748,9 @@ ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::t ...@@ -742,9 +748,9 @@ ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::t
} }
ParagraphObj::ParagraphObj( const ParagraphObj& rObj ) ParagraphObj::ParagraphObj( const ParagraphObj& rObj )
: std::vector<PortionObj*>() : PropStateValue()
, PropStateValue()
, SOParagraph() , SOParagraph()
, mvPortions()
{ {
ImplConstruct( rObj ); ImplConstruct( rObj );
} }
...@@ -756,14 +762,13 @@ ParagraphObj::~ParagraphObj() ...@@ -756,14 +762,13 @@ ParagraphObj::~ParagraphObj()
void ParagraphObj::Write( SvStream* pStrm ) void ParagraphObj::Write( SvStream* pStrm )
{ {
for ( const_iterator it = begin(); it != end(); ++it ) for ( boost::ptr_vector<PortionObj>::iterator it = mvPortions.begin(); it != mvPortions.end(); ++it )
(*it)->Write( pStrm, mbLastParagraph ); it->Write( pStrm, mbLastParagraph );
} }
void ParagraphObj::ImplClear() void ParagraphObj::ImplClear()
{ {
for ( const_iterator it = begin(); it != end(); ++it ) mvPortions.clear();
delete *it;
} }
void ParagraphObj::CalculateGraphicBulletSize( sal_uInt16 nFontHeight ) void ParagraphObj::CalculateGraphicBulletSize( sal_uInt16 nFontHeight )
...@@ -922,8 +927,7 @@ void ParagraphObj::ImplGetNumberingLevel( PPTExBulletProvider& rBuProv, sal_Int1 ...@@ -922,8 +927,7 @@ void ParagraphObj::ImplGetNumberingLevel( PPTExBulletProvider& rBuProv, sal_Int1
} }
} }
PortionObj* pPortion = front(); CalculateGraphicBulletSize( ( mvPortions.empty() ) ? 24 : mvPortions.front().mnCharHeight );
CalculateGraphicBulletSize( ( pPortion ) ? pPortion->mnCharHeight : 24 );
switch( nNumberingType ) switch( nNumberingType )
{ {
...@@ -1235,8 +1239,8 @@ void ParagraphObj::ImplConstruct( const ParagraphObj& rParagraphObj ) ...@@ -1235,8 +1239,8 @@ void ParagraphObj::ImplConstruct( const ParagraphObj& rParagraphObj )
mbForbiddenRules = rParagraphObj.mbForbiddenRules; mbForbiddenRules = rParagraphObj.mbForbiddenRules;
mnBiDi = rParagraphObj.mnBiDi; mnBiDi = rParagraphObj.mnBiDi;
for ( ParagraphObj::const_iterator it = rParagraphObj.begin(); it != rParagraphObj.end(); ++it ) for ( boost::ptr_vector<PortionObj>::const_iterator it = rParagraphObj.begin(); it != rParagraphObj.end(); ++it )
push_back( new PortionObj( **it ) ); mvPortions.push_back( new PortionObj( *it ) );
maTabStop = rParagraphObj.maTabStop; maTabStop = rParagraphObj.maTabStop;
bExtendedParameters = rParagraphObj.bExtendedParameters; bExtendedParameters = rParagraphObj.bExtendedParameters;
...@@ -1264,8 +1268,8 @@ void ParagraphObj::ImplConstruct( const ParagraphObj& rParagraphObj ) ...@@ -1264,8 +1268,8 @@ void ParagraphObj::ImplConstruct( const ParagraphObj& rParagraphObj )
sal_uInt32 ParagraphObj::ImplCalculateTextPositions( sal_uInt32 nCurrentTextPosition ) sal_uInt32 ParagraphObj::ImplCalculateTextPositions( sal_uInt32 nCurrentTextPosition )
{ {
mnTextSize = 0; mnTextSize = 0;
for ( const_iterator it = begin(); it != end(); ++it ) for ( boost::ptr_vector<PortionObj>::iterator it = mvPortions.begin(); it != mvPortions.end(); ++it )
mnTextSize += (*it)->ImplCalculateTextPositions( nCurrentTextPosition + mnTextSize ); mnTextSize += it->ImplCalculateTextPositions( nCurrentTextPosition + mnTextSize );
return mnTextSize; return mnTextSize;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/lang/Locale.hpp>
#include <editeng/svxenum.hxx> #include <editeng/svxenum.hxx>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
...@@ -172,11 +172,12 @@ struct ParaFlags ...@@ -172,11 +172,12 @@ struct ParaFlags
ParaFlags() { bFirstParagraph = true; bLastParagraph = false; }; ParaFlags() { bFirstParagraph = true; bLastParagraph = false; };
}; };
class ParagraphObj : public std::vector<PortionObj*>, public PropStateValue, public SOParagraph class ParagraphObj : public PropStateValue, public SOParagraph
{ {
friend class TextObj; friend class TextObj;
friend struct PPTExParaSheet; friend struct PPTExParaSheet;
boost::ptr_vector<PortionObj> mvPortions;
MapMode maMapModeSrc; MapMode maMapModeSrc;
MapMode maMapModeDest; MapMode maMapModeDest;
...@@ -223,6 +224,13 @@ class ParagraphObj : public std::vector<PortionObj*>, public PropStateValue, pub ...@@ -223,6 +224,13 @@ class ParagraphObj : public std::vector<PortionObj*>, public PropStateValue, pub
ParagraphObj( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSetRef, ParagraphObj( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSetRef,
PPTExBulletProvider& rBuProv ); PPTExBulletProvider& rBuProv );
bool empty() const { return mvPortions.empty(); }
const PortionObj& front() const { return mvPortions.front(); }
boost::ptr_vector<PortionObj>::const_iterator begin() const { return mvPortions.begin(); }
boost::ptr_vector<PortionObj>::const_iterator end() const { return mvPortions.end(); }
void CalculateGraphicBulletSize( sal_uInt16 nFontHeight ); void CalculateGraphicBulletSize( sal_uInt16 nFontHeight );
~ParagraphObj(); ~ParagraphObj();
......
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