merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / view / drviewsb.cxx
blobaf83e39f11a035dabc1c4e76b870ec8a6c6966d3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviewsb.cxx,v $
10 * $Revision: 1.32 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
34 #include <comphelper/processfactory.hxx>
35 #include <svx/svdlayer.hxx>
36 #ifndef _SVXIDS_HXX
37 #include <svx/svxids.hrc>
38 #endif
40 #include <svx/hyprlink.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <svx/hlnkitem.hxx>
43 #include <tools/urlobj.hxx>
44 #include <svx/eeitem.hxx>
45 #ifndef _FLDITEM_HXX
46 #include <svx/flditem.hxx>
47 #endif
48 #include <vcl/msgbox.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <svx/svdorect.hxx>
52 #include <sfx2/docfile.hxx>
53 #include <basic/sbstar.hxx>
54 #include <basic/sberrors.hxx>
55 #include <svx/fmshell.hxx>
56 #include <svx/svxdlg.hxx>
57 #include <svx/dialogs.hrc>
58 #include <svtools/useroptions.hxx>
60 #include "app.hrc"
61 #include "strings.hrc"
62 #include "res_bmp.hrc"
63 #include "glob.hrc"
64 #include "Outliner.hxx"
65 #include "Window.hxx"
66 #include "app.hxx"
67 #include "sdattr.hxx"
68 #include "drawdoc.hxx"
69 #include "DrawDocShell.hxx"
70 #include "sdresid.hxx"
71 #include "sdpage.hxx"
72 #include "DrawViewShell.hxx"
73 #include "drawview.hxx"
74 #include "unmodpg.hxx"
75 #include "undolayer.hxx"
76 #include "ViewShellBase.hxx"
77 #include "FormShellManager.hxx"
78 #include "LayerTabBar.hxx"
79 #include "sdabstdlg.hxx"
80 #include "SlideSorterViewShell.hxx"
81 #include "SlideSorter.hxx"
82 #include "controller/SlideSorterController.hxx"
84 #define RET_DELETE 100
86 namespace sd {
88 /*************************************************************************
90 |* SfxRequests fuer temporaere Funktionen
92 \************************************************************************/
94 void DrawViewShell::FuTemp02(SfxRequest& rReq)
96 USHORT nSId = rReq.GetSlot();
97 switch( nSId )
99 case SID_INSERTLAYER:
101 if ( mpDrawView->IsTextEdit() )
103 mpDrawView->SdrEndTextEdit();
106 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
107 USHORT nLayerCnt = rLayerAdmin.GetLayerCount();
108 USHORT nLayer = nLayerCnt - 2 + 1;
109 String aLayerName ( SdResId(STR_LAYER) ), aLayerTitle, aLayerDesc;
110 aLayerName += String::CreateFromInt32( (sal_Int32)nLayer );
111 BOOL bIsVisible = FALSE;
112 BOOL bIsLocked = FALSE;
113 BOOL bIsPrintable = FALSE;
115 const SfxItemSet* pArgs = rReq.GetArgs();
117 if (! pArgs)
119 SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
121 aNewAttr.Put( SdAttrLayerName( aLayerName ) );
122 aNewAttr.Put( SdAttrLayerTitle() );
123 aNewAttr.Put( SdAttrLayerDesc() );
124 aNewAttr.Put( SdAttrLayerVisible() );
125 aNewAttr.Put( SdAttrLayerPrintable() );
126 aNewAttr.Put( SdAttrLayerLocked() );
127 aNewAttr.Put( SdAttrLayerThisPage() );
129 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
130 AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, true, String( SdResId( STR_INSERTLAYER ) ) ) : 0;
131 if( pDlg )
133 pDlg->SetHelpId( SID_INSERTLAYER );
135 // Ueberpruefung auf schon vorhandene Namen
136 BOOL bLoop = TRUE;
137 while( bLoop && pDlg->Execute() == RET_OK )
139 pDlg->GetAttr( aNewAttr );
140 aLayerName = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
142 if( rLayerAdmin.GetLayer( aLayerName, FALSE )
143 || aLayerName.Len()==0 )
145 // Name ist schon vorhanden
146 WarningBox aWarningBox (
147 GetParentWindow(),
148 WinBits( WB_OK ),
149 String(SdResId( STR_WARN_NAME_DUPLICATE)));
150 aWarningBox.Execute();
152 else
153 bLoop = FALSE;
155 if( bLoop ) // wurde abgebrochen
157 delete pDlg;
159 Cancel();
160 rReq.Ignore ();
161 break;
163 else
165 //pDlg->GetAttr( aNewAttr );
166 //aLayerName = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
167 aLayerTitle = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
168 aLayerDesc = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
169 bIsVisible = ((SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
170 bIsLocked = ((SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ;
171 bIsPrintable = ((SdAttrLayerPrintable &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ;
173 delete pDlg;
177 else if (pArgs->Count () != 4)
179 StarBASIC::FatalError (SbERR_WRONG_ARGS);
180 Cancel();
181 rReq.Ignore ();
182 break;
184 else
186 SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, FALSE);
187 SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, FALSE);
188 SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, FALSE);
189 SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, FALSE);
191 aLayerName = pLayerName->GetValue ();
192 bIsVisible = pIsVisible->GetValue ();
193 bIsLocked = pIsLocked->GetValue ();
194 bIsPrintable = pIsPrintable->GetValue ();
197 String aPrevLayer = mpDrawView->GetActiveLayer();
198 String aName;
199 SdrLayer* pLayer;
200 USHORT nPrevLayer = 0;
201 nLayerCnt = rLayerAdmin.GetLayerCount();
203 for ( nLayer = 0; nLayer < nLayerCnt; nLayer++ )
205 pLayer = rLayerAdmin.GetLayer(nLayer);
206 aName = pLayer->GetName();
208 if ( aPrevLayer == aName )
210 // nPrevLayer = nLayer;
211 nPrevLayer = Max(nLayer, (USHORT) 4);
215 mpDrawView->InsertNewLayer(aLayerName, nPrevLayer + 1);
216 pLayer = rLayerAdmin.GetLayer(aLayerName, FALSE);
217 if( pLayer )
219 pLayer->SetTitle( aLayerTitle );
220 pLayer->SetDescription( aLayerDesc );
223 mpDrawView->SetLayerVisible( aLayerName, bIsVisible );
224 mpDrawView->SetLayerLocked( aLayerName, bIsLocked);
225 mpDrawView->SetLayerPrintable(aLayerName, bIsPrintable);
227 mpDrawView->SetActiveLayer(aLayerName);
229 ResetActualLayer();
231 GetDoc()->SetChanged(TRUE);
233 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHLAYER,
234 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
236 Cancel();
237 rReq.Done ();
239 break;
241 case SID_MODIFYLAYER:
243 if ( mpDrawView->IsTextEdit() )
245 mpDrawView->SdrEndTextEdit();
248 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
249 USHORT nCurPage = GetLayerTabControl()->GetCurPageId();
250 String aLayerName( GetLayerTabControl()->GetPageText(nCurPage) );
251 SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName, FALSE);
253 String aLayerTitle( pLayer->GetTitle() );
254 String aLayerDesc( pLayer->GetDescription() );
256 String aOldLayerName( aLayerName );
257 String aOldLayerTitle( aLayerTitle );
258 String aOldLayerDesc( aLayerDesc );
260 BOOL bIsVisible, bIsLocked, bIsPrintable;
261 BOOL bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName);
262 BOOL bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName);
263 BOOL bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName);
266 const SfxItemSet* pArgs = rReq.GetArgs();
267 // darf der Layer geloescht werden ?
268 bool bDelete = true;
270 String aLayoutLayer ( SdResId(STR_LAYER_LAYOUT) );
271 String aControlsLayer ( SdResId(STR_LAYER_CONTROLS) );
272 String aMeasureLinesLayer ( SdResId(STR_LAYER_MEASURELINES) );
273 String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
274 String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
276 if( aLayerName == aLayoutLayer || aLayerName == aControlsLayer ||
277 aLayerName == aMeasureLinesLayer ||
278 aLayerName == aBackgroundLayer || aLayerName == aBackgroundObjLayer )
280 bDelete = false;
283 if (! pArgs)
285 SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
287 aNewAttr.Put( SdAttrLayerName( aLayerName ) );
288 aNewAttr.Put( SdAttrLayerTitle( aLayerTitle ) );
289 aNewAttr.Put( SdAttrLayerDesc( aLayerDesc ) );
290 aNewAttr.Put( SdAttrLayerVisible( bIsVisible ) );
291 aNewAttr.Put( SdAttrLayerLocked( bIsLocked ) );
292 aNewAttr.Put( SdAttrLayerPrintable( bIsPrintable ) );
293 aNewAttr.Put( SdAttrLayerThisPage() );
295 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
296 AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, bDelete, String( SdResId( STR_MODIFYLAYER ) ) ) : 0;
297 if( pDlg )
299 pDlg->SetHelpId( SID_MODIFYLAYER );
301 // Ueberpruefung auf schon vorhandene Namen
302 BOOL bLoop = TRUE;
303 USHORT nRet = 0;
304 while( bLoop && ( (nRet = pDlg->Execute()) == RET_OK ) )
306 pDlg->GetAttr( aNewAttr );
307 aLayerName = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
309 if( (rLayerAdmin.GetLayer( aLayerName, FALSE ) &&
310 aLayerName != aOldLayerName) || aLayerName.Len()==0 )
312 // Name ist schon vorhanden
313 WarningBox aWarningBox (
314 GetParentWindow(),
315 WinBits( WB_OK ),
316 String( SdResId( STR_WARN_NAME_DUPLICATE)));
317 aWarningBox.Execute();
319 else
320 bLoop = FALSE;
322 switch (nRet)
324 case RET_OK :
325 aLayerTitle = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
326 aLayerDesc = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
327 bIsVisible = ((const SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
328 bIsLocked = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue ();
329 bIsPrintable = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue ();
331 delete pDlg;
332 break;
334 default :
335 delete pDlg;
336 rReq.Ignore ();
337 Cancel ();
338 return;
342 else if (pArgs->Count () == 4)
344 SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, FALSE);
345 SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, FALSE);
346 SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, FALSE);
347 SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, FALSE);
349 aLayerName = pLayerName->GetValue ();
350 bIsVisible = pIsVisible->GetValue ();
351 bIsLocked = pIsLocked->GetValue ();
352 bIsPrintable = pIsPrintable->GetValue ();
354 else
356 StarBASIC::FatalError (SbERR_WRONG_ARGS);
357 Cancel ();
358 rReq.Ignore ();
359 break;
362 SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
363 SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction(
364 GetDoc(),
365 pLayer,
366 // old values
367 aOldLayerName,
368 aOldLayerTitle,
369 aOldLayerDesc,
370 bOldIsVisible,
371 bOldIsLocked,
372 bOldIsPrintable,
373 // new values
374 aLayerName,
375 aLayerTitle,
376 aLayerDesc,
377 bIsVisible,
378 bIsLocked,
379 bIsPrintable
381 pManager->AddUndoAction( pAction );
383 ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable );
385 Cancel();
386 rReq.Done ();
388 break;
390 case SID_RENAMELAYER:
392 if ( mpDrawView->IsTextEdit() )
394 mpDrawView->SdrEndTextEdit();
397 GetLayerTabControl()->StartEditMode(
398 GetLayerTabControl()->GetCurPageId() );
400 Cancel();
401 rReq.Ignore ();
403 break;
405 case SID_EDIT_HYPERLINK :
407 GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
409 Cancel();
410 rReq.Done ();
412 break;
414 case SID_OPEN_HYPERLINK:
416 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
417 if ( pOutView )
419 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
420 if ( pFieldItem )
422 const SvxFieldData* pField = pFieldItem->GetField();
423 if( pField && pField->ISA( SvxURLField ) )
425 const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
427 SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
428 SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
430 String aReferName;
431 SfxViewFrame* pFrame = GetViewFrame();
432 SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
433 if (pMed)
434 aReferName = pMed->GetName();
436 SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
437 SfxStringItem aReferer( SID_REFERER, aReferName );
439 SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, FALSE );
440 SfxBoolItem aBrowsing( SID_BROWSE, TRUE );
442 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
443 if (pViewFrm)
444 pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
445 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
446 &aUrl, &aTarget,
447 &aFrm, &aReferer,
448 &aNewView, &aBrowsing,
449 0L );
453 Cancel();
454 rReq.Done ();
456 break;
458 case SID_HYPERLINK_SETLINK:
460 const SfxItemSet* pReqArgs = rReq.GetArgs();
462 if (pReqArgs)
464 SvxHyperlinkItem* pHLItem =
465 (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK);
467 if (pHLItem->GetInsertMode() == HLINK_FIELD)
469 InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
470 pHLItem->GetTargetFrame(), NULL);
472 else if (pHLItem->GetInsertMode() == HLINK_BUTTON)
474 InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
475 pHLItem->GetTargetFrame(), NULL);
477 else if (pHLItem->GetInsertMode() == HLINK_DEFAULT)
479 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
481 if (pOlView)
483 InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
484 pHLItem->GetTargetFrame(), NULL);
486 else
488 InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
489 pHLItem->GetTargetFrame(), NULL);
494 Cancel();
495 rReq.Ignore ();
497 break;
499 case SID_INSERT_FLD_DATE_FIX:
500 case SID_INSERT_FLD_DATE_VAR:
501 case SID_INSERT_FLD_TIME_FIX:
502 case SID_INSERT_FLD_TIME_VAR:
503 case SID_INSERT_FLD_AUTHOR:
504 case SID_INSERT_FLD_PAGE:
505 case SID_INSERT_FLD_PAGES:
506 case SID_INSERT_FLD_FILE:
508 USHORT nMul = 1;
509 SvxFieldItem* pFieldItem = 0;
511 switch( nSId )
513 case SID_INSERT_FLD_DATE_FIX:
514 pFieldItem = new SvxFieldItem(
515 SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
516 break;
518 case SID_INSERT_FLD_DATE_VAR:
519 pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD );
520 break;
522 case SID_INSERT_FLD_TIME_FIX:
523 pFieldItem = new SvxFieldItem(
524 SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD );
525 break;
527 case SID_INSERT_FLD_TIME_VAR:
528 pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD );
529 break;
531 case SID_INSERT_FLD_AUTHOR:
533 SvtUserOptions aUserOptions;
534 pFieldItem = new SvxFieldItem(
535 SvxAuthorField(
536 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD );
538 break;
540 case SID_INSERT_FLD_PAGE:
542 pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
543 nMul = 3;
545 break;
547 case SID_INSERT_FLD_PAGES:
549 pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD );
550 nMul = 3;
552 break;
554 case SID_INSERT_FLD_FILE:
556 String aName;
557 if( GetDocSh()->HasName() )
558 aName = GetDocSh()->GetMedium()->GetName();
559 //else
560 // aName = GetDocSh()->GetName();
561 pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD );
563 break;
566 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
568 if( pOLV )
570 const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection();
572 if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) ||
573 pOldFldItem->GetField()->ISA( SvxDateField ) ||
574 pOldFldItem->GetField()->ISA( SvxTimeField ) ||
575 pOldFldItem->GetField()->ISA( SvxExtTimeField ) ||
576 pOldFldItem->GetField()->ISA( SvxExtFileField ) ||
577 pOldFldItem->GetField()->ISA( SvxAuthorField ) ||
578 pOldFldItem->GetField()->ISA( SvxPageField ) ) )
580 // Feld selektieren, so dass es beim Insert geloescht wird
581 ESelection aSel = pOLV->GetSelection();
582 if( aSel.nStartPos == aSel.nEndPos )
583 aSel.nEndPos++;
584 pOLV->SetSelection( aSel );
587 if( pFieldItem )
588 pOLV->InsertField( *pFieldItem );
590 else
592 Outliner* pOutl = GetDoc()->GetInternalOutliner();
593 pOutl->Init( OUTLINERMODE_TEXTOBJECT );
594 USHORT nOutlMode = pOutl->GetMode();
595 pOutl->SetStyleSheet( 0, NULL );
596 pOutl->QuickInsertField( *pFieldItem, ESelection() );
597 OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
599 SdrRectObj* pRectObj = new SdrRectObj( OBJ_TEXT );
600 pRectObj->SetMergedItem(SdrTextAutoGrowWidthItem(TRUE));
602 pOutl->UpdateFields();
603 pOutl->SetUpdateMode( TRUE );
604 Size aSize( pOutl->CalcTextSize() );
605 aSize.Width() *= nMul;
606 pOutl->SetUpdateMode( FALSE );
608 Point aPos;
609 Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() );
610 aPos = aRect.Center();
611 aPos = GetActiveWindow()->PixelToLogic(aPos);
612 aPos.X() -= aSize.Width() / 2;
613 aPos.Y() -= aSize.Height() / 2;
615 Rectangle aLogicRect(aPos, aSize);
616 pRectObj->SetLogicRect(aLogicRect);
617 pRectObj->SetOutlinerParaObject( pOutlParaObject );
618 mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
619 pOutl->Init( nOutlMode );
622 delete pFieldItem;
624 Cancel();
625 rReq.Ignore ();
627 break;
629 case SID_MODIFY_FIELD:
631 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
633 if( pOLV )
635 const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection();
637 if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
638 pFldItem->GetField()->ISA( SvxAuthorField ) ||
639 pFldItem->GetField()->ISA( SvxExtFileField ) ||
640 pFldItem->GetField()->ISA( SvxExtTimeField ) ) )
642 // Dialog...
643 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
644 AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOLV->GetAttribs() ) : 0;
645 if( pDlg && pDlg->Execute() == RET_OK )
647 // #108538#
648 // To make a correct SetAttribs() call at the utlinerView
649 // it is necessary to split the actions here
650 SvxFieldData* pField = pDlg->GetField();
651 ESelection aSel = pOLV->GetSelection();
652 sal_Bool bSelectionWasModified(sal_False);
654 if( pField )
656 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
658 if( aSel.nStartPos == aSel.nEndPos )
660 bSelectionWasModified = sal_True;
661 aSel.nEndPos++;
662 pOLV->SetSelection( aSel );
665 pOLV->InsertField( aFieldItem );
667 // #108538# select again for eventual SetAttribs call
668 pOLV->SetSelection( aSel );
671 SfxItemSet aSet( pDlg->GetItemSet() );
673 if( aSet.Count() )
675 pOLV->SetAttribs( aSet );
677 ::Outliner* pOutliner = pOLV->GetOutliner();
678 if( pOutliner )
679 pOutliner->UpdateFields();
682 if(pField)
684 // #108538# restore selection to original
685 if(bSelectionWasModified)
687 aSel.nEndPos--;
688 pOLV->SetSelection( aSel );
691 delete pField;
694 delete pDlg;
698 Cancel();
699 rReq.Ignore ();
701 break;
703 case SID_OPEN_XML_FILTERSETTINGS:
707 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);
708 if( xDialog.is() )
710 xDialog->execute();
713 catch( ::com::sun::star::uno::RuntimeException& )
717 Cancel();
718 rReq.Ignore ();
720 break;
722 default:
724 // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
725 // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp03 (drviewsb)
726 // gewandert.
727 FuTemp03(rReq);
729 break;
733 bool DrawViewShell::RenameSlide( USHORT nPageId, const String & rName )
735 BOOL bOutDummy;
736 if( GetDoc()->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
737 return false;
739 SdPage* pPageToRename = NULL;
740 PageKind ePageKind = GetPageKind();
742 if( GetEditMode() == EM_PAGE )
744 pPageToRename = GetDoc()->GetSdPage( nPageId - 1, ePageKind );
746 // Undo
747 SdPage* pUndoPage = pPageToRename;
748 SdrLayerAdmin & rLayerAdmin = GetDoc()->GetLayerAdmin();
749 BYTE nBackground = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRND )), FALSE );
750 BYTE nBgObj = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ )), FALSE );
751 SetOfByte aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
753 // (#67720#)
754 SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
755 ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
756 pManager, GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(),
757 aVisibleLayers.IsSet( nBackground ),
758 aVisibleLayers.IsSet( nBgObj ));
759 pManager->AddUndoAction( pAction );
761 // rename
762 pPageToRename->SetName( rName );
764 if( ePageKind == PK_STANDARD )
766 // also rename notes-page
767 SdPage* pNotesPage = GetDoc()->GetSdPage( nPageId - 1, PK_NOTES );
768 pNotesPage->SetName( rName );
771 else
773 // rename MasterPage -> rename LayoutTemplate
774 pPageToRename = GetDoc()->GetMasterSdPage( nPageId - 1, ePageKind );
775 GetDoc()->RenameLayoutTemplate( pPageToRename->GetLayoutName(), rName );
778 bool bSuccess = ( FALSE != rName.Equals( pPageToRename->GetName()));
780 if( bSuccess )
782 // user edited page names may be changed by the page so update control
783 maTabControl.SetPageText( nPageId, rName );
785 // set document to modified state
786 GetDoc()->SetChanged( TRUE );
788 // inform navigator about change
789 SfxBoolItem aItem( SID_NAVIGATOR_INIT, TRUE );
790 GetViewFrame()->GetDispatcher()->Execute(
791 SID_NAVIGATOR_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
793 // Tell the slide sorter about the name change (necessary for
794 // accessibility.)
795 slidesorter::SlideSorterViewShell* pSlideSorterViewShell
796 = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
797 if (pSlideSorterViewShell != NULL)
799 pSlideSorterViewShell->GetSlideSorter().GetController().PageNameHasChanged(
800 nPageId-1, rName);
804 return bSuccess;
810 IMPL_LINK( DrawViewShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog )
812 if( ! pDialog )
813 return 0;
815 String aNewName;
816 pDialog->GetName( aNewName );
818 SdPage* pCurrentPage = GetDoc()->GetSdPage( maTabControl.GetCurPageId() - 1, GetPageKind() );
820 return pCurrentPage && ( aNewName.Equals( pCurrentPage->GetName() ) || GetDocSh()->IsNewPageNameValid( aNewName ) );
826 void DrawViewShell::ModifyLayer (
827 SdrLayer* pLayer,
828 const String& rLayerName,
829 const String& rLayerTitle,
830 const String& rLayerDesc,
831 bool bIsVisible,
832 bool bIsLocked,
833 bool bIsPrintable)
835 if( pLayer )
837 const USHORT nPageCount = GetLayerTabControl()->GetPageCount();
838 USHORT nCurPage = 0;
839 USHORT nPos;
840 for( nPos = 0; nPos < nPageCount; nPos++ )
842 USHORT nId = GetLayerTabControl()->GetPageId( nPos );
843 if( pLayer->GetName() == GetLayerTabControl()->GetPageText( nId ) )
845 nCurPage = nId;
846 break;
850 pLayer->SetName( rLayerName );
851 pLayer->SetTitle( rLayerTitle );
852 pLayer->SetDescription( rLayerDesc );
853 mpDrawView->SetLayerVisible( rLayerName, bIsVisible );
854 mpDrawView->SetLayerLocked( rLayerName, bIsLocked);
855 mpDrawView->SetLayerPrintable(rLayerName, bIsPrintable);
857 GetDoc()->SetChanged(TRUE);
859 GetLayerTabControl()->SetPageText(nCurPage, rLayerName);
861 TabBarPageBits nBits = 0;
863 if (!bIsVisible)
865 // Unsichtbare Layer werden anders dargestellt
866 nBits = TPB_SPECIAL;
869 GetLayerTabControl()->SetPageBits(nCurPage, nBits);
871 GetViewFrame()->GetDispatcher()->Execute(
872 SID_SWITCHLAYER,
873 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
875 // Call Invalidate at the form shell.
876 FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
877 if (pFormShell != NULL)
878 pFormShell->Invalidate();
882 } // end of namespace sd