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