diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-16 12:44:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-17 06:04:30 +0000 |
commit | f2a873cd13adf0b74d18af203676f2de86d1cb2e (patch) | |
tree | 8b0f044b217e86db3c7320855e4df133fbabf3ae /include | |
parent | 1bffa5e110772a7d6183ac64e56c23f2c3019f93 (diff) |
convert SvxBorderStyle to scoped enum
and rename to SvxBorderLineStyle
Change-Id: I19e530f162e4ca6290a0ad076e7fe3d5775ae6bc
Reviewed-on: https://gerrit.libreoffice.org/35265
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/drawinglayer/primitive2d/borderlineprimitive2d.hxx | 9 | ||||
-rw-r--r-- | include/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx | 2 | ||||
-rw-r--r-- | include/editeng/borderline.hxx | 313 | ||||
-rw-r--r-- | include/svtools/borderhelper.hxx | 10 | ||||
-rw-r--r-- | include/svtools/ctrlbox.hxx | 17 | ||||
-rw-r--r-- | include/svx/framelink.hxx | 12 | ||||
-rw-r--r-- | include/svx/frmsel.hxx | 4 |
7 files changed, 228 insertions, 139 deletions
diff --git a/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx b/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx index bd10add60aa9..4ac0a1045585 100644 --- a/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx @@ -27,8 +27,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> -#include <com/sun/star/table/BorderLineStyle.hpp> - +enum class SvxBorderLineStyle : sal_Int16; namespace drawinglayer { @@ -66,7 +65,7 @@ namespace drawinglayer basegfx::BColor maRGBColorGap; bool mbHasGapColor; - short mnStyle; + SvxBorderLineStyle mnStyle; double mfPatternScale; @@ -107,7 +106,7 @@ namespace drawinglayer const basegfx::BColor& rRGBColorLeft, const basegfx::BColor& rRGBColorGap, bool bHasGapColor, - const short nStyle, + SvxBorderLineStyle nStyle, double fPatternScale = 1.0 ); /// data read access @@ -124,7 +123,7 @@ namespace drawinglayer const basegfx::BColor& getRGBColorLeft () const { return maRGBColorLeft; } const basegfx::BColor& getRGBColorGap () const { return maRGBColorGap; } bool hasGapColor( ) const { return mbHasGapColor; } - short getStyle () const { return mnStyle; } + SvxBorderLineStyle getStyle () const { return mnStyle; } double getPatternScale() const { return mfPatternScale; } /// Same as create2DDecomposition(), but can do pixel correction if requested. void createDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation, bool bPixelCorrection) const; diff --git a/include/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx b/include/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx index 5b4a1414f747..3fe2813be9a9 100644 --- a/include/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx @@ -46,7 +46,7 @@ namespace drawinglayer const basegfx::BColor& rRGBColorLeft, const basegfx::BColor& rRGBColorGap, bool bHasGapColor, - const short nStyle, + SvxBorderLineStyle nStyle, double fPatternScale ); /// compare operator diff --git a/include/editeng/borderline.hxx b/include/editeng/borderline.hxx index 98e2245b0729..fd356b489546 100644 --- a/include/editeng/borderline.hxx +++ b/include/editeng/borderline.hxx @@ -37,118 +37,206 @@ #define DEF_LINE_WIDTH_5 10 -namespace editeng { - - // values from css::table::BorderLineStyle - typedef sal_Int16 SvxBorderStyle; - - // convert border style between Word formats and LO - SvxBorderStyle EDITENG_DLLPUBLIC ConvertBorderStyleFromWord(int); - /// convert border width in twips between Word formats and LO - double EDITENG_DLLPUBLIC ConvertBorderWidthToWord(SvxBorderStyle, double); - double EDITENG_DLLPUBLIC ConvertBorderWidthFromWord(SvxBorderStyle, - double, int); - - class EDITENG_DLLPUBLIC SvxBorderLine - { - protected: - Color aColor; - - long m_nWidth; - bool m_bMirrorWidths; - BorderWidthImpl m_aWidthImpl; - long m_nMult; - long m_nDiv; - - SvxBorderStyle m_nStyle; - - bool m_bUseLeftTop; - Color (*m_pColorOutFn)( Color ); - Color (*m_pColorInFn)( Color ); - Color (*m_pColorGapFn)( Color ); - - public: - SvxBorderLine( const Color *pCol = nullptr, - long nWidth = 0, - SvxBorderStyle nStyle = css::table::BorderLineStyle::SOLID, - Color (*pColorOutFn)( Color ) = &darkColor, - Color (*pColorInFn)( Color ) = &darkColor ); - SvxBorderLine( const SvxBorderLine& r ); - - SvxBorderLine& operator=( const SvxBorderLine& r ); - - const Color& GetColor() const { return aColor; } - Color GetColorOut( bool bLeftOrTop = true ) const; - Color GetColorIn( bool bLeftOrTop = true ) const; - bool HasGapColor() const { return m_pColorGapFn != nullptr; } - Color GetColorGap() const; - - void SetWidth( long nWidth ); - /** Guess the style and width from the three lines widths values. - - When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed - using the three values to match the best possible style among the following: - - SvxBorderLine::DOUBLE - - SvxBorderLine::THINTHICK_SMALLGAP - - SvxBorderLine::THINTHICK_MEDIUMGAP - - SvxBorderLine::THINTHICK_LARGEGAP - - SvxBorderLine::THICKTHIN_SMALLGAP - - SvxBorderLine::THICKTHIN_MEDIUMGAP - - SvxBorderLine::THICKTHIN_LARGEGAP - - If no styles matches the width, then the width is set to 0. - - There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt, - \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and - SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and - SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens - also for thick-thin styles. - - \param nStyle the border style used to guess the width. - \param nIn the width of the inner line in 1th pt - \param nOut the width of the outer line in 1th pt - \param nDist the width of the gap between the lines in 1th pt - */ - void GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 ); - - // TODO Hacky method to mirror lines in only a few cases - void SetMirrorWidths() { m_bMirrorWidths = true; } - long GetWidth( ) const { return m_nWidth; } - sal_uInt16 GetOutWidth() const; - sal_uInt16 GetInWidth() const; - sal_uInt16 GetDistance() const; - - SvxBorderStyle GetBorderLineStyle() const { return m_nStyle; } - - void SetColor( const Color &rColor ) { aColor = rColor; } - void SetBorderLineStyle( SvxBorderStyle nNew ); - void ScaleMetrics( long nMult, long nDiv ); - - bool operator==( const SvxBorderLine &rCmp ) const; - - OUString GetValueString( MapUnit eSrcUnit, MapUnit eDestUnit, - const IntlWrapper* pIntl, - bool bMetricStr = false ) const; - - bool HasPriority( const SvxBorderLine& rOtherLine ) const; - - bool isEmpty() const { - return m_aWidthImpl.IsEmpty() - || m_nStyle == css::table::BorderLineStyle::NONE - || m_nWidth == 0; - } - bool isDouble() const { return m_aWidthImpl.IsDouble(); } - sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); } - - static Color darkColor( Color aMain ); - static Color lightColor( Color aMain ); - - static Color threeDLightColor( Color aMain ); - static Color threeDMediumColor( Color aMain ); - static Color threeDDarkColor( Color aMain ); - - static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle ); - }; +// Abstracts over values from css::table::BorderLineStyle +enum class SvxBorderLineStyle : sal_Int16 +{ + /** No border line + */ + NONE = css::table::BorderLineStyle::NONE, + + /** Solid border line. + */ + SOLID = css::table::BorderLineStyle::SOLID, + + /** Dotted border line. + */ + DOTTED = css::table::BorderLineStyle::DOTTED, + + /** Dashed border line. + */ + DASHED = css::table::BorderLineStyle::DASHED, + + /** Double border line. Widths of the lines and the gap are all equal, + and vary equally with the total width. + */ + DOUBLE = css::table::BorderLineStyle::DOUBLE, + + /** Double border line with a thin line outside and a thick line + inside separated by a small gap. + */ + THINTHICK_SMALLGAP = css::table::BorderLineStyle::THINTHICK_SMALLGAP, + + /** Double border line with a thin line outside and a thick line + inside separated by a medium gap. + */ + THINTHICK_MEDIUMGAP = css::table::BorderLineStyle::THINTHICK_MEDIUMGAP, + + /** Double border line with a thin line outside and a thick line + inside separated by a large gap. + */ + THINTHICK_LARGEGAP = css::table::BorderLineStyle::THINTHICK_LARGEGAP, + + /** Double border line with a thick line outside and a thin line + inside separated by a small gap. + */ + THICKTHIN_SMALLGAP = css::table::BorderLineStyle::THICKTHIN_SMALLGAP, + + /** Double border line with a thick line outside and a thin line + inside separated by a medium gap. + */ + THICKTHIN_MEDIUMGAP = css::table::BorderLineStyle::THICKTHIN_MEDIUMGAP, + + /** Double border line with a thick line outside and a thin line + inside separated by a large gap. + */ + THICKTHIN_LARGEGAP = css::table::BorderLineStyle::THICKTHIN_LARGEGAP, + + /** 3D embossed border line. + */ + EMBOSSED = css::table::BorderLineStyle::EMBOSSED, + + /** 3D engraved border line. + */ + ENGRAVED = css::table::BorderLineStyle::ENGRAVED, + + /** Outset border line. + */ + OUTSET = css::table::BorderLineStyle::OUTSET, + + /** Inset border line. + */ + INSET = css::table::BorderLineStyle::INSET, + + /** Finely dashed border line. + */ + FINE_DASHED = css::table::BorderLineStyle::FINE_DASHED, + + /** Double border line consisting of two fixed thin lines separated by a + variable gap. + */ + DOUBLE_THIN = css::table::BorderLineStyle::DOUBLE_THIN, + + /** Line consisting of a repetition of one dash and one dot. */ + DASH_DOT = css::table::BorderLineStyle::DASH_DOT, + + /** Line consisting of a repetition of one dash and 2 dots. */ + DASH_DOT_DOT = css::table::BorderLineStyle::DASH_DOT_DOT, + + /** Maximum valid border line style value. + */ + BORDER_LINE_STYLE_MAX = css::table::BorderLineStyle::BORDER_LINE_STYLE_MAX, +}; + +namespace editeng +{ + +// convert border style between Word formats and LO +SvxBorderLineStyle EDITENG_DLLPUBLIC ConvertBorderStyleFromWord(int); +/// convert border width in twips between Word formats and LO +double EDITENG_DLLPUBLIC ConvertBorderWidthToWord(SvxBorderLineStyle, double); +double EDITENG_DLLPUBLIC ConvertBorderWidthFromWord(SvxBorderLineStyle, + double, int); + +class EDITENG_DLLPUBLIC SvxBorderLine +{ +protected: + Color aColor; + + long m_nWidth; + bool m_bMirrorWidths; + BorderWidthImpl m_aWidthImpl; + long m_nMult; + long m_nDiv; + + SvxBorderLineStyle m_nStyle; + + bool m_bUseLeftTop; + Color (*m_pColorOutFn)( Color ); + Color (*m_pColorInFn)( Color ); + Color (*m_pColorGapFn)( Color ); + +public: + SvxBorderLine( const Color *pCol = nullptr, + long nWidth = 0, + SvxBorderLineStyle nStyle = SvxBorderLineStyle::SOLID, + Color (*pColorOutFn)( Color ) = &darkColor, + Color (*pColorInFn)( Color ) = &darkColor ); + SvxBorderLine( const SvxBorderLine& r ); + + SvxBorderLine& operator=( const SvxBorderLine& r ); + + const Color& GetColor() const { return aColor; } + Color GetColorOut( bool bLeftOrTop = true ) const; + Color GetColorIn( bool bLeftOrTop = true ) const; + bool HasGapColor() const { return m_pColorGapFn != nullptr; } + Color GetColorGap() const; + + void SetWidth( long nWidth ); + /** Guess the style and width from the three lines widths values. + + When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed + using the three values to match the best possible style among the following: + - SvxBorderLine::DOUBLE + - SvxBorderLine::THINTHICK_SMALLGAP + - SvxBorderLine::THINTHICK_MEDIUMGAP + - SvxBorderLine::THINTHICK_LARGEGAP + - SvxBorderLine::THICKTHIN_SMALLGAP + - SvxBorderLine::THICKTHIN_MEDIUMGAP + - SvxBorderLine::THICKTHIN_LARGEGAP + + If no styles matches the width, then the width is set to 0. + + There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt, + \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and + SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and + SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens + also for thick-thin styles. + + \param nStyle the border style used to guess the width. + \param nIn the width of the inner line in 1th pt + \param nOut the width of the outer line in 1th pt + \param nDist the width of the gap between the lines in 1th pt + */ + void GuessLinesWidths( SvxBorderLineStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 ); + + // TODO Hacky method to mirror lines in only a few cases + void SetMirrorWidths() { m_bMirrorWidths = true; } + long GetWidth( ) const { return m_nWidth; } + sal_uInt16 GetOutWidth() const; + sal_uInt16 GetInWidth() const; + sal_uInt16 GetDistance() const; + + SvxBorderLineStyle GetBorderLineStyle() const { return m_nStyle; } + + void SetColor( const Color &rColor ) { aColor = rColor; } + void SetBorderLineStyle( SvxBorderLineStyle nNew ); + void ScaleMetrics( long nMult, long nDiv ); + + bool operator==( const SvxBorderLine &rCmp ) const; + + OUString GetValueString( MapUnit eSrcUnit, MapUnit eDestUnit, + const IntlWrapper* pIntl, + bool bMetricStr = false ) const; + + bool HasPriority( const SvxBorderLine& rOtherLine ) const; + + bool isEmpty() const { + return m_aWidthImpl.IsEmpty() + || m_nStyle == SvxBorderLineStyle::NONE + || m_nWidth == 0; + } + bool isDouble() const { return m_aWidthImpl.IsDouble(); } + sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); } + + static Color darkColor( Color aMain ); + static Color lightColor( Color aMain ); + + static Color threeDLightColor( Color aMain ); + static Color threeDMediumColor( Color aMain ); + static Color threeDDarkColor( Color aMain ); + + static BorderWidthImpl getWidthImpl( SvxBorderLineStyle nStyle ); +}; EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight ); @@ -156,4 +244,3 @@ EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLi #endif -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/borderhelper.hxx b/include/svtools/borderhelper.hxx index 5e4328dfd147..43d757be80b0 100644 --- a/include/svtools/borderhelper.hxx +++ b/include/svtools/borderhelper.hxx @@ -27,18 +27,20 @@ #include <basegfx/point/b2dpoint.hxx> #include <vcl/outdev.hxx> +enum class SvxBorderLineStyle : sal_Int16; + namespace svtools { -SVT_DLLPUBLIC std::vector<double> GetLineDashing( sal_uInt16 nDashing, double fScale ); +SVT_DLLPUBLIC std::vector<double> GetLineDashing( SvxBorderLineStyle nDashing, double fScale ); SVT_DLLPUBLIC basegfx::B2DPolyPolygon ApplyLineDashing( - const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, double fScale ); + const basegfx::B2DPolygon& rPolygon, SvxBorderLineStyle nDashing, double fScale ); SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const basegfx::B2DPoint& rBeg, - const basegfx::B2DPoint& rEnd, sal_uInt32 nWidth, sal_uInt16 nDashing ); + const basegfx::B2DPoint& rEnd, sal_uInt32 nWidth, SvxBorderLineStyle nDashing ); SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const Point& rBeg, - const Point& rEnd, sal_uInt32 nWidth, sal_uInt16 nDashing ); + const Point& rEnd, sal_uInt32 nWidth, SvxBorderLineStyle nDashing ); } #endif diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx index b226137f9da3..b2179d4c5b65 100644 --- a/include/svtools/ctrlbox.hxx +++ b/include/svtools/ctrlbox.hxx @@ -34,6 +34,7 @@ class FontList; class ImpLineListData; +enum class SvxBorderLineStyle : sal_Int16; typedef ::std::vector< ImpLineListData* > ImpLineList; typedef ::std::vector< FontMetric > ImplFontList; @@ -206,7 +207,7 @@ class SVT_DLLPUBLIC LineListBox : public ListBox SVT_DLLPRIVATE void ImpGetLine( long nLine1, long nLine2, long nDistance, Color nColor1, Color nColor2, Color nColorDist, - sal_uInt16 nStyle, Bitmap& rBmp ); + SvxBorderLineStyle nStyle, Bitmap& rBmp ); using Window::ImplInit; SVT_DLLPRIVATE void ImplInit(); void UpdatePaintLineColor(); // returns sal_True if maPaintCol has changed @@ -231,21 +232,21 @@ public: using ListBox::InsertEntry; /** Insert a listbox entry with all widths in Twips. */ void InsertEntry(const BorderWidthImpl& rWidthImpl, - sal_uInt16 nStyle, long nMinWidth = 0, + SvxBorderLineStyle nStyle, long nMinWidth = 0, ColorFunc pColor1Fn = &sameColor, ColorFunc pColor2Fn = &sameColor, ColorDistFunc pColorDistFn = &sameDistColor); using ListBox::GetEntryPos; - sal_Int32 GetEntryPos( sal_uInt16 nStyle ) const; - sal_uInt16 GetEntryStyle( sal_Int32 nPos ) const; + sal_Int32 GetEntryPos( SvxBorderLineStyle nStyle ) const; + SvxBorderLineStyle GetEntryStyle( sal_Int32 nPos ) const; - void SelectEntry( sal_uInt16 nStyle, bool bSelect = true ); - sal_uInt16 GetSelectEntryStyle() const; + void SelectEntry( SvxBorderLineStyle nStyle, bool bSelect = true ); + SvxBorderLineStyle GetSelectEntryStyle() const; - void SetUnit( FieldUnit eNewUnit ) { eUnit = eNewUnit; } + void SetUnit( FieldUnit eNewUnit ) { eUnit = eNewUnit; } - void SetSourceUnit( FieldUnit eNewUnit ) { eSourceUnit = eNewUnit; } + void SetSourceUnit( FieldUnit eNewUnit ) { eSourceUnit = eNewUnit; } void SetColor( const Color& rColor ); const Color& GetColor() const { return aColor; } diff --git a/include/svx/framelink.hxx b/include/svx/framelink.hxx index 7520faf6ca21..eacf64633d73 100644 --- a/include/svx/framelink.hxx +++ b/include/svx/framelink.hxx @@ -110,10 +110,10 @@ public: /** Constructs an invisible frame style. */ explicit Style(); /** Constructs a frame style with passed line widths. */ - explicit Style( double nP, double nD, double nS, editeng::SvxBorderStyle nType ); + explicit Style( double nP, double nD, double nS, SvxBorderLineStyle nType ); /** Constructs a frame style with passed color and line widths. */ explicit Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, - double nP, double nD, double nS, editeng::SvxBorderStyle nType ); + double nP, double nD, double nS, SvxBorderLineStyle nType ); /** Constructs a frame style from the passed SvxBorderLine struct. Clears the style, if pBorder is 0. */ explicit Style( const editeng::SvxBorderLine* pBorder, double fScale = 1.0 ); @@ -127,7 +127,7 @@ public: double Secn() const { return mfSecn; } double PatternScale() const { return mfPatternScale;} void SetPatternScale( double fScale ); - editeng::SvxBorderStyle Type() const { return mnType; } + SvxBorderLineStyle Type() const { return mnType; } /** Returns the total width of this frame style. */ double GetWidth() const { return mfPrim + mfDist + mfSecn; } @@ -150,7 +150,7 @@ public: void SetColorPrim( const Color& rColor ) { maColorPrim = rColor; } void SetColorSecn( const Color& rColor ) { maColorSecn = rColor; } /** Sets whether to use dotted style for single hair lines. */ - void SetType( editeng::SvxBorderStyle nType ) { mnType = nType; } + void SetType( SvxBorderLineStyle nType ) { mnType = nType; } /** Mirrors this style (exchanges primary and secondary), if it is a double frame style. */ Style& MirrorSelf(); @@ -166,8 +166,8 @@ private: double mfPrim; /// Width of primary (single, left, or top) line. double mfDist; /// Distance between primary and secondary line. double mfSecn; /// Width of secondary (right or bottom) line. - double mfPatternScale; /// Scale used for line pattern spacing. - editeng::SvxBorderStyle mnType; + double mfPatternScale; /// Scale used for line pattern spacing. + SvxBorderLineStyle mnType; }; bool operator==( const Style& rL, const Style& rR ); diff --git a/include/svx/frmsel.hxx b/include/svx/frmsel.hxx index cbe6f7186bea..3221512f8c44 100644 --- a/include/svx/frmsel.hxx +++ b/include/svx/frmsel.hxx @@ -121,7 +121,7 @@ public: /** Returns true, if all visible frame borders have equal widths. @descr Ignores hidden and "don't care" frame borders. On success, returns the width in the passed parameter. */ - bool GetVisibleWidth( long& rnWidth, editeng::SvxBorderStyle& rnStyle ) const; + bool GetVisibleWidth( long& rnWidth, SvxBorderLineStyle& rnStyle ) const; /** Returns true, if all visible frame borders have equal color. @descr Ignores hidden and "don't care" frame borders. On success, returns the color in the passed parameter. */ @@ -149,7 +149,7 @@ public: void SelectAllVisibleBorders(); /** Sets the passed line widths to all selected frame borders (in twips). */ - void SetStyleToSelection( long nWidth, editeng::SvxBorderStyle nStyle ); + void SetStyleToSelection( long nWidth, SvxBorderLineStyle nStyle ); /** Sets the passed color to all selected frame borders. */ void SetColorToSelection( const Color& rColor ); |