1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbaapplication.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "vbaapplication.hxx"
32 #include "vbadocument.hxx"
33 #include <osl/file.hxx>
34 #include <vbahelper/vbahelper.hxx>
35 #include "vbawindow.hxx"
36 #include "vbasystem.hxx"
37 #include "vbaoptions.hxx"
38 #include "vbaselection.hxx"
39 #include "vbadocuments.hxx"
40 #include "vbaaddins.hxx"
41 #include "vbadialogs.hxx"
42 #include <ooo/vba/word/WdEnableCancelKey.hpp>
43 #include <svx/acorrcfg.hxx>
44 #include "wordvbahelper.hxx"
47 using namespace ::ooo
;
48 using namespace ::ooo::vba
;
49 using namespace ::com::sun::star
;
51 using ::com::sun::star::uno::Reference
;
52 using ::com::sun::star::uno::UNO_QUERY_THROW
;
53 using ::com::sun::star::uno::UNO_QUERY
;
54 using ::rtl::OUString
;
56 // Enable our own join detection for Intersection and Union
57 // should be more efficient than using ScRangeList::Join ( because
58 // we already are testing the same things )
62 // #TODO is this defined somewhere else?
63 #if ( defined UNX ) || ( defined OS2 ) //unix
64 #define FILE_PATH_SEPERATOR "/"
66 #define FILE_PATH_SEPERATOR "\\"
69 #define EXCELVERSION "11.0"
71 uno::Any
sbxToUnoValue( SbxVariable
* pVar
);
73 SwVbaApplication::SwVbaApplication( uno::Reference
<uno::XComponentContext
>& xContext
): SwVbaApplication_BASE( xContext
)
77 SwVbaApplication::~SwVbaApplication()
81 SfxObjectShell
* SwVbaApplication::GetDocShell( const uno::Reference
< frame::XModel
>& xModel
) throw (uno::RuntimeException
)
83 return static_cast< SfxObjectShell
* >( word::getDocShell( xModel
) );
86 rtl::OUString SAL_CALL
87 SwVbaApplication::getName() throw (uno::RuntimeException
)
89 static rtl::OUString
appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Word" ) );
93 uno::Reference
< word::XDocument
> SAL_CALL
94 SwVbaApplication::getActiveDocument() throw (uno::RuntimeException
)
96 return new SwVbaDocument( this, mxContext
, getCurrentDocument() );
99 uno::Reference
< word::XWindow
> SAL_CALL
100 SwVbaApplication::getActiveWindow() throw (uno::RuntimeException
)
102 // #FIXME sofar can't determine Parent
103 return new SwVbaWindow( uno::Reference
< XHelperInterface
>(), mxContext
, getCurrentDocument() );
106 uno::Reference
<word::XSystem
> SAL_CALL
107 SwVbaApplication::getSystem() throw (uno::RuntimeException
)
109 return uno::Reference
< word::XSystem
>( new SwVbaSystem( mxContext
) );
112 uno::Reference
<word::XOptions
> SAL_CALL
113 SwVbaApplication::getOptions() throw (uno::RuntimeException
)
115 return uno::Reference
< word::XOptions
>( new SwVbaOptions( mxContext
) );
119 SwVbaApplication::CommandBars( const uno::Any
& aIndex
) throw (uno::RuntimeException
)
121 return VbaApplicationBase::CommandBars( aIndex
);
124 uno::Reference
< word::XSelection
> SAL_CALL
125 SwVbaApplication::getSelection() throw (uno::RuntimeException
)
127 return new SwVbaSelection( this, mxContext
, getCurrentDocument() );
131 SwVbaApplication::Documents( const uno::Any
& index
) throw (uno::RuntimeException
)
133 uno::Reference
< XCollection
> xCol( new SwVbaDocuments( this, mxContext
) );
134 if ( index
.hasValue() )
135 return xCol
->Item( index
, uno::Any() );
136 return uno::makeAny( xCol
);
140 SwVbaApplication::Addins( const uno::Any
& index
) throw (uno::RuntimeException
)
142 static uno::Reference
< XCollection
> xCol( new SwVbaAddins( this, mxContext
) );
143 if ( index
.hasValue() )
144 return xCol
->Item( index
, uno::Any() );
145 return uno::makeAny( xCol
);
149 SwVbaApplication::Dialogs( const uno::Any
& index
) throw (uno::RuntimeException
)
151 uno::Reference
< word::XDialogs
> xCol( new SwVbaDialogs( this, mxContext
, getCurrentDocument() ));
152 if ( index
.hasValue() )
153 return xCol
->Item( index
);
154 return uno::makeAny( xCol
);
157 sal_Bool SAL_CALL
SwVbaApplication::getDisplayAutoCompleteTips() throw (css::uno::RuntimeException
)
159 return SvxAutoCorrCfg::Get()->IsAutoTextTip();
162 void SAL_CALL
SwVbaApplication::setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips
) throw (css::uno::RuntimeException
)
164 SvxAutoCorrCfg::Get()->SetAutoTextTip( _displayAutoCompleteTips
);
167 sal_Int32 SAL_CALL
SwVbaApplication::getEnableCancelKey() throw (css::uno::RuntimeException
)
169 // the default value is wdCancelInterrupt in Word
170 return word::WdEnableCancelKey::wdCancelInterrupt
;
173 void SAL_CALL
SwVbaApplication::setEnableCancelKey( sal_Int32
/* _enableCancelKey */) throw (css::uno::RuntimeException
)
175 // seems not supported in Writer
178 float SAL_CALL
SwVbaApplication::CentimetersToPoints( float _Centimeters
) throw (uno::RuntimeException
)
180 return VbaApplicationBase::CentimetersToPoints( _Centimeters
);
183 uno::Reference
< frame::XModel
>
184 SwVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException
)
186 return getCurrentWordDoc( mxContext
);
190 SwVbaApplication::getServiceImplName()
192 static rtl::OUString
sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaApplication") );
196 uno::Sequence
< rtl::OUString
>
197 SwVbaApplication::getServiceNames()
199 static uno::Sequence
< rtl::OUString
> aServiceNames
;
200 if ( aServiceNames
.getLength() == 0 )
202 aServiceNames
.realloc( 1 );
203 aServiceNames
[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Application" ) );
205 return aServiceNames
;