xref: /aoo42x/main/cui/source/tabpages/transfrm.cxx (revision caceb8e7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 
27 // include ---------------------------------------------------------------
28 
29 #include <tools/shl.hxx>
30 #include <sfx2/app.hxx>
31 #include <svx/svdview.hxx>
32 #include <svx/svdobj.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <svx/svdotext.hxx>
35 #include <svx/sderitm.hxx>
36 #include <svx/dialogs.hrc>
37 #include <cuires.hrc>
38 #include "transfrm.hrc"
39 #include <editeng/sizeitem.hxx>
40 
41 #include "transfrm.hxx"
42 #include <dialmgr.hxx>
43 #include "svx/dlgutil.hxx"
44 #include <editeng/svxenum.hxx>
45 #include "svx/anchorid.hxx"
46 #include <sfx2/module.hxx>
47 #include <svl/rectitem.hxx>
48 #include <svl/aeitem.hxx>
49 #include <swpossizetabpage.hxx>
50 
51 // Toleranz fuer WorkingArea
52 #define DIFF 1000
53 
54 // static ----------------------------------------------------------------
55 
56 static sal_uInt16 pPosSizeRanges[] =
57 {
58 	SID_ATTR_TRANSFORM_POS_X,
59 	SID_ATTR_TRANSFORM_POS_Y,
60 	SID_ATTR_TRANSFORM_PROTECT_POS,
61 	SID_ATTR_TRANSFORM_PROTECT_POS,
62 	SID_ATTR_TRANSFORM_INTERN,
63 	SID_ATTR_TRANSFORM_INTERN,
64 	SID_ATTR_TRANSFORM_ANCHOR,
65 	SID_ATTR_TRANSFORM_VERT_ORIENT,
66 	SID_ATTR_TRANSFORM_WIDTH,
67 	SID_ATTR_TRANSFORM_SIZE_POINT,
68 	SID_ATTR_TRANSFORM_PROTECT_POS,
69 	SID_ATTR_TRANSFORM_INTERN,
70 	SID_ATTR_TRANSFORM_AUTOWIDTH,
71 	SID_ATTR_TRANSFORM_AUTOHEIGHT,
72 	0
73 };
74 
75 static sal_uInt16 pAngleRanges[] =
76 {
77 	SID_ATTR_TRANSFORM_ROT_X,
78 	SID_ATTR_TRANSFORM_ANGLE,
79 	SID_ATTR_TRANSFORM_INTERN,
80 	SID_ATTR_TRANSFORM_INTERN,
81 	0
82 };
83 
84 static sal_uInt16 pSlantRanges[] =
85 {
86 	SDRATTR_ECKENRADIUS,
87 	SDRATTR_ECKENRADIUS,
88 	SID_ATTR_TRANSFORM_SHEAR,
89 	SID_ATTR_TRANSFORM_SHEAR_VERTICAL,
90 	SID_ATTR_TRANSFORM_INTERN,
91 	SID_ATTR_TRANSFORM_INTERN,
92 	0
93 };
94 
95 void lcl_ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit)
96 {
97 	const basegfx::B2DPoint aTopLeft(
98 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMinX()), nDigits, ePoolUnit, eDlgUnit),
99 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMinY()), nDigits, ePoolUnit, eDlgUnit));
100 	const basegfx::B2DPoint aBottomRight(
101 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxX()), nDigits, ePoolUnit, eDlgUnit),
102 		(double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxY()), nDigits, ePoolUnit, eDlgUnit));
103 
104 	rRange = basegfx::B2DRange(aTopLeft, aBottomRight);
105 }
106 
107 void lcl_ScaleRect(basegfx::B2DRange& rRange, const Fraction aUIScale)
108 {
109 	const double fFactor(1.0 / double(aUIScale));
110 	rRange = basegfx::B2DRange(rRange.getMinimum() * fFactor, rRange.getMaximum() * fFactor);
111 }
112 
113 /*************************************************************************
114 |*
115 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
116 |*
117 \************************************************************************/
118 
119 SvxTransformTabDialog::SvxTransformTabDialog( Window* pParent, const SfxItemSet* pAttr,
120 								const SdrView* pSdrView, sal_uInt16 nAnchorTypes ) :
121 	SfxTabDialog( pParent, CUI_RES( RID_SVXDLG_TRANSFORM ), pAttr ),
122 	pView       ( pSdrView ),
123 	nAnchorCtrls(nAnchorTypes)
124 {
125 	DBG_ASSERT(pView, "no valid view (!)");
126 	FreeResource();
127 
128     //different positioning page in Writer
129     if(nAnchorCtrls & 0x00ff)
130     {
131         AddTabPage(RID_SVXPAGE_SWPOSSIZE, SvxSwPosSizeTabPage::Create, SvxSwPosSizeTabPage::GetRanges);
132         RemoveTabPage(RID_SVXPAGE_POSITION_SIZE);
133     }
134     else
135     {
136         AddTabPage(RID_SVXPAGE_POSITION_SIZE, SvxPositionSizeTabPage::Create, SvxPositionSizeTabPage::GetRanges);
137         RemoveTabPage(RID_SVXPAGE_SWPOSSIZE);
138     }
139 
140 	AddTabPage(RID_SVXPAGE_ANGLE, SvxAngleTabPage::Create, SvxAngleTabPage::GetRanges);
141 	AddTabPage(RID_SVXPAGE_SLANT, SvxSlantTabPage::Create, SvxSlantTabPage::GetRanges);
142 }
143 
144 // -----------------------------------------------------------------------
145 
146 SvxTransformTabDialog::~SvxTransformTabDialog()
147 {
148 }
149 
150 // -----------------------------------------------------------------------
151 
152 void SvxTransformTabDialog::PageCreated(sal_uInt16 nId, SfxTabPage &rPage)
153 {
154 	switch(nId)
155 	{
156 		case RID_SVXPAGE_POSITION_SIZE:
157 		{
158             SvxPositionSizeTabPage& rSvxPos =  static_cast<SvxPositionSizeTabPage&>(rPage);
159 			rSvxPos.SetView(pView);
160 			rSvxPos.Construct();
161 
162 			if(nAnchorCtrls & SVX_OBJ_NORESIZE)
163 			{
164 				rSvxPos.DisableResize();
165 			}
166 
167 			if(nAnchorCtrls & SVX_OBJ_NOPROTECT)
168 			{
169 				rSvxPos.DisableProtect();
170 				rSvxPos.UpdateControlStates();
171 			}
172 
173 			break;
174 		}
175         case RID_SVXPAGE_SWPOSSIZE :
176         {
177             SvxSwPosSizeTabPage& rSwPos =  static_cast<SvxSwPosSizeTabPage&>(rPage);
178 
179 			rSwPos.EnableAnchorTypes(nAnchorCtrls);
180             rSwPos.SetValidateFramePosLink(aValidateLink);
181             rSwPos.SetView(pView);
182 
183 			break;
184         }
185 
186 		case RID_SVXPAGE_ANGLE:
187 		{
188             SvxAngleTabPage& rSvxAng =  static_cast<SvxAngleTabPage&>(rPage);
189 
190 			rSvxAng.SetView( pView );
191 			rSvxAng.Construct();
192 
193 			break;
194 		}
195 
196 		case RID_SVXPAGE_SLANT:
197 		{
198             SvxSlantTabPage& rSvxSlnt =  static_cast<SvxSlantTabPage&>(rPage);
199 
200 			rSvxSlnt.SetView( pView );
201 			rSvxSlnt.Construct();
202 
203 			break;
204 		}
205 	}
206 }
207 
208 // -----------------------------------------------------------------------
209 
210 void SvxTransformTabDialog::SetValidateFramePosLink(const Link& rLink)
211 {
212     aValidateLink = rLink;
213 }
214 
215 /*************************************************************************
216 |*
217 |*      Dialog zum Aendern der Position des Drehwinkels und des Drehwinkels
218 |*      der Grafikobjekte
219 |*
220 \************************************************************************/
221 
222 SvxAngleTabPage::SvxAngleTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
223 	SvxTabPage              ( pParent, CUI_RES( RID_SVXPAGE_ANGLE ), rInAttrs ),
224 	aFlPosition				( this, CUI_RES( FL_POSITION ) ),
225 	aFtPosX                 ( this, CUI_RES( FT_POS_X ) ),
226 	aMtrPosX                ( this, CUI_RES( MTR_FLD_POS_X ) ),
227 	aFtPosY                 ( this, CUI_RES( FT_POS_Y ) ),
228 	aMtrPosY                ( this, CUI_RES( MTR_FLD_POS_Y ) ),
229 	aFtPosPresets			( this, CUI_RES(FT_POSPRESETS) ),
230 	aCtlRect                ( this, CUI_RES( CTL_RECT ) ),
231 
232 	aFlAngle                ( this, CUI_RES( FL_ANGLE ) ),
233 	aFtAngle                ( this, CUI_RES( FT_ANGLE ) ),
234 	aMtrAngle               ( this, CUI_RES( MTR_FLD_ANGLE ) ),
235 	aFtAnglePresets			( this, CUI_RES(FT_ANGLEPRESETS) ),
236 	aCtlAngle               ( this, CUI_RES( CTL_ANGLE ),
237 								RP_RB, 200, 80, CS_ANGLE ),
238 	rOutAttrs               ( rInAttrs )
239 {
240 	FreeResource();
241 
242 	// calculate PoolUnit
243 	SfxItemPool* pPool = rOutAttrs.GetPool();
244 	DBG_ASSERT( pPool, "no pool (!)" );
245 	ePoolUnit = pPool->GetMetric(SID_ATTR_TRANSFORM_POS_X);
246 
247 	aMtrAngle.SetModifyHdl(LINK( this, SvxAngleTabPage, ModifiedHdl));
248 
249 	aCtlRect.SetAccessibleRelationLabeledBy(&aFtPosPresets);
250 	aCtlRect.SetAccessibleRelationMemberOf(&aFlPosition);
251 	aCtlAngle.SetAccessibleRelationLabeledBy(&aFtAnglePresets);
252 	aCtlAngle.SetAccessibleRelationMemberOf(&aFlAngle);
253 }
254 
255 // -----------------------------------------------------------------------
256 
257 void SvxAngleTabPage::Construct()
258 {
259 	DBG_ASSERT(pView, "No valid view (!)");
260 	eDlgUnit = GetModuleFieldUnit(GetItemSet());
261 	SetFieldUnit(aMtrPosX, eDlgUnit, sal_True);
262 	SetFieldUnit(aMtrPosY, eDlgUnit, sal_True);
263 
264 	if(FUNIT_MILE == eDlgUnit || FUNIT_KM == eDlgUnit)
265 	{
266 		aMtrPosX.SetDecimalDigits( 3 );
267 		aMtrPosY.SetDecimalDigits( 3 );
268 	}
269 
270 	{ // #i75273#
271 		Rectangle aTempRect(pView->GetAllMarkedRect());
272 		pView->GetSdrPageView()->LogicToPagePos(aTempRect);
273 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
274 	}
275 
276 	// Take anchor into account (Writer)
277 	const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
278 
279 	if(rMarkList.GetMarkCount())
280 	{
281 		const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
282 		maAnchor = basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y());
283 
284 		if(!maAnchor.equalZero()) // -> Writer
285 		{
286 			maRange = basegfx::B2DRange(maRange.getMinimum() - maAnchor, maRange.getMaximum() - maAnchor);
287 		}
288 	}
289 
290 	// take scale into account
291 	const Fraction aUIScale(pView->GetModel()->GetUIScale());
292 	lcl_ScaleRect(maRange, aUIScale);
293 
294 	// take UI units into account
295 	sal_uInt16 nDigits(aMtrPosX.GetDecimalDigits());
296 	lcl_ConvertRect(maRange, nDigits, (MapUnit)ePoolUnit, eDlgUnit);
297 
298 	if(!pView->IsRotateAllowed())
299 	{
300 		aFlPosition.Disable();
301 		aFtPosX.Disable();
302 		aMtrPosX.Disable();
303 		aFtPosY.Disable();
304 		aMtrPosY.Disable();
305 		aFtPosPresets.Disable();
306 		aCtlRect.Disable();
307 		aFlAngle.Disable();
308 		aFtAngle.Disable();
309 		aMtrAngle.Disable();
310 		aFtAnglePresets.Disable();
311 		aCtlAngle.Disable();
312 	}
313 }
314 
315 // -----------------------------------------------------------------------
316 
317 sal_Bool SvxAngleTabPage::FillItemSet(SfxItemSet& rSet)
318 {
319 	sal_Bool bModified = sal_False;
320 
321 	if(aMtrAngle.IsValueModified() || aMtrPosX.IsValueModified() || aMtrPosY.IsValueModified())
322 	{
323 		const double fUIScale(double(pView->GetModel()->GetUIScale()));
324 		const double fTmpX((GetCoreValue(aMtrPosX, ePoolUnit) + maAnchor.getX()) * fUIScale);
325 		const double fTmpY((GetCoreValue(aMtrPosY, ePoolUnit) + maAnchor.getY()) * fUIScale);
326 
327 		rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE), static_cast<sal_Int32>(aMtrAngle.GetValue())));
328 		rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), basegfx::fround(fTmpX)));
329         rSet.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), basegfx::fround(fTmpY)));
330 
331 		bModified |= sal_True;
332 	}
333 
334 	return bModified;
335 }
336 
337 // -----------------------------------------------------------------------
338 
339 void SvxAngleTabPage::Reset(const SfxItemSet& rAttrs)
340 {
341 	const double fUIScale(double(pView->GetModel()->GetUIScale()));
342 
343 	const SfxPoolItem* pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_ROT_X );
344 	if(pItem)
345 	{
346 		const double fTmp(((double)((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getX()) / fUIScale);
347 		SetMetricValue(aMtrPosX, basegfx::fround(fTmp), ePoolUnit);
348 	}
349 	else
350 	{
351 		aMtrPosX.SetText( String() );
352 	}
353 
354 	pItem = GetItem(rAttrs, SID_ATTR_TRANSFORM_ROT_Y);
355 	if(pItem)
356 	{
357 		const double fTmp(((double)((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getY()) / fUIScale);
358 		SetMetricValue(aMtrPosY, basegfx::fround(fTmp), ePoolUnit);
359 	}
360 	else
361 	{
362 		aMtrPosX.SetText( String() );
363 	}
364 
365 	pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_ANGLE );
366 	if(pItem)
367 	{
368 		aMtrAngle.SetValue(((const SfxInt32Item*)pItem)->GetValue());
369 	}
370 	else
371 	{
372 		aMtrAngle.SetText( String() );
373 	}
374 
375 	aMtrAngle.SaveValue();
376 	ModifiedHdl(this);
377 }
378 
379 // -----------------------------------------------------------------------
380 
381 SfxTabPage* SvxAngleTabPage::Create( Window* pWindow, const SfxItemSet& rSet)
382 {
383     return(new SvxAngleTabPage(pWindow, rSet));
384 }
385 
386 //------------------------------------------------------------------------
387 
388 sal_uInt16* SvxAngleTabPage::GetRanges()
389 {
390 	return(pAngleRanges);
391 }
392 
393 // -----------------------------------------------------------------------
394 
395 void SvxAngleTabPage::ActivatePage(const SfxItemSet& /*rSet*/)
396 {
397 }
398 
399 // -----------------------------------------------------------------------
400 
401 int SvxAngleTabPage::DeactivatePage( SfxItemSet* _pSet )
402 {
403     if(_pSet)
404 	{
405         FillItemSet(*_pSet);
406 	}
407 
408 	return LEAVE_PAGE;
409 }
410 
411 //------------------------------------------------------------------------
412 
413 void SvxAngleTabPage::PointChanged(Window* pWindow, RECT_POINT eRP)
414 {
415 	if(pWindow == &aCtlRect)
416 	{
417 		switch(eRP)
418 		{
419 			case RP_LT:
420 			{
421 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
422 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
423 				break;
424 			}
425 			case RP_MT:
426 			{
427 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
428 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
429 				break;
430 			}
431 			case RP_RT:
432 			{
433 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
434 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
435 				break;
436 			}
437 			case RP_LM:
438 			{
439 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
440 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
441 				break;
442 			}
443 			case RP_MM:
444 			{
445 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
446 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
447 				break;
448 			}
449 			case RP_RM:
450 			{
451 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
452 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
453 				break;
454 			}
455 			case RP_LB:
456 			{
457 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
458 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
459 				break;
460 			}
461 			case RP_MB:
462 			{
463 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
464 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
465 				break;
466 			}
467 			case RP_RB:
468 			{
469 				aMtrPosX.SetUserValue( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
470 				aMtrPosY.SetUserValue( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
471 				break;
472 			}
473 		}
474 	}
475 	else if(pWindow == &aCtlAngle)
476 	{
477 		switch( eRP )
478 		{
479 			case RP_LT: aMtrAngle.SetUserValue( 13500, FUNIT_NONE ); break;
480 			case RP_MT: aMtrAngle.SetUserValue(  9000, FUNIT_NONE ); break;
481 			case RP_RT: aMtrAngle.SetUserValue(  4500, FUNIT_NONE ); break;
482 			case RP_LM: aMtrAngle.SetUserValue( 18000, FUNIT_NONE ); break;
483 			case RP_RM: aMtrAngle.SetUserValue(     0, FUNIT_NONE ); break;
484 			case RP_LB: aMtrAngle.SetUserValue( 22500, FUNIT_NONE ); break;
485 			case RP_MB: aMtrAngle.SetUserValue( 27000, FUNIT_NONE ); break;
486 			case RP_RB: aMtrAngle.SetUserValue( 31500, FUNIT_NONE ); break;
487             case RP_MM: break;
488         }
489 	}
490 }
491 
492 //------------------------------------------------------------------------
493 
494 IMPL_LINK( SvxAngleTabPage, ModifiedHdl, void *, EMPTYARG )
495 {
496 	switch(aMtrAngle.GetValue())
497 	{
498 		case 13500: aCtlAngle.SetActualRP( RP_LT ); break;
499 		case  9000: aCtlAngle.SetActualRP( RP_MT ); break;
500 		case  4500: aCtlAngle.SetActualRP( RP_RT ); break;
501 		case 18000: aCtlAngle.SetActualRP( RP_LM ); break;
502 		case     0: aCtlAngle.SetActualRP( RP_RM ); break;
503 		case 22500: aCtlAngle.SetActualRP( RP_LB ); break;
504 		case 27000: aCtlAngle.SetActualRP( RP_MB ); break;
505 		case 31500: aCtlAngle.SetActualRP( RP_RB ); break;
506 		default:    aCtlAngle.SetActualRP( RP_MM ); break;
507 	}
508 
509 	return( 0L );
510 }
511 
512 /*************************************************************************
513 |*
514 |*      Dialog zum Aendern des Eckenradius und zum Schraegstellen
515 |*
516 \************************************************************************/
517 
518 SvxSlantTabPage::SvxSlantTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
519 	SvxTabPage              ( pParent, CUI_RES( RID_SVXPAGE_SLANT ), rInAttrs ),
520 
521 	aFlRadius               ( this, CUI_RES( FL_RADIUS ) ),
522 	aFtRadius               ( this, CUI_RES( FT_RADIUS ) ),
523 	aMtrRadius              ( this, CUI_RES( MTR_FLD_RADIUS ) ),
524 	aFlAngle                ( this, CUI_RES( FL_SLANT ) ),
525 	aFtAngle                ( this, CUI_RES( FT_ANGLE ) ),
526 	aMtrAngle               ( this, CUI_RES( MTR_FLD_ANGLE ) ),
527 	rOutAttrs               ( rInAttrs )
528 {
529 	FreeResource();
530 
531 	// this page needs ExchangeSupport
532 	SetExchangeSupport();
533 
534 	// evaluate PoolUnit
535 	SfxItemPool* pPool = rOutAttrs.GetPool();
536 	DBG_ASSERT( pPool, "no pool (!)" );
537 	ePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X );
538 }
539 
540 // -----------------------------------------------------------------------
541 
542 void SvxSlantTabPage::Construct()
543 {
544 	// get the range
545 	DBG_ASSERT(pView, "no valid view (!)");
546 	eDlgUnit = GetModuleFieldUnit(GetItemSet());
547 	SetFieldUnit(aMtrRadius, eDlgUnit, sal_True);
548 
549 	{ // #i75273#
550 		Rectangle aTempRect(pView->GetAllMarkedRect());
551 		pView->GetSdrPageView()->LogicToPagePos(aTempRect);
552 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
553 	}
554 }
555 
556 // -----------------------------------------------------------------------
557 
558 sal_Bool SvxSlantTabPage::FillItemSet(SfxItemSet& rAttrs)
559 {
560 	sal_Bool  bModified = sal_False;
561 	sal_Int32 nValue = 0L;
562 	String aStr = aMtrRadius.GetText();
563 
564 	if( aStr != aMtrRadius.GetSavedValue() )
565 	{
566 		Fraction aUIScale = pView->GetModel()->GetUIScale();
567 		long nTmp = GetCoreValue( aMtrRadius, ePoolUnit );
568 		nTmp = Fraction( nTmp ) * aUIScale;
569 
570 		rAttrs.Put( SdrEckenradiusItem( nTmp ) );
571 		bModified = sal_True;
572 	}
573 
574 	aStr = aMtrAngle.GetText();
575 
576 	if( aStr != aMtrAngle.GetSavedValue() )
577 	{
578 		nValue = static_cast<sal_Int32>(aMtrAngle.GetValue());
579 		rAttrs.Put( SfxInt32Item( SID_ATTR_TRANSFORM_SHEAR, nValue ) );
580 		bModified = sal_True;
581 	}
582 
583 	if( bModified )
584 	{
585 		// Referenzpunkt setzen
586 		// #75897#
587 		Rectangle aObjectRect(pView->GetAllMarkedRect());
588 		pView->GetSdrPageView()->LogicToPagePos(aObjectRect);
589 		Point aPt = aObjectRect.Center();
590 
591 		rAttrs.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_X, aPt.X()));
592 		rAttrs.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_Y, aPt.Y()));
593 		rAttrs.Put( SfxBoolItem( SID_ATTR_TRANSFORM_SHEAR_VERTICAL, sal_False ) );
594 	}
595 
596 	return( bModified );
597 }
598 
599 // -----------------------------------------------------------------------
600 
601 void SvxSlantTabPage::Reset(const SfxItemSet& rAttrs)
602 {
603 	// if the view has selected objects, items with SFX_ITEM_DEFAULT need to be disabled
604 	const SfxPoolItem* pItem;
605 
606 	// Eckenradius
607 	if(!pView->IsEdgeRadiusAllowed())
608 	{
609 		aFlRadius.Disable();
610 		aFtRadius.Disable();
611 		aMtrRadius.Disable();
612 		aMtrRadius.SetText( String() );
613 	}
614 	else
615 	{
616 		pItem = GetItem( rAttrs, SDRATTR_ECKENRADIUS );
617 
618 		if( pItem )
619 		{
620 			const double fUIScale(double(pView->GetModel()->GetUIScale()));
621 			const double fTmp((double)((const SdrEckenradiusItem*)pItem)->GetValue() / fUIScale);
622 			SetMetricValue(aMtrRadius, basegfx::fround(fTmp), ePoolUnit);
623 		}
624 		else
625 		{
626 			aMtrRadius.SetText( String() );
627 		}
628 	}
629 
630 	aMtrRadius.SaveValue();
631 
632 	// Schraegstellen: Winkel
633 	if( !pView->IsShearAllowed() )
634 	{
635 		aFlAngle.Disable();
636 		aFtAngle.Disable();
637 		aMtrAngle.Disable();
638 		aMtrAngle.SetText( String() );
639 	}
640 	else
641 	{
642 		pItem = GetItem( rAttrs, SID_ATTR_TRANSFORM_SHEAR );
643 
644 		if( pItem )
645 		{
646 			aMtrAngle.SetValue( ( (const SfxInt32Item*)pItem )->GetValue() );
647 		}
648 		else
649 		{
650 			aMtrAngle.SetText( String() );
651 		}
652 	}
653 
654 	aMtrAngle.SaveValue();
655 }
656 
657 // -----------------------------------------------------------------------
658 
659 SfxTabPage* SvxSlantTabPage::Create( Window* pWindow, const SfxItemSet& rOutAttrs )
660 {
661 	return( new SvxSlantTabPage( pWindow, rOutAttrs ) );
662 }
663 
664 //------------------------------------------------------------------------
665 
666 sal_uInt16* SvxSlantTabPage::GetRanges()
667 {
668 	return( pSlantRanges );
669 }
670 
671 // -----------------------------------------------------------------------
672 
673 void SvxSlantTabPage::ActivatePage( const SfxItemSet& rSet )
674 {
675 	SfxRectangleItem* pRectItem = NULL;
676 
677 	if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN ) , sal_False, (const SfxPoolItem**) &pRectItem ) )
678 	{
679 		const Rectangle aTempRect(pRectItem->GetValue());
680 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
681 	}
682 }
683 
684 // -----------------------------------------------------------------------
685 
686 int SvxSlantTabPage::DeactivatePage( SfxItemSet* _pSet )
687 {
688     if(_pSet)
689 	{
690         FillItemSet(*_pSet);
691 	}
692 
693 	return LEAVE_PAGE;
694 }
695 
696 //------------------------------------------------------------------------
697 
698 void SvxSlantTabPage::PointChanged( Window* , RECT_POINT  )
699 {
700 }
701 
702 /*************************************************************************
703 |*
704 |*      Dialog for changing position and size of graphic objects
705 |*
706 \************************************************************************/
707 
708 SvxPositionSizeTabPage::SvxPositionSizeTabPage( Window* pParent, const SfxItemSet& rInAttrs  ) :
709 	SvxTabPage      ( pParent, CUI_RES( RID_SVXPAGE_POSITION_SIZE ), rInAttrs ),
710 	maFlPosition		( this, CUI_RES( FL_POSITION ) ),
711 	maFtPosX			( this, CUI_RES( FT_POS_X ) ),
712 	maMtrPosX			( this, CUI_RES( MTR_FLD_POS_X ) ),
713 	maFtPosY			( this, CUI_RES( FT_POS_Y ) ),
714 	maMtrPosY			( this, CUI_RES( MTR_FLD_POS_Y ) ),
715     maFtPosReference    ( this, CUI_RES( FT_POSREFERENCE ) ),
716     maCtlPos            ( this, CUI_RES( CTL_POSRECT ), RP_LT ),
717 
718     maFlSize                         ( this, CUI_RES( FL_SIZE ) ),
719 	maFtWidth                        ( this, CUI_RES( FT_WIDTH ) ),
720 	maMtrWidth                       ( this, CUI_RES( MTR_FLD_WIDTH ) ),
721 	maFtHeight                       ( this, CUI_RES( FT_HEIGHT ) ),
722 	maMtrHeight                      ( this, CUI_RES( MTR_FLD_HEIGHT ) ),
723 	maCbxScale                       ( this, CUI_RES( CBX_SCALE ) ),
724     maFtSizeReference                ( this, CUI_RES( FT_SIZEREFERENCE) ),
725     maCtlSize                        ( this, CUI_RES( CTL_SIZERECT ), RP_LT ),
726 
727     maFlProtect         ( this, CUI_RES( FL_PROTECT) ),
728     maTsbPosProtect     ( this, CUI_RES( TSB_POSPROTECT ) ),
729     maTsbSizeProtect                 ( this, CUI_RES( TSB_SIZEPROTECT ) ),
730 
731 
732     maFlAdjust                       ( this, CUI_RES( FL_ADJUST ) ),
733 	maTsbAutoGrowWidth				( this, CUI_RES( TSB_AUTOGROW_WIDTH ) ),
734 	maTsbAutoGrowHeight				( this, CUI_RES( TSB_AUTOGROW_HEIGHT ) ),
735 
736 	maFlDivider						(this, CUI_RES( FL_DIVIDER ) ),
737 
738     mrOutAttrs       ( rInAttrs ),
739     mnProtectSizeState( STATE_NOCHECK ),
740     mbPageDisabled   ( sal_False ),
741     mbProtectDisabled( false ),
742     mbSizeDisabled( false ),
743     mbAdjustDisabled( true )
744 {
745 	FreeResource();
746 
747 	// this pege needs ExchangeSupport
748 	SetExchangeSupport();
749 
750 	// evaluate PoolUnit
751 	SfxItemPool* pPool = mrOutAttrs.GetPool();
752 	DBG_ASSERT( pPool, "no pool (!)" );
753 	mePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X );
754 
755 	meRP = RP_LT; // s.o.
756 
757 	maMtrWidth.SetModifyHdl( LINK( this, SvxPositionSizeTabPage, ChangeWidthHdl ) );
758 	maMtrHeight.SetModifyHdl( LINK( this, SvxPositionSizeTabPage, ChangeHeightHdl ) );
759 	maCbxScale.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickAutoHdl ) );
760 
761 	maTsbAutoGrowWidth.Disable();
762 	maTsbAutoGrowHeight.Disable();
763 	maFlAdjust.Disable();
764 
765 	// #i2379# disable controls when protected
766 	maTsbPosProtect.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ChangePosProtectHdl ) );
767 	maTsbSizeProtect.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ChangeSizeProtectHdl ) );
768 
769 	maCtlPos.SetAccessibleRelationMemberOf( &maFlPosition );
770 	maCtlSize.SetAccessibleRelationMemberOf( &maFlSize );
771     maCtlPos.SetAccessibleRelationLabeledBy( &maFtPosReference );
772 	maCtlSize.SetAccessibleRelationLabeledBy( &maFtSizeReference );
773 }
774 
775 // -----------------------------------------------------------------------
776 
777 void SvxPositionSizeTabPage::Construct()
778 {
779 	// get range and work area
780 	DBG_ASSERT( mpView, "no valid view (!)" );
781 	meDlgUnit = GetModuleFieldUnit( GetItemSet() );
782 	SetFieldUnit( maMtrPosX, meDlgUnit, sal_True );
783 	SetFieldUnit( maMtrPosY, meDlgUnit, sal_True );
784 	SetFieldUnit( maMtrWidth, meDlgUnit, sal_True );
785 	SetFieldUnit( maMtrHeight, meDlgUnit, sal_True );
786 
787 	if(FUNIT_MILE == meDlgUnit || FUNIT_KM == meDlgUnit)
788 	{
789 		maMtrPosX.SetDecimalDigits( 3 );
790 		maMtrPosY.SetDecimalDigits( 3 );
791 		maMtrWidth.SetDecimalDigits( 3 );
792 		maMtrHeight.SetDecimalDigits( 3 );
793 	}
794 
795 	{ // #i75273#
796 		Rectangle aTempRect(mpView->GetAllMarkedRect());
797 		mpView->GetSdrPageView()->LogicToPagePos(aTempRect);
798 		maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
799 	}
800 
801 	{ // #i75273#
802 		Rectangle aTempRect(mpView->GetWorkArea());
803 		mpView->GetSdrPageView()->LogicToPagePos(aTempRect);
804 		maWorkRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
805 	}
806 
807 	// take anchor into account (Writer)
808 	const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
809 
810 	if(rMarkList.GetMarkCount())
811 	{
812 		const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
813 		maAnchor = basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y());
814 
815 		if(!maAnchor.equalZero()) // -> Writer
816 		{
817 			for(sal_uInt16 i(1); i < rMarkList.GetMarkCount(); i++)
818 			{
819 				pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
820 
821 				if(maAnchor != basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y()))
822 				{
823 					// diferent anchor positions
824 					maMtrPosX.SetText( String() );
825 					maMtrPosY.SetText( String() );
826 					mbPageDisabled = sal_True;
827 					return;
828 				}
829 			}
830 
831 			// translate ranges about anchor
832 			maRange = basegfx::B2DRange(maRange.getMinimum() - maAnchor, maRange.getMaximum() - maAnchor);
833 			maWorkRange = basegfx::B2DRange(maWorkRange.getMinimum() - maAnchor, maWorkRange.getMaximum() - maAnchor);
834 		}
835 	}
836 
837 	// this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
838 	if(1 == rMarkList.GetMarkCount())
839 	{
840 		const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
841 		const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
842 
843 		if((pObj->GetObjInventor() == SdrInventor) &&
844             (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) &&
845             // #121917# The original ((SdrTextObj*)pObj)->HasText() will fail badly with SdrVirtObjs from Writer
846             0 != dynamic_cast< const SdrTextObj* >(pObj) &&
847             static_cast< const 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