LCOV - code coverage report
Current view: top level - framework/source/fwe/xml - menuconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 47 42.6 %
Date: 2012-08-25 Functions: 4 6 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 102 23.5 %

           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                 :            : #include <framework/menuconfiguration.hxx>
      30                 :            : 
      31                 :            : #include <framework/bmkmenu.hxx>
      32                 :            : #include <framework/addonmenu.hxx>
      33                 :            : #include <xml/menudocumenthandler.hxx>
      34                 :            : #include <xml/saxnamespacefilter.hxx>
      35                 :            : #include <services.h>
      36                 :            : 
      37                 :            : #include <uielement/rootitemcontainer.hxx>
      38                 :            : 
      39                 :            : #include <com/sun/star/xml/sax/XParser.hpp>
      40                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      41                 :            : #include <com/sun/star/frame/XFrame.hpp>
      42                 :            : 
      43                 :            : using namespace ::com::sun::star::uno;
      44                 :            : using namespace ::com::sun::star::lang;
      45                 :            : using namespace ::com::sun::star::beans;
      46                 :            : using namespace ::com::sun::star::xml::sax;
      47                 :            : using namespace ::com::sun::star::container;
      48                 :            : using namespace ::com::sun::star::io;
      49                 :            : 
      50                 :            : namespace framework
      51                 :            : {
      52                 :            : 
      53                 :       1200 : MenuConfiguration::MenuConfiguration(
      54                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager )
      55                 :       1200 : :   m_rxServiceManager( rServiceManager )
      56                 :            : {
      57                 :       1200 : }
      58                 :            : 
      59                 :            : 
      60                 :       1200 : MenuConfiguration::~MenuConfiguration()
      61                 :            : {
      62         [ -  + ]:       1200 : }
      63                 :            : 
      64                 :            : 
      65                 :         96 : Reference< XIndexAccess > MenuConfiguration::CreateMenuBarConfigurationFromXML(
      66                 :            :     Reference< XInputStream >& rInputStream )
      67                 :            : throw ( WrappedTargetException )
      68                 :            : {
      69 [ +  - ][ +  - ]:         96 :     Reference< XParser > xParser( m_rxServiceManager->createInstance(SERVICENAME_SAXPARSER),UNO_QUERY);
         [ +  - ][ +  - ]
      70                 :            : 
      71                 :            :     // connect stream to input stream to the parser
      72         [ +  - ]:         96 :     InputSource aInputSource;
      73                 :            : 
      74         [ +  - ]:         96 :     aInputSource.aInputStream = rInputStream;
      75                 :            : 
      76                 :            : 
      77                 :            :     // create menu bar
      78 [ +  - ][ +  - ]:         96 :     Reference< XIndexContainer > xItemContainer( static_cast< cppu::OWeakObject *>( new RootItemContainer()), UNO_QUERY );
                 [ +  - ]
      79                 :            : 
      80                 :            :     // create namespace filter and set menudocument handler inside to support xml namespaces
      81                 :            : 
      82 [ +  - ][ +  - ]:         96 :     Reference< XDocumentHandler > xDocHandler( new OReadMenuDocumentHandler( m_rxServiceManager, xItemContainer ));
                 [ +  - ]
      83                 :            : 
      84 [ +  - ][ +  - ]:         96 :     Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
                 [ +  - ]
      85                 :            : 
      86                 :            :     // connect parser and filter
      87 [ +  - ][ +  - ]:         96 :     xParser->setDocumentHandler( xFilter );
      88                 :            : 
      89                 :            :     try
      90                 :            :     {
      91 [ +  - ][ +  - ]:         96 :         xParser->parseStream( aInputSource );
      92         [ +  - ]:        192 :         return Reference< XIndexAccess >( xItemContainer, UNO_QUERY );
      93                 :            :     }
      94                 :          0 :     catch ( const RuntimeException& e )
      95                 :            :     {
      96         [ #  # ]:          0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
      97                 :            :     }
      98                 :          0 :     catch( const SAXException& e )
      99                 :            :     {
     100         [ #  # ]:          0 :         SAXException aWrappedSAXException;
     101                 :            : 
     102   [ #  #  #  # ]:          0 :         if ( !( e.WrappedException >>= aWrappedSAXException ))
     103         [ #  # ]:          0 :             throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     104                 :            :         else
     105         [ #  # ]:          0 :             throw WrappedTargetException( aWrappedSAXException.Message, Reference< XInterface >(), Any() );
     106                 :            :     }
     107   [ #  #  #  # ]:          0 :     catch( const ::com::sun::star::io::IOException& e )
     108                 :            :     {
     109         [ #  # ]:          0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     110         [ +  - ]:         96 :     }
     111                 :            : }
     112                 :            : 
     113                 :       1104 : PopupMenu* MenuConfiguration::CreateBookmarkMenu(
     114                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
     115                 :            :     const ::rtl::OUString& aURL )
     116                 :            : throw ( ::com::sun::star::lang::WrappedTargetException )
     117                 :            : {
     118         [ +  - ]:       1104 :     if ( aURL == BOOKMARK_NEWMENU )
     119         [ +  - ]:       1104 :         return new BmkMenu( rFrame, BmkMenu::BMK_NEWMENU );
     120         [ #  # ]:          0 :     else if ( aURL == BOOKMARK_WIZARDMENU )
     121         [ #  # ]:          0 :         return new BmkMenu( rFrame, BmkMenu::BMK_WIZARDMENU );
     122                 :            :     else
     123                 :       1104 :         return NULL;
     124                 :            : }
     125                 :            : 
     126                 :          0 : void MenuConfiguration::StoreMenuBarConfigurationToXML(
     127                 :            :     Reference< XIndexAccess >& rMenuBarConfiguration,
     128                 :            :     Reference< XOutputStream >& rOutputStream )
     129                 :            : throw ( WrappedTargetException )
     130                 :            : {
     131                 :          0 :     Reference< XDocumentHandler > xWriter;
     132                 :            : 
     133         [ #  # ]:          0 :     xWriter = Reference< XDocumentHandler >( m_rxServiceManager->createInstance(
     134 [ #  # ][ #  # ]:          0 :             SERVICENAME_SAXWRITER), UNO_QUERY) ;
         [ #  # ][ #  # ]
     135                 :            : 
     136         [ #  # ]:          0 :     Reference< XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
     137 [ #  # ][ #  # ]:          0 :     xDataSource->setOutputStream( rOutputStream );
     138                 :            : 
     139                 :            :     try
     140                 :            :     {
     141         [ #  # ]:          0 :         OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xWriter );
     142 [ #  # ][ #  # ]:          0 :         aWriteMenuDocumentHandler.WriteMenuDocument();
     143                 :            :     }
     144                 :          0 :     catch ( const RuntimeException& e )
     145                 :            :     {
     146         [ #  # ]:          0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     147                 :            :     }
     148                 :          0 :     catch ( const SAXException& e )
     149                 :            :     {
     150         [ #  # ]:          0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     151                 :            :     }
     152   [ #  #  #  # ]:          0 :     catch ( const ::com::sun::star::io::IOException& e )
     153                 :            :     {
     154         [ #  # ]:          0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     155                 :          0 :     }
     156                 :          0 : }
     157                 :            : 
     158                 :            : }
     159                 :            : 
     160                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10