xref: /AOO41X/main/chart2/source/controller/inc/ObjectHierarchy.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef CHART2_OBJECTHIERARCHY_HXX
28 #define CHART2_OBJECTHIERARCHY_HXX
29 
30 #include "ObjectIdentifier.hxx"
31 
32 #include <rtl/ustring.hxx>
33 #include <com/sun/star/chart2/XChartDocument.hpp>
34 #include <com/sun/star/awt/KeyEvent.hpp>
35 
36 #include <memory>
37 #include <vector>
38 
39 namespace chart
40 {
41 
42 class ExplicitValueProvider;
43 
44 namespace impl
45 {
46 class ImplObjectHierarchy;
47 }
48 
49 class ObjectHierarchy
50 {
51 public:
52     typedef ObjectIdentifier tOID;
53     typedef ::std::vector< tOID > tChildContainer;
54 
55     /** @param bFlattenDiagram
56             If <TRUE/>, the content of the diaram (data series, wall, floor,
57             etc.) is treated as being at the same level as the diagram. (This is
58             used for keyboard navigation).
59      */
60     explicit ObjectHierarchy(
61         const ::com::sun::star::uno::Reference<
62             ::com::sun::star::chart2::XChartDocument > & xChartDocument,
63         ExplicitValueProvider * pExplicitValueProvider = 0,
64         bool bFlattenDiagram = false,
65         bool bOrderingForElementSelector = false );
66     ~ObjectHierarchy();
67 
68     static tOID      getRootNodeOID();
69     static bool      isRootNode( const tOID& rOID );
70 
71     /// equal to getChildren( getRootNodeOID())
72     tChildContainer  getTopLevelChildren() const;
73     bool             hasChildren( const tOID& rParent ) const;
74     tChildContainer  getChildren( const tOID& rParent ) const;
75 
76     tChildContainer  getSiblings( const tOID& rNode ) const;
77 
78     /// The result is empty, if the node cannot be found in the tree
79     tOID             getParent( const tOID& rNode ) const;
80     /// @returns -1, if no parent can be determined
81     sal_Int32        getIndexInParent( const tOID& rNode ) const;
82 
83 private:
84 
85     ::std::auto_ptr< impl::ImplObjectHierarchy > m_apImpl;
86 };
87 
88 class ObjectKeyNavigation
89 {
90 public:
91     explicit ObjectKeyNavigation( const ObjectHierarchy::tOID & rCurrentOID,
92                                   const ::com::sun::star::uno::Reference<
93                                       ::com::sun::star::chart2::XChartDocument > & xChartDocument,
94                                   ExplicitValueProvider * pExplicitValueProvider = 0 );
95 
96     bool handleKeyEvent( const ::com::sun::star::awt::KeyEvent & rEvent );
97     ObjectHierarchy::tOID getCurrentSelection() const;
98 
99 private:
100     void setCurrentSelection( const ObjectHierarchy::tOID& rOID );
101     bool first();
102     bool last();
103     bool next();
104     bool previous();
105     bool up();
106     bool down();
107     bool veryFirst();
108     bool veryLast();
109 
110     ObjectHierarchy::tOID m_aCurrentOID;
111     ::com::sun::star::uno::Reference<
112             ::com::sun::star::chart2::XChartDocument > m_xChartDocument;
113     ExplicitValueProvider * m_pExplicitValueProvider;
114     bool m_bStepDownInDiagram;
115 };
116 
117 } //  namespace chart
118 
119 // CHART2_OBJECTHIERARCHY_HXX
120 #endif
121