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