Files
libreoffice/xmloff/source/forms/formattributes.hxx

366 lines
15 KiB
C++
Raw Normal View History

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: formattributes.hxx,v $
* $Revision: 1.14 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _XMLOFF_FORMATTRIBUTES_HXX_
#define _XMLOFF_FORMATTRIBUTES_HXX_
#include <com/sun/star/beans/XPropertySet.hpp>
#include <sal/types.h>
#include <vos/refernce.hxx>
#include <comphelper/stl_types.hxx>
class SvXMLExport;
struct SvXMLEnumMapEntry;
//.........................................................................
namespace xmloff
{
//.........................................................................
// flags for common control attributes
#define CCA_NAME 0x00000001
#define CCA_SERVICE_NAME 0x00000002
#define CCA_BUTTON_TYPE 0x00000004
#define CCA_CONTROL_ID 0x00000008
#define CCA_CURRENT_SELECTED 0x00000010
#define CCA_CURRENT_VALUE 0x00000020
#define CCA_DISABLED 0x00000040
#define CCA_DROPDOWN 0x00000080
#define CCA_FOR 0x00000100
#define CCA_IMAGE_DATA 0x00000200
#define CCA_LABEL 0x00000400
#define CCA_MAX_LENGTH 0x00000800
#define CCA_PRINTABLE 0x00001000
#define CCA_READONLY 0x00002000
#define CCA_SELECTED 0x00004000
#define CCA_SIZE 0x00008000
#define CCA_TAB_INDEX 0x00010000
#define CCA_TARGET_FRAME 0x00020000
#define CCA_TARGET_LOCATION 0x00040000
#define CCA_TAB_STOP 0x00080000
#define CCA_TITLE 0x00100000
#define CCA_VALUE 0x00200000
#define CCA_ORIENTATION 0x00400000
#define CCA_VISUAL_EFFECT 0x00800000
// flags for database control atttributes
#define DA_BOUND_COLUMN 0x00000001
#define DA_CONVERT_EMPTY 0x00000002
#define DA_DATA_FIELD 0x00000004
#define DA_LIST_SOURCE 0x00000008
#define DA_LIST_SOURCE_TYPE 0x00000010
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
#define DA_INPUT_REQUIRED 0x00000020
// flags for binding related control attributes
#define BA_LINKED_CELL 0x00000001
#define BA_LIST_LINKING_TYPE 0x00000002
#define BA_LIST_CELL_RANGE 0x00000004
#define BA_XFORMS_BIND 0x00000008
#define BA_XFORMS_LISTBIND 0x00000010
#define BA_XFORMS_SUBMISSION 0x00000020
// flags for event attributes
#define EA_CONTROL_EVENTS 0x00000001
#define EA_ON_CHANGE 0x00000002
#define EA_ON_CLICK 0x00000004
#define EA_ON_DBLCLICK 0x00000008
#define EA_ON_SELECT 0x00000010
/// attributes in the xml tag representing a form
enum FormAttributes
{
faName,
faServiceName,
faAction,
faEnctype,
faMethod,
faTargetFrame,
faAllowDeletes,
faAllowInserts,
faAllowUpdates,
faApplyFilter,
faCommand,
faCommandType,
faEscapeProcessing,
faDatasource,
faConnectionResource,
faDetailFiels,
faFilter,
faIgnoreResult,
faMasterFields,
faNavigationMode,
faOrder,
faTabbingCycle
};
// any other attributes, which are special to some control types
#define SCA_ECHO_CHAR 0x00000001
#define SCA_MAX_VALUE 0x00000002
#define SCA_MIN_VALUE 0x00000004
#define SCA_VALIDATION 0x00000008
#define SCA_MULTI_LINE 0x00000020
#define SCA_AUTOMATIC_COMPLETION 0x00000080
#define SCA_MULTIPLE 0x00000100
#define SCA_DEFAULT_BUTTON 0x00000200
#define SCA_CURRENT_STATE 0x00000400
#define SCA_IS_TRISTATE 0x00000800
#define SCA_STATE 0x00001000
2002-10-25 06:54:55 +00:00
#define SCA_COLUMN_STYLE_NAME 0x00002000
#define SCA_STEP_SIZE 0x00004000
#define SCA_PAGE_STEP_SIZE 0x00008000
#define SCA_REPEAT_DELAY 0x00010000
#define SCA_TOGGLE 0x00020000
#define SCA_FOCUS_ON_CLICK 0x00040000
#define SCA_IMAGE_POSITION 0x00080000
// attributes of the office:forms element
enum OfficeFormsAttributes
{
ofaAutomaticFocus,
ofaApplyDesignMode
};
//=====================================================================
//= OAttributeMetaData
//=====================================================================
/** allows the translation of attribute ids into strings.
<p>This class does not allow to connect xml attributes to property names or
something like that, it only deals with the xml side</p>
*/
class OAttributeMetaData
{
public:
/** calculates the xml attribute representation of a common control attribute.
@param _nId
the id of the attribute. Has to be one of the CCA_* constants.
*/
static const sal_Char* getCommonControlAttributeName(sal_Int32 _nId);
/** calculates the xml namespace key to use for a common control attribute
@param _nId
the id of the attribute. Has to be one of the CCA_* constants.
*/
static sal_uInt16 getCommonControlAttributeNamespace(sal_Int32 _nId);
/** retrieves the name of an attribute of a form xml representation
@param _eAttrib
enum value specifying the attribute
*/
static const sal_Char* getFormAttributeName(FormAttributes _eAttrib);
/** calculates the xml namespace key to use for a attribute of a form xml representation
@param _eAttrib
enum value specifying the attribute
*/
static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib);
/** calculates the xml attribute representation of a database attribute.
@param _nId
the id of the attribute. Has to be one of the DA_* constants.
*/
static const sal_Char* getDatabaseAttributeName(sal_Int32 _nId);
/** calculates the xml namespace key to use for a database attribute.
@param _nId
the id of the attribute. Has to be one of the DA_* constants.
*/
static sal_uInt16 getDatabaseAttributeNamespace(sal_Int32 _nId);
/** calculates the xml attribute representation of a special attribute.
@param _nId
the id of the attribute. Has to be one of the SCA_* constants.
*/
static const sal_Char* getSpecialAttributeName(sal_Int32 _nId);
/** calculates the xml attribute representation of a binding attribute.
@param _nId
the id of the attribute. Has to be one of the BA_* constants.
*/
static const sal_Char* getBindingAttributeName(sal_Int32 _nId);
/** calculates the xml namespace key to use for a binding attribute.
@param _nId
the id of the attribute. Has to be one of the BA_* constants.
*/
static sal_uInt16 getBindingAttributeNamespace(sal_Int32 _nId);
/** calculates the xml namespace key to use for a special attribute.
@param _nId
the id of the attribute. Has to be one of the SCA_* constants.
*/
static sal_uInt16 getSpecialAttributeNamespace(sal_Int32 _nId);
/** calculates the xml attribute representation of a attribute of the office:forms element
@param _nId
the id of the attribute
*/
static const sal_Char* getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib);
/** calculates the xml namedspace key of a attribute of the office:forms element
@param _nId
the id of the attribute
*/
static sal_uInt16 getOfficeFormsAttributeNamespace(OfficeFormsAttributes _eAttrib);
};
//=====================================================================
//= OAttribute2Property
//=====================================================================
/** some kind of opposite to the OAttributeMetaData class. Able to translate
2002-10-25 06:54:55 +00:00
attributes into property names/types
<p>The construction of this class is rather expensive (or at least it's initialization from outside),
so it should be shared</p>
*/
class OAttribute2Property
{
public:
// TODO: maybe the following struct should be used for exports, too. In this case we would not need to
// store it's instances in a map, but in a vector for faster access.
struct AttributeAssignment
{
::rtl::OUString sAttributeName; // the attribute name
::rtl::OUString sPropertyName; // the property name
::com::sun::star::uno::Type aPropertyType; // the property type
::rtl::OUString sAttributeDefault; // the default if the attribute is not present
// entries which are special to some value types
const SvXMLEnumMapEntry* pEnumMap; // the enum map, if appliable
sal_Bool bInverseSemantics; // for booleanss: attribute and property value have the same or an inverse semantics?
AttributeAssignment() : pEnumMap(NULL), bInverseSemantics(sal_False) { }
};
protected:
DECLARE_STL_USTRINGACCESS_MAP( AttributeAssignment, AttributeAssignments );
AttributeAssignments m_aKnownProperties;
public:
OAttribute2Property();
virtual ~OAttribute2Property();
/** return the AttributeAssignment which corresponds to the given attribute
@param _rAttribName
the name of the attrribute
@return
a pointer to the <type>AttributeAssignment</type> structure as requested, NULL if the attribute
does not represent a property.
*/
const AttributeAssignment* getAttributeTranslation(
const ::rtl::OUString& _rAttribName);
/** add a attribute assignment referring to a string property to the map
@param _pAttributeName
the name of the attrribute
@param _rPropertyName
the name of the property assigned to the attribute
@param _pAttributeDefault
the default value for the attribute, if any. May be NULL, in this case the default is assumed to be
an empty string.
*/
void addStringProperty(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Char* _pAttributeDefault = NULL);
/** add a attribute assignment referring to a boolean property to the map
@param _pAttributeName
the name of the attrribute
@param _rPropertyName
the name of the property assigned to the attribute
@param _bAttributeDefault
the default value for the attribute.
@param _bInverseSemantics
if <TRUE/>, a attribute value of <TRUE/> means a property value of <FALSE/> and vice verse.<br/>
if <FALSE/>, the attribute value is used as property value directly
*/
void addBooleanProperty(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Bool _bAttributeDefault, const sal_Bool _bInverseSemantics = sal_False);
/** add a attribute assignment referring to an int16 property to the map
@param _pAttributeName
the name of the attrribute
@param _rPropertyName
the name of the property assigned to the attribute
@param _nAttributeDefault
the default value for the attribute.
*/
void addInt16Property(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Int16 _nAttributeDefault);
/** add a attribute assignment referring to an int32 property to the map
@param _pAttributeName
the name of the attrribute
@param _rPropertyName
the name of the property assigned to the attribute
@param _nAttributeDefault
the default value for the attribute.
*/
void addInt32Property(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Int32 _nAttributeDefault );
/** add a attribute assignment referring to an enum property to the map
@param _pAttributeName
the name of the attrribute
@param _rPropertyName
the name of the property assigned to the attribute
@param _nAttributeDefault
the default value for the attribute, as (32bit) integer
@param _pValueMap
the map to translate strings into enum values
@param _pType
the type of the property. May be NULL, in this case 32bit integer is assumed.
*/
void addEnumProperty(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap,
const ::com::sun::star::uno::Type* _pType = NULL);
protected:
/// some common code for the various add*Property methods
AttributeAssignment& implAdd(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const ::com::sun::star::uno::Type& _rType, const ::rtl::OUString& _rDefaultString);
};
//.........................................................................
} // namespace xmloff
//.........................................................................
#endif // _XMLOFF_FORMATTRIBUTES_HXX_