[Libreoffice-commits] core.git: 6 commits - comphelper/source filter/source forms/source include/comphelper oox/source sc/source

Stephan Bergmann sbergman at redhat.com
Wed Aug 19 05:49:02 PDT 2015


 comphelper/source/misc/types.cxx          |   32 ++++++++-----------------
 filter/source/msfilter/escherex.cxx       |    6 ++--
 forms/source/component/FormattedField.cxx |    6 ++--
 forms/source/component/clickableimage.cxx |    2 -
 include/comphelper/types.hxx              |   37 ------------------------------
 oox/source/export/drawingml.cxx           |    4 +--
 sc/source/filter/oox/worksheetbuffer.cxx  |    2 -
 7 files changed, 20 insertions(+), 69 deletions(-)

New commits:
commit a8d3a1048f414424018f98a1c03cccc42d57bcae
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 19 14:29:45 2015 +0200

    loplugin:literaltoboolconversion
    
    Change-Id: Iad48cf4949cb4a398a8abee32febaf8e152dade5

diff --git a/sc/source/filter/oox/worksheetbuffer.cxx b/sc/source/filter/oox/worksheetbuffer.cxx
index e55ea42..00d789c 100644
--- a/sc/source/filter/oox/worksheetbuffer.cxx
+++ b/sc/source/filter/oox/worksheetbuffer.cxx
@@ -233,7 +233,7 @@ void WorksheetBuffer::finalizeImport( sal_Int16 nActiveSheet )
         if ( aSheetInfo->mnCalcSheet == nActiveSheet)
             rDoc.SetVisible( aSheetInfo->mnCalcSheet, true );
         else
-            rDoc.SetVisible( aSheetInfo->mnCalcSheet, (aSheetInfo->mnState == XML_visible) ? 1 : 0 );
+            rDoc.SetVisible( aSheetInfo->mnCalcSheet, aSheetInfo->mnState == XML_visible );
     }
 }
 
commit ef1556416adb5ee88b9560e430281e7ce480da32
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 19 14:05:24 2015 +0200

    Avoid css::uno::Sequence<sal_uInt8> (which is not a proper UNO type)
    
    Change-Id: I887c358161f7ac4032b9ad9166ff16aa0b19eaa1

diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 5d01ec6..eb13752 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -1447,8 +1447,8 @@ bool EscherPropertyContainer::CreateGraphicProperties(
         sal_uInt16 nAngle = 0;
         if ( rSource == "MetaFile" )
         {
-            ::com::sun::star::uno::Sequence<sal_uInt8> aSeq = *static_cast<css::uno::Sequence<sal_uInt8> const *>(aAny.getValue());
-            const sal_uInt8*    pAry = aSeq.getArray();
+            ::com::sun::star::uno::Sequence<sal_Int8> aSeq = *static_cast<css::uno::Sequence<sal_Int8> const *>(aAny.getValue());
+            const sal_Int8*    pAry = aSeq.getArray();
             sal_uInt32          nAryLen = aSeq.getLength();
 
             // the metafile is already rotated
@@ -1457,7 +1457,7 @@ bool EscherPropertyContainer::CreateGraphicProperties(
             if ( pAry && nAryLen )
             {
                 Graphic         aGraphic;
-                SvMemoryStream  aTemp( const_cast<sal_uInt8 *>(pAry), nAryLen, StreamMode::READ );
+                SvMemoryStream  aTemp( const_cast<sal_Int8 *>(pAry), nAryLen, StreamMode::READ );
                 sal_uInt32 nErrCode = GraphicConverter::Import( aTemp, aGraphic, ConvertDataFormat::WMF );
                 if ( nErrCode == ERRCODE_NONE )
                 {
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index fc48fae..52dc142e 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1477,9 +1477,9 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su
 
 void DrawingML::GetUUID( OStringBuffer& rBuffer )
 {
-    Sequence< sal_uInt8 > aSeq( 16 );
+    sal_uInt8 aSeq[16];
     static const char cDigits[17] = "0123456789ABCDEF";
-    rtl_createUuid( aSeq.getArray(), 0, true );
+    rtl_createUuid( aSeq, 0, true );
     int i;
 
     rBuffer.append( '{' );
commit 63de6ba249a0e4349b66442821ad73aff71f25d8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 19 14:04:47 2015 +0200

    There is no css::uno::Sequence<sal_uInt8> in UNO
    
    Change-Id: Ibf5095fea20314180a4e002295c89f570d66d45f

diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx
index 06afb83..025000d 100644
--- a/comphelper/source/misc/types.cxx
+++ b/comphelper/source/misc/types.cxx
@@ -333,18 +333,6 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()) == 0;
                     }
                 }
-                else if (_rType == cppu::UnoType<Sequence<sal_uInt8>>::get())
-                {
-                    Sequence<sal_uInt8> aTemp;
-                    bConversionSuccess = _rValue >>= aTemp;
-                    if (bConversionSuccess)
-                    {
-                        const Sequence<sal_uInt8>& rLeftSeq = *static_cast<const Sequence<sal_uInt8>*>(pData);
-                        const Sequence<sal_uInt8>& rRightSeq = aTemp;
-                        bRes = rLeftSeq.getLength() == rRightSeq.getLength() &&
-                            memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()) == 0;
-                    }
-                }
                 else if (_rType == cppu::UnoType<Sequence<sal_Int16>>::get())
                 {
                     Sequence<sal_Int16> aTemp;
commit 39ce314c12e3570c074475c7809c3b37b2241c41
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 19 13:53:34 2015 +0200

    comphelper::isA(Type... -> Type == cppu::UnoType...
    
    Change-Id: I1bfb99b1715a907a03af5a30df6c7a41f91fd2fb

diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx
index e81a813..06afb83 100644
--- a/comphelper/source/misc/types.cxx
+++ b/comphelper/source/misc/types.cxx
@@ -289,7 +289,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                 break;
             }
             case TypeClass_STRUCT:
-                if (isA(_rType, static_cast<FontDescriptor*>(NULL)))
+                if (_rType == cppu::UnoType<FontDescriptor>::get())
                 {
                     FontDescriptor aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -301,19 +301,19 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                         bRes = false;
                     break;
                 }
-                if (isA(_rType, static_cast<Date*>(NULL)))
+                if (_rType == cppu::UnoType<Date>::get())
                 {
                     Date aDummy;
                     bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
                     break;
                 }
-                if (isA(_rType, static_cast<Time*>(NULL)))
+                if (_rType == cppu::UnoType<Time>::get())
                 {
                     Time aDummy;
                     bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
                     break;
                 }
-                if (isA(_rType, static_cast<DateTime*>(NULL)))
+                if (_rType == cppu::UnoType<DateTime>::get())
                 {
                     DateTime aDummy;
                     bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
@@ -321,7 +321,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                 }
                 break;
             case TypeClass_SEQUENCE:
-                if (isA(_rType, static_cast< Sequence<sal_Int8>* >(NULL)))
+                if (_rType == cppu::UnoType<Sequence<sal_Int8>>::get())
                 {
                     Sequence<sal_Int8> aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -333,7 +333,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()) == 0;
                     }
                 }
-                else if (isA(_rType, static_cast< Sequence<sal_uInt8>* >(NULL)))
+                else if (_rType == cppu::UnoType<Sequence<sal_uInt8>>::get())
                 {
                     Sequence<sal_uInt8> aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -345,7 +345,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()) == 0;
                     }
                 }
-                else if (isA(_rType, static_cast< Sequence<sal_Int16>* >(NULL)))
+                else if (_rType == cppu::UnoType<Sequence<sal_Int16>>::get())
                 {
                     Sequence<sal_Int16> aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -357,7 +357,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_Int16)) == 0;
                     }
                 }
-                else if (isA(_rType, static_cast< Sequence<sal_uInt16>* >(NULL)))
+                else if (_rType == cppu::UnoType<cppu::UnoSequenceType<cppu::UnoUnsignedShortType>>::get())
                 {
                     Sequence<sal_uInt16> aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -369,7 +369,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_uInt16)) == 0;
                     }
                 }
-                else if (isA(_rType, static_cast< Sequence<sal_Int32>* >(NULL)))
+                else if (_rType == cppu::UnoType<Sequence<sal_Int32>>::get())
                 {
                     Sequence<sal_Int32> aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -381,7 +381,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_Int32)) == 0;
                     }
                 }
-                else if (isA(_rType, static_cast< Sequence<sal_uInt32>* >(NULL)))
+                else if (_rType == cppu::UnoType<Sequence<sal_uInt32>>::get())
                 {
                     Sequence<sal_uInt32> aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
@@ -393,7 +393,7 @@ bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
                             memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_uInt32)) == 0;
                     }
                 }
-                else if (isA(_rType, static_cast< Sequence< OUString >* >(NULL)))
+                else if (_rType == cppu::UnoType<Sequence<OUString>>::get())
                 {
                     Sequence< OUString > aTemp;
                     bConversionSuccess = _rValue >>= aTemp;
diff --git a/include/comphelper/types.hxx b/include/comphelper/types.hxx
index 142cee9..0e506f3 100644
--- a/include/comphelper/types.hxx
+++ b/include/comphelper/types.hxx
@@ -55,20 +55,6 @@ namespace comphelper
     /// returns sal_True if objects of the types given are "compatible"
     COMPHELPER_DLLPUBLIC bool isAssignableFrom(const css::uno::Type& _rAssignable, const css::uno::Type& _rFrom);
 
-
-    /** just a small shortcut ...
-        check if a type you have at hand at runtime is equal to another type you have at compile time
-        if all our compiler would accept function calls with explicit template arguments (like
-        isA<classFoo>(runtimeType)), we wouldn't need the second parameter. But unfortunately at
-        least the current solaris compiler doesn't allow this ....
-        So this function is nearly senseless ....
-    */
-    template <class TYPE>
-    bool isA(const css::uno::Type& _rType, TYPE* pDummy)
-    {
-        return  _rType.equals(cppu::getTypeFavourUnsigned(pDummy));
-    }
-
     /** ask the given object for an XComponent interface and dispose on it
     */
     template <class TYPE>
commit 884e970b8c5b56b640eac1120522f77aac0eae60
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 19 13:45:59 2015 +0200

    Remove unused comphelper::isAReference
    
    Change-Id: I7033e1e60f67e93a31d19ea08513982643dd61ae

diff --git a/include/comphelper/types.hxx b/include/comphelper/types.hxx
index 5611446..142cee9 100644
--- a/include/comphelper/types.hxx
+++ b/include/comphelper/types.hxx
@@ -69,17 +69,6 @@ namespace comphelper
         return  _rType.equals(cppu::getTypeFavourUnsigned(pDummy));
     }
 
-    /** check if a type you have at hand at runtime is equal to another type you have at compile time
-    */
-    template <class TYPE>
-    bool isAReference(const css::uno::Any& _rVal, TYPE*)
-    {
-        return  _rVal.getValueType().equals(
-            cppu::getTypeFavourUnsigned(
-                static_cast<css::uno::Reference<TYPE>*>(NULL)));
-    }
-
-
     /** ask the given object for an XComponent interface and dispose on it
     */
     template <class TYPE>
commit d0f18382c59a54fcbbe8419b43e264a0c48fa6ec
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 19 13:45:01 2015 +0200

    comphelper::isA(Any... -> Any::has
    
    Change-Id: I4fdc77c6fde93d9d1ee814f7614a1c4c81e18247

diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx
index 5a91466..036605d 100644
--- a/forms/source/component/FormattedField.cxx
+++ b/forms/source/component/FormattedField.cxx
@@ -208,7 +208,7 @@ void OFormattedControl::keyPressed(const ::com::sun::star::awt::KeyEvent& e) thr
     if( !xFormSet.is() )
         return;
     Any aTmp(xFormSet->getPropertyValue( PROPERTY_TARGET_URL ));
-    if (!isA(aTmp, static_cast< OUString* >(NULL)) ||
+    if (!aTmp.has<OUString>() ||
         getString(aTmp).isEmpty() )
         return;
     Reference<XIndexAccess>  xElements(xParent, UNO_QUERY);
@@ -690,8 +690,8 @@ void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
         if (hasProperty(s_aLocaleProp, xFormat))
         {
             Any aLocale = xFormat->getPropertyValue(s_aLocaleProp);
-            DBG_ASSERT(isA(aLocale, static_cast<Locale*>(NULL)), "OFormattedModel::write : invalid language property !");
-            if (isA(aLocale, static_cast<Locale*>(NULL)))
+            DBG_ASSERT(aLocale.has<Locale>(), "OFormattedModel::write : invalid language property !");
+            if (aLocale.has<Locale>())
             {
                 Locale const * pLocale = static_cast<Locale const *>(aLocale.getValue());
                 eFormatLanguage = LanguageTag::convertToLanguageType( *pLocale, false);
diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx
index 0001bf6..7490d39 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -628,7 +628,7 @@ namespace frm
         switch (nHandle)
         {
             case PROPERTY_ID_BUTTONTYPE :
-                DBG_ASSERT(isA(rValue, static_cast<FormButtonType*>(NULL)), "OClickableImageBaseModel::setFastPropertyValue_NoBroadcast : invalid type !" );
+                DBG_ASSERT(rValue.has<FormButtonType>(), "OClickableImageBaseModel::setFastPropertyValue_NoBroadcast : invalid type !" );
                 rValue >>= m_eButtonType;
                 break;
 
diff --git a/include/comphelper/types.hxx b/include/comphelper/types.hxx
index feeb522..5611446 100644
--- a/include/comphelper/types.hxx
+++ b/include/comphelper/types.hxx
@@ -69,18 +69,6 @@ namespace comphelper
         return  _rType.equals(cppu::getTypeFavourUnsigned(pDummy));
     }
 
-
-    /** check if a type you have at hand at runtime is equal to another type you have at compile time
-        same comment as for the other isA ....
-    */
-    template <class TYPE>
-    bool isA(const css::uno::Any& _rVal, TYPE* pDummy)
-    {
-        return  _rVal.getValueType().equals(
-            cppu::getTypeFavourUnsigned(pDummy));
-    }
-
-
     /** check if a type you have at hand at runtime is equal to another type you have at compile time
     */
     template <class TYPE>


More information about the Libreoffice-commits mailing list