1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/ole/vbaprojectfilter.hxx"
25 
26 #include "oox/ole/vbaproject.hxx"
27 
28 namespace oox {
29 namespace ole {
30 
31 // ============================================================================
32 
33 using namespace ::com::sun::star::uno;
34 
35 using ::rtl::OUString;
36 
37 // ============================================================================
38 
VbaProjectFilterBase(const Reference<XComponentContext> & rxContext,const OUString & rAppName,const OUString & rStorageName)39 VbaProjectFilterBase::VbaProjectFilterBase( const Reference< XComponentContext >& rxContext,
40         const OUString& rAppName, const OUString& rStorageName ) throw( RuntimeException ) :
41     BinaryFilterBase( rxContext ),
42     maAppName( rAppName ),
43     maStorageName( rStorageName )
44 {
45 }
46 
importDocument()47 bool VbaProjectFilterBase::importDocument() throw()
48 {
49     StorageRef xVbaPrjStrg = openSubStorage( maStorageName, false );
50     if( !xVbaPrjStrg || !xVbaPrjStrg->isStorage() )
51         return false;
52 
53     getVbaProject().importVbaProject( *xVbaPrjStrg, getGraphicHelper() );
54     return true;
55 }
56 
exportDocument()57 bool VbaProjectFilterBase::exportDocument() throw()
58 {
59     return false;
60 }
61 
implCreateVbaProject() const62 VbaProject* VbaProjectFilterBase::implCreateVbaProject() const
63 {
64     return new VbaProject( getComponentContext(), getModel(), maAppName );
65 }
66 
67 // ============================================================================
68 
WordVbaProjectFilter_getImplementationName()69 OUString SAL_CALL WordVbaProjectFilter_getImplementationName() throw()
70 {
71     return CREATE_OUSTRING( "com.sun.star.comp.oox.WordVbaProjectFilter" );
72 }
73 
WordVbaProjectFilter_getSupportedServiceNames()74 Sequence< OUString > SAL_CALL WordVbaProjectFilter_getSupportedServiceNames() throw()
75 {
76     Sequence< OUString > aSeq( 1 );
77     aSeq[ 0 ] = CREATE_OUSTRING( "com.sun.star.document.ImportFilter" );
78     return aSeq;
79 }
80 
WordVbaProjectFilter_createInstance(const Reference<XComponentContext> & rxContext)81 Reference< XInterface > SAL_CALL WordVbaProjectFilter_createInstance(
82         const Reference< XComponentContext >& rxContext ) throw( Exception )
83 {
84     return static_cast< ::cppu::OWeakObject* >( new WordVbaProjectFilter( rxContext ) );
85 }
86 
87 // ----------------------------------------------------------------------------
88 
WordVbaProjectFilter(const Reference<XComponentContext> & rxContext)89 WordVbaProjectFilter::WordVbaProjectFilter( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
90     VbaProjectFilterBase( rxContext, CREATE_OUSTRING( "Writer" ), CREATE_OUSTRING( "Macros" ) )
91 {
92 }
93 
implGetImplementationName() const94 OUString WordVbaProjectFilter::implGetImplementationName() const
95 {
96     return WordVbaProjectFilter_getImplementationName();
97 }
98 
99 // ============================================================================
100 
101 } // namespace ole
102 } // namespace oox
103