merged tag ooo/OOO330_m14
[LibreOffice.git] / framework / source / helper / configimporter.cxx
blob6f2c402da1e821dccddf004d7da7168d328bd6f3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
31 #include <helper/configimporter.hxx>
32 #include <xml/toolboxconfiguration.hxx>
33 #include <com/sun/star/embed/ElementModes.hpp>
35 #include <rtl/ustrbuf.hxx>
37 using namespace ::com::sun::star;
39 namespace framework
42 sal_Bool UIConfigurationImporterOOo1x::ImportCustomToolbars(
43 const uno::Reference< ui::XUIConfigurationManager >& rContainerFactory,
44 uno::Sequence< uno::Reference< container::XIndexContainer > >& rSeqContainer,
45 const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
46 const uno::Reference< embed::XStorage >& rToolbarStorage )
48 const char USERDEFTOOLBOX[] = "userdeftoolbox0.xml";
49 uno::Reference< lang::XMultiServiceFactory > rSrvMgr( rServiceManager );
51 sal_Bool bResult ( sal_False );
52 if ( rToolbarStorage.is() && rContainerFactory.is() )
54 try
56 for ( sal_uInt16 i = 1; i <= 4; i++ )
58 rtl::OUStringBuffer aCustomTbxName( 20 );
59 aCustomTbxName.appendAscii( USERDEFTOOLBOX );
60 aCustomTbxName.setCharAt( 14, aCustomTbxName.charAt( 14 ) + i );
62 rtl::OUString aTbxStreamName( aCustomTbxName.makeStringAndClear() );
63 uno::Reference< io::XStream > xStream = rToolbarStorage->openStreamElement( aTbxStreamName, embed::ElementModes::READ );
64 if ( xStream.is() )
66 uno::Reference< io::XInputStream > xInputStream = xStream->getInputStream();
67 if ( xInputStream.is() )
69 uno::Reference< container::XIndexContainer > xContainer = rContainerFactory->createSettings();
70 if ( ToolBoxConfiguration::LoadToolBox( rSrvMgr, xInputStream, xContainer ))
72 sal_uInt32 nIndex = rSeqContainer.getLength();
73 rSeqContainer.realloc( nIndex+1 );
74 rSeqContainer[nIndex] = xContainer;
75 bResult = sal_True;
81 catch ( uno::RuntimeException& )
83 throw;
85 catch ( uno::Exception& )
90 return bResult;
93 } // namespace framework