1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAMHELPER_HXX
21 #define INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAMHELPER_HXX
23 #include <rtl/ustring.hxx>
24 #include <oox/drawingml/theme.hxx>
25 #include <oox/shape/ShapeFilterBase.hxx>
26 #include <svx/svdogrp.hxx>
27 #include <svx/diagram/IDiagramHelper.hxx>
29 namespace svx
{ namespace diagram
{
30 class DiagramDataState
;
33 namespace oox::drawingml
{
37 // Advanced DiagramHelper
39 // This helper tries to hold all necessary data to re-layout
40 // all XShapes/SdrObjects of an already imported Diagram. The
41 // Diagram holds the SmarArt model data before it gets layouted,
42 // while Theme holds the oox Fill/Line/Style definitions to
44 // Re-Layouting (re-creating) is rather complex, for detailed
45 // information see ::reLayout implementation.
46 // This helper class may/should be extended to:
47 // - deliver representative data from the Diagram-Model
48 // - modify it eventually
49 // - im/export Diagram model to other representations
50 class AdvancedDiagramHelper final
: public svx::diagram::IDiagramHelper
52 const std::shared_ptr
< Diagram
> mpDiagramPtr
;
53 std::shared_ptr
<::oox::drawingml::Theme
> mpThemePtr
;
55 css::awt::Size maImportSize
;
57 bool hasDiagramData() const;
60 AdvancedDiagramHelper(
61 std::shared_ptr
< Diagram
> xDiagramPtr
,
62 std::shared_ptr
<::oox::drawingml::Theme
> xTheme
,
63 css::awt::Size aImportSize
,
65 virtual ~AdvancedDiagramHelper();
68 virtual void reLayout(SdrObjGroup
& rTarget
) override
;
70 // get text representation of data tree
71 virtual OUString
getString() const override
;
73 // get children of provided data node
74 // use empty string for top-level nodes
75 // returns vector of (id, text)
76 virtual std::vector
<std::pair
<OUString
, OUString
>> getChildren(const OUString
& rParentId
) const override
;
78 // add/remove new top-level node to data model, returns its id
79 virtual OUString
addNode(const OUString
& rText
) override
;
80 virtual bool removeNode(const OUString
& rNodeId
) override
;
82 // Undo/Redo helpers to extract/restore Diagram-defining data
83 virtual std::shared_ptr
< svx::diagram::DiagramDataState
> extractDiagramDataState() const override
;
84 virtual void applyDiagramDataState(const std::shared_ptr
< svx::diagram::DiagramDataState
>& rState
) override
;
86 void doAnchor(SdrObjGroup
& rTarget
, ::oox::drawingml::Shape
& rRootShape
);
87 const std::shared_ptr
< ::oox::drawingml::Theme
>& getOrCreateThemePtr(
88 rtl::Reference
< oox::shape::ShapeFilterBase
>& rxFilter
) const;
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */