svl/qa/unit/svl.cxx | 16 +++++++++++++++- svl/source/numbers/zformat.cxx | 9 ++++++++- svx/source/unodraw/unoshape.cxx | 9 ++++----- 3 files changed, 27 insertions(+), 7 deletions(-)
New commits: commit 55f0b580da5c6536a7e7fc0c1cf8f1ed36b40be1 Author: Michael Stahl <[email protected]> AuthorDate: Thu May 19 13:23:33 2022 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Fri May 20 10:34:29 2022 +0200 svl: SvNumberformat::GetMappedFormatstring() vs. LANGUAGE_DONTKNOW There is this number format: <number:date-style style:name="N36" number:automatic-order="true"> <number:day number:style="long"/> <number:text>.</number:text> <number:month number:style="long"/> <number:text>.</number:text> <number:year number:style="long"/> </number:date-style> MSWordExportBase::GetNumberFormat() exports as: DATE \@"dd/MM/yyyy" But should be: DATE \@"dd.MM.yyyy" The problem is that with LANGUAGE_DONTKNOW, the available LocaleDataWrapper can't be considered reliable, so prefer to use the existing separator string in this case. Change-Id: I596bea5daa75c717931b3c5d5506103b87b8ee08 diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index d30a7b6279ec..2e4f21099d0d 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -34,6 +34,7 @@ #include <svl/sharedstring.hxx> #include <tools/color.hxx> #include <unotools/syslocale.hxx> +#include <unotest/bootstrapfixturebase.hxx> // for CPPUNIT_TEST_FIXTURE #include <memory> #include <unicode/timezone.h> @@ -90,7 +91,7 @@ public: CPPUNIT_TEST(testExcelExportFormats); CPPUNIT_TEST_SUITE_END(); -private: +protected: uno::Reference< uno::XComponentContext > m_xContext; void checkPreviewString(SvNumberFormatter& aFormatter, const OUString& sCode, @@ -1728,6 +1729,19 @@ void Test::testExcelExportFormats() CPPUNIT_ASSERT_EQUAL( OUString("[$R-1C09]\\ #,##0.0;[$R-1C09]\\-#,##0.0"), aCode); } +CPPUNIT_TEST_FIXTURE(Test, testLanguageDontknow) +{ + SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US); + NfKeywordTable keywords; + aFormatter.FillKeywordTableForExcel(keywords); + OUString code("TT.MM.JJJJ"); + sal_uInt32 nKey = aFormatter.GetEntryKey(code, LANGUAGE_GERMAN); + CPPUNIT_ASSERT(nKey != NUMBERFORMAT_ENTRY_NOT_FOUND); + SvNumberformat const*const pFormat = aFormatter.GetEntry(nKey); + LocaleDataWrapper ldw(m_xContext, LanguageTag(LANGUAGE_DONTKNOW)); + CPPUNIT_ASSERT_EQUAL(OUString("dd.mm.yyyy"), pFormat->GetMappedFormatstring(keywords, ldw)); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 23c0919aecf2..acbea945cd88 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5291,7 +5291,14 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, aStr.append( "-" ); break; case NF_SYMBOLTYPE_DATESEP : - aStr.append( rLocWrp.getDateSep() ); + if (nOriginalLang == LANGUAGE_DONTKNOW) + { // prefer whatever the existing separator is + aStr.append(rStrArray[j]); + } + else + { + aStr.append( rLocWrp.getDateSep() ); + } break; case NF_SYMBOLTYPE_TIMESEP : aStr.append( rLocWrp.getTimeSep() ); commit 991bb55ea6c51e0803d49bcf5edf51b8bcc28fb4 Author: Michael Stahl <[email protected]> AuthorDate: Fri May 20 10:28:01 2022 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Fri May 20 10:28:01 2022 +0200 Revert "svl: SvNumberformat::GetMappedFormatstring() vs. LANGUAGE_DONTKNOW" This reverts commit 1be4c01415e4e97b72bf5e3230048950d00fdc8a. diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index acbea945cd88..23c0919aecf2 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5291,14 +5291,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, aStr.append( "-" ); break; case NF_SYMBOLTYPE_DATESEP : - if (nOriginalLang == LANGUAGE_DONTKNOW) - { // prefer whatever the existing separator is - aStr.append(rStrArray[j]); - } - else - { - aStr.append( rLocWrp.getDateSep() ); - } + aStr.append( rLocWrp.getDateSep() ); break; case NF_SYMBOLTYPE_TIMESEP : aStr.append( rLocWrp.getTimeSep() ); commit 1be4c01415e4e97b72bf5e3230048950d00fdc8a Author: Michael Stahl <[email protected]> AuthorDate: Thu May 19 13:23:33 2022 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Thu May 19 17:51:22 2022 +0200 svl: SvNumberformat::GetMappedFormatstring() vs. LANGUAGE_DONTKNOW There is this number format: <number:date-style style:name="N36" number:automatic-order="true"> <number:day number:style="long"/> <number:text>.</number:text> <number:month number:style="long"/> <number:text>.</number:text> <number:year number:style="long"/> </number:date-style> MSWordExportBase::GetNumberFormat() exports as: DATE \@"dd/MM/yyyy" But should be: DATE \@"dd.MM.yyyy" The problem is that with LANGUAGE_DONTKNOW, the available LocaleDataWrapper can't be considered reliable, so prefer to use the existing separator string in this case. Change-Id: I596bea5daa75c717931b3c5d5506103b87b8ee08 diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 23c0919aecf2..acbea945cd88 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5291,7 +5291,14 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, aStr.append( "-" ); break; case NF_SYMBOLTYPE_DATESEP : - aStr.append( rLocWrp.getDateSep() ); + if (nOriginalLang == LANGUAGE_DONTKNOW) + { // prefer whatever the existing separator is + aStr.append(rStrArray[j]); + } + else + { + aStr.append( rLocWrp.getDateSep() ); + } break; case NF_SYMBOLTYPE_TIMESEP : aStr.append( rLocWrp.getTimeSep() ); commit cd733032151e0e06a49680edc180e695f2ca21ee Author: Michael Stahl <[email protected]> AuthorDate: Wed May 18 18:25:07 2022 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Thu May 19 12:10:03 2022 +0200 svx: fix double-free if SvxShape of SwDrawVirtObj is disposed First SvxShape::dispose() deletes it, then ~SwDrawFrameFormat() via ~SwDrawContact() calls SwDrawContact::RemoveAllVirtObjs() and deletes it again. Back in 2009, CWS dba32 (60698c8a619f219129dbeac7da1f962f3fa63f6a) added this OSL_ENSURE, let's actually try to fix this now. Change-Id: I5c391aa425aa75fb87cecccbf9e41c9f90196f9f diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 3f07f5ab9a82..20b308e697e7 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -1316,10 +1316,6 @@ void SAL_CALL SvxShape::dispose() if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() ) { - OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); - // normally, we are allowed to free the SdrObject only if we have its ownership. - // Why isn't this checked here? - SdrPage* pPage = pObject->getSdrPageFromSdrObject(); // delete the SdrObject from the page const size_t nCount = pPage->GetObjCount(); @@ -1328,7 +1324,10 @@ void SAL_CALL SvxShape::dispose() if ( pPage->GetObj( nNum ) == pObject ) { OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject ); - bFreeSdrObject = true; + if (HasSdrObjectOwnership()) + { + bFreeSdrObject = true; + } break; } }
