LCOV - code coverage report
Current view: top level - cui/source/tabpages - autocdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 1478 0.0 %
Date: 2014-11-03 Functions: 0 124 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10