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