xref: /AOO41X/main/sd/source/ui/view/sdview.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
31 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
32 
33 #include "View.hxx"
34 #include <editeng/unolingu.hxx>
35 #include <sfx2/request.hxx>
36 #include <svx/obj3d.hxx>
37 #include <svx/fmview.hxx>
38 #include <editeng/outliner.hxx>
39 #ifndef _SVX_SVXIDS_HRC
40 #include <svx/svxids.hrc>
41 #endif
42 #include <svx/svdograf.hxx>
43 #include <svx/svdoole2.hxx>
44 #include <svx/svdundo.hxx>
45 #include <vcl/msgbox.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/app.hxx>
48 #include <svx/svdpagv.hxx>
49 #include <sfx2/docfile.hxx>
50 #include <svx/svdoutl.hxx>
51 #include <svx/sdr/contact/displayinfo.hxx>
52 
53 #include <svx/svdetc.hxx>
54 #include <editeng/editstat.hxx>
55 
56 #include <svx/dialogs.hrc>
57 #include <sfx2/viewfrm.hxx>
58 #include <svx/svdopage.hxx>
59 #include <toolkit/helper/vclunohelper.hxx>
60 #include <svx/xlndsit.hxx>
61 #include <svx/xlineit0.hxx>
62 #include <svx/xlnclit.hxx>
63 #include <vcl/virdev.hxx>
64 
65 #include "app.hrc"
66 #include "strings.hrc"
67 #include "Window.hxx"
68 #include "Client.hxx"
69 #include "drawdoc.hxx"
70 #include "DrawDocShell.hxx"
71 #include "app.hxx"
72 #include "sdpage.hxx"
73 #include "glob.hrc"
74 #include "sdresid.hxx"
75 #include "DrawViewShell.hxx"
76 #include "futext.hxx"
77 #include "fuinsfil.hxx"
78 #include "slideshow.hxx"
79 #include "stlpool.hxx"
80 #include "FrameView.hxx"
81 #include "ViewClipboard.hxx"
82 #include "undo/undomanager.hxx"
83 #include <svx/sdr/contact/viewobjectcontact.hxx>
84 #include <svx/sdr/contact/viewcontact.hxx>
85 #include <svx/sdr/contact/displayinfo.hxx>
86 #include "EventMultiplexer.hxx"
87 #include "ViewShellBase.hxx"
88 #include "ViewShellManager.hxx"
89 
90 #include <basegfx/polygon/b2dpolygontools.hxx>
91 #include <basegfx/color/bcolor.hxx>
92 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
93 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
94 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
95 #include <svx/sdr/contact/objectcontact.hxx>
96 #include <basegfx/matrix/b2dhommatrix.hxx>
97 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
98 #include <svx/unoapi.hxx>
99 #include <basegfx/matrix/b2dhommatrixtools.hxx>
100 
101 #include <numeric>
102 
103 using namespace com::sun::star;
104 using namespace com::sun::star::uno;
105 namespace sd {
106 
107 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
108 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
109 SO2_DECL_REF(SvInPlaceObject)
110 #endif
111 
112 TYPEINIT1(View, FmFormView);
113 
114 /*************************************************************************
115 |*
116 |* Ctor
117 |*
118 \************************************************************************/
119 
120 View::View(SdDrawDocument* pDrawDoc, OutputDevice* pOutDev,
121 			   ViewShell* pViewShell)
122   : FmFormView(pDrawDoc, pOutDev),
123 	mpDoc(pDrawDoc),
124 	mpDocSh( pDrawDoc->GetDocSh() ),
125 	mpViewSh(pViewShell),
126 	mpDragSrcMarkList(NULL),
127 	mpDropMarkerObj(NULL),
128 	mpDropMarker(NULL),
129 	mnDragSrcPgNum(SDRPAGE_NOTFOUND),
130 	mnAction(DND_ACTION_NONE),
131 	mnLockRedrawSmph(0),
132 	mpLockedRedraws(NULL),
133 	mbIsDropAllowed(sal_True),
134 	maSmartTags(*this),
135     mpClipboard (new ViewClipboard (*this))
136 {
137 	// #i73602# Use default from the configuration
138 	SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_DrawImpress());
139 
140 	// #i74769#, #i75172# Use default from the configuration
141 	SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_DrawImpress());
142 
143 	EnableExtendedKeyInputDispatcher(sal_False);
144 	EnableExtendedMouseEventDispatcher(sal_False);
145 	EnableExtendedCommandEventDispatcher(sal_False);
146 
147 	SetUseIncompatiblePathCreateInterface(sal_False);
148 	SetMarkHdlWhenTextEdit(sal_True);
149 	EnableTextEditOnObjectsWithoutTextIfTextTool(sal_True);
150 
151 	SetMinMoveDistancePixel(2);
152 	SetHitTolerancePixel(2);
153 	SetMeasureLayer(String(SdResId(STR_LAYER_MEASURELINES)));
154 
155 	// Timer fuer verzoegertes Drop (muss fuer MAC sein)
156 	maDropErrorTimer.SetTimeoutHdl( LINK(this, View, DropErrorHdl) );
157 	maDropErrorTimer.SetTimeout(50);
158 	maDropInsertFileTimer.SetTimeoutHdl( LINK(this, View, DropInsertFileHdl) );
159 	maDropInsertFileTimer.SetTimeout(50);
160 }
161 
162 void View::ImplClearDrawDropMarker()
163 {
164 	if(mpDropMarker)
165 	{
166 		delete mpDropMarker;
167 		mpDropMarker = 0L;
168 	}
169 }
170 
171 /*************************************************************************
172 |*
173 |* Dtor
174 |*
175 \************************************************************************/
176 
177 View::~View()
178 {
179 	maSmartTags.Dispose();
180 
181 	// release content of selection clipboard, if we own the content
182     UpdateSelectionClipboard( sal_True );
183 
184 	maDropErrorTimer.Stop();
185 	maDropInsertFileTimer.Stop();
186 
187 	ImplClearDrawDropMarker();
188 
189 	while(PaintWindowCount())
190 	{
191 		// Alle angemeldeten OutDevs entfernen
192 		DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/);
193 	}
194 
195 	// gespeicherte Redraws loeschen
196 	if (mpLockedRedraws)
197 	{
198 		SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
199 		while (pRec)
200 		{
201 			delete pRec;
202 			pRec = (SdViewRedrawRec*)mpLockedRedraws->Next();
203 		}
204 		delete mpLockedRedraws;
205 	}
206 }
207 
208 
209 class ViewRedirector : public ::sdr::contact::ViewObjectContactRedirector
210 {
211 public:
212 	ViewRedirector();
213 	virtual ~ViewRedirector();
214 
215 	// all default implementations just call the same methods at the original. To do something
216 	// different, overload the method and at least do what the method does.
217 	virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
218 		const sdr::contact::ViewObjectContact& rOriginal,
219 		const sdr::contact::DisplayInfo& rDisplayInfo);
220 };
221 
222 ViewRedirector::ViewRedirector()
223 {
224 }
225 
226 ViewRedirector::~ViewRedirector()
227 {
228 }
229 
230 drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedPrimitive2DSequence(
231 	const sdr::contact::ViewObjectContact& rOriginal,
232 	const sdr::contact::DisplayInfo& rDisplayInfo)
233 {
234 	SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
235 	drawinglayer::primitive2d::Primitive2DSequence xRetval;
236 
237 	if(pObject && pObject->GetPage())
238 	{
239 		const bool bDoCreateGeometry(pObject->GetPage()->checkVisibility( rOriginal, rDisplayInfo, true ));
240 
241 		if(!bDoCreateGeometry && !(( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE )) )
242 			return xRetval;
243 
244 		PresObjKind eKind(PRESOBJ_NONE);
245 		const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
246 		const bool bIsMasterPageObject(pObject->GetPage()->IsMasterPage());
247 		const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter());
248 		const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
249         const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
250 		const SdPage* pObjectsSdPage = dynamic_cast< SdPage* >(pObject->GetPage());
251 		const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
252 
253 		// check if we need to draw a placeholder border. Never do it for
254 		// objects inside a SdrPageObj and never when printing
255 		if(!bIsInsidePageObj && !bIsPrinting)
256 		{
257 			bool bCreateOutline(false);
258 
259 			if( pObject->IsEmptyPresObj() && pObject->ISA(SdrTextObj) )
260 			{
261 				if( !bSubContentProcessing || !pObject->IsNotVisibleAsMaster() )
262 				{
263 					eKind = pObjectsSdPage ? pObjectsSdPage->GetPresObjKind(pObject) : PRESOBJ_NONE;
264 					bCreateOutline = true;
265 				}
266 			}
267 			else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_TEXT ) )
268 			{
269 				if( pObjectsSdPage )
270 				{
271 					eKind = pObjectsSdPage->GetPresObjKind(pObject);
272 
273 					if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
274 					{
275 						if( !bSubContentProcessing )
276 						{
277 							// only draw a boundary for header&footer objects on the masterpage itself
278 							bCreateOutline = true;
279 						}
280 					}
281 				}
282 			}
283 			else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE ) )
284 			{
285 				// only for handout page, else this frame will be created for each
286 				// page preview object in SlideSorter and PagePane
287 				if(pObjectsSdPage && PK_HANDOUT == pObjectsSdPage->GetPageKind())
288 				{
289 					bCreateOutline = true;
290 				}
291 			}
292 
293 			if(bCreateOutline)
294 			{
295 				// empty presentation objects get a gray frame
296 				const svtools::ColorConfig aColorConfig;
297 				const svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
298 
299 				if( aColor.bIsVisible )
300 				{
301 					// get basic object transformation
302 					const basegfx::BColor aRGBColor(Color(aColor.nColor).getBColor());
303 					basegfx::B2DHomMatrix aObjectMatrix;
304 					basegfx::B2DPolyPolygon aObjectPolyPolygon;
305 					pObject->TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
306 
307 					// create dashed border
308 					{
309 						// create object polygon
310 						basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
311 						aPolygon.transform(aObjectMatrix);
312 
313 						// create line and stroke attribute
314 						::std::vector< double > aDotDashArray;
315 
316 						aDotDashArray.push_back(160.0);
317 						aDotDashArray.push_back(80.0);
318 
319 						const double fFullDotDashLen(::std::accumulate(aDotDashArray.begin(), aDotDashArray.end(), 0.0));
320 						const drawinglayer::attribute::LineAttribute aLine(aRGBColor);
321 						const drawinglayer::attribute::StrokeAttribute aStroke(aDotDashArray, fFullDotDashLen);
322 
323 						// create primitive and add
324 						const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
325 							aPolygon,
326 							aLine,
327 							aStroke));
328 						drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
329 					}
330 
331 					// now paint the placeholder description, but only when masterpage
332 					// is displayed as page directly (MasterPage view)
333 					if(!bSubContentProcessing && bIsMasterPageObject)
334 					{
335 						String aObjectString;
336 
337 						switch( eKind )
338 						{
339 							case PRESOBJ_TITLE:
340 							{
341 								if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
342 								{
343 									static String aTitleAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_TITLE ) );
344 									aObjectString = aTitleAreaStr;
345 								}
346 
347 								break;
348 							}
349 							case PRESOBJ_OUTLINE:
350 							{
351 								static String aOutlineAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_OUTLINE ) );
352 								aObjectString = aOutlineAreaStr;
353 								break;
354 							}
355 							case PRESOBJ_FOOTER:
356 							{
357 								static String aFooterAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_FOOTER ) );
358 								aObjectString = aFooterAreaStr;
359 								break;
360 							}
361 							case PRESOBJ_HEADER:
362 							{
363 								static String aHeaderAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_HEADER ) );
364 								aObjectString = aHeaderAreaStr;
365 								break;
366 							}
367 							case PRESOBJ_DATETIME:
368 							{
369 								static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_DATETIME ) );
370 								aObjectString = aDateTimeStr;
371 								break;
372 							}
373 							case PRESOBJ_NOTES:
374 							{
375 								static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NOTES ) );
376 								aObjectString = aDateTimeStr;
377 								break;
378 							}
379 							case PRESOBJ_SLIDENUMBER:
380 							{
381 								if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
382 								{
383 									static String aSlideAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_SLIDE ) );
384 									aObjectString = aSlideAreaStr;
385 								}
386 								else
387 								{
388 									static String aNumberAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NUMBER ) );
389 									aObjectString = aNumberAreaStr;
390 								}
391 								break;
392 							}
393 							default:
394 							{
395 								break;
396 							}
397 						}
398 
399 						if( aObjectString.Len() )
400 						{
401 							// decompose object matrix to be able to place text correctly
402 							basegfx::B2DTuple aScale;
403 							basegfx::B2DTuple aTranslate;
404 							double fRotate, fShearX;
405 							aObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
406 
407 							// create font
408 							SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObject );
409 							const SdrTextVertAdjust eTVA(pTextObj ? pTextObj->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_CENTER);
410 							Font aScaledVclFont;
411 
412 							// use a text size factor to get more reliable text sizes from the text layouter
413 							// (and from vcl), tipp from HDU
414 							static sal_uInt32 nTextSizeFactor(100);
415 
416 							// use a factor to get more linear text size calculations
417 							aScaledVclFont.SetHeight( 500 * nTextSizeFactor );
418 
419 							// get basic geometry and get text size
420 							drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
421 							aTextLayouter.setFont(aScaledVclFont);
422 							const xub_StrLen nTextLength(aObjectString.Len());
423 
424 							// do not forget to use the factor again to get the width for the 500
425 							const double fTextWidth(aTextLayouter.getTextWidth(aObjectString, 0, nTextLength) * (1.0 / nTextSizeFactor));
426 							const double fTextHeight(aTextLayouter.getTextHeight() * (1.0 / nTextSizeFactor));
427 
428 							// calculate text primitive position. If text is at bottom, use top for
429 							// the extra text and vice versa
430 							const double fHorDist(125);
431 							const double fVerDist(125);
432 							const double fPosX((aTranslate.getX() + aScale.getX()) - fTextWidth - fHorDist);
433 							const double fPosY((SDRTEXTVERTADJUST_BOTTOM == eTVA)
434 								? aTranslate.getY() - fVerDist + fTextHeight
435 								: (aTranslate.getY() + aScale.getY()) - fVerDist);
436 
437 							// get font attributes; use normally scaled font
438 							const basegfx::BColor aFontColor(aRGBColor);
439 							Font aVclFont;
440 							basegfx::B2DVector aTextSizeAttribute;
441 
442 							aVclFont.SetHeight( 500 );
443 
444 							const drawinglayer::attribute::FontAttribute aFontAttribute(
445                                 drawinglayer::primitive2d::getFontAttributeFromVclFont(
446 								    aTextSizeAttribute,
447 								    aVclFont,
448 								    false,
449 								    false));
450 
451 							// fill text matrix
452 							const basegfx::B2DHomMatrix aTextMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
453 								aTextSizeAttribute.getX(), aTextSizeAttribute.getY(),
454 								fShearX,
455                                 fRotate,
456                                 fPosX, fPosY));
457 
458 							// create DXTextArray (can be empty one)
459 							const ::std::vector< double > aDXArray;
460 
461 							// create locale; this may need some more information in the future
462 							const ::com::sun::star::lang::Locale aLocale;
463 
464 							// create primitive and add
465 							const drawinglayer::primitive2d::Primitive2DReference xRef(
466                                 new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
467 								    aTextMatrix,
468 								    aObjectString,
469 								    0,
470 								    nTextLength,
471 								    aDXArray,
472 								    aFontAttribute,
473 								    aLocale,
474 								    aFontColor));
475 							drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
476 						}
477 					}
478 				}
479 			}
480 		}
481 
482 		if(bDoCreateGeometry)
483 		{
484 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
485 				xRetval,
486 				sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
487 					rOriginal,
488 					rDisplayInfo));
489 		}
490 	}
491 	else
492 	{
493 		// not a SdrObject visualisation (maybe e.g. page) or no page
494 		xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
495 	}
496 
497 	return xRetval;
498 }
499 
500 /*************************************************************************
501 |*
502 |* Paint-Methode: das Ereignis wird an die View weitergeleitet
503 |*
504 \************************************************************************/
505 
506 void View::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0L*/)
507 {
508 	// ausfuehren ??
509 	if (mnLockRedrawSmph == 0)
510 	{
511 		SdrPageView* pPgView = GetSdrPageView();
512 
513 		if (pPgView)
514 		{
515 			SdPage* pPage = (SdPage*) pPgView->GetPage();
516 			if( pPage )
517 			{
518 				SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
519                 bool bScreenDisplay(true);
520 
521                 if(bScreenDisplay && pOutDev && OUTDEV_PRINTER == pOutDev->GetOutDevType())
522                 {
523                     // #i75566# printing; suppress AutoColor BackgroundColor generation
524                     // for visibility reasons by giving GetPageBackgroundColor()
525                     // the needed hint
526                     bScreenDisplay = false;
527                 }
528 
529                 if(bScreenDisplay && pOutDev && pOutDev->GetPDFWriter())
530                 {
531                     // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
532                     bScreenDisplay = false;
533                 }
534 
535                 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
536                 // hint value if screen display. Only then the AutoColor mechanisms shall be applied
537 				rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, bScreenDisplay) );
538 			}
539 		}
540 
541 		ViewRedirector aViewRedirector;
542 		FmFormView::CompleteRedraw(pOutDev, rReg, pRedirector ? pRedirector : &aViewRedirector);
543 	}
544 	// oder speichern?
545 	else
546 	{
547 		if (!mpLockedRedraws)
548 			mpLockedRedraws = new List;
549 
550 		SdViewRedrawRec* pRec = new SdViewRedrawRec;
551 		pRec->mpOut	= pOutDev;
552 		pRec->aRect = rReg.GetBoundRect();
553 		mpLockedRedraws->Insert(pRec, LIST_APPEND);
554 	}
555 }
556 
557 
558 /*************************************************************************
559 |*
560 |* Selektion hat sich geaendert
561 |*
562 \************************************************************************/
563 
564 void View::MarkListHasChanged()
565 {
566 	FmFormView::MarkListHasChanged();
567 
568 	if( GetMarkedObjectCount() > 0 )
569 		maSmartTags.deselect();
570 }
571 
572 
573 /*************************************************************************
574 |*
575 |* Attribute setzen
576 |*
577 \************************************************************************/
578 
579 sal_Bool View::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
580 {
581 	sal_Bool bOk = FmFormView::SetAttributes(rSet, bReplaceAll);
582 	return (bOk);
583 }
584 
585 
586 /*************************************************************************
587 |*
588 |* Attribute holen
589 |*
590 \************************************************************************/
591 
592 sal_Bool View::GetAttributes( SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr ) const
593 {
594 	return( FmFormView::GetAttributes( rTargetSet, bOnlyHardAttr ) );
595 }
596 
597 
598 /*************************************************************************
599 |*
600 |* Ist ein Praesentationsobjekt selektiert?
601 |*
602 \************************************************************************/
603 
604 sal_Bool View::IsPresObjSelected(sal_Bool bOnPage, sal_Bool bOnMasterPage, sal_Bool bCheckPresObjListOnly, sal_Bool bCheckLayoutOnly) const
605 {
606 	/**************************************************************************
607 	* Ist ein Presentationsobjekt selektiert?
608 	**************************************************************************/
609 	SdrMarkList* pMarkList;
610 
611 	if (mnDragSrcPgNum != SDRPAGE_NOTFOUND &&
612 		mnDragSrcPgNum != GetSdrPageView()->GetPage()->GetPageNum())
613 	{
614 		// Es laeuft gerade Drag&Drop
615 		// Source- und Destination-Page unterschiedlich:
616 		// es wird die gemerkte MarkList verwendet
617 		pMarkList = mpDragSrcMarkList;
618 	}
619 	else
620 	{
621 		// Es wird die aktuelle MarkList verwendet
622 		pMarkList = new SdrMarkList(GetMarkedObjectList());
623 	}
624 
625 	SdrMark* pMark;
626 	SdPage* pPage;
627 	SdrObject* pObj;
628 
629 	sal_Bool bSelected = sal_False;
630 	sal_Bool bMasterPage = sal_False;
631 	long nMark;
632 	long nMarkMax = long(pMarkList->GetMarkCount()) - 1;
633 
634 	for (nMark = nMarkMax; (nMark >= 0) && !bSelected; nMark--)
635 	{
636 		// Rueckwaerts durch die Marklist
637 		pMark = pMarkList->GetMark(nMark);
638 		pObj = pMark->GetMarkedSdrObj();
639 
640 		if ( pObj && ( bCheckPresObjListOnly || pObj->IsEmptyPresObj() || pObj->GetUserCall() ) )
641 		{
642 			pPage = (SdPage*) pObj->GetPage();
643 			bMasterPage = pPage->IsMasterPage();
644 
645 			if ( (bMasterPage && bOnMasterPage) || (!bMasterPage && bOnPage) )
646 			{
647 				if ( pPage && pPage->IsPresObj(pObj) )
648 				{
649 					if( bCheckLayoutOnly )
650 					{
651 						PresObjKind eKind = pPage->GetPresObjKind(pObj);
652 
653 						if((eKind != PRESOBJ_FOOTER) && (eKind != PRESOBJ_HEADER) && (eKind != PRESOBJ_DATETIME) && (eKind != PRESOBJ_SLIDENUMBER) )
654 							bSelected = sal_True;
655 					}
656 					else
657 					{
658 						bSelected = sal_True;
659 					}
660 				}
661 			}
662 		}
663 	}
664 
665 	if (pMarkList != mpDragSrcMarkList)
666 	{
667 	   delete pMarkList;
668 	}
669 
670 	return (bSelected);
671 }
672 
673 /*************************************************************************
674 |*
675 |* Alles selektieren
676 |*
677 \************************************************************************/
678 
679 void View::SelectAll()
680 {
681 	if ( IsTextEdit() )
682 	{
683 		OutlinerView* pOLV = GetTextEditOutlinerView();
684 		const ::Outliner* pOutliner = GetTextEditOutliner();
685 		pOLV->SelectRange( 0, (sal_uInt16) pOutliner->GetParagraphCount() );
686 	}
687 	else
688 	{
689 		MarkAll();
690 	}
691 }
692 
693 
694 /*************************************************************************
695 |*
696 |* Dokument hat sich geaendert
697 |*
698 \************************************************************************/
699 
700 void View::ModelHasChanged()
701 {
702 	// Erst SdrView benachrichtigen
703 	FmFormView::ModelHasChanged();
704 }
705 
706 /*************************************************************************
707 |*
708 |* StyleSheet setzen
709 |*
710 \************************************************************************/
711 
712 sal_Bool View::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
713 {
714 	// weiter an SdrView
715 	return FmFormView::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
716 }
717 
718 
719 /*************************************************************************
720 |*
721 |* Texteingabe beginnen
722 |*
723 \************************************************************************/
724 
725 static void SetSpellOptions( SdDrawDocument* pDoc, sal_uLong& rCntrl )
726 {
727 	sal_Bool bOnlineSpell = pDoc->GetOnlineSpell();
728 
729 	if( bOnlineSpell )
730 		rCntrl |= EE_CNTRL_ONLINESPELLING;
731 	else
732 		rCntrl &= ~EE_CNTRL_ONLINESPELLING;
733 }
734 
735 sal_Bool View::SdrBeginTextEdit(
736 	SdrObject* pObj, SdrPageView* pPV, ::Window* pWin,
737 	sal_Bool bIsNewObj,
738 	SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
739     sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView, sal_Bool bGrabFocus )
740 {
741 	GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
742         sd::tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT, (void*)pObj );
743 
744 	if( pOutl==NULL && pObj )
745 		pOutl = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, pObj->GetModel() );
746 
747 	// make draw&impress specific initialisations
748 	if( pOutl )
749 	{
750 		pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
751 		pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
752 		sal_uLong nCntrl = pOutl->GetControlWord();
753 		nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
754 		nCntrl |= EE_CNTRL_URLSFXEXECUTE;
755 		nCntrl |= EE_CNTRL_MARKFIELDS;
756 		nCntrl |= EE_CNTRL_AUTOCORRECT;
757 
758 		nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
759 		if ( mpDoc->IsSummationOfParagraphs() )
760 		    nCntrl |= EE_CNTRL_ULSPACESUMMATION;
761 
762 		SetSpellOptions( mpDoc, nCntrl );
763 
764 		pOutl->SetControlWord(nCntrl);
765 
766 		Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
767         if ( xSpellChecker.is() )
768             pOutl->SetSpeller( xSpellChecker );
769 
770 		Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
771         if( xHyphenator.is() )
772             pOutl->SetHyphenator( xHyphenator );
773 
774 		pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
775 	}
776 
777 	sal_Bool bReturn = FmFormView::SdrBeginTextEdit(
778 		pObj, pPV, pWin, bIsNewObj, pOutl,
779 		pGivenOutlinerView, bDontDeleteOutliner,
780 		bOnlyOneView, bGrabFocus);
781 
782 	if (bReturn)
783 	{
784 		::Outliner* pOL = GetTextEditOutliner();
785 
786 		if( pObj && pObj->GetPage() )
787 		{
788 			Color aBackground;
789 			if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_TABLE )
790 			{
791 				aBackground = GetTextEditBackgroundColor(*this);
792 			}
793 			else
794 			{
795 				aBackground = pObj->GetPage()->GetPageBackgroundColor(pPV);
796 			}
797 			pOL->SetBackgroundColor( aBackground  );
798 		}
799 
800 		pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
801 		pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
802 	}
803 
804 	return(bReturn);
805 }
806 
807 /** ends current text editing */
808 SdrEndTextEditKind View::SdrEndTextEdit(sal_Bool bDontDeleteReally )
809 {
810 	SdrObjectWeakRef xObj( GetTextEditObject() );
811 
812 	sal_Bool bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );
813 
814 	SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
815 
816 	if( bDefaultTextRestored )
817 	{
818 		if( xObj.is() && !xObj->IsEmptyPresObj() )
819 		{
820 			xObj->SetEmptyPresObj( sal_True );
821 		}
822 		else
823 		{
824 			eKind = SDRENDTEXTEDIT_UNCHANGED;
825 		}
826 	}
827 	else if( xObj.is() && xObj->IsEmptyPresObj() )
828 	{
829 		SdrTextObj* pObj = dynamic_cast< SdrTextObj* >( xObj.get() );
830 		if( pObj && pObj->HasText() )
831 		{
832 			SdrPage* pPage = pObj->GetPage();
833 			if( !pPage || !pPage->IsMasterPage() )
834 				pObj->SetEmptyPresObj( sal_False );
835 		}
836 	}
837 
838 	GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT, (void*)xObj.get() );
839 
840 	if( xObj.is() )
841 	{
842 		SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() );
843 		if( pPage )
844 			pPage->onEndTextEdit( xObj.get() );
845 	}
846 
847 	return(eKind);
848 }
849 
850 // --------------------------------------------------------------------
851 
852 /** restores the default text if the given text object is currently in edit mode and
853 	no text has been entered already. Is only usefull just before text edit ends. */
854 bool View::RestoreDefaultText( SdrTextObj* pTextObj )
855 {
856 	bool bRestored = false;
857 
858 	if( pTextObj && (pTextObj == GetTextEditObject()) )
859 	{
860 		if( !pTextObj->HasText() )
861 		{
862 			SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
863 
864 			if(pPage)
865 			{
866 				bRestored = pPage->RestoreDefaultText( pTextObj );
867 				if( bRestored )
868 				{
869 					SdrOutliner* pOutliner = GetTextEditOutliner();
870 					pTextObj->SetTextEditOutliner( pOutliner );
871 					OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
872 					if (pOutliner)
873 						pOutliner->SetText(*pParaObj);
874 				}
875 			}
876 		}
877 	}
878 
879 	return bRestored;
880 }
881 
882 /*************************************************************************
883 |*
884 |* Originalgroesse der markierten Objekte setzen
885 |*
886 \************************************************************************/
887 
888 void View::SetMarkedOriginalSize()
889 {
890 	SdrUndoGroup*   pUndoGroup = new SdrUndoGroup(*mpDoc);
891 	sal_uLong           nCount = GetMarkedObjectCount();
892 	sal_Bool            bOK = sal_False;
893 
894 	for( sal_uInt32 i = 0; i < nCount; i++ )
895 	{
896 		SdrObject* pObj = GetMarkedObjectByIndex(i);
897 
898 		if( pObj->GetObjInventor() == SdrInventor )
899 		{
900 			if( pObj->GetObjIdentifier() == OBJ_OLE2 )
901 			{
902                 uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObj)->GetObjRef();
903                 if( xObj.is() )
904 				{
905                     // TODO/LEAN: working with VisualArea can switch object to running state
906 
907                    	sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
908 					Size aOleSize;
909 
910 					if ( nAspect == embed::Aspects::MSOLE_ICON )
911 					{
912 						MapMode aMap100( MAP_100TH_MM );
913                     	aOleSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMap100 );
914                     	bOK = sal_True;
915 					}
916 					else
917 					{
918                     	MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
919 						try
920 						{
921                     		awt::Size aSz = xObj->getVisualAreaSize( nAspect );
922                     		aOleSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aUnit, MAP_100TH_MM );
923                     		bOK = sal_True;
924 						}
925 						catch( embed::NoVisualAreaSizeException& )
926 						{}
927 					}
928 
929 					if ( bOK )
930 					{
931 						Rectangle   aDrawRect( pObj->GetLogicRect() );
932 
933 						pUndoGroup->AddAction( mpDoc->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
934 						pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
935 													   	Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
936 					}
937                 }
938 			}
939 			else if( pObj->GetObjIdentifier() == OBJ_GRAF )
940 			{
941 				const MapMode   aMap100( MAP_100TH_MM );
942 				Size            aSize;
943 
944 			    if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
945 				    aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 );
946 			    else
947 			    {
948 				    aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(),
949 														static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(),
950 														aMap100 );
951 				}
952 
953 				pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
954 				Rectangle aRect( pObj->GetLogicRect() );
955 				aRect.SetSize( aSize );
956 				pObj->SetLogicRect( aRect );
957 
958 				bOK = sal_True;
959 			}
960 		}
961 	}
962 
963 	if( bOK )
964 	{
965 		pUndoGroup->SetComment( String(SdResId(STR_UNDO_ORIGINALSIZE)) );
966 		mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
967 	}
968 	else
969 		delete pUndoGroup;
970 }
971 
972 /*************************************************************************
973 |*
974 |* OLE-Obj am Client connecten
975 |*
976 \************************************************************************/
977 
978 void View::DoConnect(SdrOle2Obj* pObj)
979 {
980 	if (mpViewSh)
981 	{
982         uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
983         if( xObj.is() )
984 		{
985             ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
986             SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
987             if ( !pSdClient )
988 			{
989                 pSdClient = new Client(pObj, mpViewSh, pWindow);
990 				Rectangle aRect = pObj->GetLogicRect();
991 				{
992                     // TODO/LEAN: working with visual area can switch object to running state
993 					Size aDrawSize = aRect.GetSize();
994                     awt::Size aSz;
995 
996 					MapMode aMapMode( mpDoc->GetScaleUnit() );
997                     Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
998 
999 					Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
1000 					Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
1001 					aScaleWidth.ReduceInaccurate(10);		// kompatibel zum SdrOle2Obj
1002 					aScaleHeight.ReduceInaccurate(10);
1003                     pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
1004 
1005 					// sichtbarer Ausschnitt wird nur inplace veraendert!
1006 					// the object area must be set after the scaling, since it triggers resize
1007 					aRect.SetSize(aObjAreaSize);
1008                     pSdClient->SetObjArea(aRect);
1009 				}
1010 			}
1011         }
1012 	}
1013 }
1014 
1015 /*************************************************************************
1016 |*
1017 |*
1018 |*
1019 \************************************************************************/
1020 
1021 sal_Bool View::IsMorphingAllowed() const
1022 {
1023 	const SdrMarkList&	rMarkList = GetMarkedObjectList();
1024 	sal_Bool				bRet = sal_False;
1025 
1026 	if ( rMarkList.GetMarkCount() == 2 )
1027 	{
1028 		const SdrObject*	pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1029 		const SdrObject*	pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
1030 		const sal_uInt16		nKind1 = pObj1->GetObjIdentifier();
1031 		const sal_uInt16		nKind2 = pObj2->GetObjIdentifier();
1032 
1033 		if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
1034 			 ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
1035 			 ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
1036 			 ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
1037 			 ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
1038 			 ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
1039 			 ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
1040 			 ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
1041 			 ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
1042 			 ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
1043 			 ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
1044 			 ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
1045 			 ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
1046 			 ( nKind1 != OBJ_CAPTION && nKind2 !=  OBJ_CAPTION ) &&
1047 			 !pObj1->ISA( E3dObject) && !pObj2->ISA( E3dObject) )
1048 		{
1049 			SfxItemSet		aSet1( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1050 			SfxItemSet		aSet2( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1051 
1052 			aSet1.Put(pObj1->GetMergedItemSet());
1053 			aSet2.Put(pObj2->GetMergedItemSet());
1054 
1055 			const XFillStyle	eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
1056 			const XFillStyle	eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
1057 
1058 			if( ( eFillStyle1 == XFILL_NONE || eFillStyle1 == XFILL_SOLID ) &&
1059 				( eFillStyle2 == XFILL_NONE || eFillStyle2 == XFILL_SOLID ) )
1060 				bRet = sal_True;
1061 		}
1062 	}
1063 
1064 	return bRet;
1065 }
1066 
1067 /*************************************************************************
1068 |*
1069 |*
1070 |*
1071 \************************************************************************/
1072 
1073 sal_Bool View::IsVectorizeAllowed() const
1074 {
1075 	const SdrMarkList&	rMarkList = GetMarkedObjectList();
1076 	sal_Bool				bRet = sal_False;
1077 
1078 	if( rMarkList.GetMarkCount() == 1 )
1079 	{
1080 		const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1081 
1082 		if( pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
1083 			bRet = sal_True;
1084 	}
1085 
1086 	return bRet;
1087 }
1088 
1089 void View::onAccessibilityOptionsChanged()
1090 {
1091 	if( mpViewSh )
1092 	{
1093 		::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1094 		if( pWindow )
1095 		{
1096 			const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1097 
1098 			sal_uInt16 nOutputSlot, nPreviewSlot;
1099 
1100 			SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
1101 
1102 			if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
1103 			{
1104 				if( rStyleSettings.GetHighContrastMode() )
1105 				{
1106 					nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
1107 				}
1108 				else
1109 				{
1110 					nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
1111 				}
1112 
1113 				if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
1114 				{
1115 					nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
1116 				}
1117 				else
1118 				{
1119 					nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
1120 				}
1121 
1122 				mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SFX_CALLMODE_ASYNCHRON );
1123 				mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
1124 			}
1125 
1126 			mpViewSh->Invalidate();
1127 		}
1128 	}
1129 }
1130 
1131 IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner *, pOutliner )
1132 {
1133 	Paragraph* pPara = pOutliner->GetHdlParagraph();
1134 	SdrObject* pObj = GetTextEditObject();
1135 
1136 	if( pPara && pObj )
1137 	{
1138 		SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1139 		if( pPage )
1140 			pPage->onParagraphInserted( pOutliner, pPara, pObj );
1141 	}
1142 	return 0;
1143 }
1144 
1145 /*************************************************************************
1146 |*
1147 |* Handler fuer das Loeschen von Seiten (Absaetzen)
1148 |*
1149 \************************************************************************/
1150 
1151 IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
1152 {
1153 	Paragraph* pPara = pOutliner->GetHdlParagraph();
1154 	SdrObject* pObj = GetTextEditObject();
1155 
1156 	if( pPara && pObj )
1157 	{
1158 		SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1159 		if( pPage )
1160 			pPage->onParagraphRemoving( pOutliner, pPara, pObj );
1161 	}
1162 	return 0;
1163 }
1164 
1165 bool View::isRecordingUndo() const
1166 {
1167 	if( mpDoc && mpDoc->IsUndoEnabled() )
1168 	{
1169 		sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
1170 		return pUndoManager && pUndoManager->IsInListAction();
1171 	}
1172 	else
1173 	{
1174 		return false;
1175 	}
1176 }
1177 
1178 void View::AddCustomHdl()
1179 {
1180 	maSmartTags.addCustomHandles( aHdl );
1181 }
1182 
1183 void View::updateHandles()
1184 {
1185 	AdjustMarkHdl();
1186 }
1187 
1188 SdrViewContext View::GetContext() const
1189 {
1190 	SdrViewContext eContext = SDRCONTEXT_STANDARD;
1191 	if( maSmartTags.getContext( eContext ) )
1192 		return eContext;
1193 	else
1194 		return FmFormView::GetContext();
1195 }
1196 
1197 sal_Bool View::HasMarkablePoints() const
1198 {
1199 	if( maSmartTags.HasMarkablePoints() )
1200 		return true;
1201 	else
1202 		return FmFormView::HasMarkablePoints();
1203 }
1204 
1205 sal_uLong View::GetMarkablePointCount() const
1206 {
1207 	sal_uLong nCount = FmFormView::GetMarkablePointCount();
1208 	nCount += maSmartTags.GetMarkablePointCount();
1209 	return nCount;
1210 }
1211 
1212 sal_Bool View::HasMarkedPoints() const
1213 {
1214 	if( maSmartTags.HasMarkedPoints() )
1215 		return true;
1216 	else
1217 		return FmFormView::HasMarkedPoints();
1218 }
1219 
1220 sal_uLong View::GetMarkedPointCount() const
1221 {
1222 	sal_uLong nCount = FmFormView::GetMarkedPointCount();
1223 	nCount += maSmartTags.GetMarkedPointCount();
1224 	return nCount;
1225 }
1226 
1227 sal_Bool View::IsPointMarkable(const SdrHdl& rHdl) const
1228 {
1229 	if( maSmartTags.IsPointMarkable( rHdl ) )
1230 		return true;
1231 	else
1232 		return FmFormView::IsPointMarkable( rHdl );
1233 }
1234 
1235 sal_Bool View::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
1236 {
1237 	if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
1238 		return true;
1239 	else
1240 		return FmFormView::MarkPoint( rHdl, bUnmark );
1241 }
1242 
1243 sal_Bool View::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
1244 {
1245 	if( maSmartTags.MarkPoints( pRect, bUnmark ) )
1246 		return true;
1247 	else
1248 		return FmFormView::MarkPoints( pRect, bUnmark );
1249 }
1250 
1251 void View::CheckPossibilities()
1252 {
1253 	FmFormView::CheckPossibilities();
1254 	maSmartTags.CheckPossibilities();
1255 }
1256 
1257 void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
1258 {
1259 }
1260 
1261 /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
1262 	get the correct style sheet. */
1263 void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
1264 {
1265 	SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
1266 	SdrOutliner* pOutliner = GetTextEditOutliner();
1267 	if( pOutliner && pTextObj && pTextObj->GetPage() )
1268 	{
1269 		SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
1270 
1271 		SfxStyleSheet* pStyleSheet = 0;
1272 
1273 		const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
1274 		if( eKind != PRESOBJ_NONE )
1275 			pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
1276 		else
1277 			pStyleSheet = pTextObj->GetStyleSheet();
1278 
1279 		if( eKind == PRESOBJ_OUTLINE )
1280 		{
1281 			// for outline shapes, set the correct outline style sheet for each
1282 			// new paragraph, depending on the paragraph depth
1283 			SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
1284 
1285 			for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1286 			{
1287 				sal_Int16 nDepth = pOutliner->GetDepth( nPara );
1288 
1289 				SfxStyleSheet* pStyle = 0;
1290 				if( nDepth > 0 )
1291 				{
1292 					String aStyleSheetName( pStyleSheet->GetName() );
1293 					aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
1294 					aStyleSheetName += String::CreateFromInt32( nDepth );
1295 					pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
1296 					DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
1297 				}
1298 
1299 				if( !pStyle )
1300 					pStyle = pStyleSheet;
1301 
1302 				pOutliner->SetStyleSheet( nPara, pStyle );
1303 			}
1304 		}
1305 		else
1306 		{
1307 			// just put the object style on each new paragraph
1308 			for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1309 			{
1310 				pOutliner->SetStyleSheet( nPara, pStyleSheet );
1311 			}
1312 		}
1313 	}
1314 }
1315 
1316 } // end of namespace sd
1317