LCOV - code coverage report
Current view: top level - xmloff/source/forms - elementexport.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11