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