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