1*ecfe53c5SAndrew Rist /**************************************************************
2*ecfe53c5SAndrew Rist  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ecfe53c5SAndrew Rist  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ecfe53c5SAndrew Rist  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19*ecfe53c5SAndrew Rist  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef XMLOFF_PROPERTY_DESCRIPTION_HXX
25cdf0e10cSrcweir #define XMLOFF_PROPERTY_DESCRIPTION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "forms/property_handler.hxx"
28cdf0e10cSrcweir #include "property_group.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "xmloff/xmltoken.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vector>
33cdf0e10cSrcweir #include <list>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //......................................................................................................................
36cdf0e10cSrcweir namespace xmloff
37cdf0e10cSrcweir {
38cdf0e10cSrcweir //......................................................................................................................
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 	//==================================================================================================================
41cdf0e10cSrcweir 	//= PropertyDescription
42cdf0e10cSrcweir 	//==================================================================================================================
43cdf0e10cSrcweir     struct AttributeDescription
44cdf0e10cSrcweir     {
45cdf0e10cSrcweir         sal_uInt16                      namespacePrefix;    // usually XML_NAMESPACE_FORM
46cdf0e10cSrcweir         ::xmloff::token::XMLTokenEnum   attributeToken;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir         AttributeDescription()
49cdf0e10cSrcweir             :namespacePrefix( 0 )
50cdf0e10cSrcweir             ,attributeToken( ::xmloff::token::XML_TOKEN_INVALID )
51cdf0e10cSrcweir         {
52cdf0e10cSrcweir         }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir         AttributeDescription(
55cdf0e10cSrcweir                 const sal_uInt16                    i_namespacePrefix,
56cdf0e10cSrcweir                 const ::xmloff::token::XMLTokenEnum i_attributeToken
57cdf0e10cSrcweir             )
58cdf0e10cSrcweir             :namespacePrefix( i_namespacePrefix )
59cdf0e10cSrcweir             ,attributeToken( i_attributeToken )
60cdf0e10cSrcweir         {
61cdf0e10cSrcweir         }
62cdf0e10cSrcweir     };
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     //..................................................................................................................
65cdf0e10cSrcweir     inline bool operator==( const AttributeDescription& i_lhs, const AttributeDescription& i_rhs )
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir         return  ( i_lhs.namespacePrefix == i_rhs.namespacePrefix )
68cdf0e10cSrcweir             &&  ( i_lhs.attributeToken == i_rhs.attributeToken );
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	//==================================================================================================================
72cdf0e10cSrcweir 	//= PropertyDescription
73cdf0e10cSrcweir 	//==================================================================================================================
74cdf0e10cSrcweir 	struct PropertyDescription
75cdf0e10cSrcweir 	{
76cdf0e10cSrcweir         /// is the name of the property
77cdf0e10cSrcweir         const ::rtl::OUString               propertyName;
78cdf0e10cSrcweir         /** denotes the attribute which represents the property. Note that multiple properties might comprise a single
79cdf0e10cSrcweir             attribute value.
80cdf0e10cSrcweir         */
81cdf0e10cSrcweir         const AttributeDescription          attribute;
82cdf0e10cSrcweir         /// is the factory for creating a handler for reading and writing the property
83cdf0e10cSrcweir         const PropertyHandlerFactory        factory;
84cdf0e10cSrcweir         /// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
85cdf0e10cSrcweir         const PropertyId                    propertyId;
86cdf0e10cSrcweir         /** the group which the property belongs to. Multiple properties belonging to the same group will, all together,
87cdf0e10cSrcweir             define the attribute value to be written into the ODF file.
88cdf0e10cSrcweir 
89cdf0e10cSrcweir             Consequently, properties which have the same |propertyGroup| value must also have the same |attribute|
90cdf0e10cSrcweir             and the same |factory| value, with the only exception being NO_GROUP properties.
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             Note that the other direction is not given: It is perfectly legitimate to map the same attribute to different
93cdf0e10cSrcweir             (disjunct) property groups.
94cdf0e10cSrcweir         */
95cdf0e10cSrcweir         const PropertyGroup                 propertyGroup;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         PropertyDescription()
98cdf0e10cSrcweir             :propertyName()
99cdf0e10cSrcweir             ,attribute()
100cdf0e10cSrcweir             ,factory( NULL )
101cdf0e10cSrcweir             ,propertyId( PID_INVALID )
102cdf0e10cSrcweir             ,propertyGroup( NO_GROUP )
103cdf0e10cSrcweir         {
104cdf0e10cSrcweir         }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         PropertyDescription(
107cdf0e10cSrcweir             const ::rtl::OUString&              i_propertyName,
108cdf0e10cSrcweir             const sal_uInt16                    i_namespacePrefix,
109cdf0e10cSrcweir             const ::xmloff::token::XMLTokenEnum i_attributeToken,
110cdf0e10cSrcweir             const PropertyHandlerFactory        i_factory,
111cdf0e10cSrcweir             const PropertyId                    i_propertyId,
112cdf0e10cSrcweir             const PropertyGroup                 i_propertyGroup
113cdf0e10cSrcweir         )
114cdf0e10cSrcweir             :propertyName( i_propertyName )
115cdf0e10cSrcweir             ,attribute( i_namespacePrefix, i_attributeToken )
116cdf0e10cSrcweir             ,factory( i_factory )
117cdf0e10cSrcweir             ,propertyId( i_propertyId )
118cdf0e10cSrcweir             ,propertyGroup( i_propertyGroup )
119cdf0e10cSrcweir         {
120cdf0e10cSrcweir         }
121cdf0e10cSrcweir 	};
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	//==================================================================================================================
124cdf0e10cSrcweir 	//= PropertyDescriptionList
125cdf0e10cSrcweir 	//==================================================================================================================
126cdf0e10cSrcweir     typedef ::std::vector< const PropertyDescription* > PropertyDescriptionList;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	//==================================================================================================================
129cdf0e10cSrcweir 	//= PropertyGroups
130cdf0e10cSrcweir 	//==================================================================================================================
131cdf0e10cSrcweir     typedef ::std::list< PropertyDescriptionList >  PropertyGroups;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir //......................................................................................................................
134cdf0e10cSrcweir } // namespace xmloff
135cdf0e10cSrcweir //......................................................................................................................
136cdf0e10cSrcweir 
137cdf0e10cSrcweir #endif // XMLOFF_PROPERTY_DESCRIPTION_HXX
138