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