1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "DrawViewShell.hxx"
21 #include <com/sun/star/scanner/ScannerManager.hpp>
22 #include <cppuhelper/implbase1.hxx>
23 #include <comphelper/processfactory.hxx>
24 #include <editeng/sizeitem.hxx>
25 #include <svx/svdlayer.hxx>
26 #include <sfx2/zoomitem.hxx>
27 #include <svx/svdpagv.hxx>
28 #include <svl/ptitem.hxx>
29 #include <svl/stritem.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <svx/svdopath.hxx>
33 #include <sfx2/docfile.hxx>
34 #include <svx/zoomslideritem.hxx>
35 #include <svl/eitem.hxx>
37 #include <svx/dialogs.hrc>
38 #include <svx/extrusionbar.hxx>
39 #include <svx/fontworkbar.hxx>
40 #include <svx/clipfmtitem.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <svx/fmshell.hxx>
44 #include <svtools/cliplistener.hxx>
45 #include <svx/float3d.hxx>
46 #include <svx/extedit.hxx>
47 #include <svx/sidebar/SelectionAnalyzer.hxx>
50 #include "view/viewoverlaymanager.hxx"
52 #include "strings.hrc"
53 #include "res_bmp.hrc"
55 #include "FrameView.hxx"
56 #include "drawdoc.hxx"
57 #include "sdresid.hxx"
58 #include "DrawDocShell.hxx"
62 #include "drawview.hxx"
63 #include "SdUnoDrawView.hxx"
64 #include "ViewShellBase.hxx"
65 #include "slideshow.hxx"
66 #include "ToolBarManager.hxx"
67 #include "annotationmanager.hxx"
68 #include "DrawController.hxx"
70 #include <boost/bind.hpp>
71 #include <boost/scoped_ptr.hpp>
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::uno
;
75 using sfx2::sidebar::EnumContext
;
79 bool DrawViewShell::mbPipette
= false;
81 // - ScannerEventListener -
83 class ScannerEventListener
: public ::cppu::WeakImplHelper1
< lang::XEventListener
>
87 DrawViewShell
* mpParent
;
91 ScannerEventListener( DrawViewShell
* pParent
) : mpParent( pParent
) {};
92 virtual ~ScannerEventListener();
95 virtual void SAL_CALL
disposing( const lang::EventObject
& rEventObject
) throw (uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 void ParentDestroyed() { mpParent
= NULL
; }
100 ScannerEventListener::~ScannerEventListener()
104 void SAL_CALL
ScannerEventListener::disposing( const lang::EventObject
& rEventObject
) throw (uno::RuntimeException
, std::exception
)
107 mpParent
->ScannerEvent( rEventObject
);
110 DrawViewShell::DrawViewShell( SfxViewFrame
* pFrame
, ViewShellBase
& rViewShellBase
, vcl::Window
* pParentWindow
, PageKind ePageKind
, FrameView
* pFrameViewArgument
)
111 : ViewShell (pFrame
, pParentWindow
, rViewShellBase
)
112 , maTabControl(VclPtr
<sd::TabControl
>::Create(this, pParentWindow
))
113 , mbIsLayerModeActive(false)
114 , mbIsInSwitchPage(false)
115 , mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
116 ::boost::bind(&DrawViewShell::GetSidebarContextName
, this),
117 uno::Reference
<frame::XController
>(&rViewShellBase
.GetDrawController()),
118 sfx2::sidebar::EnumContext::Context_Default
))
120 if (pFrameViewArgument
!= NULL
)
121 mpFrameView
= pFrameViewArgument
;
123 mpFrameView
= new FrameView(GetDoc());
124 Construct(GetDocSh(), ePageKind
);
126 mpSelectionChangeHandler
->Connect();
128 SetContextName(GetSidebarContextName());
133 DrawViewShell::~DrawViewShell()
135 mpSelectionChangeHandler
->Disconnect();
137 mpAnnotationManager
.reset();
138 mpViewOverlayManager
.reset();
140 OSL_ASSERT (GetViewShell()!=NULL
);
142 if( mxScannerListener
.is() )
143 static_cast< ScannerEventListener
* >( mxScannerListener
.get() )->ParentDestroyed();
145 // Remove references to items within Svx3DWin
146 // (maybe do a listening sometime in Svx3DWin)
147 sal_uInt16 nId
= Svx3DChildWindow::GetChildWindowId();
148 SfxChildWindow
* pWindow
= GetViewFrame() ? GetViewFrame()->GetChildWindow(nId
) : NULL
;
151 Svx3DWin
* p3DWin
= static_cast< Svx3DWin
* > (pWindow
->GetWindow());
153 p3DWin
->DocumentReload();
156 EndListening (*GetDoc());
157 EndListening (*GetDocSh());
159 if( SlideShow::IsRunning(*this) )
160 StopSlideShow(false);
164 sal_uInt16 aPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
166 for (sal_uInt16 i
= 0; i
< aPageCnt
; i
++)
168 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
170 if (pPage
== mpActualPage
)
172 GetDoc()->SetSelected(pPage
, true);
176 GetDoc()->SetSelected(pPage
, false);
180 if ( mpClipEvtLstnr
)
182 mpClipEvtLstnr
->AddRemoveListener( GetActiveWindow(), false );
183 mpClipEvtLstnr
->ClearCallbackLink(); // prevent callback if another thread is waiting
184 mpClipEvtLstnr
->release();
188 // Set mpView to NULL so that the destructor of the ViewShell base class
189 // does not access it.
190 mpView
= mpDrawView
= NULL
;
192 mpFrameView
->Disconnect();
193 delete [] mpSlotArray
;
195 maTabControl
.disposeAndClear();
199 * common part of both constructors
201 void DrawViewShell::Construct(DrawDocShell
* pDocSh
, PageKind eInitialPageKind
)
204 mbMousePosFreezed
= false;
205 mbReadOnly
= GetDocSh()->IsReadOnly();
208 mbPastePossible
= false;
209 mbIsLayerModeActive
= false;
211 mpFrameView
->Connect();
213 OSL_ASSERT (GetViewShell()!=NULL
);
215 /* array for slot-/image mapping:
216 even entry: main-/toolbox slot
217 odd entry: mapped slot
218 Attention: adjust GetIdBySubId() !!!
219 Do not change order (especial zoom) !!! */
220 mpSlotArray
= new sal_uInt16
[ SLOTARRAY_COUNT
];
221 mpSlotArray
[ 0 ] = SID_OBJECT_CHOOSE_MODE
;
222 mpSlotArray
[ 1 ] = SID_OBJECT_ROTATE
;
223 mpSlotArray
[ 2 ] = SID_OBJECT_ALIGN
;
224 mpSlotArray
[ 3 ] = SID_OBJECT_ALIGN_LEFT
;
225 mpSlotArray
[ 4 ] = SID_ZOOM_TOOLBOX
;
226 mpSlotArray
[ 5 ] = SID_ZOOM_TOOLBOX
;
227 mpSlotArray
[ 6 ] = SID_DRAWTBX_TEXT
;
228 mpSlotArray
[ 7 ] = SID_ATTR_CHAR
;
229 mpSlotArray
[ 8 ] = SID_DRAWTBX_RECTANGLES
;
230 mpSlotArray
[ 9 ] = SID_DRAW_RECT
;
231 mpSlotArray
[ 10 ] = SID_DRAWTBX_ELLIPSES
;
232 mpSlotArray
[ 11 ] = SID_DRAW_ELLIPSE
;
233 mpSlotArray
[ 12 ] = SID_DRAWTBX_LINES
;
234 mpSlotArray
[ 13 ] = SID_DRAW_FREELINE_NOFILL
;
235 mpSlotArray
[ 14 ] = SID_DRAWTBX_3D_OBJECTS
;
236 mpSlotArray
[ 15 ] = SID_3D_CUBE
;
237 mpSlotArray
[ 16 ] = SID_DRAWTBX_INSERT
;
238 mpSlotArray
[ 17 ] = SID_INSERT_DIAGRAM
;
239 mpSlotArray
[ 18 ] = SID_POSITION
;
240 mpSlotArray
[ 19 ] = SID_FRAME_TO_TOP
;
241 mpSlotArray
[ 20 ] = SID_DRAWTBX_CONNECTORS
;
242 mpSlotArray
[ 21 ] = SID_TOOL_CONNECTOR
;
243 mpSlotArray
[ 22 ] = SID_DRAWTBX_ARROWS
;
244 mpSlotArray
[ 23 ] = SID_LINE_ARROW_END
;
246 SetPool( &GetDoc()->GetPool() );
248 GetDoc()->CreateFirstPages();
250 mpDrawView
= new DrawView(pDocSh
, GetActiveWindow(), this);
251 mpView
= mpDrawView
; // Pointer of base class ViewShell
252 mpDrawView
->SetSwapAsynchron(true); // Asynchronous load of graphics
254 // We do not read the page kind from the frame view anymore so we have
255 // to set it in order to resync frame view and this view.
256 mpFrameView
->SetPageKind(eInitialPageKind
);
257 mePageKind
= eInitialPageKind
;
258 meEditMode
= EM_PAGE
;
259 DocumentType eDocType
= GetDoc()->GetDocumentType(); // RTTI does not work here
263 meShellType
= ST_IMPRESS
;
267 meShellType
= ST_NOTES
;
271 meShellType
= ST_HANDOUT
;
275 Size
aPageSize( GetDoc()->GetSdPage(0, mePageKind
)->GetSize() );
276 Point
aPageOrg( aPageSize
.Width(), aPageSize
.Height() / 2);
277 Size
aSize(aPageSize
.Width() * 3, aPageSize
.Height() * 2);
278 InitWindows(aPageOrg
, aSize
, Point(-1, -1));
282 if ( pDocSh
->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
284 aVisAreaPos
= pDocSh
->GetVisArea(ASPECT_CONTENT
).TopLeft();
287 mpDrawView
->SetWorkArea(Rectangle(Point() - aVisAreaPos
- aPageOrg
, aSize
));
289 // objects can not grow bigger than ViewSize
290 GetDoc()->SetMaxObjSize(aSize
);
292 // Split-Handler for TabControls
293 maTabControl
->SetSplitHdl( LINK( this, DrawViewShell
, TabSplitHdl
) );
295 /* In order to set the correct EditMode of the FrameView, we select another
296 one (small trick). */
297 if (mpFrameView
->GetViewShEditMode(mePageKind
) == EM_PAGE
)
299 meEditMode
= EM_MASTERPAGE
;
303 meEditMode
= EM_PAGE
;
306 // Use configuration of FrameView
307 ReadFrameViewData(mpFrameView
);
309 if( eDocType
== DOCUMENT_TYPE_DRAW
)
311 SetHelpId( SD_IF_SDGRAPHICVIEWSHELL
);
312 GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL
);
313 GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL
);
317 if (mePageKind
== PK_NOTES
)
319 SetHelpId( SID_NOTESMODE
);
320 GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE
);
321 GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE
);
323 // AutoLayouts have to be created
324 GetDoc()->StopWorkStartupDelay();
326 else if (mePageKind
== PK_HANDOUT
)
328 SetHelpId( SID_HANDOUTMODE
);
329 GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE
);
330 GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE
);
332 // AutoLayouts have to be created
333 GetDoc()->StopWorkStartupDelay();
337 SetHelpId( SD_IF_SDDRAWVIEWSHELL
);
338 GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL
);
339 GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL
);
343 // start selection function
344 SfxRequest
aReq(SID_OBJECT_SELECT
, SfxCallMode::SLOT
, GetDoc()->GetItemPool());
346 mpDrawView
->SetFrameDragSingles(true);
348 if (pDocSh
->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
350 mbZoomOnPage
= false;
357 mbIsRulerDrag
= false;
359 OUString
aName( "DrawViewShell" );
364 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
368 mxScannerManager
= scanner::ScannerManager::create( xContext
);
370 mxScannerListener
= uno::Reference
< lang::XEventListener
>(
371 static_cast< ::cppu::OWeakObject
* >( new ScannerEventListener( this ) ),
374 catch (Exception
& exception
)
376 // Eat the exception and log it
377 // We can still continue if scanner manager is not available.
378 SAL_WARN("sd", "Scanner manager exception: " << exception
.Message
);
381 mpAnnotationManager
.reset( new AnnotationManager( GetViewShellBase() ) );
382 mpViewOverlayManager
.reset( new ViewOverlayManager( GetViewShellBase() ) );
385 void DrawViewShell::Init (bool bIsMainViewShell
)
387 ViewShell::Init(bIsMainViewShell
);
389 StartListening (*GetDocSh());
392 void DrawViewShell::Shutdown()
394 ViewShell::Shutdown();
396 if(SlideShow::IsRunning( GetViewShellBase() ) )
399 GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE
);
403 css::uno::Reference
<css::drawing::XDrawSubController
> DrawViewShell::CreateSubController()
405 css::uno::Reference
<css::drawing::XDrawSubController
> xSubController
;
407 if (IsMainViewShell())
409 // Create uno sub controller for the main view shell.
410 xSubController
= css::uno::Reference
<css::drawing::XDrawSubController
>(
416 return xSubController
;
419 bool DrawViewShell::RelocateToParentWindow (vcl::Window
* pParentWindow
)
421 // DrawViewShells can not be relocated to a new parent window at the
422 // moment, so return <FALSE/> except when the given parent window is the
423 // parent window that is already in use.
424 return pParentWindow
==GetParentWindow();
428 * check if we have to draw a polyline
432 Polylines are represented by makros as a sequence of:
434 LineTo (x, y) [or BezierTo (x, y)]
437 There is no end command for polylines. Therefore, we have to test all
438 commands in the requests for LineTo (BezierTo) and we have to gather
439 the point-parameter. The first not-LineTo leads to the creation of the
440 polyline from the gathered points.
443 void DrawViewShell::CheckLineTo(SfxRequest
& rReq
)
449 if(SID_LINETO
== rReq
.GetSlot() || SID_BEZIERTO
== rReq
.GetSlot() || SID_MOVETO
== rReq
.GetSlot() )
451 OSL_FAIL("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
460 * Change page parameter if SID_PAGESIZE or SID_PAGEMARGIN
462 void DrawViewShell::SetupPage (Size
&rSize
,
471 sal_uInt16 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
474 for (i
= 0; i
< nPageCnt
; i
++)
476 // first, handle all master pages
477 SdPage
*pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
483 Rectangle
aBorderRect(nLeft
, nUpper
, nRight
, nLower
);
484 pPage
->ScaleObjects(rSize
, aBorderRect
, bScaleAll
);
485 pPage
->SetSize(rSize
);
490 pPage
->SetLftBorder(nLeft
);
491 pPage
->SetRgtBorder(nRight
);
492 pPage
->SetUppBorder(nUpper
);
493 pPage
->SetLwrBorder(nLower
);
496 if ( mePageKind
== PK_STANDARD
)
498 GetDoc()->GetMasterSdPage(i
, PK_NOTES
)->CreateTitleAndLayout();
501 pPage
->CreateTitleAndLayout();
505 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
507 for (i
= 0; i
< nPageCnt
; i
++)
509 // then, handle all pages
510 SdPage
*pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
516 Rectangle
aBorderRect(nLeft
, nUpper
, nRight
, nLower
);
517 pPage
->ScaleObjects(rSize
, aBorderRect
, bScaleAll
);
518 pPage
->SetSize(rSize
);
522 pPage
->SetLftBorder(nLeft
);
523 pPage
->SetRgtBorder(nRight
);
524 pPage
->SetUppBorder(nUpper
);
525 pPage
->SetLwrBorder(nLower
);
528 if ( mePageKind
== PK_STANDARD
)
530 SdPage
* pNotesPage
= GetDoc()->GetSdPage(i
, PK_NOTES
);
531 pNotesPage
->SetAutoLayout( pNotesPage
->GetAutoLayout() );
534 pPage
->SetAutoLayout( pPage
->GetAutoLayout() );
538 if ( mePageKind
== PK_STANDARD
)
540 SdPage
* pHandoutPage
= GetDoc()->GetSdPage(0, PK_HANDOUT
);
541 pHandoutPage
->CreateTitleAndLayout(true);
544 long nWidth
= mpActualPage
->GetSize().Width();
545 long nHeight
= mpActualPage
->GetSize().Height();
547 Point
aPageOrg(nWidth
, nHeight
/ 2);
548 Size
aSize( nWidth
* 3, nHeight
* 2);
550 InitWindows(aPageOrg
, aSize
, Point(-1, -1), true);
554 if ( GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
556 aVisAreaPos
= GetDocSh()->GetVisArea(ASPECT_CONTENT
).TopLeft();
559 GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos
- aPageOrg
, aSize
));
563 Point
aNewOrigin(mpActualPage
->GetLftBorder(), mpActualPage
->GetUppBorder());
564 GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin
);
566 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET
);
568 // zoom onto (new) page size
569 GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE
,
570 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
573 void DrawViewShell::GetStatusBarState(SfxItemSet
& rSet
)
576 Here we should propagate the corresponding value (Optimal ?, page width
577 or page) with the help of the ZoomItems !!! */
578 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_ATTR_ZOOM
) )
580 if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
582 rSet
.DisableItem( SID_ATTR_ZOOM
);
586 boost::scoped_ptr
<SvxZoomItem
> pZoomItem
;
587 sal_uInt16 nZoom
= (sal_uInt16
) GetActiveWindow()->GetZoom();
590 pZoomItem
.reset(new SvxZoomItem( SvxZoomType::WHOLEPAGE
, nZoom
));
592 pZoomItem
.reset(new SvxZoomItem( SvxZoomType::PERCENT
, nZoom
));
595 SvxZoomEnableFlags nZoomValues
= SvxZoomEnableFlags::ALL
;
596 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
598 if( ( pPageView
&& pPageView
->GetObjList()->GetObjCount() == 0 ) )
599 // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
601 nZoomValues
&= ~SvxZoomEnableFlags::OPTIMAL
;
604 pZoomItem
->SetValueSet( nZoomValues
);
605 rSet
.Put( *pZoomItem
);
608 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_ATTR_ZOOMSLIDER
) )
610 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
611 if (GetDocSh()->IsUIActive() || (xSlideshow
.is() && xSlideshow
->isRunning()) || !GetActiveWindow() )
613 rSet
.DisableItem( SID_ATTR_ZOOMSLIDER
);
617 sd::Window
* pActiveWindow
= GetActiveWindow();
618 SvxZoomSliderItem
aZoomItem( (sal_uInt16
) pActiveWindow
->GetZoom(), (sal_uInt16
)pActiveWindow
->GetMinZoom(), (sal_uInt16
)pActiveWindow
->GetMaxZoom() ) ;
620 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
623 Point
aPagePos(0, 0);
624 Size aPageSize
= pPageView
->GetPage()->GetSize();
626 aPagePos
.X() += aPageSize
.Width() / 2;
627 aPageSize
.Width() = (long) (aPageSize
.Width() * 1.03);
629 aPagePos
.Y() += aPageSize
.Height() / 2;
630 aPageSize
.Height() = (long) (aPageSize
.Height() * 1.03);
631 aPagePos
.Y() -= aPageSize
.Height() / 2;
633 aPagePos
.X() -= aPageSize
.Width() / 2;
635 Rectangle
aFullPageZoomRect( aPagePos
, aPageSize
);
636 aZoomItem
.AddSnappingPoint( pActiveWindow
->GetZoomForRect( aFullPageZoomRect
) );
638 aZoomItem
.AddSnappingPoint(100);
639 rSet
.Put( aZoomItem
);
643 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
646 Point aPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
647 pPageView
->LogicToPagePos(aPos
);
648 Fraction
aUIScale(GetDoc()->GetUIScale());
649 aPos
.X() = Fraction(aPos
.X()) / aUIScale
;
650 aPos
.Y() = Fraction(aPos
.Y()) / aUIScale
;
652 // position- and size items
653 if ( mpDrawView
->IsAction() )
656 mpDrawView
->TakeActionRect( aRect
);
658 if ( aRect
.IsEmpty() )
659 rSet
.Put( SfxPointItem(SID_ATTR_POSITION
, aPos
) );
662 pPageView
->LogicToPagePos(aRect
);
663 aPos
= aRect
.TopLeft();
664 aPos
.X() = Fraction(aPos
.X()) / aUIScale
;
665 aPos
.Y() = Fraction(aPos
.Y()) / aUIScale
;
666 rSet
.Put( SfxPointItem( SID_ATTR_POSITION
, aPos
) );
667 Size
aSize( aRect
.Right() - aRect
.Left(), aRect
.Bottom() - aRect
.Top() );
668 aSize
.Height() = Fraction(aSize
.Height()) / aUIScale
;
669 aSize
.Width() = Fraction(aSize
.Width()) / aUIScale
;
670 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
, aSize
) );
675 if ( mpDrawView
->AreObjectsMarked() )
677 Rectangle aRect
= mpDrawView
->GetAllMarkedRect();
678 pPageView
->LogicToPagePos(aRect
);
680 // Show the position of the selected shape(s)
681 Point
aShapePosition (aRect
.TopLeft());
682 aShapePosition
.X() = Fraction(aShapePosition
.X()) / aUIScale
;
683 aShapePosition
.Y() = Fraction(aShapePosition
.Y()) / aUIScale
;
684 rSet
.Put (SfxPointItem(SID_ATTR_POSITION
, aShapePosition
));
686 Size
aSize( aRect
.Right() - aRect
.Left(), aRect
.Bottom() - aRect
.Top() );
687 aSize
.Height() = Fraction(aSize
.Height()) / aUIScale
;
688 aSize
.Width() = Fraction(aSize
.Width()) / aUIScale
;
689 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
, aSize
) );
693 rSet
.Put( SfxPointItem(SID_ATTR_POSITION
, aPos
) );
694 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
, Size( 0, 0 ) ) );
699 // Display of current page and layer.
700 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_STATUS_PAGE
) )
702 sal_Int32 nPageCount
= sal_Int32(GetDoc()->GetSdPageCount(mePageKind
));
703 sal_Int32 nActivePageCount
= sal_Int32(GetDoc()->GetActiveSdPageCount());
704 // Always show the slide/page number.
705 OUString aOUString
= (nPageCount
== nActivePageCount
) ? SD_RESSTR(STR_SD_PAGE_COUNT
) : SD_RESSTR(STR_SD_PAGE_COUNT_CUSTOM
);
707 aOUString
= aOUString
.replaceFirst("%1", OUString::number(maTabControl
->GetCurPageId()));
708 aOUString
= aOUString
.replaceFirst("%2", OUString::number(nPageCount
));
709 if(nPageCount
!= nActivePageCount
)
710 aOUString
= aOUString
.replaceFirst("%3", OUString::number(nActivePageCount
));
712 // If in layer mode additionally show the layer that contains all
713 // selected shapes of the page. If the shapes are distributed on
714 // more than one layer, no layer name is shown.
715 if (IsLayerModeActive())
717 SdrLayerAdmin
& rLayerAdmin
= GetDoc()->GetLayerAdmin();
718 SdrLayerID nLayer
= 0, nOldLayer
= 0;
719 SdrObject
* pObj
= NULL
;
720 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
721 const size_t nMarkCount
= rMarkList
.GetMarkCount();
722 bool bOneLayer
= true;
724 // Use the first ten selected shapes as a (hopefully
725 // representative) sample of all shapes of the current page.
726 // Detect whether they belong to the same layer.
727 for( size_t j
= 0; j
< nMarkCount
&& bOneLayer
&& j
< 10; ++j
)
729 pObj
= rMarkList
.GetMark( j
)->GetMarkedSdrObj();
732 nLayer
= pObj
->GetLayer();
734 if( j
!= 0 && nLayer
!= nOldLayer
)
741 // Append the layer name to the current page number.
742 if( bOneLayer
&& nMarkCount
)
744 SdrLayer
* pLayer
= rLayerAdmin
.GetLayerPerID( nLayer
);
748 aOUString
+= pLayer
->GetName();
754 rSet
.Put (SfxStringItem (SID_STATUS_PAGE
, aOUString
));
757 if( SfxItemState::DEFAULT
== rSet
.GetItemState( SID_STATUS_LAYOUT
) )
759 OUString aString
= mpActualPage
->GetLayoutName();
760 sal_Int32 nPos
= aString
.indexOf(SD_LT_SEPARATOR
);
762 aString
= aString
.copy(0, nPos
);
763 rSet
.Put( SfxStringItem( SID_STATUS_LAYOUT
, aString
) );
767 void DrawViewShell::Notify (SfxBroadcaster
&, const SfxHint
& rHint
)
769 const SfxSimpleHint
* pSimple
= dynamic_cast< const SfxSimpleHint
* >(&rHint
);
770 if (pSimple
!=NULL
&& pSimple
->GetId()==SFX_HINT_MODECHANGED
)
772 // Change to selection when turning on read-only mode.
773 if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection
* >( GetCurrentFunction().get() ) )
775 SfxRequest
aReq(SID_OBJECT_SELECT
, SfxCallMode::SLOT
, GetDoc()->GetItemPool());
779 // Turn on design mode when document is not read-only.
780 if (GetDocSh()->IsReadOnly() != mbReadOnly
)
782 mbReadOnly
= GetDocSh()->IsReadOnly();
784 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !mbReadOnly
);
785 GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE
,
786 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, &aItem
, 0L );
792 void DrawViewShell::ExecuteAnnotation (SfxRequest
& rRequest
)
794 if( mpAnnotationManager
.get() )
795 mpAnnotationManager
->ExecuteAnnotation( rRequest
);
798 void DrawViewShell::GetAnnotationState (SfxItemSet
& rItemSet
)
800 if( mpAnnotationManager
.get() )
801 mpAnnotationManager
->GetAnnotationState( rItemSet
);
804 ::rtl::OUString
DrawViewShell::GetSidebarContextName() const
806 svx::sidebar::SelectionAnalyzer::ViewType
eViewType (svx::sidebar::SelectionAnalyzer::VT_Standard
);
810 eViewType
= svx::sidebar::SelectionAnalyzer::VT_Handout
;
813 eViewType
= svx::sidebar::SelectionAnalyzer::VT_Notes
;
816 if (meEditMode
== EM_MASTERPAGE
)
817 eViewType
= svx::sidebar::SelectionAnalyzer::VT_Master
;
819 eViewType
= svx::sidebar::SelectionAnalyzer::VT_Standard
;
822 return EnumContext::GetContextName(
823 svx::sidebar::SelectionAnalyzer::GetContextForSelection_SD(
824 mpDrawView
->GetMarkedObjectList(),
828 } // end of namespace sd
830 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */