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 "fuconstr.hxx"
31 : :
32 : : #include <svx/svxids.hrc>
33 : : #include <svl/aeitem.hxx>
34 : : #include <svx/svdpagv.hxx>
35 : : #include <svx/xdef.hxx>
36 : : #include <svx/xfillit0.hxx>
37 : : #include <sfx2/dispatch.hxx>
38 : : #include <sfx2/viewfrm.hxx>
39 : :
40 : : #include "app.hrc"
41 : : #include "glob.hrc"
42 : : #include "fudraw.hxx"
43 : : #include "View.hxx"
44 : : #include "Window.hxx"
45 : : #include "ViewShell.hxx"
46 : : #include "drawdoc.hxx"
47 : : #include "FrameView.hxx"
48 : : #include "sdpage.hxx"
49 : : #include "sdresid.hxx"
50 : : #include "stlpool.hxx"
51 : : #include <svx/globl3d.hxx>
52 : :
53 : : namespace sd {
54 : :
55 [ # # ][ # # ]: 0 : TYPEINIT1( FuConstruct, FuDraw );
56 : :
57 : : /*************************************************************************
58 : : |*
59 : : |* Konstruktor
60 : : |*
61 : : \************************************************************************/
62 : :
63 : 0 : FuConstruct::FuConstruct (
64 : : ViewShell* pViewSh,
65 : : ::sd::Window* pWin,
66 : : ::sd::View* pView,
67 : : SdDrawDocument* pDoc,
68 : : SfxRequest& rReq)
69 : : : FuDraw(pViewSh, pWin, pView, pDoc, rReq),
70 : 0 : bSelectionChanged(sal_False)
71 : : {
72 : 0 : }
73 : :
74 : 0 : void FuConstruct::DoExecute( SfxRequest& rReq )
75 : : {
76 : 0 : FuDraw::DoExecute( rReq );
77 : 0 : }
78 : :
79 : : /*************************************************************************
80 : : |*
81 : : |* MouseButtonDown-event
82 : : |*
83 : : \************************************************************************/
84 : :
85 : 0 : sal_Bool FuConstruct::MouseButtonDown(const MouseEvent& rMEvt)
86 : : {
87 : 0 : sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
88 : :
89 : 0 : bMBDown = sal_True;
90 : 0 : bSelectionChanged = sal_False;
91 : :
92 [ # # ]: 0 : if ( mpView->IsAction() )
93 : : {
94 : 0 : return sal_True;
95 : : }
96 : :
97 : 0 : bFirstMouseMove = sal_True;
98 : 0 : aDragTimer.Start();
99 : :
100 : 0 : aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
101 [ # # ]: 0 : sal_uInt16 nHitLog = sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width());
102 : :
103 [ # # ][ # # ]: 0 : if (rMEvt.IsLeft() && mpView->IsExtendedMouseEventDispatcherEnabled())
[ # # ]
104 : : {
105 : 0 : mpWindow->CaptureMouse();
106 : :
107 : 0 : SdrHdl* pHdl = mpView->PickHandle(aMDPos);
108 : :
109 [ # # ][ # # ]: 0 : if ( pHdl != NULL || mpView->IsMarkedHit(aMDPos, nHitLog) )
[ # # ]
110 : : {
111 [ # # ]: 0 : sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
112 : 0 : mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
113 : 0 : bReturn = sal_True;
114 : : }
115 [ # # ]: 0 : else if ( mpView->AreObjectsMarked() )
116 : : {
117 : 0 : mpView->UnmarkAll();
118 : 0 : bReturn = sal_True;
119 : : }
120 : : }
121 : :
122 : 0 : return bReturn;
123 : : }
124 : :
125 : : /*************************************************************************
126 : : |*
127 : : |* MouseMove-event
128 : : |*
129 : : \************************************************************************/
130 : :
131 : 0 : sal_Bool FuConstruct::MouseMove(const MouseEvent& rMEvt)
132 : : {
133 [ # # ]: 0 : FuDraw::MouseMove(rMEvt);
134 : :
135 [ # # ]: 0 : if (aDragTimer.IsActive() )
136 : : {
137 [ # # ]: 0 : if( bFirstMouseMove )
138 : 0 : bFirstMouseMove = sal_False;
139 : : else
140 [ # # ]: 0 : aDragTimer.Stop();
141 : : }
142 : :
143 : 0 : Point aPix(rMEvt.GetPosPixel());
144 [ # # ]: 0 : Point aPnt( mpWindow->PixelToLogic(aPix) );
145 : :
146 [ # # ][ # # ]: 0 : if ( mpView->IsAction() )
147 : : {
148 [ # # ]: 0 : ForceScroll(aPix);
149 [ # # ]: 0 : mpView->MovAction(aPnt);
150 : : }
151 : :
152 : 0 : return sal_True;
153 : : }
154 : :
155 : : /*************************************************************************
156 : : |*
157 : : |* MouseButtonUp-event
158 : : |*
159 : : \************************************************************************/
160 : :
161 : 0 : sal_Bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
162 : : {
163 : 0 : sal_Bool bReturn = sal_True;
164 : :
165 [ # # ]: 0 : if (aDragTimer.IsActive() )
166 : : {
167 [ # # ]: 0 : aDragTimer.Stop();
168 : 0 : bIsInDragMode = sal_False;
169 : : }
170 : :
171 [ # # ]: 0 : FuDraw::MouseButtonUp(rMEvt);
172 : :
173 [ # # ]: 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
174 : :
175 [ # # ][ # # ]: 0 : if ( mpView && mpView->IsDragObj() )
[ # # ]
176 : : {
177 [ # # ]: 0 : FrameView* pFrameView = mpViewShell->GetFrameView();
178 [ # # ][ # # ]: 0 : sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
179 : :
180 [ # # ]: 0 : if (bDragWithCopy)
181 : : {
182 [ # # ]: 0 : bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
183 : : }
184 : :
185 : 0 : mpView->SetDragWithCopy(bDragWithCopy);
186 [ # # ]: 0 : mpView->EndDragObj( mpView->IsDragWithCopy() );
187 : : }
188 [ # # ][ # # ]: 0 : else if ( mpView && mpView->IsMarkObj() )
[ # # ]
189 : : {
190 [ # # ]: 0 : mpView->EndMarkObj();
191 : : }
192 : : else
193 : : {
194 : 0 : bReturn = sal_False;
195 : : }
196 : :
197 [ # # ][ # # ]: 0 : if ( mpView && !mpView->IsAction() )
[ # # ][ # # ]
198 : : {
199 [ # # ]: 0 : mpWindow->ReleaseMouse();
200 [ # # ]: 0 : sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
201 : :
202 [ # # ]: 0 : if ( !mpView->AreObjectsMarked() )
203 : : {
204 : : SdrObject* pObj;
205 : : SdrPageView* pPV;
206 [ # # ]: 0 : sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
207 : :
208 [ # # ][ # # ]: 0 : if (!mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV))
209 : : {
210 [ # # ]: 0 : mpView->MarkObj(aPnt, nHitLog);
211 : : }
212 : :
213 [ # # ][ # # ]: 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
214 : : }
215 [ # # ][ # # ]: 0 : else if (rMEvt.IsLeft() && !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() &&
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
216 : 0 : !bSelectionChanged &&
217 : 0 : Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
218 : 0 : Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
219 : : {
220 : : /**************************************************************
221 : : * Toggle zw. Selektion und Rotation
222 : : **************************************************************/
223 : 0 : SdrObject* pSingleObj = NULL;
224 : 0 : sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
225 : :
226 [ # # ]: 0 : if (nMarkCount==1)
227 : : {
228 [ # # ][ # # ]: 0 : pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
229 : : }
230 : :
231 [ # # ][ # # ]: 0 : if (mpView->GetDragMode() == SDRDRAG_MOVE && mpView->IsRotateAllowed() &&
[ # # # # ]
[ # # ][ # # ]
[ # # ]
232 [ # # ]: 0 : (mpViewShell->GetFrameView()->IsClickChangeRotation() ||
233 [ # # ]: 0 : (pSingleObj && pSingleObj->GetObjInventor()==E3dInventor)))
234 : : {
235 [ # # ]: 0 : mpView->SetDragMode(SDRDRAG_ROTATE);
236 : : }
237 : : else
238 : : {
239 [ # # ]: 0 : mpView->SetDragMode(SDRDRAG_MOVE);
240 : : }
241 : : }
242 : : }
243 : :
244 : 0 : sal_uInt16 nClicks = rMEvt.GetClicks();
245 : :
246 [ # # ][ # # : 0 : if (nClicks == 2 && rMEvt.IsLeft() && bMBDown &&
# # # # #
# ][ # # ]
[ # # ]
247 : 0 : !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift() )
248 : : {
249 [ # # ]: 0 : DoubleClick(rMEvt);
250 : : }
251 : 0 : bMBDown = sal_False;
252 : :
253 : 0 : return bReturn;
254 : : }
255 : :
256 : : /*************************************************************************
257 : : |*
258 : : |* Tastaturereignisse bearbeiten
259 : : |*
260 : : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
261 : : |* sal_False.
262 : : |*
263 : : \************************************************************************/
264 : :
265 : 0 : sal_Bool FuConstruct::KeyInput(const KeyEvent& rKEvt)
266 : : {
267 : 0 : sal_Bool bReturn = sal_False;
268 : :
269 [ # # ]: 0 : if ( !bReturn )
270 : 0 : bReturn = FuDraw::KeyInput(rKEvt);
271 : :
272 : 0 : return(bReturn);
273 : : }
274 : :
275 : : /*************************************************************************
276 : : |*
277 : : |* Function aktivieren
278 : : |*
279 : : \************************************************************************/
280 : :
281 : 0 : void FuConstruct::Activate()
282 : : {
283 : 0 : mpView->SetEditMode(SDREDITMODE_CREATE);
284 : 0 : FuDraw::Activate();
285 : 0 : }
286 : :
287 : : /*************************************************************************
288 : : |*
289 : : |* Function deaktivieren
290 : : |*
291 : : \************************************************************************/
292 : :
293 : 0 : void FuConstruct::Deactivate()
294 : : {
295 : 0 : FuDraw::Deactivate();
296 : 0 : mpView->SetEditMode(SDREDITMODE_EDIT);
297 : 0 : }
298 : :
299 : : /*************************************************************************
300 : : |*
301 : : |* StyleSheet fuer das zu erzeugende Objekt setzen
302 : : |*
303 : : \************************************************************************/
304 : :
305 : 0 : void FuConstruct::SetStyleSheet(SfxItemSet& rAttr, SdrObject* pObj)
306 : : {
307 : : sal_Bool bUseFillStyle, bUseNoFillStyle;
308 : 0 : bUseFillStyle = bUseNoFillStyle = sal_False;
309 : :
310 [ # # # ]: 0 : switch( nSlotId )
311 : : {
312 : : case SID_DRAW_RECT:
313 : : case SID_DRAW_RECT_ROUND:
314 : : case SID_DRAW_SQUARE:
315 : : case SID_DRAW_SQUARE_ROUND:
316 : : case SID_DRAW_ELLIPSE:
317 : : case SID_DRAW_PIE:
318 : : case SID_DRAW_ELLIPSECUT:
319 : : case SID_DRAW_CIRCLE:
320 : : case SID_DRAW_CIRCLEPIE:
321 : : case SID_DRAW_CIRCLECUT:
322 : : case SID_DRAW_POLYGON:
323 : : case SID_DRAW_XPOLYGON:
324 : : case SID_DRAW_FREELINE:
325 : : case SID_DRAW_BEZIER_FILL:
326 : : {
327 : 0 : bUseFillStyle = sal_True;
328 : 0 : break;
329 : : }
330 : : case SID_DRAW_RECT_NOFILL:
331 : : case SID_DRAW_RECT_ROUND_NOFILL:
332 : : case SID_DRAW_SQUARE_NOFILL:
333 : : case SID_DRAW_SQUARE_ROUND_NOFILL:
334 : : case SID_DRAW_ELLIPSE_NOFILL:
335 : : case SID_DRAW_PIE_NOFILL:
336 : : case SID_DRAW_ELLIPSECUT_NOFILL:
337 : : case SID_DRAW_CIRCLE_NOFILL:
338 : : case SID_DRAW_CIRCLEPIE_NOFILL:
339 : : case SID_DRAW_CIRCLECUT_NOFILL:
340 : : case SID_DRAW_POLYGON_NOFILL:
341 : : case SID_DRAW_XPOLYGON_NOFILL:
342 : : case SID_DRAW_FREELINE_NOFILL:
343 : : case SID_DRAW_LINE:
344 : : case SID_DRAW_XLINE:
345 : : case SID_CONNECTOR_ARROW_START:
346 : : case SID_CONNECTOR_ARROW_END:
347 : : case SID_CONNECTOR_ARROWS:
348 : : case SID_CONNECTOR_CIRCLE_START:
349 : : case SID_CONNECTOR_CIRCLE_END:
350 : : case SID_CONNECTOR_CIRCLES:
351 : : case SID_CONNECTOR_LINE:
352 : : case SID_CONNECTOR_LINE_ARROW_START:
353 : : case SID_CONNECTOR_LINE_ARROW_END:
354 : : case SID_CONNECTOR_LINE_ARROWS:
355 : : case SID_CONNECTOR_LINE_CIRCLE_START:
356 : : case SID_CONNECTOR_LINE_CIRCLE_END:
357 : : case SID_CONNECTOR_LINE_CIRCLES:
358 : : case SID_CONNECTOR_CURVE:
359 : : case SID_CONNECTOR_CURVE_ARROW_START:
360 : : case SID_CONNECTOR_CURVE_ARROW_END:
361 : : case SID_CONNECTOR_CURVE_ARROWS:
362 : : case SID_CONNECTOR_CURVE_CIRCLE_START:
363 : : case SID_CONNECTOR_CURVE_CIRCLE_END:
364 : : case SID_CONNECTOR_CURVE_CIRCLES:
365 : : case SID_CONNECTOR_LINES:
366 : : case SID_CONNECTOR_LINES_ARROW_START:
367 : : case SID_CONNECTOR_LINES_ARROW_END:
368 : : case SID_CONNECTOR_LINES_ARROWS:
369 : : case SID_CONNECTOR_LINES_CIRCLE_START:
370 : : case SID_CONNECTOR_LINES_CIRCLE_END:
371 : : case SID_CONNECTOR_LINES_CIRCLES:
372 : : case SID_DRAW_BEZIER_NOFILL:
373 : : case SID_LINE_ARROW_END:
374 : : {
375 : 0 : bUseNoFillStyle = sal_True;
376 : 0 : break;
377 : : }
378 : : }
379 : 0 : SetStyleSheet( rAttr, pObj, bUseFillStyle, bUseNoFillStyle );
380 : 0 : }
381 : :
382 : 0 : void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
383 : : const sal_Bool bForceFillStyle, const sal_Bool bForceNoFillStyle )
384 : : {
385 : 0 : SdPage* pPage = (SdPage*)mpView->GetSdrPageView()->GetPage();
386 [ # # # # ]: 0 : if ( pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD &&
[ # # ][ # # ]
387 : 0 : mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
388 : : {
389 : : /**********************************************
390 : : * Objects was created on the slide master page
391 : : ***********************************************/
392 [ # # ]: 0 : String aName( pPage->GetLayoutName() );
393 [ # # ]: 0 : String aSep = rtl::OUString(SD_LT_SEPARATOR);
394 [ # # ]: 0 : sal_uInt16 n = aName.Search(aSep);
395 : 0 : n = n + aSep.Len();
396 [ # # ]: 0 : aName.Erase(n);
397 [ # # ][ # # ]: 0 : aName.Append( String ( SdResId( STR_LAYOUT_BACKGROUNDOBJECTS ) ) );
[ # # ][ # # ]
398 : 0 : SfxStyleSheet* pSheet = (SfxStyleSheet*)pPage->GetModel()->
399 [ # # ][ # # ]: 0 : GetStyleSheetPool()->
400 [ # # ]: 0 : Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
401 : : DBG_ASSERT(pSheet, "Objektvorlage nicht gefunden");
402 [ # # ]: 0 : if (pSheet)
403 : : {
404 : : // applying style sheet for background objects
405 [ # # ]: 0 : pObj->SetStyleSheet(pSheet, sal_False);
406 [ # # ]: 0 : SfxItemSet& rSet = pSheet->GetItemSet();
407 [ # # ]: 0 : const XFillStyleItem& rFillStyle = (const XFillStyleItem&)rSet.Get(XATTR_FILLSTYLE);
408 [ # # ]: 0 : if ( bForceFillStyle )
409 : : {
410 [ # # ]: 0 : if (rFillStyle.GetValue() == XFILL_NONE)
411 [ # # ][ # # ]: 0 : rAttr.Put(XFillStyleItem(XFILL_SOLID));
[ # # ]
412 : : }
413 [ # # ]: 0 : else if ( bForceNoFillStyle )
414 : : {
415 [ # # ]: 0 : if (rFillStyle.GetValue() != XFILL_NONE)
416 [ # # ][ # # ]: 0 : rAttr.Put(XFillStyleItem(XFILL_NONE));
[ # # ]
417 : : }
418 [ # # ][ # # ]: 0 : }
419 : : }
420 : : else
421 : : {
422 : : /***********************************
423 : : * object was created on normal page
424 : : ************************************/
425 [ # # ]: 0 : if ( bForceNoFillStyle )
426 : : {
427 [ # # ][ # # ]: 0 : String aName(SdResId(STR_POOLSHEET_OBJWITHOUTFILL));
428 : 0 : SfxStyleSheet* pSheet = (SfxStyleSheet*)pPage->GetModel()->
429 [ # # ][ # # ]: 0 : GetStyleSheetPool()->
430 [ # # ]: 0 : Find(aName, SD_STYLE_FAMILY_GRAPHICS);
431 : : DBG_ASSERT(pSheet, "Objektvorlage nicht gefunden");
432 [ # # ]: 0 : if (pSheet)
433 : : {
434 [ # # ]: 0 : pObj->SetStyleSheet(pSheet, sal_False);
435 [ # # ][ # # ]: 0 : SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
436 [ # # ][ # # ]: 0 : aAttr.Put(pSheet->GetItemSet().Get(XATTR_FILLSTYLE));
[ # # ]
437 [ # # ][ # # ]: 0 : pObj->SetMergedItemSet(aAttr);
438 : : }
439 : : else
440 : : {
441 [ # # ][ # # ]: 0 : SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
442 [ # # ][ # # ]: 0 : rAttr.Put(XFillStyleItem(XFILL_NONE));
[ # # ]
443 [ # # ][ # # ]: 0 : pObj->SetMergedItemSet(aAttr);
444 [ # # ]: 0 : }
445 : : }
446 : : }
447 : 0 : }
448 : :
449 : : } // end of namespace sd
450 : :
451 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|