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