1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <sfx2/tabdlg.hxx>
22 #include <svx/langbox.hxx>
23 #include <unotools/collatorwrapper.hxx>
32 namespace editeng
{ class SortedAutoCompleteStrings
; }
34 // class OfaAutoCorrDlg --------------------------------------------------
36 class OfaAutoCorrDlg
: public SfxTabDialogController
38 std::unique_ptr
<weld::Widget
> m_xLanguageBox
;
39 std::unique_ptr
<SvxLanguageBox
> m_xLanguageLB
;
41 DECL_LINK(SelectLanguageHdl
, weld::ComboBox
&, void);
44 OfaAutoCorrDlg(weld::Window
* pParent
, const SfxItemSet
*pSet
);
45 virtual ~OfaAutoCorrDlg() override
;
47 void EnableLanguage(bool bEnable
);
50 // class OfaAutocorrOptionsPage ------------------------------------------
52 class OfaAutocorrOptionsPage
: public SfxTabPage
56 OUString m_sDoubleCaps
;
58 OUString m_sBoldUnderline
;
61 OUString m_sNoDblSpaces
;
63 OUString m_sAccidentalCaps
;
65 std::unique_ptr
<weld::TreeView
> m_xCheckLB
;
67 void InsertEntry(const OUString
& rTxt
);
70 OfaAutocorrOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
71 virtual ~OfaAutocorrOptionsPage() override
;
73 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
74 const SfxItemSet
* rAttrSet
);
76 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
77 virtual void Reset( const SfxItemSet
* rSet
) override
;
78 virtual void ActivatePage( const SfxItemSet
& ) override
;
82 // class OfaSwAutoFmtOptionsPage ----------------------------------------------------
84 class OfaSwAutoFmtOptionsPage
: public SfxTabPage
86 OUString sDeleteEmptyPara
;
87 OUString sUseReplaceTbl
;
88 OUString sCapitalStartWord
;
89 OUString sCapitalStartSentence
;
93 OUString sNoDblSpaces
;
94 OUString sCorrectCapsLock
;
98 OUString sRightMargin
;
100 OUString sBulletsAfterSpace
;
103 OUString sReplaceTemplates
;
104 OUString sDelSpaceAtSttEnd
;
105 OUString sDelSpaceBetweenLines
;
108 OUString sBulletChar
;
109 OUString sByInputBulletChar
;
111 vcl::Font aBulletFont
;
112 vcl::Font aByInputBulletFont
;
115 std::unique_ptr
<weld::TreeView
> m_xCheckLB
;
116 std::unique_ptr
<weld::Button
> m_xEditPB
;
118 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
119 DECL_LINK(EditHdl
, weld::Button
&, void);
120 DECL_LINK(DoubleClickEditHdl
, weld::TreeView
&, bool);
122 void CreateEntry(const OUString
& rTxt
, sal_uInt16 nCol
);
125 OfaSwAutoFmtOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
126 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
127 const SfxItemSet
* rAttrSet
);
128 virtual ~OfaSwAutoFmtOptionsPage() override
;
130 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
131 virtual void Reset( const SfxItemSet
* rSet
) override
;
132 virtual void ActivatePage( const SfxItemSet
& ) override
;
135 // class OfaAutocorrReplacePage ------------------------------------------
141 void* pUserData
; ///< CheckBox -> form. Text Bool -> selection text
142 DoubleString(OUString aShort
, OUString aLong
)
143 : sShort(std::move(aShort
))
144 , sLong(std::move(aLong
))
150 typedef std::vector
<DoubleString
> DoubleStringArray
;
152 struct StringChangeList
154 DoubleStringArray aNewEntries
;
155 DoubleStringArray aDeletedEntries
;
158 typedef std::map
<LanguageType
, StringChangeList
> StringChangeTable
;
160 class OfaAutocorrReplacePage
: public SfxTabPage
164 StringChangeTable aChangesTable
;
169 std::set
<OUString
> aFormatText
;
170 std::map
<LanguageType
, DoubleStringArray
>
172 CollatorWrapper maCompareClass
;
173 std::unique_ptr
<CharClass
> pCharClass
;
176 bool bHasSelectionText
;
178 bool bReplaceEditChanged
:1;
181 std::vector
<int> m_aReplaceFixedWidths
;
182 std::unique_ptr
<weld::CheckButton
> m_xTextOnlyCB
;
183 std::unique_ptr
<weld::Entry
> m_xShortED
;
184 std::unique_ptr
<weld::Entry
> m_xReplaceED
;
185 std::unique_ptr
<weld::TreeView
> m_xReplaceTLB
;
186 std::unique_ptr
<weld::Button
> m_xNewReplacePB
;
187 std::unique_ptr
<weld::Button
> m_xReplacePB
;
188 std::unique_ptr
<weld::Button
> m_xDeleteReplacePB
;
189 std::unique_ptr
<weld::Container
> m_xButtonBox
;
191 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
192 DECL_LINK(NewDelButtonHdl
, weld::Button
&, void);
193 DECL_LINK(NewDelActionHdl
, weld::Entry
&, bool);
194 DECL_LINK(EntrySizeAllocHdl
, const Size
&, void);
195 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
196 bool NewDelHdl(const weld::Widget
*);
198 void RefillReplaceBox( bool bFromReset
,
199 LanguageType eOldLanguage
,
200 LanguageType eNewLanguage
);
203 OfaAutocorrReplacePage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
204 virtual ~OfaAutocorrReplacePage() override
;
206 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrSet
);
208 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
209 virtual void Reset( const SfxItemSet
* rSet
) override
;
210 virtual void ActivatePage( const SfxItemSet
& ) override
;
211 virtual DeactivateRC
DeactivatePage( SfxItemSet
* pSet
) override
;
213 void SetLanguage(LanguageType eSet
);
214 void DeleteEntry(const OUString
& sShort
, const OUString
& sLong
);
215 void NewEntry(const OUString
& sShort
, const OUString
& sLong
, bool bKeepSourceFormatting
);
218 // class OfaAutocorrExceptPage ---------------------------------------------
222 std::vector
<OUString
> aAbbrevStrings
;
223 std::vector
<OUString
> aDoubleCapsStrings
;
227 typedef std::map
<LanguageType
, StringsArrays
> StringsTable
;
229 class OfaAutocorrExceptPage
: public SfxTabPage
232 StringsTable aStringsTable
;
233 CollatorWrapper maCompareClass
;
236 std::unique_ptr
<weld::Entry
> m_xAbbrevED
;
237 std::unique_ptr
<weld::TreeView
> m_xAbbrevLB
;
238 std::unique_ptr
<weld::Button
> m_xNewAbbrevPB
;
239 std::unique_ptr
<weld::Button
> m_xDelAbbrevPB
;
240 std::unique_ptr
<weld::CheckButton
> m_xAutoAbbrevCB
;
242 std::unique_ptr
<weld::Entry
> m_xDoubleCapsED
;
243 std::unique_ptr
<weld::TreeView
> m_xDoubleCapsLB
;
244 std::unique_ptr
<weld::Button
> m_xNewDoublePB
;
245 std::unique_ptr
<weld::Button
> m_xDelDoublePB
;
246 std::unique_ptr
<weld::CheckButton
> m_xAutoCapsCB
;
248 DECL_LINK(NewDelButtonHdl
, weld::Button
&, void);
249 DECL_LINK(NewDelActionHdl
, weld::Entry
&, bool);
250 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
251 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
252 bool NewDelHdl(const weld::Widget
*);
253 /// Box filled with new language
254 void RefillReplaceBoxes(bool bFromReset
,
255 LanguageType eOldLanguage
,
256 LanguageType eNewLanguage
);
258 OfaAutocorrExceptPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
259 virtual ~OfaAutocorrExceptPage() override
;
261 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
262 const SfxItemSet
* rAttrSet
);
264 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
265 virtual void Reset( const SfxItemSet
* rSet
) override
;
266 virtual void ActivatePage( const SfxItemSet
& ) override
;
267 virtual DeactivateRC
DeactivatePage( SfxItemSet
* pSet
) override
;
268 void SetLanguage(LanguageType eSet
);
272 // class OfaQuoteTabPage -------------------------------------------------
274 class OfaQuoteTabPage
: public SfxTabPage
277 OUString sNonBrkSpace
;
279 OUString sTransliterateRTL
;
280 OUString sAngleQuotes
;
282 sal_UCS4 cSglStartQuote
;
283 sal_UCS4 cSglEndQuote
;
285 sal_UCS4 cStartQuote
;
288 std::unique_ptr
<weld::CheckButton
> m_xSingleTypoCB
;
289 std::unique_ptr
<weld::Button
> m_xSglStartQuotePB
;
290 std::unique_ptr
<weld::Label
> m_xSglStartExFT
;
291 std::unique_ptr
<weld::Button
> m_xSglEndQuotePB
;
292 std::unique_ptr
<weld::Label
> m_xSglEndExFT
;
293 std::unique_ptr
<weld::Button
> m_xSglStandardPB
;
294 std::unique_ptr
<weld::CheckButton
> m_xDoubleTypoCB
;
295 std::unique_ptr
<weld::Button
> m_xDblStartQuotePB
;
296 std::unique_ptr
<weld::Label
> m_xDblStartExFT
;
297 std::unique_ptr
<weld::Button
> m_xDblEndQuotePB
;
298 std::unique_ptr
<weld::Label
> m_xDblEndExFT
;
299 std::unique_ptr
<weld::Button
> m_xDblStandardPB
;
300 OUString m_sStandard
;
301 /// For anything but writer
302 std::unique_ptr
<weld::TreeView
> m_xCheckLB
;
304 std::unique_ptr
<weld::TreeView
> m_xSwCheckLB
;
307 DECL_LINK(QuoteHdl
, weld::Button
&, void);
308 DECL_LINK(StdQuoteHdl
, weld::Button
&, void);
310 OUString
ChangeStringExt_Impl( sal_UCS4
);
312 static void CreateEntry(weld::TreeView
& rLstBox
, const OUString
& rTxt
,
313 sal_uInt16 nCol
, sal_uInt16 nTextCol
);
316 OfaQuoteTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
317 static std::unique_ptr
<SfxTabPage
> Create(weld::Container
* pPage
, weld::DialogController
* pController
,
318 const SfxItemSet
* rAttrSet
);
319 virtual ~OfaQuoteTabPage() override
;
321 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
322 virtual void Reset( const SfxItemSet
* rSet
) override
;
323 virtual void ActivatePage( const SfxItemSet
& ) override
;
326 // class OfaAutoCompleteTabPage ---------------------------------------------
328 class OfaAutoCompleteTabPage
: public SfxTabPage
331 editeng::SortedAutoCompleteStrings
* m_pAutoCompleteList
;
332 sal_uInt16 m_nAutoCmpltListCnt
;
334 std::unique_ptr
<weld::CheckButton
> m_xCBActiv
; ///<Enable word completion
335 std::unique_ptr
<weld::CheckButton
> m_xCBAppendSpace
;///<Append space
336 std::unique_ptr
<weld::CheckButton
> m_xCBAsTip
; ///<Show as tip
338 std::unique_ptr
<weld::CheckButton
> m_xCBCollect
;///<Collect words
339 std::unique_ptr
<weld::CheckButton
> m_xCBRemoveList
;///<...save the list for later use...
341 std::unique_ptr
<weld::ComboBox
> m_xDCBExpandKey
;
342 std::unique_ptr
<weld::SpinButton
> m_xNFMinWordlen
;
343 std::unique_ptr
<weld::SpinButton
> m_xNFMaxEntries
;
344 std::unique_ptr
<weld::TreeView
> m_xLBEntries
;
345 std::unique_ptr
<weld::Button
> m_xPBEntries
;
347 DECL_LINK(CheckHdl
, weld::Toggleable
&, void);
348 DECL_LINK(KeyReleaseHdl
, const KeyEvent
&, bool);
351 OfaAutoCompleteTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
352 static std::unique_ptr
<SfxTabPage
> Create(weld::Container
* pPage
, weld::DialogController
* pController
,
353 const SfxItemSet
* rAttrSet
);
354 virtual ~OfaAutoCompleteTabPage() override
;
356 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
357 virtual void Reset( const SfxItemSet
* rSet
) override
;
358 virtual void ActivatePage( const SfxItemSet
& ) override
;
360 void CopyToClipboard() const;
361 DECL_LINK(DeleteHdl
, weld::Button
&, void);
364 // class OfaSmartTagOptionsTabPage ---------------------------------------------
366 /** Smart tag options tab page
368 This tab page is used to enable/disable smart tag types
370 class OfaSmartTagOptionsTabPage
: public SfxTabPage
375 std::unique_ptr
<weld::CheckButton
> m_xMainCB
;
376 std::unique_ptr
<weld::TreeView
> m_xSmartTagTypesLB
;
377 std::unique_ptr
<weld::Button
> m_xPropertiesPB
;
379 /** Inserts items into m_aSmartTagTypesLB
381 Reads out the smart tag types supported by the SmartTagMgr and
382 inserts the associated strings into the list box.
384 void FillListBox( const SmartTagMgr
& rSmartTagMgr
);
386 /** Clears the m_aSmartTagTypesLB
390 /** Handler for the check box
392 Enables/disables all controls in the tab page (except from the
395 DECL_LINK(CheckHdl
, weld::Toggleable
&, void);
397 /** Handler for the push button
399 Calls the displayPropertyPage function of the smart tag recognizer
400 associated with the currently selected smart tag type.
402 DECL_LINK(ClickHdl
, weld::Button
&, void);
404 /** Handler for the list box
406 Enables/disables the properties push button if selection in the
407 smart tag types list box changes.
409 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
412 /// construction via Create()
413 OfaSmartTagOptionsTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
414 virtual ~OfaSmartTagOptionsTabPage() override
;
416 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrSet
);
418 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
419 virtual void Reset( const SfxItemSet
* rSet
) override
;
420 virtual void ActivatePage( const SfxItemSet
& ) override
;
423 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */