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;
792 if (!(bHiddenAsZero &&
aData.mbValue))
796 nRow =
aData.mnRow2 + 1;
804 assert(nStartCol <= nEndCol);
806 SCCOL nCol = nStartCol;
808 while (nCol <= nEndCol)
813 if (
aData.mnCol2 > nEndCol)
814 aData.mnCol2 = nEndCol;
819 nCol =
aData.mnCol2 + 1;
843 return static_cast<SCCOLROW>(nLastRow);
845 return ::std::numeric_limits<SCCOLROW>::max();
859 *pFirstRow =
aData.mnRow1;
861 *pLastRow =
aData.mnRow2;
863 return aData.mbValue;
877 *pFirstCol =
aData.mnCol1;
879 *pLastCol =
aData.mnCol2;
881 return aData.mbValue;
886 SCROW nRow = nStartRow;
887 while (nRow <= nEndRow)
889 SCROW nLastRow = nRow;
890 bool bFiltered =
RowFiltered(nRow,
nullptr, &nLastRow);
901 SCCOL nCol = nStartCol;
902 while (nCol <= nEndCol)
905 bool bFiltered = rTable.
ColFiltered(nCol,
nullptr, &nLastCol);
906 if (nLastCol > nEndCol)
916 SCROW nRow = nStartRow;
917 while (nRow <= nEndRow)
920 bool bFiltered = rTable.
RowFiltered(nRow,
nullptr, &nLastRow);
921 if (nLastRow > nEndRow)
946 SCROW nRow = nStartRow;
948 while (nRow <= nEndRow)
961 nRow =
aData.mnRow2 + 1;
964 return ::std::numeric_limits<SCROW>::max();
969 SCROW nRow = nEndRow;
971 while (nRow >= nStartRow)
984 nRow =
aData.mnRow1 - 1;
987 return ::std::numeric_limits<SCROW>::max();
993 SCROW nRow = nStartRow;
995 while (nRow <= nEndRow)
1000 if (
aData.mnRow2 > nEndRow)
1001 aData.mnRow2 = nEndRow;
1006 nRow =
aData.mnRow2 + 1;
1013 Color backgroundColor;
1014 bool bHasConditionalBackgroundColor =
false;
1023 backgroundColor = pBackgroundColor->
GetColor();
1024 bHasConditionalBackgroundColor =
true;
1032 for (
size_t i = 0;
i < pCondFormat->
size();
i++)
1039 std::optional<Color> oColor = pColFormat->
GetColor(aPos);
1042 backgroundColor = oColor.value();
1043 bHasConditionalBackgroundColor =
true;
1048 return bHasConditionalBackgroundColor ? backgroundColor
1070 const Color* pColor;
1095 CRFlags nFlagMaskComplement = ~nFlagMask;
1097 pRowFlags->
AndValue(0, pDocument->
MaxRow(), nFlagMaskComplement);
1098 pColFlags->
AndValue(0, pDocument->
MaxCol() + 1, nFlagMaskComplement);
1105 while (nRow <= pDocument->MaxRow())
1113 nRow =
aData.mnRow2 + 1;
1122 while (nCol <= pDocument->MaxCol())
1130 nCol =
aData.mnCol2 + 1;
1220 aCol[rAddress.
Col()].EndListening(*pListener, rAddress.
Row());
1239 aCol[rAddress.
Col()].EndListening(rCxt, rAddress, rListener);
1247 OUString aStrNew = rName;
1253 aStrNew =
ScResId(STR_STYLENAME_STANDARD);
1254 pNewStyle = pStylePool->
Find(aStrNew, SfxStyleFamily::Page);
1261 if (pOldStyle && pNewStyle)
1274 if ((nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages))
1291 bool bNumFormatChanged,
bool bBroadcast)
1293 if (pAdrFrom && !pAdrTo)
1307 if (bNumFormatChanged)
1330 const SCCOL nCol1 = pAdrFrom ? pAdrFrom->
Col() : 0;
1331 const SCROW nRow1 = pAdrFrom ? pAdrFrom->
Row() : 0;
1335 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1349 if (bNumFormatChanged)
1350 aCol[nCol].SetScriptType(nRow, SvtScriptType::UNKNOWN);
1357 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
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
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)
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