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