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