xref: /trunk/main/sd/source/ui/func/futext.cxx (revision 02c50d825b93d3e4e3bd9073db30bd7615e748eb)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "futext.hxx"
29cdf0e10cSrcweir #include <editeng/eeitem.hxx>
30cdf0e10cSrcweir #include <editeng/editerr.hxx>
31cdf0e10cSrcweir #include <svx/dlgutil.hxx>
32cdf0e10cSrcweir #include <svx/svxerr.hxx>
33cdf0e10cSrcweir #include <tools/urlobj.hxx>
34cdf0e10cSrcweir #include <vcl/help.hxx>
35cdf0e10cSrcweir #include <editeng/editstat.hxx>
36cdf0e10cSrcweir #include <svl/aeitem.hxx>
37cdf0e10cSrcweir #include <svl/intitem.hxx>
38cdf0e10cSrcweir #include <svx/svdotext.hxx>
39cdf0e10cSrcweir #include <svx/svdogrp.hxx>
40d975be8cSAndre Fischer #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
41cdf0e10cSrcweir #include <editeng/flditem.hxx>
42cdf0e10cSrcweir #include <svl/style.hxx>
43cdf0e10cSrcweir #include <svx/svdpagv.hxx>
44cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
45cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46cdf0e10cSrcweir #include <sfx2/bindings.hxx>
47cdf0e10cSrcweir #include <sfx2/request.hxx>
48cdf0e10cSrcweir #include <editeng/editeng.hxx>
49cdf0e10cSrcweir #include <svx/svdoutl.hxx>
50cdf0e10cSrcweir #include <svx/svxids.hrc>
51cdf0e10cSrcweir #include <sfx2/docfile.hxx>
52b9e67834SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
53cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
54cdf0e10cSrcweir #include <editeng/outlobj.hxx>
55cdf0e10cSrcweir #include <svtools/langtab.hxx>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir // #104122#
58cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #include <svx/svdetc.hxx>
61cdf0e10cSrcweir #include <editeng/editview.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include "sdresid.hxx"
64cdf0e10cSrcweir #include "app.hrc"
65cdf0e10cSrcweir #include "res_bmp.hrc"
66cdf0e10cSrcweir #include "ViewShell.hxx"
67cdf0e10cSrcweir #include "ViewShellBase.hxx"
68cdf0e10cSrcweir #include "View.hxx"
69cdf0e10cSrcweir #include "Outliner.hxx"
70cdf0e10cSrcweir #include "Window.hxx"
71cdf0e10cSrcweir #include "drawdoc.hxx"
72cdf0e10cSrcweir #include "sdpage.hxx"
73cdf0e10cSrcweir #include "sdmod.hxx"
74cdf0e10cSrcweir #include "FrameView.hxx"
75cdf0e10cSrcweir #include "ToolBarManager.hxx"
76cdf0e10cSrcweir #include "DrawDocShell.hxx"
77cdf0e10cSrcweir #include "glob.hrc"
78cdf0e10cSrcweir #include "pres.hxx"
79cdf0e10cSrcweir #include "optsitem.hxx"
80cdf0e10cSrcweir 
81cdf0e10cSrcweir using ::rtl::OUString;
82cdf0e10cSrcweir using namespace ::com::sun::star;
83cdf0e10cSrcweir using namespace ::com::sun::star::uno;
84cdf0e10cSrcweir using namespace ::com::sun::star::lang;
85cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir namespace sd {
88cdf0e10cSrcweir 
89cdf0e10cSrcweir static sal_uInt16 SidArray[] = {
90cdf0e10cSrcweir     SID_STYLE_FAMILY2,                //    5542
91cdf0e10cSrcweir     SID_STYLE_FAMILY5,                //    5545
92cdf0e10cSrcweir     SID_CUT,                          //    5710
93cdf0e10cSrcweir     SID_COPY,                         //    5711
94cdf0e10cSrcweir     SID_ATTR_TABSTOP,                 //   10002
95cdf0e10cSrcweir     SID_ATTR_CHAR_FONT,               //   10007
96cdf0e10cSrcweir     SID_ATTR_CHAR_POSTURE,            //   10008
97cdf0e10cSrcweir     SID_ATTR_CHAR_WEIGHT,             //   10009
98cdf0e10cSrcweir     SID_ATTR_CHAR_UNDERLINE,          //   10014
99cdf0e10cSrcweir     SID_ATTR_CHAR_FONTHEIGHT,         //   10015
100cdf0e10cSrcweir     SID_ATTR_CHAR_COLOR,              //   10017
101cdf0e10cSrcweir     SID_ATTR_PARA_ADJUST_LEFT,        //   10028
102cdf0e10cSrcweir     SID_ATTR_PARA_ADJUST_RIGHT,       //   10029
103cdf0e10cSrcweir     SID_ATTR_PARA_ADJUST_CENTER,      //   10030
104cdf0e10cSrcweir     SID_ATTR_PARA_ADJUST_BLOCK,       //   10031
105cdf0e10cSrcweir     SID_ATTR_PARA_LINESPACE_10,       //   10034
106cdf0e10cSrcweir     SID_ATTR_PARA_LINESPACE_15,       //   10035
107cdf0e10cSrcweir     SID_ATTR_PARA_LINESPACE_20,       //   10036
108cdf0e10cSrcweir     SID_ATTR_PARA_LRSPACE,            //   10043
109cdf0e10cSrcweir     SID_OUTLINE_UP,                   //   10150
110cdf0e10cSrcweir     SID_OUTLINE_DOWN,                 //   10151
111cdf0e10cSrcweir     SID_OUTLINE_LEFT,                 //   10152
112cdf0e10cSrcweir     SID_OUTLINE_RIGHT,                //   10153
113cdf0e10cSrcweir     SID_FORMTEXT_STYLE,               //   10257
114cdf0e10cSrcweir     SID_SET_SUPER_SCRIPT,             //   10294
115cdf0e10cSrcweir     SID_SET_SUB_SCRIPT,               //   10295
116cdf0e10cSrcweir     SID_HYPERLINK_GETLINK,            //   10361
117cdf0e10cSrcweir     SID_CHARMAP,                      //   10503
118cdf0e10cSrcweir     SID_TEXTDIRECTION_LEFT_TO_RIGHT,  //   10907
119cdf0e10cSrcweir     SID_TEXTDIRECTION_TOP_TO_BOTTOM,  //   10908
120cdf0e10cSrcweir     SID_ATTR_PARA_LEFT_TO_RIGHT,      //   10950
121cdf0e10cSrcweir     SID_ATTR_PARA_RIGHT_TO_LEFT,      //   10951
122cdf0e10cSrcweir     FN_NUM_BULLET_ON,                 //   20138
123cdf0e10cSrcweir     SID_PARASPACE_INCREASE,           //   27346
124cdf0e10cSrcweir     SID_PARASPACE_DECREASE,           //   27347
125cdf0e10cSrcweir                             0 };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir TYPEINIT1( FuText, FuConstruct );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir static sal_Bool bTestText = 0;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir /*************************************************************************
133cdf0e10cSrcweir |*
134cdf0e10cSrcweir |* Basisklasse fuer Textfunktionen
135cdf0e10cSrcweir |*
136cdf0e10cSrcweir \************************************************************************/
137cdf0e10cSrcweir 
138cdf0e10cSrcweir FuText::FuText( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
139cdf0e10cSrcweir : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
140cdf0e10cSrcweir , bFirstObjCreated(sal_False)
141cdf0e10cSrcweir , rRequest (rReq)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir FunctionReference FuText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     FunctionReference xFunc( new FuText( pViewSh, pWin, pView, pDoc, rReq ) );
148cdf0e10cSrcweir     return xFunc;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir /*************************************************************************
152cdf0e10cSrcweir |*
153cdf0e10cSrcweir |* Destruktor
154cdf0e10cSrcweir |*
155cdf0e10cSrcweir \************************************************************************/
156cdf0e10cSrcweir 
157cdf0e10cSrcweir void FuText::disposing()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     if(mpView)
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         if(mpView->SdrEndTextEdit(sal_False) == SDRENDTEXTEDIT_DELETED)
162cdf0e10cSrcweir             mxTextObj.reset( 0 );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         // die RequestHandler der benutzten Outliner zuruecksetzen auf den
165cdf0e10cSrcweir         // Handler am Dokument
166cdf0e10cSrcweir         ::Outliner* pOutliner = mpView->GetTextEditOutliner();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         if (pOutliner)
169cdf0e10cSrcweir             pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /*************************************************************************
174cdf0e10cSrcweir |*
175cdf0e10cSrcweir |* Execute functionality of this class:
176cdf0e10cSrcweir |*
177cdf0e10cSrcweir |* #71422: Start the functionality of this class in this method
178cdf0e10cSrcweir |* and not in the ctor.
179cdf0e10cSrcweir |* If you construct an object of this class and you put the
180cdf0e10cSrcweir |* address of this object to pFuActual you've got a problem,
181cdf0e10cSrcweir |* because some methods inside DoExecute use the pFuActual-Pointer.
182cdf0e10cSrcweir |* If the code inside DoExecute is executed inside the ctor,
183cdf0e10cSrcweir |* the value of pFuActual is not right. And the value will not
184cdf0e10cSrcweir |* be right until the ctor finished !!!
185cdf0e10cSrcweir |*
186cdf0e10cSrcweir \************************************************************************/
187cdf0e10cSrcweir void FuText::DoExecute( SfxRequest& )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
190cdf0e10cSrcweir         ToolBarManager::TBG_FUNCTION,
191cdf0e10cSrcweir         RID_DRAW_TEXT_TOOLBOX);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     mpView->SetCurrentObj(OBJ_TEXT);
194cdf0e10cSrcweir     mpView->SetEditMode(SDREDITMODE_EDIT);
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     if (nSlotId == SID_TEXTEDIT)
199cdf0e10cSrcweir     {
200cdf0e10cSrcweir         // Try to select an object
201cdf0e10cSrcweir         SdrPageView* pPV = mpView->GetSdrPageView();
202cdf0e10cSrcweir         SdrViewEvent aVEvt;
203cdf0e10cSrcweir         mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
204cdf0e10cSrcweir         mpView->MarkObj(aVEvt.pRootObj, pPV);
205cdf0e10cSrcweir 
206cdf0e10cSrcweir         mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.pObj ) );
207cdf0e10cSrcweir     }
208cdf0e10cSrcweir     else if (mpView->AreObjectsMarked())
209cdf0e10cSrcweir     {
210cdf0e10cSrcweir         const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         if (rMarkList.GetMarkCount() == 1)
213cdf0e10cSrcweir         {
214cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
215cdf0e10cSrcweir             mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
216cdf0e10cSrcweir         }
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     // check for table
220cdf0e10cSrcweir     if (mpView->AreObjectsMarked())
221cdf0e10cSrcweir     {
222cdf0e10cSrcweir         const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
223cdf0e10cSrcweir 
224cdf0e10cSrcweir         if (rMarkList.GetMarkCount() == 1)
225cdf0e10cSrcweir         {
226cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
227cdf0e10cSrcweir             if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
228cdf0e10cSrcweir             {
229cdf0e10cSrcweir                 mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX );
230cdf0e10cSrcweir             }
231cdf0e10cSrcweir         }
232cdf0e10cSrcweir     }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     sal_Bool bQuickDrag = sal_True;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     const SfxItemSet* pArgs = rRequest.GetArgs();
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     if (pArgs
239cdf0e10cSrcweir 
240cdf0e10cSrcweir         // #98198# test for type before using
241cdf0e10cSrcweir         && SID_TEXTEDIT == nSlotId
242cdf0e10cSrcweir         && SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         && (sal_uInt16)((SfxUInt16Item&)pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
245cdf0e10cSrcweir     {
246cdf0e10cSrcweir         // Selection by doubleclick -> don't allow QuickDrag
247cdf0e10cSrcweir         bQuickDrag = sal_False;
248cdf0e10cSrcweir     }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     SetInEditMode(aMEvt, bQuickDrag);
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir /*************************************************************************
254cdf0e10cSrcweir |*
255cdf0e10cSrcweir |* MouseButtonDown-event
256cdf0e10cSrcweir |*
257cdf0e10cSrcweir \************************************************************************/
258cdf0e10cSrcweir 
259cdf0e10cSrcweir sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
260cdf0e10cSrcweir {
261cdf0e10cSrcweir     bMBDown = sal_True;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     /* af: (de)Select object before showing the context menu.
266cdf0e10cSrcweir     // Fuer PopupMenu (vorher DrawViewShell)
267cdf0e10cSrcweir     if ((rMEvt.GetButtons() == MOUSE_RIGHT) && rMEvt.GetClicks() == 1 &&
268cdf0e10cSrcweir         mpView->IsTextEdit())
269cdf0e10cSrcweir     {
270cdf0e10cSrcweir         return (sal_True);
271cdf0e10cSrcweir     }
272cdf0e10cSrcweir         */
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     mpView->SetMarkHdlWhenTextEdit(sal_True);
275cdf0e10cSrcweir     SdrViewEvent aVEvt;
276cdf0e10cSrcweir     SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     if (eHit == SDRHIT_TEXTEDIT)
279cdf0e10cSrcweir     {
280cdf0e10cSrcweir         // Text getroffen -> Event von SdrView auswerten lassen
281cdf0e10cSrcweir         if (mpView->MouseButtonDown(rMEvt, mpWindow))
282cdf0e10cSrcweir             return (sal_True);
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     if (rMEvt.GetClicks() == 1)
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir         if (mpView->IsTextEdit() && eHit != SDRHIT_MARKEDOBJECT && eHit != SDRHIT_HANDLE)
288cdf0e10cSrcweir         {
289cdf0e10cSrcweir             // Texteingabe beenden
290cdf0e10cSrcweir             if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
291cdf0e10cSrcweir             {
292cdf0e10cSrcweir                 // Bugfix von MBA: bei Doppelclick auf der Wiese im Modus Text wird
293cdf0e10cSrcweir                 // beim zweiten Click eHit = SDRHIT_TEXTEDITOBJ erhalten, weil ja der
294cdf0e10cSrcweir                 // zweite Click auf das im ersten Click angelegte TextObject geht.
295cdf0e10cSrcweir                 // Dieses wird aber in SdrEndTextEdit entfernt, weil es leer ist. Es
296cdf0e10cSrcweir                 // befindet sich aber noch in der Mark-Liste und der Aufruf MarkObj
297cdf0e10cSrcweir                 // weiter unten greift dann auf das tote Object zu.
298cdf0e10cSrcweir                 // Als einfacher Fix wird nach SdrEndTextEdit noch einmal eHit ermittelt,
299cdf0e10cSrcweir                 // was dann SDRHIT_NONE liefert.
300cdf0e10cSrcweir                 mxTextObj.reset( NULL );
301cdf0e10cSrcweir                 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
302cdf0e10cSrcweir             }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir             mpView->SetCurrentObj(OBJ_TEXT);
305cdf0e10cSrcweir             mpView->SetEditMode(SDREDITMODE_EDIT);
306cdf0e10cSrcweir         }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         if (rMEvt.IsLeft() || rMEvt.IsRight())
309cdf0e10cSrcweir         {
310cdf0e10cSrcweir             mpWindow->CaptureMouse();
311cdf0e10cSrcweir             SdrObject* pObj;
312cdf0e10cSrcweir             SdrPageView* pPV = mpView->GetSdrPageView();
313cdf0e10cSrcweir 
314cdf0e10cSrcweir             if (eHit == SDRHIT_TEXTEDIT)
315cdf0e10cSrcweir             {
316cdf0e10cSrcweir                 SetInEditMode(rMEvt, sal_False);
317cdf0e10cSrcweir             }
318cdf0e10cSrcweir             else
319cdf0e10cSrcweir             {
320cdf0e10cSrcweir                 sal_Bool bMacro = sal_False;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir                 if (bMacro && mpView->PickObj(aMDPos,mpView->getHitTolLog(),pObj,pPV,SDRSEARCH_PICKMACRO))
323cdf0e10cSrcweir                 {
324cdf0e10cSrcweir                     // Makro
325cdf0e10cSrcweir                     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
326cdf0e10cSrcweir                     mpView->BegMacroObj(aMDPos,nHitLog,pObj,pPV,mpWindow);
327cdf0e10cSrcweir                 }
328cdf0e10cSrcweir                 else
329cdf0e10cSrcweir                 {
330cdf0e10cSrcweir                     if (eHit != SDRHIT_HANDLE)
331cdf0e10cSrcweir                     {
332cdf0e10cSrcweir                         // Selektion aufheben
333cdf0e10cSrcweir                         if (!rMEvt.IsShift() && eHit == SDRHIT_TEXTEDITOBJ)
334cdf0e10cSrcweir                         {
335cdf0e10cSrcweir                             mpView->UnmarkAll();
336cdf0e10cSrcweir                             mpView->SetDragMode(SDRDRAG_MOVE);
337cdf0e10cSrcweir                         }
338cdf0e10cSrcweir                     }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir                     if ( aVEvt.eEvent == SDREVENT_EXECUTEURL                   ||
341cdf0e10cSrcweir                          eHit == SDRHIT_HANDLE                                 ||
342cdf0e10cSrcweir                          eHit == SDRHIT_MARKEDOBJECT                           ||
343cdf0e10cSrcweir                          eHit == SDRHIT_TEXTEDITOBJ                            ||
344cdf0e10cSrcweir                          ( eHit == SDRHIT_UNMARKEDOBJECT && bFirstObjCreated &&
345cdf0e10cSrcweir                            !bPermanent ) )
346cdf0e10cSrcweir                     {
347cdf0e10cSrcweir                         /**********************************************************
348cdf0e10cSrcweir                         * Handle, markiertes oder unmarkiertes Objekt getroffen
349cdf0e10cSrcweir                         **********************************************************/
350cdf0e10cSrcweir                         if (eHit == SDRHIT_TEXTEDITOBJ)
351cdf0e10cSrcweir                         {
352cdf0e10cSrcweir                             /******************************************************
353cdf0e10cSrcweir                             * Text eines unmarkierten Objekts getroffen:
354cdf0e10cSrcweir                             * Objekt wird selektiert und in EditMode versetzt
355cdf0e10cSrcweir                             ******************************************************/
356cdf0e10cSrcweir                             mpView->MarkObj(aVEvt.pRootObj, pPV);
357cdf0e10cSrcweir 
358cdf0e10cSrcweir                             if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
359cdf0e10cSrcweir                             {
360cdf0e10cSrcweir                                 mxTextObj.reset( static_cast<SdrTextObj*>(aVEvt.pObj) );
361cdf0e10cSrcweir                             }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir                             SetInEditMode(rMEvt, sal_True);
364cdf0e10cSrcweir                         }
365cdf0e10cSrcweir                         else if (aVEvt.eEvent == SDREVENT_EXECUTEURL && !rMEvt.IsMod2())
366cdf0e10cSrcweir                         {
367cdf0e10cSrcweir                             /******************************************************
368cdf0e10cSrcweir                             * URL ausfuehren
369cdf0e10cSrcweir                             ******************************************************/
370cdf0e10cSrcweir                             mpWindow->ReleaseMouse();
371cdf0e10cSrcweir                             SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
372cdf0e10cSrcweir                             SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
373cdf0e10cSrcweir                             SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
374cdf0e10cSrcweir                             SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
375cdf0e10cSrcweir                             mpWindow->ReleaseMouse();
376cdf0e10cSrcweir 
377cdf0e10cSrcweir                             if (rMEvt.IsMod1())
378cdf0e10cSrcweir                             {
379cdf0e10cSrcweir                                 // Im neuen Frame oeffnen
380cdf0e10cSrcweir                                 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
381cdf0e10cSrcweir                                             &aStrItem, &aBrowseItem, &aReferer, 0L);
382cdf0e10cSrcweir                             }
383cdf0e10cSrcweir                             else
384cdf0e10cSrcweir                             {
385cdf0e10cSrcweir                                 // Im aktuellen Frame oeffnen
386cdf0e10cSrcweir                                 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
387cdf0e10cSrcweir                                 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
388cdf0e10cSrcweir                                             &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
389cdf0e10cSrcweir                             }
390cdf0e10cSrcweir                         }
391cdf0e10cSrcweir                         else
392cdf0e10cSrcweir                         {
393cdf0e10cSrcweir                             /******************************************************
394cdf0e10cSrcweir                             * Objekt oder Handle draggen
395cdf0e10cSrcweir                             ******************************************************/
396cdf0e10cSrcweir 
397cdf0e10cSrcweir                             // #i78748#
398cdf0e10cSrcweir                             // do the EndTextEdit first, it will delete the handles and force a
399cdf0e10cSrcweir                             // recreation. This will make aVEvt.pHdl to point to a deleted handle,
400cdf0e10cSrcweir                             // thus it is necessary to reset it and to get it again.
401cdf0e10cSrcweir 
402cdf0e10cSrcweir                             // #i112855#
403cdf0e10cSrcweir                             // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObjet
404cdf0e10cSrcweir                             // this caused SdrEndTextEdit() to be called also when not in text editing and
405cdf0e10cSrcweir                             // this does not make sense and caused troubles. (see issue 112855)
406cdf0e10cSrcweir 
407cdf0e10cSrcweir //                          ::Outliner* pOutl = mpView->GetTextEditOutliner();
408cdf0e10cSrcweir //
409cdf0e10cSrcweir //                          if (mxTextObj.is() && (mxTextObj->GetOutlinerParaObject() ||
410cdf0e10cSrcweir //                              (pOutl && pOutl->GetText(pOutl->GetParagraph( 0 )).Len() != 0)))
411cdf0e10cSrcweir                             if( mpView->IsTextEdit() )
412cdf0e10cSrcweir                             {
413cdf0e10cSrcweir                                 mpView->SdrEndTextEdit();
414cdf0e10cSrcweir 
415cdf0e10cSrcweir                                 if(aVEvt.pHdl)
416cdf0e10cSrcweir                                 {
417cdf0e10cSrcweir                                     // force new handle identification, the pointer will be dead here
418cdf0e10cSrcweir                                     // since SdrEndTextEdit has resetted (deleted) the handles.
419cdf0e10cSrcweir                                     aVEvt.pHdl = 0;
420cdf0e10cSrcweir                                     mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
421cdf0e10cSrcweir                                 }
422cdf0e10cSrcweir                             }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir                             if (!aVEvt.pHdl)
425cdf0e10cSrcweir                             {
426cdf0e10cSrcweir                                 if( eHit == SDRHIT_UNMARKEDOBJECT )
427cdf0e10cSrcweir                                 {
428cdf0e10cSrcweir                                     if ( !rMEvt.IsShift() )
429cdf0e10cSrcweir                                         mpView->UnmarkAll();
430cdf0e10cSrcweir 
431cdf0e10cSrcweir                                     mpView->MarkObj(aVEvt.pRootObj, pPV);
432cdf0e10cSrcweir                                 }
433cdf0e10cSrcweir 
434cdf0e10cSrcweir                                 // Objekt draggen
435cdf0e10cSrcweir                                 bFirstMouseMove = sal_True;
436cdf0e10cSrcweir                                 aDragTimer.Start();
437cdf0e10cSrcweir                             }
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 
440cdf0e10cSrcweir                             if ( ! rMEvt.IsRight())
441cdf0e10cSrcweir                             {
442cdf0e10cSrcweir                                 // we need to pick again since SdrEndTextEdit can rebuild the handles list
443cdf0e10cSrcweir                                 eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
444cdf0e10cSrcweir                                 if( (eHit == SDRHIT_HANDLE) || (eHit == SDRHIT_MARKEDOBJECT) )
445cdf0e10cSrcweir                                 {
446cdf0e10cSrcweir                                     sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
447cdf0e10cSrcweir                                     mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
448cdf0e10cSrcweir                                 }
449cdf0e10cSrcweir                             }
450cdf0e10cSrcweir                             bReturn = true;
451cdf0e10cSrcweir                         }
452cdf0e10cSrcweir                     }
453cdf0e10cSrcweir                     else if ( nSlotId != SID_TEXTEDIT &&
454cdf0e10cSrcweir                               (bPermanent || !bFirstObjCreated) )
455cdf0e10cSrcweir                     {
456cdf0e10cSrcweir                         /**********************************************************
457cdf0e10cSrcweir                         * Objekt erzeugen
458cdf0e10cSrcweir                         **********************************************************/
459cdf0e10cSrcweir                         mpView->SetCurrentObj(OBJ_TEXT);
460cdf0e10cSrcweir                         mpView->SetEditMode(SDREDITMODE_CREATE);
461cdf0e10cSrcweir                         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
462cdf0e10cSrcweir                         mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
463cdf0e10cSrcweir                     }
464cdf0e10cSrcweir                     else
465cdf0e10cSrcweir                     {
466cdf0e10cSrcweir                         /**********************************************************
467cdf0e10cSrcweir                         * Selektieren
468cdf0e10cSrcweir                         **********************************************************/
469cdf0e10cSrcweir                         if( !rMEvt.IsShift() )
470cdf0e10cSrcweir                             mpView->UnmarkAll();
471cdf0e10cSrcweir 
472cdf0e10cSrcweir                         mpView->BegMarkObj( aMDPos );
473cdf0e10cSrcweir                     }
474cdf0e10cSrcweir                 }
475cdf0e10cSrcweir             }
476cdf0e10cSrcweir         }
477cdf0e10cSrcweir     }
478cdf0e10cSrcweir     else if ( rMEvt.GetClicks() == 2 && !mpView->IsTextEdit() )
479cdf0e10cSrcweir     {
480cdf0e10cSrcweir         MouseEvent aMEvt( mpWindow->GetPointerPosPixel() );
481cdf0e10cSrcweir         SetInEditMode( aMEvt, sal_False );
482cdf0e10cSrcweir     }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     if (!bIsInDragMode)
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         ForcePointer(&rMEvt);
487cdf0e10cSrcweir         mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir     return (bReturn);
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir /*************************************************************************
494cdf0e10cSrcweir |*
495cdf0e10cSrcweir |* MouseMove-event
496cdf0e10cSrcweir |*
497cdf0e10cSrcweir \************************************************************************/
498cdf0e10cSrcweir 
499cdf0e10cSrcweir sal_Bool FuText::MouseMove(const MouseEvent& rMEvt)
500cdf0e10cSrcweir {
501cdf0e10cSrcweir     sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
502cdf0e10cSrcweir 
503cdf0e10cSrcweir     if (aDragTimer.IsActive() )
504cdf0e10cSrcweir     {
505cdf0e10cSrcweir         if( bFirstMouseMove )
506cdf0e10cSrcweir             bFirstMouseMove = sal_False;
507cdf0e10cSrcweir         else
508cdf0e10cSrcweir             aDragTimer.Stop();
509cdf0e10cSrcweir     }
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     if (!bReturn && mpView->IsAction() && !mpDocSh->IsReadOnly())
512cdf0e10cSrcweir     {
513cdf0e10cSrcweir         Point aPix(rMEvt.GetPosPixel());
514cdf0e10cSrcweir         Point aPnt(mpWindow->PixelToLogic(aPix));
515cdf0e10cSrcweir 
516cdf0e10cSrcweir         ForceScroll(aPix);
517cdf0e10cSrcweir         mpView->MovAction(aPnt);
518cdf0e10cSrcweir     }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir     ForcePointer(&rMEvt);
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     return (bReturn);
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir /*************************************************************************
526cdf0e10cSrcweir |*
527cdf0e10cSrcweir |* MouseButtonUp-event
528cdf0e10cSrcweir |*
529cdf0e10cSrcweir \************************************************************************/
530cdf0e10cSrcweir 
531cdf0e10cSrcweir // #97016#
532cdf0e10cSrcweir void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj)
533cdf0e10cSrcweir {
534cdf0e10cSrcweir     if(mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
535cdf0e10cSrcweir     {
536cdf0e10cSrcweir         if( nSlotId == SID_ATTR_CHAR )
537cdf0e10cSrcweir         {
538cdf0e10cSrcweir             // Impress-Textobjekt wird erzeugt (faellt auf Zeilenhoehe zusammen)
539cdf0e10cSrcweir             // Damit das Objekt beim anschliessenden Erzeugen gleich die richtige
540cdf0e10cSrcweir             // Hoehe bekommt (sonst wird zuviel gepainted)
541cdf0e10cSrcweir             SfxItemSet aSet(mpViewShell->GetPool());
542cdf0e10cSrcweir             aSet.Put(SdrTextMinFrameHeightItem(0));
543cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
544cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
545cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
546cdf0e10cSrcweir             pTxtObj->AdjustTextFrameWidthAndHeight();
547cdf0e10cSrcweir             aSet.Put(SdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height()));
548cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
549cdf0e10cSrcweir         }
550cdf0e10cSrcweir         else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
551cdf0e10cSrcweir         {
552cdf0e10cSrcweir             SfxItemSet aSet(mpViewShell->GetPool());
553cdf0e10cSrcweir             aSet.Put(SdrTextMinFrameWidthItem(0));
554cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
555cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
556cdf0e10cSrcweir 
557cdf0e10cSrcweir             // #91853# Needs to be set since default is SDRTEXTHORZADJUST_BLOCK
558cdf0e10cSrcweir             aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
559cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
560cdf0e10cSrcweir             pTxtObj->AdjustTextFrameWidthAndHeight();
561cdf0e10cSrcweir             aSet.Put(SdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width()));
562cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
563cdf0e10cSrcweir         }
564cdf0e10cSrcweir     }
565cdf0e10cSrcweir     else
566cdf0e10cSrcweir     {
567cdf0e10cSrcweir         if( nSlotId == SID_ATTR_CHAR_VERTICAL )
568cdf0e10cSrcweir         {
569cdf0e10cSrcweir             // draw text object, needs to be initialized when vertical text is used
570cdf0e10cSrcweir             SfxItemSet aSet(mpViewShell->GetPool());
571cdf0e10cSrcweir 
572cdf0e10cSrcweir             // #91510#
573cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
574cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
575cdf0e10cSrcweir 
576cdf0e10cSrcweir             // #91508#
577cdf0e10cSrcweir             //aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
578cdf0e10cSrcweir             //aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
579cdf0e10cSrcweir 
580cdf0e10cSrcweir             // #107235#
581cdf0e10cSrcweir             // Set defaults for vertical klick-n'drag text object, pool defaults are:
582cdf0e10cSrcweir             // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP
583cdf0e10cSrcweir             // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK
584cdf0e10cSrcweir             // Analog to that (thus, #91508# was not completely correct):
585cdf0e10cSrcweir             aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
586cdf0e10cSrcweir             aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
587cdf0e10cSrcweir 
588cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
589cdf0e10cSrcweir         }
590cdf0e10cSrcweir     }
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir // #97016#
594cdf0e10cSrcweir void FuText::ImpSetAttributesFitToSize(SdrTextObj* pTxtObj)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     // FitToSize (An Rahmen anpassen)
597cdf0e10cSrcweir     SfxItemSet aSet(mpViewShell->GetPool(), SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
59826734c99SArmin Le Grand     SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
59926734c99SArmin Le Grand     aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
600cdf0e10cSrcweir     aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
601cdf0e10cSrcweir     aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
602cdf0e10cSrcweir     pTxtObj->SetMergedItemSet(aSet);
603cdf0e10cSrcweir     pTxtObj->AdjustTextFrameWidthAndHeight();
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir // #97016#
607cdf0e10cSrcweir void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj)
608cdf0e10cSrcweir {
60926734c99SArmin Le Grand     SfxItemSet aSet(mpViewShell->GetPool(),
61026734c99SArmin Le Grand         SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWWIDTH);
61126734c99SArmin Le Grand     SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
61226734c99SArmin Le Grand     aSet.Put(SdrTextFitToSizeTypeItem(eFTS));
613cdf0e10cSrcweir     aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
614cdf0e10cSrcweir     aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
615cdf0e10cSrcweir     pTxtObj->SetMergedItemSet(aSet);
616cdf0e10cSrcweir     pTxtObj->AdjustTextFrameWidthAndHeight();
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir // #97016#
620cdf0e10cSrcweir void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir     // Normales Textobjekt
623cdf0e10cSrcweir     if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
624cdf0e10cSrcweir     {
625cdf0e10cSrcweir         if( nSlotId == SID_ATTR_CHAR )
626cdf0e10cSrcweir         {
627cdf0e10cSrcweir             // Impress-Textobjekt (faellt auf Zeilenhoehe zusammen)
628cdf0e10cSrcweir             SfxItemSet aSet(mpViewShell->GetPool());
629cdf0e10cSrcweir             aSet.Put(SdrTextMinFrameHeightItem(0));
630cdf0e10cSrcweir             aSet.Put(SdrTextMaxFrameHeightItem(0));
631cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
632cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowWidthItem(sal_False));
633cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
634cdf0e10cSrcweir         }
635cdf0e10cSrcweir         else if( nSlotId == SID_ATTR_CHAR_VERTICAL )
636cdf0e10cSrcweir         {
637cdf0e10cSrcweir             SfxItemSet aSet(mpViewShell->GetPool());
638cdf0e10cSrcweir             aSet.Put(SdrTextMinFrameWidthItem(0));
639cdf0e10cSrcweir             aSet.Put(SdrTextMaxFrameWidthItem(0));
640cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
641cdf0e10cSrcweir             aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
642cdf0e10cSrcweir             pTxtObj->SetMergedItemSet(aSet);
643cdf0e10cSrcweir         }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir         pTxtObj->AdjustTextFrameWidthAndHeight();
646cdf0e10cSrcweir     }
647cdf0e10cSrcweir }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
650cdf0e10cSrcweir {
651cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
652cdf0e10cSrcweir 
653cdf0e10cSrcweir     if (aDragTimer.IsActive())
654cdf0e10cSrcweir     {
655cdf0e10cSrcweir         aDragTimer.Stop();
656cdf0e10cSrcweir         bIsInDragMode = sal_False;
657cdf0e10cSrcweir     }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
662cdf0e10cSrcweir 
663cdf0e10cSrcweir     if( (mpView && mpView->MouseButtonUp(rMEvt, mpWindow)) || rMEvt.GetClicks() == 2 )
664cdf0e10cSrcweir         return (sal_True); // Event von der SdrView ausgewertet
665cdf0e10cSrcweir 
666cdf0e10cSrcweir     sal_Bool bEmptyTextObj = sal_False;
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     if (mxTextObj.is())
669cdf0e10cSrcweir     {
670cdf0e10cSrcweir         const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
671cdf0e10cSrcweir 
672cdf0e10cSrcweir         if (rMarkList.GetMarkCount() == 1
673cdf0e10cSrcweir             && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
674cdf0e10cSrcweir         {
675cdf0e10cSrcweir             if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
676cdf0e10cSrcweir                 bEmptyTextObj = sal_True;
677cdf0e10cSrcweir             else
678cdf0e10cSrcweir                 bFirstObjCreated = sal_True;
679cdf0e10cSrcweir         }
680cdf0e10cSrcweir         else
681cdf0e10cSrcweir         {
682cdf0e10cSrcweir             mxTextObj.reset( 0 );
683cdf0e10cSrcweir         }
684cdf0e10cSrcweir     }
685cdf0e10cSrcweir 
686cdf0e10cSrcweir     if( mpView && mpView->IsDragObj())
687cdf0e10cSrcweir     {
688cdf0e10cSrcweir         /**********************************************************************
689cdf0e10cSrcweir         * Objekt wurde verschoben
690cdf0e10cSrcweir         **********************************************************************/
691cdf0e10cSrcweir         FrameView* pFrameView = mpViewShell->GetFrameView();
692cdf0e10cSrcweir         sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
693cdf0e10cSrcweir 
694cdf0e10cSrcweir         if (bDragWithCopy)
695cdf0e10cSrcweir         {
696cdf0e10cSrcweir             bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
697cdf0e10cSrcweir         }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir         mpView->SetDragWithCopy(bDragWithCopy);
700cdf0e10cSrcweir         mpView->EndDragObj( mpView->IsDragWithCopy() );
701cdf0e10cSrcweir         mpView->ForceMarkedToAnotherPage();
702cdf0e10cSrcweir         mpView->SetCurrentObj(OBJ_TEXT);
703cdf0e10cSrcweir 
704cdf0e10cSrcweir         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
705cdf0e10cSrcweir 
706cdf0e10cSrcweir         if ( mpView->IsRotateAllowed() && mpViewShell->GetFrameView()->IsClickChangeRotation() && (rMEvt.GetClicks() != 2) &&
707cdf0e10cSrcweir             !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
708cdf0e10cSrcweir             Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
709cdf0e10cSrcweir             Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
710cdf0e10cSrcweir         {
711cdf0e10cSrcweir             // toggle to rotation mode
712cdf0e10cSrcweir             mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_ROTATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
713cdf0e10cSrcweir         }
714cdf0e10cSrcweir     }
715cdf0e10cSrcweir     else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
716cdf0e10cSrcweir     {
717cdf0e10cSrcweir         /**********************************************************************
718cdf0e10cSrcweir         * Objekt wurde erzeugt
719cdf0e10cSrcweir         **********************************************************************/
720cdf0e10cSrcweir         mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
721cdf0e10cSrcweir 
722cdf0e10cSrcweir         if( mxTextObj.is() )
723cdf0e10cSrcweir         {
724cdf0e10cSrcweir             //AW outliner needs to be set to vertical when there is no
725cdf0e10cSrcweir             // outliner object up to now; also it needs to be set back to not
726cdf0e10cSrcweir             // vertical when there was a vertical one used last time.
727cdf0e10cSrcweir             OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
728cdf0e10cSrcweir             SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj());
729cdf0e10cSrcweir             sal_Bool bVertical((pOPO && pOPO->IsVertical())
730cdf0e10cSrcweir                 || nSlotId == SID_ATTR_CHAR_VERTICAL
731cdf0e10cSrcweir                 || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
732cdf0e10cSrcweir             rOutl.SetVertical(bVertical);
733cdf0e10cSrcweir 
734cdf0e10cSrcweir             // #107235#
735cdf0e10cSrcweir             // Before ImpSetAttributesForNewTextObject the vertical writing mode
736cdf0e10cSrcweir             // needs to be set at the object. This is done here at the OutlinerParaObject
737cdf0e10cSrcweir             // directly to not mirror the layout text items involved. These items will be set
738cdf0e10cSrcweir             // from ImpSetAttributesForNewTextObject and below.
739cdf0e10cSrcweir             OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
740cdf0e10cSrcweir 
741cdf0e10cSrcweir             if(!pPara)
742cdf0e10cSrcweir             {
743cdf0e10cSrcweir                 GetTextObj()->ForceOutlinerParaObject();
744cdf0e10cSrcweir                 pPara = GetTextObj()->GetOutlinerParaObject();
745cdf0e10cSrcweir             }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir             if(pPara && (bool)bVertical != pPara->IsVertical())
748cdf0e10cSrcweir             {
749cdf0e10cSrcweir                 // set ParaObject orientation accordingly
750cdf0e10cSrcweir                 pPara->SetVertical(bVertical);
751cdf0e10cSrcweir             }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir             // #97016#
754cdf0e10cSrcweir             ImpSetAttributesForNewTextObject(GetTextObj());
755cdf0e10cSrcweir         }
756cdf0e10cSrcweir 
757cdf0e10cSrcweir         if (!mpView->EndCreateObj(SDRCREATE_FORCEEND))
758cdf0e10cSrcweir         {
759cdf0e10cSrcweir             // Textobjekt konnte nicht erzeugt werden
760cdf0e10cSrcweir             mxTextObj.reset(0);
761cdf0e10cSrcweir         }
762cdf0e10cSrcweir         else if (nSlotId == SID_TEXT_FITTOSIZE)
763cdf0e10cSrcweir         {
764cdf0e10cSrcweir             // #97016#
765cdf0e10cSrcweir             ImpSetAttributesFitToSize(GetTextObj());
766cdf0e10cSrcweir 
767cdf0e10cSrcweir             SetInEditMode(rMEvt, sal_False);
768cdf0e10cSrcweir         }
769cdf0e10cSrcweir         else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
770cdf0e10cSrcweir         {
771cdf0e10cSrcweir             // #97016#
772cdf0e10cSrcweir             ImpSetAttributesFitToSizeVertical(GetTextObj());
773cdf0e10cSrcweir 
774cdf0e10cSrcweir             SetInEditMode(rMEvt, sal_False);
775cdf0e10cSrcweir         }
776cdf0e10cSrcweir         else
777cdf0e10cSrcweir         {
778cdf0e10cSrcweir             // #97016#
779cdf0e10cSrcweir             ImpSetAttributesFitCommon(GetTextObj());
780cdf0e10cSrcweir 
781cdf0e10cSrcweir             // Damit die Handles und der graue Rahmen stimmen
782cdf0e10cSrcweir             mpView->AdjustMarkHdl();
783cdf0e10cSrcweir             mpView->PickHandle(aPnt);
784cdf0e10cSrcweir             SetInEditMode(rMEvt, sal_False);
785cdf0e10cSrcweir         }
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir     else if ( mpView && mpView->IsAction())
788cdf0e10cSrcweir     {
789cdf0e10cSrcweir         mpView->EndAction();
790cdf0e10cSrcweir     }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir     ForcePointer(&rMEvt);
793cdf0e10cSrcweir     mpWindow->ReleaseMouse();
794cdf0e10cSrcweir     sal_uInt16 nDrgLog1 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
795cdf0e10cSrcweir 
796cdf0e10cSrcweir     if ( mpView && !mpView->AreObjectsMarked() &&
797cdf0e10cSrcweir          Abs(aMDPos.X() - aPnt.X()) < nDrgLog1 &&
798cdf0e10cSrcweir          Abs(aMDPos.Y() - aPnt.Y()) < nDrgLog1 &&
799cdf0e10cSrcweir          !rMEvt.IsShift() && !rMEvt.IsMod2() )
800cdf0e10cSrcweir     {
801cdf0e10cSrcweir         SdrPageView* pPV = mpView->GetSdrPageView();
802cdf0e10cSrcweir         SdrViewEvent aVEvt;
803cdf0e10cSrcweir         mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
804cdf0e10cSrcweir         mpView->MarkObj(aVEvt.pRootObj, pPV);
805cdf0e10cSrcweir     }
806cdf0e10cSrcweir 
807cdf0e10cSrcweir     if ( !mxTextObj.is() && mpView )
808cdf0e10cSrcweir     {
809cdf0e10cSrcweir         if ( ( (!bEmptyTextObj   &&  bPermanent) ||
810cdf0e10cSrcweir              (!bFirstObjCreated && !bPermanent) ) &&
811cdf0e10cSrcweir               !mpDocSh->IsReadOnly()               &&
812cdf0e10cSrcweir               nSlotId != SID_TEXTEDIT )
813cdf0e10cSrcweir         {
814cdf0e10cSrcweir             /**********************************************************************
815cdf0e10cSrcweir             * Mengentext (linksbuendiges AutoGrow)
816cdf0e10cSrcweir             **********************************************************************/
817cdf0e10cSrcweir             mpView->SetCurrentObj(OBJ_TEXT);
818cdf0e10cSrcweir             mpView->SetEditMode(SDREDITMODE_CREATE);
819cdf0e10cSrcweir             sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
820cdf0e10cSrcweir             mpView->BegCreateObj(aMDPos, (OutputDevice*) NULL, nDrgLog);
821cdf0e10cSrcweir 
822cdf0e10cSrcweir             sal_Bool bSnapEnabled = mpView->IsSnapEnabled();
823cdf0e10cSrcweir 
824cdf0e10cSrcweir             if (bSnapEnabled)
825cdf0e10cSrcweir                 mpView->SetSnapEnabled(sal_False);
826cdf0e10cSrcweir 
827cdf0e10cSrcweir             aPnt.X() += nDrgLog + nDrgLog;
828cdf0e10cSrcweir             aPnt.Y() += nDrgLog + nDrgLog;
829cdf0e10cSrcweir             mpView->MovAction(aPnt);
830cdf0e10cSrcweir 
831cdf0e10cSrcweir             mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
832cdf0e10cSrcweir 
833cdf0e10cSrcweir             if(mxTextObj.is())
834cdf0e10cSrcweir             {
835cdf0e10cSrcweir                 GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
836cdf0e10cSrcweir             }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir             if(!mpView->EndCreateObj(SDRCREATE_FORCEEND))
839cdf0e10cSrcweir             {
840cdf0e10cSrcweir                 mxTextObj.reset(0);
841cdf0e10cSrcweir             }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir             if(bSnapEnabled)
844cdf0e10cSrcweir                 mpView->SetSnapEnabled(bSnapEnabled);
845cdf0e10cSrcweir 
846cdf0e10cSrcweir             if(mxTextObj.is())
847cdf0e10cSrcweir             {
848cdf0e10cSrcweir                 SfxItemSet aSet(mpViewShell->GetPool());
849cdf0e10cSrcweir                 aSet.Put(SdrTextMinFrameHeightItem(0));
850cdf0e10cSrcweir                 aSet.Put(SdrTextMinFrameWidthItem(0));
851cdf0e10cSrcweir                 aSet.Put(SdrTextAutoGrowHeightItem(sal_True));
852cdf0e10cSrcweir                 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
853cdf0e10cSrcweir 
854cdf0e10cSrcweir                 // #91508#
855cdf0e10cSrcweir                 if(nSlotId == SID_ATTR_CHAR_VERTICAL)
856cdf0e10cSrcweir                 {
857cdf0e10cSrcweir                     // #107235#
858cdf0e10cSrcweir                     //
859cdf0e10cSrcweir                     // Here, all items which need to be different from pool default need to be set
860cdf0e10cSrcweir                     // again on the newly created text object.
861cdf0e10cSrcweir                     // Since this is a simple klick text object, it is first created, then SetVertical()
862cdf0e10cSrcweir                     // is used, then ImpSetAttributesForNewTextObject is called and then the object is
863cdf0e10cSrcweir                     // deleted again since not the minimum drag distance was travelled. Then, a new
864cdf0e10cSrcweir                     // klick text object is created and thus all that stuff needs to be set again here.
865cdf0e10cSrcweir                     //
866cdf0e10cSrcweir                     // Before using the new object the vertical writing mode
867cdf0e10cSrcweir                     // needs to be set. This is done here at the OutlinerParaObject
868cdf0e10cSrcweir                     // directly to not mirror the layout text items involved. These items will be set
869cdf0e10cSrcweir                     // below.
870cdf0e10cSrcweir                     OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
871cdf0e10cSrcweir 
872cdf0e10cSrcweir                     if(!pPara)
873cdf0e10cSrcweir                     {
874cdf0e10cSrcweir                         GetTextObj()->ForceOutlinerParaObject();
875cdf0e10cSrcweir                         pPara = GetTextObj()->GetOutlinerParaObject();
876cdf0e10cSrcweir                     }
877cdf0e10cSrcweir 
878cdf0e10cSrcweir                     if(pPara && sal_True != pPara->IsVertical())
879cdf0e10cSrcweir                     {
880cdf0e10cSrcweir                         // set ParaObject orientation accordingly
881cdf0e10cSrcweir                         pPara->SetVertical(sal_True);
882cdf0e10cSrcweir                     }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir                     // #91508#
885cdf0e10cSrcweir                     // aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
886cdf0e10cSrcweir                     aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
887cdf0e10cSrcweir 
888cdf0e10cSrcweir                     // #107235#
889cdf0e10cSrcweir                     // Analog to the else case below, for vertical simple click texts
890cdf0e10cSrcweir                     // one of the defaulted setted items from ImpSetAttributesForNewTextObject
891cdf0e10cSrcweir                     // needs to be adapted to non-block mode. This could have been done with the
892cdf0e10cSrcweir                     // #104122#, but was obviously overseen.
893cdf0e10cSrcweir                     const SfxItemSet& rSet = mpView->GetDefaultAttr();
894cdf0e10cSrcweir                     SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
895cdf0e10cSrcweir 
896cdf0e10cSrcweir                     if(FRMDIR_HORI_RIGHT_TOP == eDirection || FRMDIR_VERT_TOP_RIGHT == eDirection)
897cdf0e10cSrcweir                     {
898cdf0e10cSrcweir                         aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
899cdf0e10cSrcweir                     }
900cdf0e10cSrcweir                     else
901cdf0e10cSrcweir                     {
902cdf0e10cSrcweir                         aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
903cdf0e10cSrcweir                     }
904cdf0e10cSrcweir                 }
905cdf0e10cSrcweir                 else
906cdf0e10cSrcweir                 {
907cdf0e10cSrcweir                     // #104122# This is for Format/Page settings. Since this also leads
908cdf0e10cSrcweir                     // to the object defaults to be changed, i think this code can be
909cdf0e10cSrcweir                     // removed. CL. wanted to take a look before adding this.
910cdf0e10cSrcweir                     //const SdrTextHorzAdjust eHA = ( ( pDoc && pDoc->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ) ?
911cdf0e10cSrcweir                     //                                SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_LEFT );
912cdf0e10cSrcweir                     //aSet.Put( SdrTextHorzAdjustItem( eHA ) );
913cdf0e10cSrcweir 
914cdf0e10cSrcweir                     // #104122# Look in the object defaults if left-to-right is wanted. If
915cdf0e10cSrcweir                     // yes, set text anchoring to right to let the box grow to left.
916cdf0e10cSrcweir                     const SfxItemSet& rSet = mpView->GetDefaultAttr();
917cdf0e10cSrcweir                     SvxFrameDirection eDirection = (SvxFrameDirection)((SvxFrameDirectionItem&)rSet.Get(EE_PARA_WRITINGDIR)).GetValue();
918cdf0e10cSrcweir 
919cdf0e10cSrcweir                     if(FRMDIR_HORI_RIGHT_TOP == eDirection)
920cdf0e10cSrcweir                     {
921cdf0e10cSrcweir                         aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
922cdf0e10cSrcweir                     }
923cdf0e10cSrcweir                     else
924cdf0e10cSrcweir                     {
925cdf0e10cSrcweir                         aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
926cdf0e10cSrcweir                     }
927cdf0e10cSrcweir                 }
928cdf0e10cSrcweir 
929cdf0e10cSrcweir                 GetTextObj()->SetMergedItemSet(aSet);
930cdf0e10cSrcweir                 GetTextObj()->SetDisableAutoWidthOnDragging(sal_True);
931cdf0e10cSrcweir                 SetInEditMode(rMEvt, sal_False);
932cdf0e10cSrcweir             }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir             bFirstObjCreated = sal_True;
935cdf0e10cSrcweir         }
936cdf0e10cSrcweir         else
937cdf0e10cSrcweir         {
938cdf0e10cSrcweir             // In die Fkt. Selektion wechseln
939cdf0e10cSrcweir             if (mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
940cdf0e10cSrcweir             {
941cdf0e10cSrcweir                 mxTextObj.reset(0);
942cdf0e10cSrcweir             }
943cdf0e10cSrcweir 
944cdf0e10cSrcweir             mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
945cdf0e10cSrcweir                                       SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
946cdf0e10cSrcweir         }
947cdf0e10cSrcweir     }
948cdf0e10cSrcweir 
949cdf0e10cSrcweir     bMBDown = sal_False;
950cdf0e10cSrcweir     FuConstruct::MouseButtonUp(rMEvt);
951cdf0e10cSrcweir     return (bReturn);
952cdf0e10cSrcweir }
953cdf0e10cSrcweir 
954cdf0e10cSrcweir /*************************************************************************
955cdf0e10cSrcweir |*
956cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
957cdf0e10cSrcweir |*
958cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
959cdf0e10cSrcweir |* sal_False.
960cdf0e10cSrcweir |*
961cdf0e10cSrcweir \************************************************************************/
962cdf0e10cSrcweir 
963cdf0e10cSrcweir sal_Bool FuText::KeyInput(const KeyEvent& rKEvt)
964cdf0e10cSrcweir {
965cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
966cdf0e10cSrcweir     mpView->SetMarkHdlWhenTextEdit(sal_True);
967cdf0e10cSrcweir 
968cdf0e10cSrcweir     KeyCode nCode = rKEvt.GetKeyCode();
969cdf0e10cSrcweir     sal_Bool bShift = nCode.IsShift();
970cdf0e10cSrcweir 
971cdf0e10cSrcweir     // #97016# IV
972cdf0e10cSrcweir     if(mxTextObj.is())
973cdf0e10cSrcweir     {
974cdf0e10cSrcweir         // maybe object is deleted, test if it's equal to the selected object
975cdf0e10cSrcweir         const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
976cdf0e10cSrcweir         SdrObject* pSelectedObj = 0L;
977cdf0e10cSrcweir 
978cdf0e10cSrcweir         if(1 == rMarkList.GetMarkCount())
979cdf0e10cSrcweir         {
980cdf0e10cSrcweir             SdrMark* pMark = rMarkList.GetMark(0);
981cdf0e10cSrcweir             pSelectedObj = pMark->GetMarkedSdrObj();
982cdf0e10cSrcweir         }
983cdf0e10cSrcweir 
984cdf0e10cSrcweir         if(mxTextObj.get() != pSelectedObj)
985cdf0e10cSrcweir         {
986cdf0e10cSrcweir             mxTextObj.reset(0);
987cdf0e10cSrcweir         }
988cdf0e10cSrcweir     }
989cdf0e10cSrcweir 
990cdf0e10cSrcweir     if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor && mxTextObj->GetObjIdentifier() == OBJ_TITLETEXT && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
991cdf0e10cSrcweir     {
992cdf0e10cSrcweir         // Titeltext-Objekt: immer "weiche" Umbrueche
993cdf0e10cSrcweir         bShift = sal_True;
994cdf0e10cSrcweir     }
995cdf0e10cSrcweir 
996cdf0e10cSrcweir     sal_uInt16 nKey = nCode.GetCode();
997cdf0e10cSrcweir     KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
998cdf0e10cSrcweir     KeyEvent aKEvt(rKEvt.GetCharCode(), aKeyCode);
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir     sal_Bool bOK = sal_True;
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir     if (mpDocSh->IsReadOnly())
1003cdf0e10cSrcweir     {
1004cdf0e10cSrcweir         bOK = !EditEngine::DoesKeyChangeText(aKEvt);
1005cdf0e10cSrcweir     }
1006cdf0e10cSrcweir     if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
1007cdf0e10cSrcweir     {
1008cdf0e10cSrcweir         bOK = sal_False;   // default handling in base class
1009cdf0e10cSrcweir     }
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir     if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
1012cdf0e10cSrcweir     {
1013cdf0e10cSrcweir         bReturn = sal_True;
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir //      if ( pTextObj )
1018cdf0e10cSrcweir //          pTextObj->SetEmptyPresObj(sal_False);
1019cdf0e10cSrcweir     }
1020cdf0e10cSrcweir     else if (aKeyCode == KEY_ESCAPE)
1021cdf0e10cSrcweir     {
1022cdf0e10cSrcweir         bReturn = cancel();
1023cdf0e10cSrcweir     }
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir     if( bPermanent )
1026cdf0e10cSrcweir     {
1027cdf0e10cSrcweir         mpView->SetCurrentObj(OBJ_TEXT);
1028cdf0e10cSrcweir         mpView->SetEditMode(SDREDITMODE_CREATE);
1029cdf0e10cSrcweir     }
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir     if (!bReturn)
1032cdf0e10cSrcweir     {
1033cdf0e10cSrcweir         bReturn = FuDraw::KeyInput(aKEvt);
1034cdf0e10cSrcweir     }
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir     return (bReturn);
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir /*************************************************************************
1042cdf0e10cSrcweir |*
1043cdf0e10cSrcweir |* Function aktivieren
1044cdf0e10cSrcweir |*
1045cdf0e10cSrcweir \************************************************************************/
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir void FuText::Activate()
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir     mpView->SetQuickTextEditMode(mpViewShell->GetFrameView()->IsQuickEdit());
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir     // #i89661# it's no longer necessary to make it so big here, it's fine tuned
1052cdf0e10cSrcweir     // for text objects in SdrMarkView::CheckSingleSdrObjectHit
1053cdf0e10cSrcweir     mpView->SetHitTolerancePixel( 2 * HITPIX );
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir     OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir     if (pOLV)
1058cdf0e10cSrcweir         pOLV->ShowCursor();
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir     FuConstruct::Activate();
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir     if( pOLV )
1063cdf0e10cSrcweir         mpView->SetEditMode(SDREDITMODE_EDIT);
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir /*************************************************************************
1068cdf0e10cSrcweir |*
1069cdf0e10cSrcweir |* Function deaktivieren
1070cdf0e10cSrcweir |*
1071cdf0e10cSrcweir \************************************************************************/
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir void FuText::Deactivate()
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir     OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir     if (pOLV)
1078cdf0e10cSrcweir         pOLV->HideCursor();
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir     mpView->SetHitTolerancePixel( HITPIX );
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir     FuConstruct::Deactivate();
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir /*************************************************************************
1087cdf0e10cSrcweir |*
1088cdf0e10cSrcweir |* Objekt in Edit-Mode setzen
1089cdf0e10cSrcweir |*
1090cdf0e10cSrcweir \************************************************************************/
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir void FuText::SetInEditMode(const MouseEvent& rMEvt, sal_Bool bQuickDrag)
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir     SdrPageView* pPV = mpView->GetSdrPageView();
1095cdf0e10cSrcweir     if( mxTextObj.is() && (mxTextObj->GetPage() == pPV->GetPage()) )
1096cdf0e10cSrcweir     {
1097cdf0e10cSrcweir         mpView->SetCurrentObj(OBJ_TEXT);
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir         if( bPermanent )
1100cdf0e10cSrcweir             mpView->SetEditMode(SDREDITMODE_CREATE);
1101cdf0e10cSrcweir         else
1102cdf0e10cSrcweir             mpView->SetEditMode(SDREDITMODE_EDIT);
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir         sal_Bool bEmptyOutliner = sal_False;
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir         if (!GetTextObj()->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
1107cdf0e10cSrcweir         {
1108cdf0e10cSrcweir             ::Outliner* pOutl = mpView->GetTextEditOutliner();
1109cdf0e10cSrcweir             sal_uLong nParaAnz = pOutl->GetParagraphCount();
1110cdf0e10cSrcweir             Paragraph* p1stPara = pOutl->GetParagraph( 0 );
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir             if (nParaAnz==1 && p1stPara)
1113cdf0e10cSrcweir             {
1114cdf0e10cSrcweir                 // Bei nur einem Pararaph
1115cdf0e10cSrcweir                 if (pOutl->GetText(p1stPara).Len() == 0)
1116cdf0e10cSrcweir                 {
1117cdf0e10cSrcweir                     bEmptyOutliner = sal_True;
1118cdf0e10cSrcweir                 }
1119cdf0e10cSrcweir             }
1120cdf0e10cSrcweir         }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir         if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
1123cdf0e10cSrcweir         {
1124cdf0e10cSrcweir             sal_uInt32 nInv = mxTextObj->GetObjInventor();
1125cdf0e10cSrcweir             sal_uInt16 nSdrObjKind = mxTextObj->GetObjIdentifier();
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir             if (nInv == SdrInventor && GetTextObj()->HasTextEdit() &&
1128cdf0e10cSrcweir                 (nSdrObjKind == OBJ_TEXT ||
1129cdf0e10cSrcweir                 nSdrObjKind == OBJ_TITLETEXT ||
1130cdf0e10cSrcweir                 nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) )
1131cdf0e10cSrcweir             {
1132cdf0e10cSrcweir                 // Neuen Outliner machen (gehoert der SdrObjEditView)
1133cdf0e10cSrcweir                 SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir                 if (bEmptyOutliner)
1136cdf0e10cSrcweir                     mpView->SdrEndTextEdit(sal_True);
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir                 SdrTextObj* pTextObj = GetTextObj();
1139cdf0e10cSrcweir                 if( pTextObj )
1140cdf0e10cSrcweir                 {
1141cdf0e10cSrcweir                     OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
1142cdf0e10cSrcweir                     if( ( pOPO && pOPO->IsVertical() ) || (nSlotId == SID_ATTR_CHAR_VERTICAL) || (nSlotId == SID_TEXT_FITTOSIZE_VERTICAL) )
1143cdf0e10cSrcweir                         pOutl->SetVertical( sal_True );
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir                     if( pTextObj->getTextCount() > 1 )
1146cdf0e10cSrcweir                     {
1147cdf0e10cSrcweir                         Point aPix(rMEvt.GetPosPixel());
1148cdf0e10cSrcweir                         Point aPnt(mpWindow->PixelToLogic(aPix));
1149cdf0e10cSrcweir                         pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
1150cdf0e10cSrcweir                     }
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir                     if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, sal_True, pOutl) && mxTextObj->GetObjInventor() == SdrInventor)
1153cdf0e10cSrcweir                     {
1154cdf0e10cSrcweir                         bFirstObjCreated = sal_True;
1155cdf0e10cSrcweir                         DeleteDefaultText();
1156cdf0e10cSrcweir 
1157cdf0e10cSrcweir                         OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir                         nSdrObjKind = mxTextObj->GetObjIdentifier();
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir                         SdrViewEvent aVEvt;
1162cdf0e10cSrcweir                         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir                         if (eHit == SDRHIT_TEXTEDIT)
1165cdf0e10cSrcweir                         {
1166cdf0e10cSrcweir                             // Text getroffen
1167cdf0e10cSrcweir                             if (nSdrObjKind == OBJ_TEXT ||
1168cdf0e10cSrcweir                                 nSdrObjKind == OBJ_TITLETEXT ||
1169cdf0e10cSrcweir                                 nSdrObjKind == OBJ_OUTLINETEXT ||
1170cdf0e10cSrcweir                                 nSdrObjKind == OBJ_TABLE ||
1171cdf0e10cSrcweir                                 nSlotId == SID_TEXTEDIT ||
1172cdf0e10cSrcweir                                 !bQuickDrag)
1173cdf0e10cSrcweir                             {
1174cdf0e10cSrcweir                                 pOLV->MouseButtonDown(rMEvt);
1175cdf0e10cSrcweir                                 pOLV->MouseMove(rMEvt);
1176cdf0e10cSrcweir                                 pOLV->MouseButtonUp(rMEvt);
1177cdf0e10cSrcweir                             }
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir                             if (mpViewShell->GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
1180cdf0e10cSrcweir                             {
1181cdf0e10cSrcweir                                 pOLV->MouseButtonDown(rMEvt);
1182cdf0e10cSrcweir                             }
1183cdf0e10cSrcweir                         }
1184cdf0e10cSrcweir                         else
1185cdf0e10cSrcweir                         {
1186cdf0e10cSrcweir                             // #98198# Move cursor to end of text
1187cdf0e10cSrcweir                             ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1188*02c50d82SAndre Fischer                             if (pOLV != NULL)
1189cdf0e10cSrcweir                                 pOLV->SetSelection(aNewSelection);
1190cdf0e10cSrcweir                         }
1191cdf0e10cSrcweir                     }
1192cdf0e10cSrcweir                     else
1193cdf0e10cSrcweir                     {
1194cdf0e10cSrcweir                         mpView->RestoreDefaultText(dynamic_cast< SdrTextObj* >( mxTextObj.get() ));
1195cdf0e10cSrcweir                     }
1196cdf0e10cSrcweir                 }
1197cdf0e10cSrcweir             }
1198cdf0e10cSrcweir         }
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir     else
1201cdf0e10cSrcweir     {
1202cdf0e10cSrcweir         mxTextObj.reset(0);
1203cdf0e10cSrcweir     }
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir /*************************************************************************
1207cdf0e10cSrcweir |*
1208cdf0e10cSrcweir |* Texteingabe wird gestartet, ggf. Default-Text loeschen
1209cdf0e10cSrcweir |*
1210cdf0e10cSrcweir \************************************************************************/
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir sal_Bool FuText::DeleteDefaultText()
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir     sal_Bool bDeleted = sal_False;
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir     if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() )
1217cdf0e10cSrcweir     {
1218cdf0e10cSrcweir         String aString;
1219cdf0e10cSrcweir         SdPage* pPage = (SdPage*) mxTextObj->GetPage();
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir         if (pPage)
1222cdf0e10cSrcweir         {
1223cdf0e10cSrcweir             PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir             if ( (ePresObjKind == PRESOBJ_TITLE   ||
1226cdf0e10cSrcweir                   ePresObjKind == PRESOBJ_OUTLINE ||
1227cdf0e10cSrcweir                   ePresObjKind == PRESOBJ_NOTES   ||
1228cdf0e10cSrcweir                   ePresObjKind == PRESOBJ_TEXT) &&
1229cdf0e10cSrcweir                   !pPage->IsMasterPage() )
1230cdf0e10cSrcweir             {
1231cdf0e10cSrcweir                 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
1232cdf0e10cSrcweir                 SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 );
1233cdf0e10cSrcweir                 sal_Bool bIsUndoEnabled = pOutliner->IsUndoEnabled();
1234cdf0e10cSrcweir                 if( bIsUndoEnabled )
1235cdf0e10cSrcweir                     pOutliner->EnableUndo(sal_False);
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir                 pOutliner->SetText( String(), pOutliner->GetParagraph( 0 ) );
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir                 if( bIsUndoEnabled )
1240cdf0e10cSrcweir                     pOutliner->EnableUndo(sal_True);
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir                 if (pSheet &&
1243cdf0e10cSrcweir                     (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT))
1244cdf0e10cSrcweir                     pOutliner->SetStyleSheet(0, pSheet);
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir                 mxTextObj->SetEmptyPresObj(sal_True);
1247cdf0e10cSrcweir                 bDeleted = sal_True;
1248cdf0e10cSrcweir             }
1249cdf0e10cSrcweir         }
1250cdf0e10cSrcweir     }
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir     return(bDeleted);
1253cdf0e10cSrcweir }
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir /*************************************************************************
1256cdf0e10cSrcweir |*
1257cdf0e10cSrcweir |* Command-event
1258cdf0e10cSrcweir |*
1259cdf0e10cSrcweir \************************************************************************/
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir sal_Bool FuText::Command(const CommandEvent& rCEvt)
1262cdf0e10cSrcweir {
1263cdf0e10cSrcweir     return( FuPoor::Command(rCEvt) );
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir /*************************************************************************
1267cdf0e10cSrcweir |*
1268cdf0e10cSrcweir |* Help-event
1269cdf0e10cSrcweir |*
1270cdf0e10cSrcweir \************************************************************************/
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir sal_Bool FuText::RequestHelp(const HelpEvent& rHEvt)
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir     OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir     if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
1279cdf0e10cSrcweir         mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
1280cdf0e10cSrcweir     {
1281cdf0e10cSrcweir         String aHelpText;
1282cdf0e10cSrcweir         const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
1283cdf0e10cSrcweir         const SvxFieldData* pField = pFieldItem->GetField();
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir         if (pField && pField->ISA(SvxURLField))
1286cdf0e10cSrcweir         {
1287cdf0e10cSrcweir             /******************************************************************
1288cdf0e10cSrcweir             * URL-Field
1289cdf0e10cSrcweir             ******************************************************************/
1290cdf0e10cSrcweir             aHelpText = INetURLObject::decode( ((const SvxURLField*)pField)->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1291cdf0e10cSrcweir         }
1292cdf0e10cSrcweir         if (aHelpText.Len())
1293cdf0e10cSrcweir         {
1294cdf0e10cSrcweir             Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
1295cdf0e10cSrcweir             Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1296cdf0e10cSrcweir                                   mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir             if (Help::IsBalloonHelpEnabled())
1299cdf0e10cSrcweir             {
1300cdf0e10cSrcweir                 bReturn = Help::ShowBalloon( (Window*)mpWindow, rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
1301cdf0e10cSrcweir             }
1302cdf0e10cSrcweir             else if (Help::IsQuickHelpEnabled())
1303cdf0e10cSrcweir             {
1304cdf0e10cSrcweir                 bReturn = Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1305cdf0e10cSrcweir             }
1306cdf0e10cSrcweir         }
1307cdf0e10cSrcweir     }
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir     if (!bReturn)
1310cdf0e10cSrcweir     {
1311cdf0e10cSrcweir         bReturn = FuConstruct::RequestHelp(rHEvt);
1312cdf0e10cSrcweir     }
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir     return(bReturn);
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir /*************************************************************************
1318cdf0e10cSrcweir |*
1319cdf0e10cSrcweir |* Request verarbeiten
1320cdf0e10cSrcweir |*
1321cdf0e10cSrcweir \************************************************************************/
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir void FuText::ReceiveRequest(SfxRequest& rReq)
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir     nSlotId = rReq.GetSlot();
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir     // Dann Basisklasse rufen (dort wird u.a. nSlotId NICHT gesetzt)
1328cdf0e10cSrcweir     FuPoor::ReceiveRequest(rReq);
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir     if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || /*#95971#*/ SID_ATTR_CHAR == nSlotId)
1331cdf0e10cSrcweir     {
1332cdf0e10cSrcweir         MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir         mxTextObj.reset(0);
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir         if (nSlotId == SID_TEXTEDIT)
1337cdf0e10cSrcweir         {
1338cdf0e10cSrcweir             // Wird gerade editiert?
1339cdf0e10cSrcweir             if(!bTestText)
1340cdf0e10cSrcweir                 mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetTextEditObject() ) );
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir             if (!mxTextObj.is())
1343cdf0e10cSrcweir             {
1344cdf0e10cSrcweir                 // Versuchen, ein Obj zu selektieren
1345cdf0e10cSrcweir                 SdrPageView* pPV = mpView->GetSdrPageView();
1346cdf0e10cSrcweir                 SdrViewEvent aVEvt;
1347cdf0e10cSrcweir                 mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1348cdf0e10cSrcweir                 mpView->MarkObj(aVEvt.pRootObj, pPV);
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir                 if (aVEvt.pObj && aVEvt.pObj->ISA(SdrTextObj))
1351cdf0e10cSrcweir                 {
1352cdf0e10cSrcweir                     mxTextObj.reset( static_cast< SdrTextObj* >( aVEvt.pObj ) );
1353cdf0e10cSrcweir                 }
1354cdf0e10cSrcweir             }
1355cdf0e10cSrcweir         }
1356cdf0e10cSrcweir         else if (mpView->AreObjectsMarked())
1357cdf0e10cSrcweir         {
1358cdf0e10cSrcweir             const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir             if (rMarkList.GetMarkCount() == 1)
1361cdf0e10cSrcweir             {
1362cdf0e10cSrcweir                 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir                 if (pObj->ISA(SdrTextObj))
1365cdf0e10cSrcweir                 {
1366cdf0e10cSrcweir                     mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) );
1367cdf0e10cSrcweir                 }
1368cdf0e10cSrcweir             }
1369cdf0e10cSrcweir         }
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir         sal_Bool bQuickDrag = sal_True;
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir         const SfxItemSet* pArgs = rReq.GetArgs();
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir         if (pArgs
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir             // #98198# test for type before using
1378cdf0e10cSrcweir             && SID_TEXTEDIT == nSlotId
1379cdf0e10cSrcweir             && SFX_ITEM_SET == pArgs->GetItemState(SID_TEXTEDIT)
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir             && (sal_uInt16) ((SfxUInt16Item&) pArgs->Get(SID_TEXTEDIT)).GetValue() == 2)
1382cdf0e10cSrcweir         {
1383cdf0e10cSrcweir             // Anwahl per Doppelklick -> kein QuickDrag zulassen
1384cdf0e10cSrcweir             bQuickDrag = sal_False;
1385cdf0e10cSrcweir         }
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir         SetInEditMode(aMEvt, bQuickDrag);
1388cdf0e10cSrcweir     }
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir /*************************************************************************
1394cdf0e10cSrcweir |*
1395cdf0e10cSrcweir |* SpellChecker: Error-LinkHdl
1396cdf0e10cSrcweir |*
1397cdf0e10cSrcweir \************************************************************************/
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir IMPL_LINK( FuText, SpellError, void *, nLang )
1400cdf0e10cSrcweir {
1401cdf0e10cSrcweir     String aError( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_uLong)nLang ) );
1402cdf0e10cSrcweir     ErrorHandler::HandleError(* new StringErrorInfo(
1403cdf0e10cSrcweir                                 ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aError) );
1404cdf0e10cSrcweir     return 0;
1405cdf0e10cSrcweir }
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir /*************************************************************************
1409cdf0e10cSrcweir |*
1410cdf0e10cSrcweir |* Reaktion auf Doppelklick
1411cdf0e10cSrcweir |*
1412cdf0e10cSrcweir \************************************************************************/
1413cdf0e10cSrcweir void FuText::DoubleClick(const MouseEvent& )
1414cdf0e10cSrcweir {
1415cdf0e10cSrcweir     // Nichts zu tun
1416cdf0e10cSrcweir }
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir /** #97016#
1419cdf0e10cSrcweir     #105815# Removed the insertion of default text and putting a new text
1420cdf0e10cSrcweir     object directly into edit mode.
1421cdf0e10cSrcweir */
1422cdf0e10cSrcweir SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
1423cdf0e10cSrcweir {
1424cdf0e10cSrcweir     // case SID_TEXTEDIT:   // BASIC ???
1425cdf0e10cSrcweir     // case SID_ATTR_CHAR:
1426cdf0e10cSrcweir     // case SID_ATTR_CHAR_VERTICAL:
1427cdf0e10cSrcweir     // case SID_TEXT_FITTOSIZE:
1428cdf0e10cSrcweir     // case SID_TEXT_FITTOSIZE_VERTICAL:
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir     SdrObject* pObj = SdrObjFactory::MakeNewObject(
1431cdf0e10cSrcweir         mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
1432cdf0e10cSrcweir         0L, mpDoc);
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir     if(pObj)
1435cdf0e10cSrcweir     {
1436cdf0e10cSrcweir         if(pObj->ISA(SdrTextObj))
1437cdf0e10cSrcweir         {
1438cdf0e10cSrcweir             SdrTextObj* pText = (SdrTextObj*)pObj;
1439cdf0e10cSrcweir             pText->SetLogicRect(rRectangle);
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir             sal_Bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);
1442cdf0e10cSrcweir             pText->SetVerticalWriting(bVertical);
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir             // #97016#
1445cdf0e10cSrcweir             ImpSetAttributesForNewTextObject(pText);
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir             if (nSlotId == SID_TEXT_FITTOSIZE)
1448cdf0e10cSrcweir             {
1449cdf0e10cSrcweir                 // #97016#
1450cdf0e10cSrcweir                 ImpSetAttributesFitToSize(pText);
1451cdf0e10cSrcweir             }
1452cdf0e10cSrcweir             else if ( nSlotId == SID_TEXT_FITTOSIZE_VERTICAL )
1453cdf0e10cSrcweir             {
1454cdf0e10cSrcweir                 // #97016#
1455cdf0e10cSrcweir                 ImpSetAttributesFitToSizeVertical(pText);
1456cdf0e10cSrcweir             }
1457cdf0e10cSrcweir             else
1458cdf0e10cSrcweir             {
1459cdf0e10cSrcweir                 // #97016#
1460cdf0e10cSrcweir                 ImpSetAttributesFitCommon(pText);
1461cdf0e10cSrcweir             }
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir             // Put text object into edit mode.
1464cdf0e10cSrcweir             SdrPageView* pPV = mpView->GetSdrPageView();
1465cdf0e10cSrcweir             mpView->SdrBeginTextEdit(pText, pPV);
1466cdf0e10cSrcweir         }
1467cdf0e10cSrcweir         else
1468cdf0e10cSrcweir         {
1469cdf0e10cSrcweir             DBG_ERROR("Object is NO text object");
1470cdf0e10cSrcweir         }
1471cdf0e10cSrcweir     }
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir     return pObj;
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir /** is called when the currenct function should be aborted. <p>
1480cdf0e10cSrcweir     This is used when a function gets a KEY_ESCAPE but can also
1481cdf0e10cSrcweir     be called directly.
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir     @returns true if a active function was aborted
1484cdf0e10cSrcweir */
1485cdf0e10cSrcweir bool FuText::cancel()
1486cdf0e10cSrcweir {
1487cdf0e10cSrcweir     if ( mpView->IsTextEdit() )
1488cdf0e10cSrcweir     {
1489cdf0e10cSrcweir         if(mpView->SdrEndTextEdit() == SDRENDTEXTEDIT_DELETED)
1490cdf0e10cSrcweir             mxTextObj.reset(0);
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir         mpView->SetCurrentObj(OBJ_TEXT);
1493cdf0e10cSrcweir         mpView->SetEditMode(SDREDITMODE_EDIT);
1494cdf0e10cSrcweir         return true;
1495cdf0e10cSrcweir     }
1496cdf0e10cSrcweir     else
1497cdf0e10cSrcweir     {
1498cdf0e10cSrcweir         return false;
1499cdf0e10cSrcweir     }
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
1503cdf0e10cSrcweir {
1504cdf0e10cSrcweir     if( !pFontList || !pView )
1505cdf0e10cSrcweir         return;
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir     if( pOLV )
1508cdf0e10cSrcweir     {
1509cdf0e10cSrcweir         pOLV->GetEditView().ChangeFontSize( bGrow, pFontList );
1510cdf0e10cSrcweir     }
1511cdf0e10cSrcweir     else
1512cdf0e10cSrcweir     {
1513cdf0e10cSrcweir //      SdDrawDocument* pDoc = pView->GetDoc();
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
1516cdf0e10cSrcweir         for( sal_uInt32 nMark = 0; nMark < rMarkList.GetMarkCount(); nMark++ )
1517cdf0e10cSrcweir         {
1518cdf0e10cSrcweir             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
1519cdf0e10cSrcweir             if( pTextObj )
1520cdf0e10cSrcweir             {
1521cdf0e10cSrcweir                 for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
1522cdf0e10cSrcweir                 {
1523cdf0e10cSrcweir                     pTextObj->setActiveText( nText );
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir                     // Put text object into edit mode.
1526cdf0e10cSrcweir                     SdrPageView* pPV = pView->GetSdrPageView();
1527cdf0e10cSrcweir                     pView->SdrBeginTextEdit(pTextObj, pPV);
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir                     pOLV = pView->GetTextEditOutlinerView();
1530cdf0e10cSrcweir                     if( pOLV )
1531cdf0e10cSrcweir                     {
1532cdf0e10cSrcweir                         EditEngine* pEditEngine = pOLV->GetEditView().GetEditEngine();
1533cdf0e10cSrcweir                         if( pEditEngine )
1534cdf0e10cSrcweir                         {
1535cdf0e10cSrcweir                             ESelection aSel;
1536cdf0e10cSrcweir                             aSel.nEndPara = pEditEngine->GetParagraphCount()-1;
1537cdf0e10cSrcweir                             aSel.nEndPos = pEditEngine->GetTextLen(aSel.nEndPara);
1538cdf0e10cSrcweir                             pOLV->SetSelection(aSel);
1539cdf0e10cSrcweir                         }
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir                         ChangeFontSize( bGrow, pOLV, pFontList, pView );
1542cdf0e10cSrcweir                     }
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir                     pView->SdrEndTextEdit();
1545cdf0e10cSrcweir                 }
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir                 SfxItemSet aShapeSet( pTextObj->GetMergedItemSet() );
1548cdf0e10cSrcweir                 if( EditView::ChangeFontSize( bGrow, aShapeSet, pFontList ) )
1549cdf0e10cSrcweir                 {
1550cdf0e10cSrcweir                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT ) );
1551cdf0e10cSrcweir                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1552cdf0e10cSrcweir                     pTextObj->SetObjectItemNoBroadcast( aShapeSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1553cdf0e10cSrcweir                 }
1554cdf0e10cSrcweir             }
1555cdf0e10cSrcweir         }
1556cdf0e10cSrcweir     }
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir } // end of namespace sd
1560cdf0e10cSrcweir 
1561