include/sfx2/lnkbase.hxx      |   14 ++++----
 sfx2/source/appl/lnkbase2.cxx |   72 +++++++++++++++++-------------------------
 2 files changed, 38 insertions(+), 48 deletions(-)

New commits:
commit fa15b0e86a5e78a2cb56aa36f161e1b9769e3441
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Aug 24 10:07:14 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 24 21:25:41 2021 +0200

    remove one of the pimpls in SvBaseLink
    
    two pimpl's and some internal fields seems a little messy
    
    Change-Id: I24f5a8e264dd98f8f74ab904ace85be1e9ff7acb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120939
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/sfx2/lnkbase.hxx b/include/sfx2/lnkbase.hxx
index 332702b8893f..38b1ef57dfe2 100644
--- a/include/sfx2/lnkbase.hxx
+++ b/include/sfx2/lnkbase.hxx
@@ -69,21 +69,25 @@ constexpr bool isClientFileType(SvBaseLinkObjectType t)
     return (static_cast<int>(t) & check) == check;
 }
 
-struct BaseLink_Impl;
-
 class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
 {
 private:
     friend class LinkManager;
     friend class SvLinkSource;
 
+    Link<SvBaseLink&,void>  m_aEndEditLink;
+    LinkManager*            m_pLinkMgr;
+    weld::Window*           m_pParentWin;
+    std::unique_ptr<FileDialogHelper>
+                            m_pFileDlg;
     SvLinkSourceRef         xObj;
     OUString                aLinkName;
-    std::unique_ptr<BaseLink_Impl>  pImpl;
+    std::unique_ptr<ImplBaseLinkData> pImplData;
     SvBaseLinkObjectType    mnObjType;
     bool                    bVisible : 1;
     bool                    bSynchron : 1;
     bool                    bWasLastEditOK : 1;
+    bool                    m_bIsConnect : 1;
 
     DECL_LINK( EndEditHdl, const OUString&, void );
 
@@ -95,8 +99,6 @@ protected:
     // Set LinkSourceName without action
     void            SetName( const OUString & rLn );
 
-    std::unique_ptr<ImplBaseLinkData> pImplData;
-
     bool            m_bIsReadOnly;
     css::uno::Reference<css::io::XInputStream>
                     m_xInputStreamToLoadFrom;
@@ -169,7 +171,7 @@ public:
     void            clearStreamToLoadFrom();
 
     bool     WasLastEditOK() const       { return bWasLastEditOK; }
-    FileDialogHelper & GetInsertFileDialog(const OUString& rFactory) const;
+    FileDialogHelper & GetInsertFileDialog(const OUString& rFactory);
 };
 
 }
diff --git a/sfx2/source/appl/lnkbase2.cxx b/sfx2/source/appl/lnkbase2.cxx
index 8df00b9bd788..7fd3b3d530d5 100644
--- a/sfx2/source/appl/lnkbase2.cxx
+++ b/sfx2/source/appl/lnkbase2.cxx
@@ -41,27 +41,9 @@ namespace sfx2
 {
 
 namespace {
-
-class  ImplDdeItem;
-
+class ImplDdeItem;
 }
 
-struct BaseLink_Impl
-{
-    Link<SvBaseLink&,void> m_aEndEditLink;
-    LinkManager*        m_pLinkMgr;
-    weld::Window*       m_pParentWin;
-    std::unique_ptr<FileDialogHelper>
-                        m_pFileDlg;
-    bool                m_bIsConnect;
-
-    BaseLink_Impl() :
-          m_pLinkMgr( nullptr )
-        , m_pParentWin( nullptr )
-        , m_bIsConnect( false )
-        {}
-};
-
 // only for internal management
 struct ImplBaseLinkData
 {
@@ -126,8 +108,10 @@ public:
 }
 
 SvBaseLink::SvBaseLink()
-    : pImpl ( new BaseLink_Impl ),
-      m_bIsReadOnly(false)
+    : m_pLinkMgr( nullptr )
+    , m_pParentWin( nullptr )
+    , m_bIsConnect( false )
+    , m_bIsReadOnly(false)
 {
     mnObjType = SvBaseLinkObjectType::ClientSo;
     pImplData.reset( new ImplBaseLinkData );
@@ -137,8 +121,10 @@ SvBaseLink::SvBaseLink()
 
 
 SvBaseLink::SvBaseLink( SfxLinkUpdateMode nUpdateMode, SotClipboardFormatId 
nContentType )
-   : pImpl( new BaseLink_Impl ),
-     m_bIsReadOnly(false)
+    : m_pLinkMgr( nullptr )
+    , m_pParentWin( nullptr )
+    , m_bIsConnect( false )
+    , m_bIsReadOnly(false)
 {
     mnObjType = SvBaseLinkObjectType::ClientSo;
     pImplData.reset( new ImplBaseLinkData );
@@ -184,7 +170,9 @@ static DdeTopic* FindTopic( const OUString & rLinkName, 
sal_uInt16* pItemStt )
 }
 
 SvBaseLink::SvBaseLink( const OUString& rLinkName, SvBaseLinkObjectType 
nObjectType, SvLinkSource* pObj )
-    : pImpl()
+    : m_pLinkMgr( nullptr )
+    , m_pParentWin( nullptr )
+    , m_bIsConnect( false )
     , m_bIsReadOnly(false)
 {
     bVisible = bSynchron = true;
@@ -241,7 +229,7 @@ IMPL_LINK( SvBaseLink, EndEditHdl, const OUString&, 
_rNewName, void )
     if ( !ExecuteEdit( sNewName ) )
         sNewName.clear();
     bWasLastEditOK = !sNewName.isEmpty();
-    pImpl->m_aEndEditLink.Call( *this );
+    m_aEndEditLink.Call( *this );
 }
 
 
@@ -364,7 +352,7 @@ SfxLinkUpdateMode SvBaseLink::GetUpdateMode() const
 
 void SvBaseLink::GetRealObject_( bool bConnect)
 {
-    if( !pImpl->m_pLinkMgr )
+    if( !m_pLinkMgr )
         return;
 
     DBG_ASSERT( !xObj.is(), "object already exist" );
@@ -414,17 +402,17 @@ void SvBaseLink::SetContentType( SotClipboardFormatId 
nType )
 
 LinkManager* SvBaseLink::GetLinkManager()
 {
-    return pImpl->m_pLinkMgr;
+    return m_pLinkMgr;
 }
 
 const LinkManager* SvBaseLink::GetLinkManager() const
 {
-    return pImpl->m_pLinkMgr;
+    return m_pLinkMgr;
 }
 
 void SvBaseLink::SetLinkManager( LinkManager* _pMgr )
 {
-    pImpl->m_pLinkMgr = _pMgr;
+    m_pLinkMgr = _pMgr;
 }
 
 void SvBaseLink::Disconnect()
@@ -449,10 +437,10 @@ SvBaseLink::UpdateResult SvBaseLink::DataChanged( const 
OUString &, const css::u
 
 void SvBaseLink::Edit(weld::Window* pParent, const Link<SvBaseLink&,void>& 
rEndEditHdl )
 {
-    pImpl->m_pParentWin = pParent;
-    pImpl->m_aEndEditLink = rEndEditHdl;
-    pImpl->m_bIsConnect = xObj.is();
-    if( !pImpl->m_bIsConnect )
+    m_pParentWin = pParent;
+    m_aEndEditLink = rEndEditHdl;
+    m_bIsConnect = xObj.is();
+    if( !m_bIsConnect )
         GetRealObject_( xObj.is() );
 
     bool bAsync = false;
@@ -460,7 +448,7 @@ void SvBaseLink::Edit(weld::Window* pParent, const 
Link<SvBaseLink&,void>& rEndE
 
     if( isClientType(mnObjType) && pImplData->ClientType.bIntrnlLnk )
     {
-        if( pImpl->m_pLinkMgr )
+        if( m_pLinkMgr )
         {
             SvLinkSourceRef ref = sfx2::LinkManager::CreateObj( this );
             if( ref.is() )
@@ -480,7 +468,7 @@ void SvBaseLink::Edit(weld::Window* pParent, const 
Link<SvBaseLink&,void>& rEndE
     {
         ExecuteEdit( OUString() );
         bWasLastEditOK = false;
-        pImpl->m_aEndEditLink.Call( *this );
+        m_aEndEditLink.Call( *this );
     }
 }
 
@@ -516,14 +504,14 @@ bool SvBaseLink::ExecuteEdit( const OUString& _rNewName )
             else
                 return false;
 
-            std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(pImpl->m_pParentWin,
+            std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(m_pParentWin,
                                                                      
VclMessageType::Warning, VclButtonsType::Ok, sError));
             xBox->run();
         }
     }
-    else if( !pImpl->m_bIsConnect )
+    else if( !m_bIsConnect )
         Disconnect();
-    pImpl->m_bIsConnect = false;
+    m_bIsConnect = false;
     return true;
 }
 
@@ -533,12 +521,12 @@ void SvBaseLink::Closed()
         xObj->RemoveAllDataAdvise( this );
 }
 
-FileDialogHelper & SvBaseLink::GetInsertFileDialog(const OUString& rFactory) 
const
+FileDialogHelper & SvBaseLink::GetInsertFileDialog(const OUString& rFactory)
 {
-    pImpl->m_pFileDlg.reset( new FileDialogHelper(
+    m_pFileDlg.reset( new FileDialogHelper(
             ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
-            FileDialogFlags::Insert, rFactory, SfxFilterFlags::NONE, 
SfxFilterFlags::NONE, pImpl->m_pParentWin) );
-    return *pImpl->m_pFileDlg;
+            FileDialogFlags::Insert, rFactory, SfxFilterFlags::NONE, 
SfxFilterFlags::NONE, m_pParentWin) );
+    return *m_pFileDlg;
 }
 
 ImplDdeItem::~ImplDdeItem()

Reply via email to