summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-12-13 10:12:13 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-12-14 12:48:39 +0000
commitcafa391c032dbba6869bbf56132025240c34c123 (patch)
treef36ac5d46c1fc32d838719551d0c98973ac0c8a9
parentb67866895a8d836ce2af1caa4fdeff283a9bb621 (diff)
Related: fdo#38606 keep style dialog open when apply is clicked
i.e. don't close and reopen, just stay open Change-Id: I11cdc492e3c4adfb75c9a0dfa52e5ba351914858
-rw-r--r--sfx2/inc/sfx2/sfxdlg.hxx20
-rw-r--r--sfx2/inc/sfx2/tabdlg.hxx8
-rw-r--r--sw/inc/swabstdlg.hxx2
-rw-r--r--sw/source/ui/app/docst.cxx202
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx30
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx19
-rw-r--r--sw/source/ui/fmtui/tmpdlg.cxx12
-rw-r--r--sw/source/ui/inc/tmpdlg.hxx1
8 files changed, 175 insertions, 119 deletions
diff --git a/sfx2/inc/sfx2/sfxdlg.hxx b/sfx2/inc/sfx2/sfxdlg.hxx
index 3585645ddd91..0465dbbf002a 100644
--- a/sfx2/inc/sfx2/sfxdlg.hxx
+++ b/sfx2/inc/sfx2/sfxdlg.hxx
@@ -55,7 +55,7 @@ namespace com { namespace sun { namespace star { namespace frame {
class XModel;
} } } }
-class SfxAbstractDialog : public VclAbstractDialog
+class SfxAbstractDialog : virtual public VclAbstractDialog
{
public:
virtual const SfxItemSet* GetOutputItemSet() const = 0;
@@ -63,15 +63,21 @@ public:
virtual String GetText() const = 0;
};
-class SfxAbstractTabDialog : public SfxAbstractDialog
+class SfxAbstractTabDialog : virtual public SfxAbstractDialog
{
public:
virtual void SetCurPageId( sal_uInt16 nId ) = 0;
- virtual const sal_uInt16* GetInputRanges( const SfxItemPool& ) = 0;
+ virtual const sal_uInt16* GetInputRanges( const SfxItemPool& ) = 0;
virtual void SetInputSet( const SfxItemSet* pInSet ) = 0;
};
-class SfxAbstractInsertObjectDialog : public VclAbstractDialog
+class SfxAbstractApplyTabDialog : virtual public SfxAbstractTabDialog
+{
+public:
+ virtual void SetApplyHdl( const Link& rLink ) = 0;
+};
+
+class SfxAbstractInsertObjectDialog : virtual public VclAbstractDialog
{
public:
virtual com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > GetObject()=0;
@@ -79,7 +85,7 @@ public:
virtual sal_Bool IsCreateNew()=0;
};
-class SfxAbstractPasteDialog : public VclAbstractDialog
+class SfxAbstractPasteDialog : virtual public VclAbstractDialog
{
public:
virtual void Insert( SotFormatStringId nFormat, const String & rFormatName ) = 0;
@@ -89,11 +95,11 @@ public:
const TransferableObjectDescriptor* pDesc=0 ) = 0;
};
-class SfxAbstractLinksDialog : public VclAbstractDialog
+class SfxAbstractLinksDialog : virtual public VclAbstractDialog
{
};
-class AbstractScriptSelectorDialog : public VclAbstractDialog
+class AbstractScriptSelectorDialog : virtual public VclAbstractDialog
{
public:
virtual String GetScriptURL() const = 0;
diff --git a/sfx2/inc/sfx2/tabdlg.hxx b/sfx2/inc/sfx2/tabdlg.hxx
index c3e010a86c62..164dae330514 100644
--- a/sfx2/inc/sfx2/tabdlg.hxx
+++ b/sfx2/inc/sfx2/tabdlg.hxx
@@ -201,7 +201,13 @@ public:
void SetApplyHandler(const Link& _rHdl);
SAL_DLLPRIVATE void Start_Impl();
- SAL_DLLPRIVATE sal_Bool OK_Impl() { return PrepareLeaveCurrentPage(); }
+ bool OK_Impl()
+ {
+ bool bRet = PrepareLeaveCurrentPage();
+ if (bRet)
+ Ok();
+ return bRet;
+ }
};
namespace sfx { class ItemConnectionBase; }
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 5355b97fb100..c0e1bc82825c 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -416,7 +416,7 @@ public:
sal_Bool bFmt = sal_False,
sal_uInt16 nDefPage = 0,
const String* pFmtStr = 0) = 0; //add for SwFrmDlg
- virtual SfxAbstractTabDialog* CreateTemplateDialog( int nResId,
+ virtual SfxAbstractApplyTabDialog* CreateTemplateDialog(
Window* pParent,
SfxStyleSheetBase& rBase,
sal_uInt16 nRegion,
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx
index 3685eb107ead..ad8c702a94cd 100644
--- a/sw/source/ui/app/docst.cxx
+++ b/sw/source/ui/app/docst.cxx
@@ -497,6 +497,118 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
}
+class ApplyStyle
+{
+public:
+ ApplyStyle(SwDocShell &rDocSh, bool bNew, SfxStyleSheetBase* pStyle,
+ sal_uInt16 nRet, rtl::Reference< SwDocStyleSheet > xTmp,
+ sal_uInt16 nFamily, SfxAbstractApplyTabDialog *pDlg,
+ rtl::Reference< SfxStyleSheetBasePool > xBasePool,
+ bool bModified)
+ : m_rDocSh(rDocSh)
+ , m_bNew(bNew)
+ , m_pStyle(pStyle)
+ , m_nRet(nRet)
+ , m_xTmp(xTmp)
+ , m_nFamily(nFamily)
+ , m_pDlg(pDlg)
+ , m_xBasePool(xBasePool)
+ , m_bModified(bModified)
+ {
+ }
+ DECL_LINK( ApplyHdl, void* );
+ void apply()
+ {
+ ApplyHdl(NULL);
+ }
+ sal_uInt16 getRet() const { return m_nRet; }
+private:
+ SwDocShell &m_rDocSh;
+ bool m_bNew;
+ SfxStyleSheetBase* m_pStyle;
+ sal_uInt16 m_nRet;
+ rtl::Reference< SwDocStyleSheet > m_xTmp;
+ sal_uInt16 m_nFamily;
+ SfxAbstractApplyTabDialog *m_pDlg;
+ rtl::Reference< SfxStyleSheetBasePool > m_xBasePool;
+ bool m_bModified;
+};
+
+IMPL_LINK_NOARG(ApplyStyle, ApplyHdl)
+{
+ SwWrtShell* pWrtShell = m_rDocSh.GetWrtShell();
+ SwDoc* pDoc = m_rDocSh.GetDoc();
+ SwView* pView = m_rDocSh.GetView();
+
+ pWrtShell->StartAllAction();
+
+ // newly set the mask only with paragraph-templates
+ if( m_bNew )
+ {
+ m_nRet = SFX_STYLE_FAMILY_PARA == m_pStyle->GetFamily()
+ ? m_xTmp->GetMask()
+ : SFXSTYLEBIT_USERDEF;
+ }
+ else if( m_pStyle->GetMask() != m_xTmp->GetMask() )
+ m_nRet = m_xTmp->GetMask();
+
+ if( SFX_STYLE_FAMILY_PARA == m_nFamily )
+ {
+ SfxItemSet aSet( *m_pDlg->GetOutputItemSet() );
+ ::SfxToSwPageDescAttr( *pWrtShell, aSet );
+ // reset indent attributes at paragraph style, if a list style
+ // will be applied and no indent attributes will be applied.
+ m_xTmp->SetItemSet( aSet, true );
+ }
+ else
+ {
+ if(SFX_STYLE_FAMILY_PAGE == m_nFamily)
+ {
+ static const sal_uInt16 aInval[] = {
+ SID_IMAGE_ORIENTATION,
+ SID_ATTR_CHAR_FONT,
+ FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0};
+ pView->GetViewFrame()->GetBindings().Invalidate(aInval);
+ }
+ SfxItemSet aTmpSet( *m_pDlg->GetOutputItemSet() );
+ if( SFX_STYLE_FAMILY_CHAR == m_nFamily )
+ {
+ const SfxPoolItem *pTmpBrush;
+ if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
+ sal_False, &pTmpBrush ) )
+ {
+ SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
+ aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
+ aTmpSet.Put( aTmpBrush );
+ }
+ aTmpSet.ClearItem( RES_BACKGROUND );
+ }
+ m_xTmp->SetItemSet( aTmpSet );
+
+ if( SFX_STYLE_FAMILY_PAGE == m_nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
+ {
+ const SfxPoolItem *pItem = NULL;
+ if( aTmpSet.GetItemState( m_rDocSh.GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ) , sal_True, &pItem ) == SFX_ITEM_SET )
+ SwChartHelper::DoUpdateAllCharts( pDoc );
+ }
+ }
+ if(SFX_STYLE_FAMILY_PAGE == m_nFamily)
+ pView->InvalidateRulerPos();
+
+ if( m_bNew )
+ m_xBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *m_xTmp.get() ) );
+
+ pDoc->SetModified();
+ if( !m_bModified ) // Bug 57028
+ {
+ pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+ }
+
+ pWrtShell->EndAllAction();
+
+ return m_nRet;
+}
+
/*--------------------------------------------------------------------
Description: Edit
--------------------------------------------------------------------*/
@@ -654,86 +766,16 @@ sal_uInt16 SwDocShell::Edit( const String &rName, const String &rParent, sal_uIn
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateTemplateDialog( DLG_TEMPLATE_BASE,
+ SfxAbstractApplyTabDialog* pDlg = pFact->CreateTemplateDialog(
0, *(xTmp.get()), nFamily, nPageId,
pActShell ? pActShell : pWrtShell, bNew);
OSL_ENSURE(pDlg, "Dialogdiet fail!");
- while (true)
- {
- short nButton = pDlg->Execute();
- if(RET_OK == nButton || RET_APPLY_TEMPLATE == nButton)
- {
- GetWrtShell()->StartAllAction();
-
- // newly set the mask only with paragraph-templates
- if( bNew )
- {
- nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily()
- ? xTmp->GetMask()
- : SFXSTYLEBIT_USERDEF;
- }
- else if( pStyle->GetMask() != xTmp->GetMask() )
- nRet = xTmp->GetMask();
-
- if( SFX_STYLE_FAMILY_PARA == nFamily )
- {
- SfxItemSet aSet( *pDlg->GetOutputItemSet() );
- ::SfxToSwPageDescAttr( *GetWrtShell(), aSet );
- // reset indent attributes at paragraph style, if a list style
- // will be applied and no indent attributes will be applied.
- xTmp->SetItemSet( aSet, true );
- }
- else
- {
- if(SFX_STYLE_FAMILY_PAGE == nFamily)
- {
- static const sal_uInt16 aInval[] = {
- SID_IMAGE_ORIENTATION,
- SID_ATTR_CHAR_FONT,
- FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0};
- pView->GetViewFrame()->GetBindings().Invalidate(aInval);
- }
- SfxItemSet aTmpSet( *pDlg->GetOutputItemSet() );
- if( SFX_STYLE_FAMILY_CHAR == nFamily )
- {
- const SfxPoolItem *pTmpBrush;
- if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND,
- sal_False, &pTmpBrush ) )
- {
- SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
- aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
- aTmpSet.Put( aTmpBrush );
- }
- aTmpSet.ClearItem( RES_BACKGROUND );
- }
- xTmp->SetItemSet( aTmpSet );
+ ApplyStyle aApplyStyleHelper(*this, bNew, pStyle, nRet, xTmp, nFamily, pDlg, mxBasePool, bModified);
+ pDlg->SetApplyHdl(LINK(&aApplyStyleHelper, ApplyStyle, ApplyHdl));
- if( SFX_STYLE_FAMILY_PAGE == nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
- {
- const SfxPoolItem *pItem = NULL;
- if( aTmpSet.GetItemState( GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ) , sal_True, &pItem ) == SFX_ITEM_SET )
- SwChartHelper::DoUpdateAllCharts( pDoc );
- }
- }
- if(SFX_STYLE_FAMILY_PAGE == nFamily)
- pView->InvalidateRulerPos();
-
- if( bNew )
- mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) );
-
- // Destroy dialog before EndAction - with page-templates the
- // ItemSet must be destroyed, so that the cursors get removed
- // from Headers/Footers. Otherwise "GPF" happen!!!
- if(RET_OK == nButton)
- delete pDlg;
-
- pDoc->SetModified();
- if( !bModified ) // Bug 57028
- {
- pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
- }
-
- GetWrtShell()->EndAllAction();
+ if (RET_OK == pDlg->Execute())
+ {
+ aApplyStyleHelper.apply();
}
else
{
@@ -745,11 +787,11 @@ sal_uInt16 SwDocShell::Edit( const String &rName, const String &rParent, sal_uIn
if( !bModified )
pDoc->ResetModified();
- delete pDlg;
- }
- if(RET_APPLY_TEMPLATE != nButton)
- break;
}
+
+ nRet = aApplyStyleHelper.getRet();
+
+ delete pDlg;
}
else
{
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 3028bba653a7..70beaa92e86d 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -157,6 +157,19 @@ String AbstractTabDialog_Impl::GetText() const
return pDlg->GetText();
}
+IMPL_LINK_NOARG(AbstractApplyTabDialog_Impl, ApplyHdl)
+{
+ if (pDlg->OK_Impl())
+ m_aHandler.Call(NULL);
+ return 0;
+}
+
+void AbstractApplyTabDialog_Impl::SetApplyHdl( const Link& rLink )
+{
+ m_aHandler = rLink;
+ pDlg->SetApplyHandler(LINK(this, AbstractApplyTabDialog_Impl, ApplyHdl));
+}
+
sal_uInt8 AbstractSwInsertAbstractDlg_Impl::GetLevel() const
{
return pDlg->GetLevel();
@@ -1103,7 +1116,7 @@ SfxAbstractTabDialog* SwAbstractDialogFactory_Impl::CreateFrmTabDialog( int nRes
return 0;
}
-SfxAbstractTabDialog* SwAbstractDialogFactory_Impl::CreateTemplateDialog( int nResId,
+SfxAbstractApplyTabDialog* SwAbstractDialogFactory_Impl::CreateTemplateDialog(
Window* pParent,
SfxStyleSheetBase& rBase,
sal_uInt16 nRegion,
@@ -1111,19 +1124,8 @@ SfxAbstractTabDialog* SwAbstractDialogFactory_Impl::CreateTemplateDialog( int nR
SwWrtShell* pActShell,
sal_Bool bNew ) //add for SwTemplateDlg
{
- SfxTabDialog* pDlg=NULL;
- switch ( nResId )
- {
- case DLG_TEMPLATE_BASE :
- pDlg = new SwTemplateDlg( pParent, rBase, nRegion, nPageId, pActShell, bNew );
- break;
- default:
- break;
- }
-
- if ( pDlg )
- return new AbstractTabDialog_Impl( pDlg );
- return 0;
+ SfxTabDialog* pDlg = new SwTemplateDlg( pParent, rBase, nRegion, nPageId, pActShell, bNew );
+ return new AbstractApplyTabDialog_Impl( pDlg );
}
AbstractGlossaryDlg* SwAbstractDialogFactory_Impl::CreateGlossaryDlg( int nResId,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 451d59515135..1e0091c911e4 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -46,6 +46,7 @@ class DropDownFieldDialog;
}
#define DECL_ABSTDLG_BASE(Class,DialogClass) \
+protected: \
DialogClass* pDlg; \
public: \
Class( DialogClass* p) \
@@ -53,7 +54,6 @@ public: \
{} \
virtual ~Class(); \
virtual short Execute() ;
-// virtual void Show( sal_Bool bVisible = sal_True, sal_uInt16 nFlags = 0 )
#define IMPL_ABSTDLG_BASE(Class) \
Class::~Class() \
@@ -129,7 +129,7 @@ class AbstractSplitTableDialog_Impl : public AbstractSplitTableDialog // add for
// add for SwBreakDlg end
//add for SwCharDlg , SwEnvDlg , SwFootNoteOptionDlg SwParaDlg SwTableTabDlg begin
-class AbstractTabDialog_Impl : public SfxAbstractTabDialog
+class AbstractTabDialog_Impl : virtual public SfxAbstractTabDialog
{
DECL_ABSTDLG_BASE( AbstractTabDialog_Impl,SfxTabDialog )
virtual void SetCurPageId( sal_uInt16 nId );
@@ -142,6 +142,19 @@ class AbstractTabDialog_Impl : public SfxAbstractTabDialog
};
//add for SwCharDlg, SwEnvDlg ,SwFootNoteOptionDlg SwParaDlg SwTableTabDlg end
+class AbstractApplyTabDialog_Impl : public AbstractTabDialog_Impl, virtual public SfxAbstractApplyTabDialog
+{
+public:
+ AbstractApplyTabDialog_Impl( SfxTabDialog* p)
+ : AbstractTabDialog_Impl(p)
+ {
+ }
+ DECL_LINK(ApplyHdl, void*);
+private:
+ Link m_aHandler;
+ virtual void SetApplyHdl( const Link& rLink );
+};
+
//add for SwConvertTableDlg begin
class AbstractSwConvertTableDlg_Impl : public AbstractSwConvertTableDlg // add for SwConvertTableDlg
{
@@ -484,7 +497,7 @@ public:
sal_Bool bFmt = sal_False,
sal_uInt16 nDefPage = 0,
const String* pFmtStr = 0); //add for SwFrmDlg
- virtual SfxAbstractTabDialog* CreateTemplateDialog( int nResId,
+ virtual SfxAbstractApplyTabDialog* CreateTemplateDialog(
Window* pParent,
SfxStyleSheetBase& rBase,
sal_uInt16 nRegion,
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 3fca711707d6..8003ed5f907d 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -293,24 +293,12 @@ SwTemplateDlg::SwTemplateDlg(Window* pParent,
}
EnableApplyButton( true );
- SetApplyHandler( LINK(this, SwTemplateDlg, ApplyHdl ) );
}
SwTemplateDlg::~SwTemplateDlg()
{
}
-IMPL_LINK( SwTemplateDlg, ApplyHdl, void*, pVoid )
-{
- (void)pVoid; //unused
- if ( OK_Impl() )
- {
- Ok();
- EndDialog( RET_APPLY_TEMPLATE );
- }
- return 0;
-}
-
short SwTemplateDlg::Ok()
{
short nRet = SfxTabDialog::Ok();
diff --git a/sw/source/ui/inc/tmpdlg.hxx b/sw/source/ui/inc/tmpdlg.hxx
index 3d9122037bff..c2ca989c15f6 100644
--- a/sw/source/ui/inc/tmpdlg.hxx
+++ b/sw/source/ui/inc/tmpdlg.hxx
@@ -36,7 +36,6 @@ class SwTemplateDlg: public SfxStyleDialog
sal_Bool bNewStyle;
DECL_LINK( NumOptionsHdl, PushButton* );
- DECL_LINK( ApplyHdl, void* );
public:
SwTemplateDlg( Window* pParent,