nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / ui / chrdlg / pardlg.cxx
blobe64932300c3b815e4a200cd19beb8d4c6f7fa838
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>
41 SwParaDlg::SwParaDlg(weld::Window *pParent,
42 SwView& rVw,
43 const SfxItemSet& rCoreSet,
44 sal_uInt8 nDialogMode,
45 const OUString *pTitle,
46 bool bDraw,
47 const OString& sDefPage)
48 : SfxTabDialogController(pParent,
49 "modules/swriter/ui/paradialog.ui",
50 "ParagraphPropertiesDialog",
51 &rCoreSet, nullptr != pTitle)
52 , rView(rVw)
53 , bDrawParaDlg(bDraw)
55 sal_uInt16 nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
56 bool bHtmlMode = (nHtmlMode & HTMLMODE_ON) == HTMLMODE_ON;
57 if(pTitle)
59 // Update title
60 m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_TEXTCOLL_HEADER) + *pTitle + ")");
62 // tabs common to paragraph and draw paragraphs (paragraphs inside a text box)
63 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
65 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
66 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
67 AddTabPage("labelTP_PARA_STD", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),
68 pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
70 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
71 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
72 AddTabPage("labelTP_PARA_ALIGN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),
73 pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH));
75 SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
76 if (!bDrawParaDlg && (!bHtmlMode || rHtmlOpt.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 SvtCJKOptions aCJKOptions;
88 if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
90 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
91 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
92 AddTabPage( "labelTP_PARA_ASIAN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),
93 pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
95 else
96 RemoveTabPage("labelTP_PARA_ASIAN");
98 const sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
99 bool bLRValid = SfxItemState::DEFAULT <= rCoreSet.GetItemState(nWhich);
100 if(bHtmlMode || !bLRValid)
101 RemoveTabPage("labelTP_TABULATOR");
102 else
104 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
105 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
106 AddTabPage( "labelTP_TABULATOR", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
109 // remove unwanted tabs for draw text box paragraph properties
110 if (bDrawParaDlg)
112 RemoveTabPage("labelTP_NUMPARA");
113 RemoveTabPage("labelTP_DROPCAPS");
114 RemoveTabPage("labelTP_BORDER");
115 RemoveTabPage("area");
116 RemoveTabPage("transparence");
118 else
120 if(!(nDialogMode & DLG_ENVELOP))
121 AddTabPage("labelTP_NUMPARA", SwParagraphNumTabPage::Create, SwParagraphNumTabPage::GetRanges);
122 else
123 RemoveTabPage("labelTP_NUMPARA");
125 AddTabPage("labelTP_DROPCAPS", SwDropCapsPage::Create, SwDropCapsPage::GetRanges);
127 if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
129 // add Area and Transparence TabPages
130 AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
131 AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
133 else
135 RemoveTabPage("area");
136 RemoveTabPage("transparence");
139 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
140 OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
141 AddTabPage("labelTP_BORDER", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
144 if (!sDefPage.isEmpty())
145 SetCurPageId(sDefPage);
148 SwParaDlg::~SwParaDlg()
152 void SwParaDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
154 SwWrtShell& rSh = rView.GetWrtShell();
155 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
157 // Table borders cannot get any shade in Writer
158 if (rId == "labelTP_BORDER")
160 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA)));
161 rPage.PageCreated(aSet);
163 else if (rId == "labelTP_PARA_STD")
165 aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
166 static_cast< sal_uInt16 >(rSh.GetAnyCurRect(CurRectType::PagePrt).Width()) ));
168 if (!bDrawParaDlg)
170 // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
171 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
172 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
175 rPage.PageCreated(aSet);
177 else if (rId == "labelTP_PARA_ALIGN")
179 if (!bDrawParaDlg)
181 aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
182 rPage.PageCreated(aSet);
185 else if (rId == "textflow")
187 // pagebreak only when the cursor is in the body-area and not in a table
188 const FrameTypeFlags eType = rSh.GetFrameType(nullptr,true);
189 if( !(FrameTypeFlags::BODY & eType) ||
190 rSh.GetSelectionType() & SelectionType::Table )
192 aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
193 rPage.PageCreated(aSet);
196 else if (rId == "labelTP_DROPCAPS")
198 static_cast<SwDropCapsPage&>(rPage).SetFormat(false);
200 else if (rId == "labelTP_NUMPARA")
202 SwTextFormatColl* pTmpColl = rSh.GetCurTextFormatColl();
203 if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
205 static_cast<SwParagraphNumTabPage&>(rPage).DisableOutline() ;
208 static_cast<SwParagraphNumTabPage&>(rPage).EnableNewStart();
209 weld::ComboBox& rBox = static_cast<SwParagraphNumTabPage&>(rPage).GetStyleBox();
210 SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool();
211 const SfxStyleSheetBase* pBase = pPool->First(SfxStyleFamily::Pseudo);
212 std::set<OUString> aNames;
213 while(pBase)
215 aNames.insert(pBase->GetName());
216 pBase = pPool->Next();
218 for(const auto& rName : aNames)
219 rBox.append_text(rName);
221 // inits for Area and Transparency TabPages
222 // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
223 // the color table) need to be added as items (e.g. SvxColorTableItem) to make
224 // these pages find the needed attributes for fill style suggestions.
225 // These are added in SwDocStyleSheet::GetItemSet() for the SfxStyleFamily::Para on
226 // demand, but could also be directly added from the DrawModel.
227 else if (rId == "area")
229 SfxItemSet aNew(*aSet.GetPool(),
230 svl::Items<SID_COLOR_TABLE, SID_PATTERN_LIST,
231 SID_OFFER_IMPORT, SID_OFFER_IMPORT>{});
233 aNew.Put(*GetInputSetImpl());
235 // add flag for direct graphic content selection
236 aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
238 rPage.PageCreated(aNew);
240 else if (rId == "transparence")
242 rPage.PageCreated(*GetInputSetImpl());
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */