bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / chrdlg / pardlg.cxx
blobf07337e80587d61b43d8b03d2f700ffdcd58b06e
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 "hintids.hxx"
21 #include <sfx2/htmlmode.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 "frmatr.hxx"
28 #include "view.hxx"
29 #include "globals.hrc"
30 #include "swuipardlg.hxx"
31 #include "pagedesc.hxx"
32 #include "paratr.hxx"
33 #include "drpcps.hxx"
34 #include "uitool.hxx"
35 #include "viewopt.hxx"
36 #include <numpara.hxx>
37 #include "chrdlg.hrc"
38 #include "poolfmt.hrc"
39 #include <svx/svxids.hrc>
40 #include <svl/eitem.hxx>
41 #include <svl/intitem.hxx>
42 #include <svx/svxdlg.hxx>
43 #include <svx/dialogs.hrc>
44 #include <svx/flagsdef.hxx>
46 SwParaDlg::SwParaDlg(Window *pParent,
47 SwView& rVw,
48 const SfxItemSet& rCoreSet,
49 sal_uInt8 nDialogMode,
50 const String *pTitle,
51 sal_Bool bDraw,
52 sal_uInt16 nDefPage):
54 SfxTabDialog(pParent, bDraw ? SW_RES(DLG_DRAWPARA) : SW_RES(DLG_PARA),
55 &rCoreSet, 0 != pTitle),
57 rView(rVw),
58 nDlgMode(nDialogMode),
59 bDrawParaDlg(bDraw)
62 FreeResource();
64 nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
65 sal_Bool bHtmlMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
66 if(pTitle)
68 // Update title
69 String aTmp( GetText() );
70 aTmp += SW_RESSTR(STR_TEXTCOLL_HEADER);
71 aTmp += *pTitle;
72 aTmp += ')';
73 SetText(aTmp);
75 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
77 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
78 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
79 AddTabPage( TP_PARA_STD, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
81 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
82 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
83 AddTabPage( TP_PARA_ALIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH) );
85 SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
86 if (!bDrawParaDlg && (!bHtmlMode || rHtmlOpt.IsPrintLayoutExtension()))
88 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
89 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
90 AddTabPage( TP_PARA_EXT, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH) );
93 else
94 RemoveTabPage(TP_PARA_EXT);
96 SvtCJKOptions aCJKOptions;
97 if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
99 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
100 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
101 AddTabPage( TP_PARA_ASIAN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
103 else
104 RemoveTabPage(TP_PARA_ASIAN);
106 sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
107 bool bLRValid = SFX_ITEM_AVAILABLE <= rCoreSet.GetItemState(nWhich);
108 if(bHtmlMode || !bLRValid)
109 RemoveTabPage(TP_TABULATOR);
110 else
112 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
113 OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
114 AddTabPage( TP_TABULATOR, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
117 if (!bDrawParaDlg)
119 if(!(nDlgMode & DLG_ENVELOP))
120 AddTabPage(TP_NUMPARA, SwParagraphNumTabPage::Create,SwParagraphNumTabPage::GetRanges);
121 else
122 RemoveTabPage(TP_NUMPARA);
123 if(!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES))
125 AddTabPage(TP_DROPCAPS, SwDropCapsPage::Create, SwDropCapsPage::GetRanges);
127 else
129 RemoveTabPage(TP_DROPCAPS);
131 if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
133 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
134 OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
135 AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
137 else
139 RemoveTabPage(TP_BACKGROUND);
142 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
143 OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
144 AddTabPage(TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
147 if (nDefPage)
148 SetCurPageId(nDefPage);
152 SwParaDlg::~SwParaDlg()
157 void SwParaDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage)
159 SwWrtShell& rSh = rView.GetWrtShell();
160 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
162 // Table borders cannot get any shade in Writer
163 if (nId == TP_BORDER)
165 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA));
166 rPage.PageCreated(aSet);
168 else if( nId == TP_PARA_STD )
170 aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
171 static_cast< sal_uInt16 >(rSh.GetAnyCurRect(RECT_PAGE_PRT).Width()) ));
173 if (!bDrawParaDlg)
175 // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
176 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
177 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
180 rPage.PageCreated(aSet);
182 else if( TP_PARA_ALIGN == nId)
184 if (!bDrawParaDlg)
186 aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,sal_True));
187 rPage.PageCreated(aSet);
190 else if( TP_PARA_EXT == nId )
192 // pagebreak only when the cursor is in the body-area and not in a table
193 const sal_uInt16 eType = rSh.GetFrmType(0,sal_True);
194 if( !(FRMTYPE_BODY & eType) ||
195 rSh.GetSelectionType() & nsSelectionType::SEL_TBL )
197 aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,sal_True));
198 rPage.PageCreated(aSet);
201 else if( TP_DROPCAPS == nId )
203 ((SwDropCapsPage&)rPage).SetFormat(sal_False);
205 else if( TP_BACKGROUND == nId )
207 if(!( nHtmlMode & HTMLMODE_ON ) ||
208 nHtmlMode & HTMLMODE_SOME_STYLES)
210 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
211 rPage.PageCreated(aSet);
214 else if( TP_NUMPARA == nId)
216 SwTxtFmtColl* pTmpColl = rSh.GetCurTxtFmtColl();
217 if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
219 ((SwParagraphNumTabPage&)rPage).DisableOutline() ;
222 ((SwParagraphNumTabPage&)rPage).EnableNewStart();
223 ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox();
224 SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool();
225 pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL);
226 const SfxStyleSheetBase* pBase = pPool->First();
227 std::set<String> aNames;
228 while(pBase)
230 aNames.insert(pBase->GetName());
231 pBase = pPool->Next();
233 for(std::set<String>::const_iterator it = aNames.begin(); it != aNames.end(); ++it)
234 rBox.InsertEntry(*it);
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */