summaryrefslogtreecommitdiff
path: root/sw/source/ui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-08-30 09:43:59 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-09-07 14:42:31 +0200
commita2304f62e963b413b7575bedfb8d34e5f2d3ea58 (patch)
treee92b8fce9d381deb02a9823ca24cd20a272c08d0 /sw/source/ui
parent1a86f5643f3c36ead2f9aee42571664c2454ccf7 (diff)
weld writer page style dialog and SvxBorderBackgroundDlg
writer, format page is complete Change-Id: I09f6e4354461c4374cdb0d0e0754dfee35415b45 Reviewed-on: https://gerrit.libreoffice.org/60058 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui')
-rw-r--r--sw/source/ui/chrdlg/drpcps.cxx2
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx21
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx16
-rw-r--r--sw/source/ui/envelp/envlop1.cxx2
-rw-r--r--sw/source/ui/envelp/envprt.cxx2
-rw-r--r--sw/source/ui/envelp/labfmt.cxx4
-rw-r--r--sw/source/ui/fmtui/tmpdlg.cxx203
-rw-r--r--sw/source/ui/frmdlg/column.cxx2
-rw-r--r--sw/source/ui/misc/pggrid.cxx4
9 files changed, 241 insertions, 15 deletions
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index fafe26d3ca07..be094bddc51f 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -66,9 +66,9 @@ void SwDropCapsPict::SetText( const OUString& rT )
void SwDropCapsPict::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
Size aPrefSize(getParagraphPreviewOptimalSize(pDrawingArea->get_ref_device()));
pDrawingArea->set_size_request(aPrefSize.Width(), aPrefSize.Height());
- CustomWidgetController::SetDrawingArea(pDrawingArea);
}
void SwDropCapsPict::Resize()
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 413f886a78b4..971fd2a057bb 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -240,6 +240,11 @@ void AbstractTabController_Impl::SetInputSet( const SfxItemSet* pInSet )
m_xDlg->SetInputSet( pInSet );
}
+bool AbstractTabController_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+ return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
//From class Window.
void AbstractTabController_Impl::SetText( const OUString& rStr )
{
@@ -258,6 +263,18 @@ void AbstractApplyTabDialog_Impl::SetApplyHdl( const Link<LinkParamNone*,void>&
pDlg->SetApplyHandler(LINK(this, AbstractApplyTabDialog_Impl, ApplyHdl));
}
+IMPL_LINK_NOARG(AbstractApplyTabController_Impl, ApplyHdl, weld::Button&, void)
+{
+ if (m_xDlg->Apply())
+ m_aHandler.Call(nullptr);
+}
+
+void AbstractApplyTabController_Impl::SetApplyHdl( const Link<LinkParamNone*,void>& rLink )
+{
+ m_aHandler = rLink;
+ m_xDlg->SetApplyHandler(LINK(this, AbstractApplyTabController_Impl, ApplyHdl));
+}
+
sal_uInt8 AbstractSwInsertAbstractDlg_Impl::GetLevel() const
{
return pDlg->GetLevel();
@@ -930,6 +947,10 @@ VclPtr<SfxAbstractApplyTabDialog> SwAbstractDialogFactory_Impl::CreateTemplateDi
SwWrtShell* pActShell,
bool bNew )
{
+ if (nRegion == SfxStyleFamily::Page)
+ {
+ return VclPtr<AbstractApplyTabController_Impl>::Create(o3tl::make_unique<SwTemplateDlgController>(pParent ? pParent->GetFrameWeld() : nullptr, rBase, nRegion, sPage, pActShell, bNew));
+ }
VclPtr<SfxTabDialog> pDlg = VclPtr<SwTemplateDlg>::Create(pParent, rBase, nRegion, sPage, pActShell, bNew);
return VclPtr<AbstractApplyTabDialog_Impl>::Create(pDlg);
}
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index c7315197ecb5..ef655833b3fc 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -227,13 +227,14 @@ class AbstractTabDialog_Impl : virtual public SfxAbstractTabDialog
class AbstractTabController_Impl : virtual public SfxAbstractTabDialog
{
protected:
- std::unique_ptr<SfxTabDialogController> m_xDlg;
+ std::shared_ptr<SfxTabDialogController> m_xDlg;
public:
explicit AbstractTabController_Impl(std::unique_ptr<SfxTabDialogController> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
+ virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
virtual void SetCurPageId( const OString &rName ) override;
virtual const SfxItemSet* GetOutputItemSet() const override;
virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override;
@@ -255,6 +256,19 @@ private:
virtual void SetApplyHdl( const Link<LinkParamNone*,void>& rLink ) override;
};
+class AbstractApplyTabController_Impl : public AbstractTabController_Impl, virtual public SfxAbstractApplyTabDialog
+{
+public:
+ explicit AbstractApplyTabController_Impl(std::unique_ptr<SfxTabDialogController> p)
+ : AbstractTabController_Impl(std::move(p))
+ {
+ }
+ DECL_LINK(ApplyHdl, weld::Button&, void);
+private:
+ Link<LinkParamNone*,void> m_aHandler;
+ virtual void SetApplyHdl( const Link<LinkParamNone*,void>& rLink ) override;
+};
+
class AbstractSwConvertTableDlg_Impl : public AbstractSwConvertTableDlg
{
protected:
diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index 730351caeca3..16118d2ab258 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -51,9 +51,9 @@ SwEnvPreview::SwEnvPreview()
void SwEnvPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 20,
pDrawingArea->get_text_height() * 8);
- CustomWidgetController::SetDrawingArea(pDrawingArea);
}
void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
diff --git a/sw/source/ui/envelp/envprt.cxx b/sw/source/ui/envelp/envprt.cxx
index 9807e760e455..74860a832ff4 100644
--- a/sw/source/ui/envelp/envprt.cxx
+++ b/sw/source/ui/envelp/envprt.cxx
@@ -118,7 +118,7 @@ IMPL_LINK(SwEnvPrtPage, ButtonHdl, weld::Button&, rBtn, void)
// Call printer setup
if (m_xPrt)
{
- PrinterSetupDialog aDlg(GetDialogController()->getDialog());
+ PrinterSetupDialog aDlg(GetDialogFrameWeld());
aDlg.SetPrinter(m_xPrt);
aDlg.execute();
rBtn.grab_focus();
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index eb7d9621b0c0..09f6792ccc0c 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -122,6 +122,8 @@ SwLabPreview::SwLabPreview()
void SwLabPreview::SetDrawingArea(weld::DrawingArea* pWidget)
{
+ CustomWidgetController::SetDrawingArea(pWidget);
+
pWidget->set_size_request(pWidget->get_approximate_digit_width() * 54,
pWidget->get_text_height() * 15);
@@ -133,8 +135,6 @@ void SwLabPreview::SetDrawingArea(weld::DrawingArea* pWidget)
m_lColsWidth = pWidget->get_pixel_size(m_aColsStr).Width();
m_lXWidth = pWidget->get_pixel_size(OUString('X')).Width();
m_lXHeight = pWidget->get_text_height();
-
- CustomWidgetController::SetDrawingArea(pWidget);
}
void SwLabPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
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: */
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index 205510a2d8d0..5ad0abb3ae6c 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -164,7 +164,7 @@ SwColumnDlg::SwColumnDlg(weld::Window* pParent, SwWrtShell& rSh)
assert(pColPgSet);
// create TabPage
- m_pTabPage = static_cast<SwColumnPage*>(SwColumnPage::Create(m_xContentArea.get(), pColPgSet).get());
+ m_pTabPage = static_cast<SwColumnPage*>(SwColumnPage::Create(TabPageParent(m_xContentArea.get(), this), pColPgSet).get());
m_pTabPage->GetApplyLabel()->show();
weld::ComboBoxText* pApplyToLB = m_pTabPage->GetApplyComboBox();
pApplyToLB->show();
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index d12fc4de6ffb..98dd7a271e87 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -70,7 +70,7 @@ SwTextGridPage::SwTextGridPage(TabPageParent pParent, const SfxItemSet &rSet)
, m_xDisplayFL(m_xBuilder->weld_widget("frameFL_DISPLAY"))
, m_xDisplayCB(m_xBuilder->weld_check_button("checkCB_DISPLAY"))
, m_xPrintCB(m_xBuilder->weld_check_button("checkCB_PRINT"))
- , m_xColorLB(new ColorListBox(m_xBuilder->weld_menu_button("listLB_COLOR"), GetFrameWeld(), true))
+ , m_xColorLB(new ColorListBox(m_xBuilder->weld_menu_button("listLB_COLOR"), GetFrameWeld()))
{
Link<weld::SpinButton&,void> aLink = LINK(this, SwTextGridPage, CharorLineChangedHdl);
m_xCharsPerLineNF->connect_value_changed(aLink);
@@ -487,7 +487,7 @@ void SwTextGridPage::GridModifyHdl()
{
const SfxItemSet& rOldSet = GetItemSet();
SfxItemSet aSet(rOldSet);
- const SfxItemSet* pExSet = GetTabDialog()->GetExampleSet();
+ const SfxItemSet* pExSet = GetDialogController()->GetExampleSet();
if(pExSet)
aSet.Put(*pExSet);
PutGridItem(aSet);