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