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