summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-11-08 14:22:21 +0100
committerEike Rathke <erack@redhat.com>2013-11-08 14:27:16 +0100
commit9b10373edae490d2b9b7f8d733c59b4f63927bec (patch)
tree4f08c54a2e55d087314267ff65ed010b750de6cd
parent961e319da7e8aa16b64ceee421e896802cbb82c1 (diff)
"%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
-rw-r--r--sc/inc/global.hxx13
-rw-r--r--sc/source/core/data/global.cxx15
-rw-r--r--sc/source/ui/dbgui/filtdlg.cxx3
-rw-r--r--sc/source/ui/dbgui/pfiltdlg.cxx3
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx6
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx3
6 files changed, 33 insertions, 10 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 0698fbc11e34..79ab13d0c5ae 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 09b2c506dd51..534adf9b7b64 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 bfc9de8ccf4a..60953a040d95 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 23d0122de9d4..8b0e3f629cc6 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 6a8f05d10367..16bf1793d818 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 e8608a871fa3..48b12e91710d 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 );