[Libreoffice-commits] core.git: include/vcl vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Tue Mar 25 05:17:24 PDT 2014


 include/vcl/ctrl.hxx         |    2 ++
 include/vcl/outdev.hxx       |   16 ++++++++--------
 include/vcl/virdev.hxx       |    2 ++
 include/vcl/window.hxx       |    4 +++-
 vcl/source/control/ctrl.cxx  |   10 ++++++++++
 vcl/source/gdi/outdev.cxx    |   17 -----------------
 vcl/source/gdi/virdev.cxx    |   34 ++++++++++++----------------------
 vcl/source/window/window.cxx |   19 ++++++-------------
 8 files changed, 43 insertions(+), 61 deletions(-)

New commits:
commit 977aae0cdec71577cbdc74baea228a5f267e7fd8
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sun Mar 23 18:51:13 2014 +1100

    fdo#74702 Moved EnableRTL() logic to specific classes where appropriate
    
    OutputDevice::EnableRTL() is a bit of a mess. It uses a runtime
    variable to see if it is using a VirtualDevice, and it uses a
    dynamic_cast to see if the object is a Window or a Control!
    
    I have made it virtual and moved the knowledge of class specific
    functionality from OutputDevice to VirtualDevice, Window and Control
    as needed. OutputDevice::EnableRTL() functionality is then called.
    
    Also: small formatting change to outdev.hxx, also included a note
    that WindowImpl is a pimpl in window.hxx.
    
    Change-Id: I44b66601c4457fb2e0bbc1014fb7acf8f6942f80
    Reviewed-on: https://gerrit.libreoffice.org/8721
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>

diff --git a/include/vcl/ctrl.hxx b/include/vcl/ctrl.hxx
index 3487970..6c00e46 100644
--- a/include/vcl/ctrl.hxx
+++ b/include/vcl/ctrl.hxx
@@ -129,6 +129,8 @@ public:
     explicit        Control( Window* pParent, const ResId& );
     virtual         ~Control();
 
+    virtual void    EnableRTL ( bool bEnable = true );
+
     virtual void    GetFocus();
     virtual void    LoseFocus();
     virtual bool    Notify( NotifyEvent& rNEvt );
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index eb4d0ba..c86a8ac 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1141,25 +1141,25 @@ public:
     BitmapEx                    GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const;
 
     void                        EnableMapMode( bool bEnable = true );
-    bool                    IsMapModeEnabled() const { return mbMap; }
+    bool                        IsMapModeEnabled() const { return mbMap; }
 
     // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout
-    void                        EnableRTL( bool bEnable = true);
-    bool                    IsRTLEnabled() const { return mbEnableRTL; }
+    virtual void                EnableRTL( bool bEnable = true);
+    bool                        IsRTLEnabled() const { return mbEnableRTL; }
 
     void                        SetConnectMetaFile( GDIMetaFile* pMtf );
     GDIMetaFile*                GetConnectMetaFile() const { return mpMetaFile; }
 
     void                        EnableOutput( bool bEnable = true );
-    bool                    IsOutputEnabled() const { return mbOutput; }
-    bool                    IsDeviceOutput() const { return mbDevOutput; }
-    bool                    IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); }
-    bool                    IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); }
+    bool                        IsOutputEnabled() const { return mbOutput; }
+    bool                        IsDeviceOutput() const { return mbDevOutput; }
+    bool                        IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); }
+    bool                        IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); }
 
     void                        SetClipRegion();
     void                        SetClipRegion( const Region& rRegion );
     Region                      GetClipRegion() const;
-    bool                    IsClipRegion() const { return mbClipRegion; }
+    bool                        IsClipRegion() const { return mbClipRegion; }
     Region                      GetActiveClipRegion() const;
 
     void                        MoveClipRegion( long nHorzMove, long nVertMove );
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 72cc3fe..145179b 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -113,6 +113,8 @@ public:
 
     virtual             ~VirtualDevice();
 
+    void                EnableRTL( bool bEnable = true );
+
     bool                SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
     bool                SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer );
     bool                SetOutputSize( const Size& rNewSize, bool bErase = true )
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 5bf0e8d..3a3851c 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -355,7 +355,8 @@ private:
     // NOTE: to remove many dependencies of other modules
     //       to this central file, all members are now hidden
     //       in the WindowImpl class and all inline functions
