sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx | 2 - sw/source/writerfilter/rtftok/rtfdispatchflag.cxx | 15 ++++------ sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx | 22 +++++---------- sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx | 6 ---- sw/source/writerfilter/rtftok/rtfsdrimport.cxx | 6 ++-- 5 files changed, 20 insertions(+), 31 deletions(-)
New commits: commit bd343716f505bb955ddfb9fa20002468df3fb19c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Apr 25 10:55:07 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Apr 30 19:34:23 2024 +0200 use more concrete UNO classes in writerfilter rtf Change-Id: I54dded3ffce1fbe6fee1b93370eb5b44bb719339 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166810 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx b/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx index 4ff4fade6867..30b2acb58f80 100644 --- a/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx +++ b/sw/source/writerfilter/rtftok/rtfdispatchdestination.cxx @@ -613,7 +613,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) if (!aLookahead.hasTable()) { uno::Reference<drawing::XShapes> xGroupShape( - m_xModelFactory->createInstance("com.sun.star.drawing.GroupShape"), + getTextDocument()->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY); if (m_xDstDoc) { diff --git a/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx b/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx index 434936da2e53..af97b36812f9 100644 --- a/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx +++ b/sw/source/writerfilter/rtftok/rtfdispatchflag.cxx @@ -28,6 +28,7 @@ #include "rtfsdrimport.hxx" #include "rtfskipdestination.hxx" #include <unotxdoc.hxx> +#include <unoframe.hxx> using namespace com::sun::star; @@ -1039,7 +1040,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTFKeyword::DPLINE: { uno::Reference<drawing::XShape> xShape( - getModelFactory()->createInstance("com.sun.star.drawing.LineShape"), + getTextDocument()->createInstance("com.sun.star.drawing.LineShape"), uno::UNO_QUERY); m_aStates.top().getDrawingObject().setShape(xShape); break; @@ -1048,7 +1049,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) { // The reason this is not a simple CustomShape is that in the old syntax we have no ViewBox info. uno::Reference<drawing::XShape> xShape( - getModelFactory()->createInstance("com.sun.star.drawing.PolyLineShape"), + getTextDocument()->createInstance("com.sun.star.drawing.PolyLineShape"), uno::UNO_QUERY); m_aStates.top().getDrawingObject().setShape(xShape); break; @@ -1056,7 +1057,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTFKeyword::DPPOLYGON: { uno::Reference<drawing::XShape> xShape( - getModelFactory()->createInstance("com.sun.star.drawing.PolyPolygonShape"), + getTextDocument()->createInstance("com.sun.star.drawing.PolyPolygonShape"), uno::UNO_QUERY); m_aStates.top().getDrawingObject().setShape(xShape); break; @@ -1064,7 +1065,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTFKeyword::DPRECT: { uno::Reference<drawing::XShape> xShape( - getModelFactory()->createInstance("com.sun.star.drawing.RectangleShape"), + getTextDocument()->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); m_aStates.top().getDrawingObject().setShape(xShape); break; @@ -1074,9 +1075,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) break; case RTFKeyword::DPTXBX: { - uno::Reference<drawing::XShape> xShape( - getModelFactory()->createInstance("com.sun.star.text.TextFrame"), - uno::UNO_QUERY); + rtl::Reference<SwXTextFrame> xShape(getTextDocument()->createTextFrame()); m_aStates.top().getDrawingObject().setShape(xShape); std::vector<beans::PropertyValue> aDefaults = RTFSdrImport::getTextFrameDefaults(false); @@ -1099,7 +1098,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) if (nType) { uno::Reference<drawing::XShape> xShape( - getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"), + getTextDocument()->createInstance("com.sun.star.drawing.CustomShape"), uno::UNO_QUERY); m_aStates.top().getDrawingObject().setShape(xShape); } diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx index 3963d4535112..d22c648edb2f 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx @@ -335,8 +335,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x OSL_ASSERT(xInputStream.is()); m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, true); - m_xModelFactory = m_xDstDoc; - if (m_xDstDoc) m_xDocumentProperties = m_xDstDoc->getDocumentProperties(); @@ -1014,17 +1012,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS xShape.clear(); } } - if (!xShape.is()) + if (!xShape.is() && m_xDstDoc) { - if (m_xModelFactory.is()) - xShape.set(m_xModelFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), - uno::UNO_QUERY); - if (m_xDstDoc) - { - uno::Reference<drawing::XShapes> xShapes = m_xDstDoc->getDrawPage(); - if (xShapes.is()) - xShapes->add(xShape); - } + xShape.set(m_xDstDoc->createInstance("com.sun.star.drawing.GraphicObjectShape"), + uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xShapes = m_xDstDoc->getDrawPage(); + if (xShapes.is()) + xShapes->add(xShape); } uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); @@ -3524,11 +3518,11 @@ void RTFDocumentImpl::afterPopState(RTFParserState& rState) else { uno::Reference<beans::XPropertySet> xMaster( - m_xModelFactory->createInstance("com.sun.star.text.FieldMaster.User"), + m_xDstDoc->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW); xMaster->setPropertyValue("Name", uno::Any(m_aStates.top().getDocVarName())); uno::Reference<text::XDependentTextField> xField( - m_xModelFactory->createInstance("com.sun.star.text.TextField.User"), + m_xDstDoc->createInstance("com.sun.star.text.TextField.User"), uno::UNO_QUERY); xField->attachTextFieldMaster(xMaster); xField->getTextFieldMaster()->setPropertyValue("Content", uno::Any(docvar)); diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx index e0461e340b5b..e1ab4be1dd7a 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx @@ -728,10 +728,7 @@ public: Stream& Mapper() { return *m_pMapperStream; } void setSuperstream(RTFDocumentImpl* pSuperstream); - const css::uno::Reference<css::lang::XMultiServiceFactory>& getModelFactory() const - { - return m_xModelFactory; - } + const rtl::Reference<SwXTextDocument>& getTextDocument() const { return m_xDstDoc; } bool isInBackground(); void setDestinationText(std::u16string_view rString); /// Resolve a picture: If not inline, then anchored. @@ -817,7 +814,6 @@ private: 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; css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties; std::unique_ptr<SvStream> m_pInStream; Stream* m_pMapperStream; diff --git a/sw/source/writerfilter/rtftok/rtfsdrimport.cxx b/sw/source/writerfilter/rtftok/rtfsdrimport.cxx index 6c5ddcf912ff..da2a2bd1365f 100644 --- a/sw/source/writerfilter/rtftok/rtfsdrimport.cxx +++ b/sw/source/writerfilter/rtftok/rtfsdrimport.cxx @@ -81,8 +81,8 @@ RTFSdrImport::~RTFSdrImport() void RTFSdrImport::createShape(const OUString& rService, uno::Reference<drawing::XShape>& xShape, uno::Reference<beans::XPropertySet>& xPropertySet) { - if (m_rImport.getModelFactory().is()) - xShape.set(m_rImport.getModelFactory()->createInstance(rService), uno::UNO_QUERY); + if (m_rImport.getTextDocument().is()) + xShape.set(m_rImport.getTextDocument()->createInstance(rService), uno::UNO_QUERY); xPropertySet.set(xShape, uno::UNO_QUERY); } @@ -1089,7 +1089,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap uno::Any(rShape.getVertOrientRelation())); if (rShape.getWrap() != text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE) xPropertySet->setPropertyValue("Surround", uno::Any(rShape.getWrap())); - oox::ModelObjectHelper aModelObjectHelper(m_rImport.getModelFactory()); + oox::ModelObjectHelper aModelObjectHelper(m_rImport.getTextDocument()); if (aFillModel.moType.has_value()) { oox::drawingml::ShapePropertyMap aPropMap(aModelObjectHelper);