xref: /aoo4110/main/sd/source/ui/view/drviewsb.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #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 ( mpDrawView->IsTextEdit() )
237 			{
238 				mpDrawView->SdrEndTextEdit();
239 			}
240 
241 			SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
242 			sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId();
243 			String aLayerName( GetLayerTabControl()->GetPageText(nCurPage) );
244 			SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName, sal_False);
245 
246 			String aLayerTitle( pLayer->GetTitle() );
247 			String aLayerDesc( pLayer->GetDescription() );
248 
249 			String aOldLayerName( aLayerName );
250 			String aOldLayerTitle( aLayerTitle );
251 			String aOldLayerDesc( aLayerDesc );
252 
253 			sal_Bool bIsVisible, bIsLocked, bIsPrintable;
254 			sal_Bool bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName);
255 			sal_Bool bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName);
256 			sal_Bool bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName);
257 
258 
259 			const SfxItemSet* pArgs = rReq.GetArgs();
260 			// darf der Layer geloescht werden ?
261 			bool bDelete = true;
262 
263 			String aLayoutLayer ( SdResId(STR_LAYER_LAYOUT) );
264 			String aControlsLayer ( SdResId(STR_LAYER_CONTROLS) );
265 			String aMeasureLinesLayer ( SdResId(STR_LAYER_MEASURELINES) );
266 			String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
267 			String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
268 
269 			if( aLayerName == aLayoutLayer       || aLayerName == aControlsLayer ||
270 				aLayerName == aMeasureLinesLayer ||
271 				aLayerName == aBackgroundLayer   || aLayerName == aBackgroundObjLayer )
272 			{
273 				bDelete = false;
274 			}
275 
276 			if (! pArgs)
277 			{
278 				SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
279 
280 				aNewAttr.Put( SdAttrLayerName( aLayerName ) );
281 				aNewAttr.Put( SdAttrLayerTitle( aLayerTitle ) );
282 				aNewAttr.Put( SdAttrLayerDesc( aLayerDesc ) );
283 				aNewAttr.Put( SdAttrLayerVisible( bIsVisible ) );
284 				aNewAttr.Put( SdAttrLayerLocked( bIsLocked ) );
285 				aNewAttr.Put( SdAttrLayerPrintable( bIsPrintable ) );
286 				aNewAttr.Put( SdAttrLayerThisPage() );
287 
288 				SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
289 				AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, bDelete, String( SdResId( STR_MODIFYLAYER ) ) ) : 0;
290 				if( pDlg )
291 				{
292 					pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() );
293 
294 					// Ueberpruefung auf schon vorhandene Namen
295 					sal_Bool	bLoop = sal_True;
296 					sal_uInt16	nRet = 0;
297 					while( bLoop && ( (nRet = pDlg->Execute()) == RET_OK ) )
298 					{
299 						pDlg->GetAttr( aNewAttr );
300 						aLayerName	 = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
301 
302 						if( (rLayerAdmin.GetLayer( aLayerName, sal_False ) &&
303 							 aLayerName != aOldLayerName) || aLayerName.Len()==0 )
304 						{
305 							// Name ist schon vorhanden
306 							WarningBox aWarningBox (
307 								GetParentWindow(),
308 								WinBits( WB_OK ),
309 								String( SdResId( STR_WARN_NAME_DUPLICATE)));
310 							aWarningBox.Execute();
311 						}
312 						else
313 							bLoop = sal_False;
314 					}
315 					switch (nRet)
316 					{
317 						case RET_OK :
318 							aLayerTitle  = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
319 							aLayerDesc   = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
320 							bIsVisible	 = ((const SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
321 							bIsLocked	 = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue ();
322 							bIsPrintable = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue ();
323 
324 							delete pDlg;
325 							break;
326 
327 						default :
328 							delete pDlg;
329 							rReq.Ignore ();
330 							Cancel ();
331 							return;
332 					}
333 				}
334 			}
335 			else if (pArgs->Count () == 4)
336 			{
337 				SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, sal_False);
338 				SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
339 				SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, sal_False);
340 				SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, sal_False);
341 
342 				aLayerName   = pLayerName->GetValue ();
343 				bIsVisible   = pIsVisible->GetValue ();
344 				bIsLocked	 = pIsLocked->GetValue ();
345 				bIsPrintable = pIsPrintable->GetValue ();
346 			}
347 			else
348 			{
349 				StarBASIC::FatalError (SbERR_WRONG_ARGS);
350 				Cancel ();
351 				rReq.Ignore ();
352 				break;
353 			}
354 
355 			::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
356 			SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction(
357 				GetDoc(),
358 				pLayer,
359 				// old values
360 				aOldLayerName,
361 				aOldLayerTitle,
362 				aOldLayerDesc,
363 				bOldIsVisible,
364 				bOldIsLocked,
365 				bOldIsPrintable,
366 				// new values
367 				aLayerName,
368 				aLayerTitle,
369 				aLayerDesc,
370 				bIsVisible,
371 				bIsLocked,
372 				bIsPrintable
373 				);
374 			pManager->AddUndoAction( pAction );
375 
376 			ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable );
377 
378 			Cancel();
379 			rReq.Done ();
380 		}
381 		break;
382 
383 		case SID_RENAMELAYER:
384 		{
385 			if ( mpDrawView->IsTextEdit() )
386 			{
387 				mpDrawView->SdrEndTextEdit();
388 			}
389 
390 			GetLayerTabControl()->StartEditMode(
391                 GetLayerTabControl()->GetCurPageId() );
392 
393 			Cancel();
394 			rReq.Ignore ();
395 		}
396 		break;
397 
398 		case SID_EDIT_HYPERLINK :
399 		{
400 			GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
401 
402 			Cancel();
403 			rReq.Done ();
404 		}
405 		break;
406 
407         case SID_OPEN_HYPERLINK:
408         {
409             OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
410             if ( pOutView )
411             {
412                 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
413                 if ( pFieldItem )
414                 {
415                     const SvxFieldData* pField = pFieldItem->GetField();
416                     if( pField && pField->ISA( SvxURLField ) )
417                     {
418                         const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
419 
420 						SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
421 						SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
422 
423 						String aReferName;
424 						SfxViewFrame* pFrame = GetViewFrame();
425 						SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
426 						if (pMed)
427 							aReferName = pMed->GetName();
428 
429 						SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
430 						SfxStringItem aReferer( SID_REFERER, aReferName );
431 
432 						SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_False );
433 						SfxBoolItem aBrowsing( SID_BROWSE, sal_True );
434 
435 						SfxViewFrame* pViewFrm = SfxViewFrame::Current();
436 						if (pViewFrm)
437 							pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
438 														SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
439 														&aUrl, &aTarget,
440 														&aFrm, &aReferer,
441 														&aNewView, &aBrowsing,
442 														0L );
443                     }
444                 }
445             }
446 			Cancel();
447 			rReq.Done ();
448         }
449         break;
450 
451 		case SID_HYPERLINK_SETLINK:
452 		{
453 			const SfxItemSet* pReqArgs = rReq.GetArgs();
454 
455 			if (pReqArgs)
456 			{
457 				SvxHyperlinkItem* pHLItem =
458                 (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK);
459 
460 				if (pHLItem->GetInsertMode() == HLINK_FIELD)
461 				{
462 					InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
463 								   pHLItem->GetTargetFrame(), NULL);
464 				}
465 				else if (pHLItem->GetInsertMode() == HLINK_BUTTON)
466 				{
467 					InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
468 									pHLItem->GetTargetFrame(), NULL);
469 				}
470 				else if (pHLItem->GetInsertMode() == HLINK_DEFAULT)
471 				{
472 					OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
473 
474 					if (pOlView)
475 					{
476 						InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
477 									   pHLItem->GetTargetFrame(), NULL);
478 					}
479 					else
480 					{
481 						InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
482 										pHLItem->GetTargetFrame(), NULL);
483 					}
484 				}
485 			}
486 
487 			Cancel();
488 			rReq.Ignore ();
489 		}
490 		break;
491 
492 		case SID_INSERT_FLD_DATE_FIX:
493 		case SID_INSERT_FLD_DATE_VAR:
494 		case SID_INSERT_FLD_TIME_FIX:
495 		case SID_INSERT_FLD_TIME_VAR:
496 		case SID_INSERT_FLD_AUTHOR:
497 		case SID_INSERT_FLD_PAGE:
498 		case SID_INSERT_FLD_PAGES:
499 		case SID_INSERT_FLD_FILE:
500 		{
501 			sal_uInt16 nMul = 1;
502 			SvxFieldItem* pFieldItem = 0;
503 
504 			switch( nSId )
505 			{
506 				case SID_INSERT_FLD_DATE_FIX:
507 					pFieldItem = new SvxFieldItem(
508                         SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
509 				break;
510 
511 				case SID_INSERT_FLD_DATE_VAR:
512                     pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD );
513 				break;
514 
515 				case SID_INSERT_FLD_TIME_FIX:
516 					pFieldItem = new SvxFieldItem(
517                         SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD );
518 				break;
519 
520 				case SID_INSERT_FLD_TIME_VAR:
521                     pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD );
522 				break;
523 
524 				case SID_INSERT_FLD_AUTHOR:
525 				{
526                     SvtUserOptions aUserOptions;
527                     pFieldItem = new SvxFieldItem(
528                             SvxAuthorField(
529                                 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD );
530 				}
531 				break;
532 
533 				case SID_INSERT_FLD_PAGE:
534 				{
535                     pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
536 					nMul = 3;
537 				}
538 				break;
539 
540                 case SID_INSERT_FLD_PAGES:
541 				{
542                     pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD );
543 					nMul = 3;
544 				}
545 				break;
546 
547 				case SID_INSERT_FLD_FILE:
548 				{
549 					String aName;
550 					if( GetDocSh()->HasName() )
551 						aName = GetDocSh()->GetMedium()->GetName();
552 					//else
553 					//	aName = GetDocSh()->GetName();
554                     pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD );
555 				}
556 				break;
557 			}
558 
559 			OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
560 
561 			if( pOLV )
562 			{
563 				const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection();
564 
565 				if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) ||
566 									pOldFldItem->GetField()->ISA( SvxDateField ) ||
567 									pOldFldItem->GetField()->ISA( SvxTimeField ) ||
568 									pOldFldItem->GetField()->ISA( SvxExtTimeField ) ||
569 									pOldFldItem->GetField()->ISA( SvxExtFileField ) ||
570 									pOldFldItem->GetField()->ISA( SvxAuthorField ) ||
571 									pOldFldItem->GetField()->ISA( SvxPageField ) ) )
572 				{
573 					// Feld selektieren, so dass es beim Insert geloescht wird
574 					ESelection aSel = pOLV->GetSelection();
575 					if( aSel.nStartPos == aSel.nEndPos )
576 						aSel.nEndPos++;
577 					pOLV->SetSelection( aSel );
578 				}
579 
580 				if( pFieldItem )
581 					pOLV->InsertField( *pFieldItem );
582 			}
583 			else
584 			{
585 				Outliner* pOutl = GetDoc()->GetInternalOutliner();
586 				pOutl->Init( OUTLINERMODE_TEXTOBJECT );
587 				sal_uInt16 nOutlMode = pOutl->GetMode();
588 				pOutl->SetStyleSheet( 0, NULL );
589 				pOutl->QuickInsertField( *pFieldItem, ESelection() );
590 				OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
591 
592 				SdrRectObj* pRectObj = new SdrRectObj( OBJ_TEXT );
593 				pRectObj->SetMergedItem(SdrTextAutoGrowWidthItem(sal_True));
594 
595 				pOutl->UpdateFields();
596 				pOutl->SetUpdateMode( sal_True );
597 				Size aSize( pOutl->CalcTextSize() );
598 				aSize.Width() *= nMul;
599 				pOutl->SetUpdateMode( sal_False );
600 
601 				Point aPos;
602 				Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() );
603 				aPos = aRect.Center();
604 				aPos = GetActiveWindow()->PixelToLogic(aPos);
605 				aPos.X() -= aSize.Width() / 2;
606 				aPos.Y() -= aSize.Height() / 2;
607 
608 				Rectangle aLogicRect(aPos, aSize);
609 				pRectObj->SetLogicRect(aLogicRect);
610 				pRectObj->SetOutlinerParaObject( pOutlParaObject );
611 				mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
612 				pOutl->Init( nOutlMode );
613 			}
614 
615 			delete pFieldItem;
616 
617 			Cancel();
618 			rReq.Ignore ();
619 		}
620 		break;
621 
622 		case SID_MODIFY_FIELD:
623 		{
624 			OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
625 
626 			if( pOLV )
627 			{
628 				const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection();
629 
630 				if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
631 								 pFldItem->GetField()->ISA( SvxAuthorField ) ||
632 								 pFldItem->GetField()->ISA( SvxExtFileField ) ||
633 								 pFldItem->GetField()->ISA( SvxExtTimeField ) ) )
634 				{
635 					// Dialog...
636 					SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
637 					AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOLV->GetAttribs() ) : 0;
638 					if( pDlg && pDlg->Execute() == RET_OK )
639 					{
640 						// #108538#
641 						// To make a correct SetAttribs() call at the utlinerView
642 						// it is necessary to split the actions here
643 						SvxFieldData* pField = pDlg->GetField();
644 						ESelection aSel = pOLV->GetSelection();
645 						sal_Bool bSelectionWasModified(sal_False);
646 
647 						if( pField )
648 						{
649                             SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
650 
651 							if( aSel.nStartPos == aSel.nEndPos )
652 							{
653 								bSelectionWasModified = sal_True;
654 								aSel.nEndPos++;
655 								pOLV->SetSelection( aSel );
656 							}
657 
658 							pOLV->InsertField( aFieldItem );
659 
660 							// #108538# select again for eventual SetAttribs call
661 							pOLV->SetSelection( aSel );
662 						}
663 
664 						SfxItemSet aSet( pDlg->GetItemSet() );
665 
666 						if( aSet.Count() )
667 						{
668 							pOLV->SetAttribs( aSet );
669 
670 							::Outliner* pOutliner = pOLV->GetOutliner();
671 							if( pOutliner )
672 								pOutliner->UpdateFields();
673 						}
674 
675 						if(pField)
676 						{
677 							// #108538# restore selection to original
678 							if(bSelectionWasModified)
679 							{
680 								aSel.nEndPos--;
681 								pOLV->SetSelection( aSel );
682 							}
683 
684 							delete pField;
685 						}
686 					}
687 					delete pDlg;
688 				}
689 			}
690 
691 			Cancel();
692 			rReq.Ignore ();
693 		}
694 		break;
695 
696         case SID_OPEN_XML_FILTERSETTINGS:
697         {
698 			try
699 			{
700 				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);
701 				if( xDialog.is() )
702 				{
703 					xDialog->execute();
704 				}
705 			}
706 			catch( ::com::sun::star::uno::RuntimeException& )
707 			{
708 			}
709 
710 			Cancel();
711 			rReq.Ignore ();
712 		}
713 		break;
714 
715 		default:
716 		{
717 			// switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
718 			// eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp03 (drviewsb)
719 			// gewandert.
720 			FuTemp03(rReq);
721 		}
722 		break;
723 	};
724 };
725 
RenameSlide(sal_uInt16 nPageId,const String & rName)726 bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const String & rName  )
727 {
728     sal_Bool   bOutDummy;
729     if( GetDoc()->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
730         return false;
731 
732     SdPage* pPageToRename = NULL;
733     PageKind ePageKind = GetPageKind();
734 
735     if( GetEditMode() == EM_PAGE )
736     {
737         pPageToRename = GetDoc()->GetSdPage( nPageId - 1, ePageKind );
738 
739         // Undo
740         SdPage* pUndoPage = pPageToRename;
741         SdrLayerAdmin &  rLayerAdmin = GetDoc()->GetLayerAdmin();
742         sal_uInt8 nBackground = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRND )), sal_False );
743         sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ )), sal_False );
744         SetOfByte aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
745 
746         // (#67720#)
747         ::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
748         ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
749             GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(),
750             aVisibleLayers.IsSet( nBackground ),
751             aVisibleLayers.IsSet( nBgObj ));
752         pManager->AddUndoAction( pAction );
753 
754         // rename
755         pPageToRename->SetName( rName );
756 
757         if( ePageKind == PK_STANDARD )
758         {
759             // also rename notes-page
760             SdPage* pNotesPage = GetDoc()->GetSdPage( nPageId - 1, PK_NOTES );
761             pNotesPage->SetName( rName );
762         }
763     }
764     else
765     {
766         // rename MasterPage -> rename LayoutTemplate
767         pPageToRename = GetDoc()->GetMasterSdPage( nPageId - 1, ePageKind );
768         GetDoc()->RenameLayoutTemplate( pPageToRename->GetLayoutName(), rName );
769     }
770 
771     bool bSuccess = ( sal_False != rName.Equals( pPageToRename->GetName()));
772 
773     if( bSuccess )
774     {
775         // user edited page names may be changed by the page so update control
776         maTabControl.SetPageText( nPageId, rName );
777 
778         // set document to modified state
779         GetDoc()->SetChanged( sal_True );
780 
781         // inform navigator about change
782 		SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True );
783 		GetViewFrame()->GetDispatcher()->Execute(
784 			SID_NAVIGATOR_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
785 
786         // Tell the slide sorter about the name change (necessary for
787         // accessibility.)
788         slidesorter::SlideSorterViewShell* pSlideSorterViewShell
789             = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
790         if (pSlideSorterViewShell != NULL)
791         {
792             pSlideSorterViewShell->GetSlideSorter().GetController().PageNameHasChanged(
793                 nPageId-1, rName);
794         }
795     }
796 
797     return bSuccess;
798 }
799 
800 
801 
802 
IMPL_LINK(DrawViewShell,RenameSlideHdl,AbstractSvxNameDialog *,pDialog)803 IMPL_LINK( DrawViewShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog )
804 {
805     if( ! pDialog )
806         return 0;
807 
808     String aNewName;
809     pDialog->GetName( aNewName );
810 
811     SdPage* pCurrentPage = GetDoc()->GetSdPage( maTabControl.GetCurPageId() - 1, GetPageKind() );
812 
813     return pCurrentPage && ( aNewName.Equals( pCurrentPage->GetName() ) || GetDocSh()->IsNewPageNameValid( aNewName ) );
814 }
815 
816 
817 
818 
ModifyLayer(SdrLayer * pLayer,const String & rLayerName,const String & rLayerTitle,const String & rLayerDesc,bool bIsVisible,bool bIsLocked,bool bIsPrintable)819 void DrawViewShell::ModifyLayer (
820     SdrLayer* pLayer,
821     const String& rLayerName,
822     const String& rLayerTitle,
823     const String& rLayerDesc,
824     bool bIsVisible,
825     bool bIsLocked,
826     bool bIsPrintable)
827 {
828 	if( pLayer )
829 	{
830 		const sal_uInt16 nPageCount = GetLayerTabControl()->GetPageCount();
831 		sal_uInt16 nCurPage = 0;
832 		sal_uInt16 nPos;
833 		for( nPos = 0; nPos < nPageCount; nPos++ )
834 		{
835 			sal_uInt16 nId = GetLayerTabControl()->GetPageId( nPos );
836 			if( pLayer->GetName() == GetLayerTabControl()->GetPageText( nId ) )
837 			{
838 				nCurPage = nId;
839 				break;
840 			}
841 		}
842 
843 		pLayer->SetName( rLayerName );
844 		pLayer->SetTitle( rLayerTitle );
845 		pLayer->SetDescription( rLayerDesc );
846 		mpDrawView->SetLayerVisible( rLayerName, bIsVisible );
847 		mpDrawView->SetLayerLocked( rLayerName, bIsLocked);
848 		mpDrawView->SetLayerPrintable(rLayerName, bIsPrintable);
849 
850 		GetDoc()->SetChanged(sal_True);
851 
852 		GetLayerTabControl()->SetPageText(nCurPage, rLayerName);
853 
854 		TabBarPageBits nBits = 0;
855 
856 		if (!bIsVisible)
857 		{
858 			// Unsichtbare Layer werden anders dargestellt
859 			nBits = TPB_SPECIAL;
860 		}
861 
862 		GetLayerTabControl()->SetPageBits(nCurPage, nBits);
863 
864 		GetViewFrame()->GetDispatcher()->Execute(
865             SID_SWITCHLAYER,
866             SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
867 
868         // Call Invalidate at the form shell.
869         FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
870         if (pFormShell != NULL)
871             pFormShell->Invalidate();
872 	}
873 }
874 
875 } // end of namespace sd
876