bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchycontent.hxx
blob12d60d9c87591a53d746cc202d509f73aca3d6b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYCONTENT_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYCONTENT_HXX
23 #include <list>
24 #include <rtl/ref.hxx>
25 #include <com/sun/star/ucb/XContentCreator.hpp>
26 #include <ucbhelper/contenthelper.hxx>
27 #include "hierarchydata.hxx"
28 #include "hierarchyprovider.hxx"
30 namespace com { namespace sun { namespace star { namespace beans {
31 struct Property;
32 struct PropertyValue;
33 } } } }
35 namespace com { namespace sun { namespace star { namespace sdbc {
36 class XRow;
37 } } } }
39 namespace com { namespace sun { namespace star { namespace ucb {
40 struct TransferInfo;
41 } } } }
43 namespace hierarchy_ucp
48 #define HIERARCHY_ROOT_FOLDER_CONTENT_SERVICE_NAME \
49 "com.sun.star.ucb.HierarchyRootFolderContent"
50 #define HIERARCHY_FOLDER_CONTENT_SERVICE_NAME \
51 "com.sun.star.ucb.HierarchyFolderContent"
52 #define HIERARCHY_LINK_CONTENT_SERVICE_NAME \
53 "com.sun.star.ucb.HierarchyLinkContent"
57 class HierarchyContentProperties
59 public:
60 HierarchyContentProperties() {};
62 HierarchyContentProperties( const HierarchyEntryData::Type & rType )
63 : m_aData( rType ),
64 m_aContentType( rType == HierarchyEntryData::FOLDER
65 ? OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
66 : OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
68 HierarchyContentProperties( const HierarchyEntryData & rData )
69 : m_aData( rData ),
70 m_aContentType( rData.getType() == HierarchyEntryData::FOLDER
71 ? OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
72 : OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
74 const OUString & getName() const { return m_aData.getName(); }
75 void setName( const OUString & rName ) { m_aData.setName( rName ); };
77 const OUString & getTitle() const { return m_aData.getTitle(); }
78 void setTitle( const OUString & rTitle )
79 { m_aData.setTitle( rTitle ); };
81 const OUString & getTargetURL() const
82 { return m_aData.getTargetURL(); }
83 void setTargetURL( const OUString & rURL )
84 { m_aData.setTargetURL( rURL ); };
86 const OUString & getContentType() const { return m_aContentType; }
88 bool getIsFolder() const
89 { return m_aData.getType() == HierarchyEntryData::FOLDER; }
91 bool getIsDocument() const { return !getIsFolder(); }
93 com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
94 getCreatableContentsInfo() const;
96 const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
98 private:
99 HierarchyEntryData m_aData;
100 OUString m_aContentType;
105 class HierarchyContentProvider;
107 class HierarchyContent : public ::ucbhelper::ContentImplHelper,
108 public com::sun::star::ucb::XContentCreator
110 enum ContentKind { LINK, FOLDER, ROOT };
111 enum ContentState { TRANSIENT, // created via CreateNewContent,
112 // but did not process "insert" yet
113 PERSISTENT, // processed "insert"
114 DEAD // processed "delete"
117 HierarchyContentProperties m_aProps;
118 ContentKind m_eKind;
119 ContentState m_eState;
120 HierarchyContentProvider* m_pProvider;
121 bool m_bCheckedReadOnly;
122 bool m_bIsReadOnly;
124 private:
125 HierarchyContent(
126 const com::sun::star::uno::Reference<
127 com::sun::star::uno::XComponentContext >& rxContext,
128 HierarchyContentProvider* pProvider,
129 const com::sun::star::uno::Reference<
130 com::sun::star::ucb::XContentIdentifier >& Identifier,
131 const HierarchyContentProperties& rProps );
132 HierarchyContent(
133 const com::sun::star::uno::Reference<
134 com::sun::star::uno::XComponentContext >& rxContext,
135 HierarchyContentProvider* pProvider,
136 const com::sun::star::uno::Reference<
137 com::sun::star::ucb::XContentIdentifier >& Identifier,
138 const com::sun::star::ucb::ContentInfo& Info );
140 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
141 getProperties( const com::sun::star::uno::Reference<
142 com::sun::star::ucb::XCommandEnvironment > & xEnv ) SAL_OVERRIDE;
143 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
144 getCommands( const com::sun::star::uno::Reference<
145 com::sun::star::ucb::XCommandEnvironment > & xEnv ) SAL_OVERRIDE;
146 virtual OUString getParentURL() SAL_OVERRIDE;
148 static bool hasData(
149 const com::sun::star::uno::Reference<
150 com::sun::star::uno::XComponentContext >& rxContext,
151 HierarchyContentProvider* pProvider,
152 const com::sun::star::uno::Reference<
153 com::sun::star::ucb::XContentIdentifier >& Identifier );
154 bool hasData(
155 const com::sun::star::uno::Reference<
156 com::sun::star::ucb::XContentIdentifier >& Identifier )
157 { return hasData( m_xContext, m_pProvider, Identifier ); }
158 static bool loadData(
159 const com::sun::star::uno::Reference<
160 com::sun::star::uno::XComponentContext >& rxContext,
161 HierarchyContentProvider* pProvider,
162 const com::sun::star::uno::Reference<
163 com::sun::star::ucb::XContentIdentifier >& Identifier,
164 HierarchyContentProperties& rProps );
165 bool storeData();
166 bool renameData( const com::sun::star::uno::Reference<
167 com::sun::star::ucb::XContentIdentifier >& xOldId,
168 const com::sun::star::uno::Reference<
169 com::sun::star::ucb::XContentIdentifier >& xNewId );
170 bool removeData();
172 void setKind( const com::sun::star::uno::Reference<
173 com::sun::star::ucb::XContentIdentifier >& Identifier );
175 bool isReadOnly();
177 bool isFolder() const { return ( m_eKind > LINK ); }
179 ::com::sun::star::uno::Reference<
180 ::com::sun::star::ucb::XContentIdentifier >
181 makeNewIdentifier( const OUString& rTitle );
183 typedef rtl::Reference< HierarchyContent > HierarchyContentRef;
184 typedef std::list< HierarchyContentRef > HierarchyContentRefList;
185 void queryChildren( HierarchyContentRefList& rChildren );
187 bool exchangeIdentity(
188 const ::com::sun::star::uno::Reference<
189 ::com::sun::star::ucb::XContentIdentifier >& xNewId );
191 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
192 getPropertyValues( const ::com::sun::star::uno::Sequence<
193 ::com::sun::star::beans::Property >& rProperties );
194 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
195 setPropertyValues(
196 const ::com::sun::star::uno::Sequence<
197 ::com::sun::star::beans::PropertyValue >& rValues,
198 const ::com::sun::star::uno::Reference<
199 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
200 throw( ::com::sun::star::uno::Exception );
202 void insert( sal_Int32 nNameClashResolve,
203 const ::com::sun::star::uno::Reference<
204 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
205 throw( ::com::sun::star::uno::Exception );
207 void destroy( bool bDeletePhysical,
208 const ::com::sun::star::uno::Reference<
209 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
210 throw( ::com::sun::star::uno::Exception );
212 void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo,
213 const ::com::sun::star::uno::Reference<
214 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
215 throw( ::com::sun::star::uno::Exception );
217 public:
218 // Create existing content. Fail, if not already exists.
219 static HierarchyContent* create(
220 const com::sun::star::uno::Reference<
221 com::sun::star::uno::XComponentContext >& rxContext,
222 HierarchyContentProvider* pProvider,
223 const com::sun::star::uno::Reference<
224 com::sun::star::ucb::XContentIdentifier >& Identifier );
226 // Create new content. Fail, if already exists.
227 static HierarchyContent* create(
228 const com::sun::star::uno::Reference<
229 com::sun::star::uno::XComponentContext >& rxContext,
230 HierarchyContentProvider* pProvider,
231 const com::sun::star::uno::Reference<
232 com::sun::star::ucb::XContentIdentifier >& Identifier,
233 const com::sun::star::ucb::ContentInfo& Info );
235 virtual ~HierarchyContent();
237 // XInterface
238 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
239 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
240 virtual void SAL_CALL acquire()
241 throw() SAL_OVERRIDE;
242 virtual void SAL_CALL release()
243 throw() SAL_OVERRIDE;
245 // XTypeProvider
246 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
247 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
248 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
249 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
251 // XServiceInfo
252 virtual OUString SAL_CALL
253 getImplementationName()
254 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
255 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
256 getSupportedServiceNames()
257 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
259 // XContent
260 virtual OUString SAL_CALL
261 getContentType()
262 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
263 virtual com::sun::star::uno::Reference<
264 com::sun::star::ucb::XContentIdentifier > SAL_CALL
265 getIdentifier()
266 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
268 // XCommandProcessor
269 virtual com::sun::star::uno::Any SAL_CALL
270 execute( const com::sun::star::ucb::Command& aCommand,
271 sal_Int32 CommandId,
272 const com::sun::star::uno::Reference<
273 com::sun::star::ucb::XCommandEnvironment >& Environment )
274 throw( com::sun::star::uno::Exception,
275 com::sun::star::ucb::CommandAbortedException,
276 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
277 virtual void SAL_CALL
278 abort( sal_Int32 CommandId )
279 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
282 // Additional interfaces
285 // XContentCreator
286 virtual com::sun::star::uno::Sequence<
287 com::sun::star::ucb::ContentInfo > SAL_CALL
288 queryCreatableContentsInfo()
289 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
290 virtual com::sun::star::uno::Reference<
291 com::sun::star::ucb::XContent > SAL_CALL
292 createNewContent( const com::sun::star::ucb::ContentInfo& Info )
293 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
296 // Non-interface methods.
299 static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
300 getPropertyValues( const ::com::sun::star::uno::Reference<
301 ::com::sun::star::uno::XComponentContext >& rxContext,
302 const ::com::sun::star::uno::Sequence<
303 ::com::sun::star::beans::Property >& rProperties,
304 const HierarchyContentProperties& rData,
305 HierarchyContentProvider* pProvider,
306 const OUString& rContentId );
309 } // namespace hierarchy_ucp
311 #endif // INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYCONTENT_HXX
313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */