[Libreoffice-commits] .: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 2 08:39:43 PDT 2012


 sw/source/ui/frmdlg/frmpage.cxx |   18 +++++++++++-------
 sw/source/ui/inc/frmpage.hxx    |    2 ++
 2 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit c59769ec7a4f9af1086f534ae92a4f2ccd653122
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 2 16:38:21 2012 +0100

    GetParent()->GetParent() does't take into account containers
    
    The assumption was that the page is directly a child of the parent
    dialog => ka-boom
    
    Change-Id: Ia0e7f33273d7a3c6b726c74371b8ee8a809ee5bb

diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index b05b030..8396539 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -775,11 +775,15 @@ void SwFrmPage::EnableGraficMode( void )
     }
 }
 
-void SwFrmPage::Reset( const SfxItemSet &rSet )
+SwWrtShell *SwFrmPage::getFrmDlgParentShell()
 {
+    return ((SwFrmDlg*)GetParentDialog())->GetWrtShell();
+}
 
+void SwFrmPage::Reset( const SfxItemSet &rSet )
+{
     SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell() :
-            ((SwFrmDlg*)GetParent()->GetParent())->GetWrtShell();
+            getFrmDlgParentShell();
 
     nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
     bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
@@ -951,7 +955,7 @@ sal_Bool SwFrmPage::FillItemSet(SfxItemSet &rSet)
 {
     sal_Bool bRet = sal_False;
     SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
-                        : ((SwFrmDlg*)GetParent()->GetParent())->GetWrtShell();
+                        : getFrmDlgParentShell();
     OSL_ENSURE( pSh , "shell not found");
     const SfxItemSet& rOldSet = GetItemSet();
     const SfxPoolItem* pOldItem = 0;
@@ -1619,7 +1623,7 @@ int SwFrmPage::DeactivatePage(SfxItemSet * _pSet)
         //FillItemSet doesn't set the anchor into the set when it matches
         //the original. But for the other pages we need the current anchor.
         SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
-                            : ((SwFrmDlg*)GetParent()->GetParent())->GetWrtShell();
+                            : getFrmDlgParentShell();
         RndStdIds eAnchorId = (RndStdIds)GetAnchor();
         SwFmtAnchor aAnc( eAnchorId, pSh->GetPhyPageNum() );
         _pSet->Put( aAnc );
@@ -1674,7 +1678,7 @@ IMPL_LINK_NOARG(SwFrmPage, RangeModifyHdl)
         return 0;
 
     SwWrtShell* pSh = bFormat ? ::GetActiveWrtShell()
-                        :((SwFrmDlg*)GetParent()->GetParent())->GetWrtShell();
+                        : getFrmDlgParentShell();
     OSL_ENSURE(pSh , "shell not found");
     SwFlyFrmAttrMgr aMgr( bNew, pSh, (const SwAttrSet&)GetItemSet() );
     SvxSwFrameValidation        aVal;
@@ -2045,7 +2049,7 @@ void SwFrmPage::Init(const SfxItemSet& rSet, sal_Bool bReset)
 {
     if(!bFormat)
     {
-        SwWrtShell* pSh = ((SwFrmDlg*)GetParent()->GetParent())->GetWrtShell();
+        SwWrtShell* pSh = getFrmDlgParentShell();
 
         // size
         const sal_Bool bSizeFixed = pSh->IsSelObjProtected( FLYPROTECT_FIXED );
@@ -2140,7 +2144,7 @@ void SwFrmPage::Init(const SfxItemSet& rSet, sal_Bool bReset)
 
         if ( !bFormat )
         {
-            SwWrtShell* pSh = ((SwFrmDlg*)GetParent()->GetParent())->GetWrtShell();
+            SwWrtShell* pSh = getFrmDlgParentShell();
             const SwFrmFmt* pFmt = pSh->GetFlyFrmFmt();
             if( pFmt && pFmt->GetChain().GetNext() )
                 aAutoHeightCB.Enable( sal_False );
diff --git a/sw/source/ui/inc/frmpage.hxx b/sw/source/ui/inc/frmpage.hxx
index 94453ce..1e31ccb 100644
--- a/sw/source/ui/inc/frmpage.hxx
+++ b/sw/source/ui/inc/frmpage.hxx
@@ -184,6 +184,8 @@ class SwFrmPage: public SfxTabPage
     SwFrmPage(Window *pParent, const SfxItemSet &rSet);
     ~SwFrmPage();
 
+    SwWrtShell *getFrmDlgParentShell();
+
     using SfxTabPage::ActivatePage;
     using SfxTabPage::DeactivatePage;
 


More information about the Libreoffice-commits mailing list