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 <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>
41 
43  SwView& rVw,
44  const SfxItemSet& rCoreSet,
45  sal_uInt8 nDialogMode,
46  const OUString *pTitle,
47  bool bDraw,
48  const OString& sDefPage)
49  : SfxTabDialogController(pParent,
50  "modules/swriter/ui/paradialog.ui",
51  "ParagraphPropertiesDialog",
52  &rCoreSet, nullptr != pTitle)
53  , rView(rVw)
54  , bDrawParaDlg(bDraw)
55 {
56  sal_uInt16 nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
57  bool bHtmlMode = (nHtmlMode & HTMLMODE_ON) == HTMLMODE_ON;
58  if(pTitle)
59  {
60  // Update title
61  m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_TEXTCOLL_HEADER) + *pTitle + ")");
62  }
63  // tabs common to paragraph and draw paragraphs (paragraphs inside a text box)
65 
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) );
70 
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));
75 
76  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
77  if (!bDrawParaDlg && (!bHtmlMode || rHtmlOpt.IsPrintLayoutExtension()))
78  {
79  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
80  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
81  AddTabPage("textflow", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),
82  pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH));
83 
84  }
85  else
86  RemoveTabPage("textflow");
87 
88  SvtCJKOptions aCJKOptions;
89  if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
90  {
91  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
92  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
93  AddTabPage( "labelTP_PARA_ASIAN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),
94  pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
95  }
96  else
97  RemoveTabPage("labelTP_PARA_ASIAN");
98 
99  const sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
100  bool bLRValid = SfxItemState::DEFAULT <= rCoreSet.GetItemState(nWhich);
101  if(bHtmlMode || !bLRValid)
102  RemoveTabPage("labelTP_TABULATOR");
103  else
104  {
105  OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
106  OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
107  AddTabPage( "labelTP_TABULATOR", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
108  }
109 
110  // remove unwanted tabs for draw text box paragraph properties
111  if (bDrawParaDlg)
112  {
113  RemoveTabPage("labelTP_NUMPARA");
114  RemoveTabPage("labelTP_DROPCAPS");
115  RemoveTabPage("labelTP_BORDER");
116  RemoveTabPage("area");
117  RemoveTabPage("transparence");
118  }
119  else
120  {
121  if(!(nDialogMode & DLG_ENVELOP))
123  else
124  RemoveTabPage("labelTP_NUMPARA");
125 
127 
128  if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
129  {
130  // add Area and Transparence TabPages
131  AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
132  AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
133  }
134  else
135  {
136  RemoveTabPage("area");
137  RemoveTabPage("transparence");
138  }
139 
140  OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
141  OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
142  AddTabPage("labelTP_BORDER", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
143  }
144 
145  if (!sDefPage.isEmpty())
146  SetCurPageId(sDefPage);
147 }
148 
150 {
151 }
152 
153 void SwParaDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
154 {
155  SwWrtShell& rSh = rView.GetWrtShell();
156  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
157 
158  // Table borders cannot get any shade in Writer
159  if (rId == "labelTP_BORDER")
160  {
161  aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA)));
162  rPage.PageCreated(aSet);
163  }
164  else if (rId == "labelTP_PARA_STD")
165  {
166  aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
167  static_cast< sal_uInt16 >(rSh.GetAnyCurRect(CurRectType::PagePrt).Width()) ));
168 
169  if (!bDrawParaDlg)
170  {
171  // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
172  aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
173  aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
174 
175  }
176  rPage.PageCreated(aSet);
177  }
178  else if (rId == "labelTP_PARA_ALIGN")
179  {
180  if (!bDrawParaDlg)
181  {
182  aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
183  rPage.PageCreated(aSet);
184  }
185  }
186  else if (rId == "textflow")
187  {
188  // pagebreak only when the cursor is in the body-area and not in a table
189  const FrameTypeFlags eType = rSh.GetFrameType(nullptr,true);
190  if( !(FrameTypeFlags::BODY & eType) ||
192  {
193  aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
194  rPage.PageCreated(aSet);
195  }
196  }
197  else if (rId == "labelTP_DROPCAPS")
198  {
199  static_cast<SwDropCapsPage&>(rPage).SetFormat(false);
200  }
201  else if (rId == "labelTP_NUMPARA")
202  {
203  SwTextFormatColl* pTmpColl = rSh.GetCurTextFormatColl();
204  if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
205  {
206  static_cast<SwParagraphNumTabPage&>(rPage).DisableOutline() ;
207  }
208 
209  static_cast<SwParagraphNumTabPage&>(rPage).EnableNewStart();
210  weld::ComboBox& rBox = static_cast<SwParagraphNumTabPage&>(rPage).GetStyleBox();
212  const SfxStyleSheetBase* pBase = pPool->First(SfxStyleFamily::Pseudo);
213  std::set<OUString> aNames;
214  while(pBase)
215  {
216  aNames.insert(pBase->GetName());
217  pBase = pPool->Next();
218  }
219  aNames.erase("No List");
220  for (const auto& rName : aNames)
221  rBox.append_text(rName);
222  }
223  // inits for Area and Transparency TabPages
224  // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
225  // the color table) need to be added as items (e.g. SvxColorTableItem) to make
226  // these pages find the needed attributes for fill style suggestions.
227  // These are added in SwDocStyleSheet::GetItemSet() for the SfxStyleFamily::Para on
228  // demand, but could also be directly added from the DrawModel.
229  else if (rId == "area")
230  {
231  SfxItemSet aNew(*aSet.GetPool(),
232  svl::Items<SID_COLOR_TABLE, SID_PATTERN_LIST,
233  SID_OFFER_IMPORT, SID_OFFER_IMPORT>{});
234 
235  aNew.Put(*GetInputSetImpl());
236 
237  // add flag for direct graphic content selection
238  aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
239 
240  rPage.PageCreated(aNew);
241  }
242  else if (rId == "transparence")
243  {
244  rPage.PageCreated(*GetInputSetImpl());
245  }
246 }
247 
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
SwTextFormatColl * GetCurTextFormatColl() const
Get the named paragraph format of the current selection.
Definition: edattr.cxx:246
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
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:90
static SvxAbstractDialogFactory * Create()
void RemoveTabPage(const OString &rName)
SfxItemSet * GetInputSetImpl()
SwWrtShell & GetWrtShell() const
Definition: view.hxx:413
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:114
const OUString & GetName() const
SwView & rView
Definition: swuipardlg.hxx:28
void Width(tools::Long nNew)
Definition: swrect.hxx:187
static const sal_uInt16 * GetRanges()
Definition: drpcps.hxx:154
SwParaDlg(weld::Window *pParent, SwView &rVw, const SfxItemSet &, sal_uInt8 nDialogMode, const OUString *pCollName, bool bDraw=false, const OString &sDefPage=OString())
Definition: pardlg.cxx:42
static SvxHtmlOptions & Get()
DocumentType eType
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
bool bDrawParaDlg
Definition: swuipardlg.hxx:29
void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: pardlg.cxx:153
HTMLMODE_ON
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1140
#define DLG_ENVELOP
Definition: pardlg.hxx:24
virtual ~SwParaDlg() override
Definition: pardlg.cxx:149
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
SfxItemPool * GetPool() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: numpara.cxx:91
SwDocShell * GetDocShell()
Definition: view.cxx:1126
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
SfxStyleSheetBase * Next()
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
Reference< XExecutableDialog > m_xDialog
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: drpcps.cxx:525
HTMLMODE_FULL_STYLES
void append_text(const OUString &rStr)
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1395
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
Definition: view.hxx:144
void SetCurPageId(const OString &rName)
void SetFormat(LotusContext &rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt)