1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <sfx2/app.hxx>
33 #include <sfx2/module.hxx>
34 #include <tools/shl.hxx>
38 #define _SVX_MEASURE_CXX
40 #include <svx/svdomeas.hxx>
41 #include <svx/svdattr.hxx>
42 #include <svx/svdattrx.hxx>
43 #include <svx/svdview.hxx>
44 #include <svx/dialogs.hrc>
45 #include <svx/dialmgr.hxx>
46 #include "svx/measctrl.hxx"
47 #include "measure.hxx"
48 #include "measure.hrc"
49 #include <dialmgr.hxx>
50 #include "svx/dlgutil.hxx"
51 #include <svx/strarray.hxx>
52 #include <sfx2/request.hxx> //add CHINA001
53 #include "svx/ofaitem.hxx" //add CHINA001
55 static sal_uInt16 pRanges
[] =
57 SDRATTR_MEASURE_FIRST
,
62 /*************************************************************************
64 |* Dialog to change measure-attributes
66 \************************************************************************/
68 SvxMeasureDialog::SvxMeasureDialog( Window
* pParent
, const SfxItemSet
& rInAttrs
,
69 const SdrView
* pSdrView
) :
70 SfxSingleTabDialog( pParent
, rInAttrs
, RID_SVXPAGE_MEASURE
)
72 SvxMeasurePage
* _pPage
= new SvxMeasurePage( this, rInAttrs
);
74 _pPage
->SetView( pSdrView
);
78 SetText( _pPage
->GetText() );
81 /*************************************************************************
85 \************************************************************************/
87 SvxMeasureDialog::~SvxMeasureDialog()
91 /*************************************************************************
93 |* Tabpage for changing measure-attributes
95 \************************************************************************/
97 SvxMeasurePage::SvxMeasurePage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
98 SvxTabPage ( pWindow
, CUI_RES( RID_SVXPAGE_MEASURE
),
101 aFlLine ( this, CUI_RES( FL_LINE
) ),
102 aFtLineDist ( this, CUI_RES( FT_LINE_DIST
) ),
103 aMtrFldLineDist ( this, CUI_RES( MTR_LINE_DIST
) ),
104 aFtHelplineOverhang ( this, CUI_RES( FT_HELPLINE_OVERHANG
) ),
105 aMtrFldHelplineOverhang ( this, CUI_RES( MTR_FLD_HELPLINE_OVERHANG
) ),
106 aFtHelplineDist ( this, CUI_RES( FT_HELPLINE_DIST
) ),
107 aMtrFldHelplineDist ( this, CUI_RES( MTR_FLD_HELPLINE_DIST
) ),
108 aFtHelpline1Len ( this, CUI_RES( FT_HELPLINE1_LEN
) ),
109 aMtrFldHelpline1Len ( this, CUI_RES( MTR_FLD_HELPLINE1_LEN
) ),
110 aFtHelpline2Len ( this, CUI_RES( FT_HELPLINE2_LEN
) ),
111 aMtrFldHelpline2Len ( this, CUI_RES( MTR_FLD_HELPLINE2_LEN
) ),
112 aTsbBelowRefEdge ( this, CUI_RES( TSB_BELOW_REF_EDGE
) ),
113 aFtDecimalPlaces ( this, CUI_RES( FT_DECIMALPLACES
) ),
114 aMtrFldDecimalPlaces ( this, CUI_RES( MTR_FLD_DECIMALPLACES
) ),
116 aFlLabel ( this, CUI_RES( FL_LABEL
) ),
117 aFtPosition ( this, CUI_RES( FT_POSITION
) ),
118 aCtlPosition ( this, CUI_RES( CTL_POSITION
) ),
119 aTsbAutoPosV ( this, CUI_RES( TSB_AUTOPOSV
) ),
120 aTsbAutoPosH ( this, CUI_RES( TSB_AUTOPOSH
) ),
121 aTsbShowUnit ( this, CUI_RES( TSB_SHOW_UNIT
) ),
122 aLbUnit ( this, CUI_RES( LB_UNIT
) ),
123 aTsbParallel ( this, CUI_RES( TSB_PARALLEL
) ),
124 aCtlPreview ( this, CUI_RES( CTL_PREVIEW
), rInAttrs
),
126 aFlVert ( this, CUI_RES( FL_VERT
) ),
127 rOutAttrs ( rInAttrs
),
128 aAttrSet ( *rInAttrs
.GetPool() ),
131 bPositionModified ( sal_False
)
133 aCtlPreview
.SetAccessibleName(aCtlPreview
.GetHelpText());
138 const FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
139 SetFieldUnit( aMtrFldLineDist
, eFUnit
);
140 SetFieldUnit( aMtrFldHelplineOverhang
, eFUnit
);
141 SetFieldUnit( aMtrFldHelplineDist
, eFUnit
);
142 SetFieldUnit( aMtrFldHelpline1Len
, eFUnit
);
143 SetFieldUnit( aMtrFldHelpline2Len
, eFUnit
);
144 if( eFUnit
== FUNIT_MM
)
146 aMtrFldLineDist
.SetSpinSize( 50 );
147 aMtrFldHelplineOverhang
.SetSpinSize( 50 );
148 aMtrFldHelplineDist
.SetSpinSize( 50 );
149 aMtrFldHelpline1Len
.SetSpinSize( 50 );
150 aMtrFldHelpline2Len
.SetSpinSize( 50 );
153 aTsbAutoPosV
.SetClickHdl( LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
) );
154 aTsbAutoPosH
.SetClickHdl( LINK( this, SvxMeasurePage
, ClickAutoPosHdl_Impl
) );
156 // set background and border of iconchoicectrl
157 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
158 aCtlPreview
.SetBackground ( rStyles
.GetWindowColor() );
159 aCtlPreview
.SetBorderStyle(WINDOW_BORDER_MONO
);
161 Link
aLink( LINK( this, SvxMeasurePage
, ChangeAttrHdl_Impl
) );
162 aMtrFldLineDist
.SetModifyHdl( aLink
);
163 aMtrFldHelplineOverhang
.SetModifyHdl( aLink
);
164 aMtrFldHelplineDist
.SetModifyHdl( aLink
);
165 aMtrFldHelpline1Len
.SetModifyHdl( aLink
);
166 aMtrFldHelpline2Len
.SetModifyHdl( aLink
);
167 aMtrFldDecimalPlaces
.SetModifyHdl( aLink
);
168 aTsbBelowRefEdge
.SetClickHdl( aLink
);
169 aTsbParallel
.SetClickHdl( aLink
);
170 aTsbShowUnit
.SetClickHdl( aLink
);
171 aLbUnit
.SetSelectHdl( aLink
);
172 aLbUnit
.SetAccessibleName(GetNonMnemonicString(aTsbShowUnit
.GetText()));
173 aCtlPosition
.SetAccessibleRelationMemberOf( &aFlLabel
);
174 aLbUnit
.SetAccessibleRelationLabeledBy( &aTsbShowUnit
);
177 /*************************************************************************
181 \************************************************************************/
183 SvxMeasurePage::~SvxMeasurePage()
187 /*************************************************************************
189 |* read the delivered Item-Set
191 \************************************************************************/
193 void __EXPORT
SvxMeasurePage::Reset( const SfxItemSet
& rAttrs
)
195 SfxItemPool
* pPool
= rAttrs
.GetPool();
196 DBG_ASSERT( pPool
, "Wo ist der Pool" );
197 eUnit
= pPool
->GetMetric( SDRATTR_MEASURELINEDIST
);
199 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_MEASURELINEDIST
);
201 // SdrMeasureLineDistItem
203 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASURELINEDIST
);
206 long nValue
= ( ( const SdrMeasureLineDistItem
* )pItem
)->GetValue();
207 SetMetricValue( aMtrFldLineDist
, nValue
, eUnit
);
211 aMtrFldLineDist
.SetText( String() );
213 aMtrFldLineDist
.SaveValue();
215 // SdrMeasureHelplineOverhangItem
216 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINEOVERHANG
);
218 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG
);
221 long nValue
= ( ( const SdrMeasureHelplineOverhangItem
* )pItem
)->GetValue();
222 SetMetricValue( aMtrFldHelplineOverhang
, nValue
, eUnit
);
226 aMtrFldHelplineOverhang
.SetText( String() );
228 aMtrFldHelplineOverhang
.SaveValue();
230 // SdrMeasureHelplineDistItem
231 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINEDIST
);
233 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST
);
236 long nValue
= ( ( const SdrMeasureHelplineDistItem
* )pItem
)->GetValue();
237 SetMetricValue( aMtrFldHelplineDist
, nValue
, eUnit
);
241 aMtrFldHelplineDist
.SetText( String() );
243 aMtrFldHelplineDist
.SaveValue();
245 // SdrMeasureHelpline1LenItem
246 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINE1LEN
);
248 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN
);
251 long nValue
= ( ( const SdrMeasureHelpline1LenItem
* )pItem
)->GetValue();
252 SetMetricValue( aMtrFldHelpline1Len
, nValue
, eUnit
);
256 aMtrFldHelpline1Len
.SetText( String() );
258 aMtrFldHelpline1Len
.SaveValue();
260 // SdrMeasureHelpline2LenItem
261 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREHELPLINE2LEN
);
263 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN
);
266 long nValue
= ( ( const SdrMeasureHelpline2LenItem
* )pItem
)->GetValue();
267 SetMetricValue( aMtrFldHelpline2Len
, nValue
, eUnit
);
271 aMtrFldHelpline2Len
.SetText( String() );
273 aMtrFldHelpline2Len
.SaveValue();
275 // SdrMeasureBelowRefEdgeItem
276 if( rAttrs
.GetItemState( SDRATTR_MEASUREBELOWREFEDGE
) != SFX_ITEM_DONTCARE
)
278 aTsbBelowRefEdge
.SetState( ( ( const SdrMeasureBelowRefEdgeItem
& )rAttrs
.Get( SDRATTR_MEASUREBELOWREFEDGE
) ).
279 GetValue() ? STATE_CHECK
: STATE_NOCHECK
);
280 aTsbBelowRefEdge
.EnableTriState( sal_False
);
284 aTsbBelowRefEdge
.SetState( STATE_DONTKNOW
);
286 aTsbBelowRefEdge
.SaveValue();
288 // SdrMeasureDecimalPlacesItem
289 pItem
= GetItem( rAttrs
, SDRATTR_MEASUREDECIMALPLACES
);
291 pItem
= &pPool
->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES
);
294 sal_Int16 nValue
= ( ( const SdrMeasureDecimalPlacesItem
* )pItem
)->GetValue();
295 aMtrFldDecimalPlaces
.SetValue( nValue
);
299 aMtrFldDecimalPlaces
.SetText( String() );
301 aMtrFldDecimalPlaces
.SaveValue();
303 // SdrMeasureTextRota90Item
304 // Attention: negate !
305 if( rAttrs
.GetItemState( SDRATTR_MEASURETEXTROTA90
) != SFX_ITEM_DONTCARE
)
307 aTsbParallel
.SetState( ( ( const SdrMeasureTextRota90Item
& )rAttrs
.Get( SDRATTR_MEASURETEXTROTA90
) ).
308 GetValue() ? STATE_NOCHECK
: STATE_CHECK
);
309 aTsbParallel
.EnableTriState( sal_False
);
313 aTsbParallel
.SetState( STATE_DONTKNOW
);
315 aTsbParallel
.SaveValue();
317 // SdrMeasureShowUnitItem
318 if( rAttrs
.GetItemState( SDRATTR_MEASURESHOWUNIT
) != SFX_ITEM_DONTCARE
)
320 aTsbShowUnit
.SetState( ( ( const SdrMeasureShowUnitItem
& )rAttrs
.Get( SDRATTR_MEASURESHOWUNIT
) ).
321 GetValue() ? STATE_CHECK
: STATE_NOCHECK
);
322 aTsbShowUnit
.EnableTriState( sal_False
);
326 aTsbShowUnit
.SetState( STATE_DONTKNOW
);
328 aTsbShowUnit
.SaveValue();
330 // SdrMeasureUnitItem
331 if( rAttrs
.GetItemState( SDRATTR_MEASUREUNIT
) != SFX_ITEM_DONTCARE
)
333 long nFieldUnit
= (long) ( ( const SdrMeasureUnitItem
& )rAttrs
.
334 Get( SDRATTR_MEASUREUNIT
) ).GetValue();
336 for( sal_uInt16 i
= 0; i
< aLbUnit
.GetEntryCount(); ++i
)
338 if ( (long)aLbUnit
.GetEntryData( i
) == nFieldUnit
)
340 aLbUnit
.SelectEntryPos( i
);
347 aLbUnit
.SetNoSelection();
352 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTVPOS
) != SFX_ITEM_DONTCARE
)
354 SdrMeasureTextVPos eVPos
= (SdrMeasureTextVPos
)
355 ( ( const SdrMeasureTextVPosItem
& )rAttrs
.Get( SDRATTR_MEASURETEXTVPOS
) ).GetValue();
357 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTHPOS
) != SFX_ITEM_DONTCARE
)
359 aTsbAutoPosV
.EnableTriState( sal_False
);
360 aTsbAutoPosH
.EnableTriState( sal_False
);
362 SdrMeasureTextHPos eHPos
= (SdrMeasureTextHPos
)
363 ( ( const SdrMeasureTextHPosItem
& )rAttrs
.Get( SDRATTR_MEASURETEXTHPOS
) ).GetValue();
364 RECT_POINT eRP
= RP_MM
;
367 case SDRMEASURE_ABOVE
:
370 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LT
; break;
371 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MT
; break;
372 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RT
; break;
373 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MT
; break;
376 case SDRMEASURETEXT_VERTICALCENTERED
:
379 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LM
; break;
380 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MM
; break;
381 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RM
; break;
382 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MM
; break;
385 case SDRMEASURE_BELOW
:
388 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LB
; break;
389 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MB
; break;
390 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RB
; break;
391 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MB
; break;
394 case SDRMEASURE_TEXTVAUTO
:
397 case SDRMEASURE_TEXTLEFTOUTSIDE
: eRP
= RP_LM
; break;
398 case SDRMEASURE_TEXTINSIDE
: eRP
= RP_MM
; break;
399 case SDRMEASURE_TEXTRIGHTOUTSIDE
: eRP
= RP_RM
; break;
400 case SDRMEASURE_TEXTHAUTO
: eRP
= RP_MM
; break;
403 default: ;//prevent warning
406 CTL_STATE nState
= 0;
408 if( eHPos
== SDRMEASURE_TEXTHAUTO
)
410 aTsbAutoPosH
.SetState( STATE_CHECK
);
414 if( eVPos
== SDRMEASURE_TEXTVAUTO
)
416 aTsbAutoPosV
.SetState( STATE_CHECK
);
420 aCtlPosition
.SetState( nState
);
421 aCtlPosition
.SetActualRP( eRP
);
427 aCtlPosition
.Reset();
428 aTsbAutoPosV
.SetState( STATE_DONTKNOW
);
429 aTsbAutoPosH
.SetState( STATE_DONTKNOW
);
432 // put the attributes to the preview-control,
433 // otherwise the control don't know about
434 // the settings of the dialog (#67930)
435 ChangeAttrHdl_Impl( &aTsbShowUnit
);
436 aCtlPreview
.SetAttributes( rAttrs
);
438 bPositionModified
= sal_False
;
441 /*************************************************************************
443 |* Fill the delivered Item-Set with dialogbox-attributes
445 \************************************************************************/
447 sal_Bool
SvxMeasurePage::FillItemSet( SfxItemSet
& rAttrs
)
449 sal_Bool bModified
= sal_False
;
453 if( aMtrFldLineDist
.GetText() != aMtrFldLineDist
.GetSavedValue() )
455 nValue
= GetCoreValue( aMtrFldLineDist
, eUnit
);
456 rAttrs
.Put( SdrMeasureLineDistItem( nValue
) );
457 bModified
= sal_True
;
460 if( aMtrFldHelplineOverhang
.GetText() != aMtrFldHelplineOverhang
.GetSavedValue() )
462 nValue
= GetCoreValue( aMtrFldHelplineOverhang
, eUnit
);
463 rAttrs
.Put( SdrMeasureHelplineOverhangItem( nValue
) );
464 bModified
= sal_True
;
467 if( aMtrFldHelplineDist
.GetText() != aMtrFldHelplineDist
.GetSavedValue() )
469 nValue
= GetCoreValue( aMtrFldHelplineDist
, eUnit
);
470 rAttrs
.Put( SdrMeasureHelplineDistItem( nValue
) );
471 bModified
= sal_True
;
474 if( aMtrFldHelpline1Len
.GetText() != aMtrFldHelpline1Len
.GetSavedValue() )
476 nValue
= GetCoreValue( aMtrFldHelpline1Len
, eUnit
);
477 rAttrs
.Put( SdrMeasureHelpline1LenItem( nValue
) );
478 bModified
= sal_True
;
481 if( aMtrFldHelpline2Len
.GetText() != aMtrFldHelpline2Len
.GetSavedValue() )
483 nValue
= GetCoreValue( aMtrFldHelpline2Len
, eUnit
);
484 rAttrs
.Put( SdrMeasureHelpline2LenItem( nValue
) );
485 bModified
= sal_True
;
488 eState
= aTsbBelowRefEdge
.GetState();
489 if( eState
!= aTsbBelowRefEdge
.GetSavedValue() )
491 rAttrs
.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool
) STATE_CHECK
== eState
) );
492 bModified
= sal_True
;
495 if( aMtrFldDecimalPlaces
.GetText() != aMtrFldDecimalPlaces
.GetSavedValue() )
497 nValue
= static_cast<sal_Int32
>(aMtrFldDecimalPlaces
.GetValue());
499 SdrMeasureDecimalPlacesItem(
500 sal::static_int_cast
< sal_Int16
>( nValue
) ) );
501 bModified
= sal_True
;
504 eState
= aTsbParallel
.GetState();
505 if( eState
!= aTsbParallel
.GetSavedValue() )
507 rAttrs
.Put( SdrMeasureTextRota90Item( (sal_Bool
) STATE_NOCHECK
== eState
) );
508 bModified
= sal_True
;
511 eState
= aTsbShowUnit
.GetState();
512 if( eState
!= aTsbShowUnit
.GetSavedValue() )
514 rAttrs
.Put( SdrMeasureShowUnitItem( (sal_Bool
) STATE_CHECK
== eState
) );
515 bModified
= sal_True
;
518 sal_uInt16 nPos
= aLbUnit
.GetSelectEntryPos();
519 if( nPos
!= aLbUnit
.GetSavedValue() )
521 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
523 sal_uInt16 nFieldUnit
= (sal_uInt16
)(long)aLbUnit
.GetEntryData( nPos
);
524 FieldUnit _eUnit
= (FieldUnit
) nFieldUnit
;
525 rAttrs
.Put( SdrMeasureUnitItem( _eUnit
) );
526 bModified
= sal_True
;
530 //enum SdrMeasureTextHPos {SDRMEASURE_TEXTHAUTO,SDRMEASURE_TEXTLEFTOUTSIDE,SDRMEASURE_TEXTINSIDE,SDRMEASURE_TEXTRIGHTOUTSIDE};
531 //enum SdrMeasureTextVPos {SDRMEASURE_TEXTVAUTO,SDRMEASURE_ABOVE,SDRMEASURETEXT_VERTICALCENTERED,SDRMEASURE_BELOW};
533 if( bPositionModified
)
536 SdrMeasureTextVPos eVPos
, eOldVPos
;
537 SdrMeasureTextHPos eHPos
, eOldHPos
;
539 RECT_POINT eRP
= aCtlPosition
.GetActualRP();
543 case RP_LT
: eVPos
= SDRMEASURE_ABOVE
;
544 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
545 case RP_LM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
546 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
547 case RP_LB
: eVPos
= SDRMEASURE_BELOW
;
548 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
549 case RP_MT
: eVPos
= SDRMEASURE_ABOVE
;
550 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
551 case RP_MM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
552 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
553 case RP_MB
: eVPos
= SDRMEASURE_BELOW
;
554 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
555 case RP_RT
: eVPos
= SDRMEASURE_ABOVE
;
556 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
557 case RP_RM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
558 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
559 case RP_RB
: eVPos
= SDRMEASURE_BELOW
;
560 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
562 if( aTsbAutoPosH
.GetState() == STATE_CHECK
)
563 eHPos
= SDRMEASURE_TEXTHAUTO
;
565 if( aTsbAutoPosV
.GetState() == STATE_CHECK
)
566 eVPos
= SDRMEASURE_TEXTVAUTO
;
568 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTVPOS
) != SFX_ITEM_DONTCARE
)
570 eOldVPos
= (SdrMeasureTextVPos
)
571 ( ( const SdrMeasureTextVPosItem
& )rOutAttrs
.Get( SDRATTR_MEASURETEXTVPOS
) ).GetValue();
572 if( eOldVPos
!= eVPos
)
574 rAttrs
.Put( SdrMeasureTextVPosItem( eVPos
) );
575 bModified
= sal_True
;
580 rAttrs
.Put( SdrMeasureTextVPosItem( eVPos
) );
581 bModified
= sal_True
;
584 if ( rAttrs
.GetItemState( SDRATTR_MEASURETEXTHPOS
) != SFX_ITEM_DONTCARE
)
586 eOldHPos
= (SdrMeasureTextHPos
)
587 ( ( const SdrMeasureTextHPosItem
& )rOutAttrs
.Get( SDRATTR_MEASURETEXTHPOS
) ).GetValue();
588 if( eOldHPos
!= eHPos
)
590 rAttrs
.Put( SdrMeasureTextHPosItem( eHPos
) );
591 bModified
= sal_True
;
596 rAttrs
.Put( SdrMeasureTextHPosItem( eHPos
) );
597 bModified
= sal_True
;
604 /*************************************************************************
606 |* The View have to set at the measure-object to be able to notify
607 |* unit and floatingpoint-values
609 \************************************************************************/
611 void SvxMeasurePage::Construct()
613 DBG_ASSERT( pView
, "Keine gueltige View Uebergeben!" );
615 aCtlPreview
.pMeasureObj
->SetModel( pView
->GetModel() );
616 aCtlPreview
.Invalidate();
619 /*************************************************************************
621 |* create the tabpage
623 \************************************************************************/
625 SfxTabPage
* SvxMeasurePage::Create( Window
* pWindow
,
626 const SfxItemSet
& rAttrs
)
628 return( new SvxMeasurePage( pWindow
, rAttrs
) );
631 /*************************************************************************
635 \************************************************************************/
637 sal_uInt16
* SvxMeasurePage::GetRanges()
642 /*************************************************************************
646 \************************************************************************/
648 void SvxMeasurePage::PointChanged( Window
* pWindow
, RECT_POINT
/*eRP*/ )
650 ChangeAttrHdl_Impl( pWindow
);
653 /*************************************************************************
657 \************************************************************************/
659 IMPL_LINK( SvxMeasurePage
, ClickAutoPosHdl_Impl
, void *, p
)
661 if( aTsbAutoPosH
.GetState() == STATE_CHECK
)
663 switch( aCtlPosition
.GetActualRP() )
667 aCtlPosition
.SetActualRP( RP_MT
);
672 aCtlPosition
.SetActualRP( RP_MM
);
677 aCtlPosition
.SetActualRP( RP_MB
);
679 default: ;//prevent warning
682 if( aTsbAutoPosV
.GetState() == STATE_CHECK
)
684 switch( aCtlPosition
.GetActualRP() )
688 aCtlPosition
.SetActualRP( RP_LM
);
693 aCtlPosition
.SetActualRP( RP_MM
);
698 aCtlPosition
.SetActualRP( RP_RM
);
700 default: ;//prevent warning
703 ChangeAttrHdl_Impl( p
);
708 /*************************************************************************
712 \************************************************************************/
714 IMPL_LINK( SvxMeasurePage
, ChangeAttrHdl_Impl
, void *, p
)
717 if( p
== &aMtrFldLineDist
)
719 sal_Int32 nValue
= GetCoreValue( aMtrFldLineDist
, eUnit
);
720 aAttrSet
.Put( SdrMeasureLineDistItem( nValue
) );
723 if( p
== &aMtrFldHelplineOverhang
)
725 sal_Int32 nValue
= GetCoreValue( aMtrFldHelplineOverhang
, eUnit
);
726 aAttrSet
.Put( SdrMeasureHelplineOverhangItem( nValue
) );
729 if( p
== &aMtrFldHelplineDist
)
731 sal_Int32 nValue
= GetCoreValue( aMtrFldHelplineDist
, eUnit
);
732 aAttrSet
.Put( SdrMeasureHelplineDistItem( nValue
) );
735 if( p
== &aMtrFldHelpline1Len
)
737 sal_Int32 nValue
= GetCoreValue( aMtrFldHelpline1Len
, eUnit
);
738 aAttrSet
.Put( SdrMeasureHelpline1LenItem( nValue
) );
741 if( p
== &aMtrFldHelpline2Len
)
743 sal_Int32 nValue
= GetCoreValue( aMtrFldHelpline2Len
, eUnit
);
744 aAttrSet
.Put( SdrMeasureHelpline2LenItem( nValue
) );
747 if( p
== &aTsbBelowRefEdge
)
749 TriState eState
= aTsbBelowRefEdge
.GetState();
750 if( eState
!= STATE_DONTKNOW
)
751 aAttrSet
.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool
) STATE_CHECK
== eState
) );
754 if( p
== &aMtrFldDecimalPlaces
)
756 sal_Int16 nValue
= sal::static_int_cast
< sal_Int16
>(
757 aMtrFldDecimalPlaces
.GetValue() );
758 aAttrSet
.Put( SdrMeasureDecimalPlacesItem( nValue
) );
761 if( p
== &aTsbParallel
)
763 TriState eState
= aTsbParallel
.GetState();
764 if( eState
!= STATE_DONTKNOW
)
765 aAttrSet
.Put( SdrMeasureTextRota90Item( (sal_Bool
) !STATE_CHECK
== eState
) );
768 if( p
== &aTsbShowUnit
)
770 TriState eState
= aTsbShowUnit
.GetState();
771 if( eState
!= STATE_DONTKNOW
)
772 aAttrSet
.Put( SdrMeasureShowUnitItem( (sal_Bool
) STATE_CHECK
== eState
) );
777 sal_uInt16 nPos
= aLbUnit
.GetSelectEntryPos();
778 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
780 sal_uInt16 nFieldUnit
= (sal_uInt16
)(long)aLbUnit
.GetEntryData( nPos
);
781 FieldUnit _eUnit
= (FieldUnit
) nFieldUnit
;
782 aAttrSet
.Put( SdrMeasureUnitItem( _eUnit
) );
786 if( p
== &aTsbAutoPosV
|| p
== &aTsbAutoPosH
|| p
== &aCtlPosition
)
788 bPositionModified
= sal_True
;
791 RECT_POINT eRP
= aCtlPosition
.GetActualRP();
792 SdrMeasureTextVPos eVPos
;
793 SdrMeasureTextHPos eHPos
;
798 case RP_LT
: eVPos
= SDRMEASURE_ABOVE
;
799 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
800 case RP_LM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
801 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
802 case RP_LB
: eVPos
= SDRMEASURE_BELOW
;
803 eHPos
= SDRMEASURE_TEXTLEFTOUTSIDE
; break;
804 case RP_MT
: eVPos
= SDRMEASURE_ABOVE
;
805 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
806 case RP_MM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
807 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
808 case RP_MB
: eVPos
= SDRMEASURE_BELOW
;
809 eHPos
= SDRMEASURE_TEXTINSIDE
; break;
810 case RP_RT
: eVPos
= SDRMEASURE_ABOVE
;
811 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
812 case RP_RM
: eVPos
= SDRMEASURETEXT_VERTICALCENTERED
;
813 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
814 case RP_RB
: eVPos
= SDRMEASURE_BELOW
;
815 eHPos
= SDRMEASURE_TEXTRIGHTOUTSIDE
; break;
818 CTL_STATE nState
= 0;
820 if( aTsbAutoPosH
.GetState() == STATE_CHECK
)
822 eHPos
= SDRMEASURE_TEXTHAUTO
;
826 if( aTsbAutoPosV
.GetState() == STATE_CHECK
)
828 eVPos
= SDRMEASURE_TEXTVAUTO
;
832 if( p
== &aTsbAutoPosV
|| p
== &aTsbAutoPosH
)
833 aCtlPosition
.SetState( nState
);
835 aAttrSet
.Put( SdrMeasureTextVPosItem( eVPos
) );
836 aAttrSet
.Put( SdrMeasureTextHPosItem( eHPos
) );
839 aCtlPreview
.SetAttributes( aAttrSet
);
840 aCtlPreview
.Invalidate();
845 /*************************************************************************
849 \************************************************************************/
851 void SvxMeasurePage::FillUnitLB()
853 // fill ListBox with metrics
854 SvxStringArray
aMetricArr( SVX_RES( RID_SVXSTR_FIELDUNIT_TABLE
) );
856 long nUnit
= FUNIT_NONE
;
857 String
aStrMetric( CUI_RES( STR_MEASURE_AUTOMATIC
) );
858 sal_uInt16 nPos
= aLbUnit
.InsertEntry( aStrMetric
);
859 aLbUnit
.SetEntryData( nPos
, (void*)nUnit
);
861 for( sal_uInt16 i
= 0; i
< aMetricArr
.Count(); ++i
)
863 aStrMetric
= aMetricArr
.GetStringByPos( i
);
864 nUnit
= aMetricArr
.GetValue( i
);
865 nPos
= aLbUnit
.InsertEntry( aStrMetric
);
866 aLbUnit
.SetEntryData( nPos
, (void*)nUnit
);
869 void SvxMeasurePage::PageCreated (SfxAllItemSet aSet
) //add CHINA001
871 SFX_ITEMSET_ARG (&aSet
,pOfaPtrItem
,OfaPtrItem
,SID_OBJECT_LIST
,sal_False
);
874 SetView( static_cast<SdrView
*>(pOfaPtrItem
->GetValue()));