12f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52f86921cSAndrew Rist * distributed with this work for additional information
62f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82f86921cSAndrew Rist * "License"); you may not use this file except in compliance
92f86921cSAndrew Rist * with the License. You may obtain a copy of the License at
102f86921cSAndrew Rist *
112f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
122f86921cSAndrew Rist *
132f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142f86921cSAndrew Rist * software distributed under the License is distributed on an
152f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162f86921cSAndrew Rist * KIND, either express or implied. See the License for the
172f86921cSAndrew Rist * specific language governing permissions and limitations
182f86921cSAndrew Rist * under the License.
192f86921cSAndrew Rist *
202f86921cSAndrew Rist *************************************************************/
212f86921cSAndrew Rist
222f86921cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25421ed02eSdamjan #include "precompiled_file.hxx"
26cdf0e10cSrcweir #ifndef INCLUDED_STL_STACK
27cdf0e10cSrcweir #include <stack>
28cdf0e10cSrcweir #define INCLUDED_STL_STACK
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "osl/diagnose.h"
32cdf0e10cSrcweir #include <rtl/uri.hxx>
33cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
34cdf0e10cSrcweir #include <osl/time.h>
35cdf0e10cSrcweir #include <osl/file.hxx>
36cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/IllegalTypeException.hpp>
38cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
39cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp>
40cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp>
41cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifier.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
43cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
45cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
46cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
49cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp>
50cdf0e10cSrcweir #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
51cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp>
52cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
53cdf0e10cSrcweir #include <rtl/string.hxx>
54cdf0e10cSrcweir #include "filerror.hxx"
55cdf0e10cSrcweir #include "filglob.hxx"
56cdf0e10cSrcweir #include "filcmd.hxx"
57cdf0e10cSrcweir #include "filinpstr.hxx"
58cdf0e10cSrcweir #include "filstr.hxx"
59cdf0e10cSrcweir #include "filrset.hxx"
60cdf0e10cSrcweir #include "filrow.hxx"
61cdf0e10cSrcweir #include "filprp.hxx"
62cdf0e10cSrcweir #include "filid.hxx"
63cdf0e10cSrcweir #include "shell.hxx"
64cdf0e10cSrcweir #include "prov.hxx"
65cdf0e10cSrcweir #include "bc.hxx"
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir using namespace fileaccess;
69cdf0e10cSrcweir using namespace com::sun::star;
70cdf0e10cSrcweir using namespace com::sun::star::ucb;
71cdf0e10cSrcweir
72cdf0e10cSrcweir
UnqPathData()73cdf0e10cSrcweir shell::UnqPathData::UnqPathData()
74cdf0e10cSrcweir : properties( 0 ),
75cdf0e10cSrcweir notifier( 0 ),
76cdf0e10cSrcweir xS( 0 ),
77cdf0e10cSrcweir xC( 0 ),
78cdf0e10cSrcweir xA( 0 )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir // empty
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir
UnqPathData(const UnqPathData & a)84cdf0e10cSrcweir shell::UnqPathData::UnqPathData( const UnqPathData& a )
85cdf0e10cSrcweir : properties( a.properties ),
86cdf0e10cSrcweir notifier( a.notifier ),
87cdf0e10cSrcweir xS( a.xS ),
88cdf0e10cSrcweir xC( a.xC ),
89cdf0e10cSrcweir xA( a.xA )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir
operator =(UnqPathData & a)94cdf0e10cSrcweir shell::UnqPathData& shell::UnqPathData::operator=( UnqPathData& a )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir properties = a.properties;
97cdf0e10cSrcweir notifier = a.notifier;
98cdf0e10cSrcweir xS = a.xS;
99cdf0e10cSrcweir xC = a.xC;
100cdf0e10cSrcweir xA = a.xA;
101cdf0e10cSrcweir a.properties = 0;
102cdf0e10cSrcweir a.notifier = 0;
103cdf0e10cSrcweir a.xS = 0;
104cdf0e10cSrcweir a.xC = 0;
105cdf0e10cSrcweir a.xA = 0;
106cdf0e10cSrcweir return *this;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
~UnqPathData()109cdf0e10cSrcweir shell::UnqPathData::~UnqPathData()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir if( properties )
112cdf0e10cSrcweir delete properties;
113cdf0e10cSrcweir if( notifier )
114cdf0e10cSrcweir delete notifier;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir
118cdf0e10cSrcweir
119cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////
120cdf0e10cSrcweir
121cdf0e10cSrcweir
122cdf0e10cSrcweir
123cdf0e10cSrcweir
124cdf0e10cSrcweir
MyProperty(const rtl::OUString & __PropertyName)125cdf0e10cSrcweir shell::MyProperty::MyProperty( const rtl::OUString& __PropertyName )
126cdf0e10cSrcweir : PropertyName( __PropertyName )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir // empty
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir
MyProperty(const sal_Bool & __isNative,const rtl::OUString & __PropertyName,const sal_Int32 & __Handle,const com::sun::star::uno::Type & __Typ,const com::sun::star::uno::Any & __Value,const com::sun::star::beans::PropertyState & __State,const sal_Int16 & __Attributes)132cdf0e10cSrcweir shell::MyProperty::MyProperty( const sal_Bool& __isNative,
133cdf0e10cSrcweir const rtl::OUString& __PropertyName,
134cdf0e10cSrcweir const sal_Int32& __Handle,
135cdf0e10cSrcweir const com::sun::star::uno::Type& __Typ,
136cdf0e10cSrcweir const com::sun::star::uno::Any& __Value,
137cdf0e10cSrcweir const com::sun::star::beans::PropertyState& __State,
138cdf0e10cSrcweir const sal_Int16& __Attributes )
139cdf0e10cSrcweir : PropertyName( __PropertyName ),
140cdf0e10cSrcweir Handle( __Handle ),
141cdf0e10cSrcweir isNative( __isNative ),
142cdf0e10cSrcweir Typ( __Typ ),
143cdf0e10cSrcweir Value( __Value ),
144cdf0e10cSrcweir State( __State ),
145cdf0e10cSrcweir Attributes( __Attributes )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir // empty
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
~MyProperty()150cdf0e10cSrcweir shell::MyProperty::~MyProperty()
151cdf0e10cSrcweir {
152cdf0e10cSrcweir // empty for now
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir
156cdf0e10cSrcweir #include "filinl.hxx"
157cdf0e10cSrcweir
158cdf0e10cSrcweir
shell(const uno::Reference<lang::XMultiServiceFactory> & xMultiServiceFactory,FileProvider * pProvider,sal_Bool bWithConfig)159cdf0e10cSrcweir shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceFactory,
160cdf0e10cSrcweir FileProvider* pProvider, sal_Bool bWithConfig )
161cdf0e10cSrcweir : TaskManager(),
162cdf0e10cSrcweir m_bWithConfig( bWithConfig ),
163cdf0e10cSrcweir m_pProvider( pProvider ),
164cdf0e10cSrcweir m_xMultiServiceFactory( xMultiServiceFactory ),
165cdf0e10cSrcweir Title( rtl::OUString::createFromAscii( "Title" ) ),
166cdf0e10cSrcweir CasePreservingURL(
167cdf0e10cSrcweir rtl::OUString::createFromAscii( "CasePreservingURL" ) ),
168cdf0e10cSrcweir IsDocument( rtl::OUString::createFromAscii( "IsDocument" ) ),
169cdf0e10cSrcweir IsFolder( rtl::OUString::createFromAscii( "IsFolder" ) ),
170cdf0e10cSrcweir DateModified( rtl::OUString::createFromAscii( "DateModified" ) ),
171cdf0e10cSrcweir Size( rtl::OUString::createFromAscii( "Size" ) ),
172cdf0e10cSrcweir IsVolume( rtl::OUString::createFromAscii( "IsVolume" ) ),
173cdf0e10cSrcweir IsRemoveable( rtl::OUString::createFromAscii( "IsRemoveable" ) ),
174cdf0e10cSrcweir IsRemote( rtl::OUString::createFromAscii( "IsRemote" ) ),
175cdf0e10cSrcweir IsCompactDisc( rtl::OUString::createFromAscii( "IsCompactDisc" ) ),
176cdf0e10cSrcweir IsFloppy( rtl::OUString::createFromAscii( "IsFloppy" ) ),
177cdf0e10cSrcweir IsHidden( rtl::OUString::createFromAscii( "IsHidden" ) ),
178cdf0e10cSrcweir ContentType( rtl::OUString::createFromAscii( "ContentType" ) ),
179cdf0e10cSrcweir IsReadOnly( rtl::OUString::createFromAscii( "IsReadOnly" ) ),
180cdf0e10cSrcweir CreatableContentsInfo( rtl::OUString::createFromAscii( "CreatableContentsInfo" ) ),
181cdf0e10cSrcweir FolderContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" ) ),
182cdf0e10cSrcweir FileContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-file" ) ),
183cdf0e10cSrcweir m_sCommandInfo( 9 )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir // Title
186cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
187cdf0e10cSrcweir Title,
188cdf0e10cSrcweir -1 ,
189cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ),
190cdf0e10cSrcweir uno::Any(),
191cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
192cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
193cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) );
194cdf0e10cSrcweir
195cdf0e10cSrcweir // CasePreservingURL
196cdf0e10cSrcweir m_aDefaultProperties.insert(
197cdf0e10cSrcweir MyProperty( true,
198cdf0e10cSrcweir CasePreservingURL,
199cdf0e10cSrcweir -1 ,
200cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ),
201cdf0e10cSrcweir uno::Any(),
202cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
203cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
204cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
205cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
206cdf0e10cSrcweir
207cdf0e10cSrcweir
208cdf0e10cSrcweir // IsFolder
209cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
210cdf0e10cSrcweir IsFolder,
211cdf0e10cSrcweir -1 ,
212cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
213cdf0e10cSrcweir uno::Any(),
214cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
215cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
216cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
217cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
218cdf0e10cSrcweir
219cdf0e10cSrcweir
220cdf0e10cSrcweir // IsDocument
221cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
222cdf0e10cSrcweir IsDocument,
223cdf0e10cSrcweir -1 ,
224cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
225cdf0e10cSrcweir uno::Any(),
226cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
227cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
228cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
229cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
230cdf0e10cSrcweir
231cdf0e10cSrcweir // Removable
232cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
233cdf0e10cSrcweir IsVolume,
234cdf0e10cSrcweir -1 ,
235cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
236cdf0e10cSrcweir uno::Any(),
237cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
238cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
239cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
240cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
241cdf0e10cSrcweir
242cdf0e10cSrcweir
243cdf0e10cSrcweir // Removable
244cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
245cdf0e10cSrcweir IsRemoveable,
246cdf0e10cSrcweir -1 ,
247cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
248cdf0e10cSrcweir uno::Any(),
249cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
250cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
251cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
252cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
253cdf0e10cSrcweir
254cdf0e10cSrcweir // Remote
255cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
256cdf0e10cSrcweir IsRemote,
257cdf0e10cSrcweir -1 ,
258cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
259cdf0e10cSrcweir uno::Any(),
260cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
261cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
262cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
263cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
264cdf0e10cSrcweir
265cdf0e10cSrcweir // CompactDisc
266cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
267cdf0e10cSrcweir IsCompactDisc,
268cdf0e10cSrcweir -1 ,
269cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
270cdf0e10cSrcweir uno::Any(),
271cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
272cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
273cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
274cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
275cdf0e10cSrcweir
276cdf0e10cSrcweir // Floppy
277cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
278cdf0e10cSrcweir IsFloppy,
279cdf0e10cSrcweir -1 ,
280cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
281cdf0e10cSrcweir uno::Any(),
282cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
283cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
284cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
285cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
286cdf0e10cSrcweir
287cdf0e10cSrcweir // Hidden
288cdf0e10cSrcweir m_aDefaultProperties.insert(
289cdf0e10cSrcweir MyProperty(
290cdf0e10cSrcweir true,
291cdf0e10cSrcweir IsHidden,
292cdf0e10cSrcweir -1 ,
293cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
294cdf0e10cSrcweir uno::Any(),
295cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
296cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
297cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
298cdf0e10cSrcweir #if defined( WNT ) || defined( OS2 )
299cdf0e10cSrcweir ));
300cdf0e10cSrcweir #else
301cdf0e10cSrcweir | beans::PropertyAttribute::READONLY)); // under unix/linux only readable
302cdf0e10cSrcweir #endif
303cdf0e10cSrcweir
304cdf0e10cSrcweir
305cdf0e10cSrcweir // ContentType
306cdf0e10cSrcweir uno::Any aAny;
307cdf0e10cSrcweir aAny <<= rtl::OUString();
308cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( false,
309cdf0e10cSrcweir ContentType,
310cdf0e10cSrcweir -1 ,
311cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ),
312cdf0e10cSrcweir aAny,
313cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
314cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
315cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
316cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
317cdf0e10cSrcweir
318cdf0e10cSrcweir
319cdf0e10cSrcweir // DateModified
320cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
321cdf0e10cSrcweir DateModified,
322cdf0e10cSrcweir -1 ,
323cdf0e10cSrcweir getCppuType( static_cast< util::DateTime* >( 0 ) ),
324cdf0e10cSrcweir uno::Any(),
325cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
326cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
327cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) );
328cdf0e10cSrcweir
329cdf0e10cSrcweir // Size
330cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
331cdf0e10cSrcweir Size,
332cdf0e10cSrcweir -1,
333cdf0e10cSrcweir getCppuType( static_cast< sal_Int64* >( 0 ) ),
334cdf0e10cSrcweir uno::Any(),
335cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
336cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
337cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) );
338cdf0e10cSrcweir
339cdf0e10cSrcweir // IsReadOnly
340cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
341cdf0e10cSrcweir IsReadOnly,
342cdf0e10cSrcweir -1 ,
343cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ),
344cdf0e10cSrcweir uno::Any(),
345cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
346cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
347cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) );
348cdf0e10cSrcweir
349cdf0e10cSrcweir
350cdf0e10cSrcweir // CreatableContentsInfo
351cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true,
352cdf0e10cSrcweir CreatableContentsInfo,
353cdf0e10cSrcweir -1 ,
354cdf0e10cSrcweir getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
355cdf0e10cSrcweir uno::Any(),
356cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
357cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
358cdf0e10cSrcweir | beans::PropertyAttribute::BOUND
359cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) );
360cdf0e10cSrcweir
361cdf0e10cSrcweir // Commands
362cdf0e10cSrcweir m_sCommandInfo[0].Name = rtl::OUString::createFromAscii( "getCommandInfo" );
363cdf0e10cSrcweir m_sCommandInfo[0].Handle = -1;
364cdf0e10cSrcweir m_sCommandInfo[0].ArgType = getCppuVoidType();
365cdf0e10cSrcweir
366cdf0e10cSrcweir m_sCommandInfo[1].Name = rtl::OUString::createFromAscii( "getPropertySetInfo" );
367cdf0e10cSrcweir m_sCommandInfo[1].Handle = -1;
368cdf0e10cSrcweir m_sCommandInfo[1].ArgType = getCppuVoidType();
369cdf0e10cSrcweir
370cdf0e10cSrcweir m_sCommandInfo[2].Name = rtl::OUString::createFromAscii( "getPropertyValues" );
371cdf0e10cSrcweir m_sCommandInfo[2].Handle = -1;
372cdf0e10cSrcweir m_sCommandInfo[2].ArgType = getCppuType( static_cast< uno::Sequence< beans::Property >* >( 0 ) );
373cdf0e10cSrcweir
374cdf0e10cSrcweir m_sCommandInfo[3].Name = rtl::OUString::createFromAscii( "setPropertyValues" );
375cdf0e10cSrcweir m_sCommandInfo[3].Handle = -1;
376cdf0e10cSrcweir m_sCommandInfo[3].ArgType = getCppuType( static_cast< uno::Sequence< beans::PropertyValue >* >( 0 ) );
377cdf0e10cSrcweir
378cdf0e10cSrcweir m_sCommandInfo[4].Name = rtl::OUString::createFromAscii( "open" );
379cdf0e10cSrcweir m_sCommandInfo[4].Handle = -1;
380cdf0e10cSrcweir m_sCommandInfo[4].ArgType = getCppuType( static_cast< OpenCommandArgument* >( 0 ) );
381cdf0e10cSrcweir
382cdf0e10cSrcweir m_sCommandInfo[5].Name = rtl::OUString::createFromAscii( "transfer" );
383cdf0e10cSrcweir m_sCommandInfo[5].Handle = -1;
384cdf0e10cSrcweir m_sCommandInfo[5].ArgType = getCppuType( static_cast< TransferInfo* >( 0 ) );
385cdf0e10cSrcweir
386cdf0e10cSrcweir m_sCommandInfo[6].Name = rtl::OUString::createFromAscii( "delete" );
387cdf0e10cSrcweir m_sCommandInfo[6].Handle = -1;
388cdf0e10cSrcweir m_sCommandInfo[6].ArgType = getCppuType( static_cast< sal_Bool* >( 0 ) );
389cdf0e10cSrcweir
390cdf0e10cSrcweir m_sCommandInfo[7].Name = rtl::OUString::createFromAscii( "insert" );
391cdf0e10cSrcweir m_sCommandInfo[7].Handle = -1;
392cdf0e10cSrcweir m_sCommandInfo[7].ArgType = getCppuType( static_cast< InsertCommandArgument* > ( 0 ) );
393cdf0e10cSrcweir
394cdf0e10cSrcweir m_sCommandInfo[7].Name = rtl::OUString::createFromAscii( "createNewContent" );
395cdf0e10cSrcweir m_sCommandInfo[7].Handle = -1;
396cdf0e10cSrcweir m_sCommandInfo[7].ArgType = getCppuType( static_cast< ucb::ContentInfo * > ( 0 ) );
397cdf0e10cSrcweir
398cdf0e10cSrcweir if(m_bWithConfig)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir rtl::OUString Store = rtl::OUString::createFromAscii( "com.sun.star.ucb.Store" );
401cdf0e10cSrcweir uno::Reference< XPropertySetRegistryFactory > xRegFac(
402cdf0e10cSrcweir m_xMultiServiceFactory->createInstance( Store ),
403cdf0e10cSrcweir uno::UNO_QUERY );
404cdf0e10cSrcweir if ( xRegFac.is() )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir // Open/create a registry
407cdf0e10cSrcweir m_xFileRegistry = xRegFac->createPropertySetRegistry( rtl::OUString() );
408cdf0e10cSrcweir }
409cdf0e10cSrcweir }
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir
~shell()413cdf0e10cSrcweir shell::~shell()
414cdf0e10cSrcweir {
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir
418cdf0e10cSrcweir /*********************************************************************************/
419cdf0e10cSrcweir /* */
420cdf0e10cSrcweir /* de/registerNotifier-Implementation */
421cdf0e10cSrcweir /* */
422cdf0e10cSrcweir /*********************************************************************************/
423cdf0e10cSrcweir
424cdf0e10cSrcweir //
425cdf0e10cSrcweir // This two methods register and deregister a change listener for the content belonging
426cdf0e10cSrcweir // to URL aUnqPath
427cdf0e10cSrcweir //
428cdf0e10cSrcweir
429cdf0e10cSrcweir void SAL_CALL
registerNotifier(const rtl::OUString & aUnqPath,Notifier * pNotifier)430cdf0e10cSrcweir shell::registerNotifier( const rtl::OUString& aUnqPath, Notifier* pNotifier )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
433cdf0e10cSrcweir
434cdf0e10cSrcweir ContentMap::iterator it =
435cdf0e10cSrcweir m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first;
436cdf0e10cSrcweir
437cdf0e10cSrcweir if( ! it->second.notifier )
438cdf0e10cSrcweir it->second.notifier = new NotifierList();
439cdf0e10cSrcweir
440cdf0e10cSrcweir std::list< Notifier* >& nlist = *( it->second.notifier );
441cdf0e10cSrcweir
442cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = nlist.begin();
443cdf0e10cSrcweir while( it1 != nlist.end() ) // Every "Notifier" only once
444cdf0e10cSrcweir {
445cdf0e10cSrcweir if( *it1 == pNotifier ) return;
446cdf0e10cSrcweir ++it1;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir nlist.push_back( pNotifier );
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
451cdf0e10cSrcweir
452cdf0e10cSrcweir
453cdf0e10cSrcweir void SAL_CALL
deregisterNotifier(const rtl::OUString & aUnqPath,Notifier * pNotifier)454cdf0e10cSrcweir shell::deregisterNotifier( const rtl::OUString& aUnqPath,Notifier* pNotifier )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
457cdf0e10cSrcweir
458cdf0e10cSrcweir ContentMap::iterator it = m_aContent.find( aUnqPath );
459cdf0e10cSrcweir if( it == m_aContent.end() )
460cdf0e10cSrcweir return;
461cdf0e10cSrcweir
462cdf0e10cSrcweir it->second.notifier->remove( pNotifier );
463cdf0e10cSrcweir
464cdf0e10cSrcweir if( ! it->second.notifier->size() )
465cdf0e10cSrcweir m_aContent.erase( it );
466cdf0e10cSrcweir }
467cdf0e10cSrcweir
468cdf0e10cSrcweir
469cdf0e10cSrcweir
470cdf0e10cSrcweir /*********************************************************************************/
471cdf0e10cSrcweir /* */
472cdf0e10cSrcweir /* de/associate-Implementation */
473cdf0e10cSrcweir /* */
474cdf0e10cSrcweir /*********************************************************************************/
475cdf0e10cSrcweir //
476cdf0e10cSrcweir // Used to associate and deassociate a new property with
477cdf0e10cSrcweir // the content belonging to URL UnqPath.
478*fb0b81f5Smseidel // The default value and the attributes are input
479cdf0e10cSrcweir //
480cdf0e10cSrcweir
481cdf0e10cSrcweir void SAL_CALL
associate(const rtl::OUString & aUnqPath,const rtl::OUString & PropertyName,const uno::Any & DefaultValue,const sal_Int16 Attributes)482cdf0e10cSrcweir shell::associate( const rtl::OUString& aUnqPath,
483cdf0e10cSrcweir const rtl::OUString& PropertyName,
484cdf0e10cSrcweir const uno::Any& DefaultValue,
485cdf0e10cSrcweir const sal_Int16 Attributes )
486cdf0e10cSrcweir throw( beans::PropertyExistException,
487cdf0e10cSrcweir beans::IllegalTypeException,
488cdf0e10cSrcweir uno::RuntimeException )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir MyProperty newProperty( false,
491cdf0e10cSrcweir PropertyName,
492cdf0e10cSrcweir -1,
493cdf0e10cSrcweir DefaultValue.getValueType(),
494cdf0e10cSrcweir DefaultValue,
495cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE,
496cdf0e10cSrcweir Attributes );
497cdf0e10cSrcweir
498cdf0e10cSrcweir shell::PropertySet::iterator it1 = m_aDefaultProperties.find( newProperty );
499cdf0e10cSrcweir if( it1 != m_aDefaultProperties.end() )
500cdf0e10cSrcweir throw beans::PropertyExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
501cdf0e10cSrcweir
502cdf0e10cSrcweir {
503cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
504cdf0e10cSrcweir
505cdf0e10cSrcweir ContentMap::iterator it = m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first;
506cdf0e10cSrcweir
507cdf0e10cSrcweir // Load the XPersistentPropertySetInfo and create it, if it does not exist
508cdf0e10cSrcweir load( it,true );
509cdf0e10cSrcweir
510cdf0e10cSrcweir PropertySet& properties = *(it->second.properties);
511cdf0e10cSrcweir it1 = properties.find( newProperty );
512cdf0e10cSrcweir if( it1 != properties.end() )
513cdf0e10cSrcweir throw beans::PropertyExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
514cdf0e10cSrcweir
515cdf0e10cSrcweir // Property does not exist
516cdf0e10cSrcweir properties.insert( newProperty );
517cdf0e10cSrcweir it->second.xC->addProperty( PropertyName,Attributes,DefaultValue );
518cdf0e10cSrcweir }
519cdf0e10cSrcweir notifyPropertyAdded( getPropertySetListeners( aUnqPath ), PropertyName );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir
522cdf0e10cSrcweir
523cdf0e10cSrcweir
524cdf0e10cSrcweir
525cdf0e10cSrcweir void SAL_CALL
deassociate(const rtl::OUString & aUnqPath,const rtl::OUString & PropertyName)526cdf0e10cSrcweir shell::deassociate( const rtl::OUString& aUnqPath,
527cdf0e10cSrcweir const rtl::OUString& PropertyName )
528cdf0e10cSrcweir throw( beans::UnknownPropertyException,
529cdf0e10cSrcweir beans::NotRemoveableException,
530cdf0e10cSrcweir uno::RuntimeException )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir MyProperty oldProperty( PropertyName );
533cdf0e10cSrcweir
534cdf0e10cSrcweir shell::PropertySet::iterator it1 = m_aDefaultProperties.find( oldProperty );
535cdf0e10cSrcweir if( it1 != m_aDefaultProperties.end() )
536cdf0e10cSrcweir throw beans::NotRemoveableException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
537cdf0e10cSrcweir
538cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
539cdf0e10cSrcweir
540cdf0e10cSrcweir ContentMap::iterator it = m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first;
541cdf0e10cSrcweir
542cdf0e10cSrcweir load( it,false );
543cdf0e10cSrcweir
544cdf0e10cSrcweir PropertySet& properties = *(it->second.properties);
545cdf0e10cSrcweir
546cdf0e10cSrcweir it1 = properties.find( oldProperty );
547cdf0e10cSrcweir if( it1 == properties.end() )
548cdf0e10cSrcweir throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
549cdf0e10cSrcweir
550cdf0e10cSrcweir properties.erase( it1 );
551cdf0e10cSrcweir
552cdf0e10cSrcweir if( it->second.xC.is() )
553cdf0e10cSrcweir it->second.xC->removeProperty( PropertyName );
554cdf0e10cSrcweir
555cdf0e10cSrcweir if( properties.size() == 9 )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir MyProperty ContentTProperty( ContentType );
558cdf0e10cSrcweir
559cdf0e10cSrcweir if( properties.find( ContentTProperty )->getState() == beans::PropertyState_DEFAULT_VALUE )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir it->second.xS = 0;
562cdf0e10cSrcweir it->second.xC = 0;
563cdf0e10cSrcweir it->second.xA = 0;
564cdf0e10cSrcweir if(m_xFileRegistry.is())
565cdf0e10cSrcweir m_xFileRegistry->removePropertySet( aUnqPath );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir }
568cdf0e10cSrcweir notifyPropertyRemoved( getPropertySetListeners( aUnqPath ), PropertyName );
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir
572cdf0e10cSrcweir
573cdf0e10cSrcweir
574cdf0e10cSrcweir /*********************************************************************************/
575cdf0e10cSrcweir /* */
576cdf0e10cSrcweir /* page-Implementation */
577cdf0e10cSrcweir /* */
578cdf0e10cSrcweir /*********************************************************************************/
579cdf0e10cSrcweir //
580cdf0e10cSrcweir // Given an xOutputStream, this method writes the content of the file belonging to
581cdf0e10cSrcweir // URL aUnqPath into the XOutputStream
582cdf0e10cSrcweir //
583cdf0e10cSrcweir
584cdf0e10cSrcweir
page(sal_Int32 CommandId,const rtl::OUString & aUnqPath,const uno::Reference<io::XOutputStream> & xOutputStream)585cdf0e10cSrcweir void SAL_CALL shell::page( sal_Int32 CommandId,
586cdf0e10cSrcweir const rtl::OUString& aUnqPath,
587cdf0e10cSrcweir const uno::Reference< io::XOutputStream >& xOutputStream )
588cdf0e10cSrcweir throw()
589cdf0e10cSrcweir {
590cdf0e10cSrcweir uno::Reference< XContentProvider > xProvider( m_pProvider );
591cdf0e10cSrcweir osl::File aFile( aUnqPath );
592cdf0e10cSrcweir osl::FileBase::RC err = aFile.open( OpenFlag_Read );
593cdf0e10cSrcweir
594cdf0e10cSrcweir if( err != osl::FileBase::E_None )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir aFile.close();
597cdf0e10cSrcweir installError( CommandId,
598cdf0e10cSrcweir TASKHANDLING_OPEN_FILE_FOR_PAGING,
599cdf0e10cSrcweir err );
600cdf0e10cSrcweir return;
601cdf0e10cSrcweir }
602cdf0e10cSrcweir
603cdf0e10cSrcweir const sal_uInt64 bfz = 4*1024;
604cdf0e10cSrcweir sal_Int8 BFF[bfz];
605cdf0e10cSrcweir sal_uInt64 nrc; // Retrieved number of Bytes;
606cdf0e10cSrcweir
607cdf0e10cSrcweir do
608cdf0e10cSrcweir {
609cdf0e10cSrcweir err = aFile.read( (void*) BFF,bfz,nrc );
610cdf0e10cSrcweir if( err == osl::FileBase::E_None )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir uno::Sequence< sal_Int8 > seq( BFF, (sal_uInt32)nrc );
613cdf0e10cSrcweir try
614cdf0e10cSrcweir {
615cdf0e10cSrcweir xOutputStream->writeBytes( seq );
616cdf0e10cSrcweir }
617cdf0e10cSrcweir catch( io::NotConnectedException )
618cdf0e10cSrcweir {
619cdf0e10cSrcweir installError( CommandId,
620cdf0e10cSrcweir TASKHANDLING_NOTCONNECTED_FOR_PAGING );
621cdf0e10cSrcweir break;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir catch( io::BufferSizeExceededException )
624cdf0e10cSrcweir {
625cdf0e10cSrcweir installError( CommandId,
626cdf0e10cSrcweir TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING );
627cdf0e10cSrcweir break;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir catch( io::IOException )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir installError( CommandId,
632cdf0e10cSrcweir TASKHANDLING_IOEXCEPTION_FOR_PAGING );
633cdf0e10cSrcweir break;
634cdf0e10cSrcweir }
635cdf0e10cSrcweir }
636cdf0e10cSrcweir else
637cdf0e10cSrcweir {
638cdf0e10cSrcweir installError( CommandId,
639cdf0e10cSrcweir TASKHANDLING_READING_FILE_FOR_PAGING,
640cdf0e10cSrcweir err );
641cdf0e10cSrcweir break;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir } while( nrc == bfz );
644cdf0e10cSrcweir
645cdf0e10cSrcweir
646cdf0e10cSrcweir aFile.close();
647cdf0e10cSrcweir
648cdf0e10cSrcweir
649cdf0e10cSrcweir try
650cdf0e10cSrcweir {
651cdf0e10cSrcweir xOutputStream->closeOutput();
652cdf0e10cSrcweir }
653cdf0e10cSrcweir catch( io::NotConnectedException )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir }
656cdf0e10cSrcweir catch( io::BufferSizeExceededException )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir }
659cdf0e10cSrcweir catch( io::IOException )
660cdf0e10cSrcweir {
661cdf0e10cSrcweir }
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
664cdf0e10cSrcweir
665cdf0e10cSrcweir /*********************************************************************************/
666cdf0e10cSrcweir /* */
667cdf0e10cSrcweir /* open-Implementation */
668cdf0e10cSrcweir /* */
669cdf0e10cSrcweir /*********************************************************************************/
670cdf0e10cSrcweir //
671cdf0e10cSrcweir // Given a file URL aUnqPath, this methods returns a XInputStream which reads from the open file.
672cdf0e10cSrcweir //
673cdf0e10cSrcweir
674cdf0e10cSrcweir
675cdf0e10cSrcweir uno::Reference< io::XInputStream > SAL_CALL
open(sal_Int32 CommandId,const rtl::OUString & aUnqPath,sal_Bool bLock)676cdf0e10cSrcweir shell::open( sal_Int32 CommandId,
677cdf0e10cSrcweir const rtl::OUString& aUnqPath,
678cdf0e10cSrcweir sal_Bool bLock )
679cdf0e10cSrcweir throw()
680cdf0e10cSrcweir {
681cdf0e10cSrcweir XInputStream_impl* xInputStream = new XInputStream_impl( this, aUnqPath, bLock ); // from filinpstr.hxx
682cdf0e10cSrcweir
683cdf0e10cSrcweir sal_Int32 ErrorCode = xInputStream->CtorSuccess();
684cdf0e10cSrcweir
685cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir installError( CommandId,
688cdf0e10cSrcweir ErrorCode,
689cdf0e10cSrcweir xInputStream->getMinorError() );
690cdf0e10cSrcweir
691cdf0e10cSrcweir delete xInputStream;
692cdf0e10cSrcweir xInputStream = 0;
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
695cdf0e10cSrcweir return uno::Reference< io::XInputStream >( xInputStream );
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir
699cdf0e10cSrcweir
700cdf0e10cSrcweir
701cdf0e10cSrcweir /*********************************************************************************/
702cdf0e10cSrcweir /* */
703cdf0e10cSrcweir /* open for read/write access-Implementation */
704cdf0e10cSrcweir /* */
705cdf0e10cSrcweir /*********************************************************************************/
706cdf0e10cSrcweir //
707cdf0e10cSrcweir // Given a file URL aUnqPath, this methods returns a XStream which can be used
708cdf0e10cSrcweir // to read and write from/to the file.
709cdf0e10cSrcweir //
710cdf0e10cSrcweir
711cdf0e10cSrcweir
712cdf0e10cSrcweir uno::Reference< io::XStream > SAL_CALL
open_rw(sal_Int32 CommandId,const rtl::OUString & aUnqPath,sal_Bool bLock)713cdf0e10cSrcweir shell::open_rw( sal_Int32 CommandId,
714cdf0e10cSrcweir const rtl::OUString& aUnqPath,
715cdf0e10cSrcweir sal_Bool bLock )
716cdf0e10cSrcweir throw()
717cdf0e10cSrcweir {
718cdf0e10cSrcweir XStream_impl* xStream = new XStream_impl( this, aUnqPath, bLock ); // from filstr.hxx
719cdf0e10cSrcweir
720cdf0e10cSrcweir sal_Int32 ErrorCode = xStream->CtorSuccess();
721cdf0e10cSrcweir
722cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR )
723cdf0e10cSrcweir {
724cdf0e10cSrcweir installError( CommandId,
725cdf0e10cSrcweir ErrorCode,
726cdf0e10cSrcweir xStream->getMinorError() );
727cdf0e10cSrcweir
728cdf0e10cSrcweir delete xStream;
729cdf0e10cSrcweir xStream = 0;
730cdf0e10cSrcweir }
731cdf0e10cSrcweir return uno::Reference< io::XStream >( xStream );
732cdf0e10cSrcweir }
733cdf0e10cSrcweir
734cdf0e10cSrcweir
735cdf0e10cSrcweir
736cdf0e10cSrcweir /*********************************************************************************/
737cdf0e10cSrcweir /* */
738cdf0e10cSrcweir /* ls-Implementation */
739cdf0e10cSrcweir /* */
740cdf0e10cSrcweir /*********************************************************************************/
741cdf0e10cSrcweir //
742*fb0b81f5Smseidel // This method returns the result set containing the children of the directory belonging
743cdf0e10cSrcweir // to file URL aUnqPath
744cdf0e10cSrcweir //
745cdf0e10cSrcweir
746cdf0e10cSrcweir
747cdf0e10cSrcweir uno::Reference< XDynamicResultSet > SAL_CALL
ls(sal_Int32 CommandId,const rtl::OUString & aUnqPath,const sal_Int32 OpenMode,const uno::Sequence<beans::Property> & seq,const uno::Sequence<NumberedSortingInfo> & seqSort)748cdf0e10cSrcweir shell::ls( sal_Int32 CommandId,
749cdf0e10cSrcweir const rtl::OUString& aUnqPath,
750cdf0e10cSrcweir const sal_Int32 OpenMode,
751cdf0e10cSrcweir const uno::Sequence< beans::Property >& seq,
752cdf0e10cSrcweir const uno::Sequence< NumberedSortingInfo >& seqSort )
753cdf0e10cSrcweir throw()
754cdf0e10cSrcweir {
755cdf0e10cSrcweir XResultSet_impl* p = new XResultSet_impl( this,aUnqPath,OpenMode,seq,seqSort );
756cdf0e10cSrcweir
757cdf0e10cSrcweir sal_Int32 ErrorCode = p->CtorSuccess();
758cdf0e10cSrcweir
759cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir installError( CommandId,
762cdf0e10cSrcweir ErrorCode,
763cdf0e10cSrcweir p->getMinorError() );
764cdf0e10cSrcweir
765cdf0e10cSrcweir delete p;
766cdf0e10cSrcweir p = 0;
767cdf0e10cSrcweir }
768cdf0e10cSrcweir
769cdf0e10cSrcweir return uno::Reference< XDynamicResultSet > ( p );
770cdf0e10cSrcweir }
771cdf0e10cSrcweir
772cdf0e10cSrcweir
773cdf0e10cSrcweir
774cdf0e10cSrcweir
775cdf0e10cSrcweir /*********************************************************************************/
776cdf0e10cSrcweir /* */
777cdf0e10cSrcweir /* info_c implementation */
778cdf0e10cSrcweir /* */
779cdf0e10cSrcweir /*********************************************************************************/
780cdf0e10cSrcweir // Info for commands
781cdf0e10cSrcweir
782cdf0e10cSrcweir uno::Reference< XCommandInfo > SAL_CALL
info_c()783cdf0e10cSrcweir shell::info_c()
784cdf0e10cSrcweir throw()
785cdf0e10cSrcweir {
786cdf0e10cSrcweir XCommandInfo_impl* p = new XCommandInfo_impl( this );
787cdf0e10cSrcweir return uno::Reference< XCommandInfo >( p );
788cdf0e10cSrcweir }
789cdf0e10cSrcweir
790cdf0e10cSrcweir
791cdf0e10cSrcweir
792cdf0e10cSrcweir
793cdf0e10cSrcweir /*********************************************************************************/
794cdf0e10cSrcweir /* */
795cdf0e10cSrcweir /* info_p-Implementation */
796cdf0e10cSrcweir /* */
797cdf0e10cSrcweir /*********************************************************************************/
798cdf0e10cSrcweir // Info for the properties
799cdf0e10cSrcweir
800cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL
info_p(const rtl::OUString & aUnqPath)801cdf0e10cSrcweir shell::info_p( const rtl::OUString& aUnqPath )
802cdf0e10cSrcweir throw()
803cdf0e10cSrcweir {
804cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
805cdf0e10cSrcweir XPropertySetInfo_impl* p = new XPropertySetInfo_impl( this,aUnqPath );
806cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo >( p );
807cdf0e10cSrcweir }
808cdf0e10cSrcweir
809cdf0e10cSrcweir
810cdf0e10cSrcweir
811cdf0e10cSrcweir
812cdf0e10cSrcweir /*********************************************************************************/
813cdf0e10cSrcweir /* */
814cdf0e10cSrcweir /* setv-Implementation */
815cdf0e10cSrcweir /* */
816cdf0e10cSrcweir /*********************************************************************************/
817cdf0e10cSrcweir //
818cdf0e10cSrcweir // Sets the values of the properties belonging to fileURL aUnqPath
819cdf0e10cSrcweir //
820cdf0e10cSrcweir
821cdf0e10cSrcweir
822cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL
setv(const rtl::OUString & aUnqPath,const uno::Sequence<beans::PropertyValue> & values)823cdf0e10cSrcweir shell::setv( const rtl::OUString& aUnqPath,
824cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& values )
825cdf0e10cSrcweir throw()
826cdf0e10cSrcweir {
827cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
828cdf0e10cSrcweir
829cdf0e10cSrcweir sal_Int32 propChanged = 0;
830cdf0e10cSrcweir uno::Sequence< uno::Any > ret( values.getLength() );
831cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > seqChanged( values.getLength() );
832cdf0e10cSrcweir
833cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aUnqPath );
834cdf0e10cSrcweir PropertySet& properties = *( it->second.properties );
835cdf0e10cSrcweir shell::PropertySet::iterator it1;
836cdf0e10cSrcweir uno::Any aAny;
837cdf0e10cSrcweir
838cdf0e10cSrcweir for( sal_Int32 i = 0; i < values.getLength(); ++i )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir MyProperty toset( values[i].Name );
841cdf0e10cSrcweir it1 = properties.find( toset );
842cdf0e10cSrcweir if( it1 == properties.end() )
843cdf0e10cSrcweir {
844cdf0e10cSrcweir ret[i] <<= beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
845cdf0e10cSrcweir continue;
846cdf0e10cSrcweir }
847cdf0e10cSrcweir
848cdf0e10cSrcweir aAny = it1->getValue();
849cdf0e10cSrcweir if( aAny == values[i].Value )
850cdf0e10cSrcweir continue; // nothing needs to be changed
851cdf0e10cSrcweir
852cdf0e10cSrcweir if( it1->getAttributes() & beans::PropertyAttribute::READONLY )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir ret[i] <<= lang::IllegalAccessException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
855cdf0e10cSrcweir continue;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir seqChanged[ propChanged ].PropertyName = values[i].Name;
859cdf0e10cSrcweir seqChanged[ propChanged ].PropertyHandle = -1;
860cdf0e10cSrcweir seqChanged[ propChanged ].Further = false;
861cdf0e10cSrcweir seqChanged[ propChanged ].OldValue <<= aAny;
862cdf0e10cSrcweir seqChanged[ propChanged++ ].NewValue = values[i].Value;
863cdf0e10cSrcweir
864cdf0e10cSrcweir it1->setValue( values[i].Value ); // Put the new value into the local cash
865cdf0e10cSrcweir
866cdf0e10cSrcweir if( ! it1->IsNative() )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir // Also put logical properties into storage
869cdf0e10cSrcweir if( !it->second.xS.is() )
870cdf0e10cSrcweir load( it,true );
871cdf0e10cSrcweir
872cdf0e10cSrcweir if( ( values[i].Name == ContentType ) &&
873cdf0e10cSrcweir it1->getState() == beans::PropertyState_DEFAULT_VALUE )
874cdf0e10cSrcweir { // Special logic for ContentType
875cdf0e10cSrcweir // 09.07.01: Not reached anymore, because ContentType is readonly
876cdf0e10cSrcweir it1->setState( beans::PropertyState_DIRECT_VALUE );
877cdf0e10cSrcweir it->second.xC->addProperty( values[i].Name,
878cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID,
879cdf0e10cSrcweir values[i].Value );
880cdf0e10cSrcweir }
881cdf0e10cSrcweir
882cdf0e10cSrcweir try
883cdf0e10cSrcweir {
884cdf0e10cSrcweir it->second.xS->setPropertyValue( values[i].Name,values[i].Value );
885cdf0e10cSrcweir }
886cdf0e10cSrcweir catch( const uno::Exception& e )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir --propChanged; // unsuccessful setting
889cdf0e10cSrcweir ret[i] <<= e;
890cdf0e10cSrcweir }
891cdf0e10cSrcweir }
892cdf0e10cSrcweir else
893cdf0e10cSrcweir {
894cdf0e10cSrcweir // native properties
895cdf0e10cSrcweir // Setting of physical file properties
896cdf0e10cSrcweir if( values[i].Name == Size )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir sal_Int64 newSize = 0;
899cdf0e10cSrcweir if( values[i].Value >>= newSize )
900cdf0e10cSrcweir { // valid value for the size
901cdf0e10cSrcweir osl::File aFile(aUnqPath);
902cdf0e10cSrcweir bool err =
903cdf0e10cSrcweir aFile.open(OpenFlag_Write) != osl::FileBase::E_None ||
904cdf0e10cSrcweir aFile.setSize(sal_uInt64(newSize)) != osl::FileBase::E_None ||
905cdf0e10cSrcweir aFile.close() != osl::FileBase::E_None;
906cdf0e10cSrcweir
907cdf0e10cSrcweir if( err )
908cdf0e10cSrcweir {
909cdf0e10cSrcweir --propChanged; // unsuccessful setting
910cdf0e10cSrcweir uno::Sequence< uno::Any > names( 1 );
911cdf0e10cSrcweir ret[0] <<= beans::PropertyValue(
912cdf0e10cSrcweir rtl::OUString::createFromAscii("Uri"), -1,
913cdf0e10cSrcweir uno::makeAny(aUnqPath),
914cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE);
915cdf0e10cSrcweir IOErrorCode ioError(IOErrorCode_GENERAL);
916cdf0e10cSrcweir ret[i] <<= InteractiveAugmentedIOException(
917cdf0e10cSrcweir rtl::OUString(),
918cdf0e10cSrcweir 0,
919cdf0e10cSrcweir task::InteractionClassification_ERROR,
920cdf0e10cSrcweir ioError,
921cdf0e10cSrcweir names );
922cdf0e10cSrcweir }
923cdf0e10cSrcweir }
924cdf0e10cSrcweir else
925cdf0e10cSrcweir ret[i] <<= beans::IllegalTypeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
926cdf0e10cSrcweir }
927cdf0e10cSrcweir else if(values[i].Name == IsReadOnly ||
928cdf0e10cSrcweir values[i].Name == IsHidden)
929cdf0e10cSrcweir {
930cdf0e10cSrcweir sal_Bool value = sal_False;
931cdf0e10cSrcweir if( values[i].Value >>= value )
932cdf0e10cSrcweir {
933cdf0e10cSrcweir osl::DirectoryItem aDirItem;
934cdf0e10cSrcweir osl::FileBase::RC err =
935cdf0e10cSrcweir osl::DirectoryItem::get(aUnqPath,aDirItem);
936cdf0e10cSrcweir sal_uInt64 nAttributes(0);
937cdf0e10cSrcweir if(err == osl::FileBase::E_None)
938cdf0e10cSrcweir {
939cdf0e10cSrcweir osl::FileStatus aFileStatus(FileStatusMask_Attributes);
940cdf0e10cSrcweir err = aDirItem.getFileStatus(aFileStatus);
941cdf0e10cSrcweir if(err == osl::FileBase::E_None &&
942cdf0e10cSrcweir aFileStatus.isValid(FileStatusMask_Attributes))
943cdf0e10cSrcweir nAttributes = aFileStatus.getAttributes();
944cdf0e10cSrcweir }
945cdf0e10cSrcweir // now we have the attributes provided all went well.
946cdf0e10cSrcweir if(err == osl::FileBase::E_None) {
947cdf0e10cSrcweir if(values[i].Name == IsReadOnly)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir nAttributes &= ~(Attribute_OwnWrite |
950cdf0e10cSrcweir Attribute_GrpWrite |
951cdf0e10cSrcweir Attribute_OthWrite |
952cdf0e10cSrcweir Attribute_ReadOnly);
953cdf0e10cSrcweir if(value)
954cdf0e10cSrcweir nAttributes |= Attribute_ReadOnly;
955cdf0e10cSrcweir else
956cdf0e10cSrcweir nAttributes |= (
957cdf0e10cSrcweir Attribute_OwnWrite |
958cdf0e10cSrcweir Attribute_GrpWrite |
959cdf0e10cSrcweir Attribute_OthWrite);
960cdf0e10cSrcweir }
961cdf0e10cSrcweir else if(values[i].Name == IsHidden)
962cdf0e10cSrcweir {
963cdf0e10cSrcweir nAttributes &= ~(Attribute_Hidden);
964cdf0e10cSrcweir if(value)
965cdf0e10cSrcweir nAttributes |= Attribute_Hidden;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir err = osl::File::setAttributes(
968cdf0e10cSrcweir aUnqPath,nAttributes);
969cdf0e10cSrcweir }
970cdf0e10cSrcweir
971cdf0e10cSrcweir if( err != osl::FileBase::E_None )
972cdf0e10cSrcweir {
973cdf0e10cSrcweir --propChanged; // unsuccessful setting
974cdf0e10cSrcweir uno::Sequence< uno::Any > names( 1 );
975cdf0e10cSrcweir names[0] <<= beans::PropertyValue(
976cdf0e10cSrcweir rtl::OUString::createFromAscii("Uri"), -1,
977cdf0e10cSrcweir uno::makeAny(aUnqPath),
978cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE);
979cdf0e10cSrcweir IOErrorCode ioError;
980cdf0e10cSrcweir switch( err )
981cdf0e10cSrcweir {
982cdf0e10cSrcweir case osl::FileBase::E_NOMEM:
983cdf0e10cSrcweir // not enough memory for allocating structures <br>
984cdf0e10cSrcweir ioError = IOErrorCode_OUT_OF_MEMORY;
985cdf0e10cSrcweir break;
986cdf0e10cSrcweir case osl::FileBase::E_INVAL:
987cdf0e10cSrcweir // the format of the parameters was not valid<p>
988cdf0e10cSrcweir ioError = IOErrorCode_INVALID_PARAMETER;
989cdf0e10cSrcweir break;
990cdf0e10cSrcweir case osl::FileBase::E_NAMETOOLONG:
991cdf0e10cSrcweir // File name too long<br>
992cdf0e10cSrcweir ioError = IOErrorCode_NAME_TOO_LONG;
993cdf0e10cSrcweir break;
994cdf0e10cSrcweir case osl::FileBase::E_NOENT:
995cdf0e10cSrcweir // No such file or directory<br>
996cdf0e10cSrcweir case osl::FileBase::E_NOLINK:
997cdf0e10cSrcweir // Link has been severed<br>
998cdf0e10cSrcweir ioError = IOErrorCode_NOT_EXISTING;
999cdf0e10cSrcweir break;
1000cdf0e10cSrcweir case osl::FileBase::E_ROFS:
1001cdf0e10cSrcweir // #i4735# handle ROFS transparently
1002cdf0e10cSrcweir // as ACCESS_DENIED
1003cdf0e10cSrcweir case osl::FileBase::E_PERM:
1004cdf0e10cSrcweir case osl::FileBase::E_ACCES:
1005cdf0e10cSrcweir // permission denied<br>
1006cdf0e10cSrcweir ioError = IOErrorCode_ACCESS_DENIED;
1007cdf0e10cSrcweir break;
1008cdf0e10cSrcweir case osl::FileBase::E_LOOP:
1009cdf0e10cSrcweir // Too many symbolic links encountered<br>
1010cdf0e10cSrcweir case osl::FileBase::E_FAULT:
1011cdf0e10cSrcweir // Bad address<br>
1012cdf0e10cSrcweir case osl::FileBase::E_IO:
1013cdf0e10cSrcweir // I/O error<br>
1014cdf0e10cSrcweir case osl::FileBase::E_NOSYS:
1015cdf0e10cSrcweir // Function not implemented<br>
1016cdf0e10cSrcweir case osl::FileBase::E_MULTIHOP:
1017cdf0e10cSrcweir // Multihop attempted<br>
1018cdf0e10cSrcweir case osl::FileBase::E_INTR:
1019cdf0e10cSrcweir // function call was interrupted<p>
1020cdf0e10cSrcweir default:
1021cdf0e10cSrcweir ioError = IOErrorCode_GENERAL;
1022cdf0e10cSrcweir break;
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir ret[i] <<= InteractiveAugmentedIOException(
1025cdf0e10cSrcweir rtl::OUString(),
1026cdf0e10cSrcweir 0,
1027cdf0e10cSrcweir task::InteractionClassification_ERROR,
1028cdf0e10cSrcweir ioError,
1029cdf0e10cSrcweir names );
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir else
1033cdf0e10cSrcweir ret[i] <<= beans::IllegalTypeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir } // end for
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir if( propChanged )
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir seqChanged.realloc( propChanged );
1041cdf0e10cSrcweir notifyPropertyChanges( getPropertyChangeNotifier( aUnqPath ),seqChanged );
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir
1044cdf0e10cSrcweir return ret;
1045cdf0e10cSrcweir }
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir /*********************************************************************************/
1048cdf0e10cSrcweir /* */
1049cdf0e10cSrcweir /* getv-Implementation */
1050cdf0e10cSrcweir /* */
1051cdf0e10cSrcweir /*********************************************************************************/
1052cdf0e10cSrcweir //
1053cdf0e10cSrcweir // Reads the values of the properties belonging to fileURL aUnqPath;
1054cdf0e10cSrcweir // Returns an XRow object containing the values in the requested order.
1055cdf0e10cSrcweir //
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir uno::Reference< sdbc::XRow > SAL_CALL
getv(sal_Int32 CommandId,const rtl::OUString & aUnqPath,const uno::Sequence<beans::Property> & properties)1059cdf0e10cSrcweir shell::getv( sal_Int32 CommandId,
1060cdf0e10cSrcweir const rtl::OUString& aUnqPath,
1061cdf0e10cSrcweir const uno::Sequence< beans::Property >& properties )
1062cdf0e10cSrcweir throw()
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir uno::Sequence< uno::Any > seq( properties.getLength() );
1065cdf0e10cSrcweir
1066cdf0e10cSrcweir sal_Int32 n_Mask;
1067cdf0e10cSrcweir getMaskFromProperties( n_Mask,properties );
1068cdf0e10cSrcweir osl::FileStatus aFileStatus( n_Mask );
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir osl::DirectoryItem aDirItem;
1071cdf0e10cSrcweir osl::FileBase::RC nError1 = osl::DirectoryItem::get( aUnqPath,aDirItem );
1072cdf0e10cSrcweir if( nError1 != osl::FileBase::E_None )
1073cdf0e10cSrcweir installError(CommandId,
1074cdf0e10cSrcweir TASKHANDLING_OPEN_FILE_FOR_PAGING, // BEAWARE, REUSED
1075cdf0e10cSrcweir nError1);
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir osl::FileBase::RC nError2 = aDirItem.getFileStatus( aFileStatus );
1078cdf0e10cSrcweir if( nError1 == osl::FileBase::E_None &&
1079cdf0e10cSrcweir nError2 != osl::FileBase::E_None )
1080cdf0e10cSrcweir installError(CommandId,
1081cdf0e10cSrcweir TASKHANDLING_OPEN_FILE_FOR_PAGING, // BEAWARE, REUSED
1082cdf0e10cSrcweir nError2);
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aUnqPath );
1088cdf0e10cSrcweir commit( it,aFileStatus );
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir shell::PropertySet::iterator it1;
1091cdf0e10cSrcweir PropertySet& propset = *(it->second.properties);
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir for( sal_Int32 i = 0; i < seq.getLength(); ++i )
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir MyProperty readProp( properties[i].Name );
1096cdf0e10cSrcweir it1 = propset.find( readProp );
1097cdf0e10cSrcweir if( it1 == propset.end() )
1098cdf0e10cSrcweir seq[i] = uno::Any();
1099cdf0e10cSrcweir else
1100cdf0e10cSrcweir seq[i] = it1->getValue();
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir
1104cdf0e10cSrcweir XRow_impl* p = new XRow_impl( this,seq );
1105cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( p );
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir /********************************************************************************/
1110cdf0e10cSrcweir /* */
1111cdf0e10cSrcweir /* transfer-commandos */
1112cdf0e10cSrcweir /* */
1113cdf0e10cSrcweir /********************************************************************************/
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir /********************************************************************************/
1117cdf0e10cSrcweir /* */
1118cdf0e10cSrcweir /* move-implementation */
1119cdf0e10cSrcweir /* */
1120cdf0e10cSrcweir /********************************************************************************/
1121cdf0e10cSrcweir //
1122cdf0e10cSrcweir // Moves the content belonging to fileURL srcUnqPath to fileURL dstUnqPath.
1123cdf0e10cSrcweir //
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir void SAL_CALL
move(sal_Int32 CommandId,const rtl::OUString srcUnqPath,const rtl::OUString dstUnqPathIn,const sal_Int32 NameClash)1126cdf0e10cSrcweir shell::move( sal_Int32 CommandId,
1127cdf0e10cSrcweir const rtl::OUString srcUnqPath,
1128cdf0e10cSrcweir const rtl::OUString dstUnqPathIn,
1129cdf0e10cSrcweir const sal_Int32 NameClash )
1130cdf0e10cSrcweir throw()
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir // --> #i88446# Method notifyContentExchanged( getContentExchangedEventListeners( srcUnqPath,dstUnqPath,!isDocument ) ); crashes if
1133cdf0e10cSrcweir // srcUnqPath and dstUnqPathIn are equal
1134cdf0e10cSrcweir if( srcUnqPath == dstUnqPathIn )
1135cdf0e10cSrcweir return;
1136cdf0e10cSrcweir // <--
1137cdf0e10cSrcweir //
1138cdf0e10cSrcweir osl::FileBase::RC nError;
1139cdf0e10cSrcweir rtl::OUString dstUnqPath( dstUnqPathIn );
1140cdf0e10cSrcweir
1141cdf0e10cSrcweir switch( NameClash )
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir case NameClash::KEEP:
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true );
1146cdf0e10cSrcweir if( nError != osl::FileBase::E_None && nError != osl::FileBase::E_EXIST )
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir installError( CommandId,
1149cdf0e10cSrcweir TASKHANDLING_KEEPERROR_FOR_MOVE,
1150cdf0e10cSrcweir nError );
1151cdf0e10cSrcweir return;
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir break;
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir case NameClash::OVERWRITE:
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir // stat to determine whether we have a symlink
1158cdf0e10cSrcweir rtl::OUString targetPath(dstUnqPath);
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir osl::FileStatus aStatus(FileStatusMask_Type|FileStatusMask_LinkTargetURL);
1161cdf0e10cSrcweir osl::DirectoryItem aItem;
1162cdf0e10cSrcweir osl::DirectoryItem::get(dstUnqPath,aItem);
1163cdf0e10cSrcweir aItem.getFileStatus(aStatus);
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir if( aStatus.isValid(FileStatusMask_Type) &&
1166cdf0e10cSrcweir aStatus.isValid(FileStatusMask_LinkTargetURL) &&
1167cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Link )
1168cdf0e10cSrcweir targetPath = aStatus.getLinkTargetURL();
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir // Will do nothing if file does not exist.
1171cdf0e10cSrcweir osl::File::remove( targetPath );
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,targetPath );
1174cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir installError( CommandId,
1177cdf0e10cSrcweir TASKHANDLING_OVERWRITE_FOR_MOVE,
1178cdf0e10cSrcweir nError );
1179cdf0e10cSrcweir return;
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir break;
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir case NameClash::RENAME:
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir rtl::OUString newDstUnqPath;
1186cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true );
1187cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir // "invent" a new valid title.
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir sal_Int32 nPos = -1;
1192cdf0e10cSrcweir sal_Int32 nLastDot = dstUnqPath.lastIndexOf( '.' );
1193cdf0e10cSrcweir sal_Int32 nLastSlash = dstUnqPath.lastIndexOf( '/' );
1194cdf0e10cSrcweir if( ( nLastSlash < nLastDot ) // dot is part of last(!) path segment
1195cdf0e10cSrcweir && ( nLastSlash != ( nLastDot - 1 ) ) ) // file name does not start with a dot
1196cdf0e10cSrcweir nPos = nLastDot;
1197cdf0e10cSrcweir else
1198cdf0e10cSrcweir nPos = dstUnqPath.getLength();
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir sal_Int32 nTry = 0;
1201cdf0e10cSrcweir
1202cdf0e10cSrcweir do
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir newDstUnqPath = dstUnqPath;
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir rtl::OUString aPostFix( rtl::OUString::createFromAscii( "_" ) );
1207cdf0e10cSrcweir aPostFix += rtl::OUString::valueOf( ++nTry );
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir newDstUnqPath = newDstUnqPath.replaceAt( nPos, 0, aPostFix );
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,newDstUnqPath,true );
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir while( ( nError == osl::FileBase::E_EXIST ) && ( nTry < 10000 ) );
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir
1216cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir installError( CommandId,
1219cdf0e10cSrcweir TASKHANDLING_RENAME_FOR_MOVE );
1220cdf0e10cSrcweir return;
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir else if( nError != osl::FileBase::E_None )
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir installError( CommandId,
1225cdf0e10cSrcweir TASKHANDLING_RENAMEMOVE_FOR_MOVE,
1226cdf0e10cSrcweir nError );
1227cdf0e10cSrcweir return;
1228cdf0e10cSrcweir }
1229cdf0e10cSrcweir else
1230cdf0e10cSrcweir dstUnqPath = newDstUnqPath;
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir break;
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir case NameClash::ERROR:
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true );
1237cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir installError( CommandId,
1240cdf0e10cSrcweir TASKHANDLING_NAMECLASH_FOR_MOVE );
1241cdf0e10cSrcweir return;
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir else if( nError != osl::FileBase::E_None )
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir installError( CommandId,
1246cdf0e10cSrcweir TASKHANDLING_NAMECLASHMOVE_FOR_MOVE,
1247cdf0e10cSrcweir nError );
1248cdf0e10cSrcweir return;
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir break;
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir case NameClash::ASK:
1253cdf0e10cSrcweir default:
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true );
1256cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1257cdf0e10cSrcweir {
1258cdf0e10cSrcweir installError( CommandId,
1259cdf0e10cSrcweir TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE,
1260cdf0e10cSrcweir NameClash::ASK);
1261cdf0e10cSrcweir return;
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir break;
1265cdf0e10cSrcweir }
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir // Determine, whether we have moved a file or a folder
1268cdf0e10cSrcweir osl::DirectoryItem aItem;
1269cdf0e10cSrcweir nError = osl::DirectoryItem::get( dstUnqPath,aItem );
1270cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir installError( CommandId,
1273cdf0e10cSrcweir TASKHANDLING_TRANSFER_BY_MOVE_SOURCE,
1274cdf0e10cSrcweir nError );
1275cdf0e10cSrcweir return;
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir osl::FileStatus aStatus( FileStatusMask_Type );
1278cdf0e10cSrcweir nError = aItem.getFileStatus( aStatus );
1279cdf0e10cSrcweir if( nError != osl::FileBase::E_None || ! aStatus.isValid( FileStatusMask_Type ) )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir installError( CommandId,
1282cdf0e10cSrcweir TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT,
1283cdf0e10cSrcweir nError );
1284cdf0e10cSrcweir return;
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir sal_Bool isDocument = ( aStatus.getFileType() == osl::FileStatus::Regular );
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir copyPersistentSet( srcUnqPath,dstUnqPath,!isDocument );
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir rtl::OUString aDstParent = getParentName( dstUnqPath );
1292cdf0e10cSrcweir rtl::OUString aDstTitle = getTitle( dstUnqPath );
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir rtl::OUString aSrcParent = getParentName( srcUnqPath );
1295cdf0e10cSrcweir rtl::OUString aSrcTitle = getTitle( srcUnqPath );
1296cdf0e10cSrcweir
1297cdf0e10cSrcweir notifyInsert( getContentEventListeners( aDstParent ),dstUnqPath );
1298cdf0e10cSrcweir if( aDstParent != aSrcParent )
1299cdf0e10cSrcweir notifyContentRemoved( getContentEventListeners( aSrcParent ),srcUnqPath );
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir notifyContentExchanged( getContentExchangedEventListeners( srcUnqPath,dstUnqPath,!isDocument ) );
1302cdf0e10cSrcweir erasePersistentSet( srcUnqPath,!isDocument );
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir
1305cdf0e10cSrcweir
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir /********************************************************************************/
1308cdf0e10cSrcweir /* */
1309cdf0e10cSrcweir /* copy-implementation */
1310cdf0e10cSrcweir /* */
1311cdf0e10cSrcweir /********************************************************************************/
1312cdf0e10cSrcweir //
1313cdf0e10cSrcweir // Copies the content belonging to fileURL srcUnqPath to fileURL dstUnqPath ( files and directories )
1314cdf0e10cSrcweir //
1315cdf0e10cSrcweir
1316cdf0e10cSrcweir namespace {
1317cdf0e10cSrcweir
getType(TaskManager & task,sal_Int32 id,rtl::OUString const & fileUrl,osl::DirectoryItem * item,osl::FileStatus::Type * type)1318cdf0e10cSrcweir bool getType(
1319cdf0e10cSrcweir TaskManager & task, sal_Int32 id, rtl::OUString const & fileUrl,
1320cdf0e10cSrcweir osl::DirectoryItem * item, osl::FileStatus::Type * type)
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir OSL_ASSERT(item != 0 && type != 0);
1323cdf0e10cSrcweir osl::FileBase::RC err = osl::DirectoryItem::get(fileUrl, *item);
1324cdf0e10cSrcweir if (err != osl::FileBase::E_None) {
1325cdf0e10cSrcweir task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCE, err);
1326cdf0e10cSrcweir return false;
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir osl::FileStatus stat(FileStatusMask_Type);
1329cdf0e10cSrcweir err = item->getFileStatus(stat);
1330cdf0e10cSrcweir if (err != osl::FileBase::E_None) {
1331cdf0e10cSrcweir task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT, err);
1332cdf0e10cSrcweir return false;
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir *type = stat.getFileType();
1335cdf0e10cSrcweir return true;
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir
1340cdf0e10cSrcweir void SAL_CALL
copy(sal_Int32 CommandId,const rtl::OUString srcUnqPath,const rtl::OUString dstUnqPathIn,sal_Int32 NameClash)1341cdf0e10cSrcweir shell::copy(
1342cdf0e10cSrcweir sal_Int32 CommandId,
1343cdf0e10cSrcweir const rtl::OUString srcUnqPath,
1344cdf0e10cSrcweir const rtl::OUString dstUnqPathIn,
1345cdf0e10cSrcweir sal_Int32 NameClash )
1346cdf0e10cSrcweir throw()
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir osl::FileBase::RC nError;
1349cdf0e10cSrcweir rtl::OUString dstUnqPath( dstUnqPathIn );
1350cdf0e10cSrcweir
1351cdf0e10cSrcweir // Resolve symbolic links within the source path. If srcUnqPath denotes a
1352cdf0e10cSrcweir // symbolic link (targeting either a file or a folder), the contents of the
1353cdf0e10cSrcweir // target is copied (recursively, in the case of a folder). However, if
1354cdf0e10cSrcweir // recursively copying the contents of a folder causes a symbolic link to be
1355cdf0e10cSrcweir // copied, the symbolic link itself is copied.
1356cdf0e10cSrcweir osl::DirectoryItem item;
1357cdf0e10cSrcweir osl::FileStatus::Type type;
1358cdf0e10cSrcweir if (!getType(*this, CommandId, srcUnqPath, &item, &type)) {
1359cdf0e10cSrcweir return;
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir rtl::OUString rslvdSrcUnqPath;
1362cdf0e10cSrcweir if (type == osl::FileStatus::Link) {
1363cdf0e10cSrcweir osl::FileStatus stat(FileStatusMask_LinkTargetURL);
1364cdf0e10cSrcweir nError = item.getFileStatus(stat);
1365cdf0e10cSrcweir if (nError != osl::FileBase::E_None) {
1366cdf0e10cSrcweir installError(
1367cdf0e10cSrcweir CommandId, TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT, nError);
1368cdf0e10cSrcweir return;
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir rslvdSrcUnqPath = stat.getLinkTargetURL();
1371cdf0e10cSrcweir if (!getType(*this, CommandId, srcUnqPath, &item, &type)) {
1372cdf0e10cSrcweir return;
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir } else {
1375cdf0e10cSrcweir rslvdSrcUnqPath = srcUnqPath;
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir
1378cdf0e10cSrcweir sal_Bool isDocument
1379cdf0e10cSrcweir = type != osl::FileStatus::Directory && type != osl::FileStatus::Volume;
1380cdf0e10cSrcweir sal_Int32 IsWhat = isDocument ? -1 : 1;
1381cdf0e10cSrcweir
1382cdf0e10cSrcweir switch( NameClash )
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir case NameClash::KEEP:
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true );
1387cdf0e10cSrcweir if( nError != osl::FileBase::E_None && nError != osl::FileBase::E_EXIST )
1388cdf0e10cSrcweir {
1389cdf0e10cSrcweir installError( CommandId,
1390cdf0e10cSrcweir TASKHANDLING_KEEPERROR_FOR_COPY,
1391cdf0e10cSrcweir nError );
1392cdf0e10cSrcweir return;
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir break;
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir case NameClash::OVERWRITE:
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir // remove (..., MustExist = sal_False).
1399cdf0e10cSrcweir remove( CommandId, dstUnqPath, IsWhat, sal_False );
1400cdf0e10cSrcweir
1401cdf0e10cSrcweir // copy.
1402cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,false );
1403cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir installError( CommandId,
1406cdf0e10cSrcweir TASKHANDLING_OVERWRITE_FOR_COPY,
1407cdf0e10cSrcweir nError );
1408cdf0e10cSrcweir return;
1409cdf0e10cSrcweir }
1410cdf0e10cSrcweir break;
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir case NameClash::RENAME:
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir rtl::OUString newDstUnqPath;
1415cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true );
1416cdf0e10cSrcweir
1417cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir // "invent" a new valid title.
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir sal_Int32 nPos = -1;
1422cdf0e10cSrcweir sal_Int32 nLastDot = dstUnqPath.lastIndexOf( '.' );
1423cdf0e10cSrcweir sal_Int32 nLastSlash = dstUnqPath.lastIndexOf( '/' );
1424cdf0e10cSrcweir if ( ( nLastSlash < nLastDot ) // dot is part of last(!) path segment
1425cdf0e10cSrcweir && ( nLastSlash != ( nLastDot - 1 ) ) ) // file name does not start with a dot
1426cdf0e10cSrcweir nPos = nLastDot;
1427cdf0e10cSrcweir else
1428cdf0e10cSrcweir nPos = dstUnqPath.getLength();
1429cdf0e10cSrcweir
1430cdf0e10cSrcweir sal_Int32 nTry = 0;
1431cdf0e10cSrcweir
1432cdf0e10cSrcweir do
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir newDstUnqPath = dstUnqPath;
1435cdf0e10cSrcweir
1436cdf0e10cSrcweir rtl::OUString aPostFix( rtl::OUString::createFromAscii( "_" ) );
1437cdf0e10cSrcweir aPostFix += rtl::OUString::valueOf( ++nTry );
1438cdf0e10cSrcweir
1439cdf0e10cSrcweir newDstUnqPath = newDstUnqPath.replaceAt( nPos, 0, aPostFix );
1440cdf0e10cSrcweir
1441cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,newDstUnqPath,IsWhat,true );
1442cdf0e10cSrcweir }
1443cdf0e10cSrcweir while( ( nError == osl::FileBase::E_EXIST ) && ( nTry < 10000 ) );
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir
1446cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1447cdf0e10cSrcweir {
1448cdf0e10cSrcweir installError( CommandId,
1449cdf0e10cSrcweir TASKHANDLING_RENAME_FOR_COPY );
1450cdf0e10cSrcweir return;
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir else if( nError != osl::FileBase::E_None )
1453cdf0e10cSrcweir {
1454cdf0e10cSrcweir installError( CommandId,
1455cdf0e10cSrcweir TASKHANDLING_RENAMEMOVE_FOR_COPY,
1456cdf0e10cSrcweir nError );
1457cdf0e10cSrcweir return;
1458cdf0e10cSrcweir }
1459cdf0e10cSrcweir else
1460cdf0e10cSrcweir dstUnqPath = newDstUnqPath;
1461cdf0e10cSrcweir
1462cdf0e10cSrcweir break;
1463cdf0e10cSrcweir }
1464cdf0e10cSrcweir case NameClash::ERROR:
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true );
1467cdf0e10cSrcweir
1468cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir installError( CommandId,
1471cdf0e10cSrcweir TASKHANDLING_NAMECLASH_FOR_COPY );
1472cdf0e10cSrcweir return;
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir else if( nError != osl::FileBase::E_None )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir installError( CommandId,
1477cdf0e10cSrcweir TASKHANDLING_NAMECLASHMOVE_FOR_COPY,
1478cdf0e10cSrcweir nError );
1479cdf0e10cSrcweir return;
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir break;
1482cdf0e10cSrcweir }
1483cdf0e10cSrcweir case NameClash::ASK:
1484cdf0e10cSrcweir default:
1485cdf0e10cSrcweir {
1486cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true );
1487cdf0e10cSrcweir
1488cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST )
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir installError( CommandId,
1491cdf0e10cSrcweir TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY,
1492cdf0e10cSrcweir NameClash);
1493cdf0e10cSrcweir return;
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir break;
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir
1499cdf0e10cSrcweir copyPersistentSet( srcUnqPath,dstUnqPath, !isDocument );
1500cdf0e10cSrcweir notifyInsert( getContentEventListeners( getParentName( dstUnqPath ) ),dstUnqPath );
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir
1504cdf0e10cSrcweir
1505cdf0e10cSrcweir /********************************************************************************/
1506cdf0e10cSrcweir /* */
1507cdf0e10cSrcweir /* remove-implementation */
1508cdf0e10cSrcweir /* */
1509cdf0e10cSrcweir /********************************************************************************/
1510cdf0e10cSrcweir //
1511cdf0e10cSrcweir // Deletes the content belonging to fileURL aUnqPath( recursively in case of directory )
1512cdf0e10cSrcweir // Return: success of operation
1513cdf0e10cSrcweir //
1514cdf0e10cSrcweir
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir sal_Bool SAL_CALL
remove(sal_Int32 CommandId,const rtl::OUString & aUnqPath,sal_Int32 IsWhat,sal_Bool MustExist)1517cdf0e10cSrcweir shell::remove( sal_Int32 CommandId,
1518cdf0e10cSrcweir const rtl::OUString& aUnqPath,
1519cdf0e10cSrcweir sal_Int32 IsWhat,
1520cdf0e10cSrcweir sal_Bool MustExist )
1521cdf0e10cSrcweir throw()
1522cdf0e10cSrcweir {
1523cdf0e10cSrcweir sal_Int32 nMask = FileStatusMask_Type | FileStatusMask_FileURL;
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir osl::DirectoryItem aItem;
1526cdf0e10cSrcweir osl::FileStatus aStatus( nMask );
1527cdf0e10cSrcweir osl::FileBase::RC nError;
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir if( IsWhat == 0 ) // Determine whether we are removing a directory or a file
1530cdf0e10cSrcweir {
1531cdf0e10cSrcweir nError = osl::DirectoryItem::get( aUnqPath, aItem );
1532cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir if (MustExist)
1535cdf0e10cSrcweir {
1536cdf0e10cSrcweir installError( CommandId,
1537cdf0e10cSrcweir TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE,
1538cdf0e10cSrcweir nError );
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir return (!MustExist);
1541cdf0e10cSrcweir }
1542cdf0e10cSrcweir
1543cdf0e10cSrcweir nError = aItem.getFileStatus( aStatus );
1544cdf0e10cSrcweir if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) )
1545cdf0e10cSrcweir {
1546cdf0e10cSrcweir installError( CommandId,
1547cdf0e10cSrcweir TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE,
1548cdf0e10cSrcweir nError != osl::FileBase::E_None ? nError : TASKHANDLER_NO_ERROR );
1549cdf0e10cSrcweir return sal_False;
1550cdf0e10cSrcweir }
1551cdf0e10cSrcweir
1552cdf0e10cSrcweir if( aStatus.getFileType() == osl::FileStatus::Regular ||
1553cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Link )
1554cdf0e10cSrcweir IsWhat = -1; // RemoveFile
1555cdf0e10cSrcweir else if( aStatus.getFileType() == osl::FileStatus::Directory ||
1556cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Volume )
1557cdf0e10cSrcweir IsWhat = +1; // RemoveDirectory
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir
1560cdf0e10cSrcweir
1561cdf0e10cSrcweir if( IsWhat == -1 ) // Removing a file
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir nError = osl::File::remove( aUnqPath );
1564cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir if (MustExist)
1567cdf0e10cSrcweir {
1568cdf0e10cSrcweir installError( CommandId,
1569cdf0e10cSrcweir TASKHANDLING_DELETEFILE_FOR_REMOVE,
1570cdf0e10cSrcweir nError );
1571cdf0e10cSrcweir }
1572cdf0e10cSrcweir return (!MustExist);
1573cdf0e10cSrcweir }
1574cdf0e10cSrcweir else
1575cdf0e10cSrcweir {
1576cdf0e10cSrcweir notifyContentDeleted( getContentDeletedEventListeners(aUnqPath) );
1577cdf0e10cSrcweir erasePersistentSet( aUnqPath ); // Removes from XPersistentPropertySet
1578cdf0e10cSrcweir }
1579cdf0e10cSrcweir }
1580cdf0e10cSrcweir else if( IsWhat == +1 ) // Removing a directory
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir osl::Directory aDirectory( aUnqPath );
1583cdf0e10cSrcweir
1584cdf0e10cSrcweir nError = aDirectory.open();
1585cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1586cdf0e10cSrcweir {
1587cdf0e10cSrcweir if (MustExist)
1588cdf0e10cSrcweir {
1589cdf0e10cSrcweir installError( CommandId,
1590cdf0e10cSrcweir TASKHANDLING_OPENDIRECTORY_FOR_REMOVE,
1591cdf0e10cSrcweir nError );
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir return (!MustExist);
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir
1596cdf0e10cSrcweir sal_Bool whileSuccess = sal_True;
1597cdf0e10cSrcweir sal_Int32 recurse = 0;
1598cdf0e10cSrcweir rtl::OUString name;
1599cdf0e10cSrcweir
1600cdf0e10cSrcweir nError = aDirectory.getNextItem( aItem );
1601cdf0e10cSrcweir while( nError == osl::FileBase::E_None )
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir nError = aItem.getFileStatus( aStatus );
1604cdf0e10cSrcweir if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) )
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir installError( CommandId,
1607cdf0e10cSrcweir TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE,
1608cdf0e10cSrcweir nError != osl::FileBase::E_None ? nError : TASKHANDLER_NO_ERROR );
1609cdf0e10cSrcweir whileSuccess = sal_False;
1610cdf0e10cSrcweir break;
1611cdf0e10cSrcweir }
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir if( aStatus.getFileType() == osl::FileStatus::Regular ||
1614cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Link )
1615cdf0e10cSrcweir recurse = -1;
1616cdf0e10cSrcweir else if( aStatus.getFileType() == osl::FileStatus::Directory ||
1617cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Volume )
1618cdf0e10cSrcweir recurse = +1;
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir name = aStatus.getFileURL();
1621cdf0e10cSrcweir whileSuccess = remove(
1622cdf0e10cSrcweir CommandId, name, recurse, MustExist );
1623cdf0e10cSrcweir if( !whileSuccess )
1624cdf0e10cSrcweir break;
1625cdf0e10cSrcweir
1626cdf0e10cSrcweir nError = aDirectory.getNextItem( aItem );
1627cdf0e10cSrcweir }
1628cdf0e10cSrcweir
1629cdf0e10cSrcweir aDirectory.close();
1630cdf0e10cSrcweir
1631cdf0e10cSrcweir if( ! whileSuccess )
1632cdf0e10cSrcweir return sal_False; // error code is installed
1633cdf0e10cSrcweir
1634cdf0e10cSrcweir if( nError != osl::FileBase::E_NOENT )
1635cdf0e10cSrcweir {
1636cdf0e10cSrcweir installError( CommandId,
1637cdf0e10cSrcweir TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE,
1638cdf0e10cSrcweir nError );
1639cdf0e10cSrcweir return sal_False;
1640cdf0e10cSrcweir }
1641cdf0e10cSrcweir
1642cdf0e10cSrcweir nError = osl::Directory::remove( aUnqPath );
1643cdf0e10cSrcweir if( nError != osl::FileBase::E_None )
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir if (MustExist)
1646cdf0e10cSrcweir {
1647cdf0e10cSrcweir installError( CommandId,
1648cdf0e10cSrcweir TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE,
1649cdf0e10cSrcweir nError );
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir return (!MustExist);
1652cdf0e10cSrcweir }
1653cdf0e10cSrcweir else
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir notifyContentDeleted( getContentDeletedEventListeners(aUnqPath) );
1656cdf0e10cSrcweir erasePersistentSet( aUnqPath );
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir }
1659cdf0e10cSrcweir else // Don't know what to remove
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir installError( CommandId,
1662cdf0e10cSrcweir TASKHANDLING_FILETYPE_FOR_REMOVE );
1663cdf0e10cSrcweir return sal_False;
1664cdf0e10cSrcweir }
1665cdf0e10cSrcweir
1666cdf0e10cSrcweir return sal_True;
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir
1669cdf0e10cSrcweir
1670cdf0e10cSrcweir /********************************************************************************/
1671cdf0e10cSrcweir /* */
1672cdf0e10cSrcweir /* mkdir-implementation */
1673cdf0e10cSrcweir /* */
1674cdf0e10cSrcweir /********************************************************************************/
1675cdf0e10cSrcweir //
1676cdf0e10cSrcweir // Creates new directory with given URL, recursively if necessary
1677cdf0e10cSrcweir // Return:: success of operation
1678cdf0e10cSrcweir //
1679cdf0e10cSrcweir
1680cdf0e10cSrcweir sal_Bool SAL_CALL
mkdir(sal_Int32 CommandId,const rtl::OUString & rUnqPath,sal_Bool OverWrite)1681cdf0e10cSrcweir shell::mkdir( sal_Int32 CommandId,
1682cdf0e10cSrcweir const rtl::OUString& rUnqPath,
1683cdf0e10cSrcweir sal_Bool OverWrite )
1684cdf0e10cSrcweir throw()
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir rtl::OUString aUnqPath;
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir // remove trailing slash
1689cdf0e10cSrcweir if ( rUnqPath[ rUnqPath.getLength() - 1 ] == sal_Unicode( '/' ) )
1690cdf0e10cSrcweir aUnqPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 );
1691cdf0e10cSrcweir else
1692cdf0e10cSrcweir aUnqPath = rUnqPath;
1693cdf0e10cSrcweir
1694cdf0e10cSrcweir osl::FileBase::RC nError = osl::Directory::create( aUnqPath );
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir switch ( nError )
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir case osl::FileBase::E_EXIST: // Directory cannot be overwritten
1699cdf0e10cSrcweir {
1700cdf0e10cSrcweir if( !OverWrite )
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir installError( CommandId,
1703cdf0e10cSrcweir TASKHANDLING_FOLDER_EXISTS_MKDIR );
1704cdf0e10cSrcweir return sal_False;
1705cdf0e10cSrcweir }
1706cdf0e10cSrcweir else
1707cdf0e10cSrcweir return sal_True;
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir case osl::FileBase::E_INVAL:
1710cdf0e10cSrcweir {
1711cdf0e10cSrcweir installError(CommandId,
1712cdf0e10cSrcweir TASKHANDLING_INVALID_NAME_MKDIR);
1713cdf0e10cSrcweir return sal_False;
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir case osl::FileBase::E_None:
1716cdf0e10cSrcweir {
1717cdf0e10cSrcweir rtl::OUString aPrtPath = getParentName( aUnqPath );
1718cdf0e10cSrcweir notifyInsert( getContentEventListeners( aPrtPath ),aUnqPath );
1719cdf0e10cSrcweir return sal_True;
1720cdf0e10cSrcweir }
1721cdf0e10cSrcweir default:
1722cdf0e10cSrcweir return ensuredir(
1723cdf0e10cSrcweir CommandId,
1724cdf0e10cSrcweir aUnqPath,
1725cdf0e10cSrcweir TASKHANDLING_CREATEDIRECTORY_MKDIR );
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir }
1728cdf0e10cSrcweir
1729cdf0e10cSrcweir
1730cdf0e10cSrcweir /********************************************************************************/
1731cdf0e10cSrcweir /* */
1732cdf0e10cSrcweir /* mkfil-implementation */
1733cdf0e10cSrcweir /* */
1734cdf0e10cSrcweir /********************************************************************************/
1735cdf0e10cSrcweir //
1736cdf0e10cSrcweir // Creates new file with given URL.
1737cdf0e10cSrcweir // The content of aInputStream becomes the content of the file
1738cdf0e10cSrcweir // Return:: success of operation
1739cdf0e10cSrcweir //
1740cdf0e10cSrcweir
1741cdf0e10cSrcweir sal_Bool SAL_CALL
mkfil(sal_Int32 CommandId,const rtl::OUString & aUnqPath,sal_Bool Overwrite,const uno::Reference<io::XInputStream> & aInputStream)1742cdf0e10cSrcweir shell::mkfil( sal_Int32 CommandId,
1743cdf0e10cSrcweir const rtl::OUString& aUnqPath,
1744cdf0e10cSrcweir sal_Bool Overwrite,
1745cdf0e10cSrcweir const uno::Reference< io::XInputStream >& aInputStream )
1746cdf0e10cSrcweir throw()
1747cdf0e10cSrcweir {
1748cdf0e10cSrcweir // return value unimportant
1749cdf0e10cSrcweir sal_Bool bSuccess = write( CommandId,
1750cdf0e10cSrcweir aUnqPath,
1751cdf0e10cSrcweir Overwrite,
1752cdf0e10cSrcweir aInputStream );
1753cdf0e10cSrcweir if ( bSuccess )
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir rtl::OUString aPrtPath = getParentName( aUnqPath );
1756cdf0e10cSrcweir notifyInsert( getContentEventListeners( aPrtPath ),aUnqPath );
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir return bSuccess;
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir
1761cdf0e10cSrcweir
1762cdf0e10cSrcweir /********************************************************************************/
1763cdf0e10cSrcweir /* */
1764cdf0e10cSrcweir /* write-implementation */
1765cdf0e10cSrcweir /* */
1766cdf0e10cSrcweir /********************************************************************************/
1767cdf0e10cSrcweir //
1768cdf0e10cSrcweir // writes to the file with given URL.
1769cdf0e10cSrcweir // The content of aInputStream becomes the content of the file
1770cdf0e10cSrcweir // Return:: success of operation
1771cdf0e10cSrcweir //
1772cdf0e10cSrcweir
1773cdf0e10cSrcweir sal_Bool SAL_CALL
write(sal_Int32 CommandId,const rtl::OUString & aUnqPath,sal_Bool OverWrite,const uno::Reference<io::XInputStream> & aInputStream)1774cdf0e10cSrcweir shell::write( sal_Int32 CommandId,
1775cdf0e10cSrcweir const rtl::OUString& aUnqPath,
1776cdf0e10cSrcweir sal_Bool OverWrite,
1777cdf0e10cSrcweir const uno::Reference< io::XInputStream >& aInputStream )
1778cdf0e10cSrcweir throw()
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir if( ! aInputStream.is() )
1781cdf0e10cSrcweir {
1782cdf0e10cSrcweir installError( CommandId,
1783cdf0e10cSrcweir TASKHANDLING_INPUTSTREAM_FOR_WRITE );
1784cdf0e10cSrcweir return sal_False;
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir
1787cdf0e10cSrcweir // Create parent path, if necessary.
1788cdf0e10cSrcweir if ( ! ensuredir( CommandId,
1789cdf0e10cSrcweir getParentName( aUnqPath ),
1790cdf0e10cSrcweir TASKHANDLING_ENSUREDIR_FOR_WRITE ) )
1791cdf0e10cSrcweir return sal_False;
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir osl::FileBase::RC err;
1794cdf0e10cSrcweir osl::File aFile( aUnqPath );
1795cdf0e10cSrcweir
1796cdf0e10cSrcweir if( OverWrite )
1797cdf0e10cSrcweir {
1798cdf0e10cSrcweir err = aFile.open( OpenFlag_Write | OpenFlag_Create );
1799cdf0e10cSrcweir
1800cdf0e10cSrcweir if( err != osl::FileBase::E_None )
1801cdf0e10cSrcweir {
1802cdf0e10cSrcweir aFile.close();
1803cdf0e10cSrcweir err = aFile.open( OpenFlag_Write );
1804cdf0e10cSrcweir
1805cdf0e10cSrcweir if( err != osl::FileBase::E_None )
1806cdf0e10cSrcweir {
1807cdf0e10cSrcweir installError( CommandId,
1808cdf0e10cSrcweir TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE,
1809cdf0e10cSrcweir err );
1810cdf0e10cSrcweir return sal_False;
1811cdf0e10cSrcweir }
1812cdf0e10cSrcweir
1813cdf0e10cSrcweir // the existing file was just opened and should be overwritten now,
1814cdf0e10cSrcweir // truncate it first
1815cdf0e10cSrcweir
1816cdf0e10cSrcweir err = aFile.setSize( 0 );
1817cdf0e10cSrcweir if( err != osl::FileBase::E_None )
1818cdf0e10cSrcweir {
1819cdf0e10cSrcweir installError( CommandId,
1820cdf0e10cSrcweir TASKHANDLING_FILESIZE_FOR_WRITE,
1821cdf0e10cSrcweir err );
1822cdf0e10cSrcweir return sal_False;
1823cdf0e10cSrcweir }
1824cdf0e10cSrcweir }
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir else
1827cdf0e10cSrcweir {
1828cdf0e10cSrcweir err = aFile.open( OpenFlag_Read | OpenFlag_NoLock );
1829cdf0e10cSrcweir if( err == osl::FileBase::E_None ) // The file exists and shall not be overwritten
1830cdf0e10cSrcweir {
1831cdf0e10cSrcweir installError( CommandId,
1832cdf0e10cSrcweir TASKHANDLING_NOREPLACE_FOR_WRITE, // Now an exception
1833cdf0e10cSrcweir err );
1834cdf0e10cSrcweir
1835cdf0e10cSrcweir aFile.close();
1836cdf0e10cSrcweir return sal_False;
1837cdf0e10cSrcweir }
1838cdf0e10cSrcweir
1839cdf0e10cSrcweir // as a temporary solution the creation does not lock the file at all
1840cdf0e10cSrcweir // in future it should be possible to create the file without lock explicitly
1841cdf0e10cSrcweir err = aFile.open( OpenFlag_Write | OpenFlag_Create | OpenFlag_NoLock );
1842cdf0e10cSrcweir
1843cdf0e10cSrcweir if( err != osl::FileBase::E_None )
1844cdf0e10cSrcweir {
1845cdf0e10cSrcweir aFile.close();
1846cdf0e10cSrcweir installError( CommandId,
1847cdf0e10cSrcweir TASKHANDLING_NO_OPEN_FILE_FOR_WRITE,
1848cdf0e10cSrcweir err );
1849cdf0e10cSrcweir return sal_False;
1850cdf0e10cSrcweir }
1851cdf0e10cSrcweir }
1852cdf0e10cSrcweir
1853cdf0e10cSrcweir sal_Bool bSuccess = sal_True;
1854cdf0e10cSrcweir
1855cdf0e10cSrcweir sal_uInt64 nWrittenBytes;
1856cdf0e10cSrcweir sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/;
1857cdf0e10cSrcweir uno::Sequence< sal_Int8 > seq( nRequestedBytes );
1858cdf0e10cSrcweir
1859cdf0e10cSrcweir do
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir try
1862cdf0e10cSrcweir {
1863cdf0e10cSrcweir nReadBytes = aInputStream->readBytes( seq,
1864cdf0e10cSrcweir nRequestedBytes );
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir catch( const io::NotConnectedException& )
1867cdf0e10cSrcweir {
1868cdf0e10cSrcweir installError( CommandId,
1869cdf0e10cSrcweir TASKHANDLING_NOTCONNECTED_FOR_WRITE );
1870cdf0e10cSrcweir bSuccess = sal_False;
1871cdf0e10cSrcweir break;
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir catch( const io::BufferSizeExceededException& )
1874cdf0e10cSrcweir {
1875cdf0e10cSrcweir installError( CommandId,
1876cdf0e10cSrcweir TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE );
1877cdf0e10cSrcweir bSuccess = sal_False;
1878cdf0e10cSrcweir break;
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir catch( const io::IOException& )
1881cdf0e10cSrcweir {
1882cdf0e10cSrcweir installError( CommandId,
1883cdf0e10cSrcweir TASKHANDLING_IOEXCEPTION_FOR_WRITE );
1884cdf0e10cSrcweir bSuccess = sal_False;
1885cdf0e10cSrcweir break;
1886cdf0e10cSrcweir }
1887cdf0e10cSrcweir
1888cdf0e10cSrcweir if( nReadBytes )
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir const sal_Int8* p = seq.getConstArray();
1891cdf0e10cSrcweir
1892cdf0e10cSrcweir err = aFile.write( ((void*)(p)),
1893cdf0e10cSrcweir sal_uInt64( nReadBytes ),
1894cdf0e10cSrcweir nWrittenBytes );
1895cdf0e10cSrcweir
1896cdf0e10cSrcweir if( err != osl::FileBase::E_None )
1897cdf0e10cSrcweir {
1898cdf0e10cSrcweir installError( CommandId,
1899cdf0e10cSrcweir TASKHANDLING_FILEIOERROR_FOR_WRITE,
1900cdf0e10cSrcweir err );
1901cdf0e10cSrcweir bSuccess = sal_False;
1902cdf0e10cSrcweir break;
1903cdf0e10cSrcweir }
1904cdf0e10cSrcweir else if( nWrittenBytes != sal_uInt64( nReadBytes ) )
1905cdf0e10cSrcweir {
1906cdf0e10cSrcweir installError( CommandId,
1907cdf0e10cSrcweir TASKHANDLING_FILEIOERROR_FOR_NO_SPACE );
1908cdf0e10cSrcweir bSuccess = sal_False;
1909cdf0e10cSrcweir break;
1910cdf0e10cSrcweir }
1911cdf0e10cSrcweir }
1912cdf0e10cSrcweir } while( nReadBytes == nRequestedBytes );
1913cdf0e10cSrcweir
1914cdf0e10cSrcweir err = aFile.close();
1915cdf0e10cSrcweir if( err != osl::FileBase::E_None )
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir installError( CommandId,
1918cdf0e10cSrcweir TASKHANDLING_FILEIOERROR_FOR_WRITE,
1919cdf0e10cSrcweir err );
1920cdf0e10cSrcweir bSuccess = sal_False;
1921cdf0e10cSrcweir }
1922cdf0e10cSrcweir
1923cdf0e10cSrcweir return bSuccess;
1924cdf0e10cSrcweir }
1925cdf0e10cSrcweir
1926cdf0e10cSrcweir
1927cdf0e10cSrcweir
1928cdf0e10cSrcweir /*********************************************************************************/
1929cdf0e10cSrcweir /* */
1930cdf0e10cSrcweir /* insertDefaultProperties-Implementation */
1931cdf0e10cSrcweir /* */
1932cdf0e10cSrcweir /*********************************************************************************/
1933cdf0e10cSrcweir
1934cdf0e10cSrcweir
insertDefaultProperties(const rtl::OUString & aUnqPath)1935cdf0e10cSrcweir void SAL_CALL shell::insertDefaultProperties( const rtl::OUString& aUnqPath )
1936cdf0e10cSrcweir {
1937cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1938cdf0e10cSrcweir
1939cdf0e10cSrcweir ContentMap::iterator it =
1940cdf0e10cSrcweir m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first;
1941cdf0e10cSrcweir
1942cdf0e10cSrcweir load( it,false );
1943cdf0e10cSrcweir
1944cdf0e10cSrcweir MyProperty ContentTProperty( ContentType );
1945cdf0e10cSrcweir
1946cdf0e10cSrcweir PropertySet& properties = *(it->second.properties);
1947cdf0e10cSrcweir sal_Bool ContentNotDefau = properties.find( ContentTProperty ) != properties.end();
1948cdf0e10cSrcweir
1949cdf0e10cSrcweir shell::PropertySet::iterator it1 = m_aDefaultProperties.begin();
1950cdf0e10cSrcweir while( it1 != m_aDefaultProperties.end() )
1951cdf0e10cSrcweir {
1952cdf0e10cSrcweir if( ContentNotDefau && it1->getPropertyName() == ContentType )
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir // No insertion
1955cdf0e10cSrcweir }
1956cdf0e10cSrcweir else
1957cdf0e10cSrcweir properties.insert( *it1 );
1958cdf0e10cSrcweir ++it1;
1959cdf0e10cSrcweir }
1960cdf0e10cSrcweir }
1961cdf0e10cSrcweir
1962cdf0e10cSrcweir
1963cdf0e10cSrcweir
1964cdf0e10cSrcweir
1965cdf0e10cSrcweir /******************************************************************************/
1966cdf0e10cSrcweir /* */
1967cdf0e10cSrcweir /* mapping of file urls */
1968cdf0e10cSrcweir /* to uncpath and vice versa */
1969cdf0e10cSrcweir /* */
1970cdf0e10cSrcweir /******************************************************************************/
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir
getUnqFromUrl(const rtl::OUString & Url,rtl::OUString & Unq)1973cdf0e10cSrcweir sal_Bool SAL_CALL shell::getUnqFromUrl( const rtl::OUString& Url,rtl::OUString& Unq )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir if( 0 == Url.compareToAscii( "file:///" ) ||
1976cdf0e10cSrcweir 0 == Url.compareToAscii( "file://localhost/" ) ||
1977cdf0e10cSrcweir 0 == Url.compareToAscii( "file://127.0.0.1/" ) )
1978cdf0e10cSrcweir {
1979cdf0e10cSrcweir Unq = rtl::OUString::createFromAscii( "file:///" );
1980cdf0e10cSrcweir return false;
1981cdf0e10cSrcweir }
1982cdf0e10cSrcweir
1983cdf0e10cSrcweir sal_Bool err = osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( Url,Unq );
1984cdf0e10cSrcweir
1985cdf0e10cSrcweir Unq = Url;
1986cdf0e10cSrcweir
1987cdf0e10cSrcweir sal_Int32 l = Unq.getLength()-1;
1988cdf0e10cSrcweir if( ! err && Unq.getStr()[ l ] == '/' &&
1989cdf0e10cSrcweir Unq.indexOf( '/', RTL_CONSTASCII_LENGTH("//") ) < l )
1990cdf0e10cSrcweir Unq = Unq.copy(0, Unq.getLength() - 1);
1991cdf0e10cSrcweir
1992cdf0e10cSrcweir return err;
1993cdf0e10cSrcweir }
1994cdf0e10cSrcweir
1995cdf0e10cSrcweir
1996cdf0e10cSrcweir
getUrlFromUnq(const rtl::OUString & Unq,rtl::OUString & Url)1997cdf0e10cSrcweir sal_Bool SAL_CALL shell::getUrlFromUnq( const rtl::OUString& Unq,rtl::OUString& Url )
1998cdf0e10cSrcweir {
1999cdf0e10cSrcweir sal_Bool err = osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( Unq,Url );
2000cdf0e10cSrcweir
2001cdf0e10cSrcweir Url = Unq;
2002cdf0e10cSrcweir
2003cdf0e10cSrcweir return err;
2004cdf0e10cSrcweir }
2005cdf0e10cSrcweir
2006cdf0e10cSrcweir
2007cdf0e10cSrcweir
2008cdf0e10cSrcweir // Helper function for public copy
2009cdf0e10cSrcweir
2010cdf0e10cSrcweir osl::FileBase::RC SAL_CALL
copy_recursive(const rtl::OUString & srcUnqPath,const rtl::OUString & dstUnqPath,sal_Int32 TypeToCopy,sal_Bool testExistBeforeCopy)2011cdf0e10cSrcweir shell::copy_recursive( const rtl::OUString& srcUnqPath,
2012cdf0e10cSrcweir const rtl::OUString& dstUnqPath,
2013cdf0e10cSrcweir sal_Int32 TypeToCopy,
2014cdf0e10cSrcweir sal_Bool testExistBeforeCopy )
2015cdf0e10cSrcweir throw()
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir osl::FileBase::RC err = osl::FileBase::E_None;
2018cdf0e10cSrcweir
2019cdf0e10cSrcweir if( TypeToCopy == -1 ) // Document
2020cdf0e10cSrcweir {
2021cdf0e10cSrcweir err = osl_File_copy( srcUnqPath,dstUnqPath,testExistBeforeCopy );
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir else if( TypeToCopy == +1 ) // Folder
2024cdf0e10cSrcweir {
2025cdf0e10cSrcweir osl::Directory aDir( srcUnqPath );
2026cdf0e10cSrcweir aDir.open();
2027cdf0e10cSrcweir
2028cdf0e10cSrcweir err = osl::Directory::create( dstUnqPath );
2029cdf0e10cSrcweir osl::FileBase::RC next = err;
2030cdf0e10cSrcweir if( err == osl::FileBase::E_None )
2031cdf0e10cSrcweir {
2032cdf0e10cSrcweir sal_Int32 n_Mask = FileStatusMask_FileURL | FileStatusMask_FileName | FileStatusMask_Type;
2033cdf0e10cSrcweir
2034cdf0e10cSrcweir osl::DirectoryItem aDirItem;
2035cdf0e10cSrcweir
2036cdf0e10cSrcweir while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None )
2037cdf0e10cSrcweir {
2038cdf0e10cSrcweir sal_Bool IsDoc = false;
2039cdf0e10cSrcweir osl::FileStatus aFileStatus( n_Mask );
2040cdf0e10cSrcweir aDirItem.getFileStatus( aFileStatus );
2041cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Type ) )
2042cdf0e10cSrcweir IsDoc = aFileStatus.getFileType() == osl::FileStatus::Regular;
2043cdf0e10cSrcweir
2044cdf0e10cSrcweir // Getting the information for the next recursive copy
2045cdf0e10cSrcweir sal_Int32 newTypeToCopy = IsDoc ? -1 : +1;
2046cdf0e10cSrcweir
2047cdf0e10cSrcweir rtl::OUString newSrcUnqPath;
2048cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileURL ) )
2049cdf0e10cSrcweir newSrcUnqPath = aFileStatus.getFileURL();
2050cdf0e10cSrcweir
2051cdf0e10cSrcweir rtl::OUString newDstUnqPath = dstUnqPath;
2052cdf0e10cSrcweir rtl::OUString tit;
2053cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileName ) )
2054cdf0e10cSrcweir tit = rtl::Uri::encode( aFileStatus.getFileName(),
2055cdf0e10cSrcweir rtl_UriCharClassPchar,
2056cdf0e10cSrcweir rtl_UriEncodeIgnoreEscapes,
2057cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 );
2058cdf0e10cSrcweir
2059cdf0e10cSrcweir if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 )
2060cdf0e10cSrcweir newDstUnqPath += rtl::OUString::createFromAscii( "/" );
2061cdf0e10cSrcweir
2062cdf0e10cSrcweir newDstUnqPath += tit;
2063cdf0e10cSrcweir
2064cdf0e10cSrcweir if ( newSrcUnqPath != dstUnqPath )
2065cdf0e10cSrcweir err = copy_recursive( newSrcUnqPath,newDstUnqPath,newTypeToCopy,false );
2066cdf0e10cSrcweir }
2067cdf0e10cSrcweir
2068cdf0e10cSrcweir if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT )
2069cdf0e10cSrcweir err = next;
2070cdf0e10cSrcweir }
2071cdf0e10cSrcweir aDir.close();
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir
2074cdf0e10cSrcweir return err;
2075cdf0e10cSrcweir }
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir
2078cdf0e10cSrcweir
2079cdf0e10cSrcweir // Helper function for mkfil,mkdir and write
2080cdf0e10cSrcweir // Creates whole path
2081cdf0e10cSrcweir // returns success of the operation
2082cdf0e10cSrcweir
2083cdf0e10cSrcweir
ensuredir(sal_Int32 CommandId,const rtl::OUString & rUnqPath,sal_Int32 errorCode)2084cdf0e10cSrcweir sal_Bool SAL_CALL shell::ensuredir( sal_Int32 CommandId,
2085cdf0e10cSrcweir const rtl::OUString& rUnqPath,
2086cdf0e10cSrcweir sal_Int32 errorCode )
2087cdf0e10cSrcweir throw()
2088cdf0e10cSrcweir {
2089cdf0e10cSrcweir rtl::OUString aPath;
2090cdf0e10cSrcweir
2091cdf0e10cSrcweir if ( rUnqPath.getLength() < 1 )
2092cdf0e10cSrcweir return sal_False;
2093cdf0e10cSrcweir
2094cdf0e10cSrcweir if ( rUnqPath[ rUnqPath.getLength() - 1 ] == sal_Unicode( '/' ) )
2095cdf0e10cSrcweir aPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 );
2096cdf0e10cSrcweir else
2097cdf0e10cSrcweir aPath = rUnqPath;
2098cdf0e10cSrcweir
2099cdf0e10cSrcweir
2100cdf0e10cSrcweir // HACK: create directory on a mount point with nobrowse option
2101cdf0e10cSrcweir // returns ENOSYS in any case !!
2102cdf0e10cSrcweir osl::Directory aDirectory( aPath );
2103cdf0e10cSrcweir osl::FileBase::RC nError = aDirectory.open();
2104cdf0e10cSrcweir aDirectory.close();
2105cdf0e10cSrcweir
2106cdf0e10cSrcweir if( nError == osl::File::E_None )
2107cdf0e10cSrcweir return sal_True;
2108cdf0e10cSrcweir
2109cdf0e10cSrcweir nError = osl::Directory::create( aPath );
2110cdf0e10cSrcweir
2111cdf0e10cSrcweir if( nError == osl::File::E_None )
2112cdf0e10cSrcweir notifyInsert( getContentEventListeners( getParentName( aPath ) ),aPath );
2113cdf0e10cSrcweir
2114cdf0e10cSrcweir sal_Bool bSuccess = ( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST );
2115cdf0e10cSrcweir
2116cdf0e10cSrcweir if( ! bSuccess )
2117cdf0e10cSrcweir {
2118cdf0e10cSrcweir rtl::OUString aParentDir = getParentName( aPath );
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir if ( aParentDir != aPath )
2121cdf0e10cSrcweir { // Create first the parent directory
2122cdf0e10cSrcweir bSuccess = ensuredir( CommandId,
2123cdf0e10cSrcweir getParentName( aPath ),
2124cdf0e10cSrcweir errorCode );
2125cdf0e10cSrcweir
2126cdf0e10cSrcweir // After parent directory structure exists try it one's more
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir if ( bSuccess )
2129cdf0e10cSrcweir { // Parent directory exists, retry creation of directory
2130cdf0e10cSrcweir nError = osl::Directory::create( aPath );
2131cdf0e10cSrcweir
2132cdf0e10cSrcweir if( nError == osl::File::E_None )
2133cdf0e10cSrcweir notifyInsert( getContentEventListeners( getParentName( aPath ) ),aPath );
2134cdf0e10cSrcweir
2135cdf0e10cSrcweir bSuccess =( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST );
2136cdf0e10cSrcweir }
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir }
2139cdf0e10cSrcweir
2140cdf0e10cSrcweir if( ! bSuccess )
2141cdf0e10cSrcweir installError( CommandId,
2142cdf0e10cSrcweir errorCode,
2143cdf0e10cSrcweir nError );
2144cdf0e10cSrcweir
2145cdf0e10cSrcweir return bSuccess;
2146cdf0e10cSrcweir }
2147cdf0e10cSrcweir
2148cdf0e10cSrcweir
2149cdf0e10cSrcweir
2150cdf0e10cSrcweir
2151cdf0e10cSrcweir //
2152cdf0e10cSrcweir // Given a sequence of properties seq, this method determines the mask
2153cdf0e10cSrcweir // used to instantiate a osl::FileStatus, so that a call to
2154cdf0e10cSrcweir // osl::DirectoryItem::getFileStatus fills the required fields.
2155cdf0e10cSrcweir //
2156cdf0e10cSrcweir
2157cdf0e10cSrcweir
2158cdf0e10cSrcweir void SAL_CALL
getMaskFromProperties(sal_Int32 & n_Mask,const uno::Sequence<beans::Property> & seq)2159cdf0e10cSrcweir shell::getMaskFromProperties(
2160cdf0e10cSrcweir sal_Int32& n_Mask,
2161cdf0e10cSrcweir const uno::Sequence< beans::Property >& seq )
2162cdf0e10cSrcweir {
2163cdf0e10cSrcweir n_Mask = 0;
2164cdf0e10cSrcweir for(sal_Int32 j = 0; j < seq.getLength(); ++j) {
2165cdf0e10cSrcweir if(seq[j].Name == Title)
2166cdf0e10cSrcweir n_Mask |= FileStatusMask_FileName;
2167cdf0e10cSrcweir else if(seq[j].Name == CasePreservingURL)
2168cdf0e10cSrcweir n_Mask |= FileStatusMask_FileURL;
2169cdf0e10cSrcweir else if(seq[j].Name == IsDocument ||
2170cdf0e10cSrcweir seq[j].Name == IsFolder ||
2171cdf0e10cSrcweir seq[j].Name == IsVolume ||
2172cdf0e10cSrcweir seq[j].Name == IsRemoveable ||
2173cdf0e10cSrcweir seq[j].Name == IsRemote ||
2174cdf0e10cSrcweir seq[j].Name == IsCompactDisc ||
2175cdf0e10cSrcweir seq[j].Name == IsFloppy ||
2176cdf0e10cSrcweir seq[j].Name == ContentType)
2177cdf0e10cSrcweir n_Mask |= (FileStatusMask_Type | FileStatusMask_LinkTargetURL);
2178cdf0e10cSrcweir else if(seq[j].Name == Size)
2179cdf0e10cSrcweir n_Mask |= (FileStatusMask_FileSize |
2180cdf0e10cSrcweir FileStatusMask_Type |
2181cdf0e10cSrcweir FileStatusMask_LinkTargetURL);
2182cdf0e10cSrcweir else if(seq[j].Name == IsHidden ||
2183cdf0e10cSrcweir seq[j].Name == IsReadOnly)
2184cdf0e10cSrcweir n_Mask |= FileStatusMask_Attributes;
2185cdf0e10cSrcweir else if(seq[j].Name == DateModified)
2186cdf0e10cSrcweir n_Mask |= FileStatusMask_ModifyTime;
2187cdf0e10cSrcweir // n_Mask = FileStatusMask_FileURL;
2188cdf0e10cSrcweir // n_Mask |= FileStatusMask_LinkTargetURL;
2189cdf0e10cSrcweir // n_Mask |= FileStatusMask_FileName;
2190cdf0e10cSrcweir // n_Mask |= FileStatusMask_Type;
2191cdf0e10cSrcweir // n_Mask |= FileStatusMask_ModifyTime;
2192cdf0e10cSrcweir // n_Mask |= FileStatusMask_FileSize;
2193cdf0e10cSrcweir // n_Mask |= FileStatusMask_Attributes;
2194cdf0e10cSrcweir }
2195cdf0e10cSrcweir }
2196cdf0e10cSrcweir
2197cdf0e10cSrcweir
2198cdf0e10cSrcweir
2199cdf0e10cSrcweir /*********************************************************************************/
2200cdf0e10cSrcweir /* */
2201cdf0e10cSrcweir /* load-Implementation */
2202cdf0e10cSrcweir /* */
2203cdf0e10cSrcweir /*********************************************************************************/
2204cdf0e10cSrcweir //
2205cdf0e10cSrcweir // Load the properties from configuration, if create == true create them.
2206cdf0e10cSrcweir // The Properties are stored under the url belonging to it->first.
2207cdf0e10cSrcweir //
2208cdf0e10cSrcweir
2209cdf0e10cSrcweir void SAL_CALL
load(const ContentMap::iterator & it,sal_Bool create)2210cdf0e10cSrcweir shell::load( const ContentMap::iterator& it, sal_Bool create )
2211cdf0e10cSrcweir {
2212cdf0e10cSrcweir if( ! it->second.properties )
2213cdf0e10cSrcweir it->second.properties = new PropertySet;
2214cdf0e10cSrcweir
2215cdf0e10cSrcweir if( ( ! it->second.xS.is() ||
2216cdf0e10cSrcweir ! it->second.xC.is() ||
2217cdf0e10cSrcweir ! it->second.xA.is() )
2218cdf0e10cSrcweir && m_xFileRegistry.is() )
2219cdf0e10cSrcweir {
2220cdf0e10cSrcweir
2221cdf0e10cSrcweir uno::Reference< ucb::XPersistentPropertySet > xS = m_xFileRegistry->openPropertySet( it->first,create );
2222cdf0e10cSrcweir if( xS.is() )
2223cdf0e10cSrcweir {
2224cdf0e10cSrcweir uno::Reference< beans::XPropertyContainer > xC( xS,uno::UNO_QUERY );
2225cdf0e10cSrcweir uno::Reference< beans::XPropertyAccess > xA( xS,uno::UNO_QUERY );
2226cdf0e10cSrcweir
2227cdf0e10cSrcweir it->second.xS = xS;
2228cdf0e10cSrcweir it->second.xC = xC;
2229cdf0e10cSrcweir it->second.xA = xA;
2230cdf0e10cSrcweir
2231cdf0e10cSrcweir // Now put in all values in the storage in the local hash;
2232cdf0e10cSrcweir
2233cdf0e10cSrcweir PropertySet& properties = *(it->second.properties);
2234cdf0e10cSrcweir uno::Sequence< beans::Property > seq = xS->getPropertySetInfo()->getProperties();
2235cdf0e10cSrcweir
2236cdf0e10cSrcweir for( sal_Int32 i = 0; i < seq.getLength(); ++i )
2237cdf0e10cSrcweir {
2238cdf0e10cSrcweir MyProperty readProp( false,
2239cdf0e10cSrcweir seq[i].Name,
2240cdf0e10cSrcweir seq[i].Handle,
2241cdf0e10cSrcweir seq[i].Type,
2242cdf0e10cSrcweir xS->getPropertyValue( seq[i].Name ),
2243cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE,
2244cdf0e10cSrcweir seq[i].Attributes );
2245cdf0e10cSrcweir if( properties.find( readProp ) == properties.end() )
2246cdf0e10cSrcweir properties.insert( readProp );
2247cdf0e10cSrcweir }
2248cdf0e10cSrcweir }
2249cdf0e10cSrcweir else if( create )
2250cdf0e10cSrcweir {
2251cdf0e10cSrcweir // Catastrophic error
2252cdf0e10cSrcweir }
2253cdf0e10cSrcweir }
2254cdf0e10cSrcweir }
2255cdf0e10cSrcweir
2256cdf0e10cSrcweir
2257cdf0e10cSrcweir
2258cdf0e10cSrcweir
2259cdf0e10cSrcweir /*********************************************************************************/
2260cdf0e10cSrcweir /* */
2261cdf0e10cSrcweir /* commit-Implementation */
2262cdf0e10cSrcweir /* */
2263cdf0e10cSrcweir /*********************************************************************************/
2264cdf0e10cSrcweir // Commit inserts the determined properties in the filestatus object into
2265cdf0e10cSrcweir // the internal map, so that is possible to determine on a subsequent
2266cdf0e10cSrcweir // setting of file properties which properties have changed without filestat
2267cdf0e10cSrcweir
2268cdf0e10cSrcweir
2269cdf0e10cSrcweir void SAL_CALL
commit(const shell::ContentMap::iterator & it,const osl::FileStatus & aFileStatus)2270cdf0e10cSrcweir shell::commit( const shell::ContentMap::iterator& it,
2271cdf0e10cSrcweir const osl::FileStatus& aFileStatus )
2272cdf0e10cSrcweir {
2273cdf0e10cSrcweir uno::Any aAny;
2274cdf0e10cSrcweir uno::Any emptyAny;
2275cdf0e10cSrcweir shell::PropertySet::iterator it1;
2276cdf0e10cSrcweir
2277cdf0e10cSrcweir if( it->second.properties == 0 )
2278cdf0e10cSrcweir {
2279cdf0e10cSrcweir rtl::OUString aPath = it->first;
2280cdf0e10cSrcweir insertDefaultProperties( aPath );
2281cdf0e10cSrcweir }
2282cdf0e10cSrcweir
2283cdf0e10cSrcweir PropertySet& properties = *( it->second.properties );
2284cdf0e10cSrcweir
2285cdf0e10cSrcweir it1 = properties.find( MyProperty( Title ) );
2286cdf0e10cSrcweir if( it1 != properties.end() )
2287cdf0e10cSrcweir {
2288cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileName ) )
2289cdf0e10cSrcweir {
2290cdf0e10cSrcweir aAny <<= aFileStatus.getFileName();
2291cdf0e10cSrcweir it1->setValue( aAny );
2292cdf0e10cSrcweir }
2293cdf0e10cSrcweir }
2294cdf0e10cSrcweir
2295cdf0e10cSrcweir it1 = properties.find( MyProperty( CasePreservingURL ) );
2296cdf0e10cSrcweir if( it1 != properties.end() )
2297cdf0e10cSrcweir {
2298cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileURL ) )
2299cdf0e10cSrcweir {
2300cdf0e10cSrcweir aAny <<= aFileStatus.getFileURL();
2301cdf0e10cSrcweir it1->setValue( aAny );
2302cdf0e10cSrcweir }
2303cdf0e10cSrcweir }
2304cdf0e10cSrcweir
2305cdf0e10cSrcweir
2306cdf0e10cSrcweir sal_Bool isDirectory,isFile,isVolume,isRemoveable,isRemote,isFloppy,isCompactDisc;
2307cdf0e10cSrcweir
2308cdf0e10cSrcweir sal_Int64 dirSize = 0;
2309cdf0e10cSrcweir
2310cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileSize ) )
2311cdf0e10cSrcweir dirSize = aFileStatus.getFileSize();
2312cdf0e10cSrcweir
2313cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Type ) )
2314cdf0e10cSrcweir {
2315cdf0e10cSrcweir if( osl::FileStatus::Link == aFileStatus.getFileType() &&
2316cdf0e10cSrcweir aFileStatus.isValid( FileStatusMask_LinkTargetURL ) )
2317cdf0e10cSrcweir {
2318cdf0e10cSrcweir osl::DirectoryItem aDirItem;
2319cdf0e10cSrcweir osl::FileStatus aFileStatus2( FileStatusMask_Type );
2320cdf0e10cSrcweir if( osl::FileBase::E_None == osl::DirectoryItem::get( aFileStatus.getLinkTargetURL(),aDirItem ) &&
2321cdf0e10cSrcweir osl::FileBase::E_None == aDirItem.getFileStatus( aFileStatus2 ) &&
2322cdf0e10cSrcweir aFileStatus2.isValid( FileStatusMask_Type ) )
2323cdf0e10cSrcweir {
2324cdf0e10cSrcweir isVolume = osl::FileStatus::Volume == aFileStatus2.getFileType();
2325cdf0e10cSrcweir isDirectory =
2326cdf0e10cSrcweir osl::FileStatus::Volume == aFileStatus2.getFileType() ||
2327cdf0e10cSrcweir osl::FileStatus::Directory == aFileStatus2.getFileType();
2328cdf0e10cSrcweir isFile =
2329cdf0e10cSrcweir osl::FileStatus::Regular == aFileStatus2.getFileType();
2330cdf0e10cSrcweir
2331cdf0e10cSrcweir if( aFileStatus2.isValid( FileStatusMask_FileSize ) )
2332cdf0e10cSrcweir dirSize = aFileStatus2.getFileSize();
2333cdf0e10cSrcweir }
2334cdf0e10cSrcweir else
2335cdf0e10cSrcweir {
233686e1cf34SPedro Giffuni // extremely ugly, but otherwise default construction
2337cdf0e10cSrcweir // of aDirItem and aFileStatus2
2338cdf0e10cSrcweir // before the preciding if
2339cdf0e10cSrcweir isVolume = osl::FileStatus::Volume == aFileStatus.getFileType();
2340cdf0e10cSrcweir isDirectory =
2341cdf0e10cSrcweir osl::FileStatus::Volume == aFileStatus.getFileType() ||
2342cdf0e10cSrcweir osl::FileStatus::Directory == aFileStatus.getFileType();
2343cdf0e10cSrcweir isFile =
2344cdf0e10cSrcweir osl::FileStatus::Regular == aFileStatus.getFileType();
2345cdf0e10cSrcweir }
2346cdf0e10cSrcweir }
2347cdf0e10cSrcweir else
2348cdf0e10cSrcweir {
2349cdf0e10cSrcweir isVolume = osl::FileStatus::Volume == aFileStatus.getFileType();
2350cdf0e10cSrcweir isDirectory =
2351cdf0e10cSrcweir osl::FileStatus::Volume == aFileStatus.getFileType() ||
2352cdf0e10cSrcweir osl::FileStatus::Directory == aFileStatus.getFileType();
2353cdf0e10cSrcweir isFile =
2354cdf0e10cSrcweir osl::FileStatus::Regular == aFileStatus.getFileType();
2355cdf0e10cSrcweir }
2356cdf0e10cSrcweir
2357cdf0e10cSrcweir it1 = properties.find( MyProperty( IsVolume ) );
2358cdf0e10cSrcweir if( it1 != properties.end() )
2359cdf0e10cSrcweir it1->setValue( uno::makeAny( isVolume ) );
2360cdf0e10cSrcweir
2361cdf0e10cSrcweir it1 = properties.find( MyProperty( IsFolder ) );
2362cdf0e10cSrcweir if( it1 != properties.end() )
2363cdf0e10cSrcweir it1->setValue( uno::makeAny( isDirectory ) );
2364cdf0e10cSrcweir
2365cdf0e10cSrcweir it1 = properties.find( MyProperty( IsDocument ) );
2366cdf0e10cSrcweir if( it1 != properties.end() )
2367cdf0e10cSrcweir it1->setValue( uno::makeAny( isFile ) );
2368cdf0e10cSrcweir
2369cdf0e10cSrcweir osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes );
2370cdf0e10cSrcweir if( isVolume &&
2371cdf0e10cSrcweir osl::FileBase::E_None == osl::Directory::getVolumeInfo( it->first,aVolumeInfo ) &&
2372cdf0e10cSrcweir aVolumeInfo.isValid( VolumeInfoMask_Attributes ) )
2373cdf0e10cSrcweir {
2374cdf0e10cSrcweir // Retrieve the flags;
2375cdf0e10cSrcweir isRemote = aVolumeInfo.getRemoteFlag();
2376cdf0e10cSrcweir isRemoveable = aVolumeInfo.getRemoveableFlag();
2377cdf0e10cSrcweir isCompactDisc = aVolumeInfo.getCompactDiscFlag();
2378cdf0e10cSrcweir isFloppy = aVolumeInfo.getFloppyDiskFlag();
2379cdf0e10cSrcweir
2380cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemote ) );
2381cdf0e10cSrcweir if( it1 != properties.end() )
2382cdf0e10cSrcweir it1->setValue( uno::makeAny( isRemote ) );
2383cdf0e10cSrcweir
2384cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemoveable ) );
2385cdf0e10cSrcweir if( it1 != properties.end() )
2386cdf0e10cSrcweir it1->setValue( uno::makeAny( isRemoveable ) );
2387cdf0e10cSrcweir
2388cdf0e10cSrcweir it1 = properties.find( MyProperty( IsCompactDisc ) );
2389cdf0e10cSrcweir if( it1 != properties.end() )
2390cdf0e10cSrcweir it1->setValue( uno::makeAny( isCompactDisc ) );
2391cdf0e10cSrcweir
2392cdf0e10cSrcweir it1 = properties.find( MyProperty( IsFloppy ) );
2393cdf0e10cSrcweir if( it1 != properties.end() )
2394cdf0e10cSrcweir it1->setValue( uno::makeAny( isFloppy ) );
2395cdf0e10cSrcweir }
2396cdf0e10cSrcweir else
2397cdf0e10cSrcweir {
2398cdf0e10cSrcweir sal_Bool dummy = false;
2399cdf0e10cSrcweir aAny <<= dummy;
2400cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemote ) );
2401cdf0e10cSrcweir if( it1 != properties.end() )
2402cdf0e10cSrcweir it1->setValue( aAny );
2403cdf0e10cSrcweir
2404cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemoveable ) );
2405cdf0e10cSrcweir if( it1 != properties.end() )
2406cdf0e10cSrcweir it1->setValue( aAny );
2407cdf0e10cSrcweir
2408cdf0e10cSrcweir it1 = properties.find( MyProperty( IsCompactDisc ) );
2409cdf0e10cSrcweir if( it1 != properties.end() )
2410cdf0e10cSrcweir it1->setValue( aAny );
2411cdf0e10cSrcweir
2412cdf0e10cSrcweir it1 = properties.find( MyProperty( IsFloppy ) );
2413cdf0e10cSrcweir if( it1 != properties.end() )
2414cdf0e10cSrcweir it1->setValue( aAny );
2415cdf0e10cSrcweir }
2416cdf0e10cSrcweir }
2417cdf0e10cSrcweir else
2418cdf0e10cSrcweir {
2419cdf0e10cSrcweir isDirectory = sal_False;
2420cdf0e10cSrcweir }
2421cdf0e10cSrcweir
2422cdf0e10cSrcweir it1 = properties.find( MyProperty( Size ) );
2423cdf0e10cSrcweir if( it1 != properties.end() )
2424cdf0e10cSrcweir it1->setValue( uno::makeAny( dirSize ) );
2425cdf0e10cSrcweir
2426cdf0e10cSrcweir it1 = properties.find( MyProperty( IsReadOnly ) );
2427cdf0e10cSrcweir if( it1 != properties.end() )
2428cdf0e10cSrcweir {
2429cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Attributes ) )
2430cdf0e10cSrcweir {
2431cdf0e10cSrcweir sal_uInt64 Attr = aFileStatus.getAttributes();
2432cdf0e10cSrcweir sal_Bool readonly = ( Attr & Attribute_ReadOnly ) != 0;
2433cdf0e10cSrcweir it1->setValue( uno::makeAny( readonly ) );
2434cdf0e10cSrcweir }
2435cdf0e10cSrcweir }
2436cdf0e10cSrcweir
2437cdf0e10cSrcweir it1 = properties.find( MyProperty( IsHidden ) );
2438cdf0e10cSrcweir if( it1 != properties.end() )
2439cdf0e10cSrcweir {
2440cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Attributes ) )
2441cdf0e10cSrcweir {
2442cdf0e10cSrcweir sal_uInt64 Attr = aFileStatus.getAttributes();
2443cdf0e10cSrcweir sal_Bool ishidden = ( Attr & Attribute_Hidden ) != 0;
2444cdf0e10cSrcweir it1->setValue( uno::makeAny( ishidden ) );
2445cdf0e10cSrcweir }
2446cdf0e10cSrcweir }
2447cdf0e10cSrcweir
2448cdf0e10cSrcweir it1 = properties.find( MyProperty( DateModified ) );
2449cdf0e10cSrcweir if( it1 != properties.end() )
2450cdf0e10cSrcweir {
2451cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_ModifyTime ) )
2452cdf0e10cSrcweir {
2453cdf0e10cSrcweir TimeValue temp = aFileStatus.getModifyTime();
2454cdf0e10cSrcweir
2455cdf0e10cSrcweir // Convert system time to local time (for EA)
2456cdf0e10cSrcweir TimeValue myLocalTime;
2457cdf0e10cSrcweir osl_getLocalTimeFromSystemTime( &temp, &myLocalTime );
2458cdf0e10cSrcweir
2459cdf0e10cSrcweir oslDateTime myDateTime;
2460cdf0e10cSrcweir osl_getDateTimeFromTimeValue( &myLocalTime, &myDateTime );
2461cdf0e10cSrcweir util::DateTime aDateTime;
2462cdf0e10cSrcweir
2463cdf0e10cSrcweir aDateTime.HundredthSeconds = (unsigned short)(myDateTime.NanoSeconds / 10000000);
2464cdf0e10cSrcweir aDateTime.Seconds = myDateTime.Seconds;
2465cdf0e10cSrcweir aDateTime.Minutes = myDateTime.Minutes;
2466cdf0e10cSrcweir aDateTime.Hours = myDateTime.Hours;
2467cdf0e10cSrcweir aDateTime.Day = myDateTime.Day;
2468cdf0e10cSrcweir aDateTime.Month = myDateTime.Month;
2469cdf0e10cSrcweir aDateTime.Year = myDateTime.Year;
2470cdf0e10cSrcweir it1->setValue( uno::makeAny( aDateTime ) );
2471cdf0e10cSrcweir }
2472cdf0e10cSrcweir }
2473cdf0e10cSrcweir
2474cdf0e10cSrcweir it1 = properties.find( MyProperty( CreatableContentsInfo ) );
2475cdf0e10cSrcweir if( it1 != properties.end() )
2476cdf0e10cSrcweir it1->setValue( uno::makeAny(
2477cdf0e10cSrcweir isDirectory || !aFileStatus.isValid( FileStatusMask_Type )
2478cdf0e10cSrcweir ? queryCreatableContentsInfo()
2479cdf0e10cSrcweir : uno::Sequence< ucb::ContentInfo >() ) );
2480cdf0e10cSrcweir }
2481cdf0e10cSrcweir
2482cdf0e10cSrcweir
2483cdf0e10cSrcweir // Special optimized method for getting the properties of a
2484cdf0e10cSrcweir // directoryitem, which is returned by osl::DirectoryItem::getNextItem()
2485cdf0e10cSrcweir
2486cdf0e10cSrcweir
2487cdf0e10cSrcweir uno::Reference< sdbc::XRow > SAL_CALL
getv(Notifier * pNotifier,const uno::Sequence<beans::Property> & properties,osl::DirectoryItem & aDirItem,rtl::OUString & aUnqPath,sal_Bool & aIsRegular)2488cdf0e10cSrcweir shell::getv(
2489cdf0e10cSrcweir Notifier* pNotifier,
2490cdf0e10cSrcweir const uno::Sequence< beans::Property >& properties,
2491cdf0e10cSrcweir osl::DirectoryItem& aDirItem,
2492cdf0e10cSrcweir rtl::OUString& aUnqPath,
2493cdf0e10cSrcweir sal_Bool& aIsRegular )
2494cdf0e10cSrcweir {
2495cdf0e10cSrcweir uno::Sequence< uno::Any > seq( properties.getLength() );
2496cdf0e10cSrcweir
2497cdf0e10cSrcweir sal_Int32 n_Mask;
2498cdf0e10cSrcweir getMaskFromProperties( n_Mask,properties );
2499cdf0e10cSrcweir
2500cdf0e10cSrcweir // Always retrieve the type and the target URL because item might be a link
2501cdf0e10cSrcweir osl::FileStatus aFileStatus( n_Mask |
2502cdf0e10cSrcweir FileStatusMask_FileURL |
2503cdf0e10cSrcweir FileStatusMask_Type |
2504cdf0e10cSrcweir FileStatusMask_LinkTargetURL );
2505cdf0e10cSrcweir aDirItem.getFileStatus( aFileStatus );
2506cdf0e10cSrcweir aUnqPath = aFileStatus.getFileURL();
2507cdf0e10cSrcweir
2508cdf0e10cSrcweir // If the directory item type is a link retrieve the type of the target
2509cdf0e10cSrcweir
2510cdf0e10cSrcweir if ( aFileStatus.getFileType() == osl::FileStatus::Link )
2511cdf0e10cSrcweir {
2512cdf0e10cSrcweir // Assume failure
2513cdf0e10cSrcweir aIsRegular = false;
2514cdf0e10cSrcweir osl::FileBase::RC result = osl::FileBase::E_INVAL;
2515cdf0e10cSrcweir osl::DirectoryItem aTargetItem;
2516cdf0e10cSrcweir osl::DirectoryItem::get( aFileStatus.getLinkTargetURL(), aTargetItem );
2517cdf0e10cSrcweir if ( aTargetItem.is() )
2518cdf0e10cSrcweir {
2519cdf0e10cSrcweir osl::FileStatus aTargetStatus( FileStatusMask_Type );
2520cdf0e10cSrcweir
2521cdf0e10cSrcweir if ( osl::FileBase::E_None ==
2522cdf0e10cSrcweir ( result = aTargetItem.getFileStatus( aTargetStatus ) ) )
2523cdf0e10cSrcweir aIsRegular =
2524cdf0e10cSrcweir aTargetStatus.getFileType() == osl::FileStatus::Regular;
2525cdf0e10cSrcweir }
2526cdf0e10cSrcweir }
2527cdf0e10cSrcweir else
2528cdf0e10cSrcweir aIsRegular = aFileStatus.getFileType() == osl::FileStatus::Regular;
2529cdf0e10cSrcweir
2530cdf0e10cSrcweir registerNotifier( aUnqPath,pNotifier );
2531cdf0e10cSrcweir insertDefaultProperties( aUnqPath );
2532cdf0e10cSrcweir {
2533cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2534cdf0e10cSrcweir
2535cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aUnqPath );
2536cdf0e10cSrcweir commit( it,aFileStatus );
2537cdf0e10cSrcweir
2538cdf0e10cSrcweir shell::PropertySet::iterator it1;
2539cdf0e10cSrcweir PropertySet& propset = *(it->second.properties);
2540cdf0e10cSrcweir
2541cdf0e10cSrcweir for( sal_Int32 i = 0; i < seq.getLength(); ++i )
2542cdf0e10cSrcweir {
2543cdf0e10cSrcweir MyProperty readProp( properties[i].Name );
2544cdf0e10cSrcweir it1 = propset.find( readProp );
2545cdf0e10cSrcweir if( it1 == propset.end() )
2546cdf0e10cSrcweir seq[i] = uno::Any();
2547cdf0e10cSrcweir else
2548cdf0e10cSrcweir seq[i] = it1->getValue();
2549cdf0e10cSrcweir }
2550cdf0e10cSrcweir }
2551cdf0e10cSrcweir deregisterNotifier( aUnqPath,pNotifier );
2552cdf0e10cSrcweir
2553cdf0e10cSrcweir XRow_impl* p = new XRow_impl( this,seq );
2554cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( p );
2555cdf0e10cSrcweir }
2556cdf0e10cSrcweir
2557cdf0e10cSrcweir
2558cdf0e10cSrcweir
2559cdf0e10cSrcweir
2560cdf0e10cSrcweir
2561cdf0e10cSrcweir
2562cdf0e10cSrcweir // EventListener
2563cdf0e10cSrcweir
2564cdf0e10cSrcweir
2565cdf0e10cSrcweir std::list< ContentEventNotifier* >* SAL_CALL
getContentEventListeners(const rtl::OUString & aName)2566cdf0e10cSrcweir shell::getContentEventListeners( const rtl::OUString& aName )
2567cdf0e10cSrcweir {
2568cdf0e10cSrcweir std::list< ContentEventNotifier* >* p = new std::list< ContentEventNotifier* >;
2569cdf0e10cSrcweir std::list< ContentEventNotifier* >& listeners = *p;
2570cdf0e10cSrcweir {
2571cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2572cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName );
2573cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier )
2574cdf0e10cSrcweir {
2575cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier );
2576cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin();
2577cdf0e10cSrcweir while( it1 != listOfNotifiers.end() )
2578cdf0e10cSrcweir {
2579cdf0e10cSrcweir Notifier* pointer = *it1;
2580cdf0e10cSrcweir ContentEventNotifier* notifier = pointer->cCEL();
2581cdf0e10cSrcweir if( notifier )
2582cdf0e10cSrcweir listeners.push_back( notifier );
2583cdf0e10cSrcweir ++it1;
2584cdf0e10cSrcweir }
2585cdf0e10cSrcweir }
2586cdf0e10cSrcweir }
2587cdf0e10cSrcweir return p;
2588cdf0e10cSrcweir }
2589cdf0e10cSrcweir
2590cdf0e10cSrcweir
2591cdf0e10cSrcweir
2592cdf0e10cSrcweir std::list< ContentEventNotifier* >* SAL_CALL
getContentDeletedEventListeners(const rtl::OUString & aName)2593cdf0e10cSrcweir shell::getContentDeletedEventListeners( const rtl::OUString& aName )
2594cdf0e10cSrcweir {
2595cdf0e10cSrcweir std::list< ContentEventNotifier* >* p = new std::list< ContentEventNotifier* >;
2596cdf0e10cSrcweir std::list< ContentEventNotifier* >& listeners = *p;
2597cdf0e10cSrcweir {
2598cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2599cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName );
2600cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier )
2601cdf0e10cSrcweir {
2602cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier );
2603cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin();
2604cdf0e10cSrcweir while( it1 != listOfNotifiers.end() )
2605cdf0e10cSrcweir {
2606cdf0e10cSrcweir Notifier* pointer = *it1;
2607cdf0e10cSrcweir ContentEventNotifier* notifier = pointer->cDEL();
2608cdf0e10cSrcweir if( notifier )
2609cdf0e10cSrcweir listeners.push_back( notifier );
2610cdf0e10cSrcweir ++it1;
2611cdf0e10cSrcweir }
2612cdf0e10cSrcweir }
2613cdf0e10cSrcweir }
2614cdf0e10cSrcweir return p;
2615cdf0e10cSrcweir }
2616cdf0e10cSrcweir
2617cdf0e10cSrcweir
2618cdf0e10cSrcweir void SAL_CALL
notifyInsert(std::list<ContentEventNotifier * > * listeners,const rtl::OUString & aChildName)2619cdf0e10cSrcweir shell::notifyInsert( std::list< ContentEventNotifier* >* listeners,const rtl::OUString& aChildName )
2620cdf0e10cSrcweir {
2621cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin();
2622cdf0e10cSrcweir while( it != listeners->end() )
2623cdf0e10cSrcweir {
2624cdf0e10cSrcweir (*it)->notifyChildInserted( aChildName );
2625cdf0e10cSrcweir delete (*it);
2626cdf0e10cSrcweir ++it;
2627cdf0e10cSrcweir }
2628cdf0e10cSrcweir delete listeners;
2629cdf0e10cSrcweir }
2630cdf0e10cSrcweir
2631cdf0e10cSrcweir
2632cdf0e10cSrcweir void SAL_CALL
notifyContentDeleted(std::list<ContentEventNotifier * > * listeners)2633cdf0e10cSrcweir shell::notifyContentDeleted( std::list< ContentEventNotifier* >* listeners )
2634cdf0e10cSrcweir {
2635cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin();
2636cdf0e10cSrcweir while( it != listeners->end() )
2637cdf0e10cSrcweir {
2638cdf0e10cSrcweir (*it)->notifyDeleted();
2639cdf0e10cSrcweir delete (*it);
2640cdf0e10cSrcweir ++it;
2641cdf0e10cSrcweir }
2642cdf0e10cSrcweir delete listeners;
2643cdf0e10cSrcweir }
2644cdf0e10cSrcweir
2645cdf0e10cSrcweir
2646cdf0e10cSrcweir void SAL_CALL
notifyContentRemoved(std::list<ContentEventNotifier * > * listeners,const rtl::OUString & aChildName)2647cdf0e10cSrcweir shell::notifyContentRemoved( std::list< ContentEventNotifier* >* listeners,
2648cdf0e10cSrcweir const rtl::OUString& aChildName )
2649cdf0e10cSrcweir {
2650cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin();
2651cdf0e10cSrcweir while( it != listeners->end() )
2652cdf0e10cSrcweir {
2653cdf0e10cSrcweir (*it)->notifyRemoved( aChildName );
2654cdf0e10cSrcweir delete (*it);
2655cdf0e10cSrcweir ++it;
2656cdf0e10cSrcweir }
2657cdf0e10cSrcweir delete listeners;
2658cdf0e10cSrcweir }
2659cdf0e10cSrcweir
2660cdf0e10cSrcweir
2661cdf0e10cSrcweir
2662cdf0e10cSrcweir
2663cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* SAL_CALL
getPropertySetListeners(const rtl::OUString & aName)2664cdf0e10cSrcweir shell::getPropertySetListeners( const rtl::OUString& aName )
2665cdf0e10cSrcweir {
2666cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* p = new std::list< PropertySetInfoChangeNotifier* >;
2667cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >& listeners = *p;
2668cdf0e10cSrcweir {
2669cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2670cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName );
2671cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier )
2672cdf0e10cSrcweir {
2673cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier );
2674cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin();
2675cdf0e10cSrcweir while( it1 != listOfNotifiers.end() )
2676cdf0e10cSrcweir {
2677cdf0e10cSrcweir Notifier* pointer = *it1;
2678cdf0e10cSrcweir PropertySetInfoChangeNotifier* notifier = pointer->cPSL();
2679cdf0e10cSrcweir if( notifier )
2680cdf0e10cSrcweir listeners.push_back( notifier );
2681cdf0e10cSrcweir ++it1;
2682cdf0e10cSrcweir }
2683cdf0e10cSrcweir }
2684cdf0e10cSrcweir }
2685cdf0e10cSrcweir return p;
2686cdf0e10cSrcweir }
2687cdf0e10cSrcweir
2688cdf0e10cSrcweir
2689cdf0e10cSrcweir void SAL_CALL
notifyPropertyAdded(std::list<PropertySetInfoChangeNotifier * > * listeners,const rtl::OUString & aPropertyName)2690cdf0e10cSrcweir shell::notifyPropertyAdded( std::list< PropertySetInfoChangeNotifier* >* listeners,
2691cdf0e10cSrcweir const rtl::OUString& aPropertyName )
2692cdf0e10cSrcweir {
2693cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >::iterator it = listeners->begin();
2694cdf0e10cSrcweir while( it != listeners->end() )
2695cdf0e10cSrcweir {
2696cdf0e10cSrcweir (*it)->notifyPropertyAdded( aPropertyName );
2697cdf0e10cSrcweir delete (*it);
2698cdf0e10cSrcweir ++it;
2699cdf0e10cSrcweir }
2700cdf0e10cSrcweir delete listeners;
2701cdf0e10cSrcweir }
2702cdf0e10cSrcweir
2703cdf0e10cSrcweir
2704cdf0e10cSrcweir void SAL_CALL
notifyPropertyRemoved(std::list<PropertySetInfoChangeNotifier * > * listeners,const rtl::OUString & aPropertyName)2705cdf0e10cSrcweir shell::notifyPropertyRemoved( std::list< PropertySetInfoChangeNotifier* >* listeners,
2706cdf0e10cSrcweir const rtl::OUString& aPropertyName )
2707cdf0e10cSrcweir {
2708cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >::iterator it = listeners->begin();
2709cdf0e10cSrcweir while( it != listeners->end() )
2710cdf0e10cSrcweir {
2711cdf0e10cSrcweir (*it)->notifyPropertyRemoved( aPropertyName );
2712cdf0e10cSrcweir delete (*it);
2713cdf0e10cSrcweir ++it;
2714cdf0e10cSrcweir }
2715cdf0e10cSrcweir delete listeners;
2716cdf0e10cSrcweir }
2717cdf0e10cSrcweir
2718cdf0e10cSrcweir
2719cdf0e10cSrcweir
2720cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >* SAL_CALL
getContentExchangedEventListeners(const rtl::OUString aOldPrefix,const rtl::OUString aNewPrefix,sal_Bool withChilds)2721cdf0e10cSrcweir shell::getContentExchangedEventListeners( const rtl::OUString aOldPrefix,
2722cdf0e10cSrcweir const rtl::OUString aNewPrefix,
2723cdf0e10cSrcweir sal_Bool withChilds )
2724cdf0e10cSrcweir {
2725cdf0e10cSrcweir
2726cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >* aVectorOnHeap =
2727cdf0e10cSrcweir new std::vector< std::list< ContentEventNotifier* >* >;
2728cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >& aVector = *aVectorOnHeap;
2729cdf0e10cSrcweir
2730cdf0e10cSrcweir sal_Int32 count;
2731cdf0e10cSrcweir rtl::OUString aOldName;
2732cdf0e10cSrcweir rtl::OUString aNewName;
2733cdf0e10cSrcweir std::vector< rtl::OUString > oldChildList;
2734cdf0e10cSrcweir
2735cdf0e10cSrcweir {
2736cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2737cdf0e10cSrcweir
2738cdf0e10cSrcweir if( ! withChilds )
2739cdf0e10cSrcweir {
2740cdf0e10cSrcweir aOldName = aOldPrefix;
2741cdf0e10cSrcweir aNewName = aNewPrefix;
2742cdf0e10cSrcweir count = 1;
2743cdf0e10cSrcweir }
2744cdf0e10cSrcweir else
2745cdf0e10cSrcweir {
2746cdf0e10cSrcweir ContentMap::iterator itnames = m_aContent.begin();
2747cdf0e10cSrcweir while( itnames != m_aContent.end() )
2748cdf0e10cSrcweir {
2749cdf0e10cSrcweir if( isChild( aOldPrefix,itnames->first ) )
2750cdf0e10cSrcweir {
2751cdf0e10cSrcweir oldChildList.push_back( itnames->first );
2752cdf0e10cSrcweir }
2753cdf0e10cSrcweir ++itnames;
2754cdf0e10cSrcweir }
2755cdf0e10cSrcweir count = oldChildList.size();
2756cdf0e10cSrcweir }
2757cdf0e10cSrcweir
2758cdf0e10cSrcweir
2759cdf0e10cSrcweir for( sal_Int32 j = 0; j < count; ++j )
2760cdf0e10cSrcweir {
2761cdf0e10cSrcweir std::list< ContentEventNotifier* >* p = new std::list< ContentEventNotifier* >;
2762cdf0e10cSrcweir std::list< ContentEventNotifier* >& listeners = *p;
2763cdf0e10cSrcweir
2764cdf0e10cSrcweir if( withChilds )
2765cdf0e10cSrcweir {
2766cdf0e10cSrcweir aOldName = oldChildList[j];
2767cdf0e10cSrcweir aNewName = newName( aNewPrefix,aOldPrefix,aOldName );
2768cdf0e10cSrcweir }
2769cdf0e10cSrcweir
2770cdf0e10cSrcweir shell::ContentMap::iterator itold = m_aContent.find( aOldName );
2771cdf0e10cSrcweir if( itold != m_aContent.end() )
2772cdf0e10cSrcweir {
2773cdf0e10cSrcweir shell::ContentMap::iterator itnew = m_aContent.insert(
2774cdf0e10cSrcweir ContentMap::value_type( aNewName,UnqPathData() ) ).first;
2775cdf0e10cSrcweir
2776cdf0e10cSrcweir // copy Ownership also
2777cdf0e10cSrcweir delete itnew->second.properties;
2778cdf0e10cSrcweir itnew->second.properties = itold->second.properties;
2779cdf0e10cSrcweir itold->second.properties = 0;
2780cdf0e10cSrcweir
2781cdf0e10cSrcweir // copy existing list
2782cdf0e10cSrcweir std::list< Notifier* >* copyList = itnew->second.notifier;
2783cdf0e10cSrcweir itnew->second.notifier = itold->second.notifier;
2784cdf0e10cSrcweir itold->second.notifier = 0;
2785cdf0e10cSrcweir
2786cdf0e10cSrcweir m_aContent.erase( itold );
2787cdf0e10cSrcweir
2788cdf0e10cSrcweir if( itnew != m_aContent.end() && itnew->second.notifier )
2789cdf0e10cSrcweir {
2790cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( itnew->second.notifier );
2791cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin();
2792cdf0e10cSrcweir while( it1 != listOfNotifiers.end() )
2793cdf0e10cSrcweir {
2794cdf0e10cSrcweir Notifier* pointer = *it1;
2795cdf0e10cSrcweir ContentEventNotifier* notifier = pointer->cEXC( aNewName );
2796cdf0e10cSrcweir if( notifier )
2797cdf0e10cSrcweir listeners.push_back( notifier );
2798cdf0e10cSrcweir ++it1;
2799cdf0e10cSrcweir }
2800cdf0e10cSrcweir }
2801cdf0e10cSrcweir
2802cdf0e10cSrcweir // Merge with preexisting notifiers
2803cdf0e10cSrcweir // However, these may be in status BaseContent::Deleted
2804cdf0e10cSrcweir if( copyList != 0 )
2805cdf0e10cSrcweir {
2806cdf0e10cSrcweir std::list< Notifier* >::iterator copyIt = copyList->begin();
2807cdf0e10cSrcweir while( copyIt != copyList->end() )
2808cdf0e10cSrcweir {
2809cdf0e10cSrcweir itnew->second.notifier->push_back( *copyIt );
2810cdf0e10cSrcweir ++copyIt;
2811cdf0e10cSrcweir }
2812cdf0e10cSrcweir }
2813cdf0e10cSrcweir delete copyList;
2814cdf0e10cSrcweir }
2815cdf0e10cSrcweir aVector.push_back( p );
2816cdf0e10cSrcweir }
2817cdf0e10cSrcweir }
2818cdf0e10cSrcweir
2819cdf0e10cSrcweir return aVectorOnHeap;
2820cdf0e10cSrcweir }
2821cdf0e10cSrcweir
2822cdf0e10cSrcweir
2823cdf0e10cSrcweir
2824cdf0e10cSrcweir void SAL_CALL
notifyContentExchanged(std::vector<std::list<ContentEventNotifier * > * > * listeners_vec)2825cdf0e10cSrcweir shell::notifyContentExchanged( std::vector< std::list< ContentEventNotifier* >* >* listeners_vec )
2826cdf0e10cSrcweir {
2827cdf0e10cSrcweir std::list< ContentEventNotifier* >* listeners;
2828cdf0e10cSrcweir for( sal_uInt32 i = 0; i < listeners_vec->size(); ++i )
2829cdf0e10cSrcweir {
2830cdf0e10cSrcweir listeners = (*listeners_vec)[i];
2831cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin();
2832cdf0e10cSrcweir while( it != listeners->end() )
2833cdf0e10cSrcweir {
2834cdf0e10cSrcweir (*it)->notifyExchanged();
2835cdf0e10cSrcweir delete (*it);
2836cdf0e10cSrcweir ++it;
2837cdf0e10cSrcweir }
2838cdf0e10cSrcweir delete listeners;
2839cdf0e10cSrcweir }
2840cdf0e10cSrcweir delete listeners_vec;
2841cdf0e10cSrcweir }
2842cdf0e10cSrcweir
2843cdf0e10cSrcweir
2844cdf0e10cSrcweir
2845cdf0e10cSrcweir std::list< PropertyChangeNotifier* >* SAL_CALL
getPropertyChangeNotifier(const rtl::OUString & aName)2846cdf0e10cSrcweir shell::getPropertyChangeNotifier( const rtl::OUString& aName )
2847cdf0e10cSrcweir {
2848cdf0e10cSrcweir std::list< PropertyChangeNotifier* >* p = new std::list< PropertyChangeNotifier* >;
2849cdf0e10cSrcweir std::list< PropertyChangeNotifier* >& listeners = *p;
2850cdf0e10cSrcweir {
2851cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2852cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName );
2853cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier )
2854cdf0e10cSrcweir {
2855cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier );
2856cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin();
2857cdf0e10cSrcweir while( it1 != listOfNotifiers.end() )
2858cdf0e10cSrcweir {
2859cdf0e10cSrcweir Notifier* pointer = *it1;
2860cdf0e10cSrcweir PropertyChangeNotifier* notifier = pointer->cPCL();
2861cdf0e10cSrcweir if( notifier )
2862cdf0e10cSrcweir listeners.push_back( notifier );
2863cdf0e10cSrcweir ++it1;
2864cdf0e10cSrcweir }
2865cdf0e10cSrcweir }
2866cdf0e10cSrcweir }
2867cdf0e10cSrcweir return p;
2868cdf0e10cSrcweir }
2869cdf0e10cSrcweir
2870cdf0e10cSrcweir
notifyPropertyChanges(std::list<PropertyChangeNotifier * > * listeners,const uno::Sequence<beans::PropertyChangeEvent> & seqChanged)2871cdf0e10cSrcweir void SAL_CALL shell::notifyPropertyChanges( std::list< PropertyChangeNotifier* >* listeners,
2872cdf0e10cSrcweir const uno::Sequence< beans::PropertyChangeEvent >& seqChanged )
2873cdf0e10cSrcweir {
2874cdf0e10cSrcweir std::list< PropertyChangeNotifier* >::iterator it = listeners->begin();
2875cdf0e10cSrcweir while( it != listeners->end() )
2876cdf0e10cSrcweir {
2877cdf0e10cSrcweir (*it)->notifyPropertyChanged( seqChanged );
2878cdf0e10cSrcweir delete (*it);
2879cdf0e10cSrcweir ++it;
2880cdf0e10cSrcweir }
2881cdf0e10cSrcweir delete listeners;
2882cdf0e10cSrcweir }
2883cdf0e10cSrcweir
2884cdf0e10cSrcweir
2885cdf0e10cSrcweir
2886cdf0e10cSrcweir
2887cdf0e10cSrcweir /********************************************************************************/
2888cdf0e10cSrcweir /* remove persistent propertyset */
2889cdf0e10cSrcweir /********************************************************************************/
2890cdf0e10cSrcweir
2891cdf0e10cSrcweir void SAL_CALL
erasePersistentSet(const rtl::OUString & aUnqPath,sal_Bool withChilds)2892cdf0e10cSrcweir shell::erasePersistentSet( const rtl::OUString& aUnqPath,
2893cdf0e10cSrcweir sal_Bool withChilds )
2894cdf0e10cSrcweir {
2895cdf0e10cSrcweir if( ! m_xFileRegistry.is() )
2896cdf0e10cSrcweir {
2897cdf0e10cSrcweir OSL_ASSERT( m_xFileRegistry.is() );
2898cdf0e10cSrcweir return;
2899cdf0e10cSrcweir }
2900cdf0e10cSrcweir
2901cdf0e10cSrcweir uno::Sequence< rtl::OUString > seqNames;
2902cdf0e10cSrcweir
2903cdf0e10cSrcweir if( withChilds )
2904cdf0e10cSrcweir {
2905cdf0e10cSrcweir uno::Reference< container::XNameAccess > xName( m_xFileRegistry,uno::UNO_QUERY );
2906cdf0e10cSrcweir seqNames = xName->getElementNames();
2907cdf0e10cSrcweir }
2908cdf0e10cSrcweir
2909cdf0e10cSrcweir sal_Int32 count = withChilds ? seqNames.getLength() : 1;
2910cdf0e10cSrcweir
2911cdf0e10cSrcweir rtl::OUString
2912cdf0e10cSrcweir old_Name = aUnqPath;
2913cdf0e10cSrcweir
2914cdf0e10cSrcweir for( sal_Int32 j = 0; j < count; ++j )
2915cdf0e10cSrcweir {
2916cdf0e10cSrcweir if( withChilds && ! ( isChild( old_Name,seqNames[j] ) ) )
2917cdf0e10cSrcweir continue;
2918cdf0e10cSrcweir
2919cdf0e10cSrcweir if( withChilds )
2920cdf0e10cSrcweir {
2921cdf0e10cSrcweir old_Name = seqNames[j];
2922cdf0e10cSrcweir }
2923cdf0e10cSrcweir
2924cdf0e10cSrcweir {
2925cdf0e10cSrcweir // Release possible references
2926cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
2927cdf0e10cSrcweir ContentMap::iterator it = m_aContent.find( old_Name );
2928cdf0e10cSrcweir if( it != m_aContent.end() )
2929cdf0e10cSrcweir {
2930cdf0e10cSrcweir it->second.xS = 0;
2931cdf0e10cSrcweir it->second.xC = 0;
2932cdf0e10cSrcweir it->second.xA = 0;
2933cdf0e10cSrcweir
2934cdf0e10cSrcweir delete it->second.properties;
2935cdf0e10cSrcweir it->second.properties = 0;
2936cdf0e10cSrcweir }
2937cdf0e10cSrcweir }
2938cdf0e10cSrcweir
2939cdf0e10cSrcweir if( m_xFileRegistry.is() )
2940cdf0e10cSrcweir m_xFileRegistry->removePropertySet( old_Name );
2941cdf0e10cSrcweir }
2942cdf0e10cSrcweir }
2943cdf0e10cSrcweir
2944cdf0e10cSrcweir
2945cdf0e10cSrcweir
2946cdf0e10cSrcweir
2947cdf0e10cSrcweir /********************************************************************************/
2948cdf0e10cSrcweir /* copy persistent propertyset */
2949cdf0e10cSrcweir /* from srcUnqPath to dstUnqPath */
2950cdf0e10cSrcweir /********************************************************************************/
2951cdf0e10cSrcweir
2952cdf0e10cSrcweir
2953cdf0e10cSrcweir void SAL_CALL
copyPersistentSet(const rtl::OUString & srcUnqPath,const rtl::OUString & dstUnqPath,sal_Bool withChilds)2954cdf0e10cSrcweir shell::copyPersistentSet( const rtl::OUString& srcUnqPath,
2955cdf0e10cSrcweir const rtl::OUString& dstUnqPath,
2956cdf0e10cSrcweir sal_Bool withChilds )
2957cdf0e10cSrcweir {
2958cdf0e10cSrcweir if( ! m_xFileRegistry.is() )
2959cdf0e10cSrcweir {
2960cdf0e10cSrcweir OSL_ASSERT( m_xFileRegistry.is() );
2961cdf0e10cSrcweir return;
2962cdf0e10cSrcweir }
2963cdf0e10cSrcweir
2964cdf0e10cSrcweir uno::Sequence< rtl::OUString > seqNames;
2965cdf0e10cSrcweir
2966cdf0e10cSrcweir if( withChilds )
2967cdf0e10cSrcweir {
2968cdf0e10cSrcweir uno::Reference< container::XNameAccess > xName( m_xFileRegistry,uno::UNO_QUERY );
2969cdf0e10cSrcweir seqNames = xName->getElementNames();
2970cdf0e10cSrcweir }
2971cdf0e10cSrcweir
2972cdf0e10cSrcweir sal_Int32 count = withChilds ? seqNames.getLength() : 1;
2973cdf0e10cSrcweir
2974cdf0e10cSrcweir rtl::OUString
2975cdf0e10cSrcweir old_Name = srcUnqPath,
2976cdf0e10cSrcweir new_Name = dstUnqPath;
2977cdf0e10cSrcweir
2978cdf0e10cSrcweir for( sal_Int32 j = 0; j < count; ++j )
2979cdf0e10cSrcweir {
2980cdf0e10cSrcweir if( withChilds && ! ( isChild( srcUnqPath,seqNames[j] ) ) )
2981cdf0e10cSrcweir continue;
2982cdf0e10cSrcweir
2983cdf0e10cSrcweir if( withChilds )
2984cdf0e10cSrcweir {
2985cdf0e10cSrcweir old_Name = seqNames[j];
2986cdf0e10cSrcweir new_Name = newName( dstUnqPath,srcUnqPath,old_Name );
2987cdf0e10cSrcweir }
2988cdf0e10cSrcweir
2989cdf0e10cSrcweir uno::Reference< XPersistentPropertySet > x_src;
2990cdf0e10cSrcweir
2991cdf0e10cSrcweir if( m_xFileRegistry.is() )
2992cdf0e10cSrcweir {
2993cdf0e10cSrcweir x_src = m_xFileRegistry->openPropertySet( old_Name,false );
2994cdf0e10cSrcweir m_xFileRegistry->removePropertySet( new_Name );
2995cdf0e10cSrcweir }
2996cdf0e10cSrcweir
2997cdf0e10cSrcweir if( x_src.is() )
2998cdf0e10cSrcweir {
2999cdf0e10cSrcweir uno::Sequence< beans::Property > seqProperty =
3000cdf0e10cSrcweir x_src->getPropertySetInfo()->getProperties();
3001cdf0e10cSrcweir
3002cdf0e10cSrcweir if( seqProperty.getLength() )
3003cdf0e10cSrcweir {
3004cdf0e10cSrcweir uno::Reference< XPersistentPropertySet >
3005cdf0e10cSrcweir x_dstS = m_xFileRegistry->openPropertySet( new_Name,true );
3006cdf0e10cSrcweir uno::Reference< beans::XPropertyContainer >
3007cdf0e10cSrcweir x_dstC( x_dstS,uno::UNO_QUERY );
3008cdf0e10cSrcweir
3009cdf0e10cSrcweir for( sal_Int32 i = 0; i < seqProperty.getLength(); ++i )
3010cdf0e10cSrcweir {
3011cdf0e10cSrcweir x_dstC->addProperty( seqProperty[i].Name,
3012cdf0e10cSrcweir seqProperty[i].Attributes,
3013cdf0e10cSrcweir x_src->getPropertyValue( seqProperty[i].Name ) );
3014cdf0e10cSrcweir }
3015cdf0e10cSrcweir }
3016cdf0e10cSrcweir }
3017cdf0e10cSrcweir } // end for( sal_Int...
3018cdf0e10cSrcweir }
3019cdf0e10cSrcweir
queryCreatableContentsInfo()3020cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > shell::queryCreatableContentsInfo()
3021cdf0e10cSrcweir {
3022cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > seq(2);
3023cdf0e10cSrcweir
3024cdf0e10cSrcweir // file
3025cdf0e10cSrcweir seq[0].Type = FileContentType;
3026cdf0e10cSrcweir seq[0].Attributes = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
3027cdf0e10cSrcweir | ucb::ContentInfoAttribute::KIND_DOCUMENT;
3028cdf0e10cSrcweir
3029cdf0e10cSrcweir uno::Sequence< beans::Property > props( 1 );
3030cdf0e10cSrcweir props[0] = beans::Property(
3031cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ),
3032cdf0e10cSrcweir -1,
3033cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ),
3034cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID
3035cdf0e10cSrcweir | beans::PropertyAttribute::BOUND );
3036cdf0e10cSrcweir seq[0].Properties = props;
3037cdf0e10cSrcweir
3038cdf0e10cSrcweir // folder
3039cdf0e10cSrcweir seq[1].Type = FolderContentType;
3040cdf0e10cSrcweir seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
3041cdf0e10cSrcweir seq[1].Properties = props;
3042cdf0e10cSrcweir return seq;
3043cdf0e10cSrcweir }
3044cdf0e10cSrcweir
3045cdf0e10cSrcweir /*******************************************************************************/
3046cdf0e10cSrcweir /* */
3047cdf0e10cSrcweir /* some misceancellous static functions */
3048cdf0e10cSrcweir /* */
3049cdf0e10cSrcweir /*******************************************************************************/
3050cdf0e10cSrcweir
3051cdf0e10cSrcweir void SAL_CALL
getScheme(rtl::OUString & Scheme)3052cdf0e10cSrcweir shell::getScheme( rtl::OUString& Scheme )
3053cdf0e10cSrcweir {
3054cdf0e10cSrcweir Scheme = rtl::OUString::createFromAscii( "file" );
3055cdf0e10cSrcweir }
3056cdf0e10cSrcweir
3057cdf0e10cSrcweir rtl::OUString SAL_CALL
getImplementationName_static(void)3058cdf0e10cSrcweir shell::getImplementationName_static( void )
3059cdf0e10cSrcweir {
3060cdf0e10cSrcweir return rtl::OUString::createFromAscii( "com.sun.star.comp.ucb.FileProvider" );
3061cdf0e10cSrcweir }
3062cdf0e10cSrcweir
3063cdf0e10cSrcweir
3064cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames_static(void)3065cdf0e10cSrcweir shell::getSupportedServiceNames_static( void )
3066cdf0e10cSrcweir {
3067cdf0e10cSrcweir rtl::OUString Supported = rtl::OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" ) ;
3068cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > Seq( &Supported,1 );
3069cdf0e10cSrcweir return Seq;
3070cdf0e10cSrcweir }
3071