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