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 <svx/svdedtv.hxx>
31 : : #include <math.h>
32 : :
33 : : #ifndef _MATH_H
34 : : #define _MATH_H
35 : : #endif
36 : : #include <tools/bigint.hxx>
37 : : #include <svl/itemiter.hxx>
38 : : #include <vcl/msgbox.hxx>
39 : : #include <svx/rectenum.hxx>
40 : : #include <svx/svxids.hrc> // for SID_ATTR_TRANSFORM_...
41 : : #include <svx/svdattr.hxx> // for Get/SetGeoAttr
42 : : #include "svx/svditext.hxx"
43 : : #include "svx/svditer.hxx"
44 : : #include <svx/svdtrans.hxx>
45 : : #include <svx/svdundo.hxx>
46 : : #include <svx/svdpage.hxx>
47 : : #include <svx/svdpagv.hxx>
48 : : #include <svx/svdlayer.hxx> // for MergeNotPersistAttr
49 : : #include <svx/svdattrx.hxx> // for MergeNotPersistAttr
50 : : #include <svx/svdetc.hxx> // for SearchOutlinerItems
51 : : #include <svx/svdopath.hxx> // for Crook
52 : : #include "svx/svdstr.hrc" // names taken from the resource
53 : : #include "svx/svdglob.hxx" // StringCache
54 : : #include <editeng/eeitem.hxx>
55 : : #include <svl/aeitem.hxx>
56 : : #include <svl/whiter.hxx>
57 : : #include <svx/sdr/contact/objectcontact.hxx>
58 : : #include <svx/sdr/contact/viewcontact.hxx>
59 : : #include <svx/e3dsceneupdater.hxx>
60 : : #include <svx/obj3d.hxx>
61 : :
62 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
63 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
64 : : // EditView
65 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
66 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
67 : :
68 : 0 : void SdrEditView::SetMarkedObjRect(const Rectangle& rRect, sal_Bool bCopy)
69 : : {
70 : : DBG_ASSERT(!rRect.IsEmpty(),"SetMarkedObjRect() with an empty Rect does not make sense.");
71 [ # # ][ # # ]: 0 : if (rRect.IsEmpty()) return;
72 : 0 : sal_uIntPtr nAnz=GetMarkedObjectCount();
73 [ # # ]: 0 : if (nAnz==0) return;
74 [ # # ]: 0 : Rectangle aR0(GetMarkedObjRect());
75 : : DBG_ASSERT(!aR0.IsEmpty(),"SetMarkedObjRect(): GetMarkedObjRect() is empty.");
76 [ # # ][ # # ]: 0 : if (aR0.IsEmpty()) return;
77 : 0 : long x0=aR0.Left();
78 : 0 : long y0=aR0.Top();
79 : 0 : long w0=aR0.Right()-x0;
80 : 0 : long h0=aR0.Bottom()-y0;
81 : 0 : long x1=rRect.Left();
82 : 0 : long y1=rRect.Top();
83 : 0 : long w1=rRect.Right()-x1;
84 : 0 : long h1=rRect.Bottom()-y1;
85 [ # # ]: 0 : XubString aStr;
86 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditPosSize,aStr);
87 [ # # ]: 0 : if (bCopy)
88 [ # # ][ # # ]: 0 : aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ]
89 : :
90 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
91 [ # # ]: 0 : if( bUndo )
92 [ # # ]: 0 : BegUndo(aStr);
93 : :
94 [ # # ]: 0 : if (bCopy)
95 [ # # ]: 0 : CopyMarkedObj();
96 : :
97 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nAnz; nm++)
98 : : {
99 [ # # ]: 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
100 [ # # ]: 0 : SdrObject* pO=pM->GetMarkedSdrObj();
101 [ # # ]: 0 : if( bUndo )
102 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
103 : :
104 [ # # ]: 0 : Rectangle aR1(pO->GetSnapRect());
105 [ # # ][ # # ]: 0 : if (!aR1.IsEmpty())
106 : : {
107 [ # # ][ # # ]: 0 : if (aR1==aR0)
108 : : {
109 : 0 : aR1=rRect;
110 : : }
111 : : else
112 : : { // transform aR1 to aR0 after rRect
113 [ # # ]: 0 : aR1.Move(-x0,-y0);
114 [ # # ]: 0 : BigInt l(aR1.Left());
115 [ # # ]: 0 : BigInt r(aR1.Right());
116 [ # # ]: 0 : BigInt t(aR1.Top());
117 [ # # ]: 0 : BigInt b(aR1.Bottom());
118 [ # # ]: 0 : if (w0!=0) {
119 [ # # ][ # # ]: 0 : l*=w1; l/=w0;
[ # # ][ # # ]
120 [ # # ][ # # ]: 0 : r*=w1; r/=w0;
[ # # ][ # # ]
121 : : } else {
122 [ # # ][ # # ]: 0 : l=0; r=w1;
123 : : }
124 [ # # ]: 0 : if (h0!=0) {
125 [ # # ][ # # ]: 0 : t*=h1; t/=h0;
[ # # ][ # # ]
126 [ # # ][ # # ]: 0 : b*=h1; b/=h0;
[ # # ][ # # ]
127 : : } else {
128 [ # # ][ # # ]: 0 : t=0; b=h1;
129 : : }
130 [ # # ]: 0 : aR1.Left ()=long(l);
131 [ # # ]: 0 : aR1.Right ()=long(r);
132 [ # # ]: 0 : aR1.Top ()=long(t);
133 [ # # ]: 0 : aR1.Bottom()=long(b);
134 [ # # ]: 0 : aR1.Move(x1,y1);
135 : : }
136 [ # # ]: 0 : pO->SetSnapRect(aR1);
137 : : } else {
138 : : OSL_FAIL("SetMarkedObjRect(): pObj->GetSnapRect() returns empty Rect");
139 : : }
140 : : }
141 [ # # ]: 0 : if( bUndo )
142 [ # # ][ # # ]: 0 : EndUndo();
143 : : }
144 : :
145 : 68 : std::vector< SdrUndoAction* > SdrEditView::CreateConnectorUndo( SdrObject& rO )
146 : : {
147 : 68 : std::vector< SdrUndoAction* > vUndoActions;
148 : :
149 [ - + ][ + - ]: 68 : if ( rO.GetBroadcaster() )
150 : : {
151 [ # # ]: 0 : const SdrPage* pPage = rO.GetPage();
152 [ # # ]: 0 : if ( pPage )
153 : : {
154 [ # # ]: 0 : SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
155 [ # # ]: 0 : while( aIter.IsMore() )
156 : : {
157 [ # # ]: 0 : SdrObject* pPartObj = aIter.Next();
158 [ # # ][ # # ]: 0 : if ( pPartObj->ISA( SdrEdgeObj ) )
[ # # ]
159 : : {
160 [ # # ][ # # ]: 0 : if ( ( pPartObj->GetConnectedNode( sal_False ) == &rO ) ||
[ # # ][ # # ]
161 [ # # ]: 0 : ( pPartObj->GetConnectedNode( sal_True ) == &rO ) )
162 : : {
163 [ # # ][ # # ]: 0 : vUndoActions.push_back( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pPartObj ) );
[ # # ]
164 : : }
165 : : }
166 : 0 : }
167 : : }
168 : : }
169 : 68 : return vUndoActions;
170 : : }
171 : :
172 : 68 : void SdrEditView::AddUndoActions( std::vector< SdrUndoAction* >& rUndoActions )
173 : : {
174 : 68 : std::vector< SdrUndoAction* >::iterator aUndoActionIter( rUndoActions.begin() );
175 [ + - ][ - + ]: 68 : while( aUndoActionIter != rUndoActions.end() )
176 [ # # ][ # # ]: 0 : AddUndo( *aUndoActionIter++ );
177 : 68 : }
178 : :
179 : 0 : void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy)
180 : : {
181 : 0 : const bool bUndo = IsUndoEnabled();
182 : :
183 [ # # ]: 0 : if( bUndo )
184 : : {
185 [ # # ]: 0 : XubString aStr(ImpGetResStr(STR_EditMove));
186 [ # # ]: 0 : if (bCopy)
187 [ # # ][ # # ]: 0 : aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ]
188 : : // meeds its own UndoGroup because of its parameters
189 [ # # ][ # # ]: 0 : BegUndo(aStr,GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVE);
[ # # ][ # # ]
190 : : }
191 : :
192 [ # # ]: 0 : if (bCopy)
193 : 0 : CopyMarkedObj();
194 : :
195 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
196 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
197 : : {
198 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
199 : 0 : SdrObject* pO=pM->GetMarkedSdrObj();
200 [ # # ]: 0 : if( bUndo )
201 : : {
202 [ # # ]: 0 : std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
203 [ # # ]: 0 : AddUndoActions( vConnectorUndoActions );
204 [ # # ][ # # ]: 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,rSiz));
[ # # ]
205 : : }
206 : 0 : pO->Move(rSiz);
207 : : }
208 : :
209 [ # # ]: 0 : if( bUndo )
210 : 0 : EndUndo();
211 : 0 : }
212 : :
213 : 0 : void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
214 : : {
215 : 0 : const bool bUndo = IsUndoEnabled();
216 [ # # ]: 0 : if( bUndo )
217 : : {
218 [ # # ]: 0 : XubString aStr;
219 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditResize,aStr);
220 [ # # ]: 0 : if (bCopy)
221 [ # # ][ # # ]: 0 : aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ]
222 [ # # ][ # # ]: 0 : BegUndo(aStr);
223 : : }
224 : :
225 [ # # ]: 0 : if (bCopy)
226 : 0 : CopyMarkedObj();
227 : :
228 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
229 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
230 : : {
231 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
232 : 0 : SdrObject* pO=pM->GetMarkedSdrObj();
233 [ # # ]: 0 : if( bUndo )
234 : : {
235 [ # # ]: 0 : std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
236 [ # # ]: 0 : AddUndoActions( vConnectorUndoActions );
237 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
238 : : }
239 : 0 : pO->Resize(rRef,xFact,yFact);
240 : : }
241 : :
242 [ # # ]: 0 : if( bUndo )
243 : 0 : EndUndo();
244 : 0 : }
245 : :
246 : 0 : long SdrEditView::GetMarkedObjRotate() const
247 : : {
248 : 0 : sal_Bool b1st=sal_True;
249 : 0 : sal_Bool bOk=sal_True;
250 : 0 : long nWink=0;
251 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
252 [ # # ][ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz && bOk; nm++) {
[ # # ]
253 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
254 : 0 : SdrObject* pO=pM->GetMarkedSdrObj();
255 : 0 : long nWink2=pO->GetRotateAngle();
256 [ # # ]: 0 : if (b1st) nWink=nWink2;
257 [ # # ]: 0 : else if (nWink2!=nWink) bOk=sal_False;
258 : 0 : b1st=sal_False;
259 : : }
260 [ # # ]: 0 : if (!bOk) nWink=0;
261 : 0 : return nWink;
262 : : }
263 : :
264 : 0 : void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy)
265 : : {
266 : 0 : const bool bUndo = IsUndoEnabled();
267 [ # # ]: 0 : if( bUndo )
268 : : {
269 [ # # ]: 0 : XubString aStr;
270 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditRotate,aStr);
271 [ # # ][ # # ]: 0 : if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ][ # # ]
272 [ # # ][ # # ]: 0 : BegUndo(aStr);
273 : : }
274 : :
275 [ # # ]: 0 : if (bCopy)
276 : 0 : CopyMarkedObj();
277 : :
278 : 0 : double nSin=sin(nWink*nPi180);
279 : 0 : double nCos=cos(nWink*nPi180);
280 : 0 : const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
281 : :
282 [ # # ]: 0 : if(nMarkAnz)
283 : : {
284 [ # # ]: 0 : std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
285 : :
286 [ # # ]: 0 : for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
287 : : {
288 [ # # ]: 0 : SdrMark* pM = GetSdrMarkByIndex(nm);
289 [ # # ]: 0 : SdrObject* pO = pM->GetMarkedSdrObj();
290 : :
291 [ # # ]: 0 : if( bUndo )
292 : : {
293 : : // extra undo actions for changed connector which now may hold its laid out path (SJ)
294 [ # # ]: 0 : std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
295 [ # # ]: 0 : AddUndoActions( vConnectorUndoActions );
296 : :
297 [ # # ][ # # ]: 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
298 : : }
299 : :
300 : : // set up a scene updater if object is a 3d object
301 [ # # ][ # # ]: 0 : if(dynamic_cast< E3dObject* >(pO))
[ # # ]
302 : : {
303 [ # # ][ # # ]: 0 : aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pO));
[ # # ]
304 : : }
305 : :
306 [ # # ]: 0 : pO->Rotate(rRef,nWink,nSin,nCos);
307 : : }
308 : :
309 : : // fire scene updaters
310 [ # # ]: 0 : while(!aUpdaters.empty())
311 : : {
312 [ # # ][ # # ]: 0 : delete aUpdaters.back();
[ # # ]
313 [ # # ]: 0 : aUpdaters.pop_back();
314 : 0 : }
315 : : }
316 : :
317 [ # # ]: 0 : if( bUndo )
318 : 0 : EndUndo();
319 : 0 : }
320 : :
321 : 0 : void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy)
322 : : {
323 : 0 : const bool bUndo = IsUndoEnabled();
324 : :
325 [ # # ]: 0 : if( bUndo )
326 : : {
327 [ # # ]: 0 : XubString aStr;
328 : 0 : Point aDif(rRef2-rRef1);
329 [ # # ][ # # ]: 0 : if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr);
330 [ # # ][ # # ]: 0 : else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr);
331 [ # # ][ # # ]: 0 : else if (Abs(aDif.X())==Abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr);
332 [ # # ]: 0 : else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr);
333 [ # # ][ # # ]: 0 : if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ][ # # ]
334 [ # # ][ # # ]: 0 : BegUndo(aStr);
335 : : }
336 : :
337 [ # # ]: 0 : if (bCopy)
338 : 0 : CopyMarkedObj();
339 : :
340 : 0 : const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
341 : :
342 [ # # ]: 0 : if(nMarkAnz)
343 : : {
344 [ # # ]: 0 : std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
345 : :
346 [ # # ]: 0 : for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
347 : : {
348 [ # # ]: 0 : SdrMark* pM = GetSdrMarkByIndex(nm);
349 [ # # ]: 0 : SdrObject* pO = pM->GetMarkedSdrObj();
350 : :
351 [ # # ]: 0 : if( bUndo )
352 : : {
353 : : // extra undo actions for changed connector which now may hold its laid out path (SJ)
354 [ # # ]: 0 : std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
355 [ # # ]: 0 : AddUndoActions( vConnectorUndoActions );
356 : :
357 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
358 : : }
359 : :
360 : : // set up a scene updater if object is a 3d object
361 [ # # ][ # # ]: 0 : if(dynamic_cast< E3dObject* >(pO))
[ # # ]
362 : : {
363 [ # # ][ # # ]: 0 : aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pO));
[ # # ]
364 : : }
365 : :
366 [ # # ]: 0 : pO->Mirror(rRef1,rRef2);
367 : : }
368 : :
369 : : // fire scene updaters
370 [ # # ]: 0 : while(!aUpdaters.empty())
371 : : {
372 [ # # ][ # # ]: 0 : delete aUpdaters.back();
[ # # ]
373 [ # # ]: 0 : aUpdaters.pop_back();
374 : 0 : }
375 : : }
376 : :
377 [ # # ]: 0 : if( bUndo )
378 : 0 : EndUndo();
379 : 0 : }
380 : :
381 : 0 : void SdrEditView::MirrorMarkedObjHorizontal(sal_Bool bCopy)
382 : : {
383 [ # # ][ # # ]: 0 : Point aCenter(GetMarkedObjRect().Center());
384 : 0 : Point aPt2(aCenter);
385 : 0 : aPt2.Y()++;
386 [ # # ]: 0 : MirrorMarkedObj(aCenter,aPt2,bCopy);
387 : 0 : }
388 : :
389 : 0 : void SdrEditView::MirrorMarkedObjVertical(sal_Bool bCopy)
390 : : {
391 [ # # ][ # # ]: 0 : Point aCenter(GetMarkedObjRect().Center());
392 : 0 : Point aPt2(aCenter);
393 : 0 : aPt2.X()++;
394 [ # # ]: 0 : MirrorMarkedObj(aCenter,aPt2,bCopy);
395 : 0 : }
396 : :
397 : 0 : long SdrEditView::GetMarkedObjShear() const
398 : : {
399 : 0 : sal_Bool b1st=sal_True;
400 : 0 : sal_Bool bOk=sal_True;
401 : 0 : long nWink=0;
402 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
403 [ # # ][ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz && bOk; nm++) {
[ # # ]
404 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
405 : 0 : SdrObject* pO=pM->GetMarkedSdrObj();
406 : 0 : long nWink2=pO->GetShearAngle();
407 [ # # ]: 0 : if (b1st) nWink=nWink2;
408 [ # # ]: 0 : else if (nWink2!=nWink) bOk=sal_False;
409 : 0 : b1st=sal_False;
410 : : }
411 [ # # ]: 0 : if (nWink>SDRMAXSHEAR) nWink=SDRMAXSHEAR;
412 [ # # ]: 0 : if (nWink<-SDRMAXSHEAR) nWink=-SDRMAXSHEAR;
413 [ # # ]: 0 : if (!bOk) nWink=0;
414 : 0 : return nWink;
415 : : }
416 : :
417 : 0 : void SdrEditView::ShearMarkedObj(const Point& rRef, long nWink, bool bVShear, bool bCopy)
418 : : {
419 : 0 : const bool bUndo = IsUndoEnabled();
420 : :
421 [ # # ]: 0 : if( bUndo )
422 : : {
423 [ # # ]: 0 : XubString aStr;
424 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditShear,aStr);
425 [ # # ]: 0 : if (bCopy)
426 [ # # ][ # # ]: 0 : aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ]
427 [ # # ][ # # ]: 0 : BegUndo(aStr);
428 : : }
429 : :
430 [ # # ]: 0 : if (bCopy)
431 : 0 : CopyMarkedObj();
432 : :
433 : 0 : double nTan=tan(nWink*nPi180);
434 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
435 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
436 : : {
437 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
438 : 0 : SdrObject* pO=pM->GetMarkedSdrObj();
439 [ # # ]: 0 : if( bUndo )
440 : : {
441 [ # # ]: 0 : std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
442 [ # # ]: 0 : AddUndoActions( vConnectorUndoActions );
443 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
444 : : }
445 : 0 : pO->Shear(rRef,nWink,nTan,bVShear);
446 : : }
447 : :
448 [ # # ]: 0 : if( bUndo )
449 : 0 : EndUndo();
450 : 0 : }
451 : :
452 : 0 : void SdrEditView::ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad,
453 : : SdrCrookMode eMode, sal_Bool bVertical, sal_Bool bNoContortion, sal_Bool bRotate, const Rectangle& rMarkRect)
454 : : {
455 [ # # ][ # # ]: 0 : SdrPathObj* pPath=PTR_CAST(SdrPathObj,pO);
456 : 0 : sal_Bool bDone = sal_False;
457 : :
458 [ # # ][ # # ]: 0 : if(pPath!=NULL && !bNoContortion)
459 : : {
460 [ # # ]: 0 : XPolyPolygon aXPP(pPath->GetPathPoly());
461 [ # # # # ]: 0 : switch (eMode) {
462 [ # # ]: 0 : case SDRCROOK_ROTATE : CrookRotatePoly (aXPP,rRef,rRad,bVertical); break;
463 [ # # ]: 0 : case SDRCROOK_SLANT : CrookSlantPoly (aXPP,rRef,rRad,bVertical); break;
464 [ # # ]: 0 : case SDRCROOK_STRETCH: CrookStretchPoly(aXPP,rRef,rRad,bVertical,rMarkRect); break;
465 : : } // switch
466 [ # # ][ # # ]: 0 : pPath->SetPathPoly(aXPP.getB2DPolyPolygon());
[ # # ]
467 [ # # ]: 0 : bDone = sal_True;
468 : : }
469 : :
470 [ # # ][ # # ]: 0 : if(!bDone && !pPath && pO->IsPolyObj() && 0L != pO->GetPointCount())
[ # # ][ # # ]
[ # # ]
471 : : {
472 : : // for PolyObj's, but NOT for SdrPathObj's, e.g. the measurement object
473 [ # # ]: 0 : sal_uInt32 nPtAnz(pO->GetPointCount());
474 [ # # ]: 0 : XPolygon aXP((sal_uInt16)nPtAnz);
475 : : sal_uInt32 nPtNum;
476 : :
477 [ # # ]: 0 : for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
478 : : {
479 [ # # ]: 0 : Point aPt(pO->GetPoint(nPtNum));
480 [ # # ]: 0 : aXP[(sal_uInt16)nPtNum]=aPt;
481 : : }
482 : :
483 [ # # # # ]: 0 : switch (eMode)
484 : : {
485 [ # # ]: 0 : case SDRCROOK_ROTATE : CrookRotatePoly (aXP,rRef,rRad,bVertical); break;
486 [ # # ]: 0 : case SDRCROOK_SLANT : CrookSlantPoly (aXP,rRef,rRad,bVertical); break;
487 [ # # ]: 0 : case SDRCROOK_STRETCH: CrookStretchPoly(aXP,rRef,rRad,bVertical,rMarkRect); break;
488 : : }
489 : :
490 [ # # ]: 0 : for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
491 : : {
492 : : // broadcasting could be optimized here, but for the
493 : : // current two points of the measurement object, it's fine
494 [ # # ][ # # ]: 0 : pO->SetPoint(aXP[(sal_uInt16)nPtNum],nPtNum);
495 : : }
496 : :
497 [ # # ]: 0 : bDone = sal_True;
498 : : }
499 : :
500 [ # # ]: 0 : if(!bDone)
501 : : {
502 : : // for all others or if bNoContortion
503 [ # # ][ # # ]: 0 : Point aCtr0(pO->GetSnapRect().Center());
504 : 0 : Point aCtr1(aCtr0);
505 : 0 : sal_Bool bRotOk(sal_False);
506 : 0 : double nSin(0.0), nCos(1.0);
507 : 0 : double nWink(0.0);
508 : :
509 [ # # ][ # # ]: 0 : if(0 != rRad.X() && 0 != rRad.Y())
[ # # ]
510 : : {
511 : 0 : bRotOk = bRotate;
512 : :
513 [ # # # # ]: 0 : switch (eMode)
514 : : {
515 [ # # ]: 0 : case SDRCROOK_ROTATE : nWink=CrookRotateXPoint (aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical); bRotOk=bRotate; break;
516 [ # # ]: 0 : case SDRCROOK_SLANT : nWink=CrookSlantXPoint (aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical); break;
517 [ # # ]: 0 : case SDRCROOK_STRETCH: nWink=CrookStretchXPoint(aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical,rMarkRect); break;
518 : : }
519 : : }
520 : :
521 : 0 : aCtr1 -= aCtr0;
522 : :
523 [ # # ]: 0 : if(bRotOk)
524 [ # # ]: 0 : pO->Rotate(aCtr0, Round(nWink/nPi180), nSin, nCos);
525 : :
526 [ # # ]: 0 : pO->Move(Size(aCtr1.X(),aCtr1.Y()));
527 : : }
528 : 0 : }
529 : :
530 : 0 : void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode,
531 : : bool bVertical, bool bNoContortion, bool bCopy)
532 : : {
533 [ # # ]: 0 : Rectangle aMarkRect(GetMarkedObjRect());
534 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
535 : :
536 [ # # ][ # # ]: 0 : bool bRotate=bNoContortion && eMode==SDRCROOK_ROTATE && IsRotateAllowed(sal_False);
[ # # ][ # # ]
537 : :
538 [ # # ]: 0 : if( bUndo )
539 : : {
540 [ # # ]: 0 : XubString aStr;
541 [ # # ][ # # ]: 0 : ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr);
542 [ # # ]: 0 : if (bCopy)
543 [ # # ][ # # ]: 0 : aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ]
544 [ # # ][ # # ]: 0 : BegUndo(aStr);
545 : : }
546 : :
547 [ # # ]: 0 : if (bCopy)
548 [ # # ]: 0 : CopyMarkedObj();
549 : :
550 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
551 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
552 : : {
553 [ # # ]: 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
554 [ # # ]: 0 : SdrObject* pO=pM->GetMarkedSdrObj();
555 [ # # ]: 0 : if( bUndo )
556 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
557 : :
558 [ # # ]: 0 : const SdrObjList* pOL=pO->GetSubList();
559 [ # # ][ # # ]: 0 : if (bNoContortion || pOL==NULL) {
560 [ # # ]: 0 : ImpCrookObj(pO,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect);
561 : : } else {
562 [ # # ]: 0 : SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
563 [ # # ]: 0 : while (aIter.IsMore()) {
564 [ # # ]: 0 : SdrObject* pO1=aIter.Next();
565 [ # # ]: 0 : ImpCrookObj(pO1,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect);
566 : 0 : }
567 : : }
568 : : }
569 : :
570 [ # # ]: 0 : if( bUndo )
571 [ # # ]: 0 : EndUndo();
572 : 0 : }
573 : :
574 : 0 : void SdrEditView::ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPolygon& rDistortedRect, sal_Bool bNoContortion)
575 : : {
576 [ # # ][ # # ]: 0 : SdrPathObj* pPath = PTR_CAST(SdrPathObj, pO);
577 : :
578 [ # # ][ # # ]: 0 : if(!bNoContortion && pPath)
579 : : {
580 [ # # ]: 0 : XPolyPolygon aXPP(pPath->GetPathPoly());
581 [ # # ]: 0 : aXPP.Distort(rRef, rDistortedRect);
582 [ # # ][ # # ]: 0 : pPath->SetPathPoly(aXPP.getB2DPolyPolygon());
[ # # ][ # # ]
583 : : }
584 [ # # ]: 0 : else if(pO->IsPolyObj())
585 : : {
586 : : // e. g. for the measurement object
587 [ # # ]: 0 : sal_uInt32 nPtAnz(pO->GetPointCount());
588 [ # # ]: 0 : XPolygon aXP((sal_uInt16)nPtAnz);
589 : : sal_uInt32 nPtNum;
590 : :
591 [ # # ]: 0 : for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
592 : : {
593 [ # # ]: 0 : Point aPt(pO->GetPoint(nPtNum));
594 [ # # ]: 0 : aXP[(sal_uInt16)nPtNum]=aPt;
595 : : }
596 : :
597 [ # # ]: 0 : aXP.Distort(rRef, rDistortedRect);
598 : :
599 [ # # ]: 0 : for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
600 : : {
601 : : // broadcasting could be optimized here, but for the
602 : : // current two points of the measurement object it's fine
603 [ # # ][ # # ]: 0 : pO->SetPoint(aXP[(sal_uInt16)nPtNum],nPtNum);
604 [ # # ]: 0 : }
605 : : }
606 : 0 : }
607 : :
608 : 0 : void SdrEditView::DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy)
609 : : {
610 : 0 : const bool bUndo = IsUndoEnabled();
611 : :
612 [ # # ]: 0 : if( bUndo )
613 : : {
614 [ # # ]: 0 : XubString aStr;
615 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditDistort,aStr);
616 [ # # ]: 0 : if (bCopy)
617 [ # # ][ # # ]: 0 : aStr+=ImpGetResStr(STR_EditWithCopy);
[ # # ]
618 [ # # ][ # # ]: 0 : BegUndo(aStr);
619 : : }
620 : :
621 [ # # ]: 0 : if (bCopy)
622 : 0 : CopyMarkedObj();
623 : :
624 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
625 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
626 : : {
627 [ # # ]: 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
628 [ # # ]: 0 : SdrObject* pO=pM->GetMarkedSdrObj();
629 [ # # ]: 0 : if( bUndo )
630 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
[ # # ]
631 : :
632 : 0 : Rectangle aRefRect(rRef);
633 [ # # ]: 0 : XPolygon aRefPoly(rDistortedRect);
634 [ # # ]: 0 : const SdrObjList* pOL=pO->GetSubList();
635 [ # # ][ # # ]: 0 : if (bNoContortion || pOL==NULL) {
636 [ # # ]: 0 : ImpDistortObj(pO,aRefRect,aRefPoly,bNoContortion);
637 : : } else {
638 [ # # ]: 0 : SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
639 [ # # ]: 0 : while (aIter.IsMore()) {
640 [ # # ]: 0 : SdrObject* pO1=aIter.Next();
641 [ # # ]: 0 : ImpDistortObj(pO1,aRefRect,aRefPoly,bNoContortion);
642 : 0 : }
643 : : }
644 [ # # ]: 0 : }
645 [ # # ]: 0 : if( bUndo )
646 : 0 : EndUndo();
647 : 0 : }
648 : :
649 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
650 : :
651 : 0 : void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr, sal_Bool /*bReplaceAll*/)
652 : : {
653 : : // bReplaceAll has no effect here
654 [ # # ]: 0 : Rectangle aAllSnapRect(GetMarkedObjRect());
655 : 0 : const SfxPoolItem *pPoolItem=NULL;
656 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,sal_True,&pPoolItem)==SFX_ITEM_SET) {
657 : 0 : long n=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
658 [ # # ]: 0 : SetRef1(Point(n,GetRef1().Y()));
659 : : }
660 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,sal_True,&pPoolItem)==SFX_ITEM_SET) {
661 : 0 : long n=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
662 [ # # ]: 0 : SetRef1(Point(GetRef1().X(),n));
663 : : }
664 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,sal_True,&pPoolItem)==SFX_ITEM_SET) {
665 : 0 : long n=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
666 [ # # ]: 0 : SetRef2(Point(n,GetRef2().Y()));
667 : : }
668 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,sal_True,&pPoolItem)==SFX_ITEM_SET) {
669 : 0 : long n=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
670 [ # # ]: 0 : SetRef2(Point(GetRef2().X(),n));
671 : : }
672 : 0 : long nAllPosX=0; sal_Bool bAllPosX=sal_False;
673 : 0 : long nAllPosY=0; sal_Bool bAllPosY=sal_False;
674 : 0 : long nAllWdt=0; sal_Bool bAllWdt=sal_False;
675 : 0 : long nAllHgt=0; sal_Bool bAllHgt=sal_False;
676 : 0 : sal_Bool bDoIt=sal_False;
677 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_ALLPOSITIONX,sal_True,&pPoolItem)==SFX_ITEM_SET) {
678 : 0 : nAllPosX=((const SdrAllPositionXItem*)pPoolItem)->GetValue();
679 : 0 : bAllPosX=sal_True; bDoIt=sal_True;
680 : : }
681 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_ALLPOSITIONY,sal_True,&pPoolItem)==SFX_ITEM_SET) {
682 : 0 : nAllPosY=((const SdrAllPositionYItem*)pPoolItem)->GetValue();
683 : 0 : bAllPosY=sal_True; bDoIt=sal_True;
684 : : }
685 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_ALLSIZEWIDTH,sal_True,&pPoolItem)==SFX_ITEM_SET) {
686 : 0 : nAllWdt=((const SdrAllSizeWidthItem*)pPoolItem)->GetValue();
687 : 0 : bAllWdt=sal_True; bDoIt=sal_True;
688 : : }
689 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_ALLSIZEHEIGHT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
690 : 0 : nAllHgt=((const SdrAllSizeHeightItem*)pPoolItem)->GetValue();
691 : 0 : bAllHgt=sal_True; bDoIt=sal_True;
692 : : }
693 [ # # ]: 0 : if (bDoIt) {
694 : 0 : Rectangle aRect(aAllSnapRect); // TODO: change this for PolyPt's and GluePt's!!!
695 [ # # ][ # # ]: 0 : if (bAllPosX) aRect.Move(nAllPosX-aRect.Left(),0);
696 [ # # ][ # # ]: 0 : if (bAllPosY) aRect.Move(0,nAllPosY-aRect.Top());
697 [ # # ]: 0 : if (bAllWdt) aRect.Right()=aAllSnapRect.Left()+nAllWdt;
698 [ # # ]: 0 : if (bAllHgt) aRect.Bottom()=aAllSnapRect.Top()+nAllHgt;
699 [ # # ]: 0 : SetMarkedObjRect(aRect);
700 : : }
701 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_RESIZEXALL,sal_True,&pPoolItem)==SFX_ITEM_SET) {
702 [ # # ]: 0 : Fraction aXFact=((const SdrResizeXAllItem*)pPoolItem)->GetValue();
703 [ # # ][ # # ]: 0 : ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,Fraction(1,1));
704 : : }
705 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_RESIZEYALL,sal_True,&pPoolItem)==SFX_ITEM_SET) {
706 [ # # ]: 0 : Fraction aYFact=((const SdrResizeYAllItem*)pPoolItem)->GetValue();
707 [ # # ][ # # ]: 0 : ResizeMarkedObj(aAllSnapRect.TopLeft(),Fraction(1,1),aYFact);
708 : : }
709 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_ROTATEALL,sal_True,&pPoolItem)==SFX_ITEM_SET) {
710 : 0 : long nAngle=((const SdrRotateAllItem*)pPoolItem)->GetValue();
711 [ # # ][ # # ]: 0 : RotateMarkedObj(aAllSnapRect.Center(),nAngle);
712 : : }
713 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_HORZSHEARALL,sal_True,&pPoolItem)==SFX_ITEM_SET) {
714 : 0 : long nAngle=((const SdrHorzShearAllItem*)pPoolItem)->GetValue();
715 [ # # ][ # # ]: 0 : ShearMarkedObj(aAllSnapRect.Center(),nAngle,sal_False);
716 : : }
717 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_VERTSHEARALL,sal_True,&pPoolItem)==SFX_ITEM_SET) {
718 : 0 : long nAngle=((const SdrVertShearAllItem*)pPoolItem)->GetValue();
719 [ # # ][ # # ]: 0 : ShearMarkedObj(aAllSnapRect.Center(),nAngle,sal_True);
720 : : }
721 : :
722 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
723 : :
724 : : // TODO: check if WhichRange is necessary.
725 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
726 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
727 : : {
728 [ # # ]: 0 : const SdrMark* pM=GetSdrMarkByIndex(nm);
729 [ # # ]: 0 : SdrObject* pObj=pM->GetMarkedSdrObj();
730 [ # # ]: 0 : if( bUndo )
731 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
[ # # ]
732 : :
733 [ # # ]: 0 : pObj->ApplyNotPersistAttr(rAttr);
734 : : }
735 : 0 : }
736 : :
737 : 0 : void SdrEditView::MergeNotPersistAttrFromMarked(SfxItemSet& rAttr, sal_Bool /*bOnlyHardAttr*/) const
738 : : {
739 : : // bOnlyHardAttr has no effect here.
740 : : // TODO: Take into account the origin and PvPos.
741 [ # # ]: 0 : Rectangle aAllSnapRect(GetMarkedObjRect()); // TODO: change this for PolyPt's and GluePt's!!!
742 : 0 : long nAllSnapPosX=aAllSnapRect.Left();
743 : 0 : long nAllSnapPosY=aAllSnapRect.Top();
744 [ # # ]: 0 : long nAllSnapWdt=aAllSnapRect.GetWidth()-1;
745 [ # # ]: 0 : long nAllSnapHgt=aAllSnapRect.GetHeight()-1;
746 : : // TODO: could go into CheckPossibilities
747 : 0 : bool bMovProtect = false, bMovProtectDC = false;
748 : 0 : bool bSizProtect = false, bSizProtectDC = false;
749 : 0 : bool bPrintable = true, bPrintableDC = false;
750 : 0 : bool bVisible = true, bVisibleDC = false;
751 : 0 : SdrLayerID nLayerId=0; sal_Bool bLayerDC=sal_False;
752 : 0 : rtl::OUString aObjName;
753 : 0 : sal_Bool bObjNameDC=sal_False,bObjNameSet=sal_False;
754 : 0 : long nSnapPosX=0; sal_Bool bSnapPosXDC=sal_False;
755 : 0 : long nSnapPosY=0; sal_Bool bSnapPosYDC=sal_False;
756 : 0 : long nSnapWdt=0; sal_Bool bSnapWdtDC=sal_False;
757 : 0 : long nSnapHgt=0; sal_Bool bSnapHgtDC=sal_False;
758 : 0 : long nLogicWdt=0; sal_Bool bLogicWdtDC=sal_False,bLogicWdtDiff=sal_False;
759 : 0 : long nLogicHgt=0; sal_Bool bLogicHgtDC=sal_False,bLogicHgtDiff=sal_False;
760 : 0 : long nRotAngle=0; sal_Bool bRotAngleDC=sal_False;
761 : 0 : long nShrAngle=0; sal_Bool bShrAngleDC=sal_False;
762 [ # # ]: 0 : Rectangle aSnapRect;
763 [ # # ]: 0 : Rectangle aLogicRect;
764 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
765 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++) {
766 [ # # ]: 0 : const SdrMark* pM=GetSdrMarkByIndex(nm);
767 [ # # ]: 0 : const SdrObject* pObj=pM->GetMarkedSdrObj();
768 [ # # ]: 0 : if (nm==0) {
769 [ # # ]: 0 : nLayerId=pObj->GetLayer();
770 [ # # ]: 0 : bMovProtect=pObj->IsMoveProtect();
771 [ # # ]: 0 : bSizProtect=pObj->IsResizeProtect();
772 [ # # ]: 0 : bPrintable =pObj->IsPrintable();
773 [ # # ]: 0 : bVisible = pObj->IsVisible();
774 [ # # ]: 0 : Rectangle aSnapRect2(pObj->GetSnapRect());
775 [ # # ]: 0 : Rectangle aLogicRect2(pObj->GetLogicRect());
776 : 0 : nSnapPosX=aSnapRect2.Left();
777 : 0 : nSnapPosY=aSnapRect2.Top();
778 [ # # ]: 0 : nSnapWdt=aSnapRect2.GetWidth()-1;
779 [ # # ]: 0 : nSnapHgt=aSnapRect2.GetHeight()-1;
780 [ # # ]: 0 : nLogicWdt=aLogicRect2.GetWidth()-1;
781 [ # # ]: 0 : nLogicHgt=aLogicRect2.GetHeight()-1;
782 : 0 : bLogicWdtDiff=nLogicWdt!=nSnapWdt;
783 : 0 : bLogicHgtDiff=nLogicHgt!=nSnapHgt;
784 [ # # ]: 0 : nRotAngle=pObj->GetRotateAngle();
785 [ # # ]: 0 : nShrAngle=pObj->GetShearAngle();
786 : : } else {
787 [ # # ][ # # ]: 0 : if (!bLayerDC && nLayerId !=pObj->GetLayer()) bLayerDC = true;
[ # # ][ # # ]
788 [ # # ][ # # ]: 0 : if (!bMovProtectDC && bMovProtect!=pObj->IsMoveProtect()) bMovProtectDC = true;
[ # # ][ # # ]
789 [ # # ][ # # ]: 0 : if (!bSizProtectDC && bSizProtect!=pObj->IsResizeProtect()) bSizProtectDC = true;
[ # # ][ # # ]
790 [ # # ][ # # ]: 0 : if (!bPrintableDC && bPrintable !=pObj->IsPrintable()) bPrintableDC = true;
[ # # ][ # # ]
791 [ # # ][ # # ]: 0 : if (!bVisibleDC && bVisible !=pObj->IsVisible()) bVisibleDC=true;
[ # # ][ # # ]
792 [ # # ][ # # ]: 0 : if (!bRotAngleDC && nRotAngle !=pObj->GetRotateAngle()) bRotAngleDC=sal_True;
[ # # ][ # # ]
793 [ # # ][ # # ]: 0 : if (!bShrAngleDC && nShrAngle !=pObj->GetShearAngle()) bShrAngleDC=sal_True;
[ # # ][ # # ]
794 [ # # ][ # # ]: 0 : if (!bSnapWdtDC || !bSnapHgtDC || !bSnapPosXDC || !bSnapPosYDC || !bLogicWdtDiff || !bLogicHgtDiff) {
[ # # ][ # # ]
[ # # ][ # # ]
795 [ # # ]: 0 : aSnapRect=pObj->GetSnapRect();
796 [ # # ]: 0 : if (nSnapPosX!=aSnapRect.Left()) bSnapPosXDC=sal_True;
797 [ # # ]: 0 : if (nSnapPosY!=aSnapRect.Top()) bSnapPosYDC=sal_True;
798 [ # # ][ # # ]: 0 : if (nSnapWdt!=aSnapRect.GetWidth()-1) bSnapWdtDC=sal_True;
799 [ # # ][ # # ]: 0 : if (nSnapHgt!=aSnapRect.GetHeight()-1) bSnapHgtDC=sal_True;
800 : : }
801 [ # # ][ # # ]: 0 : if (!bLogicWdtDC || !bLogicHgtDC || !bLogicWdtDiff || !bLogicHgtDiff) {
[ # # ][ # # ]
802 [ # # ]: 0 : aLogicRect=pObj->GetLogicRect();
803 [ # # ][ # # ]: 0 : if (nLogicWdt!=aLogicRect.GetWidth()-1) bLogicWdtDC=sal_True;
804 [ # # ][ # # ]: 0 : if (nLogicHgt!=aLogicRect.GetHeight()-1) bLogicHgtDC=sal_True;
805 [ # # ][ # # ]: 0 : if (!bLogicWdtDiff && aSnapRect.GetWidth()!=aLogicRect.GetWidth()) bLogicWdtDiff=sal_True;
[ # # ][ # # ]
[ # # ]
806 [ # # ][ # # ]: 0 : if (!bLogicHgtDiff && aSnapRect.GetHeight()!=aLogicRect.GetHeight()) bLogicHgtDiff=sal_True;
[ # # ][ # # ]
[ # # ]
807 : : }
808 : : }
809 [ # # ]: 0 : if (!bObjNameDC ) {
810 [ # # ]: 0 : if (!bObjNameSet) {
811 [ # # ]: 0 : aObjName=pObj->GetName();
812 : : } else {
813 [ # # ][ # # ]: 0 : if (!aObjName.equals(pObj->GetName()))
814 : 0 : bObjNameDC = true;
815 : : }
816 : : }
817 : : }
818 : :
819 [ # # ][ # # ]: 0 : if (bSnapPosXDC || nAllSnapPosX!=nSnapPosX) rAttr.Put(SdrAllPositionXItem(nAllSnapPosX));
[ # # ][ # # ]
[ # # ]
820 [ # # ][ # # ]: 0 : if (bSnapPosYDC || nAllSnapPosY!=nSnapPosY) rAttr.Put(SdrAllPositionYItem(nAllSnapPosY));
[ # # ][ # # ]
[ # # ]
821 [ # # ][ # # ]: 0 : if (bSnapWdtDC || nAllSnapWdt !=nSnapWdt ) rAttr.Put(SdrAllSizeWidthItem(nAllSnapWdt));
[ # # ][ # # ]
[ # # ]
822 [ # # ][ # # ]: 0 : if (bSnapHgtDC || nAllSnapHgt !=nSnapHgt ) rAttr.Put(SdrAllSizeHeightItem(nAllSnapHgt));
[ # # ][ # # ]
[ # # ]
823 : :
824 : : // items for pure transformations
825 [ # # ][ # # ]: 0 : rAttr.Put(SdrMoveXItem());
[ # # ]
826 [ # # ][ # # ]: 0 : rAttr.Put(SdrMoveYItem());
[ # # ]
827 [ # # ][ # # ]: 0 : rAttr.Put(SdrResizeXOneItem());
[ # # ]
828 [ # # ][ # # ]: 0 : rAttr.Put(SdrResizeYOneItem());
[ # # ]
829 [ # # ][ # # ]: 0 : rAttr.Put(SdrRotateOneItem());
[ # # ]
830 [ # # ][ # # ]: 0 : rAttr.Put(SdrHorzShearOneItem());
[ # # ]
831 [ # # ][ # # ]: 0 : rAttr.Put(SdrVertShearOneItem());
[ # # ]
832 : :
833 [ # # ]: 0 : if (nMarkAnz>1) {
834 [ # # ][ # # ]: 0 : rAttr.Put(SdrResizeXAllItem());
[ # # ]
835 [ # # ][ # # ]: 0 : rAttr.Put(SdrResizeYAllItem());
[ # # ]
836 [ # # ][ # # ]: 0 : rAttr.Put(SdrRotateAllItem());
[ # # ]
837 [ # # ][ # # ]: 0 : rAttr.Put(SdrHorzShearAllItem());
[ # # ]
838 [ # # ][ # # ]: 0 : rAttr.Put(SdrVertShearAllItem());
[ # # ]
839 : : }
840 : :
841 [ # # ][ # # ]: 0 : if(eDragMode == SDRDRAG_ROTATE || eDragMode == SDRDRAG_MIRROR)
842 : : {
843 [ # # ][ # # ]: 0 : rAttr.Put(SdrTransformRef1XItem(GetRef1().X()));
[ # # ]
844 [ # # ][ # # ]: 0 : rAttr.Put(SdrTransformRef1YItem(GetRef1().Y()));
[ # # ]
845 : : }
846 : :
847 [ # # ]: 0 : if(eDragMode == SDRDRAG_MIRROR)
848 : : {
849 [ # # ][ # # ]: 0 : rAttr.Put(SdrTransformRef2XItem(GetRef2().X()));
[ # # ]
850 [ # # ][ # # ]: 0 : rAttr.Put(SdrTransformRef2YItem(GetRef2().Y()));
[ # # ]
851 : 0 : }
852 : 0 : }
853 : :
854 : 1 : SfxItemSet SdrEditView::GetAttrFromMarked(sal_Bool bOnlyHardAttr) const
855 : : {
856 : 1 : SfxItemSet aSet(pMod->GetItemPool());
857 [ + - ]: 1 : MergeAttrFromMarked(aSet,bOnlyHardAttr);
858 : : //the EE_FEATURE items should not be set with SetAttrToMarked (see error message there)
859 : : //so we do not set them here
860 : : // #i32448#
861 : : // Do not disable, but clear the items.
862 [ + - ]: 1 : aSet.ClearItem(EE_FEATURE_TAB);
863 [ + - ]: 1 : aSet.ClearItem(EE_FEATURE_LINEBR);
864 [ + - ]: 1 : aSet.ClearItem(EE_FEATURE_NOTCONV);
865 [ + - ]: 1 : aSet.ClearItem(EE_FEATURE_FIELD);
866 : 1 : return aSet;
867 : : }
868 : :
869 : 1 : void SdrEditView::MergeAttrFromMarked(SfxItemSet& rAttr, sal_Bool bOnlyHardAttr) const
870 : : {
871 : 1 : sal_uInt32 nMarkAnz(GetMarkedObjectCount());
872 : :
873 [ + + ]: 2 : for(sal_uInt32 a(0); a < nMarkAnz; a++)
874 : : {
875 : : // #80277# merging was done wrong in the prev version
876 [ + - ][ + - ]: 1 : const SfxItemSet& rSet = GetMarkedObjectByIndex(a)->GetMergedItemSet();
877 [ + - ]: 1 : SfxWhichIter aIter(rSet);
878 [ + - ]: 1 : sal_uInt16 nWhich(aIter.FirstWhich());
879 : :
880 [ + + ]: 135 : while(nWhich)
881 : : {
882 [ + - ]: 134 : if(!bOnlyHardAttr)
883 : : {
884 [ + - ][ - + ]: 134 : if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, sal_False))
885 [ # # ]: 0 : rAttr.InvalidateItem(nWhich);
886 : : else
887 [ + - ][ + - ]: 134 : rAttr.MergeValue(rSet.Get(nWhich), sal_True);
888 : : }
889 [ # # ][ # # ]: 0 : else if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False))
890 : : {
891 [ # # ]: 0 : const SfxPoolItem& rItem = rSet.Get(nWhich);
892 [ # # ]: 0 : rAttr.MergeValue(rItem, sal_True);
893 : : }
894 : :
895 [ + - ]: 134 : nWhich = aIter.NextWhich();
896 : : }
897 [ + - ]: 1 : }
898 : 1 : }
899 : :
900 : 0 : void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, sal_Bool bReplaceAll)
901 : : {
902 [ # # ]: 0 : if (AreObjectsMarked())
903 : : {
904 : : #ifdef DBG_UTIL
905 : : {
906 : : sal_Bool bHasEEFeatureItems=sal_False;
907 : : SfxItemIter aIter(rAttr);
908 : : const SfxPoolItem* pItem=aIter.FirstItem();
909 : : while (!bHasEEFeatureItems && pItem!=NULL) {
910 : : if (!IsInvalidItem(pItem)) {
911 : : sal_uInt16 nW=pItem->Which();
912 : : if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=sal_True;
913 : : }
914 : : pItem=aIter.NextItem();
915 : : }
916 : : if(bHasEEFeatureItems)
917 : : {
918 : : String aMessage;
919 : : aMessage.AppendAscii("SdrEditView::SetAttrToMarked(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents.");
920 : : InfoBox(NULL, aMessage).Execute();
921 : : }
922 : : }
923 : : #endif
924 : :
925 : : // #103836# if the user thets character attributes to the complete shape,
926 : : // we want to remove all hard set character attributes with same
927 : : // which ids from the text. We do that later but here we remember
928 : : // all character attribute which id's that are set.
929 [ # # ]: 0 : std::vector<sal_uInt16> aCharWhichIds;
930 : : {
931 [ # # ]: 0 : SfxItemIter aIter(rAttr);
932 : 0 : const SfxPoolItem* pItem=aIter.FirstItem();
933 [ # # ]: 0 : while( pItem!=NULL )
934 : : {
935 [ # # ]: 0 : if (!IsInvalidItem(pItem))
936 : : {
937 : 0 : sal_uInt16 nWhich = pItem->Which();
938 [ # # ][ # # ]: 0 : if (nWhich>=EE_CHAR_START && nWhich<=EE_CHAR_END)
939 [ # # ]: 0 : aCharWhichIds.push_back( nWhich );
940 : : }
941 [ # # ]: 0 : pItem=aIter.NextItem();
942 [ # # ]: 0 : }
943 : : }
944 : :
945 : : // To make Undo reconstruct text attributes correctly after Format.Standard
946 [ # # ]: 0 : sal_Bool bHasEEItems=SearchOutlinerItems(rAttr,bReplaceAll);
947 : :
948 : : // save additional geometry information when paragraph or character attributes
949 : : // are changed and the geometrical shape of the text object might be changed
950 : 0 : sal_Bool bPossibleGeomChange(sal_False);
951 [ # # ]: 0 : SfxWhichIter aIter(rAttr);
952 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
953 [ # # ][ # # ]: 0 : while(!bPossibleGeomChange && nWhich)
[ # # ]
954 : : {
955 [ # # ]: 0 : SfxItemState eState = rAttr.GetItemState(nWhich);
956 [ # # ]: 0 : if(eState == SFX_ITEM_SET)
957 : : {
958 [ # # ][ # # ]: 0 : if((nWhich >= SDRATTR_TEXT_MINFRAMEHEIGHT && nWhich <= SDRATTR_TEXT_CONTOURFRAME)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
959 : : || nWhich == SDRATTR_3DOBJ_PERCENT_DIAGONAL
960 : : || nWhich == SDRATTR_3DOBJ_BACKSCALE
961 : : || nWhich == SDRATTR_3DOBJ_DEPTH
962 : : || nWhich == SDRATTR_3DOBJ_END_ANGLE
963 : : || nWhich == SDRATTR_3DSCENE_DISTANCE)
964 : : {
965 : 0 : bPossibleGeomChange = sal_True;
966 : : }
967 : : }
968 [ # # ]: 0 : nWhich = aIter.NextWhich();
969 : : }
970 : :
971 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
972 [ # # ]: 0 : if( bUndo )
973 : : {
974 [ # # ]: 0 : XubString aStr;
975 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
976 [ # # ][ # # ]: 0 : BegUndo(aStr);
977 : : }
978 : :
979 : 0 : const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
980 [ # # ]: 0 : std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
981 : :
982 : : // create ItemSet without SFX_ITEM_DONTCARE. Put()
983 : : // uses its second parameter (bInvalidAsDefault) to
984 : : // remove all such items to set them to default.
985 [ # # ]: 0 : SfxItemSet aAttr(*rAttr.GetPool(), rAttr.GetRanges());
986 [ # # ]: 0 : aAttr.Put(rAttr, sal_True);
987 : :
988 : : // #i38135#
989 : 0 : bool bResetAnimationTimer(false);
990 : :
991 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
992 : : {
993 [ # # ]: 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
994 [ # # ]: 0 : SdrObject* pObj = pM->GetMarkedSdrObj();
995 : :
996 [ # # ]: 0 : if( bUndo )
997 : : {
998 [ # # ]: 0 : std::vector< SdrUndoAction* > vConnectorUndoActions;
999 [ # # ]: 0 : SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >( pObj );
1000 [ # # ]: 0 : if ( pEdgeObj )
1001 : 0 : bPossibleGeomChange = sal_True;
1002 [ # # ]: 0 : else if( bUndo )
1003 [ # # ]: 0 : vConnectorUndoActions = CreateConnectorUndo( *pObj );
1004 : :
1005 [ # # ]: 0 : AddUndoActions( vConnectorUndoActions );
1006 : : }
1007 : :
1008 : : // new geometry undo
1009 [ # # ][ # # ]: 0 : if(bPossibleGeomChange && bUndo)
1010 : : {
1011 : : // save position and size of object, too
1012 [ # # ][ # # ]: 0 : AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
[ # # ]
1013 : : }
1014 : :
1015 [ # # ]: 0 : if( bUndo )
1016 : : {
1017 : : // #i8508#
1018 : : // If this is a text object also rescue the OutlinerParaObject since
1019 : : // applying attributes to the object may change text layout when
1020 : : // multiple portions exist with multiple formats. If a OutlinerParaObject
1021 : : // really exists and needs to be rescued is evaluated in the undo
1022 : : // implementation itself.
1023 [ # # ][ # # ]: 0 : const bool bRescueText = dynamic_cast< SdrTextObj* >(pObj) != 0;
1024 : :
1025 : : // add attribute undo
1026 [ # # ][ # # ]: 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,sal_False,bHasEEItems || bPossibleGeomChange || bRescueText));
[ # # ][ # # ]
[ # # ][ # # ]
1027 : : }
1028 : :
1029 : : // set up a scene updater if object is a 3d object
1030 [ # # ][ # # ]: 0 : if(dynamic_cast< E3dObject* >(pObj))
[ # # ]
1031 : : {
1032 [ # # ][ # # ]: 0 : aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj));
[ # # ]
1033 : : }
1034 : :
1035 : : // set attributes at object
1036 [ # # ]: 0 : pObj->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
1037 : :
1038 [ # # ][ # # ]: 0 : if(pObj->ISA(SdrTextObj))
[ # # ]
1039 : : {
1040 : 0 : SdrTextObj* pTextObj = ((SdrTextObj*)pObj);
1041 : :
1042 [ # # ]: 0 : if(!aCharWhichIds.empty())
1043 : : {
1044 [ # # ]: 0 : Rectangle aOldBoundRect = pTextObj->GetLastBoundRect();
1045 : :
1046 : : // #110094#-14 pTextObj->SendRepaintBroadcast(pTextObj->GetBoundRect());
1047 [ # # ]: 0 : pTextObj->RemoveOutlinerCharacterAttribs( aCharWhichIds );
1048 : :
1049 : : // object has changed, should be called from
1050 : : // RemoveOutlinerCharacterAttribs. This will change when the text
1051 : : // object implementation changes.
1052 [ # # ]: 0 : pTextObj->SetChanged();
1053 : :
1054 [ # # ]: 0 : pTextObj->BroadcastObjectChange();
1055 [ # # ]: 0 : pTextObj->SendUserCall(SDRUSERCALL_CHGATTR, aOldBoundRect);
1056 : : }
1057 : : }
1058 : :
1059 : : // #i38495#
1060 [ # # ]: 0 : if(!bResetAnimationTimer)
1061 : : {
1062 [ # # ][ # # ]: 0 : if(pObj->GetViewContact().isAnimatedInAnyViewObjectContact())
[ # # ]
1063 : : {
1064 : 0 : bResetAnimationTimer = true;
1065 : : }
1066 : : }
1067 : : }
1068 : :
1069 : : // fire scene updaters
1070 [ # # ]: 0 : while(!aUpdaters.empty())
1071 : : {
1072 [ # # ][ # # ]: 0 : delete aUpdaters.back();
[ # # ]
1073 [ # # ]: 0 : aUpdaters.pop_back();
1074 : : }
1075 : :
1076 : : // #i38135#
1077 [ # # ]: 0 : if(bResetAnimationTimer)
1078 : : {
1079 [ # # ]: 0 : SetAnimationTimer(0L);
1080 : : }
1081 : :
1082 : : // better check before what to do:
1083 : : // pObj->SetAttr() or SetNotPersistAttr()
1084 : : // TODO: missing implementation!
1085 [ # # ]: 0 : SetNotPersistAttrToMarked(rAttr,bReplaceAll);
1086 : :
1087 [ # # ]: 0 : if( bUndo )
1088 [ # # ][ # # ]: 0 : EndUndo();
[ # # ]
1089 : : }
1090 : 0 : }
1091 : :
1092 : 0 : SfxStyleSheet* SdrEditView::GetStyleSheetFromMarked() const
1093 : : {
1094 : 0 : SfxStyleSheet* pRet=NULL;
1095 : 0 : sal_Bool b1st=sal_True;
1096 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
1097 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++) {
1098 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
1099 : 0 : SfxStyleSheet* pSS=pM->GetMarkedSdrObj()->GetStyleSheet();
1100 [ # # ]: 0 : if (b1st) pRet=pSS;
1101 [ # # ]: 0 : else if (pRet!=pSS) return NULL; // different stylesheets
1102 : 0 : b1st=sal_False;
1103 : : }
1104 : 0 : return pRet;
1105 : : }
1106 : :
1107 : 0 : void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
1108 : : {
1109 [ # # ]: 0 : if (AreObjectsMarked())
1110 : : {
1111 : 0 : const bool bUndo = IsUndoEnabled();
1112 : :
1113 [ # # ]: 0 : if( bUndo )
1114 : : {
1115 [ # # ]: 0 : XubString aStr;
1116 [ # # ]: 0 : if (pStyleSheet!=NULL)
1117 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr);
1118 : : else
1119 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr);
1120 [ # # ][ # # ]: 0 : BegUndo(aStr);
1121 : : }
1122 : :
1123 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
1124 [ # # ]: 0 : for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
1125 : : {
1126 : 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
1127 [ # # ]: 0 : if( bUndo )
1128 : : {
1129 : 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj()));
1130 : 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true));
1131 : : }
1132 : 0 : pM->GetMarkedSdrObj()->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1133 : : }
1134 : :
1135 [ # # ]: 0 : if( bUndo )
1136 : 0 : EndUndo();
1137 : : }
1138 : 0 : }
1139 : :
1140 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1141 : :
1142 : 1216 : sal_Bool SdrEditView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const
1143 : : {
1144 [ + + ]: 1216 : if(GetMarkedObjectCount())
1145 : : {
1146 [ + - ]: 1 : rTargetSet.Put(GetAttrFromMarked(bOnlyHardAttr), sal_False);
1147 : 1 : return sal_True;
1148 : : }
1149 : : else
1150 : : {
1151 : 1216 : return SdrMarkView::GetAttributes(rTargetSet, bOnlyHardAttr);
1152 : : }
1153 : : }
1154 : :
1155 : 0 : sal_Bool SdrEditView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
1156 : : {
1157 [ # # ]: 0 : if (GetMarkedObjectCount()!=0) {
1158 : 0 : SetAttrToMarked(rSet,bReplaceAll);
1159 : 0 : return sal_True;
1160 : : } else {
1161 : 0 : return SdrMarkView::SetAttributes(rSet,bReplaceAll);
1162 : : }
1163 : : }
1164 : :
1165 : 4 : SfxStyleSheet* SdrEditView::GetStyleSheet() const
1166 : : {
1167 [ - + ]: 4 : if (GetMarkedObjectCount()!=0) {
1168 : 0 : return GetStyleSheetFromMarked();
1169 : : } else {
1170 : 4 : return SdrMarkView::GetStyleSheet();
1171 : : }
1172 : : }
1173 : :
1174 : 0 : sal_Bool SdrEditView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
1175 : : {
1176 [ # # ]: 0 : if (GetMarkedObjectCount()!=0) {
1177 : 0 : SetStyleSheetToMarked(pStyleSheet,bDontRemoveHardAttr);
1178 : 0 : return sal_True;
1179 : : } else {
1180 : 0 : return SdrMarkView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1181 : : }
1182 : : }
1183 : :
1184 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1185 : :
1186 : 0 : SfxItemSet SdrEditView::GetGeoAttrFromMarked() const
1187 : : {
1188 : 0 : SfxItemSet aRetSet(pMod->GetItemPool(), // SID_ATTR_TRANSFORM_... from s:svxids.hrc
1189 : : SID_ATTR_TRANSFORM_POS_X,SID_ATTR_TRANSFORM_ANGLE,
1190 : : SID_ATTR_TRANSFORM_PROTECT_POS,SID_ATTR_TRANSFORM_AUTOHEIGHT,
1191 : : SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS,
1192 : 0 : 0);
1193 [ # # ]: 0 : if (AreObjectsMarked()) {
1194 [ # # ]: 0 : SfxItemSet aMarkAttr(GetAttrFromMarked(sal_False)); // because of AutoGrowHeight and corner radius
1195 [ # # ]: 0 : Rectangle aRect(GetMarkedObjRect());
1196 : :
1197 [ # # ]: 0 : if(GetSdrPageView())
1198 : : {
1199 [ # # ]: 0 : GetSdrPageView()->LogicToPagePos(aRect);
1200 : : }
1201 : :
1202 : : // position
1203 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X,aRect.Left()));
[ # # ]
1204 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y,aRect.Top()));
[ # # ]
1205 : :
1206 : : // size
1207 : 0 : long nResizeRefX=aRect.Left();
1208 : 0 : long nResizeRefY=aRect.Top();
1209 [ # # ]: 0 : if (eDragMode==SDRDRAG_ROTATE) { // use rotation axis as a reference for resizing, too
1210 : 0 : nResizeRefX=aRef1.X();
1211 : 0 : nResizeRefY=aRef1.Y();
1212 : : }
1213 [ # # ][ # # ]: 0 : aRetSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_WIDTH,aRect.Right()-aRect.Left()));
[ # # ]
1214 [ # # ][ # # ]: 0 : aRetSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_HEIGHT,aRect.Bottom()-aRect.Top()));
[ # # ]
1215 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_RESIZE_REF_X,nResizeRefX));
[ # # ]
1216 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_RESIZE_REF_Y,nResizeRefY));
[ # # ]
1217 : :
1218 : 0 : Point aRotateAxe(aRef1);
1219 : :
1220 [ # # ]: 0 : if(GetSdrPageView())
1221 : : {
1222 : 0 : GetSdrPageView()->LogicToPagePos(aRotateAxe);
1223 : : }
1224 : :
1225 : : // rotation
1226 [ # # ]: 0 : long nRotateRefX=aRect.Center().X();
1227 [ # # ]: 0 : long nRotateRefY=aRect.Center().Y();
1228 [ # # ]: 0 : if (eDragMode==SDRDRAG_ROTATE) {
1229 : 0 : nRotateRefX=aRotateAxe.X();
1230 : 0 : nRotateRefY=aRotateAxe.Y();
1231 : : }
1232 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ANGLE,GetMarkedObjRotate()));
[ # # ][ # # ]
1233 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_X,nRotateRefX));
[ # # ]
1234 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_Y,nRotateRefY));
[ # # ]
1235 : :
1236 : : // shearing
1237 : 0 : long nShearRefX=aRect.Left();
1238 : 0 : long nShearRefY=aRect.Bottom();
1239 [ # # ]: 0 : if (eDragMode==SDRDRAG_ROTATE) { // use rotation axis as a reference for shearing, too
1240 : 0 : nShearRefX=aRotateAxe.X();
1241 : 0 : nShearRefY=aRotateAxe.Y();
1242 : : }
1243 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR,GetMarkedObjShear()));
[ # # ][ # # ]
1244 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_X,nShearRefX));
[ # # ]
1245 [ # # ][ # # ]: 0 : aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_Y,nShearRefY));
[ # # ]
1246 : :
1247 : : // check every object whether it is protected
1248 : 0 : const SdrMarkList& rMarkList=GetMarkedObjectList();
1249 : 0 : sal_uIntPtr nMarkCount=rMarkList.GetMarkCount();
1250 [ # # ][ # # ]: 0 : SdrObject* pObj=rMarkList.GetMark(0)->GetMarkedSdrObj();
1251 [ # # ]: 0 : bool bPosProt=pObj->IsMoveProtect();
1252 [ # # ]: 0 : bool bSizProt=pObj->IsResizeProtect();
1253 : 0 : bool bPosProtDontCare=false;
1254 : 0 : bool bSizProtDontCare=false;
1255 [ # # ][ # # ]: 0 : for (sal_uIntPtr i=1; i<nMarkCount && (!bPosProtDontCare || !bSizProtDontCare); i++) {
[ # # ][ # # ]
1256 [ # # ][ # # ]: 0 : pObj=rMarkList.GetMark(i)->GetMarkedSdrObj();
1257 [ # # ][ # # ]: 0 : if (bPosProt!=pObj->IsMoveProtect()) bPosProtDontCare=true;
1258 [ # # ][ # # ]: 0 : if (bSizProt!=pObj->IsResizeProtect()) bSizProtDontCare=true;
1259 : : }
1260 : :
1261 : : // InvalidateItem sets item to DONT_CARE
1262 [ # # ]: 0 : if (bPosProtDontCare) {
1263 [ # # ]: 0 : aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_PROTECT_POS);
1264 : : } else {
1265 [ # # ][ # # ]: 0 : aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_PROTECT_POS,bPosProt));
[ # # ]
1266 : : }
1267 [ # # ]: 0 : if (bSizProtDontCare) {
1268 [ # # ]: 0 : aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_PROTECT_SIZE);
1269 : : } else {
1270 [ # # ][ # # ]: 0 : aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_PROTECT_SIZE,bSizProt));
[ # # ]
1271 : : }
1272 : :
1273 [ # # ]: 0 : SfxItemState eState=aMarkAttr.GetItemState(SDRATTR_TEXT_AUTOGROWWIDTH);
1274 [ # # ]: 0 : sal_Bool bAutoGrow=((SdrTextAutoGrowWidthItem&)(aMarkAttr.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue();
1275 [ # # ]: 0 : if (eState==SFX_ITEM_DONTCARE) {
1276 [ # # ]: 0 : aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_AUTOWIDTH);
1277 [ # # ]: 0 : } else if (eState==SFX_ITEM_SET) {
1278 [ # # ][ # # ]: 0 : aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_AUTOWIDTH,bAutoGrow));
[ # # ]
1279 : : }
1280 : :
1281 [ # # ]: 0 : eState=aMarkAttr.GetItemState(SDRATTR_TEXT_AUTOGROWHEIGHT);
1282 [ # # ]: 0 : bAutoGrow=((SdrTextAutoGrowHeightItem&)(aMarkAttr.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
1283 [ # # ]: 0 : if (eState==SFX_ITEM_DONTCARE) {
1284 [ # # ]: 0 : aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_AUTOHEIGHT);
1285 [ # # ]: 0 : } else if (eState==SFX_ITEM_SET) {
1286 [ # # ][ # # ]: 0 : aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_AUTOHEIGHT,bAutoGrow));
[ # # ]
1287 : : }
1288 : :
1289 [ # # ]: 0 : eState=aMarkAttr.GetItemState(SDRATTR_ECKENRADIUS);
1290 [ # # ]: 0 : long nRadius=((SdrEckenradiusItem&)(aMarkAttr.Get(SDRATTR_ECKENRADIUS))).GetValue();
1291 [ # # ]: 0 : if (eState==SFX_ITEM_DONTCARE) {
1292 [ # # ]: 0 : aRetSet.InvalidateItem(SDRATTR_ECKENRADIUS);
1293 [ # # ]: 0 : } else if (eState==SFX_ITEM_SET) {
1294 [ # # ][ # # ]: 0 : aRetSet.Put(SdrEckenradiusItem(nRadius));
[ # # ]
1295 [ # # ]: 0 : }
1296 : :
1297 : : }
1298 : 0 : return aRetSet;
1299 : : }
1300 : :
1301 : 0 : Point ImpGetPoint(Rectangle aRect, RECT_POINT eRP)
1302 : : {
1303 [ # # # # : 0 : switch(eRP) {
# # # # #
# ]
1304 : 0 : case RP_LT: return aRect.TopLeft();
1305 : 0 : case RP_MT: return aRect.TopCenter();
1306 : 0 : case RP_RT: return aRect.TopRight();
1307 : 0 : case RP_LM: return aRect.LeftCenter();
1308 : 0 : case RP_MM: return aRect.Center();
1309 : 0 : case RP_RM: return aRect.RightCenter();
1310 : 0 : case RP_LB: return aRect.BottomLeft();
1311 : 0 : case RP_MB: return aRect.BottomCenter();
1312 : 0 : case RP_RB: return aRect.BottomRight();
1313 : : }
1314 : 0 : return Point(); // Should not happen!
1315 : : }
1316 : :
1317 : 0 : void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr)
1318 : : {
1319 [ # # ]: 0 : Rectangle aRect(GetMarkedObjRect());
1320 : :
1321 [ # # ]: 0 : if(GetSdrPageView())
1322 : : {
1323 [ # # ]: 0 : GetSdrPageView()->LogicToPagePos(aRect);
1324 : : }
1325 : :
1326 [ # # ]: 0 : long nOldRotateAngle=GetMarkedObjRotate();
1327 [ # # ]: 0 : long nOldShearAngle=GetMarkedObjShear();
1328 : 0 : const SdrMarkList& rMarkList=GetMarkedObjectList();
1329 : 0 : sal_uIntPtr nMarkCount=rMarkList.GetMarkCount();
1330 : 0 : SdrObject* pObj=NULL;
1331 : :
1332 : 0 : RECT_POINT eSizePoint=RP_MM;
1333 : 0 : long nPosDX=0;
1334 : 0 : long nPosDY=0;
1335 : 0 : long nSizX=0;
1336 : 0 : long nSizY=0;
1337 : 0 : long nRotateAngle=0;
1338 : :
1339 : 0 : sal_Bool bModeIsRotate(eDragMode == SDRDRAG_ROTATE);
1340 : 0 : long nRotateX(0);
1341 : 0 : long nRotateY(0);
1342 : 0 : long nOldRotateX(0);
1343 : 0 : long nOldRotateY(0);
1344 [ # # ]: 0 : if(bModeIsRotate)
1345 : : {
1346 : 0 : Point aRotateAxe(aRef1);
1347 : :
1348 [ # # ]: 0 : if(GetSdrPageView())
1349 : : {
1350 : 0 : GetSdrPageView()->LogicToPagePos(aRotateAxe);
1351 : : }
1352 : :
1353 : 0 : nRotateX = nOldRotateX = aRotateAxe.X();
1354 : 0 : nRotateY = nOldRotateY = aRotateAxe.Y();
1355 : : }
1356 : :
1357 : 0 : long nShearAngle=0;
1358 : 0 : long nShearX=0;
1359 : 0 : long nShearY=0;
1360 : 0 : sal_Bool bShearVert=sal_False;
1361 : :
1362 : 0 : sal_Bool bChgPos=sal_False;
1363 : 0 : sal_Bool bChgSiz=sal_False;
1364 : 0 : sal_Bool bRotate=sal_False;
1365 : 0 : sal_Bool bShear =sal_False;
1366 : :
1367 : 0 : sal_Bool bSetAttr=sal_False;
1368 [ # # ]: 0 : SfxItemSet aSetAttr(pMod->GetItemPool());
1369 : :
1370 : 0 : const SfxPoolItem* pPoolItem=NULL;
1371 : :
1372 : : // position
1373 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_X,sal_True,&pPoolItem)) {
1374 : 0 : nPosDX=((const SfxInt32Item*)pPoolItem)->GetValue()-aRect.Left();
1375 : 0 : bChgPos=sal_True;
1376 : : }
1377 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_Y,sal_True,&pPoolItem)){
1378 : 0 : nPosDY=((const SfxInt32Item*)pPoolItem)->GetValue()-aRect.Top();
1379 : 0 : bChgPos=sal_True;
1380 : : }
1381 : : // size
1382 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_WIDTH,sal_True,&pPoolItem)) {
1383 : 0 : nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue();
1384 : 0 : bChgSiz=sal_True;
1385 : : }
1386 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,sal_True,&pPoolItem)) {
1387 : 0 : nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue();
1388 : 0 : bChgSiz=sal_True;
1389 : : }
1390 [ # # ]: 0 : if (bChgSiz) {
1391 [ # # ]: 0 : eSizePoint=(RECT_POINT)((const SfxAllEnumItem&)rAttr.Get(SID_ATTR_TRANSFORM_SIZE_POINT)).GetValue();
1392 : : }
1393 : :
1394 : : // rotation
1395 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ANGLE,sal_True,&pPoolItem)) {
1396 : 0 : nRotateAngle=((const SfxInt32Item*)pPoolItem)->GetValue()-nOldRotateAngle;
1397 : 0 : bRotate = (nRotateAngle != 0);
1398 : : }
1399 : :
1400 : : // position rotation point x
1401 [ # # ][ # # ]: 0 : if(bRotate || SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ROT_X, sal_True ,&pPoolItem))
[ # # ][ # # ]
1402 [ # # ]: 0 : nRotateX = ((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_ROT_X)).GetValue();
1403 : :
1404 : : // position rotation point y
1405 [ # # ][ # # ]: 0 : if(bRotate || SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ROT_Y, sal_True ,&pPoolItem))
[ # # ][ # # ]
1406 [ # # ]: 0 : nRotateY = ((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_ROT_Y)).GetValue();
1407 : :
1408 : : // shearing
1409 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_SHEAR,sal_True,&pPoolItem)) {
1410 : 0 : long nNewShearAngle=((const SfxInt32Item*)pPoolItem)->GetValue();
1411 [ # # ]: 0 : if (nNewShearAngle>SDRMAXSHEAR) nNewShearAngle=SDRMAXSHEAR;
1412 [ # # ]: 0 : if (nNewShearAngle<-SDRMAXSHEAR) nNewShearAngle=-SDRMAXSHEAR;
1413 [ # # ]: 0 : if (nNewShearAngle!=nOldShearAngle) {
1414 [ # # ]: 0 : bShearVert=((const SfxBoolItem&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_VERTICAL)).GetValue();
1415 [ # # ]: 0 : if (bShearVert) {
1416 : 0 : nShearAngle=nNewShearAngle;
1417 : : } else {
1418 [ # # ][ # # ]: 0 : if (nNewShearAngle!=0 && nOldShearAngle!=0) {
1419 : : // bug fix
1420 : 0 : double nOld=tan((double)nOldShearAngle*nPi180);
1421 : 0 : double nNew=tan((double)nNewShearAngle*nPi180);
1422 : 0 : nNew-=nOld;
1423 : 0 : nNew=atan(nNew)/nPi180;
1424 : 0 : nShearAngle=Round(nNew);
1425 : : } else {
1426 : 0 : nShearAngle=nNewShearAngle-nOldShearAngle;
1427 : : }
1428 : : }
1429 : 0 : bShear=nShearAngle!=0;
1430 [ # # ]: 0 : if (bShear) {
1431 [ # # ]: 0 : nShearX=((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_X)).GetValue();
1432 [ # # ]: 0 : nShearY=((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_Y)).GetValue();
1433 : : }
1434 : : }
1435 : : }
1436 : :
1437 : : // AutoGrow
1438 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_AUTOWIDTH,sal_True,&pPoolItem)) {
1439 : 0 : sal_Bool bAutoGrow=((const SfxBoolItem*)pPoolItem)->GetValue();
1440 [ # # ][ # # ]: 0 : aSetAttr.Put(SdrTextAutoGrowWidthItem(bAutoGrow));
[ # # ]
1441 : 0 : bSetAttr=sal_True;
1442 : : }
1443 : :
1444 [ # # ][ # # ]: 0 : if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_AUTOHEIGHT,sal_True,&pPoolItem)) {
1445 : 0 : sal_Bool bAutoGrow=((const SfxBoolItem*)pPoolItem)->GetValue();
1446 [ # # ][ # # ]: 0 : aSetAttr.Put(SdrTextAutoGrowHeightItem(bAutoGrow));
[ # # ]
1447 : 0 : bSetAttr=sal_True;
1448 : : }
1449 : :
1450 : : // corner radius
1451 [ # # ][ # # ]: 0 : if (bEdgeRadiusAllowed && SFX_ITEM_SET==rAttr.GetItemState(SDRATTR_ECKENRADIUS,sal_True,&pPoolItem)) {
[ # # ][ # # ]
1452 : 0 : long nRadius=((SdrEckenradiusItem*)pPoolItem)->GetValue();
1453 [ # # ][ # # ]: 0 : aSetAttr.Put(SdrEckenradiusItem(nRadius));
[ # # ]
1454 : 0 : bSetAttr=sal_True;
1455 : : }
1456 : :
1457 [ # # ]: 0 : ForcePossibilities();
1458 : :
1459 [ # # ][ # # ]: 0 : BegUndo(ImpGetResStr(STR_EditTransform),GetDescriptionOfMarkedObjects());
[ # # ][ # # ]
[ # # ]
1460 : :
1461 [ # # ]: 0 : if (bSetAttr) {
1462 [ # # ]: 0 : SetAttrToMarked(aSetAttr,sal_False);
1463 : : }
1464 : :
1465 : : // change size and height
1466 [ # # ][ # # ]: 0 : if (bChgSiz && (bResizeFreeAllowed || bResizePropAllowed)) {
[ # # ]
1467 [ # # ]: 0 : Fraction aWdt(nSizX,aRect.Right()-aRect.Left());
1468 [ # # ]: 0 : Fraction aHgt(nSizY,aRect.Bottom()-aRect.Top());
1469 [ # # ]: 0 : Point aRef(ImpGetPoint(aRect,eSizePoint));
1470 : :
1471 [ # # ]: 0 : if(GetSdrPageView())
1472 : : {
1473 : 0 : GetSdrPageView()->PagePosToLogic(aRef);
1474 : : }
1475 : :
1476 [ # # ]: 0 : ResizeMarkedObj(aRef,aWdt,aHgt);
1477 : : }
1478 : :
1479 : : // rotate
1480 [ # # ][ # # ]: 0 : if (bRotate && (bRotateFreeAllowed || bRotate90Allowed)) {
[ # # ]
1481 : 0 : Point aRef(nRotateX,nRotateY);
1482 : :
1483 [ # # ]: 0 : if(GetSdrPageView())
1484 : : {
1485 : 0 : GetSdrPageView()->PagePosToLogic(aRef);
1486 : : }
1487 : :
1488 [ # # ]: 0 : RotateMarkedObj(aRef,nRotateAngle);
1489 : : }
1490 : :
1491 : : // set rotation point position
1492 [ # # ][ # # ]: 0 : if(bModeIsRotate && (nRotateX != nOldRotateX || nRotateY != nOldRotateY))
[ # # ]
1493 : : {
1494 : 0 : Point aNewRef1(nRotateX, nRotateY);
1495 : :
1496 [ # # ]: 0 : if(GetSdrPageView())
1497 : : {
1498 : 0 : GetSdrPageView()->PagePosToLogic(aNewRef1);
1499 : : }
1500 : :
1501 [ # # ]: 0 : SetRef1(aNewRef1);
1502 : : }
1503 : :
1504 : : // shear
1505 [ # # ][ # # ]: 0 : if (bShear && bShearAllowed) {
1506 : 0 : Point aRef(nShearX,nShearY);
1507 : :
1508 [ # # ]: 0 : if(GetSdrPageView())
1509 : : {
1510 : 0 : GetSdrPageView()->PagePosToLogic(aRef);
1511 : : }
1512 : :
1513 [ # # ]: 0 : ShearMarkedObj(aRef,nShearAngle,bShearVert);
1514 : :
1515 : : // #i74358#
1516 : : // ShearMarkedObj creates a linear combination of the existing transformation and
1517 : : // the new shear to apply. If the object is already transformed (e.g. rotated) the
1518 : : // linear combination will not decompose to the same start values again, but to a
1519 : : // new combination. Thus it makes no sense to check if the wanted shear is reached
1520 : : // or not. Taking out.
1521 : : }
1522 : :
1523 : : // change position
1524 [ # # ][ # # ]: 0 : if (bChgPos && bMoveAllowed) {
1525 [ # # ]: 0 : MoveMarkedObj(Size(nPosDX,nPosDY));
1526 : : }
1527 : :
1528 : : // protect position
1529 [ # # ][ # # ]: 0 : if(SFX_ITEM_SET == rAttr.GetItemState(SID_ATTR_TRANSFORM_PROTECT_POS, sal_True, &pPoolItem))
1530 : : {
1531 : 0 : const bool bProtPos(((const SfxBoolItem*)pPoolItem)->GetValue());
1532 : 0 : bool bChanged(false);
1533 : :
1534 [ # # ]: 0 : for(sal_uInt32 i(0); i < nMarkCount; i++)
1535 : : {
1536 [ # # ][ # # ]: 0 : pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1537 : :
1538 [ # # ][ # # ]: 0 : if(pObj->IsMoveProtect() != bProtPos)
1539 : : {
1540 : 0 : bChanged = true;
1541 [ # # ]: 0 : pObj->SetMoveProtect(bProtPos);
1542 : :
1543 [ # # ]: 0 : if(bProtPos)
1544 : : {
1545 [ # # ]: 0 : pObj->SetResizeProtect(true);
1546 : : }
1547 : : }
1548 : : }
1549 : :
1550 [ # # ]: 0 : if(bChanged)
1551 : : {
1552 : 0 : bMoveProtect = bProtPos;
1553 : :
1554 [ # # ]: 0 : if(bProtPos)
1555 : : {
1556 : 0 : bResizeProtect = true;
1557 : : }
1558 : :
1559 : : // #i77187# there is no simple method to get the toolbars updated
1560 : : // in the application. The App is listening to selection change and i
1561 : : // will use it here (even if not true). It's acceptable since changing
1562 : : // this model data is pretty rare and only possible using the F4 dialog
1563 [ # # ]: 0 : MarkListHasChanged();
1564 : : }
1565 : : }
1566 : :
1567 [ # # ]: 0 : if(!bMoveProtect)
1568 : : {
1569 : : // protect size
1570 [ # # ][ # # ]: 0 : if(SFX_ITEM_SET == rAttr.GetItemState(SID_ATTR_TRANSFORM_PROTECT_SIZE, sal_True, &pPoolItem))
1571 : : {
1572 : 0 : const bool bProtSize(((const SfxBoolItem*)pPoolItem)->GetValue());
1573 : 0 : bool bChanged(false);
1574 : :
1575 [ # # ]: 0 : for(sal_uInt32 i(0); i < nMarkCount; i++)
1576 : : {
1577 [ # # ][ # # ]: 0 : pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1578 : :
1579 [ # # ][ # # ]: 0 : if(pObj->IsResizeProtect() != bProtSize)
1580 : : {
1581 : 0 : bChanged = true;
1582 [ # # ]: 0 : pObj->SetResizeProtect(bProtSize);
1583 : : }
1584 : : }
1585 : :
1586 [ # # ]: 0 : if(bChanged)
1587 : : {
1588 : 0 : bResizeProtect = bProtSize;
1589 : :
1590 : : // #i77187# see above
1591 [ # # ]: 0 : MarkListHasChanged();
1592 : : }
1593 : : }
1594 : : }
1595 : :
1596 [ # # ][ # # ]: 0 : EndUndo();
1597 : 0 : }
1598 : :
1599 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1600 : :
1601 : 0 : sal_Bool SdrEditView::IsAlignPossible() const
1602 : : { // at least two selected objects, at least one of them movable
1603 : 0 : ForcePossibilities();
1604 : 0 : sal_uIntPtr nAnz=GetMarkedObjectCount();
1605 [ # # ]: 0 : if (nAnz==0) return sal_False; // nothing selected!
1606 [ # # ]: 0 : if (nAnz==1) return bMoveAllowed; // align single object to page
1607 : 0 : return bOneOrMoreMovable; // otherwise: MarkCount>=2
1608 : : }
1609 : :
1610 : 0 : void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert, sal_Bool bBoundRects)
1611 : : {
1612 [ # # ][ # # ]: 0 : if (eHor==SDRHALIGN_NONE && eVert==SDRVALIGN_NONE)
1613 : : return;
1614 : :
1615 [ # # ]: 0 : SortMarkedObjects();
1616 [ # # ]: 0 : if (GetMarkedObjectCount()<1)
1617 : : return;
1618 : :
1619 [ # # ]: 0 : const bool bUndo = IsUndoEnabled();
1620 [ # # ]: 0 : if( bUndo )
1621 : : {
1622 [ # # ]: 0 : XubString aStr(GetDescriptionOfMarkedObjects());
1623 [ # # ]: 0 : if (eHor==SDRHALIGN_NONE)
1624 : : {
1625 [ # # # # ]: 0 : switch (eVert)
1626 : : {
1627 [ # # ]: 0 : case SDRVALIGN_TOP : ImpTakeDescriptionStr(STR_EditAlignVTop ,aStr); break;
1628 [ # # ]: 0 : case SDRVALIGN_BOTTOM: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break;
1629 [ # # ]: 0 : case SDRVALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break;
1630 : 0 : default: break;
1631 : : }
1632 : : }
1633 [ # # ]: 0 : else if (eVert==SDRVALIGN_NONE)
1634 : : {
1635 [ # # # # ]: 0 : switch (eHor)
1636 : : {
1637 [ # # ]: 0 : case SDRHALIGN_LEFT : ImpTakeDescriptionStr(STR_EditAlignHLeft ,aStr); break;
1638 [ # # ]: 0 : case SDRHALIGN_RIGHT : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break;
1639 [ # # ]: 0 : case SDRHALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break;
1640 : 0 : default: break;
1641 : : }
1642 : : }
1643 [ # # ][ # # ]: 0 : else if (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER)
1644 : : {
1645 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditAlignCenter,aStr);
1646 : : }
1647 : : else
1648 : : {
1649 [ # # ]: 0 : ImpTakeDescriptionStr(STR_EditAlign,aStr);
1650 : : }
1651 [ # # ][ # # ]: 0 : BegUndo(aStr);
1652 : : }
1653 : :
1654 [ # # ]: 0 : Rectangle aBound;
1655 : 0 : sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
1656 : : sal_uIntPtr nm;
1657 : 0 : sal_Bool bHasFixed=sal_False;
1658 [ # # ]: 0 : for (nm=0; nm<nMarkAnz; nm++)
1659 : : {
1660 [ # # ]: 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
1661 [ # # ]: 0 : SdrObject* pObj=pM->GetMarkedSdrObj();
1662 [ # # ]: 0 : SdrObjTransformInfoRec aInfo;
1663 [ # # ]: 0 : pObj->TakeObjInfo(aInfo);
1664 [ # # ][ # # ]: 0 : if (!aInfo.bMoveAllowed || pObj->IsMoveProtect())
[ # # ][ # # ]
1665 : : {
1666 [ # # ][ # # ]: 0 : Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect());
[ # # ]
1667 [ # # ]: 0 : aBound.Union(aObjRect);
1668 : 0 : bHasFixed=sal_True;
1669 : : }
1670 : : }
1671 [ # # ]: 0 : if (!bHasFixed)
1672 : : {
1673 [ # # ]: 0 : if (nMarkAnz==1)
1674 : : { // align single object to page
1675 [ # # ]: 0 : const SdrObject* pObj=GetMarkedObjectByIndex(0L);
1676 [ # # ]: 0 : const SdrPage* pPage=pObj->GetPage();
1677 [ # # ][ # # ]: 0 : const SdrPageGridFrameList* pGFL=pPage->GetGridFrameList(GetSdrPageViewOfMarkedByIndex(0),&(pObj->GetSnapRect()));
[ # # ]
1678 : 0 : const SdrPageGridFrame* pFrame=NULL;
1679 [ # # ][ # # ]: 0 : if (pGFL!=NULL && pGFL->GetCount()!=0)
[ # # ]
1680 : : { // Writer
1681 [ # # ]: 0 : pFrame=&((*pGFL)[0]);
1682 : : }
1683 : :
1684 [ # # ]: 0 : if (pFrame!=NULL)
1685 : : { // Writer
1686 : 0 : aBound=pFrame->GetUserArea();
1687 : : }
1688 : : else
1689 : : {
1690 : 0 : aBound=Rectangle(pPage->GetLftBorder(),pPage->GetUppBorder(),
1691 [ # # ][ # # ]: 0 : pPage->GetWdt()-pPage->GetRgtBorder(),
1692 [ # # ][ # # ]: 0 : pPage->GetHgt()-pPage->GetLwrBorder());
[ # # ][ # # ]
[ # # ]
1693 : : }
1694 : : }
1695 : : else
1696 : : {
1697 [ # # ]: 0 : if (bBoundRects)
1698 [ # # ]: 0 : aBound=GetMarkedObjBoundRect();
1699 : : else
1700 [ # # ]: 0 : aBound=GetMarkedObjRect();
1701 : : }
1702 : : }
1703 [ # # ]: 0 : Point aCenter(aBound.Center());
1704 [ # # ]: 0 : for (nm=0; nm<nMarkAnz; nm++)
1705 : : {
1706 [ # # ]: 0 : SdrMark* pM=GetSdrMarkByIndex(nm);
1707 [ # # ]: 0 : SdrObject* pObj=pM->GetMarkedSdrObj();
1708 [ # # ]: 0 : SdrObjTransformInfoRec aInfo;
1709 [ # # ]: 0 : pObj->TakeObjInfo(aInfo);
1710 [ # # ][ # # ]: 0 : if (aInfo.bMoveAllowed && !pObj->IsMoveProtect())
[ # # ][ # # ]
1711 : : {
1712 : 0 : long nXMov=0;
1713 : 0 : long nYMov=0;
1714 [ # # ][ # # ]: 0 : Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect());
[ # # ]
1715 [ # # # # ]: 0 : switch (eVert)
1716 : : {
1717 : 0 : case SDRVALIGN_TOP : nYMov=aBound.Top() -aObjRect.Top() ; break;
1718 : 0 : case SDRVALIGN_BOTTOM: nYMov=aBound.Bottom()-aObjRect.Bottom() ; break;
1719 [ # # ]: 0 : case SDRVALIGN_CENTER: nYMov=aCenter.Y() -aObjRect.Center().Y(); break;
1720 : 0 : default: break;
1721 : : }
1722 [ # # # # ]: 0 : switch (eHor)
1723 : : {
1724 : 0 : case SDRHALIGN_LEFT : nXMov=aBound.Left() -aObjRect.Left() ; break;
1725 : 0 : case SDRHALIGN_RIGHT : nXMov=aBound.Right() -aObjRect.Right() ; break;
1726 [ # # ]: 0 : case SDRHALIGN_CENTER: nXMov=aCenter.X() -aObjRect.Center().X(); break;
1727 : 0 : default: break;
1728 : : }
1729 [ # # ][ # # ]: 0 : if (nXMov!=0 || nYMov!=0)
1730 : : {
1731 : : // SdrEdgeObj needs an extra SdrUndoGeoObj since the
1732 : : // connections may need to be saved
1733 [ # # ]: 0 : if( bUndo )
1734 : : {
1735 [ # # ][ # # ]: 0 : if( dynamic_cast<SdrEdgeObj*>(pObj) )
[ # # ]
1736 : : {
1737 [ # # ][ # # ]: 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
[ # # ]
1738 : : }
1739 : :
1740 [ # # ][ # # ]: 0 : AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,Size(nXMov,nYMov)));
[ # # ]
1741 : : }
1742 : :
1743 [ # # ]: 0 : pObj->Move(Size(nXMov,nYMov));
1744 : : }
1745 : : }
1746 : : }
1747 : :
1748 [ # # ]: 0 : if( bUndo )
1749 [ # # ]: 0 : EndUndo();
1750 : : }
1751 : :
1752 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|