cid#1607171 Data race condition
[LibreOffice.git] / framework / inc / xml / statusbardocumenthandler.hxx
blobc4cdb0429ed4a1be5e54be2b5a0def26d78b73a9
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 <statusbarconfiguration.hxx>
24 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
26 #include <rtl/ustring.hxx>
27 #include <rtl/ref.hxx>
28 #include <comphelper/attributelist.hxx>
29 #include <cppuhelper/implbase.hxx>
31 #include <unordered_map>
33 namespace framework{
35 // Hash code function for using in all hash maps of follow implementation.
37 // workaround for incremental linking bugs in MSVC2015
38 class SAL_DLLPUBLIC_TEMPLATE OReadStatusBarDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};
40 class OReadStatusBarDocumentHandler final : public OReadStatusBarDocumentHandler_Base
42 public:
43 enum StatusBar_XML_Entry
45 SB_ELEMENT_STATUSBAR,
46 SB_ELEMENT_STATUSBARITEM,
47 SB_ATTRIBUTE_URL,
48 SB_ATTRIBUTE_ALIGN,
49 SB_ATTRIBUTE_STYLE,
50 SB_ATTRIBUTE_AUTOSIZE,
51 SB_ATTRIBUTE_OWNERDRAW,
52 SB_ATTRIBUTE_WIDTH,
53 SB_ATTRIBUTE_OFFSET,
54 SB_ATTRIBUTE_HELPURL,
55 SB_ATTRIBUTE_MANDATORY,
56 SB_XML_ENTRY_COUNT
59 enum StatusBar_XML_Namespace
61 SB_NS_STATUSBAR,
62 SB_NS_XLINK
65 OReadStatusBarDocumentHandler( const css::uno::Reference< css::container::XIndexContainer >& aStatusBarItems );
66 virtual ~OReadStatusBarDocumentHandler() override;
68 // XDocumentHandler
69 virtual void SAL_CALL startDocument() override;
71 virtual void SAL_CALL endDocument() override;
73 virtual void SAL_CALL startElement(
74 const OUString& aName,
75 const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
77 virtual void SAL_CALL endElement(const OUString& aName) override;
79 virtual void SAL_CALL characters(const OUString& aChars) override;
81 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
83 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
84 const OUString& aData) override;
86 virtual void SAL_CALL setDocumentLocator(
87 const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
89 private:
90 OUString getErrorLineString();
92 class StatusBarHashMap : public std::unordered_map<OUString,
93 StatusBar_XML_Entry >
97 bool m_bStatusBarStartFound;
98 bool m_bStatusBarItemStartFound;
99 StatusBarHashMap m_aStatusBarMap;
100 css::uno::Reference< css::container::XIndexContainer > m_aStatusBarItems;
101 css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
104 class OWriteStatusBarDocumentHandler final
106 public:
107 OWriteStatusBarDocumentHandler(
108 const css::uno::Reference< css::container::XIndexAccess >& rStatusBarItems,
109 const css::uno::Reference< css::xml::sax::XDocumentHandler >& rWriteDocHandler );
110 ~OWriteStatusBarDocumentHandler();
112 /// @throws css::xml::sax::SAXException
113 /// @throws css::uno::RuntimeException
114 void WriteStatusBarDocument();
116 private:
117 /// @throws css::xml::sax::SAXException
118 /// @throws css::uno::RuntimeException
119 void WriteStatusBarItem(
120 const OUString& rCommandURL,
121 sal_Int16 nOffset,
122 sal_Int16 nStyle,
123 sal_Int16 nWidth );
125 css::uno::Reference< css::container::XIndexAccess > m_aStatusBarItems;
126 css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
127 OUString m_aXMLStatusBarNS;
128 OUString m_aXMLXlinkNS;
129 OUString m_aAttributeURL;
132 } // namespace framework
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */