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 :
22 : #include <vcl/msgbox.hxx>
23 : #include <sfx2/viewfrm.hxx>
24 : #include <svx/hdft.hxx>
25 : #include <editeng/flstitem.hxx>
26 : #include <sfx2/htmlmode.hxx>
27 : #include <svtools/htmlcfg.hxx>
28 : #include <svl/cjkoptions.hxx>
29 : #include <numpara.hxx>
30 : #include <fmtclds.hxx>
31 : #include <swtypes.hxx>
32 : #include <swmodule.hxx>
33 : #include <wrtsh.hxx>
34 : #include <view.hxx>
35 : #include <wdocsh.hxx>
36 : #include <viewopt.hxx>
37 : #include <pgfnote.hxx>
38 : #include <pggrid.hxx>
39 : #include <tmpdlg.hxx>
40 : #include <column.hxx>
41 : #include <drpcps.hxx>
42 : #include <frmpage.hxx>
43 : #include <wrap.hxx>
44 : #include <frmmgr.hxx>
45 : #include <ccoll.hxx>
46 : #include <swuiccoll.hxx>
47 : #include <docstyle.hxx>
48 : #include <fmtcol.hxx>
49 : #include <macassgn.hxx>
50 : #include <poolfmt.hxx>
51 : #include <uitool.hxx>
52 : #include <shellres.hxx>
53 : #include <swabstdlg.hxx>
54 :
55 : #include <cmdid.h>
56 : #include <helpid.h>
57 : #include <globals.hrc>
58 : #include <SwStyleNameMapper.hxx>
59 : #include <svx/svxids.hrc>
60 : #include <svl/stritem.hxx>
61 : #include <svl/aeitem.hxx>
62 : #include <svl/slstitm.hxx>
63 : #include <svl/eitem.hxx>
64 : #include <svl/intitem.hxx>
65 : #include <svx/svxdlg.hxx>
66 : #include <svx/dialogs.hrc>
67 : #include <svx/flagsdef.hxx>
68 :
69 : // the dialog's carrier
70 0 : SwTemplateDlg::SwTemplateDlg(vcl::Window* pParent,
71 : SfxStyleSheetBase& rBase,
72 : sal_uInt16 nRegion,
73 : const OString& sPage,
74 : SwWrtShell* pActShell,
75 : bool bNew)
76 : : SfxStyleDialog(pParent,
77 0 : "TemplateDialog" + OUString::number(nRegion),
78 0 : "modules/swriter/ui/templatedialog" +
79 0 : OUString::number(nRegion) + ".ui",
80 : rBase)
81 : , nType(nRegion)
82 : , pWrtShell(pActShell)
83 : , bNewStyle(bNew)
84 : , m_nIndentsId(0)
85 : , m_nAlignId(0)
86 : , m_nTextFlowId(0)
87 : , m_nAsianTypo(0)
88 : , m_nFontId(0)
89 : , m_nFontEffectId(0)
90 : , m_nPositionId(0)
91 : , m_nAsianLayoutId(0)
92 : , m_nTabId(0)
93 : , m_nOutlineId(0)
94 : , m_nDropCapsId(0)
95 : , m_nBackgroundId(0)
96 : , m_nAreaId(0)
97 : , m_nTransparenceId(0)
98 : , m_nBorderId(0)
99 : , m_nConditionId(0)
100 : , m_nTypeId(0)
101 : , m_nOptionsId(0)
102 : , m_nWrapId(0)
103 : , m_nColumnId(0)
104 : , m_nMacroId(0)
105 : , m_nHeaderId(0)
106 : , m_nFooterId(0)
107 : , m_nPageId(0)
108 : , m_nFootNoteId(0)
109 : , m_nTextGridId(0)
110 : , m_nSingleId(0)
111 : , m_nBulletId(0)
112 : , m_nNumId(0)
113 : , m_nBmpId(0)
114 : , m_nNumOptId(0)
115 0 : , m_nNumPosId(0)
116 : {
117 0 : nHtmlMode = ::GetHtmlMode(pWrtShell->GetView().GetDocShell());
118 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
119 : OSL_ENSURE(pFact, "Dialog creation failed!");
120 : // tinker TabPages together
121 0 : switch( nRegion )
122 : {
123 : // character styles
124 : case SFX_STYLE_FAMILY_CHAR:
125 : {
126 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
127 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) , "GetTabPageRangesFunc fail!");
128 0 : m_nFontId = AddTabPage("font", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ));
129 :
130 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
131 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) , "GetTabPageRangesFunc fail!");
132 0 : m_nFontEffectId = AddTabPage("fonteffect", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ));
133 :
134 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), "GetTabPageCreatorFunc fail!");
135 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) , "GetTabPageRangesFunc fail!");
136 0 : m_nPositionId = AddTabPage("position", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ));
137 :
138 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), "GetTabPageCreatorFunc fail!");
139 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) , "GetTabPageRangesFunc fail!");
140 0 : m_nAsianLayoutId = AddTabPage("asianlayout", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ));
141 :
142 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
143 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) , "GetTabPageRangesFunc fail!");
144 0 : m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ));
145 :
146 : SAL_WARN_IF(!pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "sw.ui", "GetTabPageCreatorFunc fail!");
147 : SAL_WARN_IF(!pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "sw.ui", "GetTabPageRangesFunc fail!");
148 0 : m_nBorderId = AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ));
149 :
150 0 : SvtCJKOptions aCJKOptions;
151 0 : if(nHtmlMode & HTMLMODE_ON || !aCJKOptions.IsDoubleLinesEnabled())
152 0 : RemoveTabPage("asianlayout");
153 : }
154 0 : break;
155 : // paragraph styles
156 : case SFX_STYLE_FAMILY_PARA:
157 : {
158 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
159 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
160 0 : m_nIndentsId = AddTabPage("indents", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
161 :
162 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
163 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
164 0 : m_nAlignId = AddTabPage("alignment", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH) );
165 :
166 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
167 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
168 0 : m_nTextFlowId = AddTabPage("textflow", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH) );
169 :
170 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
171 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
172 0 : m_nAsianTypo = AddTabPage("asiantypo", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
173 :
174 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
175 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageRangesFunc fail!");
176 0 : m_nFontId = AddTabPage("font", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) );
177 :
178 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
179 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageRangesFunc fail!");
180 0 : m_nFontEffectId = AddTabPage("fonteffect", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) );
181 :
182 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), "GetTabPageCreatorFunc fail!");
183 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) , "GetTabPageRangesFunc fail!");
184 0 : m_nPositionId = AddTabPage("position", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) );
185 :
186 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), "GetTabPageCreatorFunc fail!");
187 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) , "GetTabPageRangesFunc fail!");
188 0 : m_nAsianLayoutId = AddTabPage("asianlayout", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) );
189 :
190 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
191 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
192 0 : m_nTabId = AddTabPage("tabs", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
193 :
194 : m_nOutlineId = AddTabPage("outline", SwParagraphNumTabPage::Create,
195 0 : SwParagraphNumTabPage::GetRanges);
196 : m_nDropCapsId = AddTabPage("dropcaps", SwDropCapsPage::Create,
197 0 : SwDropCapsPage::GetRanges );
198 :
199 : //UUUU add Area and Transparence TabPages
200 0 : m_nAreaId = AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
201 0 : m_nTransparenceId = AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
202 :
203 : //UUUU remove?
204 : //OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
205 : //OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
206 : //m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
207 :
208 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
209 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
210 0 : m_nBorderId = AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
211 :
212 : m_nConditionId = AddTabPage("condition", SwCondCollPage::Create,
213 0 : SwCondCollPage::GetRanges );
214 0 : if( (!bNewStyle && RES_CONDTXTFMTCOLL != static_cast<SwDocStyleSheet&>(rBase).GetCollection()->Which())
215 0 : || nHtmlMode & HTMLMODE_ON )
216 0 : RemoveTabPage("condition");
217 :
218 0 : SvtCJKOptions aCJKOptions;
219 0 : if(nHtmlMode & HTMLMODE_ON)
220 : {
221 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
222 0 : if (!rHtmlOpt.IsPrintLayoutExtension())
223 0 : RemoveTabPage("textflow");
224 0 : RemoveTabPage("asiantypo");
225 0 : RemoveTabPage("tabs");
226 0 : RemoveTabPage("outline");
227 0 : RemoveTabPage("asianlayout");
228 0 : if(!(nHtmlMode & HTMLMODE_FULL_STYLES))
229 : {
230 0 : RemoveTabPage("background");
231 0 : RemoveTabPage("dropcaps");
232 : }
233 : }
234 : else
235 : {
236 0 : if(!aCJKOptions.IsAsianTypographyEnabled())
237 0 : RemoveTabPage("asiantypo");
238 0 : if(!aCJKOptions.IsDoubleLinesEnabled())
239 0 : RemoveTabPage("asianlayout");
240 0 : }
241 : }
242 0 : break;
243 : // frame styles
244 : case SFX_STYLE_FAMILY_FRAME:
245 : {
246 : m_nTypeId = AddTabPage("type", SwFrmPage::Create,
247 0 : SwFrmPage::GetRanges);
248 : m_nOptionsId = AddTabPage("options", SwFrmAddPage::Create,
249 0 : SwFrmAddPage::GetRanges);
250 : m_nWrapId = AddTabPage("wrap", SwWrapTabPage::Create,
251 0 : SwWrapTabPage::GetRanges);
252 : //UUUU remove?
253 : //OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
254 : //OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
255 :
256 : //UUUU remove?
257 : //m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
258 : //OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
259 : //OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
260 :
261 : //UUUU add Area and Transparence TabPages
262 0 : m_nAreaId = AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
263 0 : m_nTransparenceId = AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
264 :
265 0 : m_nBorderId = AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
266 :
267 : m_nColumnId = AddTabPage("columns", SwColumnPage::Create,
268 0 : SwColumnPage::GetRanges );
269 :
270 0 : m_nMacroId = AddTabPage("macros", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
271 :
272 0 : break;
273 : }
274 : // page styles
275 : case SFX_STYLE_FAMILY_PAGE:
276 : {
277 : //UUUU remove?
278 : //OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
279 : //OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
280 : //m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
281 :
282 : //UUUU add Area and Transparence TabPages
283 0 : m_nAreaId = AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
284 0 : m_nTransparenceId = AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
285 :
286 0 : m_nHeaderId = AddTabPage("header", SvxHeaderPage::Create, SvxHeaderPage::GetRanges);
287 0 : m_nFooterId = AddTabPage("footer", SvxFooterPage::Create, SvxFooterPage::GetRanges);
288 :
289 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), "GetTabPageCreatorFunc fail!");
290 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ), "GetTabPageRangesFunc fail!");
291 : m_nPageId = AddTabPage("page",
292 0 : pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ),
293 0 : pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ) );
294 0 : if (0 == ::GetHtmlMode(pWrtShell->GetView().GetDocShell()))
295 : {
296 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
297 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
298 : m_nBorderId = AddTabPage("borders",
299 0 : pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
300 0 : m_nColumnId = AddTabPage("columns", SwColumnPage::Create, SwColumnPage::GetRanges );
301 : m_nFootNoteId = AddTabPage("footnotes",
302 : SwFootNotePage::Create,
303 0 : SwFootNotePage::GetRanges );
304 : m_nTextGridId = AddTabPage("textgrid",
305 : SwTextGridPage::Create,
306 0 : SwTextGridPage::GetRanges );
307 0 : SvtCJKOptions aCJKOptions;
308 0 : if(!aCJKOptions.IsAsianTypographyEnabled())
309 0 : RemoveTabPage("textgrid");
310 : }
311 : else
312 : {
313 0 : RemoveTabPage("borders");
314 0 : RemoveTabPage("columns");
315 0 : RemoveTabPage("footnotes");
316 0 : RemoveTabPage("textgrid");
317 : }
318 : }
319 0 : break;
320 : // numbering styles
321 : case SFX_STYLE_FAMILY_PSEUDO:
322 : {
323 0 : m_nSingleId = AddTabPage("numbering", RID_SVXPAGE_PICK_SINGLE_NUM);
324 0 : m_nBulletId = AddTabPage("bullets", RID_SVXPAGE_PICK_BULLET);
325 0 : m_nNumId = AddTabPage("outline", RID_SVXPAGE_PICK_NUM);
326 0 : m_nBmpId = AddTabPage("graphics", RID_SVXPAGE_PICK_BMP);
327 0 : m_nNumOptId = AddTabPage("options", RID_SVXPAGE_NUM_OPTIONS );
328 0 : m_nNumPosId = AddTabPage("position", RID_SVXPAGE_NUM_POSITION );
329 : }
330 0 : break;
331 :
332 : default:
333 : OSL_ENSURE(false, "wrong family");
334 : }
335 :
336 0 : if (!sPage.isEmpty())
337 0 : SetCurPageId(sPage);
338 0 : }
339 :
340 0 : short SwTemplateDlg::Ok()
341 : {
342 0 : short nRet = SfxTabDialog::Ok();
343 0 : if( RET_OK == nRet )
344 : {
345 : const SfxPoolItem *pOutItem, *pExItem;
346 0 : if( SfxItemState::SET == pExampleSet->GetItemState(
347 0 : SID_ATTR_NUMBERING_RULE, false, &pExItem ) &&
348 0 : ( !GetOutputItemSet() ||
349 : SfxItemState::SET != GetOutputItemSet()->GetItemState(
350 0 : SID_ATTR_NUMBERING_RULE, false, &pOutItem ) ||
351 0 : *pExItem != *pOutItem ))
352 : {
353 0 : if( GetOutputItemSet() )
354 0 : const_cast<SfxItemSet*>(GetOutputItemSet())->Put( *pExItem );
355 : else
356 0 : nRet = RET_CANCEL;
357 : }
358 : }
359 : else
360 : //JP 09.01.98 Bug #46446#:
361 : // that's the Ok-Handler, so OK has to be default!
362 0 : nRet = RET_OK;
363 0 : return nRet;
364 : }
365 :
366 0 : void SwTemplateDlg::RefreshInputSet()
367 : {
368 0 : SfxItemSet* pInSet = GetInputSetImpl();
369 0 : pInSet->ClearItem();
370 0 : pInSet->SetParent( &GetStyleSheet().GetItemSet() );
371 0 : }
372 :
373 0 : void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
374 : {
375 : // set style's and metric's names
376 0 : OUString sNumCharFormat, sBulletCharFormat;
377 0 : SwStyleNameMapper::FillUIName( RES_POOLCHR_NUM_LEVEL, sNumCharFormat);
378 0 : SwStyleNameMapper::FillUIName( RES_POOLCHR_BUL_LEVEL, sBulletCharFormat);
379 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
380 :
381 0 : if (nId == m_nFontId)
382 : {
383 : OSL_ENSURE(::GetActiveView(), "no active view");
384 :
385 : SvxFontListItem aFontListItem( *static_cast<const SvxFontListItem*>(::GetActiveView()->
386 0 : GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) ) );
387 :
388 0 : aSet.Put (SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
389 0 : sal_uInt32 nFlags = 0;
390 0 : if(rPage.GetItemSet().GetParent() && 0 == (nHtmlMode & HTMLMODE_ON ))
391 0 : nFlags = SVX_RELATIVE_MODE;
392 0 : if( SFX_STYLE_FAMILY_CHAR == nType )
393 0 : nFlags = nFlags|SVX_PREVIEW_CHARACTER;
394 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlags));
395 0 : rPage.PageCreated(aSet);
396 : }
397 0 : else if (nId == m_nFontEffectId)
398 : {
399 0 : sal_uInt32 nFlags = SVX_ENABLE_FLASH;
400 0 : if( SFX_STYLE_FAMILY_CHAR == nType )
401 0 : nFlags = nFlags|SVX_PREVIEW_CHARACTER;
402 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlags));
403 0 : rPage.PageCreated(aSet);
404 : }
405 0 : else if (nId == m_nPositionId)
406 : {
407 0 : if( SFX_STYLE_FAMILY_CHAR == nType )
408 : {
409 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_PREVIEW_CHARACTER));
410 0 : rPage.PageCreated(aSet);
411 : }
412 : }
413 0 : else if (nId == m_nAsianLayoutId)
414 : {
415 0 : if( SFX_STYLE_FAMILY_CHAR == nType )
416 : {
417 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_PREVIEW_CHARACTER));
418 0 : rPage.PageCreated(aSet);
419 : }
420 : }
421 0 : else if (nId == m_nIndentsId)
422 : {
423 0 : if( rPage.GetItemSet().GetParent() )
424 : {
425 0 : aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST,MM50/10));
426 0 : aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x000F));
427 0 : rPage.PageCreated(aSet);
428 : }
429 :
430 : }
431 0 : else if (nId == m_nOutlineId)
432 : {
433 : // handle if the current paragraph style is assigned to a list level of outline style,
434 0 : SwTextFormatColl* pTmpColl = pWrtShell->FindTextFormatCollByName( GetStyleSheet().GetName() );
435 0 : if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
436 : {
437 0 : static_cast<SwParagraphNumTabPage&>(rPage).DisableOutline() ;
438 0 : static_cast<SwParagraphNumTabPage&>(rPage).DisableNumbering();
439 : }//<-end
440 0 : ListBox & rBox = static_cast<SwParagraphNumTabPage&>(rPage).GetStyleBox();
441 0 : SfxStyleSheetBasePool* pPool = pWrtShell->GetView().GetDocShell()->GetStyleSheetPool();
442 0 : pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL);
443 0 : const SfxStyleSheetBase* pBase = pPool->First();
444 0 : std::set<OUString> aNames;
445 0 : while(pBase)
446 : {
447 0 : aNames.insert(pBase->GetName());
448 0 : pBase = pPool->Next();
449 : }
450 0 : for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it)
451 0 : rBox.InsertEntry(*it);
452 : }
453 0 : else if (nId == m_nAlignId)
454 : {
455 0 : aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
456 0 : rPage.PageCreated(aSet);
457 : }
458 0 : else if (nId == m_nTypeId)
459 : {
460 0 : static_cast<SwFrmPage&>(rPage).SetNewFrame( true );
461 0 : static_cast<SwFrmPage&>(rPage).SetFormatUsed( true );
462 : }
463 0 : else if (nId == m_nOptionsId)
464 : {
465 0 : static_cast<SwFrmAddPage&>(rPage).SetFormatUsed(true);
466 0 : static_cast<SwFrmAddPage&>(rPage).SetNewFrame(true);
467 : }
468 0 : else if (nId == m_nWrapId)
469 : {
470 0 : static_cast<SwWrapTabPage&>(rPage).SetFormatUsed( true, false );
471 : }
472 0 : else if (nId == m_nColumnId)
473 : {
474 0 : if( nType == SFX_STYLE_FAMILY_FRAME )
475 0 : static_cast<SwColumnPage&>(rPage).SetFrmMode(true);
476 0 : static_cast<SwColumnPage&>(rPage).SetFormatUsed( true );
477 : }
478 : //UUUU do not remove; many other style dialog combinations still use the SfxTabPage
479 : // for the SvxBrushItem (see RID_SVXPAGE_BACKGROUND)
480 0 : else if (nId == m_nBackgroundId)
481 : {
482 0 : SvxBackgroundTabFlags nFlagType = SvxBackgroundTabFlags::NONE;
483 0 : if( SFX_STYLE_FAMILY_PARA == nType )
484 0 : nFlagType |= SvxBackgroundTabFlags::SHOW_PARACTL;
485 0 : if( SFX_STYLE_FAMILY_CHAR != nType )
486 0 : nFlagType |= SvxBackgroundTabFlags::SHOW_SELECTOR;
487 0 : if( SFX_STYLE_FAMILY_FRAME == nType )
488 0 : nFlagType |= SvxBackgroundTabFlags::ENABLE_TRANSPARENCY;
489 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(nFlagType)));
490 0 : rPage.PageCreated(aSet);
491 : }
492 0 : else if (nId == m_nConditionId)
493 : {
494 : static_cast<SwCondCollPage&>(rPage).SetCollection(
495 0 : static_cast<SwDocStyleSheet&>(GetStyleSheet()).GetCollection(), bNewStyle );
496 : }
497 0 : else if (nId == m_nPageId)
498 : {
499 0 : if(0 == (nHtmlMode & HTMLMODE_ON ))
500 : {
501 0 : std::vector<OUString> aList;
502 0 : OUString aNew;
503 0 : SwStyleNameMapper::FillUIName( RES_POOLCOLL_TEXT, aNew );
504 0 : aList.push_back( aNew );
505 0 : if( pWrtShell )
506 : {
507 : SfxStyleSheetBasePool* pStyleSheetPool = pWrtShell->
508 0 : GetView().GetDocShell()->GetStyleSheetPool();
509 0 : pStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_PARA);
510 0 : SfxStyleSheetBase *pFirstStyle = pStyleSheetPool->First();
511 0 : while(pFirstStyle)
512 : {
513 0 : aList.push_back( pFirstStyle->GetName() );
514 0 : pFirstStyle = pStyleSheetPool->Next();
515 : }
516 : }
517 : //UUUU set DrawingLayer FillStyles active
518 0 : aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true));
519 0 : aSet.Put(SfxStringListItem(SID_COLLECT_LIST, &aList));
520 0 : rPage.PageCreated(aSet);
521 : }
522 : }
523 0 : else if (nId == m_nMacroId)
524 : {
525 0 : SfxAllItemSet aNewSet(*aSet.GetPool());
526 0 : aNewSet.Put( SwMacroAssignDlg::AddEvents(MACASSGN_ALLFRM) );
527 0 : if ( pWrtShell )
528 0 : rPage.SetFrame( pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() );
529 0 : rPage.PageCreated(aNewSet);
530 : }
531 0 : else if (nId == m_nNumId)
532 : {
533 0 : aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFormat));
534 0 : aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat));
535 0 : rPage.PageCreated(aSet);
536 : }
537 0 : else if (nId == m_nNumOptId)
538 : {
539 :
540 0 : aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFormat));
541 0 : aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat));
542 : // collect character styles
543 0 : ScopedVclPtrInstance< ListBox > rCharFormatLB(this);
544 0 : rCharFormatLB->Clear();
545 0 : rCharFormatLB->InsertEntry( SwViewShell::GetShellRes()->aStrNone );
546 0 : SwDocShell* pDocShell = ::GetActiveWrtShell()->GetView().GetDocShell();
547 0 : ::FillCharStyleListBox(*rCharFormatLB.get(), pDocShell);
548 :
549 0 : std::vector<OUString> aList;
550 0 : for(sal_Int32 j = 0; j < rCharFormatLB->GetEntryCount(); j++)
551 0 : aList.push_back( rCharFormatLB->GetEntry(j) );
552 :
553 0 : aSet.Put( SfxStringListItem( SID_CHAR_FMT_LIST_BOX,&aList ) ) ;
554 0 : FieldUnit eMetric = ::GetDfltMetric(pDocShell->ISA(SwWebDocShell));
555 0 : aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< sal_uInt16 >(eMetric)));
556 0 : rPage.PageCreated(aSet);
557 : }
558 0 : else if (nId == m_nNumPosId)
559 : {
560 0 : SwDocShell* pDocShell = ::GetActiveWrtShell()->GetView().GetDocShell();
561 0 : FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, pDocShell));
562 :
563 0 : aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< sal_uInt16 >(eMetric)));
564 0 : rPage.PageCreated(aSet);
565 : }
566 0 : else if (nId == m_nBulletId)
567 : {
568 0 : aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat));
569 0 : rPage.PageCreated(aSet);
570 : }
571 0 : else if (nId == m_nHeaderId)
572 : {
573 0 : if(0 == (nHtmlMode & HTMLMODE_ON ))
574 : {
575 0 : static_cast<SvxHeaderPage&>(rPage).EnableDynamicSpacing();
576 : }
577 :
578 : //UUUU set DrawingLayer FillStyles active
579 0 : aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true));
580 0 : rPage.PageCreated(aSet);
581 : }
582 0 : else if (nId == m_nFooterId)
583 : {
584 0 : if(0 == (nHtmlMode & HTMLMODE_ON ))
585 : {
586 0 : static_cast<SvxFooterPage&>(rPage).EnableDynamicSpacing();
587 : }
588 :
589 : //UUUU set DrawingLayer FillStyles active
590 0 : aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true));
591 0 : rPage.PageCreated(aSet);
592 : }
593 0 : else if (nId == m_nBorderId)
594 : {
595 0 : if( SFX_STYLE_FAMILY_PARA == nType )
596 : {
597 0 : aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::PARA)));
598 : }
599 0 : else if( SFX_STYLE_FAMILY_FRAME == nType )
600 : {
601 0 : aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::FRAME)));
602 : }
603 0 : rPage.PageCreated(aSet);
604 : }
605 : //UUUU inits for Area and Transparency TabPages
606 : // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
607 : // the color table) need to be added as items (e.g. SvxColorTableItem) to make
608 : // these pages find the needed attributes for fill style suggestions.
609 : // These are added in SwDocStyleSheet::GetItemSet() for the SFX_STYLE_FAMILY_PARA on
610 : // demand, but could also be directly added from the DrawModel.
611 0 : else if (nId == m_nAreaId)
612 : {
613 0 : aSet.Put(GetStyleSheet().GetItemSet());
614 :
615 : // add flag for direct graphic content selection
616 0 : aSet.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
617 :
618 0 : rPage.PageCreated(aSet);
619 : }
620 0 : else if (nId == m_nTransparenceId)
621 : {
622 0 : rPage.PageCreated(GetStyleSheet().GetItemSet());
623 0 : }
624 0 : }
625 :
626 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|