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