Kaydet (Commit) 830345be authored tarafından Mike Kaganski's avatar Mike Kaganski

ScUnoHelpFunctions::AnyToInterface is redundant

Change-Id: Ia61806f7781b49f29122ad9be75a5eb739918c37
Reviewed-on: https://gerrit.libreoffice.org/69734
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 0f1458cf
...@@ -127,8 +127,6 @@ public: ...@@ -127,8 +127,6 @@ public:
class SC_DLLPUBLIC ScUnoHelpFunctions class SC_DLLPUBLIC ScUnoHelpFunctions
{ {
public: public:
static css::uno::Reference<css::uno::XInterface>
AnyToInterface( const css::uno::Any& rAny );
static bool GetBoolProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, static bool GetBoolProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp,
const OUString& rName, bool bDefault = false ); const OUString& rName, bool bDefault = false );
static sal_Int16 GetShortProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, static sal_Int16 GetShortProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp,
......
...@@ -354,8 +354,7 @@ void lcl_FillNumberFormats( std::unique_ptr<sal_uInt32[]>& rFormats, long& rCoun ...@@ -354,8 +354,7 @@ void lcl_FillNumberFormats( std::unique_ptr<sal_uInt32[]>& rFormats, long& rCoun
sal_Int32 nDim = 0; sal_Int32 nDim = 0;
for ( ; nDim < nDimCount ; nDim++) for ( ; nDim < nDimCount ; nDim++)
{ {
uno::Reference<uno::XInterface> xDim = uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY ); uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY );
if ( xDimProp.is() && xDimName.is() ) if ( xDimProp.is() && xDimName.is() )
...@@ -418,9 +417,7 @@ sal_uInt32 lcl_GetFirstNumberFormat( const uno::Reference<container::XIndexAcces ...@@ -418,9 +417,7 @@ sal_uInt32 lcl_GetFirstNumberFormat( const uno::Reference<container::XIndexAcces
long nDimCount = xDims->getCount(); long nDimCount = xDims->getCount();
for (long nDim=0; nDim<nDimCount; nDim++) for (long nDim=0; nDim<nDimCount; nDim++)
{ {
uno::Reference<uno::XInterface> xDim = uno::Reference<beans::XPropertySet> xDimProp(xDims->getByIndex(nDim), uno::UNO_QUERY);
ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
if ( xDimProp.is() ) if ( xDimProp.is() )
{ {
sheet::DataPilotFieldOrientation eDimOrient = sheet::DataPilotFieldOrientation eDimOrient =
...@@ -536,8 +533,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS ...@@ -536,8 +533,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
long nDimCount = xDims->getCount(); long nDimCount = xDims->getCount();
for (long nDim=0; nDim<nDimCount; nDim++) for (long nDim=0; nDim<nDimCount; nDim++)
{ {
uno::Reference<uno::XInterface> xDim = uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDim, uno::UNO_QUERY ); uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDim, uno::UNO_QUERY );
if ( xDimProp.is() && xDimSupp.is() ) if ( xDimProp.is() && xDimSupp.is() )
...@@ -565,10 +561,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS ...@@ -565,10 +561,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
if ( nHierarchy >= xHiers->getCount() ) if ( nHierarchy >= xHiers->getCount() )
nHierarchy = 0; nHierarchy = 0;
uno::Reference<uno::XInterface> xHier = uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
ScUnoHelpFunctions::AnyToInterface( uno::UNO_QUERY);
xHiers->getByIndex(nHierarchy) );
uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
if ( xHierSupp.is() ) if ( xHierSupp.is() )
{ {
uno::Reference<container::XIndexAccess> xLevels = uno::Reference<container::XIndexAccess> xLevels =
...@@ -576,9 +570,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS ...@@ -576,9 +570,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
long nLevCount = xLevels->getCount(); long nLevCount = xLevels->getCount();
for (long nLev=0; nLev<nLevCount; nLev++) for (long nLev=0; nLev<nLevCount; nLev++)
{ {
uno::Reference<uno::XInterface> xLevel = uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev),
ScUnoHelpFunctions::AnyToInterface( uno::UNO_QUERY);
xLevels->getByIndex(nLev) );
uno::Reference<container::XNamed> xLevNam( xLevel, uno::UNO_QUERY ); uno::Reference<container::XNamed> xLevNam( xLevel, uno::UNO_QUERY );
uno::Reference<sheet::XDataPilotMemberResults> xLevRes( uno::Reference<sheet::XDataPilotMemberResults> xLevRes(
xLevel, uno::UNO_QUERY ); xLevel, uno::UNO_QUERY );
...@@ -1244,8 +1237,7 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s ...@@ -1244,8 +1237,7 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s
long nDimCount = xDims->getCount(); long nDimCount = xDims->getCount();
for (long nDim=0; nDim<nDimCount; nDim++) for (long nDim=0; nDim<nDimCount; nDim++)
{ {
uno::Reference<uno::XInterface> xDim = uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
if ( xDimProp.is() ) if ( xDimProp.is() )
{ {
......
...@@ -527,11 +527,9 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD ...@@ -527,11 +527,9 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
for (long nHier=0; nHier<nHierCount; nHier++) for (long nHier=0; nHier<nHierCount; nHier++)
{ {
uno::Reference<uno::XInterface> xHierarchy = ScUnoHelpFunctions::AnyToInterface( xHiers->getByIndex(nHier) );
long nLevCount = 0; long nLevCount = 0;
uno::Reference<container::XIndexAccess> xLevels; uno::Reference<container::XIndexAccess> xLevels;
uno::Reference<sheet::XLevelsSupplier> xLevSupp( xHierarchy, uno::UNO_QUERY ); uno::Reference<sheet::XLevelsSupplier> xLevSupp(xHiers->getByIndex(nHier), uno::UNO_QUERY);
if ( xLevSupp.is() ) if ( xLevSupp.is() )
{ {
uno::Reference<container::XNameAccess> xLevelsName = xLevSupp->getLevels(); uno::Reference<container::XNameAccess> xLevelsName = xLevSupp->getLevels();
...@@ -541,7 +539,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD ...@@ -541,7 +539,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
for (long nLev=0; nLev<nLevCount; nLev++) for (long nLev=0; nLev<nLevCount; nLev++)
{ {
uno::Reference<uno::XInterface> xLevel = ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex(nLev) ); uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
OSL_ENSURE( xLevProp.is(), "no properties at level" ); OSL_ENSURE( xLevProp.is(), "no properties at level" );
if ( xLevProp.is() ) if ( xLevProp.is() )
...@@ -591,8 +589,8 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD ...@@ -591,8 +589,8 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
OUString aMemberName = pMember->GetName(); OUString aMemberName = pMember->GetName();
if ( xMembers->hasByName( aMemberName ) ) if ( xMembers->hasByName( aMemberName ) )
{ {
uno::Reference<uno::XInterface> xMemberInt = ScUnoHelpFunctions::AnyToInterface( uno::Reference<uno::XInterface> xMemberInt(
xMembers->getByName( aMemberName ) ); xMembers->getByName(aMemberName), uno::UNO_QUERY);
pMember->WriteToSource( xMemberInt, nPosition ); pMember->WriteToSource( xMemberInt, nPosition );
if ( nPosition >= 0 ) if ( nPosition >= 0 )
...@@ -1020,8 +1018,7 @@ static void lcl_ResetOrient( const uno::Reference<sheet::XDimensionsSupplier>& x ...@@ -1020,8 +1018,7 @@ static void lcl_ResetOrient( const uno::Reference<sheet::XDimensionsSupplier>& x
long nIntCount = xIntDims->getCount(); long nIntCount = xIntDims->getCount();
for (long nIntDim=0; nIntDim<nIntCount; nIntDim++) for (long nIntDim=0; nIntDim<nIntCount; nIntDim++)
{ {
uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) ); uno::Reference<beans::XPropertySet> xDimProp(xIntDims->getByIndex(nIntDim), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
if (xDimProp.is()) if (xDimProp.is())
{ {
xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(sheet::DataPilotFieldOrientation_HIDDEN) ); xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(sheet::DataPilotFieldOrientation_HIDDEN) );
...@@ -1090,7 +1087,8 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie ...@@ -1090,7 +1087,8 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
bool bFound = false; bool bFound = false;
for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++) for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
{ {
uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) ); uno::Reference<uno::XInterface> xIntDim(xIntDims->getByIndex(nIntDim),
uno::UNO_QUERY);
if ( bData ) if ( bData )
{ {
uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
......
...@@ -70,8 +70,7 @@ void SQLFetchThread::execute() ...@@ -70,8 +70,7 @@ void SQLFetchThread::execute()
= sdb::DatabaseContext::create(comphelper::getProcessComponentContext()); = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
uno::Any aSourceAny = xContext->getByName(aDatabase); uno::Any aSourceAny = xContext->getByName(aDatabase);
uno::Reference<sdb::XCompletedConnection> xSource( uno::Reference<sdb::XCompletedConnection> xSource(aSourceAny, uno::UNO_QUERY);
ScUnoHelpFunctions::AnyToInterface(aSourceAny), uno::UNO_QUERY);
if (!xSource.is()) if (!xSource.is())
return; return;
......
...@@ -125,8 +125,7 @@ void ScDataPilotDatabaseDlg::FillObjects() ...@@ -125,8 +125,7 @@ void ScDataPilotDatabaseDlg::FillObjects()
comphelper::getProcessComponentContext() ); comphelper::getProcessComponentContext() );
uno::Any aSourceAny = xContext->getByName( aDatabaseName ); uno::Any aSourceAny = xContext->getByName( aDatabaseName );
uno::Reference<sdb::XCompletedConnection> xSource( uno::Reference<sdb::XCompletedConnection> xSource(aSourceAny, uno::UNO_QUERY);
ScUnoHelpFunctions::AnyToInterface( aSourceAny ), uno::UNO_QUERY );
if ( !xSource.is() ) return; if ( !xSource.is() ) return;
uno::Reference<task::XInteractionHandler> xHandler( uno::Reference<task::XInteractionHandler> xHandler(
......
...@@ -338,7 +338,7 @@ void PivotTableDataProvider::collectPivotTableData() ...@@ -338,7 +338,7 @@ void PivotTableDataProvider::collectPivotTableData()
for (sal_Int32 nDim = 0; nDim < xDims->getCount(); nDim++) for (sal_Int32 nDim = 0; nDim < xDims->getCount(); nDim++)
{ {
uno::Reference<uno::XInterface> xDim = ScUnoHelpFunctions::AnyToInterface(xDims->getByIndex(nDim)); uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xDimProp(xDim, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xDimProp(xDim, uno::UNO_QUERY);
uno::Reference<sheet::XHierarchiesSupplier> xDimSupp(xDim, uno::UNO_QUERY); uno::Reference<sheet::XHierarchiesSupplier> xDimSupp(xDim, uno::UNO_QUERY);
...@@ -357,9 +357,8 @@ void PivotTableDataProvider::collectPivotTableData() ...@@ -357,9 +357,8 @@ void PivotTableDataProvider::collectPivotTableData()
if (nHierarchy >= xHierarchies->getCount()) if (nHierarchy >= xHierarchies->getCount())
nHierarchy = 0; nHierarchy = 0;
uno::Reference<uno::XInterface> xHierarchy = ScUnoHelpFunctions::AnyToInterface(xHierarchies->getByIndex(nHierarchy)); uno::Reference<sheet::XLevelsSupplier> xLevelsSupplier(xHierarchies->getByIndex(nHierarchy),
uno::UNO_QUERY);
uno::Reference<sheet::XLevelsSupplier> xLevelsSupplier(xHierarchy, uno::UNO_QUERY);
if (!xLevelsSupplier.is()) if (!xLevelsSupplier.is())
continue; continue;
...@@ -368,7 +367,7 @@ void PivotTableDataProvider::collectPivotTableData() ...@@ -368,7 +367,7 @@ void PivotTableDataProvider::collectPivotTableData()
for (long nLevel = 0; nLevel < xLevels->getCount(); nLevel++) for (long nLevel = 0; nLevel < xLevels->getCount(); nLevel++)
{ {
uno::Reference<uno::XInterface> xLevel = ScUnoHelpFunctions::AnyToInterface(xLevels->getByIndex(nLevel)); uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLevel), uno::UNO_QUERY);
uno::Reference<container::XNamed> xLevelName(xLevel, uno::UNO_QUERY); uno::Reference<container::XNamed> xLevelName(xLevel, uno::UNO_QUERY);
uno::Reference<sheet::XDataPilotMemberResults> xLevelResult(xLevel, uno::UNO_QUERY ); uno::Reference<sheet::XDataPilotMemberResults> xLevelResult(xLevel, uno::UNO_QUERY );
......
...@@ -32,15 +32,6 @@ using ::com::sun::star::uno::Any; ...@@ -32,15 +32,6 @@ using ::com::sun::star::uno::Any;
SC_SIMPLE_SERVICE_INFO( ScNameToIndexAccess, "ScNameToIndexAccess", "stardiv.unknown" ) SC_SIMPLE_SERVICE_INFO( ScNameToIndexAccess, "ScNameToIndexAccess", "stardiv.unknown" )
uno::Reference<uno::XInterface> ScUnoHelpFunctions::AnyToInterface( const uno::Any& rAny )
{
if ( rAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
{
return uno::Reference<uno::XInterface>(rAny, uno::UNO_QUERY);
}
return uno::Reference<uno::XInterface>(); //! Exception?
}
bool ScUnoHelpFunctions::GetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp, bool ScUnoHelpFunctions::GetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp,
const OUString& rName, bool bDefault ) const OUString& rName, bool bDefault )
{ {
......
...@@ -262,12 +262,11 @@ ScLinkTargetsObj::~ScLinkTargetsObj() ...@@ -262,12 +262,11 @@ ScLinkTargetsObj::~ScLinkTargetsObj()
uno::Any SAL_CALL ScLinkTargetsObj::getByName(const OUString& aName) uno::Any SAL_CALL ScLinkTargetsObj::getByName(const OUString& aName)
{ {
uno::Reference< beans::XPropertySet > xProp( ScUnoHelpFunctions::AnyToInterface( xCollection->getByName(aName) ), uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xProp(xCollection->getByName(aName), uno::UNO_QUERY);
if (xProp.is()) if (xProp.is())
return uno::makeAny(xProp); return uno::makeAny(xProp);
throw container::NoSuchElementException(); throw container::NoSuchElementException();
// return uno::Any();
} }
uno::Sequence<OUString> SAL_CALL ScLinkTargetsObj::getElementNames() uno::Sequence<OUString> SAL_CALL ScLinkTargetsObj::getElementNames()
......
...@@ -279,8 +279,7 @@ ScVbaApplication::getSelection() ...@@ -279,8 +279,7 @@ ScVbaApplication::getSelection()
uno::Any any; uno::Any any;
any <<= false; any <<= false;
xPropSet->setPropertyValue( aPropName, any ); xPropSet->setPropertyValue( aPropName, any );
uno::Reference< uno::XInterface > aSelection = ScUnoHelpFunctions::AnyToInterface( uno::Reference<uno::XInterface> aSelection(xSelSupp->getSelection(), uno::UNO_QUERY);
xSelSupp->getSelection() );
xPropSet->setPropertyValue( aPropName, aOldVal ); xPropSet->setPropertyValue( aPropName, aOldVal );
if (!aSelection.is()) if (!aSelection.is())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment