LibreOffice Module sw (master)  1
vbaapplication.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column:100 -*- */
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 
20 #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
21 #include <com/sun/star/task/XStatusIndicator.hpp>
22 #include <com/sun/star/util/thePathSettings.hpp>
23 
24 #include "vbaapplication.hxx"
25 #include "vbadocument.hxx"
27 #include <sal/log.hxx>
28 #include <osl/file.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vbahelper/vbahelper.hxx>
31 #include "vbawindow.hxx"
32 #include "vbasystem.hxx"
33 #include "vbaoptions.hxx"
34 #include "vbaselection.hxx"
35 #include "vbadocuments.hxx"
36 #include "vbaaddins.hxx"
37 #include "vbamailmerge.hxx"
38 #include "vbadialogs.hxx"
39 #include <ooo/vba/XConnectionPoint.hpp>
40 #include <ooo/vba/word/WdEnableCancelKey.hpp>
41 #include <ooo/vba/word/WdWindowState.hpp>
42 #include <ooo/vba/word/XApplicationOutgoing.hpp>
43 #include <ooo/vba/word/XBookmarks.hpp>
46 #include <editeng/acorrcfg.hxx>
47 #include <swdll.hxx>
48 #include <swmodule.hxx>
49 #include "vbalistgalleries.hxx"
50 #include <tools/urlobj.hxx>
51 
52 using namespace ::ooo;
53 using namespace ::ooo::vba;
54 using namespace ::com::sun::star;
55 
56 namespace {
57 
58 class SwVbaApplicationOutgoingConnectionPoint : public cppu::WeakImplHelper<XConnectionPoint>
59 {
60 private:
61  SwVbaApplication* mpApp;
62 
63 public:
64  SwVbaApplicationOutgoingConnectionPoint( SwVbaApplication* pApp );
65 
66  // XConnectionPoint
67  sal_uInt32 SAL_CALL Advise(const uno::Reference< XSink >& Sink ) override;
68  void SAL_CALL Unadvise( sal_uInt32 Cookie ) override;
69 };
70 
71 class SwWordBasic : public cppu::WeakImplHelper<word::XWordBasic>
72 {
73 private:
74  SwVbaApplication* mpApp;
75 
76 public:
77  SwWordBasic( SwVbaApplication* pApp );
78 
79  // XWordBasic
80  virtual sal_Int32 SAL_CALL getMailMergeMainDocumentType() override;
81  virtual void SAL_CALL setMailMergeMainDocumentType( sal_Int32 _mailmergemaindocumenttype ) override;
82 
83  virtual void SAL_CALL FileOpen( const OUString& Name, const uno::Any& ConfirmConversions, const uno::Any& ReadOnly, const uno::Any& AddToMru, const uno::Any& PasswordDoc, const uno::Any& PasswordDot, const uno::Any& Revert, const uno::Any& WritePasswordDoc, const uno::Any& WritePasswordDot ) override;
84  virtual void SAL_CALL FileSave() override;
85  virtual void SAL_CALL FileSaveAs( const css::uno::Any& Name,
86  const css::uno::Any& Format,
87  const css::uno::Any& LockAnnot,
88  const css::uno::Any& Password,
89  const css::uno::Any& AddToMru,
90  const css::uno::Any& WritePassword,
91  const css::uno::Any& RecommendReadOnly,
92  const css::uno::Any& EmbedFonts,
93  const css::uno::Any& NativePictureFormat,
94  const css::uno::Any& FormsData,
95  const css::uno::Any& SaveAsAOCELetter ) override;
96  virtual void SAL_CALL FileClose( const css::uno::Any& Save ) override;
97  virtual void SAL_CALL ToolsOptionsView( const css::uno::Any& DraftFont,
98  const css::uno::Any& WrapToWindow,
99  const css::uno::Any& PicturePlaceHolders,
100  const css::uno::Any& FieldCodes,
101  const css::uno::Any& BookMarks,
102  const css::uno::Any& FieldShading,
103  const css::uno::Any& StatusBar,
104  const css::uno::Any& HScroll,
105  const css::uno::Any& VScroll,
106  const css::uno::Any& StyleAreaWidth,
107  const css::uno::Any& Tabs,
108  const css::uno::Any& Spaces,
109  const css::uno::Any& Paras,
110  const css::uno::Any& Hyphens,
111  const css::uno::Any& Hidden,
112  const css::uno::Any& ShowAll,
113  const css::uno::Any& Drawings,
114  const css::uno::Any& Anchors,
115  const css::uno::Any& TextBoundaries,
116  const css::uno::Any& VRuler,
117  const css::uno::Any& Highlight ) override;
118  virtual css::uno::Any SAL_CALL WindowName( const css::uno::Any& Number ) override;
119  virtual css::uno::Any SAL_CALL ExistingBookmark( const OUString& Name ) override;
120  virtual void SAL_CALL MailMergeOpenDataSource(const OUString& Name, const css::uno::Any& Format,
121  const css::uno::Any& ConfirmConversions, const css::uno::Any& ReadOnly,
122  const css::uno::Any& LinkToSource, const css::uno::Any& AddToRecentFiles,
123  const css::uno::Any& PasswordDocument, const css::uno::Any& PasswordTemplate,
124  const css::uno::Any& Revert, const css::uno::Any& WritePasswordDocument,
125  const css::uno::Any& WritePasswordTemplate, const css::uno::Any& Connection,
126  const css::uno::Any& SQLStatement, const css::uno::Any& SQLStatement1,
127  const css::uno::Any& OpenExclusive, const css::uno::Any& SubType) override;
128  virtual css::uno::Any SAL_CALL AppMaximize( const css::uno::Any& WindowName, const css::uno::Any& State ) override;
129  virtual css::uno::Any SAL_CALL DocMaximize( const css::uno::Any& State ) override;
130  virtual void SAL_CALL AppShow( const css::uno::Any& WindowName ) override;
131  virtual css::uno::Any SAL_CALL AppCount() override;
132 };
133 
134 }
135 
136 SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ):
137  SwVbaApplication_BASE( xContext )
138 {
139 }
140 
142 {
143 }
144 
145 sal_uInt32
146 SwVbaApplication::AddSink( const uno::Reference< XSink >& xSink )
147 {
148  {
149  SolarMutexGuard aGuard;
151  }
152  // No harm in potentially calling this several times
153  SW_MOD()->RegisterAutomationApplicationEventsCaller( uno::Reference< XSinkCaller >(this) );
154  mvSinks.push_back(xSink);
155  return mvSinks.size();
156 }
157 
158 void
159 SwVbaApplication::RemoveSink( sal_uInt32 nNumber )
160 {
161  if (nNumber < 1 || nNumber > mvSinks.size())
162  return;
163 
164  mvSinks[nNumber-1] = uno::Reference< XSink >();
165 }
166 
167 OUString SAL_CALL
169 {
170  return "Microsoft Word";
171 }
172 
173 uno::Reference< word::XDocument > SAL_CALL
175 {
176  return new SwVbaDocument( this, mxContext, getCurrentDocument() );
177 }
178 
181 {
182  // #FIXME so far can't determine Parent
183  uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW );
184  uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
185  return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController );
186 }
187 
188 uno::Reference< css::uno::XComponentContext > const &
190 {
191  return mxContext;
192 }
193 
194 uno::Reference< word::XWindow > SAL_CALL
196 {
197  return getActiveSwVbaWindow();
198 }
199 
200 uno::Reference<word::XSystem > SAL_CALL
202 {
203  return uno::Reference< word::XSystem >( new SwVbaSystem( mxContext ) );
204 }
205 
206 uno::Reference<word::XOptions > SAL_CALL
208 {
209  return uno::Reference< word::XOptions >( new SwVbaOptions( mxContext ) );
210 }
211 
212 uno::Any SAL_CALL
214 {
215  try
216  {
217  return VbaApplicationBase::CommandBars( aIndex );
218  }
219  catch (const uno::RuntimeException&)
220  {
221  return uno::Any();
222  }
223 }
224 
225 uno::Reference< word::XSelection > SAL_CALL
227 {
228  return new SwVbaSelection( this, mxContext, getCurrentDocument() );
229 }
230 
231 uno::Reference< word::XWordBasic > SAL_CALL
233 {
234  uno::Reference< word::XWordBasic > xWB( new SwWordBasic( this ) );
235  return xWB;
236 }
237 
238 uno::Any SAL_CALL
240 {
241  uno::Reference< XCollection > xCol( new SwVbaDocuments( this, mxContext ) );
242  if ( index.hasValue() )
243  return xCol->Item( index, uno::Any() );
244  return uno::makeAny( xCol );
245 }
246 
247 uno::Any SAL_CALL
249 {
250  static uno::Reference< XCollection > xCol( new SwVbaAddins( this, mxContext ) );
251  if ( index.hasValue() )
252  return xCol->Item( index, uno::Any() );
253  return uno::makeAny( xCol );
254 }
255 
256 uno::Any SAL_CALL
258 {
259  uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentDocument() ));
260  if ( index.hasValue() )
261  return xCol->Item( index );
262  return uno::makeAny( xCol );
263 }
264 
265 uno::Any SAL_CALL
267 {
268  uno::Reference< text::XTextDocument > xTextDoc( getCurrentDocument(), uno::UNO_QUERY_THROW );
269  uno::Reference< XCollection > xCol( new SwVbaListGalleries( this, mxContext, xTextDoc ) );
270  if ( index.hasValue() )
271  return xCol->Item( index, uno::Any() );
272  return uno::makeAny( xCol );
273 }
274 
276 {
278 }
279 
280 void SAL_CALL SwVbaApplication::setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips )
281 {
282  SvxAutoCorrCfg::Get().SetAutoTextTip( _displayAutoCompleteTips );
283 }
284 
286 {
287  // the default value is wdCancelInterrupt in Word
288  return word::WdEnableCancelKey::wdCancelInterrupt;
289 }
290 
291 void SAL_CALL SwVbaApplication::setEnableCancelKey( sal_Int32/* _enableCancelKey */)
292 {
293  // seems not supported in Writer
294 }
295 
297 {
298  auto xWindow = getActiveWindow();
299  if (xWindow.is())
300  {
301  uno::Any aState = xWindow->getWindowState();
302  sal_Int32 nState;
303  if (aState >>= nState)
304  return nState;
305  }
306 
307  return word::WdWindowState::wdWindowStateNormal; // ?
308 }
309 
310 void SAL_CALL SwVbaApplication::setWindowState( sal_Int32 _windowstate )
311 {
312  try
313  {
314  auto xWindow = getActiveWindow();
315  if (xWindow.is())
316  {
317  uno::Any aState;
318  aState <<= _windowstate;
319  xWindow->setWindowState( aState );
320  }
321  }
322  catch (const uno::RuntimeException&)
323  {
324  }
325 }
326 
327 sal_Int32 SAL_CALL SwVbaApplication::getWidth()
328 {
329  auto pWindow = getActiveSwVbaWindow();
330  return pWindow->getWidth();
331 }
332 
333 void SAL_CALL SwVbaApplication::setWidth( sal_Int32 _width )
334 {
335  auto pWindow = getActiveSwVbaWindow();
336  pWindow->setWidth( _width );
337 }
338 
339 sal_Int32 SAL_CALL SwVbaApplication::getHeight()
340 {
341  auto pWindow = getActiveSwVbaWindow();
342  return pWindow->getHeight();
343 }
344 
345 void SAL_CALL SwVbaApplication::setHeight( sal_Int32 _height )
346 {
347  auto pWindow = getActiveSwVbaWindow();
348  pWindow->setHeight( _height );
349 }
350 
351 sal_Int32 SAL_CALL SwVbaApplication::getLeft()
352 {
353  auto pWindow = getActiveSwVbaWindow();
354  return pWindow->getLeft();
355 }
356 
357 void SAL_CALL SwVbaApplication::setLeft( sal_Int32 _left )
358 {
359  auto pWindow = getActiveSwVbaWindow();
360  pWindow->setLeft( _left );
361 }
362 
363 sal_Int32 SAL_CALL SwVbaApplication::getTop()
364 {
365  auto pWindow = getActiveSwVbaWindow();
366  return pWindow->getTop();
367 }
368 
369 void SAL_CALL SwVbaApplication::setTop( sal_Int32 _top )
370 {
371  auto pWindow = getActiveSwVbaWindow();
372  pWindow->setTop( _top );
373 }
374 
376 {
377  return "";
378 }
379 
381 {
382  return uno::Any(); // ???
383 }
384 
385 void SAL_CALL SwVbaApplication::setCustomizationContext(const uno::Any& /*_customizationcontext*/)
386 {
387  // ???
388 }
389 
390 void SAL_CALL SwVbaApplication::setStatusBar( const OUString& _statusbar )
391 {
392  // ScVbaAppSettings::setStatusBar() also uses the XStatusIndicator to show this, so maybe that is OK?
393  uno::Reference< frame::XModel > xModel = getCurrentDocument();
394  if (xModel.is())
395  {
396  uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY );
397  if (xStatusIndicatorSupplier.is())
398  {
399  uno::Reference< task::XStatusIndicator > xStatusIndicator = xStatusIndicatorSupplier->getStatusIndicator();
400  if (xStatusIndicator.is())
401  xStatusIndicator->start( _statusbar, 100 );
402  }
403  }
404 
405  // Yes, we intentionally use the "extensions.olebridge" tag here even if this is sw. We
406  // interpret setting the StatusBar property as a request from an Automation client to display
407  // the string in LibreOffice's debug output, and all other generic Automation support debug
408  // output (in extensions/source/ole) uses that tag. If the check for "cross-module" or mixed log
409  // areas in compilerplugins/clang/sallogareas.cxx is re-activated, this will have to be added as
410  // a special case.
411 
412  SAL_INFO("extensions.olebridge", "Client debug output: " << _statusbar);
413 }
414 
415 float SAL_CALL SwVbaApplication::CentimetersToPoints( float Centimeters )
416 {
417  return VbaApplicationBase::CentimetersToPoints( Centimeters );
418 }
419 
421 {
422  // No idea what we should or could do
423 }
424 
425 void SAL_CALL SwVbaApplication::Resize( sal_Int32 Width, sal_Int32 Height )
426 {
427  // Have to do it like this as the Width and Height are hidden away in the ooo::vba::XWindowBase
428  // which ooo::vba::word::XApplication does not inherit from. SwVbaWindow, however, does inherit
429  // from XWindowBase. Ugh.
430  auto pWindow = getActiveSwVbaWindow();
431  pWindow->setWidth( Width );
432  pWindow->setHeight( Height );
433 }
434 
435 void SAL_CALL SwVbaApplication::Move( sal_Int32 Left, sal_Int32 Top )
436 {
437  // See comment in Resize().
438  auto pWindow = getActiveSwVbaWindow();
439  pWindow->setLeft( Left );
440  pWindow->setTop( Top );
441 }
442 
443 // XInterfaceWithIID
444 
445 OUString SAL_CALL
447 {
448  return "{82154421-0FBF-11d4-8313-005004526AB4}";
449 }
450 
451 // XConnectable
452 
453 OUString SAL_CALL
455 {
456  return "{82154423-0FBF-11D4-8313-005004526AB4}";
457 }
458 
459 TypeAndIID SAL_CALL
461 {
462  TypeAndIID aResult =
463  { word::XApplicationOutgoing::static_type(),
464  "{82154422-0FBF-11D4-8313-005004526AB4}"
465  };
466 
467  return aResult;
468 }
469 
470 uno::Reference<XConnectionPoint> SAL_CALL
472 {
473  uno::Reference<XConnectionPoint> xCP(new SwVbaApplicationOutgoingConnectionPoint(this));
474  return xCP;
475 }
476 
477 OUString
479 {
480  return "SwVbaApplication";
481 }
482 
483 uno::Sequence< OUString >
485 {
486  static uno::Sequence< OUString > const aServiceNames
487  {
488  "ooo.vba.word.Application"
489  };
490  return aServiceNames;
491 }
492 
493 uno::Reference< frame::XModel >
495 {
496  return getCurrentWordDoc( mxContext );
497 }
498 
499 // XSinkCaller
500 
501 void SAL_CALL
502 SwVbaApplication::CallSinks( const OUString& Method, uno::Sequence< uno::Any >& Arguments )
503 {
504  for (auto& i : mvSinks)
505  {
506  if (i.is())
507  i->Call(Method, Arguments);
508  }
509 }
510 
511 // SwVbaApplicationOutgoingConnectionPoint
512 
513 SwVbaApplicationOutgoingConnectionPoint::SwVbaApplicationOutgoingConnectionPoint( SwVbaApplication* pApp ) :
514  mpApp(pApp)
515 {
516 }
517 
518 // XConnectionPoint
519 sal_uInt32 SAL_CALL
520 SwVbaApplicationOutgoingConnectionPoint::Advise( const uno::Reference< XSink >& Sink )
521 {
522  return mpApp->AddSink(Sink);
523 }
524 
525 void SAL_CALL
526 SwVbaApplicationOutgoingConnectionPoint::Unadvise( sal_uInt32 Cookie )
527 {
528  mpApp->RemoveSink( Cookie );
529 }
530 
531 // SwWordBasic
532 
533 SwWordBasic::SwWordBasic( SwVbaApplication* pApp ) :
534  mpApp(pApp)
535 {
536 }
537 
538 // XWordBasic
539 sal_Int32 SAL_CALL
540 SwWordBasic::getMailMergeMainDocumentType()
541 {
542  return SwVbaMailMerge::get( mpApp->getParent(), mpApp->getContext() )->getMainDocumentType();
543 }
544 
545 // XWordBasic
546 void SAL_CALL
547 SwWordBasic::setMailMergeMainDocumentType( sal_Int32 _mailmergemaindocumenttype )
548 {
549  SwVbaMailMerge::get( mpApp->getParent(), mpApp->getContext() )->setMainDocumentType( _mailmergemaindocumenttype );
550 }
551 
552 void SAL_CALL
553 SwWordBasic::FileOpen( const OUString& Name, const uno::Any& ConfirmConversions, const uno::Any& ReadOnly, const uno::Any& AddToMru, const uno::Any& PasswordDoc, const uno::Any& PasswordDot, const uno::Any& Revert, const uno::Any& WritePasswordDoc, const uno::Any& WritePasswordDot )
554 {
555  uno::Any aDocuments = mpApp->Documents( uno::Any() );
556 
557  uno::Reference<word::XDocuments> rDocuments;
558 
559  if (aDocuments >>= rDocuments)
560  rDocuments->Open( Name, ConfirmConversions, ReadOnly, AddToMru, PasswordDoc, PasswordDot, Revert, WritePasswordDoc, WritePasswordDot, uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any() );
561 }
562 
563 void SAL_CALL
564 SwWordBasic::FileSave()
565 {
566  uno::Reference< frame::XModel > xModel( mpApp->getCurrentDocument(), uno::UNO_SET_THROW );
567  dispatchRequests(xModel,".uno:Save");
568 }
569 
570 void SAL_CALL
571 SwWordBasic::FileSaveAs( const css::uno::Any& Name,
572  const css::uno::Any& Format,
573  const css::uno::Any& /*LockAnnot*/,
574  const css::uno::Any& /*Password*/,
575  const css::uno::Any& /*AddToMru*/,
576  const css::uno::Any& /*WritePassword*/,
577  const css::uno::Any& /*RecommendReadOnly*/,
578  const css::uno::Any& /*EmbedFonts*/,
579  const css::uno::Any& /*NativePictureFormat*/,
580  const css::uno::Any& /*FormsData*/,
581  const css::uno::Any& /*SaveAsAOCELetter*/ )
582 {
583  SAL_INFO("sw.vba", "WordBasic.FileSaveAs(Name:=" << Name << ",Format:=" << Format << ")");
584 
585  uno::Reference< frame::XModel > xModel( mpApp->getCurrentDocument(), uno::UNO_SET_THROW );
586 
587  // Based on SwVbaDocument::SaveAs2000.
588 
589  OUString sFileName;
590  Name >>= sFileName;
591 
592  OUString sURL;
593  osl::FileBase::getFileURLFromSystemPath( sFileName, sURL );
594 
595  // Detect if there is no path then we need to use the current folder.
596  INetURLObject aURL( sURL );
597  sURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
598  if( sURL.isEmpty() )
599  {
600  // Need to add cur dir ( of this document ) or else the 'Work' dir
601  sURL = xModel->getURL();
602 
603  if ( sURL.isEmpty() )
604  {
605  // Not path available from 'this' document. Need to add the 'document'/work directory then.
606  // Based on SwVbaOptions::getValueEvent()
607  uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() );
608  OUString sPathUrl;
609  xPathSettings->getPropertyValue( "Work" ) >>= sPathUrl;
610  // Path could be a multipath, Microsoft doesn't support this feature in Word currently.
611  // Only the last path is from interest.
612  // No idea if this crack is relevant for WordBasic or not.
613  sal_Int32 nIndex = sPathUrl.lastIndexOf( ';' );
614  if( nIndex != -1 )
615  {
616  sPathUrl = sPathUrl.copy( nIndex + 1 );
617  }
618 
619  aURL.SetURL( sPathUrl );
620  }
621  else
622  {
623  aURL.SetURL( sURL );
624  aURL.Append( sFileName );
625  }
626  sURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
627 
628  }
629  sal_Int32 nFileFormat = word::WdSaveFormat::wdFormatDocument;
630  Format >>= nFileFormat;
631 
632  uno::Sequence aProps{ comphelper::makePropertyValue("FilterName", css::uno::Any()),
633  comphelper::makePropertyValue("FileName", sURL) };
634 
635  setFilterPropsFromFormat( nFileFormat, aProps );
636 
637  dispatchRequests(xModel,".uno:SaveAs",aProps);
638 }
639 
640 void SAL_CALL
641 SwWordBasic::FileClose( const css::uno::Any& Save )
642 {
643  uno::Reference< frame::XModel > xModel( mpApp->getCurrentDocument(), uno::UNO_SET_THROW );
644 
645  sal_Int16 nSave = 0;
646  if (Save.hasValue() && (Save >>= nSave) && (nSave == 0 || nSave == 1))
647  FileSave();
648 
649  // FIXME: Here I would much prefer to call VbaDocumentBase::Close() but not sure how to get at
650  // the VbaDocumentBase of the current document. (Probably it is easy and I haven't looked hard
651  // enough.)
652  //
653  // FIXME: Error handling. If there is no current document, return some kind of error? But for
654  // now, just ignore errors. This code is written to work for a very specific customer use case
655  // anyway, not for an arbitrary sequence of COM calls to the "VBA" API.
656  dispatchRequests(xModel,".uno:CloseDoc");
657 }
658 
659 void SAL_CALL
660 SwWordBasic::ToolsOptionsView( const css::uno::Any& DraftFont,
661  const css::uno::Any& WrapToWindow,
662  const css::uno::Any& PicturePlaceHolders,
663  const css::uno::Any& FieldCodes,
664  const css::uno::Any& BookMarks,
665  const css::uno::Any& FieldShading,
666  const css::uno::Any& StatusBar,
667  const css::uno::Any& HScroll,
668  const css::uno::Any& VScroll,
669  const css::uno::Any& StyleAreaWidth,
670  const css::uno::Any& Tabs,
671  const css::uno::Any& Spaces,
672  const css::uno::Any& Paras,
673  const css::uno::Any& Hyphens,
674  const css::uno::Any& Hidden,
675  const css::uno::Any& ShowAll,
676  const css::uno::Any& Drawings,
677  const css::uno::Any& Anchors,
678  const css::uno::Any& TextBoundaries,
679  const css::uno::Any& VRuler,
680  const css::uno::Any& Highlight )
681 {
682  SAL_INFO("sw.vba", "WordBasic.ToolsOptionsView("
683  "DraftFont:=" << DraftFont
684  << ", WrapToWindow:=" << WrapToWindow
685  << ", PicturePlaceHolders:=" << PicturePlaceHolders
686  << ", FieldCodes:=" << FieldCodes
687  << ", BookMarks:=" << BookMarks
688  << ", FieldShading:=" << FieldShading
689  << ", StatusBar:=" << StatusBar
690  << ", HScroll:=" << HScroll
691  << ", VScroll:=" << VScroll
692  << ", StyleAreaWidth:=" << StyleAreaWidth
693  << ", Tabs:=" << Tabs
694  << ", Spaces:=" << Spaces
695  << ", Paras:=" << Paras
696  << ", Hyphens:=" << Hyphens
697  << ", Hidden:=" << Hidden
698  << ", ShowAll:=" << ShowAll
699  << ", Drawings:=" << Drawings
700  << ", Anchors:=" << Anchors
701  << ", TextBoundaries:=" << TextBoundaries
702  << ", VRuler:=" << VRuler
703  << ", Highlight:=" << Highlight
704  << ")");
705 }
706 
707 css::uno::Any SAL_CALL
708 SwWordBasic::WindowName( const css::uno::Any& /*Number*/ )
709 {
710  return css::uno::makeAny( mpApp->getActiveSwVbaWindow()->getCaption() );
711 }
712 
713 css::uno::Any SAL_CALL
714 SwWordBasic::ExistingBookmark( const OUString& Name )
715 {
716  uno::Reference< word::XBookmarks > xBookmarks( mpApp->getActiveDocument()->Bookmarks( uno::Any() ), uno::UNO_QUERY );
717  return css::uno::makeAny( xBookmarks.is() && xBookmarks->Exists( Name ) );
718 }
719 
720 void SAL_CALL
721 SwWordBasic::MailMergeOpenDataSource( const OUString& Name, const css::uno::Any& Format,
722  const css::uno::Any& ConfirmConversions, const css::uno::Any& ReadOnly,
723  const css::uno::Any& LinkToSource, const css::uno::Any& AddToRecentFiles,
724  const css::uno::Any& PasswordDocument, const css::uno::Any& PasswordTemplate,
725  const css::uno::Any& Revert, const css::uno::Any& WritePasswordDocument,
726  const css::uno::Any& WritePasswordTemplate, const css::uno::Any& Connection,
727  const css::uno::Any& SQLStatement, const css::uno::Any& SQLStatement1,
728  const css::uno::Any& OpenExclusive, const css::uno::Any& SubType )
729 {
730  mpApp->getActiveDocument()->getMailMerge()->OpenDataSource( Name, Format, ConfirmConversions, ReadOnly,
731  LinkToSource, AddToRecentFiles,
732  PasswordDocument, PasswordTemplate,
733  Revert, WritePasswordDocument,
734  WritePasswordTemplate, Connection,
735  SQLStatement, SQLStatement1,
736  OpenExclusive, SubType );
737 }
738 
739 css::uno::Any SAL_CALL
740 SwWordBasic::AppMaximize( const css::uno::Any& WindowName, const css::uno::Any& State )
741 {
742  SAL_INFO("sw.vba", "WordBasic.AppMaximize( WindowName:=" << WindowName << ", State:=" << State);
743 
744  // FIXME: Implement if necessary
745  return css::uno::makeAny( sal_Int32(0) );
746 }
747 
748 css::uno::Any SAL_CALL
749 SwWordBasic::DocMaximize( const css::uno::Any& State )
750 {
751  SAL_INFO("sw.vba", "WordBasic.DocMaximize(State:=" << State << ")");
752 
753  // FIXME: Implement if necessary
754  return css::uno::makeAny( sal_Int32(0) );
755 }
756 
757 void SAL_CALL
758 SwWordBasic::AppShow( const css::uno::Any& WindowName )
759 {
760  SAL_INFO("sw.vba", "WordBasic.AppShow(WindowName:=" << WindowName << ")");
761 
762  // FIXME: Implement if necessary
763 }
764 
765 css::uno::Any SAL_CALL
766 SwWordBasic::AppCount()
767 {
768  SAL_INFO("sw.vba", "WordBasic.AppCount()");
769 
770  // FIXME: Implement if necessary. Return a random number for now.
771  return css::uno::makeAny( sal_Int32(2) );
772 }
773 
774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual void SAL_CALL setStatusBar(const OUString &_statusbar) override
SwVbaApplication(css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() override
URL aURL
bool hasValue()
sal_Int32 nIndex
virtual void SAL_CALL ShowMe() override
static SvxAutoCorrCfg & Get()
static rtl::Reference< SwVbaMailMerge > const & get(const css::uno::Reference< ooo::vba::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() override
uno::Reference< uno::XComponentContext > mxContext
virtual css::uno::Reference< ov::XConnectionPoint > SAL_CALL FindConnectionPoint() override
virtual ~SwVbaApplication() override
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
sal_uInt32 AddSink(const css::uno::Reference< ooo::vba::XSink > &xSink)
virtual void SAL_CALL setWindowState(sal_Int32 _windowstate) override
virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() override
virtual css::uno::Reference< ooo::vba::word::XWordBasic > SAL_CALL getWordBasic() override
virtual sal_Int32 SAL_CALL getWindowState() override
virtual float SAL_CALL CentimetersToPoints(float Centimeters) override
Sequence< OUString > aServiceNames
std::vector< css::uno::Reference< ooo::vba::XSink > > mvSinks
virtual OUString getServiceImplName() override
virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() override
Reference< XController > xController
virtual ov::TypeAndIID SAL_CALL GetConnectionPoint() override
virtual sal_Int32 SAL_CALL getLeft() override
virtual sal_Bool SAL_CALL getDisplayAutoCompleteTips() override
virtual void SAL_CALL setDisplayAutoCompleteTips(sal_Bool _displayAutoCompleteTips) override
cppu::ImplInheritanceHelper< VbaApplicationBase, ooo::vba::word::XApplication, ooo::vba::XSinkCaller > SwVbaApplication_BASE
virtual void SAL_CALL setEnableCancelKey(sal_Int32 _enableCancelKey) override
virtual css::uno::Any SAL_CALL Documents(const css::uno::Any &aIndex) override
virtual css::uno::Any SAL_CALL CommandBars(const css::uno::Any &aIndex) override
virtual void SAL_CALL CallSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments) override
virtual css::uno::Any SAL_CALL CommandBars(const css::uno::Any &aIndex) override
virtual void SAL_CALL setWidth(sal_Int32 _width) override
virtual OUString SAL_CALL GetIIDForClassItselfNotCoclass() override
virtual OUString SAL_CALL getIID() override
virtual sal_Int32 SAL_CALL getHeight() override
virtual css::uno::Any SAL_CALL ListGalleries(const css::uno::Any &aIndex) override
rtl::Reference< SwVbaWindow > getActiveSwVbaWindow()
virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() override
virtual css::uno::Sequence< OUString > getServiceNames() override
#define SW_MOD()
Definition: swmodule.hxx:256
int i
void ensure()
Definition: swdll.cxx:67
bool IsAutoTextTip() const
virtual css::uno::Any SAL_CALL Dialogs(const css::uno::Any &aIndex) override
virtual float SAL_CALL CentimetersToPoints(float Centimeters) override
uno::Reference< frame::XModel > getCurrentWordDoc(const uno::Reference< uno::XComponentContext > &xContext)
virtual sal_Int32 SAL_CALL getWidth() override
unsigned char sal_Bool
virtual css::uno::Any SAL_CALL getCustomizationContext() override
virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() override
virtual OUString SAL_CALL getStatusBar() override
virtual void SAL_CALL setHeight(sal_Int32 _height) override
virtual void SAL_CALL Resize(sal_Int32 Width, sal_Int32 Height) override
virtual sal_Int32 SAL_CALL getTop() override
virtual sal_Int32 SAL_CALL getEnableCancelKey() override
State
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()
void RemoveSink(sal_uInt32 nNumber)
virtual void SAL_CALL Move(sal_Int32 Left, sal_Int32 Top) override
virtual OUString SAL_CALL getName() override
void SetAutoTextTip(bool bSet)
css::uno::Reference< css::uno::XComponentContext > const & getContext() const
Reference< XModel > xModel
virtual void SAL_CALL setCustomizationContext(const css::uno::Any &_customizationcontext) override
void dispatchRequests(const uno::Reference< frame::XModel > &xModel, const OUString &aUrl, const uno::Sequence< beans::PropertyValue > &sProps)
virtual void SAL_CALL setLeft(sal_Int32 _left) override
virtual css::uno::Any SAL_CALL Addins(const css::uno::Any &aIndex) override
virtual void SAL_CALL setTop(sal_Int32 _top) override
sal_Int32 nState