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