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 .
21 #include "hintids.hxx"
22 #include <svl/aeitem.hxx>
23 #include <svl/itempool.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdview.hxx>
26 #include <svx/svdpage.hxx>
27 #include <editeng/editview.hxx>
28 #include <editeng/editeng.hxx>
29 #include <editeng/outliner.hxx>
30 #include <svx/fmview.hxx>
31 #include <svx/dataaccessdescriptor.hxx>
32 #include <sfx2/viewfrm.hxx>
34 #include <editeng/langitem.hxx>
35 #include <linguistic/lngprops.hxx>
36 #include <editeng/unolingu.hxx>
37 #include <svx/fontworkbar.hxx>
38 #include <svx/fontworkgallery.hxx>
39 #include <editeng/eeitem.hxx>
40 #include <svx/svdogrp.hxx>
41 #include <svx/svdetc.hxx>
42 #include <editeng/editstat.hxx>
43 #include <sfx2/request.hxx>
44 #include <sfx2/bindings.hxx>
45 #include <sfx2/printer.hxx>
46 #include <svx/fmglob.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <svx/svdoutl.hxx>
52 #include "viewopt.hxx"
55 #include "drwbassh.hxx"
56 #include "beziersh.hxx"
57 #include "conrect.hxx"
58 #include "conpoly.hxx"
60 #include "conform.hxx"
61 #include "concustomshape.hxx"
62 #include "dselect.hxx"
65 #include <dcontact.hxx>
67 #include <svx/svdpagv.hxx>
68 #include <svx/extrusionbar.hxx>
69 #include <vcl/svapp.hxx>
71 using namespace ::com::sun::star
;
73 /*--------------------------------------------------------------------
74 Beschreibung: Drawing-Ids ausfuehren
75 --------------------------------------------------------------------*/
76 void SwView::ExecDraw(SfxRequest
& rReq
)
78 const SfxItemSet
*pArgs
= rReq
.GetArgs();
79 const SfxPoolItem
* pItem
;
80 const SfxAllEnumItem
* pEItem
= 0;
81 const SfxStringItem
* pStringItem
= 0;
82 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
83 sal_Bool bDeselect
= sal_False
;
85 sal_uInt16 nSlotId
= rReq
.GetSlot();
86 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(GetPool().GetWhich(nSlotId
), sal_False
, &pItem
))
88 pEItem
= dynamic_cast< const SfxAllEnumItem
*>(pItem
);
89 pStringItem
= dynamic_cast< const SfxStringItem
*>(pItem
);
92 if (SID_INSERT_DRAW
== nSlotId
&& pEItem
)
93 switch ( pEItem
->GetValue() )
95 case SVX_SNAP_DRAW_SELECT
: nSlotId
= SID_OBJECT_SELECT
; break;
96 case SVX_SNAP_DRAW_LINE
: nSlotId
= SID_DRAW_LINE
; break;
97 case SVX_SNAP_DRAW_RECT
: nSlotId
= SID_DRAW_RECT
; break;
98 case SVX_SNAP_DRAW_ELLIPSE
: nSlotId
= SID_DRAW_ELLIPSE
; break;
99 case SVX_SNAP_DRAW_POLYGON_NOFILL
: nSlotId
= SID_DRAW_POLYGON_NOFILL
; break;
100 case SVX_SNAP_DRAW_BEZIER_NOFILL
: nSlotId
= SID_DRAW_BEZIER_NOFILL
; break;
101 case SVX_SNAP_DRAW_FREELINE_NOFILL
: nSlotId
= SID_DRAW_FREELINE_NOFILL
; break;
102 case SVX_SNAP_DRAW_ARC
: nSlotId
= SID_DRAW_ARC
; break;
103 case SVX_SNAP_DRAW_PIE
: nSlotId
= SID_DRAW_PIE
; break;
104 case SVX_SNAP_DRAW_CIRCLECUT
: nSlotId
= SID_DRAW_CIRCLECUT
; break;
105 case SVX_SNAP_DRAW_TEXT
: nSlotId
= SID_DRAW_TEXT
; break;
106 case SVX_SNAP_DRAW_TEXT_VERTICAL
: nSlotId
= SID_DRAW_TEXT_VERTICAL
; break;
107 case SVX_SNAP_DRAW_TEXT_MARQUEE
: nSlotId
= SID_DRAW_TEXT_MARQUEE
; break;
108 case SVX_SNAP_DRAW_CAPTION
: nSlotId
= SID_DRAW_CAPTION
; break;
109 case SVX_SNAP_DRAW_CAPTION_VERTICAL
: nSlotId
= SID_DRAW_CAPTION_VERTICAL
; break;
112 if (nSlotId
== SID_OBJECT_SELECT
&& m_nFormSfxId
== nSlotId
)
114 bDeselect
= sal_True
;
116 else if (nSlotId
== SID_FM_CREATE_CONTROL
)
118 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, sal_False
);
119 if( pIdentifierItem
)
121 sal_uInt16 nNewId
= pIdentifierItem
->GetValue();
122 if (nNewId
== m_nFormSfxId
)
124 bDeselect
= sal_True
;
125 GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE
); // Button soll rauspoppen
129 else if( nSlotId
== SID_FM_CREATE_FIELDCONTROL
)
131 FmFormView
* pFormView
= PTR_CAST( FmFormView
, pSdrView
);
134 SFX_REQUEST_ARG( rReq
, pDescriptorItem
, SfxUnoAnyItem
, SID_FM_DATACCESS_DESCRIPTOR
, sal_False
);
135 OSL_ENSURE( pDescriptorItem
, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
136 if( pDescriptorItem
)
138 ::svx::ODataAccessDescriptor
aDescriptor( pDescriptorItem
->GetValue() );
139 SdrObject
* pObj
= pFormView
->CreateFieldControl( aDescriptor
);
143 Size
aDocSize(m_pWrtShell
->GetDocSize());
144 const SwRect
& rVisArea
= m_pWrtShell
->VisArea();
145 Point aStartPos
= rVisArea
.Center();
146 if(rVisArea
.Width() > aDocSize
.Width())
147 aStartPos
.X() = aDocSize
.Width() / 2 + rVisArea
.Left();
148 if(rVisArea
.Height() > aDocSize
.Height())
149 aStartPos
.Y() = aDocSize
.Height() / 2 + rVisArea
.Top();
151 //determine the size of the object
152 if(pObj
->IsGroupObject())
154 const Rectangle
& rBoundRect
= ((SdrObjGroup
*)pObj
)->GetCurrentBoundRect();
155 aStartPos
.X() -= rBoundRect
.GetWidth()/2;
156 aStartPos
.Y() -= rBoundRect
.GetHeight()/2;
159 // TODO: unmark all other
160 m_pWrtShell
->EnterStdMode();
161 m_pWrtShell
->SwFEShell::InsertDrawObj( *pObj
, aStartPos
);
166 else if ( nSlotId
== SID_FONTWORK_GALLERY_FLOATER
)
168 Window
* pWin
= &( m_pWrtShell
->GetView().GetViewFrame()->GetWindow() );
173 if( !m_pWrtShell
->HasDrawView() )
174 m_pWrtShell
->MakeDrawView();
176 pSdrView
= m_pWrtShell
->GetDrawView();
179 SdrObject
* pObj
= NULL
;
180 svx::FontWorkGalleryDialog
aDlg( pSdrView
, pWin
, nSlotId
);
181 aDlg
.SetSdrObjectRef( &pObj
, pSdrView
->GetModel() );
185 Size
aDocSize( m_pWrtShell
->GetDocSize() );
186 const SwRect
& rVisArea
= m_pWrtShell
->VisArea();
187 Point
aPos( rVisArea
.Center() );
189 Size
aPrefSize( pObj
->GetSnapRect().GetSize() );
191 if( rVisArea
.Width() > aDocSize
.Width())
192 aPos
.X() = aDocSize
.Width() / 2 + rVisArea
.Left();
194 if(rVisArea
.Height() > aDocSize
.Height())
195 aPos
.Y() = aDocSize
.Height() / 2 + rVisArea
.Top();
197 if( aPrefSize
.Width() && aPrefSize
.Height() )
200 aSize
= pWin
->PixelToLogic( aPrefSize
, MAP_TWIP
);
202 aSize
= Application::GetDefaultDevice()->PixelToLogic( aPrefSize
, MAP_TWIP
);
205 aSize
= Size( 2835, 2835 );
207 m_pWrtShell
->EnterStdMode();
208 m_pWrtShell
->SwFEShell::InsertDrawObj( *pObj
, aPos
);
216 if( nSlotId
== SID_DRAW_CS_ID
)
218 //deselect if same custom shape is selected again
219 SwDrawBase
* pFuncPtr
= GetDrawFuncPtr();
220 if( pFuncPtr
&& pFuncPtr
->GetSlotId() == SID_DRAW_CS_ID
)
222 ConstCustomShape
* pConstCustomShape
= (ConstCustomShape
*)(pFuncPtr
);
223 OUString aNew
= ConstCustomShape::GetShapeTypeFromRequest( rReq
);
224 OUString aOld
= pConstCustomShape
->GetShapeType();
232 //deselect if same shape is selected again (but different custom shapes do have same slot id)
233 if ( bDeselect
|| (nSlotId
== m_nDrawSfxId
&&
234 (!pStringItem
|| (pStringItem
->GetValue() == m_sDrawCustom
))
235 && (nSlotId
!= SID_DRAW_CS_ID
) ) )
237 if (GetDrawFuncPtr())
239 GetDrawFuncPtr()->Deactivate();
240 SetDrawFuncPtr(NULL
);
243 if (m_pWrtShell
->IsObjSelected() && !m_pWrtShell
->IsSelFrmMode())
244 m_pWrtShell
->EnterSelFrmMode(NULL
);
247 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW
);
249 AttrChangedNotify(m_pWrtShell
);
255 if (m_pWrtShell
->IsFrmSelected())
256 m_pWrtShell
->EnterStdMode(); // wegen Bug #45639
258 SwDrawBase
* pFuncPtr
= NULL
;
262 case SID_OBJECT_SELECT
:
263 case SID_DRAW_SELECT
:
264 pFuncPtr
= new DrawSelection(m_pWrtShell
, m_pEditWin
, this);
265 m_nDrawSfxId
= m_nFormSfxId
= SID_OBJECT_SELECT
;
266 m_sDrawCustom
.Erase();
271 case SID_DRAW_ELLIPSE
:
273 case SID_DRAW_TEXT_VERTICAL
:
274 case SID_DRAW_TEXT_MARQUEE
:
275 case SID_DRAW_CAPTION
:
276 case SID_DRAW_CAPTION_VERTICAL
:
277 pFuncPtr
= new ConstRectangle(m_pWrtShell
, m_pEditWin
, this);
278 m_nDrawSfxId
= nSlotId
;
279 m_sDrawCustom
.Erase();
282 case SID_DRAW_POLYGON_NOFILL
:
283 case SID_DRAW_BEZIER_NOFILL
:
284 case SID_DRAW_FREELINE_NOFILL
:
285 pFuncPtr
= new ConstPolygon(m_pWrtShell
, m_pEditWin
, this);
286 m_nDrawSfxId
= nSlotId
;
287 m_sDrawCustom
.Erase();
292 case SID_DRAW_CIRCLECUT
:
293 pFuncPtr
= new ConstArc(m_pWrtShell
, m_pEditWin
, this);
294 m_nDrawSfxId
= nSlotId
;
295 m_sDrawCustom
.Erase();
298 case SID_FM_CREATE_CONTROL
:
300 SFX_REQUEST_ARG( rReq
, pIdentifierItem
, SfxUInt16Item
, SID_FM_CONTROL_IDENTIFIER
, sal_False
);
301 if( pIdentifierItem
)
302 nSlotId
= pIdentifierItem
->GetValue();
303 pFuncPtr
= new ConstFormControl(m_pWrtShell
, m_pEditWin
, this);
304 m_nFormSfxId
= nSlotId
;
308 case SID_DRAWTBX_CS_BASIC
:
309 case SID_DRAWTBX_CS_SYMBOL
:
310 case SID_DRAWTBX_CS_ARROW
:
311 case SID_DRAWTBX_CS_FLOWCHART
:
312 case SID_DRAWTBX_CS_CALLOUT
:
313 case SID_DRAWTBX_CS_STAR
:
314 case SID_DRAW_CS_ID
:
316 pFuncPtr
= new ConstCustomShape(m_pWrtShell
, m_pEditWin
, this, rReq
);
317 m_nDrawSfxId
= nSlotId
;
318 if ( nSlotId
!= SID_DRAW_CS_ID
)
322 m_sDrawCustom
= pStringItem
->GetValue();
323 m_aCurrShapeEnumCommand
[ nSlotId
- SID_DRAWTBX_CS_BASIC
] = m_sDrawCustom
;
324 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
325 rBind
.Invalidate( nSlotId
);
326 rBind
.Update( nSlotId
);
336 static sal_uInt16
const aInval
[] =
338 // Slot-Ids muessen beim Aufruf von Invalidate sortiert sein!
343 GetViewFrame()->GetBindings().Invalidate(aInval
);
345 sal_Bool bEndTextEdit
= sal_True
;
348 if (GetDrawFuncPtr())
350 GetDrawFuncPtr()->Deactivate();
351 SetDrawFuncPtr(NULL
);
354 SetDrawFuncPtr(pFuncPtr
);
355 AttrChangedNotify(m_pWrtShell
);
357 pFuncPtr
->Activate(nSlotId
);
359 if(rReq
.GetModifier() == KEY_MOD1
)
361 if(SID_OBJECT_SELECT
== m_nDrawSfxId
)
363 m_pWrtShell
->GotoObj(sal_True
);
367 pFuncPtr
->CreateDefaultObject();
368 pFuncPtr
->Deactivate();
369 SetDrawFuncPtr(NULL
);
371 m_pWrtShell
->EnterStdMode();
372 SdrView
*pTmpSdrView
= m_pWrtShell
->GetDrawView();
373 const SdrMarkList
& rMarkList
= pTmpSdrView
->GetMarkedObjectList();
374 if(rMarkList
.GetMarkCount() == 1 &&
375 (SID_DRAW_TEXT
== nSlotId
|| SID_DRAW_TEXT_VERTICAL
== nSlotId
||
376 SID_DRAW_TEXT_MARQUEE
== nSlotId
))
378 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
380 bEndTextEdit
= sal_False
;
387 if (m_pWrtShell
->IsObjSelected() && !m_pWrtShell
->IsSelFrmMode())
388 m_pWrtShell
->EnterSelFrmMode(NULL
);
391 if(bEndTextEdit
&& pSdrView
&& pSdrView
->IsTextEdit())
392 pSdrView
->SdrEndTextEdit( sal_True
);
394 AttrChangedNotify(m_pWrtShell
);
397 /*--------------------------------------------------------------------
398 Beschreibung: Drawing beenden
399 --------------------------------------------------------------------*/
400 void SwView::ExitDraw()
406 // the shell may be invalid at close/reload/SwitchToViewShell
407 SfxDispatcher
* pDispatch
= GetViewFrame()->GetDispatcher();
412 pTest
= pDispatch
->GetShell(nIdx
++);
414 while( pTest
&& pTest
!= this && pTest
!= m_pShell
);
415 if(pTest
== m_pShell
&&
416 // don't call LeaveSelFrmMode() etc. for the below,
417 // because objects may still be selected:
418 !m_pShell
->ISA(SwDrawBaseShell
) &&
419 !m_pShell
->ISA(SwBezierShell
) &&
420 !m_pShell
->ISA(svx::ExtrusionBar
) &&
421 !m_pShell
->ISA(svx::FontworkBar
))
423 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
425 if (pSdrView
&& pSdrView
->IsGroupEntered())
427 pSdrView
->LeaveOneGroup();
428 pSdrView
->UnmarkAll();
429 GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP
);
432 if (GetDrawFuncPtr())
434 if (m_pWrtShell
->IsSelFrmMode())
435 m_pWrtShell
->LeaveSelFrmMode();
436 GetDrawFuncPtr()->Deactivate();
438 SetDrawFuncPtr(NULL
);
441 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW
);
443 GetEditWin().SetPointer(Pointer(POINTER_TEXT
));
448 /*--------------------------------------------------------------------
449 Beschreibung: Rotate-Mode abschalten
450 --------------------------------------------------------------------*/
451 void SwView::NoRotate()
455 m_pWrtShell
->SetDragMode(SDRDRAG_MOVE
);
458 const SfxBoolItem
aTmp( SID_OBJECT_ROTATE
, sal_False
);
459 GetViewFrame()->GetBindings().SetState( aTmp
);
463 /******************************************************************************
464 * Beschreibung: DrawTextEditMode einschalten
465 ******************************************************************************/
466 sal_Bool
SwView::EnterDrawTextMode(const Point
& aDocPos
)
470 SwWrtShell
*pSh
= &GetWrtShell();
471 SdrView
*pSdrView
= pSh
->GetDrawView();
472 OSL_ENSURE( pSdrView
, "EnterDrawTextMode without DrawView?" );
474 sal_Bool bReturn
= sal_False
;
476 sal_uInt16 nOld
= pSdrView
->GetHitTolerancePixel();
477 pSdrView
->SetHitTolerancePixel( 2 );
479 if( pSdrView
->IsMarkedHit( aDocPos
) &&
480 !pSdrView
->PickHandle( aDocPos
) && IsTextTool() &&
481 pSdrView
->PickObj( aDocPos
, pSdrView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_PICKTEXTEDIT
) &&
483 // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
484 ( pObj
->ISA( SdrTextObj
) ||
485 ( pObj
->ISA(SwDrawVirtObj
) &&
486 ((SwDrawVirtObj
*)pObj
)->GetReferencedObj().ISA(SdrTextObj
) ) ) &&
488 !m_pWrtShell
->IsSelObjProtected(FLYPROTECT_CONTENT
))
490 bReturn
= BeginTextEdit( pObj
, pPV
, m_pEditWin
, sal_False
);
493 pSdrView
->SetHitTolerancePixel( nOld
);
498 /******************************************************************************
499 * Beschreibung: DrawTextEditMode einschalten
500 ******************************************************************************/
501 sal_Bool
SwView::BeginTextEdit(SdrObject
* pObj
, SdrPageView
* pPV
, Window
* pWin
,
502 bool bIsNewObj
, bool bSetSelectionToStart
)
504 SwWrtShell
*pSh
= &GetWrtShell();
505 SdrView
*pSdrView
= pSh
->GetDrawView();
506 SdrOutliner
* pOutliner
= ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT
, pSdrView
->GetModel());
507 uno::Reference
< linguistic2::XSpellChecker1
> xSpell( ::GetSpellChecker() );
510 pOutliner
->SetRefDevice(pSh
->getIDocumentDeviceAccess()->getReferenceDevice(false));
511 pOutliner
->SetSpeller(xSpell
);
512 uno::Reference
<linguistic2::XHyphenator
> xHyphenator( ::GetHyphenator() );
513 pOutliner
->SetHyphenator( xHyphenator
);
514 pSh
->SetCalcFieldValueHdl(pOutliner
);
516 sal_uInt32 nCntrl
= pOutliner
->GetControlWord();
517 nCntrl
|= EE_CNTRL_ALLOWBIGOBJS
;
518 nCntrl
|= EE_CNTRL_URLSFXEXECUTE
;
520 const SwViewOption
*pOpt
= pSh
->GetViewOptions();
522 if (SwViewOption::IsFieldShadings())
523 nCntrl
|= EE_CNTRL_MARKFIELDS
;
525 nCntrl
&= ~EE_CNTRL_MARKFIELDS
;
527 if (pOpt
->IsOnlineSpell())
528 nCntrl
|= EE_CNTRL_ONLINESPELLING
;
530 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
532 pOutliner
->SetControlWord(nCntrl
);
533 const SfxPoolItem
& rItem
= pSh
->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE
);
534 pOutliner
->SetDefaultLanguage(((const SvxLanguageItem
&)rItem
).GetLanguage());
537 pOutliner
->SetVertical( SID_DRAW_TEXT_VERTICAL
== m_nDrawSfxId
||
538 SID_DRAW_CAPTION_VERTICAL
== m_nDrawSfxId
);
540 // set default horizontal text direction at outliner
541 EEHorizontalTextDirection aDefHoriTextDir
=
542 pSh
->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L
: EE_HTEXTDIR_L2R
;
543 pOutliner
->SetDefaultHorizontalTextDirection( aDefHoriTextDir
);
546 // To allow editing the referenced object from a SwDrawVirtObj here
547 // the original needs to be fetched evenually. This ATM activates the
548 // text edit mode for the original object.
549 SdrObject
* pToBeActivated
= pObj
;
551 // Always the original object is edited. To allow the TextEdit to happen
552 // where the VirtObj is positioned, on demand a occurring offset is set at
553 // the TextEdit object. That offset is used for creating and managing the
555 Point
aNewTextEditOffset(0, 0);
557 if(pObj
->ISA(SwDrawVirtObj
))
559 SwDrawVirtObj
* pVirtObj
= (SwDrawVirtObj
*)pObj
;
560 pToBeActivated
= &((SdrObject
&)pVirtObj
->GetReferencedObj());
561 aNewTextEditOffset
= pVirtObj
->GetOffset();
564 // set in each case, thus it will be correct for all objects
565 ((SdrTextObj
*)pToBeActivated
)->SetTextEditOffset(aNewTextEditOffset
);
567 sal_Bool
bRet(pSdrView
->SdrBeginTextEdit( pToBeActivated
, pPV
, pWin
, sal_True
, pOutliner
, 0, sal_False
, sal_False
, sal_False
));
570 // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
571 // sets the background color, an own background color needs to be set
572 // after TextEditing was started. This is now done here.
575 OutlinerView
* pView
= pSdrView
->GetTextEditOutlinerView();
579 Color
aBackground(pSh
->GetShapeBackgrd());
580 pView
->SetBackgroundColor(aBackground
);
583 // editing should start at the end of text, spell checking at the beginning ...
584 ESelection
aNewSelection(EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
, EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
);
585 if (bSetSelectionToStart
)
586 aNewSelection
= ESelection();
587 pView
->SetSelection(aNewSelection
);
593 /******************************************************************************
594 * Beschreibung: Ist ein DrawTextObjekt selektiert?
595 ******************************************************************************/
596 bool SwView::IsTextTool() const
600 SdrView
*pSdrView
= GetWrtShell().GetDrawView();
601 OSL_ENSURE( pSdrView
, "IsTextTool without DrawView?" );
603 if (pSdrView
->IsCreateMode())
604 pSdrView
->SetCreateMode(sal_False
);
606 pSdrView
->TakeCurrentObj(nId
,nInvent
);
607 return (nInvent
==SdrInventor
);
610 SdrView
* SwView::GetDrawView() const
612 return GetWrtShell().GetDrawView();
615 bool SwView::IsBezierEditMode()
617 return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
620 bool SwView::IsFormMode() const
622 if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
624 return (GetDrawFuncPtr()->IsInsertForm());
627 return AreOnlyFormsSelected();
630 void SwView::SetDrawFuncPtr(SwDrawBase
* pFuncPtr
)
632 delete m_pDrawActual
;
633 m_pDrawActual
= pFuncPtr
;
636 void SwView::SetSelDrawSlot()
638 m_nDrawSfxId
= SID_OBJECT_SELECT
;
639 m_sDrawCustom
.Erase();
642 bool SwView::AreOnlyFormsSelected() const
644 if ( GetWrtShell().IsFrmSelected() )
649 SdrView
* pSdrView
= GetWrtShell().GetDrawView();
651 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
652 sal_uInt32 nCount
= rMarkList
.GetMarkCount();
656 for (sal_uInt32 i
= 0; i
< nCount
; i
++)
658 // Sind ausser Controls noch normale Draw-Objekte selektiert?
659 SdrObject
*pSdrObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
661 if (!HasOnlyObj(pSdrObj
, FmFormInventor
))
674 sal_Bool
SwView::HasDrwObj(SdrObject
*pSdrObj
) const
676 sal_Bool bRet
= sal_False
;
678 if (pSdrObj
->IsGroupObject())
680 SdrObjList
* pList
= pSdrObj
->GetSubList();
681 sal_uInt32 nCnt
= pList
->GetObjCount();
683 for (sal_uInt32 i
= 0; i
< nCnt
; i
++)
684 if ((bRet
= HasDrwObj(pList
->GetObj(i
))) == sal_True
)
687 else if (SdrInventor
== pSdrObj
->GetObjInventor() || pSdrObj
->Is3DObj())
693 sal_Bool
SwView::HasOnlyObj(SdrObject
*pSdrObj
, sal_uInt32 eObjInventor
) const
695 sal_Bool bRet
= sal_False
;
697 if (pSdrObj
->IsGroupObject())
699 SdrObjList
* pList
= pSdrObj
->GetSubList();
700 sal_uInt32 nCnt
= pList
->GetObjCount();
702 for (sal_uInt32 i
= 0; i
< nCnt
; i
++)
703 if ((bRet
= HasOnlyObj(pList
->GetObj(i
), eObjInventor
)) == sal_False
)
706 else if (eObjInventor
== pSdrObj
->GetObjInventor())
713 IMPL_LINK(SwView
, OnlineSpellCallback
, SpellCallbackInfo
*, pInfo
)
715 if (pInfo
->nCommand
== SPELLCMD_STARTSPELLDLG
)
716 GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG
, SFX_CALLMODE_ASYNCHRON
);
720 sal_Bool
SwView::ExecDrwTxtSpellPopup(const Point
& rPt
)
722 sal_Bool bRet
= sal_False
;
723 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
724 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
725 Point
aPos( GetEditWin().LogicToPixel( rPt
) );
727 if (pOLV
->IsWrongSpelledWordAtPos( aPos
))
730 Link aLink
= LINK(this, SwView
, OnlineSpellCallback
);
731 pOLV
->ExecuteSpellPopup( aPos
,&aLink
);
736 sal_Bool
SwView::IsDrawTextHyphenate()
738 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
739 sal_Bool bHyphenate
= sal_False
;
741 SfxItemSet
aNewAttr( pSdrView
->GetModel()->GetItemPool(),
742 EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
743 if( pSdrView
->GetAttributes( aNewAttr
) &&
744 aNewAttr
.GetItemState( EE_PARA_HYPHENATE
) >= SFX_ITEM_AVAILABLE
)
745 bHyphenate
= ((const SfxBoolItem
&)aNewAttr
.Get( EE_PARA_HYPHENATE
)).
751 void SwView::HyphenateDrawText()
753 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
754 sal_Bool bHyphenate
= IsDrawTextHyphenate();
756 SfxItemSet
aSet( GetPool(), EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
757 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, !bHyphenate
) );
758 pSdrView
->SetAttributes( aSet
);
759 GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG
);
762 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */