Update ooo320-m1
[ooovba.git] / sc / source / ui / optdlg / opredlin.cxx
blob1aa3260ff16c999d5e3399c889a14545e85733b8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: opredlin.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
38 //------------------------------------------------------------------
40 #include <svx/dlgutil.hxx>
41 #include <svx/drawitem.hxx>
42 #include <svx/xtable.hxx>
44 #include "appoptio.hxx"
45 #include "scmod.hxx"
46 #include "scitems.hxx"
47 #include "tpview.hxx"
48 #include "global.hxx"
49 #include "viewopti.hxx"
50 #include "tabvwsh.hxx"
51 #include "uiitems.hxx"
52 #include "scresid.hxx"
53 #include "docsh.hxx"
54 #include "sc.hrc" // -> Slot-IDs
55 #include "optdlg.hrc"
56 #include "globstr.hrc"
58 #include "opredlin.hxx"
59 #include "opredlin.hrc"
61 //------------------------------------------------------------------
63 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent,
64 const SfxItemSet& rSet )
65 : SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet),
66 aContentFT ( this, ScResId(FT_CONTENT )),
67 aContentColorLB ( this, ScResId(CLB_CONTENT )),
68 aRemoveFT ( this, ScResId(FT_REMOVE )),
69 aRemoveColorLB ( this, ScResId(CLB_REMOVE )),
70 aInsertFT ( this, ScResId(FT_INSERT )),
71 aInsertColorLB ( this, ScResId(CLB_INSERT )),
72 aMoveFT ( this, ScResId(FT_MOVE )),
73 aMoveColorLB ( this, ScResId(CLB_MOVE )),
74 aChangedGB ( this, ScResId(GB_COLORCHGS)),
75 aAuthorStr (ScResId(STR_AUTHOR))
77 FreeResource();
79 Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl);
80 aContentColorLB.SetSelectHdl( aLk );
81 aMoveColorLB.SetSelectHdl( aLk );
82 aInsertColorLB.SetSelectHdl( aLk );
83 aRemoveColorLB.SetSelectHdl( aLk );
86 /*-----------------------------------------------------------------------
87 Beschreibung:
88 -----------------------------------------------------------------------*/
90 __EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
94 /*-----------------------------------------------------------------------
95 Beschreibung:
96 -----------------------------------------------------------------------*/
98 SfxTabPage* __EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
100 return new ScRedlineOptionsTabPage( pParent, rSet );
103 /*-----------------------------------------------------------------------
104 Beschreibung:
105 -----------------------------------------------------------------------*/
107 BOOL __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ )
109 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
111 ULONG nNew=0;
112 USHORT nPos=0;
114 nPos = aContentColorLB.GetSelectEntryPos();
115 if (nPos != LISTBOX_ENTRY_NOTFOUND)
117 nPos = aContentColorLB.GetSelectEntryPos();
118 if (nPos!=0)
119 nNew= aContentColorLB.GetEntryColor(nPos).GetColor();
120 else
121 nNew= COL_TRANSPARENT;
123 aAppOptions.SetTrackContentColor(nNew);
126 nPos = aMoveColorLB.GetSelectEntryPos();
127 if (nPos != LISTBOX_ENTRY_NOTFOUND)
129 nPos = aMoveColorLB.GetSelectEntryPos();
130 if (nPos!=0)
131 nNew= aMoveColorLB.GetEntryColor(nPos).GetColor();
132 else
133 nNew= COL_TRANSPARENT;
135 aAppOptions.SetTrackMoveColor(nNew);
138 nPos = aInsertColorLB.GetSelectEntryPos();
139 if (nPos != LISTBOX_ENTRY_NOTFOUND)
141 nPos = aInsertColorLB.GetSelectEntryPos();
142 if (nPos!=0)
143 nNew= aInsertColorLB.GetEntryColor(nPos).GetColor();
144 else
145 nNew= COL_TRANSPARENT;
147 aAppOptions.SetTrackInsertColor(nNew);
150 nPos = aRemoveColorLB.GetSelectEntryPos();
151 if (nPos != LISTBOX_ENTRY_NOTFOUND)
153 nPos = aRemoveColorLB.GetSelectEntryPos();
154 if (nPos!=0)
155 nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor();
156 else
157 nNew= COL_TRANSPARENT;
159 aAppOptions.SetTrackDeleteColor(nNew);
163 SC_MOD()->SetAppOptions(aAppOptions);
165 // Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
166 // waere das nicht noetig...)
167 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
168 if (pDocSh)
169 pDocSh->PostPaintGridAll();
171 return FALSE;
174 /*-----------------------------------------------------------------------
175 Beschreibung:
176 -----------------------------------------------------------------------*/
178 void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ )
181 XColorTable* pColorTbl = XColorTable::GetStdColorTable();
182 aContentColorLB.InsertEntry(aAuthorStr);
183 aMoveColorLB.InsertEntry(aAuthorStr);
184 aInsertColorLB.InsertEntry(aAuthorStr);
185 aRemoveColorLB.InsertEntry(aAuthorStr);
187 aContentColorLB.SetUpdateMode( FALSE);
188 aMoveColorLB.SetUpdateMode( FALSE);
189 aInsertColorLB.SetUpdateMode( FALSE);
190 aRemoveColorLB.SetUpdateMode( FALSE);
192 for( USHORT i = 0; i < pColorTbl->Count(); ++i )
194 XColorEntry* pEntry = pColorTbl->GetColor( i );
195 Color aColor = pEntry->GetColor();
196 String sName = pEntry->GetName();
198 aContentColorLB.InsertEntry( aColor, sName );
199 aMoveColorLB.InsertEntry( aColor, sName );
200 aInsertColorLB.InsertEntry( aColor, sName );
201 aRemoveColorLB.InsertEntry( aColor, sName );
203 aContentColorLB.SetUpdateMode( TRUE );
204 aMoveColorLB.SetUpdateMode( TRUE );
205 aInsertColorLB.SetUpdateMode( TRUE );
206 aRemoveColorLB.SetUpdateMode( TRUE );
209 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
211 ULONG nColor = aAppOptions.GetTrackContentColor();
212 if (nColor == COL_TRANSPARENT)
213 aContentColorLB.SelectEntryPos(0);
214 else
215 aContentColorLB.SelectEntry(Color(nColor));
217 nColor = aAppOptions.GetTrackMoveColor();
218 if (nColor == COL_TRANSPARENT)
219 aMoveColorLB.SelectEntryPos(0);
220 else
221 aMoveColorLB.SelectEntry(Color(nColor));
224 nColor = aAppOptions.GetTrackInsertColor();
225 if (nColor == COL_TRANSPARENT)
226 aInsertColorLB.SelectEntryPos(0);
227 else
228 aInsertColorLB.SelectEntry(Color(nColor));
231 nColor = aAppOptions.GetTrackDeleteColor();
232 if (nColor == COL_TRANSPARENT)
233 aRemoveColorLB.SelectEntryPos(0);
234 else
235 aRemoveColorLB.SelectEntry(Color(nColor));
240 IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG )
243 SvxFontPrevWindow *pPrev;
244 ListBox *pLB;
246 if (pColorLB == &aInsertColorLB)
248 pPrev = &aInsertPreviewWN;
249 pLB = &aInsertLB;
251 else
253 pPrev = &aDeletedPreviewWN;
254 pLB = &aDeletedLB;
257 SvxFont& rFont = pPrev->GetFont();
258 USHORT nPos = pLB->GetSelectEntryPos();
259 if (nPos == LISTBOX_ENTRY_NOTFOUND)
260 nPos = 0;
262 CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos);
264 if (pAttr->nItemId == SID_ATTR_BRUSH)
266 rFont.SetColor(Color(COL_BLACK));
267 nPos = pColorLB->GetSelectEntryPos();
268 if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
270 Brush aBrush(Color(pColorLB->GetSelectEntryColor()));
271 pPrev->SetBrush(aBrush);
273 else
275 Brush aBrush(Color(COL_LIGHTGRAY));
276 pPrev->SetBrush(aBrush);
279 else
281 nPos = pColorLB->GetSelectEntryPos();
282 if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
283 rFont.SetColor(pColorLB->GetEntryColor(nPos));
284 else
285 rFont.SetColor(Color(COL_RED));
288 pPrev->Invalidate();
290 return 0;