Kaydet (Commit) 9b10373e authored tarafından Eike Rathke's avatar Eike Rathke

"%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
üst 961e319d
...@@ -684,6 +684,19 @@ SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pStri ...@@ -684,6 +684,19 @@ SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pStri
/** A static instance of ScFieldEditEngine not capable of resolving /** A static instance of ScFieldEditEngine not capable of resolving
document specific fields, to be used only by ScEditUtil::GetString(). */ document specific fields, to be used only by ScEditUtil::GetString(). */
static ScFieldEditEngine& GetStaticFieldEditEngine(); 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 #endif
......
...@@ -1201,4 +1201,19 @@ ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine() ...@@ -1201,4 +1201,19 @@ ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine()
return *pFieldEditEngine; 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -460,8 +460,7 @@ void ScFilterDlg::FillFieldLists() ...@@ -460,8 +460,7 @@ void ScFilterDlg::FillFieldLists()
aFieldName = pDoc->GetString(col, nFirstRow, nTab); aFieldName = pDoc->GetString(col, nFirstRow, nTab);
if (!pBtnHeader->IsChecked() || aFieldName.isEmpty()) if (!pBtnHeader->IsChecked() || aFieldName.isEmpty())
{ {
OUString aTemp( aStrColumn); aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col ));
aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col ));
} }
pLbField1->InsertEntry( aFieldName, i ); pLbField1->InsertEntry( aFieldName, i );
pLbField2->InsertEntry( aFieldName, i ); pLbField2->InsertEntry( aFieldName, i );
......
...@@ -291,8 +291,7 @@ void ScPivotFilterDlg::FillFieldLists() ...@@ -291,8 +291,7 @@ void ScPivotFilterDlg::FillFieldLists()
aFieldName = pDoc->GetString(col, nFirstRow, nTab); aFieldName = pDoc->GetString(col, nFirstRow, nTab);
if ( aFieldName.isEmpty() ) if ( aFieldName.isEmpty() )
{ {
OUString aTemp( aStrColumn); aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col ));
aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col ));
} }
aLbField1.InsertEntry( aFieldName, i ); aLbField1.InsertEntry( aFieldName, i );
aLbField2.InsertEntry( aFieldName, i ); aLbField2.InsertEntry( aFieldName, i );
......
...@@ -384,8 +384,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField ) ...@@ -384,8 +384,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField )
aFieldName = pDoc->GetString(col, nFirstSortRow, nTab); aFieldName = pDoc->GetString(col, nFirstSortRow, nTab);
if ( !bHasHeader || aFieldName.isEmpty() ) if ( !bHasHeader || aFieldName.isEmpty() )
{ {
OUString aTemp( aStrColumn); aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col ));
aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col ));
} }
nFieldArr.push_back( col ); nFieldArr.push_back( col );
...@@ -406,8 +405,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField ) ...@@ -406,8 +405,7 @@ void ScTabPageSortFields::FillFieldLists( sal_uInt16 nStartField )
aFieldName = pDoc->GetString(nFirstSortCol, row, nTab); aFieldName = pDoc->GetString(nFirstSortCol, row, nTab);
if ( !bHasHeader || aFieldName.isEmpty() ) if ( !bHasHeader || aFieldName.isEmpty() )
{ {
OUString aTemp( aStrRow); aFieldName = ScGlobal::ReplaceOrAppend( aStrRow, "%1", OUString::number( row+1));
aFieldName = aTemp.replaceFirst( "%1", OUString::number( row+1));
} }
nFieldArr.push_back( row ); nFieldArr.push_back( row );
......
...@@ -278,8 +278,7 @@ void ScTpSubTotalGroup::FillListBoxes() ...@@ -278,8 +278,7 @@ void ScTpSubTotalGroup::FillListBoxes()
aFieldName = pDoc->GetString(col, nFirstRow, nTab); aFieldName = pDoc->GetString(col, nFirstRow, nTab);
if ( aFieldName.isEmpty() ) if ( aFieldName.isEmpty() )
{ {
OUString aTemp( aStrColumn); aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, "%1", ScColToAlpha( col ));
aFieldName = aTemp.replaceFirst("%1", ScColToAlpha( col ));
} }
nFieldArr[i] = col; nFieldArr[i] = col;
aLbGroup.InsertEntry( aFieldName, i+1 ); aLbGroup.InsertEntry( aFieldName, i+1 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment