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 "hintids.hxx"
22 : #include <svl/aeitem.hxx>
23 : #include <svl/itempool.hxx>
24 : #include <svx/svdobj.hxx>
25 : #include <svx/svdview.hxx>
26 : #include <svx/svdpage.hxx>
27 : #include <editeng/editview.hxx>
28 : #include <editeng/editeng.hxx>
29 : #include <editeng/outliner.hxx>
30 : #include <svx/fmview.hxx>
31 : #include <svx/dataaccessdescriptor.hxx>
32 : #include <sfx2/viewfrm.hxx>
33 : #include <doc.hxx>
34 : #include <editeng/langitem.hxx>
35 : #include <linguistic/lngprops.hxx>
36 : #include <editeng/unolingu.hxx>
37 : #include <svx/fontworkbar.hxx>
38 : #include <svx/fontworkgallery.hxx>
39 : #include <editeng/eeitem.hxx>
40 : #include <svx/svdogrp.hxx>
41 : #include <svx/svdetc.hxx>
42 : #include <editeng/editstat.hxx>
43 : #include <sfx2/request.hxx>
44 : #include <sfx2/bindings.hxx>
45 : #include <sfx2/printer.hxx>
46 : #include <svx/fmglob.hxx>
47 : #include <sfx2/dispatch.hxx>
48 : #include <svx/svdoutl.hxx>
49 :
50 : #include "view.hxx"
51 : #include "wrtsh.hxx"
52 : #include "viewopt.hxx"
53 : #include "cmdid.h"
54 : #include "drawsh.hxx"
55 : #include "drwbassh.hxx"
56 : #include "beziersh.hxx"
57 : #include "conrect.hxx"
58 : #include "conpoly.hxx"
59 : #include "conarc.hxx"
60 : #include "conform.hxx"
61 : #include "concustomshape.hxx"
62 : #include "dselect.hxx"
63 : #include "edtwin.hxx"
64 :
65 : #include <dcontact.hxx>
66 :
67 : #include <svx/svdpagv.hxx>
68 : #include <svx/extrusionbar.hxx>
69 : #include <vcl/svapp.hxx>
70 :
71 : using namespace ::com::sun::star;
72 :
73 : /*--------------------------------------------------------------------
74 : Beschreibung: Drawing-Ids ausfuehren
75 : --------------------------------------------------------------------*/
76 0 : void SwView::ExecDraw(SfxRequest& rReq)
77 : {
78 0 : const SfxItemSet *pArgs = rReq.GetArgs();
79 : const SfxPoolItem* pItem;
80 0 : const SfxAllEnumItem* pEItem = 0;
81 0 : const SfxStringItem* pStringItem = 0;
82 0 : SdrView *pSdrView = pWrtShell->GetDrawView();
83 0 : sal_Bool bDeselect = sal_False;
84 :
85 0 : sal_uInt16 nSlotId = rReq.GetSlot();
86 0 : if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), sal_False, &pItem))
87 : {
88 0 : pEItem = dynamic_cast< const SfxAllEnumItem*>(pItem);
89 0 : pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
90 : }
91 :
92 0 : if (SID_INSERT_DRAW == nSlotId && pEItem)
93 0 : switch ( pEItem->GetValue() )
94 : {
95 0 : case SVX_SNAP_DRAW_SELECT: nSlotId = SID_OBJECT_SELECT; break;
96 0 : case SVX_SNAP_DRAW_LINE: nSlotId = SID_DRAW_LINE; break;
97 0 : case SVX_SNAP_DRAW_RECT: nSlotId = SID_DRAW_RECT; break;
98 0 : case SVX_SNAP_DRAW_ELLIPSE: nSlotId = SID_DRAW_ELLIPSE; break;
99 0 : case SVX_SNAP_DRAW_POLYGON_NOFILL: nSlotId = SID_DRAW_POLYGON_NOFILL; break;
100 0 : case SVX_SNAP_DRAW_BEZIER_NOFILL: nSlotId = SID_DRAW_BEZIER_NOFILL; break;
101 0 : case SVX_SNAP_DRAW_FREELINE_NOFILL: nSlotId = SID_DRAW_FREELINE_NOFILL; break;
102 0 : case SVX_SNAP_DRAW_ARC: nSlotId = SID_DRAW_ARC; break;
103 0 : case SVX_SNAP_DRAW_PIE: nSlotId = SID_DRAW_PIE; break;
104 0 : case SVX_SNAP_DRAW_CIRCLECUT: nSlotId = SID_DRAW_CIRCLECUT; break;
105 0 : case SVX_SNAP_DRAW_TEXT: nSlotId = SID_DRAW_TEXT; break;
106 0 : case SVX_SNAP_DRAW_TEXT_VERTICAL: nSlotId = SID_DRAW_TEXT_VERTICAL; break;
107 0 : case SVX_SNAP_DRAW_TEXT_MARQUEE: nSlotId = SID_DRAW_TEXT_MARQUEE; break;
108 0 : case SVX_SNAP_DRAW_CAPTION: nSlotId = SID_DRAW_CAPTION; break;
109 0 : case SVX_SNAP_DRAW_CAPTION_VERTICAL: nSlotId = SID_DRAW_CAPTION_VERTICAL; break;
110 : }
111 :
112 0 : if (nSlotId == SID_OBJECT_SELECT && nFormSfxId == nSlotId)
113 : {
114 0 : bDeselect = sal_True;
115 : }
116 0 : else if (nSlotId == SID_FM_CREATE_CONTROL)
117 : {
118 0 : SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
119 0 : if( pIdentifierItem )
120 : {
121 0 : sal_uInt16 nNewId = pIdentifierItem->GetValue();
122 0 : if (nNewId == nFormSfxId)
123 : {
124 0 : bDeselect = sal_True;
125 0 : GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button soll rauspoppen
126 : }
127 : }
128 : }
129 0 : else if( nSlotId == SID_FM_CREATE_FIELDCONTROL)
130 : {
131 0 : FmFormView* pFormView = PTR_CAST( FmFormView, pSdrView );
132 0 : if ( pFormView )
133 : {
134 0 : SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
135 : OSL_ENSURE( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
136 0 : if( pDescriptorItem )
137 : {
138 0 : ::svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
139 0 : SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
140 :
141 0 : if ( pObj )
142 : {
143 0 : Size aDocSize(pWrtShell->GetDocSize());
144 0 : const SwRect& rVisArea = pWrtShell->VisArea();
145 0 : Point aStartPos = rVisArea.Center();
146 0 : if(rVisArea.Width() > aDocSize.Width())
147 0 : aStartPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
148 0 : if(rVisArea.Height() > aDocSize.Height())
149 0 : aStartPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
150 :
151 : //determine the size of the object
152 0 : if(pObj->IsGroupObject())
153 : {
154 0 : const Rectangle& rBoundRect = ((SdrObjGroup*)pObj)->GetCurrentBoundRect();
155 0 : aStartPos.X() -= rBoundRect.GetWidth()/2;
156 0 : aStartPos.Y() -= rBoundRect.GetHeight()/2;
157 : }
158 :
159 : // TODO: unmark all other
160 0 : pWrtShell->EnterStdMode();
161 0 : pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
162 0 : }
163 : }
164 : }
165 : }
166 0 : else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
167 : {
168 0 : Window* pWin = &( pWrtShell->GetView().GetViewFrame()->GetWindow() );
169 :
170 0 : if ( pWin )
171 0 : pWin->EnterWait();
172 :
173 0 : if( !pWrtShell->HasDrawView() )
174 0 : pWrtShell->MakeDrawView();
175 :
176 0 : pSdrView = pWrtShell->GetDrawView();
177 0 : if ( pSdrView )
178 : {
179 0 : SdrObject* pObj = NULL;
180 0 : svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId );
181 0 : aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
182 0 : aDlg.Execute();
183 0 : if ( pObj )
184 : {
185 0 : Size aDocSize( pWrtShell->GetDocSize() );
186 0 : const SwRect& rVisArea = pWrtShell->VisArea();
187 0 : Point aPos( rVisArea.Center() );
188 0 : Size aSize;
189 0 : Size aPrefSize( pObj->GetSnapRect().GetSize() );
190 :
191 0 : if( rVisArea.Width() > aDocSize.Width())
192 0 : aPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
193 :
194 0 : if(rVisArea.Height() > aDocSize.Height())
195 0 : aPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
196 :
197 0 : if( aPrefSize.Width() && aPrefSize.Height() )
198 : {
199 0 : if( pWin )
200 0 : aSize = pWin->PixelToLogic( aPrefSize, MAP_TWIP );
201 : else
202 0 : aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
203 : }
204 : else
205 0 : aSize = Size( 2835, 2835 );
206 :
207 0 : pWrtShell->EnterStdMode();
208 0 : pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
209 0 : rReq.Ignore ();
210 0 : }
211 : }
212 0 : if( pWin )
213 0 : pWin->LeaveWait();
214 : }
215 :
216 0 : if( nSlotId == SID_DRAW_CS_ID )
217 : {
218 : //deselect if same custom shape is selected again
219 0 : SwDrawBase* pFuncPtr = GetDrawFuncPtr();
220 0 : if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
221 : {
222 0 : ConstCustomShape* pConstCustomShape = (ConstCustomShape*)(pFuncPtr);
223 0 : rtl::OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
224 0 : rtl::OUString aOld = pConstCustomShape->GetShapeType();
225 0 : if( aNew == aOld )
226 : {
227 0 : bDeselect = true;
228 0 : }
229 : }
230 : }
231 :
232 : //deselect if same shape is selected again (but different custom shapes do have same slot id)
233 0 : if ( bDeselect || (nSlotId == nDrawSfxId &&
234 0 : (!pStringItem || (pStringItem->GetValue() == sDrawCustom))
235 : && (nSlotId != SID_DRAW_CS_ID) ) )
236 : {
237 0 : if (GetDrawFuncPtr())
238 : {
239 0 : GetDrawFuncPtr()->Deactivate();
240 0 : SetDrawFuncPtr(NULL);
241 : }
242 :
243 0 : if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
244 0 : pWrtShell->EnterSelFrmMode(NULL);
245 0 : LeaveDrawCreate();
246 :
247 0 : GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
248 :
249 0 : AttrChangedNotify(pWrtShell);
250 0 : return;
251 : }
252 :
253 0 : LeaveDrawCreate();
254 :
255 0 : if (pWrtShell->IsFrmSelected())
256 0 : pWrtShell->EnterStdMode(); // wegen Bug #45639
257 :
258 0 : SwDrawBase* pFuncPtr = NULL;
259 :
260 0 : switch (nSlotId)
261 : {
262 : case SID_OBJECT_SELECT:
263 : case SID_DRAW_SELECT:
264 0 : pFuncPtr = new DrawSelection(pWrtShell, pEditWin, this);
265 0 : nDrawSfxId = nFormSfxId = SID_OBJECT_SELECT;
266 0 : sDrawCustom.Erase();
267 0 : break;
268 :
269 : case SID_DRAW_LINE:
270 : case SID_DRAW_RECT:
271 : case SID_DRAW_ELLIPSE:
272 : case SID_DRAW_TEXT:
273 : case SID_DRAW_TEXT_VERTICAL:
274 : case SID_DRAW_TEXT_MARQUEE:
275 : case SID_DRAW_CAPTION:
276 : case SID_DRAW_CAPTION_VERTICAL:
277 0 : pFuncPtr = new ConstRectangle(pWrtShell, pEditWin, this);
278 0 : nDrawSfxId = nSlotId;
279 0 : sDrawCustom.Erase();
280 0 : break;
281 :
282 : case SID_DRAW_POLYGON_NOFILL:
283 : case SID_DRAW_BEZIER_NOFILL:
284 : case SID_DRAW_FREELINE_NOFILL:
285 0 : pFuncPtr = new ConstPolygon(pWrtShell, pEditWin, this);
286 0 : nDrawSfxId = nSlotId;
287 0 : sDrawCustom.Erase();
288 0 : break;
289 :
290 : case SID_DRAW_ARC:
291 : case SID_DRAW_PIE:
292 : case SID_DRAW_CIRCLECUT:
293 0 : pFuncPtr = new ConstArc(pWrtShell, pEditWin, this);
294 0 : nDrawSfxId = nSlotId;
295 0 : sDrawCustom.Erase();
296 0 : break;
297 :
298 : case SID_FM_CREATE_CONTROL:
299 : {
300 0 : SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
301 0 : if( pIdentifierItem )
302 0 : nSlotId = pIdentifierItem->GetValue();
303 0 : pFuncPtr = new ConstFormControl(pWrtShell, pEditWin, this);
304 0 : nFormSfxId = nSlotId;
305 : }
306 0 : break;
307 :
308 : case SID_DRAWTBX_CS_BASIC :
309 : case SID_DRAWTBX_CS_SYMBOL :
310 : case SID_DRAWTBX_CS_ARROW :
311 : case SID_DRAWTBX_CS_FLOWCHART :
312 : case SID_DRAWTBX_CS_CALLOUT :
313 : case SID_DRAWTBX_CS_STAR :
314 : case SID_DRAW_CS_ID :
315 : {
316 0 : pFuncPtr = new ConstCustomShape(pWrtShell, pEditWin, this, rReq );
317 0 : nDrawSfxId = nSlotId;
318 0 : if ( nSlotId != SID_DRAW_CS_ID )
319 : {
320 0 : if ( pStringItem )
321 : {
322 0 : sDrawCustom = pStringItem->GetValue();
323 0 : aCurrShapeEnumCommand[ nSlotId - SID_DRAWTBX_CS_BASIC ] = sDrawCustom;
324 0 : SfxBindings& rBind = GetViewFrame()->GetBindings();
325 0 : rBind.Invalidate( nSlotId );
326 0 : rBind.Update( nSlotId );
327 : }
328 : }
329 : }
330 0 : break;
331 :
332 : default:
333 0 : break;
334 : }
335 :
336 : static sal_uInt16 const aInval[] =
337 : {
338 : // Slot-Ids muessen beim Aufruf von Invalidate sortiert sein!
339 : SID_ATTRIBUTES_AREA,
340 : SID_INSERT_DRAW,
341 : 0
342 : };
343 0 : GetViewFrame()->GetBindings().Invalidate(aInval);
344 :
345 0 : sal_Bool bEndTextEdit = sal_True;
346 0 : if (pFuncPtr)
347 : {
348 0 : if (GetDrawFuncPtr())
349 : {
350 0 : GetDrawFuncPtr()->Deactivate();
351 0 : SetDrawFuncPtr(NULL);
352 : }
353 :
354 0 : SetDrawFuncPtr(pFuncPtr);
355 0 : AttrChangedNotify(pWrtShell);
356 :
357 0 : pFuncPtr->Activate(nSlotId);
358 0 : NoRotate();
359 0 : if(rReq.GetModifier() == KEY_MOD1)
360 : {
361 0 : if(SID_OBJECT_SELECT == nDrawSfxId )
362 : {
363 0 : pWrtShell->GotoObj(sal_True);
364 : }
365 : else
366 : {
367 0 : pFuncPtr->CreateDefaultObject();
368 0 : pFuncPtr->Deactivate();
369 0 : SetDrawFuncPtr(NULL);
370 0 : LeaveDrawCreate();
371 0 : pWrtShell->EnterStdMode();
372 0 : SdrView *pTmpSdrView = pWrtShell->GetDrawView();
373 0 : const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
374 0 : if(rMarkList.GetMarkCount() == 1 &&
375 : (SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
376 : SID_DRAW_TEXT_MARQUEE == nSlotId ))
377 : {
378 0 : SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
379 0 : BeginTextEdit(pObj);
380 0 : bEndTextEdit = sal_False;
381 : }
382 : }
383 : }
384 : }
385 : else
386 : {
387 0 : if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
388 0 : pWrtShell->EnterSelFrmMode(NULL);
389 : }
390 :
391 0 : if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
392 0 : pSdrView->SdrEndTextEdit( sal_True );
393 :
394 0 : AttrChangedNotify(pWrtShell);
395 : }
396 :
397 : /*--------------------------------------------------------------------
398 : Beschreibung: Drawing beenden
399 : --------------------------------------------------------------------*/
400 0 : void SwView::ExitDraw()
401 : {
402 0 : NoRotate();
403 :
404 0 : if(pShell)
405 : {
406 : // the shell may be invalid at close/reload/SwitchToViewShell
407 0 : SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
408 0 : sal_uInt16 nIdx = 0;
409 0 : SfxShell* pTest = 0;
410 0 : do
411 : {
412 0 : pTest = pDispatch->GetShell(nIdx++);
413 : }
414 : while( pTest && pTest != this && pTest != pShell);
415 0 : if(pTest == pShell &&
416 : // don't call LeaveSelFrmMode() etc. for the below,
417 : // because objects may still be selected:
418 0 : !pShell->ISA(SwDrawBaseShell) &&
419 0 : !pShell->ISA(SwBezierShell) &&
420 0 : !pShell->ISA(svx::ExtrusionBar) &&
421 0 : !pShell->ISA(svx::FontworkBar))
422 : {
423 0 : SdrView *pSdrView = pWrtShell->GetDrawView();
424 :
425 0 : if (pSdrView && pSdrView->IsGroupEntered())
426 : {
427 0 : pSdrView->LeaveOneGroup();
428 0 : pSdrView->UnmarkAll();
429 0 : GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
430 : }
431 :
432 0 : if (GetDrawFuncPtr())
433 : {
434 0 : if (pWrtShell->IsSelFrmMode())
435 0 : pWrtShell->LeaveSelFrmMode();
436 0 : GetDrawFuncPtr()->Deactivate();
437 :
438 0 : SetDrawFuncPtr(NULL);
439 0 : LeaveDrawCreate();
440 :
441 0 : GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
442 : }
443 0 : GetEditWin().SetPointer(Pointer(POINTER_TEXT));
444 : }
445 : }
446 0 : }
447 :
448 : /*--------------------------------------------------------------------
449 : Beschreibung: Rotate-Mode abschalten
450 : --------------------------------------------------------------------*/
451 0 : void SwView::NoRotate()
452 : {
453 0 : if (IsDrawRotate())
454 : {
455 0 : pWrtShell->SetDragMode(SDRDRAG_MOVE);
456 0 : FlipDrawRotate();
457 :
458 0 : const SfxBoolItem aTmp( SID_OBJECT_ROTATE, sal_False );
459 0 : GetViewFrame()->GetBindings().SetState( aTmp );
460 : }
461 0 : }
462 :
463 : /******************************************************************************
464 : * Beschreibung: DrawTextEditMode einschalten
465 : ******************************************************************************/
466 0 : sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos)
467 : {
468 : SdrObject* pObj;
469 : SdrPageView* pPV;
470 0 : SwWrtShell *pSh = &GetWrtShell();
471 0 : SdrView *pSdrView = pSh->GetDrawView();
472 : OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
473 :
474 0 : sal_Bool bReturn = sal_False;
475 :
476 0 : sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
477 0 : pSdrView->SetHitTolerancePixel( 2 );
478 :
479 0 : if( pSdrView->IsMarkedHit( aDocPos ) &&
480 0 : !pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
481 0 : pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) &&
482 :
483 : // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
484 0 : ( pObj->ISA( SdrTextObj ) ||
485 0 : ( pObj->ISA(SwDrawVirtObj) &&
486 0 : ((SwDrawVirtObj*)pObj)->GetReferencedObj().ISA(SdrTextObj) ) ) &&
487 :
488 0 : !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
489 : {
490 0 : bReturn = BeginTextEdit( pObj, pPV, pEditWin, sal_False );
491 : }
492 :
493 0 : pSdrView->SetHitTolerancePixel( nOld );
494 :
495 0 : return bReturn;
496 : }
497 :
498 : /******************************************************************************
499 : * Beschreibung: DrawTextEditMode einschalten
500 : ******************************************************************************/
501 0 : sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin,
502 : bool bIsNewObj, bool bSetSelectionToStart)
503 : {
504 0 : SwWrtShell *pSh = &GetWrtShell();
505 0 : SdrView *pSdrView = pSh->GetDrawView();
506 0 : SdrOutliner* pOutliner = ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrView->GetModel());
507 0 : uno::Reference< linguistic2::XSpellChecker1 > xSpell( ::GetSpellChecker() );
508 0 : if (pOutliner)
509 : {
510 0 : pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess()->getReferenceDevice(false));
511 0 : pOutliner->SetSpeller(xSpell);
512 0 : uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
513 0 : pOutliner->SetHyphenator( xHyphenator );
514 0 : pSh->SetCalcFieldValueHdl(pOutliner);
515 :
516 0 : sal_uInt32 nCntrl = pOutliner->GetControlWord();
517 0 : nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
518 0 : nCntrl |= EE_CNTRL_URLSFXEXECUTE;
519 :
520 0 : const SwViewOption *pOpt = pSh->GetViewOptions();
521 :
522 0 : if (SwViewOption::IsFieldShadings())
523 0 : nCntrl |= EE_CNTRL_MARKFIELDS;
524 : else
525 0 : nCntrl &= ~EE_CNTRL_MARKFIELDS;
526 :
527 0 : if (pOpt->IsOnlineSpell())
528 0 : nCntrl |= EE_CNTRL_ONLINESPELLING;
529 : else
530 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
531 :
532 0 : pOutliner->SetControlWord(nCntrl);
533 0 : const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
534 0 : pOutliner->SetDefaultLanguage(((const SvxLanguageItem&)rItem).GetLanguage());
535 :
536 0 : if( bIsNewObj )
537 : pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == nDrawSfxId ||
538 0 : SID_DRAW_CAPTION_VERTICAL == nDrawSfxId );
539 :
540 : // set default horizontal text direction at outliner
541 : EEHorizontalTextDirection aDefHoriTextDir =
542 0 : pSh->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
543 0 : pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
544 : }
545 :
546 : // To allow editing the referenced object from a SwDrawVirtObj here
547 : // the original needs to be fetched evenually. This ATM activates the
548 : // text edit mode for the original object.
549 0 : SdrObject* pToBeActivated = pObj;
550 :
551 : // Always the original object is edited. To allow the TextEdit to happen
552 : // where the VirtObj is positioned, on demand a occurring offset is set at
553 : // the TextEdit object. That offset is used for creating and managing the
554 : // OutlinerView.
555 0 : Point aNewTextEditOffset(0, 0);
556 :
557 0 : if(pObj->ISA(SwDrawVirtObj))
558 : {
559 0 : SwDrawVirtObj* pVirtObj = (SwDrawVirtObj*)pObj;
560 0 : pToBeActivated = &((SdrObject&)pVirtObj->GetReferencedObj());
561 0 : aNewTextEditOffset = pVirtObj->GetOffset();
562 : }
563 :
564 : // set in each case, thus it will be correct for all objects
565 0 : ((SdrTextObj*)pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
566 :
567 0 : sal_Bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, sal_True, pOutliner, 0, sal_False, sal_False, sal_False ));
568 :
569 : // #i7672#
570 : // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
571 : // sets the background color, an own background color needs to be set
572 : // after TextEditing was started. This is now done here.
573 0 : if(bRet)
574 : {
575 0 : OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
576 :
577 0 : if(pView)
578 : {
579 0 : Color aBackground(pSh->GetShapeBackgrd());
580 0 : pView->SetBackgroundColor(aBackground);
581 : }
582 :
583 : // editing should start at the end of text, spell checking at the beginning ...
584 0 : ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
585 0 : if (bSetSelectionToStart)
586 0 : aNewSelection = ESelection();
587 0 : pView->SetSelection(aNewSelection);
588 : }
589 :
590 0 : return bRet;
591 : }
592 :
593 : /******************************************************************************
594 : * Beschreibung: Ist ein DrawTextObjekt selektiert?
595 : ******************************************************************************/
596 0 : sal_Bool SwView::IsTextTool() const
597 : {
598 : sal_uInt16 nId;
599 : sal_uInt32 nInvent;
600 0 : SdrView *pSdrView = GetWrtShell().GetDrawView();
601 : OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
602 :
603 0 : if (pSdrView->IsCreateMode())
604 0 : pSdrView->SetCreateMode(sal_False);
605 :
606 0 : pSdrView->TakeCurrentObj(nId,nInvent);
607 0 : return (nInvent==SdrInventor);
608 : }
609 :
610 260 : SdrView* SwView::GetDrawView() const
611 : {
612 260 : return GetWrtShell().GetDrawView();
613 : }
614 :
615 0 : sal_Bool SwView::IsBezierEditMode()
616 : {
617 0 : return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
618 : }
619 :
620 0 : sal_Bool SwView::IsFormMode() const
621 : {
622 0 : if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
623 : {
624 0 : return (GetDrawFuncPtr()->IsInsertForm());
625 : }
626 :
627 0 : return AreOnlyFormsSelected();
628 : }
629 :
630 63 : void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
631 : {
632 63 : delete pDrawActual;
633 63 : pDrawActual = pFuncPtr;
634 63 : }
635 :
636 0 : void SwView::SetSelDrawSlot()
637 : {
638 0 : nDrawSfxId = SID_OBJECT_SELECT;
639 0 : sDrawCustom.Erase();
640 0 : }
641 :
642 0 : sal_Bool SwView::AreOnlyFormsSelected() const
643 : {
644 0 : if ( GetWrtShell().IsFrmSelected() )
645 0 : return sal_False;
646 :
647 0 : sal_Bool bForm = sal_True;
648 :
649 0 : SdrView* pSdrView = GetWrtShell().GetDrawView();
650 :
651 0 : const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
652 0 : sal_uInt32 nCount = rMarkList.GetMarkCount();
653 :
654 0 : if (nCount)
655 : {
656 0 : for (sal_uInt32 i = 0; i < nCount; i++)
657 : {
658 : // Sind ausser Controls noch normale Draw-Objekte selektiert?
659 0 : SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
660 :
661 0 : if (!HasOnlyObj(pSdrObj, FmFormInventor))
662 : {
663 0 : bForm = sal_False;
664 0 : break;
665 : }
666 : }
667 : }
668 : else
669 0 : bForm = sal_False;
670 :
671 0 : return bForm;
672 : }
673 :
674 0 : sal_Bool SwView::HasDrwObj(SdrObject *pSdrObj) const
675 : {
676 0 : sal_Bool bRet = sal_False;
677 :
678 0 : if (pSdrObj->IsGroupObject())
679 : {
680 0 : SdrObjList* pList = pSdrObj->GetSubList();
681 0 : sal_uInt32 nCnt = pList->GetObjCount();
682 :
683 0 : for (sal_uInt32 i = 0; i < nCnt; i++)
684 0 : if ((bRet = HasDrwObj(pList->GetObj(i))) == sal_True)
685 0 : break;
686 : }
687 0 : else if (SdrInventor == pSdrObj->GetObjInventor() || pSdrObj->Is3DObj())
688 0 : return sal_True;
689 :
690 0 : return bRet;
691 : }
692 :
693 0 : sal_Bool SwView::HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const
694 : {
695 0 : sal_Bool bRet = sal_False;
696 :
697 0 : if (pSdrObj->IsGroupObject())
698 : {
699 0 : SdrObjList* pList = pSdrObj->GetSubList();
700 0 : sal_uInt32 nCnt = pList->GetObjCount();
701 :
702 0 : for (sal_uInt32 i = 0; i < nCnt; i++)
703 0 : if ((bRet = HasOnlyObj(pList->GetObj(i), eObjInventor)) == sal_False)
704 0 : break;
705 : }
706 0 : else if (eObjInventor == pSdrObj->GetObjInventor())
707 0 : return sal_True;
708 :
709 0 : return bRet;
710 : }
711 :
712 : //#i87414# mod
713 0 : IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
714 : {
715 0 : if (pInfo->nCommand == SPELLCMD_STARTSPELLDLG)
716 0 : GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
717 0 : return 0;
718 : }
719 :
720 0 : sal_Bool SwView::ExecDrwTxtSpellPopup(const Point& rPt)
721 : {
722 0 : sal_Bool bRet = sal_False;
723 0 : SdrView *pSdrView = pWrtShell->GetDrawView();
724 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
725 0 : Point aPos( GetEditWin().LogicToPixel( rPt ) );
726 :
727 0 : if (pOLV->IsWrongSpelledWordAtPos( aPos ))
728 : {
729 0 : bRet = sal_True;
730 0 : Link aLink = LINK(this, SwView, OnlineSpellCallback);
731 0 : pOLV->ExecuteSpellPopup( aPos,&aLink );
732 : }
733 0 : return bRet;
734 : }
735 :
736 0 : sal_Bool SwView::IsDrawTextHyphenate()
737 : {
738 0 : SdrView *pSdrView = pWrtShell->GetDrawView();
739 0 : sal_Bool bHyphenate = sal_False;
740 :
741 0 : SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
742 0 : EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
743 0 : if( pSdrView->GetAttributes( aNewAttr ) &&
744 0 : aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
745 0 : bHyphenate = ((const SfxBoolItem&)aNewAttr.Get( EE_PARA_HYPHENATE )).
746 0 : GetValue();
747 :
748 0 : return bHyphenate;
749 : }
750 :
751 0 : void SwView::HyphenateDrawText()
752 : {
753 0 : SdrView *pSdrView = pWrtShell->GetDrawView();
754 0 : sal_Bool bHyphenate = IsDrawTextHyphenate();
755 :
756 0 : SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
757 0 : aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
758 0 : pSdrView->SetAttributes( aSet );
759 0 : GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG);
760 0 : }
761 :
762 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|