diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2017-01-23 22:01:37 -0500 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2017-01-26 01:50:46 +0000 |
commit | b41186a2fc49e440890b8c86e5367352ffaf9cd6 (patch) | |
tree | 40b9fc8fd800b355c180d37cb86f058d697c4060 /editeng/source | |
parent | 326729ce54de5296cb2a673ae88d2befa3e245ef (diff) |
tdf#103927: Share single standard VirtualDevice instance.
To avoid creating excessive amounts of VirtualDevice instances. Also,
since we now have VclPtr, we shouldn't need this bOwnerOfRefDev flag.
Change-Id: I97a6f553a178b32bc173b83a6716185d126f97e1
Reviewed-on: https://gerrit.libreoffice.org/33508
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/editeng/eerdll.cxx | 12 | ||||
-rw-r--r-- | editeng/source/editeng/eerdll2.hxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 1 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 29 |
4 files changed, 21 insertions, 25 deletions
diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx index 558c475acaa6..94f97607d18c 100644 --- a/editeng/source/editeng/eerdll.cxx +++ b/editeng/source/editeng/eerdll.cxx @@ -70,6 +70,7 @@ #include <editeng/forbiddencharacterstable.hxx> #include <editeng/justifyitem.hxx> #include <rtl/instance.hxx> +#include <tools/mapunit.hxx> using namespace ::com::sun::star; @@ -83,9 +84,11 @@ EditDLL& EditDLL::Get() return theEditDLL::get(); } -GlobalEditData::GlobalEditData() +GlobalEditData::GlobalEditData() : + ppDefItems(nullptr), + mpVirDev(VclPtr<VirtualDevice>::Create()) { - ppDefItems = nullptr; + mpVirDev->SetMapMode(MapUnit::MapTwip); } GlobalEditData::~GlobalEditData() @@ -194,6 +197,11 @@ uno::Reference< linguistic2::XLanguageGuessing > const & GlobalEditData::GetLang return xLanguageGuesser; } +VclPtr<VirtualDevice> GlobalEditData::GetStdVirtualDevice() +{ + return mpVirDev; +} + EditResId::EditResId(sal_uInt16 nId) : ResId(nId, *EditDLL::GetResMgr()) { diff --git a/editeng/source/editeng/eerdll2.hxx b/editeng/source/editeng/eerdll2.hxx index 136b9cd3fd3d..32c7c40bbd68 100644 --- a/editeng/source/editeng/eerdll2.hxx +++ b/editeng/source/editeng/eerdll2.hxx @@ -25,6 +25,7 @@ #include <rtl/ref.hxx> class SfxPoolItem; +class VirtualDevice; class GlobalEditData { @@ -33,6 +34,7 @@ private: std::vector<SfxPoolItem*>* ppDefItems; rtl::Reference<SvxForbiddenCharactersTable> xForbiddenCharsTable; + VclPtr<VirtualDevice> mpVirDev; public: GlobalEditData(); @@ -43,6 +45,8 @@ public: rtl::Reference<SvxForbiddenCharactersTable> const & GetForbiddenCharsTable(); void SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> const & xForbiddenChars ) { xForbiddenCharsTable = xForbiddenChars; } css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetLanguageGuesser(); + + VclPtr<VirtualDevice> GetStdVirtualDevice(); }; #endif // INCLUDED_EDITENG_SOURCE_EDITENG_EERDLL2_HXX diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 1b585f7bbfe7..74a55ce39032 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -513,7 +513,6 @@ private: bool bIsInUndo:1; bool bUpdate:1; bool bUndoEnabled:1; - bool bOwnerOfRefDev:1; bool bDowning:1; bool bUseAutoColor:1; bool bForceAutoColor:1; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 0d89b4344669..1c56dfbaf18e 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -95,7 +95,6 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : bIsInUndo(false), bUpdate(true), bUndoEnabled(true), - bOwnerOfRefDev(false), bDowning(false), bUseAutoColor(true), bForceAutoColor(false), @@ -184,26 +183,15 @@ ImpEditEngine::~ImpEditEngine() delete mpIMEInfos; delete pColorConfig; delete pCTLOptions; - if ( bOwnerOfRefDev ) - pRefDev.disposeAndClear(); delete pSpellInfo; } void ImpEditEngine::SetRefDevice( OutputDevice* pRef ) { - if ( bOwnerOfRefDev ) - pRefDev.disposeAndClear(); - - if ( !pRef ) - { - pRefDev = VclPtr<VirtualDevice>::Create(); - pRefDev->SetMapMode( MapUnit::MapTwip ); - bOwnerOfRefDev = true; - } else - { + if (pRef) pRefDev = pRef; - bOwnerOfRefDev = false; - } + else + pRefDev = EditDLL::Get().GetGlobalData()->GetStdVirtualDevice(); nOnePixelInRef = (sal_uInt16)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width(); @@ -219,13 +207,10 @@ void ImpEditEngine::SetRefMapMode( const MapMode& rMapMode ) if ( GetRefDevice()->GetMapMode() == rMapMode ) return; - if ( !bOwnerOfRefDev ) - { - pRefDev = VclPtr<VirtualDevice>::Create(); - pRefDev->SetMapMode( MapUnit::MapTwip ); - SetRefDevice( pRefDev ); - bOwnerOfRefDev = true; - } + pRefDev = VclPtr<VirtualDevice>::Create(); + pRefDev->SetMapMode( MapUnit::MapTwip ); + SetRefDevice( pRefDev ); + pRefDev->SetMapMode( rMapMode ); nOnePixelInRef = (sal_uInt16)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width(); if ( IsFormatted() ) |