xref: /aoo41x/main/cui/source/tabpages/tpshadow.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_cui.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir #include <tools/shl.hxx>
33*cdf0e10cSrcweir #include <sfx2/app.hxx>
34*cdf0e10cSrcweir #include <sfx2/module.hxx>
35*cdf0e10cSrcweir #include <svx/dialogs.hrc>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define _SVX_TPSHADOW_CXX
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "svx/xattr.hxx"
40*cdf0e10cSrcweir #include <svx/xpool.hxx>
41*cdf0e10cSrcweir #include <cuires.hrc>
42*cdf0e10cSrcweir #include "tabarea.hrc"
43*cdf0e10cSrcweir #include <svx/svdattr.hxx>
44*cdf0e10cSrcweir #include "svx/drawitem.hxx"
45*cdf0e10cSrcweir #include "cuitabarea.hxx"
46*cdf0e10cSrcweir #include <dialmgr.hxx>
47*cdf0e10cSrcweir #include "svx/dlgutil.hxx"
48*cdf0e10cSrcweir #include <cuitabline.hxx>
49*cdf0e10cSrcweir #include "paragrph.hrc"
50*cdf0e10cSrcweir #include <svx/xlineit0.hxx>
51*cdf0e10cSrcweir #include <sfx2/request.hxx> //add CHINA001
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #define DLGWIN this->GetParent()->GetParent()
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir // static ----------------------------------------------------------------
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir static sal_uInt16 pShadowRanges[] =
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir 	SDRATTR_SHADOWCOLOR,
60*cdf0e10cSrcweir 	SDRATTR_SHADOWTRANSPARENCE,
61*cdf0e10cSrcweir 	SID_ATTR_FILL_SHADOW,
62*cdf0e10cSrcweir 	SID_ATTR_FILL_SHADOW,
63*cdf0e10cSrcweir 	0
64*cdf0e10cSrcweir };
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir /*************************************************************************
67*cdf0e10cSrcweir |*
68*cdf0e10cSrcweir |*	Dialog zum Aendern des Schattens
69*cdf0e10cSrcweir |*
70*cdf0e10cSrcweir \************************************************************************/
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir SvxShadowTabPage::SvxShadowTabPage( Window* pParent, const SfxItemSet& rInAttrs ) :
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	SvxTabPage			( pParent, CUI_RES( RID_SVXPAGE_SHADOW ), rInAttrs ),
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     aFlProp             ( this, CUI_RES( FL_PROP ) ),
77*cdf0e10cSrcweir     aTsbShowShadow      ( this, CUI_RES( TSB_SHOW_SHADOW ) ),
78*cdf0e10cSrcweir     aFtPosition         ( this, CUI_RES( FT_POSITION ) ),
79*cdf0e10cSrcweir     aCtlPosition        ( this, CUI_RES( CTL_POSITION ) ),
80*cdf0e10cSrcweir 	aFtDistance			( this, CUI_RES( FT_DISTANCE ) ),
81*cdf0e10cSrcweir 	aMtrDistance		( this, CUI_RES( MTR_FLD_DISTANCE ) ),
82*cdf0e10cSrcweir 	aFtShadowColor		( this, CUI_RES( FT_SHADOW_COLOR ) ),
83*cdf0e10cSrcweir 	aLbShadowColor		( this, CUI_RES( LB_SHADOW_COLOR ) ),
84*cdf0e10cSrcweir 	aFtTransparent      ( this, CUI_RES( FT_TRANSPARENT ) ),
85*cdf0e10cSrcweir 	aMtrTransparent      ( this, CUI_RES( MTR_SHADOW_TRANSPARENT ) ),
86*cdf0e10cSrcweir     aCtlXRectPreview    ( this, CUI_RES( CTL_COLOR_PREVIEW ) ),
87*cdf0e10cSrcweir 	rOutAttrs			( rInAttrs ),
88*cdf0e10cSrcweir     pColorTab( NULL ),
89*cdf0e10cSrcweir     bDisable            ( sal_False ),
90*cdf0e10cSrcweir     pXPool              ( (XOutdevItemPool*) rInAttrs.GetPool() ),
91*cdf0e10cSrcweir     aXFillAttr          ( pXPool ),
92*cdf0e10cSrcweir     rXFSet              ( aXFillAttr.GetItemSet() )
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir 	FreeResource();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	// diese Page braucht ExchangeSupport
97*cdf0e10cSrcweir 	SetExchangeSupport();
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	// Metrik einstellen
100*cdf0e10cSrcweir 	FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	switch ( eFUnit )
103*cdf0e10cSrcweir 	{
104*cdf0e10cSrcweir 		case FUNIT_M:
105*cdf0e10cSrcweir 		case FUNIT_KM:
106*cdf0e10cSrcweir 			eFUnit = FUNIT_MM;
107*cdf0e10cSrcweir 			break;
108*cdf0e10cSrcweir         default: ;//prevent warning
109*cdf0e10cSrcweir 	}
110*cdf0e10cSrcweir 	SetFieldUnit( aMtrDistance, eFUnit );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	// PoolUnit ermitteln
113*cdf0e10cSrcweir 	SfxItemPool* pPool = rOutAttrs.GetPool();
114*cdf0e10cSrcweir 	DBG_ASSERT( pPool, "Wo ist der Pool?" );
115*cdf0e10cSrcweir 	ePoolUnit = pPool->GetMetric( SDRATTR_SHADOWXDIST );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	// Setzen des Output-Devices
118*cdf0e10cSrcweir 	XFillStyle eXFS = XFILL_SOLID;
119*cdf0e10cSrcweir 	if( rOutAttrs.GetItemState( XATTR_FILLSTYLE ) != SFX_ITEM_DONTCARE )
120*cdf0e10cSrcweir 	{
121*cdf0e10cSrcweir 		eXFS = (XFillStyle) ( ( ( const XFillStyleItem& ) rOutAttrs.
122*cdf0e10cSrcweir 								Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue() );
123*cdf0e10cSrcweir 		switch( eXFS )
124*cdf0e10cSrcweir 		{
125*cdf0e10cSrcweir 			//case XFILL_NONE: --> NICHTS
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 			case XFILL_SOLID:
128*cdf0e10cSrcweir 				if( SFX_ITEM_DONTCARE != rOutAttrs.GetItemState( XATTR_FILLCOLOR ) )
129*cdf0e10cSrcweir 				{
130*cdf0e10cSrcweir 					XFillColorItem aColorItem( ( const XFillColorItem& )
131*cdf0e10cSrcweir 										rOutAttrs.Get( XATTR_FILLCOLOR ) );
132*cdf0e10cSrcweir 					rXFSet.Put( aColorItem );
133*cdf0e10cSrcweir 				}
134*cdf0e10cSrcweir 			break;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 			case XFILL_GRADIENT:
137*cdf0e10cSrcweir 				if( SFX_ITEM_DONTCARE != rOutAttrs.GetItemState( XATTR_FILLGRADIENT ) )
138*cdf0e10cSrcweir 				{
139*cdf0e10cSrcweir 					XFillGradientItem aGradientItem( ( ( const XFillGradientItem& )
140*cdf0e10cSrcweir 											rOutAttrs.Get( XATTR_FILLGRADIENT ) ) );
141*cdf0e10cSrcweir 					rXFSet.Put( aGradientItem );
142*cdf0e10cSrcweir 				}
143*cdf0e10cSrcweir 			break;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 			case XFILL_HATCH:
146*cdf0e10cSrcweir 				if( SFX_ITEM_DONTCARE != rOutAttrs.GetItemState( XATTR_FILLHATCH ) )
147*cdf0e10cSrcweir 				{
148*cdf0e10cSrcweir 					XFillHatchItem aHatchItem( ( ( const XFillHatchItem& )
149*cdf0e10cSrcweir 									rOutAttrs.Get( XATTR_FILLHATCH ) ) );
150*cdf0e10cSrcweir 					rXFSet.Put( aHatchItem );
151*cdf0e10cSrcweir 				}
152*cdf0e10cSrcweir 			break;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 			case XFILL_BITMAP:
155*cdf0e10cSrcweir 			{
156*cdf0e10cSrcweir 				if( SFX_ITEM_DONTCARE != rOutAttrs.GetItemState( XATTR_FILLBITMAP ) )
157*cdf0e10cSrcweir 				{
158*cdf0e10cSrcweir 					XFillBitmapItem aBitmapItem( ( const XFillBitmapItem& )
159*cdf0e10cSrcweir 										rOutAttrs.Get( XATTR_FILLBITMAP ) );
160*cdf0e10cSrcweir 					rXFSet.Put( aBitmapItem );
161*cdf0e10cSrcweir 				}
162*cdf0e10cSrcweir 			}
163*cdf0e10cSrcweir 			break;
164*cdf0e10cSrcweir             case XFILL_NONE : break;
165*cdf0e10cSrcweir 		}
166*cdf0e10cSrcweir 	}
167*cdf0e10cSrcweir 	else
168*cdf0e10cSrcweir 	{
169*cdf0e10cSrcweir 		rXFSet.Put( XFillColorItem( String(), COL_LIGHTRED ) );
170*cdf0e10cSrcweir 	}
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     if(XFILL_NONE == eXFS)
173*cdf0e10cSrcweir     {
174*cdf0e10cSrcweir         // #i96350#
175*cdf0e10cSrcweir         // fallback to solid fillmode when no fill mode is provided to have
176*cdf0e10cSrcweir         // a reasonable shadow preview. The used color will be a set one or
177*cdf0e10cSrcweir         // the default (currently blue8)
178*cdf0e10cSrcweir         eXFS = XFILL_SOLID;
179*cdf0e10cSrcweir     }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	rXFSet.Put( XFillStyleItem( eXFS ) );
182*cdf0e10cSrcweir 	aCtlXRectPreview.SetRectangleAttributes(aXFillAttr.GetItemSet());
183*cdf0e10cSrcweir 	//aCtlXRectPreview.SetFillAttr( aXFillAttr );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	aTsbShowShadow.SetClickHdl( LINK( this, SvxShadowTabPage, ClickShadowHdl_Impl ) );
186*cdf0e10cSrcweir 	Link aLink = LINK( this, SvxShadowTabPage, ModifyShadowHdl_Impl );
187*cdf0e10cSrcweir 	aLbShadowColor.SetSelectHdl( aLink );
188*cdf0e10cSrcweir 	aMtrTransparent.SetModifyHdl( aLink );
189*cdf0e10cSrcweir 	aMtrDistance.SetModifyHdl( aLink );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	aCtlXRectPreview.SetAccessibleName(String(CUI_RES(STR_EXAMPLE)));
192*cdf0e10cSrcweir 	aCtlPosition.SetAccessibleRelationMemberOf( &aFlProp );
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir // -----------------------------------------------------------------------
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir void SvxShadowTabPage::Construct()
198*cdf0e10cSrcweir {
199*cdf0e10cSrcweir 	// Farbtabelle fuellen
200*cdf0e10cSrcweir 	aLbShadowColor.Fill( pColorTab );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	if( bDisable )
203*cdf0e10cSrcweir 	{
204*cdf0e10cSrcweir 		aTsbShowShadow.Disable();
205*cdf0e10cSrcweir 		aFtPosition.Disable();
206*cdf0e10cSrcweir 		aCtlPosition.Disable();
207*cdf0e10cSrcweir 		aFtDistance.Disable();
208*cdf0e10cSrcweir 		aMtrDistance.Disable();
209*cdf0e10cSrcweir 		aFtShadowColor.Disable();
210*cdf0e10cSrcweir 		aLbShadowColor.Disable();
211*cdf0e10cSrcweir 		aFtTransparent.Disable();
212*cdf0e10cSrcweir 		aMtrTransparent.Disable();
213*cdf0e10cSrcweir 	}
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir // -----------------------------------------------------------------------
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir void SvxShadowTabPage::ActivatePage( const SfxItemSet& rSet )
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 	sal_uInt16 nPos;
221*cdf0e10cSrcweir 	sal_uInt16 nCount;
222*cdf0e10cSrcweir 	//add CHINA001 Begin
223*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&rSet,pPageTypeItem,SfxUInt16Item,SID_PAGE_TYPE,sal_False);
224*cdf0e10cSrcweir 	if (pPageTypeItem)
225*cdf0e10cSrcweir 		SetPageType(pPageTypeItem->GetValue());
226*cdf0e10cSrcweir 	//add CHINA001 end
227*cdf0e10cSrcweir 	if( nDlgType == 0 ) //CHINA001 // Flaechen-Dialogif( *pDlgType == 0 ) // Flaechen-Dialog
228*cdf0e10cSrcweir 	{
229*cdf0e10cSrcweir 		if( pColorTab )
230*cdf0e10cSrcweir 		{
231*cdf0e10cSrcweir 			// ColorTable
232*cdf0e10cSrcweir 			if( *pnColorTableState & CT_CHANGED ||
233*cdf0e10cSrcweir 				*pnColorTableState & CT_MODIFIED )
234*cdf0e10cSrcweir 			{
235*cdf0e10cSrcweir 				if( *pnColorTableState & CT_CHANGED )
236*cdf0e10cSrcweir 				{
237*cdf0e10cSrcweir 					SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( DLGWIN );
238*cdf0e10cSrcweir 					if( pArea )
239*cdf0e10cSrcweir 					{
240*cdf0e10cSrcweir 						pColorTab = pArea->GetNewColorTable();
241*cdf0e10cSrcweir 					}
242*cdf0e10cSrcweir 					else
243*cdf0e10cSrcweir 					{
244*cdf0e10cSrcweir 						SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( DLGWIN );
245*cdf0e10cSrcweir 						if( pLine )
246*cdf0e10cSrcweir 							pColorTab = pLine->GetNewColorTable();
247*cdf0e10cSrcweir 					}
248*cdf0e10cSrcweir 				}
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 				// aLbShadowColor
251*cdf0e10cSrcweir 				nPos = aLbShadowColor.GetSelectEntryPos();
252*cdf0e10cSrcweir 				aLbShadowColor.Clear();
253*cdf0e10cSrcweir 				aLbShadowColor.Fill( pColorTab );
254*cdf0e10cSrcweir 				nCount = aLbShadowColor.GetEntryCount();
255*cdf0e10cSrcweir 				if( nCount == 0 )
256*cdf0e10cSrcweir 					; // Dieser Fall sollte nicht auftreten
257*cdf0e10cSrcweir 				else if( nCount <= nPos )
258*cdf0e10cSrcweir 					aLbShadowColor.SelectEntryPos( 0 );
259*cdf0e10cSrcweir 				else
260*cdf0e10cSrcweir 					aLbShadowColor.SelectEntryPos( nPos );
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 				ModifyShadowHdl_Impl( this );
263*cdf0e10cSrcweir 			}
264*cdf0e10cSrcweir 			nPageType = PT_SHADOW;//CHINA001 *pPageType = PT_SHADOW;
265*cdf0e10cSrcweir 		}
266*cdf0e10cSrcweir 	}
267*cdf0e10cSrcweir }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir // -----------------------------------------------------------------------
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir int SvxShadowTabPage::DeactivatePage( SfxItemSet* _pSet )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     if( _pSet )
274*cdf0e10cSrcweir         FillItemSet( *_pSet );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	return( LEAVE_PAGE );
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir // -----------------------------------------------------------------------
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir sal_Bool SvxShadowTabPage::FillItemSet( SfxItemSet& rAttrs )
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir 	const SfxPoolItem*	pOld = NULL;
284*cdf0e10cSrcweir 	sal_Bool				bModified = sal_False;
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	if( !bDisable )
287*cdf0e10cSrcweir 	{
288*cdf0e10cSrcweir 		// Schatten
289*cdf0e10cSrcweir 		TriState eState = aTsbShowShadow.GetState();
290*cdf0e10cSrcweir 		if( eState != aTsbShowShadow.GetSavedValue() )
291*cdf0e10cSrcweir 		{
292*cdf0e10cSrcweir 			SdrShadowItem aItem( sal::static_int_cast< sal_Bool >( eState ) );
293*cdf0e10cSrcweir 			pOld = GetOldItem( rAttrs, SDRATTR_SHADOW );
294*cdf0e10cSrcweir 			if ( !pOld || !( *(const SdrShadowItem*)pOld == aItem ) )
295*cdf0e10cSrcweir 			{
296*cdf0e10cSrcweir 				rAttrs.Put( aItem );
297*cdf0e10cSrcweir 				bModified = sal_True;
298*cdf0e10cSrcweir 			}
299*cdf0e10cSrcweir 		}
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 		// Schatten-Entfernung
302*cdf0e10cSrcweir 		// Etwas umstaendliche Abfrage, ob etwas geaendert wurde,
303*cdf0e10cSrcweir 		// da Items nicht direkt auf Controls abbildbar sind
304*cdf0e10cSrcweir 		sal_Int32 nX = 0L, nY = 0L;
305*cdf0e10cSrcweir 		sal_Int32 nXY = GetCoreValue( aMtrDistance, ePoolUnit );
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 		switch( aCtlPosition.GetActualRP() )
308*cdf0e10cSrcweir 		{
309*cdf0e10cSrcweir 			case RP_LT: nX = nY = -nXY; 	 break;
310*cdf0e10cSrcweir 			case RP_MT: nY = -nXY;			 break;
311*cdf0e10cSrcweir 			case RP_RT: nX = nXY; nY = -nXY; break;
312*cdf0e10cSrcweir 			case RP_LM: nX = -nXY;			 break;
313*cdf0e10cSrcweir 			case RP_RM: nX = nXY;			 break;
314*cdf0e10cSrcweir 			case RP_LB: nX = -nXY; nY = nXY; break;
315*cdf0e10cSrcweir 			case RP_MB: nY = nXY; 			 break;
316*cdf0e10cSrcweir 			case RP_RB: nX = nY = nXY; 		 break;
317*cdf0e10cSrcweir             case RP_MM: break;
318*cdf0e10cSrcweir 		}
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 		// Wenn die Werte des Schattenabstanden==SFX_ITEM_DONTCARE und der angezeigte
321*cdf0e10cSrcweir 		// String im entspr. MetricField=="", dann w�rde der Vergleich zw. alten und
322*cdf0e10cSrcweir 		// neuen Distance-Werte ein falsches Ergebnis liefern, da in so einem Fall die
323*cdf0e10cSrcweir 		// neuen Distance-Werte den Default-Werten des MetricField entspr�chen !!!!
324*cdf0e10cSrcweir 		if ( !aMtrDistance.IsEmptyFieldValue()                                  ||
325*cdf0e10cSrcweir 			 rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SFX_ITEM_DONTCARE ||
326*cdf0e10cSrcweir 			 rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SFX_ITEM_DONTCARE    )
327*cdf0e10cSrcweir 		{
328*cdf0e10cSrcweir 			sal_Int32 nOldX = 9876543; // Unmoeglicher Wert, entspr. DontCare
329*cdf0e10cSrcweir 			sal_Int32 nOldY = 9876543;
330*cdf0e10cSrcweir 			if( rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SFX_ITEM_DONTCARE &&
331*cdf0e10cSrcweir 				rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SFX_ITEM_DONTCARE )
332*cdf0e10cSrcweir 			{
333*cdf0e10cSrcweir 				nOldX = ( ( const SdrShadowXDistItem& ) rOutAttrs.
334*cdf0e10cSrcweir 									Get( SDRATTR_SHADOWXDIST ) ).GetValue();
335*cdf0e10cSrcweir 				nOldY = ( ( const SdrShadowYDistItem& ) rOutAttrs.
336*cdf0e10cSrcweir 									Get( SDRATTR_SHADOWYDIST ) ).GetValue();
337*cdf0e10cSrcweir 			}
338*cdf0e10cSrcweir 			SdrShadowXDistItem aXItem( nX );
339*cdf0e10cSrcweir 			pOld = GetOldItem( rAttrs, SDRATTR_SHADOWXDIST );
340*cdf0e10cSrcweir 			if ( nX != nOldX &&
341*cdf0e10cSrcweir 				( !pOld || !( *(const SdrShadowXDistItem*)pOld == aXItem ) ) )
342*cdf0e10cSrcweir 			{
343*cdf0e10cSrcweir 				rAttrs.Put( aXItem );
344*cdf0e10cSrcweir 				bModified = sal_True;
345*cdf0e10cSrcweir 			}
346*cdf0e10cSrcweir 			SdrShadowYDistItem aYItem( nY );
347*cdf0e10cSrcweir 			pOld = GetOldItem( rAttrs, SDRATTR_SHADOWYDIST );
348*cdf0e10cSrcweir 			if ( nY != nOldY &&
349*cdf0e10cSrcweir 				( !pOld || !( *(const SdrShadowYDistItem*)pOld == aYItem ) ) )
350*cdf0e10cSrcweir 			{
351*cdf0e10cSrcweir 				rAttrs.Put( aYItem );
352*cdf0e10cSrcweir 				bModified = sal_True;
353*cdf0e10cSrcweir 			}
354*cdf0e10cSrcweir 		}
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 		// ShadowColor
357*cdf0e10cSrcweir 		sal_uInt16 nPos = aLbShadowColor.GetSelectEntryPos();
358*cdf0e10cSrcweir 		if( nPos != LISTBOX_ENTRY_NOTFOUND &&
359*cdf0e10cSrcweir 			nPos != aLbShadowColor.GetSavedValue() )
360*cdf0e10cSrcweir 		{
361*cdf0e10cSrcweir 			SdrShadowColorItem aItem( aLbShadowColor.GetSelectEntry(),
362*cdf0e10cSrcweir 									aLbShadowColor.GetSelectEntryColor() );
363*cdf0e10cSrcweir 			pOld = GetOldItem( rAttrs, SDRATTR_SHADOWCOLOR );
364*cdf0e10cSrcweir 			if ( !pOld || !( *(const SdrShadowColorItem*)pOld == aItem ) )
365*cdf0e10cSrcweir 			{
366*cdf0e10cSrcweir 				rAttrs.Put( aItem );
367*cdf0e10cSrcweir 				bModified = sal_True;
368*cdf0e10cSrcweir 			}
369*cdf0e10cSrcweir 		}
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 		// Transparenz
372*cdf0e10cSrcweir 		sal_uInt16 nVal = (sal_uInt16)aMtrTransparent.GetValue();
373*cdf0e10cSrcweir 		if( nVal != (sal_uInt16)aMtrTransparent.GetSavedValue().ToInt32() )
374*cdf0e10cSrcweir 		{
375*cdf0e10cSrcweir 			SdrShadowTransparenceItem aItem( nVal );
376*cdf0e10cSrcweir 			pOld = GetOldItem( rAttrs, SDRATTR_SHADOWTRANSPARENCE );
377*cdf0e10cSrcweir 			if ( !pOld || !( *(const SdrShadowTransparenceItem*)pOld == aItem ) )
378*cdf0e10cSrcweir 			{
379*cdf0e10cSrcweir 				rAttrs.Put( aItem );
380*cdf0e10cSrcweir 				bModified = sal_True;
381*cdf0e10cSrcweir 			}
382*cdf0e10cSrcweir 		}
383*cdf0e10cSrcweir 	}
384*cdf0e10cSrcweir 	//add CHINA001  begin
385*cdf0e10cSrcweir 	rAttrs.Put (CntUInt16Item(SID_PAGE_TYPE,nPageType));
386*cdf0e10cSrcweir 	//add CHINA001  end
387*cdf0e10cSrcweir 	return( bModified );
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir // -----------------------------------------------------------------------
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir void SvxShadowTabPage::Reset( const SfxItemSet& rAttrs )
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	if( !bDisable )
395*cdf0e10cSrcweir 	{
396*cdf0e10cSrcweir 		// Alle Objekte koennen einen Schatten besitzen
397*cdf0e10cSrcweir 		// z.Z. gibt es nur 8 m�gliche Positionen den Schatten zu setzen
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 		// Ist Schatten gesetzt?
400*cdf0e10cSrcweir 		if( rAttrs.GetItemState( SDRATTR_SHADOW ) != SFX_ITEM_DONTCARE )
401*cdf0e10cSrcweir 		{
402*cdf0e10cSrcweir 			aTsbShowShadow.EnableTriState( sal_False );
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 			if( ( ( const SdrShadowItem& ) rAttrs.Get( SDRATTR_SHADOW ) ).GetValue() )
405*cdf0e10cSrcweir 				aTsbShowShadow.SetState( STATE_CHECK );
406*cdf0e10cSrcweir 			else
407*cdf0e10cSrcweir 			{
408*cdf0e10cSrcweir 				aTsbShowShadow.SetState( STATE_NOCHECK );
409*cdf0e10cSrcweir 			}
410*cdf0e10cSrcweir 		}
411*cdf0e10cSrcweir 		else
412*cdf0e10cSrcweir 			aTsbShowShadow.SetState( STATE_DONTKNOW );
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 		// Entfernung (nur 8 moegliche Positionen), deshalb
415*cdf0e10cSrcweir 		// wird nur ein Item ausgewertet
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 		if( rAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SFX_ITEM_DONTCARE &&
418*cdf0e10cSrcweir 			rAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SFX_ITEM_DONTCARE )
419*cdf0e10cSrcweir 		{
420*cdf0e10cSrcweir 			sal_Int32 nX = ( ( const SdrShadowXDistItem& ) rAttrs.Get( SDRATTR_SHADOWXDIST ) ).GetValue();
421*cdf0e10cSrcweir 			sal_Int32 nY = ( ( const SdrShadowYDistItem& ) rAttrs.Get( SDRATTR_SHADOWYDIST ) ).GetValue();
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 			if( nX != 0 )
424*cdf0e10cSrcweir 				SetMetricValue( aMtrDistance, nX < 0L ? -nX : nX, ePoolUnit );
425*cdf0e10cSrcweir 			else
426*cdf0e10cSrcweir 				SetMetricValue( aMtrDistance, nY < 0L ? -nY : nY, ePoolUnit );
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 			// Setzen des Schatten-Controls
429*cdf0e10cSrcweir 			if	   ( nX <  0L && nY <  0L ) aCtlPosition.SetActualRP( RP_LT );
430*cdf0e10cSrcweir 			else if( nX == 0L && nY <  0L ) aCtlPosition.SetActualRP( RP_MT );
431*cdf0e10cSrcweir 			else if( nX >  0L && nY <  0L ) aCtlPosition.SetActualRP( RP_RT );
432*cdf0e10cSrcweir 			else if( nX <  0L && nY == 0L ) aCtlPosition.SetActualRP( RP_LM );
433*cdf0e10cSrcweir 			// Mittelpunkt gibt es nicht mehr
434*cdf0e10cSrcweir 			else if( nX == 0L && nY == 0L ) aCtlPosition.SetActualRP( RP_RB );
435*cdf0e10cSrcweir 			else if( nX >  0L && nY == 0L ) aCtlPosition.SetActualRP( RP_RM );
436*cdf0e10cSrcweir 			else if( nX <  0L && nY >  0L ) aCtlPosition.SetActualRP( RP_LB );
437*cdf0e10cSrcweir 			else if( nX == 0L && nY >  0L ) aCtlPosition.SetActualRP( RP_MB );
438*cdf0e10cSrcweir 			else if( nX >  0L && nY >  0L ) aCtlPosition.SetActualRP( RP_RB );
439*cdf0e10cSrcweir 		}
440*cdf0e10cSrcweir 		else
441*cdf0e10cSrcweir 		{
442*cdf0e10cSrcweir 			// determine default-distance
443*cdf0e10cSrcweir 			SfxItemPool* pPool = rOutAttrs.GetPool();
444*cdf0e10cSrcweir 			SdrShadowXDistItem* pXDistItem = (SdrShadowXDistItem*)&pPool->GetDefaultItem (SDRATTR_SHADOWXDIST);
445*cdf0e10cSrcweir 			SdrShadowYDistItem* pYDistItem = (SdrShadowYDistItem*)&pPool->GetDefaultItem (SDRATTR_SHADOWYDIST);
446*cdf0e10cSrcweir 			if (pXDistItem && pYDistItem)
447*cdf0e10cSrcweir 			{
448*cdf0e10cSrcweir 				sal_Int32 nX = pXDistItem->GetValue();
449*cdf0e10cSrcweir 				sal_Int32 nY = pYDistItem->GetValue();
450*cdf0e10cSrcweir 				if( nX != 0 )
451*cdf0e10cSrcweir 					SetMetricValue( aMtrDistance, nX < 0L ? -nX : nX, ePoolUnit );
452*cdf0e10cSrcweir 				else
453*cdf0e10cSrcweir 					SetMetricValue( aMtrDistance, nY < 0L ? -nY : nY, ePoolUnit );
454*cdf0e10cSrcweir 			}
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 			// Tristate, z.B. mehrer Objekte wurden markiert, wovon einige einen Schatten besitzen, einige nicht.
457*cdf0e10cSrcweir 			// Der anzuzeigende Text des MetricFields wird auf "" gesetzt und dient in der Methode FillItemSet
458*cdf0e10cSrcweir 			// als Erkennungszeichen daf�r, das der Distance-Wert NICHT ver�ndert wurde !!!!
459*cdf0e10cSrcweir 			aMtrDistance.SetText( String() );
460*cdf0e10cSrcweir 			aCtlPosition.SetActualRP( RP_MM );
461*cdf0e10cSrcweir 		}
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 		// SchattenFarbe:
464*cdf0e10cSrcweir 		if( rAttrs.GetItemState( SDRATTR_SHADOWCOLOR ) != SFX_ITEM_DONTCARE )
465*cdf0e10cSrcweir 		{
466*cdf0e10cSrcweir 			aLbShadowColor.SelectEntry( ( ( const SdrShadowColorItem& ) rAttrs.Get( SDRATTR_SHADOWCOLOR ) ).GetColorValue() );
467*cdf0e10cSrcweir 		}
468*cdf0e10cSrcweir 		else
469*cdf0e10cSrcweir 			aLbShadowColor.SetNoSelection();
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 		// Transparenz
472*cdf0e10cSrcweir 		if( rAttrs.GetItemState( SDRATTR_SHADOWTRANSPARENCE ) != SFX_ITEM_DONTCARE )
473*cdf0e10cSrcweir 		{
474*cdf0e10cSrcweir 			sal_uInt16 nTransp = ( ( const SdrShadowTransparenceItem& ) rAttrs.Get( SDRATTR_SHADOWTRANSPARENCE ) ).GetValue();
475*cdf0e10cSrcweir 			aMtrTransparent.SetValue( nTransp );
476*cdf0e10cSrcweir 		}
477*cdf0e10cSrcweir 		else
478*cdf0e10cSrcweir 			aMtrTransparent.SetText( String() );
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 		// Werte sichern
481*cdf0e10cSrcweir 		//aCtlPosition
482*cdf0e10cSrcweir 		aMtrDistance.SaveValue();
483*cdf0e10cSrcweir 		aLbShadowColor.SaveValue();
484*cdf0e10cSrcweir 		aTsbShowShadow.SaveValue();
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 		// #66832# This field was not saved, but used to determine changes.
487*cdf0e10cSrcweir 		// Why? Seems to be the error.
488*cdf0e10cSrcweir 		// It IS the error.
489*cdf0e10cSrcweir 		aMtrTransparent.SaveValue();
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 		ClickShadowHdl_Impl( NULL );
492*cdf0e10cSrcweir 		ModifyShadowHdl_Impl( NULL );
493*cdf0e10cSrcweir 	}
494*cdf0e10cSrcweir }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir // -----------------------------------------------------------------------
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir SfxTabPage* SvxShadowTabPage::Create( Window* pWindow,
499*cdf0e10cSrcweir 				const SfxItemSet& rAttrs )
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir 	return( new SvxShadowTabPage( pWindow, rAttrs ) );
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir //------------------------------------------------------------------------
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir sal_uInt16*	SvxShadowTabPage::GetRanges()
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir 	return( pShadowRanges );
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir //------------------------------------------------------------------------
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir IMPL_LINK( SvxShadowTabPage, ClickShadowHdl_Impl, void *, EMPTYARG )
514*cdf0e10cSrcweir {
515*cdf0e10cSrcweir 	if( aTsbShowShadow.GetState() == STATE_NOCHECK )
516*cdf0e10cSrcweir 	{
517*cdf0e10cSrcweir 		aFtPosition.Disable();
518*cdf0e10cSrcweir 		aCtlPosition.Disable();
519*cdf0e10cSrcweir 		aFtDistance.Disable();
520*cdf0e10cSrcweir 		aMtrDistance.Disable();
521*cdf0e10cSrcweir 		aFtShadowColor.Disable();
522*cdf0e10cSrcweir 		aLbShadowColor.Disable();
523*cdf0e10cSrcweir 		aFtTransparent.Disable();
524*cdf0e10cSrcweir 		aMtrTransparent.Disable();
525*cdf0e10cSrcweir 	}
526*cdf0e10cSrcweir 	else
527*cdf0e10cSrcweir 	{
528*cdf0e10cSrcweir 		aFtPosition.Enable();
529*cdf0e10cSrcweir 		aCtlPosition.Enable();
530*cdf0e10cSrcweir 		aFtDistance.Enable();
531*cdf0e10cSrcweir 		aMtrDistance.Enable();
532*cdf0e10cSrcweir 		aFtShadowColor.Enable();
533*cdf0e10cSrcweir 		aLbShadowColor.Enable();
534*cdf0e10cSrcweir 		aFtTransparent.Enable();
535*cdf0e10cSrcweir 		aMtrTransparent.Enable();
536*cdf0e10cSrcweir 	}
537*cdf0e10cSrcweir 	aCtlPosition.Invalidate();
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 	ModifyShadowHdl_Impl( NULL );
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 	return( 0L );
542*cdf0e10cSrcweir }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir //------------------------------------------------------------------------
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir IMPL_LINK( SvxShadowTabPage, ModifyShadowHdl_Impl, void *, EMPTYARG )
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir 	if( aTsbShowShadow.GetState() == STATE_CHECK )
549*cdf0e10cSrcweir 		rXFSet.Put( XFillStyleItem( XFILL_SOLID ) );
550*cdf0e10cSrcweir 	else
551*cdf0e10cSrcweir 		rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 	sal_uInt16 nPos = aLbShadowColor.GetSelectEntryPos();
554*cdf0e10cSrcweir 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
555*cdf0e10cSrcweir 	{
556*cdf0e10cSrcweir 		rXFSet.Put( XFillColorItem( String(),
557*cdf0e10cSrcweir 						aLbShadowColor.GetSelectEntryColor() ) );
558*cdf0e10cSrcweir 	}
559*cdf0e10cSrcweir 	sal_uInt16 nVal = (sal_uInt16)aMtrTransparent.GetValue();
560*cdf0e10cSrcweir 	XFillTransparenceItem aItem( nVal );
561*cdf0e10cSrcweir 	rXFSet.Put( XFillTransparenceItem( aItem ) );
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 	// Schatten-Entfernung
564*cdf0e10cSrcweir 	sal_Int32 nX = 0L, nY = 0L;
565*cdf0e10cSrcweir 	sal_Int32 nXY = GetCoreValue( aMtrDistance, ePoolUnit );
566*cdf0e10cSrcweir 	switch( aCtlPosition.GetActualRP() )
567*cdf0e10cSrcweir 	{
568*cdf0e10cSrcweir 		case RP_LT: nX = nY = -nXY; 	 break;
569*cdf0e10cSrcweir 		case RP_MT: nY = -nXY;			 break;
570*cdf0e10cSrcweir 		case RP_RT: nX = nXY; nY = -nXY; break;
571*cdf0e10cSrcweir 		case RP_LM: nX = -nXY;			 break;
572*cdf0e10cSrcweir 		case RP_RM: nX = nXY;			 break;
573*cdf0e10cSrcweir 		case RP_LB: nX = -nXY; nY = nXY; break;
574*cdf0e10cSrcweir 		case RP_MB: nY = nXY; 			 break;
575*cdf0e10cSrcweir 		case RP_RB: nX = nY = nXY; 		 break;
576*cdf0e10cSrcweir         case RP_MM: break;
577*cdf0e10cSrcweir     }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir     aCtlXRectPreview.SetShadowPosition(Point(nX, nY));
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir 	aCtlXRectPreview.SetShadowAttributes(aXFillAttr.GetItemSet());
582*cdf0e10cSrcweir 	//aCtlXRectPreview.SetFillAttr( aXFillAttr );
583*cdf0e10cSrcweir 	aCtlXRectPreview.Invalidate();
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 	return( 0L );
586*cdf0e10cSrcweir }
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir //------------------------------------------------------------------------
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir void SvxShadowTabPage::PointChanged( Window* pWindow, RECT_POINT eRcPt )
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir 	eRP = eRcPt;
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 	// Schatten neu zeichnen
595*cdf0e10cSrcweir 	ModifyShadowHdl_Impl( pWindow );
596*cdf0e10cSrcweir }
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir void SvxShadowTabPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
599*cdf0e10cSrcweir {
600*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pColorTabItem,SvxColorTableItem,SID_COLOR_TABLE,sal_False);
601*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pPageTypeItem,SfxUInt16Item,SID_PAGE_TYPE,sal_False);
602*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pDlgTypeItem,SfxUInt16Item,SID_DLG_TYPE,sal_False);
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir 	if (pColorTabItem)
606*cdf0e10cSrcweir 		SetColorTable(pColorTabItem->GetColorTable());
607*cdf0e10cSrcweir 	if (pPageTypeItem)
608*cdf0e10cSrcweir 		SetPageType(pPageTypeItem->GetValue());
609*cdf0e10cSrcweir 	if (pDlgTypeItem)
610*cdf0e10cSrcweir 		SetDlgType(pDlgTypeItem->GetValue());
611*cdf0e10cSrcweir 	Construct();
612*cdf0e10cSrcweir }
613