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

Chris Sherlock chris.sherlock79 at gmail.com
Tue May 6 16:31:51 PDT 2014


 desktop/inc/app.hxx          |    1 
 desktop/source/app/app.cxx   |    1 
 include/vcl/svapp.hxx        |   38 ++++++++++++++++++------------
 include/vcl/window.hxx       |    2 -
 vcl/source/app/svapp.cxx     |   54 ++++++++++++++++++++++++++++++++++++++++---
 vcl/source/outdev/map.cxx    |   11 --------
 vcl/source/window/window.cxx |   48 --------------------------------------
 7 files changed, 76 insertions(+), 79 deletions(-)

New commits:
commit 081a0854635f4bc9f6f743ef4e2675c208405f74
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Tue May 6 23:49:29 2014 +1000

    Move ImplInitAppFontData from Window to Application (take 2)
    
    I have renamed ImplInitAppFontData to InitAppFontData and moved it from
    Window to Application. This is because this is something that sets
    *application* global variables, it just so happens it gets it from a
    Window parameter. But it should be set when the application starts, so I
    have moved it to Main().
    
    This was previously reverted, but I have since located what was causing
    unit tests to fail and the font dropdowns to stop loading in writer:
    see commit c6d7ba5f33c3 where Application::SetSettings() was setting
    pImplSVData->maGDIData.mnAppFontX to zero.
    
    Change-Id: I5da7073b0d8541f1a71a09b0a8337d012fc4134b

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 67fc3fb..8b8affe 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -128,6 +128,7 @@ class Desktop : public Application
             // throws an exception upon failure
 
     private:
+
         void                    RegisterServices(
                                     css::uno::Reference< css::uno::XComponentContext > const & context);
         void                    DeregisterServices();
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 377afc7..247ac1d 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1493,6 +1493,7 @@ int Desktop::Main()
            the main thread is not yet in the event loop.
         */
         Application::GetDefaultDevice();
+        Application::InitAppFontData();
 
 #if HAVE_FEATURE_EXTENSIONS
         // Check if bundled or shared extensions were added /removed
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index a0d71e6..b7e00ca 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -267,6 +267,12 @@ public:
     */
     virtual void                Init();
 
+protected:
+    /** Initialize font data for the application.
+     */
+    static void                 InitAppFontData();
+
+public:
     /** Finish initialization of the application.
 
      @see Init, DeInit
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 5dc7340..64d4732 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -384,8 +384,6 @@ public:
     DECL_DLLPRIVATE_LINK(      ImplHideOwnerDrawWindowsHdl, void* );
 
 
-    SAL_DLLPRIVATE static void          ImplInitAppFontData( Window* pWindow );
-
     SAL_DLLPRIVATE Window*              ImplGetFrameWindow() const;
     SalFrame*                           ImplGetFrame() const;
     SAL_DLLPRIVATE ImplFrameData*       ImplGetFrameData();
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 607702d..ac24717 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -318,12 +318,12 @@ void Application::Abort( const OUString& rErrorText )
     SalAbort( rErrorText, dumpCore );
 }
 
-sal_uLong   Application::GetReservedKeyCodeCount()
+sal_uLong Application::GetReservedKeyCodeCount()
 {
     return ImplReservedKeys::get()->second;
 }
 
-const KeyCode*  Application::GetReservedKeyCode( sal_uLong i )
+const KeyCode* Application::GetReservedKeyCode( sal_uLong i )
 {
     if( i >= GetReservedKeyCodeCount() )
         return NULL;
@@ -549,7 +549,7 @@ void Application::SetSettings( const AllSettings& rSettings )
             {
                 nOldDPIX = pFirstFrame->mnDPIX;
                 nOldDPIY = pFirstFrame->mnDPIY;
-                Window::ImplInitAppFontData(pFirstFrame);
+                InitAppFontData();
             }
             Window* pFrame = pFirstFrame;
             while ( pFrame )
@@ -1664,4 +1664,52 @@ Application::createFolderPicker( const Reference< uno::XComponentContext >& xSM
     return pSVData->mpDefInst->createFolderPicker( xSM );
 }
 
+void Application::InitAppFontData()
+{
+    ImplSVData* pSVData = ImplGetSVData();
+
+    Window *pWindow = pSVData->mpDefaultWin;
+
+    long nTextHeight = pWindow->GetTextHeight();
+    long nTextWidth = pWindow->approximate_char_width() * 8;
+    long nSymHeight = nTextHeight*4;
+    // Make the basis wider if the font is too narrow
+    // such that the dialog looks symmetrical and does not become too narrow.
+    // Add some extra space when the dialog has the same width,
+    // as a little more space is better.
+    if ( nSymHeight > nTextWidth )
+        nTextWidth = nSymHeight;
+    else if ( nSymHeight+5 > nTextWidth )
+        nTextWidth = nSymHeight+5;
+    pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
+    pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
+
+    // FIXME: this is currently only on OS X, check with other
+    // platforms
+    if( pSVData->maNWFData.mbNoFocusRects )
+    {
+        // try to find out whether there is a large correction
+        // of control sizes, if yes, make app font scalings larger
+        // so dialog positioning is not completely off
+        ImplControlValue aControlValue;
+        Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
+        Rectangle aBoundingRgn( aCtrlRegion );
+        Rectangle aContentRgn( aCtrlRegion );
+        if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
+                                             CTRL_STATE_ENABLED, aControlValue, OUString(),
+                                             aBoundingRgn, aContentRgn ) )
+        {
+            // comment: the magical +6 is for the extra border in bordered
+            // (which is the standard) edit fields
+            if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
+                pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
+        }
+    }
+
+    pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
+    if ( pSVData->maAppData.mnDialogScaleX )
+        pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 117429d..55b0c23a 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -223,17 +223,6 @@ static void ImplCalcMapResolution( const MapMode& rMapMode,
         case MAP_APPFONT:
             {
             ImplSVData* pSVData = ImplGetSVData();
-            if ( !pSVData->maGDIData.mnAppFontX )
-            {
-                if( pSVData->maWinData.mpFirstFrame )
-                    Window::ImplInitAppFontData( pSVData->maWinData.mpFirstFrame );
-                else
-                {
-                    WorkWindow* pWin = new WorkWindow( NULL, 0 );
-                    Window::ImplInitAppFontData( pWin );
-                    delete pWin;
-                }
-            }
             rMapRes.mnMapScNumX   = pSVData->maGDIData.mnAppFontX;
             rMapRes.mnMapScDenomX = nDPIX * 40;
             rMapRes.mnMapScNumY   = pSVData->maGDIData.mnAppFontY;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index d329a92..ed5e018 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -533,50 +533,6 @@ bool Window::HasMirroredGraphics() const
     return pOutDev->OutputDevice::HasMirroredGraphics();
 }
 
-void Window::ImplInitAppFontData( Window* pWindow )
-{
-    ImplSVData* pSVData = ImplGetSVData();
-    long nTextHeight = pWindow->GetTextHeight();
-    long nTextWidth = pWindow->approximate_char_width() * 8;
-    long nSymHeight = nTextHeight*4;
-    // Make the basis wider if the font is too narrow
-    // such that the dialog looks symmetrical and does not become too narrow.
-    // Add some extra space when the dialog has the same width,
-    // as a little more space is better.
-    if ( nSymHeight > nTextWidth )
-        nTextWidth = nSymHeight;
-    else if ( nSymHeight+5 > nTextWidth )
-        nTextWidth = nSymHeight+5;
-    pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
-    pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
-
-    // FIXME: this is currently only on OS X, check with other
-    // platforms
-    if( pSVData->maNWFData.mbNoFocusRects )
-    {
-        // try to find out whether there is a large correction
-        // of control sizes, if yes, make app font scalings larger
-        // so dialog positioning is not completely off
-        ImplControlValue aControlValue;
-        Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
-        Rectangle aBoundingRgn( aCtrlRegion );
-        Rectangle aContentRgn( aCtrlRegion );
-        if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
-                                             CTRL_STATE_ENABLED, aControlValue, OUString(),
-                                             aBoundingRgn, aContentRgn ) )
-        {
-            // comment: the magical +6 is for the extra border in bordered
-            // (which is the standard) edit fields
-            if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
-                pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
-        }
-    }
-
-    pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
-    if ( pSVData->maAppData.mnDialogScaleX )
-        pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
-}
-
 bool Window::ImplCheckUIFont( const Font& rFont )
 {
     if( ImplGetSVData()->maGDIData.mbNativeFontConfig )
@@ -1198,10 +1154,6 @@ void Window::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSyste
 
     ImplUpdatePos();
 
-    // calculate app font res (except for the Intro Window or the default window)
-    if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
-        ImplInitAppFontData( this );
-
     if ( GetAccessibleParentWindow()  && GetParent() != Application::GetDefDialogParent() )
         GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this );
 }
commit ef31acfde05d5fe0706b0e2d24fc19d07cdbcd31
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Tue May 6 22:56:25 2014 +1000

    VCL: Application::SetSettings should not set mnAppFontX to 0
    
    pImplSVData->maGDIData.mnAppFontX is *not* a flag to determine if
    application font dimensions should be reset. The way it currently works
    is:
    
    1. Application::SetSettings() is called to reset Window settings,
    etc.
    
    2. Settings are updated on all windows - but at the same time
    pImplSVData->maGDIData.mnAppFontX is set to zero as a way of indicating
    to the global function ImplCalMapResolution that we need to get the font
    from the first window, or if this isn't available then create a new dummy
    WorkWindow and use this to get the font data, and set the application
    font to this.
    
    This is very odd. What we really should be doing is calling on
    ImplInitAppFontData directly from within SetSettings() instead of making
    ImplCalcMapResolution detect that mnAppFontX is zero and there is a
    valid first frame window.
    
    Ultimately, this was found when I commited f76026a43acc to move
    ImplInitAppFontData from Window to Application. Somehow I entirely missed
    that the font and style dropdowns in writer died, and I also somehow
    a whole bunch of tests failed but I again didn't notice this either. With
    this fix, I should be able to recommit the previous change.
    
    Change-Id: Ib526954962fdc397fb3ddd3c21ae947d939db9e5

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 4c8a254..607702d 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -549,7 +549,7 @@ void Application::SetSettings( const AllSettings& rSettings )
             {
                 nOldDPIX = pFirstFrame->mnDPIX;
                 nOldDPIY = pFirstFrame->mnDPIY;
-                pSVData->maGDIData.mnAppFontX = 0;
+                Window::ImplInitAppFontData(pFirstFrame);
             }
             Window* pFrame = pFirstFrame;
             while ( pFrame )
commit 20144988df7296fb012ff0b01f04d3978888e94d
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Mon May 5 21:30:20 2014 +1000

    Use css alias in svapp.hxx
    
    Change-Id: Ifffcf30f68aa4486e22211d9dfc5ad6d77346a85

diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 6db93f7..a0d71e6 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -23,6 +23,8 @@
 #include <config_features.h>
 
 #include <sal/config.h>
+#include <sal/types.h>
+
 
 #include <cassert>
 #include <stdexcept>
@@ -928,7 +930,7 @@ public:
      @returns UNO reference to an object that implements the css:awt:XDisplayConnection
         interface.
     */
