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