sc/inc/global.hxx | 13 +++++++++++++ sc/source/core/data/global.cxx | 15 +++++++++++++++ sc/source/ui/dbgui/filtdlg.cxx | 3 +-- sc/source/ui/dbgui/pfiltdlg.cxx | 3 +-- sc/source/ui/dbgui/tpsort.cxx | 6 ++---- sc/source/ui/dbgui/tpsubt.cxx | 3 +-- 6 files changed, 33 insertions(+), 10 deletions(-)
New commits: commit 9b10373edae490d2b9b7f8d733c59b4f63927bec Author: Eike Rathke <er...@redhat.com> Date: Fri Nov 8 14:22:21 2013 +0100 "%1 is replaced to ..." ... maybe, or maybe not Translations may have omitted the %1 placeholder in SCSTR_COLUMN and SCSTR_ROW, or not have it translated newly yet because it was introduced later. In these cases append the column indicator / row number as it was done before. Change-Id: I331cf0c529bebea02277784ea145c202eb6f6fda diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 0698fbc..79ab13d 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -684,6 +684,19 @@ SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pStri /** A static instance of ScFieldEditEngine not capable of resolving document specific fields, to be used only by ScEditUtil::GetString(). */ static ScFieldEditEngine& GetStaticFieldEditEngine(); + + /** Replaces the first occurrence of rPlaceholder in rString with + rReplacement, or if rPlaceholder is not found appends one space if + rString does not end in a space and appends rReplacement. + + Meant to be used with resource strings ala "Column %1" where a + translation may have omitted the %1 placeholder and a simple + replacement would end up with nothing replaced so no column indicator + in the result string. + */ + SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString, + const OUString& rPlaceholder, + const OUString& rReplacement ); }; #endif diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 09b2c50..534adf9 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -1201,4 +1201,19 @@ ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine() return *pFieldEditEngine; } +OUString ScGlobal::ReplaceOrAppend( const OUString& rString, + const OUString& rPlaceholder, const OUString& rReplacement ) +{ + if (rString.isEmpty()) + return rReplacement; + sal_Int32 nFound = rString.indexOf( rPlaceholder); + if (nFound < 0) + { + if (rString[rString.getLength()-1] == ' ') + return rString + rReplacement; + return rString + " " + rReplacement; + } + return rString.replaceFirst( rPlaceholder, rReplacement, &nFound); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index bfc9de8..60953a0 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -460,8 +460,7 @@ void ScFilterDlg::FillFieldLists() aFieldName = pDoc->GetString(col, nFirstRow, nTab); if (!pBtnHeader->IsChecked() || aFieldName.isEmpty()) { - OUString aTemp( aStrColumn); - aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col )); + aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col )); } pLbField1->InsertEntry( aFieldName, i ); pLbField2->InsertEntry( aFieldName, i ); diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index 23d0122..8b0e3f6 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -291,8 +291,7 @@ void ScPivotFilterDlg::FillFieldLists() aFieldName = pDoc->GetString(col, nFirstRow, nTab); if ( aFieldName.isEmpty() ) { - OUString aTemp( aStrColumn); - aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col )); + aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col )); } aLbField1.InsertEntry( aFieldName, i ); aLbField2.InsertEntry( aFieldName, i ); diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx index 6a8f05d..16bf179 100644 --- a/sc/source/ui/dbgui/tpsort.cxx +++ b/sc/source/ui/dbgui/tpsort.cxx @@ -384,8 +384,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField ) aFieldName = pDoc->GetString(col, nFirstSortRow, nTab); if ( !bHasHeader || aFieldName.isEmpty() ) { - OUString aTemp( aStrColumn); - aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col )); + aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col )); } nFieldArr.push_back( col ); @@ -406,8 +405,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField ) aFieldName = pDoc->GetString(nFirstSortCol, row, nTab); if ( !bHasHeader || aFieldName.isEmpty() ) { - OUString aTemp( aStrRow); - aFieldName = aTemp.replaceFirst( "%1", OUString::number( row+1)); + aFieldName = ScGlobal::ReplaceOrAppend( aStrRow, "%1", OUString::number( row+1)); } nFieldArr.push_back( row ); diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx index e8608a8..48b12e9 100644 --- a/sc/source/ui/dbgui/tpsubt.cxx +++ b/sc/source/ui/dbgui/tpsubt.cxx @@ -278,8 +278,7 @@ void ScTpSubTotalGroup::FillListBoxes() aFieldName = pDoc->GetString(col, nFirstRow, nTab); if ( aFieldName.isEmpty() ) { - OUString aTemp( aStrColumn); - aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col )); + aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col )); } nFieldArr[i] = col; aLbGroup.InsertEntry( aFieldName, i+1 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits