1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <svx/svddef.hxx>
21 #include <svx/sdasitm.hxx>
22 #include <svx/sdtditm.hxx>
23 #include <svx/sdtagitm.hxx>
24 #include <svx/sdtaitm.hxx>
25 #include <svx/sdtfsitm.hxx>
26 #include <svx/sdtcfitm.hxx>
27 #include <svx/svxids.hrc>
29 #include <textattr.hxx>
30 #include <svx/dlgutil.hxx>
31 #include <editeng/writingmodeitem.hxx>
32 #include <svtools/unitconv.hxx>
33 #include <osl/diagnose.h>
35 using namespace ::com::sun::star
;
37 const WhichRangesContainer
SvxTextAttrPage::pRanges(
39 SDRATTR_MISC_FIRST
,SDRATTR_TEXT_HORZADJUST
,
40 SDRATTR_TEXT_WORDWRAP
, SDRATTR_TEXT_WORDWRAP
43 /*************************************************************************
45 |* dialog (page) for copying objects
47 \************************************************************************/
48 SvxTextAttrPage::SvxTextAttrPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rInAttrs
)
49 : SvxTabPage(pPage
, pController
, "cui/ui/textattrtabpage.ui", "TextAttributesPage", rInAttrs
)
51 , m_eObjKind(SdrObjKind::NONE
)
52 , bAutoGrowSizeEnabled(false)
53 , bContourEnabled(false)
54 , bAutoGrowWidthEnabled(false)
55 , bAutoGrowHeightEnabled(false)
56 , bWordWrapTextEnabled(false)
57 , bFitToSizeEnabled(false)
58 , m_aCtlPosition(this)
59 , m_xDrawingText(m_xBuilder
->weld_widget("drawingtext"))
60 , m_xCustomShapeText(m_xBuilder
->weld_widget("customshapetext"))
61 , m_xTsbAutoGrowWidth(m_xBuilder
->weld_check_button("TSB_AUTOGROW_WIDTH"))
62 , m_xTsbAutoGrowHeight(m_xBuilder
->weld_check_button("TSB_AUTOGROW_HEIGHT"))
63 , m_xTsbFitToSize(m_xBuilder
->weld_check_button("TSB_FIT_TO_SIZE"))
64 , m_xTsbContour(m_xBuilder
->weld_check_button("TSB_CONTOUR"))
65 , m_xTsbWordWrapText(m_xBuilder
->weld_check_button("TSB_WORDWRAP_TEXT"))
66 , m_xTsbAutoGrowSize(m_xBuilder
->weld_check_button("TSB_AUTOGROW_SIZE"))
67 , m_xFlDistance(m_xBuilder
->weld_frame("FL_DISTANCE"))
68 , m_xMtrFldLeft(m_xBuilder
->weld_metric_spin_button("MTR_FLD_LEFT", FieldUnit::CM
))
69 , m_xMtrFldRight(m_xBuilder
->weld_metric_spin_button("MTR_FLD_RIGHT", FieldUnit::CM
))
70 , m_xMtrFldTop(m_xBuilder
->weld_metric_spin_button("MTR_FLD_TOP", FieldUnit::CM
))
71 , m_xMtrFldBottom(m_xBuilder
->weld_metric_spin_button("MTR_FLD_BOTTOM", FieldUnit::CM
))
72 , m_xFlPosition(m_xBuilder
->weld_frame("FL_POSITION"))
73 , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder
, "CTL_POSITION", m_aCtlPosition
))
74 , m_xTsbFullWidth(m_xBuilder
->weld_check_button("TSB_FULL_WIDTH"))
76 m_aCtlPosition
.SetControlSettings(RectPoint::MM
, 240);
78 FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
79 SetFieldUnit( *m_xMtrFldLeft
, eFUnit
);
80 SetFieldUnit( *m_xMtrFldRight
, eFUnit
);
81 SetFieldUnit( *m_xMtrFldTop
, eFUnit
);
82 SetFieldUnit( *m_xMtrFldBottom
, eFUnit
);
84 Link
<weld::Toggleable
&,void> aLink( LINK( this, SvxTextAttrPage
, ClickHdl_Impl
) );
85 m_xTsbAutoGrowWidth
->connect_toggled( aLink
);
86 m_xTsbAutoGrowHeight
->connect_toggled( aLink
);
87 m_xTsbAutoGrowSize
->connect_toggled( aLink
);
88 m_xTsbFitToSize
->connect_toggled( aLink
);
89 m_xTsbContour
->connect_toggled( aLink
);
91 m_xTsbFullWidth
->connect_toggled(LINK( this, SvxTextAttrPage
, ClickFullWidthHdl_Impl
) );
94 SvxTextAttrPage::~SvxTextAttrPage()
98 /*************************************************************************
100 |* reads the passed item set
102 \************************************************************************/
104 void SvxTextAttrPage::Reset( const SfxItemSet
* rAttrs
)
106 SfxItemPool
* pPool
= rAttrs
->GetPool();
107 DBG_ASSERT( pPool
, "Where is the pool?" );
108 MapUnit eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
110 const SdrMetricItem
* pItem
= GetItem(*rAttrs
, SDRATTR_TEXT_LEFTDIST
);
112 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_LEFTDIST
);
114 SetMetricValue(*m_xMtrFldLeft
, pItem
->GetValue(), eUnit
);
115 m_xMtrFldLeft
->save_value();
117 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_RIGHTDIST
);
119 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST
);
121 SetMetricValue(*m_xMtrFldRight
, pItem
->GetValue(), eUnit
);
122 m_xMtrFldRight
->save_value();
124 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_UPPERDIST
);
126 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_UPPERDIST
);
128 SetMetricValue(*m_xMtrFldTop
, pItem
->GetValue(), eUnit
);
129 m_xMtrFldTop
->save_value();
131 pItem
= GetItem( *rAttrs
, SDRATTR_TEXT_LOWERDIST
);
133 pItem
= &pPool
->GetDefaultItem( SDRATTR_TEXT_LOWERDIST
);
135 SetMetricValue(*m_xMtrFldBottom
, pItem
->GetValue(), eUnit
);
136 m_xMtrFldBottom
->save_value();
138 // adjust to height and autogrowsize
139 if ( rAttrs
->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT
) != SfxItemState::DONTCARE
)
141 m_xTsbAutoGrowHeight
->set_state( rAttrs
->Get( SDRATTR_TEXT_AUTOGROWHEIGHT
).
142 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
144 m_xTsbAutoGrowSize
->set_state( rAttrs
->Get( SDRATTR_TEXT_AUTOGROWHEIGHT
).
145 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
149 m_xTsbAutoGrowHeight
->set_state( TRISTATE_INDET
);
150 m_xTsbAutoGrowSize
->set_state( TRISTATE_INDET
);
152 m_xTsbAutoGrowHeight
->save_state();
153 m_xTsbAutoGrowSize
->save_state();
156 if ( rAttrs
->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH
) != SfxItemState::DONTCARE
)
158 m_xTsbAutoGrowWidth
->set_state( rAttrs
->Get( SDRATTR_TEXT_AUTOGROWWIDTH
).
159 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
162 m_xTsbAutoGrowWidth
->set_state( TRISTATE_INDET
);
163 m_xTsbAutoGrowWidth
->save_state();
166 if ( rAttrs
->GetItemState( SDRATTR_TEXT_WORDWRAP
) != SfxItemState::DONTCARE
)
168 m_xTsbWordWrapText
->set_state( rAttrs
->Get( SDRATTR_TEXT_WORDWRAP
).
169 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
172 m_xTsbWordWrapText
->set_state( TRISTATE_INDET
);
173 m_xTsbWordWrapText
->save_state();
176 // #103516# Do the setup based on states of hor/ver adjust
177 // Setup center field and FullWidth
178 SfxItemState eVState
= rAttrs
->GetItemState( SDRATTR_TEXT_VERTADJUST
);
179 SfxItemState eHState
= rAttrs
->GetItemState( SDRATTR_TEXT_HORZADJUST
);
181 if(SfxItemState::DONTCARE
!= eVState
&& SfxItemState::DONTCARE
!= eHState
)
183 // VertAdjust and HorAdjust are unequivocal, thus
184 SdrTextVertAdjust eTVA
= rAttrs
->Get(SDRATTR_TEXT_VERTADJUST
).GetValue();
185 SdrTextHorzAdjust eTHA
= rAttrs
->Get(SDRATTR_TEXT_HORZADJUST
).GetValue();
186 RectPoint eRP
= RectPoint::LB
;
188 if (m_xTsbFullWidth
->get_state() == TRISTATE_INDET
)
189 m_xTsbFullWidth
->set_state(TRISTATE_FALSE
);
191 // Translate item values into local anchor position.
194 case SDRTEXTVERTADJUST_TOP
:
198 case SDRTEXTHORZADJUST_LEFT
: eRP
= RectPoint::LT
; break;
199 case SDRTEXTHORZADJUST_BLOCK
:
200 case SDRTEXTHORZADJUST_CENTER
: eRP
= RectPoint::MT
; break;
201 case SDRTEXTHORZADJUST_RIGHT
: eRP
= RectPoint::RT
; break;
205 case SDRTEXTVERTADJUST_BLOCK
:
206 case SDRTEXTVERTADJUST_CENTER
:
210 case SDRTEXTHORZADJUST_LEFT
: eRP
= RectPoint::LM
; break;
211 case SDRTEXTHORZADJUST_BLOCK
:
212 case SDRTEXTHORZADJUST_CENTER
: eRP
= RectPoint::MM
; break;
213 case SDRTEXTHORZADJUST_RIGHT
: eRP
= RectPoint::RM
; break;
217 case SDRTEXTVERTADJUST_BOTTOM
:
221 case SDRTEXTHORZADJUST_LEFT
: eRP
= RectPoint::LB
; break;
222 case SDRTEXTHORZADJUST_BLOCK
:
223 case SDRTEXTHORZADJUST_CENTER
: eRP
= RectPoint::MB
; break;
224 case SDRTEXTHORZADJUST_RIGHT
: eRP
= RectPoint::RB
; break;
232 // See if we have to check the "full width" check button.
233 bool bLeftToRight(IsTextDirectionLeftToRight());
235 if((bLeftToRight
&& (SDRTEXTHORZADJUST_BLOCK
== eTHA
)) || (!bLeftToRight
&& (SDRTEXTVERTADJUST_BLOCK
== eTVA
)))
237 // Move anchor to valid position.
238 ClickFullWidthHdl_Impl(*m_xTsbFullWidth
);
239 m_xTsbFullWidth
->set_state(TRISTATE_TRUE
);
242 m_aCtlPosition
.SetActualRP( eRP
);
246 // VertAdjust or HorAdjust is not unequivocal
247 m_aCtlPosition
.Reset();
249 m_aCtlPosition
.SetState(CTL_STATE::NOVERT
);
250 m_aCtlPosition
.DoCompletelyDisable(true);
252 m_xTsbFullWidth
->set_state(TRISTATE_INDET
);
253 m_xFlPosition
->set_sensitive( false );
257 if (rAttrs
->GetItemState(SDRATTR_TEXT_FITTOSIZE
) != SfxItemState::DONTCARE
)
259 drawing::TextFitToSizeType
const eFTS
=
260 rAttrs
->Get( SDRATTR_TEXT_FITTOSIZE
).GetValue();
261 if (eFTS
== drawing::TextFitToSizeType_AUTOFIT
|| eFTS
== drawing::TextFitToSizeType_NONE
)
262 m_xTsbFitToSize
->set_state( TRISTATE_FALSE
);
264 m_xTsbFitToSize
->set_state( TRISTATE_TRUE
);
267 m_xTsbFitToSize
->set_state( TRISTATE_INDET
);
268 m_xTsbFitToSize
->save_state();
270 if( rAttrs
->GetItemState( SDRATTR_TEXT_CONTOURFRAME
) != SfxItemState::DONTCARE
)
272 bool bContour
= rAttrs
->Get( SDRATTR_TEXT_CONTOURFRAME
).GetValue();
273 m_xTsbContour
->set_state( bContour
? TRISTATE_TRUE
: TRISTATE_FALSE
);
276 m_xTsbContour
->set_state( TRISTATE_INDET
);
277 m_xTsbContour
->save_state();
279 ClickHdl_Impl(*m_xTsbContour
);
282 /*************************************************************************
284 |* fills the passed item set with dialog box attributes
286 \************************************************************************/
288 bool SvxTextAttrPage::FillItemSet( SfxItemSet
* rAttrs
)
290 SfxItemPool
* pPool
= rAttrs
->GetPool();
291 DBG_ASSERT( pPool
, "Where is the pool?" );
292 MapUnit eUnit
= pPool
->GetMetric( SDRATTR_TEXT_LEFTDIST
);
297 if( m_xMtrFldLeft
->get_value_changed_from_saved() )
299 nValue
= GetCoreValue( *m_xMtrFldLeft
, eUnit
);
300 rAttrs
->Put( makeSdrTextLeftDistItem( nValue
) );
303 if( m_xMtrFldRight
->get_value_changed_from_saved() )
305 nValue
= GetCoreValue( *m_xMtrFldRight
, eUnit
);
306 rAttrs
->Put( makeSdrTextRightDistItem( nValue
) );
309 if( m_xMtrFldTop
->get_value_changed_from_saved() )
311 nValue
= GetCoreValue( *m_xMtrFldTop
, eUnit
);
312 rAttrs
->Put( makeSdrTextUpperDistItem( nValue
) );
315 if( m_xMtrFldBottom
->get_value_changed_from_saved() )
317 nValue
= GetCoreValue( *m_xMtrFldBottom
, eUnit
);
318 rAttrs
->Put( makeSdrTextLowerDistItem( nValue
) );
321 eState
= m_xTsbAutoGrowHeight
->get_state();
322 if( m_xTsbAutoGrowHeight
->get_state_changed_from_saved() )
324 rAttrs
->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE
== eState
) );
327 eState
= m_xTsbAutoGrowWidth
->get_state();
328 if( m_xTsbAutoGrowWidth
->get_state_changed_from_saved() )
330 rAttrs
->Put( makeSdrTextAutoGrowWidthItem( TRISTATE_TRUE
== eState
) );
333 eState
= m_xTsbAutoGrowSize
->get_state();
334 if( m_xTsbAutoGrowSize
->get_state_changed_from_saved() )
336 rAttrs
->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE
== eState
) );
339 eState
= m_xTsbWordWrapText
->get_state();
340 if( m_xTsbWordWrapText
->get_state_changed_from_saved() )
342 rAttrs
->Put( makeSdrTextWordWrapItem( TRISTATE_TRUE
== eState
) );
345 eState
= m_xTsbContour
->get_state();
346 if( m_xTsbContour
->get_state_changed_from_saved() )
348 rAttrs
->Put( makeSdrTextContourFrameItem( TRISTATE_TRUE
== eState
) );
351 eState
= m_xTsbFitToSize
->get_state();
352 if( m_xTsbFitToSize
->get_state_changed_from_saved() )
354 drawing::TextFitToSizeType eFTS
;
357 default: ; //prevent warning
358 OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
360 case TRISTATE_FALSE
: eFTS
= drawing::TextFitToSizeType_AUTOFIT
; break;
361 case TRISTATE_TRUE
: eFTS
= drawing::TextFitToSizeType_PROPORTIONAL
; break;
363 rAttrs
->Put( SdrTextFitToSizeTypeItem( eFTS
) );
367 RectPoint eRP
= m_aCtlPosition
.GetActualRP();
368 SdrTextVertAdjust eTVA
;
369 SdrTextHorzAdjust eTHA
;
374 case RectPoint::LT
: eTVA
= SDRTEXTVERTADJUST_TOP
;
375 eTHA
= SDRTEXTHORZADJUST_LEFT
; break;
376 case RectPoint::LM
: eTVA
= SDRTEXTVERTADJUST_CENTER
;
377 eTHA
= SDRTEXTHORZADJUST_LEFT
; break;
378 case RectPoint::LB
: eTVA
= SDRTEXTVERTADJUST_BOTTOM
;
379 eTHA
= SDRTEXTHORZADJUST_LEFT
; break;
380 case RectPoint::MT
: eTVA
= SDRTEXTVERTADJUST_TOP
;
381 eTHA
= SDRTEXTHORZADJUST_CENTER
; break;
382 case RectPoint::MM
: eTVA
= SDRTEXTVERTADJUST_CENTER
;
383 eTHA
= SDRTEXTHORZADJUST_CENTER
; break;
384 case RectPoint::MB
: eTVA
= SDRTEXTVERTADJUST_BOTTOM
;
385 eTHA
= SDRTEXTHORZADJUST_CENTER
; break;
386 case RectPoint::RT
: eTVA
= SDRTEXTVERTADJUST_TOP
;
387 eTHA
= SDRTEXTHORZADJUST_RIGHT
; break;
388 case RectPoint::RM
: eTVA
= SDRTEXTVERTADJUST_CENTER
;
389 eTHA
= SDRTEXTHORZADJUST_RIGHT
; break;
390 case RectPoint::RB
: eTVA
= SDRTEXTVERTADJUST_BOTTOM
;
391 eTHA
= SDRTEXTHORZADJUST_RIGHT
; break;
394 // #103516# Do not change values if adjust controls were disabled.
395 bool bIsDisabled(m_aCtlPosition
.IsCompletelyDisabled());
400 if( m_xTsbFullWidth
->get_state() == TRISTATE_TRUE
)
402 if (IsTextDirectionLeftToRight())
403 eTHA
= SDRTEXTHORZADJUST_BLOCK
;
405 eTVA
= SDRTEXTVERTADJUST_BLOCK
;
408 if ( rOutAttrs
.GetItemState( SDRATTR_TEXT_VERTADJUST
) != SfxItemState::DONTCARE
)
410 SdrTextVertAdjust eOldTVA
= rOutAttrs
.Get( SDRATTR_TEXT_VERTADJUST
).GetValue();
411 if( eOldTVA
!= eTVA
)
412 rAttrs
->Put( SdrTextVertAdjustItem( eTVA
) );
415 rAttrs
->Put( SdrTextVertAdjustItem( eTVA
) );
417 if ( rOutAttrs
.GetItemState( SDRATTR_TEXT_HORZADJUST
) != SfxItemState::DONTCARE
)
419 SdrTextHorzAdjust eOldTHA
= rOutAttrs
.Get( SDRATTR_TEXT_HORZADJUST
).GetValue();
420 if( eOldTHA
!= eTHA
)
421 rAttrs
->Put( SdrTextHorzAdjustItem( eTHA
) );
424 rAttrs
->Put( SdrTextHorzAdjustItem( eTHA
) );
429 void SvxTextAttrPage::Construct()
433 case SdrObjKind::NONE
:
434 // indeterminate, show them all
435 bFitToSizeEnabled
= bContourEnabled
= bWordWrapTextEnabled
=
436 bAutoGrowSizeEnabled
= bAutoGrowWidthEnabled
= bAutoGrowHeightEnabled
= true;
437 m_xCustomShapeText
->show();
438 m_xDrawingText
->show();
440 case SdrObjKind::Text
:
441 case SdrObjKind::TitleText
:
442 case SdrObjKind::OutlineText
:
443 case SdrObjKind::Caption
:
444 // contour NOT possible for pure text objects
445 bContourEnabled
= bWordWrapTextEnabled
= bAutoGrowSizeEnabled
= false;
447 // adjusting width and height is ONLY possible for pure text objects
448 bFitToSizeEnabled
= bAutoGrowWidthEnabled
= bAutoGrowHeightEnabled
= true;
449 m_xCustomShapeText
->hide();
450 m_xDrawingText
->show();
452 case SdrObjKind::CustomShape
:
453 bFitToSizeEnabled
= bContourEnabled
= bAutoGrowWidthEnabled
= bAutoGrowHeightEnabled
= false;
454 bWordWrapTextEnabled
= bAutoGrowSizeEnabled
= true;
455 m_xDrawingText
->hide();
456 m_xCustomShapeText
->show();
459 bFitToSizeEnabled
= bContourEnabled
= true;
460 bWordWrapTextEnabled
= bAutoGrowSizeEnabled
= bAutoGrowWidthEnabled
= bAutoGrowHeightEnabled
= false;
461 m_xCustomShapeText
->hide();
462 m_xDrawingText
->show();
466 m_xTsbAutoGrowHeight
->set_visible( bAutoGrowHeightEnabled
);
467 m_xTsbAutoGrowWidth
->set_visible( bAutoGrowWidthEnabled
);
468 m_xTsbFitToSize
->set_visible( bFitToSizeEnabled
);
469 m_xTsbContour
->set_visible( bContourEnabled
);
470 m_xTsbAutoGrowSize
->set_visible( bAutoGrowSizeEnabled
);
471 m_xTsbWordWrapText
->set_visible( bWordWrapTextEnabled
);
474 std::unique_ptr
<SfxTabPage
> SvxTextAttrPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrs
)
476 return std::make_unique
<SvxTextAttrPage
>(pPage
, pController
, *rAttrs
);
479 /** Check whether we have to uncheck the "Full width" check box.
481 void SvxTextAttrPage::PointChanged(weld::DrawingArea
*, RectPoint eRP
)
483 if (m_xTsbFullWidth
->get_state() != TRISTATE_TRUE
)
486 // Depending on write direction and currently checked anchor we have
487 // to uncheck the "full width" button.
488 if (IsTextDirectionLeftToRight())
497 m_xTsbFullWidth
->set_state( TRISTATE_FALSE
);
499 default: ;//prevent warning
510 m_xTsbFullWidth
->set_state( TRISTATE_FALSE
);
512 default: ;//prevent warning
517 /*************************************************************************
519 |* possibly changes the position of the position-control
521 \************************************************************************/
523 /** When switching the "full width" check button on the text anchor may have
524 to be moved to a valid and adjacent position. This position depends on
525 the current anchor position and the text writing direction.
527 IMPL_LINK_NOARG(SvxTextAttrPage
, ClickFullWidthHdl_Impl
, weld::Toggleable
&, void)
529 if( m_xTsbFullWidth
->get_state() != TRISTATE_TRUE
)
532 if (IsTextDirectionLeftToRight())
534 // Move text anchor to horizontal middle axis.
535 switch( m_aCtlPosition
.GetActualRP() )
539 m_aCtlPosition
.SetActualRP( RectPoint::MT
);
544 m_aCtlPosition
.SetActualRP( RectPoint::MM
);
549 m_aCtlPosition
.SetActualRP( RectPoint::MB
);
551 default: ;//prevent warning
556 // Move text anchor to vertical middle axis.
557 switch( m_aCtlPosition
.GetActualRP() )
561 m_aCtlPosition
.SetActualRP( RectPoint::LM
);
566 m_aCtlPosition
.SetActualRP( RectPoint::MM
);
571 m_aCtlPosition
.SetActualRP( RectPoint::RM
);
573 default: ;//prevent warning
578 /*************************************************************************
580 |* enables/disables "size at text" or "adjust to frame"
582 \************************************************************************/
584 IMPL_LINK(SvxTextAttrPage
, ClickHdl_Impl
, weld::Toggleable
&, rButton
, void)
586 if (&rButton
== m_xTsbAutoGrowSize
.get())
588 m_xTsbAutoGrowHeight
->set_state(m_xTsbAutoGrowSize
->get_state());
589 if (m_xTsbAutoGrowSize
->get_state() == TRISTATE_TRUE
)
591 m_xTsbFitToSize
->set_state(TRISTATE_FALSE
);
592 m_xTsbContour
->set_state(TRISTATE_FALSE
);
595 else if (&rButton
== m_xTsbAutoGrowHeight
.get())
596 m_xTsbAutoGrowSize
->set_state(m_xTsbAutoGrowHeight
->get_state());
598 bool bAutoGrowWidth
= m_xTsbAutoGrowWidth
->get_state() == TRISTATE_TRUE
;
599 bool bAutoGrowHeight
= m_xTsbAutoGrowHeight
->get_state() == TRISTATE_TRUE
;
600 bool bFitToSize
= m_xTsbFitToSize
->get_state() == TRISTATE_TRUE
;
601 bool bContour
= m_xTsbContour
->get_state() == TRISTATE_TRUE
;
603 m_xTsbContour
->set_sensitive( !bFitToSize
&&
604 !( ( bAutoGrowWidth
&& bAutoGrowWidthEnabled
) || ( bAutoGrowHeight
&& bAutoGrowHeightEnabled
) ) &&
607 m_xTsbAutoGrowWidth
->set_sensitive( !bFitToSize
&&
608 !( bContour
&& bContourEnabled
) &&
609 bAutoGrowWidthEnabled
);
611 m_xTsbAutoGrowHeight
->set_sensitive( !bFitToSize
&&
612 !( bContour
&& bContourEnabled
) &&
613 bAutoGrowHeightEnabled
);
615 m_xTsbFitToSize
->set_sensitive( !( ( bAutoGrowWidth
&& bAutoGrowWidthEnabled
) || ( bAutoGrowHeight
&& bAutoGrowHeightEnabled
) ) &&
616 !( bContour
&& bContourEnabled
) &&
619 // #101901# enable/disable metric fields and decorations dependent of contour
620 m_xFlDistance
->set_sensitive(!bContour
);
622 if( bContour
&& bContourEnabled
)
624 m_xMtrFldLeft
->set_value(0, FieldUnit::NONE
);
625 m_xMtrFldRight
->set_value(0, FieldUnit::NONE
);
626 m_xMtrFldTop
->set_value(0, FieldUnit::NONE
);
627 m_xMtrFldBottom
->set_value(0, FieldUnit::NONE
);
630 // #103516# Do the setup based on states of hor/ver adjust
631 SfxItemState eVState
= rOutAttrs
.GetItemState( SDRATTR_TEXT_VERTADJUST
);
632 SfxItemState eHState
= rOutAttrs
.GetItemState( SDRATTR_TEXT_HORZADJUST
);
633 bool bHorAndVer(SfxItemState::DONTCARE
== eVState
|| SfxItemState::DONTCARE
== eHState
);
635 // #83698# enable/disable text anchoring dependent of contour
636 m_xFlPosition
->set_sensitive(!bContour
&& !bHorAndVer
);
640 bool SvxTextAttrPage::IsTextDirectionLeftToRight() const
642 // Determine the text writing direction with left to right as default.
643 bool bLeftToRightDirection
= true;
644 SfxItemState eState
= rOutAttrs
.GetItemState(SDRATTR_TEXTDIRECTION
);
646 if(SfxItemState::DONTCARE
!= eState
)
648 const SvxWritingModeItem
& rItem
= rOutAttrs
.Get(SDRATTR_TEXTDIRECTION
);
649 if (rItem
.GetValue() == css::text::WritingMode_TB_RL
)
650 bLeftToRightDirection
= false;
652 return bLeftToRightDirection
;
655 void SvxTextAttrPage::PageCreated(const SfxAllItemSet
& aSet
)
657 const CntUInt16Item
* pObjTypeItem
= aSet
.GetItem
<CntUInt16Item
>(SID_SVXTEXTATTRPAGE_OBJKIND
, false);
660 SetObjKind(static_cast<SdrObjKind
>(pObjTypeItem
->GetValue()));
665 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */