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 <strings.hrc>
21 #include <dialmgr.hxx>
22 #include <sfx2/app.hxx>
23 #include <sfx2/module.hxx>
24 #include <sfx2/request.hxx>
25 #include <vcl/settings.hxx>
27 #include <svx/dialogs.hrc>
28 #include <svx/svxids.hrc>
29 #include <svx/dlgutil.hxx>
30 #include <svx/measctrl.hxx>
31 #include <svx/ofaitem.hxx>
32 #include <svx/strarray.hxx>
33 #include <svx/svdomeas.hxx>
34 #include <svx/svdview.hxx>
35 #include <svx/sxekitm.hxx>
36 #include <svx/sxelditm.hxx>
37 #include <svx/sxenditm.hxx>
38 #include <svx/sxmbritm.hxx>
39 #include <svx/sxmfsitm.hxx>
40 #include <svx/sxmlhitm.hxx>
41 #include <svx/sxmtfitm.hxx>
42 #include <svx/sxmtpitm.hxx>
43 #include <svx/sxmtritm.hxx>
44 #include <svx/sxmuitm.hxx>
45 #include <svtools/unitconv.hxx>
47 #include <measure.hxx>
49 const sal_uInt16
SvxMeasurePage::pRanges
[] =
51 SDRATTR_MEASURE_FIRST
,
56 /*************************************************************************
58 |* Dialog to change measure-attributes
60 \************************************************************************/
62 SvxMeasureDialog::SvxMeasureDialog(weld::Window
* pParent
, const SfxItemSet
& rInAttrs
,
63 const SdrView
* pSdrView
)
64 : SfxSingleTabDialogController(pParent
, &rInAttrs
)
66 TabPageParent
pPageParent(get_content_area(), this);
67 VclPtrInstance
<SvxMeasurePage
> pPage(pPageParent
, rInAttrs
);
69 pPage
->SetView(pSdrView
);
73 m_xDialog
->set_title(CuiResId(RID_SVXSTR_DIMENSION_LINE
));
76 /*************************************************************************
78 |* Tabpage for changing measure-attributes
80 \************************************************************************/
82 SvxMeasurePage::SvxMeasurePage(TabPageParent pWindow
, const SfxItemSet
& rInAttrs
)
83 : SvxTabPage(pWindow
, "cui/ui/dimensionlinestabpage.ui", "DimensionLinesTabPage", rInAttrs
)
85 , aAttrSet(*rInAttrs
.GetPool())
87 , eUnit(MapUnit::Map100thMM
)
88 , bPositionModified(false)
89 , m_aCtlPosition(this)
90 , m_xMtrFldLineDist(m_xBuilder
->weld_metric_spin_button("MTR_LINE_DIST", FieldUnit::MM
))
91 , m_xMtrFldHelplineOverhang(m_xBuilder
->weld_metric_spin_button("MTR_FLD_HELPLINE_OVERHANG", FieldUnit::MM
))
92 , m_xMtrFldHelplineDist(m_xBuilder
->weld_metric_spin_button("MTR_FLD_HELPLINE_DIST", FieldUnit::MM
))
93 , m_xMtrFldHelpline1Len(m_xBuilder
->weld_metric_spin_button("MTR_FLD_HELPLINE1_LEN", FieldUnit::MM
))
94 , m_xMtrFldHelpline2Len(m_xBuilder
->weld_metric_spin_button("MTR_FLD_HELPLINE2_LEN", FieldUnit::MM
))
95 , m_xTsbBelowRefEdge(m_xBuilder
->weld_check_button("TSB_BELOW_REF_EDGE"))
96 , m_xMtrFldDecimalPlaces(m_xBuilder
->weld_spin_button("MTR_FLD_DECIMALPLACES"))
97 , m_xTsbAutoPosV(m_xBuilder
->weld_check_button("TSB_AUTOPOSV"))
98 , m_xTsbAutoPosH(m_xBuilder
->weld_check_button("TSB_AUTOPOSH"))
99 , m_xTsbShowUnit(m_xBuilder
->weld_check_button("TSB_SHOW_UNIT"))
100 , m_xLbUnit(m_xBuilder
->weld_combo_box("LB_UNIT"))
101 , m_xTsbParallel(m_xBuilder
->weld_check_button("TSB_PARALLEL"))
102 , m_xFtAutomatic(m_xBuilder
->weld_label("STR_MEASURE_AUTOMATIC"))
103 , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder
, "CTL_POSITION", m_aCtlPosition
))
104 , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder
, "CTL_PREVIEW", m_aCtlPreview
))
106 m_aCtlPreview
.SetAttributes(rInAttrs
);
110 const FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
111 SetFieldUnit( *m_xMtrFldLineDist
, eFUnit
);
112 SetFieldUnit( *m_xMtrFldHelplineOverhang
, eFUnit
);
113 SetFieldUnit( *m_xMtrFldHelplineDist
, eFUnit
);
114 SetFieldUnit( *m_xMtrFldHelpline1Len
, eFUnit
);
115 SetFieldUnit( *m_xMtrFldHelpline2Len
, eFUnit
);
116 if( eFUnit
== FieldUnit::MM
)
118 m_xMtrFldLineDist
->set_increments(50, 500, FieldUnit::NONE
);
119 m_xMtrFldHelplineOverhang
->set_increments(50, 500, FieldUnit::NONE
);
120 m_xMtrFldHelplineDist
->set_increments(50, 500, FieldUnit::NONE
);
121 m_xMtrFldHelpline1Len
->set_increments(50, 500, FieldUnit::NONE
);
122 m_xMtrFldHelpline2Len
->set_increments(50, 500, FieldUnit::NONE
);
125 m_xTsbAutoPosV
->connect_toggled(LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
));
126 m_xTsbAutoPosH
->connect_toggled(LINK(this, SvxMeasurePage
, ClickAutoPosHdl_Impl
));
128 Link
<weld::MetricSpinButton
&,void> aLink(LINK(this, SvxMeasurePage
, ChangeAttrEditHdl_Impl
));
129 m_xMtrFldLineDist
->connect_value_changed(aLink
);
130 m_xMtrFldHelplineOverhang
->connect_value_changed(aLink
);
131 m_xMtrFldHelplineDist
->connect_value_changed(aLink
);
132 m_xMtrFldHelpline1Len
->connect_value_changed(aLink
);
133 m_xMtrFldHelpline2Len
->connect_value_changed(aLink
);
134 m_xMtrFldDecimalPlaces
->connect_value_changed(LINK(this, SvxMeasurePage
, ChangeAttrSpinHdl_Impl
));
135 m_xTsbBelowRefEdge
->connect_toggled(LINK(this, SvxMeasurePage
, ChangeAttrClickHdl_Impl
));
136 m_xTsbParallel
->connect_toggled( LINK( this, SvxMeasurePage
, ChangeAttrClickHdl_Impl
));
137 m_xTsbShowUnit
->connect_toggled(LINK(this, SvxMeasurePage
, ChangeAttrClickHdl_Impl
));
138 m_xLbUnit
->connect_changed(LINK(this, SvxMeasurePage
, ChangeAttrListBoxHdl_Impl
));
141 SvxMeasurePage::~SvxMeasurePage()
146 void SvxMeasurePage::dispose()
148 m_xCtlPreview
.reset();
149 m_xCtlPosition
.reset();
150 SvxTabPage::dispose();
153 /*************************************************************************
155 |* read the delivered Item-Set
157 \************************************************************************/
159 void SvxMeasurePage::Reset( const SfxItemSet
* rAttrs
)
161 SfxItemPool
* pPool
= rAttrs
->GetPool();
162 DBG_ASSERT( pPool
, "Where is the pool?" );
163 eUnit
= pPool
->GetMetric( SDRATTR_MEASURELINEDIST
);
165 const SfxPoolItem
* pItem
= GetItem( *rAttrs
, SDRATTR_MEASURELINEDIST
);
167 // SdrMeasureLineDistItem
168 if( pItem
== nullptr )
169 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASURELINEDIST
);
170 SetMetricValue(*m_xMtrFldLineDist
, static_cast<const SdrMetricItem
*>(pItem
)->GetValue(), eUnit
);
171 m_xMtrFldLineDist
->save_value();
173 // SdrMeasureHelplineOverhangItem
174 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINEOVERHANG
);
175 if( pItem
== nullptr )
176 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG
);
177 SetMetricValue(*m_xMtrFldHelplineOverhang
, static_cast<const SdrMetricItem
*>(pItem
)->GetValue(),
179 m_xMtrFldHelplineOverhang
->save_value();
181 // SdrMeasureHelplineDistItem
182 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINEDIST
);
183 if( pItem
== nullptr )
184 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST
);
185 SetMetricValue(*m_xMtrFldHelplineDist
, static_cast<const SdrMetricItem
*>(pItem
)->GetValue(),
187 m_xMtrFldHelplineDist
->save_value();
189 // SdrMeasureHelpline1LenItem
190 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINE1LEN
);
191 if( pItem
== nullptr )
192 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN
);
193 SetMetricValue(*m_xMtrFldHelpline1Len
, static_cast<const SdrMetricItem
*>(pItem
)->GetValue(),
195 m_xMtrFldHelpline1Len
->save_value();
197 // SdrMeasureHelpline2LenItem
198 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINE2LEN
);
199 if( pItem
== nullptr )
200 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN
);
201 SetMetricValue(*m_xMtrFldHelpline2Len
, static_cast<const SdrMetricItem
*>(pItem
)->GetValue(),
203 m_xMtrFldHelpline2Len
->save_value();
205 // SdrMeasureBelowRefEdgeItem
206 if( rAttrs
->GetItemState( SDRATTR_MEASUREBELOWREFEDGE
) != SfxItemState::DONTCARE
)
208 m_xTsbBelowRefEdge
->set_state( rAttrs
->Get( SDRATTR_MEASUREBELOWREFEDGE
).
209 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
213 m_xTsbBelowRefEdge
->set_state( TRISTATE_INDET
);
215 m_xTsbBelowRefEdge
->save_state();
217 // SdrMeasureDecimalPlacesItem
218 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREDECIMALPLACES
);
219 if( pItem
== nullptr )
220 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES
);
221 m_xMtrFldDecimalPlaces
->set_value(
222 static_cast<const SdrMeasureDecimalPlacesItem
*>(pItem
)->GetValue());
223 m_xMtrFldDecimalPlaces
->save_value();
225 // SdrMeasureTextRota90Item
226 // Attention: negate !
227 if( rAttrs
->GetItemState( SDRATTR_MEASURETEXTROTA90
) != SfxItemState::DONTCARE
)
229 m_xTsbParallel
->set_state( rAttrs
->Get( SDRATTR_MEASURETEXTROTA90
).
230 GetValue() ? TRISTATE_FALSE
: TRISTATE_TRUE
);
234 m_xTsbParallel
->set_state( TRISTATE_INDET
);
236 m_xTsbParallel
->save_state();
238 // SdrMeasureShowUnitItem
239 if( rAttrs
->GetItemState( SDRATTR_MEASURESHOWUNIT
) != SfxItemState::DONTCARE
)
241 m_xTsbShowUnit
->set_state( rAttrs
->Get( SDRATTR_MEASURESHOWUNIT
).
242 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
246 m_xTsbShowUnit
->set_state( TRISTATE_INDET
);
248 m_xTsbShowUnit
->save_state();
250 // SdrMeasureUnitItem
251 if( rAttrs
->GetItemState( SDRATTR_MEASUREUNIT
) != SfxItemState::DONTCARE
)
253 long nFieldUnit
= static_cast<long>(rAttrs
->Get( SDRATTR_MEASUREUNIT
).GetValue());
255 for (sal_Int32 i
= 0; i
< m_xLbUnit
->get_count(); ++i
)
257 if (m_xLbUnit
->get_id(i
).toInt32() == nFieldUnit
)
259 m_xLbUnit
->set_active(i
);
266 m_xLbUnit
->set_active(-1);
268 m_xLbUnit
->save_value();
271 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTVPOS
) != SfxItemState::DONTCARE
)
273 css::drawing::MeasureTextVertPos eVPos
=
274 rAttrs
->Get( SDRATTR_MEASURETEXTVPOS
).GetValue();
276 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTHPOS
) != SfxItemState::DONTCARE
)
278 css::drawing::MeasureTextHorzPos eHPos
=
279 rAttrs
->Get( SDRATTR_MEASURETEXTHPOS
).GetValue();
280 RectPoint eRP
= RectPoint::MM
;
283 case css::drawing::MeasureTextVertPos_EAST
:
286 case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
: eRP
= RectPoint::LT
; break;
287 case css::drawing::MeasureTextHorzPos_INSIDE
: eRP
= RectPoint::MT
; break;
288 case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
: eRP
= RectPoint::RT
; break;
289 case css::drawing::MeasureTextHorzPos_AUTO
: eRP
= RectPoint::MT
; break;
293 case css::drawing::MeasureTextVertPos_CENTERED
:
296 case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
: eRP
= RectPoint::LM
; break;
297 case css::drawing::MeasureTextHorzPos_INSIDE
: eRP
= RectPoint::MM
; break;
298 case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
: eRP
= RectPoint::RM
; break;
299 case css::drawing::MeasureTextHorzPos_AUTO
: eRP
= RectPoint::MM
; break;
303 case css::drawing::MeasureTextVertPos_WEST
:
306 case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
: eRP
= RectPoint::LB
; break;
307 case css::drawing::MeasureTextHorzPos_INSIDE
: eRP
= RectPoint::MB
; break;
308 case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
: eRP
= RectPoint::RB
; break;
309 case css::drawing::MeasureTextHorzPos_AUTO
: eRP
= RectPoint::MB
; break;
313 case css::drawing::MeasureTextVertPos_AUTO
:
316 case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
: eRP
= RectPoint::LM
; break;
317 case css::drawing::MeasureTextHorzPos_INSIDE
: eRP
= RectPoint::MM
; break;
318 case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
: eRP
= RectPoint::RM
; break;
319 case css::drawing::MeasureTextHorzPos_AUTO
: eRP
= RectPoint::MM
; break;
323 default: ;//prevent warning
326 CTL_STATE nState
= CTL_STATE::NONE
;
328 if (eHPos
== css::drawing::MeasureTextHorzPos_AUTO
)
330 m_xTsbAutoPosH
->set_state( TRISTATE_TRUE
);
331 nState
= CTL_STATE::NOHORZ
;
334 if (eVPos
== css::drawing::MeasureTextVertPos_AUTO
)
336 m_xTsbAutoPosV
->set_state( TRISTATE_TRUE
);
337 nState
|= CTL_STATE::NOVERT
;
340 m_aCtlPosition
.SetState(nState
);
341 m_aCtlPosition
.SetActualRP(eRP
);
347 m_aCtlPosition
.Reset();
348 m_xTsbAutoPosV
->set_state( TRISTATE_INDET
);
349 m_xTsbAutoPosH
->set_state( TRISTATE_INDET
);
352 // put the attributes to the preview-control,
353 // otherwise the control don't know about
354 // the settings of the dialog (#67930)
355 ChangeAttrHdl_Impl(m_xTsbShowUnit
.get());
356 m_aCtlPreview
.SetAttributes(*rAttrs
);
358 bPositionModified
= false;
361 /*************************************************************************
363 |* Fill the delivered Item-Set with dialogbox-attributes
365 \************************************************************************/
367 bool SvxMeasurePage::FillItemSet( SfxItemSet
* rAttrs
)
369 bool bModified
= false;
373 if( m_xMtrFldLineDist
->get_value_changed_from_saved() )
375 nValue
= GetCoreValue( *m_xMtrFldLineDist
, eUnit
);
376 rAttrs
->Put( makeSdrMeasureLineDistItem( nValue
) );
380 if( m_xMtrFldHelplineOverhang
->get_value_changed_from_saved() )
382 nValue
= GetCoreValue( *m_xMtrFldHelplineOverhang
, eUnit
);
383 rAttrs
->Put( makeSdrMeasureHelplineOverhangItem( nValue
) );
387 if( m_xMtrFldHelplineDist
->get_value_changed_from_saved() )
389 nValue
= GetCoreValue( *m_xMtrFldHelplineDist
, eUnit
);
390 rAttrs
->Put( makeSdrMeasureHelplineDistItem( nValue
) );
394 if( m_xMtrFldHelpline1Len
->get_value_changed_from_saved() )
396 nValue
= GetCoreValue( *m_xMtrFldHelpline1Len
, eUnit
);
397 rAttrs
->Put( makeSdrMeasureHelpline1LenItem( nValue
) );
401 if( m_xMtrFldHelpline2Len
->get_value_changed_from_saved() )
403 nValue
= GetCoreValue( *m_xMtrFldHelpline2Len
, eUnit
);
404 rAttrs
->Put( makeSdrMeasureHelpline2LenItem( nValue
) );
408 eState
= m_xTsbBelowRefEdge
->get_state();
409 if( m_xTsbBelowRefEdge
->get_state_changed_from_saved() )
411 rAttrs
->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE
== eState
) );
415 if( m_xMtrFldDecimalPlaces
->get_value_changed_from_saved() )
417 nValue
= m_xMtrFldDecimalPlaces
->get_value();
419 SdrMeasureDecimalPlacesItem(
420 sal::static_int_cast
< sal_Int16
>( nValue
) ) );
424 eState
= m_xTsbParallel
->get_state();
425 if( m_xTsbParallel
->get_state_changed_from_saved() )
427 rAttrs
->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE
== eState
) );
431 eState
= m_xTsbShowUnit
->get_state();
432 if( m_xTsbShowUnit
->get_state_changed_from_saved() )
434 rAttrs
->Put( SdrYesNoItem(SDRATTR_MEASURESHOWUNIT
, TRISTATE_TRUE
== eState
) );
438 int nPos
= m_xLbUnit
->get_active();
439 if( m_xLbUnit
->get_value_changed_from_saved() )
443 sal_uInt16 nFieldUnit
= m_xLbUnit
->get_id(nPos
).toUInt32();
444 FieldUnit _eUnit
= static_cast<FieldUnit
>(nFieldUnit
);
445 rAttrs
->Put( SdrMeasureUnitItem( _eUnit
) );
450 if( bPositionModified
)
453 css::drawing::MeasureTextVertPos eVPos
, eOldVPos
;
454 css::drawing::MeasureTextHorzPos eHPos
, eOldHPos
;
456 RectPoint eRP
= m_aCtlPosition
.GetActualRP();
460 case RectPoint::LT
: eVPos
= css::drawing::MeasureTextVertPos_EAST
;
461 eHPos
= css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
; break;
462 case RectPoint::LM
: eVPos
= css::drawing::MeasureTextVertPos_CENTERED
;
463 eHPos
= css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
; break;
464 case RectPoint::LB
: eVPos
= css::drawing::MeasureTextVertPos_WEST
;
465 eHPos
= css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
; break;
466 case RectPoint::MT
: eVPos
= css::drawing::MeasureTextVertPos_EAST
;
467 eHPos
= css::drawing::MeasureTextHorzPos_INSIDE
; break;
468 case RectPoint::MM
: eVPos
= css::drawing::MeasureTextVertPos_CENTERED
;
469 eHPos
= css::drawing::MeasureTextHorzPos_INSIDE
; break;
470 case RectPoint::MB
: eVPos
= css::drawing::MeasureTextVertPos_WEST
;
471 eHPos
= css::drawing::MeasureTextHorzPos_INSIDE
; break;
472 case RectPoint::RT
: eVPos
= css::drawing::MeasureTextVertPos_EAST
;
473 eHPos
= css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
; break;
474 case RectPoint::RM
: eVPos
= css::drawing::MeasureTextVertPos_CENTERED
;
475 eHPos
= css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
; break;
476 case RectPoint::RB
: eVPos
= css::drawing::MeasureTextVertPos_WEST
;
477 eHPos
= css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
; break;
479 if (m_xTsbAutoPosH
->get_state() == TRISTATE_TRUE
)
480 eHPos
= css::drawing::MeasureTextHorzPos_AUTO
;
482 if (m_xTsbAutoPosV
->get_state() == TRISTATE_TRUE
)
483 eVPos
= css::drawing::MeasureTextVertPos_AUTO
;
485 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTVPOS
) != SfxItemState::DONTCARE
)
487 eOldVPos
= rOutAttrs
.Get(SDRATTR_MEASURETEXTVPOS
).GetValue();
488 if( eOldVPos
!= eVPos
)
490 rAttrs
->Put( SdrMeasureTextVPosItem( eVPos
) );
496 rAttrs
->Put( SdrMeasureTextVPosItem( eVPos
) );
500 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTHPOS
) != SfxItemState::DONTCARE
)
502 eOldHPos
= rOutAttrs
.Get( SDRATTR_MEASURETEXTHPOS
).GetValue();
503 if( eOldHPos
!= eHPos
)
505 rAttrs
->Put( SdrMeasureTextHPosItem( eHPos
) );
511 rAttrs
->Put( SdrMeasureTextHPosItem( eHPos
) );
519 /*************************************************************************
521 |* The View have to set at the measure-object to be able to notify
522 |* unit and floatingpoint-values
524 \************************************************************************/
526 void SvxMeasurePage::Construct()
528 DBG_ASSERT( pView
, "No valid View transferred!" );
531 // pMeasureObj is member of SvxXMeasurePreview and can only be accessed due to
532 // SvxMeasurePage being a friend. It has its own SdrModel (also in SvxXMeasurePreview)
533 // and 'setting' the SdrModel is a hack. The comment above about 'notify unit and
534 // floatingpoint-values' is not clear, but has to be done another way - if needed.
535 // Checked on original aw080, is just commented out there, too.
537 m_aCtlPreview
.Invalidate();
540 VclPtr
<SfxTabPage
> SvxMeasurePage::Create(TabPageParent pParent
,
541 const SfxItemSet
* rAttrs
)
543 return VclPtr
<SvxMeasurePage
>::Create(pParent
, *rAttrs
);
546 void SvxMeasurePage::PointChanged(weld::DrawingArea
* pDrawingArea
, RectPoint
/*eRP*/)
548 ChangeAttrHdl_Impl(pDrawingArea
);
551 IMPL_LINK( SvxMeasurePage
, ClickAutoPosHdl_Impl
, weld::ToggleButton
&, rBox
, void )
553 if (m_xTsbAutoPosH
->get_state() == TRISTATE_TRUE
)
555 switch( m_aCtlPosition
.GetActualRP() )
559 m_aCtlPosition
.SetActualRP( RectPoint::MT
);
564 m_aCtlPosition
.SetActualRP( RectPoint::MM
);
569 m_aCtlPosition
.SetActualRP( RectPoint::MB
);
571 default: ;//prevent warning
574 if (m_xTsbAutoPosV
->get_state() == TRISTATE_TRUE
)
576 switch( m_aCtlPosition
.GetActualRP() )
580 m_aCtlPosition
.SetActualRP( RectPoint::LM
);
585 m_aCtlPosition
.SetActualRP( RectPoint::MM
);
590 m_aCtlPosition
.SetActualRP( RectPoint::RM
);
592 default: ;//prevent warning
595 ChangeAttrHdl_Impl(&rBox
);
598 IMPL_LINK(SvxMeasurePage
, ChangeAttrClickHdl_Impl
, weld::ToggleButton
&, r
, void)
600 ChangeAttrHdl_Impl(&r
);
603 IMPL_LINK(SvxMeasurePage
, ChangeAttrListBoxHdl_Impl
, weld::ComboBox
&, rBox
, void)
605 ChangeAttrHdl_Impl(&rBox
);
608 IMPL_LINK(SvxMeasurePage
, ChangeAttrEditHdl_Impl
, weld::MetricSpinButton
&, rBox
, void)
610 ChangeAttrHdl_Impl(&rBox
);
613 IMPL_LINK( SvxMeasurePage
, ChangeAttrSpinHdl_Impl
, weld::SpinButton
&, rBox
, void )
615 ChangeAttrHdl_Impl(&rBox
);
618 void SvxMeasurePage::ChangeAttrHdl_Impl( void const * p
)
620 if (p
== m_xMtrFldLineDist
.get())
622 sal_Int32 nValue
= GetCoreValue( *m_xMtrFldLineDist
, eUnit
);
623 aAttrSet
.Put( makeSdrMeasureLineDistItem( nValue
) );
626 if (p
== m_xMtrFldHelplineOverhang
.get())
628 sal_Int32 nValue
= GetCoreValue( *m_xMtrFldHelplineOverhang
, eUnit
);
629 aAttrSet
.Put( makeSdrMeasureHelplineOverhangItem( nValue
) );
632 if (p
== m_xMtrFldHelplineDist
.get())
634 sal_Int32 nValue
= GetCoreValue( *m_xMtrFldHelplineDist
, eUnit
);
635 aAttrSet
.Put( makeSdrMeasureHelplineDistItem( nValue
) );
638 if (p
== m_xMtrFldHelpline1Len
.get())
640 sal_Int32 nValue
= GetCoreValue( *m_xMtrFldHelpline1Len
, eUnit
);
641 aAttrSet
.Put( makeSdrMeasureHelpline1LenItem( nValue
) );
644 if (p
== m_xMtrFldHelpline2Len
.get())
646 sal_Int32 nValue
= GetCoreValue( *m_xMtrFldHelpline2Len
, eUnit
);
647 aAttrSet
.Put( makeSdrMeasureHelpline2LenItem( nValue
) );
650 if (p
== m_xTsbBelowRefEdge
.get())
652 TriState eState
= m_xTsbBelowRefEdge
->get_state();
653 if( eState
!= TRISTATE_INDET
)
654 aAttrSet
.Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE
== eState
) );
657 if (p
== m_xMtrFldDecimalPlaces
.get())
659 sal_Int16 nValue
= sal::static_int_cast
< sal_Int16
>(
660 m_xMtrFldDecimalPlaces
->get_value() );
661 aAttrSet
.Put( SdrMeasureDecimalPlacesItem( nValue
) );
664 if (p
== m_xTsbParallel
.get())
666 TriState eState
= m_xTsbParallel
->get_state();
667 if( eState
!= TRISTATE_INDET
)
668 aAttrSet
.Put( SdrMeasureTextRota90Item( TRISTATE_FALSE
== eState
) );
671 if (p
== m_xTsbShowUnit
.get())
673 TriState eState
= m_xTsbShowUnit
->get_state();
674 if( eState
!= TRISTATE_INDET
)
675 aAttrSet
.Put( SdrYesNoItem( SDRATTR_MEASURESHOWUNIT
, TRISTATE_TRUE
== eState
) );
678 if (p
== m_xLbUnit
.get())
680 int nPos
= m_xLbUnit
->get_active();
683 sal_uInt16 nFieldUnit
= m_xLbUnit
->get_id(nPos
).toUInt32();
684 FieldUnit _eUnit
= static_cast<FieldUnit
>(nFieldUnit
);
685 aAttrSet
.Put( SdrMeasureUnitItem( _eUnit
) );
689 if (p
== m_xTsbAutoPosV
.get() || p
== m_xTsbAutoPosH
.get() || p
== m_aCtlPosition
.GetDrawingArea())
691 bPositionModified
= true;
694 RectPoint eRP
= m_aCtlPosition
.GetActualRP();
695 css::drawing::MeasureTextVertPos eVPos
;
696 css::drawing::MeasureTextHorzPos eHPos
;
701 case RectPoint::LT
: eVPos
= css::drawing::MeasureTextVertPos_EAST
;
702 eHPos
= css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
; break;
703 case RectPoint::LM
: eVPos
= css::drawing::MeasureTextVertPos_CENTERED
;
704 eHPos
= css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
; break;
705 case RectPoint::LB
: eVPos
= css::drawing::MeasureTextVertPos_WEST
;
706 eHPos
= css::drawing::MeasureTextHorzPos_LEFTOUTSIDE
; break;
707 case RectPoint::MT
: eVPos
= css::drawing::MeasureTextVertPos_EAST
;
708 eHPos
= css::drawing::MeasureTextHorzPos_INSIDE
; break;
709 case RectPoint::MM
: eVPos
= css::drawing::MeasureTextVertPos_CENTERED
;
710 eHPos
= css::drawing::MeasureTextHorzPos_INSIDE
; break;
711 case RectPoint::MB
: eVPos
= css::drawing::MeasureTextVertPos_WEST
;
712 eHPos
= css::drawing::MeasureTextHorzPos_INSIDE
; break;
713 case RectPoint::RT
: eVPos
= css::drawing::MeasureTextVertPos_EAST
;
714 eHPos
= css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
; break;
715 case RectPoint::RM
: eVPos
= css::drawing::MeasureTextVertPos_CENTERED
;
716 eHPos
= css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
; break;
717 case RectPoint::RB
: eVPos
= css::drawing::MeasureTextVertPos_WEST
;
718 eHPos
= css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE
; break;
721 CTL_STATE nState
= CTL_STATE::NONE
;
723 if (m_xTsbAutoPosH
->get_state() == TRISTATE_TRUE
)
725 eHPos
= css::drawing::MeasureTextHorzPos_AUTO
;
726 nState
= CTL_STATE::NOHORZ
;
729 if (m_xTsbAutoPosV
->get_state() == TRISTATE_TRUE
)
731 eVPos
= css::drawing::MeasureTextVertPos_AUTO
;
732 nState
|= CTL_STATE::NOVERT
;
735 if (p
== m_xTsbAutoPosV
.get() || p
== m_xTsbAutoPosH
.get())
736 m_aCtlPosition
.SetState( nState
);
738 aAttrSet
.Put( SdrMeasureTextVPosItem( eVPos
) );
739 aAttrSet
.Put( SdrMeasureTextHPosItem( eHPos
) );
742 m_aCtlPreview
.SetAttributes(aAttrSet
);
743 m_aCtlPreview
.Invalidate();
746 void SvxMeasurePage::FillUnitLB()
748 // fill ListBox with metrics
750 FieldUnit nUnit
= FieldUnit::NONE
;
751 OUString
aStrMetric(m_xFtAutomatic
->get_label());
752 m_xLbUnit
->append(OUString::number(sal_uInt32(nUnit
)), aStrMetric
);
754 for( sal_uInt32 i
= 0; i
< SvxFieldUnitTable::Count(); ++i
)
756 aStrMetric
= SvxFieldUnitTable::GetString(i
);
757 nUnit
= SvxFieldUnitTable::GetValue(i
);
758 m_xLbUnit
->append(OUString::number(sal_uInt32(nUnit
)), aStrMetric
);
762 void SvxMeasurePage::PageCreated(const SfxAllItemSet
& aSet
)
764 const OfaPtrItem
* pOfaPtrItem
= aSet
.GetItem
<OfaPtrItem
>(SID_OBJECT_LIST
, false);
767 SetView( static_cast<SdrView
*>(pOfaPtrItem
->GetValue()));
772 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */