1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewdraw.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include "hintids.hxx"
36 #include <svtools/aeitem.hxx>
37 #include <svtools/itempool.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdview.hxx>
40 #include <svx/svdpage.hxx>
41 #include <svx/editview.hxx>
42 #include <svx/editeng.hxx>
43 #include <svx/outliner.hxx>
44 #include <svx/fmview.hxx>
45 #include <svx/dataaccessdescriptor.hxx>
46 #include <sfx2/viewfrm.hxx>
48 #include <svx/langitem.hxx>
49 #include <linguistic/lngprops.hxx>
50 #include <svx/unolingu.hxx>
51 #include <svx/fontworkbar.hxx>
52 #include <svx/fontworkgallery.hxx>
53 #include <svx/eeitem.hxx>
54 #include <svx/svdogrp.hxx>
55 #include <svx/svdetc.hxx>
56 #include <svx/editstat.hxx>
57 #include <sfx2/request.hxx>
58 #include <sfx2/bindings.hxx>
59 #include <sfx2/printer.hxx>
60 #include <svx/fmglob.hxx>
61 #include <sfx2/dispatch.hxx>
62 #include <svx/svdoutl.hxx>
66 #include "viewopt.hxx"
69 #include "drwbassh.hxx"
70 #include "beziersh.hxx"
71 #include "conrect.hxx"
72 #include "conpoly.hxx"
74 #include "conform.hxx"
75 #include "concustomshape.hxx"
76 #include "dselect.hxx"
80 #include <dcontact.hxx>
83 #include <svx/svdpagv.hxx>
84 #include <svx/extrusionbar.hxx>
85 #include <vcl/svapp.hxx>
87 using namespace ::com::sun::star
;
88 /*--------------------------------------------------------------------
89 Beschreibung: Drawing-Ids ausfuehren
90 --------------------------------------------------------------------*/
92 void SwView::ExecDraw(SfxRequest
& rReq
)
94 const SfxItemSet
*pArgs
= rReq
.GetArgs();
95 const SfxPoolItem
* pItem
;
96 const SfxAllEnumItem
* pEItem
= 0;
97 const SfxStringItem
* pStringItem
= 0;
98 SdrView
*pSdrView
= pWrtShell
->GetDrawView();
99 sal_Bool bDeselect
= sal_False
;
101 sal_uInt16 nSlotId
= rReq
.GetSlot();
102 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(GetPool().GetWhich(nSlotId
), sal_False
, &pItem
))
104 pEItem
= dynamic_cast< const SfxAllEnumItem
*>(pItem
);
105 pStringItem
= dynamic_cast< const SfxStringItem
*>(pItem
);
108 if (SID_INSERT_DRAW
== nSlotId
&& pEItem
)
109 switch ( pEItem
->GetValue() )
111 case SVX_SNAP_DRAW_SELECT
: nSlotId
= SID_OBJECT_SELECT
; break;
112 case SVX_SNAP_DRAW_LINE
: nSlotId
= SID_DRAW_LINE
; break;
113 case SVX_SNAP_DRAW_RECT
: nSlotId
= SID_DRAW_RECT
; break;
114 case SVX_SNAP_DRAW_ELLIPSE
: nSlotId
= SID_DRAW_ELLIPSE
; break;
115 case SVX_SNAP_DRAW_POLYGON_NOFILL
: nSlotId
= SID_DRAW_POLYGON_NOFILL
; break;
116 case SVX_SNAP_DRAW_BEZIER_NOFILL
: nSlotId
= SID_DRAW_BEZIER_NOFILL
; break;
117 case SVX_SNAP_DRAW_FREELINE_NOFILL
: nSlotId
= SID_DRAW_FREELINE_NOFILL
; break;
118 case SVX_SNAP_DRAW_ARC
: nSlotId
= SID_DRAW_ARC
; break;
119 case SVX_SNAP_DRAW_PIE
: nSlotId
= SID_DRAW_PIE
; break;
120 case SVX_SNAP_DRAW_CIRCLECUT
: nSlotId
= SID_DRAW_CIRCLECUT
; break;
121 case SVX_SNAP_DRAW_TEXT
: nSlotId
= SID_DRAW_TEXT
; break;
122 case SVX_SNAP_DRAW_TEXT_VERTICAL
: nSlotId
= SID_DRAW_TEXT_VERTICAL
; break;
123 case SVX_SNAP_DRAW_TEXT_MARQUEE
: nSlotId
= SID_DRAW_TEXT_MARQUEE
; break;
124 case SVX_SNAP_DRAW_CAPTION
: nSlotId
= SID_DRAW_CAPTION
; break;
125 case SVX_SNAP_DRAW_CAPTION_VERTICAL
: nSlotId
= SID_DRAW_CAPTION_VERTICAL
; break;
128 if (nSlotId
== SID_OBJECT_SELECT
&& nFormSfxId
== nSlotId
)
130 bDeselect
= sal_True
;
132 else if (nSlotId
== SID_FM_CREATE_CONTROL
)
134 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, sal_False
);
135 if( pIdentifierItem
)
137 sal_uInt16 nNewId
= pIdentifierItem
->GetValue();
138 if (nNewId
== nFormSfxId
)
140 bDeselect
= sal_True
;
141 GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE
); // Button soll rauspoppen
145 else if( nSlotId
== SID_FM_CREATE_FIELDCONTROL
)
147 FmFormView
* pFormView
= PTR_CAST( FmFormView
, pSdrView
);
150 SFX_REQUEST_ARG( rReq
, pDescriptorItem
, SfxUnoAnyItem
, SID_FM_DATACCESS_DESCRIPTOR
, sal_False
);
151 DBG_ASSERT( pDescriptorItem
, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
152 if( pDescriptorItem
)
154 ::svx::ODataAccessDescriptor
aDescriptor( pDescriptorItem
->GetValue() );
155 SdrObject
* pObj
= pFormView
->CreateFieldControl( aDescriptor
);
159 Size
aDocSize(pWrtShell
->GetDocSize());
160 const SwRect
& rVisArea
= pWrtShell
->VisArea();
161 Point aStartPos
= rVisArea
.Center();
162 if(rVisArea
.Width() > aDocSize
.Width())
163 aStartPos
.X() = aDocSize
.Width() / 2 + rVisArea
.Left();
164 if(rVisArea
.Height() > aDocSize
.Height())
165 aStartPos
.Y() = aDocSize
.Height() / 2 + rVisArea
.Top();
167 //determine the size of the object
168 if(pObj
->IsGroupObject())
170 const Rectangle
& rBoundRect
= ((SdrObjGroup
*)pObj
)->GetCurrentBoundRect();
171 aStartPos
.X() -= rBoundRect
.GetWidth()/2;
172 aStartPos
.Y() -= rBoundRect
.GetHeight()/2;
175 // TODO: unmark all other
176 pWrtShell
->EnterStdMode();
177 pWrtShell
->SwFEShell::Insert( *pObj
, 0, 0, &aStartPos
);
182 else if ( nSlotId
== SID_FONTWORK_GALLERY_FLOATER
)
184 Window
* pWin
= &( pWrtShell
->GetView().GetViewFrame()->GetWindow() );
189 if( !pWrtShell
->HasDrawView() )
190 pWrtShell
->MakeDrawView();
192 pSdrView
= pWrtShell
->GetDrawView();
195 SdrObject
* pObj
= NULL
;
196 svx::FontWorkGalleryDialog
aDlg( pSdrView
, pWin
, nSlotId
);
197 aDlg
.SetSdrObjectRef( &pObj
, pSdrView
->GetModel() );
201 Size
aDocSize( pWrtShell
->GetDocSize() );
202 const SwRect
& rVisArea
= pWrtShell
->VisArea();
203 Point
aPos( rVisArea
.Center() );
205 Size
aPrefSize( pObj
->GetSnapRect().GetSize() );
207 if( rVisArea
.Width() > aDocSize
.Width())
208 aPos
.X() = aDocSize
.Width() / 2 + rVisArea
.Left();
210 if(rVisArea
.Height() > aDocSize
.Height())
211 aPos
.Y() = aDocSize
.Height() / 2 + rVisArea
.Top();
213 if( aPrefSize
.Width() && aPrefSize
.Height() )
216 aSize
= pWin
->PixelToLogic( aPrefSize
, MAP_TWIP
);
218 aSize
= Application::GetDefaultDevice()->PixelToLogic( aPrefSize
, MAP_TWIP
);
221 aSize
= Size( 2835, 2835 );
223 pWrtShell
->EnterStdMode();
224 pWrtShell
->SwFEShell::Insert( *pObj
, 0, 0, &aPos
);
232 if( nSlotId
== SID_DRAW_CS_ID
)
234 //deselect if same custom shape is selected again
235 SwDrawBase
* pFuncPtr
= GetDrawFuncPtr();
236 if( pFuncPtr
&& pFuncPtr
->GetSlotId() == SID_DRAW_CS_ID
)
238 ConstCustomShape
* pConstCustomShape
= (ConstCustomShape
*)(pFuncPtr
);
239 rtl::OUString aNew
= ConstCustomShape::GetShapeTypeFromRequest( rReq
);
240 rtl::OUString aOld
= pConstCustomShape
->GetShapeType();
248 //deselect if same shape is selected again (but different custom shapes do have same slot id)
249 if ( bDeselect
|| (nSlotId
== nDrawSfxId
&&
250 (!pStringItem
|| (pStringItem
->GetValue() == sDrawCustom
))
251 && (nSlotId
!= SID_DRAW_CS_ID
) ) )
253 if (GetDrawFuncPtr())
255 GetDrawFuncPtr()->Deactivate();
256 SetDrawFuncPtr(NULL
);
259 if (pWrtShell
->IsObjSelected() && !pWrtShell
->IsSelFrmMode())
260 pWrtShell
->EnterSelFrmMode(NULL
);
263 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW
);
265 AttrChangedNotify(pWrtShell
);
271 if (pWrtShell
->IsFrmSelected())
272 pWrtShell
->EnterStdMode(); // wegen Bug #45639
274 SwDrawBase
* pFuncPtr
= NULL
;
278 case SID_OBJECT_SELECT
:
279 case SID_DRAW_SELECT
:
280 pFuncPtr
= new DrawSelection(pWrtShell
, pEditWin
, this);
281 nDrawSfxId
= nFormSfxId
= SID_OBJECT_SELECT
;
287 case SID_DRAW_ELLIPSE
:
289 case SID_DRAW_TEXT_VERTICAL
:
290 case SID_DRAW_TEXT_MARQUEE
:
291 case SID_DRAW_CAPTION
:
292 case SID_DRAW_CAPTION_VERTICAL
:
293 pFuncPtr
= new ConstRectangle(pWrtShell
, pEditWin
, this);
294 nDrawSfxId
= nSlotId
;
298 case SID_DRAW_POLYGON_NOFILL
:
299 case SID_DRAW_BEZIER_NOFILL
:
300 case SID_DRAW_FREELINE_NOFILL
:
301 pFuncPtr
= new ConstPolygon(pWrtShell
, pEditWin
, this);
302 nDrawSfxId
= nSlotId
;
308 case SID_DRAW_CIRCLECUT
:
309 pFuncPtr
= new ConstArc(pWrtShell
, pEditWin
, this);
310 nDrawSfxId
= nSlotId
;
314 case SID_FM_CREATE_CONTROL
:
316 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, sal_False
);
317 if( pIdentifierItem
)
318 nSlotId
= pIdentifierItem
->GetValue();
319 pFuncPtr
= new ConstFormControl(pWrtShell
, pEditWin
, this);
320 nFormSfxId
= nSlotId
;
324 case SID_DRAWTBX_CS_BASIC
:
325 case SID_DRAWTBX_CS_SYMBOL
:
326 case SID_DRAWTBX_CS_ARROW
:
327 case SID_DRAWTBX_CS_FLOWCHART
:
328 case SID_DRAWTBX_CS_CALLOUT
:
329 case SID_DRAWTBX_CS_STAR
:
330 case SID_DRAW_CS_ID
:
332 pFuncPtr
= new ConstCustomShape(pWrtShell
, pEditWin
, this, rReq
);
333 nDrawSfxId
= nSlotId
;
334 if ( nSlotId
!= SID_DRAW_CS_ID
)
338 sDrawCustom
= pStringItem
->GetValue();
339 aCurrShapeEnumCommand
[ nSlotId
- SID_DRAWTBX_CS_BASIC
] = sDrawCustom
;
340 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
341 rBind
.Invalidate( nSlotId
);
342 rBind
.Update( nSlotId
);
352 static sal_uInt16 __READONLY_DATA aInval
[] =
354 // Slot-Ids muessen beim Aufruf von Invalidate sortiert sein!
359 GetViewFrame()->GetBindings().Invalidate(aInval
);
361 BOOL bEndTextEdit
= TRUE
;
364 if (GetDrawFuncPtr())
366 GetDrawFuncPtr()->Deactivate();
367 SetDrawFuncPtr(NULL
);
370 SetDrawFuncPtr(pFuncPtr
);
371 AttrChangedNotify(pWrtShell
);
373 pFuncPtr
->Activate(nSlotId
);
375 if(rReq
.GetModifier() == KEY_MOD1
)
377 if(SID_OBJECT_SELECT
== nDrawSfxId
)
379 pWrtShell
->GotoObj(TRUE
);
383 pFuncPtr
->CreateDefaultObject();
384 pFuncPtr
->Deactivate();
385 SetDrawFuncPtr(NULL
);
387 pWrtShell
->EnterStdMode();
388 SdrView
*pTmpSdrView
= pWrtShell
->GetDrawView();
389 const SdrMarkList
& rMarkList
= pTmpSdrView
->GetMarkedObjectList();
390 if(rMarkList
.GetMarkCount() == 1 &&
391 (SID_DRAW_TEXT
== nSlotId
|| SID_DRAW_TEXT_VERTICAL
== nSlotId
||
392 SID_DRAW_TEXT_MARQUEE
== nSlotId
))
394 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
396 bEndTextEdit
= FALSE
;
403 if (pWrtShell
->IsObjSelected() && !pWrtShell
->IsSelFrmMode())
404 pWrtShell
->EnterSelFrmMode(NULL
);
407 if(bEndTextEdit
&& pSdrView
&& pSdrView
->IsTextEdit())
408 pSdrView
->SdrEndTextEdit( sal_True
);
410 AttrChangedNotify(pWrtShell
);
413 /*--------------------------------------------------------------------
414 Beschreibung: Drawing beenden
415 --------------------------------------------------------------------*/
419 void SwView::ExitDraw()
425 //#126062 # the shell may be invalid at close/reload/SwitchToViewShell
426 SfxDispatcher
* pDispatch
= GetViewFrame()->GetDispatcher();
431 pTest
= pDispatch
->GetShell(nIdx
++);
433 while( pTest
&& pTest
!= this && pTest
!= pShell
);
434 if(pTest
== pShell
&&
435 // don't call LeaveSelFrmMode() etc. for the below,
436 // because objects may still be selected:
437 !pShell
->ISA(SwDrawBaseShell
) &&
438 !pShell
->ISA(SwBezierShell
) &&
439 !pShell
->ISA(svx::ExtrusionBar
) &&
440 !pShell
->ISA(svx::FontworkBar
))
442 SdrView
*pSdrView
= pWrtShell
->GetDrawView();
444 if (pSdrView
&& pSdrView
->IsGroupEntered())
446 pSdrView
->LeaveOneGroup();
447 pSdrView
->UnmarkAll();
448 GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP
);
451 if (GetDrawFuncPtr())
453 if (pWrtShell
->IsSelFrmMode())
454 pWrtShell
->LeaveSelFrmMode();
455 GetDrawFuncPtr()->Deactivate();
457 SetDrawFuncPtr(NULL
);
460 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW
);
462 GetEditWin().SetPointer(Pointer(POINTER_TEXT
));
467 /*--------------------------------------------------------------------
468 Beschreibung: Rotate-Mode abschalten
469 --------------------------------------------------------------------*/
473 void SwView::NoRotate()
477 pWrtShell
->SetDragMode(SDRDRAG_MOVE
);
480 const SfxBoolItem
aTmp( SID_OBJECT_ROTATE
, sal_False
);
481 GetViewFrame()->GetBindings().SetState( aTmp
);
485 /******************************************************************************
486 * Beschreibung: DrawTextEditMode einschalten
487 ******************************************************************************/
489 sal_Bool
SwView::EnterDrawTextMode(const Point
& aDocPos
)
493 SwWrtShell
*pSh
= &GetWrtShell();
494 SdrView
*pSdrView
= pSh
->GetDrawView();
495 ASSERT( pSdrView
, "EnterDrawTextMode without DrawView?" );
497 sal_Bool bReturn
= sal_False
;
499 sal_uInt16 nOld
= pSdrView
->GetHitTolerancePixel();
500 pSdrView
->SetHitTolerancePixel( 2 );
502 if( pSdrView
->IsMarkedHit( aDocPos
) &&
503 !pSdrView
->PickHandle( aDocPos
) && IsTextTool() &&
504 pSdrView
->PickObj( aDocPos
, pSdrView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_PICKTEXTEDIT
) &&
507 // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
508 //pObj->ISA( SdrTextObj ) &&
509 ( pObj
->ISA( SdrTextObj
) ||
510 ( pObj
->ISA(SwDrawVirtObj
) &&
511 ((SwDrawVirtObj
*)pObj
)->GetReferencedObj().ISA(SdrTextObj
) ) ) &&
513 !pWrtShell
->IsSelObjProtected(FLYPROTECT_CONTENT
))
515 bReturn
= BeginTextEdit( pObj
, pPV
, pEditWin
, sal_False
);
518 pSdrView
->SetHitTolerancePixel( nOld
);
523 /******************************************************************************
524 * Beschreibung: DrawTextEditMode einschalten
525 ******************************************************************************/
526 sal_Bool
SwView::BeginTextEdit(SdrObject
* pObj
, SdrPageView
* pPV
, Window
* pWin
, sal_Bool bIsNewObj
)
528 SwWrtShell
*pSh
= &GetWrtShell();
529 SdrView
*pSdrView
= pSh
->GetDrawView();
530 SdrOutliner
* pOutliner
= ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT
, pSdrView
->GetModel());
531 uno::Reference
< linguistic2::XSpellChecker1
> xSpell( ::GetSpellChecker() );
534 pOutliner
->SetRefDevice(pSh
->getIDocumentDeviceAccess()->getReferenceDevice(false));
535 pOutliner
->SetSpeller(xSpell
);
536 uno::Reference
<linguistic2::XHyphenator
> xHyphenator( ::GetHyphenator() );
537 pOutliner
->SetHyphenator( xHyphenator
);
538 pSh
->SetCalcFieldValueHdl(pOutliner
);
540 sal_uInt32 nCntrl
= pOutliner
->GetControlWord();
541 nCntrl
|= EE_CNTRL_ALLOWBIGOBJS
;
542 nCntrl
|= EE_CNTRL_URLSFXEXECUTE
;
544 const SwViewOption
*pOpt
= pSh
->GetViewOptions();
546 if (SwViewOption::IsFieldShadings())
547 nCntrl
|= EE_CNTRL_MARKFIELDS
;
549 nCntrl
&= ~EE_CNTRL_MARKFIELDS
;
551 if (pOpt
->IsOnlineSpell())
552 nCntrl
|= EE_CNTRL_ONLINESPELLING
;
554 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
556 pOutliner
->SetControlWord(nCntrl
);
557 const SfxPoolItem
& rItem
= pSh
->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE
);
558 pOutliner
->SetDefaultLanguage(((const SvxLanguageItem
&)rItem
).GetLanguage());
561 pOutliner
->SetVertical( SID_DRAW_TEXT_VERTICAL
== nDrawSfxId
||
562 SID_DRAW_CAPTION_VERTICAL
== nDrawSfxId
);
564 // No longer necessary, see text below
565 // Color aBackground(pSh->GetShapeBackgrd());
566 // pOutliner->SetBackgroundColor(aBackground);
568 // OD 09.12.2002 #103045# - set default horizontal text direction at outliner
569 EEHorizontalTextDirection aDefHoriTextDir
=
570 pSh
->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L
: EE_HTEXTDIR_L2R
;
571 pOutliner
->SetDefaultHorizontalTextDirection( aDefHoriTextDir
);
575 // To allow editing the referenced object from a SwDrawVirtObj here
576 // the original needs to be fetched evenually. This ATM activates the
577 // text edit mode for the original object.
578 SdrObject
* pToBeActivated
= pObj
;
581 // Always the original object is edited. To allow the TextEdit to happen
582 // where the VirtObj is positioned, on demand a occurring offset is set at
583 // the TextEdit object. That offset is used for creating and managing the
585 Point
aNewTextEditOffset(0, 0);
587 if(pObj
->ISA(SwDrawVirtObj
))
589 SwDrawVirtObj
* pVirtObj
= (SwDrawVirtObj
*)pObj
;
590 pToBeActivated
= &((SdrObject
&)pVirtObj
->GetReferencedObj());
591 aNewTextEditOffset
= pVirtObj
->GetOffset();
594 // set in each case, thus it will be correct for all objects
595 ((SdrTextObj
*)pToBeActivated
)->SetTextEditOffset(aNewTextEditOffset
);
597 sal_Bool
bRet(pSdrView
->SdrBeginTextEdit( pToBeActivated
, pPV
, pWin
, sal_True
, pOutliner
, 0, sal_False
, sal_False
, sal_False
));
600 // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
601 // sets the background color, an own background color needs to be set
602 // after TextEditing was started. This is now done here.
605 OutlinerView
* pView
= pSdrView
->GetTextEditOutlinerView();
609 Color
aBackground(pSh
->GetShapeBackgrd());
610 pView
->SetBackgroundColor(aBackground
);
612 ESelection
aNewSelection(EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
, EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
);
613 pView
->SetSelection(aNewSelection
);
619 /******************************************************************************
620 * Beschreibung: Ist ein DrawTextObjekt selektiert?
621 ******************************************************************************/
625 sal_Bool
SwView::IsTextTool() const
629 SdrView
*pSdrView
= GetWrtShell().GetDrawView();
630 ASSERT( pSdrView
, "IsTextTool without DrawView?" );
632 if (pSdrView
->IsCreateMode())
633 pSdrView
->SetCreateMode(sal_False
);
635 pSdrView
->TakeCurrentObj(nId
,nInvent
);
636 return (nInvent
==SdrInventor
);
639 /*--------------------------------------------------------------------
641 --------------------------------------------------------------------*/
645 SdrView
* SwView::GetDrawView() const
647 return GetWrtShell().GetDrawView();
650 /*--------------------------------------------------------------------
652 --------------------------------------------------------------------*/
656 sal_Bool
SwView::IsBezierEditMode()
658 return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
661 /*--------------------------------------------------------------------
663 --------------------------------------------------------------------*/
665 sal_Bool
SwView::IsFormMode() const
667 if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
669 return (GetDrawFuncPtr()->IsInsertForm());
672 return AreOnlyFormsSelected();
675 /*--------------------------------------------------------------------
677 --------------------------------------------------------------------*/
681 void SwView::SetDrawFuncPtr(SwDrawBase
* pFuncPtr
)
685 pDrawActual
= pFuncPtr
;
688 /*--------------------------------------------------------------------
690 --------------------------------------------------------------------*/
692 void SwView::SetSelDrawSlot()
694 nDrawSfxId
= SID_OBJECT_SELECT
;
698 /*--------------------------------------------------------------------
700 --------------------------------------------------------------------*/
702 sal_Bool
SwView::AreOnlyFormsSelected() const
704 if ( GetWrtShell().IsFrmSelected() )
707 sal_Bool bForm
= sal_True
;
709 SdrView
* pSdrView
= GetWrtShell().GetDrawView();
711 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
712 sal_uInt32 nCount
= rMarkList
.GetMarkCount();
716 for (sal_uInt32 i
= 0; i
< nCount
; i
++)
718 // Sind ausser Controls noch normale Draw-Objekte selektiert?
719 SdrObject
*pSdrObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
721 if (!HasOnlyObj(pSdrObj
, FmFormInventor
))
734 /*--------------------------------------------------------------------
736 --------------------------------------------------------------------*/
738 sal_Bool
SwView::HasDrwObj(SdrObject
*pSdrObj
) const
740 sal_Bool bRet
= sal_False
;
742 if (pSdrObj
->IsGroupObject())
744 SdrObjList
* pList
= pSdrObj
->GetSubList();
745 sal_uInt32 nCnt
= pList
->GetObjCount();
747 for (sal_uInt32 i
= 0; i
< nCnt
; i
++)
748 if ((bRet
= HasDrwObj(pList
->GetObj(i
))) == sal_True
)
751 else if (SdrInventor
== pSdrObj
->GetObjInventor() || pSdrObj
->Is3DObj())
757 /*--------------------------------------------------------------------
759 --------------------------------------------------------------------*/
761 sal_Bool
SwView::HasOnlyObj(SdrObject
*pSdrObj
, sal_uInt32 eObjInventor
) const
763 sal_Bool bRet
= sal_False
;
765 if (pSdrObj
->IsGroupObject())
767 SdrObjList
* pList
= pSdrObj
->GetSubList();
768 sal_uInt32 nCnt
= pList
->GetObjCount();
770 for (sal_uInt32 i
= 0; i
< nCnt
; i
++)
771 if ((bRet
= HasOnlyObj(pList
->GetObj(i
), eObjInventor
)) == sal_False
)
774 else if (eObjInventor
== pSdrObj
->GetObjInventor())
782 IMPL_LINK(SwView
, OnlineSpellCallback
, SpellCallbackInfo
*, pInfo
)
784 if (pInfo
->nCommand
== SPELLCMD_STARTSPELLDLG
)
785 GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG
, SFX_CALLMODE_ASYNCHRON
);
789 /*--------------------------------------------------------------------
791 --------------------------------------------------------------------*/
792 sal_Bool
SwView::ExecDrwTxtSpellPopup(const Point
& rPt
)
794 sal_Bool bRet
= sal_False
;
795 SdrView
*pSdrView
= pWrtShell
->GetDrawView();
796 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
797 Point
aPos( GetEditWin().LogicToPixel( rPt
) );
799 if (pOLV
->IsWrongSpelledWordAtPos( aPos
))
802 Link aLink
= LINK(this, SwView
, OnlineSpellCallback
);
803 pOLV
->ExecuteSpellPopup( aPos
,&aLink
);
808 /*--------------------------------------------------------------------
810 --------------------------------------------------------------------*/
814 sal_Bool
SwView::IsDrawTextHyphenate()
816 SdrView
*pSdrView
= pWrtShell
->GetDrawView();
817 sal_Bool bHyphenate
= sal_False
;
819 SfxItemSet
aNewAttr( pSdrView
->GetModel()->GetItemPool(),
820 EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
821 if( pSdrView
->GetAttributes( aNewAttr
) &&
822 aNewAttr
.GetItemState( EE_PARA_HYPHENATE
) >= SFX_ITEM_AVAILABLE
)
823 bHyphenate
= ((const SfxBoolItem
&)aNewAttr
.Get( EE_PARA_HYPHENATE
)).
829 /*--------------------------------------------------------------------
831 --------------------------------------------------------------------*/
835 void SwView::HyphenateDrawText()
837 SdrView
*pSdrView
= pWrtShell
->GetDrawView();
838 sal_Bool bHyphenate
= IsDrawTextHyphenate();
840 SfxItemSet
aSet( GetPool(), EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
841 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, !bHyphenate
) );
842 pSdrView
->SetAttributes( aSet
);
843 GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG
);