-    static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > GetDisplayConnection();
+    static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection();
 
     /** @deprecated AppEvent is used only in the Desktop class now. However, it is
      intended to notify the application that an event has occured. It was in oldsv.cxx,
@@ -1352,7 +1354,7 @@ public:
 
      @returns UNO reference to VCL toolkit
     */
-    static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > GetVCLToolkit();
+    static css::uno::Reference< css::awt::XToolkit > GetVCLToolkit();
 
     /** Get the application's UNO wrapper object.
 
commit deba6ec88a7035be0d88e5e5bf9a2bc3c78eff9d
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Mon May 5 21:11:48 2014 +1000

    Indent svapp.hxx functions
    
    Change-Id: Ibc7262921173036297c670fda3c68c6d77b9853e

diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 7f330f5..6db93f7 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -348,7 +348,7 @@ public:
 
      @returns true if exited successfully, false if not able to fully exit
     */
-    virtual bool           QueryExit();
+    virtual bool                QueryExit();
 
     /** @name Change Notification Functions
 
@@ -618,7 +618,7 @@ public:
 
      @see IsInExecute, IsInModalMode
     */
-    static bool             IsInMain();
+    static bool                 IsInMain();
 
     /** Queries whether the application is in the event loop
 
@@ -626,7 +626,7 @@ public:
 
      @see IsInMain, IsInModalMode
     */
-    static bool             IsInExecute();
+    static bool                 IsInExecute();
 
     /** Queries whether application has a modal dialog active.
 
@@ -634,7 +634,7 @@ public:
 
      @see IsInMain, IsInExecute
     */
-    static bool             IsInModalMode();
+    static bool                 IsInModalMode();
 
     /** Return how many events are being dispatched.
 
@@ -671,7 +671,7 @@ public:
 
      @returns   true if UI is captured, false if not
      */
-    static bool             IsUICaptured();
+    static bool                 IsUICaptured();
 
     /** @name Settings
 
@@ -828,7 +828,7 @@ public:
 
      @see PostKeyEvent
     */
-    static bool             HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
+    static bool                 HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
 
     /** Send keypress event
 
@@ -894,7 +894,7 @@ public:
 
      @return true if there is a default window and the event could be posted to it successfully.
     */
-    static bool             PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL );
+    static bool                 PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL );
 
     /** Remove user event based on event ID
 
@@ -912,7 +912,7 @@ public:
 
      @return true if the handler was inserted successfully, false if it couldn't be inserted.
     */
-    static bool             InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority );
+    static bool                 InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority );
 
     /** Remove an idle handler from the application.
 
@@ -1165,7 +1165,7 @@ public:
 
      @see RemoveAccel
     */
-    static bool             InsertAccel( Accelerator* pAccel );
+    static bool                 InsertAccel( Accelerator* pAccel );
 
     /** Remove accelerator
 
@@ -1189,7 +1189,7 @@ public:
 
      @see EnableAutoMnemonic
     */
-    static bool             IsAutoMnemonicEnabled();
+    static bool                 IsAutoMnemonicEnabled();
 
     /** Get the number of reserved key codes used by the application.
 
@@ -1250,7 +1250,7 @@ public:
 
      @see EnableAutoHelpId
     */
-    static bool             IsAutoHelpIdEnabled();
+    static bool                 IsAutoHelpIdEnabled();
 
     ///@}
 
@@ -1308,7 +1308,7 @@ public:
 
      @see GetDialogCancelMode, SetDialogCancelMode
     */
-    static bool             IsDialogCancelEnabled();
+    static bool                 IsDialogCancelEnabled();
 
 
     /** Make a dialog box a system window or not.
@@ -1411,7 +1411,7 @@ public:
 
      @see EnableHeadlessMode, IsHeadlessModeRequested
     */
-    static bool             IsHeadlessModeEnabled();
+    static bool                 IsHeadlessModeEnabled();
 
     /** Check command line arguments for \code --headless \endcode
 


More information about the Libreoffice-commits mailing list