/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/** helper class which allows fast translation of xml tag names into element types.
*/ class OElementNameMap : public OControlElement
{ typedef std::map<OUString, ElementType> MapString2Element; static std::map<sal_Int32, ElementType> s_sElementTranslations2;
//= OElementImport /** implements common behaviour for importing forms, controls and columns
*/ class OElementImport
:public OPropertyImport
,public IEventAttacher
,public OStackedLogging
{ protected:
OUString m_sServiceName; // the service name as extracted from the service-name attribute
OUString m_sName; // the name of the object (redundant, already contained in the base class' array)
OFormLayerXMLImport_Impl& m_rFormImport; // the form import context
IEventAttacherManager& m_rEventManager; // the event attacher manager
const XMLTextStyleContext* m_pStyleElement; // the XML element which describes the style we encountered // while reading our element
/// the parent container to insert the new element into
css::uno::Reference< css::container::XNameContainer >
m_xParentContainer;
/// the element we're creating. Valid after StartElement
css::uno::Reference< css::beans::XPropertySet >
m_xElement;
css::uno::Reference< css::beans::XPropertySetInfo >
m_xInfo;
bool m_bImplicitGenericAttributeHandling;
public: /** ctor @param _rImport the importer @param _rEventManager the event attacher manager for the control being imported @param _rAttributeMap the attribute map to be used for translating attributes into properties @param _rxParentContainer the container in which the new element should be inserted
*/
OElementImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer
); virtual ~OElementImport() override;
/** create the (uninitialized) element which is to represent the read data
<p>The default implementation uses <member>m_xORB</member> to create an object with <member>m_sServiceName</member>.
*/ virtual css::uno::Reference< css::beans::XPropertySet >
createElement();
protected: /** can be used to handle properties where the attribute default and the property default differ. <p>In such case, if the property had the attribute default upon writing, nothing is read, so upon reading, the property is still at its own default (which is not the attribute default).<p/> <p>This method, if told the attribute and the property, and the (implied) attribute default, sets the property value as if the attribute was encountered.</p> @see encounteredAttribute
*/ void simulateDefaultedAttribute(sal_Int32 nElement, const OUString& _rPropertyName, const OUString& _pAttributeDefault);
/** to be called from within handleAttribute, checks whether the given attribute is covered by our generic attribute handler mechanisms
*/ bool tryGenericAttribute( sal_Int32 nElement, const OUString& _rValue );
/** controls whether |handleAttribute| implicitly calls |tryGenericAttribute|, or whether the derived class must do this explicitly at a suitable place in its own |handleAttribute|
*/ void disableImplicitGenericAttributeHandling() { m_bImplicitGenericAttributeHandling = false; }
//= OControlImport /** helper class for importing the description of a single control
*/ class OControlImport
:public OElementImport
,public OValuePropertiesMetaData
{ protected:
OUString m_sControlId;
OControlElement::ElementType m_eElementType;
PropertyValueArray m_aValueProperties; // the value properties (value, current-value, min-value, max-value) require some special // handling
// we fake the attributes our base class gets: we add the attributes of the outer wrapper // element which encloses us
css::uno::Reference< css::xml::sax::XFastAttributeList >
m_xOuterAttributes;
/** the address of the calc cell which the control model should be bound to, if applicable
*/
OUString m_sBoundCellAddress;
/** name of a value binding (xforms:bind attribute) */
OUString m_sBindingID;
/** name of a list binding (form:xforms-list-source attribute) */
OUString m_sListBindingID;
/** name of a submission (xforms:submission attribute) */
OUString m_sSubmissionID;
protected: // for use by derived classes only
OControlImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer
);
/** registers the given cell address as value binding address for our element
<p>The default implementation simply calls registerCellValueBinding at our import context, but you may want to override this behaviour.</p>
@param _rBoundCellAddress the cell address to register for our element. Must not be <NULL/>. @precond we have a valid element (m_xElement)
*/ virtualvoid doRegisterCellValueBinding( const OUString& _rBoundCellAddress );
/** register the given XForms binding */ void doRegisterXFormsValueBinding( const OUString& );
/** register the given XForms list binding */ void doRegisterXFormsListBinding( const OUString& );
/** register the given XForms submission */ void doRegisterXFormsSubmission( const OUString& );
// TODO: // this whole mechanism doesn't scale. Instead of deriving even more classes for every new attribute, // we should have dedicated attribute handlers // The rest of xmloff implements it this way - why don't we do, too?
//= OImagePositionImport class OImagePositionImport : public OControlImport
{
css::uno::Reference<css::graphic::XGraphic> m_xGraphic;
sal_Int16 m_nImagePosition;
sal_Int16 m_nImageAlign; bool m_bHaveImagePosition;
//= OReferredControlImport class OReferredControlImport : public OControlImport
{
OUString m_sReferringControls; // the list of ids of controls referring to the one being imported
//= OURLReferenceImport /** a specialized version of the <type>OControlImport</type> class, which is able to handle attributes which denote URLs (and stored relative)
*/ class OURLReferenceImport : public OImagePositionImport
{ public:
OURLReferenceImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType
);
//= OButtonImport /** A specialized version of the <type>OControlImport</type> class, which handles the target frame for image and command buttons
*/ class OButtonImport : public OURLReferenceImport
{ public:
OButtonImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType
);
//= OValueRangeImport /** A specialized version of the <type>OControlImport</type> class, which imports the value-range elements
*/ class OValueRangeImport : public OControlImport
{ private:
sal_Int32 m_nStepSizeValue;
//= OTextLikeImport /** A specialized version of the <type>OControlImport</type> class, which handles text like controls which have the convert-empty-to-null attribute</p>
*/ class OTextLikeImport : public OControlImport
{ private:
css::uno::Reference< css::text::XTextCursor > m_xCursor;
css::uno::Reference< css::text::XTextCursor > m_xOldCursor; bool m_bEncounteredTextPara;
//= OListAndComboImport /** A specialized version of the <type>OControlImport</type> class, which handles attributes / sub elements which are special to list and combo boxes
*/ class OListAndComboImport : public OControlImport
{ friendclass OListOptionImport; friendclass OComboItemImport;
OUString m_sCellListSource; /// the cell range which acts as list source for the control
sal_Int32 m_nEmptyListItems; /// number of empty list items encountered during reading
sal_Int32 m_nEmptyValueItems; /// number of empty value items encountered during reading
bool m_bEncounteredLSAttrib; bool m_bLinkWithIndexes; /** <TRUE/> if and only if we should use a cell value binding which exchanges the selection index (instead of the selection text
*/
//= OListOptionImport /** helper class for importing a single <form:option> element.
*/ class OListOptionImport
:public SvXMLImportContext
{
OListAndComboImportRef m_xListBoxImport;
//= OComboItemImport /** helper class for importing a single <form:item> element.
*/ class OComboItemImport
:public SvXMLImportContext
{
OListAndComboImportRef m_xListBoxImport;
//= OColumnImport /** helper class importing a single grid column (without the <form:column> element wrapping the column).
<p>BASE (the template argument) must be a derivee of OControlImport</p>
*/ template <class BASE> class OColumnImport : public BASE
{
css::uno::Reference< css::form::XGridColumnFactory >
m_xColumnFactory;
/** helper class importing a single <form:grid> element
*/ class OGridImport : public OControlImport, public ODefaultEventAttacherManager
{ public:
OGridImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType);
/** helper class importing a single <form:form> element
*/ class OFormImport : public OElementImport, public ODefaultEventAttacherManager
{ public:
OFormImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer
);
// OElementImport overridables template <class BASE>
css::uno::Reference< css::beans::XPropertySet > OColumnImport< BASE >::createElement()
{
css::uno::Reference< css::beans::XPropertySet > xReturn; // no call to the base class' method. We have to use the grid column factory if (m_xColumnFactory.is())
{ // create the column
xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
} return xReturn;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.