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

Eike Rathke erack at redhat.com
Wed May 2 20:17:33 UTC 2018


 include/svl/zforlist.hxx        |    4 
 svl/source/numbers/zforfind.cxx |  164 ++++++++++++++++++++++++----------------
 svl/source/numbers/zforfind.hxx |   19 +---
 3 files changed, 111 insertions(+), 76 deletions(-)

New commits:
commit dfb9138b8b5a239b46f189a717999bcaff19aa79
Author: Eike Rathke <erack at redhat.com>
Date:   Wed May 2 22:10:05 2018 +0200

    Resolves: tdf#116579 consider both work locale and format locale date patterns
    
    If a format was set its locale's date acceptance patterns
    overwrote the work locale's patterns for the current input. Take
    both into account, with precedence depending on the
    NfEvalDateFormat set at SvNumberFormatter.
    
    Change-Id: Ie6e837447610d71eb9b8227e602d13d414cad612

diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index 536d6bdf1645..14aaf6a40940 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -882,6 +882,10 @@ public:
     /** Access for unit tests. */
     size_t GetMaxDefaultColors() const;
 
+    struct InputScannerPrivateAccess { friend class ImpSvNumberInputScan; private: InputScannerPrivateAccess() {} };
+    /** Access for input scanner to temporarily (!) switch locales. */
+    OnDemandLocaleDataWrapper& GetOnDemandLocaleDataWrapper( const InputScannerPrivateAccess& ) { return xLocaleData; }
+
 private:
     mutable ::osl::Mutex m_aMutex;
     css::uno::Reference< css::uno::XComponentContext > m_xContext;
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 85b27797d204..e55786ea9d17 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
 #include <com/sun/star/i18n/LocaleCalendar2.hpp>
 #include <unotools/digitgroupingiterator.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <svl/zforlist.hxx>
 #include "zforscan.hxx"
