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