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 <stdio.h>
29 : : #include "vbaapplication.hxx"
30 : : #include "vbadocument.hxx"
31 : : #include <osl/file.hxx>
32 : : #include <vbahelper/vbahelper.hxx>
33 : : #include "vbawindow.hxx"
34 : : #include "vbasystem.hxx"
35 : : #include "vbaoptions.hxx"
36 : : #include "vbaselection.hxx"
37 : : #include "vbadocuments.hxx"
38 : : #include "vbaaddins.hxx"
39 : : #include "vbadialogs.hxx"
40 : : #include <ooo/vba/word/WdEnableCancelKey.hpp>
41 : : #include <editeng/acorrcfg.hxx>
42 : : #include "wordvbahelper.hxx"
43 : : #include <docsh.hxx>
44 : : #include "vbalistgalleries.hxx"
45 : :
46 : : using namespace ::ooo;
47 : : using namespace ::ooo::vba;
48 : : using namespace ::com::sun::star;
49 : :
50 : : using ::com::sun::star::uno::Reference;
51 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
52 : : using ::com::sun::star::uno::UNO_QUERY;
53 : : using ::rtl::OUString;
54 : :
55 : : // #TODO is this defined somewhere else?
56 : : #if ( defined UNX )
57 : : #define FILE_PATH_SEPERATOR "/"
58 : : #else // windows
59 : : #define FILE_PATH_SEPERATOR "\\"
60 : : #endif
61 : :
62 : : #define EXCELVERSION "11.0"
63 : :
64 : : uno::Any sbxToUnoValue( SbxVariable* pVar );
65 : :
66 : 3 : SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): SwVbaApplication_BASE( xContext )
67 : : {
68 : 3 : }
69 : :
70 : 3 : SwVbaApplication::~SwVbaApplication()
71 : : {
72 [ - + ]: 6 : }
73 : :
74 : 0 : SfxObjectShell* SwVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
75 : : {
76 : 0 : return static_cast< SfxObjectShell* >( word::getDocShell( xModel ) );
77 : : }
78 : :
79 : : rtl::OUString SAL_CALL
80 : 0 : SwVbaApplication::getName() throw (uno::RuntimeException)
81 : : {
82 [ # # ][ # # ]: 0 : static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Word" ) );
[ # # ][ # # ]
83 : 0 : return appName;
84 : : }
85 : :
86 : : uno::Reference< word::XDocument > SAL_CALL
87 : 0 : SwVbaApplication::getActiveDocument() throw (uno::RuntimeException)
88 : : {
89 [ # # ][ # # ]: 0 : return new SwVbaDocument( this, mxContext, getCurrentDocument() );
[ # # ][ # # ]
90 : : }
91 : :
92 : : uno::Reference< word::XWindow > SAL_CALL
93 : 0 : SwVbaApplication::getActiveWindow() throw (uno::RuntimeException)
94 : : {
95 : : // #FIXME sofar can't determine Parent
96 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
97 [ # # ][ # # ]: 0 : uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
[ # # ]
98 [ # # ][ # # ]: 0 : return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController );
[ # # ]
99 : : }
100 : :
101 : : uno::Reference<word::XSystem > SAL_CALL
102 : 0 : SwVbaApplication::getSystem() throw (uno::RuntimeException)
103 : : {
104 [ # # ][ # # ]: 0 : return uno::Reference< word::XSystem >( new SwVbaSystem( mxContext ) );
105 : : }
106 : :
107 : : uno::Reference<word::XOptions > SAL_CALL
108 : 0 : SwVbaApplication::getOptions() throw (uno::RuntimeException)
109 : : {
110 [ # # ][ # # ]: 0 : return uno::Reference< word::XOptions >( new SwVbaOptions( mxContext ) );
111 : : }
112 : :
113 : : uno::Any SAL_CALL
114 : 0 : SwVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
115 : : {
116 : 0 : return VbaApplicationBase::CommandBars( aIndex );
117 : : }
118 : :
119 : : uno::Reference< word::XSelection > SAL_CALL
120 : 0 : SwVbaApplication::getSelection() throw (uno::RuntimeException)
121 : : {
122 [ # # ][ # # ]: 0 : return new SwVbaSelection( this, mxContext, getCurrentDocument() );
[ # # ][ # # ]
123 : : }
124 : :
125 : : uno::Any SAL_CALL
126 : 0 : SwVbaApplication::Documents( const uno::Any& index ) throw (uno::RuntimeException)
127 : : {
128 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xCol( new SwVbaDocuments( this, mxContext ) );
[ # # ][ # # ]
129 [ # # ]: 0 : if ( index.hasValue() )
130 [ # # ][ # # ]: 0 : return xCol->Item( index, uno::Any() );
131 [ # # ]: 0 : return uno::makeAny( xCol );
132 : : }
133 : :
134 : : uno::Any SAL_CALL
135 : 0 : SwVbaApplication::Addins( const uno::Any& index ) throw (uno::RuntimeException)
136 : : {
137 [ # # ][ # # ]: 0 : static uno::Reference< XCollection > xCol( new SwVbaAddins( this, mxContext ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
138 [ # # ]: 0 : if ( index.hasValue() )
139 [ # # ]: 0 : return xCol->Item( index, uno::Any() );
140 : 0 : return uno::makeAny( xCol );
141 : : }
142 : :
143 : : uno::Any SAL_CALL
144 : 0 : SwVbaApplication::Dialogs( const uno::Any& index ) throw (uno::RuntimeException)
145 : : {
146 [ # # ][ # # ]: 0 : uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentDocument() ));
[ # # ][ # # ]
[ # # ]
147 [ # # ]: 0 : if ( index.hasValue() )
148 [ # # ][ # # ]: 0 : return xCol->Item( index );
149 [ # # ]: 0 : return uno::makeAny( xCol );
150 : : }
151 : :
152 : : uno::Any SAL_CALL
153 : 0 : SwVbaApplication::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException)
154 : : {
155 [ # # ][ # # ]: 0 : uno::Reference< text::XTextDocument > xTextDoc( getCurrentDocument(), uno::UNO_QUERY_THROW );
156 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xCol( new SwVbaListGalleries( this, mxContext, xTextDoc ) );
[ # # ][ # # ]
157 [ # # ]: 0 : if ( index.hasValue() )
158 [ # # ][ # # ]: 0 : return xCol->Item( index, uno::Any() );
159 [ # # ]: 0 : return uno::makeAny( xCol );
160 : : }
161 : :
162 : 0 : sal_Bool SAL_CALL SwVbaApplication::getDisplayAutoCompleteTips() throw (css::uno::RuntimeException)
163 : : {
164 : 0 : return SvxAutoCorrCfg::Get().IsAutoTextTip();
165 : : }
166 : :
167 : 0 : void SAL_CALL SwVbaApplication::setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips ) throw (css::uno::RuntimeException)
168 : : {
169 : 0 : SvxAutoCorrCfg::Get().SetAutoTextTip( _displayAutoCompleteTips );
170 : 0 : }
171 : :
172 : 0 : sal_Int32 SAL_CALL SwVbaApplication::getEnableCancelKey() throw (css::uno::RuntimeException)
173 : : {
174 : : // the default value is wdCancelInterrupt in Word
175 : 0 : return word::WdEnableCancelKey::wdCancelInterrupt;
176 : : }
177 : :
178 : 0 : void SAL_CALL SwVbaApplication::setEnableCancelKey( sal_Int32/* _enableCancelKey */) throw (css::uno::RuntimeException)
179 : : {
180 : : // seems not supported in Writer
181 : 0 : }
182 : :
183 : 0 : float SAL_CALL SwVbaApplication::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException)
184 : : {
185 : 0 : return VbaApplicationBase::CentimetersToPoints( _Centimeters );
186 : : }
187 : :
188 : : uno::Reference< frame::XModel >
189 : 0 : SwVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException)
190 : : {
191 : 0 : return getCurrentWordDoc( mxContext );
192 : : }
193 : :
194 : : rtl::OUString
195 : 0 : SwVbaApplication::getServiceImplName()
196 : : {
197 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaApplication"));
198 : : }
199 : :
200 : : uno::Sequence< rtl::OUString >
201 : 0 : SwVbaApplication::getServiceNames()
202 : : {
203 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
204 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
205 : : {
206 : 0 : aServiceNames.realloc( 1 );
207 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Application" ) );
208 : : }
209 : 0 : return aServiceNames;
210 : : }
211 : :
212 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|