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