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