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

Lionel Elie Mamane lionel at mamane.lu
Mon Aug 5 10:28:29 PDT 2013


 xmlscript/source/xmldlg_imexp/exp_share.hxx        |    4 +
 xmlscript/source/xmldlg_imexp/imp_share.hxx        |    6 ++
 xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx |   12 ++--
 xmlscript/source/xmldlg_imexp/xmldlg_export.cxx    |   56 +++++++++++++++++++++
 xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx |   12 ++--
 xmlscript/source/xmldlg_imexp/xmldlg_import.cxx    |   38 ++++++++++++++
 6 files changed, 116 insertions(+), 12 deletions(-)

New commits:
commit 3b388abc1e9d75a045cc0f6ca9306ff3336251bc
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Aug 5 19:18:20 2013 +0200

    Adapt Dialog XML import/export code
    
    to:
     commit 8ee69b0ba13f74d1515fac71df92947eb6328ab1
    
     fdo#67235 adapt form control code to time nanosecond API change, step 3.
    
    Change-Id: I57b549c9c1379154173bb50463171a60ce35ca0c

diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx
index 3b836de6..eb94eff 100644
--- a/xmlscript/source/xmldlg_imexp/exp_share.hxx
+++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx
@@ -137,8 +137,12 @@ public:
         OUString const & rPropName, OUString const & rAttrName );
     void readImagePositionAttr(
         OUString const & rPropName, OUString const & rAttrName );
+    void readDateAttr(
+        OUString const & rPropName, OUString const & rAttrName );
     void readDateFormatAttr(
         OUString const & rPropName, OUString const & rAttrName );
