xref: /AOO41X/main/cui/source/tabpages/transfrm.cxx (revision 707fc0d4d52eb4f69d89a98ffec6918ca5de6326)
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) && (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) && ((SdrTextObj*)pObj)->HasText())
844         {
845             mbAdjustDisabled = false;
846             maFlAdjust.Enable();
847             maTsbAutoGrowWidth.Enable();
848             maTsbAutoGrowHeight.Enable();
849             maTsbAutoGrowWidth.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
850             maTsbAutoGrowHeight.SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
851 
852             // is used as flag to evaluate if its selectable
853             maTsbAutoGrowWidth.EnableTriState( sal_False );
854             maTsbAutoGrowHeight.EnableTriState( sal_False );
855         }
856     }
857 
858     // take scale into account
859     const Fraction aUIScale(mpView->GetModel()->GetUIScale());
860     lcl_ScaleRect( maWorkRange, aUIScale );
861     lcl_ScaleRect( maRange, aUIScale );
862 
863     // take UI units into account
864     const sal_uInt16 nDigits(maMtrPosX.GetDecimalDigits());
865     lcl_ConvertRect( maWorkRange, nDigits, (MapUnit) mePoolUnit, meDlgUnit );
866     lcl_ConvertRect( maRange, nDigits, (MapUnit) mePoolUnit, meDlgUnit );
867 
868     SetMinMaxPosition();
869 }
870 
871 // -----------------------------------------------------------------------
872 
873 sal_Bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet& rOutAttrs )
874 {
875     sal_Bool bModified(sal_False);
876 
877     if ( maMtrWidth.HasFocus() )
878     {
879         ChangeWidthHdl( this );
880     }
881 
882     if ( maMtrHeight.HasFocus() )
883     {
884         ChangeHeightHdl( this );
885     }
886 
887     if( !mbPageDisabled )
888     {
889         if ( maMtrPosX.IsValueModified() || maMtrPosY.IsValueModified() )
890         {
891             const double fUIScale(double(mpView->GetModel()->GetUIScale()));
892             double fX((GetCoreValue( maMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale);
893             double fY((GetCoreValue( maMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale);
894 
895             { // #i75273#
896                 Rectangle aTempRect(mpView->GetAllMarkedRect());
897                 mpView->GetSdrPageView()->LogicToPagePos(aTempRect);
898                 maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
899             }
900 
901             // #101581# GetTopLeftPosition(...) needs coordinates after UI scaling, in real PagePositions
902             GetTopLeftPosition(fX, fY, maRange);
903 
904             rOutAttrs.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_X), basegfx::fround(fX)));
905             rOutAttrs.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_Y), basegfx::fround(fY)));
906 
907             bModified |= sal_True;
908         }
909 
910         if ( maTsbPosProtect.GetState() != maTsbPosProtect.GetSavedValue() )
911         {
912             if( maTsbPosProtect.GetState() == STATE_DONTKNOW )
913             {
914                 rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
915             }
916             else
917             {
918                 rOutAttrs.Put(
919                     SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
920                     maTsbPosProtect.GetState() == STATE_CHECK ? sal_True : sal_False ) );
921             }
922 
923             bModified |= sal_True;
924         }
925     }
926 
927     if ( maMtrWidth.IsValueModified() || maMtrHeight.IsValueModified() )
928     {
929         Fraction aUIScale = mpView->GetModel()->GetUIScale();
930 
931         // get Width
932         double nWidth = static_cast<double>(maMtrWidth.GetValue( meDlgUnit ));
933         nWidth = MetricField::ConvertDoubleValue( nWidth, maMtrWidth.GetBaseValue(), maMtrWidth.GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
934         long lWidth = long(nWidth * (double)aUIScale);
935         lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit );
936         lWidth = static_cast<long>(maMtrWidth.Denormalize( lWidth ));
937 
938         // get Height
939         double nHeight = static_cast<double>(maMtrHeight.GetValue( meDlgUnit ));
940         nHeight = MetricField::ConvertDoubleValue( nHeight, maMtrHeight.GetBaseValue(), maMtrHeight.GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
941         long lHeight = long(nHeight * (double)aUIScale);
942         lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit );
943         lHeight = static_cast<long>(maMtrWidth.Denormalize( lHeight ));
944 
945         // put Width & Height to itemset
946         rOutAttrs.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ),
947                         (sal_uInt32) lWidth ) );
948         rOutAttrs.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ),
949                         (sal_uInt32) lHeight ) );
950         rOutAttrs.Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal::static_int_cast< sal_uInt16 >( meRP ) ) );
951         bModified |= sal_True;
952     }
953 
954     if ( maTsbSizeProtect.GetState() != maTsbSizeProtect.GetSavedValue() )
955     {
956         if ( maTsbSizeProtect.GetState() == STATE_DONTKNOW )
957             rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
958         else
959             rOutAttrs.Put(
960                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
961                 maTsbSizeProtect.GetState() == STATE_CHECK ? sal_True : sal_False ) );
962         bModified |= sal_True;
963     }
964 
965     if ( maTsbAutoGrowWidth.GetState() != maTsbAutoGrowWidth.GetSavedValue() )
966     {
967         if ( !maTsbAutoGrowWidth.IsTriStateEnabled() )
968         {
969             if( maTsbAutoGrowWidth.GetState() == STATE_DONTKNOW )
970                 rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH );
971             else
972                 rOutAttrs.Put(
973                     SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH ),
974                     maTsbAutoGrowWidth.GetState() == STATE_CHECK ? sal_True : sal_False ) );
975         }
976         bModified |= sal_True;
977     }
978 
979     if ( maTsbAutoGrowHeight.GetState() != maTsbAutoGrowHeight.GetSavedValue() )
980     {
981         if ( !maTsbAutoGrowHeight.IsTriStateEnabled() )
982         {
983             if( maTsbAutoGrowHeight.GetState() == STATE_DONTKNOW )
984                 rOutAttrs.InvalidateItem( SID_ATTR_TRANSFORM_AUTOHEIGHT );
985             else
986                 rOutAttrs.Put(
987                     SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT ),
988                     maTsbAutoGrowHeight.GetState() == STATE_CHECK ? sal_True : sal_False ) );
989         }
990         bModified |= sal_True;
991     }
992 
993 
994     return bModified;
995 }
996 
997 // -----------------------------------------------------------------------
998 
999 void SvxPositionSizeTabPage::Reset( const SfxItemSet&  )
1000 {
1001     const SfxPoolItem* pItem;
1002     const double fUIScale(double(mpView->GetModel()->GetUIScale()));
1003 
1004     if ( !mbPageDisabled )
1005     {
1006         pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_POS_X );
1007         if ( pItem )
1008         {
1009             const double fTmp((((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getX()) / fUIScale);
1010             SetMetricValue(maMtrPosX, basegfx::fround(fTmp), mePoolUnit);
1011         }
1012 
1013         pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_POS_Y );
1014         if ( pItem )
1015         {
1016             const double fTmp((((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getY()) / fUIScale);
1017             SetMetricValue(maMtrPosY, basegfx::fround(fTmp), mePoolUnit);
1018         }
1019 
1020         pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_POS );
1021         if ( pItem )
1022         {
1023             sal_Bool bProtected = ( ( const SfxBoolItem* )pItem )->GetValue();
1024             maTsbPosProtect.SetState( bProtected ? STATE_CHECK : STATE_NOCHECK );
1025             maTsbPosProtect.EnableTriState( sal_False );
1026         }
1027         else
1028         {
1029             maTsbPosProtect.SetState( STATE_DONTKNOW );
1030         }
1031 
1032         maTsbPosProtect.SaveValue();
1033         maCtlPos.Reset();
1034 
1035         // #i2379# Disable controls for protected objects
1036         ChangePosProtectHdl( this );
1037     }
1038 
1039     { // #i75273# set width
1040         pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_WIDTH );
1041         mfOldWidth = std::max( pItem ? (double)((const SfxUInt32Item*)pItem)->GetValue() : 0.0, 1.0 );
1042         double fTmpWidth((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldWidth), (MapUnit)mePoolUnit, MAP_100TH_MM)) / fUIScale);
1043 
1044         if(maMtrWidth.GetDecimalDigits())
1045             fTmpWidth *= pow(10.0, maMtrWidth.GetDecimalDigits());
1046 
1047         fTmpWidth = MetricField::ConvertDoubleValue(fTmpWidth, maMtrWidth.GetBaseValue(), maMtrWidth.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit);
1048         maMtrWidth.SetValue(static_cast<sal_Int64>(fTmpWidth), meDlgUnit);
1049     }
1050 
1051     { // #i75273# set height
1052         pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_HEIGHT );
1053         mfOldHeight = std::max( pItem ? (double)((const SfxUInt32Item*)pItem)->GetValue() : 0.0, 1.0 );
1054         double fTmpHeight((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldHeight), (MapUnit)mePoolUnit, MAP_100TH_MM)) / fUIScale);
1055 
1056         if(maMtrHeight.GetDecimalDigits())
1057             fTmpHeight *= pow(10.0, maMtrHeight.GetDecimalDigits());
1058 
1059         fTmpHeight = MetricField::ConvertDoubleValue(fTmpHeight, maMtrHeight.GetBaseValue(), maMtrHeight.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit);
1060         maMtrHeight.SetValue(static_cast<sal_Int64>(fTmpHeight), meDlgUnit);
1061     }
1062 
1063     pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_SIZE );
1064     if ( pItem )
1065     {
1066         maTsbSizeProtect.SetState( ( (const SfxBoolItem*)pItem )->GetValue()
1067                               ? STATE_CHECK : STATE_NOCHECK );
1068         maTsbSizeProtect.EnableTriState( sal_False );
1069     }
1070     else
1071         maTsbSizeProtect.SetState( STATE_DONTKNOW );
1072 
1073     pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_AUTOWIDTH );
1074     if ( pItem )
1075     {
1076         maTsbAutoGrowWidth.SetState( ( ( const SfxBoolItem* )pItem )->GetValue()
1077                            ? STATE_CHECK : STATE_NOCHECK );
1078     }
1079     else
1080         maTsbAutoGrowWidth.SetState( STATE_DONTKNOW );
1081 
1082     pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_AUTOHEIGHT );
1083     if ( pItem )
1084     {
1085         maTsbAutoGrowHeight.SetState( ( ( const SfxBoolItem* )pItem )->GetValue()
1086                            ? STATE_CHECK : STATE_NOCHECK );
1087     }
1088     else
1089         maTsbAutoGrowHeight.SetState( STATE_DONTKNOW );
1090 
1091     // Ist Abgleich gesetzt?
1092     String aStr = GetUserData();
1093     maCbxScale.Check( (sal_Bool)aStr.ToInt32() );
1094 
1095     maTsbSizeProtect.SaveValue();
1096     maTsbAutoGrowWidth.SaveValue();
1097     maTsbAutoGrowHeight.SaveValue();
1098     ClickSizeProtectHdl( NULL );
1099 
1100     // #i2379# Disable controls for protected objects
1101     ChangeSizeProtectHdl( this );
1102 }
1103 
1104 // -----------------------------------------------------------------------
1105 
1106 SfxTabPage* SvxPositionSizeTabPage::Create( Window* pWindow, const SfxItemSet& rOutAttrs )
1107 {
1108     return( new SvxPositionSizeTabPage( pWindow, rOutAttrs ) );
1109 }
1110 
1111 //------------------------------------------------------------------------
1112 
1113 sal_uInt16* SvxPositionSizeTabPage::GetRanges()
1114 {
1115     return( pPosSizeRanges );
1116 }
1117 
1118 // -----------------------------------------------------------------------
1119 
1120 void SvxPositionSizeTabPage::ActivatePage( const SfxItemSet& rSet )
1121 {
1122     SfxRectangleItem* pRectItem = NULL;
1123 
1124     if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN ) , sal_False, (const SfxPoolItem**) &pRectItem ) )
1125     {
1126         { // #i75273#
1127             const Rectangle aTempRect(pRectItem->GetValue());
1128             maRange = basegfx::B2DRange(aTempRect.Left(), aTempRect.Top(), aTempRect.Right(), aTempRect.Bottom());
1129         }
1130 
1131         SetMinMaxPosition();
1132     }
1133 }
1134 
1135 // -----------------------------------------------------------------------
1136 
1137 int SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
1138 {
1139     if( _pSet )
1140     {
1141         double fX((double)maMtrPosX.GetValue());
1142         double fY((double)maMtrPosY.GetValue());
1143 
1144         GetTopLeftPosition(fX, fY, maRange);
1145         const Rectangle aOutRectangle(
1146             basegfx::fround(fX), basegfx::fround(fY),
1147             basegfx::fround(fX + maRange.getWidth()), basegfx::fround(fY + maRange.getHeight()));
1148         _pSet->Put(SfxRectangleItem(SID_ATTR_TRANSFORM_INTERN, aOutRectangle));
1149 
1150         FillItemSet(*_pSet);
1151     }
1152 
1153     return LEAVE_PAGE;
1154 }
1155 
1156 //------------------------------------------------------------------------
1157 
1158 IMPL_LINK( SvxPositionSizeTabPage, ChangePosProtectHdl, void *, EMPTYARG )
1159 {
1160     // #106572# Remember user's last choice
1161     maTsbSizeProtect.SetState( maTsbPosProtect.GetState() == STATE_CHECK ?  STATE_CHECK : mnProtectSizeState );
1162     UpdateControlStates();
1163     return( 0L );
1164 }
1165 
1166 //------------------------------------------------------------------------
1167 
1168 void SvxPositionSizeTabPage::UpdateControlStates()
1169 {
1170     const bool bPosProtect =  maTsbPosProtect.GetState() == STATE_CHECK;
1171     const bool bSizeProtect = maTsbSizeProtect.GetState() == STATE_CHECK;
1172     const bool bHeightChecked = !maTsbAutoGrowHeight.IsTriStateEnabled() && (maTsbAutoGrowHeight.GetState() == STATE_CHECK);
1173     const bool bWidthChecked = !maTsbAutoGrowWidth.IsTriStateEnabled() && (maTsbAutoGrowWidth.GetState() == STATE_CHECK);
1174 
1175     maFlPosition.Enable( !bPosProtect && !mbPageDisabled );
1176     maFtPosX.Enable( !bPosProtect && !mbPageDisabled );
1177     maMtrPosX.Enable( !bPosProtect && !mbPageDisabled );
1178     maFtPosY.Enable( !bPosProtect && !mbPageDisabled );
1179     maMtrPosY.Enable( !bPosProtect && !mbPageDisabled );
1180     maFtPosReference.Enable( !bPosProtect && !mbPageDisabled );
1181     maCtlPos.Enable( !bPosProtect );
1182     maTsbPosProtect.Enable( !mbProtectDisabled && !mbPageDisabled );
1183 
1184     maFlSize.Enable( !mbSizeDisabled && !bSizeProtect );
1185     maCtlSize.Enable( !mbSizeDisabled && !bSizeProtect && (!bHeightChecked || !bWidthChecked) );
1186     maFtWidth.Enable( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
1187     maMtrWidth.Enable( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
1188     maFtHeight.Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
1189     maMtrHeight.Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
1190     maCbxScale.Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked && !bWidthChecked );
1191     maFtSizeReference.Enable( !mbSizeDisabled && !bSizeProtect );
1192     maFlProtect.Enable( !mbProtectDisabled );
1193     maTsbSizeProtect.Enable( !mbProtectDisabled && !bPosProtect );
1194 
1195     maFlAdjust.Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
1196     maTsbAutoGrowWidth.Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
1197     maTsbAutoGrowHeight.Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
1198 
1199     maCtlSize.Invalidate();
1200     maCtlPos.Invalidate();
1201 
1202 }
1203 
1204 //------------------------------------------------------------------------
1205 
1206 IMPL_LINK( SvxPositionSizeTabPage, ChangeSizeProtectHdl, void *, EMPTYARG )
1207 {
1208     if( maTsbSizeProtect.IsEnabled() )
1209     {
1210         // #106572# Remember user's last choice
1211 
1212         // Note: this works only as long as the dialog is open.  When
1213         // the user closes the dialog, there is no way to remember
1214         // whether size was enabled or disabled befor pos protect was
1215         // clicked. Thus, if pos protect is selected, the dialog is
1216         // closed and reopened again, unchecking pos protect will
1217         // always uncheck size protect, too. That's life.
1218         mnProtectSizeState = maTsbSizeProtect.GetState();
1219     }
1220 
1221     UpdateControlStates();
1222 
1223     return( 0L );
1224 }
1225 
1226 //------------------------------------------------------------------------
1227 
1228 IMPL_LINK_INLINE_START( SvxPositionSizeTabPage, ChangePosXHdl, void *, EMPTYARG )
1229 {
1230     return( 0L );
1231 }
1232 IMPL_LINK_INLINE_END( SvxPositionSizeTabPage, ChangePosXHdl, void *, EMPTYARG )
1233 
1234 //------------------------------------------------------------------------
1235 
1236 IMPL_LINK_INLINE_START( SvxPositionSizeTabPage, ChangePosYHdl, void *, EMPTYARG )
1237 {
1238     return( 0L );
1239 }
1240 IMPL_LINK_INLINE_END( SvxPositionSizeTabPage, ChangePosYHdl, void *, EMPTYARG )
1241 
1242 //------------------------------------------------------------------------
1243 
1244 void SvxPositionSizeTabPage::SetMinMaxPosition()
1245 {
1246     // position
1247     double fLeft(maWorkRange.getMinX());
1248     double fTop(maWorkRange.getMinY());
1249     double fRight(maWorkRange.getMaxX());
1250     double fBottom(maWorkRange.getMaxY());
1251 
1252     switch ( maCtlPos.GetActualRP() )
1253     {
1254         case RP_LT:
1255         {
1256             fRight  -= maRange.getWidth();
1257             fBottom -= maRange.getHeight();
1258             break;
1259         }
1260         case RP_MT:
1261         {
1262             fLeft   += maRange.getWidth() / 2.0;
1263             fRight  -= maRange.getWidth() / 2.0;
1264             fBottom -= maRange.getHeight();
1265             break;
1266         }
1267         case RP_RT:
1268         {
1269             fLeft   += maRange.getWidth();
1270             fBottom -= maRange.getHeight();
1271             break;
1272         }
1273         case RP_LM:
1274         {
1275             fRight  -= maRange.getWidth();
1276             fTop    += maRange.getHeight() / 2.0;
1277             fBottom -= maRange.getHeight() / 2.0;
1278             break;
1279         }
1280         case RP_MM:
1281         {
1282             fLeft   += maRange.getWidth() / 2.0;
1283             fRight  -= maRange.getWidth() / 2.0;
1284             fTop    += maRange.getHeight() / 2.0;
1285             fBottom -= maRange.getHeight() / 2.0;
1286             break;
1287         }
1288         case RP_RM:
1289         {
1290             fLeft   += maRange.getWidth();
1291             fTop    += maRange.getHeight() / 2.0;
1292             fBottom -= maRange.getHeight() / 2.0;
1293             break;
1294         }
1295         case RP_LB:
1296         {
1297             fRight  -= maRange.getWidth();
1298             fTop    += maRange.getHeight();
1299             break;
1300         }
1301         case RP_MB:
1302         {
1303             fLeft   += maRange.getWidth() / 2.0;
1304             fRight  -= maRange.getWidth() / 2.0;
1305             fTop    += maRange.getHeight();
1306             break;
1307         }
1308         case RP_RB:
1309         {
1310             fLeft   += maRange.getWidth();
1311             fTop    += maRange.getHeight();
1312             break;
1313         }
1314     }
1315 
1316     const double fMaxLong((double)(MetricField::ConvertValue( LONG_MAX, 0, MAP_100TH_MM, meDlgUnit ) - 1L));
1317     fLeft = (fLeft > fMaxLong) ? fMaxLong : (fLeft < -fMaxLong) ? -fMaxLong : fLeft;
1318     fRight = (fRight > fMaxLong) ? fMaxLong : (fRight < -fMaxLong) ? -fMaxLong : fRight;
1319     fTop = (fTop > fMaxLong) ? fMaxLong : (fTop < -fMaxLong) ? -fMaxLong : fTop;
1320     fBottom = (fBottom > fMaxLong) ? fMaxLong : (fBottom < -fMaxLong) ? -fMaxLong : fBottom;
1321 
1322     // #i75273# normalizing when setting the min/max values was wrong, removed
1323     maMtrPosX.SetMin(basegfx::fround64(fLeft));
1324     maMtrPosX.SetFirst(basegfx::fround64(fLeft));
1325     maMtrPosX.SetMax(basegfx::fround64(fRight));
1326     maMtrPosX.SetLast(basegfx::fround64(fRight));
1327     maMtrPosY.SetMin(basegfx::fround64(fTop));
1328     maMtrPosY.SetFirst(basegfx::fround64(fTop));
1329     maMtrPosY.SetMax(basegfx::fround64(fBottom));
1330     maMtrPosY.SetLast(basegfx::fround64(fBottom));
1331 
1332     // size
1333     fLeft = maWorkRange.getMinX();
1334     fTop = maWorkRange.getMinY();
1335     fRight = maWorkRange.getMaxX();
1336     fBottom = maWorkRange.getMaxY();
1337     double fNewX(0);
1338     double fNewY(0);
1339 
1340     switch ( maCtlSize.GetActualRP() )
1341     {
1342         case RP_LT:
1343         {
1344             fNewX = maWorkRange.getWidth() - ( maRange.getMinX() - fLeft );
1345             fNewY = maWorkRange.getHeight() - ( maRange.getMinY() - fTop );
1346             break;
1347         }
1348         case RP_MT:
1349         {
1350             fNewX = std::min( maRange.getCenter().getX() - fLeft, fRight - maRange.getCenter().getX() ) * 2.0;
1351             fNewY = maWorkRange.getHeight() - ( maRange.getMinY() - fTop );
1352             break;
1353         }
1354         case RP_RT:
1355         {
1356             fNewX = maWorkRange.getWidth() - ( fRight - maRange.getMaxX() );
1357             fNewY = maWorkRange.getHeight() - ( maRange.getMinY() - fTop );
1358             break;
1359         }
1360         case RP_LM:
1361         {
1362             fNewX = maWorkRange.getWidth() - ( maRange.getMinX() - fLeft );
1363             fNewY = std::min( maRange.getCenter().getY() - fTop, fBottom - maRange.getCenter().getY() ) * 2.0;
1364             break;
1365         }
1366         case RP_MM:
1367         {
1368             const double f1(maRange.getCenter().getX() - fLeft);
1369             const double f2(fRight - maRange.getCenter().getX());
1370             const double f3(std::min(f1, f2));
1371             const double f4(maRange.getCenter().getY() - fTop);
1372             const double f5(fBottom - maRange.getCenter().getY());
1373             const double f6(std::min(f4, f5));
1374 
1375             fNewX = f3 * 2.0;
1376             fNewY = f6 * 3.0;
1377 
1378             break;
1379         }
1380         case RP_RM:
1381         {
1382             fNewX = maWorkRange.getWidth() - ( fRight - maRange.getMaxX() );
1383             fNewY = std::min( maRange.getCenter().getY() - fTop, fBottom - maRange.getCenter().getY() ) * 2.0;
1384             break;
1385         }
1386         case RP_LB:
1387         {
1388             fNewX = maWorkRange.getWidth() - ( maRange.getMinX() - fLeft );
1389             fNewY = maWorkRange.getHeight() - ( fBottom - maRange.getMaxY() );
1390             break;
1391         }
1392         case RP_MB:
1393         {
1394             fNewX = std::min( maRange.getCenter().getX() - fLeft, fRight - maRange.getCenter().getX() ) * 2.0;
1395             fNewY = maWorkRange.getHeight() - ( maRange.getMaxY() - fBottom );
1396             break;
1397         }
1398         case RP_RB:
1399         {
1400             fNewX = maWorkRange.getWidth() - ( fRight - maRange.getMaxX() );
1401             fNewY = maWorkRange.getHeight() - ( fBottom - maRange.getMaxY() );
1402             break;
1403         }
1404     }
1405 
1406     // #i75273# normalizing when setting the min/max values was wrong, removed
1407     maMtrWidth.SetMax(basegfx::fround64(fNewX));
1408     maMtrWidth.SetLast(basegfx::fround64(fNewX));
1409     maMtrHeight.SetMax(basegfx::fround64(fNewY));
1410     maMtrHeight.SetLast(basegfx::fround64(fNewY));
1411 }
1412 
1413 //------------------------------------------------------------------------
1414 
1415 void SvxPositionSizeTabPage::GetTopLeftPosition(double& rfX, double& rfY, const basegfx::B2DRange& rRange)
1416 {
1417     switch (maCtlPos.GetActualRP())
1418     {
1419         case RP_LT:
1420         {
1421             break;
1422         }
1423         case RP_MT:
1424         {
1425             rfX -= rRange.getCenter().getX() - rRange.getMinX();
1426             break;
1427         }
1428         case RP_RT:
1429         {
1430             rfX -= rRange.getWidth();
1431             break;
1432         }
1433         case RP_LM:
1434         {
1435             rfY -= rRange.getCenter().getY() - rRange.getMinY();
1436             break;
1437         }
1438         case RP_MM:
1439         {
1440             rfX -= rRange.getCenter().getX() - rRange.getMinX();
1441             rfY -= rRange.getCenter().getY() - rRange.getMinY();
1442             break;
1443         }
1444         case RP_RM:
1445         {
1446             rfX -= rRange.getWidth();
1447             rfY -= rRange.getCenter().getY() - rRange.getMinY();
1448             break;
1449         }
1450         case RP_LB:
1451         {
1452             rfY -= rRange.getHeight();
1453             break;
1454         }
1455         case RP_MB:
1456         {
1457             rfX -= rRange.getCenter().getX() - rRange.getMinX();
1458             rfY -= rRange.getHeight();
1459             break;
1460         }
1461         case RP_RB:
1462         {
1463             rfX -= rRange.getWidth();
1464             rfY -= rRange.getHeight();
1465             break;
1466         }
1467     }
1468 }
1469 
1470 //------------------------------------------------------------------------
1471 
1472 void SvxPositionSizeTabPage::PointChanged( Window* pWindow, RECT_POINT eRP )
1473 {
1474     if( pWindow == &maCtlPos )
1475     {
1476         SetMinMaxPosition();
1477         switch( eRP )
1478         {
1479             case RP_LT:
1480             {
1481                 maMtrPosX.SetValue( basegfx::fround64(maRange.getMinX()) );
1482                 maMtrPosY.SetValue( basegfx::fround64(maRange.getMinY()) );
1483                 break;
1484             }
1485             case RP_MT:
1486             {
1487                 maMtrPosX.SetValue( basegfx::fround64(maRange.getCenter().getX()) );
1488                 maMtrPosY.SetValue( basegfx::fround64(maRange.getMinY()) );
1489                 break;
1490             }
1491             case RP_RT:
1492             {
1493                 maMtrPosX.SetValue( basegfx::fround64(maRange.getMaxX()) );
1494                 maMtrPosY.SetValue( basegfx::fround64(maRange.getMinY()) );
1495                 break;
1496             }
1497             case RP_LM:
1498             {
1499                 maMtrPosX.SetValue( basegfx::fround64(maRange.getMinX()) );
1500                 maMtrPosY.SetValue( basegfx::fround64(maRange.getCenter().getY()) );
1501                 break;
1502             }
1503             case RP_MM:
1504             {
1505                 maMtrPosX.SetValue( basegfx::fround64(maRange.getCenter().getX()) );
1506                 maMtrPosY.SetValue( basegfx::fround64(maRange.getCenter().getY()) );
1507                 break;
1508             }
1509             case RP_RM:
1510             {
1511                 maMtrPosX.SetValue( basegfx::fround64(maRange.getMaxX()) );
1512                 maMtrPosY.SetValue( basegfx::fround64(maRange.getCenter().getY()) );
1513                 break;
1514             }
1515             case RP_LB:
1516             {
1517                 maMtrPosX.SetValue( basegfx::fround64(maRange.getMinX()) );
1518                 maMtrPosY.SetValue( basegfx::fround64(maRange.getMaxY()) );
1519                 break;
1520             }
1521             case RP_MB:
1522             {
1523                 maMtrPosX.SetValue( basegfx::fround64(maRange.getCenter().getX()) );
1524                 maMtrPosY.SetValue( basegfx::fround64(maRange.getMaxY()) );
1525                 break;
1526             }
1527             case RP_RB:
1528             {
1529                 maMtrPosX.SetValue( basegfx::fround64(maRange.getMaxX()) );
1530                 maMtrPosY.SetValue( basegfx::fround64(maRange.getMaxY()) );
1531                 break;
1532             }
1533         }
1534     }
1535     else
1536     {
1537         meRP = eRP;
1538 
1539         Rectangle aTmpRect( GetRect() );
1540         SetMinMaxPosition();
1541     }
1542 }
1543 
1544 //------------------------------------------------------------------------
1545 
1546 void SvxPositionSizeTabPage::DisableResize()
1547 {
1548     mbSizeDisabled = true;
1549 }
1550 
1551 //------------------------------------------------------------------------
1552 
1553 void SvxPositionSizeTabPage::DisableProtect()
1554 {
1555     mbProtectDisabled = true;
1556 }
1557 
1558 //------------------------------------------------------------------------
1559 
1560 Rectangle SvxPositionSizeTabPage::GetRect()
1561 {
1562     double fLeft(maRange.getMinX());
1563     double fTop(maRange.getMinY());
1564     double fRight(fLeft + (double)maMtrWidth.GetValue());
1565     double fBottom(fTop + (double)maMtrHeight.GetValue());
1566 
1567     switch ( maCtlSize.GetActualRP() )
1568     {
1569         case RP_LT:
1570         {
1571             break;
1572         }
1573         case RP_MT:
1574         {
1575             fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() ) / 2.0;
1576             break;
1577         }
1578         case RP_RT:
1579         {
1580             fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() );
1581             break;
1582         }
1583         case RP_LM:
1584         {
1585             fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() ) / 2.0;
1586             break;
1587         }
1588         case RP_MM:
1589         {
1590             fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() ) / 2.0;
1591             fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() ) / 2.0;
1592             break;
1593         }
1594         case RP_RM:
1595         {
1596             fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() );
1597             fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() ) / 2.0;
1598             break;
1599         }
1600         case RP_LB:
1601         {
1602             fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() );
1603             break;
1604         }
1605         case RP_MB:
1606         {
1607             fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() ) / 2.0;
1608             fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() );
1609             break;
1610         }
1611         case RP_RB:
1612         {
1613             fLeft = maRange.getMinX() - ( fRight - maRange.getMaxX() );
1614             fTop = maRange.getMinY() - ( fBottom - maRange.getMaxY() );
1615             break;
1616         }
1617     }
1618 
1619     return Rectangle(basegfx::fround(fLeft), basegfx::fround(fTop), basegfx::fround(fRight), basegfx::fround(fBottom));
1620 }
1621 
1622 //------------------------------------------------------------------------
1623 
1624 IMPL_LINK( SvxPositionSizeTabPage, ChangeWidthHdl, void *, EMPTYARG )
1625 {
1626     if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() )
1627     {
1628         sal_Int64 nHeight(basegfx::fround64((mfOldHeight * (double)maMtrWidth.GetValue()) / mfOldWidth));
1629 
1630         if(nHeight <= maMtrHeight.GetMax(FUNIT_NONE))
1631         {
1632             maMtrHeight.SetUserValue(nHeight, FUNIT_NONE);
1633         }
1634         else
1635         {
1636             nHeight = maMtrHeight.GetMax(FUNIT_NONE);
1637             maMtrHeight.SetUserValue(nHeight);
1638 
1639             const sal_Int64 nWidth(basegfx::fround64((mfOldWidth * (double)nHeight) / mfOldHeight));
1640             maMtrWidth.SetUserValue(nWidth, FUNIT_NONE);
1641         }
1642     }
1643 
1644     return( 0L );
1645 }
1646 
1647 //------------------------------------------------------------------------
1648 
1649 IMPL_LINK( SvxPositionSizeTabPage, ChangeHeightHdl, void *, EMPTYARG )
1650 {
1651     if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() )
1652     {
1653         sal_Int64 nWidth(basegfx::fround64((mfOldWidth * (double)maMtrHeight.GetValue()) / mfOldHeight));
1654 
1655         if(nWidth <= maMtrWidth.GetMax(FUNIT_NONE))
1656         {
1657             maMtrWidth.SetUserValue(nWidth, FUNIT_NONE);
1658         }
1659         else
1660         {
1661             nWidth = maMtrWidth.GetMax(FUNIT_NONE);
1662             maMtrWidth.SetUserValue(nWidth);
1663 
1664             const sal_Int64 nHeight(basegfx::fround64((mfOldHeight * (double)nWidth) / mfOldWidth));
1665             maMtrHeight.SetUserValue(nHeight, FUNIT_NONE);
1666         }
1667     }
1668 
1669     return( 0L );
1670 }
1671 
1672 //------------------------------------------------------------------------
1673 
1674 IMPL_LINK( SvxPositionSizeTabPage, ClickSizeProtectHdl, void *, EMPTYARG )
1675 {
1676     UpdateControlStates();
1677     return( 0L );
1678 }
1679 
1680 //------------------------------------------------------------------------
1681 
1682 IMPL_LINK( SvxPositionSizeTabPage, ClickAutoHdl, void *, EMPTYARG )
1683 {
1684     if( maCbxScale.IsChecked() )
1685     {
1686         mfOldWidth  = std::max( (double)GetCoreValue( maMtrWidth,  mePoolUnit ), 1.0 );
1687         mfOldHeight = std::max( (double)GetCoreValue( maMtrHeight, mePoolUnit ), 1.0 );
1688     }
1689 
1690     return( 0L );
1691 }
1692 
1693 //------------------------------------------------------------------------
1694 
1695 void SvxPositionSizeTabPage::FillUserData()
1696 {
1697     // Abgleich wird in der Ini-Datei festgehalten
1698     UniString aStr = UniString::CreateFromInt32( (sal_Int32) maCbxScale.IsChecked() );
1699     SetUserData( aStr );
1700 }
1701 
1702 // eof
1703