1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/configimporter.hxx>
21 #include <framework/toolboxconfiguration.hxx>
22 #include <com/sun/star/embed/ElementModes.hpp>
24 #include <rtl/ustrbuf.hxx>
26 using namespace ::com::sun::star
;
31 bool UIConfigurationImporterOOo1x::ImportCustomToolbars(
32 const uno::Reference
< ui::XUIConfigurationManager2
>& rContainerFactory
,
33 uno::Sequence
< uno::Reference
< container::XIndexContainer
> >& rSeqContainer
,
34 const uno::Reference
< uno::XComponentContext
>& rxContext
,
35 const uno::Reference
< embed::XStorage
>& rToolbarStorage
)
37 const char USERDEFTOOLBOX
[] = "userdeftoolbox0.xml";
39 bool bResult ( false );
40 if ( rToolbarStorage
.is() && rContainerFactory
.is() )
44 for ( sal_uInt16 i
= 1; i
<= 4; i
++ )
46 OUStringBuffer
aCustomTbxName( 20 );
47 aCustomTbxName
.appendAscii( USERDEFTOOLBOX
);
48 aCustomTbxName
[14] = aCustomTbxName
[14] + i
;
50 OUString
aTbxStreamName( aCustomTbxName
.makeStringAndClear() );
51 uno::Reference
< io::XStream
> xStream
= rToolbarStorage
->openStreamElement( aTbxStreamName
, embed::ElementModes::READ
);
54 uno::Reference
< io::XInputStream
> xInputStream
= xStream
->getInputStream();
55 if ( xInputStream
.is() )
57 uno::Reference
< container::XIndexContainer
> xContainer
= rContainerFactory
->createSettings();
58 if ( ToolBoxConfiguration::LoadToolBox( rxContext
, xInputStream
, xContainer
))
60 sal_uInt32 nIndex
= rSeqContainer
.getLength();
61 rSeqContainer
.realloc( nIndex
+1 );
62 rSeqContainer
[nIndex
] = xContainer
;
69 catch ( const uno::RuntimeException
& )
73 catch ( const uno::Exception
& )
81 } // namespace framework
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */