1*ecfe53c5SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ecfe53c5SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ecfe53c5SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ecfe53c5SAndrew Rist * distributed with this work for additional information 6*ecfe53c5SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ecfe53c5SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ecfe53c5SAndrew Rist * "License"); you may not use this file except in compliance 9*ecfe53c5SAndrew Rist * with the License. You may obtain a copy of the License at 10*ecfe53c5SAndrew Rist * 11*ecfe53c5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ecfe53c5SAndrew Rist * 13*ecfe53c5SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ecfe53c5SAndrew Rist * software distributed under the License is distributed on an 15*ecfe53c5SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ecfe53c5SAndrew Rist * KIND, either express or implied. See the License for the 17*ecfe53c5SAndrew Rist * specific language governing permissions and limitations 18*ecfe53c5SAndrew Rist * under the License. 19*ecfe53c5SAndrew Rist * 20*ecfe53c5SAndrew Rist *************************************************************/ 21*ecfe53c5SAndrew Rist 22*ecfe53c5SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _XMLOFF_ELEMENTEXPORT_HXX_ 25cdf0e10cSrcweir #define _XMLOFF_ELEMENTEXPORT_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 28cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 29cdf0e10cSrcweir #include <com/sun/star/script/ScriptEventDescriptor.hpp> 30cdf0e10cSrcweir #include "propertyexport.hxx" 31cdf0e10cSrcweir #include "callbacks.hxx" 32cdf0e10cSrcweir #include "controlelement.hxx" 33cdf0e10cSrcweir #include "valueproperties.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir class SvXMLElementExport; 36cdf0e10cSrcweir //......................................................................... 37cdf0e10cSrcweir namespace xmloff 38cdf0e10cSrcweir { 39cdf0e10cSrcweir //......................................................................... 40cdf0e10cSrcweir 41cdf0e10cSrcweir //===================================================================== 42cdf0e10cSrcweir //= OElementExport 43cdf0e10cSrcweir //===================================================================== 44cdf0e10cSrcweir class OElementExport : public OPropertyExport 45cdf0e10cSrcweir { 46cdf0e10cSrcweir protected: 47cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor > 48cdf0e10cSrcweir m_aEvents; 49cdf0e10cSrcweir 50cdf0e10cSrcweir SvXMLElementExport* m_pXMLElement; // XML element doing the concrete startElement etc. 51cdf0e10cSrcweir 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir OElementExport(IFormsExportContext& _rContext, 54cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxProps, 55cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rEvents); 56cdf0e10cSrcweir virtual ~OElementExport(); 57cdf0e10cSrcweir 58cdf0e10cSrcweir void doExport(); 59cdf0e10cSrcweir 60cdf0e10cSrcweir protected: 61cdf0e10cSrcweir /// get the name of the XML element 62cdf0e10cSrcweir virtual const sal_Char* getXMLElementName() const = 0; 63cdf0e10cSrcweir /// examine the element we're exporting 64cdf0e10cSrcweir virtual void examine(); 65cdf0e10cSrcweir /// export the attributes 66cdf0e10cSrcweir virtual void exportAttributes(); 67cdf0e10cSrcweir /// export any sub tags 68cdf0e10cSrcweir virtual void exportSubTags(); 69cdf0e10cSrcweir 70cdf0e10cSrcweir /** exports the events (as script:events tag) 71cdf0e10cSrcweir */ 72cdf0e10cSrcweir void exportEvents(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir /** add the service-name attribute to the export context 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir virtual void exportServiceNameAttribute(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir /// start the XML element 79cdf0e10cSrcweir virtual void implStartElement(const sal_Char* _pName); 80cdf0e10cSrcweir 81cdf0e10cSrcweir /// ends the XML element 82cdf0e10cSrcweir virtual void implEndElement(); 83cdf0e10cSrcweir }; 84cdf0e10cSrcweir 85cdf0e10cSrcweir //===================================================================== 86cdf0e10cSrcweir //= OControlExport 87cdf0e10cSrcweir //===================================================================== 88cdf0e10cSrcweir /** Helper class for handling xml elements representing a form control 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir class OControlExport 91cdf0e10cSrcweir :public OControlElement 92cdf0e10cSrcweir ,public OValuePropertiesMetaData 93cdf0e10cSrcweir ,public OElementExport 94cdf0e10cSrcweir { 95cdf0e10cSrcweir protected: 96cdf0e10cSrcweir DECLARE_STL_STDKEY_SET(sal_Int16, Int16Set); 97cdf0e10cSrcweir // used below 98cdf0e10cSrcweir 99cdf0e10cSrcweir ::rtl::OUString m_sControlId; // the control id to use when exporting 100cdf0e10cSrcweir ::rtl::OUString m_sReferringControls; // list of referring controls (i.e. their id's) 101cdf0e10cSrcweir sal_Int16 m_nClassId; // class id of the control we're representing 102cdf0e10cSrcweir ElementType m_eType; // (XML) type of the control we're representing 103cdf0e10cSrcweir sal_Int32 m_nIncludeCommon; // common control attributes to include 104cdf0e10cSrcweir sal_Int32 m_nIncludeDatabase; // common database attributes to include 105cdf0e10cSrcweir sal_Int32 m_nIncludeSpecial; // special attributes to include 106cdf0e10cSrcweir sal_Int32 m_nIncludeEvents; // events to include 107cdf0e10cSrcweir sal_Int32 m_nIncludeBindings; // binding attributes to include 108cdf0e10cSrcweir 109cdf0e10cSrcweir SvXMLElementExport* m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element 110cdf0e10cSrcweir 111cdf0e10cSrcweir public: 112cdf0e10cSrcweir /** constructs an object capable of exporting controls 113cdf0e10cSrcweir 114cdf0e10cSrcweir <p>You need at least two pre-requisites from outside: The control to be exported needs to have a class id 115cdf0e10cSrcweir assigned, and you need the list control-ids of all the controls referring to this one as LabelControl.<br/> 116cdf0e10cSrcweir This information can't be collected when known only the control itself and not it's complete context.</p> 117cdf0e10cSrcweir 118cdf0e10cSrcweir @param _rControlId 119cdf0e10cSrcweir the control id to use when exporting the control 120cdf0e10cSrcweir @param _rReferringControls 121cdf0e10cSrcweir the comma-separated list of control-ids of all the controls referring to this one as LabelControl 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir OControlExport(IFormsExportContext& _rContext, 124cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl, 125cdf0e10cSrcweir const ::rtl::OUString& _rControlId, 126cdf0e10cSrcweir const ::rtl::OUString& _rReferringControls, 127cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents); 128cdf0e10cSrcweir ~OControlExport(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir protected: 131cdf0e10cSrcweir /// start the XML element 132cdf0e10cSrcweir virtual void implStartElement(const sal_Char* _pName); 133cdf0e10cSrcweir 134cdf0e10cSrcweir /// ends the XML element 135cdf0e10cSrcweir virtual void implEndElement(); 136cdf0e10cSrcweir 137cdf0e10cSrcweir /// get the name of the outer XML element 138cdf0e10cSrcweir virtual const sal_Char* getOuterXMLElementName() const; 139cdf0e10cSrcweir 140cdf0e10cSrcweir // get the name of the XML element 141cdf0e10cSrcweir virtual const sal_Char* getXMLElementName() const; 142cdf0e10cSrcweir 143cdf0e10cSrcweir /** examine the control. Some kind of CtorImpl. 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir virtual void examine(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir /// exports the attributes for the outer element 148cdf0e10cSrcweir void exportOuterAttributes(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir /// exports the attributes for the inner element 151cdf0e10cSrcweir void exportInnerAttributes(); 152cdf0e10cSrcweir 153cdf0e10cSrcweir /// export the attributes 154cdf0e10cSrcweir virtual void exportAttributes(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir /** writes everything which needs to be represented as sub tag 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir void exportSubTags() throw (::com::sun::star::uno::Exception); 159cdf0e10cSrcweir 160cdf0e10cSrcweir /** adds the attributes which are handled via generic IPropertyHandlers 161cdf0e10cSrcweir 162cdf0e10cSrcweir <p>In the future, this really should be *all* attribiutes, instead of this shitload of 163cdf0e10cSrcweir hand-crafted code we have currently ...</p> 164cdf0e10cSrcweir */ 165cdf0e10cSrcweir void exportGenericHandlerAttributes(); 166cdf0e10cSrcweir 167cdf0e10cSrcweir /** adds common control attributes to the XMLExport context given 168cdf0e10cSrcweir 169cdf0e10cSrcweir <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p> 170cdf0e10cSrcweir */ 171cdf0e10cSrcweir void exportCommonControlAttributes(); 172cdf0e10cSrcweir 173cdf0e10cSrcweir /** adds database attributes to the XMLExport context given 174cdf0e10cSrcweir 175cdf0e10cSrcweir <p>The attribute list of the context is not cleared initially, this is the responsibility of the caller.</p> 176cdf0e10cSrcweir */ 177cdf0e10cSrcweir void exportDatabaseAttributes(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir /** adds the XML attributes which are related to binding controls to 180cdf0e10cSrcweir external values and/or list sources 181cdf0e10cSrcweir */ 182cdf0e10cSrcweir void exportBindingAtributes(); 183cdf0e10cSrcweir 184cdf0e10cSrcweir /** adds attributes which are special to a control type to the export context's attribute list 185cdf0e10cSrcweir */ 186cdf0e10cSrcweir void exportSpecialAttributes(); 187cdf0e10cSrcweir 188cdf0e10cSrcweir /** exports the ListSource property of a control as attribute 189cdf0e10cSrcweir 190cdf0e10cSrcweir The ListSource property may be exported in different ways: For a ComboBox, it is an attribute 191cdf0e10cSrcweir of the form:combobox element. 192cdf0e10cSrcweir 193cdf0e10cSrcweir For a ListBox, it's an attribute if the ListSourceType states that the ListBox does <em>not</em> 194cdf0e10cSrcweir display a value list. In case of a value list, the ListSource is not exported, and the pairs of 195cdf0e10cSrcweir StringItem/ValueItem are exported as sub-elements. 196cdf0e10cSrcweir 197cdf0e10cSrcweir This method does the attribute part: It exports the ListSource property as attribute, not caring 198cdf0e10cSrcweir about whether the object is a ComboBox or a ListBox. 199cdf0e10cSrcweir */ 200cdf0e10cSrcweir void exportListSourceAsAttribute(); 201cdf0e10cSrcweir 202cdf0e10cSrcweir /** exports the ListSource property of a control as XML elements 203cdf0e10cSrcweir 204cdf0e10cSrcweir @see exportListSourceAsAttribute 205cdf0e10cSrcweir */ 206cdf0e10cSrcweir void exportListSourceAsElements(); 207cdf0e10cSrcweir 208cdf0e10cSrcweir /** get's a Sequence< sal_Int16 > property value as set of sal_Int16's 209cdf0e10cSrcweir @param _rPropertyName 210cdf0e10cSrcweir the property name to use 211cdf0e10cSrcweir @param _rOut 212cdf0e10cSrcweir out parameter. The set of integers. 213cdf0e10cSrcweir */ 214cdf0e10cSrcweir void getSequenceInt16PropertyAsSet(const ::rtl::OUString& _rPropertyName, Int16Set& _rOut); 215cdf0e10cSrcweir 216cdf0e10cSrcweir /** exports the attribute which descrives a cell value binding of a control 217cdf0e10cSrcweir in a spreadsheet document 218cdf0e10cSrcweir */ 219cdf0e10cSrcweir void exportCellBindingAttributes( bool _bIncludeListLinkageType ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir /** exports the attribute(s) which bind this control to XForms */ 222cdf0e10cSrcweir void exportXFormsBindAttributes(); 223cdf0e10cSrcweir 224cdf0e10cSrcweir /** exports the attribute(s) which bind the list of a list 225cdf0e10cSrcweir control to XForms */ 226cdf0e10cSrcweir void exportXFormsListAttributes(); 227cdf0e10cSrcweir 228cdf0e10cSrcweir /** exports the attribute(s) for an XForms submission */ 229cdf0e10cSrcweir void exportXFormsSubmissionAttributes(); 230cdf0e10cSrcweir 231cdf0e10cSrcweir /** exports the attribute which descrives a cell range which acts as list source for 232cdf0e10cSrcweir a list-like control 233cdf0e10cSrcweir */ 234cdf0e10cSrcweir void exportCellListSourceRange( ); 235cdf0e10cSrcweir 236cdf0e10cSrcweir /** exports the attribut(s) for the ImagePosition property 237cdf0e10cSrcweir */ 238cdf0e10cSrcweir void exportImagePositionAttributes(); 239cdf0e10cSrcweir 240cdf0e10cSrcweir /** determines whether the control we're exporting has an active data binding. 241cdf0e10cSrcweir 242cdf0e10cSrcweir Bindings which count here are: 243cdf0e10cSrcweir <ul><li>an established connection to a database field</li> 244cdf0e10cSrcweir <li>a binding to an external value supplier (<type scope="com::sun::star::form::binding">XValueBinding</type>)</li> 245cdf0e10cSrcweir </ul> 246cdf0e10cSrcweir */ 247cdf0e10cSrcweir bool controlHasActiveDataBinding() const; 248cdf0e10cSrcweir 249cdf0e10cSrcweir /** retrieves the string specifying the ListSource of a list or combo box 250cdf0e10cSrcweir */ 251cdf0e10cSrcweir ::rtl::OUString getScalarListSourceValue() const; 252cdf0e10cSrcweir 253cdf0e10cSrcweir /** determines whether the list entries (of a combo or list box) are supplied by the user 254cdf0e10cSrcweir 255cdf0e10cSrcweir List entries may be 256cdf0e10cSrcweir <ul><li>specified by the user</li> 257cdf0e10cSrcweir <li>specified by an external list source (<type scope="com::sun::star::form::binding">XListEntrySource</type>)</li> 258cdf0e10cSrcweir <li>obtained from a database query (in various ways)</li> 259cdf0e10cSrcweir </ul> 260cdf0e10cSrcweir 261cdf0e10cSrcweir In the latter two cases, this method will return <FALSE/> 262cdf0e10cSrcweir */ 263cdf0e10cSrcweir bool controlHasUserSuppliedListEntries() const; 264cdf0e10cSrcweir }; 265cdf0e10cSrcweir 266cdf0e10cSrcweir //===================================================================== 267cdf0e10cSrcweir //= OColumnExport 268cdf0e10cSrcweir //===================================================================== 269cdf0e10cSrcweir /** Helper class for exporting a grid column 270cdf0e10cSrcweir */ 271cdf0e10cSrcweir class OColumnExport : public OControlExport 272cdf0e10cSrcweir { 273cdf0e10cSrcweir public: 274cdf0e10cSrcweir /** ctor 275cdf0e10cSrcweir @see OColumnExport::OColumnExport 276cdf0e10cSrcweir */ 277cdf0e10cSrcweir OColumnExport(IFormsExportContext& _rContext, 278cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl, 279cdf0e10cSrcweir const ::rtl::OUString& _rControlId, 280cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents); 281cdf0e10cSrcweir 282cdf0e10cSrcweir ~OColumnExport(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir protected: 285cdf0e10cSrcweir // OControlExport overridables 286cdf0e10cSrcweir virtual const sal_Char* getOuterXMLElementName() const; 287cdf0e10cSrcweir virtual void exportServiceNameAttribute(); 288cdf0e10cSrcweir virtual void exportAttributes(); 289cdf0e10cSrcweir 290cdf0e10cSrcweir // OElementExport overridables 291cdf0e10cSrcweir virtual void examine(); 292cdf0e10cSrcweir }; 293cdf0e10cSrcweir 294cdf0e10cSrcweir //===================================================================== 295cdf0e10cSrcweir //= OFormExport 296cdf0e10cSrcweir //===================================================================== 297cdf0e10cSrcweir /** Helper class for handling xml elements representing a form 298cdf0e10cSrcweir 299cdf0e10cSrcweir <p>In opposite to the class <type>OControlExport</type>, OFormExport is unable to export a <em>complete</em> 300cdf0e10cSrcweir form. Instead the client has to care for sub elements of the form itself.</p> 301cdf0e10cSrcweir */ 302cdf0e10cSrcweir class OFormExport 303cdf0e10cSrcweir :public OControlElement 304cdf0e10cSrcweir ,public OElementExport 305cdf0e10cSrcweir { 306cdf0e10cSrcweir sal_Bool m_bCreateConnectionResourceElement; 307cdf0e10cSrcweir public: 308cdf0e10cSrcweir /** constructs an object capable of exporting controls 309cdf0e10cSrcweir */ 310cdf0e10cSrcweir OFormExport(IFormsExportContext& _rContext, 311cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, 312cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rxEvents 313cdf0e10cSrcweir ); 314cdf0e10cSrcweir 315cdf0e10cSrcweir protected: 316cdf0e10cSrcweir virtual const sal_Char* getXMLElementName() const; 317cdf0e10cSrcweir virtual void exportSubTags(); 318cdf0e10cSrcweir virtual void exportAttributes(); 319cdf0e10cSrcweir }; 320cdf0e10cSrcweir //......................................................................... 321cdf0e10cSrcweir } // namespace xmloff 322cdf0e10cSrcweir //......................................................................... 323cdf0e10cSrcweir 324cdf0e10cSrcweir #endif // _XMLOFF_ELEMENTEXPORT_HXX_ 325cdf0e10cSrcweir 326