/src/libreoffice/include/svx/diagram/IDiagramHelper.hxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <vector> |
23 | | #include <svx/svxdllapi.h> |
24 | | #include <rtl/ustring.hxx> |
25 | | #include <svx/svdhdl.hxx> |
26 | | |
27 | | // Forward declarations |
28 | | class SdrObjGroup; |
29 | | |
30 | | namespace svx { namespace diagram { |
31 | | |
32 | | // Helper class to visualize an imminently recognizable |
33 | | // additional visualization for DynamicDiagrams that can also |
34 | | // be used to show/hide the DiagramDialog by the user |
35 | | // Note: is also used as additional drag/move handle |
36 | | class SVXCORE_DLLPUBLIC DiagramFrameHdl final : public SdrHdl |
37 | | { |
38 | | // object dimensions |
39 | | basegfx::B2DHomMatrix maTransformation; |
40 | | |
41 | | // create marker for this kind |
42 | | virtual void CreateB2dIAObject() override; |
43 | | |
44 | | public: |
45 | | DiagramFrameHdl(const basegfx::B2DHomMatrix& rTransformation); |
46 | | |
47 | | static void clicked(const Point& rPnt); |
48 | | }; |
49 | | |
50 | | class DiagramDataState; |
51 | | |
52 | | // Helper class to allow administer advanced Diagram related |
53 | | // data and functionality |
54 | | class SVXCORE_DLLPUBLIC IDiagramHelper |
55 | | { |
56 | | private: |
57 | | // These values define behaviour to where take data from at re-creation time. |
58 | | // Different definitions will have different consequences for re-creation |
59 | | // of Diagram visualization (if needed/triggered). |
60 | | // The style attributes per shape e.g. can be re-stored frm either an |
61 | | // existing Theme, or the preserved key/value list of properties per XShape. |
62 | | // With the current default settings the re-creation uses the preserved |
63 | | // key/value pairs, but re-creation from Theme may also be desirable. It |
64 | | // is also good to preserve both data packages at initial import to allow |
65 | | // alternatively one of these two methods for re-construction |
66 | | |
67 | | // If true, the oox::Theme data from ::DiagramData get/set/ThemeDocument() |
68 | | // aka mxThemeDocument - if it exists - will be used to create the style |
69 | | // attributes for the to-be-created XShapes (theoretically allows re-creation |
70 | | // with other Theme) |
71 | | bool mbUseDiagramThemeData; // false |
72 | | |
73 | | // If true, the UNO API form of attributes per Point as Key/value list |
74 | | // that was secured after initial XShape creation is used to create the |
75 | | // style attributes for the to-be-created XShapes |
76 | | bool mbUseDiagramModelData; // true |
77 | | |
78 | | // If true and mxThemeDocument exists it will be re-imported to |
79 | | // a newly created oox::drawingml::Theme object |
80 | | bool mbForceThemePtrRecreation; // false |
81 | | |
82 | | // if true, content was self-created using addTo/addShape |
83 | | // and the layouting stuff |
84 | | bool mbSelfCreated; |
85 | | |
86 | | protected: |
87 | | void anchorToSdrObjGroup(SdrObjGroup& rTarget); |
88 | | |
89 | | public: |
90 | | IDiagramHelper(bool bSelfCreated); |
91 | | virtual ~IDiagramHelper(); |
92 | | |
93 | | // re-create XShapes |
94 | | virtual void reLayout(SdrObjGroup& rTarget) = 0; |
95 | | |
96 | | // get text representation of data tree |
97 | | virtual OUString getString() const = 0; |
98 | | |
99 | | // get children of provided data node |
100 | | // use empty string for top-level nodes |
101 | | // returns vector of (id, text) |
102 | | virtual std::vector<std::pair<OUString, OUString>> |
103 | | getChildren(const OUString& rParentId) const = 0; |
104 | | |
105 | | // add/remove new top-level node to data model, returns its id |
106 | | virtual OUString addNode(const OUString& rText) = 0; |
107 | | virtual bool removeNode(const OUString& rNodeId) = 0; |
108 | | |
109 | | // Undo/Redo helpers for extracting/restoring Diagram-defining data |
110 | | virtual std::shared_ptr<svx::diagram::DiagramDataState> extractDiagramDataState() const = 0; |
111 | | virtual void applyDiagramDataState(const std::shared_ptr<svx::diagram::DiagramDataState>& rState) = 0; |
112 | | |
113 | 0 | bool UseDiagramThemeData() const { return mbUseDiagramThemeData; } |
114 | 0 | bool UseDiagramModelData() const { return mbUseDiagramModelData; } |
115 | 0 | bool ForceThemePtrRecreation() const { return mbForceThemePtrRecreation; }; |
116 | | |
117 | | // get/set SelfCreated flag |
118 | 0 | bool isSelfCreated() const { return mbSelfCreated; } |
119 | 0 | void setSelfCreated() { mbSelfCreated = true; } |
120 | | |
121 | | static void AddAdditionalVisualization(const SdrObjGroup& rTarget, SdrHdlList& rHdlList); |
122 | | }; |
123 | | |
124 | | }} // end of namespace |
125 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |