sc/source/filter/inc/formulabuffer.hxx |   25 ++++++++-------
 sc/source/filter/oox/formulabuffer.cxx |   53 ++++++++++++++++-----------------
 2 files changed, 40 insertions(+), 38 deletions(-)

New commits:
commit b326c1d728e65afea4257d1142a02185ae6bc4d0
Author: Noel Power <noel.po...@novell.com>
Date:   Thu Jun 21 19:05:17 2012 +0100

    some const correctness tweaks to various signatures in new formulabuffer
    
    Change-Id: Ic6570608ac98c51438b583b7a75fa940b29b7473

diff --git a/sc/source/filter/inc/formulabuffer.hxx 
b/sc/source/filter/inc/formulabuffer.hxx
index aabd5ff..0097dc7 100644
--- a/sc/source/filter/inc/formulabuffer.hxx
+++ b/sc/source/filter/inc/formulabuffer.hxx
@@ -45,14 +45,14 @@ struct TokenAddressItem
 {
     ::rtl::OUString maTokenStr;
     ::com::sun::star::table::CellAddress maCellAddress;
-    TokenAddressItem( rtl::OUString& rTokenStr, 
::com::sun::star::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), 
maCellAddress( rCellAddress ) {}
+    TokenAddressItem( const rtl::OUString& rTokenStr, const 
::com::sun::star::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), 
maCellAddress( rCellAddress ) {}
 };
 
 struct TokenRangeAddressItem
 {
     TokenAddressItem maTokenAndAddress;
     ::com::sun::star::table::CellRangeAddress maCellRangeAddress;
-    TokenRangeAddressItem( TokenAddressItem& rTokenAndAddress, 
::com::sun::star::table::CellRangeAddress& rCellRangeAddress ) : 
maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) 
{}
+    TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const 
::com::sun::star::table::CellRangeAddress& rCellRangeAddress ) : 
maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) 
{}
 };
 
 typedef ::std::map< sal_Int32, std::vector< TokenAddressItem > > 
FormulaDataMap;
@@ -69,8 +69,8 @@ typedef ::std::map< sal_Int32, SharedIdToTokenIndex > 
SheetToSharedIdToTokenInde
 typedef ::std::pair< ::com::sun::star::table::CellAddress, double > 
ValueAddressPair;
 typedef ::std::map< sal_Int32, std::vector< ValueAddressPair > > 
FormulaValueMap;
 
-    void createSharedFormula(  ::com::sun::star::table::CellAddress& rAddress, 
 sal_Int32 nSharedId, const rtl::OUString& rTokens );
-    ::com::sun::star::uno::Reference< com::sun::star::table::XCellRange > 
getRange( ::com::sun::star::table::CellRangeAddress& rRange);
+    void createSharedFormula(  const ::com::sun::star::table::CellAddress& 
rAddress,  sal_Int32 nSharedId, const rtl::OUString& rTokens );
+    ::com::sun::star::uno::Reference< com::sun::star::table::XCellRange > 
getRange( const ::com::sun::star::table::CellRangeAddress& rRange);
     ::com::sun::star::uno::Reference< com::sun::star::table::XCell > getCell( 
::com::sun::star::table::CellAddress& rAddress );
     com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheet > 
mxCurrSheet;
     FormulaDataMap      cellFormulas;
@@ -80,18 +80,19 @@ typedef ::std::map< sal_Int32, std::vector< 
ValueAddressPair > > FormulaValueMap
     SheetToSharedIdToTokenIndex tokenIndexes;
     FormulaValueMap        cellFormulaValues;
 
-    void                applyArrayFormulas(  std::vector< 
TokenRangeAddressItem >& rVector );
-    void                applyCellFormulas(  std::vector< TokenAddressItem >& 
rVector );
-    void                applyCellFormulaValues( std::vector< ValueAddressPair 
>& rVector );
+    void                applyArrayFormulas(  const std::vector< 
TokenRangeAddressItem >& rVector );
+    void                applyCellFormula( ScDocument& rDoc, const 
ApiTokenSequence& rTokens, const ::com::sun::star::table::CellAddress& rAddress 
);
+    void                applyCellFormulas(  const std::vector< 
TokenAddressItem >& rVector );
+    void                applyCellFormulaValues( const std::vector< 
ValueAddressPair >& rVector );
 
 public:
     explicit            FormulaBuffer( const WorkbookHelper& rHelper );
     void                finalizeImport();
