diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-09-01 23:08:37 +0900 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-09-02 06:10:14 -0500 |
commit | 7ea14056cb508b6035704e1124c9301fecb0c792 (patch) | |
tree | 7ec480bbb71d389838b834e8649f6917dbce0a7e | |
parent | a4b9bfb993e9d724431befd1295b107f7758c8fd (diff) |
fdo#75757: remove inheritance to std::vector
from FontPortionModelList.
Change-Id: Ice34808107a7b381e39d5f7d164590b48a630ee0
Reviewed-on: https://gerrit.libreoffice.org/11229
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
-rw-r--r-- | sc/source/filter/inc/richstring.hxx | 21 | ||||
-rw-r--r-- | sc/source/filter/oox/richstring.cxx | 14 |
2 files changed, 25 insertions, 10 deletions
diff --git a/sc/source/filter/inc/richstring.hxx b/sc/source/filter/inc/richstring.hxx index 645a3354b2d4..229dd6f1cbab 100644 --- a/sc/source/filter/inc/richstring.hxx +++ b/sc/source/filter/inc/richstring.hxx @@ -111,10 +111,25 @@ struct FontPortionModel }; /** A vector with all font portions in a rich-string. */ -class FontPortionModelList : public ::std::vector< FontPortionModel > -{ +class FontPortionModelList { + ::std::vector< FontPortionModel > mvModels; + 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. */ void appendPortion( const FontPortionModel& rPortion ); diff --git a/sc/source/filter/oox/richstring.cxx b/sc/source/filter/oox/richstring.cxx index b3c3b29ec961..4cbc6eb24b79 100644 --- a/sc/source/filter/oox/richstring.cxx +++ b/sc/source/filter/oox/richstring.cxx @@ -165,20 +165,20 @@ void FontPortionModel::read( SequenceInputStream& rStrm ) void FontPortionModelList::appendPortion( const FontPortionModel& rPortion ) { // #i33341# real life -- same character index may occur several times - OSL_ENSURE( empty() || (back().mnPos <= rPortion.mnPos), "FontPortionModelList::appendPortion - wrong char order" ); - if( empty() || (back().mnPos < rPortion.mnPos) ) - push_back( rPortion ); + OSL_ENSURE( mvModels.empty() || (mvModels.back().mnPos <= rPortion.mnPos), "FontPortionModelList::appendPortion - wrong char order" ); + if( mvModels.empty() || (mvModels.back().mnPos < rPortion.mnPos) ) + mvModels.push_back( rPortion ); else - back().mnFontId = rPortion.mnFontId; + mvModels.back().mnFontId = rPortion.mnFontId; } void FontPortionModelList::importPortions( SequenceInputStream& rStrm ) { sal_Int32 nCount = rStrm.readInt32(); - clear(); + mvModels.clear(); 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 -> use appendPortion() to validate string position. */ FontPortionModel aPortion; @@ -443,7 +443,7 @@ void RichString::createTextPortions( const OUString& rText, FontPortionModelList rPortions.push_back( FontPortionModel( nStrLen, -1 ) ); // 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; if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) ) |