LCOV - code coverage report
Current view: top level - framework/inc/xml - toolboxdocumenthandler.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX
      21             : #define INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX
      22             : 
      23             : #include <framework/toolboxconfiguration.hxx>
      24             : 
      25             : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      26             : #include <com/sun/star/beans/PropertyValue.hpp>
      27             : 
      28             : #include <rtl/ustring.hxx>
      29             : #include <cppuhelper/implbase1.hxx>
      30             : #include <stdtypes.h>
      31             : #include <framework/fwedllapi.h>
      32             : 
      33             : namespace framework{
      34             : 
      35             : // Hash code function for using in all hash maps of follow implementation.
      36             : 
      37             : class FWE_DLLPUBLIC OReadToolBoxDocumentHandler :
      38             :                                     public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
      39             : {
      40             :     public:
      41             :         enum ToolBox_XML_Entry
      42             :         {
      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_BITMAP,
      50             :             TB_ATTRIBUTE_URL,
      51             :             TB_ATTRIBUTE_ITEMBITS,
      52             :             TB_ATTRIBUTE_VISIBLE,
      53             :             TB_ATTRIBUTE_WIDTH,
      54             :             TB_ATTRIBUTE_USER,
      55             :             TB_ATTRIBUTE_HELPID,
      56             :             TB_ATTRIBUTE_STYLE,
      57             :             TB_ATTRIBUTE_UINAME,
      58             :             TB_ATTRIBUTE_TOOLTIP,
      59             :             TB_XML_ENTRY_COUNT
      60             :         };
      61             : 
      62             :         enum ToolBox_XML_Namespace
      63             :         {
      64             :             TB_NS_TOOLBAR,
      65             :             TB_NS_XLINK,
      66             :             TB_XML_NAMESPACES_COUNT
      67             :         };
      68             : 
      69             :         OReadToolBoxDocumentHandler( const ::com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& rItemContainer );
      70             :         virtual ~OReadToolBoxDocumentHandler();
      71             : 
      72             :         // XDocumentHandler
      73             :         virtual void SAL_CALL startDocument()
      74             :         throw ( ::com::sun::star::xml::sax::SAXException,
      75             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      76             : 
      77             :         virtual void SAL_CALL endDocument()
      78             :         throw(  ::com::sun::star::xml::sax::SAXException,
      79             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      80             : 
      81             :         virtual void SAL_CALL startElement(
      82             :             const OUString& aName,
      83             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
      84             :         throw(  ::com::sun::star::xml::sax::SAXException,
      85             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      86             : 
      87             :         virtual void SAL_CALL endElement(const OUString& aName)
      88             :         throw(  ::com::sun::star::xml::sax::SAXException,
      89             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      90             : 
      91             :         virtual void SAL_CALL characters(const OUString& aChars)
      92             :         throw(  ::com::sun::star::xml::sax::SAXException,
      93             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      94             : 
      95             :         virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces)
      96             :         throw(  ::com::sun::star::xml::sax::SAXException,
      97             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      98             : 
      99             :         virtual void SAL_CALL processingInstruction(const OUString& aTarget,
     100             :                                                     const OUString& aData)
     101             :         throw(  ::com::sun::star::xml::sax::SAXException,
     102             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     103             : 
     104             :         virtual void SAL_CALL setDocumentLocator(
     105             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
     106             :         throw(  ::com::sun::star::xml::sax::SAXException,
     107             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     108             : 
     109             :     private:
     110             :         OUString getErrorLineString();
     111             : 
     112         250 :         class ToolBoxHashMap : public std::unordered_map<OUString                 ,
     113             :                                                          ToolBox_XML_Entry               ,
     114             :                                                          OUStringHash,
     115             :                                                          std::equal_to< OUString >  >
     116             :         {
     117             :             public:
     118             :                 inline void free()
     119             :                 {
     120             :                     ToolBoxHashMap().swap( *this );// get rid of reserved capacity
     121             :                 }
     122             :         };
     123             : 
     124             :         bool                                                                        m_bToolBarStartFound : 1;
     125             :         bool                                                                        m_bToolBarEndFound : 1;
     126             :         bool                                                                        m_bToolBarItemStartFound : 1;
     127             :         bool                                                                        m_bToolBarSpaceStartFound : 1;
     128             :         bool                                                                        m_bToolBarBreakStartFound : 1;
     129             :         bool                                                                        m_bToolBarSeparatorStartFound : 1;
     130             :         ToolBoxHashMap                                                                  m_aToolBoxMap;
     131             :         com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >    m_rItemContainer;
     132             :         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >        m_xLocator;
     133             : 
     134             :         sal_Int32                                                                       m_nHashCode_Style_Radio;
     135             :         sal_Int32                                                                       m_nHashCode_Style_Auto;
     136             :         sal_Int32                                                                       m_nHashCode_Style_Left;
     137             :         sal_Int32                                                                       m_nHashCode_Style_AutoSize;
     138             :         sal_Int32                                                                       m_nHashCode_Style_DropDown;
     139             :         sal_Int32                                                                       m_nHashCode_Style_Repeat;
     140             :         sal_Int32                                                                       m_nHashCode_Style_DropDownOnly;
     141             :         sal_Int32                                                                       m_nHashCode_Style_Text;
     142             :         sal_Int32                                                                       m_nHashCode_Style_Image;
     143             :         OUString                                                                   m_aType;
     144             :         OUString                                                                   m_aLabel;
     145             :         OUString                                                                   m_aStyle;
     146             :         OUString                                                                   m_aHelpURL;
     147             :         OUString                                                                   m_aTooltip;
     148             :         OUString                                                                   m_aIsVisible;
     149             :         OUString                                                                   m_aCommandURL;
     150             : };
     151             : 
     152             : class FWE_DLLPUBLIC OWriteToolBoxDocumentHandler
     153             : {
     154             :     public:
     155             :             OWriteToolBoxDocumentHandler(
     156             :             const ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccess,
     157             :             ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rDocumentHandler );
     158             :         virtual ~OWriteToolBoxDocumentHandler();
     159             : 
     160             :         void WriteToolBoxDocument() throw
     161             :             ( ::com::sun::star::xml::sax::SAXException,
     162             :               ::com::sun::star::uno::RuntimeException );
     163             : 
     164             :     protected:
     165             :         void WriteToolBoxItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, const OUString& aTooltip, sal_Int16 nStyle,
     166             :                                        sal_Int16 nWidth, bool bVisible ) throw
     167             :             ( ::com::sun::star::xml::sax::SAXException,
     168             :               ::com::sun::star::uno::RuntimeException );
     169             : 
     170             :         void WriteToolBoxSpace() throw
     171             :             ( ::com::sun::star::xml::sax::SAXException,
     172             :               ::com::sun::star::uno::RuntimeException );
     173             : 
     174             :         void WriteToolBoxBreak() throw
     175             :             ( ::com::sun::star::xml::sax::SAXException,
     176             :               ::com::sun::star::uno::RuntimeException );
     177             : 
     178             :         void WriteToolBoxSeparator() throw
     179             :             ( ::com::sun::star::xml::sax::SAXException,
     180             :               ::com::sun::star::uno::RuntimeException );
     181             : 
     182             :         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >    m_xWriteDocumentHandler;
     183             :         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >      m_xEmptyList;
     184             :         com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >           m_rItemAccess;
     185             :         OUString                                                                     m_aXMLToolbarNS;
     186             :         OUString                                                                     m_aXMLXlinkNS;
     187             :         OUString                                                                     m_aAttributeType;
     188             :         OUString                                                                     m_aAttributeURL;
     189             : };
     190             : 
     191             : } // namespace framework
     192             : 
     193             : #endif
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11