163bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 363bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 463bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 563bba73cSAndrew Rist * distributed with this work for additional information 663bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 763bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 863bba73cSAndrew Rist * "License"); you may not use this file except in compliance 963bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 1063bba73cSAndrew Rist * 1163bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1263bba73cSAndrew Rist * 1363bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 1463bba73cSAndrew Rist * software distributed under the License is distributed on an 1563bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1663bba73cSAndrew Rist * KIND, either express or implied. See the License for the 1763bba73cSAndrew Rist * specific language governing permissions and limitations 1863bba73cSAndrew Rist * under the License. 1963bba73cSAndrew Rist * 2063bba73cSAndrew Rist *************************************************************/ 2163bba73cSAndrew Rist 2263bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "elementimport.hxx" 28cdf0e10cSrcweir #include "xmloff/xmlimp.hxx" 29cdf0e10cSrcweir #include "xmloff/nmspmap.hxx" 30cdf0e10cSrcweir #include "xmloff/xmluconv.hxx" 31cdf0e10cSrcweir #include "strings.hxx" 32cdf0e10cSrcweir #include "callbacks.hxx" 33cdf0e10cSrcweir #include "attriblistmerge.hxx" 34cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 35cdf0e10cSrcweir #include "eventimport.hxx" 36cdf0e10cSrcweir #include "xmloff/txtstyli.hxx" 37cdf0e10cSrcweir #include "formenums.hxx" 38cdf0e10cSrcweir #include "xmloff/xmltoken.hxx" 39cdf0e10cSrcweir #include "gridcolumnproptranslator.hxx" 40cdf0e10cSrcweir #include "property_description.hxx" 41cdf0e10cSrcweir #include "property_meta_data.hxx" 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** === begin UNO includes === **/ 44cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp> 45cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp> 46cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp> 47cdf0e10cSrcweir #include <com/sun/star/awt/ImagePosition.hpp> 48cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp> 49cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp> 50cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 51cdf0e10cSrcweir /** === end UNO includes === **/ 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <tools/urlobj.hxx> 54cdf0e10cSrcweir #include <tools/diagnose_ex.h> 55cdf0e10cSrcweir #include <tools/time.hxx> 56cdf0e10cSrcweir #include <rtl/logfile.hxx> 57cdf0e10cSrcweir #include <comphelper/extract.hxx> 58cdf0e10cSrcweir #include <comphelper/types.hxx> 59cdf0e10cSrcweir 60cdf0e10cSrcweir #include <algorithm> 61cdf0e10cSrcweir #include <functional> 62cdf0e10cSrcweir 63cdf0e10cSrcweir //......................................................................... 64cdf0e10cSrcweir namespace xmloff 65cdf0e10cSrcweir { 66cdf0e10cSrcweir //......................................................................... 67cdf0e10cSrcweir 68cdf0e10cSrcweir using namespace ::xmloff::token; 69cdf0e10cSrcweir using namespace ::com::sun::star; 70cdf0e10cSrcweir using namespace ::com::sun::star::uno; 71cdf0e10cSrcweir using namespace ::com::sun::star::awt; 72cdf0e10cSrcweir using namespace ::com::sun::star::container; 73cdf0e10cSrcweir using namespace ::com::sun::star::beans; 74cdf0e10cSrcweir using namespace ::com::sun::star::script; 75cdf0e10cSrcweir using namespace ::com::sun::star::lang; 76cdf0e10cSrcweir using namespace ::com::sun::star::form; 77cdf0e10cSrcweir using namespace ::com::sun::star::xml; 78cdf0e10cSrcweir using namespace ::com::sun::star::util; 79cdf0e10cSrcweir using namespace ::com::sun::star::text; 80cdf0e10cSrcweir using namespace ::comphelper; 81cdf0e10cSrcweir 82cdf0e10cSrcweir #define PROPID_VALUE 1 83cdf0e10cSrcweir #define PROPID_CURRENT_VALUE 2 84cdf0e10cSrcweir #define PROPID_MIN_VALUE 3 85cdf0e10cSrcweir #define PROPID_MAX_VALUE 4 86cdf0e10cSrcweir 87cdf0e10cSrcweir //===================================================================== 88cdf0e10cSrcweir struct PropertyValueLess 89cdf0e10cSrcweir { operator ()xmloff::PropertyValueLess90cdf0e10cSrcweir sal_Bool operator()(const PropertyValue& _rLeft, const PropertyValue& _rRight) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir return _rLeft.Name < _rRight.Name; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir }; 95cdf0e10cSrcweir 96cdf0e10cSrcweir //===================================================================== 97cdf0e10cSrcweir struct PropertyValueCompare : public ::std::binary_function< PropertyValue, ::rtl::OUString, bool> 98cdf0e10cSrcweir { operator ()xmloff::PropertyValueCompare99cdf0e10cSrcweir bool operator() (const PropertyValue& lhs, const ::rtl::OUString& rhs) const 100cdf0e10cSrcweir { 101cdf0e10cSrcweir return lhs.Name == rhs; 102cdf0e10cSrcweir } operator ()xmloff::PropertyValueCompare103cdf0e10cSrcweir bool operator() (const ::rtl::OUString& lhs, const PropertyValue& rhs) const 104cdf0e10cSrcweir { 105cdf0e10cSrcweir return lhs == rhs.Name; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir }; 108cdf0e10cSrcweir 109cdf0e10cSrcweir //===================================================================== 110cdf0e10cSrcweir template <class ELEMENT> pushBackSequenceElement(Sequence<ELEMENT> & _rContainer,const ELEMENT & _rElement)111cdf0e10cSrcweir void pushBackSequenceElement(Sequence< ELEMENT >& _rContainer, const ELEMENT& _rElement) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir sal_Int32 nLen = _rContainer.getLength(); 114cdf0e10cSrcweir _rContainer.realloc(nLen + 1); 115cdf0e10cSrcweir _rContainer[nLen] = _rElement; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir //===================================================================== 119cdf0e10cSrcweir //= OElementNameMap 120cdf0e10cSrcweir //===================================================================== 121cdf0e10cSrcweir //--------------------------------------------------------------------- 122cdf0e10cSrcweir OElementNameMap::MapString2Element OElementNameMap::s_sElementTranslations; 123cdf0e10cSrcweir 124cdf0e10cSrcweir //--------------------------------------------------------------------- operator ++(OControlElement::ElementType & _e)125cdf0e10cSrcweir const OControlElement::ElementType& operator ++(OControlElement::ElementType& _e) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir OControlElement::ElementType e = _e; 128cdf0e10cSrcweir sal_Int32 nAsInt = static_cast<sal_Int32>(e); 129cdf0e10cSrcweir _e = static_cast<OControlElement::ElementType>( ++nAsInt ); 130cdf0e10cSrcweir return _e; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir //--------------------------------------------------------------------- getElementType(const::rtl::OUString & _rName)134cdf0e10cSrcweir OControlElement::ElementType OElementNameMap::getElementType(const ::rtl::OUString& _rName) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir if ( s_sElementTranslations.empty() ) 137cdf0e10cSrcweir { // initialize 138cdf0e10cSrcweir for (ElementType eType=(ElementType)0; eType<UNKNOWN; ++eType) 139cdf0e10cSrcweir s_sElementTranslations[::rtl::OUString::createFromAscii(getElementName(eType))] = eType; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir ConstMapString2ElementIterator aPos = s_sElementTranslations.find(_rName); 142cdf0e10cSrcweir if (s_sElementTranslations.end() != aPos) 143cdf0e10cSrcweir return aPos->second; 144cdf0e10cSrcweir 145cdf0e10cSrcweir return UNKNOWN; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir //===================================================================== 149cdf0e10cSrcweir //= OElementImport 150cdf0e10cSrcweir //===================================================================== 151cdf0e10cSrcweir //--------------------------------------------------------------------- OElementImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer)152cdf0e10cSrcweir OElementImport::OElementImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 153cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer) 154cdf0e10cSrcweir :OPropertyImport(_rImport, _nPrefix, _rName) 155cdf0e10cSrcweir ,m_rFormImport(_rImport) 156cdf0e10cSrcweir ,m_rEventManager(_rEventManager) 157cdf0e10cSrcweir ,m_pStyleElement( NULL ) 158cdf0e10cSrcweir ,m_xParentContainer(_rxParentContainer) 159cdf0e10cSrcweir ,m_bImplicitGenericAttributeHandling( true ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir OSL_ENSURE(m_xParentContainer.is(), "OElementImport::OElementImport: invalid parent container!"); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir //--------------------------------------------------------------------- ~OElementImport()165cdf0e10cSrcweir OElementImport::~OElementImport() 166cdf0e10cSrcweir { 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir //--------------------------------------------------------------------- determineDefaultServiceName() const170cdf0e10cSrcweir ::rtl::OUString OElementImport::determineDefaultServiceName() const 171cdf0e10cSrcweir { 172cdf0e10cSrcweir return ::rtl::OUString(); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)176cdf0e10cSrcweir void OElementImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir ENTER_LOG_CONTEXT( "xmloff::OElementImport - importing one element" ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir const SvXMLNamespaceMap& rMap = m_rContext.getGlobalContext().GetNamespaceMap(); 181cdf0e10cSrcweir const ::rtl::OUString sImplNameAttribute = rMap.GetQNameByKey( XML_NAMESPACE_FORM, GetXMLToken( XML_CONTROL_IMPLEMENTATION ) ); 182cdf0e10cSrcweir const ::rtl::OUString sControlImplementation = _rxAttrList->getValueByName( sImplNameAttribute ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir // retrieve the service name 185cdf0e10cSrcweir if ( sControlImplementation.getLength() > 0 ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir ::rtl::OUString sOOoImplementationName; 188cdf0e10cSrcweir const sal_uInt16 nImplPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sControlImplementation, &sOOoImplementationName ); 189cdf0e10cSrcweir m_sServiceName = ( nImplPrefix == XML_NAMESPACE_OOO ) ? sOOoImplementationName : sControlImplementation; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir if ( !m_sServiceName.getLength() ) 19328f2418dSTsutomu Uchino m_sServiceName = determineDefaultServiceName(); 194cdf0e10cSrcweir 195cdf0e10cSrcweir // create the object *now*. This allows setting properties in the various handleAttribute methods. 196cdf0e10cSrcweir // (Though currently not all code is migrated to this pattern, most attributes are still handled 197cdf0e10cSrcweir // by remembering the value (via implPushBackPropertyValue), and setting the correct property value 198cdf0e10cSrcweir // later (in OControlImport::StartElement).) 199cdf0e10cSrcweir m_xElement = createElement(); 200cdf0e10cSrcweir if ( m_xElement.is() ) 201cdf0e10cSrcweir m_xInfo = m_xElement->getPropertySetInfo(); 202cdf0e10cSrcweir 203cdf0e10cSrcweir // call the base class 204cdf0e10cSrcweir OPropertyImport::StartElement( _rxAttrList ); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir //--------------------------------------------------------------------- CreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,const Reference<sax::XAttributeList> & _rxAttrList)208cdf0e10cSrcweir SvXMLImportContext* OElementImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 209cdf0e10cSrcweir const Reference< sax::XAttributeList >& _rxAttrList) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir if( token::IsXMLToken(_rLocalName, token::XML_EVENT_LISTENERS) && (XML_NAMESPACE_OFFICE == _nPrefix)) 212cdf0e10cSrcweir return new OFormEventsImportContext(m_rFormImport.getGlobalContext(), _nPrefix, _rLocalName, *this); 213cdf0e10cSrcweir 214cdf0e10cSrcweir return OPropertyImport::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir //--------------------------------------------------------------------- EndElement()218cdf0e10cSrcweir void OElementImport::EndElement() 219cdf0e10cSrcweir { 220cdf0e10cSrcweir OSL_ENSURE(m_xElement.is(), "OElementImport::EndElement: invalid element created!"); 221cdf0e10cSrcweir if (!m_xElement.is()) 222cdf0e10cSrcweir return; 223cdf0e10cSrcweir 224cdf0e10cSrcweir // apply the non-generic properties 225cdf0e10cSrcweir implApplySpecificProperties(); 226cdf0e10cSrcweir 227cdf0e10cSrcweir // set the generic properties 228cdf0e10cSrcweir implApplyGenericProperties(); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // set the style properties 231cdf0e10cSrcweir if ( m_pStyleElement && m_xElement.is() ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir Reference< XPropertySet > xPropTranslation = 234cdf0e10cSrcweir new OGridColumnPropertyTranslator( Reference< XMultiPropertySet >( m_xElement, UNO_QUERY ) ); 235cdf0e10cSrcweir const_cast< XMLTextStyleContext* >( m_pStyleElement )->FillPropertySet( xPropTranslation ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir const ::rtl::OUString sNumberStyleName = const_cast< XMLTextStyleContext* >( m_pStyleElement )->GetDataStyleName( ); 238cdf0e10cSrcweir if ( sNumberStyleName.getLength() ) 239cdf0e10cSrcweir // the style also has a number (sub) style 240cdf0e10cSrcweir m_rContext.applyControlNumberStyle( m_xElement, sNumberStyleName ); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir // insert the element into the parent container 244cdf0e10cSrcweir if (!m_sName.getLength()) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir OSL_ENSURE(sal_False, "OElementImport::EndElement: did not find a name attribute!"); 247cdf0e10cSrcweir m_sName = implGetDefaultName(); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir m_xParentContainer->insertByName(m_sName, makeAny(m_xElement)); 251cdf0e10cSrcweir LEAVE_LOG_CONTEXT( ); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir //--------------------------------------------------------------------- implApplySpecificProperties()255cdf0e10cSrcweir void OElementImport::implApplySpecificProperties() 256cdf0e10cSrcweir { 257cdf0e10cSrcweir if ( m_aValues.empty() ) 258cdf0e10cSrcweir return; 259cdf0e10cSrcweir 260cdf0e10cSrcweir // set all the properties we collected 261cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 262cdf0e10cSrcweir // check if the object has all the properties 263cdf0e10cSrcweir // (We do this in the non-pro version only. Doing it all the time would be much to expensive) 264cdf0e10cSrcweir if ( m_xInfo.is() ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir PropertyValueArray::const_iterator aEnd = m_aValues.end(); 267cdf0e10cSrcweir for ( PropertyValueArray::iterator aCheck = m_aValues.begin(); 268cdf0e10cSrcweir aCheck != aEnd; 269cdf0e10cSrcweir ++aCheck 270cdf0e10cSrcweir ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir OSL_ENSURE(m_xInfo->hasPropertyByName(aCheck->Name), 273cdf0e10cSrcweir ::rtl::OString("OElementImport::implApplySpecificProperties: read a property (") 274cdf0e10cSrcweir += ::rtl::OString(aCheck->Name.getStr(), aCheck->Name.getLength(), RTL_TEXTENCODING_ASCII_US) 275cdf0e10cSrcweir += ::rtl::OString(") which does not exist on the element!")); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir } 278cdf0e10cSrcweir #endif 279cdf0e10cSrcweir 280cdf0e10cSrcweir // set the properties 281cdf0e10cSrcweir const Reference< XMultiPropertySet > xMultiProps(m_xElement, UNO_QUERY); 282cdf0e10cSrcweir sal_Bool bSuccess = sal_False; 283cdf0e10cSrcweir if (xMultiProps.is()) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir // translate our properties so that the XMultiPropertySet can handle them 286cdf0e10cSrcweir 287cdf0e10cSrcweir // sort our property value array so that we can use it in a setPropertyValues 288cdf0e10cSrcweir ::std::sort( m_aValues.begin(), m_aValues.end(), PropertyValueLess()); 289cdf0e10cSrcweir 290cdf0e10cSrcweir // the names 291cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(m_aValues.size()); 292cdf0e10cSrcweir ::rtl::OUString* pNames = aNames.getArray(); 293cdf0e10cSrcweir // the values 294cdf0e10cSrcweir Sequence< Any > aValues(m_aValues.size()); 295cdf0e10cSrcweir Any* pValues = aValues.getArray(); 296cdf0e10cSrcweir // copy 297cdf0e10cSrcweir 298cdf0e10cSrcweir PropertyValueArray::iterator aEnd = m_aValues.end(); 299cdf0e10cSrcweir for ( PropertyValueArray::iterator aPropValues = m_aValues.begin(); 300cdf0e10cSrcweir aPropValues != aEnd; 301cdf0e10cSrcweir ++aPropValues, ++pNames, ++pValues 302cdf0e10cSrcweir ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir *pNames = aPropValues->Name; 305cdf0e10cSrcweir *pValues = aPropValues->Value; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir try 309cdf0e10cSrcweir { 310cdf0e10cSrcweir xMultiProps->setPropertyValues(aNames, aValues); 311cdf0e10cSrcweir bSuccess = sal_True; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir catch(Exception&) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir OSL_ENSURE(sal_False, "OElementImport::implApplySpecificProperties: could not set the properties (using the XMultiPropertySet)!"); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir if (!bSuccess) 320cdf0e10cSrcweir { // no XMultiPropertySet or setting all properties at once failed 321cdf0e10cSrcweir PropertyValueArray::iterator aEnd = m_aValues.end(); 322cdf0e10cSrcweir for ( PropertyValueArray::iterator aPropValues = m_aValues.begin(); 323cdf0e10cSrcweir aPropValues != aEnd; 324cdf0e10cSrcweir ++aPropValues 325cdf0e10cSrcweir ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir // this try/catch here is expensive, but because this is just a fallback which should normally not be 328cdf0e10cSrcweir // used it's acceptable this way ... 329cdf0e10cSrcweir try 330cdf0e10cSrcweir { 331cdf0e10cSrcweir m_xElement->setPropertyValue(aPropValues->Name, aPropValues->Value); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir catch(Exception&) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir OSL_ENSURE(sal_False, 336cdf0e10cSrcweir ::rtl::OString("OElementImport::implApplySpecificProperties: could not set the property \"") 337cdf0e10cSrcweir += ::rtl::OString(aPropValues->Name.getStr(), aPropValues->Name.getLength(), RTL_TEXTENCODING_ASCII_US) 338cdf0e10cSrcweir += ::rtl::OString("\"!")); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir //--------------------------------------------------------------------- implApplyGenericProperties()345cdf0e10cSrcweir void OElementImport::implApplyGenericProperties() 346cdf0e10cSrcweir { 347cdf0e10cSrcweir if ( m_aGenericValues.empty() ) 348cdf0e10cSrcweir return; 349cdf0e10cSrcweir 350cdf0e10cSrcweir Reference< XPropertyContainer > xDynamicProperties( m_xElement, UNO_QUERY ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir PropertyValueArray::iterator aEnd = m_aGenericValues.end(); 353cdf0e10cSrcweir for ( PropertyValueArray::iterator aPropValues = 354cdf0e10cSrcweir m_aGenericValues.begin(); 355cdf0e10cSrcweir aPropValues != aEnd; 356cdf0e10cSrcweir ++aPropValues 357cdf0e10cSrcweir ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir // check property type for numeric types before setting 360cdf0e10cSrcweir // the property 361cdf0e10cSrcweir try 362cdf0e10cSrcweir { 363cdf0e10cSrcweir // if such a property does not yet exist at the element, create it if necessary 364cdf0e10cSrcweir const bool bExistentProperty = m_xInfo->hasPropertyByName( aPropValues->Name ); 365cdf0e10cSrcweir if ( !bExistentProperty ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir if ( !xDynamicProperties.is() ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 370cdf0e10cSrcweir ::rtl::OString aMessage( "OElementImport::implApplyGenericProperties: encountered an unknown property (" ); 371cdf0e10cSrcweir aMessage += ::rtl::OUStringToOString( aPropValues->Name, RTL_TEXTENCODING_ASCII_US ); 372cdf0e10cSrcweir aMessage += "), but component is no PropertyBag!"; 373cdf0e10cSrcweir OSL_ENSURE( false, aMessage.getStr() ); 374cdf0e10cSrcweir #endif 375cdf0e10cSrcweir continue; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir xDynamicProperties->addProperty( 379cdf0e10cSrcweir aPropValues->Name, 380cdf0e10cSrcweir PropertyAttribute::BOUND | PropertyAttribute::REMOVEABLE, 381cdf0e10cSrcweir aPropValues->Value 382cdf0e10cSrcweir ); 383cdf0e10cSrcweir 384cdf0e10cSrcweir // re-fetch the PropertySetInfo 385cdf0e10cSrcweir m_xInfo = m_xElement->getPropertySetInfo(); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir // determine the type of the value (source for the following conversion) 389cdf0e10cSrcweir TypeClass eValueTypeClass = aPropValues->Value.getValueTypeClass(); 390cdf0e10cSrcweir const sal_Bool bValueIsSequence = TypeClass_SEQUENCE == eValueTypeClass; 391cdf0e10cSrcweir if ( bValueIsSequence ) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir uno::Type aSimpleType( getSequenceElementType( aPropValues->Value.getValueType() ) ); 394cdf0e10cSrcweir eValueTypeClass = aSimpleType.getTypeClass(); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir // determine the type of the property (target for the following conversion) 398cdf0e10cSrcweir const Property aProperty( m_xInfo->getPropertyByName( aPropValues->Name ) ); 399cdf0e10cSrcweir TypeClass ePropTypeClass = aProperty.Type.getTypeClass(); 400cdf0e10cSrcweir const sal_Bool bPropIsSequence = TypeClass_SEQUENCE == ePropTypeClass; 401cdf0e10cSrcweir if( bPropIsSequence ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir uno::Type aSimpleType( ::comphelper::getSequenceElementType( aProperty.Type ) ); 404cdf0e10cSrcweir ePropTypeClass = aSimpleType.getTypeClass(); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir if ( bPropIsSequence != bValueIsSequence ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir OSL_ENSURE( false, "OElementImport::implApplyGenericProperties: either both value and property should be a sequence, or none of them!" ); 410cdf0e10cSrcweir continue; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir if ( bValueIsSequence ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir OSL_ENSURE( eValueTypeClass == TypeClass_ANY, 416cdf0e10cSrcweir "OElementImport::implApplyGenericProperties: only ANYs should have been imported as generic list property!" ); 417cdf0e10cSrcweir // (OPropertyImport should produce only Sequencer< Any >, since it cannot know the real type 418cdf0e10cSrcweir 419cdf0e10cSrcweir OSL_ENSURE( ePropTypeClass == TypeClass_SHORT, 420cdf0e10cSrcweir "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" ); 421cdf0e10cSrcweir 422cdf0e10cSrcweir Sequence< Any > aXMLValueList; 423cdf0e10cSrcweir aPropValues->Value >>= aXMLValueList; 424cdf0e10cSrcweir Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() ); 425cdf0e10cSrcweir 426cdf0e10cSrcweir const Any* pXMLValue = aXMLValueList.getConstArray(); 427cdf0e10cSrcweir sal_Int16* pPropValue = aPropertyValueList.getArray(); 428cdf0e10cSrcweir 429cdf0e10cSrcweir for ( sal_Int32 i=0; i<aXMLValueList.getLength(); ++i, ++pXMLValue, ++pPropValue ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir // only value sequences of numeric types implemented so far. 432cdf0e10cSrcweir double nVal( 0 ); 433cdf0e10cSrcweir OSL_VERIFY( *pXMLValue >>= nVal ); 434cdf0e10cSrcweir *pPropValue = static_cast< sal_Int16 >( nVal ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir aPropValues->Value <<= aPropertyValueList; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir else if ( ePropTypeClass != eValueTypeClass ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir switch ( eValueTypeClass ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir case TypeClass_DOUBLE: 444cdf0e10cSrcweir { 445cdf0e10cSrcweir double nVal = 0; 446cdf0e10cSrcweir aPropValues->Value >>= nVal; 447cdf0e10cSrcweir switch( ePropTypeClass ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir case TypeClass_BYTE: 450cdf0e10cSrcweir aPropValues->Value <<= static_cast< sal_Int8 >( nVal ); 451cdf0e10cSrcweir break; 452cdf0e10cSrcweir case TypeClass_SHORT: 453cdf0e10cSrcweir aPropValues->Value <<= static_cast< sal_Int16 >( nVal ); 454cdf0e10cSrcweir break; 455cdf0e10cSrcweir case TypeClass_LONG: 456cdf0e10cSrcweir case TypeClass_ENUM: 457cdf0e10cSrcweir aPropValues->Value <<= static_cast< sal_Int32 >( nVal ); 458cdf0e10cSrcweir break; 459cdf0e10cSrcweir case TypeClass_HYPER: 460cdf0e10cSrcweir aPropValues->Value <<= static_cast< sal_Int64 >( nVal ); 461cdf0e10cSrcweir break; 462cdf0e10cSrcweir default: 463cdf0e10cSrcweir OSL_ENSURE( false, "OElementImport::implApplyGenericProperties: unsupported value type!" ); 464cdf0e10cSrcweir break; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir } 467cdf0e10cSrcweir break; 468cdf0e10cSrcweir default: 469cdf0e10cSrcweir OSL_ENSURE( false, "OElementImport::implApplyGenericProperties: non-double values not supported!" ); 470cdf0e10cSrcweir break; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir } 473cdf0e10cSrcweir 474cdf0e10cSrcweir m_xElement->setPropertyValue( aPropValues->Name, aPropValues->Value ); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir catch(Exception&) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir OSL_ENSURE(sal_False, 479cdf0e10cSrcweir ::rtl::OString("OElementImport::EndElement: could not set the property \"") 480cdf0e10cSrcweir += ::rtl::OString(aPropValues->Name.getStr(), aPropValues->Name.getLength(), RTL_TEXTENCODING_ASCII_US) 481cdf0e10cSrcweir += ::rtl::OString("\"!")); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir } 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir //--------------------------------------------------------------------- implGetDefaultName() const487cdf0e10cSrcweir ::rtl::OUString OElementImport::implGetDefaultName() const 488cdf0e10cSrcweir { 489cdf0e10cSrcweir // no optimization here. If this method gets called, the XML stream did not contain a name for the 490cdf0e10cSrcweir // element, which is a heavy error. So in this case we don't care for performance 491cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames = m_xParentContainer->getElementNames(); 492cdf0e10cSrcweir static const ::rtl::OUString sUnnamedName = ::rtl::OUString::createFromAscii("unnamed"); 493cdf0e10cSrcweir 494cdf0e10cSrcweir ::rtl::OUString sReturn; 495cdf0e10cSrcweir const ::rtl::OUString* pNames = NULL; 496cdf0e10cSrcweir const ::rtl::OUString* pNamesEnd = aNames.getConstArray() + aNames.getLength(); 497cdf0e10cSrcweir for (sal_Int32 i=0; i<32768; ++i) // the limit is nearly arbitrary ... 498cdf0e10cSrcweir { 499cdf0e10cSrcweir // assemble the new name (suggestion) 500cdf0e10cSrcweir sReturn = sUnnamedName; 501cdf0e10cSrcweir sReturn += ::rtl::OUString::valueOf(i); 502cdf0e10cSrcweir // check the existence (this is the bad performance part ....) 503cdf0e10cSrcweir for (pNames = aNames.getConstArray(); pNames<pNamesEnd; ++pNames) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir if (*pNames == sReturn) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir break; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir if (pNames<pNamesEnd) 511cdf0e10cSrcweir // found the name 512cdf0e10cSrcweir continue; 513cdf0e10cSrcweir return sReturn; 514cdf0e10cSrcweir } 515cdf0e10cSrcweir OSL_ENSURE(sal_False, "OElementImport::implGetDefaultName: did not find a free name!"); 516cdf0e10cSrcweir return sUnnamedName; 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir //--------------------------------------------------------------------- impl_matchPropertyGroup(const PropertyGroups & i_propertyGroups) const520cdf0e10cSrcweir PropertyGroups::const_iterator OElementImport::impl_matchPropertyGroup( const PropertyGroups& i_propertyGroups ) const 521cdf0e10cSrcweir { 522cdf0e10cSrcweir ENSURE_OR_RETURN( m_xInfo.is(), "OElementImport::impl_matchPropertyGroup: no property set info!", i_propertyGroups.end() ); 523cdf0e10cSrcweir 524cdf0e10cSrcweir for ( PropertyGroups::const_iterator group = i_propertyGroups.begin(); 525cdf0e10cSrcweir group != i_propertyGroups.end(); 526cdf0e10cSrcweir ++group 527cdf0e10cSrcweir ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir bool missingProp = false; 530cdf0e10cSrcweir for ( PropertyDescriptionList::const_iterator prop = group->begin(); 531cdf0e10cSrcweir prop != group->end(); 532cdf0e10cSrcweir ++prop 533cdf0e10cSrcweir ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir if ( !m_xInfo->hasPropertyByName( (*prop)->propertyName ) ) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir missingProp = true; 538cdf0e10cSrcweir break; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir if ( missingProp ) 543cdf0e10cSrcweir // try next group 544cdf0e10cSrcweir continue; 545cdf0e10cSrcweir 546cdf0e10cSrcweir return group; 547cdf0e10cSrcweir } 548cdf0e10cSrcweir 549cdf0e10cSrcweir return i_propertyGroups.end(); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir //--------------------------------------------------------------------- tryGenericAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)553cdf0e10cSrcweir bool OElementImport::tryGenericAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ) 554cdf0e10cSrcweir { 555cdf0e10cSrcweir // the generic approach (which I hope all props will be migrated to, on the medium term): property handlers 556cdf0e10cSrcweir const AttributeDescription attribute( metadata::getAttributeDescription( _nNamespaceKey, _rLocalName ) ); 557cdf0e10cSrcweir if ( attribute.attributeToken != XML_TOKEN_INVALID ) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir PropertyGroups propertyGroups; 560cdf0e10cSrcweir metadata::getPropertyGroupList( attribute, propertyGroups ); 561cdf0e10cSrcweir const PropertyGroups::const_iterator pos = impl_matchPropertyGroup( propertyGroups ); 562cdf0e10cSrcweir if ( pos == propertyGroups.end() ) 563cdf0e10cSrcweir return false; 564cdf0e10cSrcweir 565cdf0e10cSrcweir do 566cdf0e10cSrcweir { 567cdf0e10cSrcweir const PropertyDescriptionList& rProperties( *pos ); 568cdf0e10cSrcweir const PropertyDescription* first = *rProperties.begin(); 569cdf0e10cSrcweir ENSURE_OR_BREAK( first != NULL, "OElementImport::handleAttribute: invalid property description!" ); 570cdf0e10cSrcweir const PPropertyHandler handler = (*first->factory)( first->propertyId ); 571cdf0e10cSrcweir ENSURE_OR_BREAK( handler.get() != NULL, "OElementImport::handleAttribute: invalid property handler!" ); 572cdf0e10cSrcweir 573cdf0e10cSrcweir PropertyValues aValues; 574cdf0e10cSrcweir for ( PropertyDescriptionList::const_iterator propDesc = rProperties.begin(); 575cdf0e10cSrcweir propDesc != rProperties.end(); 576cdf0e10cSrcweir ++propDesc 577cdf0e10cSrcweir ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir aValues[ (*propDesc)->propertyId ] = Any(); 580cdf0e10cSrcweir } 581cdf0e10cSrcweir if ( handler->getPropertyValues( _rValue, aValues ) ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir for ( PropertyDescriptionList::const_iterator propDesc = rProperties.begin(); 584cdf0e10cSrcweir propDesc != rProperties.end(); 585cdf0e10cSrcweir ++propDesc 586cdf0e10cSrcweir ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir implPushBackPropertyValue( (*propDesc)->propertyName, aValues[ (*propDesc)->propertyId ] ); 589cdf0e10cSrcweir } 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } 592cdf0e10cSrcweir while ( false ); 593cdf0e10cSrcweir 594cdf0e10cSrcweir // handled 595cdf0e10cSrcweir return true; 596cdf0e10cSrcweir } 597cdf0e10cSrcweir return false; 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)601cdf0e10cSrcweir bool OElementImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir if ( token::IsXMLToken( _rLocalName, token::XML_CONTROL_IMPLEMENTATION ) ) 604cdf0e10cSrcweir // ignore this, it has already been handled in OElementImport::StartElement 605cdf0e10cSrcweir return true; 606cdf0e10cSrcweir 607cdf0e10cSrcweir if ( token::IsXMLToken( _rLocalName, token::XML_NAME ) ) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir if ( !m_sName.getLength() ) 610cdf0e10cSrcweir // remember the name for later use in EndElement 611cdf0e10cSrcweir m_sName = _rValue; 612cdf0e10cSrcweir return true; 613cdf0e10cSrcweir } 614cdf0e10cSrcweir 615cdf0e10cSrcweir // maybe it's the style attribute? 616cdf0e10cSrcweir if ( token::IsXMLToken( _rLocalName, token::XML_TEXT_STYLE_NAME ) ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue ); 619cdf0e10cSrcweir OSL_ENSURE( pStyleContext, "OElementImport::handleAttribute: do not know the style!" ); 620cdf0e10cSrcweir // remember the element for later usage. 621cdf0e10cSrcweir m_pStyleElement = PTR_CAST( XMLTextStyleContext, pStyleContext ); 622cdf0e10cSrcweir return true; 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir if ( m_bImplicitGenericAttributeHandling ) 626cdf0e10cSrcweir if ( tryGenericAttribute( _nNamespaceKey, _rLocalName, _rValue ) ) 627cdf0e10cSrcweir return true; 628cdf0e10cSrcweir 629cdf0e10cSrcweir // let the base class handle it 630cdf0e10cSrcweir return OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); 631cdf0e10cSrcweir } 632cdf0e10cSrcweir 633cdf0e10cSrcweir //--------------------------------------------------------------------- createElement()634cdf0e10cSrcweir Reference< XPropertySet > OElementImport::createElement() 635cdf0e10cSrcweir { 636cdf0e10cSrcweir Reference< XPropertySet > xReturn; 637cdf0e10cSrcweir if (m_sServiceName.getLength()) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir Reference< XInterface > xPure = m_rFormImport.getGlobalContext().getServiceFactory()->createInstance(m_sServiceName); 640cdf0e10cSrcweir OSL_ENSURE(xPure.is(), 641cdf0e10cSrcweir ::rtl::OString("OElementImport::createElement: service factory gave me no object (service name: ") 642cdf0e10cSrcweir += ::rtl::OString(m_sServiceName.getStr(), m_sServiceName.getLength(), RTL_TEXTENCODING_ASCII_US) 643cdf0e10cSrcweir += ::rtl::OString(")!")); 644cdf0e10cSrcweir xReturn = Reference< XPropertySet >(xPure, UNO_QUERY); 645cdf0e10cSrcweir } 646cdf0e10cSrcweir else 647cdf0e10cSrcweir OSL_ENSURE(sal_False, "OElementImport::createElement: no service name to create an element!"); 648cdf0e10cSrcweir 649cdf0e10cSrcweir return xReturn; 650cdf0e10cSrcweir } 651cdf0e10cSrcweir 652cdf0e10cSrcweir //--------------------------------------------------------------------- registerEvents(const Sequence<ScriptEventDescriptor> & _rEvents)653cdf0e10cSrcweir void OElementImport::registerEvents(const Sequence< ScriptEventDescriptor >& _rEvents) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir OSL_ENSURE(m_xElement.is(), "OElementImport::registerEvents: no element to register events for!"); 656cdf0e10cSrcweir m_rEventManager.registerEvents(m_xElement, _rEvents); 657cdf0e10cSrcweir } 658cdf0e10cSrcweir 659cdf0e10cSrcweir //--------------------------------------------------------------------- simulateDefaultedAttribute(const sal_Char * _pAttributeName,const::rtl::OUString & _rPropertyName,const sal_Char * _pAttributeDefault)660cdf0e10cSrcweir void OElementImport::simulateDefaultedAttribute(const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, const sal_Char* _pAttributeDefault) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir OSL_ENSURE( m_xInfo.is(), "OPropertyImport::simulateDefaultedAttribute: the component should be more gossipy about it's properties!" ); 663cdf0e10cSrcweir 664cdf0e10cSrcweir if ( !m_xInfo.is() || m_xInfo->hasPropertyByName( _rPropertyName ) ) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir ::rtl::OUString sLocalAttrName = ::rtl::OUString::createFromAscii(_pAttributeName); 667cdf0e10cSrcweir if ( !encounteredAttribute( sLocalAttrName ) ) 668cdf0e10cSrcweir OSL_VERIFY( handleAttribute( XML_NAMESPACE_FORM, sLocalAttrName, ::rtl::OUString::createFromAscii( _pAttributeDefault ) ) ); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir 672cdf0e10cSrcweir //===================================================================== 673cdf0e10cSrcweir //= OControlImport 674cdf0e10cSrcweir //===================================================================== 675cdf0e10cSrcweir //--------------------------------------------------------------------- OControlImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer)676cdf0e10cSrcweir OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 677cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer) 678cdf0e10cSrcweir :OElementImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer) 679cdf0e10cSrcweir ,m_eElementType(OControlElement::UNKNOWN) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir disableImplicitGenericAttributeHandling(); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir 684cdf0e10cSrcweir //--------------------------------------------------------------------- OControlImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)685cdf0e10cSrcweir OControlImport::OControlImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 686cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType) 687cdf0e10cSrcweir :OElementImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer) 688cdf0e10cSrcweir ,m_eElementType(_eType) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir disableImplicitGenericAttributeHandling(); 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir //--------------------------------------------------------------------- determineDefaultServiceName() const694cdf0e10cSrcweir ::rtl::OUString OControlImport::determineDefaultServiceName() const 695cdf0e10cSrcweir { 696cdf0e10cSrcweir const sal_Char* pServiceName = NULL; 697cdf0e10cSrcweir switch ( m_eElementType ) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir case OControlElement::TEXT: 700cdf0e10cSrcweir case OControlElement::TEXT_AREA: 701cdf0e10cSrcweir case OControlElement::PASSWORD: pServiceName = "com.sun.star.form.component.TextField"; break; 702cdf0e10cSrcweir case OControlElement::FILE: pServiceName = "com.sun.star.form.component.FileControl"; break; 703cdf0e10cSrcweir case OControlElement::FORMATTED_TEXT: pServiceName = "com.sun.star.form.component.FormattedField"; break; 704cdf0e10cSrcweir case OControlElement::FIXED_TEXT: pServiceName = "com.sun.star.form.component.FixedText"; break; 705cdf0e10cSrcweir case OControlElement::COMBOBOX: pServiceName = "com.sun.star.form.component.ComboBox"; break; 706cdf0e10cSrcweir case OControlElement::LISTBOX: pServiceName = "com.sun.star.form.component.ListBox"; break; 707cdf0e10cSrcweir case OControlElement::BUTTON: pServiceName = "com.sun.star.form.component.CommandButton"; break; 708cdf0e10cSrcweir case OControlElement::IMAGE: pServiceName = "com.sun.star.form.component.ImageButton"; break; 709cdf0e10cSrcweir case OControlElement::CHECKBOX: pServiceName = "com.sun.star.form.component.CheckBox"; break; 710cdf0e10cSrcweir case OControlElement::RADIO: pServiceName = "com.sun.star.form.component.RadioButton"; break; 711cdf0e10cSrcweir case OControlElement::FRAME: pServiceName = "com.sun.star.form.component.GroupBox"; break; 712cdf0e10cSrcweir case OControlElement::IMAGE_FRAME: pServiceName = "com.sun.star.form.component.DatabaseImageControl"; break; 713cdf0e10cSrcweir case OControlElement::HIDDEN: pServiceName = "com.sun.star.form.component.HiddenControl"; break; 714cdf0e10cSrcweir case OControlElement::GRID: pServiceName = "com.sun.star.form.component.GridControl"; break; 71528f2418dSTsutomu Uchino case OControlElement::VALUERANGE: pServiceName = "com.sun.star.form.component.ScrollBar"; break; 716cdf0e10cSrcweir case OControlElement::TIME: pServiceName = "com.sun.star.form.component.DateField"; break; 717cdf0e10cSrcweir case OControlElement::DATE: pServiceName = "com.sun.star.form.component.TimeField"; break; 718cdf0e10cSrcweir default: break; 719cdf0e10cSrcweir } 720cdf0e10cSrcweir if ( pServiceName != NULL ) 721cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( pServiceName ); 722cdf0e10cSrcweir return ::rtl::OUString(); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir //--------------------------------------------------------------------- addOuterAttributes(const Reference<sax::XAttributeList> & _rxOuterAttribs)726cdf0e10cSrcweir void OControlImport::addOuterAttributes(const Reference< sax::XAttributeList >& _rxOuterAttribs) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir OSL_ENSURE(!m_xOuterAttributes.is(), "OControlImport::addOuterAttributes: already have these attributes!"); 729cdf0e10cSrcweir m_xOuterAttributes = _rxOuterAttribs; 730cdf0e10cSrcweir } 731cdf0e10cSrcweir 732cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)733cdf0e10cSrcweir bool OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BA_LINKED_CELL); 736cdf0e10cSrcweir 737cdf0e10cSrcweir if (IsXMLToken(_rLocalName, XML_ID)) 738cdf0e10cSrcweir { // it's the control id 739cdf0e10cSrcweir if (XML_NAMESPACE_XML == _nNamespaceKey) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir m_sControlId = _rValue; 742cdf0e10cSrcweir } 743cdf0e10cSrcweir else if (XML_NAMESPACE_FORM == _nNamespaceKey) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir if (!m_sControlId.getLength()) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir m_sControlId = _rValue; 748cdf0e10cSrcweir } 749cdf0e10cSrcweir } 750cdf0e10cSrcweir return true; 751cdf0e10cSrcweir } 752cdf0e10cSrcweir 753cdf0e10cSrcweir if ( _rLocalName.equalsAscii( pLinkedCellAttributeName ) ) 754cdf0e10cSrcweir { // it's the address of a spreadsheet cell 755cdf0e10cSrcweir m_sBoundCellAddress = _rValue; 756cdf0e10cSrcweir return true; 757cdf0e10cSrcweir } 758cdf0e10cSrcweir 759cdf0e10cSrcweir if ( _nNamespaceKey == XML_NAMESPACE_XFORMS && IsXMLToken( _rLocalName, XML_BIND ) ) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir m_sBindingID = _rValue; 762cdf0e10cSrcweir return true; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir if ( _nNamespaceKey == XML_NAMESPACE_FORM && IsXMLToken( _rLocalName, XML_XFORMS_LIST_SOURCE ) ) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir m_sListBindingID = _rValue; 768cdf0e10cSrcweir return true; 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir if ( ( ( _nNamespaceKey == XML_NAMESPACE_FORM ) 772cdf0e10cSrcweir && IsXMLToken( _rLocalName, XML_XFORMS_SUBMISSION ) 773cdf0e10cSrcweir ) 774cdf0e10cSrcweir || ( ( _nNamespaceKey == XML_NAMESPACE_XFORMS ) 775cdf0e10cSrcweir && IsXMLToken( _rLocalName, XML_SUBMISSION ) 776cdf0e10cSrcweir ) 777cdf0e10cSrcweir ) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir m_sSubmissionID = _rValue; 780cdf0e10cSrcweir return true; 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir if ( OElementImport::tryGenericAttribute( _nNamespaceKey, _rLocalName, _rValue ) ) 784cdf0e10cSrcweir return true; 785cdf0e10cSrcweir 786cdf0e10cSrcweir static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE); 787cdf0e10cSrcweir static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE); 788cdf0e10cSrcweir static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE); 789cdf0e10cSrcweir static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE); 790cdf0e10cSrcweir static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY ); 791cdf0e10cSrcweir 792cdf0e10cSrcweir sal_Int32 nHandle = -1; 793cdf0e10cSrcweir if ( _rLocalName.equalsAscii( pValueAttributeName ) ) 794cdf0e10cSrcweir nHandle = PROPID_VALUE; 795cdf0e10cSrcweir else if ( _rLocalName.equalsAscii( pCurrentValueAttributeName ) ) 796cdf0e10cSrcweir nHandle = PROPID_CURRENT_VALUE; 797cdf0e10cSrcweir else if ( _rLocalName.equalsAscii( pMinValueAttributeName ) ) 798cdf0e10cSrcweir nHandle = PROPID_MIN_VALUE; 799cdf0e10cSrcweir else if ( _rLocalName.equalsAscii( pMaxValueAttributeName ) ) 800cdf0e10cSrcweir nHandle = PROPID_MAX_VALUE; 801cdf0e10cSrcweir if ( nHandle != -1 ) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir // for the moment, simply remember the name and the value 804cdf0e10cSrcweir PropertyValue aProp; 805cdf0e10cSrcweir aProp.Name = _rLocalName; 806cdf0e10cSrcweir aProp.Handle = nHandle; 807cdf0e10cSrcweir aProp.Value <<= _rValue; 808cdf0e10cSrcweir m_aValueProperties.push_back(aProp); 809cdf0e10cSrcweir return true; 810cdf0e10cSrcweir } 811cdf0e10cSrcweir 812cdf0e10cSrcweir if ( _rLocalName.equalsAscii( pRepeatDelayAttributeName ) ) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir ::Time aTime; 815cdf0e10cSrcweir sal_Int32 nFractions = 0; 816cdf0e10cSrcweir if ( SvXMLUnitConverter::convertTimeDuration( _rValue, aTime, &nFractions ) ) 817cdf0e10cSrcweir { 818cdf0e10cSrcweir PropertyValue aProp; 819cdf0e10cSrcweir aProp.Name = PROPERTY_REPEAT_DELAY; 820cdf0e10cSrcweir aProp.Value <<= (sal_Int32)( ( ( aTime.GetMSFromTime() / 1000 ) * 1000 ) + nFractions ); 821cdf0e10cSrcweir 822cdf0e10cSrcweir implPushBackPropertyValue(aProp); 823cdf0e10cSrcweir } 824cdf0e10cSrcweir return true; 825cdf0e10cSrcweir } 826cdf0e10cSrcweir 827cdf0e10cSrcweir return OElementImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); 828cdf0e10cSrcweir } 829cdf0e10cSrcweir 830cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)831cdf0e10cSrcweir void OControlImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 832cdf0e10cSrcweir { 833cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttributes; 834cdf0e10cSrcweir if( m_xOuterAttributes.is() ) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir // merge the attribute lists 837cdf0e10cSrcweir OAttribListMerger* pMerger = new OAttribListMerger; 838cdf0e10cSrcweir // our own one 839cdf0e10cSrcweir pMerger->addList(_rxAttrList); 840cdf0e10cSrcweir // and the ones of our enclosing element 841cdf0e10cSrcweir pMerger->addList(m_xOuterAttributes); 842cdf0e10cSrcweir xAttributes = pMerger; 843cdf0e10cSrcweir } 844cdf0e10cSrcweir else 845cdf0e10cSrcweir { 846cdf0e10cSrcweir xAttributes = _rxAttrList; 847cdf0e10cSrcweir } 848cdf0e10cSrcweir 849cdf0e10cSrcweir // let the base class handle all the attributes 850cdf0e10cSrcweir OElementImport::StartElement(xAttributes); 851cdf0e10cSrcweir 852cdf0e10cSrcweir if ( !m_aValueProperties.empty() && m_xElement.is()) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir // get the property set info 855cdf0e10cSrcweir if (!m_xInfo.is()) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir OSL_ENSURE(sal_False, "OControlImport::StartElement: no PropertySetInfo!"); 858cdf0e10cSrcweir return; 859cdf0e10cSrcweir } 860cdf0e10cSrcweir 861cdf0e10cSrcweir const sal_Char* pValueProperty = NULL; 862cdf0e10cSrcweir const sal_Char* pCurrentValueProperty = NULL; 863cdf0e10cSrcweir const sal_Char* pMinValueProperty = NULL; 864cdf0e10cSrcweir const sal_Char* pMaxValueProperty = NULL; 865cdf0e10cSrcweir 866cdf0e10cSrcweir sal_Bool bRetrievedValues = sal_False; 867cdf0e10cSrcweir sal_Bool bRetrievedValueLimits = sal_False; 868cdf0e10cSrcweir 869cdf0e10cSrcweir // get the class id of our element 870cdf0e10cSrcweir sal_Int16 nClassId = FormComponentType::CONTROL; 871cdf0e10cSrcweir m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId; 872cdf0e10cSrcweir 873cdf0e10cSrcweir // translate the value properties we collected in handleAttributes 874cdf0e10cSrcweir PropertyValueArray::iterator aEnd = m_aValueProperties.end(); 875cdf0e10cSrcweir for ( PropertyValueArray::iterator aValueProps = m_aValueProperties.begin(); 876cdf0e10cSrcweir aValueProps != aEnd; 877cdf0e10cSrcweir ++aValueProps 878cdf0e10cSrcweir ) 879cdf0e10cSrcweir { 880cdf0e10cSrcweir bool bSuccess = false; 881cdf0e10cSrcweir switch (aValueProps->Handle) 882cdf0e10cSrcweir { 883cdf0e10cSrcweir case PROPID_VALUE: 884cdf0e10cSrcweir case PROPID_CURRENT_VALUE: 885cdf0e10cSrcweir { 886cdf0e10cSrcweir // get the property names 887cdf0e10cSrcweir if (!bRetrievedValues) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir getValuePropertyNames(m_eElementType, nClassId, pCurrentValueProperty, pValueProperty); 890cdf0e10cSrcweir ENSURE_OR_BREAK( pValueProperty, "OControlImport::StartElement: illegal value property names!" ); 891cdf0e10cSrcweir bRetrievedValues = sal_True; 892cdf0e10cSrcweir } 893cdf0e10cSrcweir ENSURE_OR_BREAK((PROPID_VALUE != aValueProps->Handle) || pValueProperty, 894cdf0e10cSrcweir "OControlImport::StartElement: the control does not have a value property!"); 895cdf0e10cSrcweir ENSURE_OR_BREAK((PROPID_CURRENT_VALUE != aValueProps->Handle) || pCurrentValueProperty, 896cdf0e10cSrcweir "OControlImport::StartElement: the control does not have a current-value property!"); 897cdf0e10cSrcweir 898cdf0e10cSrcweir // transfer the name 899cdf0e10cSrcweir if (PROPID_VALUE == aValueProps->Handle) 900cdf0e10cSrcweir aValueProps->Name = ::rtl::OUString::createFromAscii(pValueProperty); 901cdf0e10cSrcweir else 902cdf0e10cSrcweir aValueProps->Name = ::rtl::OUString::createFromAscii(pCurrentValueProperty); 903cdf0e10cSrcweir bSuccess = true; 904cdf0e10cSrcweir } 905cdf0e10cSrcweir break; 906cdf0e10cSrcweir case PROPID_MIN_VALUE: 907cdf0e10cSrcweir case PROPID_MAX_VALUE: 908cdf0e10cSrcweir { 909cdf0e10cSrcweir // get the property names 910cdf0e10cSrcweir if (!bRetrievedValueLimits) 911cdf0e10cSrcweir { 912cdf0e10cSrcweir getValueLimitPropertyNames(nClassId, pMinValueProperty, pMaxValueProperty); 913cdf0e10cSrcweir ENSURE_OR_BREAK( pMinValueProperty && pMaxValueProperty, "OControlImport::StartElement: illegal value limit property names!" ); 914cdf0e10cSrcweir bRetrievedValueLimits = sal_True; 915cdf0e10cSrcweir } 916cdf0e10cSrcweir OSL_ENSURE((PROPID_MIN_VALUE != aValueProps->Handle) || pMinValueProperty, 917cdf0e10cSrcweir "OControlImport::StartElement: the control does not have a value property!"); 918cdf0e10cSrcweir OSL_ENSURE((PROPID_MAX_VALUE != aValueProps->Handle) || pMaxValueProperty, 919cdf0e10cSrcweir "OControlImport::StartElement: the control does not have a current-value property!"); 920cdf0e10cSrcweir 921cdf0e10cSrcweir // transfer the name 922cdf0e10cSrcweir if (PROPID_MIN_VALUE == aValueProps->Handle) 923cdf0e10cSrcweir aValueProps->Name = ::rtl::OUString::createFromAscii(pMinValueProperty); 924cdf0e10cSrcweir else 925cdf0e10cSrcweir aValueProps->Name = ::rtl::OUString::createFromAscii(pMaxValueProperty); 926cdf0e10cSrcweir bSuccess = true; 927cdf0e10cSrcweir } 928cdf0e10cSrcweir break; 929cdf0e10cSrcweir } 930cdf0e10cSrcweir 931cdf0e10cSrcweir if ( !bSuccess ) 932cdf0e10cSrcweir continue; 933cdf0e10cSrcweir 934cdf0e10cSrcweir // translate the value 935cdf0e10cSrcweir implTranslateValueProperty(m_xInfo, *aValueProps); 936cdf0e10cSrcweir // add the property to the base class' array 937cdf0e10cSrcweir implPushBackPropertyValue(*aValueProps); 938cdf0e10cSrcweir } 939cdf0e10cSrcweir } 940cdf0e10cSrcweir } 941cdf0e10cSrcweir 942cdf0e10cSrcweir //--------------------------------------------------------------------- implTranslateValueProperty(const Reference<XPropertySetInfo> & _rxPropInfo,PropertyValue & _rPropValue)943cdf0e10cSrcweir void OControlImport::implTranslateValueProperty(const Reference< XPropertySetInfo >& _rxPropInfo, 944cdf0e10cSrcweir PropertyValue& _rPropValue) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir OSL_ENSURE(_rxPropInfo->hasPropertyByName(_rPropValue.Name), 947cdf0e10cSrcweir "OControlImport::implTranslateValueProperty: invalid property name!"); 948cdf0e10cSrcweir 949cdf0e10cSrcweir // retrieve the type of the property 950cdf0e10cSrcweir Property aProp = _rxPropInfo->getPropertyByName(_rPropValue.Name); 951cdf0e10cSrcweir // the untranslated string value as read in handleAttribute 952cdf0e10cSrcweir ::rtl::OUString sValue; 953cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 954cdf0e10cSrcweir sal_Bool bSuccess = 955cdf0e10cSrcweir #endif 956cdf0e10cSrcweir _rPropValue.Value >>= sValue; 957cdf0e10cSrcweir OSL_ENSURE(bSuccess, "OControlImport::implTranslateValueProperty: supposed to be called with non-translated string values!"); 958cdf0e10cSrcweir 959cdf0e10cSrcweir if (TypeClass_ANY == aProp.Type.getTypeClass()) 960cdf0e10cSrcweir { 961cdf0e10cSrcweir // we have exactly 2 properties where this type class is allowed: 962cdf0e10cSrcweir OSL_ENSURE( 963cdf0e10cSrcweir (0 == _rPropValue.Name.compareToAscii(PROPERTY_EFFECTIVE_VALUE)) 964cdf0e10cSrcweir || (0 == _rPropValue.Name.compareToAscii(PROPERTY_EFFECTIVE_DEFAULT)), 965cdf0e10cSrcweir "OControlImport::implTranslateValueProperty: invalid property type/name combination!"); 966cdf0e10cSrcweir 967cdf0e10cSrcweir // Both properties are allowed to have a double or a string value, 968cdf0e10cSrcweir // so first try to convert the string into a number 969cdf0e10cSrcweir double nValue; 970cdf0e10cSrcweir if (GetImport().GetMM100UnitConverter().convertDouble(nValue, sValue)) 971cdf0e10cSrcweir _rPropValue.Value <<= nValue; 972cdf0e10cSrcweir else 973cdf0e10cSrcweir _rPropValue.Value <<= sValue; 974cdf0e10cSrcweir } 975cdf0e10cSrcweir else 976cdf0e10cSrcweir _rPropValue.Value = PropertyConversion::convertString(GetImport(), aProp.Type, sValue); 977cdf0e10cSrcweir } 978cdf0e10cSrcweir 979cdf0e10cSrcweir //--------------------------------------------------------------------- EndElement()980cdf0e10cSrcweir void OControlImport::EndElement() 981cdf0e10cSrcweir { 982cdf0e10cSrcweir OSL_ENSURE(m_xElement.is(), "OControlImport::EndElement: invalid control!"); 983cdf0e10cSrcweir if ( !m_xElement.is() ) 984cdf0e10cSrcweir return; 985cdf0e10cSrcweir 986cdf0e10cSrcweir // register our control with it's id 987cdf0e10cSrcweir if (m_sControlId.getLength()) 988cdf0e10cSrcweir m_rFormImport.registerControlId(m_xElement, m_sControlId); 989cdf0e10cSrcweir // it's allowed to have no control id. In this case we're importing a column 990cdf0e10cSrcweir 991cdf0e10cSrcweir // one more pre-work to do: 992cdf0e10cSrcweir // when we set default values, then by definition the respective value is set 993cdf0e10cSrcweir // to this default value, too. This means if the sequence contains for example 994cdf0e10cSrcweir // a DefaultText value, then the Text will be affected by this, too. 995cdf0e10cSrcweir // In case the Text is not part of the property sequence (or occurs _before_ 996cdf0e10cSrcweir // the DefaultText, which can happen for other value/default-value property names), 997cdf0e10cSrcweir // this means that the Text (the value property) is incorrectly imported. 998cdf0e10cSrcweir // #102475# - 04.09.2002 - fs@openoffice.org 999cdf0e10cSrcweir 1000cdf0e10cSrcweir sal_Bool bRestoreValuePropertyValue = sal_False; 1001cdf0e10cSrcweir Any aValuePropertyValue; 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir sal_Int16 nClassId = FormComponentType::CONTROL; 1004cdf0e10cSrcweir try 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir // get the class id of our element 1007cdf0e10cSrcweir m_xElement->getPropertyValue(PROPERTY_CLASSID) >>= nClassId; 1008cdf0e10cSrcweir } 1009cdf0e10cSrcweir catch( const Exception& ) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir OSL_ENSURE( sal_False, "OControlImport::EndElement: caught an exception while retrieving the class id!" ); 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir const sal_Char* pValueProperty = NULL; 1015cdf0e10cSrcweir const sal_Char* pDefaultValueProperty = NULL; 1016cdf0e10cSrcweir getRuntimeValuePropertyNames(m_eElementType, nClassId, pValueProperty, pDefaultValueProperty); 1017cdf0e10cSrcweir if ( pDefaultValueProperty && pValueProperty ) 1018cdf0e10cSrcweir { 1019cdf0e10cSrcweir sal_Bool bNonDefaultValuePropertyValue = sal_False; 1020cdf0e10cSrcweir // is the "value property" part of the sequence? 1021cdf0e10cSrcweir 1022cdf0e10cSrcweir // look up this property in our sequence 1023cdf0e10cSrcweir PropertyValueArray::iterator aEnd = m_aValues.end(); 1024cdf0e10cSrcweir for ( PropertyValueArray::iterator aCheck = m_aValues.begin(); 1025cdf0e10cSrcweir ( aCheck != aEnd ); 1026cdf0e10cSrcweir ++aCheck 1027cdf0e10cSrcweir ) 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir if ( aCheck->Name.equalsAscii( pDefaultValueProperty ) ) 1030cdf0e10cSrcweir bRestoreValuePropertyValue = sal_True; 1031cdf0e10cSrcweir else if ( aCheck->Name.equalsAscii( pValueProperty ) ) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir bNonDefaultValuePropertyValue = sal_True; 1034cdf0e10cSrcweir // we need to restore the value property we found here, nothing else 1035cdf0e10cSrcweir aValuePropertyValue = aCheck->Value; 1036cdf0e10cSrcweir } 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir 1039cdf0e10cSrcweir if ( bRestoreValuePropertyValue && !bNonDefaultValuePropertyValue ) 1040cdf0e10cSrcweir { 1041cdf0e10cSrcweir // found it -> need to remember (and restore) the "value property value", which is not set explicitly 1042cdf0e10cSrcweir try 1043cdf0e10cSrcweir { 1044cdf0e10cSrcweir aValuePropertyValue = m_xElement->getPropertyValue( ::rtl::OUString::createFromAscii( pValueProperty ) ); 1045cdf0e10cSrcweir } 1046cdf0e10cSrcweir catch( const Exception& ) 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir OSL_ENSURE( sal_False, "OControlImport::EndElement: caught an exception while retrieving the current value property!" ); 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir } 1051cdf0e10cSrcweir } 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir // let the base class set all the values 1054cdf0e10cSrcweir OElementImport::EndElement(); 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir // restore the "value property value", if necessary 1057cdf0e10cSrcweir if ( bRestoreValuePropertyValue && pValueProperty ) 1058cdf0e10cSrcweir { 1059cdf0e10cSrcweir try 1060cdf0e10cSrcweir { 1061cdf0e10cSrcweir m_xElement->setPropertyValue( ::rtl::OUString::createFromAscii( pValueProperty ), aValuePropertyValue ); 1062cdf0e10cSrcweir } 1063cdf0e10cSrcweir catch( const Exception& ) 1064cdf0e10cSrcweir { 1065cdf0e10cSrcweir OSL_ENSURE( sal_False, "OControlImport::EndElement: caught an exception while restoring the value property!" ); 1066cdf0e10cSrcweir } 1067cdf0e10cSrcweir } 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir // the external cell binding, if applicable 1070cdf0e10cSrcweir if ( m_xElement.is() && m_sBoundCellAddress.getLength() ) 1071cdf0e10cSrcweir doRegisterCellValueBinding( m_sBoundCellAddress ); 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir // XForms binding, if applicable 1074cdf0e10cSrcweir if ( m_xElement.is() && m_sBindingID.getLength() ) 1075cdf0e10cSrcweir doRegisterXFormsValueBinding( m_sBindingID ); 1076cdf0e10cSrcweir 1077cdf0e10cSrcweir // XForms list binding, if applicable 1078cdf0e10cSrcweir if ( m_xElement.is() && m_sListBindingID.getLength() ) 1079cdf0e10cSrcweir doRegisterXFormsListBinding( m_sListBindingID ); 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir // XForms submission, if applicable 1082cdf0e10cSrcweir if ( m_xElement.is() && m_sSubmissionID.getLength() ) 1083cdf0e10cSrcweir doRegisterXFormsSubmission( m_sSubmissionID ); 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir 1086cdf0e10cSrcweir //--------------------------------------------------------------------- doRegisterCellValueBinding(const::rtl::OUString & _rBoundCellAddress)1087cdf0e10cSrcweir void OControlImport::doRegisterCellValueBinding( const ::rtl::OUString& _rBoundCellAddress ) 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir OSL_PRECOND( m_xElement.is(), "OControlImport::doRegisterCellValueBinding: invalid element!" ); 1090cdf0e10cSrcweir OSL_PRECOND( _rBoundCellAddress.getLength(), 1091cdf0e10cSrcweir "OControlImport::doRegisterCellValueBinding: invalid address!" ); 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir m_rContext.registerCellValueBinding( m_xElement, _rBoundCellAddress ); 1094cdf0e10cSrcweir } 1095cdf0e10cSrcweir 1096cdf0e10cSrcweir //--------------------------------------------------------------------- doRegisterXFormsValueBinding(const::rtl::OUString & _rBindingID)1097cdf0e10cSrcweir void OControlImport::doRegisterXFormsValueBinding( const ::rtl::OUString& _rBindingID ) 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir OSL_PRECOND( m_xElement.is(), "need element" ); 1100cdf0e10cSrcweir OSL_PRECOND( _rBindingID.getLength() > 0, "binding ID is not valid" ); 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir m_rContext.registerXFormsValueBinding( m_xElement, _rBindingID ); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir //--------------------------------------------------------------------- doRegisterXFormsListBinding(const::rtl::OUString & _rBindingID)1106cdf0e10cSrcweir void OControlImport::doRegisterXFormsListBinding( const ::rtl::OUString& _rBindingID ) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir OSL_PRECOND( m_xElement.is(), "need element" ); 1109cdf0e10cSrcweir OSL_PRECOND( _rBindingID.getLength() > 0, "binding ID is not valid" ); 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir m_rContext.registerXFormsListBinding( m_xElement, _rBindingID ); 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir //--------------------------------------------------------------------- doRegisterXFormsSubmission(const::rtl::OUString & _rSubmissionID)1115cdf0e10cSrcweir void OControlImport::doRegisterXFormsSubmission( const ::rtl::OUString& _rSubmissionID ) 1116cdf0e10cSrcweir { 1117cdf0e10cSrcweir OSL_PRECOND( m_xElement.is(), "need element" ); 1118cdf0e10cSrcweir OSL_PRECOND( _rSubmissionID.getLength() > 0, "binding ID is not valid" ); 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir m_rContext.registerXFormsSubmission( m_xElement, _rSubmissionID ); 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir //--------------------------------------------------------------------- 1124cdf0e10cSrcweir //added by BerryJia for fixing bug102407 2002-11-5 createElement()1125cdf0e10cSrcweir Reference< XPropertySet > OControlImport::createElement() 1126cdf0e10cSrcweir { 1127cdf0e10cSrcweir const Reference<XPropertySet> xPropSet = OElementImport::createElement(); 1128cdf0e10cSrcweir if ( xPropSet.is() ) 1129cdf0e10cSrcweir { 1130cdf0e10cSrcweir m_xInfo = xPropSet->getPropertySetInfo(); 1131cdf0e10cSrcweir if ( m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_ALIGN) ) 1132cdf0e10cSrcweir { 1133cdf0e10cSrcweir Any aValue; 1134cdf0e10cSrcweir xPropSet->setPropertyValue(PROPERTY_ALIGN,aValue); 1135cdf0e10cSrcweir } 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir return xPropSet; 1138cdf0e10cSrcweir } 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir //===================================================================== 1141cdf0e10cSrcweir //= OImagePositionImport 1142cdf0e10cSrcweir //===================================================================== 1143cdf0e10cSrcweir //--------------------------------------------------------------------- OImagePositionImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1144cdf0e10cSrcweir OImagePositionImport::OImagePositionImport( OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, 1145cdf0e10cSrcweir sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, const Reference< XNameContainer >& _rxParentContainer, 1146cdf0e10cSrcweir OControlElement::ElementType _eType ) 1147cdf0e10cSrcweir :OControlImport( _rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType ) 1148cdf0e10cSrcweir ,m_nImagePosition( -1 ) 1149cdf0e10cSrcweir ,m_nImageAlign( 0 ) 1150cdf0e10cSrcweir ,m_bHaveImagePosition( sal_False ) 1151cdf0e10cSrcweir { 1152cdf0e10cSrcweir } 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1155cdf0e10cSrcweir bool OImagePositionImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, 1156cdf0e10cSrcweir const ::rtl::OUString& _rValue ) 1157cdf0e10cSrcweir { 1158cdf0e10cSrcweir if ( _rLocalName == GetXMLToken( XML_IMAGE_POSITION ) ) 1159cdf0e10cSrcweir { 1160cdf0e10cSrcweir OSL_VERIFY( PropertyConversion::convertString( 1161cdf0e10cSrcweir m_rContext.getGlobalContext(), ::getCppuType( &m_nImagePosition ), 1162cdf0e10cSrcweir _rValue, OEnumMapper::getEnumMap( OEnumMapper::epImagePosition ) 1163cdf0e10cSrcweir ) >>= m_nImagePosition ); 1164cdf0e10cSrcweir m_bHaveImagePosition = sal_True; 1165cdf0e10cSrcweir return true; 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir if ( _rLocalName == GetXMLToken( XML_IMAGE_ALIGN ) ) 1169cdf0e10cSrcweir { 1170cdf0e10cSrcweir OSL_VERIFY( PropertyConversion::convertString( 1171cdf0e10cSrcweir m_rContext.getGlobalContext(), ::getCppuType( &m_nImageAlign ), 1172cdf0e10cSrcweir _rValue, OEnumMapper::getEnumMap( OEnumMapper::epImageAlign ) 1173cdf0e10cSrcweir ) >>= m_nImageAlign ); 1174cdf0e10cSrcweir return true; 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir return OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); 1178cdf0e10cSrcweir } 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1181cdf0e10cSrcweir void OImagePositionImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir OControlImport::StartElement( _rxAttrList ); 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir if ( m_bHaveImagePosition ) 1186cdf0e10cSrcweir { 1187cdf0e10cSrcweir sal_Int16 nUnoImagePosition = ImagePosition::Centered; 1188cdf0e10cSrcweir if ( m_nImagePosition >= 0 ) 1189cdf0e10cSrcweir { 1190cdf0e10cSrcweir OSL_ENSURE( ( m_nImagePosition <= 3 ) && ( m_nImageAlign >= 0 ) && ( m_nImageAlign < 3 ), 1191cdf0e10cSrcweir "OImagePositionImport::StartElement: unknown image align and/or position!" ); 1192cdf0e10cSrcweir nUnoImagePosition = m_nImagePosition * 3 + m_nImageAlign; 1193cdf0e10cSrcweir } 1194cdf0e10cSrcweir 1195cdf0e10cSrcweir PropertyValue aImagePosition; 1196cdf0e10cSrcweir aImagePosition.Name = PROPERTY_IMAGE_POSITION; 1197cdf0e10cSrcweir aImagePosition.Value <<= nUnoImagePosition; 1198cdf0e10cSrcweir implPushBackPropertyValue( aImagePosition ); 1199cdf0e10cSrcweir } 1200cdf0e10cSrcweir } 1201cdf0e10cSrcweir 1202cdf0e10cSrcweir //===================================================================== 1203cdf0e10cSrcweir //= OReferredControlImport 1204cdf0e10cSrcweir //===================================================================== 1205cdf0e10cSrcweir //--------------------------------------------------------------------- OReferredControlImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType)1206cdf0e10cSrcweir OReferredControlImport::OReferredControlImport( 1207cdf0e10cSrcweir OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1208cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, 1209cdf0e10cSrcweir OControlElement::ElementType ) 1210cdf0e10cSrcweir :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer) 1211cdf0e10cSrcweir { 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir 1214cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1215cdf0e10cSrcweir void OReferredControlImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1216cdf0e10cSrcweir { 1217cdf0e10cSrcweir OControlImport::StartElement(_rxAttrList); 1218cdf0e10cSrcweir 1219cdf0e10cSrcweir // the base class should have created the control, so we can register it 1220cdf0e10cSrcweir if ( m_sReferringControls.getLength() ) 1221cdf0e10cSrcweir m_rFormImport.registerControlReferences(m_xElement, m_sReferringControls); 1222cdf0e10cSrcweir } 1223cdf0e10cSrcweir 1224cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1225cdf0e10cSrcweir bool OReferredControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, 1226cdf0e10cSrcweir const ::rtl::OUString& _rValue) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir static const ::rtl::OUString s_sReferenceAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_FOR)); 1229cdf0e10cSrcweir if (_rLocalName == s_sReferenceAttributeName) 1230cdf0e10cSrcweir { 1231cdf0e10cSrcweir m_sReferringControls = _rValue; 1232cdf0e10cSrcweir return true; 1233cdf0e10cSrcweir } 1234cdf0e10cSrcweir return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); 1235cdf0e10cSrcweir } 1236cdf0e10cSrcweir 1237cdf0e10cSrcweir //===================================================================== 1238cdf0e10cSrcweir //= OPasswordImport 1239cdf0e10cSrcweir //===================================================================== 1240cdf0e10cSrcweir //--------------------------------------------------------------------- OPasswordImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1241cdf0e10cSrcweir OPasswordImport::OPasswordImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1242cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType) 1243cdf0e10cSrcweir :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType) 1244cdf0e10cSrcweir { 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1248cdf0e10cSrcweir bool OPasswordImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 1249cdf0e10cSrcweir { 1250cdf0e10cSrcweir static const ::rtl::OUString s_sEchoCharAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR)); 1251cdf0e10cSrcweir if (_rLocalName == s_sEchoCharAttributeName) 1252cdf0e10cSrcweir { 1253cdf0e10cSrcweir // need a special handling for the EchoChar property 1254cdf0e10cSrcweir PropertyValue aEchoChar; 1255cdf0e10cSrcweir aEchoChar.Name = PROPERTY_ECHOCHAR; 1256cdf0e10cSrcweir OSL_ENSURE(_rValue.getLength() == 1, "OPasswordImport::handleAttribute: invalid echo char attribute!"); 1257cdf0e10cSrcweir // we ourself should not have written values other than of length 1 1258cdf0e10cSrcweir if (_rValue.getLength() >= 1) 1259cdf0e10cSrcweir aEchoChar.Value <<= (sal_Int16)_rValue.getStr()[0]; 1260cdf0e10cSrcweir else 1261cdf0e10cSrcweir aEchoChar.Value <<= (sal_Int16)0; 1262cdf0e10cSrcweir implPushBackPropertyValue(aEchoChar); 1263cdf0e10cSrcweir return true; 1264cdf0e10cSrcweir } 1265cdf0e10cSrcweir return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); 1266cdf0e10cSrcweir } 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir //===================================================================== 1269cdf0e10cSrcweir //= ORadioImport 1270cdf0e10cSrcweir //===================================================================== 1271cdf0e10cSrcweir //--------------------------------------------------------------------- ORadioImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1272cdf0e10cSrcweir ORadioImport::ORadioImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1273cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType) 1274cdf0e10cSrcweir :OImagePositionImport( _rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType ) 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir } 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1279cdf0e10cSrcweir bool ORadioImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir // need special handling for the State & CurrentState properties: 1282cdf0e10cSrcweir // they're stored as booleans, but expected to be int16 properties 1283cdf0e10cSrcweir static const sal_Char* pCurrentSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED); 1284cdf0e10cSrcweir static const sal_Char* pSelectedAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED); 1285cdf0e10cSrcweir if ( _rLocalName.equalsAscii( pCurrentSelectedAttributeName ) 1286cdf0e10cSrcweir || _rLocalName.equalsAscii( pSelectedAttributeName ) 1287cdf0e10cSrcweir ) 1288cdf0e10cSrcweir { 1289cdf0e10cSrcweir const OAttribute2Property::AttributeAssignment* pProperty = m_rContext.getAttributeMap().getAttributeTranslation(_rLocalName); 1290cdf0e10cSrcweir OSL_ENSURE(pProperty, "ORadioImport::handleAttribute: invalid property map!"); 1291cdf0e10cSrcweir if (pProperty) 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir const Any aBooleanValue( PropertyConversion::convertString(m_rContext.getGlobalContext(), pProperty->aPropertyType, _rValue, pProperty->pEnumMap) ); 1294cdf0e10cSrcweir 1295cdf0e10cSrcweir // create and store a new PropertyValue 1296cdf0e10cSrcweir PropertyValue aNewValue; 1297cdf0e10cSrcweir aNewValue.Name = pProperty->sPropertyName; 1298cdf0e10cSrcweir aNewValue.Value <<= (sal_Int16)::cppu::any2bool(aBooleanValue); 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir implPushBackPropertyValue(aNewValue); 1301cdf0e10cSrcweir } 1302cdf0e10cSrcweir return true; 1303cdf0e10cSrcweir } 1304cdf0e10cSrcweir return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); 1305cdf0e10cSrcweir } 1306cdf0e10cSrcweir 1307cdf0e10cSrcweir //===================================================================== 1308cdf0e10cSrcweir //= OURLReferenceImport 1309cdf0e10cSrcweir //===================================================================== OURLReferenceImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1310cdf0e10cSrcweir OURLReferenceImport::OURLReferenceImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1311cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, 1312cdf0e10cSrcweir OControlElement::ElementType _eType) 1313cdf0e10cSrcweir :OImagePositionImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType) 1314cdf0e10cSrcweir { 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1318cdf0e10cSrcweir bool OURLReferenceImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 1319cdf0e10cSrcweir { 1320cdf0e10cSrcweir static const sal_Char* s_pTargetLocationAttributeName = OAttributeMetaData::getCommonControlAttributeName( CCA_TARGET_LOCATION ); 1321cdf0e10cSrcweir static const sal_Char* s_pImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeName( CCA_IMAGE_DATA ); 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir // need to make the URL absolute if 1324cdf0e10cSrcweir // * it's the image-data attribute 1325cdf0e10cSrcweir // * it's the target-location attribute, and we're dealign with an object which has the respective property 1326cdf0e10cSrcweir sal_Bool bMakeAbsolute = 1327cdf0e10cSrcweir ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) ) 1328cdf0e10cSrcweir || ( ( 0 == _rLocalName.compareToAscii( s_pTargetLocationAttributeName ) ) 1329cdf0e10cSrcweir && ( ( OControlElement::BUTTON == m_eElementType ) 1330cdf0e10cSrcweir || ( OControlElement::IMAGE == m_eElementType ) 1331cdf0e10cSrcweir ) 1332cdf0e10cSrcweir ); 1333cdf0e10cSrcweir 1334cdf0e10cSrcweir if ( bMakeAbsolute && ( _rValue.getLength() > 0 ) ) 1335cdf0e10cSrcweir { 1336cdf0e10cSrcweir // make a global URL out of the local one 1337cdf0e10cSrcweir ::rtl::OUString sAdjustedValue; 1338cdf0e10cSrcweir // only resolve image related url 1339cdf0e10cSrcweir // we don't want say form url targets to be resolved 1340cdf0e10cSrcweir // using ResolveGraphicObjectURL 1341cdf0e10cSrcweir if ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) ) 1342cdf0e10cSrcweir sAdjustedValue = m_rContext.getGlobalContext().ResolveGraphicObjectURL( _rValue, sal_False ); 1343cdf0e10cSrcweir else 1344cdf0e10cSrcweir sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue ); 1345cdf0e10cSrcweir return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, sAdjustedValue ); 1346cdf0e10cSrcweir } 1347cdf0e10cSrcweir 1348cdf0e10cSrcweir return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); 1349cdf0e10cSrcweir } 1350cdf0e10cSrcweir 1351cdf0e10cSrcweir //===================================================================== 1352cdf0e10cSrcweir //= OButtonImport 1353cdf0e10cSrcweir //===================================================================== 1354cdf0e10cSrcweir //--------------------------------------------------------------------- OButtonImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1355cdf0e10cSrcweir OButtonImport::OButtonImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1356cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, 1357cdf0e10cSrcweir OControlElement::ElementType _eType) 1358cdf0e10cSrcweir :OURLReferenceImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType) 1359cdf0e10cSrcweir { 1360cdf0e10cSrcweir enableTrackAttributes(); 1361cdf0e10cSrcweir } 1362cdf0e10cSrcweir 1363cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1364cdf0e10cSrcweir void OButtonImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1365cdf0e10cSrcweir { 1366cdf0e10cSrcweir OURLReferenceImport::StartElement(_rxAttrList); 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir // handle the target-frame attribute 1369cdf0e10cSrcweir simulateDefaultedAttribute(OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME), PROPERTY_TARGETFRAME, "_blank"); 1370cdf0e10cSrcweir } 1371cdf0e10cSrcweir 1372cdf0e10cSrcweir //===================================================================== 1373cdf0e10cSrcweir //= OValueRangeImport 1374cdf0e10cSrcweir //===================================================================== 1375cdf0e10cSrcweir //--------------------------------------------------------------------- OValueRangeImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1376cdf0e10cSrcweir OValueRangeImport::OValueRangeImport( OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1377cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType ) 1378cdf0e10cSrcweir :OControlImport( _rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType ) 1379cdf0e10cSrcweir ,m_nStepSizeValue( 1 ) 1380cdf0e10cSrcweir { 1381cdf0e10cSrcweir 1382cdf0e10cSrcweir } 1383cdf0e10cSrcweir 1384cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1385cdf0e10cSrcweir bool OValueRangeImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ) 1386cdf0e10cSrcweir { 1387cdf0e10cSrcweir if ( _rLocalName.equalsAscii( OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ) ) ) 1388cdf0e10cSrcweir { 1389cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertNumber( m_nStepSizeValue, _rValue ); 1390cdf0e10cSrcweir return true; 1391cdf0e10cSrcweir } 1392cdf0e10cSrcweir return OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); 1393cdf0e10cSrcweir } 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1396cdf0e10cSrcweir void OValueRangeImport::StartElement( const Reference< sax::XAttributeList >& _rxAttrList ) 1397cdf0e10cSrcweir { 1398cdf0e10cSrcweir OControlImport::StartElement( _rxAttrList ); 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir if ( m_xInfo.is() ) 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir if ( m_xInfo->hasPropertyByName( PROPERTY_SPIN_INCREMENT ) ) 1403cdf0e10cSrcweir m_xElement->setPropertyValue( PROPERTY_SPIN_INCREMENT, makeAny( m_nStepSizeValue ) ); 1404cdf0e10cSrcweir else if ( m_xInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) ) 1405cdf0e10cSrcweir m_xElement->setPropertyValue( PROPERTY_LINE_INCREMENT, makeAny( m_nStepSizeValue ) ); 1406cdf0e10cSrcweir } 1407cdf0e10cSrcweir } 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir //===================================================================== 1410cdf0e10cSrcweir //= OTextLikeImport 1411cdf0e10cSrcweir //===================================================================== 1412cdf0e10cSrcweir //--------------------------------------------------------------------- OTextLikeImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1413cdf0e10cSrcweir OTextLikeImport::OTextLikeImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1414cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, 1415cdf0e10cSrcweir OControlElement::ElementType _eType) 1416cdf0e10cSrcweir :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType) 1417cdf0e10cSrcweir ,m_bEncounteredTextPara( false ) 1418cdf0e10cSrcweir { 1419cdf0e10cSrcweir enableTrackAttributes(); 1420cdf0e10cSrcweir } 1421cdf0e10cSrcweir 1422cdf0e10cSrcweir //--------------------------------------------------------------------- CreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,const Reference<sax::XAttributeList> & _rxAttrList)1423cdf0e10cSrcweir SvXMLImportContext* OTextLikeImport::CreateChildContext( sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 1424cdf0e10cSrcweir const Reference< sax::XAttributeList >& _rxAttrList ) 1425cdf0e10cSrcweir { 1426cdf0e10cSrcweir if ( ( XML_NAMESPACE_TEXT == _nPrefix ) && _rLocalName.equalsIgnoreAsciiCaseAscii( "p" ) ) 1427cdf0e10cSrcweir { 1428cdf0e10cSrcweir OSL_ENSURE( m_eElementType == OControlElement::TEXT_AREA, 1429cdf0e10cSrcweir "OTextLikeImport::CreateChildContext: text paragraphs in a non-text-area?" ); 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir if ( m_eElementType == OControlElement::TEXT_AREA ) 1432cdf0e10cSrcweir { 1433cdf0e10cSrcweir Reference< XText > xTextElement( m_xElement, UNO_QUERY ); 1434cdf0e10cSrcweir if ( xTextElement.is() ) 1435cdf0e10cSrcweir { 1436cdf0e10cSrcweir UniReference < XMLTextImportHelper > xTextImportHelper( m_rContext.getGlobalContext().GetTextImport() ); 1437cdf0e10cSrcweir 1438cdf0e10cSrcweir if ( !m_xCursor.is() ) 1439cdf0e10cSrcweir { 1440cdf0e10cSrcweir m_xOldCursor = xTextImportHelper->GetCursor(); 1441cdf0e10cSrcweir m_xCursor = xTextElement->createTextCursor(); 1442cdf0e10cSrcweir 1443cdf0e10cSrcweir if ( m_xCursor.is() ) 1444cdf0e10cSrcweir xTextImportHelper->SetCursor( m_xCursor ); 1445cdf0e10cSrcweir } 1446cdf0e10cSrcweir if ( m_xCursor.is() ) 1447cdf0e10cSrcweir { 1448cdf0e10cSrcweir m_bEncounteredTextPara = true; 1449cdf0e10cSrcweir return xTextImportHelper->CreateTextChildContext( m_rContext.getGlobalContext(), _nPrefix, _rLocalName, _rxAttrList ); 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir else 1453cdf0e10cSrcweir { 1454cdf0e10cSrcweir // in theory, we could accumulate all the text portions (without formatting), 1455cdf0e10cSrcweir // and set it as Text property at the model ... 1456cdf0e10cSrcweir } 1457cdf0e10cSrcweir } 1458cdf0e10cSrcweir } 1459cdf0e10cSrcweir 1460cdf0e10cSrcweir return OControlImport::CreateChildContext( _nPrefix, _rLocalName, _rxAttrList ); 1461cdf0e10cSrcweir } 1462cdf0e10cSrcweir 1463cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1464cdf0e10cSrcweir void OTextLikeImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1465cdf0e10cSrcweir { 1466cdf0e10cSrcweir OControlImport::StartElement(_rxAttrList); 1467cdf0e10cSrcweir 1468cdf0e10cSrcweir // handle the convert-empty-to-null attribute, whose default is different from the property default 1469cdf0e10cSrcweir // unfortunately, different classes are imported by this class ('cause they're represented by the 1470cdf0e10cSrcweir // same XML element), though not all of them know this property. 1471cdf0e10cSrcweir // So we have to do a check ... 1472cdf0e10cSrcweir if (m_xElement.is() && m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_EMPTY_IS_NULL) ) 1473cdf0e10cSrcweir simulateDefaultedAttribute(OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY), PROPERTY_EMPTY_IS_NULL, "false"); 1474cdf0e10cSrcweir } 1475cdf0e10cSrcweir 1476cdf0e10cSrcweir //--------------------------------------------------------------------- 1477cdf0e10cSrcweir struct EqualHandle : public ::std::unary_function< PropertyValue, bool > 1478cdf0e10cSrcweir { 1479cdf0e10cSrcweir const sal_Int32 m_nHandle; EqualHandlexmloff::EqualHandle1480cdf0e10cSrcweir EqualHandle( sal_Int32 _nHandle ) : m_nHandle( _nHandle ) { } 1481cdf0e10cSrcweir operator ()xmloff::EqualHandle1482cdf0e10cSrcweir inline bool operator()( const PropertyValue& _rProp ) 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir return _rProp.Handle == m_nHandle; 1485cdf0e10cSrcweir } 1486cdf0e10cSrcweir }; 1487cdf0e10cSrcweir 1488cdf0e10cSrcweir //--------------------------------------------------------------------- removeRedundantCurrentValue()1489cdf0e10cSrcweir void OTextLikeImport::removeRedundantCurrentValue() 1490cdf0e10cSrcweir { 1491cdf0e10cSrcweir if ( m_bEncounteredTextPara ) 1492cdf0e10cSrcweir { 1493cdf0e10cSrcweir // In case the text is written in the text:p elements, we need to ignore what we read as 1494cdf0e10cSrcweir // current-value attribute, since it's redundant. 1495cdf0e10cSrcweir // fortunately, OElementImport tagged the value property with the PROPID_CURRENT_VALUE 1496cdf0e10cSrcweir // handle, so we do not need to determine the name of our value property here 1497cdf0e10cSrcweir // (normally, it should be "Text", since no other controls than the edit field should 1498cdf0e10cSrcweir // have the text:p elements) 1499cdf0e10cSrcweir PropertyValueArray::iterator aValuePropertyPos = ::std::find_if( 1500cdf0e10cSrcweir m_aValues.begin(), 1501cdf0e10cSrcweir m_aValues.end(), 1502cdf0e10cSrcweir EqualHandle( PROPID_CURRENT_VALUE ) 1503cdf0e10cSrcweir ); 1504cdf0e10cSrcweir if ( aValuePropertyPos != m_aValues.end() ) 1505cdf0e10cSrcweir { 1506cdf0e10cSrcweir OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" ); 1507cdf0e10cSrcweir if ( aValuePropertyPos->Name == PROPERTY_TEXT ) 1508cdf0e10cSrcweir { 1509cdf0e10cSrcweir ::std::copy( 1510cdf0e10cSrcweir aValuePropertyPos + 1, 1511cdf0e10cSrcweir m_aValues.end(), 1512cdf0e10cSrcweir aValuePropertyPos 1513cdf0e10cSrcweir ); 1514cdf0e10cSrcweir m_aValues.resize( m_aValues.size() - 1 ); 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir // additionally, we need to set the "RichText" property of our element to sal_True 1519cdf0e10cSrcweir // (the presence of the text:p is used as indicator for the value of the RichText property) 1520cdf0e10cSrcweir sal_Bool bHasRichTextProperty = sal_False; 1521cdf0e10cSrcweir if ( m_xInfo.is() ) 1522cdf0e10cSrcweir bHasRichTextProperty = m_xInfo->hasPropertyByName( PROPERTY_RICH_TEXT ); 1523cdf0e10cSrcweir OSL_ENSURE( bHasRichTextProperty, "OTextLikeImport::EndElement: text:p, but no rich text control?" ); 1524cdf0e10cSrcweir if ( bHasRichTextProperty ) 1525cdf0e10cSrcweir m_xElement->setPropertyValue( PROPERTY_RICH_TEXT, makeAny( (sal_Bool)sal_True ) ); 1526cdf0e10cSrcweir } 1527cdf0e10cSrcweir // Note that we do *not* set the RichText property (in case our element has one) to sal_False here 1528cdf0e10cSrcweir // since this is the default of this property, anyway. 1529cdf0e10cSrcweir } 1530cdf0e10cSrcweir 1531cdf0e10cSrcweir //--------------------------------------------------------------------- 1532cdf0e10cSrcweir struct EqualName : public ::std::unary_function< PropertyValue, bool > 1533cdf0e10cSrcweir { 1534cdf0e10cSrcweir const ::rtl::OUString m_sName; EqualNamexmloff::EqualName1535cdf0e10cSrcweir EqualName( const ::rtl::OUString& _rName ) : m_sName( _rName ) { } 1536cdf0e10cSrcweir operator ()xmloff::EqualName1537cdf0e10cSrcweir inline bool operator()( const PropertyValue& _rProp ) 1538cdf0e10cSrcweir { 1539cdf0e10cSrcweir return _rProp.Name == m_sName; 1540cdf0e10cSrcweir } 1541cdf0e10cSrcweir }; 1542cdf0e10cSrcweir 1543cdf0e10cSrcweir //--------------------------------------------------------------------- adjustDefaultControlProperty()1544cdf0e10cSrcweir void OTextLikeImport::adjustDefaultControlProperty() 1545cdf0e10cSrcweir { 1546cdf0e10cSrcweir // In OpenOffice.org 2.0, we changed the implementation of the css.form.component.TextField (the model of a text field control), 1547cdf0e10cSrcweir // so that it now uses another default control. So if we encounter a text field where the *old* default 1548cdf0e10cSrcweir // control property is writting, we are not allowed to use it 1549cdf0e10cSrcweir PropertyValueArray::iterator aDefaultControlPropertyPos = ::std::find_if( 1550cdf0e10cSrcweir m_aValues.begin(), 1551cdf0e10cSrcweir m_aValues.end(), 1552cdf0e10cSrcweir EqualName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultControl" ) ) ) 1553cdf0e10cSrcweir ); 1554cdf0e10cSrcweir if ( aDefaultControlPropertyPos != m_aValues.end() ) 1555cdf0e10cSrcweir { 1556cdf0e10cSrcweir ::rtl::OUString sDefaultControl; 1557cdf0e10cSrcweir OSL_VERIFY( aDefaultControlPropertyPos->Value >>= sDefaultControl ); 1558cdf0e10cSrcweir if ( sDefaultControl.equalsAscii( "stardiv.one.form.control.Edit" ) ) 1559cdf0e10cSrcweir { 1560cdf0e10cSrcweir // complete remove this property value from the array. Today's "default value" of the "DefaultControl" 1561cdf0e10cSrcweir // property is sufficient 1562cdf0e10cSrcweir ::std::copy( 1563cdf0e10cSrcweir aDefaultControlPropertyPos + 1, 1564cdf0e10cSrcweir m_aValues.end(), 1565cdf0e10cSrcweir aDefaultControlPropertyPos 1566cdf0e10cSrcweir ); 1567cdf0e10cSrcweir m_aValues.resize( m_aValues.size() - 1 ); 1568cdf0e10cSrcweir } 1569cdf0e10cSrcweir } 1570cdf0e10cSrcweir } 1571cdf0e10cSrcweir 1572cdf0e10cSrcweir //--------------------------------------------------------------------- EndElement()1573cdf0e10cSrcweir void OTextLikeImport::EndElement() 1574cdf0e10cSrcweir { 1575cdf0e10cSrcweir removeRedundantCurrentValue(); 1576cdf0e10cSrcweir adjustDefaultControlProperty(); 1577cdf0e10cSrcweir 1578cdf0e10cSrcweir // let the base class do the stuff 1579cdf0e10cSrcweir OControlImport::EndElement(); 1580cdf0e10cSrcweir 1581cdf0e10cSrcweir // some cleanups 1582cdf0e10cSrcweir UniReference < XMLTextImportHelper > xTextImportHelper( m_rContext.getGlobalContext().GetTextImport() ); 1583cdf0e10cSrcweir if ( m_xCursor.is() ) 1584cdf0e10cSrcweir { 1585cdf0e10cSrcweir // delete the newline which has been imported errornously 1586cdf0e10cSrcweir // TODO (fs): stole this code somewhere - why don't we fix the text import?? 1587cdf0e10cSrcweir m_xCursor->gotoEnd( sal_False ); 1588cdf0e10cSrcweir m_xCursor->goLeft( 1, sal_True ); 1589cdf0e10cSrcweir m_xCursor->setString( ::rtl::OUString() ); 1590cdf0e10cSrcweir 1591cdf0e10cSrcweir // reset cursor 1592cdf0e10cSrcweir xTextImportHelper->ResetCursor(); 1593cdf0e10cSrcweir } 1594cdf0e10cSrcweir 1595cdf0e10cSrcweir if ( m_xOldCursor.is() ) 1596cdf0e10cSrcweir xTextImportHelper->SetCursor( m_xOldCursor ); 1597cdf0e10cSrcweir 1598cdf0e10cSrcweir } 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir //===================================================================== 1601cdf0e10cSrcweir //= OListAndComboImport 1602cdf0e10cSrcweir //===================================================================== 1603cdf0e10cSrcweir //--------------------------------------------------------------------- OListAndComboImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1604cdf0e10cSrcweir OListAndComboImport::OListAndComboImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1605cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, 1606cdf0e10cSrcweir OControlElement::ElementType _eType) 1607cdf0e10cSrcweir :OControlImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType) 1608cdf0e10cSrcweir ,m_nEmptyListItems( 0 ) 1609cdf0e10cSrcweir ,m_nEmptyValueItems( 0 ) 1610cdf0e10cSrcweir ,m_bEncounteredLSAttrib( sal_False ) 1611cdf0e10cSrcweir ,m_bLinkWithIndexes( sal_False ) 1612cdf0e10cSrcweir { 1613cdf0e10cSrcweir if (OControlElement::COMBOBOX == m_eElementType) 1614cdf0e10cSrcweir enableTrackAttributes(); 1615cdf0e10cSrcweir } 1616cdf0e10cSrcweir 1617cdf0e10cSrcweir //--------------------------------------------------------------------- CreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,const Reference<sax::XAttributeList> & _rxAttrList)1618cdf0e10cSrcweir SvXMLImportContext* OListAndComboImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 1619cdf0e10cSrcweir const Reference< sax::XAttributeList >& _rxAttrList) 1620cdf0e10cSrcweir { 1621cdf0e10cSrcweir // is it the "option" sub tag of a listbox ? 1622cdf0e10cSrcweir static const ::rtl::OUString s_sOptionElementName = ::rtl::OUString::createFromAscii("option"); 1623cdf0e10cSrcweir if (s_sOptionElementName == _rLocalName) 1624cdf0e10cSrcweir return new OListOptionImport(GetImport(), _nPrefix, _rLocalName, this); 1625cdf0e10cSrcweir 1626cdf0e10cSrcweir // is it the "item" sub tag of a combobox ? 1627cdf0e10cSrcweir static const ::rtl::OUString s_sItemElementName = ::rtl::OUString::createFromAscii("item"); 1628cdf0e10cSrcweir if (s_sItemElementName == _rLocalName) 1629cdf0e10cSrcweir return new OComboItemImport(GetImport(), _nPrefix, _rLocalName, this); 1630cdf0e10cSrcweir 1631cdf0e10cSrcweir // everything else 1632cdf0e10cSrcweir return OControlImport::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList); 1633cdf0e10cSrcweir } 1634cdf0e10cSrcweir 1635cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1636cdf0e10cSrcweir void OListAndComboImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1637cdf0e10cSrcweir { 1638cdf0e10cSrcweir m_bLinkWithIndexes = sal_False; 1639cdf0e10cSrcweir 1640cdf0e10cSrcweir OControlImport::StartElement(_rxAttrList); 1641cdf0e10cSrcweir 1642cdf0e10cSrcweir if (OControlElement::COMBOBOX == m_eElementType) 1643cdf0e10cSrcweir { 1644cdf0e10cSrcweir // for the auto-completion 1645cdf0e10cSrcweir // the attribute default does not equal the property default, so in case we did not read this attribute, 1646cdf0e10cSrcweir // we have to simulate it 1647cdf0e10cSrcweir simulateDefaultedAttribute( OAttributeMetaData::getSpecialAttributeName( SCA_AUTOMATIC_COMPLETION ), PROPERTY_AUTOCOMPLETE, "false"); 1648cdf0e10cSrcweir 1649cdf0e10cSrcweir // same for the convert-empty-to-null attribute, which's default is different from the property default 1650cdf0e10cSrcweir simulateDefaultedAttribute( OAttributeMetaData::getDatabaseAttributeName( DA_CONVERT_EMPTY ), PROPERTY_EMPTY_IS_NULL, "false"); 1651cdf0e10cSrcweir } 1652cdf0e10cSrcweir } 1653cdf0e10cSrcweir 1654cdf0e10cSrcweir //--------------------------------------------------------------------- EndElement()1655cdf0e10cSrcweir void OListAndComboImport::EndElement() 1656cdf0e10cSrcweir { 1657*fb0b81f5Smseidel // append the list source property to the properties sequence of our importer 1658cdf0e10cSrcweir // the string item list 1659cdf0e10cSrcweir PropertyValue aItemList; 1660cdf0e10cSrcweir aItemList.Name = PROPERTY_STRING_ITEM_LIST; 1661cdf0e10cSrcweir aItemList.Value <<= m_aListSource; 1662cdf0e10cSrcweir implPushBackPropertyValue(aItemList); 1663cdf0e10cSrcweir 1664cdf0e10cSrcweir if (OControlElement::LISTBOX == m_eElementType) 1665cdf0e10cSrcweir { 1666cdf0e10cSrcweir OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems), 1667cdf0e10cSrcweir "OListAndComboImport::EndElement: inconsistence between labels and values!"); 1668cdf0e10cSrcweir 1669cdf0e10cSrcweir if ( !m_bEncounteredLSAttrib ) 1670cdf0e10cSrcweir { 1671cdf0e10cSrcweir // the value sequence 1672cdf0e10cSrcweir PropertyValue aValueList; 1673cdf0e10cSrcweir aValueList.Name = PROPERTY_LISTSOURCE; 1674cdf0e10cSrcweir aValueList.Value <<= m_aValueList; 1675cdf0e10cSrcweir implPushBackPropertyValue(aValueList); 1676cdf0e10cSrcweir } 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir // the select sequence 1679cdf0e10cSrcweir PropertyValue aSelected; 1680cdf0e10cSrcweir aSelected.Name = PROPERTY_SELECT_SEQ; 1681cdf0e10cSrcweir aSelected.Value <<= m_aSelectedSeq; 1682cdf0e10cSrcweir implPushBackPropertyValue(aSelected); 1683cdf0e10cSrcweir 1684cdf0e10cSrcweir // the default select sequence 1685cdf0e10cSrcweir PropertyValue aDefaultSelected; 1686cdf0e10cSrcweir aDefaultSelected.Name = PROPERTY_DEFAULT_SELECT_SEQ; 1687cdf0e10cSrcweir aDefaultSelected.Value <<= m_aDefaultSelectedSeq; 1688cdf0e10cSrcweir implPushBackPropertyValue(aDefaultSelected); 1689cdf0e10cSrcweir } 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir OControlImport::EndElement(); 1692cdf0e10cSrcweir 1693cdf0e10cSrcweir // the external list source, if applicable 1694cdf0e10cSrcweir if ( m_xElement.is() && m_sCellListSource.getLength() ) 1695cdf0e10cSrcweir m_rContext.registerCellRangeListSource( m_xElement, m_sCellListSource ); 1696cdf0e10cSrcweir } 1697cdf0e10cSrcweir 1698cdf0e10cSrcweir //--------------------------------------------------------------------- doRegisterCellValueBinding(const::rtl::OUString & _rBoundCellAddress)1699cdf0e10cSrcweir void OListAndComboImport::doRegisterCellValueBinding( const ::rtl::OUString& _rBoundCellAddress ) 1700cdf0e10cSrcweir { 1701cdf0e10cSrcweir ::rtl::OUString sBoundCellAddress( _rBoundCellAddress ); 1702cdf0e10cSrcweir if ( m_bLinkWithIndexes ) 1703cdf0e10cSrcweir { 1704cdf0e10cSrcweir // This is a HACK. We register a string which is no valid address, but allows 1705cdf0e10cSrcweir // (somewhere else) to determine that a non-standard binding should be created. 1706cdf0e10cSrcweir // This hack is acceptable for OOo 1.1.1, since the file format for value 1707cdf0e10cSrcweir // bindings of form controls is to be changed afterwards, anyway. 1708cdf0e10cSrcweir sBoundCellAddress += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":index" ) ); 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir 1711cdf0e10cSrcweir OControlImport::doRegisterCellValueBinding( sBoundCellAddress ); 1712cdf0e10cSrcweir } 1713cdf0e10cSrcweir 1714cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)1715cdf0e10cSrcweir bool OListAndComboImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 1716cdf0e10cSrcweir { 1717cdf0e10cSrcweir static const sal_Char* pListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE); 1718cdf0e10cSrcweir if ( _rLocalName.equalsAscii(pListSourceAttributeName) ) 1719cdf0e10cSrcweir { 1720cdf0e10cSrcweir PropertyValue aListSource; 1721cdf0e10cSrcweir aListSource.Name = PROPERTY_LISTSOURCE; 1722cdf0e10cSrcweir 1723cdf0e10cSrcweir // it's the ListSource attribute 1724cdf0e10cSrcweir m_bEncounteredLSAttrib = sal_True; 1725cdf0e10cSrcweir if ( OControlElement::COMBOBOX == m_eElementType ) 1726cdf0e10cSrcweir { 1727cdf0e10cSrcweir aListSource.Value <<= _rValue; 1728cdf0e10cSrcweir } 1729cdf0e10cSrcweir else 1730cdf0e10cSrcweir { 1731cdf0e10cSrcweir // a listbox which has a list-source attribute must have a list-source-type of something 1732cdf0e10cSrcweir // not equal to ValueList. 1733cdf0e10cSrcweir // In this case, the list-source value is simply the one and only element of the ListSource property. 1734cdf0e10cSrcweir Sequence< ::rtl::OUString > aListSourcePropValue( 1 ); 1735cdf0e10cSrcweir aListSourcePropValue[0] = _rValue; 1736cdf0e10cSrcweir aListSource.Value <<= aListSourcePropValue; 1737cdf0e10cSrcweir } 1738cdf0e10cSrcweir 1739cdf0e10cSrcweir implPushBackPropertyValue( aListSource ); 1740cdf0e10cSrcweir return true; 1741cdf0e10cSrcweir } 1742cdf0e10cSrcweir 1743cdf0e10cSrcweir if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ) ) ) 1744cdf0e10cSrcweir { 1745cdf0e10cSrcweir m_sCellListSource = _rValue; 1746cdf0e10cSrcweir return true; 1747cdf0e10cSrcweir } 1748cdf0e10cSrcweir 1749cdf0e10cSrcweir if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ) ) ) 1750cdf0e10cSrcweir { 1751cdf0e10cSrcweir sal_Int16 nLinkageType = 0; 1752cdf0e10cSrcweir PropertyConversion::convertString( 1753cdf0e10cSrcweir m_rContext.getGlobalContext(), 1754cdf0e10cSrcweir ::getCppuType( static_cast< sal_Int16* >( NULL ) ), 1755cdf0e10cSrcweir _rValue, 1756cdf0e10cSrcweir OEnumMapper::getEnumMap( OEnumMapper::epListLinkageType ) 1757cdf0e10cSrcweir ) >>= nLinkageType; 1758cdf0e10cSrcweir 1759cdf0e10cSrcweir m_bLinkWithIndexes = ( nLinkageType != 0 ); 1760cdf0e10cSrcweir return true; 1761cdf0e10cSrcweir } 1762cdf0e10cSrcweir 1763cdf0e10cSrcweir return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); 1764cdf0e10cSrcweir } 1765cdf0e10cSrcweir 1766cdf0e10cSrcweir //--------------------------------------------------------------------- implPushBackLabel(const::rtl::OUString & _rLabel)1767cdf0e10cSrcweir void OListAndComboImport::implPushBackLabel(const ::rtl::OUString& _rLabel) 1768cdf0e10cSrcweir { 1769cdf0e10cSrcweir OSL_ENSURE(!m_nEmptyListItems, "OListAndComboImport::implPushBackValue: label list is already done!"); 1770cdf0e10cSrcweir if (!m_nEmptyListItems) 1771cdf0e10cSrcweir pushBackSequenceElement(m_aListSource, _rLabel); 1772cdf0e10cSrcweir } 1773cdf0e10cSrcweir 1774cdf0e10cSrcweir //--------------------------------------------------------------------- implPushBackValue(const::rtl::OUString & _rValue)1775cdf0e10cSrcweir void OListAndComboImport::implPushBackValue(const ::rtl::OUString& _rValue) 1776cdf0e10cSrcweir { 1777cdf0e10cSrcweir OSL_ENSURE(!m_nEmptyValueItems, "OListAndComboImport::implPushBackValue: value list is already done!"); 1778cdf0e10cSrcweir if (!m_nEmptyValueItems) 1779cdf0e10cSrcweir { 1780cdf0e10cSrcweir OSL_ENSURE( !m_bEncounteredLSAttrib, "OListAndComboImport::implPushBackValue: invalid structure! Did you save this document with a version prior SRC641 m?" ); 1781cdf0e10cSrcweir // We already had the list-source attribute, which means that the ListSourceType is 1782cdf0e10cSrcweir // not ValueList, which means that the ListSource should contain only one string in 1783cdf0e10cSrcweir // the first element of the sequence 1784cdf0e10cSrcweir // All other values in the file are invalid 1785cdf0e10cSrcweir 1786cdf0e10cSrcweir pushBackSequenceElement( m_aValueList, _rValue ); 1787cdf0e10cSrcweir } 1788cdf0e10cSrcweir } 1789cdf0e10cSrcweir 1790cdf0e10cSrcweir //--------------------------------------------------------------------- implEmptyLabelFound()1791cdf0e10cSrcweir void OListAndComboImport::implEmptyLabelFound() 1792cdf0e10cSrcweir { 1793cdf0e10cSrcweir ++m_nEmptyListItems; 1794cdf0e10cSrcweir } 1795cdf0e10cSrcweir 1796cdf0e10cSrcweir //--------------------------------------------------------------------- implEmptyValueFound()1797cdf0e10cSrcweir void OListAndComboImport::implEmptyValueFound() 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir ++m_nEmptyValueItems; 1800cdf0e10cSrcweir } 1801cdf0e10cSrcweir 1802cdf0e10cSrcweir //--------------------------------------------------------------------- implSelectCurrentItem()1803cdf0e10cSrcweir void OListAndComboImport::implSelectCurrentItem() 1804cdf0e10cSrcweir { 1805cdf0e10cSrcweir OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems), 1806cdf0e10cSrcweir "OListAndComboImport::implSelectCurrentItem: inconsistence between labels and values!"); 1807cdf0e10cSrcweir 1808cdf0e10cSrcweir sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.getLength() - 1 + m_nEmptyListItems); 1809cdf0e10cSrcweir pushBackSequenceElement(m_aSelectedSeq, nItemNumber); 1810cdf0e10cSrcweir } 1811cdf0e10cSrcweir 1812cdf0e10cSrcweir //--------------------------------------------------------------------- implDefaultSelectCurrentItem()1813cdf0e10cSrcweir void OListAndComboImport::implDefaultSelectCurrentItem() 1814cdf0e10cSrcweir { 1815cdf0e10cSrcweir OSL_ENSURE((m_aListSource.getLength() + m_nEmptyListItems) == (m_aValueList.getLength() + m_nEmptyValueItems), 1816cdf0e10cSrcweir "OListAndComboImport::implDefaultSelectCurrentItem: inconsistence between labels and values!"); 1817cdf0e10cSrcweir 1818cdf0e10cSrcweir sal_Int16 nItemNumber = (sal_Int16)(m_aListSource.getLength() - 1 + m_nEmptyListItems); 1819cdf0e10cSrcweir pushBackSequenceElement(m_aDefaultSelectedSeq, nItemNumber); 1820cdf0e10cSrcweir } 1821cdf0e10cSrcweir 1822cdf0e10cSrcweir //===================================================================== 1823cdf0e10cSrcweir //= OListOptionImport 1824cdf0e10cSrcweir //===================================================================== 1825cdf0e10cSrcweir //--------------------------------------------------------------------- OListOptionImport(SvXMLImport & _rImport,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const OListAndComboImportRef & _rListBox)1826cdf0e10cSrcweir OListOptionImport::OListOptionImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1827cdf0e10cSrcweir const OListAndComboImportRef& _rListBox) 1828cdf0e10cSrcweir :SvXMLImportContext(_rImport, _nPrefix, _rName) 1829cdf0e10cSrcweir ,m_xListBoxImport(_rListBox) 1830cdf0e10cSrcweir { 1831cdf0e10cSrcweir } 1832cdf0e10cSrcweir 1833cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1834cdf0e10cSrcweir void OListOptionImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1835cdf0e10cSrcweir { 1836cdf0e10cSrcweir // the label and the value 1837cdf0e10cSrcweir const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); 1838cdf0e10cSrcweir const ::rtl::OUString sLabelAttribute = rMap.GetQNameByKey( 1839cdf0e10cSrcweir GetPrefix(), ::rtl::OUString::createFromAscii("label")); 1840cdf0e10cSrcweir const ::rtl::OUString sValueAttribute = rMap.GetQNameByKey( 1841cdf0e10cSrcweir GetPrefix(), ::rtl::OUString::createFromAscii("value")); 1842cdf0e10cSrcweir 1843cdf0e10cSrcweir // ------------------- 1844cdf0e10cSrcweir // the label attribute 1845cdf0e10cSrcweir ::rtl::OUString sValue = _rxAttrList->getValueByName(sLabelAttribute); 1846cdf0e10cSrcweir sal_Bool bNonexistentAttribute = sal_False; 1847cdf0e10cSrcweir if (!sValue.getLength()) 1848cdf0e10cSrcweir if (0 == _rxAttrList->getTypeByName(sLabelAttribute).getLength()) 1849cdf0e10cSrcweir // this attribute does not really exist 1850cdf0e10cSrcweir bNonexistentAttribute = sal_True; 1851cdf0e10cSrcweir 1852cdf0e10cSrcweir if (bNonexistentAttribute) 1853cdf0e10cSrcweir m_xListBoxImport->implEmptyLabelFound(); 1854cdf0e10cSrcweir else 1855cdf0e10cSrcweir m_xListBoxImport->implPushBackLabel( sValue ); 1856cdf0e10cSrcweir 1857cdf0e10cSrcweir // ------------------- 1858cdf0e10cSrcweir // the value attribute 1859cdf0e10cSrcweir sValue = _rxAttrList->getValueByName(sValueAttribute); 1860cdf0e10cSrcweir bNonexistentAttribute = sal_False; 1861cdf0e10cSrcweir if (!sValue.getLength()) 1862cdf0e10cSrcweir if (0 == _rxAttrList->getTypeByName(sValueAttribute).getLength()) 1863cdf0e10cSrcweir // this attribute does not really exist 1864cdf0e10cSrcweir bNonexistentAttribute = sal_True; 1865cdf0e10cSrcweir 1866cdf0e10cSrcweir if (bNonexistentAttribute) 1867cdf0e10cSrcweir m_xListBoxImport->implEmptyValueFound(); 1868cdf0e10cSrcweir else 1869cdf0e10cSrcweir m_xListBoxImport->implPushBackValue( sValue ); 1870cdf0e10cSrcweir 1871cdf0e10cSrcweir // the current-selected and selected 1872cdf0e10cSrcweir const ::rtl::OUString sSelectedAttribute = rMap.GetQNameByKey( 1873cdf0e10cSrcweir GetPrefix(), ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED))); 1874cdf0e10cSrcweir const ::rtl::OUString sDefaultSelectedAttribute = rMap.GetQNameByKey( 1875cdf0e10cSrcweir GetPrefix(), ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED))); 1876cdf0e10cSrcweir 1877cdf0e10cSrcweir // propagate the selected flag 1878cdf0e10cSrcweir sal_Bool bSelected; 1879cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertBool(bSelected, _rxAttrList->getValueByName(sSelectedAttribute)); 1880cdf0e10cSrcweir if (bSelected) 1881cdf0e10cSrcweir m_xListBoxImport->implSelectCurrentItem(); 1882cdf0e10cSrcweir 1883cdf0e10cSrcweir // same for the default selected 1884cdf0e10cSrcweir sal_Bool bDefaultSelected; 1885cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertBool(bDefaultSelected, _rxAttrList->getValueByName(sDefaultSelectedAttribute)); 1886cdf0e10cSrcweir if (bDefaultSelected) 1887cdf0e10cSrcweir m_xListBoxImport->implDefaultSelectCurrentItem(); 1888cdf0e10cSrcweir 1889cdf0e10cSrcweir SvXMLImportContext::StartElement(_rxAttrList); 1890cdf0e10cSrcweir } 1891cdf0e10cSrcweir 1892cdf0e10cSrcweir //===================================================================== 1893cdf0e10cSrcweir //= OComboItemImport 1894cdf0e10cSrcweir //===================================================================== 1895cdf0e10cSrcweir //--------------------------------------------------------------------- OComboItemImport(SvXMLImport & _rImport,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const OListAndComboImportRef & _rListBox)1896cdf0e10cSrcweir OComboItemImport::OComboItemImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1897cdf0e10cSrcweir const OListAndComboImportRef& _rListBox) 1898cdf0e10cSrcweir :SvXMLImportContext(_rImport, _nPrefix, _rName) 1899cdf0e10cSrcweir ,m_xListBoxImport(_rListBox) 1900cdf0e10cSrcweir { 1901cdf0e10cSrcweir } 1902cdf0e10cSrcweir 1903cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1904cdf0e10cSrcweir void OComboItemImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1905cdf0e10cSrcweir { 1906cdf0e10cSrcweir const ::rtl::OUString sLabelAttributeName = GetImport().GetNamespaceMap().GetQNameByKey( 1907cdf0e10cSrcweir GetPrefix(), ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL))); 1908cdf0e10cSrcweir m_xListBoxImport->implPushBackLabel(_rxAttrList->getValueByName(sLabelAttributeName)); 1909cdf0e10cSrcweir 1910cdf0e10cSrcweir SvXMLImportContext::StartElement(_rxAttrList); 1911cdf0e10cSrcweir } 1912cdf0e10cSrcweir 1913cdf0e10cSrcweir 1914cdf0e10cSrcweir //===================================================================== 1915cdf0e10cSrcweir //= OColumnWrapperImport 1916cdf0e10cSrcweir //===================================================================== 1917cdf0e10cSrcweir //--------------------------------------------------------------------- OColumnWrapperImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer)1918cdf0e10cSrcweir OColumnWrapperImport::OColumnWrapperImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1919cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer) 1920cdf0e10cSrcweir :SvXMLImportContext(_rImport.getGlobalContext(), _nPrefix, _rName) 1921cdf0e10cSrcweir ,m_xParentContainer(_rxParentContainer) 1922cdf0e10cSrcweir ,m_rFormImport(_rImport) 1923cdf0e10cSrcweir ,m_rEventManager(_rEventManager) 1924cdf0e10cSrcweir { 1925cdf0e10cSrcweir } 1926cdf0e10cSrcweir //--------------------------------------------------------------------- CreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,const Reference<sax::XAttributeList> &)1927cdf0e10cSrcweir SvXMLImportContext* OColumnWrapperImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 1928cdf0e10cSrcweir const Reference< sax::XAttributeList >&) 1929cdf0e10cSrcweir { 1930cdf0e10cSrcweir OControlImport* pReturn = implCreateChildContext(_nPrefix, _rLocalName, OElementNameMap::getElementType(_rLocalName)); 1931cdf0e10cSrcweir if (pReturn) 1932cdf0e10cSrcweir { 1933cdf0e10cSrcweir OSL_ENSURE(m_xOwnAttributes.is(), "OColumnWrapperImport::CreateChildContext: had no form:column element!"); 1934cdf0e10cSrcweir pReturn->addOuterAttributes(m_xOwnAttributes); 1935cdf0e10cSrcweir } 1936cdf0e10cSrcweir return pReturn; 1937cdf0e10cSrcweir } 1938cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)1939cdf0e10cSrcweir void OColumnWrapperImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 1940cdf0e10cSrcweir { 194186e1cf34SPedro Giffuni OSL_ENSURE(!m_xOwnAttributes.is(), "OColumnWrapperImport::StartElement: already have the cloned list!"); 1942cdf0e10cSrcweir 1943cdf0e10cSrcweir // clone the attributes 1944cdf0e10cSrcweir Reference< XCloneable > xCloneList(_rxAttrList, UNO_QUERY); 1945cdf0e10cSrcweir OSL_ENSURE(xCloneList.is(), "OColumnWrapperImport::StartElement: AttributeList not cloneable!"); 1946cdf0e10cSrcweir if ( xCloneList.is() ) 1947cdf0e10cSrcweir m_xOwnAttributes = Reference< sax::XAttributeList >(xCloneList->createClone(), UNO_QUERY); 1948cdf0e10cSrcweir OSL_ENSURE(m_xOwnAttributes.is(), "OColumnWrapperImport::StartElement: no cloned list!"); 1949cdf0e10cSrcweir } 1950cdf0e10cSrcweir 1951cdf0e10cSrcweir //--------------------------------------------------------------------- implCreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,OControlElement::ElementType _eType)1952cdf0e10cSrcweir OControlImport* OColumnWrapperImport::implCreateChildContext( 1953cdf0e10cSrcweir sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 1954cdf0e10cSrcweir OControlElement::ElementType _eType) 1955cdf0e10cSrcweir { 1956cdf0e10cSrcweir OSL_ENSURE( (OControlElement::TEXT == _eType) 1957cdf0e10cSrcweir || (OControlElement::TEXT_AREA == _eType) 1958cdf0e10cSrcweir || (OControlElement::FORMATTED_TEXT == _eType) 1959cdf0e10cSrcweir || (OControlElement::CHECKBOX == _eType) 1960cdf0e10cSrcweir || (OControlElement::LISTBOX == _eType) 1961cdf0e10cSrcweir || (OControlElement::COMBOBOX == _eType) 1962cdf0e10cSrcweir || (OControlElement::TIME == _eType) 1963cdf0e10cSrcweir || (OControlElement::DATE == _eType), 1964cdf0e10cSrcweir "OColumnWrapperImport::implCreateChildContext: invalid or unrecognized sub element!"); 1965cdf0e10cSrcweir 1966cdf0e10cSrcweir switch (_eType) 1967cdf0e10cSrcweir { 1968cdf0e10cSrcweir case OControlElement::COMBOBOX: 1969cdf0e10cSrcweir case OControlElement::LISTBOX: 1970cdf0e10cSrcweir return new OColumnImport<OListAndComboImport>(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType ); 1971cdf0e10cSrcweir 1972cdf0e10cSrcweir case OControlElement::PASSWORD: 1973cdf0e10cSrcweir return new OColumnImport<OPasswordImport>(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType ); 1974cdf0e10cSrcweir 1975cdf0e10cSrcweir case OControlElement::TEXT: 1976cdf0e10cSrcweir case OControlElement::TEXT_AREA: 1977cdf0e10cSrcweir case OControlElement::FORMATTED_TEXT: 1978cdf0e10cSrcweir return new OColumnImport< OTextLikeImport >( m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType ); 1979cdf0e10cSrcweir 1980cdf0e10cSrcweir default: 1981cdf0e10cSrcweir return new OColumnImport<OControlImport>(m_rFormImport, m_rEventManager, _nPrefix, _rLocalName, m_xParentContainer, _eType ); 1982cdf0e10cSrcweir } 1983cdf0e10cSrcweir } 1984cdf0e10cSrcweir 1985cdf0e10cSrcweir //===================================================================== 1986cdf0e10cSrcweir //= OGridImport 1987cdf0e10cSrcweir //===================================================================== 1988cdf0e10cSrcweir //--------------------------------------------------------------------- OGridImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer,OControlElement::ElementType _eType)1989cdf0e10cSrcweir OGridImport::OGridImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 1990cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer, 1991cdf0e10cSrcweir OControlElement::ElementType _eType) 1992cdf0e10cSrcweir :OGridImport_Base(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, "column") 1993cdf0e10cSrcweir { 1994cdf0e10cSrcweir setElementType(_eType); 1995cdf0e10cSrcweir } 1996cdf0e10cSrcweir 1997cdf0e10cSrcweir //--------------------------------------------------------------------- implCreateControlWrapper(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName)1998cdf0e10cSrcweir SvXMLImportContext* OGridImport::implCreateControlWrapper(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName) 1999cdf0e10cSrcweir { 2000cdf0e10cSrcweir return new OColumnWrapperImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer); 2001cdf0e10cSrcweir } 2002cdf0e10cSrcweir 2003cdf0e10cSrcweir //===================================================================== 2004cdf0e10cSrcweir //= OFormImport 2005cdf0e10cSrcweir //===================================================================== 2006cdf0e10cSrcweir //--------------------------------------------------------------------- OFormImport(OFormLayerXMLImport_Impl & _rImport,IEventAttacherManager & _rEventManager,sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const Reference<XNameContainer> & _rxParentContainer)2007cdf0e10cSrcweir OFormImport::OFormImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, 2008cdf0e10cSrcweir const Reference< XNameContainer >& _rxParentContainer) 2009cdf0e10cSrcweir :OFormImport_Base(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, "control") 2010cdf0e10cSrcweir { 2011cdf0e10cSrcweir enableTrackAttributes(); 2012cdf0e10cSrcweir } 2013cdf0e10cSrcweir 2014cdf0e10cSrcweir //--------------------------------------------------------------------- CreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,const Reference<sax::XAttributeList> & _rxAttrList)2015cdf0e10cSrcweir SvXMLImportContext* OFormImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 2016cdf0e10cSrcweir const Reference< sax::XAttributeList >& _rxAttrList) 2017cdf0e10cSrcweir { 2018cdf0e10cSrcweir if( token::IsXMLToken(_rLocalName, token::XML_FORM) ) 2019cdf0e10cSrcweir return new OFormImport( m_rFormImport, *this, _nPrefix, _rLocalName, 2020cdf0e10cSrcweir m_xMeAsContainer); 2021cdf0e10cSrcweir else if ( token::IsXMLToken(_rLocalName, token::XML_CONNECTION_RESOURCE) ) 2022cdf0e10cSrcweir return new OXMLDataSourceImport(GetImport(), _nPrefix, _rLocalName, _rxAttrList,m_xElement); 2023cdf0e10cSrcweir else if( (token::IsXMLToken(_rLocalName, token::XML_EVENT_LISTENERS) && 2024cdf0e10cSrcweir (XML_NAMESPACE_OFFICE == _nPrefix)) || 2025cdf0e10cSrcweir token::IsXMLToken( _rLocalName, token::XML_PROPERTIES) ) 2026cdf0e10cSrcweir return OElementImport::CreateChildContext( _nPrefix, _rLocalName, 2027cdf0e10cSrcweir _rxAttrList ); 2028cdf0e10cSrcweir else 2029cdf0e10cSrcweir return implCreateChildContext( _nPrefix, _rLocalName, 2030cdf0e10cSrcweir OElementNameMap::getElementType(_rLocalName) ); 2031cdf0e10cSrcweir } 2032cdf0e10cSrcweir 2033cdf0e10cSrcweir //--------------------------------------------------------------------- StartElement(const Reference<sax::XAttributeList> & _rxAttrList)2034cdf0e10cSrcweir void OFormImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) 2035cdf0e10cSrcweir { 2036cdf0e10cSrcweir m_rFormImport.enterEventContext(); 2037cdf0e10cSrcweir OFormImport_Base::StartElement(_rxAttrList); 2038cdf0e10cSrcweir 2039cdf0e10cSrcweir // handle the target-frame attribute 2040cdf0e10cSrcweir simulateDefaultedAttribute(OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME), PROPERTY_TARGETFRAME, "_blank"); 2041cdf0e10cSrcweir } 2042cdf0e10cSrcweir 2043cdf0e10cSrcweir //--------------------------------------------------------------------- EndElement()2044cdf0e10cSrcweir void OFormImport::EndElement() 2045cdf0e10cSrcweir { 2046cdf0e10cSrcweir OFormImport_Base::EndElement(); 2047cdf0e10cSrcweir m_rFormImport.leaveEventContext(); 2048cdf0e10cSrcweir } 2049cdf0e10cSrcweir 2050cdf0e10cSrcweir //--------------------------------------------------------------------- implCreateControlWrapper(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName)2051cdf0e10cSrcweir SvXMLImportContext* OFormImport::implCreateControlWrapper(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName) 2052cdf0e10cSrcweir { 2053870262e3SDon Lewis OSL_ENSURE( sal_False, "illegal call to OFormImport::implCreateControlWrapper" ); 2054cdf0e10cSrcweir return new SvXMLImportContext(GetImport(), _nPrefix, _rLocalName ); 2055cdf0e10cSrcweir } 2056cdf0e10cSrcweir 2057cdf0e10cSrcweir //--------------------------------------------------------------------- handleAttribute(sal_uInt16 _nNamespaceKey,const::rtl::OUString & _rLocalName,const::rtl::OUString & _rValue)2058cdf0e10cSrcweir bool OFormImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) 2059cdf0e10cSrcweir { 2060cdf0e10cSrcweir // handle the master/details field attributes (they're way too special to let the OPropertyImport handle them) 2061cdf0e10cSrcweir static const ::rtl::OUString s_sMasterFieldsAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getFormAttributeName(faMasterFields)); 2062cdf0e10cSrcweir static const ::rtl::OUString s_sDetailFieldsAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getFormAttributeName(faDetailFiels)); 2063cdf0e10cSrcweir 2064cdf0e10cSrcweir if ( s_sMasterFieldsAttributeName == _rLocalName ) 2065cdf0e10cSrcweir { 2066cdf0e10cSrcweir implTranslateStringListProperty(PROPERTY_MASTERFIELDS, _rValue); 2067cdf0e10cSrcweir return true; 2068cdf0e10cSrcweir } 2069cdf0e10cSrcweir 2070cdf0e10cSrcweir if ( s_sDetailFieldsAttributeName == _rLocalName ) 2071cdf0e10cSrcweir { 2072cdf0e10cSrcweir implTranslateStringListProperty(PROPERTY_DETAILFIELDS, _rValue); 2073cdf0e10cSrcweir return true; 2074cdf0e10cSrcweir } 2075cdf0e10cSrcweir 2076cdf0e10cSrcweir return OFormImport_Base::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); 2077cdf0e10cSrcweir } 2078cdf0e10cSrcweir 2079cdf0e10cSrcweir //--------------------------------------------------------------------- implTranslateStringListProperty(const::rtl::OUString & _rPropertyName,const::rtl::OUString & _rValue)2080cdf0e10cSrcweir void OFormImport::implTranslateStringListProperty(const ::rtl::OUString& _rPropertyName, const ::rtl::OUString& _rValue) 2081cdf0e10cSrcweir { 2082cdf0e10cSrcweir PropertyValue aProp; 2083cdf0e10cSrcweir aProp.Name = _rPropertyName; 2084cdf0e10cSrcweir 2085cdf0e10cSrcweir Sequence< ::rtl::OUString > aList; 2086cdf0e10cSrcweir 2087cdf0e10cSrcweir // split up the value string 2088cdf0e10cSrcweir if (_rValue.getLength()) 2089cdf0e10cSrcweir { 2090cdf0e10cSrcweir // For the moment, we build a vector instead of a Sequence. It's easier to handle because of it's 2091cdf0e10cSrcweir // push_back method 2092cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aElements; 2093cdf0e10cSrcweir // estimate the number of tokens 2094cdf0e10cSrcweir sal_Int32 nEstimate = 0, nLength = _rValue.getLength(); 2095cdf0e10cSrcweir const sal_Unicode* pChars = _rValue.getStr(); 2096cdf0e10cSrcweir for (sal_Int32 i=0; i<nLength; ++i, ++pChars) 2097cdf0e10cSrcweir if (*pChars == ',') 2098cdf0e10cSrcweir ++nEstimate; 2099cdf0e10cSrcweir aElements.reserve(nEstimate + 1); 2100cdf0e10cSrcweir // that's the worst case. If the string contains the separator character _quoted_, we reserved to much ... 2101cdf0e10cSrcweir 2102cdf0e10cSrcweir 2103cdf0e10cSrcweir sal_Int32 nElementStart = 0; 2104cdf0e10cSrcweir sal_Int32 nNextSep = 0; 2105cdf0e10cSrcweir sal_Int32 nElementLength; 2106cdf0e10cSrcweir ::rtl::OUString sElement; 2107cdf0e10cSrcweir do 2108cdf0e10cSrcweir { 2109cdf0e10cSrcweir // extract the current element 2110cdf0e10cSrcweir nNextSep = SvXMLUnitConverter::indexOfComma( 2111cdf0e10cSrcweir _rValue, nElementStart); 2112cdf0e10cSrcweir if (-1 == nNextSep) 2113cdf0e10cSrcweir nNextSep = nLength; 2114cdf0e10cSrcweir sElement = _rValue.copy(nElementStart, nNextSep - nElementStart); 2115cdf0e10cSrcweir 2116cdf0e10cSrcweir nElementLength = sElement.getLength(); 2117cdf0e10cSrcweir // when writing the sequence, we quoted the single elements with " characters 2118cdf0e10cSrcweir OSL_ENSURE( (nElementLength >= 2) 2119cdf0e10cSrcweir && (sElement.getStr()[0] == '"') 2120cdf0e10cSrcweir && (sElement.getStr()[nElementLength - 1] == '"'), 2121cdf0e10cSrcweir "OFormImport::implTranslateStringListProperty: invalid quoted element name."); 2122cdf0e10cSrcweir sElement = sElement.copy(1, nElementLength - 2); 2123cdf0e10cSrcweir 2124cdf0e10cSrcweir aElements.push_back(sElement); 2125cdf0e10cSrcweir 2126cdf0e10cSrcweir // swith to the next element 2127cdf0e10cSrcweir nElementStart = 1 + nNextSep; 2128cdf0e10cSrcweir } 2129cdf0e10cSrcweir while (nElementStart < nLength); 2130cdf0e10cSrcweir 2131cdf0e10cSrcweir ::rtl::OUString *pElements = aElements.empty() ? 0 : &aElements[0]; 2132cdf0e10cSrcweir aList = Sequence< ::rtl::OUString >(pElements, aElements.size()); 2133cdf0e10cSrcweir } 2134cdf0e10cSrcweir else 2135cdf0e10cSrcweir { 2136cdf0e10cSrcweir OSL_ENSURE(sal_False, "OFormImport::implTranslateStringListProperty: invalid value (empty)!"); 2137cdf0e10cSrcweir } 2138cdf0e10cSrcweir 2139cdf0e10cSrcweir aProp.Value <<= aList; 2140cdf0e10cSrcweir 2141cdf0e10cSrcweir // add the property to the base class' array 2142cdf0e10cSrcweir implPushBackPropertyValue(aProp); 2143cdf0e10cSrcweir } 2144cdf0e10cSrcweir //===================================================================== 2145cdf0e10cSrcweir //= OXMLDataSourceImport 2146cdf0e10cSrcweir //===================================================================== OXMLDataSourceImport(SvXMLImport & _rImport,sal_uInt16 nPrfx,const::rtl::OUString & _sLocalName,const Reference<::com::sun::star::xml::sax::XAttributeList> & _xAttrList,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & _xElement)2147cdf0e10cSrcweir OXMLDataSourceImport::OXMLDataSourceImport( 2148cdf0e10cSrcweir SvXMLImport& _rImport 2149cdf0e10cSrcweir ,sal_uInt16 nPrfx 2150cdf0e10cSrcweir , const ::rtl::OUString& _sLocalName 2151cdf0e10cSrcweir ,const Reference< ::com::sun::star::xml::sax::XAttributeList > & _xAttrList 2152cdf0e10cSrcweir ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xElement) : 2153cdf0e10cSrcweir SvXMLImportContext( _rImport, nPrfx, _sLocalName ) 2154cdf0e10cSrcweir { 2155cdf0e10cSrcweir OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); 2156cdf0e10cSrcweir const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap(); 2157cdf0e10cSrcweir 2158cdf0e10cSrcweir sal_Int16 nLength = (_xElement.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; 2159cdf0e10cSrcweir for(sal_Int16 i = 0; i < nLength; ++i) 2160cdf0e10cSrcweir { 2161cdf0e10cSrcweir ::rtl::OUString sLocalName; 2162cdf0e10cSrcweir ::rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); 2163cdf0e10cSrcweir sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName, &sLocalName ); 2164cdf0e10cSrcweir 2165cdf0e10cSrcweir if ( ( nPrefix == OAttributeMetaData::getCommonControlAttributeNamespace( CCA_TARGET_LOCATION ) ) 2166cdf0e10cSrcweir && ( sLocalName.equalsAscii( OAttributeMetaData::getCommonControlAttributeName( CCA_TARGET_LOCATION ) ) ) 2167cdf0e10cSrcweir ) 2168cdf0e10cSrcweir { 2169cdf0e10cSrcweir ::rtl::OUString sValue = _xAttrList->getValueByIndex( i ); 2170cdf0e10cSrcweir 2171cdf0e10cSrcweir INetURLObject aURL(sValue); 2172cdf0e10cSrcweir if ( aURL.GetProtocol() == INET_PROT_FILE ) 2173cdf0e10cSrcweir _xElement->setPropertyValue(PROPERTY_DATASOURCENAME,makeAny(sValue)); 2174cdf0e10cSrcweir else 2175cdf0e10cSrcweir _xElement->setPropertyValue(PROPERTY_URL,makeAny(sValue)); // the url is the "sdbc:" string 2176cdf0e10cSrcweir break; 2177cdf0e10cSrcweir } 2178cdf0e10cSrcweir } 2179cdf0e10cSrcweir } 2180cdf0e10cSrcweir //--------------------------------------------------------------------- implCreateChildContext(sal_uInt16 _nPrefix,const::rtl::OUString & _rLocalName,OControlElement::ElementType _eType)2181cdf0e10cSrcweir OControlImport* OFormImport::implCreateChildContext( 2182cdf0e10cSrcweir sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, 2183cdf0e10cSrcweir OControlElement::ElementType _eType ) 2184cdf0e10cSrcweir { 2185cdf0e10cSrcweir switch (_eType) 2186cdf0e10cSrcweir { 2187cdf0e10cSrcweir case OControlElement::TEXT: 2188cdf0e10cSrcweir case OControlElement::TEXT_AREA: 2189cdf0e10cSrcweir case OControlElement::FORMATTED_TEXT: 2190cdf0e10cSrcweir return new OTextLikeImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2191cdf0e10cSrcweir 2192cdf0e10cSrcweir case OControlElement::BUTTON: 2193cdf0e10cSrcweir case OControlElement::IMAGE: 2194cdf0e10cSrcweir case OControlElement::IMAGE_FRAME: 2195cdf0e10cSrcweir return new OButtonImport( m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType ); 2196cdf0e10cSrcweir 2197cdf0e10cSrcweir case OControlElement::COMBOBOX: 2198cdf0e10cSrcweir case OControlElement::LISTBOX: 2199cdf0e10cSrcweir return new OListAndComboImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2200cdf0e10cSrcweir 2201cdf0e10cSrcweir case OControlElement::RADIO: 2202cdf0e10cSrcweir return new ORadioImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2203cdf0e10cSrcweir 2204cdf0e10cSrcweir case OControlElement::CHECKBOX: 2205cdf0e10cSrcweir return new OImagePositionImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2206cdf0e10cSrcweir 2207cdf0e10cSrcweir case OControlElement::PASSWORD: 2208cdf0e10cSrcweir return new OPasswordImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2209cdf0e10cSrcweir 2210cdf0e10cSrcweir case OControlElement::FRAME: 2211cdf0e10cSrcweir case OControlElement::FIXED_TEXT: 2212cdf0e10cSrcweir return new OReferredControlImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2213cdf0e10cSrcweir 2214cdf0e10cSrcweir case OControlElement::GRID: 2215cdf0e10cSrcweir return new OGridImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2216cdf0e10cSrcweir 2217cdf0e10cSrcweir case OControlElement::VALUERANGE: 2218cdf0e10cSrcweir return new OValueRangeImport( m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType ); 2219cdf0e10cSrcweir 2220cdf0e10cSrcweir default: 2221cdf0e10cSrcweir return new OControlImport(m_rFormImport, *this, _nPrefix, _rLocalName, m_xMeAsContainer, _eType); 2222cdf0e10cSrcweir } 2223cdf0e10cSrcweir } 222428f2418dSTsutomu Uchino 222528f2418dSTsutomu Uchino //--------------------------------------------------------------------- determineDefaultServiceName() const222628f2418dSTsutomu Uchino ::rtl::OUString OFormImport::determineDefaultServiceName() const 222728f2418dSTsutomu Uchino { 222828f2418dSTsutomu Uchino return ::rtl::OUString::createFromAscii( "com.sun.star.form.component.Form" ); 222928f2418dSTsutomu Uchino } 2230cdf0e10cSrcweir 2231cdf0e10cSrcweir //......................................................................... 2232cdf0e10cSrcweir } // namespace xmloff 2233cdf0e10cSrcweir //......................................................................... 2234cdf0e10cSrcweir 2235