+    void readTimeAttr(
+        OUString const & rPropName, OUString const & rAttrName );
     void readTimeFormatAttr(
         OUString const & rPropName, OUString const & rAttrName );
     void readOrientationAttr(
diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx
index 2df45c0..dfea149 100644
--- a/xmlscript/source/xmldlg_imexp/imp_share.hxx
+++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx
@@ -444,9 +444,15 @@ public:
     bool importImagePositionProperty(
         OUString const & rPropName, OUString const & rAttrName,
         css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+    bool importDateProperty(
+        OUString const & rPropName, OUString const & rAttrName,
+        css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
     bool importDateFormatProperty(
         OUString const & rPropName, OUString const & rAttrName,
         css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+    bool importTimeProperty(
+        OUString const & rPropName, OUString const & rAttrName,
+        css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
     bool importTimeFormatProperty(
         OUString const & rPropName, OUString const & rAttrName,
         css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
index eb2ed75..84f2f16 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
@@ -737,9 +737,9 @@ void ElementDescriptor::readDateFieldModel( StyleBag * all_styles )
     readBoolAttr( "StrictFormat", XMLNS_DIALOGS_PREFIX ":strict-format" );
     readDateFormatAttr( "DateFormat", XMLNS_DIALOGS_PREFIX ":date-format" );
     readBoolAttr( "DateShowCentury", XMLNS_DIALOGS_PREFIX ":show-century" );
-    readLongAttr( "Date", XMLNS_DIALOGS_PREFIX ":value" );
-    readLongAttr( "DateMin", XMLNS_DIALOGS_PREFIX ":value-min" );
-    readLongAttr( "DateMax", XMLNS_DIALOGS_PREFIX ":value-max" );
+    readDateAttr( "Date", XMLNS_DIALOGS_PREFIX ":value" );
+    readDateAttr( "DateMin", XMLNS_DIALOGS_PREFIX ":value-min" );
+    readDateAttr( "DateMax", XMLNS_DIALOGS_PREFIX ":value-max" );
     readBoolAttr( "Spin", XMLNS_DIALOGS_PREFIX ":spin" );
     if (extract_throw<bool>( _xProps->getPropertyValue( "Repeat" ) ))
         readLongAttr( "RepeatDelay", XMLNS_DIALOGS_PREFIX ":repeat", true /* force */ );
@@ -815,9 +815,9 @@ void ElementDescriptor::readTimeFieldModel( StyleBag * all_styles )
     readBoolAttr( "HideInactiveSelection", XMLNS_DIALOGS_PREFIX ":hide-inactive-selection" );
     readBoolAttr( "StrictFormat", XMLNS_DIALOGS_PREFIX ":strict-format" );
     readTimeFormatAttr( "TimeFormat", XMLNS_DIALOGS_PREFIX ":time-format" );
-    readLongAttr( "Time", XMLNS_DIALOGS_PREFIX ":value" );
-    readLongAttr( "TimeMin", XMLNS_DIALOGS_PREFIX ":value-min" );
-    readLongAttr( "TimeMax", XMLNS_DIALOGS_PREFIX ":value-max" );
+    readTimeAttr( "Time", XMLNS_DIALOGS_PREFIX ":value" );
+    readTimeAttr( "TimeMin", XMLNS_DIALOGS_PREFIX ":value-min" );
+    readTimeAttr( "TimeMax", XMLNS_DIALOGS_PREFIX ":value-max" );
     readBoolAttr( "Spin", XMLNS_DIALOGS_PREFIX ":spin" );
     if (extract_throw<bool>( _xProps->getPropertyValue( "Repeat" ) ))
         readLongAttr( "RepeatDelay", XMLNS_DIALOGS_PREFIX ":repeat", true /* force */ );
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
index 8f7c284..e3b7a6c 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -35,6 +35,10 @@
 #include <com/sun/star/awt/LineEndFormat.hpp>
 #include <com/sun/star/awt/PushButtonType.hpp>
 #include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <tools/date.hxx>
+#include <tools/time.hxx>
 
 #include <com/sun/star/io/XPersistObject.hpp>
 
@@ -597,6 +601,50 @@ void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString
                 break;
             }
         }
+        else
+            OSL_FAIL( "### unexpected property type!" );
+    }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readDateAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+    if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+    {
+        Any a( _xProps->getPropertyValue( rPropName ) );
+        if (a.getValueTypeClass() == TypeClass_STRUCT && a.getValueType() == ::getCppuType( (util::Date*)0 ))
+        {
+            util::Date aUDate;
+            if (a >>= aUDate)
+            {
+                ::Date aTDate(aUDate);
+                addAttribute( rAttrName, OUString::valueOf( static_cast<sal_Int32>(aTDate.GetDate()) ) );
+            }
+            else
+                OSL_FAIL( "### internal error" );
+        }
+        else
+            OSL_FAIL( "### unexpected property type!" );
+    }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readTimeAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+    if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+    {
+        Any a( _xProps->getPropertyValue( rPropName ) );
+        if (a.getValueTypeClass() == TypeClass_STRUCT && a.getValueType() == ::getCppuType( (util::Time*)0 ))
+        {
+            util::Time aUTime;
+            if (a >>= aUTime)
+            {
+                ::Time aTTime(aUTime);
+                addAttribute( rAttrName, OUString::valueOf( aTTime.GetTime() / ::Time::nanoPerCenti ) );
+            }
+            else
+                OSL_FAIL( "### internal error" );
+        }
+        else
+            OSL_FAIL( "### unexpected property type!" );
     }
 }
 //__________________________________________________________________________________________________
@@ -632,6 +680,8 @@ void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString
                 break;
             }
         }
+        else
+            OSL_FAIL( "### unexpected property type!" );
     }
 }
 //__________________________________________________________________________________________________
@@ -658,6 +708,8 @@ void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString cons
                 break;
             }
         }
+        else
+            OSL_FAIL( "### unexpected property type!" );
     }
 }
 //__________________________________________________________________________________________________
@@ -686,6 +738,8 @@ void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUStr
                 break;
             }
         }
+        else
+            OSL_FAIL( "### unexpected property type!" );
     }
 }
 //__________________________________________________________________________________________________
@@ -738,6 +792,8 @@ void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString
                 break;
             }
         }
+        else
+            OSL_FAIL( "### unexpected property type!" );
     }
 }
 //__________________________________________________________________________________________________
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
index 650541d..af5d401 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
@@ -636,9 +636,9 @@ void TimeFieldElement::endElement()
     ctx.importBooleanProperty( "StrictFormat", "strict-format", _xAttributes );
     ctx.importBooleanProperty("HideInactiveSelection","hide-inactive-selection", _xAttributes );
     ctx.importTimeFormatProperty( "TimeFormat", "time-format", _xAttributes );
-    ctx.importLongProperty( "Time", "value", _xAttributes );
-    ctx.importLongProperty( "TimeMin", "value-min", _xAttributes );
-    ctx.importLongProperty( "TimeMax", "value-max", _xAttributes );
+    ctx.importTimeProperty( "Time", "value", _xAttributes );
+    ctx.importTimeProperty( "TimeMin", "value-min", _xAttributes );
+    ctx.importTimeProperty( "TimeMax", "value-max", _xAttributes );
     ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
     if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
         ctx.getControlModel()->setPropertyValue("Repeat", makeAny(true) );
@@ -753,9 +753,9 @@ void DateFieldElement::endElement()
     ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
     ctx.importDateFormatProperty( "DateFormat", "date-format", _xAttributes );
     ctx.importBooleanProperty( "DateShowCentury", "show-century", _xAttributes );
-    ctx.importLongProperty( "Date", "value", _xAttributes );
-    ctx.importLongProperty( "DateMin", "value-min", _xAttributes );
-    ctx.importLongProperty( "DateMax", "value-max", _xAttributes );
+    ctx.importDateProperty( "Date", "value", _xAttributes );
+    ctx.importDateProperty( "DateMin", "value-min", _xAttributes );
+    ctx.importDateProperty( "DateMax", "value-max", _xAttributes );
     ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
     if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
         ctx.getControlModel()->setPropertyValue( "Repeat", makeAny(true) );
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
index 3d218dd..ad278c0 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
@@ -34,6 +34,10 @@
 #include <com/sun/star/awt/PushButtonType.hpp>
 #include <com/sun/star/awt/VisualEffect.hpp>
 #include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <tools/date.hxx>
+#include <tools/time.hxx>
 
 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
@@ -1194,6 +1198,40 @@ bool ImportContext::importDateFormatProperty(
     return false;
 }
 //__________________________________________________________________________________________________
+bool ImportContext::importTimeProperty(
+    OUString const & rPropName, OUString const & rAttrName,
+    Reference< xml::input::XAttributes > const & xAttributes )
+{
+    OUString aValue(
+        xAttributes->getValueByUidName(
+            _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+    if (!aValue.isEmpty())
+    {
+        ::Time aTTime(toInt32( aValue ) * ::Time::nanoPerCenti);
+        util::Time aUTime(aTTime.GetUNOTime());
+        _xControlModel->setPropertyValue( rPropName, makeAny( aUTime ) );
+        return true;
+    }
+    return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importDateProperty(
+    OUString const & rPropName, OUString const & rAttrName,
+    Reference< xml::input::XAttributes > const & xAttributes )
+{
+    OUString aValue(
+        xAttributes->getValueByUidName(
+            _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+    if (!aValue.isEmpty())
+    {
+        ::Date aTDate(toInt32( aValue ));
+        util::Date aUDate(aTDate.GetUNODate());
+        _xControlModel->setPropertyValue( rPropName, makeAny( aUDate ) );
+        return true;
+    }
+    return false;
+}
+//__________________________________________________________________________________________________
 bool ImportContext::importTimeFormatProperty(
     OUString const & rPropName, OUString const & rAttrName,
     Reference< xml::input::XAttributes > const & xAttributes )


More information about the Libreoffice-commits mailing list