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 .
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/dialmgr.hxx>
28 #include <svx/dialogs.hrc>
29 #include <svx/dlgutil.hxx>
30 #include <svx/measctrl.hxx>
31 #include <svx/ofaitem.hxx>
32 #include <svx/strarray.hxx>
33 #include <svx/svdattr.hxx>
34 #include <svx/svdomeas.hxx>
35 #include <svx/svdview.hxx>
36 #include <svx/sxekitm.hxx>
37 #include <svx/sxelditm.hxx>
38 #include <svx/sxenditm.hxx>
39 #include <svx/sxmbritm.hxx>
40 #include <svx/sxmfsitm.hxx>
41 #include <svx/sxmlhitm.hxx>
42 #include <svx/sxmsuitm.hxx>
43 #include <svx/sxmtfitm.hxx>
44 #include <svx/sxmtpitm.hxx>
45 #include <svx/sxmtritm.hxx>
46 #include <svx/sxmuitm.hxx>
48 #include "measure.hxx"
50 const sal_uInt16
SvxMeasurePage::pRanges
[] =
52 SDRATTR_MEASURE_FIRST
,
57 /*************************************************************************
59 |* Dialog to change measure-attributes
61 \************************************************************************/
63 SvxMeasureDialog::SvxMeasureDialog( vcl::Window
* pParent
, const SfxItemSet
& rInAttrs
,
64 const SdrView
* pSdrView
)
65 : SfxSingleTabDialog(pParent
, rInAttrs
)
67 VclPtrInstance
<SvxMeasurePage
> _pPage( get_content_area(), rInAttrs
);
69 _pPage
->SetView( pSdrView
);
73 SetText(CUI_RESSTR(RID_SVXSTR_DIMENSION_LINE
));
76 /*************************************************************************
78 |* Tabpage for changing measure-attributes
80 \************************************************************************/
82 SvxMeasurePage::SvxMeasurePage( vcl::Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
84 ,"DimensionLinesTabPage"
85 ,"cui/ui/dimensionlinestabpage.ui"
87 rOutAttrs ( rInAttrs
),
88 aAttrSet ( *rInAttrs
.GetPool() ),
90 eUnit( SFX_MAPUNIT_100TH_MM
),
91 bPositionModified ( false )
93 get(m_pMtrFldLineDist
, "MTR_LINE_DIST");
94 get(m_pMtrFldHelplineOverhang
, "MTR_FLD_HELPLINE_OVERHANG");
95 get(m_pMtrFldHelplineDist
, "MTR_FLD_HELPLINE_DIST");
96 get(m_pMtrFldHelpline1Len
, "MTR_FLD_HELPLINE1_LEN");
97 get(m_pMtrFldHelpline2Len
, "MTR_FLD_HELPLINE2_LEN");
98 get(m_pTsbBelowRefEdge
, "TSB_BELOW_REF_EDGE");
99 get(m_pMtrFldDecimalPlaces
, "MTR_FLD_DECIMALPLACES");
101 get(m_pCtlPosition
, "CTL_POSITION");
102 get(m_pTsbAutoPosV
, "TSB_AUTOPOSV");
103 get(m_pTsbAutoPosH
, "TSB_AUTOPOSH");
104 get(m_pTsbShowUnit
, "TSB_SHOW_UNIT");
105 get(m_pLbUnit
, "LB_UNIT");
106 get(m_pTsbParallel
, "TSB_PARALLEL");
108 get(m_pCtlPreview
, "CTL_PREVIEW");
109 m_pCtlPreview
->SetAttributes(rInAttrs
);
111 get(m_pFtAutomatic
,"STR_MEASURE_AUTOMATIC");
115 const FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
116 SetFieldUnit( *m_pMtrFldLineDist
, eFUnit
);
117 SetFieldUnit( *m_pMtrFldHelplineOverhang
, eFUnit
);
118 SetFieldUnit( *m_pMtrFldHelplineDist
, eFUnit
);
119 SetFieldUnit( *m_pMtrFldHelpline1Len
, eFUnit
);
120 SetFieldUnit( *m_pMtrFldHelpline2Len
, eFUnit
);
121 if( eFUnit
== FUNIT_MM
)
123 m_pMtrFldLineDist
->SetSpinSize( 50 );
124 m_pMtrFldHelplineOverhang
->SetSpinSize( 50 );
125 m_pMtrFldHelplineDist
->SetSpinSize( 50 );
126 m_pMtrFldHelpline1Len
->SetSpinSize( 50 );
127 m_pMtrFldHelpline2Len
->SetSpinSize( 50 );
130 m_pTsbAutoPosV
->SetClickHdl( LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
) );
131 m_pTsbAutoPosH
->SetClickHdl( LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
) );
133 // set background and border of iconchoicectrl
134 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
135 m_pCtlPreview
->SetBackground ( rStyles
.GetWindowColor() );
136 m_pCtlPreview
->SetBorderStyle(WindowBorderStyle::MONO
);
138 Link
<> aLink( LINK( this, SvxMeasurePage
, ChangeAttrHdl_Impl
) );
139 m_pMtrFldLineDist
->SetModifyHdl( aLink
);
140 m_pMtrFldHelplineOverhang
->SetModifyHdl( aLink
);
141 m_pMtrFldHelplineDist
->SetModifyHdl( aLink
);
142 m_pMtrFldHelpline1Len
->SetModifyHdl( aLink
);
143 m_pMtrFldHelpline2Len
->SetModifyHdl( aLink
);
144 m_pMtrFldDecimalPlaces
->SetModifyHdl( aLink
);
145 m_pTsbBelowRefEdge
->SetClickHdl( aLink
);
146 m_pTsbParallel
->SetClickHdl( aLink
);
147 m_pTsbShowUnit
->SetClickHdl( aLink
);
148 m_pLbUnit
->SetSelectHdl( aLink
);
151 SvxMeasurePage::~SvxMeasurePage()
156 void SvxMeasurePage::dispose()
158 m_pMtrFldLineDist
.clear();
159 m_pMtrFldHelplineOverhang
.clear();
160 m_pMtrFldHelplineDist
.clear();
161 m_pMtrFldHelpline1Len
.clear();
162 m_pMtrFldHelpline2Len
.clear();
163 m_pTsbBelowRefEdge
.clear();
164 m_pMtrFldDecimalPlaces
.clear();
165 m_pCtlPosition
.clear();
166 m_pTsbAutoPosV
.clear();
167 m_pTsbAutoPosH
.clear();
168 m_pTsbShowUnit
.clear();
170 m_pTsbParallel
.clear();
171 m_pFtAutomatic
.clear();
172 m_pCtlPreview
.clear();
173 SvxTabPage::dispose();
176 /*************************************************************************
178 |* read the delivered Item-Set
180 \************************************************************************/
182 void SvxMeasurePage::Reset( const SfxItemSet
* rAttrs
)
184 SfxItemPool
* pPool
= rAttrs
->GetPool();
185 DBG_ASSERT( pPool
, "Wo ist der Pool" );
186 eUnit
= pPool
->GetMetric( SDRATTR_MEASURELINEDIST
);
188 const SfxPoolItem
* pItem
= GetItem( *rAttrs
, SDRATTR_MEASURELINEDIST
);
190 // SdrMeasureLineDistItem
192 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASURELINEDIST
);
195 long nValue
= static_cast<const SdrMetricItem
*>( pItem
)->GetValue();
196 SetMetricValue( *m_pMtrFldLineDist
, nValue
, eUnit
);
200 m_pMtrFldLineDist
->SetText( OUString() );
202 m_pMtrFldLineDist
->SaveValue();
204 // SdrMeasureHelplineOverhangItem
205 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINEOVERHANG
);
207 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG
);
210 long nValue
= static_cast<const SdrMetricItem
*>( pItem
)->GetValue();
211 SetMetricValue( *m_pMtrFldHelplineOverhang
, nValue
, eUnit
);
215 m_pMtrFldHelplineOverhang
->SetText( OUString() );
217 m_pMtrFldHelplineOverhang
->SaveValue();
219 // SdrMeasureHelplineDistItem
220 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINEDIST
);
222 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST
);
225 long nValue
= static_cast<const SdrMetricItem
*>( pItem
)->GetValue();
226 SetMetricValue( *m_pMtrFldHelplineDist
, nValue
, eUnit
);
230 m_pMtrFldHelplineDist
->SetText( OUString() );
232 m_pMtrFldHelplineDist
->SaveValue();
234 // SdrMeasureHelpline1LenItem
235 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINE1LEN
);
237 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN
);
240 long nValue
= static_cast<const SdrMetricItem
*>( pItem
)->GetValue();
241 SetMetricValue( *m_pMtrFldHelpline1Len
, nValue
, eUnit
);
245 m_pMtrFldHelpline1Len
->SetText( OUString() );
247 m_pMtrFldHelpline1Len
->SaveValue();
249 // SdrMeasureHelpline2LenItem
250 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREHELPLINE2LEN
);
252 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN
);
255 long nValue
= static_cast<const SdrMetricItem
*>( pItem
)->GetValue();
256 SetMetricValue( *m_pMtrFldHelpline2Len
, nValue
, eUnit
);
260 m_pMtrFldHelpline2Len
->SetText( OUString() );
262 m_pMtrFldHelpline2Len
->SaveValue();
264 // SdrMeasureBelowRefEdgeItem
265 if( rAttrs
->GetItemState( SDRATTR_MEASUREBELOWREFEDGE
) != SfxItemState::DONTCARE
)
267 m_pTsbBelowRefEdge
->SetState( static_cast<const SdrMeasureBelowRefEdgeItem
&>( rAttrs
->Get( SDRATTR_MEASUREBELOWREFEDGE
) ).
268 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
269 m_pTsbBelowRefEdge
->EnableTriState( false );
273 m_pTsbBelowRefEdge
->SetState( TRISTATE_INDET
);
275 m_pTsbBelowRefEdge
->SaveValue();
277 // SdrMeasureDecimalPlacesItem
278 pItem
= GetItem( *rAttrs
, SDRATTR_MEASUREDECIMALPLACES
);
280 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES
);
283 sal_Int16 nValue
= static_cast<const SdrMeasureDecimalPlacesItem
*>( pItem
)->GetValue();
284 m_pMtrFldDecimalPlaces
->SetValue( nValue
);
288 m_pMtrFldDecimalPlaces
->SetText( OUString() );
290 m_pMtrFldDecimalPlaces
->SaveValue();
292 // SdrMeasureTextRota90Item
293 // Attention: negate !
294 if( rAttrs
->GetItemState( SDRATTR_MEASURETEXTROTA90
) != SfxItemState::DONTCARE
)
296 m_pTsbParallel
->SetState( static_cast<const SdrMeasureTextRota90Item
&>( rAttrs
->Get( SDRATTR_MEASURETEXTROTA90
) ).
297 GetValue() ? TRISTATE_FALSE
: TRISTATE_TRUE
);
298 m_pTsbParallel
->EnableTriState( false );
302 m_pTsbParallel
->SetState( TRISTATE_INDET
);
304 m_pTsbParallel
->SaveValue();
306 // SdrMeasureShowUnitItem
307 if( rAttrs
->GetItemState( SDRATTR_MEASURESHOWUNIT
) != SfxItemState::DONTCARE
)
309 m_pTsbShowUnit
->SetState( static_cast<const SdrYesNoItem
&>( rAttrs
->Get( SDRATTR_MEASURESHOWUNIT
) ).
310 GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
311 m_pTsbShowUnit
->EnableTriState( false );
315 m_pTsbShowUnit
->SetState( TRISTATE_INDET
);
317 m_pTsbShowUnit
->SaveValue();
319 // SdrMeasureUnitItem
320 if( rAttrs
->GetItemState( SDRATTR_MEASUREUNIT
) != SfxItemState::DONTCARE
)
322 long nFieldUnit
= (long) static_cast<const SdrMeasureUnitItem
&>( rAttrs
->
323 Get( SDRATTR_MEASUREUNIT
) ).GetValue();
325 for( sal_Int32 i
= 0; i
< m_pLbUnit
->GetEntryCount(); ++i
)
327 if ( reinterpret_cast<sal_IntPtr
>(m_pLbUnit
->GetEntryData( i
)) == nFieldUnit
)
329 m_pLbUnit
->SelectEntryPos( i
);
336 m_pLbUnit
->SetNoSelection();
338 m_pLbUnit
->SaveValue();
341 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTVPOS
) != SfxItemState::DONTCARE
)
343 SdrMeasureTextVPos eVPos
= (SdrMeasureTextVPos
)
344 static_cast<const SdrMeasureTextVPosItem
&>( rAttrs
->Get( SDRATTR_MEASURETEXTVPOS
) ).GetValue();
346 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTHPOS
) != SfxItemState::DONTCARE
)
348 m_pTsbAutoPosV
->EnableTriState( false );
349 m_pTsbAutoPosH
->EnableTriState( false );
351 SdrMeasureTextHPos eHPos
= (SdrMeasureTextHPos
)
352 static_cast<const SdrMeasureTextHPosItem
&>( rAttrs
->Get( SDRATTR_MEASURETEXTHPOS
) ).GetValue();
353 RECT_POINT eRP
= RP_MM
;
356 case SDRMEASURE_ABOVE
:
359 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LT
; break;
360 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MT
; break;
361 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RT
; break;
362 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MT
; break;
365 case SDRMEASURETEXT_VERTICALCENTERED
:
368 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LM
; break;
369 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MM
; break;
370 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RM
; break;
371 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MM
; break;
374 case SDRMEASURE_BELOW
:
377 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LB
; break;
378 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MB
; break;
379 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RB
; break;
380 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MB
; break;
383 case SDRMEASURE_TEXTVAUTO
:
386 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LM
; break;
387 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MM
; break;
388 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RM
; break;
389 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MM
; break;
392 default: ;//prevent warning
395 CTL_STATE nState
= CTL_STATE::NONE
;
397 if( eHPos
== SDRMEASURE_TEXTHAUTO
)
399 m_pTsbAutoPosH
->SetState( TRISTATE_TRUE
);
400 nState
= CTL_STATE::NOHORZ
;
403 if( eVPos
== SDRMEASURE_TEXTVAUTO
)
405 m_pTsbAutoPosV
->SetState( TRISTATE_TRUE
);
406 nState
|= CTL_STATE::NOVERT
;
409 m_pCtlPosition
->SetState( nState
);
410 m_pCtlPosition
->SetActualRP( eRP
);
416 m_pCtlPosition
->Reset();
417 m_pTsbAutoPosV
->SetState( TRISTATE_INDET
);
418 m_pTsbAutoPosH
->SetState( TRISTATE_INDET
);
421 // put the attributes to the preview-control,
422 // otherwise the control don't know about
423 // the settings of the dialog (#67930)
424 ChangeAttrHdl_Impl( m_pTsbShowUnit
);
425 m_pCtlPreview
->SetAttributes( *rAttrs
);
427 bPositionModified
= false;
430 /*************************************************************************
432 |* Fill the delivered Item-Set with dialogbox-attributes
434 \************************************************************************/
436 bool SvxMeasurePage::FillItemSet( SfxItemSet
* rAttrs
)
438 bool bModified
= false;
442 if( m_pMtrFldLineDist
->IsValueChangedFromSaved() )
444 nValue
= GetCoreValue( *m_pMtrFldLineDist
, eUnit
);
445 rAttrs
->Put( makeSdrMeasureLineDistItem( nValue
) );
449 if( m_pMtrFldHelplineOverhang
->IsValueChangedFromSaved() )
451 nValue
= GetCoreValue( *m_pMtrFldHelplineOverhang
, eUnit
);
452 rAttrs
->Put( makeSdrMeasureHelplineOverhangItem( nValue
) );
456 if( m_pMtrFldHelplineDist
->IsValueChangedFromSaved() )
458 nValue
= GetCoreValue( *m_pMtrFldHelplineDist
, eUnit
);
459 rAttrs
->Put( makeSdrMeasureHelplineDistItem( nValue
) );
463 if( m_pMtrFldHelpline1Len
->IsValueChangedFromSaved() )
465 nValue
= GetCoreValue( *m_pMtrFldHelpline1Len
, eUnit
);
466 rAttrs
->Put( makeSdrMeasureHelpline1LenItem( nValue
) );
470 if( m_pMtrFldHelpline2Len
->IsValueChangedFromSaved() )
472 nValue
= GetCoreValue( *m_pMtrFldHelpline2Len
, eUnit
);
473 rAttrs
->Put( makeSdrMeasureHelpline2LenItem( nValue
) );
477 eState
= m_pTsbBelowRefEdge
->GetState();
478 if( m_pTsbBelowRefEdge
->IsValueChangedFromSaved() )
480 rAttrs
->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE
== eState
) );
484 if( m_pMtrFldDecimalPlaces
->IsValueChangedFromSaved() )
486 nValue
= static_cast<sal_Int32
>(m_pMtrFldDecimalPlaces
->GetValue());
488 SdrMeasureDecimalPlacesItem(
489 sal::static_int_cast
< sal_Int16
>( nValue
) ) );
493 eState
= m_pTsbParallel
->GetState();
494 if( m_pTsbParallel
->IsValueChangedFromSaved() )
496 rAttrs
->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE
== eState
) );
500 eState
= m_pTsbShowUnit
->GetState();
501 if( m_pTsbShowUnit
->IsValueChangedFromSaved() )
503 rAttrs
->Put( makeSdrMeasureShowUnitItem( TRISTATE_TRUE
== eState
) );
507 sal_Int32 nPos
= m_pLbUnit
->GetSelectEntryPos();
508 if( m_pLbUnit
->IsValueChangedFromSaved() )
510 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
512 sal_uInt16 nFieldUnit
= (sal_uInt16
)reinterpret_cast<sal_IntPtr
>(m_pLbUnit
->GetEntryData( nPos
));
513 FieldUnit _eUnit
= (FieldUnit
) nFieldUnit
;
514 rAttrs
->Put( SdrMeasureUnitItem( _eUnit
) );
519 if( bPositionModified
)
522 SdrMeasureTextVPos eVPos
, eOldVPos
;
523 SdrMeasureTextHPos eHPos
, eOldHPos
;
525 RECT_POINT eRP
= m_pCtlPosition
->GetActualRP();
529 case RP_LT
: eVPos
= SDRMEASURE_ABOVE
;
530 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
531 case RP_LM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
532 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
533 case RP_LB
: eVPos
= SDRMEASURE_BELOW
;
534 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
535 case RP_MT
: eVPos
= SDRMEASURE_ABOVE
;
536 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
537 case RP_MM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
538 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
539 case RP_MB
: eVPos
= SDRMEASURE_BELOW
;
540 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
541 case RP_RT
: eVPos
= SDRMEASURE_ABOVE
;
542 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
543 case RP_RM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
544 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
545 case RP_RB
: eVPos
= SDRMEASURE_BELOW
;
546 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
548 if( m_pTsbAutoPosH
->GetState() == TRISTATE_TRUE
)
549 eHPos
= SDRMEASURE_TEXTHAUTO
;
551 if( m_pTsbAutoPosV
->GetState() == TRISTATE_TRUE
)
552 eVPos
= SDRMEASURE_TEXTVAUTO
;
554 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTVPOS
) != SfxItemState::DONTCARE
)
556 eOldVPos
= (SdrMeasureTextVPos
)
557 static_cast<const SdrMeasureTextVPosItem
&>( rOutAttrs
.Get( SDRATTR_MEASURETEXTVPOS
) ).GetValue();
558 if( eOldVPos
!= eVPos
)
560 rAttrs
->Put( SdrMeasureTextVPosItem( eVPos
) );
566 rAttrs
->Put( SdrMeasureTextVPosItem( eVPos
) );
570 if ( rAttrs
->GetItemState( SDRATTR_MEASURETEXTHPOS
) != SfxItemState::DONTCARE
)
572 eOldHPos
= (SdrMeasureTextHPos
)
573 static_cast<const SdrMeasureTextHPosItem
&>( rOutAttrs
.Get( SDRATTR_MEASURETEXTHPOS
) ).GetValue();
574 if( eOldHPos
!= eHPos
)
576 rAttrs
->Put( SdrMeasureTextHPosItem( eHPos
) );
582 rAttrs
->Put( SdrMeasureTextHPosItem( eHPos
) );
590 /*************************************************************************
592 |* The View have to set at the measure-object to be able to notify
593 |* unit and floatingpoint-values
595 \************************************************************************/
597 void SvxMeasurePage::Construct()
599 DBG_ASSERT( pView
, "Keine gueltige View Uebergeben!" );
601 m_pCtlPreview
->pMeasureObj
->SetModel( pView
->GetModel() );
602 m_pCtlPreview
->Invalidate();
605 VclPtr
<SfxTabPage
> SvxMeasurePage::Create( vcl::Window
* pWindow
,
606 const SfxItemSet
* rAttrs
)
608 return VclPtr
<SvxMeasurePage
>::Create( pWindow
, *rAttrs
);
611 void SvxMeasurePage::PointChanged( vcl::Window
* pWindow
, RECT_POINT
/*eRP*/ )
613 ChangeAttrHdl_Impl( pWindow
);
616 IMPL_LINK( SvxMeasurePage
, ClickAutoPosHdl_Impl
, void *, p
)
618 if( m_pTsbAutoPosH
->GetState() == TRISTATE_TRUE
)
620 switch( m_pCtlPosition
->GetActualRP() )
624 m_pCtlPosition
->SetActualRP( RP_MT
);
629 m_pCtlPosition
->SetActualRP( RP_MM
);
634 m_pCtlPosition
->SetActualRP( RP_MB
);
636 default: ;//prevent warning
639 if( m_pTsbAutoPosV
->GetState() == TRISTATE_TRUE
)
641 switch( m_pCtlPosition
->GetActualRP() )
645 m_pCtlPosition
->SetActualRP( RP_LM
);
650 m_pCtlPosition
->SetActualRP( RP_MM
);
655 m_pCtlPosition
->SetActualRP( RP_RM
);
657 default: ;//prevent warning
660 ChangeAttrHdl_Impl( p
);
665 IMPL_LINK( SvxMeasurePage
, ChangeAttrHdl_Impl
, void *, p
)
668 if( p
== m_pMtrFldLineDist
)
670 sal_Int32 nValue
= GetCoreValue( *m_pMtrFldLineDist
, eUnit
);
671 aAttrSet
.Put( makeSdrMeasureLineDistItem( nValue
) );
674 if( p
== m_pMtrFldHelplineOverhang
)
676 sal_Int32 nValue
= GetCoreValue( *m_pMtrFldHelplineOverhang
, eUnit
);
677 aAttrSet
.Put( makeSdrMeasureHelplineOverhangItem( nValue
) );
680 if( p
== m_pMtrFldHelplineDist
)
682 sal_Int32 nValue
= GetCoreValue( *m_pMtrFldHelplineDist
, eUnit
);
683 aAttrSet
.Put( makeSdrMeasureHelplineDistItem( nValue
) );
686 if( p
== m_pMtrFldHelpline1Len
)
688 sal_Int32 nValue
= GetCoreValue( *m_pMtrFldHelpline1Len
, eUnit
);
689 aAttrSet
.Put( makeSdrMeasureHelpline1LenItem( nValue
) );
692 if( p
== m_pMtrFldHelpline2Len
)
694 sal_Int32 nValue
= GetCoreValue( *m_pMtrFldHelpline2Len
, eUnit
);
695 aAttrSet
.Put( makeSdrMeasureHelpline2LenItem( nValue
) );
698 if( p
== m_pTsbBelowRefEdge
)
700 TriState eState
= m_pTsbBelowRefEdge
->GetState();
701 if( eState
!= TRISTATE_INDET
)
702 aAttrSet
.Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE
== eState
) );
705 if( p
== m_pMtrFldDecimalPlaces
)
707 sal_Int16 nValue
= sal::static_int_cast
< sal_Int16
>(
708 m_pMtrFldDecimalPlaces
->GetValue() );
709 aAttrSet
.Put( SdrMeasureDecimalPlacesItem( nValue
) );
712 if( p
== m_pTsbParallel
)
714 TriState eState
= m_pTsbParallel
->GetState();
715 if( eState
!= TRISTATE_INDET
)
716 aAttrSet
.Put( SdrMeasureTextRota90Item( TRISTATE_FALSE
== eState
) );
719 if( p
== m_pTsbShowUnit
)
721 TriState eState
= m_pTsbShowUnit
->GetState();
722 if( eState
!= TRISTATE_INDET
)
723 aAttrSet
.Put( makeSdrMeasureShowUnitItem( TRISTATE_TRUE
== eState
) );
728 sal_Int32 nPos
= m_pLbUnit
->GetSelectEntryPos();
729 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
731 sal_uInt16 nFieldUnit
= (sal_uInt16
)reinterpret_cast<sal_IntPtr
>(m_pLbUnit
->GetEntryData( nPos
));
732 FieldUnit _eUnit
= (FieldUnit
) nFieldUnit
;
733 aAttrSet
.Put( SdrMeasureUnitItem( _eUnit
) );
737 if( p
== m_pTsbAutoPosV
|| p
== m_pTsbAutoPosH
|| p
== m_pCtlPosition
)
739 bPositionModified
= true;
742 RECT_POINT eRP
= m_pCtlPosition
->GetActualRP();
743 SdrMeasureTextVPos eVPos
;
744 SdrMeasureTextHPos eHPos
;
749 case RP_LT
: eVPos
= SDRMEASURE_ABOVE
;
750 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
751 case RP_LM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
752 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
753 case RP_LB
: eVPos
= SDRMEASURE_BELOW
;
754 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
755 case RP_MT
: eVPos
= SDRMEASURE_ABOVE
;
756 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
757 case RP_MM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
758 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
759 case RP_MB
: eVPos
= SDRMEASURE_BELOW
;
760 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
761 case RP_RT
: eVPos
= SDRMEASURE_ABOVE
;
762 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
763 case RP_RM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
764 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
765 case RP_RB
: eVPos
= SDRMEASURE_BELOW
;
766 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
769 CTL_STATE nState
= CTL_STATE::NONE
;
771 if( m_pTsbAutoPosH
->GetState() == TRISTATE_TRUE
)
773 eHPos
= SDRMEASURE_TEXTHAUTO
;
774 nState
= CTL_STATE::NOHORZ
;
777 if( m_pTsbAutoPosV
->GetState() == TRISTATE_TRUE
)
779 eVPos
= SDRMEASURE_TEXTVAUTO
;
780 nState
|= CTL_STATE::NOVERT
;
783 if( p
== m_pTsbAutoPosV
|| p
== m_pTsbAutoPosH
)
784 m_pCtlPosition
->SetState( nState
);
786 aAttrSet
.Put( SdrMeasureTextVPosItem( eVPos
) );
787 aAttrSet
.Put( SdrMeasureTextHPosItem( eHPos
) );
790 m_pCtlPreview
->SetAttributes( aAttrSet
);
791 m_pCtlPreview
->Invalidate();
796 void SvxMeasurePage::FillUnitLB()
798 // fill ListBox with metrics
799 SvxStringArray
aMetricArr( SVX_RES( RID_SVXSTR_FIELDUNIT_TABLE
) );
801 sal_IntPtr nUnit
= FUNIT_NONE
;
802 OUString
aStrMetric( m_pFtAutomatic
->GetText());
803 sal_Int32 nPos
= m_pLbUnit
->InsertEntry( aStrMetric
);
804 m_pLbUnit
->SetEntryData( nPos
, reinterpret_cast<void*>(nUnit
) );
806 for( sal_uInt32 i
= 0; i
< aMetricArr
.Count(); ++i
)
808 aStrMetric
= aMetricArr
.GetStringByPos( i
);
809 nUnit
= aMetricArr
.GetValue( i
);
810 nPos
= m_pLbUnit
->InsertEntry( aStrMetric
);
811 m_pLbUnit
->SetEntryData( nPos
, reinterpret_cast<void*>(nUnit
) );
814 void SvxMeasurePage::PageCreated(const SfxAllItemSet
& aSet
)
816 SFX_ITEMSET_ARG (&aSet
,pOfaPtrItem
,OfaPtrItem
,SID_OBJECT_LIST
,false);
819 SetView( static_cast<SdrView
*>(pOfaPtrItem
->GetValue()));
824 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */