1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: opredlin.cxx,v $
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"
46 #include "scitems.hxx"
49 #include "viewopti.hxx"
50 #include "tabvwsh.hxx"
51 #include "uiitems.hxx"
52 #include "scresid.hxx"
54 #include "sc.hrc" // -> Slot-IDs
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
))
79 Link aLk
= LINK(this, ScRedlineOptionsTabPage
, ColorHdl
);
80 aContentColorLB
.SetSelectHdl( aLk
);
81 aMoveColorLB
.SetSelectHdl( aLk
);
82 aInsertColorLB
.SetSelectHdl( aLk
);
83 aRemoveColorLB
.SetSelectHdl( aLk
);
86 /*-----------------------------------------------------------------------
88 -----------------------------------------------------------------------*/
90 __EXPORT
ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
94 /*-----------------------------------------------------------------------
96 -----------------------------------------------------------------------*/
98 SfxTabPage
* __EXPORT
ScRedlineOptionsTabPage::Create( Window
* pParent
, const SfxItemSet
& rSet
)
100 return new ScRedlineOptionsTabPage( pParent
, rSet
);
103 /*-----------------------------------------------------------------------
105 -----------------------------------------------------------------------*/
107 BOOL __EXPORT
ScRedlineOptionsTabPage::FillItemSet( SfxItemSet
& /* rSet */ )
109 ScAppOptions aAppOptions
=SC_MOD()->GetAppOptions();
114 nPos
= aContentColorLB
.GetSelectEntryPos();
115 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
117 nPos
= aContentColorLB
.GetSelectEntryPos();
119 nNew
= aContentColorLB
.GetEntryColor(nPos
).GetColor();
121 nNew
= COL_TRANSPARENT
;
123 aAppOptions
.SetTrackContentColor(nNew
);
126 nPos
= aMoveColorLB
.GetSelectEntryPos();
127 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
129 nPos
= aMoveColorLB
.GetSelectEntryPos();
131 nNew
= aMoveColorLB
.GetEntryColor(nPos
).GetColor();
133 nNew
= COL_TRANSPARENT
;
135 aAppOptions
.SetTrackMoveColor(nNew
);
138 nPos
= aInsertColorLB
.GetSelectEntryPos();
139 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
141 nPos
= aInsertColorLB
.GetSelectEntryPos();
143 nNew
= aInsertColorLB
.GetEntryColor(nPos
).GetColor();
145 nNew
= COL_TRANSPARENT
;
147 aAppOptions
.SetTrackInsertColor(nNew
);
150 nPos
= aRemoveColorLB
.GetSelectEntryPos();
151 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
153 nPos
= aRemoveColorLB
.GetSelectEntryPos();
155 nNew
= aRemoveColorLB
.GetEntryColor(nPos
).GetColor();
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());
169 pDocSh
->PostPaintGridAll();
174 /*-----------------------------------------------------------------------
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);
215 aContentColorLB
.SelectEntry(Color(nColor
));
217 nColor
= aAppOptions
.GetTrackMoveColor();
218 if (nColor
== COL_TRANSPARENT
)
219 aMoveColorLB
.SelectEntryPos(0);
221 aMoveColorLB
.SelectEntry(Color(nColor
));
224 nColor
= aAppOptions
.GetTrackInsertColor();
225 if (nColor
== COL_TRANSPARENT
)
226 aInsertColorLB
.SelectEntryPos(0);
228 aInsertColorLB
.SelectEntry(Color(nColor
));
231 nColor
= aAppOptions
.GetTrackDeleteColor();
232 if (nColor
== COL_TRANSPARENT
)
233 aRemoveColorLB
.SelectEntryPos(0);
235 aRemoveColorLB
.SelectEntry(Color(nColor
));
240 IMPL_LINK( ScRedlineOptionsTabPage
, ColorHdl
, ColorListBox
*, EMPTYARG
)
243 SvxFontPrevWindow *pPrev;
246 if (pColorLB == &aInsertColorLB)
248 pPrev = &aInsertPreviewWN;
253 pPrev = &aDeletedPreviewWN;
257 SvxFont& rFont = pPrev->GetFont();
258 USHORT nPos = pLB->GetSelectEntryPos();
259 if (nPos == LISTBOX_ENTRY_NOTFOUND)
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);
275 Brush aBrush(Color(COL_LIGHTGRAY));
276 pPrev->SetBrush(aBrush);
281 nPos = pColorLB->GetSelectEntryPos();
282 if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
283 rFont.SetColor(pColorLB->GetEntryColor(nPos));
285 rFont.SetColor(Color(COL_RED));