diff options
author | Eilidh McAdam <eilidh@lanedo.com> | 2013-11-02 21:05:12 +0000 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-11-04 09:38:48 -0600 |
commit | a37092075791ccbe6081e3e01990df6d9e6cdce6 (patch) | |
tree | 0ca2f3325ebda6f9f9c956617b79846a7fa2c466 | |
parent | 6ad8972d4b698617404e53d63f178e34b2d5358a (diff) |
Fix for Calc page scaling - see #i54993#
If a print range's manual breaks forced it over more pages than specified
by the sheet scale settings, the zoom calculation wasn't able to
converge on a zoom level, so it bottomed out at ZOOM_MIN.
This issue only appears if the Calc/Print/Page/ForceBreaks option is
selected and simply ensures the minimum number of pages is at least
the number required by the breaks in the sheet.
Change-Id: Iba36e850081718b1aa43e5c3db3c883530885853
Reviewed-on: https://gerrit.libreoffice.org/6532
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/inc/pagepar.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/pagepar.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/printfun.cxx | 34 |
3 files changed, 36 insertions, 1 deletions
diff --git a/sc/inc/pagepar.hxx b/sc/inc/pagepar.hxx index a898d5a81099..581d08ad7918 100644 --- a/sc/inc/pagepar.hxx +++ b/sc/inc/pagepar.hxx @@ -41,6 +41,7 @@ struct ScPageTableParam sal_Bool bScaleAll; sal_Bool bScaleTo; sal_Bool bScalePageNum; + sal_Bool bForceBreaks; sal_uInt16 nScaleAll; sal_uInt16 nScaleWidth; sal_uInt16 nScaleHeight; diff --git a/sc/source/core/data/pagepar.cxx b/sc/source/core/data/pagepar.cxx index 7cce7c7c2aa3..cf4ef924854c 100644 --- a/sc/source/core/data/pagepar.cxx +++ b/sc/source/core/data/pagepar.cxx @@ -43,7 +43,7 @@ void ScPageTableParam::Reset() bCellContent = sal_True; bNotes=bGrid=bHeaders=bDrawings= bLeftRight=bScaleAll=bScaleTo=bScalePageNum= - bFormulas=bNullVals=bSkipEmpty = false; + bFormulas=bNullVals=bSkipEmpty=bForceBreaks = false; bTopDown=bScaleNone=bCharts=bObjects = sal_True; nScaleAll = 100; nScalePageNum = nScaleWidth = nScaleHeight = 0; diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 6584bb83dbc3..6ab7d1e5a933 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -924,6 +924,8 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) // If pPageData is set, only the breaks are interesting for the // pagebreak preview, empty pages are not addressed separately. + aTableParam.bForceBreaks = pOptions && pOptions->GetForceBreaks(); + //------------------------------------------------------ // TabPage "Parts": //------------------------------------------------------ @@ -2751,6 +2753,21 @@ void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo ) // calcu nZoom = 100; sal_uInt16 nPagesToFit = aTableParam.nScalePageNum; + // If manual breaks are forced, calculate minimum # pages required + if (aTableParam.bForceBreaks) + { + sal_uInt16 nMinPages = 0; + std::set<SCROW> aRowBreaks; + std::set<SCCOL> aColBreaks; + pDoc->GetAllRowBreaks(aRowBreaks, nPrintTab, false, true); + pDoc->GetAllColBreaks(aColBreaks, nPrintTab, false, true); + nMinPages = (aRowBreaks.size() + 1) * (aColBreaks.size() + 1); + + // #i54993# use min forced by breaks if it's > # pages in + // scale parameter to avoid bottoming out at <= ZOOM_MIN + nPagesToFit = nMinPages > nPagesToFit ? nMinPages : nPagesToFit; + } + sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0; while (true) { @@ -2793,6 +2810,23 @@ void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo ) // calcu sal_uInt16 nW = aTableParam.nScaleWidth; sal_uInt16 nH = aTableParam.nScaleHeight; + // If manual breaks are forced, calculate minimum # pages required + if (aTableParam.bForceBreaks) + { + sal_uInt16 nMinPagesW = 0, nMinPagesH = 0; + std::set<SCROW> aRowBreaks; + std::set<SCCOL> aColBreaks; + pDoc->GetAllRowBreaks(aRowBreaks, nPrintTab, false, true); + pDoc->GetAllColBreaks(aColBreaks, nPrintTab, false, true); + nMinPagesW = aColBreaks.size() + 1; + nMinPagesH = aRowBreaks.size() + 1; + + // #i54993# use min forced by breaks if it's > # pages in + // scale parameters to avoid bottoming out at <= ZOOM_MIN + nW = nMinPagesW > nW ? nMinPagesW : nW; + nH = nMinPagesH > nH ? nMinPagesH : nH; + } + sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0; while (true) { |