xref: /aoo41x/main/sc/source/ui/drawfunc/futext.cxx (revision 512ec161)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svx/svddef.hxx>
28cdf0e10cSrcweir #include <svx/svdoutl.hxx>
29cdf0e10cSrcweir #include <editeng/outlobj.hxx>
30cdf0e10cSrcweir #include <svx/sdtaaitm.hxx>
31cdf0e10cSrcweir #include <svx/sdtacitm.hxx>
32cdf0e10cSrcweir #include <svx/svdotext.hxx>
33cdf0e10cSrcweir #include <editeng/unolingu.hxx>
34cdf0e10cSrcweir #include <svx/svdocapt.hxx>
35cdf0e10cSrcweir #include <sfx2/bindings.hxx>
36cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
37cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
38cdf0e10cSrcweir #include <svx/svxids.hrc>
39cdf0e10cSrcweir #include <editeng/eeitem.hxx>
40cdf0e10cSrcweir #include <svl/itemset.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "futext.hxx"
43cdf0e10cSrcweir #include "drwlayer.hxx"
44cdf0e10cSrcweir #include "sc.hrc"
45cdf0e10cSrcweir #include "tabvwsh.hxx"
46cdf0e10cSrcweir #include "drawview.hxx"
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // #98185# Create default drawing objects via keyboard
49cdf0e10cSrcweir #include "scresid.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //	Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
52cdf0e10cSrcweir //!	fusel,fuconstr,futext - zusammenfassen!
53cdf0e10cSrcweir #define SC_MAXDRAGMOVE	3
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //------------------------------------------------------------------
56cdf0e10cSrcweir 
lcl_InvalidateAttribs(SfxBindings & rBindings)57cdf0e10cSrcweir void lcl_InvalidateAttribs( SfxBindings& rBindings )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
60cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
61cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
62cdf0e10cSrcweir 	rBindings.Invalidate( SID_ULINE_VAL_NONE );
63cdf0e10cSrcweir 	rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
64cdf0e10cSrcweir 	rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
65cdf0e10cSrcweir 	rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
66cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
67cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
68cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_FONT );
69cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
70*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
71*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
72*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
73*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
74cdf0e10cSrcweir 	rBindings.Invalidate( SID_ALIGNLEFT );
75cdf0e10cSrcweir 	rBindings.Invalidate( SID_ALIGNCENTERHOR );
76cdf0e10cSrcweir 	rBindings.Invalidate( SID_ALIGNRIGHT );
77cdf0e10cSrcweir 	rBindings.Invalidate( SID_ALIGNBLOCK );
78cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
79cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
80cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
81cdf0e10cSrcweir 	rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
82cdf0e10cSrcweir 	rBindings.Invalidate( SID_SET_SUB_SCRIPT );
83cdf0e10cSrcweir 	rBindings.Invalidate( SID_HYPERLINK_GETLINK );
84cdf0e10cSrcweir 	rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
85cdf0e10cSrcweir 	rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
86cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
87cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
88cdf0e10cSrcweir     // pseudo slots for Format menu
89cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
90cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
91cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
92cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
93*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
94*512ec161SZheng Fan 	rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
95*512ec161SZheng Fan 	rBindings.Invalidate( SID_SET_SUB_SCRIPT );
96*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
97*512ec161SZheng Fan 	rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
lcl_UpdateHyphenator(Outliner & rOutliner,SdrObject * pObj)100cdf0e10cSrcweir void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	// use hyphenator only if hyphenation attribute is set
103cdf0e10cSrcweir 	if ( pObj && ((const SfxBoolItem&)pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) {
104cdf0e10cSrcweir             com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() );
105cdf0e10cSrcweir     		rOutliner.SetHyphenator( xHyphenator );
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir /*************************************************************************
110cdf0e10cSrcweir |*
111cdf0e10cSrcweir |* Basisklasse fuer Textfunktionen
112cdf0e10cSrcweir |*
113cdf0e10cSrcweir \************************************************************************/
114cdf0e10cSrcweir 
FuText(ScTabViewShell * pViewSh,Window * pWin,ScDrawView * pViewP,SdrModel * pDoc,SfxRequest & rReq)115cdf0e10cSrcweir FuText::FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
116cdf0e10cSrcweir 				   SdrModel* pDoc, SfxRequest& rReq) :
117cdf0e10cSrcweir     FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq),
118cdf0e10cSrcweir 	pTextObj(NULL)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir /*************************************************************************
123cdf0e10cSrcweir |*
124cdf0e10cSrcweir |* Destruktor
125cdf0e10cSrcweir |*
126cdf0e10cSrcweir \************************************************************************/
127cdf0e10cSrcweir 
~FuText()128cdf0e10cSrcweir FuText::~FuText()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir //	StopEditMode();					// in Deactivate !
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir /*************************************************************************
134cdf0e10cSrcweir |*
135cdf0e10cSrcweir |* MouseButtonDown-event
136cdf0e10cSrcweir |*
137cdf0e10cSrcweir \************************************************************************/
138cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)139cdf0e10cSrcweir sal_Bool __EXPORT FuText::MouseButtonDown(const MouseEvent& rMEvt)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
142cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	if ( pView->MouseButtonDown(rMEvt, pWindow) )
145cdf0e10cSrcweir 		return (sal_True);				   // Event von der SdrView ausgewertet
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	if ( pView->IsTextEdit() )
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir         if( !IsSizingOrMovingNote(rMEvt) )
150cdf0e10cSrcweir 		    StopEditMode();			   // Danebengeklickt, Ende mit Edit
151cdf0e10cSrcweir 		pView->SetCreateMode();
152cdf0e10cSrcweir 	}
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	if ( rMEvt.IsLeft() )
157cdf0e10cSrcweir 	{
158cdf0e10cSrcweir 		SdrHdl* pHdl = pView->PickHandle(aMDPos);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 		sal_uLong nHdlNum = pView->GetHdlNum(pHdl);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 		if (pHdl != NULL)
163cdf0e10cSrcweir 		{
164cdf0e10cSrcweir 			if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl))
165cdf0e10cSrcweir 			{
166cdf0e10cSrcweir 				sal_Bool bPointMarked=pView->IsPointMarked(*pHdl);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 				if ( rMEvt.IsShift() )
169cdf0e10cSrcweir 				{
170cdf0e10cSrcweir 					if (!bPointMarked)
171cdf0e10cSrcweir 					{
172cdf0e10cSrcweir 						pView->MarkPoint(*pHdl);
173cdf0e10cSrcweir 					}
174cdf0e10cSrcweir 					else
175cdf0e10cSrcweir 					{
176cdf0e10cSrcweir 						pView->UnmarkPoint(*pHdl);
177cdf0e10cSrcweir 					}
178cdf0e10cSrcweir 				}
179cdf0e10cSrcweir 				else
180cdf0e10cSrcweir 				{
181cdf0e10cSrcweir 					if (!bPointMarked)
182cdf0e10cSrcweir 					{
183cdf0e10cSrcweir 						pView->UnmarkAllPoints();
184cdf0e10cSrcweir 						pView->MarkPoint(*pHdl);
185cdf0e10cSrcweir 					}
186cdf0e10cSrcweir 				}
187cdf0e10cSrcweir 				pHdl=pView->GetHdl(nHdlNum);
188cdf0e10cSrcweir 			}
189cdf0e10cSrcweir 		}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		SdrObject* pObj;
192cdf0e10cSrcweir 		SdrPageView* pPV;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 		if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
195cdf0e10cSrcweir 		{
196cdf0e10cSrcweir 			if (pHdl == NULL &&
197cdf0e10cSrcweir //				pView->TakeTextEditObject(aMDPos, pObj, pPV) )
198cdf0e10cSrcweir 				pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT) )
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir 				SdrOutliner* pO = MakeOutliner();
201cdf0e10cSrcweir 				lcl_UpdateHyphenator( *pO, pObj );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 				//	vertical flag:
204cdf0e10cSrcweir 				//	deduced from slot ids only if text object has no content
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 				sal_uInt16 nSlotID = aSfxRequest.GetSlot();
207cdf0e10cSrcweir 				sal_Bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
208cdf0e10cSrcweir 				OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
209cdf0e10cSrcweir 				if ( pOPO )
210cdf0e10cSrcweir 				    bVertical = pOPO->IsVertical();		// content wins
211cdf0e10cSrcweir 				pO->SetVertical( bVertical );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 				//!??	ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
214cdf0e10cSrcweir 				if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
215cdf0e10cSrcweir 				{
216cdf0e10cSrcweir 					//	EditEngine-UndoManager anmelden
217cdf0e10cSrcweir 					pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 					OutlinerView* pOLV = pView->GetTextEditOutlinerView();
220cdf0e10cSrcweir 					if ( pOLV->MouseButtonDown(rMEvt) )
221cdf0e10cSrcweir 						return (sal_True); // Event an den Outliner
222cdf0e10cSrcweir 				}
223cdf0e10cSrcweir 			}
224cdf0e10cSrcweir 			else
225cdf0e10cSrcweir 			{
226cdf0e10cSrcweir 			    // disable tail & circular move for caption objects.
227cdf0e10cSrcweir                 bool bDrag = false;
228cdf0e10cSrcweir 			    const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
229cdf0e10cSrcweir 			    if( rMarkList.GetMarkCount() == 1 )
230cdf0e10cSrcweir 			    {
231cdf0e10cSrcweir                     SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
232cdf0e10cSrcweir                     if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
233cdf0e10cSrcweir 			        {
234cdf0e10cSrcweir                         if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)
235cdf0e10cSrcweir                             bDrag = true;
236cdf0e10cSrcweir 			        }
237cdf0e10cSrcweir 			        else
238cdf0e10cSrcweir                         bDrag = true;   // different object
239cdf0e10cSrcweir 			    }
240cdf0e10cSrcweir                 else
241cdf0e10cSrcweir                     bDrag = true;       // several objects
242cdf0e10cSrcweir 
243cdf0e10cSrcweir                 if ( bDrag )
244cdf0e10cSrcweir                 {
245cdf0e10cSrcweir                     aDragTimer.Start();
246cdf0e10cSrcweir                     pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
247cdf0e10cSrcweir                 }
248cdf0e10cSrcweir 			}
249cdf0e10cSrcweir 		}
250cdf0e10cSrcweir 		else
251cdf0e10cSrcweir 		{
252cdf0e10cSrcweir 			sal_Bool bMacro = sal_False;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir //			if (bMacro && pView->TakeMacroObject(aMDPos,pObj,pPV))
255cdf0e10cSrcweir 			if (bMacro && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 			{
258cdf0e10cSrcweir 				pView->BegMacroObj(aMDPos,pObj,pPV,pWindow);
259cdf0e10cSrcweir 			}
260cdf0e10cSrcweir 			else
261cdf0e10cSrcweir 			{
262cdf0e10cSrcweir 				if (pView->IsEditMode())
263cdf0e10cSrcweir 				{
264cdf0e10cSrcweir 					sal_Bool bPointMode=pView->HasMarkablePoints();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 					if (!rMEvt.IsShift())
267cdf0e10cSrcweir 					{
268cdf0e10cSrcweir 						if (bPointMode)
269cdf0e10cSrcweir 						{
270cdf0e10cSrcweir 							pView->UnmarkAllPoints();
271cdf0e10cSrcweir 						}
272cdf0e10cSrcweir 						else
273cdf0e10cSrcweir 						{
274cdf0e10cSrcweir 							pView->UnmarkAll();
275cdf0e10cSrcweir 						}
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 						pView->SetDragMode(SDRDRAG_MOVE);
278cdf0e10cSrcweir 						SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
279cdf0e10cSrcweir 						rBindings.Invalidate( SID_OBJECT_ROTATE );
280cdf0e10cSrcweir 						rBindings.Invalidate( SID_OBJECT_MIRROR );
281cdf0e10cSrcweir 						pHdl=pView->GetHdl(nHdlNum);
282cdf0e10cSrcweir 					}
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 					if ( pView->MarkObj(aMDPos, -2, sal_False, rMEvt.IsMod1()) )
285cdf0e10cSrcweir 					{
286cdf0e10cSrcweir 						aDragTimer.Start();
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 						pHdl=pView->PickHandle(aMDPos);
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 						if (pHdl!=NULL)
291cdf0e10cSrcweir 						{
292cdf0e10cSrcweir 							pView->MarkPoint(*pHdl);
293cdf0e10cSrcweir 							pHdl=pView->GetHdl(nHdlNum);
294cdf0e10cSrcweir 						}
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 						pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
297cdf0e10cSrcweir 					}
298cdf0e10cSrcweir 					else
299cdf0e10cSrcweir 					{
300cdf0e10cSrcweir 						if (bPointMode)
301cdf0e10cSrcweir 						{
302cdf0e10cSrcweir 							pView->BegMarkPoints(aMDPos);
303cdf0e10cSrcweir 						}
304cdf0e10cSrcweir 						else
305cdf0e10cSrcweir 						{
306cdf0e10cSrcweir 							pView->BegMarkObj(aMDPos);
307cdf0e10cSrcweir 						}
308cdf0e10cSrcweir 					}
309cdf0e10cSrcweir 				}
310cdf0e10cSrcweir 				else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
311cdf0e10cSrcweir 				{
312cdf0e10cSrcweir 					//	Notizen editieren -> keine neuen Textobjekte erzeugen,
313cdf0e10cSrcweir 					//	stattdessen Textmodus verlassen
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 					pViewShell->GetViewData()->GetDispatcher().
316cdf0e10cSrcweir 						Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
317cdf0e10cSrcweir 				}
318cdf0e10cSrcweir 				else
319cdf0e10cSrcweir 				{
320cdf0e10cSrcweir 					/**********************************************************
321cdf0e10cSrcweir 					* Objekt erzeugen
322cdf0e10cSrcweir 					**********************************************************/
323cdf0e10cSrcweir 					pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
324cdf0e10cSrcweir 				}
325cdf0e10cSrcweir 			}
326cdf0e10cSrcweir 		}
327cdf0e10cSrcweir 	}
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	if (!bIsInDragMode)
331cdf0e10cSrcweir 	{
332cdf0e10cSrcweir 		pWindow->CaptureMouse();
333cdf0e10cSrcweir //		ForcePointer(&rMEvt);
334cdf0e10cSrcweir 		lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 	pViewShell->SetActivePointer(pView->GetPreferedPointer(
338cdf0e10cSrcweir 					pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
339cdf0e10cSrcweir 
340cdf0e10cSrcweir //	return (bReturn);
341cdf0e10cSrcweir 	return sal_True;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir /*************************************************************************
345cdf0e10cSrcweir |*
346cdf0e10cSrcweir |* MouseMove-event
347cdf0e10cSrcweir |*
348cdf0e10cSrcweir \************************************************************************/
349cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)350cdf0e10cSrcweir sal_Bool __EXPORT FuText::MouseMove(const MouseEvent& rMEvt)
351cdf0e10cSrcweir {
352cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir //	pViewShell->SetActivePointer(aNewPointer);
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	pViewShell->SetActivePointer(pView->GetPreferedPointer(
357cdf0e10cSrcweir 					pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	if (aDragTimer.IsActive() )
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		Point aOldPixel = pWindow->LogicToPixel( aMDPos );
362cdf0e10cSrcweir 		Point aNewPixel = rMEvt.GetPosPixel();
363cdf0e10cSrcweir 		if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
364cdf0e10cSrcweir 			 Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
365cdf0e10cSrcweir 			aDragTimer.Stop();
366cdf0e10cSrcweir 	}
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	if ( pView->MouseMove(rMEvt, pWindow) )
369cdf0e10cSrcweir 		return (sal_True); // Event von der SdrView ausgewertet
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	if ( pView->IsAction() )
372cdf0e10cSrcweir 	{
373cdf0e10cSrcweir /*		aNewPointer = Pointer(POINTER_TEXT);
374cdf0e10cSrcweir 		pViewShell->SetActivePointer(aNewPointer);
375cdf0e10cSrcweir */
376cdf0e10cSrcweir 		Point aPix(rMEvt.GetPosPixel());
377cdf0e10cSrcweir 		Point aPnt(pWindow->PixelToLogic(aPix));
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 		ForceScroll(aPix);
380cdf0e10cSrcweir 		pView->MovAction(aPnt);
381cdf0e10cSrcweir 	}
382cdf0e10cSrcweir 
383cdf0e10cSrcweir //	ForcePointer(&rMEvt);
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	return (bReturn);
386cdf0e10cSrcweir }
387cdf0e10cSrcweir 
388cdf0e10cSrcweir /*************************************************************************
389cdf0e10cSrcweir |*
390cdf0e10cSrcweir |* MouseButtonUp-event
391cdf0e10cSrcweir |*
392cdf0e10cSrcweir \************************************************************************/
393cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)394cdf0e10cSrcweir sal_Bool __EXPORT FuText::MouseButtonUp(const MouseEvent& rMEvt)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
397cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 	if (aDragTimer.IsActive() )
402cdf0e10cSrcweir 	{
403cdf0e10cSrcweir 		aDragTimer.Stop();
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	if ( pView->MouseButtonUp(rMEvt, pWindow) )
411cdf0e10cSrcweir 		return (sal_True); // Event von der SdrView ausgewertet
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	if ( pView->IsDragObj() )
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir 		pView->EndDragObj( rMEvt.IsShift() );
416cdf0e10cSrcweir 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
417cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 		  	SdrMark* pMark = rMarkList.GetMark(0);
420cdf0e10cSrcweir 		  	SdrObject* pObj = pMark->GetMarkedSdrObj();
421cdf0e10cSrcweir 		  	FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
422cdf0e10cSrcweir 		  	FuText* pText = static_cast<FuText*>(pPoor);
423cdf0e10cSrcweir 			pText->StopDragMode(pObj );
424cdf0e10cSrcweir 		}
425cdf0e10cSrcweir 		pView->ForceMarkedToAnotherPage();
426cdf0e10cSrcweir 	}
427cdf0e10cSrcweir 	else if ( pView->IsCreateObj() )
428cdf0e10cSrcweir 	{
429cdf0e10cSrcweir 		if (rMEvt.IsLeft())
430cdf0e10cSrcweir 		{
431cdf0e10cSrcweir 			pView->EndCreateObj(SDRCREATE_FORCEEND);
432cdf0e10cSrcweir 			if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE)
433cdf0e10cSrcweir 			{
434cdf0e10cSrcweir 				//	Lauftext-Objekt erzeugen?
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
437cdf0e10cSrcweir 				if (rMarkList.GetMark(0))
438cdf0e10cSrcweir 				{
439cdf0e10cSrcweir 					SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 					// die fuer das Scrollen benoetigten Attribute setzen
442cdf0e10cSrcweir 					SfxItemSet aItemSet( pDrDoc->GetItemPool(),
443cdf0e10cSrcweir 											SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 					aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
446cdf0e10cSrcweir 					aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
447cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
448cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
449cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniCountItem( 1 ) );
450cdf0e10cSrcweir 					aItemSet.Put( SdrTextAniAmountItem(
451cdf0e10cSrcweir 									(sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
452cdf0e10cSrcweir 					pObj->SetMergedItemSetAndBroadcast(aItemSet);
453cdf0e10cSrcweir 				}
454cdf0e10cSrcweir 			}
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 			// #93382# init object different when vertical writing
457cdf0e10cSrcweir 			sal_uInt16 nSlotID(aSfxRequest.GetSlot());
458cdf0e10cSrcweir 			sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID);
459cdf0e10cSrcweir 			if(bVertical)
460cdf0e10cSrcweir 			{
461cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
462cdf0e10cSrcweir 				if(rMarkList.GetMark(0))
463cdf0e10cSrcweir 				{
464cdf0e10cSrcweir 					SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
465cdf0e10cSrcweir 					if(pObj && pObj->ISA(SdrTextObj))
466cdf0e10cSrcweir 					{
467cdf0e10cSrcweir 						SdrTextObj* pText = (SdrTextObj*)pObj;
468cdf0e10cSrcweir 						SfxItemSet aSet(pDrDoc->GetItemPool());
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 						pText->SetVerticalWriting(sal_True);
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 						aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
473cdf0e10cSrcweir 						aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
474cdf0e10cSrcweir 						aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
475cdf0e10cSrcweir 						aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 						pText->SetMergedItemSet(aSet);
478cdf0e10cSrcweir 					}
479cdf0e10cSrcweir 				}
480cdf0e10cSrcweir 			}
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 			SetInEditMode();
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 				//	Modus verlassen bei einzelnem Klick
485cdf0e10cSrcweir 				//	(-> fuconstr)
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 			if ( !pView->AreObjectsMarked() )
488cdf0e10cSrcweir 			{
489cdf0e10cSrcweir 				pView->MarkObj(aPnt, -2, sal_False, rMEvt.IsMod1());
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 				SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
492cdf0e10cSrcweir 				if ( pView->AreObjectsMarked() )
493cdf0e10cSrcweir 					rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
494cdf0e10cSrcweir 				else
495cdf0e10cSrcweir 					rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
496cdf0e10cSrcweir 			}
497cdf0e10cSrcweir 		}
498cdf0e10cSrcweir 	}
499cdf0e10cSrcweir 	else if ( pView->IsAction() )
500cdf0e10cSrcweir 	{
501cdf0e10cSrcweir 		pView->EndAction();
502cdf0e10cSrcweir 	}
503cdf0e10cSrcweir     else if( !pView->IsAction() )
504cdf0e10cSrcweir     {
505cdf0e10cSrcweir         pWindow->ReleaseMouse();
506cdf0e10cSrcweir 
507cdf0e10cSrcweir         if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
508cdf0e10cSrcweir         {
509cdf0e10cSrcweir             pView->MarkObj(aPnt, -2, sal_False, rMEvt.IsMod1());
510cdf0e10cSrcweir 
511cdf0e10cSrcweir             SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
512cdf0e10cSrcweir             if ( pView->AreObjectsMarked() )
513cdf0e10cSrcweir                 rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
514cdf0e10cSrcweir             else
515cdf0e10cSrcweir                 rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
516cdf0e10cSrcweir         }
517cdf0e10cSrcweir     }
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 	return (bReturn);
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir /*************************************************************************
523cdf0e10cSrcweir |*
524cdf0e10cSrcweir |* Maus-Pointer umschalten
525cdf0e10cSrcweir |*
526cdf0e10cSrcweir \************************************************************************/
527cdf0e10cSrcweir 
ForcePointer(const MouseEvent *)528cdf0e10cSrcweir void FuText::ForcePointer(const MouseEvent* /* pMEvt */)
529cdf0e10cSrcweir {
530cdf0e10cSrcweir 	pViewShell->SetActivePointer( aNewPointer );
531cdf0e10cSrcweir 
532cdf0e10cSrcweir /*
533cdf0e10cSrcweir 	if ( !pView->IsAction() )
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		Point aPnt(pWindow->PixelToLogic( pWindow->ScreenToOutputPixel(
536cdf0e10cSrcweir 				   Pointer::GetPosPixel() ) ) );
537cdf0e10cSrcweir 		SdrHdl* pHdl=pView->HitHandle(aPnt, *pWindow);
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 		if (pHdl!=NULL)
540cdf0e10cSrcweir 		{
541cdf0e10cSrcweir 			pViewShell->SetActivePointer(pHdl->GetPointer() );
542cdf0e10cSrcweir 		}
543cdf0e10cSrcweir 		else
544cdf0e10cSrcweir 		{
545cdf0e10cSrcweir 			SdrObject* pObj;
546cdf0e10cSrcweir 			SdrPageView* pPV;
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 			if ( pView->IsMarkedHit(aPnt) )
549cdf0e10cSrcweir 			{
550cdf0e10cSrcweir 				if ( pView->TakeTextEditObject(aPnt, pObj, pPV) )
551cdf0e10cSrcweir 				{
552cdf0e10cSrcweir 					pViewShell->SetActivePointer(Pointer(POINTER_TEXT));
553cdf0e10cSrcweir 				}
554cdf0e10cSrcweir 				else
555cdf0e10cSrcweir 				{
556cdf0e10cSrcweir 					pViewShell->SetActivePointer(Pointer(POINTER_MOVE));
557cdf0e10cSrcweir 				}
558cdf0e10cSrcweir 			}
559cdf0e10cSrcweir 			else
560cdf0e10cSrcweir 			{
561cdf0e10cSrcweir //				if ( pView->TakeMacroObject(aPnt, pObj, pPV) )
562cdf0e10cSrcweir 				if ( pView->PickObj(aPnt, pObj, pPV, SDRSEARCH_PICKMACRO) )
563cdf0e10cSrcweir 				{
564cdf0e10cSrcweir 					pViewShell->SetActivePointer( pObj->GetMacroPointer() );
565cdf0e10cSrcweir 				}
566cdf0e10cSrcweir 				else
567cdf0e10cSrcweir 				{
568cdf0e10cSrcweir 					pViewShell->SetActivePointer( aNewPointer );
569cdf0e10cSrcweir 				}
570cdf0e10cSrcweir 			}
571cdf0e10cSrcweir 		}
572cdf0e10cSrcweir 	}
573cdf0e10cSrcweir */
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 
578cdf0e10cSrcweir /*************************************************************************
579cdf0e10cSrcweir |*
580cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
581cdf0e10cSrcweir |*
582cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
583cdf0e10cSrcweir |* FALSE.
584cdf0e10cSrcweir |*
585cdf0e10cSrcweir \************************************************************************/
586cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)587cdf0e10cSrcweir sal_Bool __EXPORT FuText::KeyInput(const KeyEvent& rKEvt)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 	if ( pView->KeyInput(rKEvt, pWindow) )
592cdf0e10cSrcweir 	{
593cdf0e10cSrcweir 		bReturn = sal_True;
594cdf0e10cSrcweir 		lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
595cdf0e10cSrcweir 	}
596cdf0e10cSrcweir 	else
597cdf0e10cSrcweir 	{
598cdf0e10cSrcweir 		bReturn = FuDraw::KeyInput(rKEvt);
599cdf0e10cSrcweir 	}
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 	return (bReturn);
602cdf0e10cSrcweir }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 
606cdf0e10cSrcweir /*************************************************************************
607cdf0e10cSrcweir |*
608cdf0e10cSrcweir |* Function aktivieren
609cdf0e10cSrcweir |*
610cdf0e10cSrcweir \************************************************************************/
611cdf0e10cSrcweir 
Activate()612cdf0e10cSrcweir void FuText::Activate()
613cdf0e10cSrcweir {
614cdf0e10cSrcweir 	pView->SetDragMode(SDRDRAG_MOVE);
615cdf0e10cSrcweir 	SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
616cdf0e10cSrcweir 	rBindings.Invalidate( SID_OBJECT_ROTATE );
617cdf0e10cSrcweir 	rBindings.Invalidate( SID_OBJECT_MIRROR );
618cdf0e10cSrcweir 
619cdf0e10cSrcweir //	Sofort in den Edit Mode setzen
620cdf0e10cSrcweir //	SetInEditMode();
621cdf0e10cSrcweir 
622cdf0e10cSrcweir //	if (!pTextObj)
623cdf0e10cSrcweir 	{
624cdf0e10cSrcweir 		/**********************************************************************
625cdf0e10cSrcweir 		* Kein Textobjekt im EditMode, daher CreateMode setzen
626cdf0e10cSrcweir 		**********************************************************************/
627cdf0e10cSrcweir 		sal_uInt16 nObj = OBJ_TEXT;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir /*		sal_uInt16 nIdent;
630cdf0e10cSrcweir 		sal_uInt32 nInvent;
631cdf0e10cSrcweir 		pView->TakeCurrentObj(nIdent, nInvent);
632cdf0e10cSrcweir */
633cdf0e10cSrcweir 		pView->SetCurrentObj(nObj);
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 		pView->SetCreateMode();
636cdf0e10cSrcweir 	}
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 	aNewPointer = Pointer(POINTER_TEXT);
639cdf0e10cSrcweir //	aNewPointer = Pointer(POINTER_CROSS);				//! ???
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	aOldPointer = pWindow->GetPointer();
642cdf0e10cSrcweir 	pViewShell->SetActivePointer( aNewPointer );
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	FuConstruct::Activate();
645cdf0e10cSrcweir }
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 
648cdf0e10cSrcweir /*************************************************************************
649cdf0e10cSrcweir |*
650cdf0e10cSrcweir |* Function deaktivieren
651cdf0e10cSrcweir |*
652cdf0e10cSrcweir \************************************************************************/
653cdf0e10cSrcweir 
Deactivate()654cdf0e10cSrcweir void FuText::Deactivate()
655cdf0e10cSrcweir {
656cdf0e10cSrcweir 	FuConstruct::Deactivate();
657cdf0e10cSrcweir 	pViewShell->SetActivePointer( aOldPointer );
658cdf0e10cSrcweir 	StopEditMode();
659cdf0e10cSrcweir }
660cdf0e10cSrcweir 
661cdf0e10cSrcweir 
662cdf0e10cSrcweir /*************************************************************************
663cdf0e10cSrcweir |*
664cdf0e10cSrcweir |* Selektion hat sich geaendert
665cdf0e10cSrcweir |*
666cdf0e10cSrcweir \************************************************************************/
667cdf0e10cSrcweir 
SelectionHasChanged()668cdf0e10cSrcweir void FuText::SelectionHasChanged()
669cdf0e10cSrcweir {
670cdf0e10cSrcweir 	pView->SetDragMode(SDRDRAG_MOVE);
671cdf0e10cSrcweir 	SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
672cdf0e10cSrcweir 	rBindings.Invalidate( SID_OBJECT_ROTATE );
673cdf0e10cSrcweir 	rBindings.Invalidate( SID_OBJECT_MIRROR );
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 	pTextObj = NULL;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	if ( pView->AreObjectsMarked() )
678cdf0e10cSrcweir 	{
679cdf0e10cSrcweir 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
682cdf0e10cSrcweir 		{
683cdf0e10cSrcweir 			SdrMark* pMark = rMarkList.GetMark(0);
684cdf0e10cSrcweir 			SdrObject* pObj = pMark->GetMarkedSdrObj();
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 			sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 			if (nSdrObjKind == OBJ_TEXT ||
689cdf0e10cSrcweir 				nSdrObjKind == OBJ_TITLETEXT ||
690cdf0e10cSrcweir 				nSdrObjKind == OBJ_OUTLINETEXT /* ||
691cdf0e10cSrcweir 				pObj->ISA(SdrTextObj) */ )
692cdf0e10cSrcweir 			{
693cdf0e10cSrcweir 				pTextObj = (SdrTextObj*) pObj;
694cdf0e10cSrcweir 			}
695cdf0e10cSrcweir 		}
696cdf0e10cSrcweir 	}
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 	if (!pTextObj)
699cdf0e10cSrcweir 	{
700cdf0e10cSrcweir 		/**********************************************************************
701cdf0e10cSrcweir 		* Kein Textobjekt im EditMode, daher CreateMode setzen
702cdf0e10cSrcweir 		**********************************************************************/
703cdf0e10cSrcweir 		sal_uInt16 nObj = OBJ_TEXT;
704cdf0e10cSrcweir 		sal_uInt16 nIdent;
705cdf0e10cSrcweir 		sal_uInt32 nInvent;
706cdf0e10cSrcweir 		pView->TakeCurrentObj(nIdent, nInvent);
707cdf0e10cSrcweir 
708cdf0e10cSrcweir //		  if (! pView->IsEditMode() )
709cdf0e10cSrcweir //		  {
710cdf0e10cSrcweir //			  if (nIdent == OBJ_TEXT)
711cdf0e10cSrcweir //			  {
712cdf0e10cSrcweir //				  nObj = OBJ_TEXT;
713cdf0e10cSrcweir //			  }
714cdf0e10cSrcweir //			  else if (nIdent == OBJ_OUTLINETEXT)
715cdf0e10cSrcweir //			  {
716cdf0e10cSrcweir //				  nObj = OBJ_OUTLINETEXT;
717cdf0e10cSrcweir //			  }
718cdf0e10cSrcweir //			  else if (nIdent == OBJ_TITLETEXT)
719cdf0e10cSrcweir //			  {
720cdf0e10cSrcweir //				  nObj = OBJ_TITLETEXT;
721cdf0e10cSrcweir //			  }
722cdf0e10cSrcweir //		  }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 		pView->SetCurrentObj(nObj);
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 		pView->SetCreateMode();
727cdf0e10cSrcweir 	}
728cdf0e10cSrcweir }
729cdf0e10cSrcweir 
730cdf0e10cSrcweir /*************************************************************************
731cdf0e10cSrcweir |*
732cdf0e10cSrcweir |* Objekt in Edit-Mode setzen
733cdf0e10cSrcweir |*
734cdf0e10cSrcweir \************************************************************************/
735cdf0e10cSrcweir 
SetInEditMode(SdrObject * pObj,const Point * pMousePixel,sal_Bool bCursorToEnd,const KeyEvent * pInitialKey)736cdf0e10cSrcweir void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
737cdf0e10cSrcweir 							sal_Bool bCursorToEnd, const KeyEvent* pInitialKey)
738cdf0e10cSrcweir {
739cdf0e10cSrcweir     /*  It is possible to pass a special (unselected) object in pObj, e.g. the
740cdf0e10cSrcweir         caption object of a cell note. If pObj is 0, then the selected object
741cdf0e10cSrcweir         is used. The layer will be relocked in FuText::StopEditMode(). */
742cdf0e10cSrcweir 	if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) )
743cdf0e10cSrcweir         pView->UnlockInternalLayer();
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 	if ( !pObj && pView->AreObjectsMarked() )
746cdf0e10cSrcweir 	{
747cdf0e10cSrcweir 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
748cdf0e10cSrcweir 		if (rMarkList.GetMarkCount() == 1)
749cdf0e10cSrcweir 		{
750cdf0e10cSrcweir 			SdrMark* pMark = rMarkList.GetMark(0);
751cdf0e10cSrcweir 			pObj = pMark->GetMarkedSdrObj();
752cdf0e10cSrcweir 		}
753cdf0e10cSrcweir 	}
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 	pTextObj = NULL;
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 	if ( pObj )
758cdf0e10cSrcweir 	{
759cdf0e10cSrcweir 		sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
760cdf0e10cSrcweir 
761cdf0e10cSrcweir 		if (nSdrObjKind == OBJ_TEXT ||
762cdf0e10cSrcweir 			nSdrObjKind == OBJ_TITLETEXT ||
763cdf0e10cSrcweir 			nSdrObjKind == OBJ_OUTLINETEXT ||
764cdf0e10cSrcweir 			pObj->ISA(SdrTextObj))
765cdf0e10cSrcweir 		{
766cdf0e10cSrcweir 			SdrPageView* pPV = pView->GetSdrPageView();
767cdf0e10cSrcweir 			Rectangle aRect = pObj->GetLogicRect();
768cdf0e10cSrcweir 			Point aPnt = aRect.Center();
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 			if ( pObj->HasTextEdit() )
771cdf0e10cSrcweir 			{
772cdf0e10cSrcweir 				SdrOutliner* pO = MakeOutliner();
773cdf0e10cSrcweir 				lcl_UpdateHyphenator( *pO, pObj );
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 				//	vertical flag:
776cdf0e10cSrcweir 				//	deduced from slot ids only if text object has no content
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 				sal_uInt16 nSlotID = aSfxRequest.GetSlot();
779cdf0e10cSrcweir 				sal_Bool bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
780cdf0e10cSrcweir 				OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
781cdf0e10cSrcweir 				if ( pOPO )
782cdf0e10cSrcweir 					bVertical = pOPO->IsVertical();		// content wins
783cdf0e10cSrcweir 				pO->SetVertical( bVertical );
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 				//!??	ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
786cdf0e10cSrcweir 				if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
787cdf0e10cSrcweir 				{
788cdf0e10cSrcweir 					//	EditEngine-UndoManager anmelden
789cdf0e10cSrcweir 					pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 					pTextObj = (SdrTextObj*) pObj;
792cdf0e10cSrcweir 					pView->SetEditMode();
793cdf0e10cSrcweir 
794cdf0e10cSrcweir 					//	set text cursor to click position or to end,
795cdf0e10cSrcweir 					//	pass initial key event to outliner view
796cdf0e10cSrcweir 					if ( pMousePixel || bCursorToEnd || pInitialKey )
797cdf0e10cSrcweir 					{
798cdf0e10cSrcweir 						OutlinerView* pOLV = pView->GetTextEditOutlinerView();
799cdf0e10cSrcweir 						if (pOLV)
800cdf0e10cSrcweir 						{
801cdf0e10cSrcweir 							if ( pMousePixel )
802cdf0e10cSrcweir 							{
803cdf0e10cSrcweir 								MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
804cdf0e10cSrcweir 								pOLV->MouseButtonDown(aEditEvt);
805cdf0e10cSrcweir 								pOLV->MouseButtonUp(aEditEvt);
806cdf0e10cSrcweir 							}
807cdf0e10cSrcweir 							else if ( bCursorToEnd )
808cdf0e10cSrcweir 							{
809cdf0e10cSrcweir 								ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
810cdf0e10cSrcweir 								pOLV->SetSelection(aNewSelection);
811cdf0e10cSrcweir 							}
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 							if ( pInitialKey )
814cdf0e10cSrcweir 								pOLV->PostKeyEvent( *pInitialKey );
815cdf0e10cSrcweir 						}
816cdf0e10cSrcweir 					}
817cdf0e10cSrcweir 				}
818cdf0e10cSrcweir 			}
819cdf0e10cSrcweir 		}
820cdf0e10cSrcweir 	}
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
823cdf0e10cSrcweir // #98185# Create default drawing objects via keyboard
CreateDefaultObject(const sal_uInt16 nID,const Rectangle & rRectangle)824cdf0e10cSrcweir SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
825cdf0e10cSrcweir {
826cdf0e10cSrcweir 	// case SID_DRAW_TEXT:
827cdf0e10cSrcweir 	// case SID_DRAW_TEXT_VERTICAL:
828cdf0e10cSrcweir 	// case SID_DRAW_TEXT_MARQUEE:
829cdf0e10cSrcweir 	// case SID_DRAW_NOTEEDIT:
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
832cdf0e10cSrcweir 		pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
833cdf0e10cSrcweir 		0L, pDrDoc);
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 	if(pObj)
836cdf0e10cSrcweir 	{
837cdf0e10cSrcweir 		if(pObj->ISA(SdrTextObj))
838cdf0e10cSrcweir 		{
839cdf0e10cSrcweir 			SdrTextObj* pText = (SdrTextObj*)pObj;
840cdf0e10cSrcweir 			pText->SetLogicRect(rRectangle);
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 			//  #105815# don't set default text, start edit mode instead
843cdf0e10cSrcweir 			// String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
844cdf0e10cSrcweir 			// pText->SetText(aText);
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 			sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID);
847cdf0e10cSrcweir 			sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID);
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 			pText->SetVerticalWriting(bVertical);
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 			if(bVertical)
852cdf0e10cSrcweir 			{
853cdf0e10cSrcweir 				SfxItemSet aSet(pDrDoc->GetItemPool());
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
856cdf0e10cSrcweir 				aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
857cdf0e10cSrcweir 				aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
858cdf0e10cSrcweir 				aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 				pText->SetMergedItemSet(aSet);
861cdf0e10cSrcweir 			}
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 			if(bMarquee)
864cdf0e10cSrcweir 			{
865cdf0e10cSrcweir 				SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 				aSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
868cdf0e10cSrcweir 				aSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
869cdf0e10cSrcweir 				aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
870cdf0e10cSrcweir 				aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
871cdf0e10cSrcweir 				aSet.Put( SdrTextAniCountItem( 1 ) );
872cdf0e10cSrcweir 				aSet.Put( SdrTextAniAmountItem( (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) );
873cdf0e10cSrcweir 
874cdf0e10cSrcweir 				pObj->SetMergedItemSetAndBroadcast(aSet);
875cdf0e10cSrcweir 			}
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 			SetInEditMode( pObj );		// #105815# start edit mode
878cdf0e10cSrcweir 		}
879cdf0e10cSrcweir 		else
880cdf0e10cSrcweir 		{
881cdf0e10cSrcweir 			DBG_ERROR("Object is NO text object");
882cdf0e10cSrcweir 		}
883cdf0e10cSrcweir 	}
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 	return pObj;
886cdf0e10cSrcweir }
887cdf0e10cSrcweir 
888