summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2014-05-06 23:49:29 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2014-05-07 09:29:00 +1000
commit081a0854635f4bc9f6f743ef4e2675c208405f74 (patch)
treedaea106c0ccac23c7a1b856dc754948438b71db2
parentef31acfde05d5fe0706b0e2d24fc19d07cdbcd31 (diff)
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
-rw-r--r--desktop/inc/app.hxx1
-rw-r--r--desktop/source/app/app.cxx1
-rw-r--r--include/vcl/svapp.hxx6
-rw-r--r--include/vcl/window.hxx2
-rw-r--r--vcl/source/app/svapp.cxx54
-rw-r--r--vcl/source/outdev/map.cxx11
-rw-r--r--vcl/source/window/window.cxx48
7 files changed, 59 insertions, 64 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 67fc3fbd27a1..8b8affe06a04 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 377afc7f85c2..247ac1df6ef8 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 a0d71e6ce0ce..b7e00ca17c2e 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 5dc734037f27..64d47324c60b 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 607702d1a0d2..ac24717c4680 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 117429dd6364..55b0c23adf45 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 d329a920742e..ed5e01814182 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 );
}