[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - forms/source

Lionel Elie Mamane lionel at mamane.lu
Wed Feb 5 08:32:04 PST 2014


 forms/source/component/EditBase.cxx |   46 ++++++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 5 deletions(-)

New commits:
commit 24c01fae1c9ad1ced40f29660468f4464ce35e26
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Feb 5 16:53:10 2014 +0100

    fdo#69652 Default(Date|Time) is a UNO struct now
    
    Changed to UNO struct from integer by
      fdo#67235 adapt form control code to time nanosecond API change
    
    Change-Id: I5817d44438d70a0da534c03afd22d74a311252f5
    Reviewed-on: https://gerrit.libreoffice.org/7882
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/forms/source/component/EditBase.cxx b/forms/source/component/EditBase.cxx
index bfbb76f..18473e1 100644
--- a/forms/source/component/EditBase.cxx
+++ b/forms/source/component/EditBase.cxx
@@ -26,10 +26,15 @@
 #include <cppuhelper/queryinterface.hxx>
 #include "frm_resource.hxx"
 #include "frm_resource.hrc"
+#include <tools/time.hxx>
+#include <tools/date.hxx>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Date.hpp>
 
 //.........................................................................
 namespace frm
 {
+using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::sdb;
 using namespace ::com::sun::star::sdbc;
@@ -42,9 +47,14 @@ using namespace ::com::sun::star::io;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::util;
 
-const sal_uInt16 DEFAULT_LONG    =  0x0001;
-const sal_uInt16 DEFAULT_DOUBLE  =  0x0002;
-const sal_uInt16 FILTERPROPOSAL  =  0x0004;
+namespace
+{
+    const sal_uInt16 DEFAULT_LONG    =  0x0001;
+    const sal_uInt16 DEFAULT_DOUBLE  =  0x0002;
+    const sal_uInt16 FILTERPROPOSAL  =  0x0004;
+    const sal_uInt16 DEFAULT_TIME    =  0x0008;
+    const sal_uInt16 DEFAULT_DATE    =  0x0010;
+}
 
 DBG_NAME( OEditBaseModel )
 //------------------------------------------------------------------
@@ -84,7 +94,7 @@ void OEditBaseModel::write(const Reference<XObjectOutputStream>& _rxOutStream) t
     OBoundControlModel::write(_rxOutStream);
 
     // Version
-    sal_uInt16 nVersionId = 0x0005;
+    sal_uInt16 nVersionId = 0x0006;
     DBG_ASSERT((getPersistenceFlags() & ~PF_SPECIAL_FLAGS) == 0,
         "OEditBaseModel::write : invalid special version flags !");
         // please don't use other flags, older versions can't interpret them !
@@ -102,6 +112,10 @@ void OEditBaseModel::write(const Reference<XObjectOutputStream>& _rxOutStream) t
         nAnyMask |= DEFAULT_LONG;
     else if (m_aDefault.getValueType().getTypeClass() == TypeClass_DOUBLE)
         nAnyMask |= DEFAULT_DOUBLE;
+    else if (m_aDefault.getValueType() == ::getCppuType((const util::Time*)0))
+        nAnyMask |= DEFAULT_TIME;
+    else if (m_aDefault.getValueType() == ::getCppuType((const util::Date*)0))
+        nAnyMask |= DEFAULT_DATE;
 
     if (m_bFilterProposal)  // Don't save a value, because it's boolean
         nAnyMask |= FILTERPROPOSAL;
@@ -113,6 +127,18 @@ void OEditBaseModel::write(const Reference<XObjectOutputStream>& _rxOutStream) t
         _rxOutStream->writeLong(getINT32(m_aDefault));
     else if ((nAnyMask & DEFAULT_DOUBLE) == DEFAULT_DOUBLE)
         _rxOutStream->writeDouble(getDouble(m_aDefault));
+    else if ((nAnyMask & DEFAULT_TIME) == DEFAULT_TIME)
+    {
+        util::Time aTime;
+        OSL_VERIFY(m_aDefault >>= aTime);
+        _rxOutStream->writeHyper(::Time(aTime).GetTime());
+    }
+    else if ((nAnyMask & DEFAULT_DATE) == DEFAULT_DATE)
+    {
+        util::Date aDate;
+        OSL_VERIFY(m_aDefault >>= aDate);
+        _rxOutStream->writeLong(::Date(aDate).GetDate());
+    }
 
     // since version 5 we write the help text
     writeHelpTextCompatibly(_rxOutStream);
@@ -169,6 +195,14 @@ void OEditBaseModel::read(const Reference<XObjectInputStream>& _rxInStream) thro
             double fValue = _rxInStream->readDouble();
             m_aDefault <<= (double)fValue;
         }
+        else if ((nAnyMask & DEFAULT_TIME) == DEFAULT_TIME)
+        {
+            m_aDefault <<= ::Time(_rxInStream->readHyper()).GetUNOTime();
+        }
+        else if ((nAnyMask & DEFAULT_DATE) == DEFAULT_DATE)
+        {
+            m_aDefault <<= ::Date(_rxInStream->readLong()).GetUNODate();
+        }
 
         if ((nAnyMask & FILTERPROPOSAL) == FILTERPROPOSAL)
             m_bFilterProposal = sal_True;
@@ -281,8 +315,10 @@ sal_Bool OEditBaseModel::convertFastPropertyValue( Any& rConvertedValue, Any& rO
             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const double*)0));
             break;
         case PROPERTY_ID_DEFAULT_DATE:
+            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const util::Date*)0));
+            break;
         case PROPERTY_ID_DEFAULT_TIME:
-            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const sal_Int32*)0));
+            bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const util::Time*)0));
             break;
         default:
             bModified = OBoundControlModel::convertFastPropertyValue(


More information about the Libreoffice-commits mailing list