sw/inc/unodraw.hxx | 2 sw/inc/unotxdoc.hxx | 1 sw/source/uibase/uno/unotxdoc.cxx | 5 ++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 5 +- sw/source/writerfilter/dmapper/FormControlHelper.cxx | 15 +++--- sw/source/writerfilter/dmapper/PropertyMap.cxx | 33 ++++++--------- sw/source/writerfilter/dmapper/PropertyMap.hxx | 6 +- sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 10 ++-- sw/source/writerfilter/filter/WriterFilter.cxx | 3 - sw/source/writerfilter/inc/ooxml/OOXMLDocument.hxx | 6 +- sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx | 7 +-- sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx | 6 +- sw/source/writerfilter/ooxml/OOXMLFastContextHandler.cxx | 1 sw/source/writerfilter/rtftok/rtfdispatchflag.cxx | 3 - sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx | 3 - 15 files changed, 58 insertions(+), 48 deletions(-)
New commits: commit 1e8ace631fb8518cea3fdf94b54e73616d7229c5 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Aug 9 12:38:54 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 9 17:31:11 2024 +0200 use more concrete UNO type in writerfilter Change-Id: I22b22eebdbff24389e1a4aecb5a089904483207e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171690 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index 99db7cc7522c..7a3611bd6624 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -713,7 +713,7 @@ table::ShadowFormat PropertyMap::getShadowFromBorder( const table::BorderLine2& return aFormat; } -void SectionPropertyMap::SetBorderDistance( const uno::Reference< beans::XPropertySet >& xStyle, +void SectionPropertyMap::SetBorderDistance( const rtl::Reference<SwXPageStyle>& xStyle, PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, @@ -751,10 +751,9 @@ void SectionPropertyMap::SetBorderDistance( const uno::Reference< beans::XProper } // Change the margins with the border distance - uno::Reference< beans::XMultiPropertySet > xMultiSet( xStyle, uno::UNO_QUERY_THROW ); uno::Sequence<OUString> aProperties { sMarginName, sBorderDistanceName }; uno::Sequence<uno::Any> aValues { uno::Any( nMargin ), uno::Any( nDistance ) }; - xMultiSet->setPropertyValues( aProperties, aValues ); + xStyle->setPropertyValues( aProperties, aValues ); } void SectionPropertyMap::DontBalanceTextColumns() @@ -770,7 +769,7 @@ void SectionPropertyMap::DontBalanceTextColumns() } } -void SectionPropertyMap::ApplySectionProperties( const uno::Reference< beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ) +void SectionPropertyMap::ApplySectionProperties( const rtl::Reference< SwXTextSection >& xSection, DomainMapper_Impl& rDM_Impl ) { try { @@ -2038,10 +2037,10 @@ public: } -void SectionPropertyMap::ApplyProperties_( const uno::Reference< beans::XPropertySet >& xStyle ) +void SectionPropertyMap::ApplyProperties_( const rtl::Reference<SwXPageStyle>& xStyle ) { - uno::Reference< beans::XMultiPropertySet > const xMultiSet( xStyle, uno::UNO_QUERY ); - + if ( !xStyle.is() ) + return; std::vector< OUString > vNames; std::vector< uno::Any > vValues; { @@ -2079,24 +2078,20 @@ void SectionPropertyMap::ApplyProperties_( const uno::Reference< beans::XPropert vValues.push_back( v.Value ); } } - if ( xMultiSet.is() ) + try { - try - { - xMultiSet->setPropertyValues( comphelper::containerToSequence( vNames ), comphelper::containerToSequence( vValues ) ); - return; - } - catch ( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION( "writerfilter", "SectionPropertyMap::ApplyProperties_" ); - } + xStyle->setPropertyValues( comphelper::containerToSequence( vNames ), comphelper::containerToSequence( vValues ) ); + return; + } + catch ( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION( "writerfilter", "SectionPropertyMap::ApplyProperties_" ); } for ( size_t i = 0; i < vNames.size(); ++i ) { try { - if ( xStyle.is() ) - xStyle->setPropertyValue( vNames[i], vValues[i] ); + xStyle->setPropertyValue( vNames[i], vValues[i] ); } catch ( const uno::Exception& ) { diff --git a/sw/source/writerfilter/dmapper/PropertyMap.hxx b/sw/source/writerfilter/dmapper/PropertyMap.hxx index e03224125859..a70c628c3de0 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.hxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.hxx @@ -316,12 +316,12 @@ private: bool m_bEvenPageFooterLinkToPrevious = true; bool m_bFirstPageFooterLinkToPrevious = true; - void ApplyProperties_( const css::uno::Reference< css::beans::XPropertySet >& xStyle ); + void ApplyProperties_( const rtl::Reference<SwXPageStyle>& xStyle ); void DontBalanceTextColumns(); /// Apply section-specific properties: only valid to use after PageStyle has been determined by InheritOrFinalizePageStyles - void ApplySectionProperties( const css::uno::Reference< css::beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ); + void ApplySectionProperties( const rtl::Reference< SwXTextSection >& xSection, DomainMapper_Impl& rDM_Impl ); /// Check if document is protected. If so, ensure a section exists, and apply its protected value. void ApplyProtectionProperties( rtl::Reference<SwXTextSection>& xSection, DomainMapper_Impl& rDM_Impl ); @@ -338,7 +338,7 @@ private: bool HasHeader() const; bool HasFooter() const; - static void SetBorderDistance( const css::uno::Reference< css::beans::XPropertySet >& xStyle, + static void SetBorderDistance( const rtl::Reference<SwXPageStyle>& xStyle, PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 03e2de0eda80..f0db6d3fafa7 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 <unobasestyle.hxx> #include <unotxdoc.hxx> #include <unoxstyle.hxx> #include <unostyle.hxx> @@ -296,7 +297,7 @@ struct StyleSheetTable_Impl /// Appends the given key-value pair to the list of latent style properties of the current entry. void AppendLatentStyleProperty(const OUString& aName, Value const & rValue); /// Sets all properties of xStyle back to default. - static void SetPropertiesToDefault(const uno::Reference<style::XStyle>& xStyle); + static void SetPropertiesToDefault(const rtl::Reference<SwXBaseStyle>& xStyle); void ApplyClonedTOCStylesToXText(uno::Reference<text::XText> const& xText); }; @@ -359,18 +360,17 @@ void StyleSheetTable_Impl::AppendLatentStyleProperty(const OUString& aName, Valu m_pCurrentEntry->m_aLatentStyles.push_back(aValue); } -void StyleSheetTable_Impl::SetPropertiesToDefault(const uno::Reference<style::XStyle>& xStyle) +void StyleSheetTable_Impl::SetPropertiesToDefault(const rtl::Reference<SwXBaseStyle>& xStyle) { // See if the existing style has any non-default properties. If so, reset them back to default. - uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY); - uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xStyle->getPropertySetInfo(); const uno::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties(); std::vector<OUString> aPropertyNames; aPropertyNames.reserve(aProperties.getLength()); std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aPropertyNames), [](const beans::Property& rProp) { return rProp.Name; }); - uno::Reference<beans::XPropertyState> xPropertyState(xStyle, uno::UNO_QUERY); + uno::Reference<beans::XPropertyState> xPropertyState(static_cast<cppu::OWeakObject*>(xStyle.get()), uno::UNO_QUERY); uno::Sequence<beans::PropertyState> aStates = xPropertyState->getPropertyStates(comphelper::containerToSequence(aPropertyNames)); for (sal_Int32 i = 0; i < aStates.getLength(); ++i) { commit a32457632ffc236a7505c7ef9d5c6433482577a9 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Aug 9 12:14:18 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 9 17:31:02 2024 +0200 use more concrete UNO type in writerfilter Change-Id: Ie2adf7fb339d29f58e4a0eeabe341f57834c77f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171689 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx index 98f322bdf647..87a06e7efd9f 100644 --- a/sw/inc/unodraw.hxx +++ b/sw/inc/unodraw.hxx @@ -47,7 +47,7 @@ typedef cppu::ImplInheritanceHelper css::beans::XPropertySet> SwFmDrawPage_Base; -class SwFmDrawPage final : public SwFmDrawPage_Base +class SW_DLLPUBLIC SwFmDrawPage final : public SwFmDrawPage_Base { SwDoc* m_pDoc; SdrPageView* m_pPageView; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 9b2824700fa4..8440f958ccd2 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -522,6 +522,7 @@ public: SwDocShell* GetDocShell() {return m_pDocShell;} + rtl::Reference<SwFmDrawPage> getSwDrawPage(); rtl::Reference<SwXFootnotes> getSwXFootnotes(); rtl::Reference<SwXFootnotes> getSwXEndnotes(); rtl::Reference<SwXTextFieldMasters> getSwXTextFieldMasters(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index f45ba9f073a2..821519fa114d 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1293,6 +1293,11 @@ uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( ) } Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage() +{ + return getSwDrawPage(); +} + +rtl::Reference< SwFmDrawPage > SwXTextDocument::getSwDrawPage() { SolarMutexGuard aGuard; ThrowIfInvalid(); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 60b43c3a2ce5..e60ab7b12f29 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -152,6 +152,7 @@ #include <unoport.hxx> #include <unotextbodyhf.hxx> #include <unosett.hxx> +#include <unodraw.hxx> using namespace ::com::sun::star; using namespace oox; @@ -867,7 +868,7 @@ void DomainMapper_Impl::RemoveLastParagraph( ) if (xParagraph) { // move all anchored objects to the previous paragraph - auto xDrawPage = m_xTextDocument->getDrawPage(); + rtl::Reference<SwFmDrawPage> xDrawPage = m_xTextDocument->getSwDrawPage(); if (xDrawPage && xDrawPage->hasElements()) { // Cursor already spans two paragraphs @@ -5012,7 +5013,7 @@ void DomainMapper_Impl::PopShapeContext() { try { - uno::Reference<drawing::XDrawPage> xDrawPage = m_xTextDocument->getDrawPage(); + rtl::Reference<SwFmDrawPage> xDrawPage = m_xTextDocument->getSwDrawPage(); if ( xDrawPage.is() ) xDrawPage->remove( xShape ); } diff --git a/sw/source/writerfilter/dmapper/FormControlHelper.cxx b/sw/source/writerfilter/dmapper/FormControlHelper.cxx index 1055de840867..c3d2b6e62ee5 100644 --- a/sw/source/writerfilter/dmapper/FormControlHelper.cxx +++ b/sw/source/writerfilter/dmapper/FormControlHelper.cxx @@ -44,6 +44,7 @@ #include <rtl/ref.hxx> #include <unotxdoc.hxx> #include <unobookmark.hxx> +#include <unodraw.hxx> namespace writerfilter::dmapper { @@ -53,32 +54,32 @@ struct FormControlHelper::FormControlHelper_Impl : public virtual SvRefBase { FieldId m_eFieldId; awt::Size aSize; - uno::Reference<drawing::XDrawPage> rDrawPage; + rtl::Reference<SwFmDrawPage> mxDrawPage; uno::Reference<form::XForm> rForm; uno::Reference<form::XFormComponent> rFormComponent; rtl::Reference<SwXTextDocument> mxTextDocument; - uno::Reference<drawing::XDrawPage> const & getDrawPage(); + rtl::Reference<SwFmDrawPage> const & getDrawPage(); uno::Reference<form::XForm> const & getForm(); uno::Reference<container::XIndexContainer> getFormComps(); }; -uno::Reference<drawing::XDrawPage> const & FormControlHelper::FormControlHelper_Impl::getDrawPage() +rtl::Reference<SwFmDrawPage> const & FormControlHelper::FormControlHelper_Impl::getDrawPage() { - if (! rDrawPage.is()) + if (! mxDrawPage.is()) { if (mxTextDocument) - rDrawPage = mxTextDocument->getDrawPage(); + mxDrawPage = mxTextDocument->getSwDrawPage(); } - return rDrawPage; + return mxDrawPage; } uno::Reference<form::XForm> const & FormControlHelper::FormControlHelper_Impl::getForm() { if (! rForm.is()) { - uno::Reference<form::XFormsSupplier> xFormsSupplier(getDrawPage(), uno::UNO_QUERY); + rtl::Reference<SwFmDrawPage> xFormsSupplier(getDrawPage()); if (xFormsSupplier.is()) { diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx b/sw/source/writerfilter/filter/WriterFilter.cxx index 1a648daba438..201e2e1a4ee4 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 <unodraw.hxx> #include <unotxdoc.hxx> #include <SwXDocumentSettings.hxx> @@ -201,7 +202,7 @@ sal_Bool WriterFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescri uno::Reference<frame::XModel> xModel(static_cast<SfxBaseModel*>(m_xDstDoc.get())); pDocument->setModel(xModel); - uno::Reference<drawing::XDrawPage> xDrawPage(m_xDstDoc->getDrawPage(), uno::UNO_SET_THROW); + rtl::Reference<SwFmDrawPage> xDrawPage(m_xDstDoc->getSwDrawPage()); pDocument->setDrawPage(xDrawPage); try diff --git a/sw/source/writerfilter/inc/ooxml/OOXMLDocument.hxx b/sw/source/writerfilter/inc/ooxml/OOXMLDocument.hxx index 91a4aeec5a3f..e0dcfc2ad939 100644 --- a/sw/source/writerfilter/inc/ooxml/OOXMLDocument.hxx +++ b/sw/source/writerfilter/inc/ooxml/OOXMLDocument.hxx @@ -33,6 +33,8 @@ #include <oox/shape/ShapeContextHandler.hxx> #include <oox/drawingml/theme.hxx> +class SwFmDrawPage; + /** @file OOXMLDocument.hxx @@ -207,8 +209,8 @@ public: virtual void setModel(css::uno::Reference<css::frame::XModel> xModel) = 0; virtual css::uno::Reference<css::frame::XModel> getModel() = 0; - virtual void setDrawPage(css::uno::Reference<css::drawing::XDrawPage> xDrawPage) = 0; - virtual css::uno::Reference<css::drawing::XDrawPage> getDrawPage() = 0; + virtual void setDrawPage(rtl::Reference<SwFmDrawPage> xDrawPage) = 0; + virtual rtl::Reference<SwFmDrawPage> getDrawPage() = 0; virtual css::uno::Reference<css::io::XInputStream> getInputStreamForId(const OUString & rId) = 0; virtual void setXNoteId(const sal_Int32 nId) = 0; virtual sal_Int32 getXNoteId() const = 0; diff --git a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx index 2f9e3bb9594c..8321016ffb9e 100644 --- a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx +++ b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx @@ -41,6 +41,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/exc_hlp.hxx> #include <unotools/mediadescriptor.hxx> +#include <unodraw.hxx> #include <iostream> #include <sfx2/objsh.hxx> @@ -824,12 +825,12 @@ uno::Reference<frame::XModel> OOXMLDocumentImpl::getModel() return mxModel; } -void OOXMLDocumentImpl::setDrawPage(uno::Reference<drawing::XDrawPage> xDrawPage) +void OOXMLDocumentImpl::setDrawPage(rtl::Reference<SwFmDrawPage> xDrawPage) { - mxDrawPage.set(xDrawPage); + mxDrawPage = xDrawPage; } -uno::Reference<drawing::XDrawPage> OOXMLDocumentImpl::getDrawPage() +rtl::Reference<SwFmDrawPage> OOXMLDocumentImpl::getDrawPage() { return mxDrawPage; } diff --git a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx index ee8a01972f93..1e86bc06763c 100644 --- a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx +++ b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx @@ -44,7 +44,7 @@ class OOXMLDocumentImpl : public OOXMLDocument sal_Int32 mnXNoteId; css::uno::Reference<css::frame::XModel> mxModel; - css::uno::Reference<css::drawing::XDrawPage> mxDrawPage; + rtl::Reference<SwFmDrawPage> mxDrawPage; css::uno::Reference<css::xml::dom::XDocument> mxGlossaryDocDom; css::uno::Sequence < css::uno::Sequence< css::beans::NamedValue > > mxGlossaryDomList; /// Stack of shape contexts, 1 element for VML, 1 element / nesting level for drawingML. @@ -131,8 +131,8 @@ public: virtual void setModel(css::uno::Reference<css::frame::XModel> xModel) override; virtual css::uno::Reference<css::frame::XModel> getModel() override; - virtual void setDrawPage(css::uno::Reference<css::drawing::XDrawPage> xDrawPage) override; - virtual css::uno::Reference<css::drawing::XDrawPage> getDrawPage() override; + virtual void setDrawPage(rtl::Reference<SwFmDrawPage> xDrawPage) override; + virtual rtl::Reference<SwFmDrawPage> getDrawPage() override; virtual css::uno::Reference<css::io::XInputStream> getInputStreamForId(const OUString & rId) override; virtual void setXNoteId(const sal_Int32 nId) override; virtual sal_Int32 getXNoteId() const override; diff --git a/sw/source/writerfilter/ooxml/OOXMLFastContextHandler.cxx b/sw/source/writerfilter/ooxml/OOXMLFastContextHandler.cxx index 4707727f87ab..f902f47ecff1 100644 --- a/sw/source/writerfilter/ooxml/OOXMLFastContextHandler.cxx +++ b/sw/source/writerfilter/ooxml/OOXMLFastContextHandler.cxx @@ -41,6 +41,7 @@ #include <comphelper/sequenceashashmap.hxx> #include "OOXMLPropertySet.hxx" #include <dmapper/GraphicHelpers.hxx> +#include <unodraw.hxx> const sal_Unicode uCR = 0xd; const sal_Unicode uFtnEdnRef = 0x2; diff --git a/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx b/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx index acd753fe6eb3..25b963ec3147 100644 --- a/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx +++ b/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx @@ -29,6 +29,7 @@ #include "rtfskipdestination.hxx" #include <unotxdoc.hxx> #include <unoframe.hxx> +#include <unodraw.hxx> using namespace com::sun::star; @@ -1115,7 +1116,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) m_aStates.top().getDrawingObject().setPropertySet(xPropertySet); if (m_xDstDoc) { - uno::Reference<drawing::XShapes> xShapes = m_xDstDoc->getDrawPage(); + rtl::Reference<SwFmDrawPage> xShapes = m_xDstDoc->getSwDrawPage(); if (xShapes.is() && nKeyword != RTFKeyword::DPTXBX) { // set default VertOrient before inserting diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx index b8cf2e775bd2..dbcca8cf9424 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx @@ -56,6 +56,7 @@ #include "rtflookahead.hxx" #include "rtfcharsets.hxx" #include <unotxdoc.hxx> +#include <unodraw.hxx> using namespace com::sun::star; @@ -1016,7 +1017,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS { xShape.set(m_xDstDoc->createInstance(u"com.sun.star.drawing.GraphicObjectShape"_ustr), uno::UNO_QUERY); - uno::Reference<drawing::XShapes> xShapes = m_xDstDoc->getDrawPage(); + rtl::Reference<SwFmDrawPage> xShapes = m_xDstDoc->getSwDrawPage(); if (xShapes.is()) xShapes->add(xShape); }