oox/source/drawingml/diagram/datamodel.cxx | 2 - oox/source/drawingml/diagram/datamodel.hxx | 10 +++--- oox/source/drawingml/diagram/datamodelcontext.cxx | 2 - oox/source/drawingml/diagram/diagram.cxx | 2 - oox/source/drawingml/diagram/diagramhelper.cxx | 5 ++- svx/source/svdraw/svdedtv2.cxx | 36 ++++++++++++++++------ 6 files changed, 40 insertions(+), 17 deletions(-)
New commits: commit 4e8d6ccf97e29e5ea14e0d074074606f12040f36 Author: Armin Le Grand (Allotropia) <armin.le.gr...@me.com> AuthorDate: Wed Apr 6 12:03:10 2022 +0200 Commit: Armin Le Grand <armin.le.gr...@me.com> CommitDate: Wed Apr 6 14:31:01 2022 +0200 Advanced Diagram support: Enhance BackgroundShape handling The BackgroundShape may have a FillStyle after import, so do handle that FillStyle accordingly. Also enhance breaking the Group by keeping that shape in that case and deactivate Move/Size change lock for it. Also Undo needed. Change-Id: Iccdb236a2311275efc07162fd4bd2cfc252fd437 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132626 Tested-by: Jenkins Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> diff --git a/oox/source/drawingml/diagram/datamodel.cxx b/oox/source/drawingml/diagram/datamodel.cxx index 394266ae123d..cc8924228e23 100644 --- a/oox/source/drawingml/diagram/datamodel.cxx +++ b/oox/source/drawingml/diagram/datamodel.cxx @@ -126,7 +126,7 @@ void DiagramData::secureDataFromShapeToModelAfterDiagramImport() DiagramData::DiagramData() : svx::diagram::DiagramData() -, mpFillProperties( std::make_shared<FillProperties>() ) +, mpBackgroundFillProperties( std::make_shared<FillProperties>() ) { } diff --git a/oox/source/drawingml/diagram/datamodel.hxx b/oox/source/drawingml/diagram/datamodel.hxx index 95383ad1da77..f7402cb0681e 100644 --- a/oox/source/drawingml/diagram/datamodel.hxx +++ b/oox/source/drawingml/diagram/datamodel.hxx @@ -44,7 +44,7 @@ public: // creates temporary processing data from model data virtual void buildDiagramDataModel(bool bClearOoxShapes); - FillPropertiesPtr& getFillProperties() { return mpFillProperties; } + FillPropertiesPtr& getBackgroundFillProperties() { return mpBackgroundFillProperties; } virtual void dump() const; Shape* getOrCreateAssociatedShape(const svx::diagram::Point& rPoint, bool bCreateOnDemand = false) const; @@ -56,10 +56,12 @@ public: protected: // The model definition, the parts *only* available in oox. Also look for already // defined ModelData in svx::diagram::DiagramData - // - FillStyle - FillPropertiesPtr mpFillProperties; - // temporary processing data, deleted when using build() + // - FillStyle for Diagram Background (empty constructed, may stay empty) + FillPropertiesPtr mpBackgroundFillProperties; + + // temporary processing data, deleted when using build(). Association + // map between oox::drawingml::Shape and svx::diagram::Point ModelData PointShapeMap maPointShapeMap; }; diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx index 5715e7d11995..97484c992ad3 100644 --- a/oox/source/drawingml/diagram/datamodelcontext.cxx +++ b/oox/source/drawingml/diagram/datamodelcontext.cxx @@ -317,7 +317,7 @@ public: case A_TOKEN( solidFill ): // EG_FillProperties return FillPropertiesContext::createFillContext( - *this, aElementToken, rAttribs, *mpDataModel->getFillProperties() ); + *this, aElementToken, rAttribs, *mpDataModel->getBackgroundFillProperties() ); case A_TOKEN( effectDag ): case A_TOKEN( effectLst ): // TODO diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 6684ef913995..d12deea33d2f 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -131,7 +131,7 @@ void Diagram::addTo( const ShapePtr & pParentShape ) pBackground->setSubType(XML_rect); pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect); pBackground->setSize(pParentShape->getSize()); - pBackground->getFillProperties() = *mpData->getFillProperties(); + pBackground->getFillProperties() = *mpData->getBackgroundFillProperties(); pBackground->setLocked(true); auto& aChildren = pParentShape->getChildren(); aChildren.insert(aChildren.begin(), pBackground); diff --git a/oox/source/drawingml/diagram/diagramhelper.cxx b/oox/source/drawingml/diagram/diagramhelper.cxx index 3d2491325722..4ed76e5bff1c 100644 --- a/oox/source/drawingml/diagram/diagramhelper.cxx +++ b/oox/source/drawingml/diagram/diagramhelper.cxx @@ -69,7 +69,6 @@ void AdvancedDiagramHelper::reLayout(SdrObjGroup& rTarget) oox::drawingml::ShapePtr pShapePtr = std::make_shared<Shape>( "com.sun.star.drawing.GroupShape" ); pShapePtr->setDiagramType(); pShapePtr->setSize(maImportSize); - pShapePtr->getFillProperties() = *mpDiagramPtr->getData()->getFillProperties(); // Re-create the oox::Shapes for the diagram content mpDiagramPtr->addTo(pShapePtr); @@ -99,7 +98,11 @@ void AdvancedDiagramHelper::reLayout(SdrObjGroup& rTarget) 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)); + + // set oox::Theme at Filter. All LineStyle/FillStyle/Colors/Attributes + // will be taken from there xFilter->setCurrentTheme(mpThemePtr); + css::uno::Reference< css::lang::XComponent > aComponentModel( rUnoModel, uno::UNO_QUERY ); xFilter->setTargetDocument(aComponentModel); diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index a046a6b3a59e..08b361afa9a3 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -1915,25 +1915,43 @@ void SdrEditView::UnGroupMarked() const bool bIsDiagram(nullptr != pGroup && pGroup->isDiagram()); // If the Group is a Diagram, it has a filler BG object to guarantee - // the Diagam's dimensions. Identify that shape & delete it, it is not - // useful for any further processing + // the Diagam's dimensions. Identify that shape if(bIsDiagram && nObjCount) { SdrObject* pObj(pSrcLst->GetObj(0)); if(nullptr != pObj && !pObj->IsGroupObject() && - !pObj->HasFillStyle() && !pObj->HasLineStyle() && + !pObj->HasLineStyle() && pObj->IsMoveProtect() && pObj->IsResizeProtect()) { - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + if(pObj->HasFillStyle()) + { + // If it has FillStyle it is a useful object representing that possible + // defined fill from oox import. In this case, we should remove the + // Move/Resize protection to allow seamless further processing. + + // Undo of these is handled by SdrUndoGeoObj which holds a SdrObjGeoData, + // creae one + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + + pObj->SetMoveProtect(false); + pObj->SetResizeProtect(false); + } + else + { + // If it has no FillStyle it is not useful for any further processing + // but only was used as a placeholder, get directly rid of it + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); - pObj = pSrcLst->RemoveObject(0); + pObj = pSrcLst->RemoveObject(0); - if( !bUndo ) - SdrObject::Free(pObj); + if( !bUndo ) + SdrObject::Free(pObj); - nObjCount = pSrcLst->GetObjCount(); + nObjCount = pSrcLst->GetObjCount(); + } } }