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