/src/libreoffice/chart2/source/controller/inc/ObjectHierarchy.hxx
Line | Count | Source |
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 | | #pragma once |
20 | | |
21 | | #include <ChartModel.hxx> |
22 | | #include <ObjectIdentifier.hxx> |
23 | | #include <map> |
24 | | #include <vector> |
25 | | |
26 | | namespace com::sun::star::awt { struct KeyEvent; } |
27 | | |
28 | | namespace chart |
29 | | { |
30 | | |
31 | | class ChartView; |
32 | | |
33 | | class ObjectHierarchy |
34 | | { |
35 | | public: |
36 | | typedef std::vector< ObjectIdentifier > tChildContainer; |
37 | | |
38 | | /** @param bFlattenDiagram |
39 | | If <TRUE/>, the content of the diagram (data series, wall, floor, |
40 | | etc.) is treated as being at the same level as the diagram. (This is |
41 | | used for keyboard navigation). |
42 | | */ |
43 | | explicit ObjectHierarchy( |
44 | | const rtl::Reference<::chart::ChartModel> & xChartDocument, |
45 | | ChartView * pExplicitValueProvider, |
46 | | bool bFlattenDiagram = false, |
47 | | bool bOrderingForElementSelector = false ); |
48 | | ~ObjectHierarchy(); |
49 | | |
50 | | static ObjectIdentifier getRootNodeOID(); |
51 | | static bool isRootNode( const ObjectIdentifier& rOID ); |
52 | | |
53 | | /// equal to getChildren( getRootNodeOID()) |
54 | | const tChildContainer& getTopLevelChildren() const; |
55 | | bool hasChildren(const ObjectIdentifier& rParent) const; |
56 | | const tChildContainer& getChildren(const ObjectIdentifier& rParent) const; |
57 | | const tChildContainer& getSiblings(const ObjectIdentifier& rNode) const; |
58 | | |
59 | | /// The result is empty, if the node cannot be found in the tree |
60 | | ObjectIdentifier getParent( const ObjectIdentifier& rNode ) const; |
61 | | /// @returns -1, if no parent can be determined |
62 | | sal_Int32 getIndexInParent( const ObjectIdentifier& rNode ) const; |
63 | | |
64 | | private: |
65 | | void createTree( const rtl::Reference<::chart::ChartModel> & xChartDocument ); |
66 | | void createAxesTree( |
67 | | tChildContainer & rContainer, |
68 | | const rtl::Reference<::chart::ChartModel> & xChartDoc, |
69 | | const rtl::Reference< ::chart::Diagram > & xDiagram ); |
70 | | void createDiagramTree( |
71 | | tChildContainer& rContainer, |
72 | | const rtl::Reference<::chart::ChartModel>& xChartDoc, |
73 | | const rtl::Reference< ::chart::Diagram >& xDiagram ); |
74 | | void createDataSeriesTree( |
75 | | tChildContainer & rOutDiagramSubContainer, |
76 | | const rtl::Reference< ::chart::Diagram > & xDiagram ); |
77 | | static void createWallAndFloor( |
78 | | tChildContainer & rContainer, |
79 | | const rtl::Reference< ::chart::Diagram > & xDiagram ); |
80 | | void createLegendTree( |
81 | | tChildContainer & rContainer, |
82 | | const rtl::Reference<::chart::ChartModel> & xChartDoc, |
83 | | const rtl::Reference< ::chart::Diagram > & xDiagram ); |
84 | | void createAdditionalShapesTree(tChildContainer& rContainer); |
85 | | ObjectIdentifier getParentImpl( |
86 | | const ObjectIdentifier& rParentOID, |
87 | | const ObjectIdentifier& rOID ) const; |
88 | | |
89 | | typedef std::map<ObjectIdentifier, tChildContainer> tChildMap; |
90 | | tChildMap m_aChildMap; |
91 | | ChartView* m_pExplicitValueProvider; |
92 | | bool m_bFlattenDiagram; |
93 | | bool m_bOrderingForElementSelector; |
94 | | }; |
95 | | |
96 | | class ObjectKeyNavigation |
97 | | { |
98 | | public: |
99 | | explicit ObjectKeyNavigation( ObjectIdentifier aCurrentOID, |
100 | | rtl::Reference<::chart::ChartModel> xChartDocument, |
101 | | ChartView * pExplicitValueProvider ); |
102 | | |
103 | | bool handleKeyEvent( const css::awt::KeyEvent & rEvent ); |
104 | 0 | const ObjectIdentifier& getCurrentSelection() const { return m_aCurrentOID;} |
105 | | |
106 | | private: |
107 | | void setCurrentSelection( const ObjectIdentifier& rOID ); |
108 | | bool first(); |
109 | | bool last(); |
110 | | bool next(); |
111 | | bool previous(); |
112 | | bool up(); |
113 | | bool down(); |
114 | | bool veryFirst(); |
115 | | bool veryLast(); |
116 | | |
117 | | ObjectIdentifier m_aCurrentOID; |
118 | | rtl::Reference<::chart::ChartModel> m_xChartDocument; |
119 | | ChartView * m_pExplicitValueProvider; |
120 | | }; |
121 | | |
122 | | } // namespace chart |
123 | | |
124 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |