diff options
author | Noel Grandin <noel@peralex.com> | 2014-08-01 12:34:33 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-08-20 09:01:26 -0500 |
commit | 794d5ac4ac0b1dcaac289772ce096a4295d4e15d (patch) | |
tree | d02d4d13e793b0856c4dd962cf4b8d946942e3c4 /canvas | |
parent | 71804294c79136ef43a8f91b5c961e266d32187a (diff) |
vcl: use enum for complex text layout constants
Since these constants are bitfield flags, we define some methods to make
working with them reasonably type safe.
Move the definitions to outdevstate.hxx, since we need the values there,
and that appears to be the "root most" header file.
Also dump TEXT_LAYOUT_BIDI_LTR constant, since it means the same thing
as TEXT_LAYOUT_DEFAULT (ie. 0), and leaving it in causes people to write
weird code thinking that it's a real flag.
Change-Id: Iddab86cd6c78181ceb8caa48e77e1f5a8e526343
Reviewed-on: https://gerrit.libreoffice.org/10676
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper_text.cxx | 5 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_textlayout.cxx | 10 | ||||
-rw-r--r-- | canvas/source/vcl/canvashelper.cxx | 5 | ||||
-rw-r--r-- | canvas/source/vcl/textlayout.cxx | 10 |
4 files changed, 12 insertions, 18 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx index d65f2de34ab2..f95d71a48485 100644 --- a/canvas/source/cairo/cairo_canvashelper_text.cxx +++ b/canvas/source/cairo/cairo_canvashelper_text.cxx @@ -307,14 +307,13 @@ namespace cairocanvas return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary // change text direction and layout mode - sal_uLong nLayoutMode(0); + ComplexTextLayoutMode nLayoutMode(TEXT_LAYOUT_DEFAULT); switch( textDirection ) { case rendering::TextDirection::WEAK_LEFT_TO_RIGHT: - nLayoutMode |= TEXT_LAYOUT_BIDI_LTR; // FALLTHROUGH intended case rendering::TextDirection::STRONG_LEFT_TO_RIGHT: - nLayoutMode |= TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG; + nLayoutMode |= TEXT_LAYOUT_BIDI_STRONG; nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_LEFT; break; diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx index db9a21cb1602..f01e75a8e892 100644 --- a/canvas/source/cairo/cairo_textlayout.cxx +++ b/canvas/source/cairo/cairo_textlayout.cxx @@ -72,17 +72,13 @@ namespace cairocanvas sal_Int8 nTextDirection ) { // TODO(P3): avoid if already correctly set - sal_uLong nLayoutMode; + ComplexTextLayoutMode nLayoutMode = TEXT_LAYOUT_DEFAULT; switch( nTextDirection ) { - default: - nLayoutMode = 0; - break; case rendering::TextDirection::WEAK_LEFT_TO_RIGHT: - nLayoutMode = TEXT_LAYOUT_BIDI_LTR; break; case rendering::TextDirection::STRONG_LEFT_TO_RIGHT: - nLayoutMode = TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG; + nLayoutMode = TEXT_LAYOUT_BIDI_STRONG; break; case rendering::TextDirection::WEAK_RIGHT_TO_LEFT: nLayoutMode = TEXT_LAYOUT_BIDI_RTL; @@ -90,6 +86,8 @@ namespace cairocanvas case rendering::TextDirection::STRONG_RIGHT_TO_LEFT: nLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG; break; + default: + break; } // set calculated layout mode. Origin is always the left edge, diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 4112c5b858b1..eff50dc7df87 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -589,14 +589,13 @@ namespace vclcanvas return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary // change text direction and layout mode - sal_uIntPtr nLayoutMode(0); + ComplexTextLayoutMode nLayoutMode(TEXT_LAYOUT_DEFAULT); switch( textDirection ) { case rendering::TextDirection::WEAK_LEFT_TO_RIGHT: - nLayoutMode |= TEXT_LAYOUT_BIDI_LTR; // FALLTHROUGH intended case rendering::TextDirection::STRONG_LEFT_TO_RIGHT: - nLayoutMode |= TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG; + nLayoutMode |= TEXT_LAYOUT_BIDI_STRONG; nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_LEFT; break; diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx index 3f8127662a8a..d64f7dfa7fb7 100644 --- a/canvas/source/vcl/textlayout.cxx +++ b/canvas/source/vcl/textlayout.cxx @@ -48,17 +48,13 @@ namespace vclcanvas sal_Int8 nTextDirection ) { // TODO(P3): avoid if already correctly set - sal_uIntPtr nLayoutMode; + ComplexTextLayoutMode nLayoutMode = TEXT_LAYOUT_DEFAULT; switch( nTextDirection ) { - default: - nLayoutMode = 0; - break; case rendering::TextDirection::WEAK_LEFT_TO_RIGHT: - nLayoutMode = TEXT_LAYOUT_BIDI_LTR; break; case rendering::TextDirection::STRONG_LEFT_TO_RIGHT: - nLayoutMode = TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG; + nLayoutMode = TEXT_LAYOUT_BIDI_STRONG; break; case rendering::TextDirection::WEAK_RIGHT_TO_LEFT: nLayoutMode = TEXT_LAYOUT_BIDI_RTL; @@ -66,6 +62,8 @@ namespace vclcanvas case rendering::TextDirection::STRONG_RIGHT_TO_LEFT: nLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG; break; + default: + break; } // set calculated layout mode. Origin is always the left edge, |