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