Kaydet (Commit) a685de59 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Caolán McNamara

fdo#75757: remove inheritance to std::vector

from ApiCellRangeList.

Change-Id: I29913e0e437c112640b08187f8bea6b1f0f1c17c
Reviewed-on: https://gerrit.libreoffice.org/11349Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 62c0ff12
...@@ -32,14 +32,55 @@ class BiffInputStream; ...@@ -32,14 +32,55 @@ class BiffInputStream;
/** A vector of com.sun.star.table.CellRangeAddress elements and additional /** A vector of com.sun.star.table.CellRangeAddress elements and additional
functionality. */ functionality. */
class ApiCellRangeList : public ::std::vector< ::com::sun::star::table::CellRangeAddress > class ApiCellRangeList
{ {
public: public:
inline explicit ApiCellRangeList() {} inline explicit ApiCellRangeList() : mvAddresses() {}
size_t size() const { return mvAddresses.size(); }
bool empty() const { return mvAddresses.empty(); }
const ::com::sun::star::table::CellRangeAddress& front() const
{ return mvAddresses.front(); }
::com::sun::star::table::CellRangeAddress& operator[]( size_t i )
{ return mvAddresses[ i ]; }
::std::vector< ::com::sun::star::table::CellRangeAddress >::const_iterator begin() const
{ return mvAddresses.begin(); }
::std::vector< ::com::sun::star::table::CellRangeAddress >::iterator begin()
{ return mvAddresses.begin(); }
::std::vector< ::com::sun::star::table::CellRangeAddress >::const_iterator end() const
{ return mvAddresses.end(); }
::std::vector< ::com::sun::star::table::CellRangeAddress >::reverse_iterator rbegin()
{ return mvAddresses.rbegin(); }
::std::vector< ::com::sun::star::table::CellRangeAddress >::reverse_iterator rend()
{ return mvAddresses.rend(); }
void clear() { mvAddresses.clear(); }
void erase( ::std::vector< ::com::sun::star::table::CellRangeAddress >::iterator it )
{ mvAddresses.erase( it ); }
void pop_back() { mvAddresses.pop_back(); }
void push_back( const ::com::sun::star::table::CellRangeAddress& rAddress )
{ mvAddresses.push_back( rAddress ); }
/** Returns the base address of this range list (top-left cell of first range). */ /** Returns the base address of this range list (top-left cell of first range). */
::com::sun::star::table::CellAddress ::com::sun::star::table::CellAddress
getBaseAddress() const; getBaseAddress() const;
/** Converts to a sequence. */
com::sun::star::uno::Sequence< ::com::sun::star::table::CellRangeAddress >
toSequence() const;
private:
::std::vector< ::com::sun::star::table::CellRangeAddress > mvAddresses;
}; };
/** A 2D cell address struct for binary filters. */ /** A 2D cell address struct for binary filters. */
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <oox/core/filterbase.hxx> #include <oox/core/filterbase.hxx>
#include <oox/helper/containerhelper.hxx>
#include "biffinputstream.hxx" #include "biffinputstream.hxx"
namespace oox { namespace oox {
...@@ -69,9 +70,14 @@ const sal_Int16 BIFF8_MAXTAB = BIFF5_MAXTAB; ...@@ -69,9 +70,14 @@ const sal_Int16 BIFF8_MAXTAB = BIFF5_MAXTAB;
CellAddress ApiCellRangeList::getBaseAddress() const CellAddress ApiCellRangeList::getBaseAddress() const
{ {
if( empty() ) if( mvAddresses.empty() )
return CellAddress(); return CellAddress();
return CellAddress( front().Sheet, front().StartColumn, front().StartRow ); return CellAddress( mvAddresses.front().Sheet, mvAddresses.front().StartColumn, mvAddresses.front().StartRow );
}
com::sun::star::uno::Sequence< CellRangeAddress > ApiCellRangeList::toSequence() const
{
return ContainerHelper::vectorToSequence( mvAddresses );
} }
void BinAddress::read( SequenceInputStream& rStrm ) void BinAddress::read( SequenceInputStream& rStrm )
......
...@@ -987,7 +987,7 @@ void CondFormat::finalizeImport() ...@@ -987,7 +987,7 @@ void CondFormat::finalizeImport()
sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab); sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab);
ScRangeList aList; ScRangeList aList;
for( ApiCellRangeList::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr) for( ::std::vector< CellRangeAddress >::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr)
{ {
ScRange aRange; ScRange aRange;
ScUnoConversion::FillScRange(aRange, *itr); ScUnoConversion::FillScRange(aRange, *itr);
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <com/sun/star/sheet/XPrintAreas.hpp> #include <com/sun/star/sheet/XPrintAreas.hpp>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <oox/helper/attributelist.hxx> #include <oox/helper/attributelist.hxx>
#include <oox/helper/containerhelper.hxx>
#include <oox/helper/propertyset.hxx> #include <oox/helper/propertyset.hxx>
#include "addressconverter.hxx" #include "addressconverter.hxx"
#include "biffinputstream.hxx" #include "biffinputstream.hxx"
...@@ -406,7 +405,7 @@ void DefinedName::convertFormula() ...@@ -406,7 +405,7 @@ void DefinedName::convertFormula()
ApiCellRangeList aPrintRanges; ApiCellRangeList aPrintRanges;
getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, false, mnCalcSheet ); getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, false, mnCalcSheet );
if( xPrintAreas.is() && !aPrintRanges.empty() ) if( xPrintAreas.is() && !aPrintRanges.empty() )
xPrintAreas->setPrintAreas( ContainerHelper::vectorToSequence( aPrintRanges ) ); xPrintAreas->setPrintAreas( aPrintRanges.toSequence() );
} }
break; break;
case BIFF_DEFNAME_PRINTTITLES: case BIFF_DEFNAME_PRINTTITLES:
...@@ -419,7 +418,7 @@ void DefinedName::convertFormula() ...@@ -419,7 +418,7 @@ void DefinedName::convertFormula()
bool bHasRowTitles = false; bool bHasRowTitles = false;
bool bHasColTitles = false; bool bHasColTitles = false;
const CellAddress& rMaxPos = getAddressConverter().getMaxAddress(); const CellAddress& rMaxPos = getAddressConverter().getMaxAddress();
for( ApiCellRangeList::const_iterator aIt = aTitleRanges.begin(), aEnd = aTitleRanges.end(); (aIt != aEnd) && (!bHasRowTitles || !bHasColTitles); ++aIt ) for( ::std::vector< CellRangeAddress >::const_iterator aIt = aTitleRanges.begin(), aEnd = aTitleRanges.end(); (aIt != aEnd) && (!bHasRowTitles || !bHasColTitles); ++aIt )
{ {
bool bFullRow = (aIt->StartColumn == 0) && (aIt->EndColumn >= rMaxPos.Column); bool bFullRow = (aIt->StartColumn == 0) && (aIt->EndColumn >= rMaxPos.Column);
bool bFullCol = (aIt->StartRow == 0) && (aIt->EndRow >= rMaxPos.Row); bool bFullCol = (aIt->StartRow == 0) && (aIt->EndRow >= rMaxPos.Row);
......
...@@ -342,7 +342,7 @@ void addIfNotInMyMap( StylesBuffer& rStyles, std::map< std::pair< sal_Int32, sal ...@@ -342,7 +342,7 @@ void addIfNotInMyMap( StylesBuffer& rStyles, std::map< std::pair< sal_Int32, sal
{ {
// add ranges from the rangelist to the existing rangelist for the // add ranges from the rangelist to the existing rangelist for the
// matching style ( should we check if they overlap ? ) // matching style ( should we check if they overlap ? )
for ( ApiCellRangeList::const_iterator iter = rRangeList.begin(), iter_end = rRangeList.end(); iter != iter_end; ++iter ) for ( ::std::vector< CellRangeAddress >::const_iterator iter = rRangeList.begin(), iter_end = rRangeList.end(); iter != iter_end; ++iter )
it->second.push_back( *iter ); it->second.push_back( *iter );
return; return;
} }
...@@ -437,7 +437,7 @@ void SheetDataBuffer::finalizeImport() ...@@ -437,7 +437,7 @@ void SheetDataBuffer::finalizeImport()
for ( std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList >::iterator it = rangeStyleListMap.begin(), it_end = rangeStyleListMap.end(); it != it_end; ++it ) for ( std::map< std::pair< sal_Int32, sal_Int32 >, ApiCellRangeList >::iterator it = rangeStyleListMap.begin(), it_end = rangeStyleListMap.end(); it != it_end; ++it )
{ {
const ApiCellRangeList& rRanges( it->second ); const ApiCellRangeList& rRanges( it->second );
for ( ApiCellRangeList::const_iterator it_range = rRanges.begin(), it_rangeend = rRanges.end(); it_range!=it_rangeend; ++it_range ) for ( ::std::vector< CellRangeAddress >::const_iterator it_range = rRanges.begin(), it_rangeend = rRanges.end(); it_range!=it_rangeend; ++it_range )
addColXfStyle( it->first.first, it->first.second, *it_range ); addColXfStyle( it->first.first, it->first.second, *it_range );
} }
...@@ -652,8 +652,8 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI ...@@ -652,8 +652,8 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI
{ {
if( (rModel.mnXfId >= 0) || (nNumFmtId >= 0) ) if( (rModel.mnXfId >= 0) || (nNumFmtId >= 0) )
{ {
ApiCellRangeList::reverse_iterator aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); ::std::vector< CellRangeAddress >::reverse_iterator aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin();
ApiCellRangeList::reverse_iterator aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); ::std::vector< CellRangeAddress >::reverse_iterator aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend();
/* The xlsx sheet data contains row wise information. /* The xlsx sheet data contains row wise information.
* It is sufficient to check if the row range size is one * It is sufficient to check if the row range size is one
*/ */
...@@ -674,7 +674,7 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI ...@@ -674,7 +674,7 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI
aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin();
aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend();
ApiCellRangeList::reverse_iterator aItM = aIt+1; ::std::vector< CellRangeAddress >::reverse_iterator aItM = aIt+1;
while( aItM != aItEnd ) while( aItM != aItEnd )
{ {
if( aIt->Sheet == aItM->Sheet ) if( aIt->Sheet == aItM->Sheet )
......
...@@ -500,7 +500,7 @@ Reference< XSheetCellRanges > WorksheetGlobals::getCellRangeList( const ApiCellR ...@@ -500,7 +500,7 @@ Reference< XSheetCellRanges > WorksheetGlobals::getCellRangeList( const ApiCellR
{ {
xRanges.set( getBaseFilter().getModelFactory()->createInstance( maSheetCellRanges ), UNO_QUERY_THROW ); xRanges.set( getBaseFilter().getModelFactory()->createInstance( maSheetCellRanges ), UNO_QUERY_THROW );
Reference< XSheetCellRangeContainer > xRangeCont( xRanges, UNO_QUERY_THROW ); Reference< XSheetCellRangeContainer > xRangeCont( xRanges, UNO_QUERY_THROW );
xRangeCont->addRangeAddresses( ContainerHelper::vectorToSequence( rRanges ), sal_False ); xRangeCont->addRangeAddresses( rRanges.toSequence(), sal_False );
} }
catch( Exception& ) catch( Exception& )
{ {
......
...@@ -160,7 +160,7 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs ) ...@@ -160,7 +160,7 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs )
if (!aRangeList.empty()) if (!aRangeList.empty())
{ {
ScRangeList* pRangeList = aProt.maRangeList = new ScRangeList; ScRangeList* pRangeList = aProt.maRangeList = new ScRangeList;
for (ApiCellRangeList::const_iterator itr( aRangeList.begin()), end( aRangeList.end()); itr != end; ++itr) for (::std::vector< ::com::sun::star::table::CellRangeAddress >::const_iterator itr( aRangeList.begin()), end( aRangeList.end()); itr != end; ++itr)
{ {
ScRange aRange; ScRange aRange;
ScUnoConversion::FillScRange( aRange, *itr); ScUnoConversion::FillScRange( aRange, *itr);
......
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