xref: /AOO41X/main/svx/source/dialog/grfflt.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_svx.hxx"
30*cdf0e10cSrcweir #include <tools/shl.hxx>
31*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
33*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
34*cdf0e10cSrcweir #ifndef _SFXOBJSH_HXX
35*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #include <sfx2/request.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
40*cdf0e10cSrcweir #include <svx/grfflt.hxx>
41*cdf0e10cSrcweir //#include "grfflt.hrc"
42*cdf0e10cSrcweir #include <svx/dialogs.hrc>
43*cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir // --------------------
46*cdf0e10cSrcweir // - SvxGraphicFilter -
47*cdf0e10cSrcweir // --------------------
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject )
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir 	const Graphic&	rGraphic = rFilterObject.GetGraphic();
52*cdf0e10cSrcweir 	sal_uIntPtr			nRet = SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 	if( rGraphic.GetType() == GRAPHIC_BITMAP )
55*cdf0e10cSrcweir 	{
56*cdf0e10cSrcweir 		SfxViewFrame*	pViewFrame = SfxViewFrame::Current();
57*cdf0e10cSrcweir 		SfxObjectShell*	pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
58*cdf0e10cSrcweir 		Window*			pWindow = ( pViewFrame && pViewFrame->GetViewShell() ) ? pViewFrame->GetViewShell()->GetWindow() : NULL;
59*cdf0e10cSrcweir 		Graphic			aGraphic;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 		switch( rReq.GetSlot() )
62*cdf0e10cSrcweir 		{
63*cdf0e10cSrcweir 			case( SID_GRFFILTER_INVERT ):
64*cdf0e10cSrcweir 			{
65*cdf0e10cSrcweir 				if( pShell )
66*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_True );
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 				if( rGraphic.IsAnimated() )
69*cdf0e10cSrcweir 				{
70*cdf0e10cSrcweir 					Animation aAnimation( rGraphic.GetAnimation() );
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 					if( aAnimation.Invert() )
73*cdf0e10cSrcweir 						aGraphic = aAnimation;
74*cdf0e10cSrcweir 				}
75*cdf0e10cSrcweir 				else
76*cdf0e10cSrcweir 				{
77*cdf0e10cSrcweir 					BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 					if( aBmpEx.Invert() )
80*cdf0e10cSrcweir 						aGraphic = aBmpEx;
81*cdf0e10cSrcweir 				}
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 				if( pShell )
84*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_False );
85*cdf0e10cSrcweir 			}
86*cdf0e10cSrcweir 			break;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 			case( SID_GRFFILTER_SMOOTH ):
89*cdf0e10cSrcweir 			{
90*cdf0e10cSrcweir 				if( pShell )
91*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_True );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 				if( rGraphic.IsAnimated() )
94*cdf0e10cSrcweir 				{
95*cdf0e10cSrcweir 					Animation aAnimation( rGraphic.GetAnimation() );
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 					if( aAnimation.Filter( BMP_FILTER_SMOOTH ) )
98*cdf0e10cSrcweir 						aGraphic = aAnimation;
99*cdf0e10cSrcweir 				}
100*cdf0e10cSrcweir 				else
101*cdf0e10cSrcweir 				{
102*cdf0e10cSrcweir 					BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 					if( aBmpEx.Filter( BMP_FILTER_SMOOTH ) )
105*cdf0e10cSrcweir 						aGraphic = aBmpEx;
106*cdf0e10cSrcweir 				}
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 				if( pShell )
109*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_False );
110*cdf0e10cSrcweir 			}
111*cdf0e10cSrcweir 			break;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 			case( SID_GRFFILTER_SHARPEN ):
114*cdf0e10cSrcweir 			{
115*cdf0e10cSrcweir 				if( pShell )
116*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_True );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 				if( rGraphic.IsAnimated() )
119*cdf0e10cSrcweir 				{
120*cdf0e10cSrcweir 					Animation aAnimation( rGraphic.GetAnimation() );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 					if( aAnimation.Filter( BMP_FILTER_SHARPEN ) )
123*cdf0e10cSrcweir 						aGraphic = aAnimation;
124*cdf0e10cSrcweir 				}
125*cdf0e10cSrcweir 				else
126*cdf0e10cSrcweir 				{
127*cdf0e10cSrcweir 					BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 					if( aBmpEx.Filter( BMP_FILTER_SHARPEN ) )
130*cdf0e10cSrcweir 						aGraphic = aBmpEx;
131*cdf0e10cSrcweir 				}
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 				if( pShell )
134*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_False );
135*cdf0e10cSrcweir 			}
136*cdf0e10cSrcweir 			break;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 			case( SID_GRFFILTER_REMOVENOISE ):
139*cdf0e10cSrcweir 			{
140*cdf0e10cSrcweir 				if( pShell )
141*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_True );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 				if( rGraphic.IsAnimated() )
144*cdf0e10cSrcweir 				{
145*cdf0e10cSrcweir 					Animation aAnimation( rGraphic.GetAnimation() );
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 					if( aAnimation.Filter( BMP_FILTER_REMOVENOISE ) )
148*cdf0e10cSrcweir 						aGraphic = aAnimation;
149*cdf0e10cSrcweir 				}
150*cdf0e10cSrcweir 				else
151*cdf0e10cSrcweir 				{
152*cdf0e10cSrcweir 					BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 					if( aBmpEx.Filter( BMP_FILTER_REMOVENOISE ) )
155*cdf0e10cSrcweir 						aGraphic = aBmpEx;
156*cdf0e10cSrcweir 				}
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 				if( pShell )
159*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_False );
160*cdf0e10cSrcweir 			}
161*cdf0e10cSrcweir 			break;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 			case( SID_GRFFILTER_SOBEL ):
164*cdf0e10cSrcweir 			{
165*cdf0e10cSrcweir 				if( pShell )
166*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_True );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 				if( rGraphic.IsAnimated() )
169*cdf0e10cSrcweir 				{
170*cdf0e10cSrcweir 					Animation aAnimation( rGraphic.GetAnimation() );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 					if( aAnimation.Filter( BMP_FILTER_SOBEL_GREY ) )
173*cdf0e10cSrcweir 						aGraphic = aAnimation;
174*cdf0e10cSrcweir 				}
175*cdf0e10cSrcweir 				else
176*cdf0e10cSrcweir 				{
177*cdf0e10cSrcweir 					BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 					if( aBmpEx.Filter( BMP_FILTER_SOBEL_GREY ) )
180*cdf0e10cSrcweir 						aGraphic = aBmpEx;
181*cdf0e10cSrcweir 				}
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 				if( pShell )
184*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_False );
185*cdf0e10cSrcweir 			}
186*cdf0e10cSrcweir 			break;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 			case( SID_GRFFILTER_MOSAIC ):
189*cdf0e10cSrcweir 			{
190*cdf0e10cSrcweir 				//CHINA001 GraphicFilterMosaic aDlg( pWindow, rGraphic, 4, 4, sal_False );
191*cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
192*cdf0e10cSrcweir 				if(pFact)
193*cdf0e10cSrcweir 				{
194*cdf0e10cSrcweir 					AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic( pWindow, rGraphic, 4, 4, sal_False, RID_SVX_GRFFILTER_DLG_MOSAIC);
195*cdf0e10cSrcweir 					DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
196*cdf0e10cSrcweir 					if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
197*cdf0e10cSrcweir 						aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
198*cdf0e10cSrcweir 					delete aDlg; //add by CHINA001
199*cdf0e10cSrcweir 				}
200*cdf0e10cSrcweir 			}
201*cdf0e10cSrcweir 			break;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 			case( SID_GRFFILTER_EMBOSS	):
204*cdf0e10cSrcweir 			{
205*cdf0e10cSrcweir 				//CHINA001 GraphicFilterEmboss aDlg( pWindow, rGraphic, RP_MM );
206*cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
207*cdf0e10cSrcweir 				if(pFact)
208*cdf0e10cSrcweir 				{
209*cdf0e10cSrcweir 					AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss( pWindow, rGraphic, RP_MM, RID_SVX_GRFFILTER_DLG_EMBOSS );
210*cdf0e10cSrcweir 					DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
211*cdf0e10cSrcweir 					if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
212*cdf0e10cSrcweir 						aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
213*cdf0e10cSrcweir 					delete aDlg; //add by CHINA001
214*cdf0e10cSrcweir 				}
215*cdf0e10cSrcweir 			}
216*cdf0e10cSrcweir 			break;
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 			case( SID_GRFFILTER_POSTER	):
219*cdf0e10cSrcweir 			{
220*cdf0e10cSrcweir 				//CHINA001 GraphicFilterPoster aDlg( pWindow, rGraphic, 16 );
221*cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
222*cdf0e10cSrcweir 				if(pFact)
223*cdf0e10cSrcweir 				{
224*cdf0e10cSrcweir 					AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 16, RID_SVX_GRFFILTER_DLG_POSTER );
225*cdf0e10cSrcweir 					DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
226*cdf0e10cSrcweir 					if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
227*cdf0e10cSrcweir 						aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
228*cdf0e10cSrcweir 					delete aDlg; //add by CHINA001
229*cdf0e10cSrcweir 				}
230*cdf0e10cSrcweir 			}
231*cdf0e10cSrcweir 			break;
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 			case( SID_GRFFILTER_POPART	):
234*cdf0e10cSrcweir 			{
235*cdf0e10cSrcweir 				if( pShell )
236*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_True );
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 				if( rGraphic.IsAnimated() )
239*cdf0e10cSrcweir 				{
240*cdf0e10cSrcweir 					Animation aAnimation( rGraphic.GetAnimation() );
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 					if( aAnimation.Filter( BMP_FILTER_POPART ) )
243*cdf0e10cSrcweir 						aGraphic = aAnimation;
244*cdf0e10cSrcweir 				}
245*cdf0e10cSrcweir 				else
246*cdf0e10cSrcweir 				{
247*cdf0e10cSrcweir 					BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 					if( aBmpEx.Filter( BMP_FILTER_POPART ) )
250*cdf0e10cSrcweir 						aGraphic = aBmpEx;
251*cdf0e10cSrcweir 				}
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 				if( pShell )
254*cdf0e10cSrcweir 					pShell->SetWaitCursor( sal_False );
255*cdf0e10cSrcweir 			}
256*cdf0e10cSrcweir 			break;
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 			case( SID_GRFFILTER_SEPIA ):
259*cdf0e10cSrcweir 			{
260*cdf0e10cSrcweir 				//CHINA001 GraphicFilterSepia aDlg( pWindow, rGraphic, 10 );
261*cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
262*cdf0e10cSrcweir 				if(pFact)
263*cdf0e10cSrcweir 				{
264*cdf0e10cSrcweir 					AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 10, RID_SVX_GRFFILTER_DLG_SEPIA );
265*cdf0e10cSrcweir 					DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
266*cdf0e10cSrcweir 					if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
267*cdf0e10cSrcweir 						aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
268*cdf0e10cSrcweir 					delete aDlg; //add by CHINA001
269*cdf0e10cSrcweir 				}
270*cdf0e10cSrcweir 			}
271*cdf0e10cSrcweir 			break;
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 			case( SID_GRFFILTER_SOLARIZE ):
274*cdf0e10cSrcweir 			{
275*cdf0e10cSrcweir 				//CHINA001 GraphicFilterSolarize aDlg( pWindow, rGraphic, 128, sal_False );
276*cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
277*cdf0e10cSrcweir 				if(pFact)
278*cdf0e10cSrcweir 				{
279*cdf0e10cSrcweir 					AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize( pWindow, rGraphic, 128, sal_False, RID_SVX_GRFFILTER_DLG_SOLARIZE );
280*cdf0e10cSrcweir 					DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
281*cdf0e10cSrcweir 					if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
282*cdf0e10cSrcweir 						aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
283*cdf0e10cSrcweir 					delete aDlg; //add by CHINA001
284*cdf0e10cSrcweir 				}
285*cdf0e10cSrcweir 			}
286*cdf0e10cSrcweir 			break;
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir             case SID_GRFFILTER :
289*cdf0e10cSrcweir             {
290*cdf0e10cSrcweir                 // do nothing; no error
291*cdf0e10cSrcweir                 nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
292*cdf0e10cSrcweir                 break;
293*cdf0e10cSrcweir             }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 			default:
296*cdf0e10cSrcweir 			{
297*cdf0e10cSrcweir 				DBG_ERROR( "SvxGraphicFilter: selected filter slot not yet implemented" );
298*cdf0e10cSrcweir 				nRet = SVX_GRAPHICFILTER_UNSUPPORTED_SLOT;
299*cdf0e10cSrcweir 			}
300*cdf0e10cSrcweir 			break;
301*cdf0e10cSrcweir 		}
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 		if( aGraphic.GetType() != GRAPHIC_NONE )
304*cdf0e10cSrcweir 		{
305*cdf0e10cSrcweir 			rFilterObject.SetGraphic( aGraphic );
306*cdf0e10cSrcweir 			nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
307*cdf0e10cSrcweir 		}
308*cdf0e10cSrcweir 	}
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	return nRet;
311*cdf0e10cSrcweir }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir // -----------------------------------------------------------------------------
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir void SvxGraphicFilter::DisableGraphicFilterSlots( SfxItemSet& rSet )
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER ) )
318*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_INVERT ) )
321*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_INVERT );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SMOOTH ) )
324*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_SMOOTH );
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SHARPEN ) )
327*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_SHARPEN );
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_REMOVENOISE ) )
330*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_REMOVENOISE );
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOBEL ) )
333*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_SOBEL );
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_MOSAIC ) )
336*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_MOSAIC );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_EMBOSS ) )
339*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_EMBOSS );
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POSTER ) )
342*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_POSTER );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POPART ) )
345*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_POPART );
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SEPIA ) )
348*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_SEPIA );
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOLARIZE ) )
351*cdf0e10cSrcweir 		rSet.DisableItem( SID_GRFFILTER_SOLARIZE );
352*cdf0e10cSrcweir };
353*cdf0e10cSrcweir /* CHINA001 move to cuigrfflt.cxx
354*cdf0e10cSrcweir // --------------------------------------
355*cdf0e10cSrcweir // - GraphicFilterDialog::PreviewWindow -
356*cdf0e10cSrcweir // --------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir GraphicFilterDialog::PreviewWindow::PreviewWindow( Window* pParent, const ResId& rResId ) :
359*cdf0e10cSrcweir 	Control( pParent, rResId )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir // -----------------------------------------------------------------------------
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir GraphicFilterDialog::PreviewWindow::~PreviewWindow()
366*cdf0e10cSrcweir {
367*cdf0e10cSrcweir }
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir // -----------------------------------------------------------------------------
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir void GraphicFilterDialog::PreviewWindow::Paint( const Rectangle& rRect )
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir 	Control::Paint( rRect );
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 	const Size	aGrfSize( LogicToPixel( maGraphic.GetPrefSize(), maGraphic.GetPrefMapMode() ) );
376*cdf0e10cSrcweir 	const Size	aOutSize( GetOutputSizePixel() );
377*cdf0e10cSrcweir 	const Point aGrfPos( ( aOutSize.Width() - aGrfSize.Width() ) >> 1,
378*cdf0e10cSrcweir 						 ( aOutSize.Height() - aGrfSize.Height() ) >> 1 );
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	if( maGraphic.IsAnimated() )
381*cdf0e10cSrcweir 		maGraphic.StartAnimation( this , aGrfPos, aGrfSize );
382*cdf0e10cSrcweir 	else
383*cdf0e10cSrcweir 		maGraphic.Draw( this, aGrfPos, aGrfSize );
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir // -----------------------------------------------------------------------------
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir void GraphicFilterDialog::PreviewWindow::SetGraphic( const Graphic& rGraphic )
389*cdf0e10cSrcweir {
390*cdf0e10cSrcweir 	maGraphic = rGraphic;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir 	if( maGraphic.IsAnimated() || maGraphic.IsTransparent() )
393*cdf0e10cSrcweir 		Invalidate();
394*cdf0e10cSrcweir 	else
395*cdf0e10cSrcweir 		Paint( Rectangle( Point(), GetOutputSizePixel() ) );
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir // -----------------------
399*cdf0e10cSrcweir // - GraphicFilterDialog -
400*cdf0e10cSrcweir // -----------------------
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir GraphicFilterDialog::GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic ) :
403*cdf0e10cSrcweir 	ModalDialog		( pParent, rResId ),
404*cdf0e10cSrcweir 	mfScaleX		( 0.0 ),
405*cdf0e10cSrcweir 	mfScaleY		( 0.0 ),
406*cdf0e10cSrcweir 	maSizePixel		( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) ),
407*cdf0e10cSrcweir 	maModifyHdl		( LINK( this, GraphicFilterDialog, ImplModifyHdl ) ),
408*cdf0e10cSrcweir 	maPreview		( this, SVX_RES( CTL_PREVIEW ) ),
409*cdf0e10cSrcweir 	maFlParameter	( this, SVX_RES( FL_PARAMETER ) ),
410*cdf0e10cSrcweir 	maBtnOK			( this, SVX_RES( BTN_OK ) ),
411*cdf0e10cSrcweir 	maBtnCancel		( this, SVX_RES( BTN_CANCEL ) ),
412*cdf0e10cSrcweir 	maBtnHelp		( this, SVX_RES( BTN_HELP ) )
413*cdf0e10cSrcweir {
414*cdf0e10cSrcweir 	const Size	aPreviewSize( maPreview.GetOutputSizePixel() );
415*cdf0e10cSrcweir 	Size		aGrfSize( maSizePixel );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	if( rGraphic.GetType() == GRAPHIC_BITMAP &&
418*cdf0e10cSrcweir 		aPreviewSize.Width() && aPreviewSize.Height() &&
419*cdf0e10cSrcweir 		aGrfSize.Width() && aGrfSize.Height() )
420*cdf0e10cSrcweir 	{
421*cdf0e10cSrcweir 		const double fGrfWH = (double) aGrfSize.Width() / aGrfSize.Height();
422*cdf0e10cSrcweir 		const double fPreWH = (double) aPreviewSize.Width() / aPreviewSize.Height();
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 		if( fGrfWH < fPreWH )
425*cdf0e10cSrcweir 		{
426*cdf0e10cSrcweir 			aGrfSize.Width() = (long) ( aPreviewSize.Height() * fGrfWH );
427*cdf0e10cSrcweir 			aGrfSize.Height()= aPreviewSize.Height();
428*cdf0e10cSrcweir 		}
429*cdf0e10cSrcweir 		else
430*cdf0e10cSrcweir 		{
431*cdf0e10cSrcweir 			aGrfSize.Width() = aPreviewSize.Width();
432*cdf0e10cSrcweir 			aGrfSize.Height()= (long) ( aPreviewSize.Width() / fGrfWH);
433*cdf0e10cSrcweir 		}
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 		mfScaleX = (double) aGrfSize.Width() / maSizePixel.Width();
436*cdf0e10cSrcweir 		mfScaleY = (double) aGrfSize.Height() / maSizePixel.Height();
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 		if( !rGraphic.IsAnimated() )
439*cdf0e10cSrcweir 		{
440*cdf0e10cSrcweir 			BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 			if( aBmpEx.Scale( aGrfSize, BMP_SCALE_INTERPOLATE ) )
443*cdf0e10cSrcweir 				maGraphic = aBmpEx;
444*cdf0e10cSrcweir 		}
445*cdf0e10cSrcweir 	}
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	maTimer.SetTimeoutHdl( LINK( this, GraphicFilterDialog, ImplPreviewTimeoutHdl ) );
448*cdf0e10cSrcweir 	maTimer.SetTimeout( 100 );
449*cdf0e10cSrcweir 	ImplModifyHdl( NULL );
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir // -----------------------------------------------------------------------------
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir GraphicFilterDialog::~GraphicFilterDialog()
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir // -----------------------------------------------------------------------------
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir IMPL_LINK( GraphicFilterDialog, ImplPreviewTimeoutHdl, Timer*, pTimer )
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir 	maTimer.Stop();
463*cdf0e10cSrcweir 	maPreview.SetGraphic( GetFilteredGraphic( maGraphic, mfScaleX, mfScaleY ) );
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 	return 0;
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir // -----------------------------------------------------------------------------
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir IMPL_LINK( GraphicFilterDialog, ImplModifyHdl, void*, p )
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir 	if( maGraphic.GetType() == GRAPHIC_BITMAP )
473*cdf0e10cSrcweir 	{
474*cdf0e10cSrcweir 		maTimer.Stop();
475*cdf0e10cSrcweir 		maTimer.Start();
476*cdf0e10cSrcweir 	}
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 	return 0;
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir // ----------------
482*cdf0e10cSrcweir // - FilterMosaic -
483*cdf0e10cSrcweir // ----------------
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir GraphicFilterMosaic::GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
486*cdf0e10cSrcweir 										  sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges ) :
487*cdf0e10cSrcweir 	GraphicFilterDialog( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_MOSAIC ), rGraphic ),
488*cdf0e10cSrcweir 	maFtWidth	( this, SVX_RES( DLG_FILTERMOSAIC_FT_WIDTH ) ),
489*cdf0e10cSrcweir 	maMtrWidth	( this, SVX_RES( DLG_FILTERMOSAIC_MTR_WIDTH ) ),
490*cdf0e10cSrcweir 	maFtHeight	( this, SVX_RES( DLG_FILTERMOSAIC_FT_HEIGHT ) ),
491*cdf0e10cSrcweir 	maMtrHeight ( this, SVX_RES( DLG_FILTERMOSAIC_MTR_HEIGHT ) ),
492*cdf0e10cSrcweir 	maCbxEdges	( this, SVX_RES( DLG_FILTERMOSAIC_CBX_EDGES ) )
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir 	FreeResource();
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	maMtrWidth.SetValue( nTileWidth );
497*cdf0e10cSrcweir 	maMtrWidth.SetLast( GetGraphicSizePixel().Width() );
498*cdf0e10cSrcweir 	maMtrWidth.SetModifyHdl( GetModifyHdl() );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	maMtrHeight.SetValue( nTileHeight );
501*cdf0e10cSrcweir 	maMtrHeight.SetLast( GetGraphicSizePixel().Height() );
502*cdf0e10cSrcweir 	maMtrHeight.SetModifyHdl( GetModifyHdl() );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 	maCbxEdges.Check( bEnhanceEdges );
505*cdf0e10cSrcweir 	maCbxEdges.SetToggleHdl( GetModifyHdl() );
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 	maMtrWidth.GrabFocus();
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir // -----------------------------------------------------------------------------
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir GraphicFilterMosaic::~GraphicFilterMosaic()
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir }
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir // -----------------------------------------------------------------------------
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir Graphic	GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic,
519*cdf0e10cSrcweir 												 double fScaleX, double fScaleY )
520*cdf0e10cSrcweir {
521*cdf0e10cSrcweir 	Graphic			aRet;
522*cdf0e10cSrcweir 	const Size		aSize( Max( FRound( GetTileWidth() * fScaleX ), 1L ),
523*cdf0e10cSrcweir 						   Max( FRound( GetTileHeight() * fScaleY ), 1L ) );
524*cdf0e10cSrcweir 	BmpFilterParam	aParam( aSize );
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 	if( rGraphic.IsAnimated() )
527*cdf0e10cSrcweir 	{
528*cdf0e10cSrcweir 		Animation aAnim( rGraphic.GetAnimation() );
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 		if( aAnim.Filter( BMP_FILTER_MOSAIC, &aParam ) )
531*cdf0e10cSrcweir 		{
532*cdf0e10cSrcweir 			if( IsEnhanceEdges() )
533*cdf0e10cSrcweir 				aAnim.Filter( BMP_FILTER_SHARPEN );
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 			aRet = aAnim;
536*cdf0e10cSrcweir 		}
537*cdf0e10cSrcweir 	}
538*cdf0e10cSrcweir 	else
539*cdf0e10cSrcweir 	{
540*cdf0e10cSrcweir 		BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 		if( aBmpEx.Filter( BMP_FILTER_MOSAIC, &aParam ) )
543*cdf0e10cSrcweir 		{
544*cdf0e10cSrcweir 			if( IsEnhanceEdges() )
545*cdf0e10cSrcweir 				aBmpEx.Filter( BMP_FILTER_SHARPEN );
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir 			aRet = aBmpEx;
548*cdf0e10cSrcweir 		}
549*cdf0e10cSrcweir 	}
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	return aRet;
552*cdf0e10cSrcweir }
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir // ------------------
555*cdf0e10cSrcweir // - GraphicFilterSolarize -
556*cdf0e10cSrcweir // ------------------
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir GraphicFilterSolarize::GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
559*cdf0e10cSrcweir 											  sal_uInt8 cGreyThreshold, sal_Bool bInvert ) :
560*cdf0e10cSrcweir 	GraphicFilterDialog	( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_SOLARIZE ), rGraphic ),
561*cdf0e10cSrcweir 	maFtThreshold	( this, SVX_RES( DLG_FILTERSOLARIZE_FT_THRESHOLD ) ),
562*cdf0e10cSrcweir 	maMtrThreshold	( this, SVX_RES( DLG_FILTERSOLARIZE_MTR_THRESHOLD ) ),
563*cdf0e10cSrcweir 	maCbxInvert		( this, SVX_RES( DLG_FILTERSOLARIZE_CBX_INVERT ) )
564*cdf0e10cSrcweir {
565*cdf0e10cSrcweir 	FreeResource();
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 	maMtrThreshold.SetValue( FRound( cGreyThreshold / 2.55 ) );
568*cdf0e10cSrcweir 	maMtrThreshold.SetModifyHdl( GetModifyHdl() );
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir 	maCbxInvert.Check( bInvert );
571*cdf0e10cSrcweir 	maCbxInvert.SetToggleHdl( GetModifyHdl() );
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir 	maMtrThreshold.GrabFocus();
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir // -----------------------------------------------------------------------------
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir GraphicFilterSolarize::~GraphicFilterSolarize()
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir // -----------------------------------------------------------------------------
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir Graphic	GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic,
585*cdf0e10cSrcweir 												   double fScaleX, double fScaleY )
586*cdf0e10cSrcweir {
587*cdf0e10cSrcweir 	Graphic			aRet;
588*cdf0e10cSrcweir 	BmpFilterParam	aParam( GetGreyThreshold() );
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 	if( rGraphic.IsAnimated() )
591*cdf0e10cSrcweir 	{
592*cdf0e10cSrcweir 		Animation aAnim( rGraphic.GetAnimation() );
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 		if( aAnim.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
595*cdf0e10cSrcweir 		{
596*cdf0e10cSrcweir 			if( IsInvert() )
597*cdf0e10cSrcweir 				aAnim.Invert();
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 			aRet = aAnim;
600*cdf0e10cSrcweir 		}
601*cdf0e10cSrcweir 	}
602*cdf0e10cSrcweir 	else
603*cdf0e10cSrcweir 	{
604*cdf0e10cSrcweir 		BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 		if( aBmpEx.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
607*cdf0e10cSrcweir 		{
608*cdf0e10cSrcweir 			if( IsInvert() )
609*cdf0e10cSrcweir 				aBmpEx.Invert();
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 			aRet = aBmpEx;
612*cdf0e10cSrcweir 		}
613*cdf0e10cSrcweir 	}
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 	return aRet;
616*cdf0e10cSrcweir }
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir // ----------------------
619*cdf0e10cSrcweir // - GraphicFilterSepia -
620*cdf0e10cSrcweir // ----------------------
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir GraphicFilterSepia::GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
623*cdf0e10cSrcweir 										sal_uInt16 nSepiaPercent ) :
624*cdf0e10cSrcweir 	GraphicFilterDialog	( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_SEPIA ), rGraphic ),
625*cdf0e10cSrcweir 	maFtSepia		( this, SVX_RES( DLG_FILTERSEPIA_FT_SEPIA ) ),
626*cdf0e10cSrcweir 	maMtrSepia		( this, SVX_RES( DLG_FILTERSEPIA_MTR_SEPIA ) )
627*cdf0e10cSrcweir {
628*cdf0e10cSrcweir 	FreeResource();
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir 	maMtrSepia.SetValue( nSepiaPercent );
631*cdf0e10cSrcweir 	maMtrSepia.SetModifyHdl( GetModifyHdl() );
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir 	maMtrSepia.GrabFocus();
634*cdf0e10cSrcweir }
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir // -----------------------------------------------------------------------------
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir GraphicFilterSepia::~GraphicFilterSepia()
639*cdf0e10cSrcweir {
640*cdf0e10cSrcweir }
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir // -----------------------------------------------------------------------------
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir Graphic	GraphicFilterSepia::GetFilteredGraphic( const Graphic& rGraphic,
645*cdf0e10cSrcweir 												double fScaleX, double fScaleY )
646*cdf0e10cSrcweir {
647*cdf0e10cSrcweir 	Graphic			aRet;
648*cdf0e10cSrcweir 	BmpFilterParam	aParam( GetSepiaPercent() );
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 	if( rGraphic.IsAnimated() )
651*cdf0e10cSrcweir 	{
652*cdf0e10cSrcweir 		Animation aAnim( rGraphic.GetAnimation() );
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir 		if( aAnim.Filter( BMP_FILTER_SEPIA, &aParam ) )
655*cdf0e10cSrcweir 			aRet = aAnim;
656*cdf0e10cSrcweir 	}
657*cdf0e10cSrcweir 	else
658*cdf0e10cSrcweir 	{
659*cdf0e10cSrcweir 		BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 		if( aBmpEx.Filter( BMP_FILTER_SEPIA, &aParam ) )
662*cdf0e10cSrcweir 			aRet = aBmpEx;
663*cdf0e10cSrcweir 	}
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 	return aRet;
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir // -----------------------
669*cdf0e10cSrcweir // - GraphicFilterPoster -
670*cdf0e10cSrcweir // -----------------------
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir GraphicFilterPoster::GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
673*cdf0e10cSrcweir 										  sal_uInt16 nPosterCount ) :
674*cdf0e10cSrcweir 	GraphicFilterDialog	( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_POSTER ), rGraphic ),
675*cdf0e10cSrcweir 	maFtPoster		( this, SVX_RES( DLG_FILTERPOSTER_FT_POSTER ) ),
676*cdf0e10cSrcweir 	maNumPoster		( this, SVX_RES( DLG_FILTERPOSTER_NUM_POSTER ) )
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir 	FreeResource();
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 	maNumPoster.SetFirst( 2 );
681*cdf0e10cSrcweir 	maNumPoster.SetLast( rGraphic.GetBitmapEx().GetBitCount() );
682*cdf0e10cSrcweir 	maNumPoster.SetValue( nPosterCount );
683*cdf0e10cSrcweir 	maNumPoster.SetModifyHdl( GetModifyHdl() );
684*cdf0e10cSrcweir 	maNumPoster.GrabFocus();
685*cdf0e10cSrcweir }
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir // -----------------------------------------------------------------------------
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir GraphicFilterPoster::~GraphicFilterPoster()
690*cdf0e10cSrcweir {
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir // -----------------------------------------------------------------------------
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir Graphic	GraphicFilterPoster::GetFilteredGraphic( const Graphic& rGraphic,
696*cdf0e10cSrcweir 												 double fScaleX, double fScaleY )
697*cdf0e10cSrcweir {
698*cdf0e10cSrcweir 	Graphic			aRet;
699*cdf0e10cSrcweir 	const sal_uInt16	nPosterCount = GetPosterColorCount();
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 	if( rGraphic.IsAnimated() )
702*cdf0e10cSrcweir 	{
703*cdf0e10cSrcweir 		Animation aAnim( rGraphic.GetAnimation() );
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 		if( aAnim.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
706*cdf0e10cSrcweir 			aRet = aAnim;
707*cdf0e10cSrcweir 	}
708*cdf0e10cSrcweir 	else
709*cdf0e10cSrcweir 	{
710*cdf0e10cSrcweir 		BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 		if( aBmpEx.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
713*cdf0e10cSrcweir 			aRet = aBmpEx;
714*cdf0e10cSrcweir 	}
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir 	return aRet;
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir // -----------------------
720*cdf0e10cSrcweir // - GraphicFilterEmboss -
721*cdf0e10cSrcweir // -----------------------
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir void GraphicFilterEmboss::EmbossControl::MouseButtonDown( const MouseEvent& rEvt )
724*cdf0e10cSrcweir {
725*cdf0e10cSrcweir 	const RECT_POINT eOldRP = GetActualRP();
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 	SvxRectCtl::MouseButtonDown( rEvt );
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir 	if( GetActualRP() != eOldRP )
730*cdf0e10cSrcweir 		maModifyHdl.Call( this );
731*cdf0e10cSrcweir }
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir // -----------------------------------------------------------------------------
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir GraphicFilterEmboss::GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
736*cdf0e10cSrcweir 										  RECT_POINT eLightSource ) :
737*cdf0e10cSrcweir 	GraphicFilterDialog	( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_EMBOSS ), rGraphic ),
738*cdf0e10cSrcweir 	maFtLight		( this, SVX_RES( DLG_FILTEREMBOSS_FT_LIGHT ) ),
739*cdf0e10cSrcweir 	maCtlLight		( this, SVX_RES( DLG_FILTEREMBOSS_CTL_LIGHT ), eLightSource )
740*cdf0e10cSrcweir {
741*cdf0e10cSrcweir 	FreeResource();
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir 	maCtlLight.SetModifyHdl( GetModifyHdl() );
744*cdf0e10cSrcweir 	maCtlLight.GrabFocus();
745*cdf0e10cSrcweir }
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir // -----------------------------------------------------------------------------
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir GraphicFilterEmboss::~GraphicFilterEmboss()
750*cdf0e10cSrcweir {
751*cdf0e10cSrcweir }
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir // -----------------------------------------------------------------------------
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir Graphic	GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic,
756*cdf0e10cSrcweir 												 double fScaleX, double fScaleY )
757*cdf0e10cSrcweir {
758*cdf0e10cSrcweir 	Graphic	aRet;
759*cdf0e10cSrcweir 	sal_uInt16	nAzim, nElev;
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 	switch( maCtlLight.GetActualRP() )
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir 		case( RP_LT ): nAzim = 4500,	nElev = 4500; break;
764*cdf0e10cSrcweir 		case( RP_MT ): nAzim = 9000,	nElev = 4500; break;
765*cdf0e10cSrcweir 		case( RP_RT ): nAzim = 13500,	nElev = 4500; break;
766*cdf0e10cSrcweir 		case( RP_LM ): nAzim = 0,		nElev = 4500; break;
767*cdf0e10cSrcweir 		case( RP_MM ): nAzim = 0,		nElev = 9000; break;
768*cdf0e10cSrcweir 		case( RP_RM ): nAzim = 18000,	nElev = 4500; break;
769*cdf0e10cSrcweir 		case( RP_LB ): nAzim = 31500,	nElev = 4500; break;
770*cdf0e10cSrcweir 		case( RP_MB ): nAzim = 27000,	nElev = 4500; break;
771*cdf0e10cSrcweir 		case( RP_RB ): nAzim = 22500,	nElev = 4500; break;
772*cdf0e10cSrcweir 	}
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir 	BmpFilterParam aParam( nAzim, nElev );
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	if( rGraphic.IsAnimated() )
777*cdf0e10cSrcweir 	{
778*cdf0e10cSrcweir 		Animation aAnim( rGraphic.GetAnimation() );
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir 		if( aAnim.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
781*cdf0e10cSrcweir 			aRet = aAnim;
782*cdf0e10cSrcweir 	}
783*cdf0e10cSrcweir 	else
784*cdf0e10cSrcweir 	{
785*cdf0e10cSrcweir 		BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 		if( aBmpEx.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
788*cdf0e10cSrcweir 			aRet = aBmpEx;
789*cdf0e10cSrcweir 	}
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir 	return aRet;
792*cdf0e10cSrcweir }
793*cdf0e10cSrcweir */
794