Author: hdu
Date: Tue Mar 12 12:08:07 2013
New Revision: 1455505

URL: http://svn.apache.org/r1455505
Log:
#i99414# add bidi support to the DirextX canvas

Patch By: Henner Drewes <henn...@freenet.de>
Review By: Herbert Duerr

Modified:
    openoffice/trunk/main/canvas/source/directx/dx_textlayout.cxx
    openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.cxx
    openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.hxx

Modified: openoffice/trunk/main/canvas/source/directx/dx_textlayout.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/canvas/source/directx/dx_textlayout.cxx?rev=1455505&r1=1455504&r2=1455505&view=diff
==============================================================================
--- openoffice/trunk/main/canvas/source/directx/dx_textlayout.cxx (original)
+++ openoffice/trunk/main/canvas/source/directx/dx_textlayout.cxx Tue Mar 12 
12:08:07 2013
@@ -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;
     }

Modified: 
openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.cxx?rev=1455505&r1=1455504&r2=1455505&view=diff
==============================================================================
--- openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.cxx 
(original)
+++ openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.cxx 
Tue Mar 12 12:08:07 2013
@@ -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() );

Modified: 
openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.hxx?rev=1455505&r1=1455504&r2=1455505&view=diff
==============================================================================
--- openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.hxx 
(original)
+++ openoffice/trunk/main/canvas/source/directx/dx_textlayout_drawhelper.hxx 
Tue Mar 12 12:08:07 2013
@@ -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();


Reply via email to