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