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