1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: measure.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
39 // include ---------------------------------------------------------------
40 #include <sfx2/app.hxx>
41 #include <sfx2/module.hxx>
42 #include <tools/shl.hxx>
44 #include <svx/dialogs.hrc>
46 #define _SVX_MEASURE_CXX
48 #include <svx/svdomeas.hxx>
49 #include <svx/svdattr.hxx>
50 #include <svx/svdattrx.hxx>
51 #include <svx/svdview.hxx>
53 #include "measctrl.hxx"
54 #include "measure.hxx"
55 #include "measure.hrc"
56 #include <svx/dialmgr.hxx>
57 #include "dlgutil.hxx"
58 #include <svx/strarray.hxx>
59 #include <sfx2/request.hxx> //add CHINA001
60 #include "ofaitem.hxx" //add CHINA001
62 static USHORT pRanges
[] =
64 SDRATTR_MEASURE_FIRST
,
69 /*************************************************************************
71 |* Dialog to change measure-attributes
73 \************************************************************************/
75 SvxMeasureDialog::SvxMeasureDialog( Window
* pParent
, const SfxItemSet
& rInAttrs
,
76 const SdrView
* pSdrView
) :
77 SfxSingleTabDialog( pParent
, rInAttrs
, RID_SVXPAGE_MEASURE
)
79 SvxMeasurePage
* _pPage
= new SvxMeasurePage( this, rInAttrs
);
81 _pPage
->SetView( pSdrView
);
85 SetText( _pPage
->GetText() );
88 /*************************************************************************
92 \************************************************************************/
94 SvxMeasureDialog::~SvxMeasureDialog()
98 /*************************************************************************
100 |* Tabpage for changing measure-attributes
102 \************************************************************************/
104 SvxMeasurePage::SvxMeasurePage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
105 SvxTabPage ( pWindow
, SVX_RES( RID_SVXPAGE_MEASURE
),
108 aFlLine ( this, SVX_RES( FL_LINE
) ),
109 aFtLineDist ( this, SVX_RES( FT_LINE_DIST
) ),
110 aMtrFldLineDist ( this, SVX_RES( MTR_LINE_DIST
) ),
111 aFtHelplineOverhang ( this, SVX_RES( FT_HELPLINE_OVERHANG
) ),
112 aMtrFldHelplineOverhang ( this, SVX_RES( MTR_FLD_HELPLINE_OVERHANG
) ),
113 aFtHelplineDist ( this, SVX_RES( FT_HELPLINE_DIST
) ),
114 aMtrFldHelplineDist ( this, SVX_RES( MTR_FLD_HELPLINE_DIST
) ),
115 aFtHelpline1Len ( this, SVX_RES( FT_HELPLINE1_LEN
) ),
116 aMtrFldHelpline1Len ( this, SVX_RES( MTR_FLD_HELPLINE1_LEN
) ),
117 aFtHelpline2Len ( this, SVX_RES( FT_HELPLINE2_LEN
) ),
118 aMtrFldHelpline2Len ( this, SVX_RES( MTR_FLD_HELPLINE2_LEN
) ),
119 aTsbBelowRefEdge ( this, SVX_RES( TSB_BELOW_REF_EDGE
) ),
120 aFtDecimalPlaces ( this, SVX_RES( FT_DECIMALPLACES
) ),
121 aMtrFldDecimalPlaces ( this, SVX_RES( MTR_FLD_DECIMALPLACES
) ),
123 aFlLabel ( this, SVX_RES( FL_LABEL
) ),
124 aFtPosition ( this, SVX_RES( FT_POSITION
) ),
125 aCtlPosition ( this, SVX_RES( CTL_POSITION
) ),
126 aTsbAutoPosV ( this, SVX_RES( TSB_AUTOPOSV
) ),
127 aTsbAutoPosH ( this, SVX_RES( TSB_AUTOPOSH
) ),
128 aTsbShowUnit ( this, SVX_RES( TSB_SHOW_UNIT
) ),
129 aLbUnit ( this, SVX_RES( LB_UNIT
) ),
130 aTsbParallel ( this, SVX_RES( TSB_PARALLEL
) ),
131 aCtlPreview ( this, SVX_RES( CTL_PREVIEW
), rInAttrs
),
133 aFlVert ( this, SVX_RES( FL_VERT
) ),
134 rOutAttrs ( rInAttrs
),
135 aAttrSet ( *rInAttrs
.GetPool() ),
138 bPositionModified ( FALSE
)
144 const FieldUnit eFUnit
= GetModuleFieldUnit( &rInAttrs
);
145 SetFieldUnit( aMtrFldLineDist
, eFUnit
);
146 SetFieldUnit( aMtrFldHelplineOverhang
, eFUnit
);
147 SetFieldUnit( aMtrFldHelplineDist
, eFUnit
);
148 SetFieldUnit( aMtrFldHelpline1Len
, eFUnit
);
149 SetFieldUnit( aMtrFldHelpline2Len
, eFUnit
);
150 if( eFUnit
== FUNIT_MM
)
152 aMtrFldLineDist
.SetSpinSize( 50 );
153 aMtrFldHelplineOverhang
.SetSpinSize( 50 );
154 aMtrFldHelplineDist
.SetSpinSize( 50 );
155 aMtrFldHelpline1Len
.SetSpinSize( 50 );
156 aMtrFldHelpline2Len
.SetSpinSize( 50 );
159 aTsbAutoPosV
.SetClickHdl( LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
) );
160 aTsbAutoPosH
.SetClickHdl( LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
) );
162 // set background and border of iconchoicectrl
163 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
164 aCtlPreview
.SetBackground ( rStyles
.GetWindowColor() );
165 aCtlPreview
.SetBorderStyle(WINDOW_BORDER_MONO
);
167 Link
aLink( LINK( this, SvxMeasurePage
, ChangeAttrHdl_Impl
) );
168 aMtrFldLineDist
.SetModifyHdl( aLink
);
169 aMtrFldHelplineOverhang
.SetModifyHdl( aLink
);
170 aMtrFldHelplineDist
.SetModifyHdl( aLink
);
171 aMtrFldHelpline1Len
.SetModifyHdl( aLink
);
172 aMtrFldHelpline2Len
.SetModifyHdl( aLink
);
173 aMtrFldDecimalPlaces
.SetModifyHdl( aLink
);
174 aTsbBelowRefEdge
.SetClickHdl( aLink
);
175 aTsbParallel
.SetClickHdl( aLink
);
176 aTsbShowUnit
.SetClickHdl( aLink
);
177 aLbUnit
.SetSelectHdl( aLink
);
180 /*************************************************************************
184 \************************************************************************/
186 SvxMeasurePage::~SvxMeasurePage()
190 /*************************************************************************
192 |* read the delivered Item-Set
194 \************************************************************************/
196 void __EXPORT
SvxMeasurePage::Reset( const SfxItemSet
& rAttrs
)
198 SfxItemPool
* pPool
= rAttrs
.GetPool();
199 DBG_ASSERT( pPool
, "Wo ist der Pool" );
200 eUnit
= pPool
->GetMetric( SDRATTR_MEASURELINEDIST
);
202 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_MEASURELINEDIST
);
204 // SdrMeasureLineDistItem
206 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASURELINEDIST
);
209 long nValue
= ( ( const SdrMeasureLineDistItem
* )pItem
)->GetValue();
210 SetMetricValue( aMtrFldLineDist
, nValue
, eUnit
);
214 aMtrFldLineDist
.SetText( String() );
216 aMtrFldLineDist
.SaveValue();
218 // SdrMeasureHelplineOverhangItem
219 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINEOVERHANG
);
221 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG
);
224 long nValue
= ( ( const SdrMeasureHelplineOverhangItem
* )pItem
)->GetValue();
225 SetMetricValue( aMtrFldHelplineOverhang
, nValue
, eUnit
);
229 aMtrFldHelplineOverhang
.SetText( String() );
231 aMtrFldHelplineOverhang
.SaveValue();
233 // SdrMeasureHelplineDistItem
234 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINEDIST
);
236 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST
);
239 long nValue
= ( ( const SdrMeasureHelplineDistItem
* )pItem
)->GetValue();
240 SetMetricValue( aMtrFldHelplineDist
, nValue
, eUnit
);
244 aMtrFldHelplineDist
.SetText( String() );
246 aMtrFldHelplineDist
.SaveValue();
248 // SdrMeasureHelpline1LenItem
249 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINE1LEN
);
251 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN
);
254 long nValue
= ( ( const SdrMeasureHelpline1LenItem
* )pItem
)->GetValue();
255 SetMetricValue( aMtrFldHelpline1Len
, nValue
, eUnit
);
259 aMtrFldHelpline1Len
.SetText( String() );
261 aMtrFldHelpline1Len
.SaveValue();
263 // SdrMeasureHelpline2LenItem
264 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINE2LEN
);
266 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN
);
269 long nValue
= ( ( const SdrMeasureHelpline2LenItem
* )pItem
)->GetValue();
270 SetMetricValue( aMtrFldHelpline2Len
, nValue
, eUnit
);
274 aMtrFldHelpline2Len
.SetText( String() );
276 aMtrFldHelpline2Len
.SaveValue();
278 // SdrMeasureBelowRefEdgeItem
279 if( rAttrs
.GetItemState( SDRATTR_MEASUREBELOWREFEDGE
) != SFX_ITEM_DONTCARE
)
281 aTsbBelowRefEdge
.SetState( ( ( const SdrMeasureBelowRefEdgeItem
& )rAttrs
.Get( SDRATTR_MEASUREBELOWREFEDGE
) ).
282 GetValue() ? STATE_CHECK
: STATE_NOCHECK
);
283 aTsbBelowRefEdge
.EnableTriState( FALSE
);
287 aTsbBelowRefEdge
.SetState( STATE_DONTKNOW
);
289 aTsbBelowRefEdge
.SaveValue();
291 // SdrMeasureDecimalPlacesItem
292 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREDECIMALPLACES
);
294 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES
);
297 INT16 nValue
= ( ( const SdrMeasureDecimalPlacesItem
* )pItem
)->GetValue();
298 aMtrFldDecimalPlaces
.SetValue( nValue
);
302 aMtrFldDecimalPlaces
.SetText( String() );
304 aMtrFldDecimalPlaces
.SaveValue();
306 // SdrMeasureTextRota90Item
307 // Attention: negate !
308 if( rAttrs
.GetItemState( SDRATTR_MEASURETEXTROTA90
) != SFX_ITEM_DONTCARE
)
310 aTsbParallel
.SetState( ( ( const SdrMeasureTextRota90Item
& )rAttrs
.Get( SDRATTR_MEASURETEXTROTA90
) ).
311 GetValue() ? STATE_NOCHECK
: STATE_CHECK
);
312 aTsbParallel
.EnableTriState( FALSE
);
316 aTsbParallel
.SetState( STATE_DONTKNOW
);
318 aTsbParallel
.SaveValue();
320 // SdrMeasureShowUnitItem
321 if( rAttrs
.GetItemState( SDRATTR_MEASURESHOWUNIT
) != SFX_ITEM_DONTCARE
)
323 aTsbShowUnit
.SetState( ( ( const SdrMeasureShowUnitItem
& )rAttrs
.Get( SDRATTR_MEASURESHOWUNIT
) ).
324 GetValue() ? STATE_CHECK
: STATE_NOCHECK
);
325 aTsbShowUnit
.EnableTriState( FALSE
);
329 aTsbShowUnit
.SetState( STATE_DONTKNOW
);
331 aTsbShowUnit
.SaveValue();
333 // SdrMeasureUnitItem
334 if( rAttrs
.GetItemState( SDRATTR_MEASUREUNIT
) != SFX_ITEM_DONTCARE
)
336 long nFieldUnit
= (long) ( ( const SdrMeasureUnitItem
& )rAttrs
.
337 Get( SDRATTR_MEASUREUNIT
) ).GetValue();
339 for( USHORT i
= 0; i
< aLbUnit
.GetEntryCount(); ++i
)
341 if ( (long)aLbUnit
.GetEntryData( i
) == nFieldUnit
)
343 aLbUnit
.SelectEntryPos( i
);
350 aLbUnit
.SetNoSelection();
355 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTVPOS
) != SFX_ITEM_DONTCARE
)
357 SdrMeasureTextVPos eVPos
= (SdrMeasureTextVPos
)
358 ( ( const SdrMeasureTextVPosItem
& )rAttrs
.Get( SDRATTR_MEASURETEXTVPOS
) ).GetValue();
360 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTHPOS
) != SFX_ITEM_DONTCARE
)
362 aTsbAutoPosV
.EnableTriState( FALSE
);
363 aTsbAutoPosH
.EnableTriState( FALSE
);
365 SdrMeasureTextHPos eHPos
= (SdrMeasureTextHPos
)
366 ( ( const SdrMeasureTextHPosItem
& )rAttrs
.Get( SDRATTR_MEASURETEXTHPOS
) ).GetValue();
367 RECT_POINT eRP
= RP_MM
;
370 case SDRMEASURE_ABOVE
:
373 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LT
; break;
374 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MT
; break;
375 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RT
; break;
376 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MT
; break;
379 case SDRMEASURETEXT_VERTICALCENTERED
:
382 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LM
; break;
383 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MM
; break;
384 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RM
; break;
385 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MM
; break;
388 case SDRMEASURE_BELOW
:
391 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LB
; break;
392 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MB
; break;
393 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RB
; break;
394 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MB
; break;
397 case SDRMEASURE_TEXTVAUTO
:
400 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LM
; break;
401 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MM
; break;
402 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RM
; break;
403 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MM
; break;
406 default: ;//prevent warning
409 CTL_STATE nState
= 0;
411 if( eHPos
== SDRMEASURE_TEXTHAUTO
)
413 aTsbAutoPosH
.SetState( STATE_CHECK
);
417 if( eVPos
== SDRMEASURE_TEXTVAUTO
)
419 aTsbAutoPosV
.SetState( STATE_CHECK
);
423 aCtlPosition
.SetState( nState
);
424 aCtlPosition
.SetActualRP( eRP
);
430 aCtlPosition
.Reset();
431 aTsbAutoPosV
.SetState( STATE_DONTKNOW
);
432 aTsbAutoPosH
.SetState( STATE_DONTKNOW
);
435 // put the attributes to the preview-control,
436 // otherwise the control don't know about
437 // the settings of the dialog (#67930)
438 ChangeAttrHdl_Impl( &aTsbShowUnit
);
439 aCtlPreview
.SetAttributes( rAttrs
);
441 bPositionModified
= FALSE
;
444 /*************************************************************************
446 |* Fill the delivered Item-Set with dialogbox-attributes
448 \************************************************************************/
450 BOOL
SvxMeasurePage::FillItemSet( SfxItemSet
& rAttrs
)
452 BOOL bModified
= FALSE
;
456 if( aMtrFldLineDist
.GetText() != aMtrFldLineDist
.GetSavedValue() )
458 nValue
= GetCoreValue( aMtrFldLineDist
, eUnit
);
459 rAttrs
.Put( SdrMeasureLineDistItem( nValue
) );
463 if( aMtrFldHelplineOverhang
.GetText() != aMtrFldHelplineOverhang
.GetSavedValue() )
465 nValue
= GetCoreValue( aMtrFldHelplineOverhang
, eUnit
);
466 rAttrs
.Put( SdrMeasureHelplineOverhangItem( nValue
) );
470 if( aMtrFldHelplineDist
.GetText() != aMtrFldHelplineDist
.GetSavedValue() )
472 nValue
= GetCoreValue( aMtrFldHelplineDist
, eUnit
);
473 rAttrs
.Put( SdrMeasureHelplineDistItem( nValue
) );
477 if( aMtrFldHelpline1Len
.GetText() != aMtrFldHelpline1Len
.GetSavedValue() )
479 nValue
= GetCoreValue( aMtrFldHelpline1Len
, eUnit
);
480 rAttrs
.Put( SdrMeasureHelpline1LenItem( nValue
) );
484 if( aMtrFldHelpline2Len
.GetText() != aMtrFldHelpline2Len
.GetSavedValue() )
486 nValue
= GetCoreValue( aMtrFldHelpline2Len
, eUnit
);
487 rAttrs
.Put( SdrMeasureHelpline2LenItem( nValue
) );
491 eState
= aTsbBelowRefEdge
.GetState();
492 if( eState
!= aTsbBelowRefEdge
.GetSavedValue() )
494 rAttrs
.Put( SdrMeasureBelowRefEdgeItem( (BOOL
) STATE_CHECK
== eState
) );
498 if( aMtrFldDecimalPlaces
.GetText() != aMtrFldDecimalPlaces
.GetSavedValue() )
500 nValue
= static_cast<INT32
>(aMtrFldDecimalPlaces
.GetValue());
502 SdrMeasureDecimalPlacesItem(
503 sal::static_int_cast
< INT16
>( nValue
) ) );
507 eState
= aTsbParallel
.GetState();
508 if( eState
!= aTsbParallel
.GetSavedValue() )
510 rAttrs
.Put( SdrMeasureTextRota90Item( (BOOL
) STATE_NOCHECK
== eState
) );
514 eState
= aTsbShowUnit
.GetState();
515 if( eState
!= aTsbShowUnit
.GetSavedValue() )
517 rAttrs
.Put( SdrMeasureShowUnitItem( (BOOL
) STATE_CHECK
== eState
) );
521 USHORT nPos
= aLbUnit
.GetSelectEntryPos();
522 if( nPos
!= aLbUnit
.GetSavedValue() )
524 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
526 USHORT nFieldUnit
= (USHORT
)(long)aLbUnit
.GetEntryData( nPos
);
527 FieldUnit _eUnit
= (FieldUnit
) nFieldUnit
;
528 rAttrs
.Put( SdrMeasureUnitItem( _eUnit
) );
533 //enum SdrMeasureTextHPos {SDRMEASURE_TEXTHAUTO,SDRMEASURE_TEXTLEFTOUTSIDE,SDRMEASURE_TEXTINSIDE,SDRMEASURE_TEXTRIGHTOUTSIDE};
534 //enum SdrMeasureTextVPos {SDRMEASURE_TEXTVAUTO,SDRMEASURE_ABOVE,SDRMEASURETEXT_VERTICALCENTERED,SDRMEASURE_BELOW};
536 if( bPositionModified
)
539 SdrMeasureTextVPos eVPos
, eOldVPos
;
540 SdrMeasureTextHPos eHPos
, eOldHPos
;
542 RECT_POINT eRP
= aCtlPosition
.GetActualRP();
546 case RP_LT
: eVPos
= SDRMEASURE_ABOVE
;
547 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
548 case RP_LM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
549 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
550 case RP_LB
: eVPos
= SDRMEASURE_BELOW
;
551 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
552 case RP_MT
: eVPos
= SDRMEASURE_ABOVE
;
553 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
554 case RP_MM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
555 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
556 case RP_MB
: eVPos
= SDRMEASURE_BELOW
;
557 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
558 case RP_RT
: eVPos
= SDRMEASURE_ABOVE
;
559 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
560 case RP_RM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
561 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
562 case RP_RB
: eVPos
= SDRMEASURE_BELOW
;
563 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
565 if( aTsbAutoPosH
.GetState() == STATE_CHECK
)
566 eHPos
= SDRMEASURE_TEXTHAUTO
;
568 if( aTsbAutoPosV
.GetState() == STATE_CHECK
)
569 eVPos
= SDRMEASURE_TEXTVAUTO
;
571 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTVPOS
) != SFX_ITEM_DONTCARE
)
573 eOldVPos
= (SdrMeasureTextVPos
)
574 ( ( const SdrMeasureTextVPosItem
& )rOutAttrs
.Get( SDRATTR_MEASURETEXTVPOS
) ).GetValue();
575 if( eOldVPos
!= eVPos
)
577 rAttrs
.Put( SdrMeasureTextVPosItem( eVPos
) );
583 rAttrs
.Put( SdrMeasureTextVPosItem( eVPos
) );
587 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTHPOS
) != SFX_ITEM_DONTCARE
)
589 eOldHPos
= (SdrMeasureTextHPos
)
590 ( ( const SdrMeasureTextHPosItem
& )rOutAttrs
.Get( SDRATTR_MEASURETEXTHPOS
) ).GetValue();
591 if( eOldHPos
!= eHPos
)
593 rAttrs
.Put( SdrMeasureTextHPosItem( eHPos
) );
599 rAttrs
.Put( SdrMeasureTextHPosItem( eHPos
) );
607 /*************************************************************************
609 |* The View have to set at the measure-object to be able to notify
610 |* unit and floatingpoint-values
612 \************************************************************************/
614 void SvxMeasurePage::Construct()
616 DBG_ASSERT( pView
, "Keine gueltige View Uebergeben!" );
618 aCtlPreview
.pMeasureObj
->SetModel( pView
->GetModel() );
619 aCtlPreview
.Invalidate();
622 /*************************************************************************
624 |* create the tabpage
626 \************************************************************************/
628 SfxTabPage
* SvxMeasurePage::Create( Window
* pWindow
,
629 const SfxItemSet
& rAttrs
)
631 return( new SvxMeasurePage( pWindow
, rAttrs
) );
634 /*************************************************************************
638 \************************************************************************/
640 USHORT
* SvxMeasurePage::GetRanges()
645 /*************************************************************************
649 \************************************************************************/
651 void SvxMeasurePage::PointChanged( Window
* pWindow
, RECT_POINT
/*eRP*/ )
653 ChangeAttrHdl_Impl( pWindow
);
656 /*************************************************************************
660 \************************************************************************/
662 IMPL_LINK( SvxMeasurePage
, ClickAutoPosHdl_Impl
, void *, p
)
664 if( aTsbAutoPosH
.GetState() == STATE_CHECK
)
666 switch( aCtlPosition
.GetActualRP() )
670 aCtlPosition
.SetActualRP( RP_MT
);
675 aCtlPosition
.SetActualRP( RP_MM
);
680 aCtlPosition
.SetActualRP( RP_MB
);
682 default: ;//prevent warning
685 if( aTsbAutoPosV
.GetState() == STATE_CHECK
)
687 switch( aCtlPosition
.GetActualRP() )
691 aCtlPosition
.SetActualRP( RP_LM
);
696 aCtlPosition
.SetActualRP( RP_MM
);
701 aCtlPosition
.SetActualRP( RP_RM
);
703 default: ;//prevent warning
706 ChangeAttrHdl_Impl( p
);
711 /*************************************************************************
715 \************************************************************************/
717 IMPL_LINK( SvxMeasurePage
, ChangeAttrHdl_Impl
, void *, p
)
720 if( p
== &aMtrFldLineDist
)
722 INT32 nValue
= GetCoreValue( aMtrFldLineDist
, eUnit
);
723 aAttrSet
.Put( SdrMeasureLineDistItem( nValue
) );
726 if( p
== &aMtrFldHelplineOverhang
)
728 INT32 nValue
= GetCoreValue( aMtrFldHelplineOverhang
, eUnit
);
729 aAttrSet
.Put( SdrMeasureHelplineOverhangItem( nValue
) );
732 if( p
== &aMtrFldHelplineDist
)
734 INT32 nValue
= GetCoreValue( aMtrFldHelplineDist
, eUnit
);
735 aAttrSet
.Put( SdrMeasureHelplineDistItem( nValue
) );
738 if( p
== &aMtrFldHelpline1Len
)
740 INT32 nValue
= GetCoreValue( aMtrFldHelpline1Len
, eUnit
);
741 aAttrSet
.Put( SdrMeasureHelpline1LenItem( nValue
) );
744 if( p
== &aMtrFldHelpline2Len
)
746 INT32 nValue
= GetCoreValue( aMtrFldHelpline2Len
, eUnit
);
747 aAttrSet
.Put( SdrMeasureHelpline2LenItem( nValue
) );
750 if( p
== &aTsbBelowRefEdge
)
752 TriState eState
= aTsbBelowRefEdge
.GetState();
753 if( eState
!= STATE_DONTKNOW
)
754 aAttrSet
.Put( SdrMeasureBelowRefEdgeItem( (BOOL
) STATE_CHECK
== eState
) );
757 if( p
== &aMtrFldDecimalPlaces
)
759 INT16 nValue
= sal::static_int_cast
< INT16
>(
760 aMtrFldDecimalPlaces
.GetValue() );
761 aAttrSet
.Put( SdrMeasureDecimalPlacesItem( nValue
) );
764 if( p
== &aTsbParallel
)
766 TriState eState
= aTsbParallel
.GetState();
767 if( eState
!= STATE_DONTKNOW
)
768 aAttrSet
.Put( SdrMeasureTextRota90Item( (BOOL
) !STATE_CHECK
== eState
) );
771 if( p
== &aTsbShowUnit
)
773 TriState eState
= aTsbShowUnit
.GetState();
774 if( eState
!= STATE_DONTKNOW
)
775 aAttrSet
.Put( SdrMeasureShowUnitItem( (BOOL
) STATE_CHECK
== eState
) );
780 USHORT nPos
= aLbUnit
.GetSelectEntryPos();
781 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
783 USHORT nFieldUnit
= (USHORT
)(long)aLbUnit
.GetEntryData( nPos
);
784 FieldUnit _eUnit
= (FieldUnit
) nFieldUnit
;
785 aAttrSet
.Put( SdrMeasureUnitItem( _eUnit
) );
789 if( p
== &aTsbAutoPosV
|| p
== &aTsbAutoPosH
|| p
== &aCtlPosition
)
791 bPositionModified
= TRUE
;
794 RECT_POINT eRP
= aCtlPosition
.GetActualRP();
795 SdrMeasureTextVPos eVPos
;
796 SdrMeasureTextHPos eHPos
;
801 case RP_LT
: eVPos
= SDRMEASURE_ABOVE
;
802 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
803 case RP_LM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
804 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
805 case RP_LB
: eVPos
= SDRMEASURE_BELOW
;
806 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
807 case RP_MT
: eVPos
= SDRMEASURE_ABOVE
;
808 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
809 case RP_MM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
810 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
811 case RP_MB
: eVPos
= SDRMEASURE_BELOW
;
812 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
813 case RP_RT
: eVPos
= SDRMEASURE_ABOVE
;
814 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
815 case RP_RM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
816 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
817 case RP_RB
: eVPos
= SDRMEASURE_BELOW
;
818 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
821 CTL_STATE nState
= 0;
823 if( aTsbAutoPosH
.GetState() == STATE_CHECK
)
825 eHPos
= SDRMEASURE_TEXTHAUTO
;
829 if( aTsbAutoPosV
.GetState() == STATE_CHECK
)
831 eVPos
= SDRMEASURE_TEXTVAUTO
;
835 if( p
== &aTsbAutoPosV
|| p
== &aTsbAutoPosH
)
836 aCtlPosition
.SetState( nState
);
838 aAttrSet
.Put( SdrMeasureTextVPosItem( eVPos
) );
839 aAttrSet
.Put( SdrMeasureTextHPosItem( eHPos
) );
842 aCtlPreview
.SetAttributes( aAttrSet
);
843 aCtlPreview
.Invalidate();
848 /*************************************************************************
852 \************************************************************************/
854 void SvxMeasurePage::FillUnitLB()
856 // fill ListBox with metrics
857 SvxStringArray
aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE
);
859 long nUnit
= FUNIT_NONE
;
860 String
aStrMetric( SVX_RES( STR_MEASURE_AUTOMATIC
) );
861 USHORT nPos
= aLbUnit
.InsertEntry( aStrMetric
);
862 aLbUnit
.SetEntryData( nPos
, (void*)nUnit
);
864 for( USHORT i
= 0; i
< aMetricArr
.Count(); ++i
)
866 aStrMetric
= aMetricArr
.GetStringByPos( i
);
867 nUnit
= aMetricArr
.GetValue( i
);
868 nPos
= aLbUnit
.InsertEntry( aStrMetric
);
869 aLbUnit
.SetEntryData( nPos
, (void*)nUnit
);
872 void SvxMeasurePage::PageCreated (SfxAllItemSet aSet
) //add CHINA001
874 SFX_ITEMSET_ARG (&aSet
,pOfaPtrItem
,OfaPtrItem
,SID_OBJECT_LIST
,sal_False
);
877 SetView( static_cast<SdrView
*>(pOfaPtrItem
->GetValue()));