LibreOffice Module framework (master) 1
statusbarconfiguration.cxx
Go to the documentation of this file.
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
23
24#include <com/sun/star/xml/sax/Parser.hpp>
25#include <com/sun/star/xml/sax/Writer.hpp>
26#include <com/sun/star/xml/sax/SAXException.hpp>
27#include <com/sun/star/io/IOException.hpp>
28#include <com/sun/star/io/XInputStream.hpp>
29
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::xml::sax;
32using namespace ::com::sun::star::lang;
33using namespace ::com::sun::star::io;
34using namespace ::com::sun::star::container;
35
36namespace framework
37{
38
40 const Reference< XComponentContext >& rxContext,
41 const Reference< XInputStream >& xInputStream,
42 const Reference< XIndexContainer >& rStatusbarConfiguration )
43{
44 Reference< XParser > xParser = Parser::create(rxContext);
45
46 // connect stream to input stream to the parser
47 InputSource aInputSource;
48 aInputSource.aInputStream = xInputStream;
49
50 // create namespace filter and set menudocument handler inside to support xml namespaces
51 Reference< XDocumentHandler > xDocHandler( new OReadStatusBarDocumentHandler( rStatusbarConfiguration ));
52 Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
53
54 // connect parser and filter
55 xParser->setDocumentHandler( xFilter );
56
57 try
58 {
59 xParser->parseStream( aInputSource );
60 return true;
61 }
62 catch ( const RuntimeException& )
63 {
64 return false;
65 }
66 catch( const SAXException& )
67 {
68 return false;
69 }
70 catch( const css::io::IOException& )
71 {
72 return false;
73 }
74}
75
77 const Reference< XComponentContext >& rxContext,
78 const Reference< XOutputStream >& xOutputStream,
79 const Reference< XIndexAccess >& rStatusbarConfiguration )
80{
81 Reference< XWriter > xWriter = Writer::create( rxContext );
82 xWriter->setOutputStream( xOutputStream );
83
84 try
85 {
86 OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter );
87 aWriteStatusBarDocumentHandler.WriteStatusBarDocument();
88 return true;
89 }
90 catch ( const RuntimeException& )
91 {
92 return false;
93 }
94 catch ( const SAXException& )
95 {
96 return false;
97 }
98 catch ( const css::io::IOException& )
99 {
100 return false;
101 }
102}
103}
104
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool LoadStatusBar(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::io::XInputStream > &xInputStream, const css::uno::Reference< css::container::XIndexContainer > &rStatusbarConfiguration)
static bool StoreStatusBar(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::io::XOutputStream > &xOutputStream, const css::uno::Reference< css::container::XIndexAccess > &rStatusbarConfiguration)