LibreOffice Module sw (master)  1
pardlg.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <hintids.hxx>
21 #include <sfx2/htmlmode.hxx>
22 #include <sfx2/tabdlg.hxx>
23 #include <svl/style.hxx>
24 #include <svtools/htmlcfg.hxx>
25 #include <svl/cjkoptions.hxx>
26 #include <docsh.hxx>
27 #include <wrtsh.hxx>
28 #include <frmatr.hxx>
29 #include <view.hxx>
30 #include <globals.hrc>
31 #include <swuipardlg.hxx>
32 #include <pagedesc.hxx>
33 #include <pardlg.hxx>
34 #include <paratr.hxx>
35 #include <drpcps.hxx>
36 #include <uitool.hxx>
37 #include <viewopt.hxx>
38 #include <numpara.hxx>
39 #include <strings.hrc>
40 #include <svx/svxids.hrc>
41 #include <svl/eitem.hxx>
42 #include <svl/intitem.hxx>
43 #include <svx/svxdlg.hxx>
44 #include <svx/dialogs.hrc>
45 #include <svx/flagsdef.hxx>
46 
48  SwView& rVw,
49  const SfxItemSet& rCoreSet,
50  sal_uInt8 nDialogMode,
51  const OUString *pTitle,
52  bool bDraw,
53  const OString& sDefPage)
54  : SfxTabDialogController(pParent,
55  "modules/swriter/ui/paradialog.ui",
56  "ParagraphPropertiesDialog",
57  &rCoreSet, nullptr != pTitle)
58  , rView(rVw)
59  , bDrawParaDlg(bDraw)
60 {
62  bool bHtmlMode = (nHtmlMode & HTMLMODE_ON) == HTMLMODE_ON;
63  if(pTitle)
64  {
65  // Update title
66  m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_TEXTCOLL_HEADER) + *pTitle + ")");
67  }
68  // tabs common to paragraph and draw paragraphs (paragraphs inside a text box)
70 
71  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
72  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
73  AddTabPage("labelTP_PARA_STD", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),
74  pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
75 
76  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
77  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
78  AddTabPage("labelTP_PARA_ALIGN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),
79  pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH));
80 
81  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
82  if (!bDrawParaDlg && (!bHtmlMode || rHtmlOpt.IsPrintLayoutExtension()))
83  {
84  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
85  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
86  AddTabPage("textflow", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),
87  pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH));
88 
89  }
90  else
91  RemoveTabPage("textflow");
92 
93  SvtCJKOptions aCJKOptions;
94  if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
95  {
96  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
97  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
98  AddTabPage( "labelTP_PARA_ASIAN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),
99  pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
100  }
101  else
102  RemoveTabPage("labelTP_PARA_ASIAN");
103 
104  const sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
105  bool bLRValid = SfxItemState::DEFAULT <= rCoreSet.GetItemState(nWhich);
106  if(bHtmlMode || !bLRValid)
107  RemoveTabPage("labelTP_TABULATOR");
108  else
109  {
110  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
111  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
112  AddTabPage( "labelTP_TABULATOR", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
113  }
114 
115  // remove unwanted tabs for draw text box paragraph properties
116  if (bDrawParaDlg)
117  {
118  RemoveTabPage("labelTP_NUMPARA");
119  RemoveTabPage("labelTP_DROPCAPS");
120  RemoveTabPage("labelTP_BORDER");
121  RemoveTabPage("area");
122  RemoveTabPage("transparence");
123  }
124  else
125  {
126  if(!(nDialogMode & DLG_ENVELOP))
128  else
129  RemoveTabPage("labelTP_NUMPARA");
130 
132 
133  if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
134  {
135  // add Area and Transparence TabPages
136  AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
137  AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
138  }
139  else
140  {
141  RemoveTabPage("area");
142  RemoveTabPage("transparence");
143  }
144 
145  OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
146  OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
147  AddTabPage("labelTP_BORDER", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
148  }
149 
150  if (!sDefPage.isEmpty())
151  SetCurPageId(sDefPage);
152 }
153 
155 {
156 }
157 
158 void SwParaDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
159 {
160  SwWrtShell& rSh = rView.GetWrtShell();
161  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
162 
163  // Table borders cannot get any shade in Writer
164  if (rId == "labelTP_BORDER")
165  {
166  aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA)));
167  rPage.PageCreated(aSet);
168  }
169  else if (rId == "labelTP_PARA_STD")
170  {
171  aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
172  static_cast< sal_uInt16 >(rSh.GetAnyCurRect(CurRectType::PagePrt).Width()) ));
173 
174  if (!bDrawParaDlg)
175  {
176  // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
177  aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
178  aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
179 
180  }
181  rPage.PageCreated(aSet);
182  }
183  else if (rId == "labelTP_PARA_ALIGN")
184  {
185  if (!bDrawParaDlg)
186  {
187  aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
188  rPage.PageCreated(aSet);
189  }
190  }
191  else if (rId == "textflow")
192  {
193  // pagebreak only when the cursor is in the body-area and not in a table
194  const FrameTypeFlags eType = rSh.GetFrameType(nullptr,true);
195  if( !(FrameTypeFlags::BODY & eType) ||
197  {
198  aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
199  rPage.PageCreated(aSet);
200  }
201  }
202  else if (rId == "labelTP_DROPCAPS")
203  {
204  static_cast<SwDropCapsPage&>(rPage).SetFormat(false);
205  }
206  else if (rId == "labelTP_NUMPARA")
207  {
208  SwTextFormatColl* pTmpColl = rSh.GetCurTextFormatColl();
209  if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
210  {
211  static_cast<SwParagraphNumTabPage&>(rPage).DisableOutline() ;
212  }
213 
214  static_cast<SwParagraphNumTabPage&>(rPage).EnableNewStart();
215  weld::ComboBox& rBox = static_cast<SwParagraphNumTabPage&>(rPage).GetStyleBox();
217  pPool->SetSearchMask(SfxStyleFamily::Pseudo);
218  const SfxStyleSheetBase* pBase = pPool->First();
219  std::set<OUString> aNames;
220  while(pBase)
221  {
222  aNames.insert(pBase->GetName());
223  pBase = pPool->Next();
224  }
225  for(const auto& rName : aNames)
226  rBox.append_text(rName);
227  }
228  // inits for Area and Transparency TabPages
229  // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
230  // the color table) need to be added as items (e.g. SvxColorTableItem) to make
231  // these pages find the needed attributes for fill style suggestions.
232  // These are added in SwDocStyleSheet::GetItemSet() for the SfxStyleFamily::Para on
233  // demand, but could also be directly added from the DrawModel.
234  else if (rId == "area")
235  {
236  SfxItemSet aNew(*aSet.GetPool(),
237  svl::Items<SID_COLOR_TABLE, SID_PATTERN_LIST,
238  SID_OFFER_IMPORT, SID_OFFER_IMPORT>{});
239 
240  aNew.Put(*GetInputSetImpl());
241 
242  // add flag for direct graphic content selection
243  aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
244 
245  rPage.PageCreated(aNew);
246  }
247  else if (rId == "transparence")
248  {
249  rPage.PageCreated(*GetInputSetImpl());
250  }
251 }
252 
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwTextFormatColl * GetCurTextFormatColl() const
Get the named paragraph format of the current selection.
Definition: edattr.cxx:250
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SfxStyleSheetBase * First()
virtual void PageCreated(const SfxAllItemSet &aSet)
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:92
static SvxAbstractDialogFactory * Create()
void RemoveTabPage(const OString &rName)
SfxItemSet * GetInputSetImpl()
bool const bDrawParaDlg
Definition: swuipardlg.hxx:30
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rSet)
Definition: drpcps.cxx:523
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:109
const OUString & GetName() const
SwView & rView
Definition: swuipardlg.hxx:28
static const sal_uInt16 * GetRanges()
Definition: drpcps.hxx:157
SwParaDlg(weld::Window *pParent, SwView &rVw, const SfxItemSet &, sal_uInt8 nDialogMode, const OUString *pCollName, bool bDraw=false, const OString &sDefPage=OString())
Definition: pardlg.cxx:47
static SvxHtmlOptions & Get()
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rSet)
Definition: numpara.cxx:101
static const sal_uInt16 * GetRanges()
Definition: numpara.hxx:70
Rect of current PrtArea of page.
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: pardlg.cxx:158
HTMLMODE_ON
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:340
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1159
#define DLG_ENVELOP
Definition: pardlg.hxx:24
virtual ~SwParaDlg() override
Definition: pardlg.cxx:154
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
DocumentType const eType
SfxItemPool * GetPool() const
SwDocShell * GetDocShell()
Definition: view.cxx:1127
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsAsianTypographyEnabled() const
#define MM50
Definition: swtypes.hxx:59
HTMLMODE_SOME_STYLES
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
unsigned char sal_uInt8
void Width(long nNew)
Definition: swrect.hxx:185
SfxStyleSheetBase * Next()
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void SetSearchMask(SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
HTMLMODE_FULL_STYLES
void append_text(const OUString &rStr)
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1387
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:238
sal_uInt16 nHtmlMode
Definition: swuipardlg.hxx:29
Definition: view.hxx:146
void SetCurPageId(const OString &rName)
void SetFormat(LotusContext &rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt)