xref: /AOO41X/main/svx/source/sidebar/possize/PosSizePropertyPanel.cxx (revision 417a3a5e99dab4fe7eaac74fb4fee675c2b452e1)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <sfx2/sidebar/ResourceDefinitions.hrc>
23 #include <sfx2/sidebar/Theme.hxx>
24 #include <sfx2/sidebar/ControlFactory.hxx>
25 #include "PosSizePropertyPanel.hxx"
26 #include "PosSizePropertyPanel.hrc"
27 #include <svx/sidebar/SidebarDialControl.hxx>
28 #include <svx/dialogs.hrc>
29 #include <svx/dialmgr.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/bindings.hxx>
32 #include <sfx2/viewsh.hxx>
33 #include <sfx2/objsh.hxx>
34 #include <sfx2/imagemgr.hxx>
35 #include <svx/dlgutil.hxx>
36 #include <unotools/viewoptions.hxx>
37 #include <vcl/virdev.hxx>
38 #include <vcl/svapp.hxx>
39 #include <vcl/field.hxx>
40 #include <vcl/fixed.hxx>
41 #include <vcl/toolbox.hxx>
42 #include <svx/svdview.hxx>
43 #include <svl/aeitem.hxx>
44 
45 using namespace css;
46 using namespace cssu;
47 using ::sfx2::sidebar::Theme;
48 
49 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
50 #define USERITEM_NAME rtl::OUString::createFromAscii("FitItem")
51 #define NO_SELECT       (65535)
52 
53 
54 
55 namespace svx { namespace sidebar {
56 
57 
58 
59 PosSizePropertyPanel::PosSizePropertyPanel(
60     Window* pParent,
61     const cssu::Reference<css::frame::XFrame>& rxFrame,
62     SfxBindings* pBindings,
63     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
64 :   Control(
65         pParent,
66         SVX_RES(RID_SIDEBAR_POSSIZE_PANEL)),
67     mpFtPosX(new FixedText(this, SVX_RES(FT_SBSHAPE_HORIZONTAL))),
68     mpMtrPosX(new MetricField(this, SVX_RES(MF_SBSHAPE_HORIZONTAL))),
69     mpFtPosY(new FixedText(this, SVX_RES(FT_SBSHAPE_VERTICAL))),
70     mpMtrPosY(new MetricField(this, SVX_RES(MF_SBSHAPE_VERTICAL))),
71     mpFtWidth(new FixedText(this, SVX_RES(FT_WIDTH))),
72     mpMtrWidth(new MetricField(this, SVX_RES(MTR_FLD_WIDTH))),
73     mpFtHeight(new FixedText(this, SVX_RES(FT_HEIGHT))),
74     mpMtrHeight(new MetricField(this, SVX_RES(MTR_FLD_HEIGHT))),
75     mpCbxScale(new CheckBox(this, SVX_RES(CBX_SCALE))),
76     mpFtAngle(new FixedText(this, SVX_RES(FT_ANGLE))),
77     mpMtrAngle(new MetricBox(this, SVX_RES(MTR_FLD_ANGLE))),
78     mpDial(new SidebarDialControl(this, SVX_RES(DIAL_CONTROL))),
79     mpFtFlip(new FixedText(this, SVX_RES(FT_FLIP))),
80     mpFlipTbxBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
81     mpFlipTbx(sfx2::sidebar::ControlFactory::CreateToolBox(mpFlipTbxBackground.get(), SVX_RES(TBX_FLIP))),
82     maRect(),
83     mpView(0),
84     mlOldWidth(1),
85     mlOldHeight(1),
86     meRP(RP_LT),
87     maAnchorPos(),
88     mlRotX(0),
89     mlRotY(0),
90     maUIScale(),
91     mePoolUnit(),
92     meDlgUnit(),
93     maTransfPosXControl(SID_ATTR_TRANSFORM_POS_X, *pBindings, *this),
94     maTransfPosYControl(SID_ATTR_TRANSFORM_POS_Y, *pBindings, *this),
95     maTransfWidthControl(SID_ATTR_TRANSFORM_WIDTH, *pBindings, *this),
96     maTransfHeightControl(SID_ATTR_TRANSFORM_HEIGHT, *pBindings, *this),
97     maSvxAngleControl( SID_ATTR_TRANSFORM_ANGLE, *pBindings, *this),
98     maRotXControl(SID_ATTR_TRANSFORM_ROT_X, *pBindings, *this),
99     maRotYControl(SID_ATTR_TRANSFORM_ROT_Y, *pBindings, *this),
100     maProPosControl(SID_ATTR_TRANSFORM_PROTECT_POS, *pBindings, *this),
101     maProSizeControl(SID_ATTR_TRANSFORM_PROTECT_SIZE, *pBindings, *this),
102     maAutoWidthControl(SID_ATTR_TRANSFORM_AUTOWIDTH, *pBindings, *this),
103     maAutoHeightControl(SID_ATTR_TRANSFORM_AUTOHEIGHT, *pBindings, *this),
104     m_aMetricCtl(SID_ATTR_METRIC, *pBindings, *this),
105     mxFrame(rxFrame),
106     maContext(),
107     mpBindings(pBindings),
108     maFtWidthOrigPos(mpFtWidth->GetPosPixel()),
109     maMtrWidthOrigPos(mpMtrWidth->GetPosPixel()),
110     maFtHeightOrigPos(mpFtHeight->GetPosPixel()),
111     maMtrHeightOrigPos(mpMtrHeight->GetPosPixel()),
112     maCbxScaleOrigPos(mpCbxScale->GetPosPixel()),
113     maFtAngleOrigPos(mpFtAngle->GetPosPixel()),
114     maMtrAnglOrigPos(mpMtrAngle->GetPosPixel()),
115     maFlipTbxOrigPos(mpFlipTbx->GetPosPixel()),
116     maDialOrigPos(mpDial->GetPosPixel()),
117     maFtFlipOrigPos(mpFtFlip->GetPosPixel()),
118     mbMtrPosXMirror(false),
119     mbSizeProtected(false),
120     mbPositionProtected(false),
121     mbAutoWidth(false),
122     mbAutoHeight(false),
123     mbAdjustEnabled(false),
124     mbIsFlip(false),
125     mxSidebar(rxSidebar)
126 {
127     Initialize();
128     FreeResource();
129 
130     mpBindings->Update( SID_ATTR_TRANSFORM_WIDTH );
131     mpBindings->Update( SID_ATTR_TRANSFORM_HEIGHT );
132     mpBindings->Update( SID_ATTR_TRANSFORM_PROTECT_SIZE );
133     mpBindings->Update( SID_ATTR_METRIC );
134 }
135 
136 
137 
138 PosSizePropertyPanel::~PosSizePropertyPanel()
139 {
140     // Destroy the background windows of the toolboxes.
141     mpFlipTbx.reset();
142     mpFlipTbxBackground.reset();
143 }
144 
145 
146 
147 void PosSizePropertyPanel::ShowMenu (void)
148 {
149     if (mpBindings != NULL)
150     {
151         SfxDispatcher* pDispatcher = mpBindings->GetDispatcher();
152         if (pDispatcher != NULL)
153             pDispatcher->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_ASYNCHRON);
154     }
155 }
156 
157 
158 
159 void PosSizePropertyPanel::Initialize()
160 {
161     mpFtPosX->SetBackground(Wallpaper());
162     mpFtPosY->SetBackground(Wallpaper());
163     mpFtWidth->SetBackground(Wallpaper());
164     mpFtHeight->SetBackground(Wallpaper());
165     mpFtAngle->SetBackground(Wallpaper());
166     mpFtFlip->SetBackground(Wallpaper());
167 
168         //Position : Horizontal / Vertical
169     mpMtrPosX->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosXHdl ) );
170     mpMtrPosY->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosYHdl ) );
171     mpMtrPosX->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Horizontal")));	//wj acc
172     mpMtrPosY->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Vertical")));		//wj acc
173 
174     //Size : Width / Height
175     mpMtrWidth->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeWidthHdl ) );
176     mpMtrHeight->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeHeightHdl ) );
177     mpMtrWidth->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width")));	//wj acc
178     mpMtrHeight->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height")));	//wj acc
179 
180     //Size : Keep ratio
181     mpCbxScale->SetClickHdl( LINK( this, PosSizePropertyPanel, ClickAutoHdl ) );
182 
183     //rotation:
184     mpMtrAngle->SetModifyHdl(LINK( this, PosSizePropertyPanel, AngleModifiedHdl));
185     mpMtrAngle->EnableAutocomplete( false );
186     mpMtrAngle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Rotation")));	//wj acc
187 
188     //rotation control
189     mpDial->SetModifyHdl(LINK( this, PosSizePropertyPanel, RotationHdl));
190 
191     //flip:
192     mpFlipTbx->SetSelectHdl( LINK( this, PosSizePropertyPanel, FlipHdl) );
193     mpFlipTbx->SetItemImage(
194         FLIP_HORIZONTAL,
195         GetImage(mxFrame, A2S(".uno:FlipHorizontal"), sal_False, Theme::IsHighContrastMode()));
196     mpFlipTbx->SetItemImage(
197         FLIP_VERTICAL,
198         GetImage(mxFrame, A2S(".uno:FlipVertical"), sal_False, Theme::IsHighContrastMode()));
199     mpFlipTbx->SetQuickHelpText(FLIP_HORIZONTAL,String(SVX_RES(STR_QH_HORI_FLIP))); //Add
200     mpFlipTbx->SetQuickHelpText(FLIP_VERTICAL,String(SVX_RES(STR_QH_VERT_FLIP))); //Add
201 
202     mpMtrPosX->SetAccessibleRelationLabeledBy(mpFtPosX.get());
203     mpMtrPosY->SetAccessibleRelationLabeledBy(mpFtPosY.get());
204     mpMtrWidth->SetAccessibleRelationLabeledBy(mpFtWidth.get());
205     mpMtrHeight->SetAccessibleRelationLabeledBy(mpFtHeight.get());
206     mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtAngle.get());
207 #ifdef HAS_IA2
208     mpMtrAngle->SetMpSubEditAccLableBy(mpFtAngle.get());
209 #endif
210     mpFlipTbx->SetAccessibleRelationLabeledBy(mpFtFlip.get());
211 
212     mpMtrAngle->InsertValue(0, FUNIT_CUSTOM);
213     mpMtrAngle->InsertValue(4500, FUNIT_CUSTOM);
214     mpMtrAngle->InsertValue(9000, FUNIT_CUSTOM);
215     mpMtrAngle->InsertValue(13500, FUNIT_CUSTOM);
216     mpMtrAngle->InsertValue(18000, FUNIT_CUSTOM);
217     mpMtrAngle->InsertValue(22500, FUNIT_CUSTOM);
218     mpMtrAngle->InsertValue(27000, FUNIT_CUSTOM);
219     mpMtrAngle->InsertValue(31500, FUNIT_CUSTOM);
220     mpMtrAngle->AdaptDropDownLineCountToMaximum();
221 
222     SfxViewShell* pCurSh = SfxViewShell::Current();
223     if ( pCurSh )
224         mpView = pCurSh->GetDrawView();
225     else
226         mpView = NULL;
227 
228     if ( mpView != NULL )
229     {
230         maUIScale = mpView->GetModel()->GetUIScale();
231 
232         const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
233         if(1 == rMarkList.GetMarkCount())
234         {
235             const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
236             const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
237 
238             if((pObj->GetObjInventor() == SdrInventor) && (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) && ((SdrTextObj*)pObj)->HasText())
239             {
240                 mbAdjustEnabled = true;
241             }
242         }
243     }
244 
245     mePoolUnit = maTransfWidthControl.GetCoreMetric();
246     meDlgUnit = GetModuleFieldUnit();
247     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
248     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
249     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
250     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
251 }
252 
253 
254 
255 void PosSizePropertyPanel::SetupIcons(void)
256 {
257     if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
258     {
259         // todo
260     }
261     else
262     {
263         // todo
264     }
265 }
266 
267 
268 
269 PosSizePropertyPanel* PosSizePropertyPanel::Create (
270     Window* pParent,
271     const cssu::Reference<css::frame::XFrame>& rxFrame,
272     SfxBindings* pBindings,
273     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
274 {
275     if (pParent == NULL)
276         throw lang::IllegalArgumentException(A2S("no parent Window given to PosSizePropertyPanel::Create"), NULL, 0);
277     if ( ! rxFrame.is())
278         throw lang::IllegalArgumentException(A2S("no XFrame given to PosSizePropertyPanel::Create"), NULL, 1);
279     if (pBindings == NULL)
280         throw lang::IllegalArgumentException(A2S("no SfxBindings given to PosSizePropertyPanel::Create"), NULL, 2);
281 
282     return new PosSizePropertyPanel(
283         pParent,
284         rxFrame,
285         pBindings,
286         rxSidebar);
287 }
288 
289 
290 
291 void PosSizePropertyPanel::DataChanged(
292     const DataChangedEvent& rEvent)
293 {
294     (void)rEvent;
295 
296     SetupIcons();
297 }
298 
299 
300 
301 void PosSizePropertyPanel::AdaptWidthHeightScalePosition(bool bOriginal)
302 {
303     if(bOriginal)
304     {
305         mpFtWidth->SetPosPixel(maFtWidthOrigPos);
306         mpMtrWidth->SetPosPixel(maMtrWidthOrigPos);
307         mpFtHeight->SetPosPixel(maFtHeightOrigPos);
308         mpMtrHeight->SetPosPixel(maMtrHeightOrigPos);
309         mpCbxScale->SetPosPixel(maCbxScaleOrigPos);
310     }
311     else
312     {
313         mpFtWidth->SetPosPixel(Point(LogicToPixel(Point(FT_POSITION_X_X,FT_POSITION_X_Y), MAP_APPFONT)));
314         mpMtrWidth->SetPosPixel(Point(LogicToPixel(Point(MF_POSITION_X_X,MF_POSITION_X_Y), MAP_APPFONT)));
315         mpFtHeight->SetPosPixel(Point(LogicToPixel(Point(FT_POSITION_Y_X,FT_POSITION_Y_Y), MAP_APPFONT)));
316         mpMtrHeight->SetPosPixel(Point(LogicToPixel(Point(MF_POSITION_Y_X,MF_POSITION_Y_Y), MAP_APPFONT)));
317         mpCbxScale->SetPosPixel(Point(LogicToPixel(Point(FT_WIDTH_X,FT_WIDTH_Y), MAP_APPFONT)));
318     }
319 }
320 
321 void PosSizePropertyPanel::AdaptAngleFlipDialPosition(bool bOriginal)
322 {
323     if(bOriginal)
324     {
325         mpFtAngle->SetPosPixel(maFtAngleOrigPos);
326         mpMtrAngle->SetPosPixel(maMtrAnglOrigPos);
327         mpFlipTbx->SetPosPixel(maFlipTbxOrigPos);
328         mpDial->SetPosPixel(maDialOrigPos);
329         mpFtFlip->SetPosPixel(maFtFlipOrigPos);
330     }
331     else
332     {
333         mpFtAngle->SetPosPixel(Point(LogicToPixel(Point(FT_ANGLE_X,FT_ANGLE_Y), MAP_APPFONT)));
334         mpMtrAngle->SetPosPixel(Point(LogicToPixel(Point(MF_ANGLE_X2,MF_ANGLE_Y2), MAP_APPFONT)));
335         mpFlipTbx->SetPosPixel(Point(LogicToPixel(Point(FLIP_HORI_X2,FLIP_HORI_Y2), MAP_APPFONT)));
336         mpDial->SetPosPixel(Point(LogicToPixel(Point(ROTATE_CONTROL_X2,ROTATE_CONTROL_Y2), MAP_APPFONT)));
337         mpFtFlip->SetPosPixel(Point(LogicToPixel(Point(FT_FLIP_X2,FT_FLIP_Y2), MAP_APPFONT)));
338     }
339 }
340 
341 void PosSizePropertyPanel::HandleContextChange(
342     const ::sfx2::sidebar::EnumContext aContext)
343 {
344     if(maContext == aContext)
345     {
346         // Nothing to do.
347         return;
348     }
349 
350     maContext = aContext;
351 
352     sal_Int32 nLayoutMode (0);
353     switch (maContext.GetCombinedContext_DI())
354     {
355         case CombinedEnumContext(Application_WriterVariants, Context_Draw):
356             nLayoutMode = 0;
357             break;
358 
359         case CombinedEnumContext(Application_WriterVariants, Context_Graphic):
360         case CombinedEnumContext(Application_WriterVariants, Context_Media):
361         case CombinedEnumContext(Application_WriterVariants, Context_Frame):
362         case CombinedEnumContext(Application_WriterVariants, Context_OLE):
363         case CombinedEnumContext(Application_WriterVariants, Context_Form):
364             nLayoutMode = 1;
365             break;
366 
367         case CombinedEnumContext(Application_Calc, Context_Draw):
368         case CombinedEnumContext(Application_Calc, Context_Graphic):
369         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
370         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
371         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
372             nLayoutMode = 2;
373             break;
374 
375         case CombinedEnumContext(Application_Calc, Context_Chart):
376         case CombinedEnumContext(Application_Calc, Context_Form):
377         case CombinedEnumContext(Application_Calc, Context_Media):
378         case CombinedEnumContext(Application_Calc, Context_OLE):
379         case CombinedEnumContext(Application_Calc, Context_MultiObject):
380         case CombinedEnumContext(Application_DrawImpress, Context_Media):
381         case CombinedEnumContext(Application_DrawImpress, Context_Form):
382         case CombinedEnumContext(Application_DrawImpress, Context_OLE):
383         case CombinedEnumContext(Application_DrawImpress, Context_3DObject):
384         case CombinedEnumContext(Application_DrawImpress, Context_MultiObject):
385             nLayoutMode = 3;
386             break;
387     }
388 
389     switch (nLayoutMode)
390     {
391         case 0:
392         {
393             mpMtrWidth->SetMin( 2 );
394             mpMtrHeight->SetMin( 2 );
395             mpFtPosX->Hide();
396             mpMtrPosX->Hide();
397             mpFtPosY->Hide();
398             mpMtrPosY->Hide();
399 
400             //rotation
401             mpFtAngle->Show();
402             mpMtrAngle->Show();
403             mpDial->Show();
404 
405             //flip
406             mpFtFlip->Show();
407             mpFlipTbx->Show();
408             Size aTbxSize = mpFlipTbx->CalcWindowSizePixel();
409             mpFlipTbx->SetOutputSizePixel( aTbxSize );
410             mbIsFlip = true;
411 
412             AdaptWidthHeightScalePosition(false);
413             AdaptAngleFlipDialPosition(false);
414 
415             mpFtAngle->SetPosPixel(Point(LogicToPixel(Point(FT_ANGLE_X,FT_ANGLE_Y), MAP_APPFONT)));
416             mpMtrAngle->SetPosPixel(Point(LogicToPixel(Point(MF_ANGLE_X2,MF_ANGLE_Y2), MAP_APPFONT)));
417             mpFlipTbx->SetPosPixel(Point(LogicToPixel(Point(FLIP_HORI_X2,FLIP_HORI_Y2), MAP_APPFONT)));
418             mpDial->SetPosPixel(Point(LogicToPixel(Point(ROTATE_CONTROL_X2,ROTATE_CONTROL_Y2), MAP_APPFONT)));
419             mpFtFlip->SetPosPixel(Point(LogicToPixel(Point(FT_FLIP_X2,FT_FLIP_Y2), MAP_APPFONT)));
420 
421             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT2);
422             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
423             SetSizePixel(aSize);
424             if (mxSidebar.is())
425                 mxSidebar->requestLayout();
426         }
427         break;
428 
429         case 1:
430         {
431             mpMtrWidth->SetMin( 2 );
432             mpMtrHeight->SetMin( 2 );
433             mpFtPosX->Hide();
434             mpMtrPosX->Hide();
435             mpFtPosY->Hide();
436             mpMtrPosY->Hide();
437 
438             //rotation
439             mpFtAngle->Hide();
440             mpMtrAngle->Hide();
441             mpDial->Hide();
442 
443             //flip
444             mpFlipTbx->Hide();
445             mpFtFlip->Hide();
446             mbIsFlip = false;
447 
448             AdaptWidthHeightScalePosition(false);
449             AdaptAngleFlipDialPosition(true);
450 
451             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT3);
452             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
453             SetSizePixel(aSize);
454             if (mxSidebar.is())
455                 mxSidebar->requestLayout();
456         }
457         break;
458 
459         case 2:
460         {
461             mpMtrWidth->SetMin( 1 );
462             mpMtrHeight->SetMin( 1 );
463             mpFtPosX->Show();
464             mpMtrPosX->Show();
465             mpFtPosY->Show();
466             mpMtrPosY->Show();
467 
468             //rotation
469             mpFtAngle->Show();
470             mpMtrAngle->Show();
471             mpDial->Show();
472 
473             //flip
474             mpFlipTbx->Show();
475             mpFtFlip->Show();
476             Size aTbxSize = mpFlipTbx->CalcWindowSizePixel();
477             mpFlipTbx->SetOutputSizePixel( aTbxSize );
478             mbIsFlip = true;
479 
480             AdaptWidthHeightScalePosition(true);
481             AdaptAngleFlipDialPosition(true);
482 
483             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT);
484             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
485             SetSizePixel(aSize);
486             if (mxSidebar.is())
487                 mxSidebar->requestLayout();
488         }
489         break;
490 
491         case 3:
492         {
493             mpMtrWidth->SetMin( 1 );
494             mpMtrHeight->SetMin( 1 );
495             mpFtPosX->Show();
496             mpMtrPosX->Show();
497             mpFtPosY->Show();
498             mpMtrPosY->Show();
499 
500             //rotation
501             mpFtAngle->Hide();
502             mpMtrAngle->Hide();
503             mpDial->Hide();
504 
505             //flip
506             mpFlipTbx->Hide();
507             mpFtFlip->Hide();
508             mbIsFlip = false;
509 
510             AdaptWidthHeightScalePosition(true);
511             AdaptAngleFlipDialPosition(true);
512 
513             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT4);
514             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
515             SetSizePixel(aSize);
516             if (mxSidebar.is())
517                 mxSidebar->requestLayout();
518         }
519         break;
520     }
521 
522     //Added for windows classic theme
523     mpFlipTbx->SetBackground(Wallpaper());
524     mpFlipTbx->SetPaintTransparent(true);
525 }
526 
527 
528 
529 IMPL_LINK( PosSizePropertyPanel, ChangeWidthHdl, void*, /*pBox*/ )
530 {
531     if( mpCbxScale->IsChecked() &&
532         mpCbxScale->IsEnabled() )
533     {
534         long nHeight = (long) ( ((double) mlOldHeight * (double) mpMtrWidth->GetValue()) / (double) mlOldWidth );
535         if( nHeight <= mpMtrHeight->GetMax( FUNIT_NONE ) )
536         {
537             mpMtrHeight->SetUserValue( nHeight, FUNIT_NONE );
538         }
539         else
540         {
541             nHeight = (long)mpMtrHeight->GetMax( FUNIT_NONE );
542             mpMtrHeight->SetUserValue( nHeight );
543             const long nWidth = (long) ( ((double) mlOldWidth * (double) nHeight) / (double) mlOldHeight );
544             mpMtrWidth->SetUserValue( nWidth, FUNIT_NONE );
545         }
546     }
547     executeSize();
548     return 0;
549 }
550 
551 
552 
553 IMPL_LINK( PosSizePropertyPanel, ChangeHeightHdl, void *, EMPTYARG )
554 {
555     if( mpCbxScale->IsChecked() &&
556         mpCbxScale->IsEnabled() )
557     {
558         long nWidth = (long) ( ((double)mlOldWidth * (double)mpMtrHeight->GetValue()) / (double)mlOldHeight );
559         if( nWidth <= mpMtrWidth->GetMax( FUNIT_NONE ) )
560         {
561             mpMtrWidth->SetUserValue( nWidth, FUNIT_NONE );
562         }
563         else
564         {
565             nWidth = (long)mpMtrWidth->GetMax( FUNIT_NONE );
566             mpMtrWidth->SetUserValue( nWidth );
567             const long nHeight = (long) ( ((double)mlOldHeight * (double)nWidth) / (double)mlOldWidth );
568             mpMtrHeight->SetUserValue( nHeight, FUNIT_NONE );
569         }
570     }
571     executeSize();
572     return 0;
573 }
574 
575 
576 
577 IMPL_LINK( PosSizePropertyPanel, ChangePosXHdl, void *, EMPTYARG )
578 {
579     executePosX();
580     return 0;
581 }
582 
583 
584 
585 IMPL_LINK( PosSizePropertyPanel, ChangePosYHdl, void *, EMPTYARG )
586 {
587     executePosY();
588     return 0;
589 }
590 
591 
592 
593 IMPL_LINK( PosSizePropertyPanel, ClickAutoHdl, void *, EMPTYARG )
594 {
595     if ( mpCbxScale->IsChecked() )
596     {
597         mlOldWidth  = Max( GetCoreValue( *mpMtrWidth,  mePoolUnit ), 1L );
598         mlOldHeight = Max( GetCoreValue( *mpMtrHeight, mePoolUnit ), 1L );
599     }
600 
601     // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
602     SvtViewOptions	aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
603     aPageOpt.SetUserItem( USERITEM_NAME, ::com::sun::star::uno::makeAny( ::rtl::OUString( String::CreateFromInt32( mpCbxScale->IsChecked() ) ) ) );
604 
605     return 0;
606 }
607 
608 
609 
610 IMPL_LINK( PosSizePropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
611 {
612     String sTmp = mpMtrAngle->GetText();
613     bool    bNegative = 0;
614     sal_Unicode nChar = sTmp.GetChar( 0 );
615 
616     if( nChar == '-' )
617     {
618         bNegative = 1;
619         nChar = sTmp.GetChar( 1 );
620     }
621 
622     if( (nChar < '0') || (nChar > '9') )
623         return 0;
624     double dTmp = sTmp.ToDouble();
625     if(bNegative)
626     {
627         while(dTmp<0)
628             dTmp += 360;
629     }
630     sal_Int64 nTmp = dTmp*100;
631 
632     SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp);
633     SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X,(sal_uInt32) mlRotX);
634     SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y,(sal_uInt32) mlRotY);
635 
636     GetBindings()->GetDispatcher()->Execute(
637         SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aAngleItem, &aRotXItem, &aRotYItem, 0L );
638 
639     return 0;
640 }
641 
642 
643 
644 IMPL_LINK( PosSizePropertyPanel, RotationHdl, void *, EMPTYARG )
645 {
646     sal_Int32 nTmp = mpDial->GetRotation();
647 
648     SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp);
649     SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X,(sal_uInt32) mlRotX);
650     SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y,(sal_uInt32) mlRotY);
651 
652     GetBindings()->GetDispatcher()->Execute(
653         SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aAngleItem, &aRotXItem, &aRotYItem, 0L );
654 
655     return 0;
656 }
657 
658 
659 
660 IMPL_LINK( PosSizePropertyPanel, FlipHdl, ToolBox*, pBox )
661 {
662     switch (pBox->GetCurItemId())
663     {
664         case FLIP_HORIZONTAL:
665         {
666             SfxVoidItem aHoriItem (SID_FLIP_HORIZONTAL);
667             GetBindings()->GetDispatcher()->Execute(
668                 SID_FLIP_HORIZONTAL, SFX_CALLMODE_RECORD, &aHoriItem, 0L );
669         }
670         break;
671         case FLIP_VERTICAL:
672         {
673             SfxVoidItem aVertItem (SID_FLIP_VERTICAL );
674             GetBindings()->GetDispatcher()->Execute(
675                 SID_FLIP_VERTICAL, SFX_CALLMODE_RECORD, &aVertItem, 0L );
676         }
677         break;
678     }
679     return 0;
680 }
681 
682 
683 
684 void PosSizePropertyPanel::NotifyItemUpdate(
685     sal_uInt16 nSID,
686     SfxItemState eState,
687     const SfxPoolItem* pState,
688     const bool /* bIsEnabled */)
689 {
690     mpFtAngle->Enable();
691     mpMtrAngle->Enable();
692     mpDial->Enable();
693     mpFtFlip->Enable();
694     mpFlipTbx->Enable();
695 
696     const SfxUInt32Item*	pWidthItem;
697     const SfxUInt32Item*	pHeightItem;
698 
699     SfxViewShell* pCurSh = SfxViewShell::Current();
700     if ( pCurSh )
701         mpView = pCurSh->GetDrawView();
702     else
703         mpView = NULL;
704 
705     if ( mpView == NULL )
706         return;
707 
708     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
709 
710     if(1 == rMarkList.GetMarkCount())
711     {
712         const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
713         const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
714 
715         if((pObj->GetObjInventor() == SdrInventor) && (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) && ((SdrTextObj*)pObj)->HasText())
716             mbAdjustEnabled = true;
717         else
718             mbAdjustEnabled = false;
719     }
720     else
721         mbAdjustEnabled = false;
722 
723     // Pool unit and dialog unit may have changed, make sure that we
724     // have the current values.
725     mePoolUnit = maTransfWidthControl.GetCoreMetric();
726     meDlgUnit = GetModuleFieldUnit();
727 
728     switch (nSID)
729     {
730         case SID_ATTR_TRANSFORM_WIDTH:
731             if ( SFX_ITEM_AVAILABLE == eState )
732             {
733                 pWidthItem = dynamic_cast< const SfxUInt32Item* >(pState);
734 
735                 if(pWidthItem)
736                 {
737                     long mlOldWidth1 = pWidthItem->GetValue();
738 
739                     mlOldWidth1 = Fraction( mlOldWidth1 ) / maUIScale;
740                     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
741                     SetMetricValue( *mpMtrWidth, mlOldWidth1, mePoolUnit );
742                     mlOldWidth = mlOldWidth1;
743                     break;
744                 }
745             }
746 
747             mpMtrWidth->SetText( String());
748             break;
749 
750         case SID_ATTR_TRANSFORM_HEIGHT:
751             if ( SFX_ITEM_AVAILABLE == eState )
752             {
753                 pHeightItem = dynamic_cast< const SfxUInt32Item* >(pState);
754 
755                 if(pHeightItem)
756                 {
757                     long mlOldHeight1 = pHeightItem->GetValue();
758 
759                     mlOldHeight1 = Fraction( mlOldHeight1 ) / maUIScale;
760                     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
761                     SetMetricValue( *mpMtrHeight, mlOldHeight1, mePoolUnit );
762                     mlOldHeight = mlOldHeight1;
763                     break;
764                 }
765             }
766 
767             mpMtrHeight->SetText( String());
768             break;
769 
770         case SID_ATTR_TRANSFORM_POS_X:
771             if(SFX_ITEM_AVAILABLE == eState)
772             {
773                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
774 
775                 if(pItem)
776                 {
777                     long nTmp = pItem->GetValue();
778                     nTmp = Fraction( nTmp ) / maUIScale;
779                     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
780                     SetMetricValue( *mpMtrPosX, nTmp, mePoolUnit );
781                     break;
782                 }
783             }
784 
785             mpMtrPosX->SetText( String());
786             break;
787 
788         case SID_ATTR_TRANSFORM_POS_Y:
789             if(SFX_ITEM_AVAILABLE == eState)
790             {
791                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
792 
793                 if(pItem)
794                 {
795                     long nTmp = pItem->GetValue();
796                     nTmp = Fraction( nTmp ) / maUIScale;
797                     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
798                     SetMetricValue( *mpMtrPosY, nTmp, mePoolUnit );
799                     break;
800                 }
801             }
802 
803             mpMtrPosY->SetText( String());
804             break;
805 
806         case SID_ATTR_TRANSFORM_ROT_X:
807             if (SFX_ITEM_AVAILABLE == eState)
808             {
809                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
810 
811                 if(pItem)
812                 {
813                     mlRotX = pItem->GetValue();
814                     mlRotX = Fraction( mlRotX ) / maUIScale;
815                 }
816             }
817             break;
818 
819         case SID_ATTR_TRANSFORM_ROT_Y:
820             if (SFX_ITEM_AVAILABLE == eState)
821             {
822                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
823 
824                 if(pItem)
825                 {
826                     mlRotY = pItem->GetValue();
827                     mlRotY = Fraction( mlRotY ) / maUIScale;
828                 }
829             }
830             break;
831 
832         case SID_ATTR_TRANSFORM_PROTECT_POS:
833             if(SFX_ITEM_AVAILABLE == eState)
834             {
835                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
836 
837                 if(pItem)
838                 {
839                     // record the state of position protect
840                     mbPositionProtected = pItem->GetValue();
841                     break;
842                 }
843             }
844 
845             mbPositionProtected = false;
846             break;
847 
848         case SID_ATTR_TRANSFORM_PROTECT_SIZE:
849             if(SFX_ITEM_AVAILABLE == eState)
850             {
851                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
852 
853                 if(pItem)
854                 {
855                     // record the state of size protect
856                     mbSizeProtected = pItem->GetValue();
857                     break;
858                 }
859             }
860 
861             mbSizeProtected = false;
862             break;
863 
864         case SID_ATTR_TRANSFORM_AUTOWIDTH:
865             if(SFX_ITEM_AVAILABLE == eState)
866             {
867                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
868 
869                 if(pItem)
870                 {
871                     mbAutoWidth = pItem->GetValue();
872                 }
873             }
874             break;
875 
876         case SID_ATTR_TRANSFORM_AUTOHEIGHT:
877             if(SFX_ITEM_AVAILABLE == eState)
878             {
879                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
880 
881                 if(pItem)
882                 {
883                     mbAutoHeight = pItem->GetValue();
884                 }
885             }
886             break;
887 
888         case SID_ATTR_TRANSFORM_ANGLE:
889             if (eState >= SFX_ITEM_AVAILABLE)
890             {
891                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
892 
893                 if(pItem)
894                 {
895                     long nTmp = pItem->GetValue();
896 
897                     mpMtrAngle->SetValue( nTmp );
898                     mpDial->SetRotation( nTmp );
899 
900                     switch(nTmp)
901                     {
902                         case 0:
903                             mpMtrAngle->SelectEntryPos(0);
904                             break;
905                         case 4500:
906                             mpMtrAngle->SelectEntryPos(1);
907                             break;
908                         case 9000:
909                             mpMtrAngle->SelectEntryPos(2);
910                             break;
911                         case 13500:
912                             mpMtrAngle->SelectEntryPos(3);
913                             break;
914                         case 18000:
915                             mpMtrAngle->SelectEntryPos(4);
916                             break;
917                         case 22500:
918                             mpMtrAngle->SelectEntryPos(5);
919                             break;
920                         case 27000:
921                             mpMtrAngle->SelectEntryPos(6);
922                             break;
923                         case 315000:
924                             mpMtrAngle->SelectEntryPos(7);
925                             break;
926                     }
927 
928                     break;
929                 }
930             }
931 
932             mpMtrAngle->SetText( String() );
933             mpDial->SetRotation( 0 );
934             break;
935 
936         case SID_ATTR_METRIC:
937             MetricState( eState, pState );
938             break;
939 
940         default:
941             break;
942     }
943 
944     const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
945 
946     switch (rMarkList.GetMarkCount())
947     {
948         case 0:
949             break;
950 
951         case 1:
952         {
953             const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
954             const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
955 
956             if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
957                || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
958                  ) && OBJ_EDGE == eKind)
959                || OBJ_CAPTION == eKind)
960             {
961                 mpFtAngle->Disable();
962                 mpMtrAngle->Disable();
963                 mpDial->Disable();
964                 mpFlipTbx->Disable();
965                 mpFtFlip->Disable();
966             }
967             break;
968         }
969 
970         default:
971         {
972             sal_uInt16 nMarkObj = 0;
973             bool isNoEdge = true;
974 
975             while(isNoEdge && rMarkList.GetMark(nMarkObj))
976             {
977                 const SdrObject* pObj = rMarkList.GetMark(nMarkObj)->GetMarkedSdrObj();
978                 const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
979 
980                 if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
981                   || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
982                      ) && OBJ_EDGE == eKind)
983                   || OBJ_CAPTION == eKind)
984                 {
985                     isNoEdge = false;
986                     break;
987                 }
988                 nMarkObj++;
989             }
990 
991             if(!isNoEdge)
992             {
993                 mpFtAngle->Disable();
994                 mpMtrAngle->Disable();
995                 mpDial->Disable();
996                 mpFlipTbx->Disable();
997                 mpFtFlip->Disable();
998             }
999             break;
1000         }
1001     }
1002 
1003     if(nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject))
1004     {
1005         mpFlipTbx->Disable();
1006         mpFtFlip->Disable();
1007     }
1008 
1009     DisableControls();
1010 
1011     // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
1012     SvtViewOptions	aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
1013     String	sUserData;
1014     ::com::sun::star::uno::Any	aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
1015     ::rtl::OUString	aTemp;
1016     if ( aUserItem >>= aTemp )
1017         sUserData = String( aTemp );
1018     mpCbxScale->Check( (bool)sUserData.ToInt32() );
1019 }
1020 
1021 
1022 
1023 
1024 SfxBindings* PosSizePropertyPanel::GetBindings()
1025 {
1026     return mpBindings;
1027 }
1028 
1029 
1030 
1031 void PosSizePropertyPanel::executeSize()
1032 {
1033     if ( mpMtrWidth->IsValueModified() || mpMtrHeight->IsValueModified())
1034     {
1035         Fraction aUIScale = mpView->GetModel()->GetUIScale();
1036 
1037         // get Width
1038         double nWidth = (double)mpMtrWidth->GetValue( meDlgUnit );
1039         nWidth = MetricField::ConvertDoubleValue( nWidth, mpMtrWidth->GetBaseValue(), mpMtrWidth->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
1040         long lWidth = (long)(nWidth * (double)aUIScale);
1041         lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit );
1042         lWidth = (long)mpMtrWidth->Denormalize( lWidth );
1043 
1044         // get Height
1045         double nHeight = (double)mpMtrHeight->GetValue( meDlgUnit );
1046         nHeight = MetricField::ConvertDoubleValue( nHeight, mpMtrHeight->GetBaseValue(), mpMtrHeight->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
1047         long lHeight = (long)(nHeight * (double)aUIScale);
1048         lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit );
1049         lHeight = (long)mpMtrWidth->Denormalize( lHeight );
1050 
1051         // put Width & Height to itemset
1052         SfxUInt32Item aWidthItem( SID_ATTR_TRANSFORM_WIDTH, (sal_uInt32) lWidth);
1053         SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT, (sal_uInt32) lHeight);
1054         SfxAllEnumItem aPointItem (SID_ATTR_TRANSFORM_SIZE_POINT, (sal_uInt16)meRP);
1055         const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
1056 
1057         if( nCombinedContext == CombinedEnumContext(Application_WriterVariants, Context_Graphic)
1058             || nCombinedContext == CombinedEnumContext(Application_WriterVariants, Context_OLE)
1059             )
1060         {
1061             GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
1062         }
1063         else
1064         {
1065             if ( (mpMtrWidth->IsValueModified()) && (mpMtrHeight->IsValueModified()))
1066                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
1067             else if( mpMtrWidth->IsValueModified())
1068                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aPointItem, 0L );
1069             else if ( mpMtrHeight->IsValueModified())
1070                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aHeightItem, &aPointItem, 0L );
1071         }
1072     }
1073 }
1074 
1075 
1076 
1077 void PosSizePropertyPanel::executePosX()
1078 {
1079     if ( mpMtrPosX->IsValueModified())
1080     {
1081         long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
1082         if( mbMtrPosXMirror )
1083             lX = -lX;
1084         long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
1085 
1086         Size aPageSize;
1087         Rectangle aRect;
1088         maRect = mpView->GetAllMarkedRect();
1089         aRect = mpView->GetAllMarkedRect();
1090 
1091         Fraction aUIScale = mpView->GetModel()->GetUIScale();
1092         lX += maAnchorPos.X();
1093         lX = Fraction( lX ) * aUIScale;
1094         lY += maAnchorPos.Y();
1095         lY = Fraction( lY ) * aUIScale;
1096 
1097         SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
1098         SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
1099 
1100         GetBindings()->GetDispatcher()->Execute(
1101             SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosXItem, 0L );
1102     }
1103 }
1104 
1105 
1106 
1107 void PosSizePropertyPanel::executePosY()
1108 {
1109     if ( mpMtrPosY->IsValueModified() )
1110     {
1111         long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
1112         long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
1113 
1114         Size aPageSize;
1115         Rectangle aRect;
1116         maRect = mpView->GetAllMarkedRect();
1117         aRect = mpView->GetAllMarkedRect();
1118 
1119         Fraction aUIScale = mpView->GetModel()->GetUIScale();
1120         lX += maAnchorPos.X();
1121         lX = Fraction( lX ) * aUIScale;
1122         lY += maAnchorPos.Y();
1123         lY = Fraction( lY ) * aUIScale;
1124 
1125         SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
1126         SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
1127 
1128         GetBindings()->GetDispatcher()->Execute(
1129             SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosYItem, 0L );
1130     }
1131 }
1132 
1133 
1134 
1135 void PosSizePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
1136 {
1137     bool bPosXBlank = false;
1138     bool bPosYBlank = false;
1139     bool bWidthBlank = false;
1140     bool bHeightBlank = false;
1141     String sNull = String::CreateFromAscii("");
1142     meDlgUnit = GetCurrentUnit(eState,pState);
1143 
1144     if( mpMtrPosX->GetText() == sNull )
1145         bPosXBlank = true;
1146     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
1147     if(bPosXBlank)
1148         mpMtrPosX->SetText(String());
1149 
1150     if( mpMtrPosY->GetText() == sNull )
1151         bPosYBlank = true;
1152     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
1153     if(bPosYBlank)
1154         mpMtrPosY->SetText(String());
1155 
1156     if( mpMtrWidth->GetText() == sNull )
1157         bWidthBlank = true;
1158     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
1159     if(bWidthBlank)
1160         mpMtrWidth->SetText(String());
1161 
1162     if( mpMtrHeight->GetText() == sNull )
1163         bHeightBlank = true;
1164     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
1165     if(bHeightBlank)
1166         mpMtrHeight->SetText(String());
1167 }
1168 
1169 
1170 
1171 FieldUnit PosSizePropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
1172 {
1173     FieldUnit eUnit = FUNIT_NONE;
1174 
1175     if ( pState && eState >= SFX_ITEM_DEFAULT )
1176     {
1177         eUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
1178     }
1179     else
1180     {
1181         SfxViewFrame* pFrame = SfxViewFrame::Current();
1182         SfxObjectShell* pSh = NULL;
1183         if ( pFrame )
1184             pSh = pFrame->GetObjectShell();
1185         if ( pSh )
1186         {
1187             SfxModule* pModule = pSh->GetModule();
1188             if ( pModule )
1189             {
1190                 const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
1191                 if ( pItem )
1192                     eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
1193             }
1194             else
1195             {
1196                 DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" );
1197             }
1198         }
1199     }
1200 
1201     return eUnit;
1202 }
1203 
1204 
1205 
1206 void PosSizePropertyPanel::DisableControls()
1207 {
1208     if( mbPositionProtected )
1209     {
1210         // the position is protected("Position protect" option in modal dialog is checked),
1211         // disable all the Position controls in sidebar
1212         mpFtPosX->Disable();
1213         mpMtrPosX->Disable();
1214         mpFtPosY->Disable();
1215         mpMtrPosY->Disable();
1216         mpFtAngle->Disable();
1217         mpMtrAngle->Disable();
1218         mpDial->Disable();
1219         mpFtFlip->Disable();
1220         mpFlipTbx->Disable();
1221 
1222         mpFtWidth->Disable();
1223         mpMtrWidth->Disable();
1224         mpFtHeight->Disable();
1225         mpMtrHeight->Disable();
1226         mpCbxScale->Disable();
1227     }
1228     else
1229     {
1230         mpFtPosX->Enable();
1231         mpMtrPosX->Enable();
1232         mpFtPosY->Enable();
1233         mpMtrPosY->Enable();
1234 
1235         //mpFtAngle->Enable();
1236         //mpMtrAngle->Enable();
1237         //mpDial->Enable();
1238         //mpFtFlip->Enable();
1239         //mpFlipTbx->Enable();
1240 
1241         if( mbSizeProtected )
1242         {
1243             mpFtWidth->Disable();
1244             mpMtrWidth->Disable();
1245             mpFtHeight->Disable();
1246             mpMtrHeight->Disable();
1247             mpCbxScale->Disable();
1248         }
1249         else
1250         {
1251             if(	mbAdjustEnabled )
1252             {
1253                 if( mbAutoWidth )
1254                 {
1255                     mpFtWidth->Disable();
1256                     mpMtrWidth->Disable();
1257                     mpCbxScale->Disable();
1258                 }
1259                 else
1260                 {
1261                     mpFtWidth->Enable();
1262                     mpMtrWidth->Enable();
1263                 }
1264                 if( mbAutoHeight )
1265                 {
1266                     mpFtHeight->Disable();
1267                     mpMtrHeight->Disable();
1268                     mpCbxScale->Disable();
1269                 }
1270                 else
1271                 {
1272                     mpFtHeight->Enable();
1273                     mpMtrHeight->Enable();
1274                 }
1275                 if( !mbAutoWidth && !mbAutoHeight )
1276                     mpCbxScale->Enable();
1277             }
1278             else
1279             {
1280                 mpFtWidth->Enable();
1281                 mpMtrWidth->Enable();
1282                 mpFtHeight->Enable();
1283                 mpMtrHeight->Enable();
1284                 mpCbxScale->Enable();
1285             }
1286         }
1287     }
1288 }
1289 
1290 
1291 } } // end of namespace svx::sidebar
1292 
1293 // eof
1294