tdf#170670 NumberFormat: fix blank width string treatment
In case of 2 characters string text, with a delimiter as text and a blank width string like "-"_) the delimiter is now treated as text Add qa test with format of bug report: [>0]#,##0_);[<0](#,##0);"-"_) Change-Id: Idd4542bd186c6b6b348f6716bee2fd5055f2c83f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199314 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
committed by
Mike Kaganski
parent
a4d5492e65
commit
fb07ca38af
Binary file not shown.
@@ -1681,6 +1681,16 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testBlankWidthCharacter)
|
||||
// save to XLSX and reload
|
||||
saveAndReload(TestFilter::XLSX);
|
||||
lcl_TestNumberFormat(*getScDoc(), u"_-?0;-?0;_-?0;@"_ustr);
|
||||
|
||||
createScDoc("ods/tdf170670-Blank-width-char.ods");
|
||||
|
||||
// save to ODS and reload
|
||||
saveAndReload(TestFilter::ODS);
|
||||
lcl_TestNumberFormat(*getScDoc(), u"[>0]#,##0_);[<0](#,##0);\"-\"_)"_ustr);
|
||||
|
||||
// save to XLSX and reload
|
||||
saveAndReload(TestFilter::XLSX);
|
||||
lcl_TestNumberFormat(*getScDoc(), u"#,##0_);\\(#,##0\\);-_)"_ustr);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScExportTest4, testEmbeddedTextInDecimal)
|
||||
|
||||
@@ -530,13 +530,13 @@ static bool lcl_ValidChar( sal_Unicode cChar, const SvXMLNumFormatContext& rPare
|
||||
return false;
|
||||
}
|
||||
|
||||
static void lcl_EnquoteIfNecessary( OUStringBuffer& rContent, const SvXMLNumFormatContext& rParent )
|
||||
static void lcl_EnquoteIfNecessary( OUStringBuffer& rContent, const SvXMLNumFormatContext& rParent, const bool bIsBlankWidthStringEmpty = true )
|
||||
{
|
||||
bool bQuote = true;
|
||||
sal_Int32 nLength = rContent.getLength();
|
||||
const SvXMLStylesTokens nFormatType = rParent.GetType();
|
||||
|
||||
if (nFormatType != SvXMLStylesTokens::BOOLEAN_STYLE &&
|
||||
if (nFormatType != SvXMLStylesTokens::BOOLEAN_STYLE && bIsBlankWidthStringEmpty &&
|
||||
((nLength == 1 && lcl_ValidChar( rContent[0], rParent)) ||
|
||||
(nLength == 2 &&
|
||||
((rContent[0] == ' ' && rContent[1] == '-') ||
|
||||
@@ -547,6 +547,7 @@ static void lcl_EnquoteIfNecessary( OUStringBuffer& rContent, const SvXMLNumForm
|
||||
// Or space followed by minus (used in currency formats) that would
|
||||
// lead to almost duplicated formats with built-in formats just with
|
||||
// the difference of quotes.
|
||||
// tdf#170670: except if it is inside a blank width string
|
||||
bQuote = false;
|
||||
}
|
||||
else if ( nFormatType == SvXMLStylesTokens::PERCENTAGE_STYLE && nLength > 1 )
|
||||
@@ -974,7 +975,7 @@ void SvXMLNumFmtElementContext::endFastElement(sal_Int32 )
|
||||
}
|
||||
if ( !aContent.isEmpty() )
|
||||
{
|
||||
lcl_EnquoteIfNecessary( aContent, rParent );
|
||||
lcl_EnquoteIfNecessary( aContent, rParent, sBlankWidthString.isEmpty() );
|
||||
if ( !sBlankWidthString.isEmpty() )
|
||||
{
|
||||
lcl_InsertBlankWidthChars( sBlankWidthString, aContent );
|
||||
|
||||
Reference in New Issue
Block a user