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 _HIERARCHYDATA_HXX
25 #define _HIERARCHYDATA_HXX
26 
27 #include <rtl/ustring.hxx>
28 #include <osl/mutex.hxx>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 
31 namespace com { namespace sun { namespace star {
32     namespace container {
33         class XHierarchicalNameAccess;
34     }
35     namespace util {
36         class XOfficeInstallationDirectories;
37     }
38 } } }
39 
40 namespace hierarchy_ucp
41 {
42 
43 //=========================================================================
44 
45 class HierarchyEntryData
46 {
47 public:
48     enum Type { NONE, LINK, FOLDER };
49 
HierarchyEntryData()50     HierarchyEntryData() : m_aType( NONE ) {}
HierarchyEntryData(const Type & rType)51     HierarchyEntryData( const Type & rType ) : m_aType( rType ) {}
52 
getName() const53     const rtl::OUString & getName() const { return m_aName; }
setName(const rtl::OUString & rName)54     void setName( const rtl::OUString & rName ) { m_aName = rName; }
55 
getTitle() const56     const rtl::OUString & getTitle() const { return m_aTitle; }
setTitle(const rtl::OUString & rTitle)57     void setTitle( const rtl::OUString & rTitle ) { m_aTitle = rTitle; }
58 
getTargetURL() const59     const rtl::OUString & getTargetURL() const { return m_aTargetURL; }
setTargetURL(const rtl::OUString & rURL)60     void setTargetURL( const rtl::OUString & rURL ) { m_aTargetURL = rURL; }
61 
getType() const62     Type getType() const
63     { return ( m_aType != NONE ) ? m_aType
64                                  : m_aTargetURL.getLength()
65                                     ? LINK
66                                     : FOLDER; }
setType(const Type & rType)67     void setType( const Type & rType ) { m_aType = rType; }
68 
69 private:
70     rtl::OUString m_aName;      // Name (language independent)
71     rtl::OUString m_aTitle;     // Title (language dependent)
72     rtl::OUString m_aTargetURL; // Target URL ( links only )
73     Type          m_aType;      // Type
74 };
75 
76 //=========================================================================
77 
78 class HierarchyContentProvider;
79 class HierarchyUri;
80 
81 class HierarchyEntry
82 {
83     ::rtl::OUString m_aServiceSpecifier;
84 	::rtl::OUString m_aName;
85 	::rtl::OUString m_aPath;
86 	::osl::Mutex 	m_aMutex;
87 	::com::sun::star::uno::Reference<
88 			::com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
89 	::com::sun::star::uno::Reference<
90 			::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
91 	::com::sun::star::uno::Reference<
92 			::com::sun::star::container::XHierarchicalNameAccess >
93 														   m_xRootReadAccess;
94     ::com::sun::star::uno::Reference<
95             ::com::sun::star::util::XOfficeInstallationDirectories >
96                                                            m_xOfficeInstDirs;
97 	sal_Bool m_bTriedToGetRootReadAccess;  // #82494#
98 
99 private:
100     ::rtl::OUString createPathFromHierarchyURL( const HierarchyUri & rURI );
101 	::com::sun::star::uno::Reference<
102 			::com::sun::star::container::XHierarchicalNameAccess >
103 	getRootReadAccess();
104 
105 public:
106 	HierarchyEntry( const ::com::sun::star::uno::Reference<
107 						::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
108 					HierarchyContentProvider* pProvider,
109 					const ::rtl::OUString& rURL );
110 
111 	sal_Bool hasData();
112 
113 	sal_Bool getData( HierarchyEntryData& rData );
114 
115 	sal_Bool setData( const HierarchyEntryData& rData, sal_Bool bCreate );
116 
117 	sal_Bool move( const ::rtl::OUString& rNewURL,
118 				   const HierarchyEntryData& rData );
119 
120 	sal_Bool remove();
121 
122 	// Iteration.
123 
124 	struct iterator_Impl;
125 
126 	class iterator
127 	{
128 	friend class HierarchyEntry;
129 
130 		iterator_Impl*  m_pImpl;
131 
132 	public:
133 		iterator();
134 		~iterator();
135 
136 		const HierarchyEntryData& operator*() const;
137 	};
138 
139 	sal_Bool first( iterator& it );
140 	sal_Bool next ( iterator& it );
141 };
142 
143 } // namespace hierarchy_ucp
144 
145 #endif /* !_HIERARCHYDATA_HXX */
146