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

Generated by: LCOV version 1.11