xref: /aoo41x/main/sd/source/ui/view/drviewsb.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 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
31 #include <comphelper/processfactory.hxx>
32 #include <svx/svdlayer.hxx>
33 #ifndef _SVXIDS_HXX
34 #include <svx/svxids.hrc>
35 #endif
36 #include <sfx2/msgpool.hxx>
37 #include <svx/hyprlink.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <svx/hlnkitem.hxx>
40 #include <tools/urlobj.hxx>
41 #include <editeng/eeitem.hxx>
42 #ifndef _FLDITEM_HXX
43 #include <editeng/flditem.hxx>
44 #endif
45 #include <vcl/msgbox.hxx>
46 #include <sfx2/request.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <svx/svdorect.hxx>
49 #include <sfx2/docfile.hxx>
50 #include <basic/sbstar.hxx>
51 #include <basic/sberrors.hxx>
52 #include <svx/fmshell.hxx>
53 #include <svx/svxdlg.hxx>
54 #include <svx/dialogs.hrc>
55 #include <unotools/useroptions.hxx>
56 
57 #include "app.hrc"
58 #include "strings.hrc"
59 #include "res_bmp.hrc"
60 #include "glob.hrc"
61 #include "Outliner.hxx"
62 #include "Window.hxx"
63 #include "app.hxx"
64 #include "sdattr.hxx"
65 #include "drawdoc.hxx"
66 #include "DrawDocShell.hxx"
67 #include "sdresid.hxx"
68 #include "sdpage.hxx"
69 #include "DrawViewShell.hxx"
70 #include "drawview.hxx"
71 #include "unmodpg.hxx"
72 #include "undolayer.hxx"
73 #include "ViewShellBase.hxx"
74 #include "FormShellManager.hxx"
75 #include "LayerTabBar.hxx"
76 #include "sdabstdlg.hxx"
77 #include "SlideSorterViewShell.hxx"
78 #include "SlideSorter.hxx"
79 #include "controller/SlideSorterController.hxx"
80 
81 #define	RET_DELETE	100
82 
83 namespace sd {
84 
85 /*************************************************************************
86 |*
87 |* SfxRequests fuer temporaere Funktionen
88 |*
89 \************************************************************************/
90 
91 void DrawViewShell::FuTemp02(SfxRequest& rReq)
92 {
93 	sal_uInt16 nSId = rReq.GetSlot();
94 	switch( nSId )
95 	{
96 		case SID_INSERTLAYER:
97 		{
98 			if ( mpDrawView->IsTextEdit() )
99 			{
100 				mpDrawView->SdrEndTextEdit();
101 			}
102 
103 			SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
104 			sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
105 			sal_uInt16 nLayer = nLayerCnt - 2 + 1;
106 			String aLayerName ( SdResId(STR_LAYER) ), aLayerTitle, aLayerDesc;
107 			aLayerName += String::CreateFromInt32( (sal_Int32)nLayer );
108 			sal_Bool bIsVisible = sal_False;
109 			sal_Bool bIsLocked = sal_False;
110 			sal_Bool bIsPrintable = sal_False;
111 
112 			const SfxItemSet* pArgs = rReq.GetArgs();
113 
114 			if (! pArgs)
115 			{
116 				SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
117 
118 				aNewAttr.Put( SdAttrLayerName( aLayerName ) );
119 				aNewAttr.Put( SdAttrLayerTitle() );
120 				aNewAttr.Put( SdAttrLayerDesc() );
121 				aNewAttr.Put( SdAttrLayerVisible() );
122 				aNewAttr.Put( SdAttrLayerPrintable() );
123 				aNewAttr.Put( SdAttrLayerLocked() );
124 				aNewAttr.Put( SdAttrLayerThisPage() );
125 
126 				SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
127 				AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, true, String( SdResId( STR_INSERTLAYER ) ) ) : 0;
128 				if( pDlg )
129 				{
130 					pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_INSERTLAYER )->GetCommand() );
131 
132 					// Ueberpruefung auf schon vorhandene Namen
133 					sal_Bool bLoop = sal_True;
134 					while( bLoop && pDlg->Execute() == RET_OK )
135 					{
136 						pDlg->GetAttr( aNewAttr );
137 						aLayerName	 = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
138 
139 						if( rLayerAdmin.GetLayer( aLayerName, sal_False )
140 							|| aLayerName.Len()==0 )
141 						{
142 							// Name ist schon vorhanden
143 							WarningBox aWarningBox (
144 								GetParentWindow(),
145 								WinBits( WB_OK ),
146 								String(SdResId( STR_WARN_NAME_DUPLICATE)));
147 							aWarningBox.Execute();
148 						}
149 						else
150 							bLoop = sal_False;
151 					}
152 					if( bLoop ) // wurde abgebrochen
153 					{
154 						delete pDlg;
155 
156 						Cancel();
157 						rReq.Ignore ();
158 						break;
159 					}
160 					else
161 					{
162 						//pDlg->GetAttr( aNewAttr );
163 						//aLayerName	 = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
164 						aLayerTitle  = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
165 						aLayerDesc   = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
166 						bIsVisible	 = ((SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
167 						bIsLocked	 = ((SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ;
168 						bIsPrintable = ((SdAttrLayerPrintable &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ;
169 
170 						delete pDlg;
171 					}
172 				}
173 			}
174 			else if (pArgs->Count () != 4)
175 				 {
176 					 StarBASIC::FatalError (SbERR_WRONG_ARGS);
177 					 Cancel();
178 					 rReq.Ignore ();
179 					 break;
180 				 }
181 				 else
182 				 {
183 					 SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, sal_False);
184 					 SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
185 					 SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, sal_False);
186 					 SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, sal_False);
187 
188 					 aLayerName   = pLayerName->GetValue ();
189 					 bIsVisible   = pIsVisible->GetValue ();
190 					 bIsLocked	  = pIsLocked->GetValue ();
191 					 bIsPrintable = pIsPrintable->GetValue ();
192 				 }
193 
194 			String aPrevLayer = mpDrawView->GetActiveLayer();
195 			String aName;
196 			SdrLayer* pLayer;
197 			sal_uInt16 nPrevLayer = 0;
198 			nLayerCnt = rLayerAdmin.GetLayerCount();
199 
200 			for ( nLayer = 0; nLayer < nLayerCnt; nLayer++ )
201 			{
202 				pLayer = rLayerAdmin.GetLayer(nLayer);
203 				aName = pLayer->GetName();
204 
205 				if ( aPrevLayer == aName )
206 				{
207 //                    nPrevLayer = nLayer;
208 					nPrevLayer = Max(nLayer, (sal_uInt16) 4);
209 				}
210 			}
211 
212 			mpDrawView->InsertNewLayer(aLayerName, nPrevLayer + 1);
213 			pLayer = rLayerAdmin.GetLayer(aLayerName, sal_False);
214 			if( pLayer )
215 			{
216 				pLayer->SetTitle( aLayerTitle );
217 				pLayer->SetDescription( aLayerDesc );
218 			}
219 
220 			mpDrawView->SetLayerVisible( aLayerName, bIsVisible );
221 			mpDrawView->SetLayerLocked( aLayerName, bIsLocked);
222 			mpDrawView->SetLayerPrintable(aLayerName, bIsPrintable);
223 
224 			mpDrawView->SetActiveLayer(aLayerName);
225 
226 			ResetActualLayer();
227 
228 			GetDoc()->SetChanged(sal_True);
229 
230 			GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHLAYER,
231 					SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
232 
233 			Cancel();
234 			rReq.Done ();
235 		}
236 		break;
237 
238 		case SID_MODIFYLAYER:
239 		{
240 			if ( mpDrawView->IsTextEdit() )
241 			{
242 				mpDrawView->SdrEndTextEdit();
243 			}
244 
245 			SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
246 			sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId();
247 			String aLayerName( GetLayerTabControl()->GetPageText(nCurPage) );
248 			SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName, sal_False);
249 
250 			String aLayerTitle( pLayer->GetTitle() );
251 			String aLayerDesc( pLayer->GetDescription() );
252 
253 			String aOldLayerName( aLayerName );
254 			String aOldLayerTitle( aLayerTitle );
255 			String aOldLayerDesc( aLayerDesc );
256 
257 			sal_Bool bIsVisible, bIsLocked, bIsPrintable;
258 			sal_Bool bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName);
259 			sal_Bool bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName);
260 			sal_Bool bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName);
261 
262 
263 			const SfxItemSet* pArgs = rReq.GetArgs();
264 			// darf der Layer geloescht werden ?
265 			bool bDelete = true;
266 
267 			String aLayoutLayer ( SdResId(STR_LAYER_LAYOUT) );
268 			String aControlsLayer ( SdResId(STR_LAYER_CONTROLS) );
269 			String aMeasureLinesLayer ( SdResId(STR_LAYER_MEASURELINES) );
270 			String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
271 			String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
272 
273 			if( aLayerName == aLayoutLayer       || aLayerName == aControlsLayer ||
274 				aLayerName == aMeasureLinesLayer ||
275 				aLayerName == aBackgroundLayer   || aLayerName == aBackgroundObjLayer )
276 			{
277 				bDelete = false;
278 			}
279 
280 			if (! pArgs)
281 			{
282 				SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
283 
284 				aNewAttr.Put( SdAttrLayerName( aLayerName ) );
285 				aNewAttr.Put( SdAttrLayerTitle( aLayerTitle ) );
286 				aNewAttr.Put( SdAttrLayerDesc( aLayerDesc ) );
287 				aNewAttr.Put( SdAttrLayerVisible( bIsVisible ) );
288 				aNewAttr.Put( SdAttrLayerLocked( bIsLocked ) );
289 				aNewAttr.Put( SdAttrLayerPrintable( bIsPrintable ) );
290 				aNewAttr.Put( SdAttrLayerThisPage() );
291 
292 				SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
293 				AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, bDelete, String( SdResId( STR_MODIFYLAYER ) ) ) : 0;
294 				if( pDlg )
295 				{
296 					pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() );
297 
298 					// Ueberpruefung auf schon vorhandene Namen
299 					sal_Bool	bLoop = sal_True;
300 					sal_uInt16	nRet = 0;
301 					while( bLoop && ( (nRet = pDlg->Execute()) == RET_OK ) )
302 					{
303 						pDlg->GetAttr( aNewAttr );
304 						aLayerName	 = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
305 
306 						if( (rLayerAdmin.GetLayer( aLayerName, sal_False ) &&
307 							 aLayerName != aOldLayerName) || aLayerName.Len()==0 )
308 						{
309 							// Name ist schon vorhanden
310 							WarningBox aWarningBox (
311 								GetParentWindow(),
312 								WinBits( WB_OK ),
313 								String( SdResId( STR_WARN_NAME_DUPLICATE)));
314 							aWarningBox.Execute();
315 						}
316 						else
317 							bLoop = sal_False;
318 					}
319 					switch (nRet)
320 					{
321 						case RET_OK :
322 							aLayerTitle  = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
323 							aLayerDesc   = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
324 							bIsVisible	 = ((const SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
325 							bIsLocked	 = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue ();
326 							bIsPrintable = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue ();
327 
328 							delete pDlg;
329 							break;
330 
331 						default :
332 							delete pDlg;
333 							rReq.Ignore ();
334 							Cancel ();
335 							return;
336 					}
337 				}
338 			}
339 			else if (pArgs->Count () == 4)
340 			{
341 				SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, sal_False);
342 				SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
343 				SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, sal_False);
344 				SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, sal_False);
345 
346 				aLayerName   = pLayerName->GetValue ();
347 				bIsVisible   = pIsVisible->GetValue ();
348 				bIsLocked	 = pIsLocked->GetValue ();
349 				bIsPrintable = pIsPrintable->GetValue ();
350 			}
351 			else
352 			{
353 				StarBASIC::FatalError (SbERR_WRONG_ARGS);
354 				Cancel ();
355 				rReq.Ignore ();
356 				break;
357 			}
358 
359 			::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
360 			SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction(
361 				GetDoc(),
362 				pLayer,
363 				// old values
364 				aOldLayerName,
365 				aOldLayerTitle,
366 				aOldLayerDesc,
367 				bOldIsVisible,
368 				bOldIsLocked,
369 				bOldIsPrintable,
370 				// new values
371 				aLayerName,
372 				aLayerTitle,
373 				aLayerDesc,
374 				bIsVisible,
375 				bIsLocked,
376 				bIsPrintable
377 				);
378 			pManager->AddUndoAction( pAction );
379 
380 			ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable );
381 
382 			Cancel();
383 			rReq.Done ();
384 		}
385 		break;
386 
387 		case SID_RENAMELAYER:
388 		{
389 			if ( mpDrawView->IsTextEdit() )
390 			{
391 				mpDrawView->SdrEndTextEdit();
392 			}
393 
394 			GetLayerTabControl()->StartEditMode(
395                 GetLayerTabControl()->GetCurPageId() );
396 
397 			Cancel();
398 			rReq.Ignore ();
399 		}
400 		break;
401 
402 		case SID_EDIT_HYPERLINK :
403 		{
404 			GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
405 
406 			Cancel();
407 			rReq.Done ();
408 		}
409 		break;
410 
411         case SID_OPEN_HYPERLINK:
412         {
413             OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
414             if ( pOutView )
415             {
416                 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
417                 if ( pFieldItem )
418                 {
419                     const SvxFieldData* pField = pFieldItem->GetField();
420                     if( pField && pField->ISA( SvxURLField ) )
421                     {
422                         const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
423 
424 						SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
425 						SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
426 
427 						String aReferName;
428 						SfxViewFrame* pFrame = GetViewFrame();
429 						SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
430 						if (pMed)
431 							aReferName = pMed->GetName();
432 
433 						SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
434 						SfxStringItem aReferer( SID_REFERER, aReferName );
435 
436 						SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_False );
437 						SfxBoolItem aBrowsing( SID_BROWSE, sal_True );
438 
439 						SfxViewFrame* pViewFrm = SfxViewFrame::Current();
440 						if (pViewFrm)
441 							pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
442 														SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
443 														&aUrl, &aTarget,
444 														&aFrm, &aReferer,
445 														&aNewView, &aBrowsing,
446 														0L );
447                     }
448                 }
449             }
450 			Cancel();
451 			rReq.Done ();
452         }
453         break;
454 
455 		case SID_HYPERLINK_SETLINK:
456 		{
457 			const SfxItemSet* pReqArgs = rReq.GetArgs();
458 
459 			if (pReqArgs)
460 			{
461 				SvxHyperlinkItem* pHLItem =
462                 (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK);
463 
464 				if (pHLItem->GetInsertMode() == HLINK_FIELD)
465 				{
466 					InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
467 								   pHLItem->GetTargetFrame(), NULL);
468 				}
469 				else if (pHLItem->GetInsertMode() == HLINK_BUTTON)
470 				{
471 					InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
472 									pHLItem->GetTargetFrame(), NULL);
473 				}
474 				else if (pHLItem->GetInsertMode() == HLINK_DEFAULT)
475 				{
476 					OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
477 
478 					if (pOlView)
479 					{
480 						InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
481 									   pHLItem->GetTargetFrame(), NULL);
482 					}
483 					else
484 					{
485 						InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
486 										pHLItem->GetTargetFrame(), NULL);
487 					}
488 				}
489 			}
490 
491 			Cancel();
492 			rReq.Ignore ();
493 		}
494 		break;
495 
496 		case SID_INSERT_FLD_DATE_FIX:
497 		case SID_INSERT_FLD_DATE_VAR:
498 		case SID_INSERT_FLD_TIME_FIX:
499 		case SID_INSERT_FLD_TIME_VAR:
500 		case SID_INSERT_FLD_AUTHOR:
501 		case SID_INSERT_FLD_PAGE:
502 		case SID_INSERT_FLD_PAGES:
503 		case SID_INSERT_FLD_FILE:
504 		{
505 			sal_uInt16 nMul = 1;
506 			SvxFieldItem* pFieldItem = 0;
507 
508 			switch( nSId )
509 			{
510 				case SID_INSERT_FLD_DATE_FIX:
511 					pFieldItem = new SvxFieldItem(
512                         SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
513 				break;
514 
515 				case SID_INSERT_FLD_DATE_VAR:
516                     pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD );
517 				break;
518 
519 				case SID_INSERT_FLD_TIME_FIX:
520 					pFieldItem = new SvxFieldItem(
521                         SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD );
522 				break;
523 
524 				case SID_INSERT_FLD_TIME_VAR:
525                     pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD );
526 				break;
527 
528 				case SID_INSERT_FLD_AUTHOR:
529 				{
530                     SvtUserOptions aUserOptions;
531                     pFieldItem = new SvxFieldItem(
532                             SvxAuthorField(
533                                 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD );
534 				}
535 				break;
536 
537 				case SID_INSERT_FLD_PAGE:
538 				{
539                     pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
540 					nMul = 3;
541 				}
542 				break;
543 
544                 case SID_INSERT_FLD_PAGES:
545 				{
546                     pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD );
547 					nMul = 3;
548 				}
549 				break;
550 
551 				case SID_INSERT_FLD_FILE:
552 				{
553 					String aName;
554 					if( GetDocSh()->HasName() )
555 						aName = GetDocSh()->GetMedium()->GetName();
556 					//else
557 					//	aName = GetDocSh()->GetName();
558                     pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD );
559 				}
560 				break;
561 			}
562 
563 			OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
564 
565 			if( pOLV )
566 			{
567 				const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection();
568 
569 				if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) ||
570 									pOldFldItem->GetField()->ISA( SvxDateField ) ||
571 									pOldFldItem->GetField()->ISA( SvxTimeField ) ||
572 									pOldFldItem->GetField()->ISA( SvxExtTimeField ) ||
573 									pOldFldItem->GetField()->ISA( SvxExtFileField ) ||
574 									pOldFldItem->GetField()->ISA( SvxAuthorField ) ||
575 									pOldFldItem->GetField()->ISA( SvxPageField ) ) )
576 				{
577 					// Feld selektieren, so dass es beim Insert geloescht wird
578 					ESelection aSel = pOLV->GetSelection();
579 					if( aSel.nStartPos == aSel.nEndPos )
580 						aSel.nEndPos++;
581 					pOLV->SetSelection( aSel );
582 				}
583 
584 				if( pFieldItem )
585 					pOLV->InsertField( *pFieldItem );
586 			}
587 			else
588 			{
589 				Outliner* pOutl = GetDoc()->GetInternalOutliner();
590 				pOutl->Init( OUTLINERMODE_TEXTOBJECT );
591 				sal_uInt16 nOutlMode = pOutl->GetMode();
592 				pOutl->SetStyleSheet( 0, NULL );
593 				pOutl->QuickInsertField( *pFieldItem, ESelection() );
594 				OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
595 
596 				SdrRectObj* pRectObj = new SdrRectObj( OBJ_TEXT );
597 				pRectObj->SetMergedItem(SdrTextAutoGrowWidthItem(sal_True));
598 
599 				pOutl->UpdateFields();
600 				pOutl->SetUpdateMode( sal_True );
601 				Size aSize( pOutl->CalcTextSize() );
602 				aSize.Width() *= nMul;
603 				pOutl->SetUpdateMode( sal_False );
604 
605 				Point aPos;
606 				Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() );
607 				aPos = aRect.Center();
608 				aPos = GetActiveWindow()->PixelToLogic(aPos);
609 				aPos.X() -= aSize.Width() / 2;
610 				aPos.Y() -= aSize.Height() / 2;
611 
612 				Rectangle aLogicRect(aPos, aSize);
613 				pRectObj->SetLogicRect(aLogicRect);
614 				pRectObj->SetOutlinerParaObject( pOutlParaObject );
615 				mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
616 				pOutl->Init( nOutlMode );
617 			}
618 
619 			delete pFieldItem;
620 
621 			Cancel();
622 			rReq.Ignore ();
623 		}
624 		break;
625 
626 		case SID_MODIFY_FIELD:
627 		{
628 			OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
629 
630 			if( pOLV )
631 			{
632 				const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection();
633 
634 				if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
635 								 pFldItem->GetField()->ISA( SvxAuthorField ) ||
636 								 pFldItem->GetField()->ISA( SvxExtFileField ) ||
637 								 pFldItem->GetField()->ISA( SvxExtTimeField ) ) )
638 				{
639 					// Dialog...
640 					SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
641 					AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOLV->GetAttribs() ) : 0;
642 					if( pDlg && pDlg->Execute() == RET_OK )
643 					{
644 						// #108538#
645 						// To make a correct SetAttribs() call at the utlinerView
646 						// it is necessary to split the actions here
647 						SvxFieldData* pField = pDlg->GetField();
648 						ESelection aSel = pOLV->GetSelection();
649 						sal_Bool bSelectionWasModified(sal_False);
650 
651 						if( pField )
652 						{
653                             SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
654 
655 							if( aSel.nStartPos == aSel.nEndPos )
656 							{
657 								bSelectionWasModified = sal_True;
658 								aSel.nEndPos++;
659 								pOLV->SetSelection( aSel );
660 							}
661 
662 							pOLV->InsertField( aFieldItem );
663 
664 							// #108538# select again for eventual SetAttribs call
665 							pOLV->SetSelection( aSel );
666 						}
667 
668 						SfxItemSet aSet( pDlg->GetItemSet() );
669 
670 						if( aSet.Count() )
671 						{
672 							pOLV->SetAttribs( aSet );
673 
674 							::Outliner* pOutliner = pOLV->GetOutliner();
675 							if( pOutliner )
676 								pOutliner->UpdateFields();
677 						}
678 
679 						if(pField)
680 						{
681 							// #108538# restore selection to original
682 							if(bSelectionWasModified)
683 							{
684 								aSel.nEndPos--;
685 								pOLV->SetSelection( aSel );
686 							}
687 
688 							delete pField;
689 						}
690 					}
691 					delete pDlg;
692 				}
693 			}
694 
695 			Cancel();
696 			rReq.Ignore ();
697 		}
698 		break;
699 
700         case SID_OPEN_XML_FILTERSETTINGS:
701         {
702 			try
703 			{
704 				com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), com::sun::star::uno::UNO_QUERY);
705 				if( xDialog.is() )
706 				{
707 					xDialog->execute();
708 				}
709 			}
710 			catch( ::com::sun::star::uno::RuntimeException& )
711 			{
712 			}
713 
714 			Cancel();
715 			rReq.Ignore ();
716 		}
717 		break;
718 
719 		default:
720 		{
721 			// switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
722 			// eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp03 (drviewsb)
723 			// gewandert.
724 			FuTemp03(rReq);
725 		}
726 		break;
727 	};
728 };
729 
730 bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const String & rName  )
731 {
732     sal_Bool   bOutDummy;
733     if( GetDoc()->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
734         return false;
735 
736     SdPage* pPageToRename = NULL;
737     PageKind ePageKind = GetPageKind();
738 
739     if( GetEditMode() == EM_PAGE )
740     {
741         pPageToRename = GetDoc()->GetSdPage( nPageId - 1, ePageKind );
742 
743         // Undo
744         SdPage* pUndoPage = pPageToRename;
745         SdrLayerAdmin &  rLayerAdmin = GetDoc()->GetLayerAdmin();
746         sal_uInt8 nBackground = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRND )), sal_False );
747         sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ )), sal_False );
748         SetOfByte aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
749 
750         // (#67720#)
751         ::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
752         ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
753             GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(),
754             aVisibleLayers.IsSet( nBackground ),
755             aVisibleLayers.IsSet( nBgObj ));
756         pManager->AddUndoAction( pAction );
757 
758         // rename
759         pPageToRename->SetName( rName );
760 
761         if( ePageKind == PK_STANDARD )
762         {
763             // also rename notes-page
764             SdPage* pNotesPage = GetDoc()->GetSdPage( nPageId - 1, PK_NOTES );
765             pNotesPage->SetName( rName );
766         }
767     }
768     else
769     {
770         // rename MasterPage -> rename LayoutTemplate
771         pPageToRename = GetDoc()->GetMasterSdPage( nPageId - 1, ePageKind );
772         GetDoc()->RenameLayoutTemplate( pPageToRename->GetLayoutName(), rName );
773     }
774 
775     bool bSuccess = ( sal_False != rName.Equals( pPageToRename->GetName()));
776 
777     if( bSuccess )
778     {
779         // user edited page names may be changed by the page so update control
780         maTabControl.SetPageText( nPageId, rName );
781 
782         // set document to modified state
783         GetDoc()->SetChanged( sal_True );
784 
785         // inform navigator about change
786 		SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True );
787 		GetViewFrame()->GetDispatcher()->Execute(
788 			SID_NAVIGATOR_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
789 
790         // Tell the slide sorter about the name change (necessary for
791         // accessibility.)
792         slidesorter::SlideSorterViewShell* pSlideSorterViewShell
793             = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
794         if (pSlideSorterViewShell != NULL)
795         {
796             pSlideSorterViewShell->GetSlideSorter().GetController().PageNameHasChanged(
797                 nPageId-1, rName);
798         }
799     }
800 
801     return bSuccess;
802 }
803 
804 
805 
806 
807 IMPL_LINK( DrawViewShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog )
808 {
809     if( ! pDialog )
810         return 0;
811 
812     String aNewName;
813     pDialog->GetName( aNewName );
814 
815     SdPage* pCurrentPage = GetDoc()->GetSdPage( maTabControl.GetCurPageId() - 1, GetPageKind() );
816 
817     return pCurrentPage && ( aNewName.Equals( pCurrentPage->GetName() ) || GetDocSh()->IsNewPageNameValid( aNewName ) );
818 }
819 
820 
821 
822 
823 void DrawViewShell::ModifyLayer (
824     SdrLayer* pLayer,
825     const String& rLayerName,
826     const String& rLayerTitle,
827     const String& rLayerDesc,
828     bool bIsVisible,
829     bool bIsLocked,
830     bool bIsPrintable)
831 {
832 	if( pLayer )
833 	{
834 		const sal_uInt16 nPageCount = GetLayerTabControl()->GetPageCount();
835 		sal_uInt16 nCurPage = 0;
836 		sal_uInt16 nPos;
837 		for( nPos = 0; nPos < nPageCount; nPos++ )
838 		{
839 			sal_uInt16 nId = GetLayerTabControl()->GetPageId( nPos );
840 			if( pLayer->GetName() == GetLayerTabControl()->GetPageText( nId ) )
841 			{
842 				nCurPage = nId;
843 				break;
844 			}
845 		}
846 
847 		pLayer->SetName( rLayerName );
848 		pLayer->SetTitle( rLayerTitle );
849 		pLayer->SetDescription( rLayerDesc );
850 		mpDrawView->SetLayerVisible( rLayerName, bIsVisible );
851 		mpDrawView->SetLayerLocked( rLayerName, bIsLocked);
852 		mpDrawView->SetLayerPrintable(rLayerName, bIsPrintable);
853 
854 		GetDoc()->SetChanged(sal_True);
855 
856 		GetLayerTabControl()->SetPageText(nCurPage, rLayerName);
857 
858 		TabBarPageBits nBits = 0;
859 
860 		if (!bIsVisible)
861 		{
862 			// Unsichtbare Layer werden anders dargestellt
863 			nBits = TPB_SPECIAL;
864 		}
865 
866 		GetLayerTabControl()->SetPageBits(nCurPage, nBits);
867 
868 		GetViewFrame()->GetDispatcher()->Execute(
869             SID_SWITCHLAYER,
870             SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
871 
872         // Call Invalidate at the form shell.
873         FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
874         if (pFormShell != NULL)
875             pFormShell->Invalidate();
876 	}
877 }
878 
879 } // end of namespace sd
880