Fixes #fdo30794 Based on bin/add-modelines script (originally posted in mail 1286706307.1871.1399280959@webmail.messagingengine.com) Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
167 lines
5.8 KiB
C++
167 lines
5.8 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_framework.hxx"
|
|
#include <xml/statusbarconfiguration.hxx>
|
|
#include <xml/statusbardocumenthandler.hxx>
|
|
#include <xml/saxnamespacefilter.hxx>
|
|
#include <services.h>
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
// interface includes
|
|
//_________________________________________________________________________________________________________________
|
|
#include <com/sun/star/xml/sax/XParser.hpp>
|
|
#include <com/sun/star/io/XActiveDataSource.hpp>
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
// other includes
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
#include <unotools/streamwrap.hxx>
|
|
#include <tools/debug.hxx>
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
// namespace
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
using namespace ::com::sun::star::xml::sax;
|
|
using namespace ::com::sun::star::lang;
|
|
using namespace ::com::sun::star::io;
|
|
using namespace ::com::sun::star::container;
|
|
|
|
|
|
namespace framework
|
|
{
|
|
|
|
SV_IMPL_PTRARR( StatusBarDescriptor, StatusBarItemDescriptorPtr);
|
|
|
|
static Reference< XParser > GetSaxParser(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
|
|
)
|
|
{
|
|
return Reference< XParser >( xServiceFactory->createInstance( SERVICENAME_SAXPARSER), UNO_QUERY);
|
|
}
|
|
|
|
static Reference< XDocumentHandler > GetSaxWriter(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
|
|
)
|
|
{
|
|
return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ;
|
|
}
|
|
|
|
sal_Bool StatusBarConfiguration::LoadStatusBar(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&,
|
|
SvStream&, StatusBarDescriptor& )
|
|
{
|
|
// obsolete - only support linkage of binary filters!
|
|
return sal_True;
|
|
}
|
|
|
|
sal_Bool StatusBarConfiguration::StoreStatusBar(
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&,
|
|
SvStream&, const StatusBarDescriptor& )
|
|
{
|
|
// obsolete - only support linkage of binary filters!
|
|
return sal_True;
|
|
}
|
|
|
|
sal_Bool StatusBarConfiguration::LoadStatusBar(
|
|
const Reference< XMultiServiceFactory >& xServiceFactory,
|
|
const Reference< XInputStream >& xInputStream,
|
|
const Reference< XIndexContainer >& rStatusbarConfiguration )
|
|
{
|
|
Reference< XParser > xParser( GetSaxParser( xServiceFactory ) );
|
|
|
|
// connect stream to input stream to the parser
|
|
InputSource aInputSource;
|
|
aInputSource.aInputStream = xInputStream;
|
|
|
|
// create namespace filter and set menudocument handler inside to support xml namespaces
|
|
Reference< XDocumentHandler > xDocHandler( new OReadStatusBarDocumentHandler( rStatusbarConfiguration ));
|
|
Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
|
|
|
|
// connect parser and filter
|
|
xParser->setDocumentHandler( xFilter );
|
|
|
|
try
|
|
{
|
|
xParser->parseStream( aInputSource );
|
|
return sal_True;
|
|
}
|
|
catch ( RuntimeException& )
|
|
{
|
|
return sal_False;
|
|
}
|
|
catch( SAXException& )
|
|
{
|
|
return sal_False;
|
|
}
|
|
catch( ::com::sun::star::io::IOException& )
|
|
{
|
|
return sal_False;
|
|
}
|
|
}
|
|
|
|
sal_Bool StatusBarConfiguration::StoreStatusBar(
|
|
const Reference< XMultiServiceFactory >& xServiceFactory,
|
|
const Reference< XOutputStream >& xOutputStream,
|
|
const Reference< XIndexAccess >& rStatusbarConfiguration )
|
|
{
|
|
Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) );
|
|
Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
|
|
xDataSource->setOutputStream( xOutputStream );
|
|
|
|
try
|
|
{
|
|
OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter );
|
|
aWriteStatusBarDocumentHandler.WriteStatusBarDocument();
|
|
return sal_True;
|
|
}
|
|
catch ( RuntimeException& )
|
|
{
|
|
return sal_False;
|
|
}
|
|
catch ( SAXException& )
|
|
{
|
|
return sal_False;
|
|
}
|
|
catch ( ::com::sun::star::io::IOException& )
|
|
{
|
|
return sal_False;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|