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