Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "DrawViewShell.hxx"
22 : #include "ViewShellImplementation.hxx"
23 :
24 : #include "DrawController.hxx"
25 : #include <com/sun/star/embed/EmbedStates.hpp>
26 :
27 : #include "comphelper/anytostring.hxx"
28 : #include "comphelper/scopeguard.hxx"
29 : #include "cppuhelper/exc_hlp.hxx"
30 : #include "rtl/ref.hxx"
31 :
32 : #include <svx/svxids.hrc>
33 : #include <svx/svdpagv.hxx>
34 : #include <sfx2/viewfrm.hxx>
35 : #include <sfx2/bindings.hxx>
36 : #include <svx/svdoole2.hxx>
37 : #include <sfx2/dispatch.hxx>
38 : #include <vcl/scrbar.hxx>
39 : #include <svx/svdograf.hxx>
40 : #include <svx/svdopage.hxx>
41 : #include <vcl/msgbox.hxx>
42 : #include <sot/storage.hxx>
43 : #include <svx/fmshell.hxx>
44 : #include <svx/globl3d.hxx>
45 : #include <svx/fmglob.hxx>
46 : #include <editeng/outliner.hxx>
47 : #include <svx/dialogs.hrc>
48 :
49 : #include "view/viewoverlaymanager.hxx"
50 :
51 : #include "glob.hrc"
52 : #include "app.hrc"
53 : #include "res_bmp.hrc"
54 : #include "strings.hrc"
55 : #include "helpids.h"
56 :
57 : #include "sdmod.hxx"
58 : #include "fupoor.hxx"
59 : #include "sdresid.hxx"
60 : #include "fusel.hxx"
61 : #include "sdpage.hxx"
62 : #include "FrameView.hxx"
63 : #include "stlpool.hxx"
64 : #include "Window.hxx"
65 : #include "drawview.hxx"
66 : #include "drawdoc.hxx"
67 : #include "DrawDocShell.hxx"
68 : #include "Ruler.hxx"
69 : #include "Client.hxx"
70 : #include "slideshow.hxx"
71 : #include "optsitem.hxx"
72 : #include "fusearch.hxx"
73 : #include "Outliner.hxx"
74 : #include "AnimationChildWindow.hxx"
75 : #include "SdUnoDrawView.hxx"
76 : #include "ToolBarManager.hxx"
77 : #include "FormShellManager.hxx"
78 : #include "ViewShellBase.hxx"
79 : #include "LayerDialogChildWindow.hxx"
80 : #include "LayerTabBar.hxx"
81 : #include "ViewShellManager.hxx"
82 : #include "ViewShellHint.hxx"
83 :
84 : #include <sfx2/request.hxx>
85 : #include <boost/bind.hpp>
86 :
87 : using namespace com::sun::star;
88 :
89 : namespace sd {
90 :
91 138 : void DrawViewShell::Activate(sal_Bool bIsMDIActivate)
92 : {
93 138 : ViewShell::Activate(bIsMDIActivate);
94 138 : }
95 :
96 0 : void DrawViewShell::UIActivating( SfxInPlaceClient* pCli )
97 : {
98 0 : ViewShell::UIActivating(pCli);
99 :
100 : // Disable own controls
101 0 : maTabControl.Disable();
102 0 : if (GetLayerTabControl() != NULL)
103 0 : GetLayerTabControl()->Disable();
104 0 : }
105 :
106 0 : void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli )
107 : {
108 : // Enable own controls
109 0 : maTabControl.Enable();
110 0 : if (GetLayerTabControl() != NULL)
111 0 : GetLayerTabControl()->Enable();
112 :
113 0 : ViewShell::UIDeactivated(pCli);
114 0 : }
115 :
116 :
117 333 : void DrawViewShell::Deactivate(sal_Bool /*bIsMDIActivate*/)
118 : {
119 : // Do not forward to ViewShell::Deactivate() to prevent a context change.
120 333 : }
121 :
122 : namespace
123 : {
124 : class LockUI
125 : {
126 : private:
127 : void Lock(bool bLock);
128 : SfxViewFrame *mpFrame;
129 : public:
130 0 : LockUI(SfxViewFrame *pFrame) : mpFrame(pFrame) { Lock(true); }
131 0 : ~LockUI() { Lock(false); }
132 :
133 : };
134 :
135 0 : void LockUI::Lock(bool bLock)
136 : {
137 0 : if (!mpFrame)
138 0 : return;
139 0 : mpFrame->Enable( !bLock );
140 : }
141 : }
142 :
143 : /**
144 : * Called, if state of selection of view is changed
145 : */
146 :
147 66 : void DrawViewShell::SelectionHasChanged (void)
148 : {
149 66 : Invalidate();
150 :
151 : //Update3DWindow(); // 3D-Controller
152 66 : SfxBoolItem aItem( SID_3D_STATE, sal_True );
153 : GetViewFrame()->GetDispatcher()->Execute(
154 66 : SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
155 :
156 66 : SdrOle2Obj* pOleObj = NULL;
157 :
158 66 : if ( mpDrawView->AreObjectsMarked() )
159 : {
160 1 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
161 :
162 1 : if (rMarkList.GetMarkCount() == 1)
163 : {
164 1 : SdrMark* pMark = rMarkList.GetMark(0);
165 1 : SdrObject* pObj = pMark->GetMarkedSdrObj();
166 :
167 1 : sal_uInt32 nInv = pObj->GetObjInventor();
168 1 : sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
169 :
170 1 : if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
171 : {
172 0 : pOleObj = (SdrOle2Obj*) pObj;
173 0 : UpdateIMapDlg( pObj );
174 : }
175 1 : else if (nSdrObjKind == OBJ_GRAF)
176 0 : UpdateIMapDlg( pObj );
177 : }
178 : }
179 :
180 66 : ViewShellBase& rBase = GetViewShellBase();
181 66 : rBase.SetVerbs( uno::Sequence< embed::VerbDescriptor >() );
182 :
183 : try
184 : {
185 66 : Client* pIPClient = static_cast<Client*>(rBase.GetIPClient());
186 66 : if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
187 : {
188 : // as appropriate take ole-objects into account and deactivate
189 :
190 : // this means we recently deselected an inplace active ole object so
191 : // we need to deselect it now
192 0 : if (!pOleObj)
193 : {
194 : //#i47279# disable frame until after object has completed unload
195 0 : LockUI aUILock(GetViewFrame());
196 0 : pIPClient->DeactivateObject();
197 : //HMHmpDrView->ShowMarkHdl();
198 : }
199 : else
200 : {
201 0 : uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
202 0 : if ( xObj.is() )
203 : {
204 0 : rBase.SetVerbs( xObj->getSupportedVerbs() );
205 : }
206 : else
207 : {
208 0 : rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
209 0 : }
210 : }
211 : }
212 : else
213 : {
214 66 : if ( pOleObj )
215 : {
216 0 : uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
217 0 : if ( xObj.is() )
218 : {
219 0 : rBase.SetVerbs( xObj->getSupportedVerbs() );
220 : }
221 : else
222 : {
223 0 : rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
224 0 : }
225 : }
226 : else
227 : {
228 66 : rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
229 : }
230 : }
231 : }
232 0 : catch( ::com::sun::star::uno::Exception& )
233 : {
234 : OSL_FAIL(
235 : OString(OString("sd::DrawViewShell::SelectionHasChanged(), "
236 : "exception caught: ") +
237 : OUStringToOString(
238 : comphelper::anyToString( cppu::getCaughtException() ),
239 : RTL_TEXTENCODING_UTF8 )).getStr() );
240 : }
241 :
242 66 : if( HasCurrentFunction() )
243 : {
244 1 : GetCurrentFunction()->SelectionHasChanged();
245 : }
246 : else
247 : {
248 65 : GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
249 : }
250 :
251 : // Invalidate for every subshell
252 66 : GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
253 :
254 66 : mpDrawView->UpdateSelectionClipboard( sal_False );
255 :
256 66 : GetViewShellBase().GetDrawController().FireSelectionChangeListener();
257 66 : }
258 :
259 : /**
260 : * set zoom factor
261 : */
262 0 : void DrawViewShell::SetZoom( long nZoom )
263 : {
264 : // Make sure that the zoom factor will not be recalculated on
265 : // following window resizings.
266 0 : mbZoomOnPage = sal_False;
267 0 : ViewShell::SetZoom( nZoom );
268 0 : GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
269 0 : GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
270 0 : mpViewOverlayManager->onZoomChanged();
271 0 : }
272 :
273 : /**
274 : * Set zoom rectangle for active window
275 : */
276 :
277 215 : void DrawViewShell::SetZoomRect( const Rectangle& rZoomRect )
278 : {
279 215 : ViewShell::SetZoomRect( rZoomRect );
280 215 : GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
281 215 : GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
282 215 : mpViewOverlayManager->onZoomChanged();
283 215 : }
284 :
285 : /**
286 : * PrepareClose, as appropriate end text input, so other viewshells
287 : * discover an refreshed text objext.
288 : */
289 :
290 130 : sal_uInt16 DrawViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
291 : {
292 130 : if ( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True )
293 0 : return sal_False;
294 :
295 130 : sal_Bool bRet = sal_True;
296 :
297 130 : if( bRet && HasCurrentFunction() )
298 : {
299 130 : sal_uInt16 nID = GetCurrentFunction()->GetSlotID();
300 130 : if (nID == SID_TEXTEDIT || nID == SID_ATTR_CHAR)
301 : {
302 0 : mpDrawView->SdrEndTextEdit();
303 : }
304 : }
305 0 : else if( !bRet )
306 : {
307 0 : maCloseTimer.SetTimeoutHdl( LINK( this, DrawViewShell, CloseHdl ) );
308 0 : maCloseTimer.SetTimeout( 20 );
309 0 : maCloseTimer.Start();
310 : }
311 :
312 130 : return bRet;
313 : }
314 :
315 : /**
316 : * Set status (enabled/disabled) of menu SfxSlots
317 : */
318 :
319 359 : void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
320 : {
321 359 : if (meEditMode != eEMode || mbIsLayerModeActive != bIsLayerModeActive)
322 : {
323 143 : ViewShellManager::UpdateLock aLock (GetViewShellBase().GetViewShellManager());
324 :
325 143 : sal_uInt16 nActualPageNum = 0;
326 :
327 143 : GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode == EM_MASTERPAGE);
328 143 : GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive);
329 :
330 143 : if ( mpDrawView->IsTextEdit() )
331 : {
332 0 : mpDrawView->SdrEndTextEdit();
333 : }
334 :
335 143 : LayerTabBar* pLayerBar = GetLayerTabControl();
336 143 : if (pLayerBar != NULL)
337 52 : pLayerBar->EndEditMode();
338 143 : maTabControl.EndEditMode();
339 :
340 143 : if (mePageKind == PK_HANDOUT)
341 : {
342 : // at handouts only allow MasterPage
343 0 : eEMode = EM_MASTERPAGE;
344 : }
345 :
346 143 : GetViewShellBase().GetDrawController().BroadcastContextChange();
347 :
348 143 : meEditMode = eEMode;
349 143 : mbIsLayerModeActive = bIsLayerModeActive;
350 :
351 : // Determine whether to show the master view toolbar. The master
352 : // page mode has to be active and the shell must not be a handout
353 : // view.
354 143 : bool bShowMasterViewToolbar (meEditMode == EM_MASTERPAGE
355 143 : && GetShellType() != ViewShell::ST_HANDOUT);
356 :
357 : // If the master view toolbar is not shown we hide it before
358 : // switching the edit mode.
359 286 : if (::sd::ViewShell::mpImpl->mbIsInitialized
360 78 : && IsMainViewShell()
361 221 : && ! bShowMasterViewToolbar)
362 : {
363 78 : GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE);
364 : }
365 :
366 143 : if (meEditMode == EM_PAGE)
367 : {
368 : /******************************************************************
369 : * PAGEMODE
370 : ******************************************************************/
371 :
372 143 : maTabControl.Clear();
373 :
374 : SdPage* pPage;
375 143 : String aPageName;
376 143 : sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
377 :
378 286 : for (sal_uInt16 i = 0; i < nPageCnt; i++)
379 : {
380 143 : pPage = GetDoc()->GetSdPage(i, mePageKind);
381 143 : aPageName = pPage->GetName();
382 143 : maTabControl.InsertPage(i + 1, aPageName);
383 :
384 143 : if ( pPage->IsSelected() && nActualPageNum == 0 )
385 : {
386 78 : nActualPageNum = i;
387 : }
388 : }
389 :
390 143 : maTabControl.SetCurPageId(nActualPageNum + 1);
391 :
392 143 : SwitchPage(nActualPageNum);
393 : }
394 : else
395 : {
396 : /******************************************************************
397 : * MASTERPAGE
398 : ******************************************************************/
399 : GetViewFrame()->SetChildWindow(
400 0 : AnimationChildWindow::GetChildWindowId(), sal_False );
401 :
402 0 : if (!mpActualPage)
403 : {
404 : // as long as there is no mpActualPage, take first
405 0 : mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
406 : }
407 :
408 0 : maTabControl.Clear();
409 0 : sal_uInt16 nActualMasterPageNum = 0;
410 0 : sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
411 :
412 0 : for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
413 : {
414 0 : SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
415 0 : String aLayoutName(pMaster->GetLayoutName());
416 0 : aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
417 :
418 0 : maTabControl.InsertPage(i + 1, aLayoutName);
419 :
420 0 : if (&(mpActualPage->TRG_GetMasterPage()) == pMaster)
421 : {
422 0 : nActualMasterPageNum = i;
423 : }
424 0 : }
425 :
426 0 : maTabControl.SetCurPageId(nActualMasterPageNum + 1);
427 0 : SwitchPage(nActualMasterPageNum);
428 : }
429 :
430 : // If the master view toolbar is to be shown we turn it on after the
431 : // edit mode has been changed.
432 286 : if (::sd::ViewShell::mpImpl->mbIsInitialized
433 78 : && IsMainViewShell()
434 221 : && bShowMasterViewToolbar)
435 : {
436 0 : GetViewShellBase().GetToolBarManager()->SetToolBar(
437 : ToolBarManager::TBG_MASTER_MODE,
438 0 : ToolBarManager::msMasterViewToolBar);
439 : }
440 :
441 143 : if ( ! mbIsLayerModeActive)
442 : {
443 78 : maTabControl.Show();
444 : // Set the tab control only for draw pages. For master page
445 : // this has been done already above.
446 78 : if (meEditMode == EM_PAGE)
447 78 : maTabControl.SetCurPageId (nActualPageNum + 1);
448 : }
449 :
450 143 : ResetActualLayer();
451 :
452 143 : Invalidate( SID_PAGEMODE );
453 143 : Invalidate( SID_LAYERMODE );
454 143 : Invalidate( SID_MASTERPAGE );
455 143 : Invalidate( SID_DELETE_MASTER_PAGE );
456 143 : Invalidate( SID_DELETE_PAGE );
457 143 : Invalidate( SID_SLIDE_MASTERPAGE );
458 143 : Invalidate( SID_TITLE_MASTERPAGE );
459 143 : Invalidate( SID_NOTES_MASTERPAGE );
460 143 : Invalidate( SID_HANDOUT_MASTERPAGE );
461 :
462 143 : SetContextName(GetSidebarContextName());
463 : }
464 359 : }
465 :
466 :
467 :
468 :
469 6916 : bool DrawViewShell::IsLayerModeActive (void) const
470 : {
471 6916 : return mbIsLayerModeActive;
472 : }
473 :
474 :
475 : /**
476 : * Generate horizontal ruler
477 : */
478 :
479 52 : SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, sal_Bool bIsFirst)
480 : {
481 : Ruler* pRuler;
482 : WinBits aWBits;
483 52 : sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT;
484 :
485 52 : if ( bIsFirst )
486 : {
487 52 : aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD;
488 : nFlags |= ( SVXRULER_SUPPORT_SET_NULLOFFSET |
489 : SVXRULER_SUPPORT_TABS |
490 52 : SVXRULER_SUPPORT_PARAGRAPH_MARGINS ); // Neu
491 : }
492 : else
493 0 : aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER;
494 :
495 52 : pRuler = new Ruler (*this, GetParentWindow(), pWin, nFlags,
496 52 : GetViewFrame()->GetBindings(), aWBits);
497 52 : pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
498 :
499 : // Metric ...
500 52 : sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
501 :
502 52 : if( nMetric == 0xffff )
503 0 : nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
504 :
505 52 : pRuler->SetUnit( FieldUnit( nMetric ) );
506 :
507 : // ... and also set DefTab at the ruler
508 52 : pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // new
509 :
510 52 : Fraction aUIScale(pWin->GetMapMode().GetScaleX());
511 52 : aUIScale *= GetDoc()->GetUIScale();
512 52 : pRuler->SetZoom(aUIScale);
513 :
514 52 : return pRuler;
515 : }
516 :
517 : /**
518 : * Generate vertical ruler
519 : */
520 :
521 52 : SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin)
522 : {
523 : Ruler* pRuler;
524 52 : WinBits aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER;
525 52 : sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT;
526 :
527 52 : pRuler = new Ruler(*this, GetParentWindow(), pWin, nFlags,
528 52 : GetViewFrame()->GetBindings(), aWBits);
529 52 : pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
530 :
531 : // Metric same as HRuler, use document setting
532 52 : sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
533 :
534 52 : if( nMetric == 0xffff )
535 0 : nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
536 :
537 52 : pRuler->SetUnit( FieldUnit( nMetric ) );
538 :
539 52 : Fraction aUIScale(pWin->GetMapMode().GetScaleY());
540 52 : aUIScale *= GetDoc()->GetUIScale();
541 52 : pRuler->SetZoom(aUIScale);
542 :
543 52 : return pRuler;
544 : }
545 :
546 : /**
547 : * Refresh horizontal ruler
548 : */
549 :
550 332 : void DrawViewShell::UpdateHRuler()
551 : {
552 332 : Invalidate( SID_ATTR_LONG_LRSPACE );
553 332 : Invalidate( SID_RULER_PAGE_POS );
554 332 : Invalidate( SID_RULER_OBJECT );
555 332 : Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
556 :
557 332 : if (mpHorizontalRuler.get() != NULL)
558 332 : mpHorizontalRuler->ForceUpdate();
559 332 : }
560 :
561 : /**
562 : * Refresh vertical ruler
563 : */
564 :
565 330 : void DrawViewShell::UpdateVRuler()
566 : {
567 330 : Invalidate( SID_ATTR_LONG_LRSPACE );
568 330 : Invalidate( SID_RULER_PAGE_POS );
569 330 : Invalidate( SID_RULER_OBJECT );
570 :
571 330 : if (mpVerticalRuler.get() != NULL)
572 330 : mpVerticalRuler->ForceUpdate();
573 330 : }
574 :
575 : /**
576 : * Set metric
577 : */
578 :
579 0 : void DrawViewShell::SetUIUnit(FieldUnit eUnit)
580 : {
581 0 : ViewShell::SetUIUnit(eUnit);
582 0 : }
583 :
584 : /**
585 : * Refresh TabControl on splitter change
586 : */
587 :
588 0 : IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab )
589 : {
590 0 : const long int nMax = maViewSize.Width() - maScrBarWH.Width()
591 0 : - maTabControl.GetPosPixel().X() ;
592 :
593 0 : Size aTabSize = maTabControl.GetSizePixel();
594 0 : aTabSize.Width() = std::min(pTab->GetSplitSize(), (long)(nMax-1));
595 :
596 0 : maTabControl.SetSizePixel(aTabSize);
597 0 : GetLayerTabControl()->SetSizePixel(aTabSize);
598 :
599 0 : Point aPos = maTabControl.GetPosPixel();
600 0 : aPos.X() += aTabSize.Width();
601 :
602 0 : Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height());
603 0 : mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
604 :
605 0 : return 0;
606 : }
607 :
608 : /// inherited from sd::ViewShell
609 359 : SdPage* DrawViewShell::getCurrentPage() const
610 : {
611 359 : const sal_Int32 nPageCount = (meEditMode == EM_PAGE)?
612 359 : GetDoc()->GetSdPageCount(mePageKind):
613 718 : GetDoc()->GetMasterSdPageCount(mePageKind);
614 :
615 359 : sal_Int32 nCurrentPage = maTabControl.GetCurPageId() - 1;
616 : DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" );
617 359 : if( (nPageCount < 0) || (nCurrentPage>=nPageCount) )
618 0 : nCurrentPage = 0; // play safe here
619 :
620 359 : if (meEditMode == EM_PAGE)
621 : {
622 359 : return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind);
623 : }
624 : else // EM_MASTERPAGE
625 : {
626 0 : return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind);
627 : }
628 : }
629 :
630 : /**
631 : * Select new refreshed page, in case of a page order change (eg. by undo)
632 : */
633 :
634 178 : void DrawViewShell::ResetActualPage()
635 : {
636 178 : if (!GetDoc())
637 178 : return;
638 :
639 178 : sal_uInt16 nCurrentPage = maTabControl.GetCurPageId() - 1;
640 178 : sal_uInt16 nPageCount = (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
641 178 : if (nPageCount > 0)
642 178 : nCurrentPage = std::min((sal_uInt16)(nPageCount - 1), nCurrentPage);
643 : else
644 0 : nCurrentPage = 0;
645 :
646 178 : if (meEditMode == EM_PAGE)
647 : {
648 :
649 : // Update for TabControl
650 178 : maTabControl.Clear();
651 :
652 178 : SdPage* pPage = NULL;
653 178 : String aPageName;
654 :
655 416 : for (sal_uInt16 i = 0; i < nPageCount; i++)
656 : {
657 238 : pPage = GetDoc()->GetSdPage(i, mePageKind);
658 238 : aPageName = pPage->GetName();
659 238 : maTabControl.InsertPage(i + 1, aPageName);
660 :
661 : // correct selection recognition of the pages
662 238 : GetDoc()->SetSelected(pPage, i == nCurrentPage);
663 : }
664 :
665 178 : maTabControl.SetCurPageId(nCurrentPage + 1);
666 : }
667 : else // EM_MASTERPAGE
668 : {
669 0 : SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind);
670 0 : maTabControl.Clear();
671 0 : sal_uInt16 nActualMasterPageNum = 0;
672 :
673 0 : sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
674 0 : for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
675 : {
676 0 : SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
677 0 : String aLayoutName(pMaster->GetLayoutName());
678 0 : aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
679 0 : maTabControl.InsertPage(i + 1, aLayoutName);
680 :
681 0 : if (pActualPage == pMaster)
682 0 : nActualMasterPageNum = i;
683 0 : }
684 :
685 0 : maTabControl.SetCurPageId(nActualMasterPageNum + 1);
686 0 : SwitchPage(nActualMasterPageNum);
687 : }
688 :
689 : GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
690 178 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
691 : }
692 :
693 : /**
694 : * Apply "Verb" on OLE-object.
695 : */
696 :
697 0 : ErrCode DrawViewShell::DoVerb(long nVerb)
698 : {
699 0 : if ( mpDrawView->AreObjectsMarked() )
700 : {
701 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
702 :
703 0 : if (rMarkList.GetMarkCount() == 1)
704 : {
705 0 : SdrMark* pMark = rMarkList.GetMark(0);
706 0 : SdrObject* pObj = pMark->GetMarkedSdrObj();
707 :
708 0 : sal_uInt32 nInv = pObj->GetObjInventor();
709 0 : sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
710 :
711 0 : if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
712 : {
713 0 : ActivateObject( (SdrOle2Obj*) pObj, nVerb);
714 : }
715 : }
716 : }
717 :
718 0 : return 0;
719 : }
720 :
721 :
722 : /**
723 : * Activate OLE-object
724 : */
725 :
726 0 : sal_Bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
727 : {
728 0 : sal_Bool bActivated = sal_False;
729 :
730 0 : if ( !GetDocSh()->IsUIActive() )
731 : {
732 0 : ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager());
733 :
734 0 : bActivated = ViewShell::ActivateObject(pObj, nVerb);
735 :
736 : OSL_ASSERT(GetViewShell()!=NULL);
737 0 : Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient());
738 0 : if (pClient)
739 0 : pClient->SetSdrGrafObj(NULL);
740 : }
741 :
742 0 : return(bActivated);
743 : }
744 :
745 : /**
746 : * Switch to desired page.
747 : * nSelectPage refers to the current EditMode
748 : */
749 :
750 482 : void LclResetFlag (bool& rbFlag) {rbFlag = false;}
751 :
752 482 : sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
753 : {
754 : /** Under some circumstances there are nested calls to SwitchPage() and
755 : may crash the application (activation of form controls when the
756 : shell of the edit view is not on top of the shell stack, see issue
757 : 83888 for details.) Therefore the nested calls are ignored (they
758 : would jump to the wrong page anyway.)
759 : */
760 482 : if (mbIsInSwitchPage)
761 0 : return sal_False;
762 482 : mbIsInSwitchPage = true;
763 482 : comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage)));
764 :
765 482 : if (GetActiveWindow()->IsInPaint())
766 : {
767 : // Switching the current page while a Paint is being executed is
768 : // dangerous. So, post it for later execution and return.
769 : maAsynchronousSwitchPageCall.Post(::boost::bind(
770 : ::std::mem_fun(&DrawViewShell::SwitchPage),
771 : this,
772 0 : nSelectedPage));
773 0 : return sal_False;
774 : }
775 :
776 482 : sal_Bool bOK = sal_False;
777 :
778 : // With the current implementation of FuSlideShow there is a problem
779 : // when it dsplays the show in a window: When the show is stopped it
780 : // returns at one point in time SDRPAGE_NOTFOUND as current page index.
781 : // Because FuSlideShow is currently being rewritten this bug is fixed
782 : // here.
783 : // This is not as bad a hack as it may look because making SwitchPage()
784 : // more robust with respect to invalid page numbers is a good thing
785 : // anyway.
786 482 : if (nSelectedPage == SDRPAGE_NOTFOUND)
787 : {
788 0 : nSelectedPage = 0;
789 : }
790 : else
791 : {
792 : // Make sure that the given page index points to an existing page. Move
793 : // the index into the valid range if necessary.
794 482 : sal_uInt16 nPageCount = (meEditMode == EM_PAGE)
795 482 : ? GetDoc()->GetSdPageCount(mePageKind)
796 964 : : GetDoc()->GetMasterSdPageCount(mePageKind);
797 482 : if (nSelectedPage >= nPageCount)
798 0 : nSelectedPage = nPageCount-1;
799 : }
800 :
801 482 : if (IsSwitchPageAllowed())
802 : {
803 482 : ModifyGuard aGuard2( GetDoc() );
804 :
805 482 : bOK = sal_True;
806 :
807 482 : if (mpActualPage)
808 : {
809 417 : SdPage* pNewPage = NULL;
810 :
811 417 : if (meEditMode == EM_MASTERPAGE)
812 : {
813 0 : if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage )
814 0 : pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
815 :
816 0 : if( pNewPage )
817 : {
818 0 : SdrPageView* pPV = mpDrawView->GetSdrPageView();
819 0 : OUString sPageText(pNewPage->GetLayoutName());
820 0 : sal_Int32 nPos = sPageText.indexOf(SD_LT_SEPARATOR);
821 0 : if (nPos != -1)
822 0 : sPageText = sPageText.copy(0, nPos);
823 0 : if (pPV
824 0 : && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() )
825 0 : && sPageText == maTabControl.GetPageText(nSelectedPage+1))
826 : {
827 : // this slide is already visible
828 0 : return sal_True;
829 0 : }
830 : }
831 : }
832 : else
833 : {
834 : OSL_ASSERT(mpFrameView!=NULL);
835 417 : mpFrameView->SetSelectedPage(nSelectedPage);
836 :
837 417 : if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage)
838 417 : pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
839 :
840 417 : if (mpActualPage == pNewPage)
841 : {
842 413 : SdrPageView* pPV = mpDrawView->GetSdrPageView();
843 :
844 413 : SdPage* pCurrentPage = dynamic_cast< SdPage* >( pPV->GetPage());
845 826 : if (pPV
846 413 : && pNewPage == pCurrentPage
847 1652 : && maTabControl.GetPageText(nSelectedPage+1).equals(pNewPage->GetName()))
848 : {
849 : // this slide is already visible
850 412 : return sal_True;
851 : }
852 : }
853 : }
854 : }
855 :
856 70 : if( mpDrawView )
857 70 : mpDrawView->SdrEndTextEdit();
858 :
859 70 : mpActualPage = NULL;
860 :
861 70 : if (meEditMode == EM_PAGE)
862 : {
863 70 : mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
864 : }
865 : else
866 : {
867 0 : SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
868 :
869 : // does the selected page fit to the masterpage?
870 0 : sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
871 0 : for (sal_uInt16 i = 0; i < nPageCount; i++)
872 : {
873 0 : SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
874 0 : if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage()))
875 : {
876 0 : mpActualPage = pPage;
877 0 : break;
878 : }
879 : }
880 :
881 0 : if (!mpActualPage)
882 : {
883 : // take the first page, that fits to the masterpage
884 0 : for (sal_uInt16 i = 0; i < nPageCount; i++)
885 : {
886 0 : SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
887 0 : if(pPage && pMaster == &(pPage->TRG_GetMasterPage()))
888 : {
889 0 : mpActualPage = pPage;
890 0 : break;
891 : }
892 : }
893 : }
894 : }
895 :
896 145 : for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++)
897 : {
898 : // deselect all pages
899 75 : GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), sal_False);
900 : }
901 :
902 70 : if (!mpActualPage)
903 : {
904 : // as far as there is no mpActualPage, take the first
905 0 : mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
906 : }
907 :
908 : // also select this page (mpActualPage always points at a drawing page,
909 : // never at a masterpage)
910 70 : GetDoc()->SetSelected(mpActualPage, sal_True);
911 :
912 140 : rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
913 70 : if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) )
914 : {
915 : // tighten VisArea, to possibly deactivate objects
916 : // !!! only if we are not in presentation mode (#96279) !!!
917 : OSL_ASSERT (GetViewShell()!=NULL);
918 70 : GetViewShell()->DisconnectAllClients();
919 70 : VisAreaChanged(Rectangle(Point(), Size(1, 1)));
920 : }
921 :
922 70 : if (meEditMode == EM_PAGE)
923 : {
924 : /**********************************************************************
925 : * PAGEMODE
926 : **********************************************************************/
927 70 : GetDoc()->SetSelected(mpActualPage, sal_True);
928 :
929 70 : SdrPageView* pPageView = mpDrawView->GetSdrPageView();
930 :
931 70 : if (pPageView)
932 : {
933 5 : mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
934 5 : mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
935 5 : mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
936 :
937 5 : if (mePageKind == PK_NOTES)
938 : {
939 0 : mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
940 : }
941 5 : else if (mePageKind == PK_HANDOUT)
942 : {
943 0 : mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
944 : }
945 : else
946 : {
947 5 : mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
948 : }
949 : }
950 :
951 70 : mpDrawView->HideSdrPage();
952 70 : mpDrawView->ShowSdrPage(mpActualPage);
953 70 : GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage);
954 :
955 70 : SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
956 :
957 70 : if (pNewPageView)
958 : {
959 70 : pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
960 70 : pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
961 70 : pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
962 :
963 70 : if (mePageKind == PK_NOTES)
964 : {
965 0 : pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
966 : }
967 70 : else if (mePageKind == PK_HANDOUT)
968 : {
969 0 : pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
970 : }
971 : else
972 : {
973 70 : pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
974 : }
975 : }
976 :
977 70 : maTabControl.SetCurPageId(nSelectedPage+1);
978 70 : OUString aPageName = mpActualPage->GetName();
979 :
980 70 : if (maTabControl.GetPageText(nSelectedPage+1) != aPageName)
981 : {
982 1 : maTabControl.SetPageText(nSelectedPage+1, aPageName);
983 70 : }
984 : }
985 : else
986 : {
987 : /**********************************************************************
988 : * MASTERPAGE
989 : **********************************************************************/
990 0 : SdrPageView* pPageView = mpDrawView->GetSdrPageView();
991 :
992 0 : if (pPageView)
993 : {
994 0 : mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
995 0 : mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
996 0 : mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
997 :
998 0 : if (mePageKind == PK_NOTES)
999 : {
1000 0 : mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1001 : }
1002 0 : else if (mePageKind == PK_HANDOUT)
1003 : {
1004 0 : mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1005 : }
1006 : else
1007 : {
1008 0 : mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1009 : }
1010 : }
1011 :
1012 0 : mpDrawView->HideSdrPage();
1013 :
1014 0 : SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
1015 :
1016 0 : if( !pMaster ) // if this page should not exist
1017 0 : pMaster = GetDoc()->GetMasterSdPage(0, mePageKind);
1018 :
1019 0 : sal_uInt16 nNum = pMaster->GetPageNum();
1020 0 : mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum));
1021 :
1022 0 : GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster);
1023 :
1024 0 : SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1025 :
1026 0 : if (pNewPageView)
1027 : {
1028 0 : pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1029 0 : pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1030 0 : pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1031 :
1032 0 : if (mePageKind == PK_NOTES)
1033 : {
1034 0 : pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1035 : }
1036 0 : else if (mePageKind == PK_HANDOUT)
1037 : {
1038 0 : pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1039 : }
1040 : else
1041 : {
1042 0 : pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1043 : }
1044 : }
1045 :
1046 0 : OUString aLayoutName(pMaster->GetLayoutName());
1047 0 : sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
1048 0 : if (nPos != -1)
1049 0 : aLayoutName = aLayoutName.copy(0, nPos);
1050 :
1051 0 : maTabControl.SetCurPageId(nSelectedPage+1);
1052 :
1053 0 : if (maTabControl.GetPageText(nSelectedPage+1) != aLayoutName)
1054 : {
1055 0 : maTabControl.SetPageText(nSelectedPage+1, aLayoutName);
1056 : }
1057 :
1058 0 : if( mePageKind == PK_HANDOUT )
1059 : {
1060 : // set pages for all available handout presentation objects
1061 0 : sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList();
1062 0 : SdrObject* pObj = 0;
1063 0 : rShapeList.seekShape(0);
1064 :
1065 0 : while( (pObj = rShapeList.getNextShape()) )
1066 : {
1067 0 : if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT )
1068 : {
1069 : // #i105146# We want no content to be displayed for PK_HANDOUT,
1070 : // so just never set a page as content
1071 0 : static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0);
1072 : }
1073 : }
1074 0 : }
1075 : }
1076 :
1077 70 : Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
1078 70 : Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
1079 70 : VisAreaChanged(aVisAreaWin);
1080 70 : mpDrawView->VisAreaChanged(GetActiveWindow());
1081 :
1082 : // so navigator (and effect window) notice that
1083 70 : SfxBindings& rBindings = GetViewFrame()->GetBindings();
1084 70 : rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_False);
1085 70 : rBindings.Invalidate(SID_STATUS_PAGE, sal_True, sal_False);
1086 70 : rBindings.Invalidate(SID_DELETE_MASTER_PAGE, sal_True, sal_False);
1087 70 : rBindings.Invalidate(SID_DELETE_PAGE, sal_True, sal_False);
1088 70 : rBindings.Invalidate(SID_ASSIGN_LAYOUT,sal_True,sal_False);
1089 70 : rBindings.Invalidate(SID_INSERTPAGE,sal_True,sal_False);
1090 70 : UpdatePreview( mpActualPage );
1091 :
1092 140 : mpDrawView->AdjustMarkHdl();
1093 : }
1094 :
1095 70 : return (bOK);
1096 : }
1097 :
1098 :
1099 : /**
1100 : * Check if page change is allowed
1101 : */
1102 :
1103 482 : sal_Bool DrawViewShell::IsSwitchPageAllowed() const
1104 : {
1105 482 : bool bOK = true;
1106 :
1107 482 : FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
1108 482 : if (pFormShell!=NULL && !pFormShell->PrepareClose (sal_False))
1109 0 : bOK = false;
1110 :
1111 482 : return bOK;
1112 : }
1113 :
1114 : /**
1115 : * Select new refreshed page, in case of a page order change (eg. by undo)
1116 : */
1117 :
1118 210 : void DrawViewShell::ResetActualLayer()
1119 : {
1120 210 : LayerTabBar* pLayerBar = GetLayerTabControl();
1121 210 : if (pLayerBar != NULL)
1122 : {
1123 : // remember old layer cound and current layer id
1124 : // this is needed when one layer is renamed to
1125 : // restore current layer
1126 106 : sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount();
1127 106 : sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId();
1128 :
1129 : /**
1130 : * Update for LayerTab
1131 : */
1132 106 : pLayerBar->Clear();
1133 :
1134 106 : String aName;
1135 212 : String aActiveLayer = mpDrawView->GetActiveLayer();
1136 212 : String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
1137 212 : String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
1138 212 : String aLayoutLayer( SdResId(STR_LAYER_LAYOUT) );
1139 212 : String aControlsLayer( SdResId(STR_LAYER_CONTROLS) );
1140 212 : String aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES) );
1141 106 : sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND;
1142 106 : SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
1143 106 : sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
1144 :
1145 637 : for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ )
1146 : {
1147 531 : aName = rLayerAdmin.GetLayer(nLayer)->GetName();
1148 :
1149 531 : if ( aName == aActiveLayer )
1150 : {
1151 106 : nActiveLayer = nLayer;
1152 : }
1153 :
1154 531 : if ( aName != aBackgroundLayer )
1155 : {
1156 425 : if (meEditMode == EM_MASTERPAGE)
1157 : {
1158 : // don't show page layer onto the masterpage
1159 0 : if (aName != aLayoutLayer &&
1160 0 : aName != aControlsLayer &&
1161 0 : aName != aMeasureLinesLayer)
1162 : {
1163 0 : pLayerBar->InsertPage(nLayer+1, aName);
1164 :
1165 0 : TabBarPageBits nBits = 0;
1166 0 : SdrPageView* pPV = mpDrawView->GetSdrPageView();
1167 :
1168 0 : if (pPV && !pPV->IsLayerVisible(aName))
1169 : {
1170 : // invisible layers are displayed differently
1171 0 : nBits = TPB_SPECIAL;
1172 : }
1173 :
1174 0 : pLayerBar->SetPageBits(nLayer+1, nBits);
1175 : }
1176 : }
1177 : else
1178 : {
1179 : // don't show masterpage layer onto the page
1180 425 : if ( aName != aBackgroundObjLayer )
1181 : {
1182 319 : pLayerBar->InsertPage(nLayer+1, aName);
1183 :
1184 319 : TabBarPageBits nBits = 0;
1185 :
1186 319 : if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
1187 : {
1188 : // invisible layers are displayed differently
1189 0 : nBits = TPB_SPECIAL;
1190 : }
1191 :
1192 319 : pLayerBar->SetPageBits(nLayer+1, nBits);
1193 : }
1194 : }
1195 : }
1196 : }
1197 :
1198 106 : if ( nActiveLayer == SDRLAYER_NOTFOUND )
1199 : {
1200 0 : if( nOldLayerCnt == pLayerBar->GetPageCount() )
1201 : {
1202 0 : nActiveLayer = nOldLayerId - 1;
1203 : }
1204 : else
1205 : {
1206 0 : nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0;
1207 : }
1208 :
1209 0 : mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) );
1210 : }
1211 :
1212 106 : pLayerBar->SetCurPageId(nActiveLayer + 1);
1213 106 : GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
1214 212 : GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
1215 : }
1216 210 : }
1217 :
1218 : /**
1219 : * Execute a delayed close
1220 : */
1221 :
1222 0 : IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer )
1223 : {
1224 0 : pTimer->Stop();
1225 0 : GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN );
1226 0 : return 0L;
1227 : }
1228 :
1229 : /**
1230 : * AcceptDrop
1231 : */
1232 :
1233 0 : sal_Int8 DrawViewShell::AcceptDrop (
1234 : const AcceptDropEvent& rEvt,
1235 : DropTargetHelper& rTargetHelper,
1236 : ::sd::Window* pTargetWindow,
1237 : sal_uInt16 nPage,
1238 : sal_uInt16 nLayer )
1239 : {
1240 0 : if( nPage != SDRPAGE_NOTFOUND )
1241 0 : nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1242 :
1243 0 : if( SlideShow::IsRunning( GetViewShellBase() ) )
1244 0 : return DND_ACTION_NONE;
1245 :
1246 0 : return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer );
1247 : }
1248 :
1249 : /**
1250 : * ExecuteDrop
1251 : */
1252 :
1253 0 : sal_Int8 DrawViewShell::ExecuteDrop (
1254 : const ExecuteDropEvent& rEvt,
1255 : DropTargetHelper& rTargetHelper,
1256 : ::sd::Window* pTargetWindow,
1257 : sal_uInt16 nPage,
1258 : sal_uInt16 nLayer)
1259 : {
1260 0 : if( nPage != SDRPAGE_NOTFOUND )
1261 0 : nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1262 :
1263 0 : if( SlideShow::IsRunning( GetViewShellBase() ) )
1264 0 : return DND_ACTION_NONE;
1265 :
1266 0 : Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
1267 0 : sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ));
1268 0 : Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
1269 :
1270 0 : return nResult;
1271 : }
1272 :
1273 33 : } // end of namespace sd
1274 :
1275 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|