xref: /aoo41x/main/sd/source/ui/dlg/vectdlg.cxx (revision 79aad27f)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5b190011SAndrew Rist  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19*5b190011SAndrew Rist  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SD_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <vcl/vclenum.hxx>
31cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "strings.hrc"
34cdf0e10cSrcweir #include "sdresid.hxx"
35cdf0e10cSrcweir #include "DrawDocShell.hxx"
36cdf0e10cSrcweir #include "sdmod.hxx"
37cdf0e10cSrcweir #include "sdiocmpt.hxx"
38cdf0e10cSrcweir #include "DrawDocShell.hxx"
39cdf0e10cSrcweir #include "vectdlg.hxx"
40cdf0e10cSrcweir #include "vectdlg.hrc"
41cdf0e10cSrcweir #include <tools/config.hxx>
42cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
43cdf0e10cSrcweir #include <vcl/msgbox.hxx>
44cdf0e10cSrcweir #include <vcl/metaact.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // -----------
47cdf0e10cSrcweir // - Defines -
48cdf0e10cSrcweir // -----------
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #define VECTORIZE_MAX_EXTENT 512
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // ------------------
53cdf0e10cSrcweir // - SdVectorizeDlg -
54cdf0e10cSrcweir // ------------------
55cdf0e10cSrcweir 
SdVectorizeDlg(Window * pParent,const Bitmap & rBmp,::sd::DrawDocShell * pDocShell)56cdf0e10cSrcweir SdVectorizeDlg::SdVectorizeDlg(
57cdf0e10cSrcweir     Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell ) :
58cdf0e10cSrcweir 		ModalDialog     ( pParent, SdResId( DLG_VECTORIZE ) ),
59cdf0e10cSrcweir 		mpDocSh          ( pDocShell ),
60cdf0e10cSrcweir 		aGrpSettings    ( this, SdResId( GRP_SETTINGS ) ),
61cdf0e10cSrcweir 		aFtLayers		( this, SdResId( FT_LAYERS ) ),
62cdf0e10cSrcweir 		aNmLayers		( this, SdResId( NM_LAYERS ) ),
63cdf0e10cSrcweir 		aFtReduce		( this, SdResId( FT_REDUCE ) ),
64cdf0e10cSrcweir 		aMtReduce		( this, SdResId( MT_REDUCE ) ),
65cdf0e10cSrcweir 		aFtFillHoles	( this, SdResId( FT_FILLHOLES ) ),
66cdf0e10cSrcweir 		aMtFillHoles	( this, SdResId( MT_FILLHOLES ) ),
67cdf0e10cSrcweir 		aCbFillHoles	( this, SdResId( CB_FILLHOLES ) ),
68cdf0e10cSrcweir 		aFtOriginal		( this, SdResId( FT_ORIGINAL ) ),
69cdf0e10cSrcweir 		aBmpWin			( this, SdResId( CTL_BMP ) ),
70cdf0e10cSrcweir 		aFtVectorized	( this, SdResId( FT_VECTORIZED ) ),
71cdf0e10cSrcweir 		aMtfWin			( this, SdResId( CTL_WMF ) ),
72cdf0e10cSrcweir 		aGrpPrgs		( this, SdResId( GRP_PRGS ) ),
73cdf0e10cSrcweir 		aPrgs			( this, SdResId( WND_PRGS ) ),
74cdf0e10cSrcweir 		aBtnOK          ( this, SdResId( BTN_OK ) ),
75cdf0e10cSrcweir 		aBtnCancel      ( this, SdResId( BTN_CANCEL ) ),
76cdf0e10cSrcweir 		aBtnHelp        ( this, SdResId( BTN_HELP ) ),
77cdf0e10cSrcweir 		aBtnPreview		( this, SdResId( BTN_PREVIEW ) ),
78cdf0e10cSrcweir 		aBmp			( rBmp )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 	FreeResource();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	aBtnPreview.SetClickHdl( LINK( this, SdVectorizeDlg, ClickPreviewHdl ) );
83cdf0e10cSrcweir 	aBtnOK.SetClickHdl( LINK( this, SdVectorizeDlg, ClickOKHdl ) );
84cdf0e10cSrcweir 	aNmLayers.SetModifyHdl( LINK( this, SdVectorizeDlg, ModifyHdl ) );
85cdf0e10cSrcweir 	aMtReduce.SetModifyHdl( LINK( this, SdVectorizeDlg, ModifyHdl ) );
86cdf0e10cSrcweir 	aMtFillHoles.SetModifyHdl( LINK( this, SdVectorizeDlg, ModifyHdl ) );
87cdf0e10cSrcweir 	aCbFillHoles.SetToggleHdl( LINK( this, SdVectorizeDlg, ToggleHdl ) );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	// disable 3D border
90cdf0e10cSrcweir 	aBmpWin.SetBorderStyle(WINDOW_BORDER_MONO);
91cdf0e10cSrcweir 	aMtfWin.SetBorderStyle(WINDOW_BORDER_MONO);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	LoadSettings();
94cdf0e10cSrcweir 	InitPreviewBmp();
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir // -----------------------------------------------------------------------------
98cdf0e10cSrcweir 
~SdVectorizeDlg()99cdf0e10cSrcweir SdVectorizeDlg::~SdVectorizeDlg()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // -----------------------------------------------------------------------------
104cdf0e10cSrcweir 
GetRect(const Size & rDispSize,const Size & rBmpSize) const105cdf0e10cSrcweir Rectangle SdVectorizeDlg::GetRect( const Size& rDispSize, const Size& rBmpSize ) const
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	Rectangle aRect;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	if( rBmpSize.Width() && rBmpSize.Height() && rDispSize.Width() && rDispSize.Height() )
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		Size		 aBmpSize( rBmpSize );
112cdf0e10cSrcweir 		const double fGrfWH = (double) aBmpSize.Width() / aBmpSize.Height();
113cdf0e10cSrcweir 		const double fWinWH = (double) rDispSize.Width() / rDispSize.Height();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 		if( fGrfWH < fWinWH )
116cdf0e10cSrcweir 		{
117cdf0e10cSrcweir 			aBmpSize.Width() = (long) ( rDispSize.Height() * fGrfWH );
118cdf0e10cSrcweir 			aBmpSize.Height()= rDispSize.Height();
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 		else
121cdf0e10cSrcweir 		{
122cdf0e10cSrcweir 			aBmpSize.Width() = rDispSize.Width();
123cdf0e10cSrcweir 			aBmpSize.Height()= (long) ( rDispSize.Width() / fGrfWH);
124cdf0e10cSrcweir 		}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		const Point aBmpPos( ( rDispSize.Width()  - aBmpSize.Width() ) >> 1,
127cdf0e10cSrcweir 							 ( rDispSize.Height() - aBmpSize.Height() ) >> 1 );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		aRect = Rectangle( aBmpPos, aBmpSize );
130cdf0e10cSrcweir 	}
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	return aRect;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir // -----------------------------------------------------------------------------
136cdf0e10cSrcweir 
InitPreviewBmp()137cdf0e10cSrcweir void SdVectorizeDlg::InitPreviewBmp()
138cdf0e10cSrcweir {
139cdf0e10cSrcweir 	const Rectangle aRect( GetRect( aBmpWin.GetSizePixel(), aBmp.GetSizePixel() ) );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	aPreviewBmp = aBmp;
142cdf0e10cSrcweir 	aPreviewBmp.Scale( aRect.GetSize() );
143cdf0e10cSrcweir 	aBmpWin.SetGraphic( aPreviewBmp );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir // -----------------------------------------------------------------------------
147cdf0e10cSrcweir 
GetPreparedBitmap(Bitmap & rBmp,Fraction & rScale)148cdf0e10cSrcweir Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap& rBmp, Fraction& rScale )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	Bitmap		aNew( rBmp );
151cdf0e10cSrcweir 	const Size	aSizePix( aNew.GetSizePixel() );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	if( aSizePix.Width() > VECTORIZE_MAX_EXTENT || aSizePix.Height() > VECTORIZE_MAX_EXTENT )
154cdf0e10cSrcweir 	{
155cdf0e10cSrcweir 		const Rectangle aRect( GetRect( Size( VECTORIZE_MAX_EXTENT, VECTORIZE_MAX_EXTENT ), aSizePix ) );
156cdf0e10cSrcweir 		rScale = Fraction( aSizePix.Width(), aRect.GetWidth() );
157cdf0e10cSrcweir 		aNew.Scale( aRect.GetSize() );
158cdf0e10cSrcweir 	}
159cdf0e10cSrcweir 	else
160cdf0e10cSrcweir 		rScale = Fraction( 1, 1 );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	aNew.ReduceColors( (sal_uInt16) aNmLayers.GetValue(), BMP_REDUCE_SIMPLE );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	return aNew;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir // -----------------------------------------------------------------------------
168cdf0e10cSrcweir 
Calculate(Bitmap & rBmp,GDIMetaFile & rMtf)169cdf0e10cSrcweir void SdVectorizeDlg::Calculate( Bitmap& rBmp, GDIMetaFile& rMtf )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	mpDocSh->SetWaitCursor( sal_True );
172cdf0e10cSrcweir 	aPrgs.SetValue( 0 );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	Fraction	aScale;
175cdf0e10cSrcweir 	Bitmap		aTmp( GetPreparedBitmap( rBmp, aScale ) );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	if( !!aTmp )
178cdf0e10cSrcweir 	{
179cdf0e10cSrcweir 		const Link aPrgsHdl( LINK( this, SdVectorizeDlg, ProgressHdl ) );
180cdf0e10cSrcweir 		aTmp.Vectorize( rMtf, (sal_uInt8) aMtReduce.GetValue(), BMP_VECTORIZE_OUTER | BMP_VECTORIZE_REDUCE_EDGES, &aPrgsHdl );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 		if( aCbFillHoles.IsChecked() )
183cdf0e10cSrcweir 		{
184cdf0e10cSrcweir 			GDIMetaFile			aNewMtf;
185cdf0e10cSrcweir 			BitmapReadAccess*	pRAcc = aTmp.AcquireReadAccess();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 			if( pRAcc )
188cdf0e10cSrcweir 			{
189cdf0e10cSrcweir 				const long		nWidth = pRAcc->Width();
190cdf0e10cSrcweir 				const long		nHeight = pRAcc->Height();
191cdf0e10cSrcweir 				const long		nTileX = static_cast<long>(aMtFillHoles.GetValue());
192cdf0e10cSrcweir 				const long		nTileY = static_cast<long>(aMtFillHoles.GetValue());
193cdf0e10cSrcweir 				const long		nCountX = nWidth / nTileX;
194cdf0e10cSrcweir 				const long		nCountY = nHeight / nTileY;
195cdf0e10cSrcweir 				const long		nRestX = nWidth % nTileX;
196cdf0e10cSrcweir 				const long		nRestY = nHeight % nTileY;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 				MapMode aMap( rMtf.GetPrefMapMode() );
199cdf0e10cSrcweir 				aNewMtf.SetPrefSize( rMtf.GetPrefSize() );
200cdf0e10cSrcweir 				aNewMtf.SetPrefMapMode( aMap );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 				for( long nTY = 0; nTY < nCountY; nTY++ )
203cdf0e10cSrcweir 				{
204cdf0e10cSrcweir 					const long nY = nTY * nTileY;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 					for( long nTX = 0; nTX < nCountX; nTX++ )
207cdf0e10cSrcweir 						AddTile( pRAcc, aNewMtf, nTX * nTileX, nTY * nTileY, nTileX, nTileY );
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 					if( nRestX )
210cdf0e10cSrcweir 						AddTile( pRAcc, aNewMtf, nCountX * nTileX, nY, nRestX, nTileY );
211cdf0e10cSrcweir 				}
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 				if( nRestY )
214cdf0e10cSrcweir 				{
215cdf0e10cSrcweir 					const long nY = nCountY * nTileY;
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 					for( long nTX = 0; nTX < nCountX; nTX++ )
218cdf0e10cSrcweir 						AddTile( pRAcc, aNewMtf, nTX * nTileX, nY, nTileX, nRestY );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 					if( nRestX )
221cdf0e10cSrcweir 						AddTile( pRAcc, aNewMtf, nCountX * nTileX, nCountY * nTileY, nRestX, nRestY );
222cdf0e10cSrcweir 				}
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 				aTmp.ReleaseAccess( pRAcc );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 				for( sal_uLong n = 0UL, nCount = rMtf.GetActionCount(); n < nCount; n++ )
228cdf0e10cSrcweir 					aNewMtf.AddAction( rMtf.GetAction( n )->Clone() );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 				aMap.SetScaleX( aMap.GetScaleX() * aScale );
231cdf0e10cSrcweir 				aMap.SetScaleY( aMap.GetScaleY() * aScale );
232cdf0e10cSrcweir 				aNewMtf.SetPrefMapMode( aMap );
233cdf0e10cSrcweir 				rMtf = aNewMtf;
234cdf0e10cSrcweir 			}
235cdf0e10cSrcweir 		}
236cdf0e10cSrcweir 	}
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	aPrgs.SetValue( 0 );
239cdf0e10cSrcweir 	mpDocSh->SetWaitCursor( sal_False );
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir // -----------------------------------------------------------------------------
243cdf0e10cSrcweir 
AddTile(BitmapReadAccess * pRAcc,GDIMetaFile & rMtf,long nPosX,long nPosY,long nWidth,long nHeight)244cdf0e10cSrcweir void SdVectorizeDlg::AddTile( BitmapReadAccess* pRAcc, GDIMetaFile& rMtf,
245cdf0e10cSrcweir 							  long nPosX, long nPosY, long nWidth, long nHeight )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir 	sal_uLong			nSumR = 0UL, nSumG = 0UL, nSumB = 0UL;
248cdf0e10cSrcweir 	const long		nRight = nPosX + nWidth - 1L;
249cdf0e10cSrcweir 	const long		nBottom = nPosY + nHeight - 1L;
250cdf0e10cSrcweir 	const double	fMult = 1.0 / ( nWidth * nHeight );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	for( long nY = nPosY; nY <= nBottom; nY++ )
253cdf0e10cSrcweir 	{
254cdf0e10cSrcweir 		for( long nX = nPosX; nX <= nRight; nX++ )
255cdf0e10cSrcweir 		{
256cdf0e10cSrcweir 			const BitmapColor aPixel( pRAcc->GetColor( nY, nX ) );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 			nSumR += aPixel.GetRed();
259cdf0e10cSrcweir 			nSumG += aPixel.GetGreen();
260cdf0e10cSrcweir 			nSumB += aPixel.GetBlue();
261cdf0e10cSrcweir 		}
262cdf0e10cSrcweir 	}
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	const Color aColor( (sal_uInt8) FRound( nSumR * fMult ),
265cdf0e10cSrcweir 						(sal_uInt8) FRound( nSumG * fMult ),
266cdf0e10cSrcweir 						(sal_uInt8) FRound( nSumB * fMult ) );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	Rectangle	aRect( Point( nPosX, nPosY ), Size( nWidth + 1, nHeight + 1 ) );
269cdf0e10cSrcweir 	const Size&	rMaxSize = rMtf.GetPrefSize();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	aRect = PixelToLogic( aRect, rMtf.GetPrefMapMode() );
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	if( aRect.Right() > ( rMaxSize.Width() - 1L ) )
274cdf0e10cSrcweir 		aRect.Right() = rMaxSize.Width() - 1L;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	if( aRect.Bottom() > ( rMaxSize.Height() - 1L ) )
277cdf0e10cSrcweir 		aRect.Bottom() = rMaxSize.Height() - 1L;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 	rMtf.AddAction( new MetaLineColorAction( aColor, sal_True ) );
280cdf0e10cSrcweir 	rMtf.AddAction( new MetaFillColorAction( aColor, sal_True ) );
281cdf0e10cSrcweir 	rMtf.AddAction( new MetaRectAction( aRect ) );
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir // -----------------------------------------------------------------------------
285cdf0e10cSrcweir 
IMPL_LINK(SdVectorizeDlg,ProgressHdl,void *,pData)286cdf0e10cSrcweir IMPL_LINK( SdVectorizeDlg, ProgressHdl, void*, pData )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	aPrgs.SetValue( (sal_uInt16)(sal_uLong) pData );
289cdf0e10cSrcweir 	return 0L;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir // -----------------------------------------------------------------------------
293cdf0e10cSrcweir 
IMPL_LINK(SdVectorizeDlg,ClickPreviewHdl,PushButton *,EMPTYARG)294cdf0e10cSrcweir IMPL_LINK( SdVectorizeDlg, ClickPreviewHdl, PushButton*, EMPTYARG )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	Calculate( aBmp, aMtf );
297cdf0e10cSrcweir 	aMtfWin.SetGraphic( aMtf );
298cdf0e10cSrcweir 	aBtnPreview.Disable();
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	return 0L;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir // -----------------------------------------------------------------------------
304cdf0e10cSrcweir 
IMPL_LINK(SdVectorizeDlg,ClickOKHdl,OKButton *,EMPTYARG)305cdf0e10cSrcweir IMPL_LINK( SdVectorizeDlg, ClickOKHdl, OKButton*, EMPTYARG )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	if( aBtnPreview.IsEnabled() )
308cdf0e10cSrcweir 		Calculate( aBmp, aMtf );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	SaveSettings();
311cdf0e10cSrcweir 	EndDialog( RET_OK );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	return 0L;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir // -----------------------------------------------------------------------------
317cdf0e10cSrcweir 
IMPL_LINK(SdVectorizeDlg,ToggleHdl,CheckBox *,pCb)318cdf0e10cSrcweir IMPL_LINK( SdVectorizeDlg, ToggleHdl, CheckBox*, pCb )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir 	if( pCb->IsChecked() )
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		aFtFillHoles.Enable();
323cdf0e10cSrcweir 		aMtFillHoles.Enable();
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir 	else
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		aFtFillHoles.Disable();
328cdf0e10cSrcweir 		aMtFillHoles.Disable();
329cdf0e10cSrcweir 	}
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	ModifyHdl( NULL );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	return 0L;
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir // -----------------------------------------------------------------------------
337cdf0e10cSrcweir 
IMPL_LINK(SdVectorizeDlg,ModifyHdl,void *,EMPTYARG)338cdf0e10cSrcweir IMPL_LINK( SdVectorizeDlg, ModifyHdl, void*, EMPTYARG )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir 	aBtnPreview.Enable();
341cdf0e10cSrcweir 	return 0L;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir // -----------------------------------------------------------------------------
345cdf0e10cSrcweir 
LoadSettings()346cdf0e10cSrcweir void SdVectorizeDlg::LoadSettings()
347cdf0e10cSrcweir {
348cdf0e10cSrcweir 	SvStorageStreamRef	xIStm( SD_MOD()->GetOptionStream(
349cdf0e10cSrcweir 							   UniString::CreateFromAscii(
350cdf0e10cSrcweir 							   RTL_CONSTASCII_STRINGPARAM( SD_OPTION_VECTORIZE ) ),
351cdf0e10cSrcweir 							   SD_OPTION_LOAD ) );
352cdf0e10cSrcweir 	sal_uInt16				nLayers;
353cdf0e10cSrcweir 	sal_uInt16				nReduce;
354cdf0e10cSrcweir 	sal_uInt16				nFillHoles;
355cdf0e10cSrcweir 	sal_Bool				bFillHoles;
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	if( xIStm.Is() )
358cdf0e10cSrcweir 	{
359cdf0e10cSrcweir 		SdIOCompat aCompat( *xIStm, STREAM_READ );
360cdf0e10cSrcweir 		*xIStm >> nLayers >> nReduce >> nFillHoles >> bFillHoles;
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir 	else
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 		nLayers = 8;
365cdf0e10cSrcweir 		nReduce = 0;
366cdf0e10cSrcweir 		nFillHoles = 32;
367cdf0e10cSrcweir 		bFillHoles = sal_False;
368cdf0e10cSrcweir 	}
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	aNmLayers.SetValue( nLayers );
371cdf0e10cSrcweir 	aMtReduce.SetValue( nReduce );
372cdf0e10cSrcweir 	aMtFillHoles.SetValue( nFillHoles );
373cdf0e10cSrcweir 	aCbFillHoles.Check( bFillHoles );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	ToggleHdl( &aCbFillHoles );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
378cdf0e10cSrcweir // -----------------------------------------------------------------------------
379cdf0e10cSrcweir 
SaveSettings() const380cdf0e10cSrcweir void SdVectorizeDlg::SaveSettings() const
381cdf0e10cSrcweir {
382cdf0e10cSrcweir 	SvStorageStreamRef xOStm( SD_MOD()->GetOptionStream(
383cdf0e10cSrcweir 							  UniString::CreateFromAscii(
384cdf0e10cSrcweir 							  RTL_CONSTASCII_STRINGPARAM( SD_OPTION_VECTORIZE ) ),
385cdf0e10cSrcweir 							  SD_OPTION_STORE ) );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	if( xOStm.Is() )
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		SdIOCompat aCompat( *xOStm, STREAM_WRITE, 1 );
390cdf0e10cSrcweir 		*xOStm << (sal_uInt16) aNmLayers.GetValue() << (sal_uInt16) aMtReduce.GetValue();
391cdf0e10cSrcweir 		*xOStm << (sal_uInt16) aMtFillHoles.GetValue() << aCbFillHoles.IsChecked();
392cdf0e10cSrcweir 	}
393cdf0e10cSrcweir }
394