LibreOffice Module cui (master)  1
measure.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <strings.hrc>
21 #include <dialmgr.hxx>
22 
23 #include <svx/svxids.hrc>
24 #include <svx/dlgutil.hxx>
25 #include <svx/measctrl.hxx>
26 #include <svx/ofaitem.hxx>
27 #include <svx/strarray.hxx>
28 #include <svx/svdview.hxx>
29 #include <svx/sxmbritm.hxx>
30 #include <svx/sxmlhitm.hxx>
31 #include <svx/sxmtfitm.hxx>
32 #include <svx/sxmtpitm.hxx>
33 #include <svx/sxmtritm.hxx>
34 #include <svx/sxmuitm.hxx>
35 #include <svtools/unitconv.hxx>
36 
37 #include <measure.hxx>
38 
39 const sal_uInt16 SvxMeasurePage::pRanges[] =
40 {
43  0
44 };
45 
46 /*************************************************************************
47 |*
48 |* Dialog to change measure-attributes
49 |*
50 \************************************************************************/
51 
53  const SdrView* pSdrView)
54  : SfxSingleTabDialogController(pParent, &rInAttrs)
55 {
56  TabPageParent pPageParent(get_content_area(), this);
57  VclPtrInstance<SvxMeasurePage> pPage(pPageParent, rInAttrs);
58 
59  pPage->SetView(pSdrView);
60  pPage->Construct();
61 
62  SetTabPage(pPage);
63  m_xDialog->set_title(CuiResId(RID_SVXSTR_DIMENSION_LINE));
64 }
65 
66 /*************************************************************************
67 |*
68 |* Tabpage for changing measure-attributes
69 |*
70 \************************************************************************/
71 
73  : SvxTabPage(pWindow, "cui/ui/dimensionlinestabpage.ui", "DimensionLinesTabPage", rInAttrs)
74  , rOutAttrs(rInAttrs)
75  , aAttrSet(*rInAttrs.GetPool())
76  , pView(nullptr)
77  , eUnit(MapUnit::Map100thMM)
78  , bPositionModified(false)
79  , m_aCtlPosition(this)
80  , m_xMtrFldLineDist(m_xBuilder->weld_metric_spin_button("MTR_LINE_DIST", FieldUnit::MM))
81  , m_xMtrFldHelplineOverhang(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE_OVERHANG", FieldUnit::MM))
82  , m_xMtrFldHelplineDist(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE_DIST", FieldUnit::MM))
83  , m_xMtrFldHelpline1Len(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE1_LEN", FieldUnit::MM))
84  , m_xMtrFldHelpline2Len(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE2_LEN", FieldUnit::MM))
85  , m_xTsbBelowRefEdge(m_xBuilder->weld_check_button("TSB_BELOW_REF_EDGE"))
86  , m_xMtrFldDecimalPlaces(m_xBuilder->weld_spin_button("MTR_FLD_DECIMALPLACES"))
87  , m_xTsbAutoPosV(m_xBuilder->weld_check_button("TSB_AUTOPOSV"))
88  , m_xTsbAutoPosH(m_xBuilder->weld_check_button("TSB_AUTOPOSH"))
89  , m_xTsbShowUnit(m_xBuilder->weld_check_button("TSB_SHOW_UNIT"))
90  , m_xLbUnit(m_xBuilder->weld_combo_box("LB_UNIT"))
91  , m_xTsbParallel(m_xBuilder->weld_check_button("TSB_PARALLEL"))
92  , m_xFtAutomatic(m_xBuilder->weld_label("STR_MEASURE_AUTOMATIC"))
93  , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
94  , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder, "CTL_PREVIEW", m_aCtlPreview))
95 {
96  m_aCtlPreview.SetAttributes(rInAttrs);
97 
98  FillUnitLB();
99 
100  const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
101  SetFieldUnit( *m_xMtrFldLineDist, eFUnit );
106  if( eFUnit == FieldUnit::MM )
107  {
108  m_xMtrFldLineDist->set_increments(50, 500, FieldUnit::NONE);
109  m_xMtrFldHelplineOverhang->set_increments(50, 500, FieldUnit::NONE);
110  m_xMtrFldHelplineDist->set_increments(50, 500, FieldUnit::NONE);
111  m_xMtrFldHelpline1Len->set_increments(50, 500, FieldUnit::NONE);
112  m_xMtrFldHelpline2Len->set_increments(50, 500, FieldUnit::NONE);
113  }
114 
115  m_xTsbAutoPosV->connect_toggled(LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl));
116  m_xTsbAutoPosH->connect_toggled(LINK(this, SvxMeasurePage, ClickAutoPosHdl_Impl));
117 
118  Link<weld::MetricSpinButton&,void> aLink(LINK(this, SvxMeasurePage, ChangeAttrEditHdl_Impl));
119  m_xMtrFldLineDist->connect_value_changed(aLink);
120  m_xMtrFldHelplineOverhang->connect_value_changed(aLink);
121  m_xMtrFldHelplineDist->connect_value_changed(aLink);
122  m_xMtrFldHelpline1Len->connect_value_changed(aLink);
123  m_xMtrFldHelpline2Len->connect_value_changed(aLink);
124  m_xMtrFldDecimalPlaces->connect_value_changed(LINK(this, SvxMeasurePage, ChangeAttrSpinHdl_Impl));
125  m_xTsbBelowRefEdge->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
126  m_xTsbParallel->connect_toggled( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
127  m_xTsbShowUnit->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
128  m_xLbUnit->connect_changed(LINK(this, SvxMeasurePage, ChangeAttrListBoxHdl_Impl));
129 }
130 
132 {
133  disposeOnce();
134 }
135 
137 {
138  m_xCtlPreview.reset();
139  m_xCtlPosition.reset();
140  SvxTabPage::dispose();
141 }
142 
143 /*************************************************************************
144 |*
145 |* read the delivered Item-Set
146 |*
147 \************************************************************************/
148 
149 void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
150 {
151  SfxItemPool* pPool = rAttrs->GetPool();
152  DBG_ASSERT( pPool, "Where is the pool?" );
154 
155  const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_MEASURELINEDIST );
156 
157  // SdrMeasureLineDistItem
158  if( pItem == nullptr )
159  pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
160  SetMetricValue(*m_xMtrFldLineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
161  m_xMtrFldLineDist->save_value();
162 
163  // SdrMeasureHelplineOverhangItem
164  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
165  if( pItem == nullptr )
167  SetMetricValue(*m_xMtrFldHelplineOverhang, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
168  eUnit);
169  m_xMtrFldHelplineOverhang->save_value();
170 
171  // SdrMeasureHelplineDistItem
172  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST );
173  if( pItem == nullptr )
174  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
175  SetMetricValue(*m_xMtrFldHelplineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
176  eUnit);
177  m_xMtrFldHelplineDist->save_value();
178 
179  // SdrMeasureHelpline1LenItem
180  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
181  if( pItem == nullptr )
182  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
183  SetMetricValue(*m_xMtrFldHelpline1Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
184  eUnit);
185  m_xMtrFldHelpline1Len->save_value();
186 
187  // SdrMeasureHelpline2LenItem
188  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
189  if( pItem == nullptr )
190  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
191  SetMetricValue(*m_xMtrFldHelpline2Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
192  eUnit);
193  m_xMtrFldHelpline2Len->save_value();
194 
195  // SdrMeasureBelowRefEdgeItem
196  if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::DONTCARE )
197  {
198  m_xTsbBelowRefEdge->set_state( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ).
200  }
201  else
202  {
203  m_xTsbBelowRefEdge->set_state( TRISTATE_INDET );
204  }
205  m_xTsbBelowRefEdge->save_state();
206 
207  // SdrMeasureDecimalPlacesItem
208  pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES );
209  if( pItem == nullptr )
210  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
211  m_xMtrFldDecimalPlaces->set_value(
212  static_cast<const SdrMeasureDecimalPlacesItem*>(pItem)->GetValue());
213  m_xMtrFldDecimalPlaces->save_value();
214 
215  // SdrMeasureTextRota90Item
216  // Attention: negate !
217  if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::DONTCARE )
218  {
219  m_xTsbParallel->set_state( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ).
221  }
222  else
223  {
224  m_xTsbParallel->set_state( TRISTATE_INDET );
225  }
226  m_xTsbParallel->save_state();
227 
228  // SdrMeasureShowUnitItem
229  if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::DONTCARE )
230  {
231  m_xTsbShowUnit->set_state( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ).
233  }
234  else
235  {
236  m_xTsbShowUnit->set_state( TRISTATE_INDET );
237  }
238  m_xTsbShowUnit->save_state();
239 
240  // SdrMeasureUnitItem
241  if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::DONTCARE )
242  {
243  long nFieldUnit = static_cast<long>(rAttrs->Get( SDRATTR_MEASUREUNIT ).GetValue());
244 
245  for (sal_Int32 i = 0; i < m_xLbUnit->get_count(); ++i)
246  {
247  if (m_xLbUnit->get_id(i).toInt32() == nFieldUnit)
248  {
249  m_xLbUnit->set_active(i);
250  break;
251  }
252  }
253  }
254  else
255  {
256  m_xLbUnit->set_active(-1);
257  }
258  m_xLbUnit->save_value();
259 
260  // Position
261  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
262  {
263  css::drawing::MeasureTextVertPos eVPos =
264  rAttrs->Get( SDRATTR_MEASURETEXTVPOS ).GetValue();
265  {
266  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
267  {
268  css::drawing::MeasureTextHorzPos eHPos =
269  rAttrs->Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
270  RectPoint eRP = RectPoint::MM;
271  switch( eVPos )
272  {
273  case css::drawing::MeasureTextVertPos_EAST:
274  switch( eHPos )
275  {
276  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LT; break;
277  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MT; break;
278  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RT; break;
279  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MT; break;
280  default: break;
281  }
282  break;
283  case css::drawing::MeasureTextVertPos_CENTERED:
284  switch( eHPos )
285  {
286  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LM; break;
287  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MM; break;
288  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RM; break;
289  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MM; break;
290  default: break;
291  }
292  break;
293  case css::drawing::MeasureTextVertPos_WEST:
294  switch( eHPos )
295  {
296  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LB; break;
297  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MB; break;
298  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RB; break;
299  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MB; break;
300  default: break;
301  }
302  break;
303  case css::drawing::MeasureTextVertPos_AUTO:
304  switch( eHPos )
305  {
306  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LM; break;
307  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MM; break;
308  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RM; break;
309  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MM; break;
310  default: break;
311  }
312  break;
313  default: ;//prevent warning
314  }
315 
316  CTL_STATE nState = CTL_STATE::NONE;
317 
318  if (eHPos == css::drawing::MeasureTextHorzPos_AUTO)
319  {
320  m_xTsbAutoPosH->set_state( TRISTATE_TRUE );
321  nState = CTL_STATE::NOHORZ;
322  }
323 
324  if (eVPos == css::drawing::MeasureTextVertPos_AUTO)
325  {
326  m_xTsbAutoPosV->set_state( TRISTATE_TRUE );
327  nState |= CTL_STATE::NOVERT;
328  }
329 
330  m_aCtlPosition.SetState(nState);
332  }
333  }
334  }
335  else
336  {
338  m_xTsbAutoPosV->set_state( TRISTATE_INDET );
339  m_xTsbAutoPosH->set_state( TRISTATE_INDET );
340  }
341 
342  // put the attributes to the preview-control,
343  // otherwise the control don't know about
344  // the settings of the dialog (#67930)
346  m_aCtlPreview.SetAttributes(*rAttrs);
347 
348  bPositionModified = false;
349 }
350 
351 /*************************************************************************
352 |*
353 |* Fill the delivered Item-Set with dialogbox-attributes
354 |*
355 \************************************************************************/
356 
358 {
359  bool bModified = false;
360  sal_Int32 nValue;
361  TriState eState;
362 
363  if( m_xMtrFldLineDist->get_value_changed_from_saved() )
364  {
365  nValue = GetCoreValue( *m_xMtrFldLineDist, eUnit );
366  rAttrs->Put( makeSdrMeasureLineDistItem( nValue ) );
367  bModified = true;
368  }
369 
370  if( m_xMtrFldHelplineOverhang->get_value_changed_from_saved() )
371  {
373  rAttrs->Put( makeSdrMeasureHelplineOverhangItem( nValue ) );
374  bModified = true;
375  }
376 
377  if( m_xMtrFldHelplineDist->get_value_changed_from_saved() )
378  {
380  rAttrs->Put( makeSdrMeasureHelplineDistItem( nValue ) );
381  bModified = true;
382  }
383 
384  if( m_xMtrFldHelpline1Len->get_value_changed_from_saved() )
385  {
387  rAttrs->Put( makeSdrMeasureHelpline1LenItem( nValue ) );
388  bModified = true;
389  }
390 
391  if( m_xMtrFldHelpline2Len->get_value_changed_from_saved() )
392  {
394  rAttrs->Put( makeSdrMeasureHelpline2LenItem( nValue ) );
395  bModified = true;
396  }
397 
398  eState = m_xTsbBelowRefEdge->get_state();
399  if( m_xTsbBelowRefEdge->get_state_changed_from_saved() )
400  {
401  rAttrs->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
402  bModified = true;
403  }
404 
405  if( m_xMtrFldDecimalPlaces->get_value_changed_from_saved() )
406  {
407  nValue = m_xMtrFldDecimalPlaces->get_value();
408  rAttrs->Put(
410  sal::static_int_cast< sal_Int16 >( nValue ) ) );
411  bModified = true;
412  }
413 
414  eState = m_xTsbParallel->get_state();
415  if( m_xTsbParallel->get_state_changed_from_saved() )
416  {
417  rAttrs->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
418  bModified = true;
419  }
420 
421  eState = m_xTsbShowUnit->get_state();
422  if( m_xTsbShowUnit->get_state_changed_from_saved() )
423  {
424  rAttrs->Put( SdrYesNoItem(SDRATTR_MEASURESHOWUNIT, TRISTATE_TRUE == eState ) );
425  bModified = true;
426  }
427 
428  int nPos = m_xLbUnit->get_active();
429  if( m_xLbUnit->get_value_changed_from_saved() )
430  {
431  if (nPos != -1)
432  {
433  sal_uInt16 nFieldUnit = m_xLbUnit->get_id(nPos).toUInt32();
434  FieldUnit _eUnit = static_cast<FieldUnit>(nFieldUnit);
435  rAttrs->Put( SdrMeasureUnitItem( _eUnit ) );
436  bModified = true;
437  }
438  }
439 
440  if( bPositionModified )
441  {
442  // Position
443  css::drawing::MeasureTextVertPos eVPos, eOldVPos;
444  css::drawing::MeasureTextHorzPos eHPos, eOldHPos;
445 
447  switch( eRP )
448  {
449  default:
450  case RectPoint::LT: eVPos = css::drawing::MeasureTextVertPos_EAST;
451  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
452  case RectPoint::LM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
453  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
454  case RectPoint::LB: eVPos = css::drawing::MeasureTextVertPos_WEST;
455  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
456  case RectPoint::MT: eVPos = css::drawing::MeasureTextVertPos_EAST;
457  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
458  case RectPoint::MM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
459  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
460  case RectPoint::MB: eVPos = css::drawing::MeasureTextVertPos_WEST;
461  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
462  case RectPoint::RT: eVPos = css::drawing::MeasureTextVertPos_EAST;
463  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
464  case RectPoint::RM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
465  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
466  case RectPoint::RB: eVPos = css::drawing::MeasureTextVertPos_WEST;
467  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
468  }
469  if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
470  eHPos = css::drawing::MeasureTextHorzPos_AUTO;
471 
472  if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
473  eVPos = css::drawing::MeasureTextVertPos_AUTO;
474 
475  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
476  {
477  eOldVPos = rOutAttrs.Get(SDRATTR_MEASURETEXTVPOS).GetValue();
478  if( eOldVPos != eVPos )
479  {
480  rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
481  bModified = true;
482  }
483  }
484  else
485  {
486  rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
487  bModified = true;
488  }
489 
490  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
491  {
492  eOldHPos = rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
493  if( eOldHPos != eHPos )
494  {
495  rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
496  bModified = true;
497  }
498  }
499  else
500  {
501  rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
502  bModified = true;
503  }
504  }
505 
506  return bModified;
507 }
508 
509 /*************************************************************************
510 |*
511 |* The View have to set at the measure-object to be able to notify
512 |* unit and floatingpoint-values
513 |*
514 \************************************************************************/
515 
517 {
518  DBG_ASSERT( pView, "No valid View transferred!" );
519 
520  // TTTT
521  // pMeasureObj is member of SvxXMeasurePreview and can only be accessed due to
522  // SvxMeasurePage being a friend. It has its own SdrModel (also in SvxXMeasurePreview)
523  // and 'setting' the SdrModel is a hack. The comment above about 'notify unit and
524  // floatingpoint-values' is not clear, but has to be done another way - if needed.
525  // Checked on original aw080, is just commented out there, too.
526 
527  m_aCtlPreview.Invalidate();
528 }
529 
531  const SfxItemSet* rAttrs)
532 {
533  return VclPtr<SvxMeasurePage>::Create(pParent, *rAttrs);
534 }
535 
537 {
538  ChangeAttrHdl_Impl(pDrawingArea);
539 }
540 
541 IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, weld::ToggleButton&, rBox, void )
542 {
543  if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
544  {
545  switch( m_aCtlPosition.GetActualRP() )
546  {
547  case RectPoint::LT:
548  case RectPoint::RT:
549  m_aCtlPosition.SetActualRP( RectPoint::MT );
550  break;
551 
552  case RectPoint::LM:
553  case RectPoint::RM:
554  m_aCtlPosition.SetActualRP( RectPoint::MM );
555  break;
556 
557  case RectPoint::LB:
558  case RectPoint::RB:
559  m_aCtlPosition.SetActualRP( RectPoint::MB );
560  break;
561  default: ;//prevent warning
562  }
563  }
564  if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
565  {
566  switch( m_aCtlPosition.GetActualRP() )
567  {
568  case RectPoint::LT:
569  case RectPoint::LB:
570  m_aCtlPosition.SetActualRP( RectPoint::LM );
571  break;
572 
573  case RectPoint::MT:
574  case RectPoint::MB:
575  m_aCtlPosition.SetActualRP( RectPoint::MM );
576  break;
577 
578  case RectPoint::RT:
579  case RectPoint::RB:
580  m_aCtlPosition.SetActualRP( RectPoint::RM );
581  break;
582  default: ;//prevent warning
583  }
584  }
585  ChangeAttrHdl_Impl(&rBox);
586 }
587 
588 IMPL_LINK(SvxMeasurePage, ChangeAttrClickHdl_Impl, weld::ToggleButton&, r, void)
589 {
590  ChangeAttrHdl_Impl(&r);
591 }
592 
593 IMPL_LINK(SvxMeasurePage, ChangeAttrListBoxHdl_Impl, weld::ComboBox&, rBox, void)
594 {
595  ChangeAttrHdl_Impl(&rBox);
596 }
597 
598 IMPL_LINK(SvxMeasurePage, ChangeAttrEditHdl_Impl, weld::MetricSpinButton&, rBox, void)
599 {
600  ChangeAttrHdl_Impl(&rBox);
601 }
602 
603 IMPL_LINK( SvxMeasurePage, ChangeAttrSpinHdl_Impl, weld::SpinButton&, rBox, void )
604 {
605  ChangeAttrHdl_Impl(&rBox);
606 }
607 
609 {
610  if (p == m_xMtrFldLineDist.get())
611  {
612  sal_Int32 nValue = GetCoreValue( *m_xMtrFldLineDist, eUnit );
614  }
615 
616  if (p == m_xMtrFldHelplineOverhang.get())
617  {
618  sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelplineOverhang, eUnit );
620  }
621 
622  if (p == m_xMtrFldHelplineDist.get())
623  {
624  sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelplineDist, eUnit );
626  }
627 
628  if (p == m_xMtrFldHelpline1Len.get())
629  {
630  sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelpline1Len, eUnit );
632  }
633 
634  if (p == m_xMtrFldHelpline2Len.get())
635  {
636  sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelpline2Len, eUnit );
638  }
639 
640  if (p == m_xTsbBelowRefEdge.get())
641  {
642  TriState eState = m_xTsbBelowRefEdge->get_state();
643  if( eState != TRISTATE_INDET )
645  }
646 
647  if (p == m_xMtrFldDecimalPlaces.get())
648  {
649  sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
650  m_xMtrFldDecimalPlaces->get_value() );
652  }
653 
654  if (p == m_xTsbParallel.get())
655  {
656  TriState eState = m_xTsbParallel->get_state();
657  if( eState != TRISTATE_INDET )
659  }
660 
661  if (p == m_xTsbShowUnit.get())
662  {
663  TriState eState = m_xTsbShowUnit->get_state();
664  if( eState != TRISTATE_INDET )
666  }
667 
668  if (p == m_xLbUnit.get())
669  {
670  int nPos = m_xLbUnit->get_active();
671  if (nPos != -1)
672  {
673  sal_uInt16 nFieldUnit = m_xLbUnit->get_id(nPos).toUInt32();
674  FieldUnit _eUnit = static_cast<FieldUnit>(nFieldUnit);
675  aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
676  }
677  }
678 
679  if (p == m_xTsbAutoPosV.get() || p == m_xTsbAutoPosH.get() || p == m_aCtlPosition.GetDrawingArea())
680  {
681  bPositionModified = true;
682 
683  // Position
685  css::drawing::MeasureTextVertPos eVPos;
686  css::drawing::MeasureTextHorzPos eHPos;
687 
688  switch( eRP )
689  {
690  default:
691  case RectPoint::LT: eVPos = css::drawing::MeasureTextVertPos_EAST;
692  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
693  case RectPoint::LM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
694  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
695  case RectPoint::LB: eVPos = css::drawing::MeasureTextVertPos_WEST;
696  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
697  case RectPoint::MT: eVPos = css::drawing::MeasureTextVertPos_EAST;
698  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
699  case RectPoint::MM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
700  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
701  case RectPoint::MB: eVPos = css::drawing::MeasureTextVertPos_WEST;
702  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
703  case RectPoint::RT: eVPos = css::drawing::MeasureTextVertPos_EAST;
704  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
705  case RectPoint::RM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
706  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
707  case RectPoint::RB: eVPos = css::drawing::MeasureTextVertPos_WEST;
708  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
709  }
710 
711  CTL_STATE nState = CTL_STATE::NONE;
712 
713  if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
714  {
715  eHPos = css::drawing::MeasureTextHorzPos_AUTO;
716  nState = CTL_STATE::NOHORZ;
717  }
718 
719  if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
720  {
721  eVPos = css::drawing::MeasureTextVertPos_AUTO;
722  nState |= CTL_STATE::NOVERT;
723  }
724 
725  if (p == m_xTsbAutoPosV.get() || p == m_xTsbAutoPosH.get())
726  m_aCtlPosition.SetState( nState );
727 
728  aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
729  aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
730  }
731 
733  m_aCtlPreview.Invalidate();
734 }
735 
737 {
738  // fill ListBox with metrics
739 
740  FieldUnit nUnit = FieldUnit::NONE;
741  OUString aStrMetric(m_xFtAutomatic->get_label());
742  m_xLbUnit->append(OUString::number(sal_uInt32(nUnit)), aStrMetric);
743 
744  for( sal_uInt32 i = 0; i < SvxFieldUnitTable::Count(); ++i )
745  {
746  aStrMetric = SvxFieldUnitTable::GetString(i);
748  m_xLbUnit->append(OUString::number(sal_uInt32(nUnit)), aStrMetric);
749  }
750 }
751 
753 {
754  const OfaPtrItem* pOfaPtrItem = aSet.GetItem<OfaPtrItem>(SID_OBJECT_LIST, false);
755 
756  if (pOfaPtrItem)
757  SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()));
758 
759  Construct();
760 }
761 
762 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
FieldUnit
void SetActualRP(RectPoint eNewRP)
void ChangeAttrHdl_Impl(void const *)
Definition: measure.cxx:608
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
Definition: measure.hxx:57
std::unique_ptr< weld::SpinButton > m_xMtrFldDecimalPlaces
Definition: measure.hxx:49
void SetView(const SdrView *pSdrView)
Definition: measure.hxx:83
std::string GetValue
void Construct()
Definition: measure.cxx:516
void Reset()
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
#define SDRATTR_MEASURETEXTVPOS
#define SDRATTR_MEASURE_LAST
std::unique_ptr< weld::CheckButton > m_xTsbShowUnit
Definition: measure.hxx:52
RectPoint GetActualRP() const
weld::Container * get_content_area()
#define SDRATTR_MEASUREHELPLINE2LEN
SdrMetricItem makeSdrMeasureHelplineDistItem(long nVal)
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldLineDist
Definition: measure.hxx:43
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelpline1Len
Definition: measure.hxx:46
TRISTATE_TRUE
static FieldUnit GetValue(sal_uInt32 i)
#define SDRATTR_MEASUREHELPLINEDIST
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
#define SDRATTR_MEASURETEXTROTA90
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: measure.cxx:530
#define SDRATTR_MEASUREHELPLINE1LEN
void SetTabPage(SfxTabPage *pTabPage)
#define SDRATTR_MEASUREBELOWREFEDGE
SvxXMeasurePreview m_aCtlPreview
Definition: measure.hxx:42
SdrMetricItem makeSdrMeasureLineDistItem(long nVal)
virtual ~SvxMeasurePage() override
Definition: measure.cxx:131
void SetState(CTL_STATE nState)
TRISTATE_INDET
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelplineOverhang
Definition: measure.hxx:44
static const sal_uInt16 pRanges[]
Definition: measure.hxx:32
virtual void PointChanged(weld::DrawingArea *pWindow, RectPoint eRP) override
Definition: measure.cxx:536
#define SDRATTR_MEASURESHOWUNIT
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: measure.cxx:752
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelpline2Len
Definition: measure.hxx:47
RectPoint
void FillUnitLB()
Definition: measure.cxx:736
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
SvxMeasureDialog(weld::Window *pParent, const SfxItemSet &rAttr, const SdrView *pView)
Definition: measure.cxx:52
const SdrView * pView
Definition: measure.hxx:36
static OUString GetString(sal_uInt32 i)
#define SDRATTR_MEASUREDECIMALPLACES
int i
TRISTATE_FALSE
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
virtual bool FillItemSet(SfxItemSet *) override
Definition: measure.cxx:357
std::unique_ptr< weld::CheckButton > m_xTsbBelowRefEdge
Definition: measure.hxx:48
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelplineDist
Definition: measure.hxx:45
SvxMeasurePage(TabPageParent pWindow, const SfxItemSet &rInAttrs)
Definition: measure.cxx:72
std::unique_ptr< weld::ComboBox > m_xLbUnit
Definition: measure.hxx:53
SdrMetricItem makeSdrMeasureHelplineOverhangItem(long nVal)
static sal_uInt32 Count()
virtual void Reset(const SfxItemSet *) override
Definition: measure.cxx:149
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
std::unique_ptr< weld::CheckButton > m_xTsbAutoPosV
Definition: measure.hxx:50
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
#define SDRATTR_MEASUREUNIT
const SfxItemSet & rOutAttrs
Definition: measure.hxx:34
std::unique_ptr< weld::CustomWeld > m_xCtlPosition
Definition: measure.hxx:56
SdrMetricItem makeSdrMeasureHelpline1LenItem(long nVal)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::CheckButton > m_xTsbAutoPosH
Definition: measure.hxx:51
SvxRectCtl m_aCtlPosition
Definition: measure.hxx:41
SfxItemSet aAttrSet
Definition: measure.hxx:35
MapUnit eUnit
Definition: measure.hxx:37
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool bPositionModified
Definition: measure.hxx:39
IMPL_LINK(SvxMeasurePage, ClickAutoPosHdl_Impl, weld::ToggleButton &, rBox, void)
Definition: measure.cxx:541
#define SDRATTR_MEASUREHELPLINEOVERHANG
virtual void dispose() override
Definition: measure.cxx:136
static VclPtr< reference_type > Create(Arg &&...arg)
Dialog for changing TextAttributes.
Definition: measure.hxx:29
#define SDRATTR_MEASURETEXTHPOS
#define SDRATTR_MEASURE_FIRST
#define SDRATTR_MEASURELINEDIST
MapUnit
void * GetValue() const
std::unique_ptr< weld::CheckButton > m_xTsbParallel
Definition: measure.hxx:54
void SetAttributes(const SfxItemSet &rInAttrs)
TriState
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
sal_Int32 nPos
std::unique_ptr< weld::Label > m_xFtAutomatic
Definition: measure.hxx:55
CTL_STATE
SdrMetricItem makeSdrMeasureHelpline2LenItem(long nVal)