LibreOffice Module sw (master) 1
vbaglobals.cxx
Go to the documentation of this file.
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 "vbaglobals.hxx"
20#include "vbawordbasic.hxx"
21#include <sal/log.hxx>
22
23#include <com/sun/star/beans/PropertyValue.hpp>
24#include <com/sun/star/frame/XModel.hpp>
26
27#include "vbaapplication.hxx"
28using namespace ::com::sun::star;
29using namespace ::com::sun::star::uno;
30using namespace ::ooo::vba;
31
32SwVbaGlobals::SwVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : SwVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, "WordDocumentContext" )
33{
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() )
40 {
41 pInitArgs[ 1 ].Name = "WordDocumentContext";
42 pInitArgs[ 1 ].Value <<= getXSomethingFromArgs< frame::XModel >( aArgs, 0 );
43 }
44 init( aInitArgs );
45}
46
48{
49 SAL_INFO("sw.vba", "SwVbaGlobals::~SwVbaGlobals");
50}
51
52// XGlobals
53
54uno::Reference<word::XApplication > const &
56{
57 SAL_INFO("sw.vba", "In SwVbaGlobals::getApplication");
58 if ( !mxApplication.is() )
60
61 return mxApplication;
62}
63
64uno::Reference<word::XSystem > SAL_CALL
66{
67 return getApplication()->getSystem();
68}
69
70uno::Reference< word::XDocument > SAL_CALL
72{
73 return getApplication()->getActiveDocument();
74}
75
76uno::Reference< word::XWindow > SAL_CALL
78{
79 return getApplication()->getActiveWindow();
80}
81
82OUString SAL_CALL
84{
85 return getApplication()->getName();
86}
87
88uno::Reference<word::XOptions > SAL_CALL
90{
91 return getApplication()->getOptions();
92}
93
94uno::Any SAL_CALL
96{
97 return getApplication()->CommandBars( aIndex );
98}
99
100uno::Any SAL_CALL
102{
103 return getApplication()->Documents( index );
104}
105
106uno::Any SAL_CALL
108{
109 return getApplication()->Addins( index );
110}
111
112uno::Any SAL_CALL
114{
115 return getApplication()->Dialogs( index );
116}
117
118uno::Any SAL_CALL
120{
121 return getApplication()->ListGalleries( index );
122}
123
124uno::Reference<word::XSelection > SAL_CALL
126{
127 return getApplication()->getSelection();
128}
129
130uno::Reference<word::XGlobals> SwVbaGlobals::getWord()
131{
132 return uno::Reference<word::XGlobals>(this);
133}
134
135uno::Reference<word::XWordBasic> SAL_CALL SwVbaGlobals::getWordBasic()
136{
137 assert(dynamic_cast<SwVbaApplication*>(getApplication().get()));
138 SwVbaApplication* pVbaApp = static_cast<SwVbaApplication*>(getApplication().get());
139 uno::Reference<word::XWordBasic> xWB(new SwWordBasic(pVbaApp));
140 return xWB;
141}
142
143float SAL_CALL SwVbaGlobals::CentimetersToPoints( float Centimeters )
144{
145 return getApplication()->CentimetersToPoints( Centimeters );
146}
147
149{
150 return getApplication()->PointsToCentimeters( Points );
151}
152
153float SAL_CALL SwVbaGlobals::PixelsToPoints( float Pixels, ::sal_Bool fVertical )
154{
155 return getApplication()->PixelsToPoints( Pixels, fVertical );
156}
157
158float SAL_CALL SwVbaGlobals::PointsToPixels( float Points, ::sal_Bool fVertical )
159{
160 return getApplication()->PointsToPixels( Points, fVertical );
161}
162
163float SAL_CALL SwVbaGlobals::InchesToPoints( float Inches )
164{
165 return getApplication()->InchesToPoints( Inches );
166}
167
169{
170 return getApplication()->PointsToInches( Points );
171}
172
173float SAL_CALL SwVbaGlobals::MillimetersToPoints( float Millimeters )
174{
175 return getApplication()->MillimetersToPoints( Millimeters );
176}
177
179{
180 return getApplication()->PointsToMillimeters( Points );
181}
182
183float SAL_CALL SwVbaGlobals::PicasToPoints( float Picas )
184{
185 return getApplication()->PicasToPoints( Picas );
186}
187
188float SAL_CALL SwVbaGlobals::PointsToPicas( float Points )
189{
190 return getApplication()->PointsToPicas( Points );
191}
192
193OUString
195{
196 return "SwVbaGlobals";
197}
198
199uno::Sequence< OUString >
201{
202 return { "ooo.vba.word.Globals" };
203}
204
205uno::Sequence< OUString >
207{
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" });
214 return serviceNames;
215}
216
217extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
219 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
220{
221 return cppu::acquire(new SwVbaGlobals(args, context));
222}
223
224/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FILE * init(int, char **)
virtual float SAL_CALL PicasToPoints(float Picas) override
Definition: vbaglobals.cxx:183
virtual float SAL_CALL PointsToPicas(float Points) override
Definition: vbaglobals.cxx:188
virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() override
Definition: vbaglobals.cxx:125
virtual ~SwVbaGlobals() override
Definition: vbaglobals.cxx:47
virtual float SAL_CALL PointsToMillimeters(float Points) override
Definition: vbaglobals.cxx:178
virtual css::uno::Any SAL_CALL CommandBars(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:95
SwVbaGlobals(css::uno::Sequence< css::uno::Any > const &aArgs, css::uno::Reference< css::uno::XComponentContext > const &rxContext)
Definition: vbaglobals.cxx:32
virtual OUString SAL_CALL getName() override
Definition: vbaglobals.cxx:83
virtual css::uno::Any SAL_CALL Documents(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:101
virtual float SAL_CALL PointsToInches(float Points) override
Definition: vbaglobals.cxx:168
css::uno::Reference< ooo::vba::word::XApplication > mxApplication
Definition: vbaglobals.hxx:36
virtual OUString getServiceImplName() override
Definition: vbaglobals.cxx:194
virtual css::uno::Any SAL_CALL Dialogs(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:113
virtual css::uno::Reference< ooo::vba::word::XGlobals > SAL_CALL getWord() override
Definition: vbaglobals.cxx:130
virtual float SAL_CALL PixelsToPoints(float Pixels, ::sal_Bool fVertical) override
Definition: vbaglobals.cxx:153
virtual float SAL_CALL PointsToPixels(float Pixels, ::sal_Bool fVertical) override
Definition: vbaglobals.cxx:158
css::uno::Reference< ooo::vba::word::XApplication > const & getApplication()
Definition: vbaglobals.cxx:55
virtual css::uno::Any SAL_CALL Addins(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:107
virtual css::uno::Reference< ooo::vba::word::XWordBasic > SAL_CALL getWordBasic() override
Definition: vbaglobals.cxx:135
virtual float SAL_CALL MillimetersToPoints(float Millimeters) override
Definition: vbaglobals.cxx:173
virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() override
Definition: vbaglobals.cxx:65
virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() override
Definition: vbaglobals.cxx:77
virtual float SAL_CALL InchesToPoints(float Inches) override
Definition: vbaglobals.cxx:163
virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() override
Definition: vbaglobals.cxx:71
virtual float SAL_CALL CentimetersToPoints(float Centimeters) override
Definition: vbaglobals.cxx:143
virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() override
Definition: vbaglobals.cxx:89
virtual css::uno::Any SAL_CALL ListGalleries(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:119
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: vbaglobals.cxx:206
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaglobals.cxx:200
virtual float SAL_CALL PointsToCentimeters(float Points) override
Definition: vbaglobals.cxx:148
This is a representation of the WordBasic statements and functions that were available in Word versio...
uno::Reference< uno::XComponentContext > mxContext
std::deque< AttacherIndex_Impl > aIndex
#define SAL_INFO(area, stream)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
Reference
index
args
std::vector< Point > Points
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Writer_SwVbaGlobals_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)
Definition: vbaglobals.cxx:218
::cppu::ImplInheritanceHelper< VbaGlobalsBase, ov::word::XGlobals > SwVbaGlobals_BASE
Definition: vbaglobals.hxx:31