LibreOffice Module sc (master) 1
docsh4.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 <config_features.h>
21
22#include <boost/property_tree/json_parser.hpp>
23
24#include <com/sun/star/frame/Desktop.hpp>
25
26using namespace ::com::sun::star;
27
28#include <scitems.hxx>
29#include <editeng/flstitem.hxx>
30#include <sfx2/fcontnr.hxx>
31#include <sfx2/infobar.hxx>
32#include <sfx2/objface.hxx>
33#include <sfx2/docfile.hxx>
34#include <sfx2/docfilt.hxx>
35#include <svtools/ehdl.hxx>
36#include <svtools/langtab.hxx>
37#include <basic/sbxcore.hxx>
38#include <basic/sberrors.hxx>
39#include <svtools/sfxecode.hxx>
40#include <svx/ofaitem.hxx>
41#include <svl/stritem.hxx>
42#include <svl/whiter.hxx>
43#include <vcl/stdtext.hxx>
44#include <vcl/svapp.hxx>
45#include <vcl/weld.hxx>
47#include <svx/drawitem.hxx>
48#include <svx/fmshell.hxx>
49#include <sfx2/passwd.hxx>
51#include <sfx2/dispatch.hxx>
52#include <sfx2/sfxdlg.hxx>
57#include <LibreOfficeKit/LibreOfficeKitEnums.h>
58#include <sal/log.hxx>
61#include <o3tl/string_view.hxx>
62
63#include <comphelper/lok.hxx>
66#include <docuno.hxx>
67
68#include <docsh.hxx>
69#include "docshimp.hxx"
70#include <docfunc.hxx>
71#include <scres.hrc>
72#include <strings.hrc>
73#include <stlsheet.hxx>
74#include <stlpool.hxx>
75#include <appoptio.hxx>
76#include <globstr.hrc>
77#include <global.hxx>
78#include <dbdocfun.hxx>
79#include <printfun.hxx>
80#include <viewdata.hxx>
81#include <tabvwsh.hxx>
82#include <impex.hxx>
83#include <undodat.hxx>
84#include <undocell.hxx>
85#include <inputhdl.hxx>
86#include <dbdata.hxx>
87#include <servobj.hxx>
88#include <rangenam.hxx>
89#include <scmod.hxx>
90#include <chgviset.hxx>
91#include <reffact.hxx>
92#include <chartlis.hxx>
93#include <chartpos.hxx>
94#include <tablink.hxx>
95#include <drwlayer.hxx>
96#include <docoptio.hxx>
97#include <undostyl.hxx>
98#include <rangeseq.hxx>
99#include <chgtrack.hxx>
100#include <com/sun/star/document/UpdateDocMode.hpp>
101#include <scresid.hxx>
102#include <scabstdlg.hxx>
103#include <sharedocdlg.hxx>
104#include <conditio.hxx>
105#include <sheetevents.hxx>
106#include <formulacell.hxx>
107#include <documentlinkmgr.hxx>
108#include <memory>
110#include <helpids.h>
111#include <editeng/eeitem.hxx>
112#include <editeng/langitem.hxx>
113
114#include <svx/xdef.hxx>
115
117{
118 if (pMed)
119 {
120 const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>( pMed->GetItemSet(),
121 SID_UPDATEDOCMODE, false);
122 m_nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : css::document::UpdateDocMode::NO_UPDATE;
123 }
124
125 // GetLinkUpdateModeState() evaluates m_nCanUpdate so that must have
126 // been set first. Do not override an already forbidden LinkUpdate (the
127 // default is allow).
129 if (rEmbeddedObjectContainer.getUserAllowsLinkUpdate())
130 {
131 // For anything else than LM_ALWAYS we need user confirmation.
132 rEmbeddedObjectContainer.setUserAllowsLinkUpdate( GetLinkUpdateModeState() == LM_ALWAYS);
133 }
134}
135
137{
138 ScLkUpdMode nSet;
139 if (m_nCanUpdate == css::document::UpdateDocMode::NO_UPDATE)
140 nSet = LM_NEVER;
141 else if (m_nCanUpdate == css::document::UpdateDocMode::FULL_UPDATE)
142 nSet = LM_ALWAYS;
143 else
144 {
145 nSet = GetDocument().GetLinkMode();
146 if (nSet == LM_UNKNOWN)
147 {
148 ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
149 nSet = aAppOptions.GetLinkMode();
150 }
151 }
152
153 if (nSet == LM_ALWAYS
155 GetMedium() == nullptr ? OUString() : GetMedium()->GetName())
156 || (IsDocShared()
158 GetSharedFileURL()))))
159 {
160 nSet = LM_ON_DEMAND;
161 }
162 if (m_nCanUpdate == css::document::UpdateDocMode::QUIET_UPDATE
163 && nSet == LM_ON_DEMAND)
164 {
165 nSet = LM_NEVER;
166 }
167
168 return nSet;
169}
170
172{
173 m_pDocument->SetLinkFormulaNeedingCheck(false);
175}
176
178{
180
182 weld::Window *pDialogParent = GetActiveDialogParent();
183 m_pDocument->UpdateExternalRefLinks(pDialogParent);
184
185 bool bAnyDde = m_pDocument->GetDocLinkManager().updateDdeOrOleOrWebServiceLinks(pDialogParent);
186
187 if (bAnyDde)
188 {
189 // calculate formulas and paint like in the TrackTimeHdl
190 m_pDocument->TrackFormulas();
191 Broadcast(SfxHint(SfxHintId::ScDataChanged));
192
193 // Should FID_DATACHANGED become asynchronous some time
194 // (e.g., with Invalidate at Window), an update needs to be forced here.
195 }
196
197 m_pDocument->UpdateAreaLinks();
198}
199
200IMPL_LINK_NOARG( ScDocShell, ReloadAllLinksHdl, weld::Button&, void )
201{
202 ReloadAllLinks();
203
204 ScTabViewShell* pViewSh = GetBestViewShell();
205 SfxViewFrame* pViewFrame = pViewSh ? pViewSh->GetFrame() : nullptr;
206 if (pViewFrame)
207 pViewFrame->RemoveInfoBar(u"enablecontent");
208 SAL_WARN_IF(!pViewFrame, "sc", "expected there to be a ViewFrame");
209}
210
211namespace
212{
213 class LinkHelp
214 {
215 public:
216 DECL_STATIC_LINK(LinkHelp, DispatchHelpLinksHdl, weld::Button&, void);
217 };
218}
219
220IMPL_STATIC_LINK(LinkHelp, DispatchHelpLinksHdl, weld::Button&, rBtn, void)
221{
222 if (Help* pHelp = Application::GetHelp())
223 pHelp->Start(HID_UPDATE_LINK_WARNING, &rBtn);
224}
225
227{
228 const SfxItemSet* pReqArgs = rReq.GetArgs();
229 SfxBindings* pBindings = GetViewBindings();
230 bool bUndo (m_pDocument->IsUndoEnabled());
231
232 sal_uInt16 nSlot = rReq.GetSlot();
233 switch ( nSlot )
234 {
235 case SID_SC_SETTEXT:
236 {
237 const SfxPoolItem* pColItem;
238 const SfxPoolItem* pRowItem;
239 const SfxPoolItem* pTabItem;
240 const SfxPoolItem* pTextItem;
241 if( pReqArgs && pReqArgs->HasItem( FN_PARAM_1, &pColItem ) &&
242 pReqArgs->HasItem( FN_PARAM_2, &pRowItem ) &&
243 pReqArgs->HasItem( FN_PARAM_3, &pTabItem ) &&
244 pReqArgs->HasItem( SID_SC_SETTEXT, &pTextItem ) )
245 {
246 // parameters are 1-based !!!
247 SCCOL nCol = static_cast<const SfxInt16Item*>(pColItem)->GetValue() - 1;
248 SCROW nRow = static_cast<const SfxInt32Item*>(pRowItem)->GetValue() - 1;
249 SCTAB nTab = static_cast<const SfxInt16Item*>(pTabItem)->GetValue() - 1;
250
251 SCTAB nTabCount = m_pDocument->GetTableCount();
252 if ( m_pDocument->ValidCol(nCol) && m_pDocument->ValidRow(nRow) && ValidTab(nTab,nTabCount) )
253 {
254 if ( m_pDocument->IsBlockEditable( nTab, nCol,nRow, nCol, nRow ) )
255 {
256 OUString aVal = static_cast<const SfxStringItem*>(pTextItem)->GetValue();
257 m_pDocument->SetString( nCol, nRow, nTab, aVal );
258
259 PostPaintCell( nCol, nRow, nTab );
261
262 rReq.Done();
263 break;
264 }
265 else // protected cell
266 {
267#if HAVE_FEATURE_SCRIPTING
269#endif
270 break;
271 }
272 }
273 }
274#if HAVE_FEATURE_SCRIPTING
276#endif
277 }
278 break;
279
280 case SID_SBA_IMPORT:
281 {
282 if (pReqArgs)
283 {
284 const SfxPoolItem* pItem;
286 if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
287 {
288 uno::Any aAny = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
289 uno::Sequence<beans::PropertyValue> aProperties;
290 if ( aAny >>= aProperties )
292 }
293
294 OUString sTarget;
295 if ( pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
296 sTarget = static_cast<const SfxStringItem*>(pItem)->GetValue();
297
298 bool bIsNewArea = true; // Default sal_True (no inquiry)
299 if ( pReqArgs->GetItemState( FN_PARAM_2, true, &pItem ) == SfxItemState::SET )
300 bIsNewArea = static_cast<const SfxBoolItem*>(pItem)->GetValue();
301
302 // if necessary, create new database area
303 bool bMakeArea = false;
304 if (bIsNewArea)
305 {
306 ScDBCollection* pDBColl = m_pDocument->GetDBCollection();
307 if ( !pDBColl || !pDBColl->getNamedDBs().findByUpperName(ScGlobal::getCharClass().uppercase(sTarget)) )
308 {
309 ScAddress aPos;
310 if ( aPos.Parse( sTarget, *m_pDocument, m_pDocument->GetAddressConvention() ) & ScRefFlags::VALID )
311 {
312 bMakeArea = true;
313 if (bUndo)
314 {
315 OUString aStrImport = ScResId( STR_UNDO_IMPORTDATA );
316 ViewShellId nViewShellId(-1);
318 nViewShellId = pViewSh->GetViewShellId();
319 GetUndoManager()->EnterListAction( aStrImport, aStrImport, 0, nViewShellId );
320 }
321
323 OSL_ENSURE(pDBData, "Cannot create DB data");
324 sTarget = pDBData->GetName();
325 }
326 }
327 }
328
329 // inquire, before old DB range gets overwritten
330 bool bDo = true;
331 if (!bIsNewArea)
332 {
333 OUString aTemplate = ScResId( STR_IMPORT_REPLACE );
334 OUString aMessage = o3tl::getToken(aTemplate, 0, '#' )
335 + sTarget
336 + o3tl::getToken(aTemplate, 1, '#' );
337
338 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr,
339 VclMessageType::Question, VclButtonsType::YesNo,
340 aMessage));
341 xQueryBox->set_default_response(RET_YES);
342 bDo = xQueryBox->run() == RET_YES;
343 }
344
345 if (bDo)
346 {
347 ScDBDocFunc(*this).UpdateImport( sTarget, aDesc );
348 rReq.Done();
349
350 // UpdateImport also updates the internal operations
351 }
352 else
353 rReq.Ignore();
354
355 if ( bMakeArea && bUndo)
357 }
358 else
359 {
360 OSL_FAIL( "arguments expected" );
361 }
362 }
363 break;
364
365 case SID_CHART_SOURCE:
366 case SID_CHART_ADDSOURCE:
367 if (pReqArgs)
368 {
369 ScDocument& rDoc = GetDocument();
370 const SfxPoolItem* pItem;
371 OUString aChartName, aRangeName;
372
373 ScRange aSingleRange;
374 ScRangeListRef aRangeListRef;
375 bool bMultiRange = false;
376
377 bool bColHeaders = true;
378 bool bRowHeaders = true;
379 bool bColInit = false;
380 bool bRowInit = false;
381 bool bAddRange = (nSlot == SID_CHART_ADDSOURCE);
382
383 if( const SfxStringItem* pChartItem = pReqArgs->GetItemIfSet( SID_CHART_NAME ) )
384 aChartName = pChartItem->GetValue();
385
386 if( const SfxStringItem* pChartItem = pReqArgs->GetItemIfSet( SID_CHART_SOURCE ) )
387 aRangeName = pChartItem->GetValue();
388
389 if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
390 {
391 bColHeaders = static_cast<const SfxBoolItem*>(pItem)->GetValue();
392 bColInit = true;
393 }
394 if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
395 {
396 bRowHeaders = static_cast<const SfxBoolItem*>(pItem)->GetValue();
397 bRowInit = true;
398 }
399
400 ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
401 bool bValid = (aSingleRange.ParseAny(aRangeName, rDoc, aDetails) & ScRefFlags::VALID) != ScRefFlags::ZERO;
402 if (!bValid)
403 {
404 aRangeListRef = new ScRangeList;
405 aRangeListRef->Parse( aRangeName, rDoc, rDoc.GetAddressConvention());
406 if ( !aRangeListRef->empty() )
407 {
408 bMultiRange = true;
409 aSingleRange = aRangeListRef->front(); // for header
410 bValid = true;
411 }
412 else
413 aRangeListRef.clear();
414 }
415
417 if (pViewSh && bValid && !aChartName.isEmpty() )
418 {
419 weld::Window* pParent = pViewSh->GetFrameWeld();
420
421 SCCOL nCol1 = aSingleRange.aStart.Col();
422 SCROW nRow1 = aSingleRange.aStart.Row();
423 SCCOL nCol2 = aSingleRange.aEnd.Col();
424 SCROW nRow2 = aSingleRange.aEnd.Row();
425 SCTAB nTab = aSingleRange.aStart.Tab();
426
428 if (!bMultiRange)
429 m_pDocument->LimitChartArea( nTab, nCol1,nRow1, nCol2,nRow2 );
430
431 // Dialog for column/row headers
432 bool bOk = true;
433 if ( !bAddRange && ( !bColInit || !bRowInit ) )
434 {
435 ScChartPositioner aChartPositioner( *m_pDocument, nTab, nCol1,nRow1, nCol2,nRow2 );
436 if (!bColInit)
437 bColHeaders = aChartPositioner.HasColHeaders();
438 if (!bRowInit)
439 bRowHeaders = aChartPositioner.HasRowHeaders();
440
442
443 ScopedVclPtr<AbstractScColRowLabelDlg> pDlg(pFact->CreateScColRowLabelDlg(pParent, bRowHeaders, bColHeaders));
444 if ( pDlg->Execute() == RET_OK )
445 {
446 bColHeaders = pDlg->IsRow();
447 bRowHeaders = pDlg->IsCol();
448
449 rReq.AppendItem(SfxBoolItem(FN_PARAM_1, bColHeaders));
450 rReq.AppendItem(SfxBoolItem(FN_PARAM_2, bRowHeaders));
451 }
452 else
453 bOk = false;
454 }
455
456 if (bOk) // execute
457 {
458 if (bMultiRange)
459 {
460 if (bUndo)
461 {
463 std::make_unique<ScUndoChartData>( this, aChartName, aRangeListRef,
464 bColHeaders, bRowHeaders, bAddRange ) );
465 }
466 m_pDocument->UpdateChartArea( aChartName, aRangeListRef,
467 bColHeaders, bRowHeaders, bAddRange );
468 }
469 else
470 {
471 ScRange aNewRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
472 if (bUndo)
473 {
475 std::make_unique<ScUndoChartData>( this, aChartName, aNewRange,
476 bColHeaders, bRowHeaders, bAddRange ) );
477 }
478 m_pDocument->UpdateChartArea( aChartName, aNewRange,
479 bColHeaders, bRowHeaders, bAddRange );
480 }
481 }
482 }
483 else
484 {
485 OSL_FAIL("UpdateChartArea: no ViewShell or wrong data");
486 }
487 rReq.Done();
488 }
489 else
490 {
491 OSL_FAIL("SID_CHART_SOURCE without arguments");
492 }
493 break;
494
495 case FID_AUTO_CALC:
496 {
497 bool bNewVal;
498 const SfxPoolItem* pItem;
499 if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) )
500 bNewVal = static_cast<const SfxBoolItem*>(pItem)->GetValue();
501 else
502 bNewVal = !m_pDocument->GetAutoCalc(); // Toggle for menu
503 m_pDocument->SetAutoCalc( bNewVal );
505 if (pBindings)
506 {
507 pBindings->Invalidate( FID_AUTO_CALC );
508 }
509 rReq.AppendItem( SfxBoolItem( FID_AUTO_CALC, bNewVal ) );
510 rReq.Done();
511 }
512 break;
513 case FID_RECALC:
514 DoRecalc( rReq.IsAPI() );
515 rReq.Done();
516 break;
517 case FID_HARD_RECALC:
518 DoHardRecalc();
519 rReq.Done();
520 break;
521 case SID_UPDATETABLINKS:
522 {
524
525 if (nSet == LM_ALWAYS)
526 {
528 rReq.Done();
529 }
530 else if (nSet == LM_NEVER)
531 {
533 rReq.Ignore();
534 }
535 else if (nSet == LM_ON_DEMAND)
536 {
537 ScTabViewShell* pViewSh = GetBestViewShell();
538 SfxViewFrame* pViewFrame = pViewSh ? pViewSh->GetFrame() : nullptr;
539 if (pViewFrame)
540 {
541 pViewFrame->RemoveInfoBar(u"enablecontent");
542 auto pInfoBar = pViewFrame->AppendInfoBar("enablecontent", "", ScResId(STR_RELOAD_TABLES), InfobarType::WARNING);
543 if (pInfoBar)
544 {
545 weld::Button& rHelpBtn = pInfoBar->addButton();
546 rHelpBtn.set_label(GetStandardText(StandardButtonType::Help).replaceFirst("~", ""));
547 rHelpBtn.connect_clicked(LINK(nullptr, LinkHelp, DispatchHelpLinksHdl));
548 weld::Button& rBtn = pInfoBar->addButton();
549 rBtn.set_label(ScResId(STR_ENABLE_CONTENT));
550 rBtn.set_tooltip_text(ScResId(STR_ENABLE_CONTENT_TOOLTIP));
551 rBtn.connect_clicked(LINK(this, ScDocShell, ReloadAllLinksHdl));
552 }
553 }
554 rReq.Done();
555 }
556 }
557 break;
558
559 case SID_REIMPORT_AFTER_LOAD:
560 {
561 // Is called after loading if there are DB areas with omitted data
562
563 bool bDone = false;
564 ScDBCollection* pDBColl = m_pDocument->GetDBCollection();
565
566 if ((m_nCanUpdate != css::document::UpdateDocMode::NO_UPDATE) &&
567 (m_nCanUpdate != css::document::UpdateDocMode::QUIET_UPDATE))
568 {
569 ScRange aRange;
570 ScTabViewShell* pViewSh = GetBestViewShell();
571 OSL_ENSURE(pViewSh,"SID_REIMPORT_AFTER_LOAD: no View");
572 if (pViewSh && pDBColl)
573 {
574 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetActiveDialogParent(),
575 VclMessageType::Question, VclButtonsType::YesNo,
576 ScResId(STR_REIMPORT_AFTER_LOAD)));
577 xQueryBox->set_default_response(RET_YES);
578 if (xQueryBox->run() == RET_YES)
579 {
580 ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs();
581 for (const auto& rxDB : rDBs)
582 {
583 ScDBData& rDBData = *rxDB;
584 if ( rDBData.IsStripData() &&
585 rDBData.HasImportParam() && !rDBData.HasImportSelection() )
586 {
587 rDBData.GetArea(aRange);
588 pViewSh->MarkRange(aRange);
589
590 // Import and internal operations like SID_REFRESH_DBAREA
591 // (inquiry for import not needed here)
592
593 ScImportParam aImportParam;
594 rDBData.GetImportParam( aImportParam );
595 bool bContinue = pViewSh->ImportData( aImportParam );
596 rDBData.SetImportParam( aImportParam );
597
598 // mark (size may have changed)
599 rDBData.GetArea(aRange);
600 pViewSh->MarkRange(aRange);
601
602 if ( bContinue ) // error at import -> abort
603 {
604 // internal operations, if some where saved
605
606 if ( rDBData.HasQueryParam() || rDBData.HasSortParam() ||
607 rDBData.HasSubTotalParam() )
608 pViewSh->RepeatDB();
609
610 // pivot tables, which have the range as source data
611
612 RefreshPivotTables(aRange);
613 }
614 }
615 }
616 bDone = true;
617 }
618 }
619 }
620
621 if ( !bDone && pDBColl )
622 {
623 // if not, but then update the dependent formulas
625
626 m_pDocument->CalcAll();
628 }
629
630 if (bDone)
631 rReq.Done();
632 else
633 rReq.Ignore();
634 }
635 break;
636
637 case SID_AUTO_STYLE:
638 OSL_FAIL("use ScAutoStyleHint instead of SID_AUTO_STYLE");
639 break;
640
641 case SID_GET_COLORLIST:
642 {
643 const SvxColorListItem* pColItem = GetItem(SID_COLOR_TABLE);
644 const XColorListRef& pList = pColItem->GetColorList();
645 rReq.SetReturnValue(OfaXColorListItem(SID_GET_COLORLIST, pList));
646 }
647 break;
648
649 case FID_CHG_RECORD:
650 {
651 ScDocument& rDoc = GetDocument();
652 // get argument (recorded macro)
653 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(FID_CHG_RECORD);
654 bool bDo = true;
655
656 // desired state
657 ScChangeTrack* pChangeTrack = rDoc.GetChangeTrack();
658 bool bActivateTracking = (pChangeTrack == nullptr); // toggle
659 if ( pItem )
660 bActivateTracking = pItem->GetValue(); // from argument
661
662 if ( !bActivateTracking )
663 {
664 if ( !pItem )
665 {
666 // no dialog on playing the macro
667 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
668 VclMessageType::Warning, VclButtonsType::YesNo,
669 ScResId(STR_END_REDLINING)));
670 xWarn->set_default_response(RET_NO);
671 bDo = (xWarn->run() == RET_YES );
672 }
673
674 if ( bDo )
675 {
676 if (pChangeTrack)
677 {
678 if ( pChangeTrack->IsProtected() )
680 }
681 if ( bDo )
682 {
683 rDoc.EndChangeTracking();
685 }
686 }
687 }
688 else
689 {
690 rDoc.StartChangeTracking();
691 ScChangeViewSettings aChangeViewSet;
692 aChangeViewSet.SetShowChanges(true);
693 rDoc.SetChangeViewSettings(aChangeViewSet);
694 }
695
696 if ( bDo )
697 {
699
700 // invalidate slots
701 if (pBindings)
702 pBindings->InvalidateAll(false);
703 if ( !pItem )
704 rReq.AppendItem( SfxBoolItem( FID_CHG_RECORD, bActivateTracking ) );
705 rReq.Done();
706 }
707 else
708 rReq.Ignore();
709 }
710 break;
711
712 case SID_CHG_PROTECT :
713 {
715 {
716 rReq.Done();
718 }
719 else
720 rReq.Ignore();
721 }
722 break;
723
724 case SID_DOCUMENT_MERGE:
725 case SID_DOCUMENT_COMPARE:
726 {
727 bool bDo = true;
728 ScChangeTrack* pChangeTrack = m_pDocument->GetChangeTrack();
729 if ( pChangeTrack && !m_pImpl->bIgnoreLostRedliningWarning )
730 {
731 if ( nSlot == SID_DOCUMENT_COMPARE )
732 {
733 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
734 VclMessageType::Warning, VclButtonsType::YesNo,
735 ScResId(STR_END_REDLINING)));
736 xWarn->set_default_response(RET_NO);
737 if (xWarn->run() == RET_YES)
738 bDo = ExecuteChangeProtectionDialog( true );
739 else
740 bDo = false;
741 }
742 else // merge might reject some actions
743 bDo = ExecuteChangeProtectionDialog( true );
744 }
745 if ( !bDo )
746 {
747 rReq.Ignore();
748 break;
749 }
750 SfxApplication* pApp = SfxGetpApp();
751 const SfxPoolItem* pItem;
752 const SfxStringItem* pFileNameItem(nullptr);
753 SfxMedium* pMed = nullptr;
754 if (pReqArgs)
755 pFileNameItem = pReqArgs->GetItemIfSet(SID_FILE_NAME);
756 if (pFileNameItem)
757 {
758 OUString aFileName = pFileNameItem->GetValue();
759
760 OUString aFilterName;
761 if (const SfxStringItem* pFilterItem = pReqArgs->GetItemIfSet(SID_FILTER_NAME))
762 {
763 aFilterName = pFilterItem->GetValue();
764 }
765 OUString aOptions;
766 if (const SfxStringItem* pOptionsItem = pReqArgs->GetItemIfSet(SID_FILE_FILTEROPTIONS))
767 {
768 aOptions = pOptionsItem->GetValue();
769 }
770 short nVersion = 0;
771 const SfxInt16Item* pInt16Item(nullptr);
772 if (pReqArgs->GetItemState(SID_VERSION, true, &pItem) == SfxItemState::SET)
773 pInt16Item = dynamic_cast<const SfxInt16Item*>(pItem);
774 if (pInt16Item)
775 {
776 nVersion = pInt16Item->GetValue();
777 }
778
779 // no filter specified -> detection
780 if (aFilterName.isEmpty())
781 ScDocumentLoader::GetFilterName( aFileName, aFilterName, aOptions, true, false );
782
783 // filter name from dialog contains application prefix,
784 // GetFilter needs name without the prefix.
786
787 std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
788 auto pSet = std::make_shared<SfxAllItemSet>( pApp->GetPool() );
789 if (!aOptions.isEmpty())
790 pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
791 if ( nVersion != 0 )
792 pSet->Put( SfxInt16Item( SID_VERSION, nVersion ) );
793 pMed = new SfxMedium( aFileName, StreamMode::STD_READ, pFilter, std::move(pSet) );
794 }
795 else
796 {
797 const sfx2::DocumentInserter::Mode mode { nSlot==SID_DOCUMENT_COMPARE
800 // start file dialog asynchronous
801 m_pImpl->bIgnoreLostRedliningWarning = true;
802 m_pImpl->pRequest.reset(new SfxRequest( rReq ));
803 m_pImpl->pDocInserter.reset();
804
806 weld::Window* pParent = pViewSh ? pViewSh->GetFrameWeld() : nullptr;
807 m_pImpl->pDocInserter.reset( new ::sfx2::DocumentInserter(pParent,
808 ScDocShell::Factory().GetFactoryName(), mode ) );
809 m_pImpl->pDocInserter->StartExecuteModal( LINK( this, ScDocShell, DialogClosedHdl ) );
810 return ;
811 }
812
813 // now execute in earnest...
815
816 // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here
817 ScDocShell* pOtherDocSh = new ScDocShell;
818 SfxObjectShellLock aDocShTablesRef = pOtherDocSh;
819 pOtherDocSh->DoLoad( pMed );
820 ErrCode nErr = pOtherDocSh->GetErrorCode();
821 if (nErr)
822 ErrorHandler::HandleError( nErr ); // also warnings
823
824 if ( !pOtherDocSh->GetError() ) // only errors
825 {
826 bool bHadTrack = ( m_pDocument->GetChangeTrack() != nullptr );
827#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
828 sal_uLong nStart = 0;
829 if ( nSlot == SID_DOCUMENT_MERGE && pChangeTrack )
830 {
831 nStart = pChangeTrack->GetActionMax() + 1;
832 }
833#endif
834 if ( nSlot == SID_DOCUMENT_COMPARE )
835 CompareDocument( pOtherDocSh->GetDocument() );
836 else
837 MergeDocument( pOtherDocSh->GetDocument() );
838
839 // show "accept changes" dialog
841 if ( !IsDocShared() )
842 {
844 if ( pViewFrm )
845 {
846 pViewFrm->ShowChildWindow( ScAcceptChgDlgWrapper::GetChildWindowId() ); //@51669
847 }
848 if ( pBindings )
849 {
850 pBindings->Invalidate( FID_CHG_ACCEPT );
851 }
852 }
853
854 rReq.SetReturnValue( SfxInt32Item( nSlot, 0 ) );
855 rReq.Done();
856
857 if (!bHadTrack) // newly turned on -> show as well
858 {
859 ScChangeViewSettings* pOldSet = m_pDocument->GetChangeViewSettings();
860 if ( !pOldSet || !pOldSet->ShowChanges() )
861 {
862 ScChangeViewSettings aChangeViewSet;
863 aChangeViewSet.SetShowChanges(true);
864 m_pDocument->SetChangeViewSettings(aChangeViewSet);
865 }
866 }
867#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
868 else if ( nSlot == SID_DOCUMENT_MERGE && IsDocShared() && pChangeTrack )
869 {
870 sal_uLong nEnd = pChangeTrack->GetActionMax();
871 if ( nEnd >= nStart )
872 {
873 // only show changes from merged document
874 ScChangeViewSettings aChangeViewSet;
875 aChangeViewSet.SetShowChanges( true );
876 aChangeViewSet.SetShowAccepted( true );
877 aChangeViewSet.SetHasActionRange();
878 aChangeViewSet.SetTheActionRange( nStart, nEnd );
879 m_pDocument->SetChangeViewSettings( aChangeViewSet );
880
881 // update view
884 }
885 }
886#endif
887 }
888 pOtherDocSh->DoClose(); // delete happens with the Ref
889 }
890 break;
891
892 case SID_DELETE_SCENARIO:
893 if (pReqArgs)
894 {
895 const SfxPoolItem* pItem;
896 if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
897 {
898 if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
899 {
900 const OUString& aName = pStringItem->GetValue();
901 SCTAB nTab;
902 if (m_pDocument->GetTable( aName, nTab ))
903 {
904 // move DeleteTable from viewfunc to docfunc!
905
907 if ( pSh )
908 {
910 SCTAB nDispTab = pSh->GetViewData().GetTabNo();
911 pSh->DeleteTable( nTab );
912 pSh->SetTabNo(nDispTab);
913 rReq.Done();
914 }
915 }
916 }
917 }
918 }
919 break;
920
921 case SID_EDIT_SCENARIO:
922 {
923 const SfxPoolItem* pItem;
924 if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
925 {
926 if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
927 {
928 OUString aName = pStringItem->GetValue();
929 SCTAB nTab;
930 if (m_pDocument->GetTable( aName, nTab ))
931 {
932 if (m_pDocument->IsScenario(nTab))
933 {
934 OUString aComment;
935 Color aColor;
936 ScScenarioFlags nFlags;
937 m_pDocument->GetScenarioData( nTab, aComment, aColor, nFlags );
938
939 // Determine if the Sheet that the Scenario was created on
940 // is protected. But first we need to find that Sheet.
941 // Rewind back to the actual sheet.
942 SCTAB nActualTab = nTab;
943 do
944 {
945 nActualTab--;
946 }
947 while(m_pDocument->IsScenario(nActualTab));
948 bool bSheetProtected = m_pDocument->IsTabProtected(nActualTab);
949
951
953 pNewDlg->SetScenarioData( aName, aComment, aColor, nFlags );
954 if ( pNewDlg->Execute() == RET_OK )
955 {
956 pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
957 ModifyScenario( nTab, aName, aComment, aColor, nFlags );
958 rReq.Done();
959 }
960 }
961 }
962 }
963 }
964 }
965 break;
966
967 case SID_ATTR_YEAR2000 :
968 {
969 const SfxPoolItem* pItem;
970 if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
971 {
972 if (const SfxUInt16Item* pInt16Item = dynamic_cast<const SfxUInt16Item*>(pItem))
973 {
974 sal_uInt16 nY2k = pInt16Item->GetValue();
975 // set always to DocOptions, so that it is also saved for S050
976 // (and all inquiries run up until now on it as well).
977 // SetDocOptions propagates that to the NumberFormatter
978 ScDocOptions aDocOpt( m_pDocument->GetDocOptions() );
979 aDocOpt.SetYear2000( nY2k );
980 m_pDocument->SetDocOptions( aDocOpt );
981 // the FormShell shall notice it as well
983 if ( pSh )
984 {
985 FmFormShell* pFSh = pSh->GetFormShell();
986 if ( pFSh )
987 pFSh->SetY2KState( nY2k );
988 }
989 }
990 }
991 }
992 break;
993
994#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
995 case SID_SHARE_DOC:
996 {
997 ScViewData* pViewData = GetViewData();
998 if ( !pViewData )
999 {
1000 rReq.Ignore();
1001 break;
1002 }
1003
1005 ScShareDocumentDlg aDlg(pWin, pViewData);
1006 if (aDlg.run() == RET_OK)
1007 {
1008 bool bSetShared = aDlg.IsShareDocumentChecked();
1009 if ( bSetShared != IsDocShared() )
1010 {
1011 if ( bSetShared )
1012 {
1013 bool bContinue = true;
1014 if ( HasName() )
1015 {
1016 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin,
1017 VclMessageType::Question, VclButtonsType::YesNo,
1018 ScResId(STR_DOC_WILLBESAVED)));
1019 xQueryBox->set_default_response(RET_YES);
1020 if (xQueryBox->run() == RET_NO)
1021 {
1022 bContinue = false;
1023 }
1024 }
1025 if ( bContinue )
1026 {
1027 EnableSharedSettings( true );
1028
1029 SC_MOD()->SetInSharedDocSaving( true );
1030 if ( !SwitchToShared( true, true ) )
1031 {
1032 // TODO/LATER: what should be done in case the switch has failed?
1033 // for example in case the user has cancelled the saveAs operation
1034 }
1035
1036 SC_MOD()->SetInSharedDocSaving( false );
1037
1039 GetUndoManager()->Clear();
1040
1041 ScTabView* pTabView = pViewData->GetView();
1042 if ( pTabView )
1043 {
1044 pTabView->UpdateLayerLocks();
1045 }
1046 }
1047 }
1048 else
1049 {
1050 uno::Reference< frame::XModel > xModel;
1051 try
1052 {
1053 // load shared file
1054 xModel.set( LoadSharedDocument(), uno::UNO_SET_THROW );
1055 uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
1056
1057 // check if shared flag is set in shared file
1058 bool bShared = false;
1059 ScModelObj* pDocObj = comphelper::getFromUnoTunnel<ScModelObj>( xModel );
1060 if ( pDocObj )
1061 {
1062 ScDocShell* pDocShell = dynamic_cast< ScDocShell* >( pDocObj->GetEmbeddedObject() );
1063 if ( pDocShell )
1064 {
1065 bShared = pDocShell->HasSharedXMLFlagSet();
1066 }
1067 }
1068
1069 // #i87870# check if shared status was disabled and enabled again
1070 bool bOwnEntry = false;
1071 try
1072 {
1073 ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
1074 bOwnEntry = aControlFile.HasOwnEntry();
1075 }
1076 catch ( uno::Exception& )
1077 {
1078 }
1079
1080 if ( bShared && bOwnEntry )
1081 {
1082 uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
1083 if ( xStorable->isReadonly() )
1084 {
1085 xCloseable->close( true );
1086
1087 OUString aUserName( ScResId( STR_UNKNOWN_USER ) );
1088 try
1089 {
1091 LockFileEntry aData = aLockFile.GetLockData();
1092 if ( !aData[LockFileComponent::OOOUSERNAME].isEmpty() )
1093 {
1094 aUserName = aData[LockFileComponent::OOOUSERNAME];
1095 }
1096 else if ( !aData[LockFileComponent::SYSUSERNAME].isEmpty() )
1097 {
1098 aUserName = aData[LockFileComponent::SYSUSERNAME];
1099 }
1100 }
1101 catch ( uno::Exception& )
1102 {
1103 }
1104 OUString aMessage( ScResId( STR_FILE_LOCKED_TRY_LATER ) );
1105 aMessage = aMessage.replaceFirst( "%1", aUserName );
1106
1107 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin,
1108 VclMessageType::Warning, VclButtonsType::Ok,
1109 aMessage));
1110 xWarn->run();
1111 }
1112 else
1113 {
1114 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin,
1115 VclMessageType::Warning, VclButtonsType::YesNo,
1116 ScResId(STR_DOC_DISABLESHARED)));
1117 xWarn->set_default_response(RET_YES);
1118
1119 if (xWarn->run() == RET_YES)
1120 {
1121 xCloseable->close( true );
1122
1123 if ( !SwitchToShared( false, true ) )
1124 {
1125 // TODO/LATER: what should be done in case the switch has failed?
1126 // for example in case the user has cancelled the saveAs operation
1127 }
1128
1129 EnableSharedSettings( false );
1130
1131 // Do *not* use dispatch mechanism in this place - we don't want others (extensions etc.) to intercept this.
1132 uno::Reference<frame::XStorable> xStorable2(
1133 GetModel(), uno::UNO_QUERY_THROW);
1134 xStorable2->store();
1135
1136 ScTabView* pTabView = pViewData->GetView();
1137 if ( pTabView )
1138 {
1139 pTabView->UpdateLayerLocks();
1140 }
1141 }
1142 else
1143 {
1144 xCloseable->close( true );
1145 }
1146 }
1147 }
1148 else
1149 {
1150 xCloseable->close( true );
1151 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin,
1152 VclMessageType::Warning, VclButtonsType::Ok,
1153 ScResId(STR_DOC_NOLONGERSHARED)));
1154 xWarn->run();
1155 }
1156 }
1157 catch ( uno::Exception& )
1158 {
1159 TOOLS_WARN_EXCEPTION( "sc", "SID_SHARE_DOC" );
1160 SC_MOD()->SetInSharedDocSaving( false );
1161
1162 try
1163 {
1164 uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
1165 xClose->close( true );
1166 }
1167 catch ( uno::Exception& )
1168 {
1169 }
1170 }
1171 }
1172 }
1173 }
1174 rReq.Done();
1175 }
1176 break;
1177#endif
1178 case SID_OPEN_CALC:
1179 {
1180 SfxStringItem aApp(SID_DOC_SERVICE, "com.sun.star.sheet.SpreadsheetDocument");
1181 SfxStringItem aTarget(SID_TARGETNAME, "_blank");
1183 SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON,
1184 { &aApp, &aTarget });
1185 }
1186 break;
1187 case SID_NOTEBOOKBAR:
1188 {
1189 const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>( SID_NOTEBOOKBAR );
1190
1191 if ( pBindings && sfx2::SfxNotebookBar::IsActive() )
1192 sfx2::SfxNotebookBar::ExecMethod(*pBindings, pFile ? pFile->GetValue() : "");
1193 else if ( pBindings )
1195 }
1196 break;
1197 case SID_LANGUAGE_STATUS:
1198 {
1199 OUString aLangText;
1200 const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot);
1201 if ( pItem )
1202 aLangText = pItem->GetValue();
1203
1204 if ( !aLangText.isEmpty() )
1205 {
1206 LanguageType eLang, eLatin, eCjk, eCtl;
1207 static const OUStringLiteral aSelectionLangPrefix(u"Current_");
1208 static const OUStringLiteral aParagraphLangPrefix(u"Paragraph_");
1209 static const OUStringLiteral aDocLangPrefix(u"Default_");
1210
1211 bool bSelection = false;
1212 bool bParagraph = false;
1213
1214 ScDocument& rDoc = GetDocument();
1215 rDoc.GetLanguage( eLatin, eCjk, eCtl );
1216
1217 sal_Int32 nPos = 0;
1218 if ( aLangText == "*" )
1219 {
1222 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclDialog(pSh ? pSh->GetDialogParent() : nullptr, SID_LANGUAGE_OPTIONS));
1223 pDlg->Execute();
1224
1225 rDoc.GetLanguage( eLang, eCjk, eCtl );
1226 }
1227 else if ( (nPos = aLangText.indexOf(aDocLangPrefix)) != -1 )
1228 {
1229 aLangText = aLangText.replaceAt(nPos, aDocLangPrefix.getLength(), u"");
1230
1231 if ( aLangText == "LANGUAGE_NONE" )
1232 {
1233 eLang = LANGUAGE_NONE;
1234 rDoc.SetLanguage( eLang, eCjk, eCtl );
1235 }
1236 else if ( aLangText == "RESET_LANGUAGES" )
1237 {
1238 bool bAutoSpell;
1239
1240 ScModule::GetSpellSettings(eLang, eCjk, eCtl, bAutoSpell);
1241 rDoc.SetLanguage(eLang, eCjk, eCtl);
1242 }
1243 else
1244 {
1245 eLang = SvtLanguageTable::GetLanguageType( aLangText );
1246 if ( eLang != LANGUAGE_DONTKNOW && SvtLanguageOptions::GetScriptTypeOfLanguage(eLang) == SvtScriptType::LATIN )
1247 {
1248 rDoc.SetLanguage( eLang, eCjk, eCtl );
1249 }
1250 else
1251 {
1252 eLang = eLatin;
1253 }
1254 }
1255 }
1256 else if (-1 != (nPos = aLangText.indexOf( aSelectionLangPrefix )))
1257 {
1258 bSelection = true;
1259 aLangText = aLangText.replaceAt( nPos, aSelectionLangPrefix.getLength(), u"" );
1260 }
1261 else if (-1 != (nPos = aLangText.indexOf( aParagraphLangPrefix )))
1262 {
1263 bParagraph = true;
1264 aLangText = aLangText.replaceAt( nPos, aParagraphLangPrefix.getLength(), u"" );
1265 }
1266
1267 if (bSelection || bParagraph)
1268 {
1269 ScViewData* pViewData = GetViewData();
1270 if (!pViewData)
1271 return;
1272
1273 EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
1274 if (!pEditView)
1275 return;
1276
1277 const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aLangText );
1279
1280 SfxItemSet aAttrs = pEditView->GetEditEngine()->GetEmptyItemSet();
1281 if (nScriptType == SvtScriptType::LATIN)
1282 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
1283 if (nScriptType == SvtScriptType::COMPLEX)
1284 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
1285 if (nScriptType == SvtScriptType::ASIAN)
1286 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
1287 ESelection aOldSel;
1288 if (bParagraph)
1289 {
1290 ESelection aSel = pEditView->GetSelection();
1291 aOldSel = aSel;
1292 aSel.nStartPos = 0;
1293 aSel.nEndPos = EE_TEXTPOS_ALL;
1294 pEditView->SetSelection( aSel );
1295 }
1296
1297 pEditView->SetAttribs( aAttrs );
1298 if (bParagraph)
1299 pEditView->SetSelection( aOldSel );
1300 }
1301 else if ( eLang != eLatin )
1302 {
1304 {
1305 ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewSh);
1306 if ( pInputHandler )
1307 pInputHandler->UpdateSpellSettings();
1308
1309 pViewSh->UpdateDrawTextOutliner();
1310 }
1311
1313 Broadcast(SfxHint(SfxHintId::LanguageChanged));
1315 }
1316 }
1317 }
1318 break;
1319 case SID_SPELLCHECK_IGNORE_ALL:
1320 {
1321 ScViewData* pViewData = GetViewData();
1322 if (!pViewData)
1323 return;
1324
1325 EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
1326 if (!pEditView)
1327 return;
1328
1329 OUString sIgnoreText;
1330 const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
1331 if (pItem2)
1332 sIgnoreText = pItem2->GetValue();
1333
1334 if(sIgnoreText == "Spelling")
1335 {
1336 ESelection aOldSel = pEditView->GetSelection();
1337 pEditView->SpellIgnoreWord();
1338 pEditView->SetSelection( aOldSel );
1339 }
1340 }
1341 break;
1342 case SID_SPELLCHECK_APPLY_SUGGESTION:
1343 {
1344 ScViewData* pViewData = GetViewData();
1345 if (!pViewData)
1346 return;
1347
1348 EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
1349 if (!pEditView)
1350 return;
1351
1352 OUString sApplyText;
1353 const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
1354 if (pItem2)
1355 sApplyText = pItem2->GetValue();
1356
1357 static const OUStringLiteral sSpellingRule(u"Spelling_");
1358 sal_Int32 nPos = 0;
1359 if(-1 != (nPos = sApplyText.indexOf( sSpellingRule )))
1360 {
1361 sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), u"");
1362 pEditView->InsertText( sApplyText );
1363 }
1364 }
1365 break;
1366 case SID_REFRESH_VIEW:
1367 {
1369 }
1370 break;
1371 default:
1372 {
1373 // small (?) hack -> forwarding of the slots to TabViewShell
1375 if ( pSh )
1376 pSh->Execute( rReq );
1377#if HAVE_FEATURE_SCRIPTING
1378 else
1380#endif
1381 }
1382 }
1383}
1384
1386{
1387 // update "accept changes" dialog
1389 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1390 if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) )
1391 {
1392 SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT );
1393 if ( pChild )
1394 static_cast<ScAcceptChgDlgWrapper*>(pChild)->ReInitDlg();
1395 }
1396}
1397
1398bool ScDocShell::ExecuteChangeProtectionDialog( bool bJustQueryIfProtected )
1399{
1400 bool bDone = false;
1401 ScChangeTrack* pChangeTrack = m_pDocument->GetChangeTrack();
1402 if ( pChangeTrack )
1403 {
1404 bool bProtected = pChangeTrack->IsProtected();
1405 if ( bJustQueryIfProtected && !bProtected )
1406 return true;
1407
1408 OUString aTitle( ScResId( bProtected ? SCSTR_CHG_UNPROTECT : SCSTR_CHG_PROTECT ) );
1409 OUString aText( ScResId( SCSTR_PASSWORD ) );
1410 OUString aPassword;
1411
1413 SfxPasswordDialog aDlg(pWin, &aText);
1414 aDlg.set_title(aTitle);
1415 aDlg.SetMinLen(1);
1416 aDlg.set_help_id(GetStaticInterface()->GetSlot(SID_CHG_PROTECT)->GetCommand());
1418 if ( !bProtected )
1419 aDlg.ShowExtras(SfxShowExtras::CONFIRM);
1420 if (aDlg.run() == RET_OK)
1421 aPassword = aDlg.GetPassword();
1422
1423 if (!aPassword.isEmpty())
1424 {
1425 if ( bProtected )
1426 {
1427 if ( SvPasswordHelper::CompareHashPassword(pChangeTrack->GetProtection(), aPassword) )
1428 {
1429 if ( bJustQueryIfProtected )
1430 bDone = true;
1431 else
1432 pChangeTrack->SetProtection( {} );
1433 }
1434 else
1435 {
1436 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin,
1437 VclMessageType::Info, VclButtonsType::Ok,
1438 ScResId(SCSTR_WRONGPASSWORD)));
1439 xInfoBox->run();
1440 }
1441 }
1442 else
1443 {
1444 css::uno::Sequence< sal_Int8 > aPass;
1445 SvPasswordHelper::GetHashPassword( aPass, aPassword );
1446 pChangeTrack->SetProtection( aPass );
1447 }
1448 if ( bProtected != pChangeTrack->IsProtected() )
1449 {
1451 bDone = true;
1452 }
1453 }
1454 }
1455 else if ( bJustQueryIfProtected )
1456 bDone = true;
1457 return bDone;
1458}
1459
1460void ScDocShell::DoRecalc( bool bApi )
1461{
1462 if (m_pDocument->IsInDocShellRecalc())
1463 {
1464 SAL_WARN("sc","ScDocShell::DoRecalc tries re-entering while in Recalc; probably Forms->BASIC->Dispatcher.");
1465 return;
1466 }
1468 bool bDone = false;
1470 ScInputHandler* pHdl = ( pSh ? SC_MOD()->GetInputHdl( pSh ) : nullptr );
1471 if ( pSh )
1472 {
1473 if ( pHdl && pHdl->IsInputMode() && pHdl->IsFormulaMode() && !bApi )
1474 {
1475 pHdl->FormulaPreview(); // partial result as QuickHelp
1476 bDone = true;
1477 }
1478 else
1479 {
1480 ScTabView::UpdateInputLine(); // InputEnterHandler
1481 pSh->UpdateInputHandler();
1482 }
1483 }
1484 if (bDone) // otherwise re-calculate document
1485 return;
1486
1488 if ( pHdl )
1489 {
1490 // tdf97897 set current cell to Dirty to force recalculation of cell
1491 ScFormulaCell* pFC = m_pDocument->GetFormulaCell( pHdl->GetCursorPos());
1492 if (pFC)
1493 pFC->SetDirty();
1494 }
1495 m_pDocument->CalcFormulaTree();
1496 if ( pSh )
1497 pSh->UpdateCharts(true);
1498
1499 m_pDocument->BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
1500
1501 // If there are charts, then paint everything, so that PostDataChanged
1502 // and the charts do not come one after the other and parts are painted twice.
1503
1504 ScChartListenerCollection* pCharts = m_pDocument->GetChartListenerCollection();
1505 if ( pCharts && pCharts->hasListeners() )
1507 else
1509}
1510
1512{
1513 if (m_pDocument->IsInDocShellRecalc())
1514 {
1515 SAL_WARN("sc","ScDocShell::DoHardRecalc tries re-entering while in Recalc; probably Forms->BASIC->Dispatcher.");
1516 return;
1517 }
1518 auto start = std::chrono::steady_clock::now();
1522 if ( pSh )
1523 {
1524 ScTabView::UpdateInputLine(); // InputEnterHandler
1525 pSh->UpdateInputHandler();
1526 }
1527 m_pDocument->CalcAll();
1528 GetDocFunc().DetectiveRefresh(); // creates own Undo
1529 if ( pSh )
1530 pSh->UpdateCharts(true);
1531
1532 // set notification flags for "calculate" event (used in SfxHintId::DataChanged broadcast)
1533 // (might check for the presence of any formulas on each sheet)
1534 SCTAB nTabCount = m_pDocument->GetTableCount();
1535 if (m_pDocument->HasAnySheetEventScript( ScSheetEventId::CALCULATE, true )) // search also for VBA handler
1536 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1537 m_pDocument->SetCalcNotification(nTab);
1538
1539 // CalcAll doesn't broadcast value changes, so SfxHintId::ScCalcAll is broadcasted globally
1540 // in addition to SfxHintId::DataChanged.
1541 m_pDocument->BroadcastUno( SfxHint( SfxHintId::ScCalcAll ) );
1542 m_pDocument->BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
1543
1544 // use hard recalc also to disable stream-copying of all sheets
1545 // (somewhat consistent with charts)
1546 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1547 m_pDocument->SetStreamValid(nTab, false);
1548
1550 auto end = std::chrono::steady_clock::now();
1551 SAL_INFO("sc.timing", "ScDocShell::DoHardRecalc(): took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms");
1552}
1553
1554void ScDocShell::DoAutoStyle( const ScRange& rRange, const OUString& rStyle )
1555{
1556 ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
1557 ScStyleSheet* pStyleSheet =
1558 pStylePool->FindCaseIns( rStyle, SfxStyleFamily::Para );
1559 if (!pStyleSheet)
1560 pStyleSheet = static_cast<ScStyleSheet*>(
1561 pStylePool->Find( ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para ));
1562 if (!pStyleSheet)
1563 return;
1564
1565 OSL_ENSURE(rRange.aStart.Tab() == rRange.aEnd.Tab(),
1566 "DoAutoStyle with several tables");
1567 SCTAB nTab = rRange.aStart.Tab();
1568 SCCOL nStartCol = rRange.aStart.Col();
1569 SCROW nStartRow = rRange.aStart.Row();
1570 SCCOL nEndCol = rRange.aEnd.Col();
1571 SCROW nEndRow = rRange.aEnd.Row();
1572 m_pDocument->ApplyStyleAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, *pStyleSheet );
1573 m_pDocument->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
1574 PostPaint( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, PaintPartFlags::Grid );
1575}
1576
1578{
1579 SfxHintId nId = rHint.GetId();
1580 const SfxStyleSheetBase* pStyle = rHint.GetStyleSheet();
1581 if (!pStyle)
1582 return;
1583
1584 if ( pStyle->GetFamily() == SfxStyleFamily::Page )
1585 {
1586 if ( nId == SfxHintId::StyleSheetModified )
1587 {
1588 ScDocShellModificator aModificator( *this );
1589
1590 const OUString& aNewName = pStyle->GetName();
1591 OUString aOldName = aNewName;
1592 const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint); // name changed?
1593 if (pExtendedHint)
1594 aOldName = pExtendedHint->GetOldName();
1595
1596 if ( aNewName != aOldName )
1597 m_pDocument->RenamePageStyleInUse( aOldName, aNewName );
1598
1599 SCTAB nTabCount = m_pDocument->GetTableCount();
1600 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1601 if (m_pDocument->GetPageStyle(nTab) == aNewName) // already adjusted to new
1602 {
1603 m_pDocument->PageStyleModified( nTab, aNewName );
1604 ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
1605 aPrintFunc.UpdatePages();
1606 }
1607
1608 aModificator.SetDocumentModified();
1609
1610 if (pExtendedHint)
1611 {
1612 SfxBindings* pBindings = GetViewBindings();
1613 if (pBindings)
1614 {
1615 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
1616 pBindings->Invalidate( SID_STYLE_FAMILY4 );
1617 pBindings->Invalidate( FID_RESET_PRINTZOOM );
1618 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
1619 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
1620 }
1621 }
1622 }
1623 }
1624 else if ( pStyle->GetFamily() == SfxStyleFamily::Para )
1625 {
1626 if ( nId == SfxHintId::StyleSheetModified)
1627 {
1628 const OUString& aNewName = pStyle->GetName();
1629 OUString aOldName = aNewName;
1630 const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint);
1631 if (pExtendedHint)
1632 aOldName = pExtendedHint->GetOldName();
1633 if ( aNewName != aOldName )
1634 {
1635 for(SCTAB i = 0; i < m_pDocument->GetTableCount(); ++i)
1636 {
1637 ScConditionalFormatList* pList = m_pDocument->GetCondFormList(i);
1638 if (pList)
1639 pList->RenameCellStyle( aOldName,aNewName );
1640 }
1641 }
1642 }
1643 }
1644
1645 // everything else goes via slots...
1646}
1647
1648// like in printfun.cxx
1649#define ZOOM_MIN 10
1650
1651void ScDocShell::SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages )
1652{
1653 OUString aStyleName = m_pDocument->GetPageStyle( nTab );
1654 ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
1655 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page );
1656 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
1657 if ( !pStyleSheet )
1658 return;
1659
1660 ScDocShellModificator aModificator( *this );
1661
1662 SfxItemSet& rSet = pStyleSheet->GetItemSet();
1663 const bool bUndo(m_pDocument->IsUndoEnabled());
1664 if (bUndo)
1665 {
1666 sal_uInt16 nOldScale = rSet.Get(ATTR_PAGE_SCALE).GetValue();
1667 sal_uInt16 nOldPages = rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue();
1668 GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPrintZoom>(
1669 this, nTab, nOldScale, nOldPages, nScale, nPages ) );
1670 }
1671
1672 rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
1674
1675 ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
1676 aPrintFunc.UpdatePages();
1677 aModificator.SetDocumentModified();
1678
1679 SfxBindings* pBindings = GetViewBindings();
1680 if (pBindings)
1681 pBindings->Invalidate( FID_RESET_PRINTZOOM );
1682}
1683
1685{
1686 bool bChange = false;
1687 SCTAB nTab = rRange.aStart.Tab();
1688
1689 OUString aStyleName = m_pDocument->GetPageStyle( nTab );
1690 ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
1691 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page );
1692 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
1693 if ( pStyleSheet )
1694 {
1695 SfxItemSet& rSet = pStyleSheet->GetItemSet();
1696 bool bHeaders = rSet.Get(ATTR_PAGE_HEADERS).GetValue();
1697 sal_uInt16 nOldScale = rSet.Get(ATTR_PAGE_SCALE).GetValue();
1698 sal_uInt16 nOldPages = rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue();
1699 std::optional<ScRange> oRepeatCol = m_pDocument->GetRepeatColRange( nTab );
1700 std::optional<ScRange> oRepeatRow = m_pDocument->GetRepeatRowRange( nTab );
1701
1702 // calculate needed scaling for selection
1703
1704 sal_uInt16 nNewScale = nOldScale;
1705
1706 tools::Long nBlkTwipsX = 0;
1707 if (bHeaders)
1708 nBlkTwipsX += PRINT_HEADER_WIDTH;
1709 SCCOL nStartCol = rRange.aStart.Col();
1710 SCCOL nEndCol = rRange.aEnd.Col();
1711 if ( oRepeatCol && nStartCol >= oRepeatCol->aStart.Col() )
1712 {
1713 for (SCCOL i=oRepeatCol->aStart.Col(); i<=oRepeatCol->aEnd.Col(); i++ )
1714 nBlkTwipsX += m_pDocument->GetColWidth( i, nTab );
1715 if ( nStartCol <= oRepeatCol->aEnd.Col() )
1716 nStartCol = oRepeatCol->aEnd.Col() + 1;
1717 }
1718 // legacy compilers' own scope for i
1719 {
1720 for ( SCCOL i=nStartCol; i<=nEndCol; i++ )
1721 nBlkTwipsX += m_pDocument->GetColWidth( i, nTab );
1722 }
1723
1724 tools::Long nBlkTwipsY = 0;
1725 if (bHeaders)
1726 nBlkTwipsY += PRINT_HEADER_HEIGHT;
1727 SCROW nStartRow = rRange.aStart.Row();
1728 SCROW nEndRow = rRange.aEnd.Row();
1729 if ( oRepeatRow && nStartRow >= oRepeatRow->aStart.Row() )
1730 {
1731 nBlkTwipsY += m_pDocument->GetRowHeight( oRepeatRow->aStart.Row(),
1732 oRepeatRow->aEnd.Row(), nTab );
1733 if ( nStartRow <= oRepeatRow->aEnd.Row() )
1734 nStartRow = oRepeatRow->aEnd.Row() + 1;
1735 }
1736 nBlkTwipsY += m_pDocument->GetRowHeight( nStartRow, nEndRow, nTab );
1737
1738 Size aPhysPage;
1739 tools::Long nHdr, nFtr;
1740 ScPrintFunc aOldPrFunc( this, GetPrinter(), nTab );
1741 aOldPrFunc.GetScaleData( aPhysPage, nHdr, nFtr );
1742 nBlkTwipsY += nHdr + nFtr;
1743
1744 if ( nBlkTwipsX == 0 ) // hidden columns/rows may lead to 0
1745 nBlkTwipsX = 1;
1746 if ( nBlkTwipsY == 0 )
1747 nBlkTwipsY = 1;
1748
1749 tools::Long nNeeded = std::min( aPhysPage.Width() * 100 / nBlkTwipsX,
1750 aPhysPage.Height() * 100 / nBlkTwipsY );
1751 if ( nNeeded < ZOOM_MIN )
1752 nNeeded = ZOOM_MIN; // boundary
1753 if ( nNeeded < static_cast<tools::Long>(nNewScale) )
1754 nNewScale = static_cast<sal_uInt16>(nNeeded);
1755
1756 bChange = ( nNewScale != nOldScale || nOldPages != 0 );
1757 if ( bChange )
1758 SetPrintZoom( nTab, nNewScale, 0 );
1759 }
1760 return bChange;
1761}
1762
1763void ScDocShell::PageStyleModified( std::u16string_view rStyleName, bool bApi )
1764{
1765 ScDocShellModificator aModificator( *this );
1766
1767 SCTAB nTabCount = m_pDocument->GetTableCount();
1768 SCTAB nUseTab = MAXTAB+1;
1769 for (SCTAB nTab=0; nTab<nTabCount && nUseTab>MAXTAB; nTab++)
1770 if ( m_pDocument->GetPageStyle(nTab) == rStyleName &&
1771 ( !bApi || m_pDocument->GetPageSize(nTab).Width() ) )
1772 nUseTab = nTab;
1773 // at bApi only if breaks already shown
1774
1775 if (ValidTab(nUseTab)) // not used -> nothing to do
1776 {
1777 bool bWarn = false;
1778
1779 ScPrintFunc aPrintFunc( this, GetPrinter(), nUseTab );
1780 if (!aPrintFunc.UpdatePages()) // sets breaks on all tabs
1781 bWarn = true;
1782
1783 if (bWarn && !bApi)
1784 {
1786 weld::WaitObject aWaitOff(pWin);
1787 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin,
1788 VclMessageType::Info, VclButtonsType::Ok,
1789 ScResId(STR_PRINT_INVALID_AREA)));
1790 xInfoBox->run();
1791 }
1792 }
1793
1794 aModificator.SetDocumentModified();
1795
1796 SfxBindings* pBindings = GetViewBindings();
1797 if (pBindings)
1798 {
1799 pBindings->Invalidate( FID_RESET_PRINTZOOM );
1800 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
1801 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
1802 }
1803}
1804
1806 SfxRequest& rReq,
1807 SCTAB nCurTab )
1808{
1809 const SfxItemSet* pReqArgs = rReq.GetArgs();
1810
1811 switch ( rReq.GetSlot() )
1812 {
1813 case SID_STATUS_PAGESTYLE: // click on StatusBar control
1814 case SID_FORMATPAGE:
1815 {
1816 if ( pReqArgs == nullptr )
1817 {
1818 OUString aOldName = m_pDocument->GetPageStyle( nCurTab );
1819 ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
1820 SfxStyleSheetBase* pStyleSheet
1821 = pStylePool->Find( aOldName, SfxStyleFamily::Page );
1822
1823 OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
1824
1825 if ( pStyleSheet )
1826 {
1827 ScStyleSaveData aOldData;
1828 const bool bUndo(m_pDocument->IsUndoEnabled());
1829 if (bUndo)
1830 aOldData.InitFromStyle( pStyleSheet );
1831
1832 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1834
1836
1837 VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScStyleDlg(GetActiveDialogParent(), *pStyleSheet, true));
1838
1839 auto pRequest = std::make_shared<SfxRequest>(rReq);
1840 rReq.Ignore(); // the 'old' request is not relevant any more
1841 pDlg->StartExecuteAsync([this, pDlg, pRequest, pStyleSheet, aOldData, aOldName, &rStyleSet, nCurTab, &rCaller, bUndo](sal_Int32 nResult){
1842 if ( nResult == RET_OK )
1843 {
1844 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1845
1847
1848 OUString aNewName = pStyleSheet->GetName();
1849 if ( aNewName != aOldName &&
1850 m_pDocument->RenamePageStyleInUse( aOldName, aNewName ) )
1851 {
1852 SfxBindings* pBindings = GetViewBindings();
1853 if (pBindings)
1854 {
1855 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
1856 pBindings->Invalidate( FID_RESET_PRINTZOOM );
1857 }
1858 }
1859
1860 if ( pOutSet )
1861 m_pDocument->ModifyStyleSheet( *pStyleSheet, *pOutSet );
1862
1863 // memorizing for GetState():
1864 GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, m_bHeaderOn, m_bFooterOn );
1865 rCaller.GetViewFrame()->GetBindings().Invalidate( SID_HFEDIT );
1866
1867 ScStyleSaveData aNewData;
1868 aNewData.InitFromStyle( pStyleSheet );
1869 if (bUndo)
1870 {
1872 std::make_unique<ScUndoModifyStyle>( this, SfxStyleFamily::Page,
1873 aOldData, aNewData ) );
1874 }
1875
1876 PageStyleModified( aNewName, false );
1877 pRequest->Done();
1878 }
1879 pDlg->disposeOnce();
1880 });
1881 }
1882 }
1883 }
1884 break;
1885
1886 case SID_HFEDIT:
1887 {
1888 if ( pReqArgs == nullptr )
1889 {
1890 OUString aStr( m_pDocument->GetPageStyle( nCurTab ) );
1891
1892 ScStyleSheetPool* pStylePool
1893 = m_pDocument->GetStyleSheetPool();
1894
1895 SfxStyleSheetBase* pStyleSheet
1896 = pStylePool->Find( aStr, SfxStyleFamily::Page );
1897
1898 OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
1899
1900 if ( pStyleSheet )
1901 {
1902 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1903
1904 SvxPageUsage eUsage = rStyleSet.Get( ATTR_PAGE ).GetPageUsage();
1905 bool bShareHeader = rStyleSet
1907 .GetItemSet()
1908 .Get(ATTR_PAGE_SHARED)
1909 .GetValue();
1910 bool bShareFooter = rStyleSet
1912 .GetItemSet()
1913 .Get(ATTR_PAGE_SHARED)
1914 .GetValue();
1915 sal_uInt16 nResId = 0;
1916
1917 switch ( eUsage )
1918 {
1919 case SvxPageUsage::Left:
1920 case SvxPageUsage::Right:
1921 {
1922 if ( m_bHeaderOn && m_bFooterOn )
1923 nResId = RID_SCDLG_HFEDIT;
1924 else if ( SvxPageUsage::Right == eUsage )
1925 {
1926 if ( !m_bHeaderOn && m_bFooterOn )
1927 nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
1928 else if ( m_bHeaderOn && !m_bFooterOn )
1929 nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
1930 }
1931 else
1932 {
1933 // #69193a# respect "shared" setting
1934 if ( !m_bHeaderOn && m_bFooterOn )
1935 nResId = bShareFooter ?
1936 RID_SCDLG_HFEDIT_RIGHTFOOTER :
1937 RID_SCDLG_HFEDIT_LEFTFOOTER;
1938 else if ( m_bHeaderOn && !m_bFooterOn )
1939 nResId = bShareHeader ?
1940 RID_SCDLG_HFEDIT_RIGHTHEADER :
1941 RID_SCDLG_HFEDIT_LEFTHEADER;
1942 }
1943 }
1944 break;
1945
1946 case SvxPageUsage::Mirror:
1947 case SvxPageUsage::All:
1948 default:
1949 {
1950 if ( !bShareHeader && !bShareFooter )
1951 {
1952 if ( m_bHeaderOn && m_bFooterOn )
1953 nResId = RID_SCDLG_HFEDIT_ALL;
1954 else if ( !m_bHeaderOn && m_bFooterOn )
1955 nResId = RID_SCDLG_HFEDIT_FOOTER;
1956 else if ( m_bHeaderOn && !m_bFooterOn )
1957 nResId = RID_SCDLG_HFEDIT_HEADER;
1958 }
1959 else if ( bShareHeader && bShareFooter )
1960 {
1961 if ( m_bHeaderOn && m_bFooterOn )
1962 nResId = RID_SCDLG_HFEDIT;
1963 else
1964 {
1965 if ( !m_bHeaderOn && m_bFooterOn )
1966 nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
1967 else if ( m_bHeaderOn && !m_bFooterOn )
1968 nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
1969 }
1970 }
1971 else if ( !bShareHeader && bShareFooter )
1972 {
1973 if ( m_bHeaderOn && m_bFooterOn )
1974 nResId = RID_SCDLG_HFEDIT_SFTR;
1975 else if ( !m_bHeaderOn && m_bFooterOn )
1976 nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
1977 else if ( m_bHeaderOn && !m_bFooterOn )
1978 nResId = RID_SCDLG_HFEDIT_HEADER;
1979 }
1980 else if ( bShareHeader && !bShareFooter )
1981 {
1982 if ( m_bHeaderOn && m_bFooterOn )
1983 nResId = RID_SCDLG_HFEDIT_SHDR;
1984 else if ( !m_bHeaderOn && m_bFooterOn )
1985 nResId = RID_SCDLG_HFEDIT_FOOTER;
1986 else if ( m_bHeaderOn && !m_bFooterOn )
1987 nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
1988 }
1989 }
1990 }
1991
1993
1996 rStyleSet,
1997 aStr,
1998 nResId));
1999 auto xRequest = std::make_shared<SfxRequest>(rReq);
2000 rReq.Ignore(); // the 'old' request is not relevant any more
2001 pDlg->StartExecuteAsync([this, pDlg, pStyleSheet, xRequest](sal_Int32 nResult){
2002 if ( nResult == RET_OK )
2003 {
2004 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
2005
2006 if ( pOutSet )
2007 m_pDocument->ModifyStyleSheet( *pStyleSheet, *pOutSet );
2008
2010 xRequest->Done();
2011 }
2012 pDlg->disposeOnce();
2013 });
2014 }
2015 }
2016 }
2017 break;
2018
2019 default:
2020 break;
2021 }
2022}
2023
2025 SCTAB nCurTab )
2026{
2027 SfxWhichIter aIter(rSet);
2028 sal_uInt16 nWhich = aIter.FirstWhich();
2029 while ( nWhich )
2030 {
2031 switch (nWhich)
2032 {
2033 case SID_STATUS_PAGESTYLE:
2034 rSet.Put( SfxStringItem( nWhich, m_pDocument->GetPageStyle( nCurTab ) ) );
2035 break;
2036
2037 case SID_HFEDIT:
2038 {
2039 OUString aStr = m_pDocument->GetPageStyle( nCurTab );
2040 ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
2041 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStr, SfxStyleFamily::Page );
2042
2043 OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
2044
2045 if ( pStyleSheet )
2046 {
2047 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
2048 GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, m_bHeaderOn, m_bFooterOn );
2049
2050 if ( !m_bHeaderOn && !m_bFooterOn )
2051 rSet.DisableItem( nWhich );
2052 }
2053 }
2054 break;
2055 }
2056
2057 nWhich = aIter.NextWhich();
2058 }
2059}
2060
2062{
2063 bool bTabView = GetBestViewShell() != nullptr;
2064
2065 SfxWhichIter aIter(rSet);
2066 for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich())
2067 {
2068 if (!bTabView)
2069 {
2070 rSet.DisableItem(nWhich);
2071 continue;
2072 }
2073
2074 switch (nWhich)
2075 {
2076 case FID_AUTO_CALC:
2077 if ( m_pDocument->GetHardRecalcState() != ScDocument::HardRecalcState::OFF )
2078 rSet.DisableItem( nWhich );
2079 else
2080 rSet.Put( SfxBoolItem( nWhich, m_pDocument->GetAutoCalc() ) );
2081 break;
2082
2083 case FID_CHG_RECORD:
2084 if ( IsDocShared() )
2085 rSet.DisableItem( nWhich );
2086 else
2087 rSet.Put( SfxBoolItem( nWhich,
2088 m_pDocument->GetChangeTrack() != nullptr ) );
2089 break;
2090
2091 case SID_CHG_PROTECT:
2092 {
2093 ScChangeTrack* pChangeTrack = m_pDocument->GetChangeTrack();
2094 if ( pChangeTrack && !IsDocShared() )
2095 rSet.Put( SfxBoolItem( nWhich,
2096 pChangeTrack->IsProtected() ) );
2097 else
2098 rSet.DisableItem( nWhich );
2099 }
2100 break;
2101
2102 case SID_DOCUMENT_COMPARE:
2103 {
2104 if ( IsDocShared() )
2105 {
2106 rSet.DisableItem( nWhich );
2107 }
2108 }
2109 break;
2110
2111 // When a formula is edited, FID_RECALC must be enabled in any case. Recalc for
2112 // the doc was disabled once because of a bug if AutoCalc was on, but is now
2113 // always enabled because of another bug.
2114
2115 case SID_TABLES_COUNT:
2116 rSet.Put( SfxInt16Item( nWhich, m_pDocument->GetTableCount() ) );
2117 break;
2118
2119 case SID_ATTR_YEAR2000 :
2120 rSet.Put( SfxUInt16Item( nWhich,
2121 m_pDocument->GetDocOptions().GetYear2000() ) );
2122 break;
2123
2124 case SID_SHARE_DOC:
2125 {
2127 {
2128 rSet.DisableItem( nWhich );
2129 }
2130 }
2131 break;
2132
2133 case SID_ATTR_CHAR_FONTLIST:
2134 rSet.Put( SvxFontListItem( m_pImpl->pFontList.get(), nWhich ) );
2135 break;
2136
2137 case SID_NOTEBOOKBAR:
2138 {
2139 if (GetViewBindings())
2140 {
2142 u"modules/scalc/ui/");
2143 rSet.Put( SfxBoolItem( SID_NOTEBOOKBAR, bVisible ) );
2144 }
2145 }
2146 break;
2147
2148 case SID_LANGUAGE_STATUS:
2149 {
2150 LanguageType eLatin, eCjk, eCtl;
2151
2152 GetDocument().GetLanguage( eLatin, eCjk, eCtl );
2153 OUString sLanguage = SvtLanguageTable::GetLanguageString(eLatin);
2155 if (eLatin == LANGUAGE_NONE)
2156 sLanguage += ";-";
2157 else
2158 sLanguage += ";" + LanguageTag(eLatin).getBcp47(false);
2159 }
2160 rSet.Put(SfxStringItem(nWhich, sLanguage));
2161 }
2162 break;
2163
2164 default:
2165 {
2166 }
2167 break;
2168 }
2169 }
2170}
2171
2172void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uInt16 nAspect )
2173{
2174
2175 SCTAB nVisTab = m_pDocument->GetVisibleTab();
2176 if (!m_pDocument->HasTable(nVisTab))
2177 return;
2178
2179 vcl::text::ComplexTextLayoutFlags nOldLayoutMode = pDev->GetLayoutMode();
2180 pDev->SetLayoutMode( vcl::text::ComplexTextLayoutFlags::Default ); // even if it's the same, to get the metafile action
2181
2182 if ( nAspect == ASPECT_THUMBNAIL )
2183 {
2185 ScViewData aTmpData( *this, nullptr );
2186 aTmpData.SetTabNo(nVisTab);
2187 SnapVisArea( aBoundRect );
2188 aTmpData.SetScreen( aBoundRect );
2189 ScPrintFunc::DrawToDev( *m_pDocument, pDev, 1.0, aBoundRect, &aTmpData, true );
2190 }
2191 else
2192 {
2194 tools::Rectangle aNewArea = aOldArea;
2195 ScViewData aTmpData( *this, nullptr );
2196 aTmpData.SetTabNo(nVisTab);
2197 SnapVisArea( aNewArea );
2198 if ( aNewArea != aOldArea && (m_pDocument->GetPosLeft() > 0 || m_pDocument->GetPosTop() > 0) )
2199 SfxObjectShell::SetVisArea( aNewArea );
2200 aTmpData.SetScreen( aNewArea );
2201 ScPrintFunc::DrawToDev( *m_pDocument, pDev, 1.0, aNewArea, &aTmpData, true );
2202 }
2203
2204 pDev->SetLayoutMode( nOldLayoutMode );
2205}
2206
2207tools::Rectangle ScDocShell::GetVisArea( sal_uInt16 nAspect ) const
2208{
2209 SfxObjectCreateMode eShellMode = GetCreateMode();
2210 if ( eShellMode == SfxObjectCreateMode::ORGANIZER )
2211 {
2212 // without contents we also don't know how large are the contents;
2213 // return empty rectangle, it will then be calculated after the loading
2214 return tools::Rectangle();
2215 }
2216
2217 if( nAspect == ASPECT_THUMBNAIL )
2218 {
2219 SCTAB nVisTab = m_pDocument->GetVisibleTab();
2220 if (!m_pDocument->HasTable(nVisTab))
2221 {
2222 nVisTab = 0;
2223 const_cast<ScDocShell*>(this)->m_pDocument->SetVisibleTab(nVisTab);
2224 }
2225 Size aSize = m_pDocument->GetPageSize(nVisTab);
2226 const tools::Long SC_PREVIEW_SIZE_X = 10000;
2227 const tools::Long SC_PREVIEW_SIZE_Y = 12400;
2228 tools::Rectangle aArea( 0,0, SC_PREVIEW_SIZE_X, SC_PREVIEW_SIZE_Y);
2229 if (aSize.Width() > aSize.Height())
2230 {
2231 aArea.SetRight( SC_PREVIEW_SIZE_Y );
2232 aArea.SetBottom( SC_PREVIEW_SIZE_X );
2233 }
2234
2235 bool bNegativePage = m_pDocument->IsNegativePage( m_pDocument->GetVisibleTab() );
2236 if ( bNegativePage )
2238 SnapVisArea( aArea );
2239 return aArea;
2240 }
2241 else if( nAspect == ASPECT_CONTENT && eShellMode != SfxObjectCreateMode::EMBEDDED )
2242 {
2243 // fetch visarea like after loading
2244
2245 SCTAB nVisTab = m_pDocument->GetVisibleTab();
2246 if (!m_pDocument->HasTable(nVisTab))
2247 {
2248 nVisTab = 0;
2249 const_cast<ScDocShell*>(this)->m_pDocument->SetVisibleTab(nVisTab);
2250 }
2251 SCCOL nStartCol;
2252 SCROW nStartRow;
2253 m_pDocument->GetDataStart( nVisTab, nStartCol, nStartRow );
2254 SCCOL nEndCol;
2255 SCROW nEndRow;
2256 m_pDocument->GetPrintArea( nVisTab, nEndCol, nEndRow );
2257 if (nStartCol>nEndCol)
2258 nStartCol = nEndCol;
2259 if (nStartRow>nEndRow)
2260 nStartRow = nEndRow;
2261 tools::Rectangle aNewArea = m_pDocument
2262 ->GetMMRect( nStartCol,nStartRow, nEndCol,nEndRow, nVisTab );
2263 return aNewArea;
2264 }
2265 else
2266 return SfxObjectShell::GetVisArea( nAspect );
2267}
2268
2269namespace {
2270
2271[[nodiscard]]
2272tools::Long SnapHorizontal( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal, SCCOL& rStartCol )
2273{
2274 SCCOL nCol = 0;
2276 tools::Long nSnap = 0;
2277 while ( nCol<rDoc.MaxCol() )
2278 {
2279 tools::Long nAdd = rDoc.GetColWidth(nCol, nTab);
2280 if ( nSnap + nAdd/2 < nTwips || nCol < rStartCol )
2281 {
2282 nSnap += nAdd;
2283 ++nCol;
2284 }
2285 else
2286 break;
2287 }
2289 rStartCol = nCol;
2290 return nVal;
2291}
2292
2293[[nodiscard]]
2294tools::Long SnapVertical( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal, SCROW& rStartRow )
2295{
2296 SCROW nRow = 0;
2298 tools::Long nSnap = 0;
2299
2300 bool bFound = false;
2301 for (SCROW i = nRow; i <= rDoc.MaxRow(); ++i)
2302 {
2303 SCROW nLastRow;
2304 if (rDoc.RowHidden(i, nTab, nullptr, &nLastRow))
2305 {
2306 i = nLastRow;
2307 continue;
2308 }
2309
2310 nRow = i;
2311 tools::Long nAdd = rDoc.GetRowHeight(i, nTab);
2312 if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow )
2313 {
2314 nSnap += nAdd;
2315 ++nRow;
2316 }
2317 else
2318 {
2319 bFound = true;
2320 break;
2321 }
2322 }
2323 if (!bFound)
2324 nRow = rDoc.MaxRow(); // all hidden down to the bottom
2325
2327 rStartRow = nRow;
2328 return nVal;
2329}
2330
2331}
2332
2334{
2335 SCTAB nTab = m_pDocument->GetVisibleTab();
2336 tools::Long nOrigTop = rRect.Top();
2337 tools::Long nOrigLeft = rRect.Left();
2338 bool bNegativePage = m_pDocument->IsNegativePage( nTab );
2339 if ( bNegativePage )
2340 ScDrawLayer::MirrorRectRTL( rRect ); // calculate with positive (LTR) values
2341
2342 SCCOL nCol = m_pDocument->GetPosLeft();
2343 tools::Long nSetLeft = SnapHorizontal( *m_pDocument, nTab, rRect.Left(), nCol );
2344 rRect.SetLeft( nSetLeft );
2345 ++nCol; // at least one column
2346 tools::Long nCorrectionLeft = (nOrigLeft == 0 && nCol > 0) ? nSetLeft : 0; // initial correction
2347 rRect.SetRight( SnapHorizontal( *m_pDocument, nTab, rRect.Right() + nCorrectionLeft, nCol ));
2348
2349 SCROW nRow = m_pDocument->GetPosTop();
2350 tools::Long nSetTop = SnapVertical( *m_pDocument, nTab, rRect.Top(), nRow );
2351 rRect.SetTop( nSetTop );
2352 ++nRow; // at least one row
2353 tools::Long nCorrectionTop = (nOrigTop == 0 && nRow > 0) ? nSetTop : 0; // initial correction
2354 rRect.SetBottom( SnapVertical( *m_pDocument, nTab, rRect.Bottom() + nCorrectionTop, nRow ));
2355
2356 if ( bNegativePage )
2357 ScDrawLayer::MirrorRectRTL( rRect ); // back to real rectangle
2358}
2359
2361 SCTAB nCurTab,
2362 bool& rbHeader,
2363 bool& rbFooter )
2364{
2365 if ( !pStyleSet )
2366 {
2367 ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
2368 SfxStyleSheetBase* pStyleSheet = pStylePool->
2369 Find( m_pDocument->GetPageStyle( nCurTab ),
2370 SfxStyleFamily::Page );
2371
2372 OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
2373
2374 if ( pStyleSheet )
2375 pStyleSet = &pStyleSheet->GetItemSet();
2376 else
2377 rbHeader = rbFooter = false;
2378 }
2379
2380 OSL_ENSURE( pStyleSet, "PageStyle-Set not found! :-(" );
2381 if (!pStyleSet)
2382 return;
2383
2384 const SvxSetItem* pSetItem = nullptr;
2385 const SfxItemSet* pSet = nullptr;
2386
2387 pSetItem = &pStyleSet->Get( ATTR_PAGE_HEADERSET );
2388 pSet = &pSetItem->GetItemSet();
2389 rbHeader = pSet->Get(ATTR_PAGE_ON).GetValue();
2390
2391 pSetItem = &pStyleSet->Get( ATTR_PAGE_FOOTERSET );
2392 pSet = &pSetItem->GetItemSet();
2393 rbFooter = pSet->Get(ATTR_PAGE_ON).GetValue();
2394}
2395
2396#if defined(_WIN32)
2397bool ScDocShell::DdeGetData( const OUString& rItem,
2398 const OUString& rMimeType,
2399 css::uno::Any & rValue )
2400{
2402 if (SotClipboardFormatId::STRING == eFormatId || SotClipboardFormatId::STRING_TSVC == eFormatId)
2403 {
2404 if( rItem.equalsIgnoreAsciiCase( "Format" ) )
2405 {
2406 OString aFmtByte(OUStringToOString(m_aDdeTextFmt,
2407 osl_getThreadTextEncoding()));
2408 rValue <<= css::uno::Sequence< sal_Int8 >(
2409 reinterpret_cast<const sal_Int8*>(aFmtByte.getStr()),
2410 aFmtByte.getLength() + 1 );
2411 return true;
2412 }
2413 ScImportExport aObj( *m_pDocument, rItem );
2414 if ( !aObj.IsRef() )
2415 return false; // invalid range
2416
2417 if( m_aDdeTextFmt[0] == 'F' )
2418 aObj.SetFormulas( true );
2419 if( m_aDdeTextFmt == "SYLK" ||
2420 m_aDdeTextFmt == "FSYLK" )
2421 {
2422 OString aData;
2423 if( aObj.ExportByteString( aData, osl_getThreadTextEncoding(),
2424 SotClipboardFormatId::SYLK ) )
2425 {
2426 rValue <<= css::uno::Sequence< sal_Int8 >(
2427 reinterpret_cast<const sal_Int8*>(aData.getStr()),
2428 aData.getLength() + 1 );
2429 return true;
2430 }
2431 else
2432 return false;
2433 }
2434 if( m_aDdeTextFmt == "CSV" ||
2435 m_aDdeTextFmt == "FCSV" )
2436 aObj.SetSeparator( ',' );
2437 aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) );
2438 return aObj.ExportData( rMimeType, rValue );
2439 }
2440
2441 ScImportExport aObj( *m_pDocument, rItem );
2442 aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) );
2443 return aObj.IsRef() && aObj.ExportData( rMimeType, rValue );
2444}
2445
2446bool ScDocShell::DdeSetData( const OUString& rItem,
2447 const OUString& rMimeType,
2448 const css::uno::Any & rValue )
2449{
2451 if (SotClipboardFormatId::STRING == eFormatId || SotClipboardFormatId::STRING_TSVC == eFormatId)
2452 {
2453 if( rItem.equalsIgnoreAsciiCase( "Format" ) )
2454 {
2455 if ( ScByteSequenceToString::GetString( m_aDdeTextFmt, rValue, osl_getThreadTextEncoding() ) )
2456 {
2457 m_aDdeTextFmt = m_aDdeTextFmt.toAsciiUpperCase();
2458 return true;
2459 }
2460 return false;
2461 }
2462 ScImportExport aObj( *m_pDocument, rItem );
2463 if( m_aDdeTextFmt[0] == 'F' )
2464 aObj.SetFormulas( true );
2465 if( m_aDdeTextFmt == "SYLK" ||
2466 m_aDdeTextFmt == "FSYLK" )
2467 {
2468 OUString aData;
2469 if ( ScByteSequenceToString::GetString( aData, rValue, osl_getThreadTextEncoding() ) )
2470 {
2471 return aObj.ImportString( aData, SotClipboardFormatId::SYLK );
2472 }
2473 return false;
2474 }
2475 if( m_aDdeTextFmt == "CSV" ||
2476 m_aDdeTextFmt == "FCSV" )
2477 aObj.SetSeparator( ',' );
2478 OSL_ENSURE( false, "Implementation is missing" );
2479 return false;
2480 }
2481 /*ScImportExport aObj( aDocument, rItem );
2482 return aObj.IsRef() && ScImportExport::ImportData( rMimeType, rValue );*/
2483 OSL_ENSURE( false, "Implementation is missing" );
2484 return false;
2485}
2486#endif
2487
2489{
2490 // only check for valid item string - range is parsed again in ScServerObject ctor
2491
2492 // named range?
2493 OUString aPos = rItem;
2494 ScRangeName* pRange = m_pDocument->GetRangeName();
2495 if( pRange )
2496 {
2497 const ScRangeData* pData = pRange->findByUpperName(ScGlobal::getCharClass().uppercase(aPos));
2498 if (pData)
2499 {
2500 if( pData->HasType( ScRangeData::Type::RefArea )
2501 || pData->HasType( ScRangeData::Type::AbsArea )
2502 || pData->HasType( ScRangeData::Type::AbsPos ) )
2503 aPos = pData->GetSymbol(); // continue with the name's contents
2504 }
2505 }
2506
2507 // Address in DDE function must be always parsed as CONV_OOO so that it
2508 // would always work regardless of current address conversion. We do this
2509 // because the address item in a DDE entry is *not* normalized when saved
2510 // into ODF.
2511 ScRange aRange;
2512 bool bValid = ( (aRange.Parse(aPos, *m_pDocument, formula::FormulaGrammar::CONV_OOO ) & ScRefFlags::VALID) ||
2514
2515 ScServerObject* pObj = nullptr; // NULL = error
2516 if ( bValid )
2517 pObj = new ScServerObject( this, rItem );
2518
2519 // GetLinkManager()->InsertServer() is in the ScServerObject ctor
2520
2521 return pObj;
2522}
2523
2525{
2526 if ( !pDocument->IsDocVisible() || // don't want callbacks until document load
2529 return;
2530
2531 boost::property_tree::ptree aAnnotation;
2532 aAnnotation.put("action", (nType == LOKCommentNotificationType::Add ? "Add" :
2534 (nType == LOKCommentNotificationType::Modify ? "Modify" : "???"))));
2535
2536 assert(pNote);
2537 aAnnotation.put("id", pNote->GetId());
2538 aAnnotation.put("tab", rPos.Tab());
2539
2541 {
2542 aAnnotation.put("author", pNote->GetAuthor());
2543 aAnnotation.put("dateTime", pNote->GetDate());
2544 aAnnotation.put("text", pNote->GetText());
2545
2546 // Calculating the cell cursor position
2547 ScViewData* pViewData = GetViewData();
2548 if (pViewData && pViewData->GetActiveWin())
2549 {
2551 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
2552 OString aRectString;
2553 if (bInPrintTwips)
2554 {
2555 Point aTopLeft = pViewData->GetPrintTwipsPos(rPos.Col(), rPos.Row());
2556 tools::Long nSizeX, nSizeY;
2557 pViewData->GetMergeSizePrintTwips(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
2558 aRectString = tools::Rectangle(aTopLeft, Size(nSizeX - 1, nSizeY - 1)).toString();
2559 }
2560 else
2561 {
2562 Point aTopLeft = pViewData->GetScrPos(rPos.Col(), rPos.Row(),
2563 pViewData->GetActivePart(), true);
2564 tools::Long nSizeXPix, nSizeYPix;
2565 pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeXPix, nSizeYPix);
2566 const double fPPTX = pViewData->GetPPTX();
2567 const double fPPTY = pViewData->GetPPTY();
2568 aRectString = tools::Rectangle(Point(aTopLeft.getX() / fPPTX, aTopLeft.getY() / fPPTY),
2569 Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY)).toString();
2570 }
2571 aAnnotation.put("cellPos", aRectString);
2572 }
2573 }
2574
2575 boost::property_tree::ptree aTree;
2576 aTree.add_child("comment", aAnnotation);
2577 std::stringstream aStream;
2578 boost::property_tree::write_json(aStream, aTree);
2579 std::string aPayload = aStream.str();
2580
2581 ScViewData* pViewData = GetViewData();
2582 SfxViewShell* pThisViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr );
2583 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
2584 while (pViewShell)
2585 {
2586 if (pThisViewShell == nullptr || pViewShell->GetDocId() == pThisViewShell->GetDocId())
2587 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
2588 pViewShell = SfxViewShell::GetNext(*pViewShell);
2589 }
2590}
2591
2593{
2595 ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( pCur );
2596 return pViewSh ? &pViewSh->GetViewData() : nullptr;
2597}
2598
2600{
2602
2603 ScViewData* pViewData = GetViewData();
2604
2605 return pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
2606}
2607
2609{
2611 // wrong Doc?
2612 if( pViewSh && pViewSh->GetViewData().GetDocShell() != this )
2613 pViewSh = nullptr;
2614 if( !pViewSh )
2615 {
2616 // 1. find ViewShell
2617 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, bOnlyVisible );
2618 if( pFrame )
2619 {
2620 SfxViewShell* p = pFrame->GetViewShell();
2621 pViewSh = dynamic_cast< ScTabViewShell *>( p );
2622 }
2623 }
2624 return pViewSh;
2625}
2626
2628{
2629 // used to invalidate slots after changes to this document
2630
2631 SfxViewShell* pViewSh = GetBestViewShell();
2632 if (pViewSh)
2633 return &pViewSh->GetViewFrame()->GetBindings();
2634 else
2635 return nullptr;
2636}
2637
2638ScDocShell* ScDocShell::GetShellByNum( sal_uInt16 nDocNo ) // static
2639{
2640 ScDocShell* pFound = nullptr;
2642 sal_uInt16 nShellCnt = 0;
2643
2644 while ( pShell && !pFound )
2645 {
2646 if ( auto pDocSh = dynamic_cast<ScDocShell*>(pShell) )
2647 {
2648 if ( nShellCnt == nDocNo )
2649 pFound = pDocSh;
2650 else
2651 ++nShellCnt;
2652 }
2653 pShell = SfxObjectShell::GetNext( *pShell );
2654 }
2655
2656 return pFound;
2657}
2658
2659IMPL_LINK( ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
2660{
2661 OSL_ENSURE( _pFileDlg, "ScDocShell::DialogClosedHdl(): no file dialog" );
2662 OSL_ENSURE( m_pImpl->pDocInserter, "ScDocShell::DialogClosedHdl(): no document inserter" );
2663
2664 if ( ERRCODE_NONE == _pFileDlg->GetError() )
2665 {
2666 sal_uInt16 nSlot = m_pImpl->pRequest->GetSlot();
2667 std::unique_ptr<SfxMedium> pMed = m_pImpl->pDocInserter->CreateMedium();
2668 // #i87094# If a .odt was selected pMed is NULL.
2669 if (pMed)
2670 {
2671 m_pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
2672 if ( SID_DOCUMENT_COMPARE == nSlot )
2673 {
2674 if ( pMed->GetFilter() )
2675 m_pImpl->pRequest->AppendItem(
2676 SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
2677 OUString sOptions = ScDocumentLoader::GetOptions( *pMed );
2678 if ( !sOptions.isEmpty() )
2679 m_pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2680 }
2681 const SfxPoolItem* pItem = nullptr;
2682 const SfxInt16Item* pInt16Item(nullptr);
2683 SfxItemSet* pSet = pMed->GetItemSet();
2684 if (pSet && pSet->GetItemState(SID_VERSION, true, &pItem) == SfxItemState::SET)
2685 {
2686 pInt16Item = dynamic_cast<const SfxInt16Item*>(pItem);
2687 }
2688 if (pInt16Item)
2689 {
2690 m_pImpl->pRequest->AppendItem( *pItem );
2691 }
2692
2693 Execute( *(m_pImpl->pRequest) );
2694 }
2695 }
2696
2697 m_pImpl->bIgnoreLostRedliningWarning = false;
2698}
2699
2700#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
2701
2702void ScDocShell::EnableSharedSettings( bool bEnable )
2703{
2705
2706 if ( bEnable )
2707 {
2708 m_pDocument->EndChangeTracking();
2709 m_pDocument->StartChangeTracking();
2710
2711 // hide accept or reject changes dialog
2712 sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
2713 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
2714 if ( pViewFrame && pViewFrame->HasChildWindow( nId ) )
2715 {
2716 pViewFrame->ToggleChildWindow( nId );
2717 SfxBindings* pBindings = GetViewBindings();
2718 if ( pBindings )
2719 {
2720 pBindings->Invalidate( FID_CHG_ACCEPT );
2721 }
2722 }
2723 }
2724 else
2725 {
2726 m_pDocument->EndChangeTracking();
2727 }
2728
2729 ScChangeViewSettings aChangeViewSet;
2730 aChangeViewSet.SetShowChanges( false );
2731 m_pDocument->SetChangeViewSettings( aChangeViewSet );
2732}
2733
2734uno::Reference< frame::XModel > ScDocShell::LoadSharedDocument()
2735{
2736 uno::Reference< frame::XModel > xModel;
2737 try
2738 {
2739 SC_MOD()->SetInSharedDocLoading( true );
2740 uno::Reference< frame::XDesktop2 > xLoader = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
2741 uno::Sequence aArgs{ comphelper::makePropertyValue("Hidden", true) };
2742
2743 if ( GetMedium() )
2744 {
2745 const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
2746 if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() )
2747 {
2748 aArgs.realloc( 2 );
2749 auto pArgs = aArgs.getArray();
2750 pArgs[1].Name = "Password";
2751 pArgs[1].Value <<= pPasswordItem->GetValue();
2752 }
2753 const SfxUnoAnyItem* pEncryptionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
2754 if (pEncryptionItem)
2755 {
2756 aArgs.realloc(aArgs.getLength() + 1);
2757 auto pArgs = aArgs.getArray();
2758 pArgs[aArgs.getLength() - 1].Name = "EncryptionData";
2759 pArgs[aArgs.getLength() - 1].Value = pEncryptionItem->GetValue();
2760 }
2761 }
2762
2763 xModel.set(
2764 xLoader->loadComponentFromURL( GetSharedFileURL(), "_blank", 0, aArgs ),
2765 uno::UNO_QUERY_THROW );
2766 SC_MOD()->SetInSharedDocLoading( false );
2767 }
2768 catch ( uno::Exception& )
2769 {
2770 OSL_FAIL( "ScDocShell::LoadSharedDocument(): caught exception" );
2771 SC_MOD()->SetInSharedDocLoading( false );
2772 try
2773 {
2774 uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
2775 xClose->close( true );
2776 return uno::Reference< frame::XModel >();
2777 }
2778 catch ( uno::Exception& )
2779 {
2780 return uno::Reference< frame::XModel >();
2781 }
2782 }
2783 return xModel;
2784}
2785
2786#endif
2787
2788/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
PropertiesInfo aProperties
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
const SCTAB MAXTAB
Definition: address.hxx:70
SfxApplication * SfxGetpApp()
static Help * GetHelp()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
sal_uInt16 GetValue() const
const OUString & GetValue() const
const SfxItemSet & GetEmptyItemSet() const
ESelection GetSelection() const
void SetSelection(const ESelection &rNewSel)
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
OUString SpellIgnoreWord()
EditEngine * GetEditEngine() const
void SetAttribs(const SfxItemSet &rSet)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
void SetY2KState(sal_uInt16 n)
const OUString & getBcp47(bool bResolveSystem=true) const
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
static void SetError(ErrCode)
virtual VclPtr< SfxAbstractTabDialog > CreateScHFEditDlg(weld::Window *pParent, const SfxItemSet &rCoreSet, const OUString &rPageStyle, sal_uInt16 nResId)=0
virtual VclPtr< SfxAbstractTabDialog > CreateScStyleDlg(weld::Window *pParent, SfxStyleSheetBase &rStyleBase, bool bPage)=0
virtual VclPtr< AbstractScColRowLabelDlg > CreateScColRowLabelDlg(weld::Window *pParent, bool bCol, bool bRow)=0
virtual VclPtr< AbstractScNewScenarioDlg > CreateScNewScenarioDlg(weld::Window *pParent, const OUString &rName, bool bEdit, bool bSheetProtected)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
SCTAB Tab() const
Definition: address.hxx:283
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1537
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
ScLkUpdMode GetLinkMode() const
Definition: appoptio.hxx:67
static bool GetString(OUString &rString, const css::uno::Any &rAny, sal_uInt16 nEncoding)
Definition: rangeseq.cxx:432
sal_uLong GetActionMax() const
Definition: chgtrack.hxx:955
bool IsProtected() const
Definition: chgtrack.hxx:1127
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
Definition: chgtrack.hxx:1123
const css::uno::Sequence< sal_Int8 > & GetProtection() const
Definition: chgtrack.hxx:1125
void SetShowChanges(bool bFlag)
Definition: chgviset.hxx:78
bool ShowChanges() const
Definition: chgviset.hxx:77
void SetTheActionRange(sal_uLong nFirst, sal_uLong nLast)
Definition: chgviset.hxx:126
void SetShowAccepted(bool bVal)
Definition: chgviset.hxx:113
bool hasListeners() const
Definition: chartlis.cxx:415
bool HasColHeaders() const
Definition: chartpos.hxx:132
bool HasRowHeaders() const
Definition: chartpos.hxx:133
void RenameCellStyle(std::u16string_view rOld, const OUString &rNew)
Definition: conditio.cxx:2167
Stores global named database ranges.
Definition: dbdata.hxx:235
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1193
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:316
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:480
SC_DLLPUBLIC bool HasQueryParam() const
Definition: dbdata.cxx:524
const OUString & GetName() const
Definition: dbdata.hxx:121
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:300
void SetImportParam(const ScImportParam &rImportParam)
Definition: dbdata.cxx:490
bool HasSubTotalParam() const
Definition: dbdata.cxx:542
bool HasSortParam() const
Definition: dbdata.cxx:535
bool IsStripData() const
Definition: dbdata.hxx:140
bool HasImportSelection() const
Definition: dbdata.hxx:201
bool HasImportParam() const
Definition: dbdata.cxx:519
void UpdateImport(const OUString &rTarget, const svx::ODataAccessDescriptor &rDescriptor)
Definition: dbdocfun.cxx:1727
void RepeatDB(bool bRecord=true)
Definition: dbfunc3.cxx:2115
void UpdateCharts(bool bAllCharts)
Definition: dbfunc2.cxx:24
bool ImportData(const ScImportParam &rParam)
Definition: dbfunc.cxx:451
bool DetectiveRefresh(bool bAutomatic=false)
Definition: docfunc.cxx:476
void SetYear2000(sal_uInt16 nVal)
Definition: docoptio.hxx:84
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:457
void SetDocumentModified()
Definition: docsh.cxx:3299
void NotifyStyle(const SfxStyleSheetHint &rHint)
Definition: docsh4.cxx:1577
void SetInitialLinkUpdate(const SfxMedium *pMedium)
Definition: docsh4.cxx:116
void PostPaintCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: docsh3.cxx:188
bool AdjustPrintZoom(const ScRange &rRange)
Definition: docsh4.cxx:1684
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3091
ScDocShell(const ScDocShell &rDocShell)=delete
void PostPaintGridAll()
Definition: docsh3.cxx:183
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect) override
Definition: docsh4.cxx:2172
void DoHardRecalc()
Definition: docsh4.cxx:1511
void DoAutoStyle(const ScRange &rRange, const OUString &rStyle)
Definition: docsh4.cxx:1554
void SetDocumentModified()
Definition: docsh.cxx:2961
OUString m_aDdeTextFmt
Definition: docsh.hxx:84
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2627
bool m_bHeaderOn
Definition: docsh.hxx:90
void AllowLinkUpdate()
Definition: docsh4.cxx:171
void CompareDocument(ScDocument &rOtherDoc)
Definition: docsh3.cxx:660
SAL_DLLPRIVATE css::uno::Reference< css::frame::XModel > LoadSharedDocument()
void DoRecalc(bool bApi)
Definition: docsh4.cxx:1460
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
void ReloadTabLinks()
Definition: docsh6.cxx:386
ScLkUpdMode GetLinkUpdateModeState() const
Definition: docsh4.cxx:136
void PostDataChanged()
Definition: docsh3.cxx:93
std::shared_ptr< ScDocument > m_pDocument
Definition: docsh.hxx:82
std::unique_ptr< DocShell_Impl > m_pImpl
Definition: docsh.hxx:87
sal_Int16 m_nCanUpdate
Definition: docsh.hxx:100
bool m_bFooterOn
Definition: docsh.hxx:91
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: docsh5.cxx:753
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2608
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
Definition: docsh5.cxx:114
void PostPaintExtras()
Definition: docsh3.cxx:198
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
void MergeDocument(ScDocument &rOtherDoc, bool bShared=false, bool bCheckDuplicates=false, sal_uLong nOffset=0, ScChangeActionMergeMap *pMergeMap=nullptr, bool bInverseMap=false)
Definition: docsh3.cxx:767
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem) override
Definition: docsh4.cxx:2488
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:451
void PageStyleModified(std::u16string_view rStyleName, bool bApi)
Definition: docsh4.cxx:1763
void ExecutePageStyle(const SfxViewShell &rCaller, SfxRequest &rReq, SCTAB nCurTab)
Definition: docsh4.cxx:1805
static ScViewData * GetViewData()
Definition: docsh4.cxx:2592
const tools::Rectangle & GetVisArea() const
void SnapVisArea(tools::Rectangle &rRect) const
Definition: docsh4.cxx:2333
bool ExecuteChangeProtectionDialog(bool bJustQueryIfProtected=false)
Protect/unprotect ChangeTrack and return <TRUE> if protection was successfully changed.
Definition: docsh4.cxx:1398
SAL_DLLPRIVATE void EnableSharedSettings(bool bEnable)
void Execute(SfxRequest &rReq)
Definition: docsh4.cxx:226
static ScDocShell * GetShellByNum(sal_uInt16 nDocNo)
Definition: docsh4.cxx:2638
void SetPrintZoom(SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages)
Definition: docsh4.cxx:1651
void GetStatePageStyle(SfxItemSet &rSet, SCTAB nCurTab)
Definition: docsh4.cxx:2024
void ReloadAllLinks()
Definition: docsh4.cxx:177
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2947
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:222
static SCTAB GetCurTab()
Definition: docsh4.cxx:2599
void GetPageOnFromPageStyleSet(const SfxItemSet *pStyleSet, SCTAB nCurTab, bool &rbHeader, bool &rbFooter)
Definition: docsh4.cxx:2360
void RefreshPivotTables(const ScRange &rSource)
Definition: docsh5.cxx:472
static void LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument *pDocument, const ScAddress &rPos, const ScPostIt *pNote)
Definition: docsh4.cxx:2524
void GetState(SfxItemSet &rSet)
Definition: docsh4.cxx:2061
static void RemoveAppPrefix(OUString &rFilterName)
Definition: tablink.cxx:487
static OUString GetOptions(const SfxMedium &rMedium)
Definition: tablink.cxx:423
static bool GetFilterName(const OUString &rFileName, OUString &rFilter, OUString &rOptions, bool bWithContent, bool bWithInteraction)
Returns the filter name and options from a file name.
Definition: tablink.cxx:433
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4224
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4183
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:891
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:500
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1136
void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl)
Definition: documen3.cxx:1986
void StartChangeTracking()
Definition: documen2.cxx:277
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4492
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
Definition: documen3.cxx:510
SC_DLLPUBLIC void GetLanguage(LanguageType &rLatin, LanguageType &rCjk, LanguageType &rCtl) const
Definition: documen3.cxx:1979
SC_DLLPUBLIC bool IsDocVisible() const
Definition: document.hxx:1614
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2487
void EndChangeTracking()
Definition: documen2.cxx:283
static void MirrorRectRTL(tools::Rectangle &rRect)
Definition: drwlayer.cxx:2101
void SetDirty(bool bDirtyFlag=true)
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
bool IsInputMode() const
Definition: inputhdl.hxx:186
void UpdateSpellSettings(bool bFromStartTab=false)
Definition: inputhdl.cxx:943
void FormulaPreview()
Definition: inputhdl.cxx:1865
const ScAddress & GetCursorPos() const
Definition: inputhdl.hxx:194
bool IsFormulaMode() const
Definition: inputhdl.hxx:263
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:445
static void GetSpellSettings(LanguageType &rDefLang, LanguageType &rCjkLang, LanguageType &rCtlLang, bool &rAutoSpell)
Definition: scmod.cxx:2252
Additional class containing cell annotation data.
Definition: postit.hxx:58
sal_uInt32 GetId() const
Returns the note id.
Definition: postit.hxx:100
const OUString & GetDate() const
Returns the creation date of this note.
Definition: postit.hxx:106
const OUString & GetAuthor() const
Returns the author date of this note.
Definition: postit.hxx:111
OUString GetText() const
Returns the caption text of this note.
Definition: postit.cxx:551
static void DrawToDev(ScDocument &rDoc, OutputDevice *pDev, double nPrintFactor, const tools::Rectangle &rBound, ScViewData *pViewData, bool bMetaFile)
Definition: printfun.cxx:466
bool UpdatePages()
Definition: printfun.cxx:2426
void GetScaleData(Size &rPhysSize, tools::Long &rDocHdr, tools::Long &rDocFtr)
Definition: printfun.cxx:1127
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:704
ScAddress aEnd
Definition: address.hxx:498
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1733
ScRefFlags Parse(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1700
ScAddress aStart
Definition: address.hxx:497
bool IsShareDocumentChecked() const
Definition: sharedocdlg.cxx:97
void InitFromStyle(const SfxStyleSheetBase *pSource)
Definition: undostyl.cxx:63
ScStyleSheet * FindCaseIns(const OUString &rName, SfxStyleFamily eFam)
Definition: stlpool.cxx:406
virtual const FmFormShell * GetFormShell() const override
Definition: tabvwsh.hxx:342
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:666
void Execute(SfxRequest &rReq)
Definition: tabvwsh3.cxx:167
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1076
weld::Window * GetDialogParent()
parent window for dialogs Problem: OLE Server!
Definition: tabvwshd.cxx:31
void UpdateLayerLocks()
Definition: tabview5.cxx:354
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1711
static void UpdateInputLine()
Definition: tabview3.cxx:3059
ScViewData & GetViewData()
Definition: tabview.hxx:335
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1822
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3135
Point GetPrintTwipsPos(SCCOL nCol, SCROW nRow) const
returns the position (top-left corner) of the requested cell in print twips coordinates.
Definition: viewdata.cxx:2551
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: viewdata.cxx:3028
bool GetMergeSizePixel(SCCOL nX, SCROW nY, tools::Long &rSizeXPix, tools::Long &rSizeYPix) const
Definition: viewdata.cxx:2727
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
void SetTabNo(SCTAB nNewTab)
Definition: viewdata.cxx:2314
double GetPPTY() const
Definition: viewdata.hxx:469
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3157
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
ScDBFunc * GetView() const
Definition: viewdata.cxx:863
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
void GetEditView(ScSplitPos eWhich, EditView *&rViewPtr, SCCOL &rCol, SCROW &rRow)
Definition: viewdata.cxx:2279
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
Definition: viewdata.cxx:2375
double GetPPTX() const
Definition: viewdata.hxx:468
bool GetMergeSizePrintTwips(SCCOL nX, SCROW nY, tools::Long &rSizeXTwips, tools::Long &rSizeYTwips) const
Definition: viewdata.cxx:2764
void DeleteTable(SCTAB nTabNr, bool bRecord=true)
Definition: viewfun2.cxx:2467
static SfxAbstractDialogFactory * Create()
void Invalidate(sal_uInt16 nId)
void InvalidateAll(bool bWithMsg)
bool GetValue() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxHintId GetId() const
sal_Int16 GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
SfxItemSet * GetItemSet() const
const OUString & GetName() const
virtual SfxObjectShell * GetObjectShell() override
ErrCode GetErrorCode() const
OUString GetSharedFileURL() const
bool HasName() const
virtual void SetVisArea(const tools::Rectangle &rVisArea)
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
bool isExportLocked() const
bool SwitchToShared(bool bShared, bool bSave)
bool IsReadOnly() const
bool IsDocShared() const
ErrCode GetError() const
SfxMedium * GetMedium() const
bool HasSharedXMLFlagSet() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
const tools::Rectangle & GetVisArea() const
bool DoLoad(SfxMedium *pMedium)
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxObjectCreateMode GetCreateMode() const
void InvalidateName()
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
OUString GetPassword() const
virtual short run() override
void SetEditHelpId(const OString &rId)
void SetMinLen(sal_uInt16 Len)
void ShowExtras(SfxShowExtras nExtras)
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
bool IsAPI() const
void Done(bool bRemove=false)
SfxItemPool & GetPool() const
const OUString & GetName() const
SfxViewFrame * GetFrame() const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
static SfxInterface * GetStaticInterface()
SfxViewShell * GetViewShell() const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual SfxItemSet & GetItemSet()
SfxStyleSheetBase * GetStyleSheet() const
size_t LeaveListAction()
virtual void Clear()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
const css::uno::Any & GetValue() const
void ToggleChildWindow(sal_uInt16)
static SfxViewFrame * Current()
void RemoveInfoBar(std::u16string_view sId)
SfxBindings & GetBindings()
bool HasChildWindow(sal_uInt16)
SfxChildWindow * GetChildWindow(sal_uInt16)
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
VclPtr< SfxInfoBarWindow > AppendInfoBar(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType aInfobarType, bool bShowCloseButton=true)
void ShowChildWindow(sal_uInt16, bool bVisible=true)
weld::Window * GetFrameWeld() const
ViewShellDocId GetDocId() const override
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
SfxViewFrame * GetViewFrame() const
static SfxViewShell * Current()
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static SotClipboardFormatId GetFormatIdFromMimeType(const OUString &rMimeType)
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, std::u16string_view sNewPass)
static OUString GetLanguageString(const LanguageType eType)
static LanguageType GetLanguageType(std::u16string_view rStr)
const XColorListRef & GetColorList() const
static void ExecMethod(SfxBindings &rBindings, const OUString &rUIName)
static void CloseMethod(SfxBindings &rBindings)
static bool StateMethod(SfxBindings &rBindings, std::u16string_view rUIFile, bool bReloadNotebookbar=false)
static bool IsActive(bool bConsiderSingleToolbar=false)
virtual LockFileEntry GetLockData() override
void initializeFrom(const css::uno::Sequence< css::beans::PropertyValue > &_rValues)
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr void SetRight(tools::Long v)
constexpr tools::Long Right() const
constexpr void SetBottom(tools::Long v)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
rtl::OString toString() const
virtual void set_label(const OUString &rText)=0
void connect_clicked(const Link< Button &, void > &rLink)
virtual short run()
virtual void set_tooltip_text(const OUString &rTip)=0
#define TOOLS_WARN_EXCEPTION(area, stream)
IMPL_LINK(ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void)
Definition: docsh4.cxx:2659
void UpdateAcceptChangesDialog()
Definition: docsh4.cxx:1385
IMPL_LINK_NOARG(ScDocShell, ReloadAllLinksHdl, weld::Button &, void)
Definition: docsh4.cxx:200
#define ZOOM_MIN
Definition: docsh4.cxx:1649
IMPL_STATIC_LINK(LinkHelp, DispatchHelpLinksHdl, weld::Button &, rBtn, void)
Definition: docsh4.cxx:220
LOKCommentNotificationType
Definition: docsh.hxx:71
float u
#define EE_TEXTPOS_ALL
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
#define ERRCODE_NONE
sal_Int16 nVersion
SotClipboardFormatId
ScLkUpdMode
Definition: global.hxx:409
@ LM_NEVER
Definition: global.hxx:411
@ LM_ON_DEMAND
Definition: global.hxx:412
@ LM_UNKNOWN
Definition: global.hxx:413
@ LM_ALWAYS
Definition: global.hxx:410
@ Keep
Keep selection as is, expand to used data area if no selection.
ScScenarioFlags
Definition: global.hxx:225
@ SC_DB_IMPORT
create "Importx" (if necessary)
Definition: global.hxx:384
#define HID_UPDATE_LINK_WARNING
Definition: helpids.h:173
constexpr OStringLiteral HID_CHG_PROTECT
Definition: helpids.h:53
SfxHintId
OUString aName
void * p
#define LANGUAGE_NONE
#define LANGUAGE_DONTKNOW
SvtScriptType
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
aStr
std::unique_ptr< sal_Int32[]> pData
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
constexpr OUStringLiteral aData
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
bool isTrustedLocationUriForUpdatingLinks(OUString const &uri)
bool isCompatFlagSet(Compat flag)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
end
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
long Long
ComplexTextLayoutFlags
#define ASPECT_CONTENT
SfxObjectCreateMode
#define ASPECT_THUMBNAIL
sal_Int16 nId
const char GetValue[]
SvxPageUsage
constexpr sal_Int64 PRINT_HEADER_HEIGHT
Definition: printfun.hxx:46
constexpr sal_Int64 PRINT_HEADER_WIDTH
Definition: printfun.hxx:45
ConversionMode mode
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
#define ERRCODE_BASIC_NO_ACTIVE_OBJECT
#define ERRCODE_BASIC_NO_OBJECT
#define ERRCODE_BASIC_BAD_PARAMETER
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_SHARED(166)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_HEADERS(170)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(184)
constexpr TypedWhichId< SvxPageItem > ATTR_PAGE(159)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(185)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_ON(164)
#define SC_MOD()
Definition: scmod.hxx:249
#define ERRCTX_SFX_OPENDOC
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)
sal_Int32 nEndPos
sal_Int32 nStartPos
These options control how multi-line cells are converted during export in certain lossy formats (such...
Definition: impex.hxx:38
Reference< XModel > xModel
bool bVisible
signed char sal_Int8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
#define stringstream
Definition: utils.hxx:45
RET_OK
RET_NO
RET_YES
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLUSESLIDEBACKGROUND)