diff options
author | Yiğit Akçay <yigit.akcay@icloud.com> | 2024-01-25 23:05:59 +0300 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2024-02-28 10:37:50 +0100 |
commit | a7dd2e5a4712083cc5934e1d677e7dff86ceb7e6 (patch) | |
tree | 06f78ac305dd36215bbf8108d26328c57aff43db /sw/inc/viewopt.hxx | |
parent | 9d3366f5b392418dc83bc0adbe3d215cff4b3605 (diff) |
tdf#151710 Enable enclosing of selected text with characters
This patch implements a new setting in Tools -> Options -> Writer ->
Formatting Aids -> Autocomplete -> Enclose with characters.
When this option is enabled (default), selected text is enclosed
with parentheses, square brackets, curly braces or quotation marks,
depending on which character is pressed.
For example, if the selected text is "abcd", the option is enabled and
the button for the character '(' is hit, the text is replaced with
"(abcd)".
Change-Id: Ibc5b7be3cc96f00217dd068971e7c07e68439700
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162583
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
Diffstat (limited to 'sw/inc/viewopt.hxx')
-rw-r--r-- | sw/inc/viewopt.hxx | 79 |
1 files changed, 50 insertions, 29 deletions
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 8aac21e745b3..d58c361e24c9 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -252,39 +252,40 @@ class SW_DLLPUBLIC SwViewOption static sal_uInt16 s_nPixelTwips;// 1 Pixel == ? Twips - OUString m_sSymbolFont; // Symbolfont. - ViewOptFlags1 m_nCoreOptions; // Bits for SwViewShell. - ViewOptCoreFlags2 m_nCore2Options; // Bits for SwViewShell. - ViewOptFlags2 m_nUIOptions; // UI-Bits - Color m_aRetouchColor; // DefaultBackground for BrowseView - Size m_aSnapSize; // Describes horizontal and vertical snap. - sal_uInt16 mnViewLayoutColumns; // # columns for edit view - short m_nDivisionX; // Grid division. - short m_nDivisionY; - sal_uInt8 m_nPagePreviewRow; // Page Preview Row/Columns. - sal_uInt8 m_nPagePreviewCol; // Page Preview Row/Columns. - SwFillMode m_nShadowCursorFillMode; // FillMode for ShadowCursor. - bool m_bReadonly : 1; // Readonly-Doc. - bool m_bStarOneSetting : 1;// Prevent from UI automatics (no scrollbars in readonly documents). - bool m_bIsPagePreview : 1; // The preview mustn't print field/footnote/... shadings. - bool m_bSelectionInReadonly : 1; // Determines whether selection is switched on in readonly documents. - bool mbFormView : 1; - bool mbBrowseMode : 1; - bool mbBookView : 1; // View mode for page preview. - bool mbViewLayoutBookMode : 1; // Book view mode for edit view. - bool mbHideWhitespaceMode : 1; // Hide header, footer, and pagebreak. - bool m_bShowPlaceHolderFields : 1; // Only used in printing! - mutable bool m_bIdle; - sal_Int32 m_nDefaultAnchor; // GetDefaultAnchorType() to convert int to RndStdIds + OUString m_sSymbolFont; // Symbolfont. + ViewOptFlags1 m_nCoreOptions; // Bits for SwViewShell. + ViewOptCoreFlags2 m_nCore2Options; // Bits for SwViewShell. + ViewOptFlags2 m_nUIOptions; // UI-Bits + Color m_aRetouchColor; // DefaultBackground for BrowseView + Size m_aSnapSize; // Describes horizontal and vertical snap. + sal_uInt16 mnViewLayoutColumns; // # columns for edit view + short m_nDivisionX; // Grid division. + short m_nDivisionY; + sal_uInt8 m_nPagePreviewRow; // Page Preview Row/Columns. + sal_uInt8 m_nPagePreviewCol; // Page Preview Row/Columns. + SwFillMode m_nShadowCursorFillMode; // FillMode for ShadowCursor. + bool m_bReadonly : 1; // Readonly-Doc. + bool m_bStarOneSetting : 1; // Prevent from UI automatics (no scrollbars in readonly documents). + bool m_bIsPagePreview : 1; // The preview mustn't print field/footnote/... shadings. + bool m_bSelectionInReadonly : 1; // Determines whether selection is switched on in readonly documents. + bool mbFormView : 1; + bool mbBrowseMode : 1; + bool mbBookView : 1; // View mode for page preview. + bool mbViewLayoutBookMode : 1; // Book view mode for edit view. + bool mbHideWhitespaceMode : 1; // Hide header, footer, and pagebreak. + bool m_bShowPlaceHolderFields : 1; // Only used in printing! + bool m_bEncloseWithCharactersOn : 1; + mutable bool m_bIdle; + sal_Int32 m_nDefaultAnchor; // GetDefaultAnchorType() to convert int to RndStdIds // tdf#135266 - tox dialog: remember last used entry level depending on the index type - sal_uInt8 m_nTocEntryLvl; - sal_uInt8 m_nIdxEntryLvl; + sal_uInt8 m_nTocEntryLvl; + sal_uInt8 m_nIdxEntryLvl; // Scale - sal_uInt16 m_nZoom; // In percent. - SvxZoomType m_eZoom; // 'enum' for zoom. + sal_uInt16 m_nZoom; // In percent. + SvxZoomType m_eZoom; // 'enum' for zoom. - sal_uInt8 m_nTableDestination; // Destination for table background. + sal_uInt8 m_nTableDestination; // Destination for table background. #ifdef DBG_UTIL // Corresponds to statements in ui/config/cfgvw.src. @@ -792,6 +793,25 @@ public: void SetShadowCursor(bool b) { SetUIOption(b, ViewOptFlags2::ShadowCursor); } + // Enclose with characters autocomplete, switch on/off + bool IsEncloseWithCharactersOn() const { return m_bEncloseWithCharactersOn; } + void SetEncloseWithCharactersOn(bool b) { m_bEncloseWithCharactersOn = b; } + + static bool IsEncloseWithCharactersTrigger(sal_Unicode cChar) + { + switch (cChar) + { + case '(': [[fallthrough]]; + case '{': [[fallthrough]]; + case '[': [[fallthrough]]; + case '\'': [[fallthrough]]; + case '\"': + return true; + default: + return false; + } + } + //move vertical ruler to the right bool IsVRulerRight() const { return bool(m_nUIOptions & ViewOptFlags2::VRulerRight); } @@ -877,6 +897,7 @@ inline void SwViewOption::SetUIOptions( const SwViewOption& rVOpt ) m_nUIOptions = rVOpt.m_nUIOptions; m_nTableDestination = rVOpt.m_nTableDestination; m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode; + m_bEncloseWithCharactersOn = rVOpt.m_bEncloseWithCharactersOn; } // Helper function for checking HTML-capabilities. |