xref: /aoo4110/main/svl/inc/svl/lockfilecommon.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVT_LOCKFILECOMMON_HXX
25 #define _SVT_LOCKFILECOMMON_HXX
26 
27 #include <svl/svldllapi.h>
28 
29 #include <com/sun/star/io/XStream.hpp>
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/io/XOutputStream.hpp>
32 #include <com/sun/star/io/XSeekable.hpp>
33 #include <com/sun/star/io/XTruncate.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 
36 #include <osl/mutex.hxx>
37 #include <tools/urlobj.hxx>
38 
39 #define LOCKFILE_OOOUSERNAME_ID   0
40 #define LOCKFILE_SYSUSERNAME_ID   1
41 #define LOCKFILE_LOCALHOST_ID     2
42 #define LOCKFILE_EDITTIME_ID      3
43 #define LOCKFILE_USERURL_ID       4
44 #define LOCKFILE_ENTRYSIZE        5
45 
46 namespace svt {
47 
48 // This is a general implementation that is used in document lock file implementation and in sharing control file implementation
49 class SVL_DLLPUBLIC LockFileCommon
50 {
51 protected:
52     ::osl::Mutex m_aMutex;
53 
54     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
55     ::rtl::OUString m_aURL;
56 
57 
58     INetURLObject ResolveLinks( const INetURLObject& aDocURL );
59 
60 public:
61     LockFileCommon( const ::rtl::OUString& aOrigURL, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, const ::rtl::OUString& aPrefix );
62     ~LockFileCommon();
63 
64     static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > ParseList( const ::com::sun::star::uno::Sequence< sal_Int8 >& aBuffer );
65     static ::com::sun::star::uno::Sequence< ::rtl::OUString > ParseEntry( const ::com::sun::star::uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& o_nCurPos );
66     static ::rtl::OUString ParseName( const ::com::sun::star::uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& o_nCurPos );
67     static ::rtl::OUString EscapeCharacters( const ::rtl::OUString& aSource );
68     static ::rtl::OUString GetOOOUserName();
69     static ::rtl::OUString GetCurrentLocalTime();
70     static ::com::sun::star::uno::Sequence< ::rtl::OUString > GenerateOwnEntry();
71 };
72 
73 }
74 
75 #endif
76 
77