LibreOffice Module sc (master) 1
documen8.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 <scitems.hxx>
24#include <officecfg/Office/Common.hxx>
25#include <tools/urlobj.hxx>
27#include <editeng/langitem.hxx>
28#include <sfx2/linkmgr.hxx>
29#include <sfx2/bindings.hxx>
30#include <sfx2/objsh.hxx>
31#include <sfx2/printer.hxx>
32#include <sfx2/viewfrm.hxx>
33#include <sfx2/viewsh.hxx>
34#include <svl/flagitem.hxx>
35#include <svl/intitem.hxx>
36#include <svl/numformat.hxx>
37#include <svl/zformat.hxx>
38#include <svl/ctloptions.hxx>
40#include <sal/log.hxx>
41#include <osl/diagnose.h>
42
43#include <vcl/svapp.hxx>
44#include <vcl/virdev.hxx>
45#include <vcl/weld.hxx>
46#include <vcl/TaskStopwatch.hxx>
47
48#include <inputopt.hxx>
49#include <global.hxx>
50#include <table.hxx>
51#include <column.hxx>
52#include <poolhelp.hxx>
53#include <docpool.hxx>
54#include <stlpool.hxx>
55#include <stlsheet.hxx>
56#include <docoptio.hxx>
57#include <viewopti.hxx>
58#include <scextopt.hxx>
59#include <rechead.hxx>
60#include <ddelink.hxx>
61#include <scmatrix.hxx>
62#include <arealink.hxx>
63#include <patattr.hxx>
64#include <editutil.hxx>
65#include <progress.hxx>
66#include <document.hxx>
67#include <chartlis.hxx>
68#include <chartlock.hxx>
69#include <refupdat.hxx>
70#include <markdata.hxx>
71#include <scmod.hxx>
72#include <externalrefmgr.hxx>
73#include <globstr.hrc>
74#include <strings.hrc>
75#include <sc.hrc>
76#include <charthelper.hxx>
77#include <macromgr.hxx>
78#include <docuno.hxx>
79#include <scresid.hxx>
80#include <columniterator.hxx>
81#include <globalnames.hxx>
82#include <stringutil.hxx>
83#include <documentlinkmgr.hxx>
84#include <tokenarray.hxx>
85#include <recursionhelper.hxx>
86
87#include <memory>
88#include <utility>
89
90using namespace com::sun::star;
91
92namespace {
93
94sal_uInt16 getScaleValue(SfxStyleSheetBase& rStyle, sal_uInt16 nWhich)
95{
96 return static_cast<const SfxUInt16Item&>(rStyle.GetItemSet().Get(nWhich)).GetValue();
97}
98
99}
100
102{
103 pDocOptions.reset( new ScDocOptions() );
104 pViewOptions.reset( new ScViewOptions() );
105}
106
108{
109 pDocOptions.reset();
110 pViewOptions.reset();
111 pExtDocOptions.reset();
112}
113
114SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist)
115{
116 if ( !mpPrinter && bCreateIfNotExist )
117 {
118 auto pSet =
119 std::make_unique<SfxItemSetFixed
120 <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
121 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
122 SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET,
123 SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS>>(*mxPoolHelper->GetDocPool());
124
125 SfxPrinterChangeFlags nFlags = SfxPrinterChangeFlags::NONE;
126 if (officecfg::Office::Common::Print::Warning::PaperOrientation::get())
127 nFlags |= SfxPrinterChangeFlags::CHG_ORIENTATION;
128 if (officecfg::Office::Common::Print::Warning::PaperSize::get())
129 nFlags |= SfxPrinterChangeFlags::CHG_SIZE;
130 pSet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
131 pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get() ) );
132
133 mpPrinter = VclPtr<SfxPrinter>::Create( std::move(pSet) );
134 mpPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
136 mpPrinter->SetDigitLanguage( ScModule::GetOptDigitLanguage() );
137 }
138
139 return mpPrinter;
140}
141
143{
144 if ( pNewPrinter == mpPrinter.get() )
145 {
146 // #i6706# SetPrinter is called with the same printer again if
147 // the JobSetup has changed. In that case just call UpdateDrawPrinter
148 // (SetRefDevice for drawing layer) because of changed text sizes.
150 }
151 else
152 {
154 mpPrinter = pNewPrinter;
156 mpPrinter->SetDigitLanguage( ScModule::GetOptDigitLanguage() );
157 }
158 InvalidateTextWidth(nullptr, nullptr, false); // in both cases
159}
160
162{
163 if ( !mpPrinter ) GetPrinter(); // this sets mpPrinter
164 OSL_ENSURE( mpPrinter, "Error in printer creation :-/" );
165
166 if ( !mpPrinter )
167 return;
168
169 SfxItemSet aOptSet( mpPrinter->GetOptions() );
170
171 SfxPrinterChangeFlags nFlags = SfxPrinterChangeFlags::NONE;
172 if (officecfg::Office::Common::Print::Warning::PaperOrientation::get())
173 nFlags |= SfxPrinterChangeFlags::CHG_ORIENTATION;
174 if (officecfg::Office::Common::Print::Warning::PaperSize::get())
175 nFlags |= SfxPrinterChangeFlags::CHG_SIZE;
176 aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
177 aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get() ) );
178
179 mpPrinter->SetOptions( aOptSet );
180}
181
183{
185 {
186#ifdef IOS
188#else
189 mpVirtualDevice_100th_mm = VclPtr<VirtualDevice>::Create(DeviceFormat::WITHOUT_ALPHA);
190#endif
192 MapMode aMapMode( mpVirtualDevice_100th_mm->GetMapMode() );
193 aMapMode.SetMapUnit( MapUnit::Map100thMM );
194 mpVirtualDevice_100th_mm->SetMapMode( aMapMode );
195 }
197}
198
200{
201 // Create printer like ref device, see Writer...
202 OutputDevice* pRefDevice = nullptr;
203 if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
204 pRefDevice = GetPrinter();
205 else
206 pRefDevice = GetVirtualDevice_100th_mm();
207 return pRefDevice;
208}
209
211 const SfxItemSet& rChanges )
212{
213 SfxItemSet& rSet = rStyleSheet.GetItemSet();
214
215 switch ( rStyleSheet.GetFamily() )
216 {
217 case SfxStyleFamily::Page:
218 {
219 const sal_uInt16 nOldScale = getScaleValue(rStyleSheet, ATTR_PAGE_SCALE);
220 const sal_uInt16 nOldScaleToPages = getScaleValue(rStyleSheet, ATTR_PAGE_SCALETOPAGES);
221 rSet.Put( rChanges );
222 const sal_uInt16 nNewScale = getScaleValue(rStyleSheet, ATTR_PAGE_SCALE);
223 const sal_uInt16 nNewScaleToPages = getScaleValue(rStyleSheet, ATTR_PAGE_SCALETOPAGES);
224
225 if ( (nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages) )
226 InvalidateTextWidth( rStyleSheet.GetName() );
227
229 {
230 if( rChanges.GetItemState(ATTR_WRITINGDIR ) == SfxItemState::SET )
232 }
233 }
234 break;
235
236 case SfxStyleFamily::Para:
237 {
238 bool bNumFormatChanged;
239 if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
240 rSet, rChanges ) )
241 InvalidateTextWidth( nullptr, nullptr, bNumFormatChanged );
242
243 for (SCTAB nTab=0; nTab<=MAXTAB; ++nTab)
244 if (maTabs[nTab])
245 maTabs[nTab]->SetStreamValid( false );
246
247 sal_uLong nOldFormat =
248 rSet.Get( ATTR_VALUE_FORMAT ).GetValue();
249 sal_uLong nNewFormat =
250 rChanges.Get( ATTR_VALUE_FORMAT ).GetValue();
251 LanguageType eNewLang, eOldLang;
252 eNewLang = eOldLang = LANGUAGE_DONTKNOW;
253 if ( nNewFormat != nOldFormat )
254 {
255 SvNumberFormatter* pFormatter = GetFormatTable();
256 eOldLang = pFormatter->GetEntry( nOldFormat )->GetLanguage();
257 eNewLang = pFormatter->GetEntry( nNewFormat )->GetLanguage();
258 }
259
260 // Explanation to Items in rChanges:
261 // Set Item - take over change
262 // Dontcare - Set Default
263 // Default - No change
264 // ("no change" is not possible with PutExtended, thus the loop)
265 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
266 {
267 const SfxPoolItem* pItem;
268 SfxItemState eState = rChanges.GetItemState( nWhich, false, &pItem );
269 if ( eState == SfxItemState::SET )
270 rSet.Put( *pItem );
271 else if ( eState == SfxItemState::DONTCARE )
272 rSet.ClearItem( nWhich );
273 // when Default nothing
274 }
275
276 if ( eNewLang != eOldLang )
277 rSet.Put(
279 }
280 break;
281 default:
282 {
283 // added to avoid warnings
284 }
285 }
286}
287
289{
290 // number format exchange list has to be handled here, too
291 NumFmtMergeHandler aNumFmtMergeHdl(*this, rSrcDoc);
292 mxPoolHelper->GetStylePool()->CopyStdStylesFrom( rSrcDoc.mxPoolHelper->GetStylePool() );
293}
294
295void ScDocument::InvalidateTextWidth( std::u16string_view rStyleName )
296{
297 const SCTAB nCount = GetTableCount();
298 for ( SCTAB i=0; i<nCount && maTabs[i]; i++ )
299 if ( maTabs[i]->GetPageStyle() == rStyleName )
301}
302
304{
305 ScAddress aAdrFrom( 0, 0, nTab );
306 ScAddress aAdrTo ( MaxCol(), MaxRow(), nTab );
307 InvalidateTextWidth( &aAdrFrom, &aAdrTo, false );
308}
309
310bool ScDocument::IsPageStyleInUse( std::u16string_view rStrPageStyle, SCTAB* pInTab )
311{
312 bool bInUse = false;
313 const SCTAB nCount = GetTableCount();
314 SCTAB i;
315
316 for ( i = 0; !bInUse && i < nCount && maTabs[i]; i++ )
317 bInUse = ( maTabs[i]->GetPageStyle() == rStrPageStyle );
318
319 if ( pInTab )
320 *pInTab = i-1;
321
322 return bInUse;
323}
324
325bool ScDocument::RemovePageStyleInUse( std::u16string_view rStyle )
326{
327 bool bWasInUse = false;
328 const SCTAB nCount = GetTableCount();
329
330 for ( SCTAB i=0; i<nCount && maTabs[i]; i++ )
331 if ( maTabs[i]->GetPageStyle() == rStyle )
332 {
333 bWasInUse = true;
334 maTabs[i]->SetPageStyle( ScResId(STR_STYLENAME_STANDARD) );
335 }
336
337 return bWasInUse;
338}
339
340bool ScDocument::RenamePageStyleInUse( std::u16string_view rOld, const OUString& rNew )
341{
342 bool bWasInUse = false;
343 const SCTAB nCount = GetTableCount();
344
345 for ( SCTAB i=0; i<nCount && maTabs[i]; i++ )
346 if ( maTabs[i]->GetPageStyle() == rOld )
347 {
348 bWasInUse = true;
349 maTabs[i]->SetPageStyle( rNew );
350 }
351
352 return bWasInUse;
353}
354
356{
357 EEHorizontalTextDirection eRet = EEHorizontalTextDirection::Default;
358
359 OUString aStyleName = GetPageStyle( nTab );
360 SfxStyleSheetBase* pStyle = mxPoolHelper->GetStylePool()->Find( aStyleName, SfxStyleFamily::Page );
361 if ( pStyle )
362 {
363 SfxItemSet& rStyleSet = pStyle->GetItemSet();
364 SvxFrameDirection eDirection =
365 rStyleSet.Get( ATTR_WRITINGDIR ).GetValue();
366
367 if ( eDirection == SvxFrameDirection::Horizontal_LR_TB )
368 eRet = EEHorizontalTextDirection::L2R;
369 else if ( eDirection == SvxFrameDirection::Horizontal_RL_TB )
370 eRet = EEHorizontalTextDirection::R2L;
371 // else (invalid for EditEngine): keep "default"
372 }
373
374 return eRet;
375}
376
378{
379 if (!mpMacroMgr)
380 mpMacroMgr.reset(new ScMacroManager(*this));
381 return mpMacroMgr.get();
382}
383
385 ScMatrix& rMat, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const
386{
387 const ScTable* pTab = FetchTable(nTab);
388 if (!pTab)
389 return;
390
391 if (nCol1 > nCol2 || nRow1 > nRow2)
392 return;
393
394 SCSIZE nC, nR;
395 rMat.GetDimensions(nC, nR);
396 if (static_cast<SCROW>(nR) != nRow2 - nRow1 + 1 || static_cast<SCCOL>(nC) != nCol2 - nCol1 + 1)
397 return;
398
399 pTab->FillMatrix(rMat, nCol1, nRow1, nCol2, nRow2, pPool);
400}
401
402void ScDocument::SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen )
403{
404 ScTable* pTab = FetchTable(rTopPos.Tab());
405 if (!pTab)
406 return;
407
408 pTab->SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen);
409}
410
411void ScDocument::CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal)
412{
413 ScTable* pTab = FetchTable(rCalcRange.aStart.Tab());
414 if (!pTab)
415 return;
416
418
419 maThreadSpecific.pContext = &rContext;
420 pTab->CalculateInColumnInThread(rContext, rCalcRange.aStart.Col(), rCalcRange.aEnd.Col(), rCalcRange.aStart.Row(), rCalcRange.aEnd.Row(), nThisThread, nThreadsTotal);
421
423 maThreadSpecific.pContext = nullptr;
424 // If any of the thread_local data would cause problems if they stay around for too long
425 // (and e.g. outlive the ScDocument), clean them up here, they cannot be cleaned up
426 // later from the main thread.
429}
430
431void ScDocument::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter )
432{
434 for( const DelayedSetNumberFormat& data : GetNonThreadedContext().maDelayedSetNumberFormat)
435 SetNumberFormat( ScAddress( data.mCol, data.mRow, nTab ), data.mnNumberFormat );
437
438 ScTable* pTab = FetchTable(nTab);
439 if (!pTab)
440 return;
441
442 pTab->HandleStuffAfterParallelCalculation(nColStart, nColEnd, nRow, nLen, pInterpreter);
443}
444
445void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
446 bool bNumFormatChanged )
447{
448 bool bBroadcast = (bNumFormatChanged && GetDocOptions().IsCalcAsShown() && !IsImportingXML() && !IsClipboard());
449 if ( pAdrFrom && !pAdrTo )
450 {
451 const SCTAB nTab = pAdrFrom->Tab();
452
453 if (nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
454 maTabs[nTab]->InvalidateTextWidth( pAdrFrom, nullptr, bNumFormatChanged, bBroadcast );
455 }
456 else
457 {
458 const SCTAB nTabStart = pAdrFrom ? pAdrFrom->Tab() : 0;
459 const SCTAB nTabEnd = pAdrTo ? pAdrTo->Tab() : MAXTAB;
460
461 for ( SCTAB nTab=nTabStart; nTab<=nTabEnd && nTab < static_cast<SCTAB>(maTabs.size()); nTab++ )
462 if ( maTabs[nTab] )
463 maTabs[nTab]->InvalidateTextWidth( pAdrFrom, pAdrTo, bNumFormatChanged, bBroadcast );
464 }
465}
466
467#define CALCMAX 1000 // Calculations
468
469namespace {
470
471class IdleCalcTextWidthScope : public TaskStopwatch
472{
473 ScDocument& mrDoc;
474 ScAddress& mrCalcPos;
475 MapMode maOldMapMode;
476 ScStyleSheetPool* mpStylePool;
477 bool mbNeedMore;
478 bool mbProgress;
479
480public:
481 IdleCalcTextWidthScope(ScDocument& rDoc, ScAddress& rCalcPos) :
482 mrDoc(rDoc),
483 mrCalcPos(rCalcPos),
484 mpStylePool(rDoc.GetStyleSheetPool()),
485 mbNeedMore(false),
486 mbProgress(false)
487 {
488 mrDoc.EnableIdle(false);
489 }
490
491 ~IdleCalcTextWidthScope() COVERITY_NOEXCEPT_FALSE
492 {
493 SfxPrinter* pDev = mrDoc.GetPrinter();
494 if (pDev)
495 pDev->SetMapMode(maOldMapMode);
496
497 if (mbProgress)
499
500 mrDoc.EnableIdle(true);
501 }
502
503 SCTAB Tab() const { return mrCalcPos.Tab(); }
504 SCCOL Col() const { return mrCalcPos.Col(); }
505 SCROW Row() const { return mrCalcPos.Row(); }
506
507 void setTab(SCTAB nTab) { mrCalcPos.SetTab(nTab); }
508 void setCol(SCCOL nCol) { mrCalcPos.SetCol(nCol); }
509 void setRow(SCROW nRow) { mrCalcPos.SetRow(nRow); }
510
511 void incTab() { mrCalcPos.IncTab(); }
512 void incCol(SCCOL nInc) { mrCalcPos.IncCol(nInc); }
513
514 void setOldMapMode(const MapMode& rOldMapMode) { maOldMapMode = rOldMapMode; }
515
516 void setNeedMore(bool b) { mbNeedMore = b; }
517 bool getNeedMore() const { return mbNeedMore; }
518
519 void createProgressBar()
520 {
522 mbProgress = true;
523 }
524
525 bool hasProgressBar() const { return mbProgress; }
526
527 ScStyleSheetPool* getStylePool() { return mpStylePool; }
528};
529
530}
531
532bool ScDocument::IdleCalcTextWidth() // true = try next again
533{
534 // #i75610# if a printer hasn't been set or created yet, don't create one for this
535 if (!mbIdleEnabled || IsInLinkUpdate() || GetPrinter(false) == nullptr)
536 return false;
537
538 IdleCalcTextWidthScope aScope(*this, aCurTextWidthCalcPos);
539
540 if (!ValidRow(aScope.Row()))
541 {
542 aScope.setRow(0);
543 aScope.incCol(-1);
544 }
545
546 if (aScope.Col() < 0)
547 {
548 aScope.setCol(MaxCol());
549 aScope.incTab();
550 }
551
552 if (!HasTable(aScope.Tab()))
553 aScope.setTab(0);
554
555 ScTable* pTab = maTabs[aScope.Tab()].get();
556 ScStyleSheet* pStyle = static_cast<ScStyleSheet*>(aScope.getStylePool()->Find(pTab->aPageStyle, SfxStyleFamily::Page));
557 OSL_ENSURE( pStyle, "Missing StyleSheet :-/" );
558
559 if (!pStyle || getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0)
560 {
561 // Move to the next sheet as the current one has scale-to-pages set,
562 // and bail out.
563 aScope.incTab();
564 return false;
565 }
566
567 sal_uInt16 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE);
568 Fraction aZoomFract(nZoom, 100);
569
570 aScope.setCol(pTab->ClampToAllocatedColumns(aScope.Col()));
571 // Start at specified cell position (nCol, nRow, nTab).
572 ScColumn* pCol = &pTab->aCol[aScope.Col()];
573 std::optional<ScColumnTextWidthIterator> pColIter(std::in_place, *this, *pCol, aScope.Row(), MaxRow());
574
575 OutputDevice* pDev = nullptr;
576 sal_uInt16 nRestart = 0;
577 sal_uInt16 nCount = 0;
578 while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) )
579 {
580 if (pColIter->hasCell())
581 {
582 // More cell in this column.
583 SCROW nRow = pColIter->getPos();
584 aScope.setRow(nRow);
585
586 if (pColIter->getValue() == TEXTWIDTH_DIRTY)
587 {
588 // Calculate text width for this cell.
589 double nPPTX = 0.0;
590 double nPPTY = 0.0;
591 if (!pDev)
592 {
593 pDev = GetPrinter();
594 aScope.setOldMapMode(pDev->GetMapMode());
595 pDev->SetMapMode(MapMode(MapUnit::MapPixel)); // Important for GetNeededSize
596
597 Point aPix1000 = pDev->LogicToPixel(Point(1000,1000), MapMode(MapUnit::MapTwip));
598 nPPTX = aPix1000.X() / 1000.0;
599 nPPTY = aPix1000.Y() / 1000.0;
600 }
601
602 if (!aScope.hasProgressBar() && pCol->IsFormulaDirty(nRow))
603 aScope.createProgressBar();
604
605 sal_uInt16 nNewWidth = static_cast<sal_uInt16>(GetNeededSize(
606 aScope.Col(), aScope.Row(), aScope.Tab(),
607 pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true)); // bTotalSize
608
609 pColIter->setValue(nNewWidth);
610 aScope.setNeedMore(true);
611 }
612 pColIter->next();
613 }
614 else
615 {
616 // No more cell in this column. Move to the left column and start at row 0.
617
618 bool bNewTab = false;
619
620 aScope.setRow(0);
621 aScope.incCol(-1);
622
623 if (aScope.Col() < 0)
624 {
625 // No more column to the left. Move to the right-most column of the next sheet.
626 aScope.setCol(MaxCol());
627 aScope.incTab();
628 bNewTab = true;
629 }
630
631 if (!HasTable(aScope.Tab()))
632 {
633 // Sheet doesn't exist at specified sheet position. Restart at sheet 0.
634 aScope.setTab(0);
635 nRestart++;
636 bNewTab = true;
637 }
638
639 if ( nRestart < 2 )
640 {
641 if ( bNewTab )
642 {
643 pTab = maTabs[aScope.Tab()].get();
644 aScope.setCol(pTab->ClampToAllocatedColumns(aScope.Col()));
645 pStyle = static_cast<ScStyleSheet*>(aScope.getStylePool()->Find(
646 pTab->aPageStyle, SfxStyleFamily::Page));
647
648 if ( pStyle )
649 {
650 // Check if the scale-to-pages setting is set. If
651 // set, we exit the loop. If not, get the page
652 // scale factor of the new sheet.
653 if (getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0)
654 {
655 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE);
656 aZoomFract = Fraction(nZoom, 100);
657 }
658 else
659 nZoom = 0;
660 }
661 else
662 {
663 OSL_FAIL( "Missing StyleSheet :-/" );
664 }
665 }
666
667 if ( nZoom > 0 )
668 {
669 pCol = &pTab->aCol[aScope.Col()];
670 pColIter.emplace(*this, *pCol, aScope.Row(), MaxRow());
671 }
672 else
673 {
674 aScope.incTab(); // Move to the next sheet as the current one has scale-to-pages set.
675 return false;
676 }
677 }
678 }
679
680 ++nCount;
681
682 if (!aScope.continueIter())
683 break;
684 }
685
686 return aScope.getNeedMore();
687}
688
690{
691 if ( bIsVisible && mpShell )
692 {
693 ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>( mpShell->GetModel() );
694 if ( pModel )
695 pModel->RepaintRange( rRange ); // locked repaints are checked there
696 }
697}
698
700{
701 if ( bIsVisible && mpShell )
702 {
703 ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>( mpShell->GetModel() );
704 if ( pModel )
705 pModel->RepaintRange( rRange ); // locked repaints are checked there
706 }
707}
708
710{
711 // when 4.0-Export, remove all with mode != DEFAULT
712 bool bExport40 = ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_40 );
713
714 const ::sfx2::SvBaseLinks& rLinks = GetLinkManager()->GetLinks();
715 sal_uInt16 nCount = rLinks.size();
716
717 // Count them first
718
719 sal_uInt16 nDdeCount = 0;
720 sal_uInt16 i;
721 for (i=0; i<nCount; i++)
722 {
723 ::sfx2::SvBaseLink* pBase = rLinks[i].get();
724 if (ScDdeLink* pLink = dynamic_cast<ScDdeLink*>(pBase))
725 if ( !bExport40 || pLink->GetMode() == SC_DDE_DEFAULT )
726 ++nDdeCount;
727 }
728
729 // Header
730
731 ScMultipleWriteHeader aHdr( rStream );
732 rStream.WriteUInt16( nDdeCount );
733
734 // Save links
735
736 for (i=0; i<nCount; i++)
737 {
738 ::sfx2::SvBaseLink* pBase = rLinks[i].get();
739 if (ScDdeLink* pLink = dynamic_cast<ScDdeLink*>(pBase))
740 {
741 if ( !bExport40 || pLink->GetMode() == SC_DDE_DEFAULT )
742 pLink->Store( rStream, aHdr );
743 }
744 }
745}
746
748{
750 if (!pMgr)
751 return;
752
753 ScMultipleReadHeader aHdr( rStream );
754
755 sal_uInt16 nCount(0);
756 rStream.ReadUInt16( nCount );
757
758 const rtl_TextEncoding eCharSet = rStream.GetStreamCharSet();
759 const size_t nMinStringSize = eCharSet == RTL_TEXTENCODING_UNICODE ? sizeof(sal_uInt32) : sizeof(sal_uInt16);
760 const size_t nMinRecordSize = 1 + nMinStringSize*3;
761 const size_t nMaxRecords = rStream.remainingSize() / nMinRecordSize;
762 if (nCount > nMaxRecords)
763 {
764 SAL_WARN("sc", "Parsing error: " << nMaxRecords <<
765 " max possible entries, but " << nCount << " claimed, truncating");
766 nCount = nMaxRecords;
767 }
768
769 for (sal_uInt16 i=0; i<nCount; ++i)
770 {
771 ScDdeLink* pLink = new ScDdeLink( *this, rStream, aHdr );
772 pMgr->InsertDDELink(pLink, pLink->GetAppl(), pLink->GetTopic(), pLink->GetItem());
773 }
774}
775
777{
778 // called from TableLink and AreaLink
779
780 OSL_ENSURE( bInLinkUpdate != bSet, "SetInLinkUpdate twice" );
781 bInLinkUpdate = bSet;
782}
783
785{
787}
788
790{
791 if (!pExternalRefMgr)
792 return;
793
795 if (!pMgr)
796 return;
797
798 const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
799 sal_uInt16 nCount = rLinks.size();
800
801 bool bAny = false;
802
803 // Collect all the external ref links first.
804 std::vector<ScExternalRefLink*> aRefLinks;
805 for (sal_uInt16 i = 0; i < nCount; ++i)
806 {
807 ::sfx2::SvBaseLink* pBase = rLinks[i].get();
808 ScExternalRefLink* pRefLink = dynamic_cast<ScExternalRefLink*>(pBase);
809 if (pRefLink)
810 aRefLinks.push_back(pRefLink);
811 }
812
813 weld::WaitObject aWaitSwitch(pWin);
814
815 pExternalRefMgr->enableDocTimer(false);
816 ScProgress aProgress(GetDocumentShell(), ScResId(SCSTR_UPDATE_EXTDOCS), aRefLinks.size(), true);
817 for (size_t i = 0, n = aRefLinks.size(); i < n; ++i)
818 {
819 aProgress.SetState(i+1);
820
821 ScExternalRefLink* pRefLink = aRefLinks[i];
822 if (pRefLink->Update())
823 {
824 bAny = true;
825 continue;
826 }
827
828 // Update failed. Notify the user.
829
830 OUString aFile;
831 sfx2::LinkManager::GetDisplayNames(pRefLink, nullptr, &aFile);
832 // Decode encoded URL for display friendliness.
835
836 OUString sMessage = ScResId(SCSTR_EXTDOC_NOT_LOADED) +
837 "\n\n" +
838 aFile;
839 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin,
840 VclMessageType::Warning, VclButtonsType::Ok,
841 sMessage));
842 xBox->run();
843 }
844
845 pExternalRefMgr->enableDocTimer(true);
846
847 if (!bAny)
848 return;
849
851 mpShell->Broadcast( SfxHint(SfxHintId::ScDataChanged) );
852
853 // #i101960# set document modified, as in TrackTimeHdl for DDE links
854 if (!mpShell->IsModified())
855 {
857 SfxBindings* pBindings = GetViewBindings();
858 if (pBindings)
859 {
860 pBindings->Invalidate( SID_SAVEDOC );
861 pBindings->Invalidate( SID_DOC_MODIFIED );
862 }
863 }
864}
865
867{
868 if (bIsClip) // Create from Stream
869 {
870 if (pClipData)
871 {
872 pClipData->Seek(0);
873 rDestDoc.LoadDdeLinks(*pClipData);
874 }
875
876 return;
877 }
878
880 if (!pMgr)
881 return;
882
883 sfx2::LinkManager* pDestMgr = rDestDoc.GetDocLinkManager().getLinkManager(rDestDoc.bAutoCalc);
884 if (!pDestMgr)
885 return;
886
887 const sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
888 for (const auto & rLink : rLinks)
889 {
890 const sfx2::SvBaseLink* pBase = rLink.get();
891 if (const ScDdeLink* p = dynamic_cast<const ScDdeLink*>(pBase))
892 {
893 ScDdeLink* pNew = new ScDdeLink(rDestDoc, *p);
894 pDestMgr->InsertDDELink(
895 pNew, pNew->GetAppl(), pNew->GetTopic(), pNew->GetItem());
896 }
897 }
898}
899
900namespace {
901
906ScDdeLink* lclGetDdeLink(
907 const sfx2::LinkManager* pLinkManager,
908 std::u16string_view rAppl, std::u16string_view rTopic, std::u16string_view rItem, sal_uInt8 nMode,
909 size_t* pnDdePos = nullptr )
910{
911 if( pLinkManager )
912 {
913 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
914 if( pnDdePos ) *pnDdePos = 0;
915 for( const auto& nLinks : rLinks )
916 {
917 if( ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>( nLinks.get() ) )
918 {
919 if( (pDdeLink->GetAppl() == rAppl) &&
920 (pDdeLink->GetTopic() == rTopic) &&
921 (pDdeLink->GetItem() == rItem) &&
922 ((nMode == SC_DDE_IGNOREMODE) || (nMode == pDdeLink->GetMode())) )
923 return pDdeLink;
924 if( pnDdePos ) ++*pnDdePos;
925 }
926 }
927 }
928 return nullptr;
929}
930
934ScDdeLink* lclGetDdeLink( const sfx2::LinkManager* pLinkManager, size_t nDdePos )
935{
936 if( pLinkManager )
937 {
938 size_t nDdeIndex = 0; // counts only the DDE links
939 for( const auto& pLink : pLinkManager->GetLinks() )
940 {
941 if( ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>( pLink.get() ) )
942 {
943 if( nDdeIndex == nDdePos )
944 return pDdeLink;
945 ++nDdeIndex;
946 }
947 }
948 }
949 return nullptr;
950}
951
952} // namespace
953
954bool ScDocument::FindDdeLink( std::u16string_view rAppl, std::u16string_view rTopic, std::u16string_view rItem,
955 sal_uInt8 nMode, size_t& rnDdePos )
956{
957 return lclGetDdeLink( GetLinkManager(), rAppl, rTopic, rItem, nMode, &rnDdePos ) != nullptr;
958}
959
960bool ScDocument::GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const
961{
962 if( const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
963 {
964 rAppl = pDdeLink->GetAppl();
965 rTopic = pDdeLink->GetTopic();
966 rItem = pDdeLink->GetItem();
967 return true;
968 }
969 return false;
970}
971
972bool ScDocument::GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const
973{
974 if( const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
975 {
976 rnMode = pDdeLink->GetMode();
977 return true;
978 }
979 return false;
980}
981
982const ScMatrix* ScDocument::GetDdeLinkResultMatrix( size_t nDdePos ) const
983{
984 const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos );
985 return pDdeLink ? pDdeLink->GetResult() : nullptr;
986}
987
988bool ScDocument::CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults )
989{
990 /* Create a DDE link without updating it (i.e. for Excel import), to prevent
991 unwanted connections. First try to find existing link. Set result array
992 on existing and new links. */
993 //TODO: store DDE links additionally at document (for efficiency)?
994 OSL_ENSURE( nMode != SC_DDE_IGNOREMODE, "ScDocument::CreateDdeLink - SC_DDE_IGNOREMODE not allowed here" );
995
997 if (!pMgr)
998 return false;
999
1000 if (nMode != SC_DDE_IGNOREMODE)
1001 {
1002 ScDdeLink* pDdeLink = lclGetDdeLink(pMgr, rAppl, rTopic, rItem, nMode);
1003 if( !pDdeLink )
1004 {
1005 // create a new DDE link, but without TryUpdate
1006 pDdeLink = new ScDdeLink( *this, rAppl, rTopic, rItem, nMode );
1007 pMgr->InsertDDELink(pDdeLink, rAppl, rTopic, rItem);
1008 }
1009
1010 // insert link results
1011 if( pResults )
1012 pDdeLink->SetResult( pResults );
1013
1014 return true;
1015 }
1016 return false;
1017}
1018
1019bool ScDocument::SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults )
1020{
1021 if( ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
1022 {
1023 pDdeLink->SetResult( pResults );
1024 return true;
1025 }
1026 return false;
1027}
1028
1030{
1032 if (!pMgr)
1033 return false;
1034
1035 const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
1036 sal_uInt16 nCount = rLinks.size();
1037 for (sal_uInt16 i=0; i<nCount; i++)
1038 if (nullptr != dynamic_cast<const ScAreaLink* >(rLinks[i].get()))
1039 return true;
1040
1041 return false;
1042}
1043
1045{
1047 if (!pMgr)
1048 return;
1049
1050 const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
1051 for (const auto & rLink : rLinks)
1052 {
1053 ::sfx2::SvBaseLink* pBase = rLink.get();
1054 if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr)
1055 pBase->Update();
1056 }
1057}
1058
1060{
1062 if (!pMgr)
1063 return;
1064
1065 const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
1066 sfx2::SvBaseLinks::size_type nPos = 0;
1067 while ( nPos < rLinks.size() )
1068 {
1069 const ::sfx2::SvBaseLink* pBase = rLinks[nPos].get();
1070 const ScAreaLink* pLink = dynamic_cast<const ScAreaLink*>(pBase);
1071 if (pLink && pLink->GetDestArea().aStart.Tab() == nTab)
1072 pMgr->Remove(nPos);
1073 else
1074 ++nPos;
1075 }
1076}
1077
1079 const ScRange& rRange, SCCOL nDx, SCROW nDy, SCTAB nDz )
1080{
1082 if (!pMgr)
1083 return;
1084
1085 bool bAnyUpdate = false;
1086
1087 const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
1088 sal_uInt16 nCount = rLinks.size();
1089 for (sal_uInt16 i=0; i<nCount; i++)
1090 {
1091 ::sfx2::SvBaseLink* pBase = rLinks[i].get();
1092 if (ScAreaLink* pLink = dynamic_cast<ScAreaLink*>(pBase))
1093 {
1094 ScRange aOutRange = pLink->GetDestArea();
1095
1096 SCCOL nCol1 = aOutRange.aStart.Col();
1097 SCROW nRow1 = aOutRange.aStart.Row();
1098 SCTAB nTab1 = aOutRange.aStart.Tab();
1099 SCCOL nCol2 = aOutRange.aEnd.Col();
1100 SCROW nRow2 = aOutRange.aEnd.Row();
1101 SCTAB nTab2 = aOutRange.aEnd.Tab();
1102
1103 ScRefUpdateRes eRes =
1104 ScRefUpdate::Update( this, eUpdateRefMode,
1105 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
1106 rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
1107 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
1108 if ( eRes != UR_NOTHING )
1109 {
1110 pLink->SetDestArea( ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ) );
1111 bAnyUpdate = true;
1112 }
1113 }
1114 }
1115
1116 if ( !bAnyUpdate )
1117 return;
1118
1119 // #i52120# Look for duplicates (after updating all positions).
1120 // If several links start at the same cell, the one with the lower index is removed
1121 // (file format specifies only one link definition for a cell).
1122
1123 sal_uInt16 nFirstIndex = 0;
1124 while ( nFirstIndex < nCount )
1125 {
1126 bool bFound = false;
1127 ::sfx2::SvBaseLink* pFirst = rLinks[nFirstIndex].get();
1128 if (ScAreaLink* pFirstLink = dynamic_cast<ScAreaLink*>(pFirst))
1129 {
1130 ScAddress aFirstPos = pFirstLink->GetDestArea().aStart;
1131 for ( sal_uInt16 nSecondIndex = nFirstIndex + 1; nSecondIndex < nCount && !bFound; ++nSecondIndex )
1132 {
1133 ::sfx2::SvBaseLink* pSecond = rLinks[nSecondIndex].get();
1134 ScAreaLink* pSecondLink = dynamic_cast<ScAreaLink*>(pSecond);
1135 if (pSecondLink && pSecondLink->GetDestArea().aStart == aFirstPos)
1136 {
1137 // remove the first link, exit the inner loop, don't increment nFirstIndex
1138 pMgr->Remove(pFirst);
1139 nCount = rLinks.size();
1140 bFound = true;
1141 }
1142 }
1143 }
1144 if (!bFound)
1145 ++nFirstIndex;
1146 }
1147}
1148
1150{
1152 return;
1153
1154 // Prefer RPN over tokenized formula if available.
1155 if (rCode.GetCodeLen())
1156 {
1157 if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice))
1159 }
1160 else if (rCode.GetLen())
1161 {
1162 if (rCode.HasOpCode(ocDde) || rCode.HasOpCode(ocWebservice))
1164 }
1165 else
1166 {
1167 // Possible with named expression without expression like Excel
1168 // internal print ranges, obscure user define names, ... formula error
1169 // cells without formula ...
1170 SAL_WARN("sc.core","ScDocument::CheckLinkFormulaNeedingCheck - called with empty ScTokenArray");
1171 }
1172}
1173
1174// TimerDelays etc.
1176{
1177 if ( pChartListenerCollection->hasListeners() )
1178 pChartListenerCollection->StartTimer();
1180 apTemporaryChartLock->StartOrContinueLocking();
1181}
1182
1184{
1185 // used to invalidate slots after changes to this document
1186
1187 if ( !mpShell )
1188 return nullptr; // no ObjShell -> no view
1189
1190 // first check current view
1191 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1192 if ( pViewFrame && pViewFrame->GetObjectShell() != mpShell ) // wrong document?
1193 pViewFrame = nullptr;
1194
1195 // otherwise use first view for this doc
1196 if ( !pViewFrame )
1197 pViewFrame = SfxViewFrame::GetFirst( mpShell );
1198
1199 if (pViewFrame)
1200 return &pViewFrame->GetBindings();
1201 else
1202 return nullptr;
1203}
1204
1206{
1207 OSL_ENSURE( rMultiMark.IsMultiMarked(), "TransliterateText: no selection" );
1208
1210 bool bConsiderLanguage = aTransliterationWrapper.needLanguageForTheMode();
1211 LanguageType nLanguage = LANGUAGE_SYSTEM;
1212
1213 std::unique_ptr<ScEditEngineDefaulter> pEngine; // not using mpEditEngine member because of defaults
1214
1216 for (const SCTAB& nTab : rMultiMark)
1217 {
1218 if (nTab >= nCount)
1219 break;
1220
1221 if ( maTabs[nTab] )
1222 {
1223 SCCOL nCol = 0;
1224 SCROW nRow = 0;
1225
1226 bool bFound = rMultiMark.IsCellMarked( nCol, nRow );
1227 if (!bFound)
1228 bFound = GetNextMarkedCell( nCol, nRow, nTab, rMultiMark );
1229
1230 while (bFound)
1231 {
1232 ScRefCellValue aCell(*this, ScAddress(nCol, nRow, nTab));
1233
1234 // fdo#32786 TITLE_CASE/SENTENCE_CASE need the extra handling in EditEngine (loop over words/sentences).
1235 // Still use TransliterationWrapper directly for text cells with other transliteration types,
1236 // for performance reasons.
1237 if (aCell.getType() == CELLTYPE_EDIT ||
1238 (aCell.getType() == CELLTYPE_STRING &&
1239 ( nType == TransliterationFlags::SENTENCE_CASE || nType == TransliterationFlags::TITLE_CASE)))
1240 {
1241 if (!pEngine)
1242 pEngine.reset(new ScFieldEditEngine(this, GetEnginePool(), GetEditPool()));
1243
1244 // defaults from cell attributes must be set so right language is used
1245 const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
1246 SfxItemSet aDefaults( pEngine->GetEmptyItemSet() );
1247 if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) )
1248 {
1249 ScPatternAttr aPreviewPattern( *pPattern );
1250 aPreviewPattern.SetStyleSheet(pPreviewStyle);
1251 aPreviewPattern.FillEditItemSet( &aDefaults );
1252 }
1253 else
1254 {
1255 SfxItemSet* pFontSet = GetPreviewFont( nCol, nRow, nTab );
1256 pPattern->FillEditItemSet( &aDefaults, pFontSet );
1257 }
1258 pEngine->SetDefaults( std::move(aDefaults) );
1259 if (aCell.getType() == CELLTYPE_STRING)
1260 pEngine->SetTextCurrentDefaults(aCell.getSharedString()->getString());
1261 else if (aCell.getEditText())
1262 pEngine->SetTextCurrentDefaults(*aCell.getEditText());
1263
1264 pEngine->ClearModifyFlag();
1265
1266 sal_Int32 nLastPar = pEngine->GetParagraphCount();
1267 if (nLastPar)
1268 --nLastPar;
1269 sal_Int32 nTxtLen = pEngine->GetTextLen(nLastPar);
1270 ESelection aSelAll( 0, 0, nLastPar, nTxtLen );
1271
1272 pEngine->TransliterateText( aSelAll, nType );
1273
1274 if ( pEngine->IsModified() )
1275 {
1276 ScEditAttrTester aTester( pEngine.get() );
1277 if ( aTester.NeedsObject() )
1278 {
1279 // remove defaults (paragraph attributes) before creating text object
1280 pEngine->SetDefaults( std::make_unique<SfxItemSet>( pEngine->GetEmptyItemSet() ) );
1281
1282 // The cell will take ownership of the text object instance.
1283 SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
1284 }
1285 else
1286 {
1287 ScSetStringParam aParam;
1288 aParam.setTextInput();
1289 SetString(ScAddress(nCol,nRow,nTab), pEngine->GetText(), &aParam);
1290 }
1291 }
1292 }
1293
1294 else if (aCell.getType() == CELLTYPE_STRING)
1295 {
1296 OUString aOldStr = aCell.getSharedString()->getString();
1297 sal_Int32 nOldLen = aOldStr.getLength();
1298
1299 if ( bConsiderLanguage )
1300 {
1301 SvtScriptType nScript = GetStringScriptType( aOldStr ); //TODO: cell script type?
1302 sal_uInt16 nWhich = ( nScript == SvtScriptType::ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
1303 ( ( nScript == SvtScriptType::COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE :
1305 nLanguage = static_cast<const SvxLanguageItem*>(GetAttr( nCol, nRow, nTab, nWhich ))->GetValue();
1306 }
1307
1308 uno::Sequence<sal_Int32> aOffsets;
1309 OUString aNewStr = aTransliterationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
1310
1311 if ( aNewStr != aOldStr )
1312 {
1313 ScSetStringParam aParam;
1314 aParam.setTextInput();
1315 SetString(ScAddress(nCol,nRow,nTab), aNewStr, &aParam);
1316 }
1317 }
1318 bFound = GetNextMarkedCell( nCol, nRow, nTab, rMultiMark );
1319 }
1320 }
1321 }
1322}
1323
1324/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCTAB MAXTAB
Definition: address.hxx:70
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void SetMapUnit(MapUnit eUnit)
void SetMapMode()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
void IncTab(SCTAB nDelta=1)
Definition: address.hxx:320
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:316
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
SCCOL Col() const
Definition: address.hxx:279
static sal_uInt16 DoUpdateAllCharts(ScDocument &rDoc)
bool IsFormulaDirty(SCROW nRow) const
Definition: column.cxx:3125
bool IsCalcAsShown() const
Definition: docoptio.hxx:81
Use this class as a locale variable to merge number formatter from another document,...
Definition: document.hxx:2661
void UpdateAreaLinks()
Definition: documen8.cxx:1044
void TrackFormulas(SfxHintId nHintId=SfxHintId::ScDataChanged)
Definition: documen7.cxx:524
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:478
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
Definition: document.cxx:3422
bool bAutoCalc
Definition: document.hxx:487
bool SetDdeLinkResultMatrix(size_t nDdePos, const ScMatrixRef &pResults)
Sets a result matrix for the specified DDE link.
Definition: documen8.cxx:1019
void ModifyStyleSheet(SfxStyleSheetBase &rPageStyle, const SfxItemSet &rChanges)
Definition: documen8.cxx:210
void InvalidateTextWidth(std::u16string_view rStyleName)
Definition: documen8.cxx:295
void SC_DLLPUBLIC SetFormulaResults(const ScAddress &rTopPos, const double *pResults, size_t nLen)
Set an array of numerical formula results to a group of contiguous formula cells.
Definition: documen8.cxx:402
std::unique_ptr< SvMemoryStream > pClipData
Definition: document.hxx:392
bool bInLinkUpdate
Definition: document.hxx:510
void LoadDdeLinks(SvStream &rStream)
Definition: documen8.cxx:747
bool ValidRow(SCROW nRow) const
Definition: document.hxx:900
void UpdateRefAreaLinks(UpdateRefMode eUpdateRefMode, const ScRange &r, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: documen8.cxx:1078
void UpdateDrawPrinter()
Definition: documen9.cxx:193
bool RemovePageStyleInUse(std::u16string_view rStrPageStyle)
Definition: documen8.cxx:325
SC_DLLPUBLIC ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2509
void TransliterateText(const ScMarkData &rMultiMark, TransliterationFlags nType)
Definition: documen8.cxx:1205
ScAddress aCurTextWidthCalcPos
Definition: document.hxx:439
std::unique_ptr< ScDocOptions > pDocOptions
Definition: document.hxx:424
VclPtr< SfxPrinter > mpPrinter
Definition: document.hxx:372
EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const
Definition: documen8.cxx:355
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
bool IsClipboard() const
Definition: document.hxx:1594
rtl::Reference< ScPoolHelper > mxPoolHelper
Definition: document.hxx:358
SC_DLLPUBLIC ScMacroManager * GetMacroManager()
Definition: documen8.cxx:377
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
bool IsPageStyleInUse(std::u16string_view rStrPageStyle, SCTAB *pInTab)
Definition: documen8.cxx:310
SC_DLLPUBLIC void CopyStdStylesFrom(const ScDocument &rSrcDoc)
Definition: documen8.cxx:288
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
Definition: documen8.cxx:1149
std::unique_ptr< ScMacroManager > mpMacroMgr
Definition: document.hxx:411
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3626
SC_DLLPUBLIC bool CreateDdeLink(const OUString &rAppl, const OUString &rTopic, const OUString &rItem, sal_uInt8 nMode, const ScMatrixRef &pResults)
Tries to find a DDE link or creates a new, if not extant.
Definition: documen8.cxx:988
bool IsInDdeLinkUpdate() const
Definition: document.hxx:1045
SfxBindings * GetViewBindings()
Definition: documen8.cxx:1183
void KeyInput()
Definition: documen8.cxx:1175
void RepaintRange(const ScRange &rRange)
Definition: documen8.cxx:689
ScInterpreterContext & GetNonThreadedContext() const
Definition: document.hxx:617
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
SC_DLLPUBLIC OutputDevice * GetRefDevice()
Definition: documen8.cxx:199
void UpdateExternalRefLinks(weld::Window *pWin)
Definition: documen8.cxx:789
bool mbIdleEnabled
Definition: document.hxx:509
bool IsInLinkUpdate() const
Definition: documen8.cxx:784
SC_DLLPUBLIC const ScMatrix * GetDdeLinkResultMatrix(size_t nDdePos) const
Returns the result matrix of the specified DDE link.
Definition: documen8.cxx:982
bool HasLinkFormulaNeedingCheck() const
Definition: document.hxx:2213
void SetInLinkUpdate(bool bSet)
Definition: documen8.cxx:776
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:473
std::unique_ptr< ScExtDocOptions > pExtDocOptions
Definition: document.hxx:425
SC_DLLPUBLIC void SetNumberFormat(const ScAddress &rPos, sal_uInt32 nNumberFormat)
Definition: document.cxx:3682
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3391
TableContainer maTabs
Definition: document.hxx:378
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6176
bool bIsClip
Definition: document.hxx:494
std::unique_ptr< ScExternalRefManager > pExternalRefMgr
Definition: document.hxx:410
void SetPrinter(VclPtr< SfxPrinter > const &pNewPrinter)
Definition: documen8.cxx:142
bool IdleCalcTextWidth()
Definition: documen8.cxx:532
static thread_local ScDocumentThreadSpecific maThreadSpecific
Definition: document.hxx:471
SC_DLLPUBLIC void CopyDdeLinks(ScDocument &rDestDoc) const
Definition: documen8.cxx:866
bool GetDdeLinkMode(size_t nDdePos, sal_uInt8 &rnMode) const
Returns the link mode of the specified DDE link.
Definition: documen8.cxx:972
void EnableIdle(bool bDo)
Definition: document.hxx:2208
void ImplDeleteOptions()
Definition: documen8.cxx:107
void SaveDdeLinks(SvStream &rStream) const
Definition: documen8.cxx:709
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1083
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6055
void HandleStuffAfterParallelCalculation(SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter *pInterpreter)
Definition: documen8.cxx:431
void DeleteAreaLinksOnTab(SCTAB nTab)
Definition: documen8.cxx:1059
VclPtr< VirtualDevice > mpVirtualDevice_100th_mm
Definition: document.hxx:373
SfxItemSet * GetPreviewFont()
Definition: document.hxx:1390
bool IsThreadedGroupCalcInProgress() const
Definition: document.hxx:630
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
VirtualDevice * GetVirtualDevice_100th_mm()
Definition: documen8.cxx:182
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:241
std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock
Definition: document.hxx:384
bool GetNextMarkedCell(SCCOL &rCol, SCROW &rRow, SCTAB nTab, const ScMarkData &rMark)
Definition: documen4.cxx:538
void SetLinkFormulaNeedingCheck(bool bSet)
Definition: document.hxx:2214
ScStyleSheet * GetPreviewCellStyle()
Definition: document.hxx:1394
void ImplCreateOptions()
Definition: documen8.cxx:101
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:2502
SC_DLLPUBLIC bool FindDdeLink(std::u16string_view rAppl, std::u16string_view rTopic, std::u16string_view rItem, sal_uInt8 nMode, size_t &rnDdePos)
Tries to find a DDE link with the specified connection data.
Definition: documen8.cxx:954
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: documen8.cxx:114
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:231
SfxObjectShell * mpShell
Definition: document.hxx:371
std::unique_ptr< ScViewOptions > pViewOptions
Definition: document.hxx:423
void SetPrintOptions()
Definition: documen8.cxx:161
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4684
tools::Long GetNeededSize(SCCOL nCol, SCROW nRow, SCTAB nTab, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bWidth, bool bTotalSize=false, bool bInPrintTwips=false)
Definition: document.cxx:4253
bool HasAreaLinks() const
Definition: documen8.cxx:1029
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1936
bool RenamePageStyleInUse(std::u16string_view rOld, const OUString &rNew)
Definition: documen8.cxx:340
bool GetDdeLinkData(size_t nDdePos, OUString &rAppl, OUString &rTopic, OUString &rItem) const
Returns the connection data of the specified DDE link.
Definition: documen8.cxx:960
bool bIsVisible
Definition: document.hxx:497
void CalculateInColumnInThread(ScInterpreterContext &rContext, const ScRange &rCalcRange, unsigned nThisThread, unsigned nThreadsTotal)
Definition: documen8.cxx:411
void FillMatrix(ScMatrix &rMat, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool *pPool=nullptr) const
Definition: documen8.cxx:384
bool IsImportingXML() const
Definition: document.hxx:2227
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
std::unique_ptr< ScChartListenerCollection > pChartListenerCollection
Definition: document.hxx:391
bool NeedsObject() const
Definition: editutil.hxx:102
static bool CheckWidthInvalidate(bool &bNumFormatChanged, const SfxItemSet &rNewAttrs, const SfxItemSet &rOldAttrs)
Definition: global.cxx:186
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
bool IsMultiMarked() const
Definition: markdata.hxx:81
bool IsCellMarked(SCCOL nCol, SCROW nRow, bool bNoSimple=false) const
Definition: markdata.cxx:270
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:101
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
Definition: scmatrix.cxx:3143
void RepaintRange(const ScRange &rRange)
Definition: docuno.cxx:482
static LanguageType GetOptDigitLanguage()
Definition: scmod.cxx:907
void SetStyleSheet(ScStyleSheet *pNewStyle, bool bClearDirectFormat=true)
Definition: patattr.cxx:1306
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
Definition: patattr.cxx:868
static void DeleteInterpretProgress()
Definition: progress.cxx:152
void SetState(sal_uInt64 nVal, sal_uInt64 nNewRange=0)
Definition: progress.hxx:78
static void CreateInterpretProgress(ScDocument *pDoc, bool bWait=true)
Definition: progress.cxx:132
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
Definition: refupdat.cxx:188
OUString aPageStyle
Definition: table.hxx:176
void FillMatrix(ScMatrix &rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool *pPool) const
Definition: table1.cxx:2609
ScColContainer aCol
Definition: table.hxx:162
void CalculateInColumnInThread(ScInterpreterContext &rContext, SCCOL nColStart, SCCOL nColEnd, SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal)
Definition: table1.cxx:2642
void SetFormulaResults(SCCOL nCol, SCROW nRow, const double *pResults, size_t nLen)
Definition: table1.cxx:2634
void HandleStuffAfterParallelCalculation(SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter *pInterpreter)
Definition: table1.cxx:2659
SCCOL ClampToAllocatedColumns(SCCOL nCol) const
Definition: table.hxx:1163
void Invalidate(sal_uInt16 nId)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
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
bool IsModified() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
virtual void SetModified(bool bModified=true)
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual SfxItemSet & GetItemSet()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual SfxObjectShell * GetObjectShell() override
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
LanguageType GetLanguage() const
SvStream & WriteUInt16(sal_uInt16 nUInt16)
sal_Int32 GetVersion() const
rtl_TextEncoding GetStreamCharSet() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
static bool IsCTLFontEnabled()
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
sal_uInt16 GetLen() const
sal_uInt16 GetCodeLen() const
bool HasOpCodeRPN(OpCode) const
bool HasOpCode(OpCode) const
const sfx2::LinkManager * getExistingLinkManager() const
sfx2::LinkManager * getLinkManager(bool bCreate=true)
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
void InsertDDELink(SvBaseLink *, const OUString &rServer, std::u16string_view rTopic, std::u16string_view rItem)
void Remove(SvBaseLink const *pLink)
const SvBaseLinks & GetLinks() const
const OUString & getString() const
OUString transliterate(const OUString &rStr, sal_Int32 nStart, sal_Int32 nLen) const
bool needLanguageForTheMode() const
int nCount
constexpr double nPPTX
constexpr double nPPTY
#define CALCMAX
Definition: documen8.cxx:467
const sal_uInt8 SC_DDE_IGNOREMODE
Definition: document.hxx:304
const sal_uInt8 SC_DDE_DEFAULT
Definition: document.hxx:301
EEHorizontalTextDirection
#define SOFFICE_FILEFORMAT_40
SvxFrameDirection
@ CELLTYPE_EDIT
Definition: global.hxx:277
@ CELLTYPE_STRING
Definition: global.hxx:275
UpdateRefMode
Definition: global.hxx:301
#define TEXTWIDTH_DIRTY
Definition: globalnames.hxx:19
void * p
sal_Int64 n
#define LANGUAGE_SYSTEM
#define LANGUAGE_DONTKNOW
SvtScriptType
sal_uInt16 nPos
SvBaseLink * pLink
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
int i
std::vector< tools::SvRef< SvBaseLink > > SvBaseLinks
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
const char GetValue[]
ocWebservice
ocDde
SfxItemState
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
ScRefUpdateRes
Definition: refupdat.hxx:30
@ UR_NOTHING
Reference not affected, no change at all.
Definition: refupdat.hxx:31
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
constexpr TypedWhichId< SvxLanguageItem > ATTR_CTL_FONT_LANGUAGE(120)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr sal_uInt16 ATTR_PATTERN_START(100)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SvxFrameDirectionItem > ATTR_WRITINGDIR(138)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
constexpr sal_uInt16 ATTR_PATTERN_END(155)
constexpr TypedWhichId< SvxLanguageItem > ATTR_CJK_FONT_LANGUAGE(115)
#define SC_MOD()
Definition: scmod.hxx:247
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
OUString sMessage
ScInterpreterContext * pContext
Definition: document.hxx:310
std::unique_ptr< ScRecursionHelper > xRecursionHelper
Definition: document.hxx:309
std::vector< DelayedSetNumberFormat > maDelayedSetNumberFormat
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
const EditTextObject * getEditText() const
Definition: cellvalue.hxx:136
const svl::SharedString * getSharedString() const
Definition: cellvalue.hxx:135
CellType getType() const
Definition: cellvalue.hxx:133
Store parameters used in the ScDocument::SetString() method.
Definition: stringutil.hxx:35
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is.
Definition: stringutil.cxx:39
TransliterationFlags
unsigned char sal_uInt8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
sal_Int32 SCROW
Definition: types.hxx:17
SfxPrinterChangeFlags