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