1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <com/sun/star/i18n/WordType.hpp> 32 33 #include <svtools/accessibilityoptions.hxx> 34 35 #include <svx/svdedxv.hxx> 36 #include <svl/solar.hrc> 37 38 //#include <tools/string.h> 39 #include <svl/itemiter.hxx> 40 #include <vcl/msgbox.hxx> 41 #include <vcl/hatch.hxx> 42 #include <svl/whiter.hxx> 43 #include <svl/style.hxx> 44 #include <editeng/editstat.hxx> 45 #include <tools/config.hxx> 46 #include <vcl/cursor.hxx> 47 #include <editeng/unotext.hxx> 48 49 #include <editeng/editeng.hxx> 50 #include <editeng/editobj.hxx> 51 #include <editeng/outlobj.hxx> 52 #include <editeng/scripttypeitem.hxx> 53 #include "svx/svditext.hxx" 54 #include <svx/svdoutl.hxx> 55 #include <svx/sdtfchim.hxx> 56 #include <svx/svdotext.hxx> 57 #include <svx/svdundo.hxx> 58 #include "svx/svditer.hxx" 59 #include "svx/svdpagv.hxx" 60 #include "svx/svdpage.hxx" 61 #include "svx/svdetc.hxx" // fuer GetDraftFillColor 62 #include "svx/svdotable.hxx" 63 #include <svx/selectioncontroller.hxx> 64 #ifdef DBG_UTIL 65 #include <svdibrow.hxx> 66 #endif 67 68 #include <svx/svdoutl.hxx> 69 #include <svx/svddrgv.hxx> // fuer SetSolidDragging() 70 #include "svx/svdstr.hrc" // Namen aus der Resource 71 #include "svx/svdglob.hxx" // StringCache 72 #include "svx/globl3d.hxx" 73 #include <editeng/outliner.hxx> 74 #include <editeng/adjitem.hxx> 75 76 // #98988# 77 #include <svtools/colorcfg.hxx> 78 #include <vcl/svapp.hxx> //add CHINA001 79 #include <svx/sdrpaintwindow.hxx> 80 81 //////////////////////////////////////////////////////////////////////////////////////////////////// 82 83 void SdrObjEditView::ImpClearVars() 84 { 85 bQuickTextEditMode=sal_True; 86 bMacroMode=sal_True; 87 pTextEditOutliner=NULL; 88 pTextEditOutlinerView=NULL; 89 pTextEditPV=NULL; 90 pTextEditWin=NULL; 91 pTextEditCursorMerker=NULL; 92 pEditPara=NULL; 93 bTextEditNewObj=sal_False; 94 bMacroDown=sal_False; 95 pMacroObj=NULL; 96 pMacroPV=NULL; 97 pMacroWin=NULL; 98 nMacroTol=0; 99 bTextEditDontDelete=sal_False; 100 bTextEditOnlyOneView=sal_False; 101 } 102 103 SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut): 104 SdrGlueEditView(pModel1,pOut) 105 { 106 ImpClearVars(); 107 } 108 109 SdrObjEditView::~SdrObjEditView() 110 { 111 pTextEditWin = NULL; // Damit es in SdrEndTextEdit kein ShowCursor gibt 112 if (IsTextEdit()) SdrEndTextEdit(); 113 if (pTextEditOutliner!=NULL) { 114 delete pTextEditOutliner; 115 } 116 } 117 118 //////////////////////////////////////////////////////////////////////////////////////////////////// 119 120 sal_Bool SdrObjEditView::IsAction() const 121 { 122 return IsMacroObj() || SdrGlueEditView::IsAction(); 123 } 124 125 void SdrObjEditView::MovAction(const Point& rPnt) 126 { 127 if (IsMacroObj()) MovMacroObj(rPnt); 128 SdrGlueEditView::MovAction(rPnt); 129 } 130 131 void SdrObjEditView::EndAction() 132 { 133 if (IsMacroObj()) EndMacroObj(); 134 SdrGlueEditView::EndAction(); 135 } 136 137 void SdrObjEditView::BckAction() 138 { 139 BrkMacroObj(); 140 SdrGlueEditView::BckAction(); 141 } 142 143 void SdrObjEditView::BrkAction() 144 { 145 BrkMacroObj(); 146 SdrGlueEditView::BrkAction(); 147 } 148 149 void SdrObjEditView::TakeActionRect(Rectangle& rRect) const 150 { 151 if (IsMacroObj()) { 152 rRect=pMacroObj->GetCurrentBoundRect(); 153 } else { 154 SdrGlueEditView::TakeActionRect(rRect); 155 } 156 } 157 158 void __EXPORT SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 159 { 160 SdrGlueEditView::Notify(rBC,rHint); 161 // Printerwechsel waerend des Editierens 162 SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint); 163 if (pSdrHint!=NULL && pTextEditOutliner!=NULL) { 164 SdrHintKind eKind=pSdrHint->GetKind(); 165 if (eKind==HINT_REFDEVICECHG) { 166 pTextEditOutliner->SetRefDevice(pMod->GetRefDevice()); 167 } 168 if (eKind==HINT_DEFAULTTABCHG) { 169 pTextEditOutliner->SetDefTab(pMod->GetDefaultTabulator()); 170 } 171 if (eKind==HINT_DEFFONTHGTCHG) { 172 // ... 173 } 174 if (eKind==HINT_MODELSAVED) { // #43095# 175 pTextEditOutliner->ClearModifyFlag(); 176 } 177 } 178 } 179 180 void SdrObjEditView::ModelHasChanged() 181 { 182 SdrGlueEditView::ModelHasChanged(); 183 if (mxTextEditObj.is() && !mxTextEditObj->IsInserted()) SdrEndTextEdit(); // Objekt geloescht 184 // TextEditObj geaendert? 185 if (IsTextEdit()) { 186 SdrTextObj* pTextObj=dynamic_cast<SdrTextObj*>( mxTextEditObj.get() ); 187 if (pTextObj!=NULL) { 188 sal_uIntPtr nOutlViewAnz=pTextEditOutliner->GetViewCount(); 189 sal_Bool bAreaChg=sal_False; 190 sal_Bool bAnchorChg=sal_False; 191 sal_Bool bColorChg=sal_False; 192 bool bContourFrame=pTextObj->IsContourTextFrame(); 193 EVAnchorMode eNewAnchor(ANCHOR_VCENTER_HCENTER); 194 Rectangle aOldArea(aMinTextEditArea); 195 aOldArea.Union(aTextEditArea); 196 Color aNewColor; 197 { // Area Checken 198 Size aPaperMin1; 199 Size aPaperMax1; 200 Rectangle aEditArea1; 201 Rectangle aMinArea1; 202 pTextObj->TakeTextEditArea(&aPaperMin1,&aPaperMax1,&aEditArea1,&aMinArea1); 203 204 // #108784# 205 Point aPvOfs(pTextObj->GetTextEditOffset()); 206 207 aEditArea1.Move(aPvOfs.X(),aPvOfs.Y()); 208 aMinArea1.Move(aPvOfs.X(),aPvOfs.Y()); 209 Rectangle aNewArea(aMinArea1); 210 aNewArea.Union(aEditArea1); 211 if (aNewArea!=aOldArea || aEditArea1!=aTextEditArea || aMinArea1!=aMinTextEditArea || 212 pTextEditOutliner->GetMinAutoPaperSize()!=aPaperMin1 || pTextEditOutliner->GetMaxAutoPaperSize()!=aPaperMax1) { 213 aTextEditArea=aEditArea1; 214 aMinTextEditArea=aMinArea1; 215 pTextEditOutliner->SetUpdateMode(sal_False); 216 pTextEditOutliner->SetMinAutoPaperSize(aPaperMin1); 217 pTextEditOutliner->SetMaxAutoPaperSize(aPaperMax1); 218 pTextEditOutliner->SetPaperSize(Size(0,0)); // Damit der Outliner neu formatiert 219 if (!bContourFrame) { 220 pTextEditOutliner->ClearPolygon(); 221 sal_uIntPtr nStat=pTextEditOutliner->GetControlWord(); 222 nStat|=EE_CNTRL_AUTOPAGESIZE; 223 pTextEditOutliner->SetControlWord(nStat); 224 } else { 225 sal_uIntPtr nStat=pTextEditOutliner->GetControlWord(); 226 nStat&=~EE_CNTRL_AUTOPAGESIZE; 227 pTextEditOutliner->SetControlWord(nStat); 228 Rectangle aAnchorRect; 229 pTextObj->TakeTextAnchorRect(aAnchorRect); 230 pTextObj->ImpSetContourPolygon(*pTextEditOutliner,aAnchorRect, sal_True); 231 } 232 for (sal_uIntPtr nOV=0; nOV<nOutlViewAnz; nOV++) { 233 OutlinerView* pOLV=pTextEditOutliner->GetView(nOV); 234 sal_uIntPtr nStat0=pOLV->GetControlWord(); 235 sal_uIntPtr nStat=nStat0; 236 // AutoViewSize nur wenn nicht KontourFrame. 237 if (!bContourFrame) nStat|=EV_CNTRL_AUTOSIZE; 238 else nStat&=~EV_CNTRL_AUTOSIZE; 239 if (nStat!=nStat0) pOLV->SetControlWord(nStat); 240 } 241 pTextEditOutliner->SetUpdateMode(sal_True); 242 bAreaChg=sal_True; 243 } 244 } 245 if (pTextEditOutlinerView!=NULL) { // Fuellfarbe und Anker checken 246 EVAnchorMode eOldAnchor=pTextEditOutlinerView->GetAnchorMode(); 247 eNewAnchor=(EVAnchorMode)pTextObj->GetOutlinerViewAnchorMode(); 248 bAnchorChg=eOldAnchor!=eNewAnchor; 249 Color aOldColor(pTextEditOutlinerView->GetBackgroundColor()); 250 aNewColor = GetTextEditBackgroundColor(*this); 251 bColorChg=aOldColor!=aNewColor; 252 } 253 // #104082# refresh always when it's a contour frame. That 254 // refresh is necessary since it triggers the repaint 255 // which makes the Handles visible. Changes at TakeTextRect() 256 // seem to have resulted in a case where no refresh is executed. 257 // Before that, a refresh must have been always executed 258 // (else this error would have happend earlier), thus i 259 // even think here a refresh should be done always. 260 // Since follow-up problems cannot even be guessed I only 261 // add this one more case to the if below. 262 // BTW: It's VERY bad style that here, inside ModelHasChanged() 263 // the outliner is again massively changed for the text object 264 // in text edit mode. Normally, all necessary data should be 265 // set at SdrBeginTextEdit(). Some changes and value assigns in 266 // SdrBeginTextEdit() are completely useless since they are set here 267 // again on ModelHasChanged(). 268 if (bContourFrame || bAreaChg || bAnchorChg || bColorChg) 269 { 270 for (sal_uIntPtr nOV=0; nOV<nOutlViewAnz; nOV++) 271 { 272 OutlinerView* pOLV=pTextEditOutliner->GetView(nOV); 273 { // Alten OutlinerView-Bereich invalidieren 274 Window* pWin=pOLV->GetWindow(); 275 Rectangle aTmpRect(aOldArea); 276 sal_uInt16 nPixSiz=pOLV->GetInvalidateMore()+1; 277 Size aMore(pWin->PixelToLogic(Size(nPixSiz,nPixSiz))); 278 aTmpRect.Left()-=aMore.Width(); 279 aTmpRect.Right()+=aMore.Width(); 280 aTmpRect.Top()-=aMore.Height(); 281 aTmpRect.Bottom()+=aMore.Height(); 282 InvalidateOneWin(*pWin,aTmpRect); 283 } 284 if (bAnchorChg) 285 pOLV->SetAnchorMode(eNewAnchor); 286 if (bColorChg) 287 pOLV->SetBackgroundColor( aNewColor ); 288 289 pOLV->SetOutputArea(aTextEditArea); // weil sonst scheinbar nicht richtig umgeankert wird 290 ImpInvalidateOutlinerView(*pOLV); 291 } 292 pTextEditOutlinerView->ShowCursor(); 293 } 294 } 295 ImpMakeTextCursorAreaVisible(); 296 } 297 } 298 299 //////////////////////////////////////////////////////////////////////////////////////////////////// 300 // 301 // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@@ @@@@@ @@ @@@@@@ 302 // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ 303 // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 304 // @@ @@@@ @@@ @@ @@@@ @@ @@ @@ @@ 305 // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 306 // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ 307 // @@ @@@@@ @@ @@ @@ @@@@@ @@@@@ @@ @@ 308 // 309 //////////////////////////////////////////////////////////////////////////////////////////////////// 310 311 void SdrObjEditView::ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect) const 312 { 313 Window* pWin = rOutlView.GetWindow(); 314 315 if(pWin) 316 { 317 const SdrTextObj* pText = PTR_CAST(SdrTextObj,GetTextEditObject()); 318 bool bTextFrame(pText && pText->IsTextFrame()); 319 bool bFitToSize(0 != (pTextEditOutliner->GetControlWord() & EE_CNTRL_STRETCHING)); 320 bool bModifyMerk(pTextEditOutliner->IsModified()); // #43095# 321 Rectangle aBlankRect(rOutlView.GetOutputArea()); 322 aBlankRect.Union(aMinTextEditArea); 323 Rectangle aPixRect(pWin->LogicToPixel(aBlankRect)); 324 aBlankRect.Intersection(rRect); 325 rOutlView.GetOutliner()->SetUpdateMode(sal_True); // Bugfix #22596# 326 rOutlView.Paint(aBlankRect); 327 328 if(!bModifyMerk) 329 { 330 // #43095# 331 pTextEditOutliner->ClearModifyFlag(); 332 } 333 334 if(bTextFrame && !bFitToSize) 335 { 336 aPixRect.Left()--; 337 aPixRect.Top()--; 338 aPixRect.Right()++; 339 aPixRect.Bottom()++; 340 sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1); 341 342 { 343 // xPixRect Begrenzen, wegen Treiberproblem bei zu weit hinausragenden Pixelkoordinaten 344 Size aMaxXY(pWin->GetOutputSizePixel()); 345 long a(2 * nPixSiz); 346 long nMaxX(aMaxXY.Width() + a); 347 long nMaxY(aMaxXY.Height() + a); 348 349 if (aPixRect.Left ()<-a) aPixRect.Left()=-a; 350 if (aPixRect.Top ()<-a) aPixRect.Top ()=-a; 351 if (aPixRect.Right ()>nMaxX) aPixRect.Right ()=nMaxX; 352 if (aPixRect.Bottom()>nMaxY) aPixRect.Bottom()=nMaxY; 353 } 354 355 Rectangle aOuterPix(aPixRect); 356 aOuterPix.Left()-=nPixSiz; 357 aOuterPix.Top()-=nPixSiz; 358 aOuterPix.Right()+=nPixSiz; 359 aOuterPix.Bottom()+=nPixSiz; 360 361 bool bMerk(pWin->IsMapModeEnabled()); 362 pWin->EnableMapMode(sal_False); 363 PolyPolygon aPolyPoly( 2 ); 364 365 svtools::ColorConfig aColorConfig; 366 Color aHatchCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 367 const Hatch aHatch( HATCH_SINGLE, aHatchCol, 3, 450 ); 368 369 aPolyPoly.Insert( aOuterPix ); 370 aPolyPoly.Insert( aPixRect ); 371 pWin->DrawHatch( aPolyPoly, aHatch ); 372 373 pWin->EnableMapMode(bMerk); 374 } 375 376 rOutlView.ShowCursor(); 377 } 378 } 379 380 void SdrObjEditView::ImpInvalidateOutlinerView(OutlinerView& rOutlView) const 381 { 382 Window* pWin = rOutlView.GetWindow(); 383 384 if(pWin) 385 { 386 const SdrTextObj* pText = PTR_CAST(SdrTextObj,GetTextEditObject()); 387 bool bTextFrame(pText && pText->IsTextFrame()); 388 bool bFitToSize(0 != (pTextEditOutliner->GetControlWord() & EE_CNTRL_STRETCHING)); 389 390 if(bTextFrame && !bFitToSize) 391 { 392 Rectangle aBlankRect(rOutlView.GetOutputArea()); 393 aBlankRect.Union(aMinTextEditArea); 394 Rectangle aPixRect(pWin->LogicToPixel(aBlankRect)); 395 sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1); 396 397 aPixRect.Left()--; 398 aPixRect.Top()--; 399 aPixRect.Right()++; 400 aPixRect.Bottom()++; 401 402 { 403 // xPixRect Begrenzen, wegen Treiberproblem bei zu weit hinausragenden Pixelkoordinaten 404 Size aMaxXY(pWin->GetOutputSizePixel()); 405 long a(2 * nPixSiz); 406 long nMaxX(aMaxXY.Width() + a); 407 long nMaxY(aMaxXY.Height() + a); 408 409 if (aPixRect.Left ()<-a) aPixRect.Left()=-a; 410 if (aPixRect.Top ()<-a) aPixRect.Top ()=-a; 411 if (aPixRect.Right ()>nMaxX) aPixRect.Right ()=nMaxX; 412 if (aPixRect.Bottom()>nMaxY) aPixRect.Bottom()=nMaxY; 413 } 414 415 Rectangle aOuterPix(aPixRect); 416 aOuterPix.Left()-=nPixSiz; 417 aOuterPix.Top()-=nPixSiz; 418 aOuterPix.Right()+=nPixSiz; 419 aOuterPix.Bottom()+=nPixSiz; 420 421 bool bMerk(pWin->IsMapModeEnabled()); 422 pWin->EnableMapMode(sal_False); 423 pWin->Invalidate(aOuterPix); 424 pWin->EnableMapMode(bMerk); 425 } 426 } 427 } 428 429 OutlinerView* SdrObjEditView::ImpMakeOutlinerView(Window* pWin, sal_Bool /*bNoPaint*/, OutlinerView* pGivenView) const 430 { 431 // Hintergrund 432 Color aBackground(GetTextEditBackgroundColor(*this)); 433 SdrTextObj* pText = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() ); 434 sal_Bool bTextFrame=pText!=NULL && pText->IsTextFrame(); 435 sal_Bool bContourFrame=pText!=NULL && pText->IsContourTextFrame(); 436 // OutlinerView erzeugen 437 OutlinerView* pOutlView=pGivenView; 438 pTextEditOutliner->SetUpdateMode(sal_False); 439 if (pOutlView==NULL) pOutlView=new OutlinerView(pTextEditOutliner,pWin); 440 else pOutlView->SetWindow(pWin); 441 // Scrollen verbieten 442 sal_uIntPtr nStat=pOutlView->GetControlWord(); 443 nStat&=~EV_CNTRL_AUTOSCROLL; 444 // AutoViewSize nur wenn nicht KontourFrame. 445 if (!bContourFrame) nStat|=EV_CNTRL_AUTOSIZE; 446 if (bTextFrame) { 447 sal_uInt16 nPixSiz=aHdl.GetHdlSize()*2+1; 448 nStat|=EV_CNTRL_INVONEMORE; 449 pOutlView->SetInvalidateMore(nPixSiz); 450 } 451 pOutlView->SetControlWord(nStat); 452 pOutlView->SetBackgroundColor( aBackground ); 453 if (pText!=NULL) 454 { 455 pOutlView->SetAnchorMode((EVAnchorMode)(pText->GetOutlinerViewAnchorMode())); 456 pTextEditOutliner->SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)pText->GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); 457 } 458 pOutlView->SetOutputArea(aTextEditArea); 459 pTextEditOutliner->SetUpdateMode(sal_True); 460 ImpInvalidateOutlinerView(*pOutlView); 461 return pOutlView; 462 } 463 464 sal_Bool SdrObjEditView::IsTextEditFrame() const 465 { 466 SdrTextObj* pText = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); 467 return pText!=NULL && pText->IsTextFrame(); 468 } 469 470 IMPL_LINK(SdrObjEditView,ImpOutlinerStatusEventHdl,EditStatus*,pEditStat) 471 { 472 if(pTextEditOutliner ) 473 { 474 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() ); 475 if( pTextObj ) 476 { 477 pTextObj->onEditOutlinerStatusEvent( pEditStat ); 478 } 479 } 480 return 0; 481 } 482 483 IMPL_LINK(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI) 484 { 485 bool bOk=false; 486 String& rStr=pFI->GetRepresentation(); 487 rStr.Erase(); 488 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); 489 if (pTextObj!=NULL) { 490 Color* pTxtCol=NULL; 491 Color* pFldCol=NULL; 492 bOk=pTextObj->CalcFieldValue(pFI->GetField(),pFI->GetPara(),pFI->GetPos(),sal_True,pTxtCol,pFldCol,rStr); 493 if (bOk) { 494 if (pTxtCol!=NULL) { 495 pFI->SetTxtColor(*pTxtCol); 496 delete pTxtCol; 497 } 498 if (pFldCol!=NULL) { 499 pFI->SetFldColor(*pFldCol); 500 delete pFldCol; 501 } else { 502 pFI->SetFldColor(Color(COL_LIGHTGRAY)); // kann spaeter (357) raus 503 } 504 } 505 } 506 Outliner& rDrawOutl=pMod->GetDrawOutliner(pTextObj); 507 Link aDrawOutlLink=rDrawOutl.GetCalcFieldValueHdl(); 508 if (!bOk && aDrawOutlLink.IsSet()) { 509 aDrawOutlLink.Call(pFI); 510 bOk = (sal_Bool)rStr.Len(); 511 } 512 if (!bOk && aOldCalcFieldValueLink.IsSet()) { 513 return aOldCalcFieldValueLink.Call(pFI); 514 } 515 return 0; 516 } 517 518 sal_Bool SdrObjEditView::SdrBeginTextEdit( 519 SdrObject* pObj, SdrPageView* pPV, Window* pWin, 520 sal_Bool bIsNewObj, SdrOutliner* pGivenOutliner, 521 OutlinerView* pGivenOutlinerView, 522 sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView, 523 sal_Bool bGrabFocus) 524 { 525 SdrEndTextEdit(); 526 527 if( dynamic_cast< SdrTextObj* >( pObj ) == 0 ) 528 return sal_False; // currently only possible with text objects 529 530 if(bGrabFocus && pWin) 531 { 532 // attetion, this call may cause an EndTextEdit() call to this view 533 pWin->GrabFocus(); // to force the cursor into the edit view 534 } 535 536 bTextEditDontDelete=bDontDeleteOutliner && pGivenOutliner!=NULL; 537 bTextEditOnlyOneView=bOnlyOneView; 538 bTextEditNewObj=bIsNewObj; 539 const sal_uInt32 nWinAnz(PaintWindowCount()); 540 sal_uInt32 i; 541 sal_Bool bBrk(sal_False); 542 // Abbruch, wenn kein Objekt angegeben. 543 544 if(!pObj) 545 { 546 bBrk = sal_True; 547 } 548 549 if(!bBrk && !pWin) 550 { 551 for(i = 0L; i < nWinAnz && !pWin; i++) 552 { 553 SdrPaintWindow* pPaintWindow = GetPaintWindow(i); 554 555 if(OUTDEV_WINDOW == pPaintWindow->GetOutputDevice().GetOutDevType()) 556 { 557 pWin = (Window*)(&pPaintWindow->GetOutputDevice()); 558 } 559 } 560 561 // Abbruch, wenn kein Window da. 562 if(!pWin) 563 { 564 bBrk = sal_True; 565 } 566 } 567 568 if(!bBrk && !pPV) 569 { 570 pPV = GetSdrPageView(); 571 572 // Abbruch, wenn keine PageView zu dem Objekt vorhanden. 573 if(!pPV) 574 { 575 bBrk = sal_True; 576 } 577 } 578 579 if(pObj && pPV) 580 { 581 // Kein TextEdit an Objekten im gesperrten Layer 582 if(pPV->GetLockedLayers().IsSet(pObj->GetLayer())) 583 { 584 bBrk = sal_True; 585 } 586 } 587 588 if(pTextEditOutliner) 589 { 590 DBG_ERROR("SdrObjEditView::SdrBeginTextEdit() da stand noch ein alter Outliner rum"); 591 delete pTextEditOutliner; 592 pTextEditOutliner = 0L; 593 } 594 595 if(!bBrk) 596 { 597 pTextEditWin=pWin; 598 pTextEditPV=pPV; 599 mxTextEditObj.reset( pObj ); 600 pTextEditOutliner=pGivenOutliner; 601 if (pTextEditOutliner==NULL) 602 pTextEditOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, mxTextEditObj->GetModel() ); 603 604 { 605 SvtAccessibilityOptions aOptions; 606 pTextEditOutliner->ForceAutoColor( aOptions.GetIsAutomaticFontColor() ); 607 } 608 609 sal_Bool bEmpty = mxTextEditObj->GetOutlinerParaObject()==NULL; 610 611 aOldCalcFieldValueLink=pTextEditOutliner->GetCalcFieldValueHdl(); 612 // Der FieldHdl muss von SdrBeginTextEdit gesetzt sein, da dor ein UpdateFields gerufen wird. 613 pTextEditOutliner->SetCalcFieldValueHdl(LINK(this,SdrObjEditView,ImpOutlinerCalcFieldValueHdl)); 614 pTextEditOutliner->SetBeginPasteOrDropHdl(LINK(this,SdrObjEditView,BeginPasteOrDropHdl)); 615 pTextEditOutliner->SetEndPasteOrDropHdl(LINK(this,SdrObjEditView, EndPasteOrDropHdl)); 616 617 // It is just necessary to make the visualized page known. Set it. 618 pTextEditOutliner->setVisualizedPage(pPV ? pPV->GetPage() : 0); 619 620 pTextEditOutliner->SetTextObjNoInit( dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ) ); 621 622 if(mxTextEditObj->BegTextEdit(*pTextEditOutliner)) 623 { 624 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); 625 DBG_ASSERT( pTextObj, "svx::SdrObjEditView::BegTextEdit(), no text object?" ); 626 if( !pTextObj ) 627 return sal_False; 628 629 // #111096# Switch off evtl. running TextAnimation 630 pTextObj->SetTextAnimationAllowed(sal_False); 631 632 // alten Cursor merken 633 if (pTextEditOutliner->GetViewCount()!=0) 634 { 635 OutlinerView* pTmpOLV=pTextEditOutliner->RemoveView(sal_uIntPtr(0)); 636 if(pTmpOLV!=NULL && pTmpOLV!=pGivenOutlinerView) 637 delete pTmpOLV; 638 } 639 640 // EditArea ueberTakeTextEditArea bestimmen 641 // Das koennte eigentlich entfallen, da TakeTextRect() die Berechnung der aTextEditArea vornimmt 642 // Die aMinTextEditArea muss jedoch wohl auch erfolgen (darum bleibt es voerst drinnen) 643 pTextObj->TakeTextEditArea(NULL,NULL,&aTextEditArea,&aMinTextEditArea); 644 645 Rectangle aTextRect; 646 Rectangle aAnchorRect; 647 pTextObj->TakeTextRect(*pTextEditOutliner, aTextRect, sal_True, 648 &aAnchorRect /* #97097# Give sal_True here, not sal_False */); 649 650 if ( !pTextObj->IsContourTextFrame() ) 651 { 652 // FitToSize erstmal nicht mit ContourFrame 653 SdrFitToSizeType eFit = pTextObj->GetFitToSize(); 654 if (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES) 655 aTextRect = aAnchorRect; 656 } 657 658 aTextEditArea = aTextRect; 659 660 // #108784# 661 Point aPvOfs(pTextObj->GetTextEditOffset()); 662 663 aTextEditArea.Move(aPvOfs.X(),aPvOfs.Y()); 664 aMinTextEditArea.Move(aPvOfs.X(),aPvOfs.Y()); 665 pTextEditCursorMerker=pWin->GetCursor(); 666 667 aHdl.SetMoveOutside(sal_True); 668 669 // #i72757# 670 // Since IsMarkHdlWhenTextEdit() is ignored, it is necessary 671 // to call AdjustMarkHdl() always. 672 AdjustMarkHdl(); 673 674 pTextEditOutlinerView=ImpMakeOutlinerView(pWin,!bEmpty,pGivenOutlinerView); 675 676 // check if this view is already inserted 677 sal_uIntPtr i2,nCount = pTextEditOutliner->GetViewCount(); 678 for( i2 = 0; i2 < nCount; i2++ ) 679 { 680 if( pTextEditOutliner->GetView(i2) == pTextEditOutlinerView ) 681 break; 682 } 683 684 if( i2 == nCount ) 685 pTextEditOutliner->InsertView(pTextEditOutlinerView,0); 686 687 aHdl.SetMoveOutside(sal_False); 688 aHdl.SetMoveOutside(sal_True); 689 //OLMRefreshAllIAOManagers(); 690 691 // alle Wins als OutlinerView beim Outliner anmelden 692 if(!bOnlyOneView) 693 { 694 for(i = 0L; i < nWinAnz; i++) 695 { 696 SdrPaintWindow* pPaintWindow = GetPaintWindow(i); 697 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 698 699 if(&rOutDev != pWin && OUTDEV_WINDOW == rOutDev.GetOutDevType()) 700 { 701 OutlinerView* pOutlView = ImpMakeOutlinerView((Window*)(&rOutDev), !bEmpty, 0L); 702 pTextEditOutliner->InsertView(pOutlView, (sal_uInt16)i); 703 } 704 } 705 } 706 707 pTextEditOutlinerView->ShowCursor(); 708 pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl)); 709 #ifdef DBG_UTIL 710 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 711 #endif 712 pTextEditOutliner->ClearModifyFlag(); 713 714 // #71519#, #91453# 715 if(pWin) 716 { 717 sal_Bool bExtraInvalidate(sal_False); 718 719 // #71519# 720 if(!bExtraInvalidate) 721 { 722 SdrFitToSizeType eFit = pTextObj->GetFitToSize(); 723 if(eFit == SDRTEXTFIT_PROPORTIONAL || eFit == SDRTEXTFIT_ALLLINES) 724 bExtraInvalidate = sal_True; 725 } 726 727 if(bExtraInvalidate) 728 { 729 pWin->Invalidate(aTextEditArea); 730 } 731 } 732 733 // send HINT_BEGEDIT #99840# 734 if( GetModel() ) 735 { 736 SdrHint aHint(*pTextObj); 737 aHint.SetKind(HINT_BEGEDIT); 738 GetModel()->Broadcast(aHint); 739 } 740 741 pTextEditOutliner->setVisualizedPage(0); 742 743 if( mxSelectionController.is() ) 744 mxSelectionController->onSelectionHasChanged(); 745 746 return sal_True; // Gut gelaufen, TextEdit laeuft nun 747 } 748 else 749 { 750 bBrk = sal_True; 751 pTextEditOutliner->SetCalcFieldValueHdl(aOldCalcFieldValueLink); 752 pTextEditOutliner->SetBeginPasteOrDropHdl(Link()); 753 pTextEditOutliner->SetEndPasteOrDropHdl(Link()); 754 755 } 756 } 757 if (pTextEditOutliner != NULL) 758 { 759 pTextEditOutliner->setVisualizedPage(0); 760 } 761 762 // wenn hier angekommen, dann ist irgendwas schief gelaufen 763 if(!bDontDeleteOutliner) 764 { 765 if(pGivenOutliner!=NULL) 766 { 767 delete pGivenOutliner; 768 pTextEditOutliner = NULL; 769 } 770 if(pGivenOutlinerView!=NULL) 771 { 772 delete pGivenOutlinerView; 773 pGivenOutlinerView = NULL; 774 } 775 } 776 if( pTextEditOutliner!=NULL ) 777 { 778 delete pTextEditOutliner; 779 } 780 781 pTextEditOutliner=NULL; 782 pTextEditOutlinerView=NULL; 783 mxTextEditObj.reset(0); 784 pTextEditPV=NULL; 785 pTextEditWin=NULL; 786 //HMHif (bMarkHdlWhenTextEdit) { 787 //HMH HideMarkHdl(); 788 //HMH} 789 aHdl.SetMoveOutside(sal_False); 790 //HMHShowMarkHdl(); 791 792 return sal_False; 793 } 794 795 SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally) 796 { 797 SdrEndTextEditKind eRet=SDRENDTEXTEDIT_UNCHANGED; 798 SdrTextObj* pTEObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); 799 Window* pTEWin =pTextEditWin; 800 SdrOutliner* pTEOutliner =pTextEditOutliner; 801 OutlinerView* pTEOutlinerView=pTextEditOutlinerView; 802 Cursor* pTECursorMerker=pTextEditCursorMerker; 803 804 // send HINT_ENDEDIT #99840# 805 if( GetModel() && mxTextEditObj.is() ) 806 { 807 SdrHint aHint(*mxTextEditObj.get()); 808 aHint.SetKind(HINT_ENDEDIT); 809 GetModel()->Broadcast(aHint); 810 } 811 812 mxTextEditObj.reset(0); 813 pTextEditPV=NULL; 814 pTextEditWin=NULL; 815 pTextEditOutliner=NULL; 816 pTextEditOutlinerView=NULL; 817 pTextEditCursorMerker=NULL; 818 aTextEditArea=Rectangle(); 819 820 if (pTEOutliner!=NULL) 821 { 822 sal_Bool bModified=pTEOutliner->IsModified(); 823 if (pTEOutlinerView!=NULL) 824 { 825 pTEOutlinerView->HideCursor(); 826 } 827 if (pTEObj!=NULL) 828 { 829 pTEOutliner->CompleteOnlineSpelling(); 830 831 SdrUndoObjSetText* pTxtUndo = 0; 832 833 if( bModified ) 834 { 835 sal_Int32 nText; 836 for( nText = 0; nText < pTEObj->getTextCount(); ++nText ) 837 if( pTEObj->getText( nText ) == pTEObj->getActiveText() ) 838 break; 839 840 pTxtUndo = dynamic_cast< SdrUndoObjSetText* >( GetModel()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTEObj, nText ) ); 841 } 842 DBG_ASSERT( !bModified || pTxtUndo, "svx::SdrObjEditView::EndTextEdit(), could not create undo action!" ); 843 // Den alten CalcFieldValue-Handler wieder setzen 844 // Muss vor Obj::EndTextEdit() geschehen, da dort ein UpdateFields() gemacht wird. 845 pTEOutliner->SetCalcFieldValueHdl(aOldCalcFieldValueLink); 846 pTEOutliner->SetBeginPasteOrDropHdl(Link()); 847 pTEOutliner->SetEndPasteOrDropHdl(Link()); 848 849 const bool bUndo = IsUndoEnabled(); 850 if( bUndo ) 851 { 852 XubString aObjName; 853 pTEObj->TakeObjNameSingul(aObjName); 854 BegUndo(ImpGetResStr(STR_UndoObjSetText),aObjName); 855 } 856 857 pTEObj->EndTextEdit(*pTEOutliner); 858 859 if( (pTEObj->GetRotateAngle() != 0) || (pTEObj && pTEObj->ISA(SdrTextObj) && ((SdrTextObj*)pTEObj)->IsFontwork()) ) 860 { 861 // obviously a repaint 862 pTEObj->ActionChanged(); 863 } 864 865 if (pTxtUndo!=NULL) 866 { 867 pTxtUndo->AfterSetText(); 868 if (!pTxtUndo->IsDifferent()) 869 { 870 delete pTxtUndo; 871 pTxtUndo=NULL; 872 } 873 } 874 // Loeschung des gesamten TextObj checken 875 SdrUndoAction* pDelUndo=NULL; 876 sal_Bool bDelObj=sal_False; 877 SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pTEObj); 878 if (pTextObj!=NULL && bTextEditNewObj) 879 { 880 bDelObj=pTextObj->IsTextFrame() && 881 !pTextObj->HasText() && 882 !pTextObj->IsEmptyPresObj() && 883 !pTextObj->HasFill() && 884 !pTextObj->HasLine(); 885 886 if(pTEObj->IsInserted() && bDelObj && pTextObj->GetObjInventor()==SdrInventor && !bDontDeleteReally) 887 { 888 SdrObjKind eIdent=(SdrObjKind)pTextObj->GetObjIdentifier(); 889 if(eIdent==OBJ_TEXT || eIdent==OBJ_TEXTEXT) 890 { 891 pDelUndo= GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pTEObj); 892 } 893 } 894 } 895 if (pTxtUndo!=NULL) 896 { 897 if( bUndo ) 898 AddUndo(pTxtUndo); 899 eRet=SDRENDTEXTEDIT_CHANGED; 900 } 901 if (pDelUndo!=NULL) 902 { 903 if( bUndo ) 904 { 905 AddUndo(pDelUndo); 906 } 907 else 908 { 909 delete pDelUndo; 910 } 911 eRet=SDRENDTEXTEDIT_DELETED; 912 DBG_ASSERT(pTEObj->GetObjList()!=NULL,"SdrObjEditView::SdrEndTextEdit(): Fatal: Editiertes Objekt hat keine ObjList!"); 913 if (pTEObj->GetObjList()!=NULL) 914 { 915 pTEObj->GetObjList()->RemoveObject(pTEObj->GetOrdNum()); 916 CheckMarked(); // und gleich die Maekierung entfernen... 917 } 918 } 919 else if (bDelObj) 920 { // Fuer den Writer: Loeschen muss die App nachholen. 921 eRet=SDRENDTEXTEDIT_SHOULDBEDELETED; 922 } 923 924 if( bUndo ) 925 EndUndo(); // EndUndo hinter Remove, falls der UndoStack gleich weggehaun' wird 926 927 // #111096# 928 // Switch on evtl. TextAnimation again after TextEdit 929 if(pTEObj->ISA(SdrTextObj)) 930 { 931 ((SdrTextObj*)pTEObj)->SetTextAnimationAllowed(sal_True); 932 } 933 934 // #i72757# 935 // Since IsMarkHdlWhenTextEdit() is ignored, it is necessary 936 // to call AdjustMarkHdl() always. 937 AdjustMarkHdl(); 938 } 939 // alle OutlinerViews loeschen 940 for (sal_uIntPtr i=pTEOutliner->GetViewCount(); i>0;) 941 { 942 i--; 943 OutlinerView* pOLV=pTEOutliner->GetView(i); 944 sal_uInt16 nMorePix=pOLV->GetInvalidateMore() + 10; // solaris aw033 test #i# 945 Window* pWin=pOLV->GetWindow(); 946 Rectangle aRect(pOLV->GetOutputArea()); 947 pTEOutliner->RemoveView(i); 948 if (!bTextEditDontDelete || i!=0) 949 { 950 // die nullte gehoert mir u.U. nicht. 951 delete pOLV; 952 } 953 aRect.Union(aTextEditArea); 954 aRect.Union(aMinTextEditArea); 955 aRect=pWin->LogicToPixel(aRect); 956 aRect.Left()-=nMorePix; 957 aRect.Top()-=nMorePix; 958 aRect.Right()+=nMorePix; 959 aRect.Bottom()+=nMorePix; 960 aRect=pWin->PixelToLogic(aRect); 961 InvalidateOneWin(*pWin,aRect); 962 // pWin->Invalidate(INVALIDATE_UPDATE); 963 964 // pWin->Update(); 965 // pWin->Flush(); 966 pWin->SetFillColor(); 967 pWin->SetLineColor(COL_BLACK); 968 pWin->DrawPixel(aRect.TopLeft()); 969 pWin->DrawPixel(aRect.TopRight()); 970 pWin->DrawPixel(aRect.BottomLeft()); 971 pWin->DrawPixel(aRect.BottomRight()); 972 //pWin->DrawRect(aRect); 973 } 974 // und auch den Outliner selbst 975 if (!bTextEditDontDelete) delete pTEOutliner; 976 else pTEOutliner->Clear(); 977 if (pTEWin!=NULL) { 978 pTEWin->SetCursor(pTECursorMerker); 979 } 980 //HMH if (bMarkHdlWhenTextEdit) { 981 //HMH HideMarkHdl(); 982 //HMH } 983 aHdl.SetMoveOutside(sal_False); 984 if (eRet!=SDRENDTEXTEDIT_UNCHANGED) 985 //HMH { 986 //HMH ShowMarkHdl(); // Handles kommen ansonsten via Broadcast 987 //HMH } 988 //HMH else 989 { 990 GetMarkedObjectListWriteAccess().SetNameDirty(); 991 } 992 #ifdef DBG_UTIL 993 if (pItemBrowser) 994 { 995 GetMarkedObjectListWriteAccess().SetNameDirty(); 996 pItemBrowser->SetDirty(); 997 } 998 #endif 999 } 1000 1001 // #108784# 1002 if( pTEObj && 1003 pTEObj->GetModel() && 1004 !pTEObj->GetModel()->isLocked() && 1005 pTEObj->GetBroadcaster()) 1006 { 1007 SdrHint aHint(HINT_ENDEDIT); 1008 aHint.SetObject(pTEObj); 1009 ((SfxBroadcaster*)pTEObj->GetBroadcaster())->Broadcast(aHint); 1010 } 1011 1012 return eRet; 1013 } 1014 1015 //////////////////////////////////////////////////////////////////////////////////////////////////// 1016 // info about TextEdit. Default is sal_False. 1017 bool SdrObjEditView::IsTextEdit() const 1018 { 1019 return mxTextEditObj.is(); 1020 } 1021 1022 // info about TextEditPageView. Default is 0L. 1023 SdrPageView* SdrObjEditView::GetTextEditPageView() const 1024 { 1025 return pTextEditPV; 1026 } 1027 1028 //////////////////////////////////////////////////////////////////////////////////////////////////// 1029 1030 OutlinerView* SdrObjEditView::ImpFindOutlinerView(Window* pWin) const 1031 { 1032 if (pWin==NULL) return NULL; 1033 if (pTextEditOutliner==NULL) return NULL; 1034 OutlinerView* pNewView=NULL; 1035 sal_uIntPtr nWinAnz=pTextEditOutliner->GetViewCount(); 1036 for (sal_uIntPtr i=0; i<nWinAnz && pNewView==NULL; i++) { 1037 OutlinerView* pView=pTextEditOutliner->GetView(i); 1038 if (pView->GetWindow()==pWin) pNewView=pView; 1039 } 1040 return pNewView; 1041 } 1042 1043 void SdrObjEditView::SetTextEditWin(Window* pWin) 1044 { 1045 if(mxTextEditObj.is() && pWin!=NULL && pWin!=pTextEditWin) 1046 { 1047 OutlinerView* pNewView=ImpFindOutlinerView(pWin); 1048 if (pNewView!=NULL && pNewView!=pTextEditOutlinerView) 1049 { 1050 if (pTextEditOutlinerView!=NULL) 1051 { 1052 pTextEditOutlinerView->HideCursor(); 1053 } 1054 pTextEditOutlinerView=pNewView; 1055 pTextEditWin=pWin; 1056 pWin->GrabFocus(); // Damit der Cursor hier auch blinkt 1057 pNewView->ShowCursor(); 1058 ImpMakeTextCursorAreaVisible(); 1059 } 1060 } 1061 } 1062 1063 sal_Bool SdrObjEditView::IsTextEditHit(const Point& rHit, short nTol) const 1064 { 1065 sal_Bool bOk=sal_False; 1066 if(mxTextEditObj.is()) 1067 { 1068 nTol=ImpGetHitTolLogic(nTol,NULL); 1069 // nur drittel Toleranz hier, damit die Handles 1070 // noch vernuenftig getroffen werden koennen 1071 nTol=nTol/3; 1072 nTol=0; // Joe am 6.3.1997: Keine Hittoleranz mehr hier 1073 if (!bOk) 1074 { 1075 Rectangle aEditArea; 1076 OutlinerView* pOLV=pTextEditOutliner->GetView(0); 1077 if (pOLV!=NULL) 1078 { 1079 aEditArea.Union(pOLV->GetOutputArea()); 1080 } 1081 aEditArea.Left()-=nTol; 1082 aEditArea.Top()-=nTol; 1083 aEditArea.Right()+=nTol; 1084 aEditArea.Bottom()+=nTol; 1085 bOk=aEditArea.IsInside(rHit); 1086 if (bOk) 1087 { // Nun noch checken, ob auch wirklich Buchstaben getroffen wurden 1088 Point aPnt(rHit); aPnt-=aEditArea.TopLeft(); 1089 long nHitTol = 2000; 1090 OutputDevice* pRef = pTextEditOutliner->GetRefDevice(); 1091 if( pRef ) 1092 nHitTol = pRef->LogicToLogic( nHitTol, MAP_100TH_MM, pRef->GetMapMode().GetMapUnit() ); 1093 1094 bOk = pTextEditOutliner->IsTextPos( aPnt, (sal_uInt16)nHitTol ); 1095 } 1096 } 1097 } 1098 return bOk; 1099 } 1100 1101 sal_Bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const 1102 { 1103 sal_Bool bOk=sal_False; 1104 if(mxTextEditObj.is()) 1105 { 1106 SdrTextObj* pText= dynamic_cast<SdrTextObj*>(mxTextEditObj.get()); 1107 OutlinerView* pOLV=pTextEditOutliner->GetView(0); 1108 if( pOLV ) 1109 { 1110 Window* pWin=pOLV->GetWindow(); 1111 if (pText!=NULL && pText->IsTextFrame() && pOLV!=NULL && pWin!=NULL) { 1112 sal_uInt16 nPixSiz=pOLV->GetInvalidateMore(); 1113 Rectangle aEditArea(aMinTextEditArea); 1114 aEditArea.Union(pOLV->GetOutputArea()); 1115 if (!aEditArea.IsInside(rHit)) { 1116 Size aSiz(pWin->PixelToLogic(Size(nPixSiz,nPixSiz))); 1117 aEditArea.Left()-=aSiz.Width(); 1118 aEditArea.Top()-=aSiz.Height(); 1119 aEditArea.Right()+=aSiz.Width(); 1120 aEditArea.Bottom()+=aSiz.Height(); 1121 bOk=aEditArea.IsInside(rHit); 1122 } 1123 } 1124 } 1125 } 1126 return bOk; 1127 } 1128 1129 void SdrObjEditView::AddTextEditOfs(MouseEvent& rMEvt) const 1130 { 1131 if(mxTextEditObj.is()) 1132 { 1133 Point aPvOfs; 1134 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ); 1135 1136 if( pTextObj ) 1137 { 1138 // #108784# 1139 aPvOfs += pTextObj->GetTextEditOffset(); 1140 } 1141 1142 Point aObjOfs(mxTextEditObj->GetLogicRect().TopLeft()); 1143 (Point&)(rMEvt.GetPosPixel())+=aPvOfs+aObjOfs; 1144 } 1145 } 1146 1147 //////////////////////////////////////////////////////////////////////////////////////////////////// 1148 1149 sal_Bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, Window* pWin) 1150 { 1151 if(pTextEditOutlinerView) 1152 { 1153 #ifdef DBG_UTIL 1154 if(rKEvt.GetKeyCode().GetCode() == KEY_RETURN && pTextEditOutliner->GetParagraphCount() == 1) 1155 { 1156 ByteString aLine( 1157 pTextEditOutliner->GetText(pTextEditOutliner->GetParagraph( 0 ), 1), 1158 gsl_getSystemTextEncoding()); 1159 aLine = aLine.ToUpperAscii(); 1160 1161 if(aLine == "HELLO JOE, PLEASE SHOW THE ITEMBROWSER") 1162 ShowItemBrowser(); 1163 } 1164 #endif 1165 if (pTextEditOutlinerView->PostKeyEvent(rKEvt)) 1166 { 1167 if( pMod /* && !pMod->IsChanged() */ ) 1168 { 1169 if( pTextEditOutliner && pTextEditOutliner->IsModified() ) 1170 pMod->SetChanged( sal_True ); 1171 } 1172 1173 if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin); 1174 #ifdef DBG_UTIL 1175 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1176 #endif 1177 ImpMakeTextCursorAreaVisible(); 1178 return sal_True; 1179 } 1180 } 1181 return SdrGlueEditView::KeyInput(rKEvt,pWin); 1182 } 1183 1184 sal_Bool SdrObjEditView::MouseButtonDown(const MouseEvent& rMEvt, Window* pWin) 1185 { 1186 if (pTextEditOutlinerView!=NULL) { 1187 sal_Bool bPostIt=pTextEditOutliner->IsInSelectionMode(); 1188 if (!bPostIt) { 1189 Point aPt(rMEvt.GetPosPixel()); 1190 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt); 1191 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt); 1192 bPostIt=IsTextEditHit(aPt,nHitTolLog); 1193 } 1194 if (bPostIt) { 1195 Point aPixPos(rMEvt.GetPosPixel()); 1196 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea())); 1197 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left (); 1198 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right (); 1199 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top (); 1200 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom(); 1201 MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(), 1202 rMEvt.GetButtons(),rMEvt.GetModifier()); 1203 if (pTextEditOutlinerView->MouseButtonDown(aMEvt)) { 1204 if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin); 1205 #ifdef DBG_UTIL 1206 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1207 #endif 1208 ImpMakeTextCursorAreaVisible(); 1209 return sal_True; 1210 } 1211 } 1212 } 1213 return SdrGlueEditView::MouseButtonDown(rMEvt,pWin); 1214 } 1215 1216 sal_Bool SdrObjEditView::MouseButtonUp(const MouseEvent& rMEvt, Window* pWin) 1217 { 1218 if (pTextEditOutlinerView!=NULL) { 1219 sal_Bool bPostIt=pTextEditOutliner->IsInSelectionMode(); 1220 if (!bPostIt) { 1221 Point aPt(rMEvt.GetPosPixel()); 1222 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt); 1223 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt); 1224 bPostIt=IsTextEditHit(aPt,nHitTolLog); 1225 } 1226 if (bPostIt) { 1227 Point aPixPos(rMEvt.GetPosPixel()); 1228 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea())); 1229 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left (); 1230 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right (); 1231 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top (); 1232 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom(); 1233 MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(), 1234 rMEvt.GetButtons(),rMEvt.GetModifier()); 1235 if (pTextEditOutlinerView->MouseButtonUp(aMEvt)) { 1236 #ifdef DBG_UTIL 1237 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1238 #endif 1239 ImpMakeTextCursorAreaVisible(); 1240 return sal_True; 1241 } 1242 } 1243 } 1244 return SdrGlueEditView::MouseButtonUp(rMEvt,pWin); 1245 } 1246 1247 sal_Bool SdrObjEditView::MouseMove(const MouseEvent& rMEvt, Window* pWin) 1248 { 1249 if (pTextEditOutlinerView!=NULL) { 1250 sal_Bool bSelMode=pTextEditOutliner->IsInSelectionMode(); 1251 sal_Bool bPostIt=bSelMode; 1252 if (!bPostIt) { 1253 Point aPt(rMEvt.GetPosPixel()); 1254 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt); 1255 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt); 1256 bPostIt=IsTextEditHit(aPt,nHitTolLog); 1257 } 1258 if (bPostIt) { 1259 Point aPixPos(rMEvt.GetPosPixel()); 1260 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea())); 1261 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left (); 1262 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right (); 1263 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top (); 1264 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom(); 1265 MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(), 1266 rMEvt.GetButtons(),rMEvt.GetModifier()); 1267 if (pTextEditOutlinerView->MouseMove(aMEvt) && bSelMode) { 1268 #ifdef DBG_UTIL 1269 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1270 #endif 1271 ImpMakeTextCursorAreaVisible(); 1272 return sal_True; 1273 } 1274 } 1275 } 1276 return SdrGlueEditView::MouseMove(rMEvt,pWin); 1277 } 1278 1279 sal_Bool SdrObjEditView::Command(const CommandEvent& rCEvt, Window* pWin) 1280 { 1281 // solange bis die OutlinerView einen sal_Bool zurueckliefert 1282 // bekommt sie nur COMMAND_STARTDRAG 1283 if (pTextEditOutlinerView!=NULL) 1284 { 1285 if (rCEvt.GetCommand()==COMMAND_STARTDRAG) { 1286 sal_Bool bPostIt=pTextEditOutliner->IsInSelectionMode() || !rCEvt.IsMouseEvent(); 1287 if (!bPostIt && rCEvt.IsMouseEvent()) { 1288 Point aPt(rCEvt.GetMousePosPixel()); 1289 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt); 1290 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt); 1291 bPostIt=IsTextEditHit(aPt,nHitTolLog); 1292 } 1293 if (bPostIt) { 1294 Point aPixPos(rCEvt.GetMousePosPixel()); 1295 if (rCEvt.IsMouseEvent()) { 1296 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea())); 1297 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left (); 1298 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right (); 1299 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top (); 1300 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom(); 1301 } 1302 CommandEvent aCEvt(aPixPos,rCEvt.GetCommand(),rCEvt.IsMouseEvent()); 1303 // Command ist an der OutlinerView leider void 1304 pTextEditOutlinerView->Command(aCEvt); 1305 if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin); 1306 #ifdef DBG_UTIL 1307 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1308 #endif 1309 ImpMakeTextCursorAreaVisible(); 1310 return sal_True; 1311 } 1312 } 1313 else // if (rCEvt.GetCommand() == COMMAND_VOICE ) 1314 { 1315 pTextEditOutlinerView->Command(rCEvt); 1316 return sal_True; 1317 } 1318 } 1319 return SdrGlueEditView::Command(rCEvt,pWin); 1320 } 1321 1322 sal_Bool SdrObjEditView::Cut(sal_uIntPtr nFormat) 1323 { 1324 if (pTextEditOutliner!=NULL) { 1325 pTextEditOutlinerView->Cut(); 1326 #ifdef DBG_UTIL 1327 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1328 #endif 1329 ImpMakeTextCursorAreaVisible(); 1330 return sal_True; 1331 } else { 1332 return SdrGlueEditView::Cut(nFormat); 1333 } 1334 } 1335 1336 sal_Bool SdrObjEditView::Yank(sal_uIntPtr nFormat) 1337 { 1338 if (pTextEditOutliner!=NULL) { 1339 pTextEditOutlinerView->Copy(); 1340 return sal_True; 1341 } else { 1342 return SdrGlueEditView::Yank(nFormat); 1343 } 1344 } 1345 1346 sal_Bool SdrObjEditView::Paste(Window* pWin, sal_uIntPtr nFormat) 1347 { 1348 if (pTextEditOutliner!=NULL) { 1349 if (pWin!=NULL) { 1350 OutlinerView* pNewView=ImpFindOutlinerView(pWin); 1351 if (pNewView!=NULL) { 1352 pNewView->Paste(); 1353 } 1354 } else { 1355 pTextEditOutlinerView->Paste(); 1356 } 1357 #ifdef DBG_UTIL 1358 if (pItemBrowser!=NULL) pItemBrowser->SetDirty(); 1359 #endif 1360 ImpMakeTextCursorAreaVisible(); 1361 return sal_True; 1362 } else { 1363 return SdrGlueEditView::Paste(pWin,nFormat); 1364 } 1365 } 1366 1367 //////////////////////////////////////////////////////////////////////////////////////////////////// 1368 1369 sal_Bool SdrObjEditView::ImpIsTextEditAllSelected() const 1370 { 1371 sal_Bool bRet=sal_False; 1372 if (pTextEditOutliner!=NULL && pTextEditOutlinerView!=NULL) 1373 { 1374 if(SdrTextObj::HasTextImpl( pTextEditOutliner ) ) 1375 { 1376 const sal_uInt32 nParaAnz=pTextEditOutliner->GetParagraphCount(); 1377 Paragraph* pLastPara=pTextEditOutliner->GetParagraph( nParaAnz > 1 ? nParaAnz - 1 : 0 ); 1378 1379 ESelection aESel(pTextEditOutlinerView->GetSelection()); 1380 if (aESel.nStartPara==0 && aESel.nStartPos==0 && aESel.nEndPara==sal_uInt16(nParaAnz-1)) 1381 { 1382 XubString aStr(pTextEditOutliner->GetText(pLastPara)); 1383 1384 if(aStr.Len() == aESel.nEndPos) 1385 bRet = sal_True; 1386 } 1387 // und nun auch noch fuer den Fall, das rueckwaerts selektiert wurde 1388 if (!bRet && aESel.nEndPara==0 && aESel.nEndPos==0 && aESel.nStartPara==sal_uInt16(nParaAnz-1)) 1389 { 1390 XubString aStr(pTextEditOutliner->GetText(pLastPara)); 1391 1392 if(aStr.Len() == aESel.nStartPos) 1393 bRet = sal_True; 1394 } 1395 } 1396 else 1397 { 1398 bRet=sal_True; 1399 } 1400 } 1401 return bRet; 1402 } 1403 1404 void SdrObjEditView::ImpMakeTextCursorAreaVisible() 1405 { 1406 if (pTextEditOutlinerView!=NULL && pTextEditWin!=NULL) { 1407 Cursor* pCsr=pTextEditWin->GetCursor(); 1408 if (pCsr!=NULL) { 1409 Size aSiz(pCsr->GetSize()); 1410 if (aSiz.Width()!=0 && aSiz.Height()!=0) { // #38450# 1411 MakeVisible(Rectangle(pCsr->GetPos(),aSiz),*pTextEditWin); 1412 } 1413 } 1414 } 1415 } 1416 1417 sal_uInt16 SdrObjEditView::GetScriptType() const 1418 { 1419 sal_uInt16 nScriptType = 0; 1420 1421 if( IsTextEdit() ) 1422 { 1423 if( mxTextEditObj->GetOutlinerParaObject() ) 1424 nScriptType = mxTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType(); 1425 1426 if( pTextEditOutlinerView ) 1427 nScriptType = pTextEditOutlinerView->GetSelectedScriptType(); 1428 } 1429 else 1430 { 1431 sal_uInt32 nMarkCount( GetMarkedObjectCount() ); 1432 1433 for( sal_uInt32 i = 0; i < nMarkCount; i++ ) 1434 { 1435 OutlinerParaObject* pParaObj = GetMarkedObjectByIndex( i )->GetOutlinerParaObject(); 1436 1437 if( pParaObj ) 1438 { 1439 nScriptType |= pParaObj->GetTextObject().GetScriptType(); 1440 } 1441 } 1442 } 1443 1444 if( nScriptType == 0 ) 1445 nScriptType = SCRIPTTYPE_LATIN; 1446 1447 return nScriptType; 1448 } 1449 1450 /* new interface src537 */ 1451 sal_Bool SdrObjEditView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const 1452 { 1453 if( mxSelectionController.is() ) 1454 if( mxSelectionController->GetAttributes( rTargetSet, bOnlyHardAttr ) ) 1455 return sal_True; 1456 1457 if(IsTextEdit()) 1458 { 1459 DBG_ASSERT(pTextEditOutlinerView!=NULL,"SdrObjEditView::GetAttributes(): pTextEditOutlinerView=NULL"); 1460 DBG_ASSERT(pTextEditOutliner!=NULL,"SdrObjEditView::GetAttributes(): pTextEditOutliner=NULL"); 1461 1462 // #92389# take care of bOnlyHardAttr(!) 1463 if(!bOnlyHardAttr && mxTextEditObj->GetStyleSheet()) 1464 rTargetSet.Put(mxTextEditObj->GetStyleSheet()->GetItemSet()); 1465 1466 // add object attributes 1467 rTargetSet.Put( mxTextEditObj->GetMergedItemSet() ); 1468 1469 if( mxTextEditObj->GetOutlinerParaObject() ) 1470 rTargetSet.Put( SvxScriptTypeItem( mxTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType() ) ); 1471 1472 if(pTextEditOutlinerView) 1473 { 1474 // FALSE= InvalidItems nicht al Default, sondern als "Loecher" betrachten 1475 rTargetSet.Put(pTextEditOutlinerView->GetAttribs(), sal_False); 1476 rTargetSet.Put( SvxScriptTypeItem( pTextEditOutlinerView->GetSelectedScriptType() ), sal_False ); 1477 } 1478 1479 if(GetMarkedObjectCount()==1 && GetMarkedObjectByIndex(0)==mxTextEditObj.get()) 1480 { 1481 MergeNotPersistAttrFromMarked(rTargetSet, bOnlyHardAttr); 1482 } 1483 1484 return sal_True; 1485 } 1486 else 1487 { 1488 return SdrGlueEditView::GetAttributes(rTargetSet, bOnlyHardAttr); 1489 } 1490 } 1491 1492 sal_Bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll) 1493 { 1494 sal_Bool bRet=sal_False; 1495 sal_Bool bTextEdit=pTextEditOutlinerView!=NULL && mxTextEditObj.is(); 1496 sal_Bool bAllTextSelected=ImpIsTextEditAllSelected(); 1497 SfxItemSet* pModifiedSet=NULL; 1498 const SfxItemSet* pSet=&rSet; 1499 //const SvxAdjustItem* pParaJust=NULL; 1500 1501 if (!bTextEdit) 1502 { 1503 // Kein TextEdit aktiv -> alle Items ans Zeichenobjekt 1504 if( mxSelectionController.is() ) 1505 bRet=mxSelectionController->SetAttributes(*pSet,bReplaceAll ); 1506 1507 if( !bRet ) 1508 { 1509 bRet=SdrGlueEditView::SetAttributes(*pSet,bReplaceAll); 1510 } 1511 } 1512 else 1513 { 1514 #ifdef DBG_UTIL 1515 { 1516 sal_Bool bHasEEFeatureItems=sal_False; 1517 SfxItemIter aIter(rSet); 1518 const SfxPoolItem* pItem=aIter.FirstItem(); 1519 while (!bHasEEFeatureItems && pItem!=NULL) 1520 { 1521 if (!IsInvalidItem(pItem)) 1522 { 1523 sal_uInt16 nW=pItem->Which(); 1524 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) 1525 bHasEEFeatureItems=sal_True; 1526 } 1527 1528 pItem=aIter.NextItem(); 1529 } 1530 1531 if(bHasEEFeatureItems) 1532 { 1533 String aMessage; 1534 aMessage.AppendAscii("SdrObjEditView::SetAttributes(): Das setzen von EE_FEATURE-Items an der SdrView macht keinen Sinn! Es fuehrt nur zu Overhead und nicht mehr lesbaren Dokumenten."); 1535 InfoBox(NULL, aMessage).Execute(); 1536 } 1537 } 1538 #endif 1539 1540 sal_Bool bOnlyEEItems; 1541 sal_Bool bNoEEItems=!SearchOutlinerItems(*pSet,bReplaceAll,&bOnlyEEItems); 1542 // alles selektiert? -> Attrs auch an den Rahmen 1543 // und falls keine EEItems, dann Attrs nur an den Rahmen 1544 if (bAllTextSelected || bNoEEItems) 1545 { 1546 if( mxSelectionController.is() ) 1547 bRet=mxSelectionController->SetAttributes(*pSet,bReplaceAll ); 1548 1549 if( !bRet ) 1550 { 1551 const bool bUndo = IsUndoEnabled(); 1552 1553 if( bUndo ) 1554 { 1555 String aStr; 1556 ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); 1557 BegUndo(aStr); 1558 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get())); 1559 1560 // #i43537# 1561 // If this is a text object also rescue the OutlinerParaObject since 1562 // applying attributes to the object may change text layout when 1563 // multiple portions exist with multiple formats. If a OutlinerParaObject 1564 // really exists and needs to be rescued is evaluated in the undo 1565 // implementation itself. 1566 bool bRescueText = dynamic_cast< SdrTextObj* >(mxTextEditObj.get()); 1567 1568 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,!bNoEEItems || bRescueText)); 1569 EndUndo(); 1570 } 1571 1572 mxTextEditObj->SetMergedItemSetAndBroadcast(*pSet, bReplaceAll); 1573 1574 FlushComeBackTimer(); // Damit ModeHasChanged sofort kommt 1575 bRet=sal_True; 1576 } 1577 } 1578 else if (!bOnlyEEItems) 1579 { 1580 // sonst Set ggf. splitten 1581 // Es wird nun ein ItemSet aSet gemacht, in den die EE_Items von 1582 // *pSet nicht enhalten ist (ansonsten ist es eine Kopie). 1583 sal_uInt16* pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END); 1584 SfxItemSet aSet(pMod->GetItemPool(),pNewWhichTable); 1585 /*90353*/ delete[] pNewWhichTable; 1586 SfxWhichIter aIter(aSet); 1587 sal_uInt16 nWhich=aIter.FirstWhich(); 1588 while (nWhich!=0) 1589 { 1590 const SfxPoolItem* pItem; 1591 SfxItemState eState=pSet->GetItemState(nWhich,sal_False,&pItem); 1592 if (eState==SFX_ITEM_SET) aSet.Put(*pItem); 1593 nWhich=aIter.NextWhich(); 1594 } 1595 1596 1597 if( mxSelectionController.is() ) 1598 bRet=mxSelectionController->SetAttributes(aSet,bReplaceAll ); 1599 1600 if( !bRet ) 1601 { 1602 if( IsUndoEnabled() ) 1603 { 1604 String aStr; 1605 ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); 1606 BegUndo(aStr); 1607 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get())); 1608 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,false)); 1609 EndUndo(); 1610 } 1611 1612 mxTextEditObj->SetMergedItemSetAndBroadcast(aSet, bReplaceAll); 1613 1614 if (GetMarkedObjectCount()==1 && GetMarkedObjectByIndex(0)==mxTextEditObj.get()) 1615 { 1616 SetNotPersistAttrToMarked(aSet,bReplaceAll); 1617 } 1618 } 1619 FlushComeBackTimer(); 1620 bRet=sal_True; 1621 } 1622 if(!bNoEEItems) 1623 { 1624 // und nun die Attribute auch noch an die EditEngine 1625 if (bReplaceAll) { 1626 // Am Outliner kann man leider nur alle Attribute platthauen 1627 pTextEditOutlinerView->RemoveAttribs( sal_True ); 1628 } 1629 pTextEditOutlinerView->SetAttribs(rSet); 1630 1631 #ifdef DBG_UTIL 1632 if (pItemBrowser!=NULL) 1633 pItemBrowser->SetDirty(); 1634 #endif 1635 1636 ImpMakeTextCursorAreaVisible(); 1637 } 1638 bRet=sal_True; 1639 } 1640 if (pModifiedSet!=NULL) 1641 delete pModifiedSet; 1642 return bRet; 1643 } 1644 1645 SfxStyleSheet* SdrObjEditView::GetStyleSheet() const 1646 { 1647 SfxStyleSheet* pSheet = 0; 1648 1649 if( mxSelectionController.is() ) 1650 { 1651 if( mxSelectionController->GetStyleSheet( pSheet ) ) 1652 return pSheet; 1653 } 1654 1655 if ( pTextEditOutlinerView ) 1656 { 1657 pSheet = pTextEditOutlinerView->GetStyleSheet(); 1658 } 1659 else 1660 { 1661 pSheet = SdrGlueEditView::GetStyleSheet(); 1662 } 1663 return pSheet; 1664 } 1665 1666 sal_Bool SdrObjEditView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr) 1667 { 1668 if( mxSelectionController.is() ) 1669 { 1670 if( mxSelectionController->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr ) ) 1671 return sal_True; 1672 } 1673 1674 // if we are currently in edit mode we must also set the stylesheet 1675 // on all paragraphs in the Outliner for the edit view 1676 // #92191# 1677 if( NULL != pTextEditOutlinerView ) 1678 { 1679 Outliner* pOutliner = pTextEditOutlinerView->GetOutliner(); 1680 1681 const sal_uIntPtr nParaCount = pOutliner->GetParagraphCount(); 1682 sal_uIntPtr nPara; 1683 for( nPara = 0; nPara < nParaCount; nPara++ ) 1684 { 1685 pOutliner->SetStyleSheet( nPara, pStyleSheet ); 1686 } 1687 } 1688 1689 return SdrGlueEditView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); 1690 } 1691 1692 //////////////////////////////////////////////////////////////////////////////////////////////////// 1693 1694 void SdrObjEditView::AddWindowToPaintView(OutputDevice* pNewWin) 1695 { 1696 SdrGlueEditView::AddWindowToPaintView(pNewWin); 1697 1698 if(mxTextEditObj.is() && !bTextEditOnlyOneView && pNewWin->GetOutDevType()==OUTDEV_WINDOW) 1699 { 1700 OutlinerView* pOutlView=ImpMakeOutlinerView((Window*)pNewWin,sal_False,NULL); 1701 pTextEditOutliner->InsertView(pOutlView); 1702 } 1703 } 1704 1705 void SdrObjEditView::DeleteWindowFromPaintView(OutputDevice* pOldWin) 1706 { 1707 SdrGlueEditView::DeleteWindowFromPaintView(pOldWin); 1708 1709 if(mxTextEditObj.is() && !bTextEditOnlyOneView && pOldWin->GetOutDevType()==OUTDEV_WINDOW) 1710 { 1711 for (sal_uIntPtr i=pTextEditOutliner->GetViewCount(); i>0;) { 1712 i--; 1713 OutlinerView* pOLV=pTextEditOutliner->GetView(i); 1714 if (pOLV && pOLV->GetWindow()==(Window*)pOldWin) { 1715 delete pTextEditOutliner->RemoveView(i); 1716 } 1717 } 1718 } 1719 } 1720 1721 sal_Bool SdrObjEditView::IsTextEditInSelectionMode() const 1722 { 1723 return pTextEditOutliner!=NULL && pTextEditOutliner->IsInSelectionMode(); 1724 } 1725 1726 //////////////////////////////////////////////////////////////////////////////////////////////////// 1727 // 1728 // @@ @@ @@@@ @@@@ @@@@@ @@@@ @@ @@ @@@@ @@@@@ @@@@@ 1729 // @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ 1730 // @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ 1731 // @@@@@@@ @@@@@@ @@ @@@@@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@@@ 1732 // @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ 1733 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 1734 // @@ @@ @@ @@ @@@@ @@ @@ @@@@ @@ @@ @@@@ @@@@@ @@@@@ 1735 // 1736 //////////////////////////////////////////////////////////////////////////////////////////////////// 1737 1738 sal_Bool SdrObjEditView::BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, Window* pWin) 1739 { 1740 sal_Bool bRet=sal_False; 1741 BrkMacroObj(); 1742 if (pObj!=NULL && pPV!=NULL && pWin!=NULL && pObj->HasMacro()) { 1743 nTol=ImpGetHitTolLogic(nTol,NULL); 1744 pMacroObj=pObj; 1745 pMacroPV=pPV; 1746 pMacroWin=pWin; 1747 bMacroDown=sal_False; 1748 nMacroTol=sal_uInt16(nTol); 1749 aMacroDownPos=rPnt; 1750 MovMacroObj(rPnt); 1751 } 1752 return bRet; 1753 } 1754 1755 void SdrObjEditView::ImpMacroUp(const Point& rUpPos) 1756 { 1757 if (pMacroObj!=NULL && bMacroDown) 1758 { 1759 SdrObjMacroHitRec aHitRec; 1760 aHitRec.aPos=rUpPos; 1761 aHitRec.aDownPos=aMacroDownPos; 1762 aHitRec.nTol=nMacroTol; 1763 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers(); 1764 aHitRec.pPageView=pMacroPV; 1765 aHitRec.pOut=pMacroWin; 1766 pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec); 1767 bMacroDown=sal_False; 1768 } 1769 } 1770 1771 void SdrObjEditView::ImpMacroDown(const Point& rDownPos) 1772 { 1773 if (pMacroObj!=NULL && !bMacroDown) 1774 { 1775 SdrObjMacroHitRec aHitRec; 1776 aHitRec.aPos=rDownPos; 1777 aHitRec.aDownPos=aMacroDownPos; 1778 aHitRec.nTol=nMacroTol; 1779 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers(); 1780 aHitRec.pPageView=pMacroPV; 1781 aHitRec.bDown=sal_True; 1782 aHitRec.pOut=pMacroWin; 1783 pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec); 1784 bMacroDown=sal_True; 1785 } 1786 } 1787 1788 void SdrObjEditView::MovMacroObj(const Point& rPnt) 1789 { 1790 if (pMacroObj!=NULL) { 1791 SdrObjMacroHitRec aHitRec; 1792 aHitRec.aPos=rPnt; 1793 aHitRec.aDownPos=aMacroDownPos; 1794 aHitRec.nTol=nMacroTol; 1795 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers(); 1796 aHitRec.pPageView=pMacroPV; 1797 aHitRec.bDown=bMacroDown; 1798 aHitRec.pOut=pMacroWin; 1799 sal_Bool bDown=pMacroObj->IsMacroHit(aHitRec); 1800 if (bDown) ImpMacroDown(rPnt); 1801 else ImpMacroUp(rPnt); 1802 } 1803 } 1804 1805 void SdrObjEditView::BrkMacroObj() 1806 { 1807 if (pMacroObj!=NULL) { 1808 ImpMacroUp(aMacroDownPos); 1809 pMacroObj=NULL; 1810 pMacroPV=NULL; 1811 pMacroWin=NULL; 1812 } 1813 } 1814 1815 sal_Bool SdrObjEditView::EndMacroObj() 1816 { 1817 if (pMacroObj!=NULL && bMacroDown) { 1818 ImpMacroUp(aMacroDownPos); 1819 SdrObjMacroHitRec aHitRec; 1820 aHitRec.aPos=aMacroDownPos; 1821 aHitRec.aDownPos=aMacroDownPos; 1822 aHitRec.nTol=nMacroTol; 1823 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers(); 1824 aHitRec.pPageView=pMacroPV; 1825 aHitRec.bDown=sal_True; 1826 aHitRec.pOut=pMacroWin; 1827 bool bRet=pMacroObj->DoMacro(aHitRec); 1828 pMacroObj=NULL; 1829 pMacroPV=NULL; 1830 pMacroWin=NULL; 1831 return bRet; 1832 } else { 1833 BrkMacroObj(); 1834 return sal_False; 1835 } 1836 } 1837 1838 /** fills the given any with a XTextCursor for the current text selection. 1839 Leaves the any untouched if there currently is no text selected */ 1840 void SdrObjEditView::getTextSelection( ::com::sun::star::uno::Any& rSelection ) 1841 { 1842 if( IsTextEdit() ) 1843 { 1844 OutlinerView* pOutlinerView = GetTextEditOutlinerView(); 1845 if( pOutlinerView && pOutlinerView->HasSelection() ) 1846 { 1847 SdrObject* pObj = GetTextEditObject(); 1848 1849 if( pObj ) 1850 { 1851 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xText( pObj->getUnoShape(), ::com::sun::star::uno::UNO_QUERY ); 1852 if( xText.is() ) 1853 { 1854 SvxUnoTextBase* pRange = SvxUnoTextBase::getImplementation( xText ); 1855 if( pRange ) 1856 { 1857 rSelection <<= pRange->createTextCursorBySelection( pOutlinerView->GetSelection() ); 1858 } 1859 } 1860 } 1861 } 1862 } 1863 } 1864 1865 namespace sdr { namespace table { 1866 extern rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController ); 1867 } } 1868 1869 /* check if we have a single selection and that single object likes 1870 to handle the mouse and keyboard events itself 1871 1872 @todo: the selection controller should be queried from the 1873 object specific view contact. Currently this method only 1874 works for tables. 1875 */ 1876 void SdrObjEditView::MarkListHasChanged() 1877 { 1878 SdrGlueEditView::MarkListHasChanged(); 1879 1880 if( mxSelectionController.is() ) 1881 { 1882 mxLastSelectionController = mxSelectionController; 1883 mxSelectionController->onSelectionHasChanged(); 1884 } 1885 1886 mxSelectionController.clear(); 1887 1888 const SdrMarkList& rMarkList=GetMarkedObjectList(); 1889 if( rMarkList.GetMarkCount() == 1 ) 1890 { 1891 const SdrObject* pObj= rMarkList.GetMark(0)->GetMarkedSdrObj(); 1892 // check for table 1893 if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) ) 1894 { 1895 mxSelectionController = sdr::table::CreateTableController( this, pObj, mxLastSelectionController ); 1896 if( mxSelectionController.is() ) 1897 { 1898 mxLastSelectionController.clear(); 1899 mxSelectionController->onSelectionHasChanged(); 1900 } 1901 } 1902 } 1903 } 1904 1905 IMPL_LINK( SdrObjEditView, EndPasteOrDropHdl, PasteOrDropInfos*, pInfos ) 1906 { 1907 OnEndPasteOrDrop( pInfos ); 1908 return 0; 1909 } 1910 1911 IMPL_LINK( SdrObjEditView, BeginPasteOrDropHdl, PasteOrDropInfos*, pInfos ) 1912 { 1913 OnBeginPasteOrDrop( pInfos ); 1914 return 0; 1915 } 1916 1917 void SdrObjEditView::OnBeginPasteOrDrop( PasteOrDropInfos* ) 1918 { 1919 // applications can derive from these virtual methods to do something before a drop or paste operation 1920 } 1921 1922 void SdrObjEditView::OnEndPasteOrDrop( PasteOrDropInfos* ) 1923 { 1924 // applications can derive from these virtual methods to do something before a drop or paste operation 1925 } 1926 1927 bool SdrObjEditView::SupportsFormatPaintbrush( sal_uInt32 nObjectInventor, sal_uInt16 nObjectIdentifier ) const 1928 { 1929 if( nObjectInventor != SdrInventor && nObjectInventor != E3dInventor ) 1930 return false; 1931 switch(nObjectIdentifier) 1932 { 1933 case OBJ_NONE: 1934 case OBJ_GRUP: 1935 return false; 1936 case OBJ_LINE: 1937 case OBJ_RECT: 1938 case OBJ_CIRC: 1939 case OBJ_SECT: 1940 case OBJ_CARC: 1941 case OBJ_CCUT: 1942 case OBJ_POLY: 1943 case OBJ_PLIN: 1944 case OBJ_PATHLINE: 1945 case OBJ_PATHFILL: 1946 case OBJ_FREELINE: 1947 case OBJ_FREEFILL: 1948 case OBJ_SPLNLINE: 1949 case OBJ_SPLNFILL: 1950 case OBJ_TEXT: 1951 case OBJ_TEXTEXT: 1952 case OBJ_TITLETEXT: 1953 case OBJ_OUTLINETEXT: 1954 case OBJ_GRAF: 1955 case OBJ_OLE2: 1956 case OBJ_TABLE: 1957 return true; 1958 case OBJ_EDGE: 1959 case OBJ_CAPTION: 1960 return false; 1961 case OBJ_PATHPOLY: 1962 case OBJ_PATHPLIN: 1963 return true; 1964 case OBJ_PAGE: 1965 case OBJ_MEASURE: 1966 case OBJ_DUMMY: 1967 case OBJ_FRAME: 1968 case OBJ_UNO: 1969 return false; 1970 case OBJ_CUSTOMSHAPE: 1971 return true; 1972 default: 1973 return false; 1974 } 1975 } 1976 1977 static const sal_uInt16* GetFormatRangeImpl( bool bTextOnly ) 1978 { 1979 static const sal_uInt16 gRanges[] = { 1980 SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, 1981 SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, 1982 SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST, 1983 XATTR_LINE_FIRST, XATTR_LINE_LAST, 1984 XATTR_FILL_FIRST, XATTRSET_FILL, 1985 EE_PARA_START, EE_PARA_END, 1986 EE_CHAR_START, EE_CHAR_END, 1987 0,0 1988 }; 1989 return &gRanges[ bTextOnly ? 10 : 0]; 1990 } 1991 1992 bool SdrObjEditView::TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet ) 1993 { 1994 if( mxSelectionController.is() && mxSelectionController->TakeFormatPaintBrush(rFormatSet) ) 1995 return true; 1996 1997 const SdrMarkList& rMarkList = GetMarkedObjectList(); 1998 if( rMarkList.GetMarkCount() >= 1 ) 1999 { 2000 OutlinerView* pOLV = GetTextEditOutlinerView(); 2001 2002 rFormatSet.reset( new SfxItemSet( GetModel()->GetItemPool(), GetFormatRangeImpl( pOLV != NULL ) ) ); 2003 if( pOLV ) 2004 { 2005 rFormatSet->Put( pOLV->GetAttribs() ); 2006 } 2007 else 2008 { 2009 const sal_Bool bOnlyHardAttr = sal_False; 2010 rFormatSet->Put( GetAttrFromMarked(bOnlyHardAttr) ); 2011 } 2012 return true; 2013 } 2014 2015 return false; 2016 } 2017 2018 static SfxItemSet CreatePaintSet( const sal_uInt16 *pRanges, SfxItemPool& rPool, const SfxItemSet& rSourceSet, const SfxItemSet& rTargetSet, bool bNoCharacterFormats, bool bNoParagraphFormats ) 2019 { 2020 SfxItemSet aPaintSet( rPool, pRanges ); 2021 2022 while( *pRanges ) 2023 { 2024 sal_uInt16 nWhich = *pRanges++; 2025 const sal_uInt16 nLastWhich = *pRanges++; 2026 2027 if( bNoCharacterFormats && (nWhich == EE_CHAR_START) ) 2028 continue; 2029 2030 if( bNoParagraphFormats && (nWhich == EE_PARA_START ) ) 2031 continue; 2032 2033 for( ; nWhich < nLastWhich; nWhich++ ) 2034 { 2035 const SfxPoolItem* pSourceItem = rSourceSet.GetItem( nWhich ); 2036 const SfxPoolItem* pTargetItem = rTargetSet.GetItem( nWhich ); 2037 2038 if( (pSourceItem && !pTargetItem) || (pSourceItem && pTargetItem && !((*pSourceItem) == (*pTargetItem)) ) ) 2039 { 2040 aPaintSet.Put( *pSourceItem ); 2041 } 2042 } 2043 } 2044 return aPaintSet; 2045 } 2046 2047 void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats ) 2048 { 2049 OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; 2050 if(pParaObj) 2051 { 2052 SdrOutliner& rOutliner = rTextObj.ImpGetDrawOutliner(); 2053 rOutliner.SetText(*pParaObj); 2054 2055 sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); 2056 2057 if(nParaCount) 2058 { 2059 for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) 2060 { 2061 if( !bNoCharacterFormats ) 2062 rOutliner.QuickRemoveCharAttribs( nPara, /* remove all */0 ); 2063 2064 SfxItemSet aSet(rOutliner.GetParaAttribs(nPara)); 2065 aSet.Put(CreatePaintSet( GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) ); 2066 rOutliner.SetParaAttribs(nPara, aSet); 2067 } 2068 2069 OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); 2070 rOutliner.Clear(); 2071 2072 rTextObj.NbcSetOutlinerParaObjectForText(pTemp,pText); 2073 } 2074 } 2075 } 2076 2077 void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats ) 2078 { 2079 if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) ) 2080 { 2081 const SdrMarkList& rMarkList = GetMarkedObjectList(); 2082 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 2083 OutlinerView* pOLV = GetTextEditOutlinerView(); 2084 2085 const SfxItemSet& rShapeSet = pObj->GetMergedItemSet(); 2086 2087 if( !pOLV ) 2088 { 2089 // if not in text edit mode (aka the user selected text or clicked on a word) 2090 // apply formating attributes to selected shape 2091 // All formating items (see ranges above) that are unequal in selected shape and 2092 // the format paintbrush are hard set on the selected shape. 2093 2094 const sal_uInt16* pRanges = rFormatSet.GetRanges(); 2095 bool bTextOnly = true; 2096 2097 while( *pRanges ) 2098 { 2099 if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) ) 2100 { 2101 bTextOnly = false; 2102 break; 2103 } 2104 pRanges += 2; 2105 } 2106 2107 if( !bTextOnly ) 2108 { 2109 SfxItemSet aPaintSet( CreatePaintSet( GetFormatRangeImpl(false), *rShapeSet.GetPool(), rFormatSet, rShapeSet, bNoCharacterFormats, bNoParagraphFormats ) ); 2110 const sal_Bool bReplaceAll = sal_False; 2111 SetAttrToMarked(aPaintSet, bReplaceAll); 2112 } 2113 2114 // now apply character and paragraph formating to text, if the shape has any 2115 SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj); 2116 if( pTextObj ) 2117 { 2118 sal_Int32 nText = pTextObj->getTextCount(); 2119 2120 while( --nText >= 0 ) 2121 { 2122 SdrText* pText = pTextObj->getText( nText ); 2123 ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats ); 2124 } 2125 } 2126 } 2127 else 2128 { 2129 ::Outliner* pOutliner = pOLV->GetOutliner(); 2130 if( pOutliner ) 2131 { 2132 const EditEngine& rEditEngine = pOutliner->GetEditEngine(); 2133 2134 ESelection aSel( pOLV->GetSelection() ); 2135 if( !aSel.HasRange() ) 2136 pOLV->SetSelection( rEditEngine.GetWord( aSel, com::sun::star::i18n::WordType::DICTIONARY_WORD ) ); 2137 2138 const sal_Bool bRemoveParaAttribs = !bNoParagraphFormats; 2139 pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs ); 2140 SfxItemSet aSet( pOLV->GetAttribs() ); 2141 SfxItemSet aPaintSet( CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) ); 2142 pOLV->SetAttribs( aPaintSet ); 2143 } 2144 } 2145 } 2146 } 2147