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 <vcl/msgbox.hxx>
30 : : #include <vcl/field.hxx>
31 : : #include <vcl/keycodes.hxx>
32 : : #include <sot/exchange.hxx>
33 : : #include <svtools/transfer.hxx>
34 : : #include <unotools/syslocale.hxx>
35 : : #include <sfx2/objsh.hxx>
36 : : #include <sfx2/viewsh.hxx>
37 : : #include <unotools/charclass.hxx>
38 : : #include <unotools/collatorwrapper.hxx>
39 : : #include <com/sun/star/i18n/CollatorOptions.hpp>
40 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 : : #include <comphelper/processfactory.hxx>
42 : : #include <comphelper/string.hxx>
43 : : #include <vcl/svapp.hxx>
44 : : #include <sfx2/module.hxx>
45 : : #include <sfx2/request.hxx>
46 : : #include <sfx2/sfxsids.hrc>
47 : : #include <svl/eitem.hxx>
48 : : #include <svl/languageoptions.hxx>
49 : : #include <svx/SmartTagMgr.hxx>
50 : : #include <com/sun/star/smarttags/XSmartTagRecognizer.hpp>
51 : : #include <com/sun/star/smarttags/XSmartTagAction.hpp>
52 : : #include <rtl/strbuf.hxx>
53 : :
54 : : #define _OFA_AUTOCDLG_CXX
55 : : #include "autocdlg.hxx"
56 : : #include "autocdlg.hrc"
57 : : #include "helpid.hrc"
58 : : #include <editeng/acorrcfg.hxx>
59 : : #include <editeng/svxacorr.hxx>
60 : : #include "cuicharmap.hxx"
61 : : #include <editeng/unolingu.hxx>
62 : : #include <dialmgr.hxx>
63 : : #include <svx/svxids.hrc> // SID_OPEN_SMARTTAGSOPTIONS
64 : :
65 : : static LanguageType eLastDialogLanguage = LANGUAGE_SYSTEM;
66 : :
67 : : using namespace ::com::sun::star::util;
68 : : using namespace ::com::sun::star;
69 : : using namespace ::rtl;
70 : :
71 : : static ::com::sun::star::uno::Reference<
72 : 0 : ::com::sun::star::lang::XMultiServiceFactory >& GetProcessFact()
73 : : {
74 : : static ::com::sun::star::uno::Reference<
75 : : ::com::sun::star::lang::XMultiServiceFactory > xMSF =
76 [ # # ][ # # ]: 0 : ::comphelper::getProcessServiceFactory();
[ # # ][ # # ]
77 : 0 : return xMSF;
78 : : }
79 : :
80 : 0 : OfaAutoCorrDlg::OfaAutoCorrDlg(Window* pParent, const SfxItemSet* _pSet ) :
81 : 0 : SfxTabDialog(pParent, CUI_RES( RID_OFA_AUTOCORR_DLG ), _pSet),
82 [ # # ]: 0 : aLanguageFT( this, CUI_RES(FT_LANG )),
83 [ # # ][ # # ]: 0 : aLanguageLB( this, CUI_RES(LB_LANG ))
[ # # ][ # # ]
84 : : {
85 : 0 : sal_Bool bShowSWOptions = sal_False;
86 : 0 : sal_Bool bOpenSmartTagOptions = sal_False;
87 : :
88 [ # # ]: 0 : if ( _pSet )
89 : : {
90 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( _pSet, pItem, SfxBoolItem, SID_AUTO_CORRECT_DLG, sal_False );
91 [ # # ][ # # ]: 0 : if ( pItem && pItem->GetValue() )
[ # # ]
92 : 0 : bShowSWOptions = sal_True;
93 : :
94 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( _pSet, pItem2, SfxBoolItem, SID_OPEN_SMARTTAGOPTIONS, sal_False );
95 [ # # ][ # # ]: 0 : if ( pItem2 && pItem2->GetValue() )
[ # # ]
96 : 0 : bOpenSmartTagOptions = sal_True;
97 : : }
98 : :
99 [ # # ]: 0 : aLanguageFT.SetZOrder(0, WINDOW_ZORDER_FIRST);
100 [ # # ]: 0 : aLanguageLB.SetZOrder(&aLanguageFT, WINDOW_ZORDER_BEHIND);
101 [ # # ]: 0 : aLanguageLB.SetHelpId(HID_AUTOCORR_LANGUAGE);
102 [ # # ]: 0 : FreeResource();
103 : :
104 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_AUTOCORR_OPTIONS, OfaAutocorrOptionsPage::Create, 0);
105 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_AUTOFMT_APPLY, OfaSwAutoFmtOptionsPage::Create, 0);
106 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_AUTOCOMPLETE_OPTIONS, OfaAutoCompleteTabPage::Create, 0);
107 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS, OfaSmartTagOptionsTabPage::Create, 0);
108 : :
109 [ # # ]: 0 : if (!bShowSWOptions)
110 : : {
111 [ # # ]: 0 : RemoveTabPage(RID_OFAPAGE_AUTOFMT_APPLY);
112 [ # # ]: 0 : RemoveTabPage(RID_OFAPAGE_AUTOCOMPLETE_OPTIONS);
113 [ # # ]: 0 : RemoveTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS);
114 : : }
115 : : else
116 : : {
117 : : // remove smart tag tab page if no extensions are installed
118 [ # # ]: 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
119 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
120 [ # # ][ # # ]: 0 : if ( !pOpt || !pOpt->pSmartTagMgr || 0 == pOpt->pSmartTagMgr->NumberOfRecognizers() )
[ # # ][ # # ]
121 [ # # ]: 0 : RemoveTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS);
122 : :
123 [ # # ]: 0 : RemoveTabPage(RID_OFAPAGE_AUTOCORR_OPTIONS);
124 : : }
125 : :
126 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_AUTOCORR_REPLACE, OfaAutocorrReplacePage::Create, 0);
127 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_AUTOCORR_EXCEPT, OfaAutocorrExceptPage::Create, 0);
128 [ # # ]: 0 : AddTabPage(RID_OFAPAGE_AUTOCORR_QUOTE, OfaQuoteTabPage::Create, 0);
129 : :
130 : : // initialize languages
131 : : //! LANGUAGE_NONE is displayed as '[All]' and the LanguageType
132 : : //! will be set to LANGUAGE_DONTKNOW
133 : 0 : sal_Int16 nLangList = LANG_LIST_WESTERN;
134 : :
135 [ # # ][ # # ]: 0 : if( SvtLanguageOptions().IsCTLFontEnabled() )
[ # # ][ # # ]
136 : 0 : nLangList |= LANG_LIST_CTL;
137 [ # # ]: 0 : aLanguageLB.SetLanguageList( nLangList, sal_True, sal_True );
138 [ # # ]: 0 : aLanguageLB.SelectLanguage( LANGUAGE_NONE );
139 [ # # ]: 0 : sal_uInt16 nPos = aLanguageLB.GetSelectEntryPos();
140 : : DBG_ASSERT( LISTBOX_ENTRY_NOTFOUND != nPos, "listbox entry missing" );
141 [ # # ]: 0 : aLanguageLB.SetEntryData( nPos, (void*)(long) LANGUAGE_DONTKNOW );
142 : :
143 : : // Initialisierung funktionier fuer static nicht unter Linux - deswegen hier
144 [ # # ]: 0 : if( LANGUAGE_SYSTEM == eLastDialogLanguage )
145 [ # # ][ # # ]: 0 : eLastDialogLanguage = Application::GetSettings().GetLanguage();
146 : :
147 : 0 : LanguageType nSelectLang = LANGUAGE_DONTKNOW;
148 [ # # ]: 0 : nPos = aLanguageLB.GetEntryPos( (void*)(long) eLastDialogLanguage );
149 [ # # ]: 0 : if (LISTBOX_ENTRY_NOTFOUND != nPos)
150 : 0 : nSelectLang = eLastDialogLanguage;
151 [ # # ]: 0 : aLanguageLB.SelectLanguage( nSelectLang );
152 : :
153 [ # # ]: 0 : aLanguageLB.SetSelectHdl(LINK(this, OfaAutoCorrDlg, SelectLanguageHdl));
154 : :
155 [ # # ]: 0 : Size aMinSize(aLanguageFT.CalcMinimumSize());
156 : : //reserve some extra space for CJK accelerators that are possible inserted
157 : : //later (like '(A)')
158 [ # # ]: 0 : aLanguageFT.SetPosSizePixel( 0, 0, aMinSize.Width() + 20, 0, WINDOW_POSSIZE_WIDTH );
159 : :
160 [ # # ]: 0 : if ( bOpenSmartTagOptions )
161 : 0 : SetCurPageId( RID_OFAPAGE_SMARTTAG_OPTIONS );
162 : 0 : }
163 : :
164 : 0 : sal_Bool lcl_FindEntry( ListBox& rLB, const String& rEntry,
165 : : CollatorWrapper& rCmpClass )
166 : : {
167 : 0 : sal_uInt16 nCount = rLB.GetEntryCount();
168 : 0 : sal_uInt16 nSelPos = rLB.GetSelectEntryPos();
169 : : sal_uInt16 i;
170 [ # # ]: 0 : for(i = 0; i < nCount; i++)
171 : : {
172 [ # # ][ # # ]: 0 : if( 0 == rCmpClass.compareString(rEntry, rLB.GetEntry(i) ))
[ # # ][ # # ]
173 : : {
174 : 0 : rLB.SelectEntryPos(i, sal_True);
175 : 0 : return sal_True;
176 : : }
177 : : }
178 [ # # ]: 0 : if(LISTBOX_ENTRY_NOTFOUND != nSelPos)
179 : 0 : rLB.SelectEntryPos(nSelPos, sal_False);
180 : 0 : return sal_False;
181 : : }
182 : :
183 : 0 : IMPL_LINK(OfaAutoCorrDlg, SelectLanguageHdl, ListBox*, pBox)
184 : : {
185 : 0 : sal_uInt16 nPos = pBox->GetSelectEntryPos();
186 : 0 : void* pVoid = pBox->GetEntryData(nPos);
187 : 0 : LanguageType eNewLang = (LanguageType)(long)pVoid;
188 : : // save old settings and fill anew
189 [ # # ]: 0 : if(eNewLang != eLastDialogLanguage)
190 : : {
191 : 0 : sal_uInt16 nPageId = GetCurPageId();
192 [ # # ]: 0 : if(RID_OFAPAGE_AUTOCORR_REPLACE == nPageId)
193 : 0 : ((OfaAutocorrReplacePage*)GetTabPage( nPageId ))->SetLanguage(eNewLang);
194 [ # # ]: 0 : else if(RID_OFAPAGE_AUTOCORR_EXCEPT == nPageId)
195 : 0 : ((OfaAutocorrExceptPage*)GetTabPage( nPageId ))->SetLanguage(eNewLang);
196 : : }
197 : 0 : return 0;
198 : : }
199 : :
200 : 0 : OfaAutocorrOptionsPage::OfaAutocorrOptionsPage( Window* pParent,
201 : : const SfxItemSet& rSet ) :
202 : 0 : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_OPTIONS ), rSet),
203 [ # # ]: 0 : aCheckLB (this, CUI_RES(CLB_SETTINGS )),
204 : :
205 [ # # ]: 0 : sInput (CUI_RES(ST_USE_REPLACE )),
206 [ # # ]: 0 : sDoubleCaps (CUI_RES(ST_CPTL_STT_WORD )),
207 [ # # ]: 0 : sStartCap (CUI_RES(ST_CPTL_STT_SENT )),
208 [ # # ]: 0 : sBoldUnderline (CUI_RES(ST_BOLD_UNDER )),
209 [ # # ]: 0 : sURL (CUI_RES(ST_DETECT_URL )),
210 [ # # ]: 0 : sNoDblSpaces (CUI_RES(STR_NO_DBL_SPACES )),
211 [ # # ]: 0 : sDash (CUI_RES(ST_DASH )),
212 [ # # ][ # # ]: 0 : sAccidentalCaps (CUI_RES(ST_CORRECT_ACCIDENTAL_CAPS_LOCK))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
213 : : {
214 [ # # ]: 0 : FreeResource();
215 : :
216 [ # # ]: 0 : aCheckLB.SetHelpId(HID_OFAPAGE_AUTOCORR_CLB);
217 : 0 : }
218 : :
219 [ # # ][ # # ]: 0 : OfaAutocorrOptionsPage::~OfaAutocorrOptionsPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
220 : : {
221 [ # # ]: 0 : }
222 : :
223 : 0 : SfxTabPage* OfaAutocorrOptionsPage::Create( Window* pParent,
224 : : const SfxItemSet& rSet)
225 : : {
226 [ # # ]: 0 : return new OfaAutocorrOptionsPage(pParent, rSet);
227 : : }
228 : :
229 : 0 : sal_Bool OfaAutocorrOptionsPage::FillItemSet( SfxItemSet& )
230 : : {
231 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
232 : 0 : long nFlags = pAutoCorrect->GetFlags();
233 : :
234 : 0 : sal_uInt16 nPos = 0;
235 : 0 : pAutoCorrect->SetAutoCorrFlag(Autocorrect, aCheckLB.IsChecked(nPos++));
236 : 0 : pAutoCorrect->SetAutoCorrFlag(CptlSttWrd, aCheckLB.IsChecked(nPos++));
237 : 0 : pAutoCorrect->SetAutoCorrFlag(CptlSttSntnc, aCheckLB.IsChecked(nPos++));
238 : 0 : pAutoCorrect->SetAutoCorrFlag(ChgWeightUnderl, aCheckLB.IsChecked(nPos++));
239 : 0 : pAutoCorrect->SetAutoCorrFlag(SetINetAttr, aCheckLB.IsChecked(nPos++));
240 : 0 : pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, aCheckLB.IsChecked(nPos++));
241 : 0 : pAutoCorrect->SetAutoCorrFlag(IgnoreDoubleSpace, aCheckLB.IsChecked(nPos++));
242 : 0 : pAutoCorrect->SetAutoCorrFlag(CorrectCapsLock, aCheckLB.IsChecked(nPos++));
243 : :
244 : 0 : sal_Bool bReturn = nFlags != pAutoCorrect->GetFlags();
245 [ # # ]: 0 : if(bReturn )
246 : : {
247 : 0 : SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
248 : 0 : rCfg.SetModified();
249 : 0 : rCfg.Commit();
250 : : }
251 : 0 : return bReturn;
252 : : }
253 : :
254 : 0 : void OfaAutocorrOptionsPage::ActivatePage( const SfxItemSet& )
255 : : {
256 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_False);
257 : 0 : }
258 : :
259 : 0 : void OfaAutocorrOptionsPage::Reset( const SfxItemSet& )
260 : : {
261 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
262 : 0 : const long nFlags = pAutoCorrect->GetFlags();
263 : :
264 : 0 : aCheckLB.SetUpdateMode(sal_False);
265 : 0 : aCheckLB.Clear();
266 : :
267 : 0 : aCheckLB.InsertEntry(sInput);
268 : 0 : aCheckLB.InsertEntry(sDoubleCaps);
269 : 0 : aCheckLB.InsertEntry(sStartCap);
270 : 0 : aCheckLB.InsertEntry(sBoldUnderline);
271 : 0 : aCheckLB.InsertEntry(sURL);
272 : 0 : aCheckLB.InsertEntry(sDash);
273 : 0 : aCheckLB.InsertEntry(sNoDblSpaces);
274 : 0 : aCheckLB.InsertEntry(sAccidentalCaps);
275 : :
276 : 0 : sal_uInt16 nPos = 0;
277 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & Autocorrect) );
278 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & CptlSttWrd) );
279 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & CptlSttSntnc) );
280 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgWeightUnderl) );
281 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & SetINetAttr) );
282 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgToEnEmDash) );
283 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & IgnoreDoubleSpace) );
284 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & CorrectCapsLock) );
285 : :
286 : 0 : aCheckLB.SetUpdateMode(sal_True);
287 : 0 : }
288 : :
289 : : /*********************************************************************/
290 : : /* */
291 : : /* helping struct for dUserData of the Checklistbox */
292 : : /* */
293 : : /*********************************************************************/
294 : :
295 : : struct ImpUserData
296 : : {
297 : : String *pString;
298 : : Font* pFont;
299 : :
300 : 0 : ImpUserData(String* pText, Font* pFnt)
301 : 0 : { pString = pText; pFont = pFnt;}
302 : : };
303 : :
304 : :
305 : : /*********************************************************************/
306 : : /* */
307 : : /* dialog for per cent settings */
308 : : /* */
309 : : /*********************************************************************/
310 : :
311 [ # # ][ # # ]: 0 : class OfaAutoFmtPrcntSet : public ModalDialog
[ # # ][ # # ]
[ # # ]
312 : : {
313 : : OKButton aOKPB;
314 : : CancelButton aCancelPB;
315 : : FixedLine aPrcntFL;
316 : : MetricField aPrcntMF;
317 : :
318 : : public:
319 : 0 : OfaAutoFmtPrcntSet(Window* pParent) :
320 : 0 : ModalDialog(pParent, CUI_RES(RID_OFADLG_PRCNT_SET)),
321 [ # # ]: 0 : aOKPB(this, CUI_RES(BT_OK)),
322 [ # # ]: 0 : aCancelPB(this, CUI_RES(BT_CANCEL)),
323 [ # # ]: 0 : aPrcntFL(this, CUI_RES(FL_PRCNT)),
324 [ # # ][ # # ]: 0 : aPrcntMF(this, CUI_RES(ED_RIGHT_MARGIN))
[ # # ][ # # ]
[ # # ][ # # ]
325 : : {
326 [ # # ]: 0 : FreeResource();
327 : 0 : }
328 : 0 : MetricField& GetPrcntFld(){return aPrcntMF;}
329 : : };
330 : :
331 : :
332 : : /*********************************************************************/
333 : : /* */
334 : : /* changed LBoxString */
335 : : /* */
336 : : /*********************************************************************/
337 : :
338 [ # # ]: 0 : class OfaImpBrwString : public SvLBoxString
339 : : {
340 : : public:
341 : :
342 : 0 : OfaImpBrwString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
343 [ # # ]: 0 : const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr){}
344 : :
345 : : virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
346 : : SvLBoxEntry* pEntry);
347 : : };
348 : :
349 : 0 : void OfaImpBrwString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/,
350 : : SvLBoxEntry* pEntry )
351 : : {
352 [ # # ][ # # ]: 0 : rDev.DrawText( rPos, GetText() );
[ # # ]
353 [ # # ]: 0 : if(pEntry->GetUserData())
354 : : {
355 : 0 : ImpUserData* pUserData = (ImpUserData* )pEntry->GetUserData();
356 : 0 : Point aNewPos(rPos);
357 [ # # ][ # # ]: 0 : aNewPos.X() += rDev.GetTextWidth(GetText());
[ # # ]
358 [ # # ]: 0 : Font aOldFont( rDev.GetFont());
359 [ # # ]: 0 : Font aFont( aOldFont );
360 [ # # ]: 0 : if(pUserData->pFont)
361 : : {
362 [ # # ]: 0 : aFont = *pUserData->pFont;
363 [ # # ][ # # ]: 0 : aFont.SetColor(aOldFont.GetColor());
364 [ # # ][ # # ]: 0 : aFont.SetSize(aOldFont.GetSize());
365 : : }
366 [ # # ]: 0 : aFont.SetWeight( WEIGHT_BOLD );
367 : :
368 : 0 : sal_Bool bFett = sal_True;
369 : 0 : sal_uInt16 nPos = 0;
370 [ # # ]: 0 : do {
371 [ # # ]: 0 : String sTxt( pUserData->pString->GetToken( 0, 1, nPos ));
372 : :
373 [ # # ]: 0 : if( bFett )
374 [ # # ]: 0 : rDev.SetFont( aFont );
375 : :
376 [ # # ]: 0 : rDev.DrawText( aNewPos, sTxt );
377 : :
378 [ # # ]: 0 : if( STRING_NOTFOUND != nPos )
379 [ # # ]: 0 : aNewPos.X() += rDev.GetTextWidth( sTxt );
380 : :
381 [ # # ]: 0 : if( bFett )
382 [ # # ]: 0 : rDev.SetFont( aOldFont );
383 : :
384 [ # # ]: 0 : bFett = !bFett;
385 [ # # ][ # # ]: 0 : } while( STRING_NOTFOUND != nPos );
386 : : }
387 : 0 : }
388 : :
389 : : /*********************************************************************/
390 : : /* */
391 : : /* use TabPage autoformat */
392 : : /* */
393 : : /*********************************************************************/
394 : :
395 : : #define CBCOL_FIRST 0
396 : : #define CBCOL_SECOND 1
397 : : #define CBCOL_BOTH 2
398 : :
399 : : enum OfaAutoFmtOptions
400 : : {
401 : : USE_REPLACE_TABLE,
402 : : CORR_UPPER,
403 : : BEGIN_UPPER,
404 : : BOLD_UNDERLINE,
405 : : DETECT_URL,
406 : : REPLACE_DASHES,
407 : : DEL_SPACES_AT_STT_END,
408 : : DEL_SPACES_BETWEEN_LINES,
409 : : IGNORE_DBLSPACE,
410 : : CORRECT_CAPS_LOCK,
411 : : APPLY_NUMBERING,
412 : : INSERT_BORDER,
413 : : CREATE_TABLE,
414 : : REPLACE_STYLES,
415 : : DEL_EMPTY_NODE,
416 : : REPLACE_USER_COLL,
417 : : REPLACE_BULLETS,
418 : : MERGE_SINGLE_LINE_PARA
419 : : };
420 : :
421 : 0 : OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage( Window* pParent,
422 : : const SfxItemSet& rSet ) :
423 : 0 : SfxTabPage(pParent, CUI_RES(RID_OFAPAGE_AUTOFMT_APPLY), rSet),
424 [ # # ]: 0 : m_aCheckLBContainer(this, CUI_RES(CLB_SETTINGS)),
425 : : aCheckLB(m_aCheckLBContainer),
426 [ # # ]: 0 : aEditPB (this, CUI_RES(PB_EDIT)),
427 [ # # ]: 0 : aHeader1Expl (this, CUI_RES(FT_HEADER1_EXPLANATION)),
428 [ # # ]: 0 : aHeader2Expl (this, CUI_RES(FT_HEADER2_EXPLANATION)),
429 [ # # ]: 0 : sHeader1 (CUI_RES( STR_HEADER1 )),
430 [ # # ]: 0 : sHeader2 (CUI_RES( STR_HEADER2 )),
431 [ # # ]: 0 : sDeleteEmptyPara (CUI_RES( ST_DEL_EMPTY_PARA)),
432 [ # # ]: 0 : sUseReplaceTbl (CUI_RES( ST_USE_REPLACE )),
433 [ # # ]: 0 : sCptlSttWord (CUI_RES( ST_CPTL_STT_WORD)),
434 [ # # ]: 0 : sCptlSttSent (CUI_RES( ST_CPTL_STT_SENT)),
435 [ # # ]: 0 : sUserStyle (CUI_RES( ST_USER_STYLE )),
436 [ # # ]: 0 : sBullet (CUI_RES( ST_BULLET )),
437 [ # # ]: 0 : sBoldUnder (CUI_RES( ST_BOLD_UNDER )),
438 [ # # ]: 0 : sNoDblSpaces (CUI_RES( STR_NO_DBL_SPACES)),
439 [ # # ]: 0 : sCorrectCapsLock (CUI_RES( ST_CORRECT_ACCIDENTAL_CAPS_LOCK)),
440 [ # # ]: 0 : sDetectURL (CUI_RES( ST_DETECT_URL )),
441 [ # # ]: 0 : sDash (CUI_RES( ST_DASH )),
442 [ # # ]: 0 : sRightMargin (CUI_RES( ST_RIGHT_MARGIN )),
443 [ # # ]: 0 : sNum (CUI_RES( STR_NUM )),
444 [ # # ]: 0 : sBorder (CUI_RES( STR_BORDER )),
445 [ # # ]: 0 : sTable (CUI_RES( STR_TABLE )),
446 [ # # ]: 0 : sReplaceTemplates (CUI_RES( STR_REPLACE_TEMPLATES)),
447 [ # # ]: 0 : sDelSpaceAtSttEnd (CUI_RES( STR_DEL_SPACES_AT_STT_END)),
448 [ # # ]: 0 : sDelSpaceBetweenLines(CUI_RES(STR_DEL_SPACES_BETWEEN_LINES)),
449 : :
450 : : nPercent ( 50 ),
451 [ # # ][ # # ]: 0 : pCheckButtonData( NULL )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
452 : :
453 : : {
454 [ # # ]: 0 : FreeResource();
455 : :
456 : : // set typ. inverted commas
457 [ # # ]: 0 : SvtSysLocale aSysLcl;
458 : :
459 [ # # ]: 0 : aCheckLB.SetHelpId(HID_OFAPAGE_AUTOFORMAT_CLB);
460 [ # # ][ # # ]: 0 : aCheckLB.SetStyle(aCheckLB.GetStyle()|WB_HSCROLL| WB_VSCROLL);
461 : :
462 [ # # ]: 0 : aCheckLB.SetSelectHdl(LINK(this, OfaSwAutoFmtOptionsPage, SelectHdl));
463 [ # # ]: 0 : aCheckLB.SetDoubleClickHdl(LINK(this, OfaSwAutoFmtOptionsPage, EditHdl));
464 : :
465 : : static long aStaticTabs[]=
466 : : {
467 : : 3, 0, 20, 40
468 : : };
469 : :
470 [ # # ]: 0 : aCheckLB.SvxSimpleTable::SetTabs(aStaticTabs);
471 [ # # ]: 0 : String sHeader( sHeader1 );
472 [ # # ]: 0 : sHeader += '\t';
473 [ # # ]: 0 : sHeader += sHeader2;
474 [ # # ]: 0 : sHeader += '\t';
475 : : aCheckLB.InsertHeaderEntry( sHeader, HEADERBAR_APPEND,
476 [ # # ][ # # ]: 0 : HIB_CENTER | HIB_VCENTER | HIB_FIXEDPOS | HIB_FIXED);
477 : :
478 [ # # ][ # # ]: 0 : aEditPB.SetClickHdl(LINK(this, OfaSwAutoFmtOptionsPage, EditHdl));
[ # # ]
479 : 0 : }
480 : :
481 : 0 : SvLBoxEntry* OfaSwAutoFmtOptionsPage::CreateEntry(String& rTxt, sal_uInt16 nCol)
482 : : {
483 [ # # ][ # # ]: 0 : SvLBoxEntry* pEntry = new SvLBoxEntry;
484 : :
485 [ # # ]: 0 : if ( !pCheckButtonData )
486 : : {
487 [ # # ][ # # ]: 0 : pCheckButtonData = new SvLBoxButtonData( &aCheckLB );
488 [ # # ]: 0 : aCheckLB.SetCheckButtonData( pCheckButtonData );
489 : : }
490 : :
491 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
492 : :
493 [ # # ]: 0 : String sEmpty;
494 [ # # ]: 0 : if (nCol == CBCOL_SECOND)
495 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) );
[ # # ][ # # ]
496 : : else
497 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) );
[ # # ]
498 : :
499 [ # # ]: 0 : if (nCol == CBCOL_FIRST)
500 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) );
[ # # ][ # # ]
501 : : else
502 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) );
[ # # ]
503 [ # # ][ # # ]: 0 : pEntry->AddItem( new OfaImpBrwString( pEntry, 0, rTxt ) );
[ # # ]
504 : :
505 [ # # ]: 0 : return pEntry;
506 : : }
507 : :
508 [ # # ][ # # ]: 0 : OfaSwAutoFmtOptionsPage::~OfaSwAutoFmtOptionsPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
509 : : {
510 [ # # ]: 0 : delete (ImpUserData*) aCheckLB.GetUserData( REPLACE_BULLETS );
511 [ # # ]: 0 : delete (ImpUserData*) aCheckLB.GetUserData( APPLY_NUMBERING );
512 [ # # ]: 0 : delete (ImpUserData*) aCheckLB.GetUserData( MERGE_SINGLE_LINE_PARA );
513 [ # # ][ # # ]: 0 : delete pCheckButtonData;
514 [ # # ]: 0 : }
515 : :
516 : 0 : SfxTabPage* OfaSwAutoFmtOptionsPage::Create( Window* pParent,
517 : : const SfxItemSet& rAttrSet)
518 : : {
519 [ # # ]: 0 : return new OfaSwAutoFmtOptionsPage(pParent, rAttrSet);
520 : : }
521 : :
522 : 0 : sal_Bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet& )
523 : : {
524 : 0 : sal_Bool bModified = sal_False;
525 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
526 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
527 : 0 : long nFlags = pAutoCorrect->GetFlags();
528 : :
529 : 0 : sal_Bool bCheck = aCheckLB.IsChecked(USE_REPLACE_TABLE, CBCOL_FIRST);
530 : 0 : bModified |= pOpt->bAutoCorrect != bCheck;
531 : 0 : pOpt->bAutoCorrect = bCheck;
532 : : pAutoCorrect->SetAutoCorrFlag(Autocorrect,
533 : 0 : aCheckLB.IsChecked(USE_REPLACE_TABLE, CBCOL_SECOND));
534 : :
535 : 0 : bCheck = aCheckLB.IsChecked(CORR_UPPER, CBCOL_FIRST);
536 : 0 : bModified |= pOpt->bCptlSttWrd != bCheck;
537 : 0 : pOpt->bCptlSttWrd = bCheck;
538 : : pAutoCorrect->SetAutoCorrFlag(CptlSttWrd,
539 : 0 : aCheckLB.IsChecked(CORR_UPPER, CBCOL_SECOND));
540 : :
541 : 0 : bCheck = aCheckLB.IsChecked(BEGIN_UPPER, CBCOL_FIRST);
542 : 0 : bModified |= pOpt->bCptlSttSntnc != bCheck;
543 : 0 : pOpt->bCptlSttSntnc = bCheck;
544 : : pAutoCorrect->SetAutoCorrFlag(CptlSttSntnc,
545 : 0 : aCheckLB.IsChecked(BEGIN_UPPER, CBCOL_SECOND));
546 : :
547 : 0 : bCheck = aCheckLB.IsChecked(BOLD_UNDERLINE, CBCOL_FIRST);
548 : 0 : bModified |= pOpt->bChgWeightUnderl != bCheck;
549 : 0 : pOpt->bChgWeightUnderl = bCheck;
550 : : pAutoCorrect->SetAutoCorrFlag(ChgWeightUnderl,
551 : 0 : aCheckLB.IsChecked(BOLD_UNDERLINE, CBCOL_SECOND));
552 : :
553 : : pAutoCorrect->SetAutoCorrFlag(IgnoreDoubleSpace,
554 : 0 : aCheckLB.IsChecked(IGNORE_DBLSPACE, CBCOL_SECOND));
555 : :
556 : : pAutoCorrect->SetAutoCorrFlag(CorrectCapsLock,
557 : 0 : aCheckLB.IsChecked(CORRECT_CAPS_LOCK, CBCOL_SECOND));
558 : :
559 : 0 : bCheck = aCheckLB.IsChecked(DETECT_URL, CBCOL_FIRST);
560 : 0 : bModified |= pOpt->bSetINetAttr != bCheck;
561 : 0 : pOpt->bSetINetAttr = bCheck;
562 : : pAutoCorrect->SetAutoCorrFlag(SetINetAttr,
563 : 0 : aCheckLB.IsChecked(DETECT_URL, CBCOL_SECOND));
564 : :
565 : 0 : bCheck = aCheckLB.IsChecked(DEL_EMPTY_NODE, CBCOL_FIRST);
566 : 0 : bModified |= pOpt->bDelEmptyNode != bCheck;
567 : 0 : pOpt->bDelEmptyNode = bCheck;
568 : :
569 : 0 : bCheck = aCheckLB.IsChecked(REPLACE_USER_COLL, CBCOL_FIRST);
570 : 0 : bModified |= pOpt->bChgUserColl != bCheck;
571 : 0 : pOpt->bChgUserColl = bCheck;
572 : :
573 : 0 : bCheck = aCheckLB.IsChecked(REPLACE_BULLETS, CBCOL_FIRST);
574 : 0 : bModified |= pOpt->bChgEnumNum != bCheck;
575 : 0 : pOpt->bChgEnumNum = bCheck;
576 : 0 : bModified |= aBulletFont != pOpt->aBulletFont;
577 : 0 : pOpt->aBulletFont = aBulletFont;
578 : 0 : bModified |= !comphelper::string::equals(sBulletChar, pOpt->cBullet);
579 : 0 : pOpt->cBullet = sBulletChar.GetChar(0);
580 : :
581 : 0 : bModified |= aByInputBulletFont != pOpt->aByInputBulletFont;
582 : 0 : bModified |= !comphelper::string::equals(sByInputBulletChar, pOpt->cByInputBullet);
583 : 0 : pOpt->aByInputBulletFont = aByInputBulletFont;
584 : 0 : pOpt->cByInputBullet = sByInputBulletChar.GetChar(0);
585 : :
586 : 0 : bCheck = aCheckLB.IsChecked(MERGE_SINGLE_LINE_PARA, CBCOL_FIRST);
587 : 0 : bModified |= pOpt->bRightMargin != bCheck;
588 : 0 : pOpt->bRightMargin = bCheck;
589 : 0 : bModified |= nPercent != pOpt->nRightMargin;
590 : 0 : pOpt->nRightMargin = (sal_uInt8)nPercent;
591 : :
592 : 0 : bCheck = aCheckLB.IsChecked(APPLY_NUMBERING, CBCOL_SECOND);
593 : 0 : bModified |= pOpt->bSetNumRule != bCheck;
594 : 0 : pOpt->bSetNumRule = bCheck;
595 : :
596 : 0 : bCheck = aCheckLB.IsChecked(INSERT_BORDER, CBCOL_SECOND);
597 : 0 : bModified |= pOpt->bSetBorder != bCheck;
598 : 0 : pOpt->bSetBorder = bCheck;
599 : :
600 : 0 : bCheck = aCheckLB.IsChecked(CREATE_TABLE, CBCOL_SECOND);
601 : 0 : bModified |= pOpt->bCreateTable != bCheck;
602 : 0 : pOpt->bCreateTable = bCheck;
603 : :
604 : 0 : bCheck = aCheckLB.IsChecked(REPLACE_STYLES, CBCOL_SECOND);
605 : 0 : bModified |= pOpt->bReplaceStyles != bCheck;
606 : 0 : pOpt->bReplaceStyles = bCheck;
607 : :
608 : 0 : bCheck = aCheckLB.IsChecked(REPLACE_DASHES, CBCOL_FIRST);
609 : 0 : bModified |= pOpt->bChgToEnEmDash != bCheck;
610 : 0 : pOpt->bChgToEnEmDash = bCheck;
611 : : pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash,
612 : 0 : aCheckLB.IsChecked(REPLACE_DASHES, CBCOL_SECOND));
613 : :
614 : 0 : bCheck = aCheckLB.IsChecked(DEL_SPACES_AT_STT_END, CBCOL_FIRST);
615 : 0 : bModified |= pOpt->bAFmtDelSpacesAtSttEnd != bCheck;
616 : 0 : pOpt->bAFmtDelSpacesAtSttEnd = bCheck;
617 : 0 : bCheck = aCheckLB.IsChecked(DEL_SPACES_AT_STT_END, CBCOL_SECOND);
618 : 0 : bModified |= pOpt->bAFmtByInpDelSpacesAtSttEnd != bCheck;
619 : 0 : pOpt->bAFmtByInpDelSpacesAtSttEnd = bCheck;
620 : :
621 : 0 : bCheck = aCheckLB.IsChecked(DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST);
622 : 0 : bModified |= pOpt->bAFmtDelSpacesBetweenLines != bCheck;
623 : 0 : pOpt->bAFmtDelSpacesBetweenLines = bCheck;
624 : 0 : bCheck = aCheckLB.IsChecked(DEL_SPACES_BETWEEN_LINES, CBCOL_SECOND);
625 : 0 : bModified |= pOpt->bAFmtByInpDelSpacesBetweenLines != bCheck;
626 : 0 : pOpt->bAFmtByInpDelSpacesBetweenLines = bCheck;
627 : :
628 [ # # ][ # # ]: 0 : if(bModified || nFlags != pAutoCorrect->GetFlags())
[ # # ]
629 : : {
630 : 0 : SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
631 : 0 : rCfg.SetModified();
632 : 0 : rCfg.Commit();
633 : : }
634 : :
635 : 0 : return sal_True;
636 : : }
637 : :
638 : 0 : void OfaSwAutoFmtOptionsPage::ActivatePage( const SfxItemSet& )
639 : : {
640 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_False);
641 : 0 : }
642 : :
643 : 0 : void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet& )
644 : : {
645 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
646 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
647 : 0 : const long nFlags = pAutoCorrect->GetFlags();
648 : :
649 : 0 : aCheckLB.SetUpdateMode(sal_False);
650 : 0 : aCheckLB.Clear();
651 : :
652 : : // The following entries have to be inserted in the same order
653 : : // as in the OfaAutoFmtOptions-enum!
654 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sUseReplaceTbl, CBCOL_BOTH ));
655 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sCptlSttWord, CBCOL_BOTH ));
656 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sCptlSttSent, CBCOL_BOTH ));
657 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sBoldUnder, CBCOL_BOTH ));
658 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sDetectURL, CBCOL_BOTH ));
659 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sDash, CBCOL_BOTH ));
660 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceAtSttEnd, CBCOL_BOTH ));
661 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceBetweenLines, CBCOL_BOTH ));
662 : :
663 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sNoDblSpaces, CBCOL_SECOND));
664 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sCorrectCapsLock, CBCOL_SECOND));
665 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sNum, CBCOL_SECOND));
666 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sBorder, CBCOL_SECOND));
667 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sTable, CBCOL_SECOND));
668 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sReplaceTemplates, CBCOL_SECOND));
669 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sDeleteEmptyPara, CBCOL_FIRST ));
670 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sUserStyle, CBCOL_FIRST ));
671 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sBullet, CBCOL_FIRST ));
672 : 0 : aCheckLB.GetModel()->Insert(CreateEntry(sRightMargin, CBCOL_FIRST ));
673 : :
674 : 0 : aCheckLB.CheckEntryPos( USE_REPLACE_TABLE, CBCOL_FIRST, pOpt->bAutoCorrect );
675 : 0 : aCheckLB.CheckEntryPos( USE_REPLACE_TABLE, CBCOL_SECOND, 0 != (nFlags & Autocorrect));
676 : 0 : aCheckLB.CheckEntryPos( CORR_UPPER, CBCOL_FIRST, pOpt->bCptlSttWrd );
677 : 0 : aCheckLB.CheckEntryPos( CORR_UPPER, CBCOL_SECOND, 0 != (nFlags & CptlSttWrd) );
678 : 0 : aCheckLB.CheckEntryPos( BEGIN_UPPER, CBCOL_FIRST, pOpt->bCptlSttSntnc );
679 : 0 : aCheckLB.CheckEntryPos( BEGIN_UPPER, CBCOL_SECOND, 0 != (nFlags & CptlSttSntnc) );
680 : 0 : aCheckLB.CheckEntryPos( BOLD_UNDERLINE, CBCOL_FIRST, pOpt->bChgWeightUnderl );
681 : 0 : aCheckLB.CheckEntryPos( BOLD_UNDERLINE, CBCOL_SECOND, 0 != (nFlags & ChgWeightUnderl) );
682 : 0 : aCheckLB.CheckEntryPos( IGNORE_DBLSPACE, CBCOL_SECOND, 0 != (nFlags & IgnoreDoubleSpace) );
683 : 0 : aCheckLB.CheckEntryPos( CORRECT_CAPS_LOCK, CBCOL_SECOND, 0 != (nFlags & CorrectCapsLock) );
684 : 0 : aCheckLB.CheckEntryPos( DETECT_URL, CBCOL_FIRST, pOpt->bSetINetAttr );
685 : 0 : aCheckLB.CheckEntryPos( DETECT_URL, CBCOL_SECOND, 0 != (nFlags & SetINetAttr) );
686 : 0 : aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_FIRST, pOpt->bChgToEnEmDash );
687 : 0 : aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_SECOND, 0 != (nFlags & ChgToEnEmDash) );
688 : 0 : aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_FIRST, pOpt->bAFmtDelSpacesAtSttEnd );
689 : 0 : aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_SECOND, pOpt->bAFmtByInpDelSpacesAtSttEnd );
690 : 0 : aCheckLB.CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST, pOpt->bAFmtDelSpacesBetweenLines );
691 : 0 : aCheckLB.CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_SECOND, pOpt->bAFmtByInpDelSpacesBetweenLines );
692 : 0 : aCheckLB.CheckEntryPos( DEL_EMPTY_NODE, CBCOL_FIRST, pOpt->bDelEmptyNode );
693 : 0 : aCheckLB.CheckEntryPos( REPLACE_USER_COLL, CBCOL_FIRST, pOpt->bChgUserColl );
694 : 0 : aCheckLB.CheckEntryPos( REPLACE_BULLETS, CBCOL_FIRST, pOpt->bChgEnumNum );
695 : :
696 : 0 : aBulletFont = pOpt->aBulletFont;
697 : 0 : sBulletChar = pOpt->cBullet;
698 : 0 : ImpUserData* pUserData = new ImpUserData(&sBulletChar, &aBulletFont);
699 : 0 : aCheckLB.SetUserData( REPLACE_BULLETS, pUserData );
700 : :
701 : 0 : nPercent = pOpt->nRightMargin;
702 : 0 : sMargin = ' ';
703 [ # # ]: 0 : sMargin += String::CreateFromInt32( nPercent );
704 : 0 : sMargin += '%';
705 : 0 : pUserData = new ImpUserData(&sMargin, 0);
706 : 0 : aCheckLB.SetUserData( MERGE_SINGLE_LINE_PARA, pUserData );
707 : :
708 : 0 : aCheckLB.CheckEntryPos( APPLY_NUMBERING, CBCOL_SECOND, pOpt->bSetNumRule );
709 : :
710 : 0 : aByInputBulletFont = pOpt->aByInputBulletFont;
711 : 0 : sByInputBulletChar = pOpt->cByInputBullet;
712 : 0 : ImpUserData* pUserData2 = new ImpUserData(&sByInputBulletChar, &aByInputBulletFont);
713 : 0 : aCheckLB.SetUserData( APPLY_NUMBERING , pUserData2 );
714 : :
715 : 0 : aCheckLB.CheckEntryPos( MERGE_SINGLE_LINE_PARA, CBCOL_FIRST, pOpt->bRightMargin );
716 : 0 : aCheckLB.CheckEntryPos( INSERT_BORDER, CBCOL_SECOND, pOpt->bSetBorder );
717 : 0 : aCheckLB.CheckEntryPos( CREATE_TABLE, CBCOL_SECOND, pOpt->bCreateTable );
718 : 0 : aCheckLB.CheckEntryPos( REPLACE_STYLES, CBCOL_SECOND, pOpt->bReplaceStyles );
719 : :
720 : 0 : aCheckLB.SetUpdateMode(sal_True);
721 : 0 : }
722 : :
723 : 0 : IMPL_LINK(OfaSwAutoFmtOptionsPage, SelectHdl, OfaACorrCheckListBox*, pBox)
724 : : {
725 : 0 : aEditPB.Enable(0 != pBox->FirstSelected()->GetUserData());
726 : 0 : return 0;
727 : : }
728 : :
729 : 0 : IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl)
730 : : {
731 : 0 : sal_uLong nSelEntryPos = aCheckLB.GetSelectEntryPos();
732 [ # # ][ # # ]: 0 : if( nSelEntryPos == REPLACE_BULLETS ||
733 : : nSelEntryPos == APPLY_NUMBERING)
734 : : {
735 [ # # ]: 0 : SvxCharacterMap *pMapDlg = new SvxCharacterMap(this);
736 : 0 : ImpUserData* pUserData = (ImpUserData*)aCheckLB.FirstSelected()->GetUserData();
737 : 0 : pMapDlg->SetCharFont(*pUserData->pFont);
738 : 0 : pMapDlg->SetChar( pUserData->pString->GetChar(0) );
739 [ # # ]: 0 : if(RET_OK == pMapDlg->Execute())
740 : : {
741 [ # # ][ # # ]: 0 : Font aFont(pMapDlg->GetCharFont());
742 [ # # ]: 0 : *pUserData->pFont = aFont;
743 [ # # ]: 0 : sal_UCS4 aChar = pMapDlg->GetChar();
744 : : // using the UCS4 constructor
745 [ # # ]: 0 : rtl::OUString aOUStr( &aChar, 1 );
746 [ # # ][ # # ]: 0 : *pUserData->pString = aOUStr;
747 : : }
748 [ # # ]: 0 : delete pMapDlg;
749 : : }
750 [ # # ]: 0 : else if( MERGE_SINGLE_LINE_PARA == nSelEntryPos )
751 : : {
752 : : // dialog for per cent settings
753 [ # # ]: 0 : OfaAutoFmtPrcntSet aDlg(this);
754 [ # # ]: 0 : aDlg.GetPrcntFld().SetValue(nPercent);
755 [ # # ][ # # ]: 0 : if(RET_OK == aDlg.Execute())
756 : : {
757 [ # # ]: 0 : nPercent = (sal_uInt16)aDlg.GetPrcntFld().GetValue();
758 [ # # ]: 0 : sMargin = ' ';
759 [ # # ][ # # ]: 0 : sMargin += String::CreateFromInt32( nPercent );
[ # # ]
760 [ # # ]: 0 : sMargin += '%';
761 [ # # ]: 0 : }
762 : : }
763 : 0 : aCheckLB.Invalidate();
764 : 0 : return 0;
765 : : }
766 : :
767 : 0 : void OfaACorrCheckListBox::SetTabs()
768 : : {
769 : 0 : SvxSimpleTable::SetTabs();
770 : 0 : sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT|SV_LBOXTAB_ADJUST_LEFT|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_ADJUST_NUMERIC|SV_LBOXTAB_FORCE;
771 : :
772 [ # # ]: 0 : if( aTabs.size() > 1 )
773 : : {
774 : 0 : SvLBoxTab* pTab = aTabs[1];
775 : 0 : pTab->nFlags &= ~nAdjust;
776 : 0 : pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE;
777 : : }
778 [ # # ]: 0 : if( aTabs.size() > 2 )
779 : : {
780 : 0 : SvLBoxTab* pTab = aTabs[2];
781 : 0 : pTab->nFlags &= ~nAdjust;
782 : 0 : pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE;
783 : : }
784 : 0 : }
785 : :
786 : 0 : void OfaACorrCheckListBox::CheckEntryPos(sal_uLong nPos, sal_uInt16 nCol, sal_Bool bChecked)
787 : : {
788 [ # # ]: 0 : if ( nPos < GetEntryCount() )
789 : : SetCheckButtonState(
790 : : GetEntry(nPos),
791 : : nCol,
792 : : bChecked ? SvButtonState( SV_BUTTON_CHECKED ) :
793 [ # # ]: 0 : SvButtonState( SV_BUTTON_UNCHECKED ) );
794 : 0 : }
795 : :
796 : 0 : sal_Bool OfaACorrCheckListBox::IsChecked(sal_uLong nPos, sal_uInt16 nCol)
797 : : {
798 : 0 : return GetCheckButtonState( GetEntry(nPos), nCol ) == SV_BUTTON_CHECKED;
799 : : }
800 : :
801 : 0 : void OfaACorrCheckListBox::SetCheckButtonState( SvLBoxEntry* pEntry, sal_uInt16 nCol, SvButtonState eState)
802 : : {
803 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetItem(nCol + 1));
804 : :
805 : : DBG_ASSERT(pItem,"SetCheckButton:Item not found");
806 [ # # ]: 0 : if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON)
807 : : {
808 [ # # # # ]: 0 : switch( eState )
809 : : {
810 : : case SV_BUTTON_CHECKED:
811 : 0 : pItem->SetStateChecked();
812 : 0 : break;
813 : :
814 : : case SV_BUTTON_UNCHECKED:
815 : 0 : pItem->SetStateUnchecked();
816 : 0 : break;
817 : :
818 : : case SV_BUTTON_TRISTATE:
819 : 0 : pItem->SetStateTristate();
820 : 0 : break;
821 : : }
822 : 0 : InvalidateEntry( pEntry );
823 : : }
824 : 0 : }
825 : :
826 : 0 : SvButtonState OfaACorrCheckListBox::GetCheckButtonState( SvLBoxEntry* pEntry, sal_uInt16 nCol ) const
827 : : {
828 : 0 : SvButtonState eState = SV_BUTTON_UNCHECKED;
829 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetItem(nCol + 1));
830 : : DBG_ASSERT(pItem,"GetChButnState:Item not found");
831 : :
832 [ # # ]: 0 : if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON)
833 : : {
834 : 0 : sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
835 : 0 : eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
836 : : }
837 : :
838 : 0 : return eState;
839 : : }
840 : :
841 : 0 : void OfaACorrCheckListBox::HBarClick()
842 : : {
843 : : // sorting is stopped by this overload
844 : 0 : }
845 : :
846 : 0 : void OfaACorrCheckListBox::KeyInput( const KeyEvent& rKEvt )
847 : : {
848 [ # # # # ]: 0 : if(!rKEvt.GetKeyCode().GetModifier() &&
[ # # ]
849 : 0 : KEY_SPACE == rKEvt.GetKeyCode().GetCode())
850 : : {
851 : 0 : sal_uLong nSelPos = GetSelectEntryPos();
852 : 0 : sal_uInt16 nCol = GetCurrentTabPos() - 1;
853 [ # # ]: 0 : if ( nCol < 2 )
854 : : {
855 : 0 : CheckEntryPos( nSelPos, nCol, !IsChecked( nSelPos, nCol ) );
856 : 0 : CallImplEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)GetEntry( nSelPos ) );
857 : : }
858 : : else
859 : : {
860 [ # # ]: 0 : sal_uInt16 nCheck = IsChecked(nSelPos, 1) ? 1 : 0;
861 [ # # ]: 0 : if(IsChecked(nSelPos, 0))
862 : 0 : nCheck += 2;
863 : 0 : nCheck--;
864 : 0 : nCheck &= 3;
865 : 0 : CheckEntryPos(nSelPos, 1, 0 != (nCheck & 1));
866 : 0 : CheckEntryPos(nSelPos, 0, 0 != (nCheck & 2));
867 : : }
868 : : }
869 : : else
870 : 0 : SvxSimpleTable::KeyInput(rKEvt);
871 : 0 : }
872 : :
873 : 0 : void lcl_ClearTable(DoubleStringTable& rTable)
874 : : {
875 : 0 : rTable.clear();
876 : 0 : }
877 : :
878 : 0 : OfaAutocorrReplacePage::OfaAutocorrReplacePage( Window* pParent,
879 : : const SfxItemSet& rSet ) :
880 : 0 : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_REPLACE ), rSet),
881 [ # # ]: 0 : aTextOnlyCB( this, CUI_RES(CB_TEXT_ONLY )),
882 [ # # ]: 0 : aShortFT ( this, CUI_RES(FT_SHORT )),
883 [ # # ]: 0 : aShortED ( this, CUI_RES(ED_SHORT )),
884 [ # # ]: 0 : aReplaceFT( this, CUI_RES(FT_REPLACE )),
885 [ # # ]: 0 : aReplaceED( this, CUI_RES(ED_REPLACE )),
886 [ # # ]: 0 : aReplaceTLB( this, CUI_RES(TLB_REPLACE )),
887 [ # # ]: 0 : aNewReplacePB( this, CUI_RES(PB_NEW_REPLACE )),
888 [ # # ]: 0 : aDeleteReplacePB(this,CUI_RES(PB_DELETE_REPLACE )),
889 [ # # ]: 0 : sModify(CUI_RES(STR_MODIFY)),
890 : : sNew(aNewReplacePB.GetText()),
891 : : eLang(eLastDialogLanguage),
892 : : bHasSelectionText(sal_False),
893 : : bFirstSelect(sal_True),
894 : : bReplaceEditChanged(sal_False),
895 [ # # ][ # # ]: 0 : bSWriter(sal_True)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
896 : : {
897 [ # # ]: 0 : FreeResource();
898 [ # # ]: 0 : SfxModule *pMod = *(SfxModule**)GetAppData(SHL_WRITER);
899 [ # # ]: 0 : bSWriter = pMod == SfxModule::GetActiveModule();
900 : :
901 [ # # ]: 0 : ::com::sun::star::lang::Locale aLcl( SvxCreateLocale(eLastDialogLanguage ));
902 [ # # ][ # # ]: 0 : pCompareClass = new CollatorWrapper( GetProcessFact() );
[ # # ]
903 [ # # ]: 0 : pCompareClass->loadDefaultCollator( aLcl, 0 );
904 [ # # ][ # # ]: 0 : pCharClass = new CharClass( aLcl );
905 : :
906 : : static long nTabs[] = { 2 /* Tab-Count */, 1, 61 };
907 [ # # ]: 0 : aReplaceTLB.SetTabs( &nTabs[0], MAP_APPFONT );
908 : :
909 [ # # ][ # # ]: 0 : aReplaceTLB.SetStyle(aReplaceTLB.GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN);
910 [ # # ]: 0 : aReplaceTLB.SetSelectHdl(LINK(this, OfaAutocorrReplacePage, SelectHdl));
911 [ # # ]: 0 : aNewReplacePB.SetClickHdl( LINK(this, OfaAutocorrReplacePage, NewDelHdl));
912 [ # # ]: 0 : aDeleteReplacePB.SetClickHdl(LINK(this, OfaAutocorrReplacePage, NewDelHdl));
913 [ # # ]: 0 : aShortED.SetModifyHdl(LINK(this, OfaAutocorrReplacePage, ModifyHdl));
914 [ # # ]: 0 : aReplaceED.SetModifyHdl(LINK(this, OfaAutocorrReplacePage, ModifyHdl));
915 [ # # ]: 0 : aShortED.SetActionHdl(LINK(this, OfaAutocorrReplacePage, NewDelHdl));
916 [ # # ]: 0 : aReplaceED.SetActionHdl(LINK(this, OfaAutocorrReplacePage, NewDelHdl));
917 : :
918 : 0 : aReplaceED.SetSpaces(sal_True);
919 : 0 : aShortED.SetSpaces(sal_True);
920 [ # # ]: 0 : aShortED.SetMaxTextLen(30);
921 : 0 : }
922 : :
923 [ # # ][ # # ]: 0 : OfaAutocorrReplacePage::~OfaAutocorrReplacePage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
924 : : {
925 : 0 : lcl_ClearTable(aDoubleStringTable);
926 [ # # ][ # # ]: 0 : delete pCompareClass;
927 [ # # ][ # # ]: 0 : delete pCharClass;
928 [ # # ]: 0 : }
929 : :
930 : 0 : SfxTabPage* OfaAutocorrReplacePage::Create( Window* pParent,
931 : : const SfxItemSet& rSet)
932 : : {
933 [ # # ]: 0 : return new OfaAutocorrReplacePage(pParent, rSet);
934 : : }
935 : :
936 : 0 : void OfaAutocorrReplacePage::ActivatePage( const SfxItemSet& )
937 : : {
938 [ # # ]: 0 : if(eLang != eLastDialogLanguage)
939 : 0 : SetLanguage(eLastDialogLanguage);
940 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_True);
941 : 0 : }
942 : :
943 : 0 : int OfaAutocorrReplacePage::DeactivatePage( SfxItemSet* )
944 : : {
945 : 0 : return LEAVE_PAGE;
946 : : }
947 : :
948 : 0 : sal_Bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet& )
949 : : {
950 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
951 [ # # ][ # # ]: 0 : for (DoubleStringTable::reverse_iterator it = aDoubleStringTable.rbegin(); it != aDoubleStringTable.rend(); ++it)
[ # # ]
952 : : {
953 [ # # ]: 0 : LanguageType eCurLang = it->first;
954 [ # # ]: 0 : DoubleStringArray& rDoubleStringArray = it->second;
955 [ # # ]: 0 : if(eCurLang != eLang) // the current language is treated later
956 : : {
957 [ # # ]: 0 : SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eCurLang);
958 : 0 : sal_uInt16 nDoubleStringArrayCount = rDoubleStringArray.size();
959 : 0 : sal_uInt16 nPos = nDoubleStringArrayCount;
960 : 0 : sal_uInt16 nLastPos = nPos;
961 : : // 1st run: delete or change entries:
962 : :
963 : :
964 [ # # ][ # # ]: 0 : for( SvxAutocorrWordList::reverse_iterator it2 = pWordList->rbegin(); it2 != pWordList->rend(); ++it2 )
[ # # ]
965 : : {
966 [ # # ]: 0 : SvxAutocorrWord* pWordPtr = *it2;
967 [ # # ]: 0 : String sEntry(pWordPtr->GetShort());
968 : : // formatted text is only in Writer
969 [ # # ][ # # ]: 0 : sal_Bool bFound = !bSWriter && !pWordPtr->IsTextOnly();
970 [ # # ][ # # ]: 0 : while(!bFound && nPos)
[ # # ]
971 : : {
972 : 0 : DoubleString& rDouble = rDoubleStringArray[ nPos - 1];
973 : :
974 [ # # ]: 0 : if( 0 == pCompareClass->compareString(
975 [ # # ][ # # ]: 0 : sEntry, rDouble.sShort ))
[ # # ]
976 : : {
977 : 0 : nLastPos = nPos - 1;
978 : 0 : bFound = sal_True;
979 [ # # ]: 0 : if( !(pWordPtr->IsTextOnly() == (0 == rDouble.pUserData)
980 : : && 0 == pCompareClass->compareString(
981 [ # # ][ # # ]: 0 : pWordPtr->GetLong(), rDouble.sLong ) ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
[ # # ]
982 : : {
983 [ # # ]: 0 : pAutoCorrect->PutText(sEntry, rDouble.sLong, eCurLang);
984 : : }
985 [ # # ][ # # ]: 0 : rDoubleStringArray.erase(rDoubleStringArray.begin() + nPos - 1);
[ # # ]
986 : 0 : break;
987 : : }
988 : 0 : nPos--;
989 : : }
990 : 0 : nPos = nLastPos;
991 [ # # ]: 0 : if(!bFound)
992 : : {
993 [ # # ]: 0 : pAutoCorrect->DeleteText(sEntry, eCurLang);
994 : : }
995 [ # # ]: 0 : }
996 : 0 : nDoubleStringArrayCount = rDoubleStringArray.size();
997 [ # # ]: 0 : for(sal_uInt16 nDoubleStringArrayPos = 0; nDoubleStringArrayPos < nDoubleStringArrayCount; nDoubleStringArrayPos++ )
998 : : {
999 : : // now there should only be new entries left
1000 : 0 : DoubleString& rDouble = rDoubleStringArray[ nDoubleStringArrayPos ];
1001 [ # # ]: 0 : if(rDouble.pUserData == &bHasSelectionText)
1002 : : pAutoCorrect->PutText( rDouble.sShort,
1003 [ # # ][ # # ]: 0 : *SfxObjectShell::Current(), eCurLang );
1004 : : else
1005 : : {
1006 : : pAutoCorrect->PutText( rDouble.sShort, rDouble.sLong,
1007 [ # # ]: 0 : eCurLang);
1008 : : }
1009 : : }
1010 : : }
1011 : : }
1012 : 0 : aDoubleStringTable.clear();
1013 : : // and now the current selection
1014 : 0 : SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang);
1015 : 0 : sal_uInt16 nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount();
1016 : :
1017 : 0 : aReplaceTLB.SetUpdateMode(sal_False);
1018 : 0 : sal_uInt16 nListBoxPos = nListBoxCount;
1019 : 0 : sal_uInt16 nLastListBoxPos = nListBoxPos;
1020 : : // 1st run: delete or change entries:
1021 : :
1022 [ # # ][ # # ]: 0 : for( SvxAutocorrWordList::reverse_iterator it = pWordList->rbegin(); it != pWordList->rend(); ++it )
[ # # ]
1023 : : {
1024 [ # # ]: 0 : SvxAutocorrWord* pWordPtr = *it;
1025 [ # # ]: 0 : String sEntry(pWordPtr->GetShort());
1026 : : // formatted text is only in Writer
1027 [ # # ][ # # ]: 0 : sal_Bool bFound = !bSWriter && !pWordPtr->IsTextOnly();
1028 [ # # ][ # # ]: 0 : while(!bFound && nListBoxPos)
[ # # ]
1029 : : {
1030 [ # # ]: 0 : SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( nListBoxPos - 1);
1031 [ # # ]: 0 : if( 0 == pCompareClass->compareString( sEntry,
1032 [ # # ][ # # ]: 0 : aReplaceTLB.GetEntryText(pEntry, 0)))
[ # # ][ # # ]
[ # # ]
1033 : : {
1034 : 0 : nLastListBoxPos = nListBoxPos - 1;
1035 : 0 : bFound = sal_True;
1036 [ # # ]: 0 : String sLong = aReplaceTLB.GetEntryText(pEntry, 1);
1037 [ # # ]: 0 : if( !(pWordPtr->IsTextOnly() == (0 == pEntry->GetUserData())
1038 : : && 0 == pCompareClass->compareString(
1039 [ # # ][ # # ]: 0 : pWordPtr->GetLong(), sLong )))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
[ # # ]
1040 : : {
1041 [ # # ]: 0 : pAutoCorrect->PutText(sEntry, sLong, eLang);
1042 : : }
1043 [ # # ]: 0 : aReplaceTLB.GetModel()->Remove(pEntry);
1044 [ # # ]: 0 : break;
1045 : :
1046 : : }
1047 : 0 : nListBoxPos --;
1048 : : }
1049 : 0 : nListBoxPos = nLastListBoxPos;
1050 [ # # ]: 0 : if(!bFound)
1051 : : {
1052 [ # # ]: 0 : pAutoCorrect->DeleteText(sEntry, eLang);
1053 : : }
1054 : :
1055 [ # # ]: 0 : }
1056 : 0 : nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount();
1057 [ # # ]: 0 : for( sal_uInt16 i = 0; i < nListBoxCount; i++ )
1058 : : {
1059 : : // now there should only be new entries left
1060 [ # # ]: 0 : SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( i );
1061 [ # # ]: 0 : String sShort = aReplaceTLB.GetEntryText(pEntry, 0);
1062 [ # # ]: 0 : if(pEntry->GetUserData() == &bHasSelectionText)
1063 [ # # ][ # # ]: 0 : pAutoCorrect->PutText(sShort, *SfxObjectShell::Current(), eLang);
1064 : : else
1065 : : {
1066 [ # # ]: 0 : String sLong = aReplaceTLB.GetEntryText(pEntry, 1);
1067 [ # # ][ # # ]: 0 : pAutoCorrect->PutText(sShort, sLong, eLang);
1068 : : }
1069 [ # # ]: 0 : }
1070 : :
1071 : 0 : return sal_False;
1072 : : }
1073 : :
1074 : 0 : void OfaAutocorrReplacePage::RefillReplaceBox(sal_Bool bFromReset,
1075 : : LanguageType eOldLanguage,
1076 : : LanguageType eNewLanguage)
1077 : : {
1078 : 0 : eLang = eNewLanguage;
1079 [ # # ]: 0 : if(bFromReset)
1080 : 0 : lcl_ClearTable(aDoubleStringTable);
1081 : : else
1082 : : {
1083 : : DoubleStringArray* pArray;
1084 [ # # ][ # # ]: 0 : if(aDoubleStringTable.find(eOldLanguage) != aDoubleStringTable.end())
1085 : : {
1086 : 0 : pArray = &aDoubleStringTable[eOldLanguage];
1087 : 0 : pArray->clear();
1088 : : }
1089 : : else
1090 : : {
1091 : 0 : pArray = &aDoubleStringTable[eOldLanguage]; // create new array
1092 : : }
1093 : :
1094 : 0 : sal_uInt16 nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount();
1095 : : sal_uInt16 i;
1096 [ # # ]: 0 : for(i = 0; i < nListBoxCount; i++)
1097 : : {
1098 [ # # ]: 0 : pArray->push_back(DoubleString());
1099 : 0 : DoubleString& rDouble = (*pArray)[pArray->size() - 1];
1100 : 0 : SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( i );
1101 [ # # ]: 0 : rDouble.sShort = aReplaceTLB.GetEntryText(pEntry, 0);
1102 [ # # ]: 0 : rDouble.sLong = aReplaceTLB.GetEntryText(pEntry, 1);
1103 : 0 : rDouble.pUserData = pEntry->GetUserData();
1104 : : }
1105 : : }
1106 : :
1107 : 0 : aReplaceTLB.Clear();
1108 [ # # ]: 0 : if(!bSWriter)
1109 : 0 : aFormatText.clear();
1110 : :
1111 [ # # ][ # # ]: 0 : if(aDoubleStringTable.find(eLang) != aDoubleStringTable.end())
1112 : : {
1113 : 0 : DoubleStringArray& rArray = aDoubleStringTable[eNewLanguage];
1114 [ # # ]: 0 : for(sal_uInt16 i = 0; i < rArray.size(); i++)
1115 : : {
1116 : 0 : DoubleString& rDouble = rArray[i];
1117 : 0 : sal_Bool bTextOnly = 0 == rDouble.pUserData;
1118 : : // formatted text is only in Writer
1119 [ # # ][ # # ]: 0 : if(bSWriter || bTextOnly)
1120 : : {
1121 [ # # ]: 0 : String sEntry(rDouble.sShort);
1122 [ # # ]: 0 : sEntry += '\t';
1123 [ # # ]: 0 : sEntry += rDouble.sLong;
1124 [ # # ]: 0 : SvLBoxEntry* pEntry = aReplaceTLB.InsertEntry(sEntry);
1125 [ # # ]: 0 : aTextOnlyCB.Check(bTextOnly);
1126 [ # # ]: 0 : if(!bTextOnly)
1127 [ # # ]: 0 : pEntry->SetUserData(rDouble.pUserData); // that means: with format info or even with selection text
1128 : : }
1129 : : else
1130 [ # # ]: 0 : aFormatText.insert(rDouble.sShort);
1131 : : }
1132 : : }
1133 : : else
1134 : : {
1135 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1136 : 0 : SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang);
1137 : 0 : aReplaceTLB.SetUpdateMode(sal_False);
1138 [ # # ][ # # ]: 0 : for( SvxAutocorrWordList::iterator it = pWordList->begin(); it != pWordList->end(); ++it )
[ # # ]
1139 : : {
1140 [ # # ]: 0 : SvxAutocorrWord* pWordPtr = *it;
1141 : 0 : sal_Bool bTextOnly = pWordPtr->IsTextOnly();
1142 : : // formatted text is only in Writer
1143 [ # # ][ # # ]: 0 : if(bSWriter || bTextOnly)
1144 : : {
1145 [ # # ]: 0 : String sEntry(pWordPtr->GetShort());
1146 [ # # ]: 0 : sEntry += '\t';
1147 [ # # ]: 0 : sEntry += pWordPtr->GetLong();
1148 [ # # ]: 0 : SvLBoxEntry* pEntry = aReplaceTLB.InsertEntry(sEntry);
1149 [ # # ]: 0 : aTextOnlyCB.Check(pWordPtr->IsTextOnly());
1150 [ # # ]: 0 : if(!bTextOnly)
1151 [ # # ]: 0 : pEntry->SetUserData(&aTextOnlyCB); // that means: with format info
1152 : : }
1153 : : else
1154 [ # # ][ # # ]: 0 : aFormatText.insert(pWordPtr->GetShort());
1155 : : }
1156 : 0 : aNewReplacePB.Enable(sal_False);
1157 : 0 : aDeleteReplacePB.Enable(sal_False);
1158 : 0 : aReplaceTLB.SetUpdateMode(sal_True);
1159 : : }
1160 : :
1161 : 0 : SfxViewShell* pViewShell = SfxViewShell::Current();
1162 [ # # ][ # # ]: 0 : if( pViewShell && pViewShell->HasSelection( sal_True ) )
[ # # ]
1163 : : {
1164 : 0 : bHasSelectionText = sal_True;
1165 [ # # ]: 0 : const String sSelection( pViewShell->GetSelectionText() );
1166 [ # # ]: 0 : aReplaceED.SetText( sSelection );
1167 [ # # ]: 0 : aTextOnlyCB.Check( !bSWriter );
1168 [ # # ][ # # ]: 0 : aTextOnlyCB.Enable( bSWriter && sSelection.Len() );
[ # # ][ # # ]
1169 : : }
1170 : : else
1171 : 0 : aTextOnlyCB.Enable( sal_False );
1172 : 0 : }
1173 : :
1174 : 0 : void OfaAutocorrReplacePage::Reset( const SfxItemSet& )
1175 : : {
1176 : 0 : RefillReplaceBox(sal_True, eLang, eLang);
1177 : 0 : aShortED.GrabFocus();
1178 : 0 : }
1179 : :
1180 : 0 : void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet)
1181 : : {
1182 : : //save old settings an refill
1183 [ # # ]: 0 : if(eSet != eLang)
1184 : : {
1185 [ # # ]: 0 : RefillReplaceBox(sal_False, eLang, eSet);
1186 : 0 : eLastDialogLanguage = eSet;
1187 [ # # ][ # # ]: 0 : delete pCompareClass;
1188 [ # # ][ # # ]: 0 : delete pCharClass;
1189 : :
1190 [ # # ]: 0 : ::com::sun::star::lang::Locale aLcl( SvxCreateLocale(eLastDialogLanguage ));
1191 [ # # ][ # # ]: 0 : pCompareClass = new CollatorWrapper( GetProcessFact() );
[ # # ]
1192 [ # # ]: 0 : pCompareClass->loadDefaultCollator( aLcl, 0 );
1193 [ # # ][ # # ]: 0 : pCharClass = new CharClass( aLcl );
1194 [ # # ]: 0 : ModifyHdl(&aShortED);
1195 : : }
1196 : 0 : }
1197 : :
1198 : 0 : IMPL_LINK(OfaAutocorrReplacePage, SelectHdl, SvTabListBox*, pBox)
1199 : : {
1200 [ # # ][ # # ]: 0 : if(!bFirstSelect || !bHasSelectionText)
1201 : : {
1202 [ # # ]: 0 : SvLBoxEntry* pEntry = pBox->FirstSelected();
1203 [ # # ]: 0 : String sTmpShort(pBox->GetEntryText(pEntry, 0));
1204 : : // if the text is set via ModifyHdl, the cursor is always at the beginning
1205 : : // of a word, although you're editing here
1206 : : sal_Bool bSameContent = 0 == pCompareClass->compareString(
1207 [ # # ][ # # ]: 0 : sTmpShort, aShortED.GetText() );
[ # # ][ # # ]
[ # # ]
1208 [ # # ]: 0 : Selection aSel = aShortED.GetSelection();
1209 [ # # ][ # # ]: 0 : if(aShortED.GetText() != sTmpShort)
[ # # ][ # # ]
1210 : : {
1211 [ # # ]: 0 : aShortED.SetText(sTmpShort);
1212 : : // if it was only a different notation, the selection has to be set again
1213 [ # # ]: 0 : if(bSameContent)
1214 [ # # ]: 0 : aShortED.SetSelection(aSel);
1215 : : }
1216 [ # # ][ # # ]: 0 : aReplaceED.SetText(pBox->GetEntryText(pEntry, 1));
[ # # ]
1217 : : // with UserData there is a Formatinfo
1218 [ # # ][ # # ]: 0 : aTextOnlyCB.Check(0 == pEntry->GetUserData());
1219 : : }
1220 : : else
1221 : 0 : bFirstSelect = sal_False;
1222 : :
1223 : 0 : aNewReplacePB.Enable(sal_False);
1224 : 0 : aDeleteReplacePB.Enable();
1225 : 0 : return 0;
1226 : : };
1227 : :
1228 : 0 : IMPL_LINK(OfaAutocorrReplacePage, NewDelHdl, PushButton*, pBtn)
1229 : : {
1230 : 0 : SvLBoxEntry* _pEntry = aReplaceTLB.FirstSelected();
1231 [ # # ]: 0 : if(pBtn == &aDeleteReplacePB)
1232 : : {
1233 : : DBG_ASSERT(_pEntry, "keine Eintrag selektiert");
1234 [ # # ]: 0 : if(_pEntry)
1235 : : {
1236 : 0 : aReplaceTLB.GetModel()->Remove(_pEntry);
1237 : 0 : ModifyHdl(&aShortED);
1238 : 0 : return 0;
1239 : : }
1240 : : }
1241 [ # # ][ # # ]: 0 : if(pBtn == &aNewReplacePB || aNewReplacePB.IsEnabled())
[ # # ]
1242 : : {
1243 [ # # ]: 0 : SvLBoxEntry* _pNewEntry = aReplaceTLB.FirstSelected();
1244 [ # # ]: 0 : String sEntry(aShortED.GetText());
1245 [ # # ][ # # ]: 0 : if(sEntry.Len() && ( aReplaceED.GetText().Len() ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1246 : : ( bHasSelectionText && bSWriter ) ))
1247 : : {
1248 [ # # ]: 0 : aReplaceTLB.SetUpdateMode(sal_False);
1249 : 0 : sal_uInt16 nPos = USHRT_MAX;
1250 [ # # ]: 0 : sEntry += '\t';
1251 [ # # ][ # # ]: 0 : sEntry += aReplaceED.GetText();
[ # # ]
1252 [ # # ]: 0 : if(_pNewEntry)
1253 : : {
1254 [ # # ]: 0 : nPos = (sal_uInt16)aReplaceTLB.GetModel()->GetAbsPos(_pNewEntry);
1255 [ # # ]: 0 : aReplaceTLB.GetModel()->Remove(_pNewEntry);
1256 : : }
1257 : : else
1258 : : {
1259 : : sal_uInt16 j;
1260 [ # # ]: 0 : for( j = 0; j < aReplaceTLB.GetEntryCount(); j++ )
1261 : : {
1262 [ # # ]: 0 : SvLBoxEntry* pReplaceEntry = aReplaceTLB.GetEntry(j);
1263 [ # # ]: 0 : if( 0 >= pCompareClass->compareString(sEntry,
1264 [ # # ][ # # ]: 0 : aReplaceTLB.GetEntryText(pReplaceEntry, 0) ) )
[ # # ][ # # ]
[ # # ]
1265 : 0 : break;
1266 : : }
1267 : 0 : nPos = j;
1268 : : }
1269 : : SvLBoxEntry* pInsEntry =
1270 : : aReplaceTLB.InsertEntry(
1271 : : sEntry, static_cast< SvLBoxEntry * >(NULL), false,
1272 [ # # ][ # # ]: 0 : nPos == USHRT_MAX ? LIST_APPEND : nPos);
1273 [ # # ][ # # ]: 0 : if( !bReplaceEditChanged && !aTextOnlyCB.IsChecked())
[ # # ][ # # ]
1274 : 0 : pInsEntry->SetUserData(&bHasSelectionText); // new formatted text
1275 : :
1276 [ # # ]: 0 : aReplaceTLB.MakeVisible( pInsEntry );
1277 [ # # ]: 0 : aReplaceTLB.SetUpdateMode(sal_True);
1278 : : // if the request came from the ReplaceEdit, give focus to the ShortEdit
1279 [ # # ][ # # ]: 0 : if(aReplaceED.HasFocus())
1280 [ # # ]: 0 : aShortED.GrabFocus();
1281 : :
1282 [ # # ]: 0 : }
1283 : : }
1284 : : else
1285 : : {
1286 : : // this can only be an enter in one of the two edit fields
1287 : : // which means EndDialog() - has to be evaluated in KeyInput
1288 : 0 : return 0;
1289 : : }
1290 : 0 : ModifyHdl(&aShortED);
1291 : 0 : return 1;
1292 : : }
1293 : :
1294 : 0 : IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, Edit*, pEdt)
1295 : : {
1296 [ # # ]: 0 : SvLBoxEntry* pFirstSel = aReplaceTLB.FirstSelected();
1297 : 0 : sal_Bool bShort = pEdt == &aShortED;
1298 [ # # ]: 0 : const String rEntry = pEdt->GetText();
1299 [ # # ]: 0 : const String rRepString = aReplaceED.GetText();
1300 [ # # ][ # # ]: 0 : String aWordStr( pCharClass->lowercase( rEntry ));
[ # # ]
1301 : :
1302 [ # # ]: 0 : if(bShort)
1303 : : {
1304 [ # # ]: 0 : if(rEntry.Len())
1305 : : {
1306 : 0 : sal_Bool bFound = sal_False;
1307 : 0 : sal_Bool bTmpSelEntry=sal_False;
1308 : :
1309 [ # # ]: 0 : for(sal_uInt16 i = 0; i < aReplaceTLB.GetEntryCount(); i++)
1310 : : {
1311 [ # # ]: 0 : SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( i );
1312 [ # # ]: 0 : String aTestStr=aReplaceTLB.GetEntryText(pEntry, 0);
1313 [ # # ][ # # ]: 0 : if( 0 == pCompareClass->compareString(rEntry, aTestStr ))
[ # # ][ # # ]
1314 : : {
1315 [ # # ]: 0 : if(rRepString.Len())
1316 : 0 : bFirstSelect = sal_True;
1317 [ # # ]: 0 : aReplaceTLB.SetCurEntry(pEntry);
1318 : 0 : pFirstSel = pEntry;
1319 [ # # ]: 0 : aNewReplacePB.SetText(sModify);
1320 : 0 : bFound= sal_True;
1321 : : break;
1322 : : }
1323 : : else
1324 : : {
1325 [ # # ][ # # ]: 0 : aTestStr = pCharClass->lowercase( aTestStr );
[ # # ]
1326 [ # # ][ # # ]: 0 : if(aTestStr.Search(aWordStr)==0 && !bTmpSelEntry)
[ # # ][ # # ]
1327 : : {
1328 [ # # ]: 0 : aReplaceTLB.MakeVisible(pEntry);
1329 : 0 : bTmpSelEntry=sal_True;
1330 : : }
1331 : : }
1332 [ # # ][ # # ]: 0 : }
1333 [ # # ]: 0 : if(!bFound)
1334 : : {
1335 [ # # ]: 0 : aReplaceTLB.SelectAll(sal_False);
1336 : 0 : pFirstSel = 0;
1337 [ # # ]: 0 : aNewReplacePB.SetText(sNew);
1338 [ # # ]: 0 : if(bReplaceEditChanged)
1339 [ # # ]: 0 : aTextOnlyCB.Enable(sal_False);
1340 : : }
1341 [ # # ]: 0 : aDeleteReplacePB.Enable(bFound);
1342 : : }
1343 [ # # ]: 0 : else if(aReplaceTLB.GetEntryCount()>0)
1344 : : {
1345 [ # # ]: 0 : SvLBoxEntry* pEntry = aReplaceTLB.GetEntry( 0 );
1346 [ # # ]: 0 : aReplaceTLB.MakeVisible(pEntry);
1347 : : }
1348 : :
1349 : : }
1350 [ # # ]: 0 : else if(!bShort)
1351 : : {
1352 : 0 : bReplaceEditChanged = sal_True;
1353 [ # # ]: 0 : if(pFirstSel)
1354 : : {
1355 [ # # ]: 0 : aNewReplacePB.SetText(sModify);
1356 : : }
1357 : : }
1358 : :
1359 [ # # ]: 0 : const String& rShortTxt = aShortED.GetText();
1360 : 0 : sal_Bool bEnableNew = rShortTxt.Len() &&
1361 : 0 : ( rRepString.Len() ||
1362 : : ( bHasSelectionText && bSWriter )) &&
1363 : : ( !pFirstSel || rRepString !=
1364 [ # # ][ # # ]: 0 : aReplaceTLB.GetEntryText( pFirstSel, 1 ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1365 [ # # ]: 0 : if(bEnableNew)
1366 : : {
1367 [ # # ]: 0 : for(std::set<rtl::OUString>::iterator i = aFormatText.begin(); i != aFormatText.end(); ++i)
1368 : : {
1369 [ # # ][ # # ]: 0 : if((*i).equals(rShortTxt))
1370 : : {
1371 : 0 : bEnableNew = sal_False;
1372 : 0 : break;
1373 : : }
1374 : : }
1375 : : }
1376 [ # # ]: 0 : aNewReplacePB.Enable(bEnableNew);
1377 : :
1378 [ # # ][ # # ]: 0 : return 0;
[ # # ][ # # ]
1379 : : }
1380 : :
1381 : 0 : sal_Bool lcl_FindInArray(std::vector<rtl::OUString>& rStrings, const String& rString)
1382 : : {
1383 [ # # ][ # # ]: 0 : for(std::vector<rtl::OUString>::iterator i = rStrings.begin(); i != rStrings.end(); ++i)
1384 [ # # ][ # # ]: 0 : if((*i).equals(rString))
1385 : 0 : return sal_True;
1386 : 0 : return sal_False;
1387 : : }
1388 : :
1389 : 0 : void lcl_ClearTable(StringsTable& rTable)
1390 : : {
1391 : 0 : rTable.clear();
1392 : 0 : }
1393 : :
1394 : 0 : OfaAutocorrExceptPage::OfaAutocorrExceptPage( Window* pParent,
1395 : : const SfxItemSet& rSet ) :
1396 : 0 : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_EXCEPT ), rSet),
1397 [ # # ]: 0 : aAbbrevFL (this, CUI_RES(FL_ABBREV )),
1398 [ # # ]: 0 : aAbbrevED (this, CUI_RES(ED_ABBREV )),
1399 [ # # ]: 0 : aAbbrevLB (this, CUI_RES(LB_ABBREV )),
1400 [ # # ]: 0 : aNewAbbrevPB (this, CUI_RES(PB_NEWABBREV )),
1401 [ # # ]: 0 : aDelAbbrevPB (this, CUI_RES(PB_DELABBREV )),
1402 [ # # ]: 0 : aAutoAbbrevCB (this, CUI_RES(CB_AUTOABBREV )),
1403 [ # # ]: 0 : aDoubleCapsFL (this, CUI_RES(FL_DOUBLECAPS )),
1404 [ # # ]: 0 : aDoubleCapsED (this, CUI_RES(ED_DOUBLE_CAPS )),
1405 [ # # ]: 0 : aDoubleCapsLB (this, CUI_RES(LB_DOUBLE_CAPS )),
1406 [ # # ]: 0 : aNewDoublePB (this, CUI_RES(PB_NEWDOUBLECAPS)),
1407 [ # # ]: 0 : aDelDoublePB (this, CUI_RES(PB_DELDOUBLECAPS)),
1408 [ # # ]: 0 : aAutoCapsCB (this, CUI_RES(CB_AUTOCAPS )),
1409 [ # # ][ # # ]: 0 : eLang(eLastDialogLanguage)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1410 : : {
1411 [ # # ][ # # ]: 0 : aNewAbbrevPB.SetAccessibleName(String(CUI_RES(STR_PB_NEWABBREV) ) );
[ # # ][ # # ]
1412 [ # # ][ # # ]: 0 : aDelAbbrevPB.SetAccessibleName(String(CUI_RES(STR_PB_DELABBREV) ) );
[ # # ][ # # ]
1413 [ # # ][ # # ]: 0 : aNewDoublePB.SetAccessibleName(String(CUI_RES(STR_PB_NEWDOUBLECAPS) ) );
[ # # ][ # # ]
1414 [ # # ][ # # ]: 0 : aDelDoublePB.SetAccessibleName(String(CUI_RES(STR_PB_DELDOUBLECAPS) ) );
[ # # ][ # # ]
1415 : :
1416 [ # # ]: 0 : FreeResource();
1417 : :
1418 [ # # ]: 0 : ::com::sun::star::lang::Locale aLcl( SvxCreateLocale(eLastDialogLanguage ));
1419 [ # # ][ # # ]: 0 : pCompareClass = new CollatorWrapper( GetProcessFact() );
[ # # ]
1420 : : pCompareClass->loadDefaultCollator( aLcl, ::com::sun::star::i18n::
1421 [ # # ]: 0 : CollatorOptions::CollatorOptions_IGNORE_CASE );
1422 : :
1423 [ # # ]: 0 : aNewAbbrevPB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl));
1424 [ # # ]: 0 : aDelAbbrevPB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl));
1425 [ # # ]: 0 : aNewDoublePB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl));
1426 [ # # ]: 0 : aDelDoublePB.SetClickHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl));
1427 : :
1428 [ # # ]: 0 : aAbbrevLB.SetSelectHdl(LINK(this, OfaAutocorrExceptPage, SelectHdl));
1429 [ # # ]: 0 : aDoubleCapsLB.SetSelectHdl(LINK(this, OfaAutocorrExceptPage, SelectHdl));
1430 [ # # ]: 0 : aAbbrevED.SetModifyHdl(LINK(this, OfaAutocorrExceptPage, ModifyHdl));
1431 [ # # ]: 0 : aDoubleCapsED.SetModifyHdl(LINK(this, OfaAutocorrExceptPage, ModifyHdl));
1432 : :
1433 [ # # ]: 0 : aAbbrevED.SetActionHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl));
1434 [ # # ]: 0 : aDoubleCapsED.SetActionHdl(LINK(this, OfaAutocorrExceptPage, NewDelHdl));
1435 : :
1436 [ # # ]: 0 : aNewAbbrevPB.SetAccessibleRelationMemberOf(&aAbbrevFL);
1437 [ # # ]: 0 : aDelAbbrevPB.SetAccessibleRelationMemberOf(&aAbbrevFL);
1438 [ # # ]: 0 : aNewDoublePB.SetAccessibleRelationMemberOf(&aDoubleCapsFL);
1439 [ # # ]: 0 : aDelDoublePB.SetAccessibleRelationMemberOf(&aDoubleCapsFL);
1440 : 0 : }
1441 : :
1442 [ # # ][ # # ]: 0 : OfaAutocorrExceptPage::~OfaAutocorrExceptPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1443 : : {
1444 : 0 : lcl_ClearTable(aStringsTable);
1445 [ # # ][ # # ]: 0 : delete pCompareClass;
1446 [ # # ]: 0 : }
1447 : :
1448 : 0 : SfxTabPage* OfaAutocorrExceptPage::Create( Window* pParent,
1449 : : const SfxItemSet& rSet)
1450 : : {
1451 [ # # ]: 0 : return new OfaAutocorrExceptPage(pParent, rSet);
1452 : : }
1453 : :
1454 : 0 : void OfaAutocorrExceptPage::ActivatePage( const SfxItemSet& )
1455 : : {
1456 [ # # ]: 0 : if(eLang != eLastDialogLanguage)
1457 : 0 : SetLanguage(eLastDialogLanguage);
1458 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_True);
1459 : 0 : }
1460 : :
1461 : 0 : int OfaAutocorrExceptPage::DeactivatePage( SfxItemSet* )
1462 : : {
1463 : 0 : return LEAVE_PAGE;
1464 : : }
1465 : :
1466 : 0 : sal_Bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet& )
1467 : : {
1468 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1469 [ # # ][ # # ]: 0 : for(StringsTable::reverse_iterator it1 = aStringsTable.rbegin(); it1 != aStringsTable.rend(); ++it1)
[ # # ]
1470 : : {
1471 [ # # ]: 0 : LanguageType eCurLang = it1->first;
1472 [ # # ]: 0 : StringsArrays& rArrays = it1->second;
1473 [ # # ]: 0 : if(eCurLang != eLang) // current language is treated later
1474 : : {
1475 [ # # ]: 0 : SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWrdSttExceptList(eCurLang);
1476 : :
1477 [ # # ]: 0 : if(pWrdList)
1478 : : {
1479 : 0 : sal_uInt16 nCount = pWrdList->size();
1480 : : sal_uInt16 i;
1481 [ # # ]: 0 : for( i = nCount; i; )
1482 : : {
1483 [ # # ]: 0 : String* pString = (*pWrdList)[ --i ];
1484 : :
1485 [ # # ][ # # ]: 0 : if( !lcl_FindInArray(rArrays.aDoubleCapsStrings, *pString))
1486 : : {
1487 [ # # ][ # # ]: 0 : delete (*pWrdList)[ i ];
[ # # ]
1488 [ # # ]: 0 : pWrdList->erase(i);
1489 : : }
1490 : : }
1491 : :
1492 [ # # ][ # # ]: 0 : for(std::vector<rtl::OUString>::iterator it = rArrays.aDoubleCapsStrings.begin(); it != rArrays.aDoubleCapsStrings.end(); ++i)
1493 : : {
1494 [ # # ][ # # ]: 0 : String* s = new String(*it);
1495 [ # # ][ # # ]: 0 : if(!pWrdList->insert(s).second)
1496 [ # # ][ # # ]: 0 : delete s;
1497 : : }
1498 [ # # ]: 0 : pAutoCorrect->SaveWrdSttExceptList(eCurLang);
1499 : : }
1500 : :
1501 [ # # ]: 0 : SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eCurLang);
1502 : :
1503 [ # # ]: 0 : if(pCplList)
1504 : : {
1505 : 0 : sal_uInt16 nCount = pCplList->size();
1506 : : sal_uInt16 i;
1507 [ # # ]: 0 : for( i = nCount; i; )
1508 : : {
1509 [ # # ]: 0 : String* pString = (*pCplList)[ --i ];
1510 [ # # ][ # # ]: 0 : if( !lcl_FindInArray(rArrays.aAbbrevStrings, *pString))
1511 : : {
1512 [ # # ][ # # ]: 0 : delete (*pCplList)[ i ];
[ # # ]
1513 [ # # ]: 0 : pCplList->erase(i);
1514 : : }
1515 : : }
1516 : :
1517 [ # # ][ # # ]: 0 : for(std::vector<rtl::OUString>::iterator it = rArrays.aAbbrevStrings.begin(); it != rArrays.aAbbrevStrings.end(); ++it)
1518 : : {
1519 [ # # ][ # # ]: 0 : String* s = new String(*it);
1520 [ # # ][ # # ]: 0 : if(!pCplList->insert(s).second)
1521 [ # # ][ # # ]: 0 : delete s;
1522 : : }
1523 : :
1524 [ # # ]: 0 : pAutoCorrect->SaveCplSttExceptList(eCurLang);
1525 : : }
1526 : : }
1527 : : }
1528 : 0 : aStringsTable.clear();
1529 : :
1530 : 0 : SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWrdSttExceptList(eLang);
1531 : :
1532 [ # # ]: 0 : if(pWrdList)
1533 : : {
1534 : 0 : sal_uInt16 nCount = pWrdList->size();
1535 : : sal_uInt16 i;
1536 [ # # ]: 0 : for( i = nCount; i; )
1537 : : {
1538 : 0 : String* pString = (*pWrdList)[ --i ];
1539 [ # # ]: 0 : if( USHRT_MAX == aDoubleCapsLB.GetEntryPos(*pString) )
1540 : : {
1541 [ # # ]: 0 : delete (*pWrdList)[ i ];
1542 : 0 : pWrdList->erase(i);
1543 : : }
1544 : : }
1545 : 0 : nCount = aDoubleCapsLB.GetEntryCount();
1546 [ # # ]: 0 : for( i = 0; i < nCount; ++i )
1547 : : {
1548 [ # # ][ # # ]: 0 : String* pEntry = new String( aDoubleCapsLB.GetEntry( i ) );
1549 [ # # ][ # # ]: 0 : if( !pWrdList->insert( pEntry ).second)
1550 [ # # ][ # # ]: 0 : delete pEntry;
1551 : : }
1552 : 0 : pAutoCorrect->SaveWrdSttExceptList(eLang);
1553 : : }
1554 : :
1555 : 0 : SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eLang);
1556 : :
1557 [ # # ]: 0 : if(pCplList)
1558 : : {
1559 : 0 : sal_uInt16 nCount = pCplList->size();
1560 : : sal_uInt16 i;
1561 [ # # ]: 0 : for( i = nCount; i; )
1562 : : {
1563 : 0 : String* pString = (*pCplList)[ --i ];
1564 [ # # ]: 0 : if( USHRT_MAX == aAbbrevLB.GetEntryPos(*pString) )
1565 : : {
1566 [ # # ]: 0 : delete (*pCplList)[ i ];
1567 : 0 : pCplList->erase(i);
1568 : : }
1569 : : }
1570 : 0 : nCount = aAbbrevLB.GetEntryCount();
1571 [ # # ]: 0 : for( i = 0; i < nCount; ++i )
1572 : : {
1573 [ # # ][ # # ]: 0 : String* pEntry = new String( aAbbrevLB.GetEntry( i ) );
1574 [ # # ][ # # ]: 0 : if( !pCplList->insert( pEntry ).second)
1575 [ # # ][ # # ]: 0 : delete pEntry;
1576 : : }
1577 : 0 : pAutoCorrect->SaveCplSttExceptList(eLang);
1578 : : }
1579 [ # # ]: 0 : if(aAutoAbbrevCB.IsChecked() != aAutoAbbrevCB.GetSavedValue())
1580 : 0 : pAutoCorrect->SetAutoCorrFlag( SaveWordCplSttLst, aAutoAbbrevCB.IsChecked());
1581 [ # # ]: 0 : if(aAutoCapsCB.IsChecked() != aAutoCapsCB.GetSavedValue())
1582 : 0 : pAutoCorrect->SetAutoCorrFlag( SaveWordWrdSttLst, aAutoCapsCB.IsChecked());
1583 : 0 : return sal_False;
1584 : : }
1585 : :
1586 : 0 : void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet)
1587 : : {
1588 [ # # ]: 0 : if(eLang != eSet)
1589 : : {
1590 : : // save old settings and fill anew
1591 : 0 : RefillReplaceBoxes(sal_False, eLang, eSet);
1592 : 0 : eLastDialogLanguage = eSet;
1593 [ # # ]: 0 : delete pCompareClass;
1594 [ # # ]: 0 : pCompareClass = new CollatorWrapper( GetProcessFact() );
1595 : : pCompareClass->loadDefaultCollator( SvxCreateLocale( eLastDialogLanguage ),
1596 : : ::com::sun::star::i18n::
1597 [ # # ]: 0 : CollatorOptions::CollatorOptions_IGNORE_CASE );
1598 : 0 : ModifyHdl(&aAbbrevED);
1599 : 0 : ModifyHdl(&aDoubleCapsED);
1600 : : }
1601 : 0 : }
1602 : :
1603 : 0 : void OfaAutocorrExceptPage::RefillReplaceBoxes(sal_Bool bFromReset,
1604 : : LanguageType eOldLanguage,
1605 : : LanguageType eNewLanguage)
1606 : : {
1607 : 0 : eLang = eNewLanguage;
1608 [ # # ]: 0 : if(bFromReset)
1609 : 0 : lcl_ClearTable(aStringsTable);
1610 : : else
1611 : : {
1612 : : StringsArrays* pArrays;
1613 [ # # ][ # # ]: 0 : if(aStringsTable.find(eOldLanguage) != aStringsTable.end())
1614 : : {
1615 [ # # ]: 0 : pArrays = &aStringsTable[eOldLanguage];
1616 : 0 : pArrays->aAbbrevStrings.clear();
1617 : 0 : pArrays->aDoubleCapsStrings.clear();
1618 : : }
1619 : : else
1620 : : {
1621 [ # # ]: 0 : pArrays = &aStringsTable[eOldLanguage]; // create new array
1622 : : }
1623 : :
1624 : : sal_uInt16 i;
1625 [ # # ][ # # ]: 0 : for(i = 0; i < aAbbrevLB.GetEntryCount(); i++)
1626 [ # # ][ # # ]: 0 : pArrays->aAbbrevStrings.push_back(rtl::OUString(aAbbrevLB.GetEntry(i)));
[ # # ][ # # ]
1627 : :
1628 [ # # ][ # # ]: 0 : for(i = 0; i < aDoubleCapsLB.GetEntryCount(); i++)
1629 [ # # ][ # # ]: 0 : pArrays->aDoubleCapsStrings.push_back(rtl::OUString(aDoubleCapsLB.GetEntry(i)));
[ # # ][ # # ]
1630 : : }
1631 [ # # ]: 0 : aDoubleCapsLB.Clear();
1632 [ # # ]: 0 : aAbbrevLB.Clear();
1633 [ # # ]: 0 : String sTemp;
1634 [ # # ]: 0 : aAbbrevED.SetText(sTemp);
1635 [ # # ]: 0 : aDoubleCapsED.SetText(sTemp);
1636 : :
1637 [ # # ][ # # ]: 0 : if(aStringsTable.find(eLang) != aStringsTable.end())
1638 : : {
1639 [ # # ]: 0 : StringsArrays& rArrays = aStringsTable[eLang];
1640 [ # # ][ # # ]: 0 : for(std::vector<rtl::OUString>::iterator i = rArrays.aAbbrevStrings.begin(); i != rArrays.aAbbrevStrings.end(); ++i)
1641 [ # # ][ # # ]: 0 : aAbbrevLB.InsertEntry(*i);
[ # # ]
1642 : :
1643 [ # # ][ # # ]: 0 : for(std::vector<rtl::OUString>::iterator i = rArrays.aDoubleCapsStrings.begin(); i != rArrays.aDoubleCapsStrings.end(); ++i)
1644 [ # # ][ # # ]: 0 : aDoubleCapsLB.InsertEntry(*i);
[ # # ]
1645 : : }
1646 : : else
1647 : : {
1648 [ # # ]: 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1649 [ # # ]: 0 : const SvStringsISortDtor* pCplList = pAutoCorrect->GetCplSttExceptList(eLang);
1650 [ # # ]: 0 : const SvStringsISortDtor* pWrdList = pAutoCorrect->GetWrdSttExceptList(eLang);
1651 : : sal_uInt16 i;
1652 [ # # ]: 0 : for( i = 0; i < pCplList->size(); i++ )
1653 : : {
1654 [ # # ][ # # ]: 0 : aAbbrevLB.InsertEntry(*(*pCplList)[i]);
1655 : : }
1656 [ # # ]: 0 : for( i = 0; i < pWrdList->size(); i++ )
1657 : : {
1658 [ # # ][ # # ]: 0 : aDoubleCapsLB.InsertEntry(*(*pWrdList)[i]);
1659 : : }
1660 [ # # ]: 0 : }
1661 : 0 : }
1662 : :
1663 : 0 : void OfaAutocorrExceptPage::Reset( const SfxItemSet& )
1664 : : {
1665 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1666 : 0 : RefillReplaceBoxes(sal_True, eLang, eLang);
1667 : 0 : aAutoAbbrevCB. Check( pAutoCorrect->IsAutoCorrFlag( SaveWordCplSttLst ));
1668 : 0 : aAutoCapsCB. Check( pAutoCorrect->IsAutoCorrFlag( SaveWordWrdSttLst ));
1669 : 0 : aAutoAbbrevCB.SaveValue();
1670 : 0 : aAutoCapsCB.SaveValue();
1671 : 0 : }
1672 : :
1673 : 0 : IMPL_LINK(OfaAutocorrExceptPage, NewDelHdl, PushButton*, pBtn)
1674 : : {
1675 [ # # ]: 0 : if((pBtn == &aNewAbbrevPB || pBtn == (PushButton*)&aAbbrevED )
[ # # # # ]
[ # # ]
1676 [ # # ][ # # ]: 0 : && aAbbrevED.GetText().Len())
[ # # ]
1677 : : {
1678 [ # # ]: 0 : aAbbrevLB.InsertEntry(aAbbrevED.GetText());
1679 : 0 : ModifyHdl(&aAbbrevED);
1680 : : }
1681 [ # # ]: 0 : else if(pBtn == &aDelAbbrevPB)
1682 : : {
1683 [ # # ]: 0 : aAbbrevLB.RemoveEntry(aAbbrevED.GetText());
1684 : 0 : ModifyHdl(&aAbbrevED);
1685 : : }
1686 [ # # ]: 0 : else if((pBtn == &aNewDoublePB || pBtn == (PushButton*)&aDoubleCapsED )
[ # # # # ]
[ # # ]
1687 [ # # ][ # # ]: 0 : && aDoubleCapsED.GetText().Len())
[ # # ]
1688 : : {
1689 [ # # ]: 0 : aDoubleCapsLB.InsertEntry(aDoubleCapsED.GetText());
1690 : 0 : ModifyHdl(&aDoubleCapsED);
1691 : : }
1692 [ # # ]: 0 : else if(pBtn == &aDelDoublePB)
1693 : : {
1694 [ # # ]: 0 : aDoubleCapsLB.RemoveEntry(aDoubleCapsED.GetText());
1695 : 0 : ModifyHdl(&aDoubleCapsED);
1696 : : }
1697 : 0 : return 0;
1698 : : }
1699 : :
1700 : 0 : IMPL_LINK(OfaAutocorrExceptPage, SelectHdl, ListBox*, pBox)
1701 : : {
1702 [ # # ]: 0 : if(pBox == &aAbbrevLB)
1703 : : {
1704 [ # # ]: 0 : aAbbrevED.SetText(pBox->GetSelectEntry());
1705 : 0 : aNewAbbrevPB.Enable(sal_False);
1706 : 0 : aDelAbbrevPB.Enable();
1707 : : }
1708 : : else
1709 : : {
1710 [ # # ]: 0 : aDoubleCapsED.SetText(pBox->GetSelectEntry());
1711 : 0 : aNewDoublePB.Enable(sal_False);
1712 : 0 : aDelDoublePB.Enable();
1713 : : }
1714 : 0 : return 0;
1715 : : }
1716 : :
1717 : 0 : IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, Edit*, pEdt)
1718 : : {
1719 : : // sal_Bool bSame = pEdt->GetText() == ->GetSelectEntry();
1720 : 0 : const String& sEntry = pEdt->GetText();
1721 : 0 : sal_Bool bEntryLen = 0!= sEntry.Len();
1722 [ # # ]: 0 : if(pEdt == &aAbbrevED)
1723 : : {
1724 [ # # ]: 0 : sal_Bool bSame = lcl_FindEntry(aAbbrevLB, sEntry, *pCompareClass);
1725 [ # # ][ # # ]: 0 : if(bSame && sEntry != aAbbrevLB.GetSelectEntry())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1726 [ # # ][ # # ]: 0 : pEdt->SetText(aAbbrevLB.GetSelectEntry());
[ # # ]
1727 [ # # ][ # # ]: 0 : aNewAbbrevPB.Enable(!bSame && bEntryLen);
[ # # ]
1728 [ # # ][ # # ]: 0 : aDelAbbrevPB.Enable(bSame && bEntryLen);
[ # # ]
1729 : : }
1730 : : else
1731 : : {
1732 [ # # ]: 0 : sal_Bool bSame = lcl_FindEntry(aDoubleCapsLB, sEntry, *pCompareClass);
1733 [ # # ][ # # ]: 0 : if(bSame && sEntry != aDoubleCapsLB.GetSelectEntry())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1734 [ # # ][ # # ]: 0 : pEdt->SetText(aDoubleCapsLB.GetSelectEntry());
[ # # ]
1735 [ # # ][ # # ]: 0 : aNewDoublePB.Enable(!bSame && bEntryLen);
[ # # ]
1736 [ # # ][ # # ]: 0 : aDelDoublePB.Enable(bSame && bEntryLen);
[ # # ]
1737 : : }
1738 : 0 : return 0;
1739 : : }
1740 : :
1741 : 0 : void AutoCorrEdit::KeyInput( const KeyEvent& rKEvt )
1742 : : {
1743 : 0 : const KeyCode aKeyCode = rKEvt.GetKeyCode();
1744 : 0 : const sal_uInt16 nModifier = aKeyCode.GetModifier();
1745 [ # # ]: 0 : if( aKeyCode.GetCode() == KEY_RETURN )
1746 : : {
1747 : : // if there's nothing done on enter, call the
1748 : : // base class after all to close the dialog
1749 [ # # ][ # # ]: 0 : if(!nModifier && !aActionLink.Call(this))
[ # # ][ # # ]
1750 [ # # ]: 0 : Edit::KeyInput(rKEvt);
1751 : : }
1752 [ # # ][ # # ]: 0 : else if(bSpaces || aKeyCode.GetCode() != KEY_SPACE)
[ # # ]
1753 [ # # ]: 0 : Edit::KeyInput(rKEvt);
1754 : 0 : }
1755 : :
1756 : : enum OfaQuoteOptions
1757 : : {
1758 : : ADD_NONBRK_SPACE,
1759 : : REPLACE_1ST
1760 : : };
1761 : :
1762 : 0 : SvLBoxEntry* OfaQuoteTabPage::CreateEntry(String& rTxt, sal_uInt16 nCol)
1763 : : {
1764 [ # # ][ # # ]: 0 : SvLBoxEntry* pEntry = new SvLBoxEntry;
1765 : :
1766 [ # # ]: 0 : if ( !pCheckButtonData )
1767 : : {
1768 [ # # ][ # # ]: 0 : pCheckButtonData = new SvLBoxButtonData( &aSwCheckLB );
1769 [ # # ]: 0 : aSwCheckLB.SetCheckButtonData( pCheckButtonData );
1770 : : }
1771 : :
1772 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1773 : :
1774 [ # # ]: 0 : String sEmpty;
1775 [ # # ]: 0 : if (nCol == CBCOL_SECOND)
1776 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) );
[ # # ][ # # ]
1777 : : else
1778 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) );
[ # # ]
1779 : :
1780 [ # # ]: 0 : if (nCol == CBCOL_FIRST)
1781 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) );
[ # # ][ # # ]
1782 : : else
1783 [ # # ][ # # ]: 0 : pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) );
[ # # ]
1784 : :
1785 [ # # ][ # # ]: 0 : pEntry->AddItem( new OfaImpBrwString( pEntry, 0, rTxt ) );
[ # # ]
1786 : :
1787 [ # # ]: 0 : return pEntry;
1788 : : }
1789 : :
1790 : 0 : OfaQuoteTabPage::OfaQuoteTabPage( Window* pParent, const SfxItemSet& rSet ) :
1791 : 0 : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCORR_QUOTE ), rSet),
1792 [ # # ]: 0 : aCheckLB (this, CUI_RES(CLB_SETTINGS )),
1793 [ # # ]: 0 : m_aSwCheckLBContainer(this, CUI_RES(CLB_SETTINGS)),
1794 : : aSwCheckLB(m_aSwCheckLBContainer),
1795 [ # # ]: 0 : sHeader1 (CUI_RES( STR_HEADER1 )),
1796 [ # # ]: 0 : sHeader2 (CUI_RES( STR_HEADER2 )),
1797 [ # # ]: 0 : sNonBrkSpace (CUI_RES( ST_NON_BREAK_SPACE )),
1798 [ # # ]: 0 : sOrdinal (CUI_RES( ST_ORDINAL )),
1799 : : pCheckButtonData ( NULL ),
1800 : :
1801 [ # # ]: 0 : aSingleFL (this, CUI_RES(FL_SINGLE )),
1802 [ # # ]: 0 : aSingleTypoCB (this, CUI_RES(CB_SGL_TYPO )),
1803 [ # # ]: 0 : aSglStartQuoteFT (this, CUI_RES(FT_SGL_STARTQUOTE )),
1804 [ # # ]: 0 : aSglStartQuotePB (this, CUI_RES(PB_SGL_STARTQUOTE )),
1805 [ # # ]: 0 : aSglStartExFT (this, CUI_RES(FT_SGSTEX )),
1806 [ # # ]: 0 : aSglEndQuoteFT (this, CUI_RES(FT_SGL_ENDQUOTE )),
1807 [ # # ]: 0 : aSglEndQuotePB (this, CUI_RES(PB_SGL_ENDQUOTE )),
1808 [ # # ]: 0 : aSglEndExFT (this, CUI_RES(FT_SGENEX )),
1809 [ # # ]: 0 : aSglStandardPB (this, CUI_RES(PB_SGL_STD )),
1810 : :
1811 [ # # ]: 0 : aDoubleFL (this, CUI_RES(FL_DOUBLE )),
1812 [ # # ]: 0 : aTypoCB (this, CUI_RES(CB_TYPO )),
1813 [ # # ]: 0 : aStartQuoteFT (this, CUI_RES(FT_STARTQUOTE )),
1814 [ # # ]: 0 : aStartQuotePB (this, CUI_RES(PB_STARTQUOTE )),
1815 [ # # ]: 0 : aDblStartExFT (this, CUI_RES(FT_DBSTEX )),
1816 [ # # ]: 0 : aEndQuoteFT (this, CUI_RES(FT_ENDQUOTE )),
1817 [ # # ]: 0 : aEndQuotePB (this, CUI_RES(PB_ENDQUOTE )),
1818 [ # # ]: 0 : aDblEndExFT (this, CUI_RES(FT_DBECEX )),
1819 [ # # ]: 0 : aDblStandardPB (this, CUI_RES(PB_DBL_STD )),
1820 : :
1821 [ # # ]: 0 : sStartQuoteDlg (CUI_RES(STR_CHANGE_START)),
1822 [ # # ]: 0 : sEndQuoteDlg (CUI_RES(STR_CHANGE_END)),
1823 : :
1824 [ # # ][ # # ]: 0 : sStandard(CUI_RES(ST_STANDARD))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1825 : : {
1826 [ # # ][ # # ]: 0 : aSglStandardPB.SetAccessibleName(String(CUI_RES(STR_PB_SGL_STD) ) );
[ # # ][ # # ]
1827 [ # # ][ # # ]: 0 : aDblStandardPB.SetAccessibleName(String(CUI_RES(STR_PB_DBL_STD) ) );
[ # # ][ # # ]
1828 [ # # ][ # # ]: 0 : aStartQuotePB.SetAccessibleName( String(CUI_RES(STR_PB_DBL_START) ));
[ # # ][ # # ]
1829 [ # # ][ # # ]: 0 : aEndQuotePB.SetAccessibleName(String(CUI_RES(STR_PB_DBL_END) ));
[ # # ][ # # ]
1830 [ # # ][ # # ]: 0 : aSglStartQuotePB.SetAccessibleName(String(CUI_RES(STR_PB_SGL_START) ));
[ # # ][ # # ]
1831 [ # # ][ # # ]: 0 : aSglEndQuotePB.SetAccessibleName(String(CUI_RES(STR_PB_SGL_END) ) );
[ # # ][ # # ]
1832 : :
1833 [ # # ]: 0 : FreeResource();
1834 : :
1835 : 0 : sal_Bool bShowSWOptions = sal_False;
1836 : :
1837 [ # # ]: 0 : aCheckLB.SetHelpId( HID_OFAPAGE_QUOTE_CLB );
1838 [ # # ]: 0 : aSwCheckLB.SetHelpId( HID_OFAPAGE_QUOTE_SW_CLB );
1839 : :
1840 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( &rSet, pItem, SfxBoolItem, SID_AUTO_CORRECT_DLG, sal_False );
1841 [ # # ][ # # ]: 0 : if ( pItem && pItem->GetValue() )
[ # # ]
1842 : 0 : bShowSWOptions = sal_True;
1843 : :
1844 [ # # ]: 0 : if ( bShowSWOptions )
1845 : : {
1846 : : static long aStaticTabs[]=
1847 : : {
1848 : : 3, 0, 20, 40
1849 : : };
1850 : :
1851 [ # # ][ # # ]: 0 : aSwCheckLB.SetStyle(aSwCheckLB.GetStyle() | WB_HSCROLL| WB_VSCROLL);
1852 : :
1853 [ # # ]: 0 : aSwCheckLB.SvxSimpleTable::SetTabs(aStaticTabs);
1854 [ # # ]: 0 : String sHeader( sHeader1 );
1855 [ # # ]: 0 : sHeader += '\t';
1856 [ # # ]: 0 : sHeader += sHeader2;
1857 [ # # ]: 0 : sHeader += '\t';
1858 : : aSwCheckLB.InsertHeaderEntry( sHeader, HEADERBAR_APPEND,
1859 [ # # ][ # # ]: 0 : HIB_CENTER | HIB_VCENTER | HIB_FIXEDPOS | HIB_FIXED);
1860 [ # # ][ # # ]: 0 : aCheckLB.Hide( sal_True );
1861 : : }
1862 : : else
1863 : : {
1864 [ # # ]: 0 : aSwCheckLB.HideTable( );
1865 : : }
1866 : :
1867 [ # # ]: 0 : aStartQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl));
1868 [ # # ]: 0 : aEndQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl));
1869 [ # # ]: 0 : aSglStartQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl));
1870 [ # # ]: 0 : aSglEndQuotePB.SetClickHdl(LINK(this, OfaQuoteTabPage, QuoteHdl));
1871 [ # # ]: 0 : aDblStandardPB.SetClickHdl(LINK(this, OfaQuoteTabPage, StdQuoteHdl));
1872 [ # # ]: 0 : aSglStandardPB.SetClickHdl(LINK(this, OfaQuoteTabPage, StdQuoteHdl));
1873 : :
1874 [ # # ]: 0 : aSglStartQuotePB.SetAccessibleRelationLabeledBy( &aSglStartQuoteFT );
1875 [ # # ]: 0 : aSglEndQuotePB.SetAccessibleRelationLabeledBy( &aSglEndQuoteFT );
1876 [ # # ]: 0 : aSglStartQuotePB.SetAccessibleRelationMemberOf( &aSingleFL );
1877 [ # # ]: 0 : aSglEndQuotePB.SetAccessibleRelationMemberOf( &aSingleFL );
1878 [ # # ]: 0 : aStartQuotePB.SetAccessibleRelationLabeledBy( &aStartQuoteFT );
1879 [ # # ]: 0 : aEndQuotePB.SetAccessibleRelationLabeledBy( &aEndQuoteFT );
1880 [ # # ]: 0 : aStartQuotePB.SetAccessibleRelationMemberOf( &aDoubleFL );
1881 [ # # ]: 0 : aEndQuotePB.SetAccessibleRelationMemberOf( &aDoubleFL );
1882 [ # # ]: 0 : aSglStandardPB.SetAccessibleRelationMemberOf(&aSingleFL);
1883 [ # # ]: 0 : aDblStandardPB.SetAccessibleRelationMemberOf(&aDoubleFL);
1884 : 0 : }
1885 : :
1886 [ # # ][ # # ]: 0 : OfaQuoteTabPage::~OfaQuoteTabPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1887 : : {
1888 [ # # ][ # # ]: 0 : delete( pCheckButtonData );
1889 [ # # ]: 0 : }
1890 : :
1891 : 0 : SfxTabPage* OfaQuoteTabPage::Create( Window* pParent,
1892 : : const SfxItemSet& rAttrSet)
1893 : : {
1894 [ # # ]: 0 : return new OfaQuoteTabPage(pParent, rAttrSet);
1895 : : }
1896 : :
1897 : 0 : sal_Bool OfaQuoteTabPage::FillItemSet( SfxItemSet& )
1898 : : {
1899 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1900 : :
1901 : 0 : long nFlags = pAutoCorrect->GetFlags();
1902 : :
1903 [ # # ]: 0 : if ( aCheckLB.IsVisible( ) )
1904 : : {
1905 : 0 : sal_uInt16 nPos = 0;
1906 : 0 : pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, aCheckLB.IsChecked(nPos++));
1907 : 0 : pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, aCheckLB.IsChecked(nPos++));
1908 : : }
1909 : :
1910 : 0 : sal_Bool bModified = sal_False;
1911 [ # # ]: 0 : if ( aSwCheckLB.IsVisible( ) )
1912 : : {
1913 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
1914 : :
1915 : 0 : sal_Bool bCheck = aSwCheckLB.IsChecked(ADD_NONBRK_SPACE, CBCOL_FIRST);
1916 : 0 : bModified |= pOpt->bAddNonBrkSpace != bCheck;
1917 : 0 : pOpt->bAddNonBrkSpace = bCheck;
1918 : : pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace,
1919 : 0 : aSwCheckLB.IsChecked(ADD_NONBRK_SPACE, CBCOL_SECOND));
1920 : :
1921 : 0 : bCheck = aSwCheckLB.IsChecked(REPLACE_1ST, CBCOL_FIRST);
1922 : 0 : bModified |= pOpt->bChgOrdinalNumber != bCheck;
1923 : 0 : pOpt->bChgOrdinalNumber = bCheck;
1924 : : pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber,
1925 : 0 : aSwCheckLB.IsChecked(REPLACE_1ST, CBCOL_SECOND));
1926 : : }
1927 : :
1928 : 0 : pAutoCorrect->SetAutoCorrFlag(ChgQuotes, aTypoCB.IsChecked());
1929 : 0 : pAutoCorrect->SetAutoCorrFlag(ChgSglQuotes, aSingleTypoCB.IsChecked());
1930 : 0 : sal_Bool bReturn = nFlags != pAutoCorrect->GetFlags();
1931 [ # # ]: 0 : if(cStartQuote != pAutoCorrect->GetStartDoubleQuote())
1932 : : {
1933 : 0 : bReturn = sal_True;
1934 : 0 : sal_Unicode cUCS2 = static_cast<sal_Unicode>(cStartQuote); //TODO
1935 : 0 : pAutoCorrect->SetStartDoubleQuote(cUCS2);
1936 : : }
1937 [ # # ]: 0 : if(cEndQuote != pAutoCorrect->GetEndDoubleQuote())
1938 : : {
1939 : 0 : bReturn = sal_True;
1940 : 0 : sal_Unicode cUCS2 = static_cast<sal_Unicode>(cEndQuote); //TODO
1941 : 0 : pAutoCorrect->SetEndDoubleQuote(cUCS2);
1942 : : }
1943 [ # # ]: 0 : if(cSglStartQuote != pAutoCorrect->GetStartSingleQuote())
1944 : : {
1945 : 0 : bReturn = sal_True;
1946 : 0 : sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglStartQuote); //TODO
1947 : 0 : pAutoCorrect->SetStartSingleQuote(cUCS2);
1948 : : }
1949 [ # # ]: 0 : if(cSglEndQuote != pAutoCorrect->GetEndSingleQuote())
1950 : : {
1951 : 0 : bReturn = sal_True;
1952 : 0 : sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglEndQuote); //TODO
1953 : 0 : pAutoCorrect->SetEndSingleQuote(cUCS2);
1954 : : }
1955 : :
1956 [ # # ][ # # ]: 0 : if( bModified || bReturn )
1957 : : {
1958 : 0 : SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
1959 : 0 : rCfg.SetModified();
1960 : 0 : rCfg.Commit();
1961 : : }
1962 : 0 : return bReturn;
1963 : : }
1964 : :
1965 : 0 : void OfaQuoteTabPage::ActivatePage( const SfxItemSet& )
1966 : : {
1967 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage(sal_False);
1968 : 0 : }
1969 : :
1970 : 0 : void OfaQuoteTabPage::Reset( const SfxItemSet& )
1971 : : {
1972 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1973 : 0 : const long nFlags = pAutoCorrect->GetFlags();
1974 : :
1975 : : // Initialize the Sw options
1976 [ # # ]: 0 : if ( aSwCheckLB.IsVisible( ) )
1977 : : {
1978 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
1979 : :
1980 : 0 : aSwCheckLB.SetUpdateMode( sal_False );
1981 : 0 : aSwCheckLB.Clear();
1982 : :
1983 : 0 : aSwCheckLB.GetModel()->Insert(CreateEntry(sNonBrkSpace, CBCOL_BOTH ));
1984 : 0 : aSwCheckLB.GetModel()->Insert(CreateEntry(sOrdinal, CBCOL_BOTH ));
1985 : :
1986 : 0 : aSwCheckLB.CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_FIRST, pOpt->bAddNonBrkSpace );
1987 : 0 : aSwCheckLB.CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_SECOND, 0 != (nFlags & AddNonBrkSpace) );
1988 : 0 : aSwCheckLB.CheckEntryPos( REPLACE_1ST, CBCOL_FIRST, pOpt->bChgOrdinalNumber );
1989 : 0 : aSwCheckLB.CheckEntryPos( REPLACE_1ST, CBCOL_SECOND, 0 != (nFlags & ChgOrdinalNumber) );
1990 : :
1991 : 0 : aSwCheckLB.SetUpdateMode( sal_True );
1992 : : }
1993 : :
1994 : : // Initialize the non Sw options
1995 [ # # ]: 0 : if ( aCheckLB.IsVisible( ) )
1996 : : {
1997 : 0 : aCheckLB.SetUpdateMode( sal_False );
1998 : 0 : aCheckLB.Clear( );
1999 : :
2000 : 0 : aCheckLB.InsertEntry( sNonBrkSpace );
2001 : 0 : aCheckLB.InsertEntry( sOrdinal );
2002 : :
2003 : 0 : sal_uInt16 nPos = 0;
2004 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & AddNonBrkSpace) );
2005 : 0 : aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgOrdinalNumber) );
2006 : :
2007 : 0 : aCheckLB.SetUpdateMode( sal_True );
2008 : : }
2009 : :
2010 : : // Initialize the quote stuffs
2011 : 0 : aTypoCB .Check(0 != (nFlags & ChgQuotes));
2012 : 0 : aSingleTypoCB .Check(0 != (nFlags & ChgSglQuotes));
2013 : 0 : aTypoCB .SaveValue();
2014 : 0 : aSingleTypoCB .SaveValue();
2015 : :
2016 : 0 : cStartQuote = pAutoCorrect->GetStartDoubleQuote();
2017 : 0 : cEndQuote = pAutoCorrect->GetEndDoubleQuote();
2018 : 0 : cSglStartQuote = pAutoCorrect->GetStartSingleQuote();
2019 : 0 : cSglEndQuote = pAutoCorrect->GetEndSingleQuote();
2020 : :
2021 [ # # ]: 0 : aSglStartExFT .SetText(ChangeStringExt_Impl(cSglStartQuote));
2022 [ # # ]: 0 : aSglEndExFT .SetText(ChangeStringExt_Impl(cSglEndQuote));
2023 [ # # ]: 0 : aDblStartExFT .SetText(ChangeStringExt_Impl(cStartQuote));
2024 [ # # ]: 0 : aDblEndExFT .SetText(ChangeStringExt_Impl(cEndQuote));
2025 : 0 : }
2026 : :
2027 : : #define SGL_START 0
2028 : : #define DBL_START 1
2029 : : #define SGL_END 2
2030 : : #define DBL_END 3
2031 : :
2032 : :
2033 : 0 : IMPL_LINK( OfaQuoteTabPage, QuoteHdl, PushButton*, pBtn )
2034 : : {
2035 : 0 : sal_uInt16 nMode = SGL_START;
2036 [ # # ]: 0 : if(pBtn == &aSglEndQuotePB)
2037 : 0 : nMode = SGL_END;
2038 [ # # ]: 0 : else if(pBtn == &aStartQuotePB)
2039 : 0 : nMode = DBL_START;
2040 [ # # ]: 0 : else if(pBtn == &aEndQuotePB)
2041 : 0 : nMode = DBL_END;
2042 : : // start character selection dialog
2043 [ # # ]: 0 : SvxCharacterMap* pMap = new SvxCharacterMap( this, sal_True );
2044 : : pMap->SetCharFont( OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT,
2045 [ # # ]: 0 : LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE, 0 ));
2046 [ # # ]: 0 : pMap->SetText(nMode < SGL_END ? sStartQuoteDlg : sEndQuoteDlg );
2047 : : sal_UCS4 cDlg;
2048 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
2049 : 0 : LanguageType eLang = Application::GetSettings().GetLanguage();
2050 [ # # # # : 0 : switch( nMode )
# ]
2051 : : {
2052 : : case SGL_START:
2053 : 0 : cDlg = cSglStartQuote;
2054 [ # # ]: 0 : if(cDlg == 0)
2055 : 0 : cDlg = pAutoCorrect->GetQuote('\'', sal_True, eLang);
2056 : 0 : break;
2057 : : case SGL_END:
2058 : 0 : cDlg = cSglEndQuote;
2059 [ # # ]: 0 : if(cDlg == 0)
2060 : 0 : cDlg = pAutoCorrect->GetQuote('\'', sal_False, eLang);
2061 : 0 : break;
2062 : : case DBL_START:
2063 : 0 : cDlg = cStartQuote;
2064 [ # # ]: 0 : if(cDlg == 0)
2065 : 0 : cDlg = pAutoCorrect->GetQuote('\"', sal_True, eLang);
2066 : 0 : break;
2067 : : case DBL_END:
2068 : 0 : cDlg = cEndQuote;
2069 [ # # ]: 0 : if(cDlg == 0)
2070 : 0 : cDlg = pAutoCorrect->GetQuote('\"', sal_False, eLang);
2071 : 0 : break;
2072 : : default:
2073 : : OSL_FAIL("svx::OfaQuoteTabPage::QuoteHdl(), how to initialize cDlg?" );
2074 : 0 : cDlg = 0;
2075 : 0 : break;
2076 : :
2077 : : }
2078 : 0 : pMap->SetChar( cDlg );
2079 : 0 : pMap->DisableFontSelection();
2080 [ # # ]: 0 : if(pMap->Execute() == RET_OK)
2081 : : {
2082 : 0 : sal_UCS4 cNewChar = pMap->GetChar();
2083 [ # # # # : 0 : switch( nMode )
# ]
2084 : : {
2085 : : case SGL_START:
2086 : 0 : cSglStartQuote = cNewChar;
2087 [ # # ]: 0 : aSglStartExFT.SetText(ChangeStringExt_Impl(cNewChar));
2088 : 0 : break;
2089 : : case SGL_END:
2090 : 0 : cSglEndQuote = cNewChar;
2091 [ # # ]: 0 : aSglEndExFT.SetText(ChangeStringExt_Impl(cNewChar));
2092 : 0 : break;
2093 : : case DBL_START:
2094 : 0 : cStartQuote = cNewChar;
2095 [ # # ]: 0 : aDblStartExFT.SetText(ChangeStringExt_Impl(cNewChar));
2096 : 0 : break;
2097 : : case DBL_END:
2098 : 0 : cEndQuote = cNewChar;
2099 [ # # ]: 0 : aDblEndExFT.SetText(ChangeStringExt_Impl(cNewChar));
2100 : 0 : break;
2101 : : }
2102 : : }
2103 [ # # ]: 0 : delete pMap;
2104 : :
2105 : 0 : return 0;
2106 : : }
2107 : :
2108 : 0 : IMPL_LINK( OfaQuoteTabPage, StdQuoteHdl, PushButton*, pBtn )
2109 : : {
2110 [ # # ]: 0 : if(pBtn == &aDblStandardPB)
2111 : : {
2112 : 0 : cStartQuote = 0;
2113 [ # # ]: 0 : aDblStartExFT.SetText(ChangeStringExt_Impl(0));
2114 : 0 : cEndQuote = 0;
2115 [ # # ]: 0 : aDblEndExFT.SetText(ChangeStringExt_Impl(0));
2116 : :
2117 : : }
2118 : : else
2119 : : {
2120 : 0 : cSglStartQuote = 0;
2121 [ # # ]: 0 : aSglStartExFT.SetText(ChangeStringExt_Impl(0));
2122 : 0 : cSglEndQuote = 0;
2123 [ # # ]: 0 : aSglEndExFT.SetText(ChangeStringExt_Impl(0));
2124 : : }
2125 : 0 : return 0;
2126 : : }
2127 : :
2128 : : // --------------------------------------------------
2129 : :
2130 : 0 : String OfaQuoteTabPage::ChangeStringExt_Impl( sal_UCS4 cChar )
2131 : : {
2132 [ # # ]: 0 : if( !cChar )
2133 [ # # ]: 0 : return sStandard;
2134 : :
2135 : : // convert codepoint value to unicode-hex string
2136 : 0 : sal_UCS4 aStrCodes[32] = { 0, ' ', '(', 'U', '+', '0' };
2137 : 0 : aStrCodes[0] = cChar;
2138 : 0 : int nFullLen = 5;
2139 : 0 : int nHexLen = 4;
2140 [ # # ]: 0 : while( (cChar >> (4*nHexLen)) != 0 )
2141 : 0 : ++nHexLen;
2142 [ # # ]: 0 : for( int i = nHexLen; --i >= 0;)
2143 : : {
2144 : 0 : sal_UCS4 cHexDigit = ((cChar >> (4*i)) & 0x0f) + '0';
2145 [ # # ]: 0 : if( cHexDigit > '9' )
2146 : 0 : cHexDigit += 'A' - ('9' + 1);
2147 : 0 : aStrCodes[ nFullLen++ ] = cHexDigit;
2148 : : }
2149 : 0 : aStrCodes[ nFullLen++ ] = ')';
2150 : : // using the new UCS4 constructor
2151 [ # # ]: 0 : rtl::OUString aOUStr( aStrCodes, nFullLen );
2152 [ # # ]: 0 : return aOUStr;
2153 : : }
2154 : :
2155 : 0 : OfaAutoCompleteTabPage::OfaAutoCompleteTabPage( Window* pParent,
2156 : : const SfxItemSet& rSet )
2157 : 0 : : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_AUTOCOMPLETE_OPTIONS ), rSet),
2158 [ # # ]: 0 : aCBActiv (this, CUI_RES(CB_ACTIV)),
2159 [ # # ]: 0 : aCBAppendSpace (this, CUI_RES(CB_APPEND_SPACE)),
2160 [ # # ]: 0 : aCBAsTip (this, CUI_RES(CB_AS_TIP)),
2161 [ # # ]: 0 : aCBCollect (this, CUI_RES(CB_COLLECT)),
2162 [ # # ]: 0 : aCBRemoveList (this, CUI_RES(CB_REMOVE_LIST)),
2163 [ # # ]: 0 : aFTExpandKey (this, CUI_RES(FT_EXPAND_KEY)),
2164 [ # # ]: 0 : aDCBExpandKey (this, CUI_RES(DCB_EXPAND_KEY)),
2165 [ # # ]: 0 : aFTMinWordlen (this, CUI_RES(FT_MIN_WORDLEN)),
2166 [ # # ]: 0 : aNFMinWordlen (this, CUI_RES(NF_MIN_WORDLEN)),
2167 [ # # ]: 0 : aFTMaxEntries (this, CUI_RES(FT_MAX_ENTRIES)),
2168 [ # # ]: 0 : aNFMaxEntries (this, CUI_RES(NF_MAX_ENTRIES)),
2169 [ # # ]: 0 : aLBEntries (*this, CUI_RES(LB_ENTRIES)),
2170 [ # # ]: 0 : aPBEntries (this, CUI_RES(PB_ENTRIES)),
2171 : : m_pAutoCompleteList( 0 ),
2172 [ # # ][ # # ]: 0 : nAutoCmpltListCnt( 0 )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2173 : : {
2174 [ # # ]: 0 : FreeResource();
2175 : :
2176 : : // the defined KEYs
2177 : : static const sal_uInt16 aKeyCodes[] = {
2178 : : KEY_END,
2179 : : KEY_RETURN,
2180 : : KEY_SPACE,
2181 : : KEY_RIGHT,
2182 : : KEY_TAB,
2183 : : 0
2184 : : };
2185 : :
2186 [ # # ]: 0 : for( const sal_uInt16* pKeys = aKeyCodes; *pKeys; ++pKeys )
2187 : : {
2188 : 0 : KeyCode aKCode( *pKeys );
2189 [ # # ][ # # ]: 0 : sal_uInt16 nPos = aDCBExpandKey.InsertEntry( aKCode.GetName() );
[ # # ]
2190 [ # # ]: 0 : aDCBExpandKey.SetEntryData( nPos, (void*)(sal_uLong)*pKeys );
2191 [ # # ]: 0 : if( KEY_RETURN == *pKeys ) // default to RETURN
2192 [ # # ]: 0 : aDCBExpandKey.SelectEntryPos( nPos );
2193 : : }
2194 : :
2195 [ # # ]: 0 : aPBEntries.SetClickHdl(LINK(this, OfaAutoCompleteTabPage, DeleteHdl));
2196 [ # # ]: 0 : aCBActiv.SetToggleHdl(LINK(this, OfaAutoCompleteTabPage, CheckHdl));
2197 [ # # ]: 0 : aCBCollect.SetToggleHdl(LINK(this, OfaAutoCompleteTabPage, CheckHdl));
2198 [ # # ]: 0 : aLBEntries.SetAccessibleRelationLabeledBy(&aLBEntries);
2199 : 0 : }
2200 : :
2201 [ # # ][ # # ]: 0 : OfaAutoCompleteTabPage::~OfaAutoCompleteTabPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2202 : : {
2203 [ # # ]: 0 : }
2204 : :
2205 : 0 : SfxTabPage* OfaAutoCompleteTabPage::Create( Window* pParent,
2206 : : const SfxItemSet& rSet)
2207 : : {
2208 [ # # ]: 0 : return new OfaAutoCompleteTabPage( pParent, rSet );
2209 : : }
2210 : :
2211 : 0 : sal_Bool OfaAutoCompleteTabPage::FillItemSet( SfxItemSet& )
2212 : : {
2213 : 0 : sal_Bool bModified = sal_False, bCheck;
2214 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
2215 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
2216 : : sal_uInt16 nVal;
2217 : :
2218 : 0 : bCheck = aCBActiv.IsChecked();
2219 : 0 : bModified |= pOpt->bAutoCompleteWords != bCheck;
2220 : 0 : pOpt->bAutoCompleteWords = bCheck;
2221 : 0 : bCheck = aCBCollect.IsChecked();
2222 : 0 : bModified |= pOpt->bAutoCmpltCollectWords != bCheck;
2223 : 0 : pOpt->bAutoCmpltCollectWords = bCheck;
2224 : 0 : bCheck = !aCBRemoveList.IsChecked(); // inverted value!
2225 : 0 : bModified |= pOpt->bAutoCmpltKeepList != bCheck;
2226 : 0 : pOpt->bAutoCmpltKeepList = bCheck;
2227 : 0 : bCheck = aCBAppendSpace.IsChecked();
2228 : 0 : bModified |= pOpt->bAutoCmpltAppendBlanc != bCheck;
2229 : 0 : pOpt->bAutoCmpltAppendBlanc = bCheck;
2230 : 0 : bCheck = aCBAsTip.IsChecked();
2231 : 0 : bModified |= pOpt->bAutoCmpltShowAsTip != bCheck;
2232 : 0 : pOpt->bAutoCmpltShowAsTip = bCheck;
2233 : :
2234 : 0 : nVal = (sal_uInt16)aNFMinWordlen.GetValue();
2235 : 0 : bModified |= nVal != pOpt->nAutoCmpltWordLen;
2236 : 0 : pOpt->nAutoCmpltWordLen = nVal;
2237 : :
2238 : 0 : nVal = (sal_uInt16)aNFMaxEntries.GetValue();
2239 : 0 : bModified |= nVal != pOpt->nAutoCmpltListLen;
2240 : 0 : pOpt->nAutoCmpltListLen = nVal;
2241 : :
2242 : 0 : nVal = aDCBExpandKey.GetSelectEntryPos();
2243 [ # # ]: 0 : if( nVal < aDCBExpandKey.GetEntryCount() )
2244 : : {
2245 : 0 : sal_uLong nKey = (sal_uLong)aDCBExpandKey.GetEntryData( nVal );
2246 : 0 : bModified |= nKey != pOpt->nAutoCmpltExpandKey;
2247 : 0 : pOpt->nAutoCmpltExpandKey = (sal_uInt16)nKey;
2248 : : }
2249 : :
2250 [ # # ][ # # ]: 0 : if (m_pAutoCompleteList && nAutoCmpltListCnt != aLBEntries.GetEntryCount())
[ # # ]
2251 : : {
2252 : 0 : bModified = sal_True;
2253 : 0 : pOpt->m_pAutoCompleteList = m_pAutoCompleteList;
2254 : : }
2255 [ # # ]: 0 : if( bModified )
2256 : : {
2257 : 0 : SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
2258 : 0 : rCfg.SetModified();
2259 : 0 : rCfg.Commit();
2260 : : }
2261 : 0 : return sal_True;
2262 : : }
2263 : :
2264 : 0 : void OfaAutoCompleteTabPage::Reset( const SfxItemSet& )
2265 : : {
2266 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
2267 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
2268 : :
2269 : 0 : aCBActiv.Check( 0 != pOpt->bAutoCompleteWords );
2270 : 0 : aCBCollect.Check( 0 != pOpt->bAutoCmpltCollectWords );
2271 : 0 : aCBRemoveList.Check( !pOpt->bAutoCmpltKeepList ); //inverted value!
2272 : 0 : aCBAppendSpace.Check( 0 != pOpt->bAutoCmpltAppendBlanc );
2273 : 0 : aCBAsTip.Check( 0 != pOpt->bAutoCmpltShowAsTip );
2274 : :
2275 : 0 : aNFMinWordlen.SetValue( pOpt->nAutoCmpltWordLen );
2276 : 0 : aNFMaxEntries.SetValue( pOpt->nAutoCmpltListLen );
2277 : :
2278 : : // select the specific KeyCode:
2279 : : {
2280 : 0 : sal_uLong nKey = pOpt->nAutoCmpltExpandKey;
2281 [ # # ]: 0 : for( sal_uInt16 n = 0, nCnt = aDCBExpandKey.GetEntryCount(); n < nCnt; ++n )
2282 [ # # ]: 0 : if( nKey == (sal_uLong)aDCBExpandKey.GetEntryData( n ))
2283 : : {
2284 : 0 : aDCBExpandKey.SelectEntryPos( n );
2285 : 0 : break;
2286 : : }
2287 : : }
2288 : :
2289 [ # # ][ # # ]: 0 : if (pOpt->m_pAutoCompleteList && pOpt->m_pAutoCompleteList->size())
[ # # ]
2290 : : {
2291 : : m_pAutoCompleteList = const_cast<editeng::SortedAutoCompleteStrings*>(
2292 : 0 : pOpt->m_pAutoCompleteList);
2293 : 0 : pOpt->m_pAutoCompleteList = 0;
2294 : 0 : nAutoCmpltListCnt = m_pAutoCompleteList->size();
2295 [ # # ]: 0 : for (size_t n = 0; n < nAutoCmpltListCnt; ++n)
2296 : : {
2297 : : const String* pStr =
2298 : 0 : &(*m_pAutoCompleteList)[n]->GetAutoCompleteString();
2299 : 0 : sal_uInt16 nPos = aLBEntries.InsertEntry( *pStr );
2300 : 0 : aLBEntries.SetEntryData( nPos, (void*)pStr );
2301 : : }
2302 : : }
2303 : : else
2304 : : {
2305 : 0 : aLBEntries.Disable();
2306 : 0 : aPBEntries.Disable();
2307 : : }
2308 : :
2309 : 0 : CheckHdl( &aCBActiv );
2310 : 0 : CheckHdl( &aCBCollect );
2311 : 0 : }
2312 : :
2313 : 0 : void OfaAutoCompleteTabPage::ActivatePage( const SfxItemSet& )
2314 : : {
2315 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage( sal_False );
2316 : 0 : }
2317 : :
2318 : 0 : IMPL_LINK_NOARG(OfaAutoCompleteTabPage, DeleteHdl)
2319 : : {
2320 : : sal_uInt16 nSelCnt =
2321 [ # # ]: 0 : (m_pAutoCompleteList) ? aLBEntries.GetSelectEntryCount() : 0;
2322 [ # # ]: 0 : while( nSelCnt )
2323 : : {
2324 [ # # ]: 0 : sal_uInt16 nPos = aLBEntries.GetSelectEntryPos( --nSelCnt );
2325 [ # # ]: 0 : String* pStr = static_cast<String*>(aLBEntries.GetEntryData(nPos));
2326 [ # # ]: 0 : aLBEntries.RemoveEntry( nPos );
2327 [ # # ]: 0 : editeng::IAutoCompleteString hack(*pStr); // UGLY
2328 [ # # ]: 0 : m_pAutoCompleteList->erase(&hack);
2329 [ # # ]: 0 : }
2330 : 0 : return 0;
2331 : : }
2332 : :
2333 : 0 : IMPL_LINK( OfaAutoCompleteTabPage, CheckHdl, CheckBox*, pBox )
2334 : : {
2335 : 0 : sal_Bool bEnable = pBox->IsChecked();
2336 [ # # ]: 0 : if( pBox == &aCBActiv )
2337 : : {
2338 : 0 : aCBAppendSpace.Enable( bEnable );
2339 : 0 : aCBAppendSpace.Enable( bEnable );
2340 : 0 : aCBAsTip.Enable( bEnable );
2341 : 0 : aDCBExpandKey.Enable( bEnable );
2342 : : }
2343 [ # # ]: 0 : else if(&aCBCollect == pBox)
2344 : 0 : aCBRemoveList.Enable( bEnable );
2345 : 0 : return 0;
2346 : : }
2347 : :
2348 : 0 : void OfaAutoCompleteTabPage::CopyToClipboard() const
2349 : : {
2350 : 0 : sal_uInt16 nSelCnt = aLBEntries.GetSelectEntryCount();
2351 [ # # ][ # # ]: 0 : if (m_pAutoCompleteList && nSelCnt)
2352 : : {
2353 [ # # ]: 0 : TransferDataContainer* pCntnr = new TransferDataContainer;
2354 : : ::com::sun::star::uno::Reference<
2355 [ # # ][ # # ]: 0 : ::com::sun::star::datatransfer::XTransferable > xRef( pCntnr );
2356 : :
2357 : 0 : rtl::OStringBuffer sData;
2358 : : const sal_Char aLineEnd[] =
2359 : : #if defined(WNT)
2360 : : "\015\012";
2361 : : #else
2362 : 0 : "\012";
2363 : : #endif
2364 : :
2365 [ # # ]: 0 : rtl_TextEncoding nEncode = osl_getThreadTextEncoding();
2366 : :
2367 [ # # ]: 0 : for( sal_uInt16 n = 0; n < nSelCnt; ++n )
2368 : : {
2369 : : sData.append(rtl::OUStringToOString(aLBEntries.GetSelectEntry(n),
2370 [ # # ][ # # ]: 0 : nEncode));
[ # # ][ # # ]
[ # # ]
2371 [ # # ]: 0 : sData.append(RTL_CONSTASCII_STRINGPARAM(aLineEnd));
2372 : : }
2373 [ # # ]: 0 : pCntnr->CopyByteString( SOT_FORMAT_STRING, sData.makeStringAndClear() );
2374 [ # # ]: 0 : pCntnr->CopyToClipboard( (Window*)this );
2375 : : }
2376 : 0 : }
2377 : :
2378 : 0 : long OfaAutoCompleteTabPage::AutoCompleteMultiListBox::PreNotify(
2379 : : NotifyEvent& rNEvt )
2380 : : {
2381 : 0 : long nHandled = MultiListBox::PreNotify( rNEvt );
2382 : :
2383 [ # # ][ # # ]: 0 : if( !nHandled && EVENT_KEYUP == rNEvt.GetType() )
[ # # ]
2384 : : {
2385 : 0 : const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
2386 [ # # ]: 0 : switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
2387 : : {
2388 : : case KEY_DELETE:
2389 : 0 : rPage.DeleteHdl( 0 );
2390 : 0 : nHandled = 1;
2391 : 0 : break;
2392 : :
2393 : : default:
2394 [ # # ]: 0 : if( KEYFUNC_COPY == rKeyCode.GetFunction() )
2395 : : {
2396 : 0 : rPage.CopyToClipboard();
2397 : 0 : nHandled = 1;
2398 : : }
2399 : 0 : break;
2400 : : }
2401 : : }
2402 : 0 : return nHandled;
2403 : : }
2404 : :
2405 : : // class OfaSmartTagOptionsTabPage ---------------------------------------------
2406 : :
2407 : 0 : OfaSmartTagOptionsTabPage::OfaSmartTagOptionsTabPage( Window* pParent,
2408 : : const SfxItemSet& rSet )
2409 : 0 : : SfxTabPage(pParent, CUI_RES( RID_OFAPAGE_SMARTTAG_OPTIONS ), rSet),
2410 [ # # ]: 0 : m_aMainCB( this, CUI_RES(CB_SMARTTAGS) ),
2411 [ # # ]: 0 : m_aSmartTagTypesLB( this, CUI_RES(LB_SMARTTAGS) ),
2412 [ # # ]: 0 : m_aPropertiesPB( this, CUI_RES(PB_SMARTTAGS) ),
2413 [ # # ][ # # ]: 0 : m_aTitleFT( this, CUI_RES(FT_SMARTTAGS) )
[ # # ][ # # ]
[ # # ][ # # ]
2414 : : {
2415 [ # # ]: 0 : FreeResource();
2416 : :
2417 : : // some options for the list box:
2418 [ # # ][ # # ]: 0 : m_aSmartTagTypesLB.SetStyle( m_aSmartTagTypesLB.GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
2419 [ # # ]: 0 : m_aSmartTagTypesLB.SetHighlightRange();
2420 : :
2421 : : // set the handlers:
2422 [ # # ]: 0 : m_aMainCB.SetToggleHdl(LINK(this, OfaSmartTagOptionsTabPage, CheckHdl));
2423 [ # # ]: 0 : m_aPropertiesPB.SetClickHdl(LINK(this, OfaSmartTagOptionsTabPage, ClickHdl));
2424 [ # # ]: 0 : m_aSmartTagTypesLB.SetSelectHdl(LINK(this, OfaSmartTagOptionsTabPage, SelectHdl));
2425 : 0 : }
2426 : :
2427 [ # # ][ # # ]: 0 : OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage()
[ # # ][ # # ]
2428 : : {
2429 : :
2430 [ # # ]: 0 : }
2431 : :
2432 : 0 : SfxTabPage* OfaSmartTagOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet)
2433 : : {
2434 [ # # ]: 0 : return new OfaSmartTagOptionsTabPage( pParent, rSet );
2435 : : }
2436 : :
2437 : : /** This struct is used to associate list box entries with smart tag data
2438 : : */
2439 : 0 : struct ImplSmartTagLBUserData
2440 : : {
2441 : : rtl::OUString maSmartTagType;
2442 : : uno::Reference< smarttags::XSmartTagRecognizer > mxRec;
2443 : : sal_Int32 mnSmartTagIdx;
2444 : :
2445 : 0 : ImplSmartTagLBUserData( const rtl::OUString& rSmartTagType,
2446 : : uno::Reference< smarttags::XSmartTagRecognizer > xRec,
2447 : : sal_Int32 nSmartTagIdx ) :
2448 : : maSmartTagType( rSmartTagType ),
2449 : : mxRec( xRec ),
2450 : 0 : mnSmartTagIdx( nSmartTagIdx ) {}
2451 : : };
2452 : :
2453 : : /** Clears m_aSmartTagTypesLB
2454 : : */
2455 : 0 : void OfaSmartTagOptionsTabPage::ClearListBox()
2456 : : {
2457 : 0 : const sal_uLong nCount = m_aSmartTagTypesLB.GetEntryCount();
2458 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
2459 : : {
2460 : 0 : const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(i);
2461 : 0 : const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
2462 [ # # ]: 0 : delete pUserData;
2463 : : }
2464 : :
2465 : 0 : m_aSmartTagTypesLB.Clear();
2466 : 0 : }
2467 : :
2468 : : /** Inserts items into m_aSmartTagTypesLB
2469 : : */
2470 : 0 : void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr )
2471 : : {
2472 : : // first we have to clear the list box:
2473 [ # # ]: 0 : ClearListBox();
2474 : :
2475 : : // fill list box:
2476 : 0 : const sal_uInt32 nNumberOfRecognizers = rSmartTagMgr.NumberOfRecognizers();
2477 [ # # ]: 0 : const lang::Locale aLocale( SvxCreateLocale( eLastDialogLanguage ) );
2478 : :
2479 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nNumberOfRecognizers; ++i )
2480 : : {
2481 [ # # ]: 0 : uno::Reference< smarttags::XSmartTagRecognizer > xRec = rSmartTagMgr.GetRecognizer(i);
2482 : :
2483 [ # # ][ # # ]: 0 : const rtl::OUString aName = xRec->getName( aLocale );
2484 [ # # ][ # # ]: 0 : const rtl::OUString aDesc = xRec->getDescription( aLocale );
2485 [ # # ][ # # ]: 0 : const sal_Int32 nNumberOfSupportedSmartTags = xRec->getSmartTagCount();
2486 : :
2487 [ # # ]: 0 : for ( sal_Int32 j = 0; j < nNumberOfSupportedSmartTags; ++j )
2488 : : {
2489 [ # # ][ # # ]: 0 : const rtl::OUString aSmartTagType = xRec->getSmartTagName(j);
2490 [ # # ]: 0 : rtl::OUString aSmartTagCaption = rSmartTagMgr.GetSmartTagCaption( aSmartTagType, aLocale );
2491 : :
2492 [ # # ]: 0 : if ( aSmartTagCaption.isEmpty() )
2493 : 0 : aSmartTagCaption = aSmartTagType;
2494 : :
2495 : : const rtl::OUString aLBEntry = aSmartTagCaption +
2496 : : OUString(RTL_CONSTASCII_USTRINGPARAM(" (")) +
2497 : : aName +
2498 [ # # ][ # # ]: 0 : OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
2499 : :
2500 [ # # ][ # # ]: 0 : SvLBoxEntry* pEntry = m_aSmartTagTypesLB.SvTreeListBox::InsertEntry( aLBEntry );
[ # # ]
2501 [ # # ]: 0 : if ( pEntry )
2502 : : {
2503 [ # # ]: 0 : const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType );
2504 [ # # ][ # # ]: 0 : m_aSmartTagTypesLB.SetCheckButtonState( pEntry, bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
2505 [ # # ][ # # ]: 0 : pEntry->SetUserData(static_cast<void*>(new ImplSmartTagLBUserData( aSmartTagType, xRec, j ) ) );
2506 : : }
2507 : 0 : }
2508 : 0 : }
2509 : 0 : }
2510 : :
2511 : : /** Handler for the push button
2512 : : */
2513 : 0 : IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl)
2514 : : {
2515 [ # # ]: 0 : const sal_uInt16 nPos = m_aSmartTagTypesLB.GetSelectEntryPos();
2516 [ # # ]: 0 : const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(nPos);
2517 : 0 : const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
2518 : 0 : uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
2519 : 0 : const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
2520 : :
2521 [ # # ]: 0 : const lang::Locale aLocale( SvxCreateLocale( eLastDialogLanguage ) );
2522 [ # # ][ # # ]: 0 : if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
[ # # ]
2523 [ # # ][ # # ]: 0 : xRec->displayPropertyPage( nSmartTagIdx, aLocale );
2524 : :
2525 : 0 : return 0;
2526 : : }
2527 : :
2528 : : /** Handler for the check box
2529 : : */
2530 : 0 : IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, CheckHdl)
2531 : : {
2532 : 0 : const sal_Bool bEnable = m_aMainCB.IsChecked();
2533 : 0 : m_aSmartTagTypesLB.Enable( bEnable );
2534 : 0 : m_aSmartTagTypesLB.Invalidate();
2535 : 0 : m_aPropertiesPB.Enable( false );
2536 : :
2537 : : // if the controls are currently enabled, we still have to check
2538 : : // if the properties button should be disabled because the currently
2539 : : // seleted smart tag type does not have a properties dialog.
2540 : : // We do this by calling SelectHdl:
2541 [ # # ]: 0 : if ( bEnable )
2542 : 0 : SelectHdl( &m_aSmartTagTypesLB );
2543 : :
2544 : 0 : return 0;
2545 : : }
2546 : :
2547 : : /** Handler for the list box
2548 : : */
2549 : 0 : IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, SelectHdl)
2550 : : {
2551 [ # # ]: 0 : if ( m_aSmartTagTypesLB.GetEntryCount() < 1 )
2552 : 0 : return 0;
2553 : :
2554 [ # # ]: 0 : const sal_uInt16 nPos = m_aSmartTagTypesLB.GetSelectEntryPos();
2555 [ # # ]: 0 : const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(nPos);
2556 : 0 : const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
2557 : 0 : uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
2558 : 0 : const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
2559 : :
2560 [ # # ]: 0 : const lang::Locale aLocale( SvxCreateLocale( eLastDialogLanguage ) );
2561 [ # # ][ # # ]: 0 : if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
[ # # ]
2562 [ # # ]: 0 : m_aPropertiesPB.Enable( sal_True );
2563 : : else
2564 [ # # ]: 0 : m_aPropertiesPB.Enable( sal_False );
2565 : :
2566 : 0 : return 0;
2567 : : }
2568 : :
2569 : : /** Propagates the current settings to the smart tag manager.
2570 : : */
2571 : 0 : sal_Bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet& )
2572 : : {
2573 [ # # ]: 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
2574 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
2575 : 0 : SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr;
2576 : :
2577 : : // robust!
2578 [ # # ]: 0 : if ( !pSmartTagMgr )
2579 : 0 : return sal_False;
2580 : :
2581 : 0 : sal_Bool bModifiedSmartTagTypes = sal_False;
2582 [ # # ]: 0 : std::vector< rtl::OUString > aDisabledSmartTagTypes;
2583 : :
2584 : 0 : const sal_uLong nCount = m_aSmartTagTypesLB.GetEntryCount();
2585 : :
2586 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
2587 : : {
2588 [ # # ]: 0 : const SvLBoxEntry* pEntry = m_aSmartTagTypesLB.GetEntry(i);
2589 : 0 : const ImplSmartTagLBUserData* pUserData = static_cast< ImplSmartTagLBUserData* >(pEntry->GetUserData());
2590 [ # # ]: 0 : const sal_Bool bChecked = m_aSmartTagTypesLB.IsChecked(i);
2591 [ # # ]: 0 : const sal_Bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType );
2592 : :
2593 [ # # ][ # # ]: 0 : bModifiedSmartTagTypes = bModifiedSmartTagTypes || ( !bChecked != !bIsCurrentlyEnabled );
2594 : :
2595 [ # # ]: 0 : if ( !bChecked )
2596 [ # # ]: 0 : aDisabledSmartTagTypes.push_back( pUserData->maSmartTagType );
2597 : :
2598 [ # # ][ # # ]: 0 : delete pUserData;
2599 : : }
2600 : :
2601 [ # # ]: 0 : const sal_Bool bModifiedRecognize = ( !m_aMainCB.IsChecked() != !pSmartTagMgr->IsLabelTextWithSmartTags() );
2602 [ # # ][ # # ]: 0 : if ( bModifiedSmartTagTypes || bModifiedRecognize )
2603 : : {
2604 [ # # ]: 0 : bool bLabelTextWithSmartTags = m_aMainCB.IsChecked() ? true : false;
2605 : : pSmartTagMgr->WriteConfiguration( bModifiedRecognize ? &bLabelTextWithSmartTags : 0,
2606 [ # # ][ # # ]: 0 : bModifiedSmartTagTypes ? &aDisabledSmartTagTypes : 0 );
[ # # ]
2607 : : }
2608 : :
2609 : 0 : return sal_True;
2610 : : }
2611 : :
2612 : : /** Sets the controls based on the current settings at SmartTagMgr.
2613 : : */
2614 : 0 : void OfaSmartTagOptionsTabPage::Reset( const SfxItemSet& )
2615 : : {
2616 : 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
2617 : 0 : SvxSwAutoFmtFlags *pOpt = &pAutoCorrect->GetSwFlags();
2618 : 0 : const SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr;
2619 : :
2620 : : // robust, should not happen!
2621 [ # # ]: 0 : if ( !pSmartTagMgr )
2622 : 0 : return;
2623 : :
2624 : 0 : FillListBox( *pSmartTagMgr );
2625 : 0 : m_aSmartTagTypesLB.SelectEntryPos( 0 );
2626 : 0 : m_aMainCB.Check( pSmartTagMgr->IsLabelTextWithSmartTags() );
2627 : 0 : CheckHdl( &m_aMainCB );
2628 : : }
2629 : :
2630 : 0 : void OfaSmartTagOptionsTabPage::ActivatePage( const SfxItemSet& )
2631 : : {
2632 : 0 : ((OfaAutoCorrDlg*)GetTabDialog())->EnableLanguage( sal_False );
2633 : 0 : }
2634 : :
2635 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|