bump product version to 6.3.0.0.beta1
[LibreOffice.git] / cui / source / tabpages / textattr.cxx
blob08c7b044a62f1b386b110c24f1853cc5147affc5
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 <svx/svddef.hxx>
23 #include <svx/sdasitm.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>
34 #include <svx/svxids.hrc>
36 #include <textattr.hxx>
37 #include <svx/dlgutil.hxx>
38 #include <sfx2/request.hxx>
39 #include <svx/ofaitem.hxx>
40 #include <editeng/writingmodeitem.hxx>
41 #include <svtools/unitconv.hxx>
43 using namespace ::com::sun::star;
45 const sal_uInt16 SvxTextAttrPage::pRanges[] =
47 SDRATTR_MISC_FIRST
48 , SDRATTR_TEXT_HORZADJUST
49 , SDRATTR_TEXT_WORDWRAP
50 , SDRATTR_TEXT_WORDWRAP
51 , 0
54 /*************************************************************************
56 |* dialog (page) for copying objects
58 \************************************************************************/
59 SvxTextAttrPage::SvxTextAttrPage(TabPageParent pPage, const SfxItemSet& rInAttrs)
60 : SvxTabPage(pPage, "cui/ui/textattrtabpage.ui", "TextAttributesPage", rInAttrs)
61 , rOutAttrs(rInAttrs)
62 , m_eObjKind(OBJ_NONE)
63 , bAutoGrowSizeEnabled(false)
64 , bContourEnabled(false)
65 , bAutoGrowWidthEnabled(false)
66 , bAutoGrowHeightEnabled(false)
67 , bWordWrapTextEnabled(false)
68 , bFitToSizeEnabled(false)
69 , m_aCtlPosition(this)
70 , m_xDrawingText(m_xBuilder->weld_widget("drawingtext"))
71 , m_xCustomShapeText(m_xBuilder->weld_widget("customshapetext"))
72 , m_xTsbAutoGrowWidth(m_xBuilder->weld_check_button("TSB_AUTOGROW_WIDTH"))
73 , m_xTsbAutoGrowHeight(m_xBuilder->weld_check_button("TSB_AUTOGROW_HEIGHT"))
74 , m_xTsbFitToSize(m_xBuilder->weld_check_button("TSB_FIT_TO_SIZE"))
75 , m_xTsbContour(m_xBuilder->weld_check_button("TSB_CONTOUR"))
76 , m_xTsbWordWrapText(m_xBuilder->weld_check_button("TSB_WORDWRAP_TEXT"))
77 , m_xTsbAutoGrowSize(m_xBuilder->weld_check_button("TSB_AUTOGROW_SIZE"))
78 , m_xFlDistance(m_xBuilder->weld_frame("FL_DISTANCE"))
79 , m_xMtrFldLeft(m_xBuilder->weld_metric_spin_button("MTR_FLD_LEFT", FieldUnit::CM))
80 , m_xMtrFldRight(m_xBuilder->weld_metric_spin_button("MTR_FLD_RIGHT", FieldUnit::CM))
81 , m_xMtrFldTop(m_xBuilder->weld_metric_spin_button("MTR_FLD_TOP", FieldUnit::CM))
82 , m_xMtrFldBottom(m_xBuilder->weld_metric_spin_button("MTR_FLD_BOTTOM", FieldUnit::CM))
83 , m_xFlPosition(m_xBuilder->weld_frame("FL_POSITION"))
84 , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
85 , m_xTsbFullWidth(m_xBuilder->weld_check_button("TSB_FULL_WIDTH"))
87 m_aCtlPosition.SetControlSettings(RectPoint::MM, 240);
89 FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
90 SetFieldUnit( *m_xMtrFldLeft, eFUnit );
91 SetFieldUnit( *m_xMtrFldRight, eFUnit );
92 SetFieldUnit( *m_xMtrFldTop, eFUnit );
93 SetFieldUnit( *m_xMtrFldBottom, eFUnit );
95 Link<weld::Button&,void> aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
96 m_xTsbAutoGrowWidth->connect_clicked( aLink );
97 m_xTsbAutoGrowHeight->connect_clicked( aLink );
98 m_xTsbAutoGrowSize->connect_clicked( aLink );
99 m_xTsbFitToSize->connect_clicked( aLink );
100 m_xTsbContour->connect_clicked( aLink );
102 m_xTsbFullWidth->connect_clicked(LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
105 SvxTextAttrPage::~SvxTextAttrPage()
109 /*************************************************************************
111 |* reads the passed item set
113 \************************************************************************/
115 void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs )
117 SfxItemPool* pPool = rAttrs->GetPool();
118 DBG_ASSERT( pPool, "Where is the pool?" );
119 MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
121 const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_TEXT_LEFTDIST );
122 if( !pItem )
123 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
125 SetMetricValue(*m_xMtrFldLeft, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
126 m_xMtrFldLeft->save_value();
128 pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST );
129 if( !pItem )
130 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
132 SetMetricValue(*m_xMtrFldRight, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
133 m_xMtrFldRight->save_value();
135 pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST );
136 if( !pItem )
137 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
139 SetMetricValue(*m_xMtrFldTop, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
140 m_xMtrFldTop->save_value();
142 pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST );
143 if( !pItem )
144 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
146 SetMetricValue(*m_xMtrFldBottom, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
147 m_xMtrFldBottom->save_value();
149 // adjust to height and autogrowsize
150 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::DONTCARE )
152 m_xTsbAutoGrowHeight->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ).
153 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
155 m_xTsbAutoGrowSize->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ).
156 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
158 else
160 m_xTsbAutoGrowHeight->set_state( TRISTATE_INDET );
161 m_xTsbAutoGrowSize->set_state( TRISTATE_INDET );
163 m_xTsbAutoGrowHeight->save_state();
164 m_xTsbAutoGrowSize->save_state();
166 // adjust to width
167 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::DONTCARE )
169 m_xTsbAutoGrowWidth->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWWIDTH ).
170 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
172 else
173 m_xTsbAutoGrowWidth->set_state( TRISTATE_INDET );
174 m_xTsbAutoGrowWidth->save_state();
176 // wordwrap text
177 if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::DONTCARE )
179 m_xTsbWordWrapText->set_state( rAttrs->Get( SDRATTR_TEXT_WORDWRAP ).
180 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
182 else
183 m_xTsbWordWrapText->set_state( TRISTATE_INDET );
184 m_xTsbWordWrapText->save_state();
187 // #103516# Do the setup based on states of hor/ver adjust
188 // Setup center field and FullWidth
189 SfxItemState eVState = rAttrs->GetItemState( SDRATTR_TEXT_VERTADJUST );
190 SfxItemState eHState = rAttrs->GetItemState( SDRATTR_TEXT_HORZADJUST );
192 if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
194 // VertAdjust and HorAdjust are unequivocal, thus
195 SdrTextVertAdjust eTVA = rAttrs->Get(SDRATTR_TEXT_VERTADJUST).GetValue();
196 SdrTextHorzAdjust eTHA = rAttrs->Get(SDRATTR_TEXT_HORZADJUST).GetValue();
197 RectPoint eRP = RectPoint::LB;
199 if (m_xTsbFullWidth->get_state() == TRISTATE_INDET)
200 m_xTsbFullWidth->set_state(TRISTATE_FALSE);
202 // Translate item values into local anchor position.
203 switch (eTVA)
205 case SDRTEXTVERTADJUST_TOP:
207 switch (eTHA)
209 case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LT; break;
210 case SDRTEXTHORZADJUST_BLOCK:
211 case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MT; break;
212 case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RT; break;
214 break;
216 case SDRTEXTVERTADJUST_BLOCK:
217 case SDRTEXTVERTADJUST_CENTER:
219 switch (eTHA)
221 case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LM; break;
222 case SDRTEXTHORZADJUST_BLOCK:
223 case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MM; break;
224 case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RM; break;
226 break;
228 case SDRTEXTVERTADJUST_BOTTOM:
230 switch (eTHA)
232 case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LB; break;
233 case SDRTEXTHORZADJUST_BLOCK:
234 case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MB; break;
235 case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RB; break;
237 break;
239 default:
240 break;
243 // See if we have to check the "full width" check button.
244 bool bLeftToRight(IsTextDirectionLeftToRight());
246 if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
248 // Move anchor to valid position.
249 ClickFullWidthHdl_Impl(*m_xTsbFullWidth);
250 m_xTsbFullWidth->set_state(TRISTATE_TRUE);
253 m_aCtlPosition.SetActualRP( eRP );
255 else
257 // VertAdjust or HorAdjust is not unequivocal
258 m_aCtlPosition.Reset();
260 m_aCtlPosition.SetState(CTL_STATE::NOVERT);
261 m_aCtlPosition.DoCompletelyDisable(true);
263 m_xTsbFullWidth->set_state(TRISTATE_INDET);
264 m_xFlPosition->set_sensitive( false );
267 // adjust to border
268 if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::DONTCARE)
270 drawing::TextFitToSizeType const eFTS =
271 rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ).GetValue();
272 if (eFTS == drawing::TextFitToSizeType_AUTOFIT || eFTS == drawing::TextFitToSizeType_NONE)
273 m_xTsbFitToSize->set_state( TRISTATE_FALSE );
274 else
275 m_xTsbFitToSize->set_state( TRISTATE_TRUE );
277 else
278 m_xTsbFitToSize->set_state( TRISTATE_INDET );
279 m_xTsbFitToSize->save_state();
281 if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::DONTCARE )
283 bool bContour = rAttrs->Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue();
284 m_xTsbContour->set_state( bContour ? TRISTATE_TRUE : TRISTATE_FALSE );
286 else
287 m_xTsbContour->set_state( TRISTATE_INDET );
288 m_xTsbContour->save_state();
290 ClickHdl_Impl(*m_xTsbContour);
293 /*************************************************************************
295 |* fills the passed item set with dialog box attributes
297 \************************************************************************/
299 bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
301 SfxItemPool* pPool = rAttrs->GetPool();
302 DBG_ASSERT( pPool, "Where is the pool?" );
303 MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
305 sal_Int32 nValue;
306 TriState eState;
308 if( m_xMtrFldLeft->get_value_changed_from_saved() )
310 nValue = GetCoreValue( *m_xMtrFldLeft, eUnit );
311 rAttrs->Put( makeSdrTextLeftDistItem( nValue ) );
314 if( m_xMtrFldRight->get_value_changed_from_saved() )
316 nValue = GetCoreValue( *m_xMtrFldRight, eUnit );
317 rAttrs->Put( makeSdrTextRightDistItem( nValue ) );
320 if( m_xMtrFldTop->get_value_changed_from_saved() )
322 nValue = GetCoreValue( *m_xMtrFldTop, eUnit );
323 rAttrs->Put( makeSdrTextUpperDistItem( nValue ) );
326 if( m_xMtrFldBottom->get_value_changed_from_saved() )
328 nValue = GetCoreValue( *m_xMtrFldBottom, eUnit );
329 rAttrs->Put( makeSdrTextLowerDistItem( nValue ) );
332 eState = m_xTsbAutoGrowHeight->get_state();
333 if( m_xTsbAutoGrowHeight->get_state_changed_from_saved() )
335 rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
338 eState = m_xTsbAutoGrowWidth->get_state();
339 if( m_xTsbAutoGrowWidth->get_state_changed_from_saved() )
341 rAttrs->Put( makeSdrTextAutoGrowWidthItem( TRISTATE_TRUE == eState ) );
344 eState = m_xTsbAutoGrowSize->get_state();
345 if( m_xTsbAutoGrowSize->get_state_changed_from_saved() )
347 rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
350 eState = m_xTsbWordWrapText->get_state();
351 if( m_xTsbWordWrapText->get_state_changed_from_saved() )
353 rAttrs->Put( makeSdrTextWordWrapItem( TRISTATE_TRUE == eState ) );
356 eState = m_xTsbContour->get_state();
357 if( m_xTsbContour->get_state_changed_from_saved() )
359 rAttrs->Put( makeSdrTextContourFrameItem( TRISTATE_TRUE == eState ) );
362 eState = m_xTsbFitToSize->get_state();
363 if( m_xTsbFitToSize->get_state_changed_from_saved() )
365 drawing::TextFitToSizeType eFTS;
366 switch( eState )
368 default: ; //prevent warning
369 OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
370 [[fallthrough]];
371 case TRISTATE_FALSE: eFTS = drawing::TextFitToSizeType_AUTOFIT; break;
372 case TRISTATE_TRUE: eFTS = drawing::TextFitToSizeType_PROPORTIONAL; break;
374 rAttrs->Put( SdrTextFitToSizeTypeItem( eFTS ) );
377 // centered
378 RectPoint eRP = m_aCtlPosition.GetActualRP();
379 SdrTextVertAdjust eTVA, eOldTVA;
380 SdrTextHorzAdjust eTHA, eOldTHA;
382 switch( eRP )
384 default:
385 case RectPoint::LT: eTVA = SDRTEXTVERTADJUST_TOP;
386 eTHA = SDRTEXTHORZADJUST_LEFT; break;
387 case RectPoint::LM: eTVA = SDRTEXTVERTADJUST_CENTER;
388 eTHA = SDRTEXTHORZADJUST_LEFT; break;
389 case RectPoint::LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
390 eTHA = SDRTEXTHORZADJUST_LEFT; break;
391 case RectPoint::MT: eTVA = SDRTEXTVERTADJUST_TOP;
392 eTHA = SDRTEXTHORZADJUST_CENTER; break;
393 case RectPoint::MM: eTVA = SDRTEXTVERTADJUST_CENTER;
394 eTHA = SDRTEXTHORZADJUST_CENTER; break;
395 case RectPoint::MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
396 eTHA = SDRTEXTHORZADJUST_CENTER; break;
397 case RectPoint::RT: eTVA = SDRTEXTVERTADJUST_TOP;
398 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
399 case RectPoint::RM: eTVA = SDRTEXTVERTADJUST_CENTER;
400 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
401 case RectPoint::RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
402 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
405 // #103516# Do not change values if adjust controls were disabled.
406 bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled());
408 if(!bIsDisabled)
410 if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
412 if (IsTextDirectionLeftToRight())
413 eTHA = SDRTEXTHORZADJUST_BLOCK;
414 else
415 eTVA = SDRTEXTVERTADJUST_BLOCK;
418 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
420 eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
421 if( eOldTVA != eTVA )
422 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
424 else
425 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
427 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
429 eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
430 if( eOldTHA != eTHA )
431 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
433 else
434 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
437 return true;
440 void SvxTextAttrPage::Construct()
442 switch (m_eObjKind)
444 case OBJ_NONE:
445 // indeterminate, show them all
446 bFitToSizeEnabled = bContourEnabled = bWordWrapTextEnabled =
447 bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true;
448 m_xCustomShapeText->show();
449 m_xDrawingText->show();
450 break;
451 case OBJ_TEXT:
452 case OBJ_TITLETEXT:
453 case OBJ_OUTLINETEXT:
454 case OBJ_CAPTION:
455 // contour NOT possible for pure text objects
456 bContourEnabled = bWordWrapTextEnabled = bAutoGrowSizeEnabled = false;
458 // adjusting width and height is ONLY possible for pure text objects
459 bFitToSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true;
460 m_xCustomShapeText->hide();
461 m_xDrawingText->show();
462 break;
463 case OBJ_CUSTOMSHAPE:
464 bFitToSizeEnabled = bContourEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false;
465 bWordWrapTextEnabled = bAutoGrowSizeEnabled = true;
466 m_xDrawingText->hide();
467 m_xCustomShapeText->show();
468 break;
469 default:
470 bFitToSizeEnabled = bContourEnabled = true;
471 bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false;
472 m_xCustomShapeText->hide();
473 m_xDrawingText->show();
474 break;
477 m_xTsbAutoGrowHeight->set_visible( bAutoGrowHeightEnabled );
478 m_xTsbAutoGrowWidth->set_visible( bAutoGrowWidthEnabled );
479 m_xTsbFitToSize->set_visible( bFitToSizeEnabled );
480 m_xTsbContour->set_visible( bContourEnabled );
481 m_xTsbAutoGrowSize->set_visible( bAutoGrowSizeEnabled );
482 m_xTsbWordWrapText->set_visible( bWordWrapTextEnabled );
485 VclPtr<SfxTabPage> SvxTextAttrPage::Create(TabPageParent pWindow, const SfxItemSet* rAttrs)
487 return VclPtr<SvxTextAttrPage>::Create(pWindow, *rAttrs);
490 /** Check whether we have to uncheck the "Full width" check box.
492 void SvxTextAttrPage::PointChanged(weld::DrawingArea*, RectPoint eRP)
494 if (m_xTsbFullWidth->get_state() == TRISTATE_TRUE)
496 // Depending on write direction and currently checked anchor we have
497 // to uncheck the "full width" button.
498 if (IsTextDirectionLeftToRight())
499 switch( eRP )
501 case RectPoint::LT:
502 case RectPoint::LM:
503 case RectPoint::LB:
504 case RectPoint::RT:
505 case RectPoint::RM:
506 case RectPoint::RB:
507 m_xTsbFullWidth->set_state( TRISTATE_FALSE );
508 break;
509 default: ;//prevent warning
511 else
512 switch (eRP)
514 case RectPoint::LT:
515 case RectPoint::MT:
516 case RectPoint::RT:
517 case RectPoint::LB:
518 case RectPoint::MB:
519 case RectPoint::RB:
520 m_xTsbFullWidth->set_state( TRISTATE_FALSE );
521 break;
522 default: ;//prevent warning
528 /*************************************************************************
530 |* possibly changes the position of the position-control
532 \************************************************************************/
534 /** When switching the "full width" check button on the text anchor may have
535 to be moved to a valid and adjacent position. This position depends on
536 the current anchor position and the text writing direction.
538 IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void)
540 if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
542 if (IsTextDirectionLeftToRight())
544 // Move text anchor to horizontal middle axis.
545 switch( m_aCtlPosition.GetActualRP() )
547 case RectPoint::LT:
548 case RectPoint::RT:
549 m_aCtlPosition.SetActualRP( RectPoint::MT );
550 break;
552 case RectPoint::LM:
553 case RectPoint::RM:
554 m_aCtlPosition.SetActualRP( RectPoint::MM );
555 break;
557 case RectPoint::LB:
558 case RectPoint::RB:
559 m_aCtlPosition.SetActualRP( RectPoint::MB );
560 break;
561 default: ;//prevent warning
564 else
566 // Move text anchor to vertical middle axis.
567 switch( m_aCtlPosition.GetActualRP() )
569 case RectPoint::LT:
570 case RectPoint::LB:
571 m_aCtlPosition.SetActualRP( RectPoint::LM );
572 break;
574 case RectPoint::MT:
575 case RectPoint::MB:
576 m_aCtlPosition.SetActualRP( RectPoint::MM );
577 break;
579 case RectPoint::RT:
580 case RectPoint::RB:
581 m_aCtlPosition.SetActualRP( RectPoint::RM );
582 break;
583 default: ;//prevent warning
589 /*************************************************************************
591 |* enables/disables "size at text" or "adjust to frame"
593 \************************************************************************/
595 IMPL_LINK(SvxTextAttrPage, ClickHdl_Impl, weld::Button&, rButton, void)
597 if (&rButton == m_xTsbAutoGrowSize.get())
599 m_xTsbAutoGrowHeight->set_state(m_xTsbAutoGrowSize->get_state());
600 if (m_xTsbAutoGrowSize->get_state() == TRISTATE_TRUE)
602 m_xTsbFitToSize->set_state(TRISTATE_FALSE);
603 m_xTsbContour->set_state(TRISTATE_FALSE);
606 else if (&rButton == m_xTsbAutoGrowHeight.get())
607 m_xTsbAutoGrowSize->set_state(m_xTsbAutoGrowHeight->get_state());
609 bool bAutoGrowWidth = m_xTsbAutoGrowWidth->get_state() == TRISTATE_TRUE;
610 bool bAutoGrowHeight = m_xTsbAutoGrowHeight->get_state() == TRISTATE_TRUE;
611 bool bFitToSize = m_xTsbFitToSize->get_state() == TRISTATE_TRUE;
612 bool bContour = m_xTsbContour->get_state() == TRISTATE_TRUE;
614 m_xTsbContour->set_sensitive( !bFitToSize &&
615 !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
616 bContourEnabled );
618 m_xTsbAutoGrowWidth->set_sensitive( !bFitToSize &&
619 !( bContour && bContourEnabled ) &&
620 bAutoGrowWidthEnabled );
622 m_xTsbAutoGrowHeight->set_sensitive( !bFitToSize &&
623 !( bContour && bContourEnabled ) &&
624 bAutoGrowHeightEnabled );
626 m_xTsbFitToSize->set_sensitive( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
627 !( bContour && bContourEnabled ) &&
628 bFitToSizeEnabled );
630 // #101901# enable/disable metric fields and decorations dependent of contour
631 m_xFlDistance->set_sensitive(!bContour);
633 if( bContour && bContourEnabled )
635 m_xMtrFldLeft->set_value(0, FieldUnit::NONE);
636 m_xMtrFldRight->set_value(0, FieldUnit::NONE);
637 m_xMtrFldTop->set_value(0, FieldUnit::NONE);
638 m_xMtrFldBottom->set_value(0, FieldUnit::NONE);
641 // #103516# Do the setup based on states of hor/ver adjust
642 SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
643 SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
644 bool bHorAndVer(SfxItemState::DONTCARE == eVState || SfxItemState::DONTCARE == eHState);
646 // #83698# enable/disable text anchoring dependent of contour
647 m_xFlPosition->set_sensitive(!bContour && !bHorAndVer);
651 bool SvxTextAttrPage::IsTextDirectionLeftToRight() const
653 // Determine the text writing direction with left to right as default.
654 bool bLeftToRightDirection = true;
655 SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
657 if(SfxItemState::DONTCARE != eState)
659 const SvxWritingModeItem& rItem = rOutAttrs.Get(SDRATTR_TEXTDIRECTION);
660 if (rItem.GetValue() == css::text::WritingMode_TB_RL)
661 bLeftToRightDirection = false;
663 return bLeftToRightDirection;
666 void SvxTextAttrPage::PageCreated(const SfxAllItemSet& aSet)
668 const CntUInt16Item* pObjTypeItem = aSet.GetItem<CntUInt16Item>(SID_SVXTEXTATTRPAGE_OBJKIND, false);
670 if (pObjTypeItem)
671 SetObjKind(static_cast<SdrObjKind>(pObjTypeItem->GetValue()));
673 Construct();
676 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */