Avoid new string allocations, when only checking if empty
[LibreOffice.git] / xmlscript / source / xmlmod_imexp / imp_share.hxx
blob62bde2e30a00f1749d08f3f16e10fb2253cf1eb5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <xmlscript/xmlmod_imexp.hxx>
24 #include <cppuhelper/implbase.hxx>
25 #include <rtl/ustrbuf.hxx>
26 #include <rtl/ref.hxx>
28 #include <com/sun/star/xml/input/XRoot.hpp>
30 namespace xmlscript
33 // Script module import
35 struct ModuleImport
36 : public ::cppu::WeakImplHelper< css::xml::input::XRoot >
38 friend class ModuleElement;
40 ModuleDescriptor& mrModuleDesc;
42 sal_Int32 XMLNS_SCRIPT_UID;
44 public:
45 explicit ModuleImport(ModuleDescriptor& rModuleDesc)
46 : mrModuleDesc(rModuleDesc)
47 , XMLNS_SCRIPT_UID(0)
51 virtual ~ModuleImport() override;
53 // XRoot
54 virtual void SAL_CALL startDocument(
55 css::uno::Reference< css::xml::input::XNamespaceMapping > const & xNamespaceMapping ) override;
56 virtual void SAL_CALL endDocument() override;
57 virtual void SAL_CALL processingInstruction(
58 OUString const & rTarget, OUString const & rData ) override;
59 virtual void SAL_CALL setDocumentLocator(
60 css::uno::Reference< css::xml::sax::XLocator > const & xLocator ) override;
61 virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startRootElement(
62 sal_Int32 nUid, OUString const & rLocalName,
63 css::uno::Reference< css::xml::input::XAttributes > const & xAttributes ) override;
66 class ModuleElement
67 : public ::cppu::WeakImplHelper< css::xml::input::XElement >
69 rtl::Reference<ModuleImport> mxImport;
71 OUString const _aLocalName;
72 css::uno::Reference< css::xml::input::XAttributes > _xAttributes;
73 OUStringBuffer _strBuffer{512};
75 public:
76 ModuleElement(
77 OUString aLocalName,
78 css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
79 ModuleImport * pImport );
80 virtual ~ModuleElement() override;
82 // XElement
83 virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL getParent() override;
84 virtual OUString SAL_CALL getLocalName() override;
85 virtual sal_Int32 SAL_CALL getUid() override;
86 virtual css::uno::Reference< css::xml::input::XAttributes > SAL_CALL getAttributes() override;
87 virtual void SAL_CALL ignorableWhitespace(
88 OUString const & rWhitespaces ) override;
89 virtual void SAL_CALL characters( OUString const & rChars ) override;
90 virtual void SAL_CALL processingInstruction(
91 OUString const & rTarget, OUString const & rData ) override;
92 virtual void SAL_CALL endElement() override;
93 virtual css::uno::Reference< css::xml::input::XElement > SAL_CALL startChildElement(
94 sal_Int32 nUid, OUString const & rLocalName,
95 css::uno::Reference< css::xml::input::XAttributes > const & xAttributes ) override;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */