summaryrefslogtreecommitdiff
path: root/sc/source/filter
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-08-17 15:42:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-08-18 11:03:02 +0200
commit7fc6063914432d58d86cfcbd728d967e7c86ebfd (patch)
treef71fe9f99edaa4e896c78cdf32e34b516194d748 /sc/source/filter
parentdb83c41d460103df5d80f5bd99816575c4ead5cd (diff)
use more Reference::query instead of UNO_QUERY_THROW
since querying with exceptions is consideably more expensive Change-Id: I968a9a40766b2abb0d3058549b0ed44011fd5716 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155791 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/filter')
-rw-r--r--sc/source/filter/excel/xichart.cxx13
-rw-r--r--sc/source/filter/ftools/fapihelper.cxx4
-rw-r--r--sc/source/filter/oox/numberformatsbuffer.cxx8
-rw-r--r--sc/source/filter/oox/pivotcachebuffer.cxx8
-rw-r--r--sc/source/filter/oox/pivottablebuffer.cxx8
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx9
-rw-r--r--sc/source/filter/xml/xmlwrap.cxx11
7 files changed, 16 insertions, 45 deletions
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index a52bb103fbb6..2eb6e10683f8 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -3988,15 +3988,10 @@ void XclImpChChart::Convert( const Reference<XChartDocument>& xChartDoc,
}
// chart title
- if( mxTitle ) try
- {
- Reference< XTitled > xTitled( xChartDoc, UNO_QUERY_THROW );
- Reference< XTitle > xTitle( mxTitle->CreateTitle(), UNO_SET_THROW );
- xTitled->setTitleObject( xTitle );
- }
- catch( Exception& )
- {
- }
+ if( mxTitle )
+ if (auto xTitled = xChartDoc.query<XTitled>() )
+ if (auto xTitle = mxTitle->CreateTitle().query<XTitle>() )
+ xTitled->setTitleObject( xTitle );
/* Create the diagram object and attach it to the chart document. Currently,
one diagram is used to carry all coordinate systems and data series. */
diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx
index a8cb2f59d102..b81a58e8d64c 100644
--- a/sc/source/filter/ftools/fapihelper.cxx
+++ b/sc/source/filter/ftools/fapihelper.cxx
@@ -159,8 +159,8 @@ bool ScfPropertySet::HasProperty( const OUString& rPropName ) const
bool bHasProp = false;
try
{
- Reference< XPropertyState > xPropState( mxPropSet, UNO_QUERY_THROW );
- bHasProp = xPropState->getPropertyState( rPropName ) == css::beans::PropertyState_DIRECT_VALUE;
+ if (auto xPropState = mxPropSet.query<XPropertyState>() )
+ bHasProp = xPropState->getPropertyState( rPropName ) == css::beans::PropertyState_DIRECT_VALUE;
}
catch( Exception& )
{
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index 447878000226..8aa9124d882b 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -1866,14 +1866,8 @@ private:
NumberFormatFinalizer::NumberFormatFinalizer( const WorkbookHelper& rHelper ) :
maEnUsLocale( "en", "US", OUString() )
{
- try
- {
- Reference< XNumberFormatsSupplier > xNumFmtsSupp( rHelper.getDocument(), UNO_QUERY_THROW );
+ if (auto xNumFmtsSupp = rHelper.getDocument().query<XNumberFormatsSupplier>() )
mxNumFmts = xNumFmtsSupp->getNumberFormats();
- }
- catch( Exception& )
- {
- }
OSL_ENSURE( mxNumFmts.is(), "NumberFormatFinalizer::NumberFormatFinalizer - cannot get number formats" );
}
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index cbbacc8a6123..e796cfe53da0 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -646,14 +646,8 @@ OUString PivotCacheField::createDateGroupField( const Reference< XDataPilotField
default: OSL_FAIL( "PivotCacheField::convertRangeGrouping - unknown date/time interval" );
}
- try
- {
- Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY_THROW );
+ if (auto xDPGrouping = rxBaseDPField.query<XDataPilotFieldGrouping>() )
xDPGroupField = xDPGrouping->createDateGroup( aGroupInfo );
- }
- catch( Exception& )
- {
- }
}
Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index 637637eb378c..08c0bc8a7dca 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -1409,14 +1409,8 @@ Reference< XDataPilotField > PivotTable::getDataPilotField( sal_Int32 nFieldIdx
Reference< XDataPilotField > PivotTable::getDataLayoutField() const
{
Reference< XDataPilotField > xDPField;
- try
- {
- Reference< XDataPilotDataLayoutFieldSupplier > xDPDataFieldSupp( mxDPDescriptor, UNO_QUERY_THROW );
+ if (auto xDPDataFieldSupp = mxDPDescriptor.query<XDataPilotDataLayoutFieldSupplier>() )
xDPField = xDPDataFieldSupp->getDataLayoutField();
- }
- catch( Exception& )
- {
- }
return xDPField;
}
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 495cc0ff7828..34d393c08b3e 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -527,13 +527,8 @@ Reference< XCellRange > WorksheetGlobals::getRow( sal_Int32 nRow ) const
Reference< XDrawPage > WorksheetGlobals::getDrawPage() const
{
Reference< XDrawPage > xDrawPage;
- try
- {
- xDrawPage = Reference< XDrawPageSupplier >( mxSheet, UNO_QUERY_THROW )->getDrawPage();
- }
- catch( Exception& )
- {
- }
+ if (auto xSupplier = mxSheet.query<XDrawPageSupplier>())
+ xDrawPage = xSupplier->getDrawPage();
return xDrawPage;
}
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index f1eadd91c4b6..a3c19728eb74 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -568,9 +568,9 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCode& rError )
VBA Globals object and does all related initialization. */
if ( xModelSet.is() ) try
{
- uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue(
- "BasicLibraries" ), uno::UNO_QUERY_THROW );
- xVBACompat->setVBACompatibilityMode( true );
+ if (auto xVBACompat = xModelSet->getPropertyValue(
+ "BasicLibraries" ).query<script::vba::XVBACompatibility>() )
+ xVBACompat->setVBACompatibilityMode( true );
}
catch( const uno::Exception& )
{
@@ -853,9 +853,8 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
&& aVersion != ODFVER_010_TEXT
&& aVersion != ODFVER_011_TEXT )
{
- const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
- xModel, uno::UNO_QUERY_THROW );
- xDMA->storeMetadataToStorage( xStorage );
+ if (auto xDMA = xModel.query<rdf::XDocumentMetadataAccess>() )
+ xDMA->storeMetadataToStorage( xStorage );
}
}
catch ( const beans::UnknownPropertyException &)