[Libreoffice-commits] core.git: basic/source canvas/source dbaccess/source extensions/source include/com include/comphelper oox/source package/source pyuno/source reportdesign/source sc/source sd/source sw/source vbahelper/source writerfilter/source

Stephan Bergmann sbergman at redhat.com
Wed Apr 8 08:48:09 PDT 2015


 basic/source/classes/sbxmod.cxx                      |    2 +-
 canvas/source/tools/canvastools.cxx                  |    2 +-
 dbaccess/source/ui/tabledesign/FieldDescriptions.cxx |    4 ++--
 extensions/source/propctrlr/formgeometryhandler.cxx  |    4 ++--
 include/com/sun/star/uno/Any.h                       |   13 +++++++++++++
 include/com/sun/star/uno/Any.hxx                     |    4 ++++
 include/comphelper/sequence.hxx                      |    3 +--
 include/comphelper/sequenceashashmap.hxx             |    2 +-
 oox/source/helper/propertymap.cxx                    |    2 +-
 package/source/zippackage/ZipPackage.cxx             |    2 +-
 pyuno/source/module/pyuno.cxx                        |    4 ++--
 reportdesign/source/core/api/ReportDefinition.cxx    |    4 ++--
 sc/source/ui/vba/vbainterior.cxx                     |    2 +-
 sc/source/ui/vba/vbaworksheet.cxx                    |    2 +-
 sd/source/ui/animations/CustomAnimationDialog.cxx    |    4 ++--
 sd/source/ui/animations/CustomAnimationPane.cxx      |    2 +-
 sw/source/core/unocore/unotbl.cxx                    |    2 +-
 vbahelper/source/msforms/vbamultipage.cxx            |    2 +-
 vbahelper/source/msforms/vbauserform.cxx             |    2 +-
 vbahelper/source/vbahelper/vbaapplicationbase.cxx    |    2 +-
 writerfilter/source/dmapper/DomainMapper.cxx         |    4 ++--
 21 files changed, 42 insertions(+), 26 deletions(-)

New commits:
commit 9222f5d065bb2aafcfef93e77c58a82672a9ad22
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Apr 8 17:45:08 2015 +0200

    A UNO Any can't contain an Any
    
    ...and css::uno::makeAny<css::uno::Any>() was never meant to be used.  Introduce
    css::uno::toAny for the (template-code) cases that shall return an Any for both
    Any and non-Any inputs.
    
    Change-Id: Ifa977d73f1da71b2fedde7e8140b19497c4a0257

diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index cbeac3c..c2b0e79 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -2206,7 +2206,7 @@ SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException
     SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxVariable*)pDocObject);
     if ( pUnoObj && pUnoObj->getUnoAny() == aObj ) // object is equal, nothing to do
         return;
-    pDocObject = new SbUnoObject( GetName(), uno::makeAny( aObj ) );
+    pDocObject = new SbUnoObject( GetName(), aObj );
 
     com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObj, com::sun::star::uno::UNO_QUERY_THROW );
     if( xServiceInfo->supportsService( "ooo.vba.excel.Worksheet" ) )
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index 7b3ae29..7db3572 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -1167,7 +1167,7 @@ namespace canvas
                     o_rxParams.realloc( 2 );
 
                     o_rxParams[ 0 ] = uno::makeAny( xServiceInfo->getImplementationName() );
-                    o_rxParams[ 1 ] = uno::makeAny( xPropSet->getPropertyValue( "DeviceHandle" ) );
+                    o_rxParams[ 1 ] = xPropSet->getPropertyValue( "DeviceHandle" );
                 }
                 catch( const uno::Exception& )
                 {
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
index b23f85e..159f0fb 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -286,7 +286,7 @@ void OFieldDescription::SetDefaultValue(const Any& _rDefaultValue)
     try
     {
         if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
-            m_xDest->setPropertyValue(PROPERTY_DEFAULTVALUE,makeAny(_rDefaultValue));
+            m_xDest->setPropertyValue(PROPERTY_DEFAULTVALUE, _rDefaultValue);
         else
             m_aDefaultValue = _rDefaultValue;
     }
@@ -301,7 +301,7 @@ void OFieldDescription::SetControlDefault(const Any& _rControlDefault)
     try
     {
         if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
-            m_xDest->setPropertyValue(PROPERTY_CONTROLDEFAULT,makeAny(_rControlDefault));
+            m_xDest->setPropertyValue(PROPERTY_CONTROLDEFAULT, _rControlDefault);
         else
             m_aControlDefault = _rControlDefault;
     }
diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx
index 6e16c37..0196d3f 100644
--- a/extensions/source/propctrlr/formgeometryhandler.cxx
+++ b/extensions/source/propctrlr/formgeometryhandler.cxx
@@ -744,11 +744,11 @@ namespace pcr
         }
         else if ( _event.PropertyName == PROPERTY_ANCHOR_TYPE )
         {
-            aEventTranslations.push_back( EventTranslation( PROPERTY_TEXT_ANCHOR_TYPE, makeAny( _event.NewValue ) ) );
+            aEventTranslations.push_back( EventTranslation( PROPERTY_TEXT_ANCHOR_TYPE, _event.NewValue ) );
         }
         else if ( _event.PropertyName == PROPERTY_ANCHOR )
         {
-            aEventTranslations.push_back( EventTranslation( PROPERTY_SHEET_ANCHOR_TYPE, makeAny( _event.NewValue ) ) );
+            aEventTranslations.push_back( EventTranslation( PROPERTY_SHEET_ANCHOR_TYPE, _event.NewValue ) );
         }
 
         PropertyChangeEvent aTranslatedEvent( _event );
diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h
index 3ab2a44..1354740 100644
--- a/include/com/sun/star/uno/Any.h
+++ b/include/com/sun/star/uno/Any.h
@@ -260,6 +260,19 @@ inline Any SAL_CALL makeAny( const C & value );
 template<>
 inline Any SAL_CALL makeAny( bool const & value );
 
+template<> Any SAL_CALL makeAny(Any const &) SAL_DELETED_FUNCTION;
+
+/** Wrap a value in an Any, if necessary.
+
+    The difference to makeAny is that makeAny cannot be called on an Any, while
+    toAny just returns the given Any.
+
+    @since LibreOffice 4.5
+*/
+template<typename T> inline Any toAny(T const & value);
+
+template<> inline Any toAny(Any const & value);
+
 class BaseReference;
 
 /** Template binary <<= operator to set the value of an any.
diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
index 2b314e9..f4b4db9 100644
--- a/include/com/sun/star/uno/Any.hxx
+++ b/include/com/sun/star/uno/Any.hxx
@@ -204,6 +204,10 @@ inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value )
 }
 #endif
 
+template<typename T> Any toAny(T const & value) { return makeAny(value); }
+
+template<> Any toAny(Any const & value) { return value; }
+
 template< class C >
 inline void SAL_CALL operator <<= ( Any & rAny, const C & value )
 {
diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index f09ff1c..fcaab6b 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -198,10 +198,9 @@ namespace comphelper
     template <class TYPE>
     inline ::com::sun::star::uno::Any OSequenceIterator<TYPE>::nextElement()
     {
-        return ::com::sun::star::uno::makeAny(*m_pCurrent++);
+        return ::com::sun::star::uno::toAny(*m_pCurrent++);
     }
 
-
     /** Copy from a plain C/C++ array into a Sequence.
 
         @tpl SrcType
diff --git a/include/comphelper/sequenceashashmap.hxx b/include/comphelper/sequenceashashmap.hxx
index 801d2d1..32e67b7 100644
--- a/include/comphelper/sequenceashashmap.hxx
+++ b/include/comphelper/sequenceashashmap.hxx
@@ -265,7 +265,7 @@ class COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAsHashMapBase
         {
             if (find(sKey) == end())
             {
-                (*this)[sKey] = ::com::sun::star::uno::makeAny(aValue);
+                (*this)[sKey] = ::com::sun::star::uno::toAny(aValue);
                 return true;
             }
 
diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx
index 792de08..9db0e09 100644
--- a/oox/source/helper/propertymap.cxx
+++ b/oox/source/helper/propertymap.cxx
@@ -670,7 +670,7 @@ static const char* lclDumpAnyValueCode( Any value, int level = 0)
         for( int i=0; i<adjArray.getLength(); i++ ) {
             printLevel (level);
             fprintf (stderr, "{\n");
-            const char *var = lclDumpAnyValueCode( makeAny (adjArray[i].Value), level + 1 );
+            const char *var = lclDumpAnyValueCode( adjArray[i].Value, level + 1 );
             printLevel (level + 1);
             fprintf (stderr, "aAdjSequence [%d].Value = %s;\n", i, var);
             if (adjArray[i].Name.getLength() > 0) {
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 15d5f94..ca47523 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -950,7 +950,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
         uno::Any e(::cppu::getCaughtException());
         throw lang::WrappedTargetRuntimeException(
             OUString("ZipPackage::hasByHierarchicalName"),
-            0, uno::makeAny(e));
+            0, e);
     }
     return sal_False;
 }
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 3ec1316..7020004 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -513,7 +513,7 @@ PyObject* PyUNO_getattr (PyObject* self, char* name)
     }
     catch( const com::sun::star::reflection::InvocationTargetException & e )
     {
-        raisePyExceptionWithAny( makeAny(e.TargetException) );
+        raisePyExceptionWithAny( e.TargetException );
     }
     catch( const com::sun::star::beans::UnknownPropertyException & e )
     {
@@ -557,7 +557,7 @@ int PyUNO_setattr (PyObject* self, char* name, PyObject* value)
     }
     catch( const com::sun::star::reflection::InvocationTargetException & e )
     {
-        raisePyExceptionWithAny( makeAny(e.TargetException) );
+        raisePyExceptionWithAny( e.TargetException );
         return 1;
     }
     catch( const com::sun::star::beans::UnknownPropertyException & e )
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index a0013a31..6dd1419 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -2351,7 +2351,7 @@ uno::Any SAL_CALL OStylesHelper::getByIndex( sal_Int32 Index ) throw(lang::Index
     ::osl::MutexGuard aGuard(m_aMutex);
     if ( Index < 0 || Index >= static_cast<sal_Int32>(m_aElementsPos.size()) )
         throw lang::IndexOutOfBoundsException();
-    return uno::makeAny(m_aElementsPos[Index]->second);
+    return m_aElementsPos[Index]->second;
 }
 
 // container::XNameAccess
@@ -2361,7 +2361,7 @@ uno::Any SAL_CALL OStylesHelper::getByName( const OUString& aName ) throw(contai
     TStyleElements::iterator aFind = m_aElements.find(aName);
     if ( aFind == m_aElements.end() )
         throw container::NoSuchElementException();
-    return uno::makeAny(aFind->second);
+    return aFind->second;
 }
 
 uno::Sequence< OUString > SAL_CALL OStylesHelper::getElementNames(  ) throw(uno::RuntimeException, std::exception)
diff --git a/sc/source/ui/vba/vbainterior.cxx b/sc/source/ui/vba/vbainterior.cxx
index 1d0d322..8647f95 100644
--- a/sc/source/ui/vba/vbainterior.cxx
+++ b/sc/source/ui/vba/vbainterior.cxx
@@ -366,7 +366,7 @@ ScVbaInterior::getPatternColorIndex() throw (uno::RuntimeException, std::excepti
     sal_Int32 nColor = 0;
     XLRGBToOORGB( getPatternColor() ) >>= nColor;
 
-    return uno::makeAny( GetIndexColor( nColor ) );
+    return GetIndexColor( nColor );
 }
 void SAL_CALL
 ScVbaInterior::setPatternColorIndex( const uno::Any& _patterncolorindex ) throw (uno::RuntimeException, std::exception)
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 49b8c7f..d60e10a 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -934,7 +934,7 @@ ScVbaWorksheet::invoke( const OUString& aFunctionName, const uno::Sequence< uno:
 void SAL_CALL
 ScVbaWorksheet::setValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException, std::exception)
 {
-    setDefaultPropByIntrospection( uno::makeAny( getValue( aPropertyName ) ), aValue );
+    setDefaultPropByIntrospection( getValue( aPropertyName ), aValue );
 }
 uno::Any SAL_CALL
 ScVbaWorksheet::getValue( const OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx
index 97f9559..7ad5e3f 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.cxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.cxx
@@ -1370,12 +1370,12 @@ void CustomAnimationEffectTabPage::update( STLPropertySet* pSet )
             if ( mpCLBDimColor->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
                 aSelectedColor = mpCLBDimColor->GetSelectEntryColor();
 
-            aDimColor = makeAny( makeAny( (sal_Int32)aSelectedColor.GetRGBColor() ) );
+            aDimColor = makeAny( (sal_Int32)aSelectedColor.GetRGBColor() );
         }
 
         if( (mpSet->getPropertyState( nHandleDimColor ) == STLPropertyState_AMBIGUOUS) ||
             (mpSet->getPropertyValue( nHandleDimColor ) != aDimColor) )
-            pSet->setPropertyValue( nHandleDimColor, makeAny( aDimColor ) );
+            pSet->setPropertyValue( nHandleDimColor, aDimColor );
 
         bool bAfterEffectOnNextEffect = nPos != 2 ? sal_True : sal_False;
         bool bOldAfterEffectOnNextEffect = !bAfterEffectOnNextEffect;
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index b7087f9..f327dc9 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -1068,7 +1068,7 @@ STLPropertySet* CustomAnimationPane::createSelectionSet()
         addValue( pSet, nHandleBegin, makeAny( pEffect->getBegin() ) );
         addValue( pSet, nHandleDuration, makeAny( pEffect->getDuration() ) );
         addValue( pSet, nHandleStart, makeAny( pEffect->getNodeType() ) );
-        addValue( pSet, nHandleRepeat, makeAny( pEffect->getRepeatCount() ) );
+        addValue( pSet, nHandleRepeat, pEffect->getRepeatCount() );
         addValue( pSet, nHandleEnd, pEffect->getEnd() );
         addValue( pSet, nHandleRewind, makeAny( pEffect->getFill() ) );
 
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index b1fff82..59a4428 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1154,7 +1154,7 @@ uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
         case FN_UNO_REDLINE_NODE_END:
         {
             //redline can only be returned if it's a living object
-            return makeAny(SwXText::getPropertyValue(rPropertyName));
+            return SwXText::getPropertyValue(rPropertyName);
         }
         break;
         default:
diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx
index 4fa287e..2fb7016 100644
--- a/vbahelper/source/msforms/vbamultipage.cxx
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -102,7 +102,7 @@ ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException, std
     uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( xContainer->getElementNames().getLength() ) ) );
     if ( !index.hasValue() )
         return uno::makeAny( xColl );
-    return xColl->Item( uno::makeAny( index ), uno::Any() );
+    return xColl->Item( index, uno::Any() );
 }
 
 uno::Sequence< OUString >
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index 23bbd23..8b6fe02 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -285,7 +285,7 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException, s
     uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY );
     uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ) );
     if ( index.hasValue() )
-        return uno::makeAny( xControls->Item( index, uno::Any() ) );
+        return xControls->Item( index, uno::Any() );
     return uno::makeAny( xControls );
 }
 
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 589c029..57f6268 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -293,7 +293,7 @@ VbaApplicationBase::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeExc
 {
     uno::Reference< XCommandBars > xCommandBars( new ScVbaCommandBars( this, mxContext, uno::Reference< container::XIndexAccess >(), getCurrentDocument() ) );
     if( aIndex.hasValue() )
-        return uno::makeAny( xCommandBars->Item( aIndex, uno::Any() ) );
+        return xCommandBars->Item( aIndex, uno::Any() );
     return uno::makeAny( xCommandBars );
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index b64e216..32528c5 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2519,7 +2519,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
         resolveSprmProps(*this, rSprm);
 
         TablePropertyMapPtr pPropMap(new TablePropertyMap());
-        pPropMap->Insert(PROP_ROW_CNF_STYLE, uno::makeAny(uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag))), true, ROW_GRAB_BAG);
+        pPropMap->Insert(PROP_ROW_CNF_STYLE, uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag)), true, ROW_GRAB_BAG);
         m_pImpl->getTableManager().insertRowProps(pPropMap);
 
         m_pImpl->disableInteropGrabBag();
@@ -2531,7 +2531,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
         resolveSprmProps(*this, rSprm);
 
         TablePropertyMapPtr pPropMap(new TablePropertyMap());
-        pPropMap->Insert(PROP_CELL_CNF_STYLE, uno::makeAny(uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag))), true, CELL_GRAB_BAG);
+        pPropMap->Insert(PROP_CELL_CNF_STYLE, uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag)), true, CELL_GRAB_BAG);
         m_pImpl->getTableManager().cellProps(pPropMap);
 
         m_pImpl->disableInteropGrabBag();


More information about the Libreoffice-commits mailing list