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