1*6df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6df1ea1fSAndrew Rist  * distributed with this work for additional information
6*6df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*6df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6df1ea1fSAndrew Rist  *
11*6df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6df1ea1fSAndrew Rist  *
13*6df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
15*6df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*6df1ea1fSAndrew Rist  * specific language governing permissions and limitations
18*6df1ea1fSAndrew Rist  * under the License.
19*6df1ea1fSAndrew Rist  *
20*6df1ea1fSAndrew Rist  *************************************************************/
21*6df1ea1fSAndrew Rist 
22*6df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _HIERARCHYDATA_HXX
25cdf0e10cSrcweir #define _HIERARCHYDATA_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <osl/mutex.hxx>
29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace com { namespace sun { namespace star {
32cdf0e10cSrcweir     namespace container {
33cdf0e10cSrcweir         class XHierarchicalNameAccess;
34cdf0e10cSrcweir     }
35cdf0e10cSrcweir     namespace util {
36cdf0e10cSrcweir         class XOfficeInstallationDirectories;
37cdf0e10cSrcweir     }
38cdf0e10cSrcweir } } }
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace hierarchy_ucp
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //=========================================================================
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class HierarchyEntryData
46cdf0e10cSrcweir {
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir     enum Type { NONE, LINK, FOLDER };
49cdf0e10cSrcweir 
HierarchyEntryData()50cdf0e10cSrcweir     HierarchyEntryData() : m_aType( NONE ) {}
HierarchyEntryData(const Type & rType)51cdf0e10cSrcweir     HierarchyEntryData( const Type & rType ) : m_aType( rType ) {}
52cdf0e10cSrcweir 
getName() const53cdf0e10cSrcweir     const rtl::OUString & getName() const { return m_aName; }
setName(const rtl::OUString & rName)54cdf0e10cSrcweir     void setName( const rtl::OUString & rName ) { m_aName = rName; }
55cdf0e10cSrcweir 
getTitle() const56cdf0e10cSrcweir     const rtl::OUString & getTitle() const { return m_aTitle; }
setTitle(const rtl::OUString & rTitle)57cdf0e10cSrcweir     void setTitle( const rtl::OUString & rTitle ) { m_aTitle = rTitle; }
58cdf0e10cSrcweir 
getTargetURL() const59cdf0e10cSrcweir     const rtl::OUString & getTargetURL() const { return m_aTargetURL; }
setTargetURL(const rtl::OUString & rURL)60cdf0e10cSrcweir     void setTargetURL( const rtl::OUString & rURL ) { m_aTargetURL = rURL; }
61cdf0e10cSrcweir 
getType() const62cdf0e10cSrcweir     Type getType() const
63cdf0e10cSrcweir     { return ( m_aType != NONE ) ? m_aType
64cdf0e10cSrcweir                                  : m_aTargetURL.getLength()
65cdf0e10cSrcweir                                     ? LINK
66cdf0e10cSrcweir                                     : FOLDER; }
setType(const Type & rType)67cdf0e10cSrcweir     void setType( const Type & rType ) { m_aType = rType; }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir private:
70cdf0e10cSrcweir     rtl::OUString m_aName;      // Name (language independent)
71cdf0e10cSrcweir     rtl::OUString m_aTitle;     // Title (language dependent)
72cdf0e10cSrcweir     rtl::OUString m_aTargetURL; // Target URL ( links only )
73cdf0e10cSrcweir     Type          m_aType;      // Type
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //=========================================================================
77cdf0e10cSrcweir 
78cdf0e10cSrcweir class HierarchyContentProvider;
79cdf0e10cSrcweir class HierarchyUri;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir class HierarchyEntry
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     ::rtl::OUString m_aServiceSpecifier;
84cdf0e10cSrcweir 	::rtl::OUString m_aName;
85cdf0e10cSrcweir 	::rtl::OUString m_aPath;
86cdf0e10cSrcweir 	::osl::Mutex 	m_aMutex;
87cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
88cdf0e10cSrcweir 			::com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
89cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
90cdf0e10cSrcweir 			::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
91cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
92cdf0e10cSrcweir 			::com::sun::star::container::XHierarchicalNameAccess >
93cdf0e10cSrcweir 														   m_xRootReadAccess;
94cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
95cdf0e10cSrcweir             ::com::sun::star::util::XOfficeInstallationDirectories >
96cdf0e10cSrcweir                                                            m_xOfficeInstDirs;
97cdf0e10cSrcweir 	sal_Bool m_bTriedToGetRootReadAccess;  // #82494#
98cdf0e10cSrcweir 
99cdf0e10cSrcweir private:
100cdf0e10cSrcweir     ::rtl::OUString createPathFromHierarchyURL( const HierarchyUri & rURI );
101cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
102cdf0e10cSrcweir 			::com::sun::star::container::XHierarchicalNameAccess >
103cdf0e10cSrcweir 	getRootReadAccess();
104cdf0e10cSrcweir 
105cdf0e10cSrcweir public:
106cdf0e10cSrcweir 	HierarchyEntry( const ::com::sun::star::uno::Reference<
107cdf0e10cSrcweir 						::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
108cdf0e10cSrcweir 					HierarchyContentProvider* pProvider,
109cdf0e10cSrcweir 					const ::rtl::OUString& rURL );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	sal_Bool hasData();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	sal_Bool getData( HierarchyEntryData& rData );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	sal_Bool setData( const HierarchyEntryData& rData, sal_Bool bCreate );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	sal_Bool move( const ::rtl::OUString& rNewURL,
118cdf0e10cSrcweir 				   const HierarchyEntryData& rData );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	sal_Bool remove();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	// Iteration.
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	struct iterator_Impl;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	class iterator
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 	friend class HierarchyEntry;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 		iterator_Impl*  m_pImpl;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	public:
133cdf0e10cSrcweir 		iterator();
134cdf0e10cSrcweir 		~iterator();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		const HierarchyEntryData& operator*() const;
137cdf0e10cSrcweir 	};
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	sal_Bool first( iterator& it );
140cdf0e10cSrcweir 	sal_Bool next ( iterator& it );
141cdf0e10cSrcweir };
142cdf0e10cSrcweir 
143cdf0e10cSrcweir } // namespace hierarchy_ucp
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #endif /* !_HIERARCHYDATA_HXX */
146