update dev300-m58
[ooovba.git] / sd / source / ui / view / sdview.cxx
blob365c11df323630a983b69bf31a0d0299a0c7434f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdview.cxx,v $
10 * $Revision: 1.66 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
34 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
36 #include "View.hxx"
37 #include <svx/unolingu.hxx>
38 #include <sfx2/request.hxx>
39 #include <svx/obj3d.hxx>
40 #include <svx/fmview.hxx>
41 #include <svx/outliner.hxx>
42 #ifndef _SVX_SVXIDS_HRC
43 #include <svx/svxids.hrc>
44 #endif
45 #include <svx/svdograf.hxx>
46 #include <svx/svdoole2.hxx>
47 #include <svx/svdundo.hxx>
48 #include <vcl/msgbox.hxx>
49 #include <sfx2/dispatch.hxx>
50 #include <sfx2/app.hxx>
51 #include <svx/svdpagv.hxx>
52 #include <sfx2/docfile.hxx>
53 #include <svx/svdoutl.hxx>
54 #include <svx/sdr/contact/displayinfo.hxx>
56 #include <svx/svdetc.hxx>
57 #include <svx/editstat.hxx>
59 #include <svx/dialogs.hrc>
60 #include <sfx2/viewfrm.hxx>
61 #include <svx/svdopage.hxx>
62 #include <toolkit/helper/vclunohelper.hxx>
63 #include <svx/xlndsit.hxx>
64 #include <svx/xlineit0.hxx>
65 #include <svx/xlnclit.hxx>
66 #include <vcl/virdev.hxx>
68 #include "app.hrc"
69 #include "strings.hrc"
70 #include "Window.hxx"
71 #include "Client.hxx"
72 #include "drawdoc.hxx"
73 #include "DrawDocShell.hxx"
74 #include "app.hxx"
75 #include "sdpage.hxx"
76 #include "glob.hrc"
77 #include "sdresid.hxx"
78 #include "DrawViewShell.hxx"
79 #include "futext.hxx"
80 #include "fuinsfil.hxx"
81 #include "slideshow.hxx"
82 #include "stlpool.hxx"
83 #include "FrameView.hxx"
84 #include "ViewClipboard.hxx"
85 #include "undo/undomanager.hxx"
86 #include <svx/sdr/contact/viewobjectcontact.hxx>
87 #include <svx/sdr/contact/viewcontact.hxx>
88 #include <svx/sdr/contact/displayinfo.hxx>
89 #include "EventMultiplexer.hxx"
90 #include "ViewShellBase.hxx"
91 #include "ViewShellManager.hxx"
93 #include <basegfx/polygon/b2dpolygontools.hxx>
94 #include <basegfx/color/bcolor.hxx>
95 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
96 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
97 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
98 #include <svx/sdr/contact/objectcontact.hxx>
99 #include <basegfx/matrix/b2dhommatrix.hxx>
100 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
101 #include <svx/unoapi.hxx>
103 #include <numeric>
105 using namespace com::sun::star;
106 using namespace com::sun::star::uno;
107 namespace sd {
109 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
110 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
111 SO2_DECL_REF(SvInPlaceObject)
112 #endif
114 TYPEINIT1(View, FmFormView);
116 /*************************************************************************
118 |* Ctor
120 \************************************************************************/
122 View::View(SdDrawDocument* pDrawDoc, OutputDevice* pOutDev,
123 ViewShell* pViewShell)
124 : FmFormView(pDrawDoc, pOutDev),
125 mpDoc(pDrawDoc),
126 mpDocSh( pDrawDoc->GetDocSh() ),
127 mpViewSh(pViewShell),
128 mpDragSrcMarkList(NULL),
129 mpDropMarkerObj(NULL),
130 mpDropMarker(NULL),
131 mnDragSrcPgNum(SDRPAGE_NOTFOUND),
132 mnAction(DND_ACTION_NONE),
133 mnLockRedrawSmph(0),
134 mpLockedRedraws(NULL),
135 mbIsDropAllowed(TRUE),
136 maSmartTags(*this),
137 mpClipboard (new ViewClipboard (*this))
139 // #i73602# Use default from the configuration
140 SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_DrawImpress());
142 // #i74769#, #i75172# Use default from the configuration
143 SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_DrawImpress());
145 EnableExtendedKeyInputDispatcher(FALSE);
146 EnableExtendedMouseEventDispatcher(FALSE);
147 EnableExtendedCommandEventDispatcher(FALSE);
149 SetUseIncompatiblePathCreateInterface(FALSE);
150 SetMarkHdlWhenTextEdit(TRUE);
151 EnableTextEditOnObjectsWithoutTextIfTextTool(TRUE);
153 SetMinMoveDistancePixel(2);
154 SetHitTolerancePixel(2);
155 SetMeasureLayer(String(SdResId(STR_LAYER_MEASURELINES)));
157 // Timer fuer verzoegertes Drop (muss fuer MAC sein)
158 maDropErrorTimer.SetTimeoutHdl( LINK(this, View, DropErrorHdl) );
159 maDropErrorTimer.SetTimeout(50);
160 maDropInsertFileTimer.SetTimeoutHdl( LINK(this, View, DropInsertFileHdl) );
161 maDropInsertFileTimer.SetTimeout(50);
164 void View::ImplClearDrawDropMarker()
166 if(mpDropMarker)
168 delete mpDropMarker;
169 mpDropMarker = 0L;
173 /*************************************************************************
175 |* Dtor
177 \************************************************************************/
179 View::~View()
181 maSmartTags.Dispose();
183 // release content of selection clipboard, if we own the content
184 UpdateSelectionClipboard( TRUE );
186 maDropErrorTimer.Stop();
187 maDropInsertFileTimer.Stop();
189 ImplClearDrawDropMarker();
191 while(PaintWindowCount())
193 // Alle angemeldeten OutDevs entfernen
194 DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/);
197 // gespeicherte Redraws loeschen
198 if (mpLockedRedraws)
200 SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
201 while (pRec)
203 delete pRec;
204 pRec = (SdViewRedrawRec*)mpLockedRedraws->Next();
206 delete mpLockedRedraws;
211 class ViewRedirector : public ::sdr::contact::ViewObjectContactRedirector
213 public:
214 ViewRedirector();
215 virtual ~ViewRedirector();
217 // all default implementations just call the same methods at the original. To do something
218 // different, overload the method and at least do what the method does.
219 virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
220 const sdr::contact::ViewObjectContact& rOriginal,
221 const sdr::contact::DisplayInfo& rDisplayInfo);
224 ViewRedirector::ViewRedirector()
228 ViewRedirector::~ViewRedirector()
232 drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedPrimitive2DSequence(
233 const sdr::contact::ViewObjectContact& rOriginal,
234 const sdr::contact::DisplayInfo& rDisplayInfo)
236 SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
237 drawinglayer::primitive2d::Primitive2DSequence xRetval;
239 if(pObject && pObject->GetPage())
241 const bool bDoCreateGeometry(pObject->GetPage()->checkVisibility( rOriginal, rDisplayInfo, true ));
243 if(!bDoCreateGeometry && !(( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE )) )
244 return xRetval;
246 PresObjKind eKind(PRESOBJ_NONE);
247 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
248 const bool bIsMasterPageObject(pObject->GetPage()->IsMasterPage());
249 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter());
250 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
251 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
252 const SdPage* pObjectsSdPage = dynamic_cast< SdPage* >(pObject->GetPage());
253 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
255 // check if we need to draw a placeholder border. Never do it for
256 // objects inside a SdrPageObj and never when printing
257 if(!bIsInsidePageObj && !bIsPrinting)
259 bool bCreateOutline(false);
261 if( pObject->IsEmptyPresObj() && pObject->ISA(SdrTextObj) )
263 if( !bSubContentProcessing || !pObject->IsNotVisibleAsMaster() )
265 eKind = pObjectsSdPage ? pObjectsSdPage->GetPresObjKind(pObject) : PRESOBJ_NONE;
267 if( eKind != PRESOBJ_BACKGROUND )
269 bCreateOutline = true;
273 else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_TEXT ) )
275 if( pObjectsSdPage )
277 eKind = pObjectsSdPage->GetPresObjKind(pObject);
279 if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
281 if( !bSubContentProcessing )
283 // only draw a boundary for header&footer objects on the masterpage itself
284 bCreateOutline = true;
289 else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE ) )
291 // only for handout page, else this frame will be created for each
292 // page preview object in SlideSorter and PagePane
293 if(pObjectsSdPage && PK_HANDOUT == pObjectsSdPage->GetPageKind())
295 bCreateOutline = true;
299 if(bCreateOutline)
301 // empty presentation objects get a gray frame
302 const svtools::ColorConfig aColorConfig;
303 const svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
305 if( aColor.bIsVisible )
307 // get basic object transformation
308 const basegfx::BColor aRGBColor(Color(aColor.nColor).getBColor());
309 basegfx::B2DHomMatrix aObjectMatrix;
310 basegfx::B2DPolyPolygon aObjectPolyPolygon;
311 pObject->TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
313 // create dashed border
315 // create object polygon
316 basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)));
317 aPolygon.transform(aObjectMatrix);
319 // create line and stroke attribute
320 ::std::vector< double > aDotDashArray;
322 aDotDashArray.push_back(160.0);
323 aDotDashArray.push_back(80.0);
325 const double fFullDotDashLen(::std::accumulate(aDotDashArray.begin(), aDotDashArray.end(), 0.0));
326 const drawinglayer::attribute::LineAttribute aLine(aRGBColor);
327 const drawinglayer::attribute::StrokeAttribute aStroke(aDotDashArray, fFullDotDashLen);
329 // create primitive and add
330 const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
331 aPolygon,
332 aLine,
333 aStroke));
334 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
337 // now paint the placeholder description, but only when masterpage
338 // is displayed as page directly (MasterPage view)
339 if(!bSubContentProcessing && bIsMasterPageObject)
341 String aObjectString;
343 switch( eKind )
345 case PRESOBJ_TITLE:
347 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
349 static String aTitleAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_TITLE ) );
350 aObjectString = aTitleAreaStr;
353 break;
355 case PRESOBJ_OUTLINE:
357 static String aOutlineAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_OUTLINE ) );
358 aObjectString = aOutlineAreaStr;
359 break;
361 case PRESOBJ_FOOTER:
363 static String aFooterAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_FOOTER ) );
364 aObjectString = aFooterAreaStr;
365 break;
367 case PRESOBJ_HEADER:
369 static String aHeaderAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_HEADER ) );
370 aObjectString = aHeaderAreaStr;
371 break;
373 case PRESOBJ_DATETIME:
375 static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_DATETIME ) );
376 aObjectString = aDateTimeStr;
377 break;
379 case PRESOBJ_NOTES:
381 static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NOTES ) );
382 aObjectString = aDateTimeStr;
383 break;
385 case PRESOBJ_SLIDENUMBER:
387 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
389 static String aSlideAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_SLIDE ) );
390 aObjectString = aSlideAreaStr;
392 else
394 static String aNumberAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NUMBER ) );
395 aObjectString = aNumberAreaStr;
397 break;
399 default:
401 break;
405 if( aObjectString.Len() )
407 // decompose object matrix to be able to place text correctly
408 basegfx::B2DTuple aScale;
409 basegfx::B2DTuple aTranslate;
410 double fRotate, fShearX;
411 aObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
413 // create font
414 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObject );
415 const SdrTextVertAdjust eTVA(pTextObj ? pTextObj->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_CENTER);
416 Font aScaledVclFont;
418 // use a text size factor to get more reliable text sizes from the text layouter
419 // (and from vcl), tipp from HDU
420 static sal_uInt32 nTextSizeFactor(100);
422 // use a factor to get more linear text size calculations
423 aScaledVclFont.SetHeight( 500 * nTextSizeFactor );
425 // get basic geometry and get text size
426 drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
427 aTextLayouter.setFont(aScaledVclFont);
428 const xub_StrLen nTextLength(aObjectString.Len());
430 // do not forget to use the factor again to get the width for the 500
431 const double fTextWidth(aTextLayouter.getTextWidth(aObjectString, 0, nTextLength) * (1.0 / nTextSizeFactor));
432 const double fTextHeight(aTextLayouter.getTextHeight() * (1.0 / nTextSizeFactor));
434 // calculate text primitive position. If text is at bottom, use top for
435 // the extra text and vice versa
436 const double fHorDist(125);
437 const double fVerDist(125);
438 const double fPosX((aTranslate.getX() + aScale.getX()) - fTextWidth - fHorDist);
439 const double fPosY((SDRTEXTVERTADJUST_BOTTOM == eTVA)
440 ? aTranslate.getY() - fVerDist + fTextHeight
441 : (aTranslate.getY() + aScale.getY()) - fVerDist);
443 // get font attributes; use normally scaled font
444 const basegfx::BColor aFontColor(aRGBColor);
445 Font aVclFont;
446 basegfx::B2DVector aSize;
448 aVclFont.SetHeight( 500 );
450 const drawinglayer::primitive2d::FontAttributes aFontAttributes(drawinglayer::primitive2d::getFontAttributesFromVclFont(
451 aSize,
452 aVclFont,
453 false,
454 false));
456 // fill text matrix
457 basegfx::B2DHomMatrix aTextMatrix;
459 aTextMatrix.scale(aSize.getX(), aSize.getY());
460 aTextMatrix.shearX(fShearX);
461 aTextMatrix.rotate(fRotate);
462 aTextMatrix.translate(fPosX, fPosY);
464 // create DXTextArray (can be empty one)
465 const ::std::vector< double > aDXArray;
467 // create locale; this may need some more information in the future
468 const ::com::sun::star::lang::Locale aLocale;
470 // create primitive and add
471 const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
472 aTextMatrix,
473 aObjectString,
475 nTextLength,
476 aDXArray,
477 aFontAttributes,
478 aLocale,
479 aFontColor));
480 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
487 if(bDoCreateGeometry)
489 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
490 xRetval,
491 sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
492 rOriginal,
493 rDisplayInfo));
496 else
498 // not a SdrObject visualisation (maybe e.g. page) or no page
499 xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
502 return xRetval;
505 /*************************************************************************
507 |* Paint-Methode: das Ereignis wird an die View weitergeleitet
509 \************************************************************************/
511 void View::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0L*/)
513 // ausfuehren ??
514 if (mnLockRedrawSmph == 0)
516 SdrPageView* pPgView = GetSdrPageView();
518 if (pPgView)
520 SdPage* pPage = (SdPage*) pPgView->GetPage();
521 if( pPage )
523 SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
524 bool bScreenDisplay(true);
526 if(bScreenDisplay && pOutDev && OUTDEV_PRINTER == pOutDev->GetOutDevType())
528 // #i75566# printing; suppress AutoColor BackgroundColor generation
529 // for visibility reasons by giving GetPageBackgroundColor()
530 // the needed hint
531 bScreenDisplay = false;
534 if(bScreenDisplay && pOutDev && pOutDev->GetPDFWriter())
536 // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
537 bScreenDisplay = false;
540 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
541 // hint value if screen display. Only then the AutoColor mechanisms shall be applied
542 rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, bScreenDisplay) );
546 ViewRedirector aViewRedirector;
547 FmFormView::CompleteRedraw(pOutDev, rReg, pRedirector ? pRedirector : &aViewRedirector);
549 // oder speichern?
550 else
552 if (!mpLockedRedraws)
553 mpLockedRedraws = new List;
555 SdViewRedrawRec* pRec = new SdViewRedrawRec;
556 pRec->mpOut = pOutDev;
557 pRec->aRect = rReg.GetBoundRect();
558 mpLockedRedraws->Insert(pRec, LIST_APPEND);
563 /*************************************************************************
565 |* Selektion hat sich geaendert
567 \************************************************************************/
569 void View::MarkListHasChanged()
571 FmFormView::MarkListHasChanged();
573 if( GetMarkedObjectCount() > 0 )
574 maSmartTags.deselect();
578 /*************************************************************************
580 |* Attribute setzen
582 \************************************************************************/
584 BOOL View::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
586 BOOL bOk = FmFormView::SetAttributes(rSet, bReplaceAll);
587 return (bOk);
591 /*************************************************************************
593 |* Attribute holen
595 \************************************************************************/
597 BOOL View::GetAttributes( SfxItemSet& rTargetSet, BOOL bOnlyHardAttr ) const
599 return( FmFormView::GetAttributes( rTargetSet, bOnlyHardAttr ) );
603 /*************************************************************************
605 |* Ist ein Praesentationsobjekt selektiert?
607 \************************************************************************/
609 BOOL View::IsPresObjSelected(BOOL bOnPage, BOOL bOnMasterPage, BOOL bCheckPresObjListOnly, BOOL bCheckLayoutOnly) const
611 /**************************************************************************
612 * Ist ein Presentationsobjekt selektiert?
613 **************************************************************************/
614 SdrMarkList* pMarkList;
616 if (mnDragSrcPgNum != SDRPAGE_NOTFOUND &&
617 mnDragSrcPgNum != GetSdrPageView()->GetPage()->GetPageNum())
619 // Es laeuft gerade Drag&Drop
620 // Source- und Destination-Page unterschiedlich:
621 // es wird die gemerkte MarkList verwendet
622 pMarkList = mpDragSrcMarkList;
624 else
626 // Es wird die aktuelle MarkList verwendet
627 pMarkList = new SdrMarkList(GetMarkedObjectList());
630 SdrMark* pMark;
631 SdPage* pPage;
632 SdrObject* pObj;
634 BOOL bSelected = FALSE;
635 BOOL bMasterPage = FALSE;
636 long nMark;
637 long nMarkMax = long(pMarkList->GetMarkCount()) - 1;
639 for (nMark = nMarkMax; (nMark >= 0) && !bSelected; nMark--)
641 // Rueckwaerts durch die Marklist
642 pMark = pMarkList->GetMark(nMark);
643 pObj = pMark->GetMarkedSdrObj();
645 if ( pObj && ( bCheckPresObjListOnly || pObj->IsEmptyPresObj() || pObj->GetUserCall() ) )
647 pPage = (SdPage*) pObj->GetPage();
648 bMasterPage = pPage->IsMasterPage();
650 if ( (bMasterPage && bOnMasterPage) || (!bMasterPage && bOnPage) )
652 if ( pPage && pPage->IsPresObj(pObj) )
654 if( bCheckLayoutOnly )
656 PresObjKind eKind = pPage->GetPresObjKind(pObj);
658 if((eKind != PRESOBJ_FOOTER) && (eKind != PRESOBJ_HEADER) && (eKind != PRESOBJ_DATETIME) && (eKind != PRESOBJ_SLIDENUMBER) )
659 bSelected = TRUE;
661 else
663 bSelected = TRUE;
670 if (pMarkList != mpDragSrcMarkList)
672 delete pMarkList;
675 return (bSelected);
678 /*************************************************************************
680 |* Alles selektieren
682 \************************************************************************/
684 void View::SelectAll()
686 if ( IsTextEdit() )
688 OutlinerView* pOLV = GetTextEditOutlinerView();
689 const ::Outliner* pOutliner = GetTextEditOutliner();
690 pOLV->SelectRange( 0, (USHORT) pOutliner->GetParagraphCount() );
692 else
694 MarkAll();
699 /*************************************************************************
701 |* Dokument hat sich geaendert
703 \************************************************************************/
705 void View::ModelHasChanged()
707 // Erst SdrView benachrichtigen
708 FmFormView::ModelHasChanged();
711 /*************************************************************************
713 |* StyleSheet setzen
715 \************************************************************************/
717 BOOL View::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
719 // weiter an SdrView
720 return FmFormView::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
724 /*************************************************************************
726 |* Texteingabe beginnen
728 \************************************************************************/
730 static void SetSpellOptions( SdDrawDocument* pDoc, ULONG& rCntrl )
732 BOOL bOnlineSpell = pDoc->GetOnlineSpell();
734 if( bOnlineSpell )
735 rCntrl |= EE_CNTRL_ONLINESPELLING;
736 else
737 rCntrl &= ~EE_CNTRL_ONLINESPELLING;
740 sal_Bool View::SdrBeginTextEdit(
741 SdrObject* pObj, SdrPageView* pPV, ::Window* pWin,
742 sal_Bool bIsNewObj,
743 SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
744 sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView, sal_Bool bGrabFocus )
746 GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
747 sd::tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT, (void*)pObj );
749 if( pOutl==NULL && pObj )
750 pOutl = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, pObj->GetModel() );
752 // make draw&impress specific initialisations
753 if( pOutl )
755 pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
756 pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
757 ULONG nCntrl = pOutl->GetControlWord();
758 nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
759 nCntrl |= EE_CNTRL_URLSFXEXECUTE;
760 nCntrl |= EE_CNTRL_MARKFIELDS;
761 nCntrl |= EE_CNTRL_AUTOCORRECT;
763 nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
764 if ( mpDoc->IsSummationOfParagraphs() )
765 nCntrl |= EE_CNTRL_ULSPACESUMMATION;
767 SetSpellOptions( mpDoc, nCntrl );
769 pOutl->SetControlWord(nCntrl);
771 Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
772 if ( xSpellChecker.is() )
773 pOutl->SetSpeller( xSpellChecker );
775 Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
776 if( xHyphenator.is() )
777 pOutl->SetHyphenator( xHyphenator );
779 pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
782 sal_Bool bReturn = FmFormView::SdrBeginTextEdit(
783 pObj, pPV, pWin, bIsNewObj, pOutl,
784 pGivenOutlinerView, bDontDeleteOutliner,
785 bOnlyOneView, bGrabFocus);
787 if (bReturn)
789 ::Outliner* pOL = GetTextEditOutliner();
791 if( pObj && pObj->GetPage() )
793 Color aBackground;
794 if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_TABLE )
796 aBackground = GetTextEditBackgroundColor(*this);
798 else
800 aBackground = pObj->GetPage()->GetPageBackgroundColor(pPV);
802 pOL->SetBackgroundColor( aBackground );
805 pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
806 pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
809 return(bReturn);
812 /** ends current text editing */
813 SdrEndTextEditKind View::SdrEndTextEdit(BOOL bDontDeleteReally )
815 SdrObjectWeakRef xObj( GetTextEditObject() );
817 BOOL bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );
819 SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
821 if( bDefaultTextRestored )
823 if( xObj.is() && !xObj->IsEmptyPresObj() )
825 xObj->SetEmptyPresObj( TRUE );
827 else
829 eKind = SDRENDTEXTEDIT_UNCHANGED;
832 else if( xObj.is() && xObj->IsEmptyPresObj() )
834 SdrTextObj* pObj = dynamic_cast< SdrTextObj* >( xObj.get() );
835 if( pObj && pObj->HasText() )
837 SdrPage* pPage = pObj->GetPage();
838 if( !pPage || !pPage->IsMasterPage() )
839 pObj->SetEmptyPresObj( FALSE );
843 GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT, (void*)xObj.get() );
845 if( xObj.is() )
847 SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() );
848 if( pPage )
849 pPage->onEndTextEdit( xObj.get() );
852 return(eKind);
855 // --------------------------------------------------------------------
857 /** restores the default text if the given text object is currently in edit mode and
858 no text has been entered already. Is only usefull just before text edit ends. */
859 bool View::RestoreDefaultText( SdrTextObj* pTextObj )
861 bool bRestored = false;
863 if( pTextObj && (pTextObj == GetTextEditObject()) )
865 if( !pTextObj->HasText() )
867 SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
869 if(pPage)
871 bRestored = pPage->RestoreDefaultText( pTextObj );
872 if( bRestored )
874 SdrOutliner* pOutliner = GetTextEditOutliner();
875 pTextObj->SetTextEditOutliner( pOutliner );
876 OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
877 if (pOutliner)
878 pOutliner->SetText(*pParaObj);
884 return bRestored;
887 /*************************************************************************
889 |* Originalgroesse der markierten Objekte setzen
891 \************************************************************************/
893 void View::SetMarkedOriginalSize()
895 SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*mpDoc);
896 ULONG nCount = GetMarkedObjectCount();
897 BOOL bOK = FALSE;
899 for( sal_uInt32 i = 0; i < nCount; i++ )
901 SdrObject* pObj = GetMarkedObjectByIndex(i);
903 if( pObj->GetObjInventor() == SdrInventor )
905 if( pObj->GetObjIdentifier() == OBJ_OLE2 )
907 uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObj)->GetObjRef();
908 if( xObj.is() )
910 // TODO/LEAN: working with VisualArea can switch object to running state
912 sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
913 Size aOleSize;
915 if ( nAspect == embed::Aspects::MSOLE_ICON )
917 MapMode aMap100( MAP_100TH_MM );
918 aOleSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMap100 );
919 bOK = TRUE;
921 else
923 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
926 awt::Size aSz = xObj->getVisualAreaSize( nAspect );
927 aOleSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aUnit, MAP_100TH_MM );
928 bOK = TRUE;
930 catch( embed::NoVisualAreaSizeException& )
934 if ( bOK )
936 Rectangle aDrawRect( pObj->GetLogicRect() );
938 pUndoGroup->AddAction( mpDoc->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
939 pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
940 Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
944 else if( pObj->GetObjIdentifier() == OBJ_GRAF )
946 const MapMode aMap100( MAP_100TH_MM );
947 Size aSize;
949 if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
950 aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 );
951 else
953 aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(),
954 static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(),
955 aMap100 );
958 pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
959 Rectangle aRect( pObj->GetLogicRect() );
960 aRect.SetSize( aSize );
961 pObj->SetLogicRect( aRect );
963 bOK = TRUE;
968 if( bOK )
970 pUndoGroup->SetComment( String(SdResId(STR_UNDO_ORIGINALSIZE)) );
971 mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
973 else
974 delete pUndoGroup;
977 /** create a virtual device and paints the slide contents into it.
978 The caller must delete the returned device */
979 VirtualDevice* View::CreatePageVDev(USHORT nSdPage, PageKind ePageKind, ULONG nWidthPixel)
981 ViewShell* pViewShell = mpDocSh->GetViewShell();
982 OutputDevice* pRefDevice = 0;
983 if( pViewShell )
984 pRefDevice = pViewShell->GetActiveWindow();
986 if( !pRefDevice )
987 pRefDevice = Application::GetDefaultDevice();
989 DBG_ASSERT( pRefDevice, "sd::View::CreatePageVDev(), I need a reference device to work properly!" );
991 VirtualDevice* pVDev;
992 if( pRefDevice )
993 pVDev = new VirtualDevice( *pRefDevice );
994 else
995 pVDev = new VirtualDevice();
997 MapMode aMM( MAP_100TH_MM );
999 SdPage* pPage = mpDoc->GetSdPage(nSdPage, ePageKind);
1000 DBG_ASSERT(pPage, "sd::View::CreatePageVDev(), slide not found!");
1002 if( pPage )
1004 Size aPageSize(pPage->GetSize());
1005 aPageSize.Width() -= pPage->GetLftBorder();
1006 aPageSize.Width() -= pPage->GetRgtBorder();
1007 aPageSize.Height() -= pPage->GetUppBorder();
1008 aPageSize.Height() -= pPage->GetLwrBorder();
1010 // use scaling?
1011 if( nWidthPixel )
1013 const Fraction aFrac( (long) nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() );
1015 aMM.SetScaleX( aFrac );
1016 aMM.SetScaleY( aFrac );
1019 pVDev->SetMapMode( aMM );
1020 if( pVDev->SetOutputSize(aPageSize) )
1022 std::auto_ptr< SdrView > pView( new SdrView(mpDoc, pVDev) );
1023 pView->SetPageVisible( FALSE );
1024 pView->SetBordVisible( FALSE );
1025 pView->SetGridVisible( FALSE );
1026 pView->SetHlplVisible( FALSE );
1027 pView->SetGlueVisible( FALSE );
1028 pView->ShowSdrPage(pPage); // WAITING FOR SJ , Point(-pPage->GetLftBorder(), -pPage->GetUppBorder()));
1029 SdrPageView* pPageView = pView->GetSdrPageView();
1030 if( pViewShell )
1032 FrameView* pFrameView = pViewShell->GetFrameView();
1033 if( pFrameView )
1035 pPageView->SetVisibleLayers( pFrameView->GetVisibleLayers() );
1036 pPageView->SetLockedLayers( pFrameView->GetLockedLayers() );
1037 pPageView->SetPrintableLayers( pFrameView->GetPrintableLayers() );
1041 // SJ: i40609, the vdev mapmode seems to be dangled after CompleteRedraw,
1042 // so we are pushing here, because the mapmode is used afterwards
1043 pVDev->Push();
1045 Point aPoint( 0, 0 );
1046 Region aRegion (Rectangle( aPoint, aPageSize ) );
1047 pView->CompleteRedraw(pVDev, aRegion);
1048 pVDev->Pop();
1050 else
1052 DBG_ERROR("sd::View::CreatePageVDev(), virt. device creation failed!");
1055 return pVDev;
1060 /*************************************************************************
1062 |* OLE-Obj am Client connecten
1064 \************************************************************************/
1066 void View::DoConnect(SdrOle2Obj* pObj)
1068 if (mpViewSh)
1070 uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
1071 if( xObj.is() )
1073 ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1074 SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
1075 if ( !pSdClient )
1077 pSdClient = new Client(pObj, mpViewSh, pWindow);
1078 Rectangle aRect = pObj->GetLogicRect();
1080 // TODO/LEAN: working with visual area can switch object to running state
1081 Size aDrawSize = aRect.GetSize();
1082 awt::Size aSz;
1084 MapMode aMapMode( mpDoc->GetScaleUnit() );
1085 Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
1087 Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
1088 Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
1089 aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
1090 aScaleHeight.ReduceInaccurate(10);
1091 pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
1093 // sichtbarer Ausschnitt wird nur inplace veraendert!
1094 // the object area must be set after the scaling, since it triggers resize
1095 aRect.SetSize(aObjAreaSize);
1096 pSdClient->SetObjArea(aRect);
1103 /*************************************************************************
1107 \************************************************************************/
1109 BOOL View::IsMorphingAllowed() const
1111 const SdrMarkList& rMarkList = GetMarkedObjectList();
1112 BOOL bRet = FALSE;
1114 if ( rMarkList.GetMarkCount() == 2 )
1116 const SdrObject* pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1117 const SdrObject* pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
1118 const UINT16 nKind1 = pObj1->GetObjIdentifier();
1119 const UINT16 nKind2 = pObj2->GetObjIdentifier();
1121 if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
1122 ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
1123 ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
1124 ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
1125 ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
1126 ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
1127 ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
1128 ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
1129 ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
1130 ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
1131 ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
1132 ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
1133 ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
1134 ( nKind1 != OBJ_CAPTION && nKind2 != OBJ_CAPTION ) &&
1135 !pObj1->ISA( E3dObject) && !pObj2->ISA( E3dObject) )
1137 SfxItemSet aSet1( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1138 SfxItemSet aSet2( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1140 aSet1.Put(pObj1->GetMergedItemSet());
1141 aSet2.Put(pObj2->GetMergedItemSet());
1143 const XFillStyle eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
1144 const XFillStyle eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
1146 if( ( eFillStyle1 == XFILL_NONE || eFillStyle1 == XFILL_SOLID ) &&
1147 ( eFillStyle2 == XFILL_NONE || eFillStyle2 == XFILL_SOLID ) )
1148 bRet = TRUE;
1152 return bRet;
1155 /*************************************************************************
1159 \************************************************************************/
1161 BOOL View::IsVectorizeAllowed() const
1163 const SdrMarkList& rMarkList = GetMarkedObjectList();
1164 BOOL bRet = FALSE;
1166 if( rMarkList.GetMarkCount() == 1 )
1168 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1170 if( pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
1171 bRet = TRUE;
1174 return bRet;
1177 void View::onAccessibilityOptionsChanged()
1179 if( mpViewSh )
1181 ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1182 if( pWindow )
1184 const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1186 USHORT nOutputSlot, nPreviewSlot;
1188 SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
1190 if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
1192 if( rStyleSettings.GetHighContrastMode() )
1194 nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
1196 else
1198 nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
1201 if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
1203 nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
1205 else
1207 nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
1210 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SFX_CALLMODE_ASYNCHRON );
1211 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
1214 mpViewSh->Invalidate();
1219 IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner *, pOutliner )
1221 Paragraph* pPara = pOutliner->GetHdlParagraph();
1222 SdrObject* pObj = GetTextEditObject();
1224 if( pPara && pObj )
1226 SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1227 if( pPage )
1228 pPage->onParagraphInserted( pOutliner, pPara, pObj );
1230 return 0;
1233 /*************************************************************************
1235 |* Handler fuer das Loeschen von Seiten (Absaetzen)
1237 \************************************************************************/
1239 IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
1241 Paragraph* pPara = pOutliner->GetHdlParagraph();
1242 SdrObject* pObj = GetTextEditObject();
1244 if( pPara && pObj )
1246 SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1247 if( pPage )
1248 pPage->onParagraphRemoving( pOutliner, pPara, pObj );
1250 return 0;
1253 bool View::isRecordingUndo() const
1255 if( mpDoc && mpDoc->IsUndoEnabled() )
1257 sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
1258 return pUndoManager && pUndoManager->isInListAction();
1260 else
1262 return false;
1266 void View::AddCustomHdl()
1268 maSmartTags.addCustomHandles( aHdl );
1271 void View::updateHandles()
1273 AdjustMarkHdl();
1276 SdrViewContext View::GetContext() const
1278 SdrViewContext eContext = SDRCONTEXT_STANDARD;
1279 if( maSmartTags.getContext( eContext ) )
1280 return eContext;
1281 else
1282 return FmFormView::GetContext();
1285 BOOL View::HasMarkablePoints() const
1287 if( maSmartTags.HasMarkablePoints() )
1288 return true;
1289 else
1290 return FmFormView::HasMarkablePoints();
1293 ULONG View::GetMarkablePointCount() const
1295 ULONG nCount = FmFormView::GetMarkablePointCount();
1296 nCount += maSmartTags.GetMarkablePointCount();
1297 return nCount;
1300 BOOL View::HasMarkedPoints() const
1302 if( maSmartTags.HasMarkedPoints() )
1303 return true;
1304 else
1305 return FmFormView::HasMarkedPoints();
1308 ULONG View::GetMarkedPointCount() const
1310 ULONG nCount = FmFormView::GetMarkedPointCount();
1311 nCount += maSmartTags.GetMarkedPointCount();
1312 return nCount;
1315 BOOL View::IsPointMarkable(const SdrHdl& rHdl) const
1317 if( maSmartTags.IsPointMarkable( rHdl ) )
1318 return true;
1319 else
1320 return FmFormView::IsPointMarkable( rHdl );
1323 BOOL View::MarkPoint(SdrHdl& rHdl, BOOL bUnmark )
1325 if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
1326 return true;
1327 else
1328 return FmFormView::MarkPoint( rHdl, bUnmark );
1331 BOOL View::MarkPoints(const Rectangle* pRect, BOOL bUnmark)
1333 if( maSmartTags.MarkPoints( pRect, bUnmark ) )
1334 return true;
1335 else
1336 return FmFormView::MarkPoints( pRect, bUnmark );
1339 void View::CheckPossibilities()
1341 FmFormView::CheckPossibilities();
1342 maSmartTags.CheckPossibilities();
1345 void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
1349 /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
1350 get the correct style sheet. */
1351 void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
1353 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
1354 SdrOutliner* pOutliner = GetTextEditOutliner();
1355 if( pOutliner && pTextObj && pTextObj->GetPage() )
1357 SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
1359 SfxStyleSheet* pStyleSheet = 0;
1361 const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
1362 if( eKind != PRESOBJ_NONE )
1363 pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
1364 else
1365 pStyleSheet = pTextObj->GetStyleSheet();
1367 if( eKind == PRESOBJ_OUTLINE )
1369 // for outline shapes, set the correct outline style sheet for each
1370 // new paragraph, depending on the paragraph depth
1371 SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
1373 for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1375 sal_Int16 nDepth = pOutliner->GetDepth( nPara );
1377 SfxStyleSheet* pStyle = 0;
1378 if( nDepth > 0 )
1380 String aStyleSheetName( pStyleSheet->GetName() );
1381 aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
1382 aStyleSheetName += String::CreateFromInt32( nDepth );
1383 pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
1384 DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
1387 if( !pStyle )
1388 pStyle = pStyleSheet;
1390 pOutliner->SetStyleSheet( nPara, pStyle );
1393 else
1395 // just put the object style on each new paragraph
1396 for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1398 pOutliner->SetStyleSheet( nPara, pStyleSheet );
1404 } // end of namespace sd