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

Chris Sherlock chris.sherlock79 at gmail.com
Sat May 3 23:33:23 PDT 2014


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

New commits:
commit f76026a43acc65465882924796d93e635c35fd90
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sat May 3 23:23:06 2014 +1000

    Move ImplInitAppFontData from Window to Application
    
    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().
    
    Change-Id: I9d98aa5b533166f91352218af267930034648c7a
    Reviewed-on: https://gerrit.libreoffice.org/9242
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>

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..5f4b3bb 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();
+        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 1b8f6e1..ddf5c63 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -265,6 +265,12 @@ public:
     */
     virtual void                Init();
 
+protected:
+    /** Initialize font data for the application.
+     */
+    virtual void                InitAppFontData();
+
+public:
     /** Finish initialization of the application.
 
      @see Init, DeInit
@@ -348,7 +354,7 @@ public:
 
      @returns true if exited successfully, false if not able to fully exit
     */
-    virtual bool           QueryExit();
+    virtual bool                QueryExit();
 
     /** Send user event.
 
@@ -626,7 +632,7 @@ public:
 
      @see IsInExecute, IsInModalMode
     */
-    static bool             IsInMain();
+    static bool                 IsInMain();
 
     /** Queries whether the application is in the event loop
 
@@ -634,7 +640,7 @@ public:
 
      @see IsInMain, IsInModalMode
     */
-    static bool             IsInExecute();
+    static bool                 IsInExecute();
 
     /** Queries whether application has a modal dialog active.
 
@@ -642,7 +648,7 @@ public:
 
      @see IsInMain, IsInExecute
     */
-    static bool             IsInModalMode();
+    static bool                 IsInModalMode();
 
     /** Return how many events are being dispatched.
 
@@ -679,7 +685,7 @@ public:
 
      @returns   true if UI is captured, false if not
      */
-    static bool             IsUICaptured();
+    static bool                 IsUICaptured();
 
     /** @name Settings
 
@@ -836,7 +842,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
 
@@ -902,7 +908,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
 
@@ -920,7 +926,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.
 
@@ -1173,7 +1179,7 @@ public:
 
      @see RemoveAccel
     */
-    static bool             InsertAccel( Accelerator* pAccel );
+    static bool                 InsertAccel( Accelerator* pAccel );
 
     /** Remove accelerator
 
@@ -1197,7 +1203,7 @@ public:
 
      @see EnableAutoMnemonic
     */
-    static bool             IsAutoMnemonicEnabled();
+    static bool                 IsAutoMnemonicEnabled();
 
     /** Get the number of reserved key codes used by the application.
 
@@ -1258,7 +1264,7 @@ public:
 
      @see EnableAutoHelpId
     */
-    static bool             IsAutoHelpIdEnabled();
+    static bool                 IsAutoHelpIdEnabled();
 
     ///@}
 
@@ -1316,7 +1322,7 @@ public:
 
      @see GetDialogCancelMode, SetDialogCancelMode
     */
-    static bool             IsDialogCancelEnabled();
+    static bool                 IsDialogCancelEnabled();
 
 
     /** Make a dialog box a system window or not.
@@ -1419,7 +1425,7 @@ public:
 
      @see EnableHeadlessMode, IsHeadlessModeRequested
     */
-    static bool             IsHeadlessModeEnabled();
+    static bool                 IsHeadlessModeEnabled();
 
     /** Check command line arguments for \code --headless \endcode
 
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 001dfd5..9aa9a74 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 dd21319..0185558 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -322,12 +322,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;
@@ -1669,4 +1669,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 2747c45..d1bc349 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 );
 }


More information about the Libreoffice-commits mailing list