diff options
Diffstat (limited to 'sw/source/ui/fmtui/tmpdlg.cxx')
-rw-r--r-- | sw/source/ui/fmtui/tmpdlg.cxx | 203 |
1 files changed, 197 insertions, 6 deletions
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx index 9cdba0b23534..9e7f661872f1 100644 --- a/sw/source/ui/fmtui/tmpdlg.cxx +++ b/sw/source/ui/fmtui/tmpdlg.cxx @@ -107,7 +107,7 @@ SwTemplateDlg::SwTemplateDlg(vcl::Window* pParent, { nHtmlMode = ::GetHtmlMode(pWrtShell->GetView().GetDocShell()); SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - // tinker TabPages together + // stitch TabPages together switch( nRegion ) { // character styles @@ -253,11 +253,6 @@ SwTemplateDlg::SwTemplateDlg(vcl::Window* pParent, // page styles case SfxStyleFamily::Page: { - // remove? - //OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!"); - //OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!"); - //m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) ); - // add Area and Transparence TabPages m_nAreaId = AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA )); m_nTransparenceId = AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) ); @@ -595,4 +590,200 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) } } +// the dialog's carrier +SwTemplateDlgController::SwTemplateDlgController(weld::Window* pParent, + SfxStyleSheetBase& rBase, + SfxStyleFamily nRegion, + const OString& sPage, + SwWrtShell* pActShell, + bool /*bNew*/) + : SfxStyleDialogController(pParent, + "modules/swriter/ui/templatedialog" + + OUString::number(static_cast<sal_uInt16>(nRegion)) + ".ui", + "TemplateDialog" + OString::number(static_cast<sal_uInt16>(nRegion)), + rBase) + , nType(nRegion) + , pWrtShell(pActShell) +{ + nHtmlMode = ::GetHtmlMode(pWrtShell->GetView().GetDocShell()); + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + // stitch TabPages together + switch( nRegion ) + { + // page styles + case SfxStyleFamily::Page: + { + // add Area and Transparence TabPages + AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA )); + AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) ); + AddTabPage("header", SvxHeaderPage::Create, SvxHeaderPage::GetRanges); + AddTabPage("footer", SvxFooterPage::Create, SvxFooterPage::GetRanges); + AddTabPage("page", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PAGE), pFact->GetTabPageRangesFunc(RID_SVXPAGE_PAGE)); + if (0 == ::GetHtmlMode(pWrtShell->GetView().GetDocShell())) + { + AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) ); + AddTabPage("columns", SwColumnPage::Create, SwColumnPage::GetRanges ); + AddTabPage("footnotes", SwFootNotePage::Create, SwFootNotePage::GetRanges ); + AddTabPage("textgrid", SwTextGridPage::Create, SwTextGridPage::GetRanges ); + SvtCJKOptions aCJKOptions; + if(!aCJKOptions.IsAsianTypographyEnabled()) + RemoveTabPage("textgrid"); + } + else + { + RemoveTabPage("borders"); + RemoveTabPage("columns"); + RemoveTabPage("footnotes"); + RemoveTabPage("textgrid"); + } + } + break; + default: + OSL_ENSURE(false, "wrong family"); + } + + if (!sPage.isEmpty()) + SetCurPageId(sPage); +} + +short SwTemplateDlgController::Ok() +{ + short nRet = SfxTabDialogController::Ok(); + if( RET_OK == nRet ) + { + const SfxPoolItem *pOutItem, *pExItem; + if( SfxItemState::SET == m_xExampleSet->GetItemState( + SID_ATTR_NUMBERING_RULE, false, &pExItem ) && + ( !GetOutputItemSet() || + SfxItemState::SET != GetOutputItemSet()->GetItemState( + SID_ATTR_NUMBERING_RULE, false, &pOutItem ) || + *pExItem != *pOutItem )) + { + if( GetOutputItemSet() ) + const_cast<SfxItemSet*>(GetOutputItemSet())->Put( *pExItem ); + else + nRet = RET_CANCEL; + } + } + else + { + //JP 09.01.98 Bug #46446#: + // that's the Ok-Handler, so OK has to be default! + nRet = RET_OK; + } + return nRet; +} + +void SwTemplateDlgController::RefreshInputSet() +{ + SfxItemSet* pInSet = GetInputSetImpl(); + pInSet->ClearItem(); + pInSet->SetParent( &GetStyleSheet().GetItemSet() ); +} + +void SwTemplateDlgController::PageCreated(const OString& rId, SfxTabPage &rPage ) +{ + // set style's and metric's names + OUString sNumCharFormat, sBulletCharFormat; + SwStyleNameMapper::FillUIName( RES_POOLCHR_NUM_LEVEL, sNumCharFormat); + SwStyleNameMapper::FillUIName( RES_POOLCHR_BUL_LEVEL, sBulletCharFormat); + SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); + + if (rId == "columns") + { + if( nType == SfxStyleFamily::Frame ) + static_cast<SwColumnPage&>(rPage).SetFrameMode(true); + static_cast<SwColumnPage&>(rPage).SetFormatUsed( true ); + } + // do not remove; many other style dialog combinations still use the SfxTabPage + // for the SvxBrushItem (see RID_SVXPAGE_BACKGROUND) + else if (rId == "background") + { + SvxBackgroundTabFlags nFlagType = SvxBackgroundTabFlags::NONE; + if( SfxStyleFamily::Char == nType || SfxStyleFamily::Para == nType ) + nFlagType |= SvxBackgroundTabFlags::SHOW_HIGHLIGHTING; + aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(nFlagType))); + rPage.PageCreated(aSet); + } + else if (rId == "page") + { + if(0 == (nHtmlMode & HTMLMODE_ON )) + { + std::vector<OUString> aList; + OUString aNew; + SwStyleNameMapper::FillUIName( RES_POOLCOLL_TEXT, aNew ); + aList.push_back( aNew ); + if( pWrtShell ) + { + SfxStyleSheetBasePool* pStyleSheetPool = pWrtShell-> + GetView().GetDocShell()->GetStyleSheetPool(); + pStyleSheetPool->SetSearchMask(SfxStyleFamily::Para); + SfxStyleSheetBase *pFirstStyle = pStyleSheetPool->First(); + while(pFirstStyle) + { + aList.push_back( pFirstStyle->GetName() ); + pFirstStyle = pStyleSheetPool->Next(); + } + } + // set DrawingLayer FillStyles active + aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true)); + aSet.Put(SfxStringListItem(SID_COLLECT_LIST, &aList)); + rPage.PageCreated(aSet); + } + } + else if (rId == "header") + { + if(0 == (nHtmlMode & HTMLMODE_ON )) + { + static_cast<SvxHeaderPage&>(rPage).EnableDynamicSpacing(); + } + + // set DrawingLayer FillStyles active + aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true)); + rPage.PageCreated(aSet); + } + else if (rId == "footer") + { + if(0 == (nHtmlMode & HTMLMODE_ON )) + { + static_cast<SvxFooterPage&>(rPage).EnableDynamicSpacing(); + } + + // set DrawingLayer FillStyles active + aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true)); + rPage.PageCreated(aSet); + } + else if (rId == "border") + { + if( SfxStyleFamily::Para == nType ) + { + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA))); + } + else if( SfxStyleFamily::Frame == nType ) + { + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::FRAME))); + } + rPage.PageCreated(aSet); + } + // inits for Area and Transparency TabPages + // The selection attribute lists (XPropertyList derivates, e.g. XColorList for + // the color table) need to be added as items (e.g. SvxColorTableItem) to make + // these pages find the needed attributes for fill style suggestions. + // These are added in SwDocStyleSheet::GetItemSet() for the SfxStyleFamily::Para on + // demand, but could also be directly added from the DrawModel. + else if (rId == "area") + { + aSet.Put(GetStyleSheet().GetItemSet()); + + // add flag for direct graphic content selection + aSet.Put(SfxBoolItem(SID_OFFER_IMPORT, true)); + + rPage.PageCreated(aSet); + } + else if (rId == "transparence") + { + rPage.PageCreated(GetStyleSheet().GetItemSet()); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |