summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-03-12 11:08:07 +0000
committerHerbert Dürr <hdu@apache.org>2013-03-12 11:08:07 +0000
commit3a125c8efe2af8f15e4606558063ffab64da0566 (patch)
tree2a49b219099ccd02e795a152c222450021b9b687 /canvas
parent61bab828e5f490555580e6e61e7549a0f382ba74 (diff)
#i99414# add bidi support to the DirextX canvas
Patch By: Henner Drewes <hennerd@freenet.de> Review By: Herbert Duerr
Notes
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/directx/dx_textlayout.cxx6
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.cxx40
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.hxx6
3 files changed, 46 insertions, 6 deletions
diff --git a/canvas/source/directx/dx_textlayout.cxx b/canvas/source/directx/dx_textlayout.cxx
index 03836d0e33a0..adb6bb4240d7 100644
--- a/canvas/source/directx/dx_textlayout.cxx
+++ b/canvas/source/directx/dx_textlayout.cxx
@@ -119,7 +119,8 @@ namespace dxcanvas
maText,
maLogicalAdvancements,
mpFont.getRef(),
- mpFont->getFontMatrix()));
+ mpFont->getFontMatrix(),
+ mnTextDirection ));
return aBounds;
}
@@ -247,7 +248,8 @@ namespace dxcanvas
maLogicalAdvancements,
mpFont.getRef(),
mpFont->getFontMatrix(),
- bAlphaSurface);
+ bAlphaSurface,
+ mnTextDirection );
return true;
}
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx
index 004a39c1aa54..9e16a94f16b1 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.cxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/rendering/FontRequest.hpp>
#include <com/sun/star/rendering/PanoseProportion.hpp>
#include <com/sun/star/rendering/XCanvasFont.hpp>
+#include <com/sun/star/rendering/TextDirection.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/scopeguard.hxx>
#include <tools/color.hxx>
@@ -71,6 +72,35 @@ namespace dxcanvas
{
}
+ void setupLayoutMode( VirtualDevice& rVirDev,
+ sal_Int8 nTextDirection )
+ {
+ // TODO(P3): avoid if already correctly set
+ ULONG nLayoutMode;
+ 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;
+ break;
+ case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
+ nLayoutMode = TEXT_LAYOUT_BIDI_RTL;
+ break;
+ case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
+ nLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
+ break;
+ }
+
+ // set calculated layout mode. Origin is always the left edge,
+ // as required at the API spec
+ rVirDev.SetLayoutMode( nLayoutMode | TEXT_LAYOUT_TEXTORIGIN_LEFT );
+ }
+
void TextLayoutDrawHelper::drawText(
const GraphicsSharedPtr& rGraphics,
const ::com::sun::star::rendering::ViewState& rViewState,
@@ -81,7 +111,8 @@ namespace dxcanvas
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XCanvasFont >& rCanvasFont,
const ::com::sun::star::geometry::Matrix2D& rFontMatrix,
- bool bAlphaSurface )
+ bool bAlphaSurface,
+ sal_Int8 nTextDirection)
{
HDC hdc = rGraphics->GetHDC();
@@ -157,6 +188,8 @@ namespace dxcanvas
// set font
aVirtualDevice.SetFont(aFont);
+ setupLayoutMode( aVirtualDevice, nTextDirection );
+
// create world transformation matrix
::basegfx::B2DHomMatrix aWorldTransform;
::canvas::tools::mergeViewAndRenderTransform(aWorldTransform, rViewState, rRenderState);
@@ -240,7 +273,8 @@ namespace dxcanvas
geometry::RealRectangle2D TextLayoutDrawHelper::queryTextBounds( const rendering::StringContext& rText,
const uno::Sequence< double >& rLogicalAdvancements,
const uno::Reference< rendering::XCanvasFont >& rCanvasFont,
- const geometry::Matrix2D& rFontMatrix )
+ const geometry::Matrix2D& rFontMatrix,
+ sal_Int8 nTextDirection )
{
if(!(rText.Length))
return geometry::RealRectangle2D();
@@ -286,6 +320,8 @@ namespace dxcanvas
// set font
aVirtualDevice.SetFont(aFont);
+ setupLayoutMode( aVirtualDevice, nTextDirection );
+
// need metrics for Y offset, the XCanvas always renders
// relative to baseline
const ::FontMetric& aMetric( aVirtualDevice.GetFontMetric() );
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.hxx b/canvas/source/directx/dx_textlayout_drawhelper.hxx
index 04637faea934..4d9c3bf0bcce 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.hxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.hxx
@@ -59,14 +59,16 @@ namespace dxcanvas
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XCanvasFont >& rCanvasFont,
const ::com::sun::star::geometry::Matrix2D& rFontMatrix,
- bool bAlphaSurface );
+ bool bAlphaSurface,
+ sal_Int8 nTextDirection);
::com::sun::star::geometry::RealRectangle2D queryTextBounds(
const ::com::sun::star::rendering::StringContext& rText,
const ::com::sun::star::uno::Sequence< double >& rLogicalAdvancements,
const ::com::sun::star::uno::Reference<
::com::sun::star::rendering::XCanvasFont >& rCanvasFont,
- const ::com::sun::star::geometry::Matrix2D& rFontMatrix );
+ const ::com::sun::star::geometry::Matrix2D& rFontMatrix,
+ sal_Int8 nTextDirection );
#ifdef DBG_UTIL
void test();