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