Update ooo320-m1
[ooovba.git] / svx / source / svdraw / svdedtv1.cxx
blob76c3c3f3ab05aa2adf9cdb25037dd15a9405693d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdedtv1.cxx,v $
10 * $Revision: 1.30.146.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <svx/svdedtv.hxx>
35 #include <math.h>
37 #ifndef _MATH_H
38 #define _MATH_H
39 #endif
40 #include <tools/bigint.hxx>
41 #include <svtools/itemiter.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <svx/rectenum.hxx>
44 #include <svx/svxids.hrc> // fuer SID_ATTR_TRANSFORM_...
45 #include <svx/svdattr.hxx> // fuer Get/SetGeoAttr
46 #include "svditext.hxx"
47 #include "svditer.hxx"
48 #include <svx/svdtrans.hxx>
49 #include <svx/svdundo.hxx>
50 #include <svx/svdpage.hxx>
51 #include <svx/svdpagv.hxx>
52 #include <svx/svdlayer.hxx> // fuer MergeNotPersistAttr
53 #include <svx/svdattrx.hxx> // fuer MergeNotPersistAttr
54 #include <svx/svdetc.hxx> // fuer SearchOutlinerItems
55 #include <svx/svdopath.hxx> // fuer Crook
56 #include "svdstr.hrc" // Namen aus der Resource
57 #include "svdglob.hxx" // StringCache
58 #include <svx/eeitem.hxx>
59 #include <svtools/aeitem.hxx>
60 #include <svtools/whiter.hxx>
61 #include <svx/sdr/contact/objectcontact.hxx>
62 #include <svx/sdr/contact/viewcontact.hxx>
63 #include <svx/e3dsceneupdater.hxx>
64 #include <svx/obj3d.hxx>
66 ////////////////////////////////////////////////////////////////////////////////////////////////////
67 ////////////////////////////////////////////////////////////////////////////////////////////////////
68 ////////////////////////////////////////////////////////////////////////////////////////////////////
69 ////////////////////////////////////////////////////////////////////////////////////////////////////
71 // @@@@@ @@@@@ @@ @@@@@@ @@ @@ @@ @@@@@ @@ @@
72 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
73 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
74 // @@@@ @@ @@ @@ @@ @@@@@ @@ @@@@ @@@@@@@
75 // @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
76 // @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
77 // @@@@@ @@@@@ @@ @@ @ @@ @@@@@ @@ @@
79 ////////////////////////////////////////////////////////////////////////////////////////////////////
80 ////////////////////////////////////////////////////////////////////////////////////////////////////
82 void SdrEditView::SetMarkedObjRect(const Rectangle& rRect, BOOL bCopy)
84 DBG_ASSERT(!rRect.IsEmpty(),"SetMarkedObjRect() mit leerem Rect mach keinen Sinn");
85 if (rRect.IsEmpty()) return;
86 ULONG nAnz=GetMarkedObjectCount();
87 if (nAnz==0) return;
88 Rectangle aR0(GetMarkedObjRect());
89 DBG_ASSERT(!aR0.IsEmpty(),"SetMarkedObjRect(): GetMarkedObjRect() ist leer");
90 if (aR0.IsEmpty()) return;
91 long x0=aR0.Left();
92 long y0=aR0.Top();
93 long w0=aR0.Right()-x0;
94 long h0=aR0.Bottom()-y0;
95 long x1=rRect.Left();
96 long y1=rRect.Top();
97 long w1=rRect.Right()-x1;
98 long h1=rRect.Bottom()-y1;
99 XubString aStr;
100 ImpTakeDescriptionStr(STR_EditPosSize,aStr);
101 if (bCopy)
102 aStr+=ImpGetResStr(STR_EditWithCopy);
104 const bool bUndo = IsUndoEnabled();
105 if( bUndo )
106 BegUndo(aStr);
108 if (bCopy)
109 CopyMarkedObj();
111 for (ULONG nm=0; nm<nAnz; nm++)
113 SdrMark* pM=GetSdrMarkByIndex(nm);
114 SdrObject* pO=pM->GetMarkedSdrObj();
115 if( bUndo )
116 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
118 Rectangle aR1(pO->GetSnapRect());
119 if (!aR1.IsEmpty())
121 if (aR1==aR0)
123 aR1=rRect;
125 else
126 { // aR1 von aR0 nach rRect transformieren
127 aR1.Move(-x0,-y0);
128 BigInt l(aR1.Left());
129 BigInt r(aR1.Right());
130 BigInt t(aR1.Top());
131 BigInt b(aR1.Bottom());
132 if (w0!=0) {
133 l*=w1; l/=w0;
134 r*=w1; r/=w0;
135 } else {
136 l=0; r=w1;
138 if (h0!=0) {
139 t*=h1; t/=h0;
140 b*=h1; b/=h0;
141 } else {
142 t=0; b=h1;
144 aR1.Left ()=long(l);
145 aR1.Right ()=long(r);
146 aR1.Top ()=long(t);
147 aR1.Bottom()=long(b);
148 aR1.Move(x1,y1);
150 pO->SetSnapRect(aR1);
151 } else {
152 DBG_ERROR("SetMarkedObjRect(): pObj->GetSnapRect() liefert leeres Rect");
155 if( bUndo )
156 EndUndo();
159 std::vector< SdrUndoAction* > SdrEditView::CreateConnectorUndo( SdrObject& rO )
161 std::vector< SdrUndoAction* > vUndoActions;
163 if ( rO.GetBroadcaster() )
165 const SdrPage* pPage = rO.GetPage();
166 if ( pPage )
168 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
169 while( aIter.IsMore() )
171 SdrObject* pPartObj = aIter.Next();
172 if ( pPartObj->ISA( SdrEdgeObj ) )
174 if ( ( pPartObj->GetConnectedNode( sal_False ) == &rO ) ||
175 ( pPartObj->GetConnectedNode( sal_True ) == &rO ) )
177 vUndoActions.push_back( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pPartObj ) );
183 return vUndoActions;
186 void SdrEditView::AddUndoActions( std::vector< SdrUndoAction* >& rUndoActions )
188 std::vector< SdrUndoAction* >::iterator aUndoActionIter( rUndoActions.begin() );
189 while( aUndoActionIter != rUndoActions.end() )
190 AddUndo( *aUndoActionIter++ );
193 void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy)
195 const bool bUndo = IsUndoEnabled();
197 if( bUndo )
199 XubString aStr(ImpGetResStr(STR_EditMove));
200 if (bCopy)
201 aStr+=ImpGetResStr(STR_EditWithCopy);
202 // benoetigt eigene UndoGroup wegen Parameter
203 BegUndo(aStr,GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVE);
206 if (bCopy)
207 CopyMarkedObj();
209 ULONG nMarkAnz=GetMarkedObjectCount();
210 for (ULONG nm=0; nm<nMarkAnz; nm++)
212 SdrMark* pM=GetSdrMarkByIndex(nm);
213 SdrObject* pO=pM->GetMarkedSdrObj();
214 if( bUndo )
216 std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
217 AddUndoActions( vConnectorUndoActions );
218 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,rSiz));
220 pO->Move(rSiz);
223 if( bUndo )
224 EndUndo();
227 void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
229 const bool bUndo = IsUndoEnabled();
230 if( bUndo )
232 XubString aStr;
233 ImpTakeDescriptionStr(STR_EditResize,aStr);
234 if (bCopy)
235 aStr+=ImpGetResStr(STR_EditWithCopy);
236 BegUndo(aStr);
239 if (bCopy)
240 CopyMarkedObj();
242 ULONG nMarkAnz=GetMarkedObjectCount();
243 for (ULONG nm=0; nm<nMarkAnz; nm++)
245 SdrMark* pM=GetSdrMarkByIndex(nm);
246 SdrObject* pO=pM->GetMarkedSdrObj();
247 if( bUndo )
249 std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
250 AddUndoActions( vConnectorUndoActions );
251 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
253 pO->Resize(rRef,xFact,yFact);
256 if( bUndo )
257 EndUndo();
260 long SdrEditView::GetMarkedObjRotate() const
262 BOOL b1st=TRUE;
263 BOOL bOk=TRUE;
264 long nWink=0;
265 ULONG nMarkAnz=GetMarkedObjectCount();
266 for (ULONG nm=0; nm<nMarkAnz && bOk; nm++) {
267 SdrMark* pM=GetSdrMarkByIndex(nm);
268 SdrObject* pO=pM->GetMarkedSdrObj();
269 long nWink2=pO->GetRotateAngle();
270 if (b1st) nWink=nWink2;
271 else if (nWink2!=nWink) bOk=FALSE;
272 b1st=FALSE;
274 if (!bOk) nWink=0;
275 return nWink;
278 void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy)
280 const bool bUndo = IsUndoEnabled();
281 if( bUndo )
283 XubString aStr;
284 ImpTakeDescriptionStr(STR_EditRotate,aStr);
285 if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
286 BegUndo(aStr);
289 if (bCopy)
290 CopyMarkedObj();
292 double nSin=sin(nWink*nPi180);
293 double nCos=cos(nWink*nPi180);
294 const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
296 if(nMarkAnz)
298 std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
300 for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
302 SdrMark* pM = GetSdrMarkByIndex(nm);
303 SdrObject* pO = pM->GetMarkedSdrObj();
305 if( bUndo )
307 // extra undo actions for changed connector which now may hold it's layouted path (SJ)
308 std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
309 AddUndoActions( vConnectorUndoActions );
311 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
314 // set up a scene updater if object is a 3d object
315 if(dynamic_cast< E3dObject* >(pO))
317 aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pO));
320 pO->Rotate(rRef,nWink,nSin,nCos);
323 // fire scene updaters
324 while(aUpdaters.size())
326 delete aUpdaters.back();
327 aUpdaters.pop_back();
331 if( bUndo )
332 EndUndo();
335 void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy)
337 const bool bUndo = IsUndoEnabled();
339 if( bUndo )
341 XubString aStr;
342 Point aDif(rRef2-rRef1);
343 if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr);
344 else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr);
345 else if (Abs(aDif.X())==Abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr);
346 else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr);
347 if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
348 BegUndo(aStr);
351 if (bCopy)
352 CopyMarkedObj();
354 const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
356 if(nMarkAnz)
358 std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
360 for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
362 SdrMark* pM = GetSdrMarkByIndex(nm);
363 SdrObject* pO = pM->GetMarkedSdrObj();
365 if( bUndo )
367 // extra undo actions for changed connector which now may hold it's layouted path (SJ)
368 std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
369 AddUndoActions( vConnectorUndoActions );
371 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
374 // set up a scene updater if object is a 3d object
375 if(dynamic_cast< E3dObject* >(pO))
377 aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pO));
380 pO->Mirror(rRef1,rRef2);
383 // fire scene updaters
384 while(aUpdaters.size())
386 delete aUpdaters.back();
387 aUpdaters.pop_back();
391 if( bUndo )
392 EndUndo();
395 void SdrEditView::MirrorMarkedObjHorizontal(BOOL bCopy)
397 Point aCenter(GetMarkedObjRect().Center());
398 Point aPt2(aCenter);
399 aPt2.Y()++;
400 MirrorMarkedObj(aCenter,aPt2,bCopy);
403 void SdrEditView::MirrorMarkedObjVertical(BOOL bCopy)
405 Point aCenter(GetMarkedObjRect().Center());
406 Point aPt2(aCenter);
407 aPt2.X()++;
408 MirrorMarkedObj(aCenter,aPt2,bCopy);
411 long SdrEditView::GetMarkedObjShear() const
413 BOOL b1st=TRUE;
414 BOOL bOk=TRUE;
415 long nWink=0;
416 ULONG nMarkAnz=GetMarkedObjectCount();
417 for (ULONG nm=0; nm<nMarkAnz && bOk; nm++) {
418 SdrMark* pM=GetSdrMarkByIndex(nm);
419 SdrObject* pO=pM->GetMarkedSdrObj();
420 long nWink2=pO->GetShearAngle();
421 if (b1st) nWink=nWink2;
422 else if (nWink2!=nWink) bOk=FALSE;
423 b1st=FALSE;
425 if (nWink>SDRMAXSHEAR) nWink=SDRMAXSHEAR;
426 if (nWink<-SDRMAXSHEAR) nWink=-SDRMAXSHEAR;
427 if (!bOk) nWink=0;
428 return nWink;
431 void SdrEditView::ShearMarkedObj(const Point& rRef, long nWink, bool bVShear, bool bCopy)
433 const bool bUndo = IsUndoEnabled();
435 if( bUndo )
437 XubString aStr;
438 ImpTakeDescriptionStr(STR_EditShear,aStr);
439 if (bCopy)
440 aStr+=ImpGetResStr(STR_EditWithCopy);
441 BegUndo(aStr);
444 if (bCopy)
445 CopyMarkedObj();
447 double nTan=tan(nWink*nPi180);
448 ULONG nMarkAnz=GetMarkedObjectCount();
449 for (ULONG nm=0; nm<nMarkAnz; nm++)
451 SdrMark* pM=GetSdrMarkByIndex(nm);
452 SdrObject* pO=pM->GetMarkedSdrObj();
453 if( bUndo )
455 std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
456 AddUndoActions( vConnectorUndoActions );
457 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
459 pO->Shear(rRef,nWink,nTan,bVShear);
462 if( bUndo )
463 EndUndo();
466 void SdrEditView::ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad,
467 SdrCrookMode eMode, BOOL bVertical, BOOL bNoContortion, BOOL bRotate, const Rectangle& rMarkRect)
469 SdrPathObj* pPath=PTR_CAST(SdrPathObj,pO);
470 BOOL bDone = FALSE;
472 if(pPath!=NULL && !bNoContortion)
474 XPolyPolygon aXPP(pPath->GetPathPoly());
475 switch (eMode) {
476 case SDRCROOK_ROTATE : CrookRotatePoly (aXPP,rRef,rRad,bVertical); break;
477 case SDRCROOK_SLANT : CrookSlantPoly (aXPP,rRef,rRad,bVertical); break;
478 case SDRCROOK_STRETCH: CrookStretchPoly(aXPP,rRef,rRad,bVertical,rMarkRect); break;
479 } // switch
480 pPath->SetPathPoly(aXPP.getB2DPolyPolygon());
481 bDone = TRUE;
484 if(!bDone && !pPath && pO->IsPolyObj() && 0L != pO->GetPointCount())
486 // FuerPolyObj's, aber NICHT fuer SdrPathObj's, z.B. fuer's Bemassungsobjekt
487 sal_uInt32 nPtAnz(pO->GetPointCount());
488 XPolygon aXP((sal_uInt16)nPtAnz);
489 sal_uInt32 nPtNum;
491 for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
493 Point aPt(pO->GetPoint(nPtNum));
494 aXP[(sal_uInt16)nPtNum]=aPt;
497 switch (eMode)
499 case SDRCROOK_ROTATE : CrookRotatePoly (aXP,rRef,rRad,bVertical); break;
500 case SDRCROOK_SLANT : CrookSlantPoly (aXP,rRef,rRad,bVertical); break;
501 case SDRCROOK_STRETCH: CrookStretchPoly(aXP,rRef,rRad,bVertical,rMarkRect); break;
504 for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
506 // hier koennte man vieleicht auch mal das Broadcasting optimieren
507 // ist aber z.Zt. bei den 2 Punkten des Bemassungsobjekts noch nicht so tragisch
508 pO->SetPoint(aXP[(sal_uInt16)nPtNum],nPtNum);
511 bDone = TRUE;
514 if(!bDone)
516 // Fuer alle anderen oder wenn bNoContortion
517 Point aCtr0(pO->GetSnapRect().Center());
518 Point aCtr1(aCtr0);
519 sal_Bool bRotOk(sal_False);
520 double nSin(0.0), nCos(1.0);
521 double nWink(0.0);
523 if(0 != rRad.X() && 0 != rRad.Y())
525 bRotOk = bRotate;
527 switch (eMode)
529 case SDRCROOK_ROTATE : nWink=CrookRotateXPoint (aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical); bRotOk=bRotate; break;
530 case SDRCROOK_SLANT : nWink=CrookSlantXPoint (aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical); break;
531 case SDRCROOK_STRETCH: nWink=CrookStretchXPoint(aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical,rMarkRect); break;
535 aCtr1 -= aCtr0;
537 if(bRotOk)
538 pO->Rotate(aCtr0, Round(nWink/nPi180), nSin, nCos);
540 pO->Move(Size(aCtr1.X(),aCtr1.Y()));
544 void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode,
545 bool bVertical, bool bNoContortion, bool bCopy)
547 Rectangle aMarkRect(GetMarkedObjRect());
548 const bool bUndo = IsUndoEnabled();
550 bool bRotate=bNoContortion && eMode==SDRCROOK_ROTATE && IsRotateAllowed(FALSE);
552 if( bUndo )
554 XubString aStr;
555 ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr);
556 if (bCopy)
557 aStr+=ImpGetResStr(STR_EditWithCopy);
558 BegUndo(aStr);
561 if (bCopy)
562 CopyMarkedObj();
564 ULONG nMarkAnz=GetMarkedObjectCount();
565 for (ULONG nm=0; nm<nMarkAnz; nm++)
567 SdrMark* pM=GetSdrMarkByIndex(nm);
568 SdrObject* pO=pM->GetMarkedSdrObj();
569 if( bUndo )
570 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
572 const SdrObjList* pOL=pO->GetSubList();
573 if (bNoContortion || pOL==NULL) {
574 ImpCrookObj(pO,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect);
575 } else {
576 SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
577 while (aIter.IsMore()) {
578 SdrObject* pO1=aIter.Next();
579 ImpCrookObj(pO1,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect);
584 if( bUndo )
585 EndUndo();
588 void SdrEditView::ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPolygon& rDistortedRect, BOOL bNoContortion)
590 SdrPathObj* pPath = PTR_CAST(SdrPathObj, pO);
592 if(!bNoContortion && pPath)
594 XPolyPolygon aXPP(pPath->GetPathPoly());
595 aXPP.Distort(rRef, rDistortedRect);
596 pPath->SetPathPoly(aXPP.getB2DPolyPolygon());
598 else if(pO->IsPolyObj())
600 // z.B. fuer's Bemassungsobjekt
601 sal_uInt32 nPtAnz(pO->GetPointCount());
602 XPolygon aXP((sal_uInt16)nPtAnz);
603 sal_uInt32 nPtNum;
605 for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
607 Point aPt(pO->GetPoint(nPtNum));
608 aXP[(sal_uInt16)nPtNum]=aPt;
611 aXP.Distort(rRef, rDistortedRect);
613 for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
615 // hier koennte man vieleicht auch mal das Broadcasting optimieren
616 // ist aber z.Zt. bei den 2 Punkten des Bemassungsobjekts noch nicht so tragisch
617 pO->SetPoint(aXP[(sal_uInt16)nPtNum],nPtNum);
622 void SdrEditView::DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy)
624 const bool bUndo = IsUndoEnabled();
626 if( bUndo )
628 XubString aStr;
629 ImpTakeDescriptionStr(STR_EditDistort,aStr);
630 if (bCopy)
631 aStr+=ImpGetResStr(STR_EditWithCopy);
632 BegUndo(aStr);
635 if (bCopy)
636 CopyMarkedObj();
638 ULONG nMarkAnz=GetMarkedObjectCount();
639 for (ULONG nm=0; nm<nMarkAnz; nm++)
641 SdrMark* pM=GetSdrMarkByIndex(nm);
642 SdrObject* pO=pM->GetMarkedSdrObj();
643 if( bUndo )
644 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
646 Rectangle aRefRect(rRef);
647 XPolygon aRefPoly(rDistortedRect);
648 const SdrObjList* pOL=pO->GetSubList();
649 if (bNoContortion || pOL==NULL) {
650 ImpDistortObj(pO,aRefRect,aRefPoly,bNoContortion);
651 } else {
652 SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
653 while (aIter.IsMore()) {
654 SdrObject* pO1=aIter.Next();
655 ImpDistortObj(pO1,aRefRect,aRefPoly,bNoContortion);
659 if( bUndo )
660 EndUndo();
663 ////////////////////////////////////////////////////////////////////////////////////////////////////
665 void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr, BOOL /*bReplaceAll*/)
667 // bReplaceAll hat hier keinerlei Wirkung
668 Rectangle aAllSnapRect(GetMarkedObjRect());
669 const SfxPoolItem *pPoolItem=NULL;
670 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
671 long n=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
672 SetRef1(Point(n,GetRef1().Y()));
674 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
675 long n=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
676 SetRef1(Point(GetRef1().X(),n));
678 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
679 long n=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
680 SetRef2(Point(n,GetRef2().Y()));
682 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
683 long n=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
684 SetRef2(Point(GetRef2().X(),n));
686 long nAllPosX=0; BOOL bAllPosX=FALSE;
687 long nAllPosY=0; BOOL bAllPosY=FALSE;
688 long nAllWdt=0; BOOL bAllWdt=FALSE;
689 long nAllHgt=0; BOOL bAllHgt=FALSE;
690 BOOL bDoIt=FALSE;
691 if (rAttr.GetItemState(SDRATTR_ALLPOSITIONX,TRUE,&pPoolItem)==SFX_ITEM_SET) {
692 nAllPosX=((const SdrAllPositionXItem*)pPoolItem)->GetValue();
693 bAllPosX=TRUE; bDoIt=TRUE;
695 if (rAttr.GetItemState(SDRATTR_ALLPOSITIONY,TRUE,&pPoolItem)==SFX_ITEM_SET) {
696 nAllPosY=((const SdrAllPositionYItem*)pPoolItem)->GetValue();
697 bAllPosY=TRUE; bDoIt=TRUE;
699 if (rAttr.GetItemState(SDRATTR_ALLSIZEWIDTH,TRUE,&pPoolItem)==SFX_ITEM_SET) {
700 nAllWdt=((const SdrAllSizeWidthItem*)pPoolItem)->GetValue();
701 bAllWdt=TRUE; bDoIt=TRUE;
703 if (rAttr.GetItemState(SDRATTR_ALLSIZEHEIGHT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
704 nAllHgt=((const SdrAllSizeHeightItem*)pPoolItem)->GetValue();
705 bAllHgt=TRUE; bDoIt=TRUE;
707 if (bDoIt) {
708 Rectangle aRect(aAllSnapRect); // !!! fuer PolyPt's und GluePt's aber bitte noch aendern !!!
709 if (bAllPosX) aRect.Move(nAllPosX-aRect.Left(),0);
710 if (bAllPosY) aRect.Move(0,nAllPosY-aRect.Top());
711 if (bAllWdt) aRect.Right()=aAllSnapRect.Left()+nAllWdt;
712 if (bAllHgt) aRect.Bottom()=aAllSnapRect.Top()+nAllHgt;
713 SetMarkedObjRect(aRect);
715 if (rAttr.GetItemState(SDRATTR_RESIZEXALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
716 Fraction aXFact=((const SdrResizeXAllItem*)pPoolItem)->GetValue();
717 ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,Fraction(1,1));
719 if (rAttr.GetItemState(SDRATTR_RESIZEYALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
720 Fraction aYFact=((const SdrResizeYAllItem*)pPoolItem)->GetValue();
721 ResizeMarkedObj(aAllSnapRect.TopLeft(),Fraction(1,1),aYFact);
723 if (rAttr.GetItemState(SDRATTR_ROTATEALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
724 long nAngle=((const SdrRotateAllItem*)pPoolItem)->GetValue();
725 RotateMarkedObj(aAllSnapRect.Center(),nAngle);
727 if (rAttr.GetItemState(SDRATTR_HORZSHEARALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
728 long nAngle=((const SdrHorzShearAllItem*)pPoolItem)->GetValue();
729 ShearMarkedObj(aAllSnapRect.Center(),nAngle,FALSE);
731 if (rAttr.GetItemState(SDRATTR_VERTSHEARALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
732 long nAngle=((const SdrVertShearAllItem*)pPoolItem)->GetValue();
733 ShearMarkedObj(aAllSnapRect.Center(),nAngle,TRUE);
736 const bool bUndo = IsUndoEnabled();
738 // Todo: WhichRange nach Notwendigkeit ueberpruefen.
739 ULONG nMarkAnz=GetMarkedObjectCount();
740 for (ULONG nm=0; nm<nMarkAnz; nm++)
742 const SdrMark* pM=GetSdrMarkByIndex(nm);
743 SdrObject* pObj=pM->GetMarkedSdrObj();
744 //const SdrPageView* pPV=pM->GetPageView();
745 if( bUndo )
746 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
748 pObj->ApplyNotPersistAttr(rAttr);
752 void SdrEditView::MergeNotPersistAttrFromMarked(SfxItemSet& rAttr, BOOL /*bOnlyHardAttr*/) const
754 // bOnlyHardAttr hat hier keinerlei Wirkung
755 // Hier muss ausserdem noch der Nullpunkt und
756 // die PvPos berueksichtigt werden.
757 Rectangle aAllSnapRect(GetMarkedObjRect()); // !!! fuer PolyPt's und GluePt's aber bitte noch aendern !!!
758 long nAllSnapPosX=aAllSnapRect.Left();
759 long nAllSnapPosY=aAllSnapRect.Top();
760 long nAllSnapWdt=aAllSnapRect.GetWidth()-1;
761 long nAllSnapHgt=aAllSnapRect.GetHeight()-1;
762 // koennte mal zu CheckPossibilities mit rein
763 BOOL bMovProtect=FALSE,bMovProtectDC=FALSE;
764 BOOL bSizProtect=FALSE,bSizProtectDC=FALSE;
765 BOOL bPrintable =TRUE ,bPrintableDC=FALSE;
766 SdrLayerID nLayerId=0; BOOL bLayerDC=FALSE;
767 XubString aObjName; BOOL bObjNameDC=FALSE,bObjNameSet=FALSE;
768 long nSnapPosX=0; BOOL bSnapPosXDC=FALSE;
769 long nSnapPosY=0; BOOL bSnapPosYDC=FALSE;
770 long nSnapWdt=0; BOOL bSnapWdtDC=FALSE;
771 long nSnapHgt=0; BOOL bSnapHgtDC=FALSE;
772 long nLogicWdt=0; BOOL bLogicWdtDC=FALSE,bLogicWdtDiff=FALSE;
773 long nLogicHgt=0; BOOL bLogicHgtDC=FALSE,bLogicHgtDiff=FALSE;
774 long nRotAngle=0; BOOL bRotAngleDC=FALSE;
775 long nShrAngle=0; BOOL bShrAngleDC=FALSE;
776 Rectangle aSnapRect;
777 Rectangle aLogicRect;
778 ULONG nMarkAnz=GetMarkedObjectCount();
779 for (ULONG nm=0; nm<nMarkAnz; nm++) {
780 const SdrMark* pM=GetSdrMarkByIndex(nm);
781 const SdrObject* pObj=pM->GetMarkedSdrObj();
782 if (nm==0) {
783 nLayerId=pObj->GetLayer();
784 bMovProtect=pObj->IsMoveProtect();
785 bSizProtect=pObj->IsResizeProtect();
786 bPrintable =pObj->IsPrintable();
787 Rectangle aSnapRect2(pObj->GetSnapRect());
788 Rectangle aLogicRect2(pObj->GetLogicRect());
789 nSnapPosX=aSnapRect2.Left();
790 nSnapPosY=aSnapRect2.Top();
791 nSnapWdt=aSnapRect2.GetWidth()-1;
792 nSnapHgt=aSnapRect2.GetHeight()-1;
793 nLogicWdt=aLogicRect2.GetWidth()-1;
794 nLogicHgt=aLogicRect2.GetHeight()-1;
795 bLogicWdtDiff=nLogicWdt!=nSnapWdt;
796 bLogicHgtDiff=nLogicHgt!=nSnapHgt;
797 nRotAngle=pObj->GetRotateAngle();
798 nShrAngle=pObj->GetShearAngle();
799 } else {
800 if (!bLayerDC && nLayerId !=pObj->GetLayer()) bLayerDC=TRUE;
801 if (!bMovProtectDC && bMovProtect!=pObj->IsMoveProtect()) bMovProtectDC=TRUE;
802 if (!bSizProtectDC && bSizProtect!=pObj->IsResizeProtect()) bSizProtectDC=TRUE;
803 if (!bPrintableDC && bPrintable !=pObj->IsPrintable()) bPrintableDC=TRUE;
804 if (!bRotAngleDC && nRotAngle !=pObj->GetRotateAngle()) bRotAngleDC=TRUE;
805 if (!bShrAngleDC && nShrAngle !=pObj->GetShearAngle()) bShrAngleDC=TRUE;
806 if (!bSnapWdtDC || !bSnapHgtDC || !bSnapPosXDC || !bSnapPosYDC || !bLogicWdtDiff || !bLogicHgtDiff) {
807 aSnapRect=pObj->GetSnapRect();
808 if (nSnapPosX!=aSnapRect.Left()) bSnapPosXDC=TRUE;
809 if (nSnapPosY!=aSnapRect.Top()) bSnapPosYDC=TRUE;
810 if (nSnapWdt!=aSnapRect.GetWidth()-1) bSnapWdtDC=TRUE;
811 if (nSnapHgt!=aSnapRect.GetHeight()-1) bSnapHgtDC=TRUE;
813 if (!bLogicWdtDC || !bLogicHgtDC || !bLogicWdtDiff || !bLogicHgtDiff) {
814 aLogicRect=pObj->GetLogicRect();
815 if (nLogicWdt!=aLogicRect.GetWidth()-1) bLogicWdtDC=TRUE;
816 if (nLogicHgt!=aLogicRect.GetHeight()-1) bLogicHgtDC=TRUE;
817 if (!bLogicWdtDiff && aSnapRect.GetWidth()!=aLogicRect.GetWidth()) bLogicWdtDiff=TRUE;
818 if (!bLogicHgtDiff && aSnapRect.GetHeight()!=aLogicRect.GetHeight()) bLogicHgtDiff=TRUE;
821 if (!bObjNameDC ) {
822 if (!bObjNameSet) {
823 aObjName=pObj->GetName();
824 } else {
825 if (aObjName!=pObj->GetName()) bObjNameDC=TRUE;
830 if (bSnapPosXDC || nAllSnapPosX!=nSnapPosX) rAttr.Put(SdrAllPositionXItem(nAllSnapPosX));
831 if (bSnapPosYDC || nAllSnapPosY!=nSnapPosY) rAttr.Put(SdrAllPositionYItem(nAllSnapPosY));
832 if (bSnapWdtDC || nAllSnapWdt !=nSnapWdt ) rAttr.Put(SdrAllSizeWidthItem(nAllSnapWdt));
833 if (bSnapHgtDC || nAllSnapHgt !=nSnapHgt ) rAttr.Put(SdrAllSizeHeightItem(nAllSnapHgt));
835 // Items fuer reine Transformationen
836 rAttr.Put(SdrMoveXItem());
837 rAttr.Put(SdrMoveYItem());
838 rAttr.Put(SdrResizeXOneItem());
839 rAttr.Put(SdrResizeYOneItem());
840 rAttr.Put(SdrRotateOneItem());
841 rAttr.Put(SdrHorzShearOneItem());
842 rAttr.Put(SdrVertShearOneItem());
843 if (nMarkAnz>1) {
844 rAttr.Put(SdrResizeXAllItem());
845 rAttr.Put(SdrResizeYAllItem());
846 rAttr.Put(SdrRotateAllItem());
847 rAttr.Put(SdrHorzShearAllItem());
848 rAttr.Put(SdrVertShearAllItem());
851 if(eDragMode == SDRDRAG_ROTATE || eDragMode == SDRDRAG_MIRROR)
853 rAttr.Put(SdrTransformRef1XItem(GetRef1().X()));
854 rAttr.Put(SdrTransformRef1YItem(GetRef1().Y()));
857 if(eDragMode == SDRDRAG_MIRROR)
859 rAttr.Put(SdrTransformRef2XItem(GetRef2().X()));
860 rAttr.Put(SdrTransformRef2YItem(GetRef2().Y()));
864 SfxItemSet SdrEditView::GetAttrFromMarked(BOOL bOnlyHardAttr) const
866 SfxItemSet aSet(pMod->GetItemPool());
867 MergeAttrFromMarked(aSet,bOnlyHardAttr);
868 //the EE_FEATURE items should not be set with SetAttrToMarked (see error message there)
869 //so we do not set them here
870 // #i32448#
871 // Do not disable, but clear the items.
872 aSet.ClearItem(EE_FEATURE_TAB);
873 aSet.ClearItem(EE_FEATURE_LINEBR);
874 aSet.ClearItem(EE_FEATURE_NOTCONV);
875 aSet.ClearItem(EE_FEATURE_FIELD);
876 return aSet;
879 void SdrEditView::MergeAttrFromMarked(SfxItemSet& rAttr, BOOL bOnlyHardAttr) const
881 sal_uInt32 nMarkAnz(GetMarkedObjectCount());
883 for(sal_uInt32 a(0); a < nMarkAnz; a++)
885 // #80277# merging was done wrong in the prev version
886 //const SfxItemSet& rSet = GetMarkedObjectByIndex()->GetItemSet();
887 const SfxItemSet& rSet = GetMarkedObjectByIndex(a)->GetMergedItemSet();
888 SfxWhichIter aIter(rSet);
889 sal_uInt16 nWhich(aIter.FirstWhich());
891 while(nWhich)
893 if(!bOnlyHardAttr)
895 if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, FALSE))
896 rAttr.InvalidateItem(nWhich);
897 else
898 rAttr.MergeValue(rSet.Get(nWhich), TRUE);
900 else if(SFX_ITEM_SET == rSet.GetItemState(nWhich, FALSE))
902 const SfxPoolItem& rItem = rSet.Get(nWhich);
903 rAttr.MergeValue(rItem, TRUE);
906 nWhich = aIter.NextWhich();
911 void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, BOOL bReplaceAll)
913 if (AreObjectsMarked())
915 #ifdef DBG_UTIL
917 BOOL bHasEEFeatureItems=FALSE;
918 SfxItemIter aIter(rAttr);
919 const SfxPoolItem* pItem=aIter.FirstItem();
920 while (!bHasEEFeatureItems && pItem!=NULL) {
921 if (!IsInvalidItem(pItem)) {
922 USHORT nW=pItem->Which();
923 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=TRUE;
925 pItem=aIter.NextItem();
927 if(bHasEEFeatureItems)
929 String aMessage;
930 aMessage.AppendAscii("SdrEditView::SetAttrToMarked(): Das setzen von EE_FEATURE-Items an der SdrView macht keinen Sinn! Es fuehrt nur zu Overhead und nicht mehr lesbaren Dokumenten.");
931 InfoBox(NULL, aMessage).Execute();
934 #endif
936 // #103836# if the user thets character attributes to the complete shape,
937 // we want to remove all hard set character attributes with same
938 // which ids from the text. We do that later but here we remember
939 // all character attribute which id's that are set.
940 std::vector<sal_uInt16> aCharWhichIds;
942 SfxItemIter aIter(rAttr);
943 const SfxPoolItem* pItem=aIter.FirstItem();
944 while( pItem!=NULL )
946 if (!IsInvalidItem(pItem))
948 sal_uInt16 nWhich = pItem->Which();
949 if (nWhich>=EE_CHAR_START && nWhich<=EE_CHAR_END)
950 aCharWhichIds.push_back( nWhich );
952 pItem=aIter.NextItem();
956 // Joe, 2.7.98: Damit Undo nach Format.Standard auch die Textattribute korrekt restauriert
957 BOOL bHasEEItems=SearchOutlinerItems(rAttr,bReplaceAll);
959 // AW 030100: save additional geom info when para or char attributes
960 // are changed and the geom form of the text object might be changed
961 BOOL bPossibleGeomChange(FALSE);
962 SfxWhichIter aIter(rAttr);
963 UINT16 nWhich = aIter.FirstWhich();
964 while(!bPossibleGeomChange && nWhich)
966 SfxItemState eState = rAttr.GetItemState(nWhich);
967 if(eState == SFX_ITEM_SET)
969 if((nWhich >= SDRATTR_TEXT_MINFRAMEHEIGHT && nWhich <= SDRATTR_TEXT_CONTOURFRAME)
970 || nWhich == SDRATTR_3DOBJ_PERCENT_DIAGONAL
971 || nWhich == SDRATTR_3DOBJ_BACKSCALE
972 || nWhich == SDRATTR_3DOBJ_DEPTH
973 || nWhich == SDRATTR_3DOBJ_END_ANGLE
974 || nWhich == SDRATTR_3DSCENE_DISTANCE)
976 bPossibleGeomChange = TRUE;
979 nWhich = aIter.NextWhich();
982 const bool bUndo = IsUndoEnabled();
983 if( bUndo )
985 XubString aStr;
986 ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
987 BegUndo(aStr);
990 const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
991 std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
993 // create ItemSet without SFX_ITEM_DONTCARE. Put()
994 // uses it's second parameter (bInvalidAsDefault) to
995 // remove all such items to set them to default.
996 SfxItemSet aAttr(*rAttr.GetPool(), rAttr.GetRanges());
997 aAttr.Put(rAttr, TRUE);
999 // #i38135#
1000 bool bResetAnimationTimer(false);
1002 for (ULONG nm=0; nm<nMarkAnz; nm++)
1004 SdrMark* pM=GetSdrMarkByIndex(nm);
1005 SdrObject* pObj = pM->GetMarkedSdrObj();
1007 if( bUndo )
1009 std::vector< SdrUndoAction* > vConnectorUndoActions;
1010 SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >( pObj );
1011 if ( pEdgeObj )
1012 bPossibleGeomChange = TRUE;
1013 else if( bUndo )
1014 vConnectorUndoActions = CreateConnectorUndo( *pObj );
1016 AddUndoActions( vConnectorUndoActions );
1019 // new geometry undo
1020 if(bPossibleGeomChange && bUndo)
1022 // save position and size of obect, too
1023 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
1026 if( bUndo )
1028 // #i8508#
1029 // If this is a text object also rescue the OutlinerParaObject since
1030 // applying attributes to the object may change text layout when
1031 // multiple portions exist with multiple formats. If a OutlinerParaObject
1032 // really exists and needs to be rescued is evaluated in the undo
1033 // implementation itself.
1034 const bool bRescueText = dynamic_cast< SdrTextObj* >(pObj) != 0;
1036 // add attribute undo
1037 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,FALSE,bHasEEItems || bPossibleGeomChange || bRescueText));
1040 // set up a scxene updater if object is a 3d object
1041 if(dynamic_cast< E3dObject* >(pObj))
1043 aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj));
1046 // set attributes at object
1047 pObj->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
1049 if(pObj->ISA(SdrTextObj))
1051 SdrTextObj* pTextObj = ((SdrTextObj*)pObj);
1053 if(0 != aCharWhichIds.size())
1055 Rectangle aOldBoundRect = pTextObj->GetLastBoundRect();
1057 // #110094#-14 pTextObj->SendRepaintBroadcast(pTextObj->GetBoundRect());
1058 pTextObj->RemoveOutlinerCharacterAttribs( aCharWhichIds );
1060 // object has changed, should be called form
1061 // RemoveOutlinerCharacterAttribs. This will change when the text
1062 // object implementation changes.
1063 pTextObj->SetChanged();
1065 pTextObj->BroadcastObjectChange();
1066 pTextObj->SendUserCall(SDRUSERCALL_CHGATTR, aOldBoundRect);
1070 // #i38495#
1071 if(!bResetAnimationTimer)
1073 if(pObj->GetViewContact().isAnimatedInAnyViewObjectContact())
1075 bResetAnimationTimer = true;
1080 // fire scene updaters
1081 while(aUpdaters.size())
1083 delete aUpdaters.back();
1084 aUpdaters.pop_back();
1087 // #i38135#
1088 if(bResetAnimationTimer)
1090 SetAnimationTimer(0L);
1093 // besser vorher checken, was gemacht werden soll:
1094 // pObj->SetAttr() oder SetNotPersistAttr()
1095 // !!! fehlende Implementation !!!
1096 SetNotPersistAttrToMarked(rAttr,bReplaceAll);
1098 if( bUndo )
1099 EndUndo();
1103 SfxStyleSheet* SdrEditView::GetStyleSheetFromMarked() const
1105 SfxStyleSheet* pRet=NULL;
1106 BOOL b1st=TRUE;
1107 ULONG nMarkAnz=GetMarkedObjectCount();
1108 for (ULONG nm=0; nm<nMarkAnz; nm++) {
1109 SdrMark* pM=GetSdrMarkByIndex(nm);
1110 SfxStyleSheet* pSS=pM->GetMarkedSdrObj()->GetStyleSheet();
1111 if (b1st) pRet=pSS;
1112 else if (pRet!=pSS) return NULL; // verschiedene StyleSheets
1113 b1st=FALSE;
1115 return pRet;
1118 void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
1120 if (AreObjectsMarked())
1122 const bool bUndo = IsUndoEnabled();
1124 if( bUndo )
1126 XubString aStr;
1127 if (pStyleSheet!=NULL)
1128 ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr);
1129 else
1130 ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr);
1131 BegUndo(aStr);
1134 ULONG nMarkAnz=GetMarkedObjectCount();
1135 for (ULONG nm=0; nm<nMarkAnz; nm++)
1137 SdrMark* pM=GetSdrMarkByIndex(nm);
1138 if( bUndo )
1140 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj()));
1141 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true));
1143 pM->GetMarkedSdrObj()->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1146 if( bUndo )
1147 EndUndo();
1151 ////////////////////////////////////////////////////////////////////////////////////////////////////
1153 /* new interface src537 */
1154 BOOL SdrEditView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
1156 if(GetMarkedObjectCount())
1158 rTargetSet.Put(GetAttrFromMarked(bOnlyHardAttr), FALSE);
1159 return TRUE;
1161 else
1163 return SdrMarkView::GetAttributes(rTargetSet, bOnlyHardAttr);
1167 BOOL SdrEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
1169 if (GetMarkedObjectCount()!=0) {
1170 SetAttrToMarked(rSet,bReplaceAll);
1171 return TRUE;
1172 } else {
1173 return SdrMarkView::SetAttributes(rSet,bReplaceAll);
1177 SfxStyleSheet* SdrEditView::GetStyleSheet() const // SfxStyleSheet* SdrEditView::GetStyleSheet(BOOL& rOk) const
1179 if (GetMarkedObjectCount()!=0) {
1180 //rOk=TRUE;
1181 return GetStyleSheetFromMarked();
1182 } else {
1183 return SdrMarkView::GetStyleSheet(); // SdrMarkView::GetStyleSheet(rOk);
1187 BOOL SdrEditView::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
1189 if (GetMarkedObjectCount()!=0) {
1190 SetStyleSheetToMarked(pStyleSheet,bDontRemoveHardAttr);
1191 return TRUE;
1192 } else {
1193 return SdrMarkView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1197 ////////////////////////////////////////////////////////////////////////////////////////////////////
1199 SfxItemSet SdrEditView::GetGeoAttrFromMarked() const
1201 SfxItemSet aRetSet(pMod->GetItemPool(), // SID_ATTR_TRANSFORM_... aus s:svxids.hrc
1202 SID_ATTR_TRANSFORM_POS_X,SID_ATTR_TRANSFORM_ANGLE,
1203 SID_ATTR_TRANSFORM_PROTECT_POS,SID_ATTR_TRANSFORM_AUTOHEIGHT,
1204 SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS,
1206 if (AreObjectsMarked()) {
1207 SfxItemSet aMarkAttr(GetAttrFromMarked(FALSE)); // wg. AutoGrowHeight und Eckenradius
1208 Rectangle aRect(GetMarkedObjRect());
1210 if(GetSdrPageView())
1212 GetSdrPageView()->LogicToPagePos(aRect);
1215 // Position
1216 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X,aRect.Left()));
1217 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y,aRect.Top()));
1219 // Groesse
1220 long nResizeRefX=aRect.Left();
1221 long nResizeRefY=aRect.Top();
1222 if (eDragMode==SDRDRAG_ROTATE) { // Drehachse auch als Referenz fuer Resize
1223 nResizeRefX=aRef1.X();
1224 nResizeRefY=aRef1.Y();
1226 aRetSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_WIDTH,aRect.Right()-aRect.Left()));
1227 aRetSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_HEIGHT,aRect.Bottom()-aRect.Top()));
1228 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_RESIZE_REF_X,nResizeRefX));
1229 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_RESIZE_REF_Y,nResizeRefY));
1231 Point aRotateAxe(aRef1);
1233 if(GetSdrPageView())
1235 GetSdrPageView()->LogicToPagePos(aRotateAxe);
1238 // Drehung
1239 long nRotateRefX=aRect.Center().X();
1240 long nRotateRefY=aRect.Center().Y();
1241 if (eDragMode==SDRDRAG_ROTATE) {
1242 nRotateRefX=aRotateAxe.X();
1243 nRotateRefY=aRotateAxe.Y();
1245 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ANGLE,GetMarkedObjRotate()));
1246 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_X,nRotateRefX));
1247 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_Y,nRotateRefY));
1249 // Shear
1250 long nShearRefX=aRect.Left();
1251 long nShearRefY=aRect.Bottom();
1252 if (eDragMode==SDRDRAG_ROTATE) { // Drehachse auch als Referenz fuer Shear
1253 nShearRefX=aRotateAxe.X();
1254 nShearRefY=aRotateAxe.Y();
1256 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR,GetMarkedObjShear()));
1257 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_X,nShearRefX));
1258 aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_Y,nShearRefY));
1260 // Pruefen der einzelnen Objekte, ob Objekte geschuetzt sind
1261 const SdrMarkList& rMarkList=GetMarkedObjectList();
1262 ULONG nMarkCount=rMarkList.GetMarkCount();
1263 SdrObject* pObj=rMarkList.GetMark(0)->GetMarkedSdrObj();
1264 BOOL bPosProt=pObj->IsMoveProtect();
1265 BOOL bSizProt=pObj->IsResizeProtect();
1266 BOOL bPosProtDontCare=FALSE;
1267 BOOL bSizProtDontCare=FALSE;
1268 for (ULONG i=1; i<nMarkCount && (!bPosProtDontCare || !bSizProtDontCare); i++) {
1269 pObj=rMarkList.GetMark(i)->GetMarkedSdrObj();
1270 if (bPosProt!=pObj->IsMoveProtect()) bPosProtDontCare=TRUE;
1271 if (bSizProt!=pObj->IsResizeProtect()) bSizProtDontCare=TRUE;
1274 // InvalidateItem setzt das Item auf DONT_CARE
1275 if (bPosProtDontCare) {
1276 aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_PROTECT_POS);
1277 } else {
1278 aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_PROTECT_POS,bPosProt));
1280 if (bSizProtDontCare) {
1281 aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_PROTECT_SIZE);
1282 } else {
1283 aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_PROTECT_SIZE,bSizProt));
1286 SfxItemState eState=aMarkAttr.GetItemState(SDRATTR_TEXT_AUTOGROWWIDTH);
1287 BOOL bAutoGrow=((SdrTextAutoGrowWidthItem&)(aMarkAttr.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue();
1288 if (eState==SFX_ITEM_DONTCARE) {
1289 aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_AUTOWIDTH);
1290 } else if (eState==SFX_ITEM_SET) {
1291 aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_AUTOWIDTH,bAutoGrow));
1294 eState=aMarkAttr.GetItemState(SDRATTR_TEXT_AUTOGROWHEIGHT);
1295 bAutoGrow=((SdrTextAutoGrowHeightItem&)(aMarkAttr.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
1296 if (eState==SFX_ITEM_DONTCARE) {
1297 aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_AUTOHEIGHT);
1298 } else if (eState==SFX_ITEM_SET) {
1299 aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_AUTOHEIGHT,bAutoGrow));
1302 eState=aMarkAttr.GetItemState(SDRATTR_ECKENRADIUS);
1303 long nRadius=((SdrEckenradiusItem&)(aMarkAttr.Get(SDRATTR_ECKENRADIUS))).GetValue();
1304 if (eState==SFX_ITEM_DONTCARE) {
1305 aRetSet.InvalidateItem(SDRATTR_ECKENRADIUS);
1306 } else if (eState==SFX_ITEM_SET) {
1307 aRetSet.Put(SdrEckenradiusItem(nRadius));
1311 return aRetSet;
1314 Point ImpGetPoint(Rectangle aRect, RECT_POINT eRP)
1316 switch(eRP) {
1317 case RP_LT: return aRect.TopLeft();
1318 case RP_MT: return aRect.TopCenter();
1319 case RP_RT: return aRect.TopRight();
1320 case RP_LM: return aRect.LeftCenter();
1321 case RP_MM: return aRect.Center();
1322 case RP_RM: return aRect.RightCenter();
1323 case RP_LB: return aRect.BottomLeft();
1324 case RP_MB: return aRect.BottomCenter();
1325 case RP_RB: return aRect.BottomRight();
1327 return Point(); // Sollte nicht vorkommen !
1330 void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr)
1332 Rectangle aRect(GetMarkedObjRect());
1334 if(GetSdrPageView())
1336 GetSdrPageView()->LogicToPagePos(aRect);
1339 long nOldRotateAngle=GetMarkedObjRotate();
1340 long nOldShearAngle=GetMarkedObjShear();
1341 const SdrMarkList& rMarkList=GetMarkedObjectList();
1342 ULONG nMarkCount=rMarkList.GetMarkCount();
1343 SdrObject* pObj=NULL;
1345 RECT_POINT eSizePoint=RP_MM;
1346 long nPosDX=0;
1347 long nPosDY=0;
1348 long nSizX=0;
1349 long nSizY=0;
1350 long nRotateAngle=0;
1352 // #86909#
1353 sal_Bool bModeIsRotate(eDragMode == SDRDRAG_ROTATE);
1354 long nRotateX(0);
1355 long nRotateY(0);
1356 long nOldRotateX(0);
1357 long nOldRotateY(0);
1358 if(bModeIsRotate)
1360 Point aRotateAxe(aRef1);
1362 if(GetSdrPageView())
1364 GetSdrPageView()->LogicToPagePos(aRotateAxe);
1367 nRotateX = nOldRotateX = aRotateAxe.X();
1368 nRotateY = nOldRotateY = aRotateAxe.Y();
1371 long nNewShearAngle=0;
1372 long nShearAngle=0;
1373 long nShearX=0;
1374 long nShearY=0;
1375 BOOL bShearVert=FALSE;
1377 BOOL bChgPos=FALSE;
1378 BOOL bChgSiz=FALSE;
1379 BOOL bChgHgt=FALSE;
1380 BOOL bRotate=FALSE;
1381 BOOL bShear =FALSE;
1383 BOOL bSetAttr=FALSE;
1384 SfxItemSet aSetAttr(pMod->GetItemPool());
1386 const SfxPoolItem* pPoolItem=NULL;
1388 // Position
1389 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_X,TRUE,&pPoolItem)) {
1390 nPosDX=((const SfxInt32Item*)pPoolItem)->GetValue()-aRect.Left();
1391 bChgPos=TRUE;
1393 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_Y,TRUE,&pPoolItem)){
1394 nPosDY=((const SfxInt32Item*)pPoolItem)->GetValue()-aRect.Top();
1395 bChgPos=TRUE;
1397 // Groesse
1398 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_WIDTH,TRUE,&pPoolItem)) {
1399 nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue();
1400 bChgSiz=TRUE;
1402 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,TRUE,&pPoolItem)) {
1403 nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue();
1404 bChgSiz=TRUE;
1405 bChgHgt=TRUE;
1407 if (bChgSiz) {
1408 eSizePoint=(RECT_POINT)((const SfxAllEnumItem&)rAttr.Get(SID_ATTR_TRANSFORM_SIZE_POINT)).GetValue();
1411 // Rotation
1412 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ANGLE,TRUE,&pPoolItem)) {
1413 nRotateAngle=((const SfxInt32Item*)pPoolItem)->GetValue()-nOldRotateAngle;
1414 bRotate = (nRotateAngle != 0);
1417 // #86909# pos rot point x
1418 if(bRotate || SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ROT_X, TRUE ,&pPoolItem))
1419 nRotateX = ((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_ROT_X)).GetValue();
1421 // #86909# pos rot point y
1422 if(bRotate || SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ROT_Y, TRUE ,&pPoolItem))
1423 nRotateY = ((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_ROT_Y)).GetValue();
1425 // Shear
1426 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_SHEAR,TRUE,&pPoolItem)) {
1427 nNewShearAngle=((const SfxInt32Item*)pPoolItem)->GetValue();
1428 if (nNewShearAngle>SDRMAXSHEAR) nNewShearAngle=SDRMAXSHEAR;
1429 if (nNewShearAngle<-SDRMAXSHEAR) nNewShearAngle=-SDRMAXSHEAR;
1430 if (nNewShearAngle!=nOldShearAngle) {
1431 bShearVert=((const SfxBoolItem&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_VERTICAL)).GetValue();
1432 if (bShearVert) {
1433 nShearAngle=nNewShearAngle;
1434 } else {
1435 if (nNewShearAngle!=0 && nOldShearAngle!=0) {
1436 // Bugfix #25714#.
1437 double nOld=tan((double)nOldShearAngle*nPi180);
1438 double nNew=tan((double)nNewShearAngle*nPi180);
1439 nNew-=nOld;
1440 nNew=atan(nNew)/nPi180;
1441 nShearAngle=Round(nNew);
1442 } else {
1443 nShearAngle=nNewShearAngle-nOldShearAngle;
1446 bShear=nShearAngle!=0;
1447 if (bShear) {
1448 nShearX=((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_X)).GetValue();
1449 nShearY=((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_Y)).GetValue();
1454 // AutoGrow
1455 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_AUTOWIDTH,TRUE,&pPoolItem)) {
1456 BOOL bAutoGrow=((const SfxBoolItem*)pPoolItem)->GetValue();
1457 aSetAttr.Put(SdrTextAutoGrowWidthItem(bAutoGrow));
1458 bSetAttr=TRUE;
1461 if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_AUTOHEIGHT,TRUE,&pPoolItem)) {
1462 BOOL bAutoGrow=((const SfxBoolItem*)pPoolItem)->GetValue();
1463 aSetAttr.Put(SdrTextAutoGrowHeightItem(bAutoGrow));
1464 bSetAttr=TRUE;
1467 // Eckenradius
1468 if (bEdgeRadiusAllowed && SFX_ITEM_SET==rAttr.GetItemState(SDRATTR_ECKENRADIUS,TRUE,&pPoolItem)) {
1469 long nRadius=((SdrEckenradiusItem*)pPoolItem)->GetValue();
1470 aSetAttr.Put(SdrEckenradiusItem(nRadius));
1471 bSetAttr=TRUE;
1474 ForcePossibilities();
1476 BegUndo(ImpGetResStr(STR_EditTransform),GetDescriptionOfMarkedObjects());
1478 if (bSetAttr) {
1479 SetAttrToMarked(aSetAttr,FALSE);
1482 // Groesse und Hoehe aendern
1483 if (bChgSiz && (bResizeFreeAllowed || bResizePropAllowed)) {
1484 Fraction aWdt(nSizX,aRect.Right()-aRect.Left());
1485 Fraction aHgt(nSizY,aRect.Bottom()-aRect.Top());
1486 Point aRef(ImpGetPoint(aRect,eSizePoint));
1488 if(GetSdrPageView())
1490 GetSdrPageView()->PagePosToLogic(aRef);
1493 ResizeMarkedObj(aRef,aWdt,aHgt);
1496 // Rotieren
1497 if (bRotate && (bRotateFreeAllowed || bRotate90Allowed)) {
1498 Point aRef(nRotateX,nRotateY);
1500 if(GetSdrPageView())
1502 GetSdrPageView()->PagePosToLogic(aRef);
1505 RotateMarkedObj(aRef,nRotateAngle);
1508 // #86909# set rotation point position
1509 if(bModeIsRotate && (nRotateX != nOldRotateX || nRotateY != nOldRotateY))
1511 Point aNewRef1(nRotateX, nRotateY);
1513 if(GetSdrPageView())
1515 GetSdrPageView()->PagePosToLogic(aNewRef1);
1518 SetRef1(aNewRef1);
1521 // Shear
1522 if (bShear && bShearAllowed) {
1523 Point aRef(nShearX,nShearY);
1525 if(GetSdrPageView())
1527 GetSdrPageView()->PagePosToLogic(aRef);
1530 ShearMarkedObj(aRef,nShearAngle,bShearVert);
1532 // #i74358#
1533 // ShearMarkedObj creates a linear combination of the existing transformation and
1534 // the new shear to apply. If the object is already transformed (e.g. rotated) the
1535 // linear combination will not decompose to the same start values again, but to a
1536 // new combination. Thus it makes no sense to check if the wanted shear is reached
1537 // or not. Taking out.
1538 #if 0
1539 long nTempAngle=GetMarkedObjShear();
1540 if (nTempAngle!=0 && nTempAngle!=nNewShearAngle && !bShearVert) {
1541 // noch eine 2. Iteration zur Kompensation der Rundungsfehler
1542 double nOld=tan((double)nTempAngle*nPi180);
1543 double nNew=tan((double)nNewShearAngle*nPi180);
1544 nNew-=nOld;
1545 nNew=atan(nNew)/nPi180;
1546 nTempAngle=Round(nNew);
1547 if (nTempAngle!=0) {
1548 ShearMarkedObj(aRef,nTempAngle,bShearVert);
1551 #endif
1554 // Position aendern
1555 if (bChgPos && bMoveAllowed) {
1556 MoveMarkedObj(Size(nPosDX,nPosDY));
1559 // protect position
1560 if(SFX_ITEM_SET == rAttr.GetItemState(SID_ATTR_TRANSFORM_PROTECT_POS, TRUE, &pPoolItem))
1562 const sal_Bool bProtPos(((const SfxBoolItem*)pPoolItem)->GetValue());
1563 bool bChanged(false);
1565 for(sal_uInt32 i(0); i < nMarkCount; i++)
1567 pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1569 if(pObj->IsMoveProtect() != bProtPos)
1571 bChanged = true;
1572 pObj->SetMoveProtect(bProtPos);
1574 if(bProtPos)
1576 pObj->SetResizeProtect(true);
1581 if(bChanged)
1583 bMoveProtect = bProtPos;
1585 if(bProtPos)
1587 bResizeProtect = true;
1590 // #i77187# there is no simple method to get the toolbars updated
1591 // in the application. The App is listening to selection change and i
1592 // will use it here (even if not true). It's acceptable since changing
1593 // this model data is pretty rare and only possible using the F4 dialog
1594 MarkListHasChanged();
1598 if(!bMoveProtect)
1600 // protect size
1601 if(SFX_ITEM_SET == rAttr.GetItemState(SID_ATTR_TRANSFORM_PROTECT_SIZE, TRUE, &pPoolItem))
1603 const sal_Bool bProtSize(((const SfxBoolItem*)pPoolItem)->GetValue());
1604 bool bChanged(false);
1606 for(sal_uInt32 i(0); i < nMarkCount; i++)
1608 pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1610 if(pObj->IsResizeProtect() != bProtSize)
1612 bChanged = true;
1613 pObj->SetResizeProtect(bProtSize);
1617 if(bChanged)
1619 bResizeProtect = bProtSize;
1621 // #i77187# see above
1622 MarkListHasChanged();
1627 EndUndo();
1630 ////////////////////////////////////////////////////////////////////////////////////////////////////
1632 BOOL SdrEditView::IsAlignPossible() const
1633 { // Mindestens 2 markierte Objekte, davon mind. 1 beweglich
1634 ForcePossibilities();
1635 ULONG nAnz=GetMarkedObjectCount();
1636 if (nAnz==0) return FALSE; // Nix markiert!
1637 if (nAnz==1) return bMoveAllowed; // einzelnes Obj an der Seite ausrichten
1638 return bOneOrMoreMovable; // ansonsten ist MarkCount>=2
1641 void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert, BOOL bBoundRects)
1643 if (eHor==SDRHALIGN_NONE && eVert==SDRVALIGN_NONE)
1644 return;
1646 SortMarkedObjects();
1647 if (GetMarkedObjectCount()<1)
1648 return;
1650 const bool bUndo = IsUndoEnabled();
1651 if( bUndo )
1653 XubString aStr(GetDescriptionOfMarkedObjects());
1654 if (eHor==SDRHALIGN_NONE)
1656 switch (eVert)
1658 case SDRVALIGN_TOP : ImpTakeDescriptionStr(STR_EditAlignVTop ,aStr); break;
1659 case SDRVALIGN_BOTTOM: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break;
1660 case SDRVALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break;
1661 default: break;
1664 else if (eVert==SDRVALIGN_NONE)
1666 switch (eHor)
1668 case SDRHALIGN_LEFT : ImpTakeDescriptionStr(STR_EditAlignHLeft ,aStr); break;
1669 case SDRHALIGN_RIGHT : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break;
1670 case SDRHALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break;
1671 default: break;
1674 else if (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER)
1676 ImpTakeDescriptionStr(STR_EditAlignCenter,aStr);
1678 else
1680 ImpTakeDescriptionStr(STR_EditAlign,aStr);
1682 BegUndo(aStr);
1685 Rectangle aBound;
1686 ULONG nMarkAnz=GetMarkedObjectCount();
1687 ULONG nm;
1688 BOOL bHasFixed=FALSE;
1689 for (nm=0; nm<nMarkAnz; nm++)
1691 SdrMark* pM=GetSdrMarkByIndex(nm);
1692 SdrObject* pObj=pM->GetMarkedSdrObj();
1693 SdrObjTransformInfoRec aInfo;
1694 pObj->TakeObjInfo(aInfo);
1695 if (!aInfo.bMoveAllowed || pObj->IsMoveProtect())
1697 Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect());
1698 aBound.Union(aObjRect);
1699 bHasFixed=TRUE;
1702 if (!bHasFixed)
1704 if (nMarkAnz==1)
1705 { // einzelnes Obj an der Seite ausrichten
1706 const SdrObject* pObj=GetMarkedObjectByIndex(0L);
1707 const SdrPage* pPage=pObj->GetPage();
1708 const SdrPageGridFrameList* pGFL=pPage->GetGridFrameList(GetSdrPageViewOfMarkedByIndex(0),&(pObj->GetSnapRect()));
1709 const SdrPageGridFrame* pFrame=NULL;
1710 if (pGFL!=NULL && pGFL->GetCount()!=0)
1711 { // Writer
1712 pFrame=&((*pGFL)[0]);
1715 if (pFrame!=NULL)
1716 { // Writer
1717 aBound=pFrame->GetUserArea();
1719 else
1721 aBound=Rectangle(pPage->GetLftBorder(),pPage->GetUppBorder(),
1722 pPage->GetWdt()-pPage->GetRgtBorder(),
1723 pPage->GetHgt()-pPage->GetLwrBorder());
1726 else
1728 if (bBoundRects)
1729 aBound=GetMarkedObjBoundRect();
1730 else
1731 aBound=GetMarkedObjRect();
1734 Point aCenter(aBound.Center());
1735 for (nm=0; nm<nMarkAnz; nm++)
1737 SdrMark* pM=GetSdrMarkByIndex(nm);
1738 SdrObject* pObj=pM->GetMarkedSdrObj();
1739 SdrObjTransformInfoRec aInfo;
1740 pObj->TakeObjInfo(aInfo);
1741 if (aInfo.bMoveAllowed && !pObj->IsMoveProtect())
1743 // SdrPageView* pPV=pM->GetPageView();
1744 long nXMov=0;
1745 long nYMov=0;
1746 Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect());
1747 switch (eVert)
1749 case SDRVALIGN_TOP : nYMov=aBound.Top() -aObjRect.Top() ; break;
1750 case SDRVALIGN_BOTTOM: nYMov=aBound.Bottom()-aObjRect.Bottom() ; break;
1751 case SDRVALIGN_CENTER: nYMov=aCenter.Y() -aObjRect.Center().Y(); break;
1752 default: break;
1754 switch (eHor)
1756 case SDRHALIGN_LEFT : nXMov=aBound.Left() -aObjRect.Left() ; break;
1757 case SDRHALIGN_RIGHT : nXMov=aBound.Right() -aObjRect.Right() ; break;
1758 case SDRHALIGN_CENTER: nXMov=aCenter.X() -aObjRect.Center().X(); break;
1759 default: break;
1761 if (nXMov!=0 || nYMov!=0)
1763 // #104104# SdrEdgeObj needs an extra SdrUndoGeoObj since the
1764 // connections may need to be saved
1765 if( bUndo )
1767 if( dynamic_cast<SdrEdgeObj*>(pObj) )
1769 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
1772 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,Size(nXMov,nYMov)));
1775 pObj->Move(Size(nXMov,nYMov));
1780 if( bUndo )
1781 EndUndo();