xref: /trunk/main/sc/source/ui/optdlg/opredlin.cxx (revision a479921a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_scui.hxx"
26 
27 
28 
29 
30 //------------------------------------------------------------------
31 
32 #include <svx/dlgutil.hxx>
33 #include <svx/drawitem.hxx>
34 #include <svx/xtable.hxx>
35 
36 #include "appoptio.hxx"
37 #include "scmod.hxx"
38 #include "scitems.hxx"
39 #include "tpview.hxx"
40 #include "global.hxx"
41 #include "viewopti.hxx"
42 #include "tabvwsh.hxx"
43 #include "uiitems.hxx"
44 #include "scresid.hxx"
45 #include "docsh.hxx"
46 #include "sc.hrc"       // -> Slot-IDs
47 #include "optdlg.hrc"
48 #include "globstr.hrc"
49 
50 #include "opredlin.hxx"
51 #include "opredlin.hrc"
52 
53 //------------------------------------------------------------------
54 
ScRedlineOptionsTabPage(Window * pParent,const SfxItemSet & rSet)55 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent,
56 													const SfxItemSet& rSet )
57 	: SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet),
58 	aContentFT      ( this, ScResId(FT_CONTENT	)),
59 	aContentColorLB ( this, ScResId(CLB_CONTENT	)),
60 	aRemoveFT       ( this, ScResId(FT_REMOVE	)),
61 	aRemoveColorLB	( this, ScResId(CLB_REMOVE	)),
62 	aInsertFT       ( this, ScResId(FT_INSERT	)),
63 	aInsertColorLB  ( this, ScResId(CLB_INSERT	)),
64 	aMoveFT         ( this, ScResId(FT_MOVE		)),
65 	aMoveColorLB    ( this, ScResId(CLB_MOVE	)),
66 	aChangedGB		( this, ScResId(GB_COLORCHGS)),
67 	aAuthorStr		(ScResId(STR_AUTHOR))
68 {
69 	FreeResource();
70 
71 	Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl);
72 	aContentColorLB.SetSelectHdl( aLk );
73 	aMoveColorLB.SetSelectHdl( aLk );
74 	aInsertColorLB.SetSelectHdl( aLk );
75 	aRemoveColorLB.SetSelectHdl( aLk );
76 }
77 
78 /*-----------------------------------------------------------------------
79 	Beschreibung:
80  -----------------------------------------------------------------------*/
81 
~ScRedlineOptionsTabPage()82 __EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
83 {
84 }
85 
86 /*-----------------------------------------------------------------------
87 	Beschreibung:
88  -----------------------------------------------------------------------*/
89 
Create(Window * pParent,const SfxItemSet & rSet)90 SfxTabPage*	__EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
91 {
92 	return new ScRedlineOptionsTabPage( pParent, rSet );
93 }
94 
95 /*-----------------------------------------------------------------------
96 	Beschreibung:
97  -----------------------------------------------------------------------*/
98 
FillItemSet(SfxItemSet &)99 sal_Bool __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ )
100 {
101 	ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
102 
103 	sal_uLong nNew=0;
104 	sal_uInt16 nPos=0;
105 
106 	nPos = aContentColorLB.GetSelectEntryPos();
107 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
108 	{
109 		nPos = aContentColorLB.GetSelectEntryPos();
110 		if (nPos!=0)
111 			nNew= aContentColorLB.GetEntryColor(nPos).GetColor();
112 		else
113 			nNew= COL_TRANSPARENT;
114 
115 		aAppOptions.SetTrackContentColor(nNew);
116 
117 	}
118 	nPos = aMoveColorLB.GetSelectEntryPos();
119 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
120 	{
121 		nPos = aMoveColorLB.GetSelectEntryPos();
122 		if (nPos!=0)
123 			nNew= aMoveColorLB.GetEntryColor(nPos).GetColor();
124 		else
125 			nNew= COL_TRANSPARENT;
126 
127 		aAppOptions.SetTrackMoveColor(nNew);
128 
129 	}
130 	nPos = aInsertColorLB.GetSelectEntryPos();
131 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
132 	{
133 		nPos = aInsertColorLB.GetSelectEntryPos();
134 		if (nPos!=0)
135 			nNew= aInsertColorLB.GetEntryColor(nPos).GetColor();
136 		else
137 			nNew= COL_TRANSPARENT;
138 
139 		aAppOptions.SetTrackInsertColor(nNew);
140 
141 	}
142 	nPos = aRemoveColorLB.GetSelectEntryPos();
143 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
144 	{
145 		nPos = aRemoveColorLB.GetSelectEntryPos();
146 		if (nPos!=0)
147 			nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor();
148 		else
149 			nNew= COL_TRANSPARENT;
150 
151 		aAppOptions.SetTrackDeleteColor(nNew);
152 
153 	}
154 
155 	SC_MOD()->SetAppOptions(aAppOptions);
156 
157 	//	Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
158 	//	waere das nicht noetig...)
159 	ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
160 	if (pDocSh)
161 		pDocSh->PostPaintGridAll();
162 
163 	return sal_False;
164 }
165 
166 /*-----------------------------------------------------------------------
167 	Beschreibung:
168  -----------------------------------------------------------------------*/
169 
Reset(const SfxItemSet &)170 void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ )
171 {
172 
173 	XColorListSharedPtr aColorTbl = XColorList::GetStdColorList();
174 	aContentColorLB.InsertEntry(aAuthorStr);
175 	aMoveColorLB.InsertEntry(aAuthorStr);
176 	aInsertColorLB.InsertEntry(aAuthorStr);
177 	aRemoveColorLB.InsertEntry(aAuthorStr);
178 
179 	aContentColorLB.SetUpdateMode( sal_False);
180 	aMoveColorLB.SetUpdateMode( sal_False);
181 	aInsertColorLB.SetUpdateMode( sal_False);
182 	aRemoveColorLB.SetUpdateMode( sal_False);
183 
184 	for( sal_uInt16 i = 0; i < aColorTbl->Count(); ++i )
185 	{
186 		XColorEntry* pEntry = aColorTbl->GetColor( i );
187 		Color aColor = pEntry->GetColor();
188 		String sName = pEntry->GetName();
189 
190 		aContentColorLB.InsertEntry( aColor, sName );
191 		aMoveColorLB.InsertEntry( aColor, sName );
192 		aInsertColorLB.InsertEntry( aColor, sName );
193 		aRemoveColorLB.InsertEntry( aColor, sName );
194 	}
195 	aContentColorLB.SetUpdateMode( sal_True );
196 	aMoveColorLB.SetUpdateMode( sal_True );
197 	aInsertColorLB.SetUpdateMode( sal_True );
198 	aRemoveColorLB.SetUpdateMode( sal_True );
199 
200 
201 	ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
202 
203 	sal_uLong nColor = aAppOptions.GetTrackContentColor();
204 	if (nColor == COL_TRANSPARENT)
205 		aContentColorLB.SelectEntryPos(0);
206 	else
207 		aContentColorLB.SelectEntry(Color(nColor));
208 
209 	nColor = aAppOptions.GetTrackMoveColor();
210 	if (nColor == COL_TRANSPARENT)
211 		aMoveColorLB.SelectEntryPos(0);
212 	else
213 		aMoveColorLB.SelectEntry(Color(nColor));
214 
215 
216 	nColor = aAppOptions.GetTrackInsertColor();
217 	if (nColor == COL_TRANSPARENT)
218 		aInsertColorLB.SelectEntryPos(0);
219 	else
220 		aInsertColorLB.SelectEntry(Color(nColor));
221 
222 
223 	nColor = aAppOptions.GetTrackDeleteColor();
224 	if (nColor == COL_TRANSPARENT)
225 		aRemoveColorLB.SelectEntryPos(0);
226 	else
227 		aRemoveColorLB.SelectEntry(Color(nColor));
228 
229 }
230 
231 
IMPL_LINK(ScRedlineOptionsTabPage,ColorHdl,ColorListBox *,EMPTYARG)232 IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG )
233 {
234 /*
235 	SvxFontPrevWindow *pPrev;
236 	ListBox *pLB;
237 
238 	if (pColorLB == &aInsertColorLB)
239 	{
240 		pPrev = &aInsertPreviewWN;
241 		pLB = &aInsertLB;
242 	}
243 	else
244 	{
245 		pPrev = &aDeletedPreviewWN;
246 		pLB = &aDeletedLB;
247 	}
248 
249 	SvxFont& rFont = pPrev->GetFont();
250 	sal_uInt16 nPos = pLB->GetSelectEntryPos();
251 	if (nPos == LISTBOX_ENTRY_NOTFOUND)
252 		nPos = 0;
253 
254 	CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos);
255 
256 	if (pAttr->nItemId == SID_ATTR_BRUSH)
257 	{
258 		rFont.SetColor(Color(COL_BLACK));
259 		nPos = pColorLB->GetSelectEntryPos();
260 		if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
261 		{
262 			Brush aBrush(Color(pColorLB->GetSelectEntryColor()));
263 			pPrev->SetBrush(aBrush);
264 		}
265 		else
266 		{
267 			Brush aBrush(Color(COL_LIGHTGRAY));
268 			pPrev->SetBrush(aBrush);
269 		}
270 	}
271 	else
272 	{
273 		nPos = pColorLB->GetSelectEntryPos();
274 		if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
275 			rFont.SetColor(pColorLB->GetEntryColor(nPos));
276 		else
277 			rFont.SetColor(Color(COL_RED));
278 	}
279 
280 	pPrev->Invalidate();
281 */
282 	return 0;
283 }
284 
285