-    //       were removed
+    //       were removed.
+    //       (WindowImpl is a pImpl pattern)
 
     //       Please do *not* add new members or inline functions to class Window,
     //       but use class WindowImpl instead
@@ -594,6 +595,7 @@ public:
     OutputDevice const* GetOutDev() const { return mpOutputDevice; };
     OutputDevice*       GetOutDev()       { return mpOutputDevice; };
 
+    virtual void        EnableRTL ( bool bEnable = true );
     virtual void        MouseMove( const MouseEvent& rMEvt );
     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 2fe5c0b..e1bfbca 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -71,6 +71,16 @@ Control::~Control()
     delete mpControlData, mpControlData = NULL;
 }
 
+
+void Control::EnableRTL( bool bEnable )
+{
+    // convenience: for controls also switch layout mode
+    SetLayoutMode( bEnable ? TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT :
+                                TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_TEXTORIGIN_LEFT );
+    StateChanged( STATE_CHANGE_MIRRORING );
+    OutputDevice::EnableRTL(bEnable);
+}
+
 void Control::GetFocus()
 {
     Window::GetFocus();
diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx
index 8518345..385ac40 100644
--- a/vcl/source/gdi/outdev.cxx
+++ b/vcl/source/gdi/outdev.cxx
@@ -461,23 +461,6 @@ bool OutputDevice::supportsOperation( OutDevSupportType eType ) const
 void OutputDevice::EnableRTL( bool bEnable )
 {
     mbEnableRTL = bEnable;
-    if( meOutDevType == OUTDEV_VIRDEV )
-    {
-        // virdevs default to not mirroring, they will only be set to mirroring
-        // under rare circumstances in the UI, eg the valueset control
-        // because each virdev has its own SalGraphics we can safely switch the SalGraphics here
-        // ...hopefully
-        if( ImplGetGraphics() )
-            mpGraphics->SetLayout( mbEnableRTL ? SAL_LAYOUT_BIDI_RTL : 0 );
-    }
-
-    // convenience: for controls also switch layout mode
-    if( dynamic_cast<Control*>(this) != 0 )
-        SetLayoutMode( bEnable ? TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT : TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_TEXTORIGIN_LEFT);
-
-    Window* pWin = dynamic_cast<Window*>(this);
-    if( pWin )
-        pWin->StateChanged( STATE_CHANGE_MIRRORING );
 
     if( mpAlphaVDev )
         mpAlphaVDev->EnableRTL( bEnable );
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 68789c8..aa3f359 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -200,8 +200,6 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
     pSVData->maGDIData.mpFirstVirDev = this;
 }
 
-
-
 VirtualDevice::VirtualDevice( sal_uInt16 nBitCount )
 :   mpVirDev( NULL ),
     meRefDevMode( REFDEV_NONE )
@@ -213,8 +211,6 @@ VirtualDevice::VirtualDevice( sal_uInt16 nBitCount )
     ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount );
 }
 
-
-
 VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount )
     : mpVirDev( NULL ),
     meRefDevMode( REFDEV_NONE )
@@ -226,8 +222,6 @@ VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount
     ImplInitVirDev( &rCompDev, 1, 1, nBitCount );
 }
 
-
-
 VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount, sal_uInt16 nAlphaBitCount )
     : mpVirDev( NULL ),
     meRefDevMode( REFDEV_NONE )
@@ -243,8 +237,6 @@ VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount
     mnAlphaDepth = sal::static_int_cast<sal_Int8>(nAlphaBitCount);
 }
 
-
-
 VirtualDevice::VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount )
 :   mpVirDev( NULL ),
     meRefDevMode( REFDEV_NONE )
@@ -254,8 +246,6 @@ VirtualDevice::VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCo
     ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount, pData );
 }
 
-
-
 VirtualDevice::~VirtualDevice()
 {
     SAL_INFO( "vcl.gdi", "VirtualDevice::~VirtualDevice()" );
@@ -279,8 +269,6 @@ VirtualDevice::~VirtualDevice()
         pSVData->maGDIData.mpLastVirDev = mpPrev;
 }
 
