tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / framework / inc / xml / toolboxdocumenthandler.hxx
blobf134054267aed295f7faf1ffd8426cc1a435d07f
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 <toolboxconfiguration.hxx>
24 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
26 #include <rtl/ustring.hxx>
27 #include <cppuhelper/implbase.hxx>
29 #include <unordered_map>
31 namespace framework{
33 // Hash code function for using in all hash maps of follow implementation.
35 // workaround for incremental linking bugs in MSVC2015
36 class SAL_DLLPUBLIC_TEMPLATE OReadToolBoxDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};
38 class OReadToolBoxDocumentHandler final : public OReadToolBoxDocumentHandler_Base
40 public:
41 enum ToolBox_XML_Entry
43 TB_ELEMENT_TOOLBAR,
44 TB_ELEMENT_TOOLBARITEM,
45 TB_ELEMENT_TOOLBARSPACE,
46 TB_ELEMENT_TOOLBARBREAK,
47 TB_ELEMENT_TOOLBARSEPARATOR,
48 TB_ATTRIBUTE_TEXT,
49 TB_ATTRIBUTE_URL,
50 TB_ATTRIBUTE_VISIBLE,
51 TB_ATTRIBUTE_STYLE,
52 TB_ATTRIBUTE_UINAME,
53 TB_XML_ENTRY_COUNT
56 enum ToolBox_XML_Namespace
58 TB_NS_TOOLBAR,
59 TB_NS_XLINK
62 OReadToolBoxDocumentHandler( const css::uno::Reference< css::container::XIndexContainer >& rItemContainer );
63 virtual ~OReadToolBoxDocumentHandler() override;
65 // XDocumentHandler
66 virtual void SAL_CALL startDocument() override;
68 virtual void SAL_CALL endDocument() override;
70 virtual void SAL_CALL startElement(
71 const OUString& aName,
72 const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
74 virtual void SAL_CALL endElement(const OUString& aName) override;
76 virtual void SAL_CALL characters(const OUString& aChars) override;
78 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
80 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
81 const OUString& aData) override;
83 virtual void SAL_CALL setDocumentLocator(
84 const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
86 private:
87 OUString getErrorLineString();
89 class ToolBoxHashMap : public std::unordered_map<OUString,
90 ToolBox_XML_Entry>
94 bool m_bToolBarStartFound : 1;
95 bool m_bToolBarItemStartFound : 1;
96 bool m_bToolBarSpaceStartFound : 1;
97 bool m_bToolBarBreakStartFound : 1;
98 bool m_bToolBarSeparatorStartFound : 1;
99 ToolBoxHashMap m_aToolBoxMap;
100 css::uno::Reference< css::container::XIndexContainer > m_rItemContainer;
101 css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
103 OUString m_aType;
104 OUString m_aLabel;
105 OUString m_aStyle;
106 OUString m_aIsVisible;
107 OUString m_aCommandURL;
110 class OWriteToolBoxDocumentHandler final
112 public:
113 OWriteToolBoxDocumentHandler(
114 const css::uno::Reference< css::container::XIndexAccess >& rItemAccess,
115 css::uno::Reference< css::xml::sax::XDocumentHandler > const & rDocumentHandler );
116 ~OWriteToolBoxDocumentHandler();
118 /// @throws css::xml::sax::SAXException
119 /// @throws css::uno::RuntimeException
120 void WriteToolBoxDocument();
122 private:
123 /// @throws css::xml::sax::SAXException
124 /// @throws css::uno::RuntimeException
125 void WriteToolBoxItem( const OUString& aCommandURL, const OUString& aLabel, sal_Int16 nStyle, bool bVisible );
127 /// @throws css::xml::sax::SAXException
128 /// @throws css::uno::RuntimeException
129 void WriteToolBoxSpace();
131 /// @throws css::xml::sax::SAXException
132 /// @throws css::uno::RuntimeException
133 void WriteToolBoxBreak();
135 /// @throws css::xml::sax::SAXException
136 /// @throws css::uno::RuntimeException
137 void WriteToolBoxSeparator();
139 css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
140 css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
141 css::uno::Reference< css::container::XIndexAccess > m_rItemAccess;
142 OUString m_aXMLToolbarNS;
143 OUString m_aXMLXlinkNS;
144 OUString m_aAttributeURL;
147 } // namespace framework
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */