Advanced Diagram support: Make Style/Theme info available
The Style/Theme information is central for re-creating the Diagram shape representation. Make that data available in the ModelData classes in svx. With that information, a re- creation with all needed attributes is possible, e.g. when the model gets changed (remove/add data entries). Also some cleanups done. Change-Id: Icd925c9731891092f1ddd96c8feb165e1f846f4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132738 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
This commit is contained in:
committed by
Armin Le Grand
parent
a5c27f59c4
commit
027db2df53
@@ -70,8 +70,6 @@ public:
|
|||||||
|
|
||||||
::Color getSchemeColor( sal_Int32 nToken ) const;
|
::Color getSchemeColor( sal_Int32 nToken ) const;
|
||||||
|
|
||||||
void importTheme();
|
|
||||||
|
|
||||||
void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rxGraphicMapper)
|
void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> const & rxGraphicMapper)
|
||||||
{
|
{
|
||||||
mxGraphicMapper = rxGraphicMapper;
|
mxGraphicMapper = rxGraphicMapper;
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <com/sun/star/uno/Sequence.hxx>
|
#include <com/sun/star/uno/Sequence.hxx>
|
||||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||||
|
#include <com/sun/star/xml/dom/XDocument.hpp>
|
||||||
|
|
||||||
namespace svx::diagram {
|
namespace svx::diagram {
|
||||||
|
|
||||||
@@ -183,6 +184,9 @@ public:
|
|||||||
OUString addNode(const OUString& rText);
|
OUString addNode(const OUString& rText);
|
||||||
bool removeNode(const OUString& rNodeId);
|
bool removeNode(const OUString& rNodeId);
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void getChildrenString(OUStringBuffer& rBuf, const Point* pPoint, sal_Int32 nLevel) const;
|
void getChildrenString(OUStringBuffer& rBuf, const Point* pPoint, sal_Int32 nLevel) const;
|
||||||
void addConnection(TypeConstant nType, const OUString& sSourceId, const OUString& sDestId);
|
void addConnection(TypeConstant nType, const OUString& sSourceId, const OUString& sDestId);
|
||||||
@@ -194,8 +198,15 @@ protected:
|
|||||||
// See evtl. parts in oox::drawingml::DiagramData that may need t obe accessed
|
// See evtl. parts in oox::drawingml::DiagramData that may need t obe accessed
|
||||||
// - logic connections/associations
|
// - logic connections/associations
|
||||||
// - data point entries
|
// - data point entries
|
||||||
|
// - 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
|
||||||
|
// need to be created in PresentationFragmentHandler::importSlide. If
|
||||||
|
// this needs to be written to a File, please refer to
|
||||||
|
// fileDocxExport::WriteTheme(), look for "OOXTheme"
|
||||||
Connections maConnections;
|
Connections maConnections;
|
||||||
Points maPoints;
|
Points maPoints;
|
||||||
|
css::uno::Reference< css::xml::dom::XDocument > mxThemeDocument;
|
||||||
|
|
||||||
// temporary processing data, deleted when using build()
|
// temporary processing data, deleted when using build()
|
||||||
PointNameMap maPointNameMap;
|
PointNameMap maPointNameMap;
|
||||||
|
@@ -416,6 +416,12 @@ void loadDiagram( ShapePtr const & pShape,
|
|||||||
pDiagram->addTo(pShape);
|
pDiagram->addTo(pShape);
|
||||||
pShape->setDiagramDoms(pDiagram->getDomsAsPropertyValues());
|
pShape->setDiagramDoms(pDiagram->getDomsAsPropertyValues());
|
||||||
|
|
||||||
|
// Get the oox::Theme definition and - if available - move/secure the
|
||||||
|
// original ImportData directly to the Diagram ModelData
|
||||||
|
std::shared_ptr<::oox::drawingml::Theme> aTheme(rFilter.getCurrentThemePtr());
|
||||||
|
if(aTheme)
|
||||||
|
pData->setThemeDocument(aTheme->getFragment()); //getTempFile());
|
||||||
|
|
||||||
// Prepare support for the advanced DiagramHelper using Diagram & Theme data
|
// Prepare support for the advanced DiagramHelper using Diagram & Theme data
|
||||||
pShape->prepareDiagramHelper(pDiagram, rFilter.getCurrentThemePtr());
|
pShape->prepareDiagramHelper(pDiagram, rFilter.getCurrentThemePtr());
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#include <drawingml/fillproperties.hxx>
|
#include <drawingml/fillproperties.hxx>
|
||||||
#include <svx/svdmodel.hxx>
|
#include <svx/svdmodel.hxx>
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
|
#include <oox/drawingml/themefragmenthandler.hxx>
|
||||||
|
#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
@@ -101,7 +103,7 @@ void AdvancedDiagramHelper::reLayout(SdrObjGroup& rTarget)
|
|||||||
|
|
||||||
// set oox::Theme at Filter. All LineStyle/FillStyle/Colors/Attributes
|
// set oox::Theme at Filter. All LineStyle/FillStyle/Colors/Attributes
|
||||||
// will be taken from there
|
// will be taken from there
|
||||||
xFilter->setCurrentTheme(mpThemePtr);
|
xFilter->setCurrentTheme(getOrCreateThemePtr(xFilter));
|
||||||
|
|
||||||
css::uno::Reference< css::lang::XComponent > aComponentModel( rUnoModel, uno::UNO_QUERY );
|
css::uno::Reference< css::lang::XComponent > aComponentModel( rUnoModel, uno::UNO_QUERY );
|
||||||
xFilter->setTargetDocument(aComponentModel);
|
xFilter->setTargetDocument(aComponentModel);
|
||||||
@@ -183,6 +185,37 @@ void AdvancedDiagramHelper::doAnchor(SdrObjGroup& rTarget)
|
|||||||
anchorToSdrObjGroup(rTarget);
|
anchorToSdrObjGroup(rTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr< ::oox::drawingml::Theme > AdvancedDiagramHelper::getOrCreateThemePtr(
|
||||||
|
rtl::Reference< oox::shape::ShapeFilterBase >& rxFilter) const
|
||||||
|
{
|
||||||
|
static bool bForceThemePtrReceation(false);
|
||||||
|
|
||||||
|
// (Re-)Use already existing Theme if existing/imported if possible.
|
||||||
|
// If not, re-import Theme if data is available and thus possible
|
||||||
|
if(hasDiagramData() && (bForceThemePtrReceation || !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>();
|
||||||
|
|
||||||
|
// import Theme ModelData
|
||||||
|
rxFilter->importFragment(
|
||||||
|
new ThemeFragmentHandler(
|
||||||
|
*rxFilter, OUString(), *mpThemePtr ),
|
||||||
|
uno::Reference< css::xml::sax::XFastSAXSerializable >(
|
||||||
|
xThemeDocument,
|
||||||
|
uno::UNO_QUERY_THROW));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mpThemePtr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
#include <oox/drawingml/theme.hxx>
|
#include <oox/drawingml/theme.hxx>
|
||||||
|
#include <oox/shape/ShapeFilterBase.hxx>
|
||||||
#include <svx/svdogrp.hxx>
|
#include <svx/svdogrp.hxx>
|
||||||
|
|
||||||
namespace oox::drawingml {
|
namespace oox::drawingml {
|
||||||
@@ -44,7 +45,7 @@ class Diagram;
|
|||||||
class AdvancedDiagramHelper final : public IDiagramHelper
|
class AdvancedDiagramHelper final : public IDiagramHelper
|
||||||
{
|
{
|
||||||
const std::shared_ptr< Diagram > mpDiagramPtr;
|
const std::shared_ptr< Diagram > mpDiagramPtr;
|
||||||
const std::shared_ptr<::oox::drawingml::Theme> mpThemePtr;
|
std::shared_ptr<::oox::drawingml::Theme> mpThemePtr;
|
||||||
|
|
||||||
css::awt::Size maImportSize;
|
css::awt::Size maImportSize;
|
||||||
|
|
||||||
@@ -73,6 +74,8 @@ public:
|
|||||||
virtual bool removeNode(const OUString& rNodeId) override;
|
virtual bool removeNode(const OUString& rNodeId) override;
|
||||||
|
|
||||||
void doAnchor(SdrObjGroup& rTarget);
|
void doAnchor(SdrObjGroup& rTarget);
|
||||||
|
std::shared_ptr< ::oox::drawingml::Theme > getOrCreateThemePtr(
|
||||||
|
rtl::Reference< oox::shape::ShapeFilterBase>& rxFilter ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -132,29 +132,6 @@ GraphicHelper* ShapeFilterBase::implCreateGraphicHelper() const
|
|||||||
return nColor;
|
return nColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeFilterBase::importTheme()
|
|
||||||
{
|
|
||||||
drawingml::ThemePtr pTheme = std::make_shared<drawingml::Theme>();
|
|
||||||
uno::Reference<beans::XPropertySet> xPropSet(getModel(), uno::UNO_QUERY_THROW);
|
|
||||||
uno::Sequence<beans::PropertyValue> aGrabBag;
|
|
||||||
xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
|
|
||||||
|
|
||||||
for (const auto& rProp : std::as_const(aGrabBag))
|
|
||||||
{
|
|
||||||
if (rProp.Name == "OOXTheme")
|
|
||||||
{
|
|
||||||
uno::Reference<xml::sax::XFastSAXSerializable> xDoc;
|
|
||||||
if (rProp.Value >>= xDoc)
|
|
||||||
{
|
|
||||||
rtl::Reference<core::FragmentHandler> xFragmentHandler(
|
|
||||||
new drawingml::ThemeFragmentHandler(*this, OUString(), *pTheme));
|
|
||||||
importFragment(xFragmentHandler, xDoc);
|
|
||||||
setCurrentTheme(pTheme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user