-    void                setCellFormula( ::com::sun::star::table::CellAddress& 
rAddress, rtl::OUString&  );
-    void                setCellFormula( ::com::sun::star::table::CellAddress& 
rAddress, sal_Int32 nSharedId );
-    void                setCellFormulaValue( 
::com::sun::star::table::CellAddress& rAddress, double fValue  );
-    void                setCellArrayFormula( 
::com::sun::star::table::CellRangeAddress& rRangeAddress, 
::com::sun::star::table::CellAddress& rTokenAddress, rtl::OUString&  );
-    void                
createSharedFormulaMapEntry(::com::sun::star::table::CellAddress& rAddress, 
sal_Int32 nSharedId, const rtl::OUString& rTokens );
+    void                setCellFormula( const 
::com::sun::star::table::CellAddress& rAddress, const rtl::OUString&  );
+    void                setCellFormula( const 
::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId );
+    void                setCellFormulaValue( const 
::com::sun::star::table::CellAddress& rAddress, double fValue  );
+    void                setCellArrayFormula( const 
::com::sun::star::table::CellRangeAddress& rRangeAddress, const 
::com::sun::star::table::CellAddress& rTokenAddress, const rtl::OUString&  );
+    void                createSharedFormulaMapEntry( const 
::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId, const 
rtl::OUString& rTokens );
 };
 }
 }
diff --git a/sc/source/filter/oox/formulabuffer.cxx 
b/sc/source/filter/oox/formulabuffer.cxx
index 7d8ec1a..a82e195 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -35,7 +35,7 @@ FormulaBuffer::FormulaBuffer( const WorkbookHelper& rHelper ) 
: WorkbookHelper(
 {
 }
 
-Reference< XCellRange > FormulaBuffer::getRange( CellRangeAddress& rRange)
+Reference< XCellRange > FormulaBuffer::getRange( const CellRangeAddress& 
rRange)
 {
     Reference< XCellRange > xRange;
     try
@@ -101,10 +101,7 @@ void FormulaBuffer::finalizeImport()
                 if ( itTokenId != rTokenIdMap.end() )
                 {
                     ApiTokenSequence aTokens =  
getFormulaParser().convertNameToFormula( itTokenId->second );
-                    Reference< XFormulaTokens > xTokens( getCell( rAddress ), 
UNO_QUERY );
-                    OSL_ENSURE( xTokens.is(), "FormulaBuffer::finalizeImport - 
missing token interface" );
-                    if( xTokens.is() ) xTokens->setTokens( aTokens );
-
+                    applyCellFormula( rDoc, aTokens, rAddress );
                 }
             }
         }
@@ -132,27 +129,31 @@ void FormulaBuffer::finalizeImport()
     rDoc.SetAutoNameCache( NULL );
     xFormulaBar->setPosition( 1.0 );
 }
