chart2/source/view/axes/VCartesianAxis.cxx | 70 ++++++----------- chart2/source/view/axes/VCartesianAxis.hxx | 4 sc/inc/cell.hxx | 18 +--- sc/inc/compiler.hxx | 1 sc/source/core/data/cell.cxx | 55 +++++-------- sc/source/core/data/cell2.cxx | 32 +++---- sc/source/core/data/table6.cxx | 47 ++++++----- sc/source/core/tool/cellform.cxx | 38 ++++----- sc/source/core/tool/compiler.cxx | 8 + sc/source/core/tool/interpr1.cxx | 2 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx | 2 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 10 -- sc/source/ui/docshell/impex.cxx | 4 sc/source/ui/unoobj/cellsuno.cxx | 2 sc/source/ui/view/output2.cxx | 6 - sc/source/ui/view/viewfun4.cxx | 4 svl/inc/svl/zforlist.hxx | 11 ++ svl/source/numbers/zforlist.cxx | 43 ++++++++++ 18 files changed, 197 insertions(+), 160 deletions(-)
New commits: commit a1410ef073d2117cb2a3c9d9a4e9ecff7d911344 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Mon Mar 5 22:05:51 2012 +0100 move some auto_ptr to boost::scoped_ptr diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 8291efb..264450d 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -51,7 +51,7 @@ #include <svx/unoshtxt.hxx> #include <algorithm> -#include <memory> +#include <boost/scoped_ptr.hpp> //............................................................................. namespace chart @@ -553,17 +553,14 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo VAxisBase::createAllTickInfos(rAllTickInfos); } -SAL_WNODEPRECATED_DECLARATIONS_PUSH -::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel ) +TickIter* VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel ) { if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) - return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) ); - return ::std::auto_ptr< TickIter >(); + new PureTickIter( m_aAllTickInfos[nTextLevel] ); + return NULL; } -SAL_WNODEPRECATED_DECLARATIONS_POP -SAL_WNODEPRECATED_DECLARATIONS_PUSH -::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel ) +TickIter* VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel ) { if( isComplexCategoryAxis() || isDateAxis() ) { @@ -576,13 +573,12 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH if( !m_aAllTickInfos.empty() ) { sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; - return ::std::auto_ptr< TickIter >( new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ) ); + new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ); } } } - return ::std::auto_ptr< TickIter >(); + return NULL; } -SAL_WNODEPRECATED_DECLARATIONS_POP sal_Int32 VCartesianAxis::getTextLevelCount() const { @@ -1332,16 +1328,14 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel B2DVector aCummulatedLabelsDistance(0,0); for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); - SAL_WNODEPRECATED_DECLARATIONS_POP - if(apTickIter.get()) - { - double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; - aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() - , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) - , fRotationAngleDegree ); - } + boost::scoped_ptr< TickIter > apTickIter(createLabelTickIterator( nTextLevel )); + if(apTickIter) + { + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; + aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) + , fRotationAngleDegree ); + } } } else if( rAxisLabelProperties.getIsStaggered() ) @@ -1367,9 +1361,7 @@ void VCartesianAxis::createLabels() //create labels if( m_aAxisProperties.m_bDisplayLabels ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); - SAL_WNODEPRECATED_DECLARATIONS_POP + boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); if( !pTickFactory2D ) return; @@ -1388,10 +1380,8 @@ void VCartesianAxis::createLabels() sal_Int32 nScreenDistanceBetweenTicks = -1; for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); - SAL_WNODEPRECATED_DECLARATIONS_POP - if(apTickIter.get()) + boost::scoped_ptr< TickIter > apTickIter(createLabelTickIterator( nTextLevel )); + if(apTickIter) { if(nTextLevel==0) { @@ -1428,9 +1418,7 @@ void VCartesianAxis::createMaximumLabels() //create labels if( m_aAxisProperties.m_bDisplayLabels ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); - SAL_WNODEPRECATED_DECLARATIONS_POP + boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); if( !pTickFactory2D ) return; @@ -1450,10 +1438,8 @@ void VCartesianAxis::createMaximumLabels() sal_Int32 nTextLevelCount = getTextLevelCount(); for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - ::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel ); - SAL_WNODEPRECATED_DECLARATIONS_POP - if(apTickIter.get()) + boost::scoped_ptr< TickIter > apTickIter(createMaximumLabelTickIterator( nTextLevel )); + if(apTickIter) { while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) ) { @@ -1470,9 +1456,7 @@ void VCartesianAxis::updatePositions() //update positions of labels if( m_aAxisProperties.m_bDisplayLabels ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); - SAL_WNODEPRECATED_DECLARATIONS_POP + boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); if( !pTickFactory2D ) return; @@ -1567,9 +1551,7 @@ void VCartesianAxis::createShapes() if( !prepareShapeCreation() ) return; - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); - SAL_WNODEPRECATED_DECLARATIONS_POP + boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); if( !pTickFactory2D ) return; @@ -1593,10 +1575,8 @@ void VCartesianAxis::createShapes() sal_Int32 nTextLevelCount = getTextLevelCount(); for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); - SAL_WNODEPRECATED_DECLARATIONS_POP - if( apTickIter.get() ) + boost::scoped_ptr< TickIter > apTickIter(createLabelTickIterator( nTextLevel )); + if( apTickIter ) { double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ), fRotationAngleDegree ) ); diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index 68c93bb..55ba354 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -66,8 +66,8 @@ public: virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ); void createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition ); - ::std::auto_ptr< TickIter > createLabelTickIterator( sal_Int32 nTextLevel ); - ::std::auto_ptr< TickIter > createMaximumLabelTickIterator( sal_Int32 nTextLevel ); + TickIter* createLabelTickIterator( sal_Int32 nTextLevel ); + TickIter* createMaximumLabelTickIterator( sal_Int32 nTextLevel ); sal_Int32 getTextLevelCount() const; //------------------------------------------------------------------------- commit 3f78f26aa8db1d3ae56d9e509e0a8e5b4518821b Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Mon Mar 5 21:31:06 2012 +0100 String to OUString in cell.[ch]xx and follow up diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index ebae2b4..08fbdfa 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -129,7 +129,7 @@ public: void DeleteBroadcaster(); // String- oder EditCell - static ScBaseCell* CreateTextCell( const String& rString, ScDocument* ); + static ScBaseCell* CreateTextCell( const rtl::OUString& rString, ScDocument* ); // nOnlyNames may be one or more of SC_LISTENING_NAMES_* void StartListeningTo( ScDocument* pDoc ); @@ -144,7 +144,7 @@ public: bool HasEmptyData() const; bool HasValueData() const; bool HasStringData() const; - String GetStringData() const; // only real strings + rtl::OUString GetStringData() const; // only real strings static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ); @@ -246,7 +246,7 @@ public: const SfxItemPool* pFromPool /* = NULL */ ); ScEditCell( const ScEditCell& rCell, ScDocument& rDoc ); // for line breaks - ScEditCell( const String& rString, ScDocument* ); + ScEditCell( const rtl::OUString& rString, ScDocument* ); void SetData( const EditTextObject* pObject, const SfxItemPool* pFromPool /* = NULL */ ); @@ -363,14 +363,12 @@ public: also includes formula::FormulaGrammar::CONV_UNSPECIFIED, therefor uses the address convention associated with rPos::nTab by default. */ ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, - const String& rFormula, + const rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, sal_uInt8 cMatInd = MM_NONE ); ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, const ScAddress& rPos, int nCloneFlags = SC_CLONECELL_DEFAULT ); - void GetFormula( String& rFormula, - const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; void GetFormula( rtl::OUString& rFormula, const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; void GetFormula( rtl::OUStringBuffer& rBuffer, @@ -387,7 +385,7 @@ public: void ResetDirty() { bDirty = false; } bool NeedsListening() const { return bNeedListening; } void SetNeedsListening( bool bVar ) { bNeedListening = bVar; } - void Compile(const String& rFormula, + void Compile(const rtl::OUString& rFormula, bool bNoListening = false, const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ); void CompileTokenArray( bool bNoListening = false ); @@ -427,7 +425,7 @@ public: void UpdateInsertTabAbs(SCTAB nTable); bool UpdateDeleteTab(SCTAB nTable, bool bIsMove = false, SCTAB nSheets = 1); void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo); - void UpdateRenameTab(SCTAB nTable, const String& rName); + void UpdateRenameTab(SCTAB nTable, const rtl::OUString& rName); bool TestTabRefAbs(SCTAB nTable); void UpdateCompile( bool bForceIfNameInUse = false ); void FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes) const; @@ -498,13 +496,13 @@ public: If for whatever reason you have to use both, SetHybridDouble() and SetHybridString() or SetHybridFormula(), use SetHybridDouble() first for performance reasons.*/ - void SetHybridFormula( const String& r, + void SetHybridFormula( const rtl::OUString& r, const formula::FormulaGrammar::Grammar eGrammar ) { aResult.SetHybridFormula( r); eTempGrammar = eGrammar; } void SetErrCode( sal_uInt16 n ); inline bool IsHyperLinkCell() const { return pCode && pCode->IsHyperLink(); } EditTextObject* CreateURLObject() ; - void GetURLResult( String& rURL, String& rCellText ); + void GetURLResult( rtl::OUString& rURL, rtl::OUString& rCellText ); /** Determines whether or not the result string contains more than one paragraph */ bool IsMultilineResult(); diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 371192c..84496b6 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -423,6 +423,7 @@ public: } void CreateStringFromXMLTokenArray( String& rFormula, String& rFormulaNmsp ); + void CreateStringFromXMLTokenArray( rtl::OUString& rFormula, rtl::OUString& rFormulaNmsp ); void SetExtendedErrorDetection( ExtendedErrorDetection eVal ) { meExtendedErrorDetection = eVal; } diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 5924cf8..6d5baaf 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -288,9 +288,9 @@ void ScBaseCell::DeleteBroadcaster() DELETEZ( mpBroadcaster ); } -ScBaseCell* ScBaseCell::CreateTextCell( const String& rString, ScDocument* pDoc ) +ScBaseCell* ScBaseCell::CreateTextCell( const rtl::OUString& rString, ScDocument* pDoc ) { - if ( rString.Search('\n') != STRING_NOTFOUND || rString.Search(CHAR_CR) != STRING_NOTFOUND ) + if ( rString.indexOf('\n') != -1 || rString.indexOf(CHAR_CR) != -1 ) return new ScEditCell( rString, pDoc ); else return new ScStringCell( rString ); @@ -523,9 +523,9 @@ bool ScBaseCell::HasStringData() const } } -String ScBaseCell::GetStringData() const +rtl::OUString ScBaseCell::GetStringData() const { - String aStr; + rtl::OUString aStr; switch ( eCellType ) { case CELLTYPE_STRING: @@ -573,12 +573,12 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 ) ((const ScValueCell*)pCell2)->GetValue() ); case CELLTYPE_STRING: // String oder Edit { - String aText1; + rtl::OUString aText1; if ( pCell1->GetCellType() == CELLTYPE_STRING ) aText1 = ((const ScStringCell*)pCell1)->GetString(); else aText1 = ((const ScEditCell*)pCell1)->GetString(); - String aText2; + rtl::OUString aText2; if ( pCell2->GetCellType() == CELLTYPE_STRING ) aText2 = ((const ScStringCell*)pCell2)->GetString(); else @@ -682,7 +682,7 @@ ScStringCell::~ScStringCell() // ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, - const String& rFormula, + const rtl::OUString& rFormula, const FormulaGrammar::Grammar eGrammar, sal_uInt8 cMatInd ) : ScBaseCell( CELLTYPE_FORMULA ), @@ -956,13 +956,6 @@ void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, } } -void ScFormulaCell::GetFormula( String& rFormula, const FormulaGrammar::Grammar eGrammar ) const -{ - rtl::OUStringBuffer rBuffer( rFormula ); - GetFormula( rBuffer, eGrammar ); - rFormula = rBuffer.makeStringAndClear(); -} - void ScFormulaCell::GetFormula( rtl::OUString& rFormula, const FormulaGrammar::Grammar eGrammar ) const { rtl::OUStringBuffer rBuffer( rFormula ); @@ -985,7 +978,7 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ) } } -void ScFormulaCell::Compile( const String& rFormula, bool bNoListening, +void ScFormulaCell::Compile( const rtl::OUString& rFormula, bool bNoListening, const FormulaGrammar::Grammar eGrammar ) { if ( pDocument->IsClipOrUndo() ) @@ -1004,12 +997,12 @@ void ScFormulaCell::Compile( const String& rFormula, bool bNoListening, delete pCodeOld; if( !pCode->GetCodeError() ) { - if ( !pCode->GetLen() && aResult.GetHybridFormula().Len() && rFormula == aResult.GetHybridFormula() ) + if ( !pCode->GetLen() && aResult.GetHybridFormula().Len() && rFormula == rtl::OUString(aResult.GetHybridFormula()) ) { // nicht rekursiv CompileTokenArray/Compile/CompileTokenArray - if ( rFormula.GetChar(0) == '=' ) - pCode->AddBad( rFormula.GetBuffer() + 1 ); + if ( rFormula[0] == '=' ) + pCode->AddBad( rFormula.copy(1) ); else - pCode->AddBad( rFormula.GetBuffer() ); + pCode->AddBad( rFormula ); } bCompile = true; CompileTokenArray( bNoListening ); @@ -1076,9 +1069,9 @@ void ScFormulaCell::CompileXML( ScProgress& rProgress ) ScCompiler aComp( pDocument, aPos, *pCode); aComp.SetGrammar(eTempGrammar); - String aFormula, aFormulaNmsp; + rtl::OUString aFormula, aFormulaNmsp; aComp.CreateStringFromXMLTokenArray( aFormula, aFormulaNmsp ); - pDocument->DecXMLImportedFormulaCount( aFormula.Len() ); + pDocument->DecXMLImportedFormulaCount( aFormula.getLength() ); rProgress.SetStateCountDownOnPercent( pDocument->GetXMLImportedFormulaCount() ); // pCode darf fuer Abfragen noch nicht geloescht, muss aber leer sein if ( pCode ) @@ -1090,10 +1083,10 @@ void ScFormulaCell::CompileXML( ScProgress& rProgress ) { if ( !pCode->GetLen() ) { - if ( aFormula.GetChar(0) == '=' ) - pCode->AddBad( aFormula.GetBuffer() + 1 ); + if ( aFormula[0] == '=' ) + pCode->AddBad( aFormula.copy( 1 ) ); else - pCode->AddBad( aFormula.GetBuffer() ); + pCode->AddBad( aFormula ); } bSubTotal = aComp.CompileTokenArray(); if( !pCode->GetCodeError() ) @@ -1466,8 +1459,8 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) // documents we might need another solution. Or just confirm correctness. OSL_FAIL( "ScFormulaCell::Interpret: no UPN, no error, no token, but string -> Try compiling it." ); // Force Compilation - String aFormula = aResult.GetHybridFormula(); - aResult.SetHybridFormula( String() ); + rtl::OUString aFormula = aResult.GetHybridFormula(); + aResult.SetHybridFormula( rtl::OUString() ); Compile( aFormula ); InterpretTail( eTailParam ); return; @@ -1915,9 +1908,9 @@ void ScFormulaCell::AddRecalcMode( ScRecalcMode nBits ) } // Dynamically create the URLField on a mouse-over action on a hyperlink() cell. -void ScFormulaCell::GetURLResult( String& rURL, String& rCellText ) +void ScFormulaCell::GetURLResult( rtl::OUString& rURL, rtl::OUString& rCellText ) { - String aCellString; + rtl::OUString aCellString; Color* pColor; @@ -1952,7 +1945,7 @@ void ScFormulaCell::GetURLResult( String& rURL, String& rCellText ) pFormatter->GetOutputString( nMatVal.fVal, nURLFormat, rURL, &pColor ); } - if(!rURL.Len()) + if(rURL.isEmpty()) { if(IsValue()) pFormatter->GetOutputString( GetValue(), nURLFormat, rURL, &pColor ); @@ -1979,8 +1972,8 @@ void ScFormulaCell::MaybeInterpret() EditTextObject* ScFormulaCell::CreateURLObject() { - String aCellText; - String aURL; + rtl::OUString aCellText; + rtl::OUString aURL; GetURLResult( aURL, aCellText ); SvxURLField aUrlField( aURL, aCellText, SVXURLFORMAT_APPDEFAULT); diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 5938e15..de24d11 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -81,13 +81,13 @@ ScEditCell::ScEditCell( const ScEditCell& rCell, ScDocument& rDoc ) : SetTextObject( rCell.pData, rCell.pDoc->GetEditPool() ); } -ScEditCell::ScEditCell( const String& rString, ScDocument* pDocP ) : +ScEditCell::ScEditCell( const rtl::OUString& rString, ScDocument* pDocP ) : ScBaseCell( CELLTYPE_EDIT ), pString( NULL ), pDoc( pDocP ) { - OSL_ENSURE( rString.Search('\n') != STRING_NOTFOUND || - rString.Search(CHAR_CR) != STRING_NOTFOUND, + OSL_ENSURE( rString.indexOf('\n') != -1 || + rString.indexOf(CHAR_CR) != -1, "EditCell mit einfachem Text !?!?" ); EditEngine& rEngine = pDoc->GetEditEngine(); @@ -654,7 +654,7 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) else { #if OSL_DEBUG_LEVEL > 0 - String aTmp; + rtl::OUString aTmp; rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM( "broken Matrix, no MatFormula at origin, Pos: ")); aPos.Format( aTmp, SCA_VALID_COL | SCA_VALID_ROW, pDocument ); @@ -1614,14 +1614,14 @@ void ScFormulaCell::CompileDBFormula( bool bCreateFormulaString ) } if ( bRecompile ) { - String aFormula; + rtl::OUString aFormula; GetFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE); - if ( GetMatrixFlag() != MM_NONE && aFormula.Len() ) + if ( GetMatrixFlag() != MM_NONE && !aFormula.isEmpty() ) { - if ( aFormula.GetChar( aFormula.Len()-1 ) == '}' ) - aFormula.Erase( aFormula.Len()-1 , 1 ); - if ( aFormula.GetChar(0) == '{' ) - aFormula.Erase( 0, 1 ); + if ( aFormula[ aFormula.getLength()-1 ] == '}' ) + aFormula = aFormula.copy( aFormula.getLength()-1 , 1 ); + if ( aFormula[0] == '{' ) + aFormula = aFormula.copy( 1 ); } EndListeningTo( pDocument ); pDocument->RemoveFromFormulaTree( this ); @@ -1661,14 +1661,14 @@ void ScFormulaCell::CompileNameFormula( bool bCreateFormulaString ) } if ( bRecompile ) { - String aFormula; + rtl::OUString aFormula; GetFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE); - if ( GetMatrixFlag() != MM_NONE && aFormula.Len() ) + if ( GetMatrixFlag() != MM_NONE && !aFormula.isEmpty() ) { - if ( aFormula.GetChar( aFormula.Len()-1 ) == '}' ) - aFormula.Erase( aFormula.Len()-1 , 1 ); - if ( aFormula.GetChar(0) == '{' ) - aFormula.Erase( 0, 1 ); + if ( aFormula[ aFormula.getLength()-1 ] == '}' ) + aFormula = aFormula.copy( 0, aFormula.getLength()-1 ); + if ( aFormula[0] == '{' ) + aFormula = aFormula.copy( 1 ); } EndListeningTo( pDocument ); pDocument->RemoveFromFormulaTree( this ); diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 3ef92e1..45bf02e 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -49,7 +49,9 @@ using ::com::sun::star::util::SearchOptions; -bool lcl_GetTextWithBreaks( const ScEditCell& rCell, ScDocument* pDoc, String& rVal ) +namespace { + +bool lcl_GetTextWithBreaks( const ScEditCell& rCell, ScDocument* pDoc, rtl::OUString& rVal ) { // true = more than 1 paragraph @@ -61,6 +63,8 @@ bool lcl_GetTextWithBreaks( const ScEditCell& rCell, ScDocument* pDoc, String& r return ( rEngine.GetParagraphCount() > 1 ); } +} + bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow, const ScMarkData& rMark, rtl::OUString& rUndoStr, ScDocument* pUndoDoc) { @@ -68,7 +72,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo bool bDoSearch = true; bool bDoBack = rSearchItem.GetBackward(); - String aString; + rtl::OUString aString; ScBaseCell* pCell; if (rSearchItem.GetSelection()) bDoSearch = rMark.IsCellMarked(nCol, nRow); @@ -87,9 +91,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo *(const ScEditCell*)pCell, pDocument, aString ); else { - rtl::OUString aOUString = aString; - aCol[nCol].GetInputString( nRow, aOUString ); - aString = aOUString; + aCol[nCol].GetInputString( nRow, aString ); } } break; @@ -99,9 +101,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo *(const ScEditCell*)pCell, pDocument, aString ); else { - rtl::OUString aOUString = aString; - aCol[nCol].GetInputString( nRow, aOUString ); - aString = aOUString; + aCol[nCol].GetInputString( nRow, aString ); } break; case SVX_SEARCHIN_NOTE: @@ -110,7 +110,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo break; } xub_StrLen nStart = 0; - xub_StrLen nEnd = aString.Len(); + xub_StrLen nEnd = aString.getLength(); ::com::sun::star::util::SearchResult aSearchResult; if (pSearchText) { @@ -129,7 +129,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo } if (bFound && rSearchItem.GetWordOnly()) - bFound = (nStart == 0 && nEnd == aString.Len() - 1); + bFound = (nStart == 0 && nEnd == aString.getLength() - 1); } else { @@ -168,15 +168,18 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo String sReplStr = rSearchItem.GetReplaceString(); if (rSearchItem.GetRegExp()) { - String sFndStr = aString.Copy(nStart, nEnd-nStart+1); pSearchText->ReplaceBackReferences( sReplStr, aString, aSearchResult ); - aString.Erase(nStart, nEnd-nStart+1); - aString.Insert(sReplStr, nStart); + rtl::OUStringBuffer aStrBuffer(aString); + aStrBuffer.remove(nStart, nEnd-nStart+1); + aStrBuffer.insert(nStart, sReplStr); + aString = aStrBuffer.makeStringAndClear(); } else { - aString.Erase(nStart, nEnd - nStart + 1); - aString.Insert(rSearchItem.GetReplaceString(), nStart); + rtl::OUStringBuffer aStrBuffer(aString); + aStrBuffer.remove(nStart, nEnd-nStart+1); + aStrBuffer.insert(nStart, rSearchItem.GetReplaceString()); + aString = aStrBuffer.makeStringAndClear(); } // Indizes anpassen @@ -188,7 +191,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo else { nStart = sal::static_int_cast<xub_StrLen>( nStart + sReplStr.Len() ); - nEnd = aString.Len(); + nEnd = aString.getLength(); } // weitersuchen ? @@ -215,12 +218,12 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo if ( cMatrixFlag != MM_NONE ) { // Matrix nicht zerreissen - if ( aString.Len() > 2 ) + if ( aString.getLength() > 2 ) { // {} raus, erst hier damit auch "{=" durch "{=..." ersetzt werden kann - if ( aString.GetChar( aString.Len()-1 ) == '}' ) - aString.Erase( aString.Len()-1, 1 ); - if ( aString.GetChar(0) == '{' ) - aString.Erase( 0, 1 ); + if ( aString[ aString.getLength()-1 ] == '}' ) + aString = aString.copy( 0, aString.getLength()-1 ); + if ( aString[0] == '{' ) + aString = aString.copy( 1 ); } ScAddress aAdr( nCol, nRow, nTab ); ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr, @@ -231,7 +234,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo pFCell->SetMatColsRows( nMatCols, nMatRows ); aCol[nCol].Insert( nRow, pFCell ); } - else if ( bMultiLine && aString.Search('\n') != STRING_NOTFOUND ) + else if ( bMultiLine && aString.indexOf('\n') != -1 ) PutCell( nCol, nRow, new ScEditCell( aString, pDocument ) ); else aCol[nCol].SetString(nRow, nTab, aString, pDocument->GetAddressConvention()); diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 066b5c1..f33a48c 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -58,27 +58,26 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin return; } - String aString = rString; CellType eType = pCell->GetCellType(); switch(eType) { case CELLTYPE_STRING: { - String aCellString = ((ScStringCell*)pCell)->GetString(); - rFormatter.GetOutputString( aCellString, nFormat, aString, ppColor ); + rtl::OUString aCellString = ((ScStringCell*)pCell)->GetString(); + rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor ); } break; case CELLTYPE_EDIT: { - String aCellString = ((ScEditCell*)pCell)->GetString(); - rFormatter.GetOutputString( aCellString, nFormat, aString, ppColor ); + rtl::OUString aCellString = ((ScEditCell*)pCell)->GetString(); + rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor ); } break; case CELLTYPE_VALUE: { double nValue = ((ScValueCell*)pCell)->GetValue(); if ( !bNullVals && nValue == 0.0 ) - aString.Erase(); + rString = rtl::OUString(); else { if( eForceTextFmt == ftCheck ) @@ -88,12 +87,12 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin } if( eForceTextFmt == ftForce ) { - String aTemp; + rtl::OUString aTemp; rFormatter.GetOutputString( nValue, 0, aTemp, ppColor ); - rFormatter.GetOutputString( aTemp, nFormat, aString, ppColor ); + rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor ); } else - rFormatter.GetOutputString( nValue, nFormat, aString, ppColor ); + rFormatter.GetOutputString( nValue, nFormat, rString, ppColor ); } } break; @@ -101,7 +100,9 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin { ScFormulaCell* pFCell = (ScFormulaCell*)pCell; if ( bFormula ) - pFCell->GetFormula( aString ); + { + pFCell->GetFormula( rString ); + } else { // A macro started from the interpreter, which has @@ -114,7 +115,7 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin (!pFCell->GetDocument()->GetMacroInterpretLevel() || pFCell->IsRunning()) ) { - aString.AssignAscii( RTL_CONSTASCII_STRINGPARAM("...") ); + rString = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("...")); } else { @@ -126,31 +127,30 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin nFormat ); if (nErrCode != 0) - aString = ScGlobal::GetErrorString(nErrCode); + rString = ScGlobal::GetErrorString(nErrCode); else if ( pFCell->IsEmptyDisplayedAsString() ) - aString.Erase(); + rString = rtl::OUString(); else if ( pFCell->IsValue() ) { double fValue = pFCell->GetValue(); if ( !bNullVals && fValue == 0.0 ) - aString.Erase(); + rString = rtl::OUString(); else - rFormatter.GetOutputString( fValue, nFormat, aString, ppColor ); + rFormatter.GetOutputString( fValue, nFormat, rString, ppColor ); } else { - String aCellString = pFCell->GetString(); - rFormatter.GetOutputString( aCellString, nFormat, aString, ppColor ); + rtl::OUString aCellString = pFCell->GetString(); + rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor ); } } } } break; default: - aString.Erase(); + rString = rtl::OUString(); break; } - rString = aString; } void ScCellFormat::GetInputString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString, diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 454fab9..9b2fa2e 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3730,6 +3730,14 @@ void ScCompiler::CreateStringFromXMLTokenArray( String& rFormula, String& rFormu } } +void ScCompiler::CreateStringFromXMLTokenArray( rtl::OUString& rFormula, rtl::OUString& rFormulaNmsp ) +{ + String sFormula, aFormulaNmsp; + CreateStringFromXMLTokenArray(sFormula, aFormulaNmsp); + rFormula = sFormula; + rFormulaNmsp = aFormulaNmsp; +} + ScTokenArray* ScCompiler::CompileString( const String& rFormula ) { OSL_ENSURE( meGrammar != FormulaGrammar::GRAM_EXTERNAL, "ScCompiler::CompileString - unexpected grammar GRAM_EXTERNAL" ); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index e1eb8bd..fb8e429 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2569,7 +2569,7 @@ void ScInterpreter::ScIsFormula() void ScInterpreter::ScFormula() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScFormula" ); - String aFormula; + rtl::OUString aFormula; switch ( GetStackType() ) { case svDoubleRef : diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index 45f7e91..53c0593 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -346,7 +346,7 @@ void ScChangeTrackingExportHelper::WriteFormulaCell(const ScBaseCell* pCell, con rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_ADDRESS, sAddress); const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar(); sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC); - String sFormula; + rtl::OUString sFormula; pFormulaCell->GetFormula(sFormula, eGrammar); rtl::OUString sOUFormula(sFormula); sal_uInt8 nMatrixFlag(pFormulaCell->GetMatrixFlag()); diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index ccb7367..7364c39 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -752,28 +752,26 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(ScMyContentAction* pAction) else { sal_uInt8 nMatrixFlag = static_cast<ScFormulaCell*>(pCell)->GetMatrixFlag(); - String sFormula; + rtl::OUString sFormula; // With GRAM_ODFF reference detection is faster on compilation. /* FIXME: new cell should be created with a clone * of the token array instead. Any reason why this * wasn't done? */ static_cast<ScFormulaCell*>(pCell)->GetFormula(sFormula,formula::FormulaGrammar::GRAM_ODFF); - rtl::OUString sOUFormula(sFormula); // #i87826# [Collaboration] Rejected move destroys formulas // FIXME: adjust ScFormulaCell::GetFormula(), so that the right formula string // is returned and no further string handling is necessary - rtl::OUString sOUFormula2; + rtl::OUString sFormula2; if ( nMatrixFlag != MM_NONE ) { - sOUFormula2 = sOUFormula.copy( 2, sOUFormula.getLength() - 3 ); + sFormula2 = sFormula.copy( 2, sFormula.getLength() - 3 ); } else { - sOUFormula2 = sOUFormula.copy( 1, sOUFormula.getLength() - 1 ); + sFormula2 = sFormula.copy( 1, sFormula.getLength() - 1 ); } - String sFormula2(sOUFormula2); pNewCell = new ScFormulaCell(pDoc, aAddress, sFormula2,formula::FormulaGrammar::GRAM_ODFF, nMatrixFlag); if (pNewCell) { diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 6dc095b..7bb959e 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1870,7 +1870,9 @@ sal_Bool ScImportExport::Doc2Sylk( SvStream& rStrm ) aCellStr.Erase(); break; default: - pFCell->GetFormula( aCellStr,formula::FormulaGrammar::GRAM_PODF_A1); + rtl::OUString aOUCellStr; + pFCell->GetFormula( aOUCellStr,formula::FormulaGrammar::GRAM_PODF_A1); + aCellStr = aOUCellStr; /* FIXME: do we want GRAM_ODFF_A1 instead? At * the end it probably should be * GRAM_ODFF_R1C1, since R1C1 is what Excel diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 39926f4..c82e56a 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -5127,7 +5127,7 @@ rtl::OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeExcep // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren. // Sonst Leerstring. - String aFormula; + rtl::OUString aFormula; ScDocShell* pDocSh = GetDocShell(); if (pDocSh) { diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 8122c94..ab9783e 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -785,8 +785,8 @@ void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, ScBaseCe { vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() ); - String aCellText; - String aURL; + rtl::OUString aCellText; + rtl::OUString aURL; if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) { ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); @@ -794,7 +794,7 @@ void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, ScBaseCe pFCell->GetURLResult( aURL, aCellText ); } - if ( aURL.Len() && pPDFData ) + if ( !aURL.isEmpty() && pPDFData ) { vcl::PDFExtOutDevBookmarkEntry aBookmark; aBookmark.nLinkId = pPDFData->CreateLink( rRect ); diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 86c4496..94672a7 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -255,9 +255,9 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord ) { if (pCell->GetCellType() == CELLTYPE_FORMULA) { - String aOld; + rtl::OUString aOld; ((ScFormulaCell*)pCell)->GetFormula(aOld); - xub_StrLen nLen = aOld.Len(); + xub_StrLen nLen = aOld.getLength(); ScRefFinder aFinder( aOld, aIter.GetPos(), pDoc, pDoc->GetAddressConvention() ); aFinder.ToggleRel( 0, nLen ); if (aFinder.GetFound()) diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx index 69645e1..30d1929 100644 --- a/svl/inc/svl/zforlist.hxx +++ b/svl/inc/svl/zforlist.hxx @@ -481,12 +481,23 @@ public: void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex, String& sOutString, Color** ppColor ); + /// Format a number according to a format index, return string and color + void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex, + rtl::OUString& sOutString, Color** ppColor ); + /** Format a string according to a format index, return string and color. Formats only if the format code is of type text or the 4th subcode of a format code is specified, otherwise sOutString will be == "" */ void GetOutputString( String& sString, sal_uInt32 nFIndex, String& sOutString, Color** ppColor ); + + /** Format a string according to a format index, return string and color. + Formats only if the format code is of type text or the 4th subcode + of a format code is specified, otherwise sOutString will be == "" */ + void GetOutputString( rtl::OUString& sString, sal_uInt32 nFIndex, + rtl::OUString& sOutString, Color** ppColor ); + /** Format a number according to the standard default format matching the given format index */ void GetInputLineString( const double& fOutNumber, diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index c454843..475551e 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1568,6 +1568,49 @@ void SvNumberFormatter::GetOutputString(String& sString, } } +void SvNumberFormatter::GetOutputString(const double& fOutNumber, + sal_uInt32 nFIndex, + rtl::OUString& sOutString, + Color** ppColor) +{ + if (bNoZero && fOutNumber == 0.0) + { + sOutString = rtl::OUString(); + return; + } + SvNumberformat* pFormat = GetFormatEntry( nFIndex ); + if (!pFormat) + pFormat = GetFormatEntry(ZF_STANDARD); + ChangeIntl(pFormat->GetLanguage()); + String aOutString; + pFormat->GetOutputString(fOutNumber, aOutString, ppColor); + sOutString = aOutString; +} + +void SvNumberFormatter::GetOutputString(rtl::OUString& sString, + sal_uInt32 nFIndex, + rtl::OUString& sOutString, + Color** ppColor) +{ + SvNumberformat* pFormat = GetFormatEntry( nFIndex ); + if (!pFormat) + pFormat = GetFormatEntry(ZF_STANDARD_TEXT); + if (!pFormat->IsTextFormat() && !pFormat->HasTextFormat()) + { + *ppColor = NULL; + sOutString = sString; + } + else + { + ChangeIntl(pFormat->GetLanguage()); + String aString = sString; + String aOutString = sOutString; + pFormat->GetOutputString(aString, aOutString, ppColor); + sString = aString; + sOutString = aOutString; + } +} + bool SvNumberFormatter::GetPreviewString(const String& sFormatString, double fPreviewNumber, String& sOutString, _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits