xref: /aoo41x/main/cui/source/tabpages/transfrm.cxx (revision 2ee96f1c)
1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2ee96f1cSAndrew Rist  * distributed with this work for additional information
6*2ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2ee96f1cSAndrew Rist  *
11*2ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2ee96f1cSAndrew Rist  *
13*2ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2ee96f1cSAndrew Rist  * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist  * under the License.
19*2ee96f1cSAndrew Rist  *
20*2ee96f1cSAndrew Rist  *************************************************************/
21*2ee96f1cSAndrew Rist 
22*2ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <tools/shl.hxx>
30cdf0e10cSrcweir #include <sfx2/app.hxx>
31cdf0e10cSrcweir #include <svx/svdview.hxx>
32cdf0e10cSrcweir #include <svx/svdobj.hxx>
33cdf0e10cSrcweir #include <svx/svdpagv.hxx>
34cdf0e10cSrcweir #include <svx/svdotext.hxx>
35cdf0e10cSrcweir #include <svx/sderitm.hxx>
36cdf0e10cSrcweir #include <svx/dialogs.hrc>
37cdf0e10cSrcweir #include <cuires.hrc>
38cdf0e10cSrcweir #include "transfrm.hrc"
39cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "transfrm.hxx"
42cdf0e10cSrcweir #include <dialmgr.hxx>
43cdf0e10cSrcweir #include "svx/dlgutil.hxx"
44cdf0e10cSrcweir #include <editeng/svxenum.hxx>
45cdf0e10cSrcweir #include "svx/anchorid.hxx"
46cdf0e10cSrcweir #include <sfx2/module.hxx>
47cdf0e10cSrcweir #include <svl/rectitem.hxx>
48cdf0e10cSrcweir #include <svl/aeitem.hxx>
49cdf0e10cSrcweir #include <swpossizetabpage.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // Toleranz fuer WorkingArea
52cdf0e10cSrcweir #define DIFF 1000
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // static ----------------------------------------------------------------
55cdf0e10cSrcweir 
56cdf0e10cSrcweir static sal_uInt16 pPosSizeRanges[] =
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_POS_X,
59cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_POS_Y,
60cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_PROTECT_POS,
61cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_PROTECT_POS,
62cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
63cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
64cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_ANCHOR,
65cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_VERT_ORIENT,
66cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_WIDTH,
67cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_SIZE_POINT,
68cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_PROTECT_POS,
69cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
70cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_AUTOWIDTH,
71cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_AUTOHEIGHT,
72cdf0e10cSrcweir 	0
73cdf0e10cSrcweir };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir static sal_uInt16 pAngleRanges[] =
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_ROT_X,
78cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_ANGLE,
79cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
80cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
81cdf0e10cSrcweir 	0
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir static sal_uInt16 pSlantRanges[] =
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	SDRATTR_ECKENRADIUS,
87cdf0e10cSrcweir 	SDRATTR_ECKENRADIUS,
88cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_SHEAR,
89cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_SHEAR_VERTICAL,
90cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
91cdf0e10cSrcweir 	SID_ATTR_TRANSFORM_INTERN,
92cdf0e10cSrcweir 	0
93cdf0e10cSrcweir };
94cdf0e10cSrcweir 
95cdf0e10cSrcweir void lcl_ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	const basegfx::B2DPoint aTopLeft(
98cdf0e10cSrcweir 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMinX()), nDigits, ePoolUnit, eDlgUnit),
99cdf0e10cSrcweir 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMinY()), nDigits, ePoolUnit, eDlgUnit));
100cdf0e10cSrcweir 	const basegfx::B2DPoint aBottomRight(
101cdf0e10cSrcweir 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxX()), nDigits, ePoolUnit, eDlgUnit),
102cdf0e10cSrcweir 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxY()), nDigits, ePoolUnit, eDlgUnit));
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	rRange = basegfx::B2DRange(aTopLeft, aBottomRight);
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir void lcl_ScaleRect(basegfx::B2DRange& rRange, const Fraction aUIScale)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	const double fFactor(1.0 / double(aUIScale));
110cdf0e10cSrcweir 	rRange = basegfx::B2DRange(rRange.getMinimum() * fFactor, rRange.getMaximum() * fFactor);
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir /*************************************************************************
114cdf0e10cSrcweir |*
115cdf0e10cSrcweir |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
116cdf0e10cSrcweir |*
117cdf0e10cSrcweir \************************************************************************/
118cdf0e10cSrcweir 
119cdf0e10cSrcweir SvxTransformTabDialog::SvxTransformTabDialog( Window* pParent, const SfxItemSet* pAttr,
120cdf0e10cSrcweir 								const SdrView* pSdrView, sal_uInt16 nAnchorTypes ) :
121cdf0e10cSrcweir 	SfxTabDialog( pParent, CUI_RES( RID_SVXDLG_TRANSFORM ), pAttr ),
122cdf0e10cSrcweir 	pView       ( pSdrView ),
123cdf0e10cSrcweir 	nAnchorCtrls(nAnchorTypes)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	DBG_ASSERT(pView, "no valid view (!)");
126cdf0e10cSrcweir 	FreeResource();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     //different positioning page in Writer
129cdf0e10cSrcweir     if(nAnchorCtrls & 0x00ff)
130cdf0e10cSrcweir     {
131cdf0e10cSrcweir         AddTabPage(RID_SVXPAGE_SWPOSSIZE, SvxSwPosSizeTabPage::Create, SvxSwPosSizeTabPage::GetRanges);
132cdf0e10cSrcweir         RemoveTabPage(RID_SVXPAGE_POSITION_SIZE);
133cdf0e10cSrcweir     }
134cdf0e10cSrcweir     else
135cdf0e10cSrcweir     {
136cdf0e10cSrcweir         AddTabPage(RID_SVXPAGE_POSITION_SIZE, SvxPositionSizeTabPage::Create, SvxPositionSizeTabPage::GetRanges);
137cdf0e10cSrcweir         RemoveTabPage(RID_SVXPAGE_SWPOSSIZE);
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	AddTabPage(RID_SVXPAGE_ANGLE, SvxAngleTabPage::Create, SvxAngleTabPage::GetRanges);
141cdf0e10cSrcweir 	AddTabPage(RID_SVXPAGE_SLANT, SvxSlantTabPage::Create, SvxSlantTabPage::GetRanges);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir // -----------------------------------------------------------------------
145cdf0e10cSrcweir 
146cdf0e10cSrcweir SvxTransformTabDialog::~SvxTransformTabDialog()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // -----------------------------------------------------------------------
151cdf0e10cSrcweir 
152cdf0e10cSrcweir void SvxTransformTabDialog::PageCreated(sal_uInt16 nId, SfxTabPage &rPage)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	switch(nId)
155cdf0e10cSrcweir 	{
156cdf0e10cSrcweir 		case RID_SVXPAGE_POSITION_SIZE:
157cdf0e10cSrcweir 		{
158cdf0e10cSrcweir             SvxPositionSizeTabPage& rSvxPos =  static_cast<SvxPositionSizeTabPage&>(rPage);
159cdf0e10cSrcweir 			rSvxPos.SetView(pView);
160cdf0e10cSrcweir 			rSvxPos.Construct();
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 			if(nAnchorCtrls & SVX_OBJ_NORESIZE)
163cdf0e10cSrcweir 			{
164cdf0e10cSrcweir 				rSvxPos.DisableResize();
165cdf0e10cSrcweir 			}
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 			if(nAnchorCtrls & SVX_OBJ_NOPROTECT)
168cdf0e10cSrcweir 			{
169cdf0e10cSrcweir 				rSvxPos.DisableProtect();
170cdf0e10cSrcweir 				rSvxPos.UpdateControlStates();
171cdf0e10cSrcweir 			}
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			break;
174cdf0e10cSrcweir 		}
175cdf0e10cSrcweir         case RID_SVXPAGE_SWPOSSIZE :
176cdf0e10cSrcweir         {
177cdf0e10cSrcweir             SvxSwPosSizeTabPage& rSwPos =  static_cast<SvxSwPosSizeTabPage&>(rPage);
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 			rSwPos.EnableAnchorTypes(nAnchorCtrls);
180cdf0e10cSrcweir             rSwPos.SetValidateFramePosLink(aValidateLink);
181cdf0e10cSrcweir             rSwPos.SetView(pView);
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 			break;
184cdf0e10cSrcweir         }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 		case RID_SVXPAGE_ANGLE:
187cdf0e10cSrcweir 		{
188cdf0e10cSrcweir             SvxAngleTabPage& rSvxAng =  static_cast<SvxAngleTabPage&>(rPage);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 			rSvxAng.SetView( pView );
191cdf0e10cSrcweir 			rSvxAng.Construct();
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 			break;
194cdf0e10cSrcweir 		}
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 		case RID_SVXPAGE_SLANT:
197cdf0e10cSrcweir 		{
198cdf0e10cSrcweir             SvxSlantTabPage& rSvxSlnt =  static_cast<SvxSlantTabPage&>(rPage);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 			rSvxSlnt.SetView( pView );
201cdf0e10cSrcweir 			rSvxSlnt.Construct();
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 			break;
204cdf0e10cSrcweir 		}
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // -----------------------------------------------------------------------
209cdf0e10cSrcweir 
210cdf0e10cSrcweir void SvxTransformTabDialog::SetValidateFramePosLink(const Link& rLink)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir     aValidateLink = rLink;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir /*************************************************************************
216cdf0e10cSrcweir |*
217cdf0e10cSrcweir |*      Dialog zum Aendern der Position des Drehwinkels und des Drehwinkels
218cdf0e10cSrcweir |*      der Grafikobjekte
219cdf0e10cSrcweir |*
220cdf0e10cSrcweir \************************************************************************/
221cdf0e10cSrcweir 
222cdf0e10cSrcweir SvxAngleTabPage::SvxAngleTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
223cdf0e10cSrcweir 	SvxTabPage              ( pParent, CUI_RES( RID_SVXPAGE_ANGLE ), rInAttrs ),
224cdf0e10cSrcweir 	aFlPosition				( this, CUI_RES( FL_POSITION ) ),
225cdf0e10cSrcweir 	aFtPosX                 ( this, CUI_RES( FT_POS_X ) ),
226cdf0e10cSrcweir 	aMtrPosX                ( this, CUI_RES( MTR_FLD_POS_X ) ),
227cdf0e10cSrcweir 	aFtPosY                 ( this, CUI_RES( FT_POS_Y ) ),
228cdf0e10cSrcweir 	aMtrPosY                ( this, CUI_RES( MTR_FLD_POS_Y ) ),
229cdf0e10cSrcweir 	aFtPosPresets			( this, CUI_RES(FT_POSPRESETS) ),
230cdf0e10cSrcweir 	aCtlRect                ( this, CUI_RES( CTL_RECT ) ),
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	aFlAngle                ( this, CUI_RES( FL_ANGLE ) ),
233cdf0e10cSrcweir 	aFtAngle                ( this, CUI_RES( FT_ANGLE ) ),
234cdf0e10cSrcweir 	aMtrAngle               ( this, CUI_RES( MTR_FLD_ANGLE ) ),
235cdf0e10cSrcweir 	aFtAnglePresets			( this, CUI_RES(FT_ANGLEPRESETS) ),
236cdf0e10cSrcweir 	aCtlAngle               ( this, CUI_RES( CTL_ANGLE ),
237cdf0e10cSrcweir 								RP_RB, 200, 80, CS_ANGLE ),
238cdf0e10cSrcweir 	rOutAttrs               ( rInAttrs )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	FreeResource();
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	// calculate PoolUnit
243cdf0e10cSrcweir 	SfxItemPool* pPool = rOutAttrs.GetPool();
244cdf0e10cSrcweir 	DBG_ASSERT( pPool, "no pool (!)" );
245cdf0e10cSrcweir 	ePoolUnit = pPool->GetMetric(SID_ATTR_TRANSFORM_POS_X);
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	aMtrAngle.SetModifyHdl(LINK( this, SvxAngleTabPage, ModifiedHdl));
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	aCtlRect.SetAccessibleRelationLabeledBy(&aFtPosPresets);
250cdf0e10cSrcweir 	aCtlRect.SetAccessibleRelationMemberOf(&aFlPosition);
251cdf0e10cSrcweir 	aCtlAngle.SetAccessibleRelationLabeledBy(&aFtAnglePresets);
252cdf0e10cSrcweir 	aCtlAngle.SetAccessibleRelationMemberOf(&aFlAngle);
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir // -----------------------------------------------------------------------
256cdf0e10cSrcweir 
257cdf0e10cSrcweir void SvxAngleTabPage::Construct()
258cdf0e10cSrcweir {
259cdf0e10cSrcweir 	DBG_ASSERT(pView, "No valid view (!)");
260cdf0e10cSrcweir 	eDlgUnit = GetModuleFieldUnit(GetItemSet());
261cdf0e10cSrcweir 	SetFieldUnit(aMtrPosX, eDlgUnit, sal_True);
262cdf0e10cSrcweir 	SetFieldUnit(aMtrPosY, eDlgUnit, sal_True);
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	if(FUNIT_MILE == eDlgUnit || FUNIT_KM == eDlgUnit)
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		aMtrPosX.SetDecimalDigits( 3 );
267cdf0e10cSrcweir 		aMtrPosY.SetDecimalDigits( 3 );
268cdf0e10cSrcweir 	}
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	{ // #i75273#
271cdf0e10cSrcweir 		Rectangle aTempRect(pView->GetAllMarkedRect());
272cdf0e10cSrcweir 		pView->GetSdrPageView()->LogicToPagePos(aTempRect);
273cdf0e10cSrcweir 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
274cdf0e10cSrcweir 	}
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	// Take anchor into account (Writer)
277cdf0e10cSrcweir 	const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 	if(rMarkList.GetMarkCount())
280cdf0e10cSrcweir 	{
281cdf0e10cSrcweir 		const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
282cdf0e10cSrcweir 		maAnchor = basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y());
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 		if(!maAnchor.equalZero()) // -> Writer
285cdf0e10cSrcweir 		{
286cdf0e10cSrcweir 			maRange = basegfx::B2DRange(maRange.getMinimum() - maAnchor, maRange.getMaximum() - maAnchor);
287cdf0e10cSrcweir 		}
288cdf0e10cSrcweir 	}
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 	// take scale into account
291cdf0e10cSrcweir 	const Fraction aUIScale(pView->GetModel()->GetUIScale());
292cdf0e10cSrcweir 	lcl_ScaleRect(maRange, aUIScale);
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	// take UI units into account
295cdf0e10cSrcweir 	sal_uInt16 nDigits(aMtrPosX.GetDecimalDigits());
296cdf0e10cSrcweir 	lcl_ConvertRect(maRange, nDigits, (MapUnit)ePoolUnit, eDlgUnit);
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	if(!pView->IsRotateAllowed())
299cdf0e10cSrcweir 	{
300cdf0e10cSrcweir 		aFlPosition.Disable();
301cdf0e10cSrcweir 		aFtPosX.Disable();
302cdf0e10cSrcweir 		aMtrPosX.Disable();
303cdf0e10cSrcweir 		aFtPosY.Disable();
304cdf0e10cSrcweir 		aMtrPosY.Disable();
305cdf0e10cSrcweir 		aFtPosPresets.Disable();
306cdf0e10cSrcweir 		aCtlRect.Disable();
307cdf0e10cSrcweir 		aFlAngle.Disable();
308cdf0e10cSrcweir 		aFtAngle.Disable();
309cdf0e10cSrcweir 		aMtrAngle.Disable();
310cdf0e10cSrcweir 		aFtAnglePresets.Disable();
311cdf0e10cSrcweir 		aCtlAngle.Disable();
312cdf0e10cSrcweir 	}
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir // -----------------------------------------------------------------------
316cdf0e10cSrcweir 
317cdf0e10cSrcweir sal_Bool SvxAngleTabPage::FillItemSet(SfxItemSet& rSet)
318cdf0e10cSrcweir {
319cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	if(aMtrAngle.IsValueModified() || aMtrPosX.IsValueModified() || aMtrPosY.IsValueModified())
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 		const double fUIScale(double(pView->GetModel()->GetUIScale()));
324cdf0e10cSrcweir 		const double fTmpX((GetCoreValue(aMtrPosX, ePoolUnit) + maAnchor.getX()) * fUIScale);
325cdf0e10cSrcweir 		const double fTmpY((GetCoreValue(aMtrPosY, ePoolUnit) + maAnchor.getY()) * fUIScale);
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 		rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE), static_cast<sal_Int32>(aMtrAngle.GetValue())));
328cdf0e10cSrcweir 		rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), basegfx::fround(fTmpX)));
329cdf0e10cSrcweir         rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), basegfx::fround(fTmpY)));
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 		bModified |= sal_True;
332cdf0e10cSrcweir 	}
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	return bModified;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir // -----------------------------------------------------------------------
338cdf0e10cSrcweir 
339cdf0e10cSrcweir void SvxAngleTabPage::Reset(const SfxItemSet& rAttrs)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir 	const double fUIScale(double(pView->GetModel()->GetUIScale()));
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	const SfxPoolItem* pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_ROT_X );
344cdf0e10cSrcweir 	if(pItem)
345cdf0e10cSrcweir 	{
346cdf0e10cSrcweir 		const double fTmp(((double)((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getX()) / fUIScale);
347cdf0e10cSrcweir 		SetMetricValue(aMtrPosX, basegfx::fround(fTmp), ePoolUnit);
348cdf0e10cSrcweir 	}
349cdf0e10cSrcweir 	else
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		aMtrPosX.SetText( String() );
352cdf0e10cSrcweir 	}
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 	pItem = GetItem(rAttrs, SID_ATTR_TRANSFORM_ROT_Y);
355cdf0e10cSrcweir 	if(pItem)
356cdf0e10cSrcweir 	{
357cdf0e10cSrcweir 		const double fTmp(((double)((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getY()) / fUIScale);
358cdf0e10cSrcweir 		SetMetricValue(aMtrPosY, basegfx::fround(fTmp), ePoolUnit);
359cdf0e10cSrcweir 	}
360cdf0e10cSrcweir 	else
361cdf0e10cSrcweir 	{
362cdf0e10cSrcweir 		aMtrPosX.SetText( String() );
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_ANGLE );
366cdf0e10cSrcweir 	if(pItem)
367cdf0e10cSrcweir 	{
368cdf0e10cSrcweir 		aMtrAngle.SetValue(((const SfxInt32Item*)pItem)->GetValue());
369cdf0e10cSrcweir 	}
370cdf0e10cSrcweir 	else
371cdf0e10cSrcweir 	{
372cdf0e10cSrcweir 		aMtrAngle.SetText( String() );
373cdf0e10cSrcweir 	}
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	aMtrAngle.SaveValue();
376cdf0e10cSrcweir 	ModifiedHdl(this);
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir // -----------------------------------------------------------------------
380cdf0e10cSrcweir 
381cdf0e10cSrcweir SfxTabPage* SvxAngleTabPage::Create( Window* pWindow, const SfxItemSet& rSet)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     return(new SvxAngleTabPage(pWindow, rSet));
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir //------------------------------------------------------------------------
387cdf0e10cSrcweir 
388cdf0e10cSrcweir sal_uInt16* SvxAngleTabPage::GetRanges()
389cdf0e10cSrcweir {
390cdf0e10cSrcweir 	return(pAngleRanges);
391cdf0e10cSrcweir }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir // -----------------------------------------------------------------------
394cdf0e10cSrcweir 
395cdf0e10cSrcweir void SvxAngleTabPage::ActivatePage(const SfxItemSet& /*rSet*/)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir // -----------------------------------------------------------------------
400cdf0e10cSrcweir 
401cdf0e10cSrcweir int SvxAngleTabPage::DeactivatePage( SfxItemSet* _pSet )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     if(_pSet)
404cdf0e10cSrcweir 	{
405cdf0e10cSrcweir         FillItemSet(*_pSet);
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	return LEAVE_PAGE;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir //------------------------------------------------------------------------
412cdf0e10cSrcweir 
413cdf0e10cSrcweir void SvxAngleTabPage::PointChanged(Window* pWindow, RECT_POINT eRP)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	if(pWindow == &aCtlRect)
416cdf0e10cSrcweir 	{
417cdf0e10cSrcweir 		switch(eRP)
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			case RP_LT:
420cdf0e10cSrcweir 			{
421cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
422cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
423cdf0e10cSrcweir 				break;
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 			case RP_MT:
426cdf0e10cSrcweir 			{
427cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
428cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
429cdf0e10cSrcweir 				break;
430cdf0e10cSrcweir 			}
431cdf0e10cSrcweir 			case RP_RT:
432cdf0e10cSrcweir 			{
433cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
434cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
435cdf0e10cSrcweir 				break;
436cdf0e10cSrcweir 			}
437cdf0e10cSrcweir 			case RP_LM:
438cdf0e10cSrcweir 			{
439cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
440cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
441cdf0e10cSrcweir 				break;
442cdf0e10cSrcweir 			}
443cdf0e10cSrcweir 			case RP_MM:
444cdf0e10cSrcweir 			{
445cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
446cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
447cdf0e10cSrcweir 				break;
448cdf0e10cSrcweir 			}
449cdf0e10cSrcweir 			case RP_RM:
450cdf0e10cSrcweir 			{
451cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
452cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
453cdf0e10cSrcweir 				break;
454cdf0e10cSrcweir 			}
455cdf0e10cSrcweir 			case RP_LB:
456cdf0e10cSrcweir 			{
457cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
458cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
459cdf0e10cSrcweir 				break;
460cdf0e10cSrcweir 			}
461cdf0e10cSrcweir 			case RP_MB:
462cdf0e10cSrcweir 			{
463cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
464cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
465cdf0e10cSrcweir 				break;
466cdf0e10cSrcweir 			}
467cdf0e10cSrcweir 			case RP_RB:
468cdf0e10cSrcweir 			{
469cdf0e10cSrcweir 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
470cdf0e10cSrcweir 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
471cdf0e10cSrcweir 				break;
472cdf0e10cSrcweir 			}
473cdf0e10cSrcweir 		}
474cdf0e10cSrcweir 	}
475cdf0e10cSrcweir 	else if(pWindow == &aCtlAngle)
476cdf0e10cSrcweir 	{
477cdf0e10cSrcweir 		switch( eRP )
478cdf0e10cSrcweir 		{
479cdf0e10cSrcweir 			case RP_LT: aMtrAngle.SetUserValue( 13500, FUNIT_NONE ); break;
480cdf0e10cSrcweir 			case RP_MT: aMtrAngle.SetUserValue(  9000, FUNIT_NONE ); break;
481cdf0e10cSrcweir 			case RP_RT: aMtrAngle.SetUserValue(  4500, FUNIT_NONE ); break;
482cdf0e10cSrcweir 			case RP_LM: aMtrAngle.SetUserValue( 18000, FUNIT_NONE ); break;
483cdf0e10cSrcweir 			case RP_RM: aMtrAngle.SetUserValue(     0, FUNIT_NONE ); break;
484cdf0e10cSrcweir 			case RP_LB: aMtrAngle.SetUserValue( 22500, FUNIT_NONE ); break;
485cdf0e10cSrcweir 			case RP_MB: aMtrAngle.SetUserValue( 27000, FUNIT_NONE ); break;
486cdf0e10cSrcweir 			case RP_RB: aMtrAngle.SetUserValue( 31500, FUNIT_NONE ); break;
487cdf0e10cSrcweir             case RP_MM: break;
488cdf0e10cSrcweir         }
489cdf0e10cSrcweir 	}
490cdf0e10cSrcweir }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir //------------------------------------------------------------------------
493cdf0e10cSrcweir 
494cdf0e10cSrcweir IMPL_LINK( SvxAngleTabPage, ModifiedHdl, void *, EMPTYARG )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir 	switch(aMtrAngle.GetValue())
497cdf0e10cSrcweir 	{
498cdf0e10cSrcweir 		case 13500: aCtlAngle.SetActualRP( RP_LT ); break;
499cdf0e10cSrcweir 		case  9000: aCtlAngle.SetActualRP( RP_MT ); break;
500cdf0e10cSrcweir 		case  4500: aCtlAngle.SetActualRP( RP_RT ); break;
501cdf0e10cSrcweir 		case 18000: aCtlAngle.SetActualRP( RP_LM ); break;
502cdf0e10cSrcweir 		case     0: aCtlAngle.SetActualRP( RP_RM ); break;
503cdf0e10cSrcweir 		case 22500: aCtlAngle.SetActualRP( RP_LB ); break;
504cdf0e10cSrcweir 		case 27000: aCtlAngle.SetActualRP( RP_MB ); break;
505cdf0e10cSrcweir 		case 31500: aCtlAngle.SetActualRP( RP_RB ); break;
506cdf0e10cSrcweir 		default:    aCtlAngle.SetActualRP( RP_MM ); break;
507cdf0e10cSrcweir 	}
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 	return( 0L );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir /*************************************************************************
513cdf0e10cSrcweir |*
514cdf0e10cSrcweir |*      Dialog zum Aendern des Eckenradius und zum Schraegstellen
515cdf0e10cSrcweir |*
516cdf0e10cSrcweir \************************************************************************/
517cdf0e10cSrcweir 
518cdf0e10cSrcweir SvxSlantTabPage::SvxSlantTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
519cdf0e10cSrcweir 	SvxTabPage              ( pParent, CUI_RES( RID_SVXPAGE_SLANT ), rInAttrs ),
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 	aFlRadius               ( this, CUI_RES( FL_RADIUS ) ),
522cdf0e10cSrcweir 	aFtRadius               ( this, CUI_RES( FT_RADIUS ) ),
523cdf0e10cSrcweir 	aMtrRadius              ( this, CUI_RES( MTR_FLD_RADIUS ) ),
524cdf0e10cSrcweir 	aFlAngle                ( this, CUI_RES( FL_SLANT ) ),
525cdf0e10cSrcweir 	aFtAngle                ( this, CUI_RES( FT_ANGLE ) ),
526cdf0e10cSrcweir 	aMtrAngle               ( this, CUI_RES( MTR_FLD_ANGLE ) ),
527cdf0e10cSrcweir 	rOutAttrs               ( rInAttrs )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir 	FreeResource();
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 	// this page needs ExchangeSupport
532cdf0e10cSrcweir 	SetExchangeSupport();
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 	// evaluate PoolUnit
535cdf0e10cSrcweir 	SfxItemPool* pPool = rOutAttrs.GetPool();
536cdf0e10cSrcweir 	DBG_ASSERT( pPool, "no pool (!)" );
537cdf0e10cSrcweir 	ePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X );
538cdf0e10cSrcweir }
539cdf0e10cSrcweir 
540cdf0e10cSrcweir // -----------------------------------------------------------------------
541cdf0e10cSrcweir 
542cdf0e10cSrcweir void SvxSlantTabPage::Construct()
543cdf0e10cSrcweir {
544cdf0e10cSrcweir 	// get the range
545cdf0e10cSrcweir 	DBG_ASSERT(pView, "no valid view (!)");
546cdf0e10cSrcweir 	eDlgUnit = GetModuleFieldUnit(GetItemSet());
547cdf0e10cSrcweir 	SetFieldUnit(aMtrRadius, eDlgUnit, sal_True);
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 	{ // #i75273#
550cdf0e10cSrcweir 		Rectangle aTempRect(pView->GetAllMarkedRect());
551cdf0e10cSrcweir 		pView->GetSdrPageView()->LogicToPagePos(aTempRect);
552cdf0e10cSrcweir 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
553cdf0e10cSrcweir 	}
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir // -----------------------------------------------------------------------
557cdf0e10cSrcweir 
558cdf0e10cSrcweir sal_Bool SvxSlantTabPage::FillItemSet(SfxItemSet& rAttrs)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir 	sal_Bool  bModified = sal_False;
561cdf0e10cSrcweir 	sal_Int32 nValue = 0L;
562cdf0e10cSrcweir 	String aStr = aMtrRadius.GetText();
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	if( aStr != aMtrRadius.GetSavedValue() )
565cdf0e10cSrcweir 	{
566cdf0e10cSrcweir 		Fraction aUIScale = pView->GetModel()->GetUIScale();
567cdf0e10cSrcweir 		long nTmp = GetCoreValue( aMtrRadius, ePoolUnit );
568cdf0e10cSrcweir 		nTmp = Fraction( nTmp ) * aUIScale;
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 		rAttrs.Put( SdrEckenradiusItem( nTmp ) );
571cdf0e10cSrcweir 		bModified = sal_True;
572cdf0e10cSrcweir 	}
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 	aStr = aMtrAngle.GetText();
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 	if( aStr != aMtrAngle.GetSavedValue() )
577cdf0e10cSrcweir 	{
578cdf0e10cSrcweir 		nValue = static_cast<sal_Int32>(aMtrAngle.GetValue());
579cdf0e10cSrcweir 		rAttrs.Put( SfxInt32Item( SID_ATTR_TRANSFORM_SHEAR, nValue ) );
580cdf0e10cSrcweir 		bModified = sal_True;
581cdf0e10cSrcweir 	}
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	if( bModified )
584cdf0e10cSrcweir 	{
585cdf0e10cSrcweir 		// Referenzpunkt setzen
586cdf0e10cSrcweir 		// #75897#
587cdf0e10cSrcweir 		Rectangle aObjectRect(pView->GetAllMarkedRect());
588cdf0e10cSrcweir 		pView->GetSdrPageView()->LogicToPagePos(aObjectRect);
589cdf0e10cSrcweir 		Point aPt = aObjectRect.Center();
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 		rAttrs.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_X, aPt.X()));
592cdf0e10cSrcweir 		rAttrs.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_Y, aPt.Y()));
593cdf0e10cSrcweir 		rAttrs.Put( SfxBoolItem( SID_ATTR_TRANSFORM_SHEAR_VERTICAL, sal_False ) );
594cdf0e10cSrcweir 	}
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	return( bModified );
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir // -----------------------------------------------------------------------
600cdf0e10cSrcweir 
601cdf0e10cSrcweir void SvxSlantTabPage::Reset(const SfxItemSet& rAttrs)
602cdf0e10cSrcweir {
603cdf0e10cSrcweir 	// if the view has selected objects, items with SFX_ITEM_DEFAULT need to be disabled
604cdf0e10cSrcweir 	const SfxPoolItem* pItem;
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	// Eckenradius
607cdf0e10cSrcweir 	if(!pView->IsEdgeRadiusAllowed())
608cdf0e10cSrcweir 	{
609cdf0e10cSrcweir 		aFlRadius.Disable();
610cdf0e10cSrcweir 		aFtRadius.Disable();
611cdf0e10cSrcweir 		aMtrRadius.Disable();
612cdf0e10cSrcweir 		aMtrRadius.SetText( String() );
613cdf0e10cSrcweir 	}
614cdf0e10cSrcweir 	else
615cdf0e10cSrcweir 	{
616cdf0e10cSrcweir 		pItem = GetItem( rAttrs, SDRATTR_ECKENRADIUS );
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 		if( pItem )
619cdf0e10cSrcweir 		{
620cdf0e10cSrcweir 			const double fUIScale(double(pView->GetModel()->GetUIScale()));
621cdf0e10cSrcweir 			const double fTmp((double)((const SdrEckenradiusItem*)pItem)->GetValue() / fUIScale);
622cdf0e10cSrcweir 			SetMetricValue(aMtrRadius, basegfx::fround(fTmp), ePoolUnit);
623cdf0e10cSrcweir 		}
624cdf0e10cSrcweir 		else
625cdf0e10cSrcweir 		{
626cdf0e10cSrcweir 			aMtrRadius.SetText( String() );
627cdf0e10cSrcweir 		}
628cdf0e10cSrcweir 	}
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 	aMtrRadius.SaveValue();
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	// Schraegstellen: Winkel
633cdf0e10cSrcweir 	if( !pView->IsShearAllowed() )
634cdf0e10cSrcweir 	{
635cdf0e10cSrcweir 		aFlAngle.Disable();
636cdf0e10cSrcweir 		aFtAngle.Disable();
637cdf0e10cSrcweir 		aMtrAngle.Disable();
638cdf0e10cSrcweir 		aMtrAngle.SetText( String() );
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir 	else
641cdf0e10cSrcweir 	{
642cdf0e10cSrcweir 		pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_SHEAR );
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 		if( pItem )
645cdf0e10cSrcweir 		{
646cdf0e10cSrcweir 			aMtrAngle.SetValue( ( (const SfxInt32Item*)pItem )->GetValue() );
647cdf0e10cSrcweir 		}
648cdf0e10cSrcweir 		else
649cdf0e10cSrcweir 		{
650cdf0e10cSrcweir 			aMtrAngle.SetText( String() );
651cdf0e10cSrcweir 		}
652cdf0e10cSrcweir 	}
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	aMtrAngle.SaveValue();
655cdf0e10cSrcweir }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir // -----------------------------------------------------------------------
658cdf0e10cSrcweir 
659cdf0e10cSrcweir SfxTabPage* SvxSlantTabPage::Create( Window* pWindow, const SfxItemSet& rOutAttrs )
660cdf0e10cSrcweir {
661cdf0e10cSrcweir 	return( new SvxSlantTabPage( pWindow, rOutAttrs ) );
662cdf0e10cSrcweir }
663cdf0e10cSrcweir 
664cdf0e10cSrcweir //------------------------------------------------------------------------
665cdf0e10cSrcweir 
666cdf0e10cSrcweir sal_uInt16* SvxSlantTabPage::GetRanges()
667cdf0e10cSrcweir {
668cdf0e10cSrcweir 	return( pSlantRanges );
669cdf0e10cSrcweir }
670cdf0e10cSrcweir 
671cdf0e10cSrcweir // -----------------------------------------------------------------------
672cdf0e10cSrcweir 
673cdf0e10cSrcweir void SvxSlantTabPage::ActivatePage( const SfxItemSet& rSet )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir 	SfxRectangleItem* pRectItem = NULL;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN ) , sal_False, (const SfxPoolItem**) &pRectItem ) )
678cdf0e10cSrcweir 	{
679cdf0e10cSrcweir 		const Rectangle aTempRect(pRectItem->GetValue());
680cdf0e10cSrcweir 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
681cdf0e10cSrcweir 	}
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir // -----------------------------------------------------------------------
685cdf0e10cSrcweir 
686cdf0e10cSrcweir int SvxSlantTabPage::DeactivatePage( SfxItemSet* _pSet )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir     if(_pSet)
689cdf0e10cSrcweir 	{
690cdf0e10cSrcweir         FillItemSet(*_pSet);
691cdf0e10cSrcweir 	}
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	return LEAVE_PAGE;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir //------------------------------------------------------------------------
697cdf0e10cSrcweir 
698cdf0e10cSrcweir void SvxSlantTabPage::PointChanged( Window* , RECT_POINT  )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir }
701cdf0e10cSrcweir 
702cdf0e10cSrcweir /*************************************************************************
703cdf0e10cSrcweir |*
704cdf0e10cSrcweir |*      Dialog for changing position and size of graphic objects
705cdf0e10cSrcweir |*
706cdf0e10cSrcweir \************************************************************************/
707cdf0e10cSrcweir 
708cdf0e10cSrcweir SvxPositionSizeTabPage::SvxPositionSizeTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
709cdf0e10cSrcweir 	SvxTabPage      ( pParent, CUI_RES( RID_SVXPAGE_POSITION_SIZE ), rInAttrs ),
710cdf0e10cSrcweir 	maFlPosition		( this, CUI_RES( FL_POSITION ) ),
711cdf0e10cSrcweir 	maFtPosX			( this, CUI_RES( FT_POS_X ) ),
712cdf0e10cSrcweir 	maMtrPosX			( this, CUI_RES( MTR_FLD_POS_X ) ),
713cdf0e10cSrcweir 	maFtPosY			( this, CUI_RES( FT_POS_Y ) ),
714cdf0e10cSrcweir 	maMtrPosY			( this, CUI_RES( MTR_FLD_POS_Y ) ),
715cdf0e10cSrcweir     maFtPosReference    ( this, CUI_RES( FT_POSREFERENCE ) ),
716cdf0e10cSrcweir     maCtlPos            ( this, CUI_RES( CTL_POSRECT ), RP_LT ),
717cdf0e10cSrcweir 
718cdf0e10cSrcweir     maFlSize                         ( this, CUI_RES( FL_SIZE ) ),
719cdf0e10cSrcweir 	maFtWidth                        ( this, CUI_RES( FT_WIDTH ) ),
720cdf0e10cSrcweir 	maMtrWidth                       ( this, CUI_RES( MTR_FLD_WIDTH ) ),
721cdf0e10cSrcweir 	maFtHeight                       ( this, CUI_RES( FT_HEIGHT ) ),
722cdf0e10cSrcweir 	maMtrHeight                      ( this, CUI_RES( MTR_FLD_HEIGHT ) ),
723cdf0e10cSrcweir 	maCbxScale                       ( this, CUI_RES( CBX_SCALE ) ),
724cdf0e10cSrcweir     maFtSizeReference                ( this, CUI_RES( FT_SIZEREFERENCE) ),
725cdf0e10cSrcweir     maCtlSize                        ( this, CUI_RES( CTL_SIZERECT ), RP_LT ),
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     maFlProtect         ( this, CUI_RES( FL_PROTECT) ),
728cdf0e10cSrcweir     maTsbPosProtect     ( this, CUI_RES( TSB_POSPROTECT ) ),
729cdf0e10cSrcweir     maTsbSizeProtect                 ( this, CUI_RES( TSB_SIZEPROTECT ) ),
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     maFlAdjust                       ( this, CUI_RES( FL_ADJUST ) ),
733cdf0e10cSrcweir 	maTsbAutoGrowWidth				( this, CUI_RES( TSB_AUTOGROW_WIDTH ) ),
734cdf0e10cSrcweir 	maTsbAutoGrowHeight				( this, CUI_RES( TSB_AUTOGROW_HEIGHT ) ),
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 	maFlDivider						(this, CUI_RES( FL_DIVIDER ) ),
737cdf0e10cSrcweir 
738cdf0e10cSrcweir     mrOutAttrs       ( rInAttrs ),
739cdf0e10cSrcweir     mnProtectSizeState( STATE_NOCHECK ),
740cdf0e10cSrcweir     mbPageDisabled   ( sal_False ),
741cdf0e10cSrcweir     mbProtectDisabled( false ),
742cdf0e10cSrcweir     mbSizeDisabled( false ),
743cdf0e10cSrcweir     mbAdjustDisabled( true )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 	FreeResource();
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 	// this pege needs ExchangeSupport
748cdf0e10cSrcweir 	SetExchangeSupport();
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 	// evaluate PoolUnit
751cdf0e10cSrcweir 	SfxItemPool* pPool = mrOutAttrs.GetPool();
752cdf0e10cSrcweir 	DBG_ASSERT( pPool, "no pool (!)" );
753cdf0e10cSrcweir 	mePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X );
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 	meRP = RP_LT; // s.o.
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 	maMtrWidth.SetModifyHdl( LINK( this, SvxPositionSizeTabPage, ChangeWidthHdl ) );
758cdf0e10cSrcweir 	maMtrHeight.SetModifyHdl( LINK( this, SvxPositionSizeTabPage, ChangeHeightHdl ) );
759cdf0e10cSrcweir 	maCbxScale.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickAutoHdl ) );
760cdf0e10cSrcweir 
761cdf0e10cSrcweir 	maTsbAutoGrowWidth.Disable();
762cdf0e10cSrcweir 	maTsbAutoGrowHeight.Disable();
763cdf0e10cSrcweir 	maFlAdjust.Disable();
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 	// #i2379# disable controls when protected
766cdf0e10cSrcweir 	maTsbPosProtect.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ChangePosProtectHdl ) );
767cdf0e10cSrcweir 	maTsbSizeProtect.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ChangeSizeProtectHdl ) );
768cdf0e10cSrcweir 
769cdf0e10cSrcweir 	maCtlPos.SetAccessibleRelationMemberOf( &maFlPosition );
770cdf0e10cSrcweir 	maCtlSize.SetAccessibleRelationMemberOf( &maFlSize );
771cdf0e10cSrcweir     maCtlPos.SetAccessibleRelationLabeledBy( &maFtPosReference );
772cdf0e10cSrcweir 	maCtlSize.SetAccessibleRelationLabeledBy( &maFtSizeReference );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
775cdf0e10cSrcweir // -----------------------------------------------------------------------
776cdf0e10cSrcweir 
777cdf0e10cSrcweir void SvxPositionSizeTabPage::Construct()
778cdf0e10cSrcweir {
779cdf0e10cSrcweir 	// get range and work area
780cdf0e10cSrcweir 	DBG_ASSERT( mpView, "no valid view (!)" );
781cdf0e10cSrcweir 	meDlgUnit = GetModuleFieldUnit( GetItemSet() );
782cdf0e10cSrcweir 	SetFieldUnit( maMtrPosX, meDlgUnit, sal_True );
783cdf0e10cSrcweir 	SetFieldUnit( maMtrPosY, meDlgUnit, sal_True );
784cdf0e10cSrcweir 	SetFieldUnit( maMtrWidth, meDlgUnit, sal_True );
785cdf0e10cSrcweir 	SetFieldUnit( maMtrHeight, meDlgUnit, sal_True );
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 	if(FUNIT_MILE == meDlgUnit || FUNIT_KM == meDlgUnit)
788cdf0e10cSrcweir 	{
789cdf0e10cSrcweir 		maMtrPosX.SetDecimalDigits( 3 );
790cdf0e10cSrcweir 		maMtrPosY.SetDecimalDigits( 3 );
791cdf0e10cSrcweir 		maMtrWidth.SetDecimalDigits( 3 );
792cdf0e10cSrcweir 		maMtrHeight.SetDecimalDigits( 3 );
793cdf0e10cSrcweir 	}
794cdf0e10cSrcweir 
795cdf0e10cSrcweir 	{ // #i75273#
796cdf0e10cSrcweir 		Rectangle aTempRect(mpView->GetAllMarkedRect());
797cdf0e10cSrcweir 		mpView->GetSdrPageView()->LogicToPagePos(aTempRect);
798cdf0e10cSrcweir 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
799cdf0e10cSrcweir 	}
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 	{ // #i75273#
802cdf0e10cSrcweir 		Rectangle aTempRect(mpView->GetWorkArea());
803cdf0e10cSrcweir 		mpView->GetSdrPageView()->LogicToPagePos(aTempRect);
804cdf0e10cSrcweir 		maWorkRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
805cdf0e10cSrcweir 	}
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 	// take anchor into account (Writer)
808cdf0e10cSrcweir 	const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
809cdf0e10cSrcweir 
810cdf0e10cSrcweir 	if(rMarkList.GetMarkCount())
811cdf0e10cSrcweir 	{
812cdf0e10cSrcweir 		const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
813cdf0e10cSrcweir 		maAnchor = basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y());
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 		if(!maAnchor.equalZero()) // -> Writer
816cdf0e10cSrcweir 		{
817cdf0e10cSrcweir 			for(sal_uInt16 i(1); i < rMarkList.GetMarkCount(); i++)
818cdf0e10cSrcweir 			{
819cdf0e10cSrcweir 				pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 				if(maAnchor != basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y()))
822cdf0e10cSrcweir 				{
823cdf0e10cSrcweir 					// diferent anchor positions
824cdf0e10cSrcweir 					maMtrPosX.SetText( String() );
825cdf0e10cSrcweir 					maMtrPosY.SetText( String() );
826cdf0e10cSrcweir 					mbPageDisabled = sal_True;
827cdf0e10cSrcweir 					return;
828cdf0e10cSrcweir 				}
829cdf0e10cSrcweir 			}
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 			// translate ranges about anchor
832cdf0e10cSrcweir 			maRange = basegfx::B2DRange(maRange.getMinimum() - maAnchor, maRange.getMaximum() - maAnchor);
833cdf0e10cSrcweir 			maWorkRange = basegfx::B2DRange(maWorkRange.getMinimum() - maAnchor, maWorkRange.getMaximum() - maAnchor);
834cdf0e10cSrcweir 		}
835cdf0e10cSrcweir 	}
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 	// this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
838cdf0e10cSrcweir 	if(1 == rMarkList.GetMarkCount())
839cdf0e10cSrcweir 	{
840cdf0e10cSrcweir 		const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
841cdf0e10cSrcweir 		const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 		if((pObj->GetObjInventor() == SdrInventor) && (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) && ((SdrTextObj*)pObj)->HasText())
844cdf0e10cSrcweir 		{
845cdf0e10cSrcweir 			mbAdjustDisabled = false;
846cdf0e10cSrcweir 			maFlAdjust.Enable();
847cdf0e10cSrcweir 			maTsbAutoGrowWidth.Enable();
848cdf0e10cSrcweir 			maTsbAutoGrowHeight.Enable();
849cdf0e10cSrcweir 			maTsbAutoGrowWidth.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
850cdf0e10cSrcweir 			maTsbAutoGrowHeight.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 			// is used as flag to evaluate if its selectable
853cdf0e10cSrcweir 			maTsbAutoGrowWidth.EnableTriState( sal_False );
854cdf0e10cSrcweir 			maTsbAutoGrowHeight.EnableTriState( sal_False );
855cdf0e10cSrcweir 		}
856cdf0e10cSrcweir 	}
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 	// take scale into account
859cdf0e10cSrcweir 	const Fraction aUIScale(mpView->GetModel()->GetUIScale());
860cdf0e10cSrcweir 	lcl_ScaleRect( maWorkRange, aUIScale );
861cdf0e10cSrcweir 	lcl_ScaleRect( maRange, aUIScale );
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 	// take UI units into account
864cdf0e10cSrcweir 	const sal_uInt16 nDigits(maMtrPosX.GetDecimalDigits());
865cdf0e10cSrcweir 	lcl_ConvertRect( maWorkRange, nDigits, (MapUnit) mePoolUnit, meDlgUnit );
866cdf0e10cSrcweir 	lcl_ConvertRect( maRange, nDigits, (MapUnit) mePoolUnit, meDlgUnit );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 	SetMinMaxPosition();
869cdf0e10cSrcweir }
870cdf0e10cSrcweir 
871cdf0e10cSrcweir // -----------------------------------------------------------------------
872cdf0e10cSrcweir 
873cdf0e10cSrcweir sal_Bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet& rOutAttrs )
874cdf0e10cSrcweir {
875cdf0e10cSrcweir 	sal_Bool bModified(sal_False);
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 	if ( maMtrWidth.HasFocus() )
878cdf0e10cSrcweir 	{
879cdf0e10cSrcweir 		ChangeWidthHdl( this );
880cdf0e10cSrcweir 	}
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 	if ( maMtrHeight.HasFocus() )
883cdf0e10cSrcweir 	{
884cdf0e10cSrcweir 		ChangeHeightHdl( this );
885cdf0e10cSrcweir 	}
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 	if( !mbPageDisabled )
888cdf0e10cSrcweir 	{
889cdf0e10cSrcweir 		if ( maMtrPosX.IsValueModified() || maMtrPosY.IsValueModified() )
890cdf0e10cSrcweir 		{
891cdf0e10cSrcweir 			const double fUIScale(double(mpView->GetModel()->GetUIScale()));
892cdf0e10cSrcweir 			double fX((GetCoreValue( maMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale);
893cdf0e10cSrcweir 			double fY((GetCoreValue( maMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale);
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 			{ // #i75273#
896cdf0e10cSrcweir 				Rectangle aTempRect(mpView->GetAllMarkedRect());
897cdf0e10cSrcweir 				mpView->GetSdrPageView()->LogicToPagePos(aTempRect);
898cdf0e10cSrcweir 				maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
899cdf0e10cSrcweir 			}
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 			// #101581# GetTopLeftPosition(...) needs coordinates after UI scaling, in real PagePositions
902cdf0e10cSrcweir 			GetTopLeftPosition(fX, fY, maRange);
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 			rOutAttrs.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_X), basegfx::fround(fX)));
905cdf0e10cSrcweir 			rOutAttrs.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_Y), basegfx::fround(fY)));
906cdf0e10cSrcweir 
907cdf0e10cSrcweir 			bModified |= sal_True;
908cdf0e10cSrcweir 		}
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 		if ( maTsbPosProtect.GetState() != maTsbPosProtect.GetSavedValue() )
911cdf0e10cSrcweir 		{
912cdf0e10cSrcweir 			if( maTsbPosProtect.GetState() == STATE_DONTKNOW )
913cdf0e10cSrcweir 			{
914cdf0e10cSrcweir 				rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
915cdf0e10cSrcweir 			}
916cdf0e10cSrcweir 			else
917cdf0e10cSrcweir 			{
918cdf0e10cSrcweir 				rOutAttrs.Put(
919cdf0e10cSrcweir 					SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
920cdf0e10cSrcweir 					maTsbPosProtect.GetState() == STATE_CHECK ? sal_True : sal_False ) );
921cdf0e10cSrcweir 			}
922cdf0e10cSrcweir 
923cdf0e10cSrcweir 			bModified |= sal_True;
924cdf0e10cSrcweir 		}
925cdf0e10cSrcweir 	}
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 	if ( maMtrWidth.IsValueModified() || maMtrHeight.IsValueModified() )
928cdf0e10cSrcweir 	{
929cdf0e10cSrcweir 		Fraction aUIScale = mpView->GetModel()->GetUIScale();
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 		// get Width
932cdf0e10cSrcweir 		double nWidth = static_cast<double>(maMtrWidth.GetValue( meDlgUnit ));
933cdf0e10cSrcweir 		nWidth = MetricField::ConvertDoubleValue( nWidth, maMtrWidth.GetBaseValue(), maMtrWidth.GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
934cdf0e10cSrcweir         long lWidth = long(nWidth * (double)aUIScale);
935cdf0e10cSrcweir 		lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit );
936cdf0e10cSrcweir 		lWidth = static_cast<long>(maMtrWidth.Denormalize( lWidth ));
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 		// get Height
939cdf0e10cSrcweir 		double nHeight = static_cast<double>(maMtrHeight.GetValue( meDlgUnit ));
940cdf0e10cSrcweir 		nHeight = MetricField::ConvertDoubleValue( nHeight, maMtrHeight.GetBaseValue(), maMtrHeight.GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
941cdf0e10cSrcweir         long lHeight = long(nHeight * (double)aUIScale);
942cdf0e10cSrcweir 		lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit );
943cdf0e10cSrcweir 		lHeight = static_cast<long>(maMtrWidth.Denormalize( lHeight ));
944cdf0e10cSrcweir 
945cdf0e10cSrcweir 		// put Width & Height to itemset
946cdf0e10cSrcweir 		rOutAttrs.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ),
947cdf0e10cSrcweir 						(sal_uInt32) lWidth ) );
948cdf0e10cSrcweir 		rOutAttrs.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ),
949cdf0e10cSrcweir 						(sal_uInt32) lHeight ) );
950cdf0e10cSrcweir 		rOutAttrs.Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal::static_int_cast< sal_uInt16 >( meRP ) ) );
951cdf0e10cSrcweir 		bModified |= sal_True;
952cdf0e10cSrcweir 	}
953cdf0e10cSrcweir 
954cdf0e10cSrcweir 	if ( maTsbSizeProtect.GetState() != maTsbSizeProtect.GetSavedValue() )
955cdf0e10cSrcweir 	{
956cdf0e10cSrcweir 		if ( maTsbSizeProtect.GetState() == STATE_DONTKNOW )
957cdf0e10cSrcweir 			rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
958cdf0e10cSrcweir 		else
959cdf0e10cSrcweir 			rOutAttrs.Put(
960cdf0e10cSrcweir 				SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
961cdf0e10cSrcweir 				maTsbSizeProtect.GetState() == STATE_CHECK ? sal_True : sal_False ) );
962cdf0e10cSrcweir 		bModified |= sal_True;
963cdf0e10cSrcweir 	}
964cdf0e10cSrcweir 
965cdf0e10cSrcweir 	if ( maTsbAutoGrowWidth.GetState() != maTsbAutoGrowWidth.GetSavedValue() )
966cdf0e10cSrcweir 	{
967cdf0e10cSrcweir 		if ( !maTsbAutoGrowWidth.IsTriStateEnabled() )
968cdf0e10cSrcweir 		{
969cdf0e10cSrcweir 			if( maTsbAutoGrowWidth.GetState() == STATE_DONTKNOW )
970cdf0e10cSrcweir 				rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH );
971cdf0e10cSrcweir 			else
972cdf0e10cSrcweir 				rOutAttrs.Put(
973cdf0e10cSrcweir 					SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH ),
974cdf0e10cSrcweir 					maTsbAutoGrowWidth.GetState() == STATE_CHECK ? sal_True : sal_False ) );
975cdf0e10cSrcweir 		}
976cdf0e10cSrcweir 		bModified |= sal_True;
977cdf0e10cSrcweir 	}
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 	if ( maTsbAutoGrowHeight.GetState() != maTsbAutoGrowHeight.GetSavedValue() )
980cdf0e10cSrcweir 	{
981cdf0e10cSrcweir 		if ( !maTsbAutoGrowHeight.IsTriStateEnabled() )
982cdf0e10cSrcweir 		{
983cdf0e10cSrcweir 			if( maTsbAutoGrowHeight.GetState() == STATE_DONTKNOW )
984cdf0e10cSrcweir 				rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_AUTOHEIGHT );
985cdf0e10cSrcweir 			else
986cdf0e10cSrcweir 				rOutAttrs.Put(
987cdf0e10cSrcweir 					SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT ),
988cdf0e10cSrcweir 					maTsbAutoGrowHeight.GetState() == STATE_CHECK ? sal_True : sal_False ) );
989cdf0e10cSrcweir 		}
990cdf0e10cSrcweir 		bModified |= sal_True;
991cdf0e10cSrcweir 	}
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 	return bModified;
995cdf0e10cSrcweir }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir // -----------------------------------------------------------------------
998cdf0e10cSrcweir 
999cdf0e10cSrcweir void SvxPositionSizeTabPage::Reset( const SfxItemSet&  )
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir 	const SfxPoolItem* pItem;
1002cdf0e10cSrcweir 	const double fUIScale(double(mpView->GetModel()->GetUIScale()));
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 	if ( !mbPageDisabled )
1005cdf0e10cSrcweir 	{
1006cdf0e10cSrcweir 		pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_POS_X );
1007cdf0e10cSrcweir 		if ( pItem )
1008cdf0e10cSrcweir 		{
1009cdf0e10cSrcweir 			const double fTmp((((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getX()) / fUIScale);
1010cdf0e10cSrcweir 			SetMetricValue(maMtrPosX, basegfx::fround(fTmp), mePoolUnit);
1011cdf0e10cSrcweir 		}
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 		pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_POS_Y );
1014cdf0e10cSrcweir 		if ( pItem )
1015cdf0e10cSrcweir 		{
1016cdf0e10cSrcweir 			const double fTmp((((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getY()) / fUIScale);
1017cdf0e10cSrcweir 			SetMetricValue(maMtrPosY, basegfx::fround(fTmp), mePoolUnit);
1018cdf0e10cSrcweir 		}
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 		pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_POS );
1021cdf0e10cSrcweir 		if ( pItem )
1022cdf0e10cSrcweir 		{
1023cdf0e10cSrcweir 			sal_Bool bProtected = ( ( const SfxBoolItem* )pItem )->GetValue();
1024cdf0e10cSrcweir 			maTsbPosProtect.SetState( bProtected ? STATE_CHECK : STATE_NOCHECK );
1025cdf0e10cSrcweir 			maTsbPosProtect.EnableTriState( sal_False );
1026cdf0e10cSrcweir 		}
1027cdf0e10cSrcweir 		else
1028cdf0e10cSrcweir 		{
1029cdf0e10cSrcweir 			maTsbPosProtect.SetState( STATE_DONTKNOW );
1030cdf0e10cSrcweir 		}
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir 		maTsbPosProtect.SaveValue();
1033cdf0e10cSrcweir 		maCtlPos.Reset();
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir         // #i2379# Disable controls for protected objects
1036cdf0e10cSrcweir         ChangePosProtectHdl( this );
1037cdf0e10cSrcweir 	}
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 	{ // #i75273# set width
1040cdf0e10cSrcweir 		pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_WIDTH );
1041cdf0e10cSrcweir 		mfOldWidth = std::max( pItem ? (double)((const SfxUInt32Item*)pItem)->GetValue() : 0.0, 1.0 );
1042cdf0e10cSrcweir 		double fTmpWidth((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldWidth), (MapUnit)mePoolUnit, MAP_100TH_MM)) / fUIScale);
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 		if(maMtrWidth.GetDecimalDigits())
1045cdf0e10cSrcweir 			fTmpWidth *= pow(10.0, maMtrWidth.GetDecimalDigits());
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir 		fTmpWidth = MetricField::ConvertDoubleValue(fTmpWidth, maMtrWidth.GetBaseValue(), maMtrWidth.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit);
1048cdf0e10cSrcweir 		maMtrWidth.SetValue(static_cast<sal_Int64>(fTmpWidth), meDlgUnit);
1049cdf0e10cSrcweir 	}
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 	{ // #i75273# set height
1052cdf0e10cSrcweir 		pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_HEIGHT );
1053cdf0e10cSrcweir 		mfOldHeight = std::max( pItem ? (double)((const SfxUInt32Item*)pItem)->GetValue() : 0.0, 1.0 );
1054cdf0e10cSrcweir 		double fTmpHeight((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldHeight), (MapUnit)mePoolUnit, MAP_100TH_MM)) / fUIScale);
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 		if(maMtrHeight.GetDecimalDigits())
1057cdf0e10cSrcweir 			fTmpHeight *= pow(10.0, maMtrHeight.GetDecimalDigits());
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 		fTmpHeight = MetricField::ConvertDoubleValue(fTmpHeight, maMtrHeight.GetBaseValue(), maMtrHeight.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit);
1060cdf0e10cSrcweir 		maMtrHeight.SetValue(static_cast<sal_Int64>(fTmpHeight), meDlgUnit);
1061cdf0e10cSrcweir 	}
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir 	pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_SIZE );
1064cdf0e10cSrcweir 	if ( pItem )
1065cdf0e10cSrcweir 	{
1066cdf0e10cSrcweir 		maTsbSizeProtect.SetState( ( (const SfxBoolItem*)pItem )->GetValue()
1067cdf0e10cSrcweir 							  ? STATE_CHECK : STATE_NOCHECK );
1068cdf0e10cSrcweir 		maTsbSizeProtect.EnableTriState( sal_False );
1069cdf0e10cSrcweir 	}
1070cdf0e10cSrcweir 	else
1071cdf0e10cSrcweir 		maTsbSizeProtect.SetState( STATE_DONTKNOW );
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 	pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_AUTOWIDTH );
1074cdf0e10cSrcweir 	if ( pItem )
1075cdf0e10cSrcweir 	{
1076cdf0e10cSrcweir 		maTsbAutoGrowWidth.SetState( ( ( const SfxBoolItem* )pItem )->GetValue()
1077cdf0e10cSrcweir 						   ? STATE_CHECK : STATE_NOCHECK );
1078cdf0e10cSrcweir 	}
1079cdf0e10cSrcweir 	else
1080cdf0e10cSrcweir 		maTsbAutoGrowWidth.SetState( STATE_DONTKNOW );
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir 	pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_AUTOHEIGHT );
1083cdf0e10cSrcweir 	if ( pItem )
1084cdf0e10cSrcweir 	{
1085cdf0e10cSrcweir 		maTsbAutoGrowHeight.SetState( ( ( const SfxBoolItem* )pItem )->GetValue()
1086cdf0e10cSrcweir 						   ? STATE_CHECK : STATE_NOCHECK );
1087cdf0e10cSrcweir 	}
1088cdf0e10cSrcweir 	else
1089cdf0e10cSrcweir 		maTsbAutoGrowHeight.SetState( STATE_DONTKNOW );
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 	// Ist Abgleich gesetzt?
1092cdf0e10cSrcweir 	String aStr = GetUserData();
1093cdf0e10cSrcweir 	maCbxScale.Check( (sal_Bool)aStr.ToInt32() );
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 	maTsbSizeProtect.SaveValue();
1096cdf0e10cSrcweir 	maTsbAutoGrowWidth.SaveValue();
1097cdf0e10cSrcweir 	maTsbAutoGrowHeight.SaveValue();
1098cdf0e10cSrcweir 	ClickSizeProtectHdl( NULL );
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir     // #i2379# Disable controls for protected objects
1101cdf0e10cSrcweir     ChangeSizeProtectHdl( this );
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir // -----------------------------------------------------------------------
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir SfxTabPage* SvxPositionSizeTabPage::Create( Window* pWindow, const SfxItemSet& rOutAttrs )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir 	return( new SvxPositionSizeTabPage( pWindow, rOutAttrs ) );
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir //------------------------------------------------------------------------
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir sal_uInt16* SvxPositionSizeTabPage::GetRanges()
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir 	return( pPosSizeRanges );
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir // -----------------------------------------------------------------------
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir void SvxPositionSizeTabPage::ActivatePage( const SfxItemSet& rSet )
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir 	SfxRectangleItem* pRectItem = NULL;
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN ) , sal_False, (const SfxPoolItem**) &pRectItem ) )
1125cdf0e10cSrcweir 	{
1126cdf0e10cSrcweir 		{ // #i75273#
1127cdf0e10cSrcweir 			const Rectangle aTempRect(pRectItem->GetValue());
1128cdf0e10cSrcweir 			maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
1129cdf0e10cSrcweir 		}
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 		SetMinMaxPosition();
1132cdf0e10cSrcweir 	}
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir // -----------------------------------------------------------------------
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir int SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir     if( _pSet )
1140cdf0e10cSrcweir 	{
1141cdf0e10cSrcweir 		double fX((double)maMtrPosX.GetValue());
1142cdf0e10cSrcweir 		double fY((double)maMtrPosY.GetValue());
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir 		GetTopLeftPosition(fX, fY, maRange);
1145cdf0e10cSrcweir 		const Rectangle aOutRectangle(
1146cdf0e10cSrcweir 			basegfx::fround(fX), basegfx::fround(fY),
1147cdf0e10cSrcweir 			basegfx::fround(fX + maRange.getWidth()), basegfx::fround(fY + maRange.getHeight()));
1148cdf0e10cSrcweir         _pSet->Put(SfxRectangleItem(SID_ATTR_TRANSFORM_INTERN, aOutRectangle));
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir         FillItemSet(*_pSet);
1151cdf0e10cSrcweir 	}
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir 	return LEAVE_PAGE;
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir //------------------------------------------------------------------------
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir IMPL_LINK( SvxPositionSizeTabPage, ChangePosProtectHdl, void *, EMPTYARG )
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir     // #106572# Remember user's last choice
1161cdf0e10cSrcweir 	maTsbSizeProtect.SetState( maTsbPosProtect.GetState() == STATE_CHECK ?  STATE_CHECK : mnProtectSizeState );
1162cdf0e10cSrcweir     UpdateControlStates();
1163cdf0e10cSrcweir 	return( 0L );
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir //------------------------------------------------------------------------
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir void SvxPositionSizeTabPage::UpdateControlStates()
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir 	const bool bPosProtect =  maTsbPosProtect.GetState() == STATE_CHECK;
1171cdf0e10cSrcweir 	const bool bSizeProtect = maTsbSizeProtect.GetState() == STATE_CHECK;
1172cdf0e10cSrcweir 	const bool bHeightChecked = !maTsbAutoGrowHeight.IsTriStateEnabled() && (maTsbAutoGrowHeight.GetState() == STATE_CHECK);
1173cdf0e10cSrcweir 	const bool bWidthChecked = !maTsbAutoGrowWidth.IsTriStateEnabled() && (maTsbAutoGrowWidth.GetState() == STATE_CHECK);
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir 	maFlPosition.Enable( !bPosProtect && !mbPageDisabled );
1176cdf0e10cSrcweir 	maFtPosX.Enable( !bPosProtect && !mbPageDisabled );
1177cdf0e10cSrcweir 	maMtrPosX.Enable( !bPosProtect && !mbPageDisabled );
1178cdf0e10cSrcweir 	maFtPosY.Enable( !bPosProtect && !mbPageDisabled );
1179cdf0e10cSrcweir 	maMtrPosY.Enable( !bPosProtect && !mbPageDisabled );
1180cdf0e10cSrcweir 	maFtPosReference.Enable( !bPosProtect && !mbPageDisabled );
1181cdf0e10cSrcweir 	maCtlPos.Enable( !bPosProtect );
1182cdf0e10cSrcweir 	maTsbPosProtect.Enable( !mbProtectDisabled && !mbPageDisabled );
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir 	maFlSize.Enable( !mbSizeDisabled && !bSizeProtect );
1185cdf0e10cSrcweir 	maCtlSize.Enable( !mbSizeDisabled && !bSizeProtect && (!bHeightChecked || !bWidthChecked) );
1186cdf0e10cSrcweir 	maFtWidth.Enable( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
1187cdf0e10cSrcweir 	maMtrWidth.Enable( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
1188cdf0e10cSrcweir 	maFtHeight.Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
1189cdf0e10cSrcweir 	maMtrHeight.Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
1190cdf0e10cSrcweir 	maCbxScale.Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked && !bWidthChecked );
1191cdf0e10cSrcweir 	maFtSizeReference.Enable( !mbSizeDisabled && !bSizeProtect );
1192cdf0e10cSrcweir 	maFlProtect.Enable( !mbProtectDisabled );
1193cdf0e10cSrcweir 	maTsbSizeProtect.Enable( !mbProtectDisabled && !bPosProtect );
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 	maFlAdjust.Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
1196cdf0e10cSrcweir 	maTsbAutoGrowWidth.Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
1197cdf0e10cSrcweir 	maTsbAutoGrowHeight.Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir 	maCtlSize.Invalidate();
1200cdf0e10cSrcweir 	maCtlPos.Invalidate();
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir }
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir //------------------------------------------------------------------------
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir IMPL_LINK( SvxPositionSizeTabPage, ChangeSizeProtectHdl, void *, EMPTYARG )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir 	if( maTsbSizeProtect.IsEnabled() )
1209cdf0e10cSrcweir 	{
1210cdf0e10cSrcweir         // #106572# Remember user's last choice
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir         // Note: this works only as long as the dialog is open.  When
1213cdf0e10cSrcweir         // the user closes the dialog, there is no way to remember
1214cdf0e10cSrcweir         // whether size was enabled or disabled befor pos protect was
1215cdf0e10cSrcweir         // clicked. Thus, if pos protect is selected, the dialog is
1216cdf0e10cSrcweir         // closed and reopened again, unchecking pos protect will
1217cdf0e10cSrcweir         // always uncheck size protect, too. That's life.
1218cdf0e10cSrcweir         mnProtectSizeState = maTsbSizeProtect.GetState();
1219cdf0e10cSrcweir     }
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir     UpdateControlStates();
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 	return( 0L );
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir //------------------------------------------------------------------------
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxPositionSizeTabPage, ChangePosXHdl, void *, EMPTYARG )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir 	return( 0L );
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxPositionSizeTabPage, ChangePosXHdl, void *, EMPTYARG )
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir //------------------------------------------------------------------------
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxPositionSizeTabPage, ChangePosYHdl, void *, EMPTYARG )
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir 	return( 0L );
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxPositionSizeTabPage, ChangePosYHdl, void *, EMPTYARG )
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir //------------------------------------------------------------------------
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir void SvxPositionSizeTabPage::SetMinMaxPosition()
1245cdf0e10cSrcweir {
1246cdf0e10cSrcweir 	// position
1247cdf0e10cSrcweir 	double fLeft(maWorkRange.getMinX());
1248cdf0e10cSrcweir 	double fTop(maWorkRange.getMinY());
1249cdf0e10cSrcweir 	double fRight(maWorkRange.getMaxX());
1250cdf0e10cSrcweir 	double fBottom(maWorkRange.getMaxY());
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir 	switch ( maCtlPos.GetActualRP() )
1253cdf0e10cSrcweir 	{
1254cdf0e10cSrcweir 		case RP_LT:
1255cdf0e10cSrcweir 		{
1256cdf0e10cSrcweir 			fRight  -= maRange.getWidth();
1257cdf0e10cSrcweir 			fBottom -= maRange.getHeight();
1258cdf0e10cSrcweir 			break;
1259cdf0e10cSrcweir 		}
1260cdf0e10cSrcweir 		case RP_MT:
1261cdf0e10cSrcweir 		{
1262cdf0e10cSrcweir 			fLeft   += maRange.getWidth() / 2.0;
1263cdf0e10cSrcweir 			fRight  -= maRange.getWidth() / 2.0;
1264cdf0e10cSrcweir 			fBottom -= maRange.getHeight();
1265cdf0e10cSrcweir 			break;
1266cdf0e10cSrcweir 		}
1267cdf0e10cSrcweir 		case RP_RT:
1268cdf0e10cSrcweir 		{
1269cdf0e10cSrcweir 			fLeft   += maRange.getWidth();
1270cdf0e10cSrcweir 			fBottom -= maRange.getHeight();
1271cdf0e10cSrcweir 			break;
1272cdf0e10cSrcweir 		}
1273cdf0e10cSrcweir 		case RP_LM:
1274cdf0e10cSrcweir 		{
1275cdf0e10cSrcweir 			fRight  -= maRange.getWidth();
1276cdf0e10cSrcweir 			fTop    += maRange.getHeight() / 2.0;
1277cdf0e10cSrcweir 			fBottom -= maRange.getHeight() / 2.0;
1278cdf0e10cSrcweir 			break;
1279cdf0e10cSrcweir 		}
1280cdf0e10cSrcweir 		case RP_MM:
1281cdf0e10cSrcweir 		{
1282cdf0e10cSrcweir 			fLeft   += maRange.getWidth() / 2.0;
1283cdf0e10cSrcweir 			fRight  -= maRange.getWidth() / 2.0;
1284cdf0e10cSrcweir 			fTop    += maRange.getHeight() / 2.0;
1285cdf0e10cSrcweir 			fBottom -= maRange.getHeight() / 2.0;
1286cdf0e10cSrcweir 			break;
1287cdf0e10cSrcweir 		}
1288cdf0e10cSrcweir 		case RP_RM:
1289cdf0e10cSrcweir 		{
1290cdf0e10cSrcweir 			fLeft   += maRange.getWidth();
1291cdf0e10cSrcweir 			fTop    += maRange.getHeight() / 2.0;
1292cdf0e10cSrcweir 			fBottom -= maRange.getHeight() / 2.0;
1293cdf0e10cSrcweir 			break;
1294cdf0e10cSrcweir 		}
1295cdf0e10cSrcweir 		case RP_LB:
1296cdf0e10cSrcweir 		{
1297cdf0e10cSrcweir 			fRight  -= maRange.getWidth();
1298cdf0e10cSrcweir 			fTop    += maRange.getHeight();
1299cdf0e10cSrcweir 			break;
1300cdf0e10cSrcweir 		}
1301cdf0e10cSrcweir 		case RP_MB:
1302cdf0e10cSrcweir 		{
1303cdf0e10cSrcweir 			fLeft   += maRange.getWidth() / 2.0;
1304cdf0e10cSrcweir 			fRight  -= maRange.getWidth() / 2.0;
1305cdf0e10cSrcweir 			fTop    += maRange.getHeight();
1306cdf0e10cSrcweir 			break;
1307cdf0e10cSrcweir 		}
1308cdf0e10cSrcweir 		case RP_RB:
1309cdf0e10cSrcweir 		{
1310cdf0e10cSrcweir 			fLeft   += maRange.getWidth();
1311cdf0e10cSrcweir 			fTop    += maRange.getHeight();
1312cdf0e10cSrcweir 			break;
1313cdf0e10cSrcweir 		}
1314cdf0e10cSrcweir 	}
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir 	const double fMaxLong((double)(MetricField::ConvertValue( LONG_MAX, 0, MAP_100TH_MM, meDlgUnit ) - 1L));
1317cdf0e10cSrcweir 	fLeft = (fLeft > fMaxLong) ? fMaxLong : (fLeft < -fMaxLong) ? -fMaxLong : fLeft;
1318cdf0e10cSrcweir 	fRight = (fRight > fMaxLong) ? fMaxLong : (fRight < -fMaxLong) ? -fMaxLong : fRight;
1319cdf0e10cSrcweir 	fTop = (fTop > fMaxLong) ? fMaxLong : (fTop < -fMaxLong) ? -fMaxLong : fTop;
1320cdf0e10cSrcweir 	fBottom = (fBottom > fMaxLong) ? fMaxLong : (fBottom < -fMaxLong) ? -fMaxLong : fBottom;
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir 	// #i75273# normalizing when setting the min/max values was wrong, removed
1323cdf0e10cSrcweir 	maMtrPosX.SetMin(basegfx::fround64(fLeft));
1324cdf0e10cSrcweir 	maMtrPosX.SetFirst(basegfx::fround64(fLeft));
1325cdf0e10cSrcweir     maMtrPosX.SetMax(basegfx::fround64(fRight));
1326cdf0e10cSrcweir 	maMtrPosX.SetLast(basegfx::fround64(fRight));
1327cdf0e10cSrcweir     maMtrPosY.SetMin(basegfx::fround64(fTop));
1328cdf0e10cSrcweir 	maMtrPosY.SetFirst(basegfx::fround64(fTop));
1329cdf0e10cSrcweir     maMtrPosY.SetMax(basegfx::fround64(fBottom));
1330cdf0e10cSrcweir 	maMtrPosY.SetLast(basegfx::fround64(fBottom));
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir 	// size
1333cdf0e10cSrcweir 	fLeft = maWorkRange.getMinX();
1334cdf0e10cSrcweir 	fTop = maWorkRange.getMinY();
1335cdf0e10cSrcweir 	fRight = maWorkRange.getMaxX();
1336cdf0e10cSrcweir 	fBottom = maWorkRange.getMaxY();
1337cdf0e10cSrcweir 	double fNewX(0);
1338cdf0e10cSrcweir 	double fNewY(0);
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir 	switch ( maCtlSize.GetActualRP() )
1341cdf0e10cSrcweir 	{
1342cdf0e10cSrcweir 		case RP_LT:
1343cdf0e10cSrcweir 		{
1344cdf0e10cSrcweir 			fNewX = maWorkRange.getWidth() - ( maRange.getMinX() - fLeft );
1345cdf0e10cSrcweir 			fNewY = maWorkRange.getHeight() - ( maRange.getMinY() - fTop );
1346cdf0e10cSrcweir 			break;
1347cdf0e10cSrcweir 		}
1348cdf0e10cSrcweir 		case RP_MT:
1349cdf0e10cSrcweir 		{
1350cdf0e10cSrcweir 			fNewX = std::min( maRange.getCenter().getX() - fLeft, fRight - maRange.getCenter().getX() ) * 2.0;
1351cdf0e10cSrcweir 			fNewY = maWorkRange.getHeight() - ( maRange.getMinY() - fTop );
1352cdf0e10cSrcweir 			break;
1353cdf0e10cSrcweir 		}
1354cdf0e10cSrcweir 		case RP_RT:
1355cdf0e10cSrcweir 		{
1356cdf0e10cSrcweir 			fNewX = maWorkRange.getWidth() - ( fRight - maRange.getMaxX() );
1357cdf0e10cSrcweir 			fNewY = maWorkRange.getHeight() - ( maRange.getMinY() - fTop );
1358cdf0e10cSrcweir 			break;
1359cdf0e10cSrcweir 		}
1360cdf0e10cSrcweir 		case RP_LM:
1361cdf0e10cSrcweir 		{
1362cdf0e10cSrcweir 			fNewX = maWorkRange.getWidth() - ( maRange.getMinX() - fLeft );
1363cdf0e10cSrcweir 			fNewY = std::min( maRange.getCenter().getY() - fTop, fBottom - maRange.getCenter().getY() ) * 2.0;
1364cdf0e10cSrcweir 			break;
1365cdf0e10cSrcweir 		}
1366cdf0e10cSrcweir 		case RP_MM:
1367cdf0e10cSrcweir 		{
1368cdf0e10cSrcweir 			const double f1(maRange.getCenter().getX() - fLeft);
1369cdf0e10cSrcweir 			const double f2(fRight - maRange.getCenter().getX());
1370cdf0e10cSrcweir 			const double f3(std::min(f1, f2));
1371cdf0e10cSrcweir 			const double f4(maRange.getCenter().getY() - fTop);
1372cdf0e10cSrcweir 			const double f5(fBottom - maRange.getCenter().getY());
1373cdf0e10cSrcweir 			const double f6(std::min(f4, f5));
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 			fNewX = f3 * 2.0;
1376cdf0e10cSrcweir 			fNewY = f6 * 3.0;
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir 			break;
1379cdf0e10cSrcweir 		}
1380cdf0e10cSrcweir 		case RP_RM:
1381cdf0e10cSrcweir 		{
1382cdf0e10cSrcweir 			fNewX = maWorkRange.getWidth() - ( fRight - maRange.getMaxX() );
1383cdf0e10cSrcweir 			fNewY = std::min( maRange.getCenter().getY() - fTop, fBottom - maRange.getCenter().getY() ) * 2.0;
1384cdf0e10cSrcweir 			break;
1385cdf0e10cSrcweir 		}
1386cdf0e10cSrcweir 		case RP_LB:
1387cdf0e10cSrcweir 		{
1388cdf0e10cSrcweir 			fNewX = maWorkRange.getWidth() - ( maRange.getMinX() - fLeft );
1389cdf0e10cSrcweir 			fNewY = maWorkRange.getHeight() - ( fBottom - maRange.getMaxY() );
1390cdf0e10cSrcweir 			break;
1391cdf0e10cSrcweir 		}
1392cdf0e10cSrcweir 		case RP_MB:
1393cdf0e10cSrcweir 		{
1394cdf0e10cSrcweir 			fNewX = std::min( maRange.getCenter().getX() - fLeft, fRight - maRange.getCenter().getX() ) * 2.0;
1395cdf0e10cSrcweir 			fNewY = maWorkRange.getHeight() - ( maRange.getMaxY() - fBottom );
1396cdf0e10cSrcweir 			break;
1397cdf0e10cSrcweir 		}
1398cdf0e10cSrcweir 		case RP_RB:
1399cdf0e10cSrcweir 		{
1400cdf0e10cSrcweir 			fNewX = maWorkRange.getWidth() - ( fRight - maRange.getMaxX() );
1401cdf0e10cSrcweir 			fNewY = maWorkRange.getHeight() - ( fBottom - maRange.getMaxY() );
1402cdf0e10cSrcweir 			break;
1403cdf0e10cSrcweir 		}
1404cdf0e10cSrcweir 	}
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir 	// #i75273# normalizing when setting the min/max values was wrong, removed
1407cdf0e10cSrcweir     maMtrWidth.SetMax(basegfx::fround64(fNewX));
1408cdf0e10cSrcweir 	maMtrWidth.SetLast(basegfx::fround64(fNewX));
1409cdf0e10cSrcweir     maMtrHeight.SetMax(basegfx::fround64(fNewY));
1410cdf0e10cSrcweir 	maMtrHeight.SetLast(basegfx::fround64(fNewY));
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir //------------------------------------------------------------------------
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir void SvxPositionSizeTabPage::GetTopLeftPosition(double& rfX, double& rfY, const basegfx::B2DRange& rRange)
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir 	switch (maCtlPos.GetActualRP())
1418cdf0e10cSrcweir 	{
1419cdf0e10cSrcweir 		case RP_LT:
1420cdf0e10cSrcweir 		{
1421cdf0e10cSrcweir 			break;
1422cdf0e10cSrcweir 		}
1423cdf0e10cSrcweir 		case RP_MT:
1424cdf0e10cSrcweir 		{
1425cdf0e10cSrcweir 			rfX -= rRange.getCenter().getX() - rRange.getMinX();
1426cdf0e10cSrcweir 			break;
1427cdf0e10cSrcweir 		}
1428cdf0e10cSrcweir 		case RP_RT:
1429cdf0e10cSrcweir 		{
1430cdf0e10cSrcweir 			rfX -= rRange.getWidth();
1431cdf0e10cSrcweir 			break;
1432cdf0e10cSrcweir 		}
1433cdf0e10cSrcweir 		case RP_LM:
1434cdf0e10cSrcweir 		{
1435cdf0e10cSrcweir 			rfY -= rRange.getCenter().getY() - rRange.getMinY();
1436cdf0e10cSrcweir 			break;
1437cdf0e10cSrcweir 		}
1438cdf0e10cSrcweir 		case RP_MM:
1439cdf0e10cSrcweir 		{
1440cdf0e10cSrcweir 			rfX -= rRange.getCenter().getX() - rRange.getMinX();
1441cdf0e10cSrcweir 			rfY -= rRange.getCenter().getY() - rRange.getMinY();
1442cdf0e10cSrcweir 			break;
1443cdf0e10cSrcweir 		}
1444cdf0e10cSrcweir 		case RP_RM:
1445cdf0e10cSrcweir 		{
1446cdf0e10cSrcweir 			rfX -= rRange.getWidth();
1447cdf0e10cSrcweir 			rfY -= rRange.getCenter().getY() - rRange.getMinY();
1448cdf0e10cSrcweir 			break;
1449cdf0e10cSrcweir 		}
1450cdf0e10cSrcweir 		case RP_LB:
1451cdf0e10cSrcweir 		{
1452cdf0e10cSrcweir 			rfY -= rRange.getHeight();
1453cdf0e10cSrcweir 			break;
1454cdf0e10cSrcweir 		}
1455cdf0e10cSrcweir 		case RP_MB:
1456cdf0e10cSrcweir 		{
1457cdf0e10cSrcweir 			rfX -= rRange.getCenter().getX() - rRange.getMinX();
1458cdf0e10cSrcweir 			rfY -= rRange.getHeight();
1459cdf0e10cSrcweir 			break;
1460cdf0e10cSrcweir 		}
1461cdf0e10cSrcweir 		case RP_RB:
1462cdf0e10cSrcweir 		{
1463cdf0e10cSrcweir 			rfX -= rRange.getWidth();
1464cdf0e10cSrcweir 			rfY -= rRange.getHeight();
1465cdf0e10cSrcweir 			break;
1466cdf0e10cSrcweir 		}
1467cdf0e10cSrcweir 	}
1468cdf0e10cSrcweir }
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir //------------------------------------------------------------------------
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir void SvxPositionSizeTabPage::PointChanged( Window* pWindow, RECT_POINT eRP )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir 	if( pWindow == &maCtlPos )
1475cdf0e10cSrcweir 	{
1476cdf0e10cSrcweir 		SetMinMaxPosition();
1477cdf0e10cSrcweir 		switch( eRP )
1478cdf0e10cSrcweir 		{
1479cdf0e10cSrcweir 			case RP_LT:
1480cdf0e10cSrcweir 			{
1481cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getMinX()) );
1482cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getMinY()) );
1483cdf0e10cSrcweir 				break;
1484cdf0e10cSrcweir 			}
1485cdf0e10cSrcweir 			case RP_MT:
1486cdf0e10cSrcweir 			{
1487cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getCenter().getX()) );
1488cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getMinY()) );
1489cdf0e10cSrcweir 				break;
1490cdf0e10cSrcweir 			}
1491cdf0e10cSrcweir 			case RP_RT:
1492cdf0e10cSrcweir 			{
1493cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getMaxX()) );
1494cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getMinY()) );
1495cdf0e10cSrcweir 				break;
1496cdf0e10cSrcweir 			}
1497cdf0e10cSrcweir 			case RP_LM:
1498cdf0e10cSrcweir 			{
1499cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getMinX()) );
1500cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getCenter().getY()) );
1501cdf0e10cSrcweir 				break;
1502cdf0e10cSrcweir 			}
1503cdf0e10cSrcweir 			case RP_MM:
1504cdf0e10cSrcweir 			{
1505cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getCenter().getX()) );
1506cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getCenter().getY()) );
1507cdf0e10cSrcweir 				break;
1508cdf0e10cSrcweir 			}
1509cdf0e10cSrcweir 			case RP_RM:
1510cdf0e10cSrcweir 			{
1511cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getMaxX()) );
1512cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getCenter().getY()) );
1513cdf0e10cSrcweir 				break;
1514cdf0e10cSrcweir 			}
1515cdf0e10cSrcweir 			case RP_LB:
1516cdf0e10cSrcweir 			{
1517cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getMinX()) );
1518cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getMaxY()) );
1519cdf0e10cSrcweir 				break;
1520cdf0e10cSrcweir 			}
1521cdf0e10cSrcweir 			case RP_MB:
1522cdf0e10cSrcweir 			{
1523cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getCenter().getX()) );
1524cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getMaxY()) );
1525cdf0e10cSrcweir 				break;
1526cdf0e10cSrcweir 			}
1527cdf0e10cSrcweir 			case RP_RB:
1528cdf0e10cSrcweir 			{
1529cdf0e10cSrcweir 				maMtrPosX.SetValue( basegfx::fround64(maRange.getMaxX()) );
1530cdf0e10cSrcweir 				maMtrPosY.SetValue( basegfx::fround64(maRange.getMaxY()) );
1531cdf0e10cSrcweir 				break;
1532cdf0e10cSrcweir 			}
1533cdf0e10cSrcweir 		}
1534cdf0e10cSrcweir 	}
1535cdf0e10cSrcweir 	else
1536cdf0e10cSrcweir 	{
1537cdf0e10cSrcweir 		meRP = eRP;
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir 		Rectangle aTmpRect( GetRect() );
1540cdf0e10cSrcweir 		SetMinMaxPosition();
1541cdf0e10cSrcweir 	}
1542cdf0e10cSrcweir }
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir //------------------------------------------------------------------------
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir void SvxPositionSizeTabPage::DisableResize()
1547cdf0e10cSrcweir {
1548cdf0e10cSrcweir 	mbSizeDisabled = true;
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir //------------------------------------------------------------------------
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir void SvxPositionSizeTabPage::DisableProtect()
1554cdf0e10cSrcweir {
1555cdf0e10cSrcweir 	mbProtectDisabled = true;
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir //------------------------------------------------------------------------
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir Rectangle SvxPositionSizeTabPage::GetRect()
1561cdf0e10cSrcweir {
1562cdf0e10cSrcweir 	double fLeft(maRange.getMinX());
1563cdf0e10cSrcweir 	double fTop(maRange.getMinY());
1564cdf0e10cSrcweir 	double fRight(fLeft + (double)maMtrWidth.GetValue());
1565cdf0e10cSrcweir 	double fBottom(fTop + (double)maMtrHeight.GetValue());
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 	switch ( maCtlSize.GetActualRP() )
1568cdf0e10cSrcweir 	{
1569cdf0e10cSrcweir 		case RP_LT:
1570cdf0e10cSrcweir 		{
1571cdf0e10cSrcweir 			break;
1572cdf0e10cSrcweir 		}
1573cdf0e10cSrcweir 		case RP_MT:
1574cdf0e10cSrcweir 		{
1575cdf0e10cSrcweir 			fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() ) / 2.0;
1576cdf0e10cSrcweir 			break;
1577cdf0e10cSrcweir 		}
1578cdf0e10cSrcweir 		case RP_RT:
1579cdf0e10cSrcweir 		{
1580cdf0e10cSrcweir 			fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() );
1581cdf0e10cSrcweir 			break;
1582cdf0e10cSrcweir 		}
1583cdf0e10cSrcweir 		case RP_LM:
1584cdf0e10cSrcweir 		{
1585cdf0e10cSrcweir 			fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() ) / 2.0;
1586cdf0e10cSrcweir 			break;
1587cdf0e10cSrcweir 		}
1588cdf0e10cSrcweir 		case RP_MM:
1589cdf0e10cSrcweir 		{
1590cdf0e10cSrcweir 			fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() ) / 2.0;
1591cdf0e10cSrcweir 			fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() ) / 2.0;
1592cdf0e10cSrcweir 			break;
1593cdf0e10cSrcweir 		}
1594cdf0e10cSrcweir 		case RP_RM:
1595cdf0e10cSrcweir 		{
1596cdf0e10cSrcweir 			fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() );
1597cdf0e10cSrcweir 			fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() ) / 2.0;
1598cdf0e10cSrcweir 			break;
1599cdf0e10cSrcweir 		}
1600cdf0e10cSrcweir 		case RP_LB:
1601cdf0e10cSrcweir 		{
1602cdf0e10cSrcweir 			fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() );
1603cdf0e10cSrcweir 			break;
1604cdf0e10cSrcweir 		}
1605cdf0e10cSrcweir 		case RP_MB:
1606cdf0e10cSrcweir 		{
1607cdf0e10cSrcweir 			fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() ) / 2.0;
1608cdf0e10cSrcweir 			fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() );
1609cdf0e10cSrcweir 			break;
1610cdf0e10cSrcweir 		}
1611cdf0e10cSrcweir 		case RP_RB:
1612cdf0e10cSrcweir 		{
1613cdf0e10cSrcweir 			fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() );
1614cdf0e10cSrcweir 			fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() );
1615cdf0e10cSrcweir 			break;
1616cdf0e10cSrcweir 		}
1617cdf0e10cSrcweir 	}
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir 	return Rectangle(basegfx::fround(fLeft), basegfx::fround(fTop), basegfx::fround(fRight), basegfx::fround(fBottom));
1620cdf0e10cSrcweir }
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir //------------------------------------------------------------------------
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir IMPL_LINK( SvxPositionSizeTabPage, ChangeWidthHdl, void *, EMPTYARG )
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir 	if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() )
1627cdf0e10cSrcweir 	{
1628cdf0e10cSrcweir 		sal_Int64 nHeight(basegfx::fround64((mfOldHeight * (double)maMtrWidth.GetValue()) / mfOldWidth));
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir 		if(nHeight <= maMtrHeight.GetMax(FUNIT_NONE))
1631cdf0e10cSrcweir 		{
1632cdf0e10cSrcweir 			maMtrHeight.SetUserValue(nHeight, FUNIT_NONE);
1633cdf0e10cSrcweir 		}
1634cdf0e10cSrcweir 		else
1635cdf0e10cSrcweir 		{
1636cdf0e10cSrcweir 			nHeight = maMtrHeight.GetMax(FUNIT_NONE);
1637cdf0e10cSrcweir 			maMtrHeight.SetUserValue(nHeight);
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir 			const sal_Int64 nWidth(basegfx::fround64((mfOldWidth * (double)nHeight) / mfOldHeight));
1640cdf0e10cSrcweir 			maMtrWidth.SetUserValue(nWidth, FUNIT_NONE);
1641cdf0e10cSrcweir 		}
1642cdf0e10cSrcweir 	}
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir 	return( 0L );
1645cdf0e10cSrcweir }
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir //------------------------------------------------------------------------
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir IMPL_LINK( SvxPositionSizeTabPage, ChangeHeightHdl, void *, EMPTYARG )
1650cdf0e10cSrcweir {
1651cdf0e10cSrcweir 	if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() )
1652cdf0e10cSrcweir 	{
1653cdf0e10cSrcweir 		sal_Int64 nWidth(basegfx::fround64((mfOldWidth * (double)maMtrHeight.GetValue()) / mfOldHeight));
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir 		if(nWidth <= maMtrWidth.GetMax(FUNIT_NONE))
1656cdf0e10cSrcweir 		{
1657cdf0e10cSrcweir 			maMtrWidth.SetUserValue(nWidth, FUNIT_NONE);
1658cdf0e10cSrcweir 		}
1659cdf0e10cSrcweir 		else
1660cdf0e10cSrcweir 		{
1661cdf0e10cSrcweir 			nWidth = maMtrWidth.GetMax(FUNIT_NONE);
1662cdf0e10cSrcweir 			maMtrWidth.SetUserValue(nWidth);
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir 			const sal_Int64 nHeight(basegfx::fround64((mfOldHeight * (double)nWidth) / mfOldWidth));
1665cdf0e10cSrcweir 			maMtrHeight.SetUserValue(nHeight, FUNIT_NONE);
1666cdf0e10cSrcweir 		}
1667cdf0e10cSrcweir 	}
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir 	return( 0L );
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir //------------------------------------------------------------------------
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir IMPL_LINK( SvxPositionSizeTabPage, ClickSizeProtectHdl, void *, EMPTYARG )
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir 	UpdateControlStates();
1677cdf0e10cSrcweir 	return( 0L );
1678cdf0e10cSrcweir }
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir //------------------------------------------------------------------------
1681cdf0e10cSrcweir 
1682cdf0e10cSrcweir IMPL_LINK( SvxPositionSizeTabPage, ClickAutoHdl, void *, EMPTYARG )
1683cdf0e10cSrcweir {
1684cdf0e10cSrcweir 	if( maCbxScale.IsChecked() )
1685cdf0e10cSrcweir 	{
1686cdf0e10cSrcweir 		mfOldWidth  = std::max( (double)GetCoreValue( maMtrWidth,  mePoolUnit ), 1.0 );
1687cdf0e10cSrcweir 		mfOldHeight = std::max( (double)GetCoreValue( maMtrHeight, mePoolUnit ), 1.0 );
1688cdf0e10cSrcweir 	}
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir 	return( 0L );
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir //------------------------------------------------------------------------
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir void SvxPositionSizeTabPage::FillUserData()
1696cdf0e10cSrcweir {
1697cdf0e10cSrcweir 	// Abgleich wird in der Ini-Datei festgehalten
1698cdf0e10cSrcweir 	UniString aStr = UniString::CreateFromInt32( (sal_Int32) maCbxScale.IsChecked() );
1699cdf0e10cSrcweir 	SetUserData( aStr );
1700cdf0e10cSrcweir }
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir // eof
1703