1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_framework.hxx" 30 31 #include <framework/configimporter.hxx> 32 #include <framework/toolboxconfiguration.hxx> 33 #include <com/sun/star/embed/ElementModes.hpp> 34 35 #include <rtl/ustrbuf.hxx> 36 37 using namespace ::com::sun::star; 38 39 namespace framework 40 { 41 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 ) 47 { 48 const char USERDEFTOOLBOX[] = "userdeftoolbox0.xml"; 49 uno::Reference< lang::XMultiServiceFactory > rSrvMgr( rServiceManager ); 50 51 sal_Bool bResult ( sal_False ); 52 if ( rToolbarStorage.is() && rContainerFactory.is() ) 53 { 54 try 55 { 56 for ( sal_uInt16 i = 1; i <= 4; i++ ) 57 { 58 rtl::OUStringBuffer aCustomTbxName( 20 ); 59 aCustomTbxName.appendAscii( USERDEFTOOLBOX ); 60 aCustomTbxName.setCharAt( 14, aCustomTbxName.charAt( 14 ) + i ); 61 62 rtl::OUString aTbxStreamName( aCustomTbxName.makeStringAndClear() ); 63 uno::Reference< io::XStream > xStream = rToolbarStorage->openStreamElement( aTbxStreamName, embed::ElementModes::READ ); 64 if ( xStream.is() ) 65 { 66 uno::Reference< io::XInputStream > xInputStream = xStream->getInputStream(); 67 if ( xInputStream.is() ) 68 { 69 uno::Reference< container::XIndexContainer > xContainer = rContainerFactory->createSettings(); 70 if ( ToolBoxConfiguration::LoadToolBox( rSrvMgr, xInputStream, xContainer )) 71 { 72 sal_uInt32 nIndex = rSeqContainer.getLength(); 73 rSeqContainer.realloc( nIndex+1 ); 74 rSeqContainer[nIndex] = xContainer; 75 bResult = sal_True; 76 } 77 } 78 } 79 } 80 } 81 catch ( uno::RuntimeException& ) 82 { 83 throw; 84 } 85 catch ( uno::Exception& ) 86 { 87 } 88 } 89 90 return bResult; 91 } 92 93 } // namespace framework 94