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

344 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.cxx,v $
* $Revision: 1.21 $
*
* 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.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
#include "formattributes.hxx"
#include "xmlnmspe.hxx"
#include <xmloff/xmluconv.hxx>
#include <rtl/ustrbuf.hxx>
CWS-TOOLING: integrate CWS dbaperf1 2009-04-02 09:12:25 +0200 oj r270372 : CWS-TOOLING: rebase CWS dbaperf1 to trunk@270033 (milestone: DEV300:m45) 2009-03-17 10:20:34 +0100 oj r269577 : add parameter 2009-03-17 10:20:05 +0100 oj r269576 : add parameter 2009-03-12 12:32:24 +0100 oj r269387 : add missing ++ 2009-03-11 12:53:35 +0100 oj r269315 : compile error 2009-03-06 08:52:11 +0100 oj r268968 : #i99264# remove duplicate code 2009-03-06 08:20:08 +0100 oj r268966 : add missingheader 2009-03-06 08:17:41 +0100 oj r268965 : add header 2009-03-06 08:15:07 +0100 oj r268964 : #i99708# remove duplicate code 2009-03-06 07:24:11 +0100 oj r268963 : #i99708# remove duplicate code 2009-03-06 07:22:24 +0100 oj r268962 : #i99708# use tenary operator 2009-03-06 07:19:21 +0100 oj r268961 : remove unused rtl_logs 2009-03-06 07:15:55 +0100 oj r268960 : #i99708# extract getLength from for loop 2009-03-06 07:15:35 +0100 oj r268959 : #i99708# extract getLength from for loop 2009-03-06 07:14:57 +0100 oj r268958 : remove unused rtl_logs 2009-03-06 07:13:01 +0100 oj r268957 : insert DBG_ helper 2009-03-06 07:12:17 +0100 oj r268956 : remove unused rtl_logs 2009-03-06 07:10:26 +0100 oj r268955 : remove unused rtl_logs 2009-03-06 07:04:51 +0100 oj r268954 : #i99708# use tenary operator 2009-03-05 12:04:46 +0100 oj r268895 : comment RTL_LOG out 2009-03-05 09:05:07 +0100 oj r268874 : add rtl logfile 2009-03-04 14:21:18 +0100 oj r268828 : #i99708# make static inplace and some method calls in for loop removed 2009-03-04 14:20:34 +0100 oj r268827 : #i99708# impl double check pattern for getInfohelper 2009-03-02 09:31:42 +0100 oj r268636 : add rtl logfile 2009-03-02 08:18:37 +0100 oj r268633 : add rtl logfile 2009-02-27 11:22:16 +0100 oj r268570 : #i99709# change algorithm for marking objects 2009-02-27 11:17:04 +0100 oj r268568 : #i99708# some improvements to load forms, controls faster and replacement of size() call with !empty() which is much faster 2009-02-24 10:09:35 +0100 sb r268383 : #i99290# no longer care to set a sensible context class loader for native threads attached to the VM 2009-02-23 13:44:04 +0100 oj r268354 : #i76606# seekrow changes 2009-02-23 12:27:30 +0100 oj r268349 : deleted 2009-02-20 15:14:23 +0100 oj r268325 : #i76606# some code changes 2009-02-19 14:15:25 +0100 oj r268284 : #i76606# use of simple prep stmt instead of full blown rowset, when source and dest connection are the same use insert into ... ( select ... ) 2009-02-19 11:27:55 +0100 oj r268265 : #i76606# insert some RTL_LOG and setObject impl 2009-02-18 14:45:37 +0100 oj r268222 : #i99363# insert RTL_LOG 2009-02-18 14:45:18 +0100 oj r268221 : #i99363# insert RTL_LOG 2009-02-18 11:14:54 +0100 oj r268207 : #i99363# call some impl_ methods to avoid duplicate cechCache calls 2009-02-18 11:10:47 +0100 oj r268206 : #i99363# make isCount inline 2009-02-18 10:33:22 +0100 oj r268203 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-18 10:32:57 +0100 oj r268202 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-17 07:29:05 +0100 oj r267843 : #i96897# remove some dll public 2009-02-16 15:01:04 +0100 oj r267816 : #i96897# remove some dll public 2009-02-16 14:25:53 +0100 oj r267810 : #i99264# remove duplicate code 2009-02-16 14:25:33 +0100 oj r267809 : #i99264# remove duplicate code 2009-02-16 14:24:59 +0100 oj r267808 : #i99264# remove duplicate code 2009-02-13 10:56:17 +0100 oj r267703 : #i99191# comment the contextclassloader 2009-02-13 10:32:40 +0100 oj r267700 : reduce call to resultset meta data 2009-02-13 10:27:31 +0100 oj r267699 : reduce call to resultset meta data 2009-02-13 10:27:08 +0100 oj r267698 : reduce call to resultset meta data
2009-04-23 10:42:05 +00:00
#include <rtl/logfile.hxx>
//.........................................................................
namespace xmloff
{
//.........................................................................
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
//=====================================================================
//= OAttributeMetaData
//=====================================================================
//---------------------------------------------------------------------
const sal_Char* OAttributeMetaData::getCommonControlAttributeName(sal_Int32 _nId)
{
switch (_nId)
{
case CCA_NAME: return "name";
case CCA_SERVICE_NAME: return "control-implementation";
case CCA_BUTTON_TYPE: return "button-type";
case CCA_CONTROL_ID: return "id";
case CCA_CURRENT_SELECTED: return "current-selected";
case CCA_CURRENT_VALUE: return "current-value";
case CCA_DISABLED: return "disabled";
case CCA_DROPDOWN: return "dropdown";
case CCA_FOR: return "for";
case CCA_IMAGE_DATA: return "image-data";
case CCA_LABEL: return "label";
case CCA_MAX_LENGTH: return "max-length";
case CCA_PRINTABLE: return "printable";
case CCA_READONLY: return "readonly";
case CCA_SELECTED: return "selected";
case CCA_SIZE: return "size";
2001-02-13 12:44:41 +00:00
case CCA_TAB_INDEX: return "tab-index";
case CCA_TARGET_FRAME: return "target-frame";
case CCA_TARGET_LOCATION: return "href"; // the only special thing here: TargetLocation is represented by an xlink:href attribute
case CCA_TAB_STOP: return "tab-stop";
case CCA_TITLE: return "title";
case CCA_VALUE: return "value";
case CCA_ORIENTATION: return "orientation";
case CCA_VISUAL_EFFECT: return "visual-effect";
default:
OSL_ENSURE(sal_False, "OAttributeMetaData::getCommonControlAttributeName: invalid id (maybe you or-ed two flags?)!");
}
return "";
}
//---------------------------------------------------------------------
sal_uInt16 OAttributeMetaData::getCommonControlAttributeNamespace(sal_Int32 _nId)
{
if (CCA_TARGET_LOCATION == _nId)
return XML_NAMESPACE_XLINK;
if (CCA_TARGET_FRAME == _nId)
return XML_NAMESPACE_OFFICE;
return XML_NAMESPACE_FORM;
}
//---------------------------------------------------------------------
const sal_Char* OAttributeMetaData::getFormAttributeName(FormAttributes _eAttrib)
{
switch (_eAttrib)
{
case faName: return "name";
case faServiceName: return "service-name";
case faAction: return "href"; // the only special thing here: Action is represented by an xlink:href attribute
case faEnctype: return "enctype";
case faMethod: return "method";
case faTargetFrame: return "target-frame";
case faAllowDeletes: return "allow-deletes";
case faAllowInserts: return "allow-inserts";
case faAllowUpdates: return "allow-updates";
case faApplyFilter: return "apply-filter";
case faCommand: return "command";
case faCommandType: return "command-type";
case faEscapeProcessing: return "escape-processing";
case faDatasource: return "datasource";
case faConnectionResource: return "connection-resource";
case faDetailFiels: return "detail-fields";
case faFilter: return "filter";
case faIgnoreResult: return "ignore-result";
case faMasterFields: return "master-fields";
case faNavigationMode: return "navigation-mode";
case faOrder: return "order";
case faTabbingCycle: return "tab-cycle";
default:
OSL_ENSURE(sal_False, "OAttributeMetaData::getFormAttributeName: invalid id!");
}
return "";
}
//---------------------------------------------------------------------
sal_uInt16 OAttributeMetaData::getFormAttributeNamespace(FormAttributes _eAttrib)
{
if (faAction == _eAttrib)
return XML_NAMESPACE_XLINK;
if (faTargetFrame == _eAttrib)
return XML_NAMESPACE_OFFICE;
return XML_NAMESPACE_FORM;
}
//---------------------------------------------------------------------
const sal_Char* OAttributeMetaData::getDatabaseAttributeName(sal_Int32 _nId)
{
switch (_nId)
{
case DA_BOUND_COLUMN: return "bound-column";
case DA_CONVERT_EMPTY: return "convert-empty-to-null";
case DA_DATA_FIELD: return "data-field";
case DA_LIST_SOURCE: return "list-source";
case DA_LIST_SOURCE_TYPE: return "list-source-type";
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
case DA_INPUT_REQUIRED: return "input-required";
default:
OSL_ENSURE(sal_False, "OAttributeMetaData::getDatabaseAttributeName: invalid id (maybe you or-ed two flags?)!");
}
return "";
}
//---------------------------------------------------------------------
sal_uInt16 OAttributeMetaData::getDatabaseAttributeNamespace(sal_Int32 /*_nId*/)
{
// nothing special here
return XML_NAMESPACE_FORM;
}
//---------------------------------------------------------------------
const sal_Char* OAttributeMetaData::getBindingAttributeName(sal_Int32 _nId)
{
switch (_nId)
{
case BA_LINKED_CELL: return "linked-cell";
case BA_LIST_LINKING_TYPE: return "list-linkage-type";
case BA_LIST_CELL_RANGE: return "source-cell-range";
default:
OSL_ENSURE(sal_False, "OAttributeMetaData::getBindingAttributeName: invalid id (maybe you or-ed two flags?)!");
}
return "";
}
//---------------------------------------------------------------------
sal_uInt16 OAttributeMetaData::getBindingAttributeNamespace(sal_Int32)
{
// nothing special here
return XML_NAMESPACE_FORM;
}
//---------------------------------------------------------------------
const sal_Char* OAttributeMetaData::getSpecialAttributeName(sal_Int32 _nId)
{
switch (_nId)
{
case SCA_ECHO_CHAR: return "echo-char";
case SCA_MAX_VALUE: return "max-value";
case SCA_MIN_VALUE: return "min-value";
case SCA_VALIDATION: return "validation";
case SCA_MULTI_LINE: return "multi-line";
case SCA_AUTOMATIC_COMPLETION: return "auto-complete";
case SCA_MULTIPLE: return "multiple";
case SCA_DEFAULT_BUTTON: return "default-button";
case SCA_CURRENT_STATE: return "current-state";
case SCA_IS_TRISTATE: return "is-tristate";
case SCA_STATE: return "state";
case SCA_COLUMN_STYLE_NAME: return "text-style-name";
case SCA_STEP_SIZE: return "step-size";
case SCA_PAGE_STEP_SIZE: return "page-step-size";
case SCA_REPEAT_DELAY: return "delay-for-repeat";
case SCA_TOGGLE: return "toggle";
case SCA_FOCUS_ON_CLICK: return "focus-on-click";
default:
OSL_ENSURE(sal_False, "OAttributeMetaData::getSpecialAttributeName: invalid id (maybe you or-ed two flags?)!");
}
return "";
}
//---------------------------------------------------------------------
sal_uInt16 OAttributeMetaData::getSpecialAttributeNamespace(sal_Int32 /*_nId*/)
{
// nothing special here
return XML_NAMESPACE_FORM;
}
//---------------------------------------------------------------------
const sal_Char* OAttributeMetaData::getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib)
{
switch (_eAttrib)
{
case ofaAutomaticFocus: return "automatic-focus";
case ofaApplyDesignMode: return "apply-design-mode";
default:
OSL_ENSURE(sal_False, "OAttributeMetaData::getOfficeFormsAttributeName: invalid id!");
}
return "";
}
//---------------------------------------------------------------------
sal_uInt16 OAttributeMetaData::getOfficeFormsAttributeNamespace(OfficeFormsAttributes /* _eAttrib */)
{
// nothing special here
return XML_NAMESPACE_FORM;
}
//=====================================================================
//= OAttribute2Property
//=====================================================================
//---------------------------------------------------------------------
OAttribute2Property::OAttribute2Property()
{
}
//---------------------------------------------------------------------
OAttribute2Property::~OAttribute2Property()
{
}
//---------------------------------------------------------------------
const OAttribute2Property::AttributeAssignment* OAttribute2Property::getAttributeTranslation(
const ::rtl::OUString& _rAttribName)
{
ConstAttributeAssignmentsIterator aPos = m_aKnownProperties.find(_rAttribName);
if (m_aKnownProperties.end() != aPos)
return &aPos->second;
return NULL;
}
//---------------------------------------------------------------------
void OAttribute2Property::addStringProperty(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Char* _pAttributeDefault)
{
implAdd(_pAttributeName, _rPropertyName, ::getCppuType( static_cast< ::rtl::OUString* >(NULL) ),
_pAttributeDefault ? ::rtl::OUString::createFromAscii(_pAttributeDefault) : ::rtl::OUString());
}
//---------------------------------------------------------------------
void OAttribute2Property::addBooleanProperty(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Bool _bAttributeDefault, const sal_Bool _bInverseSemantics)
{
::rtl::OUStringBuffer aDefault;
SvXMLUnitConverter::convertBool(aDefault, _bAttributeDefault);
AttributeAssignment& aAssignment = implAdd(_pAttributeName, _rPropertyName, ::getBooleanCppuType(), aDefault.makeStringAndClear());
aAssignment.bInverseSemantics = _bInverseSemantics;
}
//---------------------------------------------------------------------
void OAttribute2Property::addInt16Property(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Int16 _nAttributeDefault)
{
::rtl::OUStringBuffer aDefault;
SvXMLUnitConverter::convertNumber(aDefault, (sal_Int32)_nAttributeDefault);
implAdd(_pAttributeName, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >(NULL) ), aDefault.makeStringAndClear());
}
//---------------------------------------------------------------------
void OAttribute2Property::addInt32Property(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_Int32 _nAttributeDefault)
{
::rtl::OUStringBuffer aDefault;
SvXMLUnitConverter::convertNumber( aDefault, _nAttributeDefault );
implAdd( _pAttributeName, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >(NULL) ), aDefault.makeStringAndClear() );
}
//---------------------------------------------------------------------
void OAttribute2Property::addEnumProperty(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap,
const ::com::sun::star::uno::Type* _pType)
{
::rtl::OUStringBuffer aDefault;
SvXMLUnitConverter::convertEnum(aDefault, _nAttributeDefault, _pValueMap);
AttributeAssignment& aAssignment = implAdd(_pAttributeName, _rPropertyName,
_pType ? *_pType : ::getCppuType( static_cast< sal_Int32* >(NULL) ),
// this assumes that the setPropertyValue for enums can handle int32's ....
aDefault.makeStringAndClear());
aAssignment.pEnumMap = _pValueMap;
}
//---------------------------------------------------------------------
OAttribute2Property::AttributeAssignment& OAttribute2Property::implAdd(
const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
const ::com::sun::star::uno::Type& _rType, const ::rtl::OUString& /*_rDefaultString*/)
{
OSL_ENSURE(m_aKnownProperties.end() == m_aKnownProperties.find(::rtl::OUString::createFromAscii(_pAttributeName)),
"OAttribute2Property::implAdd: already have this attribute!");
::rtl::OUString sAttributeName = ::rtl::OUString::createFromAscii(_pAttributeName);
AttributeAssignment aAssignment;
aAssignment.sAttributeName = sAttributeName;
aAssignment.sPropertyName = _rPropertyName;
aAssignment.aPropertyType = _rType;
// redundance, the accessor is stored in aAssignment.sAttributeName, too
return m_aKnownProperties[sAttributeName] = aAssignment;
}
//.........................................................................
} // namespace xmloff
//.........................................................................