From 6701329f5b7d9c39fbd00f2f735dcd375992aa8e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 28 Jun 2021 11:02:56 +0200 Subject: [PATCH] [API CHANGE] drop ShapeContextHandler service and interface There is zero chance an extension is using this, because it is so intimately tired together with the oox and writerfilter interactions. I'm removing this so I can expose the ShapeContextHandler and then override it's implementation in a more fashion without jumping through UNO hoops. Change-Id: I79ef30247f4642303dfdb92bbf8f6e6226234829 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117996 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../oox}/shape/ShapeContextHandler.hxx | 63 +++++++------------ offapi/UnoApi_offapi.mk | 2 - .../star/xml/sax/FastShapeContextHandler.idl | 33 ---------- .../star/xml/sax/XFastShapeContextHandler.idl | 62 ------------------ oox/source/shape/ShapeContextHandler.cxx | 61 +++++------------- oox/util/oox.component | 4 -- solenv/bin/native-code.py | 1 - solenv/clang-format/excludelist | 2 +- writerfilter/inc/ooxml/OOXMLDocument.hxx | 6 +- .../source/ooxml/OOXMLDocumentImpl.cxx | 8 +-- .../source/ooxml/OOXMLDocumentImpl.hxx | 6 +- .../source/ooxml/OOXMLFastContextHandler.cxx | 5 +- .../source/ooxml/OOXMLFastContextHandler.hxx | 3 +- 13 files changed, 54 insertions(+), 202 deletions(-) rename {oox/source => include/oox}/shape/ShapeContextHandler.hxx (68%) delete mode 100644 offapi/com/sun/star/xml/sax/FastShapeContextHandler.idl delete mode 100644 offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl diff --git a/oox/source/shape/ShapeContextHandler.hxx b/include/oox/shape/ShapeContextHandler.hxx similarity index 68% rename from oox/source/shape/ShapeContextHandler.hxx rename to include/oox/shape/ShapeContextHandler.hxx index d9b171f045b0..5655cc25acf2 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/include/oox/shape/ShapeContextHandler.hxx @@ -16,18 +16,19 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_OOX_SOURCE_SHAPE_SHAPECONTEXTHANDLER_HXX -#define INCLUDED_OOX_SOURCE_SHAPE_SHAPECONTEXTHANDLER_HXX +#pragma once #include -#include #include -#include #include #include #include +#include #include #include +#include +#include +#include namespace oox::shape { @@ -45,9 +46,8 @@ public: } }; -class ShapeContextHandler: - public ::cppu::WeakImplHelper< css::xml::sax::XFastShapeContextHandler, - css::lang::XServiceInfo > +class OOX_DLLPUBLIC ShapeContextHandler: + public ::cppu::WeakImplHelper< css::xml::sax::XFastContextHandler > { public: explicit ShapeContextHandler @@ -55,15 +55,6 @@ public: virtual ~ShapeContextHandler() override; - // css::lang::XServiceInfo: - virtual OUString SAL_CALL getImplementationName() override; - - virtual sal_Bool SAL_CALL supportsService - (const OUString & ServiceName) override; - - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedServiceNames() override; - // css::xml::sax::XFastContextHandler: virtual void SAL_CALL startFastElement (::sal_Int32 Element, @@ -93,35 +84,29 @@ public: virtual void SAL_CALL characters(const OUString & aChars) override; - // css::xml::sax::XFastShapeContextHandler: - virtual css::uno::Reference< css::drawing::XShape > SAL_CALL getShape() override; + css::uno::Reference< css::drawing::XShape > getShape(); - virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage() override; + css::uno::Reference< css::drawing::XDrawPage > getDrawPage(); + void setDrawPage(const css::uno::Reference< css::drawing::XDrawPage > & the_value); - virtual void SAL_CALL setDrawPage - (const css::uno::Reference< css::drawing::XDrawPage > & the_value) override; + css::uno::Reference< css::frame::XModel > getModel(); + void setModel(const css::uno::Reference< css::frame::XModel > & the_value); - virtual css::uno::Reference< css::frame::XModel > SAL_CALL getModel() override; + OUString getRelationFragmentPath(); + void setRelationFragmentPath(const OUString & the_value); - virtual void SAL_CALL setModel - (const css::uno::Reference< css::frame::XModel > & the_value) override; + sal_Int32 getStartToken(); + void setStartToken( sal_Int32 _starttoken ); - virtual OUString SAL_CALL getRelationFragmentPath() override; - virtual void SAL_CALL setRelationFragmentPath - (const OUString & the_value) override; + css::awt::Point getPosition(); + void setPosition(const css::awt::Point& rPosition); - virtual ::sal_Int32 SAL_CALL getStartToken() override; - virtual void SAL_CALL setStartToken( ::sal_Int32 _starttoken ) override; + void setDocumentProperties(const css::uno::Reference& xDocProps); + css::uno::Reference getDocumentProperties(); + css::uno::Sequence getMediaDescriptor(); + void setMediaDescriptor(const css::uno::Sequence& rMediaDescriptor); - virtual css::awt::Point SAL_CALL getPosition() override; - virtual void SAL_CALL setPosition(const css::awt::Point& rPosition) override; - - virtual void SAL_CALL setDocumentProperties(const css::uno::Reference& xDocProps) override; - virtual css::uno::Reference SAL_CALL getDocumentProperties() override; - virtual css::uno::Sequence SAL_CALL getMediaDescriptor() override; - virtual void SAL_CALL setMediaDescriptor(const css::uno::Sequence& rMediaDescriptor) override; - - void SAL_CALL setGraphicMapper(css::uno::Reference const & rGraphicMapper) override; + void setGraphicMapper(css::uno::Reference const & rGraphicMapper); private: ShapeContextHandler(ShapeContextHandler const &) = delete; @@ -163,6 +148,4 @@ private: } -#endif // INCLUDED_OOX_SOURCE_SHAPE_SHAPECONTEXTHANDLER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 01dd48280fea..0de6196f54b4 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -476,7 +476,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/dom,\ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/sax,\ FastParser \ - FastShapeContextHandler \ FastTokenHandler \ Parser \ Writer \ @@ -4373,7 +4372,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/xml/sax,\ XFastDocumentHandler \ XFastParser \ XFastSAXSerializable \ - XFastShapeContextHandler \ XFastTokenHandler \ XLocator \ XParser \ diff --git a/offapi/com/sun/star/xml/sax/FastShapeContextHandler.idl b/offapi/com/sun/star/xml/sax/FastShapeContextHandler.idl deleted file mode 100644 index 094482793219..000000000000 --- a/offapi/com/sun/star/xml/sax/FastShapeContextHandler.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef __com_sun_star_xml_sax_FastShapeContextHandler_idl__ -#define __com_sun_star_xml_sax_FastShapeContextHandler_idl__ - -#include - - -module com { module sun { module star { module xml { module sax { - -service FastShapeContextHandler : XFastShapeContextHandler; - -}; }; }; }; }; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl deleted file mode 100644 index 1475db6479b1..000000000000 --- a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl +++ /dev/null @@ -1,62 +0,0 @@ - /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef __com_sun_star_xml_sax_XFastShapeContextHandler_idl__ -#define __com_sun_star_xml_sax_XFastShapeContextHandler_idl__ - -#include -#include -#include -#include -#include -#include -#include - -module com { module sun { module star { module xml { module sax { - - -/** receives notification of sax document events from a - XFastParser. - - @see XFastDocumentHandler - */ -interface XFastShapeContextHandler: com::sun::star::xml::sax::XFastContextHandler -{ - [attribute, readonly] com::sun::star::drawing::XShape Shape; - [attribute] com::sun::star::drawing::XDrawPage DrawPage; - [attribute] com::sun::star::frame::XModel Model; - [attribute] string RelationFragmentPath; - [attribute] long StartToken; - [attribute] com::sun::star::awt::Point Position; - [attribute] com::sun::star::document::XDocumentProperties DocumentProperties; - [attribute] sequence< com::sun::star::beans::PropertyValue > MediaDescriptor; - - /** Graphic mapper to map a key/id string to a XGraphic. This is needed to - remember for XGraphics for a path in the document storage - - @since LibreOffice 7.1 - */ - void setGraphicMapper([in] com::sun::star::graphic::XGraphicMapper xGraphicMapper); -}; - - -}; }; }; }; }; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 7cd7251c4aaf..4eb20ad36cda 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -21,7 +21,7 @@ #include #include -#include "ShapeContextHandler.hxx" +#include #include "ShapeDrawingFragmentHandler.hxx" #include "LockedCanvasContext.hxx" #include "WpsContext.hxx" @@ -389,8 +389,7 @@ void SAL_CALL ShapeContextHandler::characters(const OUString & aChars) xContextHandler->characters(aChars); } -// css::xml::sax::XFastShapeContextHandler: -uno::Reference< drawing::XShape > SAL_CALL +uno::Reference< drawing::XShape > ShapeContextHandler::getShape() { uno::Reference< drawing::XShape > xResult; @@ -520,28 +519,24 @@ ShapeContextHandler::getShape() return xResult; } -css::uno::Reference< css::drawing::XDrawPage > SAL_CALL -ShapeContextHandler::getDrawPage() +css::uno::Reference< css::drawing::XDrawPage > ShapeContextHandler::getDrawPage() { return mxDrawPage; } -void SAL_CALL ShapeContextHandler::setDrawPage -(const css::uno::Reference< css::drawing::XDrawPage > & the_value) +void ShapeContextHandler::setDrawPage(const css::uno::Reference< css::drawing::XDrawPage > & the_value) { mxDrawPage = the_value; } -css::uno::Reference< css::frame::XModel > SAL_CALL -ShapeContextHandler::getModel() +css::uno::Reference< css::frame::XModel > ShapeContextHandler::getModel() { if( !mxShapeFilterBase.is() ) throw uno::RuntimeException(); return mxShapeFilterBase->getModel(); } -void SAL_CALL ShapeContextHandler::setModel -(const css::uno::Reference< css::frame::XModel > & the_value) +void ShapeContextHandler::setModel(const css::uno::Reference< css::frame::XModel > & the_value) { if( !mxShapeFilterBase.is() ) throw uno::RuntimeException(); @@ -549,84 +544,62 @@ void SAL_CALL ShapeContextHandler::setModel mxShapeFilterBase->setTargetDocument(xComp); } -OUString SAL_CALL ShapeContextHandler::getRelationFragmentPath() +OUString ShapeContextHandler::getRelationFragmentPath() { return msRelationFragmentPath; } -void SAL_CALL ShapeContextHandler::setRelationFragmentPath(const OUString & the_value) +void ShapeContextHandler::setRelationFragmentPath(const OUString & the_value) { msRelationFragmentPath = the_value; } -::sal_Int32 SAL_CALL ShapeContextHandler::getStartToken() +sal_Int32 ShapeContextHandler::getStartToken() { return mnStartToken; } -void SAL_CALL ShapeContextHandler::setStartToken( ::sal_Int32 _starttoken ) +void ShapeContextHandler::setStartToken( sal_Int32 _starttoken ) { mnStartToken = _starttoken; } -awt::Point SAL_CALL ShapeContextHandler::getPosition() +awt::Point ShapeContextHandler::getPosition() { return maPosition; } -void SAL_CALL ShapeContextHandler::setPosition(const awt::Point& rPosition) +void ShapeContextHandler::setPosition(const awt::Point& rPosition) { maPosition = rPosition; } -void SAL_CALL ShapeContextHandler::setDocumentProperties(const uno::Reference& xDocProps) +void ShapeContextHandler::setDocumentProperties(const uno::Reference& xDocProps) { mxDocumentProperties = xDocProps; mxShapeFilterBase->checkDocumentProperties(mxDocumentProperties); } -uno::Reference SAL_CALL ShapeContextHandler::getDocumentProperties() +uno::Reference ShapeContextHandler::getDocumentProperties() { return mxDocumentProperties; } -uno::Sequence SAL_CALL ShapeContextHandler::getMediaDescriptor() +uno::Sequence ShapeContextHandler::getMediaDescriptor() { return maMediaDescriptor; } -void SAL_CALL ShapeContextHandler::setMediaDescriptor(const uno::Sequence& rMediaDescriptor) +void ShapeContextHandler::setMediaDescriptor(const uno::Sequence& rMediaDescriptor) { maMediaDescriptor = rMediaDescriptor; } -void SAL_CALL ShapeContextHandler::setGraphicMapper(css::uno::Reference const & rxGraphicMapper) +void ShapeContextHandler::setGraphicMapper(css::uno::Reference const & rxGraphicMapper) { mxShapeFilterBase->setGraphicMapper(rxGraphicMapper); } -OUString ShapeContextHandler::getImplementationName() -{ - return "com.sun.star.comp.oox.ShapeContextHandler"; -} - -uno::Sequence< OUString > ShapeContextHandler::getSupportedServiceNames() -{ - return { "com.sun.star.xml.sax.FastShapeContextHandler" }; -} - -sal_Bool SAL_CALL ShapeContextHandler::supportsService(const OUString & ServiceName) -{ - return cppu::supportsService(this, ServiceName); -} - -} - -extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* -com_sun_star_comp_oox_ShapeContextHandler_get_implementation( - uno::XComponentContext* pCtx, uno::Sequence const& /*rSeq*/) -{ - return cppu::acquire(new oox::shape::ShapeContextHandler(pCtx)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/util/oox.component b/oox/util/oox.component index ef54da9a11e2..3d717a469b07 100644 --- a/oox/util/oox.component +++ b/oox/util/oox.component @@ -36,10 +36,6 @@ - - - diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 4316bb233fbe..5ebfa359193a 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -544,7 +544,6 @@ core_constructor_list = [ "com_sun_star_comp_oox_FormatDetector_get_implementation", "com_sun_star_comp_oox_docprop_DocumentPropertiesImporter_get_implementation", "com_sun_star_comp_oox_ppt_PowerPointImport_get_implementation", - "com_sun_star_comp_oox_ShapeContextHandler_get_implementation", "com_sun_star_comp_oox_crypto_StrongEncryptionDataSpace_get_implementation", ] diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index eaf02c2c80ae..3af599b39f3e 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -5499,6 +5499,7 @@ include/oox/ppt/slidetransitioncontext.hxx include/oox/ppt/soundactioncontext.hxx include/oox/ppt/timenode.hxx include/oox/ppt/timenodelistcontext.hxx +include/oox/shape/ShapeContextHandler.hxx include/oox/shape/ShapeFilterBase.hxx include/oox/token/tokenmap.hxx include/oox/vml/vmldrawing.hxx @@ -7323,7 +7324,6 @@ oox/source/ppt/timenodelistcontext.cxx oox/source/ppt/timetargetelementcontext.cxx oox/source/ppt/timetargetelementcontext.hxx oox/source/shape/ShapeContextHandler.cxx -oox/source/shape/ShapeContextHandler.hxx oox/source/shape/ShapeDrawingFragmentHandler.cxx oox/source/shape/ShapeDrawingFragmentHandler.hxx oox/source/shape/ShapeFilterBase.cxx diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx index de0a8a7134de..8bf1502848ec 100644 --- a/writerfilter/inc/ooxml/OOXMLDocument.hxx +++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx @@ -26,10 +26,10 @@ #include #include #include -#include #include #include #include +#include /** @file OOXMLDocument.hxx @@ -211,8 +211,8 @@ public: virtual void setXNoteId(const sal_Int32 nId) = 0; virtual sal_Int32 getXNoteId() const = 0; virtual const OUString & getTarget() const = 0; - virtual css::uno::Reference getShapeContext( ) = 0; - virtual void setShapeContext( css::uno::Reference xContext ) = 0; + virtual rtl::Reference getShapeContext( ) = 0; + virtual void setShapeContext( rtl::Reference xContext ) = 0; /// Push context of drawingML shapes, so nested shapes are handled separately. virtual void pushShapeContext() = 0; /// Pop context of a previously pushed drawingML shape. diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index 0331d3539508..e0eb6bc48119 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -834,23 +834,23 @@ const uno::Sequence& OOXMLDocumentImpl::getMediaDescriptor return maMediaDescriptor; } -void OOXMLDocumentImpl::setShapeContext( uno::Reference xContext ) +void OOXMLDocumentImpl::setShapeContext( rtl::Reference xContext ) { if (!maShapeContexts.empty()) maShapeContexts.top() = xContext; } -uno::Reference OOXMLDocumentImpl::getShapeContext( ) +rtl::Reference OOXMLDocumentImpl::getShapeContext( ) { if (!maShapeContexts.empty()) return maShapeContexts.top(); else - return uno::Reference(); + return {}; } void OOXMLDocumentImpl::pushShapeContext() { - maShapeContexts.push(uno::Reference()); + maShapeContexts.push({}); } void OOXMLDocumentImpl::popShapeContext() diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx index ed9db125cbe8..c97c208534cf 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx @@ -43,7 +43,7 @@ class OOXMLDocumentImpl : public OOXMLDocument css::uno::Reference mxGlossaryDocDom; css::uno::Sequence < css::uno::Sequence< css::uno::Any > > mxGlossaryDomList; /// Stack of shape contexts, 1 element for VML, 1 element / nesting level for drawingML. - std::stack< css::uno::Reference > maShapeContexts; + std::stack< rtl::Reference > maShapeContexts; css::uno::Reference mxThemeDom; css::uno::Sequence > mxCustomXmlDomList; css::uno::Sequence > mxCustomXmlDomPropsList; @@ -126,8 +126,8 @@ public: virtual void setXNoteId(const sal_Int32 nId) override; virtual sal_Int32 getXNoteId() const override; virtual const OUString & getTarget() const override; - virtual css::uno::Reference getShapeContext( ) override; - virtual void setShapeContext( css::uno::Reference xContext ) override; + virtual rtl::Reference getShapeContext( ) override; + virtual void setShapeContext( rtl::Reference xContext ) override; void pushShapeContext() override; void popShapeContext() override; virtual css::uno::Reference getThemeDom() override; diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index efd097405c90..16abb4987d35 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -1692,11 +1691,11 @@ void OOXMLFastContextHandlerShape::setToken(Token_t nToken) getDocument()->pushShapeContext(); } - mrShapeContext.set(getDocument()->getShapeContext()); + mrShapeContext = getDocument()->getShapeContext(); if (!mrShapeContext.is()) { // Define the shape context for the whole document - mrShapeContext = css::xml::sax::FastShapeContextHandler::create(getComponentContext()); + mrShapeContext = new oox::shape::ShapeContextHandler(getComponentContext()); getDocument()->setShapeContext(mrShapeContext); } diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index dc5c369aa0fe..0e6590a60f69 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "OOXMLParserState.hxx" @@ -448,7 +447,7 @@ class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties bool m_bShapeStarted; /// Is it necessary to pop the stack in the dtor? bool m_bShapeContextPushed; - css::uno::Reference mrShapeContext; + rtl::Reference mrShapeContext; public: explicit OOXMLFastContextHandlerShape(OOXMLFastContextHandler * pContext);