[Libreoffice-commits] .: 2 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Sat May 28 14:59:33 PDT 2011
sc/inc/chartarr.hxx | 36 +++++++++---------
sc/source/core/data/documen5.cxx | 2 -
sc/source/core/tool/chartarr.cxx | 77 ++++++++++++++++++++++-----------------
3 files changed, 63 insertions(+), 52 deletions(-)
New commits:
commit 1fd42c9bb6529bfd27f2aa4d8fb888a2fbb61a0b
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat May 28 17:58:35 2011 -0400
More on replacing String with rtl::OUString.
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index 73000cc..8cb2175 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -49,6 +49,7 @@
using ::std::vector;
using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
// -----------------------------------------------------------------------
@@ -300,16 +301,20 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
for (nCol=0; nCol<nColCount; nCol++)
{
- String aString, aColStr;
+ OUString aString, aColStr;
if (HasColHeaders())
pDocument->GetString( aCols[nCol], nStrRow, nTab1, aString );
- if ( !aString.Len() )
+ if (aString.isEmpty())
{
- aString = ScGlobal::GetRscString(STR_COLUMN);
- aString += ' ';
+ OUStringBuffer aBuf;
+ aBuf.append(ScGlobal::GetRscString(STR_COLUMN));
+ aBuf.append(sal_Unicode(' '));
+
ScAddress aPos( aCols[ nCol ], 0, 0 );
aPos.Format( aColStr, SCA_VALID_COL, NULL );
- aString += aColStr;
+ aBuf.append(aColStr);
+
+ aString = aBuf.makeStringAndClear();
}
pMemChart->SetColText( static_cast<short>(nCol), aString);
}
@@ -320,17 +325,19 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
for (nRow=0; nRow<nRowCount; nRow++)
{
- String aString;
+ OUString aString;
if (HasRowHeaders())
{
ScAddress aAddr( nStrCol, aRows[nRow], nTab1 );
pDocument->GetString( nStrCol, aRows[nRow], nTab1, aString );
}
- if ( !aString.Len() )
+ if (aString.isEmpty())
{
- aString = ScGlobal::GetRscString(STR_ROW);
- aString += ' ';
- aString += String::CreateFromInt32( aRows[nRow]+1 );
+ OUStringBuffer aBuf;
+ aBuf.append(ScGlobal::GetRscString(STR_ROW));
+ aBuf.append(sal_Unicode(' '));
+ aBuf.append(static_cast<sal_Int32>(aRows[nRow]+1));
+ aString = aBuf.makeStringAndClear();
}
pMemChart->SetRowText( static_cast<short>(nRow), aString);
}
@@ -452,22 +459,24 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
SCCOL nPosCol = 0;
for ( nCol = 0; nCol < nColCount; nCol++ )
{
- String aString, aColStr;
+ OUString aString, aColStr;
const ScAddress* pPos = GetPositionMap()->GetColHeaderPosition( static_cast<SCCOL>(nCol) );
if ( HasColHeaders() && pPos )
pDocument->GetString(
pPos->Col(), pPos->Row(), pPos->Tab(), aString );
- if ( !aString.Len() )
+
+ if (aString.isEmpty())
{
- aString = ScGlobal::GetRscString(STR_COLUMN);
- aString += ' ';
+ OUStringBuffer aBuf(ScGlobal::GetRscString(STR_COLUMN));
+ aBuf.append(sal_Unicode(' '));
if ( pPos )
nPosCol = pPos->Col() + 1;
else
nPosCol++;
ScAddress aPos( nPosCol - 1, 0, 0 );
aPos.Format( aColStr, SCA_VALID_COL, NULL );
- aString += aColStr;
+ aBuf.append(aColStr);
+ aString = aBuf.makeStringAndClear();
}
pMemChart->SetColText( static_cast<short>(nCol), aString);
}
@@ -479,22 +488,23 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
SCROW nPosRow = 0;
for ( nRow = 0; nRow < nRowCount; nRow++ )
{
- String aString;
+ OUString aString;
const ScAddress* pPos = GetPositionMap()->GetRowHeaderPosition( nRow );
if ( HasRowHeaders() && pPos )
{
pDocument->GetString(
pPos->Col(), pPos->Row(), pPos->Tab(), aString );
}
- if ( !aString.Len() )
+ if (aString.isEmpty())
{
- aString = ScGlobal::GetRscString(STR_ROW);
- aString += ' ';
+ OUStringBuffer aBuf(ScGlobal::GetRscString(STR_ROW));
+ aBuf.append(sal_Unicode(' '));
if ( pPos )
nPosRow = pPos->Row() + 1;
else
nPosRow++;
- aString += String::CreateFromInt32( nPosRow );
+ aBuf.append(static_cast<sal_Int32>(nPosRow));
+ aString = aBuf.makeStringAndClear();
}
pMemChart->SetRowText( static_cast<short>(nRow), aString);
}
commit 153d619e9669c6bd7df114f84fb9712ae95643a3
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat May 28 17:46:59 2011 -0400
Use bool and rtl::OUString in ScChartCollection et. al.
diff --git a/sc/inc/chartarr.hxx b/sc/inc/chartarr.hxx
index 40f44cb..8fe2480 100644
--- a/sc/inc/chartarr.hxx
+++ b/sc/inc/chartarr.hxx
@@ -49,8 +49,8 @@ class ScMemChart
short nRowCnt;
short nColCnt;
double* pData;
- String* pColText;
- String* pRowText;
+ ::rtl::OUString* pColText;
+ ::rtl::OUString* pRowText;
ScMemChart(const ScMemChart& rMemChart); // not implemented
@@ -60,21 +60,21 @@ public:
short GetColCount() const { return nColCnt; }
short GetRowCount() const { return nRowCnt; }
- const String& GetColText(short nCol) const { return pColText[nCol]; }
- const String& GetRowText(short nRow) const { return pRowText[nRow]; }
+ const ::rtl::OUString& GetColText(short nCol) const { return pColText[nCol]; }
+ const ::rtl::OUString& GetRowText(short nRow) const { return pRowText[nRow]; }
double GetData(short nCol, short nRow) const { return pData[nCol * nRowCnt + nRow]; }
void SetData(short nCol, short nRow, const double& rVal) { pData[nCol * nRowCnt + nRow] = rVal; }
- void SetColText(short nCol, const String& rText) { pColText[nCol] = rText; }
- void SetRowText(short nRow, const String& rText) { pRowText[nRow] = rText; }
+ void SetColText(short nCol, const ::rtl::OUString& rText) { pColText[nCol] = rText; }
+ void SetRowText(short nRow, const ::rtl::OUString& rText) { pRowText[nRow] = rText; }
};
class SC_DLLPUBLIC ScChartArray : public ScDataObject // only parameter-struct
{
- String aName;
+ ::rtl::OUString aName;
ScDocument* pDocument;
ScChartPositioner aPositioner;
- sal_Bool bValid; // for creation out of SchMemChart
+ bool bValid; // for creation out of SchMemChart
private:
ScMemChart* CreateMemChartSingle();
@@ -83,9 +83,9 @@ public:
ScChartArray( ScDocument* pDoc, SCTAB nTab,
SCCOL nStartColP, SCROW nStartRowP,
SCCOL nEndColP, SCROW nEndRowP,
- const String& rChartName );
+ const ::rtl::OUString& rChartName );
ScChartArray( ScDocument* pDoc, const ScRangeListRef& rRangeList,
- const String& rChartName );
+ const ::rtl::OUString& rChartName );
ScChartArray( const ScChartArray& rArr );
virtual ~ScChartArray();
@@ -96,14 +96,14 @@ public:
void SetRangeList( const ScRange& rNew ) { aPositioner.SetRangeList(rNew); }
const ScChartPositionMap* GetPositionMap() { return aPositioner.GetPositionMap(); }
- void SetHeaders(sal_Bool bCol, sal_Bool bRow) { aPositioner.SetHeaders(bCol, bRow); }
- sal_Bool HasColHeaders() const { return aPositioner.HasColHeaders(); }
- sal_Bool HasRowHeaders() const { return aPositioner.HasRowHeaders(); }
- sal_Bool IsValid() const { return bValid; }
- void SetName(const String& rNew) { aName = rNew; }
- const String& GetName() const { return aName; }
+ void SetHeaders(bool bCol, bool bRow) { aPositioner.SetHeaders(bCol, bRow); }
+ bool HasColHeaders() const { return aPositioner.HasColHeaders(); }
+ bool HasRowHeaders() const { return aPositioner.HasRowHeaders(); }
+ bool IsValid() const { return bValid; }
+ void SetName(const ::rtl::OUString& rNew) { aName = rNew; }
+ const ::rtl::OUString& GetName() const { return aName; }
- sal_Bool operator==(const ScChartArray& rCmp) const;
+ bool operator==(const ScChartArray& rCmp) const;
ScMemChart* CreateMemChart();
};
@@ -119,7 +119,7 @@ public:
ScChartArray* operator[](sal_uInt16 nIndex) const
{ return (ScChartArray*)At(nIndex); }
- sal_Bool operator==(const ScChartCollection& rCmp) const;
+ bool operator==(const ScChartCollection& rCmp) const;
};
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 1d76b26..fad0033 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -153,7 +153,7 @@ void ScDocument::UpdateAllCharts()
uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
if ( xIPObj.is() )
{
- String aIPName = ((SdrOle2Obj*)pObject)->GetPersistName();
+ ::rtl::OUString aIPName = ((SdrOle2Obj*)pObject)->GetPersistName();
for (nPos=0; nPos<nDataCount; nPos++)
{
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index 38f3231..73000cc 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -48,6 +48,7 @@
#include <vector>
using ::std::vector;
+using ::rtl::OUString;
// -----------------------------------------------------------------------
@@ -66,8 +67,8 @@ ScMemChart::ScMemChart(short nCols, short nRows)
*(pFill ++) = 0.0;
}
- pColText = new String[nColCnt];
- pRowText = new String[nRowCnt];
+ pColText = new OUString[nColCnt];
+ pRowText = new OUString[nRowCnt];
}
ScMemChart::~ScMemChart()
@@ -81,20 +82,20 @@ ScMemChart::~ScMemChart()
ScChartArray::ScChartArray( ScDocument* pDoc, SCTAB nTab,
SCCOL nStartColP, SCROW nStartRowP, SCCOL nEndColP, SCROW nEndRowP,
- const String& rChartName ) :
+ const OUString& rChartName ) :
aName( rChartName ),
pDocument( pDoc ),
aPositioner(pDoc, nTab, nStartColP, nStartRowP, nEndColP, nEndRowP),
- bValid( sal_True )
+ bValid( true )
{
}
ScChartArray::ScChartArray( ScDocument* pDoc, const ScRangeListRef& rRangeList,
- const String& rChartName ) :
+ const OUString& rChartName ) :
aName( rChartName ),
pDocument( pDoc ),
aPositioner(pDoc, rRangeList),
- bValid( sal_True )
+ bValid( true )
{
}
@@ -116,7 +117,7 @@ ScDataObject* ScChartArray::Clone() const
return new ScChartArray(*this);
}
-sal_Bool ScChartArray::operator==(const ScChartArray& rCmp) const
+bool ScChartArray::operator==(const ScChartArray& rCmp) const
{
return aPositioner == rCmp.aPositioner
&& aName == rCmp.aName;
@@ -226,7 +227,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
nRowCount = 0;
}
- sal_Bool bValidData = sal_True;
+ bool bValidData = true;
if ( !nColCount )
{
bValidData = false;
@@ -250,7 +251,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
{
if ( bValidData )
{
- sal_Bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
+ bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
ScBaseCell* pCell;
for (nCol=0; nCol<nColCount; nCol++)
{
@@ -350,7 +351,7 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
nRowCount = 0;
}
- sal_Bool bValidData = sal_True;
+ bool bValidData = true;
if ( !nColCount )
{
bValidData = false;
@@ -372,7 +373,7 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
{
SCSIZE nCol = 0;
SCSIZE nRow = 0;
- sal_Bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
+ bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
sal_uLong nIndex = 0;
if (bValidData)
{
@@ -516,7 +517,7 @@ ScDataObject* ScChartCollection::Clone() const
return new ScChartCollection(*this);
}
-sal_Bool ScChartCollection::operator==(const ScChartCollection& rCmp) const
+bool ScChartCollection::operator==(const ScChartCollection& rCmp) const
{
if (nCount != rCmp.nCount)
return false;
@@ -525,7 +526,7 @@ sal_Bool ScChartCollection::operator==(const ScChartCollection& rCmp) const
if (!((*(const ScChartArray*)pItems[i]) == (*(const ScChartArray*)rCmp.pItems[i])))
return false;
- return sal_True;
+ return true;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list