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 #pragma once 20 21 #include <sfx2/tabdlg.hxx> 22 #include <svx/langbox.hxx> 23 24 #include <map> 25 #include <set> 26 27 class CharClass; 28 class CollatorWrapper; 29 class SmartTagMgr; 30 31 namespace editeng { class SortedAutoCompleteStrings; } 32 33 // class OfaAutoCorrDlg -------------------------------------------------- 34 35 class OfaAutoCorrDlg : public SfxTabDialogController 36 { 37 std::unique_ptr<weld::Widget> m_xLanguageBox; 38 std::unique_ptr<SvxLanguageBox> m_xLanguageLB; 39 40 DECL_LINK(SelectLanguageHdl, weld::ComboBox&, void); 41 public: 42 43 OfaAutoCorrDlg(weld::Window* pParent, const SfxItemSet *pSet); 44 virtual ~OfaAutoCorrDlg() override; 45 46 void EnableLanguage(bool bEnable); 47 }; 48 49 // class OfaAutocorrOptionsPage ------------------------------------------ 50 51 class OfaAutocorrOptionsPage : public SfxTabPage 52 { 53 private: 54 OUString m_sInput; 55 OUString m_sDoubleCaps; 56 OUString m_sStartCap; 57 OUString m_sBoldUnderline; 58 OUString m_sURL; 59 OUString m_sNoDblSpaces; 60 OUString m_sDash; 61 OUString m_sAccidentalCaps; 62 63 std::unique_ptr<weld::TreeView> m_xCheckLB; 64 65 void InsertEntry(const OUString& rTxt); 66 67 public: 68 OfaAutocorrOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 69 virtual ~OfaAutocorrOptionsPage() override; 70 71 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, 72 const SfxItemSet* rAttrSet); 73 74 virtual bool FillItemSet( SfxItemSet* rSet ) override; 75 virtual void Reset( const SfxItemSet* rSet ) override; 76 virtual void ActivatePage( const SfxItemSet& ) override; 77 78 }; 79 80 // class OfaSwAutoFmtOptionsPage ---------------------------------------------------- 81 82 class OfaSwAutoFmtOptionsPage : public SfxTabPage 83 { 84 OUString sDeleteEmptyPara; 85 OUString sUseReplaceTbl; 86 OUString sCapitalStartWord; 87 OUString sCapitalStartSentence; 88 OUString sUserStyle; 89 OUString sBullet; 90 OUString sBoldUnder; 91 OUString sNoDblSpaces; 92 OUString sCorrectCapsLock; 93 OUString sDetectURL; 94 OUString sDash; 95 OUString sRightMargin; 96 OUString sNum; 97 OUString sBorder; 98 OUString sTable; 99 OUString sReplaceTemplates; 100 OUString sDelSpaceAtSttEnd; 101 OUString sDelSpaceBetweenLines; 102 103 OUString sMargin; 104 OUString sBulletChar; 105 OUString sByInputBulletChar; 106 107 vcl::Font aBulletFont; 108 vcl::Font aByInputBulletFont; 109 sal_uInt16 nPercent; 110 111 std::unique_ptr<weld::TreeView> m_xCheckLB; 112 std::unique_ptr<weld::Button> m_xEditPB; 113 114 DECL_LINK(SelectHdl, weld::TreeView&, void); 115 DECL_LINK(EditHdl, weld::Button&, void); 116 DECL_LINK(DoubleClickEditHdl, weld::TreeView&, bool); 117 118 void CreateEntry(const OUString& rTxt, sal_uInt16 nCol); 119 120 public: 121 OfaSwAutoFmtOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 122 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, 123 const SfxItemSet* rAttrSet); 124 virtual ~OfaSwAutoFmtOptionsPage() override; 125 126 virtual bool FillItemSet( SfxItemSet* rSet ) override; 127 virtual void Reset( const SfxItemSet* rSet ) override; 128 virtual void ActivatePage( const SfxItemSet& ) override; 129 }; 130 131 // class OfaAutocorrReplacePage ------------------------------------------ 132 133 struct DoubleString 134 { 135 OUString sShort; 136 OUString sLong; 137 void* pUserData; ///< CheckBox -> form. Text Bool -> selection text DoubleStringDoubleString138 DoubleString(const OUString& rShort, const OUString& rLong) 139 : sShort(rShort) 140 , sLong(rLong) 141 , pUserData(nullptr) 142 { 143 } 144 }; 145 146 typedef std::vector<DoubleString> DoubleStringArray; 147 148 struct StringChangeList 149 { 150 DoubleStringArray aNewEntries; 151 DoubleStringArray aDeletedEntries; 152 }; 153 154 typedef std::map<LanguageType, StringChangeList> StringChangeTable; 155 156 class OfaAutocorrReplacePage : public SfxTabPage 157 { 158 private: 159 160 StringChangeTable aChangesTable; 161 162 OUString sModify; 163 OUString sNew; 164 165 std::set<OUString> aFormatText; 166 std::map<LanguageType, DoubleStringArray> 167 aDoubleStringTable; 168 std::unique_ptr<CollatorWrapper> pCompareClass; 169 std::unique_ptr<CharClass> pCharClass; 170 LanguageType eLang; 171 172 bool bHasSelectionText; 173 bool bFirstSelect:1; 174 bool bReplaceEditChanged:1; 175 bool bSWriter:1; 176 177 std::vector<int> m_aReplaceFixedWidths; 178 std::unique_ptr<weld::CheckButton> m_xTextOnlyCB; 179 std::unique_ptr<weld::Entry> m_xShortED; 180 std::unique_ptr<weld::Entry> m_xReplaceED; 181 std::unique_ptr<weld::TreeView> m_xReplaceTLB; 182 std::unique_ptr<weld::Button> m_xNewReplacePB; 183 std::unique_ptr<weld::Button> m_xReplacePB; 184 std::unique_ptr<weld::Button> m_xDeleteReplacePB; 185 std::unique_ptr<weld::Container> m_xButtonBox; 186 187 DECL_LINK(SelectHdl, weld::TreeView&, void); 188 DECL_LINK(NewDelButtonHdl, weld::Button&, void); 189 DECL_LINK(NewDelActionHdl, weld::Entry&, bool); 190 DECL_LINK(EntrySizeAllocHdl, const Size&, void); 191 DECL_LINK(ModifyHdl, weld::Entry&, void); 192 bool NewDelHdl(const weld::Widget*); 193 194 void RefillReplaceBox( bool bFromReset, 195 LanguageType eOldLanguage, 196 LanguageType eNewLanguage); 197 198 public: 199 OfaAutocorrReplacePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 200 virtual ~OfaAutocorrReplacePage() override; 201 202 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet); 203 204 virtual bool FillItemSet( SfxItemSet* rSet ) override; 205 virtual void Reset( const SfxItemSet* rSet ) override; 206 virtual void ActivatePage( const SfxItemSet& ) override; 207 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; 208 209 void SetLanguage(LanguageType eSet); 210 void DeleteEntry(const OUString& sShort, const OUString& sLong); 211 void NewEntry(const OUString& sShort, const OUString& sLong, bool bKeepSourceFormatting); 212 }; 213 214 // class OfaAutocorrExceptPage --------------------------------------------- 215 216 struct StringsArrays 217 { 218 std::vector<OUString> aAbbrevStrings; 219 std::vector<OUString> aDoubleCapsStrings; 220 StringsArraysStringsArrays221 StringsArrays() { } 222 }; 223 typedef std::map<LanguageType, StringsArrays> StringsTable; 224 225 class OfaAutocorrExceptPage : public SfxTabPage 226 { 227 private: 228 StringsTable aStringsTable; 229 std::unique_ptr<CollatorWrapper> pCompareClass; 230 LanguageType eLang; 231 232 std::unique_ptr<weld::Entry> m_xAbbrevED; 233 std::unique_ptr<weld::TreeView> m_xAbbrevLB; 234 std::unique_ptr<weld::Button> m_xNewAbbrevPB; 235 std::unique_ptr<weld::Button> m_xDelAbbrevPB; 236 std::unique_ptr<weld::CheckButton> m_xAutoAbbrevCB; 237 238 std::unique_ptr<weld::Entry> m_xDoubleCapsED; 239 std::unique_ptr<weld::TreeView> m_xDoubleCapsLB; 240 std::unique_ptr<weld::Button> m_xNewDoublePB; 241 std::unique_ptr<weld::Button> m_xDelDoublePB; 242 std::unique_ptr<weld::CheckButton> m_xAutoCapsCB; 243 244 DECL_LINK(NewDelButtonHdl, weld::Button&, void); 245 DECL_LINK(NewDelActionHdl, weld::Entry&, bool); 246 DECL_LINK(SelectHdl, weld::TreeView&, void); 247 DECL_LINK(ModifyHdl, weld::Entry&, void); 248 bool NewDelHdl(const weld::Widget*); 249 /// Box filled with new language 250 void RefillReplaceBoxes(bool bFromReset, 251 LanguageType eOldLanguage, 252 LanguageType eNewLanguage); 253 public: 254 OfaAutocorrExceptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 255 virtual ~OfaAutocorrExceptPage() override; 256 257 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, 258 const SfxItemSet* rAttrSet); 259 260 virtual bool FillItemSet( SfxItemSet* rSet ) override; 261 virtual void Reset( const SfxItemSet* rSet ) override; 262 virtual void ActivatePage( const SfxItemSet& ) override; 263 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; 264 void SetLanguage(LanguageType eSet); 265 266 }; 267 268 // class OfaQuoteTabPage ------------------------------------------------- 269 270 class OfaQuoteTabPage : public SfxTabPage 271 { 272 private: 273 OUString sNonBrkSpace; 274 OUString sOrdinal; 275 OUString sTransliterateRTL; 276 OUString sAngleQuotes; 277 278 sal_UCS4 cSglStartQuote; 279 sal_UCS4 cSglEndQuote; 280 281 sal_UCS4 cStartQuote; 282 sal_UCS4 cEndQuote; 283 284 std::unique_ptr<weld::CheckButton> m_xSingleTypoCB; 285 std::unique_ptr<weld::Button> m_xSglStartQuotePB; 286 std::unique_ptr<weld::Label> m_xSglStartExFT; 287 std::unique_ptr<weld::Button> m_xSglEndQuotePB; 288 std::unique_ptr<weld::Label> m_xSglEndExFT; 289 std::unique_ptr<weld::Button> m_xSglStandardPB; 290 std::unique_ptr<weld::CheckButton> m_xDoubleTypoCB; 291 std::unique_ptr<weld::Button> m_xDblStartQuotePB; 292 std::unique_ptr<weld::Label> m_xDblStartExFT; 293 std::unique_ptr<weld::Button> m_xDblEndQuotePB; 294 std::unique_ptr<weld::Label> m_xDblEndExFT; 295 std::unique_ptr<weld::Button> m_xDblStandardPB; 296 OUString m_sStandard; 297 /// For anything but writer 298 std::unique_ptr<weld::TreeView> m_xCheckLB; 299 /// Just for writer 300 std::unique_ptr<weld::TreeView> m_xSwCheckLB; 301 302 303 DECL_LINK(QuoteHdl, weld::Button&, void); 304 DECL_LINK(StdQuoteHdl, weld::Button&, void); 305 306 OUString ChangeStringExt_Impl( sal_UCS4 ); 307 308 static void CreateEntry(weld::TreeView& rLstBox, const OUString& rTxt, 309 sal_uInt16 nCol, sal_uInt16 nTextCol); 310 311 public: 312 OfaQuoteTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 313 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, 314 const SfxItemSet* rAttrSet); 315 virtual ~OfaQuoteTabPage() override; 316 317 virtual bool FillItemSet( SfxItemSet* rSet ) override; 318 virtual void Reset( const SfxItemSet* rSet ) override; 319 virtual void ActivatePage( const SfxItemSet& ) override; 320 }; 321 322 // class OfaAutoCompleteTabPage --------------------------------------------- 323 324 class OfaAutoCompleteTabPage : public SfxTabPage 325 { 326 private: 327 editeng::SortedAutoCompleteStrings* m_pAutoCompleteList; 328 sal_uInt16 m_nAutoCmpltListCnt; 329 330 std::unique_ptr<weld::CheckButton> m_xCBActiv; ///<Enable word completion 331 std::unique_ptr<weld::CheckButton> m_xCBAppendSpace;///<Append space 332 std::unique_ptr<weld::CheckButton> m_xCBAsTip; ///<Show as tip 333 334 std::unique_ptr<weld::CheckButton> m_xCBCollect;///<Collect words 335 std::unique_ptr<weld::CheckButton> m_xCBRemoveList;///<...save the list for later use... 336 337 std::unique_ptr<weld::ComboBox> m_xDCBExpandKey; 338 std::unique_ptr<weld::SpinButton> m_xNFMinWordlen; 339 std::unique_ptr<weld::SpinButton> m_xNFMaxEntries; 340 std::unique_ptr<weld::TreeView> m_xLBEntries; 341 std::unique_ptr<weld::Button> m_xPBEntries; 342 343 DECL_LINK(CheckHdl, weld::Toggleable&, void); 344 DECL_LINK(KeyReleaseHdl, const KeyEvent&, bool); 345 346 public: 347 OfaAutoCompleteTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 348 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, 349 const SfxItemSet* rAttrSet); 350 virtual ~OfaAutoCompleteTabPage() override; 351 352 virtual bool FillItemSet( SfxItemSet* rSet ) override; 353 virtual void Reset( const SfxItemSet* rSet ) override; 354 virtual void ActivatePage( const SfxItemSet& ) override; 355 356 void CopyToClipboard() const; 357 DECL_LINK(DeleteHdl, weld::Button&, void); 358 }; 359 360 // class OfaSmartTagOptionsTabPage --------------------------------------------- 361 362 /** Smart tag options tab page 363 364 This tab page is used to enable/disable smart tag types 365 */ 366 class OfaSmartTagOptionsTabPage : public SfxTabPage 367 { 368 private: 369 370 // controls 371 std::unique_ptr<weld::CheckButton> m_xMainCB; 372 std::unique_ptr<weld::TreeView> m_xSmartTagTypesLB; 373 std::unique_ptr<weld::Button> m_xPropertiesPB; 374 375 /** Inserts items into m_aSmartTagTypesLB 376 377 Reads out the smart tag types supported by the SmartTagMgr and 378 inserts the associated strings into the list box. 379 */ 380 void FillListBox( const SmartTagMgr& rSmartTagMgr ); 381 382 /** Clears the m_aSmartTagTypesLB 383 */ 384 void ClearListBox(); 385 386 /** Handler for the check box 387 388 Enables/disables all controls in the tab page (except from the 389 check box. 390 */ 391 DECL_LINK(CheckHdl, weld::Toggleable&, void); 392 393 /** Handler for the push button 394 395 Calls the displayPropertyPage function of the smart tag recognizer 396 associated with the currently selected smart tag type. 397 */ 398 DECL_LINK(ClickHdl, weld::Button&, void); 399 400 /** Handler for the list box 401 402 Enables/disables the properties push button if selection in the 403 smart tag types list box changes. 404 */ 405 DECL_LINK(SelectHdl, weld::TreeView&, void); 406 407 public: 408 /// construction via Create() 409 OfaSmartTagOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); 410 virtual ~OfaSmartTagOptionsTabPage() override; 411 412 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet); 413 414 virtual bool FillItemSet( SfxItemSet* rSet ) override; 415 virtual void Reset( const SfxItemSet* rSet ) override; 416 virtual void ActivatePage( const SfxItemSet& ) override; 417 }; 418 419 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 420