summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-09-20 17:11:46 +0200
committerLászló Németh <nemeth@numbertext.org>2019-10-04 14:50:56 +0200
commita342efadfbaf5fb92a43e7b7e19e6674f2ea8b0a (patch)
tree884e1ca6a32db167bdb3c9576f475d9557ded125 /sw
parent2debad5fbe059b504da14e65719e6d18c1dc4989 (diff)
tdf#52316 Writer status bar: show also printed page counts
if they are different from the "normal" page counts. If the document contains automatically inserted blank pages, and the document setting "Print automatically inserted blank pages" is disabled, the status bar still shows page counts with blank pages. This is a problem especially, if the user wants to print a document range, because it's not possible to read the correct printing range from the status bar, and using the showed values, printing can result unwanted and missing printed pages without any notice if the Preview option is disabled in the Print dialog window (otherwise if the differency was noticed, it could be hard or near impossible to correct the range using the Preview window). Now, for example, if the title page followed an automatically inserted blank page and a third page, the status bar shows the following on the third page, if there is a differency in printing: Page 3 of 3 (Page 2 of 2 to print) If the setting "Print automatically inserted blank pages" of the actual document is enabled on page "LibreOffice Writer" of the File->Print... dialog window, or the document doesn't contain automatically inserted blank pages, there is no information about printed pages in the status bar (because there is no differency in page counting): Page 3 of 3 Change-Id: I4cef762b8a8c10ae8f65d27c7ff550855219621e Reviewed-on: https://gerrit.libreoffice.org/80185 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/doc.hxx1
-rw-r--r--sw/inc/strings.hrc1
-rw-r--r--sw/source/core/doc/doc.cxx23
-rw-r--r--sw/source/uibase/uiview/view2.cxx25
4 files changed, 46 insertions, 4 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 79ae280c872a..c5075b20f844 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -870,6 +870,7 @@ public:
sal_Int32 nDocPageCount );
static void CalculatePagePairsForProspectPrinting( const SwRootFrame& rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions,
sal_Int32 nDocPageCount );
+ static void CalculateNonBlankPages( const SwRootFrame& rLayout, sal_uInt16& nDocPageCount, sal_uInt16& nActualPage );
// PageDescriptor interface.
size_t GetPageDescCnt() const { return m_PageDescs.size(); }
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 867c03b9bb0d..54323e254cf4 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1231,6 +1231,7 @@
#define STR_PAGE NC_("STR_PAGE", "Page ")
#define STR_PAGE_COUNT NC_("STR_PAGE_COUNT", "Page %1 of %2")
#define STR_PAGE_COUNT_CUSTOM NC_("STR_PAGE_COUNT_CUSTOM", "Page %1 of %2 (Page %3)")
+#define STR_PAGE_COUNT_PRINTED NC_("STR_PAGE_COUNT_PRINTED", "Page %1 of %2 (Page %3 of %4 to print)")
//Strings for gallery/background
#define STR_SWBG_PARAGRAPH NC_("STR_SWBG_PARAGRAPH", "Paragraph")
#define STR_SWBG_GRAPHIC NC_("STR_SWBG_GRAPHIC", "Image")
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 283ee808e008..38b2404c52d8 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -684,6 +684,29 @@ OUString UIPages2PhyPages(const OUString& rUIPageRange, const std::map< sal_Int3
}
}
+// tdf#52316 remove blank pages from page count and actual page number
+void SwDoc::CalculateNonBlankPages(
+ const SwRootFrame& rLayout,
+ sal_uInt16& nDocPageCount,
+ sal_uInt16& nActualPage)
+{
+ sal_uInt16 nDocPageCountWithBlank = nDocPageCount;
+ sal_uInt16 nActualPageWithBlank = nActualPage;
+ sal_uInt16 nPageNum = 1;
+ const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
+ while (pStPage && nPageNum <= nDocPageCountWithBlank)
+ {
+ if ( pStPage->getFrameArea().Height() == 0 )
+ {
+ --nDocPageCount;
+ if (nPageNum <= nActualPageWithBlank)
+ --nActualPage;
+ }
+ ++nPageNum;
+ pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
+ }
+}
+
void SwDoc::CalculatePagesForPrinting(
const SwRootFrame& rLayout,
/* out */ SwRenderData &rData,
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index ea8b81a467f1..b708f47d3b83 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -82,6 +82,8 @@
#include <uivwimp.hxx>
#include <docsh.hxx>
#include <doc.hxx>
+#include <printdata.hxx>
+#include <IDocumentDeviceAccess.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
@@ -195,7 +197,7 @@ static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhi
* @param nVirtNum The logical page number (user-assigned)
* @param rPgStr User-defined page name (will be shown if different from logical page number)
*
- * @return OUString Formatted string: Page 1/10 (Page nVirtNumv/rPgStr)
+ * @return OUString Formatted string: Page 1 of 10 (Page 1 of 8 to print OR Page nVirtNumv/rPgStr)
**/
OUString SwView::GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
{
@@ -206,10 +208,25 @@ OUString SwView::GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUStr
else if (nPhyNum != nVirtNum)
extra = OUString::number(nVirtNum);
- OUString aStr(extra.isEmpty() ? SwResId(STR_PAGE_COUNT) : SwResId(STR_PAGE_COUNT_CUSTOM));
+ sal_uInt16 nPageCount = GetWrtShell().GetPageCnt();
+ sal_uInt16 nPrintedPhyNum = nPhyNum;
+ sal_uInt16 nPrintedPageCount = nPageCount;
+ if (!GetWrtShell().getIDocumentDeviceAccess().getPrintData().IsPrintEmptyPages())
+ SwDoc::CalculateNonBlankPages(*m_pWrtShell->GetLayout(), nPrintedPageCount, nPrintedPhyNum);
+ // Show printed page numbers only, when they are different
+ OUString aStr( nPageCount != nPrintedPageCount
+ ? SwResId(STR_PAGE_COUNT_PRINTED)
+ : (extra.isEmpty() ? SwResId(STR_PAGE_COUNT) : SwResId(STR_PAGE_COUNT_CUSTOM)));
aStr = aStr.replaceFirst("%1", OUString::number(nPhyNum));
- aStr = aStr.replaceFirst("%2", OUString::number(GetWrtShell().GetPageCnt()));
- aStr = aStr.replaceFirst("%3", extra);
+ aStr = aStr.replaceFirst("%2", OUString::number(nPageCount));
+ if (nPageCount != nPrintedPageCount)
+ {
+ aStr = aStr.replaceFirst("%3", OUString::number(nPrintedPhyNum));
+ aStr = aStr.replaceFirst("%4", OUString::number(nPrintedPageCount));
+ }
+ else
+ aStr = aStr.replaceFirst("%3", extra);
+
return aStr;
}