fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / fwe / xml / statusbarconfiguration.cxx
blob69aaf0c097c672437f0b42bafc52028f57574ebe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <framework/statusbarconfiguration.hxx>
21 #include <xml/statusbardocumenthandler.hxx>
22 #include <xml/saxnamespacefilter.hxx>
23 #include <services.h>
25 #include <com/sun/star/xml/sax/Parser.hpp>
26 #include <com/sun/star/xml/sax/Writer.hpp>
27 #include <com/sun/star/io/XActiveDataSource.hpp>
28 #include <com/sun/star/io/XInputStream.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <comphelper/processfactory.hxx>
32 #include <unotools/streamwrap.hxx>
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::xml::sax;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::io;
38 using namespace ::com::sun::star::container;
40 namespace framework
43 bool StatusBarConfiguration::LoadStatusBar(
44 const Reference< XComponentContext >& rxContext,
45 const Reference< XInputStream >& xInputStream,
46 const Reference< XIndexContainer >& rStatusbarConfiguration )
48 Reference< XParser > xParser = Parser::create(rxContext);
50 // connect stream to input stream to the parser
51 InputSource aInputSource;
52 aInputSource.aInputStream = xInputStream;
54 // create namespace filter and set menudocument handler inside to support xml namespaces
55 Reference< XDocumentHandler > xDocHandler( new OReadStatusBarDocumentHandler( rStatusbarConfiguration ));
56 Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
58 // connect parser and filter
59 xParser->setDocumentHandler( xFilter );
61 try
63 xParser->parseStream( aInputSource );
64 return true;
66 catch ( const RuntimeException& )
68 return false;
70 catch( const SAXException& )
72 return false;
74 catch( const ::com::sun::star::io::IOException& )
76 return false;
80 bool StatusBarConfiguration::StoreStatusBar(
81 const Reference< XComponentContext >& rxContext,
82 const Reference< XOutputStream >& xOutputStream,
83 const Reference< XIndexAccess >& rStatusbarConfiguration )
85 Reference< XWriter > xWriter = Writer::create( rxContext );
86 xWriter->setOutputStream( xOutputStream );
88 try
90 OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter );
91 aWriteStatusBarDocumentHandler.WriteStatusBarDocument();
92 return true;
94 catch ( const RuntimeException& )
96 return false;
98 catch ( const SAXException& )
100 return false;
102 catch ( const ::com::sun::star::io::IOException& )
104 return false;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */