Update ooo320-m1
[ooovba.git] / svx / source / svdraw / svdedxv.cxx
blobf6c15b0ba0f7b444c29a764d0b9e44329331d489
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdedxv.cxx,v $
10 * $Revision: 1.62 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svtools/accessibilityoptions.hxx>
35 #include <svx/svdedxv.hxx>
36 #include <svtools/solar.hrc>
38 //#include <tools/string.h>
39 #include <svtools/itemiter.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/hatch.hxx>
42 #include <svtools/whiter.hxx>
43 #include <svtools/style.hxx>
44 #include <editstat.hxx>
45 #include <tools/config.hxx>
46 #include <vcl/cursor.hxx>
47 #include <svx/unotext.hxx>
49 #include <svx/editobj.hxx>
50 #include <svx/outlobj.hxx>
51 #include <svx/scripttypeitem.hxx>
52 #include "svditext.hxx"
53 #include <svx/svdoutl.hxx>
54 #include <svx/sdtfchim.hxx>
55 #include <svx/svdotext.hxx>
56 #include <svx/svdundo.hxx>
57 #include "svditer.hxx"
58 #include "svx/svdpagv.hxx"
59 #include "svx/svdpage.hxx"
60 #include "svx/svdetc.hxx" // fuer GetDraftFillColor
61 #include "svx/svdotable.hxx"
62 #include <svx/selectioncontroller.hxx>
64 #ifdef DBG_UTIL
65 #include <svdibrow.hxx>
66 #endif
68 #include <svx/svdoutl.hxx>
69 #include <svx/svddrgv.hxx> // fuer SetSolidDragging()
70 #include "svdstr.hrc" // Namen aus der Resource
71 #include "svdglob.hxx" // StringCache
72 #include <svx/outliner.hxx>
73 #include <svx/adjitem.hxx>
75 // #98988#
76 #include <svtools/colorcfg.hxx>
77 #include <vcl/svapp.hxx> //add CHINA001
78 #include <sdrpaintwindow.hxx>
80 ////////////////////////////////////////////////////////////////////////////////////////////////////
82 void SdrObjEditView::ImpClearVars()
84 bQuickTextEditMode=TRUE;
85 bMacroMode=TRUE;
86 pTextEditOutliner=NULL;
87 pTextEditOutlinerView=NULL;
88 pTextEditPV=NULL;
89 pTextEditWin=NULL;
90 pTextEditCursorMerker=NULL;
91 pEditPara=NULL;
92 bTextEditNewObj=FALSE;
93 bMacroDown=FALSE;
94 pMacroObj=NULL;
95 pMacroPV=NULL;
96 pMacroWin=NULL;
97 nMacroTol=0;
98 bTextEditDontDelete=FALSE;
99 bTextEditOnlyOneView=FALSE;
102 SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
103 SdrGlueEditView(pModel1,pOut)
105 ImpClearVars();
108 SdrObjEditView::~SdrObjEditView()
110 pTextEditWin = NULL; // Damit es in SdrEndTextEdit kein ShowCursor gibt
111 if (IsTextEdit()) SdrEndTextEdit();
112 if (pTextEditOutliner!=NULL) {
113 delete pTextEditOutliner;
117 ////////////////////////////////////////////////////////////////////////////////////////////////////
119 BOOL SdrObjEditView::IsAction() const
121 return IsMacroObj() || SdrGlueEditView::IsAction();
124 void SdrObjEditView::MovAction(const Point& rPnt)
126 if (IsMacroObj()) MovMacroObj(rPnt);
127 SdrGlueEditView::MovAction(rPnt);
130 void SdrObjEditView::EndAction()
132 if (IsMacroObj()) EndMacroObj();
133 SdrGlueEditView::EndAction();
136 void SdrObjEditView::BckAction()
138 BrkMacroObj();
139 SdrGlueEditView::BckAction();
142 void SdrObjEditView::BrkAction()
144 BrkMacroObj();
145 SdrGlueEditView::BrkAction();
148 void SdrObjEditView::TakeActionRect(Rectangle& rRect) const
150 if (IsMacroObj()) {
151 rRect=pMacroObj->GetCurrentBoundRect();
152 } else {
153 SdrGlueEditView::TakeActionRect(rRect);
157 void __EXPORT SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
159 SdrGlueEditView::Notify(rBC,rHint);
160 // Printerwechsel waerend des Editierens
161 SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
162 if (pSdrHint!=NULL && pTextEditOutliner!=NULL) {
163 SdrHintKind eKind=pSdrHint->GetKind();
164 if (eKind==HINT_REFDEVICECHG) {
165 pTextEditOutliner->SetRefDevice(pMod->GetRefDevice());
167 if (eKind==HINT_DEFAULTTABCHG) {
168 pTextEditOutliner->SetDefTab(pMod->GetDefaultTabulator());
170 if (eKind==HINT_DEFFONTHGTCHG) {
171 // ...
173 if (eKind==HINT_MODELSAVED) { // #43095#
174 pTextEditOutliner->ClearModifyFlag();
179 void SdrObjEditView::ModelHasChanged()
181 SdrGlueEditView::ModelHasChanged();
182 if (mxTextEditObj.is() && !mxTextEditObj->IsInserted()) SdrEndTextEdit(); // Objekt geloescht
183 // TextEditObj geaendert?
184 if (IsTextEdit()) {
185 SdrTextObj* pTextObj=dynamic_cast<SdrTextObj*>( mxTextEditObj.get() );
186 if (pTextObj!=NULL) {
187 ULONG nOutlViewAnz=pTextEditOutliner->GetViewCount();
188 BOOL bAreaChg=FALSE;
189 BOOL bAnchorChg=FALSE;
190 BOOL bColorChg=FALSE;
191 bool bContourFrame=pTextObj->IsContourTextFrame();
192 EVAnchorMode eNewAnchor(ANCHOR_VCENTER_HCENTER);
193 Rectangle aOldArea(aMinTextEditArea);
194 aOldArea.Union(aTextEditArea);
195 Color aNewColor;
196 { // Area Checken
197 Size aPaperMin1;
198 Size aPaperMax1;
199 Rectangle aEditArea1;
200 Rectangle aMinArea1;
201 pTextObj->TakeTextEditArea(&aPaperMin1,&aPaperMax1,&aEditArea1,&aMinArea1);
203 // #108784#
204 Point aPvOfs(pTextObj->GetTextEditOffset());
206 aEditArea1.Move(aPvOfs.X(),aPvOfs.Y());
207 aMinArea1.Move(aPvOfs.X(),aPvOfs.Y());
208 Rectangle aNewArea(aMinArea1);
209 aNewArea.Union(aEditArea1);
210 if (aNewArea!=aOldArea || aEditArea1!=aTextEditArea || aMinArea1!=aMinTextEditArea ||
211 pTextEditOutliner->GetMinAutoPaperSize()!=aPaperMin1 || pTextEditOutliner->GetMaxAutoPaperSize()!=aPaperMax1) {
212 aTextEditArea=aEditArea1;
213 aMinTextEditArea=aMinArea1;
214 pTextEditOutliner->SetUpdateMode(FALSE);
215 pTextEditOutliner->SetMinAutoPaperSize(aPaperMin1);
216 pTextEditOutliner->SetMaxAutoPaperSize(aPaperMax1);
217 pTextEditOutliner->SetPaperSize(Size(0,0)); // Damit der Outliner neu formatiert
218 if (!bContourFrame) {
219 pTextEditOutliner->ClearPolygon();
220 ULONG nStat=pTextEditOutliner->GetControlWord();
221 nStat|=EE_CNTRL_AUTOPAGESIZE;
222 pTextEditOutliner->SetControlWord(nStat);
223 } else {
224 ULONG nStat=pTextEditOutliner->GetControlWord();
225 nStat&=~EE_CNTRL_AUTOPAGESIZE;
226 pTextEditOutliner->SetControlWord(nStat);
227 Rectangle aAnchorRect;
228 pTextObj->TakeTextAnchorRect(aAnchorRect);
229 pTextObj->ImpSetContourPolygon(*pTextEditOutliner,aAnchorRect, TRUE);
231 for (ULONG nOV=0; nOV<nOutlViewAnz; nOV++) {
232 OutlinerView* pOLV=pTextEditOutliner->GetView(nOV);
233 ULONG nStat0=pOLV->GetControlWord();
234 ULONG nStat=nStat0;
235 // AutoViewSize nur wenn nicht KontourFrame.
236 if (!bContourFrame) nStat|=EV_CNTRL_AUTOSIZE;
237 else nStat&=~EV_CNTRL_AUTOSIZE;
238 if (nStat!=nStat0) pOLV->SetControlWord(nStat);
240 pTextEditOutliner->SetUpdateMode(TRUE);
241 bAreaChg=TRUE;
244 if (pTextEditOutlinerView!=NULL) { // Fuellfarbe und Anker checken
245 EVAnchorMode eOldAnchor=pTextEditOutlinerView->GetAnchorMode();
246 eNewAnchor=(EVAnchorMode)pTextObj->GetOutlinerViewAnchorMode();
247 bAnchorChg=eOldAnchor!=eNewAnchor;
248 Color aOldColor(pTextEditOutlinerView->GetBackgroundColor());
249 aNewColor = GetTextEditBackgroundColor(*this);
250 bColorChg=aOldColor!=aNewColor;
252 // #104082# refresh always when it's a contour frame. That
253 // refresh is necessary since it triggers the repaint
254 // which makes the Handles visible. Changes at TakeTextRect()
255 // seem to have resulted in a case where no refresh is executed.
256 // Before that, a refresh must have been always executed
257 // (else this error would have happend earlier), thus i
258 // even think here a refresh should be done always.
259 // Since follow-up problems cannot even be guessed I only
260 // add this one more case to the if below.
261 // BTW: It's VERY bad style that here, inside ModelHasChanged()
262 // the outliner is again massively changed for the text object
263 // in text edit mode. Normally, all necessary data should be
264 // set at SdrBeginTextEdit(). Some changes and value assigns in
265 // SdrBeginTextEdit() are completely useless since they are set here
266 // again on ModelHasChanged().
267 if (bContourFrame || bAreaChg || bAnchorChg || bColorChg)
269 for (ULONG nOV=0; nOV<nOutlViewAnz; nOV++)
271 OutlinerView* pOLV=pTextEditOutliner->GetView(nOV);
272 { // Alten OutlinerView-Bereich invalidieren
273 Window* pWin=pOLV->GetWindow();
274 Rectangle aTmpRect(aOldArea);
275 USHORT nPixSiz=pOLV->GetInvalidateMore()+1;
276 Size aMore(pWin->PixelToLogic(Size(nPixSiz,nPixSiz)));
277 aTmpRect.Left()-=aMore.Width();
278 aTmpRect.Right()+=aMore.Width();
279 aTmpRect.Top()-=aMore.Height();
280 aTmpRect.Bottom()+=aMore.Height();
281 InvalidateOneWin(*pWin,aTmpRect);
283 if (bAnchorChg)
284 pOLV->SetAnchorMode(eNewAnchor);
285 if (bColorChg)
286 pOLV->SetBackgroundColor( aNewColor );
288 pOLV->SetOutputArea(aTextEditArea); // weil sonst scheinbar nicht richtig umgeankert wird
289 ImpInvalidateOutlinerView(*pOLV);
291 pTextEditOutlinerView->ShowCursor();
294 ImpMakeTextCursorAreaVisible();
298 ////////////////////////////////////////////////////////////////////////////////////////////////////
300 // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@@ @@@@@ @@ @@@@@@
301 // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
302 // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
303 // @@ @@@@ @@@ @@ @@@@ @@ @@ @@ @@
304 // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
305 // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
306 // @@ @@@@@ @@ @@ @@ @@@@@ @@@@@ @@ @@
308 ////////////////////////////////////////////////////////////////////////////////////////////////////
310 void SdrObjEditView::ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect) const
312 Window* pWin = rOutlView.GetWindow();
314 if(pWin)
316 const SdrTextObj* pText = PTR_CAST(SdrTextObj,GetTextEditObject());
317 bool bTextFrame(pText && pText->IsTextFrame());
318 bool bFitToSize(pText && pText->IsFitToSize());
319 bool bModifyMerk(pTextEditOutliner->IsModified()); // #43095#
320 Rectangle aBlankRect(rOutlView.GetOutputArea());
321 aBlankRect.Union(aMinTextEditArea);
322 Rectangle aPixRect(pWin->LogicToPixel(aBlankRect));
323 aBlankRect.Intersection(rRect);
324 rOutlView.GetOutliner()->SetUpdateMode(TRUE); // Bugfix #22596#
325 rOutlView.Paint(aBlankRect);
327 if(!bModifyMerk)
329 // #43095#
330 pTextEditOutliner->ClearModifyFlag();
333 if(bTextFrame && !bFitToSize)
335 aPixRect.Left()--;
336 aPixRect.Top()--;
337 aPixRect.Right()++;
338 aPixRect.Bottom()++;
339 sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1);
342 // xPixRect Begrenzen, wegen Treiberproblem bei zu weit hinausragenden Pixelkoordinaten
343 Size aMaxXY(pWin->GetOutputSizePixel());
344 long a(2 * nPixSiz);
345 long nMaxX(aMaxXY.Width() + a);
346 long nMaxY(aMaxXY.Height() + a);
348 if (aPixRect.Left ()<-a) aPixRect.Left()=-a;
349 if (aPixRect.Top ()<-a) aPixRect.Top ()=-a;
350 if (aPixRect.Right ()>nMaxX) aPixRect.Right ()=nMaxX;
351 if (aPixRect.Bottom()>nMaxY) aPixRect.Bottom()=nMaxY;
354 Rectangle aOuterPix(aPixRect);
355 aOuterPix.Left()-=nPixSiz;
356 aOuterPix.Top()-=nPixSiz;
357 aOuterPix.Right()+=nPixSiz;
358 aOuterPix.Bottom()+=nPixSiz;
360 bool bMerk(pWin->IsMapModeEnabled());
361 pWin->EnableMapMode(FALSE);
362 PolyPolygon aPolyPoly( 2 );
364 svtools::ColorConfig aColorConfig;
365 Color aHatchCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
366 const Hatch aHatch( HATCH_SINGLE, aHatchCol, 3, 450 );
368 aPolyPoly.Insert( aOuterPix );
369 aPolyPoly.Insert( aPixRect );
370 pWin->DrawHatch( aPolyPoly, aHatch );
372 pWin->EnableMapMode(bMerk);
375 rOutlView.ShowCursor();
379 void SdrObjEditView::ImpInvalidateOutlinerView(OutlinerView& rOutlView) const
381 Window* pWin = rOutlView.GetWindow();
383 if(pWin)
385 const SdrTextObj* pText = PTR_CAST(SdrTextObj,GetTextEditObject());
386 bool bTextFrame(pText && pText->IsTextFrame());
387 bool bFitToSize(pText && pText->IsFitToSize());
389 if(bTextFrame && !bFitToSize)
391 Rectangle aBlankRect(rOutlView.GetOutputArea());
392 aBlankRect.Union(aMinTextEditArea);
393 Rectangle aPixRect(pWin->LogicToPixel(aBlankRect));
394 sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1);
396 aPixRect.Left()--;
397 aPixRect.Top()--;
398 aPixRect.Right()++;
399 aPixRect.Bottom()++;
402 // xPixRect Begrenzen, wegen Treiberproblem bei zu weit hinausragenden Pixelkoordinaten
403 Size aMaxXY(pWin->GetOutputSizePixel());
404 long a(2 * nPixSiz);
405 long nMaxX(aMaxXY.Width() + a);
406 long nMaxY(aMaxXY.Height() + a);
408 if (aPixRect.Left ()<-a) aPixRect.Left()=-a;
409 if (aPixRect.Top ()<-a) aPixRect.Top ()=-a;
410 if (aPixRect.Right ()>nMaxX) aPixRect.Right ()=nMaxX;
411 if (aPixRect.Bottom()>nMaxY) aPixRect.Bottom()=nMaxY;
414 Rectangle aOuterPix(aPixRect);
415 aOuterPix.Left()-=nPixSiz;
416 aOuterPix.Top()-=nPixSiz;
417 aOuterPix.Right()+=nPixSiz;
418 aOuterPix.Bottom()+=nPixSiz;
420 bool bMerk(pWin->IsMapModeEnabled());
421 pWin->EnableMapMode(FALSE);
422 pWin->Invalidate(aOuterPix);
423 pWin->EnableMapMode(bMerk);
428 OutlinerView* SdrObjEditView::ImpMakeOutlinerView(Window* pWin, BOOL /*bNoPaint*/, OutlinerView* pGivenView) const
430 // Hintergrund
431 Color aBackground(GetTextEditBackgroundColor(*this));
432 SdrTextObj* pText = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() );
433 BOOL bTextFrame=pText!=NULL && pText->IsTextFrame();
434 BOOL bContourFrame=pText!=NULL && pText->IsContourTextFrame();
435 // OutlinerView erzeugen
436 OutlinerView* pOutlView=pGivenView;
437 pTextEditOutliner->SetUpdateMode(FALSE);
438 if (pOutlView==NULL) pOutlView=new OutlinerView(pTextEditOutliner,pWin);
439 else pOutlView->SetWindow(pWin);
440 // Scrollen verbieten
441 ULONG nStat=pOutlView->GetControlWord();
442 nStat&=~EV_CNTRL_AUTOSCROLL;
443 // AutoViewSize nur wenn nicht KontourFrame.
444 if (!bContourFrame) nStat|=EV_CNTRL_AUTOSIZE;
445 if (bTextFrame) {
446 USHORT nPixSiz=aHdl.GetHdlSize()*2+1;
447 nStat|=EV_CNTRL_INVONEMORE;
448 pOutlView->SetInvalidateMore(nPixSiz);
450 pOutlView->SetControlWord(nStat);
451 pOutlView->SetBackgroundColor( aBackground );
452 if (pText!=NULL)
454 pOutlView->SetAnchorMode((EVAnchorMode)(pText->GetOutlinerViewAnchorMode()));
455 pTextEditOutliner->SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)pText->GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
457 // do update before setting output area so that aTextEditArea can be recalculated
458 pTextEditOutliner->SetUpdateMode(TRUE);
459 pOutlView->SetOutputArea(aTextEditArea);
460 ImpInvalidateOutlinerView(*pOutlView);
461 return pOutlView;
464 BOOL SdrObjEditView::IsTextEditFrame() const
466 SdrTextObj* pText = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
467 return pText!=NULL && pText->IsTextFrame();
470 IMPL_LINK(SdrObjEditView,ImpOutlinerStatusEventHdl,EditStatus*,pEditStat)
472 if(pTextEditOutliner )
474 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() );
475 if( pTextObj )
477 pTextObj->onEditOutlinerStatusEvent( pEditStat );
480 return 0;
483 IMPL_LINK(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI)
485 bool bOk=false;
486 String& rStr=pFI->GetRepresentation();
487 rStr.Erase();
488 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
489 if (pTextObj!=NULL) {
490 Color* pTxtCol=NULL;
491 Color* pFldCol=NULL;
492 bOk=pTextObj->CalcFieldValue(pFI->GetField(),pFI->GetPara(),pFI->GetPos(),TRUE,pTxtCol,pFldCol,rStr);
493 if (bOk) {
494 if (pTxtCol!=NULL) {
495 pFI->SetTxtColor(*pTxtCol);
496 delete pTxtCol;
498 if (pFldCol!=NULL) {
499 pFI->SetFldColor(*pFldCol);
500 delete pFldCol;
501 } else {
502 pFI->SetFldColor(Color(COL_LIGHTGRAY)); // kann spaeter (357) raus
506 Outliner& rDrawOutl=pMod->GetDrawOutliner(pTextObj);
507 Link aDrawOutlLink=rDrawOutl.GetCalcFieldValueHdl();
508 if (!bOk && aDrawOutlLink.IsSet()) {
509 aDrawOutlLink.Call(pFI);
510 bOk = (BOOL)rStr.Len();
512 if (!bOk && aOldCalcFieldValueLink.IsSet()) {
513 return aOldCalcFieldValueLink.Call(pFI);
515 return 0;
518 sal_Bool SdrObjEditView::SdrBeginTextEdit(
519 SdrObject* pObj, SdrPageView* pPV, Window* pWin,
520 sal_Bool bIsNewObj, SdrOutliner* pGivenOutliner,
521 OutlinerView* pGivenOutlinerView,
522 sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView,
523 sal_Bool bGrabFocus)
525 SdrEndTextEdit();
527 if( dynamic_cast< SdrTextObj* >( pObj ) == 0 )
528 return FALSE; // currently only possible with text objects
530 if(bGrabFocus && pWin)
532 // attetion, this call may cause an EndTextEdit() call to this view
533 pWin->GrabFocus(); // to force the cursor into the edit view
536 bTextEditDontDelete=bDontDeleteOutliner && pGivenOutliner!=NULL;
537 bTextEditOnlyOneView=bOnlyOneView;
538 bTextEditNewObj=bIsNewObj;
539 const sal_uInt32 nWinAnz(PaintWindowCount());
540 sal_uInt32 i;
541 sal_Bool bBrk(sal_False);
542 // Abbruch, wenn kein Objekt angegeben.
544 if(!pObj)
546 bBrk = sal_True;
549 if(!bBrk && !pWin)
551 for(i = 0L; i < nWinAnz && !pWin; i++)
553 SdrPaintWindow* pPaintWindow = GetPaintWindow(i);
555 if(OUTDEV_WINDOW == pPaintWindow->GetOutputDevice().GetOutDevType())
557 pWin = (Window*)(&pPaintWindow->GetOutputDevice());
561 // Abbruch, wenn kein Window da.
562 if(!pWin)
564 bBrk = sal_True;
568 if(!bBrk && !pPV)
570 pPV = GetSdrPageView();
572 // Abbruch, wenn keine PageView zu dem Objekt vorhanden.
573 if(!pPV)
575 bBrk = sal_True;
579 if(pObj && pPV)
581 // Kein TextEdit an Objekten im gesperrten Layer
582 if(pPV->GetLockedLayers().IsSet(pObj->GetLayer()))
584 bBrk = sal_True;
588 if(pTextEditOutliner)
590 DBG_ERROR("SdrObjEditView::SdrBeginTextEdit() da stand noch ein alter Outliner rum");
591 delete pTextEditOutliner;
592 pTextEditOutliner = 0L;
595 if(!bBrk)
597 pTextEditWin=pWin;
598 pTextEditPV=pPV;
599 mxTextEditObj.reset( pObj );
600 pTextEditOutliner=pGivenOutliner;
601 if (pTextEditOutliner==NULL)
602 pTextEditOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, mxTextEditObj->GetModel() );
605 SvtAccessibilityOptions aOptions;
606 pTextEditOutliner->ForceAutoColor( aOptions.GetIsAutomaticFontColor() );
609 BOOL bEmpty = mxTextEditObj->GetOutlinerParaObject()==NULL;
611 aOldCalcFieldValueLink=pTextEditOutliner->GetCalcFieldValueHdl();
612 // Der FieldHdl muss von SdrBeginTextEdit gesetzt sein, da dor ein UpdateFields gerufen wird.
613 pTextEditOutliner->SetCalcFieldValueHdl(LINK(this,SdrObjEditView,ImpOutlinerCalcFieldValueHdl));
614 pTextEditOutliner->SetBeginPasteOrDropHdl(LINK(this,SdrObjEditView,BeginPasteOrDropHdl));
615 pTextEditOutliner->SetEndPasteOrDropHdl(LINK(this,SdrObjEditView, EndPasteOrDropHdl));
617 // It is just necessary to make the visualized page known. Set it.
618 pTextEditOutliner->setVisualizedPage(pPV ? pPV->GetPage() : 0);
620 pTextEditOutliner->SetTextObjNoInit( dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ) );
622 if(mxTextEditObj->BegTextEdit(*pTextEditOutliner))
624 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
625 DBG_ASSERT( pTextObj, "svx::SdrObjEditView::BegTextEdit(), no text object?" );
626 if( !pTextObj )
627 return FALSE;
629 // #111096# Switch off evtl. running TextAnimation
630 pTextObj->SetTextAnimationAllowed(sal_False);
632 // alten Cursor merken
633 if (pTextEditOutliner->GetViewCount()!=0)
635 OutlinerView* pTmpOLV=pTextEditOutliner->RemoveView(ULONG(0));
636 if(pTmpOLV!=NULL && pTmpOLV!=pGivenOutlinerView)
637 delete pTmpOLV;
640 // EditArea ueberTakeTextEditArea bestimmen
641 // Das koennte eigentlich entfallen, da TakeTextRect() die Berechnung der aTextEditArea vornimmt
642 // Die aMinTextEditArea muss jedoch wohl auch erfolgen (darum bleibt es voerst drinnen)
643 pTextObj->TakeTextEditArea(NULL,NULL,&aTextEditArea,&aMinTextEditArea);
645 Rectangle aTextRect;
646 Rectangle aAnchorRect;
647 pTextObj->TakeTextRect(*pTextEditOutliner, aTextRect, TRUE,
648 &aAnchorRect /* #97097# Give TRUE here, not FALSE */);
650 if ( !pTextObj->IsContourTextFrame() )
652 // FitToSize erstmal nicht mit ContourFrame
653 if (pTextObj->IsFitToSize())
654 aTextRect = aAnchorRect;
657 aTextEditArea = aTextRect;
659 // #108784#
660 Point aPvOfs(pTextObj->GetTextEditOffset());
662 aTextEditArea.Move(aPvOfs.X(),aPvOfs.Y());
663 aMinTextEditArea.Move(aPvOfs.X(),aPvOfs.Y());
664 pTextEditCursorMerker=pWin->GetCursor();
666 aHdl.SetMoveOutside(TRUE);
668 // #i72757#
669 // Since IsMarkHdlWhenTextEdit() is ignored, it is necessary
670 // to call AdjustMarkHdl() always.
671 AdjustMarkHdl();
673 pTextEditOutlinerView=ImpMakeOutlinerView(pWin,!bEmpty,pGivenOutlinerView);
675 // check if this view is already inserted
676 ULONG i2,nCount = pTextEditOutliner->GetViewCount();
677 for( i2 = 0; i2 < nCount; i2++ )
679 if( pTextEditOutliner->GetView(i2) == pTextEditOutlinerView )
680 break;
683 if( i2 == nCount )
684 pTextEditOutliner->InsertView(pTextEditOutlinerView,0);
686 aHdl.SetMoveOutside(FALSE);
687 aHdl.SetMoveOutside(TRUE);
688 //OLMRefreshAllIAOManagers();
690 // alle Wins als OutlinerView beim Outliner anmelden
691 if(!bOnlyOneView)
693 for(i = 0L; i < nWinAnz; i++)
695 SdrPaintWindow* pPaintWindow = GetPaintWindow(i);
696 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
698 if(&rOutDev != pWin && OUTDEV_WINDOW == rOutDev.GetOutDevType())
700 OutlinerView* pOutlView = ImpMakeOutlinerView((Window*)(&rOutDev), !bEmpty, 0L);
701 pTextEditOutliner->InsertView(pOutlView, (sal_uInt16)i);
706 pTextEditOutlinerView->ShowCursor();
707 pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl));
708 #ifdef DBG_UTIL
709 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
710 #endif
711 pTextEditOutliner->ClearModifyFlag();
713 // #71519#, #91453#
714 if(pWin)
716 sal_Bool bExtraInvalidate(sal_False);
718 // #71519#
719 if(!bExtraInvalidate)
721 if(pTextObj->IsFitToSize())
722 bExtraInvalidate = sal_True;
725 if(bExtraInvalidate)
727 pWin->Invalidate(aTextEditArea);
731 // send HINT_BEGEDIT #99840#
732 if( GetModel() )
734 SdrHint aHint(*pTextObj);
735 aHint.SetKind(HINT_BEGEDIT);
736 GetModel()->Broadcast(aHint);
739 pTextEditOutliner->setVisualizedPage(0);
741 if( mxSelectionController.is() )
742 mxSelectionController->onSelectionHasChanged();
744 return sal_True; // Gut gelaufen, TextEdit laeuft nun
746 else
748 bBrk = sal_True;
749 pTextEditOutliner->SetCalcFieldValueHdl(aOldCalcFieldValueLink);
750 pTextEditOutliner->SetBeginPasteOrDropHdl(Link());
751 pTextEditOutliner->SetEndPasteOrDropHdl(Link());
755 if (pTextEditOutliner != NULL)
757 pTextEditOutliner->setVisualizedPage(0);
760 // wenn hier angekommen, dann ist irgendwas schief gelaufen
761 if(!bDontDeleteOutliner)
763 if(pGivenOutliner!=NULL)
765 delete pGivenOutliner;
766 pTextEditOutliner = NULL;
768 if(pGivenOutlinerView!=NULL)
770 delete pGivenOutlinerView;
771 pGivenOutlinerView = NULL;
774 if( pTextEditOutliner!=NULL )
776 delete pTextEditOutliner;
779 pTextEditOutliner=NULL;
780 pTextEditOutlinerView=NULL;
781 mxTextEditObj.reset(0);
782 pTextEditPV=NULL;
783 pTextEditWin=NULL;
784 //HMHif (bMarkHdlWhenTextEdit) {
785 //HMH HideMarkHdl();
786 //HMH}
787 aHdl.SetMoveOutside(FALSE);
788 //HMHShowMarkHdl();
790 return sal_False;
793 SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally)
795 SdrEndTextEditKind eRet=SDRENDTEXTEDIT_UNCHANGED;
796 SdrTextObj* pTEObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
797 Window* pTEWin =pTextEditWin;
798 SdrOutliner* pTEOutliner =pTextEditOutliner;
799 OutlinerView* pTEOutlinerView=pTextEditOutlinerView;
800 Cursor* pTECursorMerker=pTextEditCursorMerker;
802 // send HINT_ENDEDIT #99840#
803 if( GetModel() && mxTextEditObj.is() )
805 SdrHint aHint(*mxTextEditObj.get());
806 aHint.SetKind(HINT_ENDEDIT);
807 GetModel()->Broadcast(aHint);
810 mxTextEditObj.reset(0);
811 pTextEditPV=NULL;
812 pTextEditWin=NULL;
813 pTextEditOutliner=NULL;
814 pTextEditOutlinerView=NULL;
815 pTextEditCursorMerker=NULL;
816 aTextEditArea=Rectangle();
818 if (pTEOutliner!=NULL)
820 BOOL bModified=pTEOutliner->IsModified();
821 if (pTEOutlinerView!=NULL)
823 pTEOutlinerView->HideCursor();
825 if (pTEObj!=NULL)
827 pTEOutliner->CompleteOnlineSpelling();
829 SdrUndoObjSetText* pTxtUndo = 0;
831 if( bModified )
833 sal_Int32 nText;
834 for( nText = 0; nText < pTEObj->getTextCount(); ++nText )
835 if( pTEObj->getText( nText ) == pTEObj->getActiveText() )
836 break;
838 pTxtUndo = dynamic_cast< SdrUndoObjSetText* >( GetModel()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTEObj, nText ) );
840 DBG_ASSERT( !bModified || pTxtUndo, "svx::SdrObjEditView::EndTextEdit(), could not create undo action!" );
841 // Den alten CalcFieldValue-Handler wieder setzen
842 // Muss vor Obj::EndTextEdit() geschehen, da dort ein UpdateFields() gemacht wird.
843 pTEOutliner->SetCalcFieldValueHdl(aOldCalcFieldValueLink);
844 pTEOutliner->SetBeginPasteOrDropHdl(Link());
845 pTEOutliner->SetEndPasteOrDropHdl(Link());
847 const bool bUndo = IsUndoEnabled();
848 if( bUndo )
850 XubString aObjName;
851 pTEObj->TakeObjNameSingul(aObjName);
852 BegUndo(ImpGetResStr(STR_UndoObjSetText),aObjName);
855 pTEObj->EndTextEdit(*pTEOutliner);
857 if( (pTEObj->GetRotateAngle() != 0) || (pTEObj && pTEObj->ISA(SdrTextObj) && ((SdrTextObj*)pTEObj)->IsFontwork()) )
859 // obviously a repaint
860 pTEObj->ActionChanged();
863 if (pTxtUndo!=NULL)
865 pTxtUndo->AfterSetText();
866 if (!pTxtUndo->IsDifferent())
868 delete pTxtUndo;
869 pTxtUndo=NULL;
872 // Loeschung des gesamten TextObj checken
873 SdrUndoAction* pDelUndo=NULL;
874 BOOL bDelObj=FALSE;
875 SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pTEObj);
876 if (pTextObj!=NULL && bTextEditNewObj)
878 bDelObj=pTextObj->IsTextFrame() &&
879 !pTextObj->HasText() &&
880 !pTextObj->IsEmptyPresObj() &&
881 !pTextObj->HasFill() &&
882 !pTextObj->HasLine();
884 if(pTEObj->IsInserted() && bDelObj && pTextObj->GetObjInventor()==SdrInventor && !bDontDeleteReally)
886 SdrObjKind eIdent=(SdrObjKind)pTextObj->GetObjIdentifier();
887 if(eIdent==OBJ_TEXT || eIdent==OBJ_TEXTEXT)
889 pDelUndo= GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pTEObj);
893 if (pTxtUndo!=NULL)
895 if( bUndo )
896 AddUndo(pTxtUndo);
897 eRet=SDRENDTEXTEDIT_CHANGED;
899 if (pDelUndo!=NULL)
901 if( bUndo )
903 AddUndo(pDelUndo);
905 else
907 delete pDelUndo;
909 eRet=SDRENDTEXTEDIT_DELETED;
910 DBG_ASSERT(pTEObj->GetObjList()!=NULL,"SdrObjEditView::SdrEndTextEdit(): Fatal: Editiertes Objekt hat keine ObjList!");
911 if (pTEObj->GetObjList()!=NULL)
913 pTEObj->GetObjList()->RemoveObject(pTEObj->GetOrdNum());
914 CheckMarked(); // und gleich die Maekierung entfernen...
917 else if (bDelObj)
918 { // Fuer den Writer: Loeschen muss die App nachholen.
919 eRet=SDRENDTEXTEDIT_SHOULDBEDELETED;
922 if( bUndo )
923 EndUndo(); // EndUndo hinter Remove, falls der UndoStack gleich weggehaun' wird
925 // #111096#
926 // Switch on evtl. TextAnimation again after TextEdit
927 if(pTEObj->ISA(SdrTextObj))
929 ((SdrTextObj*)pTEObj)->SetTextAnimationAllowed(sal_True);
932 // #i72757#
933 // Since IsMarkHdlWhenTextEdit() is ignored, it is necessary
934 // to call AdjustMarkHdl() always.
935 AdjustMarkHdl();
937 // alle OutlinerViews loeschen
938 for (ULONG i=pTEOutliner->GetViewCount(); i>0;)
940 i--;
941 OutlinerView* pOLV=pTEOutliner->GetView(i);
942 USHORT nMorePix=pOLV->GetInvalidateMore() + 10; // solaris aw033 test #i#
943 Window* pWin=pOLV->GetWindow();
944 Rectangle aRect(pOLV->GetOutputArea());
945 pTEOutliner->RemoveView(i);
946 if (!bTextEditDontDelete || i!=0)
948 // die nullte gehoert mir u.U. nicht.
949 delete pOLV;
951 aRect.Union(aTextEditArea);
952 aRect.Union(aMinTextEditArea);
953 aRect=pWin->LogicToPixel(aRect);
954 aRect.Left()-=nMorePix;
955 aRect.Top()-=nMorePix;
956 aRect.Right()+=nMorePix;
957 aRect.Bottom()+=nMorePix;
958 aRect=pWin->PixelToLogic(aRect);
959 InvalidateOneWin(*pWin,aRect);
960 // pWin->Invalidate(INVALIDATE_UPDATE);
962 // pWin->Update();
963 // pWin->Flush();
964 pWin->SetFillColor();
965 pWin->SetLineColor(COL_BLACK);
966 pWin->DrawPixel(aRect.TopLeft());
967 pWin->DrawPixel(aRect.TopRight());
968 pWin->DrawPixel(aRect.BottomLeft());
969 pWin->DrawPixel(aRect.BottomRight());
970 //pWin->DrawRect(aRect);
972 // und auch den Outliner selbst
973 if (!bTextEditDontDelete) delete pTEOutliner;
974 else pTEOutliner->Clear();
975 if (pTEWin!=NULL) {
976 pTEWin->SetCursor(pTECursorMerker);
978 //HMH if (bMarkHdlWhenTextEdit) {
979 //HMH HideMarkHdl();
980 //HMH }
981 aHdl.SetMoveOutside(FALSE);
982 if (eRet!=SDRENDTEXTEDIT_UNCHANGED)
983 //HMH {
984 //HMH ShowMarkHdl(); // Handles kommen ansonsten via Broadcast
985 //HMH }
986 //HMH else
988 GetMarkedObjectListWriteAccess().SetNameDirty();
990 #ifdef DBG_UTIL
991 if (pItemBrowser)
993 GetMarkedObjectListWriteAccess().SetNameDirty();
994 pItemBrowser->SetDirty();
996 #endif
999 // #108784#
1000 if( pTEObj &&
1001 pTEObj->GetModel() &&
1002 !pTEObj->GetModel()->isLocked() &&
1003 pTEObj->GetBroadcaster())
1005 SdrHint aHint(HINT_ENDEDIT);
1006 aHint.SetObject(pTEObj);
1007 ((SfxBroadcaster*)pTEObj->GetBroadcaster())->Broadcast(aHint);
1010 return eRet;
1013 ////////////////////////////////////////////////////////////////////////////////////////////////////
1014 // info about TextEdit. Default is sal_False.
1015 bool SdrObjEditView::IsTextEdit() const
1017 return mxTextEditObj.is();
1020 // info about TextEditPageView. Default is 0L.
1021 SdrPageView* SdrObjEditView::GetTextEditPageView() const
1023 return pTextEditPV;
1026 ////////////////////////////////////////////////////////////////////////////////////////////////////
1028 OutlinerView* SdrObjEditView::ImpFindOutlinerView(Window* pWin) const
1030 if (pWin==NULL) return NULL;
1031 if (pTextEditOutliner==NULL) return NULL;
1032 OutlinerView* pNewView=NULL;
1033 ULONG nWinAnz=pTextEditOutliner->GetViewCount();
1034 for (ULONG i=0; i<nWinAnz && pNewView==NULL; i++) {
1035 OutlinerView* pView=pTextEditOutliner->GetView(i);
1036 if (pView->GetWindow()==pWin) pNewView=pView;
1038 return pNewView;
1041 void SdrObjEditView::SetTextEditWin(Window* pWin)
1043 if(mxTextEditObj.is() && pWin!=NULL && pWin!=pTextEditWin)
1045 OutlinerView* pNewView=ImpFindOutlinerView(pWin);
1046 if (pNewView!=NULL && pNewView!=pTextEditOutlinerView)
1048 if (pTextEditOutlinerView!=NULL)
1050 pTextEditOutlinerView->HideCursor();
1052 pTextEditOutlinerView=pNewView;
1053 pTextEditWin=pWin;
1054 pWin->GrabFocus(); // Damit der Cursor hier auch blinkt
1055 pNewView->ShowCursor();
1056 ImpMakeTextCursorAreaVisible();
1061 BOOL SdrObjEditView::IsTextEditHit(const Point& rHit, short nTol) const
1063 BOOL bOk=FALSE;
1064 if(mxTextEditObj.is())
1066 nTol=ImpGetHitTolLogic(nTol,NULL);
1067 // nur drittel Toleranz hier, damit die Handles
1068 // noch vernuenftig getroffen werden koennen
1069 nTol=nTol/3;
1070 nTol=0; // Joe am 6.3.1997: Keine Hittoleranz mehr hier
1071 if (!bOk)
1073 Rectangle aEditArea;
1074 OutlinerView* pOLV=pTextEditOutliner->GetView(0);
1075 if (pOLV!=NULL)
1077 aEditArea.Union(pOLV->GetOutputArea());
1079 aEditArea.Left()-=nTol;
1080 aEditArea.Top()-=nTol;
1081 aEditArea.Right()+=nTol;
1082 aEditArea.Bottom()+=nTol;
1083 bOk=aEditArea.IsInside(rHit);
1084 if (bOk)
1085 { // Nun noch checken, ob auch wirklich Buchstaben getroffen wurden
1086 Point aPnt(rHit); aPnt-=aEditArea.TopLeft();
1087 long nHitTol = 2000;
1088 OutputDevice* pRef = pTextEditOutliner->GetRefDevice();
1089 if( pRef )
1090 nHitTol = pRef->LogicToLogic( nHitTol, MAP_100TH_MM, pRef->GetMapMode().GetMapUnit() );
1092 bOk = pTextEditOutliner->IsTextPos( aPnt, (sal_uInt16)nHitTol );
1096 return bOk;
1099 BOOL SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const
1101 BOOL bOk=FALSE;
1102 if(mxTextEditObj.is())
1104 SdrTextObj* pText= dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
1105 OutlinerView* pOLV=pTextEditOutliner->GetView(0);
1106 if( pOLV )
1108 Window* pWin=pOLV->GetWindow();
1109 if (pText!=NULL && pText->IsTextFrame() && pOLV!=NULL && pWin!=NULL) {
1110 USHORT nPixSiz=pOLV->GetInvalidateMore();
1111 Rectangle aEditArea(aMinTextEditArea);
1112 aEditArea.Union(pOLV->GetOutputArea());
1113 if (!aEditArea.IsInside(rHit)) {
1114 Size aSiz(pWin->PixelToLogic(Size(nPixSiz,nPixSiz)));
1115 aEditArea.Left()-=aSiz.Width();
1116 aEditArea.Top()-=aSiz.Height();
1117 aEditArea.Right()+=aSiz.Width();
1118 aEditArea.Bottom()+=aSiz.Height();
1119 bOk=aEditArea.IsInside(rHit);
1124 return bOk;
1127 void SdrObjEditView::AddTextEditOfs(MouseEvent& rMEvt) const
1129 if(mxTextEditObj.is())
1131 Point aPvOfs;
1132 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
1134 if( pTextObj )
1136 // #108784#
1137 aPvOfs += pTextObj->GetTextEditOffset();
1140 Point aObjOfs(mxTextEditObj->GetLogicRect().TopLeft());
1141 (Point&)(rMEvt.GetPosPixel())+=aPvOfs+aObjOfs;
1145 ////////////////////////////////////////////////////////////////////////////////////////////////////
1147 BOOL SdrObjEditView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
1149 if(pTextEditOutlinerView)
1151 #ifdef DBG_UTIL
1152 if(rKEvt.GetKeyCode().GetCode() == KEY_RETURN && pTextEditOutliner->GetParagraphCount() == 1)
1154 ByteString aLine(
1155 pTextEditOutliner->GetText(pTextEditOutliner->GetParagraph( 0 ), 1),
1156 gsl_getSystemTextEncoding());
1157 aLine = aLine.ToUpperAscii();
1159 if(aLine == "HELLO JOE, PLEASE SHOW THE ITEMBROWSER")
1160 ShowItemBrowser();
1162 #endif
1163 if (pTextEditOutlinerView->PostKeyEvent(rKEvt, pWin))
1165 if( pMod && !pMod->IsChanged() )
1167 if( pTextEditOutliner && pTextEditOutliner->IsModified() )
1168 pMod->SetChanged( sal_True );
1171 if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
1172 #ifdef DBG_UTIL
1173 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1174 #endif
1175 ImpMakeTextCursorAreaVisible();
1176 return TRUE;
1179 return SdrGlueEditView::KeyInput(rKEvt,pWin);
1182 BOOL SdrObjEditView::MouseButtonDown(const MouseEvent& rMEvt, Window* pWin)
1184 if (pTextEditOutlinerView!=NULL) {
1185 BOOL bPostIt=pTextEditOutliner->IsInSelectionMode();
1186 if (!bPostIt) {
1187 Point aPt(rMEvt.GetPosPixel());
1188 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
1189 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
1190 bPostIt=IsTextEditHit(aPt,nHitTolLog);
1192 if (bPostIt) {
1193 Point aPixPos(rMEvt.GetPosPixel());
1194 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
1195 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
1196 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
1197 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
1198 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
1199 MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(),
1200 rMEvt.GetButtons(),rMEvt.GetModifier());
1201 if (pTextEditOutlinerView->MouseButtonDown(aMEvt)) {
1202 if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
1203 #ifdef DBG_UTIL
1204 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1205 #endif
1206 ImpMakeTextCursorAreaVisible();
1207 return TRUE;
1211 return SdrGlueEditView::MouseButtonDown(rMEvt,pWin);
1214 BOOL SdrObjEditView::MouseButtonUp(const MouseEvent& rMEvt, Window* pWin)
1216 if (pTextEditOutlinerView!=NULL) {
1217 BOOL bPostIt=pTextEditOutliner->IsInSelectionMode();
1218 if (!bPostIt) {
1219 Point aPt(rMEvt.GetPosPixel());
1220 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
1221 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
1222 bPostIt=IsTextEditHit(aPt,nHitTolLog);
1224 if (bPostIt) {
1225 Point aPixPos(rMEvt.GetPosPixel());
1226 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
1227 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
1228 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
1229 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
1230 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
1231 MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(),
1232 rMEvt.GetButtons(),rMEvt.GetModifier());
1233 if (pTextEditOutlinerView->MouseButtonUp(aMEvt)) {
1234 #ifdef DBG_UTIL
1235 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1236 #endif
1237 ImpMakeTextCursorAreaVisible();
1238 return TRUE;
1242 return SdrGlueEditView::MouseButtonUp(rMEvt,pWin);
1245 BOOL SdrObjEditView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
1247 if (pTextEditOutlinerView!=NULL) {
1248 BOOL bSelMode=pTextEditOutliner->IsInSelectionMode();
1249 BOOL bPostIt=bSelMode;
1250 if (!bPostIt) {
1251 Point aPt(rMEvt.GetPosPixel());
1252 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
1253 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
1254 bPostIt=IsTextEditHit(aPt,nHitTolLog);
1256 if (bPostIt) {
1257 Point aPixPos(rMEvt.GetPosPixel());
1258 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
1259 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
1260 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
1261 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
1262 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
1263 MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(),
1264 rMEvt.GetButtons(),rMEvt.GetModifier());
1265 if (pTextEditOutlinerView->MouseMove(aMEvt) && bSelMode) {
1266 #ifdef DBG_UTIL
1267 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1268 #endif
1269 ImpMakeTextCursorAreaVisible();
1270 return TRUE;
1274 return SdrGlueEditView::MouseMove(rMEvt,pWin);
1277 BOOL SdrObjEditView::Command(const CommandEvent& rCEvt, Window* pWin)
1279 // solange bis die OutlinerView einen BOOL zurueckliefert
1280 // bekommt sie nur COMMAND_STARTDRAG
1281 if (pTextEditOutlinerView!=NULL)
1283 if (rCEvt.GetCommand()==COMMAND_STARTDRAG) {
1284 BOOL bPostIt=pTextEditOutliner->IsInSelectionMode() || !rCEvt.IsMouseEvent();
1285 if (!bPostIt && rCEvt.IsMouseEvent()) {
1286 Point aPt(rCEvt.GetMousePosPixel());
1287 if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
1288 else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
1289 bPostIt=IsTextEditHit(aPt,nHitTolLog);
1291 if (bPostIt) {
1292 Point aPixPos(rCEvt.GetMousePosPixel());
1293 if (rCEvt.IsMouseEvent()) {
1294 Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
1295 if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
1296 if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
1297 if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
1298 if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
1300 CommandEvent aCEvt(aPixPos,rCEvt.GetCommand(),rCEvt.IsMouseEvent());
1301 // Command ist an der OutlinerView leider void
1302 pTextEditOutlinerView->Command(aCEvt);
1303 if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
1304 #ifdef DBG_UTIL
1305 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1306 #endif
1307 ImpMakeTextCursorAreaVisible();
1308 return TRUE;
1311 else // if (rCEvt.GetCommand() == COMMAND_VOICE )
1313 pTextEditOutlinerView->Command(rCEvt);
1314 return TRUE;
1317 return SdrGlueEditView::Command(rCEvt,pWin);
1320 BOOL SdrObjEditView::Cut(ULONG nFormat)
1322 if (pTextEditOutliner!=NULL) {
1323 pTextEditOutlinerView->Cut();
1324 #ifdef DBG_UTIL
1325 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1326 #endif
1327 ImpMakeTextCursorAreaVisible();
1328 return TRUE;
1329 } else {
1330 return SdrGlueEditView::Cut(nFormat);
1334 BOOL SdrObjEditView::Yank(ULONG nFormat)
1336 if (pTextEditOutliner!=NULL) {
1337 pTextEditOutlinerView->Copy();
1338 return TRUE;
1339 } else {
1340 return SdrGlueEditView::Yank(nFormat);
1344 BOOL SdrObjEditView::Paste(Window* pWin, ULONG nFormat)
1346 if (pTextEditOutliner!=NULL) {
1347 if (pWin!=NULL) {
1348 OutlinerView* pNewView=ImpFindOutlinerView(pWin);
1349 if (pNewView!=NULL) {
1350 pNewView->Paste();
1352 } else {
1353 pTextEditOutlinerView->Paste();
1355 #ifdef DBG_UTIL
1356 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1357 #endif
1358 ImpMakeTextCursorAreaVisible();
1359 return TRUE;
1360 } else {
1361 return SdrGlueEditView::Paste(pWin,nFormat);
1365 ////////////////////////////////////////////////////////////////////////////////////////////////////
1367 BOOL SdrObjEditView::ImpIsTextEditAllSelected() const
1369 BOOL bRet=FALSE;
1370 if (pTextEditOutliner!=NULL && pTextEditOutlinerView!=NULL)
1372 if(SdrTextObj::HasTextImpl( pTextEditOutliner ) )
1374 const sal_uInt32 nParaAnz=pTextEditOutliner->GetParagraphCount();
1375 Paragraph* pLastPara=pTextEditOutliner->GetParagraph( nParaAnz > 1 ? nParaAnz - 1 : 0 );
1377 ESelection aESel(pTextEditOutlinerView->GetSelection());
1378 if (aESel.nStartPara==0 && aESel.nStartPos==0 && aESel.nEndPara==USHORT(nParaAnz-1))
1380 XubString aStr(pTextEditOutliner->GetText(pLastPara));
1382 if(aStr.Len() == aESel.nEndPos)
1383 bRet = TRUE;
1385 // und nun auch noch fuer den Fall, das rueckwaerts selektiert wurde
1386 if (!bRet && aESel.nEndPara==0 && aESel.nEndPos==0 && aESel.nStartPara==USHORT(nParaAnz-1))
1388 XubString aStr(pTextEditOutliner->GetText(pLastPara));
1390 if(aStr.Len() == aESel.nStartPos)
1391 bRet = TRUE;
1394 else
1396 bRet=TRUE;
1399 return bRet;
1402 void SdrObjEditView::ImpMakeTextCursorAreaVisible()
1404 if (pTextEditOutlinerView!=NULL && pTextEditWin!=NULL) {
1405 Cursor* pCsr=pTextEditWin->GetCursor();
1406 if (pCsr!=NULL) {
1407 Size aSiz(pCsr->GetSize());
1408 if (aSiz.Width()!=0 && aSiz.Height()!=0) { // #38450#
1409 MakeVisible(Rectangle(pCsr->GetPos(),aSiz),*pTextEditWin);
1415 USHORT SdrObjEditView::GetScriptType() const
1417 USHORT nScriptType = 0;
1419 if( IsTextEdit() )
1421 if( mxTextEditObj->GetOutlinerParaObject() )
1422 nScriptType = mxTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
1424 if( pTextEditOutlinerView )
1425 nScriptType = pTextEditOutlinerView->GetSelectedScriptType();
1427 else
1429 sal_uInt32 nMarkCount( GetMarkedObjectCount() );
1431 for( sal_uInt32 i = 0; i < nMarkCount; i++ )
1433 OutlinerParaObject* pParaObj = GetMarkedObjectByIndex( i )->GetOutlinerParaObject();
1435 if( pParaObj )
1437 nScriptType |= pParaObj->GetTextObject().GetScriptType();
1442 if( nScriptType == 0 )
1443 nScriptType = SCRIPTTYPE_LATIN;
1445 return nScriptType;
1448 /* new interface src537 */
1449 BOOL SdrObjEditView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
1451 if( mxSelectionController.is() )
1452 if( mxSelectionController->GetAttributes( rTargetSet, bOnlyHardAttr ) )
1453 return TRUE;
1455 if(IsTextEdit())
1457 DBG_ASSERT(pTextEditOutlinerView!=NULL,"SdrObjEditView::GetAttributes(): pTextEditOutlinerView=NULL");
1458 DBG_ASSERT(pTextEditOutliner!=NULL,"SdrObjEditView::GetAttributes(): pTextEditOutliner=NULL");
1460 // #92389# take care of bOnlyHardAttr(!)
1461 if(!bOnlyHardAttr && mxTextEditObj->GetStyleSheet())
1462 rTargetSet.Put(mxTextEditObj->GetStyleSheet()->GetItemSet());
1464 // add object attributes
1465 rTargetSet.Put( mxTextEditObj->GetMergedItemSet() );
1467 if( mxTextEditObj->GetOutlinerParaObject() )
1468 rTargetSet.Put( SvxScriptTypeItem( mxTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType() ) );
1470 if(pTextEditOutlinerView)
1472 // FALSE= InvalidItems nicht al Default, sondern als "Loecher" betrachten
1473 rTargetSet.Put(pTextEditOutlinerView->GetAttribs(), FALSE);
1474 rTargetSet.Put( SvxScriptTypeItem( pTextEditOutlinerView->GetSelectedScriptType() ), FALSE );
1477 if(GetMarkedObjectCount()==1 && GetMarkedObjectByIndex(0)==mxTextEditObj.get())
1479 MergeNotPersistAttrFromMarked(rTargetSet, bOnlyHardAttr);
1482 return TRUE;
1484 else
1486 return SdrGlueEditView::GetAttributes(rTargetSet, bOnlyHardAttr);
1490 BOOL SdrObjEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
1492 BOOL bRet=FALSE;
1493 BOOL bTextEdit=pTextEditOutlinerView!=NULL && mxTextEditObj.is();
1494 BOOL bAllTextSelected=ImpIsTextEditAllSelected();
1495 SfxItemSet* pModifiedSet=NULL;
1496 const SfxItemSet* pSet=&rSet;
1497 //const SvxAdjustItem* pParaJust=NULL;
1499 if (!bTextEdit)
1501 // Kein TextEdit aktiv -> alle Items ans Zeichenobjekt
1502 if( mxSelectionController.is() )
1503 bRet=mxSelectionController->SetAttributes(*pSet,bReplaceAll );
1505 if( !bRet )
1507 bRet=SdrGlueEditView::SetAttributes(*pSet,bReplaceAll);
1510 else
1512 #ifdef DBG_UTIL
1514 BOOL bHasEEFeatureItems=FALSE;
1515 SfxItemIter aIter(rSet);
1516 const SfxPoolItem* pItem=aIter.FirstItem();
1517 while (!bHasEEFeatureItems && pItem!=NULL)
1519 if (!IsInvalidItem(pItem))
1521 USHORT nW=pItem->Which();
1522 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END)
1523 bHasEEFeatureItems=TRUE;
1526 pItem=aIter.NextItem();
1529 if(bHasEEFeatureItems)
1531 String aMessage;
1532 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.");
1533 InfoBox(NULL, aMessage).Execute();
1536 #endif
1538 BOOL bOnlyEEItems;
1539 BOOL bNoEEItems=!SearchOutlinerItems(*pSet,bReplaceAll,&bOnlyEEItems);
1540 // alles selektiert? -> Attrs auch an den Rahmen
1541 // und falls keine EEItems, dann Attrs nur an den Rahmen
1542 if (bAllTextSelected || bNoEEItems)
1544 if( mxSelectionController.is() )
1545 bRet=mxSelectionController->SetAttributes(*pSet,bReplaceAll );
1547 if( !bRet )
1549 const bool bUndo = IsUndoEnabled();
1551 if( bUndo )
1553 String aStr;
1554 ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
1555 BegUndo(aStr);
1556 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
1558 // #i43537#
1559 // If this is a text object also rescue the OutlinerParaObject since
1560 // applying attributes to the object may change text layout when
1561 // multiple portions exist with multiple formats. If a OutlinerParaObject
1562 // really exists and needs to be rescued is evaluated in the undo
1563 // implementation itself.
1564 bool bRescueText = dynamic_cast< SdrTextObj* >(mxTextEditObj.get());
1566 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,!bNoEEItems || bRescueText));
1567 EndUndo();
1570 mxTextEditObj->SetMergedItemSetAndBroadcast(*pSet, bReplaceAll);
1572 FlushComeBackTimer(); // Damit ModeHasChanged sofort kommt
1573 bRet=TRUE;
1576 else if (!bOnlyEEItems)
1578 // sonst Set ggf. splitten
1579 // Es wird nun ein ItemSet aSet gemacht, in den die EE_Items von
1580 // *pSet nicht enhalten ist (ansonsten ist es eine Kopie).
1581 USHORT* pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END);
1582 SfxItemSet aSet(pMod->GetItemPool(),pNewWhichTable);
1583 /*90353*/ delete[] pNewWhichTable;
1584 SfxWhichIter aIter(aSet);
1585 USHORT nWhich=aIter.FirstWhich();
1586 while (nWhich!=0)
1588 const SfxPoolItem* pItem;
1589 SfxItemState eState=pSet->GetItemState(nWhich,FALSE,&pItem);
1590 if (eState==SFX_ITEM_SET) aSet.Put(*pItem);
1591 nWhich=aIter.NextWhich();
1595 if( mxSelectionController.is() )
1596 bRet=mxSelectionController->SetAttributes(aSet,bReplaceAll );
1598 if( !bRet )
1600 if( IsUndoEnabled() )
1602 String aStr;
1603 ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
1604 BegUndo(aStr);
1605 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
1606 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,false));
1607 EndUndo();
1610 mxTextEditObj->SetMergedItemSetAndBroadcast(aSet, bReplaceAll);
1612 if (GetMarkedObjectCount()==1 && GetMarkedObjectByIndex(0)==mxTextEditObj.get())
1614 SetNotPersistAttrToMarked(aSet,bReplaceAll);
1617 FlushComeBackTimer();
1618 bRet=TRUE;
1620 if(!bNoEEItems)
1622 // und nun die Attribute auch noch an die EditEngine
1623 if (bReplaceAll) {
1624 // Am Outliner kann man leider nur alle Attribute platthauen
1625 pTextEditOutlinerView->RemoveAttribs( TRUE );
1627 pTextEditOutlinerView->SetAttribs(rSet);
1629 #ifdef DBG_UTIL
1630 if (pItemBrowser!=NULL)
1631 pItemBrowser->SetDirty();
1632 #endif
1634 ImpMakeTextCursorAreaVisible();
1636 bRet=TRUE;
1638 if (pModifiedSet!=NULL)
1639 delete pModifiedSet;
1640 return bRet;
1643 SfxStyleSheet* SdrObjEditView::GetStyleSheet() const
1645 SfxStyleSheet* pSheet = 0;
1647 if( mxSelectionController.is() )
1649 if( mxSelectionController->GetStyleSheet( pSheet ) )
1650 return pSheet;
1653 if ( pTextEditOutlinerView )
1655 pSheet = pTextEditOutlinerView->GetStyleSheet();
1657 else
1659 pSheet = SdrGlueEditView::GetStyleSheet();
1661 return pSheet;
1664 BOOL SdrObjEditView::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
1666 if( mxSelectionController.is() )
1668 if( mxSelectionController->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr ) )
1669 return TRUE;
1672 // if we are currently in edit mode we must also set the stylesheet
1673 // on all paragraphs in the Outliner for the edit view
1674 // #92191#
1675 if( NULL != pTextEditOutlinerView )
1677 Outliner* pOutliner = pTextEditOutlinerView->GetOutliner();
1679 const ULONG nParaCount = pOutliner->GetParagraphCount();
1680 ULONG nPara;
1681 for( nPara = 0; nPara < nParaCount; nPara++ )
1683 pOutliner->SetStyleSheet( nPara, pStyleSheet );
1687 return SdrGlueEditView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1690 ////////////////////////////////////////////////////////////////////////////////////////////////////
1692 void SdrObjEditView::AddWindowToPaintView(OutputDevice* pNewWin)
1694 SdrGlueEditView::AddWindowToPaintView(pNewWin);
1696 if(mxTextEditObj.is() && !bTextEditOnlyOneView && pNewWin->GetOutDevType()==OUTDEV_WINDOW)
1698 OutlinerView* pOutlView=ImpMakeOutlinerView((Window*)pNewWin,FALSE,NULL);
1699 pTextEditOutliner->InsertView(pOutlView);
1703 void SdrObjEditView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
1705 SdrGlueEditView::DeleteWindowFromPaintView(pOldWin);
1707 if(mxTextEditObj.is() && !bTextEditOnlyOneView && pOldWin->GetOutDevType()==OUTDEV_WINDOW)
1709 for (ULONG i=pTextEditOutliner->GetViewCount(); i>0;) {
1710 i--;
1711 OutlinerView* pOLV=pTextEditOutliner->GetView(i);
1712 if (pOLV && pOLV->GetWindow()==(Window*)pOldWin) {
1713 delete pTextEditOutliner->RemoveView(i);
1719 BOOL SdrObjEditView::IsTextEditInSelectionMode() const
1721 return pTextEditOutliner!=NULL && pTextEditOutliner->IsInSelectionMode();
1724 ////////////////////////////////////////////////////////////////////////////////////////////////////
1726 // @@ @@ @@@@ @@@@ @@@@@ @@@@ @@ @@ @@@@ @@@@@ @@@@@
1727 // @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@
1728 // @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@
1729 // @@@@@@@ @@@@@@ @@ @@@@@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@@@
1730 // @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@
1731 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
1732 // @@ @@ @@ @@ @@@@ @@ @@ @@@@ @@ @@ @@@@ @@@@@ @@@@@
1734 ////////////////////////////////////////////////////////////////////////////////////////////////////
1736 BOOL SdrObjEditView::BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, Window* pWin)
1738 BOOL bRet=FALSE;
1739 BrkMacroObj();
1740 if (pObj!=NULL && pPV!=NULL && pWin!=NULL && pObj->HasMacro()) {
1741 nTol=ImpGetHitTolLogic(nTol,NULL);
1742 pMacroObj=pObj;
1743 pMacroPV=pPV;
1744 pMacroWin=pWin;
1745 bMacroDown=FALSE;
1746 nMacroTol=USHORT(nTol);
1747 aMacroDownPos=rPnt;
1748 MovMacroObj(rPnt);
1750 return bRet;
1753 void SdrObjEditView::ImpMacroUp(const Point& rUpPos)
1755 if (pMacroObj!=NULL && bMacroDown)
1757 SdrObjMacroHitRec aHitRec;
1758 aHitRec.aPos=rUpPos;
1759 aHitRec.aDownPos=aMacroDownPos;
1760 aHitRec.nTol=nMacroTol;
1761 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
1762 aHitRec.pPageView=pMacroPV;
1763 aHitRec.pOut=pMacroWin;
1764 pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec);
1765 bMacroDown=FALSE;
1769 void SdrObjEditView::ImpMacroDown(const Point& rDownPos)
1771 if (pMacroObj!=NULL && !bMacroDown)
1773 SdrObjMacroHitRec aHitRec;
1774 aHitRec.aPos=rDownPos;
1775 aHitRec.aDownPos=aMacroDownPos;
1776 aHitRec.nTol=nMacroTol;
1777 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
1778 aHitRec.pPageView=pMacroPV;
1779 aHitRec.bDown=TRUE;
1780 aHitRec.pOut=pMacroWin;
1781 pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec);
1782 bMacroDown=TRUE;
1786 void SdrObjEditView::MovMacroObj(const Point& rPnt)
1788 if (pMacroObj!=NULL) {
1789 SdrObjMacroHitRec aHitRec;
1790 aHitRec.aPos=rPnt;
1791 aHitRec.aDownPos=aMacroDownPos;
1792 aHitRec.nTol=nMacroTol;
1793 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
1794 aHitRec.pPageView=pMacroPV;
1795 aHitRec.bDown=bMacroDown;
1796 aHitRec.pOut=pMacroWin;
1797 BOOL bDown=pMacroObj->IsMacroHit(aHitRec);
1798 if (bDown) ImpMacroDown(rPnt);
1799 else ImpMacroUp(rPnt);
1803 void SdrObjEditView::BrkMacroObj()
1805 if (pMacroObj!=NULL) {
1806 ImpMacroUp(aMacroDownPos);
1807 pMacroObj=NULL;
1808 pMacroPV=NULL;
1809 pMacroWin=NULL;
1813 BOOL SdrObjEditView::EndMacroObj()
1815 if (pMacroObj!=NULL && bMacroDown) {
1816 ImpMacroUp(aMacroDownPos);
1817 SdrObjMacroHitRec aHitRec;
1818 aHitRec.aPos=aMacroDownPos;
1819 aHitRec.aDownPos=aMacroDownPos;
1820 aHitRec.nTol=nMacroTol;
1821 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
1822 aHitRec.pPageView=pMacroPV;
1823 aHitRec.bDown=TRUE;
1824 aHitRec.pOut=pMacroWin;
1825 bool bRet=pMacroObj->DoMacro(aHitRec);
1826 pMacroObj=NULL;
1827 pMacroPV=NULL;
1828 pMacroWin=NULL;
1829 return bRet;
1830 } else {
1831 BrkMacroObj();
1832 return FALSE;
1836 /** fills the given any with a XTextCursor for the current text selection.
1837 Leaves the any untouched if there currently is no text selected */
1838 void SdrObjEditView::getTextSelection( ::com::sun::star::uno::Any& rSelection )
1840 if( IsTextEdit() )
1842 OutlinerView* pOutlinerView = GetTextEditOutlinerView();
1843 if( pOutlinerView && pOutlinerView->HasSelection() )
1845 SdrObject* pObj = GetTextEditObject();
1847 if( pObj )
1849 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xText( pObj->getUnoShape(), ::com::sun::star::uno::UNO_QUERY );
1850 if( xText.is() )
1852 SvxUnoTextBase* pRange = SvxUnoTextBase::getImplementation( xText );
1853 if( pRange )
1855 rSelection <<= pRange->createTextCursorBySelection( pOutlinerView->GetSelection() );
1863 namespace sdr { namespace table {
1864 extern rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
1867 /* check if we have a single selection and that single object likes
1868 to handle the mouse and keyboard events itself
1870 @todo: the selection controller should be queried from the
1871 object specific view contact. Currently this method only
1872 works for tables.
1874 void SdrObjEditView::MarkListHasChanged()
1876 SdrGlueEditView::MarkListHasChanged();
1878 if( mxSelectionController.is() )
1880 mxLastSelectionController = mxSelectionController;
1881 mxSelectionController->onSelectionHasChanged();
1884 mxSelectionController.clear();
1886 const SdrMarkList& rMarkList=GetMarkedObjectList();
1887 if( rMarkList.GetMarkCount() == 1 )
1889 const SdrObject* pObj= rMarkList.GetMark(0)->GetMarkedSdrObj();
1890 // check for table
1891 if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
1893 mxSelectionController = sdr::table::CreateTableController( this, pObj, mxLastSelectionController );
1894 if( mxSelectionController.is() )
1896 mxLastSelectionController.clear();
1897 mxSelectionController->onSelectionHasChanged();
1903 IMPL_LINK( SdrObjEditView, EndPasteOrDropHdl, PasteOrDropInfos*, pInfos )
1905 OnEndPasteOrDrop( pInfos );
1906 return 0;
1909 IMPL_LINK( SdrObjEditView, BeginPasteOrDropHdl, PasteOrDropInfos*, pInfos )
1911 OnBeginPasteOrDrop( pInfos );
1912 return 0;
1915 void SdrObjEditView::OnBeginPasteOrDrop( PasteOrDropInfos* )
1917 // applications can derive from these virtual methods to do something before a drop or paste operation
1920 void SdrObjEditView::OnEndPasteOrDrop( PasteOrDropInfos* )
1922 // applications can derive from these virtual methods to do something before a drop or paste operation