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