Line data Source code
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 : #ifndef CHART2_OBJECTHIERARCHY_HXX
20 : #define CHART2_OBJECTHIERARCHY_HXX
21 :
22 : #include "ObjectIdentifier.hxx"
23 :
24 : #include <rtl/ustring.hxx>
25 : #include <com/sun/star/chart2/XChartDocument.hpp>
26 : #include <com/sun/star/awt/KeyEvent.hpp>
27 :
28 : #include <memory>
29 : #include <vector>
30 :
31 : namespace chart
32 : {
33 :
34 : class ExplicitValueProvider;
35 :
36 : namespace impl
37 : {
38 : class ImplObjectHierarchy;
39 : }
40 :
41 : class ObjectHierarchy
42 : {
43 : public:
44 : typedef ObjectIdentifier tOID;
45 : typedef ::std::vector< tOID > tChildContainer;
46 :
47 : /** @param bFlattenDiagram
48 : If <TRUE/>, the content of the diaram (data series, wall, floor,
49 : etc.) is treated as being at the same level as the diagram. (This is
50 : used for keyboard navigation).
51 : */
52 : explicit ObjectHierarchy(
53 : const ::com::sun::star::uno::Reference<
54 : ::com::sun::star::chart2::XChartDocument > & xChartDocument,
55 : ExplicitValueProvider * pExplicitValueProvider = 0,
56 : bool bFlattenDiagram = false,
57 : bool bOrderingForElementSelector = false );
58 : ~ObjectHierarchy();
59 :
60 : static tOID getRootNodeOID();
61 : static bool isRootNode( const tOID& rOID );
62 :
63 : /// equal to getChildren( getRootNodeOID())
64 : tChildContainer getTopLevelChildren() const;
65 : bool hasChildren( const tOID& rParent ) const;
66 : tChildContainer getChildren( const tOID& rParent ) const;
67 :
68 : tChildContainer getSiblings( const tOID& rNode ) const;
69 :
70 : /// The result is empty, if the node cannot be found in the tree
71 : tOID getParent( const tOID& rNode ) const;
72 : /// @returns -1, if no parent can be determined
73 : sal_Int32 getIndexInParent( const tOID& rNode ) const;
74 :
75 : private:
76 :
77 : ::std::auto_ptr< impl::ImplObjectHierarchy > m_apImpl;
78 : };
79 :
80 0 : class ObjectKeyNavigation
81 : {
82 : public:
83 : explicit ObjectKeyNavigation( const ObjectHierarchy::tOID & rCurrentOID,
84 : const ::com::sun::star::uno::Reference<
85 : ::com::sun::star::chart2::XChartDocument > & xChartDocument,
86 : ExplicitValueProvider * pExplicitValueProvider = 0 );
87 :
88 : bool handleKeyEvent( const ::com::sun::star::awt::KeyEvent & rEvent );
89 : ObjectHierarchy::tOID getCurrentSelection() const;
90 :
91 : private:
92 : void setCurrentSelection( const ObjectHierarchy::tOID& rOID );
93 : bool first();
94 : bool last();
95 : bool next();
96 : bool previous();
97 : bool up();
98 : bool down();
99 : bool veryFirst();
100 : bool veryLast();
101 :
102 : ObjectHierarchy::tOID m_aCurrentOID;
103 : ::com::sun::star::uno::Reference<
104 : ::com::sun::star::chart2::XChartDocument > m_xChartDocument;
105 : ExplicitValueProvider * m_pExplicitValueProvider;
106 : bool m_bStepDownInDiagram;
107 : };
108 :
109 : } // namespace chart
110 :
111 : // CHART2_OBJECTHIERARCHY_HXX
112 : #endif
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|