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

Generated by: LCOV version 1.10