Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #undef SC_DLLIMPLEMENTATION
31 : :
32 : :
33 : :
34 : : //------------------------------------------------------------------
35 : :
36 : : #include <svx/dlgutil.hxx>
37 : : #include <svx/drawitem.hxx>
38 : : #include <svx/xtable.hxx>
39 : :
40 : : #include "appoptio.hxx"
41 : : #include "scmod.hxx"
42 : : #include "scitems.hxx"
43 : : #include "tpview.hxx"
44 : : #include "global.hxx"
45 : : #include "viewopti.hxx"
46 : : #include "tabvwsh.hxx"
47 : : #include "uiitems.hxx"
48 : : #include "scresid.hxx"
49 : : #include "docsh.hxx"
50 : : #include "sc.hrc" // -> Slot-IDs
51 : : #include "optdlg.hrc"
52 : : #include "globstr.hrc"
53 : :
54 : : #include "opredlin.hxx"
55 : : #include "opredlin.hrc"
56 : :
57 : : //------------------------------------------------------------------
58 : :
59 : 0 : ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent,
60 : : const SfxItemSet& rSet )
61 : : : SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet),
62 : : aContentFT ( this, ScResId(FT_CONTENT )),
63 : : aContentColorLB ( this, ScResId(CLB_CONTENT )),
64 : : aRemoveFT ( this, ScResId(FT_REMOVE )),
65 : : aRemoveColorLB ( this, ScResId(CLB_REMOVE )),
66 : : aInsertFT ( this, ScResId(FT_INSERT )),
67 : : aInsertColorLB ( this, ScResId(CLB_INSERT )),
68 : : aMoveFT ( this, ScResId(FT_MOVE )),
69 : : aMoveColorLB ( this, ScResId(CLB_MOVE )),
70 : : aChangedGB ( this, ScResId(GB_COLORCHGS)),
71 : 0 : aAuthorStr (ScResId(STR_AUTHOR))
72 : : {
73 : 0 : FreeResource();
74 : :
75 : 0 : Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl);
76 : 0 : aContentColorLB.SetSelectHdl( aLk );
77 : 0 : aMoveColorLB.SetSelectHdl( aLk );
78 : 0 : aInsertColorLB.SetSelectHdl( aLk );
79 : 0 : aRemoveColorLB.SetSelectHdl( aLk );
80 : 0 : }
81 : :
82 : 0 : ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
83 : : {
84 : 0 : }
85 : :
86 : 0 : SfxTabPage* ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
87 : : {
88 : 0 : return new ScRedlineOptionsTabPage( pParent, rSet );
89 : : }
90 : :
91 : 0 : sal_Bool ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ )
92 : : {
93 : 0 : ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
94 : :
95 : 0 : sal_uLong nNew=0;
96 : 0 : sal_uInt16 nPos=0;
97 : :
98 : 0 : nPos = aContentColorLB.GetSelectEntryPos();
99 : 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
100 : : {
101 : 0 : nPos = aContentColorLB.GetSelectEntryPos();
102 : 0 : if (nPos!=0)
103 : 0 : nNew= aContentColorLB.GetEntryColor(nPos).GetColor();
104 : : else
105 : 0 : nNew= COL_TRANSPARENT;
106 : :
107 : 0 : aAppOptions.SetTrackContentColor(nNew);
108 : :
109 : : }
110 : 0 : nPos = aMoveColorLB.GetSelectEntryPos();
111 : 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
112 : : {
113 : 0 : nPos = aMoveColorLB.GetSelectEntryPos();
114 : 0 : if (nPos!=0)
115 : 0 : nNew= aMoveColorLB.GetEntryColor(nPos).GetColor();
116 : : else
117 : 0 : nNew= COL_TRANSPARENT;
118 : :
119 : 0 : aAppOptions.SetTrackMoveColor(nNew);
120 : :
121 : : }
122 : 0 : nPos = aInsertColorLB.GetSelectEntryPos();
123 : 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
124 : : {
125 : 0 : nPos = aInsertColorLB.GetSelectEntryPos();
126 : 0 : if (nPos!=0)
127 : 0 : nNew= aInsertColorLB.GetEntryColor(nPos).GetColor();
128 : : else
129 : 0 : nNew= COL_TRANSPARENT;
130 : :
131 : 0 : aAppOptions.SetTrackInsertColor(nNew);
132 : :
133 : : }
134 : 0 : nPos = aRemoveColorLB.GetSelectEntryPos();
135 : 0 : if (nPos != LISTBOX_ENTRY_NOTFOUND)
136 : : {
137 : 0 : nPos = aRemoveColorLB.GetSelectEntryPos();
138 : 0 : if (nPos!=0)
139 : 0 : nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor();
140 : : else
141 : 0 : nNew= COL_TRANSPARENT;
142 : :
143 : 0 : aAppOptions.SetTrackDeleteColor(nNew);
144 : :
145 : : }
146 : :
147 : 0 : SC_MOD()->SetAppOptions(aAppOptions);
148 : :
149 : : // Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
150 : : // waere das nicht noetig...)
151 : 0 : ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
152 : 0 : if (pDocSh)
153 : 0 : pDocSh->PostPaintGridAll();
154 : :
155 : 0 : return false;
156 : : }
157 : :
158 : 0 : void ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ )
159 : : {
160 : 0 : aContentColorLB.InsertEntry(aAuthorStr);
161 : 0 : aMoveColorLB.InsertEntry(aAuthorStr);
162 : 0 : aInsertColorLB.InsertEntry(aAuthorStr);
163 : 0 : aRemoveColorLB.InsertEntry(aAuthorStr);
164 : :
165 : 0 : aContentColorLB.SetUpdateMode( false);
166 : 0 : aMoveColorLB.SetUpdateMode( false);
167 : 0 : aInsertColorLB.SetUpdateMode( false);
168 : 0 : aRemoveColorLB.SetUpdateMode( false);
169 : :
170 : 0 : XColorListRef xColorLst = XColorList::GetStdColorList();
171 : 0 : for( sal_uInt16 i = 0; i < xColorLst->Count(); ++i )
172 : : {
173 : 0 : XColorEntry* pEntry = xColorLst->GetColor( i );
174 : 0 : Color aColor = pEntry->GetColor();
175 : 0 : String sName = pEntry->GetName();
176 : :
177 : 0 : aContentColorLB.InsertEntry( aColor, sName );
178 : 0 : aMoveColorLB.InsertEntry( aColor, sName );
179 : 0 : aInsertColorLB.InsertEntry( aColor, sName );
180 : 0 : aRemoveColorLB.InsertEntry( aColor, sName );
181 : 0 : }
182 : 0 : aContentColorLB.SetUpdateMode( sal_True );
183 : 0 : aMoveColorLB.SetUpdateMode( sal_True );
184 : 0 : aInsertColorLB.SetUpdateMode( sal_True );
185 : 0 : aRemoveColorLB.SetUpdateMode( sal_True );
186 : :
187 : :
188 : 0 : ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
189 : :
190 : 0 : sal_uLong nColor = aAppOptions.GetTrackContentColor();
191 : 0 : if (nColor == COL_TRANSPARENT)
192 : 0 : aContentColorLB.SelectEntryPos(0);
193 : : else
194 : 0 : aContentColorLB.SelectEntry(Color(nColor));
195 : :
196 : 0 : nColor = aAppOptions.GetTrackMoveColor();
197 : 0 : if (nColor == COL_TRANSPARENT)
198 : 0 : aMoveColorLB.SelectEntryPos(0);
199 : : else
200 : 0 : aMoveColorLB.SelectEntry(Color(nColor));
201 : :
202 : :
203 : 0 : nColor = aAppOptions.GetTrackInsertColor();
204 : 0 : if (nColor == COL_TRANSPARENT)
205 : 0 : aInsertColorLB.SelectEntryPos(0);
206 : : else
207 : 0 : aInsertColorLB.SelectEntry(Color(nColor));
208 : :
209 : :
210 : 0 : nColor = aAppOptions.GetTrackDeleteColor();
211 : 0 : if (nColor == COL_TRANSPARENT)
212 : 0 : aRemoveColorLB.SelectEntryPos(0);
213 : : else
214 : 0 : aRemoveColorLB.SelectEntry(Color(nColor));
215 : :
216 : 0 : }
217 : :
218 : :
219 : 0 : IMPL_LINK_NOARG(ScRedlineOptionsTabPage, ColorHdl)
220 : : {
221 : 0 : return 0;
222 : : }
223 : :
224 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|