1*ecfe53c5SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 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_FORMATTRIBUTES_HXX_ 25cdf0e10cSrcweir #define _XMLOFF_FORMATTRIBUTES_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 28cdf0e10cSrcweir #include <sal/types.h> 29cdf0e10cSrcweir #include <vos/refernce.hxx> 30cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir class SvXMLExport; 33cdf0e10cSrcweir struct SvXMLEnumMapEntry; 34cdf0e10cSrcweir 35cdf0e10cSrcweir //......................................................................... 36cdf0e10cSrcweir namespace xmloff 37cdf0e10cSrcweir { 38cdf0e10cSrcweir //......................................................................... 39cdf0e10cSrcweir 40cdf0e10cSrcweir // flags for common control attributes 41cdf0e10cSrcweir #define CCA_NAME 0x00000001 42cdf0e10cSrcweir #define CCA_SERVICE_NAME 0x00000002 43cdf0e10cSrcweir #define CCA_BUTTON_TYPE 0x00000004 44cdf0e10cSrcweir #define CCA_CONTROL_ID 0x00000008 45cdf0e10cSrcweir #define CCA_CURRENT_SELECTED 0x00000010 46cdf0e10cSrcweir #define CCA_CURRENT_VALUE 0x00000020 47cdf0e10cSrcweir #define CCA_DISABLED 0x00000040 48cdf0e10cSrcweir #define CCA_DROPDOWN 0x00000080 49cdf0e10cSrcweir #define CCA_FOR 0x00000100 50cdf0e10cSrcweir #define CCA_IMAGE_DATA 0x00000200 51cdf0e10cSrcweir #define CCA_LABEL 0x00000400 52cdf0e10cSrcweir #define CCA_MAX_LENGTH 0x00000800 53cdf0e10cSrcweir #define CCA_PRINTABLE 0x00001000 54cdf0e10cSrcweir #define CCA_READONLY 0x00002000 55cdf0e10cSrcweir #define CCA_SELECTED 0x00004000 56cdf0e10cSrcweir #define CCA_SIZE 0x00008000 57cdf0e10cSrcweir #define CCA_TAB_INDEX 0x00010000 58cdf0e10cSrcweir #define CCA_TARGET_FRAME 0x00020000 59cdf0e10cSrcweir #define CCA_TARGET_LOCATION 0x00040000 60cdf0e10cSrcweir #define CCA_TAB_STOP 0x00080000 61cdf0e10cSrcweir #define CCA_TITLE 0x00100000 62cdf0e10cSrcweir #define CCA_VALUE 0x00200000 63cdf0e10cSrcweir #define CCA_ORIENTATION 0x00400000 64cdf0e10cSrcweir #define CCA_VISUAL_EFFECT 0x00800000 65cdf0e10cSrcweir #define CCA_ENABLEVISIBLE 0x01000000 66cdf0e10cSrcweir 67cdf0e10cSrcweir // flags for database control atttributes 68cdf0e10cSrcweir #define DA_BOUND_COLUMN 0x00000001 69cdf0e10cSrcweir #define DA_CONVERT_EMPTY 0x00000002 70cdf0e10cSrcweir #define DA_DATA_FIELD 0x00000004 71cdf0e10cSrcweir #define DA_LIST_SOURCE 0x00000008 72cdf0e10cSrcweir #define DA_LIST_SOURCE_TYPE 0x00000010 73cdf0e10cSrcweir #define DA_INPUT_REQUIRED 0x00000020 74cdf0e10cSrcweir 75cdf0e10cSrcweir // flags for binding related control attributes 76cdf0e10cSrcweir #define BA_LINKED_CELL 0x00000001 77cdf0e10cSrcweir #define BA_LIST_LINKING_TYPE 0x00000002 78cdf0e10cSrcweir #define BA_LIST_CELL_RANGE 0x00000004 79cdf0e10cSrcweir #define BA_XFORMS_BIND 0x00000008 80cdf0e10cSrcweir #define BA_XFORMS_LISTBIND 0x00000010 81cdf0e10cSrcweir #define BA_XFORMS_SUBMISSION 0x00000020 82cdf0e10cSrcweir 83cdf0e10cSrcweir // flags for event attributes 84cdf0e10cSrcweir #define EA_CONTROL_EVENTS 0x00000001 85cdf0e10cSrcweir #define EA_ON_CHANGE 0x00000002 86cdf0e10cSrcweir #define EA_ON_CLICK 0x00000004 87cdf0e10cSrcweir #define EA_ON_DBLCLICK 0x00000008 88cdf0e10cSrcweir #define EA_ON_SELECT 0x00000010 89cdf0e10cSrcweir 90cdf0e10cSrcweir /// attributes in the xml tag representing a form 91cdf0e10cSrcweir enum FormAttributes 92cdf0e10cSrcweir { 93cdf0e10cSrcweir faName, 94cdf0e10cSrcweir faServiceName, 95cdf0e10cSrcweir faAction, 96cdf0e10cSrcweir faEnctype, 97cdf0e10cSrcweir faMethod, 98cdf0e10cSrcweir faTargetFrame, 99cdf0e10cSrcweir faAllowDeletes, 100cdf0e10cSrcweir faAllowInserts, 101cdf0e10cSrcweir faAllowUpdates, 102cdf0e10cSrcweir faApplyFilter, 103cdf0e10cSrcweir faCommand, 104cdf0e10cSrcweir faCommandType, 105cdf0e10cSrcweir faEscapeProcessing, 106cdf0e10cSrcweir faDatasource, 107cdf0e10cSrcweir faConnectionResource, 108cdf0e10cSrcweir faDetailFiels, 109cdf0e10cSrcweir faFilter, 110cdf0e10cSrcweir faIgnoreResult, 111cdf0e10cSrcweir faMasterFields, 112cdf0e10cSrcweir faNavigationMode, 113cdf0e10cSrcweir faOrder, 114cdf0e10cSrcweir faTabbingCycle 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir // any other attributes, which are special to some control types 118cdf0e10cSrcweir #define SCA_ECHO_CHAR 0x00000001 119cdf0e10cSrcweir #define SCA_MAX_VALUE 0x00000002 120cdf0e10cSrcweir #define SCA_MIN_VALUE 0x00000004 121cdf0e10cSrcweir #define SCA_VALIDATION 0x00000008 122cdf0e10cSrcweir #define SCA_MULTI_LINE 0x00000020 123cdf0e10cSrcweir #define SCA_AUTOMATIC_COMPLETION 0x00000080 124cdf0e10cSrcweir #define SCA_MULTIPLE 0x00000100 125cdf0e10cSrcweir #define SCA_DEFAULT_BUTTON 0x00000200 126cdf0e10cSrcweir #define SCA_CURRENT_STATE 0x00000400 127cdf0e10cSrcweir #define SCA_IS_TRISTATE 0x00000800 128cdf0e10cSrcweir #define SCA_STATE 0x00001000 129cdf0e10cSrcweir #define SCA_COLUMN_STYLE_NAME 0x00002000 130cdf0e10cSrcweir #define SCA_STEP_SIZE 0x00004000 131cdf0e10cSrcweir #define SCA_PAGE_STEP_SIZE 0x00008000 132cdf0e10cSrcweir #define SCA_REPEAT_DELAY 0x00010000 133cdf0e10cSrcweir #define SCA_TOGGLE 0x00020000 134cdf0e10cSrcweir #define SCA_FOCUS_ON_CLICK 0x00040000 135cdf0e10cSrcweir #define SCA_IMAGE_POSITION 0x00080000 136cdf0e10cSrcweir 137cdf0e10cSrcweir // attributes of the office:forms element 138cdf0e10cSrcweir enum OfficeFormsAttributes 139cdf0e10cSrcweir { 140cdf0e10cSrcweir ofaAutomaticFocus, 141cdf0e10cSrcweir ofaApplyDesignMode 142cdf0e10cSrcweir }; 143cdf0e10cSrcweir 144cdf0e10cSrcweir //===================================================================== 145cdf0e10cSrcweir //= OAttributeMetaData 146cdf0e10cSrcweir //===================================================================== 147cdf0e10cSrcweir /** allows the translation of attribute ids into strings. 148cdf0e10cSrcweir 149cdf0e10cSrcweir <p>This class does not allow to connect xml attributes to property names or 150cdf0e10cSrcweir something like that, it only deals with the xml side</p> 151cdf0e10cSrcweir */ 152cdf0e10cSrcweir class OAttributeMetaData 153cdf0e10cSrcweir { 154cdf0e10cSrcweir public: 155cdf0e10cSrcweir /** calculates the xml attribute representation of a common control attribute. 156cdf0e10cSrcweir @param _nId 157cdf0e10cSrcweir the id of the attribute. Has to be one of the CCA_* constants. 158cdf0e10cSrcweir */ 159cdf0e10cSrcweir static const sal_Char* getCommonControlAttributeName(sal_Int32 _nId); 160cdf0e10cSrcweir 161cdf0e10cSrcweir /** calculates the xml namespace key to use for a common control attribute 162cdf0e10cSrcweir @param _nId 163cdf0e10cSrcweir the id of the attribute. Has to be one of the CCA_* constants. 164cdf0e10cSrcweir */ 165cdf0e10cSrcweir static sal_uInt16 getCommonControlAttributeNamespace(sal_Int32 _nId); 166cdf0e10cSrcweir 167cdf0e10cSrcweir /** retrieves the name of an attribute of a form xml representation 168cdf0e10cSrcweir @param _eAttrib 169cdf0e10cSrcweir enum value specifying the attribute 170cdf0e10cSrcweir */ 171cdf0e10cSrcweir static const sal_Char* getFormAttributeName(FormAttributes _eAttrib); 172cdf0e10cSrcweir 173cdf0e10cSrcweir /** calculates the xml namespace key to use for a attribute of a form xml representation 174cdf0e10cSrcweir @param _eAttrib 175cdf0e10cSrcweir enum value specifying the attribute 176cdf0e10cSrcweir */ 177cdf0e10cSrcweir static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib); 178cdf0e10cSrcweir 179cdf0e10cSrcweir /** calculates the xml attribute representation of a database attribute. 180cdf0e10cSrcweir @param _nId 181cdf0e10cSrcweir the id of the attribute. Has to be one of the DA_* constants. 182cdf0e10cSrcweir */ 183cdf0e10cSrcweir static const sal_Char* getDatabaseAttributeName(sal_Int32 _nId); 184cdf0e10cSrcweir 185cdf0e10cSrcweir /** calculates the xml namespace key to use for a database attribute. 186cdf0e10cSrcweir @param _nId 187cdf0e10cSrcweir the id of the attribute. Has to be one of the DA_* constants. 188cdf0e10cSrcweir */ 189cdf0e10cSrcweir static sal_uInt16 getDatabaseAttributeNamespace(sal_Int32 _nId); 190cdf0e10cSrcweir 191cdf0e10cSrcweir /** calculates the xml attribute representation of a special attribute. 192cdf0e10cSrcweir @param _nId 193cdf0e10cSrcweir the id of the attribute. Has to be one of the SCA_* constants. 194cdf0e10cSrcweir */ 195cdf0e10cSrcweir static const sal_Char* getSpecialAttributeName(sal_Int32 _nId); 196cdf0e10cSrcweir 197cdf0e10cSrcweir /** calculates the xml attribute representation of a binding attribute. 198cdf0e10cSrcweir @param _nId 199cdf0e10cSrcweir the id of the attribute. Has to be one of the BA_* constants. 200cdf0e10cSrcweir */ 201cdf0e10cSrcweir static const sal_Char* getBindingAttributeName(sal_Int32 _nId); 202cdf0e10cSrcweir 203cdf0e10cSrcweir /** calculates the xml namespace key to use for a binding attribute. 204cdf0e10cSrcweir @param _nId 205cdf0e10cSrcweir the id of the attribute. Has to be one of the BA_* constants. 206cdf0e10cSrcweir */ 207cdf0e10cSrcweir static sal_uInt16 getBindingAttributeNamespace(sal_Int32 _nId); 208cdf0e10cSrcweir 209cdf0e10cSrcweir /** calculates the xml namespace key to use for a special attribute. 210cdf0e10cSrcweir @param _nId 211cdf0e10cSrcweir the id of the attribute. Has to be one of the SCA_* constants. 212cdf0e10cSrcweir */ 213cdf0e10cSrcweir static sal_uInt16 getSpecialAttributeNamespace(sal_Int32 _nId); 214cdf0e10cSrcweir 215cdf0e10cSrcweir /** calculates the xml attribute representation of a attribute of the office:forms element 216cdf0e10cSrcweir @param _nId 217cdf0e10cSrcweir the id of the attribute 218cdf0e10cSrcweir */ 219cdf0e10cSrcweir static const sal_Char* getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib); 220cdf0e10cSrcweir 221cdf0e10cSrcweir /** calculates the xml namedspace key of a attribute of the office:forms element 222cdf0e10cSrcweir @param _nId 223cdf0e10cSrcweir the id of the attribute 224cdf0e10cSrcweir */ 225cdf0e10cSrcweir static sal_uInt16 getOfficeFormsAttributeNamespace(OfficeFormsAttributes _eAttrib); 226cdf0e10cSrcweir }; 227cdf0e10cSrcweir 228cdf0e10cSrcweir //===================================================================== 229cdf0e10cSrcweir //= OAttribute2Property 230cdf0e10cSrcweir //===================================================================== 231cdf0e10cSrcweir /** some kind of opposite to the OAttributeMetaData class. Able to translate 232cdf0e10cSrcweir attributes into property names/types 233cdf0e10cSrcweir 234cdf0e10cSrcweir <p>The construction of this class is rather expensive (or at least it's initialization from outside), 235cdf0e10cSrcweir so it should be shared</p> 236cdf0e10cSrcweir */ 237cdf0e10cSrcweir class OAttribute2Property 238cdf0e10cSrcweir { 239cdf0e10cSrcweir public: 240cdf0e10cSrcweir // TODO: maybe the following struct should be used for exports, too. In this case we would not need to 241cdf0e10cSrcweir // store it's instances in a map, but in a vector for faster access. 242cdf0e10cSrcweir struct AttributeAssignment 243cdf0e10cSrcweir { 244cdf0e10cSrcweir ::rtl::OUString sAttributeName; // the attribute name 245cdf0e10cSrcweir ::rtl::OUString sPropertyName; // the property name 246cdf0e10cSrcweir ::com::sun::star::uno::Type aPropertyType; // the property type 247cdf0e10cSrcweir ::rtl::OUString sAttributeDefault; // the default if the attribute is not present 248cdf0e10cSrcweir 249cdf0e10cSrcweir // entries which are special to some value types 250cdf0e10cSrcweir const SvXMLEnumMapEntry* pEnumMap; // the enum map, if appliable 251cdf0e10cSrcweir sal_Bool bInverseSemantics; // for booleanss: attribute and property value have the same or an inverse semantics? 252cdf0e10cSrcweir AttributeAssignmentxmloff::OAttribute2Property::AttributeAssignment253cdf0e10cSrcweir AttributeAssignment() : pEnumMap(NULL), bInverseSemantics(sal_False) { } 254cdf0e10cSrcweir }; 255cdf0e10cSrcweir 256cdf0e10cSrcweir protected: 257cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP( AttributeAssignment, AttributeAssignments ); 258cdf0e10cSrcweir AttributeAssignments m_aKnownProperties; 259cdf0e10cSrcweir 260cdf0e10cSrcweir public: 261cdf0e10cSrcweir OAttribute2Property(); 262cdf0e10cSrcweir virtual ~OAttribute2Property(); 263cdf0e10cSrcweir 264cdf0e10cSrcweir /** return the AttributeAssignment which corresponds to the given attribute 265cdf0e10cSrcweir 266cdf0e10cSrcweir @param _rAttribName 267cdf0e10cSrcweir the name of the attrribute 268cdf0e10cSrcweir @return 269cdf0e10cSrcweir a pointer to the <type>AttributeAssignment</type> structure as requested, NULL if the attribute 270cdf0e10cSrcweir does not represent a property. 271cdf0e10cSrcweir */ 272cdf0e10cSrcweir const AttributeAssignment* getAttributeTranslation( 273cdf0e10cSrcweir const ::rtl::OUString& _rAttribName); 274cdf0e10cSrcweir 275cdf0e10cSrcweir /** add a attribute assignment referring to a string property to the map 276cdf0e10cSrcweir @param _pAttributeName 277cdf0e10cSrcweir the name of the attrribute 278cdf0e10cSrcweir @param _rPropertyName 279cdf0e10cSrcweir the name of the property assigned to the attribute 280cdf0e10cSrcweir @param _pAttributeDefault 281cdf0e10cSrcweir the default value for the attribute, if any. May be NULL, in this case the default is assumed to be 282cdf0e10cSrcweir an empty string. 283cdf0e10cSrcweir */ 284cdf0e10cSrcweir void addStringProperty( 285cdf0e10cSrcweir const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, 286cdf0e10cSrcweir const sal_Char* _pAttributeDefault = NULL); 287cdf0e10cSrcweir 288cdf0e10cSrcweir /** add a attribute assignment referring to a boolean property to the map 289cdf0e10cSrcweir 290cdf0e10cSrcweir @param _pAttributeName 291cdf0e10cSrcweir the name of the attrribute 292cdf0e10cSrcweir @param _rPropertyName 293cdf0e10cSrcweir the name of the property assigned to the attribute 294cdf0e10cSrcweir @param _bAttributeDefault 295cdf0e10cSrcweir the default value for the attribute. 296cdf0e10cSrcweir @param _bInverseSemantics 297cdf0e10cSrcweir if <TRUE/>, a attribute value of <TRUE/> means a property value of <FALSE/> and vice verse.<br/> 298cdf0e10cSrcweir if <FALSE/>, the attribute value is used as property value directly 299cdf0e10cSrcweir */ 300cdf0e10cSrcweir void addBooleanProperty( 301cdf0e10cSrcweir const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, 302cdf0e10cSrcweir const sal_Bool _bAttributeDefault, const sal_Bool _bInverseSemantics = sal_False); 303cdf0e10cSrcweir 304cdf0e10cSrcweir /** add a attribute assignment referring to an int16 property to the map 305cdf0e10cSrcweir 306cdf0e10cSrcweir @param _pAttributeName 307cdf0e10cSrcweir the name of the attrribute 308cdf0e10cSrcweir @param _rPropertyName 309cdf0e10cSrcweir the name of the property assigned to the attribute 310cdf0e10cSrcweir @param _nAttributeDefault 311cdf0e10cSrcweir the default value for the attribute. 312cdf0e10cSrcweir */ 313cdf0e10cSrcweir void addInt16Property( 314cdf0e10cSrcweir const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, 315cdf0e10cSrcweir const sal_Int16 _nAttributeDefault); 316cdf0e10cSrcweir 317cdf0e10cSrcweir /** add a attribute assignment referring to an int32 property to the map 318cdf0e10cSrcweir 319cdf0e10cSrcweir @param _pAttributeName 320cdf0e10cSrcweir the name of the attrribute 321cdf0e10cSrcweir @param _rPropertyName 322cdf0e10cSrcweir the name of the property assigned to the attribute 323cdf0e10cSrcweir @param _nAttributeDefault 324cdf0e10cSrcweir the default value for the attribute. 325cdf0e10cSrcweir */ 326cdf0e10cSrcweir void addInt32Property( 327cdf0e10cSrcweir const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, 328cdf0e10cSrcweir const sal_Int32 _nAttributeDefault ); 329cdf0e10cSrcweir 330cdf0e10cSrcweir /** add a attribute assignment referring to an enum property to the map 331cdf0e10cSrcweir 332cdf0e10cSrcweir @param _pAttributeName 333cdf0e10cSrcweir the name of the attrribute 334cdf0e10cSrcweir @param _rPropertyName 335cdf0e10cSrcweir the name of the property assigned to the attribute 336cdf0e10cSrcweir @param _nAttributeDefault 337cdf0e10cSrcweir the default value for the attribute, as (32bit) integer 338cdf0e10cSrcweir @param _pValueMap 339cdf0e10cSrcweir the map to translate strings into enum values 340cdf0e10cSrcweir @param _pType 341cdf0e10cSrcweir the type of the property. May be NULL, in this case 32bit integer is assumed. 342cdf0e10cSrcweir */ 343cdf0e10cSrcweir void addEnumProperty( 344cdf0e10cSrcweir const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, 345cdf0e10cSrcweir const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap, 346cdf0e10cSrcweir const ::com::sun::star::uno::Type* _pType = NULL); 347cdf0e10cSrcweir 348cdf0e10cSrcweir protected: 349cdf0e10cSrcweir /// some common code for the various add*Property methods 350cdf0e10cSrcweir AttributeAssignment& implAdd( 351cdf0e10cSrcweir const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, 352cdf0e10cSrcweir const ::com::sun::star::uno::Type& _rType, const ::rtl::OUString& _rDefaultString); 353cdf0e10cSrcweir }; 354cdf0e10cSrcweir //......................................................................... 355cdf0e10cSrcweir } // namespace xmloff 356cdf0e10cSrcweir //......................................................................... 357cdf0e10cSrcweir 358cdf0e10cSrcweir #endif // _XMLOFF_FORMATTRIBUTES_HXX_ 359cdf0e10cSrcweir 360