1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
10  * OpenOffice.org is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License version 3
12  * only, as published by the Free Software Foundation.
13  *
14  * OpenOffice.org is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License version 3 for more details
18  * (a copy is included in the LICENSE file that accompanied this code).
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with OpenOffice.org.  If not, see
22  * <http://www.openoffice.org/license.html>
23  * for a copy of the LGPLv3 License.
24  *
25  ************************************************************************/
26 
27 #ifndef XMLOFF_PROPERTY_DESCRIPTION_HXX
28 #define XMLOFF_PROPERTY_DESCRIPTION_HXX
29 
30 #include "forms/property_handler.hxx"
31 #include "property_group.hxx"
32 
33 #include "xmloff/xmltoken.hxx"
34 
35 #include <vector>
36 #include <list>
37 
38 //......................................................................................................................
39 namespace xmloff
40 {
41 //......................................................................................................................
42 
43 	//==================================================================================================================
44 	//= PropertyDescription
45 	//==================================================================================================================
46     struct AttributeDescription
47     {
48         sal_uInt16                      namespacePrefix;    // usually XML_NAMESPACE_FORM
49         ::xmloff::token::XMLTokenEnum   attributeToken;
50 
51         AttributeDescription()
52             :namespacePrefix( 0 )
53             ,attributeToken( ::xmloff::token::XML_TOKEN_INVALID )
54         {
55         }
56 
57         AttributeDescription(
58                 const sal_uInt16                    i_namespacePrefix,
59                 const ::xmloff::token::XMLTokenEnum i_attributeToken
60             )
61             :namespacePrefix( i_namespacePrefix )
62             ,attributeToken( i_attributeToken )
63         {
64         }
65     };
66 
67     //..................................................................................................................
68     inline bool operator==( const AttributeDescription& i_lhs, const AttributeDescription& i_rhs )
69     {
70         return  ( i_lhs.namespacePrefix == i_rhs.namespacePrefix )
71             &&  ( i_lhs.attributeToken == i_rhs.attributeToken );
72     }
73 
74 	//==================================================================================================================
75 	//= PropertyDescription
76 	//==================================================================================================================
77 	struct PropertyDescription
78 	{
79         /// is the name of the property
80         const ::rtl::OUString               propertyName;
81         /** denotes the attribute which represents the property. Note that multiple properties might comprise a single
82             attribute value.
83         */
84         const AttributeDescription          attribute;
85         /// is the factory for creating a handler for reading and writing the property
86         const PropertyHandlerFactory        factory;
87         /// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
88         const PropertyId                    propertyId;
89         /** the group which the property belongs to. Multiple properties belonging to the same group will, all together,
90             define the attribute value to be written into the ODF file.
91 
92             Consequently, properties which have the same |propertyGroup| value must also have the same |attribute|
93             and the same |factory| value, with the only exception being NO_GROUP properties.
94 
95             Note that the other direction is not given: It is perfectly legitimate to map the same attribute to different
96             (disjunct) property groups.
97         */
98         const PropertyGroup                 propertyGroup;
99 
100         PropertyDescription()
101             :propertyName()
102             ,attribute()
103             ,factory( NULL )
104             ,propertyId( PID_INVALID )
105             ,propertyGroup( NO_GROUP )
106         {
107         }
108 
109         PropertyDescription(
110             const ::rtl::OUString&              i_propertyName,
111             const sal_uInt16                    i_namespacePrefix,
112             const ::xmloff::token::XMLTokenEnum i_attributeToken,
113             const PropertyHandlerFactory        i_factory,
114             const PropertyId                    i_propertyId,
115             const PropertyGroup                 i_propertyGroup
116         )
117             :propertyName( i_propertyName )
118             ,attribute( i_namespacePrefix, i_attributeToken )
119             ,factory( i_factory )
120             ,propertyId( i_propertyId )
121             ,propertyGroup( i_propertyGroup )
122         {
123         }
124 	};
125 
126 	//==================================================================================================================
127 	//= PropertyDescriptionList
128 	//==================================================================================================================
129     typedef ::std::vector< const PropertyDescription* > PropertyDescriptionList;
130 
131 	//==================================================================================================================
132 	//= PropertyGroups
133 	//==================================================================================================================
134     typedef ::std::list< PropertyDescriptionList >  PropertyGroups;
135 
136 //......................................................................................................................
137 } // namespace xmloff
138 //......................................................................................................................
139 
140 #endif // XMLOFF_PROPERTY_DESCRIPTION_HXX
141