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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 24 17:25:40 UTC 2019


 forms/source/component/DatabaseForm.cxx |   34 +++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

New commits:
commit adbb6d9bbb1164d43b12594a1e99a5bece31cae6
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 23 16:37:15 2019 +0200
Commit:     Lionel Elie Mamane <lionel at mamane.lu>
CommitDate: Thu Jan 24 18:25:10 2019 +0100

    fix load/save of forms with HAVING
    
    Since
        commit 2b1d6f0d3b0b025148c81986ba7f109659d838af
        Date:   Sun Jul 30 17:57:14 2017 +0200
        tdf#96370 rework filtering to be aware of WHERE vs HAVING clause
    
    (1) the code was saving PROPERTY_FILTER and PROPERTY_SORT, but loading
    PROPERTY_FILTER and PROPERTY_HAVINGCLAUSE
    (2) the loading code was not putting the properties into m_xAggregateSet
    
    So I fixed the load/save mismatch, put the properties into the right
    location, and added the HAVING property, which meant I needed to do a
    version bump.
    
    I will note that this is somewhat of a backwards/forwards compatibility
    mess - the commit referenced above added new fields in the middle of the
    output stream, which means that older versions of LO will not be able
    to properly load forms generated after that commit.
    
    Change-Id: I9a13877b29d7c6bc5e6d014cfbcefd3069ddc4b5
    Reviewed-on: https://gerrit.libreoffice.org/66830
    Tested-by: Jenkins
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index ee43255d9e2b..ab58fae4ddf6 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -3752,7 +3752,7 @@ void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutS
     OFormComponents::write(_rxOutStream);
 
     // version
-    _rxOutStream->writeShort(0x0004);
+    _rxOutStream->writeShort(0x0005);
 
     // Name
     _rxOutStream << m_sName;
@@ -3830,18 +3830,15 @@ void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutS
     _rxOutStream->writeShort(static_cast<sal_Int16>(m_eNavigation));
 
     OUString sFilter;
-    OUString sHaving;
-    OUString sOrder;
+    OUString sSort;
     if (m_xAggregateSet.is())
     {
         m_xAggregateSet->getPropertyValue(PROPERTY_FILTER) >>= sFilter;
         // version 4
-        m_xAggregateSet->getPropertyValue(PROPERTY_HAVINGCLAUSE) >>= sHaving;
-        m_xAggregateSet->getPropertyValue(PROPERTY_SORT) >>= sOrder;
+        m_xAggregateSet->getPropertyValue(PROPERTY_SORT) >>= sSort;
     }
     _rxOutStream << sFilter;
-    _rxOutStream << sOrder;
-
+    _rxOutStream << sSort;
 
     // version 3
     sal_uInt16 nAnyMask = 0;
@@ -3859,6 +3856,12 @@ void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutS
         ::cppu::enum2int(nRealCycle, m_aCycle);
         _rxOutStream->writeShort(static_cast<sal_Int16>(nRealCycle));
     }
+
+    // version 5
+    OUString sHaving;
+    if (m_xAggregateSet.is())
+        m_xAggregateSet->getPropertyValue(PROPERTY_HAVINGCLAUSE) >>= sHaving;
+    _rxOutStream << sHaving;
 }
 
 
@@ -3935,16 +3938,14 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre
         m_eNavigation = static_cast<NavigationBarMode>(_rxInStream->readShort());
 
         _rxInStream >> sAggregateProp;
-        setPropertyValue(PROPERTY_FILTER, makeAny(sAggregateProp));
+        if (m_xAggregateSet.is())
+            m_xAggregateSet->setPropertyValue(PROPERTY_FILTER, makeAny(sAggregateProp));
         if(nVersion > 3)
         {
             _rxInStream >> sAggregateProp;
-            setPropertyValue(PROPERTY_HAVINGCLAUSE, makeAny(sAggregateProp));
+            if (m_xAggregateSet.is())
+                m_xAggregateSet->setPropertyValue(PROPERTY_SORT, makeAny(sAggregateProp));
         }
-
-        _rxInStream >> sAggregateProp;
-        if (m_xAggregateSet.is())
-            m_xAggregateSet->setPropertyValue(PROPERTY_SORT, makeAny(sAggregateProp));
     }
 
     sal_uInt16 nAnyMask = 0;
@@ -3961,6 +3962,13 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre
     }
     if (m_xAggregateSet.is())
         m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny((nAnyMask & DONTAPPLYFILTER) == 0));
+
+    if(nVersion > 4)
+    {
+        _rxInStream >> sAggregateProp;
+        if (m_xAggregateSet.is())
+            m_xAggregateSet->setPropertyValue(PROPERTY_HAVINGCLAUSE, makeAny(sAggregateProp));
+    }
 }
 
 


More information about the Libreoffice-commits mailing list