bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / xmloff / prhdlfac.hxx
blob2ad3f3d7a920d20d2bfc2e2471b416436181c416
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 INCLUDED_XMLOFF_PRHDLFAC_HXX
21 #define INCLUDED_XMLOFF_PRHDLFAC_HXX
23 #include <xmloff/dllapi.h>
24 #include <sal/types.h>
26 #include <salhelper/simplereferenceobject.hxx>
27 #include <memory>
29 class XMLPropertyHandler;
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 salhelper::SimpleReferenceObject
42 struct Impl;
43 std::unique_ptr<Impl> mpImpl;
45 XMLPropertyHandlerFactory( const XMLPropertyHandlerFactory& ) = delete;
46 XMLPropertyHandlerFactory& operator= ( const XMLPropertyHandlerFactory& ) = delete;
48 public:
49 XMLPropertyHandlerFactory();
50 virtual ~XMLPropertyHandlerFactory() override;
52 /**
53 This method retrieves a PropertyHandler for the given XML-type.
54 To extend this method for more XML-types override this method
55 like the example below. If you call the method of the base-class
56 you get propertyhandler for basic-XML-types ( e.g. for color, percent, ... ).
57 After that you could create your new XML-types. After creating a new type
58 you have to put the pointer into the cache via the method
59 PutHdlCache( sal_Int32 , XMLPropertyHandler* ).
61 virtual const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nType ) const
63 XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
65 if( !pHdl )
67 switch( nType )
69 case XML_TYPE_XYZ :
70 pHdl = new XML_xyz_PropHdl;
71 break;
72 case ...
77 if( pHdl )
78 PutHdlCache( nType, pHdl );
81 return pHdl;
84 virtual const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nType ) const;
86 /** helper method to statically create a property handler; this will not
87 * use the handler cache. This method should only be called in special
88 * circumstances; calling GetPropertyHandler is almost always
89 * preferable. */
90 static std::unique_ptr<XMLPropertyHandler> CreatePropertyHandler( sal_Int32 nType );
92 protected:
93 /** Retrieves a PropertyHandler from the internal cache */
94 const XMLPropertyHandler* GetHdlCache( sal_Int32 nType ) const;
95 /** Puts a PropertyHandler into the internal cache */
96 void PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const;
98 private:
99 /** Retrieves ( creates if necessary ) PropertyHandler for
100 basic XML-types */
101 SAL_DLLPRIVATE const XMLPropertyHandler* GetBasicHandler( sal_Int32 nType ) const;
104 #endif // INCLUDED_XMLOFF_PRHDLFAC_HXX
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */