1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _COMPHELPER_CONTAINER_HXX_
25 #define _COMPHELPER_CONTAINER_HXX_
26 
27 #include <vector>
28 #include "com/sun/star/uno/Reference.hxx"
29 #include "comphelper/comphelperdllapi.h"
30 
31 //.........................................................................
32 namespace comphelper
33 {
34 //.........................................................................
35 
36 //========================================================================
37 //= IndexAccessIterator
38 //========================================================================
39 /** ein Iterator, der von einem XIndexAccess ausgehend alle Elemente durchiteriert (pre-order)
40 */
41 class COMPHELPER_DLLPUBLIC IndexAccessIterator
42 {
43 protected:
44 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>	m_xStartingPoint;
45 
46 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>	m_xCurrentObject;
47 		// das aktuelle Objekt
48 	::std::vector<sal_Int32>		m_arrChildIndizies;
49 		// ich bewege mich eigentlich durch einen Baum, dummerweise haben dessen
50 		// Elemente aber kein GetNextSibling, also muss ich mir merken, wo die Childs
51 		// innerhalb ihres Parents sitzen (das ist sozusagen der Pfad von der Wurzel
52 		// zu m_xCurrentObject
53 
54 	::rtl::OUString		m_ustrProperty;
55 		// der Name der gesuchten property
56 
57 public:
58 	IndexAccessIterator(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xStartingPoint);
59 
60     virtual ~IndexAccessIterator();
61 
62 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>	Next();
63 
Invalidate()64 	virtual void Invalidate() { m_xCurrentObject = NULL; }
65 
66 protected:
ShouldHandleElement(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> &)67 	virtual sal_Bool ShouldHandleElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& /*rElement*/) { return sal_True; }
68 		// damit kann man bestimmte Elemente ausschliessen, die werden dann einfach
69 		// uebergangen
70 		// wenn hier sal_True zurueckkommt, wird dieses Element von Next zurueckgeliefert, man kann sich hier also auch
71 		// gleich ein paar zusaetzliche Angaben zu dem Element holen (deswegen ist die Methode auch nicht const)
ShouldStepInto(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> &) const72 	virtual sal_Bool ShouldStepInto(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& /*xContainer*/) const { return sal_True; }
73 };
74 
75 //.........................................................................
76 }	// namespace comphelper
77 //.........................................................................
78 
79 #endif // _COMPHELPER_CONTAINER_HXX_
80 
81 
82