bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / tabpages / textattr.cxx
blob9fe5631028821bb2ce5541084bc35c35634e4dcf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/app.hxx>
21 #include <sfx2/module.hxx>
22 #include <cuires.hrc>
23 #include <svx/svddef.hxx>
24 #include <svx/sdtditm.hxx>
25 #include <svx/sdtagitm.hxx>
26 #include <svx/sdtaitm.hxx>
27 #include <svx/sdtfsitm.hxx>
28 #include <svx/sdtcfitm.hxx>
29 #include <svx/svdobj.hxx>
30 #include <svx/svdmark.hxx>
31 #include <svx/svdview.hxx>
32 #include <svx/svdotext.hxx>
33 #include <svx/dialogs.hrc>
35 #include "textattr.hxx"
36 #include <dialmgr.hxx>
37 #include "svx/dlgutil.hxx"
38 #include <sfx2/request.hxx>
39 #include <svx/ofaitem.hxx>
40 #include <editeng/writingmodeitem.hxx>
42 const sal_uInt16 SvxTextAttrPage::pRanges[] =
44 SDRATTR_MISC_FIRST
45 , SDRATTR_TEXT_HORZADJUST
46 , SDRATTR_TEXT_WORDWRAP
47 , SDRATTR_TEXT_AUTOGROWSIZE
48 , 0
51 /*************************************************************************
53 |* dialog (page) for copying objects
55 \************************************************************************/
56 SvxTextAttrPage::SvxTextAttrPage(vcl::Window* pWindow, const SfxItemSet& rInAttrs)
57 : SvxTabPage(pWindow,"TextAttributesPage","cui/ui/textattrtabpage.ui", rInAttrs)
58 , rOutAttrs(rInAttrs)
59 , pView(NULL)
60 , bAutoGrowSizeEnabled(false)
61 , bContourEnabled(false)
62 , bAutoGrowWidthEnabled(false)
63 , bAutoGrowHeightEnabled(false)
64 , bWordWrapTextEnabled(false)
65 , bFitToSizeEnabled(false)
67 get(m_pTsbAutoGrowWidth,"TSB_AUTOGROW_WIDTH");
68 get(m_pTsbAutoGrowHeight,"TSB_AUTOGROW_HEIGHT");
69 get(m_pTsbFitToSize,"TSB_FIT_TO_SIZE");
70 get(m_pTsbContour,"TSB_CONTOUR");
71 get(m_pTsbWordWrapText,"TSB_WORDWRAP_TEXT");
72 get(m_pTsbAutoGrowSize,"TSB_AUTOGROW_SIZE");
73 get(m_pFlDistance,"FL_DISTANCE");
74 get(m_pMtrFldLeft,"MTR_FLD_LEFT");
75 get(m_pMtrFldRight,"MTR_FLD_RIGHT");
76 get(m_pMtrFldTop,"MTR_FLD_TOP");
77 get(m_pMtrFldBottom,"MTR_FLD_BOTTOM");
78 get(m_pFlPosition,"FL_POSITION");
79 get(m_pCtlPosition,"CTL_POSITION");
80 m_pCtlPosition->SetControlSettings(RP_MM, 240, 100),
81 get(m_pTsbFullWidth,"TSB_FULL_WIDTH");
84 FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
85 SetFieldUnit( *m_pMtrFldLeft, eFUnit );
86 SetFieldUnit( *m_pMtrFldRight, eFUnit );
87 SetFieldUnit( *m_pMtrFldTop, eFUnit );
88 SetFieldUnit( *m_pMtrFldBottom, eFUnit );
90 Link<> aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
91 m_pTsbAutoGrowWidth->SetClickHdl( aLink );
92 m_pTsbAutoGrowHeight->SetClickHdl( aLink );
93 m_pTsbFitToSize->SetClickHdl( aLink );
94 m_pTsbContour->SetClickHdl( aLink );
96 m_pTsbFullWidth->SetClickHdl(LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
99 SvxTextAttrPage::~SvxTextAttrPage()
101 disposeOnce();
104 void SvxTextAttrPage::dispose()
106 m_pTsbAutoGrowWidth.clear();
107 m_pTsbAutoGrowHeight.clear();
108 m_pTsbFitToSize.clear();
109 m_pTsbContour.clear();
110 m_pTsbWordWrapText.clear();
111 m_pTsbAutoGrowSize.clear();
112 m_pFlDistance.clear();
113 m_pMtrFldLeft.clear();
114 m_pMtrFldRight.clear();
115 m_pMtrFldTop.clear();
116 m_pMtrFldBottom.clear();
117 m_pFlPosition.clear();
118 m_pCtlPosition.clear();
119 m_pTsbFullWidth.clear();
120 SvxTabPage::dispose();
123 /*************************************************************************
125 |* reads the passed item set
127 \************************************************************************/
129 void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs )
131 SfxItemPool* pPool = rAttrs->GetPool();
132 DBG_ASSERT( pPool, "Wo ist der Pool" );
133 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
135 const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_TEXT_LEFTDIST );
137 if( !pItem )
138 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
139 if( pItem )
141 long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
142 SetMetricValue( *m_pMtrFldLeft, nValue, eUnit );
144 else
145 m_pMtrFldLeft->SetText( "" );
146 m_pMtrFldLeft->SaveValue();
148 pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST );
149 if( !pItem )
150 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
151 if( pItem )
153 long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
154 SetMetricValue( *m_pMtrFldRight, nValue, eUnit );
156 else
157 m_pMtrFldRight->SetText( "" );
158 m_pMtrFldRight->SaveValue();
160 pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST );
161 if( !pItem )
162 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
163 if( pItem )
165 long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
166 SetMetricValue( *m_pMtrFldTop, nValue, eUnit );
168 else
169 m_pMtrFldTop->SetText( "" );
170 m_pMtrFldTop->SaveValue();
172 pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST );
173 if( !pItem )
174 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
175 if( pItem )
177 long nValue = static_cast<const SdrMetricItem*>(pItem)->GetValue();
178 SetMetricValue( *m_pMtrFldBottom, nValue, eUnit );
180 else
181 m_pMtrFldBottom->SetText( "" );
182 m_pMtrFldBottom->SaveValue();
184 // adjust to height
185 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::DONTCARE )
187 m_pTsbAutoGrowHeight->SetState( static_cast<const SdrOnOffItem&>( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
188 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
189 m_pTsbAutoGrowHeight->EnableTriState( false );
191 else
192 m_pTsbAutoGrowHeight->SetState( TRISTATE_INDET );
193 m_pTsbAutoGrowHeight->SaveValue();
195 // adjust to width
196 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::DONTCARE )
198 m_pTsbAutoGrowWidth->SetState( static_cast<const SdrOnOffItem&>( rAttrs->Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ).
199 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
200 m_pTsbAutoGrowWidth->EnableTriState( false );
202 else
203 m_pTsbAutoGrowWidth->SetState( TRISTATE_INDET );
204 m_pTsbAutoGrowWidth->SaveValue();
206 // autogrowsize
207 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SfxItemState::DONTCARE )
209 m_pTsbAutoGrowSize->SetState( static_cast<const SdrOnOffItem&>( rAttrs->Get( SDRATTR_TEXT_AUTOGROWSIZE ) ).
210 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
211 m_pTsbAutoGrowSize->EnableTriState( false );
213 else
214 m_pTsbAutoGrowSize->SetState( TRISTATE_INDET );
215 m_pTsbAutoGrowSize->SaveValue();
217 // wordwrap text
218 if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::DONTCARE )
220 m_pTsbWordWrapText->SetState( static_cast<const SdrOnOffItem&>( rAttrs->Get( SDRATTR_TEXT_WORDWRAP ) ).
221 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
222 m_pTsbWordWrapText->EnableTriState( false );
224 else
225 m_pTsbWordWrapText->SetState( TRISTATE_INDET );
226 m_pTsbWordWrapText->SaveValue();
229 // #103516# Do the setup based on states of hor/ver adjust
230 // Setup center field and FullWidth
231 SfxItemState eVState = rAttrs->GetItemState( SDRATTR_TEXT_VERTADJUST );
232 SfxItemState eHState = rAttrs->GetItemState( SDRATTR_TEXT_HORZADJUST );
234 if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
236 // VertAdjust and HorAdjust are unequivocal, thus
237 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)static_cast<const SdrTextVertAdjustItem&>(rAttrs->Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
238 SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)static_cast<const SdrTextHorzAdjustItem&>(rAttrs->Get(SDRATTR_TEXT_HORZADJUST)).GetValue();
239 RECT_POINT eRP = RP_LB;
241 m_pTsbFullWidth->EnableTriState( false );
243 // Translate item values into local anchor position.
244 switch (eTVA)
246 case SDRTEXTVERTADJUST_TOP:
248 switch (eTHA)
250 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break;
251 case SDRTEXTHORZADJUST_BLOCK:
252 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break;
253 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break;
255 break;
257 case SDRTEXTVERTADJUST_BLOCK:
258 case SDRTEXTVERTADJUST_CENTER:
260 switch (eTHA)
262 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break;
263 case SDRTEXTHORZADJUST_BLOCK:
264 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break;
265 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break;
267 break;
269 case SDRTEXTVERTADJUST_BOTTOM:
271 switch (eTHA)
273 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break;
274 case SDRTEXTHORZADJUST_BLOCK:
275 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break;
276 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break;
278 break;
280 default:
281 break;
284 // See if we have to check the "full width" check button.
285 bool bLeftToRight(IsTextDirectionLeftToRight());
287 if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
289 // Move anchor to valid position.
290 ClickFullWidthHdl_Impl(NULL);
291 m_pTsbFullWidth->SetState(TRISTATE_TRUE);
294 m_pCtlPosition->SetActualRP( eRP );
296 else
298 // VertAdjust or HorAdjust is not unequivocal
299 m_pCtlPosition->Reset();
301 m_pCtlPosition->SetState(CTL_STATE::NOVERT);
302 m_pCtlPosition->DoCompletelyDisable(true);
304 m_pTsbFullWidth->SetState(TRISTATE_INDET);
305 m_pFlPosition->Enable( false );
308 // adjust to border
309 if ( rAttrs->GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SfxItemState::DONTCARE )
311 SdrFitToSizeType eFTS = (SdrFitToSizeType)
312 static_cast<const SdrTextFitToSizeTypeItem&>( rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
313 m_pTsbFitToSize->SetState( eFTS == SDRTEXTFIT_NONE ? TRISTATE_FALSE : TRISTATE_TRUE );
314 m_pTsbFitToSize->EnableTriState( false );
316 else
317 m_pTsbFitToSize->SetState( TRISTATE_INDET );
318 m_pTsbFitToSize->SaveValue();
320 if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::DONTCARE )
322 bool bContour = static_cast<const SdrOnOffItem&>( rAttrs->Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
323 m_pTsbContour->SetState( bContour ? TRISTATE_TRUE : TRISTATE_FALSE );
324 m_pTsbContour->EnableTriState( false );
326 else
327 m_pTsbContour->SetState( TRISTATE_INDET );
328 m_pTsbContour->SaveValue();
330 ClickHdl_Impl( NULL );
333 /*************************************************************************
335 |* fills the passed item set with dialog box attributes
337 \************************************************************************/
339 bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
341 SfxItemPool* pPool = rAttrs->GetPool();
342 DBG_ASSERT( pPool, "Wo ist der Pool" );
343 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
345 sal_Int32 nValue;
346 TriState eState;
348 if( m_pMtrFldLeft->IsValueChangedFromSaved() )
350 nValue = GetCoreValue( *m_pMtrFldLeft, eUnit );
351 rAttrs->Put( makeSdrTextLeftDistItem( nValue ) );
354 if( m_pMtrFldRight->IsValueChangedFromSaved() )
356 nValue = GetCoreValue( *m_pMtrFldRight, eUnit );
357 rAttrs->Put( makeSdrTextRightDistItem( nValue ) );
360 if( m_pMtrFldTop->IsValueChangedFromSaved() )
362 nValue = GetCoreValue( *m_pMtrFldTop, eUnit );
363 rAttrs->Put( makeSdrTextUpperDistItem( nValue ) );
366 if( m_pMtrFldBottom->IsValueChangedFromSaved() )
368 nValue = GetCoreValue( *m_pMtrFldBottom, eUnit );
369 rAttrs->Put( makeSdrTextLowerDistItem( nValue ) );
372 eState = m_pTsbAutoGrowHeight->GetState();
373 if( m_pTsbAutoGrowHeight->IsValueChangedFromSaved() )
375 rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
378 eState = m_pTsbAutoGrowWidth->GetState();
379 if( m_pTsbAutoGrowWidth->IsValueChangedFromSaved() )
381 rAttrs->Put( makeSdrTextAutoGrowWidthItem( TRISTATE_TRUE == eState ) );
384 eState = m_pTsbAutoGrowSize->GetState();
385 if( m_pTsbAutoGrowSize->IsValueChangedFromSaved() )
387 rAttrs->Put( makeSdrTextAutoGrowSizeItem ( TRISTATE_TRUE == eState ) );
390 eState = m_pTsbWordWrapText->GetState();
391 if( m_pTsbWordWrapText->IsValueChangedFromSaved() )
393 rAttrs->Put( makeSdrTextWordWrapItem( TRISTATE_TRUE == eState ) );
396 eState = m_pTsbContour->GetState();
397 if( m_pTsbContour->IsValueChangedFromSaved() )
399 rAttrs->Put( makeSdrTextContourFrameItem( TRISTATE_TRUE == eState ) );
402 eState = m_pTsbFitToSize->GetState();
403 if( m_pTsbFitToSize->IsValueChangedFromSaved() )
405 SdrFitToSizeType eFTS;
406 switch( eState )
408 default: ; //prevent warning
409 OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
410 /* Fall through */
411 case TRISTATE_FALSE: eFTS = SDRTEXTFIT_NONE; break;
412 case TRISTATE_TRUE: eFTS = SDRTEXTFIT_AUTOFIT; break;
414 rAttrs->Put( SdrTextFitToSizeTypeItem( eFTS ) );
417 // centered
418 RECT_POINT eRP = m_pCtlPosition->GetActualRP();
419 SdrTextVertAdjust eTVA, eOldTVA;
420 SdrTextHorzAdjust eTHA, eOldTHA;
422 switch( eRP )
424 default:
425 case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
426 eTHA = SDRTEXTHORZADJUST_LEFT; break;
427 case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
428 eTHA = SDRTEXTHORZADJUST_LEFT; break;
429 case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
430 eTHA = SDRTEXTHORZADJUST_LEFT; break;
431 case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
432 eTHA = SDRTEXTHORZADJUST_CENTER; break;
433 case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
434 eTHA = SDRTEXTHORZADJUST_CENTER; break;
435 case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
436 eTHA = SDRTEXTHORZADJUST_CENTER; break;
437 case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
438 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
439 case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
440 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
441 case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
442 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
445 // #103516# Do not change values if adjust controls were disabled.
446 bool bIsDisabled(m_pCtlPosition->IsCompletelyDisabled());
448 if(!bIsDisabled)
450 if( m_pTsbFullWidth->GetState() == TRISTATE_TRUE )
452 if (IsTextDirectionLeftToRight())
453 eTHA = SDRTEXTHORZADJUST_BLOCK;
454 else
455 eTVA = SDRTEXTVERTADJUST_BLOCK;
458 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
460 eOldTVA = (SdrTextVertAdjust)
461 static_cast<const SdrTextVertAdjustItem&>( rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
462 if( eOldTVA != eTVA )
463 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
465 else
466 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
468 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
470 eOldTHA = (SdrTextHorzAdjust)
471 static_cast<const SdrTextHorzAdjustItem&>( rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
472 if( eOldTHA != eTHA )
473 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
475 else
476 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
479 return true;
482 void SvxTextAttrPage::Construct()
484 DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
486 bFitToSizeEnabled = bContourEnabled = true;
487 bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false;
489 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
490 if( rMarkList.GetMarkCount() == 1 )
492 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
493 SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
494 if( pObj->GetObjInventor() == SdrInventor )
496 switch( eKind )
498 case OBJ_TEXT :
499 case OBJ_TITLETEXT :
500 case OBJ_OUTLINETEXT :
501 case OBJ_CAPTION :
503 if(pObj->HasText())
505 // contour NOT possible for pure text objects
506 bContourEnabled = false;
508 // adjusting width and height is ONLY possible for pure text objects
509 bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true;
512 break;
513 case OBJ_CUSTOMSHAPE :
515 bFitToSizeEnabled = bContourEnabled = false;
516 bAutoGrowSizeEnabled = true;
517 bWordWrapTextEnabled = true;
519 break;
520 default: ;//prevent warning
524 m_pTsbAutoGrowHeight->Enable( bAutoGrowHeightEnabled );
525 m_pTsbAutoGrowWidth->Enable( bAutoGrowWidthEnabled );
526 m_pTsbFitToSize->Enable( bFitToSizeEnabled );
527 m_pTsbContour->Enable( bContourEnabled );
528 m_pTsbAutoGrowSize->Enable( bAutoGrowSizeEnabled );
529 m_pTsbWordWrapText->Enable( bWordWrapTextEnabled );
532 VclPtr<SfxTabPage> SvxTextAttrPage::Create( vcl::Window* pWindow,
533 const SfxItemSet* rAttrs )
535 return VclPtr<SvxTextAttrPage>::Create( pWindow, *rAttrs );
538 /** Check whether we have to uncheck the "Full width" check box.
540 void SvxTextAttrPage::PointChanged( vcl::Window*, RECT_POINT eRP )
542 if (m_pTsbFullWidth->GetState() == TRISTATE_TRUE)
544 // Depending on write direction and currently checked anchor we have
545 // to uncheck the "full width" button.
546 if (IsTextDirectionLeftToRight())
547 switch( eRP )
549 case RP_LT:
550 case RP_LM:
551 case RP_LB:
552 case RP_RT:
553 case RP_RM:
554 case RP_RB:
555 m_pTsbFullWidth->SetState( TRISTATE_FALSE );
556 break;
557 default: ;//prevent warning
559 else
560 switch (eRP)
562 case RP_LT:
563 case RP_MT:
564 case RP_RT:
565 case RP_LB:
566 case RP_MB:
567 case RP_RB:
568 m_pTsbFullWidth->SetState( TRISTATE_FALSE );
569 break;
570 default: ;//prevent warning
575 /*************************************************************************
577 |* possibly changes the position of the position-control
579 \************************************************************************/
581 /** When switching the "full width" check button on the text anchor may have
582 to be moved to a valid and adjacent position. This position depends on
583 the current anchor position and the text writing direction.
585 IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl)
587 if( m_pTsbFullWidth->GetState() == TRISTATE_TRUE )
589 if (IsTextDirectionLeftToRight())
591 // Move text anchor to horizontal middle axis.
592 switch( m_pCtlPosition->GetActualRP() )
594 case RP_LT:
595 case RP_RT:
596 m_pCtlPosition->SetActualRP( RP_MT );
597 break;
599 case RP_LM:
600 case RP_RM:
601 m_pCtlPosition->SetActualRP( RP_MM );
602 break;
604 case RP_LB:
605 case RP_RB:
606 m_pCtlPosition->SetActualRP( RP_MB );
607 break;
608 default: ;//prevent warning
611 else
613 // Move text anchor to vertical middle axis.
614 switch( m_pCtlPosition->GetActualRP() )
616 case RP_LT:
617 case RP_LB:
618 m_pCtlPosition->SetActualRP( RP_LM );
619 break;
621 case RP_MT:
622 case RP_MB:
623 m_pCtlPosition->SetActualRP( RP_MM );
624 break;
626 case RP_RT:
627 case RP_RB:
628 m_pCtlPosition->SetActualRP( RP_RM );
629 break;
630 default: ;//prevent warning
634 return 0L;
637 /*************************************************************************
639 |* enables/disables "size at text" or "adjust to frame"
641 \************************************************************************/
643 IMPL_LINK_NOARG(SvxTextAttrPage, ClickHdl_Impl)
645 bool bAutoGrowWidth = m_pTsbAutoGrowWidth->GetState() == TRISTATE_TRUE;
646 bool bAutoGrowHeight = m_pTsbAutoGrowHeight->GetState() == TRISTATE_TRUE;
647 bool bFitToSize = m_pTsbFitToSize->GetState() == TRISTATE_TRUE;
648 bool bContour = m_pTsbContour->GetState() == TRISTATE_TRUE;
650 m_pTsbContour->Enable( !bFitToSize &&
651 !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
652 bContourEnabled );
654 m_pTsbAutoGrowWidth->Enable( !bFitToSize &&
655 !( bContour && bContourEnabled ) &&
656 bAutoGrowWidthEnabled );
658 m_pTsbAutoGrowHeight->Enable( !bFitToSize &&
659 !( bContour && bContourEnabled ) &&
660 bAutoGrowHeightEnabled );
662 m_pTsbFitToSize->Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
663 !( bContour && bContourEnabled ) &&
664 bFitToSizeEnabled );
666 // #101901# enable/disable metric fields and decorations dependent of contour
667 m_pFlDistance->Enable(!bContour);
669 if( bContour && bContourEnabled )
671 m_pMtrFldLeft->SetValue( 0 );
672 m_pMtrFldRight->SetValue( 0 );
673 m_pMtrFldTop->SetValue( 0 );
674 m_pMtrFldBottom->SetValue( 0 );
677 // #103516# Do the setup based on states of hor/ver adjust
678 SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
679 SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
680 bool bHorAndVer(SfxItemState::DONTCARE == eVState || SfxItemState::DONTCARE == eHState);
682 // #83698# enable/disable text anchoring dependent of contour
683 m_pFlPosition->Enable(!bContour && !bHorAndVer);
685 return 0L;
689 bool SvxTextAttrPage::IsTextDirectionLeftToRight() const
691 // Determine the text writing direction with left to right as default.
692 bool bLeftToRightDirection = true;
693 SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
695 if(SfxItemState::DONTCARE != eState)
697 const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
698 rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
699 if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
700 bLeftToRightDirection = false;
702 return bLeftToRightDirection;
705 void SvxTextAttrPage::PageCreated(const SfxAllItemSet& aSet)
707 SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,false);
709 if (pViewItem)
710 SetView( static_cast<SdrView *>(pViewItem->GetValue()));
712 Construct();
715 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */