xref: /trunk/main/sc/source/ui/optdlg/opredlin.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir //------------------------------------------------------------------
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <svx/dlgutil.hxx>
38*cdf0e10cSrcweir #include <svx/drawitem.hxx>
39*cdf0e10cSrcweir #include <svx/xtable.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "appoptio.hxx"
42*cdf0e10cSrcweir #include "scmod.hxx"
43*cdf0e10cSrcweir #include "scitems.hxx"
44*cdf0e10cSrcweir #include "tpview.hxx"
45*cdf0e10cSrcweir #include "global.hxx"
46*cdf0e10cSrcweir #include "viewopti.hxx"
47*cdf0e10cSrcweir #include "tabvwsh.hxx"
48*cdf0e10cSrcweir #include "uiitems.hxx"
49*cdf0e10cSrcweir #include "scresid.hxx"
50*cdf0e10cSrcweir #include "docsh.hxx"
51*cdf0e10cSrcweir #include "sc.hrc"       // -> Slot-IDs
52*cdf0e10cSrcweir #include "optdlg.hrc"
53*cdf0e10cSrcweir #include "globstr.hrc"
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include "opredlin.hxx"
56*cdf0e10cSrcweir #include "opredlin.hrc"
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //------------------------------------------------------------------
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent,
61*cdf0e10cSrcweir 													const SfxItemSet& rSet )
62*cdf0e10cSrcweir 	: SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet),
63*cdf0e10cSrcweir 	aContentFT      ( this, ScResId(FT_CONTENT	)),
64*cdf0e10cSrcweir 	aContentColorLB ( this, ScResId(CLB_CONTENT	)),
65*cdf0e10cSrcweir 	aRemoveFT       ( this, ScResId(FT_REMOVE	)),
66*cdf0e10cSrcweir 	aRemoveColorLB	( this, ScResId(CLB_REMOVE	)),
67*cdf0e10cSrcweir 	aInsertFT       ( this, ScResId(FT_INSERT	)),
68*cdf0e10cSrcweir 	aInsertColorLB  ( this, ScResId(CLB_INSERT	)),
69*cdf0e10cSrcweir 	aMoveFT         ( this, ScResId(FT_MOVE		)),
70*cdf0e10cSrcweir 	aMoveColorLB    ( this, ScResId(CLB_MOVE	)),
71*cdf0e10cSrcweir 	aChangedGB		( this, ScResId(GB_COLORCHGS)),
72*cdf0e10cSrcweir 	aAuthorStr		(ScResId(STR_AUTHOR))
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir 	FreeResource();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl);
77*cdf0e10cSrcweir 	aContentColorLB.SetSelectHdl( aLk );
78*cdf0e10cSrcweir 	aMoveColorLB.SetSelectHdl( aLk );
79*cdf0e10cSrcweir 	aInsertColorLB.SetSelectHdl( aLk );
80*cdf0e10cSrcweir 	aRemoveColorLB.SetSelectHdl( aLk );
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir /*-----------------------------------------------------------------------
84*cdf0e10cSrcweir 	Beschreibung:
85*cdf0e10cSrcweir  -----------------------------------------------------------------------*/
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir __EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir /*-----------------------------------------------------------------------
92*cdf0e10cSrcweir 	Beschreibung:
93*cdf0e10cSrcweir  -----------------------------------------------------------------------*/
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir SfxTabPage*	__EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	return new ScRedlineOptionsTabPage( pParent, rSet );
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir /*-----------------------------------------------------------------------
101*cdf0e10cSrcweir 	Beschreibung:
102*cdf0e10cSrcweir  -----------------------------------------------------------------------*/
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir sal_Bool __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ )
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	sal_uLong nNew=0;
109*cdf0e10cSrcweir 	sal_uInt16 nPos=0;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	nPos = aContentColorLB.GetSelectEntryPos();
112*cdf0e10cSrcweir 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
113*cdf0e10cSrcweir 	{
114*cdf0e10cSrcweir 		nPos = aContentColorLB.GetSelectEntryPos();
115*cdf0e10cSrcweir 		if (nPos!=0)
116*cdf0e10cSrcweir 			nNew= aContentColorLB.GetEntryColor(nPos).GetColor();
117*cdf0e10cSrcweir 		else
118*cdf0e10cSrcweir 			nNew= COL_TRANSPARENT;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 		aAppOptions.SetTrackContentColor(nNew);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	}
123*cdf0e10cSrcweir 	nPos = aMoveColorLB.GetSelectEntryPos();
124*cdf0e10cSrcweir 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
125*cdf0e10cSrcweir 	{
126*cdf0e10cSrcweir 		nPos = aMoveColorLB.GetSelectEntryPos();
127*cdf0e10cSrcweir 		if (nPos!=0)
128*cdf0e10cSrcweir 			nNew= aMoveColorLB.GetEntryColor(nPos).GetColor();
129*cdf0e10cSrcweir 		else
130*cdf0e10cSrcweir 			nNew= COL_TRANSPARENT;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 		aAppOptions.SetTrackMoveColor(nNew);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	}
135*cdf0e10cSrcweir 	nPos = aInsertColorLB.GetSelectEntryPos();
136*cdf0e10cSrcweir 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
137*cdf0e10cSrcweir 	{
138*cdf0e10cSrcweir 		nPos = aInsertColorLB.GetSelectEntryPos();
139*cdf0e10cSrcweir 		if (nPos!=0)
140*cdf0e10cSrcweir 			nNew= aInsertColorLB.GetEntryColor(nPos).GetColor();
141*cdf0e10cSrcweir 		else
142*cdf0e10cSrcweir 			nNew= COL_TRANSPARENT;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 		aAppOptions.SetTrackInsertColor(nNew);
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	}
147*cdf0e10cSrcweir 	nPos = aRemoveColorLB.GetSelectEntryPos();
148*cdf0e10cSrcweir 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
149*cdf0e10cSrcweir 	{
150*cdf0e10cSrcweir 		nPos = aRemoveColorLB.GetSelectEntryPos();
151*cdf0e10cSrcweir 		if (nPos!=0)
152*cdf0e10cSrcweir 			nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor();
153*cdf0e10cSrcweir 		else
154*cdf0e10cSrcweir 			nNew= COL_TRANSPARENT;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 		aAppOptions.SetTrackDeleteColor(nNew);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	}
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	SC_MOD()->SetAppOptions(aAppOptions);
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	//	Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
163*cdf0e10cSrcweir 	//	waere das nicht noetig...)
164*cdf0e10cSrcweir 	ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
165*cdf0e10cSrcweir 	if (pDocSh)
166*cdf0e10cSrcweir 		pDocSh->PostPaintGridAll();
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 	return sal_False;
169*cdf0e10cSrcweir }
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir /*-----------------------------------------------------------------------
172*cdf0e10cSrcweir 	Beschreibung:
173*cdf0e10cSrcweir  -----------------------------------------------------------------------*/
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ )
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	XColorTable* pColorTbl = XColorTable::GetStdColorTable();
179*cdf0e10cSrcweir 	aContentColorLB.InsertEntry(aAuthorStr);
180*cdf0e10cSrcweir 	aMoveColorLB.InsertEntry(aAuthorStr);
181*cdf0e10cSrcweir 	aInsertColorLB.InsertEntry(aAuthorStr);
182*cdf0e10cSrcweir 	aRemoveColorLB.InsertEntry(aAuthorStr);
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	aContentColorLB.SetUpdateMode( sal_False);
185*cdf0e10cSrcweir 	aMoveColorLB.SetUpdateMode( sal_False);
186*cdf0e10cSrcweir 	aInsertColorLB.SetUpdateMode( sal_False);
187*cdf0e10cSrcweir 	aRemoveColorLB.SetUpdateMode( sal_False);
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < pColorTbl->Count(); ++i )
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		XColorEntry* pEntry = pColorTbl->GetColor( i );
192*cdf0e10cSrcweir 		Color aColor = pEntry->GetColor();
193*cdf0e10cSrcweir 		String sName = pEntry->GetName();
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 		aContentColorLB.InsertEntry( aColor, sName );
196*cdf0e10cSrcweir 		aMoveColorLB.InsertEntry( aColor, sName );
197*cdf0e10cSrcweir 		aInsertColorLB.InsertEntry( aColor, sName );
198*cdf0e10cSrcweir 		aRemoveColorLB.InsertEntry( aColor, sName );
199*cdf0e10cSrcweir 	}
200*cdf0e10cSrcweir 	aContentColorLB.SetUpdateMode( sal_True );
201*cdf0e10cSrcweir 	aMoveColorLB.SetUpdateMode( sal_True );
202*cdf0e10cSrcweir 	aInsertColorLB.SetUpdateMode( sal_True );
203*cdf0e10cSrcweir 	aRemoveColorLB.SetUpdateMode( sal_True );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 	sal_uLong nColor = aAppOptions.GetTrackContentColor();
209*cdf0e10cSrcweir 	if (nColor == COL_TRANSPARENT)
210*cdf0e10cSrcweir 		aContentColorLB.SelectEntryPos(0);
211*cdf0e10cSrcweir 	else
212*cdf0e10cSrcweir 		aContentColorLB.SelectEntry(Color(nColor));
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 	nColor = aAppOptions.GetTrackMoveColor();
215*cdf0e10cSrcweir 	if (nColor == COL_TRANSPARENT)
216*cdf0e10cSrcweir 		aMoveColorLB.SelectEntryPos(0);
217*cdf0e10cSrcweir 	else
218*cdf0e10cSrcweir 		aMoveColorLB.SelectEntry(Color(nColor));
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	nColor = aAppOptions.GetTrackInsertColor();
222*cdf0e10cSrcweir 	if (nColor == COL_TRANSPARENT)
223*cdf0e10cSrcweir 		aInsertColorLB.SelectEntryPos(0);
224*cdf0e10cSrcweir 	else
225*cdf0e10cSrcweir 		aInsertColorLB.SelectEntry(Color(nColor));
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	nColor = aAppOptions.GetTrackDeleteColor();
229*cdf0e10cSrcweir 	if (nColor == COL_TRANSPARENT)
230*cdf0e10cSrcweir 		aRemoveColorLB.SelectEntryPos(0);
231*cdf0e10cSrcweir 	else
232*cdf0e10cSrcweir 		aRemoveColorLB.SelectEntry(Color(nColor));
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG )
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir /*
240*cdf0e10cSrcweir 	SvxFontPrevWindow *pPrev;
241*cdf0e10cSrcweir 	ListBox *pLB;
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	if (pColorLB == &aInsertColorLB)
244*cdf0e10cSrcweir 	{
245*cdf0e10cSrcweir 		pPrev = &aInsertPreviewWN;
246*cdf0e10cSrcweir 		pLB = &aInsertLB;
247*cdf0e10cSrcweir 	}
248*cdf0e10cSrcweir 	else
249*cdf0e10cSrcweir 	{
250*cdf0e10cSrcweir 		pPrev = &aDeletedPreviewWN;
251*cdf0e10cSrcweir 		pLB = &aDeletedLB;
252*cdf0e10cSrcweir 	}
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	SvxFont& rFont = pPrev->GetFont();
255*cdf0e10cSrcweir 	sal_uInt16 nPos = pLB->GetSelectEntryPos();
256*cdf0e10cSrcweir 	if (nPos == LISTBOX_ENTRY_NOTFOUND)
257*cdf0e10cSrcweir 		nPos = 0;
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	if (pAttr->nItemId == SID_ATTR_BRUSH)
262*cdf0e10cSrcweir 	{
263*cdf0e10cSrcweir 		rFont.SetColor(Color(COL_BLACK));
264*cdf0e10cSrcweir 		nPos = pColorLB->GetSelectEntryPos();
265*cdf0e10cSrcweir 		if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
266*cdf0e10cSrcweir 		{
267*cdf0e10cSrcweir 			Brush aBrush(Color(pColorLB->GetSelectEntryColor()));
268*cdf0e10cSrcweir 			pPrev->SetBrush(aBrush);
269*cdf0e10cSrcweir 		}
270*cdf0e10cSrcweir 		else
271*cdf0e10cSrcweir 		{
272*cdf0e10cSrcweir 			Brush aBrush(Color(COL_LIGHTGRAY));
273*cdf0e10cSrcweir 			pPrev->SetBrush(aBrush);
274*cdf0e10cSrcweir 		}
275*cdf0e10cSrcweir 	}
276*cdf0e10cSrcweir 	else
277*cdf0e10cSrcweir 	{
278*cdf0e10cSrcweir 		nPos = pColorLB->GetSelectEntryPos();
279*cdf0e10cSrcweir 		if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
280*cdf0e10cSrcweir 			rFont.SetColor(pColorLB->GetEntryColor(nPos));
281*cdf0e10cSrcweir 		else
282*cdf0e10cSrcweir 			rFont.SetColor(Color(COL_RED));
283*cdf0e10cSrcweir 	}
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 	pPrev->Invalidate();
286*cdf0e10cSrcweir */
287*cdf0e10cSrcweir 	return 0;
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290