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 <sal/log.hxx>
21 
22 #include <com/sun/star/beans/PropertyValue.hpp>
23 #include <com/sun/star/frame/XModel.hpp>
24 #include "vbaapplication.hxx"
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::uno;
27 using namespace ::ooo::vba;
28 
29 SwVbaGlobals::SwVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : SwVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, "WordDocumentContext" )
30 {
31  SAL_INFO("sw.vba", "SwVbaGlobals::SwVbaGlobals()");
32  uno::Sequence< beans::PropertyValue > aInitArgs( aArgs.hasElements() ? 2 : 1 );
33  auto pInitArgs = aInitArgs.getArray();
34  pInitArgs[ 0 ].Name = "Application";
35  pInitArgs[ 0 ].Value <<= getApplication();
36  if ( aArgs.hasElements() )
37  {
38  pInitArgs[ 1 ].Name = "WordDocumentContext";
39  pInitArgs[ 1 ].Value <<= getXSomethingFromArgs< frame::XModel >( aArgs, 0 );
40  }
41  init( aInitArgs );
42 }
43 
45 {
46  SAL_INFO("sw.vba", "SwVbaGlobals::~SwVbaGlobals");
47 }
48 
49 // XGlobals
50 
51 uno::Reference<word::XApplication > const &
53 {
54  SAL_INFO("sw.vba", "In SwVbaGlobals::getApplication");
55  if ( !mxApplication.is() )
57 
58  return mxApplication;
59 }
60 
61 uno::Reference<word::XSystem > SAL_CALL
63 {
64  return getApplication()->getSystem();
65 }
66 
67 uno::Reference< word::XDocument > SAL_CALL
69 {
70  return getApplication()->getActiveDocument();
71 }
72 
73 uno::Reference< word::XWindow > SAL_CALL
75 {
76  return getApplication()->getActiveWindow();
77 }
78 
79 OUString SAL_CALL
81 {
82  return getApplication()->getName();
83 }
84 
85 uno::Reference<word::XOptions > SAL_CALL
87 {
88  return getApplication()->getOptions();
89 }
90 
91 uno::Any SAL_CALL
93 {
94  return getApplication()->CommandBars( aIndex );
95 }
96 
97 uno::Any SAL_CALL
99 {
100  return getApplication()->Documents( index );
101 }
102 
103 uno::Any SAL_CALL
105 {
106  return getApplication()->Addins( index );
107 }
108 
109 uno::Any SAL_CALL
111 {
112  return getApplication()->Dialogs( index );
113 }
114 
115 uno::Any SAL_CALL
117 {
118  return getApplication()->ListGalleries( index );
119 }
120 
121 uno::Reference<word::XSelection > SAL_CALL
123 {
124  return getApplication()->getSelection();
125 }
126 
127 float SAL_CALL SwVbaGlobals::CentimetersToPoints( float Centimeters )
128 {
129  return getApplication()->CentimetersToPoints( Centimeters );
130 }
131 
132 OUString
134 {
135  return "SwVbaGlobals";
136 }
137 
138 uno::Sequence< OUString >
140 {
141  return { "ooo.vba.word.Globals" };
142 }
143 
144 uno::Sequence< OUString >
146 {
147  static uno::Sequence< OUString > const serviceNames = [&]()
148  {
149  uno::Sequence< OUString > tmp = SwVbaGlobals_BASE::getAvailableServiceNames();
150  tmp.realloc( tmp.getLength() + 1 );
151  tmp.getArray()[ tmp.getLength() - 1 ] = "ooo.vba.word.Document";
152 // #FIXME #TODO make Application a proper service
153 // OUString( "ooo.vba.word.Application" ),
154  return tmp;
155  }();
156  return serviceNames;
157 }
158 
159 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
161  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
162 {
163  return cppu::acquire(new SwVbaGlobals(args, context));
164 }
165 
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() override
Definition: vbaglobals.cxx:68
virtual OUString SAL_CALL getName() override
Definition: vbaglobals.cxx:80
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:160
uno::Reference< uno::XComponentContext > mxContext
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: vbaglobals.cxx:145
Reference
virtual float SAL_CALL CentimetersToPoints(float Centimeters) override
Definition: vbaglobals.cxx:127
SwVbaGlobals(css::uno::Sequence< css::uno::Any > const &aArgs, css::uno::Reference< css::uno::XComponentContext > const &rxContext)
Definition: vbaglobals.cxx:29
virtual css::uno::Any SAL_CALL Addins(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:104
virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() override
Definition: vbaglobals.cxx:122
virtual css::uno::Any SAL_CALL ListGalleries(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:116
css::uno::Reference< ooo::vba::word::XApplication > mxApplication
Definition: vbaglobals.hxx:36
css::uno::Reference< ooo::vba::word::XApplication > const & getApplication()
Definition: vbaglobals.cxx:52
virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() override
Definition: vbaglobals.cxx:74
virtual ~SwVbaGlobals() override
Definition: vbaglobals.cxx:44
virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() override
Definition: vbaglobals.cxx:86
virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() override
Definition: vbaglobals.cxx:62
#define SAL_INFO(area, stream)
::cppu::ImplInheritanceHelper< VbaGlobalsBase, ov::word::XGlobals > SwVbaGlobals_BASE
Definition: vbaglobals.hxx:31
FILE * init(int, char **)
virtual css::uno::Any SAL_CALL CommandBars(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:92
virtual css::uno::Any SAL_CALL Documents(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:98
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaglobals.cxx:139
virtual css::uno::Any SAL_CALL Dialogs(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:110
virtual OUString getServiceImplName() override
Definition: vbaglobals.cxx:133