LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/forms - formattributes.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-12-27 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10