bump product version to 4.1.6.2
[LibreOffice.git] / include / xmloff / prhdlfac.hxx
blobafd3472d111cf3cb17d69ce852f3c7d580d71491
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 #ifndef _XMLOFF_PROPERTYHANDLERFACTORY_HXX
21 #define _XMLOFF_PROPERTYHANDLERFACTORY_HXX
23 #include "sal/config.h"
24 #include "xmloff/dllapi.h"
25 #include "sal/types.h"
27 #include <map>
28 #include <xmloff/uniref.hxx>
29 #include <xmloff/xmlprhdl.hxx>
31 /**
32 This class is a base-class to create XMLPropertyHandler.
33 It creates PropertyHandler for given XML-types and store
34 them in an internal cache. They'll be deleted at destruction-
35 time.
36 For create your own PropertyHandler for specific XML-types
37 you have to override the virtual method GetPropertyHandler
38 ( see below ).
40 class XMLOFF_DLLPUBLIC XMLPropertyHandlerFactory : public UniRefBase
42 public:
43 virtual ~XMLPropertyHandlerFactory();
45 /**
46 This method retrieves a PropertyHandler for the given XML-type.
47 To extend this method for more XML-types override this method
48 like the example below. If you call the method of the base-class
49 you get propertyhandler for basic-XML-types ( e.g. for color, percent, ... ).
50 Afetr that you could create your new XML-types. After creating a new type
51 you have to put the pointer into the cache via the method
52 PutHdlCache( sal_Int32 , XMLPropertyHandler* ).
54 virtual const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nType ) const
56 XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
58 if( !pHdl )
60 switch( nType )
62 case XML_TYPE_XYZ :
63 pHdl = new XML_xyz_PropHdl;
64 break;
65 case ...
70 if( pHdl )
71 PutHdlCache( nType, pHdl );
74 return pHdl;
77 virtual const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nType ) const;
79 /** helper method to statically create a property handler; this will not
80 * use the handler cache. This method should only be called in special
81 * circumstances; calling GetPropertyHandler is almost always
82 * preferable. */
83 static const XMLPropertyHandler* CreatePropertyHandler( sal_Int32 nType );
85 protected:
86 /** Retrieves a PropertyHandler from the internal cache */
87 XMLPropertyHandler* GetHdlCache( sal_Int32 nType ) const;
88 /** Puts a PropertyHandler into the internal cache */
89 void PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const;
91 private:
92 /** Retrieves ( creates if necessary ) PropertyHandler for
93 basic XML-types */
94 SAL_DLLPRIVATE const XMLPropertyHandler* GetBasicHandler( sal_Int32 nType )
95 const;
97 typedef ::std::map< sal_Int32, XMLPropertyHandler* > CacheMap;
98 CacheMap maHandlerCache;
101 #endif // _XMLOFF_PROPERTYHANDLERFACTORY_HXX
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */