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
10cdf0e10cSrcweir *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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/svdglev.hxx>
28cdf0e10cSrcweir #include <math.h>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <svx/svdundo.hxx>
31*4d196ef4Smseidel #include "svx/svdstr.hrc" // Namen aus der Ressource
32cdf0e10cSrcweir #include "svx/svdglob.hxx" // StringCache
33cdf0e10cSrcweir #include <svx/svdpagv.hxx>
34cdf0e10cSrcweir #include <svx/svdglue.hxx>
35cdf0e10cSrcweir #include <svx/svdtrans.hxx>
36cdf0e10cSrcweir #include <svx/svdobj.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir
ImpClearVars()39cdf0e10cSrcweir void SdrGlueEditView::ImpClearVars()
40cdf0e10cSrcweir {
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
SdrGlueEditView(SdrModel * pModel1,OutputDevice * pOut)43cdf0e10cSrcweir SdrGlueEditView::SdrGlueEditView(SdrModel* pModel1, OutputDevice* pOut):
44cdf0e10cSrcweir SdrPolyEditView(pModel1,pOut)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir ImpClearVars();
47cdf0e10cSrcweir }
48cdf0e10cSrcweir
~SdrGlueEditView()49cdf0e10cSrcweir SdrGlueEditView::~SdrGlueEditView()
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir
ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc,sal_Bool bConst,const void * p1,const void * p2,const void * p3,const void * p4,const void * p5)54cdf0e10cSrcweir void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, sal_Bool bConst, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
57cdf0e10cSrcweir for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++) {
58cdf0e10cSrcweir SdrMark* pM=GetSdrMarkByIndex(nm);
59cdf0e10cSrcweir SdrObject* pObj=pM->GetMarkedSdrObj();
60cdf0e10cSrcweir const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
61cdf0e10cSrcweir sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
62cdf0e10cSrcweir if (nPtAnz!=0) {
63cdf0e10cSrcweir SdrGluePointList* pGPL=NULL;
64cdf0e10cSrcweir if (bConst) {
65cdf0e10cSrcweir const SdrGluePointList* pConstGPL=pObj->GetGluePointList();
66cdf0e10cSrcweir pGPL=(SdrGluePointList*)pConstGPL;
67cdf0e10cSrcweir } else {
68cdf0e10cSrcweir pGPL=pObj->ForceGluePointList();
69cdf0e10cSrcweir }
70cdf0e10cSrcweir if (pGPL!=NULL)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir if(!bConst && IsUndoEnabled() )
73cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
74cdf0e10cSrcweir
75cdf0e10cSrcweir for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++)
76cdf0e10cSrcweir {
77cdf0e10cSrcweir sal_uInt16 nPtId=pPts->GetObject(nPtNum);
78cdf0e10cSrcweir sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
79cdf0e10cSrcweir if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
82cdf0e10cSrcweir (*pDoFunc)(rGP,pObj,p1,p2,p3,p4,p5);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir }
85cdf0e10cSrcweir if (!bConst)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir pObj->SetChanged();
88cdf0e10cSrcweir pObj->BroadcastObjectChange();
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir }
93cdf0e10cSrcweir if (!bConst && nMarkAnz!=0) pMod->SetChanged();
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir
ImpGetEscDir(SdrGluePoint & rGP,const SdrObject *,const void * pbFirst,const void * pnThisEsc,const void * pnRet,const void *,const void *)97cdf0e10cSrcweir static void ImpGetEscDir(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pbFirst, const void* pnThisEsc, const void* pnRet, const void*, const void*)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir sal_uInt16& nRet=*(sal_uInt16*)pnRet;
100cdf0e10cSrcweir sal_Bool& bFirst=*(sal_Bool*)pbFirst;
101cdf0e10cSrcweir if (nRet!=FUZZY) {
102cdf0e10cSrcweir sal_uInt16 nEsc=rGP.GetEscDir();
103cdf0e10cSrcweir sal_Bool bOn=(nEsc & *(sal_uInt16*)pnThisEsc)!=0;
104cdf0e10cSrcweir if (bFirst) { nRet=bOn; bFirst=sal_False; }
105cdf0e10cSrcweir else if (nRet!=bOn) nRet=FUZZY;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
IsMarkedGluePointsEscDir(sal_uInt16 nThisEsc) const109cdf0e10cSrcweir TRISTATE SdrGlueEditView::IsMarkedGluePointsEscDir(sal_uInt16 nThisEsc) const
110cdf0e10cSrcweir {
111cdf0e10cSrcweir ForceUndirtyMrkPnt();
112cdf0e10cSrcweir sal_Bool bFirst=sal_True;
113cdf0e10cSrcweir sal_uInt16 nRet=sal_False;
114cdf0e10cSrcweir ((SdrGlueEditView*)this)->ImpDoMarkedGluePoints(ImpGetEscDir,sal_True,&bFirst,&nThisEsc,&nRet);
115cdf0e10cSrcweir return (TRISTATE)nRet;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
ImpSetEscDir(SdrGluePoint & rGP,const SdrObject *,const void * pnThisEsc,const void * pbOn,const void *,const void *,const void *)118cdf0e10cSrcweir static void ImpSetEscDir(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pnThisEsc, const void* pbOn, const void*, const void*, const void*)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir sal_uInt16 nEsc=rGP.GetEscDir();
121cdf0e10cSrcweir if (*(sal_Bool*)pbOn) nEsc|=*(sal_uInt16*)pnThisEsc;
122cdf0e10cSrcweir else nEsc&=~*(sal_uInt16*)pnThisEsc;
123cdf0e10cSrcweir rGP.SetEscDir(nEsc);
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
SetMarkedGluePointsEscDir(sal_uInt16 nThisEsc,sal_Bool bOn)126cdf0e10cSrcweir void SdrGlueEditView::SetMarkedGluePointsEscDir(sal_uInt16 nThisEsc, sal_Bool bOn)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir ForceUndirtyMrkPnt();
129cdf0e10cSrcweir BegUndo(ImpGetResStr(STR_EditSetGlueEscDir),GetDescriptionOfMarkedGluePoints());
130cdf0e10cSrcweir ImpDoMarkedGluePoints(ImpSetEscDir,sal_False,&nThisEsc,&bOn);
131cdf0e10cSrcweir EndUndo();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir
ImpGetPercent(SdrGluePoint & rGP,const SdrObject *,const void * pbFirst,const void * pnRet,const void *,const void *,const void *)135cdf0e10cSrcweir static void ImpGetPercent(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pbFirst, const void* pnRet, const void*, const void*, const void*)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir sal_uInt16& nRet=*(sal_uInt16*)pnRet;
138cdf0e10cSrcweir sal_Bool& bFirst=*(sal_Bool*)pbFirst;
139cdf0e10cSrcweir if (nRet!=FUZZY) {
140cdf0e10cSrcweir bool bOn=rGP.IsPercent();
141cdf0e10cSrcweir if (bFirst) { nRet=bOn; bFirst=sal_False; }
142cdf0e10cSrcweir else if ((nRet!=0)!=bOn) nRet=FUZZY;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
IsMarkedGluePointsPercent() const146cdf0e10cSrcweir TRISTATE SdrGlueEditView::IsMarkedGluePointsPercent() const
147cdf0e10cSrcweir {
148cdf0e10cSrcweir ForceUndirtyMrkPnt();
149cdf0e10cSrcweir sal_Bool bFirst=sal_True;
150cdf0e10cSrcweir sal_uInt16 nRet=sal_True;
151cdf0e10cSrcweir ((SdrGlueEditView*)this)->ImpDoMarkedGluePoints(ImpGetPercent,sal_True,&bFirst,&nRet);
152cdf0e10cSrcweir return (TRISTATE)nRet;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
ImpSetPercent(SdrGluePoint & rGP,const SdrObject * pObj,const void * pbOn,const void *,const void *,const void *,const void *)155cdf0e10cSrcweir static void ImpSetPercent(SdrGluePoint& rGP, const SdrObject* pObj, const void* pbOn, const void*, const void*, const void*, const void*)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir Point aPos(rGP.GetAbsolutePos(*pObj));
158cdf0e10cSrcweir rGP.SetPercent(*(sal_Bool*)pbOn);
159cdf0e10cSrcweir rGP.SetAbsolutePos(aPos,*pObj);
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
SetMarkedGluePointsPercent(sal_Bool bOn)162cdf0e10cSrcweir void SdrGlueEditView::SetMarkedGluePointsPercent(sal_Bool bOn)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir ForceUndirtyMrkPnt();
165cdf0e10cSrcweir BegUndo(ImpGetResStr(STR_EditSetGluePercent),GetDescriptionOfMarkedGluePoints());
166cdf0e10cSrcweir ImpDoMarkedGluePoints(ImpSetPercent,sal_False,&bOn);
167cdf0e10cSrcweir EndUndo();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir
ImpGetAlign(SdrGluePoint & rGP,const SdrObject *,const void * pbFirst,const void * pbDontCare,const void * pbVert,const void * pnRet,const void *)171cdf0e10cSrcweir static void ImpGetAlign(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pbFirst, const void* pbDontCare, const void* pbVert, const void* pnRet, const void*)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir sal_uInt16& nRet=*(sal_uInt16*)pnRet;
174cdf0e10cSrcweir sal_Bool& bFirst=*(sal_Bool*)pbFirst;
175cdf0e10cSrcweir sal_Bool& bDontCare=*(sal_Bool*)pbDontCare;
176cdf0e10cSrcweir sal_Bool bVert=*(sal_Bool*)pbVert;
177cdf0e10cSrcweir if (!bDontCare) {
178cdf0e10cSrcweir sal_uInt16 nAlg=0;
179cdf0e10cSrcweir if (bVert) {
180cdf0e10cSrcweir nAlg=rGP.GetVertAlign();
181cdf0e10cSrcweir } else {
182cdf0e10cSrcweir nAlg=rGP.GetHorzAlign();
183cdf0e10cSrcweir }
184cdf0e10cSrcweir if (bFirst) { nRet=nAlg; bFirst=sal_False; }
185cdf0e10cSrcweir else if (nRet!=nAlg) {
186cdf0e10cSrcweir if (bVert) {
187cdf0e10cSrcweir nRet=SDRVERTALIGN_DONTCARE;
188cdf0e10cSrcweir } else {
189cdf0e10cSrcweir nRet=SDRHORZALIGN_DONTCARE;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir bDontCare=sal_True;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
GetMarkedGluePointsAlign(sal_Bool bVert) const196cdf0e10cSrcweir sal_uInt16 SdrGlueEditView::GetMarkedGluePointsAlign(sal_Bool bVert) const
197cdf0e10cSrcweir {
198cdf0e10cSrcweir ForceUndirtyMrkPnt();
199cdf0e10cSrcweir sal_Bool bFirst=sal_True;
200cdf0e10cSrcweir sal_Bool bDontCare=sal_False;
201cdf0e10cSrcweir sal_uInt16 nRet=0;
202cdf0e10cSrcweir ((SdrGlueEditView*)this)->ImpDoMarkedGluePoints(ImpGetAlign,sal_True,&bFirst,&bDontCare,&bVert,&nRet);
203cdf0e10cSrcweir return nRet;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
ImpSetAlign(SdrGluePoint & rGP,const SdrObject * pObj,const void * pbVert,const void * pnAlign,const void *,const void *,const void *)206cdf0e10cSrcweir static void ImpSetAlign(SdrGluePoint& rGP, const SdrObject* pObj, const void* pbVert, const void* pnAlign, const void*, const void*, const void*)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir Point aPos(rGP.GetAbsolutePos(*pObj));
209cdf0e10cSrcweir if (*(sal_Bool*)pbVert) { // bVert?
210cdf0e10cSrcweir rGP.SetVertAlign(*(sal_uInt16*)pnAlign);
211cdf0e10cSrcweir } else {
212cdf0e10cSrcweir rGP.SetHorzAlign(*(sal_uInt16*)pnAlign);
213cdf0e10cSrcweir }
214cdf0e10cSrcweir rGP.SetAbsolutePos(aPos,*pObj);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
SetMarkedGluePointsAlign(sal_Bool bVert,sal_uInt16 nAlign)217cdf0e10cSrcweir void SdrGlueEditView::SetMarkedGluePointsAlign(sal_Bool bVert, sal_uInt16 nAlign)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir ForceUndirtyMrkPnt();
220cdf0e10cSrcweir BegUndo(ImpGetResStr(STR_EditSetGlueAlign),GetDescriptionOfMarkedGluePoints());
221cdf0e10cSrcweir ImpDoMarkedGluePoints(ImpSetAlign,sal_False,&bVert,&nAlign);
222cdf0e10cSrcweir EndUndo();
223cdf0e10cSrcweir }
224cdf0e10cSrcweir
225cdf0e10cSrcweir
IsDeleteMarkedGluePointsPossible() const226cdf0e10cSrcweir sal_Bool SdrGlueEditView::IsDeleteMarkedGluePointsPossible() const
227cdf0e10cSrcweir {
228cdf0e10cSrcweir return HasMarkedGluePoints();
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
DeleteMarkedGluePoints()231cdf0e10cSrcweir void SdrGlueEditView::DeleteMarkedGluePoints()
232cdf0e10cSrcweir {
233cdf0e10cSrcweir BrkAction();
234cdf0e10cSrcweir ForceUndirtyMrkPnt();
235cdf0e10cSrcweir const bool bUndo = IsUndoEnabled();
236cdf0e10cSrcweir if( bUndo )
237cdf0e10cSrcweir BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_DELETE);
238cdf0e10cSrcweir
239cdf0e10cSrcweir sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
240cdf0e10cSrcweir for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir SdrMark* pM=GetSdrMarkByIndex(nm);
243cdf0e10cSrcweir SdrObject* pObj=pM->GetMarkedSdrObj();
244cdf0e10cSrcweir const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
245cdf0e10cSrcweir sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
246cdf0e10cSrcweir if (nPtAnz!=0)
247cdf0e10cSrcweir {
248cdf0e10cSrcweir SdrGluePointList* pGPL=pObj->ForceGluePointList();
249cdf0e10cSrcweir if (pGPL!=NULL)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir if( bUndo )
252cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
253cdf0e10cSrcweir
254cdf0e10cSrcweir for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir sal_uInt16 nPtId=pPts->GetObject(nPtNum);
257cdf0e10cSrcweir sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
258cdf0e10cSrcweir if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir pGPL->Delete(nGlueIdx);
261cdf0e10cSrcweir }
262cdf0e10cSrcweir }
263cdf0e10cSrcweir pObj->SetChanged();
264cdf0e10cSrcweir pObj->BroadcastObjectChange();
265cdf0e10cSrcweir }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir if( bUndo )
269cdf0e10cSrcweir EndUndo();
270cdf0e10cSrcweir UnmarkAllGluePoints();
271cdf0e10cSrcweir if (nMarkAnz!=0)
272cdf0e10cSrcweir pMod->SetChanged();
273cdf0e10cSrcweir }
274cdf0e10cSrcweir
275cdf0e10cSrcweir
ImpCopyMarkedGluePoints()276cdf0e10cSrcweir void SdrGlueEditView::ImpCopyMarkedGluePoints()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir const bool bUndo = IsUndoEnabled();
279cdf0e10cSrcweir
280cdf0e10cSrcweir if( bUndo )
281cdf0e10cSrcweir BegUndo();
282cdf0e10cSrcweir
283cdf0e10cSrcweir sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
284cdf0e10cSrcweir for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++)
285cdf0e10cSrcweir {
286cdf0e10cSrcweir SdrMark* pM=GetSdrMarkByIndex(nm);
287cdf0e10cSrcweir SdrObject* pObj=pM->GetMarkedSdrObj();
288cdf0e10cSrcweir SdrUShortCont* pPts=pM->GetMarkedGluePoints();
289cdf0e10cSrcweir SdrGluePointList* pGPL=pObj->ForceGluePointList();
290cdf0e10cSrcweir sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
291cdf0e10cSrcweir if (nPtAnz!=0 && pGPL!=NULL)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir if( bUndo )
294cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
295cdf0e10cSrcweir
296cdf0e10cSrcweir for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir sal_uInt16 nPtId=pPts->GetObject(nPtNum);
299cdf0e10cSrcweir sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
300cdf0e10cSrcweir if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
301cdf0e10cSrcweir {
302*4d196ef4Smseidel SdrGluePoint aNewGP((*pGPL)[nGlueIdx]); // Clone GluePoint
303*4d196ef4Smseidel sal_uInt16 nNewIdx=pGPL->Insert(aNewGP); // and insert
304cdf0e10cSrcweir sal_uInt16 nNewId=(*pGPL)[nNewIdx].GetId(); // Id des neuen GluePoints ermitteln
305cdf0e10cSrcweir pPts->Replace(nNewId,nPtNum); // und diesen markieren (anstelle des alten)
306cdf0e10cSrcweir }
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir }
310cdf0e10cSrcweir if( bUndo )
311cdf0e10cSrcweir EndUndo();
312cdf0e10cSrcweir
313cdf0e10cSrcweir if (nMarkAnz!=0)
314cdf0e10cSrcweir pMod->SetChanged();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
317cdf0e10cSrcweir
ImpTransformMarkedGluePoints(PGlueTrFunc pTrFunc,const void * p1,const void * p2,const void * p3,const void * p4,const void * p5)318cdf0e10cSrcweir void SdrGlueEditView::ImpTransformMarkedGluePoints(PGlueTrFunc pTrFunc, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5)
319cdf0e10cSrcweir {
320cdf0e10cSrcweir sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
321cdf0e10cSrcweir for (sal_uIntPtr nm=0; nm<nMarkAnz; nm++) {
322cdf0e10cSrcweir SdrMark* pM=GetSdrMarkByIndex(nm);
323cdf0e10cSrcweir SdrObject* pObj=pM->GetMarkedSdrObj();
324cdf0e10cSrcweir const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
325cdf0e10cSrcweir sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
326cdf0e10cSrcweir if (nPtAnz!=0) {
327cdf0e10cSrcweir SdrGluePointList* pGPL=pObj->ForceGluePointList();
328cdf0e10cSrcweir if (pGPL!=NULL)
329cdf0e10cSrcweir {
330cdf0e10cSrcweir if( IsUndoEnabled() )
331cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
332cdf0e10cSrcweir
333cdf0e10cSrcweir for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++) {
334cdf0e10cSrcweir sal_uInt16 nPtId=pPts->GetObject(nPtNum);
335cdf0e10cSrcweir sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
336cdf0e10cSrcweir if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) {
337cdf0e10cSrcweir SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
338cdf0e10cSrcweir Point aPos(rGP.GetAbsolutePos(*pObj));
339cdf0e10cSrcweir (*pTrFunc)(aPos,p1,p2,p3,p4,p5);
340cdf0e10cSrcweir rGP.SetAbsolutePos(aPos,*pObj);
341cdf0e10cSrcweir }
342cdf0e10cSrcweir }
343cdf0e10cSrcweir pObj->SetChanged();
344cdf0e10cSrcweir pObj->BroadcastObjectChange();
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir }
348cdf0e10cSrcweir if (nMarkAnz!=0) pMod->SetChanged();
349cdf0e10cSrcweir }
350cdf0e10cSrcweir
351cdf0e10cSrcweir
ImpMove(Point & rPt,const void * p1,const void *,const void *,const void *,const void *)352cdf0e10cSrcweir static void ImpMove(Point& rPt, const void* p1, const void* /*p2*/, const void* /*p3*/, const void* /*p4*/, const void* /*p5*/)
353cdf0e10cSrcweir {
354cdf0e10cSrcweir rPt.X()+=((const Size*)p1)->Width();
355cdf0e10cSrcweir rPt.Y()+=((const Size*)p1)->Height();
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
MoveMarkedGluePoints(const Size & rSiz,bool bCopy)358cdf0e10cSrcweir void SdrGlueEditView::MoveMarkedGluePoints(const Size& rSiz, bool bCopy)
359cdf0e10cSrcweir {
360cdf0e10cSrcweir ForceUndirtyMrkPnt();
361cdf0e10cSrcweir XubString aStr(ImpGetResStr(STR_EditMove));
362cdf0e10cSrcweir if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
363cdf0e10cSrcweir BegUndo(aStr,GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_MOVE);
364cdf0e10cSrcweir if (bCopy) ImpCopyMarkedGluePoints();
365cdf0e10cSrcweir ImpTransformMarkedGluePoints(ImpMove,&rSiz);
366cdf0e10cSrcweir EndUndo();
367cdf0e10cSrcweir AdjustMarkHdl();
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir
ImpResize(Point & rPt,const void * p1,const void * p2,const void * p3,const void *,const void *)371cdf0e10cSrcweir static void ImpResize(Point& rPt, const void* p1, const void* p2, const void* p3, const void* /*p4*/, const void* /*p5*/)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir ResizePoint(rPt,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
ResizeMarkedGluePoints(const Point & rRef,const Fraction & xFact,const Fraction & yFact,bool bCopy)376cdf0e10cSrcweir void SdrGlueEditView::ResizeMarkedGluePoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
377cdf0e10cSrcweir {
378cdf0e10cSrcweir ForceUndirtyMrkPnt();
379cdf0e10cSrcweir XubString aStr(ImpGetResStr(STR_EditResize));
380cdf0e10cSrcweir if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
381cdf0e10cSrcweir BegUndo(aStr,GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_RESIZE);
382cdf0e10cSrcweir if (bCopy) ImpCopyMarkedGluePoints();
383cdf0e10cSrcweir ImpTransformMarkedGluePoints(ImpResize,&rRef,&xFact,&yFact);
384cdf0e10cSrcweir EndUndo();
385cdf0e10cSrcweir AdjustMarkHdl();
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir
ImpRotate(Point & rPt,const void * p1,const void *,const void * p3,const void * p4,const void *)389cdf0e10cSrcweir static void ImpRotate(Point& rPt, const void* p1, const void* /*p2*/, const void* p3, const void* p4, const void* /*p5*/)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir RotatePoint(rPt,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
RotateMarkedGluePoints(const Point & rRef,long nWink,bool bCopy)394cdf0e10cSrcweir void SdrGlueEditView::RotateMarkedGluePoints(const Point& rRef, long nWink, bool bCopy)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir ForceUndirtyMrkPnt();
397cdf0e10cSrcweir XubString aStr(ImpGetResStr(STR_EditRotate));
398cdf0e10cSrcweir if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
399cdf0e10cSrcweir BegUndo(aStr,GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_ROTATE);
400cdf0e10cSrcweir if (bCopy) ImpCopyMarkedGluePoints();
401cdf0e10cSrcweir double nSin=sin(nWink*nPi180);
402cdf0e10cSrcweir double nCos=cos(nWink*nPi180);
403cdf0e10cSrcweir ImpTransformMarkedGluePoints(ImpRotate,&rRef,&nWink,&nSin,&nCos);
404cdf0e10cSrcweir EndUndo();
405cdf0e10cSrcweir AdjustMarkHdl();
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
408*4d196ef4Smseidel /* vim: set noet sw=4 ts=4: */
409