Kaydet (Commit) 9040ef49 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

cp#1000022: Display message in print preview when there is nothing to show.

To make this experience slightly less confusing.

Change-Id: I844dd2cdbc0349433d445955cdcf5e9723673286
üst 12b2461a
...@@ -689,7 +689,10 @@ ...@@ -689,7 +689,10 @@
#define STR_ROWCOL_SELCOUNT 528 #define STR_ROWCOL_SELCOUNT 528
#define SC_GLOBSTR_STR_COUNT 529 /**< the count of permanently resident strings */ #define STR_PRINT_PREVIEW_NODATA 529
#define STR_PRINT_PREVIEW_EMPTY_RANGE 530
#define SC_GLOBSTR_STR_COUNT 531 /**< the count of permanently resident strings */
#endif #endif
......
...@@ -80,6 +80,7 @@ private: ...@@ -80,6 +80,7 @@ private:
bool bFooterRulerChange:1; bool bFooterRulerChange:1;
bool bPageMargin:1; bool bPageMargin:1;
bool bColRulerMove:1; bool bColRulerMove:1;
bool mbHasEmptyRangeTable:1; /// we have at least one sheet with empty print range (print range set to '- none -').
ScRange aPageArea; ScRange aPageArea;
long nRight[ MAXCOL+1 ]; long nRight[ MAXCOL+1 ];
......
...@@ -167,6 +167,7 @@ private: ...@@ -167,6 +167,7 @@ private:
sal_uInt16 nZoom; sal_uInt16 nZoom;
bool bPrintCurrentTable; bool bPrintCurrentTable;
bool bMultiArea; bool bMultiArea;
bool mbHasPrintRange;
long nTabPages; long nTabPages;
long nTotalPages; long nTotalPages;
...@@ -276,6 +277,8 @@ public: ...@@ -276,6 +277,8 @@ public:
ScPrintHFParam GetHeader(){return aHdr;} ScPrintHFParam GetHeader(){return aHdr;}
ScPrintHFParam GetFooter(){return aFtr;} ScPrintHFParam GetFooter(){return aFtr;}
bool HasPrintRange() const;
private: private:
void Construct( const ScPrintOptions* pOptions ); void Construct( const ScPrintOptions* pOptions );
void InitParam( const ScPrintOptions* pOptions ); void InitParam( const ScPrintOptions* pOptions );
......
...@@ -2061,6 +2061,16 @@ Resource RID_GLOBSTR ...@@ -2061,6 +2061,16 @@ Resource RID_GLOBSTR
{ {
Text [ en-US ] = "click to open hyperlink:"; Text [ en-US ] = "click to open hyperlink:";
}; };
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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
#include <svx/algitem.hxx> #include <svx/algitem.hxx>
#include <editeng/lrspitem.hxx> #include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx> #include <editeng/ulspitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/fhgtitem.hxx>
#include "attrib.hxx" #include "attrib.hxx"
#include "pagepar.hxx" #include "pagepar.hxx"
#include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessible.hpp>
...@@ -60,6 +62,10 @@ ...@@ -60,6 +62,10 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include "viewutil.hxx" #include "viewutil.hxx"
#include <columnspanset.hxx> #include <columnspanset.hxx>
#include <docpool.hxx>
#include <patattr.hxx>
#include <boost/scoped_ptr.hpp>
// STATIC DATA ----------------------------------------------------------- // STATIC DATA -----------------------------------------------------------
...@@ -118,6 +124,7 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView ...@@ -118,6 +124,7 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView
bFooterRulerChange( false ), bFooterRulerChange( false ),
bPageMargin ( false ), bPageMargin ( false ),
bColRulerMove( false ), bColRulerMove( false ),
mbHasEmptyRangeTable(false),
mnScale( 0 ), mnScale( 0 ),
nColNumberButttonDown( 0 ), nColNumberButttonDown( 0 ),
nHeaderHeight ( 0 ), nHeaderHeight ( 0 ),
...@@ -258,6 +265,9 @@ void ScPreview::CalcPages() ...@@ -258,6 +265,9 @@ void ScPreview::CalcPages()
long nThisStart = nTotalPages; long nThisStart = nTotalPages;
ScPrintFunc aPrintFunc( this, pDocShell, i, nAttrPage, 0, NULL, &aOptions ); ScPrintFunc aPrintFunc( this, pDocShell, i, nAttrPage, 0, NULL, &aOptions );
long nThisTab = aPrintFunc.GetTotalPages(); long nThisTab = aPrintFunc.GetTotalPages();
if (!aPrintFunc.HasPrintRange())
mbHasEmptyRangeTable = true;
nPages[i] = nThisTab; nPages[i] = nThisTab;
nTotalPages += nThisTab; nTotalPages += nThisTab;
nFirstAttr[i] = aPrintFunc.GetFirstPageNo(); // to keep or from template nFirstAttr[i] = aPrintFunc.GetFirstPageNo(); // to keep or from template
...@@ -481,6 +491,59 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) ...@@ -481,6 +491,59 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
bool bRight = nPageEndX <= aWinEnd.X(); bool bRight = nPageEndX <= aWinEnd.X();
bool bBottom = nPageEndY <= aWinEnd.Y(); 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 ) if( bPageMargin && bValidPage )
{ {
SetMapMode(aMMMode); SetMapMode(aMMMode);
......
...@@ -227,6 +227,7 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa ...@@ -227,6 +227,7 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa
bSourceRangeValid ( false ), bSourceRangeValid ( false ),
bPrintCurrentTable ( false ), bPrintCurrentTable ( false ),
bMultiArea ( false ), bMultiArea ( false ),
mbHasPrintRange(true),
nTabPages ( 0 ), nTabPages ( 0 ),
nTotalPages ( 0 ), nTotalPages ( 0 ),
nPagesX(0), nPagesX(0),
...@@ -253,6 +254,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab, ...@@ -253,6 +254,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
bSourceRangeValid ( false ), bSourceRangeValid ( false ),
bPrintCurrentTable ( false ), bPrintCurrentTable ( false ),
bMultiArea ( false ), bMultiArea ( false ),
mbHasPrintRange(true),
nTabPages ( 0 ), nTabPages ( 0 ),
nTotalPages ( 0 ), nTotalPages ( 0 ),
nPagesX(0), nPagesX(0),
...@@ -273,6 +275,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, ...@@ -273,6 +275,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
bSourceRangeValid ( false ), bSourceRangeValid ( false ),
bPrintCurrentTable ( false ), bPrintCurrentTable ( false ),
bMultiArea ( false ), bMultiArea ( false ),
mbHasPrintRange(true),
nPagesX(0), nPagesX(0),
nPagesY(0), nPagesY(0),
nTotalY(0), nTotalY(0),
...@@ -313,6 +316,11 @@ void ScPrintFunc::GetPrintState( ScPrintState& rState ) ...@@ -313,6 +316,11 @@ void ScPrintFunc::GetPrintState( ScPrintState& rState )
rState.nDocPages = nDocPages; rState.nDocPages = nDocPages;
} }
bool ScPrintFunc::HasPrintRange() const
{
return mbHasPrintRange;
}
bool ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const bool ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const
{ {
rRange = aLastSourceRange; rRange = aLastSourceRange;
...@@ -948,6 +956,13 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) ...@@ -948,6 +956,13 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
// ignoring ATTR_PAGE_PRINTTABLES // 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 if ( pUserArea ) // UserArea (selection) has prority
{ {
bPrintCurrentTable = bPrintCurrentTable =
...@@ -958,7 +973,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) ...@@ -958,7 +973,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
aAreaParam.aPrintArea.aStart.SetTab(nPrintTab); aAreaParam.aPrintArea.aStart.SetTab(nPrintTab);
aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab); aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab);
} }
else if ( pDoc->HasPrintRange() ) else if (bHasPrintRange)
{ {
if ( pPrintArea ) // at least one set? if ( pPrintArea ) // at least one set?
{ {
...@@ -966,7 +981,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) ...@@ -966,7 +981,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
aAreaParam.bPrintArea = true; aAreaParam.bPrintArea = true;
aAreaParam.aPrintArea = *pPrintArea; aAreaParam.aPrintArea = *pPrintArea;
bMultiArea = ( pDoc->GetPrintRangeCount(nPrintTab) > 1 ); bMultiArea = nPrintRangeCount > 1;
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment