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 #ifndef _COM_SUN_STAR_SCRIPTING_UTIL_SCRIPTINGCONSTANTS_HXX_
24 #define _COM_SUN_STAR_SCRIPTING_UTIL_SCRIPTINGCONSTANTS_HXX_
25 
26 namespace scripting_constants
27 {
28 
29 class ScriptingConstantsPool
30 {
31 public:
32     const ::rtl::OUString DOC_REF;
33     const ::rtl::OUString DOC_STORAGE_ID;
34     const ::rtl::OUString DOC_URI;
35     const ::rtl::OUString RESOLVED_STORAGE_ID;
36     const ::rtl::OUString SCRIPT_INFO;
37     const ::rtl::OUString SCRIPTSTORAGEMANAGER_SERVICE;
38     const sal_Int32 SHARED_STORAGE_ID;
39     const sal_Int32 USER_STORAGE_ID;
40     const sal_Int32 DOC_STORAGE_ID_NOT_SET;
41 
instance()42     static ScriptingConstantsPool& instance()
43     {
44         static ScriptingConstantsPool *pPool = 0;
45         if( ! pPool )
46         {
47             ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
48             if( ! pPool )
49             {
50                 static ScriptingConstantsPool pool;
51                 pPool = &pool;
52             }
53         }
54         return *pPool;
55     }
56 private:
57     ScriptingConstantsPool( const ScriptingConstantsPool & );
58     ScriptingConstantsPool& operator = ( const ScriptingConstantsPool & );
ScriptingConstantsPool()59     ScriptingConstantsPool()
60         : DOC_REF( RTL_CONSTASCII_USTRINGPARAM( "SCRIPTING_DOC_REF" ) ),
61         DOC_STORAGE_ID( RTL_CONSTASCII_USTRINGPARAM(
62             "SCRIPTING_DOC_STORAGE_ID" ) ),
63         DOC_URI( RTL_CONSTASCII_USTRINGPARAM( "SCRIPTING_DOC_URI" ) ),
64         RESOLVED_STORAGE_ID( RTL_CONSTASCII_USTRINGPARAM(
65             "SCRIPTING_RESOLVED_STORAGE_ID" ) ),
66         SCRIPT_INFO( RTL_CONSTASCII_USTRINGPARAM( "SCRIPT_INFO" ) ),
67         SCRIPTSTORAGEMANAGER_SERVICE( RTL_CONSTASCII_USTRINGPARAM(
68             "/singletons/com.sun.star.script.framework.storage.theScriptStorageManager" ) ),
69         SHARED_STORAGE_ID( 0 ), USER_STORAGE_ID( 1 ),
70         DOC_STORAGE_ID_NOT_SET( -1 )
71     {}
72 };
73 
74 }
75 #endif
76