diff options
24 files changed, 217 insertions, 241 deletions
diff --git a/sw/Library_sw_writerfilter.mk b/sw/Library_sw_writerfilter.mk index deebdf1439e1..447752dabd43 100644 --- a/sw/Library_sw_writerfilter.mk +++ b/sw/Library_sw_writerfilter.mk @@ -19,6 +19,7 @@ $(eval $(call gb_Library_set_precompiled_header,sw_writerfilter,sw/inc/pch/preco $(eval $(call gb_Library_set_include,sw_writerfilter,\ $$(INCLUDE) \ + -I$(SRCDIR)/sw/inc \ -I$(SRCDIR)/sw/source/writerfilter/inc \ -I$(SRCDIR)/sw/source/writerfilter \ )) @@ -45,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,sw_writerfilter,\ sot \ svt \ svxcore \ + sw \ tl \ utl \ vcl \ diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 9b7b6f16e4d4..018784174cbb 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -224,9 +224,6 @@ private: // is implemented. bool m_bApplyPagePrintSettingsFromXPagePrintable; - using SfxBaseModel::addEventListener; - using SfxBaseModel::removeEventListener; - /** abstract SdrModel provider */ virtual SdrModel& getSdrModelFromUnoModel() const override; @@ -256,6 +253,9 @@ public: rtl::Reference< SwXBodyText > getBodyText(); virtual void SAL_CALL reformat() override; + using SfxBaseModel::addEventListener; + using SfxBaseModel::removeEventListener; + //XModel virtual sal_Bool SAL_CALL attachResource( const OUString& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override; virtual OUString SAL_CALL getURL( ) override; @@ -278,21 +278,21 @@ public: virtual void SAL_CALL close( sal_Bool bDeliverOwnership ) override; //XLineNumberingProperties - virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getLineNumberingProperties() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getLineNumberingProperties() override; //XChapterNumberingSupplier - virtual css::uno::Reference< css::container::XIndexReplace > SAL_CALL getChapterNumberingRules() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XIndexReplace > SAL_CALL getChapterNumberingRules() override; //XNumberingRulesSupplier virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getNumberingRules() override; //XFootnotesSupplier SW_DLLPUBLIC virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getFootnotes() override; - virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFootnoteSettings() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFootnoteSettings() override; //XEndnotesSupplier - virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getEndnotes() override; - virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEndnoteSettings() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getEndnotes() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEndnoteSettings() override; // XContentControlsSupplier SW_DLLPUBLIC css::uno::Reference<css::container::XIndexAccess> SAL_CALL getContentControls() override; @@ -316,8 +316,8 @@ public: virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReferenceMarks() override; // css::text::XTextFieldsSupplier - virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTextFields() override; - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFieldMasters() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTextFields() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFieldMasters() override; // css::text::XTextEmbeddedObjectsSupplier virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getEmbeddedObjects() override; @@ -329,16 +329,16 @@ public: SW_DLLPUBLIC virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextSections() override; // css::text::XTextTablesSupplier - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextTables() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextTables() override; // css::text::XTextGraphicObjectsSupplier SW_DLLPUBLIC virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGraphicObjects() override; // css::text::XTextFramesSupplier - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFrames() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFrames() override; //XStyleFamiliesSupplier - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies() override; //XAutoStylesSupplier virtual css::uno::Reference< css::style::XAutoStyles > SAL_CALL getAutoStyles( ) override; @@ -361,11 +361,11 @@ public: virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getDrawPages() override; // css::text::XDocumentIndexesSupplier - virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getDocumentIndexes() override; + SW_DLLPUBLIC virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getDocumentIndexes() override; //XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; - virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + SW_DLLPUBLIC virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; SW_DLLPUBLIC virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index 22a2a17045c0..16106cf0e5d5 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -91,6 +91,7 @@ #include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <tools/UnitConversion.hxx> +#include <unotxdoc.hxx> using namespace ::com::sun::star; using namespace oox; @@ -107,7 +108,7 @@ struct DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xContext, uno::Reference<io::XInputStream> const& xInputStream, - uno::Reference<lang::XComponent> const& xModel, + rtl::Reference<SwXTextDocument> const& xModel, bool bRepairStorage, SourceDocumentType eDocumentType, utl::MediaDescriptor const & rMediaDesc) : @@ -149,14 +150,15 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon // Initialize RDF metadata, to be able to add statements during the import. try { - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel, uno::UNO_QUERY_THROW); - uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage(); - OUString aBaseURL = rMediaDesc.getUnpackedValueOrDefault("URL", OUString()); - const uno::Reference<frame::XModel> xModel_(xModel, - uno::UNO_QUERY_THROW); - const uno::Reference<rdf::XURI> xBaseURI(sfx2::createBaseURI(xContext, xModel_, aBaseURL, u"")); - const uno::Reference<task::XInteractionHandler> xHandler; - xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); + if (xModel) + { + uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage(); + OUString aBaseURL = rMediaDesc.getUnpackedValueOrDefault("URL", OUString()); + const uno::Reference<frame::XModel> xModel_(static_cast<SfxBaseModel*>(xModel.get())); + const uno::Reference<rdf::XURI> xBaseURI(sfx2::createBaseURI(xContext, xModel_, aBaseURL, u"")); + const uno::Reference<task::XInteractionHandler> xHandler; + xModel->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); + } } catch (const uno::Exception&) { @@ -192,9 +194,9 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon xContext); uno::Reference< document::XOOXMLDocumentPropertiesImporter > xImporter( xTemp, uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xPropSupplier( xModel, uno::UNO_QUERY_THROW); - xImporter->importProperties(m_pImpl->m_xDocumentStorage, - xPropSupplier->getDocumentProperties()); + if (xModel) + xImporter->importProperties(m_pImpl->m_xDocumentStorage, + xModel->getDocumentProperties()); } catch( const uno::Exception& ) {} } @@ -211,18 +213,13 @@ DomainMapper::~DomainMapper() // Remove temporary footnotes and endnotes m_pImpl->RemoveTemporaryFootOrEndnotes(); - uno::Reference< text::XDocumentIndexesSupplier> xIndexesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY ); sal_Int32 nIndexes = 0; - if( xIndexesSupplier.is() ) - { - uno::Reference< container::XIndexAccess > xIndexes = xIndexesSupplier->getDocumentIndexes(); - nIndexes = xIndexes->getCount(); - } + if ( m_pImpl->GetTextDocument() ) + nIndexes = m_pImpl->GetTextDocument()->getDocumentIndexes()->getCount(); // If we have page references, those need updating as well, similar to the indexes. - uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(m_pImpl->GetTextDocument(), uno::UNO_QUERY); - if(xTextFieldsSupplier.is()) + if ( m_pImpl->GetTextDocument() ) { - uno::Reference<container::XEnumeration> xEnumeration = xTextFieldsSupplier->getTextFields()->createEnumeration(); + uno::Reference<container::XEnumeration> xEnumeration = m_pImpl->GetTextDocument()->getTextFields()->createEnumeration(); while(xEnumeration->hasMoreElements()) { ++nIndexes; @@ -231,12 +228,10 @@ DomainMapper::~DomainMapper() } mbHasControls |= m_pImpl->m_pSdtHelper->hasElements(); - if ( nIndexes || mbHasControls ) + if ( (nIndexes || mbHasControls) && m_pImpl->GetTextDocument()) { //index update has to wait until first view is created - uno::Reference< document::XEventBroadcaster > xBroadcaster(xIndexesSupplier, uno::UNO_QUERY); - if (xBroadcaster.is()) - xBroadcaster->addEventListener(uno::Reference< document::XEventListener >(new ModelEventListener(nIndexes, mbHasControls))); + m_pImpl->GetTextDocument()->addEventListener(uno::Reference< document::XEventListener >(new ModelEventListener(nIndexes, mbHasControls))); } @@ -261,14 +256,12 @@ DomainMapper::~DomainMapper() // Add the saved w:doNotHyphenateCaps setting aProperties["NoHyphenateCaps"] <<= m_pImpl->GetSettingsTable()->GetNoHyphenateCaps(); - uno::Reference<beans::XPropertySet> xDocProps(m_pImpl->GetTextDocument(), uno::UNO_QUERY); - if (xDocProps.is()) + if (m_pImpl->GetTextDocument()) { - comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue("InteropGrabBag")); + comphelper::SequenceAsHashMap aGrabBag(m_pImpl->GetTextDocument()->getPropertyValue("InteropGrabBag")); aGrabBag.update(aProperties); - xDocProps->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList())); + m_pImpl->GetTextDocument()->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList())); } - // tdf#138782: for docs created in MS Word 2010 and older (compatibilityMode <= 14) m_pImpl->SetDocumentSettingsProperty( "AddFrameOffsets", @@ -1404,19 +1397,12 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) try { uno::Reference<beans::XPropertySet> xFtnEdnSettings; - if (m_pImpl->IsInFootnoteProperties()) - { - uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier( - m_pImpl->GetTextDocument(), uno::UNO_QUERY); - if (xFootnotesSupplier.is()) - xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings(); - } - else + if (m_pImpl->GetTextDocument()) { - uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier( - m_pImpl->GetTextDocument(), uno::UNO_QUERY); - if (xEndnotesSupplier.is()) - xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings(); + if (m_pImpl->IsInFootnoteProperties()) + xFtnEdnSettings = m_pImpl->GetTextDocument()->getFootnoteSettings(); + else + xFtnEdnSettings = m_pImpl->GetTextDocument()->getEndnoteSettings(); } if (xFtnEdnSettings.is()) { @@ -2453,11 +2439,12 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) resolveSprmProps(*this, rSprm); LineNumberSettings aSettings = m_pImpl->GetLineNumberSettings(); m_pImpl->SetLineNumberSettings( aSettings ); + if (!m_pImpl->GetTextDocument()) + break; //apply settings at XLineNumberingProperties try { - uno::Reference< text::XLineNumberingProperties > xLineNumberingProperties( m_pImpl->GetTextDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xLineNumberingPropSet = xLineNumberingProperties->getLineNumberingProperties(); + uno::Reference< beans::XPropertySet > xLineNumberingPropSet = m_pImpl->GetTextDocument()->getLineNumberingProperties(); if( aSettings.nInterval == 0 ) xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_IS_ON ), uno::Any(false) ); else @@ -2804,17 +2791,12 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) try { uno::Reference< beans::XPropertySet > xFtnEdnSettings; - if( m_pImpl->IsInFootnoteProperties() ) + if (m_pImpl->GetTextDocument()) { - uno::Reference< text::XFootnotesSupplier> xFootnotesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY ); - if (xFootnotesSupplier.is()) - xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings(); - } - else - { - uno::Reference< text::XEndnotesSupplier> xEndnotesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY ); - if (xEndnotesSupplier.is()) - xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings(); + if( m_pImpl->IsInFootnoteProperties() ) + xFtnEdnSettings = m_pImpl->GetTextDocument()->getFootnoteSettings(); + else + xFtnEdnSettings = m_pImpl->GetTextDocument()->getEndnoteSettings(); } if( NS_ooxml::LN_EG_FtnEdnNumProps_numStart == nSprmId && xFtnEdnSettings.is()) { diff --git a/sw/source/writerfilter/dmapper/DomainMapper.hxx b/sw/source/writerfilter/dmapper/DomainMapper.hxx index 9d9771e640f5..de43478bae7f 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.hxx @@ -24,11 +24,13 @@ #include "SettingsTable.hxx" #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/style/TabAlign.hpp> +#include <rtl/ref.hxx> #include <map> #include <vector> #include <memory> +class SwXTextDocument; namespace com::sun::star{ namespace beans{ struct PropertyValue; @@ -73,7 +75,7 @@ class DomainMapper : public LoggedProperties, public LoggedTable, public: DomainMapper(const css::uno::Reference<css::uno::XComponentContext>& xContext, css::uno::Reference<css::io::XInputStream> const& xInputStream, - css::uno::Reference<css::lang::XComponent> const& xModel, + rtl::Reference<SwXTextDocument> const& xModel, bool bRepairStorage, SourceDocumentType eDocumentType, utl::MediaDescriptor const & rMediaDesc); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 6e65750dec1e..2a4f3052df81 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -131,6 +131,7 @@ #include <unicode/errorcode.h> #include <unicode/regex.h> +#include <unotxdoc.hxx> #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200 @@ -325,14 +326,14 @@ static bool IsFieldNestingAllowed(const FieldContextPtr& pOuter, const FieldCont DomainMapper_Impl::DomainMapper_Impl( DomainMapper& rDMapper, uno::Reference<uno::XComponentContext> xContext, - uno::Reference<lang::XComponent> const& xModel, + rtl::Reference<SwXTextDocument> const& xModel, SourceDocumentType eDocumentType, utl::MediaDescriptor const & rMediaDesc) : m_eDocumentType( eDocumentType ), m_rDMapper( rDMapper ), m_pOOXMLDocument(nullptr), - m_xTextDocument( xModel, uno::UNO_QUERY ), - m_xTextFactory( xModel, uno::UNO_QUERY ), + m_xTextDocument( xModel ), + m_xTextFactory( xModel ), m_xComponentContext(std::move( xContext )), m_bForceGenericFields(officecfg::Office::Common::Filter::Microsoft::Import::ForceImportWWFieldsAsGenericFields::get()), m_bIsDecimalComma( false ), @@ -438,12 +439,8 @@ writerfilter::ooxml::OOXMLDocument* DomainMapper_Impl::getDocumentReference() co uno::Reference< container::XNameContainer > const & DomainMapper_Impl::GetPageStyles() { - if(!m_xPageStyles1.is()) - { - uno::Reference< style::XStyleFamiliesSupplier > xSupplier( m_xTextDocument, uno::UNO_QUERY ); - if (xSupplier.is()) - xSupplier->getStyleFamilies()->getByName("PageStyles") >>= m_xPageStyles1; - } + if(!m_xPageStyles1.is() && m_xTextDocument) + m_xTextDocument->getStyleFamilies()->getByName("PageStyles") >>= m_xPageStyles1; return m_xPageStyles1; } @@ -476,23 +473,15 @@ OUString DomainMapper_Impl::GetUnusedPageStyleName() uno::Reference< container::XNameContainer > const & DomainMapper_Impl::GetCharacterStyles() { - if(!m_xCharacterStyles.is()) - { - uno::Reference< style::XStyleFamiliesSupplier > xSupplier( m_xTextDocument, uno::UNO_QUERY ); - if (xSupplier.is()) - xSupplier->getStyleFamilies()->getByName("CharacterStyles") >>= m_xCharacterStyles; - } + if(!m_xCharacterStyles.is() && m_xTextDocument) + m_xTextDocument->getStyleFamilies()->getByName("CharacterStyles") >>= m_xCharacterStyles; return m_xCharacterStyles; } uno::Reference<container::XNameContainer> const& DomainMapper_Impl::GetParagraphStyles() { - if (!m_xParagraphStyles.is()) - { - uno::Reference<style::XStyleFamiliesSupplier> xSupplier(m_xTextDocument, uno::UNO_QUERY); - if (xSupplier.is()) - xSupplier->getStyleFamilies()->getByName("ParagraphStyles") >>= m_xParagraphStyles; - } + if (!m_xParagraphStyles.is() && m_xTextDocument) + m_xTextDocument->getStyleFamilies()->getByName("ParagraphStyles") >>= m_xParagraphStyles; return m_xParagraphStyles; } @@ -836,22 +825,22 @@ void DomainMapper_Impl::RemoveLastParagraph( ) (sizeof(SAL_NEWLINE_STRING) - 1 == 2 && xCursor->getString() == "\n"))) return; - uno::Reference<beans::XPropertySet> xDocProps(GetTextDocument(), uno::UNO_QUERY_THROW); + if (!m_xTextDocument) + return; + static constexpr OUString RecordChanges(u"RecordChanges"_ustr); comphelper::ScopeGuard redlineRestore( - [xDocProps, aPreviousValue = xDocProps->getPropertyValue(RecordChanges)]() - { xDocProps->setPropertyValue(RecordChanges, aPreviousValue); }); + [this, aPreviousValue = m_xTextDocument->getPropertyValue(RecordChanges)]() + { m_xTextDocument->setPropertyValue(RecordChanges, aPreviousValue); }); // disable redlining, otherwise we might end up with an unwanted recorded operations - xDocProps->setPropertyValue(RecordChanges, uno::Any(false)); + m_xTextDocument->setPropertyValue(RecordChanges, uno::Any(false)); if (xParagraph) { // move all anchored objects to the previous paragraph - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(GetTextDocument(), - uno::UNO_QUERY_THROW); - auto xDrawPage = xDrawPageSupplier->getDrawPage(); + auto xDrawPage = m_xTextDocument->getDrawPage(); if (xDrawPage && xDrawPage->hasElements()) { // Cursor already spans two paragraphs @@ -4381,12 +4370,11 @@ bool DomainMapper_Impl::CopyTemporaryNotes( void DomainMapper_Impl::RemoveTemporaryFootOrEndnotes() { - uno::Reference< text::XFootnotesSupplier> xFootnotesSupplier( GetTextDocument(), uno::UNO_QUERY ); - uno::Reference< text::XEndnotesSupplier> xEndnotesSupplier( GetTextDocument(), uno::UNO_QUERY ); + rtl::Reference< SwXTextDocument> xTextDoc( GetTextDocument() ); uno::Reference< text::XFootnote > xNote; if (GetFootnoteCount() > 0) { - auto xFootnotes = xFootnotesSupplier->getFootnotes(); + auto xFootnotes = xTextDoc->getFootnotes(); if ( m_nFirstFootnoteIndex > 0 ) { uno::Reference< text::XFootnote > xFirstNote; @@ -4404,7 +4392,7 @@ void DomainMapper_Impl::RemoveTemporaryFootOrEndnotes() } if (GetEndnoteCount() > 0) { - auto xEndnotes = xEndnotesSupplier->getEndnotes(); + auto xEndnotes = xTextDoc->getEndnotes(); if ( m_nFirstEndnoteIndex > 0 ) { uno::Reference< text::XFootnote > xFirstNote; @@ -4450,15 +4438,13 @@ void DomainMapper_Impl::PopFootOrEndnote() // content of the footnotes were inserted after the first footnote in temporary footnotes, // restore the content of the actual footnote by copying its content from the first // (remaining) temporary footnote and remove the temporary footnote. - uno::Reference< text::XFootnotesSupplier> xFootnotesSupplier( GetTextDocument(), uno::UNO_QUERY ); - uno::Reference< text::XEndnotesSupplier> xEndnotesSupplier( GetTextDocument(), uno::UNO_QUERY ); bool bCopied = false; - if ( IsInFootOrEndnote() && ( ( IsInFootnote() && GetFootnoteCount() > -1 && xFootnotesSupplier.is() ) || - ( !IsInFootnote() && GetEndnoteCount() > -1 && xEndnotesSupplier.is() ) ) ) + if ( m_xTextDocument && IsInFootOrEndnote() && ( ( IsInFootnote() && GetFootnoteCount() > -1 ) || + ( !IsInFootnote() && GetEndnoteCount() > -1 ) ) ) { uno::Reference< text::XFootnote > xNoteFirst, xNoteLast; - auto xFootnotes = xFootnotesSupplier->getFootnotes(); - auto xEndnotes = xEndnotesSupplier->getEndnotes(); + auto xFootnotes = m_xTextDocument->getFootnotes(); + auto xEndnotes = m_xTextDocument->getEndnotes(); if ( ( ( IsInFootnote() && xFootnotes->getCount() > 1 && ( xFootnotes->getByIndex(xFootnotes->getCount()-1) >>= xNoteLast ) ) || ( !IsInFootnote() && xEndnotes->getCount() > 1 && @@ -4943,12 +4929,11 @@ void DomainMapper_Impl::PopShapeContext() const uno::Reference<drawing::XShape> xShape( xObj, uno::UNO_QUERY_THROW ); // Remove the shape if required (most likely replacement shape for OLE object) // or anchored to a discarded header or footer - if ( m_aAnchoredStack.top().bToRemove || m_bDiscardHeaderFooter ) + if ( m_xTextDocument && (m_aAnchoredStack.top().bToRemove || m_bDiscardHeaderFooter) ) { try { - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(m_xTextDocument, uno::UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XDrawPage> xDrawPage = m_xTextDocument->getDrawPage(); if ( xDrawPage.is() ) xDrawPage->remove( xShape ); } @@ -5046,7 +5031,7 @@ void DomainMapper_Impl::HandleAltChunk(const OUString& rStreamName) // Set the target document. uno::Reference<document::XImporter> xImporter(xDocxFilter, uno::UNO_QUERY); - xImporter->setTargetDocument(m_xTextDocument); + xImporter->setTargetDocument(static_cast<SfxBaseModel*>(m_xTextDocument.get())); // Set the import parameters. uno::Reference<embed::XHierarchicalStorageAccess> xStorageAccess(m_xDocumentStorage, @@ -5598,7 +5583,7 @@ void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand, try { sal_Int32 nKey = 0; - uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( m_xTextDocument, uno::UNO_QUERY_THROW ); + uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( static_cast<cppu::OWeakObject*>(m_xTextDocument.get()), uno::UNO_QUERY_THROW ); if( bDetectFormat ) { uno::Reference< util::XNumberFormatter> xFormatter(util::NumberFormatter::create(m_xComponentContext), uno::UNO_QUERY_THROW); @@ -5930,8 +5915,9 @@ void DomainMapper_Impl::AttachTextBoxContentToShape(css::uno::Reference<css::dra uno::Reference<beans::XPropertySet> DomainMapper_Impl::FindOrCreateFieldMaster(const char* pFieldMasterService, const OUString& rFieldMasterName) { // query master, create if not available - uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier( GetTextDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters(); + if (!m_xTextDocument) + throw uno::RuntimeException(); + uno::Reference< container::XNameAccess > xFieldMasterAccess = m_xTextDocument->getTextFieldMasters(); uno::Reference< beans::XPropertySet > xMaster; OUString sFieldMasterService( OUString::createFromAscii(pFieldMasterService) ); OUStringBuffer aFieldMasterName; @@ -6698,8 +6684,7 @@ void DomainMapper_Impl::handleAuthor //Lines, Manager, NameofApplication, ODMADocId, Pages, //Security, }; - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(m_xTextDocument, uno::UNO_QUERY); - uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); + uno::Reference<document::XDocumentProperties> xDocumentProperties = m_xTextDocument->getDocumentProperties(); uno::Reference<beans::XPropertySet> xUserDefinedProps(xDocumentProperties->getUserDefinedProperties(), uno::UNO_QUERY_THROW); uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xUserDefinedProps->getPropertySetInfo(); //search for a field mapping @@ -7157,12 +7142,12 @@ void DomainMapper_Impl::handleToc } uno::Reference<container::XIndexAccess> xChapterNumberingRules; - if (auto xSupplier = GetTextDocument().query<text::XChapterNumberingSupplier>()) - xChapterNumberingRules = xSupplier->getChapterNumberingRules(); + if (m_xTextDocument) + xChapterNumberingRules = m_xTextDocument->getChapterNumberingRules(); uno::Reference<container::XNameContainer> xStyles; - if (auto xStylesSupplier = GetTextDocument().query<style::XStyleFamiliesSupplier>()) + if (m_xTextDocument) { - auto xStyleFamilies = xStylesSupplier->getStyleFamilies(); + auto xStyleFamilies = m_xTextDocument->getStyleFamilies(); xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) >>= xStyles; } @@ -7994,8 +7979,7 @@ void DomainMapper_Impl::CloseFieldCommand() bool bStyleRef = aIt->second.eFieldId == FIELD_STYLEREF; // Do we need a GetReference (default) or a GetExpression field? - uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier( GetTextDocument(), uno::UNO_QUERY ); - uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters(); + uno::Reference< container::XNameAccess > xFieldMasterAccess = GetTextDocument()->getTextFieldMasters(); if (!xFieldMasterAccess->hasByName( "com.sun.star.text.FieldMaster.SetExpression." @@ -8012,10 +7996,8 @@ void DomainMapper_Impl::CloseFieldCommand() uno::Any aStyleDisplayName; - uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier( - GetTextDocument(), uno::UNO_QUERY_THROW); uno::Reference<container::XNameAccess> xStyleFamilies - = xStylesSupplier->getStyleFamilies(); + = GetTextDocument()->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyles; xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) >>= xStyles; @@ -8555,7 +8537,7 @@ void DomainMapper_Impl::SetFieldResult(OUString const& rResult) } else if (pContext->m_bSetDateValue) { - uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( m_xTextDocument, uno::UNO_QUERY_THROW ); + uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( static_cast<cppu::OWeakObject*>(m_xTextDocument.get()), uno::UNO_QUERY_THROW ); uno::Reference<util::XNumberFormatter> xFormatter(util::NumberFormatter::create(m_xComponentContext), uno::UNO_QUERY_THROW); xFormatter->attachNumberFormatsSupplier( xNumberSupplier ); @@ -9332,12 +9314,13 @@ void DomainMapper_Impl::ImportGraphic(const writerfilter::Reference<Properties> void DomainMapper_Impl::SetLineNumbering( sal_Int32 nLnnMod, sal_uInt32 nLnc, sal_Int32 ndxaLnn ) { + if (!m_xTextDocument) + throw uno::RuntimeException(); if( !m_bLineNumberingSet ) { try { - uno::Reference< text::XLineNumberingProperties > xLineProperties( m_xTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProperties = xLineProperties->getLineNumberingProperties(); + uno::Reference< beans::XPropertySet > xProperties = m_xTextDocument->getLineNumberingProperties(); uno::Any aTrue( uno::Any( true )); xProperties->setPropertyValue( getPropertyName( PROP_IS_ON ), aTrue); xProperties->setPropertyValue( getPropertyName( PROP_COUNT_EMPTY_LINES ), aTrue ); @@ -9352,8 +9335,7 @@ void DomainMapper_Impl::SetLineNumbering( sal_Int32 nLnnMod, sal_uInt32 nLnc, sa {} } m_bLineNumberingSet = true; - uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier( GetTextDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies(); + uno::Reference< container::XNameAccess > xStyleFamilies = m_xTextDocument->getStyleFamilies(); uno::Reference<container::XNameContainer> xStyles; xStyleFamilies->getByName(getPropertyName( PROP_PARAGRAPH_STYLES )) >>= xStyles; lcl_linenumberingHeaderFooter( xStyles, "Header", this ); @@ -9608,8 +9590,7 @@ void DomainMapper_Impl::ApplySettingsTable() } rtl::Reference< comphelper::IndexedPropertyValuesContainer > xBox = new comphelper::IndexedPropertyValuesContainer(); xBox->insertByIndex(sal_Int32(0), uno::Any(comphelper::containerToSequence(aViewProps))); - uno::Reference<document::XViewDataSupplier> xViewDataSupplier(m_xTextDocument, uno::UNO_QUERY); - xViewDataSupplier->setViewData(xBox); + m_xTextDocument->setViewData(xBox); } uno::Reference< beans::XPropertySet > xSettings(m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); @@ -9683,6 +9664,8 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const sal_Int32 nListId, sal_I sal_Int32 nRet = 0; if ( nListId < 0 ) return nRet; + if ( !m_xTextDocument ) + return nRet; try { @@ -9692,8 +9675,7 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const sal_Int32 nListId, sal_I auto const pList(GetListTable()->GetList(nListId)); assert(pList); const OUString aListName = pList->GetStyleName(); - const uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY_THROW); - const uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies(); + const uno::Reference< container::XNameAccess > xStyleFamilies = m_xTextDocument->getStyleFamilies(); uno::Reference<container::XNameAccess> xNumberingStyles; xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles; const uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx index 94ab42de3f98..79c4cc8e8f3c 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx @@ -55,6 +55,8 @@ #include "FormControlHelper.hxx" #include <map> +class SwXTextDocument; + namespace com::sun::star{ namespace awt{ struct Size; @@ -532,7 +534,7 @@ private: DomainMapper& m_rDMapper; writerfilter::ooxml::OOXMLDocument* m_pOOXMLDocument; OUString m_aBaseUrl; - css::uno::Reference<css::text::XTextDocument> m_xTextDocument; + rtl::Reference<SwXTextDocument> m_xTextDocument; css::uno::Reference<css::beans::XPropertySet> m_xDocumentSettings; css::uno::Reference<css::lang::XMultiServiceFactory> m_xTextFactory; css::uno::Reference<css::uno::XComponentContext> m_xComponentContext; @@ -693,7 +695,7 @@ public: DomainMapper_Impl( DomainMapper& rDMapper, css::uno::Reference < css::uno::XComponentContext > xContext, - css::uno::Reference< css::lang::XComponent > const& xModel, + rtl::Reference< SwXTextDocument > const& xModel, SourceDocumentType eDocumentType, utl::MediaDescriptor const & rMediaDesc); ~DomainMapper_Impl(); @@ -716,7 +718,7 @@ public: { return m_xTextFactory; } - const css::uno::Reference<css::text::XTextDocument>& GetTextDocument() const + const rtl::Reference<SwXTextDocument>& GetTextDocument() const { return m_xTextDocument; } diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index 3e836f831e63..fd683b5d455b 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -65,6 +65,7 @@ #include "PropertyMapHelper.hxx" #include <o3tl/sorted_vector.hxx> #include <o3tl/unit_conversion.hxx> +#include <unotxdoc.hxx> #include <utility> #include <frozen/bits/defines.h> @@ -1199,31 +1200,27 @@ void SectionPropertyMap::HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl) // Set footnote line width to zero, document has no footnote separator. Insert(PROP_FOOTNOTE_LINE_RELATIVE_WIDTH, uno::Any(sal_Int32(0))); } - if ( rDM_Impl.m_bHasFtnSep ) + if ( rDM_Impl.m_bHasFtnSep && rDM_Impl.GetTextDocument() ) { //If default paragraph style is RTL, footnote separator should be right aligned //and for RTL locales, LTR default paragraph style should present a left aligned footnote separator try { - uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier(rDM_Impl.GetTextDocument(), uno::UNO_QUERY); - if ( xStylesSupplier.is() ) + uno::Reference<container::XNameAccess> xStyleFamilies = rDM_Impl.GetTextDocument()->getStyleFamilies(); + uno::Reference<container::XNameAccess> xParagraphStyles; + if ( xStyleFamilies.is() ) + xStyleFamilies->getByName("ParagraphStyles") >>= xParagraphStyles; + uno::Reference<beans::XPropertySet> xStandard; + if ( xParagraphStyles.is() ) + xParagraphStyles->getByName("Standard") >>= xStandard; + if ( xStandard.is() ) { - uno::Reference<container::XNameAccess> xStyleFamilies = xStylesSupplier->getStyleFamilies(); - uno::Reference<container::XNameAccess> xParagraphStyles; - if ( xStyleFamilies.is() ) - xStyleFamilies->getByName("ParagraphStyles") >>= xParagraphStyles; - uno::Reference<beans::XPropertySet> xStandard; - if ( xParagraphStyles.is() ) - xParagraphStyles->getByName("Standard") >>= xStandard; - if ( xStandard.is() ) - { - sal_Int16 aWritingMode(0); - xStandard->getPropertyValue( getPropertyName(PROP_WRITING_MODE) ) >>= aWritingMode; - if( aWritingMode == text::WritingMode2::RL_TB ) - Insert( PROP_FOOTNOTE_LINE_ADJUST, uno::Any( sal_Int16(text::HorizontalAdjust_RIGHT) ), false ); - else - Insert( PROP_FOOTNOTE_LINE_ADJUST, uno::Any( sal_Int16(text::HorizontalAdjust_LEFT) ), false ); - } + sal_Int16 aWritingMode(0); + xStandard->getPropertyValue( getPropertyName(PROP_WRITING_MODE) ) >>= aWritingMode; + if( aWritingMode == text::WritingMode2::RL_TB ) + Insert( PROP_FOOTNOTE_LINE_ADJUST, uno::Any( sal_Int16(text::HorizontalAdjust_RIGHT) ), false ); + else + Insert( PROP_FOOTNOTE_LINE_ADJUST, uno::Any( sal_Int16(text::HorizontalAdjust_LEFT) ), false ); } } catch ( const uno::Exception& ) {} @@ -1420,7 +1417,7 @@ void BeforeConvertToTextFrame(std::deque<css::uno::Any>& rFramedRedlines, std::v void AfterConvertToTextFrame(DomainMapper_Impl& rDM_Impl, std::deque<css::uno::Any>& aFramedRedlines, std::vector<sal_Int32>& redPos, std::vector<sal_Int32>& redLen, std::vector<OUString>& redCell, std::vector<OUString>& redTable) { - uno::Reference<text::XTextTablesSupplier> xTextDocument(rDM_Impl.GetTextDocument(), uno::UNO_QUERY); + rtl::Reference<SwXTextDocument> xTextDocument(rDM_Impl.GetTextDocument()); uno::Reference<container::XNameAccess> xTables = xTextDocument->getTextTables(); for( size_t i = 0; i < aFramedRedlines.size(); i+=3) { @@ -1824,10 +1821,11 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) // refer to ww8 import process function "SwWW8ImplReader::SetDocumentGrid" try { - uno::Reference< beans::XPropertySet > xDocProperties; - xDocProperties.set( rDM_Impl.GetTextDocument(), uno::UNO_QUERY_THROW ); - Insert(PROP_GRID_STANDARD_MODE, uno::Any(true)); - xDocProperties->setPropertyValue("DefaultPageMode", uno::Any(false)); + if (rDM_Impl.GetTextDocument()) + { + Insert(PROP_GRID_STANDARD_MODE, uno::Any(true)); + rDM_Impl.GetTextDocument()->setPropertyValue("DefaultPageMode", uno::Any(false)); + } } catch ( const uno::Exception& ) { diff --git a/sw/source/writerfilter/dmapper/SdtHelper.cxx b/sw/source/writerfilter/dmapper/SdtHelper.cxx index 09e7903b5f98..8d9ffb956f24 100644 --- a/sw/source/writerfilter/dmapper/SdtHelper.cxx +++ b/sw/source/writerfilter/dmapper/SdtHelper.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/xml/xpath/XPathAPI.hpp> #include <com/sun/star/xml/xpath/XPathException.hpp> #include <com/sun/star/xml/dom/DocumentBuilder.hpp> +#include <unotxdoc.hxx> namespace writerfilter::dmapper { @@ -506,9 +507,7 @@ void SdtHelper::createDateContentControl() xNameCont->insertByName(ODF_FORMDATE_CURRENTDATE, uno::Any(sFullDate)); } - uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(m_rDM_Impl.GetTextDocument(), - uno::UNO_QUERY); - uno::Reference<util::XRefreshable> xRefreshable(xTextFieldsSupplier->getTextFields(), + uno::Reference<util::XRefreshable> xRefreshable(m_rDM_Impl.GetTextDocument()->getTextFields(), uno::UNO_QUERY); xRefreshable->refresh(); diff --git a/sw/source/writerfilter/dmapper/SmartTagHandler.cxx b/sw/source/writerfilter/dmapper/SmartTagHandler.cxx index c92fa7c44be5..7f9d9303f081 100644 --- a/sw/source/writerfilter/dmapper/SmartTagHandler.cxx +++ b/sw/source/writerfilter/dmapper/SmartTagHandler.cxx @@ -18,6 +18,7 @@ #include <ooxml/resourceids.hxx> #include <sal/log.hxx> +#include <unotxdoc.hxx> namespace { @@ -38,10 +39,10 @@ namespace writerfilter::dmapper using namespace ::com::sun::star; SmartTagHandler::SmartTagHandler(uno::Reference<uno::XComponentContext> xComponentContext, - const uno::Reference<text::XTextDocument>& xTextDocument) + const rtl::Reference<SwXTextDocument>& xTextDocument) : LoggedProperties("SmartTagHandler") , m_xComponentContext(std::move(xComponentContext)) - , m_xDocumentMetadataAccess(xTextDocument, uno::UNO_QUERY) + , m_xDocumentMetadataAccess(xTextDocument) { } diff --git a/sw/source/writerfilter/dmapper/SmartTagHandler.hxx b/sw/source/writerfilter/dmapper/SmartTagHandler.hxx index 7999b9dcc22a..47d224e39349 100644 --- a/sw/source/writerfilter/dmapper/SmartTagHandler.hxx +++ b/sw/source/writerfilter/dmapper/SmartTagHandler.hxx @@ -11,7 +11,9 @@ #include <vector> #include "LoggedResources.hxx" +#include <rtl/ref.hxx> +class SwXTextDocument; namespace com::sun::star { namespace rdf @@ -42,7 +44,7 @@ class SmartTagHandler : public LoggedProperties public: SmartTagHandler(css::uno::Reference<css::uno::XComponentContext> xComponentContext, - const css::uno::Reference<css::text::XTextDocument>& xTextDocument); + const rtl::Reference<SwXTextDocument>& xTextDocument); ~SmartTagHandler() override; void lcl_attribute(Id nId, Value& rValue) override; diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 1b5633b009fd..dc678e065aa9 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -52,6 +52,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/diagnose_ex.hxx> #include <o3tl/sorted_vector.hxx> +#include <unotxdoc.hxx> using namespace ::com::sun::star; @@ -271,7 +272,7 @@ struct ListCharStylePropertyMap_t struct StyleSheetTable_Impl { DomainMapper& m_rDMapper; - uno::Reference< text::XTextDocument> m_xTextDocument; + rtl::Reference<SwXTextDocument> m_xTextDocument; uno::Reference< beans::XPropertySet> m_xTextDefaults; std::vector< StyleSheetEntryPtr > m_aStyleSheetEntries; std::map< OUString, StyleSheetEntryPtr > m_aStyleSheetEntriesMap; @@ -283,7 +284,7 @@ struct StyleSheetTable_Impl bool m_bHasImportedDefaultParaProps; bool m_bIsNewDoc; - StyleSheetTable_Impl(DomainMapper& rDMapper, uno::Reference< text::XTextDocument> xTextDocument, bool bIsNewDoc); + StyleSheetTable_Impl(DomainMapper& rDMapper, rtl::Reference<SwXTextDocument> xTextDocument, bool bIsNewDoc); OUString HasListCharStyle( const PropertyValueVector_t& rCharProperties ); @@ -296,7 +297,7 @@ struct StyleSheetTable_Impl StyleSheetTable_Impl::StyleSheetTable_Impl(DomainMapper& rDMapper, - uno::Reference< text::XTextDocument> xTextDocument, + rtl::Reference< SwXTextDocument> xTextDocument, bool const bIsNewDoc) : m_rDMapper( rDMapper ), m_xTextDocument(std::move( xTextDocument )), @@ -383,7 +384,7 @@ void StyleSheetTable_Impl::SetPropertiesToDefault(const uno::Reference<style::XS } StyleSheetTable::StyleSheetTable(DomainMapper& rDMapper, - uno::Reference< text::XTextDocument> const& xTextDocument, + rtl::Reference< SwXTextDocument> const& xTextDocument, bool const bIsNewDoc) : LoggedProperties("StyleSheetTable") , LoggedTable("StyleSheetTable") @@ -840,13 +841,12 @@ void StyleSheetTable::lcl_entry(const writerfilter::Reference<Properties>::Point // We can put all latent style info directly to the document interop // grab bag, as we can be sure that only a single style entry has // latent style info. - uno::Reference<beans::XPropertySet> xPropertySet(m_pImpl->m_xTextDocument, uno::UNO_QUERY); - auto aGrabBag = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(xPropertySet->getPropertyValue("InteropGrabBag").get< uno::Sequence<beans::PropertyValue> >()); + auto aGrabBag = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(m_pImpl->m_xTextDocument->getPropertyValue("InteropGrabBag").get< uno::Sequence<beans::PropertyValue> >()); beans::PropertyValue aValue; aValue.Name = "latentStyles"; aValue.Value <<= aLatentStyles; aGrabBag.push_back(aValue); - xPropertySet->setPropertyValue("InteropGrabBag", uno::Any(comphelper::containerToSequence(aGrabBag))); + m_pImpl->m_xTextDocument->setPropertyValue("InteropGrabBag", uno::Any(comphelper::containerToSequence(aGrabBag))); } m_pImpl->m_pCurrentEntry = StyleSheetEntryPtr(); @@ -900,11 +900,11 @@ uno::Sequence< OUString > PropValVector::getNames() void StyleSheetTable::ApplyNumberingStyleNameToParaStyles() { + if (!m_pImpl->m_xTextDocument) + return; try { - uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< lang::XMultiServiceFactory > xDocFactory( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies(); + uno::Reference< container::XNameAccess > xStyleFamilies = m_pImpl->m_xTextDocument->getStyleFamilies(); uno::Reference<container::XNameContainer> xParaStyles; xStyleFamilies->getByName(getPropertyName( PROP_PARAGRAPH_STYLES )) >>= xParaStyles; @@ -954,11 +954,11 @@ void StyleSheetTable::ApplyNumberingStyleNameToParaStyles() */ void StyleSheetTable::ReApplyInheritedOutlineLevelFromChapterNumbering() { + if (!m_pImpl->m_xTextDocument) + return; try { - uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW); - uno::Reference< lang::XMultiServiceFactory > xDocFactory(m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies(); + uno::Reference< container::XNameAccess > xStyleFamilies = m_pImpl->m_xTextDocument->getStyleFamilies(); uno::Reference<container::XNameContainer> xParaStyles; xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) >>= xParaStyles; @@ -1059,8 +1059,9 @@ void StyleSheetTable::ApplyClonedTOCStyles() SAL_INFO("writerfilter.dmapper", "Applying cloned styles to make TOC work"); // ignore header / footer, irrelevant for ToX // text frames - uno::Reference<text::XTextFramesSupplier> const xDocTFS(m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW); - uno::Reference<container::XEnumerationAccess> const xFrames(xDocTFS->getTextFrames(), uno::UNO_QUERY_THROW); + if (!m_pImpl->m_xTextDocument) + throw uno::RuntimeException(); + uno::Reference<container::XEnumerationAccess> const xFrames(m_pImpl->m_xTextDocument->getTextFrames(), uno::UNO_QUERY_THROW); uno::Reference<container::XEnumeration> const xFramesEnum(xFrames->createEnumeration()); while (xFramesEnum->hasMoreElements()) { @@ -1094,11 +1095,11 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::vector<StyleSheetEntryPtr> const& rEntries) { + if (!m_pImpl->m_xTextDocument) + return; try { - uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< lang::XMultiServiceFactory > xDocFactory( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies(); + uno::Reference< container::XNameAccess > xStyleFamilies = m_pImpl->m_xTextDocument->getStyleFamilies(); uno::Reference<container::XNameContainer> xCharStyles; uno::Reference<container::XNameContainer> xParaStyles; uno::Reference<container::XNameContainer> xNumberingStyles; @@ -1151,7 +1152,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: else { bInsert = true; - xStyle.set(xDocFactory->createInstance( + xStyle.set(m_pImpl->m_xTextDocument->createInstance( bParaStyle ? getPropertyName( PROP_SERVICE_PARA_STYLE ) : (bListStyle ? OUString("com.sun.star.style.NumberingStyle") : getPropertyName( PROP_SERVICE_CHAR_STYLE ))), @@ -1460,14 +1461,13 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: if (!aTableStylesVec.empty()) { // If we had any table styles, add a new document-level InteropGrabBag entry for them. - uno::Reference<beans::XPropertySet> xPropertySet(m_pImpl->m_xTextDocument, uno::UNO_QUERY); - uno::Any aAny = xPropertySet->getPropertyValue("InteropGrabBag"); + uno::Any aAny = m_pImpl->m_xTextDocument->getPropertyValue("InteropGrabBag"); auto aGrabBag = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aAny.get< uno::Sequence<beans::PropertyValue> >()); beans::PropertyValue aValue; aValue.Name = "tableStyles"; aValue.Value <<= comphelper::containerToSequence(aTableStylesVec); aGrabBag.push_back(aValue); - xPropertySet->setPropertyValue("InteropGrabBag", uno::Any(comphelper::containerToSequence(aGrabBag))); + m_pImpl->m_xTextDocument->setPropertyValue("InteropGrabBag", uno::Any(comphelper::containerToSequence(aGrabBag))); } } } @@ -1737,8 +1737,7 @@ void StyleSheetTable::applyDefaults(bool bParaProperties) SetDefaultParaProps(PROP_PARA_WIDOWS, aTwo); SetDefaultParaProps(PROP_PARA_ORPHANS, aTwo); - uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier(m_pImpl->m_xTextDocument, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies = xStylesSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamilies = m_pImpl->m_xTextDocument->getStyleFamilies(); uno::Reference<container::XNameAccess> xParagraphStyles; xStyleFamilies->getByName("ParagraphStyles") >>= xParagraphStyles; uno::Reference<beans::XPropertySet> xDefault; @@ -1797,10 +1796,11 @@ OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProp //create a new one otherwise const uno::Reference< container::XNameContainer >& xCharStyles = m_pImpl->m_rDMapper.GetCharacterStyles(); sListLabel = m_pImpl->m_rDMapper.GetUnusedCharacterStyleName(); - uno::Reference< lang::XMultiServiceFactory > xDocFactory( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); + if (!m_pImpl->m_xTextDocument) + throw uno::RuntimeException(); try { - uno::Reference< style::XStyle > xStyle( xDocFactory->createInstance( + uno::Reference< style::XStyle > xStyle( m_pImpl->m_xTextDocument->createInstance( getPropertyName( PROP_SERVICE_CHAR_STYLE )), uno::UNO_QUERY_THROW); uno::Reference< beans::XPropertySet > xStyleProps(xStyle, uno::UNO_QUERY_THROW ); for( const auto& rCharProp : rCharProperties) diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.hxx b/sw/source/writerfilter/dmapper/StyleSheetTable.hxx index 2308257a32b2..4980619fd469 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.hxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.hxx @@ -19,6 +19,7 @@ #pragma once #include <memory> +#include <rtl/ref.hxx> #include "TblStylePrHandler.hxx" #include "DomainMapper.hxx" @@ -27,6 +28,7 @@ #include "FontTable.hxx" #include "LoggedResources.hxx" +class SwXTextDocument; namespace com::sun::star::text { class XTextDocument; } @@ -88,7 +90,7 @@ class StyleSheetTable : std::unique_ptr<StyleSheetTable_Impl> m_pImpl; public: - StyleSheetTable(DomainMapper& rDMapper, css::uno::Reference<css::text::XTextDocument> const& xTextDocument, bool bIsNewDoc); + StyleSheetTable(DomainMapper& rDMapper, rtl::Reference<SwXTextDocument> const& xTextDocument, bool bIsNewDoc); virtual ~StyleSheetTable() override; void ReApplyInheritedOutlineLevelFromChapterNumbering(); diff --git a/sw/source/writerfilter/dmapper/domainmapperfactory.cxx b/sw/source/writerfilter/dmapper/domainmapperfactory.cxx index e52d5d2e8dec..9ea34614ea6a 100644 --- a/sw/source/writerfilter/dmapper/domainmapperfactory.cxx +++ b/sw/source/writerfilter/dmapper/domainmapperfactory.cxx @@ -16,7 +16,7 @@ namespace writerfilter::dmapper Stream::Pointer_t DomainMapperFactory::createMapper(css::uno::Reference<css::uno::XComponentContext> const& xContext, css::uno::Reference<css::io::XInputStream> const& xInputStream, - css::uno::Reference<css::lang::XComponent> const& xModel, + rtl::Reference<SwXTextDocument> const& xModel, bool bRepairStorage, SourceDocumentType eDocumentType, utl::MediaDescriptor const& rMediaDesc) { diff --git a/sw/source/writerfilter/filter/RtfFilter.cxx b/sw/source/writerfilter/filter/RtfFilter.cxx index 8f80b85353b2..be2b99ae8a5c 100644 --- a/sw/source/writerfilter/filter/RtfFilter.cxx +++ b/sw/source/writerfilter/filter/RtfFilter.cxx @@ -39,6 +39,7 @@ #include <dmapper/DomainMapperFactory.hxx> #include <rtftok/RTFDocument.hxx> +#include <unotxdoc.hxx> using namespace ::com::sun::star; @@ -50,7 +51,8 @@ class RtfFilter lang::XInitialization, lang::XServiceInfo> { uno::Reference<uno::XComponentContext> m_xContext; - uno::Reference<lang::XComponent> m_xSrcDoc, m_xDstDoc; + uno::Reference<lang::XComponent> m_xSrcDoc; + rtl::Reference<SwXTextDocument> m_xDstDoc; public: explicit RtfFilter(uno::Reference<uno::XComponentContext> xContext); @@ -100,8 +102,7 @@ sal_Bool RtfFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescripto uno::Reference<beans::XPropertySet> xDocProps; if (m_xDstDoc.is()) // not in cppunittest? { - xDocProps.set(m_xDstDoc, uno::UNO_QUERY); - xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::Any(true)); + m_xDstDoc->setPropertyValue("UndocumentedWriterfilterHack", uno::Any(true)); } comphelper::ScopeGuard g([xDocProps] { if (xDocProps.is()) // not in cppunittest? @@ -188,7 +189,8 @@ void RtfFilter::setSourceDocument(const uno::Reference<lang::XComponent>& xDoc) void RtfFilter::setTargetDocument(const uno::Reference<lang::XComponent>& xDoc) { - m_xDstDoc = xDoc; + m_xDstDoc = dynamic_cast<SwXTextDocument*>(xDoc.get()); + assert(m_xDstDoc); } void RtfFilter::initialize(const uno::Sequence<uno::Any>& /*aArguments*/) diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx b/sw/source/writerfilter/filter/WriterFilter.cxx index 8935f462636f..edb20f0c7f47 100644 --- a/sw/source/writerfilter/filter/WriterFilter.cxx +++ b/sw/source/writerfilter/filter/WriterFilter.cxx @@ -45,6 +45,7 @@ #include <sal/log.hxx> #include <comphelper/diagnose_ex.hxx> #include <comphelper/scopeguard.hxx> +#include <unotxdoc.hxx> using namespace ::com::sun::star; @@ -93,7 +94,8 @@ class WriterFilter lang::XInitialization, lang::XServiceInfo> { uno::Reference<uno::XComponentContext> m_xContext; - uno::Reference<lang::XComponent> m_xSrcDoc, m_xDstDoc; + uno::Reference<lang::XComponent> m_xSrcDoc; + rtl::Reference<SwXTextDocument> m_xDstDoc; uno::Sequence<uno::Any> m_xInitializationArguments; public: @@ -156,10 +158,9 @@ sal_Bool WriterFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescri } if (m_xDstDoc.is()) { - uno::Reference<beans::XPropertySet> const xDocProps(m_xDstDoc, uno::UNO_QUERY); - xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::Any(true)); - comphelper::ScopeGuard g([xDocProps] { - xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::Any(false)); + m_xDstDoc->setPropertyValue("UndocumentedWriterfilterHack", uno::Any(true)); + comphelper::ScopeGuard g([this] { + m_xDstDoc->setPropertyValue("UndocumentedWriterfilterHack", uno::Any(false)); }); utl::MediaDescriptor aMediaDesc(rDescriptor); bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault("RepairPackage", false); @@ -196,11 +197,10 @@ sal_Bool WriterFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescri writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream, xStatusIndicator, bSkipImages, rDescriptor)); - uno::Reference<frame::XModel> xModel(m_xDstDoc, uno::UNO_QUERY_THROW); + uno::Reference<frame::XModel> xModel(static_cast<SfxBaseModel*>(m_xDstDoc.get())); pDocument->setModel(xModel); - uno::Reference<drawing::XDrawPageSupplier> xDrawings(m_xDstDoc, uno::UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPage> xDrawPage(xDrawings->getDrawPage(), uno::UNO_SET_THROW); + uno::Reference<drawing::XDrawPage> xDrawPage(m_xDstDoc->getDrawPage(), uno::UNO_SET_THROW); pDocument->setDrawPage(xDrawPage); try @@ -248,7 +248,8 @@ sal_Bool WriterFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescri // Adding the saved embedding document to document's grab bag aGrabBagProperties["OOXEmbeddings"] <<= pDocument->getEmbeddingsList(); - oox::core::XmlFilterBase::putPropertiesToDocumentGrabBag(m_xDstDoc, aGrabBagProperties); + oox::core::XmlFilterBase::putPropertiesToDocumentGrabBag( + static_cast<SfxBaseModel*>(m_xDstDoc.get()), aGrabBagProperties); writerfilter::ooxml::OOXMLStream::Pointer_t pVBAProjectStream( writerfilter::ooxml::OOXMLDocumentFactory::createStream( @@ -295,7 +296,8 @@ void WriterFilter::cancel() {} void WriterFilter::setTargetDocument(const uno::Reference<lang::XComponent>& xDoc) { - m_xDstDoc = xDoc; + m_xDstDoc = dynamic_cast<SwXTextDocument*>(xDoc.get()); + assert(m_xDstDoc); // Set some compatibility options that are valid for the DOCX format uno::Reference<lang::XMultiServiceFactory> xFactory(xDoc, uno::UNO_QUERY); diff --git a/sw/source/writerfilter/inc/dmapper/DomainMapperFactory.hxx b/sw/source/writerfilter/inc/dmapper/DomainMapperFactory.hxx index ea7ab81e1a1b..46a5aab23dd2 100644 --- a/sw/source/writerfilter/inc/dmapper/DomainMapperFactory.hxx +++ b/sw/source/writerfilter/inc/dmapper/DomainMapperFactory.hxx @@ -14,7 +14,9 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <rtl/ref.hxx> +class SwXTextDocument; namespace utl { class MediaDescriptor; @@ -35,7 +37,7 @@ public: static Stream::Pointer_t createMapper(css::uno::Reference<css::uno::XComponentContext> const& xContext, css::uno::Reference<css::io::XInputStream> const& xInputStream, - css::uno::Reference<css::lang::XComponent> const& xModel, bool bRepairStorage, + rtl::Reference<SwXTextDocument> const& xModel, bool bRepairStorage, SourceDocumentType eDocumentType, utl::MediaDescriptor const& rMediaDesc); }; diff --git a/sw/source/writerfilter/inc/rtftok/RTFDocument.hxx b/sw/source/writerfilter/inc/rtftok/RTFDocument.hxx index 44d0173a6f3e..a19f671162c2 100644 --- a/sw/source/writerfilter/inc/rtftok/RTFDocument.hxx +++ b/sw/source/writerfilter/inc/rtftok/RTFDocument.hxx @@ -16,6 +16,8 @@ #include <com/sun/star/task/XStatusIndicator.hpp> #include <unotools/mediadescriptor.hxx> +class SwXTextDocument; + namespace writerfilter::rtftok { /// The RTFDocument opens and resolves the RTF document. @@ -36,7 +38,7 @@ public: static RTFDocument::Pointer_t createDocument(css::uno::Reference<css::uno::XComponentContext> const& xContext, css::uno::Reference<css::io::XInputStream> const& xInputStream, - css::uno::Reference<css::lang::XComponent> const& xDstDoc, + rtl::Reference<SwXTextDocument> const& xDstDoc, css::uno::Reference<css::frame::XFrame> const& xFrame, css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator, const utl::MediaDescriptor& rMediaDescriptor); diff --git a/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx b/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx index 8789c3f858a8..4ff4fade6867 100644 --- a/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx +++ b/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx @@ -31,6 +31,7 @@ #include "rtfsdrimport.hxx" #include "rtfskipdestination.hxx" #include "rtftokenizer.hxx" +#include <unotxdoc.hxx> using namespace com::sun::star; @@ -614,15 +615,13 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) uno::Reference<drawing::XShapes> xGroupShape( m_xModelFactory->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY); - uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, - uno::UNO_QUERY); - if (xDrawSupplier.is()) + if (m_xDstDoc) { uno::Reference<drawing::XShape> xShape(xGroupShape, uno::UNO_QUERY); // set default VertOrient before inserting uno::Reference<beans::XPropertySet>(xShape, uno::UNO_QUERY_THROW) ->setPropertyValue("VertOrient", uno::Any(text::VertOrientation::NONE)); - xDrawSupplier->getDrawPage()->add(xShape); + m_xDstDoc->getDrawPage()->add(xShape); } m_pSdrImport->pushParent(xGroupShape); m_aStates.top().setCreatedShapeGroup(true); diff --git a/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx b/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx index 753f1c3fbba9..434936da2e53 100644 --- a/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx +++ b/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx @@ -27,6 +27,7 @@ #include "rtfsdrimport.hxx" #include "rtfskipdestination.hxx" +#include <unotxdoc.hxx> using namespace com::sun::star; @@ -1102,13 +1103,12 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) uno::UNO_QUERY); m_aStates.top().getDrawingObject().setShape(xShape); } - uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet( m_aStates.top().getDrawingObject().getShape(), uno::UNO_QUERY); m_aStates.top().getDrawingObject().setPropertySet(xPropertySet); - if (xDrawSupplier.is()) + if (m_xDstDoc) { - uno::Reference<drawing::XShapes> xShapes = xDrawSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes = m_xDstDoc->getDrawPage(); if (xShapes.is() && nKeyword != RTFKeyword::DPTXBX) { // set default VertOrient before inserting diff --git a/sw/source/writerfilter/rtftok/rtfdocumentfactory.cxx b/sw/source/writerfilter/rtftok/rtfdocumentfactory.cxx index 75b109b6842d..1ff344fa12b6 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentfactory.cxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentfactory.cxx @@ -14,7 +14,7 @@ namespace writerfilter::rtftok RTFDocument::Pointer_t RTFDocumentFactory::createDocument( css::uno::Reference<css::uno::XComponentContext> const& xContext, css::uno::Reference<css::io::XInputStream> const& xInputStream, - css::uno::Reference<css::lang::XComponent> const& xDstDoc, + rtl::Reference<SwXTextDocument> const& xDstDoc, css::uno::Reference<css::frame::XFrame> const& xFrame, css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator, const utl::MediaDescriptor& rMediaDescriptor) diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx index ab700ff0dc14..3963d4535112 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx @@ -55,6 +55,7 @@ #include "rtftokenizer.hxx" #include "rtflookahead.hxx" #include "rtfcharsets.hxx" +#include <unotxdoc.hxx> using namespace com::sun::star; @@ -276,7 +277,7 @@ static void lcl_DestinationToMath(OUStringBuffer* pDestinationText, RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext, uno::Reference<io::XInputStream> const& xInputStream, - uno::Reference<lang::XComponent> const& xDstDoc, + rtl::Reference<SwXTextDocument> const& xDstDoc, uno::Reference<frame::XFrame> const& xFrame, uno::Reference<task::XStatusIndicator> const& xStatusIndicator, const utl::MediaDescriptor& rMediaDescriptor) @@ -334,12 +335,10 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x OSL_ASSERT(xInputStream.is()); m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, true); - m_xModelFactory.set(m_xDstDoc, uno::UNO_QUERY); + m_xModelFactory = m_xDstDoc; - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( - m_xDstDoc, uno::UNO_QUERY); - if (xDocumentPropertiesSupplier.is()) - m_xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); + if (m_xDstDoc) + m_xDocumentProperties = m_xDstDoc->getDocumentProperties(); m_pGraphicHelper = std::make_shared<oox::GraphicHelper>(m_xContext, xFrame, oox::StorageRef()); @@ -1020,10 +1019,9 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS if (m_xModelFactory.is()) xShape.set(m_xModelFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY); - uno::Reference<drawing::XDrawPageSupplier> const xDrawSupplier(m_xDstDoc, uno::UNO_QUERY); - if (xDrawSupplier.is()) + if (m_xDstDoc) { - uno::Reference<drawing::XShapes> xShapes = xDrawSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes = m_xDstDoc->getDrawPage(); if (xShapes.is()) xShapes->add(xShape); } @@ -3263,10 +3261,8 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState) = m_xDocumentProperties; // These are the real document properties. - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( - m_xDstDoc, uno::UNO_QUERY); - if (xDocumentPropertiesSupplier.is()) - m_xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); + if (m_xDstDoc) + m_xDocumentProperties = m_xDstDoc->getDocumentProperties(); if (m_xDocumentProperties.is()) { diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx index f05f7d321cdd..e0461e340b5b 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx @@ -688,7 +688,7 @@ public: using Pointer_t = tools::SvRef<RTFDocumentImpl>; RTFDocumentImpl(css::uno::Reference<css::uno::XComponentContext> const& xContext, css::uno::Reference<css::io::XInputStream> const& xInputStream, - css::uno::Reference<css::lang::XComponent> const& xDstDoc, + rtl::Reference<SwXTextDocument> const& xDstDoc, css::uno::Reference<css::frame::XFrame> const& xFrame, css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator, const utl::MediaDescriptor& rMediaDescriptor); @@ -814,7 +814,7 @@ private: css::uno::Reference<css::uno::XComponentContext> const& m_xContext; css::uno::Reference<css::io::XInputStream> const& m_xInputStream; - css::uno::Reference<css::lang::XComponent> const& m_xDstDoc; + rtl::Reference<SwXTextDocument> const& m_xDstDoc; css::uno::Reference<css::frame::XFrame> const& m_xFrame; css::uno::Reference<css::task::XStatusIndicator> const& m_xStatusIndicator; css::uno::Reference<css::lang::XMultiServiceFactory> m_xModelFactory; diff --git a/sw/source/writerfilter/rtftok/rtfsdrimport.cxx b/sw/source/writerfilter/rtftok/rtfsdrimport.cxx index d9c57be4a8a8..6c5ddcf912ff 100644 --- a/sw/source/writerfilter/rtftok/rtfsdrimport.cxx +++ b/sw/source/writerfilter/rtftok/rtfsdrimport.cxx @@ -52,21 +52,21 @@ #include <dmapper/GraphicZOrderHelper.hxx> #include "rtfdocumentimpl.hxx" +#include <unotxdoc.hxx> using namespace com::sun::star; namespace writerfilter::rtftok { RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument, - uno::Reference<lang::XComponent> const& xDstDoc) + rtl::Reference<SwXTextDocument> const& xDstDoc) : m_rImport(rDocument) , m_bTextFrame(false) , m_bTextGraphicObject(false) , m_bFakePict(false) { - uno::Reference<drawing::XDrawPageSupplier> xDrawings(xDstDoc, uno::UNO_QUERY); - if (xDrawings.is()) - m_aParents.push(xDrawings->getDrawPage()); + if (xDstDoc) + m_aParents.push(xDstDoc->getDrawPage()); m_aGraphicZOrderHelpers.push(writerfilter::dmapper::GraphicZOrderHelper()); } diff --git a/sw/source/writerfilter/rtftok/rtfsdrimport.hxx b/sw/source/writerfilter/rtftok/rtfsdrimport.hxx index b06803bd0f64..e9f940f1ac6b 100644 --- a/sw/source/writerfilter/rtftok/rtfsdrimport.hxx +++ b/sw/source/writerfilter/rtftok/rtfsdrimport.hxx @@ -14,7 +14,9 @@ #include <dmapper/GraphicZOrderHelper.hxx> #include <tools/ref.hxx> +#include <rtl/ref.hxx> +class SwXTextDocument; namespace com::sun::star { namespace beans @@ -42,8 +44,7 @@ class RTFShape; class RTFSdrImport final : public virtual SvRefBase { public: - RTFSdrImport(RTFDocumentImpl& rDocument, - css::uno::Reference<css::lang::XComponent> const& xDstDoc); + RTFSdrImport(RTFDocumentImpl& rDocument, rtl::Reference<SwXTextDocument> const& xDstDoc); ~RTFSdrImport() override; enum ShapeOrPict |