summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-04-28 11:41:31 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-04-28 15:08:48 +0100
commite8b97a52c96df9c8e8055407b1e40ed7cb9cfc67 (patch)
treeb322529f4a54a6427862cb20cb4cf87fb6a5d065 /vcl/source
parent2b0be6c0e9d23f1b8535ba7033732ae2e3bfb5c9 (diff)
parent0cde74f788a054fa2b65107a030dd463b8d11c7a (diff)
Merge remote-tracking branch 'origin/feature/vclptr'
Resolve several thousand lines of conflicts. Conflicts: accessibility/source/extended/accessiblelistbox.cxx accessibility/source/standard/vclxaccessiblecombobox.cxx accessibility/source/standard/vclxaccessibledropdowncombobox.cxx accessibility/source/standard/vclxaccessibledropdownlistbox.cxx accessibility/source/standard/vclxaccessiblelistbox.cxx accessibility/source/standard/vclxaccessibletextfield.cxx basctl/source/basicide/basidesh.cxx cui/source/inc/chardlg.hxx cui/source/tabpages/tpbitmap.cxx dbaccess/source/ui/dlg/UserAdmin.cxx dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx extensions/source/propctrlr/propertyeditor.hxx extensions/source/scanner/sanedlg.cxx filter/source/pdf/impdialog.cxx include/sfx2/mgetempl.hxx include/sfx2/sidebar/SidebarToolBox.hxx include/sfx2/viewsh.hxx include/svtools/brwbox.hxx include/svtools/filectrl.hxx include/svtools/scrwin.hxx include/svx/dlgctrl.hxx include/svx/sidebar/Popup.hxx include/svx/sidebar/PopupContainer.hxx include/svx/sidebar/PopupControl.hxx include/svx/sidebar/SidebarDialControl.hxx include/svx/sidebar/ValueSetWithTextControl.hxx sc/source/ui/condformat/condformatdlgentry.cxx sc/source/ui/navipi/navipi.cxx sc/source/ui/sidebar/CellBorderStyleControl.hxx sd/source/ui/animations/CustomAnimationDialog.cxx sd/source/ui/inc/DrawViewShell.hxx sd/source/ui/inc/Ruler.hxx sd/source/ui/inc/SlideSorter.hxx sd/source/ui/inc/ViewTabBar.hxx sd/source/ui/inc/Window.hxx sd/source/ui/inc/morphdlg.hxx sd/source/ui/inc/sdpreslt.hxx sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx sd/source/ui/sidebar/LayoutMenu.hxx sd/source/ui/sidebar/MasterPagesSelector.hxx sd/source/ui/sidebar/NavigatorWrapper.hxx sd/source/ui/sidebar/PanelBase.hxx sd/source/ui/sidebar/RecentMasterPagesSelector.cxx sd/source/ui/sidebar/RecentMasterPagesSelector.hxx sd/source/ui/slideshow/showwindow.hxx sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx sd/source/ui/view/ViewShellBase.cxx sd/source/ui/view/drviewsa.cxx sfx2/source/appl/fileobj.hxx sfx2/source/appl/opengrf.cxx sfx2/source/control/thumbnailviewacc.hxx sfx2/source/dialog/securitypage.cxx sfx2/source/dialog/templdlg.cxx sfx2/source/doc/docinsert.cxx sfx2/source/doc/guisaveas.cxx sfx2/source/inc/alienwarn.hxx sfx2/source/sidebar/Deck.cxx sfx2/source/sidebar/Deck.hxx sfx2/source/sidebar/DeckTitleBar.cxx sfx2/source/sidebar/DeckTitleBar.hxx sfx2/source/sidebar/MenuButton.cxx sfx2/source/sidebar/MenuButton.hxx sfx2/source/sidebar/Panel.cxx sfx2/source/sidebar/Panel.hxx sfx2/source/sidebar/PanelTitleBar.hxx sfx2/source/sidebar/SidebarDockingWindow.hxx sfx2/source/sidebar/SidebarToolBox.cxx sfx2/source/sidebar/TabBar.hxx sfx2/source/sidebar/TabItem.cxx sfx2/source/sidebar/TabItem.hxx sfx2/source/sidebar/TitleBar.hxx sfx2/source/toolbox/imgmgr.cxx starmath/inc/edit.hxx starmath/inc/smmod.hxx starmath/qa/cppunit/test_starmath.cxx starmath/source/edit.cxx starmath/source/smmod.cxx svtools/source/brwbox/brwbox1.cxx svtools/source/brwbox/datwin.hxx svtools/source/contnr/fileview.cxx svtools/source/contnr/simptabl.cxx svtools/source/control/filectrl.cxx svtools/source/control/valueimp.hxx svx/inc/GalleryControl.hxx svx/source/dialog/dlgctrl.cxx svx/source/dialog/swframeexample.cxx svx/source/fmcomp/fmgridif.cxx svx/source/gallery2/GalleryControl.cxx svx/source/sidebar/EmptyPanel.hxx svx/source/sidebar/area/AreaPropertyPanel.hxx svx/source/sidebar/area/AreaTransparencyGradientControl.hxx svx/source/sidebar/graphic/GraphicPropertyPanel.hxx svx/source/sidebar/insert/InsertPropertyPanel.cxx svx/source/sidebar/insert/InsertPropertyPanel.hxx svx/source/sidebar/line/LinePropertyPanel.hxx svx/source/sidebar/line/LineWidthControl.cxx svx/source/sidebar/line/LineWidthControl.hxx svx/source/sidebar/line/LineWidthValueSet.hxx svx/source/sidebar/paragraph/ParaPropertyPanel.hxx svx/source/sidebar/possize/SidebarDialControl.cxx svx/source/sidebar/text/TextCharacterSpacingPopup.hxx svx/source/sidebar/text/TextPropertyPanel.hxx svx/source/sidebar/tools/PopupContainer.cxx svx/source/sidebar/tools/PopupControl.cxx svx/source/sidebar/tools/ValueSetWithTextControl.cxx svx/source/svdraw/svdfmtf.hxx svx/source/svdraw/svdibrow.cxx svx/source/tbxctrls/colrctrl.cxx svx/source/tbxctrls/tbcontrl.cxx sw/source/ui/dbui/mmaddressblockpage.cxx sw/source/ui/dialog/uiregionsw.cxx sw/source/ui/index/cnttab.cxx sw/source/uibase/inc/drpcps.hxx sw/source/uibase/sidebar/PageColumnControl.hxx sw/source/uibase/sidebar/PageMarginControl.hxx sw/source/uibase/sidebar/PageOrientationControl.hxx sw/source/uibase/sidebar/PagePropertyPanel.hxx sw/source/uibase/sidebar/PageSizeControl.hxx sw/source/uibase/uiview/view2.cxx sw/source/uibase/utlui/navipi.cxx vcl/inc/svdata.hxx vcl/source/control/combobox.cxx vcl/source/control/lstbox.cxx vcl/source/window/dockwin.cxx vcl/source/window/winproc.cxx Change-Id: I056cf3026ff17d65cca0b6e6588bda4a88fa8d95
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/dbggui.cxx163
-rw-r--r--vcl/source/app/help.cxx20
-rw-r--r--vcl/source/app/salvtables.cxx9
-rw-r--r--vcl/source/app/stdtext.cxx4
-rw-r--r--vcl/source/app/svapp.cxx39
-rw-r--r--vcl/source/app/svdata.cxx18
-rw-r--r--vcl/source/app/svmain.cxx6
-rw-r--r--vcl/source/app/vclevent.cxx9
-rw-r--r--vcl/source/control/button.cxx64
-rw-r--r--vcl/source/control/combobox.cxx84
-rw-r--r--vcl/source/control/ctrl.cxx18
-rw-r--r--vcl/source/control/edit.cxx26
-rw-r--r--vcl/source/control/field.cxx24
-rw-r--r--vcl/source/control/field2.cxx24
-rw-r--r--vcl/source/control/fixed.cxx15
-rw-r--r--vcl/source/control/fixedhyper.cxx4
-rw-r--r--vcl/source/control/ilstbox.cxx113
-rw-r--r--vcl/source/control/longcurr.cxx8
-rw-r--r--vcl/source/control/lstbox.cxx96
-rw-r--r--vcl/source/control/menubtn.cxx6
-rw-r--r--vcl/source/control/morebtn.cxx8
-rw-r--r--vcl/source/control/prgsbar.cxx4
-rw-r--r--vcl/source/control/scrbar.cxx8
-rw-r--r--vcl/source/control/spinbtn.cxx4
-rw-r--r--vcl/source/control/spinfld.cxx15
-rw-r--r--vcl/source/control/tabctrl.cxx38
-rw-r--r--vcl/source/control/throbber.cxx6
-rw-r--r--vcl/source/edit/texteng.cxx2
-rw-r--r--vcl/source/edit/textview.cxx9
-rw-r--r--vcl/source/edit/vclmedit.cxx64
-rw-r--r--vcl/source/filter/graphicfilter.cxx16
-rw-r--r--vcl/source/filter/sgfbram.cxx14
-rw-r--r--vcl/source/filter/sgvmain.cxx4
-rw-r--r--vcl/source/filter/sgvtext.cxx16
-rw-r--r--vcl/source/filter/wmf/emfwr.cxx114
-rw-r--r--vcl/source/filter/wmf/emfwr.hxx5
-rw-r--r--vcl/source/filter/wmf/winmtf.cxx43
-rw-r--r--vcl/source/filter/wmf/wmfwr.cxx2
-rw-r--r--vcl/source/filter/wmf/wmfwr.hxx2
-rw-r--r--vcl/source/gdi/animate.cxx6
-rw-r--r--vcl/source/gdi/bitmapex.cxx14
-rw-r--r--vcl/source/gdi/cvtsvm.cxx26
-rw-r--r--vcl/source/gdi/gdimetafiletools.cxx20
-rw-r--r--vcl/source/gdi/gdimtf.cxx180
-rw-r--r--vcl/source/gdi/impanmvw.cxx22
-rw-r--r--vcl/source/gdi/impanmvw.hxx6
-rw-r--r--vcl/source/gdi/impgraph.cxx16
-rw-r--r--vcl/source/gdi/impvect.cxx4
-rw-r--r--vcl/source/gdi/oldprintadaptor.cxx6
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx16
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx2
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx6
-rw-r--r--vcl/source/gdi/print.cxx19
-rw-r--r--vcl/source/gdi/print2.cxx94
-rw-r--r--vcl/source/gdi/print3.cxx37
-rw-r--r--vcl/source/gdi/virdev.cxx13
-rw-r--r--vcl/source/helper/lazydelete.cxx13
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx13
-rw-r--r--vcl/source/outdev/bitmap.cxx10
-rw-r--r--vcl/source/outdev/font.cxx5
-rw-r--r--vcl/source/outdev/map.cxx6
-rw-r--r--vcl/source/outdev/outdev.cxx31
-rw-r--r--vcl/source/outdev/outdevstate.cxx1
-rw-r--r--vcl/source/outdev/text.cxx58
-rw-r--r--vcl/source/outdev/transparent.cxx16
-rw-r--r--vcl/source/outdev/wallpaper.cxx10
-rw-r--r--vcl/source/uipreviewer/previewer.cxx5
-rw-r--r--vcl/source/window/accel.cxx1
-rw-r--r--vcl/source/window/accessibility.cxx7
-rw-r--r--vcl/source/window/brdwin.cxx18
-rw-r--r--vcl/source/window/btndlg.cxx40
-rw-r--r--vcl/source/window/builder.cxx78
-rw-r--r--vcl/source/window/clipping.cxx10
-rw-r--r--vcl/source/window/cursor.cxx4
-rw-r--r--vcl/source/window/decoview.cxx2
-rw-r--r--vcl/source/window/dialog.cxx51
-rw-r--r--vcl/source/window/dlgctrl.cxx20
-rw-r--r--vcl/source/window/dndevdis.cxx6
-rw-r--r--vcl/source/window/dockingarea.cxx6
-rw-r--r--vcl/source/window/dockmgr.cxx43
-rw-r--r--vcl/source/window/dockwin.cxx43
-rw-r--r--vcl/source/window/event.cxx28
-rw-r--r--vcl/source/window/floatwin.cxx40
-rw-r--r--vcl/source/window/introwin.cxx11
-rw-r--r--vcl/source/window/layout.cxx136
-rw-r--r--vcl/source/window/menu.cxx29
-rw-r--r--vcl/source/window/menubarwindow.cxx135
-rw-r--r--vcl/source/window/menubarwindow.hxx28
-rw-r--r--vcl/source/window/menufloatingwindow.cxx11
-rw-r--r--vcl/source/window/menufloatingwindow.hxx3
-rw-r--r--vcl/source/window/mouse.cxx28
-rw-r--r--vcl/source/window/msgbox.cxx29
-rw-r--r--vcl/source/window/openglwin.cxx14
-rw-r--r--vcl/source/window/paint.cxx6
-rw-r--r--vcl/source/window/popupmenuwindow.cxx6
-rw-r--r--vcl/source/window/printdlg.cxx137
-rw-r--r--vcl/source/window/scrwnd.cxx8
-rw-r--r--vcl/source/window/scrwnd.hxx3
-rw-r--r--vcl/source/window/settings.cxx8
-rw-r--r--vcl/source/window/split.cxx15
-rw-r--r--vcl/source/window/splitwin.cxx15
-rw-r--r--vcl/source/window/stacking.cxx45
-rw-r--r--vcl/source/window/status.cxx12
-rw-r--r--vcl/source/window/syschild.cxx8
-rw-r--r--vcl/source/window/syswin.cxx35
-rw-r--r--vcl/source/window/tabdlg.cxx11
-rw-r--r--vcl/source/window/tabpage.cxx11
-rw-r--r--vcl/source/window/taskpanelist.cxx19
-rw-r--r--vcl/source/window/toolbox.cxx34
-rw-r--r--vcl/source/window/toolbox2.cxx18
-rw-r--r--vcl/source/window/window.cxx178
-rw-r--r--vcl/source/window/window2.cxx116
-rw-r--r--vcl/source/window/winproc.cxx17
-rw-r--r--vcl/source/window/wrkwin.cxx8
114 files changed, 1923 insertions, 1387 deletions
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx
index 1c643f241176..e8d27ae769eb 100644
--- a/vcl/source/app/dbggui.cxx
+++ b/vcl/source/app/dbggui.cxx
@@ -207,98 +207,104 @@ NULL
class DbgInfoDialog : public ModalDialog
{
private:
- ListBox maListBox;
- OKButton maOKButton;
- bool mbHelpText;
+ VclPtr<ListBox> maListBox;
+ VclPtr<OKButton> maOKButton;
+ bool mbHelpText;
public:
DbgInfoDialog( vcl::Window* pParent, bool bHelpText = false );
void SetInfoText( const OUString& rStr );
+private:
+ virtual void dispose() SAL_OVERRIDE;
+ virtual ~DbgInfoDialog() { disposeOnce(); }
};
class DbgDialog : public ModalDialog
{
private:
- CheckBox maRes;
- CheckBox maDialog;
- CheckBox maBoldAppFont;
- GroupBox maBox3;
+ VclPtr<CheckBox> maRes;
+ VclPtr<CheckBox> maDialog;
+ VclPtr<CheckBox> maBoldAppFont;
+ VclPtr<GroupBox> maBox3;
- OKButton maOKButton;
- CancelButton maCancelButton;
- HelpButton maHelpButton;
+ VclPtr<OKButton> maOKButton;
+ VclPtr<CancelButton> maCancelButton;
+ VclPtr<HelpButton> maHelpButton;
public:
DbgDialog();
DECL_LINK( ClickHdl, Button* );
void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
+private:
+ virtual void dispose() SAL_OVERRIDE;
+ virtual ~DbgDialog() { disposeOnce(); }
};
DbgDialog::DbgDialog() :
ModalDialog( NULL, WB_STDMODAL | WB_SYSTEMWINDOW ),
- maRes( this ),
- maDialog( this ),
- maBoldAppFont( this ),
- maBox3( this ),
- maOKButton( this, WB_DEFBUTTON ),
- maCancelButton( this ),
- maHelpButton( this )
+ maRes(VclPtr<CheckBox>::Create(this)),
+ maDialog(VclPtr<CheckBox>::Create(this)),
+ maBoldAppFont(VclPtr<CheckBox>::Create(this)),
+ maBox3(VclPtr<GroupBox>::Create(this)),
+ maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON)),
+ maCancelButton(VclPtr<CancelButton>::Create(this)),
+ maHelpButton(VclPtr<HelpButton>::Create(this))
{
DbgData* pData = DbgGetData();
MapMode aAppMap( MAP_APPFONT );
Size aButtonSize = LogicToPixel( Size( 60, 12 ), aAppMap );
{
- maRes.Show();
- maRes.SetText("~Resourcen");
+ maRes->Show();
+ maRes->SetText("~Resourcen");
if ( pData->nTestFlags & DBG_TEST_RESOURCE )
- maRes.Check( true );
- maRes.SetPosSizePixel( LogicToPixel( Point( 75, 95 ), aAppMap ),
+ maRes->Check( true );
+ maRes->SetPosSizePixel( LogicToPixel( Point( 75, 95 ), aAppMap ),
aButtonSize );
}
{
- maDialog.Show();
- maDialog.SetText("~Dialog");
+ maDialog->Show();
+ maDialog->SetText("~Dialog");
if ( pData->nTestFlags & DBG_TEST_DIALOG )
- maDialog.Check( true );
- maDialog.SetPosSizePixel( LogicToPixel( Point( 140, 95 ), aAppMap ),
+ maDialog->Check( true );
+ maDialog->SetPosSizePixel( LogicToPixel( Point( 140, 95 ), aAppMap ),
aButtonSize );
}
{
- maBoldAppFont.Show();
- maBoldAppFont.SetText("~Bold AppFont");
+ maBoldAppFont->Show();
+ maBoldAppFont->SetText("~Bold AppFont");
if ( pData->nTestFlags & DBG_TEST_BOLDAPPFONT )
- maBoldAppFont.Check( true );
- maBoldAppFont.SetPosSizePixel( LogicToPixel( Point( 205, 95 ), aAppMap ),
+ maBoldAppFont->Check( true );
+ maBoldAppFont->SetPosSizePixel( LogicToPixel( Point( 205, 95 ), aAppMap ),
aButtonSize );
- maBoldAppFont.SaveValue();
+ maBoldAppFont->SaveValue();
}
{
- maBox3.Show();
- maBox3.SetText("Test Options");
- maBox3.SetPosSizePixel( LogicToPixel( Point( 5, 85 ), aAppMap ),
+ maBox3->Show();
+ maBox3->SetText("Test Options");
+ maBox3->SetPosSizePixel( LogicToPixel( Point( 5, 85 ), aAppMap ),
LogicToPixel( Size( 330, 30 ), aAppMap ) );
}
{
- maOKButton.Show();
- maOKButton.SetClickHdl( LINK( this, DbgDialog, ClickHdl ) );
- maOKButton.SetPosSizePixel( LogicToPixel( Point( 10, 260 ), aAppMap ),
+ maOKButton->Show();
+ maOKButton->SetClickHdl( LINK( this, DbgDialog, ClickHdl ) );
+ maOKButton->SetPosSizePixel( LogicToPixel( Point( 10, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
{
- maCancelButton.Show();
- maCancelButton.SetPosSizePixel( LogicToPixel( Point( 70, 260 ), aAppMap ),
+ maCancelButton->Show();
+ maCancelButton->SetPosSizePixel( LogicToPixel( Point( 70, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
{
- maHelpButton.Show();
- maHelpButton.SetPosSizePixel( LogicToPixel( Point( 190, 260 ), aAppMap ),
+ maHelpButton->Show();
+ maHelpButton->SetPosSizePixel( LogicToPixel( Point( 190, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
@@ -310,20 +316,20 @@ DbgDialog::DbgDialog() :
IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton )
{
- if ( pButton == &maOKButton )
+ if ( pButton == maOKButton )
{
DbgData aData;
memcpy( &aData, DbgGetData(), sizeof( DbgData ) );
aData.nTestFlags = 0;
- if ( maRes.IsChecked() )
+ if ( maRes->IsChecked() )
aData.nTestFlags |= DBG_TEST_RESOURCE;
- if ( maDialog.IsChecked() )
+ if ( maDialog->IsChecked() )
aData.nTestFlags |= DBG_TEST_DIALOG;
- if ( maBoldAppFont.IsChecked() )
+ if ( maBoldAppFont->IsChecked() )
aData.nTestFlags |= DBG_TEST_BOLDAPPFONT;
// Daten speichern
@@ -333,12 +339,12 @@ IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton )
#define IMMEDIATE_FLAGS (DBG_TEST_RESOURCE | DBG_TEST_DIALOG | DBG_TEST_BOLDAPPFONT)
pData->nTestFlags &= ~IMMEDIATE_FLAGS;
pData->nTestFlags |= aData.nTestFlags & IMMEDIATE_FLAGS;
- if ( maBoldAppFont.IsValueChangedFromSaved() )
+ if ( maBoldAppFont->IsValueChangedFromSaved() )
{
AllSettings aSettings = Application::GetSettings();
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
vcl::Font aFont = aStyleSettings.GetAppFont();
- if ( maBoldAppFont.IsChecked() )
+ if ( maBoldAppFont->IsChecked() )
aFont.SetWeight( WEIGHT_BOLD );
else
aFont.SetWeight( WEIGHT_NORMAL );
@@ -348,10 +354,10 @@ IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton )
}
if( (aData.nTestFlags & ~IMMEDIATE_FLAGS) != (pData->nTestFlags & ~IMMEDIATE_FLAGS) )
{
- MessageDialog aBox(this, OUString(
+ ScopedVclPtrInstance<MessageDialog> aBox(this, OUString(
"Some of the changed settings will only be active after "
"restarting the process"), VCL_MESSAGE_INFO);
- aBox.Execute();
+ aBox->Execute();
}
EndDialog( RET_OK );
}
@@ -363,7 +369,7 @@ void DbgDialog::RequestHelp( const HelpEvent& rHEvt )
{
if ( rHEvt.GetMode() & HelpEventMode::CONTEXT )
{
- DbgInfoDialog aInfoDialog( this, true );
+ ScopedVclPtrInstance< DbgInfoDialog > aInfoDialog( this, true );
OUString aHelpText;
const sal_Char** pHelpStrs = pDbgHelpText;
while ( *pHelpStrs )
@@ -371,16 +377,28 @@ void DbgDialog::RequestHelp( const HelpEvent& rHEvt )
aHelpText += OUString::createFromAscii(*pHelpStrs);
pHelpStrs++;
}
- aInfoDialog.SetText( "Debug Hilfe" );
- aInfoDialog.SetInfoText( aHelpText );
- aInfoDialog.Execute();
+ aInfoDialog->SetText( "Debug Hilfe" );
+ aInfoDialog->SetInfoText( aHelpText );
+ aInfoDialog->Execute();
}
}
+void DbgDialog::dispose()
+{
+ maRes.disposeAndClear();
+ maDialog.disposeAndClear();
+ maBoldAppFont.disposeAndClear();
+ maBox3.disposeAndClear();
+ maOKButton.disposeAndClear();
+ maCancelButton.disposeAndClear();
+ maHelpButton.disposeAndClear();
+ ModalDialog::dispose();
+}
+
DbgInfoDialog::DbgInfoDialog( vcl::Window* pParent, bool bHelpText ) :
ModalDialog( pParent, WB_STDMODAL ),
- maListBox( this, WB_BORDER | WB_AUTOHSCROLL ),
- maOKButton( this, WB_DEFBUTTON )
+ maListBox(VclPtr<ListBox>::Create( this, WB_BORDER | WB_AUTOHSCROLL )),
+ maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON))
{
mbHelpText = bHelpText;
@@ -389,21 +407,21 @@ DbgInfoDialog::DbgInfoDialog( vcl::Window* pParent, bool bHelpText ) :
vcl::Font aFont = GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
aFont.SetHeight( 8 );
aFont.SetPitch( PITCH_FIXED );
- maListBox.SetControlFont( aFont );
+ maListBox->SetControlFont( aFont );
}
- maListBox.SetPosSizePixel( Point( 5, 5 ), Size( 630, 380 ) );
- maListBox.Show();
+ maListBox->SetPosSizePixel( Point( 5, 5 ), Size( 630, 380 ) );
+ maListBox->Show();
- maOKButton.SetPosSizePixel( Point( 290, 390 ), Size( 60, 25 ) );
- maOKButton.Show();
+ maOKButton->SetPosSizePixel( Point( 290, 390 ), Size( 60, 25 ) );
+ maOKButton->Show();
SetOutputSizePixel( Size( 640, 420 ) );
}
void DbgInfoDialog::SetInfoText( const OUString& rStr )
{
- maListBox.SetUpdateMode( false );
- maListBox.Clear();
+ maListBox->SetUpdateMode( false );
+ maListBox->Clear();
OUString aStr = convertLineEnd(rStr, LINEEND_LF);
sal_Int32 nStrIndex = 0;
sal_Int32 nFoundIndex;
@@ -413,18 +431,18 @@ void DbgInfoDialog::SetInfoText( const OUString& rStr )
OUString aTextParagraph = aStr.copy( nStrIndex, nFoundIndex-nStrIndex );
if ( mbHelpText )
{
- long nMaxWidth = maListBox.GetOutputSizePixel().Width()-30;
+ long nMaxWidth = maListBox->GetOutputSizePixel().Width()-30;
sal_Int32 nLastIndex = 0;
sal_Int32 nIndex = aTextParagraph.indexOf( ' ' );
while ( nIndex != -1 )
{
- if ( maListBox.GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
+ if ( maListBox->GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
{
if ( !nLastIndex )
nLastIndex = nIndex+1;
OUString aTempStr = aTextParagraph.copy( 0, nLastIndex );
aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" );
- maListBox.InsertEntry( aTempStr );
+ maListBox->InsertEntry( aTempStr );
nLastIndex = 0;
}
else
@@ -432,20 +450,27 @@ void DbgInfoDialog::SetInfoText( const OUString& rStr )
nIndex = aTextParagraph.indexOf( ' ', nLastIndex );
}
- if ( maListBox.GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
+ if ( maListBox->GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
{
if ( !nLastIndex )
nLastIndex = nIndex+1;
OUString aTempStr = aTextParagraph.copy( 0, nLastIndex );
aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" );
- maListBox.InsertEntry( aTempStr );
+ maListBox->InsertEntry( aTempStr );
}
}
- maListBox.InsertEntry( aTextParagraph );
+ maListBox->InsertEntry( aTextParagraph );
nStrIndex = nFoundIndex+1;
}
while ( nFoundIndex != -1 );
- maListBox.SetUpdateMode( true );
+ maListBox->SetUpdateMode( true );
+}
+
+void DbgInfoDialog::dispose()
+{
+ maListBox.disposeAndClear();
+ maOKButton.disposeAndClear();
+ ModalDialog::dispose();
}
void DbgDialogTest( vcl::Window* pWindow )
@@ -808,7 +833,7 @@ void DbgGUIStart()
if ( pData )
{
- std::unique_ptr<DbgDialog> xDialog(new DbgDialog);
+ ScopedVclPtrInstance< DbgDialog > xDialog;
// we switch off dialog tests for the debug dialog
sal_uLong nOldFlags = pData->nTestFlags;
pData->nTestFlags &= ~DBG_TEST_DIALOG;
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 53ebd746a3f6..2f52375d1e02 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -204,9 +204,9 @@ sal_uIntPtr Help::ShowTip( vcl::Window* pParent, const Rectangle& rScreenRect,
const OUString& rText, sal_uInt16 nStyle )
{
sal_uInt16 nHelpWinStyle = ( ( nStyle & QUICKHELP_TIP_STYLE_BALLOON ) != 0 ) ? HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
- HelpTextWindow* pHelpWin = new HelpTextWindow( pParent, rText, nHelpWinStyle, nStyle );
+ VclPtrInstance<HelpTextWindow> pHelpWin( pParent, rText, nHelpWinStyle, nStyle );
- sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin );
+ sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin.get() );
UpdateTip( nId, pParent, rScreenRect, rText );
pHelpWin->ShowHelp( HELPDELAY_NONE );
@@ -229,12 +229,12 @@ void Help::UpdateTip( sal_uIntPtr nId, vcl::Window* pParent, const Rectangle& rS
void Help::HideTip( sal_uLong nId )
{
- HelpTextWindow* pHelpWin = reinterpret_cast<HelpTextWindow*>(nId);
+ VclPtr<HelpTextWindow> pHelpWin = reinterpret_cast<HelpTextWindow*>(nId);
vcl::Window* pFrameWindow = pHelpWin->ImplGetFrameWindow();
pHelpWin->Hide();
// trigger update, so that a Paint is instantly triggered since we do not save the background
pFrameWindow->ImplUpdateAll();
- delete pHelpWin;
+ pHelpWin.disposeAndClear();
ImplGetSVData()->maHelpData.mnLastHelpHideTime = tools::Time::GetSystemTicks();
}
@@ -290,11 +290,17 @@ HelpTextWindow::HelpTextWindow( vcl::Window* pParent, const OUString& rText, sal
HelpTextWindow::~HelpTextWindow()
{
+ disposeOnce();
+}
+
+void HelpTextWindow::dispose()
+{
maShowTimer.Stop();
maHideTimer.Stop();
if( this == ImplGetSVData()->maHelpData.mpHelpWin )
ImplGetSVData()->maHelpData.mpHelpWin = NULL;
+ FloatingWindow::dispose();
}
void HelpTextWindow::SetHelpText( const OUString& rHelpText )
@@ -524,7 +530,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, sal_uIn
nDelayMode = HELPDELAY_NONE;
DBG_ASSERT( !pHelpWin, "Noch ein HelpWin ?!" );
- pHelpWin = new HelpTextWindow( pParent, rHelpText, nHelpWinStyle, nStyle );
+ pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, rHelpText, nHelpWinStyle, nStyle );
pSVData->maHelpData.mpHelpWin = pHelpWin;
pHelpWin->SetStatusText( rStatusText );
if ( pHelpArea )
@@ -544,7 +550,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, sal_uIn
void ImplDestroyHelpWindow( bool bUpdateHideTime )
{
ImplSVData* pSVData = ImplGetSVData();
- HelpTextWindow* pHelpWin = pSVData->maHelpData.mpHelpWin;
+ VclPtr<HelpTextWindow> pHelpWin = pSVData->maHelpData.mpHelpWin;
if ( pHelpWin )
{
vcl::Window * pWindow = pHelpWin->GetParent()->ImplGetFrameWindow();
@@ -555,7 +561,7 @@ void ImplDestroyHelpWindow( bool bUpdateHideTime )
pSVData->maHelpData.mpHelpWin = NULL;
pSVData->maHelpData.mbKeyboardHelp = false;
pHelpWin->Hide();
- delete pHelpWin;
+ pHelpWin.disposeAndClear();
if( bUpdateHideTime )
pSVData->maHelpData.mnLastHelpHideTime = tools::Time::GetSystemTicks();
}
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index a0447312a778..e05b73480148 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -28,6 +28,9 @@
#include <salobj.hxx>
#include <salmenu.hxx>
+
+SalFrame::SalFrame() : m_pWindow( NULL ), m_pProc( NULL ) {}
+
// this file contains the virtual destructors of the sal interface
// compilers usually put their vtables where the destructor is
@@ -35,6 +38,12 @@ SalFrame::~SalFrame()
{
}
+void SalFrame::SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc )
+{
+ m_pWindow = pWindow;
+ m_pProc = pProc;
+}
+
// default to full-frame flushes
// on ports where partial-flushes are much cheaper this method should be overridden
void SalFrame::Flush( const Rectangle& )
diff --git a/vcl/source/app/stdtext.cxx b/vcl/source/app/stdtext.cxx
index 8093a6fe6900..fcf7b9d129c7 100644
--- a/vcl/source/app/stdtext.cxx
+++ b/vcl/source/app/stdtext.cxx
@@ -39,8 +39,8 @@ void ShowServiceNotAvailableError(vcl::Window* pParent,
{
OUString aText = GetStandardText(STANDARD_TEXT_SERVICE_NOT_AVAILABLE).
replaceAll("%s", rServiceName);
- MessageDialog aBox(pParent, aText, bError ? VCL_MESSAGE_ERROR : VCL_MESSAGE_WARNING);
- aBox.Execute();
+ ScopedVclPtrInstance< MessageDialog > aBox( pParent, aText, bError ? VCL_MESSAGE_ERROR : VCL_MESSAGE_WARNING );
+ aBox->Execute();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 3d22d7cf5621..7859ccc370c4 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -156,28 +156,28 @@ struct ImplEventHook
struct ImplPostEventData
{
sal_uLong mnEvent;
- const vcl::Window* mpWin;
+ VclPtr<vcl::Window> mpWin;
ImplSVEvent * mnEventId;
KeyEvent maKeyEvent;
MouseEvent maMouseEvent;
ZoomEvent maZoomEvent;
ScrollEvent maScrollEvent;
- ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const KeyEvent& rKeyEvent ) :
+ ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const KeyEvent& rKeyEvent ) :
mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maKeyEvent( rKeyEvent ) {}
- ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const MouseEvent& rMouseEvent ) :
+ ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const MouseEvent& rMouseEvent ) :
mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maMouseEvent( rMouseEvent ) {}
#if !HAVE_FEATURE_DESKTOP
- ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const ZoomEvent& rZoomEvent ) :
+ ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const ZoomEvent& rZoomEvent ) :
mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maZoomEvent( rZoomEvent ) {}
- ImplPostEventData( sal_uLong nEvent, const vcl::Window* pWin, const ScrollEvent& rScrollEvent ) :
+ ImplPostEventData( sal_uLong nEvent, vcl::Window* pWin, const ScrollEvent& rScrollEvent ) :
mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maScrollEvent( rScrollEvent ) {}
#endif
~ImplPostEventData() {}
};
-typedef ::std::pair< vcl::Window*, ImplPostEventData* > ImplPostEventPair;
+typedef ::std::pair< VclPtr<vcl::Window>, ImplPostEventData* > ImplPostEventPair;
static ::std::list< ImplPostEventPair > aPostedEventList;
@@ -855,8 +855,8 @@ IMPL_STATIC_LINK_NOINSTANCE( Application, PostEventHandler, void*, pCallData )
break;
};
- if( pData->mpWin && pData->mpWin->mpWindowImpl->mpFrameWindow && pEventData )
- ImplWindowFrameProc( pData->mpWin->mpWindowImpl->mpFrameWindow, NULL, (sal_uInt16) nEvent, pEventData );
+ if( pData->mpWin && pData->mpWin.get()->mpWindowImpl->mpFrameWindow.get() && pEventData )
+ ImplWindowFrameProc( pData->mpWin.get()->mpWindowImpl->mpFrameWindow.get(), NULL, (sal_uInt16) nEvent, pEventData );
// remove this event from list of posted events, watch for destruction of internal data
::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() );
@@ -1010,7 +1010,7 @@ long Application::GetTopWindowCount()
{
long nRet = 0;
ImplSVData* pSVData = ImplGetSVData();
- vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL;
+ vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame.get() : NULL;
while( pWin )
{
if( pWin->ImplGetWindow()->IsTopWindow() )
@@ -1024,7 +1024,7 @@ vcl::Window* Application::GetTopWindow( long nIndex )
{
long nIdx = 0;
ImplSVData* pSVData = ImplGetSVData();
- vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL;
+ vcl::Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame.get() : NULL;
while( pWin )
{
if( pWin->ImplGetWindow()->IsTopWindow() )
@@ -1268,7 +1268,7 @@ vcl::Window* Application::GetDefDialogParent()
// #103442# find some useful dialog parent if there
// was no default set
// NOTE: currently even the default is not used
- if( false && pSVData->maWinData.mpDefDialogParent != NULL )
+ if( false && pSVData->maWinData.mpDefDialogParent.get() != NULL )
return pSVData->maWinData.mpDefDialogParent;
else
{
@@ -1629,11 +1629,24 @@ void Application::setDeInitHook(Link const & hook) {
pSVData->maAppData.mbInAppMain = true;
}
+ImplDelData::ImplDelData( vcl::Window* pWindow ) :
+ mpNext( NULL ),
+ mpWindow( NULL ),
+ mbDel( false )
+{
+ if( pWindow ) AttachToWindow( pWindow );
+}
+
// helper method to allow inline constructor even for pWindow!=NULL case
void ImplDelData::AttachToWindow( const vcl::Window* pWindow )
{
if( pWindow )
- const_cast<vcl::Window*>(pWindow)->ImplAddDel( this );
+ {
+ if( pWindow->IsDisposed() )
+ mbDel = true;
+ else
+ const_cast<vcl::Window*>(pWindow)->ImplAddDel( this );
+ }
}
// define dtor for ImplDelData
@@ -1644,7 +1657,7 @@ ImplDelData::~ImplDelData()
if( !mbDel && mpWindow )
{
// the window still exists but we were not removed
- const_cast<vcl::Window*>(mpWindow)->ImplRemoveDel( this );
+ const_cast<vcl::Window*>(mpWindow.get())->ImplRemoveDel( this );
mpWindow = NULL;
}
}
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 155b5cc0ba3c..14cf94de9dd2 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -37,6 +37,8 @@
#include "vcl/layout.hxx"
#include "vcl/button.hxx"
#include "vcl/dockwin.hxx"
+#include "vcl/print.hxx"
+#include "vcl/virdev.hxx"
#include "salinst.hxx"
#include "salframe.hxx"
#include "salgdi.hxx"
@@ -45,6 +47,8 @@
#include "salimestatus.hxx"
#include "salsys.hxx"
#include "svids.hrc"
+#include "helpwin.hxx"
+#include "../window/scrwnd.hxx"
#include "com/sun/star/accessibility/MSAAService.hpp"
@@ -84,6 +88,14 @@ ImplSVData::ImplSVData()
maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT );
}
+ImplSVGDIData::~ImplSVGDIData()
+{
+ // FIXME: deliberately leak any remaining OutputDevice
+ // until we have their pGraphics reference counted, doing
+ // any disposes so late in shutdown is rather unsafe.
+ memset( this, 0, sizeof( ImplSVGDIData ) );
+}
+
void ImplDeInitSVData()
{
ImplSVData* pSVData = ImplGetSVData();
@@ -124,7 +136,7 @@ vcl::Window* ImplGetDefaultWindow()
if ( !pSVData->mpDefaultWin && !pSVData->mbDeInit )
{
DBG_WARNING( "ImplGetDefaultWindow(): No AppWindow" );
- pSVData->mpDefaultWin = new WorkWindow( 0, WB_DEFAULTWIN );
+ pSVData->mpDefaultWin = VclPtr<WorkWindow>::Create( nullptr, WB_DEFAULTWIN );
pSVData->mpDefaultWin->SetText( OUString( "VCL ImplGetDefaultWindow" ) );
// Add a reference to the default context so it never gets deleted
@@ -160,8 +172,8 @@ ResMgr* ImplGetResMgr()
"Missing vcl resource. This indicates that files vital to localization are missing. "
"You might have a corrupt installation.";
fprintf( stderr, "%s\n", pMsg );
- MessageDialog aBox(NULL, OUString(pMsg, strlen(pMsg), RTL_TEXTENCODING_ASCII_US));
- aBox.Execute();
+ ScopedVclPtrInstance< MessageDialog > aBox( nullptr, OUString(pMsg, strlen(pMsg), RTL_TEXTENCODING_ASCII_US) );
+ aBox->Execute();
}
}
return pSVData->mpResMgr;
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index a80d576c1987..fce2961c2c53 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -423,11 +423,7 @@ void DeInitVCL()
delete pSVData->maCtrlData.mpDisclosureMinus;
pSVData->maCtrlData.mpDisclosureMinus = NULL;
}
- if ( pSVData->mpDefaultWin )
- {
- delete pSVData->mpDefaultWin;
- pSVData->mpDefaultWin = NULL;
- }
+ pSVData->mpDefaultWin.disposeAndClear();
DBGGUI_DEINIT_SOLARMUTEXCHECK();
diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index 11d03e3f8b03..325c9b659b18 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -18,6 +18,7 @@
*/
#include "vcl/vclevent.hxx"
+#include "vcl/window.hxx"
#include "svdata.hxx"
@@ -158,4 +159,12 @@ void VclEventListeners2::callListeners( VclSimpleEvent* i_pEvent )
m_aIterators.pop_back();
}
+
+VclWindowEvent::VclWindowEvent( vcl::Window* pWin, sal_uLong n, void* pDat ) : VclSimpleEvent(n)
+{
+ pWindow = pWin; pData = pDat;
+}
+
+VclWindowEvent::~VclWindowEvent() {}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 09abe44f5f80..bf23b10fb9d4 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -88,14 +88,19 @@ ImplCommonButtonData::~ImplCommonButtonData()
}
Button::Button( WindowType nType ) :
- Control( nType )
+ Control( nType ),
+ mpButtonData( new ImplCommonButtonData )
{
- mpButtonData = new ImplCommonButtonData;
}
Button::~Button()
{
- delete mpButtonData;
+ disposeOnce();
+}
+
+void Button::dispose()
+{
+ Control::dispose();
}
void Button::SetCommandHandler(const OUString& aCommand)
@@ -1173,10 +1178,6 @@ PushButton::PushButton( vcl::Window* pParent, const ResId& rResId ) :
Show();
}
-PushButton::~PushButton()
-{
-}
-
void PushButton::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( rMEvt.IsLeft() &&
@@ -1583,7 +1584,8 @@ void PushButton::SetPressed( bool bPressed )
void PushButton::EndSelection()
{
EndTracking( ENDTRACK_CANCEL );
- if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
+ if ( !IsDisposed() &&
+ ImplGetButtonState() & BUTTON_DRAW_PRESSED )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
if ( !mbPressed )
@@ -2143,20 +2145,20 @@ void RadioButton::group(RadioButton &rOther)
if (!m_xGroup)
{
- m_xGroup.reset(new std::vector<RadioButton*>);
+ m_xGroup.reset(new std::vector<VclPtr<RadioButton> >);
m_xGroup->push_back(this);
}
- std::vector<RadioButton*>::iterator aFind = std::find(m_xGroup->begin(), m_xGroup->end(), &rOther);
+ auto aFind = std::find(m_xGroup->begin(), m_xGroup->end(), VclPtr<RadioButton>(&rOther));
if (aFind == m_xGroup->end())
{
m_xGroup->push_back(&rOther);
if (rOther.m_xGroup)
{
- std::vector< RadioButton* > aOthers(rOther.GetRadioButtonGroup(false));
+ std::vector< VclPtr<RadioButton> > aOthers(rOther.GetRadioButtonGroup(false));
//make all members of the group share the same button group
- for (std::vector<RadioButton*>::iterator aI = aOthers.begin(), aEnd = aOthers.end(); aI != aEnd; ++aI)
+ for (auto aI = aOthers.begin(), aEnd = aOthers.end(); aI != aEnd; ++aI)
{
aFind = std::find(m_xGroup->begin(), m_xGroup->end(), *aI);
if (aFind == m_xGroup->end())
@@ -2165,8 +2167,7 @@ void RadioButton::group(RadioButton &rOther)
}
//make all members of the group share the same button group
- for (std::vector<RadioButton*>::iterator aI = m_xGroup->begin(), aEnd = m_xGroup->end();
- aI != aEnd; ++aI)
+ for (auto aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI)
{
RadioButton* pButton = *aI;
pButton->m_xGroup = m_xGroup;
@@ -2178,14 +2179,14 @@ void RadioButton::group(RadioButton &rOther)
ImplUncheckAllOther();
}
-std::vector< RadioButton* > RadioButton::GetRadioButtonGroup(bool bIncludeThis) const
+std::vector< VclPtr<RadioButton> > RadioButton::GetRadioButtonGroup(bool bIncludeThis) const
{
if (m_xGroup)
{
if (bIncludeThis)
return *m_xGroup;
- std::vector< RadioButton* > aGroup;
- for (std::vector<RadioButton*>::iterator aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI)
+ std::vector< VclPtr<RadioButton> > aGroup;
+ for (auto aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI)
{
RadioButton *pRadioButton = *aI;
if (pRadioButton == this)
@@ -2207,7 +2208,7 @@ std::vector< RadioButton* > RadioButton::GetRadioButtonGroup(bool bIncludeThis)
else
break;
}
- std::vector< RadioButton* > aGroup;
+ std::vector< VclPtr<RadioButton> > aGroup;
// insert radiobuttons up to next group
do
{
@@ -2226,9 +2227,9 @@ void RadioButton::ImplUncheckAllOther()
{
mpWindowImpl->mnStyle |= WB_TABSTOP;
- std::vector<RadioButton*> aGroup(GetRadioButtonGroup(false));
+ std::vector<VclPtr<RadioButton> > aGroup(GetRadioButtonGroup(false));
// iterate over radio button group and checked buttons
- for (std::vector<RadioButton*>::iterator aI = aGroup.begin(), aEnd = aGroup.end(); aI != aEnd; ++aI)
+ for (auto aI = aGroup.begin(), aEnd = aGroup.end(); aI != aEnd; ++aI)
{
RadioButton *pWindow = *aI;
if ( pWindow->IsChecked() )
@@ -2305,11 +2306,18 @@ void RadioButton::ImplLoadRes( const ResId& rResId )
RadioButton::~RadioButton()
{
+ disposeOnce();
+}
+
+void RadioButton::dispose()
+{
if (m_xGroup)
{
- m_xGroup->erase(std::remove(m_xGroup->begin(), m_xGroup->end(), this),
- m_xGroup->end());
+ m_xGroup->erase(std::remove(m_xGroup->begin(), m_xGroup->end(), VclPtr<RadioButton>(this)),
+ m_xGroup->end());
+ m_xGroup.reset();
}
+ Button::dispose();
}
void RadioButton::MouseButtonDown( const MouseEvent& rMEvt )
@@ -3753,10 +3761,6 @@ ImageButton::ImageButton( vcl::Window* pParent, const ResId& rResId ) :
ImplInitStyle();
}
-ImageButton::~ImageButton()
-{
-}
-
void ImageButton::ImplInitStyle()
{
WinBits nStyle = GetStyle();
@@ -3775,20 +3779,12 @@ ImageRadioButton::ImageRadioButton( vcl::Window* pParent, WinBits nStyle ) :
{
}
-ImageRadioButton::~ImageRadioButton()
-{
-}
-
TriStateBox::TriStateBox( vcl::Window* pParent, WinBits nStyle ) :
CheckBox( pParent, nStyle )
{
EnableTriState( true );
}
-TriStateBox::~TriStateBox()
-{
-}
-
DisclosureButton::DisclosureButton( vcl::Window* pParent, WinBits nStyle ) :
CheckBox( pParent, nStyle )
{
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index be0e048991c6..e9e24ee3cabc 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -68,20 +68,25 @@ ComboBox::ComboBox( vcl::Window* pParent, const ResId& rResId ) :
ComboBox::~ComboBox()
{
- SetSubEdit( NULL );
- delete mpSubEdit;
+ disposeOnce();
+}
+
+void ComboBox::dispose()
+{
+ mpSubEdit.disposeAndClear();
- ImplListBox *pImplLB = mpImplLB;
- mpImplLB = NULL;
- delete pImplLB;
+ VclPtr< ImplListBox > pImplLB = mpImplLB;
+ mpImplLB.clear();
+ pImplLB.disposeAndClear();
- delete mpFloatWin;
- delete mpBtn;
+ mpFloatWin.disposeAndClear();
+ mpBtn.disposeAndClear();
+ Edit::dispose();
}
void ComboBox::ImplInitComboBoxData()
{
- mpSubEdit = NULL;
+ mpSubEdit.disposeAndClear();
mpBtn = NULL;
mpImplLB = NULL;
mpFloatWin = NULL;
@@ -142,11 +147,11 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
WinBits nListStyle = nStyle;
if( nStyle & WB_DROPDOWN )
{
- mpFloatWin = new ImplListBoxFloatingWindow( this );
+ mpFloatWin = VclPtr<ImplListBoxFloatingWindow>::Create( this );
mpFloatWin->SetAutoWidth( true );
mpFloatWin->SetPopupModeEndHdl( LINK( this, ComboBox, ImplPopupModeEndHdl ) );
- mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
+ mpBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
ImplInitDropDownButton( mpBtn );
mpBtn->buttonDownSignal.connect( boost::bind( &ComboBox::ImplClickButtonHandler, this, _1 ));
mpBtn->Show();
@@ -165,7 +170,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
}
}
- mpSubEdit = new Edit( this, nEditStyle );
+ mpSubEdit.set( VclPtr<Edit>::Create( this, nEditStyle ) );
mpSubEdit->EnableRTL( false );
SetSubEdit( mpSubEdit );
mpSubEdit->SetPosPixel( Point() );
@@ -175,7 +180,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
vcl::Window* pLBParent = this;
if ( mpFloatWin )
pLBParent = mpFloatWin;
- mpImplLB = new ImplListBox( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL );
+ mpImplLB = VclPtr<ImplListBox>::Create( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL );
mpImplLB->SetPosPixel( Point() );
mpImplLB->SetSelectHdl( LINK( this, ComboBox, ImplSelectHdl ) );
mpImplLB->SetCancelHdl( LINK( this, ComboBox, ImplCancelHdl ) );
@@ -188,7 +193,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
if ( mpFloatWin )
mpFloatWin->SetImplListBox( mpImplLB );
else
- mpImplLB->GetMainWindow().AllowGrabFocus( true );
+ mpImplLB->GetMainWindow()->AllowGrabFocus( true );
ImplCalcEditHeight();
@@ -253,7 +258,7 @@ void ComboBox::ImplClickButtonHandler( ImplBtn* )
ImplClearLayoutData();
if( mpImplLB )
- mpImplLB->GetMainWindow().ImplClearLayoutData();
+ mpImplLB->GetMainWindow()->ImplClearLayoutData();
}
IMPL_LINK_NOARG(ComboBox, ImplPopupModeEndHdl)
@@ -272,7 +277,7 @@ IMPL_LINK_NOARG(ComboBox, ImplPopupModeEndHdl)
ImplClearLayoutData();
if( mpImplLB )
- mpImplLB->GetMainWindow().ImplClearLayoutData();
+ mpImplLB->GetMainWindow()->ImplClearLayoutData();
mpBtn->SetPressed( false );
CallEventListeners( VCLEVENT_DROPDOWN_CLOSE );
@@ -581,20 +586,20 @@ void ComboBox::FillLayoutData() const
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
AppendLayoutData( *mpSubEdit );
mpSubEdit->SetLayoutDataParent( this );
- Control& rMainWindow = mpImplLB->GetMainWindow();
+ ImplListBoxWindow* rMainWindow = mpImplLB->GetMainWindow();
if( mpFloatWin )
{
// dropdown mode
if( mpFloatWin->IsReallyVisible() )
{
- AppendLayoutData( rMainWindow );
- rMainWindow.SetLayoutDataParent( this );
+ AppendLayoutData( *rMainWindow );
+ rMainWindow->SetLayoutDataParent( this );
}
}
else
{
- AppendLayoutData( rMainWindow );
- rMainWindow.SetLayoutDataParent( this );
+ AppendLayoutData( *rMainWindow );
+ rMainWindow->SetLayoutDataParent( this );
}
}
@@ -647,7 +652,7 @@ void ComboBox::StateChanged( StateChangedType nType )
else if ( nType == StateChangedType::STYLE )
{
SetStyle( ImplInitStyle( GetStyle() ) );
- mpImplLB->GetMainWindow().EnableSort( ( GetStyle() & WB_SORT ) != 0 );
+ mpImplLB->GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) != 0 );
}
else if( nType == StateChangedType::MIRRORING )
{
@@ -765,7 +770,7 @@ bool ComboBox::Notify( NotifyEvent& rNEvt )
nDone = false; // don't eat this event, let the default handling happen (i.e. scroll the context)
}
}
- else if( ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN ) && ( rNEvt.GetWindow() == &mpImplLB->GetMainWindow() ) )
+ else if( ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN ) && ( rNEvt.GetWindow() == mpImplLB->GetMainWindow() ) )
{
mpSubEdit->GrabFocus();
}
@@ -799,6 +804,9 @@ void ComboBox::Modify()
void ComboBox::ImplUpdateFloatSelection()
{
+ if (!mpImplLB)
+ return;
+
// move text in the ListBox into the visible region
mpImplLB->SetCallSelectionChangedHdl( false );
if ( !IsMultiSelectionEnabled() )
@@ -1106,7 +1114,7 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines
long nCharWidth = GetTextWidth(OUString(static_cast<sal_Unicode>('x')));
if ( !IsDropDownBox() )
{
- Size aOutSz = mpImplLB->GetMainWindow().GetOutputSizePixel();
+ Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel();
rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1;
rnLines = (sal_uInt16)(aOutSz.Height()/mpImplLB->GetEntryHeight());
}
@@ -1120,11 +1128,11 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines
void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
{
- mpImplLB->GetMainWindow().ImplInitSettings( true, true, true );
+ mpImplLB->GetMainWindow()->ImplInitSettings( true, true, true );
Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize );
- vcl::Font aFont = mpImplLB->GetMainWindow().GetDrawPixelFont( pDev );
+ vcl::Font aFont = mpImplLB->GetMainWindow()->GetDrawPixelFont( pDev );
OutDevType eOutDevType = pDev->GetOutDevType();
pDev->Push();
@@ -1233,18 +1241,18 @@ void ComboBox::UserDraw( const UserDrawEvent& )
void ComboBox::SetUserItemSize( const Size& rSz )
{
- mpImplLB->GetMainWindow().SetUserItemSize( rSz );
+ mpImplLB->GetMainWindow()->SetUserItemSize( rSz );
}
void ComboBox::EnableUserDraw( bool bUserDraw )
{
- mpImplLB->GetMainWindow().EnableUserDraw( bUserDraw );
+ mpImplLB->GetMainWindow()->EnableUserDraw( bUserDraw );
}
void ComboBox::DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos )
{
- DBG_ASSERT( rEvt.GetDevice() == &mpImplLB->GetMainWindow(), "DrawEntry?!" );
- mpImplLB->GetMainWindow().DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
+ DBG_ASSERT( rEvt.GetDevice() == mpImplLB->GetMainWindow(), "DrawEntry?!" );
+ mpImplLB->GetMainWindow()->DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
}
void ComboBox::SetSeparatorPos( sal_Int32 n )
@@ -1259,7 +1267,7 @@ void ComboBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
OUString ComboBox::GetMRUEntries( sal_Unicode cSep ) const
{
- return mpImplLB->GetMRUEntries( cSep );
+ return mpImplLB ? mpImplLB->GetMRUEntries( cSep ) : OUString();
}
void ComboBox::SetMaxMRUCount( sal_Int32 n )
@@ -1269,12 +1277,12 @@ void ComboBox::SetMaxMRUCount( sal_Int32 n )
sal_Int32 ComboBox::GetMaxMRUCount() const
{
- return mpImplLB->GetMaxMRUCount();
+ return mpImplLB ? mpImplLB->GetMaxMRUCount() : 0;
}
sal_uInt16 ComboBox::GetDisplayLineCount() const
{
- return mpImplLB->GetDisplayLineCount();
+ return mpImplLB ? mpImplLB->GetDisplayLineCount() : 0;
}
void ComboBox::SetEntryData( sal_Int32 nPos, void* pNewData )
@@ -1355,8 +1363,8 @@ void ComboBox::SetNoSelection()
Rectangle ComboBox::GetBoundingRectangle( sal_Int32 nItem ) const
{
- Rectangle aRect = mpImplLB->GetMainWindow().GetBoundingRectangle( nItem );
- Rectangle aOffset = mpImplLB->GetMainWindow().GetWindowExtentsRelative( (vcl::Window*)this );
+ Rectangle aRect = mpImplLB->GetMainWindow()->GetBoundingRectangle( nItem );
+ Rectangle aOffset = mpImplLB->GetMainWindow()->GetWindowExtentsRelative( (vcl::Window*)this );
aRect.Move( aOffset.TopLeft().X(), aOffset.TopLeft().Y() );
return aRect;
}
@@ -1382,16 +1390,16 @@ long ComboBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) const
{
// point must be either in main list window
// or in impl window (dropdown case)
- ImplListBoxWindow& rMain = mpImplLB->GetMainWindow();
+ ImplListBoxWindow* rMain = mpImplLB->GetMainWindow();
// convert coordinates to ImplListBoxWindow pixel coordinate space
Point aConvPoint = LogicToPixel( rPoint );
aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
- aConvPoint = rMain.AbsoluteScreenToOutputPixel( aConvPoint );
- aConvPoint = rMain.PixelToLogic( aConvPoint );
+ aConvPoint = rMain->AbsoluteScreenToOutputPixel( aConvPoint );
+ aConvPoint = rMain->PixelToLogic( aConvPoint );
// try to find entry
- sal_Int32 nEntry = rMain.GetEntryPosForPoint( aConvPoint );
+ sal_Int32 nEntry = rMain->GetEntryPosForPoint( aConvPoint );
if( nEntry == LISTBOX_ENTRY_NOTFOUND )
nIndex = -1;
else
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 411243cccaeb..85ca49501f24 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -67,7 +67,13 @@ Control::Control( vcl::Window* pParent, const ResId& rResId ) :
Control::~Control()
{
+ disposeOnce();
+}
+
+void Control::dispose()
+{
delete mpControlData, mpControlData = NULL;
+ Window::dispose();
}
void Control::EnableRTL( bool bEnable )
@@ -107,7 +113,7 @@ void Control::CreateLayoutData() const
bool Control::HasLayoutData() const
{
- return mpControlData->mpLayoutData != NULL;
+ return mpControlData ? mpControlData->mpLayoutData != NULL : false;
}
::vcl::ControlLayoutData* Control::GetLayoutData() const
@@ -121,6 +127,10 @@ void Control::SetText( const OUString& rStr )
Window::SetText( rStr );
}
+ControlLayoutData::ControlLayoutData() : m_pParent( NULL )
+{
+}
+
Rectangle ControlLayoutData::GetCharacterBounds( long nIndex ) const
{
return (nIndex >= 0 && nIndex < (long) m_aUnicodeBoundRects.size()) ? m_aUnicodeBoundRects[ nIndex ] : Rectangle();
@@ -338,7 +348,11 @@ void Control::SetLayoutDataParent( const Control* pParent ) const
void Control::ImplClearLayoutData() const
{
- delete mpControlData->mpLayoutData, mpControlData->mpLayoutData = NULL;
+ if (mpControlData)
+ {
+ delete mpControlData->mpLayoutData;
+ mpControlData->mpLayoutData = NULL;
+ }
}
void Control::ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect )
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 809e9445fe1a..6efac8a766b7 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -239,7 +239,14 @@ bool Edit::set_property(const OString &rKey, const OString &rValue)
Edit::~Edit()
{
+ disposeOnce();
+}
+
+void Edit::dispose()
+{
delete mpDDInfo;
+ mpDDInfo = NULL;
+
vcl::Cursor* pCursor = GetCursor();
if ( pCursor )
{
@@ -248,8 +255,10 @@ Edit::~Edit()
}
delete mpIMEInfos;
+ mpIMEInfos = NULL;
delete mpUpdateDataTimer;
+ mpUpdateDataTimer = NULL;
if ( mxDnDListener.is() )
{
@@ -266,14 +275,18 @@ Edit::~Edit()
uno::Reference< lang::XEventListener> xEL( mxDnDListener, uno::UNO_QUERY );
xEL->disposing( lang::EventObject() ); // #95154# #96585# Empty Source means it's the Client
+ mxDnDListener.clear();
}
SetType(WINDOW_WINDOW);
+
+ mpSubEdit.disposeAndClear();
+ Control::dispose();
}
void Edit::ImplInitEditData()
{
- mpSubEdit = NULL;
+ mpSubEdit = VclPtr<Edit>();
mpUpdateDataTimer = NULL;
mpFilterText = NULL;
mnXOffset = 0;
@@ -792,8 +805,8 @@ void Edit::ShowTruncationWarning( vcl::Window* pParent )
ResMgr* pResMgr = ImplGetResMgr();
if( pResMgr )
{
- MessageDialog aBox(pParent, ResId(SV_EDIT_WARNING_STR, *pResMgr), VCL_MESSAGE_WARNING);
- aBox.Execute();
+ ScopedVclPtrInstance< MessageDialog > aBox( pParent, ResId(SV_EDIT_WARNING_STR, *pResMgr), VCL_MESSAGE_WARNING );
+ aBox->Execute();
}
}
@@ -2696,7 +2709,8 @@ void Edit::ClearModifyFlag()
void Edit::SetSubEdit( Edit* pEdit )
{
- mpSubEdit = pEdit;
+ mpSubEdit.disposeAndClear();
+ mpSubEdit.set( pEdit );
if ( mpSubEdit )
{
SetPointer( POINTER_ARROW ); // Nur das SubEdit hat den BEAM...
@@ -2771,8 +2785,8 @@ Size Edit::CalcMinimumSize() const
Size Edit::GetMinimumEditSize()
{
vcl::Window* pDefWin = ImplGetDefaultWindow();
- Edit aEdit( pDefWin, WB_BORDER );
- Size aSize( aEdit.CalcMinimumSize() );
+ ScopedVclPtrInstance< Edit > aEdit( pDefWin, WB_BORDER );
+ Size aSize( aEdit->CalcMinimumSize() );
return aSize;
}
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index c71b7265c32e..cb6b46b8cb7a 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -842,10 +842,6 @@ void NumericField::ImplLoadRes( const ResId& rResId )
mnSpinSize = ReadLongRes();
}
-NumericField::~NumericField()
-{
-}
-
bool NumericField::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -979,10 +975,6 @@ Size NumericBox::CalcMinimumSize() const
return aRet;
}
-NumericBox::~NumericBox()
-{
-}
-
bool NumericBox::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -1679,10 +1671,6 @@ void MetricField::ImplLoadRes( const ResId& rResId )
Reformat();
}
-MetricField::~MetricField()
-{
-}
-
void MetricField::SetUnit( FieldUnit nNewUnit )
{
sal_Int64 nRawMax = GetMax( nNewUnit );
@@ -1826,10 +1814,6 @@ Size MetricBox::CalcMinimumSize() const
return aRet;
}
-MetricBox::~MetricBox()
-{
-}
-
bool MetricBox::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -2056,10 +2040,6 @@ CurrencyField::CurrencyField( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-CurrencyField::~CurrencyField()
-{
-}
-
bool CurrencyField::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -2138,10 +2118,6 @@ CurrencyBox::CurrencyBox( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-CurrencyBox::~CurrencyBox()
-{
-}
-
bool CurrencyBox::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 4bf320f61f48..3f343b215760 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -820,10 +820,6 @@ PatternField::PatternField( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-PatternField::~PatternField()
-{
-}
-
bool PatternField::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -870,10 +866,6 @@ PatternBox::PatternBox( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-PatternBox::~PatternBox()
-{
-}
-
bool PatternBox::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -1738,10 +1730,6 @@ DateField::DateField( vcl::Window* pParent, WinBits nWinStyle ) :
ResetLastDate();
}
-DateField::~DateField()
-{
-}
-
bool DateField::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && IsStrictFormat() &&
@@ -1841,10 +1829,6 @@ DateBox::DateBox( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-DateBox::~DateBox()
-{
-}
-
bool DateBox::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && IsStrictFormat() &&
@@ -2532,10 +2516,6 @@ TimeField::TimeField( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-TimeField::~TimeField()
-{
-}
-
bool TimeField::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -2673,10 +2653,6 @@ TimeBox::TimeBox( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-TimeBox::~TimeBox()
-{
-}
-
bool TimeBox::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 62c6135438b6..69922de6df07 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -460,7 +460,14 @@ void FixedText::set_mnemonic_widget(vcl::Window *pWindow)
FixedText::~FixedText()
{
+ disposeOnce();
+}
+
+void FixedText::dispose()
+{
set_mnemonic_widget(NULL);
+ m_pMnemonicWindow.clear();
+ Control::dispose();
}
SelectableFixedText::SelectableFixedText(vcl::Window* pParent, WinBits nStyle)
@@ -748,10 +755,6 @@ FixedBitmap::FixedBitmap( vcl::Window* pParent, WinBits nStyle ) :
ImplInit( pParent, nStyle );
}
-FixedBitmap::~FixedBitmap()
-{
-}
-
void FixedBitmap::ImplDraw( OutputDevice* pDev, sal_uLong /* nDrawFlags */,
const Point& rPos, const Size& rSize )
{
@@ -915,10 +918,6 @@ FixedImage::FixedImage( vcl::Window* pParent, const ResId& rResId ) :
Show();
}
-FixedImage::~FixedImage()
-{
-}
-
void FixedImage::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
const Point& rPos, const Size& rSize )
{
diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx
index 6926a0c843c6..db36f90c2572 100644
--- a/vcl/source/control/fixedhyper.cxx
+++ b/vcl/source/control/fixedhyper.cxx
@@ -26,10 +26,6 @@ FixedHyperlink::FixedHyperlink(vcl::Window* pParent, WinBits nWinStyle)
Initialize();
}
-FixedHyperlink::~FixedHyperlink()
-{
-}
-
void FixedHyperlink::Initialize()
{
// saves the old pointer
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 64d009ab9e34..083faf072e96 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -536,7 +536,13 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle )
ImplListBoxWindow::~ImplListBoxWindow()
{
+ disposeOnce();
+}
+
+void ImplListBoxWindow::dispose()
+{
delete mpEntryList;
+ Control::dispose();
}
void ImplListBoxWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
@@ -2135,16 +2141,16 @@ sal_uInt16 ImplListBoxWindow::ImplGetTextStyle() const
ImplListBox::ImplListBox( vcl::Window* pParent, WinBits nWinStyle ) :
Control( pParent, nWinStyle ),
- maLBWindow( this, nWinStyle&(~WB_BORDER) )
+ maLBWindow(VclPtr<ImplListBoxWindow>::Create( this, nWinStyle&(~WB_BORDER) ))
{
- maLBWindow.userDrawSignal.connect( userDrawSignal );
+ maLBWindow->userDrawSignal.connect( userDrawSignal );
// for native widget rendering we must be able to detect this window type
SetType( WINDOW_LISTBOXWINDOW );
- mpVScrollBar = new ScrollBar( this, WB_VSCROLL | WB_DRAG );
- mpHScrollBar = new ScrollBar( this, WB_HSCROLL | WB_DRAG );
- mpScrollBarBox = new ScrollBarBox( this );
+ mpVScrollBar = VclPtr<ScrollBar>::Create( this, WB_VSCROLL | WB_DRAG );
+ mpHScrollBar = VclPtr<ScrollBar>::Create( this, WB_HSCROLL | WB_DRAG );
+ mpScrollBarBox = VclPtr<ScrollBarBox>::Create( this );
Link aLink( LINK( this, ImplListBox, ScrollBarHdl ) );
mpVScrollBar->SetScrollHdl( aLink );
@@ -2155,26 +2161,33 @@ ImplListBox::ImplListBox( vcl::Window* pParent, WinBits nWinStyle ) :
mbAutoHScroll = ( nWinStyle & WB_AUTOHSCROLL );
mbEdgeBlending = false;
- maLBWindow.SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) );
- maLBWindow.SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) );
- maLBWindow.SetEdgeBlending(GetEdgeBlending());
- maLBWindow.Show();
+ maLBWindow->SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) );
+ maLBWindow->SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) );
+ maLBWindow->SetEdgeBlending(GetEdgeBlending());
+ maLBWindow->Show();
}
ImplListBox::~ImplListBox()
{
- delete mpHScrollBar;
- delete mpVScrollBar;
- delete mpScrollBarBox;
+ disposeOnce();
+}
+
+void ImplListBox::dispose()
+{
+ mpHScrollBar.disposeAndClear();
+ mpVScrollBar.disposeAndClear();
+ mpScrollBarBox.disposeAndClear();
+ maLBWindow.disposeAndClear();
+ Control::dispose();
}
void ImplListBox::Clear()
{
- maLBWindow.Clear();
+ maLBWindow->Clear();
if ( GetEntryList()->GetMRUCount() )
{
- maLBWindow.GetEntryList()->SetMRUCount( 0 );
- maLBWindow.SetSeparatorPos( LISTBOX_ENTRY_NOTFOUND );
+ maLBWindow->GetEntryList()->SetMRUCount( 0 );
+ maLBWindow->SetSeparatorPos( LISTBOX_ENTRY_NOTFOUND );
}
mpVScrollBar->SetThumbPos( 0 );
mpHScrollBar->SetThumbPos( 0 );
@@ -2184,7 +2197,7 @@ void ImplListBox::Clear()
sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr )
{
ImplEntryType* pNewEntry = new ImplEntryType( rStr );
- sal_Int32 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry );
+ sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry );
if (nNewPos == LISTBOX_ERROR)
{
delete pNewEntry;
@@ -2197,7 +2210,7 @@ sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr )
sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage )
{
ImplEntryType* pNewEntry = new ImplEntryType( rStr, rImage );
- sal_Int32 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry );
+ sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry );
if (nNewPos == LISTBOX_ERROR)
{
delete pNewEntry;
@@ -2209,33 +2222,33 @@ sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr, const
void ImplListBox::RemoveEntry( sal_Int32 nPos )
{
- maLBWindow.RemoveEntry( nPos );
+ maLBWindow->RemoveEntry( nPos );
StateChanged( StateChangedType::DATA );
}
void ImplListBox::SetEntryFlags( sal_Int32 nPos, long nFlags )
{
- maLBWindow.SetEntryFlags( nPos, nFlags );
+ maLBWindow->SetEntryFlags( nPos, nFlags );
}
void ImplListBox::SelectEntry( sal_Int32 nPos, bool bSelect )
{
- maLBWindow.SelectEntry( nPos, bSelect );
+ maLBWindow->SelectEntry( nPos, bSelect );
}
void ImplListBox::SetNoSelection()
{
- maLBWindow.DeselectAll();
+ maLBWindow->DeselectAll();
}
void ImplListBox::GetFocus()
{
- maLBWindow.GrabFocus();
+ maLBWindow->GrabFocus();
}
vcl::Window* ImplListBox::GetPreferredKeyInputWindow()
{
- return &maLBWindow;
+ return maLBWindow.get();
}
void ImplListBox::Resize()
@@ -2359,7 +2372,7 @@ void ImplListBox::ImplCheckScrollBars()
void ImplListBox::ImplInitScrollBars()
{
- Size aOutSz = maLBWindow.GetOutputSizePixel();
+ Size aOutSz = maLBWindow->GetOutputSizePixel();
if ( mbVScroll )
{
@@ -2396,9 +2409,9 @@ void ImplListBox::ImplResizeControls()
// pb: #106948# explicit mirroring for calc
// Scrollbar on left or right side?
- bool bMirroring = maLBWindow.IsMirroring();
+ bool bMirroring = maLBWindow->IsMirroring();
Point aWinPos( bMirroring && mbVScroll ? nSBWidth : 0, 0 );
- maLBWindow.SetPosSizePixel( aWinPos, aInnerSz );
+ maLBWindow->SetPosSizePixel( aWinPos, aInnerSz );
// ScrollBarBox
if( mbVScroll && mbHScroll )
@@ -2450,7 +2463,7 @@ void ImplListBox::StateChanged( StateChangedType nType )
else if ( ( nType == StateChangedType::UPDATEMODE ) || ( nType == StateChangedType::DATA ) )
{
bool bUpdate = IsUpdateMode();
- maLBWindow.SetUpdateMode( bUpdate );
+ maLBWindow->SetUpdateMode( bUpdate );
if ( bUpdate && IsReallyVisible() )
ImplCheckScrollBars();
}
@@ -2459,30 +2472,30 @@ void ImplListBox::StateChanged( StateChangedType nType )
mpHScrollBar->Enable( IsEnabled() );
mpVScrollBar->Enable( IsEnabled() );
mpScrollBarBox->Enable( IsEnabled() );
- maLBWindow.Enable( IsEnabled() );
+ maLBWindow->Enable( IsEnabled() );
Invalidate();
}
else if ( nType == StateChangedType::ZOOM )
{
- maLBWindow.SetZoom( GetZoom() );
+ maLBWindow->SetZoom( GetZoom() );
Resize();
}
else if ( nType == StateChangedType::CONTROLFONT )
{
- maLBWindow.SetControlFont( GetControlFont() );
+ maLBWindow->SetControlFont( GetControlFont() );
}
else if ( nType == StateChangedType::CONTROLFOREGROUND )
{
- maLBWindow.SetControlForeground( GetControlForeground() );
+ maLBWindow->SetControlForeground( GetControlForeground() );
}
else if ( nType == StateChangedType::CONTROLBACKGROUND )
{
- maLBWindow.SetControlBackground( GetControlBackground() );
+ maLBWindow->SetControlBackground( GetControlBackground() );
}
else if( nType == StateChangedType::MIRRORING )
{
- maLBWindow.EnableRTL( IsRTLEnabled() );
+ maLBWindow->EnableRTL( IsRTLEnabled() );
mpHScrollBar->EnableRTL( IsRTLEnabled() );
mpVScrollBar->EnableRTL( IsRTLEnabled() );
ImplResizeControls();
@@ -2517,7 +2530,7 @@ bool ImplListBox::Notify( NotifyEvent& rNEvt )
const Wallpaper& ImplListBox::GetDisplayBackground() const
{
- return maLBWindow.GetDisplayBackground();
+ return maLBWindow->GetDisplayBackground();
}
bool ImplListBox::HandleWheelAsCursorTravel( const CommandEvent& rCEvt )
@@ -2542,7 +2555,7 @@ void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
// Remove old MRU entries
for ( sal_Int32 n = GetEntryList()->GetMRUCount();n; )
- maLBWindow.RemoveEntry( --n );
+ maLBWindow->RemoveEntry( --n );
sal_Int32 nMRUCount = 0;
sal_Int32 nIndex = 0;
@@ -2553,7 +2566,7 @@ void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
if ( GetEntryList()->FindEntry( aEntry ) != LISTBOX_ENTRY_NOTFOUND )
{
ImplEntryType* pNewEntry = new ImplEntryType( aEntry );
- maLBWindow.GetEntryList()->InsertEntry( nMRUCount++, pNewEntry, false );
+ maLBWindow->GetEntryList()->InsertEntry( nMRUCount++, pNewEntry, false );
bChanges = true;
}
}
@@ -2561,7 +2574,7 @@ void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
if ( bChanges )
{
- maLBWindow.GetEntryList()->SetMRUCount( nMRUCount );
+ maLBWindow->GetEntryList()->SetMRUCount( nMRUCount );
SetSeparatorPos( nMRUCount ? nMRUCount-1 : 0 );
StateChanged( StateChangedType::DATA );
}
@@ -2584,7 +2597,7 @@ void ImplListBox::SetEdgeBlending(bool bNew)
if(mbEdgeBlending != bNew)
{
mbEdgeBlending = bNew;
- maLBWindow.SetEdgeBlending(GetEdgeBlending());
+ maLBWindow->SetEdgeBlending(GetEdgeBlending());
}
}
@@ -2918,6 +2931,18 @@ ImplListBoxFloatingWindow::ImplListBoxFloatingWindow( vcl::Window* pParent ) :
}
+ImplListBoxFloatingWindow::~ImplListBoxFloatingWindow()
+{
+ disposeOnce();
+}
+
+void ImplListBoxFloatingWindow::dispose()
+{
+ mpImplLB.clear();
+ FloatingWindow::dispose();
+}
+
+
bool ImplListBoxFloatingWindow::PreNotify( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
@@ -2959,13 +2984,13 @@ void ImplListBoxFloatingWindow::setPosSizePixel( long nX, long nY, long nWidth,
// this the presence of the vertical Scrollbar has to be known.
mpImplLB->SetSizePixel( GetOutputSizePixel() );
((vcl::Window*)mpImplLB)->Resize();
- ((vcl::Window&)mpImplLB->GetMainWindow()).Resize();
+ ((vcl::Window*)mpImplLB->GetMainWindow())->Resize();
}
}
void ImplListBoxFloatingWindow::Resize()
{
- mpImplLB->GetMainWindow().ImplClearLayoutData();
+ mpImplLB->GetMainWindow()->ImplClearLayoutData();
FloatingWindow::Resize();
}
@@ -3085,12 +3110,12 @@ void ImplListBoxFloatingWindow::StartFloat( bool bStartTracking )
mpImplLB->ShowProminentEntry( nPos );
if( bStartTracking )
- mpImplLB->GetMainWindow().EnableMouseMoveSelect( true );
+ mpImplLB->GetMainWindow()->EnableMouseMoveSelect( true );
- if ( mpImplLB->GetMainWindow().IsGrabFocusAllowed() )
- mpImplLB->GetMainWindow().GrabFocus();
+ if ( mpImplLB->GetMainWindow()->IsGrabFocusAllowed() )
+ mpImplLB->GetMainWindow()->GrabFocus();
- mpImplLB->GetMainWindow().ImplClearLayoutData();
+ mpImplLB->GetMainWindow()->ImplClearLayoutData();
}
}
diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx
index 5f081bed20de..77724b0b02d3 100644
--- a/vcl/source/control/longcurr.cxx
+++ b/vcl/source/control/longcurr.cxx
@@ -468,10 +468,6 @@ LongCurrencyField::LongCurrencyField( vcl::Window* pParent, WinBits nWinStyle )
Reformat();
}
-LongCurrencyField::~LongCurrencyField()
-{
-}
-
bool LongCurrencyField::PreNotify( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
@@ -546,10 +542,6 @@ LongCurrencyBox::LongCurrencyBox( vcl::Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-LongCurrencyBox::~LongCurrencyBox()
-{
-}
-
bool LongCurrencyBox::PreNotify( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index a35c502851fd..06da9a114911 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -39,7 +39,7 @@
void ListBox::EnableQuickSelection( const bool& b )
{
- mpImplLB->GetMainWindow().EnableQuickSelection(b);
+ mpImplLB->GetMainWindow()->EnableQuickSelection(b);
}
ListBox::ListBox(WindowType nType)
@@ -70,17 +70,19 @@ ListBox::ListBox( vcl::Window* pParent, const ResId& rResId ) :
ListBox::~ListBox()
{
+ disposeOnce();
+}
+
+void ListBox::dispose()
+{
CallEventListeners( VCLEVENT_OBJECT_DYING );
- // When destroying the FloatWin TH does a GrabFocus to the Parent:
- // that means this "ListBox => PreNotify() ..."
- ImplListBox *pImplLB = mpImplLB;
- mpImplLB = NULL;
- delete pImplLB;
+ mpImplLB.disposeAndClear();
+ mpFloatWin.disposeAndClear();
+ mpImplWin.disposeAndClear();
+ mpBtn.disposeAndClear();
- delete mpFloatWin;
- delete mpImplWin;
- delete mpBtn;
+ Control::dispose();
}
void ListBox::ImplInitListBoxData()
@@ -130,19 +132,19 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
}
}
- mpFloatWin = new ImplListBoxFloatingWindow( this );
+ mpFloatWin = VclPtr<ImplListBoxFloatingWindow>::Create( this );
mpFloatWin->SetAutoWidth( true );
mpFloatWin->SetPopupModeEndHdl( LINK( this, ListBox, ImplPopupModeEndHdl ) );
mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop);
- mpImplWin = new ImplWin( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER );
+ mpImplWin = VclPtr<ImplWin>::Create( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER );
mpImplWin->buttonDownSignal.connect( boost::bind( &ListBox::ImplClickButtonHandler, this, _1 ));
mpImplWin->userDrawSignal.connect( boost::bind( &ListBox::ImplUserDrawHandler, this, _1 ) );
mpImplWin->Show();
mpImplWin->GetDropTarget()->addDropTargetListener(xDrop);
mpImplWin->SetEdgeBlending(GetEdgeBlending());
- mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
+ mpBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
ImplInitDropDownButton( mpBtn );
mpBtn->buttonDownSignal.connect( boost::bind( &ListBox::ImplClickButtonHandler, this, _1 ));
mpBtn->Show();
@@ -152,7 +154,7 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
vcl::Window* pLBParent = this;
if ( mpFloatWin )
pLBParent = mpFloatWin;
- mpImplLB = new ImplListBox( pLBParent, nStyle&(~WB_BORDER) );
+ mpImplLB = VclPtr<ImplListBox>::Create( pLBParent, nStyle&(~WB_BORDER) );
mpImplLB->SetSelectHdl( LINK( this, ListBox, ImplSelectHdl ) );
mpImplLB->SetScrollHdl( LINK( this, ListBox, ImplScrollHdl ) );
mpImplLB->SetCancelHdl( LINK( this, ListBox, ImplCancelHdl ) );
@@ -173,7 +175,7 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
mpImplLB->SetSelectionChangedHdl( LINK( this, ListBox, ImplSelectionChangedHdl ) );
}
else
- mpImplLB->GetMainWindow().AllowGrabFocus( true );
+ mpImplLB->GetMainWindow()->AllowGrabFocus( true );
SetCompoundControl( true );
}
@@ -311,7 +313,7 @@ void ListBox::ImplClickButtonHandler( Control* )
ImplClearLayoutData();
if( mpImplLB )
- mpImplLB->GetMainWindow().ImplClearLayoutData();
+ mpImplLB->GetMainWindow()->ImplClearLayoutData();
if( mpImplWin )
mpImplWin->ImplClearLayoutData();
}
@@ -341,7 +343,7 @@ IMPL_LINK_NOARG(ListBox, ImplPopupModeEndHdl)
ImplClearLayoutData();
if( mpImplLB )
- mpImplLB->GetMainWindow().ImplClearLayoutData();
+ mpImplLB->GetMainWindow()->ImplClearLayoutData();
if( mpImplWin )
mpImplWin->ImplClearLayoutData();
@@ -369,11 +371,11 @@ void ListBox::ToggleDropDown()
void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
{
- mpImplLB->GetMainWindow().ImplInitSettings( true, true, true );
+ mpImplLB->GetMainWindow()->ImplInitSettings( true, true, true );
Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize );
- vcl::Font aFont = mpImplLB->GetMainWindow().GetDrawPixelFont( pDev );
+ vcl::Font aFont = mpImplLB->GetMainWindow()->GetDrawPixelFont( pDev );
OutDevType eOutDevType = pDev->GetOutDevType();
pDev->Push();
@@ -519,9 +521,15 @@ vcl::Window* ListBox::GetPreferredKeyInputWindow()
void ListBox::LoseFocus()
{
if( IsDropDownBox() )
- mpImplWin->HideFocus();
+ {
+ if (mpImplWin)
+ mpImplWin->HideFocus();
+ }
else
- mpImplLB->HideFocus();
+ {
+ if (mpImplLB)
+ mpImplLB->HideFocus();
+ }
Control::LoseFocus();
}
@@ -691,7 +699,7 @@ void ListBox::Resize()
void ListBox::FillLayoutData() const
{
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
- const Control& rMainWin = mpImplLB->GetMainWindow();
+ const ImplListBoxWindow* rMainWin = mpImplLB->GetMainWindow();
if( mpFloatWin )
{
// Dropdown mode
@@ -699,14 +707,14 @@ void ListBox::FillLayoutData() const
mpImplWin->SetLayoutDataParent( this );
if( mpFloatWin->IsReallyVisible() )
{
- AppendLayoutData( rMainWin );
- rMainWin.SetLayoutDataParent( this );
+ AppendLayoutData( *rMainWin );
+ rMainWin->SetLayoutDataParent( this );
}
}
else
{
- AppendLayoutData( rMainWin );
- rMainWin.SetLayoutDataParent( this );
+ AppendLayoutData( *rMainWin );
+ rMainWin->SetLayoutDataParent( this );
}
}
@@ -721,16 +729,16 @@ long ListBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) const
{
// Point must be either in main list window
// or in impl window (dropdown case)
- ImplListBoxWindow& rMain = mpImplLB->GetMainWindow();
+ ImplListBoxWindow* rMain = mpImplLB->GetMainWindow();
// Convert coordinates to ImplListBoxWindow pixel coordinate space
Point aConvPoint = LogicToPixel( rPoint );
aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
- aConvPoint = rMain.AbsoluteScreenToOutputPixel( aConvPoint );
- aConvPoint = rMain.PixelToLogic( aConvPoint );
+ aConvPoint = rMain->AbsoluteScreenToOutputPixel( aConvPoint );
+ aConvPoint = rMain->PixelToLogic( aConvPoint );
// Try to find entry
- sal_Int32 nEntry = rMain.GetEntryPosForPoint( aConvPoint );
+ sal_Int32 nEntry = rMain->GetEntryPosForPoint( aConvPoint );
if( nEntry == LISTBOX_ENTRY_NOTFOUND )
{
// Not found, maybe dropdown case
@@ -803,7 +811,7 @@ void ListBox::StateChanged( StateChangedType nType )
if ( mpImplWin )
{
mpImplWin->SetZoom( GetZoom() );
- mpImplWin->SetFont( mpImplLB->GetMainWindow().GetFont() );
+ mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
mpImplWin->Invalidate();
}
Resize();
@@ -814,7 +822,7 @@ void ListBox::StateChanged( StateChangedType nType )
if ( mpImplWin )
{
mpImplWin->SetControlFont( GetControlFont() );
- mpImplWin->SetFont( mpImplLB->GetMainWindow().GetFont() );
+ mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
mpImplWin->Invalidate();
}
Resize();
@@ -826,7 +834,7 @@ void ListBox::StateChanged( StateChangedType nType )
{
mpImplWin->SetControlForeground( GetControlForeground() );
mpImplWin->SetTextColor( GetControlForeground() );
- mpImplWin->SetFont( mpImplLB->GetMainWindow().GetFont() );
+ mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
mpImplWin->Invalidate();
}
}
@@ -843,17 +851,17 @@ void ListBox::StateChanged( StateChangedType nType )
}
else
{
- mpImplWin->SetBackground( mpImplLB->GetMainWindow().GetControlBackground() );
- mpImplWin->SetControlBackground( mpImplLB->GetMainWindow().GetControlBackground() );
+ mpImplWin->SetBackground( mpImplLB->GetMainWindow()->GetControlBackground() );
+ mpImplWin->SetControlBackground( mpImplLB->GetMainWindow()->GetControlBackground() );
}
- mpImplWin->SetFont( mpImplLB->GetMainWindow().GetFont() );
+ mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
mpImplWin->Invalidate();
}
}
else if ( nType == StateChangedType::STYLE )
{
SetStyle( ImplInitStyle( GetStyle() ) );
- mpImplLB->GetMainWindow().EnableSort( ( GetStyle() & WB_SORT ) != 0 );
+ mpImplLB->GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) != 0 );
bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) != 0;
mpImplLB->SetMultiSelectionSimpleMode( bSimpleMode );
}
@@ -1157,8 +1165,8 @@ bool ListBox::IsInDropDown() const
Rectangle ListBox::GetBoundingRectangle( sal_Int32 nItem ) const
{
- Rectangle aRect = mpImplLB->GetMainWindow().GetBoundingRectangle( nItem );
- Rectangle aOffset = mpImplLB->GetMainWindow().GetWindowExtentsRelative( (vcl::Window*)this );
+ Rectangle aRect = mpImplLB->GetMainWindow()->GetBoundingRectangle( nItem );
+ Rectangle aOffset = mpImplLB->GetMainWindow()->GetWindowExtentsRelative( (vcl::Window*)this );
aRect.Move( aOffset.TopLeft().X(), aOffset.TopLeft().Y() );
return aRect;
}
@@ -1180,7 +1188,7 @@ void ListBox::EnableMultiSelection( bool bMulti, bool bStackSelection )
// In a MultiSelection, we can't see us travelling without focus
if ( mpFloatWin )
- mpImplLB->GetMainWindow().AllowGrabFocus( bMulti );
+ mpImplLB->GetMainWindow()->AllowGrabFocus( bMulti );
}
bool ListBox::IsMultiSelectionEnabled() const
@@ -1348,7 +1356,7 @@ void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines
float nCharWidth = approximate_char_width();
if ( !IsDropDownBox() )
{
- Size aOutSz = mpImplLB->GetMainWindow().GetOutputSizePixel();
+ Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel();
rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth);
rnLines = (sal_uInt16) (aOutSz.Height()/mpImplLB->GetEntryHeight());
}
@@ -1371,22 +1379,22 @@ void ListBox::UserDraw( const UserDrawEvent& )
void ListBox::DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos )
{
- if ( rEvt.GetDevice() == &mpImplLB->GetMainWindow() )
- mpImplLB->GetMainWindow().DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
+ if ( rEvt.GetDevice() == mpImplLB->GetMainWindow() )
+ mpImplLB->GetMainWindow()->DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
else if ( rEvt.GetDevice() == mpImplWin )
mpImplWin->DrawEntry( bDrawImage, bDrawText, bDrawTextAtImagePos );
}
void ListBox::SetUserItemSize( const Size& rSz )
{
- mpImplLB->GetMainWindow().SetUserItemSize( rSz );
+ mpImplLB->GetMainWindow()->SetUserItemSize( rSz );
if ( mpImplWin )
mpImplWin->SetUserItemSize( rSz );
}
void ListBox::EnableUserDraw( bool bUserDraw )
{
- mpImplLB->GetMainWindow().EnableUserDraw( bUserDraw );
+ mpImplLB->GetMainWindow()->EnableUserDraw( bUserDraw );
if ( mpImplWin )
mpImplWin->EnableUserDraw( bUserDraw );
}
diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx
index a78c5612ec86..314c41ab7f9f 100644
--- a/vcl/source/control/menubtn.cxx
+++ b/vcl/source/control/menubtn.cxx
@@ -82,8 +82,14 @@ MenuButton::MenuButton( vcl::Window* pParent, WinBits nWinBits )
MenuButton::~MenuButton()
{
+ disposeOnce();
+}
+
+void MenuButton::dispose()
+{
delete mpMenuTimer;
delete mpOwnMenu;
+ PushButton::dispose();
}
IMPL_LINK_NOARG(MenuButton, ImplMenuTimeoutHdl)
diff --git a/vcl/source/control/morebtn.cxx b/vcl/source/control/morebtn.cxx
index 95cd171afd81..999c3c308d73 100644
--- a/vcl/source/control/morebtn.cxx
+++ b/vcl/source/control/morebtn.cxx
@@ -22,7 +22,7 @@
#include <tools/rc.h>
#include <vector>
-typedef ::std::vector< vcl::Window* > ImplMoreWindowList;
+typedef ::std::vector< VclPtr<vcl::Window> > ImplMoreWindowList;
struct ImplMoreButtonData
{
@@ -80,8 +80,14 @@ MoreButton::MoreButton( vcl::Window* pParent, WinBits nStyle ) :
MoreButton::~MoreButton()
{
+ disposeOnce();
+}
+
+void MoreButton::dispose()
+{
delete mpMBData->mpItemList;
delete mpMBData;
+ PushButton::dispose();
}
void MoreButton::Click()
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index d6443cd16515..a89afac723bb 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -56,10 +56,6 @@ ProgressBar::ProgressBar( vcl::Window* pParent, WinBits nWinStyle ) :
ImplInit();
}
-ProgressBar::~ProgressBar()
-{
-}
-
void ProgressBar::ImplInitSettings( bool bFont,
bool bForeground, bool bBackground )
{
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index e31391d27ab3..b239c623e3ff 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -125,7 +125,13 @@ ScrollBar::ScrollBar( vcl::Window* pParent, WinBits nStyle ) :
ScrollBar::~ScrollBar()
{
- delete mpData;
+ disposeOnce();
+}
+
+void ScrollBar::dispose()
+{
+ delete mpData; mpData = NULL;
+ Control::dispose();
}
void ScrollBar::ImplUpdateRects( bool bUpdate )
diff --git a/vcl/source/control/spinbtn.cxx b/vcl/source/control/spinbtn.cxx
index 9b16b4753751..c9feafa07663 100644
--- a/vcl/source/control/spinbtn.cxx
+++ b/vcl/source/control/spinbtn.cxx
@@ -55,10 +55,6 @@ SpinButton::SpinButton( vcl::Window* pParent, WinBits nStyle )
ImplInit( pParent, nStyle );
}
-SpinButton::~SpinButton()
-{
-}
-
IMPL_LINK( SpinButton, ImplTimeout, Timer*, pTimer )
{
if ( pTimer->GetTimeout() == GetSettings().GetMouseSettings().GetButtonStartRepeat() )
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index 972bded96429..fe1feea8ef05 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -286,7 +286,7 @@ void ImplDrawSpinButton( OutputDevice* pOutDev,
void SpinField::ImplInitSpinFieldData()
{
- mpEdit = NULL;
+ mpEdit.disposeAndClear();
mbSpin = false;
mbRepeat = false;
mbUpperIn = false;
@@ -311,11 +311,11 @@ void SpinField::ImplInit( vcl::Window* pParent, WinBits nWinStyle )
if ( (nWinStyle & WB_SPIN) && ImplUseNativeBorder( nWinStyle ) )
{
SetBackground();
- mpEdit = new Edit( this, WB_NOBORDER );
+ mpEdit.set( VclPtr<Edit>::Create( this, WB_NOBORDER ) );
mpEdit->SetBackground();
}
else
- mpEdit = new Edit( this, WB_NOBORDER );
+ mpEdit.set( VclPtr<Edit>::Create( this, WB_NOBORDER ) );
mpEdit->EnableRTL( false );
mpEdit->SetPosPixel( Point() );
@@ -359,7 +359,14 @@ SpinField::SpinField( vcl::Window* pParent, const ResId& rResId ) :
SpinField::~SpinField()
{
- delete mpEdit;
+ disposeOnce();
+}
+
+void SpinField::dispose()
+{
+ mpEdit.disposeAndClear();
+
+ Edit::dispose();
}
void SpinField::Up()
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index ca63e5485d68..3bf2d59598d6 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -42,7 +42,7 @@
struct ImplTabItem
{
sal_uInt16 mnId;
- TabPage* mpTabPage;
+ VclPtr<TabPage> mpTabPage;
OUString maText;
OUString maFormatText;
OUString maHelpText;
@@ -67,7 +67,7 @@ struct ImplTabCtrlData
std::vector< Rectangle > maTabRectangles;
Point maItemsOffset; // offset of the tabitems
std::vector< ImplTabItem > maItemList;
- ListBox* mpListBox;
+ VclPtr<ListBox> mpListBox;
};
#define TAB_OFFSET 3
@@ -112,7 +112,7 @@ void TabControl::ImplInit( vcl::Window* pParent, WinBits nStyle )
if( (nStyle & WB_DROPDOWN) )
{
- mpTabCtrlData->mpListBox = new ListBox( this, WB_DROPDOWN );
+ mpTabCtrlData->mpListBox = VclPtr<ListBox>::Create( this, WB_DROPDOWN );
mpTabCtrlData->mpListBox->SetPosSizePixel( Point( 0, 0 ), Size( 200, 20 ) );
mpTabCtrlData->mpListBox->SetSelectHdl( LINK( this, TabControl, ImplListBoxSelectHdl ) );
mpTabCtrlData->mpListBox->Show();
@@ -192,6 +192,11 @@ TabControl::TabControl( vcl::Window* pParent, WinBits nStyle ) :
TabControl::~TabControl()
{
+ disposeOnce();
+}
+
+void TabControl::dispose()
+{
Window *pParent = GetParent();
if (pParent && pParent->IsDialog())
GetParent()->RemoveChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) );
@@ -199,12 +204,11 @@ TabControl::~TabControl()
ImplFreeLayoutData();
// delete TabCtrl data
- if ( mpTabCtrlData )
- {
- if( mpTabCtrlData->mpListBox )
- delete mpTabCtrlData->mpListBox;
- delete mpTabCtrlData;
- }
+ if (mpTabCtrlData)
+ mpTabCtrlData->mpListBox.disposeAndClear();
+ delete mpTabCtrlData;
+ mpTabCtrlData = NULL;
+ Control::dispose();
}
ImplTabItem* TabControl::ImplGetItem( sal_uInt16 nId ) const
@@ -574,9 +578,9 @@ void TabControl::ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId )
ImplTabItem* pOldItem = ImplGetItem( nOldId );
ImplTabItem* pItem = ImplGetItem( nId );
- TabPage* pOldPage = (pOldItem) ? pOldItem->mpTabPage : NULL;
- TabPage* pPage = (pItem) ? pItem->mpTabPage : NULL;
- vcl::Window* pCtrlParent = GetParent();
+ TabPage* pOldPage = (pOldItem) ? pOldItem->mpTabPage.get() : NULL;
+ TabPage* pPage = (pItem) ? pItem->mpTabPage.get() : NULL;
+ vcl::Window* pCtrlParent = GetParent();
if ( IsReallyVisible() && IsUpdateMode() )
{
@@ -1013,7 +1017,7 @@ IMPL_LINK( TabControl, ImplWindowEventListener, VclSimpleEvent*, pEvent )
void TabControl::MouseButtonDown( const MouseEvent& rMEvt )
{
- if( mpTabCtrlData->mpListBox == NULL )
+ if( mpTabCtrlData->mpListBox.get() == NULL )
{
if( rMEvt.IsLeft() )
{
@@ -1083,7 +1087,7 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout )
// in this case we're only interested in the top border of the tabpage because the tabitems are used
// standalone (eg impress)
bool bNoTabPage = false;
- TabPage* pCurPage = pCurItem ? pCurItem->mpTabPage : NULL;
+ TabPage* pCurPage = pCurItem ? pCurItem->mpTabPage.get() : NULL;
if( !pCurPage || !pCurPage->IsVisible() )
{
bNoTabPage = true;
@@ -1169,7 +1173,7 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout )
}
}
- if ( !mpTabCtrlData->maItemList.empty() && mpTabCtrlData->mpListBox == NULL )
+ if ( !mpTabCtrlData->maItemList.empty() && mpTabCtrlData->mpListBox == nullptr )
{
// Some native toolkits (GTK+) draw tabs right-to-left, with an
// overlap between adjacent tabs
@@ -1427,7 +1431,7 @@ void TabControl::RequestHelp( const HelpEvent& rHEvt )
void TabControl::Command( const CommandEvent& rCEvt )
{
- if( (mpTabCtrlData->mpListBox == NULL) && (rCEvt.GetCommand() == COMMAND_CONTEXTMENU) && (GetPageCount() > 1) )
+ if( (mpTabCtrlData->mpListBox == nullptr) && (rCEvt.GetCommand() == COMMAND_CONTEXTMENU) && (GetPageCount() > 1) )
{
Point aMenuPos;
bool bMenu;
@@ -1879,7 +1883,7 @@ void TabControl::SetTabPage( sal_uInt16 nPageId, TabPage* pTabPage )
{
ImplTabItem* pItem = ImplGetItem( nPageId );
- if ( pItem && (pItem->mpTabPage != pTabPage) )
+ if ( pItem && (pItem->mpTabPage.get() != pTabPage) )
{
if ( pTabPage )
{
diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx
index 347f24a32e31..eedadc4e5637 100644
--- a/vcl/source/control/throbber.cxx
+++ b/vcl/source/control/throbber.cxx
@@ -59,7 +59,13 @@ Throbber::Throbber( vcl::Window* i_parentWindow, WinBits i_style, const ImageSet
Throbber::~Throbber()
{
+ disposeOnce();
+}
+
+void Throbber::dispose()
+{
maWaitTimer.Stop();
+ ImageControl::dispose();
}
namespace
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index f4a11a2d0ec3..235dd138be99 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -116,7 +116,7 @@ TextEngine::~TextEngine()
delete mpDoc;
delete mpTEParaPortions;
delete mpViews; // only the list, not the Views
- delete mpRefDev;
+ mpRefDev.disposeAndClear();
delete mpUndoManager;
delete mpIMEInfos;
delete mpLocaleDataWrapper;
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 768125bf2a35..2dd8da99768f 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -147,7 +147,7 @@ struct ImpTextView
{
TextEngine* mpTextEngine;
- vcl::Window* mpWindow;
+ VclPtr<vcl::Window> mpWindow;
TextSelection maSelection;
Point maStartDocPos;
// TextPaM maMBDownPaM;
@@ -156,7 +156,7 @@ struct ImpTextView
TextDDInfo* mpDDInfo;
- VirtualDevice* mpVirtDev;
+ VclPtr<VirtualDevice> mpVirtDev;
SelectionEngine* mpSelEngine;
TextSelFunctionSet* mpSelFuncSet;
@@ -235,7 +235,7 @@ TextView::~TextView()
{
delete mpImpl->mpSelEngine;
delete mpImpl->mpSelFuncSet;
- delete mpImpl->mpVirtDev;
+ mpImpl->mpVirtDev.disposeAndClear();
if ( mpImpl->mpWindow->GetCursor() == mpImpl->mpCursor )
mpImpl->mpWindow->SetCursor( 0 );
@@ -541,8 +541,7 @@ VirtualDevice* TextView::GetVirtualDevice()
void TextView::EraseVirtualDevice()
{
- delete mpImpl->mpVirtDev;
- mpImpl->mpVirtDev = 0;
+ mpImpl->mpVirtDev.disposeAndClear();
}
bool TextView::KeyInput( const KeyEvent& rKeyEvent )
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index dd46cdad48fd..cc3a5898cab7 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -47,7 +47,8 @@ private:
public:
TextWindow( vcl::Window* pParent );
- virtual ~TextWindow();
+ virtual ~TextWindow();
+ virtual void dispose() SAL_OVERRIDE;
ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; }
ExtTextView* GetTextView() const { return mpExtTextView; }
@@ -75,12 +76,12 @@ public:
class ImpVclMEdit : public SfxListener
{
private:
- VclMultiLineEdit* pVclMultiLineEdit;
+ VclPtr<VclMultiLineEdit> pVclMultiLineEdit;
- TextWindow* mpTextWindow;
- ScrollBar* mpHScrollBar;
- ScrollBar* mpVScrollBar;
- ScrollBarBox* mpScrollBox;
+ VclPtr<TextWindow> mpTextWindow;
+ VclPtr<ScrollBar> mpHScrollBar;
+ VclPtr<ScrollBar> mpVScrollBar;
+ VclPtr<ScrollBarBox> mpScrollBox;
Point maTextWindowOffset;
sal_Int32 mnTextWidth;
@@ -152,7 +153,7 @@ ImpVclMEdit::ImpVclMEdit( VclMultiLineEdit* pEdt, WinBits nWinStyle )
{
pVclMultiLineEdit = pEdt;
mnTextWidth = 0;
- mpTextWindow = new TextWindow( pEdt );
+ mpTextWindow = VclPtr<TextWindow>::Create( pEdt );
mpTextWindow->Show();
InitFromStyle( nWinStyle );
StartListening( *mpTextWindow->GetTextEngine() );
@@ -160,9 +161,9 @@ ImpVclMEdit::ImpVclMEdit( VclMultiLineEdit* pEdt, WinBits nWinStyle )
void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
{
- const bool bHaveVScroll = (NULL != mpVScrollBar);
- const bool bHaveHScroll = (NULL != mpHScrollBar);
- const bool bHaveScrollBox = (NULL != mpScrollBox);
+ const bool bHaveVScroll = (nullptr != mpVScrollBar);
+ const bool bHaveHScroll = (nullptr != mpHScrollBar);
+ const bool bHaveScrollBox = (nullptr != mpScrollBox);
bool bNeedVScroll = ( nWinStyle & WB_VSCROLL ) == WB_VSCROLL;
const bool bNeedHScroll = ( nWinStyle & WB_HSCROLL ) == WB_HSCROLL;
@@ -183,8 +184,8 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
bool bScrollbarsChanged = false;
if ( bHaveVScroll != bNeedVScroll )
{
- delete mpVScrollBar;
- mpVScrollBar = bNeedVScroll ? new ScrollBar( pVclMultiLineEdit, WB_VSCROLL|WB_DRAG ) : NULL;
+ mpVScrollBar.disposeAndClear();
+ mpVScrollBar = bNeedVScroll ? VclPtr<ScrollBar>::Create( pVclMultiLineEdit, WB_VSCROLL|WB_DRAG ) : nullptr;
if ( bNeedVScroll )
{
@@ -197,8 +198,8 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
if ( bHaveHScroll != bNeedHScroll )
{
- delete mpHScrollBar;
- mpHScrollBar = bNeedHScroll ? new ScrollBar( pVclMultiLineEdit, WB_HSCROLL|WB_DRAG ) : NULL;
+ mpHScrollBar.disposeAndClear();
+ mpHScrollBar = bNeedHScroll ? VclPtr<ScrollBar>::Create( pVclMultiLineEdit, WB_HSCROLL|WB_DRAG ) : nullptr;
if ( bNeedHScroll )
{
@@ -211,8 +212,8 @@ void ImpVclMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle )
if ( bHaveScrollBox != bNeedScrollBox )
{
- delete mpScrollBox;
- mpScrollBox = bNeedScrollBox ? new ScrollBarBox( pVclMultiLineEdit, WB_SIZEABLE ) : NULL;
+ mpScrollBox.disposeAndClear();
+ mpScrollBox = bNeedScrollBox ? VclPtr<ScrollBarBox>::Create( pVclMultiLineEdit, WB_SIZEABLE ) : nullptr;
if ( bNeedScrollBox )
mpScrollBox->Show();
@@ -257,10 +258,11 @@ void ImpVclMEdit::InitFromStyle( WinBits nWinStyle )
ImpVclMEdit::~ImpVclMEdit()
{
EndListening( *mpTextWindow->GetTextEngine() );
- delete mpTextWindow;
- delete mpHScrollBar;
- delete mpVScrollBar;
- delete mpScrollBox;
+ mpTextWindow.disposeAndClear();
+ mpHScrollBar.disposeAndClear();
+ mpVScrollBar.disposeAndClear();
+ mpScrollBox.disposeAndClear();
+ pVclMultiLineEdit.disposeAndClear();
}
void ImpVclMEdit::ImpSetScrollBarRanges()
@@ -730,8 +732,14 @@ TextWindow::TextWindow( vcl::Window* pParent ) : Window( pParent )
TextWindow::~TextWindow()
{
+ disposeOnce();
+}
+
+void TextWindow::dispose()
+{
delete mpExtTextView;
delete mpExtTextEngine;
+ Window::dispose();
}
void TextWindow::MouseMove( const MouseEvent& rMEvt )
@@ -937,11 +945,19 @@ VclMultiLineEdit::VclMultiLineEdit( vcl::Window* pParent, WinBits nWinStyle )
VclMultiLineEdit::~VclMultiLineEdit()
{
+ disposeOnce();
+}
+
+void VclMultiLineEdit::dispose()
+{
{
std::unique_ptr< ImpVclMEdit > xDelete(pImpVclMEdit);
pImpVclMEdit = NULL;
}
delete pUpdateDataTimer;
+ pUpdateDataTimer = NULL;
+
+ Edit::dispose();
}
WinBits VclMultiLineEdit::ImplInitStyle( WinBits nStyle )
@@ -1145,17 +1161,17 @@ void VclMultiLineEdit::SetText( const OUString& rStr )
OUString VclMultiLineEdit::GetText() const
{
- return pImpVclMEdit->GetText();
+ return pImpVclMEdit ? pImpVclMEdit->GetText() : OUString("");
}
OUString VclMultiLineEdit::GetText( LineEnd aSeparator ) const
{
- return pImpVclMEdit->GetText( aSeparator );
+ return pImpVclMEdit ? pImpVclMEdit->GetText( aSeparator ) : OUString("");
}
-OUString VclMultiLineEdit::GetTextLines( LineEnd aSeparator ) const
+OUString VclMultiLineEdit::GetTextLines( LineEnd aSeparator ) const
{
- return pImpVclMEdit->GetTextLines( aSeparator );
+ return pImpVclMEdit ? pImpVclMEdit->GetTextLines( aSeparator ) : OUString("");
}
void VclMultiLineEdit::Resize()
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 147070e52810..961679796fc7 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1892,16 +1892,16 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString
{
Size aSizePixel;
sal_uLong nColorCount,nBitsPerPixel,nNeededMem,nMaxMem;
- VirtualDevice aVirDev;
+ ScopedVclPtrInstance< VirtualDevice > aVirDev;
nMaxMem = 1024;
nMaxMem *= 1024; // In Bytes
// Calculate how big the image would normally be:
- aSizePixel=aVirDev.LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode());
+ aSizePixel=aVirDev->LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode());
// Calculate how much memory the image will take up
- nColorCount=aVirDev.GetColorCount();
+ nColorCount=aVirDev->GetColorCount();
if (nColorCount<=2) nBitsPerPixel=1;
else if (nColorCount<=4) nBitsPerPixel=2;
else if (nColorCount<=16) nBitsPerPixel=4;
@@ -1918,12 +1918,12 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString
aSizePixel.Height()=(sal_uLong)(((double)aSizePixel.Height())*fFak);
}
- aVirDev.SetMapMode(MapMode(MAP_PIXEL));
- aVirDev.SetOutputSizePixel(aSizePixel);
+ aVirDev->SetMapMode(MapMode(MAP_PIXEL));
+ aVirDev->SetOutputSizePixel(aSizePixel);
Graphic aGraphic2=aGraphic;
- aGraphic2.Draw(&aVirDev,Point(0,0),aSizePixel); // this changes the MapMode
- aVirDev.SetMapMode(MapMode(MAP_PIXEL));
- aGraphic=Graphic(aVirDev.GetBitmap(Point(0,0),aSizePixel));
+ aGraphic2.Draw(aVirDev.get(),Point(0,0),aSizePixel); // this changes the MapMode
+ aVirDev->SetMapMode(MapMode(MAP_PIXEL));
+ aGraphic=Graphic(aVirDev->GetBitmap(Point(0,0),aSizePixel));
}
}
if( rOStm.GetError() )
diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx
index 8e9d167cd486..277e4af32366 100644
--- a/vcl/source/filter/sgfbram.cxx
+++ b/vcl/source/filter/sgfbram.cxx
@@ -390,7 +390,7 @@ Color Hpgl2SvFarbe( sal_uInt8 nFarb )
bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMtf)
{
- VirtualDevice aOutDev;
+ ScopedVclPtrInstance< VirtualDevice > aOutDev;
SgfVector aVect;
sal_uInt8 nFarb;
sal_uInt8 nFrb0=7;
@@ -401,9 +401,9 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt
Point aP1(0,0);
sal_uInt16 RecNr=0;
- rMtf.Record(&aOutDev);
- aOutDev.SetLineColor(Color(COL_BLACK));
- aOutDev.SetFillColor(Color(COL_BLACK));
+ rMtf.Record(aOutDev.get());
+ aOutDev->SetLineColor(Color(COL_BLACK));
+ aOutDev->SetFillColor(Color(COL_BLACK));
while (!bEoDt && !rInp.GetError()) {
ReadSgfVector( rInp, aVect ); RecNr++;
@@ -429,15 +429,15 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt
switch(nOTyp) {
case 1: if (nFarb!=nFrb0) {
switch(rHead.SwGrCol) {
- case SgfVectFarb: aOutDev.SetLineColor(Hpgl2SvFarbe(nFarb)); break;
+ case SgfVectFarb: aOutDev->SetLineColor(Hpgl2SvFarbe(nFarb)); break;
case SgfVectGray: break;
case SgfVectWdth: break;
}
}
- aOutDev.DrawLine(aP0,aP1); break; // line
+ aOutDev->DrawLine(aP0,aP1); break; // line
case 2: break; // circle
case 3: break; // text
- case 5: aOutDev.DrawRect(Rectangle(aP0,aP1)); break; // rectangle (solid)
+ case 5: aOutDev->DrawRect(Rectangle(aP0,aP1)); break; // rectangle (solid)
}
}
aP0=aP1;
diff --git a/vcl/source/filter/sgvmain.cxx b/vcl/source/filter/sgvmain.cxx
index 63526dccecad..ca754c28e4d9 100644
--- a/vcl/source/filter/sgvmain.cxx
+++ b/vcl/source/filter/sgvmain.cxx
@@ -794,13 +794,13 @@ bool SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf )
{
bool bRet = false;
PageType aPage;
- VirtualDevice aOutDev;
+ ScopedVclPtrInstance< VirtualDevice > aOutDev;
OutputDevice* pOutDev;
sal_uLong nStdPos;
sal_uLong nCharPos;
sal_uInt16 Num;
- pOutDev=&aOutDev;
+ pOutDev=aOutDev.get();
DtHdOverSeek(rInp); // read dataheader
nStdPos=rInp.Tell();
diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx
index 2a01dbcb3ae9..290ff1427912 100644
--- a/vcl/source/filter/sgvtext.cxx
+++ b/vcl/source/filter/sgvtext.cxx
@@ -660,7 +660,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
double, double,
UCHAR* cLine, bool TextFit)
{
- VirtualDevice vOut;
+ ScopedVclPtrInstance< VirtualDevice > vOut;
UCHAR c,c0;
bool First; // first char ?
sal_uInt8 Just = 0; // paragraph format
@@ -684,18 +684,18 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
sal_uInt16 i,j,k,h;
sal_uInt16 re,li;
- vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4)));
+ vOut->SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4)));
nChars=0;
- SetTextContext(vOut,AktAtr,false,0,1,1,1,1);
+ SetTextContext(*vOut.get(),AktAtr,false,0,1,1,1,1);
InitProcessCharState(*R,AktAtr,Index);
(*R0)=(*R); (*WErec)=(*R); WEnChar=0; c0=0; Border0=false;
Border=false; First=true;
WordEndCnt=0;
do { // check how many words to on that line
- if (Border) c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine);
- else c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
+ if (Border) c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine);
+ else c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
AbsEnd=(c==AbsatzEnd || c==TextEnd);
//if not AbsEnd then
{
@@ -729,8 +729,8 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
(*TRrec)=(*R); TRnChar=nChars;
Border0=false; Border=false;
do { // first check how many syllables fit
- UCHAR ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
- c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
+ UCHAR ct=ProcessChar(*vOut.get(),TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
+ c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars);
Border=TRrec->ChrXP>UmbWdt;
@@ -754,7 +754,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
} while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn))));
while (WErec0->Index<WErec->Index) { // to assure Line[] matches }
- ProcessChar(vOut,TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine);
+ ProcessChar(*vOut.get(),TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine);
}
(*R)=(*WErec); nChars=WEnChar;
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index ea74f6b618ad..3d50e2667bd9 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -266,7 +266,7 @@ void EMFWriter::ImplWritePlusColor( const Color& rColor, const sal_uInt32& nTran
void EMFWriter::ImplWritePlusPoint( const Point& rPoint )
{
// Convert to pixels
- const Point aPoint(maVDev.LogicToPixel( rPoint, maDestMapMode ));
+ const Point aPoint(maVDev->LogicToPixel( rPoint, maDestMapMode ));
m_rStm.WriteUInt16( aPoint.X() ).WriteUInt16( aPoint.Y() );
}
@@ -276,7 +276,7 @@ void EMFWriter::ImplWritePlusFillPolygonRecord( const Polygon& rPoly, const sal_
if( rPoly.GetSize() )
{
ImplBeginPlusRecord( EmfPlusFillPolygon, 0xC000 ); // Sets the color as well
- ImplWritePlusColor( maVDev.GetFillColor(), nTrans );
+ ImplWritePlusColor( maVDev->GetFillColor(), nTrans );
m_rStm.WriteUInt32( rPoly.GetSize() );
for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ )
ImplWritePlusPoint( rPoly[ i ] );
@@ -289,8 +289,8 @@ bool EMFWriter::WriteEMF(const GDIMetaFile& rMtf)
{
const sal_uLong nHeaderPos = m_rStm.Tell();
- maVDev.EnableOutput( false );
- maVDev.SetMapMode( rMtf.GetPrefMapMode() );
+ maVDev->EnableOutput( false );
+ maVDev->SetMapMode( rMtf.GetPrefMapMode() );
// don't work with pixel as destination map mode -> higher resolution preferrable
maDestMapMode.SetMapUnit( MAP_100TH_MM );
mpHandlesUsed = new bool[ MAXHANDLES ];
@@ -301,7 +301,7 @@ bool EMFWriter::WriteEMF(const GDIMetaFile& rMtf)
mnLineHandle = mnFillHandle = mnTextHandle = HANDLE_INVALID;
mnHorTextAlign = 0;
- const Size aMtfSizePix( maVDev.LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) );
+ const Size aMtfSizePix( maVDev->LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) );
const Size aMtfSizeLog( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
// seek over header
@@ -319,7 +319,7 @@ bool EMFWriter::WriteEMF(const GDIMetaFile& rMtf)
ImplEndRecord();
ImplBeginRecord( WIN_EMR_SETVIEWPORTEXTEX );
- m_rStm.WriteInt32( maVDev.GetDPIX() ).WriteInt32( maVDev.GetDPIY() );
+ m_rStm.WriteInt32( maVDev->GetDPIX() ).WriteInt32( maVDev->GetDPIY() );
ImplEndRecord();
ImplBeginRecord( WIN_EMR_SETWINDOWEXTEX );
@@ -466,12 +466,12 @@ void EMFWriter::ImplCheckLineAttr()
{
if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) )
{
- sal_uInt32 nStyle = maVDev.IsLineColor() ? 0 : 5;
+ sal_uInt32 nStyle = maVDev->IsLineColor() ? 0 : 5;
sal_uInt32 nWidth = 0, nHeight = 0;
ImplBeginRecord( WIN_EMR_CREATEPEN );
m_rStm.WriteUInt32( mnLineHandle ).WriteUInt32( nStyle ).WriteUInt32( nWidth ).WriteUInt32( nHeight );
- ImplWriteColor( maVDev.GetLineColor() );
+ ImplWriteColor( maVDev->GetLineColor() );
ImplEndRecord();
ImplBeginRecord( WIN_EMR_SELECTOBJECT );
@@ -484,12 +484,12 @@ void EMFWriter::ImplCheckFillAttr()
{
if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) )
{
- sal_uInt32 nStyle = maVDev.IsFillColor() ? 0 : 1;
+ sal_uInt32 nStyle = maVDev->IsFillColor() ? 0 : 1;
sal_uInt32 nPatternStyle = 0;
ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT );
m_rStm.WriteUInt32( mnFillHandle ).WriteUInt32( nStyle );
- ImplWriteColor( maVDev.GetFillColor() );
+ ImplWriteColor( maVDev->GetFillColor() );
m_rStm.WriteUInt32( nPatternStyle );
ImplEndRecord();
@@ -503,7 +503,7 @@ void EMFWriter::ImplCheckTextAttr()
{
if( mbTextChanged && ImplPrepareHandleSelect( mnTextHandle, TEXT_SELECT ) )
{
- const vcl::Font& rFont = maVDev.GetFont();
+ const vcl::Font& rFont = maVDev->GetFont();
OUString aFontName( rFont.GetName() );
sal_Int32 nWeight;
sal_uInt16 i;
@@ -601,7 +601,7 @@ void EMFWriter::ImplCheckTextAttr()
// Text color
ImplBeginRecord( WIN_EMR_SETTEXTCOLOR );
- ImplWriteColor( maVDev.GetTextColor() );
+ ImplWriteColor( maVDev->GetTextColor() );
ImplEndRecord();
ImplBeginRecord( WIN_EMR_SELECTOBJECT );
@@ -638,25 +638,25 @@ void EMFWriter::ImplWriteRasterOp( RasterOp eRop )
void EMFWriter::ImplWriteExtent( long nExtent )
{
- nExtent = OutputDevice::LogicToLogic( Size( nExtent, 0 ), maVDev.GetMapMode(), maDestMapMode ).Width();
+ nExtent = OutputDevice::LogicToLogic( Size( nExtent, 0 ), maVDev->GetMapMode(), maDestMapMode ).Width();
m_rStm.WriteInt32( nExtent );
}
void EMFWriter::ImplWritePoint( const Point& rPoint )
{
- const Point aPoint( OutputDevice::LogicToLogic( rPoint, maVDev.GetMapMode(), maDestMapMode ));
+ const Point aPoint( OutputDevice::LogicToLogic( rPoint, maVDev->GetMapMode(), maDestMapMode ));
m_rStm.WriteInt32( aPoint.X() ).WriteInt32( aPoint.Y() );
}
void EMFWriter::ImplWriteSize( const Size& rSize)
{
- const Size aSize( OutputDevice::LogicToLogic( rSize, maVDev.GetMapMode(), maDestMapMode ));
+ const Size aSize( OutputDevice::LogicToLogic( rSize, maVDev->GetMapMode(), maDestMapMode ));
m_rStm.WriteInt32( aSize.Width() ).WriteInt32( aSize.Height() );
}
void EMFWriter::ImplWriteRect( const Rectangle& rRect )
{
- const Rectangle aRect( OutputDevice::LogicToLogic ( rRect, maVDev.GetMapMode(), maDestMapMode ));
+ const Rectangle aRect( OutputDevice::LogicToLogic ( rRect, maVDev->GetMapMode(), maDestMapMode ));
m_rStm
.WriteInt32( aRect.Left() )
.WriteInt32( aRect.Top() )
@@ -840,7 +840,7 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt,
const sal_uLong nOffPos = m_rStm.Tell();
m_rStm.SeekRel( 16 );
- m_rStm.WriteUInt32( 0 ).WriteInt32( ( ROP_XOR == maVDev.GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP );
+ m_rStm.WriteUInt32( 0 ).WriteInt32( ( ROP_XOR == maVDev->GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP );
ImplWriteSize( rSz );
WriteDIB(rBmp, aMemStm, true, false);
@@ -898,19 +898,19 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c
// get text sizes
if( pDXArray )
{
- nNormWidth = maVDev.GetTextWidth( rText );
+ nNormWidth = maVDev->GetTextWidth( rText );
pDX = const_cast<long*>(pDXArray);
}
else
{
pOwnArray.reset(new long[ nLen ]);
- nNormWidth = maVDev.GetTextArray( rText, pOwnArray.get() );
+ nNormWidth = maVDev->GetTextArray( rText, pOwnArray.get() );
pDX = pOwnArray.get();
}
if( nLen > 1 )
{
- nNormWidth = pDX[ nLen - 2 ] + maVDev.GetTextWidth( OUString(rText[ nLen - 1 ]) );
+ nNormWidth = pDX[ nLen - 2 ] + maVDev->GetTextWidth( OUString(rText[ nLen - 1 ]) );
if( nWidth && nNormWidth && ( nWidth != nNormWidth ) )
{
@@ -924,7 +924,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c
// write text record
ImplBeginRecord( WIN_EMR_EXTTEXTOUTW );
- ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev.GetTextHeight() ) ) );
+ ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev->GetTextHeight() ) ) );
m_rStm.WriteUInt32( 1 );
m_rStm.WriteInt32( 0 ).WriteInt32( 0 );
ImplWritePoint( rPos );
@@ -975,11 +975,11 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
if(aFillPolyPolygon.count())
{
- const Color aOldLineColor(maVDev.GetLineColor());
- const Color aOldFillColor(maVDev.GetFillColor());
+ const Color aOldLineColor(maVDev->GetLineColor());
+ const Color aOldFillColor(maVDev->GetFillColor());
- maVDev.SetLineColor();
- maVDev.SetFillColor(aOldLineColor);
+ maVDev->SetLineColor();
+ maVDev->SetFillColor(aOldLineColor);
for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++)
{
@@ -987,8 +987,8 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
ImplWritePolyPolygonRecord(tools::PolyPolygon(Polygon(aPolygon)));
}
- maVDev.SetLineColor(aOldLineColor);
- maVDev.SetFillColor(aOldFillColor);
+ maVDev->SetLineColor(aOldLineColor);
+ maVDev->SetFillColor(aOldFillColor);
}
}
}
@@ -1016,14 +1016,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_POINT_ACTION ):
{
- if( maVDev.IsLineColor() )
+ if( maVDev->IsLineColor() )
{
const MetaPointAction* pA = static_cast<const MetaPointAction*>(pAction);
ImplCheckLineAttr();
ImplBeginRecord( WIN_EMR_SETPIXELV );
ImplWritePoint( pA->GetPoint() );
- ImplWriteColor( maVDev.GetLineColor() );
+ ImplWriteColor( maVDev->GetLineColor() );
ImplEndRecord();
}
}
@@ -1031,7 +1031,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_LINE_ACTION ):
{
- if( maVDev.IsLineColor() )
+ if( maVDev->IsLineColor() )
{
const MetaLineAction* pA = static_cast<const MetaLineAction*>(pAction);
@@ -1049,7 +1049,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
ImplBeginRecord( WIN_EMR_SETPIXELV );
ImplWritePoint( pA->GetEndPoint() );
- ImplWriteColor( maVDev.GetLineColor() );
+ ImplWriteColor( maVDev->GetLineColor() );
ImplEndRecord();
}
else
@@ -1066,7 +1066,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_RECT_ACTION ):
{
- if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ if( maVDev->IsLineColor() || maVDev->IsFillColor() )
{
const MetaRectAction* pA = static_cast<const MetaRectAction*>(pAction);
@@ -1082,7 +1082,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_ROUNDRECT_ACTION ):
{
- if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ if( maVDev->IsLineColor() || maVDev->IsFillColor() )
{
const MetaRoundRectAction* pA = static_cast<const MetaRoundRectAction*>(pAction);
@@ -1099,7 +1099,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_ELLIPSE_ACTION ):
{
- if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ if( maVDev->IsLineColor() || maVDev->IsFillColor() )
{
const MetaEllipseAction* pA = static_cast<const MetaEllipseAction*>(pAction);
@@ -1118,7 +1118,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_CHORD_ACTION ):
case( META_POLYGON_ACTION ):
{
- if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ if( maVDev->IsLineColor() || maVDev->IsFillColor() )
{
Polygon aPoly;
@@ -1157,7 +1157,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_POLYLINE_ACTION ):
{
- if( maVDev.IsLineColor() )
+ if( maVDev->IsLineColor() )
{
const MetaPolyLineAction* pA = static_cast<const MetaPolyLineAction*>(pAction);
const Polygon& rPoly = pA->GetPolygon();
@@ -1180,7 +1180,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_POLYPOLYGON_ACTION ):
{
- if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ if( maVDev->IsLineColor() || maVDev->IsFillColor() )
ImplWritePolyPolygonRecord( static_cast<const MetaPolyPolygonAction*>(pAction)->GetPolyPolygon() );
}
break;
@@ -1190,7 +1190,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pAction);
GDIMetaFile aTmpMtf;
- maVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+ maVDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
ImplWrite( aTmpMtf );
}
break;
@@ -1200,7 +1200,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pAction);
GDIMetaFile aTmpMtf;
- maVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+ maVDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
ImplWrite( aTmpMtf );
}
break;
@@ -1261,19 +1261,19 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
const MetaAction* pSubstAct = aSubstitute.GetAction( i );
if( pSubstAct->GetType() == META_BMPSCALE_ACTION )
{
- maVDev.Push( PushFlags::ALL );
+ maVDev->Push( PushFlags::ALL );
ImplBeginRecord( WIN_EMR_SAVEDC );
ImplEndRecord();
MapMode aMapMode( aSubstitute.GetPrefMapMode() );
- Size aOutSize( OutputDevice::LogicToLogic( pA->GetSize(), maVDev.GetMapMode(), aMapMode ) );
+ Size aOutSize( OutputDevice::LogicToLogic( pA->GetSize(), maVDev->GetMapMode(), aMapMode ) );
aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) );
aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) );
- aMapMode.SetOrigin( OutputDevice::LogicToLogic( pA->GetPoint(), maVDev.GetMapMode(), aMapMode ) );
- maVDev.SetMapMode( aMapMode );
+ aMapMode.SetOrigin( OutputDevice::LogicToLogic( pA->GetPoint(), maVDev->GetMapMode(), aMapMode ) );
+ maVDev->SetMapMode( aMapMode );
ImplWrite( aSubstitute );
- maVDev.Pop();
+ maVDev->Pop();
ImplBeginRecord( WIN_EMR_RESTOREDC );
m_rStm.WriteInt32( -1 );
ImplEndRecord();
@@ -1286,7 +1286,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case META_BMP_ACTION:
{
const MetaBmpAction* pA = static_cast<const MetaBmpAction *>(pAction);
- ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), maVDev.PixelToLogic( pA->GetBitmap().GetSizePixel() ), WIN_SRCCOPY );
+ ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), maVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ), WIN_SRCCOPY );
}
break;
@@ -1317,8 +1317,8 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
{
aBmp.Replace( aMsk, COL_WHITE );
aMsk.Invert();
- ImplWriteBmpRecord( aMsk, pA->GetPoint(), maVDev.PixelToLogic( aMsk.GetSizePixel() ), WIN_SRCPAINT );
- ImplWriteBmpRecord( aBmp, pA->GetPoint(), maVDev.PixelToLogic( aBmp.GetSizePixel() ), WIN_SRCAND );
+ ImplWriteBmpRecord( aMsk, pA->GetPoint(), maVDev->PixelToLogic( aMsk.GetSizePixel() ), WIN_SRCPAINT );
+ ImplWriteBmpRecord( aBmp, pA->GetPoint(), maVDev->PixelToLogic( aBmp.GetSizePixel() ), WIN_SRCAND );
}
else
ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCCOPY );
@@ -1405,14 +1405,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_LINECOLOR_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
mbLineChanged = true;
}
break;
case( META_FILLCOLOR_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
mbFillChanged = true;
}
break;
@@ -1423,14 +1423,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_TEXTALIGN_ACTION ):
case( META_FONT_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
mbTextChanged = true;
}
break;
case( META_ISECTRECTCLIPREGION_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
ImplBeginRecord( WIN_EMR_INTERSECTCLIPRECT );
ImplWriteRect( static_cast<const MetaISectRectClipRegionAction*>(pAction)->GetRect() );
@@ -1442,18 +1442,18 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_ISECTREGIONCLIPREGION_ACTION ):
case( META_MOVECLIPREGION_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
}
break;
case( META_REFPOINT_ACTION ):
case( META_MAPMODE_ACTION ):
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
break;
case( META_PUSH_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
ImplBeginRecord( WIN_EMR_SAVEDC );
ImplEndRecord();
@@ -1462,20 +1462,20 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
case( META_POP_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
ImplBeginRecord( WIN_EMR_RESTOREDC );
m_rStm.WriteInt32( -1 );
ImplEndRecord();
- ImplWriteRasterOp( maVDev.GetRasterOp() );
+ ImplWriteRasterOp( maVDev->GetRasterOp() );
mbLineChanged = mbFillChanged = mbTextChanged = true;
}
break;
case( META_RASTEROP_ACTION ):
{
- const_cast<MetaAction*>(pAction)->Execute( &maVDev );
+ const_cast<MetaAction*>(pAction)->Execute( maVDev );
ImplWriteRasterOp( static_cast<const MetaRasterOpAction*>(pAction)->GetRasterOp() );
}
break;
diff --git a/vcl/source/filter/wmf/emfwr.hxx b/vcl/source/filter/wmf/emfwr.hxx
index 5bf294a0e323..d037bdeb9d6c 100644
--- a/vcl/source/filter/wmf/emfwr.hxx
+++ b/vcl/source/filter/wmf/emfwr.hxx
@@ -33,7 +33,7 @@ class EMFWriter
{
private:
- VirtualDevice maVDev;
+ ScopedVclPtr<VirtualDevice> maVDev;
MapMode maDestMapMode;
SvStream& m_rStm;
bool* mpHandlesUsed;
@@ -90,7 +90,8 @@ private:
public:
EMFWriter(SvStream &rStream)
- : m_rStm(rStream)
+ : maVDev( VclPtr<VirtualDevice>::Create() )
+ , m_rStm(rStream)
, mpHandlesUsed(NULL)
, mnHandleCount(0)
, mnRecordCount(0)
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index 72c20cb0ac25..740ac493f353 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -236,12 +236,11 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont )
{
// #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
SolarMutexGuard aGuard;
- VirtualDevice aVDev;
-
+ VclPtrInstance< VirtualDevice > pVDev;
// converting the cell height into a font height
aFont.SetSize( aFontSize );
- aVDev.SetFont( aFont );
- FontMetric aMetric( aVDev.GetFontMetric() );
+ pVDev->SetFont( aFont );
+ FontMetric aMetric( pVDev->GetFontMetric() );
long nHeight = aMetric.GetAscent() + aMetric.GetDescent();
if (nHeight)
{
@@ -1448,20 +1447,19 @@ void WinMtfOutput::DrawText( Point& rPosition, OUString& rText, long* pDXArry, b
{
// #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
SolarMutexGuard aGuard;
- VirtualDevice aVDev;
-
+ VclPtrInstance< VirtualDevice > pVDev;
sal_Int32 nTextWidth;
- aVDev.SetMapMode( MapMode( MAP_100TH_MM ) );
- aVDev.SetFont( maFont );
+ pVDev->SetMapMode( MapMode( MAP_100TH_MM ) );
+ pVDev->SetFont( maFont );
if( pDXArry )
{
sal_uInt32 nLen = rText.getLength();
- nTextWidth = aVDev.GetTextWidth( OUString(rText[ nLen - 1 ]) );
+ nTextWidth = pVDev->GetTextWidth( OUString(rText[ nLen - 1 ]) );
if( nLen > 1 )
nTextWidth += pDXArry[ nLen - 2 ];
}
else
- nTextWidth = aVDev.GetTextWidth( rText );
+ nTextWidth = pVDev->GetTextWidth( rText );
if( mnTextAlign & TA_UPDATECP )
rPosition = maActPos;
@@ -1497,12 +1495,11 @@ void WinMtfOutput::DrawText( Point& rPosition, OUString& rText, long* pDXArry, b
{
// #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
SolarMutexGuard aGuard;
- VirtualDevice aVDev;
-
+ VclPtrInstance< VirtualDevice > pVDev;
pDX = new long[ rText.getLength() ];
- aVDev.SetMapMode( MAP_100TH_MM );
- aVDev.SetFont( maLatestFont );
- aVDev.GetTextArray( rText, pDX, 0, rText.getLength());
+ pVDev->SetMapMode( MAP_100TH_MM );
+ pVDev->SetFont( maLatestFont );
+ pVDev->GetTextArray( rText, pDX, 0, rText.getLength());
}
mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, rText.getLength() ) );
if ( !pDXArry ) // this means we have created our own array
@@ -1516,26 +1513,26 @@ void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const B
BitmapEx aBmpEx( rBitmap );
if ( mbComplexClip )
{
- VirtualDevice aVDev;
+ VclPtrInstance< VirtualDevice > pVDev;
MapMode aMapMode( MAP_100TH_MM );
aMapMode.SetOrigin( Point( -rPos.X(), -rPos.Y() ) );
- const Size aOutputSizePixel( aVDev.LogicToPixel( rSize, aMapMode ) );
+ const Size aOutputSizePixel( pVDev->LogicToPixel( rSize, aMapMode ) );
const Size aSizePixel( rBitmap.GetSizePixel() );
if ( aOutputSizePixel.Width() && aOutputSizePixel.Height() )
{
aMapMode.SetScaleX( Fraction( aSizePixel.Width(), aOutputSizePixel.Width() ) );
aMapMode.SetScaleY( Fraction( aSizePixel.Height(), aOutputSizePixel.Height() ) );
}
- aVDev.SetMapMode( aMapMode );
- aVDev.SetOutputSizePixel( aSizePixel );
- aVDev.SetFillColor( Color( COL_BLACK ) );
+ pVDev->SetMapMode( aMapMode );
+ pVDev->SetOutputSizePixel( aSizePixel );
+ pVDev->SetFillColor( Color( COL_BLACK ) );
const tools::PolyPolygon aClip( aClipPath.getClipPath() );
- aVDev.DrawPolyPolygon( aClip );
+ pVDev->DrawPolyPolygon( aClip );
const Point aEmptyPoint;
// #i50672# Extract whole VDev content (to match size of rBitmap)
- aVDev.EnableMapMode( false );
- Bitmap aMask( aVDev.GetBitmap( aEmptyPoint, aSizePixel ).CreateMask( Color( COL_WHITE ) ) );
+ pVDev->EnableMapMode( false );
+ Bitmap aMask( pVDev->GetBitmap( aEmptyPoint, aSizePixel ).CreateMask( Color( COL_WHITE ) ) );
if ( aBmpEx.IsTransparent() )
{
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index 2b6e6a40ddcd..dc98e2eae9b6 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -1815,7 +1815,7 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream,
delete pAt;
}
- delete pVirDev;
+ pVirDev.disposeAndClear();
if ( xStatusIndicator.is() )
xStatusIndicator->end();
diff --git a/vcl/source/filter/wmf/wmfwr.hxx b/vcl/source/filter/wmf/wmfwr.hxx
index c27a8eb3be7f..c017eb53aa61 100644
--- a/vcl/source/filter/wmf/wmfwr.hxx
+++ b/vcl/source/filter/wmf/wmfwr.hxx
@@ -58,7 +58,7 @@ private:
com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
SvStream* pWMF;
- VirtualDevice* pVirDev;
+ VclPtr<VirtualDevice> pVirDev;
MapMode aTargetMapMode;
Size aTargetSize;
diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx
index f83581fd8bba..4ab246f0d713 100644
--- a/vcl/source/gdi/animate.cxx
+++ b/vcl/source/gdi/animate.cxx
@@ -802,4 +802,10 @@ SvStream& ReadAnimation( SvStream& rIStm, Animation& rAnimation )
return rIStm;
}
+AInfo::AInfo() : pOutDev( NULL ),
+ pViewData( NULL ),
+ nExtraData( 0L ),
+ bWithSize( false ),
+ bPause( false ) {}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 79ae295b3f74..80cb6f832b29 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -706,16 +706,16 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize
Size aStdSize( aStandardSize, aStandardSize );
Rectangle aRect(aEmptyPoint, aStdSize );
- VirtualDevice aVirDevice( *Application::GetDefaultDevice(), 0, 1 );
- aVirDevice.SetOutputSizePixel( aStdSize );
- aVirDevice.SetFillColor( COL_TRANSPARENT );
- aVirDevice.SetLineColor( COL_TRANSPARENT );
+ ScopedVclPtrInstance< VirtualDevice > aVirDevice( *Application::GetDefaultDevice(), 0, 1 );
+ aVirDevice->SetOutputSizePixel( aStdSize );
+ aVirDevice->SetFillColor( COL_TRANSPARENT );
+ aVirDevice->SetLineColor( COL_TRANSPARENT );
// Draw a rect into virDevice
- aVirDevice.DrawRect( aRect );
+ aVirDevice->DrawRect( aRect );
Point aPointPixel( (long)imgposX, (long)imgposY );
- aVirDevice.DrawBitmapEx( aPointPixel, aRet );
- aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize );
+ aVirDevice->DrawBitmapEx( aPointPixel, aRet );
+ aRet = aVirDevice->GetBitmapEx( aEmptyPoint, aStdSize );
return aRet;
}
diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx
index 3ef048230e30..8509f66d8eaf 100644
--- a/vcl/source/gdi/cvtsvm.cxx
+++ b/vcl/source/gdi/cvtsvm.cxx
@@ -497,8 +497,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
}
LineInfo aLineInfo( LINE_NONE, 0 );
- ::std::stack< LineInfo* > aLIStack;
- VirtualDevice aFontVDev;
+ ::std::stack< LineInfo* > aLIStack;
+ ScopedVclPtrInstance< VirtualDevice > aFontVDev;
rtl_TextEncoding eActualCharSet = osl_getThreadTextEncoding();
bool bFatLine = false;
@@ -848,7 +848,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rMtf.AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) );
// #106172# Track font relevant data in shadow VDev
- aFontVDev.SetFont( aFont );
+ aFontVDev->SetFont( aFont );
}
break;
@@ -904,7 +904,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
{
boost::scoped_array<long> pTmpAry(new long[nStrLen]);
- aFontVDev.GetTextArray( aStr, pTmpAry.get(), nIndex, nLen );
+ aFontVDev->GetTextArray( aStr, pTmpAry.get(), nIndex, nLen );
// now, the difference between the
// last and the second last DX array
@@ -1022,7 +1022,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rMtf.AddAction( new MetaMapModeAction( aMapMode ) );
// #106172# Track font relevant data in shadow VDev
- aFontVDev.SetMapMode( aMapMode );
+ aFontVDev->SetMapMode( aMapMode );
}
break;
@@ -1132,7 +1132,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rMtf.AddAction( new MetaPushAction( PushFlags::ALL ) );
// #106172# Track font relevant data in shadow VDev
- aFontVDev.Push();
+ aFontVDev->Push();
}
break;
@@ -1159,7 +1159,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rMtf.AddAction( new MetaPopAction() );
// #106172# Track font relevant data in shadow VDev
- aFontVDev.Pop();
+ aFontVDev->Pop();
}
break;
@@ -1259,9 +1259,9 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
// #106172# Track font relevant data in shadow VDev
if( bSet )
- aFontVDev.SetRefPoint( aRefPoint );
+ aFontVDev->SetRefPoint( aRefPoint );
else
- aFontVDev.SetRefPoint();
+ aFontVDev->SetRefPoint();
}
break;
@@ -1374,7 +1374,7 @@ void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf )
rtl_TextEncoding eActualCharSet = osl_getThreadTextEncoding();
const Size aPrefSize( rMtf.GetPrefSize() );
bool bRop_0_1 = false;
- VirtualDevice aSaveVDev;
+ ScopedVclPtrInstance< VirtualDevice > aSaveVDev;
Color aLineCol( COL_BLACK );
::std::stack< Color* > aLineColStack;
@@ -1392,7 +1392,7 @@ void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf )
nCountPos = rOStm.Tell();
rOStm.SeekRel( 4L );
- const sal_Int32 nActCount = ImplWriteActions( rOStm, rMtf, aSaveVDev, bRop_0_1, aLineCol, aLineColStack, eActualCharSet );
+ const sal_Int32 nActCount = ImplWriteActions( rOStm, rMtf, *aSaveVDev.get(), bRop_0_1, aLineCol, aLineColStack, eActualCharSet );
const sal_uLong nActPos = rOStm.Tell();
rOStm.Seek( nCountPos );
@@ -2311,10 +2311,10 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf,
{
// write actions for hatch
- VirtualDevice aVDev;
+ ScopedVclPtrInstance< VirtualDevice > aVDev;
GDIMetaFile aTmpMtf;
- aVDev.AddHatchActions( rPolyPoly, rHatch, aTmpMtf );
+ aVDev->AddHatchActions( rPolyPoly, rHatch, aTmpMtf );
nAddCount = ImplWriteActions( rOStm, aTmpMtf, rSaveVDev, rRop_0_1, rLineCol, rLineColStack, rActualCharSet );
nNewPos = rOStm.Tell();
rOStm.Seek( nOldPos );
diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx
index 3fa559a6abb8..1c19a11a4305 100644
--- a/vcl/source/gdi/gdimetafiletools.cxx
+++ b/vcl/source/gdi/gdimetafiletools.cxx
@@ -161,23 +161,23 @@ namespace
// in pixel mode for alpha channel painting (black is transparent,
// white to paint 100% opacity)
const Size aSizePixel(rBitmapEx.GetSizePixel());
- VirtualDevice aVDev;
+ ScopedVclPtrInstance< VirtualDevice > aVDev;
- aVDev.SetOutputSizePixel(aSizePixel);
- aVDev.EnableMapMode(false);
- aVDev.SetFillColor(COL_WHITE);
- aVDev.SetLineColor();
+ aVDev->SetOutputSizePixel(aSizePixel);
+ aVDev->EnableMapMode(false);
+ aVDev->SetFillColor(COL_WHITE);
+ aVDev->SetLineColor();
if(rBitmapEx.IsTransparent())
{
// use given alpha channel
- aVDev.DrawBitmap(Point(0, 0), rBitmapEx.GetAlpha().GetBitmap());
+ aVDev->DrawBitmap(Point(0, 0), rBitmapEx.GetAlpha().GetBitmap());
}
else
{
// reset alpha channel
- aVDev.SetBackground(Wallpaper(Color(COL_BLACK)));
- aVDev.Erase();
+ aVDev->SetBackground(Wallpaper(Color(COL_BLACK)));
+ aVDev->Erase();
}
// transform polygon from clipping to pixel coordinates
@@ -203,11 +203,11 @@ namespace
aInvertPixelPoly.append(aPixelPoly);
// paint as alpha
- aVDev.DrawPolyPolygon(aInvertPixelPoly);
+ aVDev->DrawPolyPolygon(aInvertPixelPoly);
// get created alpha mask and set defaults
AlphaMask aAlpha(
- aVDev.GetBitmap(
+ aVDev->GetBitmap(
Point(0, 0),
aSizePixel));
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index a761a5d07516..0eafc4f67e38 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -723,10 +723,10 @@ void GDIMetaFile::Move( long nX, long nY )
{
const Size aBaseOffset( nX, nY );
Size aOffset( aBaseOffset );
- VirtualDevice aMapVDev;
+ ScopedVclPtrInstance< VirtualDevice > aMapVDev;
- aMapVDev.EnableOutput( false );
- aMapVDev.SetMapMode( GetPrefMapMode() );
+ aMapVDev->EnableOutput( false );
+ aMapVDev->SetMapMode( GetPrefMapMode() );
for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
{
@@ -745,8 +745,8 @@ void GDIMetaFile::Move( long nX, long nY )
( META_PUSH_ACTION == nType ) ||
( META_POP_ACTION == nType ) )
{
- pModAct->Execute( &aMapVDev );
- aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() );
+ pModAct->Execute( aMapVDev.get() );
+ aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() );
}
pModAct->Move( aOffset.Width(), aOffset.Height() );
@@ -757,11 +757,11 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY )
{
const Size aBaseOffset( nX, nY );
Size aOffset( aBaseOffset );
- VirtualDevice aMapVDev;
+ ScopedVclPtrInstance< VirtualDevice > aMapVDev;
- aMapVDev.EnableOutput( false );
- aMapVDev.SetReferenceDevice( nDPIX, nDPIY );
- aMapVDev.SetMapMode( GetPrefMapMode() );
+ aMapVDev->EnableOutput( false );
+ aMapVDev->SetReferenceDevice( nDPIX, nDPIY );
+ aMapVDev->SetMapMode( GetPrefMapMode() );
for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
{
@@ -780,16 +780,16 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY )
( META_PUSH_ACTION == nType ) ||
( META_POP_ACTION == nType ) )
{
- pModAct->Execute( &aMapVDev );
- if( aMapVDev.GetMapMode().GetMapUnit() == MAP_PIXEL )
+ pModAct->Execute( aMapVDev.get() );
+ if( aMapVDev->GetMapMode().GetMapUnit() == MAP_PIXEL )
{
- aOffset = aMapVDev.LogicToPixel( aBaseOffset, GetPrefMapMode() );
- MapMode aMap( aMapVDev.GetMapMode() );
+ aOffset = aMapVDev->LogicToPixel( aBaseOffset, GetPrefMapMode() );
+ MapMode aMap( aMapVDev->GetMapMode() );
aOffset.Width() = static_cast<long>(aOffset.Width() * (double)aMap.GetScaleX());
aOffset.Height() = static_cast<long>(aOffset.Height() * (double)aMap.GetScaleY());
}
else
- aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() );
+ aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() );
}
pModAct->Move( aOffset.Width(), aOffset.Height() );
@@ -825,10 +825,10 @@ void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY )
void GDIMetaFile::Clip( const Rectangle& i_rClipRect )
{
Rectangle aCurRect( i_rClipRect );
- VirtualDevice aMapVDev;
+ ScopedVclPtrInstance< VirtualDevice > aMapVDev;
- aMapVDev.EnableOutput( false );
- aMapVDev.SetMapMode( GetPrefMapMode() );
+ aMapVDev->EnableOutput( false );
+ aMapVDev->SetMapMode( GetPrefMapMode() );
for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
{
@@ -838,8 +838,8 @@ void GDIMetaFile::Clip( const Rectangle& i_rClipRect )
( META_PUSH_ACTION == nType ) ||
( META_POP_ACTION == nType ) )
{
- pAct->Execute( &aMapVDev );
- aCurRect = OutputDevice::LogicToLogic( i_rClipRect, GetPrefMapMode(), aMapVDev.GetMapMode() );
+ pAct->Execute( aMapVDev.get() );
+ aCurRect = OutputDevice::LogicToLogic( i_rClipRect, GetPrefMapMode(), aMapVDev->GetMapMode() );
}
else if( nType == META_CLIPREGION_ACTION )
{
@@ -892,12 +892,12 @@ void GDIMetaFile::ImplAddGradientEx( GDIMetaFile& rMtf,
const Gradient& rGrad )
{
// Generate comment, GradientEx and Gradient actions (within DrawGradient)
- VirtualDevice aVDev( rMapDev, 0 );
- aVDev.EnableOutput( false );
+ ScopedVclPtrInstance< VirtualDevice > aVDev( rMapDev, 0 );
+ aVDev->EnableOutput( false );
GDIMetaFile aGradMtf;
- aGradMtf.Record( &aVDev );
- aVDev.DrawGradient( rPolyPoly, rGrad );
+ aGradMtf.Record( aVDev.get() );
+ aVDev->DrawGradient( rPolyPoly, rGrad );
aGradMtf.Stop();
size_t i, nAct( aGradMtf.GetActionSize() );
@@ -917,7 +917,7 @@ void GDIMetaFile::Rotate( long nAngle10 )
if( nAngle10 )
{
GDIMetaFile aMtf;
- VirtualDevice aMapVDev;
+ ScopedVclPtrInstance< VirtualDevice > aMapVDev;
const double fAngle = F_PI1800 * nAngle10;
const double fSin = sin( fAngle );
const double fCos = cos( fAngle );
@@ -926,8 +926,8 @@ void GDIMetaFile::Rotate( long nAngle10 )
aPoly.Rotate( Point(), fSin, fCos );
- aMapVDev.EnableOutput( false );
- aMapVDev.SetMapMode( GetPrefMapMode() );
+ aMapVDev->EnableOutput( false );
+ aMapVDev->SetMapMode( GetPrefMapMode() );
const Rectangle aNewBound( aPoly.GetBoundRect() );
@@ -1130,7 +1130,7 @@ void GDIMetaFile::Rotate( long nAngle10 )
{
MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
- ImplAddGradientEx( aMtf, aMapVDev,
+ ImplAddGradientEx( aMtf, *aMapVDev.get(),
ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ),
pAct->GetGradient() );
}
@@ -1162,7 +1162,7 @@ void GDIMetaFile::Rotate( long nAngle10 )
{
// Add rotated gradientex
MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
- ImplAddGradientEx( aMtf, aMapVDev,
+ ImplAddGradientEx( aMtf, *aMapVDev.get(),
ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
pAct->GetGradient() );
}
@@ -1225,7 +1225,7 @@ void GDIMetaFile::Rotate( long nAngle10 )
else if ( pCommentAct->GetComment() == "XPATHSTROKE_SEQ_END"
|| pCommentAct->GetComment() == "XPATHFILL_SEQ_END" )
{
- pAction->Execute( &aMapVDev );
+ pAction->Execute( aMapVDev.get() );
pAction->Duplicate();
aMtf.AddAction( pAction );
}
@@ -1348,7 +1348,7 @@ void GDIMetaFile::Rotate( long nAngle10 )
default:
{
- pAction->Execute( &aMapVDev );
+ pAction->Execute( aMapVDev.get() );
pAction->Duplicate();
aMtf.AddAction( pAction );
@@ -1357,8 +1357,8 @@ void GDIMetaFile::Rotate( long nAngle10 )
( META_PUSH_ACTION == nActionType ) ||
( META_POP_ACTION == nActionType ) )
{
- aRotAnchor = OutputDevice::LogicToLogic( aOrigin, aPrefMapMode, aMapVDev.GetMapMode() );
- aRotOffset = OutputDevice::LogicToLogic( aOffset, aPrefMapMode, aMapVDev.GetMapMode() );
+ aRotAnchor = OutputDevice::LogicToLogic( aOrigin, aPrefMapMode, aMapVDev->GetMapMode() );
+ aRotOffset = OutputDevice::LogicToLogic( aOffset, aPrefMapMode, aMapVDev->GetMapMode() );
}
}
break;
@@ -1400,10 +1400,10 @@ static void ImplActionBounds( Rectangle& o_rOutBounds,
Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHairline ) const
{
GDIMetaFile aMtf;
- VirtualDevice aMapVDev( i_rReference );
+ ScopedVclPtrInstance< VirtualDevice > aMapVDev( i_rReference );
- aMapVDev.EnableOutput( false );
- aMapVDev.SetMapMode( GetPrefMapMode() );
+ aMapVDev->EnableOutput( false );
+ aMapVDev->SetMapMode( GetPrefMapMode() );
std::vector<Rectangle> aClipStack( 1, Rectangle() );
std::vector<PushFlags> aPushFlagStack;
@@ -1419,7 +1419,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaAction* pAction = GetAction(a);
const sal_uInt16 nActionType = pAction->GetType();
- Rectangle* pUseHairline = (pHairline && aMapVDev.IsLineColor()) ? pHairline : 0;
+ Rectangle* pUseHairline = (pHairline && aMapVDev->IsLineColor()) ? pHairline : 0;
switch( nActionType )
{
@@ -1427,8 +1427,8 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaPixelAction* pAct = static_cast<MetaPixelAction*>(pAction);
ImplActionBounds( aBound,
- Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ),
- aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
+ Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ),
+ aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
aClipStack, pUseHairline );
}
break;
@@ -1437,8 +1437,8 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaPointAction* pAct = static_cast<MetaPointAction*>(pAction);
ImplActionBounds( aBound,
- Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ),
- aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
+ Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ),
+ aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
aClipStack, pUseHairline );
}
break;
@@ -1458,28 +1458,28 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
pUseHairline = 0;
}
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
case( META_RECT_ACTION ):
{
MetaRectAction* pAct = static_cast<MetaRectAction*>(pAction);
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
case( META_ROUNDRECT_ACTION ):
{
MetaRoundRectAction* pAct = static_cast<MetaRoundRectAction*>(pAction);
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
case( META_ELLIPSE_ACTION ):
{
MetaEllipseAction* pAct = static_cast<MetaEllipseAction*>(pAction);
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1488,7 +1488,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
MetaArcAction* pAct = static_cast<MetaArcAction*>(pAction);
// FIXME: this is imprecise
// e.g. for small arcs the whole rectangle is WAY too large
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1497,7 +1497,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
MetaPieAction* pAct = static_cast<MetaPieAction*>(pAction);
// FIXME: this is imprecise
// e.g. for small arcs the whole rectangle is WAY too large
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1506,7 +1506,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
MetaChordAction* pAct = static_cast<MetaChordAction*>(pAction);
// FIXME: this is imprecise
// e.g. for small arcs the whole rectangle is WAY too large
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1523,7 +1523,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
pUseHairline = 0;
}
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1531,7 +1531,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaPolygonAction* pAct = static_cast<MetaPolygonAction*>(pAction);
Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1539,7 +1539,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaPolyPolygonAction* pAct = static_cast<MetaPolyPolygonAction*>(pAction);
Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
}
break;
@@ -1548,10 +1548,10 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
MetaTextAction* pAct = static_cast<MetaTextAction*>(pAction);
Rectangle aRect;
// hdu said base = index
- aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() );
+ aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() );
Point aPt( pAct->GetPoint() );
aRect.Move( aPt.X(), aPt.Y() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1560,11 +1560,11 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
MetaTextArrayAction* pAct = static_cast<MetaTextArrayAction*>(pAction);
Rectangle aRect;
// hdu said base = index
- aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
+ aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
0, pAct->GetDXArray() );
Point aPt( pAct->GetPoint() );
aRect.Move( aPt.X(), aPt.Y() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1573,11 +1573,11 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
MetaStretchTextAction* pAct = static_cast<MetaStretchTextAction*>(pAction);
Rectangle aRect;
// hdu said base = index
- aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
+ aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
pAct->GetWidth(), NULL );
Point aPt( pAct->GetPoint() );
aRect.Move( aPt.X(), aPt.Y() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1589,11 +1589,11 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
OUString aStr( pStr );
Rectangle aRect;
- aMapVDev.GetTextBoundRect( aRect, aStr, 0, 0, aStr.getLength(), 0, NULL );
+ aMapVDev->GetTextBoundRect( aRect, aStr, 0, 0, aStr.getLength(), 0, NULL );
Point aPt( pAct->GetStartPoint() );
aRect.Move( aPt.X(), aPt.Y() );
aRect.Right() = aRect.Left() + pAct->GetWidth();
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1601,7 +1601,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1609,7 +1609,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1617,7 +1617,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1625,7 +1625,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1633,7 +1633,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
Rectangle aRect( pAct->GetRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1641,7 +1641,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1655,7 +1655,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction);
Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1663,7 +1663,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pAction);
Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1673,7 +1673,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
// MetaFloatTransparentAction is defined limiting it's content Metafile
// to it's geometry definition(Point, Size), so use these directly
const Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1681,7 +1681,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1689,7 +1689,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaClipRegionAction* pAct = static_cast<MetaClipRegionAction*>(pAction);
if( pAct->IsClipping() )
- aClipStack.back() = OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() );
+ aClipStack.back() = OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev->GetMapMode(), GetPrefMapMode() );
else
aClipStack.back() = Rectangle();
}
@@ -1698,7 +1698,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
case( META_ISECTRECTCLIPREGION_ACTION ):
{
MetaISectRectClipRegionAction* pAct = static_cast<MetaISectRectClipRegionAction*>(pAction);
- Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) );
+ Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ) );
if( aClipStack.back().IsEmpty() )
aClipStack.back() = aRect;
else
@@ -1709,7 +1709,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
case( META_ISECTREGIONCLIPREGION_ACTION ):
{
MetaISectRegionClipRegionAction* pAct = static_cast<MetaISectRegionClipRegionAction*>(pAction);
- Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) );
+ Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ) );
if( aClipStack.back().IsEmpty() )
aClipStack.back() = aRect;
else
@@ -1720,24 +1720,24 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
case( META_BMP_ACTION ):
{
MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction);
- Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
case( META_BMPEX_ACTION ):
{
MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction);
- Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
case( META_MASK_ACTION ):
{
MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pAction);
- Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1745,7 +1745,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1753,7 +1753,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1761,7 +1761,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaWallpaperAction* pAct = static_cast<MetaWallpaperAction*>(pAction);
Rectangle aRect( pAct->GetRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1769,7 +1769,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
{
MetaTextRectAction* pAct = static_cast<MetaTextRectAction*>(pAction);
Rectangle aRect( pAct->GetRect() );
- ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
+ ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 );
}
break;
@@ -1779,7 +1779,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
if( ! aClipStack.back().IsEmpty() )
{
Size aDelta( pAct->GetHorzMove(), pAct->GetVertMove() );
- aDelta = OutputDevice::LogicToLogic( aDelta, aMapVDev.GetMapMode(), GetPrefMapMode() );
+ aDelta = OutputDevice::LogicToLogic( aDelta, aMapVDev->GetMapMode(), GetPrefMapMode() );
aClipStack.back().Move( aDelta.Width(), aDelta.Width() );
}
}
@@ -1787,7 +1787,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai
default:
{
- pAction->Execute( &aMapVDev );
+ pAction->Execute( aMapVDev.get() );
if( nActionType == META_PUSH_ACTION )
{
@@ -2890,11 +2890,11 @@ SvStream& GDIMetaFile::Write( SvStream& rOStm )
bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent, BmpConversion eColorConversion, long nScaleFlag) const
{
// initialization seems to be complicated but is used to avoid rounding errors
- VirtualDevice aVDev;
+ ScopedVclPtrInstance< VirtualDevice > aVDev;
const Point aNullPt;
- const Point aTLPix( aVDev.LogicToPixel( aNullPt, GetPrefMapMode() ) );
- const Point aBRPix( aVDev.LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) );
- Size aDrawSize( aVDev.LogicToPixel( GetPrefSize(), GetPrefMapMode() ) );
+ const Point aTLPix( aVDev->LogicToPixel( aNullPt, GetPrefMapMode() ) );
+ const Point aBRPix( aVDev->LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) );
+ Size aDrawSize( aVDev->LogicToPixel( GetPrefSize(), GetPrefMapMode() ) );
Size aSizePix( labs( aBRPix.X() - aTLPix.X() ) + 1, labs( aBRPix.Y() - aTLPix.Y() ) + 1 );
if (!rBitmapEx.IsEmpty())
@@ -2929,7 +2929,7 @@ bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent
// draw image(s) into VDev and get resulting image
// do it 4x larger to be able to scale it down & get beautiful antialias
Size aAntialiasSize(aSizePix.Width() * 4, aSizePix.Height() * 4);
- if (aVDev.SetOutputSizePixel(aAntialiasSize))
+ if (aVDev->SetOutputSizePixel(aAntialiasSize))
{
// antialias: provide 4x larger size, and then scale down the result
Size aAntialias(aDrawSize.Width() * 4, aDrawSize.Height() * 4);
@@ -2937,10 +2937,10 @@ bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent
// draw metafile into VDev
Point aBackPosPix;
const_cast<GDIMetaFile *>(this)->WindStart();
- const_cast<GDIMetaFile *>(this)->Play(&aVDev, aBackPosPix, aAntialias);
+ const_cast<GDIMetaFile *>(this)->Play(aVDev.get(), aBackPosPix, aAntialias);
// get paint bitmap
- Bitmap aBitmap( aVDev.GetBitmap( aNullPt, aVDev.GetOutputSizePixel() ) );
+ Bitmap aBitmap( aVDev->GetBitmap( aNullPt, aVDev->GetOutputSizePixel() ) );
// scale down the image to the desired size - use the input scaler for the scaling operation
aBitmap.Scale(aDrawSize, nScaleFlag);
diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx
index c3e7b793580c..b225280a6102 100644
--- a/vcl/source/gdi/impanmvw.cxx
+++ b/vcl/source/gdi/impanmvw.cxx
@@ -77,7 +77,7 @@ ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut,
MapMode aTempMap( mpOut->GetMapMode() );
aTempMap.SetOrigin( Point() );
mpBackground->SetMapMode( aTempMap );
- static_cast<vcl::Window*>( mpOut )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground );
+ static_cast<vcl::Window*>( mpOut.get() )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground );
mpBackground->SetMapMode( MapMode() );
}
else
@@ -93,8 +93,8 @@ ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut,
ImplAnimView::~ImplAnimView()
{
- delete mpBackground;
- delete mpRestore;
+ mpBackground.disposeAndClear();
+ mpRestore.disposeAndClear();
Animation::ImplDecAnimCount();
}
@@ -153,19 +153,19 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnm, Point& rPosPix, Size
void ImplAnimView::drawToPos( sal_uLong nPos )
{
- VirtualDevice aVDev;
+ ScopedVclPtrInstance<VirtualDevice> aVDev;
std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( mpOut->GetClipRegion() ) : NULL);
- aVDev.SetOutputSizePixel( maSzPix, false );
+ aVDev->SetOutputSizePixel( maSzPix, false );
nPos = std::min( nPos, (sal_uLong) mpParent->Count() - 1UL );
for( sal_uLong i = 0UL; i <= nPos; i++ )
- draw( i, &aVDev );
+ draw( i, aVDev.get() );
if (xOldClip)
mpOut->SetClipRegion( maClip );
- mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, aVDev );
+ mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, *aVDev.get() );
if (xOldClip)
mpOut->SetClipRegion(*xOldClip);
@@ -180,7 +180,7 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev )
setMarked( true );
else if( !mbPause )
{
- VirtualDevice* pDev;
+ VclPtr<VirtualDevice> pDev;
Point aPosPix;
Point aBmpPosPix;
Size aSizePix;
@@ -273,10 +273,10 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev )
xOldClip.reset();
}
- delete pDev;
+ pDev.disposeAndClear();
if( mpOut->GetOutDevType() == OUTDEV_WINDOW )
- static_cast<vcl::Window*>( mpOut )->Sync();
+ static_cast<vcl::Window*>( mpOut.get() )->Sync();
}
}
}
@@ -290,7 +290,7 @@ void ImplAnimView::repaint()
MapMode aTempMap( mpOut->GetMapMode() );
aTempMap.SetOrigin( Point() );
mpBackground->SetMapMode( aTempMap );
- static_cast<vcl::Window*>( mpOut )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground );
+ static_cast<vcl::Window*>( mpOut.get() )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground );
mpBackground->SetMapMode( MapMode() );
}
else
diff --git a/vcl/source/gdi/impanmvw.hxx b/vcl/source/gdi/impanmvw.hxx
index ce49476e0718..0955046d7f30 100644
--- a/vcl/source/gdi/impanmvw.hxx
+++ b/vcl/source/gdi/impanmvw.hxx
@@ -34,7 +34,7 @@ private:
friend class Animation;
Animation* mpParent;
- OutputDevice* mpOut;
+ VclPtr<OutputDevice> mpOut;
long mnExtraData;
Point maPt;
Point maDispPt;
@@ -45,8 +45,8 @@ private:
Size maRestSz;
MapMode maMap;
vcl::Region maClip;
- VirtualDevice* mpBackground;
- VirtualDevice* mpRestore;
+ VclPtr<VirtualDevice> mpBackground;
+ VclPtr<VirtualDevice> mpRestore;
sal_uLong mnActPos;
Disposal meLastDisposal;
bool mbPause;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 3f65281a7163..0aace4e88651 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -467,8 +467,8 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters)
if(maEx.IsEmpty())
{
// calculate size
- VirtualDevice aVDev;
- Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
+ ScopedVclPtrInstance< VirtualDevice > aVDev;
+ Size aDrawSize(aVDev->LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
{
@@ -502,7 +502,7 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters)
{
// get hairline and full bound rect
Rectangle aHairlineRect;
- const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect));
+ const Rectangle aRect(maMetaFile.GetBoundRect(*aVDev.get(), &aHairlineRect));
if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
{
@@ -519,22 +519,22 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters)
}
}
- if(aVDev.SetOutputSizePixel(aPixelSize))
+ if(aVDev->SetOutputSizePixel(aPixelSize))
{
if(rParameters.getAntiAliase())
{
- aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
+ aVDev->SetAntialiasing(aVDev->GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
}
if(rParameters.getSnapHorVerLines())
{
- aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
+ aVDev->SetAntialiasing(aVDev->GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
}
- ImplDraw( &aVDev, Point(), aDrawSize );
+ ImplDraw( aVDev.get(), Point(), aDrawSize );
// use maEx as local buffer for rendered metafile
- const_cast< ImpGraphic* >(this)->maEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
+ const_cast< ImpGraphic* >(this)->maEx = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() );
}
}
diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx
index 9a71a241fd65..bdb5f3114eeb 100644
--- a/vcl/source/gdi/impvect.cxx
+++ b/vcl/source/gdi/impvect.cxx
@@ -717,8 +717,8 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf,
if( rMtf.GetActionSize() )
{
MapMode aMap( MAP_100TH_MM );
- VirtualDevice aVDev;
- const Size aLogSize1( aVDev.PixelToLogic( Size( 1, 1 ), aMap ) );
+ ScopedVclPtrInstance< VirtualDevice > aVDev;
+ const Size aLogSize1( aVDev->PixelToLogic( Size( 1, 1 ), aMap ) );
rMtf.SetPrefMapMode( aMap );
rMtf.SetPrefSize( Size( nWidth + 2, nHeight + 2 ) );
diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx
index b1485a945f00..b71d9dd15654 100644
--- a/vcl/source/gdi/oldprintadaptor.cxx
+++ b/vcl/source/gdi/oldprintadaptor.cxx
@@ -44,8 +44,8 @@ using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
-OldStylePrintAdaptor::OldStylePrintAdaptor(const std::shared_ptr< Printer >& i_xPrinter)
- : PrinterController(i_xPrinter)
+OldStylePrintAdaptor::OldStylePrintAdaptor( const VclPtr< Printer >& i_xPrinter )
+ : PrinterController( i_xPrinter )
, mpData( new ImplOldStyleAdaptorData() )
{
}
@@ -64,7 +64,7 @@ void OldStylePrintAdaptor::StartPage()
getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );
// copy state into metafile
- std::shared_ptr<Printer> xPrinter(getPrinter());
+ VclPtr<Printer> xPrinter( getPrinter() );
xPrinter->SetMapMode(xPrinter->GetMapMode());
xPrinter->SetFont(xPrinter->GetFont());
xPrinter->SetDrawMode(xPrinter->GetDrawMode());
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 2a4166f4b951..9ed2d19e1644 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1874,7 +1874,7 @@ PDFWriterImpl::~PDFWriterImpl()
{
if( m_aDocDigest )
rtl_digest_destroyMD5( m_aDocDigest );
- delete static_cast<VirtualDevice*>(m_pReferenceDevice);
+ m_pReferenceDevice.disposeAndClear();
if( m_aCipher )
rtl_cipher_destroyARCFOUR( m_aCipher );
@@ -2220,7 +2220,7 @@ OutputDevice* PDFWriterImpl::getReferenceDevice()
{
if( ! m_pReferenceDevice )
{
- VirtualDevice* pVDev = new VirtualDevice( 0 );
+ VclPtrInstance<VirtualDevice> pVDev( 0 );
m_pReferenceDevice = pVDev;
@@ -10938,16 +10938,16 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit& rObject )
sal_Int32 nFunctionObject = createObject();
CHECK_RETURN( updateObject( nFunctionObject ) );
- VirtualDevice aDev;
- aDev.SetOutputSizePixel( rObject.m_aSize );
- aDev.SetMapMode( MapMode( MAP_PIXEL ) );
+ ScopedVclPtrInstance< VirtualDevice > aDev;
+ aDev->SetOutputSizePixel( rObject.m_aSize );
+ aDev->SetMapMode( MapMode( MAP_PIXEL ) );
if( m_aContext.ColorMode == PDFWriter::DrawGreyscale )
- aDev.SetDrawMode( aDev.GetDrawMode() |
+ aDev->SetDrawMode( aDev->GetDrawMode() |
( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT |
DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) );
- aDev.DrawGradient( Rectangle( Point( 0, 0 ), rObject.m_aSize ), rObject.m_aGradient );
+ aDev->DrawGradient( Rectangle( Point( 0, 0 ), rObject.m_aSize ), rObject.m_aGradient );
- Bitmap aSample = aDev.GetBitmap( Point( 0, 0 ), rObject.m_aSize );
+ Bitmap aSample = aDev->GetBitmap( Point( 0, 0 ), rObject.m_aSize );
BitmapReadAccess* pAccess = aSample.AcquireReadAccess();
AccessReleaser aReleaser( pAccess );
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 1f2ac6b1558a..60e12f58786b 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -590,7 +590,7 @@ public:
private:
static const BuiltinFont m_aBuiltinFonts[14];
- OutputDevice* m_pReferenceDevice;
+ VclPtr<OutputDevice> m_pReferenceDevice;
MapMode m_aMapMode; // PDFWriterImpl scaled units
std::vector< PDFPage > m_aPages;
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index e6bd287f6393..09c8d1b27997 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -244,10 +244,10 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
{
bool bAssertionFired( false );
- std::unique_ptr<VirtualDevice> xPrivateDevice;
+ ScopedVclPtr<VirtualDevice> xPrivateDevice;
if( ! pDummyVDev )
{
- xPrivateDevice.reset(new VirtualDevice());
+ xPrivateDevice.reset(VclPtr<VirtualDevice>::Create());
pDummyVDev = xPrivateDevice.get();
pDummyVDev->EnableOutput( false );
pDummyVDev->SetMapMode( i_rMtf.GetPrefMapMode() );
@@ -431,7 +431,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
if ( nPixelX && nPixelY )
{
Size aDstSizePixel( nPixelX, nPixelY );
- std::unique_ptr<VirtualDevice> xVDev(new VirtualDevice);
+ ScopedVclPtrInstance<VirtualDevice> xVDev;
if( xVDev->SetOutputSizePixel( aDstSizePixel ) )
{
Bitmap aPaint, aMask;
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index e96e14bc9c68..10d27223d22e 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -792,9 +792,9 @@ void Printer::ImplInitDisplay( const vcl::Window* pWindow )
mpJobGraphics = NULL;
if ( pWindow )
- mpDisplayDev = new VirtualDevice( *pWindow );
+ mpDisplayDev = VclPtr<VirtualDevice>::Create( *pWindow );
else
- mpDisplayDev = new VirtualDevice();
+ mpDisplayDev = VclPtr<VirtualDevice>::Create();
mpFontCollection = pSVData->maGDIData.mpScreenFontList;
mpFontCache = pSVData->maGDIData.mpScreenFontCache;
mnDPIX = mpDisplayDev->mnDPIX;
@@ -1015,16 +1015,22 @@ Printer::Printer( const OUString& rPrinterName )
Printer::~Printer()
{
+ disposeOnce();
+}
+
+void Printer::dispose()
+{
DBG_ASSERT( !IsPrinting(), "Printer::~Printer() - Job is printing" );
DBG_ASSERT( !IsJobActive(), "Printer::~Printer() - Job is active" );
delete mpPrinterOptions;
+ mpPrinterOptions = NULL;
ReleaseGraphics();
if ( mpInfoPrinter )
ImplGetSVData()->mpDefInst->DestroyInfoPrinter( mpInfoPrinter );
if ( mpDisplayDev )
- delete mpDisplayDev;
+ mpDisplayDev.disposeAndClear();
else
{
// OutputDevice Dtor is tryig the same thing; that why we need to set
@@ -1060,6 +1066,10 @@ Printer::~Printer()
mpNext->mpPrev = mpPrev;
else
pSVData->maGDIData.mpLastPrinter = mpPrev;
+
+ mpPrev.clear();
+ mpNext.clear();
+ OutputDevice::dispose();
}
sal_uLong Printer::GetCapabilities( sal_uInt16 nType ) const
@@ -1215,8 +1225,7 @@ bool Printer::SetPrinterProps( const Printer* pPrinter )
ReleaseGraphics();
if ( mpDisplayDev )
{
- delete mpDisplayDev;
- mpDisplayDev = NULL;
+ mpDisplayDev.disposeAndClear();
}
else
{
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index 4b5a2f1505b9..c8470ac55d09 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -728,10 +728,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
ConnectedComponents aBackgroundComponent;
// create an OutputDevice to record mapmode changes and the like
- VirtualDevice aMapModeVDev;
- aMapModeVDev.mnDPIX = mnDPIX;
- aMapModeVDev.mnDPIY = mnDPIY;
- aMapModeVDev.EnableOutput(false);
+ ScopedVclPtrInstance< VirtualDevice > aMapModeVDev;
+ aMapModeVDev->mnDPIX = mnDPIX;
+ aMapModeVDev->mnDPIY = mnDPIY;
+ aMapModeVDev->EnableOutput(false);
int nLastBgAction, nActionNum;
@@ -766,7 +766,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
aBackgroundComponent.aBounds,
aBackgroundComponent.aBgColor,
static_cast<const MetaRectAction*>(pCurrAct)->GetRect(),
- aMapModeVDev) )
+ *aMapModeVDev.get()) )
bStillBackground=false; // incomplete occlusion of background
else
nLastBgAction=nActionNum; // this _is_ background
@@ -782,7 +782,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
aBackgroundComponent.aBounds,
aBackgroundComponent.aBgColor,
aPoly.GetBoundRect(),
- aMapModeVDev) )
+ *aMapModeVDev.get()) )
bStillBackground=false; // incomplete occlusion of background
else
nLastBgAction=nActionNum; // this _is_ background
@@ -799,7 +799,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
aBackgroundComponent.aBounds,
aBackgroundComponent.aBgColor,
aPoly.GetBoundRect(),
- aMapModeVDev) )
+ *aMapModeVDev.get()) )
bStillBackground=false; // incomplete occlusion of background
else
nLastBgAction=nActionNum; // this _is_ background
@@ -811,7 +811,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
aBackgroundComponent.aBounds,
aBackgroundComponent.aBgColor,
static_cast<const MetaWallpaperAction*>(pCurrAct)->GetRect(),
- aMapModeVDev) )
+ *aMapModeVDev.get()) )
bStillBackground=false; // incomplete occlusion of background
else
nLastBgAction=nActionNum; // this _is_ background
@@ -820,29 +820,29 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
default:
{
if( ImplIsNotTransparent( *pCurrAct,
- aMapModeVDev ) )
+ *aMapModeVDev.get() ) )
bStillBackground=false; // non-transparent action, possibly
// not uniform
else
// extend current bounds (next uniform action
// needs to fully cover this area)
aBackgroundComponent.aBounds.Union(
- ImplCalcActionBounds(*pCurrAct, aMapModeVDev) );
+ ImplCalcActionBounds(*pCurrAct, *aMapModeVDev.get()) );
break;
}
}
// execute action to get correct MapModes etc.
- pCurrAct->Execute( &aMapModeVDev );
+ pCurrAct->Execute( aMapModeVDev.get() );
pCurrAct=const_cast<GDIMetaFile&>(rInMtf).NextAction();
++nActionNum;
}
// clean up aMapModeVDev
- sal_uInt32 nCount = aMapModeVDev.GetGCStackDepth();
+ sal_uInt32 nCount = aMapModeVDev->GetGCStackDepth();
while( nCount-- )
- aMapModeVDev.Pop();
+ aMapModeVDev->Pop();
ConnectedComponentsList aCCList; // list containing distinct sets of connected components as elements.
@@ -859,7 +859,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
pCurrAct, nActionNum) );
// execute action to get correct MapModes etc.
- pCurrAct->Execute( &aMapModeVDev );
+ pCurrAct->Execute( aMapModeVDev.get() );
pCurrAct=const_cast<GDIMetaFile&>(rInMtf).NextAction();
++nActionNum;
}
@@ -873,10 +873,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
pCurrAct=const_cast<GDIMetaFile&>(rInMtf).NextAction(), ++nActionNum )
{
// execute action to get correct MapModes etc.
- pCurrAct->Execute( &aMapModeVDev );
+ pCurrAct->Execute( aMapModeVDev.get() );
// cache bounds of current action
- const Rectangle aBBCurrAct( ImplCalcActionBounds(*pCurrAct, aMapModeVDev) );
+ const Rectangle aBBCurrAct( ImplCalcActionBounds(*pCurrAct, *aMapModeVDev.get()) );
// accumulate collected bounds here, initialize with current action
Rectangle aTotalBounds( aBBCurrAct ); // thus,
@@ -902,7 +902,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
// not be considered for connected components,
// too. Just put each of them into a separate
// component.
- aTotalComponents.bIsFullyTransparent = !ImplIsNotTransparent(*pCurrAct, aMapModeVDev);
+ aTotalComponents.bIsFullyTransparent = !ImplIsNotTransparent(*pCurrAct, *aMapModeVDev.get());
if( !aBBCurrAct.IsEmpty() &&
!aTotalComponents.bIsFullyTransparent )
@@ -1155,16 +1155,16 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
Point aDstPtPix( aBoundRect.TopLeft() );
Size aDstSzPix;
- VirtualDevice aMapVDev; // here, we record only mapmode information
- aMapVDev.EnableOutput(false);
+ ScopedVclPtrInstance<VirtualDevice> aMapVDev; // here, we record only mapmode information
+ aMapVDev->EnableOutput(false);
- VirtualDevice aPaintVDev; // into this one, we render.
- aPaintVDev.SetBackground( aBackgroundComponent.aBgColor );
+ ScopedVclPtrInstance<VirtualDevice> aPaintVDev; // into this one, we render.
+ aPaintVDev->SetBackground( aBackgroundComponent.aBgColor );
rOutMtf.AddAction( new MetaPushAction( PushFlags::MAPMODE ) );
rOutMtf.AddAction( new MetaMapModeAction() );
- aPaintVDev.SetDrawMode( GetDrawMode() );
+ aPaintVDev->SetDrawMode( GetDrawMode() );
while( aDstPtPix.Y() <= aBoundRect.Bottom() )
{
@@ -1180,15 +1180,15 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
aDstSzPix.Width() = aBoundRect.Right() - aDstPtPix.X() + 1L;
if( !Rectangle( aDstPtPix, aDstSzPix ).Intersection( aBoundRect ).IsEmpty() &&
- aPaintVDev.SetOutputSizePixel( aDstSzPix ) )
+ aPaintVDev->SetOutputSizePixel( aDstSzPix ) )
{
- aPaintVDev.Push();
- aMapVDev.Push();
+ aPaintVDev->Push();
+ aMapVDev->Push();
- aMapVDev.mnDPIX = aPaintVDev.mnDPIX = mnDPIX;
- aMapVDev.mnDPIY = aPaintVDev.mnDPIY = mnDPIY;
+ aMapVDev->mnDPIX = aPaintVDev->mnDPIX = mnDPIX;
+ aMapVDev->mnDPIY = aPaintVDev->mnDPIY = mnDPIY;
- aPaintVDev.EnableOutput(false);
+ aPaintVDev->EnableOutput(false);
// iterate over all actions
for( pCurrAct=const_cast<GDIMetaFile&>(rInMtf).FirstAction(), nActionNum=0;
@@ -1200,38 +1200,38 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
// the current aCCList element
// (aCurr)
if( aCCList_MemberMap[nActionNum] == &(*aCurr) )
- aPaintVDev.EnableOutput(true);
+ aPaintVDev->EnableOutput(true);
// but process every action
const sal_uInt16 nType( pCurrAct->GetType() );
if( META_MAPMODE_ACTION == nType )
{
- pCurrAct->Execute( &aMapVDev );
+ pCurrAct->Execute( aMapVDev.get() );
- MapMode aMtfMap( aMapVDev.GetMapMode() );
- const Point aNewOrg( aMapVDev.PixelToLogic( aDstPtPix ) );
+ MapMode aMtfMap( aMapVDev->GetMapMode() );
+ const Point aNewOrg( aMapVDev->PixelToLogic( aDstPtPix ) );
aMtfMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) );
- aPaintVDev.SetMapMode( aMtfMap );
+ aPaintVDev->SetMapMode( aMtfMap );
}
else if( ( META_PUSH_ACTION == nType ) || ( META_POP_ACTION ) == nType )
{
- pCurrAct->Execute( &aMapVDev );
- pCurrAct->Execute( &aPaintVDev );
+ pCurrAct->Execute( aMapVDev.get() );
+ pCurrAct->Execute( aPaintVDev.get() );
}
else if( META_GRADIENT_ACTION == nType )
{
MetaGradientAction* pGradientAction = static_cast<MetaGradientAction*>(pCurrAct);
Printer* pPrinter = dynamic_cast< Printer* >(this);
if( pPrinter )
- pPrinter->DrawGradientEx( &aPaintVDev, pGradientAction->GetRect(), pGradientAction->GetGradient() );
+ pPrinter->DrawGradientEx( aPaintVDev.get(), pGradientAction->GetRect(), pGradientAction->GetGradient() );
else
DrawGradient( pGradientAction->GetRect(), pGradientAction->GetGradient() );
}
else
{
- pCurrAct->Execute( &aPaintVDev );
+ pCurrAct->Execute( aPaintVDev.get() );
}
if( !( nActionNum % 8 ) )
@@ -1239,9 +1239,9 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
}
const bool bOldMap = mbMap;
- mbMap = aPaintVDev.mbMap = false;
+ mbMap = aPaintVDev->mbMap = false;
- Bitmap aBandBmp( aPaintVDev.GetBitmap( Point(), aDstSzPix ) );
+ Bitmap aBandBmp( aPaintVDev->GetBitmap( Point(), aDstSzPix ) );
// scale down bitmap, if requested
if( bDownsampleBitmaps )
@@ -1255,10 +1255,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
rOutMtf.AddAction( new MetaBmpScaleAction( aDstPtPix, aDstSzPix, aBandBmp ) );
rOutMtf.AddAction( new MetaCommentAction( "PRNSPOOL_TRANSPARENTBITMAP_END" ) );
- aPaintVDev.mbMap = true;
+ aPaintVDev->mbMap = true;
mbMap = bOldMap;
- aMapVDev.Pop();
- aPaintVDev.Pop();
+ aMapVDev->Pop();
+ aPaintVDev->Pop();
}
// overlapping bands to avoid missing lines (e.g. PostScript)
@@ -1276,9 +1276,9 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
}
// clean up aMapModeVDev
- nCount = aMapModeVDev.GetGCStackDepth();
+ nCount = aMapModeVDev->GetGCStackDepth();
while( nCount-- )
- aMapModeVDev.Pop();
+ aMapModeVDev->Pop();
// STAGE 4: Copy actions to output metafile
@@ -1309,7 +1309,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
// given background color
ImplConvertTransparentAction(rOutMtf,
*pCurrAct,
- aMapModeVDev,
+ *aMapModeVDev.get(),
aBackgroundComponent.aBgColor);
}
else
@@ -1318,7 +1318,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
rOutMtf.AddAction( ( pCurrAct->Duplicate(), pCurrAct ) );
}
- pCurrAct->Execute(&aMapModeVDev);
+ pCurrAct->Execute(aMapModeVDev.get());
}
}
@@ -1335,7 +1335,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
else
rOutMtf.AddAction( new MetaLineColorAction( COL_BLUE, true) );
- rOutMtf.AddAction( new MetaRectAction( aMapModeVDev.PixelToLogic( aCurr->aBounds ) ) );
+ rOutMtf.AddAction( new MetaRectAction( aMapModeVDev->PixelToLogic( aCurr->aBounds ) ) );
}
#endif
}
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 543ab88ad245..bf5c5eef4ae8 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -140,7 +140,7 @@ public:
typedef std::unordered_map< OUString, ControlDependency, OUStringHash > ControlDependencyMap;
typedef std::unordered_map< OUString, Sequence< sal_Bool >, OUStringHash > ChoiceDisableMap;
- std::shared_ptr<Printer> mxPrinter;
+ VclPtr< Printer > mxPrinter;
Sequence< PropertyValue > maUIOptions;
std::vector< PropertyValue > maUIProperties;
std::vector< bool > maUIPropertyEnabled;
@@ -156,7 +156,7 @@ public:
vcl::PrinterController::MultiPageSetup maMultiPage;
- vcl::PrintProgressDialog* mpProgress;
+ VclPtr<vcl::PrintProgressDialog> mpProgress;
ImplPageCache maPageCache;
@@ -191,7 +191,7 @@ public:
mnDefaultPaperBin( -1 ),
mnFixedPaperBin( -1 )
{}
- ~ImplPrinterControllerData() { delete mpProgress; }
+ ~ImplPrinterControllerData() { mpProgress.disposeAndClear(); }
Size getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const
{
@@ -207,7 +207,7 @@ public:
void resetPaperToLastConfigured();
};
-PrinterController::PrinterController(const std::shared_ptr<Printer>& i_xPrinter)
+PrinterController::PrinterController( const VclPtr<Printer>& i_xPrinter )
: mpImplData( new ImplPrinterControllerData )
{
mpImplData->mxPrinter = i_xPrinter;
@@ -305,9 +305,10 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
{
if (xController->isShowDialogs())
{
- MessageDialog aBox(NULL, "ErrorNoPrinterDialog",
+ ScopedVclPtrInstance<MessageDialog> aBox(
+ nullptr, "ErrorNoPrinterDialog",
"vcl/ui/errornoprinterdialog.ui");
- aBox.Execute();
+ aBox->Execute();
}
xController->setValue( OUString( "IsDirect" ),
makeAny( false ) );
@@ -320,7 +321,7 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
if (!xController->getPrinter())
{
OUString aPrinterName( i_rInitSetup.GetPrinterName() );
- std::shared_ptr<Printer> xPrinter(std::make_shared<Printer>(aPrinterName));
+ VclPtrInstance<Printer> xPrinter( aPrinterName );
xPrinter->SetJobSetup(i_rInitSetup);
xController->setPrinter(xPrinter);
}
@@ -454,9 +455,10 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
{
if( xController->getFilteredPageCount() == 0 )
{
- MessageDialog aBox(NULL, "ErrorNoContentDialog",
+ ScopedVclPtrInstance<MessageDialog> aBox(
+ nullptr, "ErrorNoContentDialog",
"vcl/ui/errornocontentdialog.ui");
- aBox.Execute();
+ aBox->Execute();
return;
}
}
@@ -470,13 +472,13 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
{
try
{
- PrintDialog aDlg( NULL, xController );
- if( ! aDlg.Execute() )
+ ScopedVclPtrInstance< PrintDialog > aDlg( nullptr, xController );
+ if( ! aDlg->Execute() )
{
xController->abortJob();
return;
}
- if( aDlg.isPrintToFile() )
+ if( aDlg->isPrintToFile() )
{
OUString aFile = queryFile( xController->getPrinter().get() );
if( aFile.isEmpty() )
@@ -487,7 +489,7 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
xController->setValue( OUString( "LocalFileName" ),
makeAny( aFile ) );
}
- else if( aDlg.isSingleJobs() )
+ else if( aDlg->isSingleJobs() )
{
xController->setValue( OUString( "PrintCollateAsSingleJobs" ),
makeAny( true ) );
@@ -771,12 +773,12 @@ void PrinterController::setJobState( view::PrintableState i_eState )
mpImplData->meJobState = i_eState;
}
-const std::shared_ptr<Printer>& PrinterController::getPrinter() const
+const VclPtr<Printer>& PrinterController::getPrinter() const
{
return mpImplData->mxPrinter;
}
-void PrinterController::setPrinter(const std::shared_ptr<Printer>& i_rPrinter)
+void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter )
{
mpImplData->mxPrinter = i_rPrinter;
setValue( OUString( "Name" ),
@@ -1332,8 +1334,7 @@ void PrinterController::abortJob()
// applications (well, sw) depend on a page request with "IsLastPage" = true
// to free resources, else they (well, sw) will crash eventually
setLastPage( true );
- delete mpImplData->mpProgress;
- mpImplData->mpProgress = NULL;
+ mpImplData->mpProgress.disposeAndClear();
GDIMetaFile aMtf;
getPageFile( 0, aMtf, false );
}
@@ -1660,7 +1661,7 @@ void PrinterController::createProgressDialog()
if( bShow && ! Application::IsHeadlessModeEnabled() )
{
- mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCountProtected() );
+ mpImplData->mpProgress = VclPtr<PrintProgressDialog>::Create( nullptr, getPageCountProtected() );
mpImplData->mpProgress->Show();
}
}
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index b94b6c20e1d6..c453d91ef81d 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -255,6 +255,12 @@ VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
VirtualDevice::~VirtualDevice()
{
SAL_INFO( "vcl.gdi", "VirtualDevice::~VirtualDevice()" );
+ disposeOnce();
+}
+
+void VirtualDevice::dispose()
+{
+ SAL_INFO( "vcl.gdi", "VirtualDevice::dispose()" );
ImplSVData* pSVData = ImplGetSVData();
@@ -272,6 +278,8 @@ VirtualDevice::~VirtualDevice()
mpNext->mpPrev = mpPrev;
else
pSVData->maGDIData.mpLastVirDev = mpPrev;
+
+ OutputDevice::dispose();
}
bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
@@ -392,13 +400,12 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
// #110958# Setup alpha bitmap
if(mpAlphaVDev && mpAlphaVDev->GetOutputSizePixel() != rNewSize)
{
- delete mpAlphaVDev;
- mpAlphaVDev = 0L;
+ mpAlphaVDev.disposeAndClear();
}
if( !mpAlphaVDev )
{
- mpAlphaVDev = new VirtualDevice( *this, mnAlphaDepth );
+ mpAlphaVDev = VclPtr<VirtualDevice>::Create( *this, mnAlphaDepth );
mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase,
basebmp::RawMemorySharedArray(),
bTopDown );
diff --git a/vcl/source/helper/lazydelete.cxx b/vcl/source/helper/lazydelete.cxx
index 45ea7e091820..2594ad47c22a 100644
--- a/vcl/source/helper/lazydelete.cxx
+++ b/vcl/source/helper/lazydelete.cxx
@@ -32,9 +32,8 @@ LazyDeletorBase::~LazyDeletorBase()
{
}
-// instantiate instance pointers for LazyDeletor<Window,Menu>
+// instantiate instance pointer for LazyDeletor<Window>
template<> LazyDeletor<vcl::Window>* LazyDeletor<vcl::Window>::s_pOneInstance = NULL;
-template<> LazyDeletor<Menu>* LazyDeletor<Menu>::s_pOneInstance = NULL;
// a list for all LazyeDeletor<T> singletons
static std::vector< LazyDeletorBase* > lcl_aDeletors;
@@ -60,16 +59,6 @@ template<> bool LazyDeletor<vcl::Window>::is_less( vcl::Window* left, vcl::Windo
return left != right && right->IsChild( left, true );
}
-#ifndef LINUX
-// specialized is_less function for Menu
-template<> bool LazyDeletor<Menu>::is_less( Menu* left, Menu* right )
-{
- while( left && left != right )
- left = left->ImplGetStartedFrom();
- return left != NULL;
-}
-#endif
-
DeleteOnDeinitBase::~DeleteOnDeinitBase()
{
ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 70c263a01ed3..8d298a434978 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -102,6 +102,8 @@ OpenGLContext::~OpenGLContext()
mpNextContext->mpPrevContext = mpPrevContext;
else
pSVData->maGDIData.mpLastContext = mpPrevContext;
+
+ m_pChildWindow.disposeAndClear();
}
#ifdef DBG_UTIL
@@ -657,7 +659,7 @@ bool OpenGLContext::init( vcl::Window* pParent )
if(mbInitialized)
return true;
- m_xWindow.reset(pParent ? NULL : new vcl::Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
+ m_xWindow.reset(pParent ? nullptr : VclPtr<vcl::Window>::Create(nullptr, WB_NOBORDER|WB_NODIALOGCONTROL));
mpWindow = pParent ? pParent : m_xWindow.get();
if(m_xWindow)
m_xWindow->setPosSizePixel(0,0,0,0);
@@ -1080,8 +1082,7 @@ bool OpenGLContext::initWindow()
if( !m_pChildWindow )
{
SystemWindowData winData = generateWinData(mpWindow, false);
- m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
- m_xChildWindowGC.reset(m_pChildWindow);
+ m_pChildWindow = VclPtr<SystemChildWindow>::Create(mpWindow, 0, &winData, false);
}
if( m_pChildWindow )
@@ -1108,8 +1109,7 @@ bool OpenGLContext::initWindow()
if( !m_pChildWindow )
{
SystemWindowData winData = generateWinData(mpWindow, mbRequestLegacyContext);
- m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
- m_xChildWindowGC.reset(m_pChildWindow);
+ m_pChildWindow = VclPtr<SystemChildWindow>::Create(mpWindow, 0, &winData, false);
}
if( m_pChildWindow )
@@ -1143,8 +1143,7 @@ bool OpenGLContext::initWindow()
{
if( !m_pChildWindow )
{
- m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
- m_xChildWindowGC.reset(m_pChildWindow);
+ m_pChildWindow = VclPtr<SystemChildWindow>::Create(mpWindow, 0, &winData, false);
}
pChildSysData = m_pChildWindow->GetSystemData();
}
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 9f13a24f1442..03938508643f 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -410,11 +410,11 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
// If the visible part has been clipped, we have to create a
// Bitmap with the correct size in which we copy the clipped
// Bitmap to the correct position.
- VirtualDevice aVDev( *this );
+ ScopedVclPtrInstance< VirtualDevice > aVDev( *this );
- if ( aVDev.SetOutputSizePixel( aRect.GetSize() ) )
+ if ( aVDev->SetOutputSizePixel( aRect.GetSize() ) )
{
- if ( ((OutputDevice*)&aVDev)->mpGraphics || ((OutputDevice*)&aVDev)->AcquireGraphics() )
+ if ( ((OutputDevice*)aVDev.get())->mpGraphics || ((OutputDevice*)aVDev.get())->AcquireGraphics() )
{
if ( (nWidth > 0) && (nHeight > 0) )
{
@@ -422,14 +422,14 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
(aRect.Left() < mnOutOffX) ? (mnOutOffX - aRect.Left()) : 0L,
(aRect.Top() < mnOutOffY) ? (mnOutOffY - aRect.Top()) : 0L,
nWidth, nHeight);
- (((OutputDevice*)&aVDev)->mpGraphics)->CopyBits( aPosAry, mpGraphics, this, this );
+ (((OutputDevice*)aVDev.get())->mpGraphics)->CopyBits( aPosAry, mpGraphics, this, this );
}
else
{
OSL_ENSURE(false, "CopyBits with negative width or height (!)");
}
- aBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
+ aBmp = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() );
}
else
bClipped = false;
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 1bf2df824ff6..27810d43ade9 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -91,7 +91,12 @@ vcl::FontInfo OutputDevice::GetDevFont( int nDevFontIndex ) const
int OutputDevice::GetDevFontCount() const
{
if( !mpGetDevFontList )
+ {
+ if (!mpFontCollection)
+ return 0;
+
mpGetDevFontList = mpFontCollection->GetDevFontList();
+ }
return mpGetDevFontList->Count();
}
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index b359e504d0a9..e7eed8872143 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -232,9 +232,8 @@ static void ImplCalcMapResolution( const MapMode& rMapMode,
vcl::Window::ImplInitAppFontData( pSVData->maWinData.mpFirstFrame );
else
{
- WorkWindow* pWin = new WorkWindow( NULL, 0 );
+ ScopedVclPtrInstance<WorkWindow> pWin( nullptr, 0 );
vcl::Window::ImplInitAppFontData( pWin );
- delete pWin;
}
}
rMapRes.mnMapScNumX = pSVData->maGDIData.mnAppFontX;
@@ -343,6 +342,9 @@ inline void ImplCalcMapResolution( const MapMode& rMapMode,
// #i75163#
void OutputDevice::ImplInvalidateViewTransform()
{
+ if(!mpOutDevData)
+ return;
+
if(mpOutDevData->mpViewTransform)
{
delete mpOutDevData->mpViewTransform;
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 372eb23bc8f4..855a2d46a27f 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -82,12 +82,12 @@ namespace {
// Begin initializer and accessor public functions
OutputDevice::OutputDevice() :
+ mnRefCnt(1), // cf. VclPtrInstance and README.lifecycle
maRegion(true),
maFillColor( COL_WHITE ),
maTextLineColor( COL_TRANSPARENT ),
mxSettings( new AllSettings(Application::GetSettings()) )
{
-
mpGraphics = NULL;
mpUnoGraphicsList = NULL;
mpPrevGraphics = NULL;
@@ -179,11 +179,32 @@ OutputDevice::OutputDevice() :
// #i75163#
mpOutDevData->mpViewTransform = NULL;
mpOutDevData->mpInverseViewTransform = NULL;
+
+ mbDisposed = false;
}
OutputDevice::~OutputDevice()
{
+ disposeOnce();
+}
+
+void OutputDevice::disposeOnce()
+{
+ if ( mbDisposed )
+ return;
+ mbDisposed = true;
+
+ // catch badness where our OutputDevice sub-class was not
+ // wrapped safely in a VclPtr cosily.
+ // FIXME: as/when we make our destructors all protected,
+ // we should introduce this assert:
+ // assert( mnRefCnt > 0 );
+ dispose();
+}
+
+void OutputDevice::dispose()
+{
if ( GetUnoGraphicsList() )
{
UnoWrapperBase* pWrapper = Application::GetUnoWrapper( false );
@@ -193,12 +214,13 @@ OutputDevice::~OutputDevice()
mpUnoGraphicsList = NULL;
}
- delete mpOutDevData->mpRotateDev;
+ mpOutDevData->mpRotateDev.disposeAndClear();
// #i75163#
ImplInvalidateViewTransform();
delete mpOutDevData;
+ mpOutDevData = NULL;
// for some reason, we haven't removed state from the stack properly
if ( !mpOutDevStateStack->empty() )
@@ -210,6 +232,7 @@ OutputDevice::~OutputDevice()
}
}
delete mpOutDevStateStack;
+ mpOutDevStateStack = NULL;
// release the active font instance
if( mpFontEntry )
@@ -218,8 +241,10 @@ OutputDevice::~OutputDevice()
// remove cached results of GetDevFontList/GetDevSizeList
// TODO: use smart pointers for them
delete mpGetDevFontList;
+ mpGetDevFontList = NULL;
delete mpGetDevSizeList;
+ mpGetDevSizeList = NULL;
// release ImplFontCache specific to this OutputDevice
// TODO: refcount ImplFontCache
@@ -242,7 +267,7 @@ OutputDevice::~OutputDevice()
mpFontCollection = NULL;
}
- delete mpAlphaVDev;
+ mpAlphaVDev.disposeAndClear();
}
SalGraphics* OutputDevice::GetGraphics()
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index a71c7d66cb92..bc6bd4a8b6c9 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -641,6 +641,7 @@ void OutputDevice::InitFillColor()
void OutputDevice::ImplReleaseFonts()
{
mpGraphics->ReleaseFonts();
+
mbNewFont = true;
mbInitFont = true;
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index eb7104d06215..1cc48a32223b 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -236,7 +236,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
// cache virtual device for rotation
if (!mpOutDevData->mpRotateDev)
- mpOutDevData->mpRotateDev = new VirtualDevice( *this, 1 );
+ mpOutDevData->mpRotateDev = VclPtr<VirtualDevice>::Create( *this, 1 );
VirtualDevice* pVDev = mpOutDevData->mpRotateDev;
// size it accordingly
@@ -2494,18 +2494,18 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
// fall back to bitmap method to get the bounding rectangle,
// so we need a monochrome virtual device with matching font
- VirtualDevice aVDev( 1 );
+ ScopedVclPtrInstance< VirtualDevice > aVDev( 1 );
vcl::Font aFont( GetFont() );
aFont.SetShadow( false );
aFont.SetOutline( false );
aFont.SetRelief( RELIEF_NONE );
aFont.SetOrientation( 0 );
aFont.SetSize( Size( mpFontEntry->maFontSelData.mnWidth, mpFontEntry->maFontSelData.mnHeight ) );
- aVDev.SetFont( aFont );
- aVDev.SetTextAlign( ALIGN_TOP );
+ aVDev->SetFont( aFont );
+ aVDev->SetTextAlign( ALIGN_TOP );
// layout the text on the virtual device
- pSalLayout = aVDev.ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry );
+ pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry );
if( !pSalLayout )
return false;
@@ -2515,7 +2515,7 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
long nHeight = mpFontEntry->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent;
Point aOffset( nWidth/2, 8 );
Size aOutSize( nWidth + 2*aOffset.X(), nHeight + 2*aOffset.Y() );
- if( !nWidth || !aVDev.SetOutputSizePixel( aOutSize ) )
+ if( !nWidth || !aVDev->SetOutputSizePixel( aOutSize ) )
{
pSalLayout->Release();
return false;
@@ -2523,14 +2523,14 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
// draw text in black
pSalLayout->DrawBase() = aOffset;
- aVDev.SetTextColor( Color( COL_BLACK ) );
- aVDev.SetTextFillColor();
- aVDev.ImplInitTextColor();
- aVDev.ImplDrawText( *pSalLayout );
+ aVDev->SetTextColor( Color( COL_BLACK ) );
+ aVDev->SetTextFillColor();
+ aVDev->ImplInitTextColor();
+ aVDev->ImplDrawText( *pSalLayout );
pSalLayout->Release();
// find extents using the bitmap
- Bitmap aBmp = aVDev.GetBitmap( Point(), aOutSize );
+ Bitmap aBmp = aVDev->GetBitmap( Point(), aOutSize );
BitmapReadAccess* pAcc = aBmp.AcquireReadAccess();
if( !pAcc )
return false;
@@ -2718,7 +2718,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
+ mnEmphasisDescent;
pSalLayout->Release();
- VirtualDevice aVDev(1);
+ ScopedVclPtrInstance< VirtualDevice > aVDev( 1 );
vcl::Font aFont(GetFont());
aFont.SetShadow(false);
@@ -2728,19 +2728,19 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
if( bOptimize )
{
aFont.SetSize( Size( 0, GLYPH_FONT_HEIGHT ) );
- aVDev.SetMapMode( MAP_PIXEL );
+ aVDev->SetMapMode( MAP_PIXEL );
}
- aVDev.SetFont( aFont );
- aVDev.SetTextAlign( ALIGN_TOP );
- aVDev.SetTextColor( Color(COL_BLACK) );
- aVDev.SetTextFillColor();
+ aVDev->SetFont( aFont );
+ aVDev->SetTextAlign( ALIGN_TOP );
+ aVDev->SetTextColor( Color(COL_BLACK) );
+ aVDev->SetTextFillColor();
- pSalLayout = aVDev.ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray );
+ pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray );
if (pSalLayout == 0)
return false;
long nWidth = pSalLayout->GetTextWidth();
- long nHeight = ((OutputDevice*)&aVDev)->mpFontEntry->mnLineHeight + ((OutputDevice*)&aVDev)->mnEmphasisAscent
- + ((OutputDevice*)&aVDev)->mnEmphasisDescent;
+ long nHeight = aVDev->mpFontEntry->mnLineHeight + aVDev->mnEmphasisAscent +
+ aVDev->mnEmphasisDescent;
pSalLayout->Release();
if( !nWidth || !nHeight )
@@ -2755,7 +2755,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
{
sal_Int32 nStart = ((nBase < nIndex) ? nBase : nIndex);
sal_Int32 nLength = ((nBase > nIndex) ? nBase : nIndex) - nStart;
- pSalLayout = aVDev.ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray );
+ pSalLayout = aVDev->ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray );
if( pSalLayout )
{
nXOffset = pSalLayout->GetTextWidth();
@@ -2776,25 +2776,25 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
bool bSuccess = false;
// draw character into virtual device
- pSalLayout = aVDev.ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray );
+ pSalLayout = aVDev->ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray );
if (pSalLayout == 0)
return false;
long nCharWidth = pSalLayout->GetTextWidth();
Point aOffset(nCharWidth / 2, 8);
Size aSize(nCharWidth + 2 * aOffset.X(), nHeight + 2 * aOffset.Y());
- bSuccess = (bool)aVDev.SetOutputSizePixel(aSize);
+ bSuccess = (bool)aVDev->SetOutputSizePixel(aSize);
if( bSuccess )
{
// draw glyph into virtual device
- aVDev.Erase();
+ aVDev->Erase();
pSalLayout->DrawBase() += aOffset;
- pSalLayout->DrawBase() += Point( ((OutputDevice*)&aVDev)->mnTextOffX, ((OutputDevice*)&aVDev)->mnTextOffY );
- pSalLayout->DrawText( *((OutputDevice*)&aVDev)->mpGraphics );
+ pSalLayout->DrawBase() += Point( aVDev->mnTextOffX, aVDev->mnTextOffY );
+ pSalLayout->DrawText( *aVDev->mpGraphics );
pSalLayout->Release();
// convert character image into outline
- Bitmap aBmp( aVDev.GetBitmap(Point(0, 0), aSize));
+ Bitmap aBmp( aVDev->GetBitmap(Point(0, 0), aSize));
tools::PolyPolygon aPolyPoly;
bool bVectorized = aBmp.Vectorize(aPolyPoly, BMP_VECTORIZE_OUTER | BMP_VECTORIZE_REDUCE_EDGES);
@@ -2810,8 +2810,8 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
{
Point& rPt = rPoly[k];
rPt -= aOffset;
- int nPixelX = rPt.X() - ((OutputDevice&)aVDev).mnTextOffX + nXOffset;
- int nPixelY = rPt.Y() - ((OutputDevice&)aVDev).mnTextOffY;
+ int nPixelX = rPt.X() - ((OutputDevice*)aVDev.get())->mnTextOffX + nXOffset;
+ int nPixelY = rPt.Y() - ((OutputDevice*)aVDev.get())->mnTextOffY;
rPt.X() = ImplDevicePixelToLogicWidth( nPixelX );
rPt.Y() = ImplDevicePixelToLogicHeight( nPixelY );
}
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 60f68c28e5dc..425a56ab7514 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -116,7 +116,7 @@ sal_uInt16 OutputDevice::GetAlphaBitCount() const
bool OutputDevice::HasAlpha()
{
- return mpAlphaVDev != NULL;
+ return mpAlphaVDev != nullptr;
}
void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
@@ -431,25 +431,25 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly,
if( !bDrawn )
{
- VirtualDevice aVDev( *this, 1 );
+ ScopedVclPtrInstance< VirtualDevice > aVDev( *this, 1 );
const Size aDstSz( aDstRect.GetSize() );
const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 );
if( aDstRect.Left() || aDstRect.Top() )
aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() );
- if( aVDev.SetOutputSizePixel( aDstSz ) )
+ if( aVDev->SetOutputSizePixel( aDstSz ) )
{
const bool bOldMap = mbMap;
EnableMapMode( false );
- aVDev.SetLineColor( COL_BLACK );
- aVDev.SetFillColor( COL_BLACK );
- aVDev.DrawPolyPolygon( aPolyPoly );
+ aVDev->SetLineColor( COL_BLACK );
+ aVDev->SetFillColor( COL_BLACK );
+ aVDev->DrawPolyPolygon( aPolyPoly );
Bitmap aPaint( GetBitmap( aDstRect.TopLeft(), aDstSz ) );
- Bitmap aPolyMask( aVDev.GetBitmap( Point(), aDstSz ) );
+ Bitmap aPolyMask( aVDev->GetBitmap( Point(), aDstSz ) );
// #107766# check for non-empty bitmaps before accessing them
if( !!aPaint && !!aPolyMask )
@@ -683,7 +683,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos,
if( !aDstRect.IsEmpty() )
{
- std::unique_ptr<VirtualDevice> xVDev(new VirtualDevice);
+ ScopedVclPtrInstance< VirtualDevice > xVDev;
((OutputDevice*)xVDev.get())->mnDPIX = mnDPIX;
((OutputDevice*)xVDev.get())->mnDPIY = mnDPIY;
diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx
index 8e4d86bc321f..ba7928b4f812 100644
--- a/vcl/source/outdev/wallpaper.cxx
+++ b/vcl/source/outdev/wallpaper.cxx
@@ -129,11 +129,11 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY,
{
if( !pCached && !rWallpaper.GetColor().GetTransparency() )
{
- VirtualDevice aVDev( *this );
- aVDev.SetBackground( rWallpaper.GetColor() );
- aVDev.SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) );
- aVDev.DrawBitmapEx( Point(), aBmpEx );
- aBmpEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
+ ScopedVclPtrInstance< VirtualDevice > aVDev( *this );
+ aVDev->SetBackground( rWallpaper.GetColor() );
+ aVDev->SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) );
+ aVDev->DrawBitmapEx( Point(), aBmpEx );
+ aBmpEx = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() );
}
bDrawColorBackground = true;
diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx
index e889e78f8644..bb93b1207dd8 100644
--- a/vcl/source/uipreviewer/previewer.cxx
+++ b/vcl/source/uipreviewer/previewer.cxx
@@ -68,8 +68,7 @@ int UIPreviewApp::Main()
try
{
- Dialog *pDialog = new Dialog(DIALOG_NO_PARENT, WB_STDDIALOG | WB_SIZEABLE);
-
+ VclPtrInstance<Dialog> pDialog(DIALOG_NO_PARENT, WB_STDDIALOG | WB_SIZEABLE);
{
VclBuilder aBuilder(pDialog, OUString(), uifiles[0]);
vcl::Window *pRoot = aBuilder.get_widget_root();
@@ -90,7 +89,7 @@ int UIPreviewApp::Main()
pRealDialog->Execute();
}
- delete pDialog;
+ pDialog.disposeAndClear();
}
catch (const uno::Exception &e)
{
diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx
index a3b7c0f8d061..99fea0983520 100644
--- a/vcl/source/window/accel.cxx
+++ b/vcl/source/window/accel.cxx
@@ -20,6 +20,7 @@
#include <tools/debug.hxx>
#include <tools/rc.h>
+#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <accel.h>
#include <vcl/accel.hxx>
diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx
index fc3dc74d009d..07abf759c92d 100644
--- a/vcl/source/window/accessibility.cxx
+++ b/vcl/source/window/accessibility.cxx
@@ -136,6 +136,8 @@ namespace vcl {
return pChild->GetAccessible();
}
*/
+ if ( !mpWindowImpl )
+ return css::uno::Reference< css::accessibility::XAccessible >();
if ( !mpWindowImpl->mxAccessible.is() && bCreate )
mpWindowImpl->mxAccessible = CreateAccessible();
@@ -647,12 +649,11 @@ vcl::Window* Window::GetAccessibleRelationLabeledBy() const
if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabeledByWindow)
return mpWindowImpl->mpAccessibleInfos->pLabeledByWindow;
- std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
+ std::vector<VclPtr<FixedText> > aMnemonicLabels(list_mnemonic_labels());
if (!aMnemonicLabels.empty())
{
//if we have multiple labels, then prefer the first that is visible
- for (std::vector<FixedText*>::iterator
- aI = aMnemonicLabels.begin(), aEnd = aMnemonicLabels.end(); aI != aEnd; ++aI)
+ for (auto aI = aMnemonicLabels.begin(), aEnd = aMnemonicLabels.end(); aI != aEnd; ++aI)
{
vcl::Window *pCandidate = *aI;
if (pCandidate->IsVisible())
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index c472777cf101..88ef65a07391 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -1013,7 +1013,7 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei
vcl::Window *pWin = NULL, *pCtrl = NULL;
if (mpOutDev->GetOutDevType() == OUTDEV_WINDOW)
- pWin = static_cast<vcl::Window*>(mpOutDev);
+ pWin = static_cast<vcl::Window*>(mpOutDev.get());
if (pWin)
pCtrl = mpBorderWindow->GetWindow(WINDOW_CLIENT);
@@ -1193,7 +1193,7 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
// control this border belongs to
vcl::Window *pWin = NULL, *pCtrl = NULL;
if( mpOutDev->GetOutDevType() == OUTDEV_WINDOW )
- pWin = static_cast<vcl::Window*>(mpOutDev);
+ pWin = static_cast<vcl::Window*>(mpOutDev.get());
ControlType aCtrlType = 0;
ControlPart aCtrlPart = PART_ENTIRE_CONTROL;
@@ -1364,8 +1364,8 @@ ImplStdBorderWindowView::ImplStdBorderWindowView( ImplBorderWindow* pBorderWindo
ImplStdBorderWindowView::~ImplStdBorderWindowView()
{
- delete mpATitleVirDev;
- delete mpDTitleVirDev;
+ mpATitleVirDev.disposeAndClear();
+ mpDTitleVirDev.disposeAndClear();
}
bool ImplStdBorderWindowView::MouseMove( const MouseEvent& rMEvt )
@@ -1556,7 +1556,7 @@ long ImplStdBorderWindowView::CalcTitleWidth() const
void ImplStdBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset )
{
ImplBorderFrameData* pData = &maFrameData;
- OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev;
+ OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev.get();
ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
Point aTmpPoint = pOffset ? Point(*pOffset) : Point();
Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) );
@@ -1851,7 +1851,15 @@ ImplBorderWindow::ImplBorderWindow( vcl::Window* pParent, WinBits nStyle ,
ImplBorderWindow::~ImplBorderWindow()
{
+ disposeOnce();
+}
+
+void ImplBorderWindow::dispose()
+{
delete mpBorderView;
+ mpBorderView = NULL;
+ mpMenuBarWindow.clear();
+ vcl::Window::dispose();
}
void ImplBorderWindow::MouseMove( const MouseEvent& rMEvt )
diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx
index 515d17a20cc6..2e8532cecba7 100644
--- a/vcl/source/window/btndlg.cxx
+++ b/vcl/source/window/btndlg.cxx
@@ -30,10 +30,10 @@ typedef boost::ptr_vector<ImplBtnDlgItem>::const_iterator btn_const_iterator;
struct ImplBtnDlgItem
{
sal_uInt16 mnId;
- bool mbOwnButton;
- bool mbDummyAlign;
- long mnSepSize;
- PushButton* mpPushButton;
+ bool mbOwnButton;
+ bool mbDummyAlign;
+ long mnSepSize;
+ VclPtr<PushButton> mpPushButton;
};
void ButtonDialog::ImplInitButtonDialogData()
@@ -59,11 +59,18 @@ ButtonDialog::ButtonDialog( vcl::Window* pParent, WinBits nStyle ) :
ButtonDialog::~ButtonDialog()
{
+ disposeOnce();
+}
+
+void ButtonDialog::dispose()
+{
for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
{
- if ( it->mpPushButton && it->mbOwnButton )
- delete it->mpPushButton;
+ if ( it->mbOwnButton )
+ it->mpPushButton.disposeAndClear();
}
+ maItemList.clear();
+ Dialog::dispose();
}
PushButton* ButtonDialog::ImplCreatePushButton( sal_uInt16 nBtnFlags )
@@ -74,13 +81,13 @@ PushButton* ButtonDialog::ImplCreatePushButton( sal_uInt16 nBtnFlags )
if ( nBtnFlags & BUTTONDIALOG_DEFBUTTON )
nStyle |= WB_DEFBUTTON;
if ( nBtnFlags & BUTTONDIALOG_CANCELBUTTON )
- pBtn = new CancelButton( this, nStyle );
+ pBtn = VclPtr<CancelButton>::Create( this, nStyle );
else if ( nBtnFlags & BUTTONDIALOG_OKBUTTON )
- pBtn = new OKButton( this, nStyle );
+ pBtn = VclPtr<OKButton>::Create( this, nStyle );
else if ( nBtnFlags & BUTTONDIALOG_HELPBUTTON )
- pBtn = new HelpButton( this, nStyle );
+ pBtn = VclPtr<HelpButton>::Create( this, nStyle );
else
- pBtn = new PushButton( this, nStyle );
+ pBtn = VclPtr<PushButton>::Create( this, nStyle );
if ( !(nBtnFlags & BUTTONDIALOG_HELPBUTTON) )
pBtn->SetClickHdl( LINK( this, ButtonDialog, ImplClickHdl ) );
@@ -327,10 +334,10 @@ void ButtonDialog::RemoveButton( sal_uInt16 nId )
if (it->mnId == nId)
{
it->mpPushButton->Hide();
-
- if (it->mbOwnButton )
- delete it->mpPushButton;
-
+ if (it->mbOwnButton)
+ it->mpPushButton.disposeAndClear();
+ else
+ it->mpPushButton.clear();
maItemList.erase(it);
return;
}
@@ -344,9 +351,8 @@ void ButtonDialog::Clear()
for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
{
it->mpPushButton->Hide();
-
- if (it->mbOwnButton )
- delete it->mpPushButton;
+ if (it->mbOwnButton)
+ it->mpPushButton.disposeAndClear();
}
maItemList.clear();
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index f7de2d12130a..dc06f34a003f 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -471,14 +471,14 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
//Remove ScrollWindow parent widgets whose children in vcl implement scrolling
//internally.
- for (std::map<vcl::Window*, vcl::Window*>::iterator aI = m_pParserState->m_aRedundantParentWidgets.begin(),
+ for (auto aI = m_pParserState->m_aRedundantParentWidgets.begin(),
aEnd = m_pParserState->m_aRedundantParentWidgets.end(); aI != aEnd; ++aI)
{
delete_by_window(aI->first);
}
//fdo#67378 merge the label into the disclosure button
- for (std::vector<VclExpander*>::iterator aI = m_pParserState->m_aExpanderWidgets.begin(),
+ for (auto aI = m_pParserState->m_aExpanderWidgets.begin(),
aEnd = m_pParserState->m_aExpanderWidgets.end(); aI != aEnd; ++aI)
{
VclExpander *pOne = *aI;
@@ -525,17 +525,24 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
VclBuilder::~VclBuilder()
{
+ disposeBuilder();
+}
+
+void VclBuilder::disposeBuilder()
+{
for (std::vector<WinAndId>::reverse_iterator aI = m_aChildren.rbegin(),
aEnd = m_aChildren.rend(); aI != aEnd; ++aI)
{
- delete aI->m_pWindow;
+ aI->m_pWindow.disposeAndClear();
}
+ m_aChildren.clear();
for (std::vector<MenuAndId>::reverse_iterator aI = m_aMenus.rbegin(),
aEnd = m_aMenus.rend(); aI != aEnd; ++aI)
{
delete aI->m_pMenu;
}
+ m_aMenus.clear();
}
void VclBuilder::handleTranslations(xmlreader::XmlReader &reader)
@@ -1259,7 +1266,7 @@ void VclBuilder::cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Wind
extern "C" { static void SAL_CALL thisModule() {} }
#endif
-vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, const OString &id,
+VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &name, const OString &id,
stringmap &rMap)
{
bool bIsPlaceHolder = name.isEmpty();
@@ -1301,7 +1308,7 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
}
if (bIsPlaceHolder || name == "GtkTreeSelection")
- return NULL;
+ return nullptr;
extractButtonImage(id, rMap, name == "GtkRadioButton");
@@ -1696,7 +1703,7 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
m_pParserState->m_nLastToolbarId = nItemId;
- return NULL; // no widget to be created
+ return nullptr; // no widget to be created
}
}
else if (name == "GtkSeparatorToolItem")
@@ -1705,7 +1712,7 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
if (pToolBox)
{
pToolBox->InsertSeparator();
- return NULL; // no widget to be created
+ return nullptr; // no widget to be created
}
}
else if (name == "GtkWindow")
@@ -1763,16 +1770,17 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
SAL_WARN_IF(!pWindow, "vcl.layout", "probably need to implement " << name.getStr() << " or add a make" << name.getStr() << " function");
if (pWindow)
{
+ VclPtr< vcl::Window > xWindow( pWindow );
pWindow->SetHelpId(m_sHelpRoot + id);
SAL_INFO("vcl.layout", "for " << name.getStr() <<
", created " << pWindow << " child of " <<
- pParent << "(" << pWindow->mpWindowImpl->mpParent << "/" <<
- pWindow->mpWindowImpl->mpRealParent << "/" <<
- pWindow->mpWindowImpl->mpBorderWindow << ") with helpid " <<
+ pParent << "(" << pWindow->mpWindowImpl->mpParent.get() << "/" <<
+ pWindow->mpWindowImpl->mpRealParent.get() << "/" <<
+ pWindow->mpWindowImpl->mpBorderWindow.get() << ") with helpid " <<
pWindow->GetHelpId().getStr());
- m_aChildren.push_back(WinAndId(id, pWindow, bVertical));
+ m_aChildren.push_back(WinAndId(id, xWindow, bVertical));
}
- return pWindow;
+ return VclPtr<vcl::Window>(pWindow, SAL_NO_ACQUIRE);
}
namespace
@@ -1807,10 +1815,10 @@ void VclBuilder::set_properties(vcl::Window *pWindow, const stringmap &rProps)
}
}
-vcl::Window *VclBuilder::insertObject(vcl::Window *pParent, const OString &rClass,
+VclPtr<vcl::Window> VclBuilder::insertObject(vcl::Window *pParent, const OString &rClass,
const OString &rID, stringmap &rProps, stringmap &rPango, stringmap &rAtk)
{
- vcl::Window *pCurrentChild = NULL;
+ VclPtr<vcl::Window> pCurrentChild;
if (m_pParent && !isConsideredGtkPseudo(m_pParent) && !m_sID.isEmpty() && rID.equals(m_sID))
{
@@ -1821,13 +1829,13 @@ vcl::Window *VclBuilder::insertObject(vcl::Window *pParent, const OString &rClas
//initialize the dialog.
if (pParent && pParent->IsSystemWindow())
{
- SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild);
+ SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild.get());
pSysWin->doDeferredInit(extractDeferredBits(rProps));
m_bToplevelHasDeferredInit = false;
}
else if (pParent && pParent->IsDockingWindow())
{
- DockingWindow *pDockWin = static_cast<DockingWindow*>(pCurrentChild);
+ DockingWindow *pDockWin = static_cast<DockingWindow*>(pCurrentChild.get());
pDockWin->doDeferredInit(extractDeferredBits(rProps));
m_bToplevelHasDeferredInit = false;
}
@@ -1846,14 +1854,14 @@ vcl::Window *VclBuilder::insertObject(vcl::Window *pParent, const OString &rClas
//if we're being inserting under a toplevel dialog whose init is
//deferred due to waiting to encounter it in this .ui, and it hasn't
//been seen yet, then make unattached widgets parent-less toplevels
- if (pParent == m_pParent && m_bToplevelHasDeferredInit)
+ if (pParent == m_pParent.get() && m_bToplevelHasDeferredInit)
pParent = NULL;
pCurrentChild = makeObject(pParent, rClass, rID, rProps);
}
if (pCurrentChild)
{
- if (pCurrentChild == m_pParent && m_bToplevelHasDeferredProperties)
+ if (pCurrentChild == m_pParent.get() && m_bToplevelHasDeferredProperties)
m_aDeferredProperties = rProps;
else
set_properties(pCurrentChild, rProps);
@@ -1865,7 +1873,7 @@ vcl::Window *VclBuilder::insertObject(vcl::Window *pParent, const OString &rClas
pCurrentChild->set_font_attribute(rKey, rValue);
}
- m_pParserState->m_aAtkInfo[pCurrentChild] = rAtk;
+ m_pParserState->m_aAtkInfo[VclPtr<vcl::Window>(pCurrentChild)] = rAtk;
}
rProps.clear();
@@ -1873,7 +1881,7 @@ vcl::Window *VclBuilder::insertObject(vcl::Window *pParent, const OString &rClas
rAtk.clear();
if (!pCurrentChild)
- pCurrentChild = m_aChildren.empty() ? pParent : m_aChildren.back().m_pWindow;
+ pCurrentChild = m_aChildren.empty() ? pParent : m_aChildren.back().m_pWindow.get();
return pCurrentChild;
}
@@ -2093,14 +2101,14 @@ void VclBuilder::handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
if (sInternalChild.startsWith("vbox") || sInternalChild.startsWith("messagedialog-vbox"))
{
if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pParent))
- pBoxParent->set_content_area(static_cast<VclBox*>(pCurrentChild));
+ pBoxParent->set_content_area(static_cast<VclBox*>(pCurrentChild)); // FIXME-VCLPTR
}
else if (sInternalChild.startsWith("action_area") || sInternalChild.startsWith("messagedialog-action_area"))
{
vcl::Window *pContentArea = pCurrentChild->GetParent();
if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pContentArea ? pContentArea->GetParent() : NULL))
{
- pBoxParent->set_action_area(static_cast<VclButtonBox*>(pCurrentChild));
+ pBoxParent->set_action_area(static_cast<VclButtonBox*>(pCurrentChild)); // FIXME-VCLPTR
}
}
@@ -2835,7 +2843,7 @@ template<typename T> bool insertItems(vcl::Window *pWindow, VclBuilder::stringma
return true;
}
-vcl::Window* VclBuilder::handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader)
+VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader)
{
OString sClass;
OString sID;
@@ -2867,22 +2875,22 @@ vcl::Window* VclBuilder::handleObject(vcl::Window *pParent, xmlreader::XmlReader
if (sClass == "GtkListStore")
{
handleListStore(reader, sID);
- return NULL;
+ return nullptr;
}
else if (sClass == "GtkMenu")
{
handleMenu(reader, sID);
- return NULL;
+ return nullptr;
}
else if (sClass == "GtkSizeGroup")
{
handleSizeGroup(reader, sID);
- return NULL;
+ return nullptr;
}
else if (sClass == "AtkObject")
{
handleAtkObject(reader, sID, pParent);
- return NULL;
+ return nullptr;
}
int nLevel = 1;
@@ -2893,7 +2901,7 @@ vcl::Window* VclBuilder::handleObject(vcl::Window *pParent, xmlreader::XmlReader
if (!sCustomProperty.isEmpty())
aProperties[OString("customproperty")] = sCustomProperty;
- vcl::Window *pCurrentChild = NULL;
+ VclPtr<vcl::Window> pCurrentChild;
while(true)
{
xmlreader::XmlReader::Result res = reader.nextItem(
@@ -3015,7 +3023,7 @@ void VclBuilder::applyPackingProperty(vcl::Window *pCurrent,
if (pCurrent->GetType() == WINDOW_SCROLLWINDOW)
{
- std::map<vcl::Window*, vcl::Window*>::iterator aFind = m_pParserState->m_aRedundantParentWidgets.find(pCurrent);
+ auto aFind = m_pParserState->m_aRedundantParentWidgets.find(VclPtr<vcl::Window>(pCurrent));
if (aFind != m_pParserState->m_aRedundantParentWidgets.end())
{
pCurrent = aFind->second;
@@ -3213,7 +3221,7 @@ void VclBuilder::collectAccelerator(xmlreader::XmlReader &reader, stringmap &rMa
vcl::Window *VclBuilder::get_widget_root()
{
- return m_aChildren.empty() ? NULL : m_aChildren[0].m_pWindow;
+ return m_aChildren.empty() ? NULL : m_aChildren[0].m_pWindow.get();
}
vcl::Window *VclBuilder::get_by_name(const OString& sID)
@@ -3279,17 +3287,17 @@ void VclBuilder::delete_by_name(const OString& sID)
{
if (aI->m_sID.equals(sID))
{
- delete aI->m_pWindow;
+ aI->m_pWindow.disposeAndClear();
m_aChildren.erase(aI);
break;
}
}
}
-void VclBuilder::delete_by_window(const vcl::Window *pWindow)
+void VclBuilder::delete_by_window(vcl::Window *pWindow)
{
drop_ownership(pWindow);
- delete pWindow;
+ pWindow->disposeOnce();
}
void VclBuilder::drop_ownership(const vcl::Window *pWindow)
@@ -3551,4 +3559,8 @@ void VclBuilder::mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rT
}
}
+VclBuilder::ParserState::ParserState()
+ : m_nLastToolbarId(0)
+{}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx
index 0c24e3051832..38efc376c7ef 100644
--- a/vcl/source/window/clipping.cxx
+++ b/vcl/source/window/clipping.cxx
@@ -842,7 +842,7 @@ void Window::ImplSaveOverlapBackground()
if ( nSaveBackSize+mpWindowImpl->mpFrameData->mnAllSaveBackSize <= IMPL_MAXALLSAVEBACKSIZE )
{
Size aOutSize( mnOutWidth, mnOutHeight );
- mpWindowImpl->mpOverlapData->mpSaveBackDev = new VirtualDevice( *mpWindowImpl->mpFrameWindow );
+ mpWindowImpl->mpOverlapData->mpSaveBackDev = VclPtr<VirtualDevice>::Create( *mpWindowImpl->mpFrameWindow );
if ( mpWindowImpl->mpOverlapData->mpSaveBackDev->SetOutputSizePixel( aOutSize ) )
{
mpWindowImpl->mpFrameWindow->ImplUpdateAll();
@@ -863,8 +863,7 @@ void Window::ImplSaveOverlapBackground()
}
else
{
- delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
- mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
+ mpWindowImpl->mpOverlapData->mpSaveBackDev.disposeAndClear();
}
}
}
@@ -915,8 +914,7 @@ void Window::ImplDeleteOverlapBackground()
if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
{
mpWindowImpl->mpFrameData->mnAllSaveBackSize -= mpWindowImpl->mpOverlapData->mnSaveBackSize;
- delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
- mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
+ mpWindowImpl->mpOverlapData->mpSaveBackDev.disposeAndClear();
if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
{
delete mpWindowImpl->mpOverlapData->mpSaveBackRgn;
@@ -929,7 +927,7 @@ void Window::ImplDeleteOverlapBackground()
else
{
vcl::Window* pTemp = mpWindowImpl->mpFrameData->mpFirstBackWin;
- while ( pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin != this )
+ while ( pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin.get() != this )
pTemp = pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin;
pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
}
diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx
index d0c9a7327e5d..e61d82b1b5d6 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -38,7 +38,7 @@ struct ImplCursorData
unsigned char mnDirection; // indicates writing direction
sal_uInt16 mnStyle; // Cursor-Style
bool mbCurVisible; // Ist Cursor aktuell sichtbar
- vcl::Window* mpWindow; // Zugeordnetes Windows
+ VclPtr<vcl::Window> mpWindow; // Zugeordnetes Windows
};
static void ImplCursorInvert( ImplCursorData* pData )
@@ -319,7 +319,7 @@ void vcl::Cursor::Hide()
void vcl::Cursor::SetWindow( vcl::Window* pWindow )
{
- if ( mpWindow != pWindow )
+ if ( mpWindow.get() != pWindow )
{
mpWindow = pWindow;
ImplNew();
diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx
index c04c430ceac3..5bb7b79cbb0e 100644
--- a/vcl/source/window/decoview.cxx
+++ b/vcl/source/window/decoview.cxx
@@ -1050,7 +1050,7 @@ void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, boo
{
Point aStart( rStart ), aStop( rStop );
const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
- vcl::Window *const pWin = (mpOutDev->GetOutDevType()==OUTDEV_WINDOW) ? static_cast<vcl::Window*>(mpOutDev) : NULL;
+ vcl::Window *const pWin = (mpOutDev->GetOutDevType()==OUTDEV_WINDOW) ? static_cast<vcl::Window*>(mpOutDev.get()) : NULL;
if(pWin)
{
ControlPart nPart = ( bVertical ? PART_SEPARATOR_VERT : PART_SEPARATOR_HORZ );
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 1e9f53a86df3..9e6d4bf12dae 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -347,8 +347,8 @@ void Dialog::ImplInitDialogData()
mbOldSaveBack = false;
mbInClose = false;
mbModalMode = false;
- mpContentArea = NULL;
- mpActionArea = NULL;
+ mpContentArea.clear();
+ mpActionArea.clear();
mnMousePositioned = 0;
mpDialogImpl = new DialogImpl;
}
@@ -403,7 +403,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle )
// create window with a small border ?
if ( (nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER )
{
- ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
+ VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
pBorderWin->mpWindowImpl->mpClientWindow = this;
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
@@ -421,7 +421,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle )
}
else
{
- ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
+ VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
pBorderWin->mpWindowImpl->mpClientWindow = this;
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
@@ -456,6 +456,12 @@ Dialog::Dialog( WindowType nType )
ImplInitDialogData();
}
+void VclBuilderContainer::disposeBuilder()
+{
+ if (m_pUIBuilder)
+ m_pUIBuilder->disposeBuilder();
+}
+
OUString VclBuilderContainer::getUIRootDir()
{
/*to-do, check if user config has an override before using shared one, etc*/
@@ -482,7 +488,7 @@ OUString VclBuilderContainer::getUIRootDir()
//do the init. Find the real parent stashed in mpDialogParent.
void Dialog::doDeferredInit(WinBits nBits)
{
- vcl::Window *pParent = mpDialogParent;
+ VclPtr<vcl::Window> pParent = mpDialogParent;
mpDialogParent = NULL;
ImplInit(pParent, nBits);
mbIsDefferedInit = false;
@@ -509,14 +515,14 @@ Dialog::Dialog(vcl::Window* pParent, WinBits nStyle)
ImplInit( pParent, nStyle );
}
-void Dialog::set_action_area(VclButtonBox* pActionArea)
+void Dialog::set_action_area(VclButtonBox* pBox)
{
- mpActionArea = pActionArea;
+ mpActionArea.set(pBox);
}
-void Dialog::set_content_area(VclBox* pContentArea)
+void Dialog::set_content_area(VclBox* pBox)
{
- mpContentArea = pContentArea;
+ mpContentArea.set(pBox);
}
void Dialog::settingOptimalLayoutSize(Window *pBox)
@@ -538,8 +544,17 @@ void Dialog::settingOptimalLayoutSize(Window *pBox)
Dialog::~Dialog()
{
+ disposeOnce();
+}
+
+void Dialog::dispose()
+{
delete mpDialogImpl;
mpDialogImpl = NULL;
+ mpPrevExecuteDlg.clear();
+ mpActionArea.clear();
+ mpContentArea.clear();
+ SystemWindow::dispose();
}
IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl)
@@ -991,7 +1006,7 @@ void Dialog::SetModalInputMode( bool bModal )
pPrevModalDlg = pPrevModalDlg->mpPrevExecuteDlg;
if( pPrevModalDlg &&
- ( pPrevModalDlg == mpPrevExecuteDlg
+ ( pPrevModalDlg == mpPrevExecuteDlg.get()
|| !pPrevModalDlg->IsWindowOrChild( this, true ) ) )
{
mpPrevExecuteDlg->SetModalInputMode( false );
@@ -1050,8 +1065,8 @@ void Dialog::GrabFocusToFirstControl()
void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
{
- ImplBorderWindow aImplWin( (vcl::Window*)this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
- aImplWin.GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
+ ScopedVclPtrInstance<ImplBorderWindow> aImplWin( (vcl::Window*)this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
+ aImplWin->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
}
void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong )
@@ -1077,13 +1092,13 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal
if (!( GetStyle() & WB_NOBORDER ))
{
- ImplBorderWindow aImplWin( this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
- aImplWin.SetText( GetText() );
- aImplWin.setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
- aImplWin.SetDisplayActive( true );
- aImplWin.InitView();
+ ScopedVclPtrInstance< ImplBorderWindow > aImplWin( this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
+ aImplWin->SetText( GetText() );
+ aImplWin->setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
+ aImplWin->SetDisplayActive( true );
+ aImplWin->InitView();
- aImplWin.Draw( Rectangle( aPos, aSize ), pDev, aPos );
+ aImplWin->Draw( Rectangle( aPos, aSize ), pDev, aPos );
}
pDev->Pop();
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index 2b63b3f3920d..eb899fdb2831 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -530,9 +530,9 @@ namespace
);
}
- bool focusNextInGroup(std::vector<RadioButton*>::iterator aStart, std::vector<RadioButton*> &rGroup)
+ bool focusNextInGroup(const std::vector<VclPtr<RadioButton> >::iterator& aStart, std::vector<VclPtr<RadioButton> > &rGroup)
{
- std::vector<RadioButton*>::iterator aI(aStart);
+ std::vector<VclPtr<RadioButton> >::iterator aI(aStart);
if (aStart != rGroup.end())
++aI;
@@ -564,7 +564,7 @@ namespace
bool nextInGroup(RadioButton *pSourceWindow, bool bBackward)
{
- std::vector<RadioButton*> aGroup(pSourceWindow->GetRadioButtonGroup(true));
+ std::vector<VclPtr<RadioButton> > aGroup(pSourceWindow->GetRadioButtonGroup(true));
if (aGroup.size() == 1) //only one button in group
return false;
@@ -572,7 +572,7 @@ namespace
if (bBackward)
std::reverse(aGroup.begin(), aGroup.end());
- std::vector<RadioButton*>::iterator aStart(std::find(aGroup.begin(), aGroup.end(), pSourceWindow));
+ auto aStart(std::find(aGroup.begin(), aGroup.end(), VclPtr<RadioButton>(pSourceWindow)));
assert(aStart != aGroup.end());
@@ -716,9 +716,9 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
if ( bKeyInput && mpWindowImpl->mpDlgCtrlDownWindow )
{
- if ( mpWindowImpl->mpDlgCtrlDownWindow != pButtonWindow )
+ if ( mpWindowImpl->mpDlgCtrlDownWindow.get() != pButtonWindow )
{
- static_cast<PushButton*>(mpWindowImpl->mpDlgCtrlDownWindow)->SetPressed( false );
+ static_cast<PushButton*>(mpWindowImpl->mpDlgCtrlDownWindow.get())->SetPressed( false );
mpWindowImpl->mpDlgCtrlDownWindow = NULL;
return true;
}
@@ -928,16 +928,16 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
{
if ( bKeyInput )
{
- if ( mpWindowImpl->mpDlgCtrlDownWindow && (mpWindowImpl->mpDlgCtrlDownWindow != pButtonWindow) )
+ if ( mpWindowImpl->mpDlgCtrlDownWindow && (mpWindowImpl->mpDlgCtrlDownWindow.get() != pButtonWindow) )
{
- static_cast<PushButton*>(mpWindowImpl->mpDlgCtrlDownWindow)->SetPressed( false );
+ static_cast<PushButton*>(mpWindowImpl->mpDlgCtrlDownWindow.get())->SetPressed( false );
mpWindowImpl->mpDlgCtrlDownWindow = NULL;
}
static_cast<PushButton*>(pButtonWindow)->SetPressed( true );
mpWindowImpl->mpDlgCtrlDownWindow = pButtonWindow;
}
- else if ( mpWindowImpl->mpDlgCtrlDownWindow == pButtonWindow )
+ else if ( mpWindowImpl->mpDlgCtrlDownWindow.get() == pButtonWindow )
{
mpWindowImpl->mpDlgCtrlDownWindow = NULL;
static_cast<PushButton*>(pButtonWindow)->SetPressed( false );
@@ -1060,7 +1060,7 @@ void Window::ImplDlgCtrlFocusChanged( vcl::Window* pWindow, bool bGetFocus )
{
if ( mpWindowImpl->mpDlgCtrlDownWindow && !bGetFocus )
{
- static_cast<PushButton*>(mpWindowImpl->mpDlgCtrlDownWindow)->SetPressed( false );
+ static_cast<PushButton*>(mpWindowImpl->mpDlgCtrlDownWindow.get())->SetPressed( false );
mpWindowImpl->mpDlgCtrlDownWindow = NULL;
}
diff --git a/vcl/source/window/dndevdis.cxx b/vcl/source/window/dndevdis.cxx
index dabfef79569e..94d6ae75b1dd 100644
--- a/vcl/source/window/dndevdis.cxx
+++ b/vcl/source/window/dndevdis.cxx
@@ -99,7 +99,7 @@ void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde )
vcl::Window* pChildWindow = findTopLevelWindow(location);
// handle the case that drop is in an other vcl window than the last dragOver
- if( pChildWindow != m_pCurrentWindow )
+ if( pChildWindow != m_pCurrentWindow.get() )
{
// fire dragExit on listeners of previous window
fireDragExitEvent( m_pCurrentWindow );
@@ -177,7 +177,7 @@ void SAL_CALL DNDEventDispatcher::dragOver( const DropTargetDragEvent& dtde )
vcl::Window * pChildWindow = findTopLevelWindow(location);
- if( pChildWindow != m_pCurrentWindow )
+ if( pChildWindow != m_pCurrentWindow.get() )
{
// fire dragExit on listeners of previous window
fireDragExitEvent( m_pCurrentWindow );
@@ -215,7 +215,7 @@ void SAL_CALL DNDEventDispatcher::dropActionChanged( const DropTargetDragEvent&
vcl::Window* pChildWindow = findTopLevelWindow(location);
- if( pChildWindow != m_pCurrentWindow )
+ if( pChildWindow != m_pCurrentWindow.get() )
{
// fire dragExit on listeners of previous window
fireDragExitEvent( m_pCurrentWindow );
diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx
index 623ea9635b37..43ce7bdb3c4d 100644
--- a/vcl/source/window/dockingarea.cxx
+++ b/vcl/source/window/dockingarea.cxx
@@ -92,7 +92,13 @@ DockingAreaWindow::DockingAreaWindow( vcl::Window* pParent ) :
DockingAreaWindow::~DockingAreaWindow()
{
+ disposeOnce();
+}
+
+void DockingAreaWindow::dispose()
+{
delete mpImplData;
+ Window::dispose();
}
void DockingAreaWindow::DataChanged( const DataChangedEvent& rDCEvt )
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 66b01f9e1283..160e21074029 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -57,6 +57,7 @@ public:
ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
ImplDockingWindowWrapper* pDockingWin );
virtual ~ImplDockFloatWin2();
+ virtual void dispose() SAL_OVERRIDE;
virtual void Move() SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
@@ -97,8 +98,14 @@ ImplDockFloatWin2::ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
ImplDockFloatWin2::~ImplDockFloatWin2()
{
+ disposeOnce();
+}
+
+void ImplDockFloatWin2::dispose()
+{
if( mnLastUserEvent )
Application::RemoveUserEvent( mnLastUserEvent );
+ FloatingWindow::dispose();
}
IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl)
@@ -477,6 +484,7 @@ private:
public:
ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
virtual ~ImplPopupFloatWin();
+ virtual void dispose() SAL_OVERRIDE;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
@@ -513,7 +521,13 @@ ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWra
ImplPopupFloatWin::~ImplPopupFloatWin()
{
+ disposeOnce();
+}
+
+void ImplPopupFloatWin::dispose()
+{
mpDockingWin = NULL;
+ FloatingWindow::dispose();
}
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
@@ -813,7 +827,7 @@ ImplDockingWindowWrapper::ImplDockingWindowWrapper( const vcl::Window *pWindow )
, mbStartDockingEnabled(false)
, mbLocked(false)
{
- DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow );
+ DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow.get() );
if( pDockWin )
mnFloatBits = pDockWin->GetFloatStyle();
}
@@ -842,14 +856,14 @@ bool ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
mbStartFloat = mbLastFloatMode;
// calculate FloatingBorder
- FloatingWindow* pWin;
+ VclPtr<FloatingWindow> pWin;
if ( mpFloatWin )
pWin = mpFloatWin;
else
- pWin = new ImplDockFloatWin2( mpParent, mnFloatBits, NULL );
+ pWin = VclPtr<ImplDockFloatWin2>::Create( mpParent, mnFloatBits, nullptr );
pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
if ( !mpFloatWin )
- delete pWin;
+ pWin.disposeAndClear();
Point aPos = GetWindow()->ImplOutputToFrame( Point() );
Size aSize = GetWindow()->GetOutputSizePixel();
@@ -1098,11 +1112,11 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, sal_uLon
// prepare reparenting
vcl::Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
- if( mpOldBorderWin == GetWindow() )
+ if( mpOldBorderWin.get() == GetWindow() )
mpOldBorderWin = NULL; // no border window found
// the new parent for popup mode
- ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
+ VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
pWin->SetText( GetWindow()->GetText() );
@@ -1153,7 +1167,7 @@ IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd)
GetWindow()->Show( false, SHOW_NOFOCUSCHANGE );
// set parameter for handler before destroying floating window
- ImplPopupFloatWin *pPopupFloatWin = static_cast<ImplPopupFloatWin*>(mpFloatWin);
+ ImplPopupFloatWin *pPopupFloatWin = static_cast<ImplPopupFloatWin*>(mpFloatWin.get());
EndPopupModeData aData( pPopupFloatWin->GetTearOffPosition(), mpFloatWin->IsPopupModeTearOff() );
// before deleting change parent back, so we can delete the floating window alone
@@ -1162,7 +1176,7 @@ IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd)
if ( mpOldBorderWin )
{
GetWindow()->SetParent( mpOldBorderWin );
- static_cast<ImplBorderWindow*>(mpOldBorderWin)->GetBorder(
+ static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
mpOldBorderWin->Resize();
@@ -1171,8 +1185,7 @@ IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd)
GetWindow()->SetParent( pRealParent );
GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
- delete mpFloatWin;
- mpFloatWin = NULL;
+ mpFloatWin.disposeAndClear();
// call handler - which will destroy the window and thus the wrapper as well !
GetWindow()->CallEventListeners( VCLEVENT_WINDOW_ENDPOPUPMODE, &aData );
@@ -1212,7 +1225,8 @@ void ImplDockingWindowWrapper::SetFloatingMode( bool bFloatMode )
mpOldBorderWin = NULL; // no border window found
ImplDockFloatWin2* pWin =
- new ImplDockFloatWin2(
+ VclPtr<ImplDockFloatWin2>::Create(
+
mpParent,
mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
mnFloatBits | WB_SYSTEMWINDOW
@@ -1277,7 +1291,7 @@ void ImplDockingWindowWrapper::SetFloatingMode( bool bFloatMode )
if ( mpOldBorderWin )
{
GetWindow()->SetParent( mpOldBorderWin );
- static_cast<ImplBorderWindow*>(mpOldBorderWin)->GetBorder(
+ static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
mpOldBorderWin->Resize();
@@ -1286,8 +1300,7 @@ void ImplDockingWindowWrapper::SetFloatingMode( bool bFloatMode )
GetWindow()->SetParent( pRealParent );
GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
- delete static_cast<ImplDockFloatWin2*>(mpFloatWin);
- mpFloatWin = NULL;
+ mpFloatWin.disposeAndClear();
GetWindow()->SetPosPixel( maDockPos );
if ( bVisible )
@@ -1350,7 +1363,7 @@ void ImplDockingWindowWrapper::SetMaxOutputSizePixel( const Size& rSize )
bool ImplDockingWindowWrapper::IsFloatingMode() const
{
- return (mpFloatWin != NULL);
+ return (mpFloatWin != nullptr);
}
void ImplDockingWindowWrapper::SetDragArea( const Rectangle& rRect )
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index a170e3f3d5ca..408cb328a132 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -42,8 +42,8 @@ public:
ImplData();
~ImplData();
- vcl::Window* mpParent;
- Size maMaxOutSize;
+ VclPtr<vcl::Window> mpParent;
+ Size maMaxOutSize;
};
DockingWindow::ImplData::ImplData()
@@ -59,7 +59,7 @@ DockingWindow::ImplData::~ImplData()
class ImplDockFloatWin : public FloatingWindow
{
private:
- DockingWindow* mpDockWin;
+ VclPtr<DockingWindow> mpDockWin;
sal_uInt64 mnLastTicks;
Idle maDockIdle;
Point maDockPos;
@@ -73,6 +73,7 @@ public:
ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits,
DockingWindow* pDockingWin );
virtual ~ImplDockFloatWin();
+ virtual void dispose() SAL_OVERRIDE;
virtual void Move() SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
@@ -111,8 +112,18 @@ ImplDockFloatWin::ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits,
ImplDockFloatWin::~ImplDockFloatWin()
{
+ disposeOnce();
+}
+
+void ImplDockFloatWin::dispose()
+{
if( mnLastUserEvent )
Application::RemoveUserEvent( mnLastUserEvent );
+
+ disposeBuilder();
+
+ mpDockWin.clear();
+ FloatingWindow::dispose();
}
IMPL_LINK_NOARG(ImplDockFloatWin, DockTimerHdl)
@@ -253,14 +264,14 @@ bool DockingWindow::ImplStartDocking( const Point& rPos )
mbStartFloat = mbLastFloatMode;
// calculate FloatingBorder
- FloatingWindow* pWin;
+ VclPtr<FloatingWindow> pWin;
if ( mpFloatWin )
pWin = mpFloatWin;
else
- pWin = new ImplDockFloatWin( mpImplData->mpParent, mnFloatBits, NULL );
+ pWin = VclPtr<ImplDockFloatWin>::Create( mpImplData->mpParent, mnFloatBits, nullptr );
pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
if ( !mpFloatWin )
- delete pWin;
+ pWin.disposeAndClear();
Point aPos = ImplOutputToFrame( Point() );
Size aSize = Window::GetOutputSizePixel();
@@ -460,6 +471,11 @@ DockingWindow::DockingWindow(vcl::Window* pParent, const OString& rID,
DockingWindow::~DockingWindow()
{
+ disposeOnce();
+}
+
+void DockingWindow::dispose()
+{
if ( IsFloatingMode() )
{
Show( false, SHOW_NOFOCUSCHANGE );
@@ -467,6 +483,11 @@ DockingWindow::~DockingWindow()
}
delete mpImplData;
mpImplData = NULL;
+ mpFloatWin.clear();
+ mpOldBorderWin.clear();
+ mpDialogParent.clear();
+ disposeBuilder();
+ Window::dispose();
}
void DockingWindow::Tracking( const TrackingEvent& rTEvt )
@@ -781,7 +802,8 @@ void DockingWindow::SetFloatingMode( bool bFloatMode )
mpOldBorderWin = mpWindowImpl->mpBorderWindow;
ImplDockFloatWin* pWin =
- new ImplDockFloatWin(
+ VclPtr<ImplDockFloatWin>::Create(
+
mpImplData->mpParent,
mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits,
this );
@@ -851,14 +873,13 @@ void DockingWindow::SetFloatingMode( bool bFloatMode )
if ( mpOldBorderWin )
{
SetParent( mpOldBorderWin );
- static_cast<ImplBorderWindow*>(mpOldBorderWin)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
+ static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
mpOldBorderWin->Resize();
}
mpWindowImpl->mpBorderWindow = mpOldBorderWin;
SetParent( pRealParent );
mpWindowImpl->mpRealParent = pRealParent;
- delete static_cast<ImplDockFloatWin*>(mpFloatWin);
- mpFloatWin = NULL;
+ mpFloatWin.disposeAndClear();
SetPosPixel( maDockPos );
ToggleFloatingMode();
@@ -1033,7 +1054,7 @@ bool DockingWindow::IsFloatingMode() const
if( pWrapper )
return pWrapper->IsFloatingMode();
else
- return (mpFloatWin != NULL);
+ return (mpFloatWin != nullptr);
}
void DockingWindow::SetMaxOutputSizePixel( const Size& rSize )
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index da38fde26b36..9c954125779d 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -94,6 +94,9 @@ bool Window::Notify( NotifyEvent& rNEvt )
{
bool nRet = false;
+ if (IsDisposed())
+ return false;
+
// check for docking window
// but do nothing if window is docked and locked
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
@@ -221,6 +224,9 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData )
{
pWindow->ImplAddDel( &aDelData );
+ if ( aDelData.IsDead() )
+ return;
+
pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
if ( aDelData.IsDead() )
@@ -277,7 +283,7 @@ ImplSVEvent * Window::PostUserEvent( const Link& rLink, void* pCaller )
void Window::RemoveUserEvent( ImplSVEvent * nUserEvent )
{
- DBG_ASSERT( nUserEvent->mpWindow == this,
+ DBG_ASSERT( nUserEvent->mpWindow.get() == this,
"Window::RemoveUserEvent(): Event doesn't send to this window or is already removed" );
DBG_ASSERT( nUserEvent->mbCall,
"Window::RemoveUserEvent(): Event is already removed" );
@@ -515,14 +521,14 @@ void Window::ImplCallFocusChangeActivate( vcl::Window* pNewOverlapWindow,
{
if ( pSVData->maWinData.mpLastDeacWin )
{
- if ( pSVData->maWinData.mpLastDeacWin == pNewOverlapWindow )
+ if ( pSVData->maWinData.mpLastDeacWin.get() == pNewOverlapWindow )
bCallActivate = false;
else
{
vcl::Window* pLastRealWindow = pSVData->maWinData.mpLastDeacWin->ImplGetWindow();
pSVData->maWinData.mpLastDeacWin->mpWindowImpl->mbActive = false;
pSVData->maWinData.mpLastDeacWin->Deactivate();
- if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin )
+ if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin.get() )
{
pLastRealWindow->mpWindowImpl->mbActive = true;
pLastRealWindow->Activate();
@@ -568,5 +574,21 @@ void Window::ImplCallFocusChangeActivate( vcl::Window* pNewOverlapWindow,
} /* namespace vcl */
+NotifyEvent::NotifyEvent()
+{
+ mpWindow = NULL;
+ mpData = NULL;
+ mnEventType = MouseNotifyEvent::NONE;
+ mnRetValue = 0;
+}
+
+NotifyEvent::NotifyEvent( MouseNotifyEvent nEventType, vcl::Window* pWindow,
+ const void* pEvent, long nRet )
+{
+ mpWindow = pWindow;
+ mpData = const_cast<void*>(pEvent);
+ mnEventType = nEventType;
+ mnRetValue = nRet;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 8ad024e1511f..65a5ef452458 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -39,7 +39,7 @@ public:
ImplData();
~ImplData();
- ToolBox* mpBox;
+ VclPtr<ToolBox> mpBox;
Rectangle maItemEdgeClipRect; // used to clip the common edge between a toolbar item and the border of this window
};
@@ -107,7 +107,7 @@ void FloatingWindow::ImplInit( vcl::Window* pParent, WinBits nStyle )
nBorderStyle |= BORDERWINDOW_STYLE_FRAME;
nStyle |= WB_CLOSEABLE; // make undecorated floaters closeable
}
- pBorderWin = new ImplBorderWindow( pParent, nStyle, nBorderStyle );
+ pBorderWin = VclPtr<ImplBorderWindow>::Create( pParent, nStyle, nBorderStyle );
SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
pBorderWin->mpWindowImpl->mpClientWindow = this;
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
@@ -185,18 +185,32 @@ void FloatingWindow::doDeferredInit(WinBits nBits)
FloatingWindow::~FloatingWindow()
{
- if( mbPopupModeCanceled )
- // indicates that ESC key was pressed
- // will be handled in Window::ImplGrabFocus()
- SetDialogControlFlags( GetDialogControlFlags() | WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL );
+ disposeOnce();
+}
+
+void FloatingWindow::dispose()
+{
+ if (mpImplData)
+ {
+ if( mbPopupModeCanceled )
+ // indicates that ESC key was pressed
+ // will be handled in Window::ImplGrabFocus()
+ SetDialogControlFlags( GetDialogControlFlags() | WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL );
- if ( IsInPopupMode() )
- EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL | FLOATWIN_POPUPMODEEND_DONTCALLHDL );
+ if ( IsInPopupMode() )
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL | FLOATWIN_POPUPMODEEND_DONTCALLHDL );
- if ( mnPostId )
- Application::RemoveUserEvent( mnPostId );
+ if ( mnPostId )
+ Application::RemoveUserEvent( mnPostId );
+ mnPostId = 0;
+ }
delete mpImplData;
+ mpImplData = NULL;
+
+ mpNextFloat.clear();
+ mpFirstPopupModeWin.clear();
+ SystemWindow::dispose();
}
Point FloatingWindow::CalcFloatingPosition( vcl::Window* pWindow, const Rectangle& rRect, sal_uLong nFlags, sal_uInt16& rArrangeIndex )
@@ -593,8 +607,8 @@ void FloatingWindow::SetTitleType( sal_uInt16 nTitle )
nTitleStyle = BORDERWINDOW_TITLE_POPUP;
else // nTitle == FLOATWIN_TITLE_NONE
nTitleStyle = BORDERWINDOW_TITLE_NONE;
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetTitleType( nTitleStyle, aOutSize );
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetTitleType( nTitleStyle, aOutSize );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
}
}
@@ -734,7 +748,7 @@ void FloatingWindow::ImplEndPopupMode( sal_uInt16 nFlags, sal_uLong nFocusId )
mbInCleanUp = true; // prevent killing this window due to focus change while working with it
// stop the PopupMode also for all following PopupMode windows
- while ( pSVData->maWinData.mpFirstFloat && pSVData->maWinData.mpFirstFloat != this )
+ while ( pSVData->maWinData.mpFirstFloat && pSVData->maWinData.mpFirstFloat.get() != this )
pSVData->maWinData.mpFirstFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
// delete window from the list
diff --git a/vcl/source/window/introwin.cxx b/vcl/source/window/introwin.cxx
index fa311d3129b5..d8b400135477 100644
--- a/vcl/source/window/introwin.cxx
+++ b/vcl/source/window/introwin.cxx
@@ -40,9 +40,16 @@ IntroWindow::IntroWindow( ) :
IntroWindow::~IntroWindow()
{
+ disposeOnce();
+}
+
+void IntroWindow::dispose()
+{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->mpIntroWindow == this )
- pSVData->mpIntroWindow = NULL;
+ if ( pSVData->mpIntroWindow.get() == this )
+ pSVData->mpIntroWindow = nullptr;
+
+ WorkWindow::dispose();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 2cc0a675b5dc..c9a43087cdf7 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1286,6 +1286,17 @@ void VclBin::setAllocation(const Size &rAllocation)
setLayoutAllocation(*pChild, Point(0, 0), rAllocation);
}
+VclFrame::~VclFrame()
+{
+ disposeOnce();
+}
+
+void VclFrame::dispose()
+{
+ m_pLabel.clear();
+ VclBin::dispose();
+}
+
//To-Do, hook a DecorationView into VclFrame ?
Size VclFrame::calculateRequisition() const
@@ -1467,11 +1478,17 @@ bool VclAlignment::set_property(const OString &rKey, const OString &rValue)
return true;
}
+void VclExpander::dispose()
+{
+ m_pDisclosureButton.disposeAndClear();
+ VclBin::dispose();
+}
+
const vcl::Window *VclExpander::get_child() const
{
const WindowImpl* pWindowImpl = ImplGetWindowImpl();
- assert(pWindowImpl->mpFirstChild == m_pDisclosureButton.get());
+ assert(pWindowImpl->mpFirstChild == m_pDisclosureButton);
return pWindowImpl->mpFirstChild->GetWindow(WINDOW_NEXT);
}
@@ -1488,12 +1505,12 @@ Size VclExpander::calculateRequisition() const
WindowImpl* pWindowImpl = ImplGetWindowImpl();
const vcl::Window *pChild = get_child();
- const vcl::Window *pLabel = pChild != pWindowImpl->mpLastChild ? pWindowImpl->mpLastChild : NULL;
+ const vcl::Window *pLabel = pChild != pWindowImpl->mpLastChild ? pWindowImpl->mpLastChild.get() : NULL;
if (pChild && pChild->IsVisible() && m_pDisclosureButton->IsChecked())
aRet = getLayoutRequisition(*pChild);
- Size aExpanderSize = getLayoutRequisition(*m_pDisclosureButton.get());
+ Size aExpanderSize = getLayoutRequisition(*m_pDisclosureButton);
if (pLabel && pLabel->IsVisible())
{
@@ -1525,9 +1542,9 @@ void VclExpander::setAllocation(const Size &rAllocation)
//The label widget is the last (of two) children
vcl::Window *pChild = get_child();
- vcl::Window *pLabel = pChild != pWindowImpl->mpLastChild ? pWindowImpl->mpLastChild : NULL;
+ vcl::Window *pLabel = pChild != pWindowImpl->mpLastChild.get() ? pWindowImpl->mpLastChild.get() : NULL;
- Size aButtonSize = getLayoutRequisition(*m_pDisclosureButton.get());
+ Size aButtonSize = getLayoutRequisition(*m_pDisclosureButton);
Size aLabelSize;
Size aExpanderSize = aButtonSize;
if (pLabel && pLabel->IsVisible())
@@ -1545,7 +1562,7 @@ void VclExpander::setAllocation(const Size &rAllocation)
long nExtraExpanderHeight = aExpanderSize.Height() - aButtonSize.Height();
Point aButtonPos(aChildPos.X(), aChildPos.Y() + nExtraExpanderHeight/2);
- setLayoutAllocation(*m_pDisclosureButton.get(), aButtonPos, aButtonSize);
+ setLayoutAllocation(*m_pDisclosureButton, aButtonPos, aButtonSize);
if (pLabel && pLabel->IsVisible())
{
@@ -1610,9 +1627,9 @@ IMPL_LINK( VclExpander, ClickHdl, DisclosureButton*, pBtn )
VclScrolledWindow::VclScrolledWindow(vcl::Window *pParent, WinBits nStyle)
: VclBin(pParent, nStyle)
, m_bUserManagedScrolling(false)
- , m_pVScroll(new ScrollBar(this, WB_HIDE | WB_VERT))
- , m_pHScroll(new ScrollBar(this, WB_HIDE | WB_HORZ))
- , m_aScrollBarBox(this, WB_HIDE)
+ , m_pVScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_VERT))
+ , m_pHScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_HORZ))
+ , m_aScrollBarBox(VclPtr<ScrollBarBox>::Create(this, WB_HIDE))
{
SetType(WINDOW_SCROLLWINDOW);
@@ -1621,6 +1638,14 @@ VclScrolledWindow::VclScrolledWindow(vcl::Window *pParent, WinBits nStyle)
m_pHScroll->SetScrollHdl(aLink);
}
+void VclScrolledWindow::dispose()
+{
+ m_pVScroll.disposeAndClear();
+ m_pHScroll.disposeAndClear();
+ m_aScrollBarBox.disposeAndClear();
+ VclBin::dispose();
+}
+
IMPL_LINK_NOARG(VclScrolledWindow, ScrollBarHdl)
{
vcl::Window *pChild = get_child();
@@ -1672,10 +1697,10 @@ Size VclScrolledWindow::calculateRequisition() const
aRet = getLayoutRequisition(*pChild);
if (GetStyle() & WB_VSCROLL)
- aRet.Width() += getLayoutRequisition(*m_pVScroll.get()).Width();
+ aRet.Width() += getLayoutRequisition(*m_pVScroll).Width();
if (GetStyle() & WB_HSCROLL)
- aRet.Height() += getLayoutRequisition(*m_pHScroll.get()).Height();
+ aRet.Height() += getLayoutRequisition(*m_pHScroll).Height();
return aRet;
}
@@ -1721,7 +1746,7 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation)
}
if (m_pVScroll->IsVisible())
- nAvailWidth -= getLayoutRequisition(*m_pVScroll.get()).Width();
+ nAvailWidth -= getLayoutRequisition(*m_pVScroll).Width();
// horz. ScrollBar
if (GetStyle() & WB_AUTOHSCROLL)
@@ -1730,7 +1755,7 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation)
m_pHScroll->Show(bShowHScroll);
if (bShowHScroll)
- nAvailHeight -= getLayoutRequisition(*m_pHScroll.get()).Height();
+ nAvailHeight -= getLayoutRequisition(*m_pHScroll).Height();
if (GetStyle() & WB_AUTOVSCROLL)
m_pVScroll->Show(nAvailHeight < aChildReq.Height());
@@ -1741,10 +1766,10 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation)
if (m_pVScroll->IsVisible())
{
- nScrollBarWidth = getLayoutRequisition(*m_pVScroll.get()).Width();
+ nScrollBarWidth = getLayoutRequisition(*m_pVScroll).Width();
Point aScrollPos(rAllocation.Width() - nScrollBarWidth, 0);
Size aScrollSize(nScrollBarWidth, rAllocation.Height());
- setLayoutAllocation(*m_pVScroll.get(), aScrollPos, aScrollSize);
+ setLayoutAllocation(*m_pVScroll, aScrollPos, aScrollSize);
aChildAllocation.Width() -= nScrollBarWidth;
aInnerSize.Width() -= nScrollBarWidth;
aChildAllocation.Height() = aChildReq.Height();
@@ -1752,10 +1777,10 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation)
if (m_pHScroll->IsVisible())
{
- nScrollBarHeight = getLayoutRequisition(*m_pHScroll.get()).Height();
+ nScrollBarHeight = getLayoutRequisition(*m_pHScroll).Height();
Point aScrollPos(0, rAllocation.Height() - nScrollBarHeight);
Size aScrollSize(rAllocation.Width(), nScrollBarHeight);
- setLayoutAllocation(*m_pHScroll.get(), aScrollPos, aScrollSize);
+ setLayoutAllocation(*m_pHScroll, aScrollPos, aScrollSize);
aChildAllocation.Height() -= nScrollBarHeight;
aInnerSize.Height() -= nScrollBarHeight;
aChildAllocation.Width() = aChildReq.Width();
@@ -1764,12 +1789,12 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation)
if (m_pVScroll->IsVisible() && m_pHScroll->IsVisible())
{
Point aBoxPos(aInnerSize.Width(), aInnerSize.Height());
- m_aScrollBarBox.SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, nScrollBarHeight));
- m_aScrollBarBox.Show();
+ m_aScrollBarBox->SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, nScrollBarHeight));
+ m_aScrollBarBox->Show();
}
else
{
- m_aScrollBarBox.Hide();
+ m_aScrollBarBox->Hide();
}
if (pChild && pChild->IsVisible())
@@ -1811,7 +1836,7 @@ bool VclScrolledWindow::Notify(NotifyEvent& rNEvt)
const CommandWheelData* pData = rCEvt.GetWheelData();
if( !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) )
{
- nDone = HandleScrollCommand(rCEvt, m_pHScroll.get(), m_pVScroll.get());
+ nDone = HandleScrollCommand(rCEvt, m_pHScroll, m_pVScroll);
}
}
}
@@ -1835,7 +1860,7 @@ const vcl::Window *VclEventBox::get_child() const
{
const WindowImpl* pWindowImpl = ImplGetWindowImpl();
- assert(pWindowImpl->mpFirstChild == &m_aEventBoxHelper);
+ assert(pWindowImpl->mpFirstChild.get() == m_aEventBoxHelper.get());
return pWindowImpl->mpFirstChild->GetWindow(WINDOW_NEXT);
}
@@ -1878,6 +1903,17 @@ void VclEventBox::Command(const CommandEvent&)
//discard events by default to block them reaching children
}
+VclEventBox::~VclEventBox()
+{
+ disposeOnce();
+}
+
+void VclEventBox::dispose()
+{
+ m_aEventBoxHelper.disposeAndClear();
+ VclBin::dispose();
+}
+
void VclSizeGroup::trigger_queue_resize()
{
//sufficient to trigger one widget to trigger all of them
@@ -1939,10 +1975,10 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue)
void MessageDialog::create_owned_areas()
{
set_border_width(12);
- m_pOwnedContentArea = new VclVBox(this, false, 24);
+ m_pOwnedContentArea.set(VclPtr<VclVBox>::Create(this, false, 24));
set_content_area(m_pOwnedContentArea);
m_pOwnedContentArea->Show();
- m_pOwnedActionArea = new VclHButtonBox(m_pOwnedContentArea);
+ m_pOwnedActionArea.set( VclPtr<VclHButtonBox>::Create(m_pOwnedContentArea) );
set_action_area(m_pOwnedActionArea);
m_pOwnedActionArea->Show();
}
@@ -1992,16 +2028,24 @@ MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUS
{
}
-MessageDialog::~MessageDialog()
+void MessageDialog::dispose()
{
for (size_t i = 0; i < m_aOwnedButtons.size(); ++i)
- delete m_aOwnedButtons[i];
- delete m_pSecondaryMessage;
- delete m_pPrimaryMessage;
- delete m_pImage;
- delete m_pGrid;
- delete m_pOwnedActionArea;
- delete m_pOwnedContentArea;
+ m_aOwnedButtons[i].disposeAndClear();
+ m_aOwnedButtons.clear();
+
+ m_pPrimaryMessage.disposeAndClear();
+ m_pSecondaryMessage.disposeAndClear();
+ m_pImage.disposeAndClear();
+ m_pGrid.disposeAndClear();
+ m_pOwnedActionArea.disposeAndClear();
+ m_pOwnedContentArea.disposeAndClear();
+ Dialog::dispose();
+}
+
+MessageDialog::~MessageDialog()
+{
+ disposeOnce();
}
void MessageDialog::response(short nResponseId)
@@ -2017,7 +2061,7 @@ IMPL_LINK(MessageDialog, ButtonHdl, Button *, pButton)
short MessageDialog::get_response(const vcl::Window *pWindow) const
{
- std::map<const vcl::Window*, short>::const_iterator aFind = m_aResponses.find(pWindow);
+ auto aFind = m_aResponses.find(pWindow);
if (aFind != m_aResponses.end())
return aFind->second;
if (!m_pUIBuilder)
@@ -2090,12 +2134,12 @@ short MessageDialog::Execute()
VclContainer *pContainer = get_content_area();
assert(pContainer);
- m_pGrid = new VclGrid(pContainer);
+ m_pGrid.set( VclPtr<VclGrid>::Create(pContainer) );
m_pGrid->reorderWithinParent(0);
m_pGrid->set_column_spacing(12);
m_pGrid->set_row_spacing(GetTextHeight());
- m_pImage = new FixedImage(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK);
+ m_pImage = VclPtr<FixedImage>::Create(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK);
switch (m_eMessageType)
{
case VCL_MESSAGE_INFO:
@@ -2120,7 +2164,7 @@ short MessageDialog::Execute()
bool bHasSecondaryText = !m_sSecondaryString.isEmpty();
- m_pPrimaryMessage = new VclMultiLineEdit(m_pGrid, nWinStyle);
+ m_pPrimaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle);
m_pPrimaryMessage->SetPaintTransparent(true);
m_pPrimaryMessage->EnableCursor(false);
@@ -2130,7 +2174,7 @@ short MessageDialog::Execute()
m_pPrimaryMessage->SetText(m_sPrimaryString);
m_pPrimaryMessage->Show(!m_sPrimaryString.isEmpty());
- m_pSecondaryMessage = new VclMultiLineEdit(m_pGrid, nWinStyle);
+ m_pSecondaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle);
m_pSecondaryMessage->SetPaintTransparent(true);
m_pSecondaryMessage->EnableCursor(false);
m_pSecondaryMessage->set_grid_left_attach(1);
@@ -2139,44 +2183,44 @@ short MessageDialog::Execute()
m_pSecondaryMessage->SetText(m_sSecondaryString);
m_pSecondaryMessage->Show(bHasSecondaryText);
- MessageDialog::SetMessagesWidths(this, m_pPrimaryMessage, bHasSecondaryText ? m_pSecondaryMessage : NULL);
+ MessageDialog::SetMessagesWidths(this, m_pPrimaryMessage, bHasSecondaryText ? m_pSecondaryMessage.get() : NULL);
VclButtonBox *pButtonBox = get_action_area();
assert(pButtonBox);
- PushButton *pBtn;
+ VclPtr<PushButton> pBtn;
switch (m_eButtonsType)
{
case VCL_BUTTONS_NONE:
break;
case VCL_BUTTONS_OK:
- pBtn = new OKButton(pButtonBox);
+ pBtn.set( VclPtr<OKButton>::Create(pButtonBox) );
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_OK;
break;
case VCL_BUTTONS_CLOSE:
- pBtn = new CloseButton(pButtonBox);
+ pBtn.set( VclPtr<CloseButton>::Create(pButtonBox) );
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_CLOSE;
break;
case VCL_BUTTONS_CANCEL:
- pBtn = new CancelButton(pButtonBox);
+ pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) );
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_CANCEL;
break;
case VCL_BUTTONS_YES_NO:
- pBtn = new PushButton(pButtonBox);
+ pBtn = VclPtr<PushButton>::Create(pButtonBox);
pBtn->SetText(Button::GetStandardText(StandardButtonType::Yes));
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_YES;
- pBtn = new PushButton(pButtonBox);
+ pBtn.set( VclPtr<PushButton>::Create(pButtonBox) );
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->SetText(Button::GetStandardText(StandardButtonType::No));
pBtn->Show();
@@ -2184,12 +2228,12 @@ short MessageDialog::Execute()
m_aResponses[pBtn] = RET_NO;
break;
case VCL_BUTTONS_OK_CANCEL:
- pBtn = new OKButton(pButtonBox);
+ pBtn.set( VclPtr<OKButton>::Create(pButtonBox) );
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_OK;
- pBtn = new CancelButton(pButtonBox);
+ pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) );
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 597e6627d1fb..e972321a7f53 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -133,16 +133,13 @@ Menu::Menu()
Menu::~Menu()
{
-
- vcl::LazyDeletor<Menu>::Undelete( this );
-
ImplCallEventListeners( VCLEVENT_OBJECT_DYING, ITEMPOS_INVALID );
// at the window free the reference to the accessible component
// and make sure the MenuFloatingWindow knows about our destruction
if ( pWindow )
{
- MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow);
+ MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
if( pFloat->pMenu == this )
pFloat->pMenu = NULL;
pWindow->SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >() );
@@ -1704,7 +1701,7 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin )
// account for the size of the close button, which actually is a toolbox
// due to NWF this is variable
- long nCloseButtonHeight = static_cast<MenuBarWindow*>(pWindow)->MinCloseButtonSize().Height();
+ long nCloseButtonHeight = static_cast<MenuBarWindow*>(pWindow.get())->MinCloseButtonSize().Height();
if (aSz.Height() < nCloseButtonHeight)
aSz.Height() = nCloseButtonHeight;
}
@@ -2269,7 +2266,7 @@ void Menu::ImplFillLayoutData() const
}
else
{
- MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow);
+ MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
ImplPaint( pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true );
}
}
@@ -2381,9 +2378,9 @@ bool Menu::IsHighlighted( sal_uInt16 nItemPos ) const
if( pWindow )
{
if (IsMenuBar())
- bRet = ( nItemPos == static_cast< MenuBarWindow * > (pWindow)->GetHighlightedItem() );
+ bRet = ( nItemPos == static_cast< MenuBarWindow * > (pWindow.get())->GetHighlightedItem() );
else
- bRet = ( nItemPos == static_cast< MenuFloatingWindow * > (pWindow)->GetHighlightedItem() );
+ bRet = ( nItemPos == static_cast< MenuFloatingWindow * > (pWindow.get())->GetHighlightedItem() );
}
return bRet;
@@ -2395,13 +2392,13 @@ void Menu::HighlightItem( sal_uInt16 nItemPos )
{
if (IsMenuBar())
{
- MenuBarWindow* pMenuWin = static_cast< MenuBarWindow* >( pWindow );
+ MenuBarWindow* pMenuWin = static_cast< MenuBarWindow* >( pWindow.get() );
pMenuWin->SetAutoPopup( false );
pMenuWin->ChangeHighlightItem( nItemPos, false );
}
else
{
- static_cast< MenuFloatingWindow* >( pWindow )->ChangeHighlightItem( nItemPos, false );
+ static_cast< MenuFloatingWindow* >( pWindow.get() )->ChangeHighlightItem( nItemPos, false );
}
}
}
@@ -2411,7 +2408,7 @@ IMenuBarWindow* MenuBar::getMenuBarWindow()
{
// so far just a dynamic_cast, hopefully to be turned into something saner
// at some stage
- IMenuBarWindow *pWin = dynamic_cast<IMenuBarWindow*>(pWindow);
+ IMenuBarWindow *pWin = dynamic_cast<IMenuBarWindow*>(pWindow.get());
//either there is no window (fdo#87663) or it is an IMenuBarWindow
assert(!pWindow || pWin);
return pWin;
@@ -2505,7 +2502,7 @@ vcl::Window* MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, Men
MenuBarWindow *pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow);
if (!pMenuBarWindow)
{
- pWindow = pMenuBarWindow = new MenuBarWindow( pParent );
+ pWindow = pMenuBarWindow = VclPtr<MenuBarWindow>::Create( pParent );
}
pMenu->pStartedFrom = 0;
@@ -2532,7 +2529,7 @@ void MenuBar::ImplDestroy( MenuBar* pMenu, bool bDelete )
IMenuBarWindow* pMenuWin = pMenu->getMenuBarWindow();
if (pMenuWin)
pMenuWin->KillActivePopup();
- delete pWindow;
+ pWindow->disposeOnce();
}
pMenu->pWindow = NULL;
}
@@ -2929,7 +2926,7 @@ sal_uInt16 PopupMenu::ImplExecute( vcl::Window* pW, const Rectangle& rRect, sal_
CreateAutoMnemonics();
}
- MenuFloatingWindow* pWin = new MenuFloatingWindow( this, pW, nStyle | WB_SYSTEMWINDOW );
+ VclPtrInstance<MenuFloatingWindow> pWin( this, pW, nStyle | WB_SYSTEMWINDOW );
if( pSVData->maNWFData.mbFlatMenu )
pWin->SetBorderStyle( WindowBorderStyle::NOBORDER );
else
@@ -3009,9 +3006,9 @@ sal_uInt16 PopupMenu::ImplExecute( vcl::Window* pW, const Rectangle& rRect, sal_
{
sal_uInt16 aPos;
if (pSFrom->IsMenuBar())
- aPos = static_cast<MenuBarWindow *>(pSFrom->pWindow)->GetHighlightedItem();
+ aPos = static_cast<MenuBarWindow *>(pSFrom->pWindow.get())->GetHighlightedItem();
else
- aPos = static_cast<MenuFloatingWindow *>(pSFrom->pWindow)->GetHighlightedItem();
+ aPos = static_cast<MenuFloatingWindow *>(pSFrom->pWindow.get())->GetHighlightedItem();
pWin->SetPosInParent( aPos ); // store position to be sent in SUBMENUDEACTIVATE
pSFrom->ImplCallEventListeners( VCLEVENT_MENU_SUBMENUACTIVATE, aPos );
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 553baa472ecb..47f61ad6829d 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -60,7 +60,7 @@ void DecoToolBox::DataChanged( const DataChangedEvent& rDCEvt )
void DecoToolBox::calcMinSize()
{
- ToolBox aTbx( GetParent() );
+ ScopedVclPtrInstance<ToolBox> aTbx( GetParent() );
if( GetItemCount() == 0 )
{
ResMgr* pResMgr = ImplGetResMgr();
@@ -68,7 +68,7 @@ void DecoToolBox::calcMinSize()
Bitmap aBitmap;
if( pResMgr )
aBitmap = Bitmap( ResId( SV_RESID_BITMAP_CLOSEDOC, *pResMgr ) );
- aTbx.InsertItem( IID_DOCUMENTCLOSE, Image( aBitmap ) );
+ aTbx->InsertItem( IID_DOCUMENTCLOSE, Image( aBitmap ) );
}
else
{
@@ -76,11 +76,13 @@ void DecoToolBox::calcMinSize()
for( sal_uInt16 i = 0; i < nItems; i++ )
{
sal_uInt16 nId = GetItemId( i );
- aTbx.InsertItem( nId, GetItemImage( nId ) );
+ aTbx->InsertItem( nId, GetItemImage( nId ) );
}
}
- aTbx.SetOutStyle( TOOLBOX_STYLE_FLAT );
- maMinSize = aTbx.CalcWindowSizePixel();
+ aTbx->SetOutStyle( TOOLBOX_STYLE_FLAT );
+ maMinSize = aTbx->CalcWindowSizePixel();
+
+ aTbx.disposeAndClear();
}
void DecoToolBox::SetImages( long nMaxHeight, bool bForce )
@@ -117,9 +119,9 @@ void DecoToolBox::SetImages( long nMaxHeight, bool bForce )
MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) :
Window( pParent, 0 ),
- aCloseBtn(this),
- aFloatBtn( this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE ),
- aHideBtn( this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE )
+ aCloseBtn(VclPtr<DecoToolBox>::Create(this)),
+ aFloatBtn(VclPtr<PushButton>::Create( this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE )),
+ aHideBtn(VclPtr<PushButton>::Create(this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE ))
{
SetType( WINDOW_MENUBARWINDOW );
pMenu = NULL;
@@ -137,25 +139,25 @@ MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) :
if( pResMgr )
{
BitmapEx aBitmap( ResId( SV_RESID_BITMAP_CLOSEDOC, *pResMgr ) );
- aCloseBtn.maImage = Image(aBitmap);
+ aCloseBtn->maImage = Image(aBitmap);
- aCloseBtn.SetOutStyle(TOOLBOX_STYLE_FLAT);
- aCloseBtn.SetBackground();
- aCloseBtn.SetPaintTransparent(true);
- aCloseBtn.SetParentClipMode(PARENTCLIPMODE_NOCLIP);
+ aCloseBtn->SetOutStyle(TOOLBOX_STYLE_FLAT);
+ aCloseBtn->SetBackground();
+ aCloseBtn->SetPaintTransparent(true);
+ aCloseBtn->SetParentClipMode(PARENTCLIPMODE_NOCLIP);
- aCloseBtn.InsertItem(IID_DOCUMENTCLOSE, aCloseBtn.maImage, ToolBoxItemBits::NONE);
- aCloseBtn.SetSelectHdl(LINK(this, MenuBarWindow, CloseHdl));
- aCloseBtn.AddEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
- aCloseBtn.SetQuickHelpText(IID_DOCUMENTCLOSE, ResId(SV_HELPTEXT_CLOSEDOCUMENT, *pResMgr).toString());
+ aCloseBtn->InsertItem(IID_DOCUMENTCLOSE, aCloseBtn->maImage, ToolBoxItemBits::NONE);
+ aCloseBtn->SetSelectHdl(LINK(this, MenuBarWindow, CloseHdl));
+ aCloseBtn->AddEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
+ aCloseBtn->SetQuickHelpText(IID_DOCUMENTCLOSE, ResId(SV_HELPTEXT_CLOSEDOCUMENT, *pResMgr).toString());
- aFloatBtn.SetClickHdl( LINK( this, MenuBarWindow, FloatHdl ) );
- aFloatBtn.SetSymbol( SymbolType::FLOAT );
- aFloatBtn.SetQuickHelpText( ResId(SV_HELPTEXT_RESTORE, *pResMgr).toString() );
+ aFloatBtn->SetClickHdl( LINK( this, MenuBarWindow, FloatHdl ) );
+ aFloatBtn->SetSymbol( SymbolType::FLOAT );
+ aFloatBtn->SetQuickHelpText( ResId(SV_HELPTEXT_RESTORE, *pResMgr).toString() );
- aHideBtn.SetClickHdl( LINK( this, MenuBarWindow, HideHdl ) );
- aHideBtn.SetSymbol( SymbolType::HIDE );
- aHideBtn.SetQuickHelpText( ResId(SV_HELPTEXT_MINIMIZE, *pResMgr).toString() );
+ aHideBtn->SetClickHdl( LINK( this, MenuBarWindow, HideHdl ) );
+ aHideBtn->SetSymbol( SymbolType::HIDE );
+ aHideBtn->SetQuickHelpText( ResId(SV_HELPTEXT_MINIMIZE, *pResMgr).toString() );
}
ImplInitStyleSettings();
@@ -165,8 +167,19 @@ MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) :
MenuBarWindow::~MenuBarWindow()
{
- aCloseBtn.RemoveEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
+ disposeOnce();
+}
+
+void MenuBarWindow::dispose()
+{
+ aCloseBtn->RemoveEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
RemoveEventListener(LINK(this, MenuBarWindow, ShowHideListener));
+
+ aHideBtn.disposeAndClear();
+ aFloatBtn.disposeAndClear();
+ aCloseBtn.disposeAndClear();
+
+ Window::dispose();
}
void MenuBarWindow::SetMenu( MenuBar* pMen )
@@ -177,10 +190,10 @@ void MenuBarWindow::SetMenu( MenuBar* pMen )
ImplInitMenuWindow( this, true, true );
if ( pMen )
{
- aCloseBtn.ShowItem(IID_DOCUMENTCLOSE, pMen->HasCloseButton());
- aCloseBtn.Show(pMen->HasCloseButton() || !m_aAddButtons.empty());
- aFloatBtn.Show(pMen->HasFloatButton());
- aHideBtn.Show(pMen->HasHideButton());
+ aCloseBtn->ShowItem(IID_DOCUMENTCLOSE, pMen->HasCloseButton());
+ aCloseBtn->Show(pMen->HasCloseButton() || !m_aAddButtons.empty());
+ aFloatBtn->Show(pMen->HasFloatButton());
+ aHideBtn->Show(pMen->HasHideButton());
}
Invalidate();
@@ -201,16 +214,16 @@ void MenuBarWindow::SetHeight(long nHeight)
void MenuBarWindow::ShowButtons( bool bClose, bool bFloat, bool bHide )
{
- aCloseBtn.ShowItem(IID_DOCUMENTCLOSE, bClose);
- aCloseBtn.Show(bClose || !m_aAddButtons.empty());
- aFloatBtn.Show( bFloat );
- aHideBtn.Show( bHide );
+ aCloseBtn->ShowItem(IID_DOCUMENTCLOSE, bClose);
+ aCloseBtn->Show(bClose || !m_aAddButtons.empty());
+ aFloatBtn->Show( bFloat );
+ aHideBtn->Show( bHide );
Resize();
}
Size MenuBarWindow::MinCloseButtonSize()
{
- return aCloseBtn.getMinSize();
+ return aCloseBtn->getMinSize();
}
IMPL_LINK_NOARG(MenuBarWindow, CloseHdl)
@@ -218,7 +231,7 @@ IMPL_LINK_NOARG(MenuBarWindow, CloseHdl)
if( ! pMenu )
return 0;
- if( aCloseBtn.GetCurItemId() == IID_DOCUMENTCLOSE )
+ if( aCloseBtn->GetCurItemId() == IID_DOCUMENTCLOSE )
{
// #i106052# call close hdl asynchronously to ease handler implementation
// this avoids still being in the handler while the DecoToolBox already
@@ -227,12 +240,12 @@ IMPL_LINK_NOARG(MenuBarWindow, CloseHdl)
}
else
{
- std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(aCloseBtn.GetCurItemId());
+ std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(aCloseBtn->GetCurItemId());
if( it != m_aAddButtons.end() )
{
MenuBar::MenuBarButtonCallbackArg aArg;
aArg.nId = it->first;
- aArg.bHighlight = (aCloseBtn.GetHighlightItemId() == it->first);
+ aArg.bHighlight = (aCloseBtn->GetHighlightItemId() == it->first);
aArg.pMenuBar = dynamic_cast<MenuBar*>(pMenu);
return it->second.m_aSelectLink.Call( &aArg );
}
@@ -250,11 +263,11 @@ IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent*, pEvent )
aArg.bHighlight = (pEvent->GetId() == VCLEVENT_TOOLBOX_HIGHLIGHT);
aArg.pMenuBar = dynamic_cast<MenuBar*>(pMenu);
if( pEvent->GetId() == VCLEVENT_TOOLBOX_HIGHLIGHT )
- aArg.nId = aCloseBtn.GetHighlightItemId();
+ aArg.nId = aCloseBtn->GetHighlightItemId();
else if( pEvent->GetId() == VCLEVENT_TOOLBOX_HIGHLIGHTOFF )
{
sal_uInt16 nPos = static_cast< sal_uInt16 >(reinterpret_cast<sal_IntPtr>(pEvent->GetData()));
- aArg.nId = aCloseBtn.GetItemId(nPos);
+ aArg.nId = aCloseBtn->GetItemId(nPos);
}
std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId );
if( it != m_aAddButtons.end() )
@@ -338,8 +351,8 @@ void MenuBarWindow::KillActivePopup()
{
if ( pActivePopup )
{
- if( pActivePopup->pWindow != NULL )
- if( static_cast<FloatingWindow *>(pActivePopup->pWindow)->IsInCleanUp() )
+ if( pActivePopup->pWindow )
+ if( static_cast<FloatingWindow *>(pActivePopup->pWindow.get())->IsInCleanUp() )
return; // kill it later
if ( pActivePopup->bInCallback )
@@ -446,7 +459,7 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
if( !bStayActive )
{
// #105406# avoid saving the focus when we already have the focus
- bool bNoSaveFocus = (this == ImplGetSVData()->maWinData.mpFocusWin );
+ bool bNoSaveFocus = (this == ImplGetSVData()->maWinData.mpFocusWin.get() );
if( nSaveFocusId )
{
@@ -913,30 +926,30 @@ void MenuBarWindow::Resize()
long nX = aOutSz.Width()-3;
long nY = 2;
- if ( aCloseBtn.IsVisible() )
+ if ( aCloseBtn->IsVisible() )
{
- aCloseBtn.Hide();
- aCloseBtn.SetImages(n);
- Size aTbxSize( aCloseBtn.CalcWindowSizePixel() );
+ aCloseBtn->Hide();
+ aCloseBtn->SetImages(n);
+ Size aTbxSize( aCloseBtn->CalcWindowSizePixel() );
nX -= aTbxSize.Width();
long nTbxY = (aOutSz.Height() - aTbxSize.Height())/2;
- aCloseBtn.setPosSizePixel(nX, nTbxY, aTbxSize.Width(), aTbxSize.Height());
+ aCloseBtn->setPosSizePixel(nX, nTbxY, aTbxSize.Width(), aTbxSize.Height());
nX -= 3;
- aCloseBtn.Show();
+ aCloseBtn->Show();
}
- if ( aFloatBtn.IsVisible() )
+ if ( aFloatBtn->IsVisible() )
{
nX -= n;
- aFloatBtn.setPosSizePixel( nX, nY, n, n );
+ aFloatBtn->setPosSizePixel( nX, nY, n, n );
}
- if ( aHideBtn.IsVisible() )
+ if ( aHideBtn->IsVisible() )
{
nX -= n;
- aHideBtn.setPosSizePixel( nX, nY, n, n );
+ aHideBtn->setPosSizePixel( nX, nY, n, n );
}
- aFloatBtn.SetSymbol( SymbolType::FLOAT );
- aHideBtn.SetSymbol( SymbolType::HIDE );
+ aFloatBtn->SetSymbol( SymbolType::FLOAT );
+ aHideBtn->SetSymbol( SymbolType::HIDE );
Invalidate();
}
@@ -1083,9 +1096,9 @@ sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link& i
AddButtonEntry& rNewEntry = m_aAddButtons[nId];
rNewEntry.m_nId = nId;
rNewEntry.m_aSelectLink = i_rLink;
- aCloseBtn.InsertItem(nId, i_rImage, ToolBoxItemBits::NONE, 0);
- aCloseBtn.calcMinSize();
- ShowButtons(aCloseBtn.IsItemVisible(IID_DOCUMENTCLOSE), aFloatBtn.IsVisible(), aHideBtn.IsVisible());
+ aCloseBtn->InsertItem(nId, i_rImage, ToolBoxItemBits::NONE, 0);
+ aCloseBtn->calcMinSize();
+ ShowButtons(aCloseBtn->IsItemVisible(IID_DOCUMENTCLOSE), aFloatBtn->IsVisible(), aHideBtn->IsVisible());
LayoutChanged();
if( pMenu->mpSalMenu )
@@ -1118,8 +1131,8 @@ Rectangle MenuBarWindow::GetMenuBarButtonRectPixel( sal_uInt16 nId )
if( aRect.IsEmpty() )
{
- aRect = aCloseBtn.GetItemRect(nId);
- Point aOffset = aCloseBtn.OutputToScreenPixel(Point());
+ aRect = aCloseBtn->GetItemRect(nId);
+ Point aOffset = aCloseBtn->OutputToScreenPixel(Point());
aRect.Move( aOffset.X(), aOffset.Y() );
}
}
@@ -1128,10 +1141,10 @@ Rectangle MenuBarWindow::GetMenuBarButtonRectPixel( sal_uInt16 nId )
void MenuBarWindow::RemoveMenuBarButton( sal_uInt16 nId )
{
- sal_uInt16 nPos = aCloseBtn.GetItemPos(nId);
- aCloseBtn.RemoveItem(nPos);
+ sal_uInt16 nPos = aCloseBtn->GetItemPos(nId);
+ aCloseBtn->RemoveItem(nPos);
m_aAddButtons.erase( nId );
- aCloseBtn.calcMinSize();
+ aCloseBtn->calcMinSize();
LayoutChanged();
if( pMenu->mpSalMenu )
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index 46c79accc0f5..bb3c8be22073 100644
--- a/vcl/source/window/menubarwindow.hxx
+++ b/vcl/source/window/menubarwindow.hxx
@@ -39,7 +39,9 @@ class DecoToolBox : public ToolBox
using Window::ImplInit;
public:
- DecoToolBox( vcl::Window* pParent, WinBits nStyle = 0 );
+ DecoToolBox( vcl::Window* pParent, WinBits nStyle = 0 );
+ virtual ~DecoToolBox() {}
+
void ImplInit();
void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
@@ -52,6 +54,7 @@ public:
Image maImage;
};
+
/** Class that implements the actual window of the menu bar.
*/
class MenuBarWindow : public vcl::Window, public IMenuBarWindow
@@ -62,32 +65,32 @@ class MenuBarWindow : public vcl::Window, public IMenuBarWindow
private:
struct AddButtonEntry
{
- sal_uInt16 m_nId;
- Link m_aSelectLink;
- Link m_aHighlightLink;
+ sal_uInt16 m_nId;
+ Link m_aSelectLink;
+ Link m_aHighlightLink;
AddButtonEntry() : m_nId( 0 ) {}
};
Menu* pMenu;
PopupMenu* pActivePopup;
- sal_uInt16 nHighlightedItem;
- sal_uInt16 nRolloveredItem;
- sal_uLong nSaveFocusId;
+ sal_uInt16 nHighlightedItem;
+ sal_uInt16 nRolloveredItem;
+ sal_uLong nSaveFocusId;
bool mbAutoPopup;
bool bIgnoreFirstMove;
bool bStayActive;
- DecoToolBox aCloseBtn;
- PushButton aFloatBtn;
- PushButton aHideBtn;
+ VclPtr<DecoToolBox> aCloseBtn;
+ VclPtr<PushButton> aFloatBtn;
+ VclPtr<PushButton> aHideBtn;
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons;
void HighlightItem( sal_uInt16 nPos, bool bHighlight );
virtual void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true) SAL_OVERRIDE;
- sal_uInt16 ImplFindEntry( const Point& rMousePos ) const;
+ sal_uInt16 ImplFindEntry( const Point& rMousePos ) const;
void ImplCreatePopup( bool bPreSelectFirst );
virtual bool HandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true) SAL_OVERRIDE;
Rectangle ImplGetItemRect( sal_uInt16 nPos );
@@ -107,7 +110,8 @@ private:
public:
MenuBarWindow( vcl::Window* pParent );
- virtual ~MenuBarWindow();
+ virtual ~MenuBarWindow();
+ virtual void dispose() SAL_OVERRIDE;
virtual void ShowButtons(bool bClose, bool bFloat, bool bHide) SAL_OVERRIDE;
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 19e709d43423..227cc8bb5932 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -104,7 +104,14 @@ void MenuFloatingWindow::doShutdown()
MenuFloatingWindow::~MenuFloatingWindow()
{
+ disposeOnce();
+}
+
+void MenuFloatingWindow::dispose()
+{
doShutdown();
+
+ FloatingWindow::dispose();
}
void MenuFloatingWindow::Resize()
@@ -406,8 +413,8 @@ void MenuFloatingWindow::KillActivePopup( PopupMenu* pThisOnly )
{
if ( pActivePopup && ( !pThisOnly || ( pThisOnly == pActivePopup ) ) )
{
- if( pActivePopup->pWindow != NULL )
- if( static_cast<FloatingWindow *>(pActivePopup->pWindow)->IsInCleanUp() )
+ if( pActivePopup->pWindow )
+ if( static_cast<FloatingWindow *>(pActivePopup->pWindow.get())->IsInCleanUp() )
return; // kill it later
if ( pActivePopup->bInCallback )
pActivePopup->bCanceled = true;
diff --git a/vcl/source/window/menufloatingwindow.hxx b/vcl/source/window/menufloatingwindow.hxx
index 5e1b3437584d..3157be8d493f 100644
--- a/vcl/source/window/menufloatingwindow.hxx
+++ b/vcl/source/window/menufloatingwindow.hxx
@@ -80,7 +80,8 @@ protected:
public:
MenuFloatingWindow( Menu* pMenu, vcl::Window* pParent, WinBits nStyle );
- virtual ~MenuFloatingWindow();
+ virtual ~MenuFloatingWindow();
+ virtual void dispose() SAL_OVERRIDE;
void doShutdown();
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index bb7698a8428e..c4623a61fb72 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -198,7 +198,7 @@ static bool IsWindowFocused(const WindowImpl& rWinImpl)
void Window::ImplGrabFocus( sal_uInt16 nFlags )
{
// #143570# no focus for destructing windows
- if( mpWindowImpl->mbInDtor )
+ if( !mpWindowImpl || mpWindowImpl->mbInDispose )
return;
// some event listeners do really bad stuff
@@ -215,7 +215,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
// For a lack of design we need a little hack here to
// ensure that dialogs on close pass the focus back to
// the correct window
- if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
+ if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow.get() != this) &&
!(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
@@ -231,7 +231,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
// For a lack of design we need a little hack here to
// ensure that dialogs on close pass the focus back to
// the correct window
- if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
+ if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow.get() != this) &&
!(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
@@ -257,7 +257,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
vcl::Window *pFrame = pSVData->maWinData.mpFirstFrame;
while( pFrame )
{
- if( pFrame != mpWindowImpl->mpFrameWindow && pFrame->mpWindowImpl->mpFrameData->mnFocusId )
+ if( pFrame != mpWindowImpl->mpFrameWindow.get() && pFrame->mpWindowImpl->mpFrameData->mnFocusId )
{
bAsyncFocusWaiting = true;
break;
@@ -283,11 +283,13 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
pParent = pParent->mpWindowImpl->mpParent;
}
- if ( ( pSVData->maWinData.mpFocusWin != this && ! mpWindowImpl->mbInDtor ) || ( bAsyncFocusWaiting && !bHasFocus && !bMustNotGrabFocus ) )
+ if ( ( pSVData->maWinData.mpFocusWin.get() != this &&
+ mpWindowImpl && !mpWindowImpl->mbInDispose ) ||
+ ( bAsyncFocusWaiting && !bHasFocus && !bMustNotGrabFocus ) )
{
// EndExtTextInput if it is not the same window
if ( pSVData->maWinData.mpExtTextInputWin &&
- (pSVData->maWinData.mpExtTextInputWin != this) )
+ (pSVData->maWinData.mpExtTextInputWin.get() != this) )
pSVData->maWinData.mpExtTextInputWin->EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
// mark this windows as the last FocusWindow
@@ -358,7 +360,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
pOldFocusWindow->ImplCallDeactivateListeners( this );
}
- if ( pSVData->maWinData.mpFocusWin == this )
+ if ( pSVData->maWinData.mpFocusWin.get() == this )
{
if ( mpWindowImpl->mpSysObj )
{
@@ -367,7 +369,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
mpWindowImpl->mpSysObj->GrabFocus();
}
- if ( pSVData->maWinData.mpFocusWin == this )
+ if ( pSVData->maWinData.mpFocusWin.get() == this )
{
if ( mpWindowImpl->mpCursor )
mpWindowImpl->mpCursor->ImplShow();
@@ -450,13 +452,13 @@ void Window::CaptureMouse()
ImplSVData* pSVData = ImplGetSVData();
// possibly stop tracking
- if ( pSVData->maWinData.mpTrackWin != this )
+ if ( pSVData->maWinData.mpTrackWin.get() != this )
{
if ( pSVData->maWinData.mpTrackWin )
pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
}
- if ( pSVData->maWinData.mpCaptureWin != this )
+ if ( pSVData->maWinData.mpCaptureWin.get() != this )
{
pSVData->maWinData.mpCaptureWin = this;
mpWindowImpl->mpFrame->CaptureMouse( true );
@@ -468,10 +470,10 @@ void Window::ReleaseMouse()
ImplSVData* pSVData = ImplGetSVData();
- DBG_ASSERTWARNING( pSVData->maWinData.mpCaptureWin == this,
+ DBG_ASSERTWARNING( pSVData->maWinData.mpCaptureWin.get() == this,
"Window::ReleaseMouse(): window doesn't have the mouse capture" );
- if ( pSVData->maWinData.mpCaptureWin == this )
+ if ( pSVData->maWinData.mpCaptureWin.get() == this )
{
pSVData->maWinData.mpCaptureWin = NULL;
mpWindowImpl->mpFrame->CaptureMouse( false );
@@ -657,6 +659,8 @@ void Window::ImplStartDnd()
Reference< css::datatransfer::dnd::XDropTarget > Window::GetDropTarget()
{
+ if( !mpWindowImpl )
+ return Reference< css::datatransfer::dnd::XDropTarget >();
if( ! mpWindowImpl->mxDNDListenerContainer.is() )
{
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index 2c68157e759c..9f2fd75973c7 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -151,9 +151,15 @@ MessBox::MessBox( vcl::Window* pParent, WinBits nStyle,
MessBox::~MessBox()
{
- delete mpVCLMultiLineEdit;
- delete mpFixedImage;
- delete mpCheckBox;
+ disposeOnce();
+}
+
+void MessBox::dispose()
+{
+ mpVCLMultiLineEdit.disposeAndClear();
+ mpFixedImage.disposeAndClear();
+ mpCheckBox.disposeAndClear();
+ ButtonDialog::dispose();
}
void MessBox::ImplPosControls()
@@ -190,17 +196,12 @@ void MessBox::ImplPosControls()
WinBits nWinStyle = WB_LEFT | WB_NOLABEL;
sal_uInt16 nTextStyle = TEXT_DRAW_MULTILINE | TEXT_DRAW_TOP | TEXT_DRAW_LEFT;
- delete mpVCLMultiLineEdit;
- if ( mpFixedImage )
- {
- delete mpFixedImage;
- mpFixedImage = NULL;
- }
+ mpVCLMultiLineEdit.disposeAndClear();
+ mpFixedImage.disposeAndClear();
if ( mpCheckBox )
{
mbCheck = mpCheckBox->IsChecked();
- delete mpCheckBox;
- mpCheckBox = NULL;
+ mpCheckBox.disposeAndClear();
}
// Clean up message text with tabs
@@ -230,7 +231,7 @@ void MessBox::ImplPosControls()
aImageSize.Width() += 4;
aImageSize.Height() += 4;
aTextPos.X() += aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE;
- mpFixedImage = new FixedImage( this );
+ mpFixedImage = VclPtr<FixedImage>::Create( this );
mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X,
IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ),
aImageSize );
@@ -320,7 +321,7 @@ void MessBox::ImplPosControls()
}
}
- mpCheckBox = new CheckBox( this );
+ mpCheckBox = VclPtr<CheckBox>::Create( this );
mpCheckBox->Check( mbCheck );
mpCheckBox->SetText( aMnemonicString );
mpCheckBox->SetStyle( mpCheckBox->GetStyle() | WB_WORDBREAK );
@@ -342,7 +343,7 @@ void MessBox::ImplPosControls()
mpCheckBox->Show();
}
- mpVCLMultiLineEdit = new VclMultiLineEdit( this, nWinStyle );
+ mpVCLMultiLineEdit = VclPtr<VclMultiLineEdit>::Create( this, nWinStyle );
mpVCLMultiLineEdit->SetText( aMessText );
mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize );
mpVCLMultiLineEdit->Show();
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 741940f45e2d..21af6cc53598 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -16,22 +16,22 @@ class OpenGLWindowImpl
{
public:
OpenGLWindowImpl(vcl::Window* pWindow);
+ ~OpenGLWindowImpl() { mxChildWindow.disposeAndClear(); }
OpenGLContext& getContext() { return maContext;}
private:
OpenGLContext maContext;
- std::unique_ptr<SystemChildWindow> mxChildWindow;
+ VclPtr<SystemChildWindow> mxChildWindow;
};
OpenGLWindowImpl::OpenGLWindowImpl(vcl::Window* pWindow)
{
SystemWindowData aData = OpenGLContext::generateWinData(pWindow, false);
- mxChildWindow.reset(new SystemChildWindow(pWindow, 0, &aData));
+ mxChildWindow.reset(VclPtr<SystemChildWindow>::Create(pWindow, 0, &aData));
mxChildWindow->Show();
maContext.init(mxChildWindow.get());
pWindow->SetMouseTransparent(false);
}
-
OpenGLWindow::OpenGLWindow(vcl::Window* pParent):
Window(pParent, 0),
mxImpl(new OpenGLWindowImpl(this)),
@@ -41,8 +41,16 @@ OpenGLWindow::OpenGLWindow(vcl::Window* pParent):
OpenGLWindow::~OpenGLWindow()
{
+ disposeOnce();
+}
+
+void OpenGLWindow::dispose()
+{
if(mpRenderer)
mpRenderer->contextDestroyed();
+ mpRenderer = NULL;
+ mxImpl.reset();
+ Window::dispose();
}
OpenGLContext& OpenGLWindow::getContext()
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 1384dfe3d8f2..1dd9b3a50e98 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -43,7 +43,7 @@
class PaintHelper
{
private:
- vcl::Window* m_pWindow;
+ VclPtr<vcl::Window> m_pWindow;
vcl::Region* m_pChildRegion;
Rectangle m_aSelectionRect;
Rectangle m_aPaintRect;
@@ -1094,7 +1094,7 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP
mpWindowImpl->mbReallyVisible = bRVisible;
// paint metafile to VDev
- VirtualDevice* pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 );
+ VclPtrInstance<VirtualDevice> pMaskedDevice( *i_pTargetOutDev, 0, 0 );
pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() );
pMaskedDevice->EnableRTL( IsRTLEnabled() );
aMtf.WindStart();
@@ -1102,7 +1102,7 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP
BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), pMaskedDevice->GetOutputSizePixel() ) );
i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx );
// get rid of virtual device now so they don't pile up during recursive calls
- delete pMaskedDevice, pMaskedDevice = NULL;
+ pMaskedDevice.disposeAndClear();
for( vcl::Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext )
{
diff --git a/vcl/source/window/popupmenuwindow.cxx b/vcl/source/window/popupmenuwindow.cxx
index 1a33ff9037ca..2d9c52699054 100644
--- a/vcl/source/window/popupmenuwindow.cxx
+++ b/vcl/source/window/popupmenuwindow.cxx
@@ -46,7 +46,13 @@ PopupMenuFloatingWindow::PopupMenuFloatingWindow( vcl::Window* pParent, WinBits
PopupMenuFloatingWindow::~PopupMenuFloatingWindow()
{
+ disposeOnce();
+}
+
+void PopupMenuFloatingWindow::dispose()
+{
delete mpImplData;
+ FloatingWindow::dispose();
}
sal_uInt16 PopupMenuFloatingWindow::GetMenuStackLevel() const
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index c4ea5c7aac3c..f24755d92904 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -64,24 +64,33 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeShowNupOrderWindow(vcl
PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent )
: Window( i_pParent, 0 )
, maOrigSize( 10, 10 )
- , maPageVDev( *this )
+ , maPageVDev( VclPtr<VirtualDevice>::Create(*this) )
, maToolTipString(VclResId( SV_PRINT_PRINTPREVIEW_TXT).toString())
, mbGreyscale( false )
- , maHorzDim( this, WB_HORZ | WB_CENTER )
- , maVertDim( this, WB_VERT | WB_VCENTER )
+ , maHorzDim(VclPtr<FixedLine>::Create(this, WB_HORZ | WB_CENTER))
+ , maVertDim(VclPtr<FixedLine>::Create(this, WB_VERT | WB_VCENTER))
{
SetPaintTransparent( true );
SetBackground();
- maPageVDev.SetBackground( Color( COL_WHITE ) );
- maHorzDim.Show();
- maVertDim.Show();
+ maPageVDev->SetBackground( Color( COL_WHITE ) );
+ maHorzDim->Show();
+ maVertDim->Show();
- maHorzDim.SetText( OUString( "2.0in" ) );
- maVertDim.SetText( OUString( "2.0in" ) );
+ maHorzDim->SetText( OUString( "2.0in" ) );
+ maVertDim->SetText( OUString( "2.0in" ) );
}
PrintDialog::PrintPreviewWindow::~PrintPreviewWindow()
{
+ disposeOnce();
+}
+
+void PrintDialog::PrintPreviewWindow::dispose()
+{
+ maHorzDim.disposeAndClear();
+ maVertDim.disposeAndClear();
+ maPageVDev.disposeAndClear();
+ Window::dispose();
}
const sal_Int32 PrintDialog::PrintPreviewWindow::PREVIEW_BITMAP_WIDTH = 1600;
@@ -91,7 +100,7 @@ void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDC
// react on settings changed
if( i_rDCEvt.GetType() == DataChangedEventType::SETTINGS )
{
- maPageVDev.SetBackground( Color( COL_WHITE ) );
+ maPageVDev->SetBackground( Color( COL_WHITE ) );
}
Window::DataChanged( i_rDCEvt );
}
@@ -99,7 +108,7 @@ void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDC
void PrintDialog::PrintPreviewWindow::Resize()
{
Size aNewSize( GetSizePixel() );
- long nTextHeight = maHorzDim.GetTextHeight();
+ long nTextHeight = maHorzDim->GetTextHeight();
// leave small space for decoration
aNewSize.Width() -= nTextHeight + 2;
aNewSize.Height() -= nTextHeight + 2;
@@ -140,21 +149,21 @@ void PrintDialog::PrintPreviewWindow::Resize()
aScaledSize.Width() = PREVIEW_BITMAP_WIDTH;
aScaledSize.Height() = PREVIEW_BITMAP_WIDTH * aAspectRatio;
- maPageVDev.SetOutputSizePixel( aScaledSize, false );
+ maPageVDev->SetOutputSizePixel( aScaledSize, false );
// position dimension lines
Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2,
nTextHeight + (aNewSize.Height() - maPreviewSize.Height())/2 );
- maHorzDim.SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ),
+ maHorzDim->SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ),
Size( maPreviewSize.Width(), nTextHeight ) );
- maVertDim.SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ),
+ maVertDim->SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ),
Size( nTextHeight, maPreviewSize.Height() ) );
}
void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
{
- long nTextHeight = maHorzDim.GetTextHeight();
+ long nTextHeight = maHorzDim->GetTextHeight();
Size aSize( GetSizePixel() );
Point aOffset( (aSize.Width() - maPreviewSize.Width() + nTextHeight) / 2 ,
(aSize.Height() - maPreviewSize.Height() + nTextHeight) / 2 );
@@ -218,8 +227,8 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
maOrigSize = i_rOrigSize;
maReplacementString = i_rReplacement;
mbGreyscale = i_bGreyscale;
- maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY );
- maPageVDev.EnableOutput( true );
+ maPageVDev->SetReferenceDevice( i_nDPIX, i_nDPIY );
+ maPageVDev->EnableOutput( true );
// use correct measurements
const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() );
@@ -241,13 +250,13 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
aBuf.append( i_rPaperName );
aBuf.append( ')' );
}
- maHorzDim.SetText( aBuf.makeStringAndClear() );
+ maHorzDim->SetText( aBuf.makeStringAndClear() );
aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
aBuf.append( aNumText )
.append( sal_Unicode( ' ' ) );
aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" );
- maVertDim.SetText( aBuf.makeStringAndClear() );
+ maVertDim->SetText( aBuf.makeStringAndClear() );
Resize();
preparePreviewBitmap();
@@ -258,8 +267,8 @@ void PrintDialog::PrintPreviewWindow::preparePreviewBitmap()
{
GDIMetaFile aMtf( maMtf );
- Size aVDevSize( maPageVDev.GetOutputSizePixel() );
- const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) );
+ Size aVDevSize( maPageVDev->GetOutputSizePixel() );
+ const Size aLogicSize( maPageVDev->PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) );
Size aOrigSize( maOrigSize );
if( aOrigSize.Width() < 1 )
aOrigSize.Width() = aLogicSize.Width();
@@ -267,31 +276,31 @@ void PrintDialog::PrintPreviewWindow::preparePreviewBitmap()
aOrigSize.Height() = aLogicSize.Height();
double fScale = double(aLogicSize.Width())/double(aOrigSize.Width());
- maPageVDev.Erase();
- maPageVDev.Push();
- maPageVDev.SetMapMode( MAP_100TH_MM );
- sal_uLong nOldDrawMode = maPageVDev.GetDrawMode();
+ maPageVDev->Erase();
+ maPageVDev->Push();
+ maPageVDev->SetMapMode( MAP_100TH_MM );
+ sal_uLong nOldDrawMode = maPageVDev->GetDrawMode();
if( mbGreyscale )
- maPageVDev.SetDrawMode( maPageVDev.GetDrawMode() |
+ maPageVDev->SetDrawMode( maPageVDev->GetDrawMode() |
( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT |
DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) );
aMtf.WindStart();
aMtf.Scale( fScale, fScale );
aMtf.WindStart();
- const sal_uInt16 nOriginalAA(maPageVDev.GetAntialiasing());
- maPageVDev.SetAntialiasing(nOriginalAA | ANTIALIASING_ENABLE_B2DDRAW);
- aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize );
- maPageVDev.SetAntialiasing(nOriginalAA);
+ const sal_uInt16 nOriginalAA(maPageVDev->GetAntialiasing());
+ maPageVDev->SetAntialiasing(nOriginalAA | ANTIALIASING_ENABLE_B2DDRAW);
+ aMtf.Play( maPageVDev.get(), Point( 0, 0 ), aLogicSize );
+ maPageVDev->SetAntialiasing(nOriginalAA);
- maPageVDev.Pop();
+ maPageVDev->Pop();
SetMapMode( MAP_PIXEL );
- maPageVDev.SetMapMode( MAP_PIXEL );
+ maPageVDev->SetMapMode( MAP_PIXEL );
- maPreviewBitmap = Bitmap(maPageVDev.GetBitmap(Point(0, 0), aVDevSize));
+ maPreviewBitmap = Bitmap(maPageVDev->GetBitmap(Point(0, 0), aVDevSize));
- maPageVDev.SetDrawMode( nOldDrawMode );
+ maPageVDev->SetDrawMode( nOldDrawMode );
}
PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( vcl::Window* i_pParent )
@@ -303,10 +312,6 @@ PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( vcl::Window* i_pParent )
ImplInitSettings();
}
-PrintDialog::ShowNupOrderWindow::~ShowNupOrderWindow()
-{
-}
-
void PrintDialog::ShowNupOrderWindow::ImplInitSettings()
{
SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
@@ -619,13 +624,13 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
if( maJobPage.mpPrinters->GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND )
{
maJobPage.mpPrinters->SelectEntry( aValue );
- maPController->setPrinter(std::make_shared<Printer>(aValue));
+ maPController->setPrinter( VclPtrInstance<Printer>( aValue ) );
}
else
{
// fall back to default printer
maJobPage.mpPrinters->SelectEntry( Printer::GetDefaultPrinterName() );
- maPController->setPrinter(std::make_shared<Printer>(Printer::GetDefaultPrinterName()));
+ maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
}
}
// not printing to file
@@ -712,7 +717,22 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
PrintDialog::~PrintDialog()
{
+ disposeOnce();
+}
+
+void PrintDialog::dispose()
+{
delete mpCustomOptionsUIBuilder;
+ mpTabCtrl.clear();
+ mpPreviewWindow.clear();
+ mpPageEdit.clear();
+ mpNumPagesText.clear();
+ mpBackwardBtn.clear();
+ mpForwardBtn.clear();
+ mpOKButton.clear();
+ mpCancelButton.clear();
+ mpHelpButton.clear();
+ ModalDialog::dispose();
}
void PrintDialog::readFromSettings()
@@ -1207,7 +1227,7 @@ void PrintDialog::checkControlDependencies()
void PrintDialog::checkOptionalControlDependencies()
{
- for( std::map< vcl::Window*, OUString >::iterator it = maControlToPropertyMap.begin();
+ for( auto it = maControlToPropertyMap.begin();
it != maControlToPropertyMap.end(); ++it )
{
bool bShouldbeEnabled = maPController->isUIOptionEnabled( it->second );
@@ -1229,9 +1249,9 @@ void PrintDialog::checkOptionalControlDependencies()
}
}
- if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first) )
+ if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first.get()) )
{
- std::map< vcl::Window*, sal_Int32 >::const_iterator r_it = maControlToNumValMap.find( it->first );
+ auto r_it = maControlToNumValMap.find( it->first );
if( r_it != maControlToNumValMap.end() )
{
bShouldbeEnabled = maPController->isUIChoiceEnabled( it->second, r_it->second );
@@ -1308,7 +1328,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
{
const MapMode aMapMode( MAP_100TH_MM );
GDIMetaFile aMtf;
- std::shared_ptr<Printer> aPrt(maPController->getPrinter());
+ VclPtr<Printer> aPrt( maPController->getPrinter() );
if( nPages > 0 )
{
PrinterController::PageSize aPageSize =
@@ -1501,7 +1521,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox )
{
OUString aNewPrinter( pBox->GetSelectEntry() );
// set new printer
- maPController->setPrinter(std::make_shared<Printer>(aNewPrinter));
+ maPController->setPrinter( VclPtrInstance<Printer>( aNewPrinter ) );
maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() );
// update text fields
updatePrinterText();
@@ -1650,7 +1670,7 @@ IMPL_LINK_NOARG(PrintDialog, UIOptionsChanged)
PropertyValue* PrintDialog::getValueForWindow( vcl::Window* i_pWindow ) const
{
PropertyValue* pVal = NULL;
- std::map< vcl::Window*, OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow );
+ auto it = maControlToPropertyMap.find( i_pWindow );
if( it != maControlToPropertyMap.end() )
{
pVal = maPController->getValue( it->second );
@@ -1666,10 +1686,10 @@ PropertyValue* PrintDialog::getValueForWindow( vcl::Window* i_pWindow ) const
void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
{
beans::PropertyValue* pValue = maPController->getValue( i_rProperty );
- std::map< OUString, std::vector< vcl::Window* > >::const_iterator it = maPropertyToWindowMap.find( i_rProperty );
+ auto it = maPropertyToWindowMap.find( i_rProperty );
if( pValue && it != maPropertyToWindowMap.end() )
{
- const std::vector< vcl::Window* >& rWindows( it->second );
+ const std::vector< VclPtr<vcl::Window> >& rWindows( it->second );
if( ! rWindows.empty() )
{
bool bVal = false;
@@ -1677,7 +1697,7 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
if( pValue->Value >>= bVal )
{
// we should have a CheckBox for this one
- CheckBox* pBox = dynamic_cast< CheckBox* >( rWindows.front() );
+ CheckBox* pBox = dynamic_cast< CheckBox* >( rWindows.front().get() );
if( pBox )
{
pBox->Check( bVal );
@@ -1698,14 +1718,14 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
else if( pValue->Value >>= nVal )
{
// this could be a ListBox or a RadioButtonGroup
- ListBox* pList = dynamic_cast< ListBox* >( rWindows.front() );
+ ListBox* pList = dynamic_cast< ListBox* >( rWindows.front().get() );
if( pList )
{
pList->SelectEntryPos( static_cast< sal_uInt16 >(nVal) );
}
else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) )
{
- RadioButton* pBtn = dynamic_cast< RadioButton* >( rWindows[nVal] );
+ RadioButton* pBtn = dynamic_cast< RadioButton* >( rWindows[nVal].get() );
DBG_ASSERT( pBtn, "unexpected control for property" );
if( pBtn )
pBtn->Check();
@@ -1717,7 +1737,7 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
void PrintDialog::makeEnabled( vcl::Window* i_pWindow )
{
- std::map< vcl::Window*, OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow );
+ auto it = maControlToPropertyMap.find( i_pWindow );
if( it != maControlToPropertyMap.end() )
{
OUString aDependency( maPController->makeEnabled( it->second ) );
@@ -1752,7 +1772,7 @@ IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn )
if( i_pBtn->IsChecked() )
{
PropertyValue* pVal = getValueForWindow( i_pBtn );
- std::map< vcl::Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn );
+ auto it = maControlToNumValMap.find( i_pBtn );
if( pVal && it != maControlToNumValMap.end() )
{
makeEnabled( i_pBtn );
@@ -1895,6 +1915,19 @@ PrintProgressDialog::PrintProgressDialog(vcl::Window* i_pParent, int i_nMax)
}
+PrintProgressDialog::~PrintProgressDialog()
+{
+ disposeOnce();
+}
+
+void PrintProgressDialog::dispose()
+{
+ mpText.clear();
+ mpProgress.clear();
+ mpButton.clear();
+ ModelessDialog::dispose();
+}
+
IMPL_LINK( PrintProgressDialog, ClickHdl, Button*, pButton )
{
if( pButton == mpButton )
diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx
index 7532ccf9cdc4..a40ef10dc592 100644
--- a/vcl/source/window/scrwnd.cxx
+++ b/vcl/source/window/scrwnd.cxx
@@ -84,8 +84,16 @@ ImplWheelWindow::ImplWheelWindow( vcl::Window* pParent ) :
ImplWheelWindow::~ImplWheelWindow()
{
+ disposeOnce();
+}
+
+void ImplWheelWindow::dispose()
+{
ImplStop();
delete mpTimer;
+ mpTimer = NULL;
+
+ FloatingWindow::dispose();
}
void ImplWheelWindow::ImplStop()
diff --git a/vcl/source/window/scrwnd.hxx b/vcl/source/window/scrwnd.hxx
index ddd08f940cc9..6ec18c4e2b73 100644
--- a/vcl/source/window/scrwnd.hxx
+++ b/vcl/source/window/scrwnd.hxx
@@ -70,7 +70,8 @@ protected:
public:
ImplWheelWindow( vcl::Window* pParent );
- virtual ~ImplWheelWindow();
+ virtual ~ImplWheelWindow();
+ virtual void dispose() SAL_OVERRIDE;
void ImplStop();
void ImplSetWheelMode( sal_uLong nWheelMode );
diff --git a/vcl/source/window/settings.cxx b/vcl/source/window/settings.cxx
index 3e60bbd9bab0..63586e3ee70e 100644
--- a/vcl/source/window/settings.cxx
+++ b/vcl/source/window/settings.cxx
@@ -51,8 +51,8 @@ void Window::SetSettings( const AllSettings& rSettings, bool bChild )
{
mpWindowImpl->mpBorderWindow->SetSettings( rSettings, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->SetSettings( rSettings, true );
}
AllSettings aOldSettings(*mxSettings);
@@ -86,8 +86,8 @@ void Window::UpdateSettings( const AllSettings& rSettings, bool bChild )
{
mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->UpdateSettings( rSettings, true );
}
AllSettings aOldSettings(*mxSettings);
diff --git a/vcl/source/window/split.cxx b/vcl/source/window/split.cxx
index 947dc986cf20..70482c02a039 100644
--- a/vcl/source/window/split.cxx
+++ b/vcl/source/window/split.cxx
@@ -151,8 +151,19 @@ Splitter::Splitter( vcl::Window* pParent, WinBits nStyle ) :
Splitter::~Splitter()
{
- TaskPaneList *pTList = GetSystemWindow()->GetTaskPaneList();
- pTList->RemoveWindow( this );
+ disposeOnce();
+}
+
+void Splitter::dispose()
+{
+ SystemWindow *pSysWin = GetSystemWindow();
+ if(pSysWin)
+ {
+ TaskPaneList *pTList = pSysWin->GetTaskPaneList();
+ pTList->RemoveWindow(this);
+ }
+ mpRefWin.clear();
+ Window::dispose();
}
void Splitter::SetHorizontal(bool bNew)
diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx
index c18e1d06adca..293479151943 100644
--- a/vcl/source/window/splitwin.cxx
+++ b/vcl/source/window/splitwin.cxx
@@ -53,9 +53,9 @@ struct ImplSplitItem
long mnOldWidth;
long mnOldHeight;
ImplSplitSet* mpSet;
- vcl::Window* mpWindow;
- vcl::Window* mpOrgParent;
- sal_uInt16 mnId;
+ VclPtr<vcl::Window> mpWindow;
+ VclPtr<vcl::Window> mpOrgParent;
+ sal_uInt16 mnId;
SplitWindowItemBits mnBits;
bool mbFixed;
bool mbSubSize;
@@ -1347,9 +1347,16 @@ SplitWindow::SplitWindow( vcl::Window* pParent, WinBits nStyle ) :
SplitWindow::~SplitWindow()
{
+ disposeOnce();
+}
+
+void SplitWindow::dispose()
+{
// delete Sets
- ImplDeleteSet( mpMainSet );
+ if (mpMainSet)
+ ImplDeleteSet( mpMainSet );
mpMainSet = NULL; //NULL for base-class callbacks during dtoring
+ DockingWindow::dispose();
}
void SplitWindow::ImplSetWindowSize( long nDelta )
diff --git a/vcl/source/window/stacking.cxx b/vcl/source/window/stacking.cxx
index f20c0ece86dd..ccf60ca60f5f 100644
--- a/vcl/source/window/stacking.cxx
+++ b/vcl/source/window/stacking.cxx
@@ -46,8 +46,8 @@ using ::com::sun::star::awt::XTopWindow;
struct ImplCalcToTopData
{
- ImplCalcToTopData* mpNext;
- vcl::Window* mpWindow;
+ ImplCalcToTopData* mpNext;
+ VclPtr<vcl::Window> mpWindow;
vcl::Region* mpInvalidateRegion;
};
@@ -117,12 +117,12 @@ void Window::ImplRemoveWindow( bool bRemoveFrameData )
{
if ( ImplIsOverlapWindow() )
{
- if ( mpWindowImpl->mpFrameData->mpFirstOverlap == this )
+ if ( mpWindowImpl->mpFrameData->mpFirstOverlap.get() == this )
mpWindowImpl->mpFrameData->mpFirstOverlap = mpWindowImpl->mpNextOverlap;
else
{
vcl::Window* pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
- while ( pTempWin->mpWindowImpl->mpNextOverlap != this )
+ while ( pTempWin->mpWindowImpl->mpNextOverlap.get() != this )
pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
pTempWin->mpWindowImpl->mpNextOverlap = mpWindowImpl->mpNextOverlap;
}
@@ -194,7 +194,7 @@ void Window::reorderWithinParent(sal_uInt16 nNewPosition)
void Window::ImplToBottomChild()
{
- if ( !ImplIsOverlapWindow() && !mpWindowImpl->mbReallyVisible && (mpWindowImpl->mpParent->mpWindowImpl->mpLastChild != this) )
+ if ( !ImplIsOverlapWindow() && !mpWindowImpl->mbReallyVisible && (mpWindowImpl->mpParent->mpWindowImpl->mpLastChild.get() != this) )
{
// put the window to the end of the list
if ( mpWindowImpl->mpPrev )
@@ -265,7 +265,7 @@ void Window::ImplToTop( sal_uInt16 nFlags )
}
else
{
- if ( mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap != this )
+ if ( mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap.get() != this )
{
// remove window from the list
mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
@@ -477,7 +477,7 @@ void Window::SetZOrder( vcl::Window* pRefWindow, sal_uInt16 nFlags )
DBG_ASSERT( pRefWindow->mpWindowImpl->mpParent == mpWindowImpl->mpParent, "Window::SetZOrder() - pRefWindow has other parent" );
if ( nFlags & WINDOW_ZORDER_BEFOR )
{
- if ( pRefWindow->mpWindowImpl->mpPrev == this )
+ if ( pRefWindow->mpWindowImpl->mpPrev.get() == this )
return;
if ( ImplIsOverlapWindow() )
@@ -515,7 +515,7 @@ void Window::SetZOrder( vcl::Window* pRefWindow, sal_uInt16 nFlags )
}
else if ( nFlags & WINDOW_ZORDER_BEHIND )
{
- if ( pRefWindow->mpWindowImpl->mpNext == this )
+ if ( pRefWindow->mpWindowImpl->mpNext.get() == this )
return;
if ( ImplIsOverlapWindow() )
@@ -632,7 +632,7 @@ void Window::EnableAlwaysOnTop( bool bEnable )
bool Window::IsTopWindow() const
{
- if ( mpWindowImpl->mbInDtor )
+ if ( !mpWindowImpl || mpWindowImpl->mbInDispose )
return false;
// topwindows must be frames or they must have a borderwindow which is a frame
@@ -879,9 +879,8 @@ void Window::SetParent( vcl::Window* pNewParent )
// remove ownerdraw decorated windows from list in the top-most frame window
if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
{
- ::std::vector< vcl::Window* >& rList = ImplGetOwnerDrawList();
- ::std::vector< vcl::Window* >::iterator p;
- p = ::std::find( rList.begin(), rList.end(), this );
+ ::std::vector< VclPtr<vcl::Window> >& rList = ImplGetOwnerDrawList();
+ auto p = ::std::find( rList.begin(), rList.end(), VclPtr<vcl::Window>(this) );
if( p != rList.end() )
rList.erase( p );
}
@@ -895,7 +894,7 @@ void Window::SetParent( vcl::Window* pNewParent )
return;
}
- if ( mpWindowImpl->mpParent == pNewParent )
+ if ( mpWindowImpl->mpParent.get() == pNewParent )
return;
if ( mpWindowImpl->mbFrame )
@@ -912,7 +911,7 @@ void Window::SetParent( vcl::Window* pNewParent )
else
{
pNewOverlapWindow = pNewParent->ImplGetFirstOverlapWindow();
- if ( mpWindowImpl->mpOverlapWindow != pNewOverlapWindow )
+ if ( mpWindowImpl->mpOverlapWindow.get() != pNewOverlapWindow )
pOldOverlapWindow = mpWindowImpl->mpOverlapWindow;
else
pOldOverlapWindow = NULL;
@@ -1023,6 +1022,8 @@ void Window::SetParent( vcl::Window* pNewParent )
sal_uInt16 Window::GetChildCount() const
{
+ if (!mpWindowImpl)
+ return 0;
sal_uInt16 nChildCount = 0;
vcl::Window* pChild = mpWindowImpl->mpFirstChild;
@@ -1037,6 +1038,8 @@ sal_uInt16 Window::GetChildCount() const
vcl::Window* Window::GetChild( sal_uInt16 nChild ) const
{
+ if (!mpWindowImpl)
+ return NULL;
sal_uInt16 nChildCount = 0;
vcl::Window* pChild = mpWindowImpl->mpFirstChild;
@@ -1053,6 +1056,8 @@ vcl::Window* Window::GetChild( sal_uInt16 nChild ) const
vcl::Window* Window::GetWindow( sal_uInt16 nType ) const
{
+ if (!mpWindowImpl)
+ return 0;
switch ( nType )
{
@@ -1104,17 +1109,17 @@ vcl::Window* Window::GetWindow( sal_uInt16 nType ) const
return const_cast<vcl::Window*>(this);
case WINDOW_FIRSTTOPWINDOWCHILD:
- return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.begin();
+ return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : (*ImplGetWinData()->maTopWindowChildren.begin()).get();
case WINDOW_LASTTOPWINDOWCHILD:
- return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.rbegin();
+ return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : (*ImplGetWinData()->maTopWindowChildren.rbegin()).get();
case WINDOW_PREVTOPWINDOWSIBLING:
{
if ( !mpWindowImpl->mpRealParent )
return NULL;
- const ::std::list< vcl::Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
- ::std::list< vcl::Window* >::const_iterator myPos =
+ const ::std::list< VclPtr<vcl::Window> >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
+ ::std::list< VclPtr<vcl::Window> >::const_iterator myPos =
::std::find( rTopWindows.begin(), rTopWindows.end(), this );
if ( myPos == rTopWindows.end() )
return NULL;
@@ -1127,8 +1132,8 @@ vcl::Window* Window::GetWindow( sal_uInt16 nType ) const
{
if ( !mpWindowImpl->mpRealParent )
return NULL;
- const ::std::list< vcl::Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
- ::std::list< vcl::Window* >::const_iterator myPos =
+ const ::std::list< VclPtr<vcl::Window> >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
+ ::std::list< VclPtr<vcl::Window> >::const_iterator myPos =
::std::find( rTopWindows.begin(), rTopWindows.end(), this );
if ( ( myPos == rTopWindows.end() ) || ( ++myPos == rTopWindows.end() ) )
return NULL;
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index bca642e23612..7f43c18e2b1a 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -45,7 +45,7 @@ public:
ImplData();
~ImplData();
- VirtualDevice* mpVirDev;
+ VclPtr<VirtualDevice> mpVirDev;
long mnItemBorderWidth;
bool mbDrawItemFrames:1;
};
@@ -123,7 +123,7 @@ void StatusBar::ImplInit( vcl::Window* pParent, WinBits nStyle )
// remember WinBits
mpItemList = new ImplStatusItemList;
- mpImplData->mpVirDev = new VirtualDevice( *this );
+ mpImplData->mpVirDev = VclPtr<VirtualDevice>::Create( *this );
mnCurItemId = 0;
mbFormat = true;
mbVisibleItems = true;
@@ -151,6 +151,11 @@ StatusBar::StatusBar( vcl::Window* pParent, WinBits nStyle ) :
StatusBar::~StatusBar()
{
+ disposeOnce();
+}
+
+void StatusBar::dispose()
+{
// delete all items
for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
delete (*mpItemList)[ i ];
@@ -158,8 +163,9 @@ StatusBar::~StatusBar()
delete mpItemList;
// delete VirtualDevice
- delete mpImplData->mpVirDev;
+ mpImplData->mpVirDev.disposeAndClear();
delete mpImplData;
+ Window::dispose();
}
void StatusBar::AdjustItemWidthsForHiDPI(bool bAdjustHiDPI)
diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx
index f82e274d3c12..618170994105 100644
--- a/vcl/source/window/syschild.cxx
+++ b/vcl/source/window/syschild.cxx
@@ -133,12 +133,18 @@ SystemChildWindow::SystemChildWindow( vcl::Window* pParent, WinBits nStyle, Syst
SystemChildWindow::~SystemChildWindow()
{
+ disposeOnce();
+}
+
+void SystemChildWindow::dispose()
+{
Hide();
- if ( mpWindowImpl->mpSysObj )
+ if ( mpWindowImpl && mpWindowImpl->mpSysObj )
{
ImplGetSVData()->mpDefInst->DestroyObject( mpWindowImpl->mpSysObj );
mpWindowImpl->mpSysObj = NULL;
}
+ Window::dispose();
}
const SystemEnvData* SystemChildWindow::GetSystemData() const
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index c5d0522dc0e1..99ac9bcb4fa4 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -106,12 +106,21 @@ void SystemWindow::loadUI(vcl::Window* pParent, const OString& rID, const OUStri
SystemWindow::~SystemWindow()
{
+ disposeOnce();
+}
+
+void SystemWindow::dispose()
+{
maLayoutIdle.Stop();
delete mpImplData;
mpImplData = NULL;
+
// Hack to make sure code called from base ~Window does not interpret this
// as a SystemWindow (which it no longer is by then):
mpWindowImpl->mbSysWin = false;
+ disposeBuilder();
+ mpDialogParent.clear();
+ Window::dispose();
}
bool SystemWindow::Notify( NotifyEvent& rNEvt )
@@ -177,6 +186,8 @@ bool SystemWindow::PreNotify( NotifyEvent& rNEvt )
TaskPaneList* SystemWindow::GetTaskPaneList()
{
+ if( !mpImplData )
+ return NULL;
if( mpImplData->mpTaskPaneList )
return mpImplData->mpTaskPaneList ;
else
@@ -306,7 +317,7 @@ void SystemWindow::ShowTitleButton( sal_uInt16 nButton, bool bVisible )
{
mbDockBtn = bVisible;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetDockButton( bVisible );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetDockButton( bVisible );
}
}
else if ( nButton == TITLE_BUTTON_HIDE )
@@ -315,13 +326,13 @@ void SystemWindow::ShowTitleButton( sal_uInt16 nButton, bool bVisible )
{
mbHideBtn = bVisible;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetHideButton( bVisible );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetHideButton( bVisible );
}
}
else if ( nButton == TITLE_BUTTON_MENU )
{
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuButton( bVisible );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuButton( bVisible );
}
else
return;
@@ -341,7 +352,7 @@ void SystemWindow::SetPin( bool bPin )
{
mbPinned = bPin;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetPin( bPin );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetPin( bPin );
}
}
@@ -356,7 +367,7 @@ void SystemWindow::RollUp()
aSize.Width() = GetOutputSizePixel().Width();
mbRollUp = true;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetRollUp( true, aSize );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetRollUp( true, aSize );
else
SetOutputSizePixel( aSize );
mbRollFunc = false;
@@ -369,7 +380,7 @@ void SystemWindow::RollDown()
{
mbRollUp = false;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetRollUp( false, maOrgSize );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetRollUp( false, maOrgSize );
else
SetOutputSizePixel( maOrgSize );
}
@@ -380,7 +391,7 @@ void SystemWindow::SetMinOutputSizePixel( const Size& rSize )
maMinOutSize = rSize;
if ( mpWindowImpl->mpBorderWindow )
{
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMinOutputSize( rSize.Width(), rSize.Height() );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMinOutputSize( rSize.Width(), rSize.Height() );
if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMinClientSize( rSize.Width(), rSize.Height() );
}
@@ -399,7 +410,7 @@ void SystemWindow::SetMaxOutputSizePixel( const Size& rSize )
mpImplData->maMaxOutSize = aSize;
if ( mpWindowImpl->mpBorderWindow )
{
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMaxOutputSize( aSize.Width(), aSize.Height() );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMaxOutputSize( aSize.Width(), aSize.Height() );
if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMaxClientSize( aSize.Width(), aSize.Height() );
}
@@ -905,11 +916,11 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar, const css::uno::Reference<css::
if ( pMenuBar )
{
DBG_ASSERT( !pMenuBar->pWindow, "SystemWindow::SetMenuBar() - MenuBars can only set in one SystemWindow at time" );
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar, rFrame));
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar, rFrame));
CallEventListeners( VCLEVENT_WINDOW_MENUBARADDED, (void*) pMenuBar );
}
else
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( NULL );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarWindow( NULL );
ImplToBottomChild();
if ( pOldMenuBar )
{
@@ -952,9 +963,9 @@ void SystemWindow::SetMenuBarMode( sal_uInt16 nMode )
if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) )
{
if ( nMode == MENUBAR_MODE_HIDE )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarMode( true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarMode( true );
else
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarMode( false );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarMode( false );
}
}
}
diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx
index f15a2a03be49..e5c9061389e3 100644
--- a/vcl/source/window/tabdlg.cxx
+++ b/vcl/source/window/tabdlg.cxx
@@ -197,7 +197,7 @@ void TabDialog::ImplPosControls()
{
Size aDlgSize = GetOutputSizePixel();
if ( !mpFixedLine )
- mpFixedLine = new FixedLine( this );
+ mpFixedLine = VclPtr<FixedLine>::Create( this );
mpFixedLine->SetPosSizePixel( Point( 0, nOffY ),
Size( aDlgSize.Width(), 2 ) );
mpFixedLine->Show();
@@ -221,7 +221,14 @@ TabDialog::TabDialog( vcl::Window* pParent, const OUString& rID, const OUString&
TabDialog::~TabDialog()
{
- delete mpFixedLine;
+ disposeOnce();
+}
+
+void TabDialog::dispose()
+{
+ mpFixedLine.disposeAndClear();
+ mpViewWindow.clear();
+ Dialog::dispose();
}
void TabDialog::StateChanged( StateChangedType nType )
diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx
index d55496412e2b..964f96043d78 100644
--- a/vcl/source/window/tabpage.cxx
+++ b/vcl/source/window/tabpage.cxx
@@ -85,6 +85,17 @@ TabPage::TabPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXM
set_expand(true);
}
+TabPage::~TabPage()
+{
+ disposeOnce();
+}
+
+void TabPage::dispose()
+{
+ disposeBuilder();
+ vcl::Window::dispose();
+}
+
void TabPage::StateChanged( StateChangedType nType )
{
Window::StateChanged( nType );
diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx
index 2089172df14d..af4f617205ae 100644
--- a/vcl/source/window/taskpanelist.cxx
+++ b/vcl/source/window/taskpanelist.cxx
@@ -95,11 +95,8 @@ void TaskPaneList::AddWindow( vcl::Window *pWindow )
{
if( pWindow )
{
- ::std::vector< vcl::Window* >::iterator insertionPos = mTaskPanes.end();
- for ( ::std::vector< vcl::Window* >::iterator p = mTaskPanes.begin();
- p != mTaskPanes.end();
- ++p
- )
+ auto insertionPos = mTaskPanes.end();
+ for ( auto p = mTaskPanes.begin(); p != mTaskPanes.end(); ++p )
{
if ( *p == pWindow )
// avoid duplicates
@@ -131,8 +128,7 @@ void TaskPaneList::AddWindow( vcl::Window *pWindow )
void TaskPaneList::RemoveWindow( vcl::Window *pWindow )
{
- ::std::vector< vcl::Window* >::iterator p;
- p = ::std::find( mTaskPanes.begin(), mTaskPanes.end(), pWindow );
+ auto p = ::std::find( mTaskPanes.begin(), mTaskPanes.end(), VclPtr<vcl::Window>(pWindow) );
if( p != mTaskPanes.end() )
{
mTaskPanes.erase( p );
@@ -142,8 +138,7 @@ void TaskPaneList::RemoveWindow( vcl::Window *pWindow )
bool TaskPaneList::IsInList( vcl::Window *pWindow )
{
- ::std::vector< vcl::Window* >::iterator p;
- p = ::std::find( mTaskPanes.begin(), mTaskPanes.end(), pWindow );
+ auto p = ::std::find( mTaskPanes.begin(), mTaskPanes.end(), VclPtr<vcl::Window>(pWindow) );
if( p != mTaskPanes.end() )
return true;
else
@@ -172,7 +167,7 @@ bool TaskPaneList::HandleKeyEvent(const KeyEvent& rKeyEvent)
bSplitterOnly = aKeyCode.IsMod1() && aKeyCode.IsShift();
// is the focus in the list ?
- ::std::vector< vcl::Window* >::iterator p = mTaskPanes.begin();
+ auto p = mTaskPanes.begin();
while( p != mTaskPanes.end() )
{
vcl::Window *pWin = *p;
@@ -245,7 +240,7 @@ vcl::Window* TaskPaneList::FindNextSplitter( vcl::Window *pWindow, bool bForward
else
::std::stable_sort( mTaskPanes.begin(), mTaskPanes.end(), LTRSortBackward() );
- ::std::vector< vcl::Window* >::iterator p = mTaskPanes.begin();
+ auto p = mTaskPanes.begin();
while( p != mTaskPanes.end() )
{
if( !pWindow || *p == pWindow )
@@ -282,7 +277,7 @@ vcl::Window* TaskPaneList::FindNextFloat( vcl::Window *pWindow, bool bForward )
else
::std::stable_sort( mTaskPanes.begin(), mTaskPanes.end(), LTRSortBackward() );
- ::std::vector< vcl::Window* >::iterator p = mTaskPanes.begin();
+ auto p = mTaskPanes.begin();
while( p != mTaskPanes.end() )
{
if( !pWindow || *p == pWindow )
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 5b627939ef76..2369a7d25da5 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -84,13 +84,13 @@
static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow );
-typedef ::std::vector< ToolBox* > ImplTBList;
+typedef ::std::vector< VclPtr<ToolBox> > ImplTBList;
class ImplTBDragMgr
{
private:
ImplTBList* mpBoxList;
- ToolBox* mpDragBox;
+ VclPtr<ToolBox> mpDragBox;
Point maMouseOff;
Rectangle maRect;
Rectangle maStartRect;
@@ -1570,8 +1570,13 @@ ToolBox::ToolBox( vcl::Window* pParent, const ResId& rResId ) :
ToolBox::~ToolBox()
{
+ disposeOnce();
+}
+
+void ToolBox::dispose()
+{
// custom menu event still running?
- if( mpData->mnEventId )
+ if( mpData && mpData->mnEventId )
Application::RemoveUserEvent( mpData->mnEventId );
// #103005# make sure our activate/deactivate balance is right
@@ -1582,9 +1587,12 @@ ToolBox::~ToolBox()
// still connected
if ( mpFloatWin )
mpFloatWin->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
+ mpFloatWin = NULL;
// delete private data
- delete mpData;
+ if (mpData)
+ delete mpData;
+ mpData = NULL;
// remove the lists when there are no more toolbox references to
// the lists
@@ -1601,10 +1609,15 @@ ToolBox::~ToolBox()
pSVData->maCtrlData.mpTBDragMgr = NULL;
}
}
+ mpFloatWin.clear();
+ DockingWindow::dispose();
}
ImplToolItem* ToolBox::ImplGetItem( sal_uInt16 nItemId ) const
{
+ if (!mpData)
+ return NULL;
+
std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
while ( it != mpData->m_aItems.end() )
{
@@ -2630,7 +2643,7 @@ IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl)
// do not reset data if the dropdown handler opened a floating window
// see ImplFloatControl()
- if( mpFloatWin == NULL )
+ if( !mpFloatWin )
{
// no floater was opened
Deactivate();
@@ -2651,7 +2664,7 @@ IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl)
IMPL_LINK_NOARG(ToolBox, ImplUpdateHdl)
{
- if( mbFormat )
+ if( mbFormat && mpData )
ImplFormat();
return 0;
@@ -2952,7 +2965,7 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight, bool bPaint,
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
// no gradient background for items that have a popup open
- bool bHasOpenPopup = (mpFloatWin != NULL) && (mnDownItemId==pItem->mnId);
+ bool bHasOpenPopup = mpFloatWin && (mnDownItemId==pItem->mnId);
bool bHighContrastWhite = false;
// check the face color as highcontrast indicator
@@ -3864,7 +3877,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
// do not reset data if the dropdown handler opened a floating window
// see ImplFloatControl()
- if( mpFloatWin == NULL )
+ if( !mpFloatWin )
{
// no floater was opened
Deactivate();
@@ -4823,7 +4836,7 @@ Size ToolBox::CalcMinimumWindowSizePixel() const
else
{
// create dummy toolbox for measurements
- ToolBox *pToolBox = new ToolBox( GetParent(), GetStyle() );
+ VclPtrInstance< ToolBox > pToolBox( GetParent(), GetStyle() );
// copy until first useful item
std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
@@ -4851,7 +4864,8 @@ Size ToolBox::CalcMinimumWindowSizePixel() const
ImplGetDockingManager()->RemoveWindow( pToolBox );
pToolBox->Clear();
- delete pToolBox;
+
+ pToolBox.disposeAndClear();
return aSize;
}
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 80b2bf920075..481122834fc5 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -165,6 +165,7 @@ ImplToolItem::ImplToolItem( const ImplToolItem& rItem ) :
ImplToolItem::~ImplToolItem()
{
+ // don't dispose mpWindow - we get copied around.
}
ImplToolItem& ImplToolItem::operator=( const ImplToolItem& rItem )
@@ -866,7 +867,7 @@ void ToolBox::SetPageScroll( bool b )
sal_uInt16 ToolBox::GetItemCount() const
{
- return (sal_uInt16)mpData->m_aItems.size();
+ return mpData ? (sal_uInt16)mpData->m_aItems.size() : 0;
}
ToolBoxItemType ToolBox::GetItemType( sal_uInt16 nPos ) const
@@ -876,11 +877,13 @@ ToolBoxItemType ToolBox::GetItemType( sal_uInt16 nPos ) const
sal_uInt16 ToolBox::GetItemPos( sal_uInt16 nItemId ) const
{
- int nCount = mpData->m_aItems.size();
- for( int nPos = 0; nPos < nCount; nPos++ )
- if( mpData->m_aItems[nPos].mnId == nItemId )
- return (sal_uInt16)nPos;
-
+ if (mpData)
+ {
+ int nCount = mpData->m_aItems.size();
+ for( int nPos = 0; nPos < nCount; nPos++ )
+ if( mpData->m_aItems[nPos].mnId == nItemId )
+ return (sal_uInt16)nPos;
+ }
return TOOLBOX_ITEM_NOTFOUND;
}
@@ -934,6 +937,9 @@ sal_uInt16 ToolBox::GetItemId( const Point& rPos ) const
sal_uInt16 ToolBox::GetItemId(const OUString &rCommand) const
{
+ if (!mpData)
+ return TOOLBOX_ITEM_NOTFOUND;
+
for (std::vector<ImplToolItem>::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
{
if (it->maCommandStr == rCommand)
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 4a898eeac6b9..f991b98b6fe5 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -33,6 +33,7 @@
#include <vcl/syschild.hxx>
#include <vcl/dockwin.hxx>
#include <vcl/wall.hxx>
+#include <vcl/fixed.hxx>
#include <vcl/gradient.hxx>
#include <vcl/button.hxx>
#include <vcl/taskpanelist.hxx>
@@ -131,13 +132,18 @@ namespace
}
#endif
-Window::~Window()
+bool Window::IsDisposed() const
{
- vcl::LazyDeletor<vcl::Window>::Undelete( this );
-
- DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" );
+ return !mpWindowImpl;
+}
- dispose();
+void Window::dispose()
+{
+ assert( mpWindowImpl );
+ assert( !mpWindowImpl->mbInDispose ); // should only be called from disposeOnce()
+ assert( !mpWindowImpl->mpParent ||
+ !mpWindowImpl->mpParent->IsDisposed() ||
+ "vcl::Window child should have its parent disposed first" );
// remove Key and Mouse events issued by Application::PostKey/MouseEvent
Application::RemoveMouseAndKeyEvents( this );
@@ -152,7 +158,7 @@ Window::~Window()
xCanvasComponent->dispose();
}
- mpWindowImpl->mbInDtor = true;
+ mpWindowImpl->mbInDispose = true;
CallEventListeners( VCLEVENT_OBJECT_DYING );
@@ -167,9 +173,8 @@ Window::~Window()
// remove ownerdraw decorated windows from list in the top-most frame window
if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
{
- ::std::vector< vcl::Window* >& rList = ImplGetOwnerDrawList();
- ::std::vector< vcl::Window* >::iterator p;
- p = ::std::find( rList.begin(), rList.end(), this );
+ ::std::vector< VclPtr<vcl::Window> >& rList = ImplGetOwnerDrawList();
+ auto p = ::std::find( rList.begin(), rList.end(), VclPtr<vcl::Window>(this) );
if( p != rList.end() )
rList.erase( p );
}
@@ -232,9 +237,9 @@ Window::~Window()
if ( pSVData->maHelpData.mpHelpWin && (pSVData->maHelpData.mpHelpWin->GetParent() == this) )
ImplDestroyHelpWindow( true );
- DBG_ASSERT( pSVData->maWinData.mpTrackWin != this,
+ DBG_ASSERT( pSVData->maWinData.mpTrackWin.get() != this,
"Window::~Window(): Window is in TrackingMode" );
- DBG_ASSERT( pSVData->maWinData.mpCaptureWin != this,
+ DBG_ASSERT( pSVData->maWinData.mpCaptureWin.get() != this,
"Window::~Window(): Window has the mouse captured" );
// due to old compatibility
@@ -251,6 +256,22 @@ Window::~Window()
OStringBuffer aErrorStr;
bool bError = false;
vcl::Window* pTempWin;
+
+ if ( mpWindowImpl->mpFirstChild )
+ {
+ OStringBuffer aTempStr("Window (");
+ aTempStr.append(lcl_createWindowInfo(*this));
+ aTempStr.append(") with live children destroyed: ");
+ pTempWin = mpWindowImpl->mpFirstChild;
+ while ( pTempWin )
+ {
+ aTempStr.append(lcl_createWindowInfo(*pTempWin));
+ pTempWin = pTempWin->mpWindowImpl->mpNext;
+ }
+ OSL_FAIL( aTempStr.getStr() );
+ Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
+ }
+
if (mpWindowImpl->mpFrameData != 0)
{
pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
@@ -267,8 +288,7 @@ Window::~Window()
{
OStringBuffer aTempStr;
aTempStr.append("Window (");
- aTempStr.append(OUStringToOString(GetText(),
- RTL_TEXTENCODING_UTF8));
+ aTempStr.append(lcl_createWindowInfo(*this));
aTempStr.append(") with live SystemWindows destroyed: ");
aTempStr.append(aErrorStr.toString());
OSL_FAIL(aTempStr.getStr());
@@ -292,32 +312,17 @@ Window::~Window()
if ( bError )
{
OStringBuffer aTempStr( "Window (" );
- aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
+ aTempStr.append(lcl_createWindowInfo(*this));
aTempStr.append(") with live SystemWindows destroyed: ");
aTempStr.append(aErrorStr.toString());
OSL_FAIL( aTempStr.getStr() );
Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
}
- if ( mpWindowImpl->mpFirstChild )
- {
- OStringBuffer aTempStr("Window (");
- aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
- aTempStr.append(") with live children destroyed: ");
- pTempWin = mpWindowImpl->mpFirstChild;
- while ( pTempWin )
- {
- aTempStr.append(lcl_createWindowInfo(*pTempWin));
- pTempWin = pTempWin->mpWindowImpl->mpNext;
- }
- OSL_FAIL( aTempStr.getStr() );
- Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
- }
-
if ( mpWindowImpl->mpFirstOverlap )
{
OStringBuffer aTempStr("Window (");
- aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
+ aTempStr.append(lcl_createWindowInfo(*this));
aTempStr.append(") with live SystemWindows destroyed: ");
pTempWin = mpWindowImpl->mpFirstOverlap;
while ( pTempWin )
@@ -343,7 +348,7 @@ Window::~Window()
if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
{
OStringBuffer aTempStr("Window (");
- aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
+ aTempStr.append(lcl_createWindowInfo(*this));
aTempStr.append(") still in TaskPanelList!");
OSL_FAIL( aTempStr.getStr() );
Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
@@ -381,9 +386,8 @@ Window::~Window()
remove_from_all_size_groups();
// clear mnemonic labels
- std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
- for (std::vector<FixedText*>::iterator aI = aMnemonicLabels.begin();
- aI != aMnemonicLabels.end(); ++aI)
+ std::vector<VclPtr<FixedText> > aMnemonicLabels(list_mnemonic_labels());
+ for (auto aI = aMnemonicLabels.begin(); aI != aMnemonicLabels.end(); ++aI)
{
remove_mnemonic_label(*aI);
}
@@ -499,7 +503,7 @@ Window::~Window()
while ( pDelData )
{
pDelData->mbDel = true;
- pDelData->mpWindow = NULL; // #112873# pDel is not associated with a Window anymore
+ pDelData->mpWindow.clear(); // #112873# pDel is not associated with a Window anymore
pDelData = pDelData->mpNext;
}
@@ -514,8 +518,8 @@ Window::~Window()
{
ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
- ::std::list< vcl::Window* >::iterator myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
- pParentWinData->maTopWindowChildren.end(), this );
+ auto myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
+ pParentWinData->maTopWindowChildren.end(), VclPtr<vcl::Window>(this) );
DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" );
if ( myPos != pParentWinData->maTopWindowChildren.end() )
pParentWinData->maTopWindowChildren.erase( myPos );
@@ -546,17 +550,18 @@ Window::~Window()
delete mpWindowImpl->mpOverlapData;
// remove BorderWindow or Frame window data
- if ( mpWindowImpl->mpBorderWindow )
- delete mpWindowImpl->mpBorderWindow;
- else if ( mpWindowImpl->mbFrame )
+ mpWindowImpl->mpBorderWindow.disposeAndClear();
+ if ( mpWindowImpl->mbFrame )
{
if ( pSVData->maWinData.mpFirstFrame == this )
pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
else
{
vcl::Window* pSysWin = pSVData->maWinData.mpFirstFrame;
- while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this )
+ while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame.get() != this )
pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
+
+ assert (mpWindowImpl->mpFrameData->mpNextFrame.get() != pSysWin);
pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
}
mpWindowImpl->mpFrame->SetCallback( NULL, NULL );
@@ -566,6 +571,31 @@ Window::~Window()
// should be the last statements
delete mpWindowImpl; mpWindowImpl = NULL;
+
+ OutputDevice::dispose();
+}
+
+Window::~Window()
+{
+ // FIXME: we should kill all LazyDeletor usage.
+ vcl::LazyDeletor<vcl::Window>::Undelete( this );
+ disposeOnce();
+}
+
+// We will eventually being removing the inheritance of OutputDevice
+// from Window. It will be replaced with a transient relationship such
+// that the OutputDevice is only live for the scope of the Paint method.
+// In the meantime this can help move us towards a Window use an
+// OutputDevice, not being one.
+
+::OutputDevice const* Window::GetOutDev() const
+{
+ return this;
+}
+
+::OutputDevice* Window::GetOutDev()
+{
+ return this;
}
} /* namespace vcl */
@@ -584,8 +614,8 @@ WindowImpl::WindowImpl( WindowType nType )
mpOverlapWindow = NULL; // first overlap parent
mpBorderWindow = NULL; // Border-Window
mpClientWindow = NULL; // Client-Window of a FrameWindow
- mpParent = NULL; // parent (inkl. BorderWindow)
- mpRealParent = NULL; // real parent (exkl. BorderWindow)
+ mpParent = NULL; // parent (incl. BorderWindow)
+ mpRealParent = NULL; // real parent (excl. BorderWindow)
mpFirstChild = NULL; // first child window
mpLastChild = NULL; // last child window
mpFirstOverlap = NULL; // first overlap window (only set in overlap windows)
@@ -704,7 +734,7 @@ WindowImpl::WindowImpl( WindowType nType )
mbCompoundControlHasFocus = false; // true: Composite Control has focus somewhere
mbPaintDisabled = false; // true: Paint should not be executed
mbAllResize = false; // true: Also sent ResizeEvents with 0,0
- mbInDtor = false; // true: We're still in Window-Dtor
+ mbInDispose = false; // true: We're still in Window::dispose()
mbExtTextInput = false; // true: ExtTextInput-Mode is active
mbInFocusHdl = false; // true: Within GetFocus-Handler
mbCreatedWithToolkit = false;
@@ -876,7 +906,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME;
nStyle |= WB_BORDER;
}
- ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
+ VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
((vcl::Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this;
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
mpWindowImpl->mpBorderWindow = pBorderWin;
@@ -989,6 +1019,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
mpWindowImpl->mpOverlapWindow = this;
// set frame data
+ assert (pSVData->maWinData.mpFirstFrame.get() != this);
mpWindowImpl->mpFrameData->mpNextFrame = pSVData->maWinData.mpFirstFrame;
pSVData->maWinData.mpFirstFrame = this;
mpWindowImpl->mpFrameData->mpFirstOverlap = NULL;
@@ -1181,13 +1212,6 @@ void Window::ImplInitAppFontData( vcl::Window* pWindow )
void Window::ImplInitWindowData( WindowType nType )
{
- // We will eventually being removing the inheritance of OutputDevice from Window.
- // It will be replaced with a composition relationship. A Window will use an OutputDevice,
- // it will not *be* an OutputDevice
- mpOutputDevice = (OutputDevice*)this;
-
- mnRefCnt = 0;
-
mpWindowImpl = new WindowImpl( nType );
meOutDevType = OUTDEV_WINDOW;
@@ -1352,6 +1376,12 @@ void Window::ImplSetReallyVisible()
void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatibility ok
{
+ if ( IsDisposed() )
+ {
+ pDel->mbDel = true;
+ return;
+ }
+
DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" );
if( !pDel->mpWindow )
{
@@ -1364,6 +1394,10 @@ void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompat
void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatibility ok
{
pDel->mpWindow = NULL; // #112873# pDel is not associated with a Window anymore
+
+ if ( IsDisposed() )
+ return;
+
if ( mpWindowImpl->mpFirstDel == pDel )
mpWindowImpl->mpFirstDel = pDel->mpNext;
else
@@ -2074,7 +2108,7 @@ void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
// this is a little awkward: some controls (e.g. svtools ProgressBar)
// cannot avoid getting constructed with WB_BORDER but want to disable
// borders in case of NWF drawing. So they need a method to remove their border window
- vcl::Window* pBorderWin = mpWindowImpl->mpBorderWindow;
+ VclPtr<vcl::Window> pBorderWin = mpWindowImpl->mpBorderWindow;
// remove us as border window's client
pBorderWin->mpWindowImpl->mpClientWindow = NULL;
mpWindowImpl->mpBorderWindow = NULL;
@@ -2086,7 +2120,7 @@ void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
Size aBorderSize( pBorderWin->GetSizePixel() );
setPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() );
// release border window
- delete pBorderWin;
+ pBorderWin.disposeAndClear();
// set new style bits
SetStyle( GetStyle() & (~WB_BORDER) );
@@ -2094,7 +2128,7 @@ void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
else
{
if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetBorderStyle( nBorderStyle );
else
mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
}
@@ -2107,7 +2141,7 @@ WindowBorderStyle Window::GetBorderStyle() const
if ( mpWindowImpl->mpBorderWindow )
{
if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
- return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorderStyle();
+ return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorderStyle();
else
return mpWindowImpl->mpBorderWindow->GetBorderStyle();
}
@@ -2121,7 +2155,7 @@ long Window::CalcTitleWidth() const
if ( mpWindowImpl->mpBorderWindow )
{
if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
- return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->CalcTitleWidth();
+ return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->CalcTitleWidth();
else
return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
}
@@ -2241,8 +2275,7 @@ vcl::Font Window::GetPointFont() const
void Window::Show( bool bVisible, sal_uInt16 nFlags )
{
-
- if ( mpWindowImpl->mbVisible == bVisible )
+ if ( IsDisposed() || mpWindowImpl->mbVisible == bVisible )
return;
ImplDelData aDogTag( this );
@@ -2482,7 +2515,7 @@ Size Window::GetSizePixel() const
// #i43257# trigger pending resize handler to assure correct window sizes
if( mpWindowImpl->mpFrameData->maResizeIdle.IsActive() )
{
- ImplDelData aDogtag( this );
+ ImplDelData aDogtag( const_cast<Window*>(this) );
mpWindowImpl->mpFrameData->maResizeIdle.Stop();
mpWindowImpl->mpFrameData->maResizeIdle.GetIdleHdl().Call( NULL );
if( aDogtag.IsDead() )
@@ -2504,6 +2537,8 @@ void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
void Window::Enable( bool bEnable, bool bChild )
{
+ if ( IsDisposed() )
+ return;
if ( !bEnable )
{
@@ -2525,15 +2560,15 @@ void Window::Enable( bool bEnable, bool bChild )
{
mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->Enable( bEnable, true );
}
// #i56102# restore app focus win in case the
// window was disabled when the frame focus changed
ImplSVData* pSVData = ImplGetSVData();
if( bEnable &&
- pSVData->maWinData.mpFocusWin == NULL &&
+ pSVData->maWinData.mpFocusWin == nullptr &&
mpWindowImpl->mpFrameData->mbHasFocus &&
mpWindowImpl->mpFrameData->mpFocusWin == this )
pSVData->maWinData.mpFocusWin = this;
@@ -2587,8 +2622,8 @@ void Window::EnableInput( bool bEnable, bool bChild )
{
mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->EnableInput( bEnable, true );
}
if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
@@ -2616,7 +2651,7 @@ void Window::EnableInput( bool bEnable, bool bChild )
// window was disabled when the frame focus changed
ImplSVData* pSVData = ImplGetSVData();
if( bEnable &&
- pSVData->maWinData.mpFocusWin == NULL &&
+ pSVData->maWinData.mpFocusWin == nullptr &&
mpWindowImpl->mpFrameData->mbHasFocus &&
mpWindowImpl->mpFrameData->mpFocusWin == this )
pSVData->maWinData.mpFocusWin = this;
@@ -2688,8 +2723,8 @@ void Window::EnableInput( bool bEnable, bool bChild, bool bSysWin,
// the same for ownerdraw floating windows
if( mpWindowImpl->mbFrame )
{
- ::std::vector< vcl::Window* >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
- ::std::vector< vcl::Window* >::iterator p = rList.begin();
+ ::std::vector< VclPtr<vcl::Window> >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
+ auto p = rList.begin();
while( p != rList.end() )
{
// Is Window in the path from this window
@@ -3055,7 +3090,7 @@ Rectangle Window::ImplGetWindowExtentsRelative( vcl::Window *pRelativeWindow, bo
if( pRelativeWindow )
{
// #106399# express coordinates relative to borderwindow
- vcl::Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow : pRelativeWindow;
+ vcl::Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow.get() : pRelativeWindow;
aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
}
return Rectangle( aPos, aSize );
@@ -3102,7 +3137,6 @@ void Window::SetUpdateMode( bool bUpdate )
void Window::GrabFocus()
{
-
ImplGrabFocus( 0 );
}
@@ -3608,7 +3642,7 @@ void Window::ImplIncModalCount()
{
pParent = pParent->GetParent();
}
- pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
+ pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow.get() : NULL;
}
}
void Window::ImplDecModalCount()
@@ -3622,7 +3656,7 @@ void Window::ImplDecModalCount()
{
pParent = pParent->GetParent();
}
- pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
+ pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow.get() : NULL;
}
}
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 68129c08561b..c43563e7db74 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -375,7 +375,7 @@ void Window::StartTracking( sal_uInt16 nFlags )
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maWinData.mpTrackWin != this )
+ if ( pSVData->maWinData.mpTrackWin.get() != this )
{
if ( pSVData->maWinData.mpTrackWin )
pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
@@ -402,7 +402,7 @@ void Window::EndTracking( sal_uInt16 nFlags )
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maWinData.mpTrackWin == this )
+ if ( pSVData->maWinData.mpTrackWin.get() == this )
{
// due to DbgChkThis in brackets, as the window could be destroyed
// in the handler
@@ -449,7 +449,7 @@ void Window::StartAutoScroll( sal_uInt16 nFlags )
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maWinData.mpAutoScrollWin != this )
+ if ( pSVData->maWinData.mpAutoScrollWin.get() != this )
{
if ( pSVData->maWinData.mpAutoScrollWin )
pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
@@ -457,14 +457,14 @@ void Window::StartAutoScroll( sal_uInt16 nFlags )
pSVData->maWinData.mpAutoScrollWin = this;
pSVData->maWinData.mnAutoScrollFlags = nFlags;
- pSVData->maAppData.mpWheelWindow = new ImplWheelWindow( this );
+ pSVData->maAppData.mpWheelWindow = VclPtr<ImplWheelWindow>::Create( this );
}
void Window::EndAutoScroll()
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maWinData.mpAutoScrollWin == this )
+ if ( pSVData->maWinData.mpAutoScrollWin.get() == this )
{
pSVData->maWinData.mpAutoScrollWin = NULL;
pSVData->maWinData.mnAutoScrollFlags = 0;
@@ -938,7 +938,7 @@ void Window::EnableDocking( bool bEnable )
}
// retrieves the list of owner draw decorated windows for this window hiearchy
-::std::vector<vcl::Window *>& Window::ImplGetOwnerDrawList()
+::std::vector<VclPtr<vcl::Window> >& Window::ImplGetOwnerDrawList()
{
return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList;
}
@@ -975,27 +975,27 @@ vcl::Window* Window::ImplGetWindow()
ImplFrameData* Window::ImplGetFrameData()
{
- return mpWindowImpl->mpFrameData;
+ return mpWindowImpl ? mpWindowImpl->mpFrameData : NULL;
}
SalFrame* Window::ImplGetFrame() const
{
- return mpWindowImpl->mpFrame;
+ return mpWindowImpl ? mpWindowImpl->mpFrame : NULL;
}
vcl::Window* Window::ImplGetParent() const
{
- return mpWindowImpl->mpParent;
+ return mpWindowImpl ? mpWindowImpl->mpParent.get() : NULL;
}
vcl::Window* Window::ImplGetClientWindow() const
{
- return mpWindowImpl->mpClientWindow;
+ return mpWindowImpl ? mpWindowImpl->mpClientWindow.get() : NULL;
}
vcl::Window* Window::ImplGetBorderWindow() const
{
- return mpWindowImpl->mpBorderWindow;
+ return mpWindowImpl ? mpWindowImpl->mpBorderWindow.get() : NULL;
}
vcl::Window* Window::ImplGetFirstOverlapWindow()
@@ -1016,37 +1016,38 @@ const vcl::Window* Window::ImplGetFirstOverlapWindow() const
vcl::Window* Window::ImplGetFrameWindow() const
{
- return mpWindowImpl->mpFrameWindow;
+ return mpWindowImpl ? mpWindowImpl->mpFrameWindow.get() : NULL;
}
bool Window::IsDockingWindow() const
{
- return mpWindowImpl->mbDockWin;
+ return mpWindowImpl ? mpWindowImpl->mbDockWin : false;
}
bool Window::ImplIsFloatingWindow() const
{
- return mpWindowImpl->mbFloatWin;
+ return mpWindowImpl ? mpWindowImpl->mbFloatWin : false;
}
bool Window::ImplIsSplitter() const
{
- return mpWindowImpl->mbSplitter;
+ return mpWindowImpl ? mpWindowImpl->mbSplitter : false;
}
bool Window::ImplIsPushButton() const
{
- return mpWindowImpl->mbPushButton;
+ return mpWindowImpl ? mpWindowImpl->mbPushButton : false;
}
bool Window::ImplIsOverlapWindow() const
{
- return mpWindowImpl->mbOverlapWin;
+ return mpWindowImpl ? mpWindowImpl->mbOverlapWin : false;
}
void Window::ImplSetMouseTransparent( bool bTransparent )
{
- mpWindowImpl->mbMouseTransparent = bTransparent;
+ if (mpWindowImpl)
+ mpWindowImpl->mbMouseTransparent = bTransparent;
}
Point Window::ImplOutputToFrame( const Point& rPos )
@@ -1061,7 +1062,8 @@ Point Window::ImplFrameToOutput( const Point& rPos )
void Window::SetCompoundControl( bool bCompound )
{
- mpWindowImpl->mbCompoundControl = bCompound;
+ if (mpWindowImpl)
+ mpWindowImpl->mbCompoundControl = bCompound;
}
void Window::IncrementLockCount()
@@ -1076,27 +1078,31 @@ void Window::DecrementLockCount()
WinBits Window::GetStyle() const
{
- return mpWindowImpl->mnStyle;
+ return mpWindowImpl ? mpWindowImpl->mnStyle : 0;
}
WinBits Window::GetPrevStyle() const
{
- return mpWindowImpl->mnPrevStyle;
+ return mpWindowImpl ? mpWindowImpl->mnPrevStyle : 0;
}
WinBits Window::GetExtendedStyle() const
{
- return mpWindowImpl->mnExtendedStyle;
+ return mpWindowImpl ? mpWindowImpl->mnExtendedStyle : 0;
}
void Window::SetType( WindowType nType )
{
- mpWindowImpl->mnType = nType;
+ if (mpWindowImpl)
+ mpWindowImpl->mnType = nType;
}
WindowType Window::GetType() const
{
- return mpWindowImpl->mnType;
+ if (mpWindowImpl)
+ return mpWindowImpl->mnType;
+ else
+ return WINDOW_PARENT;
}
Dialog* Window::GetParentDialog() const
@@ -1116,22 +1122,22 @@ Dialog* Window::GetParentDialog() const
bool Window::IsSystemWindow() const
{
- return mpWindowImpl->mbSysWin;
+ return mpWindowImpl ? mpWindowImpl->mbSysWin : false;
}
bool Window::IsDialog() const
{
- return mpWindowImpl->mbDialog;
+ return mpWindowImpl ? mpWindowImpl->mbDialog : false;
}
bool Window::IsMenuFloatingWindow() const
{
- return mpWindowImpl->mbMenuFloatingWindow;
+ return mpWindowImpl ? mpWindowImpl->mbMenuFloatingWindow : false;
}
bool Window::IsToolbarFloatingWindow() const
{
- return mpWindowImpl->mbToolbarFloatingWindow;
+ return mpWindowImpl ? mpWindowImpl->mbToolbarFloatingWindow : false;
}
void Window::EnableAllResize( bool bEnable )
@@ -1146,17 +1152,17 @@ void Window::EnableChildTransparentMode( bool bEnable )
bool Window::IsChildTransparentModeEnabled() const
{
- return mpWindowImpl->mbChildTransparent;
+ return mpWindowImpl ? mpWindowImpl->mbChildTransparent : false;
}
bool Window::IsMouseTransparent() const
{
- return mpWindowImpl->mbMouseTransparent;
+ return mpWindowImpl ? mpWindowImpl->mbMouseTransparent : false;
}
bool Window::IsPaintTransparent() const
{
- return mpWindowImpl->mbPaintTransparent;
+ return mpWindowImpl ? mpWindowImpl->mbPaintTransparent : false;
}
void Window::SetDialogControlStart( bool bStart )
@@ -1166,7 +1172,7 @@ void Window::SetDialogControlStart( bool bStart )
bool Window::IsDialogControlStart() const
{
- return mpWindowImpl->mbDlgCtrlStart;
+ return mpWindowImpl ? mpWindowImpl->mbDlgCtrlStart : false;
}
void Window::SetDialogControlFlags( sal_uInt16 nFlags )
@@ -1211,27 +1217,27 @@ bool Window::IsControlBackground() const
bool Window::IsInPaint() const
{
- return mpWindowImpl->mbInPaint;
+ return mpWindowImpl ? mpWindowImpl->mbInPaint : false;
}
vcl::Window* Window::GetParent() const
{
- return mpWindowImpl->mpRealParent;
+ return mpWindowImpl ? mpWindowImpl->mpRealParent.get() : NULL;
}
bool Window::IsVisible() const
{
- return mpWindowImpl->mbVisible;
+ return mpWindowImpl ? mpWindowImpl->mbVisible : false;
}
bool Window::IsReallyVisible() const
{
- return mpWindowImpl->mbReallyVisible;
+ return mpWindowImpl ? mpWindowImpl->mbReallyVisible : false;
}
bool Window::IsReallyShown() const
{
- return mpWindowImpl->mbReallyShown;
+ return mpWindowImpl ? mpWindowImpl->mbReallyShown : false;
}
bool Window::IsInInitShow() const
@@ -1241,12 +1247,12 @@ bool Window::IsInInitShow() const
bool Window::IsEnabled() const
{
- return !mpWindowImpl->mbDisabled;
+ return mpWindowImpl ? !mpWindowImpl->mbDisabled : false;
}
bool Window::IsInputEnabled() const
{
- return !mpWindowImpl->mbInputDisabled;
+ return mpWindowImpl ? !mpWindowImpl->mbInputDisabled : false;
}
bool Window::IsAlwaysEnableInput() const
@@ -1317,6 +1323,8 @@ bool Window::IsWait() const
vcl::Cursor* Window::GetCursor() const
{
+ if (!mpWindowImpl)
+ return NULL;
return mpWindowImpl->mpCursor;
}
@@ -1338,7 +1346,8 @@ void Window::SetHelpText( const OUString& rHelpText )
void Window::SetQuickHelpText( const OUString& rHelpText )
{
- mpWindowImpl->maQuickHelpText = rHelpText;
+ if (mpWindowImpl)
+ mpWindowImpl->maQuickHelpText = rHelpText;
}
const OUString& Window::GetQuickHelpText() const
@@ -1364,8 +1373,8 @@ bool Window::IsCreatedWithToolkit() const
void Window::SetCreatedWithToolkit( bool b )
{
mpWindowImpl->mbCreatedWithToolkit = b;
-
}
+
const Pointer& Window::GetPointer() const
{
return mpWindowImpl->maPointer;
@@ -1373,7 +1382,7 @@ const Pointer& Window::GetPointer() const
VCLXWindow* Window::GetWindowPeer() const
{
- return mpWindowImpl->mpVCLXWindow;
+ return mpWindowImpl ? mpWindowImpl->mpVCLXWindow : NULL;
}
void Window::SetPosPixel( const Point& rNewPos )
@@ -1436,6 +1445,9 @@ void Window::InvalidateSizeCache()
void Window::queue_resize(StateChangedType eReason)
{
+ if (IsDisposed())
+ return;
+
bool bSomeoneCares = queue_ungrouped_resize(this);
if (eReason != StateChangedType::VISIBLE)
@@ -1446,9 +1458,8 @@ void Window::queue_resize(StateChangedType eReason)
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VCL_SIZE_GROUP_NONE)
{
- std::set<vcl::Window*> &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
- for (std::set<vcl::Window*>::iterator aI = rWindows.begin(),
- aEnd = rWindows.end(); aI != aEnd; ++aI)
+ std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
+ for (auto aI = rWindows.begin(), aEnd = rWindows.end(); aI != aEnd; ++aI)
{
vcl::Window *pOther = *aI;
if (pOther == this)
@@ -1743,9 +1754,8 @@ Size Window::get_preferred_size() const
if (eMode != VCL_SIZE_GROUP_NONE)
{
const bool bIgnoreInHidden = pWindowImpl->m_xSizeGroup->get_ignore_hidden();
- const std::set<vcl::Window*> &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
- for (std::set<vcl::Window*>::const_iterator aI = rWindows.begin(),
- aEnd = rWindows.end(); aI != aEnd; ++aI)
+ const std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
+ for (auto aI = rWindows.begin(), aEnd = rWindows.end(); aI != aEnd; ++aI)
{
const vcl::Window *pOther = *aI;
if (pOther == this)
@@ -2029,8 +2039,8 @@ void Window::remove_from_all_size_groups()
void Window::add_mnemonic_label(FixedText *pLabel)
{
- std::vector<FixedText*>& v = mpWindowImpl->m_aMnemonicLabels;
- if (std::find(v.begin(), v.end(), pLabel) != v.end())
+ std::vector<VclPtr<FixedText> >& v = mpWindowImpl->m_aMnemonicLabels;
+ if (std::find(v.begin(), v.end(), VclPtr<FixedText>(pLabel)) != v.end())
return;
v.push_back(pLabel);
pLabel->set_mnemonic_widget(this);
@@ -2038,15 +2048,15 @@ void Window::add_mnemonic_label(FixedText *pLabel)
void Window::remove_mnemonic_label(FixedText *pLabel)
{
- std::vector<FixedText*>& v = mpWindowImpl->m_aMnemonicLabels;
- std::vector<FixedText*>::iterator aFind = std::find(v.begin(), v.end(), pLabel);
+ std::vector<VclPtr<FixedText> >& v = mpWindowImpl->m_aMnemonicLabels;
+ auto aFind = std::find(v.begin(), v.end(), VclPtr<FixedText>(pLabel));
if (aFind == v.end())
return;
v.erase(aFind);
pLabel->set_mnemonic_widget(NULL);
}
-std::vector<FixedText*> Window::list_mnemonic_labels() const
+std::vector<VclPtr<FixedText> > Window::list_mnemonic_labels() const
{
return mpWindowImpl->m_aMnemonicLabels;
}
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 139d77149e1e..ce4edf81670b 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -243,7 +243,7 @@ static bool ImplCallCommand( vcl::Window* pChild, sal_uInt16 nEvt, void* pData =
struct ContextMenuEvent
{
- vcl::Window* pWindow;
+ VclPtr<vcl::Window> pWindow;
ImplDelData aDelData;
Point aChildPos;
};
@@ -377,13 +377,13 @@ bool ImplHandleMouseEvent( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, bool
// no mouse messages to disabled windows
// #106845# if the window was disabed during capturing we have to pass the mouse events to release capturing
- if ( pSVData->maWinData.mpCaptureWin != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalNonRefMode() ) )
+ if ( pSVData->maWinData.mpCaptureWin.get() != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalNonRefMode() ) )
{
ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave );
if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
{
ImplHandleMouseHelpRequest( pChild, aMousePos );
- if( pWinFrameData->mpMouseMoveWin != pChild )
+ if( pWinFrameData->mpMouseMoveWin.get() != pChild )
nMode |= MouseEventModifiers::ENTERWINDOW;
}
@@ -1371,11 +1371,10 @@ class HandleGestureEventBase
{
protected:
ImplSVData* m_pSVData;
- vcl::Window *m_pWindow;
+ VclPtr<vcl::Window> m_pWindow;
Point m_aMousePos;
public:
-
HandleGestureEventBase(vcl::Window *pWindow, const Point &rMousePos)
: m_pSVData(ImplGetSVData())
, m_pWindow(pWindow)
@@ -1692,7 +1691,7 @@ void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight )
{
// #i42750# presentation wants to be informed about resize
// as early as possible
- WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pWindow->ImplGetWindowImpl()->mpClientWindow);
+ WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pWindow->ImplGetWindowImpl()->mpClientWindow.get());
if( ! pWorkWindow || pWorkWindow->IsPresentationMode() )
bStartTimer = false;
}
@@ -1938,7 +1937,7 @@ static void ImplHandleLoseFocus( vcl::Window* pWindow )
struct DelayedCloseEvent
{
- vcl::Window* pWindow;
+ VclPtr<vcl::Window> pWindow;
ImplDelData aDelData;
};
@@ -1951,9 +1950,9 @@ static sal_IntPtr DelayedCloseEventLink( void* pCEvent, void* )
pEv->pWindow->ImplRemoveDel( &pEv->aDelData );
// dispatch to correct window type
if( pEv->pWindow->IsSystemWindow() )
- static_cast<SystemWindow*>(pEv->pWindow)->Close();
+ static_cast<SystemWindow*>(pEv->pWindow.get())->Close();
else if( pEv->pWindow->IsDockingWindow() )
- static_cast<DockingWindow*>(pEv->pWindow)->Close();
+ static_cast<DockingWindow*>(pEv->pWindow.get())->Close();
}
delete pEv;
diff --git a/vcl/source/window/wrkwin.cxx b/vcl/source/window/wrkwin.cxx
index 1f75bd63a5ec..136adc859d84 100644
--- a/vcl/source/window/wrkwin.cxx
+++ b/vcl/source/window/wrkwin.cxx
@@ -49,7 +49,7 @@ void WorkWindow::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentDat
if ( nStyle & WB_APP )
nFrameStyle |= BORDERWINDOW_STYLE_APP;
- ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle );
+ VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, pSystemParentData, nStyle, nFrameStyle );
Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
pBorderWin->mpWindowImpl->mpClientWindow = this;
pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
@@ -113,12 +113,18 @@ WorkWindow::WorkWindow( SystemParentData* pParent ) :
WorkWindow::~WorkWindow()
{
+ disposeOnce();
+}
+
+void WorkWindow::dispose()
+{
ImplSVData* pSVData = ImplGetSVData();
if ( pSVData->maWinData.mpAppWin == this )
{
pSVData->maWinData.mpAppWin = NULL;
Application::Quit();
}
+ SystemWindow::dispose();
}
void WorkWindow::ShowFullScreenMode( bool bFullScreenMode )