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 #include "precompiled_xmloff.hxx"
25 
26 #include "forms/form_handler_factory.hxx"
27 #include "vcl_date_handler.hxx"
28 #include "vcl_time_handler.hxx"
29 
30 //......................................................................................................................
31 namespace xmloff
32 {
33 //......................................................................................................................
34 
35     namespace
36     {
37         static PPropertyHandler s_pVCLDateHandler = NULL;
38         static PPropertyHandler s_pVCLTimeHandler = NULL;
39     }
40 
41 	//==================================================================================================================
42 	//= FormHandlerFactory
43 	//==================================================================================================================
44 	//------------------------------------------------------------------------------------------------------------------
getFormPropertyHandler(const PropertyId i_propertyId)45     PPropertyHandler FormHandlerFactory::getFormPropertyHandler( const PropertyId i_propertyId )
46     {
47         PPropertyHandler pHandler( NULL );
48 
49         switch ( i_propertyId )
50         {
51         case PID_DATE_MIN:
52         case PID_DATE_MAX:
53         case PID_DEFAULT_DATE:
54         case PID_DATE:
55             if ( s_pVCLDateHandler.get() == NULL )
56             {
57                 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
58                 if ( s_pVCLDateHandler == NULL )
59                     s_pVCLDateHandler = new VCLDateHandler();
60             }
61             pHandler = s_pVCLDateHandler;
62             break;
63 
64         case PID_TIME_MIN:
65         case PID_TIME_MAX:
66         case PID_DEFAULT_TIME:
67         case PID_TIME:
68             if ( s_pVCLTimeHandler.get() == NULL )
69             {
70                 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
71                 if ( s_pVCLTimeHandler == NULL )
72                     s_pVCLTimeHandler = new VCLTimeHandler();
73             }
74             pHandler = s_pVCLTimeHandler;
75             break;
76 
77         default:
78             OSL_ENSURE( false, "FormHandlerFactory::getFormPropertyHandler: unknown property ID!" );
79             break;
80         }
81 
82         return pHandler;
83     }
84 
85 //......................................................................................................................
86 } // namespace xmloff
87 //......................................................................................................................
88