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