xref: /aoo4110/main/sc/source/ui/optdlg/opredlin.cxx (revision b1cdbd2c)
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_sc.hxx"
26 
27 #undef SC_DLLIMPLEMENTATION
28 
29 
30 
31 //------------------------------------------------------------------
32 
33 #include <svx/dlgutil.hxx>
34 #include <svx/drawitem.hxx>
35 #include <svx/xtable.hxx>
36 
37 #include "appoptio.hxx"
38 #include "scmod.hxx"
39 #include "scitems.hxx"
40 #include "tpview.hxx"
41 #include "global.hxx"
42 #include "viewopti.hxx"
43 #include "tabvwsh.hxx"
44 #include "uiitems.hxx"
45 #include "scresid.hxx"
46 #include "docsh.hxx"
47 #include "sc.hrc"       // -> Slot-IDs
48 #include "optdlg.hrc"
49 #include "globstr.hrc"
50 
51 #include "opredlin.hxx"
52 #include "opredlin.hrc"
53 
54 //------------------------------------------------------------------
55 
ScRedlineOptionsTabPage(Window * pParent,const SfxItemSet & rSet)56 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent,
57 													const SfxItemSet& rSet )
58 	: SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet),
59 	aContentFT      ( this, ScResId(FT_CONTENT	)),
60 	aContentColorLB ( this, ScResId(CLB_CONTENT	)),
61 	aRemoveFT       ( this, ScResId(FT_REMOVE	)),
62 	aRemoveColorLB	( this, ScResId(CLB_REMOVE	)),
63 	aInsertFT       ( this, ScResId(FT_INSERT	)),
64 	aInsertColorLB  ( this, ScResId(CLB_INSERT	)),
65 	aMoveFT         ( this, ScResId(FT_MOVE		)),
66 	aMoveColorLB    ( this, ScResId(CLB_MOVE	)),
67 	aChangedGB		( this, ScResId(GB_COLORCHGS)),
68 	aAuthorStr		(ScResId(STR_AUTHOR))
69 {
70 	FreeResource();
71 
72 	Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl);
73 	aContentColorLB.SetSelectHdl( aLk );
74 	aMoveColorLB.SetSelectHdl( aLk );
75 	aInsertColorLB.SetSelectHdl( aLk );
76 	aRemoveColorLB.SetSelectHdl( aLk );
77 }
78 
79 /*-----------------------------------------------------------------------
80 	Beschreibung:
81  -----------------------------------------------------------------------*/
82 
~ScRedlineOptionsTabPage()83 __EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
84 {
85 }
86 
87 /*-----------------------------------------------------------------------
88 	Beschreibung:
89  -----------------------------------------------------------------------*/
90 
Create(Window * pParent,const SfxItemSet & rSet)91 SfxTabPage*	__EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
92 {
93 	return new ScRedlineOptionsTabPage( pParent, rSet );
94 }
95 
96 /*-----------------------------------------------------------------------
97 	Beschreibung:
98  -----------------------------------------------------------------------*/
99 
FillItemSet(SfxItemSet &)100 sal_Bool __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ )
101 {
102 	ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
103 
104 	sal_uLong nNew=0;
105 	sal_uInt16 nPos=0;
106 
107 	nPos = aContentColorLB.GetSelectEntryPos();
108 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
109 	{
110 		nPos = aContentColorLB.GetSelectEntryPos();
111 		if (nPos!=0)
112 			nNew= aContentColorLB.GetEntryColor(nPos).GetColor();
113 		else
114 			nNew= COL_TRANSPARENT;
115 
116 		aAppOptions.SetTrackContentColor(nNew);
117 
118 	}
119 	nPos = aMoveColorLB.GetSelectEntryPos();
120 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
121 	{
122 		nPos = aMoveColorLB.GetSelectEntryPos();
123 		if (nPos!=0)
124 			nNew= aMoveColorLB.GetEntryColor(nPos).GetColor();
125 		else
126 			nNew= COL_TRANSPARENT;
127 
128 		aAppOptions.SetTrackMoveColor(nNew);
129 
130 	}
131 	nPos = aInsertColorLB.GetSelectEntryPos();
132 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
133 	{
134 		nPos = aInsertColorLB.GetSelectEntryPos();
135 		if (nPos!=0)
136 			nNew= aInsertColorLB.GetEntryColor(nPos).GetColor();
137 		else
138 			nNew= COL_TRANSPARENT;
139 
140 		aAppOptions.SetTrackInsertColor(nNew);
141 
142 	}
143 	nPos = aRemoveColorLB.GetSelectEntryPos();
144 	if (nPos != LISTBOX_ENTRY_NOTFOUND)
145 	{
146 		nPos = aRemoveColorLB.GetSelectEntryPos();
147 		if (nPos!=0)
148 			nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor();
149 		else
150 			nNew= COL_TRANSPARENT;
151 
152 		aAppOptions.SetTrackDeleteColor(nNew);
153 
154 	}
155 
156 	SC_MOD()->SetAppOptions(aAppOptions);
157 
158 	//	Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
159 	//	waere das nicht noetig...)
160 	ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
161 	if (pDocSh)
162 		pDocSh->PostPaintGridAll();
163 
164 	return sal_False;
165 }
166 
167 /*-----------------------------------------------------------------------
168 	Beschreibung:
169  -----------------------------------------------------------------------*/
170 
Reset(const SfxItemSet &)171 void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ )
172 {
173 
174 	XColorListSharedPtr aColorTbl = XColorList::GetStdColorList();
175 	aContentColorLB.InsertEntry(aAuthorStr);
176 	aMoveColorLB.InsertEntry(aAuthorStr);
177 	aInsertColorLB.InsertEntry(aAuthorStr);
178 	aRemoveColorLB.InsertEntry(aAuthorStr);
179 
180 	aContentColorLB.SetUpdateMode( sal_False);
181 	aMoveColorLB.SetUpdateMode( sal_False);
182 	aInsertColorLB.SetUpdateMode( sal_False);
183 	aRemoveColorLB.SetUpdateMode( sal_False);
184 
185 	for( sal_uInt16 i = 0; i < aColorTbl->Count(); ++i )
186 	{
187 		XColorEntry* pEntry = aColorTbl->GetColor( i );
188 		Color aColor = pEntry->GetColor();
189 		String sName = pEntry->GetName();
190 
191 		aContentColorLB.InsertEntry( aColor, sName );
192 		aMoveColorLB.InsertEntry( aColor, sName );
193 		aInsertColorLB.InsertEntry( aColor, sName );
194 		aRemoveColorLB.InsertEntry( aColor, sName );
195 	}
196 	aContentColorLB.SetUpdateMode( sal_True );
197 	aMoveColorLB.SetUpdateMode( sal_True );
198 	aInsertColorLB.SetUpdateMode( sal_True );
199 	aRemoveColorLB.SetUpdateMode( sal_True );
200 
201 
202 	ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
203 
204 	sal_uLong nColor = aAppOptions.GetTrackContentColor();
205 	if (nColor == COL_TRANSPARENT)
206 		aContentColorLB.SelectEntryPos(0);
207 	else
208 		aContentColorLB.SelectEntry(Color(nColor));
209 
210 	nColor = aAppOptions.GetTrackMoveColor();
211 	if (nColor == COL_TRANSPARENT)
212 		aMoveColorLB.SelectEntryPos(0);
213 	else
214 		aMoveColorLB.SelectEntry(Color(nColor));
215 
216 
217 	nColor = aAppOptions.GetTrackInsertColor();
218 	if (nColor == COL_TRANSPARENT)
219 		aInsertColorLB.SelectEntryPos(0);
220 	else
221 		aInsertColorLB.SelectEntry(Color(nColor));
222 
223 
224 	nColor = aAppOptions.GetTrackDeleteColor();
225 	if (nColor == COL_TRANSPARENT)
226 		aRemoveColorLB.SelectEntryPos(0);
227 	else
228 		aRemoveColorLB.SelectEntry(Color(nColor));
229 
230 }
231 
232 
IMPL_LINK(ScRedlineOptionsTabPage,ColorHdl,ColorListBox *,EMPTYARG)233 IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG )
234 {
235 /*
236 	SvxFontPrevWindow *pPrev;
237 	ListBox *pLB;
238 
239 	if (pColorLB == &aInsertColorLB)
240 	{
241 		pPrev = &aInsertPreviewWN;
242 		pLB = &aInsertLB;
243 	}
244 	else
245 	{
246 		pPrev = &aDeletedPreviewWN;
247 		pLB = &aDeletedLB;
248 	}
249 
250 	SvxFont& rFont = pPrev->GetFont();
251 	sal_uInt16 nPos = pLB->GetSelectEntryPos();
252 	if (nPos == LISTBOX_ENTRY_NOTFOUND)
253 		nPos = 0;
254 
255 	CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos);
256 
257 	if (pAttr->nItemId == SID_ATTR_BRUSH)
258 	{
259 		rFont.SetColor(Color(COL_BLACK));
260 		nPos = pColorLB->GetSelectEntryPos();
261 		if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
262 		{
263 			Brush aBrush(Color(pColorLB->GetSelectEntryColor()));
264 			pPrev->SetBrush(aBrush);
265 		}
266 		else
267 		{
268 			Brush aBrush(Color(COL_LIGHTGRAY));
269 			pPrev->SetBrush(aBrush);
270 		}
271 	}
272 	else
273 	{
274 		nPos = pColorLB->GetSelectEntryPos();
275 		if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
276 			rFont.SetColor(pColorLB->GetEntryColor(nPos));
277 		else
278 			rFont.SetColor(Color(COL_RED));
279 	}
280 
281 	pPrev->Invalidate();
282 */
283 	return 0;
284 }
285 
286