[Libreoffice-commits] core.git: svl/qa svl/source

2023-10-20 Thread Stephan Bergmann (via logerrit)
 svl/qa/unit/items/test_IndexedStyleSheets.cxx |2 -
 svl/source/items/srchitem.cxx |   28 ++--
 svl/source/numbers/numfmuno.cxx   |   36 +-
 svl/source/numbers/zformat.cxx|6 ++--
 4 files changed, 36 insertions(+), 36 deletions(-)

New commits:
commit 74a6ce486b13f33380959ae58a40300bb84082f2
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:30 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Oct 20 10:24:25 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: svl

Change-Id: I31d46c2b75888474136ecd630fd3f817db189fb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158223
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/svl/qa/unit/items/test_IndexedStyleSheets.cxx 
b/svl/qa/unit/items/test_IndexedStyleSheets.cxx
index f5014a261e13..6afaca629565 100644
--- a/svl/qa/unit/items/test_IndexedStyleSheets.cxx
+++ b/svl/qa/unit/items/test_IndexedStyleSheets.cxx
@@ -146,7 +146,7 @@ void 
IndexedStyleSheetsTest::StyleSheetsCanBeRetrievedByTheirName()
 
 void IndexedStyleSheetsTest::KnowsThatItStoresAStyleSheet()
 {
-static constexpr OUStringLiteral name1(u"name1");
+static constexpr OUString name1(u"name1"_ustr);
 rtl::Reference sheet1(new MockedStyleSheet(name1));
 rtl::Reference sheet2(new MockedStyleSheet(name1));
 rtl::Reference sheet3(new MockedStyleSheet("name2"));
diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx
index e8447dbb209c..1300bf744afa 100644
--- a/svl/source/items/srchitem.cxx
+++ b/svl/source/items/srchitem.cxx
@@ -39,22 +39,22 @@ using namespace com::sun::star::beans;
 using namespace com::sun::star::uno;
 using namespace com::sun::star::util;
 
-constexpr OUStringLiteral CFG_ROOT_NODE = u"Office.Common/SearchOptions";
+constexpr OUString CFG_ROOT_NODE = u"Office.Common/SearchOptions"_ustr;
 
 #define SRCH_PARAMS 13
-constexpr OUStringLiteral SRCH_PARA_OPTIONS = u"Options";
-constexpr OUStringLiteral SRCH_PARA_FAMILY = u"Family";
-constexpr OUStringLiteral SRCH_PARA_COMMAND = u"Command";
-constexpr OUStringLiteral SRCH_PARA_CELLTYPE = u"CellType";
-constexpr OUStringLiteral SRCH_PARA_APPFLAG = u"AppFlag";
-constexpr OUStringLiteral SRCH_PARA_ROWDIR = u"RowDirection";
-constexpr OUStringLiteral SRCH_PARA_ALLTABLES = u"AllTables";
-constexpr OUStringLiteral SRCH_PARA_SEARCHFILTERED = u"SearchFiltered";
-constexpr OUStringLiteral SRCH_PARA_SEARCHFORMATTED = u"SearchFormatted";
-constexpr OUStringLiteral SRCH_PARA_BACKWARD = u"Backward";
-constexpr OUStringLiteral SRCH_PARA_PATTERN = u"Pattern";
-constexpr OUStringLiteral SRCH_PARA_CONTENT = u"Content";
-constexpr OUStringLiteral SRCH_PARA_ASIANOPT = u"AsianOptions";
+constexpr OUString SRCH_PARA_OPTIONS = u"Options"_ustr;
+constexpr OUString SRCH_PARA_FAMILY = u"Family"_ustr;
+constexpr OUString SRCH_PARA_COMMAND = u"Command"_ustr;
+constexpr OUString SRCH_PARA_CELLTYPE = u"CellType"_ustr;
+constexpr OUString SRCH_PARA_APPFLAG = u"AppFlag"_ustr;
+constexpr OUString SRCH_PARA_ROWDIR = u"RowDirection"_ustr;
+constexpr OUString SRCH_PARA_ALLTABLES = u"AllTables"_ustr;
+constexpr OUString SRCH_PARA_SEARCHFILTERED = u"SearchFiltered"_ustr;
+constexpr OUString SRCH_PARA_SEARCHFORMATTED = u"SearchFormatted"_ustr;
+constexpr OUString SRCH_PARA_BACKWARD = u"Backward"_ustr;
+constexpr OUString SRCH_PARA_PATTERN = u"Pattern"_ustr;
+constexpr OUString SRCH_PARA_CONTENT = u"Content"_ustr;
+constexpr OUString SRCH_PARA_ASIANOPT = u"AsianOptions"_ustr;
 
 SfxPoolItem* SvxSearchItem::CreateDefault() { return new  SvxSearchItem(0);}
 
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx
index 41810574bffb..58094faa54e7 100644
--- a/svl/source/numbers/numfmuno.cxx
+++ b/svl/source/numbers/numfmuno.cxx
@@ -41,24 +41,24 @@
 
 using namespace com::sun::star;
 
-constexpr OUStringLiteral PROPERTYNAME_FMTSTR = u"FormatString";
-constexpr OUStringLiteral PROPERTYNAME_LOCALE = u"Locale";
-constexpr OUStringLiteral PROPERTYNAME_TYPE = u"Type";
-constexpr OUStringLiteral PROPERTYNAME_COMMENT = u"Comment";
-constexpr OUStringLiteral PROPERTYNAME_CURREXT = u"CurrencyExtension";
-constexpr OUStringLiteral PROPERTYNAME_CURRSYM = u"CurrencySymbol";
-constexpr OUStringLiteral PROPERTYNAME_CURRABB = u"CurrencyAbbreviation";
-constexpr OUStringLiteral PROPERTYNAME_DECIMALS = u"Decimals";
-constexpr OUStringLiteral PROPERTYNAME_LEADING = u"LeadingZeros";
-constexpr OUStringLiteral PROPERTYNAME_NEGRED = u"NegativeRed";
-constexpr OUStringLiteral PROPERTYNAME_STDFORM = u"StandardFormat";
-constexpr OUStringLiteral PROPERTYNAME_THOUS = u"ThousandsSeparator";
-constexpr OUStringLiteral PROPERTYNAME_USERDEF = u"UserDefined";
-
-constexpr OUStringLiteral PROPERTYNAME_NOZERO = u"NoZero";
-constexpr OUStringLiteral PROPERTYNAME_NULLDATE = u"NullDate";
-constexpr OUStringLiteral PROPERTYNAME_STDDEC = u"StandardDecimals";
-constexpr 

[Libreoffice-commits] core.git: svl/qa svl/source

2023-05-02 Thread Baole Fang (via logerrit)
 svl/qa/unit/test_URIHelper.cxx |5 +
 svl/source/misc/urihelper.cxx  |4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit e8d7bf954fe74ce85bdd084d6e12d27027a4c379
Author: Baole Fang 
AuthorDate: Thu Apr 27 14:16:18 2023 -0400
Commit: Stephan Bergmann 
CommitDate: Wed May 3 07:55:02 2023 +0200

tdf#145925: Support AutoCapitalize in DOI recognition

Sometimes, the first character of the doi string is auto capitalized, which 
isn't recognized as DOI.
Now, the doi detection is able to recognize doi string with the first 
character capitalized,
like what is done in url recognition.

Change-Id: I95334941dc4cda3095f1750fea927640dea55e23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151142
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx
index df9e5d5114b8..33a08996cb58 100644
--- a/svl/qa/unit/test_URIHelper.cxx
+++ b/svl/qa/unit/test_URIHelper.cxx
@@ -410,6 +410,11 @@ void Test::testFindFirstDOIInText() {
 };
 static Data const tests[] = {
 { "doi:10.1000/182", "https://doi.org/10.1000/182;, 0, 15 }, // valid 
doi suffix with only digits
+{ "Doi:10.1000/182", "https://doi.org/10.1000/182;, 0, 15 }, // valid 
doi suffix with some of the the first three character being capitalized
+{ "DoI:10.1000/182", "https://doi.org/10.1000/182;, 0, 15 }, // valid 
doi suffix with some of the the first three character being capitalized
+{ "DOI:10.1000/182", "https://doi.org/10.1000/182;, 0, 15 }, // valid 
doi suffix with some of the the first three character being capitalized
+{ "dOI:10.1000/182", "https://doi.org/10.1000/182;, 0, 15 }, // valid 
doi suffix with some of the the first three character being capitalized
+{ "dOi:10.1000/182", "https://doi.org/10.1000/182;, 0, 15 }, // valid 
doi suffix with some of the the first three character being capitalized
 { "doi:10.1038/nature03001", "https://doi.org/10.1038/nature03001;, 0, 
23 }, // valid doi suffix with alphanumeric characters
 { "doi:10.1093/ajae/aaq063", "https://doi.org/10.1093/ajae/aaq063;, 0, 
23 }, // valid doi suffix with multiple slash
 { "doi:10.1016/S0735-1097(98)00347-7", 
"https://doi.org/10.1016/S0735-1097(98)00347-7", 0, 33 }, // valid doi suffix 
with characters apart from alphanumeric
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index 0043b7883a87..9aa78a584614 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -757,7 +757,7 @@ OUString URIHelper::FindFirstDOIInText(OUString const & 
rText,
 sal_Int32 count = rEnd-rBegin;
 OUString candidate(rText.subView(rBegin, count));
 // Match with regex "doi:10\.\d{4,9}\/[-._;()\/:a-zA-Z0-9]+"
-if (candidate.startsWith("doi:10."))
+if (candidate.startsWithIgnoreAsciiCase("doi:10."))
 {
 bool flag = true;
 sal_Int32 digit = 0;
@@ -797,7 +797,7 @@ OUString URIHelper::FindFirstDOIInText(OUString const & 
rText,
 }
 if (flag && digit==-1)
 {
-return candidate.replaceFirst("doi:","https://doi.org/;);
+return OUString::Concat("https://doi.org/;)+candidate.subView(4);
 }
 }
 rBegin = rEnd;


[Libreoffice-commits] core.git: svl/qa svl/source

2023-04-06 Thread Laurent Balland (via logerrit)
 svl/qa/unit/svl.cxx|   12 
 svl/source/numbers/zformat.cxx |8 +---
 2 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit dc9b8c31aaf72812dc205f610638098898a4cde7
Author: Laurent Balland 
AuthorDate: Sun Mar 19 21:45:52 2023 +0100
Commit: Eike Rathke 
CommitDate: Thu Apr 6 18:00:12 2023 +0200

tdf#153887 Fraction number format: avoid 0/0

If round value is an integer and there is no integer part in the number
format, then nDiv was wrongly forced to 0.
Add corresponding unit tests.

Change-Id: Ib69393eca8f6c2bdda0eacfc83637ab0c971ff2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149118
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 557c9be639e6..06d018f3b624 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1449,6 +1449,18 @@ void Test::testUserDefinedNumberFormats()
 sExpected = "-575 540/697";
 checkPreviewString(aFormatter, sCode, -575.774749601315, eLang, 
sExpected);
 }
+{  // tdf#153887: integer value without integer part displayed
+sCode = "#/?";
+sExpected = "2/1";
+checkPreviewString(aFormatter, sCode, 1.95, eLang, sExpected);
+checkPreviewString(aFormatter, sCode, 2.00, eLang, sExpected);
+checkPreviewString(aFormatter, sCode, 2.05, eLang, sExpected);
+sCode = "0/8";
+sExpected = "16/8";
+checkPreviewString(aFormatter, sCode, 1.95, eLang, sExpected);
+checkPreviewString(aFormatter, sCode, 2.00, eLang, sExpected);
+checkPreviewString(aFormatter, sCode, 2.05, eLang, sExpected);
+}
 {  // tdf#102507: left alignment of denominator
 sCode = "# ?/???";
 sExpected = "3 1/2  ";
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 676692da6fdb..5128c5cca118 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2830,9 +2830,10 @@ void SvNumberformat::ImpGetFractionElements ( double& 
fNumber, sal_uInt16 nIx,
 fIntPart = floor(fNumber); // Integral part
 fNumber -= fIntPart; // Fractional part
 const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
-nDiv = lcl_GetDenominatorString( rInfo, NumFor[nIx].GetCount() ).toInt32();
-if( nDiv > 0 )
+sal_Int64 nForcedDiv = lcl_GetDenominatorString( rInfo, 
NumFor[nIx].GetCount() ).toInt32();
+if( nForcedDiv > 0 )
 {   // Forced Denominator
+nDiv = nForcedDiv;
 nFrac = static_cast(floor ( fNumber * nDiv ));
 double fFracNew = static_cast(nFrac) / 
static_cast(nDiv);
 double fFracNew1 = static_cast(nFrac + 1) / 
static_cast(nDiv);
@@ -2886,7 +2887,8 @@ void SvNumberformat::ImpGetFractionElements ( double& 
fNumber, sal_uInt16 nIx,
 if (nFrac >= nDiv)
 {
 ++fIntPart;
-nFrac = nDiv = 0;
+nFrac = 0;
+nDiv = ( nForcedDiv > 0 ) ? nForcedDiv : 1;
 }
 }
 


[Libreoffice-commits] core.git: svl/qa svl/source

2022-05-03 Thread Stephan Bergmann (via logerrit)
 svl/qa/unit/test_URIHelper.cxx |2 +-
 svl/source/config/asiancfg.cxx |   10 +-
 svl/source/fsstor/fsstorage.cxx|4 ++--
 svl/source/misc/documentlockfile.cxx   |4 ++--
 svl/source/misc/sharecontrolfile.cxx   |4 ++--
 svl/source/passwordcontainer/passwordcontainer.cxx |2 +-
 6 files changed, 13 insertions(+), 13 deletions(-)

New commits:
commit eaf1f095ef96ceaf94f2fb1859324c11a35422c6
Author: Stephan Bergmann 
AuthorDate: Tue May 3 20:07:43 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Tue May 3 23:20:20 2022 +0200

Just use Any ctor instead of makeAny in svl

Change-Id: Iefa570476bf0c881e36679ae9511ff63162e05d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133771
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx
index bb3e29ee2810..1f81867e658a 100644
--- a/svl/qa/unit/test_URIHelper.cxx
+++ b/svl/qa/unit/test_URIHelper.cxx
@@ -150,7 +150,7 @@ css::uno::Any Content::execute(
 }
 break;
 }
-return css::uno::makeAny(uri.toAsciiLowerCase());
+return css::uno::Any(uri.toAsciiLowerCase());
 }
 
 class Provider: public cppu::WeakImplHelper< css::ucb::XContentProvider > {
diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx
index 3ff5797fccaf..a8f4e08e519d 100644
--- a/svl/source/config/asiancfg.cxx
+++ b/svl/source/config/asiancfg.cxx
@@ -149,17 +149,17 @@ void SvxAsianConfig::SetStartEndChars(
 css::uno::Reference< css::beans::XPropertySet > el(
 v.get< css::uno::Reference< css::beans::XPropertySet > >(),
 css::uno::UNO_SET_THROW);
-el->setPropertyValue("StartCharacters", 
css::uno::makeAny(*startChars));
-el->setPropertyValue("EndCharacters", 
css::uno::makeAny(*endChars));
+el->setPropertyValue("StartCharacters", 
css::uno::Any(*startChars));
+el->setPropertyValue("EndCharacters", css::uno::Any(*endChars));
 } else {
 css::uno::Reference< css::beans::XPropertySet > el(
 (css::uno::Reference< css::lang::XSingleServiceFactory >(
 set, css::uno::UNO_QUERY_THROW)->
  createInstance()),
 css::uno::UNO_QUERY_THROW);
-el->setPropertyValue("StartCharacters", 
css::uno::makeAny(*startChars));
-el->setPropertyValue("EndCharacters", 
css::uno::makeAny(*endChars));
-css::uno::Any v2(css::uno::makeAny(el));
+el->setPropertyValue("StartCharacters", 
css::uno::Any(*startChars));
+el->setPropertyValue("EndCharacters", css::uno::Any(*endChars));
+css::uno::Any v2(el);
 try {
 set->insertByName(name, v2);
 } catch (css::container::ElementExistException &) {
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 0ae71ab53389..8d2da219d7be 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -924,9 +924,9 @@ uno::Any SAL_CALL FSStorage::getPropertyValue( const 
OUString& aPropertyName )
 ::osl::MutexGuard aGuard( m_aMutex );
 
 if ( aPropertyName == "URL" )
-return uno::makeAny( m_aURL );
+return uno::Any( m_aURL );
 else if ( aPropertyName == "OpenMode" )
-return uno::makeAny( m_nMode );
+return uno::Any( m_nMode );
 
 throw beans::UnknownPropertyException(aPropertyName); // TODO
 }
diff --git a/svl/source/misc/documentlockfile.cxx 
b/svl/source/misc/documentlockfile.cxx
index fdbbc90ba465..09d67a9e5533 100644
--- a/svl/source/misc/documentlockfile.cxx
+++ b/svl/source/misc/documentlockfile.cxx
@@ -101,7 +101,7 @@ bool GenDocumentLockFile::CreateOwnLockFile()
 
 // try to let the file be hidden if possible
 try {
-aTargetContent.setPropertyValue("IsHidden", uno::makeAny( true ) );
+aTargetContent.setPropertyValue("IsHidden", uno::Any( true ) );
 } catch( uno::Exception& ) {}
 }
 catch( ucb::NameClashException& )
@@ -159,7 +159,7 @@ void GenDocumentLockFile::RemoveFileDirectly()
 uno::Reference < css::ucb::XCommandEnvironment > xEnv;
 ::ucbhelper::Content aCnt(GetURL(), xEnv, 
comphelper::getProcessComponentContext());
 aCnt.executeCommand("delete",
-uno::makeAny(true));
+uno::Any(true));
 }
 
 
diff --git a/svl/source/misc/sharecontrolfile.cxx 
b/svl/source/misc/sharecontrolfile.cxx
index d0cdda561876..486f280533f7 100644
--- a/svl/source/misc/sharecontrolfile.cxx
+++ b/svl/source/misc/sharecontrolfile.cxx
@@ -76,11 +76,11 @@ ShareControlFile::ShareControlFile( std::u16string_view 
aOrigURL )
 ucb::InsertCommandArgument aInsertArg;
 aInsertArg.Data = xInput;
 aInsertArg.ReplaceExisting = false;
-

[Libreoffice-commits] core.git: svl/qa svl/source

2021-12-15 Thread Armin Le Grand (Allotropia) (via logerrit)
 svl/qa/unit/test_URIHelper.cxx |1 +
 svl/source/misc/urihelper.cxx  |   40 ++--
 2 files changed, 35 insertions(+), 6 deletions(-)

New commits:
commit 76f29376183be48c076ada06159581ea981de3d1
Author: Armin Le Grand (Allotropia) 
AuthorDate: Tue Dec 14 14:45:58 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Dec 15 12:26:40 2021 +0100

tdf#145381 handle closing brackets in URLs correctly

The task presents an URL that ends with a closing bracket. If
pasted to LO, the closing bracket got interpreted as not being part
of the URL due to the heuristical interpretation of URLs in
urihelper.
Adapted this to handle matching brackets, so that an closing and
ending bracket will be added to the uri text when there is a
matching pair.
Added unit test to testFindFirstURLInText with simplified uri
example.

Change-Id: I58dd460a37d0066ff46845832eabd2a790e4ccd1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126832
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx
index 68c76ad68374..bb3e29ee2810 100644
--- a/svl/qa/unit/test_URIHelper.cxx
+++ b/svl/qa/unit/test_URIHelper.cxx
@@ -322,6 +322,7 @@ void Test::testFindFirstURLInText() {
 { "{a:\\bla/bla/bla...}", "file:///a:/bla/bla/bla", 1, 15 },
 { "#b:/c/d#e#f#", "file:///b:/c/d", 1, 7 },
 { "a:/", "file:///a:/", 0, 3 },
+{ "http://sun.com/R_(l_a)", "http://sun.com/R_(l_a)", 0, 22 },
 { ".component:", nullptr, 0, 0 },
 { ".uno:", nullptr, 0, 0 },
 { "cid:", nullptr, 0, 0 },
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index 6792fc1d77f7..068aea281312 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -347,9 +347,12 @@ bool isBoundary2(CharClass const & rCharClass, OUString 
const & rStr,
 }
 }
 
+// tdf#145381 Added MatchingBracketDepth counter o detect maching closing
+// brackets that are part of the uri
 bool checkWChar(CharClass const & rCharClass, OUString const & rStr,
-sal_Int32 * pPos, sal_Int32 * pEnd, bool bBackslash = false,
-bool bPipe = false)
+sal_Int32 * pPos, sal_Int32 * pEnd,
+sal_Int32 * pMatchingBracketDepth = nullptr,
+bool bBackslash = false, bool bPipe = false)
 {
 sal_Unicode c = rStr[*pPos];
 if (rtl::isAscii(c))
@@ -360,7 +363,7 @@ bool checkWChar(CharClass const & rCharClass, OUString 
const & rStr,
 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0,
 0, 1, 0, 0, 4, 4, 4, 1,   //  !"#$%&'
-1, 1, 1, 1, 1, 4, 1, 4,   // ()*+,-./
+5, 6, 1, 1, 1, 4, 1, 4,   // ()*+,-./
 4, 4, 4, 4, 4, 4, 4, 4,   // 01234567
 4, 4, 1, 1, 0, 1, 0, 1,   // 89:;<=>?
 4, 4, 4, 4, 4, 4, 4, 4,   // @ABCDEFG
@@ -402,6 +405,24 @@ bool checkWChar(CharClass const & rCharClass, OUString 
const & rStr,
 // isBoundary1)
 *pEnd = ++(*pPos);
 return true;
+
+case 5: // opening bracket
+++(*pPos);
+if(nullptr != pMatchingBracketDepth)
+++(*pMatchingBracketDepth);
+return true;
+
+case 6: // closing bracket
+++(*pPos);
+if(nullptr != pMatchingBracketDepth && *pMatchingBracketDepth 
> 0)
+{
+--(*pMatchingBracketDepth);
+// tdf#145381 When there was an opening bracket, detect 
this closing bracket
+// as part of the uri
+*pEnd = *pPos;
+}
+return true;
+
 }
 }
 else if (rCharClass.isLetterNumeric(rStr, *pPos))
@@ -499,6 +520,11 @@ OUString URIHelper::FindFirstURLInText(OUString const & 
rText,
 // Productions 6--9 are only applicable if the FSysStyle::Dos bit is set in
 // eStyle.
 
+// tdf#145381: In addition to the productions I added a mechanism to detect
+// matching brackets. The task presents the case of an url that ends on a
+// closing bracket. This needs to be detected as part of the uri in the 
case
+// that a matching opening bracket exists.
+
 bool bBoundary1 = true;
 bool bBoundary2 = true;
 for (sal_Int32 nPos = rBegin; nPos != rEnd; nPos = nextChar(rText, nPos))
@@ -516,7 +542,7 @@ OUString URIHelper::FindFirstURLInText(OUString const & 
rText,
 sal_Int32 nPrefixEnd = i;
 sal_Int32 nUriEnd = i;
 while (i != rEnd
-   && checkWChar(rCharClass, rText, , , true,
+   && checkWChar(rCharClass, rText, , , 
nullptr, true,
  true)) ;
 if (i 

[Libreoffice-commits] core.git: svl/qa svl/source

2020-06-05 Thread Stephan Bergmann (via logerrit)
 svl/qa/unit/items/test_IndexedStyleSheets.cxx |3 +--
 svl/qa/unit/svl.cxx   |5 ++---
 svl/qa/unit/test_lngmisc.cxx  |   23 ---
 svl/source/numbers/zforlist.cxx   |3 +--
 4 files changed, 12 insertions(+), 22 deletions(-)

New commits:
commit c288a97e8983e7b98046fc3a742dda8bc1bc633e
Author: Stephan Bergmann 
AuthorDate: Fri Jun 5 08:48:07 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Jun 5 10:16:16 2020 +0200

Upcoming loplugin:elidestringvar: svl

Change-Id: I124dd9be0ca8ede61323dd77b737253c5af99ceb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95570
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/svl/qa/unit/items/test_IndexedStyleSheets.cxx 
b/svl/qa/unit/items/test_IndexedStyleSheets.cxx
index 88af521d3aef..50fd4d1ed42c 100644
--- a/svl/qa/unit/items/test_IndexedStyleSheets.cxx
+++ b/svl/qa/unit/items/test_IndexedStyleSheets.cxx
@@ -147,10 +147,9 @@ void 
IndexedStyleSheetsTest::StyleSheetsCanBeRetrievedByTheirName()
 void IndexedStyleSheetsTest::KnowsThatItStoresAStyleSheet()
 {
 OUString const name1("name1");
-OUString const name2("name2");
 rtl::Reference sheet1(new MockedStyleSheet(name1));
 rtl::Reference sheet2(new MockedStyleSheet(name1));
-rtl::Reference sheet3(new MockedStyleSheet(name2));
+rtl::Reference sheet3(new MockedStyleSheet("name2"));
 rtl::Reference sheet4(new MockedStyleSheet(name1));
 IndexedStyleSheets iss;
 iss.AddStyleSheet(sheet1);
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 2c266e4d9d31..8362c9fbc88b 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -343,13 +343,12 @@ void Test::testSharedStringPool()
 CPPUNIT_ASSERT_EQUAL(p1.getData(), p2.getData());
 
 // Test case insensitive string ID's.
-OUString const aAndyLower("andy"), aAndyUpper("ANDY");
 p1 = aPool.intern(aAndy);
-p2 = aPool.intern(aAndyLower);
+p2 = aPool.intern("andy");
 CPPUNIT_ASSERT_MESSAGE("Failed to intern strings.", p1.getData() && 
p2.getData());
 CPPUNIT_ASSERT_MESSAGE("These two ID's should differ.", p1.getData() != 
p2.getData());
 CPPUNIT_ASSERT_EQUAL_MESSAGE("These two ID's should be equal.", 
p2.getDataIgnoreCase(), p1.getDataIgnoreCase());
-p2 = aPool.intern(aAndyUpper);
+p2 = aPool.intern("ANDY");
 CPPUNIT_ASSERT_MESSAGE("Failed to intern string.", p2.getData());
 CPPUNIT_ASSERT_MESSAGE("These two ID's should differ.", p1.getData() != 
p2.getData());
 CPPUNIT_ASSERT_EQUAL_MESSAGE("These two ID's should be equal.", 
p2.getDataIgnoreCase(), p1.getDataIgnoreCase());
diff --git a/svl/qa/unit/test_lngmisc.cxx b/svl/qa/unit/test_lngmisc.cxx
index 5193eb33e159..9287c72365da 100644
--- a/svl/qa/unit/test_lngmisc.cxx
+++ b/svl/qa/unit/test_lngmisc.cxx
@@ -133,37 +133,30 @@ namespace
 
   void LngMiscTest::testGetThesaurusReplaceText()
   {
-const OUString str1("");
 const OUString str2("asdf");
-const OUString str3("asdf (abc)");
-const OUString str4("asdf*");
-const OUString str5("asdf * ");
-const OUString str6("asdf (abc) *");
-const OUString str7("asdf asdf * (abc)");
-const OUString str8(" * (abc) asdf *");
-
-OUString r = linguistic::GetThesaurusReplaceText(str1);
+
+OUString r = linguistic::GetThesaurusReplaceText("");
 CPPUNIT_ASSERT(r.isEmpty());
 
 r = linguistic::GetThesaurusReplaceText(str2);
 CPPUNIT_ASSERT_EQUAL(str2, r);
 
-r = linguistic::GetThesaurusReplaceText(str3);
+r = linguistic::GetThesaurusReplaceText("asdf (abc)");
 CPPUNIT_ASSERT_EQUAL(str2, r);
 
-r = linguistic::GetThesaurusReplaceText(str4);
+r = linguistic::GetThesaurusReplaceText("asdf*");
 CPPUNIT_ASSERT_EQUAL(str2, r);
 
-r = linguistic::GetThesaurusReplaceText(str5);
+r = linguistic::GetThesaurusReplaceText("asdf * ");
 CPPUNIT_ASSERT_EQUAL(str2, r);
 
-r = linguistic::GetThesaurusReplaceText(str6);
+r = linguistic::GetThesaurusReplaceText("asdf (abc) *");
 CPPUNIT_ASSERT_EQUAL(str2, r);
 
-r = linguistic::GetThesaurusReplaceText(str7);
+r = linguistic::GetThesaurusReplaceText("asdf asdf * (abc)");
 CPPUNIT_ASSERT_EQUAL(OUString("asdf asdf"), r);
 
-r = linguistic::GetThesaurusReplaceText(str8);
+r = linguistic::GetThesaurusReplaceText(" * (abc) asdf *");
 CPPUNIT_ASSERT(r.isEmpty());
   }
 
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index f8652a0c1284..fa501943c341 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1016,8 +1016,7 @@ sal_uInt32 SvNumberFormatter::ImpGenerateCL( LanguageType 
eLnge )
 const LanguageTag& rLoadedLocale = 
xLocaleData->getLoadedLanguageTag();
 if ( !rLoadedLocale.equals( maLanguageTag ) )
 {
-OUString const aMsg("SvNumberFormatter::ImpGenerateCL: locales 
don't match:");
-

[Libreoffice-commits] core.git: svl/qa svl/source

2020-06-03 Thread Noel Grandin (via logerrit)
 svl/qa/unit/svl.cxx  |4 ++--
 svl/source/misc/sharedstringpool.cxx |7 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 4aa6ae8ba911bd3420d3b74c085aa69d87339f4d
Author: Noel Grandin 
AuthorDate: Wed Jun 3 14:35:27 2020 +0200
Commit: Noel Grandin 
CommitDate: Wed Jun 3 21:59:21 2020 +0200

fix ubsan in SharedStringPool

with a slightly dodgy fix.

regression from
commit 3581f1d71ae0d431ba28c0f3b7b263ff6212ce7b
optimize SharedStringPool::purge() and fix tests

It's not ideal - we no longer have a way of purging uppercase keys that
are longer in use.
But that doesn't cost much memory, because we are sharing those strings.

We could potentially identify them with extra book-keeping in either
intern() or purge(), but since this class is performance-sensitive, best
just to sacrifice some space in the map.

Change-Id: I85a469448f5b36b1b6889da60280edd56bbcb083
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95432
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 6b44a96729d1..2c266e4d9d31 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -392,10 +392,10 @@ void Test::testSharedStringPoolPurge()
 CPPUNIT_ASSERT_EQUAL(static_cast(3), aPool.getCount());
 CPPUNIT_ASSERT_EQUAL(static_cast(2), aPool.getCountIgnoreCase());
 
-// Ditto...
+// Nothing changes, because the upper-string is still in the map
 pStr3.reset();
 aPool.purge();
-CPPUNIT_ASSERT_EQUAL(static_cast(2), aPool.getCount());
+CPPUNIT_ASSERT_EQUAL(static_cast(3), aPool.getCount());
 CPPUNIT_ASSERT_EQUAL(static_cast(2), aPool.getCountIgnoreCase());
 
 // Again.
diff --git a/svl/source/misc/sharedstringpool.cxx 
b/svl/source/misc/sharedstringpool.cxx
index 25898084f327..d2d890004fbd 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -60,7 +60,12 @@ SharedString SharedStringPool::intern( const OUString& rStr )
 // need to use the same underlying rtl_uString object so the
 // upper->upper detection in purge() works
 auto pData = insertResult.first->pData;
-mpImpl->maStrMap.insert_or_assign(mapIt, pData, pData);
+// This is dodgy, but necessary. I don't want to do a 
delete/insert because
+// this class is very performance sensitive. This does not violate 
the internals
+// the map because the new key points to something with the same 
hash and equality
+// as the old key.
+const_cast(mapIt->first) = *insertResult.first;
+mapIt->second = pData;
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2020-06-02 Thread Noel Grandin (via logerrit)
 svl/qa/unit/svl.cxx  |   15 +++-
 svl/source/misc/sharedstringpool.cxx |   60 ---
 2 files changed, 54 insertions(+), 21 deletions(-)

New commits:
commit 3581f1d71ae0d431ba28c0f3b7b263ff6212ce7b
Author: Noel Grandin 
AuthorDate: Sat May 30 10:46:41 2020 +0200
Commit: Noel Grandin 
CommitDate: Tue Jun 2 15:32:26 2020 +0200

optimize SharedStringPool::purge() and fix tests

which were checking the wrong thing - we don't care
about the input strings to intern(), we care
about which SharedString objects are still alive.

Change-Id: Ia35a173a02a24efb335268dcae4078a956d11098
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95177
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 488cc04ecde7..6b44a96729d1 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -36,6 +36,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 using namespace ::com::sun::star;
@@ -371,15 +372,11 @@ void Test::testSharedStringPoolPurge()
 CPPUNIT_ASSERT_EQUAL(static_cast(0), aPool.getCount());
 CPPUNIT_ASSERT_EQUAL(static_cast(0), aPool.getCountIgnoreCase());
 
-// Now, create string objects on the heap.
-std::unique_ptr pStr1(new OUString("Andy"));
-std::unique_ptr pStr2(new OUString("andy"));
-std::unique_ptr pStr3(new OUString("ANDY"));
-std::unique_ptr pStr4(new OUString("Bruce"));
-aPool.intern(*pStr1);
-aPool.intern(*pStr2);
-aPool.intern(*pStr3);
-aPool.intern(*pStr4);
+// Now, create string objects using optional so we can clear them
+std::optional pStr1 = aPool.intern("Andy");
+std::optional pStr2 = aPool.intern("andy");
+std::optional pStr3 = aPool.intern("ANDY");
+std::optional pStr4 = aPool.intern("Bruce");
 
 CPPUNIT_ASSERT_EQUAL(static_cast(4), aPool.getCount());
 CPPUNIT_ASSERT_EQUAL(static_cast(2), aPool.getCountIgnoreCase());
diff --git a/svl/source/misc/sharedstringpool.cxx 
b/svl/source/misc/sharedstringpool.cxx
index 5c26c912bc42..25898084f327 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -31,7 +31,7 @@ struct SharedStringPool::Impl
 mutable osl::Mutex maMutex;
 // set of upper-case, so we can share these as the value in the maStrMap
 std::unordered_set maStrPoolUpper;
-// map with rtl_uString* as key so we can avoid some ref-counting
+// map with rtl_uString* as value so we can avoid some ref-counting
 std::unordered_map maStrMap;
 const CharClass& mrCharClass;
 
@@ -57,7 +57,10 @@ SharedString SharedStringPool::intern( const OUString& rStr )
 if (aUpper == rStr)
 {
 auto insertResult = mpImpl->maStrPoolUpper.insert(rStr);
-mapIt->second = insertResult.first->pData;
+// need to use the same underlying rtl_uString object so the
+// upper->upper detection in purge() works
+auto pData = insertResult.first->pData;
+mpImpl->maStrMap.insert_or_assign(mapIt, pData, pData);
 }
 else
 {
@@ -72,23 +75,56 @@ void SharedStringPool::purge()
 {
 osl::MutexGuard aGuard(>maMutex);
 
-std::unordered_set aNewStrPoolUpper;
+// Because we can have an uppercase entry mapped to itself,
+// and then a bunch of lowercase entries mapped to that same
+// upper-case entry, we need to scan the map twice - the first
+// time to remove lowercase entries, and then only can we
+// check for unused uppercase entries.
+
+auto it = mpImpl->maStrMap.begin();
+auto itEnd = mpImpl->maStrMap.end();
+while (it != itEnd)
 {
-auto it = mpImpl->maStrMap.begin(), itEnd = mpImpl->maStrMap.end();
-while (it != itEnd)
+rtl_uString* p1 = it->first.pData;
+rtl_uString* p2 = it->second;
+if (p1 != p2)
 {
-const rtl_uString* p = it->first.pData;
-if (getRefCount(p) == 1)
+// normal case - lowercase mapped to uppercase, which
+// means that the lowercase entry has one ref-counted
+// entry as the key in the map
+if (getRefCount(p1) == 1)
+{
 it = mpImpl->maStrMap.erase(it);
-else
+// except that the uppercase entry may be mapped to
+// by other lower-case entries
+if (getRefCount(p2) == 1)
+mpImpl->maStrPoolUpper.erase(OUString::unacquired());
+continue;
+}
+}
+++it;
+}
+
+it = mpImpl->maStrMap.begin();
+itEnd = mpImpl->maStrMap.end();
+while (it != itEnd)
+{
+rtl_uString* p1 = it->first.pData;
+rtl_uString* p2 = it->second;
+if (p1 == p2)
+{
+// uppercase which is mapped to itself, which means
+// one ref-counted entry as the key in the map, and
+  

[Libreoffice-commits] core.git: svl/qa svl/source

2020-05-25 Thread DaeHyun Sung (via logerrit)
 svl/qa/unit/svl.cxx|   34 +-
 svl/source/numbers/zformat.cxx |8 
 2 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit 51404171449eadcb69057ff03cbb7bdb0117910b
Author: DaeHyun Sung 
AuthorDate: Sun May 24 11:11:04 2020 +0900
Commit: Eike Rathke 
CommitDate: Mon May 25 22:56:21 2020 +0200

Remapping NatNum-DBNum in Korean for compatibility tdf#130193

Remapping NatNum-DBNum in Korean for compatibility tdf#130193
Unlike Japanese and Chinese[Simplified, Traditional] environment on Excel, 
In Korean Situation, Excel exist DBNum1~4.

I checked DBNum1~4 series on Excel 2016 in Korean Environment.

DBNum1  1234567890  一十二億三千四百五十六万七千八百九十
DBNum2  1234567890  壹拾貳億參阡四百伍拾六萬七阡八百九拾
DBNum3  1234567890  十2億3千4百5十6万7千8百9十
DBNum4  1234567890  일십이억삼천사백오십육만칠천팔백구십

Also, I checked  Korean Number to Strings on LibreOffice.
[natnum1]   1234567890  一二三四五六七八九〇
[natnum2]   1234567890  壹貳參四伍六七八九零
[natnum3]   1234567890  1234567890
[natnum4]   1234567890  一十二億三千四百五十六万七千八百九十
[natnum5]   1234567890  壹拾貳億參阡四佰伍拾六萬七阡八佰九拾
[natnum6]   1234567890  1십2억3천4백5십6만7천8백9십
[natnum7]   1234567890  十二億三千四百五十六万七千八百九十
[natnum8]   1234567890  拾貳億參阡四佰伍拾六萬七阡八佰九拾
[natnum9]   1234567890  일이삼사오육칠팔구영
[natnum10]  1234567890  일십이억삼천사백오십육만칠천팔백구십
[natnum11]  1234567890  십이억삼천사백오십육만칠천팔백구십

I also checked Korean billion units test.
[natnum1]   123456789012一二三四五六七八九〇一二
[natnum2]   123456789012壹貳參四五六七八九零壹貳
[natnum3]   123456789012123456789012
[natnum4]   123456789012一千二百三十四億五千六百七十八万九千一十二
[natnum5]   123456789012壹仟貳佰參拾四億五仟六佰七拾八萬九仟壹拾貳
[natnum6]   1234567890121천2백3십4억5천6백7십8만9천1십2
[natnum7]   123456789012千二百三十四億五千六百七十八万九千十二
[natnum8]   123456789012仟貳佰參拾四億五仟六佰七拾八萬九仟拾貳
[natnum9]   123456789012일이삼사오육칠팔구영일이
[natnum10]  123456789012일천이백삼십사억오천육백칠십팔만구천일십이
[natnum11]  123456789012천이백삼십사억오천육백칠십팔만구천십이

As a result,
1. from DBNum to NatNum (import):
 - DBNum1 -> NatNum4 (Korean Hanja text 한자숫자)
 - DBNum2 -> NatNum5 (Korean Upper Hanja text 갖은자)
 - DBNum3 -> NatNum6 (fullwidth Arabic digits with Korean hanja unit of 
Numbering)
 - DBNum4 -> NatNum10 (Korean Hangul text)

I found the Bug for NatNum6 (I'll change Korean Hangul to Hanja for 
compatibility)

2. From NatNum to DBNum
 - NatNum1 -> DBNum1
 - NatNum2 -> DBNum2
 - NatNum3 -> DBNum3
 - NatNum4 -> DBNum1
 - NatNum5 -> DBNum2
 - NatNum6 -> DBNum3
 - NatNum7 -> DBNum1
 - NatNum8 -> DBNum2
 - NatNum9 -> DBNum4
 - NatNum10 -> DBNum4
 - NatNum11 -> DBNum4

By the way, I change test cases for Korean.
It is included in svl/qa/unit/svl.cxx

It solves the issue tdf#130140
Also, It related the issue tdf#130077

Change-Id: Idb7f3defc5f19e3edc4c179b0a081d2abe8ee3a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94747
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 80be2b2af79a..5d045a8d00ca 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1510,36 +1510,36 @@ void Test::testUserDefinedNumberFormats()
 sCode = "[DBNum3][$-0411]General\\ ";
 checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
 
-// -- Korean: DBNum1 -> NatNum1, DBNum2 -> NatNum2, DBNum3 -> NatNum4, 
DBNum4 -> NatNum9
+// -- Korean: DBNum1 -> NatNum4, DBNum2 -> NatNum5, DBNum3 -> NatNum6, 
DBNum4 -> NatNum10
 
-// DBNum1 -> NatNum1: Korean lower case characters
-// 一二三四五六七八九
-sExpected = u"\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d ";
-sCode = "[NatNum1][$-0412]General\\ ";
+// DBNum1 -> NatNum4: Korean lower case characters
+// 一億二千三百四十五万六千七百八十九
+sExpected = 
u"\u4e00\u5104\u4e8c\u5343\u4e09\u767e\u56db\u5341\u4e94\u4e07\u516d\u5343\u4e03\u767e\u516b\u5341\u4e5d
 ";
+sCode = "[NatNum4][$-0412]General\\ ";
 checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
 sCode = "[DBNum1][$-0412]General\\ ";
 checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
 
-// DBNum2 -> NatNum2: Korean upper case characters
-// 壹貳參四伍六七八九
-sExpected = u"\u58f9\u8cb3\u53c3\u56db\u4f0d\u516d\u4e03\u516b\u4e5d ";
-sCode = "[NatNum2][$-0412]General\\ ";
+// DBNum2 -> NatNum5: Korean upper case characters
+// 壹億貳阡參佰四拾伍萬六阡七佰八拾九
+sExpected = 
u"\u58f9\u5104\u8cb3\u9621\u53c3\u4f70\u56db\u62fe\u4f0d\u842c\u516d\u9621\u4e03\u4f70\u516b\u62fe\u4e5d
 ";
+sCode = "[NatNum5][$-0412]General\\ ";
 checkPreviewString(aFormatter, sCode, 

[Libreoffice-commits] core.git: svl/qa svl/source

2020-05-25 Thread Naruhiko Ogasawara (via logerrit)
 svl/qa/unit/svl.cxx|   91 ++
 svl/source/numbers/zformat.cxx |   96 -
 2 files changed, 111 insertions(+), 76 deletions(-)

New commits:
commit 9efd7cd637d9d882f2fc8277b657ec117c591e80
Author: Naruhiko Ogasawara 
AuthorDate: Wed May 6 20:55:49 2020 +0900
Commit: Eike Rathke 
CommitDate: Mon May 25 22:51:22 2020 +0200

tdf#130193: Asian Excel-Calc number format interop

remap NatNum - DBNum in Japanese/Chinese to improve
Excel interoprability

from DBNum to NatNum (import) in ja/zh:

- DBNum1 -> NatNum4 (modern long Kanji text)
- DBNum2 -> NatNum5 (traditional long Kanji text)
- DBNum3 -> NatNum3 (fullwidth Arabic digits)

from NatNum to DBNum (export) in ja:

- NatNum1 -> DBNum1
- NatNum2 -> DBNum2
- NatNum3 -> DBNum3
- NatNum4 -> DBNum1
- NatNum5 -> DBNum2
- NatNum6 -> DBNum3
- NatNum7 -> DBNum1
- NatNum8 -> DBNum2
- NatNum9 -> (DBNum0, as Arabic)

in zh, nothing change about export.

It also partially solves the issue tdf#130140
(about Japanese, not Korean)

To do this, more data-drivened MapDBNumToNatNum() and
MapNatNumToDBNum() in svl/source/numbers/zformat.cxx

By mapping "NatNum - DBNum" to a table using map and array, it
makes the specification for each language more understandable

The new test cases are also included in svl/qa/unit/svl.cxx

Change-Id: I34a70d970ef2e46c1b3db5db1c397ab89c056191
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94376
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index fc541861f182..80be2b2af79a 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1453,6 +1453,97 @@ void Test::testUserDefinedNumberFormats()
 checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected);
 #endif
 }
+{ // tdf#130193 tdf#130140 Native Number Formats mapping for Chinese 
(Traditonal), Japanese, Korean
+// -- Traditional Chinese: DBNum1 -> NatNum4, DBNum2 -> NatNum5, 
DBnum3 -> NatNum3
+
+// DBNum1 -> NatNum4: Chinese lower case text for 123456789
+// 一億二千三百四十五萬六千七百八十九
+sExpected = 
u"\u4e00\u5104\u4e8c\u5343\u4e09\u767e\u56db\u5341\u4e94\u842c\u516d\u5343"
+u"\u4e03\u767e\u516b\u5341\u4e5d ";
+sCode = "[NatNum4][$-0404]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+sCode = "[DBNum1][$-0404]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+
+// DBNum2 -> NatNum5: Chinese upper case text
+// 壹億貳仟參佰肆拾伍萬陸仟柒佰捌拾玖
+sExpected = 
u"\u58f9\u5104\u8cb3\u4edf\u53c3\u4f70\u8086\u62fe\u4f0d\u842c\u9678\u4edf"
+u"\u67d2\u4f70\u634c\u62fe\u7396 ";
+sCode = "[NatNum5][$-0404]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+sCode = "[DBNum2][$-0404]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+
+// DBNum3 -> NatNum3: fullwidth text
+// 123456789
+sExpected = u"\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19 ";
+sCode = "[NatNum3][$-0404]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+sCode = "[DBNum3][$-0404]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+
+// -- Japanese: DBNum1 -> NatNum4, DBNum2 -> NatNum5, DBnum3 -> NatNum3
+
+// DBNum1 -> NatNum4: Japanese modern long Kanji text for 123456789
+// 一億二千三百四十五万六千七百八十九
+sExpected = 
u"\u4e00\u5104\u4e8c\u5343\u4e09\u767e\u56db\u5341\u4e94\u4e07\u516d\u5343"
+u"\u4e03\u767e\u516b\u5341\u4e5d ";
+sCode = "[NatNum4][$-0411]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+sCode = "[DBNum1][$-0411]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+
+// DBNum2 -> NatNum5: traditional long Kanji text
+// 壱億弐阡参百四拾伍萬六阡七百八拾九
+sExpected = 
u"\u58f1\u5104\u5f10\u9621\u53c2\u767e\u56db\u62fe\u4f0d\u842c\u516d\u9621"
+u"\u4e03\u767e\u516b\u62fe\u4e5d ";
+sCode = "[NatNum5][$-0411]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+sCode = "[DBNum2][$-0411]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+
+// DBNum3 -> NatNum3: fullwidth Arabic digits
+// 123456789
+sExpected = u"\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19 ";
+sCode = "[NatNum3][$-0411]General\\ ";
+checkPreviewString(aFormatter, sCode, 123456789, eLang, sExpected);
+sCode = "[DBNum3][$-0411]General\\ 

[Libreoffice-commits] core.git: svl/qa svl/source

2020-03-13 Thread Noel Grandin (via logerrit)
 svl/qa/unit/svl.cxx  |8 
 svl/source/crypto/cryptosign.cxx |6 +++---
 svl/source/fsstor/fsstorage.cxx  |4 ++--
 svl/source/items/style.cxx   |2 +-
 svl/source/misc/gridprinter.cxx  |2 +-
 svl/source/undo/undo.cxx |6 +++---
 svl/source/uno/pathservice.cxx   |2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit df3e1b7bbd126ed114015070bf68db30fbe9516e
Author: Noel Grandin 
AuthorDate: Fri Mar 13 10:01:24 2020 +0200
Commit: Noel Grandin 
CommitDate: Fri Mar 13 19:21:01 2020 +0100

Revert "loplugin:constfields in svl"

This reverts commit 5181253946ca1877cc42050452aa6d733d6da3f1.

Change-Id: I30e30aae45c33824c0df823a9fad710faa81ea3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90453
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 707754ac920f..fc541861f182 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -244,9 +244,9 @@ void Test::testNumberFormat()
 };
 
 struct {
-NfIndexTableOffset const eStart;
-NfIndexTableOffset const eEnd;
-size_t const nSize;
+NfIndexTableOffset eStart;
+NfIndexTableOffset eEnd;
+size_t nSize;
 const char** pCodes;
 } aTests[] = {
 { NF_NUMBER_START, NF_NUMBER_END, 6, pNumber },
@@ -1114,7 +1114,7 @@ void Test::testIsNumberFormat()
 static struct NumberFormatData
 {
 const char* pFormat;
-bool const bIsNumber;
+bool bIsNumber;
 } const aTests[] = {
 { "20.3", true },
 { "2", true },
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx
index 483a9ee31638..573c06ba5826 100644
--- a/svl/source/crypto/cryptosign.cxx
+++ b/svl/source/crypto/cryptosign.cxx
@@ -121,9 +121,9 @@ Extension  ::=  SEQUENCE  {
 */
 
 struct Extension {
-SECItem const extnID;
-SECItem const critical;
-SECItem const extnValue;
+SECItem  extnID;
+SECItem  critical;
+SECItem  extnValue;
 };
 
 /*
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 0b566b2ac15d..344d4b01c751 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -60,9 +60,9 @@ using namespace ::com::sun::star;
 
 struct FSStorage_Impl
 {
-OUString const m_aURL;
+OUString  m_aURL;
 ::ucbhelper::Content m_aContent;
-sal_Int32 const m_nMode;
+sal_Int32 m_nMode;
 std::unique_ptr<::comphelper::OInterfaceContainerHelper2> 
m_pListenersContainer; // list of listeners
 uno::Reference< uno::XComponentContext > m_xContext;
 
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 6d2095ad93b3..f8bbd6c25936 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -387,7 +387,7 @@ struct DoesStyleMatchStyleSheetPredicate final : public 
svl::StyleSheetPredicate
 return bMatches;
 }
 
-SfxStyleSheetIterator * const mIterator;
+SfxStyleSheetIterator *mIterator;
 };
 
 }
diff --git a/svl/source/misc/gridprinter.cxx b/svl/source/misc/gridprinter.cxx
index b40dd049c8ef..ae910e4f0cf7 100644
--- a/svl/source/misc/gridprinter.cxx
+++ b/svl/source/misc/gridprinter.cxx
@@ -55,7 +55,7 @@ typedef mdds::multi_type_matrix MatrixImplType;
 struct GridPrinter::Impl
 {
 MatrixImplType maMatrix;
-bool const mbPrint;
+bool mbPrint;
 
 Impl( size_t nRows, size_t nCols, bool bPrint ) :
 maMatrix(nRows, nCols, OUString()), mbPrint(bPrint) {}
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 868982813f98..a08e451e471d 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -1258,11 +1258,11 @@ void SfxUndoManager::EmptyActionsChanged()
 
 struct SfxListUndoAction::Impl
 {
-sal_uInt16 const mnId;
-ViewShellId const mnViewShellId;
+sal_uInt16 mnId;
+ViewShellId mnViewShellId;
 
 OUString maComment;
-OUString const maRepeatComment;
+OUString maRepeatComment;
 
 Impl( sal_uInt16 nId, ViewShellId nViewShellId, const OUString& rComment, 
const OUString& rRepeatComment ) :
 mnId(nId), mnViewShellId(nViewShellId), maComment(rComment), 
maRepeatComment(rRepeatComment) {}
diff --git a/svl/source/uno/pathservice.cxx b/svl/source/uno/pathservice.cxx
index c0b951f15046..b1d109894bf3 100644
--- a/svl/source/uno/pathservice.cxx
+++ b/svl/source/uno/pathservice.cxx
@@ -34,7 +34,7 @@ namespace {
 
 class PathService : public ::cppu::WeakImplHelper< css::frame::XConfigManager, 
css::lang::XServiceInfo >
 {
-SvtPathOptions const m_aOptions;
+SvtPathOptions m_aOptions;
 
 public:
 PathService()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2020-02-07 Thread Stephan Bergmann (via logerrit)
 svl/qa/unit/test_URIHelper.cxx |   13 +
 svl/source/misc/urihelper.cxx  |   10 ++
 2 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 4c0394461af4d6bcba059161113abffbb484efe8
Author: Stephan Bergmann 
AuthorDate: Fri Feb 7 15:34:33 2020 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Feb 7 21:27:00 2020 +0100

tdf#130501: Fix off-by-one error in URIHelper::resolveIdnaHost

Change-Id: Ibc231308d0fc93085933ae7d80dc8c4b2699fe02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88204
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx
index dcfd64b871f6..68c76ad68374 100644
--- a/svl/qa/unit/test_URIHelper.cxx
+++ b/svl/qa/unit/test_URIHelper.cxx
@@ -458,6 +458,19 @@ void Test::testResolveIdnaHost() {
 CPPUNIT_ASSERT_EQUAL(
 OUString("foo://xn--mnchen-3ya.de"),
 URIHelper::resolveIdnaHost(u"foo://Mu\u0308nchen.de"));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString("foo://example.xn--m-eha"), 
URIHelper::resolveIdnaHost(u"foo://example.mü"));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString("foo://example.xn--m-eha:0"), 
URIHelper::resolveIdnaHost(u"foo://example.mü:0"));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString("foo://xn--e1afmkfd.xn--p1ai"), 
URIHelper::resolveIdnaHost(u"foo://пример.рф"));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString("foo://xn--e1afmkfd.xn--p1ai:0"),
+URIHelper::resolveIdnaHost(u"foo://пример.рф:0"));
 }
 
 css::uno::Reference< css::uno::XComponentContext > Test::m_context;
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index 62177ac79e25..127134d1ab72 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -742,12 +742,14 @@ OUString URIHelper::resolveIdnaHost(OUString const & url) 
{
 if (auth.isEmpty())
 return url;
 sal_Int32 hostStart = auth.indexOf('@') + 1;
-sal_Int32 hostEnd = auth.getLength() - 1;
-while (hostEnd > hostStart && rtl::isAsciiDigit(auth[hostEnd])) {
+sal_Int32 hostEnd = auth.getLength();
+while (hostEnd > hostStart && rtl::isAsciiDigit(auth[hostEnd - 1])) {
 --hostEnd;
 }
-if (!(hostEnd > hostStart && auth[hostEnd] == ':')) {
-hostEnd = auth.getLength() - 1;
+if (hostEnd > hostStart && auth[hostEnd - 1] == ':') {
+--hostEnd;
+} else {
+hostEnd = auth.getLength();
 }
 auto asciiOnly = true;
 for (auto i = hostStart; i != hostEnd; ++i) {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source xmloff/source

2019-08-12 Thread Andrea Gelmini (via logerrit)
 svl/qa/unit/svl.cxx |2 +-
 svl/source/items/style.cxx  |2 +-
 svl/source/items/stylepool.cxx  |2 +-
 svl/source/numbers/supservs.cxx |2 +-
 svl/source/numbers/supservs.hxx |4 ++--
 svl/source/numbers/zforfind.cxx |2 +-
 svl/source/undo/undo.cxx|2 +-
 xmloff/source/draw/ximpshap.cxx |2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit d4cea44bf212da4365deb4593f5c1957798f6629
Author: Andrea Gelmini 
AuthorDate: Sun Aug 11 12:37:46 2019 +0200
Commit: Julien Nabet 
CommitDate: Mon Aug 12 10:38:49 2019 +0200

Fix typos

Change-Id: I359ac987daa01e624bdf889c319eeb660f88bbfd
Reviewed-on: https://gerrit.libreoffice.org/77260
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 4a781627f9bc..9136dc76e930 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -108,7 +108,7 @@ Test::Test()
 
 //Without this we're crashing because callees are using
 //getProcessServiceFactory.  In general those should be removed in favour
-//of retaining references to the root ServiceFactory as its passed around
+//of retaining references to the root ServiceFactory as it's passed around
 comphelper::setProcessServiceFactory(xSM);
 m_pDefaultTimeZone.reset(icu::TimeZone::createDefault());
 }
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 4ce1a225948a..9e15baa034f5 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -637,7 +637,7 @@ SfxStyleSheetBase* SfxStyleSheetBasePool::Create( const 
SfxStyleSheetBase& r )
 
 SfxStyleSheetBase& SfxStyleSheetBasePool::Make( const OUString& rName, 
SfxStyleFamily eFam, SfxStyleSearchBits mask)
 {
-OSL_ENSURE( eFam != SfxStyleFamily::All, 
"svl::SfxStyleSheetBasePool::Make(), FamilyAll is not a allowed Familie" );
+OSL_ENSURE( eFam != SfxStyleFamily::All, 
"svl::SfxStyleSheetBasePool::Make(), FamilyAll is not an allowed Family" );
 
 SfxStyleSheetIterator aIter(this, eFam, mask);
 rtl::Reference< SfxStyleSheetBase > xStyle( aIter.Find( rName ) );
diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx
index 33e8fddbce11..14f30f35b26a 100644
--- a/svl/source/items/stylepool.cxx
+++ b/svl/source/items/stylepool.cxx
@@ -415,7 +415,7 @@ std::shared_ptr StylePoolImpl::insertItemSet( 
const SfxItemSet& rSet
 }
 // Every leaf node represents an inserted item set, but "non-leaf" nodes 
represents subsets
 // of inserted itemsets.
-// These nodes could have but does not need to have a shared_ptr to a item 
set.
+// These nodes could have but does not need to have a shared_ptr to an 
item set.
 if( !pCurNode->hasItemSet( false ) )
 {
 pCurNode->setItemSet( rSet );
diff --git a/svl/source/numbers/supservs.cxx b/svl/source/numbers/supservs.cxx
index bbdf1dc7c70d..307dbd11cbb2 100644
--- a/svl/source/numbers/supservs.cxx
+++ b/svl/source/numbers/supservs.cxx
@@ -66,7 +66,7 @@ void SAL_CALL 
SvNumberFormatsSupplierServiceObject::initialize( const Sequence<
 // maybe you already called a method which needed the formatter
 // you should use XMultiServiceFactory::createInstanceWithArguments to 
avoid that
 if (m_pOwnFormatter)
-{   // !!! this is only a emergency handling, normally this should not 
occur !!!
+{   // !!! this is only an emergency handling, normally this should not 
occur !!!
 m_pOwnFormatter.reset();
 SetNumberFormatter(m_pOwnFormatter.get());
 }
diff --git a/svl/source/numbers/supservs.hxx b/svl/source/numbers/supservs.hxx
index 88676b5e5668..64ed4b3fe943 100644
--- a/svl/source/numbers/supservs.hxx
+++ b/svl/source/numbers/supservs.hxx
@@ -28,7 +28,7 @@
 
 /**
  * SvNumberFormatsSupplierServiceObject - a number formats supplier which
- * - can be instantiated as an service
+ * - can be instantiated as a service
  * - works with its own SvNumberFormatter instance
  * - can be initialized (css::lang::XInitialization)
  * with a specific language (i.e. css::lang::Locale)
@@ -70,7 +70,7 @@ public:
 virtual css::uno::Reference< css::util::XNumberFormats > SAL_CALL
 getNumberFormats() override;
 
-// XUnoTunnler
+// XUnoTunneler
 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
sal_Int8 >& aIdentifier ) override;
 };
 
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 63209ca04b0c..ea7b9ee61c0d 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -2343,7 +2343,7 @@ bool ImpSvNumberInputScan::ScanStartString( const 
OUString& rString )
 if (nPos < rString.getLength() || (nStringsCnt >= 4 && 
nNumericsCnt >= 2))
 {
 nMonth = nTempMonth;
-nMonthPos = 1; // month a the beginning
+nMonthPos = 1; // 

[Libreoffice-commits] core.git: svl/qa svl/source

2019-04-20 Thread Noel Grandin (via logerrit)
 svl/qa/unit/items/test_itempool.cxx |   18 +++
 svl/source/inc/poolio.hxx   |   13 ++---
 svl/source/items/itempool.cxx   |   91 ++--
 svl/source/items/poolio.cxx |5 -
 4 files changed, 55 insertions(+), 72 deletions(-)

New commits:
commit bcb0c9b4bee1d943d9c60f9d4512dba901f85f54
Author: Noel Grandin 
AuthorDate: Wed Apr 17 15:39:06 2019 +0200
Commit: Noel Grandin 
CommitDate: Sat Apr 20 08:17:12 2019 +0200

flatten SfxItemPool_Impl (tdf#81765 related)

Flatten the vector of SfxPoolItemArray_Impl, to reduce pointer chasing.
This struct is movable, etc, so no need to allocate it separately on the
heap.

Change-Id: I794b4356660e9cd0e63bc98b011f58162a838662
Reviewed-on: https://gerrit.libreoffice.org/70884
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/svl/qa/unit/items/test_itempool.cxx 
b/svl/qa/unit/items/test_itempool.cxx
index 9b5528532515..e08c77d01378 100644
--- a/svl/qa/unit/items/test_itempool.cxx
+++ b/svl/qa/unit/items/test_itempool.cxx
@@ -43,17 +43,17 @@ void PoolItemTest::testPool()
 SfxItemPool *pPool = new SfxItemPool("testpool", 1, 4, aItems);
 SfxItemPool_Impl *pImpl = SfxItemPool_Impl::GetImpl(pPool);
 CPPUNIT_ASSERT(pImpl != nullptr);
-CPPUNIT_ASSERT_EQUAL(static_cast(4), pImpl->maPoolItems.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(4), 
pImpl->maPoolItemArrays.size());
 
 // Poolable
 SfxVoidItem aItemOne( 1 );
 SfxVoidItem aNotherOne( 1 );
 
 {
-CPPUNIT_ASSERT(!pImpl->maPoolItems[0]);
+CPPUNIT_ASSERT(pImpl->maPoolItemArrays[0].empty());
 const SfxPoolItem  = pPool->Put(aItemOne);
 CPPUNIT_ASSERT(bool(rVal == aItemOne));
-CPPUNIT_ASSERT(pImpl->maPoolItems[0] != nullptr);
+CPPUNIT_ASSERT(!pImpl->maPoolItemArrays[0].empty());
 const SfxPoolItem  = pPool->Put(aNotherOne);
 CPPUNIT_ASSERT(bool(rVal2 == rVal));
 CPPUNIT_ASSERT_EQUAL(, );
@@ -69,10 +69,10 @@ void PoolItemTest::testPool()
 SfxVoidItem aItemTwo( 2 );
 SfxVoidItem aNotherTwo( 2 );
 {
-CPPUNIT_ASSERT(!pImpl->maPoolItems[1]);
+CPPUNIT_ASSERT(pImpl->maPoolItemArrays[1].empty());
 const SfxPoolItem  = pPool->Put(aItemTwo);
 CPPUNIT_ASSERT(bool(rVal == aItemTwo));
-CPPUNIT_ASSERT(pImpl->maPoolItems[1] != nullptr);
+CPPUNIT_ASSERT(!pImpl->maPoolItemArrays[1].empty());
 
 const SfxPoolItem  = pPool->Put(aNotherTwo);
 CPPUNIT_ASSERT(bool(rVal2 == rVal));
@@ -84,12 +84,12 @@ void PoolItemTest::testPool()
 SfxVoidItem aNotherFour(4);
 const SfxPoolItem  = pPool->Put(aRemoveFour);
 pPool->Put(aNotherFour);
-CPPUNIT_ASSERT(pImpl->maPoolItems[3]->size() > 0);
-CPPUNIT_ASSERT_EQUAL(static_cast(2), 
pImpl->maPoolItems[3]->size());
+CPPUNIT_ASSERT(pImpl->maPoolItemArrays[3].size() > 0);
+CPPUNIT_ASSERT_EQUAL(static_cast(2), 
pImpl->maPoolItemArrays[3].size());
 pPool->Remove(rKeyFour);
-CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pImpl->maPoolItems[3]->size());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pImpl->maPoolItemArrays[3].size());
 pPool->Put(aNotherFour);
-CPPUNIT_ASSERT_EQUAL(static_cast(2), 
pImpl->maPoolItems[3]->size());
+CPPUNIT_ASSERT_EQUAL(static_cast(2), 
pImpl->maPoolItemArrays[3].size());
 }
 
 
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index eb78be10e71a..8eef10c5af96 100644
--- a/svl/source/inc/poolio.hxx
+++ b/svl/source/inc/poolio.hxx
@@ -43,21 +43,22 @@ struct SfxPoolItemArray_Impl
 private:
 o3tl::sorted_vector maPoolItemSet;
 public:
-o3tl::sorted_vector::const_iterator begin() { return 
maPoolItemSet.begin(); }
-o3tl::sorted_vector::const_iterator end() { return 
maPoolItemSet.end(); }
+o3tl::sorted_vector::const_iterator begin() const { return 
maPoolItemSet.begin(); }
+o3tl::sorted_vector::const_iterator end() const { return 
maPoolItemSet.end(); }
 /// clear array of PoolItem variants after all PoolItems are deleted
 /// or all ref counts are decreased
 void clear();
 size_t size() const {return maPoolItemSet.size();}
+bool empty() const {return maPoolItemSet.empty();}
 void insert(SfxPoolItem* pItem) { maPoolItemSet.insert(pItem); }
-o3tl::sorted_vector::const_iterator find(SfxPoolItem* pItem) 
{ return maPoolItemSet.find(pItem); }
+o3tl::sorted_vector::const_iterator find(SfxPoolItem* pItem) 
const { return maPoolItemSet.find(pItem); }
 void erase(o3tl::sorted_vector::const_iterator it) { return 
maPoolItemSet.erase(it); }
 };
 
 struct SfxItemPool_Impl
 {
 SfxBroadcaster  aBC;
-std::vector> maPoolItems;
+std::vector maPoolItemArrays;
 std::vector   maSfxItemPoolUsers; /// ObjectUser section
 OUStringaName;
 std::vector   maPoolDefaults;
@@ -70,7 +71,7 @@ struct SfxItemPool_Impl
 MapUnit 

[Libreoffice-commits] core.git: svl/qa svl/source

2018-10-08 Thread Libreoffice Gerrit user
 svl/qa/unit/svl.cxx  |8 
 svl/source/crypto/cryptosign.cxx |6 +++---
 svl/source/fsstor/fsstorage.cxx  |4 ++--
 svl/source/items/style.cxx   |2 +-
 svl/source/misc/gridprinter.cxx  |2 +-
 svl/source/undo/undo.cxx |6 +++---
 svl/source/uno/pathservice.cxx   |2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 5181253946ca1877cc42050452aa6d733d6da3f1
Author: Noel Grandin 
AuthorDate: Mon Oct 8 08:27:51 2018 +0200
Commit: Noel Grandin 
CommitDate: Mon Oct 8 10:25:31 2018 +0200

loplugin:constfields in svl

Change-Id: I18183c5c257cbe69bd067d4e74c50483ae683cf3
Reviewed-on: https://gerrit.libreoffice.org/61509
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 5c14f6539baa..76730bec7127 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -233,9 +233,9 @@ void Test::testNumberFormat()
 };
 
 struct {
-NfIndexTableOffset eStart;
-NfIndexTableOffset eEnd;
-size_t nSize;
+NfIndexTableOffset const eStart;
+NfIndexTableOffset const eEnd;
+size_t const nSize;
 const char** pCodes;
 } aTests[] = {
 { NF_NUMBER_START, NF_NUMBER_END, 6, pNumber },
@@ -1101,7 +1101,7 @@ void Test::testIsNumberFormat()
 struct NumberFormatData
 {
 const char* pFormat;
-bool bIsNumber;
+bool const bIsNumber;
 } aTests[] = {
 { "20.3", true },
 { "2", true },
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx
index 0e86664c28c1..57da138391ed 100644
--- a/svl/source/crypto/cryptosign.cxx
+++ b/svl/source/crypto/cryptosign.cxx
@@ -118,9 +118,9 @@ Extension  ::=  SEQUENCE  {
 */
 
 typedef struct {
-SECItem extnID;
-SECItem critical;
-SECItem extnValue;
+SECItem const extnID;
+SECItem const critical;
+SECItem const extnValue;
 } Extension;
 
 /*
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index c05c788b1bd8..360083cf386a 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -67,10 +67,10 @@ using namespace ::com::sun::star;
 
 struct FSStorage_Impl
 {
-OUString m_aURL;
+OUString const m_aURL;
 
 ::ucbhelper::Content m_aContent;
-sal_Int32 m_nMode;
+sal_Int32 const m_nMode;
 
 std::unique_ptr<::comphelper::OInterfaceContainerHelper2> 
m_pListenersContainer; // list of listeners
 std::unique_ptr<::cppu::OTypeCollection> m_pTypeCollection;
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 3517c68cd718..acfa74f8e910 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -388,7 +388,7 @@ struct DoesStyleMatchStyleSheetPredicate final : public 
svl::StyleSheetPredicate
 return bMatches;
 }
 
-SfxStyleSheetIterator *mIterator;
+SfxStyleSheetIterator * const mIterator;
 };
 
 }
diff --git a/svl/source/misc/gridprinter.cxx b/svl/source/misc/gridprinter.cxx
index fc89fdea4688..9ed7f43b41d5 100644
--- a/svl/source/misc/gridprinter.cxx
+++ b/svl/source/misc/gridprinter.cxx
@@ -51,7 +51,7 @@ typedef mdds::multi_type_matrix MatrixImplType;
 struct GridPrinter::Impl
 {
 MatrixImplType maMatrix;
-bool mbPrint;
+bool const mbPrint;
 
 Impl( size_t nRows, size_t nCols, bool bPrint ) :
 maMatrix(nRows, nCols, OUString()), mbPrint(bPrint) {}
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index cc7cb8157ff8..3b2085108126 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -1298,11 +1298,11 @@ void SfxUndoManager::EmptyActionsChanged()
 
 struct SfxListUndoAction::Impl
 {
-sal_uInt16 mnId;
-ViewShellId mnViewShellId;
+sal_uInt16 const mnId;
+ViewShellId const mnViewShellId;
 
 OUString maComment;
-OUString maRepeatComment;
+OUString const maRepeatComment;
 
 Impl( sal_uInt16 nId, ViewShellId nViewShellId, const OUString& rComment, 
const OUString& rRepeatComment ) :
 mnId(nId), mnViewShellId(nViewShellId), maComment(rComment), 
maRepeatComment(rRepeatComment) {}
diff --git a/svl/source/uno/pathservice.cxx b/svl/source/uno/pathservice.cxx
index 8e49057f1e9c..90aeeddfc3ed 100644
--- a/svl/source/uno/pathservice.cxx
+++ b/svl/source/uno/pathservice.cxx
@@ -33,7 +33,7 @@ namespace com { namespace sun { namespace star { namespace 
uno {
 
 class PathService : public ::cppu::WeakImplHelper< css::frame::XConfigManager, 
css::lang::XServiceInfo >
 {
-SvtPathOptions m_aOptions;
+SvtPathOptions const m_aOptions;
 
 public:
 PathService()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2016-10-24 Thread Takeshi Abe
 svl/qa/unit/svl.cxx|   21 +
 svl/source/numbers/zformat.cxx |3 +++
 2 files changed, 24 insertions(+)

New commits:
commit 1bd2f008130c717f8f2acd6edad64e00faa2e98d
Author: Takeshi Abe 
Date:   Fri Oct 21 11:46:47 2016 +0900

tdf#103060 Format "GGG" as the era name of a locale-dependent calendar

by default, as Excel does.

This change applies to "GG" and "G" as well. Note that nothing changes
for Italian locale, in which "GGG" stays as a placeholder for day of week.

Change-Id: Iad68f6a9548b7229930c0e0c518fdb29bfaa026f
Reviewed-on: https://gerrit.libreoffice.org/29724
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 9ae468f..48b5b44 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -60,6 +60,7 @@ public:
 void testSharedStringPoolPurge();
 void testFdo60915();
 void testI116701();
+void testTdf103060();
 void testDateInput();
 void testIsNumberFormat();
 void testUserDefinedNumberFormats();
@@ -71,6 +72,7 @@ public:
 CPPUNIT_TEST(testSharedStringPoolPurge);
 CPPUNIT_TEST(testFdo60915);
 CPPUNIT_TEST(testI116701);
+CPPUNIT_TEST(testTdf103060);
 CPPUNIT_TEST(testDateInput);
 CPPUNIT_TEST(testIsNumberFormat);
 CPPUNIT_TEST(testUserDefinedNumberFormats);
@@ -484,6 +486,25 @@ void Test::testI116701()
 checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
 }
 
+void Test::testTdf103060()
+{
+LanguageType eLang = LANGUAGE_JAPANESE;
+OUString sCode, sExpected;
+double fPreviewNumber = 42655; // equals 2016-10-12
+SvNumberFormatter aFormatter(m_xContext, eLang);
+sCode = "G";
+sExpected = "H"; // Heisei era
+checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+sCode = "GG";
+const sal_Unicode EXPECTED_G2[] = {0x5E73};
+sExpected = OUString(EXPECTED_G2, SAL_N_ELEMENTS(EXPECTED_G2));
+checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+sCode = "GGG";
+const sal_Unicode EXPECTED_G3[] = {0x5E73, 0x6210};
+sExpected = OUString(EXPECTED_G3, SAL_N_ELEMENTS(EXPECTED_G3));
+checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+}
+
 void Test::testDateInput()
 {
 const char* aData[][2] = {
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index a37987e..8178b7e 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -3264,6 +3264,9 @@ bool SvNumberformat::ImpIsOtherCalendar( const 
ImpSvNumFor& rNumFor ) const
 case NF_KEY_RR :
 case NF_KEY_AAA :
 case NF_KEY_ :
+case NF_KEY_G :
+case NF_KEY_GG :
+case NF_KEY_GGG :
 return true;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2016-09-01 Thread Jochen Nitschke
 svl/qa/unit/items/test_itempool.cxx |   53 +---
 svl/source/items/itempool.cxx   |2 -
 2 files changed, 27 insertions(+), 28 deletions(-)

New commits:
commit d22525fcb03497a38ef5c9308ae7b50416ea9fb2
Author: Jochen Nitschke 
Date:   Thu Sep 1 01:27:42 2016 +0200

avoid warning in PoolItemTest

> warn:legacy.tools:19758:1:svl/source/inc/poolio.hxx:139:
> Start-Which-Id must be greater 0

adapt ID range in the test
and leave usage comment in SfxItemPool ctor params

Change-Id: I93150be8d3d1e330c6574b9f8d05b3b1ef2ffa43
Reviewed-on: https://gerrit.libreoffice.org/28570
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/svl/qa/unit/items/test_itempool.cxx 
b/svl/qa/unit/items/test_itempool.cxx
index cc43694..bf52772 100644
--- a/svl/qa/unit/items/test_itempool.cxx
+++ b/svl/qa/unit/items/test_itempool.cxx
@@ -35,69 +35,68 @@ class PoolItemTest : public CppUnit::TestFixture
 void PoolItemTest::testPool()
 {
 SfxItemInfo aItems[] =
-{ { 0, true },
-  { 1, false /* not poolable */ },
-  { 2, false },
-  { 3, false /* not poolable */}
+{ { 1, true },
+  { 2, false /* not poolable */ },
+  { 3, false },
+  { 4, false /* not poolable */}
 };
 
-SfxItemPool *pPool = new SfxItemPool("testpool", 0, 3, aItems);
+SfxItemPool *pPool = new SfxItemPool("testpool", 1, 4, aItems);
 SfxItemPool_Impl *pImpl = SfxItemPool_Impl::GetImpl(pPool);
 CPPUNIT_ASSERT(pImpl != nullptr);
 CPPUNIT_ASSERT(pImpl->maPoolItems.size() == 4);
 
 // Poolable
-SfxVoidItem aItemZero( 0 );
-SfxVoidItem aNotherZero( 0 );
+SfxVoidItem aItemOne( 1 );
+SfxVoidItem aNotherOne( 1 );
 
 {
 CPPUNIT_ASSERT(pImpl->maPoolItems[0] == nullptr);
-const SfxPoolItem  = pPool->Put(aItemZero);
-CPPUNIT_ASSERT(rVal == aItemZero);
+const SfxPoolItem  = pPool->Put(aItemOne);
+CPPUNIT_ASSERT(rVal == aItemOne);
 CPPUNIT_ASSERT(pImpl->maPoolItems[0] != nullptr);
-const SfxPoolItem  = pPool->Put(aNotherZero);
+const SfxPoolItem  = pPool->Put(aNotherOne);
 CPPUNIT_ASSERT(rVal2 == rVal);
 CPPUNIT_ASSERT( == );
 
 // Clones on Put ...
-CPPUNIT_ASSERT( != );
-CPPUNIT_ASSERT( != );
-CPPUNIT_ASSERT( != );
-CPPUNIT_ASSERT( != );
+CPPUNIT_ASSERT( != );
+CPPUNIT_ASSERT( != );
+CPPUNIT_ASSERT( != );
+CPPUNIT_ASSERT( != );
 }
 
 // non-poolable
-SfxVoidItem aItemOne( 1 );
-SfxVoidItem aNotherOne( 1 );
+SfxVoidItem aItemTwo( 2 );
+SfxVoidItem aNotherTwo( 2 );
 {
 CPPUNIT_ASSERT(pImpl->maPoolItems[1] == nullptr);
-const SfxPoolItem  = pPool->Put(aItemOne);
-CPPUNIT_ASSERT(rVal == aItemOne);
+const SfxPoolItem  = pPool->Put(aItemTwo);
+CPPUNIT_ASSERT(rVal == aItemTwo);
 CPPUNIT_ASSERT(pImpl->maPoolItems[1] != nullptr);
 
-const SfxPoolItem  = pPool->Put(aNotherOne);
+const SfxPoolItem  = pPool->Put(aNotherTwo);
 CPPUNIT_ASSERT(rVal2 == rVal);
 CPPUNIT_ASSERT( != );
 }
 
 // Test rehash
-for (size_t i = 0; i < pImpl->maPoolItems.size(); ++i)
+for (SfxPoolItemArray_Impl *pSlice : pImpl->maPoolItems)
 {
-SfxPoolItemArray_Impl *pSlice = pImpl->maPoolItems[i];
 if (pSlice)
 pSlice->ReHash();
 }
 
 // Test removal.
-SfxVoidItem aRemoveThree(3);
-SfxVoidItem aNotherThree(3);
-const SfxPoolItem  = pPool->Put(aRemoveThree);
-pPool->Put(aNotherThree);
+SfxVoidItem aRemoveFour(4);
+SfxVoidItem aNotherFour(4);
+const SfxPoolItem  = pPool->Put(aRemoveFour);
+pPool->Put(aNotherFour);
 CPPUNIT_ASSERT(pImpl->maPoolItems[3]->size() > 0);
 CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 0);
-pPool->Remove(rKeyThree);
+pPool->Remove(rKeyFour);
 CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 1);
-pPool->Put(aNotherThree);
+pPool->Put(aNotherFour);
 CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 0);
 }
 
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 2b3d9ff..fc250c3 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -164,7 +164,7 @@ SfxBroadcaster& SfxItemPool::BC()
 SfxItemPool::SfxItemPool
 (
 const OUString& rName,  /* Pool name to identify in the file 
format */
-sal_uInt16  nStartWhich,/* First WhichId of the Pool */
+sal_uInt16  nStartWhich,/* First WhichId of the Pool (must be 
> 0) */
 sal_uInt16  nEndWhich,  /* Last WhichId of the Pool */
 const SfxItemInfo*  pInfo, /* SID Map and Item flags */
 SfxPoolItem**   pDefaults,  /* Pointer to static Defaults;

[Libreoffice-commits] core.git: svl/qa svl/source

2016-08-02 Thread Eike Rathke
 svl/qa/unit/svl.cxx |4 ++--
 svl/source/numbers/zforscan.cxx |   12 ++--
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 88134dcba680418496f7a1c70a47fde0159ce390
Author: Eike Rathke 
Date:   Tue Aug 2 23:46:22 2016 +0200

break the Excel rule for YMD and DMY, tdf#101147 follow-up

Clearly in {HH -MM-DD} the MM should not be minute. Also not in
{HH DD.MM.YY}. Don't follow every bullshit. Period.

It is debatable how to treat MDY, {HH:MM DD/YY} should be different from
{HH MM/DD/YY}, Excel ironically takes both as minute, even in an en-US 
locale.

Change-Id: I13d39a36294e3c40cc0e9bf72026804b299bb264

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 6af6566..f4c033d 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1132,8 +1132,8 @@ void Test::testUserDefinedNumberFormats()
 checkPreviewString(aFormatter, sCode, -12.0, eLang, sExpected);
 }
 {  // tdf#995339: detect SSMM as second minute
-sCode = "SS:MM:HH DD/MM/YY"; // Month not detected by Excel, so we do 
not neither to keep compatibility
-sExpected = "54:23:03 02/23/00";
+sCode = "SS:MM:HH DD/MM/YY"; // Month not detected by Excel, but we do 
not follow that.
+sExpected = "54:23:03 02/01/00";
 checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected);
 }
 {  // tdf#6: better algorithm for fraction representation
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 8de7ac7..a59617d 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1156,9 +1156,12 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
Minute if one of:
* preceded by time keyword H (ignoring separators)
* followed by time keyword S (ignoring separators)
-   * H or S was detected
+   * H or S was detected and this is the first M following
* preceded by '[' amount bracket
Else month.
+   That are the Excel rules. BUT, we break it because certainly
+   in something like {HH -MM-DD} the MM is NOT meant to be
+   minute, so not if MM is between YY and DD or DD and YY.
 */
 nIndexPre = PreviousKeyword(i);
 nIndexNex = NextKeyword(i);
@@ -1166,7 +1169,12 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
 nIndexPre == NF_KEY_HH  ||  // HH
 nIndexNex == NF_KEY_S   ||  // S
 nIndexNex == NF_KEY_SS  ||  // SS
-bIsTimeDetected ||  // tdf#101147
+(bIsTimeDetected &&
+ !(((nIndexPre == NF_KEY_YY || nIndexPre == NF_KEY_) &&
+(nIndexNex == NF_KEY_D  || nIndexNex == NF_KEY_DD)) ||
+   ((nIndexPre == NF_KEY_D  || nIndexPre == NF_KEY_DD) &&
+(nIndexNex == NF_KEY_YY || nIndexNex == NF_KEY_)))
+)   ||  // tdf#101147
 PreviousChar(i) == '['  )   // [M
 {
 eNewType = css::util::NumberFormat::TIME;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2016-08-01 Thread Laurent Balland-Poirier
 svl/qa/unit/svl.cxx |4 ++--
 svl/source/numbers/zforscan.cxx |   19 ++-
 2 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit aa6bca0dfa0a58aae91eb5fa3564add642cd4238
Author: Laurent Balland-Poirier 
Date:   Wed Jul 27 09:02:46 2016 +0200

tdf#101147 Improve (again) minute/month detection

For format like HH:MM:SS MM/DD
second MM is detected as minute: see tdf#95339

New rules:
- first M following each H is minute
- first M following first S is minute

Detection Month/minute now fully compatible with Excel even with unwanted 
detection:
SS:MM:HH DD/MM/YY
second MM is minute even if user would expect month

Change-Id: Ia789fbc2dbd6d2dcbe9b9c34d3f288674966dd10
Reviewed-on: https://gerrit.libreoffice.org/27560
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 4522516..6af6566 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1132,8 +1132,8 @@ void Test::testUserDefinedNumberFormats()
 checkPreviewString(aFormatter, sCode, -12.0, eLang, sExpected);
 }
 {  // tdf#995339: detect SSMM as second minute
-sCode = "SS:MM:HH DD/MM/YY";
-sExpected = "54:23:03 02/01/00";
+sCode = "SS:MM:HH DD/MM/YY"; // Month not detected by Excel, so we do 
not neither to keep compatibility
+sExpected = "54:23:03 02/23/00";
 checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected);
 }
 {  // tdf#6: better algorithm for fraction representation
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 33eda8f..8de7ac7 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1121,6 +1121,8 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
 short eNewType;
 bool bMatchBracket = false;
 bool bHaveGeneral = false; // if General/Standard encountered
+bool bIsTimeDetected =false;   // hour or second found in format
+bool bHaveMinute = false;
 
 SkipStrings(i, nPos);
 while (i < nAnzStrings)
@@ -1135,20 +1137,26 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
 case NF_KEY_E:  // E
 eNewType = css::util::NumberFormat::SCIENTIFIC;
 break;
-case NF_KEY_AMPM:   // AM,A,PM,P
-case NF_KEY_AP:
 case NF_KEY_H:  // H
 case NF_KEY_HH: // HH
+bIsTimeDetected = true;
+SAL_FALLTHROUGH;
 case NF_KEY_S:  // S
 case NF_KEY_SS: // SS
+if ( !bHaveMinute )
+bIsTimeDetected = true;
+SAL_FALLTHROUGH;
+case NF_KEY_AMPM:   // AM,A,PM,P
+case NF_KEY_AP:
 eNewType = css::util::NumberFormat::TIME;
 break;
 case NF_KEY_M:  // M
 case NF_KEY_MM: // MM
 /* Minute or month.
Minute if one of:
-   * preceded by time keyword H or S (ignoring separators)
+   * preceded by time keyword H (ignoring separators)
* followed by time keyword S (ignoring separators)
+   * H or S was detected
* preceded by '[' amount bracket
Else month.
 */
@@ -1156,14 +1164,15 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
 nIndexNex = NextKeyword(i);
 if (nIndexPre == NF_KEY_H   ||  // H
 nIndexPre == NF_KEY_HH  ||  // HH
-nIndexPre == NF_KEY_S   ||  // S before M tdf#95339
-nIndexPre == NF_KEY_SS  ||  // SS
 nIndexNex == NF_KEY_S   ||  // S
 nIndexNex == NF_KEY_SS  ||  // SS
+bIsTimeDetected ||  // tdf#101147
 PreviousChar(i) == '['  )   // [M
 {
 eNewType = css::util::NumberFormat::TIME;
 nTypeArray[i] -= 2; // 6 -> 4, 7 -> 5
+bIsTimeDetected = false;// next M should be month
+bHaveMinute = true;
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2015-06-29 Thread Tobias Lippert
 svl/qa/unit/notify/test_SfxBroadcaster.cxx |   25 +
 svl/source/notify/lstner.cxx   |5 -
 2 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit b014150e64cdc23dfd999061bc210f0ad701f0a2
Author: Tobias Lippert d...@fastmail.fm
Date:   Tue Jun 9 21:25:40 2015 +0200

tdf#68016 Write fixture for current behaviour of SfxListener

Also: Make destructor of SfxListener more robust, so that it can be used
in tests.

Change-Id: I02b273ca8e527705c2d3ea3295ed0dec1c4f83ae
Reviewed-on: https://gerrit.libreoffice.org/16483
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/svl/qa/unit/notify/test_SfxBroadcaster.cxx 
b/svl/qa/unit/notify/test_SfxBroadcaster.cxx
index 6096029..292cd9d 100644
--- a/svl/qa/unit/notify/test_SfxBroadcaster.cxx
+++ b/svl/qa/unit/notify/test_SfxBroadcaster.cxx
@@ -22,12 +22,16 @@ class SfxBroadcasterTest : public CppUnit::TestFixture
 void AddingListenersIncreasesCount();
 void RemovingListenersDecreasesCount();
 void HintsAreNotForwardedToRemovedListeners();
+void SameListenerCanBeAddedMoreThanOnce();
+void StoppingListeningAffectsOnlyFirstOfIdenticalListeners();
 
 // Adds code needed to register the test suite
 CPPUNIT_TEST_SUITE(SfxBroadcasterTest);
 CPPUNIT_TEST(AddingListenersIncreasesCount);
 CPPUNIT_TEST(RemovingListenersDecreasesCount);
 CPPUNIT_TEST(HintsAreNotForwardedToRemovedListeners);
+CPPUNIT_TEST(SameListenerCanBeAddedMoreThanOnce);
+CPPUNIT_TEST(StoppingListeningAffectsOnlyFirstOfIdenticalListeners);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -93,6 +97,27 @@ SfxBroadcasterTest::HintsAreNotForwardedToRemovedListeners()
 CPPUNIT_ASSERT_EQUAL(false, sl1.NotifyWasCalled());
 }
 
+void
+SfxBroadcasterTest::SameListenerCanBeAddedMoreThanOnce()
+{
+MockedSfxListener sl;
+SfxBroadcaster sb;
+sb.AddListener(sl);
+sb.AddListener(sl);
+CPPUNIT_ASSERT_EQUAL((size_t)2, sb.GetListenerCount());
+}
+
+void
+SfxBroadcasterTest::StoppingListeningAffectsOnlyFirstOfIdenticalListeners()
+{
+MockedSfxListener sl;
+SfxBroadcaster sb;
+sb.AddListener(sl);
+sb.AddListener(sl);
+sb.RemoveListener(sl);
+CPPUNIT_ASSERT_EQUAL((size_t)1, sb.GetListenerCount());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SfxBroadcasterTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index ee0809c..4fc3426 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -68,7 +68,10 @@ SfxListener::~SfxListener()
 
 void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster rBroadcaster )
 {
-mpImpl-maBCs.erase( std::find( mpImpl-maBCs.begin(), 
mpImpl-maBCs.end(), rBroadcaster ) );
+auto it = std::find( mpImpl-maBCs.begin(), mpImpl-maBCs.end(), 
rBroadcaster );
+if (it != mpImpl-maBCs.end()) {
+mpImpl-maBCs.erase( it );
+}
 }
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svl/qa svl/source

2014-02-25 Thread Alexander Wilms
 svl/qa/complex/ConfigItems/CheckConfigItems.java |   28 ++--
 svl/source/inc/poolio.hxx|2 
 svl/source/items/cenumitm.cxx|   12 ++---
 svl/source/items/cintitem.cxx|   16 +++
 svl/source/items/ctypeitm.cxx|4 -
 svl/source/items/custritm.cxx|4 -
 svl/source/items/intitem.cxx |   24 +--
 svl/source/items/stritem.cxx |4 -
 svl/source/items/style.cxx   |2 
 svl/source/items/visitem.cxx |4 -
 svl/source/misc/adrparse.cxx |8 +--
 svl/source/misc/inettype.cxx |8 +--
 svl/source/misc/mediatyp.src |8 +--
 svl/source/misc/strmadpt.cxx |   20 -
 svl/source/misc/urihelper.cxx|   50 +++
 svl/source/numbers/zforlist.cxx  |4 -
 svl/source/svdde/ddeimp.hxx  |   16 +++
 17 files changed, 107 insertions(+), 107 deletions(-)

New commits:
commit 31ea60c882cd9e0ce042f2d2945c711bffc93f18
Author: Alexander Wilms f.alexander.wi...@gmail.com
Date:   Tue Feb 25 20:44:28 2014 +0100

Remove visual noise from svl

Change-Id: Ib914ec8d161e24f4e3e1fb8e7684a780d3ae6209
Reviewed-on: https://gerrit.libreoffice.org/8319
Reviewed-by: Björn Michaelsen bjoern.michael...@canonical.com
Tested-by: Björn Michaelsen bjoern.michael...@canonical.com

diff --git a/svl/qa/complex/ConfigItems/CheckConfigItems.java 
b/svl/qa/complex/ConfigItems/CheckConfigItems.java
index 292ec46..73ca7b7 100644
--- a/svl/qa/complex/ConfigItems/CheckConfigItems.java
+++ b/svl/qa/complex/ConfigItems/CheckConfigItems.java
@@ -32,16 +32,16 @@ import org.junit.Test;
 import org.openoffice.test.OfficeConnection;
 // import static org.junit.Assert.*;
 
-//---
+
 /** @short  todo document me
  * @deprecated this tests seems no longer work as expected.
  */
 public class CheckConfigItems
 {
-//---
+
 // some const
 
-//---
+
 // member
 
 /** points to the global uno service manager. */
@@ -50,10 +50,10 @@ public class CheckConfigItems
 /** implements real config item tests in C++. */
 private XJob m_xTest = null;
 
-//---
+
 // test environment
 
-//---
+
 /** @short  A function to tell the framework,
 which test functions are available.
 
@@ -73,7 +73,7 @@ public class CheckConfigItems
 //};
 //}
 
-//---
+
 /** @short  Create the environment for following tests.
 
  * @throws java.lang.Exception
@@ -92,7 +92,7 @@ public class CheckConfigItems
 m_xTest = UnoRuntime.queryInterface(XJob.class, 
m_xSmgr.createInstance(com.sun.star.comp.svl.ConfigItemTest));
 }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @short  close the environment.
@@ -106,7 +106,7 @@ public class CheckConfigItems
 m_xSmgr = null;
 }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @todo document me
@@ -117,7 +117,7 @@ public class CheckConfigItems
 impl_triggerTest(checkPicklist);
 }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @todo document me
@@ -128,7 +128,7 @@ public class CheckConfigItems
 impl_triggerTest(checkURLHistory);
 }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @todo document me
@@ -139,7 +139,7 @@ public class CheckConfigItems
 impl_triggerTest(checkHelpBookmarks);
 }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @todo document me
@@ -150,7 +150,7 @@ public class CheckConfigItems
 // impl_triggerTest(checkPrintOptions);
 // }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @todo document me
@@ -161,7 +161,7 @@ public class CheckConfigItems
 impl_triggerTest(checkAccessibilityOptions);
 }
 
-//---
+
 /**
  * @throws java.lang.Exception
  * @todo document me
@@ -172,7 +172,7 @@ public class CheckConfigItems
 impl_triggerTest(checkUserOptions);
 }
 
-//---
+
 /** @todo document me
  */
 private void impl_triggerTest(String sTest)
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index de90d0b..9fa2dac 100644
--- a/svl/source/inc/poolio.hxx
+++