merge the formfield patch from ooo-build
[ooovba.git] / framework / source / helper / configimporter.cxx
bloba49845166697a914e90aa18fa495fc24568797f4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: configimporter.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #include <helper/configimporter.hxx>
35 #include <xml/toolboxconfiguration.hxx>
36 #include <com/sun/star/embed/ElementModes.hpp>
38 #include <rtl/ustrbuf.hxx>
40 using namespace ::com::sun::star;
42 namespace framework
45 sal_Bool UIConfigurationImporterOOo1x::ImportCustomToolbars(
46 const uno::Reference< ui::XUIConfigurationManager >& rContainerFactory,
47 uno::Sequence< uno::Reference< container::XIndexContainer > >& rSeqContainer,
48 const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
49 const uno::Reference< embed::XStorage >& rToolbarStorage )
51 const char USERDEFTOOLBOX[] = "userdeftoolbox0.xml";
52 uno::Reference< lang::XMultiServiceFactory > rSrvMgr( rServiceManager );
54 sal_Bool bResult ( sal_False );
55 if ( rToolbarStorage.is() && rContainerFactory.is() )
57 try
59 for ( sal_uInt16 i = 1; i <= 4; i++ )
61 rtl::OUStringBuffer aCustomTbxName( 20 );
62 aCustomTbxName.appendAscii( USERDEFTOOLBOX );
63 aCustomTbxName.setCharAt( 14, aCustomTbxName.charAt( 14 ) + i );
65 rtl::OUString aTbxStreamName( aCustomTbxName.makeStringAndClear() );
66 uno::Reference< io::XStream > xStream = rToolbarStorage->openStreamElement( aTbxStreamName, embed::ElementModes::READ );
67 if ( xStream.is() )
69 uno::Reference< io::XInputStream > xInputStream = xStream->getInputStream();
70 if ( xInputStream.is() )
72 uno::Reference< container::XIndexContainer > xContainer = rContainerFactory->createSettings();
73 if ( ToolBoxConfiguration::LoadToolBox( rSrvMgr, xInputStream, xContainer ))
75 sal_uInt32 nIndex = rSeqContainer.getLength();
76 rSeqContainer.realloc( nIndex+1 );
77 rSeqContainer[nIndex] = xContainer;
78 bResult = sal_True;
84 catch ( uno::RuntimeException& )
86 throw;
88 catch ( uno::Exception& )
93 return bResult;
96 } // namespace framework