1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <sfx2/app.hxx>
22 #include <svx/svdview.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/svdpagv.hxx>
25 #include <svx/svdotext.hxx>
26 #include <svx/sderitm.hxx>
27 #include <svx/dialogs.hrc>
29 #include <editeng/sizeitem.hxx>
31 #include "transfrm.hxx"
32 #include <dialmgr.hxx>
33 #include "svx/dlgutil.hxx"
34 #include <editeng/svxenum.hxx>
35 #include "svx/anchorid.hxx"
36 #include <sfx2/module.hxx>
37 #include <svl/rectitem.hxx>
38 #include <svl/aeitem.hxx>
39 #include <swpossizetabpage.hxx>
41 // static ----------------------------------------------------------------
43 static const sal_uInt16 pPosSizeRanges
[] =
45 SID_ATTR_TRANSFORM_POS_X
,
46 SID_ATTR_TRANSFORM_POS_Y
,
47 SID_ATTR_TRANSFORM_PROTECT_POS
,
48 SID_ATTR_TRANSFORM_PROTECT_POS
,
49 SID_ATTR_TRANSFORM_INTERN
,
50 SID_ATTR_TRANSFORM_INTERN
,
51 SID_ATTR_TRANSFORM_ANCHOR
,
52 SID_ATTR_TRANSFORM_VERT_ORIENT
,
53 SID_ATTR_TRANSFORM_WIDTH
,
54 SID_ATTR_TRANSFORM_SIZE_POINT
,
55 SID_ATTR_TRANSFORM_PROTECT_POS
,
56 SID_ATTR_TRANSFORM_INTERN
,
57 SID_ATTR_TRANSFORM_AUTOWIDTH
,
58 SID_ATTR_TRANSFORM_AUTOHEIGHT
,
62 static const sal_uInt16 pAngleRanges
[] =
64 SID_ATTR_TRANSFORM_ROT_X
,
65 SID_ATTR_TRANSFORM_ANGLE
,
66 SID_ATTR_TRANSFORM_INTERN
,
67 SID_ATTR_TRANSFORM_INTERN
,
71 static const sal_uInt16 pSlantRanges
[] =
75 SID_ATTR_TRANSFORM_SHEAR
,
76 SID_ATTR_TRANSFORM_SHEAR_VERTICAL
,
77 SID_ATTR_TRANSFORM_INTERN
,
78 SID_ATTR_TRANSFORM_INTERN
,
82 static void lcl_ConvertRect(basegfx::B2DRange
& rRange
, const sal_uInt16 nDigits
, const MapUnit ePoolUnit
, const FieldUnit eDlgUnit
)
84 const basegfx::B2DPoint
aTopLeft(
85 (double)MetricField::ConvertValue(basegfx::fround(rRange
.getMinX()), nDigits
, ePoolUnit
, eDlgUnit
),
86 (double)MetricField::ConvertValue(basegfx::fround(rRange
.getMinY()), nDigits
, ePoolUnit
, eDlgUnit
));
87 const basegfx::B2DPoint
aBottomRight(
88 (double)MetricField::ConvertValue(basegfx::fround(rRange
.getMaxX()), nDigits
, ePoolUnit
, eDlgUnit
),
89 (double)MetricField::ConvertValue(basegfx::fround(rRange
.getMaxY()), nDigits
, ePoolUnit
, eDlgUnit
));
91 rRange
= basegfx::B2DRange(aTopLeft
, aBottomRight
);
94 static void lcl_ScaleRect(basegfx::B2DRange
& rRange
, const Fraction aUIScale
)
96 const double fFactor(1.0 / double(aUIScale
));
97 rRange
= basegfx::B2DRange(rRange
.getMinimum() * fFactor
, rRange
.getMaximum() * fFactor
);
100 /*************************************************************************
102 |* constructor of the tab dialog: adds the pages to the dialog
104 \************************************************************************/
106 SvxTransformTabDialog::SvxTransformTabDialog( Window
* pParent
, const SfxItemSet
* pAttr
,
107 const SdrView
* pSdrView
, sal_uInt16 nAnchorTypes
)
108 : SfxTabDialog( pParent
109 ,"PositionAndSizeDialog"
110 ,"cui/ui/positionsizedialog.ui"
115 , nAnchorCtrls(nAnchorTypes
)
117 DBG_ASSERT(pView
, "no valid view (!)");
119 //different positioning page in Writer
120 if(nAnchorCtrls
& 0x00ff)
122 nSWPosSize
= AddTabPage("RID_SVXPAGE_SWPOSSIZE", SvxSwPosSizeTabPage::Create
, SvxSwPosSizeTabPage::GetRanges
);
123 RemoveTabPage("RID_SVXPAGE_POSITION_SIZE");
127 nPosSize
= AddTabPage("RID_SVXPAGE_POSITION_SIZE", SvxPositionSizeTabPage::Create
, SvxPositionSizeTabPage::GetRanges
);
128 RemoveTabPage("RID_SVXPAGE_SWPOSSIZE");
131 nRotation
= AddTabPage("RID_SVXPAGE_ANGLE", SvxAngleTabPage::Create
, SvxAngleTabPage::GetRanges
);
132 nSlant
= AddTabPage("RID_SVXPAGE_SLANT", SvxSlantTabPage::Create
, SvxSlantTabPage::GetRanges
);
137 SvxTransformTabDialog::~SvxTransformTabDialog()
143 void SvxTransformTabDialog::PageCreated(sal_uInt16 nId
, SfxTabPage
&rPage
)
147 SvxPositionSizeTabPage
& rSvxPos
= static_cast<SvxPositionSizeTabPage
&>(rPage
);
148 rSvxPos
.SetView(pView
);
151 if(nAnchorCtrls
& SVX_OBJ_NORESIZE
)
153 rSvxPos
.DisableResize();
156 if(nAnchorCtrls
& SVX_OBJ_NOPROTECT
)
158 rSvxPos
.DisableProtect();
159 rSvxPos
.UpdateControlStates();
162 else if (nId
== nSWPosSize
)
164 SvxSwPosSizeTabPage
& rSwPos
= static_cast<SvxSwPosSizeTabPage
&>(rPage
);
166 rSwPos
.EnableAnchorTypes(nAnchorCtrls
);
167 rSwPos
.SetValidateFramePosLink(aValidateLink
);
168 rSwPos
.SetView(pView
);
171 else if( nId
== nRotation
)
173 SvxAngleTabPage
& rSvxAng
= static_cast<SvxAngleTabPage
&>(rPage
);
175 rSvxAng
.SetView( pView
);
179 else if (nId
== nSlant
)
181 SvxSlantTabPage
& rSvxSlnt
= static_cast<SvxSlantTabPage
&>(rPage
);
183 rSvxSlnt
.SetView( pView
);
184 rSvxSlnt
.Construct();
190 void SvxTransformTabDialog::SetValidateFramePosLink(const Link
& rLink
)
192 aValidateLink
= rLink
;
195 /*************************************************************************
197 |* dialog for changing the positions of the rotation
198 |* angle and the rotation angle of the graphic objects
200 \************************************************************************/
201 SvxAngleTabPage::SvxAngleTabPage(Window
* pParent
, const SfxItemSet
& rInAttrs
)
202 : SvxTabPage( pParent
,"Rotation","cui/ui/rotationtabpage.ui", rInAttrs
)
203 , rOutAttrs(rInAttrs
)
205 , eDlgUnit(FUNIT_NONE
)
207 get(m_pFlPosition
, "FL_POSITION");
208 get(m_pMtrPosX
, "MTR_FLD_POS_X");
209 get(m_pMtrPosY
, "MTR_FLD_POS_Y");
210 get(m_pCtlRect
, "CTL_RECT");
212 get(m_pFlAngle
, "FL_ANGLE");
213 get(m_pNfAngle
, "NF_ANGLE");
214 get(m_pCtlAngle
, "CTL_ANGLE");
216 // calculate PoolUnit
217 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
218 DBG_ASSERT( pPool
, "no pool (!)" );
219 ePoolUnit
= pPool
->GetMetric(SID_ATTR_TRANSFORM_POS_X
);
221 m_pCtlAngle
->SetLinkedField( m_pNfAngle
, 2 );
224 void SvxAngleTabPage::Construct()
226 DBG_ASSERT(pView
, "No valid view (!)");
227 eDlgUnit
= GetModuleFieldUnit(GetItemSet());
228 SetFieldUnit(*m_pMtrPosX
, eDlgUnit
, true);
229 SetFieldUnit(*m_pMtrPosY
, eDlgUnit
, true);
231 if(FUNIT_MILE
== eDlgUnit
|| FUNIT_KM
== eDlgUnit
)
233 m_pMtrPosX
->SetDecimalDigits( 3 );
234 m_pMtrPosY
->SetDecimalDigits( 3 );
238 Rectangle
aTempRect(pView
->GetAllMarkedRect());
239 pView
->GetSdrPageView()->LogicToPagePos(aTempRect
);
240 maRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
243 // Take anchor into account (Writer)
244 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
246 if(rMarkList
.GetMarkCount())
248 const SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
249 maAnchor
= basegfx::B2DPoint(pObj
->GetAnchorPos().X(), pObj
->GetAnchorPos().Y());
251 if(!maAnchor
.equalZero()) // -> Writer
253 maRange
= basegfx::B2DRange(maRange
.getMinimum() - maAnchor
, maRange
.getMaximum() - maAnchor
);
257 // take scale into account
258 const Fraction
aUIScale(pView
->GetModel()->GetUIScale());
259 lcl_ScaleRect(maRange
, aUIScale
);
261 // take UI units into account
262 sal_uInt16
nDigits(m_pMtrPosX
->GetDecimalDigits());
263 lcl_ConvertRect(maRange
, nDigits
, (MapUnit
)ePoolUnit
, eDlgUnit
);
265 if(!pView
->IsRotateAllowed())
267 m_pFlPosition
->Disable();
268 m_pFlAngle
->Disable();
272 bool SvxAngleTabPage::FillItemSet(SfxItemSet
& rSet
)
274 bool bModified
= false;
276 if(m_pCtlAngle
->IsValueModified() || m_pMtrPosX
->IsValueModified() || m_pMtrPosY
->IsValueModified())
278 const double fUIScale(double(pView
->GetModel()->GetUIScale()));
279 const double fTmpX((GetCoreValue(*m_pMtrPosX
, ePoolUnit
) + maAnchor
.getX()) * fUIScale
);
280 const double fTmpY((GetCoreValue(*m_pMtrPosY
, ePoolUnit
) + maAnchor
.getY()) * fUIScale
);
282 rSet
.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE
), m_pCtlAngle
->GetRotation()));
283 rSet
.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X
), basegfx::fround(fTmpX
)));
284 rSet
.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y
), basegfx::fround(fTmpY
)));
294 void SvxAngleTabPage::Reset(const SfxItemSet
& rAttrs
)
296 const double fUIScale(double(pView
->GetModel()->GetUIScale()));
298 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SID_ATTR_TRANSFORM_ROT_X
);
301 const double fTmp(((double)((const SfxInt32Item
*)pItem
)->GetValue() - maAnchor
.getX()) / fUIScale
);
302 SetMetricValue(*m_pMtrPosX
, basegfx::fround(fTmp
), ePoolUnit
);
306 m_pMtrPosX
->SetText( OUString() );
309 pItem
= GetItem(rAttrs
, SID_ATTR_TRANSFORM_ROT_Y
);
312 const double fTmp(((double)((const SfxInt32Item
*)pItem
)->GetValue() - maAnchor
.getY()) / fUIScale
);
313 SetMetricValue(*m_pMtrPosY
, basegfx::fround(fTmp
), ePoolUnit
);
317 m_pMtrPosY
->SetText( OUString() );
320 pItem
= GetItem( rAttrs
, SID_ATTR_TRANSFORM_ANGLE
);
323 m_pCtlAngle
->SetRotation(((const SfxInt32Item
*)pItem
)->GetValue());
327 m_pCtlAngle
->SetRotation(0);
329 m_pCtlAngle
->SaveValue();
334 SfxTabPage
* SvxAngleTabPage::Create( Window
* pWindow
, const SfxItemSet
& rSet
)
336 return(new SvxAngleTabPage(pWindow
, rSet
));
341 const sal_uInt16
* SvxAngleTabPage::GetRanges()
343 return(pAngleRanges
);
348 void SvxAngleTabPage::ActivatePage(const SfxItemSet
& /*rSet*/)
354 int SvxAngleTabPage::DeactivatePage( SfxItemSet
* _pSet
)
366 void SvxAngleTabPage::PointChanged(Window
* pWindow
, RECT_POINT eRP
)
368 if(pWindow
== m_pCtlRect
)
374 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getMinX()), FUNIT_NONE
);
375 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getMinY()), FUNIT_NONE
);
380 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getCenter().getX()), FUNIT_NONE
);
381 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getMinY()), FUNIT_NONE
);
386 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getMaxX()), FUNIT_NONE
);
387 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getMinY()), FUNIT_NONE
);
392 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getMinX()), FUNIT_NONE
);
393 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getCenter().getY()), FUNIT_NONE
);
398 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getCenter().getX()), FUNIT_NONE
);
399 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getCenter().getY()), FUNIT_NONE
);
404 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getMaxX()), FUNIT_NONE
);
405 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getCenter().getY()), FUNIT_NONE
);
410 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getMinX()), FUNIT_NONE
);
411 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getMaxY()), FUNIT_NONE
);
416 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getCenter().getX()), FUNIT_NONE
);
417 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getMaxY()), FUNIT_NONE
);
422 m_pMtrPosX
->SetUserValue( basegfx::fround64(maRange
.getMaxX()), FUNIT_NONE
);
423 m_pMtrPosY
->SetUserValue( basegfx::fround64(maRange
.getMaxY()), FUNIT_NONE
);
430 /*************************************************************************
432 |* dialog for changing slant and corner radius
434 \************************************************************************/
435 SvxSlantTabPage::SvxSlantTabPage(Window
* pParent
, const SfxItemSet
& rInAttrs
)
436 : SvxTabPage( pParent
,"SlantAndCornerRadius","cui/ui/slantcornertabpage.ui",
438 , rOutAttrs(rInAttrs
)
440 , eDlgUnit(FUNIT_NONE
)
442 get(m_pFlRadius
, "FL_RADIUS");
443 get(m_pMtrRadius
, "MTR_FLD_RADIUS");
444 get(m_pFlAngle
, "FL_SLANT");
445 get(m_pMtrAngle
, "MTR_FLD_ANGLE");
447 // this page needs ExchangeSupport
448 SetExchangeSupport();
451 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
452 DBG_ASSERT( pPool
, "no pool (!)" );
453 ePoolUnit
= pPool
->GetMetric( SID_ATTR_TRANSFORM_POS_X
);
456 void SvxSlantTabPage::Construct()
459 DBG_ASSERT(pView
, "no valid view (!)");
460 eDlgUnit
= GetModuleFieldUnit(GetItemSet());
461 SetFieldUnit(*m_pMtrRadius
, eDlgUnit
, true);
464 Rectangle
aTempRect(pView
->GetAllMarkedRect());
465 pView
->GetSdrPageView()->LogicToPagePos(aTempRect
);
466 maRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
472 bool SvxSlantTabPage::FillItemSet(SfxItemSet
& rAttrs
)
474 bool bModified
= false;
475 OUString aStr
= m_pMtrRadius
->GetText();
477 if( m_pMtrRadius
->IsValueChangedFromSaved() )
479 Fraction aUIScale
= pView
->GetModel()->GetUIScale();
480 long nTmp
= GetCoreValue( *m_pMtrRadius
, ePoolUnit
);
481 nTmp
= Fraction( nTmp
) * aUIScale
;
483 rAttrs
.Put( SdrEckenradiusItem( nTmp
) );
487 aStr
= m_pMtrAngle
->GetText();
489 if( m_pMtrAngle
->IsValueChangedFromSaved() )
491 sal_Int32 nValue
= static_cast<sal_Int32
>(m_pMtrAngle
->GetValue());
492 rAttrs
.Put( SfxInt32Item( SID_ATTR_TRANSFORM_SHEAR
, nValue
) );
498 // set reference points
500 Rectangle
aObjectRect(pView
->GetAllMarkedRect());
501 pView
->GetSdrPageView()->LogicToPagePos(aObjectRect
);
502 Point aPt
= aObjectRect
.Center();
504 rAttrs
.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_X
, aPt
.X()));
505 rAttrs
.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_Y
, aPt
.Y()));
506 rAttrs
.Put( SfxBoolItem( SID_ATTR_TRANSFORM_SHEAR_VERTICAL
, false ) );
514 void SvxSlantTabPage::Reset(const SfxItemSet
& rAttrs
)
516 // if the view has selected objects, items with SFX_ITEM_DEFAULT need to be disabled
517 const SfxPoolItem
* pItem
;
520 if(!pView
->IsEdgeRadiusAllowed())
522 m_pMtrRadius
->SetText( "" );
523 m_pFlRadius
->Disable();
527 pItem
= GetItem( rAttrs
, SDRATTR_ECKENRADIUS
);
531 const double fUIScale(double(pView
->GetModel()->GetUIScale()));
532 const double fTmp((double)((const SdrEckenradiusItem
*)pItem
)->GetValue() / fUIScale
);
533 SetMetricValue(*m_pMtrRadius
, basegfx::fround(fTmp
), ePoolUnit
);
537 m_pMtrRadius
->SetText( "" );
541 m_pMtrRadius
->SaveValue();
544 if( !pView
->IsShearAllowed() )
546 m_pMtrAngle
->SetText( "" );
547 m_pFlAngle
->Disable();
551 pItem
= GetItem( rAttrs
, SID_ATTR_TRANSFORM_SHEAR
);
555 m_pMtrAngle
->SetValue( ( (const SfxInt32Item
*)pItem
)->GetValue() );
559 m_pMtrAngle
->SetText( "" );
563 m_pMtrAngle
->SaveValue();
568 SfxTabPage
* SvxSlantTabPage::Create( Window
* pWindow
, const SfxItemSet
& rOutAttrs
)
570 return( new SvxSlantTabPage( pWindow
, rOutAttrs
) );
575 const sal_uInt16
* SvxSlantTabPage::GetRanges()
577 return( pSlantRanges
);
582 void SvxSlantTabPage::ActivatePage( const SfxItemSet
& rSet
)
584 SfxRectangleItem
* pRectItem
= NULL
;
586 if( SFX_ITEM_SET
== rSet
.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN
) , false, (const SfxPoolItem
**) &pRectItem
) )
588 const Rectangle
aTempRect(pRectItem
->GetValue());
589 maRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
595 int SvxSlantTabPage::DeactivatePage( SfxItemSet
* _pSet
)
607 void SvxSlantTabPage::PointChanged( Window
* , RECT_POINT
)
611 /*************************************************************************
613 |* Dialog for changing position and size of graphic objects
615 \************************************************************************/
616 SvxPositionSizeTabPage::SvxPositionSizeTabPage(Window
* pParent
, const SfxItemSet
& rInAttrs
)
617 : SvxTabPage(pParent
,"PositionAndSize","cui/ui/possizetabpage.ui", rInAttrs
)
618 , mrOutAttrs(rInAttrs
)
620 , meDlgUnit(FUNIT_NONE
)
621 , meMapUnit(MAP_100TH_MM
)
622 , mnProtectSizeState(TRISTATE_FALSE
)
623 , mbPageDisabled(false)
624 , mbProtectDisabled(false)
625 , mbSizeDisabled(false)
626 , mbAdjustDisabled(true)
631 get(m_pFlPosition
, "FL_POSITION");
632 get(m_pMtrPosX
, "MTR_FLD_POS_X");
633 get(m_pMtrPosY
, "MTR_FLD_POS_Y");
634 get(m_pCtlPos
, "CTL_POSRECT" );
636 get(m_pFlSize
, "FL_SIZE");
637 get(m_pFtWidth
, "FT_WIDTH");
638 get(m_pMtrWidth
, "MTR_FLD_WIDTH");
639 get(m_pFtHeight
, "FT_HEIGHT");
640 get(m_pMtrHeight
, "MTR_FLD_HEIGHT");
641 get(m_pCbxScale
, "CBX_SCALE");
642 get(m_pCtlSize
, "CTL_SIZERECT" );
644 get(m_pFlProtect
, "FL_PROTECT");
645 get(m_pTsbPosProtect
, "TSB_POSPROTECT");
646 get(m_pTsbSizeProtect
, "TSB_SIZEPROTECT");
648 get(m_pFlAdjust
, "FL_ADJUST");
649 get(m_pTsbAutoGrowWidth
, "TSB_AUTOGROW_WIDTH");
650 get(m_pTsbAutoGrowHeight
, "TSB_AUTOGROW_HEIGHT");
652 // this pege needs ExchangeSupport
653 SetExchangeSupport();
656 SfxItemPool
* pPool
= mrOutAttrs
.GetPool();
657 DBG_ASSERT( pPool
, "no pool (!)" );
658 mePoolUnit
= pPool
->GetMetric( SID_ATTR_TRANSFORM_POS_X
);
660 m_pCtlPos
->SetActualRP(RP_LT
);
661 m_pCtlSize
->SetActualRP(RP_LT
);
662 meRP
= RP_LT
; // see above
664 m_pMtrWidth
->SetModifyHdl( LINK( this, SvxPositionSizeTabPage
, ChangeWidthHdl
) );
665 m_pMtrHeight
->SetModifyHdl( LINK( this, SvxPositionSizeTabPage
, ChangeHeightHdl
) );
666 m_pCbxScale
->SetClickHdl( LINK( this, SvxPositionSizeTabPage
, ClickAutoHdl
) );
668 m_pTsbAutoGrowWidth
->Disable();
669 m_pTsbAutoGrowHeight
->Disable();
670 m_pFlAdjust
->Disable();
672 // #i2379# disable controls when protected
673 m_pTsbPosProtect
->SetClickHdl( LINK( this, SvxPositionSizeTabPage
, ChangePosProtectHdl
) );
674 m_pTsbSizeProtect
->SetClickHdl( LINK( this, SvxPositionSizeTabPage
, ChangeSizeProtectHdl
) );
678 void SvxPositionSizeTabPage::Construct()
680 // get range and work area
681 DBG_ASSERT( mpView
, "no valid view (!)" );
682 meDlgUnit
= GetModuleFieldUnit( GetItemSet() );
683 SetFieldUnit( *m_pMtrPosX
, meDlgUnit
, true );
684 SetFieldUnit( *m_pMtrPosY
, meDlgUnit
, true );
685 SetFieldUnit( *m_pMtrWidth
, meDlgUnit
, true );
686 SetFieldUnit( *m_pMtrHeight
, meDlgUnit
, true );
688 if(FUNIT_MILE
== meDlgUnit
|| FUNIT_KM
== meDlgUnit
)
690 m_pMtrPosX
->SetDecimalDigits( 3 );
691 m_pMtrPosY
->SetDecimalDigits( 3 );
692 m_pMtrWidth
->SetDecimalDigits( 3 );
693 m_pMtrHeight
->SetDecimalDigits( 3 );
697 Rectangle
aTempRect(mpView
->GetAllMarkedRect());
698 mpView
->GetSdrPageView()->LogicToPagePos(aTempRect
);
699 maRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
703 Rectangle
aTempRect(mpView
->GetWorkArea());
704 mpView
->GetSdrPageView()->LogicToPagePos(aTempRect
);
705 maWorkRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
708 // take anchor into account (Writer)
709 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
711 if(rMarkList
.GetMarkCount())
713 const SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
714 maAnchor
= basegfx::B2DPoint(pObj
->GetAnchorPos().X(), pObj
->GetAnchorPos().Y());
716 if(!maAnchor
.equalZero()) // -> Writer
718 for(sal_uInt16
i(1); i
< rMarkList
.GetMarkCount(); i
++)
720 pObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
722 if(maAnchor
!= basegfx::B2DPoint(pObj
->GetAnchorPos().X(), pObj
->GetAnchorPos().Y()))
724 // different anchor positions
725 m_pMtrPosX
->SetText( "" );
726 m_pMtrPosY
->SetText( "" );
727 mbPageDisabled
= true;
732 // translate ranges about anchor
733 maRange
= basegfx::B2DRange(maRange
.getMinimum() - maAnchor
, maRange
.getMaximum() - maAnchor
);
734 maWorkRange
= basegfx::B2DRange(maWorkRange
.getMinimum() - maAnchor
, maWorkRange
.getMaximum() - maAnchor
);
738 // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
739 if(1 == rMarkList
.GetMarkCount())
741 const SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
742 const SdrObjKind
eKind((SdrObjKind
)pObj
->GetObjIdentifier());
744 if((pObj
->GetObjInventor() == SdrInventor
) &&
745 (OBJ_TEXT
== eKind
|| OBJ_TITLETEXT
== eKind
|| OBJ_OUTLINETEXT
== eKind
) &&
748 mbAdjustDisabled
= false;
750 m_pFlAdjust
->Enable();
752 m_pTsbAutoGrowWidth
->SetClickHdl( LINK( this, SvxPositionSizeTabPage
, ClickSizeProtectHdl
) );
753 m_pTsbAutoGrowHeight
->SetClickHdl( LINK( this, SvxPositionSizeTabPage
, ClickSizeProtectHdl
) );
755 // is used as flag to evaluate if its selectable
756 m_pTsbAutoGrowWidth
->EnableTriState( false );
757 m_pTsbAutoGrowHeight
->EnableTriState( false );
761 // take scale into account
762 const Fraction
aUIScale(mpView
->GetModel()->GetUIScale());
763 lcl_ScaleRect( maWorkRange
, aUIScale
);
764 lcl_ScaleRect( maRange
, aUIScale
);
766 // take UI units into account
767 const sal_uInt16
nDigits(m_pMtrPosX
->GetDecimalDigits());
768 lcl_ConvertRect( maWorkRange
, nDigits
, (MapUnit
) mePoolUnit
, meDlgUnit
);
769 lcl_ConvertRect( maRange
, nDigits
, (MapUnit
) mePoolUnit
, meDlgUnit
);
776 bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet
& rOutAttrs
)
778 bool bModified(false);
780 if ( m_pMtrWidth
->HasFocus() )
782 ChangeWidthHdl( this );
785 if ( m_pMtrHeight
->HasFocus() )
787 ChangeHeightHdl( this );
790 if( !mbPageDisabled
)
792 if ( m_pMtrPosX
->IsValueModified() || m_pMtrPosY
->IsValueModified() )
794 const double fUIScale(double(mpView
->GetModel()->GetUIScale()));
795 double fX((GetCoreValue( *m_pMtrPosX
, mePoolUnit
) + maAnchor
.getX()) * fUIScale
);
796 double fY((GetCoreValue( *m_pMtrPosY
, mePoolUnit
) + maAnchor
.getY()) * fUIScale
);
799 Rectangle
aTempRect(mpView
->GetAllMarkedRect());
800 mpView
->GetSdrPageView()->LogicToPagePos(aTempRect
);
801 maRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
804 // #101581# GetTopLeftPosition(...) needs coordinates after UI scaling, in real PagePositions
805 GetTopLeftPosition(fX
, fY
, maRange
);
807 rOutAttrs
.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_X
), basegfx::fround(fX
)));
808 rOutAttrs
.Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_Y
), basegfx::fround(fY
)));
813 if ( m_pTsbPosProtect
->IsValueChangedFromSaved() )
815 if( m_pTsbPosProtect
->GetState() == TRISTATE_INDET
)
817 rOutAttrs
.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS
);
822 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS
),
823 m_pTsbPosProtect
->GetState() == TRISTATE_TRUE
? sal_True
: sal_False
) );
830 if ( m_pMtrWidth
->IsValueModified() || m_pMtrHeight
->IsValueModified() )
832 Fraction aUIScale
= mpView
->GetModel()->GetUIScale();
835 double nWidth
= static_cast<double>(m_pMtrWidth
->GetValue( meDlgUnit
));
836 nWidth
= MetricField::ConvertDoubleValue( nWidth
, m_pMtrWidth
->GetBaseValue(), m_pMtrWidth
->GetDecimalDigits(), meDlgUnit
, FUNIT_100TH_MM
);
837 long lWidth
= long(nWidth
* (double)aUIScale
);
838 lWidth
= OutputDevice::LogicToLogic( lWidth
, MAP_100TH_MM
, (MapUnit
)mePoolUnit
);
839 lWidth
= static_cast<long>(m_pMtrWidth
->Denormalize( lWidth
));
842 double nHeight
= static_cast<double>(m_pMtrHeight
->GetValue( meDlgUnit
));
843 nHeight
= MetricField::ConvertDoubleValue( nHeight
, m_pMtrHeight
->GetBaseValue(), m_pMtrHeight
->GetDecimalDigits(), meDlgUnit
, FUNIT_100TH_MM
);
844 long lHeight
= long(nHeight
* (double)aUIScale
);
845 lHeight
= OutputDevice::LogicToLogic( lHeight
, MAP_100TH_MM
, (MapUnit
)mePoolUnit
);
846 lHeight
= static_cast<long>(m_pMtrHeight
->Denormalize( lHeight
));
848 // put Width & Height to itemset
849 rOutAttrs
.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH
), (sal_uInt32
) lWidth
) );
850 rOutAttrs
.Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT
), (sal_uInt32
) lHeight
) );
851 rOutAttrs
.Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT
), sal::static_int_cast
< sal_uInt16
>( meRP
) ) );
855 if ( m_pTsbSizeProtect
->IsValueChangedFromSaved() )
857 if ( m_pTsbSizeProtect
->GetState() == TRISTATE_INDET
)
858 rOutAttrs
.InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE
);
861 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE
),
862 m_pTsbSizeProtect
->GetState() == TRISTATE_TRUE
? sal_True
: sal_False
) );
866 if ( m_pTsbAutoGrowWidth
->IsValueChangedFromSaved() )
868 if ( !m_pTsbAutoGrowWidth
->IsTriStateEnabled() )
870 if( m_pTsbAutoGrowWidth
->GetState() == TRISTATE_INDET
)
871 rOutAttrs
.InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH
);
874 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH
),
875 m_pTsbAutoGrowWidth
->GetState() == TRISTATE_TRUE
? sal_True
: sal_False
) );
880 if ( m_pTsbAutoGrowHeight
->IsValueChangedFromSaved() )
882 if ( !m_pTsbAutoGrowHeight
->IsTriStateEnabled() )
884 if( m_pTsbAutoGrowHeight
->GetState() == TRISTATE_INDET
)
885 rOutAttrs
.InvalidateItem( SID_ATTR_TRANSFORM_AUTOHEIGHT
);
888 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT
),
889 m_pTsbAutoGrowHeight
->GetState() == TRISTATE_TRUE
? sal_True
: sal_False
) );
900 void SvxPositionSizeTabPage::Reset( const SfxItemSet
& )
902 const SfxPoolItem
* pItem
;
903 const double fUIScale(double(mpView
->GetModel()->GetUIScale()));
905 if ( !mbPageDisabled
)
907 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_POS_X
);
910 const double fTmp((((const SfxInt32Item
*)pItem
)->GetValue() - maAnchor
.getX()) / fUIScale
);
911 SetMetricValue(*m_pMtrPosX
, basegfx::fround(fTmp
), mePoolUnit
);
914 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_POS_Y
);
917 const double fTmp((((const SfxInt32Item
*)pItem
)->GetValue() - maAnchor
.getY()) / fUIScale
);
918 SetMetricValue(*m_pMtrPosY
, basegfx::fround(fTmp
), mePoolUnit
);
921 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_PROTECT_POS
);
924 bool bProtected
= ( ( const SfxBoolItem
* )pItem
)->GetValue();
925 m_pTsbPosProtect
->SetState( bProtected
? TRISTATE_TRUE
: TRISTATE_FALSE
);
926 m_pTsbPosProtect
->EnableTriState( false );
930 m_pTsbPosProtect
->SetState( TRISTATE_INDET
);
933 m_pTsbPosProtect
->SaveValue();
936 // #i2379# Disable controls for protected objects
937 ChangePosProtectHdl( this );
940 { // #i75273# set width
941 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_WIDTH
);
942 mfOldWidth
= std::max( pItem
? (double)((const SfxUInt32Item
*)pItem
)->GetValue() : 0.0, 1.0 );
943 double fTmpWidth((OutputDevice::LogicToLogic(static_cast<sal_Int32
>(mfOldWidth
), (MapUnit
)mePoolUnit
, MAP_100TH_MM
)) / fUIScale
);
945 if(m_pMtrWidth
->GetDecimalDigits())
946 fTmpWidth
*= pow(10.0, m_pMtrWidth
->GetDecimalDigits());
948 fTmpWidth
= MetricField::ConvertDoubleValue(fTmpWidth
, m_pMtrWidth
->GetBaseValue(), m_pMtrWidth
->GetDecimalDigits(), FUNIT_100TH_MM
, meDlgUnit
);
949 m_pMtrWidth
->SetValue(static_cast<sal_Int64
>(fTmpWidth
), meDlgUnit
);
952 { // #i75273# set height
953 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_HEIGHT
);
954 mfOldHeight
= std::max( pItem
? (double)((const SfxUInt32Item
*)pItem
)->GetValue() : 0.0, 1.0 );
955 double fTmpHeight((OutputDevice::LogicToLogic(static_cast<sal_Int32
>(mfOldHeight
), (MapUnit
)mePoolUnit
, MAP_100TH_MM
)) / fUIScale
);
957 if(m_pMtrHeight
->GetDecimalDigits())
958 fTmpHeight
*= pow(10.0, m_pMtrHeight
->GetDecimalDigits());
960 fTmpHeight
= MetricField::ConvertDoubleValue(fTmpHeight
, m_pMtrHeight
->GetBaseValue(), m_pMtrHeight
->GetDecimalDigits(), FUNIT_100TH_MM
, meDlgUnit
);
961 m_pMtrHeight
->SetValue(static_cast<sal_Int64
>(fTmpHeight
), meDlgUnit
);
964 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_PROTECT_SIZE
);
967 m_pTsbSizeProtect
->SetState( ( (const SfxBoolItem
*)pItem
)->GetValue()
968 ? TRISTATE_TRUE
: TRISTATE_FALSE
);
969 m_pTsbSizeProtect
->EnableTriState( false );
972 m_pTsbSizeProtect
->SetState( TRISTATE_INDET
);
974 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_AUTOWIDTH
);
977 m_pTsbAutoGrowWidth
->SetState( ( ( const SfxBoolItem
* )pItem
)->GetValue()
978 ? TRISTATE_TRUE
: TRISTATE_FALSE
);
981 m_pTsbAutoGrowWidth
->SetState( TRISTATE_INDET
);
983 pItem
= GetItem( mrOutAttrs
, SID_ATTR_TRANSFORM_AUTOHEIGHT
);
986 m_pTsbAutoGrowHeight
->SetState( ( ( const SfxBoolItem
* )pItem
)->GetValue()
987 ? TRISTATE_TRUE
: TRISTATE_FALSE
);
990 m_pTsbAutoGrowHeight
->SetState( TRISTATE_INDET
);
993 OUString aStr
= GetUserData();
994 m_pCbxScale
->Check( aStr
.toInt32() != 0 );
996 m_pTsbSizeProtect
->SaveValue();
997 m_pTsbAutoGrowWidth
->SaveValue();
998 m_pTsbAutoGrowHeight
->SaveValue();
999 ClickSizeProtectHdl( NULL
);
1001 // #i2379# Disable controls for protected objects
1002 ChangeSizeProtectHdl( this );
1007 SfxTabPage
* SvxPositionSizeTabPage::Create( Window
* pWindow
, const SfxItemSet
& rOutAttrs
)
1009 return( new SvxPositionSizeTabPage( pWindow
, rOutAttrs
) );
1014 const sal_uInt16
* SvxPositionSizeTabPage::GetRanges()
1016 return( pPosSizeRanges
);
1021 void SvxPositionSizeTabPage::ActivatePage( const SfxItemSet
& rSet
)
1023 SfxRectangleItem
* pRectItem
= NULL
;
1025 if( SFX_ITEM_SET
== rSet
.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN
) , false, (const SfxPoolItem
**) &pRectItem
) )
1028 const Rectangle
aTempRect(pRectItem
->GetValue());
1029 maRange
= basegfx::B2DRange(aTempRect
.Left(), aTempRect
.Top(), aTempRect
.Right(), aTempRect
.Bottom());
1032 SetMinMaxPosition();
1038 int SvxPositionSizeTabPage::DeactivatePage( SfxItemSet
* _pSet
)
1042 double fX((double)m_pMtrPosX
->GetValue());
1043 double fY((double)m_pMtrPosY
->GetValue());
1045 GetTopLeftPosition(fX
, fY
, maRange
);
1046 const Rectangle
aOutRectangle(
1047 basegfx::fround(fX
), basegfx::fround(fY
),
1048 basegfx::fround(fX
+ maRange
.getWidth()), basegfx::fround(fY
+ maRange
.getHeight()));
1049 _pSet
->Put(SfxRectangleItem(SID_ATTR_TRANSFORM_INTERN
, aOutRectangle
));
1051 FillItemSet(*_pSet
);
1059 IMPL_LINK_NOARG(SvxPositionSizeTabPage
, ChangePosProtectHdl
)
1061 // #106572# Remember user's last choice
1062 m_pTsbSizeProtect
->SetState( m_pTsbPosProtect
->GetState() == TRISTATE_TRUE
? TRISTATE_TRUE
: mnProtectSizeState
);
1063 UpdateControlStates();
1069 void SvxPositionSizeTabPage::UpdateControlStates()
1071 const bool bPosProtect
= m_pTsbPosProtect
->GetState() == TRISTATE_TRUE
;
1072 const bool bSizeProtect
= m_pTsbSizeProtect
->GetState() == TRISTATE_TRUE
;
1073 const bool bHeightChecked
= !m_pTsbAutoGrowHeight
->IsTriStateEnabled() && (m_pTsbAutoGrowHeight
->GetState() == TRISTATE_TRUE
);
1074 const bool bWidthChecked
= !m_pTsbAutoGrowWidth
->IsTriStateEnabled() && (m_pTsbAutoGrowWidth
->GetState() == TRISTATE_TRUE
);
1076 m_pFlPosition
->Enable( !bPosProtect
&& !mbPageDisabled
);
1078 m_pTsbPosProtect
->Enable( !mbProtectDisabled
&& !mbPageDisabled
);
1080 m_pFlSize
->Enable( !mbSizeDisabled
&& !bSizeProtect
);
1082 m_pFtWidth
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& !bWidthChecked
);
1083 m_pMtrWidth
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& !bWidthChecked
);
1085 m_pFtHeight
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& !bHeightChecked
);
1086 m_pMtrHeight
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& !bHeightChecked
);
1088 m_pCbxScale
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& !bHeightChecked
&& !bWidthChecked
);
1089 m_pCtlSize
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& (!bHeightChecked
|| !bWidthChecked
) );
1091 m_pFlProtect
->Enable( !mbProtectDisabled
);
1092 m_pTsbSizeProtect
->Enable( !mbProtectDisabled
&& !bPosProtect
);
1094 m_pFlAdjust
->Enable( !mbSizeDisabled
&& !bSizeProtect
&& !mbAdjustDisabled
);
1096 m_pCtlSize
->Invalidate();
1097 m_pCtlPos
->Invalidate();
1103 IMPL_LINK_NOARG(SvxPositionSizeTabPage
, ChangeSizeProtectHdl
)
1105 if( m_pTsbSizeProtect
->IsEnabled() )
1107 // #106572# Remember user's last choice
1109 // Note: this works only as long as the dialog is open. When
1110 // the user closes the dialog, there is no way to remember
1111 // whether size was enabled or disabled before pos protect was
1112 // clicked. Thus, if pos protect is selected, the dialog is
1113 // closed and reopened again, unchecking pos protect will
1114 // always uncheck size protect, too. That's life.
1115 mnProtectSizeState
= m_pTsbSizeProtect
->GetState();
1118 UpdateControlStates();
1125 void SvxPositionSizeTabPage::SetMinMaxPosition()
1128 double fLeft(maWorkRange
.getMinX());
1129 double fTop(maWorkRange
.getMinY());
1130 double fRight(maWorkRange
.getMaxX());
1131 double fBottom(maWorkRange
.getMaxY());
1133 switch ( m_pCtlPos
->GetActualRP() )
1137 fRight
-= maRange
.getWidth();
1138 fBottom
-= maRange
.getHeight();
1143 fLeft
+= maRange
.getWidth() / 2.0;
1144 fRight
-= maRange
.getWidth() / 2.0;
1145 fBottom
-= maRange
.getHeight();
1150 fLeft
+= maRange
.getWidth();
1151 fBottom
-= maRange
.getHeight();
1156 fRight
-= maRange
.getWidth();
1157 fTop
+= maRange
.getHeight() / 2.0;
1158 fBottom
-= maRange
.getHeight() / 2.0;
1163 fLeft
+= maRange
.getWidth() / 2.0;
1164 fRight
-= maRange
.getWidth() / 2.0;
1165 fTop
+= maRange
.getHeight() / 2.0;
1166 fBottom
-= maRange
.getHeight() / 2.0;
1171 fLeft
+= maRange
.getWidth();
1172 fTop
+= maRange
.getHeight() / 2.0;
1173 fBottom
-= maRange
.getHeight() / 2.0;
1178 fRight
-= maRange
.getWidth();
1179 fTop
+= maRange
.getHeight();
1184 fLeft
+= maRange
.getWidth() / 2.0;
1185 fRight
-= maRange
.getWidth() / 2.0;
1186 fTop
+= maRange
.getHeight();
1191 fLeft
+= maRange
.getWidth();
1192 fTop
+= maRange
.getHeight();
1197 const double fMaxLong((double)(MetricField::ConvertValue( LONG_MAX
, 0, MAP_100TH_MM
, meDlgUnit
) - 1L));
1198 fLeft
= (fLeft
> fMaxLong
) ? fMaxLong
: (fLeft
< -fMaxLong
) ? -fMaxLong
: fLeft
;
1199 fRight
= (fRight
> fMaxLong
) ? fMaxLong
: (fRight
< -fMaxLong
) ? -fMaxLong
: fRight
;
1200 fTop
= (fTop
> fMaxLong
) ? fMaxLong
: (fTop
< -fMaxLong
) ? -fMaxLong
: fTop
;
1201 fBottom
= (fBottom
> fMaxLong
) ? fMaxLong
: (fBottom
< -fMaxLong
) ? -fMaxLong
: fBottom
;
1203 // #i75273# normalizing when setting the min/max values was wrong, removed
1204 m_pMtrPosX
->SetMin(basegfx::fround64(fLeft
));
1205 m_pMtrPosX
->SetFirst(basegfx::fround64(fLeft
));
1206 m_pMtrPosX
->SetMax(basegfx::fround64(fRight
));
1207 m_pMtrPosX
->SetLast(basegfx::fround64(fRight
));
1208 m_pMtrPosY
->SetMin(basegfx::fround64(fTop
));
1209 m_pMtrPosY
->SetFirst(basegfx::fround64(fTop
));
1210 m_pMtrPosY
->SetMax(basegfx::fround64(fBottom
));
1211 m_pMtrPosY
->SetLast(basegfx::fround64(fBottom
));
1214 fLeft
= maWorkRange
.getMinX();
1215 fTop
= maWorkRange
.getMinY();
1216 fRight
= maWorkRange
.getMaxX();
1217 fBottom
= maWorkRange
.getMaxY();
1221 switch ( m_pCtlSize
->GetActualRP() )
1225 fNewX
= maWorkRange
.getWidth() - ( maRange
.getMinX() - fLeft
);
1226 fNewY
= maWorkRange
.getHeight() - ( maRange
.getMinY() - fTop
);
1231 fNewX
= std::min( maRange
.getCenter().getX() - fLeft
, fRight
- maRange
.getCenter().getX() ) * 2.0;
1232 fNewY
= maWorkRange
.getHeight() - ( maRange
.getMinY() - fTop
);
1237 fNewX
= maWorkRange
.getWidth() - ( fRight
- maRange
.getMaxX() );
1238 fNewY
= maWorkRange
.getHeight() - ( maRange
.getMinY() - fTop
);
1243 fNewX
= maWorkRange
.getWidth() - ( maRange
.getMinX() - fLeft
);
1244 fNewY
= std::min( maRange
.getCenter().getY() - fTop
, fBottom
- maRange
.getCenter().getY() ) * 2.0;
1249 const double f1(maRange
.getCenter().getX() - fLeft
);
1250 const double f2(fRight
- maRange
.getCenter().getX());
1251 const double f3(std::min(f1
, f2
));
1252 const double f4(maRange
.getCenter().getY() - fTop
);
1253 const double f5(fBottom
- maRange
.getCenter().getY());
1254 const double f6(std::min(f4
, f5
));
1263 fNewX
= maWorkRange
.getWidth() - ( fRight
- maRange
.getMaxX() );
1264 fNewY
= std::min( maRange
.getCenter().getY() - fTop
, fBottom
- maRange
.getCenter().getY() ) * 2.0;
1269 fNewX
= maWorkRange
.getWidth() - ( maRange
.getMinX() - fLeft
);
1270 fNewY
= maWorkRange
.getHeight() - ( fBottom
- maRange
.getMaxY() );
1275 fNewX
= std::min( maRange
.getCenter().getX() - fLeft
, fRight
- maRange
.getCenter().getX() ) * 2.0;
1276 fNewY
= maWorkRange
.getHeight() - ( maRange
.getMaxY() - fBottom
);
1281 fNewX
= maWorkRange
.getWidth() - ( fRight
- maRange
.getMaxX() );
1282 fNewY
= maWorkRange
.getHeight() - ( fBottom
- maRange
.getMaxY() );
1287 // #i75273# normalizing when setting the min/max values was wrong, removed
1288 m_pMtrWidth
->SetMax(basegfx::fround64(fNewX
));
1289 m_pMtrWidth
->SetLast(basegfx::fround64(fNewX
));
1290 m_pMtrHeight
->SetMax(basegfx::fround64(fNewY
));
1291 m_pMtrHeight
->SetLast(basegfx::fround64(fNewY
));
1296 void SvxPositionSizeTabPage::GetTopLeftPosition(double& rfX
, double& rfY
, const basegfx::B2DRange
& rRange
)
1298 switch (m_pCtlPos
->GetActualRP())
1306 rfX
-= rRange
.getCenter().getX() - rRange
.getMinX();
1311 rfX
-= rRange
.getWidth();
1316 rfY
-= rRange
.getCenter().getY() - rRange
.getMinY();
1321 rfX
-= rRange
.getCenter().getX() - rRange
.getMinX();
1322 rfY
-= rRange
.getCenter().getY() - rRange
.getMinY();
1327 rfX
-= rRange
.getWidth();
1328 rfY
-= rRange
.getCenter().getY() - rRange
.getMinY();
1333 rfY
-= rRange
.getHeight();
1338 rfX
-= rRange
.getCenter().getX() - rRange
.getMinX();
1339 rfY
-= rRange
.getHeight();
1344 rfX
-= rRange
.getWidth();
1345 rfY
-= rRange
.getHeight();
1353 void SvxPositionSizeTabPage::PointChanged( Window
* pWindow
, RECT_POINT eRP
)
1355 if( pWindow
== m_pCtlPos
)
1357 SetMinMaxPosition();
1362 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getMinX()) );
1363 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getMinY()) );
1368 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getCenter().getX()) );
1369 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getMinY()) );
1374 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getMaxX()) );
1375 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getMinY()) );
1380 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getMinX()) );
1381 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getCenter().getY()) );
1386 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getCenter().getX()) );
1387 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getCenter().getY()) );
1392 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getMaxX()) );
1393 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getCenter().getY()) );
1398 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getMinX()) );
1399 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getMaxY()) );
1404 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getCenter().getX()) );
1405 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getMaxY()) );
1410 m_pMtrPosX
->SetValue( basegfx::fround64(maRange
.getMaxX()) );
1411 m_pMtrPosY
->SetValue( basegfx::fround64(maRange
.getMaxY()) );
1419 SetMinMaxPosition();
1425 void SvxPositionSizeTabPage::DisableResize()
1427 mbSizeDisabled
= true;
1432 void SvxPositionSizeTabPage::DisableProtect()
1434 mbProtectDisabled
= true;
1439 IMPL_LINK_NOARG(SvxPositionSizeTabPage
, ChangeWidthHdl
)
1441 if( m_pCbxScale
->IsChecked() && m_pCbxScale
->IsEnabled() )
1443 sal_Int64
nHeight(basegfx::fround64((mfOldHeight
* (double)m_pMtrWidth
->GetValue()) / mfOldWidth
));
1445 if(nHeight
<= m_pMtrHeight
->GetMax(FUNIT_NONE
))
1447 m_pMtrHeight
->SetUserValue(nHeight
, FUNIT_NONE
);
1451 nHeight
= m_pMtrHeight
->GetMax(FUNIT_NONE
);
1452 m_pMtrHeight
->SetUserValue(nHeight
);
1454 const sal_Int64
nWidth(basegfx::fround64((mfOldWidth
* (double)nHeight
) / mfOldHeight
));
1455 m_pMtrWidth
->SetUserValue(nWidth
, FUNIT_NONE
);
1464 IMPL_LINK_NOARG(SvxPositionSizeTabPage
, ChangeHeightHdl
)
1466 if( m_pCbxScale
->IsChecked() && m_pCbxScale
->IsEnabled() )
1468 sal_Int64
nWidth(basegfx::fround64((mfOldWidth
* (double)m_pMtrHeight
->GetValue()) / mfOldHeight
));
1470 if(nWidth
<= m_pMtrWidth
->GetMax(FUNIT_NONE
))
1472 m_pMtrWidth
->SetUserValue(nWidth
, FUNIT_NONE
);
1476 nWidth
= m_pMtrWidth
->GetMax(FUNIT_NONE
);
1477 m_pMtrWidth
->SetUserValue(nWidth
);
1479 const sal_Int64
nHeight(basegfx::fround64((mfOldHeight
* (double)nWidth
) / mfOldWidth
));
1480 m_pMtrHeight
->SetUserValue(nHeight
, FUNIT_NONE
);
1489 IMPL_LINK_NOARG(SvxPositionSizeTabPage
, ClickSizeProtectHdl
)
1491 UpdateControlStates();
1497 IMPL_LINK_NOARG(SvxPositionSizeTabPage
, ClickAutoHdl
)
1499 if( m_pCbxScale
->IsChecked() )
1501 mfOldWidth
= std::max( (double)GetCoreValue( *m_pMtrWidth
, mePoolUnit
), 1.0 );
1502 mfOldHeight
= std::max( (double)GetCoreValue( *m_pMtrHeight
, mePoolUnit
), 1.0 );
1510 void SvxPositionSizeTabPage::FillUserData()
1512 // matching is saved in the Ini-file
1513 OUString aStr
= m_pCbxScale
->IsChecked() ? OUString("1") : OUString("0");
1514 SetUserData( aStr
);
1517 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */