1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "vbaglobals.hxx"
20 #include "vbawordbasic.hxx"
21 #include <sal/log.hxx>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
25 #include <comphelper/sequence.hxx>
27 #include "vbaapplication.hxx"
28 using namespace ::com::sun::star
;
29 using namespace ::com::sun::star::uno
;
30 using namespace ::ooo::vba
;
32 SwVbaGlobals::SwVbaGlobals( uno::Sequence
< uno::Any
> const& aArgs
, uno::Reference
< uno::XComponentContext
>const& rxContext
) : SwVbaGlobals_BASE( uno::Reference
< XHelperInterface
>(), rxContext
, "WordDocumentContext" )
34 SAL_INFO("sw.vba", "SwVbaGlobals::SwVbaGlobals()");
35 uno::Sequence
< beans::PropertyValue
> aInitArgs( aArgs
.hasElements() ? 2 : 1 );
36 auto pInitArgs
= aInitArgs
.getArray();
37 pInitArgs
[ 0 ].Name
= "Application";
38 pInitArgs
[ 0 ].Value
<<= getApplication();
39 if ( aArgs
.hasElements() )
41 pInitArgs
[ 1 ].Name
= "WordDocumentContext";
42 pInitArgs
[ 1 ].Value
<<= getXSomethingFromArgs
< frame::XModel
>( aArgs
, 0 );
47 SwVbaGlobals::~SwVbaGlobals()
49 SAL_INFO("sw.vba", "SwVbaGlobals::~SwVbaGlobals");
54 uno::Reference
<word::XApplication
> const &
55 SwVbaGlobals::getApplication()
57 SAL_INFO("sw.vba", "In SwVbaGlobals::getApplication");
58 if ( !mxApplication
.is() )
59 mxApplication
.set( new SwVbaApplication( mxContext
) );
64 uno::Reference
<word::XSystem
> SAL_CALL
65 SwVbaGlobals::getSystem()
67 return getApplication()->getSystem();
70 uno::Reference
< word::XDocument
> SAL_CALL
71 SwVbaGlobals::getActiveDocument()
73 return getApplication()->getActiveDocument();
76 uno::Reference
< word::XWindow
> SAL_CALL
77 SwVbaGlobals::getActiveWindow()
79 return getApplication()->getActiveWindow();
83 SwVbaGlobals::getName()
85 return getApplication()->getName();
88 uno::Reference
<word::XOptions
> SAL_CALL
89 SwVbaGlobals::getOptions()
91 return getApplication()->getOptions();
95 SwVbaGlobals::CommandBars( const uno::Any
& aIndex
)
97 return getApplication()->CommandBars( aIndex
);
101 SwVbaGlobals::Documents( const uno::Any
& index
)
103 return getApplication()->Documents( index
);
107 SwVbaGlobals::Addins( const uno::Any
& index
)
109 return getApplication()->Addins( index
);
113 SwVbaGlobals::Dialogs( const uno::Any
& index
)
115 return getApplication()->Dialogs( index
);
119 SwVbaGlobals::ListGalleries( const uno::Any
& index
)
121 return getApplication()->ListGalleries( index
);
124 uno::Reference
<word::XSelection
> SAL_CALL
125 SwVbaGlobals::getSelection()
127 return getApplication()->getSelection();
130 uno::Reference
<word::XGlobals
> SwVbaGlobals::getWord()
132 return uno::Reference
<word::XGlobals
>(this);
135 uno::Reference
<word::XWordBasic
> SAL_CALL
SwVbaGlobals::getWordBasic()
137 assert(dynamic_cast<SwVbaApplication
*>(getApplication().get()));
138 SwVbaApplication
* pVbaApp
= static_cast<SwVbaApplication
*>(getApplication().get());
139 uno::Reference
<word::XWordBasic
> xWB(new SwWordBasic(pVbaApp
));
143 float SAL_CALL
SwVbaGlobals::CentimetersToPoints( float Centimeters
)
145 return getApplication()->CentimetersToPoints( Centimeters
);
148 float SAL_CALL
SwVbaGlobals::PointsToCentimeters( float Points
)
150 return getApplication()->PointsToCentimeters( Points
);
153 float SAL_CALL
SwVbaGlobals::PixelsToPoints( float Pixels
, ::sal_Bool fVertical
)
155 return getApplication()->PixelsToPoints( Pixels
, fVertical
);
158 float SAL_CALL
SwVbaGlobals::PointsToPixels( float Points
, ::sal_Bool fVertical
)
160 return getApplication()->PointsToPixels( Points
, fVertical
);
163 float SAL_CALL
SwVbaGlobals::InchesToPoints( float Inches
)
165 return getApplication()->InchesToPoints( Inches
);
168 float SAL_CALL
SwVbaGlobals::PointsToInches( float Points
)
170 return getApplication()->PointsToInches( Points
);
173 float SAL_CALL
SwVbaGlobals::MillimetersToPoints( float Millimeters
)
175 return getApplication()->MillimetersToPoints( Millimeters
);
178 float SAL_CALL
SwVbaGlobals::PointsToMillimeters( float Points
)
180 return getApplication()->PointsToMillimeters( Points
);
183 float SAL_CALL
SwVbaGlobals::PicasToPoints( float Picas
)
185 return getApplication()->PicasToPoints( Picas
);
188 float SAL_CALL
SwVbaGlobals::PointsToPicas( float Points
)
190 return getApplication()->PointsToPicas( Points
);
194 SwVbaGlobals::getServiceImplName()
196 return "SwVbaGlobals";
199 uno::Sequence
< OUString
>
200 SwVbaGlobals::getServiceNames()
202 return { "ooo.vba.word.Globals" };
205 uno::Sequence
< OUString
>
206 SwVbaGlobals::getAvailableServiceNames( )
208 static const uno::Sequence
<OUString
> serviceNames
= comphelper::concatSequences(
209 SwVbaGlobals_BASE::getAvailableServiceNames(),
210 uno::Sequence
<OUString
>{ "ooo.vba.word.Document",
211 // "ooo.vba.word.Globals",
212 // "ooo.vba.word.WrapFormat",
213 "com.sun.star.script.vba.VBATextEventProcessor" });
217 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
218 Writer_SwVbaGlobals_get_implementation(
219 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const& args
)
221 return cppu::acquire(new SwVbaGlobals(args
, context
));
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */