diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-11-23 20:50:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-11-24 12:47:23 +0100 |
commit | ca0609368edf80c4e56abf36fefc2bfabfd82deb (patch) | |
tree | d27c4dc949a4a09c203b0dfeaea92ea396a550a2 /sc/source | |
parent | 57974af130e7421da6b07589d4a63a754b757ad6 (diff) |
use more concrete UNO in sc
Change-Id: I20f0200a4ed74b32b67b740e0084dae9620c2912
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159871
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/inc/workbookhelper.hxx | 8 | ||||
-rw-r--r-- | sc/source/filter/oox/addressconverter.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/oox/externallinkbuffer.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/oox/numberformatsbuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/querytablebuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/scenariobuffer.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/oox/sheetdatabuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/tablebuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/unitconverter.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/viewsettings.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/oox/workbookhelper.cxx | 30 | ||||
-rw-r--r-- | sc/source/filter/oox/workbooksettings.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/oox/worksheetbuffer.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/servuno.cxx | 5 |
15 files changed, 41 insertions, 39 deletions
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx index fd6343a31a79..e76285ca37a2 100644 --- a/sc/source/filter/inc/workbookhelper.hxx +++ b/sc/source/filter/inc/workbookhelper.hxx @@ -26,7 +26,7 @@ #include <o3tl/hash_combine.hxx> #include <oox/helper/storagebase.hxx> #include <address.hxx> - +#include <rtl/ref.hxx> #include <com/sun/star/awt/FontDescriptor.hpp> namespace oox::drawingml::chart { class ChartConverter; } @@ -58,6 +58,7 @@ class ScDocumentImport; class ScEditEngineDefaulter; class ScDBData; class ScRangeData; +class ScModelObj; namespace oox::xls { @@ -188,9 +189,8 @@ public: const ScDocumentImport& getDocImport() const; ScEditEngineDefaulter& getEditEngine() const; - /** Returns a reference to the source/target spreadsheet document model. */ - const css::uno::Reference< css::sheet::XSpreadsheetDocument >& - getDocument() const; + /** Returns a reference to the source/target spreadsheet document model (XSpreadsheetDocument). */ + const rtl::Reference< ScModelObj >& getDocument() const; /** Returns a reference to the specified spreadsheet in the document model. */ css::uno::Reference< css::sheet::XSpreadsheet > diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx index 0d6e52f13f9d..2408e2670ee8 100644 --- a/sc/source/filter/oox/addressconverter.cxx +++ b/sc/source/filter/oox/addressconverter.cxx @@ -27,6 +27,7 @@ #include <osl/diagnose.h> #include <oox/core/filterbase.hxx> #include <oox/helper/binaryinputstream.hxx> +#include <docuno.hxx> namespace oox::xls { diff --git a/sc/source/filter/oox/externallinkbuffer.cxx b/sc/source/filter/oox/externallinkbuffer.cxx index 595d6e3dd766..a812a48cff5a 100644 --- a/sc/source/filter/oox/externallinkbuffer.cxx +++ b/sc/source/filter/oox/externallinkbuffer.cxx @@ -43,6 +43,7 @@ #include <oox/token/tokens.hxx> #include <addressconverter.hxx> #include <biffhelper.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -203,7 +204,7 @@ bool ExternalName::getDdeLinkData( OUString& orDdeServer, OUString& orDdeTopic, // try to create a DDE link and to set the imported link results if( !mbDdeLinkCreated ) try { - PropertySet aDocProps( getDocument() ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(getDocument()) )); Reference< XDDELinks > xDdeLinks( aDocProps.getAnyProperty( PROP_DDELinks ), UNO_QUERY_THROW ); mxDdeLink = xDdeLinks->addDDELink( mrParentLink.getClassName(), mrParentLink.getTargetUrl(), maModel.maName, css::sheet::DDELinkMode_DEFAULT ); mbDdeLinkCreated = true; // ignore if setting results fails @@ -526,7 +527,7 @@ void ExternalLink::setExternalTargetUrl( const OUString& rTargetUrl, const OUStr // create the external document link API object that will contain the sheet caches if( meLinkType == ExternalLinkType::External ) try { - PropertySet aDocProps( getDocument() ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(getDocument()) )); Reference< XExternalDocLinks > xDocLinks( aDocProps.getAnyProperty( PROP_ExternalDocLinks ), UNO_QUERY_THROW ); mxDocLink = xDocLinks->addDocLink( maTargetUrl ); } diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx index 447878000226..5fa701b3f19c 100644 --- a/sc/source/filter/oox/numberformatsbuffer.cxx +++ b/sc/source/filter/oox/numberformatsbuffer.cxx @@ -46,6 +46,7 @@ #include <scitems.hxx> #include <document.hxx> #include <ftools.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -1868,7 +1869,7 @@ NumberFormatFinalizer::NumberFormatFinalizer( const WorkbookHelper& rHelper ) : { try { - Reference< XNumberFormatsSupplier > xNumFmtsSupp( rHelper.getDocument(), UNO_QUERY_THROW ); + Reference< XNumberFormatsSupplier > xNumFmtsSupp( static_cast<cppu::OWeakObject*>(rHelper.getDocument().get()), UNO_QUERY_THROW ); mxNumFmts = xNumFmtsSupp->getNumberFormats(); } catch( Exception& ) diff --git a/sc/source/filter/oox/querytablebuffer.cxx b/sc/source/filter/oox/querytablebuffer.cxx index 1ec2ea8be012..1c5ee4464887 100644 --- a/sc/source/filter/oox/querytablebuffer.cxx +++ b/sc/source/filter/oox/querytablebuffer.cxx @@ -34,6 +34,7 @@ #include <biffhelper.hxx> #include <connectionsbuffer.hxx> #include <defnamesbuffer.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -246,7 +247,7 @@ void QueryTable::finalizeImport() try { - PropertySet aDocProps( getDocument() ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(getDocument()) )); Reference< XAreaLinks > xAreaLinks( aDocProps.getAnyProperty( PROP_AreaLinks ), UNO_QUERY_THROW ); CellAddress aDestPos( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row() ); static constexpr OUString aFilterName = u"calc_HTML_WebQuery"_ustr; diff --git a/sc/source/filter/oox/scenariobuffer.cxx b/sc/source/filter/oox/scenariobuffer.cxx index 7c45c822da27..44ad52814680 100644 --- a/sc/source/filter/oox/scenariobuffer.cxx +++ b/sc/source/filter/oox/scenariobuffer.cxx @@ -32,6 +32,7 @@ #include <oox/token/tokens.hxx> #include <addressconverter.hxx> #include <biffhelper.hxx> +#include <docuno.hxx> namespace oox::xls { diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index b25dba6eb079..98d50c2a05c3 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -50,6 +50,7 @@ #include <formulabuffer.hxx> #include <numformat.hxx> #include <sax/tools/converter.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -155,7 +156,7 @@ void SheetDataBuffer::setDateTimeCell( const CellModel& rModel, const css::util: // set number format try { - Reference< XNumberFormatsSupplier > xNumFmtsSupp( getDocument(), UNO_QUERY_THROW ); + Reference< XNumberFormatsSupplier > xNumFmtsSupp( static_cast<cppu::OWeakObject*>(getDocument().get()), UNO_QUERY_THROW ); Reference< XNumberFormatTypes > xNumFmtTypes( xNumFmtsSupp->getNumberFormats(), UNO_QUERY_THROW ); sal_Int32 nIndex = xNumFmtTypes->getStandardFormat( nStdFmt, Locale() ); PropertySet aPropSet( getCell( rModel.maCellAddr ) ); diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index 7481b1dec851..2310f324e27a 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -86,6 +86,7 @@ #include <patattr.hxx> #include <stlsheet.hxx> #include <biffhelper.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -804,7 +805,7 @@ void Font::finalizeImport() } else { - PropertySet aDocProps( getDocument() ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(getDocument()) )); Reference< XDevice > xDevice( aDocProps.getAnyProperty( PROP_ReferenceDevice ), UNO_QUERY ); if( !xDevice.is() ) return; diff --git a/sc/source/filter/oox/tablebuffer.cxx b/sc/source/filter/oox/tablebuffer.cxx index a6352e63f8d5..dec0498f4678 100644 --- a/sc/source/filter/oox/tablebuffer.cxx +++ b/sc/source/filter/oox/tablebuffer.cxx @@ -32,6 +32,7 @@ #include <oox/token/tokens.hxx> #include <addressconverter.hxx> #include <biffhelper.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -137,7 +138,7 @@ void Table::applyAutoFilters() try { // get the range ( maybe we should cache the xDatabaseRange from finalizeImport ) - PropertySet aDocProps( getDocument() ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(getDocument()) )); Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW ); Reference< XDatabaseRange > xDatabaseRange( xDatabaseRanges->getByName( maDBRangeName ), UNO_QUERY ); maAutoFilters.finalizeImport( xDatabaseRange, maModel.maRange.aStart.Tab() ); diff --git a/sc/source/filter/oox/unitconverter.cxx b/sc/source/filter/oox/unitconverter.cxx index d17f590aaee4..dd4178eee8be 100644 --- a/sc/source/filter/oox/unitconverter.cxx +++ b/sc/source/filter/oox/unitconverter.cxx @@ -33,6 +33,7 @@ #include <oox/token/properties.hxx> #include <stylesbuffer.hxx> #include <biffhelper.hxx> +#include <docuno.hxx> namespace com::sun::star::awt { struct FontDescriptor; } @@ -110,7 +111,7 @@ UnitConverter::UnitConverter( const WorkbookHelper& rHelper ) : void UnitConverter::finalizeImport() { - PropertySet aDocProps( getDocument() ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(getDocument()) )); Reference< XDevice > xDevice( aDocProps.getAnyProperty( PROP_ReferenceDevice ), UNO_QUERY ); if( !xDevice.is() ) return; diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx index c72a61b17c15..fbf28be289b3 100644 --- a/sc/source/filter/oox/viewsettings.cxx +++ b/sc/source/filter/oox/viewsettings.cxx @@ -42,6 +42,7 @@ #include <workbooksettings.hxx> #include <worksheetbuffer.hxx> #include <vcl/svapp.hxx> +#include <docuno.hxx> namespace com::sun::star::container { class XNameContainer; } @@ -600,8 +601,7 @@ void ViewSettings::finalizeImport() aPropMap.setProperty( PROP_IsOutlineSymbolsSet, rxActiveSheetView->mbShowOutline); xContainer->insertByIndex( 0, Any( aPropMap.makePropertyValueSequence() ) ); - Reference< XViewDataSupplier > xViewDataSuppl( getDocument(), UNO_QUERY_THROW ); - xViewDataSuppl->setViewData( xContainer ); + getDocument()->setViewData( xContainer ); } catch( Exception& ) { diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx index 91166cb9c478..855c7dab40b0 100644 --- a/sc/source/filter/oox/workbookhelper.cxx +++ b/sc/source/filter/oox/workbookhelper.cxx @@ -149,7 +149,7 @@ public: ScDocumentImport& getDocImport(); /** Returns a reference to the source/target spreadsheet document model. */ - const Reference< XSpreadsheetDocument >& getDocument() const { return mxDoc; } + const rtl::Reference< ScModelObj >& getDocument() const { return mxDoc; } /** Returns the cell or page styles container from the Calc document. */ Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const; /** Returns the specified cell or page style from the Calc document. */ @@ -261,7 +261,7 @@ private: OUString maPageStyles; /// Style family name for page styles. OUString maCellStyleServ; /// Service name for a cell style. OUString maPageStyleServ; /// Service name for a page style. - Reference< XSpreadsheetDocument > mxDoc; /// Document model. + rtl::Reference< ScModelObj > mxDoc; /// Document model (XSpreadsheetDocument) FilterBase& mrBaseFilter; /// Base filter object. ExcelFilter& mrExcelFilter; /// Base object for registration of this structure. ProgressBarPtr mxProgressBar; /// The progress bar. @@ -339,8 +339,7 @@ Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) Reference< XNameContainer > xStylesNC; try { - Reference< XStyleFamiliesSupplier > xFamiliesSup( mxDoc, UNO_QUERY_THROW ); - Reference< XNameAccess > xFamiliesNA( xFamiliesSup->getStyleFamilies(), UNO_SET_THROW ); + Reference< XNameAccess > xFamiliesNA( mxDoc->getStyleFamilies(), UNO_SET_THROW ); xStylesNC.set( xFamiliesNA->getByName( bPageStyles ? maPageStyles : maCellStyles ), UNO_QUERY ); } catch( Exception& ) @@ -456,7 +455,7 @@ Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString if( bValidRange && !orName.isEmpty() ) try { // find an unused name - PropertySet aDocProps( mxDoc ); + PropertySet aDocProps(( Reference< css::beans::XPropertySet >(mxDoc) )); Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW ); orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' ); // create the database range @@ -547,23 +546,16 @@ void WorkbookGlobals::initialize() meTextEnc = osl_getThreadTextEncoding(); // the spreadsheet document - mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY ); - OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" ); + mxDoc = &dynamic_cast<ScModelObj&>(*mrBaseFilter.getModel()); - if (mxDoc) - { - ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(mxDoc); - if (pModel) - mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject()); - if (mpDocShell) - mpDoc = &mpDocShell->GetDocument(); - } + mpDocShell = static_cast<ScDocShell*>(mxDoc->GetEmbeddedObject()); + if (mpDocShell) + mpDoc = &mpDocShell->GetDocument(); if (!mpDoc) throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model"); - Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY); - Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties(); + Reference< XDocumentProperties > xDocProps = mxDoc->getDocumentProperties(); const OUString aGenerator( xDocProps->getGenerator()); if (aGenerator.startsWithIgnoreAsciiCase("Microsoft")) @@ -759,7 +751,7 @@ void WorkbookHelper::finalizeWorkbookImport() } // set selected sheet and positionleft/positiontop for OLE objects - Reference<XViewDataSupplier> xViewDataSupplier(getDocument(), UNO_QUERY); + rtl::Reference<ScModelObj> xViewDataSupplier(getDocument()); if (!xViewDataSupplier.is()) return; @@ -841,7 +833,7 @@ ScEditEngineDefaulter& WorkbookHelper::getEditEngine() const return mrBookGlob.getEditEngine(); } -const Reference< XSpreadsheetDocument > & WorkbookHelper::getDocument() const +const rtl::Reference< ScModelObj > & WorkbookHelper::getDocument() const { return mrBookGlob.getDocument(); } diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx index f23afc412012..655368acf0de 100644 --- a/sc/source/filter/oox/workbooksettings.cxx +++ b/sc/source/filter/oox/workbooksettings.cxx @@ -37,6 +37,7 @@ #include <oox/token/tokens.hxx> #include <unitconverter.hxx> #include <biffhelper.hxx> +#include <docuno.hxx> namespace oox::xls { @@ -188,7 +189,7 @@ void WorkbookSettings::importCalcPr( SequenceInputStream& rStrm ) void WorkbookSettings::finalizeImport() { // default settings - PropertySet aPropSet( getDocument() ); + PropertySet aPropSet(( Reference< css::beans::XPropertySet >(getDocument()) )); aPropSet.setProperty( PROP_IgnoreCase, true ); // always in Excel aPropSet.setProperty( PROP_RegularExpressions, false ); // not supported in Excel aPropSet.setProperty( PROP_Wildcards, true ); // always in Excel @@ -240,14 +241,14 @@ void WorkbookSettings::finalizeImport() aPropSet.setProperty( PROP_CalcAsShown, !maCalcSettings.mbFullPrecision ); aPropSet.setProperty( PROP_LookUpLabels, false ); - Reference< XNumberFormatsSupplier > xNumFmtsSupp( getDocument(), UNO_QUERY ); + Reference< XNumberFormatsSupplier > xNumFmtsSupp( static_cast<cppu::OWeakObject*>(getDocument().get()), UNO_QUERY ); if( xNumFmtsSupp.is() ) { PropertySet aNumFmtProp( xNumFmtsSupp->getNumberFormatSettings() ); aNumFmtProp.setProperty( PROP_NullDate, aNullDate ); } - Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY ); + rtl::Reference< ScModelObj > xCalculatable( getDocument() ); if( xCalculatable.is() ) xCalculatable->enableAutomaticCalculation( (maCalcSettings.mnCalcMode == XML_auto) || (maCalcSettings.mnCalcMode == XML_autoNoTable) ); diff --git a/sc/source/filter/oox/worksheetbuffer.cxx b/sc/source/filter/oox/worksheetbuffer.cxx index a00f6cb6cc78..52285a75d390 100644 --- a/sc/source/filter/oox/worksheetbuffer.cxx +++ b/sc/source/filter/oox/worksheetbuffer.cxx @@ -38,6 +38,7 @@ #include <biffhelper.hxx> #include <globstr.hrc> #include <scresid.hxx> +#include <docuno.hxx> namespace oox::xls { diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index 8680179f162a..432681702738 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -124,12 +124,11 @@ public: OUString sSheetName; if( rDoc.GetName( i, sSheetName ) ) { - uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() ); - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW ); + rtl::Reference< ScModelObj > xSpreadDoc( mpDocShell->GetModel() ); uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_SET_THROW ); uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW ); uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Any > aArgs{ maWorkbook, uno::Any(xModel), uno::Any(sSheetName) }; + uno::Sequence< uno::Any > aArgs{ maWorkbook, uno::Any(uno::Reference< frame::XModel >(xSpreadDoc)), uno::Any(sSheetName) }; // use the convenience function maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); break; |