[Libreoffice-commits] core.git: 2 commits - include/cppuhelper xmlsecurity/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Oct 20 15:13:09 UTC 2016


 include/cppuhelper/proptypehlp.hxx                     |  667 ++++++++++-------
 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx |   12 
 xmlsecurity/source/helper/documentsignaturemanager.cxx |    6 
 3 files changed, 422 insertions(+), 263 deletions(-)

New commits:
commit 7f671122df8760ca3cccb75c91c21b50d87ff47f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 20 17:07:26 2016 +0200

    xmlsecurity: show PDF signature right after adding it
    
    Also:
    
    - handle PDF in DocumentSignatureManager::write(), so the PDF file is
      not truncated when closing the document signatures dialog, and
    - handle PDF in DigitalSignaturesDialog::canAddRemove()
    
    Change-Id: I77c1fcdcbdcb079ce934f37546129d9d280e5d2e

diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index c82cff0..61789f6 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -244,8 +244,12 @@ void DigitalSignaturesDialog::SetSignatureStream( const css::uno::Reference < cs
 
 bool DigitalSignaturesDialog::canAddRemove()
 {
-    //m56
     bool ret = true;
+
+    if (!maSignatureManager.mxStore.is())
+        // It's always possible to append a PDF signature.
+        return ret;
+
     OSL_ASSERT(maSignatureManager.mxStore.is());
     bool bDoc1_1 = DocumentSignatureHelper::isODFPre_1_2(m_sODFVersion);
     SaveODFItem item;
@@ -357,7 +361,11 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
                 return;
             mbSignaturesChanged = true;
 
-            sal_Int32 nStatus = maSignatureManager.maSignatureHelper.GetSignatureInformation( nSecurityId ).nStatus;
+            sal_Int32 nStatus = xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
+
+            if (maSignatureManager.mxStore.is())
+                // In the PDF case the signature information is only available after parsing.
+                nStatus = maSignatureManager.maSignatureHelper.GetSignatureInformation( nSecurityId ).nStatus;
 
             if ( nStatus == css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED )
             {
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 05fbf3d..1db2319 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -385,6 +385,12 @@ void DocumentSignatureManager::read(bool bUseTempStream, bool bCacheLastSignatur
 
 void DocumentSignatureManager::write()
 {
+    if (!mxStore.is())
+    {
+        // Something not ZIP based, assume PDF, which is written directly in add() already.
+        return;
+    }
+
     // Export all other signatures...
     SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, false);
 
commit c48cd497b27dfe177256c96c510a72ecadd51ee8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Oct 20 17:01:50 2016 +0200

    Revert "Some clean-up"
    
    This reverts commit 0b04e8f80ea1b0ae0603d79b2c80d669f16375d3, shuffling the code
    around started to cause some builds to complain with -Werror=maybe-uninitialized
    in places where they did not before.  Needs a better fix.

diff --git a/include/cppuhelper/proptypehlp.hxx b/include/cppuhelper/proptypehlp.hxx
index 1e1c780..9f3dcf4 100644
--- a/include/cppuhelper/proptypehlp.hxx
+++ b/include/cppuhelper/proptypehlp.hxx
@@ -16,7 +16,6 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-
 #ifndef INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX
 #define INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX
 
@@ -27,6 +26,13 @@
 namespace cppu
 {
 
+/** Converts the value stored in an any to a concrete C++ type.
+    The function does the same as the operator >>= () at the
+    Any class, except that it throws an IllegalArgumentException in case of
+    failures (the value cannot be extracted without data loss )
+
+   @exception css::lang::IllegalArgumentException when the type could not be converted.
+ */
 template < class target >
 inline void SAL_CALL convertPropertyValue( target &value , const  css::uno::Any & a)
 {
@@ -36,54 +42,48 @@ inline void SAL_CALL convertPropertyValue( target &value , const  css::uno::Any
     }
 }
 
+
+/**
+  conversion of basic types
+*/
 inline void SAL_CALL convertPropertyValue( sal_Bool & b   , const css::uno::Any & a )
 {
-    if( !(a >>= b) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BYTE:
-            {
-                sal_Int8 i8 = 0;
-                a >>= i8;
-                b = i8 != 0;
-                break;
-            }
-        case css::uno::TypeClass_SHORT:
-            {
-                sal_Int16 i16 = 0;
-                a >>= i16;
-                b = i16 != 0;
-                break;
-            }
-        case css::uno::TypeClass_UNSIGNED_SHORT:
-            {
-                sal_uInt16 i16 = 0;
-                a >>= i16;
-                b = i16 != 0;
-                break;
-            }
-        case css::uno::TypeClass_LONG:
-            {
-                sal_Int32 i32 = 0;
-                a >>= i32;
-                b = i32 != 0;
-                break;
-            }
-        case css::uno::TypeClass_UNSIGNED_LONG:
-            {
-                sal_uInt32 i32 = 0;
-                a >>= i32;
-                b = i32 != 0;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c = *static_cast<sal_Unicode const *>(a.getValue());
-                b = c != 0;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if( css::uno::TypeClass_LONG == tc ) {
+        sal_Int32 i32 = 0;
+        a >>= i32;
+        b = i32 != 0;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c = *static_cast<sal_Unicode const *>(a.getValue());
+        b = c != 0;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16 = 0;
+        a >>= i16;
+        b = i16 != 0;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        a >>= b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8 = 0;
+        a >>= i8;
+        b = i8 != 0;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16 = 0;
+        a >>= i16;
+        b = i16 != 0;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        sal_uInt32 i32 = 0;
+        a >>= i32;
+        b = i32 != 0;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
@@ -95,266 +95,410 @@ void convertPropertyValue(bool & target, css::uno::Any const & source) {
 
 inline void SAL_CALL convertPropertyValue( sal_Int64 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_Int64 ) b;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                i = ( sal_Int64 ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if( css::uno::TypeClass_HYPER == tc ) {
+        a >>= i;
+    }
+    else if( css::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+        sal_uInt64 i64 = 0;
+        a >>= i64;
+        i = ( sal_Int64 ) i64;
+    }
+    else if( css::uno::TypeClass_LONG == tc ) {
+        sal_Int32 i32 = 0;
+        a >>= i32;
+        i = ( sal_Int64 )i32;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        i = ( sal_Int64 ) c;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16 = 0;
+        a >>= i16;
+        i = ( sal_Int64 ) i16;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_Int64 ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8 = 0;
+        a >>= i8;
+        i = ( sal_Int64 ) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16 = 0;
+        a >>= i16;
+        i = ( sal_Int64 ) i16;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        sal_uInt32 i32 = 0;
+        a >>= i32;
+        i = ( sal_Int64 ) i32;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
 
 inline void SAL_CALL convertPropertyValue( sal_uInt64 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_uInt64 ) b;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                i = ( sal_uInt64 ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if( css::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+        a >>= i;
+    }
+    if( css::uno::TypeClass_HYPER == tc ) {
+        sal_Int64 i64;
+        a >>= i64;
+        i = ( sal_uInt64 ) i64;
+    }
+    else if( css::uno::TypeClass_LONG == tc ) {
+        sal_Int32 i32;
+        a >>= i32;
+        i = ( sal_uInt64 )i32;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        i = ( sal_uInt64 ) c;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16;
+        a >>= i16;
+        i = ( sal_uInt64 ) i16;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_uInt64 ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8;
+        a >>= i8;
+        i = ( sal_uInt64 ) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16;
+        a >>= i16;
+        i = ( sal_uInt64    ) i16;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        sal_uInt32 i32;
+        a >>= i32;
+        i = ( sal_uInt64 ) i32;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
+// the basic types
+// sal_Int32
 inline void SAL_CALL convertPropertyValue( sal_Int32 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_Int32 ) b;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                i = ( sal_Int32 ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if( css::uno::TypeClass_LONG == tc ) {
+        a >>= i;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        i = ( sal_Int32 ) c;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16 = 0;
+        a >>= i16;
+        i = ( sal_Int32 ) i16;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_Int32 ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8 = 0;
+        a >>= i8;
+        i = ( sal_Int32 ) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16 = 0;
+        a >>= i16;
+        i = ( sal_Int32 ) i16;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        sal_uInt32 i32 = 0;
+        a >>= i32;
+        i = ( sal_Int32 ) i32;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
 inline void SAL_CALL convertPropertyValue( sal_uInt32 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_uInt32 ) b;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                i = ( sal_uInt32 ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        a >>= i;
+    }
+    else if( css::uno::TypeClass_LONG == tc ) {
+        sal_Int32 i32;
+        a >>= i32;
+        i = (sal_uInt32 ) i32;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        i = ( sal_uInt32 ) c;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16;
+        a >>= i16;
+        i = ( sal_uInt32 ) i16;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_uInt32 ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8;
+        a >>= i8;
+        i = ( sal_uInt32 ) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16;
+        a >>= i16;
+        i = ( sal_uInt32    ) i16;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
+
 inline void SAL_CALL convertPropertyValue( sal_Int16 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_Int16 ) b;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                i = ( sal_Int16 ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if ( css::uno::TypeClass_SHORT == tc ) {
+        a >>= i;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        i = ( sal_Int16 ) c;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_Int16 ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8 = 0;
+        a >>= i8;
+        i = ( sal_Int16 ) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16 = 0;
+        a >>= i16;
+        i = ( sal_Int16 ) i16;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
 inline void SAL_CALL convertPropertyValue( sal_uInt16 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_Int16 ) b;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                i = ( sal_Int16 ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        a >>= i;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        i = ( sal_Int16 ) c;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_Int16 ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8 = 0;
+        a >>= i8;
+        i = ( sal_Int16 ) i8;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16 = 0;
+        a >>= i16;
+        i = ( sal_Int16 ) i16;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
 inline void SAL_CALL convertPropertyValue( sal_Int8 & i  , const css::uno::Any & a )
 {
-    if( !(a >>= i) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                i = ( sal_Int8 ) b;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if ( css::uno::TypeClass_BYTE == tc ) {
+        a >>= i;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        i = ( sal_Int8 ) b;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
 inline void SAL_CALL convertPropertyValue( float &f , const css::uno::Any &a )
 {
-    if( !(a >>= f) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                f = ( float ) b;
-                break;
-            }
-        case css::uno::TypeClass_LONG:
-            {
-                sal_Int32 i32 = 0;
-                a >>= i32;
-                f = ( float )i32;
-                break;
-            }
-        case css::uno::TypeClass_UNSIGNED_LONG:
-            {
-                sal_uInt32 i32 = 0;
-                a >>= i32;
-                f = ( float ) i32;
-                break;
-            }
-        case css::uno::TypeClass_HYPER:
-            {
-                sal_Int64 i64 = 0;
-                a >>= i64;
-                f = ( float ) i64;
-                break;
-            }
-        case css::uno::TypeClass_UNSIGNED_HYPER:
-            {
-                sal_uInt64 i64 = 0;
-                a >>= i64;
-                f = ( float ) i64;
-                break;
-            }
-        case css::uno::TypeClass_DOUBLE:
-            {
-                double d = 0;
-                a >>= d;
-                f = ( float ) d;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                f = ( float ) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if ( css::uno::TypeClass_FLOAT == tc ) {
+        a >>= f;
+    }
+    else if( css::uno::TypeClass_DOUBLE == tc ) {
+         double d = 0;
+         a >>= d;
+         f = ( float ) d;
+    }
+    else if( css::uno::TypeClass_HYPER == tc ) {
+        sal_Int64 i64 = 0;
+        a >>= i64;
+        f = ( float ) i64;
+    }
+    else if( css::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+        sal_uInt64 i64 = 0;
+        a >>= i64;
+        f = ( float ) i64;
+    }
+    else if( css::uno::TypeClass_LONG == tc ) {
+        sal_Int32 i32 = 0;
+        a >>= i32;
+        f = ( float )i32;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        f = ( float ) c;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16 = 0;
+        a >>= i16;
+        f = ( float ) i16;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        f = ( float ) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8 = 0;
+        a >>= i8;
+        f = ( float ) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16 = 0;
+        a >>= i16;
+        f = ( float ) i16;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        sal_uInt32 i32 = 0;
+        a >>= i32;
+        f = ( float ) i32;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
+
 inline void SAL_CALL convertPropertyValue( double &d , const css::uno::Any &a )
 {
-    if( !(a >>= d) ) {
-        switch( a.getValueType().getTypeClass() ) {
-        case css::uno::TypeClass_BOOLEAN:
-            {
-                bool b;
-                a >>= b;
-                d = (double) b;
-                break;
-            }
-        case css::uno::TypeClass_HYPER:
-            {
-                sal_Int64 i64;
-                a >>= i64;
-                d = (double) i64;
-                break;
-            }
-        case css::uno::TypeClass_UNSIGNED_HYPER:
-            {
-                sal_uInt64 i64 = 0;
-                a >>= i64;
-                d = (double) i64;
-                break;
-            }
-        case css::uno::TypeClass_CHAR:
-            {
-                sal_Unicode c;
-                c = *static_cast<sal_Unicode const *>(a.getValue());
-                d = (double) c;
-                break;
-            }
-        default:
-            throw css::lang::IllegalArgumentException();
-        }
+    const enum css::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+    if( css::uno::TypeClass_DOUBLE == tc ) {
+         float f;
+         a >>= f;
+         d = ( double ) f;
+    }
+    else if ( css::uno::TypeClass_FLOAT == tc ) {
+        float f;
+        a >>= f;
+        d = (double) f;
+    }
+    else if( css::uno::TypeClass_HYPER == tc ) {
+        sal_Int64 i64;
+        a >>= i64;
+        d = (double) i64;
+    }
+    else if( css::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+        sal_uInt64 i64 = 0;
+        a >>= i64;
+        d = (double) i64;
+    }
+    else if( css::uno::TypeClass_LONG == tc ) {
+        sal_Int32 i32;
+        a >>= i32;
+        d = (double)i32;
+    }
+    else if ( css::uno::TypeClass_CHAR  == tc ) {
+        sal_Unicode c;
+        c = *static_cast<sal_Unicode const *>(a.getValue());
+        d = (double) c;
+    }
+    else if ( css::uno::TypeClass_SHORT == tc ) {
+        sal_Int16 i16;
+        a >>= i16;
+        d = (double) i16;
+    }
+    else if ( css::uno::TypeClass_BOOLEAN == tc ) {
+        bool b;
+        a >>= b;
+        d = (double) b;
+    }
+    else if ( css::uno::TypeClass_BYTE == tc ) {
+        sal_Int8 i8;
+        a >>= i8;
+        d = (double) i8;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+        sal_uInt16 i16;
+        a >>= i16;
+        d = (double) i16;
+    }
+    else if ( css::uno::TypeClass_UNSIGNED_LONG == tc ) {
+        sal_uInt32 i32;
+        a >>= i32;
+        d = (double) i32;
+    }
+    else {
+        throw css::lang::IllegalArgumentException();
     }
 }
 
 inline void SAL_CALL convertPropertyValue( ::rtl::OUString &ow , const css::uno::Any &a )
 {
-    if( !(a >>= ow) ) {
+    if( css::uno::TypeClass_STRING == a.getValueType().getTypeClass() ) {
+        a >>= ow;
+    }
+    else {
         throw css::lang::IllegalArgumentException();
     }
 }
@@ -363,4 +507,5 @@ inline void SAL_CALL convertPropertyValue( ::rtl::OUString &ow , const css::uno:
 
 #endif
 
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list