diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2016-07-26 18:01:59 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-07-26 15:35:43 +0000 |
commit | d357334a0237bda6d9c090990d44e46c6af8edf3 (patch) | |
tree | 10078f18bf7d533d08fe1574633a9d3cee1460a0 | |
parent | adf874c7cc21aedd29286d2ca860b4fd201f87d2 (diff) |
tdf#75757 Remove inheritance to std::vector
Change-Id: I2ddaaf52f27b5297bda58a045946e87a24b66a83
Reviewed-on: https://gerrit.libreoffice.org/27536
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/edit/textdat2.hxx | 17 | ||||
-rw-r--r-- | vcl/source/edit/textdata.cxx | 71 |
2 files changed, 77 insertions, 11 deletions
diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx index 6a09fa8e4fac..9b0dc4c1d26c 100644 --- a/vcl/source/edit/textdat2.hxx +++ b/vcl/source/edit/textdat2.hxx @@ -67,12 +67,27 @@ public: bool IsRightToLeft() const { return bRightToLeft; } }; -class TETextPortionList : public std::vector<TETextPortion*> +class TETextPortionList { +private: + std::vector<TETextPortion*> maPortions; + public: TETextPortionList(); ~TETextPortionList(); + TETextPortion* operator[]( size_t nPos ); + std::vector<TETextPortion*>::iterator begin(); + std::vector<TETextPortion*>::const_iterator begin() const; + std::vector<TETextPortion*>::iterator end(); + std::vector<TETextPortion*>::const_iterator end() const; + bool empty() const; + size_t size() const; + std::vector<TETextPortion*>::iterator erase( std::vector<TETextPortion*>::iterator aIter ); + std::vector<TETextPortion*>::iterator insert( std::vector<TETextPortion*>::iterator aIter, + TETextPortion* pTP ); + void push_back( TETextPortion* pTP ); + void Reset(); sal_uInt16 FindPortion( sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false ); void DeleteFromPortion( sal_uInt16 nDelFrom ); diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index 02897052dcbf..cc7e79a4a87e 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -55,33 +55,84 @@ TETextPortionList::~TETextPortionList() Reset(); } +TETextPortion* TETextPortionList::operator[]( size_t nPos ) +{ + return maPortions[ nPos ]; +} + +std::vector<TETextPortion*>::iterator TETextPortionList::begin() +{ + return maPortions.begin(); +} + +std::vector<TETextPortion*>::const_iterator TETextPortionList::begin() const +{ + return maPortions.begin(); +} + +std::vector<TETextPortion*>::iterator TETextPortionList::end() +{ + return maPortions.end(); +} + +std::vector<TETextPortion*>::const_iterator TETextPortionList::end() const +{ + return maPortions.end(); +} + +bool TETextPortionList::empty() const +{ + return maPortions.empty(); +} + +size_t TETextPortionList::size() const +{ + return maPortions.size(); +} + +std::vector<TETextPortion*>::iterator TETextPortionList::erase( std::vector<TETextPortion*>::iterator aIter ) +{ + return maPortions.erase( aIter ); +} + +std::vector<TETextPortion*>::iterator TETextPortionList::insert( std::vector<TETextPortion*>::iterator aIter, + TETextPortion* pTP ) +{ + return maPortions.insert( aIter, pTP ); +} + +void TETextPortionList::push_back( TETextPortion* pTP ) +{ + maPortions.push_back( pTP ); +} + void TETextPortionList::Reset() { - for ( iterator it = begin(); it != end(); ++it ) - delete *it; - clear(); + for ( auto pTP : maPortions ) + delete pTP; + maPortions.clear(); } void TETextPortionList::DeleteFromPortion( sal_uInt16 nDelFrom ) { - SAL_WARN_IF( ( nDelFrom >= size() ) && ( (nDelFrom != 0) || (size() != 0) ), "vcl", "DeleteFromPortion: Out of range" ); - for ( iterator it = begin() + nDelFrom; it != end(); ++it ) + SAL_WARN_IF( ( nDelFrom >= maPortions.size() ) && ( (nDelFrom != 0) || (maPortions.size() != 0) ), "vcl", "DeleteFromPortion: Out of range" ); + for ( auto it = maPortions.begin() + nDelFrom; it != maPortions.end(); ++it ) delete *it; - erase( begin() + nDelFrom, end() ); + maPortions.erase( maPortions.begin() + nDelFrom, maPortions.end() ); } sal_uInt16 TETextPortionList::FindPortion( sal_Int32 nCharPos, sal_Int32& nPortionStart, bool bPreferStartingPortion ) { // find left portion at nCharPos at portion border sal_Int32 nTmpPos = 0; - for ( size_t nPortion = 0; nPortion < size(); nPortion++ ) + for ( size_t nPortion = 0; nPortion < maPortions.size(); nPortion++ ) { - TETextPortion* pPortion = operator[]( nPortion ); + TETextPortion* pPortion = maPortions[ nPortion ]; nTmpPos += pPortion->GetLen(); if ( nTmpPos >= nCharPos ) { // take this one if we don't prefer the starting portion, or if it's the last one - if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == size() - 1 ) ) + if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == maPortions.size() - 1 ) ) { nPortionStart = nTmpPos - pPortion->GetLen(); return nPortion; @@ -89,7 +140,7 @@ sal_uInt16 TETextPortionList::FindPortion( sal_Int32 nCharPos, sal_Int32& nPorti } } OSL_FAIL( "FindPortion: Nicht gefunden!" ); - return ( size() - 1 ); + return ( maPortions.size() - 1 ); } TEParaPortion::TEParaPortion( TextNode* pN ) |