merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / optcolor.cxx
blob887be321ab27fc77631245ef780019ebabdeb118
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: optcolor.cxx,v $
10 * $Revision: 1.18.256.2 $
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_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
39 #include <svtools/colorcfg.hxx>
40 #include <svtools/extcolorcfg.hxx>
41 #include <svtools/headbar.hxx>
42 #include <svtools/ctrlbox.hxx>
43 #include <vcl/scrbar.hxx>
44 #include <svx/xtable.hxx>
45 #include <svtools/moduleoptions.hxx>
46 #include <svtools/pathoptions.hxx>
47 #include <vcl/msgbox.hxx>
48 #include <boost/shared_ptr.hpp>
49 //CHINA001 #ifndef _SVX_DLG_NAME_HXX
50 //CHINA001 #include <dlgname.hxx>
51 //CHINA001 #endif
52 #include <svx/svxdlg.hxx> //CHINA001
53 #ifndef _SVX_HELPID_HRC
54 #include <helpid.hrc>
55 #endif
56 #include <svx/svxids.hrc>
57 #include <svx/dialmgr.hxx>
58 #include "optcolor.hxx"
59 #include <svx/dialogs.hrc>
60 #include "optcolor.hrc"
61 #include "dlgutil.hxx"
62 using namespace ::com::sun::star;
63 using namespace ::svtools;
65 #define GROUP_COUNT 7
66 #define GROUP_UNKNOWN -1
67 #define GROUP_GENERAL 0
68 #define GROUP_WRITER 1
69 #define GROUP_HTML 2
70 #define GROUP_CALC 3
71 #define GROUP_DRAW 4
72 #define GROUP_BASIC 5
73 #define GROUP_SQL 6
75 /* -----------------------------2002/06/26 10:48------------------------------
77 ---------------------------------------------------------------------------*/
79 class SvxExtFixedText_Impl : public FixedText
81 private:
82 long m_nGroupHeight;
84 protected:
85 virtual void DataChanged( const DataChangedEvent& rDCEvt );
87 public:
88 SvxExtFixedText_Impl(Window* pParent, const ResId& rResId) :
89 FixedText(pParent, rResId), m_nGroupHeight(0) {}
91 inline long GetGroupHeight() { return m_nGroupHeight; }
92 inline void SetGroupHeight( long _nHeight ) { m_nGroupHeight = _nHeight; }
95 /* -----------------------------25.03.2002 15:48------------------------------
97 ---------------------------------------------------------------------------*/
98 class ColorConfigCtrl_Impl;
99 class ColorConfigWindow_Impl : public Window
101 friend class ColorConfigCtrl_Impl;
102 Window aGeneralBackWN;
103 SvxExtFixedText_Impl aGeneralFT;
104 FixedText aDocColorFT;
105 ColorListBox aDocColorLB;
106 Window aDocColorWN;
107 CheckBox aDocBoundCB;
108 ColorListBox aDocBoundLB;
109 Window aDocBoundWN;
110 FixedText aAppBackFT;
111 ColorListBox aAppBackLB;
112 Window aAppBackWN;
113 CheckBox aObjBoundCB;
114 ColorListBox aObjBoundLB;
115 Window aObjBoundWN;
116 CheckBox aTableBoundCB;
117 ColorListBox aTableBoundLB;
118 Window aTableBoundWN;
119 FixedText aFontColorFT;
120 ColorListBox aFontColorLB;
121 Window aFontColorWN;
122 CheckBox aLinksCB;
123 ColorListBox aLinksLB;
124 Window aLinksWN;
125 CheckBox aLinksVisitedCB;
126 ColorListBox aLinksVisitedLB;
127 Window aLinksVisitedWN;
128 FixedText aSpellFT;
129 ColorListBox aSpellLB;
130 Window aSpellWN;
131 FixedText aSmarttagsFT;
132 ColorListBox aSmarttagsLB;
133 Window aSmarttagsWN;
134 Window aWriterBackWN;
135 SvxExtFixedText_Impl aWriterFT;
136 FixedText aWrtTextGridFT;
137 ColorListBox aWrtTextGridLB;
138 Window aWrtTextGridWN;
139 CheckBox aWrtFieldCB;
140 ColorListBox aWrtFieldLB;
141 Window aWrtFieldWN;
142 CheckBox aWrtIdxShadingBackCB;
143 ColorListBox aWrtIdxShadingBackLB;
144 Window aWrtIdxShadingBackWN;
145 FixedText aWrtScriptIndicatorFT;
146 ColorListBox aWrtScriptIndicatorLB;
147 Window aWrtScriptIndicatorWN;
148 CheckBox aWrtSectionBoundCB;
149 ColorListBox aWrtSectionBoundLB;
150 Window aWrtSectionBoundWN;
151 FixedText aWrtPageBreaksFT;
152 ColorListBox aWrtPageBreaksLB;
153 Window aWrtPageBreaksWN;
154 FixedText aWrtDirectCrsrFT;
155 ColorListBox aWrtDirectCrsrLB;
156 Window aWrtDirectCrsrWN;
157 Window aHTMLBackWN;
158 SvxExtFixedText_Impl aHTMLFT;
159 FixedText aHTMLSGMLFT;
160 ColorListBox aHTMLSGMLLB;
161 Window aHTMLSGMLWN;
162 FixedText aHTMLCommentFT;
163 ColorListBox aHTMLCommentLB;
164 Window aHTMLCommentWN;
165 FixedText aHTMLKeywdFT;
166 ColorListBox aHTMLKeywdLB;
167 Window aHTMLKeywdWN;
168 FixedText aHTMLUnknownFT;
169 ColorListBox aHTMLUnknownLB;
170 Window aHTMLUnknownWN;
171 Window aCalcBackWN;
172 SvxExtFixedText_Impl aCalcFT;
173 FixedText aCalcGridFT;
174 ColorListBox aCalcGridLB;
175 Window aCalcGridWN;
176 FixedText aCalcPageBreakFT;
177 ColorListBox aCalcPageBreakLB;
178 Window aCalcPageBreakWN;
179 FixedText aCalcPageBreakManualFT;
180 ColorListBox aCalcPageBreakManualLB;
181 Window aCalcPageBreakManualWN;
182 FixedText aCalcPageBreakAutoFT;
183 ColorListBox aCalcPageBreakAutoLB;
184 Window aCalcPageBreakAutoWN;
185 FixedText aCalcDetectiveFT;
186 ColorListBox aCalcDetectiveLB;
187 Window aCalcDetectiveWN;
188 FixedText aCalcDetectiveErrorFT;
189 ColorListBox aCalcDetectiveErrorLB;
190 Window aCalcDetectiveErrorWN;
191 FixedText aCalcReferenceFT;
192 ColorListBox aCalcReferenceLB;
193 Window aCalcReferenceWN;
194 FixedText aCalcNotesBackFT;
195 ColorListBox aCalcNotesBackLB;
196 Window aCalcNotesBackWN;
197 Window aDrawBackWN;
198 SvxExtFixedText_Impl aDrawFT;
199 FixedText aDrawGridFT;
200 ColorListBox aDrawGridLB;
201 Window aDrawGridWN;
202 Window aBasicBackWN;
203 SvxExtFixedText_Impl aBasicFT;
204 FixedText aBasicIdentifierFT;
205 ColorListBox aBasicIdentifierLB;
206 Window aBasicIdentifierWN;
207 FixedText aBasicCommentFT;
208 ColorListBox aBasicCommentLB;
209 Window aBasicCommentWN;
210 FixedText aBasicNumberFT;
211 ColorListBox aBasicNumberLB;
212 Window aBasicNumberWN;
213 FixedText aBasicStringFT;
214 ColorListBox aBasicStringLB;
215 Window aBasicStringWN;
216 FixedText aBasicOperatorFT;
217 ColorListBox aBasicOperatorLB;
218 Window aBasicOperatorWN;
219 FixedText aBasicKeywordFT;
220 ColorListBox aBasicKeywordLB;
221 Window aBasicKeywordWN;
222 FixedText aBasicErrorFT;
223 ColorListBox aBasicErrorLB;
224 Window aBasicErrorWN;
225 Window aSQLBackWN;
226 SvxExtFixedText_Impl aSQLFT;
227 FixedText aSQLIdentifierFT;
228 ColorListBox aSQLIdentifierLB;
229 Window aSQLIdentifierWN;
230 FixedText aSQLNumberFT;
231 ColorListBox aSQLNumberLB;
232 Window aSQLNumberWN;
233 FixedText aSQLStringFT;
234 ColorListBox aSQLStringLB;
235 Window aSQLStringWN;
236 FixedText aSQLOperatorFT;
237 ColorListBox aSQLOperatorLB;
238 Window aSQLOperatorWN;
239 FixedText aSQLKeywordFT;
240 ColorListBox aSQLKeywordLB;
241 Window aSQLKeywordWN;
242 FixedText aSQLParameterFT;
243 ColorListBox aSQLParameterLB;
244 Window aSQLParameterWN;
245 FixedText aSQLCommentFT;
246 ColorListBox aSQLCommentLB;
247 Window aSQLCommentWN;
249 ::std::vector< SvxExtFixedText_Impl*> aChapters;
250 ::std::vector< Window* > aChapterWins;
251 ::std::vector< FixedText* > aFixedTexts;
252 ::std::vector< CheckBox* > aCheckBoxes;
253 ::std::vector< ColorListBox* > aColorBoxes;
254 ::std::vector< Window* > aWindows; // [ColorConfigEntryCount]
255 ::std::vector< ::boost::shared_ptr<SvxExtFixedText_Impl> > m_aExtensionTitles;
257 SvtModuleOptions m_aModuleOptions;
259 void SetNewPosition( sal_Int32 _nFeature, Window* _pWin );
261 virtual void Command( const CommandEvent& rCEvt );
262 virtual void DataChanged( const DataChangedEvent& rDCEvt );
264 public:
265 ColorConfigWindow_Impl(Window* pParent, const ResId& rResId);
266 ~ColorConfigWindow_Impl();
268 inline const SvtModuleOptions& GetModuleOptions() const { return m_aModuleOptions; }
271 sal_Bool lcl_isGroupVisible( sal_Int32 _nGroup, const SvtModuleOptions& _rModOptions )
273 sal_Bool bRet = sal_True;
275 switch ( _nGroup )
277 case GROUP_WRITER :
278 case GROUP_HTML :
280 bRet = _rModOptions.IsModuleInstalled( SvtModuleOptions::E_SWRITER );
281 break;
284 case GROUP_CALC :
286 bRet = _rModOptions.IsModuleInstalled( SvtModuleOptions::E_SCALC );
287 break;
290 case GROUP_DRAW :
292 bRet = ( _rModOptions.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ||
293 _rModOptions.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) );
294 break;
296 case GROUP_SQL :
298 bRet = _rModOptions.IsModuleInstalled( SvtModuleOptions::E_SDATABASE );
299 break;
303 return bRet;
306 sal_Int16 lcl_getGroup( sal_Int32 _nFeature )
308 if ( _nFeature >= ColorConfigEntryCount )
309 return GROUP_COUNT; // feature of an extension
311 sal_Int16 nRet = GROUP_UNKNOWN;
313 switch ( _nFeature )
315 case DOCCOLOR :
316 case DOCBOUNDARIES :
317 case APPBACKGROUND :
318 case OBJECTBOUNDARIES :
319 case TABLEBOUNDARIES :
320 case FONTCOLOR :
321 case LINKS :
322 case LINKSVISITED :
323 case ANCHOR :
324 case SPELL :
325 case SMARTTAGS :
327 nRet = GROUP_GENERAL;
328 break;
331 case WRITERTEXTGRID :
332 case WRITERFIELDSHADINGS :
333 case WRITERIDXSHADINGS :
334 case WRITERDIRECTCURSOR :
335 case WRITERSCRIPTINDICATOR :
336 case WRITERSECTIONBOUNDARIES :
337 case WRITERPAGEBREAKS :
339 nRet = GROUP_WRITER;
340 break;
343 case HTMLSGML :
344 case HTMLCOMMENT :
345 case HTMLKEYWORD :
346 case HTMLUNKNOWN :
348 nRet = GROUP_HTML;
349 break;
352 case CALCGRID :
353 case CALCPAGEBREAK :
354 case CALCPAGEBREAKMANUAL :
355 case CALCPAGEBREAKAUTOMATIC :
356 case CALCDETECTIVE :
357 case CALCDETECTIVEERROR :
358 case CALCREFERENCE :
359 case CALCNOTESBACKGROUND :
361 nRet = GROUP_CALC;
362 break;
365 case DRAWGRID :
366 case DRAWDRAWING :
367 case DRAWFILL :
369 nRet = GROUP_DRAW;
370 break;
373 case BASICIDENTIFIER :
374 case BASICCOMMENT :
375 case BASICNUMBER :
376 case BASICSTRING :
377 case BASICOPERATOR :
378 case BASICKEYWORD :
379 case BASICERROR :
381 nRet = GROUP_BASIC;
382 break;
384 case SQLIDENTIFIER :
385 case SQLNUMBER:
386 case SQLSTRING:
387 case SQLOPERATOR:
388 case SQLKEYWORD:
389 case SQLPARAMETER:
390 case SQLCOMMENT:
392 nRet = GROUP_SQL;
393 break;
396 return nRet;
399 /* -----------------------------25.03.2002 17:05------------------------------
401 ---------------------------------------------------------------------------*/
402 ColorConfigWindow_Impl::ColorConfigWindow_Impl(Window* pParent, const ResId& rResId) :
403 Window(pParent, rResId),
404 aGeneralBackWN(this),
405 aGeneralFT(&aGeneralBackWN, ResId( FT_GENERAL, *rResId.GetResMgr() )),
406 aDocColorFT(this, ResId( FT_DOCCOLOR, *rResId.GetResMgr())),
407 aDocColorLB(this, ResId( LB_DOCCOLOR, *rResId.GetResMgr())),
408 aDocColorWN(this, ResId( WN_DOCCOLOR, *rResId.GetResMgr())),
409 aDocBoundCB(this, ResId( CB_DOCBOUND, *rResId.GetResMgr())),
410 aDocBoundLB(this, ResId( LB_DOCBOUND, *rResId.GetResMgr())),
411 aDocBoundWN(this, ResId( WN_DOCBOUND, *rResId.GetResMgr())),
412 aAppBackFT(this, ResId( FT_APPBACKGROUND, *rResId.GetResMgr())),
413 aAppBackLB(this, ResId( LB_APPBACKGROUND, *rResId.GetResMgr())),
414 aAppBackWN(this, ResId( WN_APPBACKGROUND, *rResId.GetResMgr())),
415 aObjBoundCB(this, ResId( CB_OBJECTBOUNDARIES, *rResId.GetResMgr())),
416 aObjBoundLB(this, ResId( LB_OBJECTBOUNDARIES, *rResId.GetResMgr())),
417 aObjBoundWN(this, ResId( WN_OBJECTBOUNDARIES, *rResId.GetResMgr())),
418 aTableBoundCB(this, ResId( CB_TABLEBOUNDARIES, *rResId.GetResMgr())),
419 aTableBoundLB(this, ResId( LB_TABLEBOUNDARIES, *rResId.GetResMgr())),
420 aTableBoundWN(this, ResId( WN_TABLEBOUNDARIES, *rResId.GetResMgr())),
421 aFontColorFT(this, ResId( FT_FONTCOLOR, *rResId.GetResMgr())),
422 aFontColorLB(this, ResId( LB_FONTCOLOR, *rResId.GetResMgr())),
423 aFontColorWN(this, ResId( WN_FONTCOLOR, *rResId.GetResMgr())),
424 aLinksCB(this, ResId( CB_LINKS, *rResId.GetResMgr())),
425 aLinksLB(this, ResId( LB_LINKS, *rResId.GetResMgr())),
426 aLinksWN(this, ResId( WN_LINKS, *rResId.GetResMgr())),
427 aLinksVisitedCB(this, ResId( CB_LINKSVISITED, *rResId.GetResMgr())),
428 aLinksVisitedLB(this, ResId( LB_LINKSVISITED, *rResId.GetResMgr())),
429 aLinksVisitedWN(this, ResId( WN_LINKSVISITED, *rResId.GetResMgr())),
430 aSpellFT(this, ResId( FT_SPELL, *rResId.GetResMgr())),
431 aSpellLB(this, ResId( LB_SPELL, *rResId.GetResMgr())),
432 aSpellWN(this, ResId( WN_SPELL, *rResId.GetResMgr())),
433 aSmarttagsFT(this, ResId( FT_SMARTTAGS, *rResId.GetResMgr() )),
434 aSmarttagsLB(this, ResId( LB_SMARTTAGS, *rResId.GetResMgr() )),
435 aSmarttagsWN(this, ResId( WN_SMARTTAGS, *rResId.GetResMgr() )),
436 aWriterBackWN(this),
437 aWriterFT(this, ResId(FT_WRITER, *rResId.GetResMgr())),
438 aWrtTextGridFT(this, ResId( FT_WRITERTEXTGRID, *rResId.GetResMgr())),
439 aWrtTextGridLB(this, ResId( LB_WRITERTEXTGRID, *rResId.GetResMgr())),
440 aWrtTextGridWN(this, ResId( WN_WRITERTEXTGRID, *rResId.GetResMgr())),
441 aWrtFieldCB(this, ResId( CB_WRITERFIELDSHADINGS, *rResId.GetResMgr())),
442 aWrtFieldLB(this, ResId( LB_WRITERFIELDSHADINGS, *rResId.GetResMgr())),
443 aWrtFieldWN(this, ResId( WN_WRITERFIELDSHADINGS, *rResId.GetResMgr())),
444 aWrtIdxShadingBackCB(this, ResId( CB_WRITERIDXSHADINGS, *rResId.GetResMgr())),
445 aWrtIdxShadingBackLB(this, ResId( LB_WRITERIDXSHADINGS, *rResId.GetResMgr())),
446 aWrtIdxShadingBackWN(this, ResId( WN_WRITERIDXSHADINGS, *rResId.GetResMgr())),
447 aWrtScriptIndicatorFT(this, ResId( FT_WRITERSCRIPTINDICATOR, *rResId.GetResMgr())),
448 aWrtScriptIndicatorLB(this, ResId( LB_WRITERSCRIPTINDICATOR, *rResId.GetResMgr())),
449 aWrtScriptIndicatorWN(this, ResId( WN_WRITERSCRIPTINDICATOR, *rResId.GetResMgr())),
450 aWrtSectionBoundCB(this, ResId( CB_WRITERSECTIONBOUNDARIES, *rResId.GetResMgr())),
451 aWrtSectionBoundLB(this, ResId( LB_WRITERSECTIONBOUNDARIES, *rResId.GetResMgr())),
452 aWrtSectionBoundWN(this, ResId( WN_WRITERSECTIONBOUNDARIES, *rResId.GetResMgr())),
453 aWrtPageBreaksFT(this, ResId( FT_WRITERPAGEBREAKS, *rResId.GetResMgr())),
454 aWrtPageBreaksLB(this, ResId( LB_WRITERPAGEBREAKS, *rResId.GetResMgr())),
455 aWrtPageBreaksWN(this, ResId( WN_WRITERPAGEBREAKS, *rResId.GetResMgr())),
456 aWrtDirectCrsrFT(this, ResId( FT_WRITERDIRECTCURSOR, *rResId.GetResMgr())),
457 aWrtDirectCrsrLB(this, ResId( LB_WRITERDIRECTCURSOR, *rResId.GetResMgr())),
458 aWrtDirectCrsrWN(this, ResId( WN_WRITERDIRECTCURSOR, *rResId.GetResMgr())),
459 aHTMLBackWN(this),
460 aHTMLFT(this, ResId( FT_HTML, *rResId.GetResMgr())),
461 aHTMLSGMLFT(this, ResId( FT_HTMLSGML, *rResId.GetResMgr())),
462 aHTMLSGMLLB(this, ResId( LB_HTMLSGML, *rResId.GetResMgr())),
463 aHTMLSGMLWN(this, ResId( WN_HTMLSGML, *rResId.GetResMgr())),
464 aHTMLCommentFT(this, ResId( FT_HTMLCOMMENT, *rResId.GetResMgr())),
465 aHTMLCommentLB(this, ResId( LB_HTMLCOMMENT, *rResId.GetResMgr())),
466 aHTMLCommentWN(this, ResId( WN_HTMLCOMMENT, *rResId.GetResMgr())),
467 aHTMLKeywdFT(this, ResId( FT_HTMLKEYWORD, *rResId.GetResMgr())),
468 aHTMLKeywdLB(this, ResId( LB_HTMLKEYWORD, *rResId.GetResMgr())),
469 aHTMLKeywdWN(this, ResId( WN_HTMLKEYWORD, *rResId.GetResMgr())),
470 aHTMLUnknownFT(this, ResId( FT_HTMLUNKNOWN, *rResId.GetResMgr())),
471 aHTMLUnknownLB(this, ResId( LB_HTMLUNKNOWN, *rResId.GetResMgr())),
472 aHTMLUnknownWN(this, ResId( WN_HTMLUNKNOWN, *rResId.GetResMgr())),
473 aCalcBackWN(this),
474 aCalcFT(this, ResId( FT_CALC, *rResId.GetResMgr())),
475 aCalcGridFT(this, ResId( FT_CALCGRID, *rResId.GetResMgr())),
476 aCalcGridLB(this, ResId( LB_CALCGRID, *rResId.GetResMgr())),
477 aCalcGridWN(this, ResId( WN_CALCGRID, *rResId.GetResMgr())),
478 aCalcPageBreakFT(this, ResId( FT_CALCPAGEBREAK, *rResId.GetResMgr())),
479 aCalcPageBreakLB(this, ResId( LB_CALCPAGEBREAK, *rResId.GetResMgr())),
480 aCalcPageBreakWN(this, ResId( WN_CALCPAGEBREAK, *rResId.GetResMgr())),
481 aCalcPageBreakManualFT(this, ResId( FT_CALCPAGEBREAKMANUAL, *rResId.GetResMgr())),
482 aCalcPageBreakManualLB(this, ResId( LB_CALCPAGEBREAKMANUAL, *rResId.GetResMgr())),
483 aCalcPageBreakManualWN(this, ResId( WN_CALCPAGEBREAKMANUAL, *rResId.GetResMgr())),
484 aCalcPageBreakAutoFT(this, ResId( FT_CALCPAGEBREAKAUTO, *rResId.GetResMgr())),
485 aCalcPageBreakAutoLB(this, ResId( LB_CALCPAGEBREAKAUTO, *rResId.GetResMgr())),
486 aCalcPageBreakAutoWN(this, ResId( WN_CALCPAGEBREAKAUTO, *rResId.GetResMgr())),
487 aCalcDetectiveFT(this, ResId( FT_CALCDETECTIVE, *rResId.GetResMgr())),
488 aCalcDetectiveLB(this, ResId( LB_CALCDETECTIVE, *rResId.GetResMgr())),
489 aCalcDetectiveWN(this, ResId( WN_CALCDETECTIVE, *rResId.GetResMgr())),
490 aCalcDetectiveErrorFT(this, ResId( FT_CALCDETECTIVEERROR, *rResId.GetResMgr())),
491 aCalcDetectiveErrorLB(this, ResId( LB_CALCDETECTIVEERROR, *rResId.GetResMgr())),
492 aCalcDetectiveErrorWN(this, ResId( WN_CALCDETECTIVEERROR, *rResId.GetResMgr())),
493 aCalcReferenceFT(this, ResId( FT_CALCREFERENCE, *rResId.GetResMgr())),
494 aCalcReferenceLB(this, ResId( LB_CALCREFERENCE, *rResId.GetResMgr())),
495 aCalcReferenceWN(this, ResId( WN_CALCREFERENCE, *rResId.GetResMgr())),
496 aCalcNotesBackFT(this, ResId( FT_CALCNOTESBACKGROUND, *rResId.GetResMgr())),
497 aCalcNotesBackLB(this, ResId( LB_CALCNOTESBACKGROUND, *rResId.GetResMgr())),
498 aCalcNotesBackWN(this, ResId( WN_CALCNOTESBACKGROUND, *rResId.GetResMgr())),
499 aDrawBackWN(this),
500 aDrawFT(this, ResId( FT_DRAW, *rResId.GetResMgr())),
501 aDrawGridFT(this, ResId( FT_DRAWGRID, *rResId.GetResMgr())),
502 aDrawGridLB(this, ResId( LB_DRAWGRID, *rResId.GetResMgr())),
503 aDrawGridWN(this, ResId( WN_DRAWGRID, *rResId.GetResMgr())),
504 aBasicBackWN(this),
505 aBasicFT(this, ResId( FT_BASIC, *rResId.GetResMgr())),
506 aBasicIdentifierFT(this, ResId( FT_BASICIDENTIFIER, *rResId.GetResMgr())),
507 aBasicIdentifierLB(this, ResId( LB_BASICIDENTIFIER, *rResId.GetResMgr())),
508 aBasicIdentifierWN(this, ResId( WN_BASICIDENTIFIER, *rResId.GetResMgr())),
509 aBasicCommentFT(this, ResId( FT_BASICCOMMENT, *rResId.GetResMgr())),
510 aBasicCommentLB(this, ResId( LB_BASICCOMMENT, *rResId.GetResMgr())),
511 aBasicCommentWN(this, ResId( WN_BASICCOMMENT, *rResId.GetResMgr())),
512 aBasicNumberFT(this, ResId( FT_BASICNUMBER, *rResId.GetResMgr())),
513 aBasicNumberLB(this, ResId( LB_BASICNUMBER, *rResId.GetResMgr())),
514 aBasicNumberWN(this, ResId( WN_BASICNUMBER, *rResId.GetResMgr())),
515 aBasicStringFT(this, ResId( FT_BASICSTRING, *rResId.GetResMgr())),
516 aBasicStringLB(this, ResId( LB_BASICSTRING, *rResId.GetResMgr())),
517 aBasicStringWN(this, ResId( WN_BASICSTRING, *rResId.GetResMgr())),
518 aBasicOperatorFT(this, ResId( FT_BASICOPERATOR, *rResId.GetResMgr())),
519 aBasicOperatorLB(this, ResId( LB_BASICOPERATOR, *rResId.GetResMgr())),
520 aBasicOperatorWN(this, ResId( WN_BASICOPERATOR, *rResId.GetResMgr())),
521 aBasicKeywordFT(this, ResId( FT_BASICKEYWORD, *rResId.GetResMgr())),
522 aBasicKeywordLB(this, ResId( LB_BASICKEYWORD, *rResId.GetResMgr())),
523 aBasicKeywordWN(this, ResId( WN_BASICKEYWORD, *rResId.GetResMgr())),
524 aBasicErrorFT(this, ResId( FT_BASICERROR, *rResId.GetResMgr())),
525 aBasicErrorLB(this, ResId( LB_BASICERROR, *rResId.GetResMgr())),
526 aBasicErrorWN(this, ResId( WN_BASICERROR, *rResId.GetResMgr())),
528 aSQLBackWN(this),
529 aSQLFT(this, ResId( FT_SQL_COMMAND, *rResId.GetResMgr())),
530 aSQLIdentifierFT(this, ResId( FT_SQLIDENTIFIER, *rResId.GetResMgr())),
531 aSQLIdentifierLB(this, ResId( LB_SQLIDENTIFIER, *rResId.GetResMgr())),
532 aSQLIdentifierWN(this, ResId( WN_SQLIDENTIFIER, *rResId.GetResMgr())),
534 aSQLNumberFT(this, ResId( FT_SQLNUMBER, *rResId.GetResMgr())),
535 aSQLNumberLB(this, ResId( LB_SQLNUMBER, *rResId.GetResMgr())),
536 aSQLNumberWN(this, ResId( WN_SQLNUMBER, *rResId.GetResMgr())),
538 aSQLStringFT(this, ResId( FT_SQLSTRING, *rResId.GetResMgr())),
539 aSQLStringLB(this, ResId( LB_SQLSTRING, *rResId.GetResMgr())),
540 aSQLStringWN(this, ResId( WN_SQLSTRING, *rResId.GetResMgr())),
542 aSQLOperatorFT(this, ResId( FT_SQLOPERATOR, *rResId.GetResMgr())),
543 aSQLOperatorLB(this, ResId( LB_SQLOPERATOR, *rResId.GetResMgr())),
544 aSQLOperatorWN(this, ResId( WN_SQLOPERATOR, *rResId.GetResMgr())),
546 aSQLKeywordFT(this, ResId( FT_SQLKEYWORD, *rResId.GetResMgr())),
547 aSQLKeywordLB(this, ResId( LB_SQLKEYWORD, *rResId.GetResMgr())),
548 aSQLKeywordWN(this, ResId( WN_SQLKEYWORD, *rResId.GetResMgr())),
550 aSQLParameterFT(this, ResId( FT_SQLPARAMETER, *rResId.GetResMgr())),
551 aSQLParameterLB(this, ResId( LB_SQLPARAMETER, *rResId.GetResMgr())),
552 aSQLParameterWN(this, ResId( WN_SQLPARAMETER, *rResId.GetResMgr())),
554 aSQLCommentFT(this, ResId( FT_SQLCOMMENT, *rResId.GetResMgr())),
555 aSQLCommentLB(this, ResId( LB_SQLCOMMENT, *rResId.GetResMgr())),
556 aSQLCommentWN(this, ResId( WN_SQLCOMMENT, *rResId.GetResMgr()))
558 aFixedTexts.resize(ColorConfigEntryCount);
559 aCheckBoxes.resize(ColorConfigEntryCount);
560 aColorBoxes.resize(ColorConfigEntryCount);
561 aWindows.resize(ColorConfigEntryCount);
563 aFixedTexts[DOCCOLOR ] = &aDocColorFT;
564 aCheckBoxes[DOCBOUNDARIES ] = &aDocBoundCB ;
565 aFixedTexts[APPBACKGROUND ] = &aAppBackFT;
566 aCheckBoxes[OBJECTBOUNDARIES ] = &aObjBoundCB ;
567 aCheckBoxes[TABLEBOUNDARIES ] = &aTableBoundCB ;
568 aFixedTexts[FONTCOLOR ] = &aFontColorFT ;
569 aCheckBoxes[LINKS ] = &aLinksCB ;
570 aCheckBoxes[LINKSVISITED ] = &aLinksVisitedCB ;
571 aFixedTexts[SPELL ]=& aSpellFT;
572 aFixedTexts[SMARTTAGS ]=& aSmarttagsFT;
573 aFixedTexts[WRITERTEXTGRID ]=& aWrtTextGridFT;
574 aCheckBoxes[WRITERFIELDSHADINGS ] = &aWrtFieldCB ;
575 aCheckBoxes[WRITERIDXSHADINGS ] = &aWrtIdxShadingBackCB ;
576 aFixedTexts[WRITERDIRECTCURSOR ]=& aWrtDirectCrsrFT;
577 aFixedTexts[WRITERSCRIPTINDICATOR ]=& aWrtScriptIndicatorFT;
578 aCheckBoxes[WRITERSECTIONBOUNDARIES ]=& aWrtSectionBoundCB;
579 aFixedTexts[HTMLSGML ]=& aHTMLSGMLFT;
580 aFixedTexts[HTMLCOMMENT ]=& aHTMLCommentFT;
581 aFixedTexts[HTMLKEYWORD ]=& aHTMLKeywdFT;
582 aFixedTexts[HTMLUNKNOWN ]=& aHTMLUnknownFT;
583 aFixedTexts[CALCGRID ] = &aCalcGridFT ;
584 aFixedTexts[CALCPAGEBREAK ] = &aCalcPageBreakFT;
585 aFixedTexts[CALCPAGEBREAKMANUAL ] = &aCalcPageBreakManualFT;
586 aFixedTexts[CALCPAGEBREAKAUTOMATIC ] = &aCalcPageBreakAutoFT;
587 aFixedTexts[CALCDETECTIVE ]=& aCalcDetectiveFT;
588 aFixedTexts[CALCDETECTIVEERROR ]=& aCalcDetectiveErrorFT;
589 aFixedTexts[CALCREFERENCE ]=& aCalcReferenceFT;
590 aFixedTexts[CALCNOTESBACKGROUND ]=& aCalcNotesBackFT;
591 aFixedTexts[WRITERPAGEBREAKS] = &aWrtPageBreaksFT;
592 aFixedTexts[DRAWGRID ] = &aDrawGridFT ;
593 aFixedTexts[BASICIDENTIFIER ] = &aBasicIdentifierFT;
594 aFixedTexts[BASICCOMMENT ] = &aBasicCommentFT;
595 aFixedTexts[BASICNUMBER ] = &aBasicNumberFT;
596 aFixedTexts[BASICSTRING ] = &aBasicStringFT;
597 aFixedTexts[BASICOPERATOR ] = &aBasicOperatorFT;
598 aFixedTexts[BASICKEYWORD ] = &aBasicKeywordFT;
599 aFixedTexts[BASICERROR ] = &aBasicErrorFT;
600 aFixedTexts[SQLIDENTIFIER ] = &aSQLIdentifierFT;
601 aFixedTexts[SQLNUMBER ] = &aSQLNumberFT;
602 aFixedTexts[SQLSTRING ] = &aSQLStringFT;
603 aFixedTexts[SQLOPERATOR ] = &aSQLOperatorFT;
604 aFixedTexts[SQLKEYWORD ] = &aSQLKeywordFT;
605 aFixedTexts[SQLPARAMETER ] = &aSQLParameterFT;
606 aFixedTexts[SQLCOMMENT ] = &aSQLCommentFT;
608 aColorBoxes[DOCCOLOR ] = &aDocColorLB ;
609 aColorBoxes[DOCBOUNDARIES ] = &aDocBoundLB ;
610 aColorBoxes[APPBACKGROUND ] = &aAppBackLB ;
611 aColorBoxes[OBJECTBOUNDARIES ] = &aObjBoundLB ;
612 aColorBoxes[TABLEBOUNDARIES ] = &aTableBoundLB ;
613 aColorBoxes[FONTCOLOR ] = &aFontColorLB ;
614 aColorBoxes[LINKS ] = &aLinksLB ;
615 aColorBoxes[LINKSVISITED ] = &aLinksVisitedLB ;
616 aColorBoxes[SPELL ] = &aSpellLB ;
617 aColorBoxes[SMARTTAGS ] = &aSmarttagsLB ;
618 aColorBoxes[WRITERTEXTGRID ] = &aWrtTextGridLB ;
619 aColorBoxes[WRITERFIELDSHADINGS ] = &aWrtFieldLB ;
620 aColorBoxes[WRITERIDXSHADINGS ] = &aWrtIdxShadingBackLB ;
621 aColorBoxes[WRITERDIRECTCURSOR ] = &aWrtDirectCrsrLB ;
622 aColorBoxes[WRITERSCRIPTINDICATOR ] = &aWrtScriptIndicatorLB ;
623 aColorBoxes[WRITERSECTIONBOUNDARIES ] = &aWrtSectionBoundLB ;
624 aColorBoxes[WRITERPAGEBREAKS] = &aWrtPageBreaksLB;
625 aColorBoxes[HTMLSGML ] = &aHTMLSGMLLB ;
626 aColorBoxes[HTMLCOMMENT ] = &aHTMLCommentLB ;
627 aColorBoxes[HTMLKEYWORD ] = &aHTMLKeywdLB ;
628 aColorBoxes[HTMLUNKNOWN ] = &aHTMLUnknownLB ;
629 aColorBoxes[CALCGRID ] = &aCalcGridLB ;
630 aColorBoxes[CALCPAGEBREAK ] = &aCalcPageBreakLB ;
631 aColorBoxes[CALCPAGEBREAKMANUAL ] = &aCalcPageBreakManualLB ;
632 aColorBoxes[CALCPAGEBREAKAUTOMATIC]= &aCalcPageBreakAutoLB ;
633 aColorBoxes[CALCDETECTIVE ] = &aCalcDetectiveLB ;
634 aColorBoxes[CALCDETECTIVEERROR ] = &aCalcDetectiveErrorLB ;
635 aColorBoxes[CALCREFERENCE ] = &aCalcReferenceLB ;
636 aColorBoxes[CALCNOTESBACKGROUND ] = &aCalcNotesBackLB ;
637 aColorBoxes[DRAWGRID ] = &aDrawGridLB ;
638 aColorBoxes[BASICIDENTIFIER ] = &aBasicIdentifierLB;
639 aColorBoxes[BASICCOMMENT ] = &aBasicCommentLB;
640 aColorBoxes[BASICNUMBER ] = &aBasicNumberLB;
641 aColorBoxes[BASICSTRING ] = &aBasicStringLB;
642 aColorBoxes[BASICOPERATOR ] = &aBasicOperatorLB;
643 aColorBoxes[BASICKEYWORD ] = &aBasicKeywordLB;
644 aColorBoxes[BASICERROR ] = &aBasicErrorLB;
645 aColorBoxes[SQLIDENTIFIER ] = &aSQLIdentifierLB;
646 aColorBoxes[SQLNUMBER ] = &aSQLNumberLB;
647 aColorBoxes[SQLSTRING ] = &aSQLStringLB;
648 aColorBoxes[SQLOPERATOR ] = &aSQLOperatorLB;
649 aColorBoxes[SQLKEYWORD ] = &aSQLKeywordLB;
650 aColorBoxes[SQLPARAMETER ] = &aSQLParameterLB;
651 aColorBoxes[SQLCOMMENT ] = &aSQLCommentLB;
653 aWindows[DOCCOLOR ] = &aDocColorWN ;
654 aWindows[DOCBOUNDARIES ] = &aDocBoundWN ;
655 aWindows[APPBACKGROUND ] = &aAppBackWN ;
656 aWindows[OBJECTBOUNDARIES ] = &aObjBoundWN ;
657 aWindows[TABLEBOUNDARIES ] = &aTableBoundWN ;
658 aWindows[FONTCOLOR ] = &aFontColorWN ;
659 aWindows[LINKS ] = &aLinksWN ;
660 aWindows[LINKSVISITED ] = &aLinksVisitedWN ;
661 aWindows[SPELL ] = &aSpellWN ;
662 aWindows[SMARTTAGS ] = &aSmarttagsWN ;
663 aWindows[WRITERTEXTGRID ] = &aWrtTextGridWN ;
664 aWindows[WRITERFIELDSHADINGS ] = &aWrtFieldWN ;
665 aWindows[WRITERIDXSHADINGS ] = &aWrtIdxShadingBackWN ;
666 aWindows[WRITERDIRECTCURSOR ] = &aWrtDirectCrsrWN ;
667 aWindows[WRITERSCRIPTINDICATOR ] = &aWrtScriptIndicatorWN ;
668 aWindows[WRITERSECTIONBOUNDARIES ] = &aWrtSectionBoundWN ;
669 aWindows[WRITERPAGEBREAKS] = &aWrtPageBreaksWN;
670 aWindows[HTMLSGML ] = &aHTMLSGMLWN ;
671 aWindows[HTMLCOMMENT ] = &aHTMLCommentWN ;
672 aWindows[HTMLKEYWORD ] = &aHTMLKeywdWN ;
673 aWindows[HTMLUNKNOWN ] = &aHTMLUnknownWN ;
674 aWindows[CALCGRID ] = &aCalcGridWN ;
675 aWindows[CALCPAGEBREAK ] = &aCalcPageBreakWN ;
676 aWindows[CALCPAGEBREAKMANUAL ] = &aCalcPageBreakManualWN ;
677 aWindows[CALCPAGEBREAKAUTOMATIC] = &aCalcPageBreakAutoWN ;
678 aWindows[CALCDETECTIVE ] = &aCalcDetectiveWN ;
679 aWindows[CALCDETECTIVEERROR ] = &aCalcDetectiveErrorWN ;
680 aWindows[CALCREFERENCE ] = &aCalcReferenceWN ;
681 aWindows[CALCNOTESBACKGROUND ] = &aCalcNotesBackWN ;
682 aWindows[DRAWGRID ] = &aDrawGridWN ;
683 aWindows[BASICIDENTIFIER ] = &aBasicIdentifierWN;
684 aWindows[BASICCOMMENT ] = &aBasicCommentWN;
685 aWindows[BASICNUMBER ] = &aBasicNumberWN;
686 aWindows[BASICSTRING ] = &aBasicStringWN;
687 aWindows[BASICOPERATOR ] = &aBasicOperatorWN;
688 aWindows[BASICKEYWORD ] = &aBasicKeywordWN;
689 aWindows[BASICERROR ] = &aBasicErrorWN;
690 aWindows[SQLIDENTIFIER ] = &aSQLIdentifierWN;
691 aWindows[SQLNUMBER ] = &aSQLNumberWN;
692 aWindows[SQLSTRING ] = &aSQLStringWN;
693 aWindows[SQLOPERATOR ] = &aSQLOperatorWN;
694 aWindows[SQLKEYWORD ] = &aSQLKeywordWN;
695 aWindows[SQLPARAMETER ] = &aSQLParameterWN;
696 aWindows[SQLCOMMENT ] = &aSQLCommentWN;
698 aChapters.push_back(&aGeneralFT); aChapterWins.push_back(&aGeneralBackWN);
699 aChapters.push_back(&aWriterFT); aChapterWins.push_back(&aWriterBackWN);
700 aChapters.push_back(&aHTMLFT); aChapterWins.push_back(&aHTMLBackWN);
701 aChapters.push_back(&aCalcFT); aChapterWins.push_back(&aCalcBackWN);
702 aChapters.push_back(&aDrawFT); aChapterWins.push_back(&aDrawBackWN);
703 aChapters.push_back(&aBasicFT); aChapterWins.push_back(&aBasicBackWN);
704 aChapters.push_back(&aSQLFT); aChapterWins.push_back(&aSQLBackWN);
706 // calculate heights of groups which can be hidden
707 aChapters[GROUP_WRITER ]->SetGroupHeight( aChapters[GROUP_HTML]->GetPosPixel().Y() - aChapters[GROUP_WRITER]->GetPosPixel().Y() );
708 aChapters[GROUP_HTML ]->SetGroupHeight( aChapters[GROUP_CALC]->GetPosPixel().Y() - aChapters[GROUP_HTML]->GetPosPixel().Y() );
709 aChapters[GROUP_CALC ]->SetGroupHeight( aChapters[GROUP_DRAW]->GetPosPixel().Y() - aChapters[GROUP_CALC]->GetPosPixel().Y() );
710 aChapters[GROUP_DRAW ]->SetGroupHeight( aChapters[GROUP_BASIC]->GetPosPixel().Y() - aChapters[GROUP_DRAW]->GetPosPixel().Y() );
711 aChapters[GROUP_BASIC ]->SetGroupHeight( aChapters[GROUP_SQL]->GetPosPixel().Y() - aChapters[GROUP_BASIC]->GetPosPixel().Y() );
713 ExtendedColorConfig aExtConfig;
714 sal_Int32 nExtCount = aExtConfig.GetComponentCount();
715 if ( nExtCount )
717 // calculate position behind last chapter
718 sal_Int32 nLastY = aSQLCommentWN.GetPosPixel().Y() + aSQLCommentWN.GetSizePixel().Height();
719 nLastY = nLastY + LogicToPixel( Size( 0, 3 ), MAP_APPFONT ).Height();
720 // to calculate the number of lines
721 sal_Int32 nHeight = LogicToPixel( Size( 0, _LINE_HEIGHT ), MAP_APPFONT ).Height();
722 sal_Int32 nLineNum = nLastY / nHeight;
724 Point aFixedPos = LogicToPixel( Point( _FT_XPOS, nLineNum * _LINE_HEIGHT ), MAP_APPFONT );
725 Point aLBPos = LogicToPixel( Point( _LB_XPOS, nLineNum * _LINE_HEIGHT ), MAP_APPFONT );
726 Size aFixedSize = LogicToPixel( Size( _FT_WIDTH , _FT_HEIGHT ), MAP_APPFONT );
727 Size aLBSize = LogicToPixel( Size( _LB_WIDTH , _LB_HEIGHT ), MAP_APPFONT );
728 Size aWinSize = LogicToPixel( Size( _WN_WIDTH , _WN_HEIGHT ), MAP_APPFONT );
730 for (sal_Int32 j = 0; j < nExtCount; ++j)
732 ::rtl::OUString sComponentName = aExtConfig.GetComponentName(j);
733 aChapterWins.push_back(new Window(this));
734 ::boost::shared_ptr<SvxExtFixedText_Impl> pTitle(new SvxExtFixedText_Impl(this,ResId(FT_SQL_COMMAND, *rResId.GetResMgr())));
735 m_aExtensionTitles.push_back(pTitle);
736 pTitle->SetPosSizePixel(LogicToPixel( Point( _FT_XPOS, nLineNum * _LINE_HEIGHT ), MAP_APPFONT ),aFixedSize);
737 pTitle->SetText(aExtConfig.GetComponentDisplayName(sComponentName));
738 aChapters.push_back(pTitle.get());
739 ++nLineNum;
740 sal_Int32 nColorCount = aExtConfig.GetComponentColorCount(sComponentName);
741 for (sal_Int32 i = 0; i < nColorCount; ++i,++nLineNum)
743 ExtendedColorConfigValue aColorEntry = aExtConfig.GetComponentColorConfigValue(sComponentName,i);
744 FixedText* pFixedText = new FixedText(this,ResId(FT_BASICERROR, *rResId.GetResMgr()));
745 pFixedText->SetPosSizePixel(LogicToPixel( Point( _FT_XPOS, nLineNum * _LINE_HEIGHT ), MAP_APPFONT ),aFixedSize);
746 pFixedText->SetText(aColorEntry.getDisplayName());
747 aFixedTexts.push_back(pFixedText);
748 aCheckBoxes.push_back(NULL); // no checkboxes
749 ColorListBox* pColorBox = new ColorListBox(this,ResId(LB_BASICERROR, *rResId.GetResMgr()));
750 pColorBox->SetPosSizePixel(LogicToPixel( Point( _LB_XPOS, nLineNum * _LINE_HEIGHT ), MAP_APPFONT ),aLBSize);
751 aColorBoxes.push_back(pColorBox);
752 Window* pWin = new Window(this,ResId(WN_BASICERROR, *rResId.GetResMgr()));
753 pWin->SetPosSizePixel(LogicToPixel( Point( _WN_XPOS, nLineNum * _LINE_HEIGHT ), MAP_APPFONT ),aWinSize);
754 aWindows.push_back(pWin);
755 } // for (sal_Int32 i = 0; i < nExtCount; ++i,++nLineNum)
759 FreeResource();
761 Color TempColor(COL_TRANSPARENT);
762 Wallpaper aTransparentWall(TempColor);
763 sal_Int32 nWinWidth = GetSizePixel().Width();
764 sal_Int32 nFTHeight = aChapters[0]->GetSizePixel().Height();
765 sal_Bool bHighContrast = GetDisplayBackground().GetColor().IsDark();
766 Color aBackColor;
767 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
768 if ( bHighContrast )
769 aBackColor = rStyleSettings.GetShadowColor();
770 else
771 aBackColor = Color( COL_LIGHTGRAY);
772 sal_Int32 nCount = aChapterWins.size();
773 for(sal_Int32 i = 0; i < nCount; ++i)
775 if ( lcl_isGroupVisible( i, m_aModuleOptions ) )
777 Font aFont = aChapters[i]->GetFont();
778 aFont.SetWeight(WEIGHT_BOLD);
779 aChapters[i]->SetFont(aFont);
780 aChapters[i]->SetBackground(aTransparentWall);
781 aChapterWins[i]->SetPosSizePixel( Point(0, aChapters[i]->GetPosPixel().Y()),
782 Size(nWinWidth, nFTHeight));
783 aChapterWins[i]->SetBackground(Wallpaper(aBackColor));
784 aChapterWins[i]->Show();
786 else
788 aChapters[i]->Hide();
789 aChapterWins[i]->Hide();
792 Color aTextColor;
793 BOOL bSetTextColor = FALSE;
794 //#104195# when the window color is the same as the text color it has to be changed
795 Color aWinCol = rStyleSettings.GetWindowColor();
796 Color aRCheckCol = rStyleSettings.GetRadioCheckTextColor();
797 if(aWinCol == aRCheckCol )
799 bSetTextColor = TRUE;
800 aRCheckCol.Invert();
801 //if inversion didn't work (gray) then it's set to black
802 if(aRCheckCol == aWinCol)
803 aRCheckCol = Color(COL_BLACK);
804 } // if(aWinCol == aRCheckCol )
805 nCount = aFixedTexts.size();
806 sal_Int16 nGroup = GROUP_UNKNOWN;
807 for( sal_Int32 i = 0; i < nCount; i++ )
809 if(ANCHOR == i)
810 continue;
811 sal_Int16 nNewGroup = lcl_getGroup(i);
812 sal_Bool bShow = lcl_isGroupVisible( nNewGroup, m_aModuleOptions );
814 if ( nNewGroup > nGroup )
816 nGroup = nNewGroup;
817 if ( bShow && nGroup >= GROUP_CALC )
819 SetNewPosition( i, aChapters[nGroup] );
820 SetNewPosition( i, aChapterWins[nGroup] );
823 if(aCheckBoxes[i])
825 if ( bShow )
826 SetNewPosition( i, aCheckBoxes[i] );
827 else
828 aCheckBoxes[i]->Hide();
829 aCheckBoxes[i]->SetBackground(aTransparentWall);
830 aCheckBoxes[i]->SetHelpId(HID_COLORPAGE_CHECKBOX_START + i);
831 if(bSetTextColor)
832 aCheckBoxes[i]->SetTextColor(aRCheckCol);
834 if(aFixedTexts[i])
836 if ( bShow )
837 SetNewPosition( i, aFixedTexts[i] );
838 else
839 aFixedTexts[i]->Hide();
840 aFixedTexts[i]->SetBackground(aTransparentWall);
841 if(bSetTextColor)
842 aFixedTexts[i]->SetTextColor(aRCheckCol);
844 if(aWindows[i])
846 if ( bShow )
847 SetNewPosition( i, aWindows[i] );
848 else
849 aWindows[i]->Hide();
850 aWindows[i]->SetBorderStyle(WINDOW_BORDER_MONO);
853 if ( aColorBoxes[i] )
855 if ( bShow )
856 SetNewPosition( i, aColorBoxes[i] );
857 else
858 aColorBoxes[i]->Hide();
862 XColorTable aColorTable( SvtPathOptions().GetPalettePath() );
863 aColorBoxes[0]->InsertAutomaticEntry();
864 for( sal_Int32 i = 0; i < aColorTable.Count(); i++ )
866 XColorEntry* pEntry = aColorTable.GetColor(i);
867 aColorBoxes[0]->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
869 aColorBoxes[0]->SetHelpId(HID_COLORPAGE_LISTBOX_START);
870 for( sal_Int32 i = 1; i < nCount; i++ )
872 if(aColorBoxes[i])
874 aColorBoxes[i]->CopyEntries( *aColorBoxes[0] );
875 aColorBoxes[i]->SetHelpId(HID_COLORPAGE_LISTBOX_START + i);
879 /* -----------------------------27.03.2002 11:04------------------------------
881 ---------------------------------------------------------------------------*/
882 ColorConfigWindow_Impl::~ColorConfigWindow_Impl()
884 aChapters.clear();
885 ::std::vector< SvxExtFixedText_Impl*>().swap(aChapters);
888 sal_Int32 nCount = aFixedTexts.size();
889 for (sal_Int32 i = ColorConfigEntryCount; i < nCount; ++i)
891 delete aFixedTexts[i];
892 delete aCheckBoxes[i];
893 delete aColorBoxes[i];
894 delete aWindows[i];
896 for (sal_uInt32 i = GROUP_COUNT; i < aChapterWins.size(); ++i)
897 delete aChapterWins[i];
898 aChapterWins.clear();
899 ::std::vector< Window*>().swap(aChapterWins);
901 /* -----------------------------2002/06/20 12:48------------------------------
903 ---------------------------------------------------------------------------*/
904 void ColorConfigWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
906 Window::DataChanged( rDCEvt );
907 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
908 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
910 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
911 sal_Bool bHighContrast = rStyleSettings.GetHighContrastMode();
912 Color aBackColor( bHighContrast ? COL_TRANSPARENT : COL_LIGHTGRAY);
913 ::std::vector< Window* >::iterator aIter = aChapterWins.begin();
914 ::std::vector< Window* >::iterator aEnd = aChapterWins.end();
915 for(;aIter != aEnd; ++aIter )
916 (*aIter)->SetBackground(Wallpaper(aBackColor));
917 SetBackground(Wallpaper(rStyleSettings.GetWindowColor()));
920 /* -----------------------------2002/06/26 10:49------------------------------
922 ---------------------------------------------------------------------------*/
923 void SvxExtFixedText_Impl::DataChanged(const DataChangedEvent& rDCEvt)
925 FixedText::DataChanged(rDCEvt);
926 Color TempColor(COL_TRANSPARENT);
927 Wallpaper aTransparentWall(TempColor);
928 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
929 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
931 Font aFont = GetFont();
932 aFont.SetWeight(WEIGHT_BOLD);
933 SetFont(aFont);
934 SetBackground(aTransparentWall);
938 void ColorConfigWindow_Impl::SetNewPosition( sal_Int32 _nFeature, Window* _pWin )
940 DBG_ASSERT( _pWin, "ColorConfigWindow_Impl::SetNewPosition(): no window" );
942 // calculate the overall height of the invisible groups
943 long nDelta = 0;
944 sal_Int16 nGroup = lcl_getGroup( _nFeature ) - 1;
945 while ( nGroup > 0 ) // GROUP_GENERAL (0) is always visible
947 if ( !lcl_isGroupVisible( nGroup, m_aModuleOptions ) )
948 nDelta += aChapters[nGroup]->GetGroupHeight();
949 nGroup--;
952 // move this window to its new position
953 if ( nDelta > 0 )
955 Point aPos = _pWin->GetPosPixel();
956 aPos.Y() -= nDelta;
957 _pWin->SetPosPixel( aPos );
961 /* -----------------------------08.04.2002 17:10------------------------------
963 ---------------------------------------------------------------------------*/
964 void ColorConfigWindow_Impl::Command( const CommandEvent& rCEvt )
966 GetParent()->Command(rCEvt);
968 /* -----------------------------25.03.2002 10:44------------------------------
970 ---------------------------------------------------------------------------*/
971 class ColorConfigCtrl_Impl : public Control
973 HeaderBar aHeaderHB;
974 ScrollBar aVScroll;
976 String sOn;
977 String sUIElem;
978 String sColSetting;
979 String sPreview;
980 ColorConfigWindow_Impl aScrollWindow;
982 EditableColorConfig* pColorConfig;
983 EditableExtendedColorConfig* pExtColorConfig;
985 long nScrollPos;
987 DECL_LINK(ScrollHdl, ScrollBar*);
988 DECL_LINK(ClickHdl, CheckBox*);
989 DECL_LINK(ColorHdl, ColorListBox*);
990 DECL_LINK(ControlFocusHdl, Control*);
992 virtual long PreNotify( NotifyEvent& rNEvt );
993 virtual void Command( const CommandEvent& rCEvt );
994 virtual void DataChanged( const DataChangedEvent& rDCEvt );
995 public:
996 ColorConfigCtrl_Impl(Window* pParent, const ResId& rResId );
997 ~ColorConfigCtrl_Impl();
999 void SetConfig(EditableColorConfig& rConfig) {pColorConfig = &rConfig;}
1000 void SetExtendedConfig(EditableExtendedColorConfig& rConfig) {pExtColorConfig = &rConfig;}
1001 void Update();
1002 sal_Int32 GetScrollPosition() {return aVScroll.GetThumbPos();}
1003 void SetScrollPosition(sal_Int32 nSet)
1005 aVScroll.SetThumbPos(nSet);
1006 ScrollHdl(&aVScroll);
1009 /* -----------------------------25.03.2002 17:09------------------------------
1011 ---------------------------------------------------------------------------*/
1012 ColorConfigCtrl_Impl::ColorConfigCtrl_Impl(
1013 Window* pParent, const ResId& rResId) :
1014 Control(pParent, rResId),
1017 aHeaderHB(this, WB_BUTTONSTYLE | WB_BOTTOMBORDER),
1018 aVScroll(this, ResId(VB_VSCROLL, *rResId.GetResMgr())),
1019 sOn( ResId(ST_ON, *rResId.GetResMgr())),
1020 sUIElem( ResId(ST_UIELEM, *rResId.GetResMgr())),
1021 sColSetting( ResId(ST_COLSET, *rResId.GetResMgr())),
1022 sPreview( ResId(ST_PREVIEW, *rResId.GetResMgr())),
1023 aScrollWindow(this, ResId(WN_SCROLL, *rResId.GetResMgr())),
1025 pColorConfig(0),
1026 pExtColorConfig(0),
1027 nScrollPos(0)
1029 FreeResource();
1031 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1032 aScrollWindow.SetBackground(Wallpaper(rStyleSettings.GetFieldColor()));
1033 aScrollWindow.SetHelpId( HID_OPTIONS_COLORCONFIG_COLORLIST_WIN );
1034 aVScroll.EnableDrag();
1035 aVScroll.Show();
1036 aHeaderHB.SetPosSizePixel(
1037 Point(0,0),
1038 Size(GetOutputSizePixel().Width(), aVScroll.GetPosPixel().Y()));
1039 sal_Int32 nFirstWidth = aScrollWindow.aGeneralFT.GetPosPixel().X();
1040 sal_Int32 nSecondWidth = aScrollWindow.aColorBoxes[0]->GetPosPixel().X() - nFirstWidth;
1041 sal_Int32 nThirdWidth = aScrollWindow.aWindows[0]->GetPosPixel().X() - nFirstWidth - nSecondWidth;
1043 const WinBits nHeadBits = HIB_VCENTER | HIB_FIXED| HIB_FIXEDPOS;
1044 aHeaderHB.InsertItem( 1, sOn, nFirstWidth, (USHORT)nHeadBits|HIB_CENTER);
1045 aHeaderHB.InsertItem( 2, sUIElem, nSecondWidth, (USHORT)nHeadBits|HIB_LEFT);
1046 aHeaderHB.InsertItem( 3, sColSetting, nThirdWidth, (USHORT)nHeadBits|HIB_LEFT);
1047 aHeaderHB.InsertItem( 4, sPreview,
1048 aHeaderHB.GetSizePixel().Width() - nFirstWidth - nSecondWidth - nThirdWidth, (USHORT)nHeadBits|HIB_LEFT);
1049 aHeaderHB.Show();
1051 aVScroll.SetRangeMin(0);
1052 sal_Int32 nScrollOffset = aScrollWindow.aColorBoxes[1]->GetPosPixel().Y() - aScrollWindow.aColorBoxes[0]->GetPosPixel().Y();
1053 sal_Int32 nVisibleEntries = aScrollWindow.GetSizePixel().Height() / nScrollOffset;
1055 aVScroll.SetRangeMax(aScrollWindow.aCheckBoxes.size() + aScrollWindow.aChapters.size() );
1056 // static: minus three for ANCHOR, DRAWFILL and DRAWDRAWING
1057 aVScroll.SetRangeMax( aVScroll.GetRangeMax() - 3 );
1058 // dynamic: calculate the hidden lines
1059 long nInvisibleLines = 0;
1060 sal_Int16 nGroup = GROUP_UNKNOWN;
1061 sal_Int32 nCount = aScrollWindow.aCheckBoxes.size();
1062 for ( sal_Int32 i = 0; i < nCount; i++ )
1064 if ( ANCHOR == i || DRAWFILL == i || DRAWDRAWING == i ) // not used at the moment
1065 continue;
1066 sal_Int16 nNewGroup = lcl_getGroup(i);
1067 sal_Bool bVisible = lcl_isGroupVisible( nNewGroup, aScrollWindow.GetModuleOptions() );
1068 if ( !bVisible )
1069 nInvisibleLines++;
1070 if ( nNewGroup > nGroup )
1072 nGroup = nNewGroup;
1073 if ( !bVisible )
1074 nInvisibleLines++;
1077 aVScroll.SetRangeMax( aVScroll.GetRangeMax() - nInvisibleLines );
1079 aVScroll.SetPageSize( nVisibleEntries - 1 );
1080 aVScroll.SetVisibleSize(nVisibleEntries);
1081 Link aScrollLink = LINK(this, ColorConfigCtrl_Impl, ScrollHdl);
1082 aVScroll.SetScrollHdl(aScrollLink);
1083 aVScroll.SetEndScrollHdl(aScrollLink);
1085 Link aCheckLink = LINK(this, ColorConfigCtrl_Impl, ClickHdl);
1086 Link aColorLink = LINK(this, ColorConfigCtrl_Impl, ColorHdl);
1087 Link aGetFocusLink = LINK(this, ColorConfigCtrl_Impl, ControlFocusHdl);
1088 for( sal_Int16 i = 0; i < nCount; i++ )
1090 if(aScrollWindow.aColorBoxes[i])
1092 aScrollWindow.aColorBoxes[i]->SetSelectHdl(aColorLink);
1093 aScrollWindow.aColorBoxes[i]->SetGetFocusHdl(aGetFocusLink);
1095 if(aScrollWindow.aCheckBoxes[i])
1097 aScrollWindow.aCheckBoxes[i]->SetClickHdl(aCheckLink);
1098 aScrollWindow.aCheckBoxes[i]->SetGetFocusHdl(aGetFocusLink);
1102 /* -----------------------------27.03.2002 10:46------------------------------
1104 ---------------------------------------------------------------------------*/
1105 ColorConfigCtrl_Impl::~ColorConfigCtrl_Impl()
1108 /* -----------------------------25.03.2002 17:19------------------------------
1110 ---------------------------------------------------------------------------*/
1111 void ColorConfigCtrl_Impl::Update()
1113 DBG_ASSERT(pColorConfig, "Configuration not set" );
1114 sal_Int32 i;
1115 for( i = 0; i < ColorConfigEntryCount; i++ )
1117 if(ANCHOR == i)
1118 continue;
1119 const ColorConfigValue& rColorEntry = pColorConfig->GetColorValue(ColorConfigEntry(i));
1120 if(COL_AUTO == (UINT32)rColorEntry.nColor)
1122 if(aScrollWindow.aColorBoxes[i])
1123 aScrollWindow.aColorBoxes[i]->SelectEntryPos(0);
1124 if(aScrollWindow.aWindows[i])
1125 aScrollWindow.aWindows[i]->SetBackground(
1126 Wallpaper(ColorConfig::GetDefaultColor((ColorConfigEntry) i)));
1128 else
1130 Color aColor(rColorEntry.nColor);
1131 if(aScrollWindow.aColorBoxes[i])
1132 aScrollWindow.aColorBoxes[i]->SelectEntry( aColor );
1133 if(aScrollWindow.aWindows[i])
1134 aScrollWindow.aWindows[i]->SetBackground(Wallpaper(aColor));
1136 if(aScrollWindow.aWindows[i])
1137 aScrollWindow.aWindows[i]->Invalidate();
1138 if(aScrollWindow.aCheckBoxes[i])
1139 aScrollWindow.aCheckBoxes[i]->Check(rColorEntry.bIsVisible);
1140 } // for( i = 0; i < ColorConfigEntryCount; i++ )
1143 sal_Int32 nExtCount = pExtColorConfig->GetComponentCount();
1144 sal_Int32 nCount = aScrollWindow.aCheckBoxes.size();
1145 sal_Int32 nPos = 0;
1146 i = ColorConfigEntryCount;
1147 for (sal_Int32 j = 0; j < nExtCount; ++j)
1149 ::rtl::OUString sComponentName = pExtColorConfig->GetComponentName(j);
1150 sal_Int32 nColorCount = pExtColorConfig->GetComponentColorCount(sComponentName);
1152 for( sal_Int32 k = 0; i < nCount && k < nColorCount; ++i ,++nPos,++k)
1154 if(aScrollWindow.aColorBoxes[i])
1156 ExtendedColorConfigValue aColorEntry = pExtColorConfig->GetComponentColorConfigValue(sComponentName,k);
1157 Color aColor(aColorEntry.getColor());
1158 if(aColorEntry.getDefaultColor() == aColorEntry.getColor() )
1160 aScrollWindow.aColorBoxes[i]->SelectEntryPos(0);
1162 else
1164 aScrollWindow.aColorBoxes[i]->SelectEntry( aColor );
1166 if(aScrollWindow.aWindows[i])
1167 aScrollWindow.aWindows[i]->SetBackground(Wallpaper(aColor));
1169 if(aScrollWindow.aWindows[i])
1170 aScrollWindow.aWindows[i]->Invalidate();
1175 /* -----------------------------26.03.2002 12:55------------------------------
1177 ---------------------------------------------------------------------------*/
1178 sal_Bool lcl_MoveAndShow(Window* pWindow, long nOffset, long nMaxVisible, bool _bShow)
1180 BOOL bHide = TRUE;
1181 if(pWindow)
1183 Point aPos = pWindow->GetPosPixel();
1184 aPos.Y() += nOffset;
1185 pWindow->SetPosPixel(aPos);
1186 if ( _bShow )
1187 bHide = aPos.Y() > nMaxVisible || (aPos.Y() + pWindow->GetSizePixel().Height()) < 0;
1188 pWindow->Show(!bHide);
1190 return !bHide;
1192 IMPL_LINK(ColorConfigCtrl_Impl, ScrollHdl, ScrollBar*, pScrollBar)
1194 aScrollWindow.SetUpdateMode(TRUE);
1195 sal_Int16 i;
1196 long nOffset = aScrollWindow.aColorBoxes[1]->GetPosPixel().Y() - aScrollWindow.aColorBoxes[0]->GetPosPixel().Y();
1197 nOffset *= (nScrollPos - pScrollBar->GetThumbPos());
1198 nScrollPos = pScrollBar->GetThumbPos();
1199 const long nWindowHeight = aScrollWindow.GetSizePixel().Height();
1200 sal_Int16 nFirstVisible = -1;
1201 sal_Int16 nLastVisible = -1;
1202 sal_Int32 nCount = aScrollWindow.aFixedTexts.size();
1203 for( i = 0; i < nCount; i++ )
1205 if(ANCHOR == i)
1206 continue;
1207 Point aPos;
1208 //controls outside of the view need to be hidden to speed up accessibility tools
1209 bool bShowCtrl = ( lcl_isGroupVisible(
1210 lcl_getGroup(i), aScrollWindow.GetModuleOptions() ) != sal_False );
1211 lcl_MoveAndShow(aScrollWindow.aCheckBoxes[i], nOffset, nWindowHeight, bShowCtrl);
1212 lcl_MoveAndShow(aScrollWindow.aFixedTexts[i], nOffset, nWindowHeight, bShowCtrl);
1213 lcl_MoveAndShow(aScrollWindow.aWindows[i] , nOffset, nWindowHeight, bShowCtrl);
1214 BOOL bShow = lcl_MoveAndShow(aScrollWindow.aColorBoxes[i], nOffset, nWindowHeight, bShowCtrl);
1215 if(bShow)
1217 if(nFirstVisible == -1)
1218 nFirstVisible = i;
1219 else
1220 nLastVisible = i;
1223 //show the one prior to the first visible and the first after the last visble control
1224 //to enable KEY_TAB travelling
1226 if(nFirstVisible)
1228 //skip gaps where no controls exist for the related ColorConfigEntry
1230 --nFirstVisible;
1231 while(!aScrollWindow.aCheckBoxes[nFirstVisible] && !aScrollWindow.aColorBoxes[nFirstVisible] && nFirstVisible >= 0);
1233 if ( lcl_isGroupVisible(
1234 lcl_getGroup( nFirstVisible ), aScrollWindow.GetModuleOptions() ) != sal_False )
1236 if(aScrollWindow.aCheckBoxes[nFirstVisible])
1237 aScrollWindow.aCheckBoxes[nFirstVisible]->Show();
1238 if(aScrollWindow.aColorBoxes[nFirstVisible])
1239 aScrollWindow.aColorBoxes[nFirstVisible]->Show();
1243 if(nLastVisible < nCount - 1)
1245 nLastVisible++;
1246 //skip gaps where no controls exist for the related ColorConfigEntry
1247 while(!aScrollWindow.aCheckBoxes[nLastVisible] && !aScrollWindow.aColorBoxes[nLastVisible] &&
1248 nLastVisible < nCount - 1 )
1249 nLastVisible++;
1250 if ( nLastVisible < nCount )
1252 if ( lcl_isGroupVisible(
1253 lcl_getGroup( nLastVisible ), aScrollWindow.GetModuleOptions() ) != sal_False )
1255 if(aScrollWindow.aCheckBoxes[nLastVisible])
1256 aScrollWindow.aCheckBoxes[nLastVisible]->Show();
1257 if(aScrollWindow.aColorBoxes[nLastVisible])
1258 aScrollWindow.aColorBoxes[nLastVisible]->Show();
1261 } // if(nLastVisible < nCount - 1)
1262 sal_Int32 nChapterCount = aScrollWindow.aChapters.size();
1263 for( i = 0; i < nChapterCount; i++ )
1265 Point aPos = aScrollWindow.aChapters[i]->GetPosPixel(); aPos.Y() += nOffset; aScrollWindow.aChapters[i]->SetPosPixel(aPos);
1266 aPos = aScrollWindow.aChapterWins[i]->GetPosPixel(); aPos.Y() += nOffset; aScrollWindow.aChapterWins[i]->SetPosPixel(aPos);
1268 aScrollWindow.SetUpdateMode(TRUE);
1269 return 0;
1271 /* -----------------------------29.04.2002 17:02------------------------------
1273 ---------------------------------------------------------------------------*/
1274 long ColorConfigCtrl_Impl::PreNotify( NotifyEvent& rNEvt )
1276 if(rNEvt.GetType() == EVENT_COMMAND)
1278 const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
1279 USHORT nCmd = pCEvt->GetCommand();
1280 if( COMMAND_WHEEL == nCmd )
1282 Command(*pCEvt);
1283 return 1;
1286 return Control::PreNotify(rNEvt);
1288 /* -----------------------------08.04.2002 16:37------------------------------
1290 ---------------------------------------------------------------------------*/
1291 void ColorConfigCtrl_Impl::Command( const CommandEvent& rCEvt )
1293 switch ( rCEvt.GetCommand() )
1296 case COMMAND_WHEEL:
1297 case COMMAND_STARTAUTOSCROLL:
1298 case COMMAND_AUTOSCROLL:
1300 const CommandWheelData* pWheelData = rCEvt.GetWheelData();
1301 if(pWheelData && !pWheelData->IsHorz() && COMMAND_WHEEL_ZOOM != pWheelData->GetMode())
1303 HandleScrollCommand( rCEvt, 0, &aVScroll );
1306 break;
1307 default:
1308 Control::Command(rCEvt);
1312 /* -----------------------------14.12.2005 12:37------------------------------
1314 ---------------------------------------------------------------------------*/
1315 void ColorConfigCtrl_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1317 Window::DataChanged( rDCEvt );
1318 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1319 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1321 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1322 SetBackground(Wallpaper(rStyleSettings.GetFieldColor()));
1327 /* -----------------------------27.03.2002 11:43------------------------------
1329 ---------------------------------------------------------------------------*/
1330 IMPL_LINK(ColorConfigCtrl_Impl, ClickHdl, CheckBox*, pBox)
1332 DBG_ASSERT(pColorConfig, "Configuration not set" );
1334 for( sal_Int32 i = 0; i < ColorConfigEntryCount; i++ )
1336 if(ANCHOR == i)
1337 continue;
1338 if(aScrollWindow.aCheckBoxes[i] == pBox )
1340 ColorConfigValue aBoundCol = pColorConfig->GetColorValue(ColorConfigEntry(i));
1341 aBoundCol.bIsVisible = pBox->IsChecked();
1342 pColorConfig->SetColorValue(ColorConfigEntry(i), aBoundCol);
1343 break;
1345 } // for( sal_Int32 i = 0; i < ColorConfigEntryCount; i++ )
1346 return 0;
1348 /* -----------------------------27.03.2002 11:43------------------------------
1350 ---------------------------------------------------------------------------*/
1351 IMPL_LINK(ColorConfigCtrl_Impl, ColorHdl, ColorListBox*, pBox)
1353 DBG_ASSERT(pColorConfig, "Configuration not set" );
1354 sal_Int32 i = 0;
1355 for( ; i < ColorConfigEntryCount; i++ )
1357 if(pBox && aScrollWindow.aColorBoxes[i] == pBox)
1359 ColorConfigValue aColorEntry = pColorConfig->GetColorValue(ColorConfigEntry(i));
1360 if(!pBox->GetSelectEntryPos())
1362 aColorEntry.nColor = COL_AUTO;
1363 if(aScrollWindow.aWindows[i])
1364 aScrollWindow.aWindows[i]->SetBackground(
1365 Wallpaper(ColorConfig::GetDefaultColor((ColorConfigEntry) i)));
1367 else
1369 Color aColor = pBox->GetSelectEntryColor(); // #i14869# no Color&, 'cause it's a ref to a temp object on the stack!
1370 aColorEntry.nColor = aColor.GetColor();
1371 if(aScrollWindow.aWindows[i])
1372 aScrollWindow.aWindows[i]->SetBackground(Wallpaper(aColor));
1374 if(aScrollWindow.aWindows[i])
1375 aScrollWindow.aWindows[i]->Invalidate();
1376 pColorConfig->SetColorValue(ColorConfigEntry(i), aColorEntry);
1377 break;
1379 } // for( sal_Int32 i = 0; i < ColorConfigEntryCount; i++ )
1380 sal_Int32 nExtCount = pExtColorConfig->GetComponentCount();
1381 sal_Int32 nCount = aScrollWindow.aCheckBoxes.size();
1382 sal_Int32 nPos = 0;
1383 i = ColorConfigEntryCount;
1384 for (sal_Int32 j = 0; j < nExtCount; ++j)
1386 ::rtl::OUString sComponentName = pExtColorConfig->GetComponentName(j);
1387 sal_Int32 nColorCount = pExtColorConfig->GetComponentColorCount(sComponentName);
1389 for( sal_Int32 k = 0; i < nCount && k < nColorCount; ++i ,++nPos,++k)
1391 if(pBox && aScrollWindow.aColorBoxes[i] == pBox)
1393 ExtendedColorConfigValue aColorEntry = pExtColorConfig->GetComponentColorConfigValue(sComponentName,k);
1394 Color aColor = pBox->GetSelectEntryColor(); // #i14869# no Color&, 'cause it's a ref to a temp object on the stack!
1395 aColorEntry.setColor(aColor.GetColor());
1396 if( !pBox->GetSelectEntryPos() ) // auto color
1398 aColorEntry.setColor(aColorEntry.getDefaultColor());
1399 aColor.SetColor(aColorEntry.getColor());
1401 if ( aScrollWindow.aWindows[i] )
1403 aScrollWindow.aWindows[i]->SetBackground(Wallpaper(aColor));
1404 aScrollWindow.aWindows[i]->Invalidate();
1406 pExtColorConfig->SetColorValue(sComponentName,aColorEntry);
1407 break;
1411 return 0;
1413 IMPL_LINK(ColorConfigCtrl_Impl, ControlFocusHdl, Control*, pCtrl)
1415 //determine whether a control is completely visible
1416 //and make it visible
1417 Point aCtrlPos(pCtrl->GetPosPixel());
1418 sal_Int32 nWinHeight = aScrollWindow.GetSizePixel().Height();
1419 if(0 != (GETFOCUS_TAB & pCtrl->GetGetFocusFlags() &&
1420 (aCtrlPos.Y() < 0 ||
1421 nWinHeight < aCtrlPos.Y() + aScrollWindow.aColorBoxes[0]->GetSizePixel().Height())))
1423 long nThumbPos = aVScroll.GetThumbPos();
1424 if(nWinHeight < aCtrlPos.Y() + aScrollWindow.aColorBoxes[0]->GetSizePixel().Height())
1426 //scroll down
1427 nThumbPos +=2;
1429 else
1431 //scroll up
1432 nThumbPos -= 2;
1433 if(nThumbPos < 0)
1434 nThumbPos = 0;
1436 aVScroll.SetThumbPos(nThumbPos);
1437 ScrollHdl(&aVScroll);
1439 return 0;
1441 /* -----------------------------25.03.2002 10:47------------------------------
1443 ---------------------------------------------------------------------------*/
1444 SvxColorOptionsTabPage::SvxColorOptionsTabPage(
1445 Window* pParent, const SfxItemSet& rCoreSet) :
1446 SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_COLORCONFIG ), rCoreSet ),
1447 aColorSchemeFL( this, SVX_RES( FL_COLORSCHEME ) ),
1448 aColorSchemeFT( this, SVX_RES( FT_COLORSCHEME ) ),
1449 aColorSchemeLB( this, SVX_RES( LB_COLORSCHEME ) ),
1450 aSaveSchemePB( this, SVX_RES( PB_SAVESCHEME) ),
1451 aDeleteSchemePB( this, SVX_RES( PB_DELETESCHEME ) ),
1452 aCustomColorsFL( this, SVX_RES( FL_CUSTOMCOLORS ) ),
1453 bFillItemSetCalled(FALSE),
1454 pColorConfig(0),
1455 pExtColorConfig(0),
1456 pColorConfigCT( new ColorConfigCtrl_Impl(this, SVX_RES( CT_COLORCONFIG ) ))
1458 FreeResource();
1459 aColorSchemeLB.SetSelectHdl(LINK(this, SvxColorOptionsTabPage, SchemeChangedHdl_Impl));
1460 Link aLk = LINK(this, SvxColorOptionsTabPage, SaveDeleteHdl_Impl );
1461 aSaveSchemePB.SetClickHdl(aLk);
1462 aDeleteSchemePB.SetClickHdl(aLk);
1464 /* -----------------------------25.03.2002 10:47------------------------------
1466 ---------------------------------------------------------------------------*/
1467 SvxColorOptionsTabPage::~SvxColorOptionsTabPage()
1469 //when the dialog is cancelled but the color scheme ListBox has been changed these
1470 //changes need to be undone
1471 if(!bFillItemSetCalled && aColorSchemeLB.GetSavedValue() != aColorSchemeLB.GetSelectEntryPos())
1473 rtl::OUString sOldScheme = aColorSchemeLB.GetEntry(aColorSchemeLB.GetSavedValue());
1474 if(sOldScheme.getLength())
1476 pColorConfig->SetCurrentSchemeName(sOldScheme);
1477 pExtColorConfig->SetCurrentSchemeName(sOldScheme);
1480 delete pColorConfigCT;
1481 pColorConfig->ClearModified();
1482 pColorConfig->EnableBroadcast();
1483 delete pColorConfig;
1484 pExtColorConfig->ClearModified();
1485 pExtColorConfig->EnableBroadcast();
1486 delete pExtColorConfig;
1488 /* -----------------------------25.03.2002 10:47------------------------------
1490 ---------------------------------------------------------------------------*/
1491 SfxTabPage* SvxColorOptionsTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1493 return ( new SvxColorOptionsTabPage( pParent, rAttrSet ) );
1495 /* -----------------------------25.03.2002 10:47------------------------------
1497 ---------------------------------------------------------------------------*/
1498 BOOL SvxColorOptionsTabPage::FillItemSet( SfxItemSet& )
1500 bFillItemSetCalled = TRUE;
1501 if(aColorSchemeLB.GetSavedValue() != aColorSchemeLB.GetSelectEntryPos())
1503 pColorConfig->SetModified();
1504 pExtColorConfig->SetModified();
1506 if(pColorConfig->IsModified())
1507 pColorConfig->Commit();
1508 if(pExtColorConfig->IsModified())
1509 pExtColorConfig->Commit();
1510 return TRUE;
1512 /* -----------------------------25.03.2002 10:47------------------------------
1514 ---------------------------------------------------------------------------*/
1515 void SvxColorOptionsTabPage::Reset( const SfxItemSet& )
1517 if(pColorConfig)
1519 pColorConfig->ClearModified();
1520 pColorConfig->DisableBroadcast();
1521 delete pColorConfig;
1523 pColorConfig = new EditableColorConfig;
1524 pColorConfigCT->SetConfig(*pColorConfig);
1526 if(pExtColorConfig)
1528 pExtColorConfig->ClearModified();
1529 pExtColorConfig->DisableBroadcast();
1530 delete pExtColorConfig;
1532 pExtColorConfig = new EditableExtendedColorConfig;
1533 pColorConfigCT->SetExtendedConfig(*pExtColorConfig);
1535 String sUser = GetUserData();
1536 //has to be called always to speed up accessibility tools
1537 pColorConfigCT->SetScrollPosition(sUser.ToInt32());
1538 aColorSchemeLB.Clear();
1539 uno::Sequence< ::rtl::OUString > aSchemes = pColorConfig->GetSchemeNames();
1540 const rtl::OUString* pSchemes = aSchemes.getConstArray();
1541 for(sal_Int32 i = 0; i < aSchemes.getLength(); i++)
1542 aColorSchemeLB.InsertEntry(pSchemes[i]);
1543 aColorSchemeLB.SelectEntry(pColorConfig->GetCurrentSchemeName());
1544 aColorSchemeLB.SaveValue();
1545 aDeleteSchemePB.Enable( aSchemes.getLength() > 1 );
1546 UpdateColorConfig();
1548 /* -----------------------------25.03.2002 10:47------------------------------
1550 ---------------------------------------------------------------------------*/
1551 int SvxColorOptionsTabPage::DeactivatePage( SfxItemSet* _pSet )
1553 if ( _pSet )
1554 FillItemSet( *_pSet );
1555 return( LEAVE_PAGE );
1557 /* -----------------------------25.03.2002 15:32------------------------------
1559 ---------------------------------------------------------------------------*/
1560 void SvxColorOptionsTabPage::UpdateColorConfig()
1562 //update the color config control
1563 pColorConfigCT->Update();
1565 /* -----------------------------25.03.2002 15:30------------------------------
1567 ---------------------------------------------------------------------------*/
1568 IMPL_LINK(SvxColorOptionsTabPage, SchemeChangedHdl_Impl, ListBox*, pBox)
1570 pColorConfig->LoadScheme(pBox->GetSelectEntry());
1571 pExtColorConfig->LoadScheme(pBox->GetSelectEntry());
1572 UpdateColorConfig();
1573 return 0;
1575 /* -----------------------------09.04.2002 15:21------------------------------
1577 ---------------------------------------------------------------------------*/
1578 IMPL_LINK(SvxColorOptionsTabPage, SaveDeleteHdl_Impl, PushButton*, pButton )
1580 if(&aSaveSchemePB == pButton)
1582 String sName;
1583 //CHINA001 SvxNameDialog aNameDlg(pButton,
1584 //CHINA001 sName,
1585 //CHINA001 String(SVX_RES(RID_SVXSTR_COLOR_CONFIG_SAVE2)));
1586 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1587 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
1588 AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( pButton,
1589 sName, String(SVX_RES(RID_SVXSTR_COLOR_CONFIG_SAVE2)), RID_SVXDLG_NAME );
1590 DBG_ASSERT(aNameDlg, "Dialogdiet fail!");//CHINA001
1591 aNameDlg->SetCheckNameHdl( LINK(this, SvxColorOptionsTabPage, CheckNameHdl_Impl));
1592 aNameDlg->SetText(String(SVX_RES(RID_SVXSTR_COLOR_CONFIG_SAVE1)));
1593 aNameDlg->SetHelpId(HID_OPTIONS_COLORCONFIG_SAVE_SCHEME);
1594 aNameDlg->SetEditHelpId(HID_OPTIONS_COLORCONFIG_NAME_SCHEME);
1595 aNameDlg->SetCheckNameHdl( LINK(this, SvxColorOptionsTabPage, CheckNameHdl_Impl));
1596 if(RET_OK == aNameDlg->Execute()) //CHINA001 if(RET_OK == aNameDlg.Execute())
1598 aNameDlg->GetName(sName); //CHINA001 aNameDlg.GetName(sName);
1599 pColorConfig->AddScheme(sName);
1600 pExtColorConfig->AddScheme(sName);
1601 aColorSchemeLB.InsertEntry(sName);
1602 aColorSchemeLB.SelectEntry(sName);
1603 aColorSchemeLB.GetSelectHdl().Call(&aColorSchemeLB);
1605 delete aNameDlg; //add by CHINA001
1607 else
1609 DBG_ASSERT(aColorSchemeLB.GetEntryCount() > 1, "don't delete the last scheme");
1610 QueryBox aQuery(pButton, SVX_RES(RID_SVXQB_DELETE_COLOR_CONFIG));
1611 aQuery.SetText(String(SVX_RES(RID_SVXSTR_COLOR_CONFIG_DELETE)));
1612 if(RET_YES == aQuery.Execute())
1614 rtl::OUString sDeleteScheme(aColorSchemeLB.GetSelectEntry());
1615 aColorSchemeLB.RemoveEntry(aColorSchemeLB.GetSelectEntryPos());
1616 aColorSchemeLB.SelectEntryPos(0);
1617 aColorSchemeLB.GetSelectHdl().Call(&aColorSchemeLB);
1618 //first select the new scheme and then delete the old one
1619 pColorConfig->DeleteScheme(sDeleteScheme);
1620 pExtColorConfig->DeleteScheme(sDeleteScheme);
1623 aDeleteSchemePB.Enable( aColorSchemeLB.GetEntryCount() > 1 );
1624 return 0;
1626 /* -----------------------------09.04.2002 15:47------------------------------
1628 ---------------------------------------------------------------------------*/
1629 IMPL_LINK(SvxColorOptionsTabPage, CheckNameHdl_Impl, AbstractSvxNameDialog*, pDialog )
1631 String sName;
1632 pDialog->GetName(sName);
1633 return sName.Len() && LISTBOX_ENTRY_NOTFOUND == aColorSchemeLB.GetEntryPos( sName );
1635 /* -----------------------------25.04.2002 15:12------------------------------
1637 ---------------------------------------------------------------------------*/
1638 void SvxColorOptionsTabPage::FillUserData()
1640 SetUserData(String::CreateFromInt32(pColorConfigCT->GetScrollPosition()));