LibreOffice Module xmloff (master)  1
XMLAutoTextEventImport.cxx
Go to the documentation of this file.
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 
21 #include <com/sun/star/uno/Reference.hxx>
22 #include <com/sun/star/document/XEventsSupplier.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <xmloff/xmlnamespace.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <tools/debug.hxx>
30 
31 using namespace ::com::sun::star;
32 
33 using ::com::sun::star::uno::Any;
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::Sequence;
36 using ::com::sun::star::uno::Type;
37 using ::com::sun::star::uno::XInterface;
38 using ::com::sun::star::document::XEventsSupplier;
39 using ::com::sun::star::container::XNameReplace;
40 using ::com::sun::star::lang::XMultiServiceFactory;
42 
44  const css::uno::Reference< css::uno::XComponentContext >& xContext)
45 : SvXMLImport(xContext, "")
46 {
47 }
48 
50 {
51 }
52 
54  const Sequence<Any> & rArguments )
55 {
56  // The events may come as either an XNameReplace or XEventsSupplier.
57 
58  for( const auto& rArgument : rArguments )
59  {
60  const Type& rType = rArgument.getValueType();
62  {
63  Reference<XEventsSupplier> xSupplier;
64  rArgument >>= xSupplier;
65  DBG_ASSERT(xSupplier.is(), "need XEventsSupplier or XNameReplace");
66 
67  xEvents = xSupplier->getEvents();
68  }
69  else if (rType == cppu::UnoType<XNameReplace>::get())
70  {
71  rArgument >>= xEvents;
72  DBG_ASSERT(xEvents.is(), "need XEventsSupplier or XNameReplace");
73  }
74  }
75 
76  // call parent
77  SvXMLImport::initialize(rArguments);
78 }
79 
80 
82  sal_Int32 nElement,
83  const Reference<css::xml::sax::XFastAttributeList> & /*xAttrList*/ )
84 {
85  if ( xEvents.is() && nElement == XML_ELEMENT(OOO, XML_AUTO_TEXT_EVENTS) )
86  {
87  return new XMLAutoTextContainerEventImport(*this, xEvents);
88  }
89  return nullptr;
90 }
91 
92 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
94  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
95 {
96  return cppu::acquire(new XMLAutoTextEventImport(context));
97 }
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
virtual ~XMLAutoTextEventImport() override
virtual SvXMLImportContext * CreateFastContext(sal_Int32 Element, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Import the text:auto-text-container element.
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1033
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
#define DBG_ASSERT(sCon, aError)
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
XMLAutoTextEventImport(const css::uno::Reference< css::uno::XComponentContext > &xContext)
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:94
css::uno::Reference< css::container::XNameReplace > xEvents
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_Writer_XMLOasisAutotextEventsImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)