[Libreoffice-commits] core.git: sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 23 15:58:26 UTC 2019


 sc/source/ui/miscdlgs/acredlin.cxx |   45 +++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 17 deletions(-)

New commits:
commit 65f81f6acdeb03b34033a1c6515618936d5f8eca
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Apr 23 11:06:20 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Apr 23 17:57:33 2019 +0200

    multiple concatted AcceptChgDat stored in config
    
    FillInfo is called more often than Initialize, so we've ended up
    with multiple AcceptChgDat strings
    
    Change-Id: I99e9398757d63e2c6315ec9c3101910d5978b13b
    Reviewed-on: https://gerrit.libreoffice.org/71119
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 3e39243c5210..00b841ed4bc5 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -1701,34 +1701,43 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void)
     }
 }
 
-void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
+namespace
 {
-    OUString aStr;
-    if(pInfo!=nullptr)
+    //at one point we were writing multiple AcceptChgDat strings,
+    //so strip all of them and keep the results of the last one
+    OUString lcl_StripAcceptChgDat(OUString &rExtraString)
     {
-        if ( !pInfo->aExtraString.isEmpty() )
+        OUString aStr;
+        while (true)
         {
-            sal_Int32 nPos = pInfo->aExtraString.indexOf("AcceptChgDat:");
-
+            sal_Int32 nPos = rExtraString.indexOf("AcceptChgDat:");
+            if (nPos == -1)
+                break;
             // Try to read the alignment string "ALIGN:(...)"; if it is missing
             // we have an old version
-            if ( nPos != -1 )
+            sal_Int32 n1 = rExtraString.indexOf('(', nPos);
+            if ( n1 != -1 )
             {
-                sal_Int32 n1 = pInfo->aExtraString.indexOf('(', nPos);
-                if ( n1 != -1 )
+                sal_Int32 n2 = rExtraString.indexOf(')', n1);
+                if ( n2 != -1 )
                 {
-                    sal_Int32 n2 = pInfo->aExtraString.indexOf(')', n1);
-                    if ( n2 != -1 )
-                    {
-                        // cut out alignment string
-                        aStr = pInfo->aExtraString.copy(nPos, n2 - nPos + 1);
-                        pInfo->aExtraString = pInfo->aExtraString.replaceAt(nPos, n2 - nPos + 1, "");
-                        aStr = aStr.copy( n1-nPos+1 );
-                    }
+                    // cut out alignment string
+                    aStr = rExtraString.copy(nPos, n2 - nPos + 1);
+                    rExtraString = rExtraString.replaceAt(nPos, n2 - nPos + 1, "");
+                    aStr = aStr.copy( n1-nPos+1 );
                 }
             }
         }
+        return aStr;
     }
+}
+
+void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
+{
+    OUString aStr;
+    if (pInfo && !pInfo->aExtraString.isEmpty())
+        aStr = lcl_StripAcceptChgDat(pInfo->aExtraString);
+
     SfxModelessDialog::Initialize(pInfo);
 
     if ( !aStr.isEmpty())
@@ -1747,6 +1756,8 @@ void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
 void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
 {
     SfxModelessDialog::FillInfo(rInfo);
+    //remove any old one before adding a new one
+    lcl_StripAcceptChgDat(rInfo.aExtraString);
     rInfo.aExtraString += "AcceptChgDat:(";
 
     sal_uInt16  nCount=pTheView->TabCount();


More information about the Libreoffice-commits mailing list