summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2017-01-23 22:01:37 -0500
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-02-01 13:29:27 +0000
commit48168ced891de8e4eca6fd1eb490c452534fccd2 (patch)
treea12855c0d2d5606d80c1ef8724e97f5f1ee35413
parentfe2260df51f543292bd5db54aab7db5d76a3fbbe (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. This fixes tdf#102688 as well as other GDI-Limit related issues. See tdf#105469 for other bugs this may fix. (cherry picked from commit b41186a2fc49e440890b8c86e5367352ffaf9cd6) (cherry picked from commit fab2f546d1fb3ceaf5ee5d4d728f1728a8f1e7f3) (cherry picked from commit bac2baa785ffc75160de2d15da60901152da33de) Change-Id: Ieda242786c6376c7ac249a9f6d469b670f1ac177 Reviewed-on: https://gerrit.libreoffice.org/33640 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--editeng/source/editeng/eerdll.cxx12
-rw-r--r--editeng/source/editeng/eerdll2.hxx4
-rw-r--r--editeng/source/editeng/impedit.hxx2
-rw-r--r--editeng/source/editeng/impedit2.cxx32
4 files changed, 25 insertions, 25 deletions
diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx
index f1bf58cd07c1..b9aa26dcc9f4 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()
@@ -193,6 +196,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 ffb96fe0aa19..615783b05990 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:
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 b76fa58b749b..291a95ad572a 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -421,6 +421,7 @@ private:
VclPtr< VirtualDevice> pVirtDev;
VclPtr< OutputDevice > pRefDev;
+ VclPtr<VirtualDevice> mpOwnDev;
svtools::ColorConfig* pColorConfig;
mutable SvtCTLOptions* pCTLOptions;
@@ -506,7 +507,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 a879060b0b28..579e29db3565 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),
@@ -174,6 +173,7 @@ ImpEditEngine::~ImpEditEngine()
bDowning = true;
SetUpdateMode( false );
+ mpOwnDev.disposeAndClear();
pVirtDev.disposeAndClear();
delete pEmptyItemSet;
delete pUndoManager;
@@ -181,26 +181,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();
@@ -216,13 +205,12 @@ 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;
- }
+ mpOwnDev.disposeAndClear();
+ mpOwnDev = VclPtr<VirtualDevice>::Create();
+ pRefDev = mpOwnDev;
+ pRefDev->SetMapMode( MapUnit::MapTwip );
+ SetRefDevice( pRefDev );
+
pRefDev->SetMapMode( rMapMode );
nOnePixelInRef = (sal_uInt16)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width();
if ( IsFormatted() )