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

Miklos Vajna vmiklos at collabora.co.uk
Mon May 5 03:28:36 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, 76 insertions(+), 71 deletions(-)

New commits:
commit b4107411900f5bb4c215e2d9db09fc2b2b82939b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon May 5 11:54:16 2014 +0200

    Revert "Move ImplInitAppFontData from Window to Application"
    
    This reverts commit f76026a43acc65465882924796d93e635c35fd90. This
    brings back the paragraph style and font name combo boxes in Writer.
    
    Change-Id: Idb28253797ef842d575fe10537f6e70faa34fe75

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