[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Xisco Fauli anistenis at gmail.com
Mon Jun 6 07:10:33 UTC 2016


 include/sfx2/viewsh.hxx                |    2 
 sfx2/source/view/sfxbasecontroller.cxx |    2 
 sfx2/source/view/viewprn.cxx           |   14 +--
 sfx2/source/view/viewsh.cxx            |  136 ++++++++++++++++-----------------
 4 files changed, 76 insertions(+), 78 deletions(-)

New commits:
commit 82407c651ee8b5d8876d4a1f76898de33c69e232
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Jun 5 00:53:03 2016 +0200

    tdf#89329: use unique_ptr for pImpl in viewsh
    
    Change-Id: I8847b734c90adf2710f5481af41883eb5017c44a
    Reviewed-on: https://gerrit.libreoffice.org/25911
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index f76e00c..936df38 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -148,7 +148,7 @@ friend class SfxBaseController;
 friend class SfxPrinterController;
 #endif
 
-    struct SfxViewShell_Impl*   pImp;
+    std::unique_ptr<struct SfxViewShell_Impl>   pImpl;
     SfxViewFrame*               pFrame;
     SfxShell*                   pSubShell;
     VclPtr<vcl::Window>         pWindow;
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index eca3f8a..11c316c 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -996,7 +996,7 @@ void SAL_CALL SfxBaseController::dispose() throw( RuntimeException, std::excepti
         if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell )
             pFrame->GetFrame().SetIsClosing_Impl();
         m_pData->m_pViewShell->DiscardClients_Impl();
-        m_pData->m_pViewShell->pImp->m_bControllerSet = false;
+        m_pData->m_pViewShell->pImpl->m_bControllerSet = false;
 
         if ( pFrame )
         {
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 1ce85c4..87b0869 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -397,7 +397,7 @@ void SfxPrinterController::jobFinished( css::view::PrintableState nState )
 
         if ( mpViewShell )
         {
-            mpViewShell->pImp->m_xPrinterController.reset();
+            mpViewShell->pImpl->m_xPrinterController.reset();
         }
     }
 }
@@ -567,7 +567,7 @@ void SfxViewShell::SetPrinter_Impl( VclPtr<SfxPrinter>& pNewPrinter )
 
 void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rProps, bool bIsAPI, bool bIsDirect )
 {
-    assert( pImp->m_xPrinterController.get() == nullptr );
+    assert( pImpl->m_xPrinterController.get() == nullptr );
 
     // get the current selection; our controller should know it
     Reference< frame::XController > xController( GetController() );
@@ -605,7 +605,7 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr
                                                                                this,
                                                                                rProps
                                                                                ));
-    pImp->m_xPrinterController = xNewController;
+    pImpl->m_xPrinterController = xNewController;
 
     SfxObjectShell *pObjShell = GetObjectShell();
     xNewController->setValue( "JobName",
@@ -624,13 +624,13 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro
 
 const std::shared_ptr< vcl::PrinterController >& SfxViewShell::GetPrinterController() const
 {
-    return pImp->m_xPrinterController;
+    return pImpl->m_xPrinterController;
 }
 
 Printer* SfxViewShell::GetActivePrinter() const
 {
-    return (pImp->m_xPrinterController)
-        ?  pImp->m_xPrinterController->getPrinter().get() : nullptr;
+    return (pImpl->m_xPrinterController)
+        ?  pImpl->m_xPrinterController->getPrinter().get() : nullptr;
 }
 
 void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
@@ -821,7 +821,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
                 VclPtrInstance<PrinterSetupDialog> pPrintSetupDlg( GetWindow() );
                 std::unique_ptr<SfxDialogExecutor_Impl> pExecutor;
 
-                if (pImp->m_bHasPrintOptions && HasPrintOptionsPage())
+                if (pImpl->m_bHasPrintOptions && HasPrintOptionsPage())
                 {
                     // additional controls for dialog
                     pExecutor.reset( new SfxDialogExecutor_Impl( this, pPrintSetupDlg ) );
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index a957c14..e3ec058 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -381,12 +381,12 @@ OUString impl_searchFormatTypeForApp(const css::uno::Reference< css::frame::XFra
 
 void SfxViewShell::NewIPClient_Impl( SfxInPlaceClient *pIPClient )
 {
-    pImp->GetIPClientList_Impl()->push_back(pIPClient);
+    pImpl->GetIPClientList_Impl()->push_back(pIPClient);
 }
 
 void SfxViewShell::IPClientGone_Impl( SfxInPlaceClient *pIPClient )
 {
-    SfxInPlaceClientList* pClientList = pImp->GetIPClientList_Impl();
+    SfxInPlaceClientList* pClientList = pImpl->GetIPClientList_Impl();
 
     for( SfxInPlaceClientList::iterator it = pClientList->begin(); it != pClientList->end(); ++it )
     {
@@ -409,7 +409,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
             const SfxUInt16Item* pItem = rReq.GetArg<SfxUInt16Item>(nId);
             if (pItem)
             {
-                pImp->m_nFamily = pItem->GetValue();
+                pImpl->m_nFamily = pItem->GetValue();
             }
             break;
         }
@@ -707,7 +707,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
             case SID_SETUPPRINTER:
             case SID_PRINTER_NAME:
             {
-                bool bEnabled = pImp->m_bCanPrint && !pImp->m_nPrinterLocks
+                bool bEnabled = pImpl->m_bCanPrint && !pImpl->m_nPrinterLocks
                               && !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
                 if ( bEnabled )
                 {
@@ -740,7 +740,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
             }
             case SID_STYLE_FAMILY :
             {
-                rSet.Put( SfxUInt16Item( SID_STYLE_FAMILY, pImp->m_nFamily ) );
+                rSet.Put( SfxUInt16Item( SID_STYLE_FAMILY, pImpl->m_nFamily ) );
                 break;
             }
         }
@@ -808,7 +808,7 @@ SfxInPlaceClient* SfxViewShell::FindIPClient
     vcl::Window*             pObjParentWin
 )   const
 {
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return nullptr;
 
@@ -833,7 +833,7 @@ SfxInPlaceClient* SfxViewShell::GetIPClient() const
 SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const
 {
     // this method is needed as long as SFX still manages the border space for ChildWindows (see SfxFrame::Resize)
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return nullptr;
 
@@ -848,7 +848,7 @@ SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const
 
 SfxInPlaceClient* SfxViewShell::GetUIActiveClient() const
 {
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return nullptr;
 
@@ -1014,9 +1014,9 @@ void SfxViewShell::InvalidateBorder()
     DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
 
     GetViewFrame()->InvalidateBorderImpl( this );
-    if (pImp->m_pController.is())
+    if (pImpl->m_pController.is())
     {
-        pImp->m_pController->BorderWidthsChanged_Impl();
+        pImpl->m_pController->BorderWidthsChanged_Impl();
     }
 }
 
@@ -1028,9 +1028,9 @@ void SfxViewShell::SetBorderPixel( const SvBorder &rBorder )
     GetViewFrame()->SetBorderPixelImpl( this, rBorder );
 
     // notify related controller that border size is changed
-    if (pImp->m_pController.is())
+    if (pImpl->m_pController.is())
     {
-        pImp->m_pController->BorderWidthsChanged_Impl();
+        pImpl->m_pController->BorderWidthsChanged_Impl();
     }
 }
 
@@ -1092,7 +1092,7 @@ SfxViewShell::SfxViewShell
 )
 
 :   SfxShell(this)
-,   pImp( new SfxViewShell_Impl(nFlags) )
+,   pImpl( new SfxViewShell_Impl(nFlags) )
 ,   pFrame(pViewFrame)
 ,   pSubShell(nullptr)
 ,   pWindow(nullptr)
@@ -1120,19 +1120,17 @@ SfxViewShell::~SfxViewShell()
     SfxViewShellArr_Impl::iterator it = std::find( rViewArr.begin(), rViewArr.end(), pThis );
     rViewArr.erase( it );
 
-    if ( pImp->xClipboardListener.is() )
+    if ( pImpl->xClipboardListener.is() )
     {
-        pImp->xClipboardListener->DisconnectViewShell();
-        pImp->xClipboardListener = nullptr;
+        pImpl->xClipboardListener->DisconnectViewShell();
+        pImpl->xClipboardListener = nullptr;
     }
 
-    if (pImp->m_pController.is())
+    if (pImpl->m_pController.is())
     {
-        pImp->m_pController->ReleaseShell_Impl();
-        pImp->m_pController.clear();
+        pImpl->m_pController->ReleaseShell_Impl();
+        pImpl->m_pController.clear();
     }
-
-    DELETEZ( pImp );
 }
 
 bool SfxViewShell::PrepareClose
@@ -1245,7 +1243,7 @@ bool SfxViewShell::HasSelection( bool ) const
 
 void SfxViewShell::AddSubShell( SfxShell& rShell )
 {
-    pImp->aArr.push_back(&rShell);
+    pImpl->aArr.push_back(&rShell);
     SfxDispatcher *pDisp = pFrame->GetDispatcher();
     if ( pDisp->IsActive(*this) )
     {
@@ -1259,21 +1257,21 @@ void SfxViewShell::RemoveSubShell( SfxShell* pShell )
     SfxDispatcher *pDisp = pFrame->GetDispatcher();
     if ( !pShell )
     {
-        size_t nCount = pImp->aArr.size();
+        size_t nCount = pImpl->aArr.size();
         if ( pDisp->IsActive(*this) )
         {
             for(size_t n = nCount; n > 0; --n)
-                pDisp->Pop(*pImp->aArr[n - 1]);
+                pDisp->Pop(*pImpl->aArr[n - 1]);
             pDisp->Flush();
         }
-        pImp->aArr.clear();
+        pImpl->aArr.clear();
     }
     else
     {
-        SfxShellArr_Impl::iterator i = std::find(pImp->aArr.begin(), pImp->aArr.end(), pShell);
-        if(i != pImp->aArr.end())
+        SfxShellArr_Impl::iterator i = std::find(pImpl->aArr.begin(), pImpl->aArr.end(), pShell);
+        if(i != pImpl->aArr.end())
         {
-            pImp->aArr.erase(i);
+            pImpl->aArr.erase(i);
             if(pDisp->IsActive(*this))
             {
                 pDisp->RemoveShell_Impl(*pShell);
@@ -1285,9 +1283,9 @@ void SfxViewShell::RemoveSubShell( SfxShell* pShell )
 
 SfxShell* SfxViewShell::GetSubShell( sal_uInt16 nNo )
 {
-    sal_uInt16 nCount = pImp->aArr.size();
+    sal_uInt16 nCount = pImpl->aArr.size();
     if(nNo < nCount)
-        return pImp->aArr[nCount - nNo - 1];
+        return pImpl->aArr[nCount - nNo - 1];
     return nullptr;
 }
 
@@ -1296,12 +1294,12 @@ void SfxViewShell::PushSubShells_Impl( bool bPush )
     SfxDispatcher *pDisp = pFrame->GetDispatcher();
     if ( bPush )
     {
-        for(SfxShellArr_Impl::const_iterator i = pImp->aArr.begin(); i != pImp->aArr.end(); ++i)
+        for(SfxShellArr_Impl::const_iterator i = pImpl->aArr.begin(); i != pImpl->aArr.end(); ++i)
             pDisp->Push(**i);
     }
-    else if(!pImp->aArr.empty())
+    else if(!pImpl->aArr.empty())
     {
-        SfxShell& rPopUntil = *pImp->aArr[0];
+        SfxShell& rPopUntil = *pImpl->aArr[0];
         if ( pDisp->GetShellLevel( rPopUntil ) != USHRT_MAX )
             pDisp->Pop( rPopUntil, SfxDispatcherPopFlags::POP_UNTIL );
     }
@@ -1425,7 +1423,7 @@ void SfxViewShell::Notify( SfxBroadcaster& rBC,
                             const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pSet, SID_VIEW_DATA, false);
                             if ( pItem )
                             {
-                                pImp->m_pController->restoreViewData( pItem->GetValue() );
+                                pImpl->m_pController->restoreViewData( pItem->GetValue() );
                                 pSet->ClearItem( SID_VIEW_DATA );
                             }
 
@@ -1442,26 +1440,26 @@ void SfxViewShell::Notify( SfxBroadcaster& rBC,
 
 bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
 {
-    if (!pImp->m_xAccExec.get())
+    if (!pImpl->m_xAccExec.get())
     {
-        pImp->m_xAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper();
-        pImp->m_xAccExec->init(::comphelper::getProcessComponentContext(),
+        pImpl->m_xAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper();
+        pImpl->m_xAccExec->init(::comphelper::getProcessComponentContext(),
             pFrame->GetFrame().GetFrameInterface());
     }
 
-    return pImp->m_xAccExec->execute(aKey.GetKeyCode());
+    return pImpl->m_xAccExec->execute(aKey.GetKeyCode());
 }
 
 void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pData)
 {
-    pImp->m_pLibreOfficeKitViewCallback = pCallback;
-    pImp->m_pLibreOfficeKitViewData = pData;
+    pImpl->m_pLibreOfficeKitViewCallback = pCallback;
+    pImpl->m_pLibreOfficeKitViewData = pData;
 }
 
 void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) const
 {
-    if (pImp->m_pLibreOfficeKitViewCallback)
-        pImp->m_pLibreOfficeKitViewCallback(nType, pPayload, pImp->m_pLibreOfficeKitViewData);
+    if (pImpl->m_pLibreOfficeKitViewCallback)
+        pImpl->m_pLibreOfficeKitViewCallback(nType, pPayload, pImpl->m_pLibreOfficeKitViewData);
 }
 
 bool SfxViewShell::KeyInput( const KeyEvent &rKeyEvent )
@@ -1511,7 +1509,7 @@ void SfxViewShell::ShowCursor( bool /*bOn*/ )
 void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient *pIP )
 {
 
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return;
 
@@ -1525,7 +1523,7 @@ void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient *pIP )
 
 void SfxViewShell::DisconnectAllClients()
 {
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return;
 
@@ -1542,7 +1540,7 @@ void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const
 
 void SfxViewShell::VisAreaChanged(const Rectangle& /*rVisArea*/)
 {
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return;
 
@@ -1597,7 +1595,7 @@ void SfxViewShell::DiscardClients_Impl()
 */
 
 {
-    SfxInPlaceClientList *pClients = pImp->GetIPClientList_Impl(false);
+    SfxInPlaceClientList *pClients = pImpl->GetIPClientList_Impl(false);
     if ( !pClients )
         return;
 
@@ -1634,7 +1632,7 @@ void SfxViewShell::SetCurrentDocument() const
 
 const Size& SfxViewShell::GetMargin() const
 {
-    return pImp->aMargin;
+    return pImpl->aMargin;
 }
 
 
@@ -1647,9 +1645,9 @@ void SfxViewShell::SetMargin( const Size& rSize )
     if ( aMargin.Height() == -1 )
         aMargin.Height() = DEFAULT_MARGIN_HEIGHT;
 
-    if ( aMargin != pImp->aMargin )
+    if ( aMargin != pImpl->aMargin )
     {
-        pImp->aMargin = aMargin;
+        pImpl->aMargin = aMargin;
         MarginChanged();
     }
 }
@@ -1660,7 +1658,7 @@ void SfxViewShell::MarginChanged()
 
 bool SfxViewShell::IsShowView_Impl() const
 {
-    return pImp->m_bIsShowView;
+    return pImpl->m_bIsShowView;
 }
 
 void SfxViewShell::JumpToMark( const OUString& rMark )
@@ -1674,34 +1672,34 @@ void SfxViewShell::JumpToMark( const OUString& rMark )
 
 void SfxViewShell::SetController( SfxBaseController* pController )
 {
-    pImp->m_pController = pController;
-    pImp->m_bControllerSet = true;
+    pImpl->m_pController = pController;
+    pImpl->m_bControllerSet = true;
 
     // there should be no old listener, but if there is one, it should be disconnected
-    if (  pImp->xClipboardListener.is() )
-        pImp->xClipboardListener->DisconnectViewShell();
+    if (  pImpl->xClipboardListener.is() )
+        pImpl->xClipboardListener->DisconnectViewShell();
 
-    pImp->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() );
+    pImpl->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() );
 }
 
 Reference < XController > SfxViewShell::GetController()
 {
-    return pImp->m_pController.get();
+    return pImpl->m_pController.get();
 }
 
 SfxBaseController* SfxViewShell::GetBaseController_Impl() const
 {
-    return pImp->m_pController.get();
+    return pImpl->m_pController.get();
 }
 
 void SfxViewShell::AddContextMenuInterceptor_Impl( const uno::Reference< ui::XContextMenuInterceptor >& xInterceptor )
 {
-    pImp->aInterceptorContainer.addInterface( xInterceptor );
+    pImpl->aInterceptorContainer.addInterface( xInterceptor );
 }
 
 void SfxViewShell::RemoveContextMenuInterceptor_Impl( const uno::Reference< ui::XContextMenuInterceptor >& xInterceptor )
 {
-    pImp->aInterceptorContainer.removeInterface( xInterceptor );
+    pImpl->aInterceptorContainer.removeInterface( xInterceptor );
 }
 
 void Change( Menu* pMenu, SfxViewShell* pView )
@@ -1756,7 +1754,7 @@ bool SfxViewShell::TryContextMenuInterception( Menu& rIn, const OUString& rMenuI
     aEvent.Selection.set( GetController(), uno::UNO_QUERY );
 
     // call interceptors
-    ::comphelper::OInterfaceIteratorHelper2 aIt( pImp->aInterceptorContainer );
+    ::comphelper::OInterfaceIteratorHelper2 aIt( pImpl->aInterceptorContainer );
     while( aIt.hasMoreElements() )
     {
         try
@@ -1818,7 +1816,7 @@ bool SfxViewShell::TryContextMenuInterception( Menu& rMenu, const OUString& rMen
     aEvent.Selection = css::uno::Reference< css::view::XSelectionSupplier >( GetController(), css::uno::UNO_QUERY );
 
     // call interceptors
-    ::comphelper::OInterfaceIteratorHelper2 aIt( pImp->aInterceptorContainer );
+    ::comphelper::OInterfaceIteratorHelper2 aIt( pImpl->aInterceptorContainer );
     while( aIt.hasMoreElements() )
     {
         try
@@ -1870,33 +1868,33 @@ void SfxViewShell::TakeOwnership_Impl()
 {
     // currently there is only one reason to take Ownership: a hidden frame is printed
     // so the ViewShell will check this on EndPrint (->prnmon.cxx)
-    pImp->m_bGotOwnership = true;
+    pImpl->m_bGotOwnership = true;
 }
 
 void SfxViewShell::TakeFrameOwnership_Impl()
 {
     // currently there is only one reason to take Ownership: a hidden frame is printed
     // so the ViewShell will check this on EndPrint (->prnmon.cxx)
-    pImp->m_bGotFrameOwnership = true;
+    pImpl->m_bGotFrameOwnership = true;
 }
 
 bool SfxViewShell::HandleNotifyEvent_Impl( NotifyEvent& rEvent )
 {
-    if (pImp->m_pController.is())
-        return pImp->m_pController->HandleEvent_Impl( rEvent );
+    if (pImpl->m_pController.is())
+        return pImpl->m_pController->HandleEvent_Impl( rEvent );
     return false;
 }
 
 bool SfxViewShell::HasKeyListeners_Impl()
 {
-    return (pImp->m_pController.is())
-        && pImp->m_pController->HasKeyListeners_Impl();
+    return (pImpl->m_pController.is())
+        && pImpl->m_pController->HasKeyListeners_Impl();
 }
 
 bool SfxViewShell::HasMouseClickListeners_Impl()
 {
-    return (pImp->m_pController.is())
-        && pImp->m_pController->HasMouseClickListeners_Impl();
+    return (pImpl->m_pController.is())
+        && pImpl->m_pController->HasMouseClickListeners_Impl();
 }
 
 bool SfxViewShell::Escape()


More information about the Libreoffice-commits mailing list