25 #include <document.hxx>
28 #include <stlpool.hxx>
30 #include <globstr.hrc>
36 #include <printopt.hxx>
41 #include <com/sun/star/sheet/TablePageBreakData.hpp>
43 #include <osl/diagnose.h>
48 using ::com::sun::star::uno::Sequence;
49 using ::com::sun::star::sheet::TablePageBreakData;
74 OSL_FAIL(
"UpdatePageBreaks: Style not found");
87 nEndCol = pUserArea->
aEnd.
Col();
88 nEndRow = pUserArea->
aEnd.
Row();
104 else if (nAreaCount == 1)
121 bool bSkipColBreaks =
false;
122 bool bSkipRowBreaks =
false;
128 bSkipColBreaks = bSkipRowBreaks = pItem->GetValue() > 0;
136 bSkipColBreaks =
true;
138 bSkipRowBreaks =
true;
159 bool bColFound =
false;
161 for (
SCCOL nX = nStartCol; nX <= nEndCol; nX++)
163 bool bStartOfPage =
false;
166 if ((nSizeX + nThisX > nPageSizeX) || (bManualBreak && !bSkipColBreaks))
172 else if (nX != nStartCol)
177 if (bStartOfPage && bRepeatCol && nX >
nRepeatStartX && !bColFound)
195 bool bRowFound =
false;
200 for (
SCROW nY = nStartRow; nY <= nEndRow; ++nY)
202 bool bStartOfPage =
false;
203 bool bThisRowHidden =
false;
204 const bool bHasValue = aIterHidden.
getValue(nY, bThisRowHidden);
211 const bool bHasHeight = aIterHeights.
getValue(nY, nTmp);
217 bool bManualBreak =
false;
218 if (nNextManualBreak >= 0)
220 bManualBreak = (nY == nNextManualBreak);
221 if (nY >= nNextManualBreak)
226 if ((nSizeY + nThisY > nPageSizeY) || (bManualBreak && !bSkipRowBreaks))
232 else if (nY != nStartRow)
237 if (bStartOfPage && bRepeatRow && nY >
nRepeatStartY && !bRowFound)
241 #if OSL_DEBUG_LEVEL > 0
242 if (nHeights == ::std::numeric_limits<tools::Long>::max())
243 OSL_FAIL(
"ScTable::UpdatePageBreaks: row heights overflow");
245 nPageSizeY -= nHeights;
255 if (nNextManualBreak >= 0)
256 nLastCommon = ::std::min(nLastCommon, nNextManualBreak - 1);
265 SCROW nLastCommon = ::std::min(nLastHidden, nLastHeight);
266 if (nNextManualBreak >= 0)
267 nLastCommon = ::std::min(nLastCommon, nNextManualBreak - 1);
269 if (nLastCommon > nY)
272 tools::Long nMultiple = (nPageSizeY - nSizeY) / nThisY;
273 if (nMultiple > nMaxMultiple)
274 nMultiple = nMaxMultiple;
277 nSizeY += nThisY * (nMultiple - 1);
340 inserter(rBreaks, rBreaks.begin()));
352 inserter(rBreaks, rBreaks.begin()));
466 using ::std::inserter;
470 inserter(aRowBreaks, aRowBreaks.begin()));
472 Sequence<TablePageBreakData>
aSeq(aRowBreaks.size());
473 std::transform(aRowBreaks.begin(), aRowBreaks.end(),
aSeq.getArray(), [
this](
const SCROW nRow) {
503 *pFirstRow = aData.
mnRow1;
533 *pFirstRow = aData.
mnRow1;
542 SCROW nRow = nStartRow;
543 while (nRow <= nEndRow)
546 bool bHidden =
RowHidden(nRow,
nullptr, &nLastRow);
565 *pFirstCol = aData.
mnCol1;
574 bool bChanged =
false;
584 std::vector<SdrObject*> aRowDrawObjects;
586 for (
auto aObj : aRowDrawObjects)
592 aObj->SetVisible(
false);
596 aObj->SetVisible(
true);
614 aCol[
i].BroadcastRows(nStartRow, nEndRow, SfxHintId::ScHiddenRowsChanged);
624 bool bChanged =
false;
634 std::vector<SdrObject*> aColDrawObjects;
636 for (
auto aObj : aColDrawObjects)
642 aObj->SetVisible(
false);
646 aObj->SetVisible(
true);
658 SCCOL nCol = nStartCol;
659 while (nCol <= nEndCol)
662 bool bHidden = rTable.
ColHidden(nCol,
nullptr, &nLastCol);
663 if (nLastCol > nEndCol)
673 SCROW nRow = nStartRow;
674 while (nRow <= nEndRow)
677 bool bHidden = rTable.
RowHidden(nRow,
nullptr, &nLastRow);
678 if (nLastRow > nEndRow)
688 SCROW nRow = nStartRow;
690 while (nRow <= nEndRow)
692 if (!rSrcTable.
mpRowHeights->getRangeData(nRow + nSrcOffset, aSrcData))
697 if (nLastRow > nEndRow)
707 SCROW nRow = nStartRow;
709 while (nRow <= nEndRow)
725 return ::std::numeric_limits<SCROW>::max();
730 SCROW nRow = nEndRow;
732 while (nRow >= nStartRow)
748 return ::std::numeric_limits<SCROW>::max();
754 SCROW nRow = nStartRow;
756 while (nRow <= nEndRow)
761 if (aData.
mnRow2 > nEndRow)
765 nCount += aData.
mnRow2 - nRow + 1;
775 SCROW nRow = nStartRow;
777 while (nRow <= nEndRow)
782 if (aData.
mnRow2 > nEndRow)
785 if (!(bHiddenAsZero && aData.
mbValue))
797 assert(nStartCol <= nEndCol);
799 SCCOL nCol = nStartCol;
801 while (nCol <= nEndCol)
806 if (aData.
mnCol2 > nEndCol)
810 nCount += aData.
mnCol2 - nCol + 1;
836 return static_cast<SCCOLROW>(nLastRow);
838 return ::std::numeric_limits<SCCOLROW>::max();
852 *pFirstRow = aData.
mnRow1;
870 *pFirstCol = aData.
mnCol1;
879 SCROW nRow = nStartRow;
880 while (nRow <= nEndRow)
882 SCROW nLastRow = nRow;
883 bool bFiltered =
RowFiltered(nRow,
nullptr, &nLastRow);
894 SCCOL nCol = nStartCol;
895 while (nCol <= nEndCol)
898 bool bFiltered = rTable.
ColFiltered(nCol,
nullptr, &nLastCol);
899 if (nLastCol > nEndCol)
909 SCROW nRow = nStartRow;
910 while (nRow <= nEndRow)
913 bool bFiltered = rTable.
RowFiltered(nRow,
nullptr, &nLastRow);
914 if (nLastRow > nEndRow)
939 SCROW nRow = nStartRow;
941 while (nRow <= nEndRow)
957 return ::std::numeric_limits<SCROW>::max();
962 SCROW nRow = nEndRow;
964 while (nRow >= nStartRow)
980 return ::std::numeric_limits<SCROW>::max();
986 SCROW nRow = nStartRow;
988 while (nRow <= nEndRow)
993 if (aData.
mnRow2 > nEndRow)
997 nCount += aData.
mnRow2 - nRow + 1;
1016 using ::sal::static_int_cast;
1018 CRFlags nFlagMaskComplement = ~nFlagMask;
1020 pRowFlags->
AndValue(0, pDocument->
MaxRow(), nFlagMaskComplement);
1021 pColFlags->
AndValue(0, pDocument->
MaxCol() + 1, nFlagMaskComplement);
1028 while (nRow <= pDocument->MaxRow())
1045 while (nCol <= pDocument->MaxCol())
1143 aCol[rAddress.
Col()].EndListening(*pListener, rAddress.
Row());
1162 aCol[rAddress.
Col()].EndListening(rCxt, rAddress, rListener);
1170 OUString aStrNew = rName;
1176 aStrNew =
ScResId(STR_STYLENAME_STANDARD);
1177 pNewStyle = pStylePool->
Find(aStrNew, SfxStyleFamily::Page);
1184 if (pOldStyle && pNewStyle)
1188 auto getScaleValue = [](
const SfxItemSet& rSet, sal_uInt16
nId) {
1197 if ((nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages))
1214 bool bNumFormatChanged,
bool bBroadcast)
1216 if (pAdrFrom && !pAdrTo)
1230 if (bNumFormatChanged)
1253 const SCCOL nCol1 = pAdrFrom ? pAdrFrom->
Col() : 0;
1254 const SCROW nRow1 = pAdrFrom ? pAdrFrom->
Row() : 0;
1258 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1272 if (bNumFormatChanged)
1273 aCol[nCol].SetScriptType(nRow, SvtScriptType::UNKNOWN);
1280 aCol[nCol].Broadcast(nRow);
sal_uInt16 GetHeight() const
void UpdatePageBreaks(const ScRange *pUserArea)
bool ColFiltered(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
void SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
bool HasRowManualBreak(SCROW nRow) const
std::vector< SdrObject * > GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow)
OUString ScResId(TranslateId aId)
std::unique_ptr< ScFlatUInt16RowSegments > mpRowHeights
void InvalidateTextWidth(const ScAddress *pAdrFrom, const ScAddress *pAdrTo, bool bNumFormatChanged, bool bBroadcast)
const ScRange * GetPrintRange(sal_uInt16 nPos) const
void setValue(sal_uInt16 nVal)
SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const
void PageStyleModified(const OUString &rNewName)
void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow)
::std::set< SCROW > maRowPageBreaks
sheet protection state container
std::unique_ptr< sal_Int32[]> pData
void StartListening(const ScAddress &rAddress, SvtListener *pListener)
sal_uInt16 GetPrintRangeCount() const
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
void CopyRowFiltered(const ScTable &rTable, SCROW nStartRow, SCROW nEndRow)
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
bool getValue(SCROW nPos, bool &rVal)
void SetPageSize(const Size &rSize)
std::unique_ptr< ScFlatBoolColSegments > mpFilteredCols
void Broadcast(SCROW nRow)
Store position data for column array storage.
SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const
std::vector< SdrObject * > GetObjectsAnchoredToCols(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol)
void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden)
void AndValue(A nPos, const D &rValueToAnd)
virtual SfxItemSet & GetItemSet()
This is very similar to ScCellValue, except that it references the original value instead of copying ...
void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered)
SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const
bool ValidRow(SCROW nRow) const
void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual)
constexpr tools::Long Width() const
void SetStreamValid(bool bSet, bool bIgnoreLock=false)
ScColumn & CreateColumnIfNotExists(const SCCOL nScCol) const
void SetRowBreak(SCROW nRow, bool bPage, bool bManual)
ScRefCellValue GetCellValue(SCROW nRow) const
SC_DLLPUBLIC SCROW MaxRow() const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
void EndListening(const ScAddress &rAddress, SvtListener *pListener)
const ScTableProtection * GetProtection() const
void SetPageStyle(const OUString &rName)
ScFormulaCell * mpFormula
void SetRowManualBreaks(::std::set< SCROW > &&rBreaks)
void CopyColHidden(const ScTable &rTable, SCCOL nStartCol, SCCOL nEndCol)
bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden)
SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const
ScBroadcastAreaSlotMachine * GetBASM() const
std::unique_ptr< ScBitMaskCompressedArray< SCCOL, CRFlags > > mpColFlags
constexpr OUStringLiteral aData
std::unique_ptr< ScFlatBoolColSegments > mpHiddenCols
sal_uInt16 GetWidth() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC SCCOL MaxCol() const
bool ColHidden(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
bool ValidCol(SCCOL nCol) const
bool IsImportingXML() const
void SetColManualBreaks(::std::set< SCCOL > &&rBreaks)
bool HasColManualBreak(SCCOL nCol) const
void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual)
void CopyRowHidden(const ScTable &rTable, SCROW nStartRow, SCROW nEndRow)
SCCOL CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const
std::unique_ptr< ScTableProtection > pTabProtection
void GetAllRowBreaks(::std::set< SCROW > &rBreaks, bool bPage, bool bManual) const
::std::set< SCROW > maRowManualBreaks
bool HasRowPageBreak(SCROW nRow) const
const SCROW SCROW_REPEAT_NONE
constexpr TypedWhichId< ScPageScaleToItem > ATTR_PAGE_SCALETO(188)
tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero=true) const
void InvalidatePageBreaks()
bool HasManualBreaks() const
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const
void GetAllColBreaks(::std::set< SCCOL > &rBreaks, bool bPage, bool bManual) const
::std::set< SCCOL > maColPageBreaks
bool RowHidden(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
void SetProtection(const ScTableProtection *pProtect)
std::unique_ptr< ScFlatBoolRowSegments > mpFilteredRows
Contains the "scale to width/height" attribute in page styles.
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr tools::Long Height() const
ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const
bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const
::std::set< SCCOL > maColManualBreaks
void SetRepeatArea(SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow)
SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const
void CopyRowHeight(const ScTable &rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset)
bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const
std::unique_ptr< ScCompressedArray< SCCOL, sal_uInt16 > > mpColWidth
void copy(const fs::path &src, const fs::path &dest)
Sequence< sal_Int8 > aSeq
void SetColBreak(SCCOL nCol, bool bPage, bool bManual)
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
void SetScriptType(SCROW nRow, SvtScriptType nType)
bool RowFiltered(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
bool IsManualRowHeight(SCROW nRow) const
SCROW GetNextManualBreak(SCROW nRow) const
Get the row position of the next manual break that occurs at or below specified row.
The data type represents bits, manageable by bitwise operations.
bool getRangeData(SCROW nRow, RangeData &rData) const
bool InitColumnBlockPosition(sc::ColumnBlockPosition &rBlockPos, SCCOL nCol)
bool HasColPageBreak(SCCOL nCol) const
std::unique_ptr< ScBitMaskCompressedArray< SCROW, CRFlags > > pRowFlags
bool RowHiddenLeaf(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
bool getRangeData(SCCOL nCol, RangeData &rData)
void OrValue(A nPos, const D &rValueToOr)
bool getValue(SCROW nPos, sal_uInt16 &rVal)
std::unique_ptr< ScFlatBoolRowSegments > mpHiddenRows
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
void RemoveManualBreaks()
double GetValue(SCCOL nCol, SCROW nRow) const
const SCCOL SCCOL_REPEAT_NONE
void CopyColFiltered(const ScTable &rTable, SCCOL nStartCol, SCCOL nEndCol)
css::uno::Sequence< css::sheet::TablePageBreakData > GetRowBreakData() const
SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const
void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered)