1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: grfflt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <tools/shl.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/viewsh.hxx>
38 #include <sfx2/objsh.hxx>
40 #include <sfx2/request.hxx>
42 #include <svx/dialmgr.hxx>
43 #include <svx/grfflt.hxx>
44 //#include "grfflt.hrc"
45 #include <svx/dialogs.hrc>
46 #include <svx/svxdlg.hxx> //CHINA001
48 // --------------------
49 // - SvxGraphicFilter -
50 // --------------------
52 ULONG
SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest
& rReq
, GraphicObject
& rFilterObject
)
54 const Graphic
& rGraphic
= rFilterObject
.GetGraphic();
55 ULONG nRet
= SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE
;
57 if( rGraphic
.GetType() == GRAPHIC_BITMAP
)
59 SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
60 SfxObjectShell
* pShell
= pViewFrame
? pViewFrame
->GetObjectShell() : NULL
;
61 Window
* pWindow
= ( pViewFrame
&& pViewFrame
->GetViewShell() ) ? pViewFrame
->GetViewShell()->GetWindow() : NULL
;
64 switch( rReq
.GetSlot() )
66 case( SID_GRFFILTER_INVERT
):
69 pShell
->SetWaitCursor( TRUE
);
71 if( rGraphic
.IsAnimated() )
73 Animation
aAnimation( rGraphic
.GetAnimation() );
75 if( aAnimation
.Invert() )
76 aGraphic
= aAnimation
;
80 BitmapEx
aBmpEx( rGraphic
.GetBitmapEx() );
87 pShell
->SetWaitCursor( FALSE
);
91 case( SID_GRFFILTER_SMOOTH
):
94 pShell
->SetWaitCursor( TRUE
);
96 if( rGraphic
.IsAnimated() )
98 Animation
aAnimation( rGraphic
.GetAnimation() );
100 if( aAnimation
.Filter( BMP_FILTER_SMOOTH
) )
101 aGraphic
= aAnimation
;
105 BitmapEx
aBmpEx( rGraphic
.GetBitmapEx() );
107 if( aBmpEx
.Filter( BMP_FILTER_SMOOTH
) )
112 pShell
->SetWaitCursor( FALSE
);
116 case( SID_GRFFILTER_SHARPEN
):
119 pShell
->SetWaitCursor( TRUE
);
121 if( rGraphic
.IsAnimated() )
123 Animation
aAnimation( rGraphic
.GetAnimation() );
125 if( aAnimation
.Filter( BMP_FILTER_SHARPEN
) )
126 aGraphic
= aAnimation
;
130 BitmapEx
aBmpEx( rGraphic
.GetBitmapEx() );
132 if( aBmpEx
.Filter( BMP_FILTER_SHARPEN
) )
137 pShell
->SetWaitCursor( FALSE
);
141 case( SID_GRFFILTER_REMOVENOISE
):
144 pShell
->SetWaitCursor( TRUE
);
146 if( rGraphic
.IsAnimated() )
148 Animation
aAnimation( rGraphic
.GetAnimation() );
150 if( aAnimation
.Filter( BMP_FILTER_REMOVENOISE
) )
151 aGraphic
= aAnimation
;
155 BitmapEx
aBmpEx( rGraphic
.GetBitmapEx() );
157 if( aBmpEx
.Filter( BMP_FILTER_REMOVENOISE
) )
162 pShell
->SetWaitCursor( FALSE
);
166 case( SID_GRFFILTER_SOBEL
):
169 pShell
->SetWaitCursor( TRUE
);
171 if( rGraphic
.IsAnimated() )
173 Animation
aAnimation( rGraphic
.GetAnimation() );
175 if( aAnimation
.Filter( BMP_FILTER_SOBEL_GREY
) )
176 aGraphic
= aAnimation
;
180 BitmapEx
aBmpEx( rGraphic
.GetBitmapEx() );
182 if( aBmpEx
.Filter( BMP_FILTER_SOBEL_GREY
) )
187 pShell
->SetWaitCursor( FALSE
);
191 case( SID_GRFFILTER_MOSAIC
):
193 //CHINA001 GraphicFilterMosaic aDlg( pWindow, rGraphic, 4, 4, FALSE );
194 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
197 AbstractGraphicFilterDialog
* aDlg
= pFact
->CreateGraphicFilterMosaic( pWindow
, rGraphic
, 4, 4, FALSE
, RID_SVX_GRFFILTER_DLG_MOSAIC
);
198 DBG_ASSERT(aDlg
, "Dialogdiet fail!");//CHINA001
199 if( aDlg
->Execute() == RET_OK
) //CHINA001 if( aDlg.Execute() == RET_OK )
200 aGraphic
= aDlg
->GetFilteredGraphic( rGraphic
, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
201 delete aDlg
; //add by CHINA001
206 case( SID_GRFFILTER_EMBOSS
):
208 //CHINA001 GraphicFilterEmboss aDlg( pWindow, rGraphic, RP_MM );
209 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
212 AbstractGraphicFilterDialog
* aDlg
= pFact
->CreateGraphicFilterEmboss( pWindow
, rGraphic
, RP_MM
, RID_SVX_GRFFILTER_DLG_EMBOSS
);
213 DBG_ASSERT(aDlg
, "Dialogdiet fail!");//CHINA001
214 if( aDlg
->Execute() == RET_OK
) //CHINA001 if( aDlg.Execute() == RET_OK )
215 aGraphic
= aDlg
->GetFilteredGraphic( rGraphic
, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
216 delete aDlg
; //add by CHINA001
221 case( SID_GRFFILTER_POSTER
):
223 //CHINA001 GraphicFilterPoster aDlg( pWindow, rGraphic, 16 );
224 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
227 AbstractGraphicFilterDialog
* aDlg
= pFact
->CreateGraphicFilterPosterSepia( pWindow
, rGraphic
, 16, RID_SVX_GRFFILTER_DLG_POSTER
);
228 DBG_ASSERT(aDlg
, "Dialogdiet fail!");//CHINA001
229 if( aDlg
->Execute() == RET_OK
) //CHINA001 if( aDlg.Execute() == RET_OK )
230 aGraphic
= aDlg
->GetFilteredGraphic( rGraphic
, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
231 delete aDlg
; //add by CHINA001
236 case( SID_GRFFILTER_POPART
):
239 pShell
->SetWaitCursor( TRUE
);
241 if( rGraphic
.IsAnimated() )
243 Animation
aAnimation( rGraphic
.GetAnimation() );
245 if( aAnimation
.Filter( BMP_FILTER_POPART
) )
246 aGraphic
= aAnimation
;
250 BitmapEx
aBmpEx( rGraphic
.GetBitmapEx() );
252 if( aBmpEx
.Filter( BMP_FILTER_POPART
) )
257 pShell
->SetWaitCursor( FALSE
);
261 case( SID_GRFFILTER_SEPIA
):
263 //CHINA001 GraphicFilterSepia aDlg( pWindow, rGraphic, 10 );
264 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
267 AbstractGraphicFilterDialog
* aDlg
= pFact
->CreateGraphicFilterPosterSepia( pWindow
, rGraphic
, 10, RID_SVX_GRFFILTER_DLG_SEPIA
);
268 DBG_ASSERT(aDlg
, "Dialogdiet fail!");//CHINA001
269 if( aDlg
->Execute() == RET_OK
) //CHINA001 if( aDlg.Execute() == RET_OK )
270 aGraphic
= aDlg
->GetFilteredGraphic( rGraphic
, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
271 delete aDlg
; //add by CHINA001
276 case( SID_GRFFILTER_SOLARIZE
):
278 //CHINA001 GraphicFilterSolarize aDlg( pWindow, rGraphic, 128, FALSE );
279 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
282 AbstractGraphicFilterDialog
* aDlg
= pFact
->CreateGraphicFilterSolarize( pWindow
, rGraphic
, 128, FALSE
, RID_SVX_GRFFILTER_DLG_SOLARIZE
);
283 DBG_ASSERT(aDlg
, "Dialogdiet fail!");//CHINA001
284 if( aDlg
->Execute() == RET_OK
) //CHINA001 if( aDlg.Execute() == RET_OK )
285 aGraphic
= aDlg
->GetFilteredGraphic( rGraphic
, 1.0, 1.0 ); //CHINA001 aGraphic = aDlg.GetFilteredGraphic( rGraphic, 1.0, 1.0 );
286 delete aDlg
; //add by CHINA001
293 // do nothing; no error
294 nRet
= SVX_GRAPHICFILTER_ERRCODE_NONE
;
300 DBG_ERROR( "SvxGraphicFilter: selected filter slot not yet implemented" );
301 nRet
= SVX_GRAPHICFILTER_UNSUPPORTED_SLOT
;
306 if( aGraphic
.GetType() != GRAPHIC_NONE
)
308 rFilterObject
.SetGraphic( aGraphic
);
309 nRet
= SVX_GRAPHICFILTER_ERRCODE_NONE
;
316 // -----------------------------------------------------------------------------
318 void SvxGraphicFilter::DisableGraphicFilterSlots( SfxItemSet
& rSet
)
320 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER
) )
321 rSet
.DisableItem( SID_GRFFILTER
);
323 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_INVERT
) )
324 rSet
.DisableItem( SID_GRFFILTER_INVERT
);
326 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_SMOOTH
) )
327 rSet
.DisableItem( SID_GRFFILTER_SMOOTH
);
329 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_SHARPEN
) )
330 rSet
.DisableItem( SID_GRFFILTER_SHARPEN
);
332 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_REMOVENOISE
) )
333 rSet
.DisableItem( SID_GRFFILTER_REMOVENOISE
);
335 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_SOBEL
) )
336 rSet
.DisableItem( SID_GRFFILTER_SOBEL
);
338 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_MOSAIC
) )
339 rSet
.DisableItem( SID_GRFFILTER_MOSAIC
);
341 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_EMBOSS
) )
342 rSet
.DisableItem( SID_GRFFILTER_EMBOSS
);
344 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_POSTER
) )
345 rSet
.DisableItem( SID_GRFFILTER_POSTER
);
347 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_POPART
) )
348 rSet
.DisableItem( SID_GRFFILTER_POPART
);
350 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_SEPIA
) )
351 rSet
.DisableItem( SID_GRFFILTER_SEPIA
);
353 if( SFX_ITEM_AVAILABLE
<= rSet
.GetItemState( SID_GRFFILTER_SOLARIZE
) )
354 rSet
.DisableItem( SID_GRFFILTER_SOLARIZE
);
356 /* CHINA001 move to cuigrfflt.cxx
357 // --------------------------------------
358 // - GraphicFilterDialog::PreviewWindow -
359 // --------------------------------------
361 GraphicFilterDialog::PreviewWindow::PreviewWindow( Window* pParent, const ResId& rResId ) :
362 Control( pParent, rResId )
366 // -----------------------------------------------------------------------------
368 GraphicFilterDialog::PreviewWindow::~PreviewWindow()
372 // -----------------------------------------------------------------------------
374 void GraphicFilterDialog::PreviewWindow::Paint( const Rectangle& rRect )
376 Control::Paint( rRect );
378 const Size aGrfSize( LogicToPixel( maGraphic.GetPrefSize(), maGraphic.GetPrefMapMode() ) );
379 const Size aOutSize( GetOutputSizePixel() );
380 const Point aGrfPos( ( aOutSize.Width() - aGrfSize.Width() ) >> 1,
381 ( aOutSize.Height() - aGrfSize.Height() ) >> 1 );
383 if( maGraphic.IsAnimated() )
384 maGraphic.StartAnimation( this , aGrfPos, aGrfSize );
386 maGraphic.Draw( this, aGrfPos, aGrfSize );
389 // -----------------------------------------------------------------------------
391 void GraphicFilterDialog::PreviewWindow::SetGraphic( const Graphic& rGraphic )
393 maGraphic = rGraphic;
395 if( maGraphic.IsAnimated() || maGraphic.IsTransparent() )
398 Paint( Rectangle( Point(), GetOutputSizePixel() ) );
401 // -----------------------
402 // - GraphicFilterDialog -
403 // -----------------------
405 GraphicFilterDialog::GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic ) :
406 ModalDialog ( pParent, rResId ),
409 maSizePixel ( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) ),
410 maModifyHdl ( LINK( this, GraphicFilterDialog, ImplModifyHdl ) ),
411 maPreview ( this, SVX_RES( CTL_PREVIEW ) ),
412 maFlParameter ( this, SVX_RES( FL_PARAMETER ) ),
413 maBtnOK ( this, SVX_RES( BTN_OK ) ),
414 maBtnCancel ( this, SVX_RES( BTN_CANCEL ) ),
415 maBtnHelp ( this, SVX_RES( BTN_HELP ) )
417 const Size aPreviewSize( maPreview.GetOutputSizePixel() );
418 Size aGrfSize( maSizePixel );
420 if( rGraphic.GetType() == GRAPHIC_BITMAP &&
421 aPreviewSize.Width() && aPreviewSize.Height() &&
422 aGrfSize.Width() && aGrfSize.Height() )
424 const double fGrfWH = (double) aGrfSize.Width() / aGrfSize.Height();
425 const double fPreWH = (double) aPreviewSize.Width() / aPreviewSize.Height();
427 if( fGrfWH < fPreWH )
429 aGrfSize.Width() = (long) ( aPreviewSize.Height() * fGrfWH );
430 aGrfSize.Height()= aPreviewSize.Height();
434 aGrfSize.Width() = aPreviewSize.Width();
435 aGrfSize.Height()= (long) ( aPreviewSize.Width() / fGrfWH);
438 mfScaleX = (double) aGrfSize.Width() / maSizePixel.Width();
439 mfScaleY = (double) aGrfSize.Height() / maSizePixel.Height();
441 if( !rGraphic.IsAnimated() )
443 BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
445 if( aBmpEx.Scale( aGrfSize, BMP_SCALE_INTERPOLATE ) )
450 maTimer.SetTimeoutHdl( LINK( this, GraphicFilterDialog, ImplPreviewTimeoutHdl ) );
451 maTimer.SetTimeout( 100 );
452 ImplModifyHdl( NULL );
455 // -----------------------------------------------------------------------------
457 GraphicFilterDialog::~GraphicFilterDialog()
461 // -----------------------------------------------------------------------------
463 IMPL_LINK( GraphicFilterDialog, ImplPreviewTimeoutHdl, Timer*, pTimer )
466 maPreview.SetGraphic( GetFilteredGraphic( maGraphic, mfScaleX, mfScaleY ) );
471 // -----------------------------------------------------------------------------
473 IMPL_LINK( GraphicFilterDialog, ImplModifyHdl, void*, p )
475 if( maGraphic.GetType() == GRAPHIC_BITMAP )
488 GraphicFilterMosaic::GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
489 USHORT nTileWidth, USHORT nTileHeight, BOOL bEnhanceEdges ) :
490 GraphicFilterDialog( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_MOSAIC ), rGraphic ),
491 maFtWidth ( this, SVX_RES( DLG_FILTERMOSAIC_FT_WIDTH ) ),
492 maMtrWidth ( this, SVX_RES( DLG_FILTERMOSAIC_MTR_WIDTH ) ),
493 maFtHeight ( this, SVX_RES( DLG_FILTERMOSAIC_FT_HEIGHT ) ),
494 maMtrHeight ( this, SVX_RES( DLG_FILTERMOSAIC_MTR_HEIGHT ) ),
495 maCbxEdges ( this, SVX_RES( DLG_FILTERMOSAIC_CBX_EDGES ) )
499 maMtrWidth.SetValue( nTileWidth );
500 maMtrWidth.SetLast( GetGraphicSizePixel().Width() );
501 maMtrWidth.SetModifyHdl( GetModifyHdl() );
503 maMtrHeight.SetValue( nTileHeight );
504 maMtrHeight.SetLast( GetGraphicSizePixel().Height() );
505 maMtrHeight.SetModifyHdl( GetModifyHdl() );
507 maCbxEdges.Check( bEnhanceEdges );
508 maCbxEdges.SetToggleHdl( GetModifyHdl() );
510 maMtrWidth.GrabFocus();
513 // -----------------------------------------------------------------------------
515 GraphicFilterMosaic::~GraphicFilterMosaic()
519 // -----------------------------------------------------------------------------
521 Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic,
522 double fScaleX, double fScaleY )
525 const Size aSize( Max( FRound( GetTileWidth() * fScaleX ), 1L ),
526 Max( FRound( GetTileHeight() * fScaleY ), 1L ) );
527 BmpFilterParam aParam( aSize );
529 if( rGraphic.IsAnimated() )
531 Animation aAnim( rGraphic.GetAnimation() );
533 if( aAnim.Filter( BMP_FILTER_MOSAIC, &aParam ) )
535 if( IsEnhanceEdges() )
536 aAnim.Filter( BMP_FILTER_SHARPEN );
543 BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
545 if( aBmpEx.Filter( BMP_FILTER_MOSAIC, &aParam ) )
547 if( IsEnhanceEdges() )
548 aBmpEx.Filter( BMP_FILTER_SHARPEN );
557 // ------------------
558 // - GraphicFilterSolarize -
559 // ------------------
561 GraphicFilterSolarize::GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
562 BYTE cGreyThreshold, BOOL bInvert ) :
563 GraphicFilterDialog ( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_SOLARIZE ), rGraphic ),
564 maFtThreshold ( this, SVX_RES( DLG_FILTERSOLARIZE_FT_THRESHOLD ) ),
565 maMtrThreshold ( this, SVX_RES( DLG_FILTERSOLARIZE_MTR_THRESHOLD ) ),
566 maCbxInvert ( this, SVX_RES( DLG_FILTERSOLARIZE_CBX_INVERT ) )
570 maMtrThreshold.SetValue( FRound( cGreyThreshold / 2.55 ) );
571 maMtrThreshold.SetModifyHdl( GetModifyHdl() );
573 maCbxInvert.Check( bInvert );
574 maCbxInvert.SetToggleHdl( GetModifyHdl() );
576 maMtrThreshold.GrabFocus();
579 // -----------------------------------------------------------------------------
581 GraphicFilterSolarize::~GraphicFilterSolarize()
585 // -----------------------------------------------------------------------------
587 Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic,
588 double fScaleX, double fScaleY )
591 BmpFilterParam aParam( GetGreyThreshold() );
593 if( rGraphic.IsAnimated() )
595 Animation aAnim( rGraphic.GetAnimation() );
597 if( aAnim.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
607 BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
609 if( aBmpEx.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
621 // ----------------------
622 // - GraphicFilterSepia -
623 // ----------------------
625 GraphicFilterSepia::GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
626 USHORT nSepiaPercent ) :
627 GraphicFilterDialog ( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_SEPIA ), rGraphic ),
628 maFtSepia ( this, SVX_RES( DLG_FILTERSEPIA_FT_SEPIA ) ),
629 maMtrSepia ( this, SVX_RES( DLG_FILTERSEPIA_MTR_SEPIA ) )
633 maMtrSepia.SetValue( nSepiaPercent );
634 maMtrSepia.SetModifyHdl( GetModifyHdl() );
636 maMtrSepia.GrabFocus();
639 // -----------------------------------------------------------------------------
641 GraphicFilterSepia::~GraphicFilterSepia()
645 // -----------------------------------------------------------------------------
647 Graphic GraphicFilterSepia::GetFilteredGraphic( const Graphic& rGraphic,
648 double fScaleX, double fScaleY )
651 BmpFilterParam aParam( GetSepiaPercent() );
653 if( rGraphic.IsAnimated() )
655 Animation aAnim( rGraphic.GetAnimation() );
657 if( aAnim.Filter( BMP_FILTER_SEPIA, &aParam ) )
662 BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
664 if( aBmpEx.Filter( BMP_FILTER_SEPIA, &aParam ) )
671 // -----------------------
672 // - GraphicFilterPoster -
673 // -----------------------
675 GraphicFilterPoster::GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
676 USHORT nPosterCount ) :
677 GraphicFilterDialog ( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_POSTER ), rGraphic ),
678 maFtPoster ( this, SVX_RES( DLG_FILTERPOSTER_FT_POSTER ) ),
679 maNumPoster ( this, SVX_RES( DLG_FILTERPOSTER_NUM_POSTER ) )
683 maNumPoster.SetFirst( 2 );
684 maNumPoster.SetLast( rGraphic.GetBitmapEx().GetBitCount() );
685 maNumPoster.SetValue( nPosterCount );
686 maNumPoster.SetModifyHdl( GetModifyHdl() );
687 maNumPoster.GrabFocus();
690 // -----------------------------------------------------------------------------
692 GraphicFilterPoster::~GraphicFilterPoster()
696 // -----------------------------------------------------------------------------
698 Graphic GraphicFilterPoster::GetFilteredGraphic( const Graphic& rGraphic,
699 double fScaleX, double fScaleY )
702 const USHORT nPosterCount = GetPosterColorCount();
704 if( rGraphic.IsAnimated() )
706 Animation aAnim( rGraphic.GetAnimation() );
708 if( aAnim.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
713 BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
715 if( aBmpEx.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
722 // -----------------------
723 // - GraphicFilterEmboss -
724 // -----------------------
726 void GraphicFilterEmboss::EmbossControl::MouseButtonDown( const MouseEvent& rEvt )
728 const RECT_POINT eOldRP = GetActualRP();
730 SvxRectCtl::MouseButtonDown( rEvt );
732 if( GetActualRP() != eOldRP )
733 maModifyHdl.Call( this );
736 // -----------------------------------------------------------------------------
738 GraphicFilterEmboss::GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
739 RECT_POINT eLightSource ) :
740 GraphicFilterDialog ( pParent, SVX_RES( RID_SVX_GRFFILTER_DLG_EMBOSS ), rGraphic ),
741 maFtLight ( this, SVX_RES( DLG_FILTEREMBOSS_FT_LIGHT ) ),
742 maCtlLight ( this, SVX_RES( DLG_FILTEREMBOSS_CTL_LIGHT ), eLightSource )
746 maCtlLight.SetModifyHdl( GetModifyHdl() );
747 maCtlLight.GrabFocus();
750 // -----------------------------------------------------------------------------
752 GraphicFilterEmboss::~GraphicFilterEmboss()
756 // -----------------------------------------------------------------------------
758 Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic,
759 double fScaleX, double fScaleY )
764 switch( maCtlLight.GetActualRP() )
766 case( RP_LT ): nAzim = 4500, nElev = 4500; break;
767 case( RP_MT ): nAzim = 9000, nElev = 4500; break;
768 case( RP_RT ): nAzim = 13500, nElev = 4500; break;
769 case( RP_LM ): nAzim = 0, nElev = 4500; break;
770 case( RP_MM ): nAzim = 0, nElev = 9000; break;
771 case( RP_RM ): nAzim = 18000, nElev = 4500; break;
772 case( RP_LB ): nAzim = 31500, nElev = 4500; break;
773 case( RP_MB ): nAzim = 27000, nElev = 4500; break;
774 case( RP_RB ): nAzim = 22500, nElev = 4500; break;
777 BmpFilterParam aParam( nAzim, nElev );
779 if( rGraphic.IsAnimated() )
781 Animation aAnim( rGraphic.GetAnimation() );
783 if( aAnim.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
788 BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
790 if( aBmpEx.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )