Skip to content

Commit

Permalink
fix for fdo#30800: Option to display calc gridlines on colored cells
Browse files Browse the repository at this point in the history
* change UI option for grid line display to tri-state drop down
* view option VOPT_GRID will take the information wheter to "Show"
  or "Hide" grid lines. New view option VOPT_GRID_ONTOP will take
  the information wheter to display grid lines on top of colored
  cells or not
* depending on VOPT_GRID_ONTOP grid lines will be drawn before or
  after drawing cell background in ScGridWindow::Draw
* store option as boolean property "GridOnColoredCells" (path:
  "/org.openoffice.Office.Calc/Layout/Line") in user config
* see
  http://wiki.documentfoundation.org/User:Andreschnabel/Spec_Calc_grid_lines_on_colored_background#UI_definitions
  for spec
  • Loading branch information
André Schnabel authored and Katarina Machalkova committed Jul 6, 2011
1 parent 9b28cc8 commit 0c95b19
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 25 deletions.
1 change: 1 addition & 0 deletions sc/inc/viewopti.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum ScViewOption
VOPT_OUTLINER,
VOPT_HEADER,
VOPT_GRID,
VOPT_GRID_ONTOP,
VOPT_HELPLINES,
VOPT_ANCHOR,
VOPT_PAGEBREAKS,
Expand Down
11 changes: 10 additions & 1 deletion sc/source/core/tool/viewopti.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void ScViewOptions::SetDefaults()
aOptArr[ VOPT_FORMULAS ] =
aOptArr[ VOPT_SYNTAX ] =
aOptArr[ VOPT_HELPLINES ] =
aOptArr[ VOPT_GRID_ONTOP ] =
aOptArr[ VOPT_BIGHANDLES ] = false;
aOptArr[ VOPT_NOTES ] =
aOptArr[ VOPT_NULLVALS ] =
Expand Down Expand Up @@ -308,7 +309,8 @@ SfxPoolItem* ScTpViewItem::Clone( SfxItemPool * ) const
#define SCLAYOUTOPT_VERTSCROLL 8
#define SCLAYOUTOPT_SHEETTAB 9
#define SCLAYOUTOPT_OUTLINE 10
#define SCLAYOUTOPT_COUNT 11
#define SCLAYOUTOPT_GRID_ONCOLOR 11
#define SCLAYOUTOPT_COUNT 12

#define CFGPATH_DISPLAY "Office.Calc/Content/Display"

Expand Down Expand Up @@ -343,6 +345,7 @@ Sequence<OUString> ScViewCfg::GetLayoutPropertyNames()
static const char* aPropNames[] =
{
"Line/GridLine", // SCLAYOUTOPT_GRIDLINES
"Line/GridOnColoredCells", // SCLAYOUTOPT_GRID_ONCOLOR
"Line/GridLineColor", // SCLAYOUTOPT_GRIDCOLOR
"Line/PageBreak", // SCLAYOUTOPT_PAGEBREAK
"Line/Guide", // SCLAYOUTOPT_GUIDE
Expand Down Expand Up @@ -445,6 +448,9 @@ ScViewCfg::ScViewCfg() :
case SCLAYOUTOPT_GRIDLINES:
SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break;
case SCLAYOUTOPT_GRID_ONCOLOR:
SetOption( VOPT_GRID_ONTOP, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break;
case SCLAYOUTOPT_PAGEBREAK:
SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break;
Expand Down Expand Up @@ -613,6 +619,9 @@ IMPL_LINK( ScViewCfg, LayoutCommitHdl, void *, EMPTYARG )
case SCLAYOUTOPT_GRIDLINES:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID ) );
break;
case SCLAYOUTOPT_GRID_ONCOLOR:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID_ONTOP ) );
break;
case SCLAYOUTOPT_PAGEBREAK:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_PAGEBREAKS ) );
break;
Expand Down
3 changes: 2 additions & 1 deletion sc/source/ui/inc/optdlg.hrc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
#define CB_TBLREG 54
#define CB_OUTLINE 55
#define GB_LINES 56
#define CB_GRID 57
#define FT_COLOR 58
#define LB_COLOR 59
#define CB_GUIDELINE 60
Expand All @@ -162,6 +161,8 @@
#define FL_SEPARATOR1 71
#define FL_SEPARATOR2 72
#define FL_SEPARATOR 73
#define FT_GRID 74
#define LB_GRID 75

// TP_INPUT
#define GB_OPTIONS 70
Expand Down
5 changes: 3 additions & 2 deletions sc/source/ui/inc/tpview.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class ScViewOptions;
class ScTpContentOptions : public SfxTabPage
{
FixedLine aLinesGB;
CheckBox aGridCB;
FixedText aGridFT;
ListBox aGridLB;
FixedText aColorFT;
ColorListBox aColorLB;
CheckBox aBreakCB;
Expand Down Expand Up @@ -89,7 +90,7 @@ class ScTpContentOptions : public SfxTabPage
ScViewOptions* pLocalOptions;

void InitGridOpt();
DECL_LINK( GridHdl, CheckBox* );
DECL_LINK( GridHdl, ListBox* );
DECL_LINK( SelLbObjHdl, ListBox* );
DECL_LINK( CBHdl, CheckBox* );

Expand Down
50 changes: 33 additions & 17 deletions sc/source/ui/optdlg/tpview.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ ScTpContentOptions::ScTpContentOptions( Window* pParent,
SfxTabPage(pParent, ScResId( RID_SCPAGE_CONTENT ), rArgSet),

aLinesGB( this, ScResId(GB_LINES )),
aGridCB( this, ScResId(CB_GRID )),
aGridFT( this, ScResId(FT_GRID )),
aGridLB( this, ScResId(LB_GRID )),
aColorFT( this, ScResId(FT_COLOR )),
aColorLB( this, ScResId(LB_COLOR )),
aBreakCB( this, ScResId(CB_PAGEBREAKS )),
Expand Down Expand Up @@ -108,6 +109,7 @@ ScTpContentOptions::ScTpContentOptions( Window* pParent,
aObjGrfLB. SetSelectHdl(aSelObjHdl);
aDiagramLB. SetSelectHdl(aSelObjHdl);
aDrawLB. SetSelectHdl(aSelObjHdl);
aGridLB. SetSelectHdl( LINK( this, ScTpContentOptions, GridHdl ) );

Link aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) );
aFormulaCB .SetClickHdl(aCBHdl);
Expand All @@ -127,7 +129,6 @@ ScTpContentOptions::ScTpContentOptions( Window* pParent,
aBigHandleCB.SetClickHdl(aCBHdl);
aRowColHeaderCB.SetClickHdl(aCBHdl);

aGridCB .SetClickHdl( LINK( this, ScTpContentOptions, GridHdl ) );
}

ScTpContentOptions::~ScTpContentOptions()
Expand All @@ -153,7 +154,7 @@ sal_Bool ScTpContentOptions::FillItemSet( SfxItemSet& rCoreSet )
aObjGrfLB .GetSavedValue() != aObjGrfLB .GetSelectEntryPos() ||
aDiagramLB .GetSavedValue() != aDiagramLB .GetSelectEntryPos() ||
aDrawLB .GetSavedValue() != aDrawLB .GetSelectEntryPos() ||
aGridCB .GetSavedValue() != aGridCB.IsChecked() ||
aGridLB .GetSavedValue() != aGridLB .GetSelectEntryPos() ||
aRowColHeaderCB .GetSavedValue() != aRowColHeaderCB.IsChecked() ||
aHScrollCB .GetSavedValue() != aHScrollCB .IsChecked() ||
aVScrollCB .GetSavedValue() != aVScrollCB .IsChecked() ||
Expand Down Expand Up @@ -239,7 +240,7 @@ void ScTpContentOptions::Reset( const SfxItemSet& rCoreSet )
aVScrollCB .SaveValue();
aTblRegCB .SaveValue();
aOutlineCB .SaveValue();
aGridCB .SaveValue();
aGridLB .SaveValue();
aColorLB .SaveValue();
aBreakCB .SaveValue();
aGuideLineCB .SaveValue();
Expand Down Expand Up @@ -310,19 +311,30 @@ IMPL_LINK( ScTpContentOptions, CBHdl, CheckBox*, pBtn )

void ScTpContentOptions::InitGridOpt()
{
sal_Bool bGrid = pLocalOptions->GetOption( VOPT_GRID );

aGridCB.Check( bGrid );
sal_Bool bGrid = pLocalOptions->GetOption( VOPT_GRID );
sal_Bool bGridOnTop = pLocalOptions->GetOption( VOPT_GRID_ONTOP );
sal_uInt16 nSelPos = 0;

if ( bGrid )
{
aColorFT.Enable(), aColorLB.Enable();
if ( !bGridOnTop )
nSelPos = 0;
else
nSelPos = 1;
}
else
{
aColorFT.Disable(), aColorLB.Disable();
nSelPos = 2;
}

aGridLB.SelectEntryPos (nSelPos);

if ( aColorLB.GetEntryCount() == 0 )
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
// hier koennte auch eine andere DocShell kommen!
// there might be another DocShell here
pDocSh = PTR_CAST(ScDocShell, pDocSh);

XColorTable* pColorTable = NULL;
Expand All @@ -344,7 +356,7 @@ void ScTpContentOptions::InitGridOpt()

aColorLB.SetUpdateMode( false );

// Eintraege aus der Colortable
// items from ColorTable

long nCount = pColorTable->Count();
for ( long n=0; n<nCount; n++ )
Expand All @@ -353,9 +365,9 @@ void ScTpContentOptions::InitGridOpt()
aColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}

// Standard-Gitterfarbe
// default GridColor

Color aStdCol( SC_STD_GRIDCOLOR ); // wie Default in ScViewOptions
Color aStdCol( SC_STD_GRIDCOLOR ); // same default as in ScViewOptions
if ( LISTBOX_ENTRY_NOTFOUND ==
aColorLB.GetEntryPos( aStdCol ) )
aColorLB.InsertEntry( aStdCol, ScGlobal::GetRscString( STR_GRIDCOLOR ) );
Expand All @@ -369,20 +381,24 @@ void ScTpContentOptions::InitGridOpt()

String aName;
Color aCol = pLocalOptions->GetGridColor( &aName );
sal_uInt16 nSelPos = aColorLB.GetEntryPos( aCol );
nSelPos = aColorLB.GetEntryPos( aCol );

if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
aColorLB.SelectEntryPos( nSelPos );
else
aColorLB.SelectEntryPos( aColorLB.InsertEntry( aCol, aName ) );
}

IMPL_LINK( ScTpContentOptions, GridHdl, CheckBox*, pBox )
IMPL_LINK( ScTpContentOptions, GridHdl, ListBox*, pLb )
{
sal_Bool bChecked = pBox->IsChecked();
aColorFT.Enable(bChecked);
aColorLB.Enable(bChecked);
pLocalOptions->SetOption( VOPT_GRID, bChecked );
sal_uInt16 nSelPos = pLb->GetSelectEntryPos();
sal_Bool bGrid = ( nSelPos <= 1 );
sal_Bool bGridOnTop = ( nSelPos == 1 );

aColorFT.Enable(bGridOnTop);
aColorLB.Enable(bGridOnTop);
pLocalOptions->SetOption( VOPT_GRID, bGrid );
pLocalOptions->SetOption( VOPT_GRID_ONTOP, bGridOnTop );
return 0;
}

Expand Down
21 changes: 18 additions & 3 deletions sc/source/ui/src/optdlg.src
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,28 @@ TabPage RID_SCPAGE_CONTENT
Size = MAP_APPFONT ( 121 , 8 ) ;
Text [ en-US ] = "Visual aids";
};
CheckBox CB_GRID
FixedText FT_GRID
{
HelpID = "sc:CheckBox:RID_SCPAGE_CONTENT:CB_GRID";
HelpID = "sc:CheckBox:RID_SCPAGE_CONTENT:FT_GRID";
Pos = MAP_APPFONT ( 12 , 14 ) ;
Size = MAP_APPFONT ( 112 , 10 ) ;
Size = MAP_APPFONT ( 40 , 8 ) ;
Text [ en-US ] = "~Grid lines" ;
};
ListBox LB_GRID
{
HelpID = "sc:ListBox:RID_SCPAGE_CONTENT:LB_GRID";
Pos = MAP_APPFONT ( 54 , 12 ) ;
Size = MAP_APPFONT ( 70 , 46 ) ;
Border = TRUE ;
DropDown = TRUE ;
StringList [ en-US ] =
{
< "Show" ; Default ; > ;
< "Show on colored cells" ; Default ; > ;
< "Hide" ; Default ; > ;
};

};
FixedText FT_COLOR
{
Pos = MAP_APPFONT ( 21 , 28 ) ;
Expand Down
2 changes: 1 addition & 1 deletion sc/source/ui/view/gridwin4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
{
ScModule* pScMod = SC_MOD();
sal_Bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
sal_Bool bGridFirst = true; //! entscheiden!!!

if (pViewData->IsMinimized())
return;
Expand Down Expand Up @@ -543,6 +542,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
aOutputData.SetViewShell( pViewData->GetViewShell() );

sal_Bool bGrid = rOpts.GetOption( VOPT_GRID ) && pViewData->GetShowGrid();
sal_Bool bGridFirst = !rOpts.GetOption( VOPT_GRID_ONTOP );

sal_Bool bPage = rOpts.GetOption( VOPT_PAGEBREAKS );

Expand Down

0 comments on commit 0c95b19

Please sign in to comment.