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