xref: /AOO41X/main/svx/source/sidebar/possize/PosSizePropertyPanel.cxx (revision c52956d99206d4260ca75cf85deddec899b4249f)
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/propertypanel.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     switch (nSID)
724     {
725         case SID_ATTR_TRANSFORM_WIDTH:
726             if ( SFX_ITEM_AVAILABLE == eState )
727             {
728                 pWidthItem = dynamic_cast< const SfxUInt32Item* >(pState);
729 
730                 if(pWidthItem)
731                 {
732                     long mlOldWidth1 = pWidthItem->GetValue();
733 
734                     mlOldWidth1 = Fraction( mlOldWidth1 ) / maUIScale;
735                     SetMetricValue( *mpMtrWidth, mlOldWidth1, mePoolUnit );
736                     mlOldWidth = mlOldWidth1;
737                     break;
738                 }
739             }
740 
741             mpMtrWidth->SetText( String());
742             break;
743 
744         case SID_ATTR_TRANSFORM_HEIGHT:
745             if ( SFX_ITEM_AVAILABLE == eState )
746             {
747                 pHeightItem = dynamic_cast< const SfxUInt32Item* >(pState);
748 
749                 if(pHeightItem)
750                 {
751                     long mlOldHeight1 = pHeightItem->GetValue();
752 
753                     mlOldHeight1 = Fraction( mlOldHeight1 ) / maUIScale;
754                     SetMetricValue( *mpMtrHeight, mlOldHeight1, mePoolUnit );
755                     mlOldHeight = mlOldHeight1;
756                     break;
757                 }
758             }
759 
760             mpMtrHeight->SetText( String());
761             break;
762 
763         case SID_ATTR_TRANSFORM_POS_X:
764             if(SFX_ITEM_AVAILABLE == eState)
765             {
766                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
767 
768                 if(pItem)
769                 {
770                     long nTmp = pItem->GetValue();
771                     nTmp = Fraction( nTmp ) / maUIScale;
772                     SetMetricValue( *mpMtrPosX, nTmp, mePoolUnit );
773                     break;
774                 }
775             }
776 
777             mpMtrPosX->SetText( String());
778             break;
779 
780         case SID_ATTR_TRANSFORM_POS_Y:
781             if(SFX_ITEM_AVAILABLE == eState)
782             {
783                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
784 
785                 if(pItem)
786                 {
787                     long nTmp = pItem->GetValue();
788                     nTmp = Fraction( nTmp ) / maUIScale;
789                     SetMetricValue( *mpMtrPosY, nTmp, mePoolUnit );
790                     break;
791                 }
792             }
793 
794             mpMtrPosY->SetText( String());
795             break;
796 
797         case SID_ATTR_TRANSFORM_ROT_X:
798             if (SFX_ITEM_AVAILABLE == eState)
799             {
800                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
801 
802                 if(pItem)
803                 {
804                     mlRotX = pItem->GetValue();
805                     mlRotX = Fraction( mlRotX ) / maUIScale;
806                 }
807             }
808             break;
809 
810         case SID_ATTR_TRANSFORM_ROT_Y:
811             if (SFX_ITEM_AVAILABLE == eState)
812             {
813                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
814 
815                 if(pItem)
816                 {
817                     mlRotY = pItem->GetValue();
818                     mlRotY = Fraction( mlRotY ) / maUIScale;
819                 }
820             }
821             break;
822 
823         case SID_ATTR_TRANSFORM_PROTECT_POS:
824             if(SFX_ITEM_AVAILABLE == eState)
825             {
826                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
827 
828                 if(pItem)
829                 {
830                     // record the state of position protect
831                     mbPositionProtected = pItem->GetValue();
832                     break;
833                 }
834             }
835 
836             mbPositionProtected = false;
837             break;
838 
839         case SID_ATTR_TRANSFORM_PROTECT_SIZE:
840             if(SFX_ITEM_AVAILABLE == eState)
841             {
842                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
843 
844                 if(pItem)
845                 {
846                     // record the state of size protect
847                     mbSizeProtected = pItem->GetValue();
848                     break;
849                 }
850             }
851 
852             mbSizeProtected = false;
853             break;
854 
855         case SID_ATTR_TRANSFORM_AUTOWIDTH:
856             if(SFX_ITEM_AVAILABLE == eState)
857             {
858                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
859 
860                 if(pItem)
861                 {
862                     mbAutoWidth = pItem->GetValue();
863                 }
864             }
865             break;
866 
867         case SID_ATTR_TRANSFORM_AUTOHEIGHT:
868             if(SFX_ITEM_AVAILABLE == eState)
869             {
870                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
871 
872                 if(pItem)
873                 {
874                     mbAutoHeight = pItem->GetValue();
875                 }
876             }
877             break;
878 
879         case SID_ATTR_TRANSFORM_ANGLE:
880             if (eState >= SFX_ITEM_AVAILABLE)
881             {
882                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
883 
884                 if(pItem)
885                 {
886                     long nTmp = pItem->GetValue();
887 
888                     mpMtrAngle->SetValue( nTmp );
889                     mpDial->SetRotation( nTmp );
890 
891                     switch(nTmp)
892                     {
893                         case 0:
894                             mpMtrAngle->SelectEntryPos(0);
895                             break;
896                         case 4500:
897                             mpMtrAngle->SelectEntryPos(1);
898                             break;
899                         case 9000:
900                             mpMtrAngle->SelectEntryPos(2);
901                             break;
902                         case 13500:
903                             mpMtrAngle->SelectEntryPos(3);
904                             break;
905                         case 18000:
906                             mpMtrAngle->SelectEntryPos(4);
907                             break;
908                         case 22500:
909                             mpMtrAngle->SelectEntryPos(5);
910                             break;
911                         case 27000:
912                             mpMtrAngle->SelectEntryPos(6);
913                             break;
914                         case 315000:
915                             mpMtrAngle->SelectEntryPos(7);
916                     }
917 
918                     break;
919                 }
920             }
921 
922             mpMtrAngle->SetText( String() );
923             mpDial->SetRotation( 0 );
924             break;
925 
926         case SID_ATTR_METRIC:
927             MetricState( eState, pState );
928             break;
929 
930         default:
931             break;
932     }
933 
934     const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
935 
936     switch (rMarkList.GetMarkCount())
937     {
938         case 0:
939             break;
940 
941         case 1:
942         {
943             const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
944             const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
945 
946             if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
947                || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
948                  ) && OBJ_EDGE == eKind)
949                || OBJ_CAPTION == eKind)
950             {
951                 mpFtAngle->Disable();
952                 mpMtrAngle->Disable();
953                 mpDial->Disable();
954                 mpFlipTbx->Disable();
955                 mpFtFlip->Disable();
956             }
957             break;
958         }
959 
960         default:
961         {
962             sal_uInt16 nMarkObj = 0;
963             bool isNoEdge = true;
964 
965             while(isNoEdge && rMarkList.GetMark(nMarkObj))
966             {
967                 const SdrObject* pObj = rMarkList.GetMark(nMarkObj)->GetMarkedSdrObj();
968                 const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
969 
970                 if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
971                   || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
972                      ) && OBJ_EDGE == eKind)
973                   || OBJ_CAPTION == eKind)
974                 {
975                     isNoEdge = false;
976                     break;
977                 }
978                 nMarkObj++;
979             }
980 
981             if(!isNoEdge)
982             {
983                 mpFtAngle->Disable();
984                 mpMtrAngle->Disable();
985                 mpDial->Disable();
986                 mpFlipTbx->Disable();
987                 mpFtFlip->Disable();
988             }
989             break;
990         }
991     }
992 
993     if(nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject))
994     {
995         mpFlipTbx->Disable();
996         mpFtFlip->Disable();
997     }
998 
999     DisableControls();
1000 
1001     // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
1002     SvtViewOptions	aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
1003     String	sUserData;
1004     ::com::sun::star::uno::Any	aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
1005     ::rtl::OUString	aTemp;
1006     if ( aUserItem >>= aTemp )
1007         sUserData = String( aTemp );
1008     mpCbxScale->Check( (bool)sUserData.ToInt32() );
1009 }
1010 
1011 
1012 
1013 
1014 SfxBindings* PosSizePropertyPanel::GetBindings()
1015 {
1016     return mpBindings;
1017 }
1018 
1019 
1020 
1021 void PosSizePropertyPanel::executeSize()
1022 {
1023     if ( mpMtrWidth->IsValueModified() || mpMtrHeight->IsValueModified())
1024     {
1025         Fraction aUIScale = mpView->GetModel()->GetUIScale();
1026 
1027         // get Width
1028         double nWidth = (double)mpMtrWidth->GetValue( meDlgUnit );
1029         nWidth = MetricField::ConvertDoubleValue( nWidth, mpMtrWidth->GetBaseValue(), mpMtrWidth->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
1030         long lWidth = (long)(nWidth * (double)aUIScale);
1031         lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit );
1032         lWidth = (long)mpMtrWidth->Denormalize( lWidth );
1033 
1034         // get Height
1035         double nHeight = (double)mpMtrHeight->GetValue( meDlgUnit );
1036         nHeight = MetricField::ConvertDoubleValue( nHeight, mpMtrHeight->GetBaseValue(), mpMtrHeight->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
1037         long lHeight = (long)(nHeight * (double)aUIScale);
1038         lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit );
1039         lHeight = (long)mpMtrWidth->Denormalize( lHeight );
1040 
1041         // put Width & Height to itemset
1042         SfxUInt32Item aWidthItem( SID_ATTR_TRANSFORM_WIDTH, (sal_uInt32) lWidth);
1043         SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT, (sal_uInt32) lHeight);
1044         SfxAllEnumItem aPointItem (SID_ATTR_TRANSFORM_SIZE_POINT, (sal_uInt16)meRP);
1045         const sal_Int32 nCombinedContext(maContext.GetCombinedContext());
1046 
1047         if( nCombinedContext == CombinedEnumContext(Application_Writer, Context_Graphic) // mnContextId == PROPERTY_CONTEXT_SW_GRAPHIC
1048             || nCombinedContext == CombinedEnumContext(Application_Writer, Context_OLE) //mnContextId == PROPERTY_CONTEXT_SW_OLE
1049             )
1050         // if( mnContextId == PROPERTY_CONTEXT_SW_GRAPHIC || mnContextId == PROPERTY_CONTEXT_SW_OLE )
1051         {
1052             GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
1053         }
1054         else
1055         {
1056             if ( (mpMtrWidth->IsValueModified()) && (mpMtrHeight->IsValueModified()))
1057                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
1058             else if( mpMtrWidth->IsValueModified())
1059                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aPointItem, 0L );
1060             else if ( mpMtrHeight->IsValueModified())
1061                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aHeightItem, &aPointItem, 0L );
1062         }
1063     }
1064 }
1065 
1066 
1067 
1068 void PosSizePropertyPanel::executePosX()
1069 {
1070     if ( mpMtrPosX->IsValueModified())
1071     {
1072         long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
1073         if( mbMtrPosXMirror )
1074             lX = -lX;
1075         long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
1076 
1077         Size aPageSize;
1078         Rectangle aRect;
1079         maRect = mpView->GetAllMarkedRect();
1080         aRect = mpView->GetAllMarkedRect();
1081 
1082         Fraction aUIScale = mpView->GetModel()->GetUIScale();
1083         lX += maAnchorPos.X();
1084         lX = Fraction( lX ) * aUIScale;
1085         lY += maAnchorPos.Y();
1086         lY = Fraction( lY ) * aUIScale;
1087 
1088         SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
1089         SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
1090 
1091         GetBindings()->GetDispatcher()->Execute(
1092             SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosXItem, 0L );
1093     }
1094 }
1095 
1096 
1097 
1098 void PosSizePropertyPanel::executePosY()
1099 {
1100     if ( mpMtrPosY->IsValueModified() )
1101     {
1102         long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
1103         long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
1104 
1105         Size aPageSize;
1106         Rectangle aRect;
1107         maRect = mpView->GetAllMarkedRect();
1108         aRect = mpView->GetAllMarkedRect();
1109 
1110         Fraction aUIScale = mpView->GetModel()->GetUIScale();
1111         lX += maAnchorPos.X();
1112         lX = Fraction( lX ) * aUIScale;
1113         lY += maAnchorPos.Y();
1114         lY = Fraction( lY ) * aUIScale;
1115 
1116         SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
1117         SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
1118 
1119         GetBindings()->GetDispatcher()->Execute(
1120             SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosYItem, 0L );
1121     }
1122 }
1123 
1124 
1125 
1126 void PosSizePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
1127 {
1128     bool bPosXBlank = false;
1129     bool bPosYBlank = false;
1130     bool bWidthBlank = false;
1131     bool bHeightBlank = false;
1132     String sNull = String::CreateFromAscii("");
1133     meDlgUnit = GetCurrentUnit(eState,pState);
1134 
1135     if( mpMtrPosX->GetText() == sNull )
1136         bPosXBlank = true;
1137     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
1138     if(bPosXBlank)
1139         mpMtrPosX->SetText(String());
1140 
1141     if( mpMtrPosY->GetText() == sNull )
1142         bPosYBlank = true;
1143     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
1144     if(bPosYBlank)
1145         mpMtrPosY->SetText(String());
1146 
1147     if( mpMtrWidth->GetText() == sNull )
1148         bWidthBlank = true;
1149     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
1150     if(bWidthBlank)
1151         mpMtrWidth->SetText(String());
1152 
1153     if( mpMtrHeight->GetText() == sNull )
1154         bHeightBlank = true;
1155     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
1156     if(bHeightBlank)
1157         mpMtrHeight->SetText(String());
1158 }
1159 
1160 
1161 
1162 FieldUnit PosSizePropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
1163 {
1164     FieldUnit eUnit = FUNIT_NONE;
1165 
1166     if ( pState && eState >= SFX_ITEM_DEFAULT )
1167     {
1168         eUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
1169     }
1170     else
1171     {
1172         SfxViewFrame* pFrame = SfxViewFrame::Current();
1173         SfxObjectShell* pSh = NULL;
1174         if ( pFrame )
1175             pSh = pFrame->GetObjectShell();
1176         if ( pSh )
1177         {
1178             SfxModule* pModule = pSh->GetModule();
1179             if ( pModule )
1180             {
1181                 const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
1182                 if ( pItem )
1183                     eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
1184             }
1185             else
1186             {
1187                 DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" );
1188             }
1189         }
1190     }
1191 
1192     return eUnit;
1193 }
1194 
1195 
1196 
1197 void PosSizePropertyPanel::DisableControls()
1198 {
1199     if( mbPositionProtected )
1200     {
1201         // the position is protected("Position protect" option in modal dialog is checked),
1202         // disable all the Position controls in sidebar
1203         mpFtPosX->Disable();
1204         mpMtrPosX->Disable();
1205         mpFtPosY->Disable();
1206         mpMtrPosY->Disable();
1207         mpFtAngle->Disable();
1208         mpMtrAngle->Disable();
1209         mpDial->Disable();
1210         mpFtFlip->Disable();
1211         mpFlipTbx->Disable();
1212 
1213         mpFtWidth->Disable();
1214         mpMtrWidth->Disable();
1215         mpFtHeight->Disable();
1216         mpMtrHeight->Disable();
1217         mpCbxScale->Disable();
1218     }
1219     else
1220     {
1221         mpFtPosX->Enable();
1222         mpMtrPosX->Enable();
1223         mpFtPosY->Enable();
1224         mpMtrPosY->Enable();
1225 
1226         //mpFtAngle->Enable();
1227         //mpMtrAngle->Enable();
1228         //mpDial->Enable();
1229         //mpFtFlip->Enable();
1230         //mpFlipTbx->Enable();
1231 
1232         if( mbSizeProtected )
1233         {
1234             mpFtWidth->Disable();
1235             mpMtrWidth->Disable();
1236             mpFtHeight->Disable();
1237             mpMtrHeight->Disable();
1238             mpCbxScale->Disable();
1239         }
1240         else
1241         {
1242             if(	mbAdjustEnabled )
1243             {
1244                 if( mbAutoWidth )
1245                 {
1246                     mpFtWidth->Disable();
1247                     mpMtrWidth->Disable();
1248                     mpCbxScale->Disable();
1249                 }
1250                 else
1251                 {
1252                     mpFtWidth->Enable();
1253                     mpMtrWidth->Enable();
1254                 }
1255                 if( mbAutoHeight )
1256                 {
1257                     mpFtHeight->Disable();
1258                     mpMtrHeight->Disable();
1259                     mpCbxScale->Disable();
1260                 }
1261                 else
1262                 {
1263                     mpFtHeight->Enable();
1264                     mpMtrHeight->Enable();
1265                 }
1266                 if( !mbAutoWidth && !mbAutoHeight )
1267                     mpCbxScale->Enable();
1268             }
1269             else
1270             {
1271                 mpFtWidth->Enable();
1272                 mpMtrWidth->Enable();
1273                 mpFtHeight->Enable();
1274                 mpMtrHeight->Enable();
1275                 mpCbxScale->Enable();
1276             }
1277         }
1278     }
1279 }
1280 
1281 
1282 } } // end of namespace svx::sidebar
1283 
1284 // eof
1285