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 <config_features.h>
22 #include "DrawViewShell.hxx"
24 #include <sfx2/viewfrm.hxx>
25 #include <editeng/eeitem.hxx>
26 #include <editeng/tstpitem.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <editeng/protitem.hxx>
29 #include <editeng/frmdiritem.hxx>
30 #include <editeng/adjustitem.hxx>
31 #include <svx/ruler.hxx>
32 #include <editeng/numitem.hxx>
33 #include <svx/rulritem.hxx>
34 #include <sfx2/zoomitem.hxx>
35 #include <svx/svxids.hrc>
36 #include <svx/svdpagv.hxx>
37 #include <sfx2/request.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <tools/urlobj.hxx>
40 #include <svl/aeitem.hxx>
41 #include <svl/eitem.hxx>
42 #include <svl/rectitem.hxx>
43 #include <svl/stritem.hxx>
44 #include <svx/svdoole2.hxx>
45 #include <svl/itempool.hxx>
46 #include <svl/ptitem.hxx>
47 #include <basic/sbstar.hxx>
48 #include <basic/sberrors.hxx>
49 #include <svx/fmshell.hxx>
50 #include <svx/f3dchild.hxx>
51 #include <svx/float3d.hxx>
52 #include "optsitem.hxx"
56 #include "strings.hrc"
57 #include "res_bmp.hrc"
59 #include "sdundogr.hxx"
60 #include "undopage.hxx"
64 #include "slideshow.hxx"
65 #include "FrameView.hxx"
68 #include "sdresid.hxx"
69 #include "drawview.hxx"
70 #include "drawdoc.hxx"
72 #include "DrawDocShell.hxx"
73 #include "headerfooterdlg.hxx"
74 #include "masterlayoutdlg.hxx"
75 #include "sdabstdlg.hxx"
76 #include <sfx2/ipclient.hxx>
77 #include <tools/diagnose_ex.h>
78 #include "ViewShellBase.hxx"
79 #include "FormShellManager.hxx"
80 #include "LayerTabBar.hxx"
81 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
82 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
83 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
84 #include <com/sun/star/frame/XFrame.hpp>
85 #include <editeng/lspcitem.hxx>
86 #include <editeng/ulspitem.hxx>
87 #include <boost/scoped_ptr.hpp>
89 using namespace ::com::sun::star::uno
;
90 using namespace ::com::sun::star::drawing::framework
;
91 using ::com::sun::star::frame::XFrame
;
92 using ::com::sun::star::frame::XController
;
97 * handle SfxRequests for controller
99 void DrawViewShell::ExecCtrl(SfxRequest
& rReq
)
101 // except a page switch and jumps to bookmarks, nothing is executed during
103 if( HasCurrentFunction(SID_PRESENTATION
) &&
104 rReq
.GetSlot() != SID_SWITCHPAGE
&&
105 rReq
.GetSlot() != SID_JUMPTOMARK
)
110 // End text edit mode for some requests.
111 sal_uInt16 nSlot
= rReq
.GetSlot();
114 case SID_OUTPUT_QUALITY_COLOR
:
115 case SID_OUTPUT_QUALITY_GRAYSCALE
:
116 case SID_OUTPUT_QUALITY_BLACKWHITE
:
117 case SID_OUTPUT_QUALITY_CONTRAST
:
121 if ( mpDrawView
->IsTextEdit() )
123 mpDrawView
->SdrEndTextEdit();
127 // sal_uInt16 nSlot = rReq.GetSlot();
130 case SID_SWITCHPAGE
: // BASIC
132 // switch page in running slide show
133 if(SlideShow::IsRunning(GetViewShellBase()) && rReq
.GetArgs())
135 SFX_REQUEST_ARG(rReq
, pWhatPage
, SfxUInt32Item
, ID_VAL_WHATPAGE
, false);
136 SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber((sal_Int32
)((pWhatPage
->GetValue()-1)>>1));
140 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
141 sal_uInt16 nSelectedPage
= 0;
145 nSelectedPage
= maTabControl
->GetCurPageId() - 1;
147 else if (pArgs
->Count () == 2)
149 SFX_REQUEST_ARG (rReq
, pWhatPage
, SfxUInt32Item
, ID_VAL_WHATPAGE
, false);
150 SFX_REQUEST_ARG (rReq
, pWhatKind
, SfxUInt32Item
, ID_VAL_WHATKIND
, false);
152 sal_Int32 nWhatPage
= (sal_Int32
)pWhatPage
->GetValue ();
153 sal_Int32 nWhatKind
= (sal_Int32
)pWhatKind
->GetValue ();
154 if (! CHECK_RANGE (PK_STANDARD
, nWhatKind
, PK_HANDOUT
))
156 #if HAVE_FEATURE_SCRIPTING
157 StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
162 else if (meEditMode
!= EM_MASTERPAGE
)
164 if (! CHECK_RANGE (0, nWhatPage
, GetDoc()->GetSdPageCount((PageKind
)nWhatKind
)))
166 #if HAVE_FEATURE_SCRIPTING
167 StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
173 nSelectedPage
= (short) nWhatPage
;
174 mePageKind
= (PageKind
) nWhatKind
;
179 #if HAVE_FEATURE_SCRIPTING
180 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
186 if( GetDocSh() && (GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
))
187 GetDocSh()->SetModified();
189 SwitchPage(nSelectedPage
);
191 if(HasCurrentFunction(SID_BEZIER_EDIT
))
192 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
201 case SID_SWITCHLAYER
: // BASIC
203 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
206 bool bCurPageValid(false);
207 sal_uInt16
nCurPage(0);
209 if(GetLayerTabControl())
211 nCurPage
= GetLayerTabControl()->GetCurPageId();
212 bCurPageValid
= true;
215 if(pArgs
&& 1 == pArgs
->Count())
217 SFX_REQUEST_ARG (rReq
, pWhatLayer
, SfxUInt32Item
, ID_VAL_WHATLAYER
, false);
221 nCurPage
= (short)pWhatLayer
->GetValue();
222 bCurPageValid
= true;
228 mpDrawView
->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage
) );
237 case SID_PAGEMODE
: // BASIC
240 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
242 if ( pArgs
&& pArgs
->Count () == 2)
244 SFX_REQUEST_ARG (rReq
, pIsActive
, SfxBoolItem
, ID_VAL_ISACTIVE
, false);
245 SFX_REQUEST_ARG (rReq
, pWhatKind
, SfxUInt32Item
, ID_VAL_WHATKIND
, false);
247 sal_Int32 nWhatKind
= (sal_Int32
)pWhatKind
->GetValue ();
248 if (CHECK_RANGE (PK_STANDARD
, nWhatKind
, PK_HANDOUT
))
250 mbIsLayerModeActive
= pIsActive
->GetValue ();
251 mePageKind
= (PageKind
) nWhatKind
;
255 // turn on default layer of page
256 mpDrawView
->SetActiveLayer(SD_RESSTR(STR_LAYER_LAYOUT
));
258 ChangeEditMode(EM_PAGE
, mbIsLayerModeActive
);
266 case SID_LAYERMODE
: // BASIC
268 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
270 if ( pArgs
&& pArgs
->Count () == 2)
272 SFX_REQUEST_ARG (rReq
, pWhatLayerMode
, SfxBoolItem
, ID_VAL_ISACTIVE
, false);
273 SFX_REQUEST_ARG (rReq
, pWhatLayer
, SfxUInt32Item
, ID_VAL_WHATLAYER
, false);
275 sal_Int32 nWhatLayer
= (sal_Int32
)pWhatLayer
->GetValue ();
276 if (CHECK_RANGE (EM_PAGE
, nWhatLayer
, EM_MASTERPAGE
))
278 mbIsLayerModeActive
= pWhatLayerMode
->GetValue ();
279 meEditMode
= (EditMode
) nWhatLayer
;
283 ChangeEditMode(meEditMode
, !mbIsLayerModeActive
);
291 case SID_HEADER_AND_FOOTER
:
292 case SID_INSERT_PAGE_NUMBER
:
293 case SID_INSERT_DATE_TIME
:
295 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
296 boost::scoped_ptr
<AbstractHeaderFooterDialog
> pDlg(pFact
? pFact
->CreateHeaderFooterDialog( this, GetActiveWindow(), GetDoc(), mpActualPage
) : 0);
302 GetActiveWindow()->Invalidate();
303 UpdatePreview( mpActualPage
);
312 case SID_MASTER_LAYOUTS
:
314 SdPage
* pPage
= GetActualPage();
315 if (meEditMode
== EM_MASTERPAGE
)
316 // Use the master page of the current page.
317 pPage
= static_cast<SdPage
*>(&pPage
->TRG_GetMasterPage());
319 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
320 boost::scoped_ptr
<VclAbstractDialog
> pDlg(pFact
? pFact
->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage
) : 0);
330 case SID_OBJECTRESIZE
:
332 // The server likes to change the client size
333 OSL_ASSERT (GetViewShell()!=NULL
);
334 SfxInPlaceClient
* pIPClient
= GetViewShell()->GetIPClient();
336 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
338 const SfxRectangleItem
& rRect
=
339 static_cast<const SfxRectangleItem
&>(rReq
.GetArgs()->Get(SID_OBJECTRESIZE
));
340 Rectangle
aRect( GetActiveWindow()->PixelToLogic( rRect
.GetValue() ) );
342 if ( mpDrawView
->AreObjectsMarked() )
344 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
346 if (rMarkList
.GetMarkCount() == 1)
348 SdrMark
* pMark
= rMarkList
.GetMark(0);
349 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
351 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
354 if( pOle2Obj
->GetObjRef().is() )
356 pOle2Obj
->SetLogicRect(aRect
);
368 sal_uInt16 nId
= Svx3DChildWindow::GetChildWindowId();
369 SfxViewFrame
* pFrame
= GetViewFrame();
373 Reference
< XFrame
> xFrame( pFrame
->GetFrame().GetFrameInterface(), UNO_SET_THROW
);
375 // Save the current configuration of panes and views.
376 Reference
<XControllerManager
> xControllerManager (
377 GetViewShellBase().GetController(), UNO_QUERY_THROW
);
378 Reference
<XConfigurationController
> xConfigurationController (
379 xControllerManager
->getConfigurationController(), UNO_QUERY_THROW
);
380 Reference
<XConfiguration
> xConfiguration (
381 xConfigurationController
->getRequestedConfiguration(), UNO_SET_THROW
);
383 SfxChildWindow
* pWindow
= pFrame
->GetChildWindow(nId
);
386 Svx3DWin
* p3DWin
= static_cast<Svx3DWin
*>(pWindow
->GetWindow());
388 p3DWin
->DocumentReload();
391 // normal forwarding to ViewFrame for execution
392 GetViewFrame()->ExecuteSlot(rReq
);
394 // From here on we must cope with this object and the frame already being
395 // deleted. Do not call any methods or use data members.
396 Reference
<XController
> xController( xFrame
->getController(), UNO_SET_THROW
);
398 // Restore the configuration.
399 xControllerManager
= Reference
<XControllerManager
>( xController
, UNO_QUERY_THROW
);
400 xConfigurationController
= Reference
<XConfigurationController
>(
401 xControllerManager
->getConfigurationController());
402 if ( ! xConfigurationController
.is())
403 throw RuntimeException();
404 xConfigurationController
->restoreConfiguration(xConfiguration
);
406 catch (RuntimeException
&)
408 DBG_UNHANDLED_EXCEPTION();
411 // We have to return immediately to avoid accessing this object.
419 SFX_REQUEST_ARG(rReq
, pBookmark
, SfxStringItem
, SID_JUMPTOMARK
, false);
423 OUString
sBookmark(INetURLObject::decode(pBookmark
->GetValue(), INetURLObject::DECODE_WITH_CHARSET
));
425 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
426 if(xSlideshow
.is() && xSlideshow
->isRunning())
428 xSlideshow
->jumpToBookmark(sBookmark
);
432 GotoBookmark(sBookmark
);
440 case SID_OUTPUT_QUALITY_COLOR
:
441 case SID_OUTPUT_QUALITY_GRAYSCALE
:
442 case SID_OUTPUT_QUALITY_BLACKWHITE
:
443 case SID_OUTPUT_QUALITY_CONTRAST
:
449 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
455 case SID_ATTR_YEAR2000
:
457 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
458 if (pFormShell
!= NULL
)
460 const SfxPoolItem
* pItem
;
461 if (rReq
.GetArgs()->GetItemState(
462 SID_ATTR_YEAR2000
, true, &pItem
) == SfxItemState::SET
)
463 pFormShell
->SetY2KState (
464 static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
471 case SID_OPT_LOCALE_CHANGED
:
473 GetActiveWindow()->Invalidate();
474 UpdatePreview( mpActualPage
);
483 void DrawViewShell::ExecRuler(SfxRequest
& rReq
)
485 // nothing is executed during a slide show!
486 if(HasCurrentFunction(SID_PRESENTATION
))
491 const SfxItemSet
* pArgs
= rReq
.GetArgs();
492 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
493 Size aPageSize
= mpActualPage
->GetSize();
494 Size aViewSize
= GetActiveWindow()->GetViewSize();
496 switch ( rReq
.GetSlot() )
498 case SID_ATTR_LONG_LRSPACE
:
500 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(GetDoc());
501 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
503 const SvxLongLRSpaceItem
& rLRSpace
= static_cast<const SvxLongLRSpaceItem
&>(
504 pArgs
->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE
)));
506 if( mpDrawView
->IsTextEdit() )
508 Rectangle aRect
= maMarkRect
;
509 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
510 aRect
.Left() = rLRSpace
.GetLeft();
511 aRect
.Right() = aViewSize
.Width() - rLRSpace
.GetRight();
512 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
513 if ( aRect
!= maMarkRect
)
515 mpDrawView
->SetAllMarkedRect(aRect
);
516 maMarkRect
= mpDrawView
->GetAllMarkedRect();
517 Invalidate( SID_RULER_OBJECT
);
522 long nLeft
= std::max(0L, rLRSpace
.GetLeft() - aPagePos
.X());
523 long nRight
= std::max(0L, rLRSpace
.GetRight() + aPagePos
.X() +
524 aPageSize
.Width() - aViewSize
.Width());
526 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
528 for ( i
= 0; i
< nPageCnt
; i
++)
530 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
531 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
533 pPage
->GetLftBorder(),
534 pPage
->GetRgtBorder(),
536 pUndoGroup
->AddAction(pUndo
);
537 pPage
->SetLftBorder(nLeft
);
538 pPage
->SetRgtBorder(nRight
);
540 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
542 for (i
= 0; i
< nPageCnt
; i
++)
544 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
545 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
547 pPage
->GetLftBorder(),
548 pPage
->GetRgtBorder(),
550 pUndoGroup
->AddAction(pUndo
);
551 pPage
->SetLftBorder(nLeft
);
552 pPage
->SetRgtBorder(nRight
);
557 // give the undo group to the undo manager
558 GetViewFrame()->GetObjectShell()->GetUndoManager()->
559 AddUndoAction(pUndoGroup
);
562 case SID_ATTR_LONG_ULSPACE
:
564 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(GetDoc());
565 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
567 const SvxLongULSpaceItem
& rULSpace
= static_cast<const SvxLongULSpaceItem
&>(
568 pArgs
->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE
)));
570 if( mpDrawView
->IsTextEdit() )
572 Rectangle aRect
= maMarkRect
;
573 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
574 aRect
.Top() = rULSpace
.GetUpper();
575 aRect
.Bottom() = aViewSize
.Height() - rULSpace
.GetLower();
576 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
578 if ( aRect
!= maMarkRect
)
580 mpDrawView
->SetAllMarkedRect(aRect
);
581 maMarkRect
= mpDrawView
->GetAllMarkedRect();
582 Invalidate( SID_RULER_OBJECT
);
587 long nUpper
= std::max(0L, rULSpace
.GetUpper() - aPagePos
.Y());
588 long nLower
= std::max(0L, rULSpace
.GetLower() + aPagePos
.Y() +
589 aPageSize
.Height() - aViewSize
.Height());
591 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
593 for ( i
= 0; i
< nPageCnt
; i
++)
595 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
596 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
598 pPage
->GetUppBorder(),
599 pPage
->GetLwrBorder(),
601 pUndoGroup
->AddAction(pUndo
);
602 pPage
->SetUppBorder(nUpper
);
603 pPage
->SetLwrBorder(nLower
);
605 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
607 for (i
= 0; i
< nPageCnt
; i
++)
609 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
610 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
612 pPage
->GetUppBorder(),
613 pPage
->GetLwrBorder(),
615 pUndoGroup
->AddAction(pUndo
);
616 pPage
->SetUppBorder(nUpper
);
617 pPage
->SetLwrBorder(nLower
);
622 // give the undo group to the undo manager
623 GetViewFrame()->GetObjectShell()->GetUndoManager()->
624 AddUndoAction(pUndoGroup
);
629 case SID_RULER_OBJECT
:
631 Rectangle aRect
= maMarkRect
;
632 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
634 const SvxObjectItem
& rOI
= static_cast<const SvxObjectItem
&>(
635 pArgs
->Get(GetPool().GetWhich(SID_RULER_OBJECT
)));
637 if ( rOI
.GetStartX() != rOI
.GetEndX() )
639 aRect
.Left() = rOI
.GetStartX();
640 aRect
.Right() = rOI
.GetEndX();
642 if ( rOI
.GetStartY() != rOI
.GetEndY() )
644 aRect
.Top() = rOI
.GetStartY();
645 aRect
.Bottom() = rOI
.GetEndY();
647 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
648 if ( aRect
!= maMarkRect
)
650 mpDrawView
->SetAllMarkedRect(aRect
);
651 maMarkRect
= mpDrawView
->GetAllMarkedRect();
652 Invalidate( SID_RULER_OBJECT
);
657 case SID_ATTR_TABSTOP
:
659 if( mpDrawView
->IsTextEdit() )
661 const SvxTabStopItem
& rItem
= static_cast<const SvxTabStopItem
&>(
662 pArgs
->Get( EE_PARA_TABS
));
664 SfxItemSet
aEditAttr( GetPool(), EE_PARA_TABS
, EE_PARA_TABS
);
666 aEditAttr
.Put( rItem
);
667 mpDrawView
->SetAttributes( aEditAttr
);
669 Invalidate(SID_ATTR_TABSTOP
);
674 case SID_ATTR_PARA_LINESPACE
:
676 sal_uInt16 nSlot
= SID_ATTR_PARA_LINESPACE
;
677 SvxLineSpacingItem aParaLineSP
= static_cast<const SvxLineSpacingItem
&>(pArgs
->Get(
678 GetPool().GetWhich(nSlot
)));
680 SfxItemSet
aEditAttr( GetPool(), EE_PARA_SBL
, EE_PARA_SBL
);
681 aParaLineSP
.SetWhich( EE_PARA_SBL
);
683 aEditAttr
.Put( aParaLineSP
);
684 mpDrawView
->SetAttributes( aEditAttr
);
686 Invalidate(SID_ATTR_PARA_LINESPACE
);
689 case SID_ATTR_PARA_ADJUST_LEFT
:
691 SvxAdjustItem
aItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
);
692 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
694 aEditAttr
.Put( aItem
);
695 mpDrawView
->SetAttributes( aEditAttr
);
697 Invalidate(SID_ATTR_PARA_ADJUST_LEFT
);
700 case SID_ATTR_PARA_ADJUST_CENTER
:
702 SvxAdjustItem
aItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
);
703 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
705 aEditAttr
.Put( aItem
);
706 mpDrawView
->SetAttributes( aEditAttr
);
708 Invalidate(SID_ATTR_PARA_ADJUST_CENTER
);
711 case SID_ATTR_PARA_ADJUST_RIGHT
:
713 SvxAdjustItem
aItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
);
714 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
716 aEditAttr
.Put( aItem
);
717 mpDrawView
->SetAttributes( aEditAttr
);
719 Invalidate(SID_ATTR_PARA_ADJUST_RIGHT
);
722 case SID_ATTR_PARA_ADJUST_BLOCK
:
724 SvxAdjustItem
aItem( SVX_ADJUST_BLOCK
, EE_PARA_JUST
);
725 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
727 aEditAttr
.Put( aItem
);
728 mpDrawView
->SetAttributes( aEditAttr
);
730 Invalidate(SID_ATTR_PARA_ADJUST_BLOCK
);
733 case SID_ATTR_PARA_ULSPACE
:
735 sal_uInt16 nSlot
= SID_ATTR_PARA_ULSPACE
;
736 SvxULSpaceItem aULSP
= static_cast<const SvxULSpaceItem
&>(pArgs
->Get(
737 GetPool().GetWhich(nSlot
)));
738 SfxItemSet
aEditAttr( GetPool(), EE_PARA_ULSPACE
, EE_PARA_ULSPACE
);
739 aULSP
.SetWhich( EE_PARA_ULSPACE
);
741 aEditAttr
.Put( aULSP
);
742 mpDrawView
->SetAttributes( aEditAttr
);
744 Invalidate(SID_ATTR_PARA_ULSPACE
);
748 case SID_ATTR_PARA_LRSPACE
:
750 sal_uInt16 nSlot
= SID_ATTR_PARA_LRSPACE
;
751 SvxLRSpaceItem aLRSpace
= static_cast<const SvxLRSpaceItem
&>(pArgs
->Get(
752 GetPool().GetWhich(nSlot
)));
754 SfxItemSet
aEditAttr( GetPool(), EE_PARA_LRSPACE
, EE_PARA_LRSPACE
);
755 aLRSpace
.SetWhich( EE_PARA_LRSPACE
);
757 aEditAttr
.Put( aLRSpace
);
758 mpDrawView
->SetAttributes( aEditAttr
);
760 Invalidate(SID_ATTR_PARA_LRSPACE
);
763 case SID_ATTR_LRSPACE
:
765 if( mpDrawView
->IsTextEdit() )
767 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
768 const SvxLRSpaceItem
& rItem
= static_cast<const SvxLRSpaceItem
&>(
771 static const sal_uInt16 aWhichTable
[]=
773 EE_PARA_OUTLLEVEL
, EE_PARA_OUTLLEVEL
,
774 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
,
775 EE_PARA_NUMBULLET
, EE_PARA_NUMBULLET
,
779 SfxItemSet
aEditAttr( GetDoc()->GetPool(),
781 mpDrawView
->GetAttributes( aEditAttr
);
783 nId
= EE_PARA_LRSPACE
;
784 SvxLRSpaceItem
aLRSpaceItem( rItem
.GetLeft(),
785 rItem
.GetRight(), rItem
.GetTextLeft(),
786 rItem
.GetTextFirstLineOfst(), nId
);
788 const sal_Int16 nOutlineLevel
= static_cast<const SfxInt16Item
&>(aEditAttr
.Get( EE_PARA_OUTLLEVEL
)).GetValue();
789 const SvxLRSpaceItem
& rOrigLRSpaceItem
= static_cast<const SvxLRSpaceItem
&>( aEditAttr
.Get( EE_PARA_LRSPACE
));
790 const SvxNumBulletItem
& rNumBulletItem
= static_cast<const SvxNumBulletItem
&>( aEditAttr
.Get( EE_PARA_NUMBULLET
) );
791 if( nOutlineLevel
!= -1 &&
792 rNumBulletItem
.GetNumRule() &&
793 rNumBulletItem
.GetNumRule()->GetLevelCount() > nOutlineLevel
)
795 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule()->GetLevel(nOutlineLevel
);
796 SvxNumberFormat
aFormat(rFormat
);
798 // left margin gets distributed onto LRSpace item
799 // and number format AbsLSpace - this fixes
800 // n#707779 (previously, LRSpace left indent could
801 // become negative - EditEngine really does not
803 const short nAbsLSpace
=aFormat
.GetAbsLSpace();
804 const long nTxtLeft
=rItem
.GetTextLeft();
805 const long nLeftIndent
=std::max(0L,nTxtLeft
- nAbsLSpace
);
806 aLRSpaceItem
.SetTextLeft(nLeftIndent
);
807 // control for clipped left indent - remainder
808 // reduces number format first line indent
809 aFormat
.SetAbsLSpace(nTxtLeft
- nLeftIndent
);
811 // negative first line indent goes to the number
812 // format, positive to the lrSpace item
813 if( rItem
.GetTextFirstLineOfst() < 0 )
815 aFormat
.SetFirstLineOffset(
816 rItem
.GetTextFirstLineOfst()
817 - rOrigLRSpaceItem
.GetTextFirstLineOfst()
818 + aFormat
.GetCharTextDistance());
819 aLRSpaceItem
.SetTextFirstLineOfst(0);
823 aFormat
.SetFirstLineOffset(0);
824 aLRSpaceItem
.SetTextFirstLineOfst(
825 rItem
.GetTextFirstLineOfst()
826 - aFormat
.GetFirstLineOffset()
827 + aFormat
.GetCharTextDistance());
830 if( rFormat
!= aFormat
)
833 SvxNumBulletItem
aNumBulletItem(rNumBulletItem
);
834 aNumBulletItem
.GetNumRule()->SetLevel(nOutlineLevel
,aFormat
);
835 aEditAttr
.Put( aNumBulletItem
);
836 aEditAttr
.Put( aLRSpaceItem
);
837 mpDrawView
->SetAttributes( aEditAttr
);
839 Invalidate(SID_ATTR_PARA_LRSPACE
);
844 // only put lrSpace item
845 SfxItemSet
aEditAttrReduced( GetDoc()->GetPool(),
846 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
);
847 aEditAttrReduced
.Put( aLRSpaceItem
);
848 mpDrawView
->SetAttributes( aEditAttrReduced
);
850 Invalidate(SID_ATTR_PARA_LRSPACE
);
857 void DrawViewShell::GetRulerState(SfxItemSet
& rSet
)
861 if (mpDrawView
->GetSdrPageView())
863 aOrigin
= mpDrawView
->GetSdrPageView()->GetPageOrigin();
866 Size aViewSize
= GetActiveWindow()->GetViewSize();
868 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
869 Size aPageSize
= mpActualPage
->GetSize();
871 Rectangle
aRect(aPagePos
, Point( aViewSize
.Width() - (aPagePos
.X() + aPageSize
.Width()),
872 aViewSize
.Height() - (aPagePos
.Y() + aPageSize
.Height())));
874 if( mpDrawView
->IsTextEdit() )
876 Point aPnt1
= GetActiveWindow()->GetWinViewPos();
877 Rectangle aMinMaxRect
= Rectangle( aPnt1
, Size(ULONG_MAX
, ULONG_MAX
) );
878 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aMinMaxRect
) );
882 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aRect
) );
885 SvxLongLRSpaceItem
aLRSpace(aPagePos
.X() + mpActualPage
->GetLftBorder(),
886 aRect
.Right() + mpActualPage
->GetRgtBorder(),
887 GetPool().GetWhich(SID_ATTR_LONG_LRSPACE
));
888 SvxLongULSpaceItem
aULSpace(aPagePos
.Y() + mpActualPage
->GetUppBorder(),
889 aRect
.Bottom() + mpActualPage
->GetLwrBorder(),
890 GetPool().GetWhich(SID_ATTR_LONG_ULSPACE
));
891 rSet
.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos
, aViewSize
.Width(),
892 aViewSize
.Height()));
893 SfxPointItem
aPointItem( SID_RULER_NULL_OFFSET
, aPagePos
+ aOrigin
);
895 SvxProtectItem
aProtect( SID_RULER_PROTECT
);
897 maMarkRect
= mpDrawView
->GetAllMarkedRect();
899 const bool bRTL
= GetDoc() && GetDoc()->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB
;
900 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, bRTL
));
902 if( mpDrawView
->AreObjectsMarked() )
904 if( mpDrawView
->IsTextEdit() )
906 SdrObject
* pObj
= mpDrawView
->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
907 if( pObj
->GetObjInventor() == SdrInventor
)
909 SfxItemSet
aEditAttr( GetDoc()->GetPool() );
910 mpDrawView
->GetAttributes( aEditAttr
);
911 if( aEditAttr
.GetItemState( EE_PARA_TABS
) >= SfxItemState::DEFAULT
)
913 const SvxTabStopItem
& rItem
= static_cast<const SvxTabStopItem
&>( aEditAttr
.Get( EE_PARA_TABS
) );
916 const SvxLRSpaceItem
& rLRSpaceItem
= static_cast<const SvxLRSpaceItem
&>( aEditAttr
.Get( EE_PARA_LRSPACE
) );
917 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
918 SvxLRSpaceItem
aLRSpaceItem( rLRSpaceItem
.GetLeft(),
919 rLRSpaceItem
.GetRight(), rLRSpaceItem
.GetTextLeft(),
920 rLRSpaceItem
.GetTextFirstLineOfst(), nId
);
922 const sal_Int16 nOutlineLevel
= static_cast<const SfxInt16Item
&>( aEditAttr
.Get( EE_PARA_OUTLLEVEL
)).GetValue();
923 const SvxNumBulletItem
& rNumBulletItem
= static_cast<const SvxNumBulletItem
&>( aEditAttr
.Get( EE_PARA_NUMBULLET
) );
924 if( nOutlineLevel
!= -1 &&
925 rNumBulletItem
.GetNumRule() &&
926 rNumBulletItem
.GetNumRule()->GetLevelCount() > nOutlineLevel
)
928 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule()->GetLevel(nOutlineLevel
);
929 aLRSpaceItem
.SetTextLeft(rFormat
.GetAbsLSpace() + rLRSpaceItem
.GetTextLeft());
930 aLRSpaceItem
.SetTextFirstLineOfst(
931 rLRSpaceItem
.GetTextFirstLineOfst() + rFormat
.GetFirstLineOffset()
932 - rFormat
.GetCharTextDistance());
935 rSet
.Put( aLRSpaceItem
);
937 Point
aPos( aPagePos
+ maMarkRect
.TopLeft() );
939 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
941 const SdrMetricItem
& rTLDItem
= static_cast<const SdrMetricItem
&>(
942 aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
));
943 long nLD
= rTLDItem
.GetValue();
947 aPointItem
.SetValue( aPos
);
949 aLRSpace
.SetLeft( aPagePos
.X() + maMarkRect
.Left() );
951 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
953 const SdrMetricItem
& rTLDItem
= static_cast<const SdrMetricItem
&>(
954 aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
));
955 long nLD
= rTLDItem
.GetValue();
956 aLRSpace
.SetLeft( aLRSpace
.GetLeft() + nLD
);
959 aLRSpace
.SetRight( aRect
.Right() + aPageSize
.Width() - maMarkRect
.Right() );
960 aULSpace
.SetUpper( aPagePos
.Y() + maMarkRect
.Top() );
961 aULSpace
.SetLower( aRect
.Bottom() + aPageSize
.Height() - maMarkRect
.Bottom() );
963 rSet
.DisableItem( SID_RULER_OBJECT
);
966 aProtect
.SetSizeProtect( true );
967 aProtect
.SetPosProtect( true );
970 if( aEditAttr
.GetItemState( EE_PARA_WRITINGDIR
) >= SfxItemState::DEFAULT
)
972 const SvxFrameDirectionItem
& rItem
= static_cast<const SvxFrameDirectionItem
&>( aEditAttr
.Get( EE_PARA_WRITINGDIR
) );
973 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, rItem
.GetValue() == ::com::sun::star::text::WritingMode_RL_TB
));
979 rSet
.DisableItem( EE_PARA_TABS
);
980 rSet
.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT
);
982 if( mpDrawView
->IsResizeAllowed(true) )
984 Rectangle
aResizeRect( maMarkRect
);
986 aResizeRect
.SetPos(aResizeRect
.TopLeft() + aPagePos
);
987 SvxObjectItem
aObjItem(aResizeRect
.Left(), aResizeRect
.Right(),
988 aResizeRect
.Top(), aResizeRect
.Bottom());
990 rSet
.DisableItem( EE_PARA_TABS
);
994 rSet
.DisableItem( SID_RULER_OBJECT
);
1000 rSet
.DisableItem( SID_RULER_OBJECT
);
1001 rSet
.DisableItem( EE_PARA_TABS
);
1004 rSet
.Put( aLRSpace
);
1005 rSet
.Put( aULSpace
);
1007 rSet
.Put( aPointItem
);
1008 rSet
.Put( aProtect
);
1011 void DrawViewShell::ExecStatusBar(SfxRequest
& rReq
)
1013 // nothing is executed during a slide show!
1014 if(HasCurrentFunction(SID_PRESENTATION
))
1019 switch ( rReq
.GetSlot() )
1023 GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM
, SfxCallMode::ASYNCHRON
);
1027 case SID_STATUS_LAYOUT
:
1029 GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT
, SfxCallMode::ASYNCHRON
);
1036 * set state of snap object entries in popup
1038 void DrawViewShell::GetSnapItemState( SfxItemSet
&rSet
)
1041 Point aMPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
1042 sal_uInt16 nHitLog
= (sal_uInt16
) GetActiveWindow()->PixelToLogic(
1043 Size(FuPoor::HITPIX
,0)).Width();
1044 sal_uInt16 nHelpLine
;
1046 if ( mpDrawView
->PickHelpLine(aMPos
, nHitLog
, *GetActiveWindow(), nHelpLine
, pPV
) )
1048 const SdrHelpLine
& rHelpLine
= (pPV
->GetHelpLines())[nHelpLine
];
1050 if ( rHelpLine
.GetKind() == SDRHELPLINE_POINT
)
1052 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1053 SD_RESSTR( STR_POPUP_EDIT_SNAPPOINT
)) );
1054 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1055 SD_RESSTR( STR_POPUP_DELETE_SNAPPOINT
)) );
1059 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1060 SD_RESSTR( STR_POPUP_EDIT_SNAPLINE
)) );
1061 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1062 SD_RESSTR( STR_POPUP_DELETE_SNAPLINE
)) );
1067 } // end of namespace sd
1069 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */