/* -*- 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 .
*/
#ifndef INCLUDED_XMLOFF_SOURCE_FORMS_ELEMENTIMPORT_HXX
#define INCLUDED_XMLOFF_SOURCE_FORMS_ELEMENTIMPORT_HXX
#include
#include "propertyimport.hxx"
#include "controlelement.hxx"
#include "valueproperties.hxx"
#include "eventimport.hxx"
#include "logging.hxx"
#include "property_description.hxx"
#include
#include
#include
#include
#include
#include
*/
class OTextLikeImport : public OControlImport
{
private:
css::uno::Reference< css::text::XTextCursor > m_xCursor;
css::uno::Reference< css::text::XTextCursor > m_xOldCursor;
bool m_bEncounteredTextPara;
public:
OTextLikeImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType
);
// SvXMLImportContext overridables
virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual SvXMLImportContextRef CreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual void EndElement() override;
private:
void adjustDefaultControlProperty();
void removeRedundantCurrentValue();
};
//= OListAndComboImport
/** A specialized version of the OControlImport class, which handles
attributes / sub elements which are special to list and combo boxes
*/
class OListAndComboImport : public OControlImport
{
friend class OListOptionImport;
friend class OComboItemImport;
protected:
std::vector
m_aListSource;
std::vector< OUString >
m_aValueList;
std::vector< sal_Int16 >
m_aSelectedSeq;
std::vector< sal_Int16 >
m_aDefaultSelectedSeq;
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; /** if and only if we should use a cell value binding
which exchanges the selection index (instead of the selection text
*/
public:
OListAndComboImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType
);
// SvXMLImportContext overridables
virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual SvXMLImportContextRef CreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual void EndElement() override;
// OPropertyImport overridables
virtual bool handleAttribute(sal_uInt16 _nNamespaceKey,
const OUString& _rLocalName,
const OUString& _rValue) override;
// OControlImport overridables
virtual void doRegisterCellValueBinding( const OUString& _rBoundCellAddress ) override;
protected:
void implPushBackLabel(const OUString& _rLabel);
void implPushBackValue(const OUString& _rValue);
void implEmptyLabelFound();
void implEmptyValueFound();
void implSelectCurrentItem();
void implDefaultSelectCurrentItem();
};
typedef rtl::Reference OListAndComboImportRef;
//= OListOptionImport
/** helper class for importing a single <form:option> element.
*/
class OListOptionImport
:public SvXMLImportContext
{
OListAndComboImportRef m_xListBoxImport;
public:
OListOptionImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
const OListAndComboImportRef& _rListBox);
virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
};
//= OComboItemImport
/** helper class for importing a single <form:item> element.
*/
class OComboItemImport
:public SvXMLImportContext
{
OListAndComboImportRef m_xListBoxImport;
public:
OComboItemImport(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const OUString& _rName,
const OListAndComboImportRef& _rListBox);
protected:
// SvXMLImportContext overridables
virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
};
//= OColumnImport
/** helper class importing a single grid column (without the <form:column> element wrapping
the column).
BASE (the template argument) must be a derivee of OControlImport
*/
template
class OColumnImport : public BASE
{
css::uno::Reference< css::form::XGridColumnFactory >
m_xColumnFactory;
public:
OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType);
protected:
// OElementImport overridables
virtual css::uno::Reference< css::beans::XPropertySet >
createElement() override;
};
//= OColumnWrapperImport
class OColumnWrapperImport : public SvXMLImportContext
{
css::uno::Reference< css::xml::sax::XAttributeList >
m_xOwnAttributes;
css::uno::Reference< css::container::XNameContainer >
m_xParentContainer;
OFormLayerXMLImport_Impl& m_rFormImport;
IEventAttacherManager& m_rEventManager;
public:
OColumnWrapperImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer);
// SvXMLImportContext overridables
virtual SvXMLImportContextRef CreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
private:
OControlImport* implCreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
OControlElement::ElementType _eType);
};
/** helper class importing a single <form:grid> element
*/
class OGridImport : public OControlImport, public ODefaultEventAttacherManager
{
public:
OGridImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType);
// SvXMLImportContext overridables
virtual SvXMLImportContextRef CreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual void EndElement() override;
private:
// OElementImport overridables
virtual css::uno::Reference< css::beans::XPropertySet > createElement() override;
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer;
};
/** helper class importing a single <form:form> element
*/
class OFormImport : public OElementImport, public ODefaultEventAttacherManager
{
public:
OFormImport(
OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer
);
private:
// SvXMLImportContext overridables
virtual SvXMLImportContextRef CreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& _rxAttrList) override;
virtual void EndElement() override;
// OPropertyImport overridables
virtual bool handleAttribute(sal_uInt16 _nNamespaceKey,
const OUString& _rLocalName,
const OUString& _rValue) override;
// OElementImport overridables
virtual css::uno::Reference< css::beans::XPropertySet >
createElement() override;
OControlImport* implCreateChildContext(
sal_uInt16 _nPrefix, const OUString& _rLocalName,
OControlElement::ElementType _eType );
virtual OUString determineDefaultServiceName() const override;
void implTranslateStringListProperty(const OUString& _rPropertyName, const OUString& _rValue);
css::uno::Reference< css::container::XNameContainer > m_xMeAsContainer;
};
//= OXMLDataSourceImport
class OXMLDataSourceImport : public SvXMLImportContext
{
public:
OXMLDataSourceImport( SvXMLImport& _rImport
,sal_uInt16 nPrfx
,const OUString& rLName
,const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList
,const css::uno::Reference< css::beans::XPropertySet >& _xElement);
};
//= OColumnImport
template
OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
const css::uno::Reference< css::container::XNameContainer >& _rxParentContainer,
OControlElement::ElementType _eType)
:BASE(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer, _eType)
,m_xColumnFactory(_rxParentContainer, css::uno::UNO_QUERY)
{
OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
}
// OElementImport overridables
template
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;
}
} // namespace xmloff
#endif // INCLUDED_XMLOFF_SOURCE_FORMS_ELEMENTIMPORT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */