1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_cui.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <sfx2/app.hxx> 33 #include <sfx2/module.hxx> 34 #include <tools/shl.hxx> 35 #include <cuires.hrc> 36 #include <svx/svddef.hxx> 37 #include <svx/sdtditm.hxx> 38 #include <svx/sdtagitm.hxx> 39 #include <svx/sdtaitm.hxx> 40 #include <svx/sdtfsitm.hxx> 41 #include <svx/sdtcfitm.hxx> 42 #include <svx/svdobj.hxx> 43 #include <svx/svdmark.hxx> 44 #include <svx/svdview.hxx> 45 #include <svx/svdotext.hxx> 46 #include <svx/dialogs.hrc> 47 48 #ifndef _SVX_TEXTATTR_CXX 49 #define _SVX_TEXTATTR_CXX 50 #endif 51 #include "textattr.hxx" 52 #include "textattr.hrc" 53 #include <dialmgr.hxx> 54 #include "svx/dlgutil.hxx" 55 #include <sfx2/request.hxx> //add CHINA001 56 #include <svx/ofaitem.hxx> //add CHINA001 57 #include <editeng/writingmodeitem.hxx> 58 59 static sal_uInt16 pRanges[] = 60 { 61 SDRATTR_MISC_FIRST, SDRATTR_TEXT_HORZADJUST, 62 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE, 63 0 64 }; 65 66 /************************************************************************* 67 |* 68 |* Dialog zum Kopieren von Objekten 69 |* 70 \************************************************************************/ 71 72 //CHINA001 SvxTextAttrDialog::SvxTextAttrDialog( Window* pParent, const SfxItemSet& rInAttrs, 73 //CHINA001 const SdrView* pSdrView ) : 74 //CHINA001 SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_TEXTATTR ) 75 //CHINA001 { 76 //CHINA001 SvxTextAttrPage* pPage = new SvxTextAttrPage( this, rInAttrs ); 77 //CHINA001 78 //CHINA001 pPage->SetView( pSdrView ); 79 //CHINA001 pPage->Construct(); 80 //CHINA001 81 //CHINA001 SetTabPage( pPage ); 82 //CHINA001 SetText( pPage->GetText() ); 83 //CHINA001 } 84 //CHINA001 85 /************************************************************************* 86 |* 87 |* Dtor 88 |* 89 \************************************************************************/ 90 91 //CHINA001 SvxTextAttrDialog::~SvxTextAttrDialog() 92 //CHINA001 { 93 //CHINA001 } 94 95 /************************************************************************* 96 |* 97 |* Dialog (Seite) zum Kopieren von Objekten 98 |* 99 \************************************************************************/ 100 101 SvxTextAttrPage::SvxTextAttrPage( Window* pWindow, const SfxItemSet& rInAttrs ) : 102 SvxTabPage ( pWindow, CUI_RES( RID_SVXPAGE_TEXTATTR ), 103 rInAttrs ), 104 105 aFlText ( this, CUI_RES( FL_TEXT ) ), 106 aTsbAutoGrowWidth ( this, CUI_RES( TSB_AUTOGROW_WIDTH ) ), 107 aTsbAutoGrowHeight ( this, CUI_RES( TSB_AUTOGROW_HEIGHT ) ), 108 aTsbFitToSize ( this, CUI_RES( TSB_FIT_TO_SIZE ) ), 109 aTsbContour ( this, CUI_RES( TSB_CONTOUR ) ), 110 aTsbWordWrapText( this, CUI_RES( TSB_WORDWRAP_TEXT ) ), 111 aTsbAutoGrowSize( this, CUI_RES( TSB_AUTOGROW_SIZE ) ), 112 aFlDistance ( this, CUI_RES( FL_DISTANCE ) ), 113 aFtLeft ( this, CUI_RES( FT_LEFT ) ), 114 aMtrFldLeft ( this, CUI_RES( MTR_FLD_LEFT ) ), 115 aFtRight ( this, CUI_RES( FT_RIGHT ) ), 116 aMtrFldRight ( this, CUI_RES( MTR_FLD_RIGHT ) ), 117 aFtTop ( this, CUI_RES( FT_TOP ) ), 118 aMtrFldTop ( this, CUI_RES( MTR_FLD_TOP ) ), 119 aFtBottom ( this, CUI_RES( FT_BOTTOM ) ), 120 aMtrFldBottom ( this, CUI_RES( MTR_FLD_BOTTOM ) ), 121 122 aFlSeparator ( this, CUI_RES( FL_SEPARATOR ) ), 123 124 aFlPosition ( this, CUI_RES( FL_POSITION ) ), 125 aCtlPosition ( this, CUI_RES( CTL_POSITION ), 126 RP_MM, 240, 100 ), 127 aTsbFullWidth ( this, CUI_RES( TSB_FULL_WIDTH ) ), 128 129 rOutAttrs ( rInAttrs ) 130 { 131 FreeResource(); 132 133 FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs ); 134 SetFieldUnit( aMtrFldLeft, eFUnit ); 135 SetFieldUnit( aMtrFldRight, eFUnit ); 136 SetFieldUnit( aMtrFldTop, eFUnit ); 137 SetFieldUnit( aMtrFldBottom, eFUnit ); 138 139 Link aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) ); 140 aTsbAutoGrowWidth.SetClickHdl( aLink ); 141 aTsbAutoGrowHeight.SetClickHdl( aLink ); 142 aTsbFitToSize.SetClickHdl( aLink ); 143 aTsbContour.SetClickHdl( aLink ); 144 145 aTsbFullWidth.SetClickHdl( 146 LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) ); 147 148 aCtlPosition.SetAccessibleRelationMemberOf( &aFlPosition ); 149 } 150 151 /************************************************************************* 152 |* 153 |* Dtor 154 |* 155 \************************************************************************/ 156 157 SvxTextAttrPage::~SvxTextAttrPage() 158 { 159 } 160 161 /************************************************************************* 162 |* 163 |* Liest uebergebenen Item-Set 164 |* 165 \************************************************************************/ 166 167 void __EXPORT SvxTextAttrPage::Reset( const SfxItemSet& rAttrs ) 168 { 169 SfxItemPool* pPool = rAttrs.GetPool(); 170 DBG_ASSERT( pPool, "Wo ist der Pool" ); 171 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST ); 172 173 // Linker Abstand vom Rahmen 174 const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_TEXT_LEFTDIST ); 175 176 if( !pItem ) 177 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST ); 178 if( pItem ) 179 { 180 long nValue = ( ( const SdrTextLeftDistItem* )pItem )->GetValue(); 181 SetMetricValue( aMtrFldLeft, nValue, eUnit ); 182 } 183 else 184 aMtrFldLeft.SetText( String() ); 185 aMtrFldLeft.SaveValue(); 186 187 // Rechter Abstand vom Rahmen 188 pItem = GetItem( rAttrs, SDRATTR_TEXT_RIGHTDIST ); 189 if( !pItem ) 190 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST ); 191 if( pItem ) 192 { 193 long nValue = ( ( const SdrTextRightDistItem* )pItem )->GetValue(); 194 SetMetricValue( aMtrFldRight, nValue, eUnit ); 195 } 196 else 197 aMtrFldRight.SetText( String() ); 198 aMtrFldRight.SaveValue(); 199 200 // Oberer Abstand vom Rahmen 201 pItem = GetItem( rAttrs, SDRATTR_TEXT_UPPERDIST ); 202 if( !pItem ) 203 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST ); 204 if( pItem ) 205 { 206 long nValue = ( ( const SdrTextUpperDistItem* )pItem )->GetValue(); 207 SetMetricValue( aMtrFldTop, nValue, eUnit ); 208 } 209 else 210 aMtrFldTop.SetText( String() ); 211 aMtrFldTop.SaveValue(); 212 213 // Unterer Abstand vom Rahmen 214 pItem = GetItem( rAttrs, SDRATTR_TEXT_LOWERDIST ); 215 if( !pItem ) 216 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST ); 217 if( pItem ) 218 { 219 long nValue = ( ( const SdrTextLowerDistItem* )pItem )->GetValue(); 220 SetMetricValue( aMtrFldBottom, nValue, eUnit ); 221 } 222 else 223 aMtrFldBottom.SetText( String() ); 224 aMtrFldBottom.SaveValue(); 225 226 // An Hoehe anpassen 227 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SFX_ITEM_DONTCARE ) 228 { 229 aTsbAutoGrowHeight.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ). 230 GetValue() ? STATE_CHECK : STATE_NOCHECK ); 231 aTsbAutoGrowHeight.EnableTriState( sal_False ); 232 } 233 else 234 aTsbAutoGrowHeight.SetState( STATE_DONTKNOW ); 235 aTsbAutoGrowHeight.SaveValue(); 236 237 // An Breite anpassen 238 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SFX_ITEM_DONTCARE ) 239 { 240 aTsbAutoGrowWidth.SetState( ( ( const SdrTextAutoGrowWidthItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ). 241 GetValue() ? STATE_CHECK : STATE_NOCHECK ); 242 aTsbAutoGrowWidth.EnableTriState( sal_False ); 243 } 244 else 245 aTsbAutoGrowWidth.SetState( STATE_DONTKNOW ); 246 aTsbAutoGrowWidth.SaveValue(); 247 248 // autogrowsize 249 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SFX_ITEM_DONTCARE ) 250 { 251 aTsbAutoGrowSize.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ). 252 GetValue() ? STATE_CHECK : STATE_NOCHECK ); 253 aTsbAutoGrowSize.EnableTriState( sal_False ); 254 } 255 else 256 aTsbAutoGrowSize.SetState( STATE_DONTKNOW ); 257 aTsbAutoGrowSize.SaveValue(); 258 259 // wordwrap text 260 if ( rAttrs.GetItemState( SDRATTR_TEXT_WORDWRAP ) != SFX_ITEM_DONTCARE ) 261 { 262 aTsbWordWrapText.SetState( ( ( const SdrTextWordWrapItem& )rAttrs.Get( SDRATTR_TEXT_WORDWRAP ) ). 263 GetValue() ? STATE_CHECK : STATE_NOCHECK ); 264 aTsbWordWrapText.EnableTriState( sal_False ); 265 } 266 else 267 aTsbWordWrapText.SetState( STATE_DONTKNOW ); 268 aTsbWordWrapText.SaveValue(); 269 270 271 // #103516# Do the setup based on states of hor/ver adjust 272 // Setup center field and FullWidth 273 SfxItemState eVState = rAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); 274 SfxItemState eHState = rAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); 275 276 if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState) 277 { 278 // VertAdjust and HorAdjust are unequivocal, thus 279 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)rAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); 280 SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)((const SdrTextHorzAdjustItem&)rAttrs.Get(SDRATTR_TEXT_HORZADJUST)).GetValue(); 281 RECT_POINT eRP = RP_LB; 282 283 aTsbFullWidth.EnableTriState( sal_False ); 284 285 // Translate item values into local anchor position. 286 switch (eTVA) 287 { 288 case SDRTEXTVERTADJUST_TOP: 289 { 290 switch (eTHA) 291 { 292 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break; 293 case SDRTEXTHORZADJUST_BLOCK: 294 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break; 295 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break; 296 } 297 break; 298 } 299 case SDRTEXTVERTADJUST_BLOCK: 300 case SDRTEXTVERTADJUST_CENTER: 301 { 302 switch (eTHA) 303 { 304 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break; 305 case SDRTEXTHORZADJUST_BLOCK: 306 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break; 307 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break; 308 } 309 break; 310 } 311 case SDRTEXTVERTADJUST_BOTTOM: 312 { 313 switch (eTHA) 314 { 315 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break; 316 case SDRTEXTHORZADJUST_BLOCK: 317 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break; 318 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break; 319 } 320 break; 321 } 322 default: 323 break; 324 } 325 326 // See if we have to check the "full width" check button. 327 sal_Bool bLeftToRight(IsTextDirectionLeftToRight()); 328 329 if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA))) 330 { 331 // Move anchor to valid position. 332 ClickFullWidthHdl_Impl(NULL); 333 aTsbFullWidth.SetState(STATE_CHECK); 334 } 335 336 aCtlPosition.SetActualRP( eRP ); 337 } 338 else 339 { 340 // VertAdjust or HorAdjust is not unequivocal 341 aCtlPosition.Reset(); 342 343 aCtlPosition.SetState(STATE_DONTKNOW); 344 aCtlPosition.DoCompletelyDisable(sal_True); 345 346 aTsbFullWidth.SetState(STATE_DONTKNOW); 347 aTsbFullWidth.Enable( sal_False ); 348 aFlPosition.Enable( sal_False ); 349 } 350 351 // Am Rahmen anpassen 352 if ( rAttrs.GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SFX_ITEM_DONTCARE ) 353 { 354 SdrFitToSizeType eFTS = (SdrFitToSizeType) 355 ( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue(); 356 aTsbFitToSize.SetState( eFTS == SDRTEXTFIT_NONE ? STATE_NOCHECK : STATE_CHECK ); 357 aTsbFitToSize.EnableTriState( sal_False ); 358 } 359 else 360 aTsbFitToSize.SetState( STATE_DONTKNOW ); 361 aTsbFitToSize.SaveValue(); 362 363 // Konturfluss 364 if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE ) 365 { 366 sal_Bool bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue(); 367 aTsbContour.SetState( bContour ? STATE_CHECK : STATE_NOCHECK ); 368 aTsbContour.EnableTriState( sal_False ); 369 } 370 else 371 aTsbContour.SetState( STATE_DONTKNOW ); 372 aTsbContour.SaveValue(); 373 374 ClickHdl_Impl( NULL ); 375 } 376 377 /************************************************************************* 378 |* 379 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen 380 |* 381 \************************************************************************/ 382 383 sal_Bool SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs) 384 { 385 SfxItemPool* pPool = rAttrs.GetPool(); 386 DBG_ASSERT( pPool, "Wo ist der Pool" ); 387 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST ); 388 389 sal_Int32 nValue; 390 TriState eState; 391 392 if( aMtrFldLeft.GetText() != aMtrFldLeft.GetSavedValue() ) 393 { 394 nValue = GetCoreValue( aMtrFldLeft, eUnit ); 395 rAttrs.Put( SdrTextLeftDistItem( nValue ) ); 396 } 397 398 if( aMtrFldRight.GetText() != aMtrFldRight.GetSavedValue() ) 399 { 400 nValue = GetCoreValue( aMtrFldRight, eUnit ); 401 rAttrs.Put( SdrTextRightDistItem( nValue ) ); 402 } 403 404 if( aMtrFldTop.GetText() != aMtrFldTop.GetSavedValue() ) 405 { 406 nValue = GetCoreValue( aMtrFldTop, eUnit ); 407 rAttrs.Put( SdrTextUpperDistItem( nValue ) ); 408 } 409 410 if( aMtrFldBottom.GetText() != aMtrFldBottom.GetSavedValue() ) 411 { 412 nValue = GetCoreValue( aMtrFldBottom, eUnit ); 413 rAttrs.Put( SdrTextLowerDistItem( nValue ) ); 414 } 415 416 eState = aTsbAutoGrowHeight.GetState(); 417 if( eState != aTsbAutoGrowHeight.GetSavedValue() ) 418 { 419 rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) ); 420 } 421 422 eState = aTsbAutoGrowWidth.GetState(); 423 if( eState != aTsbAutoGrowWidth.GetSavedValue() ) 424 { 425 rAttrs.Put( SdrTextAutoGrowWidthItem( (sal_Bool) STATE_CHECK == eState ) ); 426 } 427 428 eState = aTsbAutoGrowSize.GetState(); 429 if( eState != aTsbAutoGrowSize.GetSavedValue() ) 430 { 431 rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) ); 432 } 433 434 eState = aTsbWordWrapText.GetState(); 435 if( eState != aTsbWordWrapText.GetSavedValue() ) 436 { 437 rAttrs.Put( SdrTextWordWrapItem( (sal_Bool) STATE_CHECK == eState ) ); 438 } 439 440 // Konturfluss 441 eState = aTsbContour.GetState(); 442 if( eState != aTsbContour.GetSavedValue() ) 443 { 444 rAttrs.Put( SdrTextContourFrameItem( (sal_Bool) STATE_CHECK == eState ) ); 445 } 446 447 eState = aTsbFitToSize.GetState(); 448 if( eState != aTsbFitToSize.GetSavedValue() ) 449 { 450 SdrFitToSizeType eFTS; 451 switch( eState ) 452 { 453 default: ; //prevent warning 454 DBG_ERROR( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" ); 455 case STATE_NOCHECK: eFTS = SDRTEXTFIT_NONE; break; 456 //case STATE_CHECK: eFTS = SDRTEXTFIT_RESIZEATTR; break; 457 case STATE_CHECK: eFTS = SDRTEXTFIT_PROPORTIONAL; break; 458 } 459 rAttrs.Put( SdrTextFitToSizeTypeItem( eFTS ) ); 460 } 461 462 // zentriert 463 RECT_POINT eRP = aCtlPosition.GetActualRP(); 464 SdrTextVertAdjust eTVA, eOldTVA; 465 SdrTextHorzAdjust eTHA, eOldTHA; 466 467 switch( eRP ) 468 { 469 default: 470 case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP; 471 eTHA = SDRTEXTHORZADJUST_LEFT; break; 472 case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER; 473 eTHA = SDRTEXTHORZADJUST_LEFT; break; 474 case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM; 475 eTHA = SDRTEXTHORZADJUST_LEFT; break; 476 case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP; 477 eTHA = SDRTEXTHORZADJUST_CENTER; break; 478 case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER; 479 eTHA = SDRTEXTHORZADJUST_CENTER; break; 480 case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM; 481 eTHA = SDRTEXTHORZADJUST_CENTER; break; 482 case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP; 483 eTHA = SDRTEXTHORZADJUST_RIGHT; break; 484 case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER; 485 eTHA = SDRTEXTHORZADJUST_RIGHT; break; 486 case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM; 487 eTHA = SDRTEXTHORZADJUST_RIGHT; break; 488 } 489 490 // #103516# Do not change values if adjust controls were disabled. 491 sal_Bool bIsDisabled(aCtlPosition.IsCompletelyDisabled()); 492 493 if(!bIsDisabled) 494 { 495 if( aTsbFullWidth.GetState() == STATE_CHECK ) 496 { 497 if (IsTextDirectionLeftToRight()) 498 eTHA = SDRTEXTHORZADJUST_BLOCK; 499 else 500 eTVA = SDRTEXTVERTADJUST_BLOCK; 501 } 502 503 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE ) 504 { 505 eOldTVA = (SdrTextVertAdjust) 506 ( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue(); 507 if( eOldTVA != eTVA ) 508 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) ); 509 } 510 else 511 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) ); 512 513 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE ) 514 { 515 eOldTHA = (SdrTextHorzAdjust) 516 ( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue(); 517 if( eOldTHA != eTHA ) 518 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) ); 519 } 520 else 521 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) ); 522 } 523 524 return( sal_True ); 525 } 526 527 /************************************************************************* 528 |* 529 |* 530 |* 531 \************************************************************************/ 532 533 void SvxTextAttrPage::Construct() 534 { 535 DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" ); 536 537 bFitToSizeEnabled = bContourEnabled = sal_True; 538 bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_False; 539 540 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 541 if( rMarkList.GetMarkCount() == 1 ) 542 { 543 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 544 SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); 545 if( pObj->GetObjInventor() == SdrInventor ) 546 { 547 switch( eKind ) 548 { 549 case OBJ_TEXT : 550 case OBJ_TITLETEXT : 551 case OBJ_OUTLINETEXT : 552 case OBJ_CAPTION : 553 { 554 if ( ((SdrTextObj*)pObj)->HasText() ) 555 { 556 // Konturfluss ist NICHT bei reinen Textobjekten m�glich 557 bContourEnabled = sal_False; 558 559 // Breite und Hoehe anpassen ist NUR bei reinen Textobjekten m�glich 560 bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_True; 561 } 562 } 563 break; 564 case OBJ_CUSTOMSHAPE : 565 { 566 bFitToSizeEnabled = bContourEnabled = sal_False; 567 bAutoGrowSizeEnabled = sal_True; 568 bWordWrapTextEnabled = sal_True; 569 } 570 break; 571 default: ;//prevent warning 572 } 573 } 574 } 575 aTsbAutoGrowHeight.Enable( bAutoGrowHeightEnabled ); 576 aTsbAutoGrowWidth.Enable( bAutoGrowWidthEnabled ); 577 aTsbFitToSize.Enable( bFitToSizeEnabled ); 578 aTsbContour.Enable( bContourEnabled ); 579 aTsbAutoGrowSize.Enable( bAutoGrowSizeEnabled ); 580 aTsbWordWrapText.Enable( bWordWrapTextEnabled ); 581 } 582 583 /************************************************************************* 584 |* 585 |* Erzeugt die Seite 586 |* 587 \************************************************************************/ 588 589 SfxTabPage* SvxTextAttrPage::Create( Window* pWindow, 590 const SfxItemSet& rAttrs ) 591 { 592 return( new SvxTextAttrPage( pWindow, rAttrs ) ); 593 } 594 595 /************************************************************************* 596 |* 597 |* 598 |* 599 \************************************************************************/ 600 601 sal_uInt16* SvxTextAttrPage::GetRanges() 602 { 603 return( pRanges ); 604 } 605 606 /************************************************************************* 607 |* 608 |* 609 |* 610 \************************************************************************/ 611 612 /** Check whether we have to uncheck the "Full width" check box. 613 */ 614 void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP ) 615 { 616 if (aTsbFullWidth.GetState() == STATE_CHECK) 617 { 618 // Depending on write direction and currently checked anchor we have 619 // to uncheck the "full width" button. 620 if (IsTextDirectionLeftToRight()) 621 switch( eRP ) 622 { 623 case RP_LT: 624 case RP_LM: 625 case RP_LB: 626 case RP_RT: 627 case RP_RM: 628 case RP_RB: 629 aTsbFullWidth.SetState( STATE_NOCHECK ); 630 break; 631 default: ;//prevent warning 632 } 633 else 634 switch (eRP) 635 { 636 case RP_LT: 637 case RP_MT: 638 case RP_RT: 639 case RP_LB: 640 case RP_MB: 641 case RP_RB: 642 aTsbFullWidth.SetState( STATE_NOCHECK ); 643 break; 644 default: ;//prevent warning 645 } 646 } 647 } 648 649 /************************************************************************* 650 |* 651 |* Aendert evtl. die Position des Positions-Controls 652 |* 653 \************************************************************************/ 654 655 /** When switching the "full width" check button on the text anchor may have 656 to be moved to a valid and adjacent position. This position depends on 657 the current anchor position and the text writing direction. 658 */ 659 IMPL_LINK( SvxTextAttrPage, ClickFullWidthHdl_Impl, void *, EMPTYARG ) 660 { 661 if( aTsbFullWidth.GetState() == STATE_CHECK ) 662 { 663 if (IsTextDirectionLeftToRight()) 664 { 665 // Move text anchor to horizontal middle axis. 666 switch( aCtlPosition.GetActualRP() ) 667 { 668 case RP_LT: 669 case RP_RT: 670 aCtlPosition.SetActualRP( RP_MT ); 671 break; 672 673 case RP_LM: 674 case RP_RM: 675 aCtlPosition.SetActualRP( RP_MM ); 676 break; 677 678 case RP_LB: 679 case RP_RB: 680 aCtlPosition.SetActualRP( RP_MB ); 681 break; 682 default: ;//prevent warning 683 } 684 } 685 else 686 { 687 // Move text anchor to vertical middle axis. 688 switch( aCtlPosition.GetActualRP() ) 689 { 690 case RP_LT: 691 case RP_LB: 692 aCtlPosition.SetActualRP( RP_LM ); 693 break; 694 695 case RP_MT: 696 case RP_MB: 697 aCtlPosition.SetActualRP( RP_MM ); 698 break; 699 700 case RP_RT: 701 case RP_RB: 702 aCtlPosition.SetActualRP( RP_RM ); 703 break; 704 default: ;//prevent warning 705 } 706 } 707 } 708 return( 0L ); 709 } 710 711 /************************************************************************* 712 |* 713 |* Enabled/Disabled "Groesse an Text" oder "Am Rahmen Anpassen" 714 |* 715 \************************************************************************/ 716 717 IMPL_LINK( SvxTextAttrPage, ClickHdl_Impl, void *, EMPTYARG ) 718 { 719 sal_Bool bAutoGrowWidth = aTsbAutoGrowWidth.GetState() == STATE_CHECK; 720 sal_Bool bAutoGrowHeight = aTsbAutoGrowHeight.GetState() == STATE_CHECK; 721 sal_Bool bFitToSize = aTsbFitToSize.GetState() == STATE_CHECK; 722 sal_Bool bContour = aTsbContour.GetState() == STATE_CHECK; 723 724 aTsbContour.Enable( !bFitToSize && 725 !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) && 726 bContourEnabled ); 727 728 aTsbAutoGrowWidth.Enable( !bFitToSize && 729 !( bContour && bContourEnabled ) && 730 bAutoGrowWidthEnabled ); 731 732 aTsbAutoGrowHeight.Enable( !bFitToSize && 733 !( bContour && bContourEnabled ) && 734 bAutoGrowHeightEnabled ); 735 736 aTsbFitToSize.Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) && 737 !( bContour && bContourEnabled ) && 738 bFitToSizeEnabled ); 739 740 // #101901# enable/disable metric fields and decorations dependent of contour 741 aMtrFldLeft.Enable(!bContour); 742 aMtrFldRight.Enable(!bContour); 743 aMtrFldTop.Enable(!bContour); 744 aMtrFldBottom.Enable(!bContour); 745 aFlDistance.Enable(!bContour); 746 aFtLeft.Enable(!bContour); 747 aFtRight.Enable(!bContour); 748 aFtTop.Enable(!bContour); 749 aFtBottom.Enable(!bContour); 750 751 if( bContour && bContourEnabled ) 752 { 753 aMtrFldLeft.SetValue( 0 ); 754 aMtrFldRight.SetValue( 0 ); 755 aMtrFldTop.SetValue( 0 ); 756 aMtrFldBottom.SetValue( 0 ); 757 } 758 759 // #103516# Do the setup based on states of hor/ver adjust 760 SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); 761 SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); 762 sal_Bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState); 763 764 // #83698# enable/disable text anchoring dependent of contour 765 aCtlPosition.Enable(!bContour && !bHorAndVer); 766 aTsbFullWidth.Enable(!bContour && !bHorAndVer); 767 aFlPosition.Enable(!bContour && !bHorAndVer); 768 769 return( 0L ); 770 } 771 772 773 bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const 774 { 775 // Determine the text writing direction with left to right as default. 776 bool bLeftToRightDirection = true; 777 SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION); 778 779 if(SFX_ITEM_DONTCARE != eState) 780 { 781 const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> ( 782 rOutAttrs.Get (SDRATTR_TEXTDIRECTION)); 783 if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL) 784 bLeftToRightDirection = false; 785 } 786 return bLeftToRightDirection; 787 } 788 789 //add CHINA001 begin 790 void SvxTextAttrPage::PageCreated(SfxAllItemSet aSet) 791 { 792 SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,sal_False); 793 794 if (pViewItem) 795 SetView( static_cast<SdrView *>(pViewItem->GetValue())); 796 797 Construct(); 798 } 799 800 //end of CHINA001 801