[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Mar 19 17:04:32 PDT 2014
sc/inc/globstr.hrc | 5 ++-
sc/source/ui/inc/preview.hxx | 1
sc/source/ui/inc/printfun.hxx | 3 +
sc/source/ui/src/globstr.src | 10 ++++++
sc/source/ui/view/preview.cxx | 63 +++++++++++++++++++++++++++++++++++++++++
sc/source/ui/view/printfun.cxx | 19 +++++++++++-
6 files changed, 98 insertions(+), 3 deletions(-)
New commits:
commit c1d0f15f673c26feaf377896f91f751ca96bbc46
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Mar 19 14:05:04 2014 -0400
cp#1000022: Display message in print preview when there is nothing to show.
To make this experience slightly less confusing.
(cherry picked from commit 9040ef49f0b2886a51630878c06b2fb9cf94b927)
Conflicts:
sc/inc/globstr.hrc
sc/source/ui/inc/printfun.hxx
sc/source/ui/src/globstr.src
sc/source/ui/view/preview.cxx
sc/source/ui/view/printfun.cxx
Change-Id: I844dd2cdbc0349433d445955cdcf5e9723673286
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 7dc6cd6..53e6e30 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -673,7 +673,10 @@
#define STR_FUN_TEXT_SELECTION_COUNT 546
-#define STR_COUNT 547
+#define STR_PRINT_PREVIEW_NODATA 547
+#define STR_PRINT_PREVIEW_EMPTY_RANGE 548
+
+#define STR_COUNT 549
#endif
diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index d88d973..2ecc07c 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -80,6 +80,7 @@ private:
bool bFooterRulerChange:1;
bool bPageMargin:1;
bool bColRulerMove:1;
+ bool mbHasEmptyRangeTable:1; /// we have at least one sheet with empty print range (print range set to '- none -').
ScRange aPageArea;
long nRight[ MAXCOL+1 ];
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 7273283..3e42715 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -167,6 +167,7 @@ private:
sal_uInt16 nZoom;
sal_Bool bPrintCurrentTable;
sal_Bool bMultiArea;
+ bool mbHasPrintRange;
long nTabPages;
long nTotalPages;
@@ -275,6 +276,8 @@ public:
ScPrintHFParam GetHeader(){return aHdr;}
ScPrintHFParam GetFooter(){return aFtr;}
+ bool HasPrintRange() const;
+
private:
void Construct( const ScPrintOptions* pOptions );
void InitParam( const ScPrintOptions* pOptions );
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index b9ffd2a..ee64094 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -2065,6 +2065,16 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Invalid condition." ;
};
+
+ String STR_PRINT_PREVIEW_NODATA
+ {
+ Text [ en-US ] = "Empty Content";
+ };
+
+ String STR_PRINT_PREVIEW_EMPTY_RANGE
+ {
+ Text [ en-US ] = "Empty Print Range";
+ };
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 8ad3ec4..776a265 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -52,12 +52,18 @@
#include <svx/algitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/fhgtitem.hxx>
#include "attrib.hxx"
#include "pagepar.hxx"
#include <com/sun/star/accessibility/XAccessible.hpp>
#include "AccessibilityHints.hxx"
#include <vcl/svapp.hxx>
#include "viewutil.hxx"
+#include <docpool.hxx>
+#include <patattr.hxx>
+
+#include <boost/scoped_ptr.hpp>
// STATIC DATA -----------------------------------------------------------
@@ -116,6 +122,7 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView
bFooterRulerChange( false ),
bPageMargin ( false ),
bColRulerMove( false ),
+ mbHasEmptyRangeTable(false),
mnScale( 0 ),
nColNumberButttonDown( 0 ),
nHeaderHeight ( 0 ),
@@ -256,6 +263,9 @@ void ScPreview::CalcPages()
long nThisStart = nTotalPages;
ScPrintFunc aPrintFunc( this, pDocShell, i, nAttrPage, 0, NULL, &aOptions );
long nThisTab = aPrintFunc.GetTotalPages();
+ if (!aPrintFunc.HasPrintRange())
+ mbHasEmptyRangeTable = true;
+
nPages[i] = nThisTab;
nTotalPages += nThisTab;
nFirstAttr[i] = aPrintFunc.GetFirstPageNo(); // to keep or from template
@@ -479,6 +489,59 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
bool bRight = nPageEndX <= aWinEnd.X();
bool bBottom = nPageEndY <= aWinEnd.Y();
+ if (!nTotalPages)
+ {
+ // There is no data to print. Print a friendly warning message and
+ // bail out.
+
+ SetMapMode(aMMMode);
+
+ // Draw background first.
+ SetLineColor();
+ SetFillColor(aBackColor);
+ DrawRect(Rectangle(0, 0, aWinEnd.X(), aWinEnd.Y()));
+
+ const ScPatternAttr& rDefPattern =
+ static_cast<const ScPatternAttr&>(
+ pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN));
+
+ boost::scoped_ptr<ScEditEngineDefaulter> pEditEng(
+ new ScEditEngineDefaulter(EditEngine::CreatePool(), true));
+
+ pEditEng->SetRefMapMode(aMMMode);
+ SfxItemSet* pEditDefaults = new SfxItemSet( pEditEng->GetEmptyItemSet() );
+ rDefPattern.FillEditItemSet(pEditDefaults);
+ pEditEng->SetDefaults(pEditDefaults, true);
+
+ Color aTextColor(COL_LIGHTGRAY);
+ pEditDefaults->Put(SvxColorItem(aTextColor, EE_CHAR_COLOR));
+
+ OUString aEmptyMsg;
+ if (mbHasEmptyRangeTable)
+ aEmptyMsg = ScGlobal::GetRscString(STR_PRINT_PREVIEW_EMPTY_RANGE);
+ else
+ aEmptyMsg = ScGlobal::GetRscString(STR_PRINT_PREVIEW_NODATA);
+
+ long nHeight = 3000;
+ pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT));
+ pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
+ pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
+
+ pEditEng->SetText(aEmptyMsg);
+
+ // Calculate text position so that the text appears at the center
+ // of the screen center-aligned.
+ Size aTextSize(pEditEng->CalcTextWidth(), pEditEng->GetTextHeight());
+
+ Point aCenter(
+ (aWinEnd.X() - pEditEng->CalcTextWidth())/2,
+ (aWinEnd.Y() - pEditEng->GetTextHeight())/2);
+
+ pEditEng->Draw(this, aCenter);
+
+ return;
+ }
+
if( bPageMargin && bValidPage )
{
SetMapMode(aMMMode);
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 9ac8230..a8b5330 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -230,6 +230,7 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa
bSourceRangeValid ( false ),
bPrintCurrentTable ( false ),
bMultiArea ( false ),
+ mbHasPrintRange(true),
nTabPages ( 0 ),
nTotalPages ( 0 ),
nPagesX(0),
@@ -256,6 +257,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
bSourceRangeValid ( false ),
bPrintCurrentTable ( false ),
bMultiArea ( false ),
+ mbHasPrintRange(true),
nTabPages ( 0 ),
nTotalPages ( 0 ),
nPagesX(0),
@@ -276,6 +278,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
bSourceRangeValid ( false ),
bPrintCurrentTable ( false ),
bMultiArea ( false ),
+ mbHasPrintRange(true),
nPagesX(0),
nPagesY(0),
nTotalY(0),
@@ -316,6 +319,11 @@ void ScPrintFunc::GetPrintState( ScPrintState& rState )
rState.nDocPages = nDocPages;
}
+bool ScPrintFunc::HasPrintRange() const
+{
+ return mbHasPrintRange;
+}
+
sal_Bool ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const
{
rRange = aLastSourceRange;
@@ -935,6 +943,13 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
// ignoring ATTR_PAGE_PRINTTABLES
+ bool bHasPrintRange = pDoc->HasPrintRange();
+ sal_uInt16 nPrintRangeCount = pDoc->GetPrintRangeCount(nPrintTab);
+ bool bPrintEntireSheet = pDoc->IsPrintEntireSheet(nPrintTab);
+
+ if (!bPrintEntireSheet && !nPrintRangeCount)
+ mbHasPrintRange = false;
+
if ( pUserArea ) // UserArea (selection) has prority
{
bPrintCurrentTable =
@@ -945,7 +960,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
aAreaParam.aPrintArea.aStart.SetTab(nPrintTab);
aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab);
}
- else if ( pDoc->HasPrintRange() )
+ else if (bHasPrintRange)
{
if ( pPrintArea ) // at least one set?
{
@@ -953,7 +968,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
aAreaParam.bPrintArea = sal_True;
aAreaParam.aPrintArea = *pPrintArea;
- bMultiArea = ( pDoc->GetPrintRangeCount(nPrintTab) > 1 );
+ bMultiArea = nPrintRangeCount > 1;
}
else
{
More information about the Libreoffice-commits
mailing list