xref: /aoo42x/main/sw/source/ui/fmtui/tmpdlg.cxx (revision 870262e3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #ifdef SW_DLLIMPLEMENTATION
28 #undef SW_DLLIMPLEMENTATION
29 #endif
30 
31 
32 #include <hintids.hxx>
33 
34 #ifndef _SVSTDARR_STRINGSSORTDTOR
35 #define _SVSTDARR_STRINGSSORTDTOR
36 #include <svl/svstdarr.hxx>
37 #endif
38 #include <vcl/msgbox.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <svx/hdft.hxx>
41 #include <editeng/flstitem.hxx>
42 #include <svx/htmlmode.hxx>
43 #include <svtools/htmlcfg.hxx>
44 #include <svl/cjkoptions.hxx>
45 #include <numpara.hxx>
46 #include <fmtclds.hxx>
47 #include <swtypes.hxx>
48 #include <swmodule.hxx>
49 #include <errhdl.hxx>		// fuer Create-Methoden
50 #include <wrtsh.hxx>
51 #ifndef _VIEW_HXX
52 #include <view.hxx>
53 #endif
54 #include <wdocsh.hxx>
55 #include <viewopt.hxx>
56 #include <pgfnote.hxx>
57 #ifndef _PGFGRID_HXX
58 #include <pggrid.hxx>
59 #endif
60 #ifndef _TMPDLG_HXX
61 #include <tmpdlg.hxx>		// der Dialog
62 #endif
63 #include <column.hxx>		// Spalten
64 #include <drpcps.hxx>		// Initialen
65 #include <frmpage.hxx>		// Rahmen
66 #include <wrap.hxx>			// Rahmen
67 #include <frmmgr.hxx>		// Rahmen
68 #include <ccoll.hxx>		// CondColl
69 #include <swuiccoll.hxx>
70 #include <docstyle.hxx>		//
71 #include <fmtcol.hxx>		//
72 #include <macassgn.hxx>		//
73 #include <poolfmt.hxx>
74 #include <uitool.hxx>
75 #include <shellres.hxx>
76 
77 #ifndef _CMDID_H
78 #include <cmdid.h>
79 #endif
80 #ifndef _HELPID_H
81 #include <helpid.h>
82 #endif
83 #ifndef _GLOBALS_HRC
84 #include <globals.hrc>
85 #endif
86 #ifndef _FMTUI_HRC
87 #include <fmtui.hrc>
88 #endif
89 #include <SwStyleNameMapper.hxx>
90 #include <svx/svxids.hrc>
91 #include <svl/stritem.hxx>
92 #include <svl/aeitem.hxx>
93 #include <svl/slstitm.hxx>
94 #include <svl/eitem.hxx>
95 #include <svl/intitem.hxx>
96 #include <svx/svxdlg.hxx>
97 #include <svx/dialogs.hrc>
98 #include <svx/flagsdef.hxx>
99 
100 extern SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
101 
102 /*--------------------------------------------------------------------
103 	Beschreibung:	Der Traeger des Dialoges
104  --------------------------------------------------------------------*/
105 
SwTemplateDlg(Window * pParent,SfxStyleSheetBase & rBase,sal_uInt16 nRegion,const sal_uInt16 nSlot,SwWrtShell * pActShell,sal_Bool bNew)106 SwTemplateDlg::SwTemplateDlg(Window*			pParent,
107 							 SfxStyleSheetBase& rBase,
108 							 sal_uInt16 			nRegion,
109 							 const sal_uInt16 nSlot,
110 							 SwWrtShell* 		pActShell,
111 							 sal_Bool 				bNew ) :
112 	SfxStyleDialog(	pParent,
113 					SW_RES(DLG_TEMPLATE_BASE + nRegion),
114 					rBase,
115 					sal_False,
116 					0 ),
117 	nType( nRegion ),
118 	pWrtShell(pActShell),
119 	bNewStyle(bNew)
120 {
121 	FreeResource();
122 
123 	nHtmlMode = ::GetHtmlMode(pWrtShell->GetView().GetDocShell());
124 	SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
125     DBG_ASSERT(pFact, "Dialogdiet fail!");
126 	// TabPages zusammenfieseln
127 	switch( nRegion )
128 	{
129 		// Zeichenvorlagen
130 		case SFX_STYLE_FAMILY_CHAR:
131 		{
132             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
133             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) , "GetTabPageRangesFunc fail!");
134             AddTabPage(TP_CHAR_STD, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) );
135 
136             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
137             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) , "GetTabPageRangesFunc fail!");
138             AddTabPage(TP_CHAR_EXT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) );
139 
140             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), "GetTabPageCreatorFunc fail!");
141             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) , "GetTabPageRangesFunc fail!");
142             AddTabPage(TP_CHAR_POS, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) );
143 
144             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), "GetTabPageCreatorFunc fail!");
145             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) , "GetTabPageRangesFunc fail!");
146             AddTabPage(TP_CHAR_TWOLN, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) );
147 
148             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
149             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) , "GetTabPageRangesFunc fail!");
150             AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
151 
152             SvtCJKOptions aCJKOptions;
153             if(nHtmlMode & HTMLMODE_ON || !aCJKOptions.IsDoubleLinesEnabled())
154                 RemoveTabPage(TP_CHAR_TWOLN);
155         }
156         break;
157 		// Absatzvorlagen
158 		case SFX_STYLE_FAMILY_PARA:
159 		{
160                 DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
161                 DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
162 				AddTabPage( TP_PARA_STD,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
163 
164                 DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
165                 DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
166 				AddTabPage( TP_PARA_ALIGN,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH) );
167 
168                 DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
169                 DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
170 				AddTabPage( TP_PARA_EXT,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH) );
171 
172                 DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
173                 DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
174 				AddTabPage( TP_PARA_ASIAN,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
175 
176                 DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
177                 DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageRangesFunc fail!");
178                 AddTabPage(TP_CHAR_STD, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) );
179 
180                 DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
181                 DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageRangesFunc fail!");
182                 AddTabPage(TP_CHAR_EXT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) );
183 
184                 DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), "GetTabPageCreatorFunc fail!");
185                 DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) , "GetTabPageRangesFunc fail!");
186                 AddTabPage(TP_CHAR_POS, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_POSITION ) );
187 
188                 DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), "GetTabPageCreatorFunc fail!");
189                 DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) , "GetTabPageRangesFunc fail!");
190                 AddTabPage(TP_CHAR_TWOLN, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_TWOLINES ) );
191 
192 
193             DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
194             DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
195 			AddTabPage( TP_TABULATOR,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
196 
197 
198 			AddTabPage(TP_NUMPARA,   SwParagraphNumTabPage::Create,
199 									SwParagraphNumTabPage::GetRanges);
200 			AddTabPage(TP_DROPCAPS, 	SwDropCapsPage::Create,
201 										SwDropCapsPage::GetRanges );
202             //UUUU remove?
203             //DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
204             //DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
205             //AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
206 
207             //UUUU add Area and Transparence TabPages
208             AddTabPage(RID_SVXPAGE_AREA);
209             AddTabPage(RID_SVXPAGE_TRANSPARENCE);
210 
211             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
212             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
213             AddTabPage(TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
214 
215 			AddTabPage( TP_CONDCOLL,    SwCondCollPage::Create,
216 										SwCondCollPage::GetRanges );
217 			if( (!bNewStyle && RES_CONDTXTFMTCOLL != ((SwDocStyleSheet&)rBase).GetCollection()->Which())
218 			|| nHtmlMode & HTMLMODE_ON )
219 				RemoveTabPage(TP_CONDCOLL);
220 
221             SvtCJKOptions aCJKOptions;
222             if(nHtmlMode & HTMLMODE_ON)
223 			{
224 				SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
225 				if (!pHtmlOpt->IsPrintLayoutExtension())
226 					RemoveTabPage(TP_PARA_EXT);
227 				RemoveTabPage(TP_PARA_ASIAN);
228 				RemoveTabPage(TP_TABULATOR);
229 				RemoveTabPage(TP_NUMPARA);
230 				RemoveTabPage(TP_CHAR_TWOLN);
231 				if(!(nHtmlMode & HTMLMODE_FULL_STYLES))
232 				{
233 					RemoveTabPage(TP_BACKGROUND);
234 					RemoveTabPage(TP_DROPCAPS);
235 				}
236 				if(!(nHtmlMode & HTMLMODE_PARA_BORDER))
237 					RemoveTabPage(TP_BORDER);
238 			}
239             else
240             {
241                 if(!aCJKOptions.IsAsianTypographyEnabled())
242                     RemoveTabPage(TP_PARA_ASIAN);
243                 if(!aCJKOptions.IsDoubleLinesEnabled())
244                     RemoveTabPage(TP_CHAR_TWOLN);
245             }
246         }
247 		break;
248 		// Rahmenvorlagen
249 		case SFX_STYLE_FAMILY_FRAME:
250 		{
251 			AddTabPage(TP_FRM_STD, 		SwFrmPage::Create,
252 										SwFrmPage::GetRanges );
253 			AddTabPage(TP_FRM_ADD,		SwFrmAddPage::Create,
254 										SwFrmAddPage::GetRanges );
255 			AddTabPage(TP_FRM_WRAP, 	SwWrapTabPage::Create,
256 										SwWrapTabPage::GetRanges );
257 
258             //UUUU remove?
259             //DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
260             //DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
261 
262             //UUUU remove?
263             //AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
264 
265             //UUUU add Area and Transparence TabPages
266             AddTabPage(RID_SVXPAGE_AREA);
267             AddTabPage(RID_SVXPAGE_TRANSPARENCE);
268 
269             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
270             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
271             AddTabPage(TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
272 
273 			AddTabPage(TP_COLUMN, 		SwColumnPage::Create,
274 										SwColumnPage::GetRanges );
275 
276 			AddTabPage( TP_MACRO_ASSIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
277 
278 		break;
279 		}
280 		// Seitenvorlagen
281 		case SFX_STYLE_FAMILY_PAGE:
282 		{
283             //UUUU remove?
284             //DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
285             //DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
286             //AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
287 
288             //UUUU add Area and Transparence TabPages
289             AddTabPage(RID_SVXPAGE_AREA);
290             AddTabPage(RID_SVXPAGE_TRANSPARENCE);
291 
292             AddTabPage(TP_HEADER_PAGE,		String(SW_RES(STR_PAGE_HEADER)),
293                                             SvxHeaderPage::Create,
294                                             SvxHeaderPage::GetRanges );
295             AddTabPage(TP_FOOTER_PAGE,		String(SW_RES(STR_PAGE_FOOTER)),
296                                             SvxFooterPage::Create,
297                                             SvxFooterPage::GetRanges );
298             if ( nSlot == FN_FORMAT_PAGE_COLUMN_DLG )
299             {
300                 SetCurPageId(TP_COLUMN);
301             }
302             else if ( nSlot == FN_FORMAT_PAGE_SETTING_DLG )
303             {
304                 SetCurPageId(TP_PAGE_STD);
305             }
306 
307             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), "GetTabPageCreatorFunc fail!");
308             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ), "GetTabPageRangesFunc fail!");
309             AddTabPage(TP_PAGE_STD,			String(SW_RES(STR_PAGE_STD)),
310                                             pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ),
311                                             pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ),
312                                             sal_False,
313                                             1 ); // nach der Verwalten-Page
314             if(!pActShell || 0 == ::GetHtmlMode(pWrtShell->GetView().GetDocShell()))
315             {
316                 DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
317                 DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
318                 AddTabPage(TP_BORDER, 			String(SW_RES(STR_PAGE_BORDER)),
319                                 pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
320                 AddTabPage(TP_COLUMN,			String(SW_RES(STR_PAGE_COLUMN)),
321                                                 SwColumnPage::Create,
322                                                 SwColumnPage::GetRanges );
323                 AddTabPage(TP_FOOTNOTE_PAGE,	String(SW_RES(STR_PAGE_FOOTNOTE)),
324                                                 SwFootNotePage::Create,
325                                                 SwFootNotePage::GetRanges );
326                 AddTabPage(TP_TEXTGRID_PAGE,    String(SW_RES(STR_PAGE_TEXTGRID)),
327                                                 SwTextGridPage::Create,
328                                                 SwTextGridPage::GetRanges );
329                 SvtCJKOptions aCJKOptions;
330                 if(!aCJKOptions.IsAsianTypographyEnabled())
331                     RemoveTabPage(TP_TEXTGRID_PAGE);
332             }
333 
334 
335         }
336         break;
337         // Numerierungsvorlagen
338 		case SFX_STYLE_FAMILY_PSEUDO:
339 		{
340             AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
341             AddTabPage( RID_SVXPAGE_PICK_BULLET );
342             AddTabPage( RID_SVXPAGE_PICK_NUM );
343             AddTabPage( RID_SVXPAGE_PICK_BMP);
344             AddTabPage( RID_SVXPAGE_NUM_OPTIONS );
345             AddTabPage( RID_SVXPAGE_NUM_POSITION );
346 
347 
348 /*			const SfxPoolItem* pItem;
349 			if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState(
350 				FN_PARAM_ACT_NUMBER, sal_False, &pItem ))
351 			{
352 //				pActNum = (ActNumberFormat*)((const SwPtrItem*)pItem)->GetValue();
353 			}
354 */
355 		}
356 		break;
357 
358 		default:
359 			ASSERT(sal_False, "Wrong family");
360 
361 	}
362 }
363 
364 /*--------------------------------------------------------------------
365 	Beschreibung:
366  --------------------------------------------------------------------*/
367 
~SwTemplateDlg()368 SwTemplateDlg::~SwTemplateDlg()
369 {
370 }
371 
372 /*--------------------------------------------------------------------
373 	Beschreibung:
374  --------------------------------------------------------------------*/
375 
Ok()376 short SwTemplateDlg::Ok()
377 {
378 	short nRet = SfxTabDialog::Ok();
379 	if( RET_OK == nRet )
380 	{
381 		const SfxPoolItem *pOutItem, *pExItem;
382 		if( SFX_ITEM_SET == pExampleSet->GetItemState(
383 			SID_ATTR_NUMBERING_RULE, sal_False, &pExItem ) &&
384 			( !GetOutputItemSet() ||
385 			SFX_ITEM_SET != GetOutputItemSet()->GetItemState(
386 			SID_ATTR_NUMBERING_RULE, sal_False, &pOutItem ) ||
387 			*pExItem != *pOutItem ))
388 		{
389 			if( GetOutputItemSet() )
390 				((SfxItemSet*)GetOutputItemSet())->Put( *pExItem );
391 			else
392 				nRet = RET_CANCEL;
393 		}
394 	}
395 	else
396 		//JP 09.01.98 Bug #46446#:
397 		// das ist der Ok - Handler also muss auf OK defaultet werden!
398 		nRet = RET_OK;
399 	return nRet;
400 }
401 
402 /*--------------------------------------------------------------------
403 	Beschreibung:
404  --------------------------------------------------------------------*/
405 
GetRefreshedSet()406 const SfxItemSet* SwTemplateDlg::GetRefreshedSet()
407 {
408 	SfxItemSet* pInSet = GetInputSetImpl();
409 	pInSet->ClearItem();
410 	pInSet->SetParent( &GetStyleSheet().GetItemSet() );
411 	return pInSet;
412 }
413 
414 /*--------------------------------------------------------------------
415 	Beschreibung:
416  --------------------------------------------------------------------*/
417 
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)418 void SwTemplateDlg::PageCreated(sal_uInt16 nId,SfxTabPage &rPage)
419 {
420     //Namen der Vorlagen und Metric setzen
421     String sNumCharFmt,sBulletCharFmt;
422     SwStyleNameMapper::FillUIName(RES_POOLCHR_NUM_LEVEL,sNumCharFmt);
423     SwStyleNameMapper::FillUIName(RES_POOLCHR_BUL_LEVEL,sBulletCharFmt);
424     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
425 
426     switch(nId)
427     {
428         case TP_CHAR_STD:
429         {
430             ASSERT(::GetActiveView(),"keine View aktiv");
431 
432             SvxFontListItem aFontListItem(*((SvxFontListItem*)::GetActiveView()->
433                 GetDocShell()->GetItem(SID_ATTR_CHAR_FONTLIST)));
434 
435             aSet.Put(SvxFontListItem(aFontListItem.GetFontList(),SID_ATTR_CHAR_FONTLIST));
436             sal_uInt32 nFlags = 0;
437             if(rPage.GetItemSet().GetParent() && 0 == (nHtmlMode & HTMLMODE_ON))
438                 nFlags = SVX_RELATIVE_MODE;
439             if(SFX_STYLE_FAMILY_CHAR == nType)
440                 nFlags = nFlags | SVX_PREVIEW_CHARACTER;
441             aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,nFlags));
442             rPage.PageCreated(aSet);
443             break;
444         }
445 
446         case TP_CHAR_EXT:
447         {
448             sal_uInt32 nFlags = SVX_ENABLE_FLASH;
449             if(SFX_STYLE_FAMILY_CHAR == nType)
450                 nFlags = nFlags | SVX_PREVIEW_CHARACTER;
451             aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,nFlags));
452             rPage.PageCreated(aSet);
453             break;
454         }
455 
456         case TP_CHAR_POS:
457         {
458             if(SFX_STYLE_FAMILY_CHAR == nType)
459             {
460                 aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
461                 rPage.PageCreated(aSet);
462             }
463             break;
464         }
465 
466         case TP_CHAR_TWOLN:
467         {
468             if(SFX_STYLE_FAMILY_CHAR == nType)
469             {
470                 aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
471                 rPage.PageCreated(aSet);
472             }
473             break;
474         }
475 
476         case TP_PARA_STD:
477         {
478             if(rPage.GetItemSet().GetParent())
479             {
480                 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST,MM50 / 10));
481                 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x000F));
482                 rPage.PageCreated(aSet);
483             }
484 
485             break;
486         }
487 
488         case TP_NUMPARA:
489         {
490             //-->#outlinelevel added by zhaojianwei
491             //  handle if the current paragraph style is assigned to a list level of outline style,
492             SwTxtFmtColl* pTmpColl = pWrtShell->FindTxtFmtCollByName(GetStyleSheet().GetName());
493             if(pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle())
494             {
495                 ((SwParagraphNumTabPage&)rPage).DisableOutline();
496                 ((SwParagraphNumTabPage&)rPage).DisableNumbering();
497             }//<-end
498             ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox();
499             SfxStyleSheetBasePool* pPool = pWrtShell->GetView().GetDocShell()->GetStyleSheetPool();
500             pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO,SFXSTYLEBIT_ALL);
501             const SfxStyleSheetBase* pBase = pPool->First();
502             SvStringsSortDtor aNames;
503             while(pBase)
504             {
505                 aNames.Insert(new String(pBase->GetName()));
506                 pBase = pPool->Next();
507             }
508             for(sal_uInt16 i = 0; i < aNames.Count(); i++)
509                 rBox.InsertEntry(*aNames.GetObject(i));
510             break;
511         }
512 
513         case TP_PARA_ALIGN:
514         {
515             aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,sal_True));
516             rPage.PageCreated(aSet);
517             break;
518         }
519 
520         case TP_FRM_STD:
521         {
522             ((SwFrmPage&)rPage).SetNewFrame(sal_True);
523             ((SwFrmPage&)rPage).SetFormatUsed(sal_True);
524             break;
525         }
526 
527         case TP_FRM_ADD:
528         {
529             ((SwFrmAddPage&)rPage).SetFormatUsed(sal_True);
530             ((SwFrmAddPage&)rPage).SetNewFrame(sal_True);
531             break;
532         }
533 
534         case TP_FRM_WRAP:
535         {
536             ((SwWrapTabPage&)rPage).SetFormatUsed(sal_True,sal_False);
537             break;
538         }
539 
540         case TP_COLUMN:
541         {
542             if(nType == SFX_STYLE_FAMILY_FRAME)
543                 ((SwColumnPage&)rPage).SetFrmMode(sal_True);
544             ((SwColumnPage&)rPage).SetFormatUsed(sal_True);
545             break;
546         }
547 
548         //UUUU do not remove; many other style dialog combinations still use the SfxTabPage
549         // for the SvxBrushItem (see RID_SVXPAGE_BACKGROUND)
550         case TP_BACKGROUND:
551         {
552             sal_Int32 nFlagType = 0;
553             if(SFX_STYLE_FAMILY_PARA == nType)
554                 nFlagType |= SVX_SHOW_PARACTL;
555             if(SFX_STYLE_FAMILY_CHAR != nType)
556                 nFlagType |= SVX_SHOW_SELECTOR;
557             if(SFX_STYLE_FAMILY_FRAME == nType)
558                 nFlagType |= SVX_ENABLE_TRANSPARENCY;
559             aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,nFlagType));
560             rPage.PageCreated(aSet);
561             break;
562         }
563 
564         case TP_CONDCOLL:
565         {
566             ((SwCondCollPage&)rPage).SetCollection(
567                 ((SwDocStyleSheet&)GetStyleSheet()).GetCollection(),bNewStyle);
568             break;
569         }
570 
571         case TP_PAGE_STD:
572         {
573             if(0 == (nHtmlMode & HTMLMODE_ON))
574             {
575                 List aList;
576                 String* pNew = new String;
577                 SwStyleNameMapper::FillUIName(RES_POOLCOLL_TEXT,*pNew);
578                 aList.Insert(pNew,(sal_uLong)0);
579 
580                 if(pWrtShell)
581                 {
582                     SfxStyleSheetBasePool* pStyleSheetPool = pWrtShell->GetView().GetDocShell()->GetStyleSheetPool();
583                     pStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_PARA);
584                     SfxStyleSheetBase *pFirstStyle = pStyleSheetPool->First();
585 
586                     while(pFirstStyle)
587                     {
588                         aList.Insert(new String(pFirstStyle->GetName()), aList.Count());
589                         pFirstStyle = pStyleSheetPool->Next();
590                     }
591                 }
592 
593                 //UUUU set DrawingLayer FillStyles active
594                 aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true));
595                 aSet.Put(SfxStringListItem(SID_COLLECT_LIST, &aList));
596                 rPage.PageCreated(aSet);
597 
598                 for(sal_uInt16 i = (sal_uInt16)aList.Count(); i; --i)
599                 {
600                     delete (String*)aList.Remove(i);
601                 }
602             }
603 
604             break;
605         }
606 
607         case TP_MACRO_ASSIGN:
608         {
609             SfxAllItemSet aNewSet(*aSet.GetPool());
610             aNewSet.Put(SwMacroAssignDlg::AddEvents(MACASSGN_ALLFRM));
611             if(pWrtShell)
612                 rPage.SetFrame(pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface());
613             rPage.PageCreated(aNewSet);
614             break;
615         }
616 
617         case RID_SVXPAGE_PICK_NUM:
618         {
619                 aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFmt));
620                 aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
621                 rPage.PageCreated(aSet);
622             break;
623         }
624 
625         case RID_SVXPAGE_NUM_OPTIONS:
626         {
627             aSet.Put(SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFmt));
628             aSet.Put(SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
629             // Zeichenvorlagen sammeln
630             ListBox rCharFmtLB(this);
631             rCharFmtLB.Clear();
632             rCharFmtLB.InsertEntry(ViewShell::GetShellRes()->aStrNone);
633             SwDocShell* pDocShell = ::GetActiveWrtShell()->GetView().GetDocShell();
634             ::FillCharStyleListBox(rCharFmtLB,pDocShell);
635             List aList;
636             for(sal_uInt16 j = 0; j < rCharFmtLB.GetEntryCount(); j++)
637             {
638 
639                 aList.Insert(new XubString(rCharFmtLB.GetEntry(j)),LIST_APPEND);
640             }
641             aSet.Put(SfxStringListItem(SID_CHAR_FMT_LIST_BOX,&aList));
642             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell,pDocShell));
643             aSet.Put(SfxAllEnumItem(SID_METRIC_ITEM,static_cast<sal_uInt16>(eMetric)));
644             rPage.PageCreated(aSet);
645             for(sal_uInt16 i = (sal_uInt16)aList.Count(); i; --i)
646                 delete (XubString*)aList.Remove(i);
647             aList.Clear();
648             break;
649         }
650 
651         case RID_SVXPAGE_NUM_POSITION:
652         {
653             SwDocShell* pDocShell = ::GetActiveWrtShell()->GetView().GetDocShell();
654             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell,pDocShell));
655 
656             aSet.Put(SfxAllEnumItem(SID_METRIC_ITEM,static_cast<sal_uInt16>(eMetric)));
657             rPage.PageCreated(aSet);
658             break;
659         }
660 
661         case  RID_SVXPAGE_PICK_BULLET:
662         {
663             aSet.Put(SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
664             rPage.PageCreated(aSet);
665             break;
666         }
667 
668         case  TP_HEADER_PAGE:
669         {
670             if(0 == (nHtmlMode & HTMLMODE_ON))
671             {
672                 static_cast< SvxHeaderPage& >(rPage).EnableDynamicSpacing();
673             }
674 
675             //UUUU set DrawingLayer FillStyles active
676             aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true));
677             rPage.PageCreated(aSet);
678 
679             break;
680         }
681 
682         case  TP_FOOTER_PAGE:
683         {
684             if(0 == (nHtmlMode & HTMLMODE_ON))
685             {
686                 static_cast< SvxFooterPage& >(rPage).EnableDynamicSpacing();
687             }
688 
689             //UUUU set DrawingLayer FillStyles active
690             aSet.Put(SfxBoolItem(SID_DRAWINGLAYER_FILLSTYLES, true));
691             rPage.PageCreated(aSet);
692 
693             break;
694         }
695 
696         case TP_BORDER:
697         {
698             if(SFX_STYLE_FAMILY_PARA == nType)
699             {
700                 aSet.Put(SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA));
701             }
702             else if(SFX_STYLE_FAMILY_FRAME == nType)
703             {
704                 aSet.Put(SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
705             }
706             rPage.PageCreated(aSet);
707             break;
708         }
709 
710         //UUUU inits for Area and Transparency TabPages
711         // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
712         // the color table) need to be added as items (e.g. SvxColorTableItem) to make
713         // these pages find the needed attributes for fill style suggestions.
714         // These are added in SwDocStyleSheet::GetItemSet() for the SFX_STYLE_FAMILY_PARA on
715         // demand, but could also be directly added from the DrawModel.
716         case RID_SVXPAGE_AREA:
717         {
718             aSet.Put(GetStyleSheet().GetItemSet());
719 
720             // add flag for direct graphic content selection
721             aSet.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
722 
723             rPage.PageCreated(aSet);
724             break;
725         }
726 
727         case RID_SVXPAGE_TRANSPARENCE:
728         {
729             rPage.PageCreated(GetStyleSheet().GetItemSet());
730             break;
731         }
732 	}
733 }
734 
735 // eof
736