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