[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 5 commits - basctl/source basic/source include/basic reportbuilder/java sw/source wizards/source xmloff/source

Noel Power noel.power at suse.com
Sun Sep 15 17:22:55 PDT 2013


 basctl/source/basicide/basides1.cxx                                  |    3 
 basic/source/classes/propacc.cxx                                     |    9 
 basic/source/classes/sbunoobj.cxx                                    |   11 
 basic/source/classes/sbxmod.cxx                                      |    3 
 basic/source/inc/date.hxx                                            |   15 
 basic/source/runtime/methods.cxx                                     |  200 +++++++++-
 basic/source/runtime/methods1.cxx                                    |    4 
 basic/source/runtime/rtlproto.hxx                                    |    6 
 basic/source/runtime/stdobj.cxx                                      |   12 
 basic/source/sbx/sbxvalue.cxx                                        |    2 
 include/basic/sbuno.hxx                                              |    6 
 include/basic/sbxvar.hxx                                             |    2 
 reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java |   98 ++--
 sw/source/ui/misc/swruler.cxx                                        |    7 
 wizards/source/depot/Depot.xba                                       |   20 -
 wizards/source/depot/Internet.xba                                    |    8 
 xmloff/source/draw/ximpstyl.cxx                                      |   45 ++
 17 files changed, 349 insertions(+), 102 deletions(-)

New commits:
commit 2c0cc6fac2437c864a90270eadfe005dfc707726
Author: Noel Power <noel.power at suse.com>
Date:   Thu Sep 12 21:37:42 2013 +0100

    fix for fdo#69173 crasher
    
    the layout changes for the basic IDE ( for the object browser and object
    catalog ) seem flacky, I have seen since those changes have been introduced
    some strange ( but random ) behaviour ( like the odd unrepeatable core ( maybe
    related to this ) and also sometimes Modules appearing in the tree under the
    wrong nodes etc. I'm no expert in the basic IDE code but this patch seems to
    fix the problem.
    However there is one drawback, in the core inducing scenario the tree view
    ( object catalog ) dissappears, this is because the patch suppresses the
    problematic layout in this case ( as the layout seem not to be currently able
    to deal with 'no-existent' (recently) deleted current window )
    Probably in this scenario a fallback currentwin (instead of nil) could be set
    this would behave better but ideally. Ultimately the layout class should
    probably be modified ( possibly redesigned )
    
    Change-Id: I9d1e23bd6fc4aae32aa78da8278c318f7051136a

diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 474e792..6779889 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -1010,7 +1010,10 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe
             }
         }
         else
+        {
+            SetWindow(pLayout);
             pLayout = 0;
+        }
         if ( bUpdateTabBar )
         {
             sal_uLong nKey = GetWindowId( pCurWin );
commit 952c5fe20d5975c8a2c9f5093d05472ca0fc78fd
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Sep 13 06:38:04 2013 +0200

    fdo#69147 report sort columns are RESULT columns
    
    as opposed to table columns or other expressions.
    So it makes no sense to slap a table name on them.
    Notwithstanding HSQLDB 1.8 (our embedded database) bugs.
    
    Change-Id: Ib5d0b1479e29b9efeafca9ebc2eb7ed8e0f42b79
    Reviewed-on: https://gerrit.libreoffice.org/5931
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java b/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java
index 20709e8..86ba838 100644
--- a/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java
+++ b/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java
@@ -234,67 +234,51 @@ public class SDBCReportDataFactory implements DataSourceFactory
     {
         final StringBuffer order = new StringBuffer();
         final int count = sortExpressions.size();
-        if (count != 0)
+        String quote;
+        try
+        {
+            quote = connection.getMetaData().getIdentifierQuoteString();
+        }
+        catch (SQLException ex)
+        {
+            LOGGER.error("ReportProcessing failed / getOrderStatement could not get quote character", ex);
+            // fall back to the SQL standard
+            quote="";
+        }
+        for (int i = 0; i < count; i++)
         {
-            try
+            final Object[] pair = (Object[]) sortExpressions.get(i);
+            String expression = (String) pair[0];
+
+            // LEM FIXME: ${EXPLETIVE}! Either the values we get are *always* already quoted
+            // (and then this whole work is not useful)
+            // or they are *never* quoted
+            // (and then just quote them unconditionally)
+            // The current mess gives an ambiguity when the column name starts with a quote character.
+            // It *seems* they are never quoted, but this needs further testing.
+            if (!expression.startsWith(quote))
             {
-                final String quote = connection.getMetaData().getIdentifierQuoteString();
-                final XComponent[] hold = new XComponent[1];
-                final XNameAccess columns = getFieldsByCommandDescriptor(commandType, command, hold);
-                if (columns != null)
-                {
-                    for (int i = 0; i < count; i++)
-                    {
-                        final Object[] pair = (Object[]) sortExpressions.get(i);
-                        String expression = (String) pair[0];
-
-                        if (!expression.startsWith(quote) && columns.hasByName(expression))
-                        {
-                            XPropertySet column;
-                            try
-                            {
-                                column = UnoRuntime.queryInterface(XPropertySet.class, columns.getByName(expression));
-                                String prefix;
-                                prefix = (String)column.getPropertyValue("TableName");
-                                if (prefix == null)
-                                    prefix = "";
-                                if (prefix.length() != 0)
-                                {
-                                    prefix = quote + prefix + quote + ".";
-                                }
-                                expression = prefix + quote + expression + quote;
-                            }
-                            catch (Exception ex)
-                            {
-                                Logger.getLogger(SDBCReportDataFactory.class.getName()).log(Level.SEVERE, null, ex);
-                                expression = quote + expression + quote;
-                            }
-                        }
-                        expression = expression.trim(); // Trim away white spaces
-
-                        if (expression.length() > 0)
-                        {
-                            order.append(expression);
-                            if (order.length() > 0)
-                            {
-                                order.append(' ');
-                            }
-                            final String sorting = (String) pair[1];
-                            if (sorting == null || sorting.equals(OfficeToken.FALSE))
-                            {
-                                order.append("DESC");
-                            }
-                            if ((i + 1) < count)
-                            {
-                                order.append(", ");
-                            }
-                        }
-                    }
-                }
+                expression = quote + expression + quote;
+                // LEM TODO: we should escape quotes in expression?
             }
-            catch (SQLException ex)
+            expression = expression.trim(); // Trim away white spaces
+
+            if (expression.length() > 0)
             {
-                LOGGER.error("ReportProcessing failed", ex);
+                order.append(expression);
+                if (order.length() > 0)
+                {
+                    order.append(' ');
+                }
+                final String sorting = (String) pair[1];
+                if (sorting == null || sorting.equals(OfficeToken.FALSE))
+                {
+                    order.append("DESC");
+                }
+                if ((i + 1) < count)
+                {
+                    order.append(", ");
+                }
             }
         }
         return order.toString();
commit 0964a73d03bf9f5b9f485ff39f97c7e7b54339b3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Sep 9 16:54:30 2013 +0100

    Resolves: fdo#34987 skip autoheight reset if it will be set to the same value
    
    Triggered by aa9af08b389a106fcfb53842ac7669b208a27205 which explicitly sets
    rSet.Put( SdrTextAutoGrowHeightItem(FALSE) ); so there is something set on the
    style which is being overwritten.
    
    The code here resets the style to the default of "true" before going on to set
    it to the explicit "false" again. In that window of time the master shapes
    listen to the property change, on being set to autoheight they resize and on
    being unset, they remain stuck on their autoheight calculated size.
    
    Reviewed-on: https://gerrit.libreoffice.org/5887
    Reviewed-by: mhofmann <borim7 at web.de>
    Reviewed-by: Thorsten Behrens <thb at documentfoundation.org>
    Tested-by: Thorsten Behrens <thb at documentfoundation.org>
    (cherry picked from commit 14e7a290dab7fead66ef6ff7f94c6a425d80ceb6)
    
    Conflicts:
    	xmloff/source/draw/ximpstyl.cxx
    
    Change-Id: I567a791b2bbbcb3a1a111633fabf509142984645
    Reviewed-on: https://gerrit.libreoffice.org/5929
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index db902df..d5fae19 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -1312,6 +1312,43 @@ void SdXMLStylesContext::ImpSetCellStyles() const
     }
 }
 
+//Resolves: fdo#34987 if the style's auto height before and after is the same
+//then don't reset it back to the underlying default of true for the small
+//period before its going to be reset to false again. Doing this avoids the
+//master page shapes from resizing themselves due to autoheight becoming
+//enabled before having autoheight turned off again and getting stuck on that
+//autosized height
+static bool canSkipReset(const OUString &rName, const XMLPropStyleContext* pPropStyle,
+    const uno::Reference< beans::XPropertySet > &rPropSet, const UniReference < XMLPropertySetMapper >& rPrMap)
+{
+    bool bCanSkipReset = false;
+    if (pPropStyle && rName == "TextAutoGrowHeight")
+    {
+        sal_Bool bOldStyleTextAutoGrowHeight(sal_False);
+        rPropSet->getPropertyValue("TextAutoGrowHeight") >>= bOldStyleTextAutoGrowHeight;
+
+        sal_Int32 nIndexStyle = rPrMap->GetEntryIndex(XML_NAMESPACE_DRAW, "auto-grow-height", 0);
+        if (nIndexStyle != -1)
+        {
+            const ::std::vector< XMLPropertyState > &rProperties = pPropStyle->GetProperties();
+            ::std::vector< XMLPropertyState >::const_iterator property = rProperties.begin();
+            for(; property != rProperties.end(); ++property)
+            {
+                sal_Int32 nIdx = property->mnIndex;
+                if (nIdx == nIndexStyle)
+                {
+                    sal_Bool bNewStyleTextAutoGrowHeight(sal_False);
+                    property->maValue >>= bNewStyleTextAutoGrowHeight;
+                    if (bNewStyleTextAutoGrowHeight == bOldStyleTextAutoGrowHeight)
+                        bCanSkipReset = true;;
+                    break;
+                }
+            }
+        }
+    }
+    return bCanSkipReset;
+}
+
 //////////////////////////////////////////////////////////////////////////////
 // help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles()
 //
@@ -1341,6 +1378,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc
             if(nFamily == pStyle->GetFamily() && !pStyle->IsDefaultStyle())
             {
                 OUString aStyleName(pStyle->GetDisplayName());
+
                 if( nPrefLen )
                 {
                     sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( sal_Unicode('-') ) + 1;
@@ -1350,6 +1388,8 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc
                     aStyleName = aStyleName.copy( nPrefLen );
                 }
 
+                XMLPropStyleContext* pPropStyle = dynamic_cast< XMLPropStyleContext* >(const_cast< SvXMLStyleContext* >( pStyle ) );
+
                 uno::Reference< style::XStyle > xStyle;
                 if(xPageStyles->hasByName(aStyleName))
                 {
@@ -1378,6 +1418,9 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc
                                 const OUString& rName = xPrMap->GetEntryAPIName( i );
                                 if( xPropSetInfo->hasPropertyByName( rName ) && beans::PropertyState_DIRECT_VALUE == xPropState->getPropertyState( rName ) )
                                 {
+                                    bool bCanSkipReset = canSkipReset(rName, pPropStyle, xPropSet, xPrMap);
+                                    if (bCanSkipReset)
+                                        continue;
                                     xPropState->setPropertyToDefault( rName );
                                 }
                             }
@@ -1408,9 +1451,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc
                 if(xStyle.is())
                 {
                     // set properties at style
-                    XMLPropStyleContext* pPropStyle = dynamic_cast< XMLPropStyleContext* >( const_cast< SvXMLStyleContext* >( pStyle ) );
                     uno::Reference< beans::XPropertySet > xPropSet(xStyle, uno::UNO_QUERY);
-
                     if(xPropSet.is() && pPropStyle)
                     {
                         pPropStyle->FillPropertySet(xPropSet);
commit c09bd7346f38b5c2f4048fa3e613883690b98c51
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Sep 9 20:00:48 2013 +0200

    Easier conversion between Basic Date and UNO Date/Time
    
    Utility functions to convert between Basic Date type
    and the representations of Date and Time in UNO, namely:
     - com.sun.star.util.Date
     - com.sun.star.util.Time
     - com.sun.star.util.DateTime
    
    Name of new functions:
     - CDateToUnoDate
     - CDateFromUnoDate
     - CDateToUnoTime
     - CDateFromUnoTime
     - CDateToUnoDateTime
     - CDateFromUnoDateTime
    
    Change-Id: I2b971df20df1c0351d071023e042169b548894f1
    Reviewed-on: https://gerrit.libreoffice.org/5897
    Reviewed-by: Noel Power <noel.power at suse.com>
    Tested-by: Noel Power <noel.power at suse.com>
    Reviewed-on: https://gerrit.libreoffice.org/5919

diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index 67cd65a..d4cc1e7 100644
--- a/basic/source/classes/propacc.cxx
+++ b/basic/source/classes/propacc.cxx
@@ -22,6 +22,7 @@
 
 #include <basic/sbstar.hxx>
 #include <sbunoobj.hxx>
+#include <basic/sbuno.hxx>
 
 using com::sun::star::uno::Reference;
 using namespace com::sun::star;
@@ -30,14 +31,6 @@ using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
 using namespace cppu;
 
-
-//========================================================================
-
-// Declaration conversion from Sbx to UNO with known target type
-Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty = NULL );
-
-//========================================================================
-
 #ifdef WNT
 #define CDECL _cdecl
 #endif
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 001df2a..fbc0f58 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -896,7 +896,7 @@ Type getUnoTypeForSbxBaseType( SbxDataType eType )
 }
 
 // Converting of Sbx to Uno without a know target class for TypeClass_ANY
-Type getUnoTypeForSbxValue( SbxValue* pVal )
+Type getUnoTypeForSbxValue( const SbxValue* pVal )
 {
     Type aRetType = getCppuVoidType();
     if( !pVal )
@@ -1025,11 +1025,8 @@ Type getUnoTypeForSbxValue( SbxValue* pVal )
     return aRetType;
 }
 
-// Declaration converting of Sbx to Uno with known target class
-Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty = NULL );
-
 // converting of Sbx to Uno without known target class for TypeClass_ANY
-Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType = false )
+Any sbxToUnoValueImpl( const SbxValue* pVar, bool bBlockConversionToSmallestType = false )
 {
     SbxDataType eBaseType = pVar->SbxValue::GetType();
     if( eBaseType == SbxOBJECT )
@@ -1193,7 +1190,7 @@ static Any implRekMultiDimArrayToSequence( SbxDimArray* pArray,
 }
 
 // Map old interface
-Any sbxToUnoValue( SbxVariable* pVar )
+Any sbxToUnoValue( const SbxValue* pVar )
 {
     return sbxToUnoValueImpl( pVar );
 }
@@ -1222,7 +1219,7 @@ static bool implGetTypeByName( const OUString& rName, Type& rRetType )
 
 
 // converting of Sbx to Uno with known target class
-Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty )
+Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property* pUnoProperty )
 {
     Any aRetVal;
 
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 28d10e2..0a1e338 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -25,6 +25,7 @@
 #include <svl/brdcst.hxx>
 #include <tools/shl.hxx>
 #include <basic/sbx.hxx>
+#include <basic/sbuno.hxx>
 #include "sbdiagnose.hxx"
 #include "sb.hxx"
 #include <sbjsmeth.hxx>
@@ -86,8 +87,6 @@ using namespace com::sun::star::uno;
 
 typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE;
 typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
-::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
-void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue );
 
 class DocObjectWrapper : public DocObjectWrapper_BASE
 {
diff --git a/basic/source/inc/date.hxx b/basic/source/inc/date.hxx
index cd38c89..cb70702 100644
--- a/basic/source/inc/date.hxx
+++ b/basic/source/inc/date.hxx
@@ -20,7 +20,15 @@
 #ifndef _SBDATE_HXX
 #define _SBDATE_HXX
 
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+
 bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double& rdRet );
+double implTimeSerial( sal_Int16 nHour, sal_Int16 nMinute, sal_Int16 nSecond);
+bool implDateTimeSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay,
+                         sal_Int16 nHour, sal_Int16 nMinute, sal_Int16 nSecond,
+                         double& rdRet );
 
 sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam = false, sal_Int16 nFirstDay = 0 );
 
@@ -32,6 +40,13 @@ sal_Int16 implGetHour( double dDate );
 sal_Int16 implGetMinute( double dDate );
 sal_Int16 implGetSecond( double dDate );
 
+::com::sun::star::util::Date SbxDateToUNODate( const SbxValue* );
+void SbxDateFromUNODate( SbxValue*, const ::com::sun::star::util::Date& );
+::com::sun::star::util::Time SbxDateToUNOTime( const SbxValue* );
+void SbxDateFromUNOTime( SbxValue*, const ::com::sun::star::util::Time& );
+::com::sun::star::util::DateTime SbxDateToUNODateTime( const SbxValue* );
+void SbxDateFromUNODateTime( SbxValue*, const ::com::sun::star::util::DateTime& );
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 4a94763..200b7b7 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -19,6 +19,7 @@
 
 #include <tools/date.hxx>
 #include <basic/sbxvar.hxx>
+#include <basic/sbuno.hxx>
 #include <osl/process.h>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
@@ -1856,6 +1857,177 @@ sal_Int16 implGetDateMonth( double aDate )
     return nRet;
 }
 
+::com::sun::star::util::Date SbxDateToUNODate( const SbxValue* const pVal )
+{
+    double aDate = pVal->GetDate();
+
+    com::sun::star::util::Date aUnoDate;
+    aUnoDate.Day   = implGetDateDay  ( aDate );
+    aUnoDate.Month = implGetDateMonth( aDate );
+    aUnoDate.Year  = implGetDateYear ( aDate );
+
+    return aUnoDate;
+}
+
+void SbxDateFromUNODate( SbxValue *pVal, const ::com::sun::star::util::Date& aUnoDate)
+{
+    double dDate;
+    if( implDateSerial( aUnoDate.Year, aUnoDate.Month, aUnoDate.Day, dDate ) )
+    {
+        pVal->PutDate( dDate );
+    }
+}
+
+// Function to convert date to UNO date (com.sun.star.util.Date)
+RTLFUNC(CDateToUnoDate)
+{
+    (void)pBasic;
+    (void)bWrite;
+
+    if ( rPar.Count() != 2 )
+    {
+        StarBASIC::Error( SbERR_BAD_ARGUMENT );
+        return;
+    }
+
+    unoToSbxValue(rPar.Get(0), Any(SbxDateToUNODate(rPar.Get(1))));
+}
+
+// Function to convert date from UNO date (com.sun.star.util.Date)
+RTLFUNC(CDateFromUnoDate)
+{
+    (void)pBasic;
+    (void)bWrite;
+
+    if ( rPar.Count() != 2 || rPar.Get(1)->GetType() != SbxOBJECT )
+    {
+        StarBASIC::Error( SbERR_BAD_ARGUMENT );
+        return;
+    }
+
+    Any aAny (sbxToUnoValue(rPar.Get(1), ::getCppuType( (com::sun::star::util::Date*)0 )));
+    com::sun::star::util::Date aUnoDate;
+    if(aAny >>= aUnoDate)
+        SbxDateFromUNODate(rPar.Get(0), aUnoDate);
+    else
+        SbxBase::SetError( SbxERR_CONVERSION );
+}
+
+::com::sun::star::util::Time SbxDateToUNOTime( const SbxValue* const pVal )
+{
+    double aDate = pVal->GetDate();
+
+    com::sun::star::util::Time aUnoTime;
+    aUnoTime.Hours       = implGetHour      ( aDate );
+    aUnoTime.Minutes     = implGetMinute    ( aDate );
+    aUnoTime.Seconds     = implGetSecond    ( aDate );
+    aUnoTime.NanoSeconds = 0;
+
+    return aUnoTime;
+}
+
+void SbxDateFromUNOTime( SbxValue *pVal, const ::com::sun::star::util::Time& aUnoTime)
+{
+    pVal->PutDate( implTimeSerial(aUnoTime.Hours, aUnoTime.Minutes, aUnoTime.Seconds) );
+}
+
+// Function to convert date to UNO time (com.sun.star.util.Time)
+RTLFUNC(CDateToUnoTime)
+{
+    (void)pBasic;
+    (void)bWrite;
+
+    if ( rPar.Count() != 2 )
+    {
+        StarBASIC::Error( SbERR_BAD_ARGUMENT );
+        return;
+    }
+
+    unoToSbxValue(rPar.Get(0), Any(SbxDateToUNOTime(rPar.Get(1))));
+}
+
+// Function to convert date from UNO time (com.sun.star.util.Time)
+RTLFUNC(CDateFromUnoTime)
+{
+    (void)pBasic;
+    (void)bWrite;
+
+    if ( rPar.Count() != 2 || rPar.Get(1)->GetType() != SbxOBJECT )
+    {
+        StarBASIC::Error( SbERR_BAD_ARGUMENT );
+        return;
+    }
+
+    Any aAny (sbxToUnoValue(rPar.Get(1), ::getCppuType( (com::sun::star::util::Time*)0 )));
+    com::sun::star::util::Time aUnoTime;
+    if(aAny >>= aUnoTime)
+        SbxDateFromUNOTime(rPar.Get(0), aUnoTime);
+    else
+        SbxBase::SetError( SbxERR_CONVERSION );
+}
+
+::com::sun::star::util::DateTime SbxDateToUNODateTime( const SbxValue* const pVal )
+{
+    double aDate = pVal->GetDate();
+
+    com::sun::star::util::DateTime aUnoDT;
+    aUnoDT.Day   = implGetDateDay  ( aDate );
+    aUnoDT.Month = implGetDateMonth( aDate );
+    aUnoDT.Year  = implGetDateYear ( aDate );
+    aUnoDT.Hours       = implGetHour      ( aDate );
+    aUnoDT.Minutes     = implGetMinute    ( aDate );
+    aUnoDT.Seconds     = implGetSecond    ( aDate );
+    aUnoDT.NanoSeconds = 0;
+
+    return aUnoDT;
+}
+
+void SbxDateFromUNODateTime( SbxValue *pVal, const ::com::sun::star::util::DateTime& aUnoDT)
+{
+    double dDate;
+    if( implDateTimeSerial( aUnoDT.Year, aUnoDT.Month, aUnoDT.Day,
+                            aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds,
+                            dDate ) )
+    {
+        pVal->PutDate( dDate );
+    }
+}
+
+// Function to convert date to UNO date (com.sun.star.util.Date)
+RTLFUNC(CDateToUnoDateTime)
+{
+    (void)pBasic;
+    (void)bWrite;
+
+    if ( rPar.Count() != 2 )
+    {
+        StarBASIC::Error( SbERR_BAD_ARGUMENT );
+        return;
+    }
+
+    unoToSbxValue(rPar.Get(0), Any(SbxDateToUNODateTime(rPar.Get(1))));
+}
+
+// Function to convert date from UNO date (com.sun.star.util.Date)
+RTLFUNC(CDateFromUnoDateTime)
+{
+    (void)pBasic;
+    (void)bWrite;
+
+    if ( rPar.Count() != 2 || rPar.Get(1)->GetType() != SbxOBJECT )
+    {
+        StarBASIC::Error( SbERR_BAD_ARGUMENT );
+        return;
+    }
+
+    Any aAny (sbxToUnoValue(rPar.Get(1), ::getCppuType( (com::sun::star::util::DateTime*)0 )));
+    com::sun::star::util::DateTime aUnoDT;
+    if(aAny >>= aUnoDT)
+        SbxDateFromUNODateTime(rPar.Get(0), aUnoDT);
+    else
+        SbxBase::SetError( SbxERR_CONVERSION );
+}
+
 // Function to convert date to ISO 8601 date format
 RTLFUNC(CDateToIso)
 {
@@ -1953,12 +2125,7 @@ RTLFUNC(TimeSerial)
         return;
     }
 