-
-void FormulaBuffer::applyCellFormulas( std::vector< TokenAddressItem >& 
rVector )
+void FormulaBuffer::applyCellFormula( ScDocument& rDoc, const 
ApiTokenSequence& rTokens, const ::com::sun::star::table::CellAddress& rAddress 
)
 {
-    ScDocument& rDoc = getScDocument();
-    for ( std::vector< TokenAddressItem >::iterator it = rVector.begin(), 
it_end = rVector.end(); it != it_end; ++it )
-    {
-        ::com::sun::star::table::CellAddress& rAddress = it->maCellAddress;
-        ApiTokenSequence rTokens = getFormulaParser().importFormula( rAddress, 
it->maTokenStr );
         ScTokenArray aTokenArray;
         ScAddress aCellPos;
         ScUnoConversion::FillScAddress( aCellPos, rAddress );
         ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
         ScBaseCell* pNewCell = new ScFormulaCell( &rDoc, aCellPos, 
&aTokenArray );
         rDoc.PutCell( aCellPos, pNewCell, sal_True );
+}
+
+void FormulaBuffer::applyCellFormulas( const std::vector< TokenAddressItem >& 
rVector )
+{
+    ScDocument& rDoc = getScDocument();
+    for ( std::vector< TokenAddressItem >::const_iterator it = 
rVector.begin(), it_end = rVector.end(); it != it_end; ++it )
+    {
+        const ::com::sun::star::table::CellAddress& rAddress = 
it->maCellAddress;
+        ApiTokenSequence aTokens = getFormulaParser().importFormula( rAddress, 
it->maTokenStr );
+        applyCellFormula( rDoc, aTokens, rAddress );
     }
 }
 
-void FormulaBuffer::applyCellFormulaValues( std::vector< ValueAddressPair >& 
rVector )
+void FormulaBuffer::applyCellFormulaValues( const std::vector< 
ValueAddressPair >& rVector )
 {
     ScDocument& rDoc = getScDocument();
-    for ( std::vector< ValueAddressPair >::iterator it = rVector.begin(), 
it_end = rVector.end(); it != it_end; ++it )
+    for ( std::vector< ValueAddressPair >::const_iterator it = 
rVector.begin(), it_end = rVector.end(); it != it_end; ++it )
     {
         ScAddress aCellPos;
         ScUnoConversion::FillScAddress( aCellPos, it->first );
@@ -167,55 +168,55 @@ void FormulaBuffer::applyCellFormulaValues( std::vector< 
ValueAddressPair >& rVe
     }
 }
 
-void FormulaBuffer::applyArrayFormulas( std::vector< TokenRangeAddressItem >& 
rVector )
+void FormulaBuffer::applyArrayFormulas( const std::vector< 
TokenRangeAddressItem >& rVector )
 {
-    for ( std::vector< TokenRangeAddressItem >::iterator it = rVector.begin(), 
it_end = rVector.end(); it != it_end; ++it )
+    for ( std::vector< TokenRangeAddressItem >::const_iterator it = 
rVector.begin(), it_end = rVector.end(); it != it_end; ++it )
     {
         Reference< XArrayFormulaTokens > xTokens( getRange( 
it->maCellRangeAddress ), UNO_QUERY );
         OSL_ENSURE( xTokens.is(), "SheetDataBuffer::finalizeArrayFormula - 
missing formula token interface" );
-        ApiTokenSequence rTokens = getFormulaParser().importFormula( 
it->maTokenAndAddress.maCellAddress, it->maTokenAndAddress.maTokenStr );
+        ApiTokenSequence aTokens = getFormulaParser().importFormula( 
it->maTokenAndAddress.maCellAddress, it->maTokenAndAddress.maTokenStr );
         if( xTokens.is() )
-            xTokens->setArrayTokens( rTokens );
+            xTokens->setArrayTokens( aTokens );
     }
 }
 
-void 
FormulaBuffer::createSharedFormulaMapEntry(::com::sun::star::table::CellAddress&
 rAddress, sal_Int32 nSharedId, const rtl::OUString& rTokens )
+void FormulaBuffer::createSharedFormulaMapEntry( const 
::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId, const 
rtl::OUString& rTokens )
 {
      std::vector<SharedFormulaEntry>& rSharedFormulas = sharedFormulas[ 
rAddress.Sheet ];
     SharedFormulaEntry aEntry( rAddress, rTokens, nSharedId );
     rSharedFormulas.push_back( aEntry );
 }
 
-void FormulaBuffer::setCellFormula( ::com::sun::star::table::CellAddress& 
rAddress, rtl::OUString& rTokenStr )
+void FormulaBuffer::setCellFormula( const 
::com::sun::star::table::CellAddress& rAddress, const rtl::OUString& rTokenStr )
 {
     cellFormulas[ rAddress.Sheet ].push_back( TokenAddressItem( rTokenStr, 
rAddress ) );
 }
 
-void FormulaBuffer::setCellFormula( ::com::sun::star::table::CellAddress& 
rAddress, sal_Int32 nSharedId )
+void FormulaBuffer::setCellFormula( const 
::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId )
 {
     sharedFormulaIds[ rAddress.Sheet ].push_back( SharedFormulaDesc( rAddress, 
nSharedId ) );
 }
 
-void FormulaBuffer::setCellArrayFormula( 
::com::sun::star::table::CellRangeAddress& rRangeAddress, 
::com::sun::star::table::CellAddress& rTokenAddress, rtl::OUString& rTokenStr )
+void FormulaBuffer::setCellArrayFormula( const 
::com::sun::star::table::CellRangeAddress& rRangeAddress, const 
::com::sun::star::table::CellAddress& rTokenAddress, const rtl::OUString& 
rTokenStr )
 {
 
     TokenAddressItem tokenPair( rTokenStr, rTokenAddress );
     cellArrayFormulas[ rRangeAddress.Sheet ].push_back( TokenRangeAddressItem( 
tokenPair, rRangeAddress ) );
 }
 
-void FormulaBuffer::setCellFormulaValue( ::com::sun::star::table::CellAddress& 
rAddress, double fValue )
+void FormulaBuffer::setCellFormulaValue( const 
::com::sun::star::table::CellAddress& rAddress, double fValue )
 {
     cellFormulaValues[ rAddress.Sheet ].push_back( ValueAddressPair( rAddress, 
fValue ) );
 }
 
-void  FormulaBuffer::createSharedFormula(::com::sun::star::table::CellAddress& 
rAddress,  sal_Int32 nSharedId, const rtl::OUString& rTokenStr )
+void  FormulaBuffer::createSharedFormula( const 
::com::sun::star::table::CellAddress& rAddress,  sal_Int32 nSharedId, const 
rtl::OUString& rTokenStr )
 {
-    ApiTokenSequence rTokens = getFormulaParser().importFormula( rAddress, 
rTokenStr );
+    ApiTokenSequence aTokens = getFormulaParser().importFormula( rAddress, 
rTokenStr );
     rtl::OUString aName = rtl::OUStringBuffer().appendAscii( 
RTL_CONSTASCII_STRINGPARAM( "__shared_" ) ).
         append( static_cast< sal_Int32 >( rAddress.Sheet + 1 ) ).
         append( sal_Unicode( '_' ) ).append( nSharedId ).
         append( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_0") ) 
).makeStringAndClear();
-    ScRangeData* pScRangeData  = createNamedRangeObject( aName, rTokens, 0  );
+    ScRangeData* pScRangeData  = createNamedRangeObject( aName, aTokens, 0  );
 
     pScRangeData->SetType(RT_SHARED);
     sal_Int32 nTokenIndex = static_cast< sal_Int32 >( pScRangeData->GetIndex() 
);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to