1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: autocdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
38 #define _SVSTDARR_STRINGSISORTDTOR
39 #define _SVSTDARR_STRINGSDTOR
40 #include <svtools/svstdarr.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <vcl/field.hxx>
43 #include <vcl/keycodes.hxx>
44 #include <sot/exchange.hxx>
45 #include <svtools/transfer.hxx>
46 #include <svtools/syslocale.hxx>
47 #include <sfx2/objsh.hxx>
48 #include <sfx2/viewsh.hxx>
49 #include <unotools/charclass.hxx>
50 #include <unotools/collatorwrapper.hxx>
51 #include <com/sun/star/i18n/CollatorOptions.hpp>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <comphelper/processfactory.hxx>
55 #include <vcl/svapp.hxx>
56 #include <sfx2/module.hxx>
57 #include <sfx2/request.hxx>
58 #include <sfx2/sfxsids.hrc>
59 #include <svtools/eitem.hxx>
60 #include <svtools/languageoptions.hxx>
61 #include <svx/SmartTagMgr.hxx>
62 #include <com/sun/star/smarttags/XSmartTagRecognizer.hpp>
63 #include <com/sun/star/smarttags/XSmartTagAction.hpp>
65 #define _OFA_AUTOCDLG_CXX
66 #include "autocdlg.hxx"
67 #include "autocdlg.hrc"
69 #include "acorrcfg.hxx"
70 #include <svx/svxacorr.hxx>
71 #include "cuicharmap.hxx"
72 #include "unolingu.hxx"
73 #include <svx/dialmgr.hxx>
75 static LanguageType eLastDialogLanguage
= LANGUAGE_SYSTEM
;
77 using namespace ::com::sun::star::util
;
78 using namespace ::com::sun::star
;
79 using namespace ::rtl
;
81 static ::com::sun::star::uno::Reference
<
82 ::com::sun::star::lang::XMultiServiceFactory
>& GetProcessFact()
84 static ::com::sun::star::uno::Reference
<
85 ::com::sun::star::lang::XMultiServiceFactory
> xMSF
=
86 ::comphelper::getProcessServiceFactory();
90 /*-----------------14.10.96 15.47-------------------
92 --------------------------------------------------*/
94 OfaAutoCorrDlg::OfaAutoCorrDlg(Window
* pParent
, const SfxItemSet
* _pSet
) :
95 SfxTabDialog(pParent
, SVX_RES( RID_OFA_AUTOCORR_DLG
), _pSet
),
96 aLanguageFT( this, SVX_RES(FT_LANG
)),
97 aLanguageLB( this, SVX_RES(LB_LANG
))
99 BOOL bShowSWOptions
= FALSE
;
100 BOOL bOpenSmartTagOptions
= FALSE
;
104 SFX_ITEMSET_ARG( _pSet
, pItem
, SfxBoolItem
, SID_AUTO_CORRECT_DLG
, FALSE
);
105 if ( pItem
&& pItem
->GetValue() )
106 bShowSWOptions
= TRUE
;
108 SFX_ITEMSET_ARG( _pSet
, pItem2
, SfxBoolItem
, SID_OPEN_SMARTTAGOPTIONS
, FALSE
);
109 if ( pItem2
&& pItem2
->GetValue() )
110 bOpenSmartTagOptions
= TRUE
;
113 aLanguageFT
.SetZOrder(0, WINDOW_ZORDER_FIRST
);
114 aLanguageLB
.SetZOrder(&aLanguageFT
, WINDOW_ZORDER_BEHIND
);
115 aLanguageLB
.SetHelpId(HID_AUTOCORR_LANGUAGE
);
118 AddTabPage(RID_OFAPAGE_AUTOCORR_OPTIONS
, OfaAutocorrOptionsPage::Create
, 0);
119 AddTabPage(RID_OFAPAGE_AUTOFMT_APPLY
, OfaSwAutoFmtOptionsPage::Create
, 0);
120 AddTabPage(RID_OFAPAGE_AUTOCOMPLETE_OPTIONS
, OfaAutoCompleteTabPage::Create
, 0);
121 AddTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS
, OfaSmartTagOptionsTabPage::Create
, 0);
125 RemoveTabPage(RID_OFAPAGE_AUTOFMT_APPLY
);
126 RemoveTabPage(RID_OFAPAGE_AUTOCOMPLETE_OPTIONS
);
127 RemoveTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS
);
131 // remove smart tag tab page if no extensions are installed
132 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
133 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
134 if ( !pOpt
|| !pOpt
->pSmartTagMgr
|| 0 == pOpt
->pSmartTagMgr
->NumberOfRecognizers() )
135 RemoveTabPage(RID_OFAPAGE_SMARTTAG_OPTIONS
);
137 RemoveTabPage(RID_OFAPAGE_AUTOCORR_OPTIONS
);
140 AddTabPage(RID_OFAPAGE_AUTOCORR_REPLACE
, OfaAutocorrReplacePage::Create
, 0);
141 AddTabPage(RID_OFAPAGE_AUTOCORR_EXCEPT
, OfaAutocorrExceptPage::Create
, 0);
142 AddTabPage(RID_OFAPAGE_AUTOCORR_QUOTE
, OfaQuoteTabPage::Create
, 0);
144 // initialize languages
145 //! LANGUAGE_NONE is displayed as '[All]' and the LanguageType
146 //! will be set to LANGUAGE_DONTKNOW
147 sal_Int16 nLangList
= LANG_LIST_WESTERN
;
149 if( SvtLanguageOptions().IsCTLFontEnabled() )
150 nLangList
|= LANG_LIST_CTL
;
151 aLanguageLB
.SetLanguageList( nLangList
, TRUE
, TRUE
);
152 aLanguageLB
.SelectLanguage( LANGUAGE_NONE
);
153 USHORT nPos
= aLanguageLB
.GetSelectEntryPos();
154 DBG_ASSERT( LISTBOX_ENTRY_NOTFOUND
!= nPos
, "listbox entry missing" );
155 aLanguageLB
.SetEntryData( nPos
, (void*)(long) LANGUAGE_DONTKNOW
);
157 // Initialisierung funktionier fuer static nicht unter Linux - deswegen hier
158 if( LANGUAGE_SYSTEM
== eLastDialogLanguage
)
159 eLastDialogLanguage
= Application::GetSettings().GetLanguage();
161 LanguageType nSelectLang
= LANGUAGE_DONTKNOW
;
162 nPos
= aLanguageLB
.GetEntryPos( (void*)(long) eLastDialogLanguage
);
163 if (LISTBOX_ENTRY_NOTFOUND
!= nPos
)
164 nSelectLang
= eLastDialogLanguage
;
165 aLanguageLB
.SelectLanguage( nSelectLang
);
167 aLanguageLB
.SetSelectHdl(LINK(this, OfaAutoCorrDlg
, SelectLanguageHdl
));
169 Size
aMinSize(aLanguageFT
.CalcMinimumSize());
170 //reserve some extra space for CJK accelerators that are possible inserted
172 aLanguageFT
.SetPosSizePixel( 0, 0, aMinSize
.Width() + 20, 0, WINDOW_POSSIZE_WIDTH
);
174 if ( bOpenSmartTagOptions
)
175 SetCurPageId( RID_OFAPAGE_SMARTTAG_OPTIONS
);
177 /*-----------------16.10.96 14.06-------------------
179 --------------------------------------------------*/
181 BOOL
lcl_FindEntry( ListBox
& rLB
, const String
& rEntry
,
182 CollatorWrapper
& rCmpClass
)
184 USHORT nCount
= rLB
.GetEntryCount();
185 USHORT nSelPos
= rLB
.GetSelectEntryPos();
187 for(i
= 0; i
< nCount
; i
++)
189 if( 0 == rCmpClass
.compareString(rEntry
, rLB
.GetEntry(i
) ))
191 rLB
.SelectEntryPos(i
, TRUE
);
195 if(LISTBOX_ENTRY_NOTFOUND
!= nSelPos
)
196 rLB
.SelectEntryPos(nSelPos
, FALSE
);
200 /* -----------------23.11.98 10:46-------------------
202 * --------------------------------------------------*/
203 IMPL_LINK(OfaAutoCorrDlg
, SelectLanguageHdl
, ListBox
*, pBox
)
205 USHORT nPos
= pBox
->GetSelectEntryPos();
206 void* pVoid
= pBox
->GetEntryData(nPos
);
207 LanguageType eNewLang
= (LanguageType
)(long)pVoid
;
208 //alte Einstellungen speichern und neu fuellen
209 if(eNewLang
!= eLastDialogLanguage
)
211 USHORT nPageId
= GetCurPageId();
212 if(RID_OFAPAGE_AUTOCORR_REPLACE
== nPageId
)
213 ((OfaAutocorrReplacePage
*)GetTabPage( nPageId
))->SetLanguage(eNewLang
);
214 else if(RID_OFAPAGE_AUTOCORR_EXCEPT
== nPageId
)
215 ((OfaAutocorrExceptPage
*)GetTabPage( nPageId
))->SetLanguage(eNewLang
);
219 /*-----------------14.10.96 15.57-------------------
221 --------------------------------------------------*/
223 OfaAutocorrOptionsPage::OfaAutocorrOptionsPage( Window
* pParent
,
224 const SfxItemSet
& rSet
) :
225 SfxTabPage(pParent
, SVX_RES( RID_OFAPAGE_AUTOCORR_OPTIONS
), rSet
),
226 aCheckLB (this, SVX_RES(CLB_SETTINGS
)),
228 sInput (SVX_RES(ST_USE_REPLACE
)),
229 sDoubleCaps (SVX_RES(ST_CPTL_STT_WORD
)),
230 sStartCap (SVX_RES(ST_CPTL_STT_SENT
)),
231 sBoldUnderline (SVX_RES(ST_BOLD_UNDER
)),
232 sURL (SVX_RES(ST_DETECT_URL
)),
233 sNoDblSpaces (SVX_RES(STR_NO_DBL_SPACES
)),
234 sHalf (SVX_RES(ST_FRACTION
)),
235 sDash (SVX_RES(ST_DASH
)),
236 sNonBrkSpace (SVX_RES(ST_NON_BREAK_SPACE
)),
237 sFirst (SVX_RES(ST_ORDINAL
)),
238 sAccidentalCaps (SVX_RES(ST_CORRECT_ACCIDENTAL_CAPS_LOCK
))
242 aCheckLB
.SetHelpId(HID_OFAPAGE_AUTOCORR_CLB
);
245 /*-----------------14.10.96 15.58-------------------
247 --------------------------------------------------*/
250 OfaAutocorrOptionsPage::~OfaAutocorrOptionsPage()
254 /*-----------------14.10.96 15.58-------------------
256 --------------------------------------------------*/
259 SfxTabPage
* OfaAutocorrOptionsPage::Create( Window
* pParent
,
260 const SfxItemSet
& rSet
)
262 return new OfaAutocorrOptionsPage(pParent
, rSet
);
264 /*-----------------14.10.96 15.58-------------------
266 --------------------------------------------------*/
269 BOOL
OfaAutocorrOptionsPage::FillItemSet( SfxItemSet
& )
271 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
272 long nFlags
= pAutoCorrect
->GetFlags();
275 pAutoCorrect
->SetAutoCorrFlag(Autocorrect
, aCheckLB
.IsChecked(nPos
++));
276 pAutoCorrect
->SetAutoCorrFlag(CptlSttWrd
, aCheckLB
.IsChecked(nPos
++));
277 pAutoCorrect
->SetAutoCorrFlag(CptlSttSntnc
, aCheckLB
.IsChecked(nPos
++));
278 pAutoCorrect
->SetAutoCorrFlag(ChgWeightUnderl
, aCheckLB
.IsChecked(nPos
++));
279 pAutoCorrect
->SetAutoCorrFlag(SetINetAttr
, aCheckLB
.IsChecked(nPos
++));
280 pAutoCorrect
->SetAutoCorrFlag(ChgOrdinalNumber
, aCheckLB
.IsChecked(nPos
++));
281 pAutoCorrect
->SetAutoCorrFlag(ChgFractionSymbol
, aCheckLB
.IsChecked(nPos
++));
282 pAutoCorrect
->SetAutoCorrFlag(ChgToEnEmDash
, aCheckLB
.IsChecked(nPos
++));
283 pAutoCorrect
->SetAutoCorrFlag(AddNonBrkSpace
, aCheckLB
.IsChecked(nPos
++));
284 pAutoCorrect
->SetAutoCorrFlag(IngnoreDoubleSpace
, aCheckLB
.IsChecked(nPos
++));
285 pAutoCorrect
->SetAutoCorrFlag(CorrectCapsLock
, aCheckLB
.IsChecked(nPos
++));
287 BOOL bReturn
= nFlags
!= pAutoCorrect
->GetFlags();
290 SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
297 /* -----------------23.11.98 16:15-------------------
299 * --------------------------------------------------*/
300 void OfaAutocorrOptionsPage::ActivatePage( const SfxItemSet
& )
302 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage(FALSE
);
305 /*-----------------14.10.96 15.58-------------------
307 --------------------------------------------------*/
310 void OfaAutocorrOptionsPage::Reset( const SfxItemSet
& )
312 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
313 const long nFlags
= pAutoCorrect
->GetFlags();
315 aCheckLB
.SetUpdateMode(FALSE
);
318 aCheckLB
.InsertEntry(sInput
);
319 aCheckLB
.InsertEntry(sDoubleCaps
);
320 aCheckLB
.InsertEntry(sStartCap
);
321 aCheckLB
.InsertEntry(sBoldUnderline
);
322 aCheckLB
.InsertEntry(sURL
);
323 aCheckLB
.InsertEntry(sFirst
);
324 aCheckLB
.InsertEntry(sHalf
);
325 aCheckLB
.InsertEntry(sDash
);
326 aCheckLB
.InsertEntry(sNonBrkSpace
);
327 aCheckLB
.InsertEntry(sNoDblSpaces
);
328 aCheckLB
.InsertEntry(sAccidentalCaps
);
331 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& Autocorrect
) );
332 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& CptlSttWrd
) );
333 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& CptlSttSntnc
) );
334 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& ChgWeightUnderl
) );
335 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& SetINetAttr
) );
336 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& ChgOrdinalNumber
) );
337 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& ChgFractionSymbol
) );
338 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& ChgToEnEmDash
) );
339 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& AddNonBrkSpace
) );
340 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& IngnoreDoubleSpace
) );
341 aCheckLB
.CheckEntryPos( nPos
++, 0 != (nFlags
& CorrectCapsLock
) );
343 aCheckLB
.SetUpdateMode(TRUE
);
346 /*********************************************************************/
348 /* Hilfs-struct fuer dUserDaten der Checklistbox */
350 /*********************************************************************/
357 ImpUserData(String
* pText
, Font
* pFnt
)
358 { pString
= pText
; pFont
= pFnt
;}
362 /*********************************************************************/
364 /* Dialog fuer Prozenteinstellung */
366 /*********************************************************************/
368 class OfaAutoFmtPrcntSet
: public ModalDialog
371 CancelButton aCancelPB
;
373 MetricField aPrcntMF
;
376 OfaAutoFmtPrcntSet(Window
* pParent
) :
377 ModalDialog(pParent
, SVX_RES(RID_OFADLG_PRCNT_SET
)),
378 aOKPB(this, SVX_RES(BT_OK
)),
379 aCancelPB(this, SVX_RES(BT_CANCEL
)),
380 aPrcntFL(this, SVX_RES(FL_PRCNT
)),
381 aPrcntMF(this, SVX_RES(ED_RIGHT_MARGIN
))
385 MetricField
& GetPrcntFld(){return aPrcntMF
;}
389 /*********************************************************************/
391 /* veraenderter LBoxString */
393 /*********************************************************************/
395 class OfaImpBrwString
: public SvLBoxString
399 OfaImpBrwString( SvLBoxEntry
* pEntry
, USHORT nFlags
,
400 const String
& rStr
) : SvLBoxString(pEntry
,nFlags
,rStr
){}
402 virtual void Paint( const Point
& rPos
, SvLBox
& rDev
, USHORT nFlags
,
403 SvLBoxEntry
* pEntry
);
406 /*********************************************************************/
408 /*********************************************************************/
411 void __EXPORT
OfaImpBrwString::Paint( const Point
& rPos
, SvLBox
& rDev
, USHORT
/*nFlags*/,
412 SvLBoxEntry
* pEntry
)
414 rDev
.DrawText( rPos
, GetText() );
415 if(pEntry
->GetUserData())
417 ImpUserData
* pUserData
= (ImpUserData
* )pEntry
->GetUserData();
419 aNewPos
.X() += rDev
.GetTextWidth(GetText());
420 Font
aOldFont( rDev
.GetFont());
421 Font
aFont( aOldFont
);
424 aFont
= *pUserData
->pFont
;
425 aFont
.SetColor(aOldFont
.GetColor());
426 aFont
.SetSize(aOldFont
.GetSize());
428 aFont
.SetWeight( WEIGHT_BOLD
);
433 String
sTxt( pUserData
->pString
->GetToken( 0, 1, nPos
));
436 rDev
.SetFont( aFont
);
438 rDev
.DrawText( aNewPos
, sTxt
);
440 if( STRING_NOTFOUND
!= nPos
)
441 aNewPos
.X() += rDev
.GetTextWidth( sTxt
);
444 rDev
.SetFont( aOldFont
);
447 } while( STRING_NOTFOUND
!= nPos
);
451 /*********************************************************************/
453 /* TabPage Autoformat anwenden */
455 /*********************************************************************/
457 #define CBCOL_FIRST 0
458 #define CBCOL_SECOND 1
461 enum OfaAutoFmtOptions
472 DEL_SPACES_AT_STT_END
,
473 DEL_SPACES_BETWEEN_LINES
,
484 MERGE_SINGLE_LINE_PARA
487 OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage( Window
* pParent
,
488 const SfxItemSet
& rSet
) :
489 SfxTabPage(pParent
, SVX_RES(RID_OFAPAGE_AUTOFMT_APPLY
), rSet
),
490 aCheckLB (this, SVX_RES(CLB_SETTINGS
)),
491 aEditPB (this, SVX_RES(PB_EDIT
)),
492 aHeader1Expl (this, SVX_RES(FT_HEADER1_EXPLANATION
)),
493 aHeader2Expl (this, SVX_RES(FT_HEADER2_EXPLANATION
)),
494 sHeader1 (SVX_RES( STR_HEADER1
)),
495 sHeader2 (SVX_RES( STR_HEADER2
)),
496 sDeleteEmptyPara (SVX_RES( ST_DEL_EMPTY_PARA
)),
497 sUseReplaceTbl (SVX_RES( ST_USE_REPLACE
)),
498 sCptlSttWord (SVX_RES( ST_CPTL_STT_WORD
)),
499 sCptlSttSent (SVX_RES( ST_CPTL_STT_SENT
)),
500 sTypo (SVX_RES( ST_TYPO
)),
501 sUserStyle (SVX_RES( ST_USER_STYLE
)),
502 sBullet (SVX_RES( ST_BULLET
)),
503 sBoldUnder (SVX_RES( ST_BOLD_UNDER
)),
504 sNoDblSpaces (SVX_RES( STR_NO_DBL_SPACES
)),
505 sCorrectCapsLock (SVX_RES( ST_CORRECT_ACCIDENTAL_CAPS_LOCK
)),
506 sFraction (SVX_RES( ST_FRACTION
)),
507 sDetectURL (SVX_RES( ST_DETECT_URL
)),
508 sDash (SVX_RES( ST_DASH
)),
509 sNonBrkSpace (SVX_RES( ST_NON_BREAK_SPACE
)),
510 sOrdinal (SVX_RES( ST_ORDINAL
)),
511 sRightMargin (SVX_RES( ST_RIGHT_MARGIN
)),
512 sNum (SVX_RES( STR_NUM
)),
513 sBorder (SVX_RES( STR_BORDER
)),
514 sTable (SVX_RES( STR_TABLE
)),
515 sReplaceTemplates (SVX_RES( STR_REPLACE_TEMPLATES
)),
516 sDelSpaceAtSttEnd (SVX_RES( STR_DEL_SPACES_AT_STT_END
)),
517 sDelSpaceBetweenLines(SVX_RES(STR_DEL_SPACES_BETWEEN_LINES
)),
520 pCheckButtonData( NULL
)
525 //typ. Anfuehrungszeichen einsetzen
526 SvtSysLocale aSysLcl
;
527 const LocaleDataWrapper
& rLcl
= aSysLcl
.GetLocaleData();
528 sTypo
.SearchAndReplace( String::CreateFromAscii("%1"),
529 rLcl
.getDoubleQuotationMarkStart());
530 sTypo
.SearchAndReplace( String::CreateFromAscii("%2"),
531 rLcl
.getDoubleQuotationMarkEnd());
533 aCheckLB
.SetHelpId(HID_OFAPAGE_AUTOFORMAT_CLB
);
534 aCheckLB
.SetWindowBits(WB_HSCROLL
| WB_VSCROLL
);
536 aCheckLB
.SetSelectHdl(LINK(this, OfaSwAutoFmtOptionsPage
, SelectHdl
));
537 aCheckLB
.SetDoubleClickHdl(LINK(this, OfaSwAutoFmtOptionsPage
, EditHdl
));
539 static long aStaticTabs
[]=
544 aCheckLB
.SvxSimpleTable::SetTabs(aStaticTabs
);
545 String
sHeader( sHeader1
);
549 aCheckLB
.InsertHeaderEntry( sHeader
, HEADERBAR_APPEND
,
550 HIB_CENTER
| HIB_VCENTER
| HIB_FIXEDPOS
| HIB_FIXED
);
552 aEditPB
.SetClickHdl(LINK(this, OfaSwAutoFmtOptionsPage
, EditHdl
));
555 /*********************************************************************/
557 /*********************************************************************/
559 SvLBoxEntry
* OfaSwAutoFmtOptionsPage::CreateEntry(String
& rTxt
, USHORT nCol
)
561 SvLBoxEntry
* pEntry
= new SvLBoxEntry
;
563 if ( !pCheckButtonData
)
565 pCheckButtonData
= new SvLBoxButtonData( &aCheckLB
);
566 aCheckLB
.SetCheckButtonData( pCheckButtonData
);
569 pEntry
->AddItem( new SvLBoxContextBmp( pEntry
, 0, Image(), Image(), 0)); // Sonst Puff!
572 if (nCol
== CBCOL_SECOND
)
573 pEntry
->AddItem( new SvLBoxString( pEntry
, 0, sEmpty
) ); // Leerspalte
575 pEntry
->AddItem( new SvLBoxButton( pEntry
, SvLBoxButtonKind_enabledCheckbox
, 0, pCheckButtonData
) );
577 if (nCol
== CBCOL_FIRST
)
578 pEntry
->AddItem( new SvLBoxString( pEntry
, 0, sEmpty
) ); // Leerspalte
580 pEntry
->AddItem( new SvLBoxButton( pEntry
, SvLBoxButtonKind_enabledCheckbox
, 0, pCheckButtonData
) );
581 pEntry
->AddItem( new OfaImpBrwString( pEntry
, 0, rTxt
) );
586 /*********************************************************************/
588 /*********************************************************************/
591 __EXPORT
OfaSwAutoFmtOptionsPage::~OfaSwAutoFmtOptionsPage()
593 delete (ImpUserData
*) aCheckLB
.GetUserData( REPLACE_BULLETS
);
594 delete (ImpUserData
*) aCheckLB
.GetUserData( APPLY_NUMBERING
);
595 delete (ImpUserData
*) aCheckLB
.GetUserData( MERGE_SINGLE_LINE_PARA
);
596 delete pCheckButtonData
;
599 /*********************************************************************/
601 /*********************************************************************/
603 SfxTabPage
* __EXPORT
OfaSwAutoFmtOptionsPage::Create( Window
* pParent
,
604 const SfxItemSet
& rAttrSet
)
606 return new OfaSwAutoFmtOptionsPage(pParent
, rAttrSet
);
609 /*********************************************************************/
611 /*********************************************************************/
613 BOOL
OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet
& )
615 BOOL bModified
= FALSE
;
616 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
617 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
618 long nFlags
= pAutoCorrect
->GetFlags();
620 BOOL bCheck
= aCheckLB
.IsChecked(USE_REPLACE_TABLE
, CBCOL_FIRST
);
621 bModified
|= pOpt
->bAutoCorrect
!= bCheck
;
622 pOpt
->bAutoCorrect
= bCheck
;
623 pAutoCorrect
->SetAutoCorrFlag(Autocorrect
,
624 aCheckLB
.IsChecked(USE_REPLACE_TABLE
, CBCOL_SECOND
));
626 bCheck
= aCheckLB
.IsChecked(CORR_UPPER
, CBCOL_FIRST
);
627 bModified
|= pOpt
->bCptlSttWrd
!= bCheck
;
628 pOpt
->bCptlSttWrd
= bCheck
;
629 pAutoCorrect
->SetAutoCorrFlag(CptlSttWrd
,
630 aCheckLB
.IsChecked(CORR_UPPER
, CBCOL_SECOND
));
632 bCheck
= aCheckLB
.IsChecked(BEGIN_UPPER
, CBCOL_FIRST
);
633 bModified
|= pOpt
->bCptlSttSntnc
!= bCheck
;
634 pOpt
->bCptlSttSntnc
= bCheck
;
635 pAutoCorrect
->SetAutoCorrFlag(CptlSttSntnc
,
636 aCheckLB
.IsChecked(BEGIN_UPPER
, CBCOL_SECOND
));
638 bCheck
= aCheckLB
.IsChecked(BOLD_UNDERLINE
, CBCOL_FIRST
);
639 bModified
|= pOpt
->bChgWeightUnderl
!= bCheck
;
640 pOpt
->bChgWeightUnderl
= bCheck
;
641 pAutoCorrect
->SetAutoCorrFlag(ChgWeightUnderl
,
642 aCheckLB
.IsChecked(BOLD_UNDERLINE
, CBCOL_SECOND
));
644 pAutoCorrect
->SetAutoCorrFlag(IngnoreDoubleSpace
,
645 aCheckLB
.IsChecked(IGNORE_DBLSPACE
, CBCOL_SECOND
));
647 pAutoCorrect
->SetAutoCorrFlag(CorrectCapsLock
,
648 aCheckLB
.IsChecked(CORRECT_CAPS_LOCK
, CBCOL_SECOND
));
650 bCheck
= aCheckLB
.IsChecked(DETECT_URL
, CBCOL_FIRST
);
651 bModified
|= pOpt
->bSetINetAttr
!= bCheck
;
652 pOpt
->bSetINetAttr
= bCheck
;
653 pAutoCorrect
->SetAutoCorrFlag(SetINetAttr
,
654 aCheckLB
.IsChecked(DETECT_URL
, CBCOL_SECOND
));
656 bCheck
= aCheckLB
.IsChecked(REPLACE_1ST
, CBCOL_FIRST
);
657 bModified
|= pOpt
->bChgOrdinalNumber
!= bCheck
;
658 pOpt
->bChgOrdinalNumber
= bCheck
;
659 pAutoCorrect
->SetAutoCorrFlag(ChgOrdinalNumber
,
660 aCheckLB
.IsChecked(REPLACE_1ST
, CBCOL_SECOND
));
662 bCheck
= aCheckLB
.IsChecked(DEL_EMPTY_NODE
, CBCOL_FIRST
);
663 bModified
|= pOpt
->bDelEmptyNode
!= bCheck
;
664 pOpt
->bDelEmptyNode
= bCheck
;
666 bCheck
= aCheckLB
.IsChecked(REPLACE_QUOTATION
, CBCOL_FIRST
);
667 bModified
|= pOpt
->bReplaceQuote
!= bCheck
;
668 pOpt
->bReplaceQuote
= bCheck
;
670 bCheck
= aCheckLB
.IsChecked(REPLACE_USER_COLL
, CBCOL_FIRST
);
671 bModified
|= pOpt
->bChgUserColl
!= bCheck
;
672 pOpt
->bChgUserColl
= bCheck
;
674 bCheck
= aCheckLB
.IsChecked(REPLACE_BULLETS
, CBCOL_FIRST
);
675 bModified
|= pOpt
->bChgEnumNum
!= bCheck
;
676 pOpt
->bChgEnumNum
= bCheck
;
677 bModified
|= aBulletFont
!= pOpt
->aBulletFont
;
678 pOpt
->aBulletFont
= aBulletFont
;
679 bModified
|= String(pOpt
->cBullet
) != sBulletChar
;
680 pOpt
->cBullet
= sBulletChar
.GetChar(0);
682 bModified
|= aByInputBulletFont
!= pOpt
->aByInputBulletFont
;
683 bModified
|= String(pOpt
->cByInputBullet
) != sByInputBulletChar
;
684 pOpt
->aByInputBulletFont
= aByInputBulletFont
;
685 pOpt
->cByInputBullet
= sByInputBulletChar
.GetChar(0);
687 bCheck
= aCheckLB
.IsChecked(MERGE_SINGLE_LINE_PARA
, CBCOL_FIRST
);
688 bModified
|= pOpt
->bRightMargin
!= bCheck
;
689 pOpt
->bRightMargin
= bCheck
;
690 bModified
|= nPercent
!= pOpt
->nRightMargin
;
691 pOpt
->nRightMargin
= (BYTE
)nPercent
;
693 bCheck
= aCheckLB
.IsChecked(APPLY_NUMBERING
, CBCOL_SECOND
);
694 bModified
|= pOpt
->bSetNumRule
!= bCheck
;
695 pOpt
->bSetNumRule
= bCheck
;
697 bCheck
= aCheckLB
.IsChecked(INSERT_BORDER
, CBCOL_SECOND
);
698 bModified
|= pOpt
->bSetBorder
!= bCheck
;
699 pOpt
->bSetBorder
= bCheck
;
701 bCheck
= aCheckLB
.IsChecked(CREATE_TABLE
, CBCOL_SECOND
);
702 bModified
|= pOpt
->bCreateTable
!= bCheck
;
703 pOpt
->bCreateTable
= bCheck
;
705 bCheck
= aCheckLB
.IsChecked(REPLACE_STYLES
, CBCOL_SECOND
);
706 bModified
|= pOpt
->bReplaceStyles
!= bCheck
;
707 pOpt
->bReplaceStyles
= bCheck
;
709 bCheck
= aCheckLB
.IsChecked(REPLACE_HALF
, CBCOL_FIRST
);
710 bModified
|= pOpt
->bChgFracionSymbol
!= bCheck
;
711 pOpt
->bChgFracionSymbol
= bCheck
;
712 pAutoCorrect
->SetAutoCorrFlag(ChgFractionSymbol
,
713 aCheckLB
.IsChecked(REPLACE_HALF
, CBCOL_SECOND
));
715 bCheck
= aCheckLB
.IsChecked(REPLACE_DASHES
, CBCOL_FIRST
);
716 bModified
|= pOpt
->bChgToEnEmDash
!= bCheck
;
717 pOpt
->bChgToEnEmDash
= bCheck
;
718 pAutoCorrect
->SetAutoCorrFlag(ChgToEnEmDash
,
719 aCheckLB
.IsChecked(REPLACE_DASHES
, CBCOL_SECOND
));
721 bCheck
= aCheckLB
.IsChecked(ADD_NON_BRK_SPACE
, CBCOL_FIRST
);
722 bModified
|= pOpt
->bAddNonBrkSpace
!= bCheck
;
723 pOpt
->bAddNonBrkSpace
= bCheck
;
724 pAutoCorrect
->SetAutoCorrFlag(AddNonBrkSpace
,
725 aCheckLB
.IsChecked(ADD_NON_BRK_SPACE
, CBCOL_SECOND
));
727 bCheck
= aCheckLB
.IsChecked(DEL_SPACES_AT_STT_END
, CBCOL_FIRST
);
728 bModified
|= pOpt
->bAFmtDelSpacesAtSttEnd
!= bCheck
;
729 pOpt
->bAFmtDelSpacesAtSttEnd
= bCheck
;
730 bCheck
= aCheckLB
.IsChecked(DEL_SPACES_AT_STT_END
, CBCOL_SECOND
);
731 bModified
|= pOpt
->bAFmtByInpDelSpacesAtSttEnd
!= bCheck
;
732 pOpt
->bAFmtByInpDelSpacesAtSttEnd
= bCheck
;
734 bCheck
= aCheckLB
.IsChecked(DEL_SPACES_BETWEEN_LINES
, CBCOL_FIRST
);
735 bModified
|= pOpt
->bAFmtDelSpacesBetweenLines
!= bCheck
;
736 pOpt
->bAFmtDelSpacesBetweenLines
= bCheck
;
737 bCheck
= aCheckLB
.IsChecked(DEL_SPACES_BETWEEN_LINES
, CBCOL_SECOND
);
738 bModified
|= pOpt
->bAFmtByInpDelSpacesBetweenLines
!= bCheck
;
739 pOpt
->bAFmtByInpDelSpacesBetweenLines
= bCheck
;
741 if(bModified
|| nFlags
!= pAutoCorrect
->GetFlags())
743 SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
751 /* -----------------23.11.98 16:15-------------------
753 * --------------------------------------------------*/
754 void OfaSwAutoFmtOptionsPage::ActivatePage( const SfxItemSet
& )
756 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage(FALSE
);
759 /*********************************************************************/
761 /*********************************************************************/
764 void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet
& )
766 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
767 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
768 const long nFlags
= pAutoCorrect
->GetFlags();
770 aCheckLB
.SetUpdateMode(FALSE
);
773 // Die folgenden Eintraege muessen in der selben Reihenfolge, wie im
774 // OfaAutoFmtOptions-enum eingefuegt werden!
775 aCheckLB
.GetModel()->Insert(CreateEntry(sUseReplaceTbl
, CBCOL_BOTH
));
776 aCheckLB
.GetModel()->Insert(CreateEntry(sCptlSttWord
, CBCOL_BOTH
));
777 aCheckLB
.GetModel()->Insert(CreateEntry(sCptlSttSent
, CBCOL_BOTH
));
778 aCheckLB
.GetModel()->Insert(CreateEntry(sBoldUnder
, CBCOL_BOTH
));
779 aCheckLB
.GetModel()->Insert(CreateEntry(sDetectURL
, CBCOL_BOTH
));
780 aCheckLB
.GetModel()->Insert(CreateEntry(sOrdinal
, CBCOL_BOTH
));
781 aCheckLB
.GetModel()->Insert(CreateEntry(sFraction
, CBCOL_BOTH
));
782 aCheckLB
.GetModel()->Insert(CreateEntry(sDash
, CBCOL_BOTH
));
783 aCheckLB
.GetModel()->Insert(CreateEntry(sNonBrkSpace
, CBCOL_BOTH
));
784 aCheckLB
.GetModel()->Insert(CreateEntry(sDelSpaceAtSttEnd
, CBCOL_BOTH
));
785 aCheckLB
.GetModel()->Insert(CreateEntry(sDelSpaceBetweenLines
, CBCOL_BOTH
));
787 aCheckLB
.GetModel()->Insert(CreateEntry(sNoDblSpaces
, CBCOL_SECOND
));
788 aCheckLB
.GetModel()->Insert(CreateEntry(sCorrectCapsLock
, CBCOL_SECOND
));
789 aCheckLB
.GetModel()->Insert(CreateEntry(sNum
, CBCOL_SECOND
));
790 aCheckLB
.GetModel()->Insert(CreateEntry(sBorder
, CBCOL_SECOND
));
791 aCheckLB
.GetModel()->Insert(CreateEntry(sTable
, CBCOL_SECOND
));
792 aCheckLB
.GetModel()->Insert(CreateEntry(sReplaceTemplates
, CBCOL_SECOND
));
793 aCheckLB
.GetModel()->Insert(CreateEntry(sDeleteEmptyPara
, CBCOL_FIRST
));
794 aCheckLB
.GetModel()->Insert(CreateEntry(sUserStyle
, CBCOL_FIRST
));
795 aCheckLB
.GetModel()->Insert(CreateEntry(sBullet
, CBCOL_FIRST
));
796 aCheckLB
.GetModel()->Insert(CreateEntry(sTypo
, CBCOL_FIRST
));
797 aCheckLB
.GetModel()->Insert(CreateEntry(sRightMargin
, CBCOL_FIRST
));
799 aCheckLB
.CheckEntryPos( USE_REPLACE_TABLE
, CBCOL_FIRST
, pOpt
->bAutoCorrect
);
800 aCheckLB
.CheckEntryPos( USE_REPLACE_TABLE
, CBCOL_SECOND
, 0 != (nFlags
& Autocorrect
));
801 aCheckLB
.CheckEntryPos( CORR_UPPER
, CBCOL_FIRST
, pOpt
->bCptlSttWrd
);
802 aCheckLB
.CheckEntryPos( CORR_UPPER
, CBCOL_SECOND
, 0 != (nFlags
& CptlSttWrd
) );
803 aCheckLB
.CheckEntryPos( BEGIN_UPPER
, CBCOL_FIRST
, pOpt
->bCptlSttSntnc
);
804 aCheckLB
.CheckEntryPos( BEGIN_UPPER
, CBCOL_SECOND
, 0 != (nFlags
& CptlSttSntnc
) );
805 aCheckLB
.CheckEntryPos( BOLD_UNDERLINE
, CBCOL_FIRST
, pOpt
->bChgWeightUnderl
);
806 aCheckLB
.CheckEntryPos( BOLD_UNDERLINE
, CBCOL_SECOND
, 0 != (nFlags
& ChgWeightUnderl
) );
807 aCheckLB
.CheckEntryPos( IGNORE_DBLSPACE
, CBCOL_SECOND
, 0 != (nFlags
& IngnoreDoubleSpace
) );
808 aCheckLB
.CheckEntryPos( CORRECT_CAPS_LOCK
, CBCOL_SECOND
, 0 != (nFlags
& CorrectCapsLock
) );
809 aCheckLB
.CheckEntryPos( DETECT_URL
, CBCOL_FIRST
, pOpt
->bSetINetAttr
);
810 aCheckLB
.CheckEntryPos( DETECT_URL
, CBCOL_SECOND
, 0 != (nFlags
& SetINetAttr
) );
811 aCheckLB
.CheckEntryPos( REPLACE_1ST
, CBCOL_FIRST
, pOpt
->bChgOrdinalNumber
);
812 aCheckLB
.CheckEntryPos( REPLACE_1ST
, CBCOL_SECOND
, 0 != (nFlags
& ChgOrdinalNumber
) );
813 aCheckLB
.CheckEntryPos( REPLACE_HALF
, CBCOL_FIRST
, pOpt
->bChgFracionSymbol
);
814 aCheckLB
.CheckEntryPos( REPLACE_HALF
, CBCOL_SECOND
, 0 != (nFlags
& ChgFractionSymbol
) );
815 aCheckLB
.CheckEntryPos( REPLACE_DASHES
, CBCOL_FIRST
, pOpt
->bChgToEnEmDash
);
816 aCheckLB
.CheckEntryPos( REPLACE_DASHES
, CBCOL_SECOND
, 0 != (nFlags
& ChgToEnEmDash
) );
817 aCheckLB
.CheckEntryPos( ADD_NON_BRK_SPACE
, CBCOL_FIRST
, 0 != (nFlags
& AddNonBrkSpace
) );
818 aCheckLB
.CheckEntryPos( ADD_NON_BRK_SPACE
, CBCOL_SECOND
, 0 != (nFlags
& AddNonBrkSpace
) );
819 aCheckLB
.CheckEntryPos( DEL_SPACES_AT_STT_END
, CBCOL_FIRST
, pOpt
->bAFmtDelSpacesAtSttEnd
);
820 aCheckLB
.CheckEntryPos( DEL_SPACES_AT_STT_END
, CBCOL_SECOND
, pOpt
->bAFmtByInpDelSpacesAtSttEnd
);
821 aCheckLB
.CheckEntryPos( DEL_SPACES_BETWEEN_LINES
, CBCOL_FIRST
, pOpt
->bAFmtDelSpacesBetweenLines
);
822 aCheckLB
.CheckEntryPos( DEL_SPACES_BETWEEN_LINES
, CBCOL_SECOND
, pOpt
->bAFmtByInpDelSpacesBetweenLines
);
823 aCheckLB
.CheckEntryPos( DEL_EMPTY_NODE
, CBCOL_FIRST
, pOpt
->bDelEmptyNode
);
824 aCheckLB
.CheckEntryPos( REPLACE_QUOTATION
, CBCOL_FIRST
, pOpt
->bReplaceQuote
);
825 aCheckLB
.CheckEntryPos( REPLACE_USER_COLL
, CBCOL_FIRST
, pOpt
->bChgUserColl
);
826 aCheckLB
.CheckEntryPos( REPLACE_BULLETS
, CBCOL_FIRST
, pOpt
->bChgEnumNum
);
828 aBulletFont
= pOpt
->aBulletFont
;
829 sBulletChar
= pOpt
->cBullet
;
830 ImpUserData
* pUserData
= new ImpUserData(&sBulletChar
, &aBulletFont
);
831 aCheckLB
.SetUserData( REPLACE_BULLETS
, pUserData
);
833 nPercent
= pOpt
->nRightMargin
;
835 sMargin
+= String::CreateFromInt32( nPercent
);
837 pUserData
= new ImpUserData(&sMargin
, 0);
838 aCheckLB
.SetUserData( MERGE_SINGLE_LINE_PARA
, pUserData
);
840 aCheckLB
.CheckEntryPos( APPLY_NUMBERING
, CBCOL_SECOND
, pOpt
->bSetNumRule
);
842 aByInputBulletFont
= pOpt
->aByInputBulletFont
;
843 sByInputBulletChar
= pOpt
->cByInputBullet
;
844 ImpUserData
* pUserData2
= new ImpUserData(&sByInputBulletChar
, &aByInputBulletFont
);
845 aCheckLB
.SetUserData( APPLY_NUMBERING
, pUserData2
);
847 aCheckLB
.CheckEntryPos( MERGE_SINGLE_LINE_PARA
, CBCOL_FIRST
, pOpt
->bRightMargin
);
848 aCheckLB
.CheckEntryPos( INSERT_BORDER
, CBCOL_SECOND
, pOpt
->bSetBorder
);
849 aCheckLB
.CheckEntryPos( CREATE_TABLE
, CBCOL_SECOND
, pOpt
->bCreateTable
);
850 aCheckLB
.CheckEntryPos( REPLACE_STYLES
, CBCOL_SECOND
, pOpt
->bReplaceStyles
);
852 aCheckLB
.SetUpdateMode(TRUE
);
855 /*********************************************************************/
857 /*********************************************************************/
859 IMPL_LINK(OfaSwAutoFmtOptionsPage
, SelectHdl
, OfaACorrCheckListBox
*, pBox
)
861 aEditPB
.Enable(0 != pBox
->FirstSelected()->GetUserData());
865 /*********************************************************************/
867 /*********************************************************************/
869 IMPL_LINK(OfaSwAutoFmtOptionsPage
, EditHdl
, PushButton
*, EMPTYARG
)
871 ULONG nSelEntryPos
= aCheckLB
.GetSelectEntryPos();
872 if( nSelEntryPos
== REPLACE_BULLETS
||
873 nSelEntryPos
== APPLY_NUMBERING
)
875 SvxCharacterMap
*pMapDlg
= new SvxCharacterMap(this);
876 ImpUserData
* pUserData
= (ImpUserData
*)aCheckLB
.FirstSelected()->GetUserData();
877 pMapDlg
->SetCharFont(*pUserData
->pFont
);
878 pMapDlg
->SetChar( pUserData
->pString
->GetChar(0) );
879 if(RET_OK
== pMapDlg
->Execute())
881 Font
aFont(pMapDlg
->GetCharFont());
882 *pUserData
->pFont
= aFont
;
883 sal_UCS4 aChar
= pMapDlg
->GetChar();
884 // using the UCS4 constructor
885 rtl::OUString
aOUStr( &aChar
, 1 );
886 *pUserData
->pString
= aOUStr
;
890 else if( MERGE_SINGLE_LINE_PARA
== nSelEntryPos
)
892 // Dialog fuer Prozenteinstellung
893 OfaAutoFmtPrcntSet
aDlg(this);
894 aDlg
.GetPrcntFld().SetValue(nPercent
);
895 if(RET_OK
== aDlg
.Execute())
897 nPercent
= (USHORT
)aDlg
.GetPrcntFld().GetValue();
899 sMargin
+= String::CreateFromInt32( nPercent
);
903 aCheckLB
.Invalidate();
907 /*********************************************************************/
909 /*********************************************************************/
911 void OfaACorrCheckListBox::SetTabs()
913 SvxSimpleTable::SetTabs();
914 USHORT nAdjust
= SV_LBOXTAB_ADJUST_RIGHT
|SV_LBOXTAB_ADJUST_LEFT
|SV_LBOXTAB_ADJUST_CENTER
|SV_LBOXTAB_ADJUST_NUMERIC
|SV_LBOXTAB_FORCE
;
916 if( aTabs
.Count() > 1 )
918 SvLBoxTab
* pTab
= (SvLBoxTab
*)aTabs
.GetObject(1);
919 pTab
->nFlags
&= ~nAdjust
;
920 pTab
->nFlags
|= SV_LBOXTAB_PUSHABLE
|SV_LBOXTAB_ADJUST_CENTER
|SV_LBOXTAB_FORCE
;
922 if( aTabs
.Count() > 2 )
924 SvLBoxTab
* pTab
= (SvLBoxTab
*)aTabs
.GetObject(2);
925 pTab
->nFlags
&= ~nAdjust
;
926 pTab
->nFlags
|= SV_LBOXTAB_PUSHABLE
|SV_LBOXTAB_ADJUST_CENTER
|SV_LBOXTAB_FORCE
;
930 /*********************************************************************/
932 /*********************************************************************/
934 void OfaACorrCheckListBox::CheckEntryPos(ULONG nPos
, USHORT nCol
, BOOL bChecked
)
936 if ( nPos
< GetEntryCount() )
940 bChecked
? SvButtonState( SV_BUTTON_CHECKED
) :
941 SvButtonState( SV_BUTTON_UNCHECKED
) );
944 /*********************************************************************/
946 /*********************************************************************/
948 BOOL
OfaACorrCheckListBox::IsChecked(ULONG nPos
, USHORT nCol
)
950 return GetCheckButtonState( GetEntry(nPos
), nCol
) == SV_BUTTON_CHECKED
;
953 /*********************************************************************/
955 /*********************************************************************/
957 void OfaACorrCheckListBox::SetCheckButtonState( SvLBoxEntry
* pEntry
, USHORT nCol
, SvButtonState eState
)
959 SvLBoxButton
* pItem
= (SvLBoxButton
*)(pEntry
->GetItem(nCol
+ 1));
961 DBG_ASSERT(pItem
,"SetCheckButton:Item not found");
962 if (((SvLBoxItem
*)pItem
)->IsA() == SV_ITEM_ID_LBOXBUTTON
)
966 case SV_BUTTON_CHECKED
:
967 pItem
->SetStateChecked();
970 case SV_BUTTON_UNCHECKED
:
971 pItem
->SetStateUnchecked();
974 case SV_BUTTON_TRISTATE
:
975 pItem
->SetStateTristate();
978 InvalidateEntry( pEntry
);
982 /*********************************************************************/
984 /*********************************************************************/
986 SvButtonState
OfaACorrCheckListBox::GetCheckButtonState( SvLBoxEntry
* pEntry
, USHORT nCol
) const
988 SvButtonState eState
= SV_BUTTON_UNCHECKED
;
989 SvLBoxButton
* pItem
= (SvLBoxButton
*)(pEntry
->GetItem(nCol
+ 1));
990 DBG_ASSERT(pItem
,"GetChButnState:Item not found");
992 if (((SvLBoxItem
*)pItem
)->IsA() == SV_ITEM_ID_LBOXBUTTON
)
994 USHORT nButtonFlags
= pItem
->GetButtonFlags();
995 eState
= pCheckButtonData
->ConvertToButtonState( nButtonFlags
);
1001 void OfaACorrCheckListBox::HBarClick()
1003 // Sortierung durch diese Ueberladung abgeklemmt
1005 /* -----------------------------22.05.2002 11:06------------------------------
1007 ---------------------------------------------------------------------------*/
1008 void OfaACorrCheckListBox::KeyInput( const KeyEvent
& rKEvt
)
1010 if(!rKEvt
.GetKeyCode().GetModifier() &&
1011 KEY_SPACE
== rKEvt
.GetKeyCode().GetCode())
1013 ULONG nSelPos
= GetSelectEntryPos();
1014 USHORT nCol
= GetCurrentTabPos() - 1;
1017 CheckEntryPos( nSelPos
, nCol
, !IsChecked( nSelPos
, nCol
) );
1018 CallImplEventListeners( VCLEVENT_CHECKBOX_TOGGLE
, (void*)GetEntry( nSelPos
) );
1022 USHORT nCheck
= IsChecked(nSelPos
, 1) ? 1 : 0;
1023 if(IsChecked(nSelPos
, 0))
1027 CheckEntryPos(nSelPos
, 1, 0 != (nCheck
& 1));
1028 CheckEntryPos(nSelPos
, 0, 0 != (nCheck
& 2));
1032 SvxSimpleTable::KeyInput(rKEvt
);
1034 /* -----------------19.11.98 15:57-------------------
1036 * --------------------------------------------------*/
1041 void* pUserData
; // CheckBox -> form. Text Bool -> Selektionstext
1043 typedef DoubleString
* DoubleStringPtr
;
1044 SV_DECL_PTRARR_DEL(DoubleStringArray
, DoubleStringPtr
, 4, 4)
1045 SV_IMPL_PTRARR(DoubleStringArray
, DoubleStringPtr
);
1047 /* -----------------19.11.98 16:07-------------------
1049 * --------------------------------------------------*/
1050 void lcl_ClearTable(DoubleStringTable
& rTable
)
1052 DoubleStringArrayPtr pArray
= rTable
.Last();
1055 pArray
->DeleteAndDestroy(0, pArray
->Count());
1057 pArray
= rTable
.Prev();
1062 /*-----------------14.10.96 15.57-------------------
1064 --------------------------------------------------*/
1066 OfaAutocorrReplacePage::OfaAutocorrReplacePage( Window
* pParent
,
1067 const SfxItemSet
& rSet
) :
1068 SfxTabPage(pParent
, SVX_RES( RID_OFAPAGE_AUTOCORR_REPLACE
), rSet
),
1069 aTextOnlyCB( this, SVX_RES(CB_TEXT_ONLY
)),
1070 aShortFT ( this, SVX_RES(FT_SHORT
)),
1071 aShortED ( this, SVX_RES(ED_SHORT
)),
1072 aReplaceFT( this, SVX_RES(FT_REPLACE
)),
1073 aReplaceED( this, SVX_RES(ED_REPLACE
)),
1074 aReplaceTLB( this, SVX_RES(TLB_REPLACE
)),
1075 aNewReplacePB( this, SVX_RES(PB_NEW_REPLACE
)),
1076 aDeleteReplacePB(this,SVX_RES(PB_DELETE_REPLACE
)),
1077 sModify(SVX_RES(STR_MODIFY
)),
1078 sNew(aNewReplacePB
.GetText()),
1080 eLang(eLastDialogLanguage
),
1081 bHasSelectionText(FALSE
),
1083 bReplaceEditChanged(FALSE
),
1087 SfxModule
*pMod
= *(SfxModule
**)GetAppData(SHL_WRITER
);
1088 bSWriter
= pMod
== SfxModule::GetActiveModule();
1090 ::com::sun::star::lang::Locale
aLcl( SvxCreateLocale(eLastDialogLanguage
));
1091 pCompareClass
= new CollatorWrapper( GetProcessFact() );
1092 pCompareCaseClass
= new CollatorWrapper( GetProcessFact() );
1093 pCompareClass
->loadDefaultCollator( aLcl
, ::com::sun::star::i18n::
1094 CollatorOptions::CollatorOptions_IGNORE_CASE
);
1095 pCompareCaseClass
->loadDefaultCollator( aLcl
, 0 );
1096 pCharClass
= new CharClass( aLcl
);
1098 static long nTabs
[] = { 2 /* Tab-Count */, 1, 61 };
1099 aReplaceTLB
.SetTabs( &nTabs
[0], MAP_APPFONT
);
1101 aReplaceTLB
.SetWindowBits(WB_HSCROLL
|WB_CLIPCHILDREN
);
1102 aReplaceTLB
.SetSelectHdl(LINK(this, OfaAutocorrReplacePage
, SelectHdl
));
1103 aNewReplacePB
.SetClickHdl( LINK(this, OfaAutocorrReplacePage
, NewDelHdl
));
1104 aDeleteReplacePB
.SetClickHdl(LINK(this, OfaAutocorrReplacePage
, NewDelHdl
));
1105 aShortED
.SetModifyHdl(LINK(this, OfaAutocorrReplacePage
, ModifyHdl
));
1106 aReplaceED
.SetModifyHdl(LINK(this, OfaAutocorrReplacePage
, ModifyHdl
));
1107 aShortED
.SetActionHdl(LINK(this, OfaAutocorrReplacePage
, NewDelHdl
));
1108 aReplaceED
.SetActionHdl(LINK(this, OfaAutocorrReplacePage
, NewDelHdl
));
1110 aReplaceED
.SetSpaces(TRUE
);
1111 aShortED
.SetSpaces(TRUE
);
1112 aShortED
.SetMaxTextLen(30);
1115 /*-----------------14.10.96 15.58-------------------
1117 --------------------------------------------------*/
1120 OfaAutocorrReplacePage::~OfaAutocorrReplacePage()
1123 lcl_ClearTable(aDoubleStringTable
);
1124 delete pCompareClass
;
1125 delete pCompareCaseClass
;
1128 /*-----------------14.10.96 15.58-------------------
1130 --------------------------------------------------*/
1132 SfxTabPage
* OfaAutocorrReplacePage::Create( Window
* pParent
,
1133 const SfxItemSet
& rSet
)
1135 return new OfaAutocorrReplacePage(pParent
, rSet
);
1137 /* -----------------20.11.98 13:26-------------------
1139 * --------------------------------------------------*/
1140 void OfaAutocorrReplacePage::ActivatePage( const SfxItemSet
& )
1142 if(eLang
!= eLastDialogLanguage
)
1143 SetLanguage(eLastDialogLanguage
);
1144 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage(TRUE
);
1146 /* -----------------20.11.98 13:26-------------------
1148 * --------------------------------------------------*/
1149 int OfaAutocorrReplacePage::DeactivatePage( SfxItemSet
* )
1153 /*-----------------14.10.96 15.58-------------------
1155 --------------------------------------------------*/
1157 BOOL
OfaAutocorrReplacePage::FillItemSet( SfxItemSet
& )
1159 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
1160 DoubleStringArrayPtr pDoubleStringArray
= aDoubleStringTable
.Last();
1161 while(pDoubleStringArray
)
1163 LanguageType eCurLang
= (LanguageType
)aDoubleStringTable
.GetCurKey();
1164 if(eCurLang
!= eLang
) // die aktuelle Sprache wird weiter hinten behandelt
1166 SvxAutocorrWordList
* pWordList
= pAutoCorrect
->LoadAutocorrWordList(eCurLang
);
1167 USHORT nWordListCount
= pWordList
->Count();
1168 USHORT nDoubleStringArrayCount
= pDoubleStringArray
->Count();
1169 USHORT nPos
= nDoubleStringArrayCount
;
1170 USHORT nLastPos
= nPos
;
1171 // 1. Durchlauf: Eintraege loeschen oder veraendern:
1174 for( USHORT nWordListPos
= nWordListCount
; nWordListPos
; nWordListPos
-- )
1176 SvxAutocorrWordPtr pWordPtr
= pWordList
->GetObject(nWordListPos
- 1);
1177 String
sEntry(pWordPtr
->GetShort());
1178 // formatierter Text steht nur im Writer
1179 BOOL bFound
= !bSWriter
&& !pWordPtr
->IsTextOnly();
1180 while(!bFound
&& nPos
)
1182 DoubleString
* pDouble
= pDoubleStringArray
->GetObject( nPos
- 1);
1184 if( 0 == pCompareClass
->compareString(
1185 sEntry
, pDouble
->sShort
))
1187 nLastPos
= nPos
- 1;
1189 if( !(pWordPtr
->IsTextOnly() == (0 == pDouble
->pUserData
)
1190 && 0 == pCompareCaseClass
->compareString(
1191 pWordPtr
->GetLong(), pDouble
->sLong
) ) )
1193 pAutoCorrect
->PutText(sEntry
, pDouble
->sLong
, eCurLang
);
1195 pDoubleStringArray
->DeleteAndDestroy(nPos
- 1, 1);
1203 pAutoCorrect
->DeleteText(sEntry
, eCurLang
);
1206 nDoubleStringArrayCount
= pDoubleStringArray
->Count();
1207 for(USHORT nDoubleStringArrayPos
= 0; nDoubleStringArrayPos
< nDoubleStringArrayCount
; nDoubleStringArrayPos
++ )
1209 //jetzt sollte es nur noch neue Eintraege geben
1210 DoubleString
* pDouble
= pDoubleStringArray
->GetObject( nDoubleStringArrayPos
);
1211 if(pDouble
->pUserData
== &bHasSelectionText
)
1212 pAutoCorrect
->PutText( pDouble
->sShort
,
1213 *SfxObjectShell::Current(), eCurLang
);
1216 pAutoCorrect
->PutText( pDouble
->sShort
, pDouble
->sLong
,
1221 pDoubleStringArray
->DeleteAndDestroy(0, pDoubleStringArray
->Count());
1222 delete pDoubleStringArray
;
1223 pDoubleStringArray
= aDoubleStringTable
.Prev();
1225 aDoubleStringTable
.Clear();
1226 // jetzt noch die aktuelle Selektion
1227 SvxAutocorrWordList
* pWordList
= pAutoCorrect
->LoadAutocorrWordList(eLang
);
1228 USHORT nWordListCount
= pWordList
->Count();
1229 USHORT nListBoxCount
= (USHORT
)aReplaceTLB
.GetEntryCount();
1231 aReplaceTLB
.SetUpdateMode(FALSE
);
1232 USHORT nListBoxPos
= nListBoxCount
;
1233 USHORT nLastListBoxPos
= nListBoxPos
;
1234 // 1. Durchlauf: Eintraege loeschen oder veraendern:
1237 for( i
= nWordListCount
; i
; i
-- )
1239 SvxAutocorrWordPtr pWordPtr
= pWordList
->GetObject(i
- 1);
1240 String
sEntry(pWordPtr
->GetShort());
1241 // formatierter Text steht nur im Writer
1242 BOOL bFound
= !bSWriter
&& !pWordPtr
->IsTextOnly();
1243 while(!bFound
&& nListBoxPos
)
1245 SvLBoxEntry
* pEntry
= aReplaceTLB
.GetEntry( nListBoxPos
- 1);
1246 if( 0 == pCompareClass
->compareString( sEntry
,
1247 aReplaceTLB
.GetEntryText(pEntry
, 0)))
1249 nLastListBoxPos
= nListBoxPos
- 1;
1251 String sLong
= aReplaceTLB
.GetEntryText(pEntry
, 1);
1252 if( !(pWordPtr
->IsTextOnly() == (0 == pEntry
->GetUserData())
1253 && 0 == pCompareCaseClass
->compareString(
1254 pWordPtr
->GetLong(), sLong
)))
1256 pAutoCorrect
->PutText(sEntry
, sLong
, eLang
);
1258 aReplaceTLB
.GetModel()->Remove(pEntry
);
1264 nListBoxPos
= nLastListBoxPos
;
1267 pAutoCorrect
->DeleteText(sEntry
, eLang
);
1271 nListBoxCount
= (USHORT
)aReplaceTLB
.GetEntryCount();
1272 for(i
= 0; i
< nListBoxCount
; i
++ )
1274 //jetzt sollte es nur noch neue Eintraege geben
1275 SvLBoxEntry
* pEntry
= aReplaceTLB
.GetEntry( i
);
1276 String sShort
= aReplaceTLB
.GetEntryText(pEntry
, 0);
1277 if(pEntry
->GetUserData() == &bHasSelectionText
)
1278 pAutoCorrect
->PutText(sShort
, *SfxObjectShell::Current(), eLang
);
1281 String sLong
= aReplaceTLB
.GetEntryText(pEntry
, 1);
1282 pAutoCorrect
->PutText(sShort
, sLong
, eLang
);
1289 /* -----------------19.11.98 13:16-------------------
1291 * --------------------------------------------------*/
1292 void OfaAutocorrReplacePage::RefillReplaceBox(BOOL bFromReset
,
1293 LanguageType eOldLanguage
,
1294 LanguageType eNewLanguage
)
1296 eLang
= eNewLanguage
;
1298 lcl_ClearTable(aDoubleStringTable
);
1301 DoubleStringArray
* pArray
= 0;
1302 if(aDoubleStringTable
.IsKeyValid(eOldLanguage
))
1304 pArray
= aDoubleStringTable
.Seek(ULONG(eOldLanguage
));
1305 pArray
->DeleteAndDestroy(0, pArray
->Count());
1309 pArray
= new DoubleStringArray
;
1310 aDoubleStringTable
.Insert(ULONG(eOldLanguage
), pArray
);
1313 USHORT nListBoxCount
= (USHORT
)aReplaceTLB
.GetEntryCount();
1315 for(i
= 0; i
< nListBoxCount
; i
++)
1317 DoubleString
* pDouble
= new DoubleString();
1318 SvLBoxEntry
* pEntry
= aReplaceTLB
.GetEntry( i
);
1319 pDouble
->sShort
= aReplaceTLB
.GetEntryText(pEntry
, 0);
1320 pDouble
->sLong
= aReplaceTLB
.GetEntryText(pEntry
, 1);
1321 pDouble
->pUserData
= pEntry
->GetUserData();
1322 pArray
->Insert(pDouble
, i
);
1326 aReplaceTLB
.Clear();
1330 pFormatText
->DeleteAndDestroy(0, pFormatText
->Count());
1332 pFormatText
= new SvStringsISortDtor();
1335 if(aDoubleStringTable
.IsKeyValid(eLang
))
1337 DoubleStringArray
* pArray
= aDoubleStringTable
.Seek(ULONG(eNewLanguage
));
1338 for(USHORT i
= 0; i
< pArray
->Count(); i
++)
1340 DoubleString
* pDouble
= pArray
->GetObject(i
);
1341 BOOL bTextOnly
= 0 == pDouble
->pUserData
;
1342 // formatierter Text wird nur im Writer angeboten
1343 if(bSWriter
|| bTextOnly
)
1345 String
sEntry(pDouble
->sShort
);
1347 sEntry
+= pDouble
->sLong
;
1348 SvLBoxEntry
* pEntry
= aReplaceTLB
.InsertEntry(sEntry
);
1349 aTextOnlyCB
.Check(bTextOnly
);
1351 pEntry
->SetUserData(pDouble
->pUserData
); // Das heisst: mit Formatinfo oder sogar mit Selektionstext
1355 pFormatText
->Insert(new String(pDouble
->sShort
));
1361 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
1362 SvxAutocorrWordList
* pWordList
= pAutoCorrect
->LoadAutocorrWordList(eLang
);
1364 for(USHORT i
= 0; i
< pWordList
->Count(); i
++)
1366 SvxAutocorrWordPtr pWordPtr
= pWordList
->GetObject(i
);
1367 BOOL bTextOnly
= pWordPtr
->IsTextOnly();
1368 // formatierter Text wird nur im Writer angeboten
1369 if(bSWriter
|| bTextOnly
)
1371 String
sEntry(pWordPtr
->GetShort());
1373 sEntry
+= pWordPtr
->GetLong();
1374 SvLBoxEntry
* pEntry
= aReplaceTLB
.InsertEntry(sEntry
);
1375 aTextOnlyCB
.Check(pWordPtr
->IsTextOnly());
1377 pEntry
->SetUserData(&aTextOnlyCB
); // Das heisst: mit Formatinfo
1381 pFormatText
->Insert(new String(pWordPtr
->GetShort()));
1384 aNewReplacePB
.Enable(FALSE
);
1385 aDeleteReplacePB
.Enable(FALSE
);
1389 SfxViewShell
* pViewShell
= SfxViewShell::Current();
1390 if( pViewShell
&& pViewShell
->HasSelection( TRUE
) )
1392 bHasSelectionText
= TRUE
;
1393 const String
sSelection( pViewShell
->GetSelectionText() );
1394 aReplaceED
.SetText( sSelection
);
1395 aTextOnlyCB
.Check( !bSWriter
);
1396 aTextOnlyCB
.Enable( bSWriter
&& sSelection
.Len() );
1399 aTextOnlyCB
.Enable( FALSE
);
1401 /*-----------------14.10.96 15.58-------------------
1403 --------------------------------------------------*/
1405 void OfaAutocorrReplacePage::Reset( const SfxItemSet
& )
1407 RefillReplaceBox(TRUE
, eLang
, eLang
);
1408 aShortED
.GrabFocus();
1411 /* -----------------23.11.98 10:33-------------------
1413 * --------------------------------------------------*/
1414 void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet
)
1416 //save old settings an refill
1419 RefillReplaceBox(FALSE
, eLang
, eSet
);
1420 eLastDialogLanguage
= eSet
;
1421 delete pCompareClass
;
1422 delete pCompareCaseClass
;
1425 ::com::sun::star::lang::Locale
aLcl( SvxCreateLocale(eLastDialogLanguage
));
1426 pCompareClass
= new CollatorWrapper( GetProcessFact() );
1427 pCompareCaseClass
= new CollatorWrapper( GetProcessFact() );
1428 pCompareClass
->loadDefaultCollator( aLcl
, ::com::sun::star::i18n::
1429 CollatorOptions::CollatorOptions_IGNORE_CASE
);
1430 pCompareCaseClass
->loadDefaultCollator( aLcl
, 0 );
1431 pCharClass
= new CharClass( aLcl
);
1432 ModifyHdl(&aShortED
);
1435 /*-----------------14.10.96 15.58-------------------
1437 --------------------------------------------------*/
1440 IMPL_LINK(OfaAutocorrReplacePage
, SelectHdl
, SvTabListBox
*, pBox
)
1442 if(!bFirstSelect
|| !bHasSelectionText
)
1444 SvLBoxEntry
* pEntry
= pBox
->FirstSelected();
1445 String
sTmpShort(pBox
->GetEntryText(pEntry
, 0));
1446 // wird der Text ueber den ModifyHdl gesetzt, dann steht der Cursor sonst immer am Wortanfang,
1447 // obwohl man gerade hier editiert
1448 BOOL bSameContent
= 0 == pCompareClass
->compareString(
1449 sTmpShort
, aShortED
.GetText() );
1450 Selection aSel
= aShortED
.GetSelection();
1451 if(aShortED
.GetText() != sTmpShort
)
1453 aShortED
.SetText(sTmpShort
);
1454 //war es nur eine andere Schreibweise, dann muss die Selektion auch wieder gesetzt werden
1456 aShortED
.SetSelection(aSel
);
1458 aReplaceED
.SetText(pBox
->GetEntryText(pEntry
, 1));
1459 // mit UserData gibt es eine Formatinfo
1460 aTextOnlyCB
.Check(0 == pEntry
->GetUserData());
1463 bFirstSelect
= FALSE
;
1465 aNewReplacePB
.Enable(FALSE
);
1466 aDeleteReplacePB
.Enable();
1470 /*-----------------14.10.96 15.58-------------------
1472 --------------------------------------------------*/
1475 IMPL_LINK(OfaAutocorrReplacePage
, NewDelHdl
, PushButton
*, pBtn
)
1477 SvLBoxEntry
* _pEntry
= aReplaceTLB
.FirstSelected();
1478 if(pBtn
== &aDeleteReplacePB
)
1480 DBG_ASSERT(_pEntry
, "keine Eintrag selektiert");
1483 aReplaceTLB
.GetModel()->Remove(_pEntry
);
1484 ModifyHdl(&aShortED
);
1488 if(pBtn
== &aNewReplacePB
|| aNewReplacePB
.IsEnabled())
1490 SvLBoxEntry
* _pNewEntry
= aReplaceTLB
.FirstSelected();
1491 String
sEntry(aShortED
.GetText());
1492 if(sEntry
.Len() && ( aReplaceED
.GetText().Len() ||
1493 ( bHasSelectionText
&& bSWriter
) ))
1495 aReplaceTLB
.SetUpdateMode(FALSE
);
1496 USHORT nPos
= USHRT_MAX
;
1498 sEntry
+= aReplaceED
.GetText();
1501 nPos
= (USHORT
)aReplaceTLB
.GetModel()->GetAbsPos(_pNewEntry
);
1502 aReplaceTLB
.GetModel()->Remove(_pNewEntry
);
1507 for( j
= 0; j
< aReplaceTLB
.GetEntryCount(); j
++ )
1509 SvLBoxEntry
* pReplaceEntry
= aReplaceTLB
.GetEntry(j
);
1510 if( 0 >= pCompareClass
->compareString(sEntry
,
1511 aReplaceTLB
.GetEntryText(pReplaceEntry
, 0) ) )
1516 SvLBoxEntry
* pInsEntry
=
1517 aReplaceTLB
.InsertEntry(
1518 sEntry
, static_cast< SvLBoxEntry
* >(NULL
), false,
1519 nPos
== USHRT_MAX
? LIST_APPEND
: nPos
);
1520 if( !bReplaceEditChanged
&& !aTextOnlyCB
.IsChecked())
1521 pInsEntry
->SetUserData(&bHasSelectionText
); // neuer formatierter Text
1523 aReplaceTLB
.MakeVisible( pInsEntry
);
1524 aReplaceTLB
.SetUpdateMode(TRUE
);
1525 // falls der Request aus dem ReplaceEdit kam, dann Focus in das ShortEdit setzen
1526 if(aReplaceED
.HasFocus())
1527 aShortED
.GrabFocus();
1533 // das kann nur ein Enter in einem der beiden Edit-Felder sein und das
1534 // bedeutet EndDialog() - muss im KeyInput ausgewertet werden
1537 ModifyHdl(&aShortED
);
1541 /*-----------------17.10.96 07.49-------------------
1543 --------------------------------------------------*/
1544 IMPL_LINK(OfaAutocorrReplacePage
, ModifyHdl
, Edit
*, pEdt
)
1546 SvLBoxEntry
* pFirstSel
= aReplaceTLB
.FirstSelected();
1547 BOOL bShort
= pEdt
== &aShortED
;
1548 const String rEntry
= pEdt
->GetText();
1549 const String rRepString
= aReplaceED
.GetText();
1550 String
aWordStr( pCharClass
->lower( rEntry
));
1556 BOOL bFound
= FALSE
;
1557 BOOL bTmpSelEntry
=FALSE
;
1559 for(USHORT i
= 0; i
< aReplaceTLB
.GetEntryCount(); i
++)
1561 SvLBoxEntry
* pEntry
= aReplaceTLB
.GetEntry( i
);
1562 String aTestStr
=aReplaceTLB
.GetEntryText(pEntry
, 0);
1563 if( 0 == pCompareClass
->compareString(rEntry
, aTestStr
))
1565 if(rRepString
.Len())
1566 bFirstSelect
= TRUE
;
1567 aReplaceTLB
.SetCurEntry(pEntry
);
1569 aNewReplacePB
.SetText(sModify
);
1575 pCharClass
->toLower( aTestStr
);
1576 if(aTestStr
.Search(aWordStr
)==0 && !bTmpSelEntry
)
1578 aReplaceTLB
.MakeVisible(pEntry
);
1585 aReplaceTLB
.SelectAll(FALSE
);
1587 aNewReplacePB
.SetText(sNew
);
1588 if(bReplaceEditChanged
)
1589 aTextOnlyCB
.Enable(FALSE
);
1591 aDeleteReplacePB
.Enable(bFound
);
1593 else if(aReplaceTLB
.GetEntryCount()>0)
1595 SvLBoxEntry
* pEntry
= aReplaceTLB
.GetEntry( 0 );
1596 aReplaceTLB
.MakeVisible(pEntry
);
1602 bReplaceEditChanged
= TRUE
;
1605 aNewReplacePB
.SetText(sModify
);
1609 const String
& rShortTxt
= aShortED
.GetText();
1610 BOOL bEnableNew
= rShortTxt
.Len() &&
1611 ( rRepString
.Len() ||
1612 ( bHasSelectionText
&& bSWriter
)) &&
1613 ( !pFirstSel
|| rRepString
!=
1614 aReplaceTLB
.GetEntryText( pFirstSel
, 1 ) );
1615 if(bEnableNew
&& pFormatText
)
1617 for(USHORT i
= 0; i
< pFormatText
->Count(); i
++)
1618 if(*pFormatText
->GetObject(i
) == rShortTxt
)
1624 aNewReplacePB
.Enable(bEnableNew
);
1629 /* -----------------20.11.98 13:48-------------------
1631 * --------------------------------------------------*/
1633 struct StringsArrays
1636 SvStringsDtor aAbbrevStrings
;
1637 SvStringsDtor aDoubleCapsStrings
;
1640 aAbbrevStrings(5,5), aDoubleCapsStrings(5,5) {}
1642 typedef StringsArrays
* StringsArraysPtr
;
1643 /* -----------------19.11.98 16:07-------------------
1645 * --------------------------------------------------*/
1646 BOOL
lcl_FindInArray(SvStringsDtor
& rStrings
, const String
& rString
)
1648 for(USHORT i
= 0; i
< rStrings
.Count(); i
++)
1649 if(rString
== *rStrings
.GetObject(i
))
1654 void lcl_ClearTable(StringsTable
& rTable
)
1656 StringsArraysPtr pArrays
= rTable
.Last();
1660 pArrays
= rTable
.Prev();
1665 /*-----------------14.10.96 15.57-------------------
1667 --------------------------------------------------*/
1669 OfaAutocorrExceptPage::OfaAutocorrExceptPage( Window
* pParent
,
1670 const SfxItemSet
& rSet
) :
1671 SfxTabPage(pParent
, SVX_RES( RID_OFAPAGE_AUTOCORR_EXCEPT
), rSet
),
1672 aAbbrevFL (this, SVX_RES(FL_ABBREV
)),
1673 aAbbrevED (this, SVX_RES(ED_ABBREV
)),
1674 aAbbrevLB (this, SVX_RES(LB_ABBREV
)),
1675 aNewAbbrevPB (this, SVX_RES(PB_NEWABBREV
)),
1676 aDelAbbrevPB (this, SVX_RES(PB_DELABBREV
)),
1677 aAutoAbbrevCB (this, SVX_RES(CB_AUTOABBREV
)),
1678 aDoubleCapsFL (this, SVX_RES(FL_DOUBLECAPS
)),
1679 aDoubleCapsED (this, SVX_RES(ED_DOUBLE_CAPS
)),
1680 aDoubleCapsLB (this, SVX_RES(LB_DOUBLE_CAPS
)),
1681 aNewDoublePB (this, SVX_RES(PB_NEWDOUBLECAPS
)),
1682 aDelDoublePB (this, SVX_RES(PB_DELDOUBLECAPS
)),
1683 aAutoCapsCB (this, SVX_RES(CB_AUTOCAPS
)),
1684 eLang(eLastDialogLanguage
)
1688 ::com::sun::star::lang::Locale
aLcl( SvxCreateLocale(eLastDialogLanguage
));
1689 pCompareClass
= new CollatorWrapper( GetProcessFact() );
1690 pCompareClass
->loadDefaultCollator( aLcl
, ::com::sun::star::i18n::
1691 CollatorOptions::CollatorOptions_IGNORE_CASE
);
1693 aNewAbbrevPB
.SetClickHdl(LINK(this, OfaAutocorrExceptPage
, NewDelHdl
));
1694 aDelAbbrevPB
.SetClickHdl(LINK(this, OfaAutocorrExceptPage
, NewDelHdl
));
1695 aNewDoublePB
.SetClickHdl(LINK(this, OfaAutocorrExceptPage
, NewDelHdl
));
1696 aDelDoublePB
.SetClickHdl(LINK(this, OfaAutocorrExceptPage
, NewDelHdl
));
1698 aAbbrevLB
.SetSelectHdl(LINK(this, OfaAutocorrExceptPage
, SelectHdl
));
1699 aDoubleCapsLB
.SetSelectHdl(LINK(this, OfaAutocorrExceptPage
, SelectHdl
));
1700 aAbbrevED
.SetModifyHdl(LINK(this, OfaAutocorrExceptPage
, ModifyHdl
));
1701 aDoubleCapsED
.SetModifyHdl(LINK(this, OfaAutocorrExceptPage
, ModifyHdl
));
1703 aAbbrevED
.SetActionHdl(LINK(this, OfaAutocorrExceptPage
, NewDelHdl
));
1704 aDoubleCapsED
.SetActionHdl(LINK(this, OfaAutocorrExceptPage
, NewDelHdl
));
1708 /*-----------------14.10.96 15.58-------------------
1710 --------------------------------------------------*/
1712 OfaAutocorrExceptPage::~OfaAutocorrExceptPage()
1714 lcl_ClearTable(aStringsTable
);
1715 delete pCompareClass
;
1718 /*-----------------14.10.96 15.58-------------------
1720 --------------------------------------------------*/
1722 SfxTabPage
* OfaAutocorrExceptPage::Create( Window
* pParent
,
1723 const SfxItemSet
& rSet
)
1725 return new OfaAutocorrExceptPage(pParent
, rSet
);
1727 /* -----------------20.11.98 13:26-------------------
1729 * --------------------------------------------------*/
1730 void OfaAutocorrExceptPage::ActivatePage( const SfxItemSet
& )
1732 if(eLang
!= eLastDialogLanguage
)
1733 SetLanguage(eLastDialogLanguage
);
1734 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage(TRUE
);
1736 /* -----------------20.11.98 13:26-------------------
1738 * --------------------------------------------------*/
1739 int OfaAutocorrExceptPage::DeactivatePage( SfxItemSet
* )
1743 /*-----------------14.10.96 15.58-------------------
1745 --------------------------------------------------*/
1747 BOOL
OfaAutocorrExceptPage::FillItemSet( SfxItemSet
& )
1749 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
1750 StringsArraysPtr pArrays
= aStringsTable
.Last();
1753 LanguageType eCurLang
= (LanguageType
)aStringsTable
.GetCurKey();
1754 if(eCurLang
!= eLang
) // die aktuelle Sprache wird weiter hinten behandelt
1756 SvStringsISortDtor
* pWrdList
= pAutoCorrect
->LoadWrdSttExceptList(eCurLang
);
1760 USHORT nCount
= pWrdList
->Count();
1762 for( i
= nCount
; i
; )
1764 String
* pString
= pWrdList
->GetObject( --i
);
1765 //Eintrag finden u. gfs entfernen
1766 if( !lcl_FindInArray(pArrays
->aDoubleCapsStrings
, *pString
))
1767 pWrdList
->DeleteAndDestroy( i
);
1769 nCount
= pArrays
->aDoubleCapsStrings
.Count();
1770 for( i
= 0; i
< nCount
; ++i
)
1772 String
* pEntry
= new String( *pArrays
->aDoubleCapsStrings
.GetObject( i
) );
1773 if( !pWrdList
->Insert( pEntry
))
1776 pAutoCorrect
->SaveWrdSttExceptList(eCurLang
);
1779 SvStringsISortDtor
* pCplList
= pAutoCorrect
->LoadCplSttExceptList(eCurLang
);
1783 USHORT nCount
= pCplList
->Count();
1785 for( i
= nCount
; i
; )
1787 String
* pString
= pCplList
->GetObject( --i
);
1788 if( !lcl_FindInArray(pArrays
->aAbbrevStrings
, *pString
))
1789 pCplList
->DeleteAndDestroy( i
);
1791 nCount
= pArrays
->aAbbrevStrings
.Count();
1792 for( i
= 0; i
< nCount
; ++i
)
1794 String
* pEntry
= new String( *pArrays
->aAbbrevStrings
.GetObject(i
) );
1795 if( !pCplList
->Insert( pEntry
))
1798 pAutoCorrect
->SaveCplSttExceptList(eCurLang
);
1801 pArrays
= aStringsTable
.Prev();
1803 aStringsTable
.Clear();
1805 SvStringsISortDtor
* pWrdList
= pAutoCorrect
->LoadWrdSttExceptList(eLang
);
1809 USHORT nCount
= pWrdList
->Count();
1811 for( i
= nCount
; i
; )
1813 String
* pString
= pWrdList
->GetObject( --i
);
1814 if( USHRT_MAX
== aDoubleCapsLB
.GetEntryPos(*pString
) )
1815 pWrdList
->DeleteAndDestroy( i
);
1817 nCount
= aDoubleCapsLB
.GetEntryCount();
1818 for( i
= 0; i
< nCount
; ++i
)
1820 String
* pEntry
= new String( aDoubleCapsLB
.GetEntry( i
) );
1821 if( !pWrdList
->Insert( pEntry
))
1824 pAutoCorrect
->SaveWrdSttExceptList(eLang
);
1827 SvStringsISortDtor
* pCplList
= pAutoCorrect
->LoadCplSttExceptList(eLang
);
1831 USHORT nCount
= pCplList
->Count();
1833 for( i
= nCount
; i
; )
1835 String
* pString
= pCplList
->GetObject( --i
);
1836 if( USHRT_MAX
== aAbbrevLB
.GetEntryPos(*pString
) )
1837 pCplList
->DeleteAndDestroy( i
);
1839 nCount
= aAbbrevLB
.GetEntryCount();
1840 for( i
= 0; i
< nCount
; ++i
)
1842 String
* pEntry
= new String( aAbbrevLB
.GetEntry( i
) );
1843 if( !pCplList
->Insert( pEntry
))
1846 pAutoCorrect
->SaveCplSttExceptList(eLang
);
1848 if(aAutoAbbrevCB
.IsChecked() != aAutoAbbrevCB
.GetSavedValue())
1849 pAutoCorrect
->SetAutoCorrFlag( SaveWordCplSttLst
, aAutoAbbrevCB
.IsChecked());
1850 if(aAutoCapsCB
.IsChecked() != aAutoCapsCB
.GetSavedValue())
1851 pAutoCorrect
->SetAutoCorrFlag( SaveWordWrdSttLst
, aAutoCapsCB
.IsChecked());
1855 /* -----------------23.11.98 10:33-------------------
1857 * --------------------------------------------------*/
1858 void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet
)
1862 //alte Einstellungen speichern und neu fuellen
1863 RefillReplaceBoxes(FALSE
, eLang
, eSet
);
1864 eLastDialogLanguage
= eSet
;
1865 delete pCompareClass
;
1866 pCompareClass
= new CollatorWrapper( GetProcessFact() );
1867 pCompareClass
->loadDefaultCollator( SvxCreateLocale( eLastDialogLanguage
),
1868 ::com::sun::star::i18n::
1869 CollatorOptions::CollatorOptions_IGNORE_CASE
);
1870 ModifyHdl(&aAbbrevED
);
1871 ModifyHdl(&aDoubleCapsED
);
1874 /* -----------------20.11.98 14:06-------------------
1876 * --------------------------------------------------*/
1877 void OfaAutocorrExceptPage::RefillReplaceBoxes(BOOL bFromReset
,
1878 LanguageType eOldLanguage
,
1879 LanguageType eNewLanguage
)
1881 eLang
= eNewLanguage
;
1883 lcl_ClearTable(aStringsTable
);
1886 StringsArraysPtr pArrays
= 0;
1887 if(aStringsTable
.IsKeyValid(eOldLanguage
))
1889 pArrays
= aStringsTable
.Seek(ULONG(eOldLanguage
));
1890 pArrays
->aAbbrevStrings
.DeleteAndDestroy(
1891 0, pArrays
->aAbbrevStrings
.Count());
1892 pArrays
->aDoubleCapsStrings
.DeleteAndDestroy(
1893 0, pArrays
->aDoubleCapsStrings
.Count());
1897 pArrays
= new StringsArrays
;
1898 aStringsTable
.Insert(ULONG(eOldLanguage
), pArrays
);
1902 for(i
= 0; i
< aAbbrevLB
.GetEntryCount(); i
++)
1904 pArrays
->aAbbrevStrings
.Insert(
1905 new String(aAbbrevLB
.GetEntry(i
)), i
);
1908 for(i
= 0; i
< aDoubleCapsLB
.GetEntryCount(); i
++)
1910 pArrays
->aDoubleCapsStrings
.Insert(
1911 new String(aDoubleCapsLB
.GetEntry(i
)), i
);
1914 aDoubleCapsLB
.Clear();
1917 aAbbrevED
.SetText(sTemp
);
1918 aDoubleCapsED
.SetText(sTemp
);
1920 if(aStringsTable
.IsKeyValid(eLang
))
1922 StringsArraysPtr pArrays
= aStringsTable
.Seek(ULONG(eLang
));
1924 for(i
= 0; i
< pArrays
->aAbbrevStrings
.Count(); i
++ )
1926 aAbbrevLB
.InsertEntry(*pArrays
->aAbbrevStrings
.GetObject(i
));
1928 for( i
= 0; i
< pArrays
->aDoubleCapsStrings
.Count(); i
++ )
1930 aDoubleCapsLB
.InsertEntry(*pArrays
->aDoubleCapsStrings
.GetObject(i
));
1935 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
1936 const SvStringsISortDtor
* pCplList
= pAutoCorrect
->GetCplSttExceptList(eLang
);
1937 const SvStringsISortDtor
* pWrdList
= pAutoCorrect
->GetWrdSttExceptList(eLang
);
1939 for( i
= 0; i
< pCplList
->Count(); i
++ )
1941 aAbbrevLB
.InsertEntry(*pCplList
->GetObject(i
));
1943 for( i
= 0; i
< pWrdList
->Count(); i
++ )
1945 aDoubleCapsLB
.InsertEntry(*pWrdList
->GetObject(i
));
1950 /*-----------------14.10.96 15.58-------------------
1952 --------------------------------------------------*/
1954 void OfaAutocorrExceptPage::Reset( const SfxItemSet
& )
1956 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
1957 RefillReplaceBoxes(TRUE
, eLang
, eLang
);
1958 aAutoAbbrevCB
. Check( pAutoCorrect
->IsAutoCorrFlag( SaveWordCplSttLst
));
1959 aAutoCapsCB
. Check( pAutoCorrect
->IsAutoCorrFlag( SaveWordWrdSttLst
));
1960 aAutoAbbrevCB
.SaveValue();
1961 aAutoCapsCB
.SaveValue();
1964 /*-----------------16.10.96 12.27-------------------
1966 --------------------------------------------------*/
1969 IMPL_LINK(OfaAutocorrExceptPage
, NewDelHdl
, PushButton
*, pBtn
)
1971 if((pBtn
== &aNewAbbrevPB
|| pBtn
== (PushButton
*)&aAbbrevED
)
1972 && aAbbrevED
.GetText().Len())
1974 aAbbrevLB
.InsertEntry(aAbbrevED
.GetText());
1975 ModifyHdl(&aAbbrevED
);
1977 else if(pBtn
== &aDelAbbrevPB
)
1979 aAbbrevLB
.RemoveEntry(aAbbrevED
.GetText());
1980 ModifyHdl(&aAbbrevED
);
1982 else if((pBtn
== &aNewDoublePB
|| pBtn
== (PushButton
*)&aDoubleCapsED
)
1983 && aDoubleCapsED
.GetText().Len())
1985 aDoubleCapsLB
.InsertEntry(aDoubleCapsED
.GetText());
1986 ModifyHdl(&aDoubleCapsED
);
1988 else if(pBtn
== &aDelDoublePB
)
1990 aDoubleCapsLB
.RemoveEntry(aDoubleCapsED
.GetText());
1991 ModifyHdl(&aDoubleCapsED
);
1996 /*-----------------16.10.96 12.57-------------------
1998 --------------------------------------------------*/
2000 IMPL_LINK(OfaAutocorrExceptPage
, SelectHdl
, ListBox
*, pBox
)
2002 if(pBox
== &aAbbrevLB
)
2004 aAbbrevED
.SetText(pBox
->GetSelectEntry());
2005 aNewAbbrevPB
.Enable(FALSE
);
2006 aDelAbbrevPB
.Enable();
2010 aDoubleCapsED
.SetText(pBox
->GetSelectEntry());
2011 aNewDoublePB
.Enable(FALSE
);
2012 aDelDoublePB
.Enable();
2017 /*-----------------16.10.96 13.02-------------------
2019 --------------------------------------------------*/
2021 IMPL_LINK(OfaAutocorrExceptPage
, ModifyHdl
, Edit
*, pEdt
)
2023 // BOOL bSame = pEdt->GetText() == ->GetSelectEntry();
2024 const String
& sEntry
= pEdt
->GetText();
2025 BOOL bEntryLen
= 0!= sEntry
.Len();
2026 if(pEdt
== &aAbbrevED
)
2028 BOOL bSame
= lcl_FindEntry(aAbbrevLB
, sEntry
, *pCompareClass
);
2029 if(bSame
&& sEntry
!= aAbbrevLB
.GetSelectEntry())
2030 pEdt
->SetText(aAbbrevLB
.GetSelectEntry());
2031 aNewAbbrevPB
.Enable(!bSame
&& bEntryLen
);
2032 aDelAbbrevPB
.Enable(bSame
&& bEntryLen
);
2036 BOOL bSame
= lcl_FindEntry(aDoubleCapsLB
, sEntry
, *pCompareClass
);
2037 if(bSame
&& sEntry
!= aDoubleCapsLB
.GetSelectEntry())
2038 pEdt
->SetText(aDoubleCapsLB
.GetSelectEntry());
2039 aNewDoublePB
.Enable(!bSame
&& bEntryLen
);
2040 aDelDoublePB
.Enable(bSame
&& bEntryLen
);
2045 /*-----------------16.10.96 15.03-------------------
2047 --------------------------------------------------*/
2049 void AutoCorrEdit::KeyInput( const KeyEvent
& rKEvt
)
2051 const KeyCode aKeyCode
= rKEvt
.GetKeyCode();
2052 const USHORT nModifier
= aKeyCode
.GetModifier();
2053 if( aKeyCode
.GetCode() == KEY_RETURN
)
2055 //wird bei Enter nichts getan, dann doch die Basisklasse rufen
2056 // um den Dialog zu schliessen
2057 if(!nModifier
&& !aActionLink
.Call(this))
2058 Edit::KeyInput(rKEvt
);
2060 else if(bSpaces
|| aKeyCode
.GetCode() != KEY_SPACE
)
2061 Edit::KeyInput(rKEvt
);
2064 /*-----------------03.07.97 13:17-------------------
2066 --------------------------------------------------*/
2068 OfaQuoteTabPage::OfaQuoteTabPage( Window
* pParent
, const SfxItemSet
& rSet
) :
2069 SfxTabPage(pParent
, SVX_RES( RID_OFAPAGE_AUTOCORR_QUOTE
), rSet
),
2070 aSingleFL (this, SVX_RES(FL_SINGLE
)),
2071 aSingleTypoCB (this, SVX_RES(CB_SGL_TYPO
)),
2072 aSglStartQuoteFT (this, SVX_RES(FT_SGL_STARTQUOTE
)),
2073 aSglStartQuotePB (this, SVX_RES(PB_SGL_STARTQUOTE
)),
2074 aSglStartExFT (this, SVX_RES(FT_SGSTEX
)),
2075 aSglEndQuoteFT (this, SVX_RES(FT_SGL_ENDQUOTE
)),
2076 aSglEndQuotePB (this, SVX_RES(PB_SGL_ENDQUOTE
)),
2077 aSglEndExFT (this, SVX_RES(FT_SGENEX
)),
2078 aSglStandardPB (this, SVX_RES(PB_SGL_STD
)),
2080 aDoubleFL (this, SVX_RES(FL_DOUBLE
)),
2081 aTypoCB (this, SVX_RES(CB_TYPO
)),
2082 aStartQuoteFT (this, SVX_RES(FT_STARTQUOTE
)),
2083 aStartQuotePB (this, SVX_RES(PB_STARTQUOTE
)),
2084 aDblStartExFT (this, SVX_RES(FT_DBSTEX
)),
2085 aEndQuoteFT (this, SVX_RES(FT_ENDQUOTE
)),
2086 aEndQuotePB (this, SVX_RES(PB_ENDQUOTE
)),
2087 aDblEndExFT (this, SVX_RES(FT_DBECEX
)),
2088 aDblStandardPB (this, SVX_RES(PB_DBL_STD
)),
2090 sStartQuoteDlg (SVX_RES(STR_CHANGE_START
)),
2091 sEndQuoteDlg (SVX_RES(STR_CHANGE_END
)),
2093 sStandard(SVX_RES(ST_STANDARD
))
2097 aStartQuotePB
.SetClickHdl(LINK(this, OfaQuoteTabPage
, QuoteHdl
));
2098 aEndQuotePB
.SetClickHdl(LINK(this, OfaQuoteTabPage
, QuoteHdl
));
2099 aSglStartQuotePB
.SetClickHdl(LINK(this, OfaQuoteTabPage
, QuoteHdl
));
2100 aSglEndQuotePB
.SetClickHdl(LINK(this, OfaQuoteTabPage
, QuoteHdl
));
2101 aDblStandardPB
.SetClickHdl(LINK(this, OfaQuoteTabPage
, StdQuoteHdl
));
2102 aSglStandardPB
.SetClickHdl(LINK(this, OfaQuoteTabPage
, StdQuoteHdl
));
2105 /*-----------------03.07.97 13:17-------------------
2107 --------------------------------------------------*/
2108 OfaQuoteTabPage::~OfaQuoteTabPage()
2111 /*-----------------03.07.97 13:17-------------------
2113 --------------------------------------------------*/
2114 SfxTabPage
* OfaQuoteTabPage::Create( Window
* pParent
,
2115 const SfxItemSet
& rAttrSet
)
2117 return new OfaQuoteTabPage(pParent
, rAttrSet
);
2119 /*-----------------03.07.97 13:18-------------------
2121 --------------------------------------------------*/
2122 BOOL
OfaQuoteTabPage::FillItemSet( SfxItemSet
& )
2124 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2126 long nFlags
= pAutoCorrect
->GetFlags();
2127 pAutoCorrect
->SetAutoCorrFlag(ChgQuotes
, aTypoCB
.IsChecked());
2128 pAutoCorrect
->SetAutoCorrFlag(ChgSglQuotes
, aSingleTypoCB
.IsChecked());
2129 BOOL bReturn
= nFlags
!= pAutoCorrect
->GetFlags();
2130 if(cStartQuote
!= pAutoCorrect
->GetStartDoubleQuote())
2133 sal_Unicode cUCS2
= static_cast<sal_Unicode
>(cStartQuote
); //TODO
2134 pAutoCorrect
->SetStartDoubleQuote(cUCS2
);
2136 if(cEndQuote
!= pAutoCorrect
->GetEndDoubleQuote())
2139 sal_Unicode cUCS2
= static_cast<sal_Unicode
>(cEndQuote
); //TODO
2140 pAutoCorrect
->SetEndDoubleQuote(cUCS2
);
2142 if(cSglStartQuote
!= pAutoCorrect
->GetStartSingleQuote())
2145 sal_Unicode cUCS2
= static_cast<sal_Unicode
>(cSglStartQuote
); //TODO
2146 pAutoCorrect
->SetStartSingleQuote(cUCS2
);
2148 if(cSglEndQuote
!= pAutoCorrect
->GetEndSingleQuote())
2151 sal_Unicode cUCS2
= static_cast<sal_Unicode
>(cSglEndQuote
); //TODO
2152 pAutoCorrect
->SetEndSingleQuote(cUCS2
);
2157 SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
2158 pCfg
->SetModified();
2163 /* -----------------23.11.98 16:15-------------------
2165 * --------------------------------------------------*/
2166 void OfaQuoteTabPage::ActivatePage( const SfxItemSet
& )
2168 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage(FALSE
);
2170 /*-----------------03.07.97 13:18-------------------
2172 --------------------------------------------------*/
2173 void OfaQuoteTabPage::Reset( const SfxItemSet
& )
2175 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2176 const long nFlags
= pAutoCorrect
->GetFlags();
2178 aTypoCB
.Check(0 != (nFlags
& ChgQuotes
));
2179 aSingleTypoCB
.Check(0 != (nFlags
& ChgSglQuotes
));
2180 aTypoCB
.SaveValue();
2181 aSingleTypoCB
.SaveValue();
2183 cStartQuote
= pAutoCorrect
->GetStartDoubleQuote();
2184 cEndQuote
= pAutoCorrect
->GetEndDoubleQuote();
2185 cSglStartQuote
= pAutoCorrect
->GetStartSingleQuote();
2186 cSglEndQuote
= pAutoCorrect
->GetEndSingleQuote();
2188 aSglStartExFT
.SetText(ChangeStringExt_Impl(cSglStartQuote
));
2189 aSglEndExFT
.SetText(ChangeStringExt_Impl(cSglEndQuote
));
2190 aDblStartExFT
.SetText(ChangeStringExt_Impl(cStartQuote
));
2191 aDblEndExFT
.SetText(ChangeStringExt_Impl(cEndQuote
));
2195 /*-----------------15.10.96 16.42-------------------
2197 --------------------------------------------------*/
2204 IMPL_LINK( OfaQuoteTabPage
, QuoteHdl
, PushButton
*, pBtn
)
2206 USHORT nMode
= SGL_START
;
2207 if(pBtn
== &aSglEndQuotePB
)
2209 else if(pBtn
== &aStartQuotePB
)
2211 else if(pBtn
== &aEndQuotePB
)
2213 // Zeichenauswahl-Dialog starten
2214 SvxCharacterMap
* pMap
= new SvxCharacterMap( this, TRUE
);
2215 pMap
->SetCharFont( OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT
,
2216 LANGUAGE_ENGLISH_US
, DEFAULTFONT_FLAGS_ONLYONE
, 0 ));
2217 pMap
->SetText(nMode
< SGL_END
? sStartQuoteDlg
: sEndQuoteDlg
);
2219 //The two lines below are added by BerryJia for Bug95846 Time:2002-8-13 15:50
2220 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2221 LanguageType eLang
= Application::GetSettings().GetLanguage();
2225 cDlg
= cSglStartQuote
;
2227 cDlg
= pAutoCorrect
->GetQuote('\'',TRUE
,eLang
); //add by BerryJia for Bug95846 Time:2002-8-13 15:50
2230 cDlg
= cSglEndQuote
;
2232 cDlg
= pAutoCorrect
->GetQuote('\'',FALSE
,eLang
); //add by BerryJia for Bug95846 Time:2002-8-13 15:50
2237 cDlg
= pAutoCorrect
->GetQuote('\"',TRUE
,eLang
); //add by BerryJia for Bug95846 Time:2002-8-13 15:50
2242 cDlg
= pAutoCorrect
->GetQuote('\"',FALSE
,eLang
); //add by BerryJia for Bug95846 Time:2002-8-13 15:50
2245 DBG_ERROR("svx::OfaQuoteTabPage::QuoteHdl(), how to initialize cDlg?" );
2250 pMap
->SetChar( cDlg
);
2251 pMap
->DisableFontSelection();
2252 if(pMap
->Execute() == RET_OK
)
2254 sal_UCS4 cNewChar
= pMap
->GetChar();
2258 cSglStartQuote
= cNewChar
;
2259 aSglStartExFT
.SetText(ChangeStringExt_Impl(cNewChar
));
2262 cSglEndQuote
= cNewChar
;
2263 aSglEndExFT
.SetText(ChangeStringExt_Impl(cNewChar
));
2266 cStartQuote
= cNewChar
;
2267 aDblStartExFT
.SetText(ChangeStringExt_Impl(cNewChar
));
2270 cEndQuote
= cNewChar
;
2271 aDblEndExFT
.SetText(ChangeStringExt_Impl(cNewChar
));
2280 /*-----------------27.06.97 09.55-------------------
2282 --------------------------------------------------*/
2283 IMPL_LINK( OfaQuoteTabPage
, StdQuoteHdl
, PushButton
*, pBtn
)
2285 if(pBtn
== &aDblStandardPB
)
2288 aDblStartExFT
.SetText(ChangeStringExt_Impl(0));
2290 aDblEndExFT
.SetText(ChangeStringExt_Impl(0));
2296 aSglStartExFT
.SetText(ChangeStringExt_Impl(0));
2298 aSglEndExFT
.SetText(ChangeStringExt_Impl(0));
2303 // --------------------------------------------------
2305 String
OfaQuoteTabPage::ChangeStringExt_Impl( sal_UCS4 cChar
)
2310 // convert codepoint value to unicode-hex string
2311 sal_UCS4 aStrCodes
[32] = { 0, ' ', '(', 'U', '+', '0' };
2312 aStrCodes
[0] = cChar
;
2315 while( (cChar
>> (4*nHexLen
)) != 0 )
2317 for( int i
= nHexLen
; --i
>= 0;)
2319 sal_UCS4 cHexDigit
= ((cChar
>> (4*i
)) & 0x0f) + '0';
2320 if( cHexDigit
> '9' )
2321 cHexDigit
+= 'A' - ('9' + 1);
2322 aStrCodes
[ nFullLen
++ ] = cHexDigit
;
2324 aStrCodes
[ nFullLen
++ ] = ')';
2325 // using the new UCS4 constructor
2326 rtl::OUString
aOUStr( aStrCodes
, nFullLen
);
2330 OfaAutoCompleteTabPage::OfaAutoCompleteTabPage( Window
* pParent
,
2331 const SfxItemSet
& rSet
)
2332 : SfxTabPage(pParent
, SVX_RES( RID_OFAPAGE_AUTOCOMPLETE_OPTIONS
), rSet
),
2333 aCBActiv (this, SVX_RES(CB_ACTIV
)),
2334 aCBAppendSpace (this, SVX_RES(CB_APPEND_SPACE
)),
2335 aCBAsTip (this, SVX_RES(CB_AS_TIP
)),
2336 aCBCollect (this, SVX_RES(CB_COLLECT
)),
2337 aCBRemoveList (this, SVX_RES(CB_REMOVE_LIST
)),
2338 aFTExpandKey (this, SVX_RES(FT_EXPAND_KEY
)),
2339 aDCBExpandKey (this, SVX_RES(DCB_EXPAND_KEY
)),
2340 aFTMinWordlen (this, SVX_RES(FT_MIN_WORDLEN
)),
2341 aNFMinWordlen (this, SVX_RES(NF_MIN_WORDLEN
)),
2342 aFTMaxEntries (this, SVX_RES(FT_MAX_ENTRIES
)),
2343 aNFMaxEntries (this, SVX_RES(NF_MAX_ENTRIES
)),
2344 aLBEntries (*this, SVX_RES(LB_ENTRIES
)),
2345 aPBEntries (this, SVX_RES(PB_ENTRIES
)),
2346 pAutoCmpltList( 0 ),
2347 nAutoCmpltListCnt( 0 )
2352 static const USHORT aKeyCodes
[] = {
2361 for( const USHORT
* pKeys
= aKeyCodes
; *pKeys
; ++pKeys
)
2363 KeyCode
aKCode( *pKeys
);
2364 USHORT nPos
= aDCBExpandKey
.InsertEntry( aKCode
.GetName() );
2365 aDCBExpandKey
.SetEntryData( nPos
, (void*)(ULONG
)*pKeys
);
2366 if( KEY_RETURN
== *pKeys
) // default to RETURN
2367 aDCBExpandKey
.SelectEntryPos( nPos
);
2370 aPBEntries
.SetClickHdl(LINK(this, OfaAutoCompleteTabPage
, DeleteHdl
));
2371 aCBActiv
.SetToggleHdl(LINK(this, OfaAutoCompleteTabPage
, CheckHdl
));
2372 aCBCollect
.SetToggleHdl(LINK(this, OfaAutoCompleteTabPage
, CheckHdl
));
2375 OfaAutoCompleteTabPage::~OfaAutoCompleteTabPage()
2379 SfxTabPage
* OfaAutoCompleteTabPage::Create( Window
* pParent
,
2380 const SfxItemSet
& rSet
)
2382 return new OfaAutoCompleteTabPage( pParent
, rSet
);
2385 BOOL
OfaAutoCompleteTabPage::FillItemSet( SfxItemSet
& )
2387 BOOL bModified
= FALSE
, bCheck
;
2388 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2389 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
2392 bCheck
= aCBActiv
.IsChecked();
2393 bModified
|= pOpt
->bAutoCompleteWords
!= bCheck
;
2394 pOpt
->bAutoCompleteWords
= bCheck
;
2395 bCheck
= aCBCollect
.IsChecked();
2396 bModified
|= pOpt
->bAutoCmpltCollectWords
!= bCheck
;
2397 pOpt
->bAutoCmpltCollectWords
= bCheck
;
2398 bCheck
= !aCBRemoveList
.IsChecked(); // inverted value!
2399 bModified
|= pOpt
->bAutoCmpltKeepList
!= bCheck
;
2400 pOpt
->bAutoCmpltKeepList
= bCheck
;
2401 bCheck
= aCBAppendSpace
.IsChecked();
2402 bModified
|= pOpt
->bAutoCmpltAppendBlanc
!= bCheck
;
2403 pOpt
->bAutoCmpltAppendBlanc
= bCheck
;
2404 bCheck
= aCBAsTip
.IsChecked();
2405 bModified
|= pOpt
->bAutoCmpltShowAsTip
!= bCheck
;
2406 pOpt
->bAutoCmpltShowAsTip
= bCheck
;
2408 nVal
= (USHORT
)aNFMinWordlen
.GetValue();
2409 bModified
|= nVal
!= pOpt
->nAutoCmpltWordLen
;
2410 pOpt
->nAutoCmpltWordLen
= nVal
;
2412 nVal
= (USHORT
)aNFMaxEntries
.GetValue();
2413 bModified
|= nVal
!= pOpt
->nAutoCmpltListLen
;
2414 pOpt
->nAutoCmpltListLen
= nVal
;
2416 nVal
= aDCBExpandKey
.GetSelectEntryPos();
2417 if( nVal
< aDCBExpandKey
.GetEntryCount() )
2419 ULONG nKey
= (ULONG
)aDCBExpandKey
.GetEntryData( nVal
);
2420 bModified
|= nKey
!= pOpt
->nAutoCmpltExpandKey
;
2421 pOpt
->nAutoCmpltExpandKey
= (USHORT
)nKey
;
2424 if( pAutoCmpltList
&& nAutoCmpltListCnt
!= aLBEntries
.GetEntryCount() )
2427 pOpt
->pAutoCmpltList
= pAutoCmpltList
;
2431 SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
2432 pCfg
->SetModified();
2438 void OfaAutoCompleteTabPage::Reset( const SfxItemSet
& )
2440 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2441 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
2443 aCBActiv
.Check( 0 != pOpt
->bAutoCompleteWords
);
2444 aCBCollect
.Check( 0 != pOpt
->bAutoCmpltCollectWords
);
2445 aCBRemoveList
.Check( !pOpt
->bAutoCmpltKeepList
); //inverted value!
2446 aCBAppendSpace
.Check( 0 != pOpt
->bAutoCmpltAppendBlanc
);
2447 aCBAsTip
.Check( 0 != pOpt
->bAutoCmpltShowAsTip
);
2449 aNFMinWordlen
.SetValue( pOpt
->nAutoCmpltWordLen
);
2450 aNFMaxEntries
.SetValue( pOpt
->nAutoCmpltListLen
);
2452 // select the specific KeyCode:
2454 ULONG nKey
= pOpt
->nAutoCmpltExpandKey
;
2455 for( USHORT n
= 0, nCnt
= aDCBExpandKey
.GetEntryCount(); n
< nCnt
; ++n
)
2456 if( nKey
== (ULONG
)aDCBExpandKey
.GetEntryData( n
))
2458 aDCBExpandKey
.SelectEntryPos( n
);
2463 if( pOpt
->pAutoCmpltList
&& pOpt
->pAutoCmpltList
->Count() )
2465 pAutoCmpltList
= (SvStringsISortDtor
*)pOpt
->pAutoCmpltList
;
2466 pOpt
->pAutoCmpltList
= 0;
2467 nAutoCmpltListCnt
= pAutoCmpltList
->Count();
2468 for( USHORT n
= 0; n
< nAutoCmpltListCnt
; ++n
)
2470 const StringPtr pStr
= pAutoCmpltList
->GetObject( n
);
2471 USHORT nPos
= aLBEntries
.InsertEntry( *pStr
);
2472 aLBEntries
.SetEntryData( nPos
, (void*)pStr
);
2477 aLBEntries
.Disable();
2478 aPBEntries
.Disable();
2481 CheckHdl( &aCBActiv
);
2482 CheckHdl( &aCBCollect
);
2485 void OfaAutoCompleteTabPage::ActivatePage( const SfxItemSet
& )
2487 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage( FALSE
);
2490 IMPL_LINK( OfaAutoCompleteTabPage
, DeleteHdl
, PushButton
*, EMPTYARG
)
2492 USHORT nSelCnt
= pAutoCmpltList
? aLBEntries
.GetSelectEntryCount() : 0;
2495 USHORT nPos
= aLBEntries
.GetSelectEntryPos( --nSelCnt
);
2496 const StringPtr pStr
= (StringPtr
)aLBEntries
.GetEntryData( nPos
);
2497 aLBEntries
.RemoveEntry( nPos
);
2498 nPos
= pAutoCmpltList
->GetPos( pStr
);
2499 if( USHRT_MAX
!= nPos
)
2500 pAutoCmpltList
->Remove( nPos
);
2505 IMPL_LINK( OfaAutoCompleteTabPage
, CheckHdl
, CheckBox
*, pBox
)
2507 BOOL bEnable
= pBox
->IsChecked();
2508 if( pBox
== &aCBActiv
)
2510 aCBAppendSpace
.Enable( bEnable
);
2511 aCBAppendSpace
.Enable( bEnable
);
2512 aCBAsTip
.Enable( bEnable
);
2513 aDCBExpandKey
.Enable( bEnable
);
2515 else if(&aCBCollect
== pBox
)
2516 aCBRemoveList
.Enable( bEnable
);
2520 void OfaAutoCompleteTabPage::CopyToClipboard() const
2522 USHORT nSelCnt
= aLBEntries
.GetSelectEntryCount();
2523 if( pAutoCmpltList
&& nSelCnt
)
2525 TransferDataContainer
* pCntnr
= new TransferDataContainer
;
2526 ::com::sun::star::uno::Reference
<
2527 ::com::sun::star::datatransfer::XTransferable
> xRef( pCntnr
);
2530 const sal_Char
* pLineEnd
=
2537 rtl_TextEncoding nEncode
= gsl_getSystemTextEncoding();
2539 for( USHORT n
= 0; n
< nSelCnt
; ++n
)
2541 sData
+= ByteString( aLBEntries
.GetSelectEntry( n
), nEncode
);
2544 pCntnr
->CopyByteString( SOT_FORMAT_STRING
, sData
);
2545 pCntnr
->CopyToClipboard( (Window
*)this );
2549 long OfaAutoCompleteTabPage::AutoCompleteMultiListBox::PreNotify(
2550 NotifyEvent
& rNEvt
)
2552 long nHandled
= MultiListBox::PreNotify( rNEvt
);
2554 if( !nHandled
&& EVENT_KEYUP
== rNEvt
.GetType() )
2556 const KeyCode
& rKeyCode
= rNEvt
.GetKeyEvent()->GetKeyCode();
2557 switch( rKeyCode
.GetModifier() | rKeyCode
.GetCode() )
2560 rPage
.DeleteHdl( 0 );
2565 if( KEYFUNC_COPY
== rKeyCode
.GetFunction() )
2567 rPage
.CopyToClipboard();
2576 // class OfaSmartTagOptionsTabPage ---------------------------------------------
2578 OfaSmartTagOptionsTabPage::OfaSmartTagOptionsTabPage( Window
* pParent
,
2579 const SfxItemSet
& rSet
)
2580 : SfxTabPage(pParent
, SVX_RES( RID_OFAPAGE_SMARTTAG_OPTIONS
), rSet
),
2581 m_aMainCB( this, SVX_RES(CB_SMARTTAGS
) ),
2582 m_aSmartTagTypesLB( this, SVX_RES(LB_SMARTTAGS
) ),
2583 m_aPropertiesPB( this, SVX_RES(PB_SMARTTAGS
) ),
2584 m_aTitleFT( this, SVX_RES(FT_SMARTTAGS
) )
2588 // some options for the list box:
2589 m_aSmartTagTypesLB
.SetWindowBits( m_aSmartTagTypesLB
.GetStyle() | WB_HSCROLL
| WB_HIDESELECTION
);
2590 m_aSmartTagTypesLB
.SetHighlightRange();
2592 // set the handlers:
2593 m_aMainCB
.SetToggleHdl(LINK(this, OfaSmartTagOptionsTabPage
, CheckHdl
));
2594 m_aPropertiesPB
.SetClickHdl(LINK(this, OfaSmartTagOptionsTabPage
, ClickHdl
));
2595 m_aSmartTagTypesLB
.SetSelectHdl(LINK(this, OfaSmartTagOptionsTabPage
, SelectHdl
));
2598 OfaSmartTagOptionsTabPage::~OfaSmartTagOptionsTabPage()
2603 SfxTabPage
* OfaSmartTagOptionsTabPage::Create( Window
* pParent
, const SfxItemSet
& rSet
)
2605 return new OfaSmartTagOptionsTabPage( pParent
, rSet
);
2608 /** This struct is used to associate list box entries with smart tag data
2610 struct ImplSmartTagLBUserData
2612 rtl::OUString maSmartTagType
;
2613 uno::Reference
< smarttags::XSmartTagRecognizer
> mxRec
;
2614 sal_Int32 mnSmartTagIdx
;
2616 ImplSmartTagLBUserData( const rtl::OUString
& rSmartTagType
,
2617 uno::Reference
< smarttags::XSmartTagRecognizer
> xRec
,
2618 sal_Int32 nSmartTagIdx
) :
2619 maSmartTagType( rSmartTagType
),
2621 mnSmartTagIdx( nSmartTagIdx
) {}
2624 /** Clears m_aSmartTagTypesLB
2626 void OfaSmartTagOptionsTabPage::ClearListBox()
2628 const ULONG nCount
= m_aSmartTagTypesLB
.GetEntryCount();
2629 for ( USHORT i
= 0; i
< nCount
; ++i
)
2631 const SvLBoxEntry
* pEntry
= m_aSmartTagTypesLB
.GetEntry(i
);
2632 const ImplSmartTagLBUserData
* pUserData
= static_cast< ImplSmartTagLBUserData
* >(pEntry
->GetUserData());
2636 m_aSmartTagTypesLB
.Clear();
2639 /** Inserts items into m_aSmartTagTypesLB
2641 void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr
& rSmartTagMgr
)
2643 // first we have to clear the list box:
2647 const sal_uInt32 nNumberOfRecognizers
= rSmartTagMgr
.NumberOfRecognizers();
2648 const lang::Locale
aLocale( SvxCreateLocale( eLastDialogLanguage
) );
2649 std::vector
< ActionReference
> aActionReferences
;
2651 for ( sal_uInt32 i
= 0; i
< nNumberOfRecognizers
; ++i
)
2653 uno::Reference
< smarttags::XSmartTagRecognizer
> xRec
= rSmartTagMgr
.GetRecognizer(i
);
2655 const rtl::OUString aName
= xRec
->getName( aLocale
);
2656 const rtl::OUString aDesc
= xRec
->getDescription( aLocale
);
2657 const sal_Int32 nNumberOfSupportedSmartTags
= xRec
->getSmartTagCount();
2659 for ( sal_Int32 j
= 0; j
< nNumberOfSupportedSmartTags
; ++j
)
2661 const rtl::OUString aSmartTagType
= xRec
->getSmartTagName(j
);
2662 rtl::OUString aSmartTagCaption
= rSmartTagMgr
.GetSmartTagCaption( aSmartTagType
, aLocale
);
2664 if ( !aSmartTagCaption
.getLength() )
2665 aSmartTagCaption
= aSmartTagType
;
2667 const rtl::OUString aLBEntry
= aSmartTagCaption
+
2668 OUString::createFromAscii(" (") +
2670 OUString::createFromAscii(")");
2672 SvLBoxEntry
* pEntry
= m_aSmartTagTypesLB
.SvTreeListBox::InsertEntry( aLBEntry
);
2675 const bool bCheck
= rSmartTagMgr
.IsSmartTagTypeEnabled( aSmartTagType
);
2676 m_aSmartTagTypesLB
.SetCheckButtonState( pEntry
, bCheck
? SV_BUTTON_CHECKED
: SV_BUTTON_UNCHECKED
);
2677 pEntry
->SetUserData(static_cast<void*>(new ImplSmartTagLBUserData( aSmartTagType
, xRec
, j
) ) );
2683 /** Handler for the push button
2685 IMPL_LINK( OfaSmartTagOptionsTabPage
, ClickHdl
, PushButton
*, EMPTYARG
)
2687 const USHORT nPos
= m_aSmartTagTypesLB
.GetSelectEntryPos();
2688 const SvLBoxEntry
* pEntry
= m_aSmartTagTypesLB
.GetEntry(nPos
);
2689 const ImplSmartTagLBUserData
* pUserData
= static_cast< ImplSmartTagLBUserData
* >(pEntry
->GetUserData());
2690 uno::Reference
< smarttags::XSmartTagRecognizer
> xRec
= pUserData
->mxRec
;
2691 const sal_Int32 nSmartTagIdx
= pUserData
->mnSmartTagIdx
;
2693 const lang::Locale
aLocale( SvxCreateLocale( eLastDialogLanguage
) );
2694 if ( xRec
->hasPropertyPage( nSmartTagIdx
, aLocale
) )
2695 xRec
->displayPropertyPage( nSmartTagIdx
, aLocale
);
2700 /** Handler for the check box
2702 IMPL_LINK( OfaSmartTagOptionsTabPage
, CheckHdl
, CheckBox
*, EMPTYARG
)
2704 const BOOL bEnable
= m_aMainCB
.IsChecked();
2705 m_aSmartTagTypesLB
.Enable( bEnable
);
2706 m_aSmartTagTypesLB
.Invalidate();
2707 m_aPropertiesPB
.Enable( false );
2709 // if the controls are currently enabled, we still have to check
2710 // if the properties button should be disabled because the currently
2711 // seleted smart tag type does not have a properties dialog.
2712 // We do this by calling SelectHdl:
2714 SelectHdl( &m_aSmartTagTypesLB
);
2719 /** Handler for the list box
2721 IMPL_LINK(OfaSmartTagOptionsTabPage
, SelectHdl
, SvxCheckListBox
*, EMPTYARG
)
2723 if ( m_aSmartTagTypesLB
.GetEntryCount() < 1 )
2726 const USHORT nPos
= m_aSmartTagTypesLB
.GetSelectEntryPos();
2727 const SvLBoxEntry
* pEntry
= m_aSmartTagTypesLB
.GetEntry(nPos
);
2728 const ImplSmartTagLBUserData
* pUserData
= static_cast< ImplSmartTagLBUserData
* >(pEntry
->GetUserData());
2729 uno::Reference
< smarttags::XSmartTagRecognizer
> xRec
= pUserData
->mxRec
;
2730 const sal_Int32 nSmartTagIdx
= pUserData
->mnSmartTagIdx
;
2732 const lang::Locale
aLocale( SvxCreateLocale( eLastDialogLanguage
) );
2733 if ( xRec
->hasPropertyPage( nSmartTagIdx
, aLocale
) )
2734 m_aPropertiesPB
.Enable( sal_True
);
2736 m_aPropertiesPB
.Enable( sal_False
);
2741 /** Propagates the current settings to the smart tag manager.
2743 BOOL
OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet
& )
2745 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2746 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
2747 SmartTagMgr
* pSmartTagMgr
= pOpt
->pSmartTagMgr
;
2750 if ( !pSmartTagMgr
)
2753 BOOL bModifiedSmartTagTypes
= FALSE
;
2754 std::vector
< rtl::OUString
> aDisabledSmartTagTypes
;
2756 const ULONG nCount
= m_aSmartTagTypesLB
.GetEntryCount();
2758 for ( USHORT i
= 0; i
< nCount
; ++i
)
2760 const SvLBoxEntry
* pEntry
= m_aSmartTagTypesLB
.GetEntry(i
);
2761 const ImplSmartTagLBUserData
* pUserData
= static_cast< ImplSmartTagLBUserData
* >(pEntry
->GetUserData());
2762 const BOOL bChecked
= m_aSmartTagTypesLB
.IsChecked(i
);
2763 const BOOL bIsCurrentlyEnabled
= pSmartTagMgr
->IsSmartTagTypeEnabled( pUserData
->maSmartTagType
);
2765 bModifiedSmartTagTypes
= bModifiedSmartTagTypes
|| ( !bChecked
!= !bIsCurrentlyEnabled
);
2768 aDisabledSmartTagTypes
.push_back( pUserData
->maSmartTagType
);
2773 const BOOL bModifiedRecognize
= ( !m_aMainCB
.IsChecked() != !pSmartTagMgr
->IsLabelTextWithSmartTags() );
2774 if ( bModifiedSmartTagTypes
|| bModifiedRecognize
)
2776 bool bLabelTextWithSmartTags
= m_aMainCB
.IsChecked() ? true : false;
2777 pSmartTagMgr
->WriteConfiguration( bModifiedRecognize
? &bLabelTextWithSmartTags
: 0,
2778 bModifiedSmartTagTypes
? &aDisabledSmartTagTypes
: 0 );
2784 /** Sets the controls based on the current settings at SmartTagMgr.
2786 void OfaSmartTagOptionsTabPage::Reset( const SfxItemSet
& )
2788 SvxAutoCorrect
* pAutoCorrect
= SvxAutoCorrCfg::Get()->GetAutoCorrect();
2789 SvxSwAutoFmtFlags
*pOpt
= &pAutoCorrect
->GetSwFlags();
2790 const SmartTagMgr
* pSmartTagMgr
= pOpt
->pSmartTagMgr
;
2792 // robust, should not happen!
2793 if ( !pSmartTagMgr
)
2796 FillListBox( *pSmartTagMgr
);
2797 m_aSmartTagTypesLB
.SelectEntryPos( 0 );
2798 m_aMainCB
.Check( pSmartTagMgr
->IsLabelTextWithSmartTags() );
2799 CheckHdl( &m_aMainCB
);
2802 void OfaSmartTagOptionsTabPage::ActivatePage( const SfxItemSet
& )
2804 ((OfaAutoCorrDlg
*)GetTabDialog())->EnableLanguage( FALSE
);