xref: /aoo41x/main/sw/source/ui/uiview/viewdraw.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include "hintids.hxx"
29 #include <svl/aeitem.hxx>
30 #include <svl/itempool.hxx>
31 #include <svx/svdobj.hxx>
32 #include <svx/svdview.hxx>
33 #include <svx/svdpage.hxx>
34 #include <editeng/editview.hxx>
35 #include <editeng/editeng.hxx>
36 #include <editeng/outliner.hxx>
37 #include <svx/fmview.hxx>
38 #include <svx/dataaccessdescriptor.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <doc.hxx>
41 #include <editeng/langitem.hxx>
42 #include <linguistic/lngprops.hxx>
43 #include <editeng/unolingu.hxx>
44 #include <svx/fontworkbar.hxx>
45 #include <svx/fontworkgallery.hxx>
46 #include <editeng/eeitem.hxx>
47 #include <svx/svdogrp.hxx>
48 #include <svx/svdetc.hxx>
49 #include <editeng/editstat.hxx>
50 #include <sfx2/request.hxx>
51 #include <sfx2/bindings.hxx>
52 #include <sfx2/printer.hxx>
53 #include <svx/fmglob.hxx>
54 #include <sfx2/dispatch.hxx>
55 #include <svx/svdoutl.hxx>
56 
57 #include "view.hxx"
58 #include "wrtsh.hxx"
59 #include "viewopt.hxx"
60 #include "cmdid.h"
61 #include "drawsh.hxx"
62 #include "drwbassh.hxx"
63 #include "beziersh.hxx"
64 #include "conrect.hxx"
65 #include "conpoly.hxx"
66 #include "conarc.hxx"
67 #include "conform.hxx"
68 #include "concustomshape.hxx"
69 #include "dselect.hxx"
70 #include "edtwin.hxx"
71 
72 // #108784#
73 #include <dcontact.hxx>
74 
75 // #108784#
76 #include <svx/svdpagv.hxx>
77 #include <svx/extrusionbar.hxx>
78 #include <vcl/svapp.hxx>
79 
80 using namespace ::com::sun::star;
81 /*--------------------------------------------------------------------
82 	Beschreibung: 	Drawing-Ids ausfuehren
83  --------------------------------------------------------------------*/
84 
ExecDraw(SfxRequest & rReq)85 void SwView::ExecDraw(SfxRequest& rReq)
86 {
87 	const SfxItemSet *pArgs = rReq.GetArgs();
88 	const SfxPoolItem* pItem;
89 	const SfxAllEnumItem* pEItem = 0;
90     const SfxStringItem* pStringItem = 0;
91 	SdrView *pSdrView = pWrtShell->GetDrawView();
92 	sal_Bool bDeselect = sal_False;
93 
94 	sal_uInt16 nSlotId = rReq.GetSlot();
95 	if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), sal_False, &pItem))
96 	{
97         pEItem = dynamic_cast< const SfxAllEnumItem*>(pItem);
98         pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
99     }
100 
101     if (SID_INSERT_DRAW == nSlotId && pEItem)
102         switch ( pEItem->GetValue() )
103 		{
104             case SVX_SNAP_DRAW_SELECT:              nSlotId = SID_OBJECT_SELECT;            break;
105             case SVX_SNAP_DRAW_LINE:                nSlotId = SID_DRAW_LINE;                break;
106             case SVX_SNAP_DRAW_RECT:                nSlotId = SID_DRAW_RECT;                break;
107             case SVX_SNAP_DRAW_ELLIPSE:             nSlotId = SID_DRAW_ELLIPSE;             break;
108             case SVX_SNAP_DRAW_POLYGON_NOFILL:      nSlotId = SID_DRAW_POLYGON_NOFILL;      break;
109             case SVX_SNAP_DRAW_BEZIER_NOFILL:       nSlotId = SID_DRAW_BEZIER_NOFILL;       break;
110             case SVX_SNAP_DRAW_FREELINE_NOFILL:     nSlotId = SID_DRAW_FREELINE_NOFILL;     break;
111             case SVX_SNAP_DRAW_ARC:                 nSlotId = SID_DRAW_ARC;                 break;
112             case SVX_SNAP_DRAW_PIE:                 nSlotId = SID_DRAW_PIE;                 break;
113             case SVX_SNAP_DRAW_CIRCLECUT:           nSlotId = SID_DRAW_CIRCLECUT;           break;
114             case SVX_SNAP_DRAW_TEXT:                nSlotId = SID_DRAW_TEXT;                break;
115             case SVX_SNAP_DRAW_TEXT_VERTICAL:       nSlotId = SID_DRAW_TEXT_VERTICAL;       break;
116             case SVX_SNAP_DRAW_TEXT_MARQUEE:        nSlotId = SID_DRAW_TEXT_MARQUEE;        break;
117             case SVX_SNAP_DRAW_CAPTION:             nSlotId = SID_DRAW_CAPTION;             break;
118             case SVX_SNAP_DRAW_CAPTION_VERTICAL:    nSlotId = SID_DRAW_CAPTION_VERTICAL;    break;
119 		}
120 
121 	if (nSlotId == SID_OBJECT_SELECT && nFormSfxId == nSlotId)
122 	{
123 		bDeselect = sal_True;
124 	}
125 	else if (nSlotId == SID_FM_CREATE_CONTROL)
126 	{
127 		SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
128 		if( pIdentifierItem )
129 		{
130 			sal_uInt16 nNewId = pIdentifierItem->GetValue();
131 			if (nNewId == nFormSfxId)
132 			{
133 				bDeselect = sal_True;
134 				GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE);	// Button soll rauspoppen
135 			}
136 		}
137 	}
138     else if( nSlotId == SID_FM_CREATE_FIELDCONTROL)
139     {
140         FmFormView* pFormView = PTR_CAST( FmFormView, pSdrView );
141         if ( pFormView )
142         {
143             SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
144             DBG_ASSERT( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
145             if( pDescriptorItem )
146             {
147                 ::svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
148                 SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
149 
150                 if ( pObj )
151                 {
152                     Size aDocSize(pWrtShell->GetDocSize());
153                     const SwRect& rVisArea = pWrtShell->VisArea();
154                     Point aStartPos = rVisArea.Center();
155                     if(rVisArea.Width() > aDocSize.Width())
156                         aStartPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
157                     if(rVisArea.Height() > aDocSize.Height())
158                         aStartPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
159 
160                     //determine the size of the object
161                     if(pObj->IsGroupObject())
162                     {
163                         const Rectangle& rBoundRect = ((SdrObjGroup*)pObj)->GetCurrentBoundRect();
164                         aStartPos.X() -= rBoundRect.GetWidth()/2;
165                         aStartPos.Y() -= rBoundRect.GetHeight()/2;
166                     }
167 
168                     // TODO: unmark all other
169                     pWrtShell->EnterStdMode();
170                     pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
171                 }
172             }
173         }
174     }
175 	else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
176 	{
177 		Window*	 pWin = &( pWrtShell->GetView().GetViewFrame()->GetWindow() );
178 
179 		if ( pWin )
180 			pWin->EnterWait();
181 
182 		if( !pWrtShell->HasDrawView() )
183 			pWrtShell->MakeDrawView();
184 
185 		pSdrView = pWrtShell->GetDrawView();
186 		if ( pSdrView )
187 		{
188 			SdrObject* pObj = NULL;
189 			svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId );
190 			aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
191 			aDlg.Execute();
192 			if ( pObj )
193 			{
194 				Size 			aDocSize( pWrtShell->GetDocSize() );
195 				const SwRect& 	rVisArea = pWrtShell->VisArea();
196 				Point 			aPos( rVisArea.Center() );
197 				Size			aSize;
198 				Size			aPrefSize( pObj->GetSnapRect().GetSize() );
199 
200 				if( rVisArea.Width() > aDocSize.Width())
201 					aPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
202 
203 				if(rVisArea.Height() > aDocSize.Height())
204 					aPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
205 
206 				if( aPrefSize.Width() && aPrefSize.Height() )
207 				{
208 					if( pWin )
209 						aSize = pWin->PixelToLogic( aPrefSize, MAP_TWIP );
210 					else
211 						aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
212 				}
213 				else
214 					aSize = Size( 2835, 2835 );
215 
216 				pWrtShell->EnterStdMode();
217                 pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
218 				rReq.Ignore ();
219 			}
220 		}
221 		if( pWin )
222 			pWin->LeaveWait();
223 	}
224 
225 	if( nSlotId == SID_DRAW_CS_ID )
226     {
227         //deselect if same custom shape is selected again
228         SwDrawBase* pFuncPtr = GetDrawFuncPtr();
229         if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
230         {
231             ConstCustomShape* pConstCustomShape = (ConstCustomShape*)(pFuncPtr);
232             rtl::OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
233             rtl::OUString aOld = pConstCustomShape->GetShapeType();
234             if( aNew == aOld )
235             {
236                 bDeselect = true;
237             }
238         }
239     }
240 
241     //deselect if same shape is selected again (but different custom shapes do have same slot id)
242     if ( bDeselect || (nSlotId == nDrawSfxId &&
243             (!pStringItem || (pStringItem->GetValue() == sDrawCustom))
244                 && (nSlotId != SID_DRAW_CS_ID) ) )
245 	{
246 		if (GetDrawFuncPtr())
247 		{
248 			GetDrawFuncPtr()->Deactivate();
249 			SetDrawFuncPtr(NULL);
250 		}
251 
252 		if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
253 			pWrtShell->EnterSelFrmMode(NULL);
254 		LeaveDrawCreate();
255 
256 		GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
257 
258 		AttrChangedNotify(pWrtShell);
259 		return;
260 	}
261 
262 	LeaveDrawCreate();
263 
264 	if (pWrtShell->IsFrmSelected())
265 		pWrtShell->EnterStdMode();	// wegen Bug #45639
266 
267 	SwDrawBase* pFuncPtr = NULL;
268 
269 	switch (nSlotId)
270 	{
271 		case SID_OBJECT_SELECT:
272 		case SID_DRAW_SELECT:
273 			pFuncPtr = new DrawSelection(pWrtShell, pEditWin, this);
274 			nDrawSfxId = nFormSfxId = SID_OBJECT_SELECT;
275             sDrawCustom.Erase();
276 			break;
277 
278 		case SID_DRAW_LINE:
279 		case SID_DRAW_RECT:
280 		case SID_DRAW_ELLIPSE:
281 		case SID_DRAW_TEXT:
282 		case SID_DRAW_TEXT_VERTICAL:
283 		case SID_DRAW_TEXT_MARQUEE:
284 		case SID_DRAW_CAPTION:
285 		case SID_DRAW_CAPTION_VERTICAL:
286 			pFuncPtr = new ConstRectangle(pWrtShell, pEditWin, this);
287 			nDrawSfxId = nSlotId;
288             sDrawCustom.Erase();
289             break;
290 
291 		case SID_DRAW_POLYGON_NOFILL:
292 		case SID_DRAW_BEZIER_NOFILL:
293 		case SID_DRAW_FREELINE_NOFILL:
294 			pFuncPtr = new ConstPolygon(pWrtShell, pEditWin, this);
295 			nDrawSfxId = nSlotId;
296             sDrawCustom.Erase();
297             break;
298 
299 		case SID_DRAW_ARC:
300 		case SID_DRAW_PIE:
301 		case SID_DRAW_CIRCLECUT:
302 			pFuncPtr = new ConstArc(pWrtShell, pEditWin, this);
303 			nDrawSfxId = nSlotId;
304             sDrawCustom.Erase();
305             break;
306 
307 		case SID_FM_CREATE_CONTROL:
308 		{
309 			SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
310 			if( pIdentifierItem )
311 				nSlotId = pIdentifierItem->GetValue();
312 			pFuncPtr = new ConstFormControl(pWrtShell, pEditWin, this);
313 			nFormSfxId = nSlotId;
314 		}
315 		break;
316 
317 		case SID_DRAWTBX_CS_BASIC :
318 		case SID_DRAWTBX_CS_SYMBOL :
319 		case SID_DRAWTBX_CS_ARROW :
320 		case SID_DRAWTBX_CS_FLOWCHART :
321 		case SID_DRAWTBX_CS_CALLOUT :
322 		case SID_DRAWTBX_CS_STAR :
323 		case SID_DRAW_CS_ID :
324 		{
325 			pFuncPtr = new ConstCustomShape(pWrtShell, pEditWin, this, rReq );
326             nDrawSfxId = nSlotId;
327             if ( nSlotId != SID_DRAW_CS_ID )
328             {
329                 if ( pStringItem )
330                 {
331                     sDrawCustom = pStringItem->GetValue();
332                     aCurrShapeEnumCommand[ nSlotId - SID_DRAWTBX_CS_BASIC ] = sDrawCustom;
333 		            SfxBindings& rBind = GetViewFrame()->GetBindings();
334 		            rBind.Invalidate( nSlotId );
335 		            rBind.Update( nSlotId );
336                 }
337             }
338 		}
339 		break;
340 
341 		default:
342 			break;
343 	}
344 
345 	static sal_uInt16 __READONLY_DATA aInval[] =
346 	{
347 		// Slot-Ids muessen beim Aufruf von Invalidate sortiert sein!
348 		SID_ATTRIBUTES_AREA,
349 		SID_INSERT_DRAW,
350 		0
351 	};
352 	GetViewFrame()->GetBindings().Invalidate(aInval);
353 
354     sal_Bool bEndTextEdit = sal_True;
355     if (pFuncPtr)
356 	{
357         if (GetDrawFuncPtr())
358 		{
359 			GetDrawFuncPtr()->Deactivate();
360 			SetDrawFuncPtr(NULL);
361 		}
362 
363         SetDrawFuncPtr(pFuncPtr);
364         AttrChangedNotify(pWrtShell);
365 
366         pFuncPtr->Activate(nSlotId);
367         NoRotate();
368         if(rReq.GetModifier() == KEY_MOD1)
369         {
370             if(SID_OBJECT_SELECT == nDrawSfxId )
371             {
372                 pWrtShell->GotoObj(sal_True);
373             }
374             else
375             {
376                 pFuncPtr->CreateDefaultObject();
377                 pFuncPtr->Deactivate();
378                 SetDrawFuncPtr(NULL);
379                 LeaveDrawCreate();
380                 pWrtShell->EnterStdMode();
381                 SdrView *pTmpSdrView = pWrtShell->GetDrawView();
382                 const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
383                 if(rMarkList.GetMarkCount() == 1 &&
384 						(SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
385 							SID_DRAW_TEXT_MARQUEE == nSlotId ))
386                 {
387 					SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
388 					BeginTextEdit(pObj);
389                     bEndTextEdit = sal_False;
390                 }
391             }
392         }
393     }
394 	else
395 	{
396 		if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
397 			pWrtShell->EnterSelFrmMode(NULL);
398 	}
399 
400     if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
401 		pSdrView->SdrEndTextEdit( sal_True );
402 
403 	AttrChangedNotify(pWrtShell);
404 }
405 
406 /*--------------------------------------------------------------------
407 	Beschreibung: 	Drawing beenden
408  --------------------------------------------------------------------*/
409 
410 
411 
ExitDraw()412 void SwView::ExitDraw()
413 {
414 	NoRotate();
415 
416     if(pShell)
417     {
418         //#126062 # the shell may be invalid at close/reload/SwitchToViewShell
419         SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
420         sal_uInt16 nIdx = 0;
421         SfxShell* pTest = 0;
422         do
423         {
424             pTest = pDispatch->GetShell(nIdx++);
425         }
426         while( pTest && pTest != this && pTest != pShell);
427         if(pTest == pShell &&
428             // don't call LeaveSelFrmMode() etc. for the below,
429             // because objects may still be selected:
430             !pShell->ISA(SwDrawBaseShell) &&
431             !pShell->ISA(SwBezierShell) &&
432             !pShell->ISA(svx::ExtrusionBar) &&
433             !pShell->ISA(svx::FontworkBar))
434         {
435             SdrView *pSdrView = pWrtShell->GetDrawView();
436 
437             if (pSdrView && pSdrView->IsGroupEntered())
438             {
439                 pSdrView->LeaveOneGroup();
440                 pSdrView->UnmarkAll();
441                 GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
442             }
443 
444             if (GetDrawFuncPtr())
445             {
446                 if (pWrtShell->IsSelFrmMode())
447                     pWrtShell->LeaveSelFrmMode();
448                 GetDrawFuncPtr()->Deactivate();
449 
450                 SetDrawFuncPtr(NULL);
451                 LeaveDrawCreate();
452 
453                 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
454             }
455             GetEditWin().SetPointer(Pointer(POINTER_TEXT));
456         }
457     }
458 }
459 
460 /*--------------------------------------------------------------------
461 	Beschreibung: 	Rotate-Mode abschalten
462  --------------------------------------------------------------------*/
463 
464 
465 
NoRotate()466 void SwView::NoRotate()
467 {
468 	if (IsDrawRotate())
469 	{
470 		pWrtShell->SetDragMode(SDRDRAG_MOVE);
471 		FlipDrawRotate();
472 
473 		const SfxBoolItem aTmp( SID_OBJECT_ROTATE, sal_False );
474 		GetViewFrame()->GetBindings().SetState( aTmp );
475 	}
476 }
477 
478 /******************************************************************************
479  *	Beschreibung: DrawTextEditMode einschalten
480  ******************************************************************************/
481 
EnterDrawTextMode(const Point & aDocPos)482 sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos)
483 {
484 	SdrObject* pObj;
485 	SdrPageView* pPV;
486 	SwWrtShell *pSh = &GetWrtShell();
487 	SdrView *pSdrView = pSh->GetDrawView();
488 	ASSERT( pSdrView, "EnterDrawTextMode without DrawView?" );
489 
490 	sal_Bool bReturn = sal_False;
491 
492 	sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
493 	pSdrView->SetHitTolerancePixel( 2 );
494 
495 	if( pSdrView->IsMarkedHit( aDocPos ) &&
496 		!pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
497 		pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) &&
498 
499 		// #108784#
500 		// To allow SwDrawVirtObj text objects to be activated, allow their type, too.
501 		//pObj->ISA( SdrTextObj ) &&
502         ( pObj->ISA( SdrTextObj ) ||
503           ( pObj->ISA(SwDrawVirtObj) &&
504             ((SwDrawVirtObj*)pObj)->GetReferencedObj().ISA(SdrTextObj) ) ) &&
505 
506         !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
507     {
508 		bReturn = BeginTextEdit( pObj, pPV, pEditWin, sal_False );
509     }
510 
511 	pSdrView->SetHitTolerancePixel( nOld );
512 
513 	return bReturn;
514 }
515 
516 /******************************************************************************
517  *	Beschreibung: DrawTextEditMode einschalten
518  ******************************************************************************/
BeginTextEdit(SdrObject * pObj,SdrPageView * pPV,Window * pWin,bool bIsNewObj,bool bSetSelectionToStart)519 sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin,
520         bool bIsNewObj, bool bSetSelectionToStart)
521 {
522 	SwWrtShell *pSh = &GetWrtShell();
523 	SdrView *pSdrView = pSh->GetDrawView();
524 	SdrOutliner* pOutliner = ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrView->GetModel());
525 	uno::Reference< linguistic2::XSpellChecker1 >  xSpell( ::GetSpellChecker() );
526 	if (pOutliner)
527 	{
528         pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess()->getReferenceDevice(false));
529 		pOutliner->SetSpeller(xSpell);
530         uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
531 		pOutliner->SetHyphenator( xHyphenator );
532 		pSh->SetCalcFieldValueHdl(pOutliner);
533 
534 		sal_uInt32 nCntrl = pOutliner->GetControlWord();
535 		nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
536 		nCntrl |= EE_CNTRL_URLSFXEXECUTE;
537 
538 		const SwViewOption *pOpt = pSh->GetViewOptions();
539 
540         if (SwViewOption::IsFieldShadings())
541 			nCntrl |= EE_CNTRL_MARKFIELDS;
542 		else
543 			nCntrl &= ~EE_CNTRL_MARKFIELDS;
544 
545 		if (pOpt->IsOnlineSpell())
546 			nCntrl |= EE_CNTRL_ONLINESPELLING;
547 		else
548 			nCntrl &= ~EE_CNTRL_ONLINESPELLING;
549 
550 		pOutliner->SetControlWord(nCntrl);
551 		const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
552 		pOutliner->SetDefaultLanguage(((const SvxLanguageItem&)rItem).GetLanguage());
553 
554 		if( bIsNewObj )
555 			pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == nDrawSfxId ||
556 									SID_DRAW_CAPTION_VERTICAL == nDrawSfxId );
557 		// #i7672#
558 		// No longer necessary, see text below
559         // Color aBackground(pSh->GetShapeBackgrd());
560         // pOutliner->SetBackgroundColor(aBackground);
561 
562         // OD 09.12.2002 #103045# - set default horizontal text direction at outliner
563         EEHorizontalTextDirection aDefHoriTextDir =
564             pSh->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
565         pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
566     }
567 
568 	// #108784#
569 	// To allow editing the referenced object from a SwDrawVirtObj here
570 	// the original needs to be fetched evenually. This ATM activates the
571 	// text edit mode for the original object.
572 	SdrObject* pToBeActivated = pObj;
573 
574 	// #108784#
575 	// Always the original object is edited. To allow the TextEdit to happen
576 	// where the VirtObj is positioned, on demand a occurring offset is set at
577 	// the TextEdit object. That offset is used for creating and managing the
578 	// OutlinerView.
579 	Point aNewTextEditOffset(0, 0);
580 
581 	if(pObj->ISA(SwDrawVirtObj))
582 	{
583 		SwDrawVirtObj* pVirtObj = (SwDrawVirtObj*)pObj;
584 		pToBeActivated = &((SdrObject&)pVirtObj->GetReferencedObj());
585 		aNewTextEditOffset = pVirtObj->GetOffset();
586 	}
587 
588 	// set in each case, thus it will be correct for all objects
589 	((SdrTextObj*)pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
590 
591     sal_Bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, sal_True, pOutliner, 0, sal_False, sal_False, sal_False ));
592 
593 	// #i7672#
594 	// Since SdrBeginTextEdit actually creates the OutlinerView and thus also
595 	// sets the background color, an own background color needs to be set
596 	// after TextEditing was started. This is now done here.
597 	if(bRet)
598 	{
599 		OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
600 
601 		if(pView)
602 		{
603 			Color aBackground(pSh->GetShapeBackgrd());
604 			pView->SetBackgroundColor(aBackground);
605 		}
606 
607         // editing should start at the end of text, spell checking at the beginning ...
608         ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
609         if (bSetSelectionToStart)
610             aNewSelection = ESelection();
611         pView->SetSelection(aNewSelection);
612 	}
613 
614 	return bRet;
615 }
616 
617 /******************************************************************************
618  *	Beschreibung: Ist ein DrawTextObjekt selektiert?
619  ******************************************************************************/
620 
621 
622 
IsTextTool() const623 sal_Bool SwView::IsTextTool() const
624 {
625 	sal_uInt16 nId;
626 	sal_uInt32 nInvent;
627 	SdrView *pSdrView = GetWrtShell().GetDrawView();
628 	ASSERT( pSdrView, "IsTextTool without DrawView?" );
629 
630 	if (pSdrView->IsCreateMode())
631 		pSdrView->SetCreateMode(sal_False);
632 
633 	pSdrView->TakeCurrentObj(nId,nInvent);
634 	return (nInvent==SdrInventor);
635 }
636 
637 /*--------------------------------------------------------------------
638 	Beschreibung:
639  --------------------------------------------------------------------*/
640 
641 
642 
GetDrawView() const643 SdrView* SwView::GetDrawView() const
644 {
645 	return GetWrtShell().GetDrawView();
646 }
647 
648 /*--------------------------------------------------------------------
649 	Beschreibung:
650  --------------------------------------------------------------------*/
651 
652 
653 
IsBezierEditMode()654 sal_Bool SwView::IsBezierEditMode()
655 {
656 	return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
657 }
658 
659 /*--------------------------------------------------------------------
660 	Beschreibung:
661  --------------------------------------------------------------------*/
662 
IsFormMode() const663 sal_Bool SwView::IsFormMode() const
664 {
665 	if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
666 	{
667         return (GetDrawFuncPtr()->IsInsertForm());
668 	}
669 
670 	return AreOnlyFormsSelected();
671 }
672 
673 /*--------------------------------------------------------------------
674 	Beschreibung:
675  --------------------------------------------------------------------*/
676 
677 
678 
SetDrawFuncPtr(SwDrawBase * pFuncPtr)679 void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
680 {
681 	if (pDrawActual)
682 		delete pDrawActual;
683 	pDrawActual = pFuncPtr;
684 }
685 
686 /*--------------------------------------------------------------------
687 	Beschreibung:
688  --------------------------------------------------------------------*/
689 
SetSelDrawSlot()690 void SwView::SetSelDrawSlot()
691 {
692 	nDrawSfxId = SID_OBJECT_SELECT;
693     sDrawCustom.Erase();
694 }
695 
696 /*--------------------------------------------------------------------
697 	Beschreibung:
698  --------------------------------------------------------------------*/
699 
AreOnlyFormsSelected() const700 sal_Bool SwView::AreOnlyFormsSelected() const
701 {
702 	if ( GetWrtShell().IsFrmSelected() )
703 		return sal_False;
704 
705 	sal_Bool bForm = sal_True;
706 
707 	SdrView* pSdrView = GetWrtShell().GetDrawView();
708 
709 	const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
710 	sal_uInt32 nCount = rMarkList.GetMarkCount();
711 
712 	if (nCount)
713 	{
714 		for (sal_uInt32 i = 0; i < nCount; i++)
715 		{
716 			// Sind ausser Controls noch normale Draw-Objekte selektiert?
717 			SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
718 
719 			if (!HasOnlyObj(pSdrObj, FmFormInventor))
720 			{
721 				bForm = sal_False;
722 				break;
723 			}
724 		}
725 	}
726 	else
727 		bForm = sal_False;
728 
729 	return bForm;
730 }
731 
732 /*--------------------------------------------------------------------
733 	Beschreibung:
734  --------------------------------------------------------------------*/
735 
HasDrwObj(SdrObject * pSdrObj) const736 sal_Bool SwView::HasDrwObj(SdrObject *pSdrObj) const
737 {
738 	sal_Bool bRet = sal_False;
739 
740 	if (pSdrObj->IsGroupObject())
741 	{
742 		SdrObjList*	pList = pSdrObj->GetSubList();
743 		sal_uInt32 nCnt = pList->GetObjCount();
744 
745 		for (sal_uInt32 i = 0; i < nCnt; i++)
746 			if ((bRet = HasDrwObj(pList->GetObj(i))) == sal_True)
747 				break;
748 	}
749 	else if (SdrInventor == pSdrObj->GetObjInventor() || pSdrObj->Is3DObj())
750 		return sal_True;
751 
752 	return bRet;
753 }
754 
755 /*--------------------------------------------------------------------
756 	Beschreibung:
757  --------------------------------------------------------------------*/
758 
HasOnlyObj(SdrObject * pSdrObj,sal_uInt32 eObjInventor) const759 sal_Bool SwView::HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const
760 {
761 	sal_Bool bRet = sal_False;
762 
763 	if (pSdrObj->IsGroupObject())
764 	{
765 		SdrObjList*	pList = pSdrObj->GetSubList();
766 		sal_uInt32 nCnt = pList->GetObjCount();
767 
768 		for (sal_uInt32 i = 0; i < nCnt; i++)
769 			if ((bRet = HasOnlyObj(pList->GetObj(i), eObjInventor)) == sal_False)
770 				break;
771 	}
772 	else if (eObjInventor == pSdrObj->GetObjInventor())
773 		return sal_True;
774 
775 	return bRet;
776 }
777 
778 
779 //#i87414# mod
IMPL_LINK(SwView,OnlineSpellCallback,SpellCallbackInfo *,pInfo)780 IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
781 {
782 	if (pInfo->nCommand == SPELLCMD_STARTSPELLDLG)
783         GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
784 	return 0;
785 }
786 
787 /*--------------------------------------------------------------------
788 	Beschreibung:
789  --------------------------------------------------------------------*/
ExecDrwTxtSpellPopup(const Point & rPt)790 sal_Bool SwView::ExecDrwTxtSpellPopup(const Point& rPt)
791 {
792 	sal_Bool bRet = sal_False;
793 	SdrView *pSdrView = pWrtShell->GetDrawView();
794 	OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
795 	Point aPos( GetEditWin().LogicToPixel( rPt ) );
796 
797 	if (pOLV->IsWrongSpelledWordAtPos( aPos ))
798 	{
799 		bRet = sal_True;
800 		Link aLink = LINK(this, SwView, OnlineSpellCallback);
801 		pOLV->ExecuteSpellPopup( aPos,&aLink );
802 	}
803 	return bRet;
804 }
805 
806 /*--------------------------------------------------------------------
807 	Beschreibung:
808  --------------------------------------------------------------------*/
809 
810 
811 
IsDrawTextHyphenate()812 sal_Bool SwView::IsDrawTextHyphenate()
813 {
814 	SdrView *pSdrView = pWrtShell->GetDrawView();
815 	sal_Bool bHyphenate = sal_False;
816 
817 	SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
818 							EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
819 	if( pSdrView->GetAttributes( aNewAttr ) &&
820 		aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
821 		bHyphenate = ((const SfxBoolItem&)aNewAttr.Get( EE_PARA_HYPHENATE )).
822 						GetValue();
823 
824 	return bHyphenate;
825 }
826 
827 /*--------------------------------------------------------------------
828 	Beschreibung:
829  --------------------------------------------------------------------*/
830 
831 
832 
HyphenateDrawText()833 void SwView::HyphenateDrawText()
834 {
835 	SdrView *pSdrView = pWrtShell->GetDrawView();
836 	sal_Bool bHyphenate = IsDrawTextHyphenate();
837 
838 	SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
839 	aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
840 	pSdrView->SetAttributes( aSet );
841 	GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG);
842 }
843 
844 
845 
846