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: cuigrfflt.hxx,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 #ifndef _CUI_GRFFLT_HXX
32 #define _CUI_GRFFLT_HXX
34 #include <vcl/fixed.hxx>
35 #include <vcl/field.hxx>
36 #ifndef _SV_BUTTON_HXX
37 #include <vcl/button.hxx>
39 #include <vcl/timer.hxx>
40 #include <vcl/dialog.hxx>
41 #include <vcl/group.hxx>
42 #include <vcl/salbtype.hxx>
43 #include <goodies/grfmgr.hxx>
44 #include <svx/graphctl.hxx>
45 #include <svx/dlgctrl.hxx>
46 #include <svx/rectenum.hxx>
52 #define SVX_GRAPHICFILTER_ERRCODE_NONE 0x00000000
53 #define SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE 0x00000001
54 #define SVX_GRAPHICFILTER_UNSUPPORTED_SLOT 0x00000002
56 // --------------------
57 // - SvxGraphicFilter -
58 // --------------------
63 class SvxGraphicFilter
67 static ULONG ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject );
68 static void DisableGraphicFilterSlots( SfxItemSet& rSet );
71 // -----------------------
72 // - GraphicFilterDialog -
73 // -----------------------
75 class GraphicFilterDialog
: public ModalDialog
79 class PreviewWindow
: public Control
83 GraphicObject maGraphic
;
85 virtual void Paint( const Rectangle
& rRect
);
89 PreviewWindow( Window
* pParent
, const ResId
& rResId
);
92 void SetGraphic( const Graphic
& rGraphic
);
103 PreviewWindow maPreview
;
104 FixedLine maFlParameter
;
106 CancelButton maBtnCancel
;
107 HelpButton maBtnHelp
;
109 DECL_LINK( ImplPreviewTimeoutHdl
, Timer
* pTimer
);
110 DECL_LINK( ImplModifyHdl
, void* p
);
114 const Link
& GetModifyHdl() const { return maModifyHdl
; }
115 const Size
& GetGraphicSizePixel() const { return maSizePixel
; }
119 GraphicFilterDialog( Window
* pParent
, const ResId
& rResId
, const Graphic
& rGraphic
);
120 ~GraphicFilterDialog();
122 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) = 0;
125 // -----------------------
126 // - GraphicFilterMosaic -
127 // -----------------------
129 class GraphicFilterMosaic
: public GraphicFilterDialog
134 MetricField maMtrWidth
;
135 FixedText maFtHeight
;
136 MetricField maMtrHeight
;
141 GraphicFilterMosaic( Window
* pParent
, const Graphic
& rGraphic
,
142 USHORT nTileWidth
, USHORT nTileHeight
, BOOL bEnhanceEdges
);
143 ~GraphicFilterMosaic();
145 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
);
146 long GetTileWidth() const { return static_cast<long>(maMtrWidth
.GetValue()); }
147 long GetTileHeight() const { return static_cast<long>(maMtrHeight
.GetValue()); }
148 BOOL
IsEnhanceEdges() const { return maCbxEdges
.IsChecked(); }
151 // -------------------------
152 // - GraphicFilterSolarize -
153 // -------------------------
155 class GraphicFilterSolarize
: public GraphicFilterDialog
159 FixedText maFtThreshold
;
160 MetricField maMtrThreshold
;
161 CheckBox maCbxInvert
;
165 GraphicFilterSolarize( Window
* pParent
, const Graphic
& rGraphic
,
166 BYTE nGreyThreshold
, BOOL bInvert
);
167 ~GraphicFilterSolarize();
169 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
);
170 BYTE
GetGreyThreshold() const { return( (BYTE
) FRound( maMtrThreshold
.GetValue() * 2.55 ) ); }
171 BOOL
IsInvert() const { return maCbxInvert
.IsChecked(); }
174 // ----------------------
175 // - GraphicFilterSepia -
176 // ----------------------
178 class GraphicFilterSepia
: public GraphicFilterDialog
183 MetricField maMtrSepia
;
187 GraphicFilterSepia( Window
* pParent
, const Graphic
& rGraphic
,
188 USHORT nSepiaPercent
);
189 ~GraphicFilterSepia();
191 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
);
192 USHORT
GetSepiaPercent() const
193 { return sal::static_int_cast
< USHORT
>(maMtrSepia
.GetValue()); }
196 // -----------------------
197 // - GraphicFilterPoster -
198 // -----------------------
200 class GraphicFilterPoster
: public GraphicFilterDialog
204 FixedText maFtPoster
;
205 NumericField maNumPoster
;
209 GraphicFilterPoster( Window
* pParent
, const Graphic
& rGraphic
,
210 USHORT nPosterColorCount
);
211 ~GraphicFilterPoster();
213 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
);
214 USHORT
GetPosterColorCount() const { return( (USHORT
) maNumPoster
.GetValue() ); }
217 // -----------------------
218 // - GraphicFilterEmboss -
219 // -----------------------
221 class GraphicFilterEmboss
: public GraphicFilterDialog
225 class EmbossControl
: public SvxRectCtl
231 virtual void MouseButtonDown( const MouseEvent
& rEvt
);
235 EmbossControl( Window
* pParent
, const ResId
& rResId
, RECT_POINT eRectPoint
) :
236 SvxRectCtl( pParent
, rResId
) { SetActualRP( eRectPoint
); }
238 void SetModifyHdl( const Link
& rHdl
) { maModifyHdl
= rHdl
; }
244 EmbossControl maCtlLight
;
248 GraphicFilterEmboss( Window
* pParent
, const Graphic
& rGraphic
,
249 RECT_POINT eLightSource
);
250 ~GraphicFilterEmboss();
252 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
);
253 RECT_POINT
GetLightSource() const { return maCtlLight
.GetActualRP(); }