25#include <document.hxx>
36#include <printopt.hxx>
44#include <com/sun/star/sheet/TablePageBreakData.hpp>
48#include <osl/diagnose.h>
55using ::com::sun::star::uno::Sequence;
56using ::com::sun::star::sheet::TablePageBreakData;
81 OSL_FAIL(
"UpdatePageBreaks: Style not found");
94 nEndCol = pUserArea->
aEnd.
Col();
95 nEndRow = pUserArea->
aEnd.
Row();
111 else if (nAreaCount == 1)
128 bool bSkipColBreaks =
false;
129 bool bSkipRowBreaks =
false;
135 bSkipColBreaks = bSkipRowBreaks = pItem->GetValue() > 0;
143 bSkipColBreaks =
true;
145 bSkipRowBreaks =
true;
166 bool bColFound =
false;
168 for (
SCCOL nX = nStartCol; nX <= nEndCol; nX++)
170 bool bStartOfPage =
false;
173 if ((nSizeX + nThisX > nPageSizeX) || (bManualBreak && !bSkipColBreaks))
179 else if (nX != nStartCol)
184 if (bStartOfPage && bRepeatCol && nX >
nRepeatStartX && !bColFound)
202 bool bRowFound =
false;
207 for (
SCROW nY = nStartRow; nY <= nEndRow; ++nY)
209 bool bStartOfPage =
false;
210 bool bThisRowHidden =
false;
211 const bool bHasValue = aIterHidden.
getValue(nY, bThisRowHidden);
218 const bool bHasHeight = aIterHeights.
getValue(nY, nTmp);
224 bool bManualBreak =
false;
225 if (nNextManualBreak >= 0)
227 bManualBreak = (nY == nNextManualBreak);
228 if (nY >= nNextManualBreak)
233 if ((nSizeY + nThisY > nPageSizeY) || (bManualBreak && !bSkipRowBreaks))
239 else if (nY != nStartRow)
244 if (bStartOfPage && bRepeatRow && nY >
nRepeatStartY && !bRowFound)
248#if OSL_DEBUG_LEVEL > 0
249 if (nHeights == ::std::numeric_limits<tools::Long>::max())
250 OSL_FAIL(
"ScTable::UpdatePageBreaks: row heights overflow");
252 nPageSizeY -= nHeights;
262 if (nNextManualBreak >= 0)
263 nLastCommon = ::std::min(nLastCommon, nNextManualBreak - 1);
272 SCROW nLastCommon = ::std::min(nLastHidden, nLastHeight);
273 if (nNextManualBreak >= 0)
274 nLastCommon = ::std::min(nLastCommon, nNextManualBreak - 1);
276 if (nLastCommon > nY)
279 tools::Long nMultiple = (nPageSizeY - nSizeY) / nThisY;
280 if (nMultiple > nMaxMultiple)
281 nMultiple = nMaxMultiple;
284 nSizeY += nThisY * (nMultiple - 1);
347 inserter(rBreaks, rBreaks.begin()));
359 inserter(rBreaks, rBreaks.begin()));
473 using ::std::inserter;
477 inserter(aRowBreaks, aRowBreaks.begin()));
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));
510 *pFirstRow =
aData.mnRow1;
512 *pLastRow =
aData.mnRow2;
514 return aData.mbValue;
540 *pFirstRow =
aData.mnRow1;
542 *pLastRow =
aData.mnRow2;
544 return aData.mbValue;
549 SCROW nRow = nStartRow;
550 while (nRow <= nEndRow)
553 bool bHidden =
RowHidden(nRow,
nullptr, &nLastRow);
572 *pFirstCol =
aData.mnCol1;
574 *pLastCol =
aData.mnCol2;
576 return aData.mbValue;
581 bool bChanged =
false;
591 std::vector<SdrObject*> aRowDrawObjects;
593 for (
auto aObj : aRowDrawObjects)
599 aObj->SetVisible(
false);
603 aObj->SetVisible(
true);
621 aCol[
i].BroadcastRows(nStartRow, nEndRow, SfxHintId::ScHiddenRowsChanged);
631 bool bChanged =
false;
641 std::vector<SdrObject*> aColDrawObjects;
643 for (
auto aObj : aColDrawObjects)
649 aObj->SetVisible(
false);
653 aObj->SetVisible(
true);
665 SCCOL nCol = nStartCol;
666 while (nCol <= nEndCol)
669 bool bHidden = rTable.
ColHidden(nCol,
nullptr, &nLastCol);
670 if (nLastCol > nEndCol)
680 SCROW nRow = nStartRow;
681 while (nRow <= nEndRow)
684 bool bHidden = rTable.
RowHidden(nRow,
nullptr, &nLastRow);
685 if (nLastRow > nEndRow)
695 SCROW nRow = nStartRow;
697 while (nRow <= nEndRow)
699 if (!rSrcTable.
mpRowHeights->getRangeData(nRow + nSrcOffset, aSrcData))
704 if (nLastRow > nEndRow)
714 SCROW nRow = nStartRow;
716 while (nRow <= nEndRow)
729 nRow =
aData.mnRow2 + 1;
732 return ::std::numeric_limits<SCROW>::max();
737 SCROW nRow = nEndRow;
739 while (nRow >= nStartRow)
752 nRow =
aData.mnRow1 - 1;
755 return ::std::numeric_limits<SCROW>::max();
761 SCROW nRow = nStartRow;
763 while (nRow <= nEndRow)
768 if (
aData.mnRow2 > nEndRow)
769 aData.mnRow2 = nEndRow;
774 nRow =
aData.mnRow2 + 1;
782 SCROW nRow = nStartRow;
784 while (nRow <= nEndRow)
789 if (
aData.mnRow2 > nEndRow)
790 aData.mnRow2 = nEndRow;
795 nRow =
aData.mnRow2 + 1;
803 SCROW nRow = nStartRow;
805 while (nRow <= nEndRow)
810 if (
aData.mnRow2 > nEndRow)
811 aData.mnRow2 = nEndRow;
813 if (!(bHiddenAsZero &&
aData.mbValue))
817 nRow =
aData.mnRow2 + 1;
825 assert(nStartCol <= nEndCol);
827 SCCOL nCol = nStartCol;
829 while (nCol <= nEndCol)
834 if (
aData.mnCol2 > nEndCol)
835 aData.mnCol2 = nEndCol;
840 nCol =
aData.mnCol2 + 1;
848 SCCOL nCol = nStartCol;
850 while (nCol <= nEndCol)
855 if (
aData.mnCol2 > nEndCol)
856 aData.mnCol2 = nEndCol;
861 nCol =
aData.mnCol2 + 1;
885 return static_cast<SCCOLROW>(nLastRow);
887 return ::std::numeric_limits<SCCOLROW>::max();
901 *pFirstRow =
aData.mnRow1;
903 *pLastRow =
aData.mnRow2;
905 return aData.mbValue;
919 *pFirstCol =
aData.mnCol1;
921 *pLastCol =
aData.mnCol2;
923 return aData.mbValue;
928 SCROW nRow = nStartRow;
929 while (nRow <= nEndRow)
931 SCROW nLastRow = nRow;
932 bool bFiltered =
RowFiltered(nRow,
nullptr, &nLastRow);
943 SCCOL nCol = nStartCol;
944 while (nCol <= nEndCol)
947 bool bFiltered = rTable.
ColFiltered(nCol,
nullptr, &nLastCol);
948 if (nLastCol > nEndCol)
958 SCROW nRow = nStartRow;
959 while (nRow <= nEndRow)
962 bool bFiltered = rTable.
RowFiltered(nRow,
nullptr, &nLastRow);
963 if (nLastRow > nEndRow)
988 SCROW nRow = nStartRow;
990 while (nRow <= nEndRow)
1003 nRow =
aData.mnRow2 + 1;
1006 return ::std::numeric_limits<SCROW>::max();
1011 SCROW nRow = nEndRow;
1013 while (nRow >= nStartRow)
1026 nRow =
aData.mnRow1 - 1;
1029 return ::std::numeric_limits<SCROW>::max();
1035 SCROW nRow = nStartRow;
1037 while (nRow <= nEndRow)
1042 if (
aData.mnRow2 > nEndRow)
1043 aData.mnRow2 = nEndRow;
1048 nRow =
aData.mnRow2 + 1;
1055 Color backgroundColor;
1056 bool bHasConditionalBackgroundColor =
false;
1065 backgroundColor = pBackgroundColor->
GetColor();
1066 bHasConditionalBackgroundColor =
true;
1074 for (
size_t i = 0;
i < pCondFormat->
size();
i++)
1081 std::optional<Color> oColor = pColFormat->
GetColor(aPos);
1084 backgroundColor = oColor.value();
1085 bHasConditionalBackgroundColor =
true;
1090 return bHasConditionalBackgroundColor ? backgroundColor
1112 const Color* pColor;
1137 CRFlags nFlagMaskComplement = ~nFlagMask;
1139 pRowFlags->
AndValue(0, pDocument->
MaxRow(), nFlagMaskComplement);
1140 pColFlags->
AndValue(0, pDocument->
MaxCol() + 1, nFlagMaskComplement);
1147 while (nRow <= pDocument->MaxRow())
1155 nRow =
aData.mnRow2 + 1;
1164 while (nCol <= pDocument->MaxCol())
1172 nCol =
aData.mnCol2 + 1;
1262 aCol[rAddress.
Col()].EndListening(*pListener, rAddress.
Row());
1281 aCol[rAddress.
Col()].EndListening(rCxt, rAddress, rListener);
1289 OUString aStrNew = rName;
1295 aStrNew =
ScResId(STR_STYLENAME_STANDARD);
1296 pNewStyle = pStylePool->
Find(aStrNew, SfxStyleFamily::Page);
1303 if (pOldStyle && pNewStyle)
1316 if ((nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages))
1333 bool bNumFormatChanged,
bool bBroadcast)
1335 if (pAdrFrom && !pAdrTo)
1349 if (bNumFormatChanged)
1372 const SCCOL nCol1 = pAdrFrom ? pAdrFrom->
Col() : 0;
1373 const SCROW nRow1 = pAdrFrom ? pAdrFrom->
Row() : 0;
1377 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1391 if (bNumFormatChanged)
1392 aCol[nCol].SetScriptType(nRow, SvtScriptType::UNKNOWN);
1399 aCol[nCol].Broadcast(nRow);
const SCROW SCROW_REPEAT_NONE
const SCCOL SCCOL_REPEAT_NONE
sal_uInt32 GetValue() const
The data type represents bits, manageable by bitwise operations.
void AndValue(A nPos, const D &rValueToAnd)
void OrValue(A nPos, const D &rValueToOr)
void setValue(sal_uInt16 nVal)
ScRefCellValue GetCellValue(SCROW nRow) const
void Broadcast(SCROW nRow)
void SetScriptType(SCROW nRow, SvtScriptType nType)
void SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
void StartListening(SvtListener &rLst, SCROW nRow)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
ScBroadcastAreaSlotMachine * GetBASM() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC ScConditionalFormat * GetCondFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
SC_DLLPUBLIC const SfxItemSet * GetCondResult(SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue *pCell=nullptr) const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
bool IsImportingXML() const
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
std::vector< SdrObject * > GetObjectsAnchoredToCols(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol)
std::vector< SdrObject * > GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow)
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)
Contains the "scale to width/height" attribute in page styles.
sal_uInt16 GetHeight() const
sal_uInt16 GetWidth() const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
sheet protection state container
std::unique_ptr< ScFlatBoolColSegments > mpHiddenCols
SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const
bool ValidCol(SCCOL nCol) const
SCCOL CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const
void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden)
std::unique_ptr< ScFlatBoolRowSegments > mpFilteredRows
SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const
ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const
bool ColFiltered(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered)
SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const
void InvalidatePageBreaks()
void GetAllRowBreaks(::std::set< SCROW > &rBreaks, bool bPage, bool bManual) const
void EndListening(const ScAddress &rAddress, SvtListener *pListener)
bool RowHiddenLeaf(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
::std::set< SCCOL > maColManualBreaks
void CopyRowFiltered(const ScTable &rTable, SCROW nStartRow, SCROW nEndRow)
void GetAllColBreaks(::std::set< SCCOL > &rBreaks, bool bPage, bool bManual) const
std::unique_ptr< ScBitMaskCompressedArray< SCROW, CRFlags > > pRowFlags
void PageStyleModified(const OUString &rNewName)
ScColumn & CreateColumnIfNotExists(const SCCOL nScCol)
::std::set< SCROW > maRowPageBreaks
std::unique_ptr< ScBitMaskCompressedArray< SCCOL, CRFlags > > mpColFlags
void SetStreamValid(bool bSet, bool bIgnoreLock=false)
void CopyRowHeight(const ScTable &rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset)
bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden)
void SetPageSize(const Size &rSize)
std::unique_ptr< ScFlatBoolColSegments > mpFilteredCols
css::uno::Sequence< css::sheet::TablePageBreakData > GetRowBreakData() const
void SetColBreak(SCCOL nCol, bool bPage, bool bManual)
bool HasRowPageBreak(SCROW nRow) const
SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const
void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow)
bool HasColPageBreak(SCCOL nCol) const
bool ColHidden(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
void SetRepeatArea(SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow)
tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero=true) const
void StartListening(const ScAddress &rAddress, SvtListener *pListener)
sal_uInt16 GetPrintRangeCount() const
SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const
void InvalidateTextWidth(const ScAddress *pAdrFrom, const ScAddress *pAdrTo, bool bNumFormatChanged, bool bBroadcast)
void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered)
bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const
SCCOL CountHiddenCols(SCCOL nStartCol, SCCOL nEndCol) const
void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual)
void SetProtection(const ScTableProtection *pProtect)
bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const
bool RowHidden(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
bool HasColManualBreak(SCCOL nCol) const
void SetRowBreak(SCROW nRow, bool bPage, bool bManual)
void RemoveManualBreaks()
::std::set< SCROW > maRowManualBreaks
SCROW GetNextManualBreak(SCROW nRow) const
Get the row position of the next manual break that occurs at or below specified row.
SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const
std::unique_ptr< ScCompressedArray< SCCOL, sal_uInt16 > > mpColWidth
void CopyColFiltered(const ScTable &rTable, SCCOL nStartCol, SCCOL nEndCol)
bool InitColumnBlockPosition(sc::ColumnBlockPosition &rBlockPos, SCCOL nCol)
void UpdatePageBreaks(const ScRange *pUserArea)
std::unique_ptr< ScFlatBoolRowSegments > mpHiddenRows
bool RowFiltered(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
std::unique_ptr< ScFlatUInt16RowSegments > mpRowHeights
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const
Color GetCellBackgroundColor(ScAddress aPos) const
void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual)
const ScTableProtection * GetProtection() const
void SetColManualBreaks(::std::set< SCCOL > &&rBreaks)
void CopyColHidden(const ScTable &rTable, SCCOL nStartCol, SCCOL nEndCol)
bool HasManualBreaks() const
bool IsManualRowHeight(SCROW nRow) const
Color GetCellTextColor(ScAddress aPos) const
double GetValue(SCCOL nCol, SCROW nRow) const
const ScRange * GetPrintRange(sal_uInt16 nPos) const
std::unique_ptr< ScTableProtection > pTabProtection
void CopyRowHidden(const ScTable &rTable, SCROW nStartRow, SCROW nEndRow)
::std::set< SCCOL > maColPageBreaks
bool HasRowManualBreak(SCROW nRow) const
void SetPageStyle(const OUString &rName)
void SetRowManualBreaks(::std::set< SCROW > &&rBreaks)
bool ValidRow(SCROW nRow) const
SCROW CountHiddenRows(SCROW nStartRow, SCROW nEndRow) const
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()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetColor() const
const Color & GetValue() const
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
void copy(const fs::path &src, const fs::path &dest)
OUString ScResId(TranslateId aId)
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)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
Store position data for column array storage.
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW