Kaydet (Commit) 7ea14056 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) David Tardon

fdo#75757: remove inheritance to std::vector

from FontPortionModelList.

Change-Id: Ice34808107a7b381e39d5f7d164590b48a630ee0
Reviewed-on: https://gerrit.libreoffice.org/11229Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst a4b9bfb9
...@@ -111,10 +111,25 @@ struct FontPortionModel ...@@ -111,10 +111,25 @@ struct FontPortionModel
}; };
/** A vector with all font portions in a rich-string. */ /** A vector with all font portions in a rich-string. */
class FontPortionModelList : public ::std::vector< FontPortionModel > class FontPortionModelList {
{ ::std::vector< FontPortionModel > mvModels;
public: public:
inline explicit FontPortionModelList() {} inline explicit FontPortionModelList() : mvModels() {}
bool empty() const { return mvModels.empty(); }
const FontPortionModel& back() const { return mvModels.back(); }
const FontPortionModel& front() const { return mvModels.front(); }
void push_back(const FontPortionModel& rModel) { mvModels.push_back(rModel); }
void insert(::std::vector< FontPortionModel >::iterator it,
const FontPortionModel& rModel)
{ mvModels.insert(it, rModel); }
::std::vector< FontPortionModel >::const_iterator begin() const { return mvModels.begin(); }
::std::vector< FontPortionModel >::iterator begin() { return mvModels.begin(); }
/** Appends a rich-string font identifier. */ /** Appends a rich-string font identifier. */
void appendPortion( const FontPortionModel& rPortion ); void appendPortion( const FontPortionModel& rPortion );
......
...@@ -165,20 +165,20 @@ void FontPortionModel::read( SequenceInputStream& rStrm ) ...@@ -165,20 +165,20 @@ void FontPortionModel::read( SequenceInputStream& rStrm )
void FontPortionModelList::appendPortion( const FontPortionModel& rPortion ) void FontPortionModelList::appendPortion( const FontPortionModel& rPortion )
{ {
// #i33341# real life -- same character index may occur several times // #i33341# real life -- same character index may occur several times
OSL_ENSURE( empty() || (back().mnPos <= rPortion.mnPos), "FontPortionModelList::appendPortion - wrong char order" ); OSL_ENSURE( mvModels.empty() || (mvModels.back().mnPos <= rPortion.mnPos), "FontPortionModelList::appendPortion - wrong char order" );
if( empty() || (back().mnPos < rPortion.mnPos) ) if( mvModels.empty() || (mvModels.back().mnPos < rPortion.mnPos) )
push_back( rPortion ); mvModels.push_back( rPortion );
else else
back().mnFontId = rPortion.mnFontId; mvModels.back().mnFontId = rPortion.mnFontId;
} }
void FontPortionModelList::importPortions( SequenceInputStream& rStrm ) void FontPortionModelList::importPortions( SequenceInputStream& rStrm )
{ {
sal_Int32 nCount = rStrm.readInt32(); sal_Int32 nCount = rStrm.readInt32();
clear(); mvModels.clear();
if( nCount > 0 ) if( nCount > 0 )
{ {
reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 4 ) ); mvModels.reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 4 ) );
/* #i33341# real life -- same character index may occur several times /* #i33341# real life -- same character index may occur several times
-> use appendPortion() to validate string position. */ -> use appendPortion() to validate string position. */
FontPortionModel aPortion; FontPortionModel aPortion;
...@@ -443,7 +443,7 @@ void RichString::createTextPortions( const OUString& rText, FontPortionModelList ...@@ -443,7 +443,7 @@ void RichString::createTextPortions( const OUString& rText, FontPortionModelList
rPortions.push_back( FontPortionModel( nStrLen, -1 ) ); rPortions.push_back( FontPortionModel( nStrLen, -1 ) );
// create all string portions according to the font id vector // create all string portions according to the font id vector
for( FontPortionModelList::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt ) for( ::std::vector< FontPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
{ {
sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos; sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) ) if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
......
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