diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-03-09 15:23:11 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-03-12 00:21:29 +0000 |
commit | 51d0b4037b36a4a74c9181b95edb18017542ab79 (patch) | |
tree | c13c5ac4782888e1640ee60911d68329018dcc05 /sc/inc | |
parent | dc519b6dea7653e4b68b45aa664e3c0b5189d682 (diff) |
tdf#84938 Change defines to typed_flags
Put defines into an enum class and use typed_flags template from o3tl
to give them flag operators.
There were some shift operations to apply flags from start references
to end references, these went into a helper in address.hxx to hide
them. A marco with shift operations in address.cxx was rewritten in two
helpers without shifts.
One shift remained in ScRange::Format with a comment.
The other flag untypical operator was a minus 1 in a helper for
ScRefFinder::ToggleRel, which iteratates through all possible
combinations for absolute references. This is used to make referecnces
absolute via SHIFT+F4. A replacement would be too complex.
Change-Id: I4850f1623e01e56c60ac2260b95fc5cad8b6fd71
Signed-off-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Reviewed-on: https://gerrit.libreoffice.org/22840
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/address.hxx | 91 | ||||
-rw-r--r-- | sc/inc/attrib.hxx | 3 | ||||
-rw-r--r-- | sc/inc/rangelst.hxx | 6 | ||||
-rw-r--r-- | sc/inc/rangeutl.hxx | 8 |
4 files changed, 61 insertions, 47 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index 0e545be5578f..a917de79d0c8 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -29,6 +29,7 @@ #include "types.hxx" #include <formula/grammar.hxx> +#include <o3tl/typed_flags_set.hxx> #include <com/sun/star/uno/Sequence.hxx> namespace com { namespace sun { namespace star { @@ -140,35 +141,51 @@ SAL_WARN_UNUSED_RESULT inline SCTAB SanitizeTab( SCTAB nTab ) // not using gcc -fno-strict-aliasing // The result of ConvertRef() is a bit group of the following: +enum class ScRefFlags : sal_uInt16 +{ + ZERO = 0x0000, + COL_ABS = 0x0001, + ROW_ABS = 0x0002, + TAB_ABS = 0x0004, + TAB_3D = 0x0008, + COL2_ABS = 0x0010, + ROW2_ABS = 0x0020, + TAB2_ABS = 0x0040, + TAB2_3D = 0x0080, + ROW_VALID = 0x0100, + COL_VALID = 0x0200, + TAB_VALID = 0x0400, + // BITS for convience + BITS = COL_ABS | ROW_ABS | TAB_ABS | TAB_3D \ + | ROW_VALID | COL_VALID | TAB_VALID, + // somewhat cheesy kludge to force the display of the document name even for + // local references. Requires TAB_3D to be valid + FORCE_DOC = 0x0800, + ROW2_VALID = 0x1000, + COL2_VALID = 0x2000, + TAB2_VALID = 0x4000, + VALID = 0x8000, + + ADDR_ABS = VALID | COL_ABS | ROW_ABS | TAB_ABS, + + RANGE_ABS = ADDR_ABS | COL2_ABS | ROW2_ABS | TAB2_ABS, + + ADDR_ABS_3D = ADDR_ABS | TAB_3D, + RANGE_ABS_3D = RANGE_ABS | TAB_3D +}; -#define SCA_COL_ABSOLUTE 0x01 -#define SCA_ROW_ABSOLUTE 0x02 -#define SCA_TAB_ABSOLUTE 0x04 -#define SCA_TAB_3D 0x08 -#define SCA_COL2_ABSOLUTE 0x10 -#define SCA_ROW2_ABSOLUTE 0x20 -#define SCA_TAB2_ABSOLUTE 0x40 -#define SCA_TAB2_3D 0x80 -#define SCA_VALID_ROW 0x0100 -#define SCA_VALID_COL 0x0200 -#define SCA_VALID_TAB 0x0400 -// SCA_BITS is a convience for -// (SCA_VALID_TAB | SCA_VALID_COL | SCA_VALID_ROW | SCA_TAB_3D | SCA_TAB_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_COL_ABSOLUTE) -#define SCA_BITS 0x070F -// somewhat cheesy kludge to force the display of the document name even for -// local references. Requires TAB_3D to be valid -#define SCA_FORCE_DOC 0x0800 -#define SCA_VALID_ROW2 0x1000 -#define SCA_VALID_COL2 0x2000 -#define SCA_VALID_TAB2 0x4000 -#define SCA_VALID 0x8000 - -#define SCA_ABS SCA_VALID | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE - -#define SCR_ABS SCA_ABS | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE - -#define SCA_ABS_3D SCA_ABS | SCA_TAB_3D -#define SCR_ABS_3D SCR_ABS | SCA_TAB_3D +namespace o3tl +{ + template<> struct typed_flags<ScRefFlags> : is_typed_flags<ScRefFlags, 0xffff> {}; +} +inline void applyStartToEndFlags(ScRefFlags &target,const ScRefFlags source) +{ + target |= ScRefFlags((std::underlying_type<ScRefFlags>::type)source << 4); +} +inline void applyStartToEndFlags(ScRefFlags &target) +{ + target |= ScRefFlags((std::underlying_type<ScRefFlags>::type)target << 4); +} // ScAddress class ScAddress @@ -291,17 +308,17 @@ public: nTabP = nTab; } - SC_DLLPUBLIC sal_uInt16 Parse( + SC_DLLPUBLIC ScRefFlags Parse( const OUString&, ScDocument* = nullptr, const Details& rDetails = detailsOOOa1, ExternalInfo* pExtInfo = nullptr, const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr ); - SC_DLLPUBLIC void Format( OStringBuffer& r, sal_uInt16 nFlags = 0, + SC_DLLPUBLIC void Format( OStringBuffer& r, ScRefFlags nFlags = ScRefFlags::ZERO, const ScDocument* pDocument = nullptr, const Details& rDetails = detailsOOOa1) const; - SC_DLLPUBLIC OUString Format( sal_uInt16 nFlags = 0, + SC_DLLPUBLIC OUString Format( ScRefFlags nFlags = ScRefFlags::ZERO, const ScDocument* pDocument = nullptr, const Details& rDetails = detailsOOOa1) const; @@ -476,14 +493,14 @@ public: inline bool In( const ScAddress& ) const; ///< is Address& in Range? inline bool In( const ScRange& ) const; ///< is Range& in Range? - SC_DLLPUBLIC sal_uInt16 Parse( const OUString&, ScDocument* = nullptr, + SC_DLLPUBLIC ScRefFlags Parse( const OUString&, ScDocument* = nullptr, const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, ScAddress::ExternalInfo* pExtInfo = nullptr, const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr ); - SC_DLLPUBLIC sal_uInt16 ParseAny( const OUString&, ScDocument* = nullptr, + SC_DLLPUBLIC ScRefFlags ParseAny( const OUString&, ScDocument* = nullptr, const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); - SC_DLLPUBLIC sal_uInt16 ParseCols( const OUString&, ScDocument* = nullptr, + SC_DLLPUBLIC ScRefFlags ParseCols( const OUString&, ScDocument* = nullptr, const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); SC_DLLPUBLIC void ParseRows( const OUString&, ScDocument* = nullptr, const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); @@ -502,7 +519,7 @@ public: @returns Pointer to the position after '!' if successfully parsed, and rExternDocName, rStartTabName and/or rEndTabName filled if - applicable. SCA_... flags set in nFlags. + applicable. ScRefFlags::... flags set in nFlags. Or if no valid document and/or sheet header could be parsed the start position passed with pString. Or NULL if a 3D sheet header could be parsed but @@ -510,11 +527,11 @@ public: */ const sal_Unicode* Parse_XL_Header( const sal_Unicode* pString, const ScDocument* pDocument, OUString& rExternDocName, OUString& rStartTabName, - OUString& rEndTabName, sal_uInt16& nFlags, + OUString& rEndTabName, ScRefFlags& nFlags, bool bOnlyAcceptSingle, const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr ); - SC_DLLPUBLIC OUString Format(sal_uInt16 nFlags= 0, const ScDocument* pDocument = nullptr, + SC_DLLPUBLIC OUString Format(ScRefFlags nFlags = ScRefFlags::ZERO, const ScDocument* pDocument = nullptr, const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx index 7bab719aadc3..4c0b739a34b3 100644 --- a/sc/inc/attrib.hxx +++ b/sc/inc/attrib.hxx @@ -144,9 +144,6 @@ public: }; // ScRangeItem: manages an area of a table - -#define SCR_INVALID 0x01 - class ScRangeItem : public SfxPoolItem { public: diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx index 7d19174cbe43..2641483adef9 100644 --- a/sc/inc/rangelst.hxx +++ b/sc/inc/rangelst.hxx @@ -38,12 +38,12 @@ public: ScRangeList& operator=(const ScRangeList& rList); void Append( const ScRange& rRange ); - sal_uInt16 Parse( const OUString&, ScDocument* = nullptr, - sal_uInt16 nMask = SCA_VALID, + ScRefFlags Parse( const OUString&, ScDocument* = nullptr, + ScRefFlags nMask = ScRefFlags::VALID, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 ); - void Format( OUString&, sal_uInt16 nFlags = 0, ScDocument* = nullptr, + void Format( OUString&, ScRefFlags nFlags = ScRefFlags::ZERO, ScDocument* = nullptr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, sal_Unicode cDelimiter = 0 ) const; diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx index c572797bc6f6..2aa035e07de2 100644 --- a/sc/inc/rangeutl.hxx +++ b/sc/inc/rangeutl.hxx @@ -177,7 +177,7 @@ public: formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator = ' ', bool bAppendStr = false, - sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) ); static void GetStringFromRange( OUString& rString, const ScRange& rRange, @@ -185,7 +185,7 @@ public: formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator = ' ', bool bAppendStr = false, - sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) ); static void GetStringFromRangeList( OUString& rString, const ScRangeList* pRangeList, @@ -200,7 +200,7 @@ public: formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator = ' ', bool bAppendStr = false, - sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) ); /// Range to String API static void GetStringFromAddress( @@ -217,7 +217,7 @@ public: formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator = ' ', bool bAppendStr = false, - sal_uInt16 nFormatFlags = (SCA_VALID | SCA_TAB_3D) ); + ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) ); static void GetStringFromRangeList( OUString& rString, const css::uno::Sequence< css::table::CellRangeAddress >& rRangeSeq, |