1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 #include <tools/shl.hxx>
27 #include <svtools/ctrltool.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/wrkwin.hxx>
30 #include <svtools/fontsubstconfig.hxx>
31 #include <unotools/sourceviewconfig.hxx>
32 #include "fontsubs.hrc"
33 #include "fontsubs.hxx"
34 #include <dialmgr.hxx>
35 #include "helpid.hrc"
36 #include <cuires.hrc>
37
38 /*********************************************************************/
39 /* */
40 /* TabPage Fontersetzung */
41 /* */
42 /*********************************************************************/
43
44 #define CBCOL_FIRST 0
45 #define CBCOL_SECOND 1
46 #define CBCOL_BOTH 2
47
SvxFontSubstTabPage(Window * pParent,const SfxItemSet & rSet)48 SvxFontSubstTabPage::SvxFontSubstTabPage( Window* pParent,
49 const SfxItemSet& rSet ) :
50 SfxTabPage(pParent, CUI_RES(RID_SVX_FONT_SUBSTITUTION), rSet),
51 aUseTableCB (this, CUI_RES(CB_USETABLE)),
52 aFont1FT (this, CUI_RES(FT_FONT1)),
53 aFont1CB (this, CUI_RES(CB_FONT1)),
54 aFont2FT (this, CUI_RES(FT_FONT2)),
55 aFont2CB (this, CUI_RES(CB_FONT2)),
56 aNewDelTBX (this, CUI_RES(TBX_SUBSTNEWDEL)),
57 aCheckLB (this, CUI_RES(CLB_SUBSTITUTES)),
58
59 aSourceViewFontsFL (this, CUI_RES(FL_SOURCEVIEW )),
60 aFontNameFT (this, CUI_RES(FT_FONTNAME )),
61 aFontNameLB (this, CUI_RES(LB_FONTNAME )),
62 aNonPropFontsOnlyCB(this, CUI_RES(CB_NONPROP )),
63 aFontHeightFT (this, CUI_RES(FT_FONTHEIGHT )),
64 aFontHeightLB (this, CUI_RES(LB_FONTHEIGHT )),
65
66 aImageList (CUI_RES(IL_ICON)),
67
68 sAutomatic (CUI_RES( STR_AUTOMATIC )),
69 pConfig(new SvtFontSubstConfig),
70 pSourceViewConfig(new utl::SourceViewConfig),
71
72 sHeader1 (CUI_RES( STR_HEADER1 )),
73 sHeader2 (CUI_RES( STR_HEADER2 )),
74 sHeader3 (CUI_RES( STR_HEADER3 )),
75 sHeader4 (CUI_RES( STR_HEADER4 )),
76
77 sFontGroup ("FontSubstitution"),
78 pCheckButtonData(0)
79 {
80 FreeResource();
81
82 aTextColor = aCheckLB.GetTextColor();
83
84 for(sal_uInt16 k = 0; k < aNewDelTBX.GetItemCount(); k++)
85 aNewDelTBX.SetItemImage(aNewDelTBX.GetItemId(k),
86 aImageList.GetImage(aNewDelTBX.GetItemId(k)));
87
88 aNewDelTBX.SetSizePixel( aNewDelTBX.CalcWindowSizePixel() );
89
90 long nDelta = ( aFont1CB.GetSizePixel().Height() -
91 aNewDelTBX.GetSizePixel().Height() ) / 2;
92 Point aNewPnt = aNewDelTBX.GetPosPixel();
93 aNewPnt.Y() += nDelta;
94 aNewDelTBX.SetPosPixel( aNewPnt );
95
96 aCheckLB.SetHelpId(HID_OFA_FONT_SUBST_CLB);
97 aCheckLB.SetStyle(aCheckLB.GetStyle()|WB_HSCROLL|WB_VSCROLL);
98 aCheckLB.SetSelectionMode(MULTIPLE_SELECTION);
99 aCheckLB.SortByCol(2);
100
101 Link aLink(LINK(this, SvxFontSubstTabPage, SelectHdl));
102
103 aCheckLB.SetSelectHdl(aLink);
104 aUseTableCB.SetClickHdl(aLink);
105 aFont1CB.SetSelectHdl(aLink);
106 aFont1CB.SetModifyHdl(aLink);
107 aFont2CB.SetSelectHdl(aLink);
108 aFont2CB.SetModifyHdl(aLink);
109 aNewDelTBX.SetClickHdl(aLink);
110
111 aNonPropFontsOnlyCB.SetClickHdl(LINK(this, SvxFontSubstTabPage, NonPropFontsHdl));
112
113 static long aStaticTabs[] = { 4, 0, 0, 0, 0 };
114 long nW1 = GetTextWidth( sHeader1 );
115 long nW2 = GetTextWidth( sHeader2 );
116 long nMax = Max( nW1, nW2 ) + 6; // width of the longest header + a little offset
117 long nMin = aFontNameFT.LogicToPixel( Size( 30, 0 ), MAP_APPFONT ).Width();
118 nMax = Max( nMax, nMin );
119 const long nDoubleMax = 2*nMax;
120 const long nRest = aCheckLB.GetSizePixel().Width() - nDoubleMax;
121 aStaticTabs[2] = nMax;
122 aStaticTabs[3] = nDoubleMax;
123 aStaticTabs[4] = nDoubleMax + nRest/2;
124 aCheckLB.SvxSimpleTable::SetTabs( aStaticTabs, MAP_PIXEL );
125
126 String sHeader(sHeader1);
127 String sTab(String::CreateFromAscii("\t"));
128 String sTabSpace(String::CreateFromAscii("\t "));
129 sHeader += sTab;
130 sHeader += sHeader2;
131 sHeader += sTabSpace;
132 sHeader += sHeader3;
133 sHeader += sTabSpace;
134 sHeader += sHeader4;
135 // sHeader += sTabSpace;
136 aCheckLB.InsertHeaderEntry(sHeader);
137
138 HeaderBar* pBar = aCheckLB.GetTheHeaderBar();
139
140 HeaderBarItemBits nBits = pBar->GetItemBits(1) | HIB_FIXEDPOS | HIB_FIXED;
141 nBits &= ~HIB_CLICKABLE;
142 pBar->SetItemBits(1, nBits);
143 pBar->SetItemBits(2, nBits);
144
145 sal_uInt16 nHeight;
146 for(nHeight = 6; nHeight <= 16; nHeight++)
147 aFontHeightLB.InsertEntry(String::CreateFromInt32(nHeight));
148 for(nHeight = 18; nHeight <= 28; nHeight+= 2)
149 aFontHeightLB.InsertEntry(String::CreateFromInt32(nHeight));
150 for(nHeight = 32; nHeight <= 48; nHeight+= 4)
151 aFontHeightLB.InsertEntry(String::CreateFromInt32(nHeight));
152 for(nHeight = 54; nHeight <= 72; nHeight+= 6)
153 aFontHeightLB.InsertEntry(String::CreateFromInt32(nHeight));
154 for(nHeight = 80; nHeight <= 96; nHeight+= 8)
155 aFontHeightLB.InsertEntry(String::CreateFromInt32(nHeight));
156 }
157
158 /*********************************************************************/
159 /* */
160 /*********************************************************************/
161
CreateEntry(String & rFont1,String & rFont2)162 SvLBoxEntry* SvxFontSubstTabPage::CreateEntry(String& rFont1, String& rFont2)
163 {
164 SvLBoxEntry* pEntry = new SvLBoxEntry;
165
166 if( !pCheckButtonData )
167 pCheckButtonData = new SvLBoxButtonData( &aCheckLB );
168
169 pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0)); // Sonst Puff!
170
171 pEntry->AddItem( new SvLBoxButton( pEntry,
172 SvLBoxButtonKind_enabledCheckbox, 0,
173 pCheckButtonData ) );
174 pEntry->AddItem( new SvLBoxButton( pEntry,
175 SvLBoxButtonKind_enabledCheckbox, 0,
176 pCheckButtonData ) );
177
178 pEntry->AddItem( new SvLBoxString( pEntry, 0, rFont1 ) );
179 pEntry->AddItem( new SvLBoxString( pEntry, 0, rFont2 ) );
180
181 return pEntry;
182 }
183
184 /*********************************************************************/
185 /* */
186 /*********************************************************************/
187
188
~SvxFontSubstTabPage()189 SvxFontSubstTabPage::~SvxFontSubstTabPage()
190 {
191 delete pCheckButtonData;
192 delete pConfig;
193 delete pSourceViewConfig;
194 }
195
196 /*********************************************************************/
197 /* */
198 /*********************************************************************/
199
Create(Window * pParent,const SfxItemSet & rAttrSet)200 SfxTabPage* SvxFontSubstTabPage::Create( Window* pParent,
201 const SfxItemSet& rAttrSet)
202 {
203 return new SvxFontSubstTabPage(pParent, rAttrSet);
204 }
205
206 /*********************************************************************/
207 /* */
208 /*********************************************************************/
209
FillItemSet(SfxItemSet &)210 sal_Bool SvxFontSubstTabPage::FillItemSet( SfxItemSet& )
211 {
212 pConfig->ClearSubstitutions();// remove all entries
213
214 pConfig->Enable(aUseTableCB.IsChecked());
215
216 SvLBoxEntry* pEntry = aCheckLB.First();
217
218 while (pEntry)
219 {
220 SubstitutionStruct aAdd;
221 aAdd.sFont = aCheckLB.GetEntryText(pEntry, 0);
222 aAdd.sReplaceBy = aCheckLB.GetEntryText(pEntry, 1);
223 aAdd.bReplaceAlways = aCheckLB.IsChecked(pEntry, 0);
224 aAdd.bReplaceOnScreenOnly = aCheckLB.IsChecked(pEntry, 1);
225 pConfig->AddSubstitution(aAdd);
226 pEntry = aCheckLB.Next(pEntry);
227 }
228 if(pConfig->IsModified())
229 pConfig->Commit();
230 pConfig->Apply();
231 if(aFontHeightLB.GetSavedValue() != aFontHeightLB.GetSelectEntryPos())
232 pSourceViewConfig->SetFontHeight((sal_Int16)aFontHeightLB.GetSelectEntry().ToInt32());
233 if(aNonPropFontsOnlyCB.GetSavedValue() != aNonPropFontsOnlyCB.IsChecked())
234 pSourceViewConfig->SetShowProportionalFontsOnly(aNonPropFontsOnlyCB.IsChecked());
235 //font name changes cannot be detected by saved values
236 String sFontName;
237 if(aFontNameLB.GetSelectEntryPos())
238 sFontName = aFontNameLB.GetSelectEntry();
239 pSourceViewConfig->SetFontName(sFontName);
240
241 return sal_False;
242 }
243
244 /*********************************************************************/
245 /* */
246 /*********************************************************************/
247
248
Reset(const SfxItemSet &)249 void SvxFontSubstTabPage::Reset( const SfxItemSet& )
250 {
251 aCheckLB.SetUpdateMode(sal_False);
252 aCheckLB.Clear();
253
254 FontList aFntLst( Application::GetDefaultDevice() );
255 aFont1CB.Fill( &aFntLst );
256 aFont2CB.Fill( &aFntLst );
257
258 sal_Int32 nCount = pConfig->SubstitutionCount();
259 if (nCount)
260 aUseTableCB.Check(pConfig->IsEnabled());
261
262 for (sal_Int32 i = 0; i < nCount; i++)
263 {
264 const SubstitutionStruct* pSubs = pConfig->GetSubstitution(i);
265 String aTmpStr1(pSubs->sFont);
266 String aTmpStr2(pSubs->sReplaceBy);
267 SvLBoxEntry* pEntry = CreateEntry(aTmpStr1, aTmpStr2);
268 aCheckLB.Insert(pEntry);
269 aCheckLB.CheckEntry(pEntry, 0, pSubs->bReplaceAlways);
270 aCheckLB.CheckEntry(pEntry, 1, pSubs->bReplaceOnScreenOnly);
271 }
272
273 CheckEnable();
274 aCheckLB.SetUpdateMode(sal_True);
275
276 //fill font name box first
277 aNonPropFontsOnlyCB.Check(pSourceViewConfig->IsShowProportionalFontsOnly());
278 NonPropFontsHdl(&aNonPropFontsOnlyCB);
279 String sFontName(pSourceViewConfig->GetFontName());
280 if(sFontName.Len())
281 aFontNameLB.SelectEntry(sFontName);
282 else
283 aFontNameLB.SelectEntryPos(0);
284 short nFontHeight = pSourceViewConfig->GetFontHeight();
285 aFontHeightLB.SelectEntry(String::CreateFromInt32(nFontHeight));
286 aNonPropFontsOnlyCB.SaveValue();
287 aFontHeightLB.SaveValue();
288 }
289
290 /*********************************************************************/
291 /* */
292 /*********************************************************************/
293
IMPL_LINK(SvxFontSubstTabPage,SelectHdl,Window *,pWin)294 IMPL_LINK(SvxFontSubstTabPage, SelectHdl, Window*, pWin)
295 {
296 if (pWin == &aNewDelTBX)
297 {
298 SvLBoxEntry* pEntry;
299 // nCol ist behaemmerterweise die nCol'te Textspalte, werden nicht gezaehlt!
300 // Daher als Spalte "0".
301 sal_uLong nPos = aCheckLB.GetEntryPos(aFont1CB.GetText(), 0);
302
303 switch (aNewDelTBX.GetCurItemId())
304 {
305 case BT_SUBSTAPPLY:
306 {
307 if (nPos != 0xffffffff)
308 {
309 // Eintrag aendern
310 aCheckLB.SetEntryText(aFont2CB.GetText(), nPos, 1);
311 pEntry = aCheckLB.GetEntry(nPos);
312 }
313 else
314 {
315 // Neuer Eintrag
316 String sFont1 = aFont1CB.GetText();
317 String sFont2 = aFont2CB.GetText();
318
319 pEntry = CreateEntry(sFont1, sFont2);
320 aCheckLB.Insert(pEntry);
321 }
322 aCheckLB.SelectAll(sal_False);
323 aCheckLB.Select(pEntry);
324 }
325 break;
326
327 case BT_SUBSTDELETE:
328 {
329 if (nPos != 0xffffffff)
330 {
331 pEntry = aCheckLB.FirstSelected();
332 while (pEntry)
333 {
334 SvLBoxEntry* pDelEntry = pEntry;
335 pEntry = aCheckLB.NextSelected(pEntry);
336 aCheckLB.RemoveEntry(pDelEntry);
337 }
338 }
339 }
340 break;
341 }
342 }
343
344 if (pWin == &aCheckLB)
345 {
346 SvLBoxEntry* pEntry = aCheckLB.FirstSelected();
347
348 if (aCheckLB.NextSelected(pEntry) == 0)
349 {
350 aFont1CB.SetText(aCheckLB.GetEntryText(pEntry, 0));
351 aFont2CB.SetText(aCheckLB.GetEntryText(pEntry, 1));
352 }
353 }
354
355 if (pWin == &aFont1CB)
356 {
357 sal_uLong nPos = aCheckLB.GetEntryPos(aFont1CB.GetText(), 0);
358
359 if (nPos != 0xffffffff)
360 {
361 SvLBoxEntry* pEntry = aCheckLB.GetEntry(nPos);
362
363 if (pEntry != aCheckLB.FirstSelected())
364 {
365 aCheckLB.SelectAll(sal_False);
366 aCheckLB.Select(pEntry);
367 }
368 }
369 }
370
371 CheckEnable();
372
373 return 0;
374 }
375 /* -----------------------------29.08.2002 11:47------------------------------
376
377 ---------------------------------------------------------------------------*/
IMPL_LINK(SvxFontSubstTabPage,NonPropFontsHdl,CheckBox *,pBox)378 IMPL_LINK(SvxFontSubstTabPage, NonPropFontsHdl, CheckBox*, pBox)
379 {
380 String sFontName = aFontNameLB.GetSelectEntry();
381 sal_Bool bNonPropOnly = pBox->IsChecked();
382 aFontNameLB.Clear();
383 FontList aFntLst( Application::GetDefaultDevice() );
384 aFontNameLB.InsertEntry(sAutomatic);
385 sal_uInt16 nFontCount = aFntLst.GetFontNameCount();
386 for(sal_uInt16 nFont = 0; nFont < nFontCount; nFont++)
387 {
388 const FontInfo& rInfo = aFntLst.GetFontName( nFont );
389 if(!bNonPropOnly || rInfo.GetPitch() == PITCH_FIXED)
390 aFontNameLB.InsertEntry(rInfo.GetName());
391 }
392 aFontNameLB.SelectEntry(sFontName);
393 return 0;
394 }
395 /*********************************************************************/
396 /* */
397 /*********************************************************************/
398
CheckEnable()399 void SvxFontSubstTabPage::CheckEnable()
400 {
401 sal_Bool bEnableAll = aUseTableCB.IsChecked();
402
403 if (bEnableAll)
404 {
405 sal_Bool bApply, bDelete;
406
407 SvLBoxEntry* pEntry = aCheckLB.FirstSelected();
408
409 String sEntry = aFont1CB.GetText();
410 sEntry += '\t';
411 sEntry += aFont2CB.GetText();
412
413 /* if (!aFont1CB.GetText().Len() || !aFont2CB.GetText().Len() ||
414 aFont1CB.GetText() == aFont2CB.GetText() ||
415 aCheckLB.GetEntryPos(sEntry) != 0xffffffff ||
416 (pEntry != 0 && aCheckLB.NextSelected(pEntry) != 0))
417 bApply = sal_False;
418 else
419 bApply = sal_True;*/
420
421 // Wegen OS/2-Optimierungsfehler (Bug #56267) etwas umstaendlicher:
422 if (!aFont1CB.GetText().Len() || !aFont2CB.GetText().Len())
423 bApply = sal_False;
424 else if(aFont1CB.GetText() == aFont2CB.GetText())
425 bApply = sal_False;
426 else if(aCheckLB.GetEntryPos(sEntry) != 0xffffffff)
427 bApply = sal_False;
428 else if(pEntry != 0 && aCheckLB.NextSelected(pEntry) != 0)
429 bApply = sal_False;
430 else
431 bApply = sal_True;
432
433 bDelete = pEntry != 0;
434
435 aNewDelTBX.EnableItem(BT_SUBSTAPPLY, bApply);
436 aNewDelTBX.EnableItem(BT_SUBSTDELETE, bDelete);
437 }
438
439 if (bEnableAll)
440 {
441 if (!aCheckLB.IsEnabled())
442 {
443 aCheckLB.EnableTable();
444 aCheckLB.SetTextColor(aTextColor);
445 aCheckLB.Invalidate();
446 SelectHdl(&aFont1CB);
447 }
448 }
449 else
450 {
451 if (aCheckLB.IsEnabled())
452 {
453 aCheckLB.DisableTable();
454 aCheckLB.SetTextColor(Color(COL_GRAY));
455 aCheckLB.Invalidate();
456 aCheckLB.SelectAll(sal_False);
457 }
458 }
459 aNewDelTBX.Enable(bEnableAll);
460 aFont1FT.Enable(bEnableAll);
461 aFont1CB.Enable(bEnableAll);
462 aFont2FT.Enable(bEnableAll);
463 aFont2CB.Enable(bEnableAll);
464 }
465
466 /*********************************************************************/
467 /* */
468 /*********************************************************************/
469
SetTabs()470 void SvxFontSubstCheckListBox::SetTabs()
471 {
472 SvxSimpleTable::SetTabs();
473 sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT|SV_LBOXTAB_ADJUST_LEFT|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_ADJUST_NUMERIC|SV_LBOXTAB_FORCE;
474
475 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(1);
476 pTab->nFlags &= ~nAdjust;
477 pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE;
478
479 pTab = (SvLBoxTab*)aTabs.GetObject(2);
480 pTab->nFlags &= ~nAdjust;
481 pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE;
482 }
483 /* -----------------------------22.05.2002 11:06------------------------------
484
485 ---------------------------------------------------------------------------*/
KeyInput(const KeyEvent & rKEvt)486 void SvxFontSubstCheckListBox::KeyInput( const KeyEvent& rKEvt )
487 {
488 if(!rKEvt.GetKeyCode().GetModifier() &&
489 KEY_SPACE == rKEvt.GetKeyCode().GetCode())
490 {
491 sal_uLong nSelPos = GetModel()->GetAbsPos(GetCurEntry());
492 sal_uInt16 nCol = GetCurrentTabPos() - 1;
493 if ( nCol < 2 )
494 {
495 CheckEntryPos( nSelPos, nCol, !IsChecked( nSelPos, nCol ) );
496 CallImplEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)GetEntry( nSelPos ) );
497 }
498 else
499 {
500 sal_uInt16 nCheck = IsChecked(nSelPos, 1) ? 1 : 0;
501 if(IsChecked(nSelPos, 0))
502 nCheck += 2;
503 nCheck--;
504 nCheck &= 3;
505 CheckEntryPos(nSelPos, 1, 0 != (nCheck & 1));
506 CheckEntryPos(nSelPos, 0, 0 != (nCheck & 2));
507 }
508 }
509 else
510 SvxSimpleTable::KeyInput(rKEvt);
511 }
512
513 /*********************************************************************/
514 /* */
515 /*********************************************************************/
516
CheckEntryPos(sal_uLong nPos,sal_uInt16 nCol,sal_Bool bChecked)517 void SvxFontSubstCheckListBox::CheckEntryPos(sal_uLong nPos, sal_uInt16 nCol, sal_Bool bChecked)
518 {
519 if ( nPos < GetEntryCount() )
520 SetCheckButtonState(
521 GetEntry(nPos),
522 nCol,
523 bChecked ? SvButtonState( SV_BUTTON_CHECKED ) :
524 SvButtonState( SV_BUTTON_UNCHECKED ) );
525 }
526
527 /*********************************************************************/
528 /* */
529 /*********************************************************************/
530
CheckEntry(SvLBoxEntry * pEntry,sal_uInt16 nCol,sal_Bool bChecked)531 void SvxFontSubstCheckListBox::CheckEntry(SvLBoxEntry* pEntry, sal_uInt16 nCol, sal_Bool bChecked)
532 {
533 if ( pEntry )
534 SetCheckButtonState(
535 pEntry,
536 nCol,
537 bChecked ? SvButtonState( SV_BUTTON_CHECKED ) :
538 SvButtonState( SV_BUTTON_UNCHECKED ) );
539 }
540
541 /*********************************************************************/
542 /* */
543 /*********************************************************************/
544
IsChecked(sal_uLong nPos,sal_uInt16 nCol)545 sal_Bool SvxFontSubstCheckListBox::IsChecked(sal_uLong nPos, sal_uInt16 nCol)
546 {
547 return GetCheckButtonState( GetEntry(nPos), nCol ) == SV_BUTTON_CHECKED;
548 }
549
550 /*********************************************************************/
551 /* */
552 /*********************************************************************/
553
IsChecked(SvLBoxEntry * pEntry,sal_uInt16 nCol)554 sal_Bool SvxFontSubstCheckListBox::IsChecked(SvLBoxEntry* pEntry, sal_uInt16 nCol)
555 {
556 return GetCheckButtonState( pEntry, nCol ) == SV_BUTTON_CHECKED;
557 }
558
559 /*********************************************************************/
560 /* */
561 /*********************************************************************/
562
SetCheckButtonState(SvLBoxEntry * pEntry,sal_uInt16 nCol,SvButtonState eState)563 void SvxFontSubstCheckListBox::SetCheckButtonState( SvLBoxEntry* pEntry, sal_uInt16 nCol, SvButtonState eState)
564 {
565 SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetItem(nCol + 1));
566
567 DBG_ASSERT(pItem,"SetCheckButton:Item not found");
568 if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON)
569 {
570 switch( eState )
571 {
572 case SV_BUTTON_CHECKED:
573 pItem->SetStateChecked();
574 break;
575
576 case SV_BUTTON_UNCHECKED:
577 pItem->SetStateUnchecked();
578 break;
579
580 case SV_BUTTON_TRISTATE:
581 pItem->SetStateTristate();
582 break;
583 }
584 InvalidateEntry( pEntry );
585 }
586 }
587
588 /*********************************************************************/
589 /* */
590 /*********************************************************************/
591
GetCheckButtonState(SvLBoxEntry * pEntry,sal_uInt16 nCol) const592 SvButtonState SvxFontSubstCheckListBox::GetCheckButtonState( SvLBoxEntry* pEntry, sal_uInt16 nCol ) const
593 {
594 SvButtonState eState = SV_BUTTON_UNCHECKED;
595 SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetItem(nCol + 1));
596 DBG_ASSERT(pItem,"GetChButnState:Item not found");
597
598 if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON)
599 {
600 sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
601 eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
602 }
603
604 return eState;
605 }
606
607
608