-    sal_Int32 nSeconds = nHour;
-    nSeconds *= 3600;
-    nSeconds += nMinute * 60;
-    nSeconds += nSecond;
-    double nDays = ((double)nSeconds) / (double)(86400.0);
-    rPar.Get(0)->PutDate( nDays ); // JSM
+    rPar.Get(0)->PutDate( implTimeSerial(nHour, nMinute, nSecond) ); // JSM
 }
 
 RTLFUNC(DateValue)
@@ -4805,6 +4972,27 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double&
     return true;
 }
 
+double implTimeSerial( sal_Int16 nHours, sal_Int16 nMinutes, sal_Int16 nSeconds )
+{
+    return
+        static_cast<double>( nHours * ::Time::secondPerHour +
+                             nMinutes * ::Time::secondPerMinute +
+                             nSeconds)
+        /
+        static_cast<double>( ::Time::secondPerDay );
+}
+
+bool implDateTimeSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay,
+                         sal_Int16 nHour, sal_Int16 nMinute, sal_Int16 nSecond,
+                         double& rdRet )
+{
+    double dDate;
+    if(!implDateSerial(nYear, nMonth, nDay, dDate))
+        return false;
+    rdRet += dDate + implTimeSerial(nHour, nMinute, nSecond);
+    return true;
+}
+
 sal_Int16 implGetMinute( double dDate )
 {
     if( dDate < 0.0 )
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 5847754..ae0c99a 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -33,6 +33,7 @@
 #include <osl/file.hxx>
 #include <vcl/jobset.hxx>
 #include <basic/sbobjmod.hxx>
+#include <basic/sbuno.hxx>
 
 #include "date.hxx"
 #include "sbintern.hxx"
@@ -60,9 +61,6 @@ using namespace com::sun::star::lang;
 using namespace com::sun::star::sheet;
 using namespace com::sun::star::uno;
 
-void unoToSbxValue( SbxVariable* pVar, const Any& aValue );
-Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, com::sun::star::beans::Property* pUnoProperty = NULL );
-
 static Reference< XCalendar3 > getLocaleCalendar( void )
 {
     static Reference< XCalendar3 > xCalendar;
diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx
index ccf0a3b..7a6a9d8 100644
--- a/basic/source/runtime/rtlproto.hxx
+++ b/basic/source/runtime/rtlproto.hxx
@@ -347,6 +347,12 @@ extern RTLFUNC(GlobalScope);
 extern RTLFUNC(FileExists);
 extern RTLFUNC(ConvertToUrl);
 extern RTLFUNC(ConvertFromUrl);
+extern RTLFUNC(CDateToUnoDate);
+extern RTLFUNC(CDateFromUnoDate);
+extern RTLFUNC(CDateToUnoTime);
+extern RTLFUNC(CDateFromUnoTime);
+extern RTLFUNC(CDateToUnoDateTime);
+extern RTLFUNC(CDateFromUnoDateTime);
 extern RTLFUNC(CDateToIso);
 extern RTLFUNC(CDateFromIso);
 extern RTLFUNC(CompatibilityMode);
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 0815804..34d4582 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -108,6 +108,18 @@ static Methods aMethods[] = {
   { "expression",   SbxVARIANT, 0,NULL,0 },
 { "CDate",          SbxDATE,      1 | _FUNCTION, RTLNAME(CDate),0           },
   { "expression",   SbxVARIANT, 0,NULL,0 },
+{ "CDateFromUnoDate",   SbxDATE,      1 | _FUNCTION, RTLNAME(CDateFromUnoDate),0    },
+  { "UnoDate",      SbxOBJECT, 0,NULL,0 },
+{ "CDateToUnoDate", SbxOBJECT,    1 | _FUNCTION, RTLNAME(CDateToUnoDate),0      },
+  { "Date",         SbxDATE, 0,NULL,0 },
+{ "CDateFromUnoTime",   SbxDATE,      1 | _FUNCTION, RTLNAME(CDateFromUnoTime),0    },
+  { "UnoTime",      SbxOBJECT, 0,NULL,0 },
+{ "CDateToUnoTime", SbxOBJECT,    1 | _FUNCTION, RTLNAME(CDateToUnoTime),0      },
+  { "Time",         SbxDATE, 0,NULL,0 },
+{ "CDateFromUnoDateTime",   SbxDATE,      1 | _FUNCTION, RTLNAME(CDateFromUnoDateTime),0    },
+  { "UnoDateTime",      SbxOBJECT, 0,NULL,0 },
+{ "CDateToUnoDateTime", SbxOBJECT,    1 | _FUNCTION, RTLNAME(CDateToUnoDateTime),0      },
+  { "DateTime",         SbxDATE, 0,NULL,0 },
 { "CDateFromIso",   SbxDATE,      1 | _FUNCTION, RTLNAME(CDateFromIso),0    },
   { "IsoDate",      SbxSTRING, 0,NULL,0 },
 { "CDateToIso",     SbxSTRING,    1 | _FUNCTION, RTLNAME(CDateToIso),0      },
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 3efbdab..2f9e969 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -663,7 +663,7 @@ sal_Bool SbxValue::PutDecimal( com::sun::star::bridge::oleautomation::Decimal& r
 }
 
 sal_Bool SbxValue::fillAutomationDecimal
-    ( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec )
+    ( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ) const
 {
     SbxDecimal* pDecimal = GetDecimal();
     if( pDecimal != NULL )
diff --git a/include/basic/sbuno.hxx b/include/basic/sbuno.hxx
index 55d487a..3014869 100644
--- a/include/basic/sbuno.hxx
+++ b/include/basic/sbuno.hxx
@@ -20,6 +20,9 @@
 #ifndef _SB_SBUNO_HXX
 #define _SB_SBUNO_HXX
 
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Type.hxx>
 #include <basic/sbxobj.hxx>
 #include "basicdllapi.h"
 
@@ -33,7 +36,8 @@ BASIC_DLLPUBLIC SbxObjectRef GetSbUnoObject( const OUString& aName, const com::s
 BASIC_DLLPUBLIC void createAllObjectProperties( SbxObject* pObj );
 BASIC_DLLPUBLIC void SetSbUnoObjectDfltPropName( SbxObject* pObj );
 
-BASIC_DLLPUBLIC ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
+BASIC_DLLPUBLIC ::com::sun::star::uno::Any sbxToUnoValue( const SbxValue* pVar );
+BASIC_DLLPUBLIC ::com::sun::star::uno::Any sbxToUnoValue( const SbxValue* pVar, const ::com::sun::star::uno::Type& rType, com::sun::star::beans::Property* pUnoProperty = NULL );
 
 BASIC_DLLPUBLIC void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue );
 
diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx
index 4d4a8b6..a81836f 100644
--- a/include/basic/sbxvar.hxx
+++ b/include/basic/sbxvar.hxx
@@ -189,7 +189,7 @@ public:
             // Special methods
     sal_Bool PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
     sal_Bool PutDecimal( SbxDecimal* pDecimal ); // This function is needed for Windows build, don't remove
-    sal_Bool fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
+    sal_Bool fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ) const;
     sal_Bool PutCurrency( const sal_Int64& );
             // Interface for CDbl in Basic
     static SbxError ScanNumIntnl( const OUString& rSrc, double& nVal, bool bSingle = false );
diff --git a/wizards/source/depot/Depot.xba b/wizards/source/depot/Depot.xba
index 73f81a1..6a8b141 100644
--- a/wizards/source/depot/Depot.xba
+++ b/wizards/source/depot/Depot.xba
@@ -129,7 +129,7 @@ Dim LocStockName as String
 		End If
 	End If
 	CurRate = TransactModel.txtRate.Value
-	TransactDate = CDateFromISO(TransactModel.txtDate.Date)
+	TransactDate = CDateFromUNODate(TransactModel.txtDate.Date)
 	DlgTransaction.EndExecute()
 	UnprotectSheets(oSheets)
 
@@ -148,7 +148,7 @@ Dim LocStockName as String
 		oMovementSheet.GetCellByPosition(SBCOLUMNQUANTITY2, iNewRow).Value = -TransactModel.txtQuantity.Value
 	End If
 	
-	oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iNewRow).Value = CDateFromISO(TransactModel.txtDate.Date)
+	oMovementSheet.GetCellByPosition(SBCOLUMNDATE2, iNewRow).Value = CDateFromUNODate(TransactModel.txtDate.Date)
 	oMovementSheet.GetCellByPosition(SBCOLUMNRATE2, iNewRow).Value = TransactModel.txtRate.Value
 	oMovementSheet.GetCellByPosition(SBCOLUMNPROVPERCENT2, iNewRow).Value = TransactModel.txtCommission.EffectiveValue
 	oMovementSheet.GetCellByPosition(SBCOLUMNPROVMIN2, iNewRow).Value = TransactModel.txtMinimum.Value
@@ -290,7 +290,7 @@ Dim oModel as Object
 			' Store entered values in variables
 			OldNumber = oModel.txtOldRate.Value
 			NewNumber = oModel.txtNewRate.Value
-			SplitDate = CDateFromISO(oModel.txtDate.Date)
+			SplitDate = CDateFromUNODate(oModel.txtDate.Date)
 			iRow = SBROWFIRSTTRANSACT2
 			NoteText = cSplit & SplitDate & ", " & oModel.txtOldRate.Value & oModel.lblColon.Label & oModel.txtNewRate.Value
 			Do 
@@ -398,8 +398,8 @@ End Sub
 Sub SetupTransactionControls(CurStep as Integer)
 	DlgReference = DlgTransaction
 	With TransactModel
-		.txtDate.Date = CDateToISO(Date())
-		.txtDate.DateMax = CDateToISO(Date())
+		.txtDate.Date = CDateToUNODate(Date())
+		.txtDate.DateMax = CDateToUNODate(Date())
 		.txtStockID.Enabled = False
 		.lblStockID.Enabled = False
 		.lblStockID.Label = sCurStockIDLabel
@@ -504,12 +504,12 @@ Sub InitializeStockRatesControls(CurStep as Integer)
 			Case 2
 				.txtOldRate.Value = 1
 				.txtNewRate.Value = 1
-				.txtDate.Date = CDateToISO(Date())
+				.txtDate.Date = CDateToUNODate(Date())
 			Case 3
-				.txtStartDate.DateMax = CDateToISO(CDate(Date())-1)
-				.txtEndDate.DateMax = CDateToISO(CDate(Date())-1)
-				.txtStartDate.Date = CDateToISO(CDate(Date())-8)
-				.txtEndDate.Date = CDateToISO(CDate(Date())-1)
+				.txtStartDate.DateMax = CDateToUNODate(CDate(Date())-1)
+				.txtEndDate.DateMax = CDateToUNODate(CDate(Date())-1)
+				.txtStartDate.Date = CDateToUNODate(CDate(Date())-8)
+				.txtEndDate.Date = CDateToUNODate(CDate(Date())-1)
 				.optDaily.State = 1
 		End Select
 	End With
diff --git a/wizards/source/depot/Internet.xba b/wizards/source/depot/Internet.xba
index 3e57f0a..b4bcf57 100644
--- a/wizards/source/depot/Internet.xba
+++ b/wizards/source/depot/Internet.xba
@@ -25,8 +25,8 @@ Function CheckHistoryControls()
 Dim bLocGoOn as Boolean
 Dim Firstdate as Date
 Dim LastDate as Date
-	LastDate = CDateFromISO(StockRatesModel.txtEndDate.Date)
-	FirstDate = CDateFromISO(StockRatesModel.txtStartDate.Date)
+	LastDate = CDateFromUNODate(StockRatesModel.txtEndDate.Date)
+	FirstDate = CDateFromUNODate(StockRatesModel.txtStartDate.Date)
 	bLocGoOn = FirstDate <> 0 And LastDate <> 0
 	If bLocGoOn Then
 		If FirstDate >= LastDate Then
@@ -47,8 +47,8 @@ Dim oCell as Object
 Dim sStockID as String
 Dim ChartSource as String	
 	If CheckHistoryControls() Then
-		StartDate = CDateFromISO(StockRatesModel.txtStartDate.Date)
-		EndDate = CDateFromISO(StockRatesModel.txtEndDate.Date)
+		StartDate = CDateFromUNODate(StockRatesModel.txtStartDate.Date)
+		EndDate = CDateFromUNODate(StockRatesModel.txtEndDate.Date)
 		DlgStockRates.EndExecute()
 		If StockRatesModel.optDaily.State = 1 Then
 			sInterval = "d"
commit 20d50a8c87c87f33c57397ca2c6f25d49e51f7cd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 12 10:56:37 2013 +0100

    Resolves: rhbz#1006850 crash in SwCommentRuler::GetCommentControlRegion
    
    Change-Id: Ic846da3b22391d724da6f8df94dd771e89d2efb4
    (cherry picked from commit b73dec8a06ef762098e642b2c37e4baad780b11a)
    Reviewed-on: https://gerrit.libreoffice.org/5924
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/sw/source/ui/misc/swruler.cxx b/sw/source/ui/misc/swruler.cxx
index a41fc0b..76fb8be 100644
--- a/sw/source/ui/misc/swruler.cxx
+++ b/sw/source/ui/misc/swruler.cxx
@@ -247,6 +247,13 @@ void SwCommentRuler::UpdateCommentHelpText()
 Rectangle SwCommentRuler::GetCommentControlRegion()
 {
     SwPostItMgr *pPostItMgr = mpViewShell->GetPostItMgr();
+
+    //rhbz#1006850 When the SwPostItMgr ctor is called from SwView::SwView it
+    //triggers an update of the uiview, but the result of the ctor hasn't been
+    //set into the mpViewShell yet, so GetPostItMgr is temporarily still NULL
+    if (!pPostItMgr)
+        return Rectangle();
+
     //FIXME When the page width is larger then screen, the ruler is misplaced by one pixel
     long nLeft   = GetWinOffset() + GetPageOffset() + mpSwWin->LogicToPixel(Size(GetPageWidth(), 0)).Width();
     long nTop    = 0 + 4; // Ruler::ImplDraw uses RULER_OFF (value: 3px) as offset, and Ruler::ImplFormat adds one extra pixel


More information about the Libreoffice-commits mailing list