summaryrefslogtreecommitdiffstats
path: root/framework/inc/xml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--framework/inc/xml/acceleratorconfigurationreader.hxx133
-rw-r--r--framework/inc/xml/acceleratorconfigurationwriter.hxx78
-rw-r--r--framework/inc/xml/imagesconfiguration.hxx54
-rw-r--r--framework/inc/xml/imagesdocumenthandler.hxx133
-rw-r--r--framework/inc/xml/menudocumenthandler.hxx222
-rw-r--r--framework/inc/xml/saxnamespacefilter.hxx74
-rw-r--r--framework/inc/xml/statusbardocumenthandler.hxx134
-rw-r--r--framework/inc/xml/toolboxconfigurationdefines.hxx67
-rw-r--r--framework/inc/xml/toolboxdocumenthandler.hxx158
-rw-r--r--framework/inc/xml/xmlnamespaces.hxx52
10 files changed, 1105 insertions, 0 deletions
diff --git a/framework/inc/xml/acceleratorconfigurationreader.hxx b/framework/inc/xml/acceleratorconfigurationreader.hxx
new file mode 100644
index 000000000..775463013
--- /dev/null
+++ b/framework/inc/xml/acceleratorconfigurationreader.hxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <accelerators/acceleratorcache.hxx>
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+
+#include <com/sun/star/xml/sax/XLocator.hpp>
+
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ustring.hxx>
+
+namespace framework{
+
+class AcceleratorConfigurationReader final : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
+{
+
+ // const, types
+
+ private:
+
+ /** @short classification of XML elements. */
+ enum EXMLElement
+ {
+ E_ELEMENT_ACCELERATORLIST,
+ E_ELEMENT_ITEM
+ };
+
+ /** @short classification of XML attributes. */
+ enum EXMLAttribute
+ {
+ E_ATTRIBUTE_KEYCODE,
+ E_ATTRIBUTE_MOD_SHIFT,
+ E_ATTRIBUTE_MOD_MOD1,
+ E_ATTRIBUTE_MOD_MOD2,
+ E_ATTRIBUTE_MOD_MOD3,
+ E_ATTRIBUTE_URL
+ };
+
+ // member
+
+ private:
+
+ /** @short reference to the outside container, where this
+ reader/writer must work on. */
+ AcceleratorCache& m_rContainer;
+
+ /** @short used to detect if an accelerator list
+ occurs recursive inside xml. */
+ bool m_bInsideAcceleratorList;
+
+ /** @short used to detect if an accelerator item
+ occurs recursive inside xml. */
+ bool m_bInsideAcceleratorItem;
+
+ /** @short provide information about the parsing state.
+
+ @descr We use it to find out the line and column, where
+ an error occurred.
+ */
+ css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
+
+ // interface
+
+ public:
+
+ /** @short connect this new reader/writer instance
+ to an outside container, which should be used
+ flushed to the underlying XML configuration or
+ filled from there.
+
+ @param rContainer
+ a reference to the outside container.
+ */
+ AcceleratorConfigurationReader(AcceleratorCache& rContainer);
+
+ /** @short does nothing real ... */
+ virtual ~AcceleratorConfigurationReader() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(const OUString& sElement ,
+ const css::uno::Reference< css::xml::sax::XAttributeList >& xAttributeList) override;
+
+ virtual void SAL_CALL endElement(const OUString& sElement) override;
+
+ virtual void SAL_CALL characters(const OUString& sChars) override;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& sWhitespaces) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& sTarget,
+ const OUString& sData ) override;
+
+ virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator >& xLocator) override;
+
+ // helper
+
+ private:
+
+ /** TODO document me */
+ static EXMLElement implst_classifyElement(std::u16string_view sElement);
+
+ /** TODO document me */
+ static EXMLAttribute implst_classifyAttribute(std::u16string_view sAttribute);
+
+ /** TODO document me */
+ OUString implts_getErrorLineString();
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/acceleratorconfigurationwriter.hxx b/framework/inc/xml/acceleratorconfigurationwriter.hxx
new file mode 100644
index 000000000..ae5580675
--- /dev/null
+++ b/framework/inc/xml/acceleratorconfigurationwriter.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <accelerators/acceleratorcache.hxx>
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <rtl/ustring.hxx>
+
+namespace framework{
+
+class AcceleratorConfigurationWriter final
+{
+
+ // member
+
+ private:
+
+ /** @short needed to write the xml configuration. */
+ css::uno::Reference< css::xml::sax::XDocumentHandler > m_xConfig;
+
+ /** @short reference to the outside container, where this
+ writer must work on. */
+ const AcceleratorCache& m_rContainer;
+
+ // interface
+
+ public:
+
+ /** @short connect this new writer instance
+ to an outside container, which should be
+ flushed to the underlying XML configuration.
+
+ @param rContainer
+ a reference to the outside container.
+
+ @param xConfig
+ used to write the configuration there.
+ */
+ AcceleratorConfigurationWriter(const AcceleratorCache& rContainer,
+ css::uno::Reference< css::xml::sax::XDocumentHandler > xConfig );
+
+ /** @short does nothing real ... */
+ ~AcceleratorConfigurationWriter();
+
+ /** @short TODO */
+ void flush();
+
+ // helper
+
+ private:
+
+ /** @short TODO */
+ void impl_ts_writeKeyCommandPair(const css::awt::KeyEvent& aKey ,
+ const OUString& sCommand,
+ const css::uno::Reference< css::xml::sax::XDocumentHandler >& xConfig );
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx
new file mode 100644
index 000000000..4b17b7c98
--- /dev/null
+++ b/framework/inc/xml/imagesconfiguration.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vector>
+
+namespace framework
+{
+
+struct ImageItemDescriptor
+{
+ OUString aCommandURL; // URL command to dispatch
+};
+
+typedef std::vector<ImageItemDescriptor> ImageItemDescriptorList;
+
+class ImagesConfiguration
+{
+ public:
+ static bool LoadImages(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XInputStream >& rInputStream,
+ ImageItemDescriptorList& rItems );
+
+ static bool StoreImages(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::io::XOutputStream >& rOutputStream,
+ const ImageItemDescriptorList& rItems );
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx
new file mode 100644
index 000000000..d8cd84f4d
--- /dev/null
+++ b/framework/inc/xml/imagesdocumenthandler.hxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+
+#include <xml/imagesconfiguration.hxx>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <unordered_map>
+
+namespace framework{
+
+// Hash code function for using in all hash maps of follow implementation.
+
+class OReadImagesDocumentHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
+{
+ public:
+ enum Image_XML_Entry
+ {
+ IMG_ELEMENT_IMAGECONTAINER,
+ IMG_ELEMENT_IMAGES,
+ IMG_ELEMENT_ENTRY,
+ IMG_ELEMENT_EXTERNALIMAGES,
+ IMG_ELEMENT_EXTERNALENTRY,
+ IMG_ATTRIBUTE_HREF,
+ IMG_ATTRIBUTE_MASKCOLOR,
+ IMG_ATTRIBUTE_COMMAND,
+ IMG_ATTRIBUTE_BITMAPINDEX,
+ IMG_ATTRIBUTE_MASKURL,
+ IMG_ATTRIBUTE_MASKMODE,
+ IMG_ATTRIBUTE_HIGHCONTRASTURL,
+ IMG_ATTRIBUTE_HIGHCONTRASTMASKURL,
+ IMG_XML_ENTRY_COUNT
+ };
+
+ enum Image_XML_Namespace
+ {
+ IMG_NS_IMAGE,
+ IMG_NS_XLINK
+ };
+
+ OReadImagesDocumentHandler( ImageItemDescriptorList& aItems );
+ virtual ~OReadImagesDocumentHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& aTarget,
+ const OUString& aData) override;
+
+ virtual void SAL_CALL setDocumentLocator(
+ const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
+
+ private:
+ OUString getErrorLineString();
+
+ class ImageHashMap : public std::unordered_map< OUString, Image_XML_Entry >
+ {
+ };
+
+ bool m_bImageContainerStartFound;
+ bool m_bImageContainerEndFound;
+ bool m_bImagesStartFound;
+ ImageHashMap m_aImageMap;
+ ImageItemDescriptorList& m_rImageList;
+ css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
+};
+
+class OWriteImagesDocumentHandler final
+{
+ public:
+ OWriteImagesDocumentHandler(
+ const ImageItemDescriptorList& aItems,
+ css::uno::Reference< css::xml::sax::XDocumentHandler > const &
+ rWriteDocumentHandler);
+ ~OWriteImagesDocumentHandler();
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteImagesDocument();
+
+ private:
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteImageList( const ImageItemDescriptorList* );
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteImage( const ImageItemDescriptor* );
+
+ const ImageItemDescriptorList& m_rImageItemList;
+ css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
+ css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
+ OUString m_aXMLImageNS;
+ OUString m_aAttributeType;
+ OUString m_aAttributeXlinkType;
+ OUString m_aAttributeValueSimple;
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/menudocumenthandler.hxx b/framework/inc/xml/menudocumenthandler.hxx
new file mode 100644
index 000000000..f3a0238d0
--- /dev/null
+++ b/framework/inc/xml/menudocumenthandler.hxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase.hxx>
+
+namespace framework{
+
+class ReadMenuDocumentHandlerBase : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
+{
+ public:
+ ReadMenuDocumentHandlerBase();
+ virtual ~ReadMenuDocumentHandlerBase() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override = 0;
+
+ virtual void SAL_CALL endDocument() override = 0;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override = 0;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override = 0;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override = 0;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& aTarget,
+ const OUString& aData) override;
+
+ virtual void SAL_CALL setDocumentLocator(
+ const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
+
+ protected:
+ OUString getErrorLineString();
+
+ css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
+ css::uno::Reference< css::xml::sax::XDocumentHandler> m_xReader;
+ void initPropertyCommon( css::uno::Sequence< css::beans::PropertyValue > &rProps,
+ const OUString &rCommandURL, const OUString &rHelpId,
+ const OUString &rLabel, sal_Int16 nItemStyleBits );
+ private:
+ OUString m_aType;
+ OUString m_aLabel;
+ OUString m_aContainer;
+ OUString m_aHelpURL;
+ OUString m_aCommandURL;
+ OUString m_aStyle;
+};
+
+class OReadMenuDocumentHandler final : public ReadMenuDocumentHandlerBase
+{
+ public:
+ OReadMenuDocumentHandler(
+ const css::uno::Reference< css::container::XIndexContainer >& rItemContainer );
+ virtual ~OReadMenuDocumentHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ private:
+ int m_nElementDepth;
+ enum class ReaderMode { None, MenuBar, MenuPopup };
+ ReaderMode m_eReaderMode;
+ css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer;
+ css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
+}; // OReadMenuDocumentHandler
+
+class OReadMenuBarHandler final : public ReadMenuDocumentHandlerBase
+{
+ public:
+ OReadMenuBarHandler(
+ const css::uno::Reference< css::container::XIndexContainer >& rMenuBarContainer,
+ const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory );
+ virtual ~OReadMenuBarHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ private:
+ int m_nElementDepth;
+ bool m_bMenuMode;
+ css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer;
+ css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
+}; // OReadMenuBarHandler
+
+class OReadMenuHandler final : public ReadMenuDocumentHandlerBase
+{
+ public:
+ OReadMenuHandler( const css::uno::Reference< css::container::XIndexContainer >& rMenuContainer,
+ const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory );
+ virtual ~OReadMenuHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ private:
+ int m_nElementDepth;
+ bool m_bMenuPopupMode;
+ css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer;
+ css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
+}; // OReadMenuHandler
+
+class OReadMenuPopupHandler final : public ReadMenuDocumentHandlerBase
+{
+ public:
+ OReadMenuPopupHandler( const css::uno::Reference< css::container::XIndexContainer >& rMenuContainer,
+ const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory );
+ virtual ~OReadMenuPopupHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference<
+ css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ private:
+ enum NextElementClose { ELEM_CLOSE_NONE, ELEM_CLOSE_MENUITEM, ELEM_CLOSE_MENUSEPARATOR };
+
+ int m_nElementDepth;
+ bool m_bMenuMode;
+ css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer;
+ css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
+ css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
+ NextElementClose m_nNextElementExpected;
+}; // OReadMenuPopupHandler
+
+class OWriteMenuDocumentHandler final
+{
+ public:
+ OWriteMenuDocumentHandler(
+ const css::uno::Reference< css::container::XIndexAccess >& rMenuBarContainer,
+ const css::uno::Reference< css::xml::sax::XDocumentHandler >& rDocumentHandler,
+ bool bIsMenuBar );
+ ~OWriteMenuDocumentHandler();
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteMenuDocument();
+ private:
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteMenu( const css::uno::Reference< css::container::XIndexAccess >& rSubMenuContainer );
+
+ void WriteMenuItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, sal_Int16 nStyle );
+ void WriteMenuSeparator();
+
+ css::uno::Reference< css::container::XIndexAccess > m_xMenuBarContainer;
+ css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
+ css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
+ OUString m_aAttributeType;
+ bool m_bIsMenuBar;
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/saxnamespacefilter.hxx b/framework/inc/xml/saxnamespacefilter.hxx
new file mode 100644
index 000000000..04f5bd4fe
--- /dev/null
+++ b/framework/inc/xml/saxnamespacefilter.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <xml/xmlnamespaces.hxx>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <stack>
+
+namespace framework
+{
+
+// workaround for incremental linking bugs in MSVC2015
+class SAL_DLLPUBLIC_TEMPLATE SaxNamespaceFilter_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};
+
+class SaxNamespaceFilter final : public SaxNamespaceFilter_Base
+{
+ public:
+ SaxNamespaceFilter( css::uno::Reference< css::xml::sax::XDocumentHandler > const & rSax1DocumentHandler );
+ virtual ~SaxNamespaceFilter() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& aTarget,
+ const OUString& aData) override;
+
+ virtual void SAL_CALL setDocumentLocator(
+ const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
+
+ private:
+ typedef ::std::stack< XMLNamespaces > NamespaceStack;
+
+ OUString getErrorLineString();
+
+ css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
+ css::uno::Reference< css::xml::sax::XDocumentHandler> xDocumentHandler;
+ NamespaceStack m_aNamespaceStack;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/statusbardocumenthandler.hxx b/framework/inc/xml/statusbardocumenthandler.hxx
new file mode 100644
index 000000000..829cd0b97
--- /dev/null
+++ b/framework/inc/xml/statusbardocumenthandler.hxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <statusbarconfiguration.hxx>
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <unordered_map>
+
+namespace framework{
+
+// Hash code function for using in all hash maps of follow implementation.
+
+// workaround for incremental linking bugs in MSVC2015
+class SAL_DLLPUBLIC_TEMPLATE OReadStatusBarDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};
+
+class OReadStatusBarDocumentHandler final : public OReadStatusBarDocumentHandler_Base
+{
+ public:
+ enum StatusBar_XML_Entry
+ {
+ SB_ELEMENT_STATUSBAR,
+ SB_ELEMENT_STATUSBARITEM,
+ SB_ATTRIBUTE_URL,
+ SB_ATTRIBUTE_ALIGN,
+ SB_ATTRIBUTE_STYLE,
+ SB_ATTRIBUTE_AUTOSIZE,
+ SB_ATTRIBUTE_OWNERDRAW,
+ SB_ATTRIBUTE_WIDTH,
+ SB_ATTRIBUTE_OFFSET,
+ SB_ATTRIBUTE_HELPURL,
+ SB_ATTRIBUTE_MANDATORY,
+ SB_XML_ENTRY_COUNT
+ };
+
+ enum StatusBar_XML_Namespace
+ {
+ SB_NS_STATUSBAR,
+ SB_NS_XLINK
+ };
+
+ OReadStatusBarDocumentHandler( const css::uno::Reference< css::container::XIndexContainer >& aStatusBarItems );
+ virtual ~OReadStatusBarDocumentHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& aTarget,
+ const OUString& aData) override;
+
+ virtual void SAL_CALL setDocumentLocator(
+ const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
+
+ private:
+ OUString getErrorLineString();
+
+ class StatusBarHashMap : public std::unordered_map<OUString,
+ StatusBar_XML_Entry >
+ {
+ };
+
+ bool m_bStatusBarStartFound;
+ bool m_bStatusBarItemStartFound;
+ StatusBarHashMap m_aStatusBarMap;
+ css::uno::Reference< css::container::XIndexContainer > m_aStatusBarItems;
+ css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
+};
+
+class OWriteStatusBarDocumentHandler final
+{
+ public:
+ OWriteStatusBarDocumentHandler(
+ const css::uno::Reference< css::container::XIndexAccess >& rStatusBarItems,
+ const css::uno::Reference< css::xml::sax::XDocumentHandler >& rWriteDocHandler );
+ ~OWriteStatusBarDocumentHandler();
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteStatusBarDocument();
+
+ private:
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteStatusBarItem(
+ const OUString& rCommandURL,
+ sal_Int16 nOffset,
+ sal_Int16 nStyle,
+ sal_Int16 nWidth );
+
+ css::uno::Reference< css::container::XIndexAccess > m_aStatusBarItems;
+ css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
+ css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
+ OUString m_aXMLStatusBarNS;
+ OUString m_aXMLXlinkNS;
+ OUString m_aAttributeType;
+ OUString m_aAttributeURL;
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/toolboxconfigurationdefines.hxx b/framework/inc/xml/toolboxconfigurationdefines.hxx
new file mode 100644
index 000000000..399693044
--- /dev/null
+++ b/framework/inc/xml/toolboxconfigurationdefines.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <rtl/ustring.hxx>
+
+#define XMLNS_TOOLBAR "http://openoffice.org/2001/toolbar"
+#define XMLNS_XLINK "http://www.w3.org/1999/xlink"
+inline constexpr OUStringLiteral XMLNS_TOOLBAR_PREFIX = u"toolbar:";
+#define XMLNS_XLINK_PREFIX "xlink:"
+
+#define XMLNS_FILTER_SEPARATOR "^"
+
+#define ELEMENT_TOOLBAR "toolbar"
+#define ELEMENT_TOOLBARITEM "toolbaritem"
+#define ELEMENT_TOOLBARSPACE "toolbarspace"
+#define ELEMENT_TOOLBARBREAK "toolbarbreak"
+#define ELEMENT_TOOLBARSEPARATOR "toolbarseparator"
+
+#define ATTRIBUTE_UINAME "uiname"
+
+#define ATTRIBUTE_TEXT "text"
+#define ATTRIBUTE_URL "href"
+#define ATTRIBUTE_VISIBLE "visible"
+#define ATTRIBUTE_ITEMSTYLE "style"
+
+inline constexpr OUStringLiteral ELEMENT_NS_TOOLBAR = u"toolbar:toolbar";
+inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARITEM = u"toolbar:toolbaritem";
+inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARSPACE = u"toolbar:toolbarspace";
+inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARBREAK = u"toolbar:toolbarbreak";
+inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARSEPARATOR = u"toolbar:toolbarseparator";
+
+inline constexpr OUStringLiteral ATTRIBUTE_XMLNS_TOOLBAR = u"xmlns:toolbar";
+inline constexpr OUStringLiteral ATTRIBUTE_XMLNS_XLINK = u"xmlns:xlink";
+
+inline constexpr OUStringLiteral ATTRIBUTE_TYPE_CDATA = u"CDATA";
+
+#define ATTRIBUTE_BOOLEAN_TRUE "true"
+inline constexpr OUStringLiteral ATTRIBUTE_BOOLEAN_FALSE = u"false";
+
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_RADIO = u"radio";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_AUTO = u"auto";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_LEFT = u"left";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_AUTOSIZE = u"autosize";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_DROPDOWN = u"dropdown";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_REPEAT = u"repeat";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_TEXT = u"text";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY = u"dropdownonly";
+inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_IMAGE = u"image";
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx
new file mode 100644
index 000000000..79657e532
--- /dev/null
+++ b/framework/inc/xml/toolboxdocumenthandler.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <toolboxconfiguration.hxx>
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <unordered_map>
+
+namespace framework{
+
+// Hash code function for using in all hash maps of follow implementation.
+
+// workaround for incremental linking bugs in MSVC2015
+class SAL_DLLPUBLIC_TEMPLATE OReadToolBoxDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};
+
+class OReadToolBoxDocumentHandler final : public OReadToolBoxDocumentHandler_Base
+{
+ public:
+ enum ToolBox_XML_Entry
+ {
+ TB_ELEMENT_TOOLBAR,
+ TB_ELEMENT_TOOLBARITEM,
+ TB_ELEMENT_TOOLBARSPACE,
+ TB_ELEMENT_TOOLBARBREAK,
+ TB_ELEMENT_TOOLBARSEPARATOR,
+ TB_ATTRIBUTE_TEXT,
+ TB_ATTRIBUTE_URL,
+ TB_ATTRIBUTE_VISIBLE,
+ TB_ATTRIBUTE_STYLE,
+ TB_ATTRIBUTE_UINAME,
+ TB_XML_ENTRY_COUNT
+ };
+
+ enum ToolBox_XML_Namespace
+ {
+ TB_NS_TOOLBAR,
+ TB_NS_XLINK
+ };
+
+ OReadToolBoxDocumentHandler( const css::uno::Reference< css::container::XIndexContainer >& rItemContainer );
+ virtual ~OReadToolBoxDocumentHandler() override;
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() override;
+
+ virtual void SAL_CALL endDocument() override;
+
+ virtual void SAL_CALL startElement(
+ const OUString& aName,
+ const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) override;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& aTarget,
+ const OUString& aData) override;
+
+ virtual void SAL_CALL setDocumentLocator(
+ const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
+
+ private:
+ OUString getErrorLineString();
+
+ class ToolBoxHashMap : public std::unordered_map<OUString,
+ ToolBox_XML_Entry>
+ {
+ };
+
+ bool m_bToolBarStartFound : 1;
+ bool m_bToolBarItemStartFound : 1;
+ bool m_bToolBarSpaceStartFound : 1;
+ bool m_bToolBarBreakStartFound : 1;
+ bool m_bToolBarSeparatorStartFound : 1;
+ ToolBoxHashMap m_aToolBoxMap;
+ css::uno::Reference< css::container::XIndexContainer > m_rItemContainer;
+ css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
+
+ sal_Int32 m_nHashCode_Style_Radio;
+ sal_Int32 m_nHashCode_Style_Left;
+ sal_Int32 m_nHashCode_Style_AutoSize;
+ sal_Int32 m_nHashCode_Style_DropDown;
+ sal_Int32 m_nHashCode_Style_Repeat;
+ sal_Int32 m_nHashCode_Style_DropDownOnly;
+ sal_Int32 m_nHashCode_Style_Text;
+ sal_Int32 m_nHashCode_Style_Image;
+ OUString m_aType;
+ OUString m_aLabel;
+ OUString m_aStyle;
+ OUString m_aIsVisible;
+ OUString m_aCommandURL;
+};
+
+class OWriteToolBoxDocumentHandler final
+{
+ public:
+ OWriteToolBoxDocumentHandler(
+ const css::uno::Reference< css::container::XIndexAccess >& rItemAccess,
+ css::uno::Reference< css::xml::sax::XDocumentHandler > const & rDocumentHandler );
+ ~OWriteToolBoxDocumentHandler();
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteToolBoxDocument();
+
+ private:
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteToolBoxItem( const OUString& aCommandURL, const OUString& aLabel, sal_Int16 nStyle, bool bVisible );
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteToolBoxSpace();
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteToolBoxBreak();
+
+ /// @throws css::xml::sax::SAXException
+ /// @throws css::uno::RuntimeException
+ void WriteToolBoxSeparator();
+
+ css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
+ css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
+ css::uno::Reference< css::container::XIndexAccess > m_rItemAccess;
+ OUString m_aXMLToolbarNS;
+ OUString m_aXMLXlinkNS;
+ OUString m_aAttributeType;
+ OUString m_aAttributeURL;
+};
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/xml/xmlnamespaces.hxx b/framework/inc/xml/xmlnamespaces.hxx
new file mode 100644
index 000000000..1c01b03cc
--- /dev/null
+++ b/framework/inc/xml/xmlnamespaces.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <map>
+
+#include <rtl/ustring.hxx>
+
+namespace framework
+{
+
+class XMLNamespaces final
+{
+ public:
+ /// @throws css::xml::sax::SAXException
+ void addNamespace( const OUString& aName, const OUString& aValue );
+
+ /// @throws css::xml::sax::SAXException
+ OUString applyNSToAttributeName( const OUString& ) const;
+ /// @throws css::xml::sax::SAXException
+ OUString applyNSToElementName( const OUString& ) const;
+
+ private:
+ typedef ::std::map< OUString, OUString > NamespaceMap;
+
+ /// @throws css::xml::sax::SAXException
+ OUString const & getNamespaceValue( const OUString& aNamespace ) const;
+
+ OUString m_aDefaultNamespace;
+ NamespaceMap m_aNamespaceMap;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */