From 58a32075ca4f457f570af75aef368dd6c389aca7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 3 May 2016 08:39:03 +0200 Subject: use Any constructor instead of temporaries Change-Id: Iffb82a2cee1a28d89eeea2b905aaa14086ee475a --- sc/source/core/data/dpobject.cxx | 12 ++----- sc/source/core/data/dpsave.cxx | 22 ++++--------- sc/source/filter/excel/xiescher.cxx | 11 ++----- sc/source/ui/Accessibility/AccessibleCellBase.cxx | 10 ++---- .../Accessibility/AccessiblePreviewHeaderCell.cxx | 12 ++----- sc/source/ui/app/scmod.cxx | 4 +-- sc/source/ui/docshell/dbdocimp.cxx | 10 ++---- sc/source/ui/docshell/docsh8.cxx | 38 +++++++--------------- sc/source/ui/drawfunc/drawsh5.cxx | 13 +++----- sc/source/ui/unoobj/condformatuno.cxx | 4 +-- sc/source/ui/unoobj/linkuno.cxx | 20 +++--------- sc/source/ui/view/tabvwshg.cxx | 16 +++------ sc/source/ui/view/viewdata.cxx | 4 +-- 13 files changed, 50 insertions(+), 126 deletions(-) (limited to 'sc/source') diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 0b0171bc1df9..23bfd0e767f4 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -3159,15 +3159,9 @@ uno::Reference ScDPCollection::DBCaches::createRowSet( // set source parameters - uno::Any aAny; - aAny <<= rDBName; - xRowProp->setPropertyValue( SC_DBPROP_DATASOURCENAME, aAny ); - - aAny <<= rCommand; - xRowProp->setPropertyValue( SC_DBPROP_COMMAND, aAny ); - - aAny <<= nSdbType; - xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_DATASOURCENAME, Any(rDBName) ); + xRowProp->setPropertyValue( SC_DBPROP_COMMAND, Any(rCommand) ); + xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, Any(nSdbType) ); uno::Reference xExecute( xRowSet, uno::UNO_QUERY ); if ( xExecute.is() ) diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index 15920edf3554..1e356e950a81 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -562,26 +562,22 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference& xD if ( xDimProp.is() ) { // exceptions are caught at ScDPSaveData::WriteToSource - uno::Any aAny; sheet::DataPilotFieldOrientation eOrient = (sheet::DataPilotFieldOrientation)nOrientation; - aAny <<= eOrient; - xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, aAny ); + xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(eOrient) ); sheet::GeneralFunction eFunc = (sheet::GeneralFunction)nFunction; - aAny <<= eFunc; - xDimProp->setPropertyValue( SC_UNO_DP_FUNCTION, aAny ); + xDimProp->setPropertyValue( SC_UNO_DP_FUNCTION, uno::Any(eFunc) ); if ( nUsedHierarchy >= 0 ) { - aAny <<= (sal_Int32)nUsedHierarchy; - xDimProp->setPropertyValue( SC_UNO_DP_USEDHIERARCHY, aAny ); + xDimProp->setPropertyValue( SC_UNO_DP_USEDHIERARCHY, uno::Any((sal_Int32)nUsedHierarchy) ); } if ( pReferenceValue ) { - aAny <<= *pReferenceValue; - xDimProp->setPropertyValue( SC_UNO_DP_REFVALUE, aAny ); + ; + xDimProp->setPropertyValue( SC_UNO_DP_REFVALUE, uno::Any(*pReferenceValue) ); } if (mpLayoutName) @@ -631,7 +627,6 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference& xD OSL_ENSURE( xLevProp.is(), "no properties at level" ); if ( xLevProp.is() ) { - uno::Any aAny; if ( !bSubTotalDefault ) { if ( !pSubTotalFuncs ) @@ -641,8 +636,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference& xD sheet::GeneralFunction* pArray = aSeq.getArray(); for (long i=0; isetPropertyValue( SC_UNO_DP_SUBTOTAL, aAny ); + xLevProp->setPropertyValue( SC_UNO_DP_SUBTOTAL, uno::Any(aSeq) ); } if ( nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xLevProp, @@ -1148,9 +1142,7 @@ static void lcl_ResetOrient( const uno::Reference& x uno::Reference xDimProp( xIntDim, uno::UNO_QUERY ); if (xDimProp.is()) { - uno::Any aAny; - aAny <<= eOrient; - xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, aAny ); + xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(eOrient) ); } } } diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 2c1809983825..726ef0d17b3e 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -461,11 +461,9 @@ SdrObjectPtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, c { //Need summary type for export. Detail type(checkbox, button ...) has been contained by mnObjType const sal_Int16 nTBXControlType = eCreateFromMSTBXControl ; - Any aAny; - aAny <<= nTBXControlType; try { - xPropSet->setPropertyValue(sPropertyName, aAny); + xPropSet->setPropertyValue(sPropertyName, Any(nTBXControlType)); } catch(const Exception&) { @@ -480,14 +478,11 @@ SdrObjectPtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, c if( pObj != nullptr && pObj->IsOcxControl() ) { const sal_Int16 nOCXControlType = eCreateFromMSOCXControl; - Any aAny; try { - aAny <<= nOCXControlType; - xPropSet->setPropertyValue(sPropertyName, aAny); + xPropSet->setPropertyValue(sPropertyName, Any(nOCXControlType)); //Detail type(checkbox, button ...) - aAny<<= mnObjId; - xPropSet->setPropertyValue(sObjIdPropertyName, aAny); + xPropSet->setPropertyValue(sObjIdPropertyName, makeAny(mnObjId)); } catch(const Exception&) { diff --git a/sc/source/ui/Accessibility/AccessibleCellBase.cxx b/sc/source/ui/Accessibility/AccessibleCellBase.cxx index 7637027c2a7c..526c80ab00bb 100644 --- a/sc/source/ui/Accessibility/AccessibleCellBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleCellBase.cxx @@ -269,20 +269,14 @@ uno::Any SAL_CALL ScAccessibleCellBase::getMaximumValue( ) throw (uno::RuntimeException, std::exception) { - uno::Any aAny; - aAny <<= DBL_MAX; - - return aAny; + return uno::Any(DBL_MAX); } uno::Any SAL_CALL ScAccessibleCellBase::getMinimumValue( ) throw (uno::RuntimeException, std::exception) { - uno::Any aAny; - aAny <<= -DBL_MAX; - - return aAny; + return uno::Any(-DBL_MAX); } //===== XServiceInfo ==================================================== diff --git a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx index 5a40bcf2a6ee..816a78dc4b72 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx @@ -173,9 +173,7 @@ uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getCurrentValue() throw (uno::R else fValue = maCellPos.Row(); - uno::Any aAny; - aAny <<= fValue; - return aAny; + return uno::Any(fValue); } sal_Bool SAL_CALL ScAccessiblePreviewHeaderCell::setCurrentValue( const uno::Any& /* aNumber */ ) @@ -195,17 +193,13 @@ uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMaximumValue() throw (uno::R fValue = MAXCOL; else fValue = MAXROW; - uno::Any aAny; - aAny <<= fValue; - return aAny; + return uno::Any(fValue); } uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMinimumValue() throw (uno::RuntimeException, std::exception) { double fValue(0.0); - uno::Any aAny; - aAny <<= fValue; - return aAny; + return uno::Any(fValue); } //===== XAccessibleComponent ============================================ diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 756d028efac6..5da434129969 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2243,9 +2243,7 @@ void ScModule::SetAutoSpellProperty( bool bSet ) // loading the linguistic component SvtLinguConfig aConfig; - uno::Any aAny; - aAny <<= bSet; - aConfig.SetProperty( OUString( LINGUPROP_AUTOSPELL ), aAny ); + aConfig.SetProperty( OUString( LINGUPROP_AUTOSPELL ), uno::Any(bSet) ); } bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang ) diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index 45a68e64e851..8cba5795a60f 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -210,16 +210,12 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND : ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY : sdb::CommandType::TABLE ); - uno::Any aAny; - aAny <<= rParam.aDBName; - xRowProp->setPropertyValue( SC_DBPROP_DATASOURCENAME, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_DATASOURCENAME, uno::Any(rParam.aDBName) ); - aAny <<= rParam.aStatement; - xRowProp->setPropertyValue( SC_DBPROP_COMMAND, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_COMMAND, uno::Any(rParam.aStatement) ); - aAny <<= nType; - xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, uno::Any(nType) ); uno::Reference xExecute( xRowSet, uno::UNO_QUERY ); if ( xExecute.is() ) diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index c160b8a9c4fa..86fe2a950693 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -325,19 +325,14 @@ sal_uLong ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncodi if (!xRowProp.is()) return SCERR_IMPORT_CONNECT; sal_Int32 nType = sdb::CommandType::TABLE; - uno::Any aAny; - aAny <<= xConnection; - xRowProp->setPropertyValue( SC_DBPROP_ACTIVECONNECTION, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_ACTIVECONNECTION, uno::Any(xConnection) ); - aAny <<= nType; - xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, uno::Any(nType) ); - aAny <<= OUString( aTabName ); - xRowProp->setPropertyValue( SC_DBPROP_COMMAND, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_COMMAND, uno::Any(aTabName) ); - aAny <<= false; - xRowProp->setPropertyValue( SC_DBPROP_PROPCHANGE_NOTIFY, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_PROPCHANGE_NOTIFY, uno::Any(false) ); xRowSet->execute(); @@ -794,7 +789,6 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncodi KillFile( aDeleteObj ); sal_uLong nErr = eERR_OK; - uno::Any aAny; SCCOL nFirstCol, nLastCol; SCROW nFirstRow, nLastRow; @@ -869,8 +863,7 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncodi OSL_ENSURE( xTableDesc.is(), "can't get table descriptor" ); if (!xTableDesc.is()) return SCERR_EXPORT_CONNECT; - aAny <<= OUString( aTabName ); - xTableDesc->setPropertyValue( SC_DBPROP_NAME, aAny ); + xTableDesc->setPropertyValue( SC_DBPROP_NAME, uno::Any(aTabName) ); // create columns @@ -902,17 +895,13 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncodi OSL_ENSURE( xColumnDesc.is(), "can't get column descriptor" ); if (!xColumnDesc.is()) return SCERR_EXPORT_CONNECT; - aAny <<= pColNames[nCol]; - xColumnDesc->setPropertyValue( SC_DBPROP_NAME, aAny ); + xColumnDesc->setPropertyValue( SC_DBPROP_NAME, uno::Any(pColNames[nCol]) ); - aAny <<= pColTypes[nCol]; - xColumnDesc->setPropertyValue( SC_DBPROP_TYPE, aAny ); + xColumnDesc->setPropertyValue( SC_DBPROP_TYPE, uno::Any(pColTypes[nCol]) ); - aAny <<= pColLengths[nCol]; - xColumnDesc->setPropertyValue( SC_DBPROP_PRECISION, aAny ); + xColumnDesc->setPropertyValue( SC_DBPROP_PRECISION, uno::Any(pColLengths[nCol]) ); - aAny <<= pColScales[nCol]; - xColumnDesc->setPropertyValue( SC_DBPROP_SCALE, aAny ); + xColumnDesc->setPropertyValue( SC_DBPROP_SCALE, uno::Any(pColScales[nCol]) ); xColumnsAppend->appendByDescriptor( xColumnDesc ); } @@ -928,14 +917,11 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncodi OSL_ENSURE( xRowProp.is(), "can't get RowSet" ); if (!xRowProp.is()) return SCERR_EXPORT_CONNECT; - aAny <<= xConnection; - xRowProp->setPropertyValue( SC_DBPROP_ACTIVECONNECTION, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_ACTIVECONNECTION, uno::Any(xConnection) ); - aAny <<= (sal_Int32) sdb::CommandType::TABLE; - xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, uno::Any((sal_Int32) sdb::CommandType::TABLE) ); - aAny <<= OUString( aTabName ); - xRowProp->setPropertyValue( SC_DBPROP_COMMAND, aAny ); + xRowProp->setPropertyValue( SC_DBPROP_COMMAND, uno::Any(aTabName) ); xRowSet->execute(); diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 6f58a8580e60..28a9084a66c2 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -189,28 +189,23 @@ void ScDrawShell::ExecuteHLink( SfxRequest& rReq ) OUString sPropTargetFrame( "TargetFrame" ); OUString sPropLabel( "Label" ); - uno::Any aAny; if ( xInfo->hasPropertyByName( sPropLabel ) ) { - aAny <<= OUString(rName); - xPropSet->setPropertyValue( sPropLabel, aAny ); + xPropSet->setPropertyValue( sPropLabel, uno::Any(rName) ); } OUString aTmp = INetURLObject::GetAbsURL( pViewData->GetDocShell()->GetMedium()->GetBaseURL(), rURL ); - aAny <<= aTmp; - xPropSet->setPropertyValue( sPropTargetURL, aAny ); + xPropSet->setPropertyValue( sPropTargetURL, uno::Any(aTmp) ); if( !rTarget.isEmpty() && xInfo->hasPropertyByName( sPropTargetFrame ) ) { - aAny <<= OUString(rTarget); - xPropSet->setPropertyValue( sPropTargetFrame, aAny ); + xPropSet->setPropertyValue( sPropTargetFrame, uno::Any(rTarget) ); } if ( xInfo->hasPropertyByName( sPropButtonType ) ) { form::FormButtonType eButtonType = form::FormButtonType_URL; - aAny <<= eButtonType; - xPropSet->setPropertyValue( sPropButtonType, aAny ); + xPropSet->setPropertyValue( sPropButtonType, uno::Any(eButtonType) ); } //! Undo ??? diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index ae121a45aed0..5fce4c2f2489 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -551,9 +551,7 @@ uno::Any ScCondFormatObj::getByIndex(sal_Int32 nIndex) const ScFormatEntry* pEntry = getCoreObject()->GetEntry(nIndex); uno::Reference xCondEntry = createConditionEntry(pEntry, this); - uno::Any aAny; - aAny <<= xCondEntry; - return aAny; + return uno::Any(xCondEntry); } uno::Reference SAL_CALL ScCondFormatObj::getPropertySetInfo() diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 301f36b8e379..abe81aa75f36 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -1203,9 +1203,7 @@ void ScDDELinkObj::setResults( const uno::Sequence< uno::Sequence< uno::Any > >& size_t nPos = 0; if ( rDoc.FindDdeLink( aAppl, aTopic, aItem, SC_DDE_IGNOREMODE, nPos ) ) { - uno::Any aAny; - aAny <<= aResults; - ScMatrixRef xMatrix = ScSequenceToMatrix::CreateMixedMatrix( aAny ); + ScMatrixRef xMatrix = ScSequenceToMatrix::CreateMixedMatrix( Any(aResults) ); bSuccess = rDoc.SetDdeLinkResultMatrix( nPos, xMatrix ); } } @@ -1572,9 +1570,7 @@ Any SAL_CALL ScExternalDocLinkObj::getByName(const OUString &aName) Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(mpDocShell, pTable, nIndex)); - Any aAny; - aAny <<= aSheetCache; - return aAny; + return Any(aSheetCache); } Sequence< OUString > SAL_CALL ScExternalDocLinkObj::getElementNames() @@ -1634,9 +1630,7 @@ Any SAL_CALL ScExternalDocLinkObj::getByIndex(sal_Int32 nApiIndex) Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(mpDocShell, pTable, nIndex)); - Any aAny; - aAny <<= aSheetCache; - return aAny; + return Any(aSheetCache); } Reference< container::XEnumeration > SAL_CALL ScExternalDocLinkObj::createEnumeration() @@ -1703,9 +1697,7 @@ Any SAL_CALL ScExternalDocLinksObj::getByName(const OUString &aName) sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocUrl); Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); - Any aAny; - aAny <<= aDocLink; - return aAny; + return Any(aDocLink); } Sequence< OUString > SAL_CALL ScExternalDocLinksObj::getElementNames() @@ -1750,9 +1742,7 @@ Any SAL_CALL ScExternalDocLinksObj::getByIndex(sal_Int32 nIndex) throw lang::IndexOutOfBoundsException(); Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); - Any aAny; - aAny <<= aDocLink; - return aAny; + return Any(aDocLink); } Reference< container::XEnumeration > SAL_CALL ScExternalDocLinksObj::createEnumeration() diff --git a/sc/source/ui/view/tabvwshg.cxx b/sc/source/ui/view/tabvwshg.cxx index 54b7ba43a6d2..73cbb2ca2073 100644 --- a/sc/source/ui/view/tabvwshg.cxx +++ b/sc/source/ui/view/tabvwshg.cxx @@ -71,29 +71,23 @@ void ScTabViewShell::InsertURLButton( const OUString& rName, const OUString& rUR return; uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); - uno::Any aAny; - aAny <<= OUString(rName); - xPropSet->setPropertyValue("Label", aAny ); + xPropSet->setPropertyValue("Label", uno::Any(rName) ); OUString aTmp = INetURLObject::GetAbsURL( pDoc->GetDocumentShell()->GetMedium()->GetBaseURL(), rURL ); - aAny <<= aTmp; - xPropSet->setPropertyValue("TargetURL", aAny ); + xPropSet->setPropertyValue("TargetURL", uno::Any(aTmp) ); if( !rTarget.isEmpty() ) { - aAny <<= rTarget; - xPropSet->setPropertyValue("TargetFrame", aAny ); + xPropSet->setPropertyValue("TargetFrame", uno::Any(rTarget) ); } form::FormButtonType eButtonType = form::FormButtonType_URL; - aAny <<= eButtonType; - xPropSet->setPropertyValue("ButtonType", aAny ); + xPropSet->setPropertyValue("ButtonType", uno::Any(eButtonType) ); if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) ) { - aAny <<= true; - xPropSet->setPropertyValue("DispatchURLInternal", aAny ); + xPropSet->setPropertyValue("DispatchURLInternal", uno::Any(true) ); } Point aPos; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 4bfa4e76b620..5c3e55214791 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2651,11 +2651,9 @@ void ScViewData::WriteUserDataSequence(uno::Sequence & rSe maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab); OUString sTabName; GetDocument()->GetName( nTab, sTabName ); - uno::Any aAny; - aAny <<= aTableViewSettings; try { - xNameContainer->insertByName(sTabName, aAny); + xNameContainer->insertByName(sTabName, uno::Any(aTableViewSettings)); } //#101739#; two tables with the same name are possible catch ( container::ElementExistException& ) -- cgit