Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include <vbahelper/helperdecl.hxx>
29 : : #include "vbaglobals.hxx"
30 : : #include <sal/macros.h>
31 : : #include <comphelper/unwrapargs.hxx>
32 : :
33 : : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
34 : : #include <com/sun/star/beans/XPropertySet.hpp>
35 : : #include <com/sun/star/container/XNameContainer.hpp>
36 : : #include <cppuhelper/bootstrap.hxx>
37 : : #include "vbaapplication.hxx"
38 : : using namespace ::com::sun::star;
39 : : using namespace ::com::sun::star::uno;
40 : : using namespace ::ooo::vba;
41 : :
42 : :
43 : 3 : rtl::OUString sDocCtxName( RTL_CONSTASCII_USTRINGPARAM("WordDocumentContext") );
44 : :
45 : : // =============================================================================
46 : : // SwVbaGlobals
47 : : // =============================================================================
48 : :
49 [ + - ]: 3 : SwVbaGlobals::SwVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : SwVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName )
50 : : {
51 : : OSL_TRACE("SwVbaGlobals::SwVbaGlobals()");
52 [ + - ]: 3 : uno::Sequence< beans::PropertyValue > aInitArgs( 2 );
53 [ + - ][ + - ]: 3 : aInitArgs[ 0 ].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Application"));
54 [ + - ][ + - ]: 3 : aInitArgs[ 0 ].Value = uno::makeAny( getApplication() );
[ + - ]
55 [ + - ]: 3 : aInitArgs[ 1 ].Name = sDocCtxName;
56 [ + - ][ + - ]: 3 : aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) );
[ + - ]
57 : :
58 [ + - ][ + - ]: 3 : init( aInitArgs );
59 : 3 : }
60 : :
61 : 3 : SwVbaGlobals::~SwVbaGlobals()
62 : : {
63 : : OSL_TRACE("SwVbaGlobals::~SwVbaGlobals");
64 [ - + ]: 3 : }
65 : :
66 : : // =============================================================================
67 : : // XGlobals
68 : : // =============================================================================
69 : : uno::Reference<word::XApplication >
70 : 3 : SwVbaGlobals::getApplication() throw (uno::RuntimeException)
71 : : {
72 : : OSL_TRACE("In SwVbaGlobals::getApplication");
73 [ + - ]: 3 : if ( !mxApplication.is() )
74 [ + - ][ + - ]: 3 : mxApplication.set( new SwVbaApplication( mxContext) );
75 : :
76 : 3 : return mxApplication;
77 : : }
78 : :
79 : : uno::Reference<word::XSystem > SAL_CALL
80 : 0 : SwVbaGlobals::getSystem() throw (uno::RuntimeException)
81 : : {
82 [ # # ][ # # ]: 0 : return getApplication()->getSystem();
83 : : }
84 : :
85 : : uno::Reference< word::XDocument > SAL_CALL
86 : 0 : SwVbaGlobals::getActiveDocument() throw (uno::RuntimeException)
87 : : {
88 [ # # ][ # # ]: 0 : return getApplication()->getActiveDocument();
89 : : }
90 : :
91 : : uno::Reference< word::XWindow > SAL_CALL
92 : 0 : SwVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
93 : : {
94 [ # # ][ # # ]: 0 : return getApplication()->getActiveWindow();
95 : : }
96 : :
97 : : rtl::OUString SAL_CALL
98 : 0 : SwVbaGlobals::getName() throw (uno::RuntimeException)
99 : : {
100 [ # # ][ # # ]: 0 : return getApplication()->getName();
101 : : }
102 : :
103 : : uno::Reference<word::XOptions > SAL_CALL
104 : 0 : SwVbaGlobals::getOptions() throw (uno::RuntimeException)
105 : : {
106 [ # # ][ # # ]: 0 : return getApplication()->getOptions();
107 : : }
108 : :
109 : : uno::Any SAL_CALL
110 : 0 : SwVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
111 : : {
112 [ # # ][ # # ]: 0 : return getApplication()->CommandBars( aIndex );
113 : : }
114 : :
115 : : uno::Any SAL_CALL
116 : 0 : SwVbaGlobals::Documents( const uno::Any& index ) throw (uno::RuntimeException)
117 : : {
118 [ # # ][ # # ]: 0 : return getApplication()->Documents( index );
119 : : }
120 : :
121 : : uno::Any SAL_CALL
122 : 0 : SwVbaGlobals::Addins( const uno::Any& index ) throw (uno::RuntimeException)
123 : : {
124 [ # # ][ # # ]: 0 : return getApplication()->Addins( index );
125 : : }
126 : :
127 : : uno::Any SAL_CALL
128 : 0 : SwVbaGlobals::Dialogs( const uno::Any& index ) throw (uno::RuntimeException)
129 : : {
130 [ # # ][ # # ]: 0 : return getApplication()->Dialogs( index );
131 : : }
132 : :
133 : : uno::Any SAL_CALL
134 : 0 : SwVbaGlobals::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException)
135 : : {
136 [ # # ][ # # ]: 0 : return getApplication()->ListGalleries( index );
137 : : }
138 : :
139 : : uno::Reference<word::XSelection > SAL_CALL
140 : 0 : SwVbaGlobals::getSelection() throw (uno::RuntimeException)
141 : : {
142 [ # # ][ # # ]: 0 : return getApplication()->getSelection();
143 : : }
144 : :
145 : 0 : float SAL_CALL SwVbaGlobals::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException)
146 : : {
147 [ # # ][ # # ]: 0 : return getApplication()->CentimetersToPoints( _Centimeters );
148 : : }
149 : :
150 : : rtl::OUString
151 : 0 : SwVbaGlobals::getServiceImplName()
152 : : {
153 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaGlobals"));
154 : : }
155 : :
156 : : uno::Sequence< rtl::OUString >
157 : 0 : SwVbaGlobals::getServiceNames()
158 : : {
159 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
160 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
161 : : {
162 : 0 : aServiceNames.realloc( 1 );
163 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Globals" ) );
164 : : }
165 : 0 : return aServiceNames;
166 : : }
167 : :
168 : : uno::Sequence< rtl::OUString >
169 : 39 : SwVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException)
170 : : {
171 : : static bool bInit = false;
172 [ + + ][ + - ]: 39 : static uno::Sequence< rtl::OUString > serviceNames( SwVbaGlobals_BASE::getAvailableServiceNames() );
[ + - ][ # # ]
173 [ + + ]: 39 : if ( !bInit )
174 : : {
175 : : rtl::OUString names[] = {
176 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Document" ) ),
177 : : // #FIXME #TODO make Application a proper service
178 : : // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Application" ) ),
179 [ + - ]: 6 : };
[ # # # # ]
180 : 3 : sal_Int32 nWordServices = SAL_N_ELEMENTS( names );
181 : 3 : sal_Int32 startIndex = serviceNames.getLength();
182 [ + - ]: 3 : serviceNames.realloc( serviceNames.getLength() + nWordServices );
183 [ + + ]: 6 : for ( sal_Int32 index = 0; index < nWordServices; ++index )
184 [ + - ]: 3 : serviceNames[ startIndex + index ] = names[ index ];
185 [ + + ][ # # ]: 6 : bInit = true;
186 : : }
187 : 39 : return serviceNames;
188 : : }
189 : :
190 : : namespace globals
191 : : {
192 : : namespace sdecl = comphelper::service_decl;
193 : 3 : sdecl::vba_service_class_<SwVbaGlobals, sdecl::with_args<true> > serviceImpl;
194 : 3 : extern sdecl::ServiceDecl const serviceDecl(
195 : : serviceImpl,
196 : : "SwVbaGlobals",
197 : : "ooo.vba.word.Globals" );
198 [ + - ][ + - ]: 9 : }
199 : :
200 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|