Branch data 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 XMLOFF_PROPERTY_DESCRIPTION_HXX
21 : : #define XMLOFF_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 : : //......................................................................................................................
32 : : namespace xmloff
33 : : {
34 : : //......................................................................................................................
35 : :
36 : : //==================================================================================================================
37 : : //= PropertyDescription
38 : : //==================================================================================================================
39 : : struct AttributeDescription
40 : : {
41 : : sal_uInt16 namespacePrefix; // usually XML_NAMESPACE_FORM
42 : : ::xmloff::token::XMLTokenEnum attributeToken;
43 : :
44 : 239 : AttributeDescription()
45 : : :namespacePrefix( 0 )
46 : 239 : ,attributeToken( ::xmloff::token::XML_TOKEN_INVALID )
47 : : {
48 : 239 : }
49 : :
50 : 64 : AttributeDescription(
51 : : const sal_uInt16 i_namespacePrefix,
52 : : const ::xmloff::token::XMLTokenEnum i_attributeToken
53 : : )
54 : : :namespacePrefix( i_namespacePrefix )
55 : 64 : ,attributeToken( i_attributeToken )
56 : : {
57 : 64 : }
58 : : };
59 : :
60 : : //..................................................................................................................
61 : 15 : inline bool operator==( const AttributeDescription& i_lhs, const AttributeDescription& i_rhs )
62 : : {
63 : : return ( i_lhs.namespacePrefix == i_rhs.namespacePrefix )
64 [ + - ][ + - ]: 15 : && ( i_lhs.attributeToken == i_rhs.attributeToken );
65 : : }
66 : :
67 : : //==================================================================================================================
68 : : //= PropertyDescription
69 : : //==================================================================================================================
70 : 72 : struct PropertyDescription
71 : : {
72 : : /// is the name of the property
73 : : const ::rtl::OUString propertyName;
74 : : /** denotes the attribute which represents the property. Note that multiple properties might comprise a single
75 : : attribute value.
76 : : */
77 : : const AttributeDescription attribute;
78 : : /// is the factory for creating a handler for reading and writing the property
79 : : const PropertyHandlerFactory factory;
80 : : /// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
81 : : const PropertyId propertyId;
82 : : /** the group which the property belongs to. Multiple properties belonging to the same group will, all together,
83 : : define the attribute value to be written into the ODF file.
84 : :
85 : : Consequently, properties which have the same |propertyGroup| value must also have the same |attribute|
86 : : and the same |factory| value, with the only exception being NO_GROUP properties.
87 : :
88 : : Note that the other direction is not given: It is perfectly legitimate to map the same attribute to different
89 : : (disjunct) property groups.
90 : : */
91 : : const PropertyGroup propertyGroup;
92 : :
93 : 8 : PropertyDescription()
94 : : :propertyName()
95 : : ,attribute()
96 : : ,factory( NULL )
97 : : ,propertyId( PID_INVALID )
98 : 8 : ,propertyGroup( NO_GROUP )
99 : : {
100 : 8 : }
101 : :
102 : 64 : PropertyDescription(
103 : : const ::rtl::OUString& i_propertyName,
104 : : const sal_uInt16 i_namespacePrefix,
105 : : const ::xmloff::token::XMLTokenEnum i_attributeToken,
106 : : const PropertyHandlerFactory i_factory,
107 : : const PropertyId i_propertyId,
108 : : const PropertyGroup i_propertyGroup
109 : : )
110 : : :propertyName( i_propertyName )
111 : : ,attribute( i_namespacePrefix, i_attributeToken )
112 : : ,factory( i_factory )
113 : : ,propertyId( i_propertyId )
114 : 64 : ,propertyGroup( i_propertyGroup )
115 : : {
116 : 64 : }
117 : : };
118 : :
119 : : //==================================================================================================================
120 : : //= PropertyDescriptionList
121 : : //==================================================================================================================
122 : : typedef ::std::vector< const PropertyDescription* > PropertyDescriptionList;
123 : :
124 : : //==================================================================================================================
125 : : //= PropertyGroups
126 : : //==================================================================================================================
127 : : typedef ::std::list< PropertyDescriptionList > PropertyGroups;
128 : :
129 : : //......................................................................................................................
130 : : } // namespace xmloff
131 : : //......................................................................................................................
132 : :
133 : : #endif // XMLOFF_PROPERTY_DESCRIPTION_HXX
134 : :
135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|