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