[Libreoffice-commits] core.git: sc/source

Takeshi Abe tabe at fixedpoint.jp
Tue Sep 2 04:10:38 PDT 2014


 sc/source/filter/inc/richstring.hxx |   21 ++++++++++++++++++---
 sc/source/filter/oox/richstring.cxx |   14 +++++++-------
 2 files changed, 25 insertions(+), 10 deletions(-)

New commits:
commit 7ea14056cb508b6035704e1124c9301fecb0c792
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Sep 1 23:08:37 2014 +0900

    fdo#75757: remove inheritance to std::vector
    
    from FontPortionModelList.
    
    Change-Id: Ice34808107a7b381e39d5f7d164590b48a630ee0
    Reviewed-on: https://gerrit.libreoffice.org/11229
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/sc/source/filter/inc/richstring.hxx b/sc/source/filter/inc/richstring.hxx
index 645a335..229dd6f 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 b3c3b29..4cbc6eb 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) )


More information about the Libreoffice-commits mailing list