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