/************************************************************************* * * $RCSfile: elementexport.cxx,v $ * * $Revision: 1.6 $ * * last change: $Author: mib $ $Date: 2000-12-18 13:25:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library 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 for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://www.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ #include #ifndef _XMLOFF_ELEMENTEXPORT_HXX_ #include "elementexport.hxx" #endif #ifndef _XMLOFF_FORMS_STRINGS_HXX_ #include "strings.hxx" #endif #ifndef _XMLOFF_XMLEXP_HXX #include "xmlexp.hxx" #endif #ifndef _XMLOFF_NMSPMAP_HXX #include "nmspmap.hxx" #endif #ifndef _XMLOFF_XMLNMSPE_HXX #include "xmlnmspe.hxx" #endif #ifndef _XMLOFF_XMLUCONV_HXX #include "xmluconv.hxx" #endif #ifndef _CPPUHELPER_EXTRACT_HXX_ #include #endif #ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include #endif #ifndef _XMLOFF_FORMENUMS_HXX_ #include "formenums.hxx" #endif #ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_NAVIGATIONBARMODE_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_TABULATORCYCLE_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_LISTSOURCETYPE_HPP_ #include #endif #ifndef _SV_WINTYPES_HXX #include // for check states #endif //......................................................................... namespace xmloff { //......................................................................... using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::form; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; //===================================================================== //= OControlExport //===================================================================== //--------------------------------------------------------------------- OControlExport::OControlExport(SvXMLExport& _rContext, IExportImplementation* _pCallback, const Reference< XPropertySet >& _rxControl, const ::rtl::OUString& _rControlId, const ::rtl::OUString& _rReferringControls) :OPropertyExport(_rContext, _rxControl) ,m_sControlId(_rControlId) ,m_sReferringControls(_rReferringControls) ,m_nIncludeCommon(0) ,m_nIncludeDatabase(0) ,m_nIncludeSpecial(0) ,m_nIncludeEvents(0) ,m_nClassId(FormComponentType::CONTROL) ,m_pXMLElement(NULL) ,m_pCallback(_pCallback) { OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!"); } //--------------------------------------------------------------------- void OControlExport::doExport() { // collect some general information about the control examine(); // start the element startExportElement(); // the sub elements (mostly control type dependent) exportSubTags(); } //--------------------------------------------------------------------- OControlExport::~OControlExport() { delete m_pXMLElement; // if we already started the element, this will end it, if not, nothing will happen } //--------------------------------------------------------------------- void OControlExport::startExportElement() { // first add the attributes necessary for the element m_rContext.ClearAttrList(); // common control attributes exportCommonControlAttributes(); // common database attributes exportDatabaseAttributes(); // attributes special to the respective control type exportSpecialAttributes(); // add the style references to the attributes implExportStyleReference(); // TODO: add the event attributes m_pXMLElement = new SvXMLElementExport(m_rContext, XML_NAMESPACE_FORM, getElementName(m_eType), sal_True, sal_True); } //--------------------------------------------------------------------- void OControlExport::exportSubTags() throw (Exception) { // the ListSource related properties do not need to be exported in a generic way, exportListSourceAsElements // will handle this (if necessary) exportedProperty(PROPERTY_STRING_ITEM_LIST); exportedProperty(PROPERTY_VALUE_SEQ); exportedProperty(PROPERTY_SELECT_SEQ); exportedProperty(PROPERTY_DEFAULT_SELECT_SEQ); exportedProperty(PROPERTY_LISTSOURCE); // for the upcoming exportRemainingProperties: // if a control has the LabelControl property, this is not stored with the control itself, but instead with // the control which is referenced by this property. As the base class' exportRemainingProperties doesn't // know anything about this, we need to prevent that it tries to export this property exportedProperty(PROPERTY_CONTROLLABEL); // the properties which where not exported 'til now exportRemainingProperties(); // TODO: the script:events sub tags // special sub tags for some controls switch (m_eType) { case LISTBOX: // a list box description has sub elements: the options exportListSourceAsElements(); break; case GRID: { // a grid control requires us to store all columns as sub elements OSL_ENSURE(m_pCallback, "OControlExport::exportSubTags: need a callback for the export of GridControls!"); Reference< XIndexAccess > xColumnContainer(m_xProps, UNO_QUERY); OSL_ENSURE(xColumnContainer.is(), "OControlExport::exportSubTags: a grid control which is no IndexAccess?!!"); if (xColumnContainer.is()) m_pCallback->exportCollectionElements(xColumnContainer); } break; case COMBOBOX: { // a combox box description has sub elements: the items DBG_CHECK_PROPERTY((const sal_Char*)PROPERTY_STRING_ITEM_LIST, Sequence< ::rtl::OUString >); // get the item list Sequence< ::rtl::OUString > aListItems; m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems; // loop through it and write the sub elements const ::rtl::OUString* pListItems = aListItems.getConstArray(); for (sal_Int32 i=0; igetPropertyValue(PROPERTY_ECHO_CHAR) >>= nValue; if (nValue) { ::rtl::OUString sCharacter(reinterpret_cast(&nValue), 1); AddAttribute( getSpecialAttributeNamespace(SCA_ECHO_CHAR), getSpecialAttributeName(SCA_ECHO_CHAR), sCharacter); } exportedProperty(PROPERTY_ECHO_CHAR); #ifdef DBG_UTIL // reset the bit for later checking m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_ECHO_CHAR; #endif } } if ((SCA_MIN_VALUE | SCA_MAX_VALUE) & m_nIncludeSpecial) { // need to export the min value and the max value as attributes // It depends on the real type (FormComponentType) of the control, which properties hold these // values const sal_Char* pMinValuePropertyName = NULL; const sal_Char* pMaxValuePropertyName = NULL; getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName); OSL_ENSURE((NULL == pMinValuePropertyName) == (0 == (SCA_MIN_VALUE & m_nIncludeSpecial)), "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!"); OSL_ENSURE((NULL == pMaxValuePropertyName) == (0 == (SCA_MAX_VALUE & m_nIncludeSpecial)), "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!"); // add the two attributes static const sal_Char* pMinValueAttributeName = getSpecialAttributeName(SCA_MIN_VALUE); static const sal_Char* pMaxValueAttributeName = getSpecialAttributeName(SCA_MAX_VALUE); static const sal_uInt16 nMinValueNamespaceKey = getSpecialAttributeNamespace(SCA_MIN_VALUE); static const sal_uInt16 nMaxValueNamespaceKey = getSpecialAttributeNamespace(SCA_MAX_VALUE); if (pMinValuePropertyName && (SCA_MIN_VALUE & m_nIncludeSpecial)) exportGenericPropertyAttribute( nMinValueNamespaceKey, pMinValueAttributeName, pMinValuePropertyName); if (pMaxValuePropertyName && (SCA_MAX_VALUE & m_nIncludeSpecial)) exportGenericPropertyAttribute( nMaxValueNamespaceKey, pMaxValueAttributeName, pMaxValuePropertyName); #ifdef DBG_UTIL // reset the bit for later checking m_nIncludeSpecial = m_nIncludeSpecial & ~(SCA_MIN_VALUE | SCA_MAX_VALUE); #endif } OSL_ENSURE(0 == m_nIncludeSpecial, "OControlExport::exportSpecialAttributes: forgot some flags!"); // in the dbg_util version, we should have removed every bit we handled from the mask, so it should // be 0 now ... } //--------------------------------------------------------------------- void OControlExport::exportListSourceAsAttribute() { // DA_LIST_SOURCE needs some special handling DBG_CHECK_PROPERTY_NO_TYPE((const sal_Char*)PROPERTY_LISTSOURCE); ::rtl::OUString sListSource; Any aListSource = m_xProps->getPropertyValue(PROPERTY_LISTSOURCE); if (!(aListSource >>= sListSource)) { Sequence< ::rtl::OUString > aListSourceSequence; aListSource >>= aListSourceSequence; if (aListSourceSequence.getLength()) sListSource = aListSourceSequence[0]; } if (sListSource.getLength()) { // the ListSource property needs to be exported as attribute, and it is not empty AddAttribute( getDatabaseAttributeNamespace(DA_LIST_SOURCE), getDatabaseAttributeName(DA_LIST_SOURCE), sListSource); } } //--------------------------------------------------------------------- void OControlExport::getSequenceInt16PropertyAsSet(const ::rtl::OUString& _rPropertyName, Int16Set& _rOut) { Sequence< sal_Int16 > aValueSequence; DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >); m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence; const sal_Int16* pValues = aValueSequence.getConstArray(); for (sal_Int32 i=0; i aItems, aValues; DBG_CHECK_PROPERTY((const sal_Char*)PROPERTY_STRING_ITEM_LIST, Sequence< ::rtl::OUString >); m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems; DBG_CHECK_PROPERTY((const sal_Char*)PROPERTY_LISTSOURCE, Sequence< ::rtl::OUString >); m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues; // the selection lists Int16Set aSelection, aDefaultSelection; getSequenceInt16PropertyAsSet(PROPERTY_SELECT_SEQ, aSelection); getSequenceInt16PropertyAsSet(PROPERTY_DEFAULT_SELECT_SEQ, aDefaultSelection); // the string for "true" and "false" ::rtl::OUString sTrue; ::rtl::OUStringBuffer sBuffer; m_rContext.GetMM100UnitConverter().convertBool(sBuffer, sal_True); sTrue = sBuffer.makeStringAndClear(); // loop through both lists ('til the maximum of both lengths) const ::rtl::OUString* pItems = aItems.getConstArray(); const ::rtl::OUString* pValues = aValues.getConstArray(); sal_Int32 nItems = aItems.getLength(); sal_Int32 nValues = aValues.getLength(); sal_Int32 nMaxLen = max(nItems, nValues); for (sal_Int16 i=0; igetPropertyValue(PROPERTY_CLASSID) >>= m_nClassId; switch (m_nClassId) { case FormComponentType::DATEFIELD: case FormComponentType::TIMEFIELD: case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: case FormComponentType::PATTERNFIELD: m_eType = FORMATTED_TEXT; // NO BREAK case FormComponentType::TEXTFIELD: { // it's some kind of edit. To know which type we need further investigation if (FORMATTED_TEXT != m_eType) { // not coming from the presious cases which had a class id .ne. TEXTFIELD // check if it's a formatted field if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY)) { m_eType = FORMATTED_TEXT; } else { // all other controls are represented by an ordinary edit control, but which XML control type // it is depends on the current values of some properties // if the EchoChar string is not empty, it is a password field sal_Int16 nEchoChar = 0; if (m_xPropertyInfo->hasPropertyByName(PROPERTY_ECHOCHAR)) // grid columns do not have this property .... m_xProps->getPropertyValue(PROPERTY_ECHOCHAR) >>= nEchoChar; if (nEchoChar) { m_eType = PASSWORD; m_nIncludeSpecial |= SCA_ECHO_CHAR; } else { // if the MultiLine property is sal_True, it is a TextArea sal_Bool bMultiLine = sal_False; if (m_xPropertyInfo->hasPropertyByName(PROPERTY_MULTILINE)) // grid columns do not have this property .... bMultiLine = ::cppu::any2bool(m_xProps->getPropertyValue(PROPERTY_MULTILINE)); if (bMultiLine) m_eType = TEXT_AREA; else // the only case left is represented by a Text element m_eType = TEXT; } } } // attributes which are common to all the four types: // common attributes m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE; // database attributes m_nIncludeDatabase = DA_DATA_FIELD; // event attributes m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT; // only text and pattern fields have a ConvertEmptyToNull property if ((m_nClassId == FormComponentType::TEXTFIELD) || (m_nClassId == FormComponentType::PATTERNFIELD)) m_nIncludeDatabase |= DA_CONVERT_EMPTY; // all controls but the file control fields have a readonly property if (m_nClassId != FormComponentType::FILECONTROL) m_nIncludeCommon |= CCA_READONLY; // a text field has a max text len if (m_nClassId == FormComponentType::TEXTFIELD) m_nIncludeCommon |= CCA_MAX_LENGTH; // max and min values and validation: if (FORMATTED_TEXT == m_eType) { // in general all control represented as formatted-text have these props if (FormComponentType::PATTERNFIELD != m_nClassId) // but the PatternField does not have value limits m_nIncludeSpecial |= SCA_MAX_VALUE | SCA_MIN_VALUE; if (FormComponentType::TEXTFIELD != m_nClassId) // and the FormattedField does not have a validation flag m_nIncludeSpecial |= SCA_VALIDATION; } // if it's not a password field, the CurrentValue needs to be stored, too if (PASSWORD != m_eType) m_nIncludeCommon |= CCA_CURRENT_VALUE; } break; case FormComponentType::FILECONTROL: m_eType = FILE; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE | CCA_DISABLED | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE; m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT; break; case FormComponentType::FIXEDTEXT: m_eType = FIXED_TEXT; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL | CCA_PRINTABLE | CCA_TITLE | CCA_FOR; m_nIncludeSpecial = SCA_MULTI_LINE; m_nIncludeEvents = EA_CONTROL_EVENTS; break; case FormComponentType::COMBOBOX: m_eType = COMBOBOX; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_CURRENT_VALUE | CCA_DISABLED | CCA_DROPDOWN | CCA_MAX_LENGTH | CCA_PRINTABLE | CCA_READONLY | CCA_SIZE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE; m_nIncludeSpecial = SCA_AUTOMATIC_COMPLETION; m_nIncludeDatabase = DA_CONVERT_EMPTY | DA_DATA_FIELD | DA_LIST_SOURCE | DA_LIST_SOURCE_TYPE; m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT; break; case FormComponentType::LISTBOX: m_eType = LISTBOX; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_DROPDOWN | CCA_PRINTABLE | CCA_SIZE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE; m_nIncludeSpecial = SCA_MULTIPLE; m_nIncludeDatabase = DA_BOUND_COLUMN | DA_DATA_FIELD | DA_LIST_SOURCE_TYPE; m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_CLICK | EA_ON_DBLCLICK; // check if we need to export the ListSource as attribute { // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead // a sequence of pairs which is build from the StringItemList and the ValueList ListSourceType eListSourceType = ListSourceType_VALUELIST; #ifdef DBG_UTIL sal_Bool bSuccess = #endif m_xProps->getPropertyValue(PROPERTY_LISTSOURCETYPE) >>= eListSourceType; #ifdef DBG_UTIL OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!"); #endif if (ListSourceType_VALUELIST != eListSourceType) { m_nIncludeDatabase |= DA_LIST_SOURCE; } } break; case FormComponentType::COMMANDBUTTON: m_eType = BUTTON; m_nIncludeCommon |= CCA_TAB_STOP | CCA_LABEL; m_nIncludeSpecial = SCA_DEFAULT_BUTTON; // NO BREAK ! case FormComponentType::IMAGEBUTTON: if (BUTTON != m_eType) // not coming from the previous case m_eType = IMAGE; m_nIncludeCommon |= CCA_NAME | CCA_SERVICE_NAME | CCA_BUTTON_TYPE | CCA_DISABLED | CCA_IMAGE_DATA | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TARGET_FRAME | CCA_TARGET_LOCATION | CCA_TITLE; m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CLICK | EA_ON_DBLCLICK; break; case FormComponentType::CHECKBOX: m_eType = CHECKBOX; m_nIncludeSpecial = SCA_CURRENT_STATE | SCA_IS_TRISTATE | SCA_STATE; // NO BREAK ! case FormComponentType::RADIOBUTTON: m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE | CCA_VALUE; if (CHECKBOX != m_eType) { // not coming from the previous case m_eType = RADIO; m_nIncludeCommon |= CCA_CURRENT_SELECTED | CCA_SELECTED; } m_nIncludeDatabase = DA_DATA_FIELD; m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE; break; case FormComponentType::GROUPBOX: m_eType = FRAME; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_LABEL | CCA_PRINTABLE | CCA_TITLE | CCA_FOR; m_nIncludeEvents = EA_CONTROL_EVENTS; break; case FormComponentType::IMAGECONTROL: m_eType = IMAGE_FRAME; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_IMAGE_DATA | CCA_PRINTABLE | CCA_READONLY | CCA_TITLE; m_nIncludeDatabase = DA_DATA_FIELD; m_nIncludeEvents = EA_CONTROL_EVENTS; break; case FormComponentType::HIDDENCONTROL: m_eType = HIDDEN; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_VALUE; break; case FormComponentType::GRIDCONTROL: m_eType = GRID; m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE; m_nIncludeEvents = EA_CONTROL_EVENTS; break; case FormComponentType::CONTROL: m_eType = CONTROL; // unknown control type m_nIncludeCommon = CCA_NAME | CCA_SERVICE_NAME; // at least a name should be there, 'cause without a name the control could never have been // inserted into it's parent container // In addition, the service name is absolutely necessary to create the control upon reading. m_nIncludeEvents = EA_CONTROL_EVENTS; // we always should be able to export events - this is not control type dependent break; default: OSL_ENSHURE(sal_False, "OControlExport::examineControl: unknown control type (class id)!"); break; } // in general, all control types need to export the control id m_nIncludeCommon |= CCA_CONTROL_ID; } //===================================================================== //= OColumnExport //===================================================================== //--------------------------------------------------------------------- OColumnExport::OColumnExport(SvXMLExport& _rContext, const Reference< XPropertySet >& _rxControl) :OControlExport(_rContext, NULL, _rxControl, ::rtl::OUString(), ::rtl::OUString()) ,m_pColumnXMLElement(NULL) { } //--------------------------------------------------------------------- OColumnExport::~OColumnExport() { // delete m_pXMLElement before m_pColumnXMLElement !! // TODO: this makes me seriously thinking about why OColumnExport is derived from OControlExport, and // not the other way round delete m_pXMLElement; m_pXMLElement = NULL; delete m_pColumnXMLElement; } //--------------------------------------------------------------------- void OColumnExport::examine() { OControlExport::examine(); // grid columns miss some properties of the controls they're representing m_nIncludeCommon &= ~(CCA_SERVICE_NAME | CCA_CONTROL_ID | CCA_FOR | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_LABEL | CCA_NAME); m_nIncludeSpecial &= ~(SCA_ECHO_CHAR | SCA_AUTOMATIC_COMPLETION | SCA_MULTIPLE | SCA_MULTI_LINE | SCA_IS_TRISTATE); if (FormComponentType::DATEFIELD != m_nClassId) // except date fields, no column has the DropDown property m_nIncludeCommon &= ~CCA_DROPDOWN; } //--------------------------------------------------------------------- void OColumnExport::startExportElement() { // before the base class can start it's element, start an additional one stating that the following is // a grid column // the attributes: m_rContext.ClearAttrList(); // the attribute "name" exportStringPropertyAttribute( getCommonControlAttributeNamespace(CCA_NAME), getCommonControlAttributeName(CCA_NAME), PROPERTY_NAME ); // the attribute "service name" (which has a slightly different meaning for columns DBG_CHECK_PROPERTY((const sal_Char*)PROPERTY_COLUMNSERVICENAME, ::rtl::OUString); ::rtl::OUString sColumnServiceName; m_xProps->getPropertyValue(PROPERTY_COLUMNSERVICENAME) >>= sColumnServiceName; // the service name is a full qualified one (i.e. com.sun.star.form.TextField), but the // real service name for the column (for use with the XGridColumnFactory) is only the last // token of this complete name. sal_Int32 nLastSep = sColumnServiceName.lastIndexOf('.'); OSL_ENSURE(-1 != nLastSep, "OColumnExport::startExportElement: invalid service name!"); sColumnServiceName = sColumnServiceName.copy(nLastSep + 1); // add the attribute AddAttribute(getCommonControlAttributeNamespace(CCA_SERVICE_NAME), getCommonControlAttributeName(CCA_SERVICE_NAME), sColumnServiceName); // flag the property as "handled" exportedProperty(PROPERTY_COLUMNSERVICENAME); // the attribute "label" exportStringPropertyAttribute( getCommonControlAttributeNamespace(CCA_LABEL), getCommonControlAttributeName(CCA_LABEL), PROPERTY_LABEL); // start the extra element indicating that we're a column m_pColumnXMLElement = new SvXMLElementExport(m_rContext, XML_NAMESPACE_FORM, "column", sal_True, sal_True); // let the base class do it's handling OControlExport::startExportElement(); } //===================================================================== //= OFormExport //===================================================================== //--------------------------------------------------------------------- OFormExport::OFormExport(SvXMLExport& _rContext, IExportImplementation* _pCallback, const Reference< XPropertySet >& _rxForm) :OPropertyExport(_rContext, _rxForm) ,m_pCallback(_pCallback) ,m_pXMLElement(NULL) { OSL_ENSURE(m_xProps.is() && m_pCallback, "OFormExport::OFormExport: invalid arguments!"); // add the attributes m_rContext.ClearAttrList(); exportAttributes(); // start the form element m_pXMLElement = new SvXMLElementExport(m_rContext, XML_NAMESPACE_FORM, "form", sal_True, sal_True); // the properties which where not exported 'til now exportRemainingProperties(); // TODO: the remaining scripts // loop through all children Reference< XIndexAccess > xCollection(m_xProps, UNO_QUERY); OSL_ENSURE(xCollection.is(), "OFormLayerXMLExport::implExportForm: a form which is not an index access? Suspicíous!"); if (xCollection.is() && m_pCallback) m_pCallback->exportCollectionElements(xCollection); } //--------------------------------------------------------------------- OFormExport::~OFormExport() { delete m_pXMLElement; // if we already started the element, this will end it, if not, nothing will happen } //--------------------------------------------------------------------- void OFormExport::exportAttributes() { sal_Int32 i=0; // --------------------- // the string properties { static FormAttributes eStringPropertyIds[] = { faName, faAction, faCommand, faDatasource, faFilter, faOrder }; static const sal_Char* pStringPropertyNames[] = { PROPERTY_NAME, PROPERTY_TARGETURL, PROPERTY_COMMAND, PROPERTY_DATASOURCENAME, PROPERTY_FILTER, PROPERTY_ORDER }; sal_Int32 nIdCount = sizeof(eStringPropertyIds) / sizeof(eStringPropertyIds[0]); #ifdef DBG_UTIL sal_Int32 nNameCount = sizeof(pStringPropertyNames) / sizeof(pStringPropertyNames[0]); OSL_ENSURE((nIdCount == nNameCount), "OFormExport::exportAttributes: somebody tampered with the maps (1)!"); #endif for (i=0; i