@@ -98,6 +99,7 @@ ImpSvNumberInputScan::~ImpSvNumberInputScan()
 
 void ImpSvNumberInputScan::Reset()
 {
+    mpFormat     = nullptr;
     nMonth       = 0;
     nMonthPos    = 0;
     nDayOfWeek   = 0;
@@ -702,14 +704,13 @@ int ImpSvNumberInputScan::GetDayOfWeek( const OUString& rString, sal_Int32& nPos
  * '$'   => true
  * else => false
  */
-bool ImpSvNumberInputScan::GetCurrency( const OUString& rString, sal_Int32& nPos,
-                                        const SvNumberformat* pFormat )
+bool ImpSvNumberInputScan::GetCurrency( const OUString& rString, sal_Int32& nPos )
 {
     if ( rString.getLength() > nPos )
     {
         if ( !aUpperCurrSymbol.getLength() )
         {   // if no format specified the currency of the initialized formatter
-            LanguageType eLang = (pFormat ? pFormat->GetLanguage() : pFormatter->GetLanguage());
+            LanguageType eLang = (mpFormat ? mpFormat->GetLanguage() : pFormatter->GetLanguage());
             aUpperCurrSymbol = pFormatter->GetCharClass()->uppercase(
                 SvNumberFormatter::GetCurrencyEntry( eLang ).GetSymbol() );
         }
@@ -718,10 +719,10 @@ bool ImpSvNumberInputScan::GetCurrency( const OUString& rString, sal_Int32& nPos
             nPos = nPos + aUpperCurrSymbol.getLength();
             return true;
         }
-        if ( pFormat )
+        if ( mpFormat )
         {
             OUString aSymbol, aExtension;
-            if ( pFormat->GetNewCurrencySymbol( aSymbol, aExtension ) )
+            if ( mpFormat->GetNewCurrencySymbol( aSymbol, aExtension ) )
             {
                 if ( aSymbol.getLength() <= rString.getLength() - nPos )
                 {
@@ -1100,18 +1101,18 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
 }
 
 
-bool ImpSvNumberInputScan::IsAcceptableIso8601( const SvNumberformat* pFormat )
+bool ImpSvNumberInputScan::IsAcceptableIso8601()
 {
-    if (pFormat && (pFormat->GetType() & SvNumFormatType::DATE))
+    if (mpFormat && (mpFormat->GetType() & SvNumFormatType::DATE))
     {
         switch (pFormatter->GetEvalDateFormat())
         {
             case NF_EVALDATEFORMAT_INTL:
                 return CanForceToIso8601( GetDateOrder());
             case NF_EVALDATEFORMAT_FORMAT:
-                return CanForceToIso8601( pFormat->GetDateOrder());
+                return CanForceToIso8601( mpFormat->GetDateOrder());
             default:
-                return CanForceToIso8601( GetDateOrder()) || CanForceToIso8601( pFormat->GetDateOrder());
+                return CanForceToIso8601( GetDateOrder()) || CanForceToIso8601( mpFormat->GetDateOrder());
         }
     }
     return CanForceToIso8601( GetDateOrder());
@@ -1191,7 +1192,46 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt )
     }
     else if (!sDateAcceptancePatterns.getLength())
     {
-        sDateAcceptancePatterns = pFormatter->GetLocaleData()->getDateAcceptancePatterns();
+        // The current locale is the format's locale, if a format is present.
+        const NfEvalDateFormat eEDF = pFormatter->GetEvalDateFormat();
+        if (!mpFormat || eEDF == NF_EVALDATEFORMAT_FORMAT || mpFormat->GetLanguage() == pFormatter->GetLanguage())
+        {
+            sDateAcceptancePatterns = pFormatter->GetLocaleData()->getDateAcceptancePatterns();
+        }
+        else
+        {
+            OnDemandLocaleDataWrapper& xLocaleData = pFormatter->GetOnDemandLocaleDataWrapper(
+                    SvNumberFormatter::InputScannerPrivateAccess());
+            const LanguageTag aSaveLocale( xLocaleData->getLanguageTag() );
+            assert(mpFormat->GetLanguage() == aSaveLocale.getLanguageType());   // prerequisite
+            // Obtain formatter's locale's (e.g. system) patterns.
+            xLocaleData.changeLocale( LanguageTag( pFormatter->GetLanguage()));
+            const css::uno::Sequence<OUString> aLocalePatterns( xLocaleData->getDateAcceptancePatterns());
+            // Reset to format's locale.
+            xLocaleData.changeLocale( aSaveLocale);
+            // When concatenating don't care about duplicates, combining
+            // weeding those out reallocs yet another time and probably doesn't
+            // take less time than looping over two additional patterns below..
+            switch (eEDF)
+            {
+                case NF_EVALDATEFORMAT_FORMAT:
+                    assert(!"shouldn't reach here");
+                break;
+                case NF_EVALDATEFORMAT_INTL:
+                    sDateAcceptancePatterns = aLocalePatterns;
+                break;
+                case NF_EVALDATEFORMAT_INTL_FORMAT:
+                    sDateAcceptancePatterns = comphelper::concatSequences(
+                            aLocalePatterns,
+                            xLocaleData->getDateAcceptancePatterns());
+                break;
+                case NF_EVALDATEFORMAT_FORMAT_INTL:
+                    sDateAcceptancePatterns = comphelper::concatSequences(
+                            xLocaleData->getDateAcceptancePatterns(),
+                            aLocalePatterns);
+                break;
+            }
+        }
         SAL_WARN_IF( !sDateAcceptancePatterns.getLength(), "svl.numbers", "ImpSvNumberInputScan::IsAcceptedDatePattern: no date acceptance patterns");
         nAcceptedDatePattern = (sDateAcceptancePatterns.getLength() ? -2 : -1);
     }
@@ -1546,13 +1586,12 @@ DateOrder ImpSvNumberInputScan::GetDateOrder()
     return pFormatter->GetLocaleData()->getDateOrder();
 }
 
-bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
-                                       const SvNumberformat* pFormat )
+bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter )
 {
     using namespace ::com::sun::star::i18n;
     NfEvalDateFormat eEDF;
     int nFormatOrder;
-    if ( pFormat && (pFormat->GetType() & SvNumFormatType::DATE) )
+    if ( mpFormat && (mpFormat->GetType() & SvNumFormatType::DATE) )
     {
         eEDF = pFormatter->GetEvalDateFormat();
         switch ( eEDF )
@@ -1593,7 +1632,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
             break;
         case NF_EVALDATEFORMAT_FORMAT :
             bFormatTurn = true;
-            DateFmt = pFormat->GetDateOrder();
+            DateFmt = mpFormat->GetDateOrder();
             break;
         case NF_EVALDATEFORMAT_INTL_FORMAT :
             if ( nTryOrder == 1 )
@@ -1604,7 +1643,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
             else
             {
                 bFormatTurn = true;
-                DateFmt = pFormat->GetDateOrder();
+                DateFmt = mpFormat->GetDateOrder();
             }
             break;
         case NF_EVALDATEFORMAT_FORMAT_INTL :
@@ -1616,7 +1655,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
             else
             {
                 bFormatTurn = true;
-                DateFmt = pFormat->GetDateOrder();
+                DateFmt = mpFormat->GetDateOrder();
             }
             break;
         default:
@@ -1653,13 +1692,13 @@ input for the following reasons:
 
 */
 #ifdef THE_FUTURE
-            if ( pFormat->IsOtherCalendar( nStringScanNumFor ) )
+            if ( mpFormat->IsOtherCalendar( nStringScanNumFor ) )
             {
-                pFormat->SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+                mpFormat->SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
             }
             else
             {
-                pFormat->SwitchToSpecifiedCalendar( aOrgCalendar, fOrgDateTime,
+                mpFormat->SwitchToSpecifiedCalendar( aOrgCalendar, fOrgDateTime,
                                                     nStringScanNumFor );
             }
 #endif
@@ -1695,7 +1734,7 @@ input for the following reasons:
                 // 'D-', 'M-' or 'Y-'. If input did not match a
                 // pattern assume the usual day of current month.
                 sal_uInt32 nDateOrder = (bFormatTurn ?
-                                         pFormat->GetExactDateOrder() :
+                                         mpFormat->GetExactDateOrder() :
                                          GetDatePatternOrder());
                 switch (nDateOrder)
                 {
@@ -1767,7 +1806,7 @@ input for the following reasons:
             case 0:             // not found
             {
                 sal_uInt32 nExactDateOrder = (bFormatTurn ?
-                                              pFormat->GetExactDateOrder() :
+                                              mpFormat->GetExactDateOrder() :
                                               GetDatePatternOrder());
                 bool bIsExact = (0xff < nExactDateOrder && nExactDateOrder <= 0xffff);
                 if (!bIsExact && bFormatTurn && IsAcceptedDatePattern( nNums[0]))
@@ -1876,7 +1915,7 @@ input for the following reasons:
                 // constellation, there is no date order (M)YD except if
                 // set in a format applied.
                 pCal->setValue( CalendarFieldIndex::MONTH, std::abs(nMonth)-1 );
-                sal_uInt32 nExactDateOrder = (bFormatTurn ? pFormat->GetExactDateOrder() : 0);
+                sal_uInt32 nExactDateOrder = (bFormatTurn ? mpFormat->GetExactDateOrder() : 0);
                 if ((((nExactDateOrder >> 8) & 0xff) == 'Y') && ((nExactDateOrder & 0xff) == 'D'))
                 {
                     pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
@@ -2108,8 +2147,7 @@ input for the following reasons:
  * All gone => true
  * else     => false
  */
-bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
-                                            const SvNumberformat* pFormat )
+bool ImpSvNumberInputScan::ScanStartString( const OUString& rString )
 {
     sal_Int32 nPos = 0;
 
@@ -2128,7 +2166,7 @@ bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
         // Match against format in any case, so later on for a "x1-2-3" input
         // we may distinguish between a xy-m-d (or similar) date and a x0-0-0
         // format. No sign detection here!
-        if ( ScanStringNumFor( rString, nPos, pFormat, 0, true ) )
+        if ( ScanStringNumFor( rString, nPos, 0, true ) )
         {
             nMatchedAllStrings |= nMatchedStartString;
         }
@@ -2147,7 +2185,7 @@ bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
         nDecPos = 1;
         SkipBlanks(rString, nPos);
     }
-    else if ( GetCurrency(rString, nPos, pFormat) ) // currency (DM 1)?
+    else if ( GetCurrency(rString, nPos) )          // currency (DM 1)?
     {
         eScannedType = SvNumFormatType::CURRENCY;       // !!! it IS currency !!!
         SkipBlanks(rString, nPos);
@@ -2280,7 +2318,7 @@ bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
     {
         // Does input StartString equal StartString of format?
         // This time with sign detection!
-        if ( !ScanStringNumFor( rString, nPos, pFormat, 0 ) )
+        if ( !ScanStringNumFor( rString, nPos, 0 ) )
         {
             return MatchedReturn();
         }
@@ -2295,8 +2333,7 @@ bool ImpSvNumberInputScan::ScanStartString( const OUString& rString,
  * All gone => true
  * else     => false
  */
-bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
-                                          sal_uInt16 nStringPos, const SvNumberformat* pFormat )
+bool ImpSvNumberInputScan::ScanMidString( const OUString& rString, sal_uInt16 nStringPos )
 {
     sal_Int32 nPos = 0;
     SvNumFormatType eOldScannedType = eScannedType;
@@ -2305,7 +2342,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
     {   // Match against format in any case, so later on for a "1-2-3-4" input
         // we may distinguish between a y-m-d (or similar) date and a 0-0-0-0
         // format.
-        if ( ScanStringNumFor( rString, 0, pFormat, nStringPos ) )
+        if ( ScanStringNumFor( rString, 0, nStringPos ) )
         {
             nMatchedAllStrings |= nMatchedMidString;
         }
@@ -2653,8 +2690,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
  * All gone => true
  * else     => false
  */
-bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
-                                          const SvNumberformat* pFormat )
+bool ImpSvNumberInputScan::ScanEndString( const OUString& rString )
 {
     sal_Int32 nPos = 0;
 
@@ -2662,7 +2698,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
     {   // Match against format in any case, so later on for a "1-2-3-4" input
         // we may distinguish between a y-m-d (or similar) date and a 0-0-0-0
         // format.
-        if ( ScanStringNumFor( rString, 0, pFormat, 0xFFFF ) )
+        if ( ScanStringNumFor( rString, 0, 0xFFFF ) )
         {
             nMatchedAllStrings |= nMatchedEndString;
         }
@@ -2732,7 +2768,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
         SkipBlanks(rString, nPos);
     }
 
-    if ( GetCurrency(rString, nPos, pFormat) )      // currency symbol?
+    if ( GetCurrency(rString, nPos) )               // currency symbol?
     {
         if (eScannedType != SvNumFormatType::UNDEFINED) // currency dup
         {
@@ -2956,7 +2992,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
     if (nPos < rString.getLength()) // everything consumed?
     {
         // does input EndString equal EndString in Format?
-        if ( !ScanStringNumFor( rString, nPos, pFormat, 0xFFFF ) )
+        if ( !ScanStringNumFor( rString, nPos, 0xFFFF ) )
         {
             return false;
         }
@@ -2968,11 +3004,10 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString,
 
 bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString,       // String to scan
                                              sal_Int32 nPos,                // Position until which was consumed
-                                             const SvNumberformat* pFormat, // The format to match
                                              sal_uInt16 nString,            // Substring of format, 0xFFFF => last
                                              bool bDontDetectNegation)      // Suppress sign detection
 {
-    if ( !pFormat )
+    if ( !mpFormat )
     {
         return false;
     }
@@ -2991,7 +3026,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString,       // S
         do
         {   // Step through subformats, first positive, then negative, then
             // other, but not the last (text) subformat.
-            pStr = pFormat->GetNumForString( nSub, nString, true );
+            pStr = mpFormat->GetNumForString( nSub, nString, true );
             if ( pStr && pTransliteration->isEqual( aString, *pStr ) )
             {
                 bFound = true;
@@ -3020,7 +3055,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString,       // S
     if ( !bFound )
     {
         if ( !bDontDetectNegation && (nString == 0) &&
-             !bFirst && (nSign < 0) && pFormat->IsSecondSubformatRealNegative() )
+             !bFirst && (nSign < 0) && mpFormat->IsSecondSubformatRealNegative() )
         {
             // simply negated twice? --1
             aString = aString.replaceAll(" ", "");
@@ -3037,7 +3072,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString,       // S
         }
     }
     else if ( !bDontDetectNegation && (nSub == 1) &&
-              pFormat->IsSecondSubformatRealNegative() )
+              mpFormat->IsSecondSubformatRealNegative() )
     {
         // negative
         if ( nStringScanSign < 0 )
@@ -3057,7 +3092,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString,       // S
                 {
                     nStringScanSign = -1; // direct double negation
                 }
-                else if ( pFormat->IsNegativeWithoutSign() )
+                else if ( mpFormat->IsNegativeWithoutSign() )
                 {
                     nStringScanSign = -1; // indirect double negation
                 }
@@ -3085,6 +3120,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                                                const SvNumberformat* pFormat ) // maybe number format set to match against
 {
     Reset();
+    mpFormat = pFormat;
     NumberStringDivision( rString );             // breakdown into strings and numbers
     if (nStringsCnt >= SV_MAX_COUNT_INPUT_STRINGS) // too many elements
     {
@@ -3138,7 +3174,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
         }
         else
         {                                   // Analyze start string
-            if (!ScanStartString( sStrArray[i], pFormat ))  // i=0
+            if (!ScanStartString( sStrArray[i] ))  // i=0
             {
                 return false;               // already an error
             }
@@ -3159,7 +3195,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                 return true;
             }
         }
-        if (i < nStringsCnt && !ScanEndString( sStrArray[i], pFormat ))
+        if (i < nStringsCnt && !ScanEndString( sStrArray[i] ))
         {
             return false;
         }
@@ -3168,18 +3204,18 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                                             // nStringsCnt >= 3
         if (!GetNextNumber(i,j))            // i=1,0
         {                                   // Analyze start string
-            if (!ScanStartString( sStrArray[i], pFormat ))
+            if (!ScanStartString( sStrArray[i] ))
                 return false;               // already an error
             i++;                            // i=1
         }
         GetNextNumber(i,j);                 // i=1,2
-        if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+        if ( !ScanMidString( sStrArray[i], i ) )
         {
             return false;
         }
         i++;                                // next symbol, i=2,3
         GetNextNumber(i,j);                 // i=3,4
-        if (i < nStringsCnt && !ScanEndString( sStrArray[i], pFormat ))
+        if (i < nStringsCnt && !ScanEndString( sStrArray[i] ))
         {
             return false;
         }
@@ -3200,7 +3236,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                                             // nStringsCnt >= 5
         if (!GetNextNumber(i,j))            // i=1,0
         {                                   // Analyze start string
-            if (!ScanStartString( sStrArray[i], pFormat ))
+            if (!ScanStartString( sStrArray[i] ))
             {
                 return false;               // already an error
             }
@@ -3211,7 +3247,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
             }
         }
         GetNextNumber(i,j);                 // i=1,2
-        if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+        if ( !ScanMidString( sStrArray[i], i ) )
         {
             return false;
         }
@@ -3221,13 +3257,13 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
             return false;
         }
         GetNextNumber(i,j);                 // i=3,4
-        if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+        if ( !ScanMidString( sStrArray[i], i ) )
         {
             return false;
         }
         i++;                                // i=4,5
         GetNextNumber(i,j);                 // i=5,6
-        if (i < nStringsCnt && !ScanEndString( sStrArray[i], pFormat ))
+        if (i < nStringsCnt && !ScanEndString( sStrArray[i] ))
         {
             return false;
         }
@@ -3252,14 +3288,14 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                                             // nStringsCnt >= 7
         if (!GetNextNumber(i,j))            // i=1,0
         {                                   // Analyze startstring
-            if (!ScanStartString( sStrArray[i], pFormat ))
+            if (!ScanStartString( sStrArray[i] ))
                 return false;               // already an error
             i++;                            // i=1
             if (nDecPos == 1)               // decimal separator at start => error
                 return false;
         }
         GetNextNumber(i,j);                 // i=1,2
-        if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+        if ( !ScanMidString( sStrArray[i], i ) )
         {
             return false;
         }
@@ -3275,7 +3311,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                     return false;
                 }
                 GetNextNumber(i,j);
-                if ( i < nStringsCnt && !ScanMidString( sStrArray[i], i, pFormat ) )
+                if ( i < nStringsCnt && !ScanMidString( sStrArray[i], i ) )
                 {
                     return false;
                 }
@@ -3293,7 +3329,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
                     return false;
                 }
                 GetNextNumber(i,j);
-                if ( i < nStringsCnt && !ScanMidString( sStrArray[i], i, pFormat ) )
+                if ( i < nStringsCnt && !ScanMidString( sStrArray[i], i ) )
                 {
                     return false;
                 }
@@ -3301,7 +3337,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
             }
         }
         GetNextNumber(i,j);
-        if (i < nStringsCnt && !ScanEndString( sStrArray[i], pFormat ))
+        if (i < nStringsCnt && !ScanEndString( sStrArray[i] ))
         {
             return false;
         }
@@ -3331,7 +3367,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
         bool bDidMatch = (nMatchedAllStrings != 0);
         if ( nMatchedAllStrings )
         {
-            bool bMatch = pFormat && pFormat->IsNumForStringElementCountEqual(
+            bool bMatch = mpFormat && mpFormat->IsNumForStringElementCountEqual(
                                nStringScanNumFor, nStringsCnt, nNumericsCnt );
             if ( !bMatch )
             {
@@ -3344,8 +3380,8 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
             // overall format because of mixed type subformats. Use the scan
             // matched subformat's type if any.
             SvNumFormatType eForType = eSetType;
-            if ((eForType == SvNumFormatType::UNDEFINED || eForType == SvNumFormatType::DEFINED) && pFormat)
-                eForType = pFormat->GetNumForInfoScannedType( nStringScanNumFor);
+            if ((eForType == SvNumFormatType::UNDEFINED || eForType == SvNumFormatType::DEFINED) && mpFormat)
+                eForType = mpFormat->GetNumForInfoScannedType( nStringScanNumFor);
             if (eForType != SvNumFormatType::UNDEFINED && eForType != SvNumFormatType::DEFINED)
                 eScannedType = eForType;
             else
@@ -3368,7 +3404,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
         bool bWasReturn = ((nMatchedAllStrings & nMatchedUsedAsReturn) != 0);
         if ( nMatchedAllStrings )
         {
-            bool bMatch = pFormat && pFormat->IsNumForStringElementCountEqual(
+            bool bMatch = mpFormat && mpFormat->IsNumForStringElementCountEqual(
                                nStringScanNumFor, nStringsCnt, nNumericsCnt );
             if ( !bMatch )
             {
@@ -3382,8 +3418,8 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
             // the scanned type in this case. Otherwise in IsNumberFormat() the
             // first numeric particle would be accepted as number.
             SvNumFormatType eForType = eSetType;
-            if ((eForType == SvNumFormatType::UNDEFINED || eForType == SvNumFormatType::DEFINED) && pFormat)
-                eForType = pFormat->GetNumForInfoScannedType( nStringScanNumFor);
+            if ((eForType == SvNumFormatType::UNDEFINED || eForType == SvNumFormatType::DEFINED) && mpFormat)
+                eForType = mpFormat->GetNumForInfoScannedType( nStringScanNumFor);
             if (eForType != SvNumFormatType::UNDEFINED && eForType != SvNumFormatType::DEFINED)
                 eScannedType = eForType;
         }
@@ -3691,7 +3727,7 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString,         // s
                         // not. The count of numbers in pattern must match the
                         // count of numbers in input.
                         res = (GetDatePatternNumbers() == nNumericsCnt)
-                            || IsAcceptableIso8601( pFormat) || nMatchedAllStrings;
+                            || IsAcceptableIso8601() || nMatchedAllStrings;
                     }
                 }
                 break;
@@ -3947,11 +3983,11 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString,         // s
             break;
 
         case SvNumFormatType::DATE:
-            res = GetDateRef( fOutNumber, k, pFormat );
+            res = GetDateRef( fOutNumber, k );
             break;
 
         case SvNumFormatType::DATETIME:
-            res = GetDateRef( fOutNumber, k, pFormat );
+            res = GetDateRef( fOutNumber, k );
             if ( res )
             {
                 double fTime;
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index 17b14edb4c2d..e7ddb7e6f1d9 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -70,6 +70,7 @@ public:
 
 private:
     SvNumberFormatter*  pFormatter;
+    const SvNumberformat* mpFormat;                            //* The format to compare against, if any
     std::unique_ptr<OUString[]> pUpperMonthText;               //* Array of month names, uppercase
     std::unique_ptr<OUString[]> pUpperAbbrevMonthText;         //* Array of month names, abbreviated, uppercase
     std::unique_ptr<OUString[]> pUpperGenitiveMonthText;       //* Array of genitive month names, uppercase
@@ -283,8 +284,7 @@ private:
 
     // Get currency symbol and advance string position
     bool GetCurrency( const OUString& rString,
-                      sal_Int32& nPos,
-                      const SvNumberformat* pFormat ); // number format to match against
+                      sal_Int32& nPos );
 
     // Get symbol AM or PM and advance string position
     bool GetTimeAmPm( const OUString& rString,
@@ -324,28 +324,23 @@ private:
 
     // Conversion of date to number
     bool GetDateRef( double& fDays,                          // OUT: days diff to null date
-                     sal_uInt16& nCounter,                   // Count of date substrings
-                     const SvNumberformat* pFormat );        // number format to match against
+                     sal_uInt16& nCounter );                 // Count of date substrings
 
     // Analyze start of string
-    bool ScanStartString( const OUString& rString,
-                          const SvNumberformat* pFormat );
+    bool ScanStartString( const OUString& rString );
 
     // Analyze middle substring
     bool ScanMidString( const OUString& rString,
-                        sal_uInt16 nStringPos,
-                        const SvNumberformat* pFormat );
+                        sal_uInt16 nStringPos );
 
 
     // Analyze end of string
-    bool ScanEndString( const OUString& rString,
-                        const SvNumberformat* pFormat );
+    bool ScanEndString( const OUString& rString );
 
     // Compare rString to substring of array indexed by nString
     // nString == 0xFFFF => last substring
     bool ScanStringNumFor( const OUString& rString,
                            sal_Int32 nPos,
-                           const SvNumberformat* pFormat,
                            sal_uInt16 nString,
                            bool bDontDetectNegation = false );
 
@@ -420,7 +415,7 @@ private:
     /** Whether input is acceptable as ISO 8601 date format in the current
         NfEvalDateFormat setting.
      */
-    bool IsAcceptableIso8601( const SvNumberformat* pFormat );
+    bool IsAcceptableIso8601();
 };
 
 #endif // INCLUDED_SVL_SOURCE_NUMBERS_ZFORFIND_HXX


More information about the Libreoffice-commits mailing list