diff options
Diffstat (limited to '')
-rw-r--r-- | framework/inc/xml/acceleratorconfigurationreader.hxx | 136 | ||||
-rw-r--r-- | framework/inc/xml/acceleratorconfigurationwriter.hxx | 81 | ||||
-rw-r--r-- | framework/inc/xml/imagesconfiguration.hxx | 57 | ||||
-rw-r--r-- | framework/inc/xml/imagesdocumenthandler.hxx | 136 | ||||
-rw-r--r-- | framework/inc/xml/menudocumenthandler.hxx | 226 | ||||
-rw-r--r-- | framework/inc/xml/saxnamespacefilter.hxx | 83 | ||||
-rw-r--r-- | framework/inc/xml/statusbardocumenthandler.hxx | 138 | ||||
-rw-r--r-- | framework/inc/xml/toolboxconfigurationdefines.hxx | 68 | ||||
-rw-r--r-- | framework/inc/xml/toolboxdocumenthandler.hxx | 162 | ||||
-rw-r--r-- | framework/inc/xml/xmlnamespaces.hxx | 56 |
10 files changed, 1143 insertions, 0 deletions
diff --git a/framework/inc/xml/acceleratorconfigurationreader.hxx b/framework/inc/xml/acceleratorconfigurationreader.hxx new file mode 100644 index 000000000..76a0a159c --- /dev/null +++ b/framework/inc/xml/acceleratorconfigurationreader.hxx @@ -0,0 +1,136 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONREADER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONREADER_HXX + +#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(const OUString& sElement); + + /** TODO document me */ + static EXMLAttribute implst_classifyAttribute(const OUString& sAttribute); + + /** TODO document me */ + OUString implts_getErrorLineString(); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONREADER_HXX + +/* 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..f66b5f6da --- /dev/null +++ b/framework/inc/xml/acceleratorconfigurationwriter.hxx @@ -0,0 +1,81 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX + +#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, + const 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 + +#endif // INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX + +/* 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..cadf20e92 --- /dev/null +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -0,0 +1,57 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_IMAGESCONFIGURATION_HXX +#define INCLUDED_FRAMEWORK_INC_XML_IMAGESCONFIGURATION_HXX + +#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 + +#endif // __FRAMEWORK_CLASSES_IMAGES + +/* 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..f9cbd6122 --- /dev/null +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -0,0 +1,136 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_IMAGESDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_IMAGESDOCUMENTHANDLER_HXX + +#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 + +#endif + +/* 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..236e83591 --- /dev/null +++ b/framework/inc/xml/menudocumenthandler.hxx @@ -0,0 +1,226 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX + +#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> +#include <framework/fwedllapi.h> + +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 + +#endif // INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX + +/* 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..620ebd03d --- /dev/null +++ b/framework/inc/xml/saxnamespacefilter.hxx @@ -0,0 +1,83 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_SAXNAMESPACEFILTER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_SAXNAMESPACEFILTER_HXX + +#include <config_options.h> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <xml/xmlnamespaces.hxx> +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +#include <stack> +#include <framework/fwedllapi.h> + +namespace framework +{ + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE SaxNamespaceFilter_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {}; + +class UNLESS_MERGELIBS(FWE_DLLPUBLIC) 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; + + OUString m_aXMLAttributeNamespace; + OUString m_aXMLAttributeType; + +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_XML_SAXNAMESPACEFILTER_HXX + +/* 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..9dea5b145 --- /dev/null +++ b/framework/inc/xml/statusbardocumenthandler.hxx @@ -0,0 +1,138 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_STATUSBARDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_STATUSBARDOCUMENTHANDLER_HXX + +#include <statusbarconfiguration.hxx> + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +#include <unordered_map> +#include <framework/fwedllapi.h> + +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 + +#endif + +/* 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..505133bb5 --- /dev/null +++ b/framework/inc/xml/toolboxconfigurationdefines.hxx @@ -0,0 +1,68 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_FRAMEWORK_INC_XML_TOOLBOXCONFIGURATIONDEFINES_HXX +#define INCLUDED_FRAMEWORK_INC_XML_TOOLBOXCONFIGURATIONDEFINES_HXX + +#define XMLNS_TOOLBAR "http://openoffice.org/2001/toolbar" +#define XMLNS_XLINK "http://www.w3.org/1999/xlink" +#define XMLNS_TOOLBAR_PREFIX "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" + +#define ELEMENT_NS_TOOLBAR "toolbar:toolbar" +#define ELEMENT_NS_TOOLBARITEM "toolbar:toolbaritem" +#define ELEMENT_NS_TOOLBARSPACE "toolbar:toolbarspace" +#define ELEMENT_NS_TOOLBARBREAK "toolbar:toolbarbreak" +#define ELEMENT_NS_TOOLBARSEPARATOR "toolbar:toolbarseparator" + +#define ATTRIBUTE_XMLNS_TOOLBAR "xmlns:toolbar" +#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink" + +#define ATTRIBUTE_TYPE_CDATA "CDATA" + +#define ATTRIBUTE_BOOLEAN_TRUE "true" +#define ATTRIBUTE_BOOLEAN_FALSE "false" + +#define ATTRIBUTE_ITEMSTYLE_RADIO "radio" +#define ATTRIBUTE_ITEMSTYLE_AUTO "auto" +#define ATTRIBUTE_ITEMSTYLE_LEFT "left" +#define ATTRIBUTE_ITEMSTYLE_AUTOSIZE "autosize" +#define ATTRIBUTE_ITEMSTYLE_DROPDOWN "dropdown" +#define ATTRIBUTE_ITEMSTYLE_REPEAT "repeat" +#define ATTRIBUTE_ITEMSTYLE_TEXT "text" +#define ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY "dropdownonly" +#define ATTRIBUTE_ITEMSTYLE_IMAGE "image" + +#endif // INCLUDED_FRAMEWORK_INC_XML_TOOLBOXCONFIGURATIONDEFINES_HXX + +/* 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..db9184605 --- /dev/null +++ b/framework/inc/xml/toolboxdocumenthandler.hxx @@ -0,0 +1,162 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX + +#include <toolboxconfiguration.hxx> + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> +#include <framework/fwedllapi.h> + +#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 + +#endif + +/* 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..5f0c9670e --- /dev/null +++ b/framework/inc/xml/xmlnamespaces.hxx @@ -0,0 +1,56 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_XMLNAMESPACES_HXX +#define INCLUDED_FRAMEWORK_INC_XML_XMLNAMESPACES_HXX + +#include <map> +#include <framework/fwedllapi.h> + +#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; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_XML_XMLNAMESPACES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |