cui/source/dialogs/DiagramDialog.cxx           |    7 +
 include/oox/drawingml/shape.hxx                |   13 ++
 include/oox/ppt/pptimport.hxx                  |    1 
 include/svx/svdogrp.hxx                        |   24 ++++
 oox/Library_oox.mk                             |    1 
 oox/source/drawingml/diagram/diagram.cxx       |    9 +
 oox/source/drawingml/diagram/diagramhelper.cxx |  140 +++++++++++++++++++++++++
 oox/source/drawingml/diagram/diagramhelper.hxx |   63 +++++++++++
 oox/source/drawingml/shape.cxx                 |   42 +++++++
 oox/source/ppt/pptimport.cxx                   |    5 
 oox/source/ppt/pptshape.cxx                    |    6 +
 sd/source/ui/view/drviews3.cxx                 |   13 ++
 solenv/clang-format/excludelist                |    2 
 svx/source/svdraw/svdogrp.cxx                  |   19 ++-
 14 files changed, 341 insertions(+), 4 deletions(-)

New commits:
commit eaaf5ef8f99404797ffbb44ceeebf8795d85f07e
Author:     Armin Le Grand (Allotropia) <armin.le.gr...@me.com>
AuthorDate: Fri Feb 18 16:07:28 2022 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Tue Feb 22 18:09:24 2022 +0100

    Advanced Diagram support: first additions/reorganizations
    
    To allow advanced Diagram/SmartArt support in the future
    this is a first step to organize imported SmartArt Data in
    a way that will allow to re-layout loaded SmartArts, under
    re-usage of the oox::Theme (held available).
    
    It is designed to work without holding available the
    original XML snippets defining the imported Diagram in any
    way, also for performance reasons. It tries to re-use some
    of the already basically added functionality, including
    the systematic layouting using the generic layout
    algorithm, plus some already available text extraction.
    
    Before being sure that the former state can be completely
    replaced this is optoinal and used when
    SAL_ENABLE_ADVANCED_SMART_ART is defined. Some new stuff
    is already done but e.g. the redefined reLayout method will
    not (yet) be triggered. It works and reliably produces a
    re-layouted identical version, also preserving
    transformations.
    
    Change-Id: I08cfbae04afa663d0589530aae549216d853128d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130171
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/cui/source/dialogs/DiagramDialog.cxx 
b/cui/source/dialogs/DiagramDialog.cxx
index 97ae0ca3d80d..eceaaed0c666 100644
--- a/cui/source/dialogs/DiagramDialog.cxx
+++ b/cui/source/dialogs/DiagramDialog.cxx
@@ -40,6 +40,8 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow,
 IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void)
 {
     OUString sText = mpTextAdd->get_text();
+    static bool bAdvancedSmartArt(nullptr != 
getenv("SAL_ENABLE_ADVANCED_SMART_ART"));
+
     if (!sText.isEmpty())
     {
         OUString sNodeId = mpDiagramData->addNode(sText);
@@ -48,6 +50,11 @@ IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, 
void)
         mpTreeDiagram->select(*pEntry);
         comphelper::dispatchCommand(".uno:RegenerateDiagram", {});
     }
+    else if (bAdvancedSmartArt)
+    {
+        // For test purposes re-layout without change
+        comphelper::dispatchCommand(".uno:RegenerateDiagram", {});
+    }
 }
 
 IMPL_LINK_NOARG(DiagramDialog, OnRemoveClick, weld::Button&, void)
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 40c8319f67d3..59ed231378fe 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -57,6 +57,8 @@ namespace oox::vml {
     struct OleObjectInfo;
 }
 
+class DiagramHelper;
+
 namespace oox::drawingml {
 
 class Theme;
@@ -100,6 +102,8 @@ struct LinkedTxbxAttr
     LinkedTxbxAttr(): id(0),seq(0){};
 };
 
+class Diagram;
+
 class OOX_DLLPUBLIC Shape
     : public std::enable_shared_from_this< Shape >
 {
@@ -249,6 +253,11 @@ public:
 
     oox::core::NamedShapePairs& getDiagramFontHeights() { return 
maDiagramFontHeights; }
 
+    // Allows preparation of a local Diagram helper && propagate an eventually
+    // existing one to the data holder object later
+    void prepareDiagramHelper(const std::shared_ptr< Diagram >& rDiagramPtr, 
const std::shared_ptr<::oox::drawingml::Theme>& rTheme);
+    void propagateDiagramHelper();
+
 protected:
 
     enum FrameType
@@ -392,6 +401,10 @@ private:
 
     /// For SmartArt, this contains groups of shapes: automatic font size is 
the same in each group.
     oox::core::NamedShapePairs maDiagramFontHeights;
+
+    // temporary space for DiagramHelper in preparation for collecting data
+    // Note: I tried to use a unique_ptr here, but existing constuctor func 
does not allow that
+    DiagramHelper* mpDiagramHelper;
 };
 
 }
diff --git a/include/oox/ppt/pptimport.hxx b/include/oox/ppt/pptimport.hxx
index 3b81f26ec5e8..b7b9e059e828 100644
--- a/include/oox/ppt/pptimport.hxx
+++ b/include/oox/ppt/pptimport.hxx
@@ -75,6 +75,7 @@ public:
     virtual sal_Bool SAL_CALL filter( const css::uno::Sequence<   
css::beans::PropertyValue >& rDescriptor ) override;
 
     ::Color getSchemeColor( sal_Int32 nToken ) const;
+    std::shared_ptr<::oox::drawingml::Theme> getCurrentThemePtr() const;
 
 #if OSL_DEBUG_LEVEL > 0
     static XmlFilterBase* mpDebugFilterBase;
diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx
index eb2f620334b9..1616355c81ce 100644
--- a/include/svx/svdogrp.hxx
+++ b/include/svx/svdogrp.hxx
@@ -26,6 +26,21 @@
 
 // Forward declarations
 class SfxItemSet;
+class SdrObjGroup;
+
+// Helper class to allow administer advanced Diagram related
+// data and functionality
+class SVXCORE_DLLPUBLIC DiagramHelper
+{
+protected:
+    void anchorToSdrObjGroup(SdrObjGroup& rTarget);
+
+public:
+    DiagramHelper();
+    virtual ~DiagramHelper();
+
+    virtual void reLayout() = 0;
+};
 
 //   SdrObjGroup
 class SVXCORE_DLLPUBLIC SdrObjGroup final : public SdrObject, public SdrObjList
@@ -37,6 +52,15 @@ private:
 
     Point maRefPoint; // Reference point inside the object group
 
+    // Allow *only* DiagramHelper itself to set this internal reference to
+    // tightly control usage
+    friend class DiagramHelper;
+    std::unique_ptr<DiagramHelper> mp_DiagramHelper;
+
+public:
+    bool isDiagram() const { return bool(mp_DiagramHelper); }
+    DiagramHelper* getDiagramHelper() { return mp_DiagramHelper.get(); }
+
 private:
     // protected destructor - due to final, make private
     virtual ~SdrObjGroup() override;
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 979635a2f213..ca88ab100039 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -150,6 +150,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
     oox/source/drawingml/diagram/datamodel \
     oox/source/drawingml/diagram/datamodelcontext \
     oox/source/drawingml/diagram/diagram \
+    oox/source/drawingml/diagram/diagramhelper \
     oox/source/drawingml/diagram/diagramdefinitioncontext \
     oox/source/drawingml/diagram/diagramfragmenthandler \
     oox/source/drawingml/diagram/diagramlayoutatoms \
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 13fc4aa26b3b..e23ce68a14a8 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -34,6 +34,7 @@
 #include <oox/token/namespaces.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <svx/svdpage.hxx>
+#include <oox/ppt/pptimport.hxx>
 
 #include "diagramlayoutatoms.hxx"
 #include "layoutatomvisitors.hxx"
@@ -362,6 +363,14 @@ void loadDiagram( ShapePtr const & pShape,
     pDiagram->addTo(pShape);
     pShape->setDiagramData(pData);
     pShape->setDiagramDoms(pDiagram->getDomsAsPropertyValues());
+
+    // We need the shared_ptr to oox::Theme here, so do something direct when
+    // we can identify the expected type of the used import filter
+    oox::ppt::PowerPointImport* 
pFilter(dynamic_cast<oox::ppt::PowerPointImport*>(&rFilter));
+    const std::shared_ptr<::oox::drawingml::Theme> aThemePtr(pFilter ? 
pFilter->getCurrentThemePtr() : nullptr);
+
+    // Prepare support for the advanced DiagramHelper using Diagram & Theme 
data
+    pShape->prepareDiagramHelper(pDiagram, aThemePtr);
 }
 
 void loadDiagram(ShapePtr const& pShape,
diff --git a/oox/source/drawingml/diagram/diagramhelper.cxx 
b/oox/source/drawingml/diagram/diagramhelper.cxx
new file mode 100644
index 000000000000..61179993461d
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramhelper.cxx
@@ -0,0 +1,140 @@
+/* -*- 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 "diagramhelper.hxx"
+#include "diagram.hxx"
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <oox/shape/ShapeFilterBase.hxx>
+#include <oox/ppt/pptimport.hxx>
+#include <svx/svdmodel.hxx>
+#include <comphelper/processfactory.hxx>
+
+using namespace ::com::sun::star;
+
+namespace oox::drawingml {
+
+AdvancedDiagramHelper::AdvancedDiagramHelper(
+    const std::shared_ptr< Diagram >& rDiagramPtr,
+    const std::shared_ptr<::oox::drawingml::Theme>& rTheme)
+: DiagramHelper()
+, mpDiagramPtr(rDiagramPtr)
+, mpThemePtr(rTheme)
+{
+}
+
+AdvancedDiagramHelper::~AdvancedDiagramHelper()
+{
+}
+
+void AdvancedDiagramHelper::reLayout()
+{
+    if(mpDiagramPtr)
+    {
+        // Get the oox::Shape that represents the Diagram GraphicObject
+        const ShapePtr & pParentShape = mpDiagramPtr->getShape();
+
+        // Remove it's children which represent the oox::Shapes created by
+        // the layout process as preparation to re-creation. These should
+        // already be cleared, but make sure.
+        pParentShape->getChildren().clear();
+
+        // Re-create the oox::Shapes for the diagram content
+        mpDiagramPtr->addTo(pParentShape);
+
+        // Access the GroupObject representing the SmartArt in DrawingLayer
+        SdrObjGroup* 
pAnchorObj(dynamic_cast<SdrObjGroup*>(SdrObject::getSdrObjectFromXShape(pParentShape->getXShape())));
+
+        // Rescue/remember geometric transformation of existing Diagram
+        basegfx::B2DHomMatrix aTransformation;
+        basegfx::B2DPolyPolygon aPolyPolygon;
+        pAnchorObj->TRGetBaseGeometry(aTransformation, aPolyPolygon);
+
+        // Delete all existing shapes in that group to prepare re-creation
+        pAnchorObj->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 incarrnated 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(pAnchorObj->getSdrModelFromSdrObject());
+        uno::Reference< uno::XInterface > const & 
rUnoModel(rModel.getUnoModel());
+        css::uno::Reference<css::uno::XComponentContext> 
xContext(comphelper::getProcessComponentContext());
+        rtl::Reference<oox::shape::ShapeFilterBase> xFilter(new 
oox::shape::ShapeFilterBase(xContext));
+        xFilter->setCurrentTheme(mpThemePtr);
+        css::uno::Reference< css::lang::XComponent > aComponentModel( 
rUnoModel, uno::UNO_QUERY );
+        xFilter->setTargetDocument(aComponentModel);
+
+        // Prepare the target for the to-be-created XShapes
+        uno::Reference<drawing::XShapes> xShapes(pParentShape->getXShape(), 
uno::UNO_QUERY_THROW);
+
+        for (auto const& child : pParentShape->getChildren())
+        {
+            // Create all sub-shapes. This will recursively create needed 
geometry using
+            // filter-internal ::createShapes
+            child->addShape(
+                *xFilter,
+                xFilter->getCurrentTheme(),
+                xShapes,
+                aTransformation,
+                pParentShape->getFillProperties());
+        }
+
+        // Re-apply remembered geometry
+        pAnchorObj->TRSetBaseGeometry(aTransformation, aPolyPolygon);
+
+        // Delete oox::Shapes that represented the content of the
+        // diagram. These were needed for creating the XShapes/SdrObjects
+        // (created by ::addTo above) but are no longer needed, so free
+        // the memory
+        pParentShape->getChildren().clear();
+    }
+}
+
+void AdvancedDiagramHelper::doAnchor(SdrObjGroup& rTarget)
+{
+    const ShapePtr & pParentShape = mpDiagramPtr->getShape();
+
+    if(pParentShape)
+    {
+        // The oox::Shapes childs are not needed for holding the original data,
+        // free that memory
+        pParentShape->getChildren().clear();
+    }
+
+    anchorToSdrObjGroup(rTarget);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/diagram/diagramhelper.hxx 
b/oox/source/drawingml/diagram/diagramhelper.hxx
new file mode 100644
index 000000000000..c6bd507f32e6
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramhelper.hxx
@@ -0,0 +1,63 @@
+/* -*- 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 INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAMHELPER_HXX
+#define INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAMHELPER_HXX
+
+#include <rtl/ustring.hxx>
+#include <oox/drawingml/theme.hxx>
+#include <svx/svdogrp.hxx>
+
+namespace oox::drawingml {
+
+class Diagram;
+
+// Advanced DiagramHelper
+//
+// This helper tries to hold all neccessary data to re-layout
+// all XShapes/SdrObjects of an already imported Diagram. The
+// Diagram holds the SmarArt model data before it gets layouted,
+// while Theme holds the oox Fill/Line/Style definitions to
+// apply.
+// Re-Layouting (re-reating) is rather complex, for detailed
+// information see ::reLayout implementation.
+// This helper class may/should be extended to:
+// - deliver representative data from the Diagram-Model
+// - modify it eventually
+// - im/export Diagram model to other representations
+class AdvancedDiagramHelper final : public DiagramHelper
+{
+    const std::shared_ptr< Diagram >                mpDiagramPtr;
+    const std::shared_ptr<::oox::drawingml::Theme>  mpThemePtr;
+
+public:
+    AdvancedDiagramHelper(
+        const std::shared_ptr< Diagram >& rDiagramPtr,
+        const std::shared_ptr<::oox::drawingml::Theme>& rTheme);
+    virtual ~AdvancedDiagramHelper();
+
+    virtual void reLayout();
+    void doAnchor(SdrObjGroup& rTarget);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 40377e29c230..97f87a2683ab 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -50,6 +50,7 @@
 #include <oox/mathml/import.hxx>
 #include <oox/token/properties.hxx>
 #include "diagram/datamodel.hxx"
+#include "diagram/diagramhelper.hxx"
 
 #include <comphelper/classids.hxx>
 #include <comphelper/propertysequence.hxx>
@@ -102,6 +103,7 @@
 #include <vcl/wmfexternal.hxx>
 #include <sal/log.hxx>
 #include <svx/sdtaitm.hxx>
+#include <oox/drawingml/diagram/diagram.hxx>
 
 using namespace ::oox::core;
 using namespace ::com::sun::star;
@@ -140,6 +142,7 @@ Shape::Shape( const char* pServiceName, bool bDefaultHeight 
)
 , mbTextBox( false )
 , mbHasLinkedTxbx( false )
 , maDiagramDoms( 0 )
+, mpDiagramHelper( nullptr )
 {
     if ( pServiceName )
         msServiceName = OUString::createFromAscii( pServiceName );
@@ -189,10 +192,49 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mfAspectRatio(pSourceShape->mfAspectRatio)
 , mbUseBgFill(pSourceShape->mbUseBgFill)
 , maDiagramFontHeights(pSourceShape->maDiagramFontHeights)
+, mpDiagramHelper( nullptr )
 {}
 
 Shape::~Shape()
 {
+    // DiagramHelper should not be set here anymore, see
+    // propagateDiagramHelper below (maybe assert..?)
+    delete mpDiagramHelper;
+}
+
+void Shape::prepareDiagramHelper(
+    const std::shared_ptr< Diagram >& rDiagramPtr,
+    const std::shared_ptr<::oox::drawingml::Theme>& rTheme)
+{
+    // Prepare Diagam data collecting for this Shape
+    if( nullptr == mpDiagramHelper && FRAMETYPE_DIAGRAM == meFrameType )
+    {
+        mpDiagramHelper = new AdvancedDiagramHelper(rDiagramPtr, rTheme);
+    }
+}
+
+void Shape::propagateDiagramHelper()
+{
+    // Propagate collected Diagram data to data holder
+    if (FRAMETYPE_DIAGRAM == meFrameType && nullptr != mpDiagramHelper)
+    {
+        SdrObjGroup* pAnchorObj = 
dynamic_cast<SdrObjGroup*>(SdrObject::getSdrObjectFromXShape(mxShape));
+
+        if(pAnchorObj)
+        {
+            
static_cast<AdvancedDiagramHelper*>(mpDiagramHelper)->doAnchor(*pAnchorObj);
+            mpDiagramHelper = nullptr;
+        }
+    }
+
+    // If propagation failed, delete/cleanup here. Since the DiagramHelper
+    // holds a Diagram and that this Shape it is necessary - the destructor
+    // will not be called and will be too late
+    if (nullptr != mpDiagramHelper)
+    {
+        delete mpDiagramHelper;
+        mpDiagramHelper = nullptr;
+    }
 }
 
 table::TablePropertiesPtr const & Shape::getTableProperties()
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 8e35217ea590..87d2e1ee43d7 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -182,6 +182,11 @@ const ::oox::drawingml::Theme* 
PowerPointImport::getCurrentTheme() const
     return mpActualSlidePersist ? mpActualSlidePersist->getTheme().get() : 
nullptr;
 }
 
+std::shared_ptr<::oox::drawingml::Theme> 
PowerPointImport::getCurrentThemePtr() const
+{
+    return mpActualSlidePersist ? mpActualSlidePersist->getTheme() : 
std::shared_ptr<::oox::drawingml::Theme>();
+}
+
 sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& 
rDescriptor )
 {
     if( XmlFilterBase::filter( rDescriptor ) )
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index f94abea01c7a..d8ab4dfef7ca 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -564,6 +564,12 @@ void PPTShape::addShape(
                 syncDiagramFontHeights();
             }
 
+            // Support advanced DiagramHelper
+            if (FRAMETYPE_DIAGRAM == meFrameType)
+            {
+                propagateDiagramHelper();
+            }
+
             getShapeProperties().getProperty(PROP_URL) >>= sURL;
             if (!sURL.isEmpty() && !xShapes.is())
                 aURLShapes.push_back({ sURL, xShape });
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index 54cccf78654b..8e06b9327def 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -48,6 +48,7 @@
 #include <svx/f3dchild.hxx>
 #include <svx/float3d.hxx>
 #include <svx/sdmetitm.hxx>
+#include <svx/svdogrp.hxx>
 
 #include <app.hrc>
 #include <strings.hrc>
@@ -487,8 +488,9 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
             {
                 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
                 Reference<css::drawing::XShape> xShape(pObj->getUnoShape(), 
UNO_QUERY);
+                static bool bAdvancedSmartArt(nullptr != 
getenv("SAL_ENABLE_ADVANCED_SMART_ART"));
 
-                if (oox::drawingml::DrawingML::IsDiagram(xShape))
+                if (!bAdvancedSmartArt && 
oox::drawingml::DrawingML::IsDiagram(xShape))
                 {
                     mpDrawView->UnmarkAll();
 
@@ -502,6 +504,15 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
 
                     mpDrawView->MarkObj(pObj, mpDrawView->GetSdrPageView());
                 }
+
+                // Support advanced DiagramHelper
+                SdrObjGroup* pAnchorObj = dynamic_cast<SdrObjGroup*>(pObj);
+                if(bAdvancedSmartArt && pAnchorObj && pAnchorObj->isDiagram())
+                {
+                    mpDrawView->UnmarkAll();
+                    pAnchorObj->getDiagramHelper()->reLayout();
+                    mpDrawView->MarkObj(pObj, mpDrawView->GetSdrPageView());
+                }
             }
 
             rReq.Done();
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 5f8f5ec71d1c..d2adcf0b54c8 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -7159,6 +7159,8 @@ oox/source/drawingml/diagram/constraintlistcontext.cxx
 oox/source/drawingml/diagram/constraintlistcontext.hxx
 oox/source/drawingml/diagram/datamodel.cxx
 oox/source/drawingml/diagram/datamodel.hxx
+oox/source/drawingml/diagram/diagramhelper.cxx
+oox/source/drawingml/diagram/diagramhelper.hxx
 oox/source/drawingml/diagram/datamodelcontext.cxx
 oox/source/drawingml/diagram/datamodelcontext.hxx
 oox/source/drawingml/diagram/diagram.cxx
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index f9eb754bb7c2..47e9f0f83901 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -35,6 +35,14 @@
 #include <rtl/ustrbuf.hxx>
 #include <vcl/canvastools.hxx>
 
+DiagramHelper::DiagramHelper() {}
+DiagramHelper::~DiagramHelper() {}
+
+void DiagramHelper::anchorToSdrObjGroup(SdrObjGroup& rTarget)
+{
+    rTarget.mp_DiagramHelper.reset(this);
+}
+
 // BaseProperties section
 std::unique_ptr<sdr::properties::BaseProperties> 
SdrObjGroup::CreateObjectSpecificProperties()
 {
@@ -48,14 +56,19 @@ std::unique_ptr<sdr::contact::ViewContact> 
SdrObjGroup::CreateObjectSpecificView
 }
 
 SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel)
-:   SdrObject(rSdrModel),
-    maRefPoint(0, 0)
+: SdrObject(rSdrModel)
+, SdrObjList()
+, maRefPoint(0, 0)
+, mp_DiagramHelper()
 {
     m_bClosedObj=false;
 }
 
 SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const & rSource)
-:   SdrObject(rSdrModel, rSource)
+: SdrObject(rSdrModel, rSource)
+, SdrObjList()
+, maRefPoint(0, 0)
+, mp_DiagramHelper()
 {
     m_bClosedObj=false;
 

Reply via email to