xref: /aoo41x/main/cui/source/tabpages/measure.cxx (revision 2ee96f1c)
1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2ee96f1cSAndrew Rist  * distributed with this work for additional information
6*2ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2ee96f1cSAndrew Rist  *
11*2ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2ee96f1cSAndrew Rist  *
13*2ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2ee96f1cSAndrew Rist  * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist  * under the License.
19*2ee96f1cSAndrew Rist  *
20*2ee96f1cSAndrew Rist  *************************************************************/
21*2ee96f1cSAndrew Rist 
22*2ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <sfx2/app.hxx>
29cdf0e10cSrcweir #include <sfx2/module.hxx>
30cdf0e10cSrcweir #include <tools/shl.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <cuires.hrc>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #define _SVX_MEASURE_CXX
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <svx/svdomeas.hxx>
37cdf0e10cSrcweir #include <svx/svdattr.hxx>
38cdf0e10cSrcweir #include <svx/svdattrx.hxx>
39cdf0e10cSrcweir #include <svx/svdview.hxx>
40cdf0e10cSrcweir #include <svx/dialogs.hrc>
41cdf0e10cSrcweir #include <svx/dialmgr.hxx>
42cdf0e10cSrcweir #include "svx/measctrl.hxx"
43cdf0e10cSrcweir #include "measure.hxx"
44cdf0e10cSrcweir #include "measure.hrc"
45cdf0e10cSrcweir #include <dialmgr.hxx>
46cdf0e10cSrcweir #include "svx/dlgutil.hxx"
47cdf0e10cSrcweir #include <svx/strarray.hxx>
48cdf0e10cSrcweir #include <sfx2/request.hxx> //add CHINA001
49cdf0e10cSrcweir #include "svx/ofaitem.hxx" //add CHINA001
50cdf0e10cSrcweir 
51cdf0e10cSrcweir static sal_uInt16 pRanges[] =
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	SDRATTR_MEASURE_FIRST,
54cdf0e10cSrcweir 	SDRATTR_MEASURE_LAST,
55cdf0e10cSrcweir 	0
56cdf0e10cSrcweir };
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /*************************************************************************
59cdf0e10cSrcweir |*
60cdf0e10cSrcweir |* Dialog to change measure-attributes
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir \************************************************************************/
63cdf0e10cSrcweir 
SvxMeasureDialog(Window * pParent,const SfxItemSet & rInAttrs,const SdrView * pSdrView)64cdf0e10cSrcweir SvxMeasureDialog::SvxMeasureDialog( Window* pParent, const SfxItemSet& rInAttrs,
65cdf0e10cSrcweir 								const SdrView* pSdrView ) :
66cdf0e10cSrcweir 		SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_MEASURE )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir     SvxMeasurePage* _pPage = new SvxMeasurePage( this, rInAttrs );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     _pPage->SetView( pSdrView );
71cdf0e10cSrcweir     _pPage->Construct();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     SetTabPage( _pPage );
74cdf0e10cSrcweir     SetText( _pPage->GetText() );
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir /*************************************************************************
78cdf0e10cSrcweir |*
79cdf0e10cSrcweir |* Dtor
80cdf0e10cSrcweir |*
81cdf0e10cSrcweir \************************************************************************/
82cdf0e10cSrcweir 
~SvxMeasureDialog()83cdf0e10cSrcweir SvxMeasureDialog::~SvxMeasureDialog()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir /*************************************************************************
88cdf0e10cSrcweir |*
89cdf0e10cSrcweir |* Tabpage for changing measure-attributes
90cdf0e10cSrcweir |*
91cdf0e10cSrcweir \************************************************************************/
92cdf0e10cSrcweir 
SvxMeasurePage(Window * pWindow,const SfxItemSet & rInAttrs)93cdf0e10cSrcweir SvxMeasurePage::SvxMeasurePage( Window* pWindow, const SfxItemSet& rInAttrs ) :
94cdf0e10cSrcweir 				SvxTabPage		( pWindow, CUI_RES( RID_SVXPAGE_MEASURE ),
95cdf0e10cSrcweir 								  rInAttrs ),
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         aFlLine                 ( this, CUI_RES( FL_LINE ) ),
98cdf0e10cSrcweir 		aFtLineDist				( this, CUI_RES( FT_LINE_DIST ) ),
99cdf0e10cSrcweir 		aMtrFldLineDist			( this, CUI_RES( MTR_LINE_DIST ) ),
100cdf0e10cSrcweir 		aFtHelplineOverhang		( this, CUI_RES( FT_HELPLINE_OVERHANG ) ),
101cdf0e10cSrcweir 		aMtrFldHelplineOverhang	( this, CUI_RES( MTR_FLD_HELPLINE_OVERHANG ) ),
102cdf0e10cSrcweir 		aFtHelplineDist			( this, CUI_RES( FT_HELPLINE_DIST ) ),
103cdf0e10cSrcweir 		aMtrFldHelplineDist		( this, CUI_RES( MTR_FLD_HELPLINE_DIST ) ),
104cdf0e10cSrcweir 		aFtHelpline1Len			( this, CUI_RES( FT_HELPLINE1_LEN ) ),
105cdf0e10cSrcweir 		aMtrFldHelpline1Len		( this, CUI_RES( MTR_FLD_HELPLINE1_LEN ) ),
106cdf0e10cSrcweir 		aFtHelpline2Len			( this, CUI_RES( FT_HELPLINE2_LEN ) ),
107cdf0e10cSrcweir 		aMtrFldHelpline2Len		( this, CUI_RES( MTR_FLD_HELPLINE2_LEN ) ),
108cdf0e10cSrcweir 		aTsbBelowRefEdge		( this, CUI_RES( TSB_BELOW_REF_EDGE ) ),
109cdf0e10cSrcweir 		aFtDecimalPlaces		( this, CUI_RES( FT_DECIMALPLACES ) ),
110cdf0e10cSrcweir 		aMtrFldDecimalPlaces	( this, CUI_RES( MTR_FLD_DECIMALPLACES ) ),
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 		aFlLabel    			( this, CUI_RES( FL_LABEL ) ),
113cdf0e10cSrcweir         aFtPosition             ( this, CUI_RES( FT_POSITION ) ),
114cdf0e10cSrcweir         aCtlPosition            ( this, CUI_RES( CTL_POSITION ) ),
115cdf0e10cSrcweir         aTsbAutoPosV            ( this, CUI_RES( TSB_AUTOPOSV ) ),
116cdf0e10cSrcweir         aTsbAutoPosH            ( this, CUI_RES( TSB_AUTOPOSH ) ),
117cdf0e10cSrcweir         aTsbShowUnit            ( this, CUI_RES( TSB_SHOW_UNIT ) ),
118cdf0e10cSrcweir         aLbUnit                 ( this, CUI_RES( LB_UNIT ) ),
119cdf0e10cSrcweir         aTsbParallel            ( this, CUI_RES( TSB_PARALLEL ) ),
120cdf0e10cSrcweir         aCtlPreview             ( this, CUI_RES( CTL_PREVIEW ), rInAttrs ),
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         aFlVert                 ( this, CUI_RES( FL_VERT ) ),
123cdf0e10cSrcweir         rOutAttrs               ( rInAttrs ),
124cdf0e10cSrcweir         aAttrSet                ( *rInAttrs.GetPool() ),
125cdf0e10cSrcweir         pView( 0 ),
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         bPositionModified       ( sal_False )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	aCtlPreview.SetAccessibleName(aCtlPreview.GetHelpText());
130cdf0e10cSrcweir 	FillUnitLB();
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	FreeResource();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
135cdf0e10cSrcweir 	SetFieldUnit( aMtrFldLineDist, eFUnit );
136cdf0e10cSrcweir 	SetFieldUnit( aMtrFldHelplineOverhang, eFUnit );
137cdf0e10cSrcweir 	SetFieldUnit( aMtrFldHelplineDist, eFUnit );
138cdf0e10cSrcweir 	SetFieldUnit( aMtrFldHelpline1Len, eFUnit );
139cdf0e10cSrcweir 	SetFieldUnit( aMtrFldHelpline2Len, eFUnit );
140cdf0e10cSrcweir 	if( eFUnit == FUNIT_MM )
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 		aMtrFldLineDist.SetSpinSize( 50 );
143cdf0e10cSrcweir 		aMtrFldHelplineOverhang.SetSpinSize( 50 );
144cdf0e10cSrcweir 		aMtrFldHelplineDist.SetSpinSize( 50 );
145cdf0e10cSrcweir 		aMtrFldHelpline1Len.SetSpinSize( 50 );
146cdf0e10cSrcweir 		aMtrFldHelpline2Len.SetSpinSize( 50 );
147cdf0e10cSrcweir 	}
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	aTsbAutoPosV.SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
150cdf0e10cSrcweir 	aTsbAutoPosH.SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	// set background and border of iconchoicectrl
153cdf0e10cSrcweir 	const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
154cdf0e10cSrcweir 	aCtlPreview.SetBackground ( rStyles.GetWindowColor() );
155cdf0e10cSrcweir 	aCtlPreview.SetBorderStyle(WINDOW_BORDER_MONO);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	Link aLink( LINK( this, SvxMeasurePage, ChangeAttrHdl_Impl ) );
158cdf0e10cSrcweir 	aMtrFldLineDist.SetModifyHdl( aLink );
159cdf0e10cSrcweir 	aMtrFldHelplineOverhang.SetModifyHdl( aLink );
160cdf0e10cSrcweir 	aMtrFldHelplineDist.SetModifyHdl( aLink );
161cdf0e10cSrcweir 	aMtrFldHelpline1Len.SetModifyHdl( aLink );
162cdf0e10cSrcweir 	aMtrFldHelpline2Len.SetModifyHdl( aLink );
163cdf0e10cSrcweir 	aMtrFldDecimalPlaces.SetModifyHdl( aLink );
164cdf0e10cSrcweir 	aTsbBelowRefEdge.SetClickHdl( aLink );
165cdf0e10cSrcweir 	aTsbParallel.SetClickHdl( aLink );
166cdf0e10cSrcweir 	aTsbShowUnit.SetClickHdl( aLink );
167cdf0e10cSrcweir 	aLbUnit.SetSelectHdl( aLink );
168cdf0e10cSrcweir 	aLbUnit.SetAccessibleName(GetNonMnemonicString(aTsbShowUnit.GetText()));
169cdf0e10cSrcweir 	aCtlPosition.SetAccessibleRelationMemberOf( &aFlLabel );
170cdf0e10cSrcweir 	aLbUnit.SetAccessibleRelationLabeledBy( &aTsbShowUnit );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /*************************************************************************
174cdf0e10cSrcweir |*
175cdf0e10cSrcweir |* Dtor
176cdf0e10cSrcweir |*
177cdf0e10cSrcweir \************************************************************************/
178cdf0e10cSrcweir 
~SvxMeasurePage()179cdf0e10cSrcweir SvxMeasurePage::~SvxMeasurePage()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir /*************************************************************************
184cdf0e10cSrcweir |*
185cdf0e10cSrcweir |* read the delivered Item-Set
186cdf0e10cSrcweir |*
187cdf0e10cSrcweir \************************************************************************/
188cdf0e10cSrcweir 
Reset(const SfxItemSet & rAttrs)189cdf0e10cSrcweir void __EXPORT SvxMeasurePage::Reset( const SfxItemSet& rAttrs )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	SfxItemPool* pPool = rAttrs.GetPool();
192cdf0e10cSrcweir 	DBG_ASSERT( pPool, "Wo ist der Pool" );
193cdf0e10cSrcweir 	eUnit = pPool->GetMetric( SDRATTR_MEASURELINEDIST );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_MEASURELINEDIST );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	// SdrMeasureLineDistItem
198cdf0e10cSrcweir     if( pItem == NULL )
199cdf0e10cSrcweir         pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
200cdf0e10cSrcweir 	if( pItem )
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		long nValue = ( ( const SdrMeasureLineDistItem* )pItem )->GetValue();
203cdf0e10cSrcweir 		SetMetricValue( aMtrFldLineDist, nValue, eUnit );
204cdf0e10cSrcweir 	}
205cdf0e10cSrcweir 	else
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir 		aMtrFldLineDist.SetText( String() );
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir 	aMtrFldLineDist.SaveValue();
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	// SdrMeasureHelplineOverhangItem
212cdf0e10cSrcweir 	pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
213cdf0e10cSrcweir     if( pItem == NULL )
214cdf0e10cSrcweir         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG );
215cdf0e10cSrcweir 	if( pItem )
216cdf0e10cSrcweir 	{
217cdf0e10cSrcweir 		long nValue = ( ( const SdrMeasureHelplineOverhangItem* )pItem )->GetValue();
218cdf0e10cSrcweir 		SetMetricValue( aMtrFldHelplineOverhang, nValue, eUnit );
219cdf0e10cSrcweir 	}
220cdf0e10cSrcweir 	else
221cdf0e10cSrcweir 	{
222cdf0e10cSrcweir 		aMtrFldHelplineOverhang.SetText( String() );
223cdf0e10cSrcweir 	}
224cdf0e10cSrcweir 	aMtrFldHelplineOverhang.SaveValue();
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	// SdrMeasureHelplineDistItem
227cdf0e10cSrcweir 	pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINEDIST );
228cdf0e10cSrcweir     if( pItem == NULL )
229cdf0e10cSrcweir         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
230cdf0e10cSrcweir 	if( pItem )
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir 		long nValue = ( ( const SdrMeasureHelplineDistItem* )pItem )->GetValue();
233cdf0e10cSrcweir 		SetMetricValue( aMtrFldHelplineDist, nValue, eUnit );
234cdf0e10cSrcweir 	}
235cdf0e10cSrcweir 	else
236cdf0e10cSrcweir 	{
237cdf0e10cSrcweir 		aMtrFldHelplineDist.SetText( String() );
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir 	aMtrFldHelplineDist.SaveValue();
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	// SdrMeasureHelpline1LenItem
242cdf0e10cSrcweir 	pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
243cdf0e10cSrcweir     if( pItem == NULL )
244cdf0e10cSrcweir         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
245cdf0e10cSrcweir 	if( pItem )
246cdf0e10cSrcweir 	{
247cdf0e10cSrcweir 		long nValue = ( ( const SdrMeasureHelpline1LenItem* )pItem )->GetValue();
248cdf0e10cSrcweir 		SetMetricValue( aMtrFldHelpline1Len, nValue, eUnit );
249cdf0e10cSrcweir 	}
250cdf0e10cSrcweir 	else
251cdf0e10cSrcweir 	{
252cdf0e10cSrcweir 		aMtrFldHelpline1Len.SetText( String() );
253cdf0e10cSrcweir 	}
254cdf0e10cSrcweir 	aMtrFldHelpline1Len.SaveValue();
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	// SdrMeasureHelpline2LenItem
257cdf0e10cSrcweir 	pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
258cdf0e10cSrcweir     if( pItem == NULL )
259cdf0e10cSrcweir         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
260cdf0e10cSrcweir 	if( pItem )
261cdf0e10cSrcweir 	{
262cdf0e10cSrcweir 		long nValue = ( ( const SdrMeasureHelpline2LenItem* )pItem )->GetValue();
263cdf0e10cSrcweir 		SetMetricValue( aMtrFldHelpline2Len, nValue, eUnit );
264cdf0e10cSrcweir 	}
265cdf0e10cSrcweir 	else
266cdf0e10cSrcweir 	{
267cdf0e10cSrcweir 		aMtrFldHelpline2Len.SetText( String() );
268cdf0e10cSrcweir 	}
269cdf0e10cSrcweir 	aMtrFldHelpline2Len.SaveValue();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	// SdrMeasureBelowRefEdgeItem
272cdf0e10cSrcweir 	if( rAttrs.GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SFX_ITEM_DONTCARE )
273cdf0e10cSrcweir 	{
274cdf0e10cSrcweir 		aTsbBelowRefEdge.SetState( ( ( const SdrMeasureBelowRefEdgeItem& )rAttrs.Get( SDRATTR_MEASUREBELOWREFEDGE ) ).
275cdf0e10cSrcweir 						GetValue() ? STATE_CHECK : STATE_NOCHECK );
276cdf0e10cSrcweir 		aTsbBelowRefEdge.EnableTriState( sal_False );
277cdf0e10cSrcweir 	}
278cdf0e10cSrcweir 	else
279cdf0e10cSrcweir 	{
280cdf0e10cSrcweir 		aTsbBelowRefEdge.SetState( STATE_DONTKNOW );
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir 	aTsbBelowRefEdge.SaveValue();
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 	// SdrMeasureDecimalPlacesItem
285cdf0e10cSrcweir 	pItem = GetItem( rAttrs, SDRATTR_MEASUREDECIMALPLACES );
286cdf0e10cSrcweir     if( pItem == NULL )
287cdf0e10cSrcweir         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
288cdf0e10cSrcweir 	if( pItem )
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		sal_Int16 nValue = ( ( const SdrMeasureDecimalPlacesItem* )pItem )->GetValue();
291cdf0e10cSrcweir 		aMtrFldDecimalPlaces.SetValue( nValue );
292cdf0e10cSrcweir 	}
293cdf0e10cSrcweir 	else
294cdf0e10cSrcweir 	{
295cdf0e10cSrcweir 		aMtrFldDecimalPlaces.SetText( String() );
296cdf0e10cSrcweir 	}
297cdf0e10cSrcweir 	aMtrFldDecimalPlaces.SaveValue();
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	// SdrMeasureTextRota90Item
300cdf0e10cSrcweir 	// Attention: negate !
301cdf0e10cSrcweir 	if( rAttrs.GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SFX_ITEM_DONTCARE )
302cdf0e10cSrcweir 	{
303cdf0e10cSrcweir 		aTsbParallel.SetState( ( ( const SdrMeasureTextRota90Item& )rAttrs.Get( SDRATTR_MEASURETEXTROTA90 ) ).
304cdf0e10cSrcweir 						GetValue() ? STATE_NOCHECK : STATE_CHECK );
305cdf0e10cSrcweir 		aTsbParallel.EnableTriState( sal_False );
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir 	else
308cdf0e10cSrcweir 	{
309cdf0e10cSrcweir 		aTsbParallel.SetState( STATE_DONTKNOW );
310cdf0e10cSrcweir 	}
311cdf0e10cSrcweir 	aTsbParallel.SaveValue();
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	// SdrMeasureShowUnitItem
314cdf0e10cSrcweir 	if( rAttrs.GetItemState( SDRATTR_MEASURESHOWUNIT ) != SFX_ITEM_DONTCARE )
315cdf0e10cSrcweir 	{
316cdf0e10cSrcweir 		aTsbShowUnit.SetState( ( ( const SdrMeasureShowUnitItem& )rAttrs.Get( SDRATTR_MEASURESHOWUNIT ) ).
317cdf0e10cSrcweir 						GetValue() ? STATE_CHECK : STATE_NOCHECK );
318cdf0e10cSrcweir 		aTsbShowUnit.EnableTriState( sal_False );
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 	else
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		aTsbShowUnit.SetState( STATE_DONTKNOW );
323cdf0e10cSrcweir 	}
324cdf0e10cSrcweir 	aTsbShowUnit.SaveValue();
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	// SdrMeasureUnitItem
327cdf0e10cSrcweir 	if( rAttrs.GetItemState( SDRATTR_MEASUREUNIT ) != SFX_ITEM_DONTCARE )
328cdf0e10cSrcweir 	{
329cdf0e10cSrcweir 		long nFieldUnit = (long) ( ( const SdrMeasureUnitItem& )rAttrs.
330cdf0e10cSrcweir 									Get( SDRATTR_MEASUREUNIT ) ).GetValue();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < aLbUnit.GetEntryCount(); ++i )
333cdf0e10cSrcweir 		{
334cdf0e10cSrcweir 			if ( (long)aLbUnit.GetEntryData( i ) == nFieldUnit )
335cdf0e10cSrcweir 			{
336cdf0e10cSrcweir 				aLbUnit.SelectEntryPos( i );
337cdf0e10cSrcweir 				break;
338cdf0e10cSrcweir 			}
339cdf0e10cSrcweir 		}
340cdf0e10cSrcweir 	}
341cdf0e10cSrcweir 	else
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		aLbUnit.SetNoSelection();
344cdf0e10cSrcweir 	}
345cdf0e10cSrcweir 	aLbUnit.SaveValue();
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	// Position
348cdf0e10cSrcweir 	if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTVPOS ) != SFX_ITEM_DONTCARE )
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		SdrMeasureTextVPos eVPos = (SdrMeasureTextVPos)
351cdf0e10cSrcweir 					( ( const SdrMeasureTextVPosItem& )rAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
352cdf0e10cSrcweir 		{
353cdf0e10cSrcweir 			if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTHPOS ) != SFX_ITEM_DONTCARE )
354cdf0e10cSrcweir 			{
355cdf0e10cSrcweir 				aTsbAutoPosV.EnableTriState( sal_False );
356cdf0e10cSrcweir 				aTsbAutoPosH.EnableTriState( sal_False );
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 				SdrMeasureTextHPos eHPos = (SdrMeasureTextHPos)
359cdf0e10cSrcweir 							( ( const SdrMeasureTextHPosItem& )rAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
360cdf0e10cSrcweir 				RECT_POINT eRP = RP_MM;
361cdf0e10cSrcweir 				switch( eVPos )
362cdf0e10cSrcweir 				{
363cdf0e10cSrcweir 				case SDRMEASURE_ABOVE:
364cdf0e10cSrcweir 					switch( eHPos )
365cdf0e10cSrcweir 					{
366cdf0e10cSrcweir 					case SDRMEASURE_TEXTLEFTOUTSIDE:	eRP = RP_LT; break;
367cdf0e10cSrcweir 					case SDRMEASURE_TEXTINSIDE:			eRP = RP_MT; break;
368cdf0e10cSrcweir 					case SDRMEASURE_TEXTRIGHTOUTSIDE:	eRP = RP_RT; break;
369cdf0e10cSrcweir 					case SDRMEASURE_TEXTHAUTO:			eRP = RP_MT; break;
370cdf0e10cSrcweir 					}
371cdf0e10cSrcweir 					break;
372cdf0e10cSrcweir 				case SDRMEASURETEXT_VERTICALCENTERED:
373cdf0e10cSrcweir 					switch( eHPos )
374cdf0e10cSrcweir 					{
375cdf0e10cSrcweir 					case SDRMEASURE_TEXTLEFTOUTSIDE:	eRP = RP_LM; break;
376cdf0e10cSrcweir 					case SDRMEASURE_TEXTINSIDE:			eRP = RP_MM; break;
377cdf0e10cSrcweir 					case SDRMEASURE_TEXTRIGHTOUTSIDE:	eRP = RP_RM; break;
378cdf0e10cSrcweir 					case SDRMEASURE_TEXTHAUTO:			eRP = RP_MM; break;
379cdf0e10cSrcweir 					}
380cdf0e10cSrcweir 					break;
381cdf0e10cSrcweir 				case SDRMEASURE_BELOW:
382cdf0e10cSrcweir 					switch( eHPos )
383cdf0e10cSrcweir 					{
384cdf0e10cSrcweir 					case SDRMEASURE_TEXTLEFTOUTSIDE:	eRP = RP_LB; break;
385cdf0e10cSrcweir 					case SDRMEASURE_TEXTINSIDE:			eRP = RP_MB; break;
386cdf0e10cSrcweir 					case SDRMEASURE_TEXTRIGHTOUTSIDE:	eRP = RP_RB; break;
387cdf0e10cSrcweir 					case SDRMEASURE_TEXTHAUTO:			eRP = RP_MB; break;
388cdf0e10cSrcweir 					}
389cdf0e10cSrcweir 					break;
390cdf0e10cSrcweir 				case SDRMEASURE_TEXTVAUTO:
391cdf0e10cSrcweir 					switch( eHPos )
392cdf0e10cSrcweir 					{
393cdf0e10cSrcweir 					case SDRMEASURE_TEXTLEFTOUTSIDE:	eRP = RP_LM; break;
394cdf0e10cSrcweir 					case SDRMEASURE_TEXTINSIDE:			eRP = RP_MM; break;
395cdf0e10cSrcweir 					case SDRMEASURE_TEXTRIGHTOUTSIDE:	eRP = RP_RM; break;
396cdf0e10cSrcweir 					case SDRMEASURE_TEXTHAUTO:			eRP = RP_MM; break;
397cdf0e10cSrcweir 					}
398cdf0e10cSrcweir 					break;
399cdf0e10cSrcweir                  default: ;//prevent warning
400cdf0e10cSrcweir 				}
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 				CTL_STATE nState = 0;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 				if( eHPos == SDRMEASURE_TEXTHAUTO )
405cdf0e10cSrcweir 				{
406cdf0e10cSrcweir 					aTsbAutoPosH.SetState( STATE_CHECK );
407cdf0e10cSrcweir 					nState = CS_NOHORZ;
408cdf0e10cSrcweir 				}
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 				if( eVPos == SDRMEASURE_TEXTVAUTO )
411cdf0e10cSrcweir 				{
412cdf0e10cSrcweir 					aTsbAutoPosV.SetState( STATE_CHECK );
413cdf0e10cSrcweir 					nState |= CS_NOVERT;
414cdf0e10cSrcweir 				}
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 				aCtlPosition.SetState( nState );
417cdf0e10cSrcweir 				aCtlPosition.SetActualRP( eRP );
418cdf0e10cSrcweir 			}
419cdf0e10cSrcweir 		}
420cdf0e10cSrcweir 	}
421cdf0e10cSrcweir 	else
422cdf0e10cSrcweir 	{
423cdf0e10cSrcweir 		aCtlPosition.Reset();
424cdf0e10cSrcweir 		aTsbAutoPosV.SetState( STATE_DONTKNOW );
425cdf0e10cSrcweir 		aTsbAutoPosH.SetState( STATE_DONTKNOW );
426cdf0e10cSrcweir 	}
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	// put the attributes to the preview-control,
429cdf0e10cSrcweir 	// otherwise the control don't know about
430cdf0e10cSrcweir 	// the settings of the dialog (#67930)
431cdf0e10cSrcweir 	ChangeAttrHdl_Impl( &aTsbShowUnit );
432cdf0e10cSrcweir 	aCtlPreview.SetAttributes( rAttrs );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	bPositionModified = sal_False;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir /*************************************************************************
438cdf0e10cSrcweir |*
439cdf0e10cSrcweir |* Fill the delivered Item-Set with dialogbox-attributes
440cdf0e10cSrcweir |*
441cdf0e10cSrcweir \************************************************************************/
442cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rAttrs)443cdf0e10cSrcweir sal_Bool SvxMeasurePage::FillItemSet( SfxItemSet& rAttrs)
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	sal_Bool	 bModified = sal_False;
446cdf0e10cSrcweir 	sal_Int32	 nValue;
447cdf0e10cSrcweir 	TriState eState;
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 	if( aMtrFldLineDist.GetText() != aMtrFldLineDist.GetSavedValue() )
450cdf0e10cSrcweir 	{
451cdf0e10cSrcweir 		nValue = GetCoreValue( aMtrFldLineDist, eUnit );
452cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureLineDistItem( nValue ) );
453cdf0e10cSrcweir 		bModified = sal_True;
454cdf0e10cSrcweir 	}
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	if( aMtrFldHelplineOverhang.GetText() != aMtrFldHelplineOverhang.GetSavedValue() )
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir 		nValue = GetCoreValue( aMtrFldHelplineOverhang, eUnit );
459cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureHelplineOverhangItem( nValue ) );
460cdf0e10cSrcweir 		bModified = sal_True;
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 	if( aMtrFldHelplineDist.GetText() != aMtrFldHelplineDist.GetSavedValue() )
464cdf0e10cSrcweir 	{
465cdf0e10cSrcweir 		nValue = GetCoreValue( aMtrFldHelplineDist, eUnit );
466cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureHelplineDistItem( nValue ) );
467cdf0e10cSrcweir 		bModified = sal_True;
468cdf0e10cSrcweir 	}
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 	if( aMtrFldHelpline1Len.GetText() != aMtrFldHelpline1Len.GetSavedValue() )
471cdf0e10cSrcweir 	{
472cdf0e10cSrcweir 		nValue = GetCoreValue( aMtrFldHelpline1Len, eUnit );
473cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureHelpline1LenItem( nValue ) );
474cdf0e10cSrcweir 		bModified = sal_True;
475cdf0e10cSrcweir 	}
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	if( aMtrFldHelpline2Len.GetText() != aMtrFldHelpline2Len.GetSavedValue() )
478cdf0e10cSrcweir 	{
479cdf0e10cSrcweir 		nValue = GetCoreValue( aMtrFldHelpline2Len, eUnit );
480cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureHelpline2LenItem( nValue ) );
481cdf0e10cSrcweir 		bModified = sal_True;
482cdf0e10cSrcweir 	}
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	eState = aTsbBelowRefEdge.GetState();
485cdf0e10cSrcweir 	if( eState != aTsbBelowRefEdge.GetSavedValue() )
486cdf0e10cSrcweir 	{
487cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool) STATE_CHECK == eState ) );
488cdf0e10cSrcweir 		bModified = sal_True;
489cdf0e10cSrcweir 	}
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	if( aMtrFldDecimalPlaces.GetText() != aMtrFldDecimalPlaces.GetSavedValue() )
492cdf0e10cSrcweir 	{
493cdf0e10cSrcweir 		nValue = static_cast<sal_Int32>(aMtrFldDecimalPlaces.GetValue());
494cdf0e10cSrcweir 		rAttrs.Put(
495cdf0e10cSrcweir             SdrMeasureDecimalPlacesItem(
496cdf0e10cSrcweir                 sal::static_int_cast< sal_Int16 >( nValue ) ) );
497cdf0e10cSrcweir 		bModified = sal_True;
498cdf0e10cSrcweir 	}
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 	eState = aTsbParallel.GetState();
501cdf0e10cSrcweir 	if( eState != aTsbParallel.GetSavedValue() )
502cdf0e10cSrcweir 	{
503cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureTextRota90Item( (sal_Bool) STATE_NOCHECK == eState ) );
504cdf0e10cSrcweir 		bModified = sal_True;
505cdf0e10cSrcweir 	}
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 	eState = aTsbShowUnit.GetState();
508cdf0e10cSrcweir 	if( eState != aTsbShowUnit.GetSavedValue() )
509cdf0e10cSrcweir 	{
510cdf0e10cSrcweir 		rAttrs.Put( SdrMeasureShowUnitItem( (sal_Bool) STATE_CHECK == eState ) );
511cdf0e10cSrcweir 		bModified = sal_True;
512cdf0e10cSrcweir 	}
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	sal_uInt16 nPos = aLbUnit.GetSelectEntryPos();
515cdf0e10cSrcweir 	if( nPos != aLbUnit.GetSavedValue() )
516cdf0e10cSrcweir 	{
517cdf0e10cSrcweir 		if( nPos != LISTBOX_ENTRY_NOTFOUND )
518cdf0e10cSrcweir 		{
519cdf0e10cSrcweir 			sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbUnit.GetEntryData( nPos );
520cdf0e10cSrcweir             FieldUnit _eUnit = (FieldUnit) nFieldUnit;
521cdf0e10cSrcweir             rAttrs.Put( SdrMeasureUnitItem( _eUnit ) );
522cdf0e10cSrcweir 			bModified = sal_True;
523cdf0e10cSrcweir 		}
524cdf0e10cSrcweir 	}
525cdf0e10cSrcweir 
526cdf0e10cSrcweir //enum SdrMeasureTextHPos {SDRMEASURE_TEXTHAUTO,SDRMEASURE_TEXTLEFTOUTSIDE,SDRMEASURE_TEXTINSIDE,SDRMEASURE_TEXTRIGHTOUTSIDE};
527cdf0e10cSrcweir //enum SdrMeasureTextVPos {SDRMEASURE_TEXTVAUTO,SDRMEASURE_ABOVE,SDRMEASURETEXT_VERTICALCENTERED,SDRMEASURE_BELOW};
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	if( bPositionModified )
530cdf0e10cSrcweir 	{
531cdf0e10cSrcweir 		// Position
532cdf0e10cSrcweir 		SdrMeasureTextVPos eVPos, eOldVPos;
533cdf0e10cSrcweir 		SdrMeasureTextHPos eHPos, eOldHPos;
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 		RECT_POINT eRP = aCtlPosition.GetActualRP();
536cdf0e10cSrcweir 		switch( eRP )
537cdf0e10cSrcweir 		{
538cdf0e10cSrcweir 			default:
539cdf0e10cSrcweir 			case RP_LT: eVPos = SDRMEASURE_ABOVE;
540cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
541cdf0e10cSrcweir 			case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
542cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
543cdf0e10cSrcweir 			case RP_LB: eVPos = SDRMEASURE_BELOW;
544cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
545cdf0e10cSrcweir 			case RP_MT: eVPos = SDRMEASURE_ABOVE;
546cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTINSIDE; break;
547cdf0e10cSrcweir 			case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
548cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTINSIDE; break;
549cdf0e10cSrcweir 			case RP_MB: eVPos = SDRMEASURE_BELOW;
550cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTINSIDE; break;
551cdf0e10cSrcweir 			case RP_RT: eVPos = SDRMEASURE_ABOVE;
552cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
553cdf0e10cSrcweir 			case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
554cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
555cdf0e10cSrcweir 			case RP_RB: eVPos = SDRMEASURE_BELOW;
556cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
557cdf0e10cSrcweir 		}
558cdf0e10cSrcweir 		if( aTsbAutoPosH.GetState() == STATE_CHECK )
559cdf0e10cSrcweir 			eHPos = SDRMEASURE_TEXTHAUTO;
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 		if( aTsbAutoPosV.GetState() == STATE_CHECK )
562cdf0e10cSrcweir 			eVPos = SDRMEASURE_TEXTVAUTO;
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 		if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTVPOS ) != SFX_ITEM_DONTCARE )
565cdf0e10cSrcweir 		{
566cdf0e10cSrcweir 			eOldVPos = (SdrMeasureTextVPos)
567cdf0e10cSrcweir 						( ( const SdrMeasureTextVPosItem& )rOutAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
568cdf0e10cSrcweir 			if( eOldVPos != eVPos )
569cdf0e10cSrcweir 			{
570cdf0e10cSrcweir 				rAttrs.Put( SdrMeasureTextVPosItem( eVPos ) );
571cdf0e10cSrcweir 				bModified = sal_True;
572cdf0e10cSrcweir 			}
573cdf0e10cSrcweir 		}
574cdf0e10cSrcweir 		else
575cdf0e10cSrcweir 		{
576cdf0e10cSrcweir 			rAttrs.Put( SdrMeasureTextVPosItem( eVPos ) );
577cdf0e10cSrcweir 			bModified = sal_True;
578cdf0e10cSrcweir 		}
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 		if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTHPOS ) != SFX_ITEM_DONTCARE )
581cdf0e10cSrcweir 		{
582cdf0e10cSrcweir 			eOldHPos = (SdrMeasureTextHPos)
583cdf0e10cSrcweir 						( ( const SdrMeasureTextHPosItem& )rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
584cdf0e10cSrcweir 			if( eOldHPos != eHPos )
585cdf0e10cSrcweir 			{
586cdf0e10cSrcweir 				rAttrs.Put( SdrMeasureTextHPosItem( eHPos ) );
587cdf0e10cSrcweir 				bModified = sal_True;
588cdf0e10cSrcweir 			}
589cdf0e10cSrcweir 		}
590cdf0e10cSrcweir 		else
591cdf0e10cSrcweir 		{
592cdf0e10cSrcweir 			rAttrs.Put( SdrMeasureTextHPosItem( eHPos ) );
593cdf0e10cSrcweir 			bModified = sal_True;
594cdf0e10cSrcweir 		}
595cdf0e10cSrcweir 	}
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	return( bModified );
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir /*************************************************************************
601cdf0e10cSrcweir |*
602cdf0e10cSrcweir |* The View have to set at the measure-object to be able to notify
603cdf0e10cSrcweir |* unit and floatingpoint-values
604cdf0e10cSrcweir |*
605cdf0e10cSrcweir \************************************************************************/
606cdf0e10cSrcweir 
Construct()607cdf0e10cSrcweir void SvxMeasurePage::Construct()
608cdf0e10cSrcweir {
609cdf0e10cSrcweir 	DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 	aCtlPreview.pMeasureObj->SetModel( pView->GetModel() );
612cdf0e10cSrcweir 	aCtlPreview.Invalidate();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir /*************************************************************************
616cdf0e10cSrcweir |*
617cdf0e10cSrcweir |* create the tabpage
618cdf0e10cSrcweir |*
619cdf0e10cSrcweir \************************************************************************/
620cdf0e10cSrcweir 
Create(Window * pWindow,const SfxItemSet & rAttrs)621cdf0e10cSrcweir SfxTabPage* SvxMeasurePage::Create( Window* pWindow,
622cdf0e10cSrcweir 				const SfxItemSet& rAttrs )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir 	return( new SvxMeasurePage( pWindow, rAttrs ) );
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir /*************************************************************************
628cdf0e10cSrcweir |*
629cdf0e10cSrcweir |*
630cdf0e10cSrcweir |*
631cdf0e10cSrcweir \************************************************************************/
632cdf0e10cSrcweir 
GetRanges()633cdf0e10cSrcweir sal_uInt16*	SvxMeasurePage::GetRanges()
634cdf0e10cSrcweir {
635cdf0e10cSrcweir 	return( pRanges );
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
638cdf0e10cSrcweir /*************************************************************************
639cdf0e10cSrcweir |*
640cdf0e10cSrcweir |*
641cdf0e10cSrcweir |*
642cdf0e10cSrcweir \************************************************************************/
643cdf0e10cSrcweir 
PointChanged(Window * pWindow,RECT_POINT)644cdf0e10cSrcweir void SvxMeasurePage::PointChanged( Window* pWindow, RECT_POINT /*eRP*/ )
645cdf0e10cSrcweir {
646cdf0e10cSrcweir 	ChangeAttrHdl_Impl( pWindow );
647cdf0e10cSrcweir }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir /*************************************************************************
650cdf0e10cSrcweir |*
651cdf0e10cSrcweir |*
652cdf0e10cSrcweir |*
653cdf0e10cSrcweir \************************************************************************/
654cdf0e10cSrcweir 
IMPL_LINK(SvxMeasurePage,ClickAutoPosHdl_Impl,void *,p)655cdf0e10cSrcweir IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, void *, p )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir 	if( aTsbAutoPosH.GetState() == STATE_CHECK )
658cdf0e10cSrcweir 	{
659cdf0e10cSrcweir 		switch( aCtlPosition.GetActualRP() )
660cdf0e10cSrcweir 		{
661cdf0e10cSrcweir 			case RP_LT:
662cdf0e10cSrcweir 			case RP_RT:
663cdf0e10cSrcweir 				aCtlPosition.SetActualRP( RP_MT );
664cdf0e10cSrcweir 			break;
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 			case RP_LM:
667cdf0e10cSrcweir 			case RP_RM:
668cdf0e10cSrcweir 				aCtlPosition.SetActualRP( RP_MM );
669cdf0e10cSrcweir 			break;
670cdf0e10cSrcweir 
671cdf0e10cSrcweir 			case RP_LB:
672cdf0e10cSrcweir 			case RP_RB:
673cdf0e10cSrcweir 				aCtlPosition.SetActualRP( RP_MB );
674cdf0e10cSrcweir 			break;
675cdf0e10cSrcweir             default: ;//prevent warning
676cdf0e10cSrcweir 		}
677cdf0e10cSrcweir 	}
678cdf0e10cSrcweir 	if( aTsbAutoPosV.GetState() == STATE_CHECK )
679cdf0e10cSrcweir 	{
680cdf0e10cSrcweir 		switch( aCtlPosition.GetActualRP() )
681cdf0e10cSrcweir 		{
682cdf0e10cSrcweir 			case RP_LT:
683cdf0e10cSrcweir 			case RP_LB:
684cdf0e10cSrcweir 				aCtlPosition.SetActualRP( RP_LM );
685cdf0e10cSrcweir 			break;
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 			case RP_MT:
688cdf0e10cSrcweir 			case RP_MB:
689cdf0e10cSrcweir 				aCtlPosition.SetActualRP( RP_MM );
690cdf0e10cSrcweir 			break;
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 			case RP_RT:
693cdf0e10cSrcweir 			case RP_RB:
694cdf0e10cSrcweir 				aCtlPosition.SetActualRP( RP_RM );
695cdf0e10cSrcweir 			break;
696cdf0e10cSrcweir             default: ;//prevent warning
697cdf0e10cSrcweir 		}
698cdf0e10cSrcweir 	}
699cdf0e10cSrcweir 	ChangeAttrHdl_Impl( p );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 	return( 0L );
702cdf0e10cSrcweir }
703cdf0e10cSrcweir 
704cdf0e10cSrcweir /*************************************************************************
705cdf0e10cSrcweir |*
706cdf0e10cSrcweir |*
707cdf0e10cSrcweir |*
708cdf0e10cSrcweir \************************************************************************/
709cdf0e10cSrcweir 
IMPL_LINK(SvxMeasurePage,ChangeAttrHdl_Impl,void *,p)710cdf0e10cSrcweir IMPL_LINK( SvxMeasurePage, ChangeAttrHdl_Impl, void *, p )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 	if( p == &aMtrFldLineDist )
714cdf0e10cSrcweir 	{
715cdf0e10cSrcweir 		sal_Int32 nValue = GetCoreValue( aMtrFldLineDist, eUnit );
716cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureLineDistItem( nValue ) );
717cdf0e10cSrcweir 	}
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 	if( p == &aMtrFldHelplineOverhang )
720cdf0e10cSrcweir 	{
721cdf0e10cSrcweir 		sal_Int32 nValue = GetCoreValue( aMtrFldHelplineOverhang, eUnit );
722cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureHelplineOverhangItem( nValue) );
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 	if( p == &aMtrFldHelplineDist )
726cdf0e10cSrcweir 	{
727cdf0e10cSrcweir 		sal_Int32 nValue = GetCoreValue( aMtrFldHelplineDist, eUnit );
728cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureHelplineDistItem( nValue) );
729cdf0e10cSrcweir 	}
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 	if( p == &aMtrFldHelpline1Len )
732cdf0e10cSrcweir 	{
733cdf0e10cSrcweir 		sal_Int32 nValue = GetCoreValue( aMtrFldHelpline1Len, eUnit );
734cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureHelpline1LenItem( nValue ) );
735cdf0e10cSrcweir 	}
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 	if( p == &aMtrFldHelpline2Len )
738cdf0e10cSrcweir 	{
739cdf0e10cSrcweir 		sal_Int32 nValue = GetCoreValue( aMtrFldHelpline2Len, eUnit );
740cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureHelpline2LenItem( nValue ) );
741cdf0e10cSrcweir 	}
742cdf0e10cSrcweir 
743cdf0e10cSrcweir 	if( p == &aTsbBelowRefEdge )
744cdf0e10cSrcweir 	{
745cdf0e10cSrcweir 		TriState eState = aTsbBelowRefEdge.GetState();
746cdf0e10cSrcweir 		if( eState != STATE_DONTKNOW )
747cdf0e10cSrcweir 			aAttrSet.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool) STATE_CHECK == eState ) );
748cdf0e10cSrcweir 	}
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 	if( p == &aMtrFldDecimalPlaces )
751cdf0e10cSrcweir 	{
752cdf0e10cSrcweir 		sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
753cdf0e10cSrcweir             aMtrFldDecimalPlaces.GetValue() );
754cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureDecimalPlacesItem( nValue ) );
755cdf0e10cSrcweir 	}
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 	if( p == &aTsbParallel )
758cdf0e10cSrcweir 	{
759cdf0e10cSrcweir 		TriState eState = aTsbParallel.GetState();
760cdf0e10cSrcweir 		if( eState != STATE_DONTKNOW )
761cdf0e10cSrcweir 			aAttrSet.Put( SdrMeasureTextRota90Item( (sal_Bool) !STATE_CHECK == eState ) );
762cdf0e10cSrcweir 	}
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 	if( p == &aTsbShowUnit )
765cdf0e10cSrcweir 	{
766cdf0e10cSrcweir 		TriState eState = aTsbShowUnit.GetState();
767cdf0e10cSrcweir 		if( eState != STATE_DONTKNOW )
768cdf0e10cSrcweir 			aAttrSet.Put( SdrMeasureShowUnitItem( (sal_Bool) STATE_CHECK == eState ) );
769cdf0e10cSrcweir 	}
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 	if( p == &aLbUnit )
772cdf0e10cSrcweir 	{
773cdf0e10cSrcweir 		sal_uInt16 nPos = aLbUnit.GetSelectEntryPos();
774cdf0e10cSrcweir 		if( nPos != LISTBOX_ENTRY_NOTFOUND )
775cdf0e10cSrcweir 		{
776cdf0e10cSrcweir 			sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbUnit.GetEntryData( nPos );
777cdf0e10cSrcweir             FieldUnit _eUnit = (FieldUnit) nFieldUnit;
778cdf0e10cSrcweir             aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
779cdf0e10cSrcweir 		}
780cdf0e10cSrcweir 	}
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 	if( p == &aTsbAutoPosV || p == &aTsbAutoPosH || p == &aCtlPosition )
783cdf0e10cSrcweir 	{
784cdf0e10cSrcweir 		bPositionModified = sal_True;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 		// Position
787cdf0e10cSrcweir 		RECT_POINT eRP = aCtlPosition.GetActualRP();
788cdf0e10cSrcweir 		SdrMeasureTextVPos eVPos;
789cdf0e10cSrcweir 		SdrMeasureTextHPos eHPos;
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 		switch( eRP )
792cdf0e10cSrcweir 		{
793cdf0e10cSrcweir 			default:
794cdf0e10cSrcweir 			case RP_LT: eVPos = SDRMEASURE_ABOVE;
795cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
796cdf0e10cSrcweir 			case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
797cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
798cdf0e10cSrcweir 			case RP_LB: eVPos = SDRMEASURE_BELOW;
799cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
800cdf0e10cSrcweir 			case RP_MT: eVPos = SDRMEASURE_ABOVE;
801cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTINSIDE; break;
802cdf0e10cSrcweir 			case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
803cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTINSIDE; break;
804cdf0e10cSrcweir 			case RP_MB: eVPos = SDRMEASURE_BELOW;
805cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTINSIDE; break;
806cdf0e10cSrcweir 			case RP_RT: eVPos = SDRMEASURE_ABOVE;
807cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
808cdf0e10cSrcweir 			case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
809cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
810cdf0e10cSrcweir 			case RP_RB: eVPos = SDRMEASURE_BELOW;
811cdf0e10cSrcweir 						eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
812cdf0e10cSrcweir 		}
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 		CTL_STATE nState = 0;
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 		if( aTsbAutoPosH.GetState() == STATE_CHECK )
817cdf0e10cSrcweir 		{
818cdf0e10cSrcweir 			eHPos = SDRMEASURE_TEXTHAUTO;
819cdf0e10cSrcweir 			nState = CS_NOHORZ;
820cdf0e10cSrcweir 		}
821cdf0e10cSrcweir 
822cdf0e10cSrcweir 		if( aTsbAutoPosV.GetState() == STATE_CHECK )
823cdf0e10cSrcweir 		{
824cdf0e10cSrcweir 			eVPos = SDRMEASURE_TEXTVAUTO;
825cdf0e10cSrcweir 			nState |= CS_NOVERT;
826cdf0e10cSrcweir 		}
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 		if( p == &aTsbAutoPosV || p == &aTsbAutoPosH )
829cdf0e10cSrcweir 			aCtlPosition.SetState( nState );
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
832cdf0e10cSrcweir 		aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
833cdf0e10cSrcweir 	}
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 	aCtlPreview.SetAttributes( aAttrSet );
836cdf0e10cSrcweir 	aCtlPreview.Invalidate();
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 	return( 0L );
839cdf0e10cSrcweir }
840cdf0e10cSrcweir 
841cdf0e10cSrcweir /*************************************************************************
842cdf0e10cSrcweir |*
843cdf0e10cSrcweir |*
844cdf0e10cSrcweir |*
845cdf0e10cSrcweir \************************************************************************/
846cdf0e10cSrcweir 
FillUnitLB()847cdf0e10cSrcweir void SvxMeasurePage::FillUnitLB()
848cdf0e10cSrcweir {
849cdf0e10cSrcweir 	// fill ListBox with metrics
850cdf0e10cSrcweir 	SvxStringArray aMetricArr( SVX_RES( RID_SVXSTR_FIELDUNIT_TABLE ) );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 	long nUnit = FUNIT_NONE;
853cdf0e10cSrcweir 	String aStrMetric( CUI_RES( STR_MEASURE_AUTOMATIC ) );
854cdf0e10cSrcweir 	sal_uInt16 nPos = aLbUnit.InsertEntry( aStrMetric );
855cdf0e10cSrcweir 	aLbUnit.SetEntryData( nPos, (void*)nUnit );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i )
858cdf0e10cSrcweir 	{
859cdf0e10cSrcweir 		aStrMetric = aMetricArr.GetStringByPos( i );
860cdf0e10cSrcweir 		nUnit = aMetricArr.GetValue( i );
861cdf0e10cSrcweir 		nPos = aLbUnit.InsertEntry( aStrMetric );
862cdf0e10cSrcweir 		aLbUnit.SetEntryData( nPos, (void*)nUnit );
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir }
PageCreated(SfxAllItemSet aSet)865cdf0e10cSrcweir void SvxMeasurePage::PageCreated (SfxAllItemSet aSet) //add CHINA001
866cdf0e10cSrcweir {
867cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pOfaPtrItem,OfaPtrItem,SID_OBJECT_LIST,sal_False);
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 	if (pOfaPtrItem)
870cdf0e10cSrcweir 		SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()));
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 	Construct();
873cdf0e10cSrcweir }
874cdf0e10cSrcweir 
875