xref: /aoo4110/main/sd/source/ui/dlg/prltempl.cxx (revision b1cdbd2c)
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_sd.hxx"
26 
27 #ifdef SD_DLLIMPLEMENTATION
28 #undef SD_DLLIMPLEMENTATION
29 #endif
30 
31 
32 #include "eetext.hxx"
33 
34 #include <svx/dialogs.hrc>
35 #include <editeng/flstitem.hxx>
36 #include <svx/drawitem.hxx>
37 #include <svl/style.hxx>
38 #include <svx/tabline.hxx>
39 #include <editeng/bulitem.hxx>
40 #include <editeng/eeitem.hxx>
41 #include <editeng/brshitem.hxx>
42 #include <vcl/graph.hxx>
43 #include <editeng/lrspitem.hxx>
44 #include <editeng/numitem.hxx>
45 #include <svl/cjkoptions.hxx>
46 
47 #include "DrawDocShell.hxx"
48 #include "glob.hrc"
49 #include "sdresid.hxx"
50 #include "prltempl.hxx"
51 #include "prltempl.hrc"
52 #include "enumdlg.hrc"
53 //#include "enumdlg.hxx"
54 #include "bulmaper.hxx"
55 #include <svl/intitem.hxx>
56 #include <svx/svxgrahicitem.hxx>
57 #include <svx/flagsdef.hxx>
58 #include "drawdoc.hxx"
59 #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9)
60 
61 /*************************************************************************
62 |*
63 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
64 |*
65 \************************************************************************/
66 
SdPresLayoutTemplateDlg(SfxObjectShell * pDocSh,Window * pParent,SdResId DlgId,SfxStyleSheetBase & rStyleBase,PresentationObjects _ePO,SfxStyleSheetBasePool * pSSPool)67 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
68                                 Window* pParent,
69 								SdResId DlgId,
70 								SfxStyleSheetBase& rStyleBase,
71 								PresentationObjects _ePO,
72 								SfxStyleSheetBasePool* pSSPool ) :
73 		SfxTabDialog		( pParent, DlgId ),
74 		mpDocShell			( pDocSh ),
75 		ePO 				( _ePO ),
76 		aInputSet			( *rStyleBase.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ),
77 		pOutSet				( NULL ),
78 		pOrgSet				( &rStyleBase.GetItemSet() )
79 {
80 	if( IS_OUTLINE(ePO))
81 	{
82 		// Leider sind die Itemsets unserer Stylesheets nicht discret..
83 		const sal_uInt16* pPtr = pOrgSet->GetRanges();
84 		sal_uInt16 p1, p2;
85 		while( *pPtr )
86 		{
87 			p1 = pPtr[0];
88 			p2 = pPtr[1];
89 
90 			// erstmal das ganze discret machen
91 			while(pPtr[2] && (pPtr[2] - p2 == 1))
92 			{
93 				p2 = pPtr[3];
94 				pPtr += 2;
95 			}
96 			aInputSet.MergeRange( p1, p2 );
97 			pPtr += 2;
98 		}
99 
100 		aInputSet.Put( rStyleBase.GetItemSet() );
101 
102 		// need parent-relationship
103 		const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();;
104 		if( pParentItemSet )
105 			aInputSet.SetParent( pParentItemSet );
106 
107 		pOutSet = new SfxItemSet( rStyleBase.GetItemSet() );
108 		pOutSet->ClearItem();
109 
110 		const SfxPoolItem *pItem = NULL;
111 
112 		// Fals in diesem Stylesheet kein Bullet Item ist, holen wir uns
113 		// das aus dem 'Outline 1' Stylesheet.
114 		if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem ))
115 		{
116 			String aStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
117 			aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
118 			SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
119 
120 			if(pFirstStyleSheet)
121 				if( SFX_ITEM_SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem) )
122 					aInputSet.Put( *pItem );
123 		}
124 
125 		// gewaehlte Ebene im Dialog vorselektieren
126 		aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
127 
128 		SetInputSet( &aInputSet );
129 	}
130 	else
131 		SetInputSet( pOrgSet );
132 
133 	FreeResource();
134 
135 	SvxColorTableItem aColorTableItem(*( (const SvxColorTableItem*)
136 		( mpDocShell->GetItem( SID_COLOR_TABLE ) ) ) );
137 	SvxGradientListItem aGradientListItem(*( (const SvxGradientListItem*)
138 		( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) ) );
139 	SvxBitmapListItem aBitmapListItem(*( (const SvxBitmapListItem*)
140 		( mpDocShell->GetItem( SID_BITMAP_LIST ) ) ) );
141 	SvxHatchListItem aHatchListItem(*( (const SvxHatchListItem*)
142 		( mpDocShell->GetItem( SID_HATCH_LIST ) ) ) );
143 	SvxDashListItem aDashListItem(*( (const SvxDashListItem*)
144 		( mpDocShell->GetItem( SID_DASH_LIST ) ) ) );
145 	SvxLineEndListItem aLineEndListItem(*( (const SvxLineEndListItem*)
146 		( mpDocShell->GetItem( SID_LINEEND_LIST ) ) ) );
147 
148 	maColorTab = aColorTableItem.GetColorTable();
149 	maDashList = aDashListItem.GetDashList();
150 	maLineEndList = aLineEndListItem.GetLineEndList();
151 	maGradientList = aGradientListItem.GetGradientList();
152 	maHatchingList = aHatchListItem.GetHatchList();
153 	maBitmapList = aBitmapListItem.GetBitmapList();
154 
155 	switch( DlgId.GetId() )
156 	{
157 		case TAB_PRES_LAYOUT_TEMPLATE:
158 		{
159 			AddTabPage( RID_SVXPAGE_LINE);
160 			AddTabPage( RID_SVXPAGE_AREA);
161 			AddTabPage( RID_SVXPAGE_SHADOW);
162 			AddTabPage( RID_SVXPAGE_TRANSPARENCE);
163 			AddTabPage( RID_SVXPAGE_CHAR_NAME );
164 			AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
165 			AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
166     		AddTabPage( RID_SVXPAGE_TEXTATTR );
167             AddTabPage( RID_SVXPAGE_PICK_BULLET );
168             AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
169             AddTabPage( RID_SVXPAGE_PICK_BMP );
170             AddTabPage( RID_SVXPAGE_NUM_OPTIONS );
171     		AddTabPage( RID_SVXPAGE_TABULATOR );
172 		}
173 		break;
174 
175 		case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND:        // background
176 			AddTabPage( RID_SVXPAGE_AREA);
177 		break;
178 	}
179 
180 	// #112490# the tabpages Alignment, Tabs and Asian Typography are very
181 	// usefull, except for the background style
182 	if( DlgId.GetId() != TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND )
183 	{
184 	    SvtCJKOptions aCJKOptions;
185 		if( aCJKOptions.IsAsianTypographyEnabled() )
186 			AddTabPage( RID_SVXPAGE_PARA_ASIAN );
187 		else
188 			RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
189 
190 		AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
191 	}
192 
193 	// Titel setzen und
194 	// entsprechende Seiten zum Dialog hinzufuegen
195 	String aTitle;
196 
197 	switch( ePO )
198 	{
199 		case PO_TITLE:
200 			aTitle = String(SdResId( STR_PSEUDOSHEET_TITLE ));
201 		break;
202 
203 		case PO_SUBTITLE:
204 			aTitle = String(SdResId( STR_PSEUDOSHEET_SUBTITLE ));
205 		break;
206 
207 		case PO_BACKGROUND:
208 			aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUND ));
209 		break;
210 
211 		case PO_BACKGROUNDOBJECTS:
212 			aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS ));
213 		break;
214 
215 		case PO_OUTLINE_1:
216 		case PO_OUTLINE_2:
217 		case PO_OUTLINE_3:
218 		case PO_OUTLINE_4:
219 		case PO_OUTLINE_5:
220 		case PO_OUTLINE_6:
221 		case PO_OUTLINE_7:
222 		case PO_OUTLINE_8:
223 		case PO_OUTLINE_9:
224 			aTitle = String(SdResId( STR_PSEUDOSHEET_OUTLINE ));
225 			aTitle.Append( sal_Unicode(' ') );
226 			aTitle.Append( UniString::CreateFromInt32( ePO - PO_OUTLINE_1 + 1 ) );
227 		break;
228 
229 		case PO_NOTES:
230 			aTitle = String(SdResId( STR_PSEUDOSHEET_NOTES ));
231 		break;
232 	}
233 	SetText( aTitle );
234 
235 	nDlgType = 1; // Vorlagen-Dialog
236 	nPageType = 0;
237 	nPos = 0;
238 
239 	nColorTableState = CT_NONE;
240 	nBitmapListState = CT_NONE;
241 	nGradientListState = CT_NONE;
242 	nHatchingListState = CT_NONE;
243 }
244 
245 // -----------------------------------------------------------------------
246 
~SdPresLayoutTemplateDlg()247 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
248 {
249 	delete pOutSet;
250 }
251 
252 // -----------------------------------------------------------------------
253 
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)254 void SdPresLayoutTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
255 {	SfxAllItemSet aSet(*(aInputSet.GetPool()));
256 	switch( nId )
257 	{
258 		case RID_SVXPAGE_LINE:
259 		{
260 			aSet.Put (SvxColorTableItem(maColorTab,SID_COLOR_TABLE));
261 			aSet.Put (SvxDashListItem(maDashList,SID_DASH_LIST));
262 			aSet.Put (SvxLineEndListItem(maLineEndList,SID_LINEEND_LIST));
263 			aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
264 
265 			rPage.PageCreated(aSet);
266 		}
267 		break;
268 
269 		case RID_SVXPAGE_AREA:
270 		{
271 			aSet.Put (SvxColorTableItem(maColorTab,SID_COLOR_TABLE));
272 			aSet.Put (SvxGradientListItem(maGradientList,SID_GRADIENT_LIST));
273 			aSet.Put (SvxHatchListItem(maHatchingList,SID_HATCH_LIST));
274 			aSet.Put (SvxBitmapListItem(maBitmapList,SID_BITMAP_LIST));
275 			aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
276 			aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
277 			aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos));
278 			rPage.PageCreated(aSet);
279 
280 		}
281 		break;
282 
283 		case RID_SVXPAGE_SHADOW:
284 				aSet.Put (SvxColorTableItem(maColorTab,SID_COLOR_TABLE)); //add CHINA001
285 				aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
286 				aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
287 				rPage.PageCreated(aSet);
288 			break;
289 
290 		case RID_SVXPAGE_TRANSPARENCE:
291 			aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
292 			aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
293 			rPage.PageCreated(aSet);
294 		break;
295 
296 		case RID_SVXPAGE_CHAR_NAME:
297 		{
298 			SvxFontListItem aItem(*( (const SvxFontListItem*)
299 				( mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
300 
301 			aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
302 			rPage.PageCreated(aSet);
303 		}
304 		break;
305 
306 		case RID_SVXPAGE_CHAR_EFFECTS:
307 			aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
308 			rPage.PageCreated(aSet);
309 		break;
310 
311 		case RID_SVXPAGE_STD_PARAGRAPH:
312 		break;
313 	}
314 }
315 
GetOutputItemSet() const316 const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const
317 {
318 	if( pOutSet )
319 	{
320 		pOutSet->Put( *SfxTabDialog::GetOutputItemSet() );
321 
322 		const SvxNumBulletItem *pSvxNumBulletItem = NULL;
323 		if( SFX_ITEM_SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pSvxNumBulletItem ))
324 			SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet );
325 		return pOutSet;
326 	}
327 	else
328 		return SfxTabDialog::GetOutputItemSet();
329 }
330 
331 // ---------------------------------------------------------------------
332 // ---------------------------------------------------------------------
GetOutlineLevel() const333 sal_uInt16 SdPresLayoutTemplateDlg::GetOutlineLevel() const
334 {
335 	switch( ePO )
336 	{
337 	case PO_OUTLINE_1: return 0;
338 	case PO_OUTLINE_2: return 1;
339 	case PO_OUTLINE_3: return 2;
340 	case PO_OUTLINE_4: return 3;
341 	case PO_OUTLINE_5: return 4;
342 	case PO_OUTLINE_6: return 5;
343 	case PO_OUTLINE_7: return 6;
344 	case PO_OUTLINE_8: return 7;
345 	case PO_OUTLINE_9: return 8;
346 	default:
347 		DBG_ASSERT( sal_False, "Falscher Po! [CL]");
348 	}
349 	return 0;
350 }
351 
352 
353 
354