Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / ui / chrdlg / pardlg.cxx
blobf28acc46bc87e9d467f590e1b15c1dbc04cb0f7e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/htmlmode.hxx>
21 #include <sfx2/tabdlg.hxx>
22 #include <svl/style.hxx>
23 #include <svtools/htmlcfg.hxx>
24 #include <svl/cjkoptions.hxx>
25 #include <docsh.hxx>
26 #include <wrtsh.hxx>
27 #include <view.hxx>
28 #include <swuipardlg.hxx>
29 #include <pardlg.hxx>
30 #include <drpcps.hxx>
31 #include <viewopt.hxx>
32 #include <numpara.hxx>
33 #include <strings.hrc>
34 #include <svx/svxids.hrc>
35 #include <svl/eitem.hxx>
36 #include <svl/intitem.hxx>
37 #include <svx/svxdlg.hxx>
38 #include <svx/dialogs.hrc>
39 #include <svx/flagsdef.hxx>
40 #include <osl/diagnose.h>
42 SwParaDlg::SwParaDlg(weld::Window *pParent,
43 SwView& rVw,
44 const SfxItemSet& rCoreSet,
45 sal_uInt8 nDialogMode,
46 const OUString *pTitle,
47 bool bDraw,
48 const OUString& sDefPage)
49 : SfxTabDialogController(pParent,
50 "modules/swriter/ui/paradialog.ui",
51 "ParagraphPropertiesDialog",
52 &rCoreSet, nullptr != pTitle)
53 , m_rView(rVw)
54 , m_bDrawParaDlg(bDraw)
56 sal_uInt16 nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
57 bool bHtmlMode = (nHtmlMode & HTMLMODE_ON) == HTMLMODE_ON;
58 if(pTitle)
60 // Update title
61 m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_TEXTCOLL_HEADER) + *pTitle + ")");
63 // tabs common to paragraph and draw paragraphs (paragraphs inside a text box)
64 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
66 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
67 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
68 AddTabPage("labelTP_PARA_STD", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),
69 pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
71 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
72 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
73 AddTabPage("labelTP_PARA_ALIGN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),
74 pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH));
76 if (!m_bDrawParaDlg && (!bHtmlMode || SvxHtmlOptions::IsPrintLayoutExtension()))
78 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
79 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
80 AddTabPage("textflow", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),
81 pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH));
84 else
85 RemoveTabPage("textflow");
87 if(!bHtmlMode && SvtCJKOptions::IsAsianTypographyEnabled())
89 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
90 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
91 AddTabPage( "labelTP_PARA_ASIAN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),
92 pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
94 else
95 RemoveTabPage("labelTP_PARA_ASIAN");
97 if(bHtmlMode)
98 RemoveTabPage("labelTP_TABULATOR");
99 else
101 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
102 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
103 AddTabPage( "labelTP_TABULATOR", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
106 // remove unwanted tabs for draw text box paragraph properties
107 if (m_bDrawParaDlg)
109 RemoveTabPage("labelTP_NUMPARA");
110 RemoveTabPage("labelTP_DROPCAPS");
111 RemoveTabPage("labelTP_BORDER");
112 RemoveTabPage("area");
113 RemoveTabPage("transparence");
115 else
117 if(!(nDialogMode & DLG_ENVELOP))
118 AddTabPage("labelTP_NUMPARA", SwParagraphNumTabPage::Create, SwParagraphNumTabPage::GetRanges);
119 else
120 RemoveTabPage("labelTP_NUMPARA");
122 AddTabPage("labelTP_DROPCAPS", SwDropCapsPage::Create, SwDropCapsPage::GetRanges);
124 if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
126 // add Area and Transparence TabPages
127 AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
128 AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
130 else
132 RemoveTabPage("area");
133 RemoveTabPage("transparence");
136 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
137 OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
138 AddTabPage("labelTP_BORDER", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
141 if (!sDefPage.isEmpty())
142 SetCurPageId(sDefPage);
145 SwParaDlg::~SwParaDlg()
149 void SwParaDlg::PageCreated(const OUString& rId, SfxTabPage& rPage)
151 SwWrtShell& rSh = m_rView.GetWrtShell();
152 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
154 // Table borders cannot get any shade in Writer
155 if (rId == "labelTP_BORDER")
157 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA)));
158 rPage.PageCreated(aSet);
160 else if (rId == "labelTP_PARA_STD")
162 aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
163 static_cast< sal_uInt16 >(rSh.GetAnyCurRect(CurRectType::PagePrt).Width()) ));
165 if (!m_bDrawParaDlg)
167 // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
168 constexpr tools::Long constTwips_0_5mm = o3tl::toTwips(5, o3tl::Length::mm10);
169 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
170 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, constTwips_0_5mm));
173 rPage.PageCreated(aSet);
175 else if (rId == "labelTP_PARA_ALIGN")
177 if (!m_bDrawParaDlg)
179 aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
180 rPage.PageCreated(aSet);
183 else if (rId == "textflow")
185 // pagebreak only when the cursor is in the body-area and not in a table
186 const FrameTypeFlags eType = rSh.GetFrameType(nullptr,true);
187 if( !(FrameTypeFlags::BODY & eType) ||
188 rSh.GetSelectionType() & SelectionType::Table )
190 aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
191 rPage.PageCreated(aSet);
194 else if (rId == "labelTP_DROPCAPS")
196 static_cast<SwDropCapsPage&>(rPage).SetFormat(false);
198 else if (rId == "labelTP_NUMPARA")
200 SwTextFormatColl* pTmpColl = rSh.GetCurTextFormatColl();
201 if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
203 static_cast<SwParagraphNumTabPage&>(rPage).DisableOutline() ;
206 static_cast<SwParagraphNumTabPage&>(rPage).EnableNewStart();
207 weld::ComboBox& rBox = static_cast<SwParagraphNumTabPage&>(rPage).GetStyleBox();
208 SfxStyleSheetBasePool* pPool = m_rView.GetDocShell()->GetStyleSheetPool();
209 const SfxStyleSheetBase* pBase = pPool->First(SfxStyleFamily::Pseudo);
210 std::set<OUString> aNames;
211 while(pBase)
213 aNames.insert(pBase->GetName());
214 pBase = pPool->Next();
216 aNames.erase(SwResId(STR_POOLNUMRULE_NOLIST));
217 for (const auto& rName : aNames)
218 rBox.append_text(rName);
220 // inits for Area and Transparency TabPages
221 // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
222 // the color table) need to be added as items (e.g. SvxColorTableItem) to make
223 // these pages find the needed attributes for fill style suggestions.
224 // These are added in SwDocStyleSheet::GetItemSet() for the SfxStyleFamily::Para on
225 // demand, but could also be directly added from the DrawModel.
226 else if (rId == "area")
228 SfxItemSetFixed
229 <SID_COLOR_TABLE, SID_PATTERN_LIST,
230 SID_OFFER_IMPORT, SID_OFFER_IMPORT> aNew(*aSet.GetPool());
232 aNew.Put(*GetInputSetImpl());
234 // add flag for direct graphic content selection
235 aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
237 rPage.PageCreated(aNew);
239 else if (rId == "transparence")
241 rPage.PageCreated(*GetInputSetImpl());
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */