SmartArt: regenerate diagram command
It removes diagram content and rebuilds shape tree from diagram markup. Diagram should appear unchanged - editing will be added in future commits. Change-Id: I6bfc21956a1a23e55d3c7a74384db71d957d690d Reviewed-on: https://gerrit.libreoffice.org/71584 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
committed by
Miklos Vajna
parent
afb566b6d3
commit
c61b75eede
@@ -24,6 +24,8 @@
|
||||
#include <oox/drawingml/shape.hxx>
|
||||
#include <oox/core/xmlfilterbase.hxx>
|
||||
|
||||
#include <com/sun/star/drawing/XShape.hpp>
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
#include <com/sun/star/xml/dom/XDocument.hpp>
|
||||
|
||||
namespace oox { namespace drawingml {
|
||||
@@ -42,6 +44,16 @@ void loadDiagram( ShapePtr const & pShape,
|
||||
const OUString& rColorStylePath,
|
||||
const oox::core::Relations& rRelations );
|
||||
|
||||
void loadDiagram(ShapePtr const& pShape,
|
||||
const css::uno::Reference<css::xml::dom::XDocument>& dataDom,
|
||||
const css::uno::Reference<css::xml::dom::XDocument>& layoutDom,
|
||||
const css::uno::Reference<css::xml::dom::XDocument>& styleDom,
|
||||
const css::uno::Reference<css::xml::dom::XDocument>& colorDom,
|
||||
core::XmlFilterBase& rFilter);
|
||||
|
||||
OOX_DLLPUBLIC void reloadDiagram(css::uno::Reference<css::drawing::XShape>& rXShape,
|
||||
core::XmlFilterBase& rFilter);
|
||||
|
||||
} }
|
||||
|
||||
#endif
|
@@ -17,20 +17,27 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_OOX_SOURCE_SHAPE_SHAPEFILTERBASE_HXX
|
||||
#define INCLUDED_OOX_SOURCE_SHAPE_SHAPEFILTERBASE_HXX
|
||||
#ifndef INCLUDED_OOX_SHAPE_SHAPEFILTERBASE_HXX
|
||||
#define INCLUDED_OOX_SHAPE_SHAPEFILTERBASE_HXX
|
||||
|
||||
#include <memory>
|
||||
#include <rtl/ref.hxx>
|
||||
#include <oox/dllapi.h>
|
||||
#include <oox/vml/vmldrawing.hxx>
|
||||
#include <drawingml/table/tablestylelist.hxx>
|
||||
#include <oox/core/xmlfilterbase.hxx>
|
||||
#include <oox/drawingml/drawingmltypes.hxx>
|
||||
|
||||
namespace oox { namespace drawingml { namespace table {
|
||||
|
||||
class TableStyleList;
|
||||
typedef std::shared_ptr< TableStyleList > TableStyleListPtr;
|
||||
|
||||
}}}
|
||||
|
||||
namespace oox {
|
||||
namespace shape {
|
||||
|
||||
class ShapeFilterBase : public core::XmlFilterBase
|
||||
class OOX_DLLPUBLIC ShapeFilterBase : public core::XmlFilterBase
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<ShapeFilterBase> Pointer_t;
|
||||
@@ -59,6 +66,8 @@ public:
|
||||
|
||||
::Color getSchemeColor( sal_Int32 nToken ) const;
|
||||
|
||||
void importTheme();
|
||||
|
||||
private:
|
||||
virtual ::oox::ole::VbaProject* implCreateVbaProject() const override;
|
||||
virtual OUString SAL_CALL getImplementationName() override;
|
@@ -7002,6 +7002,11 @@
|
||||
<value xml:lang="en-US">More Fields</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name=".uno:RegenerateDiagram" oor:op="replace">
|
||||
<prop oor:name="Label" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Regenerate Diagram</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</oor:component-data>
|
||||
|
@@ -334,6 +334,8 @@ StorageRef const & FilterBase::getStorage() const
|
||||
|
||||
Reference< XInputStream > FilterBase::openInputStream( const OUString& rStreamName ) const
|
||||
{
|
||||
if (!mxImpl->mxStorage)
|
||||
throw RuntimeException();
|
||||
return mxImpl->mxStorage->openInputStream( rStreamName );
|
||||
}
|
||||
|
||||
|
@@ -17,8 +17,12 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <oox/drawingml/diagram/diagram.hxx>
|
||||
#include "diagram.hxx"
|
||||
#include <com/sun/star/awt/Point.hpp>
|
||||
#include <com/sun/star/awt/Size.hpp>
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/drawing/XShapes.hpp>
|
||||
#include <com/sun/star/xml/dom/XDocument.hpp>
|
||||
#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
@@ -27,12 +31,12 @@
|
||||
#include <drawingml/textbody.hxx>
|
||||
#include <drawingml/textparagraph.hxx>
|
||||
#include <drawingml/textrun.hxx>
|
||||
#include <drawingml/diagram/diagram.hxx>
|
||||
#include <drawingml/fillproperties.hxx>
|
||||
#include <drawingml/customshapeproperties.hxx>
|
||||
#include <oox/ppt/pptshapegroupcontext.hxx>
|
||||
#include <oox/ppt/pptshape.hxx>
|
||||
#include <oox/token/namespaces.hxx>
|
||||
#include <basegfx/matrix/b2dhommatrix.hxx>
|
||||
|
||||
#include "diagramlayoutatoms.hxx"
|
||||
#include "layoutatomvisitors.hxx"
|
||||
@@ -544,6 +548,103 @@ void loadDiagram( ShapePtr const & pShape,
|
||||
pDiagram->addTo(pShape);
|
||||
}
|
||||
|
||||
void loadDiagram(ShapePtr const& pShape,
|
||||
const uno::Reference<xml::dom::XDocument>& dataDom,
|
||||
const uno::Reference<xml::dom::XDocument>& layoutDom,
|
||||
const uno::Reference<xml::dom::XDocument>& styleDom,
|
||||
const uno::Reference<xml::dom::XDocument>& colorDom,
|
||||
core::XmlFilterBase& rFilter)
|
||||
{
|
||||
DiagramPtr pDiagram(new Diagram);
|
||||
|
||||
DiagramDataPtr pData(new DiagramData());
|
||||
pDiagram->setData(pData);
|
||||
|
||||
DiagramLayoutPtr pLayout(new DiagramLayout(*pDiagram));
|
||||
pDiagram->setLayout(pLayout);
|
||||
|
||||
|
||||
// data
|
||||
if (dataDom.is())
|
||||
{
|
||||
rtl::Reference<core::FragmentHandler> xRefDataModel(
|
||||
new DiagramDataFragmentHandler(rFilter, OUString(), pData));
|
||||
|
||||
importFragment(rFilter, dataDom, "OOXData", pDiagram, xRefDataModel);
|
||||
}
|
||||
|
||||
// layout
|
||||
if (layoutDom.is())
|
||||
{
|
||||
rtl::Reference<core::FragmentHandler> xRefLayout(
|
||||
new DiagramLayoutFragmentHandler(rFilter, OUString(), pLayout));
|
||||
|
||||
importFragment(rFilter, layoutDom, "OOXLayout", pDiagram, xRefLayout);
|
||||
}
|
||||
|
||||
// style
|
||||
if (styleDom.is())
|
||||
{
|
||||
rtl::Reference<core::FragmentHandler> xRefQStyle(
|
||||
new DiagramQStylesFragmentHandler(rFilter, OUString(), pDiagram->getStyles()));
|
||||
|
||||
importFragment(rFilter, styleDom, "OOXStyle", pDiagram, xRefQStyle);
|
||||
}
|
||||
|
||||
// colors
|
||||
if (colorDom.is())
|
||||
{
|
||||
rtl::Reference<core::FragmentHandler> xRefColorStyle(
|
||||
new ColorFragmentHandler(rFilter, OUString(), pDiagram->getColors()));
|
||||
|
||||
importFragment(rFilter, colorDom, "OOXColor", pDiagram, xRefColorStyle);
|
||||
}
|
||||
|
||||
// diagram loaded. now lump together & attach to shape
|
||||
pDiagram->addTo(pShape);
|
||||
}
|
||||
|
||||
void reloadDiagram(css::uno::Reference<css::drawing::XShape>& rXShape,
|
||||
core::XmlFilterBase& rFilter)
|
||||
{
|
||||
uno::Reference<beans::XPropertySet> xPropSet(rXShape, uno::UNO_QUERY_THROW);
|
||||
|
||||
uno::Reference<xml::dom::XDocument> dataDom;
|
||||
uno::Reference<xml::dom::XDocument> layoutDom;
|
||||
uno::Reference<xml::dom::XDocument> styleDom;
|
||||
uno::Reference<xml::dom::XDocument> colorDom;
|
||||
|
||||
// retrieve the doms from the GrabBag
|
||||
uno::Sequence<beans::PropertyValue> propList;
|
||||
xPropSet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= propList;
|
||||
for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
|
||||
{
|
||||
OUString propName = propList[nProp].Name;
|
||||
if (propName == "OOXData")
|
||||
propList[nProp].Value >>= dataDom;
|
||||
else if (propName == "OOXLayout")
|
||||
propList[nProp].Value >>= layoutDom;
|
||||
else if (propName == "OOXStyle")
|
||||
propList[nProp].Value >>= styleDom;
|
||||
else if (propName == "OOXColor")
|
||||
propList[nProp].Value >>= colorDom;
|
||||
}
|
||||
|
||||
ShapePtr pShape(new Shape());
|
||||
pShape->setDiagramType();
|
||||
pShape->setSize(awt::Size(rXShape->getSize().Width * EMU_PER_HMM,
|
||||
rXShape->getSize().Height * EMU_PER_HMM));
|
||||
|
||||
loadDiagram(pShape, dataDom, layoutDom, styleDom, colorDom, rFilter);
|
||||
|
||||
uno::Reference<drawing::XShapes> xShapes(rXShape, uno::UNO_QUERY_THROW);
|
||||
basegfx::B2DHomMatrix aTransformation;
|
||||
aTransformation.translate(rXShape->getPosition().X * EMU_PER_HMM,
|
||||
rXShape->getPosition().Y * EMU_PER_HMM);
|
||||
for (auto const& child : pShape->getChildren())
|
||||
child->addShape(rFilter, rFilter.getCurrentTheme(), xShapes, aTransformation, pShape->getFillProperties());
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAMFRAGMENTHANDLER_HXX
|
||||
|
||||
#include <oox/core/fragmenthandler2.hxx>
|
||||
#include <drawingml/diagram/diagram.hxx>
|
||||
#include <oox/drawingml/diagram/diagram.hxx>
|
||||
|
||||
namespace oox { namespace drawingml {
|
||||
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "layoutnodecontext.hxx"
|
||||
|
||||
#include <oox/helper/attributelist.hxx>
|
||||
#include <drawingml/diagram/diagram.hxx>
|
||||
#include <oox/drawingml/shapecontext.hxx>
|
||||
#include <drawingml/customshapeproperties.hxx>
|
||||
#include "diagramdefinitioncontext.hxx"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <drawingml/misccontexts.hxx>
|
||||
#include <drawingml/graphicproperties.hxx>
|
||||
#include <drawingml/customshapeproperties.hxx>
|
||||
#include <drawingml/diagram/diagram.hxx>
|
||||
#include <oox/drawingml/diagram/diagram.hxx>
|
||||
#include <drawingml/table/tablecontext.hxx>
|
||||
#include <oox/core/xmlfilterbase.hxx>
|
||||
#include <oox/helper/attributelist.hxx>
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include <oox/drawingml/theme.hxx>
|
||||
#include <oox/core/fragmenthandler2.hxx>
|
||||
#include <oox/core/xmlfilterbase.hxx>
|
||||
#include "ShapeFilterBase.hxx"
|
||||
#include <oox/shape/ShapeFilterBase.hxx>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
|
||||
|
@@ -17,12 +17,16 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include "ShapeFilterBase.hxx"
|
||||
#include <oox/shape/ShapeFilterBase.hxx>
|
||||
#include <oox/drawingml/chart/chartconverter.hxx>
|
||||
#include <oox/drawingml/themefragmenthandler.hxx>
|
||||
#include <oox/helper/graphichelper.hxx>
|
||||
#include <oox/ole/vbaproject.hxx>
|
||||
#include <oox/drawingml/theme.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
|
||||
|
||||
namespace oox {
|
||||
namespace shape {
|
||||
|
||||
@@ -109,6 +113,29 @@ GraphicHelper* ShapeFilterBase::implCreateGraphicHelper() const
|
||||
return nColor;
|
||||
}
|
||||
|
||||
void ShapeFilterBase::importTheme()
|
||||
{
|
||||
drawingml::ThemePtr pTheme(new drawingml::Theme);
|
||||
uno::Reference<beans::XPropertySet> xPropSet(getModel(), uno::UNO_QUERY_THROW);
|
||||
uno::Sequence<beans::PropertyValue> aGrabBag;
|
||||
xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
|
||||
|
||||
for (int i = 0; i < aGrabBag.getLength(); i++)
|
||||
{
|
||||
if (aGrabBag[i].Name == "OOXTheme")
|
||||
{
|
||||
uno::Reference<xml::sax::XFastSAXSerializable> xDoc;
|
||||
if (aGrabBag[i].Value >>= xDoc)
|
||||
{
|
||||
rtl::Reference<core::FragmentHandler> xFragmentHandler(
|
||||
new drawingml::ThemeFragmentHandler(*this, OUString(), *pTheme));
|
||||
importFragment(xFragmentHandler, xDoc);
|
||||
setCurrentTheme(pTheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\
|
||||
i18nlangtag \
|
||||
i18nutil \
|
||||
msfilter \
|
||||
oox \
|
||||
sal \
|
||||
sax \
|
||||
salhelper \
|
||||
|
@@ -61,6 +61,7 @@ endif
|
||||
|
||||
$(eval $(call gb_Library_use_custom_headers,sd,\
|
||||
officecfg/registry \
|
||||
oox/generated \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_use_sdk_api,sd))
|
||||
|
@@ -460,6 +460,7 @@
|
||||
#define SID_HIDE_LAST_LEVEL (SID_SD_START+448)
|
||||
#define SID_SHOW_NEXT_LEVEL (SID_SD_START+449)
|
||||
#define SID_PRESENTATION_MINIMIZER (SID_SD_START+450)
|
||||
#define SID_REGENERATE_DIAGRAM (SID_SD_START+451)
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -2789,5 +2789,10 @@ interface DrawView
|
||||
[
|
||||
ExecMethod = FuTemporary ;
|
||||
]
|
||||
SID_REGENERATE_DIAGRAM
|
||||
[
|
||||
ExecMethod = ExecCtrl ;
|
||||
StateMethod = GetMenuState ;
|
||||
]
|
||||
|
||||
}
|
||||
|
@@ -4631,3 +4631,20 @@ SfxVoidItem MovePageLast SID_MOVE_PAGE_LAST
|
||||
ToolBoxConfig = TRUE,
|
||||
GroupId = SfxGroupId::Modify;
|
||||
]
|
||||
|
||||
SfxVoidItem RegenerateDiagram SID_REGENERATE_DIAGRAM
|
||||
()
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
ReadOnlyDoc = FALSE,
|
||||
Toggle = FALSE,
|
||||
Container = FALSE,
|
||||
RecordAbsolute = FALSE,
|
||||
RecordPerSet;
|
||||
|
||||
AccelConfig = TRUE,
|
||||
MenuConfig = TRUE,
|
||||
ToolBoxConfig = TRUE,
|
||||
GroupId = SfxGroupId::Modify;
|
||||
]
|
||||
|
@@ -82,10 +82,15 @@
|
||||
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
|
||||
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
|
||||
#include <com/sun/star/drawing/framework/XConfiguration.hpp>
|
||||
#include <com/sun/star/drawing/XShape.hpp>
|
||||
#include <com/sun/star/frame/XFrame.hpp>
|
||||
#include <editeng/lspcitem.hxx>
|
||||
#include <editeng/ulspitem.hxx>
|
||||
#include <memory>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <oox/drawingml/diagram/diagram.hxx>
|
||||
#include <oox/export/drawingml.hxx>
|
||||
#include <oox/shape/ShapeFilterBase.hxx>
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::drawing::framework;
|
||||
@@ -472,6 +477,35 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq)
|
||||
}
|
||||
break;
|
||||
|
||||
case SID_REGENERATE_DIAGRAM:
|
||||
{
|
||||
const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
|
||||
if (rMarkList.GetMarkCount() == 1)
|
||||
{
|
||||
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
|
||||
Reference<css::drawing::XShape> xShape(pObj->getUnoShape(), UNO_QUERY);
|
||||
|
||||
if (oox::drawingml::DrawingML::IsDiagram(xShape))
|
||||
{
|
||||
mpDrawView->UnmarkAll();
|
||||
pObj->getChildrenOfSdrObject()->ClearSdrObjList();
|
||||
|
||||
css::uno::Reference<css::uno::XComponentContext> xContext
|
||||
= comphelper::getProcessComponentContext();
|
||||
rtl::Reference<oox::shape::ShapeFilterBase> xFilter(
|
||||
new oox::shape::ShapeFilterBase(xContext));
|
||||
xFilter->setTargetDocument(GetDocSh()->GetModel());
|
||||
xFilter->importTheme();
|
||||
oox::drawingml::reloadDiagram(xShape, *xFilter);
|
||||
|
||||
mpDrawView->MarkObj(pObj, mpDrawView->GetSdrPageView());
|
||||
}
|
||||
}
|
||||
|
||||
rReq.Done();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -6462,6 +6462,7 @@ include/oox/drawingml/chart/modelbase.hxx
|
||||
include/oox/drawingml/clrscheme.hxx
|
||||
include/oox/drawingml/color.hxx
|
||||
include/oox/drawingml/connectorshapecontext.hxx
|
||||
include/oox/drawingml/diagram/diagram.hxx
|
||||
include/oox/drawingml/drawingmltypes.hxx
|
||||
include/oox/drawingml/graphicshapecontext.hxx
|
||||
include/oox/drawingml/shape.hxx
|
||||
@@ -6538,6 +6539,7 @@ include/oox/ppt/slidetransitioncontext.hxx
|
||||
include/oox/ppt/soundactioncontext.hxx
|
||||
include/oox/ppt/timenode.hxx
|
||||
include/oox/ppt/timenodelistcontext.hxx
|
||||
include/oox/shape/ShapeFilterBase.hxx
|
||||
include/oox/token/namespacemap.hxx
|
||||
include/oox/token/propertynames.hxx
|
||||
include/oox/token/relationship.hxx
|
||||
@@ -8825,7 +8827,6 @@ oox/inc/drawingml/clrschemecontext.hxx
|
||||
oox/inc/drawingml/colorchoicecontext.hxx
|
||||
oox/inc/drawingml/customshapegeometry.hxx
|
||||
oox/inc/drawingml/customshapeproperties.hxx
|
||||
oox/inc/drawingml/diagram/diagram.hxx
|
||||
oox/inc/drawingml/embeddedwavaudiofile.hxx
|
||||
oox/inc/drawingml/fillproperties.hxx
|
||||
oox/inc/drawingml/graphicproperties.hxx
|
||||
@@ -9105,7 +9106,6 @@ oox/source/shape/ShapeContextHandler.hxx
|
||||
oox/source/shape/ShapeDrawingFragmentHandler.cxx
|
||||
oox/source/shape/ShapeDrawingFragmentHandler.hxx
|
||||
oox/source/shape/ShapeFilterBase.cxx
|
||||
oox/source/shape/ShapeFilterBase.hxx
|
||||
oox/source/shape/WpgContext.cxx
|
||||
oox/source/shape/WpgContext.hxx
|
||||
oox/source/token/namespacemap.cxx
|
||||
|
Reference in New Issue
Block a user