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