Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / forms / handler / form_handler_factory.cxx
blob1444f9cb883b219f1f78a4a53361db1cbb5b25f2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "forms/form_handler_factory.hxx"
21 #include "vcl_date_handler.hxx"
22 #include "vcl_time_handler.hxx"
23 #include <osl/diagnose.h>
24 #include <osl/mutex.hxx>
26 namespace xmloff
29 namespace
31 static PPropertyHandler s_pVCLDateHandler = nullptr;
32 static PPropertyHandler s_pVCLTimeHandler = nullptr;
35 //= FormHandlerFactory
36 PPropertyHandler FormHandlerFactory::getFormPropertyHandler( const PropertyId i_propertyId )
38 PPropertyHandler pHandler( nullptr );
40 switch ( i_propertyId )
42 case PID_DATE_MIN:
43 case PID_DATE_MAX:
44 case PID_DEFAULT_DATE:
45 case PID_DATE:
46 if ( s_pVCLDateHandler.get() == nullptr )
48 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
49 if ( s_pVCLDateHandler == nullptr )
50 s_pVCLDateHandler = new VCLDateHandler();
52 pHandler = s_pVCLDateHandler;
53 break;
55 case PID_TIME_MIN:
56 case PID_TIME_MAX:
57 case PID_DEFAULT_TIME:
58 case PID_TIME:
59 if ( s_pVCLTimeHandler.get() == nullptr )
61 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
62 if ( s_pVCLTimeHandler == nullptr )
63 s_pVCLTimeHandler = new VCLTimeHandler();
65 pHandler = s_pVCLTimeHandler;
66 break;
68 default:
69 OSL_ENSURE( false, "FormHandlerFactory::getFormPropertyHandler: unknown property ID!" );
70 break;
73 return pHandler;
76 } // namespace xmloff
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */