[Libreoffice-commits] core.git: 2 commits - cui/source

Eike Rathke erack at redhat.com
Mon Apr 14 15:36:17 PDT 2014


 cui/source/options/optgdlg.cxx |   43 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 4 deletions(-)

New commits:
commit 042d4f8300a9a97fdd8da89013288a2c5623d48e
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Apr 14 23:52:02 2014 +0200

    a pattern must not start with a separator
    
    Change-Id: I5dfc5c859b007b7e3d7266c7656dc533788888ba

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 3e8718b..08586e8 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1736,6 +1736,10 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, Edit*, pEd )
                             bSep = false;
                             break;
                         default:
+                            // A pattern must not start with a separator (but
+                            // may end with).
+                            if (!(bY || bM || bD))
+                                bValid = false;
                             bSep = true;
                     }
                     nChar += i-j;
commit 03e96dd2bea1dba5297a41b5ed1ee3b4d0c3b65b
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Apr 14 23:19:18 2014 +0200

    toupper YMD for better input check visibility
    
    Change-Id: I24a01860bd019c3bf6e36c1e9df16e6ae6aa0ace

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index f833d44..3e8718b 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1668,13 +1668,16 @@ IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
 
 IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, Edit*, pEd )
 {
-    OUString aPatterns( pEd->GetText());
+    const OUString aPatterns( pEd->GetText());
+    OUStringBuffer aBuf( aPatterns);
+    sal_Int32 nChar = 0;
     bool bValid = true;
+    bool bModified = false;
     if (!aPatterns.isEmpty())
     {
-        for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; /*nop*/)
+        for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; ++nChar)
         {
-            OUString aPat( aPatterns.getToken( 0, ';', nIndex));
+            const OUString aPat( aPatterns.getToken( 0, ';', nIndex));
             if (aPat.isEmpty() && nIndex < 0)
             {
                 // Indicating failure when about to append a pattern is too
@@ -1691,37 +1694,65 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, Edit*, pEd )
                 bool bSep = true;
                 for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/)
                 {
-                    sal_uInt32 c = aPat.iterateCodePoints( &i);
+                    const sal_Int32 j = i;
+                    const sal_uInt32 c = aPat.iterateCodePoints( &i);
                     // Only one Y,M,D per pattern, separated by any character(s).
                     switch (c)
                     {
+                        case 'y':
                         case 'Y':
                             if (bY || !bSep)
                                 bValid = false;
+                            else if (c == 'y')
+                            {
+                                aBuf[nChar] = 'Y';
+                                bModified = true;
+                            }
                             bY = true;
                             bSep = false;
                             break;
+                        case 'm':
                         case 'M':
                             if (bM || !bSep)
                                 bValid = false;
+                            else if (c == 'm')
+                            {
+                                aBuf[nChar] = 'M';
+                                bModified = true;
+                            }
                             bM = true;
                             bSep = false;
                             break;
+                        case 'd':
                         case 'D':
                             if (bD || !bSep)
                                 bValid = false;
+                            else if (c == 'd')
+                            {
+                                aBuf[nChar] = 'D';
+                                bModified = true;
+                            }
                             bD = true;
                             bSep = false;
                             break;
                         default:
                             bSep = true;
                     }
+                    nChar += i-j;
                 }
                 // At least one of Y,M,D
                 bValid &= (bY || bM || bD);
             }
         }
     }
+    if (bModified)
+    {
+        // Do not use SetText(...,GetSelection()) because internally the
+        // reference's pointer of the selection is obtained resulting in the
+        // entire text being selected at the end.
+        Selection aSelection( pEd->GetSelection());
+        pEd->SetText( aBuf.makeStringAndClear(), aSelection);
+    }
     if (bValid)
     {
         pEd->SetControlForeground();


More information about the Libreoffice-commits mailing list