Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _HIERARCHYCONTENT_HXX
30 : : #define _HIERARCHYCONTENT_HXX
31 : :
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"
38 : :
39 : : namespace com { namespace sun { namespace star { namespace beans {
40 : : struct Property;
41 : : struct PropertyValue;
42 : : } } } }
43 : :
44 : : namespace com { namespace sun { namespace star { namespace sdbc {
45 : : class XRow;
46 : : } } } }
47 : :
48 : : namespace com { namespace sun { namespace star { namespace ucb {
49 : : struct TransferInfo;
50 : : } } } }
51 : :
52 : : namespace hierarchy_ucp
53 : : {
54 : :
55 : : //=========================================================================
56 : :
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"
63 : :
64 : : //=========================================================================
65 : :
66 : 150 : class HierarchyContentProperties
67 : : {
68 : : public:
69 : 54 : HierarchyContentProperties() {};
70 : :
71 : 34 : HierarchyContentProperties( const HierarchyEntryData::Type & rType )
72 : : : m_aData( rType ),
73 : : m_aContentType( rType == HierarchyEntryData::FOLDER
74 : : ? rtl::OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
75 [ + + ][ + + ]: 34 : : rtl::OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
[ + + ]
76 : :
77 : 32 : HierarchyContentProperties( const HierarchyEntryData & rData )
78 : : : m_aData( rData ),
79 : 32 : m_aContentType( rData.getType() == HierarchyEntryData::FOLDER
80 : : ? rtl::OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
81 [ + + ][ + + ]: 64 : : rtl::OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
[ + + ]
82 : :
83 : 30 : const rtl::OUString & getName() const { return m_aData.getName(); }
84 : 30 : void setName( const rtl::OUString & rName ) { m_aData.setName( rName ); };
85 : :
86 : 146 : const rtl::OUString & getTitle() const { return m_aData.getTitle(); }
87 : 30 : void setTitle( const rtl::OUString & rTitle )
88 : 30 : { m_aData.setTitle( rTitle ); };
89 : :
90 : 60 : const rtl::OUString & getTargetURL() const
91 : 60 : { return m_aData.getTargetURL(); }
92 : 20 : void setTargetURL( const rtl::OUString & rURL )
93 : 20 : { m_aData.setTargetURL( rURL ); };
94 : :
95 : 0 : const rtl::OUString & getContentType() const { return m_aContentType; }
96 : :
97 : 60 : sal_Bool getIsFolder() const
98 : 60 : { return m_aData.getType() == HierarchyEntryData::FOLDER; }
99 : :
100 : 20 : sal_Bool getIsDocument() const { return !getIsFolder(); }
101 : :
102 : : com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
103 : : getCreatableContentsInfo() const;
104 : :
105 : 36 : const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
106 : :
107 : : private:
108 : : HierarchyEntryData m_aData;
109 : : rtl::OUString m_aContentType;
110 : : };
111 : :
112 : : //=========================================================================
113 : :
114 : : class HierarchyContentProvider;
115 : :
116 : : class HierarchyContent : public ::ucbhelper::ContentImplHelper,
117 : : public com::sun::star::ucb::XContentCreator
118 : : {
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"
124 : : };
125 : :
126 : : HierarchyContentProperties m_aProps;
127 : : ContentKind m_eKind;
128 : : ContentState m_eState;
129 : : HierarchyContentProvider* m_pProvider;
130 : : bool m_bCheckedReadOnly;
131 : : bool m_bIsReadOnly;
132 : :
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 );
148 : :
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();
156 : :
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 : 30 : sal_Bool hasData(
164 : : const com::sun::star::uno::Reference<
165 : : com::sun::star::ucb::XContentIdentifier >& Identifier )
166 : 30 : { 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();
180 : :
181 : : void setKind( const com::sun::star::uno::Reference<
182 : : com::sun::star::ucb::XContentIdentifier >& Identifier );
183 : :
184 : : bool isReadOnly();
185 : :
186 : 70 : sal_Bool isFolder() const { return ( m_eKind > LINK ); }
187 : :
188 : : ::com::sun::star::uno::Reference<
189 : : ::com::sun::star::ucb::XContentIdentifier >
190 : : makeNewIdentifier( const rtl::OUString& rTitle );
191 : :
192 : : typedef rtl::Reference< HierarchyContent > HierarchyContentRef;
193 : : typedef std::list< HierarchyContentRef > HierarchyContentRefList;
194 : : void queryChildren( HierarchyContentRefList& rChildren );
195 : :
196 : : sal_Bool exchangeIdentity(
197 : : const ::com::sun::star::uno::Reference<
198 : : ::com::sun::star::ucb::XContentIdentifier >& xNewId );
199 : :
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 );
210 : :
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 );
215 : :
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 );
220 : :
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 );
225 : :
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 );
234 : :
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 );
243 : :
244 : : virtual ~HierarchyContent();
245 : :
246 : : // XInterface
247 : : XINTERFACE_DECL()
248 : :
249 : : // XTypeProvider
250 : : XTYPEPROVIDER_DECL()
251 : :
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 );
259 : :
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 );
268 : :
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 );
281 : :
282 : : //////////////////////////////////////////////////////////////////////
283 : : // Additional interfaces
284 : : //////////////////////////////////////////////////////////////////////
285 : :
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 );
295 : :
296 : : //////////////////////////////////////////////////////////////////////
297 : : // Non-interface methods.
298 : : //////////////////////////////////////////////////////////////////////
299 : :
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 );
308 : : };
309 : :
310 : : } // namespace hierarchy_ucp
311 : :
312 : : #endif /* !_HIERARCHYCONTENT_HXX */
313 : :
314 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|