Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_DESCRIPTION_HXX
21 : #define INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_DESCRIPTION_HXX
22 :
23 : #include "forms/property_handler.hxx"
24 : #include "property_group.hxx"
25 :
26 : #include <xmloff/xmltoken.hxx>
27 :
28 : #include <vector>
29 : #include <list>
30 :
31 : namespace xmloff
32 : {
33 :
34 : //= PropertyDescription
35 : struct AttributeDescription
36 : {
37 : sal_uInt16 namespacePrefix; // usually XML_NAMESPACE_FORM
38 : ::xmloff::token::XMLTokenEnum attributeToken;
39 :
40 271 : AttributeDescription()
41 : :namespacePrefix( 0 )
42 271 : ,attributeToken( ::xmloff::token::XML_TOKEN_INVALID )
43 : {
44 271 : }
45 :
46 80 : AttributeDescription(
47 : const sal_uInt16 i_namespacePrefix,
48 : const ::xmloff::token::XMLTokenEnum i_attributeToken
49 : )
50 : :namespacePrefix( i_namespacePrefix )
51 80 : ,attributeToken( i_attributeToken )
52 : {
53 80 : }
54 : };
55 :
56 5 : inline bool operator==( const AttributeDescription& i_lhs, const AttributeDescription& i_rhs )
57 : {
58 5 : return ( i_lhs.namespacePrefix == i_rhs.namespacePrefix )
59 5 : && ( i_lhs.attributeToken == i_rhs.attributeToken );
60 : }
61 :
62 : //= PropertyDescription
63 90 : struct PropertyDescription
64 : {
65 : /// is the name of the property
66 : const OUString propertyName;
67 : /** denotes the attribute which represents the property. Note that multiple properties might comprise a single
68 : attribute value.
69 : */
70 : const AttributeDescription attribute;
71 : /// is the factory for creating a handler for reading and writing the property
72 : const PropertyHandlerFactory factory;
73 : /// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
74 : const PropertyId propertyId;
75 : /** the group which the property belongs to. Multiple properties belonging to the same group will, all together,
76 : define the attribute value to be written into the ODF file.
77 :
78 : Consequently, properties which have the same |propertyGroup| value must also have the same |attribute|
79 : and the same |factory| value, with the only exception being NO_GROUP properties.
80 :
81 : Note that the other direction is not given: It is perfectly legitimate to map the same attribute to different
82 : (disjunct) property groups.
83 : */
84 : const PropertyGroup propertyGroup;
85 :
86 10 : PropertyDescription()
87 : :propertyName()
88 : ,attribute()
89 : ,factory( NULL )
90 : ,propertyId( PID_INVALID )
91 10 : ,propertyGroup( NO_GROUP )
92 : {
93 10 : }
94 :
95 80 : PropertyDescription(
96 : const OUString& i_propertyName,
97 : const sal_uInt16 i_namespacePrefix,
98 : const ::xmloff::token::XMLTokenEnum i_attributeToken,
99 : const PropertyHandlerFactory i_factory,
100 : const PropertyId i_propertyId,
101 : const PropertyGroup i_propertyGroup
102 : )
103 : :propertyName( i_propertyName )
104 : ,attribute( i_namespacePrefix, i_attributeToken )
105 : ,factory( i_factory )
106 : ,propertyId( i_propertyId )
107 80 : ,propertyGroup( i_propertyGroup )
108 : {
109 80 : }
110 : };
111 :
112 : //= PropertyDescriptionList
113 : typedef ::std::vector< const PropertyDescription* > PropertyDescriptionList;
114 :
115 : //= PropertyGroups
116 : typedef ::std::list< PropertyDescriptionList > PropertyGroups;
117 :
118 : } // namespace xmloff
119 :
120 : #endif // INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_DESCRIPTION_HXX
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|