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