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