-
-
 bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
 {
     SAL_INFO( "vcl.gdi",
@@ -381,8 +369,6 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
     return bRet;
 }
 
-
-
 // #i32109#: Fill opaque areas correctly (without relying on
 // fill/linecolor state)
 void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
@@ -397,8 +383,6 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
     Pop();
 }
 
-
-
 bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
 {
     if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
@@ -434,6 +418,18 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, c
     return false;
 }
 
+void VirtualDevice::EnableRTL( bool bEnable )
+{
+    // virdevs default to not mirroring, they will only be set to mirroring
+    // under rare circumstances in the UI, eg the valueset control
+    // because each virdev has its own SalGraphics we can safely switch the SalGraphics here
+    // ...hopefully
+    if( ImplGetGraphics() )
+        mpGraphics->SetLayout( bEnable ? SAL_LAYOUT_BIDI_RTL : 0 );
+
+    OutputDevice::EnableRTL(bEnable);
+}
+
 bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase )
 {
     return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray() );
@@ -451,8 +447,6 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize
     return ImplSetOutputSizePixel( rNewSize, true, pBuffer);
 }
 
-
-
 void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )
 {
     sal_Int32 nDPIX = 600, nDPIY = 600;
@@ -533,13 +527,9 @@ void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32
     mpFontCache = new ImplFontCache();
 }
 
-
-
 void VirtualDevice::Compat_ZeroExtleadBug()
 {
     meRefDevMode = (sal_uInt8)meRefDevMode | REFDEV_FORCE_ZERO_EXTLEAD;
 }
 
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index abe769a..6736c54 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -106,11 +106,8 @@ using namespace ::com::sun::star::datatransfer::dnd;
 using namespace ::com::sun::star;
 using namespace com::sun;
 
-
 using ::com::sun::star::awt::XTopWindow;
 
-
-
 #define IMPL_PAINT_PAINT            ((sal_uInt16)0x0001)
 #define IMPL_PAINT_PAINTALL         ((sal_uInt16)0x0002)
 #define IMPL_PAINT_PAINTALLCHILDREN   ((sal_uInt16)0x0004)
@@ -118,8 +115,6 @@ using ::com::sun::star::awt::XTopWindow;
 #define IMPL_PAINT_ERASE            ((sal_uInt16)0x0010)
 #define IMPL_PAINT_CHECKRTL         ((sal_uInt16)0x0020)
 
-
-
 struct ImplCalcToTopData
 {
     ImplCalcToTopData*  mpNext;
@@ -144,7 +139,6 @@ ImplAccessibleInfos::~ImplAccessibleInfos()
 }
 
 
-
 WindowImpl::WindowImpl( WindowType nType )
 {
     maZoom              = Fraction( 1, 1 );
@@ -303,9 +297,6 @@ WindowImpl::~WindowImpl()
     delete mpControlFont;
 }
 
-
-
-
 // helper method to allow inline constructor even for pWindow!=NULL case
 void ImplDelData::AttachToWindow( const Window* pWindow )
 {
@@ -313,8 +304,6 @@ void ImplDelData::AttachToWindow( const Window* pWindow )
         const_cast<Window*>(pWindow)->ImplAddDel( this );
 }
 
-
-
 // define dtor for ImplDelData
 ImplDelData::~ImplDelData()
 {
@@ -328,8 +317,6 @@ ImplDelData::~ImplDelData()
     }
 }
 
-
-
 #ifdef DBG_UTIL
 const char* ImplDbgCheckWindow( const void* pObj )
 {
@@ -420,6 +407,12 @@ bool Window::ImplInitGraphics() const
     return mpGraphics ? true : false;
 }
 
+void Window::EnableRTL ( bool bEnable )
+{
+    StateChanged( STATE_CHANGE_MIRRORING );
+    OutputDevice::EnableRTL(bEnable);
+}
+
 void Window::CopyAreaFinal( SalTwoRect& aPosAry, sal_uInt32 nFlags )
 {
     if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)


More information about the Libreoffice-commits mailing list