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