LCOV - code coverage report
Current view: top level - framework/source/fwe/xml - toolboxdocumenthandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 163 384 42.4 %
Date: 2012-08-25 Functions: 7 21 33.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 183 787 23.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <stdio.h>
      31                 :            : 
      32                 :            : #include <threadhelp/resetableguard.hxx>
      33                 :            : #include <xml/toolboxdocumenthandler.hxx>
      34                 :            : #include <macros/debug.hxx>
      35                 :            : #include <xml/toolboxconfigurationdefines.hxx>
      36                 :            : 
      37                 :            : #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
      38                 :            : #include <com/sun/star/ui/ItemType.hpp>
      39                 :            : #include <com/sun/star/ui/ItemStyle.hpp>
      40                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      41                 :            : 
      42                 :            : #include <sal/config.h>
      43                 :            : #include <sal/macros.h>
      44                 :            : #include <vcl/svapp.hxx>
      45                 :            : #include <vcl/toolbox.hxx>
      46                 :            : #include <rtl/ustrbuf.hxx>
      47                 :            : 
      48                 :            : #include <comphelper/attributelist.hxx>
      49                 :            : 
      50                 :            : using namespace ::com::sun::star::uno;
      51                 :            : using namespace ::com::sun::star::beans;
      52                 :            : using namespace ::com::sun::star::container;
      53                 :            : using namespace ::com::sun::star::xml::sax;
      54                 :            : 
      55                 :            : 
      56                 :            : #define TOOLBAR_DOCTYPE             "<!DOCTYPE toolbar:toolbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"toolbar.dtd\">"
      57                 :            : 
      58                 :            : namespace framework
      59                 :            : {
      60                 :            : 
      61                 :            : // Property names of a menu/menu item ItemDescriptor
      62                 :            : static const char ITEM_DESCRIPTOR_COMMANDURL[]  = "CommandURL";
      63                 :            : static const char ITEM_DESCRIPTOR_HELPURL[]     = "HelpURL";
      64                 :            : static const char ITEM_DESCRIPTOR_TOOLTIP[]     = "Tooltip";
      65                 :            : static const char ITEM_DESCRIPTOR_LABEL[]       = "Label";
      66                 :            : static const char ITEM_DESCRIPTOR_TYPE[]        = "Type";
      67                 :            : static const char ITEM_DESCRIPTOR_STYLE[]       = "Style";
      68                 :            : static const char ITEM_DESCRIPTOR_VISIBLE[]     = "IsVisible";
      69                 :            : static const char ITEM_DESCRIPTOR_WIDTH[]       = "Width";
      70                 :            : 
      71                 :          0 : static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp,
      72                 :            :                                       ::rtl::OUString&                       rCommandURL,
      73                 :            :                                       ::rtl::OUString&                       rLabel,
      74                 :            :                                       ::rtl::OUString&                       rHelpURL,
      75                 :            :                                       ::rtl::OUString&                       rTooltip,
      76                 :            :                                       sal_Int16&                      rStyle,
      77                 :            :                                       sal_Int16&                      rWidth,
      78                 :            :                                       sal_Bool&                       rVisible,
      79                 :            :                                       sal_Int16&                      rType )
      80                 :            : {
      81         [ #  # ]:          0 :     for ( sal_Int32 i = 0; i < rProp.getLength(); i++ )
      82                 :            :     {
      83         [ #  # ]:          0 :         if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
      84                 :            :         {
      85                 :          0 :             rProp[i].Value >>= rCommandURL;
      86                 :          0 :             rCommandURL = rCommandURL.intern();
      87                 :            :         }
      88         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
      89                 :          0 :             rProp[i].Value >>= rHelpURL;
      90         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TOOLTIP ))
      91                 :          0 :             rProp[i].Value >>= rTooltip;
      92         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
      93                 :          0 :             rProp[i].Value >>= rLabel;
      94         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
      95                 :          0 :             rProp[i].Value >>= rType;
      96         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_VISIBLE ))
      97                 :          0 :             rProp[i].Value >>= rVisible;
      98         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH ))
      99                 :          0 :             rProp[i].Value >>= rWidth;
     100         [ #  # ]:          0 :         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
     101                 :          0 :             rProp[i].Value >>= rStyle;
     102                 :            :     }
     103                 :          0 : }
     104                 :            : 
     105                 :            : struct ToolboxStyleItem
     106                 :            : {
     107                 :            :     sal_Int16 nBit;
     108                 :            :     const char* attrName;
     109                 :            : };
     110                 :            : 
     111                 :            : ToolboxStyleItem Styles[ ] = {
     112                 :            :     { ::com::sun::star::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO },
     113                 :            :     { ::com::sun::star::ui::ItemStyle::ALIGN_LEFT, ATTRIBUTE_ITEMSTYLE_LEFT },
     114                 :            :     { ::com::sun::star::ui::ItemStyle::AUTO_SIZE, ATTRIBUTE_ITEMSTYLE_AUTO },
     115                 :            :     { ::com::sun::star::ui::ItemStyle::REPEAT, ATTRIBUTE_ITEMSTYLE_REPEAT },
     116                 :            :     { ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY, ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY },
     117                 :            :     { ::com::sun::star::ui::ItemStyle::DROP_DOWN, ATTRIBUTE_ITEMSTYLE_DROPDOWN },
     118                 :            :     { ::com::sun::star::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE },
     119                 :            :     { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT },
     120                 :            : };
     121                 :            : 
     122                 :            : sal_Int32 nStyleItemEntries = sizeof (Styles) / sizeof (Styles[0]);
     123                 :            : 
     124                 :            : struct ToolBarEntryProperty
     125                 :            : {
     126                 :            :     OReadToolBoxDocumentHandler::ToolBox_XML_Namespace  nNamespace;
     127                 :            :     char                                                aEntryName[20];
     128                 :            : };
     129                 :            : 
     130                 :            : ToolBarEntryProperty ToolBoxEntries[OReadToolBoxDocumentHandler::TB_XML_ENTRY_COUNT] =
     131                 :            : {
     132                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBAR             },
     133                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBARITEM         },
     134                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBARSPACE        },
     135                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBARBREAK        },
     136                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBARSEPARATOR    },
     137                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_TEXT              },
     138                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_BITMAP            },
     139                 :            :     { OReadToolBoxDocumentHandler::TB_NS_XLINK,     ATTRIBUTE_URL               },
     140                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_ITEMBITS          },
     141                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_VISIBLE           },
     142                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_WIDTH             },
     143                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_USER              },
     144                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_HELPID            },
     145                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_ITEMSTYLE         },
     146                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_UINAME            },
     147                 :            :     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ATTRIBUTE_TOOLTIP           },
     148                 :            : };
     149                 :            : 
     150                 :        226 : OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XIndexContainer >& rItemContainer ) :
     151                 :        226 :     ThreadHelpBase( &Application::GetSolarMutex() ),
     152                 :            :     m_rItemContainer( rItemContainer ),
     153                 :            :     m_aType( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE )),
     154                 :            :     m_aLabel( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL )),
     155                 :            :     m_aStyle( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE )),
     156                 :            :     m_aHelpURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL )),
     157                 :            :     m_aTooltip( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TOOLTIP )),
     158                 :            :     m_aIsVisible( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_VISIBLE )),
     159 [ +  - ][ +  - ]:        226 :     m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ))
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     160                 :            :  {
     161         [ +  - ]:        226 :     ::rtl::OUString aNamespaceToolBar( RTL_CONSTASCII_USTRINGPARAM( XMLNS_TOOLBAR ));
     162         [ +  - ]:        226 :     ::rtl::OUString aNamespaceXLink( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK ));
     163         [ +  - ]:        226 :     ::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( XMLNS_FILTER_SEPARATOR ));
     164                 :            : 
     165                 :            :     // create hash map
     166         [ +  + ]:       3842 :     for ( int i = 0; i < (int)TB_XML_ENTRY_COUNT; i++ )
     167                 :            :     {
     168         [ +  + ]:       3616 :         if ( ToolBoxEntries[i].nNamespace == TB_NS_TOOLBAR )
     169                 :            :         {
     170                 :       3390 :             ::rtl::OUString temp( aNamespaceToolBar );
     171                 :       3390 :             temp += aSeparator;
     172                 :       3390 :             temp += ::rtl::OUString::createFromAscii( ToolBoxEntries[i].aEntryName );
     173         [ +  - ]:       3390 :             m_aToolBoxMap.insert( ToolBoxHashMap::value_type( temp, (ToolBox_XML_Entry)i ) );
     174                 :            :         }
     175                 :            :         else
     176                 :            :         {
     177                 :        226 :             ::rtl::OUString temp( aNamespaceXLink );
     178                 :        226 :             temp += aSeparator;
     179                 :        226 :             temp += ::rtl::OUString::createFromAscii( ToolBoxEntries[i].aEntryName );
     180         [ +  - ]:        226 :             m_aToolBoxMap.insert( ToolBoxHashMap::value_type( temp, (ToolBox_XML_Entry)i ) );
     181                 :            :         }
     182                 :            :     }
     183                 :            : 
     184                 :            :     // pre-calculate a hash code for all style strings to speed up xml read process
     185         [ +  - ]:        226 :     m_nHashCode_Style_Radio         = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_RADIO )).hashCode();
     186         [ +  - ]:        226 :     m_nHashCode_Style_Auto          = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_AUTO )).hashCode();
     187         [ +  - ]:        226 :     m_nHashCode_Style_Left          = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_LEFT )).hashCode();
     188         [ +  - ]:        226 :     m_nHashCode_Style_AutoSize      = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_AUTOSIZE )).hashCode();
     189         [ +  - ]:        226 :     m_nHashCode_Style_DropDown      = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_DROPDOWN )).hashCode();
     190         [ +  - ]:        226 :     m_nHashCode_Style_Repeat        = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_REPEAT )).hashCode();
     191         [ +  - ]:        226 :     m_nHashCode_Style_DropDownOnly  = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY )).hashCode();
     192         [ +  - ]:        226 :     m_nHashCode_Style_Text  = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT )).hashCode();
     193         [ +  - ]:        226 :     m_nHashCode_Style_Image  = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE )).hashCode();
     194                 :            : 
     195                 :        226 :     m_bToolBarStartFound            = sal_False;
     196                 :        226 :     m_bToolBarEndFound              = sal_False;
     197                 :        226 :     m_bToolBarItemStartFound        = sal_False;
     198                 :        226 :     m_bToolBarSpaceStartFound       = sal_False;
     199                 :        226 :     m_bToolBarBreakStartFound       = sal_False;
     200                 :        226 :     m_bToolBarSeparatorStartFound   = sal_False;
     201                 :        226 : }
     202                 :            : 
     203 [ +  - ][ +  - ]:        226 : OReadToolBoxDocumentHandler::~OReadToolBoxDocumentHandler()
     204                 :            : {
     205         [ -  + ]:        452 : }
     206                 :            : 
     207                 :            : // XDocumentHandler
     208                 :          0 : void SAL_CALL OReadToolBoxDocumentHandler::startDocument(void)
     209                 :            : throw ( SAXException, RuntimeException )
     210                 :            : {
     211                 :          0 : }
     212                 :            : 
     213                 :          0 : void SAL_CALL OReadToolBoxDocumentHandler::endDocument(void)
     214                 :            : throw(  SAXException, RuntimeException )
     215                 :            : {
     216         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     217                 :            : 
     218 [ #  # ][ #  # ]:          0 :     if (( m_bToolBarStartFound && !m_bToolBarEndFound ) ||
         [ #  # ][ #  # ]
     219                 :          0 :         ( !m_bToolBarStartFound && m_bToolBarEndFound )     )
     220                 :            :     {
     221         [ #  # ]:          0 :         ::rtl::OUString aErrorMessage = getErrorLineString();
     222         [ #  # ]:          0 :         aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No matching start or end element 'toolbar' found!" ));
     223         [ #  # ]:          0 :         throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     224         [ #  # ]:          0 :     }
     225                 :          0 : }
     226                 :            : 
     227                 :       7796 : void SAL_CALL OReadToolBoxDocumentHandler::startElement(
     228                 :            :     const ::rtl::OUString& aName, const Reference< XAttributeList > &xAttribs )
     229                 :            : throw(  SAXException, RuntimeException )
     230                 :            : {
     231         [ +  - ]:       7796 :     ResetableGuard aGuard( m_aLock );
     232                 :            : 
     233         [ +  - ]:       7796 :     ToolBoxHashMap::const_iterator pToolBoxEntry = m_aToolBoxMap.find( aName ) ;
     234 [ +  - ][ +  - ]:       7796 :     if ( pToolBoxEntry != m_aToolBoxMap.end() )
     235                 :            :     {
     236 [ +  - ][ +  +  :       7796 :         switch ( pToolBoxEntry->second )
             -  +  +  - ]
     237                 :            :         {
     238                 :            :             case TB_ELEMENT_TOOLBAR:
     239                 :            :             {
     240         [ -  + ]:        226 :                 if ( m_bToolBarStartFound )
     241                 :            :                 {
     242         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     243         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'toolbar:toolbar' cannot be embeded into 'toolbar:toolbar'!" ));
     244         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     245                 :            :                 }
     246                 :            :                         else
     247                 :            :                         {
     248                 :            :                             // Check if we have a UI name set in our XML file
     249                 :        226 :                             ::rtl::OUString aUIName;
     250 [ +  - ][ +  - ]:        340 :                             for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ )
                 [ +  + ]
     251                 :            :                       {
     252 [ +  - ][ +  - ]:        114 :                         pToolBoxEntry = m_aToolBoxMap.find( xAttribs->getNameByIndex( n ) );
                 [ +  - ]
     253 [ -  + ][ +  - ]:        114 :                         if ( pToolBoxEntry != m_aToolBoxMap.end() )
     254                 :            :                         {
     255 [ #  # ][ #  # ]:          0 :                                     switch ( pToolBoxEntry->second )
     256                 :            :                                     {
     257                 :            :                                         case TB_ATTRIBUTE_UINAME:
     258 [ #  # ][ #  # ]:          0 :                                     aUIName = xAttribs->getValueByIndex( n );
     259                 :          0 :                                             break;
     260                 :            :                                         default:
     261                 :          0 :                                             break;
     262                 :            :                                     }
     263                 :            :                                 }
     264                 :            :                             }
     265                 :            : 
     266         [ -  + ]:        226 :                             if ( !aUIName.isEmpty() )
     267                 :            :                             {
     268                 :            :                                 // Try to set UI name as a container property
     269         [ #  # ]:          0 :                                 Reference< XPropertySet > xPropSet( m_rItemContainer, UNO_QUERY );
     270         [ #  # ]:          0 :                                 if ( xPropSet.is() )
     271                 :            :                                 {
     272                 :            :                                     try
     273                 :            :                                     {
     274 [ #  # ][ #  # ]:          0 :                                         xPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" )), makeAny( aUIName ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     275                 :            :                                     }
     276         [ #  # ]:          0 :                                     catch ( const UnknownPropertyException& )
     277                 :            :                                     {
     278                 :            :                                     }
     279                 :          0 :                                 }
     280                 :        226 :                             }
     281                 :            :                         }
     282                 :            : 
     283                 :        226 :                 m_bToolBarStartFound = sal_True;
     284                 :            :             }
     285                 :        226 :             break;
     286                 :            : 
     287                 :            :             case TB_ELEMENT_TOOLBARITEM:
     288                 :            :             {
     289         [ -  + ]:       5804 :                 if ( !m_bToolBarStartFound )
     290                 :            :                 {
     291         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     292         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'toolbar:toolbaritem' must be embeded into element 'toolbar:toolbar'!" ));
     293         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     294                 :            :                 }
     295                 :            : 
     296 [ +  - ][ +  - ]:       5804 :                 if ( m_bToolBarSeparatorStartFound ||
         [ +  - ][ -  + ]
     297                 :            :                      m_bToolBarBreakStartFound ||
     298                 :            :                      m_bToolBarSpaceStartFound ||
     299                 :            :                      m_bToolBarItemStartFound )
     300                 :            :                 {
     301         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     302         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element toolbar:toolbaritem is not a container!" ));
     303         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     304                 :            :                 }
     305                 :            : 
     306                 :       5804 :                 sal_Bool bAttributeURL  = sal_False;
     307                 :            : 
     308                 :       5804 :                 m_bToolBarItemStartFound = sal_True;
     309                 :       5804 :                 ::rtl::OUString        aLabel;
     310                 :       5804 :                 ::rtl::OUString        aCommandURL;
     311                 :       5804 :                 ::rtl::OUString        aHelpURL;
     312                 :       5804 :                 ::rtl::OUString        aTooltip;
     313                 :       5804 :                 ::rtl::OUString        aBitmapName;
     314                 :       5804 :                 sal_uInt16      nItemBits( 0 );
     315                 :       5804 :                 sal_Bool        bVisible( sal_True );
     316                 :            : 
     317 [ +  - ][ +  - ]:      20214 :                 for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ )
                 [ +  + ]
     318                 :            :                 {
     319 [ +  - ][ +  - ]:      14410 :                     pToolBoxEntry = m_aToolBoxMap.find( xAttribs->getNameByIndex( n ) );
                 [ +  - ]
     320 [ +  - ][ +  - ]:      14410 :                     if ( pToolBoxEntry != m_aToolBoxMap.end() )
     321                 :            :                     {
     322 [ +  - ][ +  -  :      14410 :                         switch ( pToolBoxEntry->second )
          +  -  +  +  -  
                   +  - ]
     323                 :            :                         {
     324                 :            :                             case TB_ATTRIBUTE_TEXT:
     325                 :            :                             {
     326 [ +  - ][ +  - ]:        208 :                                 aLabel = xAttribs->getValueByIndex( n );
     327                 :            :                             }
     328                 :        208 :                             break;
     329                 :            : 
     330                 :            :                             case TB_ATTRIBUTE_BITMAP:
     331                 :            :                             {
     332 [ #  # ][ #  # ]:          0 :                                 aBitmapName = xAttribs->getValueByIndex( n );
     333                 :            :                             }
     334                 :          0 :                             break;
     335                 :            : 
     336                 :            :                             case TB_ATTRIBUTE_URL:
     337                 :            :                             {
     338                 :       5804 :                                 bAttributeURL   = sal_True;
     339 [ +  - ][ +  - ]:       5804 :                                 aCommandURL     = xAttribs->getValueByIndex( n ).intern();
                 [ +  - ]
     340                 :            :                             }
     341                 :       5804 :                             break;
     342                 :            : 
     343                 :            :                             case TB_ATTRIBUTE_ITEMBITS:
     344                 :            :                             {
     345 [ #  # ][ #  # ]:          0 :                                 nItemBits = (sal_uInt16)(xAttribs->getValueByIndex( n ).toInt32());
     346                 :            :                             }
     347                 :          0 :                             break;
     348                 :            : 
     349                 :            :                             case TB_ATTRIBUTE_VISIBLE:
     350                 :            :                             {
     351 [ +  - ][ +  - ]:       1464 :                                 if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE )
                 [ +  + ]
     352                 :         18 :                                     bVisible = sal_True;
     353 [ +  - ][ +  - ]:       1446 :                                 else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE )
                 [ +  - ]
     354                 :       1446 :                                     bVisible = sal_False;
     355                 :            :                                 else
     356                 :            :                                 {
     357         [ #  # ]:          0 :                                     ::rtl::OUString aErrorMessage = getErrorLineString();
     358         [ #  # ]:          0 :                                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute toolbar:visible must have value 'true' or 'false'!" ));
     359         [ #  # ]:          0 :                                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     360                 :            :                                 }
     361                 :            :                             }
     362                 :       1464 :                             break;
     363                 :            : 
     364                 :            :                             case TB_ATTRIBUTE_HELPID:
     365                 :            :                             {
     366 [ +  - ][ +  - ]:       5586 :                                 aHelpURL = xAttribs->getValueByIndex( n );
     367                 :            :                             }
     368                 :       5586 :                             break;
     369                 :            : 
     370                 :            :                             case TB_ATTRIBUTE_TOOLTIP:
     371                 :            :                             {
     372 [ #  # ][ #  # ]:          0 :                                 aTooltip = xAttribs->getValueByIndex( n );
     373                 :            :                             }
     374                 :          0 :                             break;
     375                 :            : 
     376                 :            :                             case TB_ATTRIBUTE_STYLE:
     377                 :            :                             {
     378                 :            :                                 // read space seperated item style list
     379 [ +  - ][ +  - ]:       1348 :                                 ::rtl::OUString aTemp = xAttribs->getValueByIndex( n );
     380                 :       1348 :                                 sal_Int32 nIndex = 0;
     381                 :            : 
     382         [ +  + ]:       1754 :                                 do
     383                 :            :                                 {
     384                 :       1754 :                                     ::rtl::OUString aToken  = aTemp.getToken( 0, ' ', nIndex );
     385         [ +  + ]:       1754 :                                     if ( !aToken.isEmpty() )
     386                 :            :                                     {
     387                 :       1748 :                                         sal_Int32 nHashCode = aToken.hashCode();
     388         [ +  + ]:       1748 :                                         if ( nHashCode == m_nHashCode_Style_Radio )
     389                 :        974 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::RADIO_CHECK;
     390         [ -  + ]:        774 :                                         else if ( nHashCode == m_nHashCode_Style_Left )
     391                 :          0 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::ALIGN_LEFT;
     392         [ -  + ]:        774 :                                         else if ( nHashCode == m_nHashCode_Style_AutoSize )
     393                 :          0 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::AUTO_SIZE;
     394         [ -  + ]:        774 :                                         else if ( nHashCode == m_nHashCode_Style_Repeat )
     395                 :          0 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::REPEAT;
     396         [ +  + ]:        774 :                                         else if ( nHashCode == m_nHashCode_Style_DropDownOnly )
     397                 :          8 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY;
     398         [ +  + ]:        766 :                                         else if ( nHashCode == m_nHashCode_Style_DropDown )
     399                 :        568 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::DROP_DOWN;
     400         [ -  + ]:        198 :                                         else if ( nHashCode == m_nHashCode_Style_Text )
     401                 :          0 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT;
     402         [ -  + ]:        198 :                                         else if ( nHashCode == m_nHashCode_Style_Image )
     403                 :          0 :                                             nItemBits |= ::com::sun::star::ui::ItemStyle::ICON;
     404                 :       1754 :                                     }
     405                 :            :                                 }
     406                 :       1348 :                                 while ( nIndex >= 0 );
     407                 :            :                             }
     408                 :       1348 :                             break;
     409                 :            :                             case TB_ATTRIBUTE_USER:
     410                 :            :                             case TB_ATTRIBUTE_WIDTH:
     411                 :            :                             default:
     412                 :      14410 :                             break;
     413                 :            :                         }
     414                 :            :                     }
     415                 :            :                 } // for
     416                 :            : 
     417         [ -  + ]:       5804 :                 if ( !bAttributeURL )
     418                 :            :                 {
     419         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     420         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute toolbar:url must have a value!" ));
     421         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     422                 :            :                 }
     423                 :            : 
     424         [ +  - ]:       5804 :                 if ( !aCommandURL.isEmpty() )
     425                 :            :                 {
     426         [ +  - ]:       5804 :                     Sequence< PropertyValue > aToolbarItemProp( 7 );
     427         [ +  - ]:       5804 :                     aToolbarItemProp[0].Name = m_aCommandURL;
     428         [ +  - ]:       5804 :                     aToolbarItemProp[1].Name = m_aHelpURL;
     429         [ +  - ]:       5804 :                     aToolbarItemProp[2].Name = m_aLabel;
     430         [ +  - ]:       5804 :                     aToolbarItemProp[3].Name = m_aType;
     431         [ +  - ]:       5804 :                     aToolbarItemProp[4].Name = m_aStyle;
     432         [ +  - ]:       5804 :                     aToolbarItemProp[5].Name = m_aIsVisible;
     433         [ +  - ]:       5804 :                     aToolbarItemProp[6].Name = m_aTooltip;
     434                 :            : 
     435 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[0].Value <<= aCommandURL;
     436 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[1].Value <<= aHelpURL;
     437 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[2].Value <<= aLabel;
     438 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[3].Value = makeAny( ::com::sun::star::ui::ItemType::DEFAULT );
     439 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[4].Value <<= nItemBits;
     440 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[5].Value <<= bVisible;
     441 [ +  - ][ +  - ]:       5804 :                     aToolbarItemProp[6].Value <<= aTooltip;
     442                 :            : 
     443 [ +  - ][ +  - ]:       5804 :                     m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     444                 :       5804 :                 }
     445                 :            :             }
     446                 :       5804 :             break;
     447                 :            : 
     448                 :            :             case TB_ELEMENT_TOOLBARSPACE:
     449                 :            :             {
     450 [ #  # ][ #  # ]:          0 :                 if ( m_bToolBarSeparatorStartFound ||
         [ #  # ][ #  # ]
     451                 :            :                      m_bToolBarBreakStartFound ||
     452                 :            :                      m_bToolBarSpaceStartFound ||
     453                 :            :                      m_bToolBarItemStartFound )
     454                 :            :                 {
     455         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     456         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element toolbar:toolbarspace is not a container!" ));
     457         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     458                 :            :                 }
     459                 :            : 
     460                 :          0 :                 m_bToolBarSpaceStartFound = sal_True;
     461                 :            : 
     462         [ #  # ]:          0 :                 Sequence< PropertyValue > aToolbarItemProp( 2 );
     463         [ #  # ]:          0 :                 aToolbarItemProp[0].Name = m_aCommandURL;
     464         [ #  # ]:          0 :                 aToolbarItemProp[1].Name = m_aType;
     465                 :            : 
     466 [ #  # ][ #  # ]:          0 :                 aToolbarItemProp[0].Value <<= rtl::OUString();
     467 [ #  # ][ #  # ]:          0 :                 aToolbarItemProp[1].Value <<= ::com::sun::star::ui::ItemType::SEPARATOR_SPACE;
     468                 :            : 
     469 [ #  # ][ #  # ]:          0 :                 m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     470                 :            :             }
     471                 :          0 :             break;
     472                 :            : 
     473                 :            :             case TB_ELEMENT_TOOLBARBREAK:
     474                 :            :             {
     475 [ +  - ][ +  - ]:          4 :                 if ( m_bToolBarSeparatorStartFound ||
         [ +  - ][ -  + ]
     476                 :            :                      m_bToolBarBreakStartFound ||
     477                 :            :                      m_bToolBarSpaceStartFound ||
     478                 :            :                      m_bToolBarItemStartFound )
     479                 :            :                 {
     480         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     481         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element toolbar:toolbarbreak is not a container!" ));
     482         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     483                 :            :                 }
     484                 :            : 
     485                 :          4 :                 m_bToolBarBreakStartFound = sal_True;
     486                 :            : 
     487         [ +  - ]:          4 :                 Sequence< PropertyValue > aToolbarItemProp( 2 );
     488         [ +  - ]:          4 :                 aToolbarItemProp[0].Name = m_aCommandURL;
     489         [ +  - ]:          4 :                 aToolbarItemProp[1].Name = m_aType;
     490                 :            : 
     491 [ +  - ][ +  - ]:          4 :                 aToolbarItemProp[0].Value <<= rtl::OUString();
     492 [ +  - ][ +  - ]:          4 :                 aToolbarItemProp[1].Value <<= ::com::sun::star::ui::ItemType::SEPARATOR_LINEBREAK;
     493                 :            : 
     494 [ +  - ][ +  - ]:          4 :                 m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     495                 :            :             }
     496                 :          4 :             break;
     497                 :            : 
     498                 :            :             case TB_ELEMENT_TOOLBARSEPARATOR:
     499                 :            :             {
     500 [ +  - ][ +  - ]:       1762 :                 if ( m_bToolBarSeparatorStartFound ||
         [ +  - ][ -  + ]
     501                 :            :                      m_bToolBarBreakStartFound ||
     502                 :            :                      m_bToolBarSpaceStartFound ||
     503                 :            :                      m_bToolBarItemStartFound )
     504                 :            :                 {
     505         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     506         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element toolbar:toolbarseparator is not a container!" ));
     507         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     508                 :            :                 }
     509                 :            : 
     510                 :       1762 :                 m_bToolBarSeparatorStartFound = sal_True;
     511                 :            : 
     512         [ +  - ]:       1762 :                 Sequence< PropertyValue > aToolbarItemProp( 2 );
     513         [ +  - ]:       1762 :                 aToolbarItemProp[0].Name = m_aCommandURL;
     514         [ +  - ]:       1762 :                 aToolbarItemProp[1].Name = m_aType;
     515                 :            : 
     516 [ +  - ][ +  - ]:       1762 :                 aToolbarItemProp[0].Value <<= rtl::OUString();
     517 [ +  - ][ +  - ]:       1762 :                 aToolbarItemProp[1].Value <<= ::com::sun::star::ui::ItemType::SEPARATOR_LINE;
     518                 :            : 
     519 [ +  - ][ +  - ]:       1762 :                 m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     520                 :            :             }
     521                 :       1762 :             break;
     522                 :            : 
     523                 :            :                   default:
     524                 :       7796 :                       break;
     525                 :            :         }
     526         [ +  - ]:       7796 :     }
     527                 :       7796 : }
     528                 :            : 
     529                 :       7796 : void SAL_CALL OReadToolBoxDocumentHandler::endElement(const ::rtl::OUString& aName)
     530                 :            : throw(  SAXException, RuntimeException )
     531                 :            : {
     532         [ +  - ]:       7796 :     ResetableGuard aGuard( m_aLock );
     533                 :            : 
     534         [ +  - ]:       7796 :     ToolBoxHashMap::const_iterator pToolBoxEntry = m_aToolBoxMap.find( aName ) ;
     535 [ +  - ][ +  - ]:       7796 :     if ( pToolBoxEntry != m_aToolBoxMap.end() )
     536                 :            :     {
     537 [ +  - ][ +  +  :       7796 :         switch ( pToolBoxEntry->second )
             +  -  +  - ]
     538                 :            :         {
     539                 :            :             case TB_ELEMENT_TOOLBAR:
     540                 :            :             {
     541         [ -  + ]:        226 :                 if ( !m_bToolBarStartFound )
     542                 :            :                 {
     543         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     544         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'toolbar' found, but no start element 'toolbar'" ));
     545         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     546                 :            :                 }
     547                 :            : 
     548                 :        226 :                 m_bToolBarStartFound = sal_False;
     549                 :            :             }
     550                 :        226 :             break;
     551                 :            : 
     552                 :            :             case TB_ELEMENT_TOOLBARITEM:
     553                 :            :             {
     554         [ -  + ]:       5804 :                 if ( !m_bToolBarItemStartFound )
     555                 :            :                 {
     556         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     557         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'toolbar:toolbaritem' found, but no start element 'toolbar:toolbaritem'" ));
     558         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     559                 :            :                 }
     560                 :            : 
     561                 :       5804 :                 m_bToolBarItemStartFound = sal_False;
     562                 :            :             }
     563                 :       5804 :             break;
     564                 :            : 
     565                 :            :             case TB_ELEMENT_TOOLBARBREAK:
     566                 :            :             {
     567         [ -  + ]:          4 :                 if ( !m_bToolBarBreakStartFound )
     568                 :            :                 {
     569         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     570         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'toolbar:toolbarbreak' found, but no start element 'toolbar:toolbarbreak'" ));
     571         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     572                 :            :                 }
     573                 :            : 
     574                 :          4 :                 m_bToolBarBreakStartFound = sal_False;
     575                 :            :             }
     576                 :          4 :             break;
     577                 :            : 
     578                 :            :             case TB_ELEMENT_TOOLBARSPACE:
     579                 :            :             {
     580         [ #  # ]:          0 :                 if ( !m_bToolBarSpaceStartFound )
     581                 :            :                 {
     582         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     583         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'toolbar:toolbarspace' found, but no start element 'toolbar:toolbarspace'" ));
     584         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     585                 :            :                 }
     586                 :            : 
     587                 :          0 :                 m_bToolBarSpaceStartFound = sal_False;
     588                 :            :             }
     589                 :          0 :             break;
     590                 :            : 
     591                 :            :             case TB_ELEMENT_TOOLBARSEPARATOR:
     592                 :            :             {
     593         [ -  + ]:       1762 :                 if ( !m_bToolBarSeparatorStartFound )
     594                 :            :                 {
     595         [ #  # ]:          0 :                     ::rtl::OUString aErrorMessage = getErrorLineString();
     596         [ #  # ]:          0 :                     aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'toolbar:toolbarseparator' found, but no start element 'toolbar:toolbarseparator'" ));
     597         [ #  # ]:          0 :                     throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
     598                 :            :                 }
     599                 :            : 
     600                 :       1762 :                 m_bToolBarSeparatorStartFound = sal_False;
     601                 :            :             }
     602                 :       1762 :             break;
     603                 :            : 
     604                 :            :                   default:
     605                 :       7796 :                       break;
     606                 :            :         }
     607         [ +  - ]:       7796 :     }
     608                 :       7796 : }
     609                 :            : 
     610                 :      15370 : void SAL_CALL OReadToolBoxDocumentHandler::characters(const ::rtl::OUString&)
     611                 :            : throw(  SAXException, RuntimeException )
     612                 :            : {
     613                 :      15370 : }
     614                 :            : 
     615                 :          0 : void SAL_CALL OReadToolBoxDocumentHandler::ignorableWhitespace(const ::rtl::OUString&)
     616                 :            : throw(  SAXException, RuntimeException )
     617                 :            : {
     618                 :          0 : }
     619                 :            : 
     620                 :          0 : void SAL_CALL OReadToolBoxDocumentHandler::processingInstruction(
     621                 :            :     const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ )
     622                 :            : throw(  SAXException, RuntimeException )
     623                 :            : {
     624                 :          0 : }
     625                 :            : 
     626                 :        226 : void SAL_CALL OReadToolBoxDocumentHandler::setDocumentLocator(
     627                 :            :     const Reference< XLocator > &xLocator)
     628                 :            : throw(  SAXException, RuntimeException )
     629                 :            : {
     630         [ +  - ]:        226 :     ResetableGuard aGuard( m_aLock );
     631                 :            : 
     632 [ +  - ][ +  - ]:        226 :     m_xLocator = xLocator;
     633                 :        226 : }
     634                 :            : 
     635                 :          0 : ::rtl::OUString OReadToolBoxDocumentHandler::getErrorLineString()
     636                 :            : {
     637         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     638                 :            : 
     639                 :            :     char buffer[32];
     640                 :            : 
     641         [ #  # ]:          0 :     if ( m_xLocator.is() )
     642                 :            :     {
     643 [ #  # ][ #  # ]:          0 :         snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast<long>( m_xLocator->getLineNumber() ));
     644                 :          0 :         return ::rtl::OUString::createFromAscii( buffer );
     645                 :            :     }
     646                 :            :     else
     647         [ #  # ]:          0 :         return ::rtl::OUString();
     648                 :            : }
     649                 :            : 
     650                 :            : 
     651                 :            : //_________________________________________________________________________________________________________________
     652                 :            : //  OWriteToolBoxDocumentHandler
     653                 :            : //_________________________________________________________________________________________________________________
     654                 :            : 
     655                 :          0 : OWriteToolBoxDocumentHandler::OWriteToolBoxDocumentHandler(
     656                 :            :     const Reference< XIndexAccess >& rItemAccess,
     657                 :            :     Reference< XDocumentHandler >& rWriteDocumentHandler ) :
     658                 :          0 :     ThreadHelpBase( &Application::GetSolarMutex() ),
     659                 :            :     m_xWriteDocumentHandler( rWriteDocumentHandler ),
     660                 :          0 :     m_rItemAccess( rItemAccess )
     661                 :            : {
     662         [ #  # ]:          0 :     ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
     663 [ #  # ][ #  # ]:          0 :     m_xEmptyList        = Reference< XAttributeList >( (XAttributeList *) pList, UNO_QUERY );
                 [ #  # ]
     664         [ #  # ]:          0 :     m_aAttributeType    = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE_CDATA ));
     665         [ #  # ]:          0 :     m_aXMLXlinkNS       = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ));
     666         [ #  # ]:          0 :     m_aXMLToolbarNS     = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_TOOLBAR_PREFIX ));
     667                 :          0 : }
     668                 :            : 
     669                 :          0 : OWriteToolBoxDocumentHandler::~OWriteToolBoxDocumentHandler()
     670                 :            : {
     671         [ #  # ]:          0 : }
     672                 :            : 
     673                 :          0 : void OWriteToolBoxDocumentHandler::WriteToolBoxDocument() throw
     674                 :            : ( SAXException, RuntimeException )
     675                 :            : {
     676         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     677                 :            : 
     678 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->startDocument();
     679                 :            : 
     680                 :            :     // write DOCTYPE line!
     681         [ #  # ]:          0 :     Reference< XExtendedDocumentHandler > xExtendedDocHandler( m_xWriteDocumentHandler, UNO_QUERY );
     682         [ #  # ]:          0 :     if ( xExtendedDocHandler.is() )
     683                 :            :     {
     684 [ #  # ][ #  # ]:          0 :         xExtendedDocHandler->unknown( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( TOOLBAR_DOCTYPE )) );
                 [ #  # ]
     685 [ #  # ][ #  # ]:          0 :         m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     686                 :            :     }
     687                 :            : 
     688                 :          0 :     ::rtl::OUString aUIName;
     689         [ #  # ]:          0 :     Reference< XPropertySet > xPropSet( m_rItemAccess, UNO_QUERY );
     690         [ #  # ]:          0 :     if ( xPropSet.is() )
     691                 :            :     {
     692                 :            :         try
     693                 :            :         {
     694 [ #  # ][ #  # ]:          0 :             xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))) >>= aUIName;
         [ #  # ][ #  # ]
     695                 :            :         }
     696         [ #  # ]:          0 :         catch ( const UnknownPropertyException& )
     697                 :            :         {
     698                 :            :         }
     699                 :            :     }
     700                 :            : 
     701         [ #  # ]:          0 :     ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
     702 [ #  # ][ #  # ]:          0 :     Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
     703                 :            : 
     704                 :            :     pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_TOOLBAR )),
     705                 :            :                          m_aAttributeType,
     706 [ #  # ][ #  # ]:          0 :                          ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_TOOLBAR )) );
                 [ #  # ]
     707                 :            : 
     708                 :            :     pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_XLINK )),
     709                 :            :                          m_aAttributeType,
     710 [ #  # ][ #  # ]:          0 :                          ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK )) );
                 [ #  # ]
     711                 :            : 
     712         [ #  # ]:          0 :     if ( !aUIName.isEmpty() )
     713                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_UINAME )),
     714                 :            :                              m_aAttributeType,
     715 [ #  # ][ #  # ]:          0 :                              aUIName );
     716                 :            : 
     717 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBAR )), pList );
         [ #  # ][ #  # ]
                 [ #  # ]
     718 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     719                 :            : 
     720 [ #  # ][ #  # ]:          0 :     sal_Int32  nItemCount = m_rItemAccess->getCount();
     721                 :          0 :     Any        aAny;
     722                 :            : 
     723         [ #  # ]:          0 :     for ( sal_Int32 nItemPos = 0; nItemPos < nItemCount; nItemPos++ )
     724                 :            :     {
     725         [ #  # ]:          0 :         Sequence< PropertyValue > aProps;
     726 [ #  # ][ #  # ]:          0 :         aAny = m_rItemAccess->getByIndex( nItemPos );
     727 [ #  # ][ #  # ]:          0 :         if ( aAny >>= aProps )
     728                 :            :         {
     729                 :          0 :             ::rtl::OUString    aCommandURL;
     730                 :          0 :             ::rtl::OUString    aLabel;
     731                 :          0 :             ::rtl::OUString    aHelpURL;
     732                 :          0 :             ::rtl::OUString    aTooltip;
     733                 :          0 :             sal_Bool    bVisible( sal_True );
     734                 :          0 :             sal_Int16   nType( ::com::sun::star::ui::ItemType::DEFAULT );
     735                 :          0 :             sal_Int16   nWidth( 0 );
     736                 :          0 :             sal_Int16   nStyle( 0 );
     737                 :            : 
     738 [ #  # ][ #  # ]:          0 :             ExtractToolbarParameters( aProps, aCommandURL, aLabel, aHelpURL, aTooltip, nStyle, nWidth, bVisible, nType );
                 [ #  # ]
     739         [ #  # ]:          0 :             if ( nType == ::com::sun::star::ui::ItemType::DEFAULT )
     740         [ #  # ]:          0 :                 WriteToolBoxItem( aCommandURL, aLabel, aHelpURL, aTooltip, nStyle, nWidth, bVisible );
     741         [ #  # ]:          0 :             else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_SPACE )
     742         [ #  # ]:          0 :                 WriteToolBoxSpace();
     743         [ #  # ]:          0 :             else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_LINE )
     744         [ #  # ]:          0 :                 WriteToolBoxSeparator();
     745         [ #  # ]:          0 :             else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_LINEBREAK )
     746         [ #  # ]:          0 :                 WriteToolBoxBreak();
     747                 :            :         }
     748         [ #  # ]:          0 :     }
     749                 :            : 
     750 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     751 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBAR )) );
                 [ #  # ]
     752 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     753 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->endDocument();
                 [ #  # ]
     754                 :          0 : }
     755                 :            : 
     756                 :            : //_________________________________________________________________________________________________________________
     757                 :            : //  protected member functions
     758                 :            : //_________________________________________________________________________________________________________________
     759                 :            : 
     760                 :          0 : void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
     761                 :            :     const ::rtl::OUString& rCommandURL,
     762                 :            :     const ::rtl::OUString& rLabel,
     763                 :            :     const ::rtl::OUString& rHelpURL,
     764                 :            :     const ::rtl::OUString& rTooltip,
     765                 :            :     sal_Int16       nStyle,
     766                 :            :     sal_Int16       nWidth,
     767                 :            :     sal_Bool        bVisible )
     768                 :            : throw ( SAXException, RuntimeException )
     769                 :            : {
     770         [ #  # ]:          0 :     ::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
     771 [ #  # ][ #  # ]:          0 :     Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
     772                 :            : 
     773         [ #  # ]:          0 :     if ( m_aAttributeURL.isEmpty() )
     774                 :            :     {
     775                 :          0 :         m_aAttributeURL = m_aXMLXlinkNS;
     776         [ #  # ]:          0 :         m_aAttributeURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_URL ));
     777                 :            :     }
     778                 :            : 
     779                 :            :     // save required attribute (URL)
     780         [ #  # ]:          0 :     pList->AddAttribute( m_aAttributeURL, m_aAttributeType, rCommandURL );
     781                 :            : 
     782         [ #  # ]:          0 :     if ( !rLabel.isEmpty() )
     783                 :            :     {
     784                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TEXT )),
     785                 :            :                              m_aAttributeType,
     786 [ #  # ][ #  # ]:          0 :                              rLabel );
     787                 :            :     }
     788                 :            : 
     789         [ #  # ]:          0 :     if ( bVisible == sal_False )
     790                 :            :     {
     791                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_VISIBLE )),
     792                 :            :                              m_aAttributeType,
     793 [ #  # ][ #  # ]:          0 :                              ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_BOOLEAN_FALSE )) );
                 [ #  # ]
     794                 :            :     }
     795                 :            : 
     796         [ #  # ]:          0 :     if ( !rHelpURL.isEmpty() )
     797                 :            :     {
     798                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HELPID )),
     799                 :            :                              m_aAttributeType,
     800 [ #  # ][ #  # ]:          0 :                              rHelpURL );
     801                 :            :     }
     802                 :            : 
     803         [ #  # ]:          0 :     if ( !rTooltip.isEmpty() )
     804                 :            :     {
     805                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TOOLTIP )),
     806                 :            :                              m_aAttributeType,
     807 [ #  # ][ #  # ]:          0 :                              rTooltip );
     808                 :            :     }
     809                 :            : 
     810         [ #  # ]:          0 :     if ( nStyle > 0 )
     811                 :            :     {
     812                 :          0 :         rtl::OUString aValue;
     813                 :          0 :         ToolboxStyleItem* pStyle = Styles;
     814                 :            : 
     815         [ #  # ]:          0 :         for ( sal_Int32 nIndex = 0; nIndex < nStyleItemEntries; ++nIndex, ++pStyle )
     816                 :            :         {
     817         [ #  # ]:          0 :             if ( nStyle & pStyle->nBit )
     818                 :            :             {
     819         [ #  # ]:          0 :                 if ( !aValue.isEmpty() )
     820         [ #  # ]:          0 :                     aValue = aValue.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" ") ) );
     821                 :          0 :                 aValue += rtl::OUString::createFromAscii( pStyle->attrName );
     822                 :            :             }
     823                 :            :         }
     824                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE )),
     825                 :            :                              m_aAttributeType,
     826 [ #  # ][ #  # ]:          0 :                              aValue );
     827                 :            :     }
     828                 :            : 
     829         [ #  # ]:          0 :     if ( nWidth > 0 )
     830                 :            :     {
     831                 :            :         pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_WIDTH )),
     832                 :            :                              m_aAttributeType,
     833 [ #  # ][ #  # ]:          0 :                              ::rtl::OUString::valueOf( sal_Int32( nWidth )) );
     834                 :            :     }
     835                 :            : 
     836 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     837 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARITEM )), xList );
                 [ #  # ]
     838 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     839 [ #  # ][ #  # ]:          0 :     m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARITEM )) );
                 [ #  # ]
     840                 :          0 : }
     841                 :            : 
     842                 :          0 : void OWriteToolBoxDocumentHandler::WriteToolBoxSpace() throw
     843                 :            : ( SAXException, RuntimeException )
     844                 :            : {
     845         [ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     846         [ #  # ]:          0 :     m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARSPACE )), m_xEmptyList );
     847         [ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     848         [ #  # ]:          0 :     m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARSPACE )) );
     849                 :          0 : }
     850                 :            : 
     851                 :          0 : void OWriteToolBoxDocumentHandler::WriteToolBoxBreak() throw
     852                 :            : ( SAXException, RuntimeException )
     853                 :            : {
     854         [ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     855         [ #  # ]:          0 :     m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARBREAK )), m_xEmptyList );
     856         [ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     857         [ #  # ]:          0 :     m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARBREAK )) );
     858                 :          0 : }
     859                 :            : 
     860                 :          0 : void OWriteToolBoxDocumentHandler::WriteToolBoxSeparator() throw
     861                 :            : ( SAXException, RuntimeException )
     862                 :            : {
     863         [ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     864         [ #  # ]:          0 :     m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARSEPARATOR )), m_xEmptyList );
     865         [ #  # ]:          0 :     m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
     866         [ #  # ]:          0 :     m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_TOOLBARSEPARATOR )) );
     867                 :          0 : }
     868                 :            : 
     869                 :            : } // namespace framework
     870                 :            : 
     871                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10