LibreOffice Module framework (master) 1
configimporter.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
22#include <com/sun/star/embed/ElementModes.hpp>
23#include <com/sun/star/ui/XUIConfigurationManager2.hpp>
24
25using namespace ::com::sun::star;
26
27namespace framework
28{
29
30bool UIConfigurationImporterOOo1x::ImportCustomToolbars(
31 const uno::Reference< ui::XUIConfigurationManager2 >& rContainerFactory,
32 std::vector< uno::Reference< container::XIndexContainer > >& rSeqContainer,
33 const uno::Reference< uno::XComponentContext >& rxContext,
34 const uno::Reference< embed::XStorage >& rToolbarStorage )
35{
36 bool bResult ( false );
37 if ( rToolbarStorage.is() && rContainerFactory.is() )
38 {
39 try
40 {
41 for ( sal_uInt16 i = 1; i <= 4; i++ )
42 {
43 OUString aTbxStreamName = "userdeftoolbox" + OUString::number(i) + ".xml";
44 uno::Reference< io::XStream > xStream = rToolbarStorage->openStreamElement( aTbxStreamName, embed::ElementModes::READ );
45 if ( xStream.is() )
46 {
47 uno::Reference< io::XInputStream > xInputStream = xStream->getInputStream();
48 if ( xInputStream.is() )
49 {
50 uno::Reference< container::XIndexContainer > xContainer = rContainerFactory->createSettings();
51 if ( ToolBoxConfiguration::LoadToolBox( rxContext, xInputStream, xContainer ))
52 {
53 rSeqContainer.push_back( xContainer );
54 bResult = true;
55 }
56 }
57 }
58 }
59 }
60 catch ( const uno::RuntimeException& )
61 {
62 throw;
63 }
64 catch ( const uno::Exception& )
65 {
66 }
67 }
68
69 return bResult;
70}
71
72} // namespace framework
73
74/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XInputStream > xStream
static bool LoadToolBox(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::io::XInputStream > &rInputStream, const css::uno::Reference< css::container::XIndexContainer > &rToolbarConfiguration)
int i