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