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