diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-03-31 09:43:49 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-03-31 09:44:45 +0200 |
commit | 6f455018b4b4a52314c837b50a40e653866628ce (patch) | |
tree | 6b178d56c974e142c34c7ada4ea81bb08bdb43ee | |
parent | e75f8d8e059bc293625dfa34e15b68eb6d820ac4 (diff) |
sc: clean-up address.hxx/cxx
Change-Id: Iea3d90fb22631b48b25836b73a8dad7bd979a58e
-rw-r--r-- | sc/inc/address.hxx | 567 | ||||
-rw-r--r-- | sc/source/core/tool/address.cxx | 332 |
2 files changed, 513 insertions, 386 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index 3c08c60a638d..1c03aa3c6fc5 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -202,14 +202,12 @@ inline SCTAB SanitizeTab( SCTAB nTab, SCTAB nMaxTab ) #define SCA_VALID_TAB2 0x4000 #define SCA_VALID 0x8000 -#define SCA_ABS SCA_VALID \ - | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE +#define SCA_ABS SCA_VALID | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE -#define SCR_ABS SCA_ABS \ - | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE +#define SCR_ABS SCA_ABS | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE -#define SCA_ABS_3D SCA_ABS | SCA_TAB_3D -#define SCR_ABS_3D SCR_ABS | SCA_TAB_3D +#define SCA_ABS_3D SCA_ABS | SCA_TAB_3D +#define SCR_ABS_3D SCR_ABS | SCA_TAB_3D // ScAddress class ScAddress @@ -224,19 +222,21 @@ public: enum Uninitialized { UNINITIALIZED }; enum InitializeInvalid { INITIALIZE_INVALID }; - struct Details { + struct Details + { formula::FormulaGrammar::AddressConvention eConv; SCROW nRow; SCCOL nCol; - inline Details( formula::FormulaGrammar::AddressConvention eConvP, SCROW nRowP, SCCOL nColP ) - : eConv( eConvP ), nRow( nRowP ), nCol( nColP ) - {} - inline Details( formula::FormulaGrammar::AddressConvention eConvP, ScAddress const & rAddr ) - : eConv( eConvP ), nRow( rAddr.Row() ), nCol( rAddr.Col() ) - {} - inline Details( formula::FormulaGrammar::AddressConvention eConvP) - : eConv( eConvP ), nRow( 0 ), nCol( 0 ) - {} + + inline Details( formula::FormulaGrammar::AddressConvention eConvP, SCROW nRowP, SCCOL nColP ) : + eConv(eConvP), nRow(nRowP), nCol(nColP) + {} + inline Details( formula::FormulaGrammar::AddressConvention eConvP, ScAddress const & rAddr ) : + eConv(eConvP), nRow(rAddr.Row()), nCol(rAddr.Col()) + {} + inline Details( formula::FormulaGrammar::AddressConvention eConvP) : + eConv(eConvP), nRow(0), nCol(0) + {} /* Use the formula::FormulaGrammar::AddressConvention associated with rAddr::Tab() */ Details( const ScDocument* pDoc, const ScAddress & rAddr ); }; @@ -244,86 +244,138 @@ public: struct ExternalInfo { - OUString maTabName; + OUString maTabName; sal_uInt16 mnFileId; bool mbExternal; - inline ExternalInfo() : mnFileId(0), mbExternal(false) {} + inline ExternalInfo() : + mnFileId(0), mbExternal(false) + {} }; - inline ScAddress() : nRow(0), nCol(0), nTab(0) {} - inline ScAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) - : nRow(nRowP), nCol(nColP), nTab(nTabP) - {} + inline ScAddress() : + nRow(0), nCol(0), nTab(0) + {} + inline ScAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) : + nRow(nRowP), nCol(nColP), nTab(nTabP) + {} /** Yes, it is what it seems to be: Uninitialized. May be used for performance reasons if it is initialized by other means. */ - inline ScAddress( Uninitialized ) {} - inline ScAddress( InitializeInvalid ) - : nRow(-1), nCol(-1), nTab(-1) {} - inline ScAddress( const ScAddress& r ) - : nRow(r.nRow), nCol(r.nCol), nTab(r.nTab) - {} - inline ScAddress& operator=( const ScAddress& r ); + inline ScAddress( Uninitialized ) + {} + inline ScAddress( InitializeInvalid ) : + nRow(-1), nCol(-1), nTab(-1) + {} + inline ScAddress( const ScAddress& rAddress ) : + nRow(rAddress.nRow), nCol(rAddress.nCol), nTab(rAddress.nTab) + {} + inline ScAddress& operator=( const ScAddress& rAddress ); inline void Set( SCCOL nCol, SCROW nRow, SCTAB nTab ); - inline SCROW Row() const { return nRow; } - inline SCCOL Col() const { return nCol; } - inline SCTAB Tab() const { return nTab; } - inline void SetRow( SCROW nRowP ) { nRow = nRowP; } - inline void SetCol( SCCOL nColP ) { nCol = nColP; } - inline void SetTab( SCTAB nTabP ) { nTab = nTabP; } - inline void SetInvalid() { nRow = -1; nCol = -1; nTab = -1; } - inline bool IsValid() const { return (nRow >= 0) && (nCol >= 0) && (nTab >= 0); } - inline void PutInOrder( ScAddress& r ); - inline void IncRow( SCsROW n=1 ) { nRow = sal::static_int_cast<SCROW>(nRow + n); } - inline void IncCol( SCsCOL n=1 ) { nCol = sal::static_int_cast<SCCOL>(nCol + n); } - inline void IncTab( SCsTAB n=1 ) { nTab = sal::static_int_cast<SCTAB>(nTab + n); } + + inline SCROW Row() const + { + return nRow; + } + + inline SCCOL Col() const + { + return nCol; + } + inline SCTAB Tab() const + { + return nTab; + } + inline void SetRow( SCROW nRowP ) + { + nRow = nRowP; + } + inline void SetCol( SCCOL nColP ) + { + nCol = nColP; + } + inline void SetTab( SCTAB nTabP ) + { + nTab = nTabP; + } + inline void SetInvalid() + { + nRow = -1; + nCol = -1; + nTab = -1; + } + inline bool IsValid() const + { + return (nRow >= 0) && (nCol >= 0) && (nTab >= 0); + } + + inline void PutInOrder( ScAddress& rAddress ); + + inline void IncRow( SCsROW nDelta = 1 ) + { + nRow = sal::static_int_cast<SCROW>(nRow + nDelta); + } + inline void IncCol( SCsCOL nDelta = 1 ) + { + nCol = sal::static_int_cast<SCCOL>(nCol + nDelta); + } + inline void IncTab( SCsTAB nDelta = 1 ) + { + nTab = sal::static_int_cast<SCTAB>(nTab + nDelta); + } inline void GetVars( SCCOL& nColP, SCROW& nRowP, SCTAB& nTabP ) const - { nColP = nCol; nRowP = nRow; nTabP = nTab; } + { + nColP = nCol; + nRowP = nRow; + nTabP = nTab; + } - SC_DLLPUBLIC sal_uInt16 Parse( const OUString&, ScDocument* = NULL, - const Details& rDetails = detailsOOOa1, - ExternalInfo* pExtInfo = NULL, - const ::com::sun::star::uno::Sequence< - com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL ); + SC_DLLPUBLIC sal_uInt16 Parse( + const OUString&, ScDocument* = NULL, + const Details& rDetails = detailsOOOa1, + ExternalInfo* pExtInfo = NULL, + const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = NULL ); - SC_DLLPUBLIC OUString Format( sal_uInt16 = 0, const ScDocument* = NULL, - const Details& rDetails = detailsOOOa1) const; + SC_DLLPUBLIC OUString Format( sal_uInt16 nFlags = 0, + const ScDocument* pDocument = NULL, + const Details& rDetails = detailsOOOa1) const; // The document for the maximum defined sheet number - SC_DLLPUBLIC bool Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScDocument* =NULL ); - inline bool operator==( const ScAddress& r ) const; - inline bool operator!=( const ScAddress& r ) const; - inline bool operator<( const ScAddress& r ) const; - inline bool operator<=( const ScAddress& r ) const; - inline bool operator>( const ScAddress& r ) const; - inline bool operator>=( const ScAddress& r ) const; + SC_DLLPUBLIC bool Move( SCsCOL nDeltaX, SCsROW nDeltaY, SCsTAB nDeltaZ, + ScDocument* pDocument = NULL ); + + inline bool operator==( const ScAddress& rAddress ) const; + inline bool operator!=( const ScAddress& rAddress ) const; + inline bool operator<( const ScAddress& rAddress ) const; + inline bool operator<=( const ScAddress& rAddress ) const; + inline bool operator>( const ScAddress& rAddress ) const; + inline bool operator>=( const ScAddress& rAddress ) const; inline size_t hash() const; /// "A1" or "$A$1" or R1C1 or R[1]C[1] OUString GetColRowString( bool bAbsolute = false, - const Details& rDetails = detailsOOOa1) const; + const Details& rDetails = detailsOOOa1) const; }; -inline void ScAddress::PutInOrder( ScAddress& r ) +inline void ScAddress::PutInOrder( ScAddress& rAddress ) { - if ( r.Col() < Col() ) + if ( rAddress.Col() < Col() ) { - SCCOL nTmp = r.Col(); - r.SetCol( Col() ); + SCCOL nTmp = rAddress.Col(); + rAddress.SetCol( Col() ); SetCol( nTmp ); } - if ( r.Row() < Row() ) + if ( rAddress.Row() < Row() ) { - SCROW nTmp = r.Row(); - r.SetRow( Row() ); + SCROW nTmp = rAddress.Row(); + rAddress.SetRow( Row() ); SetRow( nTmp ); } - if ( r.Tab() < Tab() ) + if ( rAddress.Tab() < Tab() ) { - SCTAB nTmp = r.Tab(); - r.SetTab( Tab() ); + SCTAB nTmp = rAddress.Tab(); + rAddress.SetTab( Tab() ); SetTab( nTmp ); } } @@ -335,52 +387,52 @@ inline void ScAddress::Set( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) nTab = nTabP; } -inline ScAddress& ScAddress::operator=( const ScAddress& r ) +inline ScAddress& ScAddress::operator=( const ScAddress& rAddress ) { - nCol = r.nCol; - nRow = r.nRow; - nTab = r.nTab; + nCol = rAddress.nCol; + nRow = rAddress.nRow; + nTab = rAddress.nTab; return *this; } -inline bool ScAddress::operator==( const ScAddress& r ) const +inline bool ScAddress::operator==( const ScAddress& rAddress ) const { - return nRow == r.nRow && nCol == r.nCol && nTab == r.nTab; + return nRow == rAddress.nRow && nCol == rAddress.nCol && nTab == rAddress.nTab; } -inline bool ScAddress::operator!=( const ScAddress& r ) const +inline bool ScAddress::operator!=( const ScAddress& rAddress ) const { - return !operator==( r ); + return !operator==( rAddress ); } /** Same behavior as the old sal_uInt32 nAddress < r.nAddress with encoded tab|col|row bit fields. */ -inline bool ScAddress::operator<( const ScAddress& r ) const +inline bool ScAddress::operator<( const ScAddress& rAddress ) const { - if (nTab == r.nTab) + if (nTab == rAddress.nTab) { - if (nCol == r.nCol) - return nRow < r.nRow; + if (nCol == rAddress.nCol) + return nRow < rAddress.nRow; else - return nCol < r.nCol; + return nCol < rAddress.nCol; } else - return nTab < r.nTab; + return nTab < rAddress.nTab; } -inline bool ScAddress::operator<=( const ScAddress& r ) const +inline bool ScAddress::operator<=( const ScAddress& rAddress ) const { - return operator<( r ) || operator==( r ); + return operator<( rAddress ) || operator==( rAddress ); } -inline bool ScAddress::operator>( const ScAddress& r ) const +inline bool ScAddress::operator>( const ScAddress& rAddress ) const { - return !operator<=( r ); + return !operator<=( rAddress ); } -inline bool ScAddress::operator>=( const ScAddress& r ) const +inline bool ScAddress::operator>=( const ScAddress& rAddress ) const { - return !operator<( r ); + return !operator<( rAddress ); } inline size_t ScAddress::hash() const @@ -397,9 +449,9 @@ inline size_t ScAddress::hash() const struct ScAddressHashFunctor { - size_t operator()( const ScAddress & rAdr ) const + size_t operator()( const ScAddress & rAddress ) const { - return rAdr.hash(); + return rAddress.hash(); } }; @@ -411,52 +463,80 @@ struct ScAddressEqualFunctor } }; -inline bool ValidAddress( const ScAddress& rAddr ) +inline bool ValidAddress( const ScAddress& rAddress ) { - return ValidCol(rAddr.Col()) && ValidRow(rAddr.Row()) && ValidTab(rAddr.Tab()); + return ValidCol(rAddress.Col()) && ValidRow(rAddress.Row()) && ValidTab(rAddress.Tab()); } // ScRange class ScRange { public: - ScAddress aStart, aEnd; - inline ScRange() : aStart(), aEnd() {} - inline ScRange( ScAddress::Uninitialized e ) - : aStart( e ), aEnd( e ) {} - inline ScRange( ScAddress::InitializeInvalid e ) - : aStart( e ), aEnd( e ) {} - inline ScRange( const ScAddress& s, const ScAddress& e ) - : aStart( s ), aEnd( e ) { aStart.PutInOrder( aEnd ); } - inline ScRange( const ScRange& r ) : aStart( r.aStart ), aEnd( r.aEnd ) {} - inline ScRange( const ScAddress& r ) : aStart( r ), aEnd( r ) {} - inline ScRange( SCCOL nCol, SCROW nRow, SCTAB nTab ) - : aStart( nCol, nRow, nTab ), aEnd( aStart ) {} - inline ScRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, - SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) - : aStart( nCol1, nRow1, nTab1 ), aEnd( nCol2, nRow2, nTab2 ) {} - - inline ScRange& operator=( const ScRange& r ) - { aStart = r.aStart; aEnd = r.aEnd; return *this; } + ScAddress aStart; + ScAddress aEnd; + + inline ScRange() : + aStart(), aEnd() + {} + + inline ScRange( ScAddress::Uninitialized eUninitialized ) : + aStart( eUninitialized ), aEnd( eUninitialized ) + {} + inline ScRange( ScAddress::InitializeInvalid eInvalid ) : + aStart( eInvalid ), aEnd( eInvalid ) + {} + inline ScRange( const ScAddress& aInputStart, const ScAddress& aInputEnd ) : + aStart( aInputStart ), aEnd( aInputEnd ) + { + aStart.PutInOrder( aEnd ); + } + inline ScRange( const ScRange& rRange ) : + aStart( rRange.aStart ), aEnd( rRange.aEnd ) + {} + inline ScRange( const ScAddress& rRange ) : + aStart( rRange ), aEnd( rRange ) + {} + inline ScRange( SCCOL nCol, SCROW nRow, SCTAB nTab ) : + aStart( nCol, nRow, nTab ), aEnd( aStart ) + {} + inline ScRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) : + aStart( nCol1, nRow1, nTab1 ), aEnd( nCol2, nRow2, nTab2 ) + {} + + inline ScRange& operator=( const ScRange& rRange ) + { + aStart = rRange.aStart; + aEnd = rRange.aEnd; + return *this; + } inline ScRange& operator=( const ScAddress& rPos ) - { aStart = aEnd = rPos; return *this; } - inline void SetInvalid() { aStart.SetInvalid(); aEnd.SetInvalid(); } - inline bool IsValid() const { return aStart.IsValid() && aEnd.IsValid(); } + { + aStart = aEnd = rPos; + return *this; + } + inline void SetInvalid() + { + aStart.SetInvalid(); + aEnd.SetInvalid(); + } + inline bool IsValid() const + { + return aStart.IsValid() && aEnd.IsValid(); + } inline bool In( const ScAddress& ) const; ///< is Address& in Range? inline bool In( const ScRange& ) const; ///< is Range& in Range? SC_DLLPUBLIC sal_uInt16 Parse( const OUString&, ScDocument* = NULL, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, - ScAddress::ExternalInfo* pExtInfo = NULL, - const ::com::sun::star::uno::Sequence< - com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL ); + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, + ScAddress::ExternalInfo* pExtInfo = NULL, + const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = NULL ); SC_DLLPUBLIC sal_uInt16 ParseAny( const OUString&, ScDocument* = NULL, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); SC_DLLPUBLIC sal_uInt16 ParseCols( const OUString&, ScDocument* = NULL, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); SC_DLLPUBLIC sal_uInt16 ParseRows( const OUString&, ScDocument* = NULL, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); /** Parse an Excel style reference up to and including the sheet name separator '!', including detection of external documents and sheet @@ -478,29 +558,29 @@ public: Or NULL if a 3D sheet header could be parsed but bOnlyAcceptSingle==true was given. */ - const sal_Unicode* Parse_XL_Header( const sal_Unicode* pString, const ScDocument* pDoc, - OUString& rExternDocName, OUString& rStartTabName, OUString& rEndTabName, sal_uInt16& nFlags, - bool bOnlyAcceptSingle, - const ::com::sun::star::uno::Sequence< - com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL ); + const sal_Unicode* Parse_XL_Header( const sal_Unicode* pString, const ScDocument* pDocument, + OUString& rExternDocName, OUString& rStartTabName, + OUString& rEndTabName, sal_uInt16& nFlags, + bool bOnlyAcceptSingle, + const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = NULL ); - SC_DLLPUBLIC OUString Format(sal_uInt16 = 0, const ScDocument* = NULL, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; + SC_DLLPUBLIC OUString Format(sal_uInt16 nFlags= 0, const ScDocument* pDocument = NULL, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, - SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const; + SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const; // The document for the maximum defined sheet number - SC_DLLPUBLIC bool Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScDocument* =NULL ); + SC_DLLPUBLIC bool Move( SCsCOL aDeltaX, SCsROW aDeltaY, SCsTAB aDeltaZ, ScDocument* pDocument = NULL ); SC_DLLPUBLIC void Justify(); SC_DLLPUBLIC void ExtendTo( const ScRange& rRange ); - SC_DLLPUBLIC bool Intersects( const ScRange& ) const; // do two ranges intersect? + SC_DLLPUBLIC bool Intersects( const ScRange& rRange ) const; // do two ranges intersect? void PutInOrder(); - inline bool operator==( const ScRange& r ) const; - inline bool operator!=( const ScRange& r ) const; - inline bool operator<( const ScRange& r ) const; - inline bool operator<=( const ScRange& r ) const; - inline bool operator>( const ScRange& r ) const; - inline bool operator>=( const ScRange& r ) const; + inline bool operator==( const ScRange& rRange ) const; + inline bool operator!=( const ScRange& rRange ) const; + inline bool operator<( const ScRange& rRange ) const; + inline bool operator<=( const ScRange& rRange ) const; + inline bool operator>( const ScRange& rRange ) const; + inline bool operator>=( const ScRange& rRange ) const; /// Hash 2D area ignoring table number. inline size_t hashArea() const; @@ -509,20 +589,20 @@ public: }; inline void ScRange::GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, - SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const + SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const { aStart.GetVars( nCol1, nRow1, nTab1 ); aEnd.GetVars( nCol2, nRow2, nTab2 ); } -inline bool ScRange::operator==( const ScRange& r ) const +inline bool ScRange::operator==( const ScRange& rRange ) const { - return ( (aStart == r.aStart) && (aEnd == r.aEnd) ); + return ( (aStart == rRange.aStart) && (aEnd == rRange.aEnd) ); } -inline bool ScRange::operator!=( const ScRange& r ) const +inline bool ScRange::operator!=( const ScRange& rRange ) const { - return !operator==( r ); + return !operator==( rRange ); } /// Sort on upper left corner, if equal then use lower right too. @@ -531,35 +611,35 @@ inline bool ScRange::operator<( const ScRange& r ) const return aStart < r.aStart || (aStart == r.aStart && aEnd < r.aEnd) ; } -inline bool ScRange::operator<=( const ScRange& r ) const +inline bool ScRange::operator<=( const ScRange& rRange ) const { - return operator<( r ) || operator==( r ); + return operator<( rRange ) || operator==( rRange ); } -inline bool ScRange::operator>( const ScRange& r ) const +inline bool ScRange::operator>( const ScRange& rRange ) const { - return !operator<=( r ); + return !operator<=( rRange ); } -inline bool ScRange::operator>=( const ScRange& r ) const +inline bool ScRange::operator>=( const ScRange& rRange ) const { - return !operator<( r ); + return !operator<( rRange ); } -inline bool ScRange::In( const ScAddress& rAddr ) const +inline bool ScRange::In( const ScAddress& rAddress ) const { return - aStart.Col() <= rAddr.Col() && rAddr.Col() <= aEnd.Col() && - aStart.Row() <= rAddr.Row() && rAddr.Row() <= aEnd.Row() && - aStart.Tab() <= rAddr.Tab() && rAddr.Tab() <= aEnd.Tab(); + aStart.Col() <= rAddress.Col() && rAddress.Col() <= aEnd.Col() && + aStart.Row() <= rAddress.Row() && rAddress.Row() <= aEnd.Row() && + aStart.Tab() <= rAddress.Tab() && rAddress.Tab() <= aEnd.Tab(); } -inline bool ScRange::In( const ScRange& r ) const +inline bool ScRange::In( const ScRange& rRange ) const { return - aStart.Col() <= r.aStart.Col() && r.aEnd.Col() <= aEnd.Col() && - aStart.Row() <= r.aStart.Row() && r.aEnd.Row() <= aEnd.Row() && - aStart.Tab() <= r.aStart.Tab() && r.aEnd.Tab() <= aEnd.Tab(); + aStart.Col() <= rRange.aStart.Col() && rRange.aEnd.Col() <= aEnd.Col() && + aStart.Row() <= rRange.aStart.Row() && rRange.aEnd.Row() <= aEnd.Row() && + aStart.Tab() <= rRange.aStart.Tab() && rRange.aEnd.Tab() <= aEnd.Tab(); } inline size_t ScRange::hashArea() const @@ -574,8 +654,8 @@ inline size_t ScRange::hashArea() const return (static_cast<size_t>(aStart.Row()) << 26) ^ // start row <= 2^6 (static_cast<size_t>(aStart.Col()) << 21) ^ // start column <= 2^5 - (static_cast<size_t>(aEnd.Col()) << 15) ^ // end column <= 2^6 - static_cast<size_t>(aEnd.Row()); // end row <= 2^15 + (static_cast<size_t>(aEnd.Col()) << 15) ^ // end column <= 2^6 + static_cast<size_t>(aEnd.Row()); // end row <= 2^15 } inline size_t ScRange::hashStartColumn() const @@ -586,7 +666,7 @@ inline size_t ScRange::hashStartColumn() const return (static_cast<size_t>(aStart.Col()) << 24) ^ // start column <= 2^8 (static_cast<size_t>(aStart.Row()) << 16) ^ // start row <= 2^8 - static_cast<size_t>(aEnd.Row()); + static_cast<size_t>(aEnd.Row()); } struct ScRangeHashAreaFunctor @@ -617,87 +697,136 @@ private: ScRange aRange[2]; public: - ScRangePair() {} + ScRangePair() + {} ScRangePair( const ScRangePair& r ) - { aRange[0] = r.aRange[0]; aRange[1] = r.aRange[1]; } - ScRangePair( const ScRange& r1, const ScRange& r2 ) - { aRange[0] = r1; aRange[1] = r2; } + { + aRange[0] = r.aRange[0]; + aRange[1] = r.aRange[1]; + } + ScRangePair( const ScRange& rRange1, const ScRange& rRange2 ) + { + aRange[0] = rRange1; + aRange[1] = rRange2; + } - inline ScRangePair& operator= ( const ScRangePair& r ); - const ScRange& GetRange( sal_uInt16 n ) const { return aRange[n]; } - ScRange& GetRange( sal_uInt16 n ) { return aRange[n]; } + inline ScRangePair& operator= ( const ScRangePair& rRange ); + const ScRange& GetRange( sal_uInt16 n ) const + { + return aRange[n]; + } + ScRange& GetRange( sal_uInt16 n ) + { + return aRange[n]; + } inline bool operator==( const ScRangePair& ) const; inline bool operator!=( const ScRangePair& ) const; }; -inline ScRangePair& ScRangePair::operator= ( const ScRangePair& r ) +inline ScRangePair& ScRangePair::operator= ( const ScRangePair& rRange ) { - aRange[0] = r.aRange[0]; - aRange[1] = r.aRange[1]; + aRange[0] = rRange.aRange[0]; + aRange[1] = rRange.aRange[1]; return *this; } -inline bool ScRangePair::operator==( const ScRangePair& r ) const +inline bool ScRangePair::operator==( const ScRangePair& rRange ) const { - return ( (aRange[0] == r.aRange[0]) && (aRange[1] == r.aRange[1]) ); + return (aRange[0] == rRange.aRange[0]) && + (aRange[1] == rRange.aRange[1]); } -inline bool ScRangePair::operator!=( const ScRangePair& r ) const +inline bool ScRangePair::operator!=( const ScRangePair& rRange ) const { - return !operator==( r ); + return !operator==( rRange ); } // ScRefAddress class ScRefAddress { - ScAddress aAdr; - bool bRelCol; - bool bRelRow; - bool bRelTab; +private: + ScAddress aAdr; + bool bRelCol; + bool bRelRow; + bool bRelTab; public: - inline ScRefAddress() : bRelCol(false), bRelRow(false), bRelTab(false) - {} + inline ScRefAddress() : + bRelCol(false), bRelRow(false), bRelTab(false) + {} inline ScRefAddress( SCCOL nCol, SCROW nRow, SCTAB nTab, - bool bRelColP, bool bRelRowP, bool bRelTabP ) : + bool bRelColP, bool bRelRowP, bool bRelTabP ) : aAdr(nCol, nRow, nTab), bRelCol(bRelColP), bRelRow(bRelRowP), bRelTab(bRelTabP) - {} + {} inline ScRefAddress( const ScAddress& rAdr, - bool bRelColP, bool bRelRowP, bool bRelTabP ) : + bool bRelColP, bool bRelRowP, bool bRelTabP ) : aAdr(rAdr), bRelCol(bRelColP), bRelRow(bRelRowP), bRelTab(bRelTabP) - {} + {} inline ScRefAddress( const ScRefAddress& rRef ) : - aAdr(rRef.aAdr), bRelCol(rRef.bRelCol), bRelRow(rRef.bRelRow), - bRelTab(rRef.bRelTab) - {} + aAdr(rRef.aAdr), bRelCol(rRef.bRelCol), bRelRow(rRef.bRelRow), + bRelTab(rRef.bRelTab) + {} - inline ScRefAddress& operator=( const ScRefAddress& ); + inline ScRefAddress& operator=( const ScRefAddress& ); - inline bool IsRelCol() const { return bRelCol; } - inline bool IsRelRow() const { return bRelRow; } - inline bool IsRelTab() const { return bRelTab; } + inline bool IsRelCol() const + { + return bRelCol; + } + inline bool IsRelRow() const + { + return bRelRow; + } + inline bool IsRelTab() const + { + return bRelTab; + } + + inline void SetRelCol(bool bNewRelCol) + { + bRelCol = bNewRelCol; + } + inline void SetRelRow(bool bNewRelRow) + { + bRelRow = bNewRelRow; + } + inline void SetRelTab(bool bNewRelTab) + { + bRelTab = bNewRelTab; + } - inline void SetRelCol(bool bNewRelCol) { bRelCol = bNewRelCol; } - inline void SetRelRow(bool bNewRelRow) { bRelRow = bNewRelRow; } - inline void SetRelTab(bool bNewRelTab) { bRelTab = bNewRelTab; } + inline void Set( const ScAddress& rAdr, + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ); + inline void Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ); - inline void Set( const ScAddress& rAdr, - bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ); - inline void Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, - bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ); + inline const ScAddress& GetAddress() const + { + return aAdr; + } - inline const ScAddress& GetAddress() const { return aAdr; } - inline SCCOL Col() const { return aAdr.Col(); } - inline SCROW Row() const { return aAdr.Row(); } - inline SCTAB Tab() const { return aAdr.Tab(); } + inline SCCOL Col() const + { + return aAdr.Col(); + } + inline SCROW Row() const + { + return aAdr.Row(); + } + inline SCTAB Tab() const + { + return aAdr.Tab(); + } - inline bool operator == ( const ScRefAddress& r ) const; - inline bool operator != ( const ScRefAddress& r ) const - { return !(operator==(r)); } + inline bool operator == ( const ScRefAddress& r ) const; + inline bool operator != ( const ScRefAddress& r ) const + { + return !(operator==(r)); + } - OUString GetRefString( ScDocument* pDoc, SCTAB nActTab, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; + OUString GetRefString( ScDocument* pDocument, SCTAB nActTab, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; }; inline ScRefAddress& ScRefAddress::operator=( const ScRefAddress& rRef ) @@ -710,7 +839,7 @@ inline ScRefAddress& ScRefAddress::operator=( const ScRefAddress& rRef ) } inline void ScRefAddress::Set( const ScAddress& rAdr, - bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ) + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ) { aAdr = rAdr; bRelCol = bNewRelCol; @@ -719,7 +848,7 @@ inline void ScRefAddress::Set( const ScAddress& rAdr, } inline void ScRefAddress::Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, - bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ) + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ) { aAdr.Set( nNewCol, nNewRow, nNewTab); bRelCol = bNewRelCol; @@ -727,10 +856,12 @@ inline void ScRefAddress::Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, bRelTab = bNewRelTab; } -inline bool ScRefAddress::operator==( const ScRefAddress& r ) const +inline bool ScRefAddress::operator==( const ScRefAddress& rRefAddress ) const { - return aAdr == r.aAdr && bRelCol == r.bRelCol && bRelRow == r.bRelRow && - bRelTab == r.bRelTab; + return aAdr == rRefAddress.aAdr && + bRelCol == rRefAddress.bRelCol && + bRelRow == rRefAddress.bRelRow && + bRelTab == rRefAddress.bRelTab; } // Global functions @@ -751,16 +882,16 @@ template< typename T > void PutInOrder( T& nStart, T& nEnd ) } } -bool ConvertSingleRef( ScDocument* pDoc, const OUString& rRefString, - SCTAB nDefTab, ScRefAddress& rRefAddress, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, - ScAddress::ExternalInfo* pExtInfo = NULL ); +bool ConvertSingleRef( ScDocument* pDocument, const OUString& rRefString, + SCTAB nDefTab, ScRefAddress& rRefAddress, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, + ScAddress::ExternalInfo* pExtInfo = NULL ); -bool ConvertDoubleRef(ScDocument* pDoc, const OUString& rRefString, - SCTAB nDefTab, ScRefAddress& rStartRefAddress, - ScRefAddress& rEndRefAddress, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, - ScAddress::ExternalInfo* pExtInfo = NULL ); +bool ConvertDoubleRef( ScDocument* pDocument, const OUString& rRefString, + SCTAB nDefTab, ScRefAddress& rStartRefAddress, + ScRefAddress& rEndRefAddress, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, + ScAddress::ExternalInfo* pExtInfo = NULL ); /// append alpha representation of column to buffer SC_DLLPUBLIC void ScColToAlpha( OUStringBuffer& rBuffer, SCCOL nCol); diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index 3cdd2fe5b1d6..825daaeaf772 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -34,7 +34,7 @@ #include <sfx2/objsh.hxx> #include <tools/urlobj.hxx> -using namespace ::com::sun::star; +using namespace css; const ScAddress::Details ScAddress::detailsOOOa1( formula::FormulaGrammar::CONV_OOO, 0, 0 ); @@ -43,8 +43,7 @@ ScAddress::Details::Details ( const ScDocument* pDoc, eConv( pDoc->GetAddressConvention() ), nRow( rAddr.Row() ), nCol( rAddr.Col() ) -{ -} +{} namespace { @@ -130,9 +129,7 @@ const sal_Unicode* parseQuotedName( const sal_Unicode* p, OUString& rName ) } -static long int -sal_Unicode_strtol ( const sal_Unicode* p, - const sal_Unicode** pEnd ) +static long int sal_Unicode_strtol ( const sal_Unicode* p, const sal_Unicode** pEnd ) { long int accum = 0, prev = 0; bool is_neg = false; @@ -180,13 +177,13 @@ static const sal_Unicode* lcl_eatWhiteSpace( const sal_Unicode* p ) result in the identical file ID. Else <TRUE/>. */ static bool lcl_ScRange_External_TabSpan( - ScRange & rRange, - sal_uInt16 & rFlags, - ScAddress::ExternalInfo* pExtInfo, - const OUString & rExternDocName, - const OUString & rStartTabName, - const OUString & rEndTabName, - ScDocument* pDoc ) + ScRange & rRange, + sal_uInt16 & rFlags, + ScAddress::ExternalInfo* pExtInfo, + const OUString & rExternDocName, + const OUString & rStartTabName, + const OUString & rEndTabName, + ScDocument* pDoc ) { if (rExternDocName.isEmpty()) return !pExtInfo || !pExtInfo->mbExternal; @@ -258,11 +255,10 @@ static bool lcl_ScRange_External_TabSpan( Starting _within_ a quoted name, but still may be 3D; quoted name stops at pMsoxlQuoteStop */ -static const sal_Unicode * -lcl_XL_ParseSheetRef( const sal_Unicode* start, - OUString& rExternTabName, - bool allow_3d, - const sal_Unicode* pMsoxlQuoteStop ) +static const sal_Unicode * lcl_XL_ParseSheetRef( const sal_Unicode* start, + OUString& rExternTabName, + bool bAllow3D, + const sal_Unicode* pMsoxlQuoteStop ) { OUString aTabName; const sal_Unicode *p = start; @@ -296,8 +292,8 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start, return NULL; if (p == pMsoxlQuoteStop) ++p; // position on ! of ...'!... - if( *p != '!' && ( !allow_3d || *p != ':' ) ) - return (!allow_3d && *p == ':') ? p : start; + if( *p != '!' && ( !bAllow3D || *p != ':' ) ) + return (!bAllow3D && *p == ':') ? p : start; } else if( *p == '\'') { @@ -360,8 +356,8 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start, break; } - if( *p != '!' && ( !allow_3d || *p != ':' ) ) - return (!allow_3d && *p == ':') ? p : start; + if( *p != '!' && ( !bAllow3D || *p != ':' ) ) + return (!bAllow3D && *p == ':') ? p : start; aTabName += OUString( start, sal::static_int_cast<sal_Int32>( p - start ) ); } @@ -383,7 +379,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start, name is not numeric. */ static bool lcl_XL_getExternalDoc( const sal_Unicode** ppErrRet, OUString& rExternDocName, - const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) + const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) { // 1-based, sequence starts with an empty element. if (pExternalLinks && pExternalLinks->hasElements()) @@ -427,14 +423,14 @@ static bool lcl_XL_getExternalDoc( const sal_Unicode** ppErrRet, OUString& rExte } const sal_Unicode* ScRange::Parse_XL_Header( - const sal_Unicode* p, - const ScDocument* pDoc, - OUString& rExternDocName, - OUString& rStartTabName, - OUString& rEndTabName, - sal_uInt16& nFlags, - bool bOnlyAcceptSingle, - const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) + const sal_Unicode* p, + const ScDocument* pDoc, + OUString& rExternDocName, + OUString& rStartTabName, + OUString& rEndTabName, + sal_uInt16& nFlags, + bool bOnlyAcceptSingle, + const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) { const sal_Unicode* startTabs, *start = p; sal_uInt16 nSaveFlags = nFlags; @@ -607,10 +603,9 @@ const sal_Unicode* ScRange::Parse_XL_Header( return p; } -static const sal_Unicode* -lcl_r1c1_get_col( const sal_Unicode* p, - const ScAddress::Details& rDetails, - ScAddress* pAddr, sal_uInt16* nFlags ) +static const sal_Unicode* lcl_r1c1_get_col( const sal_Unicode* p, + const ScAddress::Details& rDetails, + ScAddress* pAddr, sal_uInt16* nFlags ) { const sal_Unicode *pEnd; long int n; @@ -652,10 +647,11 @@ lcl_r1c1_get_col( const sal_Unicode* p, return pEnd; } -static inline const sal_Unicode* -lcl_r1c1_get_row( const sal_Unicode* p, - const ScAddress::Details& rDetails, - ScAddress* pAddr, sal_uInt16* nFlags ) + +static inline const sal_Unicode* lcl_r1c1_get_row( + const sal_Unicode* p, + const ScAddress::Details& rDetails, + ScAddress* pAddr, sal_uInt16* nFlags ) { const sal_Unicode *pEnd; long int n; @@ -698,13 +694,12 @@ lcl_r1c1_get_row( const sal_Unicode* p, return pEnd; } -static sal_uInt16 -lcl_ScRange_Parse_XL_R1C1( ScRange& r, - const sal_Unicode* p, - ScDocument* pDoc, - const ScAddress::Details& rDetails, - bool bOnlyAcceptSingle, - ScAddress::ExternalInfo* pExtInfo ) +static sal_uInt16 lcl_ScRange_Parse_XL_R1C1( ScRange& r, + const sal_Unicode* p, + ScDocument* pDoc, + const ScAddress::Details& rDetails, + bool bOnlyAcceptSingle, + ScAddress::ExternalInfo* pExtInfo ) { const sal_Unicode* pTmp = NULL; OUString aExternDocName, aStartTabName, aEndTabName; @@ -725,7 +720,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r, if( *p == 'R' || *p == 'r' ) { if( NULL == (p = lcl_r1c1_get_row( p, rDetails, &r.aStart, &nFlags )) ) - goto failed; + return 0; if( *p != 'C' && *p != 'c' ) // full row R# { @@ -761,7 +756,9 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r, return bOnlyAcceptSingle ? 0 : nFlags; } else if( NULL == (p = lcl_r1c1_get_col( p, rDetails, &r.aStart, &nFlags ))) - goto failed; + { + return 0; + } if( p[0] != ':' || (p[1] != 'R' && p[1] != 'r') || @@ -798,7 +795,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r, else if( *p == 'C' || *p == 'c' ) // full col C# { if( NULL == (p = lcl_r1c1_get_col( p, rDetails, &r.aStart, &nFlags ))) - goto failed; + return 0; if( p[0] != ':' || (p[1] != 'C' && p[1] != 'c') || NULL == (pTmp = lcl_r1c1_get_col( p+1, rDetails, &r.aEnd, &nFlags2 ))) @@ -829,12 +826,12 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r, return bOnlyAcceptSingle ? 0 : nFlags; } -failed : return 0; } -static inline const sal_Unicode* -lcl_a1_get_col( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags ) +static inline const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p, + ScAddress* pAddr, + sal_uInt16* nFlags ) { SCCOL nCol; @@ -856,8 +853,9 @@ lcl_a1_get_col( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags ) return p; } -static inline const sal_Unicode* -lcl_a1_get_row( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags ) +static inline const sal_Unicode* lcl_a1_get_row( const sal_Unicode* p, + ScAddress* pAddr, + sal_uInt16* nFlags ) { const sal_Unicode *pEnd; long int n; @@ -875,13 +873,12 @@ lcl_a1_get_row( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags ) return pEnd; } -static sal_uInt16 -lcl_ScRange_Parse_XL_A1( ScRange& r, - const sal_Unicode* p, - ScDocument* pDoc, - bool bOnlyAcceptSingle, - ScAddress::ExternalInfo* pExtInfo, - const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) +static sal_uInt16 lcl_ScRange_Parse_XL_A1( ScRange& r, + const sal_Unicode* p, + ScDocument* pDoc, + bool bOnlyAcceptSingle, + ScAddress::ExternalInfo* pExtInfo, + const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) { const sal_Unicode* tmp1, *tmp2; OUString aExternDocName, aStartTabName, aEndTabName; // for external link table @@ -1022,9 +1019,8 @@ lcl_ScRange_Parse_XL_A1( ScRange& r, used in conjunction with pExtInfo to determine the tab span of a 3D reference. */ -static sal_uInt16 -lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr, - ScAddress::ExternalInfo* pExtInfo = NULL, ScRange* pRange = NULL ) +static sal_uInt16 lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr, + ScAddress::ExternalInfo* pExtInfo = NULL, ScRange* pRange = NULL ) { sal_uInt16 nRes = 0; OUString aDocName; // der pure Dokumentenname @@ -1266,38 +1262,37 @@ lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAdd return nRes; } -static sal_uInt16 -lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr, - const ScAddress::Details& rDetails, - ScAddress::ExternalInfo* pExtInfo = NULL, - const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks = NULL ) +static sal_uInt16 lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr, + const ScAddress::Details& rDetails, + ScAddress::ExternalInfo* pExtInfo = NULL, + const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks = NULL ) { if( !*p ) return 0; switch (rDetails.eConv) { - default : - case formula::FormulaGrammar::CONV_OOO: + case formula::FormulaGrammar::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_OOX: { - return lcl_ScAddress_Parse_OOo( p, pDoc, rAddr, pExtInfo, NULL ); + ScRange rRange = rAddr; + sal_uInt16 nFlags = lcl_ScRange_Parse_XL_A1( + rRange, p, pDoc, true, pExtInfo, + (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) ); + rAddr = rRange.aStart; + return nFlags; } - - case formula::FormulaGrammar::CONV_XL_A1: - case formula::FormulaGrammar::CONV_XL_OOX: + case formula::FormulaGrammar::CONV_XL_R1C1: { - ScRange r = rAddr; - sal_uInt16 nFlags = lcl_ScRange_Parse_XL_A1( r, p, pDoc, true, pExtInfo, - (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) ); - rAddr = r.aStart; + ScRange rRange = rAddr; + sal_uInt16 nFlags = lcl_ScRange_Parse_XL_R1C1( rRange, p, pDoc, rDetails, true, pExtInfo ); + rAddr = rRange.aStart; return nFlags; } - case formula::FormulaGrammar::CONV_XL_R1C1: + default : + case formula::FormulaGrammar::CONV_OOO: { - ScRange r = rAddr; - sal_uInt16 nFlags = lcl_ScRange_Parse_XL_R1C1( r, p, pDoc, rDetails, true, pExtInfo ); - rAddr = r.aStart; - return nFlags; + return lcl_ScAddress_Parse_OOo( p, pDoc, rAddr, pExtInfo, NULL ); } } } @@ -1351,19 +1346,19 @@ bool ConvertDoubleRef( ScDocument* pDoc, const OUString& rRefString, SCTAB nDefT } sal_uInt16 ScAddress::Parse( const OUString& r, ScDocument* pDoc, - const Details& rDetails, - ExternalInfo* pExtInfo, - const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) + const Details& rDetails, + ExternalInfo* pExtInfo, + const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) { return lcl_ScAddress_Parse( r.getStr(), pDoc, *this, rDetails, pExtInfo, pExternalLinks ); } -bool ScRange::Intersects( const ScRange& r ) const +bool ScRange::Intersects( const ScRange& rRange ) const { return !( - std::min( aEnd.Col(), r.aEnd.Col() ) < std::max( aStart.Col(), r.aStart.Col() ) - || std::min( aEnd.Row(), r.aEnd.Row() ) < std::max( aStart.Row(), r.aStart.Row() ) - || std::min( aEnd.Tab(), r.aEnd.Tab() ) < std::max( aStart.Tab(), r.aStart.Tab() ) + std::min( aEnd.Col(), rRange.aEnd.Col() ) < std::max( aStart.Col(), rRange.aStart.Col() ) + || std::min( aEnd.Row(), rRange.aEnd.Row() ) < std::max( aStart.Row(), rRange.aStart.Row() ) + || std::min( aEnd.Tab(), rRange.aEnd.Tab() ) < std::max( aStart.Tab(), rRange.aStart.Tab() ) ); } @@ -1410,19 +1405,21 @@ void ScRange::ExtendTo( const ScRange& rRange ) OSL_ENSURE( rRange.IsValid(), "ScRange::ExtendTo - cannot extend to invalid range" ); if( IsValid() ) { - aStart.SetCol( ::std::min( aStart.Col(), rRange.aStart.Col() ) ); - aStart.SetRow( ::std::min( aStart.Row(), rRange.aStart.Row() ) ); - aStart.SetTab( ::std::min( aStart.Tab(), rRange.aStart.Tab() ) ); - aEnd.SetCol( ::std::max( aEnd.Col(), rRange.aEnd.Col() ) ); - aEnd.SetRow( ::std::max( aEnd.Row(), rRange.aEnd.Row() ) ); - aEnd.SetTab( ::std::max( aEnd.Tab(), rRange.aEnd.Tab() ) ); + aStart.SetCol( std::min( aStart.Col(), rRange.aStart.Col() ) ); + aStart.SetRow( std::min( aStart.Row(), rRange.aStart.Row() ) ); + aStart.SetTab( std::min( aStart.Tab(), rRange.aStart.Tab() ) ); + aEnd.SetCol( std::max( aEnd.Col(), rRange.aEnd.Col() ) ); + aEnd.SetRow( std::max( aEnd.Row(), rRange.aEnd.Row() ) ); + aEnd.SetTab( std::max( aEnd.Tab(), rRange.aEnd.Tab() ) ); } else *this = rRange; } -static sal_uInt16 -lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScAddress::ExternalInfo* pExtInfo = NULL ) +static sal_uInt16 lcl_ScRange_Parse_OOo( ScRange& rRange, + const OUString& r, + ScDocument* pDoc, + ScAddress::ExternalInfo* pExtInfo = NULL ) { sal_uInt16 nRes1 = 0, nRes2 = 0; sal_Int32 nPos = ScGlobal::FindUnquoted( r, ':'); @@ -1431,17 +1428,17 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA OUStringBuffer aTmp(r); aTmp[nPos] = 0; const sal_Unicode* p = aTmp.getStr(); - if( (nRes1 = lcl_ScAddress_Parse_OOo( p, pDoc, aRange.aStart, pExtInfo, NULL ) ) != 0 ) + if( (nRes1 = lcl_ScAddress_Parse_OOo( p, pDoc, rRange.aStart, pExtInfo, NULL ) ) != 0 ) { - aRange.aEnd = aRange.aStart; // sheet must be initialized identical to first sheet - if ( (nRes2 = lcl_ScAddress_Parse_OOo( p + nPos+ 1, pDoc, aRange.aEnd, pExtInfo, &aRange ) ) != 0 ) + rRange.aEnd = rRange.aStart; // sheet must be initialized identical to first sheet + if ( (nRes2 = lcl_ScAddress_Parse_OOo( p + nPos+ 1, pDoc, rRange.aEnd, pExtInfo, &rRange ) ) != 0 ) { // PutInOrder / Justify sal_uInt16 nMask, nBits1, nBits2; SCCOL nTempCol; - if ( aRange.aEnd.Col() < (nTempCol = aRange.aStart.Col()) ) + if ( rRange.aEnd.Col() < (nTempCol = rRange.aStart.Col()) ) { - aRange.aStart.SetCol(aRange.aEnd.Col()); aRange.aEnd.SetCol(nTempCol); + rRange.aStart.SetCol(rRange.aEnd.Col()); rRange.aEnd.SetCol(nTempCol); nMask = (SCA_VALID_COL | SCA_COL_ABSOLUTE); nBits1 = nRes1 & nMask; nBits2 = nRes2 & nMask; @@ -1449,9 +1446,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA nRes2 = (nRes2 & ~nMask) | nBits1; } SCROW nTempRow; - if ( aRange.aEnd.Row() < (nTempRow = aRange.aStart.Row()) ) + if ( rRange.aEnd.Row() < (nTempRow = rRange.aStart.Row()) ) { - aRange.aStart.SetRow(aRange.aEnd.Row()); aRange.aEnd.SetRow(nTempRow); + rRange.aStart.SetRow(rRange.aEnd.Row()); rRange.aEnd.SetRow(nTempRow); nMask = (SCA_VALID_ROW | SCA_ROW_ABSOLUTE); nBits1 = nRes1 & nMask; nBits2 = nRes2 & nMask; @@ -1459,9 +1456,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA nRes2 = (nRes2 & ~nMask) | nBits1; } SCTAB nTempTab; - if ( aRange.aEnd.Tab() < (nTempTab = aRange.aStart.Tab()) ) + if ( rRange.aEnd.Tab() < (nTempTab = rRange.aStart.Tab()) ) { - aRange.aStart.SetTab(aRange.aEnd.Tab()); aRange.aEnd.SetTab(nTempTab); + rRange.aStart.SetTab(rRange.aEnd.Tab()); rRange.aEnd.SetTab(nTempTab); nMask = (SCA_VALID_TAB | SCA_TAB_ABSOLUTE | SCA_TAB_3D); nBits1 = nRes1 & nMask; nBits2 = nRes2 & nMask; @@ -1483,42 +1480,47 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA return nRes1; } -sal_uInt16 ScRange::Parse( const OUString& r, ScDocument* pDoc, - const ScAddress::Details& rDetails, - ScAddress::ExternalInfo* pExtInfo, - const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) +sal_uInt16 ScRange::Parse( const OUString& rString, ScDocument* pDoc, + const ScAddress::Details& rDetails, + ScAddress::ExternalInfo* pExtInfo, + const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks ) { - if (r.isEmpty()) + if (rString.isEmpty()) return 0; switch (rDetails.eConv) { - default : - case formula::FormulaGrammar::CONV_OOO: - return lcl_ScRange_Parse_OOo( *this, r, pDoc, pExtInfo ); + case formula::FormulaGrammar::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_OOX: + { + return lcl_ScRange_Parse_XL_A1( *this, rString.getStr(), pDoc, false, pExtInfo, + (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) ); + } - case formula::FormulaGrammar::CONV_XL_A1: - case formula::FormulaGrammar::CONV_XL_OOX: - return lcl_ScRange_Parse_XL_A1( *this, r.getStr(), pDoc, false, pExtInfo, - (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) ); + case formula::FormulaGrammar::CONV_XL_R1C1: + { + return lcl_ScRange_Parse_XL_R1C1( *this, rString.getStr(), pDoc, rDetails, false, pExtInfo ); + } - case formula::FormulaGrammar::CONV_XL_R1C1: - return lcl_ScRange_Parse_XL_R1C1( *this, r.getStr(), pDoc, rDetails, false, pExtInfo ); + default: + case formula::FormulaGrammar::CONV_OOO: + { + return lcl_ScRange_Parse_OOo( *this, rString, pDoc, pExtInfo ); + } } } // Accept a full range, or an address -sal_uInt16 ScRange::ParseAny( const OUString& r, ScDocument* pDoc, - const ScAddress::Details& rDetails ) +sal_uInt16 ScRange::ParseAny( const OUString& rString, ScDocument* pDoc, + const ScAddress::Details& rDetails ) { - sal_uInt16 nRet = Parse( r, pDoc, rDetails ); - const sal_uInt16 nValid = SCA_VALID | SCA_VALID_COL2 | SCA_VALID_ROW2 | - SCA_VALID_TAB2; + sal_uInt16 nRet = Parse( rString, pDoc, rDetails ); + const sal_uInt16 nValid = SCA_VALID | SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2; if ( (nRet & nValid) != nValid ) { ScAddress aAdr(aStart);//initialize with currentPos as fallback for table number - nRet = aAdr.Parse( r, pDoc, rDetails ); + nRet = aAdr.Parse( rString, pDoc, rDetails ); if ( nRet & SCA_VALID ) aStart = aEnd = aAdr; } @@ -1527,7 +1529,7 @@ sal_uInt16 ScRange::ParseAny( const OUString& r, ScDocument* pDoc, // Parse only full row references sal_uInt16 ScRange::ParseCols( const OUString& rStr, ScDocument* pDoc, - const ScAddress::Details& rDetails ) + const ScAddress::Details& rDetails ) { if (rStr.isEmpty()) return 0; @@ -1586,7 +1588,7 @@ sal_uInt16 ScRange::ParseCols( const OUString& rStr, ScDocument* pDoc, // Parse only full row references sal_uInt16 ScRange::ParseRows( const OUString& rStr, ScDocument* pDoc, - const ScAddress::Details& rDetails ) + const ScAddress::Details& rDetails ) { if (rStr.isEmpty()) return 0; @@ -1643,59 +1645,55 @@ sal_uInt16 ScRange::ParseRows( const OUString& rStr, ScDocument* pDoc, return (p != NULL && *p == '\0') ? nRes : 0; } -static inline void -lcl_a1_append_c ( OUString &r, int nCol, bool bIsAbs ) +static inline void lcl_a1_append_c ( OUString &rString, int nCol, bool bIsAbs ) { if( bIsAbs ) - r += "$"; - ScColToAlpha( r, sal::static_int_cast<SCCOL>(nCol) ); + rString += "$"; + ScColToAlpha( rString, sal::static_int_cast<SCCOL>(nCol) ); } -static inline void -lcl_a1_append_r ( OUString &r, int nRow, bool bIsAbs ) +static inline void lcl_a1_append_r ( OUString &rString, int nRow, bool bIsAbs ) { if ( bIsAbs ) - r += "$"; - r += OUString::number( nRow+1 ); + rString += "$"; + rString += OUString::number( nRow+1 ); } -static inline void -lcl_r1c1_append_c ( OUString &r, int nCol, bool bIsAbs, - const ScAddress::Details& rDetails ) +static inline void lcl_r1c1_append_c ( OUString &rString, int nCol, bool bIsAbs, + const ScAddress::Details& rDetails ) { - r += "C"; + rString += "C"; if (bIsAbs) { - r += OUString::number( nCol + 1 ); + rString += OUString::number( nCol + 1 ); } else { nCol -= rDetails.nCol; if (nCol != 0) { - r += "[" + OUString::number( nCol ) + "]"; + rString += "[" + OUString::number( nCol ) + "]"; } } } -static inline void -lcl_r1c1_append_r ( OUString &r, int nRow, bool bIsAbs, - const ScAddress::Details& rDetails ) + +static inline void lcl_r1c1_append_r ( OUString &rString, int nRow, bool bIsAbs, + const ScAddress::Details& rDetails ) { - r += "R"; + rString += "R"; if (bIsAbs) { - r += OUString::number( nRow + 1 ); + rString += OUString::number( nRow + 1 ); } else { nRow -= rDetails.nRow; if (nRow != 0) { - r += "[" + OUString::number( nRow ) + "]"; + rString += "[" + OUString::number( nRow ) + "]"; } } } -static OUString -getFileNameFromDoc( const ScDocument* pDoc ) +static OUString getFileNameFromDoc( const ScDocument* pDoc ) { // TODO : er points at ScGlobal::GetAbsDocName() // as a better template. Look into it @@ -1721,7 +1719,7 @@ getFileNameFromDoc( const ScDocument* pDoc ) } OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc, - const Details& rDetails) const + const Details& rDetails) const { OUString r; if( nFlags & SCA_VALID ) @@ -1805,11 +1803,10 @@ OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc, return r; } -static void -lcl_Split_DocTab( const ScDocument* pDoc, SCTAB nTab, - const ScAddress::Details& rDetails, - sal_uInt16 nFlags, - OUString& rTabName, OUString& rDocName ) +static void lcl_Split_DocTab( const ScDocument* pDoc, SCTAB nTab, + const ScAddress::Details& rDetails, + sal_uInt16 nFlags, + OUString& rTabName, OUString& rDocName ) { pDoc->GetName(nTab, rTabName); rDocName = ""; @@ -1835,10 +1832,9 @@ lcl_Split_DocTab( const ScDocument* pDoc, SCTAB nTab, ScCompiler::CheckTabQuotes( rTabName, rDetails.eConv); } -static void -lcl_ScRange_Format_XL_Header( OUString& r, const ScRange& rRange, - sal_uInt16 nFlags, const ScDocument* pDoc, - const ScAddress::Details& rDetails ) +static void lcl_ScRange_Format_XL_Header( OUString& rString, const ScRange& rRange, + sal_uInt16 nFlags, const ScDocument* pDoc, + const ScAddress::Details& rDetails ) { if( nFlags & SCA_TAB_3D ) { @@ -1847,23 +1843,23 @@ lcl_ScRange_Format_XL_Header( OUString& r, const ScRange& rRange, aTabName, aDocName ); if( !aDocName.isEmpty() ) { - r += "[" + aDocName + "]"; + rString += "[" + aDocName + "]"; } - r += aTabName; + rString += aTabName; if( nFlags & SCA_TAB2_3D ) { lcl_Split_DocTab( pDoc, rRange.aEnd.Tab(), rDetails, nFlags, aTabName, aDocName ); - r += ":"; - r += aTabName; + rString += ":"; + rString += aTabName; } - r += "!"; + rString += "!"; } } OUString ScRange::Format( sal_uInt16 nFlags, const ScDocument* pDoc, - const ScAddress::Details& rDetails ) const + const ScAddress::Details& rDetails ) const { if( !( nFlags & SCA_VALID ) ) { |