xref: /trunk/main/sc/source/ui/view/drawview.cxx (revision 512ec161)
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_sc.hxx"
26 
27 // INCLUDE ---------------------------------------------------------------
28 
29 #include <com/sun/star/embed/EmbedStates.hpp>
30 
31 #include <svx/svditer.hxx>
32 #include <svx/svdograf.hxx>
33 #include <svx/svdomedia.hxx>
34 #include <svx/svdogrp.hxx>
35 #include <svx/svdoole2.hxx>
36 #include <svx/svdouno.hxx>
37 #include <svx/svdpage.hxx>
38 #include <svx/svdundo.hxx>
39 #include <svx/svdocapt.hxx>
40 #include <editeng/outlobj.hxx>
41 #include <editeng/writingmodeitem.hxx>
42 #include <svx/sdrpaintwindow.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <svx/sdrundomanager.hxx>
46 
47 #include "drawview.hxx"
48 #include "global.hxx"
49 #include "viewdata.hxx"
50 #include "document.hxx"
51 #include "drawutil.hxx"
52 #include "futext.hxx"
53 #include "globstr.hrc"
54 #include "tabvwsh.hxx"
55 #include "client.hxx"
56 #include "scmod.hxx"
57 #include "drwlayer.hxx"
58 #include "docsh.hxx"
59 #include "viewuno.hxx"
60 #include "userdat.hxx"
61 #include "postit.hxx"
62 #include "undocell.hxx"
63 #include "document.hxx"
64 
65 #include "sc.hrc"
66 
67 using namespace com::sun::star;
68 
69 // -----------------------------------------------------------------------
70 
71 #define SC_HANDLESIZE_BIG		9
72 #define SC_HANDLESIZE_SMALL		7
73 
74 // -----------------------------------------------------------------------
75 
76 #ifdef _MSC_VER
77 #pragma optimize ( "", off )
78 #endif
79 
80 
81 void ScDrawView::Construct()
82 {
83 	EnableExtendedKeyInputDispatcher(sal_False);
84 	EnableExtendedMouseEventDispatcher(sal_False);
85 	EnableExtendedCommandEventDispatcher(sal_False);
86 
87 	SetFrameDragSingles(sal_True);
88 //	SetSolidMarkHdl(sal_True);				// einstellbar -> UpdateUserViewOptions
89 
90 	SetMinMoveDistancePixel( 2 );
91 	SetHitTolerancePixel( 2 );
92 
93 	if (pViewData)
94 	{
95 		SCTAB nViewTab = pViewData->GetTabNo();
96 		ShowSdrPage(GetModel()->GetPage(nViewTab));
97 
98 		sal_Bool bEx = pViewData->GetViewShell()->IsDrawSelMode();
99 		sal_Bool bProt = pDoc->IsTabProtected( nViewTab ) ||
100 					 pViewData->GetSfxDocShell()->IsReadOnly();
101 
102 		SdrLayer* pLayer;
103 		SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin();
104 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
105 		if (pLayer)
106 			SetLayerLocked( pLayer->GetName(), bProt || !bEx );
107 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
108 		if (pLayer)
109 			SetLayerLocked( pLayer->GetName(), sal_True );
110 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
111 		if (pLayer)
112 		{
113 			SetLayerLocked( pLayer->GetName(), bProt );
114 			SetActiveLayer( pLayer->GetName() );		// FRONT als aktiven Layer setzen
115 		}
116 		pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
117 		if (pLayer)
118 			SetLayerLocked( pLayer->GetName(), bProt );
119         pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
120         if (pLayer)
121         {
122             SetLayerLocked( pLayer->GetName(), bProt );
123             SetLayerVisible( pLayer->GetName(), sal_False);
124         }
125 
126 		SetSwapAsynchron(sal_True);
127 	}
128 	else
129 	{
130 		ShowSdrPage(GetModel()->GetPage(nTab));
131 	}
132 
133 	UpdateUserViewOptions();
134 	RecalcScale();
135 	UpdateWorkArea();
136 
137 	bInConstruct = sal_False;
138 }
139 
140 void ScDrawView::ImplClearCalcDropMarker()
141 {
142 	if(pDropMarker)
143 	{
144 		delete pDropMarker;
145 		pDropMarker = 0L;
146 	}
147 }
148 
149 __EXPORT ScDrawView::~ScDrawView()
150 {
151 	ImplClearCalcDropMarker();
152 }
153 
154 void ScDrawView::AddCustomHdl()
155 {
156 	sal_Bool bNegativePage = pDoc->IsNegativePage( nTab );
157 
158 	const SdrMarkList &rMrkList = GetMarkedObjectList();
159 	sal_uInt32 nCount = rMrkList.GetMarkCount();
160 	for(sal_uInt32 nPos=0; nPos<nCount; nPos++ )
161 	{
162 		const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
163 		if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
164 		{
165 			const sal_Int32 nDelta = 1;
166 
167 			Rectangle aBoundRect = pObj->GetCurrentBoundRect();
168 			Point aPos;
169 			if (bNegativePage)
170 			{
171 				aPos = aBoundRect.TopRight();
172 				aPos.X() = -aPos.X();			// so the loop below is the same
173 			}
174 			else
175 				aPos = aBoundRect.TopLeft();
176 			long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta;
177 			long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta;
178 
179 			SCCOL nCol;
180 			sal_Int32 nWidth = 0;
181 
182 			for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++)
183 				nWidth += pDoc->GetColWidth(nCol,nTab);
184 
185 			if(nCol > 0)
186 				--nCol;
187 
188             SCROW nRow = nPosY <= 0 ? 0 : pDoc->GetRowForHeight( nTab,
189                     (sal_uLong) nPosY);
190 			if(nRow > 0)
191 				--nRow;
192 
193 			ScTabView* pView = pViewData->GetView();
194 			ScAddress aScAddress(nCol, nRow, nTab);
195 			pView->CreateAnchorHandles(aHdl, aScAddress);
196 		}
197 	}
198 }
199 
200 void ScDrawView::InvalidateAttribs()
201 {
202 	if (!pViewData) return;
203 	SfxBindings& rBindings = pViewData->GetBindings();
204 
205 		// echte Statuswerte:
206 	rBindings.InvalidateAll( sal_True );
207 }
208 
209 void ScDrawView::InvalidateDrawTextAttrs()
210 {
211 	if (!pViewData) return;
212 	SfxBindings& rBindings = pViewData->GetBindings();
213 
214 	//	cjk/ctl font items have no configured slots,
215 	//	need no invalidate
216 
217 	rBindings.Invalidate( SID_ATTR_CHAR_FONT );
218 	rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
219 	rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
220 	rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
221 	rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
222 	rBindings.Invalidate( SID_ULINE_VAL_NONE );
223 	rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
224 	rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
225 	rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
226 	rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
227 	rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
228 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
229 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
230 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
231 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
232 	rBindings.Invalidate( SID_ALIGNLEFT );
233 	rBindings.Invalidate( SID_ALIGNCENTERHOR );
234 	rBindings.Invalidate( SID_ALIGNRIGHT );
235 	rBindings.Invalidate( SID_ALIGNBLOCK );
236 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
237 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
238 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
239 	rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
240 	rBindings.Invalidate( SID_SET_SUB_SCRIPT );
241 	rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
242 	rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
243 	rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
244 	rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
245 	rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
246 	rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
247 	rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
248     // pseudo slots for Format menu
249     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
250     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
251     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
252     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
253 }
254 
255 //void ScDrawView::DrawMarks( OutputDevice* pOut ) const
256 //{
257 //	DBG_ASSERT(pOut, "ScDrawView::DrawMarks: No OutputDevice (!)");
258 //	SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
259 //
260 //	if(pPaintWindow)
261 //	{
262 //		if(pPaintWindow->isXorVisible())
263 //		{
264 //			ToggleShownXor(pOut, 0L);
265 //		}
266 //	}
267 //}
268 
269 void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo )
270 {
271 	if (AreObjectsMarked())
272 	{
273 		//	#i11702# use SdrUndoObjectLayerChange for undo
274 		//	STR_UNDO_SELATTR is "Attributes" - should use a different text later
275 		BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) );
276 
277 		const SdrMarkList& rMark = GetMarkedObjectList();
278 		sal_uLong nCount = rMark.GetMarkCount();
279 		for (sal_uLong i=0; i<nCount; i++)
280 		{
281 			SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
282 			if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) )
283 			{
284 				AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
285 				pObj->SetLayer( nLayerNo );
286 			}
287 		}
288 
289 		EndUndo();
290 
291 		//	repaint is done in SetLayer
292 
293 		pViewData->GetDocShell()->SetDrawModified();
294 
295 		//	#84073# check mark list now instead of later in a timer
296 		CheckMarked();
297 		MarkListHasChanged();
298 	}
299 }
300 
301 bool ScDrawView::HasMarkedControl() const
302 {
303     SdrObjListIter aIter( GetMarkedObjectList() );
304     for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
305         if( pObj->ISA( SdrUnoObj ) )
306             return true;
307 	return false;
308 }
309 
310 bool ScDrawView::HasMarkedInternal() const
311 {
312     // internal objects should not be inside a group, but who knows...
313     SdrObjListIter aIter( GetMarkedObjectList() );
314     for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
315         if( pObj->GetLayer() == SC_LAYER_INTERN )
316             return true;
317 	return false;
318 }
319 
320 void ScDrawView::UpdateWorkArea()
321 {
322 	SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
323 	if (pPage)
324 	{
325 		Point aPos;
326 		Size aPageSize( pPage->GetSize() );
327 		Rectangle aNewArea( aPos, aPageSize );
328 		if ( aPageSize.Width() < 0 )
329 		{
330 			//	RTL: from max.negative (left) to zero (right)
331 			aNewArea.Right() = 0;
332 			aNewArea.Left() = aPageSize.Width() + 1;
333 		}
334 		SetWorkArea( aNewArea );
335 	}
336 	else
337 	{
338 		DBG_ERROR("Page nicht gefunden");
339 	}
340 }
341 
342 void ScDrawView::DoCut()
343 {
344 	DoCopy();
345 	BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) );
346 	DeleteMarked();		// auf dieser View - von der 505f Umstellung nicht betroffen
347 	EndUndo();
348 }
349 
350 void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const
351 {
352 	rFractX = aScaleX;
353 	rFractY = aScaleY;
354 }
355 
356 void ScDrawView::RecalcScale()
357 {
358 	double nPPTX;
359 	double nPPTY;
360 	Fraction aZoomX(1,1);
361 	Fraction aZoomY(1,1);
362 
363 	if (pViewData)
364 	{
365 		nTab = pViewData->GetTabNo();
366 		nPPTX = pViewData->GetPPTX();
367 		nPPTY = pViewData->GetPPTY();
368 		aZoomX = pViewData->GetZoomX();
369 		aZoomY = pViewData->GetZoomY();
370 	}
371 	else
372 	{
373 		Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
374 		nPPTX = aLogic.X() / 1000.0;
375 		nPPTY = aLogic.Y() / 1000.0;
376 											//! Zoom uebergeben ???
377 	}
378 
379 	SCCOL nEndCol = 0;
380 	SCROW nEndRow = 0;
381 	pDoc->GetTableArea( nTab, nEndCol, nEndRow );
382 	if (nEndCol<20)
383 		nEndCol = 20;
384 	if (nEndRow<20)
385         nEndRow = 20;   // #i116848# instead of a large row number for an empty sheet, heights are multiplied in CalcScale
386 
387 	ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY,
388 							aScaleX,aScaleY );
389 }
390 
391 void ScDrawView::DoConnect(SdrOle2Obj* pOleObj)
392 {
393     if ( pViewData )
394         pViewData->GetViewShell()->ConnectObject( pOleObj );
395 }
396 
397 void ScDrawView::MarkListHasChanged()
398 {
399 	FmFormView::MarkListHasChanged();
400 
401 	UpdateBrowser();
402 
403 	ScTabViewShell* pViewSh = pViewData->GetViewShell();
404 
405     // #i110829# remove the cell selection only if drawing objects are selected
406     if ( !bInConstruct && GetMarkedObjectList().GetMarkCount() )
407 	{
408         pViewSh->Unmark();      // remove cell selection
409 
410 		//	#65379# end cell edit mode if drawing objects are selected
411         SC_MOD()->InputEnterHandler();
412 	}
413 
414 	//	IP deaktivieren
415 
416     ScModule* pScMod = SC_MOD();
417     bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
418 
419 	ScClient* pClient = (ScClient*) pViewSh->GetIPClient();
420     if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
421 	{
422 		//	#41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen
423 		//HMHbDisableHdl = sal_True;
424         pClient->DeactivateObject();
425 		//HMHbDisableHdl = sal_False;
426 		//	Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate
427 	}
428 
429 	//	Ole-Objekt selektiert?
430 
431 	SdrOle2Obj* pOle2Obj = NULL;
432 	SdrGrafObj* pGrafObj = NULL;
433 	SdrMediaObj* pMediaObj = NULL;
434 
435 	const SdrMarkList& rMarkList = GetMarkedObjectList();
436 	sal_uLong nMarkCount = rMarkList.GetMarkCount();
437 
438 	if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct )
439 	{
440 		//	relock layers that may have been unlocked before
441         LockBackgroundLayer();
442         LockInternalLayer();
443 	}
444 
445 	sal_Bool bSubShellSet = sal_False;
446 	if (nMarkCount == 1)
447 	{
448 		SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
449 		if (pObj->GetObjIdentifier() == OBJ_OLE2)
450 		{
451 			pOle2Obj = (SdrOle2Obj*) pObj;
452 			if (!pDoc->IsChart(pObj) )
453 				pViewSh->SetOleObjectShell(sal_True);
454 			else
455 				pViewSh->SetChartShell(sal_True);
456 			bSubShellSet = sal_True;
457 		}
458 		else if (pObj->GetObjIdentifier() == OBJ_GRAF)
459 		{
460 			pGrafObj = (SdrGrafObj*) pObj;
461 			pViewSh->SetGraphicShell(sal_True);
462 			bSubShellSet = sal_True;
463 		}
464 		else if (pObj->GetObjIdentifier() == OBJ_MEDIA)
465 		{
466 			pMediaObj = (SdrMediaObj*) pObj;
467 			pViewSh->SetMediaShell(sal_True);
468 			bSubShellSet = sal_True;
469 		}
470 		else if (pObj->GetObjIdentifier() != OBJ_TEXT   // Verhindern, das beim Anlegen
471 					|| !pViewSh->IsDrawTextShell())		// eines TextObjekts auf die
472 		{												// DrawShell umgeschaltet wird.
473 			pViewSh->SetDrawShell(sal_True);				//@#70206#
474 		}
475 	}
476 
477 	if ( nMarkCount && !bSubShellSet )
478 	{
479 		sal_Bool bOnlyControls = sal_True;
480 		sal_Bool bOnlyGraf     = sal_True;
481 		for (sal_uLong i=0; i<nMarkCount; i++)
482 		{
483 			SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
484 			if ( pObj->ISA( SdrObjGroup ) )
485 			{
486 				const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
487 				sal_uLong nListCount = pLst->GetObjCount();
488 				if ( nListCount == 0 )
489 				{
490 					//	#104156# An empty group (may occur during Undo) is no control or graphics object.
491 					//	Creating the form shell during undo would lead to problems with the undo manager.
492 					bOnlyControls = sal_False;
493 					bOnlyGraf = sal_False;
494 				}
495 				for ( sal_uInt16 j = 0; j < nListCount; ++j )
496 				{
497 					SdrObject *pSubObj = pLst->GetObj( j );
498 
499 					if (!pSubObj->ISA(SdrUnoObj))
500 						bOnlyControls = sal_False;
501 					if (pSubObj->GetObjIdentifier() != OBJ_GRAF)
502 						bOnlyGraf = sal_False;
503 
504 					if ( !bOnlyControls && !bOnlyGraf ) break;
505 				}
506 			}
507 			else
508 			{
509 				if (!pObj->ISA(SdrUnoObj))
510 					bOnlyControls = sal_False;
511 				if (pObj->GetObjIdentifier() != OBJ_GRAF)
512 					bOnlyGraf = sal_False;
513 			}
514 
515 			if ( !bOnlyControls && !bOnlyGraf ) break;
516 		}
517 
518 		if(bOnlyControls)
519 		{
520 			pViewSh->SetDrawFormShell(sal_True);			// jetzt UNO-Controls
521 		}
522 		else if(bOnlyGraf)
523 		{
524 			pViewSh->SetGraphicShell(sal_True);
525 		}
526 		else if(nMarkCount>1)
527 		{
528 			pViewSh->SetDrawShell(sal_True);
529 		}
530 	}
531 
532 
533 
534 	//	Verben anpassen
535 
536 	SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
537     sal_Bool bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace();
538     uno::Sequence< embed::VerbDescriptor > aVerbs;
539 	if ( pOle2Obj && !bOle )
540 	{
541         uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
542 		DBG_ASSERT( xObj.is(), "SdrOle2Obj ohne ObjRef" );
543         if (xObj.is())
544             aVerbs = xObj->getSupportedVerbs();
545 	}
546 	pViewSh->SetVerbs( aVerbs );
547 
548 	//	Image-Map Editor
549 
550 	if ( pOle2Obj )
551 		UpdateIMap( pOle2Obj );
552 	else if ( pGrafObj )
553 		UpdateIMap( pGrafObj );
554 
555 	InvalidateAttribs();				// nach dem IMap-Editor Update
556 	InvalidateDrawTextAttrs();
557 
558 	for(sal_uInt32 a(0L); a < PaintWindowCount(); a++)
559 	{
560 		SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
561 		OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
562 
563 		if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
564 		{
565 			((Window&)rOutDev).Update();
566 		}
567 	}
568 
569 	//	uno object for view returns drawing objects as selection,
570 	//	so it must notify its SelectionChangeListeners
571 
572 	if (pViewFrame)
573 	{
574 		SfxFrame& rFrame = pViewFrame->GetFrame();
575 		uno::Reference<frame::XController> xController = rFrame.GetController();
576 		if (xController.is())
577 		{
578 			ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
579 			if (pImp)
580 				pImp->SelectionChanged();
581 		}
582 	}
583 
584 	//	update selection transfer object
585 
586 	pViewSh->CheckSelectionTransfer();
587 
588 }
589 
590 void __EXPORT ScDrawView::ModelHasChanged()
591 {
592 	SdrObject* pEditObj = GetTextEditObject();
593 	if ( pEditObj && !pEditObj->IsInserted() && pViewData )
594 	{
595 		//	#111700# SdrObjEditView::ModelHasChanged will end text edit in this case,
596 		//	so make sure the EditEngine's undo manager is no longer used.
597 		pViewData->GetViewShell()->SetDrawTextUndo(NULL);
598 		SetCreateMode();	// don't leave FuText in a funny state
599 	}
600 
601 	FmFormView::ModelHasChanged();
602 }
603 
604 void __EXPORT ScDrawView::UpdateUserViewOptions()
605 {
606 	if (pViewData)
607 	{
608 		const ScViewOptions&	rOpt = pViewData->GetOptions();
609 		const ScGridOptions&	rGrid = rOpt.GetGridOptions();
610 
611 		sal_Bool bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES );
612 
613 		SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) );
614 		SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) );
615 		SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL );
616 
617 		SetGridVisible( rGrid.GetGridVisible() );
618 		SetSnapEnabled( rGrid.GetUseGridSnap() );
619 		SetGridSnap( rGrid.GetUseGridSnap() );
620 
621 		//	Snap from grid options is no longer used
622 //		SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) );
623 
624 		Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 );
625 		Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 );
626 		SetSnapGridWidth( aFractX, aFractY );
627 
628 		SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) );
629 		SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1),
630 						   rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) );
631 	}
632 }
633 
634 #ifdef _MSC_VER
635 #pragma optimize ( "", on )
636 #endif
637 
638 sal_Bool ScDrawView::SelectObject( const String& rName )
639 {
640 	UnmarkAll();
641 
642 	SCTAB nObjectTab = 0;
643 	SdrObject* pFound = NULL;
644 
645 	SfxObjectShell*	pShell = pDoc->GetDocumentShell();
646 	if (pShell)
647 	{
648 		SdrModel* pDrawLayer = GetModel();
649 		SCTAB nTabCount = pDoc->GetTableCount();
650 		for (SCTAB i=0; i<nTabCount && !pFound; i++)
651 		{
652 			SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
653 			DBG_ASSERT(pPage,"Page ?");
654 			if (pPage)
655 			{
656 				SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
657 				SdrObject* pObject = aIter.Next();
658 				while (pObject && !pFound)
659 				{
660 					if ( ScDrawLayer::GetVisibleName( pObject ) == rName )
661 					{
662 						pFound = pObject;
663 						nObjectTab = i;
664 					}
665 					pObject = aIter.Next();
666 				}
667 			}
668 		}
669 	}
670 
671 	if ( pFound )
672 	{
673 		ScTabView* pView = pViewData->GetView();
674 		if ( nObjectTab != nTab )								// Tabelle umschalten
675 			pView->SetTabNo( nObjectTab );
676 
677 		DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" );
678 
679 		pView->ScrollToObject( pFound );
680 
681         /*  #61585# To select an object on the background layer, the layer has to
682             be unlocked even if exclusive drawing selection mode is not active
683             (this is reversed in MarkListHasChanged when nothing is selected) */
684 		if ( pFound->GetLayer() == SC_LAYER_BACK &&
685 				!pViewData->GetViewShell()->IsDrawSelMode() &&
686 				!pDoc->IsTabProtected( nTab ) &&
687 				!pViewData->GetSfxDocShell()->IsReadOnly() )
688 		{
689             UnlockBackgroundLayer();
690 		}
691 
692 		SdrPageView* pPV = GetSdrPageView();
693 		MarkObj( pFound, pPV );
694 	}
695 
696 	return ( pFound != NULL );
697 }
698 
699 //UNUSED2008-05  String ScDrawView::GetSelectedChartName() const
700 //UNUSED2008-05  {
701 //UNUSED2008-05      //  used for modifying a chart's data area - PersistName must always be used
702 //UNUSED2008-05      //  (as in ScDocument::FindChartData and UpdateChartArea)
703 //UNUSED2008-05
704 //UNUSED2008-05      const SdrMarkList& rMarkList = GetMarkedObjectList();
705 //UNUSED2008-05      if (rMarkList.GetMarkCount() == 1)
706 //UNUSED2008-05      {
707 //UNUSED2008-05          SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
708 //UNUSED2008-05          if (pObj->GetObjIdentifier() == OBJ_OLE2)
709 //UNUSED2008-05              if ( pDoc->IsChart(pObj) )
710 //UNUSED2008-05                  return static_cast<SdrOle2Obj*>(pObj)->GetPersistName();
711 //UNUSED2008-05      }
712 //UNUSED2008-05
713 //UNUSED2008-05      return EMPTY_STRING;        // nichts gefunden
714 //UNUSED2008-05  }
715 
716 FASTBOOL ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, sal_uLong nOptions)
717 {
718 	//	Markierung nicht aendern, wenn Ole-Objekt aktiv
719 	//	(bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
720 
721 	if (pViewData)
722 	{
723 		SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
724         if ( pClient && pClient->IsObjectInPlaceActive() )
725 			nOptions |= SDRINSERT_DONTMARK;
726 	}
727 
728 	return InsertObjectAtView( pObj, rPV, nOptions );
729 }
730 
731 SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData )
732 {
733     const SdrMarkList& rMarkList = GetMarkedObjectList();
734     if( pViewData && (rMarkList.GetMarkCount() == 1) )
735     {
736         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
737         if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) )
738         {
739             if( ppCaptData ) *ppCaptData = pCaptData;
740             return pObj;
741         }
742     }
743     return 0;
744 }
745 
746 void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock )
747 {
748     SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer );
749     if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) )
750         SetLayerLocked( pLockLayer->GetName(), bLock );
751 }
752 
753 void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin )
754 {
755 	//!	rWin richtig auswerten
756 	//!	ggf Zoom aendern
757 
758 	if ( pViewData && pViewData->GetActiveWin() == &rWin )
759 		pViewData->GetView()->MakeVisible( rRect );
760 }
761 
762 void ScDrawView::DeleteMarked()
763 {
764     // try to delete a note caption object with its cell note in the Calc document
765     ScDrawObjData* pCaptData = 0;
766     if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
767     {
768         (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds
769         ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
770         ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0;
771         ::svl::IUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0;
772         bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
773 
774         // remove the cell note from document, we are its owner now
775         ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
776         DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
777         if( pNote )
778         {
779             // rescue note data for undo (with pointer to caption object)
780             ScNoteData aNoteData = pNote->GetNoteData();
781             DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
782             // collect the drawing undo action created while deleting the note
783             if( bUndo )
784                 pDrawLayer->BeginCalcUndo();
785             // delete the note (already removed from document above)
786             delete pNote;
787             // add the undo action for the note
788             if( bUndo )
789                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
790             // repaint the cell to get rid of the note marker
791             if( pDocShell )
792                 pDocShell->PostPaintCell( pCaptData->maStart );
793             // done, return now to skip call of FmFormView::DeleteMarked()
794             return;
795         }
796     }
797 
798     FmFormView::DeleteMarked();
799 }
800 
801 SdrEndTextEditKind ScDrawView::ScEndTextEdit()
802 {
803 	sal_Bool bIsTextEdit = IsTextEdit();
804 	SdrEndTextEditKind eKind = SdrEndTextEdit();
805 
806 	if ( bIsTextEdit && pViewData )
807 		pViewData->GetViewShell()->SetDrawTextUndo(NULL);	// "normaler" Undo-Manager
808 
809 	return eKind;
810 }
811 
812 void ScDrawView::MarkDropObj( SdrObject* pObj )
813 {
814 	if ( pDropMarkObj != pObj )
815 	{
816 		pDropMarkObj = pObj;
817 		ImplClearCalcDropMarker();
818 
819 		if(pDropMarkObj)
820 		{
821 			pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj);
822 		}
823 	}
824 }
825 
826 // support enhanced text edit for draw objects
827 SdrUndoManager* ScDrawView::getSdrUndoManagerForEnhancedTextEdit() const
828 {
829     return pDoc ? dynamic_cast< SdrUndoManager* >(pDoc->GetUndoManager()) : 0;
830 }
831 
832 // eof
833