Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "vbaapplication.hxx"
20 : #include "vbadocument.hxx"
21 : #include <osl/file.hxx>
22 : #include <vbahelper/vbahelper.hxx>
23 : #include "vbawindow.hxx"
24 : #include "vbasystem.hxx"
25 : #include "vbaoptions.hxx"
26 : #include "vbaselection.hxx"
27 : #include "vbadocuments.hxx"
28 : #include "vbaaddins.hxx"
29 : #include "vbadialogs.hxx"
30 : #include <ooo/vba/word/WdEnableCancelKey.hpp>
31 : #include <basic/sbuno.hxx>
32 : #include <editeng/acorrcfg.hxx>
33 : #include "wordvbahelper.hxx"
34 : #include <docsh.hxx>
35 : #include "vbalistgalleries.hxx"
36 :
37 : using namespace ::ooo;
38 : using namespace ::ooo::vba;
39 : using namespace ::com::sun::star;
40 :
41 : using ::com::sun::star::uno::Reference;
42 : using ::com::sun::star::uno::UNO_QUERY_THROW;
43 : using ::com::sun::star::uno::UNO_QUERY;
44 :
45 1 : SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): SwVbaApplication_BASE( xContext )
46 : {
47 1 : }
48 :
49 2 : SwVbaApplication::~SwVbaApplication()
50 : {
51 2 : }
52 :
53 : OUString SAL_CALL
54 0 : SwVbaApplication::getName() throw (uno::RuntimeException, std::exception)
55 : {
56 0 : return OUString("Microsoft Word" );
57 : }
58 :
59 : uno::Reference< word::XDocument > SAL_CALL
60 0 : SwVbaApplication::getActiveDocument() throw (uno::RuntimeException, std::exception)
61 : {
62 0 : return new SwVbaDocument( this, mxContext, getCurrentDocument() );
63 : }
64 :
65 : uno::Reference< word::XWindow > SAL_CALL
66 0 : SwVbaApplication::getActiveWindow() throw (uno::RuntimeException, std::exception)
67 : {
68 : // #FIXME sofar can't determine Parent
69 0 : uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
70 0 : uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
71 0 : return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController );
72 : }
73 :
74 : uno::Reference<word::XSystem > SAL_CALL
75 0 : SwVbaApplication::getSystem() throw (uno::RuntimeException, std::exception)
76 : {
77 0 : return uno::Reference< word::XSystem >( new SwVbaSystem( mxContext ) );
78 : }
79 :
80 : uno::Reference<word::XOptions > SAL_CALL
81 0 : SwVbaApplication::getOptions() throw (uno::RuntimeException, std::exception)
82 : {
83 0 : return uno::Reference< word::XOptions >( new SwVbaOptions( mxContext ) );
84 : }
85 :
86 : uno::Any SAL_CALL
87 0 : SwVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException, std::exception)
88 : {
89 0 : return VbaApplicationBase::CommandBars( aIndex );
90 : }
91 :
92 : uno::Reference< word::XSelection > SAL_CALL
93 0 : SwVbaApplication::getSelection() throw (uno::RuntimeException, std::exception)
94 : {
95 0 : return new SwVbaSelection( this, mxContext, getCurrentDocument() );
96 : }
97 :
98 : uno::Any SAL_CALL
99 0 : SwVbaApplication::Documents( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
100 : {
101 0 : uno::Reference< XCollection > xCol( new SwVbaDocuments( this, mxContext ) );
102 0 : if ( index.hasValue() )
103 0 : return xCol->Item( index, uno::Any() );
104 0 : return uno::makeAny( xCol );
105 : }
106 :
107 : uno::Any SAL_CALL
108 0 : SwVbaApplication::Addins( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
109 : {
110 0 : static uno::Reference< XCollection > xCol( new SwVbaAddins( this, mxContext ) );
111 0 : if ( index.hasValue() )
112 0 : return xCol->Item( index, uno::Any() );
113 0 : return uno::makeAny( xCol );
114 : }
115 :
116 : uno::Any SAL_CALL
117 0 : SwVbaApplication::Dialogs( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
118 : {
119 0 : uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentDocument() ));
120 0 : if ( index.hasValue() )
121 0 : return xCol->Item( index );
122 0 : return uno::makeAny( xCol );
123 : }
124 :
125 : uno::Any SAL_CALL
126 0 : SwVbaApplication::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException, std::exception)
127 : {
128 0 : uno::Reference< text::XTextDocument > xTextDoc( getCurrentDocument(), uno::UNO_QUERY_THROW );
129 0 : uno::Reference< XCollection > xCol( new SwVbaListGalleries( this, mxContext, xTextDoc ) );
130 0 : if ( index.hasValue() )
131 0 : return xCol->Item( index, uno::Any() );
132 0 : return uno::makeAny( xCol );
133 : }
134 :
135 0 : sal_Bool SAL_CALL SwVbaApplication::getDisplayAutoCompleteTips() throw (css::uno::RuntimeException, std::exception)
136 : {
137 0 : return SvxAutoCorrCfg::Get().IsAutoTextTip();
138 : }
139 :
140 0 : void SAL_CALL SwVbaApplication::setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips ) throw (css::uno::RuntimeException, std::exception)
141 : {
142 0 : SvxAutoCorrCfg::Get().SetAutoTextTip( _displayAutoCompleteTips );
143 0 : }
144 :
145 0 : sal_Int32 SAL_CALL SwVbaApplication::getEnableCancelKey() throw (css::uno::RuntimeException, std::exception)
146 : {
147 : // the default value is wdCancelInterrupt in Word
148 0 : return word::WdEnableCancelKey::wdCancelInterrupt;
149 : }
150 :
151 0 : void SAL_CALL SwVbaApplication::setEnableCancelKey( sal_Int32/* _enableCancelKey */) throw (css::uno::RuntimeException, std::exception)
152 : {
153 : // seems not supported in Writer
154 0 : }
155 :
156 0 : float SAL_CALL SwVbaApplication::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException, std::exception)
157 : {
158 0 : return VbaApplicationBase::CentimetersToPoints( _Centimeters );
159 : }
160 :
161 : uno::Reference< frame::XModel >
162 0 : SwVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException)
163 : {
164 0 : return getCurrentWordDoc( mxContext );
165 : }
166 :
167 : OUString
168 0 : SwVbaApplication::getServiceImplName()
169 : {
170 0 : return OUString("SwVbaApplication");
171 : }
172 :
173 : uno::Sequence< OUString >
174 0 : SwVbaApplication::getServiceNames()
175 : {
176 0 : static uno::Sequence< OUString > aServiceNames;
177 0 : if ( aServiceNames.getLength() == 0 )
178 : {
179 0 : aServiceNames.realloc( 1 );
180 0 : aServiceNames[ 0 ] = "ooo.vba.word.Application";
181 : }
182 0 : return aServiceNames;
183 : }
184 :
185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|