LibreOffice Module vbahelper (master) 1
vbahelper.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/util/URLTransformer.hpp>
21#include <com/sun/star/util/XURLTransformer.hpp>
22#include <com/sun/star/frame/XDispatchProvider.hpp>
23#include <com/sun/star/frame/XModel.hpp>
24#include <com/sun/star/frame/XFrame.hpp>
25#include <com/sun/star/frame/XController.hpp>
26#include <com/sun/star/frame/XModel2.hpp>
27#include <com/sun/star/script/BasicErrorException.hpp>
28#include <com/sun/star/script/XDefaultProperty.hpp>
29#include <com/sun/star/script/XInvocation.hpp>
30#include <com/sun/star/script/Converter.hpp>
31#include <com/sun/star/uno/XComponentContext.hpp>
32#include <com/sun/star/lang/XUnoTunnel.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/beans/theIntrospection.hpp>
35#include <com/sun/star/util/MeasureUnit.hpp>
36#include <com/sun/star/awt/XControl.hpp>
37#include <com/sun/star/awt/XWindow.hpp>
38#include <com/sun/star/awt/XDialog.hpp>
39#include <com/sun/star/awt/XUnitConversion.hpp>
40#include <com/sun/star/drawing/XShape.hpp>
41#include <ooo/vba/XHelperInterface.hpp>
42
47
48#include <sfx2/objsh.hxx>
49#include <sfx2/viewfrm.hxx>
50#include <sfx2/dispatch.hxx>
51#include <sfx2/app.hxx>
52#include <sfx2/sfxsids.hrc>
53#include <svl/stritem.hxx>
54#include <svl/eitem.hxx>
55#include <svl/intitem.hxx>
56#include <svl/itemset.hxx>
57#include <sfx2/docfac.hxx>
58#include <sfx2/viewfac.hxx>
59
60#include <basic/sbstar.hxx>
61#include <basic/basmgr.hxx>
62#include <basic/sbmod.hxx>
63#include <basic/sbuno.hxx>
64#include <basic/sberrors.hxx>
66#include <rtl/ustrbuf.hxx>
67#include <sfx2/viewsh.hxx>
68#include <sal/log.hxx>
70#include <utility>
71#include <vcl/svapp.hxx>
72#include <vcl/window.hxx>
73#include <vcl/syswin.hxx>
77
78using namespace ::com::sun::star;
79using namespace ::ooo::vba;
80
81
82namespace ooo::vba
83{
84
85// helper method to determine if the view ( calc ) is in print-preview mode
86static bool isInPrintPreview( SfxViewFrame* pView )
87{
88 sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0;
90nViewNo && !pView->GetObjectShell()->IsInPlaceActive() )
91 {
92 SfxViewFactory &rViewFactory =
93 pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
94 if ( pView->GetCurViewId() == rViewFactory.GetOrdinal() )
95 return true;
96 }
97 return false;
98}
99
100uno::Reference< beans::XIntrospectionAccess >
102{
103 static uno::Reference< beans::XIntrospection > xIntrospection( beans::theIntrospection::get( comphelper::getProcessComponentContext() ) );
104 return xIntrospection->inspect( aObject );
105}
106
107uno::Reference< script::XTypeConverter > const &
108getTypeConverter( const uno::Reference< uno::XComponentContext >& xContext )
109{
110 static uno::Reference< script::XTypeConverter > xTypeConv( script::Converter::create(xContext) );
111 return xTypeConv;
112}
113const uno::Any&
115{
116 static uno::Any aNULLL{ uno::Reference< uno::XInterface >() };
117 return aNULLL;
118}
119
120void dispatchExecute(SfxViewShell const * pViewShell, sal_uInt16 nSlot)
121{
122 SfxViewFrame* pViewFrame = nullptr;
123 if ( pViewShell )
124 pViewFrame = &pViewShell->GetViewFrame();
125 if ( pViewFrame )
126 {
127 SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
128 if( pDispatcher )
129 {
130 pDispatcher->Execute( nSlot , SfxCallMode::SYNCHRON );
131 }
132 }
133}
134
135void
136dispatchRequests (const uno::Reference< frame::XModel>& xModel, const OUString & aUrl, const uno::Sequence< beans::PropertyValue >& sProps )
137{
138 util::URL url;
139 url.Complete = aUrl;
140 uno::Reference<frame::XController> xController = xModel->getCurrentController();
141 uno::Reference<frame::XFrame> xFrame = xController->getFrame();
142 uno::Reference<frame::XDispatchProvider> xDispatchProvider (xFrame,uno::UNO_QUERY_THROW);
143 try
144 {
145 uno::Reference<uno::XComponentContext > xContext(
147 uno::Reference<util::XURLTransformer> xParser( util::URLTransformer::create(xContext) );
148 xParser->parseStrict (url);
149 }
150 catch (const uno::Exception&)
151 {
152 return;
153 }
154
155 uno::Reference<frame::XDispatch> xDispatcher = xDispatchProvider->queryDispatch(url,"",0);
156
157 sal_Int32 nProps = sProps.getLength();
158 uno::Sequence<beans::PropertyValue> dispatchProps(nProps + 1);
159
160 if ( nProps )
161 {
162 std::copy(sProps.begin(), sProps.end(), dispatchProps.getArray());
163 }
164
165 if ( xDispatcher.is() )
166 {
167 xDispatcher->dispatch( url, dispatchProps );
168 }
169}
170
171void
172dispatchRequests( const uno::Reference< frame::XModel>& xModel, const OUString& aUrl )
173{
174 uno::Sequence<beans::PropertyValue> dispatchProps;
175 dispatchRequests( xModel, aUrl, dispatchProps );
176}
177
178uno::Reference< frame::XModel >
179getCurrentDoc( const OUString& sKey )
180{
181 uno::Reference< frame::XModel > xModel;
183 if (pBasic == nullptr)
184 {
185 SAL_INFO("vbahelper", "getModelFromBasic() StarBASIC* is NULL" );
186 return xModel;
187 }
188 SbxObject* basicChosen = pBasic;
189 SbxObject* pParent = pBasic->GetParent();
190 SbxObject* pParentParent = pParent ? pParent->GetParent() : nullptr;
191
192 if( pParentParent )
193 {
194 basicChosen = pParentParent;
195 }
196 else if( pParent )
197 {
198 basicChosen = pParent;
199 }
200
201
202 uno::Any aModel;
203 SbxVariable *pCompVar = basicChosen->Find( sKey, SbxClassType::Object );
204
205 if ( pCompVar )
206 {
207 aModel = sbxToUnoValue( pCompVar );
208 if ( !( aModel >>= xModel ) || !xModel.is() )
209 {
210 throw uno::RuntimeException(
211 "Can't extract model from basic ( it's obviously not set yet therefore don't know the current document context)" );
212 }
213 SAL_INFO("vbahelper", "Have model points to url " << xModel->getURL());
214 }
215 else
216 {
217 SAL_INFO("vbahelper", "Failed to get " << sKey);
218 throw uno::RuntimeException( "Can't determine the currently selected document" );
219 }
220 return xModel;
221}
222
224static uno::Reference< frame::XModel >
225getCurrentDocCtx( const OUString& ctxName, const uno::Reference< uno::XComponentContext >& xContext )
226{
227 uno::Reference< frame::XModel > xModel;
228 // try fallback to calling doc
229 css::uno::Reference< css::container::XNameAccess > xNameAccess( xContext, css::uno::UNO_QUERY_THROW );
230 xModel.set( xNameAccess->getByName( ctxName ), uno::UNO_QUERY_THROW );
231 return xModel;
232}
233
234uno::Reference< frame::XModel >
235getThisExcelDoc( const uno::Reference< uno::XComponentContext >& xContext )
236{
237 return getCurrentDocCtx( "ExcelDocumentContext" , xContext );
238}
239
240uno::Reference< frame::XModel >
241getThisWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
242{
243 return getCurrentDocCtx( "WordDocumentContext" , xContext );
244}
245
246 uno::Reference< frame::XModel >
247getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext )
248{
249 uno::Reference< frame::XModel > xModel;
250 try
251 {
252 xModel = getCurrentDoc( "ThisExcelDoc" );
253 }
254 catch (const uno::Exception&)
255 {
256 try
257 {
258 xModel = getThisExcelDoc( xContext );
259 }
260 catch (const uno::Exception&)
261 {
262 }
263 }
264 return xModel;
265}
266
267 uno::Reference< frame::XModel >
268getCurrentWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
269{
270 uno::Reference< frame::XModel > xModel;
271 try
272 {
273 xModel = getCurrentDoc( "ThisWordDoc" );
274 }
275 catch (const uno::Exception&)
276 {
277 try
278 {
279 xModel = getThisWordDoc( xContext );
280 }
281 catch (const uno::Exception&)
282 {
283 }
284 }
285 return xModel;
286}
287
288sal_Int32
289OORGBToXLRGB( sal_Int32 nCol )
290{
291 sal_Int32 nAutoBits = nCol;
292 nAutoBits &= 0xFF000000;
293 sal_Int32 nRed = nCol;
294 nRed &= 0x00FF0000;
295 nRed >>= 16;
296 sal_Int32 nGreen = nCol;
297 nGreen &= 0x0000FF00;
298 nGreen >>= 8;
299 sal_Int32 nBlue = nCol;
300 nBlue &= 0x000000FF;
301 sal_Int32 nRGB = ( nAutoBits | (nBlue << 16) | (nGreen << 8) | nRed );
302 return nRGB;
303}
304
305sal_Int32
306XLRGBToOORGB( sal_Int32 nCol )
307{
308 sal_Int32 nAutoBits = nCol;
309 nAutoBits &= 0xFF000000;
310
311 sal_Int32 nBlue = nCol;
312 nBlue &= 0x00FF0000;
313 nBlue >>= 16;
314 sal_Int32 nGreen = nCol;
315 nGreen &= 0x0000FF00;
316 nGreen >>= 8;
317 sal_Int32 nRed = nCol;
318 nRed &= 0x000000FF;
319 sal_Int32 nRGB = ( nAutoBits | (nRed << 16) | (nGreen << 8) | nBlue );
320 return nRGB;
321}
323OORGBToXLRGB( const uno::Any& aCol )
324{
325 sal_Int32 nCol(0);
326 aCol >>= nCol;
327 nCol = OORGBToXLRGB( nCol );
328 return uno::Any( nCol );
329}
331XLRGBToOORGB( const uno::Any& aCol )
332{
333 sal_Int32 nCol(0);
334 aCol >>= nCol;
335 nCol = XLRGBToOORGB( nCol );
336 return uno::Any( nCol );
337}
338
339void PrintOutHelper( SfxViewShell const * pViewShell, const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& /*ActivePrinter*/, const uno::Any& /*PrintToFile*/, const uno::Any& Collate, const uno::Any& PrToFileName, bool bUseSelection )
340{
341 sal_Int32 nTo = 0;
342 sal_Int32 nFrom = 0;
343 sal_Int16 nCopies = 1;
344 bool bPreview = false;
345 bool bCollate = false;
346 bool bSelection = bUseSelection;
347 From >>= nFrom;
348 To >>= nTo;
349 Copies >>= nCopies;
350 Preview >>= bPreview;
351 if ( nCopies > 1 ) // Collate only useful when more that 1 copy
352 Collate >>= bCollate;
353
354 OUString sRange( "-" );
355 OUString sFileName;
356
357 if ( nFrom || nTo )
358 {
359 if ( nFrom )
360 sRange = OUString::number( nFrom ) + sRange;
361 if ( nTo )
362 sRange += OUString::number( nTo );
363 }
364
365 PrToFileName >>= sFileName;
366 SfxViewFrame* pViewFrame = nullptr;
367 if ( pViewShell )
368 pViewFrame = &pViewShell->GetViewFrame();
369 if ( !pViewFrame )
370 return;
371
372 SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
373
374 SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate );
375 aArgs.Put( sfxCollate, sfxCollate.Which() );
376 SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
377 aArgs.Put( sfxCopies, sfxCopies.Which() );
378 if ( !sFileName.isEmpty() )
379 {
380 SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
381 aArgs.Put( sfxFileName, sfxFileName.Which() );
382
383 }
384 if ( !sRange.isEmpty() )
385 {
386 SfxStringItem sfxRange( SID_PRINT_PAGES, sRange );
387 aArgs.Put( sfxRange, sfxRange.Which() );
388 }
389 SfxBoolItem sfxSelection( SID_SELECTION, bSelection );
390 aArgs.Put( sfxSelection, sfxSelection.Which() );
391 SfxBoolItem sfxAsync( SID_ASYNCHRON, false );
392 aArgs.Put( sfxAsync, sfxAsync.Which() );
393 SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
394
395 if ( !pDispatcher )
396 return;
397
398 if ( bPreview )
399 {
400 if ( !pViewFrame->GetFrame().IsInPlace() )
401 {
402 // #TODO is this necessary ( calc specific )
403// SC_MOD()->InputEnterHandler();
404 pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SfxCallMode::SYNCHRON );
405 WaitUntilPreviewIsClosed( pViewFrame );
406 }
407 }
408 else
409 pDispatcher->Execute( sal_uInt16(SID_PRINTDOC), SfxCallMode::SYNCHRON, aArgs );
410
411
412 // #FIXME #TODO
413 // 1 ActivePrinter ( how/can we switch a printer via API? )
414 // 2 PrintToFile ( ms behaviour if this option is specified but no
415 // filename supplied 'PrToFileName' then the user will be prompted )
416 // 3 Need to check behaviour of Selected sheets with range ( e.g. From & To
417 // values ) in oOO these options are mutually exclusive
418 // 4 There is a pop up to do with transparent objects in the print source
419 // should be able to disable that via configuration for the duration
420 // of this method
421}
422
423void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, SfxViewShell const * pViewShell )
424{
425 SfxViewFrame* pViewFrame = nullptr;
426 if ( pViewShell )
427 pViewFrame = &pViewShell->GetViewFrame();
428 if ( pViewFrame )
429 {
430 if ( !pViewFrame->GetFrame().IsInPlace() )
431 {
432 dispatchExecute( pViewShell, SID_VIEWSHELL1 );
433 WaitUntilPreviewIsClosed( pViewFrame );
434 }
435 }
436}
437
439{
440 while ( pViewFrame && isInPrintPreview( pViewFrame ) && !Application::IsQuit())
442}
443
444bool extractBoolFromAny( const uno::Any& rAny )
445{
446 switch( rAny.getValueType().getTypeClass() )
447 {
448 case uno::TypeClass_BOOLEAN:
449 return rAny.get< bool >();
450 case uno::TypeClass_FLOAT:
451 return rAny.get< float >() != 0.0;
452 case uno::TypeClass_DOUBLE:
453 return rAny.get< double >() != 0.0;
454 case uno::TypeClass_BYTE:
455 case uno::TypeClass_SHORT:
456 case uno::TypeClass_LONG:
457 return rAny.get< sal_Int32 >() != 0;
458 case uno::TypeClass_HYPER:
459 return rAny.get< sal_Int64 >() != 0;
460 default:;
461 }
462 throw uno::RuntimeException( "Invalid type, cannot convert to boolean." , nullptr );
463}
464
465OUString extractStringFromAny( const uno::Any& rAny, bool bUppercaseBool )
466{
467 switch( rAny.getValueType().getTypeClass() )
468 {
469 case uno::TypeClass_STRING:
470 return rAny.get< OUString >();
471 case uno::TypeClass_BOOLEAN:
472 return bUppercaseBool ?
473 (rAny.get< bool >() ? OUString( "TRUE" ) : OUString( "FALSE" )) :
474 OUString::boolean( rAny.get< bool >() );
475 case uno::TypeClass_FLOAT:
476 return OUString::number( rAny.get< float >() );
477 case uno::TypeClass_DOUBLE:
478 return OUString::number( rAny.get< double >() );
479 case uno::TypeClass_BYTE:
480 case uno::TypeClass_SHORT:
481 case uno::TypeClass_LONG:
482 return OUString::number( rAny.get< sal_Int32 >() );
483 case uno::TypeClass_HYPER:
484 return OUString::number( rAny.get< sal_Int64 >() );
485 default:;
486 }
487 throw uno::RuntimeException( "Invalid type, cannot convert to string." , nullptr );
488}
489
490OUString extractStringFromAny( const uno::Any& rAny, const OUString& rDefault, bool bUppercaseBool )
491{
492 return rAny.hasValue() ? extractStringFromAny( rAny, bUppercaseBool ) : rDefault;
493}
494
495OUString getAnyAsString( const uno::Any& pvargItem )
496{
497 return extractStringFromAny( pvargItem );
498}
499
500
501OUString
502ContainerUtilities::getUniqueName( const uno::Sequence< OUString >& _slist, const OUString& _sElementName, std::u16string_view _sSuffixSeparator)
503{
504 return getUniqueName(_slist, _sElementName, _sSuffixSeparator, sal_Int32(2));
505}
506
507OUString
508ContainerUtilities::getUniqueName( const uno::Sequence< OUString >& _slist, const OUString& _sElementName, std::u16string_view _sSuffixSeparator, sal_Int32 _nStartSuffix)
509{
510 if ( !_slist.hasElements() )
511 return _sElementName;
512
513 OUString scompname = _sElementName;
514 sal_Int32 a = _nStartSuffix;
515
516 for (;;)
517 {
518 if (FieldInList(_slist, scompname) == -1)
519 return scompname;
520
521 scompname = _sElementName + _sSuffixSeparator + OUString::number( a++ );
522 }
523}
524
525sal_Int32
526ContainerUtilities::FieldInList( const uno::Sequence< OUString >& SearchList, const OUString& SearchString )
527{
528 // I wonder why comparing lexicographically is done
529 // when it's a match, is it interesting?
530 return comphelper::findValue(SearchList, SearchString);
531}
532
533static bool NeedEsc(sal_Unicode cCode)
534{
535 return OUString(".^$+\\|{}()").indexOf(cCode) != -1;
536}
537
538OUString VBAToRegexp(const OUString &rIn)
539{
540 OUStringBuffer sResult;
541 const sal_Unicode *start = rIn.getStr();
542 const sal_Unicode *end = start + rIn.getLength();
543
544 int seenright = 0;
545
546 while (start < end)
547 {
548 switch (*start)
549 {
550 case '?':
551 sResult.append('.');
552 start++;
553 break;
554 case '*':
555 sResult.append(".*");
556 start++;
557 break;
558 case '#':
559 sResult.append("[0-9]");
560 start++;
561 break;
562 case '~':
563 sResult.append('\\');
564 sResult.append(*(++start));
565 start++;
566 break;
567 // dump the ~ and escape the next character
568 case ']':
569 sResult.append('\\');
570 sResult.append(*start++);
571 break;
572 case '[':
573 sResult.append(*start++);
574 seenright = 0;
575 while (start < end && !seenright)
576 {
577 switch (*start)
578 {
579 case '[':
580 case '?':
581 case '*':
582 sResult.append('\\');
583 sResult.append(*start);
584 break;
585 case ']':
586 sResult.append(*start);
587 seenright = 1;
588 break;
589 case '!':
590 sResult.append('^');
591 break;
592 default:
593 if (NeedEsc(*start))
594 sResult.append('\\');
595 sResult.append(*start);
596 break;
597 }
598 start++;
599 }
600 break;
601 default:
602 if (NeedEsc(*start))
603 sResult.append('\\');
604 sResult.append(*start++);
605 }
606 }
607
608 return sResult.makeStringAndClear( );
609}
610
611static double getPixelToMeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, bool bVertical)
612{
613 return bVertical ? xDevice->getInfo().PixelPerMeterY : xDevice->getInfo().PixelPerMeterX;
614}
615
616double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, bool bVertical)
617{
618 double fConvertFactor = getPixelToMeterConversionFactor( xDevice, bVertical );
619 return o3tl::convert(fPoints, o3tl::Length::pt, o3tl::Length::m) * fConvertFactor;
620}
621double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, bool bVertical)
622{
623 double fConvertFactor = getPixelToMeterConversionFactor( xDevice, bVertical );
624 return o3tl::convert(fPixels / fConvertFactor, o3tl::Length::m, o3tl::Length::pt);
625}
626
627ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::drawing::XShape >& xShape )
628 : m_aShapeHelper( xShape )
629{
630}
632{
633}
634
635PointerStyle getPointerStyle( const uno::Reference< frame::XModel >& xModel )
636{
637
638 PointerStyle nPointerStyle( PointerStyle::Arrow );
639 try
640 {
641 const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
642 const uno::Reference< frame::XFrame > xFrame ( xController->getFrame(), uno::UNO_SET_THROW );
643 const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
644 // why the heck isn't there an XWindowPeer::getPointer, but a setPointer only?
645 const vcl::Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
646 if ( pWindow )
647 nPointerStyle = pWindow->GetSystemWindow()->GetPointer();
648 }
649 catch (const uno::Exception&)
650 {
651 DBG_UNHANDLED_EXCEPTION("vbahelper");
652 }
653 return nPointerStyle;
654}
655
656// #FIXME this method looks wrong, shouldn't it just affect calc *or* writer
657// document/frame/window(s) but not both ( and depending on what api called
658// this )
659void setCursorHelper( const uno::Reference< frame::XModel >& xModel, PointerStyle nPointer, bool bOverWrite )
660{
661 ::std::vector< uno::Reference< frame::XController > > aControllers;
662
663 uno::Reference< frame::XModel2 > xModel2( xModel, uno::UNO_QUERY );
664 if ( xModel2.is() )
665 {
666 const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW );
667 while ( xEnumControllers->hasMoreElements() )
668 {
669 const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW );
670 aControllers.push_back( xController );
671 }
672 }
673 else
674 {
675 if ( xModel.is() )
676 {
677 const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
678 aControllers.push_back( xController );
679 }
680 }
681
682 for ( const auto& rController : aControllers )
683 {
684 const uno::Reference< frame::XFrame > xFrame ( rController->getFrame(), uno::UNO_SET_THROW );
685 const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
686
687 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
688 SAL_WARN_IF( !pWindow, "vbahelper", "ScVbaApplication::setCursor: no window!" );
689 if ( !pWindow )
690 continue;
691
692 pWindow->GetSystemWindow()->SetPointer( nPointer );
693 pWindow->GetSystemWindow()->EnableChildPointerOverwrite( bOverWrite );
694 }
695}
696
697void setDefaultPropByIntrospection( const uno::Any& aObj, const uno::Any& aValue )
698{
699 uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObj ) );
700
701 // #MAYBE #FIXME sort of a bit of a hack,
702 uno::Reference< script::XDefaultProperty > xDflt( aObj, uno::UNO_QUERY_THROW );
703 uno::Reference< beans::XPropertySet > xPropSet;
704
705 if ( xUnoAccess.is() )
706 xPropSet.set( xUnoAccess->queryAdapter( cppu::UnoType<beans::XPropertySet>::get()), uno::UNO_QUERY);
707
708 if ( !xPropSet.is() )
709 throw uno::RuntimeException();
710
711 xPropSet->setPropertyValue( xDflt->getDefaultPropertyName(), aValue );
712}
713
714uno::Any getPropertyValue( const uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName )
715{
716 auto pProp = std::find_if(aProp.begin(), aProp.end(),
717 [&aName](const beans::PropertyValue& rProp) { return rProp.Name == aName; });
718 if (pProp != aProp.end())
719 return pProp->Value;
720 return uno::Any();
721}
722
723bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName, const uno::Any& aValue )
724{
725 auto [begin, end] = asNonConstRange(aProp);
726 auto pProp = std::find_if(begin, end,
727 [&aName](const beans::PropertyValue& rProp) { return rProp.Name == aName; });
728 if (pProp != end)
729 {
730 pProp->Value = aValue;
731 return true;
732 }
733 return false;
734}
735
736void setOrAppendPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName, const uno::Any& aValue )
737{
738 if( setPropertyValue( aProp, aName, aValue ) )
739 return;
740
741 // append the property
742 sal_Int32 nLength = aProp.getLength();
743 aProp.realloc( nLength + 1 );
744 auto pProp = aProp.getArray();
745 pProp[ nLength ].Name = aName;
746 pProp[ nLength ].Value = aValue;
747}
748
749bool executeRunTimeLibrary(const std::u16string_view& rSbRtl_command, SbxArray* pParameters)
750{
751 StarBASIC* pBasic = dynamic_cast< StarBASIC* >(StarBASIC::GetActiveModule()->GetParent());
752 if (!pBasic)
753 return false;
754
755 SbxObject* pRunTimeLibrary = pBasic->GetRtl();
756 if (!pRunTimeLibrary)
757 return false;
758
759 SbxVariable* pFound = pRunTimeLibrary->Find(OUString(rSbRtl_command), SbxClassType::Method);
760 SbxMethod* pMethod = dynamic_cast<SbxMethod*>(pFound);
761 if (!pMethod)
762 return false;
763
764 pMethod->SetParameters(pParameters);
765 // Believe it or not, this actually runs the command
766 pMethod->Broadcast(SfxHintId::BasicDataWanted);
767 return true;
768}
769
770// ====UserFormGeomentryHelper====
771
773 const uno::Reference< awt::XControl >& xControl,
774 double fOffsetX, double fOffsetY ) :
775 mfOffsetX( fOffsetX ),
776 mfOffsetY( fOffsetY ),
777 mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() )
778{
779 if ( !xControl.is() )
780 throw uno::RuntimeException( "No control is provided!" );
781
782 mxWindow.set( xControl->getPeer(), uno::UNO_QUERY_THROW );
783 mxModelProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
784 mxUnitConv.set( mxWindow, uno::UNO_QUERY_THROW );
785}
786
788{
789 return implGetPos( false );
790}
791
793{
794 implSetPos( fLeft, false );
795}
796
798{
799 return implGetPos( true );
800}
801
803{
804 implSetPos( fTop, true );
805}
806
808{
809 return implGetSize( false, true );
810}
811
813{
814 implSetSize( fWidth, false, true );
815}
816
818{
819 return implGetSize( true, true );
820}
821
823{
824 implSetSize( fHeight, true, true );
825}
826
828{
829 return implGetSize( false, false );
830}
831
833{
834 implSetSize( fWidth, false, false );
835}
836
838{
839 return implGetSize( true, false );
840}
841
843{
844 implSetSize( fHeight, true, false );
845}
846
848{
849 return mfOffsetX;
850}
851
853{
854 return mfOffsetY;
855}
856
857constexpr OUStringLiteral saPosXName = u"PositionX";
858constexpr OUStringLiteral saPosYName = u"PositionY";
859constexpr OUStringLiteral saWidthName = u"Width";
860constexpr OUStringLiteral saHeightName = u"Height";
861
862double UserFormGeometryHelper::implGetPos( bool bPosY ) const
863{
864 sal_Int32 nPosAppFont = mxModelProps->getPropertyValue( bPosY ? OUString(saPosYName) : OUString(saPosXName) ).get< sal_Int32 >();
865 // appfont to pixel
866 awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosAppFont, nPosAppFont ), util::MeasureUnit::APPFONT );
867 // pixel to VBA points
868 awt::Point aPosPoint = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::POINT );
869 return bPosY ? (aPosPoint.Y - mfOffsetY) : (aPosPoint.X - mfOffsetX);
870}
871
872void UserFormGeometryHelper::implSetPos( double fPos, bool bPosY )
873{
874 // convert passed VBA points to pixels
875 sal_Int32 nPosPixel = static_cast< sal_Int32 >( fPos + (bPosY ? mfOffsetY : mfOffsetX) );
876 awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosPixel, nPosPixel ), util::MeasureUnit::POINT );
877 // pixel to appfont
878 awt::Point aPosAppFont = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::APPFONT );
879 mxModelProps->setPropertyValue( bPosY ? OUString(saPosYName) : OUString(saPosXName), uno::Any( bPosY ? aPosAppFont.Y : aPosAppFont.X ) );
880}
881
882double UserFormGeometryHelper::implGetSize( bool bHeight, bool bOuter ) const
883{
884 sal_Int32 nSizeAppFont = mxModelProps->getPropertyValue( bHeight ? OUString(saHeightName) : OUString(saWidthName) ).get< sal_Int32 >();
885 // appfont to pixel
886 awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSizeAppFont, nSizeAppFont ), util::MeasureUnit::APPFONT );
887
888 /* The VBA symbols 'Width' and 'Height' return the outer size including
889 window decoration (in difference to the symbols 'InnerWidth' and
890 'InnerHeight'), but the window API returns the inner size. */
891 if( mbDialog && bOuter )
892 {
893 if( const vcl::Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
894 {
895 tools::Rectangle aOuterRect = pWindow->GetWindowExtentsAbsolute();
896 aSizePixel = awt::Size( aOuterRect.getOpenWidth(), aOuterRect.getOpenHeight() );
897 }
898 }
899
900 // pixel to VBA points
901 awt::Size aSizePoint = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::POINT );
902 return bHeight ? aSizePoint.Height : aSizePoint.Width;
903}
904
905void UserFormGeometryHelper::implSetSize( double fSize, bool bHeight, bool bOuter )
906{
907 // convert passed VBA points to pixels
908 sal_Int32 nSize = static_cast< sal_Int32 >( fSize );
909 awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSize, nSize ), util::MeasureUnit::POINT );
910
911 /* The VBA symbols 'Width' and 'Height' set the outer size (in difference
912 to the symbols 'InnerWidth' and 'InnerHeight'), but the dialog model
913 expects the inner size. We have to remove the window extents from the
914 pixel height to get the same result. */
915 if ( mbDialog && bOuter )
916 {
917 if( const vcl::Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
918 {
919 tools::Rectangle aOuterRect = pWindow->GetWindowExtentsAbsolute();
920 if( !aOuterRect.IsEmpty() )
921 {
922 awt::Rectangle aInnerRect = mxWindow->getPosSize();
923 sal_Int32 nDecorWidth = aOuterRect.getOpenWidth() - aInnerRect.Width;
924 sal_Int32 nDecorHeight = aOuterRect.getOpenHeight() - aInnerRect.Height;
925 aSizePixel.Width = ::std::max< sal_Int32 >( aSizePixel.Width - nDecorWidth, 1 );
926 aSizePixel.Height = ::std::max< sal_Int32 >( aSizePixel.Height - nDecorHeight, 1 );
927 }
928 }
929 }
930
931 awt::Size aSizeAppFont = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::APPFONT );
932 mxModelProps->setPropertyValue( bHeight ? OUString(saHeightName) : OUString(saWidthName), uno::Any( bHeight ? aSizeAppFont.Height : aSizeAppFont.Width ) );
933}
934
935
937{
938 return m_aShapeHelper.getLeft();
939}
941{
942 m_aShapeHelper.setLeft( nLeft );
943}
945{
946 return m_aShapeHelper.getTop();
947}
949{
950 m_aShapeHelper.setTop( nTop );
951}
952
954{
955 return m_aShapeHelper.getHeight();
956}
958{
959 m_aShapeHelper.setHeight( nHeight );
960}
962{
963 return m_aShapeHelper.getWidth();
964}
966{
967 m_aShapeHelper.setWidth( nWidth );
968}
969
970
971ShapeHelper::ShapeHelper( css::uno::Reference< css::drawing::XShape > _xShape)
972 : xShape(std::move( _xShape ))
973{
974 if( !xShape.is() )
975 throw css::uno::RuntimeException( "No valid shape for helper" );
976}
977
979{
980 return Millimeter::getInPoints(xShape->getSize().Height);
981}
982
983void ShapeHelper::setHeight(double _fheight)
984{
985 css::awt::Size aSize = xShape->getSize();
986 aSize.Height = Millimeter::getInHundredthsOfOneMillimeter(_fheight);
987 xShape->setSize(aSize);
988}
989
991{
992 return Millimeter::getInPoints(xShape->getSize().Width);
993}
994
995void ShapeHelper::setWidth(double _fWidth)
996{
997 css::awt::Size aSize = xShape->getSize();
998 aSize.Width = Millimeter::getInHundredthsOfOneMillimeter(_fWidth);
999 xShape->setSize(aSize);
1000}
1001
1003{
1004 return Millimeter::getInPoints(xShape->getPosition().X);
1005}
1006
1007void ShapeHelper::setLeft(double _fLeft)
1008{
1009 css::awt::Point aPoint = xShape->getPosition();
1011 xShape->setPosition(aPoint);
1012}
1013
1015{
1016 return Millimeter::getInPoints(xShape->getPosition().Y);
1017}
1018
1019void ShapeHelper::setTop(double _fTop)
1020{
1021 css::awt::Point aPoint = xShape->getPosition();
1023 xShape->setPosition(aPoint);
1024}
1025
1026void DebugHelper::basicexception( const css::uno::Exception& ex, ErrCode err, std::u16string_view /*additionalArgument*/ )
1027{
1028 // #TODO #FIXME ( do we want to support additionalArg here )
1029 throw css::script::BasicErrorException( ex.Message, css::uno::Reference< css::uno::XInterface >(), sal_uInt32(err), OUString() );
1030}
1031
1032void DebugHelper::basicexception( ErrCode err, std::u16string_view additionalArgument )
1033{
1034 basicexception( css::uno::Exception(), err, additionalArgument );
1035}
1036
1037void DebugHelper::basicexception( const css::uno::Exception& ex )
1038{
1040}
1041
1043{
1044 // #TODO #FIXME ( do we want to support additionalArg here )
1045 throw css::uno::RuntimeException( css::uno::Exception().Message + " " + OUString::number(sal_uInt32(err)),
1046 css::uno::Reference< css::uno::XInterface >() );
1047}
1048
1049Millimeter::Millimeter():m_nMillimeter(0) {}
1050
1051Millimeter::Millimeter(double mm):m_nMillimeter(mm) {}
1052
1053void Millimeter::setInPoints(double points)
1054{
1055 m_nMillimeter = convertPointToMm100(points) / 100.0;
1056}
1057
1059{
1060 return m_nMillimeter * 100;
1061}
1062
1064{
1065 sal_Int32 mm = std::round(convertPointToMm100(points));
1066 return mm;
1067}
1068
1070{
1071 double points = convertMm100ToPoint<double>(_hmm);
1072 return points;
1073}
1074
1075uno::Reference< XHelperInterface > getVBADocument( const uno::Reference< frame::XModel >& xModel )
1076{
1077 uno::Reference< XHelperInterface > xIf;
1078 try
1079 {
1080 uno::Reference< beans::XPropertySet > xDocProps( xModel, uno::UNO_QUERY_THROW );
1081 OUString aCodeName;
1082 xDocProps->getPropertyValue( "CodeName" ) >>= aCodeName;
1083 xIf = getUnoDocModule( aCodeName, getSfxObjShell( xModel ) );
1084 }
1085 catch (const uno::Exception&)
1086 {
1087 }
1088 return xIf;
1089}
1090
1091uno::Reference< XHelperInterface > getUnoDocModule( std::u16string_view aModName, SfxObjectShell const * pShell )
1092{
1093 uno::Reference< XHelperInterface > xIf;
1094 if ( pShell )
1095 {
1096 OUString sProj( "Standard" );
1097 // GetBasicManager() causes a SolarMutex assertion failure in some use cases from
1098 // Automation, at least when opening a Calc Document through ooo::vba::excel::
1099 // XWorkbooks::Open(). Let's see if this check is a good way around that. It does seem that
1100 // callers are prepared for this to return null?
1102 return xIf;
1103 BasicManager* pBasMgr = pShell->GetBasicManager();
1104 if ( pBasMgr && !pBasMgr->GetName().isEmpty() )
1105 sProj = pBasMgr->GetName();
1106 if( StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ) )
1107 if( SbModule* pMod = pBasic->FindModule( aModName ) )
1108 xIf.set( pMod->GetUnoModule(), uno::UNO_QUERY );
1109 }
1110 return xIf;
1111}
1112
1113SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel )
1114{
1115 SfxObjectShell* pFoundShell = comphelper::getFromUnoTunnel<SfxObjectShell>(xModel);
1116 if ( !pFoundShell )
1117 throw uno::RuntimeException();
1118 return pFoundShell;
1119}
1120
1121} //org
1122
1123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr auto convertPointToMm100(N n)
SfxApplication * SfxGetpApp()
static void Yield()
static bool IsQuit()
StarBASIC * GetLib(sal_uInt16 nLib) const
const OUString & GetName() const
virtual SbxVariable * Find(const OUString &, SbxClassType)
const SbxObject * GetParent() const
virtual void Broadcast(SfxHintId nHintId) override
void SetParameters(SbxArray *p)
static StarBASIC * GetBasic()
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
bool IsInPlace() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxViewFactory & GetViewFactory(sal_uInt16 i=0) const
sal_uInt16 GetViewFactoryCount() const
BasicManager * GetBasicManager() const
virtual SfxObjectFactory & GetFactory() const=0
bool IsInPlaceActive() const
sal_uInt16 Which() const
SfxInterfaceId GetOrdinal() const
SfxInterfaceId GetCurViewId() const
SfxDispatcher * GetDispatcher()
SfxFrame & GetFrame() const
virtual SfxObjectShell * GetObjectShell() override
SfxViewFrame & GetViewFrame() const
static SbModule * GetActiveModule()
SbxObject * GetRtl()
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
virtual double getLeft() const override
Definition: vbahelper.cxx:936
virtual double getWidth() const override
Definition: vbahelper.cxx:961
virtual void setTop(double nTop) override
Definition: vbahelper.cxx:948
virtual ~ConcreteXShapeGeometryAttributes() override
Definition: vbahelper.cxx:631
virtual double getTop() const override
Definition: vbahelper.cxx:944
ConcreteXShapeGeometryAttributes(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: vbahelper.cxx:627
virtual void setWidth(double nWidth) override
Definition: vbahelper.cxx:965
virtual double getHeight() const override
Definition: vbahelper.cxx:953
virtual void setHeight(double nHeight) override
Definition: vbahelper.cxx:957
virtual void setLeft(double nLeft) override
Definition: vbahelper.cxx:940
static OUString getUniqueName(const css::uno::Sequence< OUString > &_slist, const OUString &_sElementName, std::u16string_view _sSuffixSeparator)
static sal_Int32 FieldInList(const css::uno::Sequence< OUString > &SearchList, const OUString &SearchString)
Definition: vbahelper.cxx:526
static void basicexception(const css::uno::Exception &ex, ErrCode err, std::u16string_view)
Definition: vbahelper.cxx:1026
static void runtimeexception(ErrCode err)
Definition: vbahelper.cxx:1042
double getInHundredthsOfOneMillimeter() const
Definition: vbahelper.cxx:1058
void setInPoints(double points)
Definition: vbahelper.cxx:1053
static double getInPoints(int _hmm)
Definition: vbahelper.cxx:1069
double getHeight() const
Definition: vbahelper.cxx:978
double getLeft() const
Definition: vbahelper.cxx:1002
css::uno::Reference< css::drawing::XShape > xShape
Definition: vbahelper.hxx:178
double getTop() const
Definition: vbahelper.cxx:1014
void setWidth(double _fWidth)
Definition: vbahelper.cxx:995
double getWidth() const
Definition: vbahelper.cxx:990
void setTop(double _fTop)
Definition: vbahelper.cxx:1019
ShapeHelper(css::uno::Reference< css::drawing::XShape > _xShape)
Definition: vbahelper.cxx:971
void setHeight(double _fheight)
Definition: vbahelper.cxx:983
void setLeft(double _fLeft)
Definition: vbahelper.cxx:1007
double implGetSize(bool bHeight, bool bOuter) const
Definition: vbahelper.cxx:882
css::uno::Reference< css::awt::XWindow > mxWindow
Definition: vbahelper.hxx:241
virtual void setInnerWidth(double fWidth) override
Definition: vbahelper.cxx:832
double implGetPos(bool bPosY) const
Definition: vbahelper.cxx:862
virtual void setTop(double fTop) override
Definition: vbahelper.cxx:802
UserFormGeometryHelper(const css::uno::Reference< css::awt::XControl > &xControl, double fOffsetX, double fOffsetY)
Definition: vbahelper.cxx:772
virtual double getOffsetY() const override
Definition: vbahelper.cxx:852
virtual double getInnerHeight() const override
Definition: vbahelper.cxx:837
virtual double getHeight() const override
Definition: vbahelper.cxx:817
void implSetSize(double fSize, bool bHeight, bool bOuter)
Definition: vbahelper.cxx:905
virtual double getOffsetX() const override
Definition: vbahelper.cxx:847
virtual double getLeft() const override
Definition: vbahelper.cxx:787
virtual void setLeft(double fLeft) override
Definition: vbahelper.cxx:792
virtual double getWidth() const override
Definition: vbahelper.cxx:807
virtual void setInnerHeight(double fHeight) override
Definition: vbahelper.cxx:842
virtual void setHeight(double fHeight) override
Definition: vbahelper.cxx:822
css::uno::Reference< css::awt::XUnitConversion > mxUnitConv
Definition: vbahelper.hxx:243
virtual double getTop() const override
Definition: vbahelper.cxx:797
void implSetPos(double fPos, bool bPosY)
Definition: vbahelper.cxx:872
css::uno::Reference< css::beans::XPropertySet > mxModelProps
Definition: vbahelper.hxx:242
virtual double getInnerWidth() const override
Definition: vbahelper.cxx:827
virtual void setWidth(double fWidth) override
Definition: vbahelper.cxx:812
tools::Long getOpenHeight() const
tools::Long getOpenWidth() const
constexpr bool IsEmpty() const
SystemWindow * GetSystemWindow() const
PointerStyle GetPointer() const
#define DBG_UNHANDLED_EXCEPTION(...)
float u
OUString aName
Reference< XIntrospection > xIntrospection
uno_Any a
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
err
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
Reference< XComponentContext > getProcessComponentContext()
Reference
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
enumrange< T >::Iterator begin(enumrange< T >)
double PixelsToPoints(const css::uno::Reference< css::awt::XDevice > &xDevice, double fPixels, bool bVertical)
Definition: vbahelper.cxx:621
bool extractBoolFromAny(const uno::Any &rAny)
Definition: vbahelper.cxx:444
static uno::Reference< frame::XModel > getCurrentDocCtx(const OUString &ctxName, const uno::Reference< uno::XComponentContext > &xContext)
Definition: vbahelper.cxx:225
sal_Int32 XLRGBToOORGB(sal_Int32 nCol)
Definition: vbahelper.cxx:306
void PrintOutHelper(SfxViewShell const *pViewShell, const uno::Any &From, const uno::Any &To, const uno::Any &Copies, const uno::Any &Preview, const uno::Any &, const uno::Any &, const uno::Any &Collate, const uno::Any &PrToFileName, bool bUseSelection)
Definition: vbahelper.cxx:339
uno::Reference< script::XTypeConverter > const & getTypeConverter(const uno::Reference< uno::XComponentContext > &xContext)
Definition: vbahelper.cxx:108
void PrintPreviewHelper(const css::uno::Any &, SfxViewShell const *pViewShell)
Definition: vbahelper.cxx:423
const uno::Any & aNULL()
Definition: vbahelper.cxx:114
uno::Any getPropertyValue(const uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName)
Definition: vbahelper.cxx:714
constexpr OUStringLiteral saPosYName
Definition: vbahelper.cxx:858
void WaitUntilPreviewIsClosed(SfxViewFrame *pViewFrame)
Definition: vbahelper.cxx:438
constexpr OUStringLiteral saWidthName
Definition: vbahelper.cxx:859
void setCursorHelper(const uno::Reference< frame::XModel > &xModel, PointerStyle nPointer, bool bOverWrite)
Definition: vbahelper.cxx:659
uno::Reference< frame::XModel > getCurrentDoc(const OUString &sKey)
Definition: vbahelper.cxx:179
uno::Reference< frame::XModel > getCurrentExcelDoc(const uno::Reference< uno::XComponentContext > &xContext)
Definition: vbahelper.cxx:247
OUString VBAToRegexp(const OUString &rIn)
Definition: vbahelper.cxx:538
constexpr OUStringLiteral saHeightName
Definition: vbahelper.cxx:860
uno::Reference< XHelperInterface > getUnoDocModule(std::u16string_view aModName, SfxObjectShell const *pShell)
Definition: vbahelper.cxx:1091
uno::Reference< frame::XModel > getThisWordDoc(const uno::Reference< uno::XComponentContext > &xContext)
Definition: vbahelper.cxx:241
static bool NeedEsc(sal_Unicode cCode)
Definition: vbahelper.cxx:533
uno::Reference< beans::XIntrospectionAccess > getIntrospectionAccess(const uno::Any &aObject)
Definition: vbahelper.cxx:101
static bool isInPrintPreview(SfxViewFrame *pView)
Definition: vbahelper.cxx:86
void setOrAppendPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
Definition: vbahelper.cxx:736
OUString extractStringFromAny(const uno::Any &rAny, bool bUppercaseBool)
Definition: vbahelper.cxx:465
void dispatchExecute(SfxViewShell const *pViewShell, sal_uInt16 nSlot)
Definition: vbahelper.cxx:120
SfxObjectShell * getSfxObjShell(const uno::Reference< frame::XModel > &xModel)
Definition: vbahelper.cxx:1113
double PointsToPixels(const css::uno::Reference< css::awt::XDevice > &xDevice, double fPoints, bool bVertical)
Definition: vbahelper.cxx:616
uno::Reference< XHelperInterface > getVBADocument(const uno::Reference< frame::XModel > &xModel)
Definition: vbahelper.cxx:1075
PointerStyle getPointerStyle(const uno::Reference< frame::XModel > &xModel)
Definition: vbahelper.cxx:635
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
Definition: vbahelper.cxx:723
OUString getAnyAsString(const uno::Any &pvargItem)
Definition: vbahelper.cxx:495
void setDefaultPropByIntrospection(const uno::Any &aObj, const uno::Any &aValue)
Definition: vbahelper.cxx:697
uno::Reference< frame::XModel > getCurrentWordDoc(const uno::Reference< uno::XComponentContext > &xContext)
Definition: vbahelper.cxx:268
constexpr OUStringLiteral saPosXName
Definition: vbahelper.cxx:857
void dispatchRequests(const uno::Reference< frame::XModel > &xModel, const OUString &aUrl, const uno::Sequence< beans::PropertyValue > &sProps)
Definition: vbahelper.cxx:136
sal_Int32 OORGBToXLRGB(sal_Int32 nCol)
Definition: vbahelper.cxx:289
bool executeRunTimeLibrary(const std::u16string_view &rSbRtl_command, SbxArray *pParameters)
Definition: vbahelper.cxx:749
uno::Reference< frame::XModel > getThisExcelDoc(const uno::Reference< uno::XComponentContext > &xContext)
Definition: vbahelper.cxx:235
static double getPixelToMeterConversionFactor(const css::uno::Reference< css::awt::XDevice > &xDevice, bool bVertical)
Definition: vbahelper.cxx:611
end
PointerStyle
#define ERRCODE_BASIC_INTERNAL_ERROR
Any sbxToUnoValue(const SbxValue *pVar)
bool hasValue()
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel
sal_uInt16 sal_Unicode
sal_Int32 nLength