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 <com/sun/star/scanner/ScannerManager.hpp>
23 : #include <cppuhelper/implbase1.hxx>
24 : #include <comphelper/processfactory.hxx>
25 : #ifndef _SVX_SIZEITEM
26 : #include <editeng/sizeitem.hxx>
27 : #endif
28 : #include <svx/svdlayer.hxx>
29 : #ifndef _SVX_ZOOMITEM
30 : #include <sfx2/zoomitem.hxx>
31 : #endif
32 : #include <svx/svdpagv.hxx>
33 : #include <svl/ptitem.hxx>
34 : #include <svl/stritem.hxx>
35 : #include <sfx2/request.hxx>
36 : #include <sfx2/dispatch.hxx>
37 : #include <svx/svdopath.hxx>
38 : #include <sfx2/docfile.hxx>
39 : #include <svx/zoomslideritem.hxx>
40 : #include <svl/eitem.hxx>
41 :
42 : #include <svx/dialogs.hrc>
43 : #include <svx/extrusionbar.hxx>
44 : #include <svx/fontworkbar.hxx>
45 : #include <svx/clipfmtitem.hxx>
46 :
47 :
48 : #include <sfx2/viewfrm.hxx>
49 : #include <svx/fmshell.hxx>
50 : #include <svtools/cliplistener.hxx>
51 : #include <svx/float3d.hxx>
52 : #include <svx/sidebar/SelectionAnalyzer.hxx>
53 : #include "helpids.h"
54 :
55 : #include "view/viewoverlaymanager.hxx"
56 : #include "app.hrc"
57 : #include "strings.hrc"
58 : #include "res_bmp.hrc"
59 : #include "sdpage.hxx"
60 : #include "FrameView.hxx"
61 : #include "drawdoc.hxx"
62 : #include "sdresid.hxx"
63 : #include "DrawDocShell.hxx"
64 : #include "Window.hxx"
65 : #include "fupoor.hxx"
66 : #include "fusel.hxx"
67 : #include "drawview.hxx"
68 : #include "SdUnoDrawView.hxx"
69 : #include "ViewShellBase.hxx"
70 : #include "slideshow.hxx"
71 : #include "ToolBarManager.hxx"
72 : #include "annotationmanager.hxx"
73 : #include "DrawController.hxx"
74 :
75 : #include <boost/bind.hpp>
76 :
77 : using namespace ::rtl;
78 : using namespace ::com::sun::star;
79 : using namespace ::com::sun::star::uno;
80 : using sfx2::sidebar::EnumContext;
81 :
82 : namespace sd {
83 :
84 : sal_Bool DrawViewShell::mbPipette = sal_False;
85 :
86 : // ------------------------
87 : // - ScannerEventListener -
88 : // ------------------------
89 :
90 : class ScannerEventListener : public ::cppu::WeakImplHelper1< lang::XEventListener >
91 : {
92 : private:
93 :
94 : DrawViewShell* mpParent;
95 :
96 : public:
97 :
98 65 : ScannerEventListener( DrawViewShell* pParent ) : mpParent( pParent ) {};
99 : ~ScannerEventListener();
100 :
101 : // XEventListener
102 : virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) throw (uno::RuntimeException);
103 :
104 65 : void ParentDestroyed() { mpParent = NULL; }
105 : };
106 :
107 : // -----------------------------------------------------------------------------
108 :
109 130 : ScannerEventListener::~ScannerEventListener()
110 : {
111 130 : }
112 :
113 : // -----------------------------------------------------------------------------
114 :
115 0 : void SAL_CALL ScannerEventListener::disposing( const lang::EventObject& rEventObject ) throw (uno::RuntimeException)
116 : {
117 0 : if( mpParent )
118 0 : mpParent->ScannerEvent( rEventObject );
119 0 : }
120 :
121 :
122 65 : DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, PageKind ePageKind, FrameView* pFrameViewArgument )
123 : : ViewShell (pFrame, pParentWindow, rViewShellBase)
124 : , maTabControl(this, pParentWindow)
125 : , mbIsLayerModeActive(false)
126 : , mbIsInSwitchPage(false)
127 : , mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
128 : ::boost::bind(&DrawViewShell::GetSidebarContextName, this),
129 65 : uno::Reference<frame::XController>(&rViewShellBase.GetDrawController()),
130 130 : sfx2::sidebar::EnumContext::Context_Default))
131 : {
132 65 : if (pFrameViewArgument != NULL)
133 0 : mpFrameView = pFrameViewArgument;
134 : else
135 65 : mpFrameView = new FrameView(GetDoc());
136 65 : Construct(GetDocSh(), ePageKind);
137 :
138 65 : mpSelectionChangeHandler->Connect();
139 :
140 65 : SetContextName(GetSidebarContextName());
141 :
142 65 : doShow();
143 65 : }
144 :
145 :
146 143 : DrawViewShell::~DrawViewShell()
147 : {
148 65 : mpSelectionChangeHandler->Disconnect();
149 :
150 65 : mpAnnotationManager.reset();
151 65 : mpViewOverlayManager.reset();
152 :
153 : OSL_ASSERT (GetViewShell()!=NULL);
154 :
155 65 : if( mxScannerListener.is() )
156 65 : static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed();
157 :
158 : // Remove references to items within Svx3DWin
159 : // (maybe do a listening sometime in Svx3DWin)
160 65 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
161 65 : SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL;
162 65 : if(pWindow)
163 : {
164 0 : Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow());
165 0 : if(p3DWin)
166 0 : p3DWin->DocumentReload();
167 : }
168 :
169 65 : EndListening (*GetDoc());
170 65 : EndListening (*GetDocSh());
171 :
172 65 : if( SlideShow::IsRunning(*this) )
173 0 : StopSlideShow(false);
174 :
175 65 : DisposeFunctions();
176 :
177 : SdPage* pPage;
178 65 : sal_uInt16 aPageCnt = GetDoc()->GetSdPageCount(mePageKind);
179 :
180 139 : for (sal_uInt16 i = 0; i < aPageCnt; i++)
181 : {
182 74 : pPage = GetDoc()->GetSdPage(i, mePageKind);
183 :
184 74 : if (pPage == mpActualPage)
185 : {
186 65 : GetDoc()->SetSelected(pPage, sal_True);
187 : }
188 : else
189 : {
190 9 : GetDoc()->SetSelected(pPage, sal_False);
191 : }
192 : }
193 :
194 65 : if ( mpClipEvtLstnr )
195 : {
196 65 : mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False );
197 65 : mpClipEvtLstnr->ClearCallbackLink(); // prevent callback if another thread is waiting
198 65 : mpClipEvtLstnr->release();
199 : }
200 :
201 65 : delete mpDrawView;
202 : // Set mpView to NULL so that the destructor of the ViewShell base class
203 : // does not access it.
204 65 : mpView = mpDrawView = NULL;
205 :
206 65 : mpFrameView->Disconnect();
207 65 : delete [] mpSlotArray;
208 78 : }
209 :
210 : /**
211 : * common part of both constructors
212 : */
213 65 : void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
214 : {
215 65 : mpActualPage = 0;
216 65 : mbMousePosFreezed = sal_False;
217 65 : mbReadOnly = GetDocSh()->IsReadOnly();
218 65 : mpSlotArray = 0;
219 65 : mpClipEvtLstnr = 0;
220 65 : mbPastePossible = sal_False;
221 65 : mbIsLayerModeActive = false;
222 :
223 65 : mpFrameView->Connect();
224 :
225 : OSL_ASSERT (GetViewShell()!=NULL);
226 :
227 : /* array for slot-/image mapping:
228 : even entry: main-/toolbox slot
229 : odd entry: mapped slot
230 : Attention: adjust GetIdBySubId() !!!
231 : Do not change order (especial zoom) !!! */
232 65 : mpSlotArray = new sal_uInt16[ SLOTARRAY_COUNT ];
233 65 : mpSlotArray[ 0 ] = SID_OBJECT_CHOOSE_MODE;
234 65 : mpSlotArray[ 1 ] = SID_OBJECT_ROTATE;
235 65 : mpSlotArray[ 2 ] = SID_OBJECT_ALIGN;
236 65 : mpSlotArray[ 3 ] = SID_OBJECT_ALIGN_LEFT;
237 65 : mpSlotArray[ 4 ] = SID_ZOOM_TOOLBOX;
238 65 : mpSlotArray[ 5 ] = SID_ZOOM_TOOLBOX;
239 65 : mpSlotArray[ 6 ] = SID_DRAWTBX_TEXT;
240 65 : mpSlotArray[ 7 ] = SID_ATTR_CHAR;
241 65 : mpSlotArray[ 8 ] = SID_DRAWTBX_RECTANGLES;
242 65 : mpSlotArray[ 9 ] = SID_DRAW_RECT;
243 65 : mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES;
244 65 : mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE;
245 65 : mpSlotArray[ 12 ] = SID_DRAWTBX_LINES;
246 65 : mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL;
247 65 : mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS;
248 65 : mpSlotArray[ 15 ] = SID_3D_CUBE;
249 65 : mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT;
250 65 : mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM;
251 65 : mpSlotArray[ 18 ] = SID_POSITION;
252 65 : mpSlotArray[ 19 ] = SID_FRAME_TO_TOP;
253 65 : mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS;
254 65 : mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR;
255 65 : mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS;
256 65 : mpSlotArray[ 23 ] = SID_LINE_ARROW_END;
257 :
258 65 : SetPool( &GetDoc()->GetPool() );
259 :
260 65 : GetDoc()->CreateFirstPages();
261 :
262 65 : mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
263 65 : mpView = mpDrawView; // Pointer of base class ViewShell
264 65 : mpDrawView->SetSwapAsynchron(sal_True); // Asynchronous load of graphics
265 :
266 : // We do not read the page kind from the frame view anymore so we have
267 : // to set it in order to resync frame view and this view.
268 65 : mpFrameView->SetPageKind(eInitialPageKind);
269 65 : mePageKind = eInitialPageKind;
270 65 : meEditMode = EM_PAGE;
271 65 : DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI does not work here
272 65 : switch (mePageKind)
273 : {
274 : case PK_STANDARD:
275 65 : meShellType = ST_IMPRESS;
276 65 : break;
277 :
278 : case PK_NOTES:
279 0 : meShellType = ST_NOTES;
280 0 : break;
281 :
282 : case PK_HANDOUT:
283 0 : meShellType = ST_HANDOUT;
284 0 : break;
285 : }
286 :
287 65 : Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() );
288 65 : Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2);
289 65 : Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
290 65 : InitWindows(aPageOrg, aSize, Point(-1, -1));
291 :
292 65 : Point aVisAreaPos;
293 :
294 65 : if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
295 : {
296 0 : aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft();
297 : }
298 :
299 65 : mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
300 :
301 : // objects can not grow bigger than ViewSize
302 65 : GetDoc()->SetMaxObjSize(aSize);
303 :
304 : // Split-Handler for TabControls
305 65 : maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) );
306 :
307 : /* In order to set the correct EditMode of the FrameView, we select another
308 : one (small trick). */
309 65 : if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
310 : {
311 65 : meEditMode = EM_MASTERPAGE;
312 : }
313 : else
314 : {
315 0 : meEditMode = EM_PAGE;
316 : }
317 :
318 : // Use configuration of FrameView
319 65 : ReadFrameViewData(mpFrameView);
320 :
321 65 : if( eDocType == DOCUMENT_TYPE_DRAW )
322 : {
323 52 : SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
324 52 : GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL );
325 52 : GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL );
326 : }
327 : else
328 : {
329 13 : if (mePageKind == PK_NOTES)
330 : {
331 0 : SetHelpId( SID_NOTESMODE );
332 0 : GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE );
333 0 : GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE );
334 :
335 : // AutoLayouts have to be created
336 0 : GetDoc()->StopWorkStartupDelay();
337 : }
338 13 : else if (mePageKind == PK_HANDOUT)
339 : {
340 0 : SetHelpId( SID_HANDOUTMODE );
341 0 : GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE );
342 0 : GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE );
343 :
344 : // AutoLayouts have to be created
345 0 : GetDoc()->StopWorkStartupDelay();
346 : }
347 : else
348 : {
349 13 : SetHelpId( SD_IF_SDDRAWVIEWSHELL );
350 13 : GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL );
351 13 : GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL );
352 : }
353 : }
354 :
355 : // start selection function
356 65 : SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
357 65 : FuPermanent(aReq);
358 65 : mpDrawView->SetFrameDragSingles(sal_True);
359 :
360 65 : if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
361 : {
362 0 : mbZoomOnPage = sal_False;
363 : }
364 : else
365 : {
366 65 : mbZoomOnPage = sal_True;
367 : }
368 :
369 65 : mbIsRulerDrag = sal_False;
370 :
371 130 : OUString aName( "DrawViewShell" );
372 65 : SetName (aName);
373 :
374 65 : mnLockCount = 0UL;
375 :
376 130 : uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
377 :
378 65 : mxScannerManager = scanner::ScannerManager::create( xContext );
379 :
380 195 : mxScannerListener = uno::Reference< lang::XEventListener >(
381 65 : static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ),
382 65 : uno::UNO_QUERY );
383 :
384 65 : mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) );
385 130 : mpViewOverlayManager.reset( new ViewOverlayManager( GetViewShellBase() ) );
386 65 : }
387 :
388 :
389 :
390 :
391 65 : void DrawViewShell::Init (bool bIsMainViewShell)
392 : {
393 65 : ViewShell::Init(bIsMainViewShell);
394 :
395 65 : StartListening (*GetDocSh());
396 65 : }
397 :
398 :
399 :
400 :
401 65 : void DrawViewShell::Shutdown (void)
402 : {
403 65 : ViewShell::Shutdown();
404 :
405 65 : if(SlideShow::IsRunning( GetViewShellBase() ) )
406 : {
407 : // Turn off effects.
408 0 : GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE);
409 : }
410 65 : }
411 :
412 :
413 :
414 :
415 65 : css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void)
416 : {
417 65 : css::uno::Reference<css::drawing::XDrawSubController> xSubController;
418 :
419 65 : if (IsMainViewShell())
420 : {
421 : // Create uno sub controller for the main view shell.
422 130 : xSubController = css::uno::Reference<css::drawing::XDrawSubController>(
423 : new SdUnoDrawView (
424 : *this,
425 130 : *GetView()));
426 : }
427 :
428 65 : return xSubController;
429 : }
430 :
431 :
432 :
433 :
434 0 : bool DrawViewShell::RelocateToParentWindow (::Window* pParentWindow)
435 : {
436 : // DrawViewShells can not be relocated to a new parent window at the
437 : // moment, so return <FALSE/> except when the given parent window is the
438 : // parent window that is already in use.
439 0 : return pParentWindow==GetParentWindow();
440 : }
441 :
442 :
443 :
444 :
445 : /**
446 : * check if we have to draw a polyline
447 : */
448 :
449 : /*
450 : Polylines are represented by makros as a sequence of:
451 : MoveTo (x, y)
452 : LineTo (x, y) [or BezierTo (x, y)]
453 : LineTo (x, y)
454 : :
455 : There is no end command for polylines. Therefore, we have to test all
456 : commands in the requests for LineTo (BezierTo) and we have to gather
457 : the point-parameter. The first not-LineTo leads to the creation of the
458 : polyline from the gathered points.
459 : */
460 :
461 646 : void DrawViewShell::CheckLineTo(SfxRequest& rReq)
462 : {
463 : (void)rReq;
464 : #ifdef DBG_UTIL
465 : if(rReq.IsAPI())
466 : {
467 : if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() )
468 : {
469 : OSL_FAIL("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
470 : }
471 : }
472 : #endif
473 :
474 646 : rReq.Ignore ();
475 646 : }
476 :
477 : /**
478 : * Change page parameter if SID_PAGESIZE or SID_PAGEMARGIN
479 : */
480 0 : void DrawViewShell::SetupPage (Size &rSize,
481 : long nLeft,
482 : long nRight,
483 : long nUpper,
484 : long nLower,
485 : sal_Bool bSize,
486 : sal_Bool bMargin,
487 : sal_Bool bScaleAll)
488 : {
489 0 : sal_uInt16 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
490 : sal_uInt16 i;
491 :
492 0 : for (i = 0; i < nPageCnt; i++)
493 : {
494 : // first, handle all master pages
495 0 : SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
496 :
497 0 : if( pPage )
498 : {
499 0 : if( bSize )
500 : {
501 0 : Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
502 0 : pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
503 0 : pPage->SetSize(rSize);
504 :
505 : }
506 0 : if( bMargin )
507 : {
508 0 : pPage->SetLftBorder(nLeft);
509 0 : pPage->SetRgtBorder(nRight);
510 0 : pPage->SetUppBorder(nUpper);
511 0 : pPage->SetLwrBorder(nLower);
512 : }
513 :
514 0 : if ( mePageKind == PK_STANDARD )
515 : {
516 0 : GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
517 : }
518 :
519 0 : pPage->CreateTitleAndLayout();
520 : }
521 : }
522 :
523 0 : nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
524 :
525 0 : for (i = 0; i < nPageCnt; i++)
526 : {
527 : // then, handle all pages
528 0 : SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind);
529 :
530 0 : if( pPage )
531 : {
532 0 : if( bSize )
533 : {
534 0 : Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
535 0 : pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
536 0 : pPage->SetSize(rSize);
537 : }
538 0 : if( bMargin )
539 : {
540 0 : pPage->SetLftBorder(nLeft);
541 0 : pPage->SetRgtBorder(nRight);
542 0 : pPage->SetUppBorder(nUpper);
543 0 : pPage->SetLwrBorder(nLower);
544 : }
545 :
546 0 : if ( mePageKind == PK_STANDARD )
547 : {
548 0 : SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
549 0 : pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
550 : }
551 :
552 0 : pPage->SetAutoLayout( pPage->GetAutoLayout() );
553 : }
554 : }
555 :
556 0 : if ( mePageKind == PK_STANDARD )
557 : {
558 0 : SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
559 0 : pHandoutPage->CreateTitleAndLayout(sal_True);
560 : }
561 :
562 0 : long nWidth = mpActualPage->GetSize().Width();
563 0 : long nHeight = mpActualPage->GetSize().Height();
564 :
565 0 : Point aPageOrg(nWidth, nHeight / 2);
566 0 : Size aSize( nWidth * 3, nHeight * 2);
567 :
568 0 : InitWindows(aPageOrg, aSize, Point(-1, -1), sal_True);
569 :
570 0 : Point aVisAreaPos;
571 :
572 0 : if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
573 : {
574 0 : aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
575 : }
576 :
577 0 : GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
578 :
579 0 : UpdateScrollBars();
580 :
581 0 : Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder());
582 0 : GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin);
583 :
584 0 : GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
585 :
586 : // zoom onto (new) page size
587 : GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
588 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
589 0 : }
590 :
591 :
592 466 : void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
593 : {
594 : /* Zoom-Item
595 : Here we should propagate the corresponding value (Optimal ?, page width
596 : or page) with the help of the ZoomItems !!! */
597 466 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) )
598 : {
599 139 : if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
600 : {
601 0 : rSet.DisableItem( SID_ATTR_ZOOM );
602 : }
603 : else
604 : {
605 : SvxZoomItem* pZoomItem;
606 139 : sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
607 :
608 139 : if( mbZoomOnPage )
609 139 : pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom );
610 : else
611 0 : pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
612 :
613 : // constrain area
614 139 : sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
615 139 : SdrPageView* pPageView = mpDrawView->GetSdrPageView();
616 :
617 139 : if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
618 : // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
619 : {
620 77 : nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
621 : }
622 :
623 139 : pZoomItem->SetValueSet( nZoomValues );
624 139 : rSet.Put( *pZoomItem );
625 139 : delete pZoomItem;
626 : }
627 : }
628 466 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
629 : {
630 139 : rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
631 139 : if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() )
632 : {
633 0 : rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
634 : }
635 : else
636 : {
637 139 : sd::Window * pActiveWindow = GetActiveWindow();
638 139 : SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
639 :
640 139 : SdrPageView* pPageView = mpDrawView->GetSdrPageView();
641 139 : if( pPageView )
642 : {
643 139 : Point aPagePos(0, 0);
644 139 : Size aPageSize = pPageView->GetPage()->GetSize();
645 :
646 139 : aPagePos.X() += aPageSize.Width() / 2;
647 139 : aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
648 :
649 139 : aPagePos.Y() += aPageSize.Height() / 2;
650 139 : aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
651 139 : aPagePos.Y() -= aPageSize.Height() / 2;
652 :
653 139 : aPagePos.X() -= aPageSize.Width() / 2;
654 :
655 139 : Rectangle aFullPageZoomRect( aPagePos, aPageSize );
656 139 : aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) );
657 : }
658 139 : aZoomItem.AddSnappingPoint(100);
659 139 : rSet.Put( aZoomItem );
660 139 : }
661 : }
662 :
663 466 : Point aPos = GetActiveWindow()->PixelToLogic(maMousePos);
664 466 : mpDrawView->GetSdrPageView()->LogicToPagePos(aPos);
665 466 : Fraction aUIScale(GetDoc()->GetUIScale());
666 466 : aPos.X() = Fraction(aPos.X()) / aUIScale;
667 466 : aPos.Y() = Fraction(aPos.Y()) / aUIScale;
668 :
669 : // position- and size items
670 466 : if ( mpDrawView->IsAction() )
671 : {
672 0 : Rectangle aRect;
673 0 : mpDrawView->TakeActionRect( aRect );
674 :
675 0 : if ( aRect.IsEmpty() )
676 0 : rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
677 : else
678 : {
679 0 : mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
680 0 : aPos = aRect.TopLeft();
681 0 : aPos.X() = Fraction(aPos.X()) / aUIScale;
682 0 : aPos.Y() = Fraction(aPos.Y()) / aUIScale;
683 0 : rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) );
684 0 : Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
685 0 : aSize.Height() = Fraction(aSize.Height()) / aUIScale;
686 0 : aSize.Width() = Fraction(aSize.Width()) / aUIScale;
687 0 : rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
688 : }
689 : }
690 : else
691 : {
692 466 : if ( mpDrawView->AreObjectsMarked() )
693 : {
694 0 : Rectangle aRect = mpDrawView->GetAllMarkedRect();
695 0 : mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
696 :
697 : // Show the position of the selected shape(s)
698 0 : Point aShapePosition (aRect.TopLeft());
699 0 : aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale;
700 0 : aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale;
701 0 : rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition));
702 :
703 0 : Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
704 0 : aSize.Height() = Fraction(aSize.Height()) / aUIScale;
705 0 : aSize.Width() = Fraction(aSize.Width()) / aUIScale;
706 0 : rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
707 : }
708 : else
709 : {
710 466 : rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
711 466 : rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
712 : }
713 : }
714 :
715 : // Display of current page and layer.
716 466 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) )
717 : {
718 141 : sal_Int32 nPageCount = sal_Int32(GetDoc()->GetSdPageCount(mePageKind));
719 141 : sal_Int32 nActivePageCount = sal_Int32(GetDoc()->GetActiveSdPageCount());
720 : // Always show the slide/page number.
721 141 : OUString aOUString = SD_RESSTR(STR_SD_PAGE);
722 141 : aOUString += " ";
723 141 : aOUString += OUString::valueOf( sal_Int32(maTabControl.GetCurPageId()) );
724 141 : aOUString += " / " ;
725 141 : aOUString += OUString::valueOf( nPageCount );
726 141 : if (nPageCount != nActivePageCount)
727 : {
728 0 : aOUString += " (";
729 0 : aOUString += OUString::valueOf( nActivePageCount );
730 0 : aOUString += ")";
731 : }
732 :
733 : // If in layer mode additionally show the layer that contains all
734 : // selected shapes of the page. If the shapes are distributed on
735 : // more than one layer, no layer name is shown.
736 141 : if (IsLayerModeActive())
737 : {
738 62 : SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
739 62 : SdrLayerID nLayer = 0, nOldLayer = 0;
740 62 : SdrLayer* pLayer = NULL;
741 62 : SdrObject* pObj = NULL;
742 62 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
743 62 : sal_uLong nMarkCount = rMarkList.GetMarkCount();
744 62 : bool bOneLayer = true;
745 :
746 : // Use the first ten selected shapes as a (hopefully
747 : // representative) sample of all shapes of the current page.
748 : // Detect whether they belong to the same layer.
749 62 : for( sal_uLong j = 0; j < nMarkCount && bOneLayer && j < 10; j++ )
750 : {
751 0 : pObj = rMarkList.GetMark( j )->GetMarkedSdrObj();
752 0 : if( pObj )
753 : {
754 0 : nLayer = pObj->GetLayer();
755 :
756 0 : if( j != 0 && nLayer != nOldLayer )
757 0 : bOneLayer = sal_False;
758 :
759 0 : nOldLayer = nLayer;
760 : }
761 : }
762 :
763 : // Append the layer name to the current page number.
764 62 : if( bOneLayer && nMarkCount )
765 : {
766 0 : pLayer = rLayerAdmin.GetLayerPerID( nLayer );
767 0 : if( pLayer )
768 : {
769 0 : aOUString += " (" ;
770 0 : aOUString += pLayer->GetName();
771 0 : aOUString += ")";
772 : }
773 : }
774 : }
775 :
776 141 : rSet.Put (SfxStringItem (SID_STATUS_PAGE, aOUString));
777 : }
778 : // Layout
779 466 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
780 : {
781 141 : String aString = mpActualPage->GetLayoutName();
782 141 : aString.Erase( aString.SearchAscii( SD_LT_SEPARATOR ) );
783 141 : rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) );
784 : }
785 466 : }
786 :
787 :
788 :
789 3522 : void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint)
790 : {
791 3522 : const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint);
792 3522 : if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED)
793 : {
794 : // Change to selection when turning on read-only mode.
795 4 : if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) )
796 : {
797 0 : SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
798 0 : FuPermanent(aReq);
799 : }
800 :
801 : // Turn on design mode when document is not read-only.
802 4 : if (GetDocSh()->IsReadOnly() != mbReadOnly )
803 : {
804 0 : mbReadOnly = GetDocSh()->IsReadOnly();
805 :
806 0 : SfxBoolItem aItem( SID_FM_DESIGN_MODE, !mbReadOnly );
807 : GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE,
808 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
809 : }
810 : }
811 :
812 3522 : }
813 :
814 0 : void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest)
815 : {
816 0 : if( mpAnnotationManager.get() )
817 0 : mpAnnotationManager->ExecuteAnnotation( rRequest );
818 0 : }
819 :
820 : // --------------------------------------------------------------------
821 :
822 0 : void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet )
823 : {
824 0 : if( mpAnnotationManager.get() )
825 0 : mpAnnotationManager->GetAnnotationState( rItemSet );
826 0 : }
827 :
828 :
829 :
830 :
831 412 : ::rtl::OUString DrawViewShell::GetSidebarContextName (void) const
832 : {
833 412 : ::svx::sidebar::SelectionAnalyzer::ViewType eViewType (::svx::sidebar::SelectionAnalyzer::VT_Standard);
834 412 : switch (mePageKind)
835 : {
836 : case PK_HANDOUT:
837 0 : eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Handout;
838 0 : break;
839 : case PK_NOTES:
840 0 : eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Notes;
841 0 : break;
842 : case PK_STANDARD:
843 412 : if (meEditMode == EM_MASTERPAGE)
844 0 : eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Master;
845 : else
846 412 : eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Standard;
847 412 : break;
848 : }
849 : return EnumContext::GetContextName(
850 : ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SD(
851 412 : mpDrawView->GetMarkedObjectList(),
852 412 : eViewType));
853 : }
854 :
855 :
856 33 : } // end of namespace sd
857 :
858 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|