From commits-return-51681-archive-asf-public=cust-asf.ponee.io@openoffice.apache.org Mon Feb 5 19:20:52 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id AB9DC180647 for ; Mon, 5 Feb 2018 19:20:52 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9B37C160C4B; Mon, 5 Feb 2018 18:20:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 47BD4160C3B for ; Mon, 5 Feb 2018 19:20:51 +0100 (CET) Received: (qmail 86913 invoked by uid 500); 5 Feb 2018 18:20:50 -0000 Mailing-List: contact commits-help@openoffice.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openoffice.apache.org Delivered-To: mailing list commits@openoffice.apache.org Received: (qmail 86904 invoked by uid 99); 5 Feb 2018 18:20:50 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2018 18:20:50 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 3E9513A0166 for ; Mon, 5 Feb 2018 18:20:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1823225 - in /openoffice/trunk/main/toolkit: inc/layout/layout.hxx source/layout/vcl/wbutton.cxx source/layout/vcl/wcontainer.cxx source/layout/vcl/wfield.cxx source/layout/vcl/wrapper.cxx source/layout/vcl/wrapper.hxx Date: Mon, 05 Feb 2018 18:20:47 -0000 To: commits@openoffice.apache.org From: truckman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180205182049.3E9513A0166@svn01-us-west.apache.org> Author: truckman Date: Mon Feb 5 18:20:47 2018 New Revision: 1823225 URL: http://svn.apache.org/viewvc?rev=1823225&view=rev Log: A number of methods in main/toolkit/source/layout/vcl/* use either "!this" or "this" in a boolean context in order to detect being called with a null object and exit early. In a valid C++ program "this" will never be null, so a compiler could legally optimize out this comparision, which could potentially result in the method dereferencing a null pointer later in the code. This situation could only happen if the caller is using a null object pointer to call the method or is using a object ref to call the method that was generated by dereferencing a null pointer, neither of which is valid. Resolve this by moving the checks out of the method and into the caller. Make this easier by changing the getImpl() method to return the private *Impl pointer directly instead of deferencing the pointer and returning a ref. The latter is invalid if the pointer is null. This allows GetImpl() to be called in a boolean contect to peform the check. It also allows a number of instances of "&getImpl()" calls in a boolean context to be fixed by changing them to "getImpl()". The address of a ref will never be zero in a valid C++ program, so the compiler could potentially optimize out those checks. There does not appear to be any need for Control and ComboBox to use customized versions of GetImpl() since these appear to behave identically to the versions generated by the canned macro, so switch them back to the macro version. This commit should result in no functional changes. It seems like all of these checks for a null implementation should not be necessary, but that requires further investigation. Modified: openoffice/trunk/main/toolkit/inc/layout/layout.hxx openoffice/trunk/main/toolkit/source/layout/vcl/wbutton.cxx openoffice/trunk/main/toolkit/source/layout/vcl/wcontainer.cxx openoffice/trunk/main/toolkit/source/layout/vcl/wfield.cxx openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.cxx openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.hxx Modified: openoffice/trunk/main/toolkit/inc/layout/layout.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/inc/layout/layout.hxx?rev=1823225&r1=1823224&r2=1823225&view=diff ============================================================================== --- openoffice/trunk/main/toolkit/inc/layout/layout.hxx (original) +++ openoffice/trunk/main/toolkit/inc/layout/layout.hxx Mon Feb 5 18:20:47 2018 @@ -102,7 +102,7 @@ public: t( Window *parent, WinBits nStyle = defaultWinBit ); \ t (Window *parent, ResId const &res) #define DECL_GET_IMPL(t) \ - inline t##Impl &getImpl() const + inline t##Impl *getImpl() const #define DECL_GET_WINDOW( cls ) ::cls* Get##cls() const #define IMPL_GET_WINDOW( cls ) ::cls* cls::Get##cls() const { return dynamic_cast< ::cls*>( GetWindow() ); } Modified: openoffice/trunk/main/toolkit/source/layout/vcl/wbutton.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/source/layout/vcl/wbutton.cxx?rev=1823225&r1=1823224&r2=1823225&view=diff ============================================================================== --- openoffice/trunk/main/toolkit/source/layout/vcl/wbutton.cxx (original) +++ openoffice/trunk/main/toolkit/source/layout/vcl/wbutton.cxx Mon Feb 5 18:20:47 2018 @@ -140,35 +140,36 @@ String Button::GetStandardText (sal_uInt void Button::SetText( OUString const& rStr ) { - if ( !getImpl().mxButton.is() ) + if ( !getImpl()->mxButton.is() ) return; - getImpl().mxButton->setLabel( rStr ); + getImpl()->mxButton->setLabel( rStr ); } void Button::SetClickHdl( const Link& link ) { - if (&getImpl () && getImpl().mxButton.is ()) - getImpl().SetClickHdl( link ); + if (getImpl() && getImpl()->mxButton.is ()) + getImpl()->SetClickHdl( link ); } Link& Button::GetClickHdl () { - return getImpl().GetClickHdl (); + return getImpl()->GetClickHdl (); } bool Button::SetModeImage (Image const& image) { - return getImpl().SetModeImage (image.getImpl().mxGraphic); + return getImpl() || getImpl()->SetModeImage (image.getImpl().mxGraphic); } bool Button::SetModeImage (::Image const& image, BmpColorMode mode) { - return GetButton ()->SetModeImage (image, mode); + return !GetButton () || GetButton ()->SetModeImage (image, mode); } void Button::SetImageAlign( ImageAlign eAlign ) { - getImpl().setProperty( "ImageAlign", uno::Any( (sal_Int16) eAlign ) ); + if ( getImpl() ) + getImpl()->setProperty( "ImageAlign", uno::Any( (sal_Int16) eAlign ) ); } void Button::Click() @@ -229,14 +230,15 @@ PushButton::~PushButton () void PushButton::Check( bool bCheck ) { - getImpl().setProperty( "State", uno::Any( (sal_Int16) !!bCheck ) ); + if ( getImpl() ) + getImpl()->setProperty( "State", uno::Any( (sal_Int16) !!bCheck ) ); // XButton doesn't have explicit toggle event - getImpl().fireToggle(); + getImpl()->fireToggle(); } bool PushButton::IsChecked() const { - return !!( getImpl().getProperty( "State" ).get< sal_Int16 >() ); + return !!( getImpl() && getImpl()->getProperty( "State" ).get< sal_Int16 >() ); } void PushButton::Toggle() @@ -246,8 +248,8 @@ void PushButton::Toggle() void PushButton::SetToggleHdl( const Link& link ) { - if (&getImpl () && getImpl().mxButton.is ()) - getImpl().SetToggleHdl( link ); + if (getImpl() && getImpl()->mxButton.is ()) + getImpl()->SetToggleHdl( link ); } IMPL_GET_IMPL( PushButton ); @@ -343,18 +345,18 @@ RadioButton::~RadioButton () void RadioButton::Check( bool bCheck ) { - getImpl().Check( bCheck ); + getImpl()->Check( bCheck ); } bool RadioButton::IsChecked() const { - return getImpl().IsChecked(); + return getImpl()->IsChecked(); } void RadioButton::SetToggleHdl( const Link& link ) { - if (&getImpl () && getImpl().mxRadioButton.is ()) - getImpl().SetToggleHdl( link ); + if (getImpl() && getImpl()->mxRadioButton.is ()) + getImpl()->SetToggleHdl( link ); } IMPL_GET_IMPL( RadioButton ); @@ -401,22 +403,22 @@ CheckBox::~CheckBox () void CheckBox::Check( bool bCheck ) { - if ( !getImpl().mxCheckBox.is() ) + if ( !getImpl()->mxCheckBox.is() ) return; - getImpl().mxCheckBox->setState( !!bCheck ); + getImpl()->mxCheckBox->setState( !!bCheck ); } bool CheckBox::IsChecked() const { - if ( !getImpl().mxCheckBox.is() ) + if ( !getImpl()->mxCheckBox.is() ) return false; - return getImpl().mxCheckBox->getState() != 0; + return getImpl()->mxCheckBox->getState() != 0; } void CheckBox::SetToggleHdl( const Link& link ) { - if (&getImpl () && getImpl().mxCheckBox.is ()) - getImpl().SetToggleHdl( link ); + if (getImpl() && getImpl()->mxCheckBox.is ()) + getImpl()->SetToggleHdl( link ); } IMPL_GET_IMPL( CheckBox ); @@ -578,51 +580,51 @@ public: void AdvancedButton::AddAdvanced( Window* w ) { - getImpl().AddAdvanced( w ); + getImpl()->AddAdvanced( w ); } void AdvancedButton::AddSimple( Window* w ) { - getImpl().AddSimple( w ); + getImpl()->AddSimple( w ); } void AdvancedButton::RemoveAdvanced( Window* w ) { - getImpl().RemoveAdvanced( w ); + getImpl()->RemoveAdvanced( w ); } void AdvancedButton::RemoveSimple( Window* w ) { - getImpl().RemoveSimple( w ); + getImpl()->RemoveSimple( w ); } void AdvancedButton::SetAdvancedText (rtl::OUString const& text) { if (text.getLength ()) - getImpl ().mAdvancedLabel = text; + getImpl()->mAdvancedLabel = text; } void AdvancedButton::SetSimpleText (rtl::OUString const& text) { if (text.getLength ()) - getImpl ().mSimpleLabel = text; + getImpl()->mSimpleLabel = text; } rtl::OUString AdvancedButton::GetAdvancedText () const { - return getImpl ().mAdvancedLabel; + return getImpl()->mAdvancedLabel; } rtl::OUString AdvancedButton::GetSimpleText () const { - return getImpl ().mSimpleLabel; + return getImpl()->mSimpleLabel; } void AdvancedButton::SetDelta (int) { } -IMPL_CONSTRUCTORS_BODY( AdvancedButton, PushButton, "advancedbutton", getImpl().simpleMode () ); +IMPL_CONSTRUCTORS_BODY( AdvancedButton, PushButton, "advancedbutton", getImpl()->simpleMode () ); IMPL_GET_IMPL( AdvancedButton ); @@ -641,17 +643,17 @@ public: // TODO //BUTTON_IMPL( MoreButton, PushButton, 0 ); -IMPL_CONSTRUCTORS_BODY( MoreButton, AdvancedButton, "morebutton", getImpl().simpleMode () ); +IMPL_CONSTRUCTORS_BODY( MoreButton, AdvancedButton, "morebutton", getImpl()->simpleMode () ); IMPL_GET_IMPL( MoreButton ); void MoreButton::AddWindow( Window* w ) { - getImpl().AddWindow( w ); + getImpl()->AddWindow( w ); } void MoreButton::RemoveWindow( Window* w ) { - getImpl().RemoveWindow( w ); + getImpl()->RemoveWindow( w ); } void MoreButton::SetMoreText (rtl::OUString const& text) Modified: openoffice/trunk/main/toolkit/source/layout/vcl/wcontainer.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/source/layout/vcl/wcontainer.cxx?rev=1823225&r1=1823224&r2=1823225&view=diff ============================================================================== --- openoffice/trunk/main/toolkit/source/layout/vcl/wcontainer.cxx (original) +++ openoffice/trunk/main/toolkit/source/layout/vcl/wcontainer.cxx Mon Feb 5 18:20:47 2018 @@ -149,8 +149,8 @@ void Table::Add( Window *window, bool bX { if ( !window ) return; - WindowImpl &rImpl = window->getImpl(); - uno::Reference< awt::XLayoutConstrains > xChild( rImpl.mxWindow, + WindowImpl *pImpl = window->getImpl(); + uno::Reference< awt::XLayoutConstrains > xChild( pImpl->mxWindow, uno::UNO_QUERY ); mxContainer->addChild( xChild ); setProps( xChild, bXExpand, bYExpand, nXSpan, nYSpan ); @@ -194,8 +194,8 @@ void Box::Add( Window *window, bool bExp { if ( !window ) return; - WindowImpl &rImpl = window->getImpl(); - uno::Reference< awt::XLayoutConstrains > xChild( rImpl.mxWindow, + WindowImpl *pImpl = window->getImpl(); + uno::Reference< awt::XLayoutConstrains > xChild( pImpl->mxWindow, uno::UNO_QUERY ); mxContainer->addChild( xChild ); Modified: openoffice/trunk/main/toolkit/source/layout/vcl/wfield.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/source/layout/vcl/wfield.cxx?rev=1823225&r1=1823224&r2=1823225&view=diff ============================================================================== --- openoffice/trunk/main/toolkit/source/layout/vcl/wfield.cxx (original) +++ openoffice/trunk/main/toolkit/source/layout/vcl/wfield.cxx Mon Feb 5 18:20:47 2018 @@ -101,8 +101,8 @@ Edit::~Edit () void Edit::SetSelection( Selection const& rSelection ) { #if LAYOUT_API_CALLS_HANDLER - if ( !getImpl().mxEdit.is() ) - getImpl().mxEdit->setSelection( awt::Selection( rSelection.Min(), rSelection.Max() ) ); + if ( !getImpl()->mxEdit.is() ) + getImpl()->mxEdit->setSelection( awt::Selection( rSelection.Min(), rSelection.Max() ) ); #else /* !LAYOUT_API_CALLS_HANDLER */ GetEdit ()->SetSelection (rSelection); #endif /* !LAYOUT_API_CALLS_HANDLER */ @@ -111,9 +111,9 @@ void Edit::SetSelection( Selection const void Edit::SetText( OUString const& rStr ) { #if LAYOUT_API_CALLS_HANDLER - if ( getImpl().mxEdit.is() ) + if ( getImpl()->mxEdit.is() ) /// this calls handlers; endless loop in numfmt.cxx - getImpl().mxEdit->setText( rStr ); + getImpl()->mxEdit->setText( rStr ); #else /* !LAYOUT_API_CALLS_HANDLER */ GetEdit ()->SetText (rStr); #endif /* !LAYOUT_API_CALLS_HANDLER */ @@ -121,15 +121,15 @@ void Edit::SetText( OUString const& rStr String Edit::GetText() const { - if ( !getImpl().mxEdit.is() ) - return getImpl().mxEdit->getText(); + if ( !getImpl()->mxEdit.is() ) + return getImpl()->mxEdit->getText(); return OUString(); } void Edit::SetModifyHdl( const Link& link ) { - if (&getImpl () && getImpl().mxEdit.is ()) - getImpl().SetModifyHdl( link ); + if (getImpl() && getImpl()->mxEdit.is ()) + getImpl()->SetModifyHdl( link ); } IMPL_CONSTRUCTORS( Edit, Control, "edit" ); @@ -434,51 +434,52 @@ void ComboBoxImpl::disposing( lang::Even sal_uInt16 ComboBox::InsertEntry( String const& rStr, sal_uInt16 nPos ) { - return getImpl().InsertEntry( rStr, nPos ); + return getImpl()->InsertEntry( rStr, nPos ); } void ComboBox::RemoveEntry( String const& rStr ) { - getImpl().RemoveEntry( GetEntryPos( rStr ) ); + getImpl()->RemoveEntry( GetEntryPos( rStr ) ); } void ComboBox::RemoveEntry( sal_uInt16 nPos ) { - getImpl().RemoveEntry( nPos ); + getImpl()->RemoveEntry( nPos ); } void ComboBox::Clear() { uno::Sequence< rtl::OUString> aNoItems; - getImpl().setProperty( "StringItemList", uno::Any( aNoItems ) ); + if ( getImpl() ) + getImpl()->setProperty( "StringItemList", uno::Any( aNoItems ) ); } sal_uInt16 ComboBox::GetEntryPos( String const& rStr ) const { - return getImpl().GetEntryPos( rStr ); + return getImpl()->GetEntryPos( rStr ); } String ComboBox::GetEntry( sal_uInt16 nPos ) const { - rtl::OUString rItem = getImpl().mxComboBox->getItem( nPos ); + rtl::OUString rItem = getImpl()->mxComboBox->getItem( nPos ); return OUString( rItem ); } sal_uInt16 ComboBox::GetEntryCount() const { - return getImpl().GetEntryCount(); + return getImpl()->GetEntryCount(); } void ComboBox::SetClickHdl( const Link& link ) { - if (&getImpl () && getImpl().mxComboBox.is ()) - getImpl().SetClickHdl( link ); + if (getImpl() && getImpl()->mxComboBox.is ()) + getImpl()->SetClickHdl( link ); } void ComboBox::SetSelectHdl( const Link& link ) { - if (&getImpl () && getImpl().mxComboBox.is ()) - getImpl().SetSelectHdl( link ); + if (getImpl() && getImpl()->mxComboBox.is ()) + getImpl()->SetSelectHdl( link ); } void ComboBox::EnableAutocomplete (bool enable, bool matchCase) @@ -486,18 +487,9 @@ void ComboBox::EnableAutocomplete (bool GetComboBox ()->EnableAutocomplete (enable, matchCase); } -IMPL_CONSTRUCTORS_BODY( ComboBox, Edit, "combobox", getImpl().parent = parent; ); +IMPL_CONSTRUCTORS_BODY( ComboBox, Edit, "combobox", getImpl()->parent = parent; ); IMPL_GET_WINDOW (ComboBox); -/// IMPL_GET_IMPL( ComboBox ); - -static ComboBoxImpl* null_combobox_impl = 0; - -ComboBoxImpl &ComboBox::getImpl () const -{ - if (ComboBoxImpl* c = static_cast(mpImpl)) - return *c; - return *null_combobox_impl; -} +IMPL_GET_IMPL( ComboBox ); class ListBoxImpl : public ControlImpl , public ::cppu::WeakImplHelper1< awt::XActionListener > @@ -668,44 +660,45 @@ ListBox::~ListBox () sal_uInt16 ListBox::InsertEntry (String const& rStr, sal_uInt16 nPos) { - return getImpl().InsertEntry(rStr, nPos); + return getImpl()->InsertEntry(rStr, nPos); } void ListBox::RemoveEntry( sal_uInt16 nPos ) { - return getImpl().RemoveEntry( nPos ); + return getImpl()->RemoveEntry( nPos ); } void ListBox::RemoveEntry( String const& rStr ) { - return getImpl().RemoveEntry( GetEntryPos( rStr ) ); + return getImpl()->RemoveEntry( GetEntryPos( rStr ) ); } void ListBox::Clear() { uno::Sequence< rtl::OUString> aNoItems; - getImpl().setProperty( "StringItemList", uno::Any( aNoItems ) ); + if ( getImpl() ) + getImpl()->setProperty( "StringItemList", uno::Any( aNoItems ) ); } sal_uInt16 ListBox::GetEntryPos( String const& rStr ) const { - return getImpl().GetEntryPos( rStr ); + return getImpl()->GetEntryPos( rStr ); } String ListBox::GetEntry( sal_uInt16 nPos ) const { - return getImpl().GetEntry( nPos ); + return getImpl()->GetEntry( nPos ); } sal_uInt16 ListBox::GetEntryCount() const { - return getImpl().GetEntryCount(); + return getImpl()->GetEntryCount(); } void ListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect ) { #if LAYOUT_API_CALLS_HANDLER - getImpl().SelectEntryPos( nPos, bSelect ); + getImpl()->SelectEntryPos( nPos, bSelect ); #else /* !LAYOUT_API_CALLS_HANDLER */ GetListBox ()->SelectEntryPos (nPos, bSelect); #endif /* !LAYOUT_API_CALLS_HANDLER */ @@ -718,12 +711,12 @@ void ListBox::SelectEntry( String const& sal_uInt16 ListBox::GetSelectEntryCount() const { - return getImpl().GetSelectEntryCount(); + return getImpl()->GetSelectEntryCount(); } sal_uInt16 ListBox::GetSelectEntryPos( sal_uInt16 nSelIndex ) const { - return getImpl().GetSelectEntryPos( nSelIndex ); + return getImpl()->GetSelectEntryPos( nSelIndex ); } String ListBox::GetSelectEntry( sal_uInt16 nSelIndex ) const @@ -733,33 +726,33 @@ String ListBox::GetSelectEntry( sal_uInt Link& ListBox::GetSelectHdl () { - return getImpl ().GetSelectHdl (); + return getImpl()->GetSelectHdl (); } void ListBox::SetSelectHdl( Link const& link ) { - getImpl().SetSelectHdl( link ); + getImpl()->SetSelectHdl( link ); } Link& ListBox::GetClickHdl () { - return getImpl ().GetSelectHdl (); + return getImpl()->GetSelectHdl (); } void ListBox::SetClickHdl( Link const& link ) { - if (&getImpl () && getImpl().mxListBox.is ()) - getImpl().SetClickHdl( link ); + if (getImpl() && getImpl()->mxListBox.is ()) + getImpl()->SetClickHdl( link ); } Link& ListBox::GetDoubleClickHdl () { - return getImpl ().GetSelectHdl (); + return getImpl()->GetSelectHdl (); } void ListBox::SetDoubleClickHdl( Link const& link ) { - getImpl().SetDoubleClickHdl( link ); + getImpl()->SetDoubleClickHdl( link ); } void ListBox::SetEntryData( sal_uInt16 pos, void* data) Modified: openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.cxx?rev=1823225&r1=1823224&r2=1823225&view=diff ============================================================================== --- openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.cxx (original) +++ openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.cxx Mon Feb 5 18:20:47 2018 @@ -206,7 +206,7 @@ void SAL_CALL WindowImpl::disposing (lan uno::Any WindowImpl::getProperty (char const* name) { - if ( !this || !mxVclPeer.is() ) + if ( !mxVclPeer.is() ) return css::uno::Any(); return mxVclPeer->getProperty ( rtl::OUString( name, strlen( name ), RTL_TEXTENCODING_ASCII_US ) ); @@ -214,7 +214,7 @@ uno::Any WindowImpl::getProperty (char c void WindowImpl::setProperty (char const *name, uno::Any any) { - if ( !this || !mxVclPeer.is() ) + if ( !mxVclPeer.is() ) return; mxVclPeer->setProperty ( rtl::OUString( name, strlen( name ), RTL_TEXTENCODING_ASCII_US ), any ); @@ -249,16 +249,7 @@ Window::~Window() mpImpl = 0; } -///IMPL_GET_IMPL( Control ); - -static ControlImpl* null_control_impl = 0; - -ControlImpl &Control::getImpl () const -{ - if (ControlImpl* c = static_cast(mpImpl)) - return *c; - return *null_control_impl; -} +IMPL_GET_IMPL( Control ); Control::~Control () { @@ -336,7 +327,7 @@ void Window::ParentSet (Window *window) Context *Window::getContext() { - return this && mpImpl ? mpImpl->mpCtx : NULL; + return mpImpl ? mpImpl->mpCtx : NULL; } PeerHandle Window::GetPeer() const @@ -553,7 +544,8 @@ void Window::SetStyle( WinBits nStyle ) aValue = uno::makeAny( (bool) nValue ); else aValue = uno::makeAny( (short) nValue ); - mpImpl->setProperty( toolkitVclPropsMap[ i ].propName, aValue ); + if ( mpImpl ) + mpImpl->setProperty( toolkitVclPropsMap[ i ].propName, aValue ); } } } @@ -562,6 +554,8 @@ WinBits Window::GetStyle() { uno::Reference< awt::XVclWindowPeer > xPeer = mpImpl->mxVclPeer; WinBits ret = 0; + if ( !mpImpl ) + return 0; for (int i = 0; i < toolkitVclPropsMapLen; i++) { if ( toolkitVclPropsMap[ i ].propName ) @@ -613,30 +607,30 @@ PeerHandle Window::CreatePeer( Window *p void Window::Enable( bool bEnable ) { - if ( !getImpl().mxWindow.is() ) + if ( !getImpl()->mxWindow.is() ) return; - getImpl().mxWindow->setEnable( bEnable ); + getImpl()->mxWindow->setEnable( bEnable ); } void Window::Show( bool bVisible ) { - if ( !getImpl().mxWindow.is() ) + if ( !getImpl()->mxWindow.is() ) return; - getImpl().mxWindow->setVisible( bVisible ); + getImpl()->mxWindow->setVisible( bVisible ); if (!bVisible) - getImpl ().bFirstTimeVisible = true; - else if (GetParent() && getImpl().bFirstTimeVisible) + getImpl()->bFirstTimeVisible = true; + else if (GetParent() && getImpl()->bFirstTimeVisible) { - getImpl().redraw (); - getImpl().bFirstTimeVisible = false; + getImpl()->redraw (); + getImpl()->bFirstTimeVisible = false; } } void Window::GrabFocus() { - if ( !getImpl().mxWindow.is() ) + if ( !getImpl()->mxWindow.is() ) return; - getImpl().mxWindow->setFocus(); + getImpl()->mxWindow->setFocus(); } void Window::SetUpdateMode(bool mode) @@ -745,24 +739,24 @@ void SAL_CALL ControlImpl::focusLost (aw Link& Control::GetGetFocusHdl () { - return getImpl ().GetGetFocusHdl (); + return getImpl()->GetGetFocusHdl (); } void Control::SetGetFocusHdl (Link const& link) { - if (&getImpl () && getImpl().mxWindow.is ()) - getImpl ().SetGetFocusHdl (link); + if (getImpl() && getImpl()->mxWindow.is ()) + getImpl()->SetGetFocusHdl (link); } Link& Control::GetLoseFocusHdl () { - return getImpl ().GetLoseFocusHdl (); + return getImpl()->GetLoseFocusHdl (); } void Control::SetLoseFocusHdl (Link const& link) { - if (&getImpl () && getImpl().mxWindow.is ()) - getImpl ().SetLoseFocusHdl (link); + if (getImpl() && getImpl()->mxWindow.is ()) + getImpl()->SetLoseFocusHdl (link); } class DialogImpl : public WindowImpl @@ -802,8 +796,8 @@ Dialog::~Dialog () IMPL_GET_WINDOW (Dialog); IMPL_GET_IMPL (Dialog); -#define MX_DIALOG if (getImpl ().mxDialog.is ()) getImpl ().mxDialog -#define RETURN_MX_DIALOG if (getImpl ().mxDialog.is ()) return getImpl ().mxDialog +#define MX_DIALOG if (getImpl()->mxDialog.is ()) getImpl()->mxDialog +#define RETURN_MX_DIALOG if (getImpl()->mxDialog.is ()) return getImpl()->mxDialog short Dialog::Execute() { @@ -1082,8 +1076,8 @@ public: IMPL_GET_WINDOW (TabControl); IMPL_GET_LAYOUT_VCLXWINDOW (TabControl); -#define MX_TABCONTROL if (getImpl ().mxTabControl.is ()) getImpl ().mxTabControl -#define RETURN_MX_TABCONTROL if (getImpl ().mxTabControl.is ()) return getImpl ().mxTabControl +#define MX_TABCONTROL if (getImpl()->mxTabControl.is ()) getImpl()->mxTabControl +#define RETURN_MX_TABCONTROL if (getImpl()->mxTabControl.is ()) return getImpl ()->mxTabControl TabControl::~TabControl () { @@ -1132,7 +1126,7 @@ void TabControl::InsertPage (sal_uInt16 //GetVCLXTabControl ()->AddChild (uno::Reference (page->::Window::GetWindowPeer (), uno::UNO_QUERY)); //GetVCLXTabControl ()->AddChild (uno::Reference (page->GetComponentInterface (), uno::UNO_QUERY)); } - getImpl ().redraw (); + getImpl()->redraw (); #endif } void TabControl::RemovePage (sal_uInt16 id) @@ -1149,12 +1143,12 @@ sal_uInt16 TabControl::GetPageId (sal_uI } sal_uInt16 TabControl::GetPagePos (sal_uInt16 id) const { - getImpl ().redraw (); + getImpl()->redraw (); return GetTabControl ()->GetPagePos (id); } void TabControl::SetCurPageId (sal_uInt16 id) { - getImpl ().redraw (); + getImpl()->redraw (); GetTabControl ()->SetCurPageId (id); } sal_uInt16 TabControl::GetCurPageId () const @@ -1179,7 +1173,7 @@ void TabControl::SetTabPage (sal_uInt16 //GetVCLXTabControl ()->AddChild (uno::Reference (page->GetComponentInterface (), uno::UNO_QUERY)); } #endif - getImpl ().redraw (); + getImpl()->redraw (); } ::TabPage* TabControl::GetTabPage (sal_uInt16 id) const { @@ -1187,21 +1181,21 @@ void TabControl::SetTabPage (sal_uInt16 } void TabControl::SetActivatePageHdl (Link const& link) { - if (&getImpl () && getImpl().mxTabControl.is ()) - getImpl ().SetActivatePageHdl (link); + if (getImpl() && getImpl()->mxTabControl.is ()) + getImpl()->SetActivatePageHdl (link); } Link& TabControl::GetActivatePageHdl () const { - return getImpl ().GetActivatePageHdl (); + return getImpl()->GetActivatePageHdl (); } void TabControl::SetDeactivatePageHdl (Link const& link) { - if (&getImpl () && getImpl().mxTabControl.is ()) - getImpl ().SetDeactivatePageHdl (link); + if (getImpl() && getImpl()->mxTabControl.is ()) + getImpl()->SetDeactivatePageHdl (link); } Link& TabControl::GetDeactivatePageHdl () const { - return getImpl ().GetDeactivatePageHdl (); + return getImpl()->GetDeactivatePageHdl (); } void TabControl::SetTabPageSizePixel (Size const& size) { @@ -1330,9 +1324,9 @@ IMPL_GET_IMPL( FixedText ); void FixedText::SetText( OUString const& rStr ) { - if ( !getImpl().mxFixedText.is() ) + if ( !getImpl()->mxFixedText.is() ) return; - getImpl().mxFixedText->setText( rStr ); + getImpl()->mxFixedText->setText( rStr ); } class FixedInfoImpl : public FixedTextImpl @@ -1382,7 +1376,7 @@ public: } #if 0 else - getImpl().mxGraphic->...(); + getImpl()->mxGraphic->...(); #endif } }; @@ -1393,10 +1387,10 @@ IMPL_GET_IMPL( FixedImage ) void FixedImage::setImage( ::Image const& i ) { (void) i; - if ( !getImpl().mxGraphic.is() ) + if ( !getImpl()->mxGraphic.is() ) return; //FIXME: hack moved to proplist - //getImpl().mxGraphic = + //getImpl()->mxGraphic = } #if 0 @@ -1419,37 +1413,37 @@ IMPL_GET_IMPL( ProgressBar ); void ProgressBar::SetForegroundColor( util::Color color ) { - if ( !getImpl().mxProgressBar.is() ) + if ( !getImpl()->mxProgressBar.is() ) return; - getImpl().mxProgressBar->setForegroundColor( color ); + getImpl()->mxProgressBar->setForegroundColor( color ); } void ProgressBar::SetBackgroundColor( util::Color color ) { - if ( !getImpl().mxProgressBar.is() ) + if ( !getImpl()->mxProgressBar.is() ) return; - getImpl().mxProgressBar->setBackgroundColor( color ); + getImpl()->mxProgressBar->setBackgroundColor( color ); } void ProgressBar::SetValue( sal_Int32 i ) { - if ( !getImpl().mxProgressBar.is() ) + if ( !getImpl()->mxProgressBar.is() ) return; - getImpl().mxProgressBar->setValue( i ); + getImpl()->mxProgressBar->setValue( i ); } void ProgressBar::SetRange( sal_Int32 min, sal_Int32 max ) { - if ( !getImpl().mxProgressBar.is() ) + if ( !getImpl()->mxProgressBar.is() ) return; - getImpl().mxProgressBar->setRange( min, max ); + getImpl()->mxProgressBar->setRange( min, max ); } sal_Int32 ProgressBar::GetValue() { - if ( !getImpl().mxProgressBar.is() ) + if ( !getImpl()->mxProgressBar.is() ) return 0; - return getImpl().mxProgressBar->getValue(); + return getImpl()->mxProgressBar->getValue(); } class PluginImpl: public ControlImpl @@ -1516,12 +1510,12 @@ LocalizedString::LocalizedString( Contex String LocalizedString::getString () { - return getImpl ().getText (); + return getImpl()->getText (); } OUString LocalizedString::getOUString () { - return getImpl ().getText (); + return getImpl()->getText (); } LocalizedString::operator OUString () @@ -1532,13 +1526,13 @@ LocalizedString::operator OUString () LocalizedString::operator OUString const& () { getOUString (); - return getImpl ().maString; + return getImpl()->maString; } LocalizedString::operator String() { getOUString (); - return getImpl ().maString; + return getImpl()->maString; } String LocalizedString::GetToken (sal_uInt16 i, sal_Char c) @@ -1548,24 +1542,24 @@ String LocalizedString::GetToken (sal_uI OUString LocalizedString::operator= (OUString const& s) { - getImpl().setText( s ); - return getImpl().getText(); + getImpl()->setText( s ); + return getImpl()->getText(); } OUString LocalizedString::operator+= (OUString const& b) { - OUString a = getImpl ().getText (); + OUString a = getImpl()->getText (); a += b; - getImpl ().setText (a); - return getImpl ().getText (); + getImpl()->setText (a); + return getImpl()->getText (); } OUString LocalizedString::operator+= (sal_Unicode const b) { - String a = getImpl ().getText (); + String a = getImpl()->getText (); a += b; - getImpl ().setText (a); - return getImpl ().getText (); + getImpl()->setText (a); + return getImpl()->getText (); } class InPlugImpl : public WindowImpl Modified: openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.hxx?rev=1823225&r1=1823224&r2=1823225&view=diff ============================================================================== --- openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.hxx (original) +++ openoffice/trunk/main/toolkit/source/layout/vcl/wrapper.hxx Mon Feb 5 18:20:47 2018 @@ -83,14 +83,14 @@ public: void SAL_CALL focusLost (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException); }; -inline WindowImpl &Window::getImpl() const{ return *(static_cast< WindowImpl * >( mpImpl )); } +inline WindowImpl *Window::getImpl() const{ return (static_cast< WindowImpl * >( mpImpl )); } // Helpers for defining boiler-plate constructors ... // Could in-line in top-level but not with safe static_casts. #define IMPL_GET_IMPL(t) \ - inline t##Impl &t::getImpl() const \ + inline t##Impl* t::getImpl() const \ { \ - return *(static_cast(mpImpl)); \ + return (static_cast(mpImpl)); \ } #define IMPL_CONSTRUCTORS_BODY(t,par,unoName,body) \ t::t( Context *context, const char *pId, sal_uInt32 nId ) \