1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
28 #include <xmloff/uniref.hxx>
29 #include <xmloff/xmlprhdl.hxx>
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-
36 For create your own PropertyHandler for specific XML-types
37 you have to override the virtual method GetPropertyHandler
40 class XMLOFF_DLLPUBLIC XMLPropertyHandlerFactory
: public UniRefBase
43 virtual ~XMLPropertyHandlerFactory();
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 );
63 pHdl = new XML_xyz_PropHdl;
71 PutHdlCache( nType, 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
83 static const XMLPropertyHandler
* CreatePropertyHandler( sal_Int32 nType
);
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;
92 /** Retrieves ( creates if necessary ) PropertyHandler for
94 SAL_DLLPRIVATE
const XMLPropertyHandler
* GetBasicHandler( sal_Int32 nType
)
97 typedef ::std::map
< sal_Int32
, XMLPropertyHandler
* > CacheMap
;
98 CacheMap maHandlerCache
;
101 #endif // _XMLOFF_PROPERTYHANDLERFACTORY_HXX
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */