diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-13 10:08:49 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-16 06:52:39 +0000 |
commit | 0a2b17943945f38b8b0a60e15525d120f789fefb (patch) | |
tree | 1a47d34f04ad5ff95eb232ba0459ccb4a37750d3 /sw | |
parent | 52372ae0370cb755ed810eead456d75c8cb1adf3 (diff) |
Convert VIEWOPT flags to scoped enum
Change-Id: Ia89e397b98f118166737201623288c271d1639e7
Reviewed-on: https://gerrit.libreoffice.org/24952
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/viewopt.hxx | 50 | ||||
-rw-r--r-- | sw/source/uibase/config/viewopt.cxx | 54 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view0.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/uno/unomod.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 2 |
5 files changed, 64 insertions, 58 deletions
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 419422f216b1..4f2aef10a3a7 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -96,15 +96,21 @@ namespace o3tl { #define TBL_DEST_TBL 2 // Appearance flags. -#define VIEWOPT_DOC_BOUNDARIES 0x0001 -#define VIEWOPT_OBJECT_BOUNDARIES 0x0002 -#define VIEWOPT_TABLE_BOUNDARIES 0x0004 -#define VIEWOPT_INDEX_SHADINGS 0x0008 -#define VIEWOPT_LINKS 0x0010 -#define VIEWOPT_VISITED_LINKS 0x0020 -#define VIEWOPT_FIELD_SHADINGS 0x0040 -#define VIEWOPT_SECTION_BOUNDARIES 0x0080 -#define VIEWOPT_SHADOW 0x0100 +enum class ViewOptFlags { + NONE = 0x0000, + DocBoundaries = 0x0001, + ObjectBoundaries = 0x0002, + TableBoundaries = 0x0004, + IndexShadings = 0x0008, + Links = 0x0010, + VisitedLinks = 0x0020, + FieldShadings = 0x0040, + SectionBoundaries = 0x0080, + Shadow = 0x0100, +}; +namespace o3tl { + template<> struct typed_flags<ViewOptFlags> : is_typed_flags<ViewOptFlags, 0x01ff> {}; +} class SW_DLLPUBLIC SwViewOption { @@ -128,7 +134,7 @@ class SW_DLLPUBLIC SwViewOption static Color m_aShadowColor; static Color m_aHeaderFooterMarkColor; - static sal_Int32 m_nAppearanceFlags; + static ViewOptFlags m_nAppearanceFlags; protected: static sal_uInt16 m_nPixelTwips;// 1 Pixel == ? Twips @@ -579,21 +585,21 @@ public: static Color& GetPageBreakColor(); static Color& GetHeaderFooterMarkColor(); - static bool IsAppearanceFlag(sal_Int32 nFlag); + static bool IsAppearanceFlag(ViewOptFlags nFlag); - static bool IsDocBoundaries() {return IsAppearanceFlag(VIEWOPT_DOC_BOUNDARIES);} - static bool IsObjectBoundaries(){return IsAppearanceFlag(VIEWOPT_OBJECT_BOUNDARIES);} - static bool IsTableBoundaries() {return IsAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES );} - static bool IsIndexShadings() {return IsAppearanceFlag(VIEWOPT_INDEX_SHADINGS );} - static bool IsLinks() {return IsAppearanceFlag(VIEWOPT_LINKS );} - static bool IsVisitedLinks() {return IsAppearanceFlag(VIEWOPT_VISITED_LINKS );} - static bool IsFieldShadings() {return IsAppearanceFlag(VIEWOPT_FIELD_SHADINGS);} - static bool IsSectionBoundaries() {return IsAppearanceFlag(VIEWOPT_SECTION_BOUNDARIES);} - static bool IsShadow() {return IsAppearanceFlag(VIEWOPT_SHADOW );} + static bool IsDocBoundaries() {return IsAppearanceFlag(ViewOptFlags::DocBoundaries);} + static bool IsObjectBoundaries() {return IsAppearanceFlag(ViewOptFlags::ObjectBoundaries);} + static bool IsTableBoundaries() {return IsAppearanceFlag(ViewOptFlags::TableBoundaries );} + static bool IsIndexShadings() {return IsAppearanceFlag(ViewOptFlags::IndexShadings );} + static bool IsLinks() {return IsAppearanceFlag(ViewOptFlags::Links );} + static bool IsVisitedLinks() {return IsAppearanceFlag(ViewOptFlags::VisitedLinks );} + static bool IsFieldShadings() {return IsAppearanceFlag(ViewOptFlags::FieldShadings);} + static bool IsSectionBoundaries() {return IsAppearanceFlag(ViewOptFlags::SectionBoundaries);} + static bool IsShadow() {return IsAppearanceFlag(ViewOptFlags::Shadow );} - static void SetAppearanceFlag(sal_Int32 nFlag, bool bSet, bool bSaveInConfig = false); + static void SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig = false); - static void SetDocBoundaries(bool bSet) {SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES, bSet);} + static void SetDocBoundaries(bool bSet) {SetAppearanceFlag(ViewOptFlags::DocBoundaries, bSet);} static void ApplyColorConfigValues(const svtools::ColorConfig& rConfig); }; diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index f8ef3cdc326b..88654a863d2a 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -64,7 +64,7 @@ Color SwViewOption::m_aScriptIndicatorColor(COL_GREEN); Color SwViewOption::m_aShadowColor(COL_GRAY); Color SwViewOption::m_aHeaderFooterMarkColor(COL_BLUE); -sal_Int32 SwViewOption::m_nAppearanceFlags = VIEWOPT_DOC_BOUNDARIES|VIEWOPT_OBJECT_BOUNDARIES; +ViewOptFlags SwViewOption::m_nAppearanceFlags = ViewOptFlags::DocBoundaries|ViewOptFlags::ObjectBoundaries; sal_uInt16 SwViewOption::m_nPixelTwips = 0; // one pixel on the screen static const char aPostItStr[] = " "; @@ -451,41 +451,41 @@ void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig ) svtools::ColorConfigValue aValue = rConfig.GetColorValue(svtools::DOCBOUNDARIES); m_aDocBoundColor.SetColor(aValue.nColor); - m_nAppearanceFlags = 0; + m_nAppearanceFlags = ViewOptFlags::NONE; if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_DOC_BOUNDARIES; + m_nAppearanceFlags |= ViewOptFlags::DocBoundaries; m_aAppBackgroundColor.SetColor(rConfig.GetColorValue(svtools::APPBACKGROUND).nColor); aValue = rConfig.GetColorValue(svtools::OBJECTBOUNDARIES); m_aObjectBoundColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_OBJECT_BOUNDARIES; + m_nAppearanceFlags |= ViewOptFlags::ObjectBoundaries; aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES); m_aTableBoundColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_TABLE_BOUNDARIES; + m_nAppearanceFlags |= ViewOptFlags::TableBoundaries; aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS); m_aIndexShadingsColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_INDEX_SHADINGS; + m_nAppearanceFlags |= ViewOptFlags::IndexShadings; aValue = rConfig.GetColorValue(svtools::LINKS); m_aLinksColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_LINKS; + m_nAppearanceFlags |= ViewOptFlags::Links; aValue = rConfig.GetColorValue(svtools::LINKSVISITED); m_aVisitedLinksColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_VISITED_LINKS; + m_nAppearanceFlags |= ViewOptFlags::VisitedLinks; aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR); m_aShadowColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_SHADOW; + m_nAppearanceFlags |= ViewOptFlags::Shadow; m_aDirectCursorColor.SetColor(rConfig.GetColorValue(svtools::WRITERDIRECTCURSOR).nColor); @@ -500,12 +500,12 @@ void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig ) aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS); m_aFieldShadingsColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_FIELD_SHADINGS; + m_nAppearanceFlags |= ViewOptFlags::FieldShadings; aValue = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES); m_aSectionBoundColor.SetColor(aValue.nColor); if(aValue.bIsVisible) - m_nAppearanceFlags |= VIEWOPT_SECTION_BOUNDARIES; + m_nAppearanceFlags |= ViewOptFlags::SectionBoundaries; aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS); m_aPageBreakColor.SetColor(aValue.nColor); @@ -516,7 +516,7 @@ void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig ) m_aScriptIndicatorColor.SetColor(rConfig.GetColorValue(svtools::WRITERSCRIPTINDICATOR).nColor); } -void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, bool bSet, bool bSaveInConfig ) +void SwViewOption::SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig ) { if(bSet) m_nAppearanceFlags |= nFlag; @@ -528,26 +528,26 @@ void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, bool bSet, bool bSaveInCon svtools::EditableColorConfig aEditableConfig; struct FlagToConfig_Impl { - sal_Int32 nFlag; + ViewOptFlags nFlag; svtools::ColorConfigEntry eEntry; }; static const FlagToConfig_Impl aFlags[] = { - { VIEWOPT_DOC_BOUNDARIES , svtools::DOCBOUNDARIES }, - { VIEWOPT_OBJECT_BOUNDARIES , svtools::OBJECTBOUNDARIES }, - { VIEWOPT_TABLE_BOUNDARIES , svtools::TABLEBOUNDARIES }, - { VIEWOPT_INDEX_SHADINGS , svtools::WRITERIDXSHADINGS }, - { VIEWOPT_LINKS , svtools::LINKS }, - { VIEWOPT_VISITED_LINKS , svtools::LINKSVISITED }, - { VIEWOPT_FIELD_SHADINGS , svtools::WRITERFIELDSHADINGS }, - { VIEWOPT_SECTION_BOUNDARIES , svtools::WRITERSECTIONBOUNDARIES }, - { VIEWOPT_SHADOW , svtools::SHADOWCOLOR }, - { 0 , svtools::ColorConfigEntryCount } + { ViewOptFlags::DocBoundaries , svtools::DOCBOUNDARIES }, + { ViewOptFlags::ObjectBoundaries , svtools::OBJECTBOUNDARIES }, + { ViewOptFlags::TableBoundaries , svtools::TABLEBOUNDARIES }, + { ViewOptFlags::IndexShadings , svtools::WRITERIDXSHADINGS }, + { ViewOptFlags::Links , svtools::LINKS }, + { ViewOptFlags::VisitedLinks , svtools::LINKSVISITED }, + { ViewOptFlags::FieldShadings , svtools::WRITERFIELDSHADINGS }, + { ViewOptFlags::SectionBoundaries , svtools::WRITERSECTIONBOUNDARIES }, + { ViewOptFlags::Shadow , svtools::SHADOWCOLOR }, + { ViewOptFlags::NONE , svtools::ColorConfigEntryCount } }; sal_uInt16 nPos = 0; - while(aFlags[nPos].nFlag) + while(aFlags[nPos].nFlag != ViewOptFlags::NONE) { - if(0 != (nFlag&aFlags[nPos].nFlag)) + if(nFlag & aFlags[nPos].nFlag) { svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry); aValue.bIsVisible = bSet; @@ -558,9 +558,9 @@ void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, bool bSet, bool bSaveInCon } } -bool SwViewOption::IsAppearanceFlag(sal_Int32 nFlag) +bool SwViewOption::IsAppearanceFlag(ViewOptFlags nFlag) { - return 0 != (m_nAppearanceFlags & nFlag); + return bool(m_nAppearanceFlags & nFlag); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx index 297189b7ef3a..cdb0ba77bc44 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -174,7 +174,7 @@ static void lcl_SetViewMarks(SwViewOption& rVOpt, bool bOn ) rVOpt.SetHardBlank(bOn); rVOpt.SetSoftHyph(bOn); SwViewOption::SetAppearanceFlag( - VIEWOPT_FIELD_SHADINGS, bOn, true); + ViewOptFlags::FieldShadings, bOn, true); } static void lcl_SetViewMetaChars( SwViewOption& rVOpt, bool bOn) @@ -393,13 +393,13 @@ void SwView::ExecViewOptions(SfxRequest &rReq) case FN_VIEW_FIELDS: if( STATE_TOGGLE == eState ) bFlag = !SwViewOption::IsFieldShadings() ; - SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bFlag, true ); + SwViewOption::SetAppearanceFlag(ViewOptFlags::FieldShadings, bFlag, true ); break; case FN_VIEW_BOUNDS: if( STATE_TOGGLE == eState ) bFlag = !SwViewOption::IsDocBoundaries(); - SwViewOption::SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES, bFlag, true ); + SwViewOption::SetAppearanceFlag(ViewOptFlags::DocBoundaries, bFlag, true ); break; case SID_GRID_VISIBLE: @@ -496,7 +496,7 @@ void SwView::ExecViewOptions(SfxRequest &rReq) case FN_VIEW_TABLEGRID: if( STATE_TOGGLE == eState ) bFlag = !SwViewOption::IsTableBoundaries(); - SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bFlag, true ); + SwViewOption::SetAppearanceFlag(ViewOptFlags::TableBoundaries, bFlag, true ); break; case FN_VIEW_FIELDNAME: diff --git a/sw/source/uibase/uno/unomod.cxx b/sw/source/uibase/uno/unomod.cxx index 1d5e87b44d21..cab2f7649949 100644 --- a/sw/source/uibase/uno/unomod.cxx +++ b/sw/source/uibase/uno/unomod.cxx @@ -603,10 +603,10 @@ void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, c case HANDLE_VIEWSET_DRAWINGS : mpViewOption->SetDraw(bVal); break; case HANDLE_VIEWSET_FIELD_COMMANDS : mpViewOption->SetFieldName(bVal); break; case HANDLE_VIEWSET_ANNOTATIONS : mpViewOption->SetPostIts(bVal); break; - case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, true); break; + case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : SwViewOption::SetAppearanceFlag(ViewOptFlags::FieldShadings, bVal, true); break; case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( bVal ); break; - case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, true); break; - case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, true); break; + case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : SwViewOption::SetAppearanceFlag(ViewOptFlags::FieldShadings, bVal, true); break; + case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : SwViewOption::SetAppearanceFlag(ViewOptFlags::FieldShadings, bVal, true); break; case HANDLE_VIEWSET_PARA_BREAKS : mpViewOption->SetParagraph(bVal); break; case HANDLE_VIEWSET_SOFT_HYPHENS : mpViewOption->SetSoftHyph(bVal); break; case HANDLE_VIEWSET_SPACES : mpViewOption->SetBlank(bVal); break; @@ -616,7 +616,7 @@ void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, c case HANDLE_VIEWSET_HIDDEN_TEXT : mpViewOption->SetShowHiddenField(bVal); break; case HANDLE_VIEWSET_HIDDEN_CHARACTERS : mpViewOption->SetShowHiddenChar(bVal); break; case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : mpViewOption->SetShowHiddenPara(bVal); break; - case HANDLE_VIEWSET_TABLE_BOUNDARIES : SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bVal, true); break; + case HANDLE_VIEWSET_TABLE_BOUNDARIES : SwViewOption::SetAppearanceFlag(ViewOptFlags::TableBoundaries, bVal, true); break; case HANDLE_VIEWSET_TEXT_BOUNDARIES : SwViewOption::SetDocBoundaries(bVal); break; case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(bVal); break; case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : mpViewOption->SetShowContentTips(bVal); break; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 19038c74bbe0..d6efe1f79824 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3262,7 +3262,7 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>()) aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>()); else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>()) - SwViewOption::SetAppearanceFlag(VIEWOPT_SHADOW , rValue.Value.get<bool>()); + SwViewOption::SetAppearanceFlag(ViewOptFlags::Shadow , rValue.Value.get<bool>()); } pViewShell->ApplyViewOptions(aViewOption); |