LibreOffice Module sc (master) 1
table5.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>
21#include <attrib.hxx>
22#include <formulacell.hxx>
23#include <table.hxx>
24#include <column.hxx>
25#include <document.hxx>
26#include <drwlayer.hxx>
27#include <global.hxx>
28#include <stlpool.hxx>
29#include <tabprotection.hxx>
30#include <globstr.hrc>
31#include <scresid.hxx>
32#include <segmenttree.hxx>
33#include <columniterator.hxx>
34#include <globalnames.hxx>
35#include <scmod.hxx>
36#include <printopt.hxx>
37#include <bcaslot.hxx>
38#include <compressedarray.hxx>
39#include <userdat.hxx>
40#include <conditio.hxx>
41#include <colorscale.hxx>
42#include <cellform.hxx>
43
44#include <com/sun/star/sheet/TablePageBreakData.hpp>
45
46#include <editeng/brushitem.hxx>
47#include <editeng/colritem.hxx>
48#include <osl/diagnose.h>
49#include <svl/numformat.hxx>
50#include <svl/zformat.hxx>
51
52#include <algorithm>
53#include <limits>
54
55using ::com::sun::star::uno::Sequence;
56using ::com::sun::star::sheet::TablePageBreakData;
57using ::std::set;
58
59void ScTable::UpdatePageBreaks(const ScRange* pUserArea)
60{
62 return;
63
64 // pUserArea != NULL -> print area is specified. We need to force-update
65 // the page breaks.
66
67 if (!pUserArea)
68 {
69 if (!bPageSizeValid)
70 return;
71
72 // Always update breaks if force breaks option has changed
73 if (mbPageBreaksValid && mbForceBreaks == SC_MOD()->GetPrintOptions().GetForceBreaks())
74 return;
75 }
76
77 SfxStyleSheetBase* pStyle
78 = rDocument.GetStyleSheetPool()->Find(aPageStyle, SfxStyleFamily::Page);
79 if (!pStyle)
80 {
81 OSL_FAIL("UpdatePageBreaks: Style not found");
82 return;
83 }
84 SfxItemSet* pStyleSet = &pStyle->GetItemSet();
85
86 SCCOL nStartCol = 0;
87 SCROW nStartRow = 0;
88 SCCOL nEndCol = rDocument.MaxCol();
89 SCROW nEndRow = rDocument.MaxRow();
90 if (pUserArea)
91 {
92 nStartCol = pUserArea->aStart.Col();
93 nStartRow = pUserArea->aStart.Row();
94 nEndCol = pUserArea->aEnd.Col();
95 nEndRow = pUserArea->aEnd.Row();
96 }
97 else
98 {
99 sal_uInt16 nAreaCount = GetPrintRangeCount();
100 if (nAreaCount > 1)
101 {
102 // Show nothing, when multiple ranges
103
104 for (SCCOL nX : GetColumnsRange(0, rDocument.MaxCol()))
105 RemoveColBreak(nX, true, false);
106
108
109 return;
110 }
111 else if (nAreaCount == 1)
112 {
113 const ScRange* pArea = GetPrintRange(0);
114 if (pArea)
115 {
116 nStartCol = pArea->aStart.Col();
117 nStartRow = pArea->aStart.Row();
118 nEndCol = pArea->aEnd.Col();
119 nEndRow = pArea->aEnd.Row();
120 }
121 } // otherwise show everything
122 }
123
124 // get bSkipColBreaks/bSkipRowBreaks flags:
125 // fdo#40788 - print range scale settings can cause manual breaks to be
126 // ignored (see below). This behaviour may now be set by the user.
127 mbForceBreaks = SC_MOD()->GetPrintOptions().GetForceBreaks();
128 bool bSkipColBreaks = false;
129 bool bSkipRowBreaks = false;
130
131 if (!mbForceBreaks)
132 {
133 if (const SfxUInt16Item* pItem = pStyleSet->GetItemIfSet(ATTR_PAGE_SCALETOPAGES, false))
134 {
135 bSkipColBreaks = bSkipRowBreaks = pItem->GetValue() > 0;
136 }
137
138 const ScPageScaleToItem* pScaleToItem;
139 if (!bSkipColBreaks && (pScaleToItem = pStyleSet->GetItemIfSet(ATTR_PAGE_SCALETO, false)))
140 {
141 // #i54993# when fitting to width or height, ignore only manual breaks in that direction
142 if (pScaleToItem->GetWidth() > 0)
143 bSkipColBreaks = true;
144 if (pScaleToItem->GetHeight() > 0)
145 bSkipRowBreaks = true;
146 }
147 }
148
149 tools::Long nPageSizeX = aPageSizeTwips.Width();
150 tools::Long nPageSizeY = aPageSizeTwips.Height();
151
152 // Beginning: Remove breaks
153
154 for (SCCOL nX : GetColumnsRange(0, nStartCol - 1))
155 RemoveColBreak(nX, true, false);
156 RemoveRowPageBreaks(0, nStartRow - 1);
157
158 if (nStartCol > 0)
159 SetColBreak(nStartCol, true, false); // AREABREAK
160 if (nStartRow > 0)
161 SetRowBreak(nStartRow, true, false); // AREABREAK
162
163 // Middle part: Distribute breaks
164
165 bool bRepeatCol = (nRepeatStartX != SCCOL_REPEAT_NONE);
166 bool bColFound = false;
167 tools::Long nSizeX = 0;
168 for (SCCOL nX = nStartCol; nX <= nEndCol; nX++)
169 {
170 bool bStartOfPage = false;
171 tools::Long nThisX = ColHidden(nX) ? 0 : mpColWidth->GetValue(nX);
172 bool bManualBreak = HasColManualBreak(nX);
173 if ((nSizeX + nThisX > nPageSizeX) || (bManualBreak && !bSkipColBreaks))
174 {
175 SetColBreak(nX, true, false);
176 nSizeX = 0;
177 bStartOfPage = true;
178 }
179 else if (nX != nStartCol)
180 RemoveColBreak(nX, true, false);
181 else
182 bStartOfPage = true;
183
184 if (bStartOfPage && bRepeatCol && nX > nRepeatStartX && !bColFound)
185 {
186 // subtract size of repeat columns from page size
187 for (SCCOL i = nRepeatStartX; i <= nRepeatEndX; i++)
188 nPageSizeX -= ColHidden(i) ? 0 : mpColWidth->GetValue(i);
189 while (nX <= nRepeatEndX)
190 RemoveColBreak(++nX, true, false);
191 bColFound = true;
192 }
193
194 nSizeX += nThisX;
195 }
196
197 // Remove all page breaks in range.
198 RemoveRowPageBreaks(nStartRow + 1, nEndRow);
199
200 // And set new page breaks.
201 bool bRepeatRow = (nRepeatStartY != SCROW_REPEAT_NONE);
202 bool bRowFound = false;
203 tools::Long nSizeY = 0;
206 SCROW nNextManualBreak = GetNextManualBreak(nStartRow); // -1 => no more manual breaks
207 for (SCROW nY = nStartRow; nY <= nEndRow; ++nY)
208 {
209 bool bStartOfPage = false;
210 bool bThisRowHidden = false;
211 const bool bHasValue = aIterHidden.getValue(nY, bThisRowHidden);
212 assert(bHasValue);
213 (void)bHasValue;
214 tools::Long nThisY = 0;
215 if (!bThisRowHidden)
216 {
217 sal_uInt16 nTmp;
218 const bool bHasHeight = aIterHeights.getValue(nY, nTmp);
219 assert(bHasHeight);
220 if (bHasHeight)
221 nThisY = static_cast<tools::Long>(nTmp);
222 }
223
224 bool bManualBreak = false;
225 if (nNextManualBreak >= 0)
226 {
227 bManualBreak = (nY == nNextManualBreak);
228 if (nY >= nNextManualBreak)
229 // Query the next manual break position.
230 nNextManualBreak = GetNextManualBreak(nY + 1);
231 }
232
233 if ((nSizeY + nThisY > nPageSizeY) || (bManualBreak && !bSkipRowBreaks))
234 {
235 SetRowBreak(nY, true, false);
236 nSizeY = 0;
237 bStartOfPage = true;
238 }
239 else if (nY != nStartRow)
240 ; // page break already removed
241 else
242 bStartOfPage = true;
243
244 if (bStartOfPage && bRepeatRow && nY > nRepeatStartY && !bRowFound)
245 {
246 // subtract size of repeat rows from page size
248#if OSL_DEBUG_LEVEL > 0
249 if (nHeights == ::std::numeric_limits<tools::Long>::max())
250 OSL_FAIL("ScTable::UpdatePageBreaks: row heights overflow");
251#endif
252 nPageSizeY -= nHeights;
253 if (nY <= nRepeatEndY)
255 bRowFound = true;
256 }
257
258 if (bThisRowHidden)
259 {
260 // Hidden row range. Skip them unless there is a manual break.
261 SCROW nLastCommon = aIterHidden.getLastPos();
262 if (nNextManualBreak >= 0)
263 nLastCommon = ::std::min(nLastCommon, nNextManualBreak - 1);
264 nY = nLastCommon;
265 }
266 else
267 {
268 // Visible row range.
269
270 SCROW nLastHidden = aIterHidden.getLastPos();
271 SCROW nLastHeight = aIterHeights.getLastPos();
272 SCROW nLastCommon = ::std::min(nLastHidden, nLastHeight);
273 if (nNextManualBreak >= 0)
274 nLastCommon = ::std::min(nLastCommon, nNextManualBreak - 1);
275
276 if (nLastCommon > nY)
277 {
278 tools::Long nMaxMultiple = static_cast<tools::Long>(nLastCommon - nY);
279 tools::Long nMultiple = (nPageSizeY - nSizeY) / nThisY;
280 if (nMultiple > nMaxMultiple)
281 nMultiple = nMaxMultiple;
282 if (nMultiple > 1)
283 {
284 nSizeY += nThisY * (nMultiple - 1);
285 nY += nMultiple - 1;
286 }
287 }
288 }
289
290 nSizeY += nThisY;
291 }
292
293 // End: Remove Break
294
295 if (nEndCol < rDocument.MaxCol())
296 {
297 SetColBreak(nEndCol + 1, true, false); // AREABREAK
298 for (SCCOL nCol : GetColumnsRange(nEndCol + 2, rDocument.MaxCol()))
299 RemoveColBreak(nCol, true, false);
300 }
301 if (nEndRow < rDocument.MaxRow())
302 {
303 SetRowBreak(nEndRow + 1, true, false); // AREABREAK
304 if (nEndRow + 2 <= rDocument.MaxRow())
305 RemoveRowPageBreaks(nEndRow + 2, rDocument.MaxRow());
306 }
308 = !pUserArea; // #i116881# the valid flag can only apply to the "no user area" case
309}
310
312{
313 maRowManualBreaks.clear();
314 maColManualBreaks.clear();
316
317 SetStreamValid(false);
318}
319
321{
322 return !maRowManualBreaks.empty() || !maColManualBreaks.empty();
323}
324
325void ScTable::SetRowManualBreaks(::std::set<SCROW>&& rBreaks)
326{
327 maRowManualBreaks = std::move(rBreaks);
329 SetStreamValid(false);
330}
331
332void ScTable::SetColManualBreaks(::std::set<SCCOL>&& rBreaks)
333{
334 maColManualBreaks = std::move(rBreaks);
336 SetStreamValid(false);
337}
338
339void ScTable::GetAllRowBreaks(set<SCROW>& rBreaks, bool bPage, bool bManual) const
340{
341 if (bPage)
342 rBreaks = maRowPageBreaks;
343
344 if (bManual)
345 {
347 inserter(rBreaks, rBreaks.begin()));
348 }
349}
350
351void ScTable::GetAllColBreaks(set<SCCOL>& rBreaks, bool bPage, bool bManual) const
352{
353 if (bPage)
354 rBreaks = maColPageBreaks;
355
356 if (bManual)
357 {
359 inserter(rBreaks, rBreaks.begin()));
360 }
361}
362
364{
365 if (!ValidRow(nRow))
366 return false;
367
368 return maRowPageBreaks.find(nRow) != maRowPageBreaks.end();
369}
370
372{
373 if (!ValidCol(nCol))
374 return false;
375
376 return maColPageBreaks.find(nCol) != maColPageBreaks.end();
377}
378
380{
381 if (!ValidRow(nRow))
382 return false;
383
384 return maRowManualBreaks.find(nRow) != maRowManualBreaks.end();
385}
386
388{
389 if (!ValidCol(nCol))
390 return false;
391
392 return maColManualBreaks.find(nCol) != maColManualBreaks.end();
393}
394
396{
397 set<SCROW>::const_iterator itr = maRowManualBreaks.lower_bound(nRow);
398 return itr == maRowManualBreaks.end() ? -1 : *itr;
399}
400
402{
403 if (!ValidRow(nStartRow) || !ValidRow(nEndRow))
404 return;
405
406 set<SCROW>::iterator low = maRowPageBreaks.lower_bound(nStartRow);
407 set<SCROW>::iterator high = maRowPageBreaks.upper_bound(nEndRow);
408 maRowPageBreaks.erase(low, high);
409}
410
411void ScTable::RemoveRowBreak(SCROW nRow, bool bPage, bool bManual)
412{
413 if (!ValidRow(nRow))
414 return;
415
416 if (bPage)
417 maRowPageBreaks.erase(nRow);
418
419 if (bManual)
420 {
421 maRowManualBreaks.erase(nRow);
423 }
424}
425
426void ScTable::RemoveColBreak(SCCOL nCol, bool bPage, bool bManual)
427{
428 if (!ValidCol(nCol))
429 return;
430
431 if (bPage)
432 maColPageBreaks.erase(nCol);
433
434 if (bManual)
435 {
436 maColManualBreaks.erase(nCol);
438 }
439}
440
441void ScTable::SetRowBreak(SCROW nRow, bool bPage, bool bManual)
442{
443 if (!ValidRow(nRow))
444 return;
445
446 if (bPage)
447 maRowPageBreaks.insert(nRow);
448
449 if (bManual)
450 {
451 maRowManualBreaks.insert(nRow);
453 }
454}
455
456void ScTable::SetColBreak(SCCOL nCol, bool bPage, bool bManual)
457{
458 if (!ValidCol(nCol))
459 return;
460
461 if (bPage)
462 maColPageBreaks.insert(nCol);
463
464 if (bManual)
465 {
466 maColManualBreaks.insert(nCol);
468 }
469}
470
471Sequence<TablePageBreakData> ScTable::GetRowBreakData() const
472{
473 using ::std::inserter;
474
475 set<SCROW> aRowBreaks = maRowPageBreaks;
477 inserter(aRowBreaks, aRowBreaks.begin()));
478
479 Sequence<TablePageBreakData> aSeq(aRowBreaks.size());
480 std::transform(aRowBreaks.begin(), aRowBreaks.end(), aSeq.getArray(), [this](const SCROW nRow) {
481 return TablePageBreakData(nRow, HasRowManualBreak(nRow));
482 });
483
484 return aSeq;
485}
486
487bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const
488{
489 if (!ValidRow(nRow))
490 {
491 if (pFirstRow)
492 *pFirstRow = nRow;
493 if (pLastRow)
494 *pLastRow = nRow;
495 return true;
496 }
497
499 if (!mpHiddenRows->getRangeData(nRow, aData))
500 {
501 // search failed.
502 if (pFirstRow)
503 *pFirstRow = nRow;
504 if (pLastRow)
505 *pLastRow = nRow;
506 return true;
507 }
508
509 if (pFirstRow)
510 *pFirstRow = aData.mnRow1;
511 if (pLastRow)
512 *pLastRow = aData.mnRow2;
513
514 return aData.mbValue;
515}
516
517bool ScTable::RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const
518{
519 if (!ValidRow(nRow))
520 {
521 if (pFirstRow)
522 *pFirstRow = nRow;
523 if (pLastRow)
524 *pLastRow = nRow;
525 return true;
526 }
527
529 if (!mpHiddenRows->getRangeDataLeaf(nRow, aData))
530 {
531 // search failed.
532 if (pFirstRow)
533 *pFirstRow = nRow;
534 if (pLastRow)
535 *pLastRow = nRow;
536 return true;
537 }
538
539 if (pFirstRow)
540 *pFirstRow = aData.mnRow1;
541 if (pLastRow)
542 *pLastRow = aData.mnRow2;
543
544 return aData.mbValue;
545}
546
547bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const
548{
549 SCROW nRow = nStartRow;
550 while (nRow <= nEndRow)
551 {
552 SCROW nLastRow = -1;
553 bool bHidden = RowHidden(nRow, nullptr, &nLastRow);
554 if (bHidden)
555 return true;
556
557 nRow = nLastRow + 1;
558 }
559 return false;
560}
561
562bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) const
563{
564 if (!ValidCol(nCol))
565 return true;
566
568 if (!mpHiddenCols->getRangeData(nCol, aData))
569 return true;
570
571 if (pFirstCol)
572 *pFirstCol = aData.mnCol1;
573 if (pLastCol)
574 *pLastCol = aData.mnCol2;
575
576 return aData.mbValue;
577}
578
579bool ScTable::SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden)
580{
581 bool bChanged = false;
582 if (bHidden)
583 bChanged = mpHiddenRows->setTrue(nStartRow, nEndRow);
584 else
585 bChanged = mpHiddenRows->setFalse(nStartRow, nEndRow);
586
587 // Cell anchored objects might change visibility
588 ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer();
589 if (pDrawLayer)
590 {
591 std::vector<SdrObject*> aRowDrawObjects;
592 aRowDrawObjects = pDrawLayer->GetObjectsAnchoredToRows(GetTab(), nStartRow, nEndRow);
593 for (auto aObj : aRowDrawObjects)
594 {
596 if (pData)
597 {
598 if (bHidden)
599 aObj->SetVisible(false);
600 else if (!GetDoc().ColHidden(pData->maStart.Col(), pData->maStart.Tab()))
601 {
602 // Only change visibility if object is not hidden by a hidden col
603 aObj->SetVisible(true);
604 }
605 }
606 }
607 }
608
609 if (bChanged)
610 {
611 SetStreamValid(false);
612
613 { // Scoped bulk broadcast.
614 // Only subtotal formula cells will accept the notification of
615 // SfxHintId::ScHiddenRowsChanged, leaving the bulk will track
616 // those and broadcast SfxHintId::ScDataChanged to notify all
617 // dependents.
618 ScBulkBroadcast aBulkBroadcast(rDocument.GetBASM(), SfxHintId::ScDataChanged);
619 for (SCCOL i = 0; i < aCol.size(); i++)
620 {
621 aCol[i].BroadcastRows(nStartRow, nEndRow, SfxHintId::ScHiddenRowsChanged);
622 }
623 }
624 }
625
626 return bChanged;
627}
628
629void ScTable::SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden)
630{
631 bool bChanged = false;
632 if (bHidden)
633 bChanged = mpHiddenCols->setTrue(nStartCol, nEndCol);
634 else
635 bChanged = mpHiddenCols->setFalse(nStartCol, nEndCol);
636
637 // Cell anchored objects might change visibility
638 ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer();
639 if (pDrawLayer)
640 {
641 std::vector<SdrObject*> aColDrawObjects;
642 aColDrawObjects = pDrawLayer->GetObjectsAnchoredToCols(GetTab(), nStartCol, nEndCol);
643 for (auto aObj : aColDrawObjects)
644 {
646 if (pData)
647 {
648 if (bHidden)
649 aObj->SetVisible(false);
650 else if (!GetDoc().RowHidden(pData->maStart.Row(), pData->maStart.Tab()))
651 {
652 // Only change visibility if object is not hidden by a hidden row
653 aObj->SetVisible(true);
654 }
655 }
656 }
657 }
658
659 if (bChanged)
660 SetStreamValid(false);
661}
662
663void ScTable::CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol)
664{
665 SCCOL nCol = nStartCol;
666 while (nCol <= nEndCol)
667 {
668 SCCOL nLastCol = -1;
669 bool bHidden = rTable.ColHidden(nCol, nullptr, &nLastCol);
670 if (nLastCol > nEndCol)
671 nLastCol = nEndCol;
672
673 SetColHidden(nCol, nLastCol, bHidden);
674 nCol = nLastCol + 1;
675 }
676}
677
678void ScTable::CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow)
679{
680 SCROW nRow = nStartRow;
681 while (nRow <= nEndRow)
682 {
683 SCROW nLastRow = -1;
684 bool bHidden = rTable.RowHidden(nRow, nullptr, &nLastRow);
685 if (nLastRow > nEndRow)
686 nLastRow = nEndRow;
687 SetRowHidden(nRow, nLastRow, bHidden);
688 nRow = nLastRow + 1;
689 }
690}
691
692void ScTable::CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow,
693 SCROW nSrcOffset)
694{
695 SCROW nRow = nStartRow;
697 while (nRow <= nEndRow)
698 {
699 if (!rSrcTable.mpRowHeights->getRangeData(nRow + nSrcOffset, aSrcData))
700 // Something is wrong !
701 return;
702
703 SCROW nLastRow = aSrcData.mnRow2 - nSrcOffset;
704 if (nLastRow > nEndRow)
705 nLastRow = nEndRow;
706
707 mpRowHeights->setValue(nRow, nLastRow, aSrcData.mnValue);
708 nRow = nLastRow + 1;
709 }
710}
711
712SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const
713{
714 SCROW nRow = nStartRow;
716 while (nRow <= nEndRow)
717 {
718 if (!ValidRow(nRow))
719 break;
720
721 if (!mpHiddenRows->getRangeData(nRow, aData))
722 // failed to get range data.
723 break;
724
725 if (!aData.mbValue)
726 // visible row found
727 return nRow;
728
729 nRow = aData.mnRow2 + 1;
730 }
731
732 return ::std::numeric_limits<SCROW>::max();
733}
734
735SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const
736{
737 SCROW nRow = nEndRow;
739 while (nRow >= nStartRow)
740 {
741 if (!ValidRow(nRow))
742 break;
743
744 if (!mpHiddenRows->getRangeData(nRow, aData))
745 // failed to get range data.
746 break;
747
748 if (!aData.mbValue)
749 // visible row found
750 return nRow;
751
752 nRow = aData.mnRow1 - 1;
753 }
754
755 return ::std::numeric_limits<SCROW>::max();
756}
757
759{
760 SCROW nCount = 0;
761 SCROW nRow = nStartRow;
763 while (nRow <= nEndRow)
764 {
765 if (!mpHiddenRows->getRangeData(nRow, aData))
766 break;
767
768 if (aData.mnRow2 > nEndRow)
769 aData.mnRow2 = nEndRow;
770
771 if (!aData.mbValue)
772 nCount += aData.mnRow2 - nRow + 1;
773
774 nRow = aData.mnRow2 + 1;
775 }
776 return nCount;
777}
778
779SCROW ScTable::CountHiddenRows(SCROW nStartRow, SCROW nEndRow) const
780{
781 SCROW nCount = 0;
782 SCROW nRow = nStartRow;
784 while (nRow <= nEndRow)
785 {
786 if (!mpHiddenRows->getRangeData(nRow, aData))
787 break;
788
789 if (aData.mnRow2 > nEndRow)
790 aData.mnRow2 = nEndRow;
791
792 if (aData.mbValue)
793 nCount += aData.mnRow2 - nRow + 1;
794
795 nRow = aData.mnRow2 + 1;
796 }
797 return nCount;
798}
799
800tools::Long ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero) const
801{
802 tools::Long nHeight = 0;
803 SCROW nRow = nStartRow;
805 while (nRow <= nEndRow)
806 {
807 if (!mpHiddenRows->getRangeData(nRow, aData))
808 break;
809
810 if (aData.mnRow2 > nEndRow)
811 aData.mnRow2 = nEndRow;
812
813 if (!(bHiddenAsZero && aData.mbValue))
814 // visible row range.
815 nHeight += mpRowHeights->getSumValue(nRow, aData.mnRow2);
816
817 nRow = aData.mnRow2 + 1;
818 }
819
820 return nHeight;
821}
822
824{
825 assert(nStartCol <= nEndCol);
826 SCCOL nCount = 0;
827 SCCOL nCol = nStartCol;
829 while (nCol <= nEndCol)
830 {
831 if (!mpHiddenCols->getRangeData(nCol, aData))
832 break;
833
834 if (aData.mnCol2 > nEndCol)
835 aData.mnCol2 = nEndCol;
836
837 if (!aData.mbValue)
838 nCount += aData.mnCol2 - nCol + 1;
839
840 nCol = aData.mnCol2 + 1;
841 }
842 return nCount;
843}
844
845SCCOL ScTable::CountHiddenCols(SCCOL nStartCol, SCCOL nEndCol) const
846{
847 SCCOL nCount = 0;
848 SCCOL nCol = nStartCol;
850 while (nCol <= nEndCol)
851 {
852 if (!mpHiddenCols->getRangeData(nCol, aData))
853 break;
854
855 if (aData.mnCol2 > nEndCol)
856 aData.mnCol2 = nEndCol;
857
858 if (aData.mbValue)
859 nCount += aData.mnCol2 - nCol + 1;
860
861 nCol = aData.mnCol2 + 1;
862 }
863 return nCount;
864}
865
867{
868 if (bCol)
869 {
870 SCCOL nCol = static_cast<SCCOL>(nPos);
871 if (ColHidden(nCol))
872 {
873 for (SCCOL i = nCol + 1; i <= rDocument.MaxCol(); ++i)
874 {
875 if (!ColHidden(i))
876 return i - 1;
877 }
878 }
879 }
880 else
881 {
882 SCROW nRow = static_cast<SCROW>(nPos);
883 SCROW nLastRow;
884 if (RowHidden(nRow, nullptr, &nLastRow))
885 return static_cast<SCCOLROW>(nLastRow);
886 }
887 return ::std::numeric_limits<SCCOLROW>::max();
888}
889
890bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const
891{
892 if (!ValidRow(nRow))
893 return false;
894
896 if (!mpFilteredRows->getRangeData(nRow, aData))
897 // search failed.
898 return false;
899
900 if (pFirstRow)
901 *pFirstRow = aData.mnRow1;
902 if (pLastRow)
903 *pLastRow = aData.mnRow2;
904
905 return aData.mbValue;
906}
907
908bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) const
909{
910 if (!ValidCol(nCol))
911 return false;
912
914 if (!mpFilteredCols->getRangeData(nCol, aData))
915 // search failed.
916 return false;
917
918 if (pFirstCol)
919 *pFirstCol = aData.mnCol1;
920 if (pLastCol)
921 *pLastCol = aData.mnCol2;
922
923 return aData.mbValue;
924}
925
926bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const
927{
928 SCROW nRow = nStartRow;
929 while (nRow <= nEndRow)
930 {
931 SCROW nLastRow = nRow;
932 bool bFiltered = RowFiltered(nRow, nullptr, &nLastRow);
933 if (bFiltered)
934 return true;
935
936 nRow = nLastRow + 1;
937 }
938 return false;
939}
940
941void ScTable::CopyColFiltered(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol)
942{
943 SCCOL nCol = nStartCol;
944 while (nCol <= nEndCol)
945 {
946 SCCOL nLastCol = -1;
947 bool bFiltered = rTable.ColFiltered(nCol, nullptr, &nLastCol);
948 if (nLastCol > nEndCol)
949 nLastCol = nEndCol;
950
951 SetColFiltered(nCol, nLastCol, bFiltered);
952 nCol = nLastCol + 1;
953 }
954}
955
956void ScTable::CopyRowFiltered(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow)
957{
958 SCROW nRow = nStartRow;
959 while (nRow <= nEndRow)
960 {
961 SCROW nLastRow = -1;
962 bool bFiltered = rTable.RowFiltered(nRow, nullptr, &nLastRow);
963 if (nLastRow > nEndRow)
964 nLastRow = nEndRow;
965 SetRowFiltered(nRow, nLastRow, bFiltered);
966 nRow = nLastRow + 1;
967 }
968}
969
970void ScTable::SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered)
971{
972 if (bFiltered)
973 mpFilteredRows->setTrue(nStartRow, nEndRow);
974 else
975 mpFilteredRows->setFalse(nStartRow, nEndRow);
976}
977
978void ScTable::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered)
979{
980 if (bFiltered)
981 mpFilteredCols->setTrue(nStartCol, nEndCol);
982 else
983 mpFilteredCols->setFalse(nStartCol, nEndCol);
984}
985
987{
988 SCROW nRow = nStartRow;
990 while (nRow <= nEndRow)
991 {
992 if (!ValidRow(nRow))
993 break;
994
995 if (!mpFilteredRows->getRangeData(nRow, aData))
996 // failed to get range data.
997 break;
998
999 if (!aData.mbValue)
1000 // non-filtered row found
1001 return nRow;
1002
1003 nRow = aData.mnRow2 + 1;
1004 }
1005
1006 return ::std::numeric_limits<SCROW>::max();
1007}
1008
1010{
1011 SCROW nRow = nEndRow;
1013 while (nRow >= nStartRow)
1014 {
1015 if (!ValidRow(nRow))
1016 break;
1017
1018 if (!mpFilteredRows->getRangeData(nRow, aData))
1019 // failed to get range data.
1020 break;
1021
1022 if (!aData.mbValue)
1023 // non-filtered row found
1024 return nRow;
1025
1026 nRow = aData.mnRow1 - 1;
1027 }
1028
1029 return ::std::numeric_limits<SCROW>::max();
1030}
1031
1033{
1034 SCROW nCount = 0;
1035 SCROW nRow = nStartRow;
1037 while (nRow <= nEndRow)
1038 {
1039 if (!mpFilteredRows->getRangeData(nRow, aData))
1040 break;
1041
1042 if (aData.mnRow2 > nEndRow)
1043 aData.mnRow2 = nEndRow;
1044
1045 if (!aData.mbValue)
1046 nCount += aData.mnRow2 - nRow + 1;
1047
1048 nRow = aData.mnRow2 + 1;
1049 }
1050 return nCount;
1051}
1052
1054{
1055 Color backgroundColor;
1056 bool bHasConditionalBackgroundColor = false;
1057 // Check background color from cond. formatting
1058 const ScPatternAttr* pPattern = GetDoc().GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
1059 if (pPattern)
1060 {
1061 if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
1062 {
1063 const SfxItemSet* pCondSet = GetDoc().GetCondResult(aPos.Col(), aPos.Row(), aPos.Tab());
1064 const SvxBrushItem* pBackgroundColor = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
1065 backgroundColor = pBackgroundColor->GetColor();
1066 bHasConditionalBackgroundColor = true;
1067 }
1068 }
1069
1070 // Color scale needs a different handling
1071 ScConditionalFormat* pCondFormat = GetDoc().GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
1072 if (pCondFormat)
1073 {
1074 for (size_t i = 0; i < pCondFormat->size(); i++)
1075 {
1076 auto aEntry = pCondFormat->GetEntry(i);
1077 if (aEntry->GetType() == ScFormatEntry::Type::Colorscale)
1078 {
1079 const ScColorScaleFormat* pColFormat
1080 = static_cast<const ScColorScaleFormat*>(aEntry);
1081 std::optional<Color> oColor = pColFormat->GetColor(aPos);
1082 if (oColor)
1083 {
1084 backgroundColor = oColor.value();
1085 bHasConditionalBackgroundColor = true;
1086 }
1087 }
1088 }
1089 }
1090 return bHasConditionalBackgroundColor ? backgroundColor
1091 : GetDoc().GetAttr(aPos, ATTR_BACKGROUND)->GetColor();
1092}
1093
1095{
1096 // Check text & background color from cond. formatting
1097 const ScPatternAttr* pPattern = GetDoc().GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
1098 if (pPattern)
1099 {
1100 if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
1101 {
1102 const SfxItemSet* pCondSet = GetDoc().GetCondResult(aPos.Col(), aPos.Row(), aPos.Tab());
1103 const SvxColorItem* pColor = &pPattern->GetItem(ATTR_FONT_COLOR, pCondSet);
1104 return pColor->GetValue();
1105 }
1106
1107 if (pPattern->GetItem(ATTR_VALUE_FORMAT).GetValue())
1108 {
1109 SvNumberFormatter* pNumberFormatter = GetDoc().GetFormatTable();
1110 const SfxUInt32Item pItem = pPattern->GetItem(ATTR_VALUE_FORMAT);
1111 auto& rDoc = const_cast<ScDocument&>(GetDoc());
1112 const Color* pColor;
1113 ScRefCellValue aCell(rDoc, aPos);
1114 ScCellFormat::GetString(rDoc, aPos, pItem.GetValue(), &pColor, *pNumberFormatter, false,
1115 false);
1116 if (pColor)
1117 return *pColor;
1118 }
1119 }
1120
1121 const SvxColorItem* pColor = GetDoc().GetAttr(aPos, ATTR_FONT_COLOR);
1122 return pColor->GetValue();
1123}
1124
1126{
1127 return bool(pRowFlags->GetValue(nRow) & CRFlags::ManualSize);
1128}
1129
1130namespace
1131{
1132void lcl_syncFlags(const ScDocument* pDocument, ScFlatBoolColSegments& rColSegments,
1133 const ScFlatBoolRowSegments& rRowSegments,
1135 ScBitMaskCompressedArray<SCROW, CRFlags>* pRowFlags, const CRFlags nFlagMask)
1136{
1137 CRFlags nFlagMaskComplement = ~nFlagMask;
1138
1139 pRowFlags->AndValue(0, pDocument->MaxRow(), nFlagMaskComplement);
1140 pColFlags->AndValue(0, pDocument->MaxCol() + 1, nFlagMaskComplement);
1141
1142 {
1143 // row hidden flags.
1144
1145 SCROW nRow = 0;
1147 while (nRow <= pDocument->MaxRow())
1148 {
1149 if (!rRowSegments.getRangeData(nRow, aData))
1150 break;
1151
1152 if (aData.mbValue)
1153 pRowFlags->OrValue(nRow, aData.mnRow2, nFlagMask);
1154
1155 nRow = aData.mnRow2 + 1;
1156 }
1157 }
1158
1159 {
1160 // column hidden flags.
1161
1162 SCCOL nCol = 0;
1164 while (nCol <= pDocument->MaxCol())
1165 {
1166 if (!rColSegments.getRangeData(nCol, aData))
1167 break;
1168
1169 if (aData.mbValue)
1170 pColFlags->OrValue(nCol, aData.mnCol2, nFlagMask);
1171
1172 nCol = aData.mnCol2 + 1;
1173 }
1174 }
1175}
1176}
1177
1179{
1180 CRFlags nManualBreakComplement = ~CRFlags::ManualBreak;
1181
1182 // Manual breaks.
1183 pRowFlags->AndValue(0, rDocument.MaxRow(), nManualBreakComplement);
1184 mpColFlags->AndValue(0, rDocument.MaxCol() + 1, nManualBreakComplement);
1185
1186 for (const auto& rBreakPos : maRowManualBreaks)
1187 pRowFlags->OrValue(rBreakPos, CRFlags::ManualBreak);
1188
1189 for (const auto& rBreakPos : maColManualBreaks)
1190 mpColFlags->OrValue(rBreakPos, CRFlags::ManualBreak);
1191
1192 // Hidden flags.
1193 lcl_syncFlags(&rDocument, *mpHiddenCols, *mpHiddenRows, mpColFlags.get(), pRowFlags.get(),
1195 lcl_syncFlags(&rDocument, *mpFilteredCols, *mpFilteredRows, mpColFlags.get(), pRowFlags.get(),
1197}
1198
1199void ScTable::SetPageSize(const Size& rSize)
1200{
1201 if (!rSize.IsEmpty())
1202 {
1203 if (aPageSizeTwips != rSize)
1205
1206 bPageSizeValid = true;
1207 aPageSizeTwips = rSize;
1208 }
1209 else
1210 bPageSizeValid = false;
1211}
1212
1213bool ScTable::IsProtected() const { return pTabProtection && pTabProtection->isProtected(); }
1214
1216{
1217 if (pProtect)
1218 pTabProtection.reset(new ScTableProtection(*pProtect));
1219 else
1220 pTabProtection.reset();
1221
1222 SetStreamValid(false);
1223}
1224
1226
1228{
1229 if (bPageSizeValid)
1230 return aPageSizeTwips;
1231 else
1232 return Size(); // blank
1233}
1234
1235void ScTable::SetRepeatArea(SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow)
1236{
1237 // #i117952# page break calculation uses these values (set from ScPrintFunc), not pRepeatColRange/pRepeatRowRange
1238 if (nStartCol != nRepeatStartX || nEndCol != nRepeatEndX || nStartRow != nRepeatStartY
1239 || nEndRow != nRepeatEndY)
1241
1242 nRepeatStartX = nStartCol;
1243 nRepeatEndX = nEndCol;
1244 nRepeatStartY = nStartRow;
1245 nRepeatEndY = nEndRow;
1246}
1247
1248void ScTable::StartListening(const ScAddress& rAddress, SvtListener* pListener)
1249{
1250 if (!ValidCol(rAddress.Col()))
1251 return;
1252
1253 CreateColumnIfNotExists(rAddress.Col()).StartListening(*pListener, rAddress.Row());
1254}
1255
1256void ScTable::EndListening(const ScAddress& rAddress, SvtListener* pListener)
1257{
1258 if (!ValidCol(rAddress.Col()))
1259 return;
1260
1261 if (rAddress.Col() < aCol.size())
1262 aCol[rAddress.Col()].EndListening(*pListener, rAddress.Row());
1263}
1264
1266 SvtListener& rListener)
1267{
1268 if (!ValidCol(rAddress.Col()))
1269 return;
1270
1271 CreateColumnIfNotExists(rAddress.Col()).StartListening(rCxt, rAddress, rListener);
1272}
1273
1275 SvtListener& rListener)
1276{
1277 if (!ValidCol(rAddress.Col()))
1278 return;
1279
1280 if (rAddress.Col() < aCol.size())
1281 aCol[rAddress.Col()].EndListening(rCxt, rAddress, rListener);
1282}
1283
1284void ScTable::SetPageStyle(const OUString& rName)
1285{
1286 if (aPageStyle == rName)
1287 return;
1288
1289 OUString aStrNew = rName;
1291 SfxStyleSheetBase* pNewStyle = pStylePool->Find(aStrNew, SfxStyleFamily::Page);
1292
1293 if (!pNewStyle)
1294 {
1295 aStrNew = ScResId(STR_STYLENAME_STANDARD);
1296 pNewStyle = pStylePool->Find(aStrNew, SfxStyleFamily::Page);
1297 }
1298
1299 if (aPageStyle == aStrNew)
1300 return;
1301
1302 SfxStyleSheetBase* pOldStyle = pStylePool->Find(aPageStyle, SfxStyleFamily::Page);
1303 if (pOldStyle && pNewStyle)
1304 {
1305 SfxItemSet& rOldSet = pOldStyle->GetItemSet();
1306 SfxItemSet& rNewSet = pNewStyle->GetItemSet();
1307 auto getScaleValue = [](const SfxItemSet& rSet, sal_uInt16 nId) {
1308 return static_cast<const SfxUInt16Item&>(rSet.Get(nId)).GetValue();
1309 };
1310
1311 const sal_uInt16 nOldScale = getScaleValue(rOldSet, ATTR_PAGE_SCALE);
1312 const sal_uInt16 nOldScaleToPages = getScaleValue(rOldSet, ATTR_PAGE_SCALETOPAGES);
1313 const sal_uInt16 nNewScale = getScaleValue(rNewSet, ATTR_PAGE_SCALE);
1314 const sal_uInt16 nNewScaleToPages = getScaleValue(rNewSet, ATTR_PAGE_SCALETOPAGES);
1315
1316 if ((nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages))
1317 InvalidateTextWidth(nullptr, nullptr, false, false);
1318 }
1319
1320 if (pNewStyle) // also without the old one (for UpdateStdNames)
1321 aPageStyle = aStrNew;
1322
1323 SetStreamValid(false);
1324}
1325
1326void ScTable::PageStyleModified(const OUString& rNewName)
1327{
1328 aPageStyle = rNewName;
1329 InvalidateTextWidth(nullptr, nullptr, false, false); // don't know what was in the style before
1330}
1331
1332void ScTable::InvalidateTextWidth(const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1333 bool bNumFormatChanged, bool bBroadcast)
1334{
1335 if (pAdrFrom && !pAdrTo)
1336 {
1337 // Special case: only process the "from" cell.
1338 SCCOL nCol = pAdrFrom->Col();
1339 SCROW nRow = pAdrFrom->Row();
1340 if (nCol >= aCol.size())
1341 return;
1342 ScColumn& rCol = aCol[nCol];
1343 ScRefCellValue aCell = rCol.GetCellValue(nRow);
1344 if (aCell.isEmpty())
1345 return;
1346
1347 rCol.SetTextWidth(nRow, TEXTWIDTH_DIRTY);
1348
1349 if (bNumFormatChanged)
1350 rCol.SetScriptType(nRow, SvtScriptType::UNKNOWN);
1351
1352 if (bBroadcast)
1353 { // Only with CalcAsShown
1354 switch (aCell.getType())
1355 {
1356 case CELLTYPE_VALUE:
1357 rCol.Broadcast(nRow);
1358 break;
1359 case CELLTYPE_FORMULA:
1360 aCell.getFormula()->SetDirty();
1361 break;
1362 default:
1363 {
1364 // added to avoid warnings
1365 }
1366 }
1367 }
1368
1369 return;
1370 }
1371
1372 const SCCOL nCol1 = pAdrFrom ? pAdrFrom->Col() : 0;
1373 const SCROW nRow1 = pAdrFrom ? pAdrFrom->Row() : 0;
1374 const SCCOL nCol2 = pAdrTo ? pAdrTo->Col() : aCol.size() - 1;
1375 const SCROW nRow2 = pAdrTo ? pAdrTo->Row() : rDocument.MaxRow();
1376
1377 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1378 {
1379 ScColumnTextWidthIterator aIter(GetDoc(), aCol[nCol], nRow1, nRow2);
1380 sc::ColumnBlockPosition blockPos; // cache mdds position
1381 InitColumnBlockPosition(blockPos, nCol);
1382
1383 for (; aIter.hasCell(); aIter.next())
1384 {
1385 SCROW nRow = aIter.getPos();
1387 ScRefCellValue aCell = aCol[nCol].GetCellValue(blockPos, nRow);
1388 if (aCell.isEmpty())
1389 continue;
1390
1391 if (bNumFormatChanged)
1392 aCol[nCol].SetScriptType(nRow, SvtScriptType::UNKNOWN);
1393
1394 if (bBroadcast)
1395 { // Only with CalcAsShown
1396 switch (aCell.getType())
1397 {
1398 case CELLTYPE_VALUE:
1399 aCol[nCol].Broadcast(nRow);
1400 break;
1401 case CELLTYPE_FORMULA:
1402 aCell.getFormula()->SetDirty();
1403 break;
1404 default:
1405 {
1406 // added to avoid warnings
1407 }
1408 }
1409 }
1410 }
1411 }
1412}
1413
1414/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCROW SCROW_REPEAT_NONE
Definition: address.hxx:94
const SCCOL SCCOL_REPEAT_NONE
Definition: address.hxx:93
sal_uInt32 GetValue() const
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
The data type represents bits, manageable by bitwise operations.
void AndValue(A nPos, const D &rValueToAnd)
void OrValue(A nPos, const D &rValueToOr)
static OUString GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:31
SCCOL size() const
std::optional< Color > GetColor(const ScAddress &rAddr) const
Definition: colorscale.cxx:633
void setValue(sal_uInt16 nVal)
ScRefCellValue GetCellValue(SCROW nRow) const
Definition: column.cxx:638
void Broadcast(SCROW nRow)
Definition: column3.cxx:75
void SetScriptType(SCROW nRow, SvtScriptType nType)
Definition: column2.cxx:2382
void SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
Definition: column2.cxx:2292
void StartListening(SvtListener &rLst, SCROW nRow)
Definition: column2.cxx:3476
const ScFormatEntry * GetEntry(sal_uInt16 nPos) const
Definition: conditio.cxx:1802
size_t size() const
Definition: conditio.cxx:1788
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
ScBroadcastAreaSlotMachine * GetBASM() const
Definition: document.hxx:2230
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1083
SC_DLLPUBLIC ScConditionalFormat * GetCondFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen4.cxx:843
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6170
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4778
SC_DLLPUBLIC const SfxItemSet * GetCondResult(SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue *pCell=nullptr) const
Definition: documen4.cxx:797
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4813
bool IsImportingXML() const
Definition: document.hxx:2226
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2874
std::vector< SdrObject * > GetObjectsAnchoredToCols(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol)
Definition: drwlayer.cxx:2810
std::vector< SdrObject * > GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow)
Definition: drwlayer.cxx:2742
bool getRangeData(SCCOL nCol, RangeData &rData)
bool getValue(SCROW nPos, bool &rVal)
bool getRangeData(SCROW nRow, RangeData &rData) const
bool getValue(SCROW nPos, sal_uInt16 &rVal)
void SetDirty(bool bDirtyFlag=true)
Contains the "scale to width/height" attribute in page styles.
Definition: attrib.hxx:230
sal_uInt16 GetHeight() const
Definition: attrib.hxx:248
sal_uInt16 GetWidth() const
Definition: attrib.hxx:247
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
sheet protection state container
std::unique_ptr< ScFlatBoolColSegments > mpHiddenCols
Definition: table.hxx:196
Size aPageSizeTwips
Definition: table.hxx:177
OUString aPageStyle
Definition: table.hxx:176
SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const
Definition: table5.cxx:866
bool ValidCol(SCCOL nCol) const
Definition: table.hxx:353
SCCOL CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const
Definition: table5.cxx:823
void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden)
Definition: table5.cxx:629
std::unique_ptr< ScFlatBoolRowSegments > mpFilteredRows
Definition: table.hxx:199
bool bPageSizeValid
Definition: table.hxx:247
SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:735
ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const
Definition: table1.cxx:2723
bool ColFiltered(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: table5.cxx:908
void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered)
Definition: table5.cxx:970
SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:712
void InvalidatePageBreaks()
Definition: table2.cxx:1560
void GetAllRowBreaks(::std::set< SCROW > &rBreaks, bool bPage, bool bManual) const
Definition: table5.cxx:339
void EndListening(const ScAddress &rAddress, SvtListener *pListener)
Definition: table5.cxx:1256
bool RowHiddenLeaf(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: table5.cxx:517
::std::set< SCCOL > maColManualBreaks
Definition: table.hxx:204
void CopyRowFiltered(const ScTable &rTable, SCROW nStartRow, SCROW nEndRow)
Definition: table5.cxx:956
Size GetPageSize() const
Definition: table5.cxx:1227
ScColContainer aCol
Definition: table.hxx:162
void GetAllColBreaks(::std::set< SCCOL > &rBreaks, bool bPage, bool bManual) const
Definition: table5.cxx:351
std::unique_ptr< ScBitMaskCompressedArray< SCROW, CRFlags > > pRowFlags
Definition: table.hxx:195
void PageStyleModified(const OUString &rNewName)
Definition: table5.cxx:1326
ScColumn & CreateColumnIfNotExists(const SCCOL nScCol)
Definition: table.hxx:300
bool mbPageBreaksValid
Definition: table.hxx:256
SCROW nRepeatEndY
Definition: table.hxx:181
::std::set< SCROW > maRowPageBreaks
Definition: table.hxx:201
std::unique_ptr< ScBitMaskCompressedArray< SCCOL, CRFlags > > mpColFlags
Definition: table.hxx:194
void SetStreamValid(bool bSet, bool bIgnoreLock=false)
Definition: table1.cxx:378
void CopyRowHeight(const ScTable &rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset)
Definition: table5.cxx:692
bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden)
Definition: table5.cxx:579
void SetPageSize(const Size &rSize)
Definition: table5.cxx:1199
std::unique_ptr< ScFlatBoolColSegments > mpFilteredCols
Definition: table.hxx:198
void SyncColRowFlags()
Definition: table5.cxx:1178
SCCOL nRepeatStartX
Definition: table.hxx:178
css::uno::Sequence< css::sheet::TablePageBreakData > GetRowBreakData() const
Definition: table5.cxx:471
void SetColBreak(SCCOL nCol, bool bPage, bool bManual)
Definition: table5.cxx:456
bool HasRowPageBreak(SCROW nRow) const
Definition: table5.cxx:363
SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:1032
void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow)
Definition: table5.cxx:401
bool HasColPageBreak(SCCOL nCol) const
Definition: table5.cxx:371
bool mbForceBreaks
Definition: table.hxx:257
bool ColHidden(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: table5.cxx:562
void SetRepeatArea(SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow)
Definition: table5.cxx:1235
tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero=true) const
Definition: table5.cxx:800
void StartListening(const ScAddress &rAddress, SvtListener *pListener)
Definition: table5.cxx:1248
sal_uInt16 GetPrintRangeCount() const
Definition: table.hxx:823
SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:986
void InvalidateTextWidth(const ScAddress *pAdrFrom, const ScAddress *pAdrTo, bool bNumFormatChanged, bool bBroadcast)
Definition: table5.cxx:1332
bool IsProtected() const
Definition: table5.cxx:1213
void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered)
Definition: table5.cxx:978
bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:547
SCCOL CountHiddenCols(SCCOL nStartCol, SCCOL nEndCol) const
Definition: table5.cxx:845
void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual)
Definition: table5.cxx:411
void SetProtection(const ScTableProtection *pProtect)
Definition: table5.cxx:1215
bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:926
bool RowHidden(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: table5.cxx:487
bool HasColManualBreak(SCCOL nCol) const
Definition: table5.cxx:387
void SetRowBreak(SCROW nRow, bool bPage, bool bManual)
Definition: table5.cxx:441
void RemoveManualBreaks()
Definition: table5.cxx:311
SCCOL nRepeatEndX
Definition: table.hxx:179
::std::set< SCROW > maRowManualBreaks
Definition: table.hxx:202
SCROW GetNextManualBreak(SCROW nRow) const
Get the row position of the next manual break that occurs at or below specified row.
Definition: table5.cxx:395
SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:1009
std::unique_ptr< ScCompressedArray< SCCOL, sal_uInt16 > > mpColWidth
Definition: table.hxx:191
void CopyColFiltered(const ScTable &rTable, SCCOL nStartCol, SCCOL nEndCol)
Definition: table5.cxx:941
SCROW nRepeatStartY
Definition: table.hxx:180
bool InitColumnBlockPosition(sc::ColumnBlockPosition &rBlockPos, SCCOL nCol)
Definition: table2.cxx:710
void UpdatePageBreaks(const ScRange *pUserArea)
Definition: table5.cxx:59
std::unique_ptr< ScFlatBoolRowSegments > mpHiddenRows
Definition: table.hxx:197
SCTAB GetTab() const
Definition: table.hxx:296
bool RowFiltered(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: table5.cxx:890
std::unique_ptr< ScFlatUInt16RowSegments > mpRowHeights
Definition: table.hxx:192
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:758
Color GetCellBackgroundColor(ScAddress aPos) const
Definition: table5.cxx:1053
void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual)
Definition: table5.cxx:426
const ScTableProtection * GetProtection() const
Definition: table5.cxx:1225
ScDocument & rDocument
Definition: table.hxx:216
void SetColManualBreaks(::std::set< SCCOL > &&rBreaks)
Definition: table5.cxx:332
void CopyColHidden(const ScTable &rTable, SCCOL nStartCol, SCCOL nEndCol)
Definition: table5.cxx:663
bool HasManualBreaks() const
Definition: table5.cxx:320
bool IsManualRowHeight(SCROW nRow) const
Definition: table5.cxx:1125
ScDocument & GetDoc()
Definition: table.hxx:294
Color GetCellTextColor(ScAddress aPos) const
Definition: table5.cxx:1094
double GetValue(SCCOL nCol, SCROW nRow) const
Definition: table2.cxx:1796
const ScRange * GetPrintRange(sal_uInt16 nPos) const
Definition: table1.cxx:2336
std::unique_ptr< ScTableProtection > pTabProtection
Definition: table.hxx:189
void CopyRowHidden(const ScTable &rTable, SCROW nStartRow, SCROW nEndRow)
Definition: table5.cxx:678
::std::set< SCCOL > maColPageBreaks
Definition: table.hxx:203
bool HasRowManualBreak(SCROW nRow) const
Definition: table5.cxx:379
void SetPageStyle(const OUString &rName)
Definition: table5.cxx:1284
void SetRowManualBreaks(::std::set< SCROW > &&rBreaks)
Definition: table5.cxx:325
bool ValidRow(SCROW nRow) const
Definition: table.hxx:354
SCROW CountHiddenRows(SCROW nStartRow, SCROW nEndRow) const
Definition: table5.cxx:779
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const
virtual SfxItemSet & GetItemSet()
bool IsEmpty() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetColor() const
const Color & GetValue() const
int nCount
@ CELLTYPE_FORMULA
Definition: global.hxx:276
@ CELLTYPE_VALUE
Definition: global.hxx:274
CRFlags
Definition: global.hxx:125
#define TEXTWIDTH_DIRTY
Definition: globalnames.hxx:19
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
void copy(const fs::path &src, const fs::path &dest)
int i
long Long
sal_Int16 nId
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< ScPageScaleToItem > ATTR_PAGE_SCALETO(188)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
#define SC_MOD()
Definition: scmod.hxx:249
static SfxItemSet & rSet
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
ScFormulaCell * getFormula() const
Definition: cellvalue.hxx:137
bool isEmpty() const
Definition: cellvalue.cxx:667
CellType getType() const
Definition: cellvalue.hxx:133
Store position data for column array storage.
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17