Line data Source code
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 "paratr.hxx"
34 : #include "drpcps.hxx"
35 : #include "uitool.hxx"
36 : #include "viewopt.hxx"
37 : #include <numpara.hxx>
38 : #include "chrdlg.hrc"
39 : #include "poolfmt.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 :
47 0 : SwParaDlg::SwParaDlg(vcl::Window *pParent,
48 : SwView& rVw,
49 : const SfxItemSet& rCoreSet,
50 : sal_uInt8 nDialogMode,
51 : const OUString *pTitle,
52 : bool bDraw,
53 : const OString& sDefPage)
54 : : SfxTabDialog(pParent,
55 : "ParagraphPropertiesDialog",
56 : "modules/swriter/ui/paradialog.ui",
57 : &rCoreSet, 0 != pTitle)
58 : , rView(rVw)
59 : , nDlgMode(nDialogMode)
60 : , bDrawParaDlg(bDraw)
61 : , m_nParaStd(0)
62 : , m_nParaAlign(0)
63 : , m_nParaExt(0)
64 : , m_nParaNumPara(0)
65 : , m_nParaDrpCps(0)
66 : , m_nParaBckGrnd(0)
67 : , m_nParaBorder(0)
68 : , m_nAreaId(0)
69 0 : , m_nTransparenceId(0)
70 : {
71 0 : nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
72 0 : bool bHtmlMode = (nHtmlMode & HTMLMODE_ON) == HTMLMODE_ON;
73 0 : if(pTitle)
74 : {
75 : // Update title
76 0 : SetText(GetText() + SW_RESSTR(STR_TEXTCOLL_HEADER) + *pTitle + ")");
77 : }
78 : // tabs common to paragraph and draw paragraphs (paragraphs inside a text box)
79 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
80 :
81 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
82 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
83 0 : m_nParaStd = AddTabPage("labelTP_PARA_STD", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),
84 0 : pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
85 :
86 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
87 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
88 0 : m_nParaAlign = AddTabPage( "labelTP_PARA_ALIGN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),
89 0 : pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH) );
90 :
91 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
92 0 : if (!bDrawParaDlg && (!bHtmlMode || rHtmlOpt.IsPrintLayoutExtension()))
93 : {
94 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
95 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
96 0 : m_nParaExt = AddTabPage( "textflow", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),
97 0 : pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH) );
98 :
99 : }
100 : else
101 0 : RemoveTabPage("textflow");
102 :
103 0 : SvtCJKOptions aCJKOptions;
104 0 : if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
105 : {
106 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
107 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
108 0 : AddTabPage( "labelTP_PARA_ASIAN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),
109 0 : pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
110 : }
111 : else
112 0 : RemoveTabPage("labelTP_PARA_ASIAN");
113 :
114 0 : const sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
115 0 : bool bLRValid = SfxItemState::DEFAULT <= rCoreSet.GetItemState(nWhich);
116 0 : if(bHtmlMode || !bLRValid)
117 0 : RemoveTabPage("labelTP_TABULATOR");
118 : else
119 : {
120 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
121 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
122 0 : AddTabPage( "labelTP_TABULATOR", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
123 : }
124 :
125 : // remove unwanted tabs for draw text box paragraph properties
126 0 : if (bDrawParaDlg)
127 : {
128 0 : RemoveTabPage("labelTP_NUMPARA");
129 0 : RemoveTabPage("labelTP_DROPCAPS");
130 0 : RemoveTabPage("labelTP_BACKGROUND");
131 0 : RemoveTabPage("labelTP_BORDER");
132 0 : RemoveTabPage("area");
133 0 : RemoveTabPage("transparence");
134 : }
135 : else
136 : {
137 0 : if(!(nDlgMode & DLG_ENVELOP))
138 0 : m_nParaNumPara = AddTabPage("labelTP_NUMPARA", SwParagraphNumTabPage::Create, SwParagraphNumTabPage::GetRanges);
139 : else
140 0 : RemoveTabPage("labelTP_NUMPARA");
141 :
142 0 : m_nParaDrpCps = AddTabPage("labelTP_DROPCAPS", SwDropCapsPage::Create, SwDropCapsPage::GetRanges);
143 :
144 0 : if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
145 : {
146 : //UUUU remove?
147 : //OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
148 : //OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
149 : //m_nParaBckGrnd = AddTabPage("labelTP_BACKGROUND", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
150 : //
151 : //UUUU add Area and Transparence TabPages
152 0 : m_nAreaId = AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
153 0 : m_nTransparenceId = AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
154 : }
155 : else
156 : {
157 : //UUUU RemoveTabPage("labelTP_BACKGROUND");
158 0 : RemoveTabPage("area");
159 0 : RemoveTabPage("transparence");
160 : }
161 :
162 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
163 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
164 0 : m_nParaBorder = AddTabPage("labelTP_BORDER", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
165 : }
166 :
167 0 : if (!sDefPage.isEmpty())
168 0 : SetCurPageId(sDefPage);
169 0 : }
170 :
171 0 : SwParaDlg::~SwParaDlg()
172 : {
173 0 : }
174 :
175 0 : void SwParaDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage)
176 : {
177 0 : SwWrtShell& rSh = rView.GetWrtShell();
178 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
179 :
180 : // Table borders cannot get any shade in Writer
181 0 : if (nId == m_nParaBorder)
182 : {
183 0 : aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA)));
184 0 : rPage.PageCreated(aSet);
185 : }
186 0 : else if( nId == m_nParaStd )
187 : {
188 : aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
189 0 : static_cast< sal_uInt16 >(rSh.GetAnyCurRect(RECT_PAGE_PRT).Width()) ));
190 :
191 0 : if (!bDrawParaDlg)
192 : {
193 : // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
194 0 : aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
195 0 : aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
196 :
197 : }
198 0 : rPage.PageCreated(aSet);
199 : }
200 0 : else if( m_nParaAlign == nId)
201 : {
202 0 : if (!bDrawParaDlg)
203 : {
204 0 : aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
205 0 : rPage.PageCreated(aSet);
206 : }
207 : }
208 0 : else if( m_nParaExt == nId )
209 : {
210 : // pagebreak only when the cursor is in the body-area and not in a table
211 0 : const FrmTypeFlags eType = rSh.GetFrmType(0,true);
212 0 : if( !(FrmTypeFlags::BODY & eType) ||
213 0 : rSh.GetSelectionType() & nsSelectionType::SEL_TBL )
214 : {
215 0 : aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
216 0 : rPage.PageCreated(aSet);
217 : }
218 : }
219 0 : else if( m_nParaDrpCps == nId )
220 : {
221 0 : static_cast<SwDropCapsPage&>(rPage).SetFormat(false);
222 : }
223 0 : else if( m_nParaBckGrnd == nId )
224 : {
225 0 : if(!( nHtmlMode & HTMLMODE_ON ) ||
226 0 : nHtmlMode & HTMLMODE_SOME_STYLES)
227 : {
228 : // Seitenumbruch nur, wenn der Cursor im Body-Bereich und nicht in
229 : // einer Tabelle steht
230 0 : const FrmTypeFlags eType = rSh.GetFrmType(0,true);
231 0 : if(!(FrmTypeFlags::BODY & eType) ||
232 0 : rSh.GetSelectionType() & nsSelectionType::SEL_TBL)
233 : {
234 0 : aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
235 0 : rPage.PageCreated(aSet);
236 : }
237 : }
238 : }
239 0 : else if( m_nParaNumPara == nId)
240 : {
241 0 : SwTextFormatColl* pTmpColl = rSh.GetCurTextFormatColl();
242 0 : if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
243 : {
244 0 : static_cast<SwParagraphNumTabPage&>(rPage).DisableOutline() ;
245 : }
246 :
247 0 : static_cast<SwParagraphNumTabPage&>(rPage).EnableNewStart();
248 0 : ListBox & rBox = static_cast<SwParagraphNumTabPage&>(rPage).GetStyleBox();
249 0 : SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool();
250 0 : pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL);
251 0 : const SfxStyleSheetBase* pBase = pPool->First();
252 0 : std::set<OUString> aNames;
253 0 : while(pBase)
254 : {
255 0 : aNames.insert(pBase->GetName());
256 0 : pBase = pPool->Next();
257 : }
258 0 : for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it)
259 0 : rBox.InsertEntry(*it);
260 : }
261 : //UUUU inits for Area and Transparency TabPages
262 : // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
263 : // the color table) need to be added as items (e.g. SvxColorTableItem) to make
264 : // these pages find the needed attributes for fill style suggestions.
265 : // These are added in SwDocStyleSheet::GetItemSet() for the SFX_STYLE_FAMILY_PARA on
266 : // demand, but could also be directly added from the DrawModel.
267 0 : else if (m_nAreaId == nId)
268 : {
269 0 : SfxItemSet aNew(*aSet.GetPool(),
270 : SID_COLOR_TABLE, SID_BITMAP_LIST,
271 0 : SID_OFFER_IMPORT, SID_OFFER_IMPORT, 0, 0);
272 :
273 0 : aNew.Put(*GetInputSetImpl());
274 :
275 : // add flag for direct graphic content selection
276 0 : aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
277 :
278 0 : rPage.PageCreated(aNew);
279 : }
280 0 : else if (m_nTransparenceId == nId)
281 : {
282 0 : rPage.PageCreated(*GetInputSetImpl());
283 0 : }
284 0 : }
285 :
286 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|