xref: /AOO41X/main/svx/source/sidebar/possize/PosSizePropertyPanel.cxx (revision 5f79b2b9670beba2dd6cdfbd8fe333c4e997ffc4)
15d39f272SZheng Fan /**************************************************************
25d39f272SZheng Fan  *
35d39f272SZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
45d39f272SZheng Fan  * or more contributor license agreements.  See the NOTICE file
55d39f272SZheng Fan  * distributed with this work for additional information
65d39f272SZheng Fan  * regarding copyright ownership.  The ASF licenses this file
75d39f272SZheng Fan  * to you under the Apache License, Version 2.0 (the
85d39f272SZheng Fan  * "License"); you may not use this file except in compliance
95d39f272SZheng Fan  * with the License.  You may obtain a copy of the License at
105d39f272SZheng Fan  *
115d39f272SZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
125d39f272SZheng Fan  *
135d39f272SZheng Fan  * Unless required by applicable law or agreed to in writing,
145d39f272SZheng Fan  * software distributed under the License is distributed on an
155d39f272SZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165d39f272SZheng Fan  * KIND, either express or implied.  See the License for the
175d39f272SZheng Fan  * specific language governing permissions and limitations
185d39f272SZheng Fan  * under the License.
195d39f272SZheng Fan  *
205d39f272SZheng Fan  *************************************************************/
215d39f272SZheng Fan 
22d29c2fc2SAndre Fischer #include <sfx2/sidebar/ResourceDefinitions.hrc>
235d39f272SZheng Fan #include <sfx2/sidebar/Theme.hxx>
245d39f272SZheng Fan #include <sfx2/sidebar/ControlFactory.hxx>
256a606da0SAndre Fischer #include <sfx2/sidebar/Layouter.hxx>
265d39f272SZheng Fan #include "PosSizePropertyPanel.hxx"
275d39f272SZheng Fan #include "PosSizePropertyPanel.hrc"
28facb16e7SArmin Le Grand #include <svx/sidebar/SidebarDialControl.hxx>
295d39f272SZheng Fan #include <svx/dialogs.hrc>
305d39f272SZheng Fan #include <svx/dialmgr.hxx>
315d39f272SZheng Fan #include <sfx2/dispatch.hxx>
325d39f272SZheng Fan #include <sfx2/bindings.hxx>
335d39f272SZheng Fan #include <sfx2/viewsh.hxx>
345d39f272SZheng Fan #include <sfx2/objsh.hxx>
35aed5c350SAndre Fischer #include <sfx2/imagemgr.hxx>
365d39f272SZheng Fan #include <svx/dlgutil.hxx>
375d39f272SZheng Fan #include <unotools/viewoptions.hxx>
385d39f272SZheng Fan #include <vcl/virdev.hxx>
395d39f272SZheng Fan #include <vcl/svapp.hxx>
405d39f272SZheng Fan #include <vcl/field.hxx>
415d39f272SZheng Fan #include <vcl/fixed.hxx>
425d39f272SZheng Fan #include <vcl/toolbox.hxx>
435d39f272SZheng Fan #include <svx/svdview.hxx>
445d39f272SZheng Fan #include <svl/aeitem.hxx>
455d39f272SZheng Fan 
465d39f272SZheng Fan using namespace css;
475d39f272SZheng Fan using namespace cssu;
486a606da0SAndre Fischer using ::sfx2::sidebar::Layouter;
495d39f272SZheng Fan using ::sfx2::sidebar::Theme;
505d39f272SZheng Fan 
515d39f272SZheng Fan #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
525d39f272SZheng Fan #define USERITEM_NAME rtl::OUString::createFromAscii("FitItem")
535d39f272SZheng Fan #define NO_SELECT       (65535)
545d39f272SZheng Fan 
555d39f272SZheng Fan 
565d39f272SZheng Fan 
575d39f272SZheng Fan namespace svx { namespace sidebar {
585d39f272SZheng Fan 
595d39f272SZheng Fan 
605d39f272SZheng Fan 
PosSizePropertyPanel(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings,const cssu::Reference<css::ui::XSidebar> & rxSidebar)615d39f272SZheng Fan PosSizePropertyPanel::PosSizePropertyPanel(
625d39f272SZheng Fan     Window* pParent,
635d39f272SZheng Fan     const cssu::Reference<css::frame::XFrame>& rxFrame,
6437fee4fdSAndre Fischer     SfxBindings* pBindings,
6537fee4fdSAndre Fischer     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
665d39f272SZheng Fan :   Control(
675d39f272SZheng Fan         pParent,
685d39f272SZheng Fan         SVX_RES(RID_SIDEBAR_POSSIZE_PANEL)),
695d39f272SZheng Fan     mpFtPosX(new FixedText(this, SVX_RES(FT_SBSHAPE_HORIZONTAL))),
705d39f272SZheng Fan     mpMtrPosX(new MetricField(this, SVX_RES(MF_SBSHAPE_HORIZONTAL))),
715d39f272SZheng Fan     mpFtPosY(new FixedText(this, SVX_RES(FT_SBSHAPE_VERTICAL))),
725d39f272SZheng Fan     mpMtrPosY(new MetricField(this, SVX_RES(MF_SBSHAPE_VERTICAL))),
735d39f272SZheng Fan     mpFtWidth(new FixedText(this, SVX_RES(FT_WIDTH))),
745d39f272SZheng Fan     mpMtrWidth(new MetricField(this, SVX_RES(MTR_FLD_WIDTH))),
755d39f272SZheng Fan     mpFtHeight(new FixedText(this, SVX_RES(FT_HEIGHT))),
765d39f272SZheng Fan     mpMtrHeight(new MetricField(this, SVX_RES(MTR_FLD_HEIGHT))),
775d39f272SZheng Fan     mpCbxScale(new CheckBox(this, SVX_RES(CBX_SCALE))),
785d39f272SZheng Fan     mpFtAngle(new FixedText(this, SVX_RES(FT_ANGLE))),
795d39f272SZheng Fan     mpMtrAngle(new MetricBox(this, SVX_RES(MTR_FLD_ANGLE))),
805d39f272SZheng Fan     mpDial(new SidebarDialControl(this, SVX_RES(DIAL_CONTROL))),
815d39f272SZheng Fan     mpFtFlip(new FixedText(this, SVX_RES(FT_FLIP))),
825d39f272SZheng Fan     mpFlipTbxBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
835d39f272SZheng Fan     mpFlipTbx(sfx2::sidebar::ControlFactory::CreateToolBox(mpFlipTbxBackground.get(), SVX_RES(TBX_FLIP))),
845d39f272SZheng Fan     maRect(),
855d39f272SZheng Fan     mpView(0),
865d39f272SZheng Fan     mlOldWidth(1),
875d39f272SZheng Fan     mlOldHeight(1),
885d39f272SZheng Fan     meRP(RP_LT),
895d39f272SZheng Fan     maAnchorPos(),
905d39f272SZheng Fan     mlRotX(0),
915d39f272SZheng Fan     mlRotY(0),
925d39f272SZheng Fan     maUIScale(),
935d39f272SZheng Fan     mePoolUnit(),
945d39f272SZheng Fan     meDlgUnit(),
955d39f272SZheng Fan     maTransfPosXControl(SID_ATTR_TRANSFORM_POS_X, *pBindings, *this),
965d39f272SZheng Fan     maTransfPosYControl(SID_ATTR_TRANSFORM_POS_Y, *pBindings, *this),
975d39f272SZheng Fan     maTransfWidthControl(SID_ATTR_TRANSFORM_WIDTH, *pBindings, *this),
985d39f272SZheng Fan     maTransfHeightControl(SID_ATTR_TRANSFORM_HEIGHT, *pBindings, *this),
995d39f272SZheng Fan     maSvxAngleControl( SID_ATTR_TRANSFORM_ANGLE, *pBindings, *this),
1005d39f272SZheng Fan     maRotXControl(SID_ATTR_TRANSFORM_ROT_X, *pBindings, *this),
1015d39f272SZheng Fan     maRotYControl(SID_ATTR_TRANSFORM_ROT_Y, *pBindings, *this),
1025d39f272SZheng Fan     maProPosControl(SID_ATTR_TRANSFORM_PROTECT_POS, *pBindings, *this),
1035d39f272SZheng Fan     maProSizeControl(SID_ATTR_TRANSFORM_PROTECT_SIZE, *pBindings, *this),
1045d39f272SZheng Fan     maAutoWidthControl(SID_ATTR_TRANSFORM_AUTOWIDTH, *pBindings, *this),
1055d39f272SZheng Fan     maAutoHeightControl(SID_ATTR_TRANSFORM_AUTOHEIGHT, *pBindings, *this),
1065d39f272SZheng Fan     m_aMetricCtl(SID_ATTR_METRIC, *pBindings, *this),
1075d39f272SZheng Fan     mxFrame(rxFrame),
1085d39f272SZheng Fan     maContext(),
1095d39f272SZheng Fan     mpBindings(pBindings),
110d74d90d6SArmin Le Grand     maFtWidthOrigPos(mpFtWidth->GetPosPixel()),
111d74d90d6SArmin Le Grand     maMtrWidthOrigPos(mpMtrWidth->GetPosPixel()),
112d74d90d6SArmin Le Grand     maFtHeightOrigPos(mpFtHeight->GetPosPixel()),
113d74d90d6SArmin Le Grand     maMtrHeightOrigPos(mpMtrHeight->GetPosPixel()),
114d74d90d6SArmin Le Grand     maCbxScaleOrigPos(mpCbxScale->GetPosPixel()),
115d74d90d6SArmin Le Grand     maFtAngleOrigPos(mpFtAngle->GetPosPixel()),
116d74d90d6SArmin Le Grand     maMtrAnglOrigPos(mpMtrAngle->GetPosPixel()),
117d74d90d6SArmin Le Grand     maFlipTbxOrigPos(mpFlipTbx->GetPosPixel()),
118d74d90d6SArmin Le Grand     maDialOrigPos(mpDial->GetPosPixel()),
119d74d90d6SArmin Le Grand     maFtFlipOrigPos(mpFtFlip->GetPosPixel()),
1205d39f272SZheng Fan     mbMtrPosXMirror(false),
1215d39f272SZheng Fan     mbSizeProtected(false),
1225d39f272SZheng Fan     mbPositionProtected(false),
1235d39f272SZheng Fan     mbAutoWidth(false),
1245d39f272SZheng Fan     mbAutoHeight(false),
1255d39f272SZheng Fan     mbAdjustEnabled(false),
1265d39f272SZheng Fan     mbIsFlip(false),
1276a606da0SAndre Fischer     mxSidebar(rxSidebar),
1286a606da0SAndre Fischer     maLayouter(*this)
1295d39f272SZheng Fan {
1305d39f272SZheng Fan     Initialize();
1315d39f272SZheng Fan     FreeResource();
1320c259c9fSOliver-Rainer Wittmann 
1330c259c9fSOliver-Rainer Wittmann     mpBindings->Update( SID_ATTR_TRANSFORM_WIDTH );
1340c259c9fSOliver-Rainer Wittmann     mpBindings->Update( SID_ATTR_TRANSFORM_HEIGHT );
1350c259c9fSOliver-Rainer Wittmann     mpBindings->Update( SID_ATTR_TRANSFORM_PROTECT_SIZE );
1360c259c9fSOliver-Rainer Wittmann     mpBindings->Update( SID_ATTR_METRIC );
1376a606da0SAndre Fischer 
1386a606da0SAndre Fischer     // Setup the grid layouter.
1396a606da0SAndre Fischer     const sal_Int32 nMappedMboxWidth (Layouter::MapWidth(*this, MBOX_WIDTH));
1406a606da0SAndre Fischer 
1416a606da0SAndre Fischer     maLayouter.GetCell(0,0).SetControl(*mpFtPosX);
1426a606da0SAndre Fischer     maLayouter.GetCell(1,0).SetControl(*mpMtrPosX);
1436a606da0SAndre Fischer 
1446a606da0SAndre Fischer     maLayouter.GetCell(0,2).SetControl(*mpFtPosY);
1456a606da0SAndre Fischer     maLayouter.GetCell(1,2).SetControl(*mpMtrPosY);
1466a606da0SAndre Fischer 
1476a606da0SAndre Fischer     maLayouter.GetCell(2,0).SetControl(*mpFtWidth);
1486a606da0SAndre Fischer     maLayouter.GetCell(3,0).SetControl(*mpMtrWidth);
1496a606da0SAndre Fischer 
1506a606da0SAndre Fischer     maLayouter.GetCell(2,2).SetControl(*mpFtHeight);
1516a606da0SAndre Fischer     maLayouter.GetCell(3,2).SetControl(*mpMtrHeight);
1526a606da0SAndre Fischer 
1536a606da0SAndre Fischer     maLayouter.GetCell(4,0).SetControl(*mpCbxScale).SetGridWidth(3);
1546a606da0SAndre Fischer     maLayouter.GetCell(5,0).SetControl(*mpFtAngle).SetGridWidth(3);
1556a606da0SAndre Fischer 
1566a606da0SAndre Fischer 
1576a606da0SAndre Fischer     maLayouter.GetColumn(0)
1586a606da0SAndre Fischer         .SetWeight(1)
1596a606da0SAndre Fischer         .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
1606a606da0SAndre Fischer         .SetMinimumWidth(nMappedMboxWidth);
1616a606da0SAndre Fischer     maLayouter.GetColumn(1)
1626a606da0SAndre Fischer         .SetWeight(0)
1636a606da0SAndre Fischer         .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
1646a606da0SAndre Fischer     maLayouter.GetColumn(2)
1656a606da0SAndre Fischer         .SetWeight(1)
1666a606da0SAndre Fischer         .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
1676a606da0SAndre Fischer         .SetMinimumWidth(nMappedMboxWidth);
1686a606da0SAndre Fischer 
1696a606da0SAndre Fischer     // Make controls that display text handle short widths more
1706a606da0SAndre Fischer     // graceful.
1716a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtPosX);
1726a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtPosY);
1736a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtWidth);
1746a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtHeight);
1756a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpCbxScale);
1766a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtAngle);
1776a606da0SAndre Fischer 
1785d39f272SZheng Fan }
1795d39f272SZheng Fan 
1805d39f272SZheng Fan 
1815d39f272SZheng Fan 
~PosSizePropertyPanel()1825d39f272SZheng Fan PosSizePropertyPanel::~PosSizePropertyPanel()
1835d39f272SZheng Fan {
1845d39f272SZheng Fan     // Destroy the background windows of the toolboxes.
1855d39f272SZheng Fan     mpFlipTbx.reset();
1865d39f272SZheng Fan     mpFlipTbxBackground.reset();
1875d39f272SZheng Fan }
1885d39f272SZheng Fan 
1895d39f272SZheng Fan 
1905d39f272SZheng Fan 
ShowMenu(void)1915d39f272SZheng Fan void PosSizePropertyPanel::ShowMenu (void)
1925d39f272SZheng Fan {
1935d39f272SZheng Fan     if (mpBindings != NULL)
1945d39f272SZheng Fan     {
1955d39f272SZheng Fan         SfxDispatcher* pDispatcher = mpBindings->GetDispatcher();
1965d39f272SZheng Fan         if (pDispatcher != NULL)
1975d39f272SZheng Fan             pDispatcher->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_ASYNCHRON);
1985d39f272SZheng Fan     }
1995d39f272SZheng Fan }
2005d39f272SZheng Fan 
2015d39f272SZheng Fan 
2025d39f272SZheng Fan 
203eefa0d2bSArmin Le Grand namespace
204eefa0d2bSArmin Le Grand {
hasText(const SdrView & rSdrView)205eefa0d2bSArmin Le Grand     bool hasText(const SdrView& rSdrView)
206eefa0d2bSArmin Le Grand     {
207eefa0d2bSArmin Le Grand         const SdrMarkList& rMarkList = rSdrView.GetMarkedObjectList();
208eefa0d2bSArmin Le Grand 
209eefa0d2bSArmin Le Grand         if(1 == rMarkList.GetMarkCount())
210eefa0d2bSArmin Le Grand         {
211eefa0d2bSArmin Le Grand             const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
212eefa0d2bSArmin Le Grand             const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
213eefa0d2bSArmin Le Grand 
214eefa0d2bSArmin Le Grand             if((pObj->GetObjInventor() == SdrInventor) && (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind))
215eefa0d2bSArmin Le Grand             {
216eefa0d2bSArmin Le Grand                 const SdrTextObj* pSdrTextObj = dynamic_cast< const SdrTextObj* >(pObj);
217eefa0d2bSArmin Le Grand 
218eefa0d2bSArmin Le Grand                 if(pSdrTextObj && pSdrTextObj->HasText())
219eefa0d2bSArmin Le Grand                 {
220eefa0d2bSArmin Le Grand                     return true;
221eefa0d2bSArmin Le Grand                 }
222eefa0d2bSArmin Le Grand             }
223eefa0d2bSArmin Le Grand         }
224eefa0d2bSArmin Le Grand 
225eefa0d2bSArmin Le Grand         return false;
226eefa0d2bSArmin Le Grand     }
227eefa0d2bSArmin Le Grand } // end of anonymous namespace
228eefa0d2bSArmin Le Grand 
229eefa0d2bSArmin Le Grand 
230eefa0d2bSArmin Le Grand 
2316a606da0SAndre Fischer 
Resize(void)2326a606da0SAndre Fischer void PosSizePropertyPanel::Resize (void)
2336a606da0SAndre Fischer {
2346a606da0SAndre Fischer     maLayouter.Layout();
2356a606da0SAndre Fischer }
2366a606da0SAndre Fischer 
2376a606da0SAndre Fischer 
2386a606da0SAndre Fischer 
2396a606da0SAndre Fischer 
Initialize()2405d39f272SZheng Fan void PosSizePropertyPanel::Initialize()
2415d39f272SZheng Fan {
24237fee4fdSAndre Fischer     mpFtPosX->SetBackground(Wallpaper());
24337fee4fdSAndre Fischer     mpFtPosY->SetBackground(Wallpaper());
24437fee4fdSAndre Fischer     mpFtWidth->SetBackground(Wallpaper());
24537fee4fdSAndre Fischer     mpFtHeight->SetBackground(Wallpaper());
24637fee4fdSAndre Fischer     mpFtAngle->SetBackground(Wallpaper());
24737fee4fdSAndre Fischer     mpFtFlip->SetBackground(Wallpaper());
24837fee4fdSAndre Fischer 
2495d39f272SZheng Fan         //Position : Horizontal / Vertical
2505d39f272SZheng Fan     mpMtrPosX->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosXHdl ) );
2515d39f272SZheng Fan     mpMtrPosY->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosYHdl ) );
2525d39f272SZheng Fan     mpMtrPosX->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Horizontal")));	//wj acc
2535d39f272SZheng Fan     mpMtrPosY->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Vertical")));		//wj acc
2545d39f272SZheng Fan 
2555d39f272SZheng Fan     //Size : Width / Height
2565d39f272SZheng Fan     mpMtrWidth->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeWidthHdl ) );
2575d39f272SZheng Fan     mpMtrHeight->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeHeightHdl ) );
2585d39f272SZheng Fan     mpMtrWidth->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width")));	//wj acc
2595d39f272SZheng Fan     mpMtrHeight->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height")));	//wj acc
2605d39f272SZheng Fan 
2615d39f272SZheng Fan     //Size : Keep ratio
2625d39f272SZheng Fan     mpCbxScale->SetClickHdl( LINK( this, PosSizePropertyPanel, ClickAutoHdl ) );
2635d39f272SZheng Fan 
2645d39f272SZheng Fan     //rotation:
2655d39f272SZheng Fan     mpMtrAngle->SetModifyHdl(LINK( this, PosSizePropertyPanel, AngleModifiedHdl));
2665d39f272SZheng Fan     mpMtrAngle->EnableAutocomplete( false );
2675d39f272SZheng Fan     mpMtrAngle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Rotation")));	//wj acc
2685d39f272SZheng Fan 
2695d39f272SZheng Fan     //rotation control
2705d39f272SZheng Fan     mpDial->SetModifyHdl(LINK( this, PosSizePropertyPanel, RotationHdl));
2715d39f272SZheng Fan 
2725d39f272SZheng Fan     //flip:
2735d39f272SZheng Fan     mpFlipTbx->SetSelectHdl( LINK( this, PosSizePropertyPanel, FlipHdl) );
274aed5c350SAndre Fischer     mpFlipTbx->SetItemImage(
275aed5c350SAndre Fischer         FLIP_HORIZONTAL,
276aed5c350SAndre Fischer         GetImage(mxFrame, A2S(".uno:FlipHorizontal"), sal_False, Theme::IsHighContrastMode()));
277aed5c350SAndre Fischer     mpFlipTbx->SetItemImage(
278aed5c350SAndre Fischer         FLIP_VERTICAL,
279aed5c350SAndre Fischer         GetImage(mxFrame, A2S(".uno:FlipVertical"), sal_False, Theme::IsHighContrastMode()));
2805d39f272SZheng Fan     mpFlipTbx->SetQuickHelpText(FLIP_HORIZONTAL,String(SVX_RES(STR_QH_HORI_FLIP))); //Add
2815d39f272SZheng Fan     mpFlipTbx->SetQuickHelpText(FLIP_VERTICAL,String(SVX_RES(STR_QH_VERT_FLIP))); //Add
2825d39f272SZheng Fan 
2835d39f272SZheng Fan     mpMtrPosX->SetAccessibleRelationLabeledBy(mpFtPosX.get());
2845d39f272SZheng Fan     mpMtrPosY->SetAccessibleRelationLabeledBy(mpFtPosY.get());
2855d39f272SZheng Fan     mpMtrWidth->SetAccessibleRelationLabeledBy(mpFtWidth.get());
2865d39f272SZheng Fan     mpMtrHeight->SetAccessibleRelationLabeledBy(mpFtHeight.get());
2875d39f272SZheng Fan     mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtAngle.get());
288facb16e7SArmin Le Grand #ifdef HAS_IA2
289facb16e7SArmin Le Grand     mpMtrAngle->SetMpSubEditAccLableBy(mpFtAngle.get());
290facb16e7SArmin Le Grand #endif
2915d39f272SZheng Fan     mpFlipTbx->SetAccessibleRelationLabeledBy(mpFtFlip.get());
2925d39f272SZheng Fan 
2935d39f272SZheng Fan     mpMtrAngle->InsertValue(0, FUNIT_CUSTOM);
2945d39f272SZheng Fan     mpMtrAngle->InsertValue(4500, FUNIT_CUSTOM);
2955d39f272SZheng Fan     mpMtrAngle->InsertValue(9000, FUNIT_CUSTOM);
2965d39f272SZheng Fan     mpMtrAngle->InsertValue(13500, FUNIT_CUSTOM);
2975d39f272SZheng Fan     mpMtrAngle->InsertValue(18000, FUNIT_CUSTOM);
2985d39f272SZheng Fan     mpMtrAngle->InsertValue(22500, FUNIT_CUSTOM);
2995d39f272SZheng Fan     mpMtrAngle->InsertValue(27000, FUNIT_CUSTOM);
3005d39f272SZheng Fan     mpMtrAngle->InsertValue(31500, FUNIT_CUSTOM);
301a68b38dfSArmin Le Grand     mpMtrAngle->AdaptDropDownLineCountToMaximum();
3025d39f272SZheng Fan 
3035d39f272SZheng Fan     SfxViewShell* pCurSh = SfxViewShell::Current();
3045d39f272SZheng Fan     if ( pCurSh )
3055d39f272SZheng Fan         mpView = pCurSh->GetDrawView();
3065d39f272SZheng Fan     else
3075d39f272SZheng Fan         mpView = NULL;
3085d39f272SZheng Fan 
3095d39f272SZheng Fan     if ( mpView != NULL )
3105d39f272SZheng Fan     {
3115d39f272SZheng Fan         maUIScale = mpView->GetModel()->GetUIScale();
312eefa0d2bSArmin Le Grand         mbAdjustEnabled = hasText(*mpView);
3135d39f272SZheng Fan     }
3145d39f272SZheng Fan 
3155d39f272SZheng Fan     mePoolUnit = maTransfWidthControl.GetCoreMetric();
3165d39f272SZheng Fan     meDlgUnit = GetModuleFieldUnit();
3175d39f272SZheng Fan     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
3185d39f272SZheng Fan     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
3195d39f272SZheng Fan     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
3205d39f272SZheng Fan     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
3215d39f272SZheng Fan }
3225d39f272SZheng Fan 
3235d39f272SZheng Fan 
3245d39f272SZheng Fan 
SetupIcons(void)3255d39f272SZheng Fan void PosSizePropertyPanel::SetupIcons(void)
3265d39f272SZheng Fan {
3275d39f272SZheng Fan     if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
3285d39f272SZheng Fan     {
3295d39f272SZheng Fan         // todo
3305d39f272SZheng Fan     }
3315d39f272SZheng Fan     else
3325d39f272SZheng Fan     {
3335d39f272SZheng Fan         // todo
3345d39f272SZheng Fan     }
3355d39f272SZheng Fan }
3365d39f272SZheng Fan 
3375d39f272SZheng Fan 
3385d39f272SZheng Fan 
Create(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings,const cssu::Reference<css::ui::XSidebar> & rxSidebar)3395d39f272SZheng Fan PosSizePropertyPanel* PosSizePropertyPanel::Create (
3405d39f272SZheng Fan     Window* pParent,
3415d39f272SZheng Fan     const cssu::Reference<css::frame::XFrame>& rxFrame,
34237fee4fdSAndre Fischer     SfxBindings* pBindings,
34337fee4fdSAndre Fischer     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
3445d39f272SZheng Fan {
3455d39f272SZheng Fan     if (pParent == NULL)
3465d39f272SZheng Fan         throw lang::IllegalArgumentException(A2S("no parent Window given to PosSizePropertyPanel::Create"), NULL, 0);
3475d39f272SZheng Fan     if ( ! rxFrame.is())
3485d39f272SZheng Fan         throw lang::IllegalArgumentException(A2S("no XFrame given to PosSizePropertyPanel::Create"), NULL, 1);
3495d39f272SZheng Fan     if (pBindings == NULL)
3505d39f272SZheng Fan         throw lang::IllegalArgumentException(A2S("no SfxBindings given to PosSizePropertyPanel::Create"), NULL, 2);
3515d39f272SZheng Fan 
3525d39f272SZheng Fan     return new PosSizePropertyPanel(
3535d39f272SZheng Fan         pParent,
3545d39f272SZheng Fan         rxFrame,
35537fee4fdSAndre Fischer         pBindings,
35637fee4fdSAndre Fischer         rxSidebar);
3575d39f272SZheng Fan }
3585d39f272SZheng Fan 
3595d39f272SZheng Fan 
3605d39f272SZheng Fan 
DataChanged(const DataChangedEvent & rEvent)3615d39f272SZheng Fan void PosSizePropertyPanel::DataChanged(
3625d39f272SZheng Fan     const DataChangedEvent& rEvent)
3635d39f272SZheng Fan {
3645d39f272SZheng Fan     (void)rEvent;
3655d39f272SZheng Fan 
3665d39f272SZheng Fan     SetupIcons();
3675d39f272SZheng Fan }
3685d39f272SZheng Fan 
3695d39f272SZheng Fan 
3705d39f272SZheng Fan 
AdaptWidthHeightScalePosition(bool bOriginal)371d74d90d6SArmin Le Grand void PosSizePropertyPanel::AdaptWidthHeightScalePosition(bool bOriginal)
372d74d90d6SArmin Le Grand {
373d74d90d6SArmin Le Grand     if(bOriginal)
374d74d90d6SArmin Le Grand     {
375d74d90d6SArmin Le Grand         mpFtWidth->SetPosPixel(maFtWidthOrigPos);
376d74d90d6SArmin Le Grand         mpMtrWidth->SetPosPixel(maMtrWidthOrigPos);
377d74d90d6SArmin Le Grand         mpFtHeight->SetPosPixel(maFtHeightOrigPos);
378d74d90d6SArmin Le Grand         mpMtrHeight->SetPosPixel(maMtrHeightOrigPos);
379d74d90d6SArmin Le Grand         mpCbxScale->SetPosPixel(maCbxScaleOrigPos);
380d74d90d6SArmin Le Grand     }
381d74d90d6SArmin Le Grand     else
382d74d90d6SArmin Le Grand     {
383d74d90d6SArmin Le Grand         mpFtWidth->SetPosPixel(Point(LogicToPixel(Point(FT_POSITION_X_X,FT_POSITION_X_Y), MAP_APPFONT)));
384d74d90d6SArmin Le Grand         mpMtrWidth->SetPosPixel(Point(LogicToPixel(Point(MF_POSITION_X_X,MF_POSITION_X_Y), MAP_APPFONT)));
385d74d90d6SArmin Le Grand         mpFtHeight->SetPosPixel(Point(LogicToPixel(Point(FT_POSITION_Y_X,FT_POSITION_Y_Y), MAP_APPFONT)));
386d74d90d6SArmin Le Grand         mpMtrHeight->SetPosPixel(Point(LogicToPixel(Point(MF_POSITION_Y_X,MF_POSITION_Y_Y), MAP_APPFONT)));
387d74d90d6SArmin Le Grand         mpCbxScale->SetPosPixel(Point(LogicToPixel(Point(FT_WIDTH_X,FT_WIDTH_Y), MAP_APPFONT)));
388d74d90d6SArmin Le Grand     }
389d74d90d6SArmin Le Grand }
390d74d90d6SArmin Le Grand 
AdaptAngleFlipDialPosition(bool bOriginal)391d74d90d6SArmin Le Grand void PosSizePropertyPanel::AdaptAngleFlipDialPosition(bool bOriginal)
392d74d90d6SArmin Le Grand {
393d74d90d6SArmin Le Grand     if(bOriginal)
394d74d90d6SArmin Le Grand     {
395d74d90d6SArmin Le Grand         mpFtAngle->SetPosPixel(maFtAngleOrigPos);
396d74d90d6SArmin Le Grand         mpMtrAngle->SetPosPixel(maMtrAnglOrigPos);
397d74d90d6SArmin Le Grand         mpFlipTbx->SetPosPixel(maFlipTbxOrigPos);
398d74d90d6SArmin Le Grand         mpDial->SetPosPixel(maDialOrigPos);
399d74d90d6SArmin Le Grand         mpFtFlip->SetPosPixel(maFtFlipOrigPos);
400d74d90d6SArmin Le Grand     }
401d74d90d6SArmin Le Grand     else
402d74d90d6SArmin Le Grand     {
403d74d90d6SArmin Le Grand         mpFtAngle->SetPosPixel(Point(LogicToPixel(Point(FT_ANGLE_X,FT_ANGLE_Y), MAP_APPFONT)));
404d74d90d6SArmin Le Grand         mpMtrAngle->SetPosPixel(Point(LogicToPixel(Point(MF_ANGLE_X2,MF_ANGLE_Y2), MAP_APPFONT)));
405d74d90d6SArmin Le Grand         mpFlipTbx->SetPosPixel(Point(LogicToPixel(Point(FLIP_HORI_X2,FLIP_HORI_Y2), MAP_APPFONT)));
406d74d90d6SArmin Le Grand         mpDial->SetPosPixel(Point(LogicToPixel(Point(ROTATE_CONTROL_X2,ROTATE_CONTROL_Y2), MAP_APPFONT)));
407d74d90d6SArmin Le Grand         mpFtFlip->SetPosPixel(Point(LogicToPixel(Point(FT_FLIP_X2,FT_FLIP_Y2), MAP_APPFONT)));
408d74d90d6SArmin Le Grand     }
409d74d90d6SArmin Le Grand }
410d74d90d6SArmin Le Grand 
HandleContextChange(const::sfx2::sidebar::EnumContext aContext)4115d39f272SZheng Fan void PosSizePropertyPanel::HandleContextChange(
4125d39f272SZheng Fan     const ::sfx2::sidebar::EnumContext aContext)
4135d39f272SZheng Fan {
4145d39f272SZheng Fan     if(maContext == aContext)
4155d39f272SZheng Fan     {
4165d39f272SZheng Fan         // Nothing to do.
4175d39f272SZheng Fan         return;
4185d39f272SZheng Fan     }
4195d39f272SZheng Fan 
4205d39f272SZheng Fan     maContext = aContext;
4215d39f272SZheng Fan 
4225d39f272SZheng Fan     sal_Int32 nLayoutMode (0);
4235d39f272SZheng Fan     switch (maContext.GetCombinedContext_DI())
4245d39f272SZheng Fan     {
42585f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Draw):
4265d39f272SZheng Fan             nLayoutMode = 0;
4275d39f272SZheng Fan             break;
4285d39f272SZheng Fan 
42985f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Graphic):
43085f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Media):
43185f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Frame):
43285f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_OLE):
43385f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Form):
4345d39f272SZheng Fan             nLayoutMode = 1;
4355d39f272SZheng Fan             break;
4365d39f272SZheng Fan 
4375d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_Draw):
4385d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_Graphic):
4395d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
4405d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
4415d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
4425d39f272SZheng Fan             nLayoutMode = 2;
4435d39f272SZheng Fan             break;
4445d39f272SZheng Fan 
4455d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_Chart):
4465d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_Form):
4475d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_Media):
4485d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_OLE):
4495d39f272SZheng Fan         case CombinedEnumContext(Application_Calc, Context_MultiObject):
4505d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_Media):
4515d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_Form):
4525d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_OLE):
4535d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_3DObject):
4545d39f272SZheng Fan         case CombinedEnumContext(Application_DrawImpress, Context_MultiObject):
4555d39f272SZheng Fan             nLayoutMode = 3;
4565d39f272SZheng Fan             break;
4575d39f272SZheng Fan     }
458d74d90d6SArmin Le Grand 
4595d39f272SZheng Fan     switch (nLayoutMode)
4605d39f272SZheng Fan     {
4615d39f272SZheng Fan         case 0:
4625d39f272SZheng Fan         {
4635d39f272SZheng Fan             mpMtrWidth->SetMin( 2 );
4645d39f272SZheng Fan             mpMtrHeight->SetMin( 2 );
4655d39f272SZheng Fan             mpFtPosX->Hide();
4665d39f272SZheng Fan             mpMtrPosX->Hide();
4675d39f272SZheng Fan             mpFtPosY->Hide();
4685d39f272SZheng Fan             mpMtrPosY->Hide();
4695d39f272SZheng Fan 
4705d39f272SZheng Fan             //rotation
4715d39f272SZheng Fan             mpFtAngle->Show();
4725d39f272SZheng Fan             mpMtrAngle->Show();
4735d39f272SZheng Fan             mpDial->Show();
4745d39f272SZheng Fan 
4755d39f272SZheng Fan             //flip
4765d39f272SZheng Fan             mpFtFlip->Show();
4775d39f272SZheng Fan             mpFlipTbx->Show();
4785d39f272SZheng Fan             Size aTbxSize = mpFlipTbx->CalcWindowSizePixel();
4795d39f272SZheng Fan             mpFlipTbx->SetOutputSizePixel( aTbxSize );
4805d39f272SZheng Fan             mbIsFlip = true;
4815d39f272SZheng Fan 
482d74d90d6SArmin Le Grand             AdaptWidthHeightScalePosition(false);
483d74d90d6SArmin Le Grand             AdaptAngleFlipDialPosition(false);
4845d39f272SZheng Fan 
4855d39f272SZheng Fan             mpFtAngle->SetPosPixel(Point(LogicToPixel(Point(FT_ANGLE_X,FT_ANGLE_Y), MAP_APPFONT)));
4865d39f272SZheng Fan             mpMtrAngle->SetPosPixel(Point(LogicToPixel(Point(MF_ANGLE_X2,MF_ANGLE_Y2), MAP_APPFONT)));
4875d39f272SZheng Fan             mpFlipTbx->SetPosPixel(Point(LogicToPixel(Point(FLIP_HORI_X2,FLIP_HORI_Y2), MAP_APPFONT)));
4885d39f272SZheng Fan             mpDial->SetPosPixel(Point(LogicToPixel(Point(ROTATE_CONTROL_X2,ROTATE_CONTROL_Y2), MAP_APPFONT)));
4895d39f272SZheng Fan             mpFtFlip->SetPosPixel(Point(LogicToPixel(Point(FT_FLIP_X2,FT_FLIP_Y2), MAP_APPFONT)));
4905d39f272SZheng Fan 
4915d39f272SZheng Fan             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT2);
4925d39f272SZheng Fan             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
4935d39f272SZheng Fan             SetSizePixel(aSize);
49437fee4fdSAndre Fischer             if (mxSidebar.is())
49537fee4fdSAndre Fischer                 mxSidebar->requestLayout();
4965d39f272SZheng Fan         }
4975d39f272SZheng Fan         break;
4985d39f272SZheng Fan 
4995d39f272SZheng Fan         case 1:
5005d39f272SZheng Fan         {
5015d39f272SZheng Fan             mpMtrWidth->SetMin( 2 );
5025d39f272SZheng Fan             mpMtrHeight->SetMin( 2 );
5035d39f272SZheng Fan             mpFtPosX->Hide();
5045d39f272SZheng Fan             mpMtrPosX->Hide();
5055d39f272SZheng Fan             mpFtPosY->Hide();
5065d39f272SZheng Fan             mpMtrPosY->Hide();
5075d39f272SZheng Fan 
5085d39f272SZheng Fan             //rotation
5095d39f272SZheng Fan             mpFtAngle->Hide();
5105d39f272SZheng Fan             mpMtrAngle->Hide();
5115d39f272SZheng Fan             mpDial->Hide();
5125d39f272SZheng Fan 
5135d39f272SZheng Fan             //flip
5145d39f272SZheng Fan             mpFlipTbx->Hide();
5155d39f272SZheng Fan             mpFtFlip->Hide();
5165d39f272SZheng Fan             mbIsFlip = false;
5175d39f272SZheng Fan 
518d74d90d6SArmin Le Grand             AdaptWidthHeightScalePosition(false);
519d74d90d6SArmin Le Grand             AdaptAngleFlipDialPosition(true);
5205d39f272SZheng Fan 
5215d39f272SZheng Fan             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT3);
5225d39f272SZheng Fan             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5235d39f272SZheng Fan             SetSizePixel(aSize);
52437fee4fdSAndre Fischer             if (mxSidebar.is())
52537fee4fdSAndre Fischer                 mxSidebar->requestLayout();
5265d39f272SZheng Fan         }
5275d39f272SZheng Fan         break;
5285d39f272SZheng Fan 
5295d39f272SZheng Fan         case 2:
5305d39f272SZheng Fan         {
5315d39f272SZheng Fan             mpMtrWidth->SetMin( 1 );
5325d39f272SZheng Fan             mpMtrHeight->SetMin( 1 );
5335d39f272SZheng Fan             mpFtPosX->Show();
5345d39f272SZheng Fan             mpMtrPosX->Show();
5355d39f272SZheng Fan             mpFtPosY->Show();
5365d39f272SZheng Fan             mpMtrPosY->Show();
5375d39f272SZheng Fan 
5385d39f272SZheng Fan             //rotation
5395d39f272SZheng Fan             mpFtAngle->Show();
5405d39f272SZheng Fan             mpMtrAngle->Show();
5415d39f272SZheng Fan             mpDial->Show();
5425d39f272SZheng Fan 
5435d39f272SZheng Fan             //flip
5445d39f272SZheng Fan             mpFlipTbx->Show();
5455d39f272SZheng Fan             mpFtFlip->Show();
5465d39f272SZheng Fan             Size aTbxSize = mpFlipTbx->CalcWindowSizePixel();
5475d39f272SZheng Fan             mpFlipTbx->SetOutputSizePixel( aTbxSize );
5485d39f272SZheng Fan             mbIsFlip = true;
5495d39f272SZheng Fan 
550d74d90d6SArmin Le Grand             AdaptWidthHeightScalePosition(true);
551d74d90d6SArmin Le Grand             AdaptAngleFlipDialPosition(true);
552d74d90d6SArmin Le Grand 
5535d39f272SZheng Fan             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT);
5545d39f272SZheng Fan             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5555d39f272SZheng Fan             SetSizePixel(aSize);
55637fee4fdSAndre Fischer             if (mxSidebar.is())
55737fee4fdSAndre Fischer                 mxSidebar->requestLayout();
5585d39f272SZheng Fan         }
5595d39f272SZheng Fan         break;
5605d39f272SZheng Fan 
5615d39f272SZheng Fan         case 3:
5625d39f272SZheng Fan         {
5635d39f272SZheng Fan             mpMtrWidth->SetMin( 1 );
5645d39f272SZheng Fan             mpMtrHeight->SetMin( 1 );
5655d39f272SZheng Fan             mpFtPosX->Show();
5665d39f272SZheng Fan             mpMtrPosX->Show();
5675d39f272SZheng Fan             mpFtPosY->Show();
5685d39f272SZheng Fan             mpMtrPosY->Show();
5695d39f272SZheng Fan 
5705d39f272SZheng Fan             //rotation
5715d39f272SZheng Fan             mpFtAngle->Hide();
5725d39f272SZheng Fan             mpMtrAngle->Hide();
5735d39f272SZheng Fan             mpDial->Hide();
5745d39f272SZheng Fan 
5755d39f272SZheng Fan             //flip
5765d39f272SZheng Fan             mpFlipTbx->Hide();
5775d39f272SZheng Fan             mpFtFlip->Hide();
5785d39f272SZheng Fan             mbIsFlip = false;
5795d39f272SZheng Fan 
580d74d90d6SArmin Le Grand             AdaptWidthHeightScalePosition(true);
581d74d90d6SArmin Le Grand             AdaptAngleFlipDialPosition(true);
582d74d90d6SArmin Le Grand 
5835d39f272SZheng Fan             Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT4);
5845d39f272SZheng Fan             aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5855d39f272SZheng Fan             SetSizePixel(aSize);
58637fee4fdSAndre Fischer             if (mxSidebar.is())
58737fee4fdSAndre Fischer                 mxSidebar->requestLayout();
5885d39f272SZheng Fan         }
5895d39f272SZheng Fan         break;
5905d39f272SZheng Fan     }
5915d39f272SZheng Fan 
5925d39f272SZheng Fan     //Added for windows classic theme
5935d39f272SZheng Fan     mpFlipTbx->SetBackground(Wallpaper());
5945d39f272SZheng Fan     mpFlipTbx->SetPaintTransparent(true);
5955d39f272SZheng Fan }
5965d39f272SZheng Fan 
5975d39f272SZheng Fan 
5985d39f272SZheng Fan 
5998a383445SArmin Le Grand IMPL_LINK( PosSizePropertyPanel, ChangeWidthHdl, void*, /*pBox*/ )
6005d39f272SZheng Fan {
6015d39f272SZheng Fan     if( mpCbxScale->IsChecked() &&
6025d39f272SZheng Fan         mpCbxScale->IsEnabled() )
6035d39f272SZheng Fan     {
6045d39f272SZheng Fan         long nHeight = (long) ( ((double) mlOldHeight * (double) mpMtrWidth->GetValue()) / (double) mlOldWidth );
6055d39f272SZheng Fan         if( nHeight <= mpMtrHeight->GetMax( FUNIT_NONE ) )
6065d39f272SZheng Fan         {
6075d39f272SZheng Fan             mpMtrHeight->SetUserValue( nHeight, FUNIT_NONE );
6085d39f272SZheng Fan         }
6095d39f272SZheng Fan         else
6105d39f272SZheng Fan         {
6115d39f272SZheng Fan             nHeight = (long)mpMtrHeight->GetMax( FUNIT_NONE );
6125d39f272SZheng Fan             mpMtrHeight->SetUserValue( nHeight );
6135d39f272SZheng Fan             const long nWidth = (long) ( ((double) mlOldWidth * (double) nHeight) / (double) mlOldHeight );
6145d39f272SZheng Fan             mpMtrWidth->SetUserValue( nWidth, FUNIT_NONE );
6155d39f272SZheng Fan         }
6165d39f272SZheng Fan     }
6175d39f272SZheng Fan     executeSize();
6185d39f272SZheng Fan     return 0;
6195d39f272SZheng Fan }
6205d39f272SZheng Fan 
6215d39f272SZheng Fan 
6225d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,ChangeHeightHdl,void *,EMPTYARG)6235d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ChangeHeightHdl, void *, EMPTYARG )
6245d39f272SZheng Fan {
6255d39f272SZheng Fan     if( mpCbxScale->IsChecked() &&
6265d39f272SZheng Fan         mpCbxScale->IsEnabled() )
6275d39f272SZheng Fan     {
6285d39f272SZheng Fan         long nWidth = (long) ( ((double)mlOldWidth * (double)mpMtrHeight->GetValue()) / (double)mlOldHeight );
6295d39f272SZheng Fan         if( nWidth <= mpMtrWidth->GetMax( FUNIT_NONE ) )
6305d39f272SZheng Fan         {
6315d39f272SZheng Fan             mpMtrWidth->SetUserValue( nWidth, FUNIT_NONE );
6325d39f272SZheng Fan         }
6335d39f272SZheng Fan         else
6345d39f272SZheng Fan         {
6355d39f272SZheng Fan             nWidth = (long)mpMtrWidth->GetMax( FUNIT_NONE );
6365d39f272SZheng Fan             mpMtrWidth->SetUserValue( nWidth );
6375d39f272SZheng Fan             const long nHeight = (long) ( ((double)mlOldHeight * (double)nWidth) / (double)mlOldWidth );
6385d39f272SZheng Fan             mpMtrHeight->SetUserValue( nHeight, FUNIT_NONE );
6395d39f272SZheng Fan         }
6405d39f272SZheng Fan     }
6415d39f272SZheng Fan     executeSize();
6425d39f272SZheng Fan     return 0;
6435d39f272SZheng Fan }
6445d39f272SZheng Fan 
6455d39f272SZheng Fan 
6465d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,ChangePosXHdl,void *,EMPTYARG)6475d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ChangePosXHdl, void *, EMPTYARG )
6485d39f272SZheng Fan {
6495d39f272SZheng Fan     executePosX();
6505d39f272SZheng Fan     return 0;
6515d39f272SZheng Fan }
6525d39f272SZheng Fan 
6535d39f272SZheng Fan 
6545d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,ChangePosYHdl,void *,EMPTYARG)6555d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ChangePosYHdl, void *, EMPTYARG )
6565d39f272SZheng Fan {
6575d39f272SZheng Fan     executePosY();
6585d39f272SZheng Fan     return 0;
6595d39f272SZheng Fan }
6605d39f272SZheng Fan 
6615d39f272SZheng Fan 
6625d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,ClickAutoHdl,void *,EMPTYARG)6635d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ClickAutoHdl, void *, EMPTYARG )
6645d39f272SZheng Fan {
6655d39f272SZheng Fan     if ( mpCbxScale->IsChecked() )
6665d39f272SZheng Fan     {
6675d39f272SZheng Fan         mlOldWidth  = Max( GetCoreValue( *mpMtrWidth,  mePoolUnit ), 1L );
6685d39f272SZheng Fan         mlOldHeight = Max( GetCoreValue( *mpMtrHeight, mePoolUnit ), 1L );
6695d39f272SZheng Fan     }
6705d39f272SZheng Fan 
6715d39f272SZheng Fan     // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
6725d39f272SZheng Fan     SvtViewOptions	aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
6735d39f272SZheng Fan     aPageOpt.SetUserItem( USERITEM_NAME, ::com::sun::star::uno::makeAny( ::rtl::OUString( String::CreateFromInt32( mpCbxScale->IsChecked() ) ) ) );
6745d39f272SZheng Fan 
6755d39f272SZheng Fan     return 0;
6765d39f272SZheng Fan }
6775d39f272SZheng Fan 
6785d39f272SZheng Fan 
6795d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,AngleModifiedHdl,void *,EMPTYARG)6805d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
6815d39f272SZheng Fan {
6825d39f272SZheng Fan     String sTmp = mpMtrAngle->GetText();
6835d39f272SZheng Fan     bool    bNegative = 0;
6845d39f272SZheng Fan     sal_Unicode nChar = sTmp.GetChar( 0 );
6855d39f272SZheng Fan 
6865d39f272SZheng Fan     if( nChar == '-' )
6875d39f272SZheng Fan     {
6885d39f272SZheng Fan         bNegative = 1;
6895d39f272SZheng Fan         nChar = sTmp.GetChar( 1 );
6905d39f272SZheng Fan     }
6915d39f272SZheng Fan 
6925d39f272SZheng Fan     if( (nChar < '0') || (nChar > '9') )
6935d39f272SZheng Fan         return 0;
6945d39f272SZheng Fan     double dTmp = sTmp.ToDouble();
6955d39f272SZheng Fan     if(bNegative)
6965d39f272SZheng Fan     {
6975d39f272SZheng Fan         while(dTmp<0)
6985d39f272SZheng Fan             dTmp += 360;
6995d39f272SZheng Fan     }
7005d39f272SZheng Fan     sal_Int64 nTmp = dTmp*100;
7015d39f272SZheng Fan 
702a2565cdfSArmin Le Grand     // #123993# Need to take UIScale into account when executing rotations
703a2565cdfSArmin Le Grand     const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0);
7045d39f272SZheng Fan     SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp);
705a2565cdfSArmin Le Grand     SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * fUIScale));
706a2565cdfSArmin Le Grand     SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * fUIScale));
7075d39f272SZheng Fan 
7085d39f272SZheng Fan     GetBindings()->GetDispatcher()->Execute(
7095d39f272SZheng Fan         SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aAngleItem, &aRotXItem, &aRotYItem, 0L );
7105d39f272SZheng Fan 
7115d39f272SZheng Fan     return 0;
7125d39f272SZheng Fan }
7135d39f272SZheng Fan 
7145d39f272SZheng Fan 
7155d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,RotationHdl,void *,EMPTYARG)7165d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, RotationHdl, void *, EMPTYARG )
7175d39f272SZheng Fan {
7185d39f272SZheng Fan     sal_Int32 nTmp = mpDial->GetRotation();
7195d39f272SZheng Fan 
720a2565cdfSArmin Le Grand     // #123993# Need to take UIScale into account when executing rotations
721a2565cdfSArmin Le Grand     const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0);
7225d39f272SZheng Fan     SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp);
723a2565cdfSArmin Le Grand     SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * fUIScale));
724a2565cdfSArmin Le Grand     SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * fUIScale));
7255d39f272SZheng Fan 
7265d39f272SZheng Fan     GetBindings()->GetDispatcher()->Execute(
7275d39f272SZheng Fan         SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aAngleItem, &aRotXItem, &aRotYItem, 0L );
7285d39f272SZheng Fan 
7295d39f272SZheng Fan     return 0;
7305d39f272SZheng Fan }
7315d39f272SZheng Fan 
7325d39f272SZheng Fan 
7335d39f272SZheng Fan 
IMPL_LINK(PosSizePropertyPanel,FlipHdl,ToolBox *,pBox)7345d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, FlipHdl, ToolBox*, pBox )
7355d39f272SZheng Fan {
7365d39f272SZheng Fan     switch (pBox->GetCurItemId())
7375d39f272SZheng Fan     {
7385d39f272SZheng Fan         case FLIP_HORIZONTAL:
7395d39f272SZheng Fan         {
7405d39f272SZheng Fan             SfxVoidItem aHoriItem (SID_FLIP_HORIZONTAL);
7415d39f272SZheng Fan             GetBindings()->GetDispatcher()->Execute(
7425d39f272SZheng Fan                 SID_FLIP_HORIZONTAL, SFX_CALLMODE_RECORD, &aHoriItem, 0L );
7435d39f272SZheng Fan         }
7445d39f272SZheng Fan         break;
7455d39f272SZheng Fan         case FLIP_VERTICAL:
7465d39f272SZheng Fan         {
7475d39f272SZheng Fan             SfxVoidItem aVertItem (SID_FLIP_VERTICAL );
7485d39f272SZheng Fan             GetBindings()->GetDispatcher()->Execute(
7495d39f272SZheng Fan                 SID_FLIP_VERTICAL, SFX_CALLMODE_RECORD, &aVertItem, 0L );
7505d39f272SZheng Fan         }
7515d39f272SZheng Fan         break;
7525d39f272SZheng Fan     }
7535d39f272SZheng Fan     return 0;
7545d39f272SZheng Fan }
7555d39f272SZheng Fan 
7565d39f272SZheng Fan 
7575d39f272SZheng Fan 
NotifyItemUpdate(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState,const bool)7585d39f272SZheng Fan void PosSizePropertyPanel::NotifyItemUpdate(
7595d39f272SZheng Fan     sal_uInt16 nSID,
7605d39f272SZheng Fan     SfxItemState eState,
76145da7d5eSAndre Fischer     const SfxPoolItem* pState,
76206ccb52fSPavel Janík     const bool /* bIsEnabled */)
7635d39f272SZheng Fan {
7645d39f272SZheng Fan     mpFtAngle->Enable();
7655d39f272SZheng Fan     mpMtrAngle->Enable();
7665d39f272SZheng Fan     mpDial->Enable();
7675d39f272SZheng Fan     mpFtFlip->Enable();
7685d39f272SZheng Fan     mpFlipTbx->Enable();
7695d39f272SZheng Fan 
7705d39f272SZheng Fan     const SfxUInt32Item*	pWidthItem;
7715d39f272SZheng Fan     const SfxUInt32Item*	pHeightItem;
7725d39f272SZheng Fan 
7735d39f272SZheng Fan     SfxViewShell* pCurSh = SfxViewShell::Current();
7745d39f272SZheng Fan     if ( pCurSh )
7755d39f272SZheng Fan         mpView = pCurSh->GetDrawView();
7765d39f272SZheng Fan     else
7775d39f272SZheng Fan         mpView = NULL;
7785d39f272SZheng Fan 
7795d39f272SZheng Fan     if ( mpView == NULL )
7805d39f272SZheng Fan         return;
7815d39f272SZheng Fan 
782eefa0d2bSArmin Le Grand     mbAdjustEnabled = hasText(*mpView);
7835d39f272SZheng Fan 
78490d0dc26SAndre Fischer     // Pool unit and dialog unit may have changed, make sure that we
78590d0dc26SAndre Fischer     // have the current values.
78690d0dc26SAndre Fischer     mePoolUnit = maTransfWidthControl.GetCoreMetric();
78790d0dc26SAndre Fischer     meDlgUnit = GetModuleFieldUnit();
78890d0dc26SAndre Fischer 
7895d39f272SZheng Fan     switch (nSID)
7905d39f272SZheng Fan     {
7915d39f272SZheng Fan         case SID_ATTR_TRANSFORM_WIDTH:
7925d39f272SZheng Fan             if ( SFX_ITEM_AVAILABLE == eState )
7935d39f272SZheng Fan             {
7945d39f272SZheng Fan                 pWidthItem = dynamic_cast< const SfxUInt32Item* >(pState);
7955d39f272SZheng Fan 
7965d39f272SZheng Fan                 if(pWidthItem)
7975d39f272SZheng Fan                 {
7985d39f272SZheng Fan                     long mlOldWidth1 = pWidthItem->GetValue();
7995d39f272SZheng Fan 
8005d39f272SZheng Fan                     mlOldWidth1 = Fraction( mlOldWidth1 ) / maUIScale;
80190d0dc26SAndre Fischer                     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
8025d39f272SZheng Fan                     SetMetricValue( *mpMtrWidth, mlOldWidth1, mePoolUnit );
8035d39f272SZheng Fan                     mlOldWidth = mlOldWidth1;
804da72173fSAndre Fischer                     break;
8055d39f272SZheng Fan                 }
8065d39f272SZheng Fan             }
807da72173fSAndre Fischer 
8085d39f272SZheng Fan             mpMtrWidth->SetText( String());
8095d39f272SZheng Fan             break;
8105d39f272SZheng Fan 
8115d39f272SZheng Fan         case SID_ATTR_TRANSFORM_HEIGHT:
8125d39f272SZheng Fan             if ( SFX_ITEM_AVAILABLE == eState )
8135d39f272SZheng Fan             {
8145d39f272SZheng Fan                 pHeightItem = dynamic_cast< const SfxUInt32Item* >(pState);
8155d39f272SZheng Fan 
8165d39f272SZheng Fan                 if(pHeightItem)
8175d39f272SZheng Fan                 {
8185d39f272SZheng Fan                     long mlOldHeight1 = pHeightItem->GetValue();
8195d39f272SZheng Fan 
8205d39f272SZheng Fan                     mlOldHeight1 = Fraction( mlOldHeight1 ) / maUIScale;
82190d0dc26SAndre Fischer                     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
8225d39f272SZheng Fan                     SetMetricValue( *mpMtrHeight, mlOldHeight1, mePoolUnit );
8235d39f272SZheng Fan                     mlOldHeight = mlOldHeight1;
824da72173fSAndre Fischer                     break;
8255d39f272SZheng Fan                 }
8265d39f272SZheng Fan             }
827da72173fSAndre Fischer 
8285d39f272SZheng Fan             mpMtrHeight->SetText( String());
8295d39f272SZheng Fan             break;
8305d39f272SZheng Fan 
8315d39f272SZheng Fan         case SID_ATTR_TRANSFORM_POS_X:
832da72173fSAndre Fischer             if(SFX_ITEM_AVAILABLE == eState)
8335d39f272SZheng Fan             {
8345d39f272SZheng Fan                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
8355d39f272SZheng Fan 
836da72173fSAndre Fischer                 if(pItem)
8375d39f272SZheng Fan                 {
8385d39f272SZheng Fan                     long nTmp = pItem->GetValue();
8395d39f272SZheng Fan                     nTmp = Fraction( nTmp ) / maUIScale;
84090d0dc26SAndre Fischer                     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
8415d39f272SZheng Fan                     SetMetricValue( *mpMtrPosX, nTmp, mePoolUnit );
8425d39f272SZheng Fan                     break;
8435d39f272SZheng Fan                 }
844da72173fSAndre Fischer             }
845da72173fSAndre Fischer 
846da72173fSAndre Fischer             mpMtrPosX->SetText( String());
847da72173fSAndre Fischer             break;
8485d39f272SZheng Fan 
8495d39f272SZheng Fan         case SID_ATTR_TRANSFORM_POS_Y:
850da72173fSAndre Fischer             if(SFX_ITEM_AVAILABLE == eState)
8515d39f272SZheng Fan             {
8525d39f272SZheng Fan                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
8535d39f272SZheng Fan 
854da72173fSAndre Fischer                 if(pItem)
8555d39f272SZheng Fan                 {
8565d39f272SZheng Fan                     long nTmp = pItem->GetValue();
8575d39f272SZheng Fan                     nTmp = Fraction( nTmp ) / maUIScale;
85890d0dc26SAndre Fischer                     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
8595d39f272SZheng Fan                     SetMetricValue( *mpMtrPosY, nTmp, mePoolUnit );
8605d39f272SZheng Fan                     break;
8615d39f272SZheng Fan                 }
862da72173fSAndre Fischer             }
863da72173fSAndre Fischer 
864da72173fSAndre Fischer             mpMtrPosY->SetText( String());
865da72173fSAndre Fischer             break;
8665d39f272SZheng Fan 
8675d39f272SZheng Fan         case SID_ATTR_TRANSFORM_ROT_X:
8685d39f272SZheng Fan             if (SFX_ITEM_AVAILABLE == eState)
8695d39f272SZheng Fan             {
870da72173fSAndre Fischer                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
871da72173fSAndre Fischer 
872da72173fSAndre Fischer                 if(pItem)
873da72173fSAndre Fischer                 {
874da72173fSAndre Fischer                     mlRotX = pItem->GetValue();
8755d39f272SZheng Fan                     mlRotX = Fraction( mlRotX ) / maUIScale;
8765d39f272SZheng Fan                 }
877da72173fSAndre Fischer             }
8785d39f272SZheng Fan             break;
8795d39f272SZheng Fan 
8805d39f272SZheng Fan         case SID_ATTR_TRANSFORM_ROT_Y:
8815d39f272SZheng Fan             if (SFX_ITEM_AVAILABLE == eState)
8825d39f272SZheng Fan             {
883da72173fSAndre Fischer                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
884da72173fSAndre Fischer 
885da72173fSAndre Fischer                 if(pItem)
886da72173fSAndre Fischer                 {
887da72173fSAndre Fischer                     mlRotY = pItem->GetValue();
8885d39f272SZheng Fan                     mlRotY = Fraction( mlRotY ) / maUIScale;
8895d39f272SZheng Fan                 }
890da72173fSAndre Fischer             }
8915d39f272SZheng Fan             break;
8925d39f272SZheng Fan 
8935d39f272SZheng Fan         case SID_ATTR_TRANSFORM_PROTECT_POS:
894da72173fSAndre Fischer             if(SFX_ITEM_AVAILABLE == eState)
8955d39f272SZheng Fan             {
8965d39f272SZheng Fan                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
8975d39f272SZheng Fan 
898da72173fSAndre Fischer                 if(pItem)
8995d39f272SZheng Fan                 {
9005d39f272SZheng Fan                     // record the state of position protect
9015d39f272SZheng Fan                     mbPositionProtected = pItem->GetValue();
9025d39f272SZheng Fan                     break;
9035d39f272SZheng Fan                 }
904da72173fSAndre Fischer             }
905da72173fSAndre Fischer 
906da72173fSAndre Fischer             mbPositionProtected = false;
907da72173fSAndre Fischer             break;
9085d39f272SZheng Fan 
9095d39f272SZheng Fan         case SID_ATTR_TRANSFORM_PROTECT_SIZE:
910da72173fSAndre Fischer             if(SFX_ITEM_AVAILABLE == eState)
9115d39f272SZheng Fan             {
9125d39f272SZheng Fan                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9135d39f272SZheng Fan 
914da72173fSAndre Fischer                 if(pItem)
9155d39f272SZheng Fan                 {
9165d39f272SZheng Fan                     // record the state of size protect
9175d39f272SZheng Fan                     mbSizeProtected = pItem->GetValue();
9185d39f272SZheng Fan                     break;
9195d39f272SZheng Fan                 }
920da72173fSAndre Fischer             }
921da72173fSAndre Fischer 
922da72173fSAndre Fischer             mbSizeProtected = false;
923da72173fSAndre Fischer             break;
9245d39f272SZheng Fan 
9255d39f272SZheng Fan         case SID_ATTR_TRANSFORM_AUTOWIDTH:
926da72173fSAndre Fischer             if(SFX_ITEM_AVAILABLE == eState)
9275d39f272SZheng Fan             {
9285d39f272SZheng Fan                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9295d39f272SZheng Fan 
930da72173fSAndre Fischer                 if(pItem)
9315d39f272SZheng Fan                 {
9325d39f272SZheng Fan                     mbAutoWidth = pItem->GetValue();
9335d39f272SZheng Fan                 }
9345d39f272SZheng Fan             }
935da72173fSAndre Fischer             break;
9365d39f272SZheng Fan 
9375d39f272SZheng Fan         case SID_ATTR_TRANSFORM_AUTOHEIGHT:
938da72173fSAndre Fischer             if(SFX_ITEM_AVAILABLE == eState)
9395d39f272SZheng Fan             {
9405d39f272SZheng Fan                 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9415d39f272SZheng Fan 
942da72173fSAndre Fischer                 if(pItem)
9435d39f272SZheng Fan                 {
9445d39f272SZheng Fan                     mbAutoHeight = pItem->GetValue();
9455d39f272SZheng Fan                 }
9465d39f272SZheng Fan             }
947da72173fSAndre Fischer             break;
9485d39f272SZheng Fan 
9495d39f272SZheng Fan         case SID_ATTR_TRANSFORM_ANGLE:
9505d39f272SZheng Fan             if (eState >= SFX_ITEM_AVAILABLE)
9515d39f272SZheng Fan             {
952da72173fSAndre Fischer                 const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
953da72173fSAndre Fischer 
954da72173fSAndre Fischer                 if(pItem)
955da72173fSAndre Fischer                 {
956da72173fSAndre Fischer                     long nTmp = pItem->GetValue();
957da72173fSAndre Fischer 
9585d39f272SZheng Fan                     mpMtrAngle->SetValue( nTmp );
9595d39f272SZheng Fan                     mpDial->SetRotation( nTmp );
960da72173fSAndre Fischer 
9615d39f272SZheng Fan                     switch(nTmp)
9625d39f272SZheng Fan                     {
9635d39f272SZheng Fan                         case 0:
9645d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(0);
9655d39f272SZheng Fan                             break;
9665d39f272SZheng Fan                         case 4500:
9675d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(1);
9685d39f272SZheng Fan                             break;
9695d39f272SZheng Fan                         case 9000:
9705d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(2);
9715d39f272SZheng Fan                             break;
9725d39f272SZheng Fan                         case 13500:
9735d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(3);
9745d39f272SZheng Fan                             break;
9755d39f272SZheng Fan                         case 18000:
9765d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(4);
9775d39f272SZheng Fan                             break;
9785d39f272SZheng Fan                         case 22500:
9795d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(5);
9805d39f272SZheng Fan                             break;
9815d39f272SZheng Fan                         case 27000:
9825d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(6);
9835d39f272SZheng Fan                             break;
9845d39f272SZheng Fan                         case 315000:
9855d39f272SZheng Fan                             mpMtrAngle->SelectEntryPos(7);
98687ab04d0SAndre Fischer                             break;
9875d39f272SZheng Fan                     }
988da72173fSAndre Fischer 
989da72173fSAndre Fischer                     break;
9905d39f272SZheng Fan                 }
991da72173fSAndre Fischer             }
992da72173fSAndre Fischer 
9935d39f272SZheng Fan             mpMtrAngle->SetText( String() );
9945d39f272SZheng Fan             mpDial->SetRotation( 0 );
9955d39f272SZheng Fan             break;
9965d39f272SZheng Fan 
9975d39f272SZheng Fan         case SID_ATTR_METRIC:
9985d39f272SZheng Fan             MetricState( eState, pState );
999*5f79b2b9SAndre Fischer             UpdateUIScale();
10005d39f272SZheng Fan             break;
10015d39f272SZheng Fan 
10025d39f272SZheng Fan         default:
10035d39f272SZheng Fan             break;
10045d39f272SZheng Fan     }
10055d39f272SZheng Fan 
10065d39f272SZheng Fan     const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
1007eefa0d2bSArmin Le Grand     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
10085d39f272SZheng Fan 
10095d39f272SZheng Fan     switch (rMarkList.GetMarkCount())
10105d39f272SZheng Fan     {
10115d39f272SZheng Fan         case 0:
10125d39f272SZheng Fan             break;
10135d39f272SZheng Fan 
10145d39f272SZheng Fan         case 1:
10155d39f272SZheng Fan         {
10165d39f272SZheng Fan             const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
10175d39f272SZheng Fan             const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
10185d39f272SZheng Fan 
10195d39f272SZheng Fan             if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
10205d39f272SZheng Fan                || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
10215d39f272SZheng Fan                  ) && OBJ_EDGE == eKind)
10225d39f272SZheng Fan                || OBJ_CAPTION == eKind)
10235d39f272SZheng Fan             {
10245d39f272SZheng Fan                 mpFtAngle->Disable();
10255d39f272SZheng Fan                 mpMtrAngle->Disable();
10265d39f272SZheng Fan                 mpDial->Disable();
10275d39f272SZheng Fan                 mpFlipTbx->Disable();
10285d39f272SZheng Fan                 mpFtFlip->Disable();
10295d39f272SZheng Fan             }
10305d39f272SZheng Fan             break;
10315d39f272SZheng Fan         }
10325d39f272SZheng Fan 
10335d39f272SZheng Fan         default:
10345d39f272SZheng Fan         {
10355d39f272SZheng Fan             sal_uInt16 nMarkObj = 0;
10365d39f272SZheng Fan             bool isNoEdge = true;
1037d74d90d6SArmin Le Grand 
1038d74d90d6SArmin Le Grand             while(isNoEdge && rMarkList.GetMark(nMarkObj))
10395d39f272SZheng Fan             {
10405d39f272SZheng Fan                 const SdrObject* pObj = rMarkList.GetMark(nMarkObj)->GetMarkedSdrObj();
10415d39f272SZheng Fan                 const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
10425d39f272SZheng Fan 
10435d39f272SZheng Fan                 if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
10445d39f272SZheng Fan                   || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
10455d39f272SZheng Fan                      ) && OBJ_EDGE == eKind)
10465d39f272SZheng Fan                   || OBJ_CAPTION == eKind)
10475d39f272SZheng Fan                 {
10485d39f272SZheng Fan                     isNoEdge = false;
10495d39f272SZheng Fan                     break;
10505d39f272SZheng Fan                 }
10515d39f272SZheng Fan                 nMarkObj++;
10525d39f272SZheng Fan             }
1053d74d90d6SArmin Le Grand 
10545d39f272SZheng Fan             if(!isNoEdge)
10555d39f272SZheng Fan             {
10565d39f272SZheng Fan                 mpFtAngle->Disable();
10575d39f272SZheng Fan                 mpMtrAngle->Disable();
10585d39f272SZheng Fan                 mpDial->Disable();
10595d39f272SZheng Fan                 mpFlipTbx->Disable();
10605d39f272SZheng Fan                 mpFtFlip->Disable();
10615d39f272SZheng Fan             }
10625d39f272SZheng Fan             break;
10635d39f272SZheng Fan         }
10645d39f272SZheng Fan     }
10655d39f272SZheng Fan 
10665d39f272SZheng Fan     if(nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject))
10675d39f272SZheng Fan     {
10685d39f272SZheng Fan         mpFlipTbx->Disable();
10695d39f272SZheng Fan         mpFtFlip->Disable();
10705d39f272SZheng Fan     }
10715d39f272SZheng Fan 
10725d39f272SZheng Fan     DisableControls();
10735d39f272SZheng Fan 
10745d39f272SZheng Fan     // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
10755d39f272SZheng Fan     SvtViewOptions	aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
10765d39f272SZheng Fan     String	sUserData;
10775d39f272SZheng Fan     ::com::sun::star::uno::Any	aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
10785d39f272SZheng Fan     ::rtl::OUString	aTemp;
10795d39f272SZheng Fan     if ( aUserItem >>= aTemp )
10805d39f272SZheng Fan         sUserData = String( aTemp );
10815d39f272SZheng Fan     mpCbxScale->Check( (bool)sUserData.ToInt32() );
10825d39f272SZheng Fan }
10835d39f272SZheng Fan 
10845d39f272SZheng Fan 
10855d39f272SZheng Fan 
108645da7d5eSAndre Fischer 
GetBindings()10875d39f272SZheng Fan SfxBindings* PosSizePropertyPanel::GetBindings()
10885d39f272SZheng Fan {
10895d39f272SZheng Fan     return mpBindings;
10905d39f272SZheng Fan }
10915d39f272SZheng Fan 
10925d39f272SZheng Fan 
10935d39f272SZheng Fan 
executeSize()10945d39f272SZheng Fan void PosSizePropertyPanel::executeSize()
10955d39f272SZheng Fan {
10965d39f272SZheng Fan     if ( mpMtrWidth->IsValueModified() || mpMtrHeight->IsValueModified())
10975d39f272SZheng Fan     {
10985d39f272SZheng Fan         Fraction aUIScale = mpView->GetModel()->GetUIScale();
10995d39f272SZheng Fan 
11005d39f272SZheng Fan         // get Width
11015d39f272SZheng Fan         double nWidth = (double)mpMtrWidth->GetValue( meDlgUnit );
11025d39f272SZheng Fan         nWidth = MetricField::ConvertDoubleValue( nWidth, mpMtrWidth->GetBaseValue(), mpMtrWidth->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
11035d39f272SZheng Fan         long lWidth = (long)(nWidth * (double)aUIScale);
11045d39f272SZheng Fan         lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit );
11055d39f272SZheng Fan         lWidth = (long)mpMtrWidth->Denormalize( lWidth );
11065d39f272SZheng Fan 
11075d39f272SZheng Fan         // get Height
11085d39f272SZheng Fan         double nHeight = (double)mpMtrHeight->GetValue( meDlgUnit );
11095d39f272SZheng Fan         nHeight = MetricField::ConvertDoubleValue( nHeight, mpMtrHeight->GetBaseValue(), mpMtrHeight->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
11105d39f272SZheng Fan         long lHeight = (long)(nHeight * (double)aUIScale);
11115d39f272SZheng Fan         lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit );
11125d39f272SZheng Fan         lHeight = (long)mpMtrWidth->Denormalize( lHeight );
11135d39f272SZheng Fan 
11145d39f272SZheng Fan         // put Width & Height to itemset
11155d39f272SZheng Fan         SfxUInt32Item aWidthItem( SID_ATTR_TRANSFORM_WIDTH, (sal_uInt32) lWidth);
11165d39f272SZheng Fan         SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT, (sal_uInt32) lHeight);
11175d39f272SZheng Fan         SfxAllEnumItem aPointItem (SID_ATTR_TRANSFORM_SIZE_POINT, (sal_uInt16)meRP);
11188eda4adfSOliver-Rainer Wittmann         const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
11195d39f272SZheng Fan 
11208eda4adfSOliver-Rainer Wittmann         if( nCombinedContext == CombinedEnumContext(Application_WriterVariants, Context_Graphic)
11218eda4adfSOliver-Rainer Wittmann             || nCombinedContext == CombinedEnumContext(Application_WriterVariants, Context_OLE)
11225d39f272SZheng Fan             )
11235d39f272SZheng Fan         {
11245d39f272SZheng Fan             GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
11255d39f272SZheng Fan         }
11265d39f272SZheng Fan         else
11275d39f272SZheng Fan         {
11285d39f272SZheng Fan             if ( (mpMtrWidth->IsValueModified()) && (mpMtrHeight->IsValueModified()))
11295d39f272SZheng Fan                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
11305d39f272SZheng Fan             else if( mpMtrWidth->IsValueModified())
11315d39f272SZheng Fan                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aPointItem, 0L );
11325d39f272SZheng Fan             else if ( mpMtrHeight->IsValueModified())
11335d39f272SZheng Fan                 GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aHeightItem, &aPointItem, 0L );
11345d39f272SZheng Fan         }
11355d39f272SZheng Fan     }
11365d39f272SZheng Fan }
11375d39f272SZheng Fan 
11385d39f272SZheng Fan 
11395d39f272SZheng Fan 
executePosX()11405d39f272SZheng Fan void PosSizePropertyPanel::executePosX()
11415d39f272SZheng Fan {
11425d39f272SZheng Fan     if ( mpMtrPosX->IsValueModified())
11435d39f272SZheng Fan     {
11445d39f272SZheng Fan         long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
11455d39f272SZheng Fan         if( mbMtrPosXMirror )
11465d39f272SZheng Fan             lX = -lX;
11475d39f272SZheng Fan         long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
11485d39f272SZheng Fan 
11495d39f272SZheng Fan         Size aPageSize;
11505d39f272SZheng Fan         Rectangle aRect;
11515d39f272SZheng Fan         maRect = mpView->GetAllMarkedRect();
11525d39f272SZheng Fan         aRect = mpView->GetAllMarkedRect();
11535d39f272SZheng Fan 
11545d39f272SZheng Fan         Fraction aUIScale = mpView->GetModel()->GetUIScale();
11555d39f272SZheng Fan         lX += maAnchorPos.X();
11565d39f272SZheng Fan         lX = Fraction( lX ) * aUIScale;
11575d39f272SZheng Fan         lY += maAnchorPos.Y();
11585d39f272SZheng Fan         lY = Fraction( lY ) * aUIScale;
11595d39f272SZheng Fan 
11605d39f272SZheng Fan         SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
11615d39f272SZheng Fan         SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
11625d39f272SZheng Fan 
11635d39f272SZheng Fan         GetBindings()->GetDispatcher()->Execute(
11645d39f272SZheng Fan             SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosXItem, 0L );
11655d39f272SZheng Fan     }
11665d39f272SZheng Fan }
11675d39f272SZheng Fan 
11685d39f272SZheng Fan 
11695d39f272SZheng Fan 
executePosY()11705d39f272SZheng Fan void PosSizePropertyPanel::executePosY()
11715d39f272SZheng Fan {
11725d39f272SZheng Fan     if ( mpMtrPosY->IsValueModified() )
11735d39f272SZheng Fan     {
11745d39f272SZheng Fan         long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
11755d39f272SZheng Fan         long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
11765d39f272SZheng Fan 
11775d39f272SZheng Fan         Size aPageSize;
11785d39f272SZheng Fan         Rectangle aRect;
11795d39f272SZheng Fan         maRect = mpView->GetAllMarkedRect();
11805d39f272SZheng Fan         aRect = mpView->GetAllMarkedRect();
11815d39f272SZheng Fan 
11825d39f272SZheng Fan         Fraction aUIScale = mpView->GetModel()->GetUIScale();
11835d39f272SZheng Fan         lX += maAnchorPos.X();
11845d39f272SZheng Fan         lX = Fraction( lX ) * aUIScale;
11855d39f272SZheng Fan         lY += maAnchorPos.Y();
11865d39f272SZheng Fan         lY = Fraction( lY ) * aUIScale;
11875d39f272SZheng Fan 
11885d39f272SZheng Fan         SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
11895d39f272SZheng Fan         SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
11905d39f272SZheng Fan 
11915d39f272SZheng Fan         GetBindings()->GetDispatcher()->Execute(
11925d39f272SZheng Fan             SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosYItem, 0L );
11935d39f272SZheng Fan     }
11945d39f272SZheng Fan }
11955d39f272SZheng Fan 
11965d39f272SZheng Fan 
11975d39f272SZheng Fan 
MetricState(SfxItemState eState,const SfxPoolItem * pState)11985d39f272SZheng Fan void PosSizePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
11995d39f272SZheng Fan {
12005d39f272SZheng Fan     bool bPosXBlank = false;
12015d39f272SZheng Fan     bool bPosYBlank = false;
12025d39f272SZheng Fan     bool bWidthBlank = false;
12035d39f272SZheng Fan     bool bHeightBlank = false;
12045d39f272SZheng Fan     String sNull = String::CreateFromAscii("");
12055d39f272SZheng Fan     meDlgUnit = GetCurrentUnit(eState,pState);
12065d39f272SZheng Fan 
12075d39f272SZheng Fan     if( mpMtrPosX->GetText() == sNull )
12085d39f272SZheng Fan         bPosXBlank = true;
12095d39f272SZheng Fan     SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
12105d39f272SZheng Fan     if(bPosXBlank)
12115d39f272SZheng Fan         mpMtrPosX->SetText(String());
12125d39f272SZheng Fan 
12135d39f272SZheng Fan     if( mpMtrPosY->GetText() == sNull )
12145d39f272SZheng Fan         bPosYBlank = true;
12155d39f272SZheng Fan     SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
12165d39f272SZheng Fan     if(bPosYBlank)
12175d39f272SZheng Fan         mpMtrPosY->SetText(String());
12185d39f272SZheng Fan 
12195d39f272SZheng Fan     if( mpMtrWidth->GetText() == sNull )
12205d39f272SZheng Fan         bWidthBlank = true;
12215d39f272SZheng Fan     SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
12225d39f272SZheng Fan     if(bWidthBlank)
12235d39f272SZheng Fan         mpMtrWidth->SetText(String());
12245d39f272SZheng Fan 
12255d39f272SZheng Fan     if( mpMtrHeight->GetText() == sNull )
12265d39f272SZheng Fan         bHeightBlank = true;
12275d39f272SZheng Fan     SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
12285d39f272SZheng Fan     if(bHeightBlank)
12295d39f272SZheng Fan         mpMtrHeight->SetText(String());
12305d39f272SZheng Fan }
12315d39f272SZheng Fan 
12325d39f272SZheng Fan 
12335d39f272SZheng Fan 
GetCurrentUnit(SfxItemState eState,const SfxPoolItem * pState)12345d39f272SZheng Fan FieldUnit PosSizePropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
12355d39f272SZheng Fan {
12365d39f272SZheng Fan     FieldUnit eUnit = FUNIT_NONE;
12375d39f272SZheng Fan 
12385d39f272SZheng Fan     if ( pState && eState >= SFX_ITEM_DEFAULT )
1239a567bdc8SArmin Le Grand     {
12405d39f272SZheng Fan         eUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
1241a567bdc8SArmin Le Grand     }
12425d39f272SZheng Fan     else
12435d39f272SZheng Fan     {
12445d39f272SZheng Fan         SfxViewFrame* pFrame = SfxViewFrame::Current();
12455d39f272SZheng Fan         SfxObjectShell* pSh = NULL;
12465d39f272SZheng Fan         if ( pFrame )
12475d39f272SZheng Fan             pSh = pFrame->GetObjectShell();
12485d39f272SZheng Fan         if ( pSh )
12495d39f272SZheng Fan         {
12505d39f272SZheng Fan             SfxModule* pModule = pSh->GetModule();
12515d39f272SZheng Fan             if ( pModule )
12525d39f272SZheng Fan             {
12535d39f272SZheng Fan                 const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
12545d39f272SZheng Fan                 if ( pItem )
12555d39f272SZheng Fan                     eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
12565d39f272SZheng Fan             }
12575d39f272SZheng Fan             else
12585d39f272SZheng Fan             {
12595d39f272SZheng Fan                 DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" );
12605d39f272SZheng Fan             }
12615d39f272SZheng Fan         }
12625d39f272SZheng Fan     }
12635d39f272SZheng Fan 
12645d39f272SZheng Fan     return eUnit;
12655d39f272SZheng Fan }
12665d39f272SZheng Fan 
12675d39f272SZheng Fan 
12685d39f272SZheng Fan 
DisableControls()12695d39f272SZheng Fan void PosSizePropertyPanel::DisableControls()
12705d39f272SZheng Fan {
12715d39f272SZheng Fan     if( mbPositionProtected )
12725d39f272SZheng Fan     {
12735d39f272SZheng Fan         // the position is protected("Position protect" option in modal dialog is checked),
12745d39f272SZheng Fan         // disable all the Position controls in sidebar
12755d39f272SZheng Fan         mpFtPosX->Disable();
12765d39f272SZheng Fan         mpMtrPosX->Disable();
12775d39f272SZheng Fan         mpFtPosY->Disable();
12785d39f272SZheng Fan         mpMtrPosY->Disable();
12795d39f272SZheng Fan         mpFtAngle->Disable();
12805d39f272SZheng Fan         mpMtrAngle->Disable();
12815d39f272SZheng Fan         mpDial->Disable();
12825d39f272SZheng Fan         mpFtFlip->Disable();
12835d39f272SZheng Fan         mpFlipTbx->Disable();
12845d39f272SZheng Fan 
12855d39f272SZheng Fan         mpFtWidth->Disable();
12865d39f272SZheng Fan         mpMtrWidth->Disable();
12875d39f272SZheng Fan         mpFtHeight->Disable();
12885d39f272SZheng Fan         mpMtrHeight->Disable();
12895d39f272SZheng Fan         mpCbxScale->Disable();
12905d39f272SZheng Fan     }
12915d39f272SZheng Fan     else
12925d39f272SZheng Fan     {
12935d39f272SZheng Fan         mpFtPosX->Enable();
12945d39f272SZheng Fan         mpMtrPosX->Enable();
12955d39f272SZheng Fan         mpFtPosY->Enable();
12965d39f272SZheng Fan         mpMtrPosY->Enable();
12975d39f272SZheng Fan 
12985d39f272SZheng Fan         //mpFtAngle->Enable();
12995d39f272SZheng Fan         //mpMtrAngle->Enable();
13005d39f272SZheng Fan         //mpDial->Enable();
13015d39f272SZheng Fan         //mpFtFlip->Enable();
13025d39f272SZheng Fan         //mpFlipTbx->Enable();
13035d39f272SZheng Fan 
13045d39f272SZheng Fan         if( mbSizeProtected )
13055d39f272SZheng Fan         {
13065d39f272SZheng Fan             mpFtWidth->Disable();
13075d39f272SZheng Fan             mpMtrWidth->Disable();
13085d39f272SZheng Fan             mpFtHeight->Disable();
13095d39f272SZheng Fan             mpMtrHeight->Disable();
13105d39f272SZheng Fan             mpCbxScale->Disable();
13115d39f272SZheng Fan         }
13125d39f272SZheng Fan         else
13135d39f272SZheng Fan         {
13145d39f272SZheng Fan             if(	mbAdjustEnabled )
13155d39f272SZheng Fan             {
13165d39f272SZheng Fan                 if( mbAutoWidth )
13175d39f272SZheng Fan                 {
13185d39f272SZheng Fan                     mpFtWidth->Disable();
13195d39f272SZheng Fan                     mpMtrWidth->Disable();
13205d39f272SZheng Fan                     mpCbxScale->Disable();
13215d39f272SZheng Fan                 }
13225d39f272SZheng Fan                 else
13235d39f272SZheng Fan                 {
13245d39f272SZheng Fan                     mpFtWidth->Enable();
13255d39f272SZheng Fan                     mpMtrWidth->Enable();
13265d39f272SZheng Fan                 }
13275d39f272SZheng Fan                 if( mbAutoHeight )
13285d39f272SZheng Fan                 {
13295d39f272SZheng Fan                     mpFtHeight->Disable();
13305d39f272SZheng Fan                     mpMtrHeight->Disable();
13315d39f272SZheng Fan                     mpCbxScale->Disable();
13325d39f272SZheng Fan                 }
13335d39f272SZheng Fan                 else
13345d39f272SZheng Fan                 {
13355d39f272SZheng Fan                     mpFtHeight->Enable();
13365d39f272SZheng Fan                     mpMtrHeight->Enable();
13375d39f272SZheng Fan                 }
13385d39f272SZheng Fan                 if( !mbAutoWidth && !mbAutoHeight )
13395d39f272SZheng Fan                     mpCbxScale->Enable();
13405d39f272SZheng Fan             }
13415d39f272SZheng Fan             else
13425d39f272SZheng Fan             {
13435d39f272SZheng Fan                 mpFtWidth->Enable();
13445d39f272SZheng Fan                 mpMtrWidth->Enable();
13455d39f272SZheng Fan                 mpFtHeight->Enable();
13465d39f272SZheng Fan                 mpMtrHeight->Enable();
13475d39f272SZheng Fan                 mpCbxScale->Enable();
13485d39f272SZheng Fan             }
13495d39f272SZheng Fan         }
13505d39f272SZheng Fan     }
13515d39f272SZheng Fan }
13525d39f272SZheng Fan 
13535d39f272SZheng Fan 
1354*5f79b2b9SAndre Fischer 
1355*5f79b2b9SAndre Fischer 
UpdateUIScale(void)1356*5f79b2b9SAndre Fischer void PosSizePropertyPanel::UpdateUIScale (void)
1357*5f79b2b9SAndre Fischer {
1358*5f79b2b9SAndre Fischer     const Fraction aUIScale (mpView->GetModel()->GetUIScale());
1359*5f79b2b9SAndre Fischer     if (maUIScale != aUIScale)
1360*5f79b2b9SAndre Fischer     {
1361*5f79b2b9SAndre Fischer         // UI scale has changed.
1362*5f79b2b9SAndre Fischer 
1363*5f79b2b9SAndre Fischer         // Remember the new UI scale.
1364*5f79b2b9SAndre Fischer         maUIScale = aUIScale;
1365*5f79b2b9SAndre Fischer 
1366*5f79b2b9SAndre Fischer         // The content of the position and size boxes is only updated when item changes are notified.
1367*5f79b2b9SAndre Fischer         // Request such notifications without changing the actual item values.
1368*5f79b2b9SAndre Fischer         GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_X, sal_True, sal_False);
1369*5f79b2b9SAndre Fischer         GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_Y, sal_True, sal_False);
1370*5f79b2b9SAndre Fischer         GetBindings()->Invalidate(SID_ATTR_TRANSFORM_WIDTH, sal_True, sal_False);
1371*5f79b2b9SAndre Fischer         GetBindings()->Invalidate(SID_ATTR_TRANSFORM_HEIGHT, sal_True, sal_False);
1372*5f79b2b9SAndre Fischer     }
1373*5f79b2b9SAndre Fischer }
1374*5f79b2b9SAndre Fischer 
1375*5f79b2b9SAndre Fischer 
13765d39f272SZheng Fan } } // end of namespace svx::sidebar
13774e8031e0SArmin Le Grand 
13784e8031e0SArmin Le Grand // eof
1379