1*6d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6d739b60SAndrew Rist  * distributed with this work for additional information
6*6d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
9*6d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6d739b60SAndrew Rist  *
11*6d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6d739b60SAndrew Rist  *
13*6d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6d739b60SAndrew Rist  * software distributed under the License is distributed on an
15*6d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6d739b60SAndrew Rist  * specific language governing permissions and limitations
18*6d739b60SAndrew Rist  * under the License.
19*6d739b60SAndrew Rist  *
20*6d739b60SAndrew Rist  *************************************************************/
21*6d739b60SAndrew Rist 
22*6d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <framework/configimporter.hxx>
28cdf0e10cSrcweir #include <framework/toolboxconfiguration.hxx>
29cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace framework
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 
ImportCustomToolbars(const uno::Reference<ui::XUIConfigurationManager> & rContainerFactory,uno::Sequence<uno::Reference<container::XIndexContainer>> & rSeqContainer,const uno::Reference<lang::XMultiServiceFactory> & rServiceManager,const uno::Reference<embed::XStorage> & rToolbarStorage)38cdf0e10cSrcweir sal_Bool UIConfigurationImporterOOo1x::ImportCustomToolbars(
39cdf0e10cSrcweir     const uno::Reference< ui::XUIConfigurationManager >& rContainerFactory,
40cdf0e10cSrcweir     uno::Sequence< uno::Reference< container::XIndexContainer > >& rSeqContainer,
41cdf0e10cSrcweir     const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
42cdf0e10cSrcweir     const uno::Reference< embed::XStorage >& rToolbarStorage )
43cdf0e10cSrcweir {
44cdf0e10cSrcweir     const char USERDEFTOOLBOX[] = "userdeftoolbox0.xml";
45cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > rSrvMgr( rServiceManager );
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     sal_Bool bResult ( sal_False );
48cdf0e10cSrcweir     if ( rToolbarStorage.is() && rContainerFactory.is() )
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         try
51cdf0e10cSrcweir         {
52cdf0e10cSrcweir             for ( sal_uInt16 i = 1; i <= 4; i++ )
53cdf0e10cSrcweir             {
54cdf0e10cSrcweir                 rtl::OUStringBuffer aCustomTbxName( 20 );
55cdf0e10cSrcweir                 aCustomTbxName.appendAscii( USERDEFTOOLBOX );
56cdf0e10cSrcweir                 aCustomTbxName.setCharAt( 14, aCustomTbxName.charAt( 14 ) + i );
57cdf0e10cSrcweir 
58cdf0e10cSrcweir                 rtl::OUString aTbxStreamName( aCustomTbxName.makeStringAndClear() );
59cdf0e10cSrcweir                 uno::Reference< io::XStream > xStream = rToolbarStorage->openStreamElement( aTbxStreamName, embed::ElementModes::READ );
60cdf0e10cSrcweir                 if ( xStream.is() )
61cdf0e10cSrcweir                 {
62cdf0e10cSrcweir                     uno::Reference< io::XInputStream > xInputStream = xStream->getInputStream();
63cdf0e10cSrcweir                     if ( xInputStream.is() )
64cdf0e10cSrcweir                     {
65cdf0e10cSrcweir                         uno::Reference< container::XIndexContainer > xContainer = rContainerFactory->createSettings();
66cdf0e10cSrcweir                         if ( ToolBoxConfiguration::LoadToolBox( rSrvMgr, xInputStream, xContainer ))
67cdf0e10cSrcweir                         {
68cdf0e10cSrcweir                             sal_uInt32 nIndex = rSeqContainer.getLength();
69cdf0e10cSrcweir                             rSeqContainer.realloc( nIndex+1 );
70cdf0e10cSrcweir                             rSeqContainer[nIndex] = xContainer;
71cdf0e10cSrcweir                             bResult = sal_True;
72cdf0e10cSrcweir                         }
73cdf0e10cSrcweir                     }
74cdf0e10cSrcweir                 }
75cdf0e10cSrcweir             }
76cdf0e10cSrcweir         }
77cdf0e10cSrcweir         catch ( uno::RuntimeException& )
78cdf0e10cSrcweir         {
79cdf0e10cSrcweir             throw;
80cdf0e10cSrcweir         }
81cdf0e10cSrcweir         catch ( uno::Exception& )
82cdf0e10cSrcweir         {
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     return bResult;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir } // namespace framework
90