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