Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchycontent.hxx
blob115721fa5ceb2a7eb03b40a7cf605268b0294636
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _HIERARCHYCONTENT_HXX
30 #define _HIERARCHYCONTENT_HXX
32 #include <list>
33 #include <rtl/ref.hxx>
34 #include <com/sun/star/ucb/XContentCreator.hpp>
35 #include <ucbhelper/contenthelper.hxx>
36 #include "hierarchydata.hxx"
37 #include "hierarchyprovider.hxx"
39 namespace com { namespace sun { namespace star { namespace beans {
40 struct Property;
41 struct PropertyValue;
42 } } } }
44 namespace com { namespace sun { namespace star { namespace sdbc {
45 class XRow;
46 } } } }
48 namespace com { namespace sun { namespace star { namespace ucb {
49 struct TransferInfo;
50 } } } }
52 namespace hierarchy_ucp
55 //=========================================================================
57 #define HIERARCHY_ROOT_FOLDER_CONTENT_SERVICE_NAME \
58 "com.sun.star.ucb.HierarchyRootFolderContent"
59 #define HIERARCHY_FOLDER_CONTENT_SERVICE_NAME \
60 "com.sun.star.ucb.HierarchyFolderContent"
61 #define HIERARCHY_LINK_CONTENT_SERVICE_NAME \
62 "com.sun.star.ucb.HierarchyLinkContent"
64 //=========================================================================
66 class HierarchyContentProperties
68 public:
69 HierarchyContentProperties() {};
71 HierarchyContentProperties( const HierarchyEntryData::Type & rType )
72 : m_aData( rType ),
73 m_aContentType( rType == HierarchyEntryData::FOLDER
74 ? rtl::OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
75 : rtl::OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
77 HierarchyContentProperties( const HierarchyEntryData & rData )
78 : m_aData( rData ),
79 m_aContentType( rData.getType() == HierarchyEntryData::FOLDER
80 ? rtl::OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
81 : rtl::OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
83 const rtl::OUString & getName() const { return m_aData.getName(); }
84 void setName( const rtl::OUString & rName ) { m_aData.setName( rName ); };
86 const rtl::OUString & getTitle() const { return m_aData.getTitle(); }
87 void setTitle( const rtl::OUString & rTitle )
88 { m_aData.setTitle( rTitle ); };
90 const rtl::OUString & getTargetURL() const
91 { return m_aData.getTargetURL(); }
92 void setTargetURL( const rtl::OUString & rURL )
93 { m_aData.setTargetURL( rURL ); };
95 const rtl::OUString & getContentType() const { return m_aContentType; }
97 sal_Bool getIsFolder() const
98 { return m_aData.getType() == HierarchyEntryData::FOLDER; }
100 sal_Bool getIsDocument() const { return !getIsFolder(); }
102 com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
103 getCreatableContentsInfo() const;
105 const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
107 private:
108 HierarchyEntryData m_aData;
109 rtl::OUString m_aContentType;
112 //=========================================================================
114 class HierarchyContentProvider;
116 class HierarchyContent : public ::ucbhelper::ContentImplHelper,
117 public com::sun::star::ucb::XContentCreator
119 enum ContentKind { LINK, FOLDER, ROOT };
120 enum ContentState { TRANSIENT, // created via CreateNewContent,
121 // but did not process "insert" yet
122 PERSISTENT, // processed "insert"
123 DEAD // processed "delete"
126 HierarchyContentProperties m_aProps;
127 ContentKind m_eKind;
128 ContentState m_eState;
129 HierarchyContentProvider* m_pProvider;
130 bool m_bCheckedReadOnly;
131 bool m_bIsReadOnly;
133 private:
134 HierarchyContent(
135 const com::sun::star::uno::Reference<
136 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
137 HierarchyContentProvider* pProvider,
138 const com::sun::star::uno::Reference<
139 com::sun::star::ucb::XContentIdentifier >& Identifier,
140 const HierarchyContentProperties& rProps );
141 HierarchyContent(
142 const com::sun::star::uno::Reference<
143 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
144 HierarchyContentProvider* pProvider,
145 const com::sun::star::uno::Reference<
146 com::sun::star::ucb::XContentIdentifier >& Identifier,
147 const com::sun::star::ucb::ContentInfo& Info );
149 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
150 getProperties( const com::sun::star::uno::Reference<
151 com::sun::star::ucb::XCommandEnvironment > & xEnv );
152 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
153 getCommands( const com::sun::star::uno::Reference<
154 com::sun::star::ucb::XCommandEnvironment > & xEnv );
155 virtual ::rtl::OUString getParentURL();
157 static sal_Bool hasData(
158 const com::sun::star::uno::Reference<
159 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
160 HierarchyContentProvider* pProvider,
161 const com::sun::star::uno::Reference<
162 com::sun::star::ucb::XContentIdentifier >& Identifier );
163 sal_Bool hasData(
164 const com::sun::star::uno::Reference<
165 com::sun::star::ucb::XContentIdentifier >& Identifier )
166 { return hasData( m_xSMgr, m_pProvider, Identifier ); }
167 static sal_Bool loadData(
168 const com::sun::star::uno::Reference<
169 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
170 HierarchyContentProvider* pProvider,
171 const com::sun::star::uno::Reference<
172 com::sun::star::ucb::XContentIdentifier >& Identifier,
173 HierarchyContentProperties& rProps );
174 sal_Bool storeData();
175 sal_Bool renameData( const com::sun::star::uno::Reference<
176 com::sun::star::ucb::XContentIdentifier >& xOldId,
177 const com::sun::star::uno::Reference<
178 com::sun::star::ucb::XContentIdentifier >& xNewId );
179 sal_Bool removeData();
181 void setKind( const com::sun::star::uno::Reference<
182 com::sun::star::ucb::XContentIdentifier >& Identifier );
184 bool isReadOnly();
186 sal_Bool isFolder() const { return ( m_eKind > LINK ); }
188 ::com::sun::star::uno::Reference<
189 ::com::sun::star::ucb::XContentIdentifier >
190 makeNewIdentifier( const rtl::OUString& rTitle );
192 typedef rtl::Reference< HierarchyContent > HierarchyContentRef;
193 typedef std::list< HierarchyContentRef > HierarchyContentRefList;
194 void queryChildren( HierarchyContentRefList& rChildren );
196 sal_Bool exchangeIdentity(
197 const ::com::sun::star::uno::Reference<
198 ::com::sun::star::ucb::XContentIdentifier >& xNewId );
200 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
201 getPropertyValues( const ::com::sun::star::uno::Sequence<
202 ::com::sun::star::beans::Property >& rProperties );
203 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
204 setPropertyValues(
205 const ::com::sun::star::uno::Sequence<
206 ::com::sun::star::beans::PropertyValue >& rValues,
207 const ::com::sun::star::uno::Reference<
208 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
209 throw( ::com::sun::star::uno::Exception );
211 void insert( sal_Int32 nNameClashResolve,
212 const ::com::sun::star::uno::Reference<
213 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
214 throw( ::com::sun::star::uno::Exception );
216 void destroy( sal_Bool bDeletePhysical,
217 const ::com::sun::star::uno::Reference<
218 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
219 throw( ::com::sun::star::uno::Exception );
221 void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo,
222 const ::com::sun::star::uno::Reference<
223 ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
224 throw( ::com::sun::star::uno::Exception );
226 public:
227 // Create existing content. Fail, if not already exists.
228 static HierarchyContent* create(
229 const com::sun::star::uno::Reference<
230 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
231 HierarchyContentProvider* pProvider,
232 const com::sun::star::uno::Reference<
233 com::sun::star::ucb::XContentIdentifier >& Identifier );
235 // Create new content. Fail, if already exists.
236 static HierarchyContent* create(
237 const com::sun::star::uno::Reference<
238 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
239 HierarchyContentProvider* pProvider,
240 const com::sun::star::uno::Reference<
241 com::sun::star::ucb::XContentIdentifier >& Identifier,
242 const com::sun::star::ucb::ContentInfo& Info );
244 virtual ~HierarchyContent();
246 // XInterface
247 XINTERFACE_DECL()
249 // XTypeProvider
250 XTYPEPROVIDER_DECL()
252 // XServiceInfo
253 virtual ::rtl::OUString SAL_CALL
254 getImplementationName()
255 throw( ::com::sun::star::uno::RuntimeException );
256 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
257 getSupportedServiceNames()
258 throw( ::com::sun::star::uno::RuntimeException );
260 // XContent
261 virtual rtl::OUString SAL_CALL
262 getContentType()
263 throw( com::sun::star::uno::RuntimeException );
264 virtual com::sun::star::uno::Reference<
265 com::sun::star::ucb::XContentIdentifier > SAL_CALL
266 getIdentifier()
267 throw( com::sun::star::uno::RuntimeException );
269 // XCommandProcessor
270 virtual com::sun::star::uno::Any SAL_CALL
271 execute( const com::sun::star::ucb::Command& aCommand,
272 sal_Int32 CommandId,
273 const com::sun::star::uno::Reference<
274 com::sun::star::ucb::XCommandEnvironment >& Environment )
275 throw( com::sun::star::uno::Exception,
276 com::sun::star::ucb::CommandAbortedException,
277 com::sun::star::uno::RuntimeException );
278 virtual void SAL_CALL
279 abort( sal_Int32 CommandId )
280 throw( com::sun::star::uno::RuntimeException );
282 //////////////////////////////////////////////////////////////////////
283 // Additional interfaces
284 //////////////////////////////////////////////////////////////////////
286 // XContentCreator
287 virtual com::sun::star::uno::Sequence<
288 com::sun::star::ucb::ContentInfo > SAL_CALL
289 queryCreatableContentsInfo()
290 throw( com::sun::star::uno::RuntimeException );
291 virtual com::sun::star::uno::Reference<
292 com::sun::star::ucb::XContent > SAL_CALL
293 createNewContent( const com::sun::star::ucb::ContentInfo& Info )
294 throw( com::sun::star::uno::RuntimeException );
296 //////////////////////////////////////////////////////////////////////
297 // Non-interface methods.
298 //////////////////////////////////////////////////////////////////////
300 static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
301 getPropertyValues( const ::com::sun::star::uno::Reference<
302 ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
303 const ::com::sun::star::uno::Sequence<
304 ::com::sun::star::beans::Property >& rProperties,
305 const HierarchyContentProperties& rData,
306 HierarchyContentProvider* pProvider,
307 const ::rtl::OUString& rContentId );
310 } // namespace hierarchy_ucp
312 #endif /* !_HIERARCHYCONTENT_HXX */
314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */