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(),
946acc8afaSArmin Le Grand
956acc8afaSArmin Le Grand // #124409# init with fallback default
966acc8afaSArmin Le Grand meDlgUnit(FUNIT_INCH),
976acc8afaSArmin Le Grand
985d39f272SZheng Fan maTransfPosXControl(SID_ATTR_TRANSFORM_POS_X, *pBindings, *this),
995d39f272SZheng Fan maTransfPosYControl(SID_ATTR_TRANSFORM_POS_Y, *pBindings, *this),
1005d39f272SZheng Fan maTransfWidthControl(SID_ATTR_TRANSFORM_WIDTH, *pBindings, *this),
1015d39f272SZheng Fan maTransfHeightControl(SID_ATTR_TRANSFORM_HEIGHT, *pBindings, *this),
1025d39f272SZheng Fan maSvxAngleControl( SID_ATTR_TRANSFORM_ANGLE, *pBindings, *this),
1035d39f272SZheng Fan maRotXControl(SID_ATTR_TRANSFORM_ROT_X, *pBindings, *this),
1045d39f272SZheng Fan maRotYControl(SID_ATTR_TRANSFORM_ROT_Y, *pBindings, *this),
1055d39f272SZheng Fan maProPosControl(SID_ATTR_TRANSFORM_PROTECT_POS, *pBindings, *this),
1065d39f272SZheng Fan maProSizeControl(SID_ATTR_TRANSFORM_PROTECT_SIZE, *pBindings, *this),
1075d39f272SZheng Fan maAutoWidthControl(SID_ATTR_TRANSFORM_AUTOWIDTH, *pBindings, *this),
1085d39f272SZheng Fan maAutoHeightControl(SID_ATTR_TRANSFORM_AUTOHEIGHT, *pBindings, *this),
1095d39f272SZheng Fan m_aMetricCtl(SID_ATTR_METRIC, *pBindings, *this),
1105d39f272SZheng Fan mxFrame(rxFrame),
1115d39f272SZheng Fan maContext(),
1125d39f272SZheng Fan mpBindings(pBindings),
113d74d90d6SArmin Le Grand maFtWidthOrigPos(mpFtWidth->GetPosPixel()),
114d74d90d6SArmin Le Grand maMtrWidthOrigPos(mpMtrWidth->GetPosPixel()),
115d74d90d6SArmin Le Grand maFtHeightOrigPos(mpFtHeight->GetPosPixel()),
116d74d90d6SArmin Le Grand maMtrHeightOrigPos(mpMtrHeight->GetPosPixel()),
117d74d90d6SArmin Le Grand maCbxScaleOrigPos(mpCbxScale->GetPosPixel()),
118d74d90d6SArmin Le Grand maFtAngleOrigPos(mpFtAngle->GetPosPixel()),
119d74d90d6SArmin Le Grand maMtrAnglOrigPos(mpMtrAngle->GetPosPixel()),
120d74d90d6SArmin Le Grand maFlipTbxOrigPos(mpFlipTbx->GetPosPixel()),
121d74d90d6SArmin Le Grand maDialOrigPos(mpDial->GetPosPixel()),
122d74d90d6SArmin Le Grand maFtFlipOrigPos(mpFtFlip->GetPosPixel()),
1235d39f272SZheng Fan mbMtrPosXMirror(false),
1245d39f272SZheng Fan mbSizeProtected(false),
1255d39f272SZheng Fan mbPositionProtected(false),
1265d39f272SZheng Fan mbAutoWidth(false),
1275d39f272SZheng Fan mbAutoHeight(false),
1285d39f272SZheng Fan mbAdjustEnabled(false),
1295d39f272SZheng Fan mbIsFlip(false),
1306a606da0SAndre Fischer mxSidebar(rxSidebar),
1316a606da0SAndre Fischer maLayouter(*this)
1325d39f272SZheng Fan {
1335d39f272SZheng Fan Initialize();
1345d39f272SZheng Fan FreeResource();
1350c259c9fSOliver-Rainer Wittmann
1360c259c9fSOliver-Rainer Wittmann mpBindings->Update( SID_ATTR_TRANSFORM_WIDTH );
1370c259c9fSOliver-Rainer Wittmann mpBindings->Update( SID_ATTR_TRANSFORM_HEIGHT );
1380c259c9fSOliver-Rainer Wittmann mpBindings->Update( SID_ATTR_TRANSFORM_PROTECT_SIZE );
1390c259c9fSOliver-Rainer Wittmann mpBindings->Update( SID_ATTR_METRIC );
1406a606da0SAndre Fischer
1416a606da0SAndre Fischer // Setup the grid layouter.
1426a606da0SAndre Fischer const sal_Int32 nMappedMboxWidth (Layouter::MapWidth(*this, MBOX_WIDTH));
1436a606da0SAndre Fischer
1446a606da0SAndre Fischer maLayouter.GetCell(0,0).SetControl(*mpFtPosX);
1456a606da0SAndre Fischer maLayouter.GetCell(1,0).SetControl(*mpMtrPosX);
1466a606da0SAndre Fischer
1476a606da0SAndre Fischer maLayouter.GetCell(0,2).SetControl(*mpFtPosY);
1486a606da0SAndre Fischer maLayouter.GetCell(1,2).SetControl(*mpMtrPosY);
1496a606da0SAndre Fischer
1506a606da0SAndre Fischer maLayouter.GetCell(2,0).SetControl(*mpFtWidth);
1516a606da0SAndre Fischer maLayouter.GetCell(3,0).SetControl(*mpMtrWidth);
1526a606da0SAndre Fischer
1536a606da0SAndre Fischer maLayouter.GetCell(2,2).SetControl(*mpFtHeight);
1546a606da0SAndre Fischer maLayouter.GetCell(3,2).SetControl(*mpMtrHeight);
1556a606da0SAndre Fischer
1566a606da0SAndre Fischer maLayouter.GetCell(4,0).SetControl(*mpCbxScale).SetGridWidth(3);
1576a606da0SAndre Fischer maLayouter.GetCell(5,0).SetControl(*mpFtAngle).SetGridWidth(3);
1586a606da0SAndre Fischer
1596a606da0SAndre Fischer
1606a606da0SAndre Fischer maLayouter.GetColumn(0)
1616a606da0SAndre Fischer .SetWeight(1)
1626a606da0SAndre Fischer .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
1636a606da0SAndre Fischer .SetMinimumWidth(nMappedMboxWidth);
1646a606da0SAndre Fischer maLayouter.GetColumn(1)
1656a606da0SAndre Fischer .SetWeight(0)
1666a606da0SAndre Fischer .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
1676a606da0SAndre Fischer maLayouter.GetColumn(2)
1686a606da0SAndre Fischer .SetWeight(1)
1696a606da0SAndre Fischer .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
1706a606da0SAndre Fischer .SetMinimumWidth(nMappedMboxWidth);
1716a606da0SAndre Fischer
1726a606da0SAndre Fischer // Make controls that display text handle short widths more
1736a606da0SAndre Fischer // graceful.
1746a606da0SAndre Fischer Layouter::PrepareForLayouting(*mpFtPosX);
1756a606da0SAndre Fischer Layouter::PrepareForLayouting(*mpFtPosY);
1766a606da0SAndre Fischer Layouter::PrepareForLayouting(*mpFtWidth);
1776a606da0SAndre Fischer Layouter::PrepareForLayouting(*mpFtHeight);
1786a606da0SAndre Fischer Layouter::PrepareForLayouting(*mpCbxScale);
1796a606da0SAndre Fischer Layouter::PrepareForLayouting(*mpFtAngle);
1806a606da0SAndre Fischer
1815d39f272SZheng Fan }
1825d39f272SZheng Fan
1835d39f272SZheng Fan
1845d39f272SZheng Fan
~PosSizePropertyPanel()1855d39f272SZheng Fan PosSizePropertyPanel::~PosSizePropertyPanel()
1865d39f272SZheng Fan {
1875d39f272SZheng Fan // Destroy the background windows of the toolboxes.
1885d39f272SZheng Fan mpFlipTbx.reset();
1895d39f272SZheng Fan mpFlipTbxBackground.reset();
1905d39f272SZheng Fan }
1915d39f272SZheng Fan
1925d39f272SZheng Fan
1935d39f272SZheng Fan
ShowMenu(void)1945d39f272SZheng Fan void PosSizePropertyPanel::ShowMenu (void)
1955d39f272SZheng Fan {
1965d39f272SZheng Fan if (mpBindings != NULL)
1975d39f272SZheng Fan {
1985d39f272SZheng Fan SfxDispatcher* pDispatcher = mpBindings->GetDispatcher();
1995d39f272SZheng Fan if (pDispatcher != NULL)
2005d39f272SZheng Fan pDispatcher->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_ASYNCHRON);
2015d39f272SZheng Fan }
2025d39f272SZheng Fan }
2035d39f272SZheng Fan
2045d39f272SZheng Fan
2055d39f272SZheng Fan
206eefa0d2bSArmin Le Grand namespace
207eefa0d2bSArmin Le Grand {
hasText(const SdrView & rSdrView)208eefa0d2bSArmin Le Grand bool hasText(const SdrView& rSdrView)
209eefa0d2bSArmin Le Grand {
210eefa0d2bSArmin Le Grand const SdrMarkList& rMarkList = rSdrView.GetMarkedObjectList();
211eefa0d2bSArmin Le Grand
212eefa0d2bSArmin Le Grand if(1 == rMarkList.GetMarkCount())
213eefa0d2bSArmin Le Grand {
214eefa0d2bSArmin Le Grand const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
215eefa0d2bSArmin Le Grand const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
216eefa0d2bSArmin Le Grand
217eefa0d2bSArmin Le Grand if((pObj->GetObjInventor() == SdrInventor) && (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind))
218eefa0d2bSArmin Le Grand {
219eefa0d2bSArmin Le Grand const SdrTextObj* pSdrTextObj = dynamic_cast< const SdrTextObj* >(pObj);
220eefa0d2bSArmin Le Grand
221eefa0d2bSArmin Le Grand if(pSdrTextObj && pSdrTextObj->HasText())
222eefa0d2bSArmin Le Grand {
223eefa0d2bSArmin Le Grand return true;
224eefa0d2bSArmin Le Grand }
225eefa0d2bSArmin Le Grand }
226eefa0d2bSArmin Le Grand }
227eefa0d2bSArmin Le Grand
228eefa0d2bSArmin Le Grand return false;
229eefa0d2bSArmin Le Grand }
230eefa0d2bSArmin Le Grand } // end of anonymous namespace
231eefa0d2bSArmin Le Grand
232eefa0d2bSArmin Le Grand
233eefa0d2bSArmin Le Grand
2346a606da0SAndre Fischer
Resize(void)2356a606da0SAndre Fischer void PosSizePropertyPanel::Resize (void)
2366a606da0SAndre Fischer {
2376a606da0SAndre Fischer maLayouter.Layout();
2386a606da0SAndre Fischer }
2396a606da0SAndre Fischer
2406a606da0SAndre Fischer
2416a606da0SAndre Fischer
2426a606da0SAndre Fischer
Initialize()2435d39f272SZheng Fan void PosSizePropertyPanel::Initialize()
2445d39f272SZheng Fan {
24537fee4fdSAndre Fischer mpFtPosX->SetBackground(Wallpaper());
24637fee4fdSAndre Fischer mpFtPosY->SetBackground(Wallpaper());
24737fee4fdSAndre Fischer mpFtWidth->SetBackground(Wallpaper());
24837fee4fdSAndre Fischer mpFtHeight->SetBackground(Wallpaper());
24937fee4fdSAndre Fischer mpFtAngle->SetBackground(Wallpaper());
25037fee4fdSAndre Fischer mpFtFlip->SetBackground(Wallpaper());
25137fee4fdSAndre Fischer
2525d39f272SZheng Fan //Position : Horizontal / Vertical
2535d39f272SZheng Fan mpMtrPosX->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosXHdl ) );
2545d39f272SZheng Fan mpMtrPosY->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosYHdl ) );
2555d39f272SZheng Fan mpMtrPosX->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Horizontal"))); //wj acc
2565d39f272SZheng Fan mpMtrPosY->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Vertical"))); //wj acc
2575d39f272SZheng Fan
2585d39f272SZheng Fan //Size : Width / Height
2595d39f272SZheng Fan mpMtrWidth->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeWidthHdl ) );
2605d39f272SZheng Fan mpMtrHeight->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeHeightHdl ) );
2615d39f272SZheng Fan mpMtrWidth->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width"))); //wj acc
2625d39f272SZheng Fan mpMtrHeight->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height"))); //wj acc
2635d39f272SZheng Fan
2645d39f272SZheng Fan //Size : Keep ratio
2655d39f272SZheng Fan mpCbxScale->SetClickHdl( LINK( this, PosSizePropertyPanel, ClickAutoHdl ) );
2665d39f272SZheng Fan
2675d39f272SZheng Fan //rotation:
2685d39f272SZheng Fan mpMtrAngle->SetModifyHdl(LINK( this, PosSizePropertyPanel, AngleModifiedHdl));
2695d39f272SZheng Fan mpMtrAngle->EnableAutocomplete( false );
2705d39f272SZheng Fan mpMtrAngle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Rotation"))); //wj acc
2715d39f272SZheng Fan
2725d39f272SZheng Fan //rotation control
2735d39f272SZheng Fan mpDial->SetModifyHdl(LINK( this, PosSizePropertyPanel, RotationHdl));
2745d39f272SZheng Fan
2755d39f272SZheng Fan //flip:
2765d39f272SZheng Fan mpFlipTbx->SetSelectHdl( LINK( this, PosSizePropertyPanel, FlipHdl) );
277aed5c350SAndre Fischer mpFlipTbx->SetItemImage(
278aed5c350SAndre Fischer FLIP_HORIZONTAL,
279aed5c350SAndre Fischer GetImage(mxFrame, A2S(".uno:FlipHorizontal"), sal_False, Theme::IsHighContrastMode()));
280aed5c350SAndre Fischer mpFlipTbx->SetItemImage(
281aed5c350SAndre Fischer FLIP_VERTICAL,
282aed5c350SAndre Fischer GetImage(mxFrame, A2S(".uno:FlipVertical"), sal_False, Theme::IsHighContrastMode()));
2835d39f272SZheng Fan mpFlipTbx->SetQuickHelpText(FLIP_HORIZONTAL,String(SVX_RES(STR_QH_HORI_FLIP))); //Add
2845d39f272SZheng Fan mpFlipTbx->SetQuickHelpText(FLIP_VERTICAL,String(SVX_RES(STR_QH_VERT_FLIP))); //Add
2855d39f272SZheng Fan
2865d39f272SZheng Fan mpMtrPosX->SetAccessibleRelationLabeledBy(mpFtPosX.get());
2875d39f272SZheng Fan mpMtrPosY->SetAccessibleRelationLabeledBy(mpFtPosY.get());
2885d39f272SZheng Fan mpMtrWidth->SetAccessibleRelationLabeledBy(mpFtWidth.get());
2895d39f272SZheng Fan mpMtrHeight->SetAccessibleRelationLabeledBy(mpFtHeight.get());
2905d39f272SZheng Fan mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtAngle.get());
291facb16e7SArmin Le Grand #ifdef HAS_IA2
292facb16e7SArmin Le Grand mpMtrAngle->SetMpSubEditAccLableBy(mpFtAngle.get());
293facb16e7SArmin Le Grand #endif
2945d39f272SZheng Fan mpFlipTbx->SetAccessibleRelationLabeledBy(mpFtFlip.get());
2955d39f272SZheng Fan
2965d39f272SZheng Fan mpMtrAngle->InsertValue(0, FUNIT_CUSTOM);
2975d39f272SZheng Fan mpMtrAngle->InsertValue(4500, FUNIT_CUSTOM);
2985d39f272SZheng Fan mpMtrAngle->InsertValue(9000, FUNIT_CUSTOM);
2995d39f272SZheng Fan mpMtrAngle->InsertValue(13500, FUNIT_CUSTOM);
3005d39f272SZheng Fan mpMtrAngle->InsertValue(18000, FUNIT_CUSTOM);
3015d39f272SZheng Fan mpMtrAngle->InsertValue(22500, FUNIT_CUSTOM);
3025d39f272SZheng Fan mpMtrAngle->InsertValue(27000, FUNIT_CUSTOM);
3035d39f272SZheng Fan mpMtrAngle->InsertValue(31500, FUNIT_CUSTOM);
304a68b38dfSArmin Le Grand mpMtrAngle->AdaptDropDownLineCountToMaximum();
3055d39f272SZheng Fan
3065d39f272SZheng Fan SfxViewShell* pCurSh = SfxViewShell::Current();
3075d39f272SZheng Fan if ( pCurSh )
3085d39f272SZheng Fan mpView = pCurSh->GetDrawView();
3095d39f272SZheng Fan else
3105d39f272SZheng Fan mpView = NULL;
3115d39f272SZheng Fan
3125d39f272SZheng Fan if ( mpView != NULL )
3135d39f272SZheng Fan {
3145d39f272SZheng Fan maUIScale = mpView->GetModel()->GetUIScale();
315eefa0d2bSArmin Le Grand mbAdjustEnabled = hasText(*mpView);
3165d39f272SZheng Fan }
3175d39f272SZheng Fan
3185d39f272SZheng Fan mePoolUnit = maTransfWidthControl.GetCoreMetric();
3196acc8afaSArmin Le Grand
3206acc8afaSArmin Le Grand // #124409# no need to do this, the mpBindings->Update( SID_ATTR_METRIC )
3216acc8afaSArmin Le Grand // call in the constructor will trigger MetricState and will get the correct unit
3226acc8afaSArmin Le Grand //
3236acc8afaSArmin Le Grand // meDlgUnit = GetModuleFieldUnit();
3246acc8afaSArmin Le Grand // SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
3256acc8afaSArmin Le Grand // SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
3266acc8afaSArmin Le Grand // SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
3276acc8afaSArmin Le Grand // SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
3285d39f272SZheng Fan }
3295d39f272SZheng Fan
3305d39f272SZheng Fan
3315d39f272SZheng Fan
SetupIcons(void)3325d39f272SZheng Fan void PosSizePropertyPanel::SetupIcons(void)
3335d39f272SZheng Fan {
3345d39f272SZheng Fan if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
3355d39f272SZheng Fan {
3365d39f272SZheng Fan // todo
3375d39f272SZheng Fan }
3385d39f272SZheng Fan else
3395d39f272SZheng Fan {
3405d39f272SZheng Fan // todo
3415d39f272SZheng Fan }
3425d39f272SZheng Fan }
3435d39f272SZheng Fan
3445d39f272SZheng Fan
3455d39f272SZheng Fan
Create(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings,const cssu::Reference<css::ui::XSidebar> & rxSidebar)3465d39f272SZheng Fan PosSizePropertyPanel* PosSizePropertyPanel::Create (
3475d39f272SZheng Fan Window* pParent,
3485d39f272SZheng Fan const cssu::Reference<css::frame::XFrame>& rxFrame,
34937fee4fdSAndre Fischer SfxBindings* pBindings,
35037fee4fdSAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar)
3515d39f272SZheng Fan {
3525d39f272SZheng Fan if (pParent == NULL)
3535d39f272SZheng Fan throw lang::IllegalArgumentException(A2S("no parent Window given to PosSizePropertyPanel::Create"), NULL, 0);
3545d39f272SZheng Fan if ( ! rxFrame.is())
3555d39f272SZheng Fan throw lang::IllegalArgumentException(A2S("no XFrame given to PosSizePropertyPanel::Create"), NULL, 1);
3565d39f272SZheng Fan if (pBindings == NULL)
3575d39f272SZheng Fan throw lang::IllegalArgumentException(A2S("no SfxBindings given to PosSizePropertyPanel::Create"), NULL, 2);
3585d39f272SZheng Fan
3595d39f272SZheng Fan return new PosSizePropertyPanel(
3605d39f272SZheng Fan pParent,
3615d39f272SZheng Fan rxFrame,
36237fee4fdSAndre Fischer pBindings,
36337fee4fdSAndre Fischer rxSidebar);
3645d39f272SZheng Fan }
3655d39f272SZheng Fan
3665d39f272SZheng Fan
3675d39f272SZheng Fan
DataChanged(const DataChangedEvent & rEvent)3685d39f272SZheng Fan void PosSizePropertyPanel::DataChanged(
3695d39f272SZheng Fan const DataChangedEvent& rEvent)
3705d39f272SZheng Fan {
3715d39f272SZheng Fan (void)rEvent;
3725d39f272SZheng Fan
3735d39f272SZheng Fan SetupIcons();
3745d39f272SZheng Fan }
3755d39f272SZheng Fan
3765d39f272SZheng Fan
3775d39f272SZheng Fan
AdaptWidthHeightScalePosition(bool bOriginal)378d74d90d6SArmin Le Grand void PosSizePropertyPanel::AdaptWidthHeightScalePosition(bool bOriginal)
379d74d90d6SArmin Le Grand {
380d74d90d6SArmin Le Grand if(bOriginal)
381d74d90d6SArmin Le Grand {
382d74d90d6SArmin Le Grand mpFtWidth->SetPosPixel(maFtWidthOrigPos);
383d74d90d6SArmin Le Grand mpMtrWidth->SetPosPixel(maMtrWidthOrigPos);
384d74d90d6SArmin Le Grand mpFtHeight->SetPosPixel(maFtHeightOrigPos);
385d74d90d6SArmin Le Grand mpMtrHeight->SetPosPixel(maMtrHeightOrigPos);
386d74d90d6SArmin Le Grand mpCbxScale->SetPosPixel(maCbxScaleOrigPos);
387d74d90d6SArmin Le Grand }
388d74d90d6SArmin Le Grand else
389d74d90d6SArmin Le Grand {
390d74d90d6SArmin Le Grand mpFtWidth->SetPosPixel(Point(LogicToPixel(Point(FT_POSITION_X_X,FT_POSITION_X_Y), MAP_APPFONT)));
391d74d90d6SArmin Le Grand mpMtrWidth->SetPosPixel(Point(LogicToPixel(Point(MF_POSITION_X_X,MF_POSITION_X_Y), MAP_APPFONT)));
392d74d90d6SArmin Le Grand mpFtHeight->SetPosPixel(Point(LogicToPixel(Point(FT_POSITION_Y_X,FT_POSITION_Y_Y), MAP_APPFONT)));
393d74d90d6SArmin Le Grand mpMtrHeight->SetPosPixel(Point(LogicToPixel(Point(MF_POSITION_Y_X,MF_POSITION_Y_Y), MAP_APPFONT)));
394d74d90d6SArmin Le Grand mpCbxScale->SetPosPixel(Point(LogicToPixel(Point(FT_WIDTH_X,FT_WIDTH_Y), MAP_APPFONT)));
395d74d90d6SArmin Le Grand }
396d74d90d6SArmin Le Grand }
397d74d90d6SArmin Le Grand
AdaptAngleFlipDialPosition(bool bOriginal)398d74d90d6SArmin Le Grand void PosSizePropertyPanel::AdaptAngleFlipDialPosition(bool bOriginal)
399d74d90d6SArmin Le Grand {
400d74d90d6SArmin Le Grand if(bOriginal)
401d74d90d6SArmin Le Grand {
402d74d90d6SArmin Le Grand mpFtAngle->SetPosPixel(maFtAngleOrigPos);
403d74d90d6SArmin Le Grand mpMtrAngle->SetPosPixel(maMtrAnglOrigPos);
404d74d90d6SArmin Le Grand mpFlipTbx->SetPosPixel(maFlipTbxOrigPos);
405d74d90d6SArmin Le Grand mpDial->SetPosPixel(maDialOrigPos);
406d74d90d6SArmin Le Grand mpFtFlip->SetPosPixel(maFtFlipOrigPos);
407d74d90d6SArmin Le Grand }
408d74d90d6SArmin Le Grand else
409d74d90d6SArmin Le Grand {
410d74d90d6SArmin Le Grand mpFtAngle->SetPosPixel(Point(LogicToPixel(Point(FT_ANGLE_X,FT_ANGLE_Y), MAP_APPFONT)));
411d74d90d6SArmin Le Grand mpMtrAngle->SetPosPixel(Point(LogicToPixel(Point(MF_ANGLE_X2,MF_ANGLE_Y2), MAP_APPFONT)));
412d74d90d6SArmin Le Grand mpFlipTbx->SetPosPixel(Point(LogicToPixel(Point(FLIP_HORI_X2,FLIP_HORI_Y2), MAP_APPFONT)));
413d74d90d6SArmin Le Grand mpDial->SetPosPixel(Point(LogicToPixel(Point(ROTATE_CONTROL_X2,ROTATE_CONTROL_Y2), MAP_APPFONT)));
414d74d90d6SArmin Le Grand mpFtFlip->SetPosPixel(Point(LogicToPixel(Point(FT_FLIP_X2,FT_FLIP_Y2), MAP_APPFONT)));
415d74d90d6SArmin Le Grand }
416d74d90d6SArmin Le Grand }
417d74d90d6SArmin Le Grand
HandleContextChange(const::sfx2::sidebar::EnumContext aContext)4185d39f272SZheng Fan void PosSizePropertyPanel::HandleContextChange(
4195d39f272SZheng Fan const ::sfx2::sidebar::EnumContext aContext)
4205d39f272SZheng Fan {
4215d39f272SZheng Fan if(maContext == aContext)
4225d39f272SZheng Fan {
4235d39f272SZheng Fan // Nothing to do.
4245d39f272SZheng Fan return;
4255d39f272SZheng Fan }
4265d39f272SZheng Fan
4275d39f272SZheng Fan maContext = aContext;
4285d39f272SZheng Fan
4295d39f272SZheng Fan sal_Int32 nLayoutMode (0);
4305d39f272SZheng Fan switch (maContext.GetCombinedContext_DI())
4315d39f272SZheng Fan {
43285f1aca2SAndre Fischer case CombinedEnumContext(Application_WriterVariants, Context_Draw):
4335d39f272SZheng Fan nLayoutMode = 0;
4345d39f272SZheng Fan break;
4355d39f272SZheng Fan
43685f1aca2SAndre Fischer case CombinedEnumContext(Application_WriterVariants, Context_Graphic):
43785f1aca2SAndre Fischer case CombinedEnumContext(Application_WriterVariants, Context_Media):
43885f1aca2SAndre Fischer case CombinedEnumContext(Application_WriterVariants, Context_Frame):
43985f1aca2SAndre Fischer case CombinedEnumContext(Application_WriterVariants, Context_OLE):
44085f1aca2SAndre Fischer case CombinedEnumContext(Application_WriterVariants, Context_Form):
4415d39f272SZheng Fan nLayoutMode = 1;
4425d39f272SZheng Fan break;
4435d39f272SZheng Fan
4445d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_Draw):
4455d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_Graphic):
4465d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_Draw):
4475d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
4485d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
4495d39f272SZheng Fan nLayoutMode = 2;
4505d39f272SZheng Fan break;
4515d39f272SZheng Fan
4525d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_Chart):
4535d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_Form):
4545d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_Media):
4555d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_OLE):
4565d39f272SZheng Fan case CombinedEnumContext(Application_Calc, Context_MultiObject):
4575d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_Media):
4585d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_Form):
4595d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_OLE):
4605d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_3DObject):
4615d39f272SZheng Fan case CombinedEnumContext(Application_DrawImpress, Context_MultiObject):
4625d39f272SZheng Fan nLayoutMode = 3;
4635d39f272SZheng Fan break;
4645d39f272SZheng Fan }
465d74d90d6SArmin Le Grand
4665d39f272SZheng Fan switch (nLayoutMode)
4675d39f272SZheng Fan {
4685d39f272SZheng Fan case 0:
4695d39f272SZheng Fan {
4705d39f272SZheng Fan mpMtrWidth->SetMin( 2 );
4715d39f272SZheng Fan mpMtrHeight->SetMin( 2 );
4725d39f272SZheng Fan mpFtPosX->Hide();
4735d39f272SZheng Fan mpMtrPosX->Hide();
4745d39f272SZheng Fan mpFtPosY->Hide();
4755d39f272SZheng Fan mpMtrPosY->Hide();
4765d39f272SZheng Fan
4775d39f272SZheng Fan //rotation
4785d39f272SZheng Fan mpFtAngle->Show();
4795d39f272SZheng Fan mpMtrAngle->Show();
4805d39f272SZheng Fan mpDial->Show();
4815d39f272SZheng Fan
4825d39f272SZheng Fan //flip
4835d39f272SZheng Fan mpFtFlip->Show();
4845d39f272SZheng Fan mpFlipTbx->Show();
4855d39f272SZheng Fan Size aTbxSize = mpFlipTbx->CalcWindowSizePixel();
4865d39f272SZheng Fan mpFlipTbx->SetOutputSizePixel( aTbxSize );
4875d39f272SZheng Fan mbIsFlip = true;
4885d39f272SZheng Fan
489d74d90d6SArmin Le Grand AdaptWidthHeightScalePosition(false);
490d74d90d6SArmin Le Grand AdaptAngleFlipDialPosition(false);
4915d39f272SZheng Fan
4925d39f272SZheng Fan mpFtAngle->SetPosPixel(Point(LogicToPixel(Point(FT_ANGLE_X,FT_ANGLE_Y), MAP_APPFONT)));
4935d39f272SZheng Fan mpMtrAngle->SetPosPixel(Point(LogicToPixel(Point(MF_ANGLE_X2,MF_ANGLE_Y2), MAP_APPFONT)));
4945d39f272SZheng Fan mpFlipTbx->SetPosPixel(Point(LogicToPixel(Point(FLIP_HORI_X2,FLIP_HORI_Y2), MAP_APPFONT)));
4955d39f272SZheng Fan mpDial->SetPosPixel(Point(LogicToPixel(Point(ROTATE_CONTROL_X2,ROTATE_CONTROL_Y2), MAP_APPFONT)));
4965d39f272SZheng Fan mpFtFlip->SetPosPixel(Point(LogicToPixel(Point(FT_FLIP_X2,FT_FLIP_Y2), MAP_APPFONT)));
4975d39f272SZheng Fan
4985d39f272SZheng Fan Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT2);
4995d39f272SZheng Fan aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5005d39f272SZheng Fan SetSizePixel(aSize);
50137fee4fdSAndre Fischer if (mxSidebar.is())
50237fee4fdSAndre Fischer mxSidebar->requestLayout();
5035d39f272SZheng Fan }
5045d39f272SZheng Fan break;
5055d39f272SZheng Fan
5065d39f272SZheng Fan case 1:
5075d39f272SZheng Fan {
5085d39f272SZheng Fan mpMtrWidth->SetMin( 2 );
5095d39f272SZheng Fan mpMtrHeight->SetMin( 2 );
5105d39f272SZheng Fan mpFtPosX->Hide();
5115d39f272SZheng Fan mpMtrPosX->Hide();
5125d39f272SZheng Fan mpFtPosY->Hide();
5135d39f272SZheng Fan mpMtrPosY->Hide();
5145d39f272SZheng Fan
5155d39f272SZheng Fan //rotation
5165d39f272SZheng Fan mpFtAngle->Hide();
5175d39f272SZheng Fan mpMtrAngle->Hide();
5185d39f272SZheng Fan mpDial->Hide();
5195d39f272SZheng Fan
5205d39f272SZheng Fan //flip
5215d39f272SZheng Fan mpFlipTbx->Hide();
5225d39f272SZheng Fan mpFtFlip->Hide();
5235d39f272SZheng Fan mbIsFlip = false;
5245d39f272SZheng Fan
525d74d90d6SArmin Le Grand AdaptWidthHeightScalePosition(false);
526d74d90d6SArmin Le Grand AdaptAngleFlipDialPosition(true);
5275d39f272SZheng Fan
5285d39f272SZheng Fan Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT3);
5295d39f272SZheng Fan aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5305d39f272SZheng Fan SetSizePixel(aSize);
53137fee4fdSAndre Fischer if (mxSidebar.is())
53237fee4fdSAndre Fischer mxSidebar->requestLayout();
5335d39f272SZheng Fan }
5345d39f272SZheng Fan break;
5355d39f272SZheng Fan
5365d39f272SZheng Fan case 2:
5375d39f272SZheng Fan {
5385d39f272SZheng Fan mpMtrWidth->SetMin( 1 );
5395d39f272SZheng Fan mpMtrHeight->SetMin( 1 );
5405d39f272SZheng Fan mpFtPosX->Show();
5415d39f272SZheng Fan mpMtrPosX->Show();
5425d39f272SZheng Fan mpFtPosY->Show();
5435d39f272SZheng Fan mpMtrPosY->Show();
5445d39f272SZheng Fan
5455d39f272SZheng Fan //rotation
5465d39f272SZheng Fan mpFtAngle->Show();
5475d39f272SZheng Fan mpMtrAngle->Show();
5485d39f272SZheng Fan mpDial->Show();
5495d39f272SZheng Fan
5505d39f272SZheng Fan //flip
5515d39f272SZheng Fan mpFlipTbx->Show();
5525d39f272SZheng Fan mpFtFlip->Show();
5535d39f272SZheng Fan Size aTbxSize = mpFlipTbx->CalcWindowSizePixel();
5545d39f272SZheng Fan mpFlipTbx->SetOutputSizePixel( aTbxSize );
5555d39f272SZheng Fan mbIsFlip = true;
5565d39f272SZheng Fan
557d74d90d6SArmin Le Grand AdaptWidthHeightScalePosition(true);
558d74d90d6SArmin Le Grand AdaptAngleFlipDialPosition(true);
559d74d90d6SArmin Le Grand
5605d39f272SZheng Fan Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT);
5615d39f272SZheng Fan aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5625d39f272SZheng Fan SetSizePixel(aSize);
56337fee4fdSAndre Fischer if (mxSidebar.is())
56437fee4fdSAndre Fischer mxSidebar->requestLayout();
5655d39f272SZheng Fan }
5665d39f272SZheng Fan break;
5675d39f272SZheng Fan
5685d39f272SZheng Fan case 3:
5695d39f272SZheng Fan {
5705d39f272SZheng Fan mpMtrWidth->SetMin( 1 );
5715d39f272SZheng Fan mpMtrHeight->SetMin( 1 );
5725d39f272SZheng Fan mpFtPosX->Show();
5735d39f272SZheng Fan mpMtrPosX->Show();
5745d39f272SZheng Fan mpFtPosY->Show();
5755d39f272SZheng Fan mpMtrPosY->Show();
5765d39f272SZheng Fan
5775d39f272SZheng Fan //rotation
5785d39f272SZheng Fan mpFtAngle->Hide();
5795d39f272SZheng Fan mpMtrAngle->Hide();
5805d39f272SZheng Fan mpDial->Hide();
5815d39f272SZheng Fan
5825d39f272SZheng Fan //flip
5835d39f272SZheng Fan mpFlipTbx->Hide();
5845d39f272SZheng Fan mpFtFlip->Hide();
5855d39f272SZheng Fan mbIsFlip = false;
5865d39f272SZheng Fan
587d74d90d6SArmin Le Grand AdaptWidthHeightScalePosition(true);
588d74d90d6SArmin Le Grand AdaptAngleFlipDialPosition(true);
589d74d90d6SArmin Le Grand
5905d39f272SZheng Fan Size aSize(GetOutputSizePixel().Width(),PS_SECTIONPAGE_HEIGHT4);
5915d39f272SZheng Fan aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
5925d39f272SZheng Fan SetSizePixel(aSize);
59337fee4fdSAndre Fischer if (mxSidebar.is())
59437fee4fdSAndre Fischer mxSidebar->requestLayout();
5955d39f272SZheng Fan }
5965d39f272SZheng Fan break;
5975d39f272SZheng Fan }
5985d39f272SZheng Fan
5995d39f272SZheng Fan //Added for windows classic theme
6005d39f272SZheng Fan mpFlipTbx->SetBackground(Wallpaper());
6015d39f272SZheng Fan mpFlipTbx->SetPaintTransparent(true);
6025d39f272SZheng Fan }
6035d39f272SZheng Fan
6045d39f272SZheng Fan
6055d39f272SZheng Fan
6068a383445SArmin Le Grand IMPL_LINK( PosSizePropertyPanel, ChangeWidthHdl, void*, /*pBox*/ )
6075d39f272SZheng Fan {
6085d39f272SZheng Fan if( mpCbxScale->IsChecked() &&
6095d39f272SZheng Fan mpCbxScale->IsEnabled() )
6105d39f272SZheng Fan {
6115d39f272SZheng Fan long nHeight = (long) ( ((double) mlOldHeight * (double) mpMtrWidth->GetValue()) / (double) mlOldWidth );
6125d39f272SZheng Fan if( nHeight <= mpMtrHeight->GetMax( FUNIT_NONE ) )
6135d39f272SZheng Fan {
6145d39f272SZheng Fan mpMtrHeight->SetUserValue( nHeight, FUNIT_NONE );
6155d39f272SZheng Fan }
6165d39f272SZheng Fan else
6175d39f272SZheng Fan {
6185d39f272SZheng Fan nHeight = (long)mpMtrHeight->GetMax( FUNIT_NONE );
6195d39f272SZheng Fan mpMtrHeight->SetUserValue( nHeight );
6205d39f272SZheng Fan const long nWidth = (long) ( ((double) mlOldWidth * (double) nHeight) / (double) mlOldHeight );
6215d39f272SZheng Fan mpMtrWidth->SetUserValue( nWidth, FUNIT_NONE );
6225d39f272SZheng Fan }
6235d39f272SZheng Fan }
6245d39f272SZheng Fan executeSize();
6255d39f272SZheng Fan return 0;
6265d39f272SZheng Fan }
6275d39f272SZheng Fan
6285d39f272SZheng Fan
6295d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,ChangeHeightHdl,void *,EMPTYARG)6305d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ChangeHeightHdl, void *, EMPTYARG )
6315d39f272SZheng Fan {
6325d39f272SZheng Fan if( mpCbxScale->IsChecked() &&
6335d39f272SZheng Fan mpCbxScale->IsEnabled() )
6345d39f272SZheng Fan {
6355d39f272SZheng Fan long nWidth = (long) ( ((double)mlOldWidth * (double)mpMtrHeight->GetValue()) / (double)mlOldHeight );
6365d39f272SZheng Fan if( nWidth <= mpMtrWidth->GetMax( FUNIT_NONE ) )
6375d39f272SZheng Fan {
6385d39f272SZheng Fan mpMtrWidth->SetUserValue( nWidth, FUNIT_NONE );
6395d39f272SZheng Fan }
6405d39f272SZheng Fan else
6415d39f272SZheng Fan {
6425d39f272SZheng Fan nWidth = (long)mpMtrWidth->GetMax( FUNIT_NONE );
6435d39f272SZheng Fan mpMtrWidth->SetUserValue( nWidth );
6445d39f272SZheng Fan const long nHeight = (long) ( ((double)mlOldHeight * (double)nWidth) / (double)mlOldWidth );
6455d39f272SZheng Fan mpMtrHeight->SetUserValue( nHeight, FUNIT_NONE );
6465d39f272SZheng Fan }
6475d39f272SZheng Fan }
6485d39f272SZheng Fan executeSize();
6495d39f272SZheng Fan return 0;
6505d39f272SZheng Fan }
6515d39f272SZheng Fan
6525d39f272SZheng Fan
6535d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,ChangePosXHdl,void *,EMPTYARG)6545d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ChangePosXHdl, void *, EMPTYARG )
6555d39f272SZheng Fan {
6565d39f272SZheng Fan executePosX();
6575d39f272SZheng Fan return 0;
6585d39f272SZheng Fan }
6595d39f272SZheng Fan
6605d39f272SZheng Fan
6615d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,ChangePosYHdl,void *,EMPTYARG)6625d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ChangePosYHdl, void *, EMPTYARG )
6635d39f272SZheng Fan {
6645d39f272SZheng Fan executePosY();
6655d39f272SZheng Fan return 0;
6665d39f272SZheng Fan }
6675d39f272SZheng Fan
6685d39f272SZheng Fan
6695d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,ClickAutoHdl,void *,EMPTYARG)6705d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, ClickAutoHdl, void *, EMPTYARG )
6715d39f272SZheng Fan {
6725d39f272SZheng Fan if ( mpCbxScale->IsChecked() )
6735d39f272SZheng Fan {
6745d39f272SZheng Fan mlOldWidth = Max( GetCoreValue( *mpMtrWidth, mePoolUnit ), 1L );
6755d39f272SZheng Fan mlOldHeight = Max( GetCoreValue( *mpMtrHeight, mePoolUnit ), 1L );
6765d39f272SZheng Fan }
6775d39f272SZheng Fan
6785d39f272SZheng Fan // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
6795d39f272SZheng Fan SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
6805d39f272SZheng Fan aPageOpt.SetUserItem( USERITEM_NAME, ::com::sun::star::uno::makeAny( ::rtl::OUString( String::CreateFromInt32( mpCbxScale->IsChecked() ) ) ) );
6815d39f272SZheng Fan
6825d39f272SZheng Fan return 0;
6835d39f272SZheng Fan }
6845d39f272SZheng Fan
6855d39f272SZheng Fan
6865d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,AngleModifiedHdl,void *,EMPTYARG)6875d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
6885d39f272SZheng Fan {
6895d39f272SZheng Fan String sTmp = mpMtrAngle->GetText();
6905d39f272SZheng Fan bool bNegative = 0;
6915d39f272SZheng Fan sal_Unicode nChar = sTmp.GetChar( 0 );
6925d39f272SZheng Fan
6935d39f272SZheng Fan if( nChar == '-' )
6945d39f272SZheng Fan {
6955d39f272SZheng Fan bNegative = 1;
6965d39f272SZheng Fan nChar = sTmp.GetChar( 1 );
6975d39f272SZheng Fan }
6985d39f272SZheng Fan
6995d39f272SZheng Fan if( (nChar < '0') || (nChar > '9') )
7005d39f272SZheng Fan return 0;
7015d39f272SZheng Fan double dTmp = sTmp.ToDouble();
7025d39f272SZheng Fan if(bNegative)
7035d39f272SZheng Fan {
7045d39f272SZheng Fan while(dTmp<0)
7055d39f272SZheng Fan dTmp += 360;
7065d39f272SZheng Fan }
7075d39f272SZheng Fan sal_Int64 nTmp = dTmp*100;
7085d39f272SZheng Fan
709a2565cdfSArmin Le Grand // #123993# Need to take UIScale into account when executing rotations
710a2565cdfSArmin Le Grand const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0);
7115d39f272SZheng Fan SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp);
712a2565cdfSArmin Le Grand SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * fUIScale));
713a2565cdfSArmin Le Grand SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * fUIScale));
7145d39f272SZheng Fan
7155d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(
7165d39f272SZheng Fan SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aAngleItem, &aRotXItem, &aRotYItem, 0L );
7175d39f272SZheng Fan
7185d39f272SZheng Fan return 0;
7195d39f272SZheng Fan }
7205d39f272SZheng Fan
7215d39f272SZheng Fan
7225d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,RotationHdl,void *,EMPTYARG)7235d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, RotationHdl, void *, EMPTYARG )
7245d39f272SZheng Fan {
7255d39f272SZheng Fan sal_Int32 nTmp = mpDial->GetRotation();
7265d39f272SZheng Fan
727a2565cdfSArmin Le Grand // #123993# Need to take UIScale into account when executing rotations
728a2565cdfSArmin Le Grand const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0);
7295d39f272SZheng Fan SfxInt32Item aAngleItem( SID_ATTR_TRANSFORM_ANGLE,(sal_uInt32) nTmp);
730a2565cdfSArmin Le Grand SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * fUIScale));
731a2565cdfSArmin Le Grand SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * fUIScale));
7325d39f272SZheng Fan
7335d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(
7345d39f272SZheng Fan SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aAngleItem, &aRotXItem, &aRotYItem, 0L );
7355d39f272SZheng Fan
7365d39f272SZheng Fan return 0;
7375d39f272SZheng Fan }
7385d39f272SZheng Fan
7395d39f272SZheng Fan
7405d39f272SZheng Fan
IMPL_LINK(PosSizePropertyPanel,FlipHdl,ToolBox *,pBox)7415d39f272SZheng Fan IMPL_LINK( PosSizePropertyPanel, FlipHdl, ToolBox*, pBox )
7425d39f272SZheng Fan {
7435d39f272SZheng Fan switch (pBox->GetCurItemId())
7445d39f272SZheng Fan {
7455d39f272SZheng Fan case FLIP_HORIZONTAL:
7465d39f272SZheng Fan {
7475d39f272SZheng Fan SfxVoidItem aHoriItem (SID_FLIP_HORIZONTAL);
7485d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(
7495d39f272SZheng Fan SID_FLIP_HORIZONTAL, SFX_CALLMODE_RECORD, &aHoriItem, 0L );
7505d39f272SZheng Fan }
7515d39f272SZheng Fan break;
7525d39f272SZheng Fan case FLIP_VERTICAL:
7535d39f272SZheng Fan {
7545d39f272SZheng Fan SfxVoidItem aVertItem (SID_FLIP_VERTICAL );
7555d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(
7565d39f272SZheng Fan SID_FLIP_VERTICAL, SFX_CALLMODE_RECORD, &aVertItem, 0L );
7575d39f272SZheng Fan }
7585d39f272SZheng Fan break;
7595d39f272SZheng Fan }
7605d39f272SZheng Fan return 0;
7615d39f272SZheng Fan }
7625d39f272SZheng Fan
7635d39f272SZheng Fan
7645d39f272SZheng Fan
NotifyItemUpdate(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState,const bool)7655d39f272SZheng Fan void PosSizePropertyPanel::NotifyItemUpdate(
7665d39f272SZheng Fan sal_uInt16 nSID,
7675d39f272SZheng Fan SfxItemState eState,
76845da7d5eSAndre Fischer const SfxPoolItem* pState,
76906ccb52fSPavel Janík const bool /* bIsEnabled */)
7705d39f272SZheng Fan {
7715d39f272SZheng Fan mpFtAngle->Enable();
7725d39f272SZheng Fan mpMtrAngle->Enable();
7735d39f272SZheng Fan mpDial->Enable();
7745d39f272SZheng Fan mpFtFlip->Enable();
7755d39f272SZheng Fan mpFlipTbx->Enable();
7765d39f272SZheng Fan
7775d39f272SZheng Fan const SfxUInt32Item* pWidthItem;
7785d39f272SZheng Fan const SfxUInt32Item* pHeightItem;
7795d39f272SZheng Fan
7805d39f272SZheng Fan SfxViewShell* pCurSh = SfxViewShell::Current();
7815d39f272SZheng Fan if ( pCurSh )
7825d39f272SZheng Fan mpView = pCurSh->GetDrawView();
7835d39f272SZheng Fan else
7845d39f272SZheng Fan mpView = NULL;
7855d39f272SZheng Fan
7865d39f272SZheng Fan if ( mpView == NULL )
7875d39f272SZheng Fan return;
7885d39f272SZheng Fan
789eefa0d2bSArmin Le Grand mbAdjustEnabled = hasText(*mpView);
7905d39f272SZheng Fan
79190d0dc26SAndre Fischer // Pool unit and dialog unit may have changed, make sure that we
79290d0dc26SAndre Fischer // have the current values.
79390d0dc26SAndre Fischer mePoolUnit = maTransfWidthControl.GetCoreMetric();
7946acc8afaSArmin Le Grand
7956acc8afaSArmin Le Grand // #124409# do not change; GetModuleFieldUnit uses SfxModule::GetCurrentFieldUnit()
7966acc8afaSArmin Le Grand // which uses GetActiveModule() and if no items are set there (which is the case e.g.
7976acc8afaSArmin Le Grand // for writer), will just return the system fallback of FUNIT_INCH which is wrong.
798*49333635SJohn Bampton // Anyways, with multiple open views the static call GetActiveModule is ambiguous
7996acc8afaSArmin Le Grand //
8006acc8afaSArmin Le Grand // meDlgUnit = GetModuleFieldUnit();
80190d0dc26SAndre Fischer
8025d39f272SZheng Fan switch (nSID)
8035d39f272SZheng Fan {
8045d39f272SZheng Fan case SID_ATTR_TRANSFORM_WIDTH:
8055d39f272SZheng Fan if ( SFX_ITEM_AVAILABLE == eState )
8065d39f272SZheng Fan {
8075d39f272SZheng Fan pWidthItem = dynamic_cast< const SfxUInt32Item* >(pState);
8085d39f272SZheng Fan
8095d39f272SZheng Fan if(pWidthItem)
8105d39f272SZheng Fan {
8115d39f272SZheng Fan long mlOldWidth1 = pWidthItem->GetValue();
8125d39f272SZheng Fan
8135d39f272SZheng Fan mlOldWidth1 = Fraction( mlOldWidth1 ) / maUIScale;
81490d0dc26SAndre Fischer SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
8155d39f272SZheng Fan SetMetricValue( *mpMtrWidth, mlOldWidth1, mePoolUnit );
8165d39f272SZheng Fan mlOldWidth = mlOldWidth1;
817da72173fSAndre Fischer break;
8185d39f272SZheng Fan }
8195d39f272SZheng Fan }
820da72173fSAndre Fischer
8215d39f272SZheng Fan mpMtrWidth->SetText( String());
8225d39f272SZheng Fan break;
8235d39f272SZheng Fan
8245d39f272SZheng Fan case SID_ATTR_TRANSFORM_HEIGHT:
8255d39f272SZheng Fan if ( SFX_ITEM_AVAILABLE == eState )
8265d39f272SZheng Fan {
8275d39f272SZheng Fan pHeightItem = dynamic_cast< const SfxUInt32Item* >(pState);
8285d39f272SZheng Fan
8295d39f272SZheng Fan if(pHeightItem)
8305d39f272SZheng Fan {
8315d39f272SZheng Fan long mlOldHeight1 = pHeightItem->GetValue();
8325d39f272SZheng Fan
8335d39f272SZheng Fan mlOldHeight1 = Fraction( mlOldHeight1 ) / maUIScale;
83490d0dc26SAndre Fischer SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
8355d39f272SZheng Fan SetMetricValue( *mpMtrHeight, mlOldHeight1, mePoolUnit );
8365d39f272SZheng Fan mlOldHeight = mlOldHeight1;
837da72173fSAndre Fischer break;
8385d39f272SZheng Fan }
8395d39f272SZheng Fan }
840da72173fSAndre Fischer
8415d39f272SZheng Fan mpMtrHeight->SetText( String());
8425d39f272SZheng Fan break;
8435d39f272SZheng Fan
8445d39f272SZheng Fan case SID_ATTR_TRANSFORM_POS_X:
845da72173fSAndre Fischer if(SFX_ITEM_AVAILABLE == eState)
8465d39f272SZheng Fan {
8475d39f272SZheng Fan const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
8485d39f272SZheng Fan
849da72173fSAndre Fischer if(pItem)
8505d39f272SZheng Fan {
8515d39f272SZheng Fan long nTmp = pItem->GetValue();
8525d39f272SZheng Fan nTmp = Fraction( nTmp ) / maUIScale;
85390d0dc26SAndre Fischer SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
8545d39f272SZheng Fan SetMetricValue( *mpMtrPosX, nTmp, mePoolUnit );
8555d39f272SZheng Fan break;
8565d39f272SZheng Fan }
857da72173fSAndre Fischer }
858da72173fSAndre Fischer
859da72173fSAndre Fischer mpMtrPosX->SetText( String());
860da72173fSAndre Fischer break;
8615d39f272SZheng Fan
8625d39f272SZheng Fan case SID_ATTR_TRANSFORM_POS_Y:
863da72173fSAndre Fischer if(SFX_ITEM_AVAILABLE == eState)
8645d39f272SZheng Fan {
8655d39f272SZheng Fan const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
8665d39f272SZheng Fan
867da72173fSAndre Fischer if(pItem)
8685d39f272SZheng Fan {
8695d39f272SZheng Fan long nTmp = pItem->GetValue();
8705d39f272SZheng Fan nTmp = Fraction( nTmp ) / maUIScale;
87190d0dc26SAndre Fischer SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
8725d39f272SZheng Fan SetMetricValue( *mpMtrPosY, nTmp, mePoolUnit );
8735d39f272SZheng Fan break;
8745d39f272SZheng Fan }
875da72173fSAndre Fischer }
876da72173fSAndre Fischer
877da72173fSAndre Fischer mpMtrPosY->SetText( String());
878da72173fSAndre Fischer break;
8795d39f272SZheng Fan
8805d39f272SZheng Fan case SID_ATTR_TRANSFORM_ROT_X:
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 mlRotX = pItem->GetValue();
8885d39f272SZheng Fan mlRotX = Fraction( mlRotX ) / maUIScale;
8895d39f272SZheng Fan }
890da72173fSAndre Fischer }
8915d39f272SZheng Fan break;
8925d39f272SZheng Fan
8935d39f272SZheng Fan case SID_ATTR_TRANSFORM_ROT_Y:
8945d39f272SZheng Fan if (SFX_ITEM_AVAILABLE == eState)
8955d39f272SZheng Fan {
896da72173fSAndre Fischer const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
897da72173fSAndre Fischer
898da72173fSAndre Fischer if(pItem)
899da72173fSAndre Fischer {
900da72173fSAndre Fischer mlRotY = pItem->GetValue();
9015d39f272SZheng Fan mlRotY = Fraction( mlRotY ) / maUIScale;
9025d39f272SZheng Fan }
903da72173fSAndre Fischer }
9045d39f272SZheng Fan break;
9055d39f272SZheng Fan
9065d39f272SZheng Fan case SID_ATTR_TRANSFORM_PROTECT_POS:
907da72173fSAndre Fischer if(SFX_ITEM_AVAILABLE == eState)
9085d39f272SZheng Fan {
9095d39f272SZheng Fan const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9105d39f272SZheng Fan
911da72173fSAndre Fischer if(pItem)
9125d39f272SZheng Fan {
9135d39f272SZheng Fan // record the state of position protect
9145d39f272SZheng Fan mbPositionProtected = pItem->GetValue();
9155d39f272SZheng Fan break;
9165d39f272SZheng Fan }
917da72173fSAndre Fischer }
918da72173fSAndre Fischer
919da72173fSAndre Fischer mbPositionProtected = false;
920da72173fSAndre Fischer break;
9215d39f272SZheng Fan
9225d39f272SZheng Fan case SID_ATTR_TRANSFORM_PROTECT_SIZE:
923da72173fSAndre Fischer if(SFX_ITEM_AVAILABLE == eState)
9245d39f272SZheng Fan {
9255d39f272SZheng Fan const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9265d39f272SZheng Fan
927da72173fSAndre Fischer if(pItem)
9285d39f272SZheng Fan {
9295d39f272SZheng Fan // record the state of size protect
9305d39f272SZheng Fan mbSizeProtected = pItem->GetValue();
9315d39f272SZheng Fan break;
9325d39f272SZheng Fan }
933da72173fSAndre Fischer }
934da72173fSAndre Fischer
935da72173fSAndre Fischer mbSizeProtected = false;
936da72173fSAndre Fischer break;
9375d39f272SZheng Fan
9385d39f272SZheng Fan case SID_ATTR_TRANSFORM_AUTOWIDTH:
939da72173fSAndre Fischer if(SFX_ITEM_AVAILABLE == eState)
9405d39f272SZheng Fan {
9415d39f272SZheng Fan const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9425d39f272SZheng Fan
943da72173fSAndre Fischer if(pItem)
9445d39f272SZheng Fan {
9455d39f272SZheng Fan mbAutoWidth = pItem->GetValue();
9465d39f272SZheng Fan }
9475d39f272SZheng Fan }
948da72173fSAndre Fischer break;
9495d39f272SZheng Fan
9505d39f272SZheng Fan case SID_ATTR_TRANSFORM_AUTOHEIGHT:
951da72173fSAndre Fischer if(SFX_ITEM_AVAILABLE == eState)
9525d39f272SZheng Fan {
9535d39f272SZheng Fan const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
9545d39f272SZheng Fan
955da72173fSAndre Fischer if(pItem)
9565d39f272SZheng Fan {
9575d39f272SZheng Fan mbAutoHeight = pItem->GetValue();
9585d39f272SZheng Fan }
9595d39f272SZheng Fan }
960da72173fSAndre Fischer break;
9615d39f272SZheng Fan
9625d39f272SZheng Fan case SID_ATTR_TRANSFORM_ANGLE:
9635d39f272SZheng Fan if (eState >= SFX_ITEM_AVAILABLE)
9645d39f272SZheng Fan {
965da72173fSAndre Fischer const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >(pState);
966da72173fSAndre Fischer
967da72173fSAndre Fischer if(pItem)
968da72173fSAndre Fischer {
969da72173fSAndre Fischer long nTmp = pItem->GetValue();
970da72173fSAndre Fischer
9715d39f272SZheng Fan mpMtrAngle->SetValue( nTmp );
9725d39f272SZheng Fan mpDial->SetRotation( nTmp );
973da72173fSAndre Fischer
9745d39f272SZheng Fan switch(nTmp)
9755d39f272SZheng Fan {
9765d39f272SZheng Fan case 0:
9775d39f272SZheng Fan mpMtrAngle->SelectEntryPos(0);
9785d39f272SZheng Fan break;
9795d39f272SZheng Fan case 4500:
9805d39f272SZheng Fan mpMtrAngle->SelectEntryPos(1);
9815d39f272SZheng Fan break;
9825d39f272SZheng Fan case 9000:
9835d39f272SZheng Fan mpMtrAngle->SelectEntryPos(2);
9845d39f272SZheng Fan break;
9855d39f272SZheng Fan case 13500:
9865d39f272SZheng Fan mpMtrAngle->SelectEntryPos(3);
9875d39f272SZheng Fan break;
9885d39f272SZheng Fan case 18000:
9895d39f272SZheng Fan mpMtrAngle->SelectEntryPos(4);
9905d39f272SZheng Fan break;
9915d39f272SZheng Fan case 22500:
9925d39f272SZheng Fan mpMtrAngle->SelectEntryPos(5);
9935d39f272SZheng Fan break;
9945d39f272SZheng Fan case 27000:
9955d39f272SZheng Fan mpMtrAngle->SelectEntryPos(6);
9965d39f272SZheng Fan break;
9975d39f272SZheng Fan case 315000:
9985d39f272SZheng Fan mpMtrAngle->SelectEntryPos(7);
99987ab04d0SAndre Fischer break;
10005d39f272SZheng Fan }
1001da72173fSAndre Fischer
1002da72173fSAndre Fischer break;
10035d39f272SZheng Fan }
1004da72173fSAndre Fischer }
1005da72173fSAndre Fischer
10065d39f272SZheng Fan mpMtrAngle->SetText( String() );
10075d39f272SZheng Fan mpDial->SetRotation( 0 );
10085d39f272SZheng Fan break;
10095d39f272SZheng Fan
10105d39f272SZheng Fan case SID_ATTR_METRIC:
10115d39f272SZheng Fan MetricState( eState, pState );
10125f79b2b9SAndre Fischer UpdateUIScale();
10135d39f272SZheng Fan break;
10145d39f272SZheng Fan
10155d39f272SZheng Fan default:
10165d39f272SZheng Fan break;
10175d39f272SZheng Fan }
10185d39f272SZheng Fan
10195d39f272SZheng Fan const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
1020eefa0d2bSArmin Le Grand const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
10215d39f272SZheng Fan
10225d39f272SZheng Fan switch (rMarkList.GetMarkCount())
10235d39f272SZheng Fan {
10245d39f272SZheng Fan case 0:
10255d39f272SZheng Fan break;
10265d39f272SZheng Fan
10275d39f272SZheng Fan case 1:
10285d39f272SZheng Fan {
10295d39f272SZheng Fan const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
10305d39f272SZheng Fan const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
10315d39f272SZheng Fan
10325d39f272SZheng Fan if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
10335d39f272SZheng Fan || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
10345d39f272SZheng Fan ) && OBJ_EDGE == eKind)
10355d39f272SZheng Fan || OBJ_CAPTION == eKind)
10365d39f272SZheng Fan {
10375d39f272SZheng Fan mpFtAngle->Disable();
10385d39f272SZheng Fan mpMtrAngle->Disable();
10395d39f272SZheng Fan mpDial->Disable();
10405d39f272SZheng Fan mpFlipTbx->Disable();
10415d39f272SZheng Fan mpFtFlip->Disable();
10425d39f272SZheng Fan }
10435d39f272SZheng Fan break;
10445d39f272SZheng Fan }
10455d39f272SZheng Fan
10465d39f272SZheng Fan default:
10475d39f272SZheng Fan {
10485d39f272SZheng Fan sal_uInt16 nMarkObj = 0;
10495d39f272SZheng Fan bool isNoEdge = true;
1050d74d90d6SArmin Le Grand
1051d74d90d6SArmin Le Grand while(isNoEdge && rMarkList.GetMark(nMarkObj))
10525d39f272SZheng Fan {
10535d39f272SZheng Fan const SdrObject* pObj = rMarkList.GetMark(nMarkObj)->GetMarkedSdrObj();
10545d39f272SZheng Fan const SdrObjKind eKind((SdrObjKind)pObj->GetObjIdentifier());
10555d39f272SZheng Fan
10565d39f272SZheng Fan if(((nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_Draw)
10575d39f272SZheng Fan || nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject)
10585d39f272SZheng Fan ) && OBJ_EDGE == eKind)
10595d39f272SZheng Fan || OBJ_CAPTION == eKind)
10605d39f272SZheng Fan {
10615d39f272SZheng Fan isNoEdge = false;
10625d39f272SZheng Fan break;
10635d39f272SZheng Fan }
10645d39f272SZheng Fan nMarkObj++;
10655d39f272SZheng Fan }
1066d74d90d6SArmin Le Grand
10675d39f272SZheng Fan if(!isNoEdge)
10685d39f272SZheng Fan {
10695d39f272SZheng Fan mpFtAngle->Disable();
10705d39f272SZheng Fan mpMtrAngle->Disable();
10715d39f272SZheng Fan mpDial->Disable();
10725d39f272SZheng Fan mpFlipTbx->Disable();
10735d39f272SZheng Fan mpFtFlip->Disable();
10745d39f272SZheng Fan }
10755d39f272SZheng Fan break;
10765d39f272SZheng Fan }
10775d39f272SZheng Fan }
10785d39f272SZheng Fan
10795d39f272SZheng Fan if(nCombinedContext == CombinedEnumContext(Application_DrawImpress, Context_TextObject))
10805d39f272SZheng Fan {
10815d39f272SZheng Fan mpFlipTbx->Disable();
10825d39f272SZheng Fan mpFtFlip->Disable();
10835d39f272SZheng Fan }
10845d39f272SZheng Fan
10855d39f272SZheng Fan DisableControls();
10865d39f272SZheng Fan
10875d39f272SZheng Fan // mpCbxScale must synchronized with that on Position and Size tabpage on Shape Properties dialog
10885d39f272SZheng Fan SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( RID_SVXPAGE_POSITION_SIZE ) );
10895d39f272SZheng Fan String sUserData;
10905d39f272SZheng Fan ::com::sun::star::uno::Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
10915d39f272SZheng Fan ::rtl::OUString aTemp;
10925d39f272SZheng Fan if ( aUserItem >>= aTemp )
10935d39f272SZheng Fan sUserData = String( aTemp );
10945d39f272SZheng Fan mpCbxScale->Check( (bool)sUserData.ToInt32() );
10955d39f272SZheng Fan }
10965d39f272SZheng Fan
10975d39f272SZheng Fan
10985d39f272SZheng Fan
109945da7d5eSAndre Fischer
GetBindings()11005d39f272SZheng Fan SfxBindings* PosSizePropertyPanel::GetBindings()
11015d39f272SZheng Fan {
11025d39f272SZheng Fan return mpBindings;
11035d39f272SZheng Fan }
11045d39f272SZheng Fan
11055d39f272SZheng Fan
11065d39f272SZheng Fan
executeSize()11075d39f272SZheng Fan void PosSizePropertyPanel::executeSize()
11085d39f272SZheng Fan {
11095d39f272SZheng Fan if ( mpMtrWidth->IsValueModified() || mpMtrHeight->IsValueModified())
11105d39f272SZheng Fan {
11115d39f272SZheng Fan Fraction aUIScale = mpView->GetModel()->GetUIScale();
11125d39f272SZheng Fan
11135d39f272SZheng Fan // get Width
11145d39f272SZheng Fan double nWidth = (double)mpMtrWidth->GetValue( meDlgUnit );
11155d39f272SZheng Fan nWidth = MetricField::ConvertDoubleValue( nWidth, mpMtrWidth->GetBaseValue(), mpMtrWidth->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
11165d39f272SZheng Fan long lWidth = (long)(nWidth * (double)aUIScale);
11175d39f272SZheng Fan lWidth = OutputDevice::LogicToLogic( lWidth, MAP_100TH_MM, (MapUnit)mePoolUnit );
11185d39f272SZheng Fan lWidth = (long)mpMtrWidth->Denormalize( lWidth );
11195d39f272SZheng Fan
11205d39f272SZheng Fan // get Height
11215d39f272SZheng Fan double nHeight = (double)mpMtrHeight->GetValue( meDlgUnit );
11225d39f272SZheng Fan nHeight = MetricField::ConvertDoubleValue( nHeight, mpMtrHeight->GetBaseValue(), mpMtrHeight->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
11235d39f272SZheng Fan long lHeight = (long)(nHeight * (double)aUIScale);
11245d39f272SZheng Fan lHeight = OutputDevice::LogicToLogic( lHeight, MAP_100TH_MM, (MapUnit)mePoolUnit );
11255d39f272SZheng Fan lHeight = (long)mpMtrWidth->Denormalize( lHeight );
11265d39f272SZheng Fan
11275d39f272SZheng Fan // put Width & Height to itemset
11285d39f272SZheng Fan SfxUInt32Item aWidthItem( SID_ATTR_TRANSFORM_WIDTH, (sal_uInt32) lWidth);
11295d39f272SZheng Fan SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT, (sal_uInt32) lHeight);
11305d39f272SZheng Fan SfxAllEnumItem aPointItem (SID_ATTR_TRANSFORM_SIZE_POINT, (sal_uInt16)meRP);
11318eda4adfSOliver-Rainer Wittmann const sal_Int32 nCombinedContext(maContext.GetCombinedContext_DI());
11325d39f272SZheng Fan
11338eda4adfSOliver-Rainer Wittmann if( nCombinedContext == CombinedEnumContext(Application_WriterVariants, Context_Graphic)
11348eda4adfSOliver-Rainer Wittmann || nCombinedContext == CombinedEnumContext(Application_WriterVariants, Context_OLE)
11355d39f272SZheng Fan )
11365d39f272SZheng Fan {
11375d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
11385d39f272SZheng Fan }
11395d39f272SZheng Fan else
11405d39f272SZheng Fan {
11415d39f272SZheng Fan if ( (mpMtrWidth->IsValueModified()) && (mpMtrHeight->IsValueModified()))
11425d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aHeightItem, &aPointItem, 0L );
11435d39f272SZheng Fan else if( mpMtrWidth->IsValueModified())
11445d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aWidthItem, &aPointItem, 0L );
11455d39f272SZheng Fan else if ( mpMtrHeight->IsValueModified())
11465d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aHeightItem, &aPointItem, 0L );
11475d39f272SZheng Fan }
11485d39f272SZheng Fan }
11495d39f272SZheng Fan }
11505d39f272SZheng Fan
11515d39f272SZheng Fan
11525d39f272SZheng Fan
executePosX()11535d39f272SZheng Fan void PosSizePropertyPanel::executePosX()
11545d39f272SZheng Fan {
11555d39f272SZheng Fan if ( mpMtrPosX->IsValueModified())
11565d39f272SZheng Fan {
11575d39f272SZheng Fan long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
11585d39f272SZheng Fan if( mbMtrPosXMirror )
11595d39f272SZheng Fan lX = -lX;
11605d39f272SZheng Fan long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
11615d39f272SZheng Fan
11625d39f272SZheng Fan Size aPageSize;
11635d39f272SZheng Fan Rectangle aRect;
11645d39f272SZheng Fan maRect = mpView->GetAllMarkedRect();
11655d39f272SZheng Fan aRect = mpView->GetAllMarkedRect();
11665d39f272SZheng Fan
11675d39f272SZheng Fan Fraction aUIScale = mpView->GetModel()->GetUIScale();
11685d39f272SZheng Fan lX += maAnchorPos.X();
11695d39f272SZheng Fan lX = Fraction( lX ) * aUIScale;
11705d39f272SZheng Fan lY += maAnchorPos.Y();
11715d39f272SZheng Fan lY = Fraction( lY ) * aUIScale;
11725d39f272SZheng Fan
11735d39f272SZheng Fan SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
11745d39f272SZheng Fan SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
11755d39f272SZheng Fan
11765d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(
11775d39f272SZheng Fan SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosXItem, 0L );
11785d39f272SZheng Fan }
11795d39f272SZheng Fan }
11805d39f272SZheng Fan
11815d39f272SZheng Fan
11825d39f272SZheng Fan
executePosY()11835d39f272SZheng Fan void PosSizePropertyPanel::executePosY()
11845d39f272SZheng Fan {
11855d39f272SZheng Fan if ( mpMtrPosY->IsValueModified() )
11865d39f272SZheng Fan {
11875d39f272SZheng Fan long lX = GetCoreValue( *mpMtrPosX, mePoolUnit );
11885d39f272SZheng Fan long lY = GetCoreValue( *mpMtrPosY, mePoolUnit );
11895d39f272SZheng Fan
11905d39f272SZheng Fan Size aPageSize;
11915d39f272SZheng Fan Rectangle aRect;
11925d39f272SZheng Fan maRect = mpView->GetAllMarkedRect();
11935d39f272SZheng Fan aRect = mpView->GetAllMarkedRect();
11945d39f272SZheng Fan
11955d39f272SZheng Fan Fraction aUIScale = mpView->GetModel()->GetUIScale();
11965d39f272SZheng Fan lX += maAnchorPos.X();
11975d39f272SZheng Fan lX = Fraction( lX ) * aUIScale;
11985d39f272SZheng Fan lY += maAnchorPos.Y();
11995d39f272SZheng Fan lY = Fraction( lY ) * aUIScale;
12005d39f272SZheng Fan
12015d39f272SZheng Fan SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX);
12025d39f272SZheng Fan SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY);
12035d39f272SZheng Fan
12045d39f272SZheng Fan GetBindings()->GetDispatcher()->Execute(
12055d39f272SZheng Fan SID_ATTR_TRANSFORM, SFX_CALLMODE_RECORD, &aPosYItem, 0L );
12065d39f272SZheng Fan }
12075d39f272SZheng Fan }
12085d39f272SZheng Fan
12095d39f272SZheng Fan
12105d39f272SZheng Fan
MetricState(SfxItemState eState,const SfxPoolItem * pState)12115d39f272SZheng Fan void PosSizePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
12125d39f272SZheng Fan {
12135d39f272SZheng Fan bool bPosXBlank = false;
12145d39f272SZheng Fan bool bPosYBlank = false;
12155d39f272SZheng Fan bool bWidthBlank = false;
12165d39f272SZheng Fan bool bHeightBlank = false;
12175d39f272SZheng Fan String sNull = String::CreateFromAscii("");
12186acc8afaSArmin Le Grand
12196acc8afaSArmin Le Grand // #124409# use the given Item to get the correct UI unit and initialize it
12206acc8afaSArmin Le Grand // and the Fields using it
12215d39f272SZheng Fan meDlgUnit = GetCurrentUnit(eState,pState);
12225d39f272SZheng Fan
12235d39f272SZheng Fan if( mpMtrPosX->GetText() == sNull )
12245d39f272SZheng Fan bPosXBlank = true;
12255d39f272SZheng Fan SetFieldUnit( *mpMtrPosX, meDlgUnit, true );
12265d39f272SZheng Fan if(bPosXBlank)
12275d39f272SZheng Fan mpMtrPosX->SetText(String());
12285d39f272SZheng Fan
12295d39f272SZheng Fan if( mpMtrPosY->GetText() == sNull )
12305d39f272SZheng Fan bPosYBlank = true;
12315d39f272SZheng Fan SetFieldUnit( *mpMtrPosY, meDlgUnit, true );
12325d39f272SZheng Fan if(bPosYBlank)
12335d39f272SZheng Fan mpMtrPosY->SetText(String());
12345d39f272SZheng Fan
12355d39f272SZheng Fan if( mpMtrWidth->GetText() == sNull )
12365d39f272SZheng Fan bWidthBlank = true;
12375d39f272SZheng Fan SetFieldUnit( *mpMtrWidth, meDlgUnit, true );
12385d39f272SZheng Fan if(bWidthBlank)
12395d39f272SZheng Fan mpMtrWidth->SetText(String());
12405d39f272SZheng Fan
12415d39f272SZheng Fan if( mpMtrHeight->GetText() == sNull )
12425d39f272SZheng Fan bHeightBlank = true;
12435d39f272SZheng Fan SetFieldUnit( *mpMtrHeight, meDlgUnit, true );
12445d39f272SZheng Fan if(bHeightBlank)
12455d39f272SZheng Fan mpMtrHeight->SetText(String());
12465d39f272SZheng Fan }
12475d39f272SZheng Fan
12485d39f272SZheng Fan
12495d39f272SZheng Fan
GetCurrentUnit(SfxItemState eState,const SfxPoolItem * pState)12505d39f272SZheng Fan FieldUnit PosSizePropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
12515d39f272SZheng Fan {
12525d39f272SZheng Fan FieldUnit eUnit = FUNIT_NONE;
12535d39f272SZheng Fan
12545d39f272SZheng Fan if ( pState && eState >= SFX_ITEM_DEFAULT )
1255a567bdc8SArmin Le Grand {
12565d39f272SZheng Fan eUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
1257a567bdc8SArmin Le Grand }
12585d39f272SZheng Fan else
12595d39f272SZheng Fan {
12605d39f272SZheng Fan SfxViewFrame* pFrame = SfxViewFrame::Current();
12615d39f272SZheng Fan SfxObjectShell* pSh = NULL;
12625d39f272SZheng Fan if ( pFrame )
12635d39f272SZheng Fan pSh = pFrame->GetObjectShell();
12645d39f272SZheng Fan if ( pSh )
12655d39f272SZheng Fan {
12665d39f272SZheng Fan SfxModule* pModule = pSh->GetModule();
12675d39f272SZheng Fan if ( pModule )
12685d39f272SZheng Fan {
12695d39f272SZheng Fan const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
12705d39f272SZheng Fan if ( pItem )
12715d39f272SZheng Fan eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
12725d39f272SZheng Fan }
12735d39f272SZheng Fan else
12745d39f272SZheng Fan {
12755d39f272SZheng Fan DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" );
12765d39f272SZheng Fan }
12775d39f272SZheng Fan }
12785d39f272SZheng Fan }
12795d39f272SZheng Fan
12805d39f272SZheng Fan return eUnit;
12815d39f272SZheng Fan }
12825d39f272SZheng Fan
12835d39f272SZheng Fan
12845d39f272SZheng Fan
DisableControls()12855d39f272SZheng Fan void PosSizePropertyPanel::DisableControls()
12865d39f272SZheng Fan {
12875d39f272SZheng Fan if( mbPositionProtected )
12885d39f272SZheng Fan {
12895d39f272SZheng Fan // the position is protected("Position protect" option in modal dialog is checked),
12905d39f272SZheng Fan // disable all the Position controls in sidebar
12915d39f272SZheng Fan mpFtPosX->Disable();
12925d39f272SZheng Fan mpMtrPosX->Disable();
12935d39f272SZheng Fan mpFtPosY->Disable();
12945d39f272SZheng Fan mpMtrPosY->Disable();
12955d39f272SZheng Fan mpFtAngle->Disable();
12965d39f272SZheng Fan mpMtrAngle->Disable();
12975d39f272SZheng Fan mpDial->Disable();
12985d39f272SZheng Fan mpFtFlip->Disable();
12995d39f272SZheng Fan mpFlipTbx->Disable();
13005d39f272SZheng Fan
13015d39f272SZheng Fan mpFtWidth->Disable();
13025d39f272SZheng Fan mpMtrWidth->Disable();
13035d39f272SZheng Fan mpFtHeight->Disable();
13045d39f272SZheng Fan mpMtrHeight->Disable();
13055d39f272SZheng Fan mpCbxScale->Disable();
13065d39f272SZheng Fan }
13075d39f272SZheng Fan else
13085d39f272SZheng Fan {
13095d39f272SZheng Fan mpFtPosX->Enable();
13105d39f272SZheng Fan mpMtrPosX->Enable();
13115d39f272SZheng Fan mpFtPosY->Enable();
13125d39f272SZheng Fan mpMtrPosY->Enable();
13135d39f272SZheng Fan
13145d39f272SZheng Fan //mpFtAngle->Enable();
13155d39f272SZheng Fan //mpMtrAngle->Enable();
13165d39f272SZheng Fan //mpDial->Enable();
13175d39f272SZheng Fan //mpFtFlip->Enable();
13185d39f272SZheng Fan //mpFlipTbx->Enable();
13195d39f272SZheng Fan
13205d39f272SZheng Fan if( mbSizeProtected )
13215d39f272SZheng Fan {
13225d39f272SZheng Fan mpFtWidth->Disable();
13235d39f272SZheng Fan mpMtrWidth->Disable();
13245d39f272SZheng Fan mpFtHeight->Disable();
13255d39f272SZheng Fan mpMtrHeight->Disable();
13265d39f272SZheng Fan mpCbxScale->Disable();
13275d39f272SZheng Fan }
13285d39f272SZheng Fan else
13295d39f272SZheng Fan {
13305d39f272SZheng Fan if( mbAdjustEnabled )
13315d39f272SZheng Fan {
13325d39f272SZheng Fan if( mbAutoWidth )
13335d39f272SZheng Fan {
13345d39f272SZheng Fan mpFtWidth->Disable();
13355d39f272SZheng Fan mpMtrWidth->Disable();
13365d39f272SZheng Fan mpCbxScale->Disable();
13375d39f272SZheng Fan }
13385d39f272SZheng Fan else
13395d39f272SZheng Fan {
13405d39f272SZheng Fan mpFtWidth->Enable();
13415d39f272SZheng Fan mpMtrWidth->Enable();
13425d39f272SZheng Fan }
13435d39f272SZheng Fan if( mbAutoHeight )
13445d39f272SZheng Fan {
13455d39f272SZheng Fan mpFtHeight->Disable();
13465d39f272SZheng Fan mpMtrHeight->Disable();
13475d39f272SZheng Fan mpCbxScale->Disable();
13485d39f272SZheng Fan }
13495d39f272SZheng Fan else
13505d39f272SZheng Fan {
13515d39f272SZheng Fan mpFtHeight->Enable();
13525d39f272SZheng Fan mpMtrHeight->Enable();
13535d39f272SZheng Fan }
13545d39f272SZheng Fan if( !mbAutoWidth && !mbAutoHeight )
13555d39f272SZheng Fan mpCbxScale->Enable();
13565d39f272SZheng Fan }
13575d39f272SZheng Fan else
13585d39f272SZheng Fan {
13595d39f272SZheng Fan mpFtWidth->Enable();
13605d39f272SZheng Fan mpMtrWidth->Enable();
13615d39f272SZheng Fan mpFtHeight->Enable();
13625d39f272SZheng Fan mpMtrHeight->Enable();
13635d39f272SZheng Fan mpCbxScale->Enable();
13645d39f272SZheng Fan }
13655d39f272SZheng Fan }
13665d39f272SZheng Fan }
13675d39f272SZheng Fan }
13685d39f272SZheng Fan
13695d39f272SZheng Fan
13705f79b2b9SAndre Fischer
13715f79b2b9SAndre Fischer
UpdateUIScale(void)13725f79b2b9SAndre Fischer void PosSizePropertyPanel::UpdateUIScale (void)
13735f79b2b9SAndre Fischer {
13745f79b2b9SAndre Fischer const Fraction aUIScale (mpView->GetModel()->GetUIScale());
13755f79b2b9SAndre Fischer if (maUIScale != aUIScale)
13765f79b2b9SAndre Fischer {
13775f79b2b9SAndre Fischer // UI scale has changed.
13785f79b2b9SAndre Fischer
13795f79b2b9SAndre Fischer // Remember the new UI scale.
13805f79b2b9SAndre Fischer maUIScale = aUIScale;
13815f79b2b9SAndre Fischer
13825f79b2b9SAndre Fischer // The content of the position and size boxes is only updated when item changes are notified.
13835f79b2b9SAndre Fischer // Request such notifications without changing the actual item values.
13845f79b2b9SAndre Fischer GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_X, sal_True, sal_False);
13855f79b2b9SAndre Fischer GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_Y, sal_True, sal_False);
13865f79b2b9SAndre Fischer GetBindings()->Invalidate(SID_ATTR_TRANSFORM_WIDTH, sal_True, sal_False);
13875f79b2b9SAndre Fischer GetBindings()->Invalidate(SID_ATTR_TRANSFORM_HEIGHT, sal_True, sal_False);
13885f79b2b9SAndre Fischer }
13895f79b2b9SAndre Fischer }
13905f79b2b9SAndre Fischer
13915f79b2b9SAndre Fischer
13925d39f272SZheng Fan } } // end of namespace svx::sidebar
13934e8031e0SArmin Le Grand
13944e8031e0SArmin Le Grand // eof
1395