LibreOffice Module sc (master) 1
excelvbahelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "excelvbahelper.hxx"
21
22#include <basic/basmgr.hxx>
26#include <osl/file.hxx>
27#include <tools/urlobj.hxx>
29#include <com/sun/star/beans/PropertyAttribute.hpp>
30#include <com/sun/star/beans/PropertyExistException.hpp>
31#include <com/sun/star/frame/XModel.hpp>
32#include <com/sun/star/sheet/XSheetCellRange.hpp>
33#include <com/sun/star/sheet/GlobalSheetSettings.hpp>
34#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
35#include <com/sun/star/sheet/XSpreadsheet.hpp>
36#include <com/sun/star/sheet/XDatabaseRange.hpp>
37#include <com/sun/star/system/SystemShellExecute.hpp>
38#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
39#include <com/sun/star/util/XCloneable.hpp>
40
41#include <document.hxx>
42#include <docuno.hxx>
43#include <tabvwsh.hxx>
44#include <transobj.hxx>
45#include <cellsuno.hxx>
46#include <gridwin.hxx>
47
48#include <com/sun/star/script/vba/VBAEventId.hpp>
49#include <com/sun/star/script/vba/XVBACompatibility.hpp>
50#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
51#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
52#include <com/sun/star/script/ModuleInfo.hpp>
53#include <com/sun/star/script/ModuleType.hpp>
54
55using namespace ::com::sun::star;
56using namespace ::ooo::vba;
57
58namespace ooo::vba::excel {
59
60uno::Reference< sheet::XUnnamedDatabaseRanges >
62{
63 uno::Reference< frame::XModel > xModel;
64 if ( pShell )
65 xModel.set( pShell->GetModel(), uno::UNO_SET_THROW );
66 uno::Reference< beans::XPropertySet > xModelProps( xModel, uno::UNO_QUERY_THROW );
67 uno::Reference< sheet::XUnnamedDatabaseRanges > xUnnamedDBRanges( xModelProps->getPropertyValue("UnnamedDatabaseRanges"), uno::UNO_QUERY_THROW );
68 return xUnnamedDBRanges;
69}
70
71// returns the XDatabaseRange for the autofilter on sheet (nSheet)
72// also populates sName with the name of range
73uno::Reference< sheet::XDatabaseRange >
74GetAutoFiltRange( const ScDocShell* pShell, sal_Int16 nSheet )
75{
76 uno::Reference< sheet::XUnnamedDatabaseRanges > xUnnamedDBRanges( GetUnnamedDataBaseRanges( pShell ), uno::UNO_SET_THROW );
77 uno::Reference< sheet::XDatabaseRange > xDataBaseRange;
78 if (xUnnamedDBRanges->hasByTable( nSheet ) )
79 {
80 uno::Reference< sheet::XDatabaseRange > xDBRange( xUnnamedDBRanges->getByTable( nSheet ) , uno::UNO_QUERY_THROW );
81 bool bHasAuto = false;
82 uno::Reference< beans::XPropertySet > xProps( xDBRange, uno::UNO_QUERY_THROW );
83 xProps->getPropertyValue("AutoFilter") >>= bHasAuto;
84 if ( bHasAuto )
85 {
86 xDataBaseRange=xDBRange;
87 }
88 }
89 return xDataBaseRange;
90}
91
92ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange )
93{
94 ScCellRangesBase* pScCellRangesBase = dynamic_cast<ScCellRangesBase*>( xRange.get() );
95 if ( !pScCellRangesBase )
96 {
97 throw uno::RuntimeException("Failed to access underlying doc shell uno range object" );
98 }
99 return pScCellRangesBase->GetDocShell();
100}
101
102uno::Reference< XHelperInterface >
103getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange )
104{
105 uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW );
106 uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW );
107 return getUnoSheetModuleObj( xSheet );
108}
109
110void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs )
111{
113 Fraction aFract( nZoom, 100 );
114 pViewSh->GetViewData().SetZoom( aFract, aFract, nTabs );
115 pViewSh->RefreshZoom();
116}
117
118namespace {
119
120class PasteCellsWarningReseter
121{
122private:
125 static uno::Reference< sheet::XGlobalSheetSettings > const & getGlobalSheetSettings()
126 {
127 static uno::Reference< sheet::XGlobalSheetSettings > xProps = sheet::GlobalSheetSettings::create( comphelper::getProcessComponentContext() );
128 return xProps;
129 }
130
132 static bool getReplaceCellsWarning()
133 {
134 return getGlobalSheetSettings()->getReplaceCellsWarning();
135 }
136
138 static void setReplaceCellsWarning( bool bState )
139 {
140 getGlobalSheetSettings()->setReplaceCellsWarning( bState );
141 }
142public:
144 PasteCellsWarningReseter()
145 {
146 bInitialWarningState = getReplaceCellsWarning();
148 setReplaceCellsWarning( false );
149 }
150 ~PasteCellsWarningReseter()
151 {
153 {
154 // don't allow dtor to throw
155 try
156 {
157 setReplaceCellsWarning( true );
158 }
159 catch ( uno::Exception& /*e*/ ){}
160 }
161 }
162};
163
164}
165
166void
167implnPaste( const uno::Reference< frame::XModel>& xModel )
168{
169 PasteCellsWarningReseter resetWarningBox;
170 ScTabViewShell* pViewShell = getBestViewShell( xModel );
171 if ( pViewShell )
172 {
173 pViewShell->PasteFromSystem();
174 pViewShell->CellContentChanged();
175 }
176}
177
178void
179implnCopy( const uno::Reference< frame::XModel>& xModel )
180{
181 ScTabViewShell* pViewShell = getBestViewShell( xModel );
182 ScDocShell* pDocShell = getDocShell( xModel );
183 if ( !(pViewShell && pDocShell) )
184 return;
185
186 pViewShell->CopyToClip(nullptr,false,false,true);
187
188 // mark the copied transfer object so it is used in ScVbaRange::Insert
189 uno::Reference<datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin()));
190 ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard(xTransferable);
191 if (pClipObj)
192 {
193 pClipObj->SetUseInApi( true );
194 pDocShell->SetClipData(xTransferable);
195 }
196}
197
198void
199implnCut( const uno::Reference< frame::XModel>& xModel )
200{
201 ScTabViewShell* pViewShell = getBestViewShell( xModel );
202 ScDocShell* pDocShell = getDocShell( xModel );
203 if ( !(pViewShell && pDocShell) )
204 return;
205
206 pViewShell->CutToClip();
207
208 // mark the copied transfer object so it is used in ScVbaRange::Insert
209 uno::Reference<datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin()));
210 ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard(xTransferable);
211 if (pClipObj)
212 {
213 pClipObj->SetUseInApi( true );
214 pDocShell->SetClipData(xTransferable);
215 }
216}
217
218void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bTranspose)
219{
220 PasteCellsWarningReseter resetWarningBox;
221
222 ScTabViewShell* pTabViewShell = getBestViewShell(xModel);
223 if (!pTabViewShell)
224 return;
225
226 ScDocShell* pDocShell = getDocShell(xModel);
227 if (!pDocShell)
228 return;
229
230 ScViewData& rView = pTabViewShell->GetViewData();
231 vcl::Window* pWin = rView.GetActiveWin();
232 if (!pWin)
233 return;
234
236 if (pOwnClip)
237 {
238 pTabViewShell->PasteFromClip(nFlags, pOwnClip->GetDocument(),
239 nFunction, bSkipEmpty, bTranspose, false,
241
242 pTabViewShell->CellContentChanged();
243 }
244}
245
247getDocShell( const css::uno::Reference< css::frame::XModel>& xModel )
248{
249 uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW );
250 ScModelObj* pModel = comphelper::getFromUnoTunnel< ScModelObj >( xIf );
251 ScDocShell* pDocShell = nullptr;
252 if ( pModel )
253 pDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
254 return pDocShell;
255
256}
257
259getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel )
260{
261 ScDocShell* pDocShell = getDocShell( xModel );
262 if ( pDocShell )
263 return pDocShell->GetBestViewShell();
264 return nullptr;
265}
266
268getCurrentBestViewShell( const uno::Reference< uno::XComponentContext >& xContext )
269{
270 uno::Reference< frame::XModel > xModel = getCurrentExcelDoc( xContext );
271 return getBestViewShell( xModel );
272}
273
275getViewFrame( const uno::Reference< frame::XModel >& xModel )
276{
277 ScTabViewShell* pViewShell = getBestViewShell( xModel );
278 if ( pViewShell )
279 return &pViewShell->GetViewFrame();
280 return nullptr;
281}
282
283uno::Reference< XHelperInterface >
284getUnoSheetModuleObj( const uno::Reference< sheet::XSpreadsheet >& xSheet )
285{
286 uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW );
287 OUString sCodeName;
288 xProps->getPropertyValue("CodeName") >>= sCodeName;
289 // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible
290 // to create a module ( and use 'Option VBASupport 1' ) for a calc document, in this scenario there
291 // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at
292 // the document in the future could fix this, especially IF the switching of the vba mode takes care to
293 // create the special document module objects if they don't exist.
294 return getUnoDocModule( sCodeName, GetDocShellFromRange( xSheet ) );
295}
296
297uno::Reference< XHelperInterface >
298getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges )
299{
300 uno::Reference< container::XEnumerationAccess > xEnumAccess( xRanges, uno::UNO_QUERY_THROW );
301 uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
302 uno::Reference< table::XCellRange > xRange( xEnum->nextElement(), uno::UNO_QUERY_THROW );
303 return getUnoSheetModuleObj( xRange );
304}
305
306uno::Reference< XHelperInterface >
307getUnoSheetModuleObj( const uno::Reference< table::XCell >& xCell )
308{
309 uno::Reference< sheet::XSheetCellRange > xSheetRange( xCell, uno::UNO_QUERY_THROW );
310 uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW );
311 return getUnoSheetModuleObj( xSheet );
312}
313
314uno::Reference< XHelperInterface >
315getUnoSheetModuleObj( const uno::Reference< frame::XModel >& xModel, SCTAB nTab )
316{
317 uno::Reference< sheet::XSpreadsheetDocument > xDoc( xModel, uno::UNO_QUERY_THROW );
318 uno::Reference< container::XIndexAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW );
319 uno::Reference< sheet::XSpreadsheet > xSheet( xSheets->getByIndex( nTab ), uno::UNO_QUERY_THROW );
320 return getUnoSheetModuleObj( xSheet );
321}
322
323void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc )
324{
325 uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
327 if ( !pShell )
328 return;
329
330 OUString aPrjName( "Standard" );
331 pShell->GetBasicManager()->SetName( aPrjName );
332
333 /* Set library container to VBA compatibility mode. This will create
334 the VBA Globals object and store it in the Basic manager of the
335 document. */
336 uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer();
337 uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW );
338 xVBACompat->setVBACompatibilityMode( true );
339
340 if( xLibContainer.is() )
341 {
342 if( !xLibContainer->hasByName( aPrjName ) )
343 xLibContainer->createLibrary( aPrjName );
344 uno::Any aLibAny = xLibContainer->getByName( aPrjName );
345 uno::Reference< container::XNameContainer > xLib;
346 aLibAny >>= xLib;
347 if( xLib.is() )
348 {
349 uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW );
350 uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( pShell->GetModel()->createInstance("ooo.vba.VBAObjectModuleObjectProvider"), uno::UNO_QUERY_THROW );
351 // set up the module info for the workbook and sheets in the newly created
352 // spreadsheet
353 ScDocument& rDoc = pShell->GetDocument();
354 OUString sCodeName = rDoc.GetCodeName();
355 if ( sCodeName.isEmpty() )
356 {
357 sCodeName = "ThisWorkbook";
358 rDoc.SetCodeName( sCodeName );
359 }
360
361 std::vector< OUString > sDocModuleNames { sCodeName };
362
363 for ( SCTAB index = 0; index < rDoc.GetTableCount(); index++)
364 {
365 OUString aName;
366 rDoc.GetCodeName( index, aName );
367 sDocModuleNames.push_back( aName );
368 }
369
370 for ( const auto& rName : sDocModuleNames )
371 {
372 script::ModuleInfo sModuleInfo;
373
374 uno::Any aName= xVBACodeNamedObjectAccess->getByName( rName );
375 sModuleInfo.ModuleObject.set( aName, uno::UNO_QUERY );
376 sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
377 xVBAModuleInfo->insertModuleInfo( rName, sModuleInfo );
378 if( xLib->hasByName( rName ) )
379 xLib->replaceByName( rName, uno::Any( OUString( "Option VBASupport 1\n") ) );
380 else
381 xLib->insertByName( rName, uno::Any( OUString( "Option VBASupport 1\n" ) ) );
382 }
383 }
384 }
385
386 /* Trigger the Workbook_Open event, event processor will register
387 itself as listener for specific events. */
388 try
389 {
390 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument().GetVbaEventProcessor(), uno::UNO_SET_THROW );
391 uno::Sequence< uno::Any > aArgs;
392 xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs );
393 }
394 catch( uno::Exception& )
395 {
396 }
397}
398
400 const uno::Reference< frame::XModel >& xModel, const css::uno::Reference< XApplication >& xApplication,
401 const css::uno::Any& Type, const css::uno::Any& FileName, const css::uno::Any& Quality,
402 const css::uno::Any& IncludeDocProperties, const css::uno::Any& From,
403 const css::uno::Any& To, const css::uno::Any& OpenAfterPublish)
404{
405 OUString sType;
406 if ((Type >>= sType) && (sType.equalsIgnoreAsciiCase(u"xlTypeXPS") || sType == "1"))
407 {
408 /* xlTypePDF 0 "PDF" - Portable Document Format file(.pdf)
409 xlTypeXPS 1 "XPS" - XPS Document(.xps) --> not supported in LibreOffice */
410 return;
411 }
412
413 OUString sFileName;
414 FileName >>= sFileName;
415 OUString sRelURL;;
416 osl::FileBase::getFileURLFromSystemPath(sFileName, sRelURL);
417 // detect if there is no path then we need
418 // to use the current folder
419 INetURLObject aURL(sRelURL);
420 OUString sURL;
422 if (sURL.isEmpty())
423 {
424 // need to add cur dir ( of this workbook ) or else the 'Work' dir
425 sURL = xModel->getURL();
426
427 if (sURL.isEmpty())
428 {
429 // not path available from 'this' document
430 // need to add the 'document'/work directory then
431 OUString sWorkPath = xApplication->getDefaultFilePath();
432 OUString sWorkURL;
433 osl::FileBase::getFileURLFromSystemPath(sWorkPath, sWorkURL);
434 aURL.SetURL(sWorkURL);
435 }
436 else
437 {
438 if (!sFileName.isEmpty())
439 {
440 aURL.SetURL(INetURLObject::GetAbsURL(sURL, sRelURL));
441 }
442 else
443 {
444 aURL.SetURL(sURL);
445 if (aURL.removeExtension())
446 aURL.setExtension(u"pdf");
447 }
448 }
450
451 }
452
453 sal_Int32 nTo = 0;
454 sal_Int32 nFrom = 0;
455 From >>= nFrom;
456 To >>= nTo;
457
458 OUString sRange("-");
459
460 css::uno::Sequence<css::beans::PropertyValue> aFilterData;
461 if (nFrom || nTo)
462 {
463 if (nFrom)
464 sRange = OUString::number(nFrom) + sRange;
465 if (nTo)
466 sRange += OUString::number(nTo);
467
468 aFilterData.realloc(aFilterData.getLength() + 1);
469 aFilterData.getArray()[aFilterData.getLength() - 1] = comphelper::makePropertyValue("PageRange", sRange);
470 }
471
472 OUString sQuality;
473 if (Quality >>= sQuality)
474 {
475 if (sQuality.equalsIgnoreAsciiCase(u"xlQualityMinimum") || sQuality == "1")
476 {
477 aFilterData.realloc(aFilterData.getLength() + 1);
478 aFilterData.getArray()[aFilterData.getLength() - 1] = comphelper::makePropertyValue("Quality", sal_Int32(70));
479 }
480 else if (sQuality.equalsIgnoreAsciiCase(u"xlQualityStandard") || sQuality == "0")
481 {
482 aFilterData.realloc(aFilterData.getLength() + 1);
483 aFilterData.getArray()[aFilterData.getLength() - 1] = comphelper::makePropertyValue("UseLosslessCompression", true);
484 }
485 else
486 {
487 /* Name Value Description
488 xlQualityMinimum 1 Minimum quality
489 xlQualityStandard 0 Standard quality */
490 }
491 }
492
493 // init set of params for storeToURL() call
494 css::uno::Sequence<css::beans::PropertyValue> storeProps{
495 comphelper::makePropertyValue("FilterData", aFilterData),
496 comphelper::makePropertyValue("FilterName", OUString("calc_pdf_Export")),
498 };
499
500 bool bIncludeDocProperties = true;
501 if ((IncludeDocProperties >>= bIncludeDocProperties) && !bIncludeDocProperties)
502 {
503 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(xModel, uno::UNO_QUERY);
504 if (xDPS.is())
505 {
506 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
507 uno::Reference<util::XCloneable> xCloneable(xDocProps, uno::UNO_QUERY_THROW);
508 uno::Reference<document::XDocumentProperties> xOldDocProps(xCloneable->createClone(), uno::UNO_QUERY_THROW);
509
510 // reset doc properties to default temporary
511 xDocProps->resetUserData(OUString());
512
513 uno::Reference< frame::XStorable > xStor(xModel, uno::UNO_QUERY_THROW);
514 try {
515 xStor->storeToURL(sURL, storeProps);
516 }
517 catch (const uno::Exception&)
518 {
519 SetDocInfoState(xModel, xOldDocProps);
520 throw;
521 }
522
523 SetDocInfoState(xModel, xOldDocProps);
524 }
525 }
526 else
527 {
528 uno::Reference< frame::XStorable > xStor(xModel, uno::UNO_QUERY_THROW);
529 xStor->storeToURL(sURL, storeProps);
530 }
531
532 bool bOpenAfterPublish = false;
533 if ((OpenAfterPublish >>= bOpenAfterPublish) && bOpenAfterPublish)
534 {
535 uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute(css::system::SystemShellExecute::create(::comphelper::getProcessComponentContext()));
536 xSystemShellExecute->execute(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), "", css::system::SystemShellExecuteFlags::URIS_ONLY);
537 }
538}
539
541 const uno::Reference< frame::XModel >& xModel,
542 const uno::Reference< css::document::XDocumentProperties>& i_xOldDocProps)
543{
544 uno::Reference<document::XDocumentPropertiesSupplier> const
545 xModelDocPropsSupplier(xModel, uno::UNO_QUERY_THROW);
546 uno::Reference<document::XDocumentProperties> const xDocPropsToFill =
547 xModelDocPropsSupplier->getDocumentProperties();
548 uno::Reference< beans::XPropertySet > const xPropSet(
549 i_xOldDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
550
551 uno::Reference< util::XModifiable > xModifiable(xModel, uno::UNO_QUERY);
552 if (!xModifiable.is())
553 throw uno::RuntimeException();
554
555 bool bIsModified = xModifiable->isModified();
556
557 try
558 {
559 uno::Reference< beans::XPropertySet > const xSet(
560 xDocPropsToFill->getUserDefinedProperties(), uno::UNO_QUERY);
561 uno::Reference< beans::XPropertyContainer > xContainer(xSet, uno::UNO_QUERY);
562 uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
563 const uno::Sequence< beans::Property > lProps = xSetInfo->getProperties();
564 for (const beans::Property& rProp : lProps)
565 {
566 uno::Any aValue = xPropSet->getPropertyValue(rProp.Name);
567 if (rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE)
568 {
569 try
570 {
571 // QUESTION: DefaultValue?!
572 xContainer->addProperty(rProp.Name, rProp.Attributes, aValue);
573 }
574 catch (beans::PropertyExistException const&) {}
575 try
576 {
577 // it is possible that the propertysets from XML and binary files differ; we shouldn't break then
578 xSet->setPropertyValue(rProp.Name, aValue);
579 }
580 catch (const uno::Exception&) {}
581 }
582 }
583
584 // sigh... have to set these manually I'm afraid...
585 xDocPropsToFill->setAuthor(i_xOldDocProps->getAuthor());
586 xDocPropsToFill->setGenerator(i_xOldDocProps->getGenerator());
587 xDocPropsToFill->setCreationDate(i_xOldDocProps->getCreationDate());
588 xDocPropsToFill->setTitle(i_xOldDocProps->getTitle());
589 xDocPropsToFill->setSubject(i_xOldDocProps->getSubject());
590 xDocPropsToFill->setDescription(i_xOldDocProps->getDescription());
591 xDocPropsToFill->setKeywords(i_xOldDocProps->getKeywords());
592 xDocPropsToFill->setModifiedBy(i_xOldDocProps->getModifiedBy());
593 xDocPropsToFill->setModificationDate(i_xOldDocProps->getModificationDate());
594 xDocPropsToFill->setPrintedBy(i_xOldDocProps->getPrintedBy());
595 xDocPropsToFill->setPrintDate(i_xOldDocProps->getPrintDate());
596 xDocPropsToFill->setAutoloadURL(i_xOldDocProps->getAutoloadURL());
597 xDocPropsToFill->setAutoloadSecs(i_xOldDocProps->getAutoloadSecs());
598 xDocPropsToFill->setDefaultTarget(i_xOldDocProps->getDefaultTarget());
599 xDocPropsToFill->setEditingCycles(i_xOldDocProps->getEditingCycles());
600 xDocPropsToFill->setEditingDuration(i_xOldDocProps->getEditingDuration());
601 }
602 catch (const uno::Exception&) {}
603
604 // set the modified flag back if required
605 if (bIsModified != bool(xModifiable->isModified()))
606 xModifiable->setModified(bIsModified);
607}
608
610ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj )
611{
612 return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : nullptr;
613}
614
615} // namespace ooo::vba::excel
616
617/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sType
void SetName(const OUString &rName)
static OUString GetAbsURL(std::u16string_view rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void SetClipData(const css::uno::Reference< css::datatransfer::XTransferable2 > &xTransferable)
Definition: docsh.hxx:224
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2623
ScModelObj * GetModel() const
Definition: docsh.hxx:432
void SetCodeName(const OUString &r)
Definition: document.hxx:610
const css::uno::Reference< css::script::vba::XVBAEventProcessor > & GetVbaEventProcessor() const
Definition: document.hxx:2539
const OUString & GetCodeName() const
Definition: document.hxx:609
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:445
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(const OUString &aServiceSpecifier) override
XMultiServiceFactory.
Definition: docuno.cxx:3113
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
Definition: tabvwshc.cxx:519
SC_DLLPUBLIC void RefreshZoom()
Definition: tabview5.cxx:432
ScViewData & GetViewData()
Definition: tabview.hxx:344
SC_DLLPUBLIC void CellContentChanged()
Definition: tabview3.cxx:513
ScDocument * GetDocument() const
Definition: transobj.hxx:82
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: transobj.cxx:199
SC_DLLPUBLIC void SetUseInApi(bool bSet)
Definition: transobj.cxx:623
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3162
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, std::vector< SCTAB > &tabs)
Definition: viewdata.cxx:1036
SC_DLLPUBLIC void CutToClip()
Definition: viewfun3.cxx:90
SC_DLLPUBLIC void PasteFromSystem()
Definition: viewfun3.cxx:484
SC_DLLPUBLIC bool CopyToClip(ScDocument *pClipDoc, bool bCut, bool bApi=false, bool bIncludeObjects=false, bool bStopEdit=true)
Definition: viewfun3.cxx:168
SC_DLLPUBLIC bool PasteFromClip(InsertDeleteFlags nFlags, ScDocument *pClipDoc, ScPasteFunc nFunction=ScPasteFunc::NONE, bool bSkipEmptyCells=false, bool bTranspose=false, bool bAsLink=false, InsCellCmd eMoveMode=INS_NONE, InsertDeleteFlags nUndoExtraFlags=InsertDeleteFlags::NONE, bool bAllowDialogs=false)
Definition: viewfun3.cxx:871
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
BasicManager * GetBasicManager() const
SfxViewFrame & GetViewFrame() const
static SfxItemSet * GetDataSet(ScCellRangesBase *pRangeObj)
URL aURL
float u
bool bInitialWarningState
ScPasteFunc
Definition: global.hxx:181
@ INS_NONE
Definition: global.hxx:295
InsertDeleteFlags
Definition: global.hxx:149
OUString aName
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Type
index
ScDocShell * GetDocShellFromRange(const uno::Reference< uno::XInterface > &xRange)
ScTabViewShell * getCurrentBestViewShell(const uno::Reference< uno::XComponentContext > &xContext)
void setUpDocumentModules(const uno::Reference< sheet::XSpreadsheetDocument > &xDoc)
uno::Reference< sheet::XUnnamedDatabaseRanges > GetUnnamedDataBaseRanges(const ScDocShell *pShell)
void implnCut(const uno::Reference< frame::XModel > &xModel)
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)
void implnPasteSpecial(const uno::Reference< frame::XModel > &xModel, InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bTranspose)
SfxViewFrame * getViewFrame(const uno::Reference< frame::XModel > &xModel)
void implnPaste(const uno::Reference< frame::XModel > &xModel)
void ExportAsFixedFormatHelper(const uno::Reference< frame::XModel > &xModel, const css::uno::Reference< XApplication > &xApplication, const css::uno::Any &Type, const css::uno::Any &FileName, const css::uno::Any &Quality, const css::uno::Any &IncludeDocProperties, const css::uno::Any &From, const css::uno::Any &To, const css::uno::Any &OpenAfterPublish)
ScTabViewShell * getBestViewShell(const css::uno::Reference< css::frame::XModel > &xModel)
void implSetZoom(const uno::Reference< frame::XModel > &xModel, sal_Int16 nZoom, std::vector< SCTAB > &nTabs)
uno::Reference< sheet::XDatabaseRange > GetAutoFiltRange(const ScDocShell *pShell, sal_Int16 nSheet)
void implnCopy(const uno::Reference< frame::XModel > &xModel)
void SetDocInfoState(const uno::Reference< frame::XModel > &xModel, const uno::Reference< css::document::XDocumentProperties > &i_xOldDocProps)
uno::Reference< XHelperInterface > getUnoSheetModuleObj(const uno::Reference< table::XCellRange > &xRange)
uno::Reference< frame::XModel > getCurrentExcelDoc(const uno::Reference< uno::XComponentContext > &xContext)
uno::Reference< XHelperInterface > getUnoDocModule(std::u16string_view aModName, SfxObjectShell const *pShell)
Reference< XModel > xModel
sal_Int16 SCTAB
Definition: types.hxx:22