xref: /aoo41x/main/sd/source/ui/view/sdview.cxx (revision 02c50d82)
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             if (pOL != NULL)
799                 pOL->SetBackgroundColor( aBackground  );
800 		}
801 
802         if (pOL != NULL)
803         {
804             pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
805             pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
806         }
807 	}
808 
809 	return(bReturn);
810 }
811 
812 /** ends current text editing */
813 SdrEndTextEditKind View::SdrEndTextEdit(sal_Bool bDontDeleteReally )
814 {
815 	SdrObjectWeakRef xObj( GetTextEditObject() );
816 
817 	sal_Bool bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );
818 
819 	SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
820 
821 	if( bDefaultTextRestored )
822 	{
823 		if( xObj.is() && !xObj->IsEmptyPresObj() )
824 		{
825 			xObj->SetEmptyPresObj( sal_True );
826 		}
827 		else
828 		{
829 			eKind = SDRENDTEXTEDIT_UNCHANGED;
830 		}
831 	}
832 	else if( xObj.is() && xObj->IsEmptyPresObj() )
833 	{
834 		SdrTextObj* pObj = dynamic_cast< SdrTextObj* >( xObj.get() );
835 		if( pObj && pObj->HasText() )
836 		{
837 			SdrPage* pPage = pObj->GetPage();
838 			if( !pPage || !pPage->IsMasterPage() )
839 				pObj->SetEmptyPresObj( sal_False );
840 		}
841 	}
842 
843 	GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
844         sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT,
845         (void*)xObj.get() );
846     ContextChangeEventMultiplexer::NotifyContextChange(
847         GetViewShell()->GetViewShellBase().GetController(),
848         ::sfx2::sidebar::EnumContext::Context_Default);
849 
850 	if( xObj.is() )
851 	{
852 		SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() );
853 		if( pPage )
854 			pPage->onEndTextEdit( xObj.get() );
855 	}
856 
857 	return(eKind);
858 }
859 
860 // --------------------------------------------------------------------
861 
862 /** restores the default text if the given text object is currently in edit mode and
863 	no text has been entered already. Is only usefull just before text edit ends. */
864 bool View::RestoreDefaultText( SdrTextObj* pTextObj )
865 {
866 	bool bRestored = false;
867 
868 	if( pTextObj && (pTextObj == GetTextEditObject()) )
869 	{
870 		if( !pTextObj->HasText() )
871 		{
872 			SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
873 
874 			if(pPage)
875 			{
876 				bRestored = pPage->RestoreDefaultText( pTextObj );
877 				if( bRestored )
878 				{
879 					SdrOutliner* pOutliner = GetTextEditOutliner();
880 					pTextObj->SetTextEditOutliner( pOutliner );
881 					OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
882 					if (pOutliner)
883 						pOutliner->SetText(*pParaObj);
884 				}
885 			}
886 		}
887 	}
888 
889 	return bRestored;
890 }
891 
892 /*************************************************************************
893 |*
894 |* Originalgroesse der markierten Objekte setzen
895 |*
896 \************************************************************************/
897 
898 void View::SetMarkedOriginalSize()
899 {
900 	SdrUndoGroup*   pUndoGroup = new SdrUndoGroup(*mpDoc);
901 	sal_uLong           nCount = GetMarkedObjectCount();
902 	sal_Bool            bOK = sal_False;
903 
904 	for( sal_uInt32 i = 0; i < nCount; i++ )
905 	{
906 		SdrObject* pObj = GetMarkedObjectByIndex(i);
907 
908 		if( pObj->GetObjInventor() == SdrInventor )
909 		{
910 			if( pObj->GetObjIdentifier() == OBJ_OLE2 )
911 			{
912                 uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObj)->GetObjRef();
913                 if( xObj.is() )
914 				{
915                     // TODO/LEAN: working with VisualArea can switch object to running state
916 
917                    	sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
918 					Size aOleSize;
919 
920 					if ( nAspect == embed::Aspects::MSOLE_ICON )
921 					{
922 						MapMode aMap100( MAP_100TH_MM );
923                     	aOleSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMap100 );
924                     	bOK = sal_True;
925 					}
926 					else
927 					{
928                     	MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
929 						try
930 						{
931                     		awt::Size aSz = xObj->getVisualAreaSize( nAspect );
932                     		aOleSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aUnit, MAP_100TH_MM );
933                     		bOK = sal_True;
934 						}
935 						catch( embed::NoVisualAreaSizeException& )
936 						{}
937 					}
938 
939 					if ( bOK )
940 					{
941 						Rectangle   aDrawRect( pObj->GetLogicRect() );
942 
943 						pUndoGroup->AddAction( mpDoc->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
944 						pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
945 													   	Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
946 					}
947                 }
948 			}
949 			else if( pObj->GetObjIdentifier() == OBJ_GRAF )
950 			{
951 				const MapMode   aMap100( MAP_100TH_MM );
952 				Size            aSize;
953 
954 			    if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
955 				    aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 );
956 			    else
957 			    {
958 				    aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(),
959 														static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(),
960 														aMap100 );
961 				}
962 
963 				pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
964 				Rectangle aRect( pObj->GetLogicRect() );
965 				aRect.SetSize( aSize );
966 				pObj->SetLogicRect( aRect );
967 
968 				bOK = sal_True;
969 			}
970 		}
971 	}
972 
973 	if( bOK )
974 	{
975 		pUndoGroup->SetComment( String(SdResId(STR_UNDO_ORIGINALSIZE)) );
976 		mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
977 	}
978 	else
979 		delete pUndoGroup;
980 }
981 
982 /*************************************************************************
983 |*
984 |* OLE-Obj am Client connecten
985 |*
986 \************************************************************************/
987 
988 void View::DoConnect(SdrOle2Obj* pObj)
989 {
990 	if (mpViewSh)
991 	{
992         uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
993         if( xObj.is() )
994 		{
995             ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
996             SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
997             if ( !pSdClient )
998 			{
999                 pSdClient = new Client(pObj, mpViewSh, pWindow);
1000 				Rectangle aRect = pObj->GetLogicRect();
1001 				{
1002                     // TODO/LEAN: working with visual area can switch object to running state
1003 					Size aDrawSize = aRect.GetSize();
1004                     awt::Size aSz;
1005 
1006 					MapMode aMapMode( mpDoc->GetScaleUnit() );
1007                     Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
1008 
1009 					Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
1010 					Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
1011 					aScaleWidth.ReduceInaccurate(10);		// kompatibel zum SdrOle2Obj
1012 					aScaleHeight.ReduceInaccurate(10);
1013                     pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
1014 
1015 					// sichtbarer Ausschnitt wird nur inplace veraendert!
1016 					// the object area must be set after the scaling, since it triggers resize
1017 					aRect.SetSize(aObjAreaSize);
1018                     pSdClient->SetObjArea(aRect);
1019 				}
1020 			}
1021         }
1022 	}
1023 }
1024 
1025 /*************************************************************************
1026 |*
1027 |*
1028 |*
1029 \************************************************************************/
1030 
1031 sal_Bool View::IsMorphingAllowed() const
1032 {
1033 	const SdrMarkList&	rMarkList = GetMarkedObjectList();
1034 	sal_Bool				bRet = sal_False;
1035 
1036 	if ( rMarkList.GetMarkCount() == 2 )
1037 	{
1038 		const SdrObject*	pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1039 		const SdrObject*	pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
1040 		const sal_uInt16		nKind1 = pObj1->GetObjIdentifier();
1041 		const sal_uInt16		nKind2 = pObj2->GetObjIdentifier();
1042 
1043 		if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
1044 			 ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
1045 			 ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
1046 			 ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
1047 			 ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
1048 			 ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
1049 			 ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
1050 			 ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
1051 			 ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
1052 			 ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
1053 			 ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
1054 			 ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
1055 			 ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
1056 			 ( nKind1 != OBJ_CAPTION && nKind2 !=  OBJ_CAPTION ) &&
1057 			 !pObj1->ISA( E3dObject) && !pObj2->ISA( E3dObject) )
1058 		{
1059 			SfxItemSet		aSet1( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1060 			SfxItemSet		aSet2( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1061 
1062 			aSet1.Put(pObj1->GetMergedItemSet());
1063 			aSet2.Put(pObj2->GetMergedItemSet());
1064 
1065 			const XFillStyle	eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
1066 			const XFillStyle	eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
1067 
1068 			if( ( eFillStyle1 == XFILL_NONE || eFillStyle1 == XFILL_SOLID ) &&
1069 				( eFillStyle2 == XFILL_NONE || eFillStyle2 == XFILL_SOLID ) )
1070 				bRet = sal_True;
1071 		}
1072 	}
1073 
1074 	return bRet;
1075 }
1076 
1077 /*************************************************************************
1078 |*
1079 |*
1080 |*
1081 \************************************************************************/
1082 
1083 sal_Bool View::IsVectorizeAllowed() const
1084 {
1085 	const SdrMarkList&	rMarkList = GetMarkedObjectList();
1086 	sal_Bool				bRet = sal_False;
1087 
1088 	if( rMarkList.GetMarkCount() == 1 )
1089 	{
1090 		const SdrGrafObj* pObj = dynamic_cast< const SdrGrafObj* >(rMarkList.GetMark( 0 )->GetMarkedSdrObj());
1091 
1092         if(pObj)
1093         {
1094             if(GRAPHIC_BITMAP == pObj->GetGraphicType() && !pObj->isEmbeddedSvg())
1095             {
1096                 bRet = sal_True;
1097             }
1098         }
1099 	}
1100 
1101 	return bRet;
1102 }
1103 
1104 void View::onAccessibilityOptionsChanged()
1105 {
1106 	if( mpViewSh )
1107 	{
1108 		::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1109 		if( pWindow )
1110 		{
1111 			const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1112 
1113 			sal_uInt16 nOutputSlot, nPreviewSlot;
1114 
1115 			SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
1116 
1117 			if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
1118 			{
1119 				if( rStyleSettings.GetHighContrastMode() )
1120 				{
1121 					nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
1122 				}
1123 				else
1124 				{
1125 					nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
1126 				}
1127 
1128 				if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
1129 				{
1130 					nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
1131 				}
1132 				else
1133 				{
1134 					nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
1135 				}
1136 
1137 				mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SFX_CALLMODE_ASYNCHRON );
1138 				mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
1139 			}
1140 
1141 			mpViewSh->Invalidate();
1142 		}
1143 	}
1144 }
1145 
1146 IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner *, pOutliner )
1147 {
1148 	Paragraph* pPara = pOutliner->GetHdlParagraph();
1149 	SdrObject* pObj = GetTextEditObject();
1150 
1151 	if( pPara && pObj )
1152 	{
1153 		SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1154 		if( pPage )
1155 			pPage->onParagraphInserted( pOutliner, pPara, pObj );
1156 	}
1157 	return 0;
1158 }
1159 
1160 /*************************************************************************
1161 |*
1162 |* Handler fuer das Loeschen von Seiten (Absaetzen)
1163 |*
1164 \************************************************************************/
1165 
1166 IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
1167 {
1168 	Paragraph* pPara = pOutliner->GetHdlParagraph();
1169 	SdrObject* pObj = GetTextEditObject();
1170 
1171 	if( pPara && pObj )
1172 	{
1173 		SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1174 		if( pPage )
1175 			pPage->onParagraphRemoving( pOutliner, pPara, pObj );
1176 	}
1177 	return 0;
1178 }
1179 
1180 bool View::isRecordingUndo() const
1181 {
1182 	if( mpDoc && mpDoc->IsUndoEnabled() )
1183 	{
1184 		sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
1185 		return pUndoManager && pUndoManager->IsInListAction();
1186 	}
1187 	else
1188 	{
1189 		return false;
1190 	}
1191 }
1192 
1193 void View::AddCustomHdl()
1194 {
1195 	maSmartTags.addCustomHandles( aHdl );
1196 }
1197 
1198 void View::updateHandles()
1199 {
1200 	AdjustMarkHdl();
1201 }
1202 
1203 SdrViewContext View::GetContext() const
1204 {
1205 	SdrViewContext eContext = SDRCONTEXT_STANDARD;
1206 	if( maSmartTags.getContext( eContext ) )
1207 		return eContext;
1208 	else
1209 		return FmFormView::GetContext();
1210 }
1211 
1212 sal_Bool View::HasMarkablePoints() const
1213 {
1214 	if( maSmartTags.HasMarkablePoints() )
1215 		return true;
1216 	else
1217 		return FmFormView::HasMarkablePoints();
1218 }
1219 
1220 sal_uLong View::GetMarkablePointCount() const
1221 {
1222 	sal_uLong nCount = FmFormView::GetMarkablePointCount();
1223 	nCount += maSmartTags.GetMarkablePointCount();
1224 	return nCount;
1225 }
1226 
1227 sal_Bool View::HasMarkedPoints() const
1228 {
1229 	if( maSmartTags.HasMarkedPoints() )
1230 		return true;
1231 	else
1232 		return FmFormView::HasMarkedPoints();
1233 }
1234 
1235 sal_uLong View::GetMarkedPointCount() const
1236 {
1237 	sal_uLong nCount = FmFormView::GetMarkedPointCount();
1238 	nCount += maSmartTags.GetMarkedPointCount();
1239 	return nCount;
1240 }
1241 
1242 sal_Bool View::IsPointMarkable(const SdrHdl& rHdl) const
1243 {
1244 	if( maSmartTags.IsPointMarkable( rHdl ) )
1245 		return true;
1246 	else
1247 		return FmFormView::IsPointMarkable( rHdl );
1248 }
1249 
1250 sal_Bool View::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
1251 {
1252 	if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
1253 		return true;
1254 	else
1255 		return FmFormView::MarkPoint( rHdl, bUnmark );
1256 }
1257 
1258 sal_Bool View::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
1259 {
1260 	if( maSmartTags.MarkPoints( pRect, bUnmark ) )
1261 		return true;
1262 	else
1263 		return FmFormView::MarkPoints( pRect, bUnmark );
1264 }
1265 
1266 void View::CheckPossibilities()
1267 {
1268 	FmFormView::CheckPossibilities();
1269 	maSmartTags.CheckPossibilities();
1270 }
1271 
1272 void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
1273 {
1274 }
1275 
1276 /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
1277 	get the correct style sheet. */
1278 void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
1279 {
1280 	SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
1281 	SdrOutliner* pOutliner = GetTextEditOutliner();
1282 	if( pOutliner && pTextObj && pTextObj->GetPage() )
1283 	{
1284 		SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
1285 
1286 		SfxStyleSheet* pStyleSheet = 0;
1287 
1288 		const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
1289 		if( eKind != PRESOBJ_NONE )
1290 			pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
1291 		else
1292 			pStyleSheet = pTextObj->GetStyleSheet();
1293 
1294 		if( eKind == PRESOBJ_OUTLINE )
1295 		{
1296 			// for outline shapes, set the correct outline style sheet for each
1297 			// new paragraph, depending on the paragraph depth
1298 			SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
1299 
1300 			for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1301 			{
1302 				sal_Int16 nDepth = pOutliner->GetDepth( nPara );
1303 
1304 				SfxStyleSheet* pStyle = 0;
1305 				if( nDepth > 0 )
1306 				{
1307 					String aStyleSheetName( pStyleSheet->GetName() );
1308 					aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
1309 					aStyleSheetName += String::CreateFromInt32( nDepth );
1310 					pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
1311 					DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
1312 				}
1313 
1314 				if( !pStyle )
1315 					pStyle = pStyleSheet;
1316 
1317 				pOutliner->SetStyleSheet( nPara, pStyle );
1318 			}
1319 		}
1320 		else
1321 		{
1322 			// just put the object style on each new paragraph
1323 			for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1324 			{
1325 				pOutliner->SetStyleSheet( nPara, pStyleSheet );
1326 			}
1327 		}
1328 	}
1329 }
1330 
1331 } // end of namespace sd
1332