diff options
-rw-r--r-- | include/oox/drawingml/diagram/diagram.hxx (renamed from oox/inc/drawingml/diagram/diagram.hxx) | 12 | ||||
-rw-r--r-- | include/oox/shape/ShapeFilterBase.hxx (renamed from oox/source/shape/ShapeFilterBase.hxx) | 17 | ||||
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 5 | ||||
-rw-r--r-- | oox/source/core/filterbase.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagram.cxx | 103 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramfragmenthandler.hxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/layoutnodecontext.cxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/graphicshapecontext.cxx | 2 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.hxx | 2 | ||||
-rw-r--r-- | oox/source/shape/ShapeFilterBase.cxx | 29 | ||||
-rw-r--r-- | sd/CppunitTest_sd_uimpress.mk | 1 | ||||
-rw-r--r-- | sd/Library_sd.mk | 1 | ||||
-rw-r--r-- | sd/inc/app.hrc | 1 | ||||
-rw-r--r-- | sd/sdi/_drvwsh.sdi | 5 | ||||
-rw-r--r-- | sd/sdi/sdraw.sdi | 17 | ||||
-rw-r--r-- | sd/source/ui/view/drviews3.cxx | 34 | ||||
-rw-r--r-- | solenv/clang-format/blacklist | 4 |
17 files changed, 226 insertions, 12 deletions
diff --git a/oox/inc/drawingml/diagram/diagram.hxx b/include/oox/drawingml/diagram/diagram.hxx index 73431815dadb..3db8d5f69fc1 100644 --- a/oox/inc/drawingml/diagram/diagram.hxx +++ b/include/oox/drawingml/diagram/diagram.hxx @@ -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 diff --git a/oox/source/shape/ShapeFilterBase.hxx b/include/oox/shape/ShapeFilterBase.hxx index 86297cda7011..1dc7653bd314 100644 --- a/oox/source/shape/ShapeFilterBase.hxx +++ b/include/oox/shape/ShapeFilterBase.hxx @@ -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; diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 7dfefa1bc10a..ee1f797e7a1d 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -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> diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index ea9fdcf47c0c..b79b0a569b69 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -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 ); } diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index e8e661e64d51..c3c28a84db23 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -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: */ diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.hxx b/oox/source/drawingml/diagram/diagramfragmenthandler.hxx index 80537f5f7eac..e0f0f3d9ae87 100644 --- a/oox/source/drawingml/diagram/diagramfragmenthandler.hxx +++ b/oox/source/drawingml/diagram/diagramfragmenthandler.hxx @@ -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 { diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx index 10070063c8ec..e984862c44b4 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.cxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx @@ -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" diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index 01b14237e9c9..527c43f9be3d 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -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> diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index 478aaa55b0c3..2de45f533637 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.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> diff --git a/oox/source/shape/ShapeFilterBase.cxx b/oox/source/shape/ShapeFilterBase.cxx index 6da4a5dfbe08..bde8cdca19c3 100644 --- a/oox/source/shape/ShapeFilterBase.cxx +++ b/oox/source/shape/ShapeFilterBase.cxx @@ -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); + } + } + } +} + } } diff --git a/sd/CppunitTest_sd_uimpress.mk b/sd/CppunitTest_sd_uimpress.mk index e483fb59a59c..3adb271e0907 100644 --- a/sd/CppunitTest_sd_uimpress.mk +++ b/sd/CppunitTest_sd_uimpress.mk @@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\ i18nlangtag \ i18nutil \ msfilter \ + oox \ sal \ sax \ salhelper \ diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index cf181c303a95..a38184c07673 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -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)) diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc index 8da621f7596f..73a974a5f93c 100644 --- a/sd/inc/app.hrc +++ b/sd/inc/app.hrc @@ -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: */ diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index e4793664eb82..93a30e6757dc 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -2789,5 +2789,10 @@ interface DrawView [ ExecMethod = FuTemporary ; ] + SID_REGENERATE_DIAGRAM + [ + ExecMethod = ExecCtrl ; + StateMethod = GetMenuState ; + ] } diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi index c9427f3f94fa..800081533fc0 100644 --- a/sd/sdi/sdraw.sdi +++ b/sd/sdi/sdraw.sdi @@ -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; +] diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 9c2e7d5f5c11..ba88762b4221 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -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; } diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index e70fa42bd831..338cf748285a 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -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 |