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