xref: /aoo41x/main/sd/source/ui/func/futempl.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/container/XNameAccess.hpp>
35 
36 #include "futempl.hxx"
37 
38 #include <editeng/editdata.hxx>
39 #include <editeng/bulitem.hxx>
40 #include <svx/svxids.hrc>   // fuer SID_OBJECT_SELECT
41 #include <sfx2/bindings.hxx>
42 #include <svl/aeitem.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <vcl/msgbox.hxx>
45 #include <editeng/eeitem.hxx>
46 #include <sfx2/request.hxx>
47 #include <editeng/numitem.hxx>
48 #include <editeng/editeng.hxx>
49 #include <editeng/lrspitem.hxx>
50 #include <svx/svdopage.hxx>
51 #include <svx/svditer.hxx>
52 #include <svx/sdr/properties/properties.hxx>
53 
54 #include <sfx2/viewfrm.hxx>
55 #include <svx/xlndsit.hxx>
56 #include <svx/xlnstit.hxx>
57 #include <svx/xlnedit.hxx>
58 #include "app.hrc"
59 #include "stlsheet.hxx"
60 #include "sdpage.hxx"
61 #include "stlpool.hxx"
62 #include "app.hxx"
63 #include "View.hxx"
64 #ifndef SD_WINDOW_SHELL_HXX
65 #include "Window.hxx"
66 #endif
67 #include "drawview.hxx"
68 #include "drawdoc.hxx"
69 #include "DrawDocShell.hxx"
70 #include "DrawViewShell.hxx"
71 #include "ViewShell.hxx"
72 #include "res_bmp.hrc"
73 #include "glob.hrc"
74 #include "prlayout.hxx"         // enum PresentationObjects
75 #include "prltempl.hrc"         // TAB_PRES_LAYOUT_TEMPLATE_x
76 #include <svx/tabarea.hxx>
77 #include "sdresid.hxx"
78 #include "OutlineViewShell.hxx"
79 #include "strings.hrc"
80 #include "helpids.h"
81 #include "sdabstdlg.hxx"
82 
83 using rtl::OUString;
84 using namespace com::sun::star::uno;
85 using namespace com::sun::star::container;
86 using namespace com::sun::star::beans;
87 using namespace com::sun::star::style;
88 
89 namespace sd
90 {
91 
92 TYPEINIT1( FuTemplate, FuPoor );
93 
94 /*************************************************************************
95 |*
96 |* Konstruktor
97 |*
98 \************************************************************************/
99 
100 FuTemplate::FuTemplate (
101     ViewShell* pViewSh,
102     ::sd::Window* pWin,
103     ::sd::View* pView,
104     SdDrawDocument* pDoc,
105     SfxRequest& rReq )
106     : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
107 {
108 }
109 
110 FunctionReference FuTemplate::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
111 {
112 	FunctionReference xFunc( new FuTemplate( pViewSh, pWin, pView, pDoc, rReq ) );
113 	xFunc->DoExecute(rReq);
114 	return xFunc;
115 }
116 
117 void FuTemplate::DoExecute( SfxRequest& rReq )
118 {
119 	const SfxItemSet* pArgs = rReq.GetArgs();
120 	sal_uInt16 nSId = rReq.GetSlot();
121 
122 	// StyleSheet-Parameter holen
123 	SfxStyleSheetBasePool* pSSPool = mpDoc->GetDocSh()->GetStyleSheetPool();
124 	SfxStyleSheetBase* pStyleSheet = NULL;
125 
126 	const SfxPoolItem* pItem;
127     sal_uInt16 nFamily = USHRT_MAX;
128     if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY,
129         sal_False, &pItem ))
130     {
131         nFamily = ( (const SfxUInt16Item &) pArgs->Get( SID_STYLE_FAMILY ) ).GetValue();
132     }
133     else
134     if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME,
135         sal_False, &pItem ))
136     {
137         String sFamily = ( (const SfxStringItem &) pArgs->Get( SID_STYLE_FAMILYNAME ) ).GetValue();
138         if (sFamily.CompareToAscii("graphics") == COMPARE_EQUAL)
139             nFamily = SD_STYLE_FAMILY_GRAPHICS;
140 		else
141 			nFamily = SD_STYLE_FAMILY_PSEUDO;
142     }
143 
144 	String aStyleName;
145 	sal_uInt16 nRetMask = 0xffff;
146 
147 	switch( nSId )
148 	{
149 		case SID_STYLE_APPLY:
150 		case SID_STYLE_EDIT:
151 		case SID_STYLE_DELETE:
152 		case SID_STYLE_FAMILY:
153 		case SID_STYLE_NEW_BY_EXAMPLE:
154 		{
155             SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False );
156             SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False );
157             if ( pFamilyItem && pNameItem )
158             {
159                 try
160                 {
161 					Reference< XStyleFamiliesSupplier > xModel(mpDoc->GetDocSh()->GetModel(), UNO_QUERY_THROW );
162                     Reference< XNameAccess > xCont( xModel->getStyleFamilies() );
163                     Reference< XNameAccess > xStyles( xCont->getByName(pFamilyItem->GetValue()), UNO_QUERY_THROW );
164                     Reference< XPropertySet > xInfo( xStyles->getByName( pNameItem->GetValue() ), UNO_QUERY_THROW );
165 
166 					OUString aUIName;
167                     xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName;
168                     if ( aUIName.getLength() )
169                         rReq.AppendItem( SfxStringItem( nSId, aUIName ) );
170                 }
171                 catch( Exception& )
172                 {
173                 }
174             }
175 
176 			if (pArgs->GetItemState(nSId) == SFX_ITEM_SET)
177 				aStyleName = ( ( (const SfxStringItem &) pArgs->Get( nSId ) ).GetValue() );
178 		}
179 	}
180 
181 	switch( nSId )
182 	{
183 		case SID_STYLE_NEW:
184 		{
185 			SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL );
186 			if(p)
187 			{
188 				pSSPool->Remove(p);
189 				p = 0;
190 			}
191 			pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF );
192 
193 			if (pArgs->GetItemState(SID_STYLE_REFERENCE) == SFX_ITEM_ON)
194 			{
195 				String aParentName(((const SfxStringItem&) pArgs->Get(SID_STYLE_REFERENCE)).GetValue());
196 				pStyleSheet->SetParent(aParentName);
197 			}
198 			else
199 			{
200 				pStyleSheet->SetParent(String(SdResId(STR_STANDARD_STYLESHEET_NAME)));
201 			}
202 		}
203 		break;
204 
205 		case SID_STYLE_NEW_BY_EXAMPLE:
206 		{
207 			// Z.Z. geht immer noch der Dialog auf, um den Namen
208 			// der Vorlage einzugeben.
209 			if( mpView->AreObjectsMarked() || sal_True )
210 			{
211 				SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL );
212 				if(p)
213 				{
214 					pSSPool->Remove(p);
215 					p = 0;
216 				}
217 				pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF );
218 				pStyleSheet->SetParent(String(SdResId(STR_STANDARD_STYLESHEET_NAME)));
219 			}
220 		}
221 		break;
222 
223 		case SID_STYLE_EDIT:
224 			pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
225 		break;
226 
227 		case SID_STYLE_DELETE:
228 			pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
229 			if( pStyleSheet )
230 			{
231 				pSSPool->Remove( pStyleSheet );
232 				nRetMask = sal_True;
233 				mpDoc->SetChanged(sal_True);
234 			}
235 			else
236 			{
237 				nRetMask = sal_False;
238 			}
239 		break;
240 
241 		case SID_STYLE_APPLY:
242 			// Anwenden der Vorlage auf das Dokument
243 			pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
244 
245 			// do not set presentation styles, they will be set implicit
246 			if ( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO )
247 			{
248 				SfxStyleSheet* pOldStyleSheet = mpView->GetStyleSheet();
249 				String aStr;
250 
251 				if( // if the object had no style sheet, allow all
252 					!pOldStyleSheet ||
253 
254 					// allow if old and new style sheet has same family
255 					pStyleSheet->GetFamily() == pOldStyleSheet->GetFamily() ||
256 
257 					// allow if old was background objects and new is graphics
258 					pStyleSheet->GetFamily() == (SD_STYLE_FAMILY_GRAPHICS && pOldStyleSheet->GetHelpId( aStr ) == HID_PSEUDOSHEET_BACKGROUNDOBJECTS) ||
259 
260 					// allow if old was presentation and we are a drawing document
261 					(pOldStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE && mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) )
262 				{
263 					mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet);
264 					mpDoc->SetChanged(sal_True);
265 					mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
266 				}
267 			}
268 /* #96983# GrabFocus moved to stylist
269 			pWin->GrabFocus();
270 */
271 		break;
272 
273 		case SID_STYLE_WATERCAN:
274 		{
275 			if( !SD_MOD()->GetWaterCan() )
276 			{
277 				if( pArgs->GetItemState( nSId ) == SFX_ITEM_SET )
278 				{
279 					aStyleName = ( ( (const SfxStringItem &) pArgs->Get( nSId ) ).GetValue() );
280 					SD_MOD()->SetWaterCan( sal_True );
281 					pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
282 				}
283 				// keine Praesentationsobjektvorlagen, die werden nur
284 				// implizit zugewiesen
285 				if( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO )
286 				{
287 					( (SdStyleSheetPool*) pSSPool )->SetActualStyleSheet( pStyleSheet );
288 
289 					// Es wird explizit in den Selektionsmodus geschaltet
290 					mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
291 										SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
292 
293 				}
294 				else
295 					SD_MOD()->SetWaterCan( sal_False );
296 			}
297 			else
298 			{
299 				SD_MOD()->SetWaterCan( sal_False );
300 				// Werkzeugleiste muss wieder enabled werden
301 				mpViewShell->Invalidate();
302 			}
303 		}
304 		break;
305 
306 		default:
307 		break;
308 	}
309 
310 	switch( nSId )
311 	{
312 		case SID_STYLE_NEW:
313 		case SID_STYLE_EDIT:
314 		{
315 			PresentationObjects ePO = PO_OUTLINE_1;
316 
317 			if( pStyleSheet )
318 			{
319 				SfxAbstractTabDialog*  pStdDlg  = NULL;
320 				SfxAbstractTabDialog*  pPresDlg = NULL;
321 				SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
322 				sal_Bool bOldDocInOtherLanguage = sal_False;
323 				SfxItemSet aOriSet( pStyleSheet->GetItemSet() );
324 
325 				SfxStyleFamily eFamily = pStyleSheet->GetFamily();
326 
327 				if (eFamily == SD_STYLE_FAMILY_GRAPHICS)
328 				{
329 					pStdDlg = pFact ? pFact->CreateSdTabTemplateDlg( 0, mpDoc->GetDocSh(), *pStyleSheet, mpDoc, mpView ) : 0;
330 				}
331 				else if (eFamily == SD_STYLE_FAMILY_PSEUDO)
332 				{
333 					String aName(pStyleSheet->GetName());
334 					sal_uInt16 nDlgId = 0;
335 
336 					if (aName == String(SdResId(STR_PSEUDOSHEET_TITLE)))
337 					{
338 						nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
339 						ePO    = PO_TITLE;
340 					}
341 					else if (aName == String(SdResId(STR_PSEUDOSHEET_SUBTITLE)))
342 					{
343 						nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
344 						ePO    = PO_SUBTITLE;
345 					}
346 					else if (aName ==
347 							 String(SdResId(STR_PSEUDOSHEET_BACKGROUND)))
348 					{
349 						nDlgId = TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND;
350 						ePO    = PO_BACKGROUND;
351 					}
352 					else if (aName ==
353 							 String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS)))
354 					{
355 						nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
356 						ePO    = PO_BACKGROUNDOBJECTS;
357 					}
358 					else if (aName ==
359 							 String(SdResId(STR_PSEUDOSHEET_NOTES)))
360 					{
361 						nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
362 						ePO    = PO_NOTES;
363 					}
364 					else if(aName.Search(String(SdResId(STR_PSEUDOSHEET_OUTLINE))) !=
365 							STRING_NOTFOUND)
366 					{
367 						nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
368 
369 						String aOutlineStr((SdResId(STR_PSEUDOSHEET_OUTLINE)));
370 						// die Nummer ermitteln; ein Leerzeichen zwischen
371 						// Name und Nummer beachten
372 						String aNumStr(aName.Copy(aOutlineStr.Len() + 1));
373 						sal_uInt16 nLevel = (sal_uInt16)aNumStr.ToInt32();
374 						switch (nLevel)
375 						{
376 							case 1: ePO = PO_OUTLINE_1; break;
377 							case 2: ePO = PO_OUTLINE_2; break;
378 							case 3: ePO = PO_OUTLINE_3; break;
379 							case 4: ePO = PO_OUTLINE_4; break;
380 							case 5: ePO = PO_OUTLINE_5; break;
381 							case 6: ePO = PO_OUTLINE_6; break;
382 							case 7: ePO = PO_OUTLINE_7; break;
383 							case 8: ePO = PO_OUTLINE_8; break;
384 							case 9: ePO = PO_OUTLINE_9; break;
385 						}
386 					}
387 					else
388 					{
389 						DBG_ERROR("Vorlage aus aelterer anderssprachiger Version");
390 						bOldDocInOtherLanguage = sal_True;
391 					}
392 
393 					if( !bOldDocInOtherLanguage )
394 					{
395 						pPresDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId(nDlgId), *pStyleSheet, ePO, pSSPool ) : 0;
396 					}
397 				}
398 				else if (eFamily == SD_STYLE_FAMILY_CELL)
399 				{
400 				}
401 
402 				sal_uInt16 nResult = RET_CANCEL;
403 				const SfxItemSet* pOutSet = NULL;
404 				if (pStdDlg)
405 				{
406 					nResult = pStdDlg->Execute();
407 					pOutSet = pStdDlg->GetOutputItemSet();
408 				}
409 				else if( pPresDlg )
410 				{
411 					nResult = pPresDlg->Execute();
412 					pOutSet = pPresDlg->GetOutputItemSet();
413 				}
414 
415 				switch( nResult )
416 				{
417 					case RET_OK:
418 					{
419 						nRetMask = pStyleSheet->GetMask();
420 
421 						if (eFamily == SD_STYLE_FAMILY_PSEUDO)
422 						{
423 							SfxItemSet aTempSet(*pOutSet);
424 							((SdStyleSheet*)pStyleSheet)->AdjustToFontHeight(aTempSet);
425 
426 							// Sonderbehandlung: die INVALIDS auf NULL-Pointer
427 							// zurueckgesetzen (sonst landen INVALIDs oder
428 							// Pointer auf die DefaultItems in der Vorlage;
429 							// beides wuerde die Attribut-Vererbung unterbinden)
430 							aTempSet.ClearInvalidItems();
431 
432 							// EE_PARA_NUMBULLET item is only valid in first outline template
433 							if( (ePO >= PO_OUTLINE_2) && (ePO <= PO_OUTLINE_9) )
434 							{
435 								if (aTempSet.GetItemState(EE_PARA_NUMBULLET) == SFX_ITEM_SET)
436 								{
437 									SvxNumRule aRule(*((SvxNumBulletItem*)aTempSet.GetItem(EE_PARA_NUMBULLET))->GetNumRule());
438 
439 									String sStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
440 									sStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
441 									SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( sStyleName, SD_STYLE_FAMILY_PSEUDO);
442 
443 									if(pFirstStyleSheet)
444 									{
445 										pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ));
446 										SdStyleSheet* pRealSheet = ((SdStyleSheet*)pFirstStyleSheet)->GetRealStyleSheet();
447 										pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
448 									}
449 
450 									aTempSet.ClearItem( EE_PARA_NUMBULLET );
451 								}
452 							}
453 
454 							String sStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
455 							sStyleName.Append( sal_Unicode( ' ' ));
456 
457 							pStyleSheet->GetItemSet().Put(aTempSet);
458 
459 							SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet();
460 							pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
461 
462 							if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) )
463 							{
464 								for( sal_uInt16 n = (sal_uInt16)(ePO - PO_OUTLINE_1 + 2); n < 10; n++ )
465 								{
466 									String aName( sStyleName );
467 									aName.Append( String::CreateFromInt32( (sal_Int32) n ));
468 
469 									SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SD_STYLE_FAMILY_PSEUDO);
470 
471 									if(pSheet)
472 									{
473 										SdStyleSheet* pRealStyleSheet = ((SdStyleSheet*)pSheet)->GetRealStyleSheet();
474 										pRealStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
475 									}
476 								}
477 							}
478 						}
479 
480 						SfxItemSet& rAttr = pStyleSheet->GetItemSet();
481 
482 						sdr::properties::CleanupFillProperties( rAttr );
483 
484 						// check for unique names of named items for xml
485 						if( rAttr.GetItemState( XATTR_FILLBITMAP ) == SFX_ITEM_SET )
486 						{
487 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLBITMAP );
488 							SfxPoolItem* pNewItem = ((XFillBitmapItem*)pOldItem)->checkForUniqueItem( mpDoc );
489 							if( pOldItem != pNewItem )
490 							{
491 								rAttr.Put( *pNewItem );
492 								delete pNewItem;
493 							}
494 						}
495 						if( rAttr.GetItemState( XATTR_LINEDASH ) == SFX_ITEM_SET )
496 						{
497 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEDASH );
498 							SfxPoolItem* pNewItem = ((XLineDashItem*)pOldItem)->checkForUniqueItem( mpDoc );
499 							if( pOldItem != pNewItem )
500 							{
501 								rAttr.Put( *pNewItem );
502 								delete pNewItem;
503 							}
504 						}
505 						if( rAttr.GetItemState( XATTR_LINESTART ) == SFX_ITEM_SET )
506 						{
507 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINESTART );
508 							SfxPoolItem* pNewItem = ((XLineStartItem*)pOldItem)->checkForUniqueItem( mpDoc );
509 							if( pOldItem != pNewItem )
510 							{
511 								rAttr.Put( *pNewItem );
512 								delete pNewItem;
513 							}
514 						}
515 						if( rAttr.GetItemState( XATTR_LINEEND ) == SFX_ITEM_SET )
516 						{
517 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEEND );
518 							SfxPoolItem* pNewItem = ((XLineEndItem*)pOldItem)->checkForUniqueItem( mpDoc );
519 							if( pOldItem != pNewItem )
520 							{
521 								rAttr.Put( *pNewItem );
522 								delete pNewItem;
523 							}
524 						}
525 						if( rAttr.GetItemState( XATTR_FILLGRADIENT ) == SFX_ITEM_SET )
526 						{
527 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLGRADIENT );
528 							SfxPoolItem* pNewItem = ((XFillGradientItem*)pOldItem)->checkForUniqueItem( mpDoc );
529 							if( pOldItem != pNewItem )
530 							{
531 								rAttr.Put( *pNewItem );
532 								delete pNewItem;
533 							}
534 						}
535 						if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET )
536 						{
537 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLFLOATTRANSPARENCE );
538 							SfxPoolItem* pNewItem = ((XFillFloatTransparenceItem*)pOldItem)->checkForUniqueItem( mpDoc );
539 							if( pOldItem != pNewItem )
540 							{
541 								rAttr.Put( *pNewItem );
542 								delete pNewItem;
543 							}
544 						}
545 						if( rAttr.GetItemState( XATTR_FILLHATCH ) == SFX_ITEM_SET )
546 						{
547 							const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLHATCH );
548 							SfxPoolItem* pNewItem = ((XFillHatchItem*)pOldItem)->checkForUniqueItem( mpDoc );
549 							if( pOldItem != pNewItem )
550 							{
551 								rAttr.Put( *pNewItem );
552 								delete pNewItem;
553 							}
554 						}
555 
556 						( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
557 
558 						DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewShell );
559 						if( pDrawViewShell )
560 						{
561 							PageKind ePageKind = pDrawViewShell->GetPageKind();
562 							if( ePageKind == PK_NOTES || ePageKind == PK_HANDOUT )
563 							{
564 								SdPage* pPage = mpViewShell->GetActualPage();
565 
566 								if(pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
567 								{
568 									pPage = static_cast<SdPage*>((&(pPage->TRG_GetMasterPage())));
569 								}
570 
571 								if( pPage )
572 								{
573 									SdrObjListIter aIter( *pPage );
574 									while( aIter.IsMore() )
575 									{
576 										SdrObject* pObj = aIter.Next();
577 										if( pObj->ISA(SdrPageObj) )
578 										{
579 											// repaint only
580 											pObj->ActionChanged();
581 											// pObj->SendRepaintBroadcast();
582 										}
583 									}
584 								}
585 							}
586 						}
587 
588 						if( mpDoc->GetOnlineSpell() )
589 						{
590 							const SfxPoolItem* pTempItem;
591 							if( SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE, sal_False, &pTempItem ) ||
592 								SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CJK, sal_False, &pTempItem ) ||
593 								SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CTL, sal_False, &pTempItem ) )
594 							{
595 								mpDoc->StopOnlineSpelling();
596 								mpDoc->StartOnlineSpelling();
597 							}
598 						}
599 
600 						mpDoc->SetChanged(sal_True);
601 					}
602 					break;
603 
604 					default:
605 					{
606 						if( nSId == SID_STYLE_NEW )
607 							pSSPool->Remove( pStyleSheet );
608 						delete pStdDlg;
609 						delete pPresDlg;
610 					}
611 					return; // Abbruch
612 				}
613 				delete pStdDlg;
614 				delete pPresDlg;
615 			}
616 		}
617 		break;
618 
619 		case SID_STYLE_NEW_BY_EXAMPLE:
620 		{
621 			if( pStyleSheet )
622 			{
623 				nRetMask = pStyleSheet->GetMask();
624 				SfxItemSet aCoreSet( mpDoc->GetPool() );
625 				mpView->GetAttributes( aCoreSet, sal_True );
626 
627 				// wenn das Objekt eine Vorlage hatte, wird diese Parent
628 				// der neuen Vorlage
629 				SfxStyleSheet* pOldStyle = mpView->GetStyleSheet();
630 
631 				// Wenn pOldStyle == pStyleSheet -> Rekursion
632 				if( pOldStyle != pStyleSheet )
633 				{
634 					if (pOldStyle)
635 					{
636 						pStyleSheet->SetParent(pOldStyle->GetName());
637 					}
638 
639 					SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
640 					pStyleSet->Put(aCoreSet);
641 
642 					// Vorlage anwenden (Aber nicht, wenn gerade ein Text
643 					// editiert wird, denn dazu muesste die Edit Engine
644 					// Vorlagen auf Zeichenebene beherrschen.)
645 					if (!mpView->GetTextEditObject())
646 					{
647 						mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet);
648 					}
649 
650 					( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
651 					mpDoc->SetChanged(sal_True);
652 
653 					mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
654 				}
655 			}
656 		}
657 		break;
658 
659 		case SID_STYLE_UPDATE_BY_EXAMPLE:
660 		{
661 			if ((mpView->AreObjectsMarked() && mpView->GetMarkedObjectList().GetMarkCount() == 1) ||
662 				 mpView->ISA(OutlineView))
663 			{
664 				pStyleSheet = mpView->GetStyleSheet();
665 
666 				if( pStyleSheet )
667 				{
668 					nRetMask = pStyleSheet->GetMask();
669 					SfxItemSet aCoreSet( mpDoc->GetPool() );
670 					mpView->GetAttributes( aCoreSet );
671 
672 					SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
673 					pStyleSet->Put( aCoreSet );
674 
675 					mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet);
676 
677 					( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
678 					mpDoc->SetChanged(sal_True);
679 					mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
680 				}
681 			}
682 		}
683 		break;
684 
685 	}
686 	if( nRetMask != 0xffff )
687 		rReq.SetReturnValue( SfxUInt16Item( nSId, nRetMask ) );
688 }
689 
690 void FuTemplate::Activate()
691 {
692 }
693 
694 void FuTemplate::Deactivate()
695 {
696 }
697 
698 } // end of namespace sd
699