bin/find-can-be-private-symbols.functions.results | 4 bin/find-mergedlib-can-be-private-symbols.functions.results | 4 compilerplugins/clang/mergeclasses.results | 2 compilerplugins/clang/singlevalfields.results | 12 compilerplugins/clang/unusedfields.readonly.results | 8 compilerplugins/clang/unusedmethods.results | 6 cui/source/dialogs/DiagramDialog.cxx | 10 include/oox/drawingml/diagram/diagramhelper_oox.hxx | 34 include/oox/drawingml/shape.hxx | 9 include/svx/diagram/DiagramHelper_svx.hxx | 22 include/svx/diagram/datamodel_svx.hxx | 60 - include/svx/svdobj.hxx | 6 include/svx/svdogrp.hxx | 6 oox/Library_oox.mk | 2 oox/source/drawingml/diagram/datamodel_oox.cxx | 411 +--------- oox/source/drawingml/diagram/datamodel_oox.hxx | 11 oox/source/drawingml/diagram/diagram.cxx | 11 oox/source/drawingml/diagram/diagram.hxx | 8 oox/source/drawingml/diagram/diagramhelper.cxx | 349 -------- oox/source/drawingml/diagram/diagramhelper_oox.cxx | 473 ++++++++++++ oox/source/drawingml/shape.cxx | 32 oox/source/export/drawingml.cxx | 12 oox/source/ppt/pptshapegroupcontext.cxx | 6 oox/source/shape/ShapeContextHandler.cxx | 8 sc/source/ui/drawfunc/drawsh5.cxx | 4 sd/qa/unit/export-tests-ooxml2.cxx | 4 sd/qa/unit/import-tests-smartart.cxx | 6 sd/source/filter/eppt/pptx-epptooxml.cxx | 2 sd/source/ui/func/fusel.cxx | 2 sd/source/ui/view/drviews3.cxx | 4 solenv/clang-format/excludelist | 8 svx/Library_svxcore.mk | 2 svx/qa/unit/svdraw.cxx | 2 svx/source/diagram/DiagramHelper_svx.cxx | 13 svx/source/diagram/datamodel_svx.cxx | 247 ++---- svx/source/svdraw/svdoashp.cxx | 6 svx/source/svdraw/svdobj.cxx | 6 svx/source/svdraw/svdogrp.cxx | 6 svx/source/svdraw/svdundo.cxx | 4 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 4 sw/source/uibase/shells/drwbassh.cxx | 4 41 files changed, 758 insertions(+), 1072 deletions(-)
New commits: commit fde80f0497f89c18ac3d74f181ead958d9d1314a Author: Armin Le Grand (collabora) <[email protected]> AuthorDate: Tue Jan 27 18:49:56 2026 +0100 Commit: Armin Le Grand <[email protected]> CommitDate: Wed Jan 28 10:37:40 2026 +0100 SmartArt: Adapt DiagramModel Up to now with lots of effort ModelData was held at the svx::diagram::Point to keep a stripped version of Text and TextAttributes and also a selective (not complete!) key/value list of attributes for each shape itself (fill/line/text/...). These had to be moved to/rescued from oox::Shape that is used as helper at import to that model after import, set again at the oox::Shapes when XShapes had to be re-created, you name it - very complicated and error-prone, and never complete by definition. Nonetheless data in OOXML MSO format, so pretty easy to re- export if necessary /that's what I was looking at last changes). That also meant that all changes done to an XShape/SdrObject *had* to be somehow transfered to that diagram model data, too. We have no converters for that at all, target would be data representation as in OOXML files. What we *have* is import to our model using oox::Shapes and ccreating XShapes/SdrObjects, and export XShapes snippets 'direct' to MSO ooxml formats. Thus I thought about to use what we have, for the cost to split the model: the DiagramModel *has* to be kept to be able to re-create the Diagram on structural changes, that is needed. But the attribute & text data can stay at the associated XShapes that need to exist and get created anyways. That needs reliable identification of the XShapes belonging to the model. It requires to load that Diagram initially, using the oox::Shapes which have the complete attribute model data to create the XShapes. Remember that there is a 2nd import, from the ReplacementGraphic which (may) be contained in the MSO file. From that moment on changes on those XShapes will be diagram model changes if attributes get changed. But they will not need to forward changes to the DiagramModel in another format. When re-layouting it means to copy that data from old XShape to new XShape, before these get deleted. There may be new XShapes that need to be initialized, too. For export this means that part of that export will have to use the XShapes as model data as needed. This also means that the quality of im/export of Diagrams will in the future rely on the quality of our existing im/export snippets for XShape/oox::Shape/oox. These are developed and in use for a while now and should have reached a good quality. If we have to improve these that will always improve im/export and Diagram stuff then, too. This change does that big change and looks promising, doing what it is intended to do. I still have to experiment, so in master it is still deactivated due to being too dangerous yet, see last SmartArt change and mention of ACTIVATE_RECREATE_DIAGRAM_DATADOMS and it's description. Change-Id: Ife1591b0d3c8974d90a1004d94f3e6799be85a56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198221 Tested-by: Jenkins Reviewed-by: Armin Le Grand <[email protected]> diff --git a/bin/find-can-be-private-symbols.functions.results b/bin/find-can-be-private-symbols.functions.results index 10e85b53b006..68e63af4ba4f 100644 --- a/bin/find-can-be-private-symbols.functions.results +++ b/bin/find-can-be-private-symbols.functions.results @@ -15373,11 +15373,11 @@ svx::ThemeDialog::runThemeColorEditDialog() svx::classification::containsProperty(com::sun::star::uno::Sequence<com::sun::star::beans::Property> const&, std::basic_string_view<char16_t, std::char_traits<char16_t> >) svx::classification::convertClassificationResultToString(std::__debug::vector<svx::ClassificationResult, std::allocator<svx::ClassificationResult> > const&) svx::diagram::DiagramData_svx::addConnection(svx::diagram::TypeConstant, rtl::OUString const&, rtl::OUString const&) -svx::diagram::DiagramData_svx::getChildrenString(rtl::OUStringBuffer&, svx::diagram::Point const*, int) const +svx::diagram::DiagramData_svx::getDiagramChildrenString(rtl::OUStringBuffer&, svx::diagram::Point const*, int) const svx::diagram::DiagramDataState::DiagramDataState(std::__debug::vector<svx::diagram::Connection, std::allocator<svx::diagram::Connection> >, std::__debug::vector<svx::diagram::Point, std::allocator<svx::diagram::Point> >) svx::diagram::DiagramFrameHdl::CreateB2dIAObject() svx::diagram::DiagramFrameHdl::DiagramFrameHdl(basegfx::B2DHomMatrix const&) -svx::diagram::IDiagramHelper::AddAdditionalVisualization(SdrObjGroup const&, SdrHdlList&) +svx::diagram::DiagramHelper_svx::AddAdditionalVisualization(SdrObjGroup const&, SdrHdlList&) svx::frame::Style::Set(double, double, double) svx::frame::Style::hashCode() const svx::sidebar::AreaPropertyPanelBase::FillStyleChanged(bool) diff --git a/bin/find-mergedlib-can-be-private-symbols.functions.results b/bin/find-mergedlib-can-be-private-symbols.functions.results index a5d281d22aa1..d50c4fc4df7f 100644 --- a/bin/find-mergedlib-can-be-private-symbols.functions.results +++ b/bin/find-mergedlib-can-be-private-symbols.functions.results @@ -15747,10 +15747,10 @@ svx::checkForFontWork(SdrObject const*) svx::classification::containsProperty(com::sun::star::uno::Sequence<com::sun::star::beans::Property> const&, std::basic_string_view<char16_t, std::char_traits<char16_t> >) svx::classification::convertClassificationResultToString(std::vector<svx::ClassificationResult, std::allocator<svx::ClassificationResult> > const&) svx::diagram::DiagramData_svx::addConnection(svx::diagram::TypeConstant, rtl::OUString const&, rtl::OUString const&) -svx::diagram::DiagramData_svx::getChildrenString(rtl::OUStringBuffer&, svx::diagram::Point const*, int) const +svx::diagram::DiagramData_svx::getDiagramChildrenString(rtl::OUStringBuffer&, svx::diagram::Point const*, int) const svx::diagram::DiagramFrameHdl::CreateB2dIAObject() svx::diagram::DiagramFrameHdl::DiagramFrameHdl(basegfx::B2DHomMatrix const&) -svx::diagram::IDiagramHelper::AddAdditionalVisualization(SdrObjGroup const&, SdrHdlList&) +svx::diagram::DiagramHelper_svx::AddAdditionalVisualization(SdrObjGroup const&, SdrHdlList&) svx::frame::Array::GetB2DRange(int, int, int, int) const svx::frame::Array::GetCellCount() const svx::frame::Array::GetCellStyleBL(int, int) const diff --git a/compilerplugins/clang/mergeclasses.results b/compilerplugins/clang/mergeclasses.results index 4257c7327a0d..c08a2c7fa3cf 100644 --- a/compilerplugins/clang/mergeclasses.results +++ b/compilerplugins/clang/mergeclasses.results @@ -685,7 +685,7 @@ merge svx::IFocusObserver with svx::FmTextControlShell maybe merge svx::ODataAccessObjectTransferable with dbaui::ODataClipboard, in modules svx and dbaccess merge svx::RegistrationItemSetHolder with svx::DatabaseRegistrationDialog maybe merge svx::diagram::DiagramData_svx with oox::drawingml::DiagramData, in modules svx and oox -maybe merge svx::diagram::IDiagramHelper with oox::drawingml::AdvancedDiagramHelper, in modules svx and oox +maybe merge svx::diagram::DiagramHelper_svx with oox::drawingml::DiagramHelper_oox, in modules svx and oox maybe merge svx::sidebar::InspectorTextPanel with sw::sidebar::WriterInspectorTextPanel, in modules svx and sw merge svx::sidebar::SvxShapeCommandsMap with svx::sidebar::DefaultShapesPanel merge svxform::DispatchInterceptor with svxform::FormController diff --git a/compilerplugins/clang/singlevalfields.results b/compilerplugins/clang/singlevalfields.results index f82fe970ae82..839ee36d0060 100644 --- a/compilerplugins/clang/singlevalfields.results +++ b/compilerplugins/clang/singlevalfields.results @@ -343,14 +343,14 @@ include/svx/deflt3d.hxx:54 include/svx/deflt3d.hxx:55 E3dDefaultAttributes m_bDefaultExtrudeSmoothFrontBack 0 -include/svx/diagram/IDiagramHelper.hxx:72 - svx::diagram::IDiagramHelper mbUseDiagramThemeData +include/svx/diagram/DiagramHelper_svx.hxx:72 + svx::diagram::DiagramHelper_svx mbUseDiagramThemeData 0 -include/svx/diagram/IDiagramHelper.hxx:77 - svx::diagram::IDiagramHelper mbUseDiagramModelData +include/svx/diagram/DiagramHelper_svx.hxx:77 + svx::diagram::DiagramHelper_svx mbUseDiagramModelData 1 -include/svx/diagram/IDiagramHelper.hxx:81 - svx::diagram::IDiagramHelper mbForceThemePtrRecreation +include/svx/diagram/DiagramHelper_svx.hxx:81 + svx::diagram::DiagramHelper_svx mbForceThemePtrRecreation 0 include/svx/fontwork.hxx:77 SvxFontWorkDialog aInputIdle diff --git a/compilerplugins/clang/unusedfields.readonly.results b/compilerplugins/clang/unusedfields.readonly.results index 04f665f59493..26b835529dec 100644 --- a/compilerplugins/clang/unusedfields.readonly.results +++ b/compilerplugins/clang/unusedfields.readonly.results @@ -382,10 +382,10 @@ include/svl/ondemand.hxx:54 OnDemandLocaleDataWrapper aSysLocale SvtSysLocale include/svx/annotation/Annotation.hxx:108 sdr::annotation::Annotation maUniqueID UniqueID -include/svx/diagram/IDiagramHelper.hxx:71 - svx::diagram::IDiagramHelper mbUseDiagramThemeData _Bool -include/svx/diagram/IDiagramHelper.hxx:80 - svx::diagram::IDiagramHelper mbForceThemePtrRecreation _Bool +include/svx/diagram/DiagramHelper_svx.hxx:71 + svx::diagram::DiagramHelper_svx mbUseDiagramThemeData _Bool +include/svx/diagram/DiagramHelper_svx.hxx:80 + svx::diagram::DiagramHelper_svx mbForceThemePtrRecreation _Bool include/svx/EnhancedCustomShape2d.hxx:108 EnhancedCustomShape2d::EquationResult bReady _Bool include/svx/graphctl.hxx:52 diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results index feb414cd1eca..68670d274b4b 100644 --- a/compilerplugins/clang/unusedmethods.results +++ b/compilerplugins/clang/unusedmethods.results @@ -916,10 +916,10 @@ include/svx/ClassificationField.hxx:53 _Bool svx::ClassificationResult::operator==(const svx::ClassificationResult &) const include/svx/ctredlin.hxx:64 std::basic_ostream<char> & operator<<(std::basic_ostream<char> &,const enum RedlineType &) -include/svx/diagram/IDiagramHelper.hxx:47 +include/svx/diagram/DiagramHelper_svx.hxx:47 void svx::diagram::DiagramFrameHdl::clicked(const struct svx::diagram::Point &) -include/svx/diagram/IDiagramHelper.hxx:97 - rtl::OUString svx::diagram::IDiagramHelper::getString() const +include/svx/diagram/DiagramHelper_svx.hxx:97 + rtl::OUString svx::diagram::DiagramHelper_svx::getString() const include/svx/dlgctrl.hxx:263 void SvxLineEndLB::set_active_text(const rtl::OUString &) include/svx/framelink.hxx:169 diff --git a/cui/source/dialogs/DiagramDialog.cxx b/cui/source/dialogs/DiagramDialog.cxx index 18fea8e75824..a04b0dd6c709 100644 --- a/cui/source/dialogs/DiagramDialog.cxx +++ b/cui/source/dialogs/DiagramDialog.cxx @@ -15,7 +15,7 @@ #include <svx/svdundo.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <svx/diagram/datamodel_svx.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> DiagramDialog::DiagramDialog(weld::Window* pWindow, SdrObjGroup& rDiagram) : GenericDialogController(pWindow, u"cui/ui/diagramdialog.ui"_ustr, u"DiagramDialog"_ustr) @@ -61,7 +61,7 @@ IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void) return; OUString sText = mpTextAdd->get_text(); - const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper()); + const std::shared_ptr< svx::diagram::DiagramHelper_svx >& pDiagramHelper(m_rDiagram.getDiagramHelper()); if (pDiagramHelper && !sText.isEmpty()) { @@ -99,7 +99,7 @@ IMPL_LINK_NOARG(DiagramDialog, OnRemoveClick, weld::Button&, void) return; std::unique_ptr<weld::TreeIter> pEntry = mpTreeDiagram->get_selected(); - const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper()); + const std::shared_ptr< svx::diagram::DiagramHelper_svx >& pDiagramHelper(m_rDiagram.getDiagramHelper()); if (pDiagramHelper && pEntry) { @@ -135,12 +135,12 @@ void DiagramDialog::populateTree(const weld::TreeIter* pParent, const OUString& if (!m_rDiagram.isDiagram()) return; - const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper()); + const std::shared_ptr< svx::diagram::DiagramHelper_svx >& pDiagramHelper(m_rDiagram.getDiagramHelper()); if (!pDiagramHelper) return; - auto aItems = pDiagramHelper->getChildren(rParentId); + auto aItems = pDiagramHelper->getDiagramChildren(rParentId); for (auto& aItem : aItems) { std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); diff --git a/include/oox/drawingml/diagram/diagramhelper.hxx b/include/oox/drawingml/diagram/diagramhelper_oox.hxx similarity index 76% rename from include/oox/drawingml/diagram/diagramhelper.hxx rename to include/oox/drawingml/diagram/diagramhelper_oox.hxx index cfd27b1f1d19..ecc9a3f3629b 100644 --- a/include/oox/drawingml/diagram/diagramhelper.hxx +++ b/include/oox/drawingml/diagram/diagramhelper_oox.hxx @@ -24,7 +24,7 @@ #include <oox/drawingml/theme.hxx> #include <oox/shape/ShapeFilterBase.hxx> #include <svx/svdogrp.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> namespace oox::drawingml { @@ -43,50 +43,58 @@ class Diagram; // - deliver representative data from the Diagram-Model // - modify it eventually // - im/export Diagram model to other representations -class AdvancedDiagramHelper final : public svx::diagram::IDiagramHelper +class DiagramHelper_oox final : public svx::diagram::DiagramHelper_svx { const std::shared_ptr< Diagram > mpDiagramPtr; std::shared_ptr<::oox::drawingml::Theme> mpThemePtr; css::awt::Size maImportSize; + // data values set by addDiagramNode to be used by next reLayout call + // when a new ode gets added + OUString msNewNodeId; + OUString msNewNodeText; + bool hasDiagramData() const; + static void moveDiagramModelDataFromOldToNewXShape( + const css::uno::Reference<css::drawing::XShape>& xOldShape, + const css::uno::Reference<css::drawing::XShape>& xNewShape); + public: - AdvancedDiagramHelper( + DiagramHelper_oox( std::shared_ptr< Diagram > xDiagramPtr, std::shared_ptr<::oox::drawingml::Theme> xTheme, - css::awt::Size aImportSize, - bool bSelfCreated); - virtual ~AdvancedDiagramHelper(); + css::awt::Size aImportSize); + virtual ~DiagramHelper_oox(); // re-create XShapes - virtual void reLayout(SdrObjGroup& rTarget) override; + virtual void reLayout() override; // get text representation of data tree - virtual OUString getString() const override; + virtual OUString getDiagramString() const override; // get children of provided data node // use empty string for top-level nodes // returns vector of (id, text) - virtual std::vector<std::pair<OUString, OUString>> getChildren(const OUString& rParentId) const override; + virtual std::vector<std::pair<OUString, OUString>> getDiagramChildren(const OUString& rParentId) const override; // add/remove new top-level node to data model, returns its id virtual OUString addDiagramNode(const OUString& rText) override; virtual bool removeDiagramNode(const OUString& rNodeId) override; - virtual void TextInformationChange(const OUString& rDiagramDataModelID, SdrOutliner& rOutl) override; + virtual void TextInformationChange() override; // Undo/Redo helpers to extract/restore Diagram-defining data virtual std::shared_ptr< svx::diagram::DiagramDataState > extractDiagramDataState() const override; virtual void applyDiagramDataState(const std::shared_ptr< svx::diagram::DiagramDataState >& rState) override; - void doAnchor(com::sun::star::uno::Reference<com::sun::star::drawing::XShape>& rTarget, ::oox::drawingml::Shape& rRootShape); + void doAnchor(css::uno::Reference<css::drawing::XShape>& rTarget); const std::shared_ptr< ::oox::drawingml::Theme >& getOrCreateThemePtr( const rtl::Reference< oox::shape::ShapeFilterBase>& rxFilter ) const; // access to get/set PropertyValues - void setOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag, const com::sun::star::uno::Any& rValue); - virtual com::sun::star::uno::Any getOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag) const override; + void setOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag, const css::uno::Any& rValue); + virtual css::uno::Any getOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag) const override; // check if mandatory DiagramDomS exist (or can be created) bool checkMinimalDataDoms() const; diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx index 2da7db183bb2..ed6b5a18ac94 100644 --- a/include/oox/drawingml/shape.hxx +++ b/include/oox/drawingml/shape.hxx @@ -65,7 +65,7 @@ struct FillProperties; struct GraphicProperties; struct LineProperties; struct Shape3DProperties; -class AdvancedDiagramHelper; +class DiagramHelper_oox; class CustomShapeProperties; typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; @@ -233,7 +233,7 @@ public: SAL_DLLPRIVATE void setTextBox(bool bTextBox); // access to DiagramHelper - AdvancedDiagramHelper* getDiagramHelper() const { return mpDiagramHelper; } + DiagramHelper_oox* getDiagramHelper() const { return mpDiagramHelper; } SAL_DLLPRIVATE css::uno::Sequence< css::uno::Sequence< css::uno::Any > >resolveRelationshipsOfTypeFromOfficeDoc( core::XmlFilterBase& rFilter, const OUString& sFragment, std::u16string_view sType ); void setLinkedTxbxAttributes(const LinkedTxbxAttr& rhs){ maLinkedTxbxAttr = rhs; }; @@ -271,8 +271,7 @@ public: // existing one to the data holder object later SAL_DLLPRIVATE void prepareDiagramHelper( const std::shared_ptr< Diagram >& rDiagramPtr, - const std::shared_ptr<::oox::drawingml::Theme>& rTheme, - bool bSelfCreated); + const std::shared_ptr<::oox::drawingml::Theme>& rTheme); SAL_DLLPRIVATE void propagateDiagramHelper(); // for Writer it is necessary to migrate an existing helper to a new Shape @@ -449,7 +448,7 @@ private: // temporary space for DiagramHelper in preparation for collecting data // Note: I tried to use a unique_ptr here, but existing constructor func does not allow that - AdvancedDiagramHelper* mpDiagramHelper; + DiagramHelper_oox* mpDiagramHelper; // association-ID to identify the Diagram ModelData OUString msDiagramDataModelID; diff --git a/include/svx/diagram/IDiagramHelper.hxx b/include/svx/diagram/DiagramHelper_svx.hxx similarity index 88% rename from include/svx/diagram/IDiagramHelper.hxx rename to include/svx/diagram/DiagramHelper_svx.hxx index 33cde5244efb..a24b8174802e 100644 --- a/include/svx/diagram/IDiagramHelper.hxx +++ b/include/svx/diagram/DiagramHelper_svx.hxx @@ -52,7 +52,7 @@ class DiagramDataState; // Helper class to allow administer advanced Diagram related // data and functionality -class SVXCORE_DLLPUBLIC IDiagramHelper +class SVXCORE_DLLPUBLIC DiagramHelper_svx { private: // These values define behaviour to where take data from at re-creation time. @@ -80,34 +80,30 @@ private: // a newly created oox::drawingml::Theme object bool mbForceThemePtrRecreation; // false - // if true, content was self-created using addTo/addShape - // and the layouting stuff - bool mbSelfCreated; - protected: // remember associated SdrObjGroup com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxGroupShape; public: - IDiagramHelper(bool bSelfCreated); - virtual ~IDiagramHelper(); + DiagramHelper_svx(); + virtual ~DiagramHelper_svx(); // re-create XShapes - virtual void reLayout(SdrObjGroup& rTarget) = 0; + virtual void reLayout() = 0; // get text representation of data tree - virtual OUString getString() const = 0; + virtual OUString getDiagramString() const = 0; // get children of provided data node // use empty string for top-level nodes // returns vector of (id, text) virtual std::vector<std::pair<OUString, OUString>> - getChildren(const OUString& rParentId) const = 0; + getDiagramChildren(const OUString& rParentId) const = 0; // add/remove new top-level node to data model, returns its id virtual OUString addDiagramNode(const OUString& rText) = 0; virtual bool removeDiagramNode(const OUString& rNodeId) = 0; - virtual void TextInformationChange(const OUString& rDiagramDataModelID, SdrOutliner& rOutl) = 0; + virtual void TextInformationChange() = 0; // Undo/Redo helpers for extracting/restoring Diagram-defining data virtual std::shared_ptr<svx::diagram::DiagramDataState> extractDiagramDataState() const = 0; @@ -117,10 +113,6 @@ public: bool UseDiagramModelData() const { return mbUseDiagramModelData; } bool ForceThemePtrRecreation() const { return mbForceThemePtrRecreation; }; - // get/set SelfCreated flag - bool isSelfCreated() const { return mbSelfCreated; } - void setSelfCreated() { mbSelfCreated = true; } - // connect/disconnect to/from Group void connectToSdrObjGroup(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rTarget); void disconnectFromSdrObjGroup(); diff --git a/include/svx/diagram/datamodel_svx.hxx b/include/svx/diagram/datamodel_svx.hxx index 6df1c1963c3e..4587678781fc 100644 --- a/include/svx/diagram/datamodel_svx.hxx +++ b/include/svx/diagram/datamodel_svx.hxx @@ -36,8 +36,6 @@ #include <oox/token/tokens.hxx> #include <sax/fshelper.hxx> -class Outliner; - namespace svx::diagram { enum TypeConstant { @@ -77,47 +75,12 @@ struct SVXCORE_DLLPUBLIC Connection typedef std::vector< Connection > Connections; -/** Text and properties for a point - * For proof of concept to make TextData available in svx level this - * is in a first run pretty simple, but may need to be extended accordingly - * up to similar data as in oox::drawingml::TextBody. - */ -struct SVXCORE_DLLPUBLIC TextBody -{ - // text from 1st paragraph (1st run) - OUString msText; - - // attributes from TextBody::getTextProperties() - std::vector< std::pair< OUString, css::uno::Any >> maTextProps; -}; - -typedef std::shared_ptr< TextBody > TextBodyPtr; - -/** Styles for a Point (FillStyle/LineStyle/...) - */ -struct SVXCORE_DLLPUBLIC PointStyle -{ - // attributes (LineStyle/FillStyle/...) - std::vector< std::pair< OUString, css::uno::Any >> maProperties; -}; - -typedef std::shared_ptr< PointStyle > PointStylePtr; - /** A point */ struct SVXCORE_DLLPUBLIC Point { Point(); - // The minimal text data from the imported Diagram - // in source format - TextBodyPtr msTextBody; - - // The property sequence of pairs<OUString, css::uno::Any>, - // interpreted & assigned by the ::addShape(s) creators in the - // import filter that created a XShape associated/based on this entry - PointStylePtr msPointStylePtr; - OUString msCnxId; OUString msModelId; OUString msColorTransformCategoryId; @@ -159,9 +122,10 @@ struct SVXCORE_DLLPUBLIC Point bool mbCustomText; bool mbIsPlaceholder; - void writeDiagramData(sax_fastparser::FSHelperPtr& rTarget); + void writeDiagramData_data(sax_fastparser::FSHelperPtr& rTarget); }; +void SVXCORE_DLLPUBLIC addTypeConstantToFastAttributeList(TypeConstant aTypeConstant, rtl::Reference<sax_fastparser::FastAttributeList>& rAttributeList); typedef std::vector< Point > Points; /** Snippet of Diagram ModelData for Diagram-defining data undo/redo @@ -215,13 +179,14 @@ public: // read accesses Connections& getConnections() { return maConnections; } Points& getPoints() { return maPoints; } + const Points& getPoints() const { return maPoints; } StringMap& getPresOfNameMap() { return maPresOfNameMap; } PointNameMap& getPointNameMap() { return maPointNameMap; } PointsNameMap& getPointsPresNameMap() { return maPointsPresNameMap; } ::std::vector<OUString>& getExtDrawings() { return maExtDrawings; } const Point* getRootPoint() const; - OUString getString() const; - std::vector<std::pair<OUString, OUString>> getChildren(const OUString& rParentId) const; + OUString getDiagramString(const css::uno::Reference<css::drawing::XShape>& rRootShape) const; + std::vector<std::pair<OUString, OUString>> getDiagramChildren(const OUString& rParentId, const css::uno::Reference<css::drawing::XShape>& rRootShape) const; const css::uno::Reference< css::xml::dom::XDocument >& getThemeDocument() const { return mxThemeDocument; } void setThemeDocument( const css::uno::Reference< css::xml::dom::XDocument >& xRef ) { mxThemeDocument = xRef; } @@ -230,17 +195,20 @@ public: void setBackgroundShapeModelID( const OUString& rModelID ) { msBackgroundShapeModelID = rModelID; } // model modifiers - std::pair<OUString, DomMapFlags> addDiagramNode(const OUString& rText); + std::pair<OUString, DomMapFlags> addDiagramNode(); DomMapFlags removeDiagramNode(const OUString& rNodeId); - DomMapFlags TextInformationChange(const OUString& rDiagramDataModelID, Outliner& rOutl); // Undo/Redo helpers to extract/restore Diagram-defining data DiagramDataStatePtr extractDiagramDataState() const; void applyDiagramDataState(const DiagramDataStatePtr& rState); + css::uno::Reference<css::drawing::XShape> getMasterXShapeForPoint(const Point& rPoint, const css::uno::Reference<css::drawing::XShape>& rRootShape) const; + OUString getTextForPoint(const Point& rPoint, const css::uno::Reference<css::drawing::XShape>& rRootShape) const; + static css::uno::Reference<css::drawing::XShape> getXShapeByModelID(const css::uno::Reference<css::drawing::XShape>& rxShape, std::u16string_view rModelID); + protected: // helpers - void getChildrenString(OUStringBuffer& rBuf, const Point* pPoint, sal_Int32 nLevel) const; + void getDiagramChildrenString(OUStringBuffer& rBuf, const Point* pPoint, sal_Int32 nLevel, const css::uno::Reference<css::drawing::XShape>& rRootShape) const; void addConnection(TypeConstant nType, const OUString& sSourceId, const OUString& sDestId); // evtl. existing alternative imported visualization identifier @@ -254,12 +222,6 @@ protected: // - data point entries Points maPoints; - // - style for the BackgroundShape (if used) - // this is the property sequence of pairs<OUString, css::uno::Any>, - // as interpreted & assigned by the ::addShape(s) creators in the - // import filter - PointStylePtr maBackgroundShapeStyle; - // - Theme definition as css::xml::dom::XDocument // Note: I decided to use dom::XDocument which is already in use, instead of a // temp file what is also possible (implemented that for POC) but would diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 1a9a4b37c181..78c0fdd1dc79 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -80,7 +80,7 @@ namespace sdr::properties { class BaseProperties; } namespace sdr::contact { class ViewContact; } namespace sdr::annotation { class ObjectAnnotationData; } namespace com::sun::star::drawing { class XShape; } -namespace svx::diagram { class IDiagramHelper; } +namespace svx::diagram { class DiagramHelper_svx; } enum class SdrInventor : sal_uInt32 { @@ -228,8 +228,8 @@ class SVXCORE_DLLPUBLIC SdrObject : public SfxListener, public cppu::OWeakObject public: // Basic DiagramHelper support virtual bool isDiagram() const; - virtual const std::shared_ptr< svx::diagram::IDiagramHelper >& getDiagramHelper() const; - const std::shared_ptr< svx::diagram::IDiagramHelper >& getDiagramHelperFromDiagramOrMember() const; + virtual const std::shared_ptr< svx::diagram::DiagramHelper_svx >& getDiagramHelper() const; + const std::shared_ptr< svx::diagram::DiagramHelper_svx >& getDiagramHelperFromDiagramOrMember() const; void setDiagramDataModelID(const OUString& rID) { msDiagramDataModelID = rID; } const OUString& getDiagramDataModelID() const { return msDiagramDataModelID; } diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx index 5949f3d4b4b0..5e8c9f58f0ab 100644 --- a/include/svx/svdogrp.hxx +++ b/include/svx/svdogrp.hxx @@ -30,7 +30,7 @@ class SVXCORE_DLLPUBLIC SdrObjGroup final : public SdrObject, public SdrObjList public: // Basic DiagramHelper support virtual bool isDiagram() const override; - virtual const std::shared_ptr< svx::diagram::IDiagramHelper >& getDiagramHelper() const override; + virtual const std::shared_ptr< svx::diagram::DiagramHelper_svx >& getDiagramHelper() const override; private: virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override; @@ -41,8 +41,8 @@ private: // Allow *only* DiagramHelper itself to set this internal reference to // tightly control usage - friend class svx::diagram::IDiagramHelper; - std::shared_ptr< svx::diagram::IDiagramHelper > mp_DiagramHelper; + friend class svx::diagram::DiagramHelper_svx; + std::shared_ptr< svx::diagram::DiagramHelper_svx > mp_DiagramHelper; public: SdrObjGroup(SdrModel& rSdrModel); diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index 550a82e839ba..74b9dc3f2aaa 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -159,7 +159,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\ oox/source/drawingml/diagram/datamodel_oox \ oox/source/drawingml/diagram/datamodelcontext \ oox/source/drawingml/diagram/diagram \ - oox/source/drawingml/diagram/diagramhelper \ + oox/source/drawingml/diagram/diagramhelper_oox \ oox/source/drawingml/diagram/diagramdefinitioncontext \ oox/source/drawingml/diagram/diagramfragmenthandler \ oox/source/drawingml/diagram/diagramlayoutatoms \ diff --git a/oox/source/drawingml/diagram/datamodel_oox.cxx b/oox/source/drawingml/diagram/datamodel_oox.cxx index 37d89661bf69..33796886e2e1 100644 --- a/oox/source/drawingml/diagram/datamodel_oox.cxx +++ b/oox/source/drawingml/diagram/datamodel_oox.cxx @@ -31,13 +31,14 @@ #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <editeng/unoprnms.hxx> -#include <svx/svdobj.hxx> #include <oox/token/namespaces.hxx> #include <oox/export/drawingml.hxx> +#include <sax/fastattribs.hxx> #include <unordered_set> using namespace ::com::sun::star; +using namespace ::svx::diagram; namespace oox::drawingml { @@ -53,44 +54,12 @@ Shape* DiagramData_oox::getOrCreateAssociatedShape(const svx::diagram::Point& rP if(!rShapePtr && bCreateOnDemand) { const_cast<ShapePtr&>(rShapePtr) = std::make_shared<Shape>(); - - // If we did create a new oox::drawingml::Shape, directly apply - // available data from the Diagram ModelData to it as preparation - restoreDataFromModelToShapeAfterReCreation(rPoint, *rShapePtr); } return rShapePtr.get(); } -void DiagramData_oox::restoreDataFromModelToShapeAfterReCreation(const svx::diagram::Point& rPoint, Shape& rNewShape) -{ - // If we did create a new oox::drawingml::Shape, directly apply - // available data from the Diagram ModelData to it as preparation - - // This is e.g. the Text, but may get more (styles?) - if(!rPoint.msTextBody->msText.isEmpty()) - { - TextBodyPtr aNewTextBody(std::make_shared<TextBody>()); - rNewShape.setTextBody(aNewTextBody); - TextRunPtr pTextRun = std::make_shared<TextRun>(); - pTextRun->getText() = rPoint.msTextBody->msText; - aNewTextBody->addParagraph().addRun(pTextRun); - - if(!rPoint.msTextBody->maTextProps.empty()) - { - oox::PropertyMap& rTargetMap(aNewTextBody->getTextProperties().maPropertyMap); - - for (auto const& prop : rPoint.msTextBody->maTextProps) - { - const sal_Int32 nPropId(oox::PropertyMap::getPropertyId(prop.first)); - if(nPropId > 0) - rTargetMap.setAnyProperty(nPropId, prop.second); - } - } - } -} - -void DiagramData_oox::writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastparser::FSHelperPtr& rTarget, const css::uno::Reference<css::drawing::XShape>& rXShape) +void DiagramData_oox::writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastparser::FSHelperPtr& rTarget, const uno::Reference<drawing::XShape>& rRootShape) { if (!rTarget) return; @@ -105,7 +74,50 @@ void DiagramData_oox::writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastpa // write PointList rTarget->startElementNS(XML_dgm, XML_ptLst); for (auto& rPoint : getPoints()) - rPoint.writeDiagramData(rTarget); + { + rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList(sax_fastparser::FastSerializerHelper::createAttrList()); + + pAttributeList->add(XML_modelId, rPoint.msModelId); + addTypeConstantToFastAttributeList(rPoint.mnXMLType, pAttributeList); + if (!rPoint.msCnxId.isEmpty()) + pAttributeList->add(XML_cxnId, rPoint.msCnxId); + rTarget->startElementNS(XML_dgm, XML_pt, pAttributeList); + + rPoint.writeDiagramData_data(rTarget); + + uno::Reference<drawing::XShape> xMasterText(getMasterXShapeForPoint(rPoint, rRootShape)); + + if (xMasterText) + { + rTarget->startElementNS(XML_dgm, XML_t); + DrawingML aTempML(rTarget, &rFB); + aTempML.WriteText(xMasterText, false, true, XML_a); + rTarget->endElementNS(XML_dgm, XML_t); + + // uno::Reference<beans::XPropertySet> xProps(xBgShape, uno::UNO_QUERY); + // aTempML.WriteFill( xProps, xBgShape->getSize()); + } + else + { + const bool bWriteEmptyText( + TypeConstant::XML_parTrans == rPoint.mnXMLType || + TypeConstant::XML_sibTrans == rPoint.mnXMLType || + "textNode" == rPoint.msPresentationLayoutName); + + if (bWriteEmptyText) + { + rTarget->startElementNS(XML_dgm, XML_t); + rTarget->singleElementNS(XML_a, XML_bodyPr); + rTarget->singleElementNS(XML_a, XML_lstStyle); + rTarget->startElementNS(XML_a, XML_p); + rTarget->singleElementNS(XML_a, XML_endParaRPr, XML_lang, "en-US"); + rTarget->endElementNS(XML_a, XML_p); + rTarget->endElementNS(XML_dgm, XML_t); + } + } + + rTarget->endElementNS(XML_dgm, XML_pt); + } rTarget->endElementNS(XML_dgm, XML_ptLst); // write ConnectorList @@ -127,21 +139,7 @@ void DiagramData_oox::writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastpa // Diagram::createShapeHierarchyFromModel. This will also allow to use existing stuff like standard dialogs // and more for later offering changing the Background of a Diagram. // Note that an incarnation of BG as XShape is also needed to 'carry' the correct Size for that Diagram. - uno::Reference<drawing::XShape> xBgShape; - uno::Reference<drawing::XShapes> xGroup(rXShape, uno::UNO_QUERY); - if (xGroup.is() && 0 != xGroup->getCount()) - { - // access the BGShape, it *should* always exist and be the 1st shape (to *be* in the BG) - uno::Reference<drawing::XShape> xCandidate(xGroup->getByIndex(0), uno::UNO_QUERY); - if (xCandidate.is()) - { - // check comparing the DiagramDataModelID created at BackgroundSHape creation for the oox::Shape - // that got transferred to the XShape when it was created - SdrObject* pCandidate(SdrObject::getSdrObjectFromXShape(xCandidate)); - if (nullptr != pCandidate && pCandidate->getDiagramDataModelID() == getBackgroundShapeModelID()) - xBgShape = xCandidate; - } - } + uno::Reference<drawing::XShape> xBgShape(getXShapeByModelID(rRootShape, getBackgroundShapeModelID())); if (xBgShape.is()) { @@ -177,319 +175,6 @@ void DiagramData_oox::writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastpa rTarget->endDocument(); } -static void addProperty(const OUString& rName, - const css::uno::Reference< css::beans::XPropertySetInfo >& xInfo, - std::vector< std::pair< OUString, css::uno::Any >>& rTarget, - const css::uno::Reference< css::beans::XPropertySet >& xPropSet ) -{ - if(xInfo->hasPropertyByName(rName)) - rTarget.push_back(std::pair(OUString(rName), xPropSet->getPropertyValue(rName))); -} - -void DiagramData_oox::secureStyleDataFromShapeToModel(::oox::drawingml::Shape& rShape) -{ - const std::vector< ShapePtr >& rChildren(rShape.getChildren()); - - if(!rChildren.empty()) - { - // group shape - for (auto& child : rChildren) - { - secureStyleDataFromShapeToModel(*child); - } - - // if group shape we are done. Do not secure properties for group shapes - return; - } - - // we need a XShape - const css::uno::Reference< css::drawing::XShape > &rXShape(rShape.getXShape()); - if(!rXShape) - return; - - // we need a ModelID for association - if(rShape.getDiagramDataModelID().isEmpty()) - return; - - // define target to save to - svx::diagram::PointStyle* pTarget(nullptr); - const bool bIsBackgroundShape(rShape.getDiagramDataModelID() == getBackgroundShapeModelID()); - - if(bIsBackgroundShape) - { - // if BackgroundShape, create properties & set as target - if(!maBackgroundShapeStyle) - maBackgroundShapeStyle = std::make_shared< svx::diagram::PointStyle >(); - pTarget = maBackgroundShapeStyle.get(); - } - else - { - // if Shape, seek association - for (auto & point : maPoints) - { - if(point.msModelId == rShape.getDiagramDataModelID()) - { - // found - create properties & set as target - pTarget = point.msPointStylePtr.get(); - - // we are done, there is no 2nd shape with the same ModelID by definition - break; - } - } - } - - // no target -> nothing to do - if(nullptr == pTarget) - return; - -#ifdef DBG_UTIL - // to easier decide which additional properties may/should be preserved, - // create a full list of set properties to browse/decide (in debugger) - const css::uno::Reference< css::beans::XPropertyState > xAllPropStates(rXShape, css::uno::UNO_QUERY); - const css::uno::Reference< css::beans::XPropertySet > xAllPropSet( rXShape, css::uno::UNO_QUERY ); - const css::uno::Sequence< css::beans::Property > allSequence(xAllPropSet->getPropertySetInfo()->getProperties()); - std::vector< std::pair< OUString, css::uno::Any >> allSetProps; - for (auto& rProp : allSequence) - { - try - { - if (xAllPropStates->getPropertyState(rProp.Name) == css::beans::PropertyState::PropertyState_DIRECT_VALUE) - { - css::uno::Any aValue(xAllPropSet->getPropertyValue(rProp.Name)); - if(aValue.hasValue()) - allSetProps.push_back(std::pair(rProp.Name, aValue)); - } - } - catch (...) - { - } - } -#endif - - const css::uno::Reference< css::beans::XPropertySet > xPropSet( rXShape, css::uno::UNO_QUERY ); - if(!xPropSet) - return; - - const css::uno::Reference< css::lang::XServiceInfo > xServiceInfo( rXShape, css::uno::UNO_QUERY ); - if(!xServiceInfo) - return; - - const css::uno::Reference< css::beans::XPropertySetInfo > xInfo(xPropSet->getPropertySetInfo()); - if (!xInfo.is()) - return; - - // Note: The Text may also be secured here, so it may also be possible to - // secure/store it at PointStyle instead of at TextBody, same maybe evaluated - // for the text attributes - where when securing here the attributes would be - // in our UNO API format already. - // if(xServiceInfo->supportsService("com.sun.star.drawing.Text")) - // { - // css::uno::Reference< css::text::XText > xText(rXShape, css::uno::UNO_QUERY); - // const OUString aText(xText->getString()); - // - // if(!aText.isEmpty()) - // { - // } - // } - - // Add all kinds of properties that are needed to re-create the XShape. - // For now this is a minimal example-selection, it will need to be extended - // over time for all kind of cases/properties - - // text properties - if(!bIsBackgroundShape - && xServiceInfo->supportsService(u"com.sun.star.drawing.TextProperties"_ustr)) - { - addProperty(UNO_NAME_CHAR_COLOR, xInfo, pTarget->maProperties, xPropSet); - addProperty(UNO_NAME_CHAR_HEIGHT, xInfo, pTarget->maProperties, xPropSet); - addProperty(UNO_NAME_CHAR_SHADOWED, xInfo, pTarget->maProperties, xPropSet); - addProperty(UNO_NAME_CHAR_WEIGHT, xInfo, pTarget->maProperties, xPropSet); - } - - // fill properties - if(xServiceInfo->supportsService(u"com.sun.star.drawing.FillProperties"_ustr)) - { - css::drawing::FillStyle eFillStyle(css::drawing::FillStyle_NONE); - if (xInfo->hasPropertyByName(UNO_NAME_FILLSTYLE)) - xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= eFillStyle; - - if(css::drawing::FillStyle_NONE != eFillStyle) - { - addProperty(UNO_NAME_FILLSTYLE, xInfo, pTarget->maProperties, xPropSet); - - switch(eFillStyle) - { - case css::drawing::FillStyle_SOLID: - { - addProperty(UNO_NAME_FILLCOLOR, xInfo, pTarget->maProperties, xPropSet); - break; - } - default: - case css::drawing::FillStyle_NONE: - case css::drawing::FillStyle_GRADIENT: - case css::drawing::FillStyle_HATCH: - case css::drawing::FillStyle_BITMAP: - break; - } - } - } - - // line properties - if(!bIsBackgroundShape - && xServiceInfo->supportsService(u"com.sun.star.drawing.LineProperties"_ustr)) - { - css::drawing::LineStyle eLineStyle(css::drawing::LineStyle_NONE); - if (xInfo->hasPropertyByName(UNO_NAME_LINESTYLE)) - xPropSet->getPropertyValue(UNO_NAME_LINESTYLE) >>= eLineStyle; - - if(css::drawing::LineStyle_NONE != eLineStyle) - { - addProperty(UNO_NAME_LINESTYLE, xInfo, pTarget->maProperties, xPropSet); - addProperty(UNO_NAME_LINECOLOR, xInfo, pTarget->maProperties, xPropSet); - addProperty(UNO_NAME_LINEWIDTH, xInfo, pTarget->maProperties, xPropSet); - - switch(eLineStyle) - { - case css::drawing::LineStyle_SOLID: - break; - default: - case css::drawing::LineStyle_NONE: - case css::drawing::LineStyle_DASH: - break; - } - } - } -} - -void DiagramData_oox::secureDataFromShapeToModelAfterDiagramImport(::oox::drawingml::Shape& rRootShape) -{ - const std::vector< ShapePtr >& rChildren(rRootShape.getChildren()); - - for (auto& child : rChildren) - { - secureStyleDataFromShapeToModel(*child); - } - - // After Diagram import, parts of the Diagram ModelData is at the - // oox::drawingml::Shape. Since these objects are temporary helpers, - // secure that data at the Diagram ModelData by copying. - - // This is currently mainly the Text, but may get more (styles?) - for (auto & point : maPoints) - { - Shape* pShapeCandidate(getOrCreateAssociatedShape(point)); - - if(nullptr != pShapeCandidate) - { - if(pShapeCandidate->getTextBody() && !pShapeCandidate->getTextBody()->isEmpty()) - { - point.msTextBody->msText = pShapeCandidate->getTextBody()->toString(); - - const uno::Sequence< beans::PropertyValue > aTextProps( - pShapeCandidate->getTextBody()->getTextProperties().maPropertyMap.makePropertyValueSequence()); - - for (auto const& prop : aTextProps) - point.msTextBody->maTextProps.push_back(std::pair(prop.Name, prop.Value)); - } - - // At this place a mechanism to find missing data should be added: - // Create a Shape from so-far secured data & compare it with the - // imported one. Report differences to allow extending the mechanism - // more easily. -#ifdef DBG_UTIL - // The original is pShapeCandidate, re-create potential new oox::drawingml::Shape - // as aNew to be able to compare these - ShapePtr aNew(std::make_shared<Shape>()); - restoreDataFromModelToShapeAfterReCreation(point, *aNew); - - // Unfortunately oox::drawingml::Shape has no operator==. I tried to add - // one, but that is too expensive. I stopped at oox::drawingml::Color. - // To compare it is necessary to use the debugger, or for single aspects - // of the oox data it might be possible to call local dump() methods at - // both instances to compare them/their output - - // bool bSame(aNew.get() == pShapeCandidate); -#endif - } - } -} - -void DiagramData_oox::restoreStyleDataFromShapeToModel(::oox::drawingml::Shape& rShape) -{ - const std::vector< ShapePtr >& rChildren(rShape.getChildren()); - - if(!rChildren.empty()) - { - // group shape - for (auto& child : rChildren) - { - restoreStyleDataFromShapeToModel(*child); - } - - // if group shape we are done. Do not restore properties for group shapes - return; - } - - // we need a XShape - const css::uno::Reference< css::drawing::XShape > &rXShape(rShape.getXShape()); - if(!rXShape) - return; - - // we need a ModelID for association - if(rShape.getDiagramDataModelID().isEmpty()) - return; - - // define source to save to - svx::diagram::PointStyle* pSource(nullptr); - - if(rShape.getDiagramDataModelID() == getBackgroundShapeModelID()) - { - // if BackgroundShape, set BackgroundShapeStyle as source - if(maBackgroundShapeStyle) - pSource = maBackgroundShapeStyle.get(); - } - else - { - // if Shape, seek association - for (auto & point : maPoints) - { - if(point.msModelId == rShape.getDiagramDataModelID()) - { - // found - create properties & set as source - pSource = point.msPointStylePtr.get(); - - // we are done, there is no 2nd shape with the same ModelID by definition - break; - } - } - } - - // no source -> nothing to do - if(nullptr == pSource) - return; - - // get target PropertySet of new XShape - css::uno::Reference<css::beans::XPropertySet> xPropSet(rXShape, css::uno::UNO_QUERY); - if(!xPropSet) - return; - - // apply properties - for (auto const& prop : pSource->maProperties) - { - xPropSet->setPropertyValue(prop.first, prop.second); - } -} - -void DiagramData_oox::restoreDataFromShapeToModelAfterDiagramImport(::oox::drawingml::Shape& rRootShape) -{ - const std::vector< ShapePtr >& rChildren(rRootShape.getChildren()); - - for (auto& child : rChildren) - { - restoreStyleDataFromShapeToModel(*child); - } -} - DiagramData_oox::DiagramData_oox() : svx::diagram::DiagramData_svx() , mpBackgroundShapeFillProperties( std::make_shared<FillProperties>() ) diff --git a/oox/source/drawingml/diagram/datamodel_oox.hxx b/oox/source/drawingml/diagram/datamodel_oox.hxx index 8a52cb5d4032..8833cc602a27 100644 --- a/oox/source/drawingml/diagram/datamodel_oox.hxx +++ b/oox/source/drawingml/diagram/datamodel_oox.hxx @@ -50,16 +50,7 @@ public: Shape* getOrCreateAssociatedShape(const svx::diagram::Point& rPoint, bool bCreateOnDemand = false) const; - // get/set data between Diagram DataModel and oox::drawingml::Shape - void secureDataFromShapeToModelAfterDiagramImport(::oox::drawingml::Shape& rRootShape); - void restoreDataFromShapeToModelAfterDiagramImport(::oox::drawingml::Shape& rRootShape); - static void restoreDataFromModelToShapeAfterReCreation(const svx::diagram::Point& rPoint, Shape& rNewShape); - - void writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastparser::FSHelperPtr& rTarget, const css::uno::Reference<css::drawing::XShape>& rXShape); - -protected: - void secureStyleDataFromShapeToModel(::oox::drawingml::Shape& rShape); - void restoreStyleDataFromShapeToModel(::oox::drawingml::Shape& rShape); + void writeDiagramData(oox::core::XmlFilterBase& rFB, sax_fastparser::FSHelperPtr& rTarget, const css::uno::Reference<css::drawing::XShape>& rRootShape); private: // The model definition, the parts *only* available in oox. Also look for already diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index b567a48e0890..3ea5eb1fcfb7 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -200,7 +200,7 @@ bool Diagram::checkMinimalDataDoms() const return true; } -void Diagram::tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB, const css::uno::Reference<css::drawing::XShape>& rXRootShape) +void Diagram::tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB, const uno::Reference<drawing::XShape>& rXRootShape) { // internal testing: allow to force to always recreate static bool bForceAlwaysReCreate(false); @@ -252,7 +252,7 @@ void Diagram::tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB, const cs } using ShapePairs - = std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>; + = std::map<std::shared_ptr<drawingml::Shape>, uno::Reference<drawing::XShape>>; void Diagram::syncDiagramFontHeights() { @@ -443,7 +443,7 @@ void loadDiagram( ShapePtr const & pShape, } // Layout: always import to allow editing in the future. It's needed for - // AdvancedDiagramHelper::reLayout to re-create the oox::Shape(s) for the + // DiagramHelper_oox::reLayout to re-create the oox::Shape(s) for the // model. Without importing these the diagram model will be not complete. // NOTE: This also adds the DomMaps to rMainDomMap, so the lines // DiagramDomMap& rMainDomMap = pDiagram->getDomMap(); @@ -513,7 +513,8 @@ void loadDiagram( ShapePtr const & pShape, // already *filtered* version, see usage of DiagramShapeCounter // above. Moving to local bool, there might more conditions show // up - const bool bCreate(pShape->getExtDrawings().empty()); + static bool bIgnoreExtDrawings(nullptr != std::getenv("DIAGRAM_IGNORE_EXTDRAWINGS")); + const bool bCreate(bIgnoreExtDrawings || pShape->getExtDrawings().empty()); pDiagram->createShapeHierarchyFromModel(pShape, bCreate); // Get the oox::Theme definition and - if available - move/secure the @@ -523,7 +524,7 @@ void loadDiagram( ShapePtr const & pShape, pData->setThemeDocument(aTheme->getFragment()); //getTempFile()); // Prepare support for the advanced DiagramHelper using Diagram & Theme data - pShape->prepareDiagramHelper(pDiagram, rFilter.getCurrentThemePtr(), bCreate); + pShape->prepareDiagramHelper(pDiagram, rFilter.getCurrentThemePtr()); } catch (...) { diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx index bc7308a7b8d1..943e33b4e1c4 100644 --- a/oox/source/drawingml/diagram/diagram.hxx +++ b/oox/source/drawingml/diagram/diagram.hxx @@ -123,7 +123,7 @@ struct DiagramColor }; typedef std::map<OUString,DiagramColor> DiagramColorMap; -typedef std::map<svx::diagram::DomMapFlag,com::sun::star::uno::Any> DiagramPRDomMap; +typedef std::map<svx::diagram::DomMapFlag,css::uno::Any> DiagramPRDomMap; class Diagram { @@ -147,13 +147,13 @@ public: oox::core::NamedShapePairs& getDiagramFontHeights() { return maDiagramFontHeights; } void syncDiagramFontHeights(); - void setOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag, const com::sun::star::uno::Any& rValue); - com::sun::star::uno::Any getOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag) const; + void setOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag, const css::uno::Any& rValue); + css::uno::Any getOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag) const; void resetOOXDomValues(svx::diagram::DomMapFlags aDomMapFlags); // check if mandatory DiagramDomS exist (or can be created) bool checkMinimalDataDoms() const; - void tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB, const com::sun::star::uno::Reference<css::drawing::XShape>& rXRootShape); + void tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB, const css::uno::Reference<css::drawing::XShape>& rXRootShape); private: // This contains groups of shapes: automatic font size is the same in each group. diff --git a/oox/source/drawingml/diagram/diagramhelper.cxx b/oox/source/drawingml/diagram/diagramhelper.cxx deleted file mode 100644 index 868da3d15e4d..000000000000 --- a/oox/source/drawingml/diagram/diagramhelper.cxx +++ /dev/null @@ -1,349 +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 . - */ - -#include <oox/drawingml/diagram/diagramhelper.hxx> -#include "diagram.hxx" - -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <oox/shape/ShapeFilterBase.hxx> -#include <oox/ppt/pptimport.hxx> -#include <drawingml/fillproperties.hxx> -#include <svx/svdmodel.hxx> -#include <svx/svdoutl.hxx> -#include <comphelper/processfactory.hxx> -#include <oox/drawingml/themefragmenthandler.hxx> -#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <utility> - -using namespace ::com::sun::star; - -namespace oox::drawingml { - -bool AdvancedDiagramHelper::hasDiagramData() const -{ - return mpDiagramPtr && mpDiagramPtr->getData(); -} - -AdvancedDiagramHelper::AdvancedDiagramHelper( - std::shared_ptr< Diagram > xDiagramPtr, - std::shared_ptr<::oox::drawingml::Theme> xTheme, - css::awt::Size aImportSize, - bool bSelfCreated) -: svx::diagram::IDiagramHelper(bSelfCreated) -, mpDiagramPtr(std::move(xDiagramPtr)) -, mpThemePtr(std::move(xTheme)) -, maImportSize(aImportSize) -{ -} - -AdvancedDiagramHelper::~AdvancedDiagramHelper() -{ -} - -void AdvancedDiagramHelper::reLayout(SdrObjGroup& rTarget) -{ - if(!mpDiagramPtr) - { - return; - } - - // Rescue/remember geometric transformation of existing Diagram - basegfx::B2DHomMatrix aTransformation; - basegfx::B2DPolyPolygon aPolyPolygon; - rTarget.TRGetBaseGeometry(aTransformation, aPolyPolygon); - - // create temporary oox::Shape as target. No longer needed is to keep/remember - // the original oox::Shape to do that. Use original Size and Pos from initial import - // to get the same layout(s) - oox::drawingml::ShapePtr pShapePtr = std::make_shared<Shape>( "com.sun.star.drawing.GroupShape" ); - pShapePtr->setDiagramType(); - pShapePtr->setSize(maImportSize); - - // Re-create the oox::Shapes for the diagram content - mpDiagramPtr->createShapeHierarchyFromModel(pShapePtr, true); - - // Delete all existing shapes in that group to prepare re-creation - rTarget.getChildrenOfSdrObject()->ClearSdrObjList(); - - // For re-creation we need to use ::addShape functionality from the - // oox import filter since currently Shape import is very tightly - // coupled to Shape creation. It converts a oox::Shape representation - // combined with an oox::Theme to incarnated XShapes representing the - // Diagram. - // To use that functionality, we have to create a temporary filter - // (based on ShapeFilterBase). Problems are that this needs to know - // the oox:Theme and a ComponentModel from TargetDocument. - // The DiagramHelper holds/delivers the oox::Theme to use, so - // it does not need to be re-imported from oox repeatedly. - // The ComponentModel can be derived from the existing XShape/GroupShape - // when knowing where to get it from, making it independent from app. - // - // NOTE: Using another (buffered) oox::Theme would allow to re-create - // using another theming in the future. - // NOTE: The incarnation of import filter (ShapeFilterBase) is only - // used for XShape creation, no xml snippets/data gets imported - // here. XShape creation may be isolated in the future. - SdrModel& rModel(rTarget.getSdrModelFromSdrObject()); - uno::Reference< uno::XInterface > const & rUnoModel(rModel.getUnoModel()); - const css::uno::Reference<css::uno::XComponentContext>& xContext(comphelper::getProcessComponentContext()); - rtl::Reference<oox::shape::ShapeFilterBase> xFilter(new oox::shape::ShapeFilterBase(xContext)); - - // set oox::Theme at Filter. All LineStyle/FillStyle/Colors/Attributes - // will be taken from there - // also need to use theme when geometry gets self-created the first time - if(UseDiagramThemeData() || !isSelfCreated()) - xFilter->setCurrentTheme(getOrCreateThemePtr(xFilter)); - - uno::Reference< css::lang::XComponent > aComponentModel( rUnoModel, uno::UNO_QUERY ); - xFilter->setTargetDocument(aComponentModel); - - // set DiagramFontHeights - xFilter->setDiagramFontHeights(&mpDiagramPtr->getDiagramFontHeights()); - - // Prepare the target for the to-be-created XShapes - uno::Reference<drawing::XShapes> xShapes(rTarget.getUnoShape(), uno::UNO_QUERY_THROW); - - for (auto const& child : pShapePtr->getChildren()) - { - // Create all sub-shapes. This will recursively create needed geometry using - // filter-internal ::createShapes - child->addShape( - *xFilter, - xFilter->getCurrentTheme(), - xShapes, - aTransformation, - pShapePtr->getFillProperties()); - } - - // sync FontHeights - mpDiagramPtr->syncDiagramFontHeights(); - - if (isSelfCreated()) - { - // already secured at import, re-apply secured data from ModelData - if(UseDiagramModelData()) - mpDiagramPtr->getData()->restoreDataFromShapeToModelAfterDiagramImport(*pShapePtr); - } - else - { - // secure data from ModelData for the 1st time for shapes except BackgroundShape - if(UseDiagramModelData()) - mpDiagramPtr->getData()->secureDataFromShapeToModelAfterDiagramImport(*pShapePtr); - - // note that shapes are now self-created - setSelfCreated(); - } - - // Re-apply remembered geometry - rTarget.TRSetBaseGeometry(aTransformation, aPolyPolygon); -} - -OUString AdvancedDiagramHelper::getString() const -{ - if(hasDiagramData()) - { - return mpDiagramPtr->getData()->getString(); - } - - return OUString(); -} - -std::vector<std::pair<OUString, OUString>> AdvancedDiagramHelper::getChildren(const OUString& rParentId) const -{ - if(hasDiagramData()) - { - return mpDiagramPtr->getData()->getChildren(rParentId); - } - - return std::vector<std::pair<OUString, OUString>>(); -} - -OUString AdvancedDiagramHelper::addDiagramNode(const OUString& rText) -{ - OUString aRetval; - - if(hasDiagramData()) - { - const std::pair<OUString, svx::diagram::DomMapFlags> aResult = mpDiagramPtr->getData()->addDiagramNode(rText); - aRetval = aResult.first; - - // reset Dom properties at DiagramData - mpDiagramPtr->resetOOXDomValues(aResult.second); - - // reset temporary buffered ModelData association lists & rebuild them - // and the Diagram DataModel - mpDiagramPtr->getData()->buildDiagramDataModel(true); - - // also reset temporary buffered layout data - that might - // still refer to changed oox::Shape data - mpDiagramPtr->getLayout()->getPresPointShapeMap().clear(); - } - - return aRetval; -} - -bool AdvancedDiagramHelper::removeDiagramNode(const OUString& rNodeId) -{ - bool bRetval(false); - - if(hasDiagramData()) - { - svx::diagram::DomMapFlags aResult = mpDiagramPtr->getData()->removeDiagramNode(rNodeId); - bRetval = !aResult.empty(); - - // reset Dom properties at DiagramData - mpDiagramPtr->resetOOXDomValues(std::move(aResult)); - - // reset temporary buffered ModelData association lists & rebuild them - // and the Diagram DataModel - mpDiagramPtr->getData()->buildDiagramDataModel(true); - - // also reset temporary buffered layout data - that might - // still refer to changed oox::Shape data - mpDiagramPtr->getLayout()->getPresPointShapeMap().clear(); - } - - return bRetval; -} - -void AdvancedDiagramHelper::TextInformationChange(const OUString& rDiagramDataModelID, SdrOutliner& rOutl) -{ - if(!mpDiagramPtr) - { - return; - } - - // try text change for model part in DiagramData - svx::diagram::DomMapFlags aDomMapFlags(mpDiagramPtr->getData()->TextInformationChange(rDiagramDataModelID, rOutl)); - - if(!aDomMapFlags.empty()) - { - // reset Dom properties at DiagramData - mpDiagramPtr->resetOOXDomValues(std::move(aDomMapFlags)); - - // still reset GrabBag at Associated SdrObjGroup object. There are no "OOX.*" - // entries anymore, but others like "mso-rotation-angle" and others - uno::Reference<beans::XPropertySet> xPropSet(mxGroupShape, uno::UNO_QUERY); - if (xPropSet->getPropertySetInfo()->hasPropertyByName(u"InteropGrabBag"_ustr)) - xPropSet->setPropertyValue(u"InteropGrabBag"_ustr, uno::Any(uno::Sequence<beans::PropertyValue>())); - } -} - -svx::diagram::DiagramDataStatePtr AdvancedDiagramHelper::extractDiagramDataState() const -{ - if(!mpDiagramPtr) - { - return svx::diagram::DiagramDataStatePtr(); - } - - return mpDiagramPtr->getData()->extractDiagramDataState(); -} - -void AdvancedDiagramHelper::applyDiagramDataState(const svx::diagram::DiagramDataStatePtr& rState) -{ - if(!mpDiagramPtr) - { - return; - } - - mpDiagramPtr->getData()->applyDiagramDataState(rState); -} - -void AdvancedDiagramHelper::doAnchor(uno::Reference<drawing::XShape>& rTarget, ::oox::drawingml::Shape& rRootShape) -{ - if(!mpDiagramPtr || !rTarget) - { - return; - } - - mpDiagramPtr->syncDiagramFontHeights(); - - // After Diagram import, parts of the Diagram ModelData is at the - // oox::drawingml::Shape. Since these objects are temporary helpers, - // secure that data at the Diagram ModelData by copying. - mpDiagramPtr->getData()->secureDataFromShapeToModelAfterDiagramImport(rRootShape); - - // initialize connection to GroupObject - connectToSdrObjGroup(rTarget); -} - -const std::shared_ptr< ::oox::drawingml::Theme >& AdvancedDiagramHelper::getOrCreateThemePtr( - const rtl::Reference< oox::shape::ShapeFilterBase >& rxFilter) const -{ - // (Re-)Use already existing Theme if existing/imported if possible. - // If not, re-import Theme if data is available and thus possible - if(hasDiagramData() && (ForceThemePtrRecreation() || !mpThemePtr)) - { - // get the originally imported dom::XDocument - const uno::Reference< css::xml::dom::XDocument >& xThemeDocument(mpDiagramPtr->getData()->getThemeDocument()); - - if(xThemeDocument) - { - // reset local Theme ModelData *always* to get rid of former data that would - // else be added additionally - const_cast<AdvancedDiagramHelper*>(this)->mpThemePtr = std::make_shared<oox::drawingml::Theme>(); - auto pTheme = std::make_shared<model::Theme>(); - mpThemePtr->setTheme(pTheme); - - // import Theme ModelData - rxFilter->importFragment( - new ThemeFragmentHandler(*rxFilter, OUString(), *mpThemePtr, *pTheme), - uno::Reference< css::xml::sax::XFastSAXSerializable >( - xThemeDocument, - uno::UNO_QUERY_THROW)); - } - } - - return mpThemePtr; -} - -void AdvancedDiagramHelper::setOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag, const uno::Any& rValue) -{ - if (mpDiagramPtr) - mpDiagramPtr->setOOXDomValue(aDomMapFlag, rValue); -} - -uno::Any AdvancedDiagramHelper::getOOXDomValue(svx::diagram::DomMapFlag aDomMapFlag) const -{ - if (mpDiagramPtr) - return mpDiagramPtr->getOOXDomValue(aDomMapFlag); - - return uno::Any(); -} - -bool AdvancedDiagramHelper::checkMinimalDataDoms() const -{ - if (!mpDiagramPtr) - return false; - - return mpDiagramPtr->checkMinimalDataDoms(); -} - -void AdvancedDiagramHelper::tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB) -{ - if (!mpDiagramPtr) - return; - - mpDiagramPtr->tryToCreateMissingDataDoms(rFB, mxGroupShape); -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/diagramhelper_oox.cxx b/oox/source/drawingml/diagram/diagramhelper_oox.cxx new file mode 100644 index 000000000000..4957434c7fb8 --- /dev/null +++ b/oox/source/drawingml/diagram/diagramhelper_oox.cxx @@ -0,0 +1,473 @@ +/* -*- 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 . + */ + +#include <oox/drawingml/diagram/diagramhelper_oox.hxx> +#include "diagram.hxx" + +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <oox/shape/ShapeFilterBase.hxx> +#include <oox/ppt/pptimport.hxx> +#include <drawingml/fillproperties.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svditer.hxx> +#include <svx/diagram/DomMapFlag.hxx> +#include <comphelper/processfactory.hxx> +#include <oox/drawingml/themefragmenthandler.hxx> +#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/text/XText.hpp> +#include <utility> + +using namespace ::com::sun::star; +using namespace svx::diagram; + +namespace oox::drawingml +{ +bool DiagramHelper_oox::hasDiagramData() const { return mpDiagramPtr && mpDiagramPtr->getData(); } + +DiagramHelper_oox::DiagramHelper_oox(std::shared_ptr<Diagram> xDiagramPtr, + std::shared_ptr<::oox::drawingml::Theme> xTheme, + awt::Size aImportSize) + : mpDiagramPtr(std::move(xDiagramPtr)) + , mpThemePtr(std::move(xTheme)) + , maImportSize(aImportSize) +{ +} + +DiagramHelper_oox::~DiagramHelper_oox() {} + +void DiagramHelper_oox::moveDiagramModelDataFromOldToNewXShape( + const uno::Reference<drawing::XShape>& xOldShape, + const uno::Reference<drawing::XShape>& xNewShape) +{ + SdrObject* pOldShape(SdrObject::getSdrObjectFromXShape(xOldShape)); + SdrObject* pNewShape(SdrObject::getSdrObjectFromXShape(xNewShape)); + + if (nullptr == pOldShape || nullptr == pNewShape) + return; + + // copy attributes + pNewShape->SetMergedItemSet(pOldShape->GetMergedItemSet(), false, true); + + // copy Text/OutlinerParaObject + OutlinerParaObject* pParaObject(pOldShape->GetOutlinerParaObject()); + if (nullptr != pParaObject) + pNewShape->SetOutlinerParaObject(*pParaObject); + + // maybe copy more stuff... +} + +void DiagramHelper_oox::reLayout() +{ + SdrObjGroup* pTarget( + dynamic_cast<SdrObjGroup*>(SdrObject::getSdrObjectFromXShape(mxGroupShape))); + if (nullptr == pTarget) + return; + + // Rescue/remember geometric transformation of existing Diagram + basegfx::B2DHomMatrix aTransformation; + basegfx::B2DPolyPolygon aPolyPolygon; + pTarget->TRGetBaseGeometry(aTransformation, aPolyPolygon); + + // create temporary oox::Shape as target. No longer needed is to keep/remember + // the original oox::Shape to do that. Use original Size and Pos from initial import + // to get the same layout(s) + oox::drawingml::ShapePtr pShapePtr = std::make_shared<Shape>("com.sun.star.drawing.GroupShape"); + pShapePtr->setDiagramType(); + pShapePtr->setSize(maImportSize); + + // remember exsiting DrawingLayerModelData. Do this before createShapeHierarchyFromModel + // below, that will create a new BackgroundShapeModelID and the BGShape would + // be missing. + // Also important is to do this as XShapes, the content of the Group will delete the + // SdrObjects in the process of re-creation, but the XShapes will survive + std::vector<uno::Reference<drawing::XShape>> xOldXShapes; + const bool bNewNodeMode(!msNewNodeId.isEmpty()); + uno::Reference<drawing::XShape> xOldShapeWithText; + uno::Reference<drawing::XShape> xOldBGShape; + { + const OUString& rBGShapeID(mpDiagramPtr->getData()->getBackgroundShapeModelID()); + SdrObjListIter aIter(*pTarget, SdrIterMode::DeepNoGroups); + while (aIter.IsMore()) + { + SdrObject* pCandidate(aIter.Next()); + if (pCandidate->getDiagramDataModelID() == rBGShapeID) + xOldBGShape = pCandidate->getUnoShape(); + else + { + uno::Reference<drawing::XShape> xCandidate(pCandidate->getUnoShape()); + xOldXShapes.push_back(xCandidate); + + if (bNewNodeMode && !xOldShapeWithText) + { + uno::Reference<text::XText> xText(xCandidate, uno::UNO_QUERY); + if (xText && !xText->getString().isEmpty()) + xOldShapeWithText = pCandidate->getUnoShape(); + } + } + } + } + + // Re-create the oox::Shapes for the diagram content + mpDiagramPtr->createShapeHierarchyFromModel(pShapePtr, true); + + // Delete all existing shapes in that group to prepare re-creation + pTarget->getChildrenOfSdrObject()->ClearSdrObjList(); + + // For re-creation we need to use ::addShape functionality from the + // oox import filter since currently Shape import is very tightly + // coupled to Shape creation. It converts a oox::Shape representation + // combined with an oox::Theme to incarnated XShapes representing the + // Diagram. + // To use that functionality, we have to create a temporary filter + // (based on ShapeFilterBase). Problems are that this needs to know + // the oox:Theme and a ComponentModel from TargetDocument. + // The DiagramHelper holds/delivers the oox::Theme to use, so + // it does not need to be re-imported from oox repeatedly. + // The ComponentModel can be derived from the existing XShape/GroupShape + // when knowing where to get it from, making it independent from app. + // + // NOTE: Using another (buffered) oox::Theme would allow to re-create + // using another theming in the future. + // NOTE: The incarnation of import filter (ShapeFilterBase) is only + // used for XShape creation, no xml snippets/data gets imported + // here. XShape creation may be isolated in the future. + SdrModel& rModel(pTarget->getSdrModelFromSdrObject()); + uno::Reference<uno::XInterface> const& rUnoModel(rModel.getUnoModel()); + const uno::Reference<uno::XComponentContext>& xContext( + comphelper::getProcessComponentContext()); + rtl::Reference<oox::shape::ShapeFilterBase> xFilter(new oox::shape::ShapeFilterBase(xContext)); + + // set oox::Theme at Filter. All LineStyle/FillStyle/Colors/Attributes + // will be taken from there + if (UseDiagramThemeData()) + xFilter->setCurrentTheme(getOrCreateThemePtr(xFilter)); + + uno::Reference<lang::XComponent> aComponentModel(rUnoModel, uno::UNO_QUERY); + xFilter->setTargetDocument(aComponentModel); + + // set DiagramFontHeights + xFilter->setDiagramFontHeights(&mpDiagramPtr->getDiagramFontHeights()); + + // Prepare the target for the to-be-created XShapes + uno::Reference<drawing::XShapes> xShapes(mxGroupShape, uno::UNO_QUERY_THROW); + + for (auto const& child : pShapePtr->getChildren()) + { + // Create all sub-shapes. This will recursively create needed geometry using + // filter-internal ::createShapes + child->addShape(*xFilter, xFilter->getCurrentTheme(), xShapes, aTransformation, + pShapePtr->getFillProperties()); + } + + // Re-apply remembered geometry + pTarget->TRSetBaseGeometry(aTransformation, aPolyPolygon); + + // extract newly created DrawingLayerModelData + std::vector<uno::Reference<drawing::XShape>> xNewXShapes; + uno::Reference<drawing::XShape> xNewShape; + uno::Reference<drawing::XShape> xNewBGShape; + { + const OUString& rBGShapeID(mpDiagramPtr->getData()->getBackgroundShapeModelID()); + SdrObjListIter aIter(*pTarget, SdrIterMode::DeepNoGroups); + while (aIter.IsMore()) + { + SdrObject* pCandidate(aIter.Next()); + if (pCandidate->getDiagramDataModelID() == rBGShapeID) + xNewBGShape = pCandidate->getUnoShape(); + else + { + xNewXShapes.push_back(pCandidate->getUnoShape()); + + if (bNewNodeMode && !xNewShape + && msNewNodeId == pCandidate->getDiagramDataModelID()) + xNewShape = pCandidate->getUnoShape(); + } + } + } + + if (xOldBGShape && xNewBGShape) + { + // we have old and new BGShapes, copy necessary data + moveDiagramModelDataFromOldToNewXShape(xOldBGShape, xNewBGShape); + } + + for (const auto& rNewShape : xNewXShapes) + { + if (!rNewShape) + continue; + + SdrObject* pNewShape(SdrObject::getSdrObjectFromXShape(rNewShape)); + if (nullptr == pNewShape) + continue; + + const OUString& rNewModelID(pNewShape->getDiagramDataModelID()); + if (rNewModelID.isEmpty()) + continue; + + for (const auto& rOldShape : xOldXShapes) + { + if (rOldShape) + { + SdrObject* pOldShape(SdrObject::getSdrObjectFromXShape(rOldShape)); + if (nullptr != pOldShape) + { + if (rNewModelID == pOldShape->getDiagramDataModelID()) + { + // we have old and new version of this shape, copy necessary data + moveDiagramModelDataFromOldToNewXShape(rOldShape, rNewShape); + break; + } + } + } + } + } + + if (bNewNodeMode) + { + if (xOldShapeWithText && xNewShape) + { + // a shape was added in DomTree model and the model counter part in XShapes + // is not filled yet + SdrObject* pOldShape(SdrObject::getSdrObjectFromXShape(xOldShapeWithText)); + SdrObject* pNewShape(SdrObject::getSdrObjectFromXShape(xNewShape)); + + if (nullptr != pOldShape && nullptr != pNewShape) + { + // copy attributes + pNewShape->SetMergedItemSet(pOldShape->GetMergedItemSet(), false, true); + + OutlinerParaObject* pParaObject(pOldShape->GetOutlinerParaObject()); + if (nullptr != pParaObject) + { + pNewShape->SetOutlinerParaObject(*pParaObject); + uno::Reference<text::XText> xText(xNewShape, uno::UNO_QUERY); + if (xText) + xText->insertString(xText->getStart(), msNewNodeText, true); + } + } + } + + msNewNodeId.clear(); + msNewNodeText.clear(); + } +} + +OUString DiagramHelper_oox::getDiagramString() const +{ + if (hasDiagramData()) + { + return mpDiagramPtr->getData()->getDiagramString(mxGroupShape); + } + + return OUString(); +} + +std::vector<std::pair<OUString, OUString>> +DiagramHelper_oox::getDiagramChildren(const OUString& rParentId) const +{ + if (hasDiagramData()) + { + return mpDiagramPtr->getData()->getDiagramChildren(rParentId, mxGroupShape); + } + + return std::vector<std::pair<OUString, OUString>>(); +} + +OUString DiagramHelper_oox::addDiagramNode(const OUString& rText) +{ + OUString aRetval; + + if (hasDiagramData()) + { + const std::pair<OUString, DomMapFlags> aResult = mpDiagramPtr->getData()->addDiagramNode(); + aRetval = aResult.first; + + // reset Dom properties at DiagramData + mpDiagramPtr->resetOOXDomValues(aResult.second); + + // reset temporary buffered ModelData association lists & rebuild them + // and the Diagram DataModel + mpDiagramPtr->getData()->buildDiagramDataModel(true); + + // also reset temporary buffered layout data - that might + // still refer to changed oox::Shape data + mpDiagramPtr->getLayout()->getPresPointShapeMap().clear(); + + // we have the text node in aRetval, but we need the ModelID + // of the node referring that one, that is the one that will be used + // as ModelID in the XShape/SdrObject. Loop and look for it + for (const auto& rCandidate : mpDiagramPtr->getData()->getPoints()) + { + if (!rCandidate.msPresentationAssociationId.isEmpty() + && rCandidate.msPresentationAssociationId == aRetval) + { + msNewNodeId = rCandidate.msModelId; + break; + } + } + + // msNewNodeId = aRetval; + msNewNodeText = rText; + } + + return aRetval; +} + +bool DiagramHelper_oox::removeDiagramNode(const OUString& rNodeId) +{ + bool bRetval(false); + + if (hasDiagramData()) + { + DomMapFlags aResult = mpDiagramPtr->getData()->removeDiagramNode(rNodeId); + bRetval = !aResult.empty(); + + // reset Dom properties at DiagramData + mpDiagramPtr->resetOOXDomValues(std::move(aResult)); + + // reset temporary buffered ModelData association lists & rebuild them + // and the Diagram DataModel + mpDiagramPtr->getData()->buildDiagramDataModel(true); + + // also reset temporary buffered layout data - that might + // still refer to changed oox::Shape data + mpDiagramPtr->getLayout()->getPresPointShapeMap().clear(); + } + + return bRetval; +} + +void DiagramHelper_oox::TextInformationChange() +{ + if (!mpDiagramPtr) + return; + + DomMapFlags aFlags; + aFlags.push_back(DomMapFlag::OOXData); + // aFlags.push_back(DomMapFlag::OOXDrawing); + // aFlags.push_back(DomMapFlag::OOXDataRels); + mpDiagramPtr->resetOOXDomValues(std::move(aFlags)); + + // still reset GrabBag at Associated SdrObjGroup object. There are no "OOX.*" + // entries anymore, but others like "mso-rotation-angle" and others + uno::Reference<beans::XPropertySet> xPropSet(mxGroupShape, uno::UNO_QUERY); + if (xPropSet->getPropertySetInfo()->hasPropertyByName(u"InteropGrabBag"_ustr)) + xPropSet->setPropertyValue(u"InteropGrabBag"_ustr, + uno::Any(uno::Sequence<beans::PropertyValue>())); +} + +DiagramDataStatePtr DiagramHelper_oox::extractDiagramDataState() const +{ + if (!mpDiagramPtr) + { + return DiagramDataStatePtr(); + } + + return mpDiagramPtr->getData()->extractDiagramDataState(); +} + +void DiagramHelper_oox::applyDiagramDataState(const DiagramDataStatePtr& rState) +{ + if (!mpDiagramPtr) + { + return; + } + + mpDiagramPtr->getData()->applyDiagramDataState(rState); +} + +void DiagramHelper_oox::doAnchor(uno::Reference<drawing::XShape>& rTarget) +{ + if (!mpDiagramPtr || !rTarget) + { + return; + } + + // sync FontHeights + mpDiagramPtr->syncDiagramFontHeights(); + + // initialize connection to GroupObject + connectToSdrObjGroup(rTarget); +} + +const std::shared_ptr<::oox::drawingml::Theme>& DiagramHelper_oox::getOrCreateThemePtr( + const rtl::Reference<oox::shape::ShapeFilterBase>& rxFilter) const +{ + // (Re-)Use already existing Theme if existing/imported if possible. + // If not, re-import Theme if data is available and thus possible + if (hasDiagramData() && (ForceThemePtrRecreation() || !mpThemePtr)) + { + // get the originally imported dom::XDocument + const uno::Reference<xml::dom::XDocument>& xThemeDocument( + mpDiagramPtr->getData()->getThemeDocument()); + + if (xThemeDocument) + { + // reset local Theme ModelData *always* to get rid of former data that would + // else be added additionally + const_cast<DiagramHelper_oox*>(this)->mpThemePtr + = std::make_shared<oox::drawingml::Theme>(); + auto pTheme = std::make_shared<model::Theme>(); + mpThemePtr->setTheme(pTheme); + + // import Theme ModelData + rxFilter->importFragment( + new ThemeFragmentHandler(*rxFilter, OUString(), *mpThemePtr, *pTheme), + uno::Reference<xml::sax::XFastSAXSerializable>(xThemeDocument, + uno::UNO_QUERY_THROW)); + } + } + + return mpThemePtr; +} + +void DiagramHelper_oox::setOOXDomValue(DomMapFlag aDomMapFlag, const uno::Any& rValue) +{ + if (mpDiagramPtr) + mpDiagramPtr->setOOXDomValue(aDomMapFlag, rValue); +} + +uno::Any DiagramHelper_oox::getOOXDomValue(DomMapFlag aDomMapFlag) const +{ + if (mpDiagramPtr) + return mpDiagramPtr->getOOXDomValue(aDomMapFlag); + + return uno::Any(); +} + +bool DiagramHelper_oox::checkMinimalDataDoms() const +{ + if (!mpDiagramPtr) + return false; + + return mpDiagramPtr->checkMinimalDataDoms(); +} + +void DiagramHelper_oox::tryToCreateMissingDataDoms(oox::core::XmlFilterBase& rFB) +{ + if (!mpDiagramPtr) + return; + + mpDiagramPtr->tryToCreateMissingDataDoms(rFB, mxGroupShape); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 324bdb913e10..0611eb115ad4 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -55,7 +55,7 @@ #include <oox/mathml/importutils.hxx> #include <oox/token/properties.hxx> #include "diagram/datamodel_oox.hxx" -#include <oox/drawingml/diagram/diagramhelper.hxx> +#include <oox/drawingml/diagram/diagramhelper_oox.hxx> #include <comphelper/classids.hxx> #include <comphelper/propertysequence.hxx> @@ -255,17 +255,15 @@ Shape::~Shape() void Shape::prepareDiagramHelper( const std::shared_ptr< Diagram >& rDiagramPtr, - const std::shared_ptr<::oox::drawingml::Theme>& rTheme, - bool bSelfCreated) + const std::shared_ptr<::oox::drawingml::Theme>& rTheme) { // Prepare Diagram data collecting for this Shape if( nullptr == mpDiagramHelper && FRAMETYPE_DIAGRAM == meFrameType ) { - mpDiagramHelper = new AdvancedDiagramHelper( + mpDiagramHelper = new DiagramHelper_oox( rDiagramPtr, rTheme, - getSize(), - bSelfCreated); + getSize()); } } @@ -276,7 +274,7 @@ void Shape::propagateDiagramHelper() { if (mxShape) { - mpDiagramHelper->doAnchor(mxShape, *this); + mpDiagramHelper->doAnchor(mxShape); mpDiagramHelper = nullptr; } } @@ -1430,19 +1428,15 @@ Reference< XShape > const & Shape::createAndInsert( if (!getDiagramDataModelID().isEmpty()) { - SdrObject* pShape(SdrObject::getSdrObjectFromXShape(mxShape)); + SdrObject* pSdrObject(SdrObject::getSdrObjectFromXShape(mxShape)); - if (nullptr != pShape) + if (nullptr != pSdrObject) { - // check if we have a DiagramHelper - std::shared_ptr< svx::diagram::IDiagramHelper > pIDiagramHelper( - pShape->getDiagramHelperFromDiagramOrMember()); - - if (pIDiagramHelper) - { - // only needed when DiagramHelper exists - pShape->setDiagramDataModelID(getDiagramDataModelID()); - } + // I checked if pSdrObject has a DiagramHelper here once, but this is + // highly dependent on when propagateDiagramHelper() will be called + // and not needed since when a DiagramDataModelID is set locally + // is sufficient to know that we are in a Diagram context. + pSdrObject->setDiagramDataModelID(getDiagramDataModelID()); } } @@ -2414,7 +2408,7 @@ Reference< XShape > const & Shape::createAndInsert( void Shape::keepDiagramDrawing(XmlFilterBase& rFilterBase, const OUString& rFragmentPath) { - AdvancedDiagramHelper* pAdvancedDiagramHelper(getDiagramHelper()); + DiagramHelper_oox* pAdvancedDiagramHelper(getDiagramHelper()); if (nullptr == pAdvancedDiagramHelper) return; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index a986078dc1f1..8f673cfd49b1 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -19,7 +19,7 @@ #include <config_features.h> -#include <oox/drawingml/diagram/diagramhelper.hxx> +#include <oox/drawingml/diagram/diagramhelper_oox.hxx> #include <config_folders.h> #include <rtl/bootstrap.hxx> #include <sal/log.hxx> @@ -144,7 +144,7 @@ #include <drawingml/presetgeometrynames.hxx> #include <docmodel/uno/UnoGradientTools.hxx> #include <svx/svdpage.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> using namespace ::css; using namespace ::css::beans; @@ -6782,12 +6782,12 @@ bool DrawingML::PrepareToWriteAsDiagram(const css::uno::Reference<css::drawing:: if (nullptr == pObj) return false; - const std::shared_ptr<svx::diagram::IDiagramHelper>& rIDiagramHelper(pObj->getDiagramHelper()); + const std::shared_ptr<svx::diagram::DiagramHelper_svx>& rIDiagramHelper(pObj->getDiagramHelper()); if (!rIDiagramHelper) return false; - AdvancedDiagramHelper* pAdvancedDiagramHelper = static_cast<AdvancedDiagramHelper*>(rIDiagramHelper.get()); + DiagramHelper_oox* pAdvancedDiagramHelper = static_cast<DiagramHelper_oox*>(rIDiagramHelper.get()); if (nullptr == pAdvancedDiagramHelper) return false; @@ -6807,10 +6807,10 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX assert(pObj && "no SdrObject"); assert(pObj->isDiagram() && "is no Diagram"); - const std::shared_ptr< svx::diagram::IDiagramHelper >& rIDiagramHelper(pObj->getDiagramHelper()); + const std::shared_ptr< svx::diagram::DiagramHelper_svx >& rIDiagramHelper(pObj->getDiagramHelper()); assert(rIDiagramHelper && "has no DiagramHelper"); - const AdvancedDiagramHelper* pAdvancedDiagramHelper = static_cast<AdvancedDiagramHelper*>(rIDiagramHelper.get()); + const DiagramHelper_oox* pAdvancedDiagramHelper = static_cast<DiagramHelper_oox*>(rIDiagramHelper.get()); assert(pAdvancedDiagramHelper && "has no DiagramHelper"); if (!pAdvancedDiagramHelper->checkMinimalDataDoms()) diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 91684cf8d47b..139f716c273b 100644 --- a/oox/source/ppt/pptshapegroupcontext.cxx +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -142,11 +142,15 @@ void PPTShapeGroupContext::importExtDrawings( ) for (auto const& extDrawing : pGraphicShape->getExtDrawings()) { OUString aFragmentPath = getFragmentPathFromRelId(extDrawing); - getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), aFragmentPath, + static bool bIgnoreExtDrawings(nullptr != std::getenv("DIAGRAM_IGNORE_EXTDRAWINGS")); + if (!bIgnoreExtDrawings) + { + getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), aFragmentPath, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, pGraphicShape ) ); + } pGraphicShape->keepDiagramDrawing(getFilter(), aFragmentPath); // Apply font color imported from color fragment diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index e23175e32cd5..aff8ccbd9861 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -460,7 +460,9 @@ ShapeContextHandler::getShape() else if (mxDiagramShapeContext.is()) { basegfx::B2DHomMatrix aMatrix; - if (mpShape->getExtDrawings().empty()) + static bool bIgnoreExtDrawings(nullptr != std::getenv("DIAGRAM_IGNORE_EXTDRAWINGS")); + + if (bIgnoreExtDrawings || mpShape->getExtDrawings().empty()) { mpShape->addShape( *mxShapeFilterBase, mpThemePtr.get(), xShapes, aMatrix, mpShape->getFillProperties() ); xResult = mpShape->getXShape(); @@ -478,11 +480,11 @@ ShapeContextHandler::getShape() if (mpShape->getFontRefColorForNodes().isUsed()) applyFontRefColor(pShapePtr, mpShape->getFontRefColorForNodes()); - // migrate IDiagramHelper to new oox::Shape (from mpShape which was loaded + // migrate DiagramHelper_svx to new oox::Shape (from mpShape which was loaded // to pShapePtr where the geometry is now constructed) mpShape->migrateDiagramHelperToNewShape(pShapePtr); - // use now migrated AdvancedDiagramHelper + // use now migrated DiagramHelper_oox pShapePtr->keepDiagramDrawing(*mxShapeFilterBase, aFragmentPath); if (!mpShape->getChildren().empty()) diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 992e7b1b161c..0aee24f8ff06 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -33,7 +33,7 @@ #include <svx/svdogrp.hxx> #include <sfx2/docfile.hxx> #include <osl/diagnose.h> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> #include <com/sun/star/form/FormButtonType.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -291,7 +291,7 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) if(SID_REGENERATE_DIAGRAM == nSlotId) { pView->UnmarkAll(); - pObj->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup*>(pObj)); + pObj->getDiagramHelper()->reLayout(); pView->MarkObj(pObj, pView->GetSdrPageView()); } else if (SID_EDIT_DIAGRAM == nSlotId) diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index fb91475f3b3a..225421f31951 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -15,7 +15,7 @@ #include <svx/svdotable.hxx> #include <svx/svdpage.hxx> #include <svx/svdogrp.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> #include <docmodel/uno/UnoGradientTools.hxx> #include <com/sun/star/animations/TransitionType.hpp> @@ -1603,7 +1603,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testSmartartRotation2) // clear SmartArt data to check how group shapes with double-rotated children are exported, not smartart // NOTE: Now we have a slot (comphelper::dispatchCommand(u".uno:DiagramToGroup"_ustr, {})) and method - // at IDiagramHelper to do that, adapted removal of Diagram/SmartArt functionality + // at DiagramHelper_svx to do that, adapted removal of Diagram/SmartArt functionality uno::Reference<drawing::XDrawPage> xPage(getPage(0)); uno::Reference<drawing::XShape> xShape(xPage->getByIndex(0), uno::UNO_QUERY); SdrObjGroup* pSdrObjGroup diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 73cd176220cd..acf70c5a4d27 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -22,7 +22,7 @@ #include <svx/svdogrp.hxx> #include <comphelper/sequenceashashmap.hxx> #include <oox/drawingml/drawingmltypes.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> using namespace ::com::sun::star; @@ -1067,8 +1067,8 @@ CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt, testInteropGrabBag) CPPUNIT_ASSERT(nullptr != pObj); CPPUNIT_ASSERT(pObj->isDiagram()); - const std::shared_ptr<svx::diagram::IDiagramHelper>& rIDiagramHelper(pObj->getDiagramHelper()); - // const AdvancedDiagramHelper* pHelper(dynamic_cast<AdvancedDiagramHelper*>(rIDiagramHelper.get())); + const std::shared_ptr<svx::diagram::DiagramHelper_svx>& rIDiagramHelper( + pObj->getDiagramHelper()); CPPUNIT_ASSERT(rIDiagramHelper); CPPUNIT_ASSERT(rIDiagramHelper->getOOXDomValue(svx::diagram::DomMapFlag::OOXData).hasValue()); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 21cb6e91694c..65d6d24fabd7 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -88,7 +88,7 @@ #include <svx/unoapi.hxx> #include <svx/svdogrp.hxx> #include <svx/ColorSets.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> #include <sdmod.hxx> #include <sdpage.hxx> #include <unomodel.hxx> diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx index 65b113afe2f5..ccde638f8f34 100644 --- a/sd/source/ui/func/fusel.cxx +++ b/sd/source/ui/func/fusel.cxx @@ -57,7 +57,7 @@ #include <svx/svdundo.hxx> #include <svx/sdrhittesthelper.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> #include <svx/annotation/ObjectAnnotationData.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 6b38d6147c72..192f7bcdccbf 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -50,7 +50,7 @@ #include <svx/float3d.hxx> #include <svx/sdmetitm.hxx> #include <svx/svdogrp.hxx> -#include <svx/diagram/IDiagramHelper.hxx> +#include <svx/diagram/DiagramHelper_svx.hxx> #include <app.hrc> #include <strings.hrc> @@ -501,7 +501,7 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) if (SID_REGENERATE_DIAGRAM == nSlot) { mpDrawView->UnmarkAll(); - pObj->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup*>(pObj)); + pObj->getDiagramHelper()->reLayout(); mpDrawView->MarkObj(pObj, mpDrawView->GetSdrPageView()); } else if (SID_EDIT_DIAGRAM == nSlot) diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 95931ee74153..29e4a3137818 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -1,4 +1,4 @@ -UnoControls/inc/basecontainercontrol.hxx +hUnoControls/inc/basecontainercontrol.hxx UnoControls/inc/basecontrol.hxx UnoControls/inc/multiplexer.hxx UnoControls/source/base/basecontainercontrol.cxx @@ -5143,7 +5143,7 @@ include/oox/drawingml/clrscheme.hxx include/oox/drawingml/color.hxx include/oox/drawingml/connectorshapecontext.hxx include/oox/drawingml/diagram/diagram.hxx -include/oox/drawingml/diagram/diagramhelper.hxx +include/oox/drawingml/diagram/diagramhelper_oox.hxx include/oox/drawingml/drawingmltypes.hxx include/oox/drawingml/graphicshapecontext.hxx include/oox/drawingml/shape.hxx @@ -5667,7 +5667,7 @@ include/svx/sdmetitm.hxx include/svx/sdooitm.hxx include/svx/sdprcitm.hxx include/svx/diagram/datamodel_svx.hxx -include/svx/diagram/IDiagramHelper.hxx +include/svx/diagram/DiagramHelper_svx.hxx include/svx/sdr/animation/animationstate.hxx include/svx/sdr/animation/objectanimator.hxx include/svx/sdr/animation/scheduler.hxx @@ -11111,7 +11111,7 @@ svx/source/customshapes/EnhancedCustomShapeHandle.cxx svx/source/customshapes/EnhancedCustomShapeHandle.hxx svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx svx/source/diagram/datamodel_svx.cxx -svx/source/diagram/IDiagramHelper.cxx +svx/source/diagram/DiagramHelper_svx.cxx svx/source/dialog/ClassificationDialog.cxx svx/source/dialog/ClassificationEditView.cxx svx/source/dialog/ClassificationEditView.hxx diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index ce5ddb80a883..44d65d94a33a 100644 -e ... etc. - the rest is truncated
