From 446be18a3e6636f40f6ae2f6f8749e068f48aad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 2 Oct 2015 11:38:11 +0100 Subject: [PATCH] make CppunitTest_sw_ww8export work again revert xmloff portion of commit 35e68754ec3cff30c5cdb665688a9b13f29dd439 Author: Noel Grandin Date: Thu Oct 1 15:10:56 2015 +0200 loplugin:unusedmethods Change-Id: I3d6f1300f4fae2af9e580d1d3b2c2c80fa9e9268 Reviewed-on: https://gerrit.libreoffice.org/19075 Reviewed-by: Noel Grandin Tested-by: Noel Grandin Change-Id: I24aa3f113a77d93c789b063b3c099bf2038e1dad --- xmloff/inc/DomExport.hxx | 1 + xmloff/source/core/DomExport.cxx | 6 ++ xmloff/source/forms/elementimport.hxx | 15 +++++ xmloff/source/forms/elementimport_impl.hxx | 67 ++++++++++++++++++++++ 4 files changed, 89 insertions(+) diff --git a/xmloff/inc/DomExport.hxx b/xmloff/inc/DomExport.hxx index c8c9a5d36906..6f88dc3bafb9 100644 --- a/xmloff/inc/DomExport.hxx +++ b/xmloff/inc/DomExport.hxx @@ -30,6 +30,7 @@ namespace com { namespace sun { namespace star { } } } void exportDom( SvXMLExport&, const com::sun::star::uno::Reference& ); +void exportDom( SvXMLExport&, const com::sun::star::uno::Reference& ); #endif diff --git a/xmloff/source/core/DomExport.cxx b/xmloff/source/core/DomExport.cxx index 450271858d19..ec55a174adc1 100644 --- a/xmloff/source/core/DomExport.cxx +++ b/xmloff/source/core/DomExport.cxx @@ -257,4 +257,10 @@ void exportDom( SvXMLExport& rExport, const Reference& xDocument ) visit( aDomExport, xDocument ); } +void exportDom( SvXMLExport& rExport, const Reference& xNode ) +{ + DomExport aDomExport( rExport ); + visit( aDomExport, xNode ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx index 0affa225123d..c74ba87ef0a5 100644 --- a/xmloff/source/forms/elementimport.hxx +++ b/xmloff/source/forms/elementimport.hxx @@ -572,7 +572,17 @@ namespace xmloff { } + // SvXMLImportContext overridables + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 _nPrefix, const OUString& _rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList); + virtual void EndElement(); + protected: + // OElementImport overridables + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + createElement(); + // create the child context for the given control type virtual SvXMLImportContext* implCreateControlWrapper( sal_uInt16 _nPrefix, const OUString& _rLocalName) = 0; @@ -595,6 +605,11 @@ namespace xmloff OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer, OControlElement::ElementType _eType); + + protected: + // OElementImport overridables + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + createElement(); }; //= OColumnWrapperImport diff --git a/xmloff/source/forms/elementimport_impl.hxx b/xmloff/source/forms/elementimport_impl.hxx index 16783673c19c..a9cfc99aa9c2 100644 --- a/xmloff/source/forms/elementimport_impl.hxx +++ b/xmloff/source/forms/elementimport_impl.hxx @@ -28,6 +28,58 @@ // no namespace. Same as above: this file is included from elementimport.hxx only, // and this is done inside the namespace +//= OContainerImport +template +inline SvXMLImportContext* OContainerImport< BASE >::CreateChildContext( + sal_uInt16 _nPrefix, const OUString& _rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList) +{ + // maybe it's a sub control + if (_rLocalName == m_sWrapperElementName) + { + if (m_xMeAsContainer.is()) + return implCreateControlWrapper(_nPrefix, _rLocalName); + else + { + OSL_FAIL("OContainerImport::CreateChildContext: don't have an element!"); + return NULL; + } + } + + return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList); +} + +template +inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + OContainerImport< BASE >::createElement() +{ + // let the base class create the object + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement(); + if (!xReturn.is()) + return xReturn; + + // ensure that the object is a XNameContainer (we strongly need this for inserting child elements) + m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY); + if (!m_xMeAsContainer.is()) + { + OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!"); + xReturn.clear(); + } + + return xReturn; +} + +template +inline void OContainerImport< BASE >::EndElement() +{ + BASE::EndElement(); + + // now that we have all children, attach the events + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY); + if (xIndexContainer.is()) + ODefaultEventAttacherManager::setEvents(xIndexContainer); +} + //= OColumnImport template OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName, @@ -39,4 +91,19 @@ OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventA OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!"); } +// OElementImport overridables +template +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement() +{ + ::com::sun::star::uno::Reference< ::com::sun::star::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; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */