LCOV - code coverage report
Current view: top level - framework/source/fwe/xml - menuconfiguration.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 44 0.0 %
Date: 2014-04-14 Functions: 0 6 0.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             : #include <framework/menuconfiguration.hxx>
      21             : 
      22             : #include <framework/bmkmenu.hxx>
      23             : #include <framework/addonmenu.hxx>
      24             : #include <xml/menudocumenthandler.hxx>
      25             : #include <xml/saxnamespacefilter.hxx>
      26             : #include <services.h>
      27             : 
      28             : #include <uielement/rootitemcontainer.hxx>
      29             : 
      30             : #include <com/sun/star/xml/sax/Parser.hpp>
      31             : #include <com/sun/star/xml/sax/Writer.hpp>
      32             : #include <com/sun/star/io/XActiveDataSource.hpp>
      33             : #include <com/sun/star/frame/XFrame.hpp>
      34             : #include <comphelper/processfactory.hxx>
      35             : 
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::xml::sax;
      40             : using namespace ::com::sun::star::container;
      41             : using namespace ::com::sun::star::io;
      42             : 
      43             : namespace framework
      44             : {
      45             : 
      46           0 : MenuConfiguration::MenuConfiguration(
      47             :     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext )
      48           0 : :   m_xContext( rxContext )
      49             : {
      50           0 : }
      51             : 
      52           0 : MenuConfiguration::~MenuConfiguration()
      53             : {
      54           0 : }
      55             : 
      56           0 : Reference< XIndexAccess > MenuConfiguration::CreateMenuBarConfigurationFromXML(
      57             :     Reference< XInputStream >& rInputStream )
      58             : throw ( WrappedTargetException )
      59             : {
      60           0 :     Reference< XParser > xParser = Parser::create( m_xContext );
      61             : 
      62             :     // connect stream to input stream to the parser
      63           0 :     InputSource aInputSource;
      64             : 
      65           0 :     aInputSource.aInputStream = rInputStream;
      66             : 
      67             :     // create menu bar
      68           0 :     Reference< XIndexContainer > xItemContainer( static_cast< cppu::OWeakObject *>( new RootItemContainer()), UNO_QUERY );
      69             : 
      70             :     // create namespace filter and set menudocument handler inside to support xml namespaces
      71             : 
      72           0 :     Reference< XDocumentHandler > xDocHandler( new OReadMenuDocumentHandler( xItemContainer ));
      73             : 
      74           0 :     Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
      75             : 
      76             :     // connect parser and filter
      77           0 :     xParser->setDocumentHandler( xFilter );
      78             : 
      79             :     try
      80             :     {
      81           0 :         xParser->parseStream( aInputSource );
      82           0 :         return xItemContainer;
      83             :     }
      84           0 :     catch ( const RuntimeException& e )
      85             :     {
      86           0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
      87             :     }
      88           0 :     catch( const SAXException& e )
      89             :     {
      90           0 :         SAXException aWrappedSAXException;
      91             : 
      92           0 :         if ( !( e.WrappedException >>= aWrappedSAXException ))
      93           0 :             throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
      94             :         else
      95           0 :             throw WrappedTargetException( aWrappedSAXException.Message, Reference< XInterface >(), Any() );
      96             :     }
      97           0 :     catch( const ::com::sun::star::io::IOException& e )
      98             :     {
      99           0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     100           0 :     }
     101             : }
     102             : 
     103           0 : PopupMenu* MenuConfiguration::CreateBookmarkMenu(css::uno::Reference<css::frame::XFrame >& rFrame, const OUString& aURL)
     104             :     throw (css::lang::WrappedTargetException,
     105             :            css::uno::RuntimeException)
     106             : {
     107           0 :     if ( aURL == BOOKMARK_NEWMENU )
     108           0 :         return new BmkMenu( rFrame, BmkMenu::BMK_NEWMENU );
     109           0 :     else if ( aURL == BOOKMARK_WIZARDMENU )
     110           0 :         return new BmkMenu( rFrame, BmkMenu::BMK_WIZARDMENU );
     111             :     else
     112           0 :         return NULL;
     113             : }
     114             : 
     115           0 : void MenuConfiguration::StoreMenuBarConfigurationToXML(
     116             :     Reference< XIndexAccess >& rMenuBarConfiguration,
     117             :     Reference< XOutputStream >& rOutputStream )
     118             : throw ( WrappedTargetException )
     119             : {
     120           0 :     Reference< XWriter > xWriter = Writer::create(m_xContext);
     121           0 :     xWriter->setOutputStream( rOutputStream );
     122             : 
     123             :     try
     124             :     {
     125           0 :         OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xWriter );
     126           0 :         aWriteMenuDocumentHandler.WriteMenuDocument();
     127             :     }
     128           0 :     catch ( const RuntimeException& e )
     129             :     {
     130           0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     131             :     }
     132           0 :     catch ( const SAXException& e )
     133             :     {
     134           0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     135             :     }
     136           0 :     catch ( const ::com::sun::star::io::IOException& e )
     137             :     {
     138           0 :         throw WrappedTargetException( e.Message, Reference< XInterface >(), Any() );
     139           0 :     }
     140           0 : }
     141             : 
     142             : }
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10