xref: /AOO41X/main/svx/source/dialog/_contdlg.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
27cdf0e10cSrcweir #include <sot/factory.hxx>
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #include <vcl/salbtype.hxx>		// FRound
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <svl/eitem.hxx>
32cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
34cdf0e10cSrcweir #include <svtools/miscopt.hxx>
35cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
36cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
37cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define _SDR_NOITEMS
41cdf0e10cSrcweir #define _SDR_NOTOUCH
42cdf0e10cSrcweir #define _SDR_NOTRANSFORM
43cdf0e10cSrcweir #define _SDR_NOOBJECTS
44cdf0e10cSrcweir #define _SDR_NOVIEWMARKER
45cdf0e10cSrcweir #define _SDR_NODRAGMETHODS
46cdf0e10cSrcweir #define _SDR_NOUNDO
47cdf0e10cSrcweir #define _SDR_NOXOUTDEV
48cdf0e10cSrcweir #define _XOUTBMP_STATICS_ONLY
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <svx/dialmgr.hxx>
51cdf0e10cSrcweir #include "svx/xoutbmp.hxx"
52cdf0e10cSrcweir #include <svx/dialogs.hrc>
53cdf0e10cSrcweir #include <svx/svxids.hrc>
54cdf0e10cSrcweir #include <svx/contdlg.hxx>
55cdf0e10cSrcweir #include "contimp.hxx"
56cdf0e10cSrcweir #include "contdlg.hrc"
57cdf0e10cSrcweir #include "contwnd.hxx"
58cdf0e10cSrcweir #include <svx/svdtrans.hxx>
59cdf0e10cSrcweir #include <svx/svdopath.hxx>
60cdf0e10cSrcweir #include "svx/dlgutil.hxx"
61cdf0e10cSrcweir #include <vcl/svapp.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir /******************************************************************************/
64cdf0e10cSrcweir 
GetUnitString(long nVal_100,FieldUnit eFieldUnit,sal_Unicode cSep)65cdf0e10cSrcweir inline String GetUnitString( long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	String aVal = UniString::CreateFromInt64( MetricField::ConvertValue( nVal_100, 2, MAP_100TH_MM, eFieldUnit ) );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	while( aVal.Len() < 3 )
70cdf0e10cSrcweir 		aVal.Insert( sal_Unicode('0'), 0 );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	aVal.Insert( cSep, aVal.Len() - 2 );
73cdf0e10cSrcweir 	aVal += sal_Unicode(' ');
74cdf0e10cSrcweir 	aVal += SdrFormatter::GetUnitStr( eFieldUnit );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	return aVal;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /******************************************************************************/
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 
83cdf0e10cSrcweir SFX_IMPL_FLOATINGWINDOW( SvxContourDlgChildWindow, SID_CONTOUR_DLG );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir /******************************************************************************/
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir /*************************************************************************
90cdf0e10cSrcweir |*
91cdf0e10cSrcweir |* ControllerItem
92cdf0e10cSrcweir |*
93cdf0e10cSrcweir \************************************************************************/
94cdf0e10cSrcweir 
SvxContourDlgItem(sal_uInt16 _nId,SvxSuperContourDlg & rContourDlg,SfxBindings & rBindings)95cdf0e10cSrcweir SvxContourDlgItem::SvxContourDlgItem( sal_uInt16 _nId, SvxSuperContourDlg& rContourDlg, SfxBindings& rBindings ) :
96cdf0e10cSrcweir             SfxControllerItem   ( _nId, rBindings ),
97cdf0e10cSrcweir 			rDlg				( rContourDlg )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir /*************************************************************************
103cdf0e10cSrcweir |*
104cdf0e10cSrcweir |*
105cdf0e10cSrcweir |*
106cdf0e10cSrcweir \************************************************************************/
107cdf0e10cSrcweir 
StateChanged(sal_uInt16 nSID,SfxItemState,const SfxPoolItem * pItem)108cdf0e10cSrcweir void SvxContourDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, const SfxPoolItem* pItem )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	if ( pItem && ( SID_CONTOUR_EXEC == nSID ) )
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 		const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 		DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		rDlg.SetExecState( !pStateItem->GetValue() );
117cdf0e10cSrcweir 	}
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir /******************************************************************************/
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir /*************************************************************************
125cdf0e10cSrcweir |*
126cdf0e10cSrcweir |* Contour-Float
127cdf0e10cSrcweir |*
128cdf0e10cSrcweir \************************************************************************/
129cdf0e10cSrcweir 
SvxContourDlgChildWindow(Window * _pParent,sal_uInt16 nId,SfxBindings * pBindings,SfxChildWinInfo * pInfo)130cdf0e10cSrcweir SvxContourDlgChildWindow::SvxContourDlgChildWindow( Window* _pParent, sal_uInt16 nId,
131cdf0e10cSrcweir 													SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
132cdf0e10cSrcweir             SfxChildWindow( _pParent, nId )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir     SvxSuperContourDlg* pDlg = new SvxSuperContourDlg( pBindings, this, _pParent, CONT_RESID( RID_SVXDLG_CONTOUR ) );
135cdf0e10cSrcweir     pWindow = pDlg;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
138cdf0e10cSrcweir 		pDlg->RollUp();
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	eChildAlignment = SFX_ALIGN_NOALIGNMENT;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     pDlg->Initialize( pInfo );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir /*************************************************************************
146cdf0e10cSrcweir |*
147cdf0e10cSrcweir |*
148cdf0e10cSrcweir |*
149cdf0e10cSrcweir \************************************************************************/
150cdf0e10cSrcweir 
UpdateContourDlg(const Graphic & rGraphic,sal_Bool bGraphicLinked,const PolyPolygon * pPolyPoly,void * pEditingObj)151cdf0e10cSrcweir void SvxContourDlgChildWindow::UpdateContourDlg( const Graphic& rGraphic, sal_Bool bGraphicLinked,
152cdf0e10cSrcweir 												 const PolyPolygon* pPolyPoly, void* pEditingObj )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	if ( SfxViewFrame::Current() &&
155cdf0e10cSrcweir 		 SfxViewFrame::Current()->HasChildWindow( SvxContourDlgChildWindow::GetChildWindowId() ) )
156cdf0e10cSrcweir 		SVXCONTOURDLG()->Update( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir /*************************************************************************
160cdf0e10cSrcweir |*
161cdf0e10cSrcweir |*
162cdf0e10cSrcweir |*
163cdf0e10cSrcweir \************************************************************************/
164cdf0e10cSrcweir 
SvxContourDlg(SfxBindings * _pBindings,SfxChildWindow * pCW,Window * _pParent,const ResId & rResId)165cdf0e10cSrcweir SvxContourDlg::SvxContourDlg( SfxBindings* _pBindings, SfxChildWindow* pCW,
166cdf0e10cSrcweir                               Window* _pParent, const ResId& rResId ) :
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     SfxFloatingWindow   ( _pBindings, pCW, _pParent, rResId )
169cdf0e10cSrcweir 
170cdf0e10cSrcweir {
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /*************************************************************************
174cdf0e10cSrcweir |*
175cdf0e10cSrcweir |*
176cdf0e10cSrcweir |*
177cdf0e10cSrcweir \************************************************************************/
178cdf0e10cSrcweir 
~SvxContourDlg()179cdf0e10cSrcweir SvxContourDlg::~SvxContourDlg()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir /*************************************************************************
184cdf0e10cSrcweir |*
185cdf0e10cSrcweir |*
186cdf0e10cSrcweir |*
187cdf0e10cSrcweir \************************************************************************/
188cdf0e10cSrcweir 
CreateAutoContour(const Graphic & rGraphic,const Rectangle * pRect,const sal_uIntPtr nFlags)189cdf0e10cSrcweir PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
190cdf0e10cSrcweir 											  const Rectangle* pRect,
191cdf0e10cSrcweir 											  const sal_uIntPtr nFlags )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir 	Bitmap	aBmp;
194cdf0e10cSrcweir 	sal_uIntPtr	nContourFlags = XOUTBMP_CONTOUR_HORZ;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	if ( rGraphic.GetType() == GRAPHIC_BITMAP )
197cdf0e10cSrcweir 	{
198cdf0e10cSrcweir 		if( rGraphic.IsAnimated() )
199cdf0e10cSrcweir 		{
200cdf0e10cSrcweir 			VirtualDevice		aVDev;
201cdf0e10cSrcweir 			MapMode				aTransMap;
202cdf0e10cSrcweir 			PolyPolygon			aAnimPolyPoly;
203cdf0e10cSrcweir 			const Animation		aAnim( rGraphic.GetAnimation() );
204cdf0e10cSrcweir 			const Size&			rSizePix = aAnim.GetDisplaySizePixel();
205cdf0e10cSrcweir 			const sal_uInt16		nCount = aAnim.Count();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 			if ( aVDev.SetOutputSizePixel( rSizePix ) )
208cdf0e10cSrcweir 			{
209cdf0e10cSrcweir 				aVDev.SetLineColor( Color( COL_BLACK ) );
210cdf0e10cSrcweir 				aVDev.SetFillColor( Color( COL_BLACK ) );
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 				for( sal_uInt16 i = 0; i < nCount; i++ )
213cdf0e10cSrcweir 				{
214cdf0e10cSrcweir 					const AnimationBitmap& rStepBmp = aAnim.Get( i );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 					// Polygonausgabe an die richtige Stelle schieben;
217cdf0e10cSrcweir 					// dies ist der Offset des Teilbildes innerhalb
218cdf0e10cSrcweir 					// der Gesamtanimation
219cdf0e10cSrcweir 					aTransMap.SetOrigin( Point( rStepBmp.aPosPix.X(), rStepBmp.aPosPix.Y() ) );
220cdf0e10cSrcweir 					aVDev.SetMapMode( aTransMap );
221cdf0e10cSrcweir 					aVDev.DrawPolyPolygon( CreateAutoContour( rStepBmp.aBmpEx, pRect, nFlags ) );
222cdf0e10cSrcweir 				}
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 				aTransMap.SetOrigin( Point() );
225cdf0e10cSrcweir 				aVDev.SetMapMode( aTransMap );
226cdf0e10cSrcweir 				aBmp = aVDev.GetBitmap( Point(), rSizePix );
227cdf0e10cSrcweir 				aBmp.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
228cdf0e10cSrcweir 			}
229cdf0e10cSrcweir 		}
230cdf0e10cSrcweir 		else if( rGraphic.IsTransparent() )
231cdf0e10cSrcweir 			aBmp = rGraphic.GetBitmapEx().GetMask();
232cdf0e10cSrcweir 		else
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			aBmp = rGraphic.GetBitmap();
235cdf0e10cSrcweir 			nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 	}
238cdf0e10cSrcweir 	else if( rGraphic.GetType() != GRAPHIC_NONE )
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir         const Graphic   aTmpGrf( rGraphic.GetGDIMetaFile().GetMonochromeMtf( Color( COL_BLACK ) ) );
241cdf0e10cSrcweir         VirtualDevice	aVDev;
242cdf0e10cSrcweir         Size			aSizePix( aVDev.LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 		if( aSizePix.Width() && aSizePix.Height() && ( aSizePix.Width() > 512 || aSizePix.Height() > 512 ) )
245cdf0e10cSrcweir 		{
246cdf0e10cSrcweir 			double fWH = (double) aSizePix.Width() / aSizePix.Height();
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 			if( fWH <= 1.0 )
249cdf0e10cSrcweir 				aSizePix.Width() = FRound( ( aSizePix.Height() = 512 ) * fWH );
250cdf0e10cSrcweir 			else
251cdf0e10cSrcweir 				aSizePix.Height() = FRound( ( aSizePix.Width() = 512 ) / fWH );
252cdf0e10cSrcweir 		}
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 		if( aVDev.SetOutputSizePixel( aSizePix ) )
255cdf0e10cSrcweir         {
256cdf0e10cSrcweir 			const Point aPt;
257cdf0e10cSrcweir             aTmpGrf.Draw( &aVDev, aPt, aSizePix );
258cdf0e10cSrcweir             aBmp = aVDev.GetBitmap( aPt, aSizePix );
259cdf0e10cSrcweir         }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 		nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
262cdf0e10cSrcweir 	}
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	aBmp.SetPrefSize( rGraphic.GetPrefSize() );
265cdf0e10cSrcweir 	aBmp.SetPrefMapMode( rGraphic.GetPrefMapMode() );
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	return PolyPolygon( XOutBitmap::GetCountour( aBmp, nContourFlags, 128, pRect ) );
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 
271cdf0e10cSrcweir /*************************************************************************
272cdf0e10cSrcweir |*
273cdf0e10cSrcweir |*
274cdf0e10cSrcweir |*
275cdf0e10cSrcweir \************************************************************************/
276cdf0e10cSrcweir 
ScaleContour(PolyPolygon & rContour,const Graphic & rGraphic,const MapUnit eUnit,const Size & rDisplaySize)277cdf0e10cSrcweir void SvxContourDlg::ScaleContour( PolyPolygon& rContour, const Graphic& rGraphic,
278cdf0e10cSrcweir 								  const MapUnit eUnit, const Size& rDisplaySize )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir 	DBG_ASSERT( rGraphic.GetType() != GRAPHIC_NONE, "Graphic is not valid!" );
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	OutputDevice*	pOutDev = Application::GetDefaultDevice();
283cdf0e10cSrcweir 	const MapMode	aDispMap( eUnit );
284cdf0e10cSrcweir 	const MapMode	aGrfMap( rGraphic.GetPrefMapMode() );
285cdf0e10cSrcweir 	const Size		aGrfSize( rGraphic.GetPrefSize() );
286cdf0e10cSrcweir 	double			fScaleX;
287cdf0e10cSrcweir 	double			fScaleY;
288cdf0e10cSrcweir 	Size			aOrgSize;
289cdf0e10cSrcweir 	Point			aNewPoint;
290cdf0e10cSrcweir 	sal_Bool			bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	if ( bPixelMap )
293cdf0e10cSrcweir 		aOrgSize = pOutDev->PixelToLogic( aGrfSize, aDispMap );
294cdf0e10cSrcweir 	else
295cdf0e10cSrcweir 		aOrgSize = pOutDev->LogicToLogic( aGrfSize, aGrfMap, aDispMap );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	if ( aOrgSize.Width() && aOrgSize.Height() )
298cdf0e10cSrcweir 	{
299cdf0e10cSrcweir 		fScaleX = (double) rDisplaySize.Width() / aOrgSize.Width();
300cdf0e10cSrcweir 		fScaleY = (double) rDisplaySize.Height() / aOrgSize.Height();
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 		for ( sal_uInt16 j = 0, nPolyCount = rContour.Count(); j < nPolyCount; j++ )
303cdf0e10cSrcweir 		{
304cdf0e10cSrcweir 			Polygon& rPoly = rContour[ j ];
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 			for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
307cdf0e10cSrcweir 			{
308cdf0e10cSrcweir 				if ( bPixelMap )
309cdf0e10cSrcweir 					aNewPoint = pOutDev->PixelToLogic( rPoly[ i ], aDispMap  );
310cdf0e10cSrcweir 				else
311cdf0e10cSrcweir 					aNewPoint = pOutDev->LogicToLogic( rPoly[ i ], aGrfMap, aDispMap  );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 				rPoly[ i ] = Point( FRound( aNewPoint.X() * fScaleX ), FRound( aNewPoint.Y() * fScaleY ) );
314cdf0e10cSrcweir 			}
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 
320cdf0e10cSrcweir /*************************************************************************
321cdf0e10cSrcweir |*
322cdf0e10cSrcweir |* Durchschleifen an SuperClass; keine virt. Methoden, um
323cdf0e10cSrcweir |* bei IF-Aenderungen nicht inkompatibel zu werden
324cdf0e10cSrcweir |*
325cdf0e10cSrcweir \************************************************************************/
326cdf0e10cSrcweir 
SetExecState(sal_Bool bEnable)327cdf0e10cSrcweir void SvxContourDlg::SetExecState( sal_Bool bEnable )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	pSuperClass->SetExecState( bEnable );
330cdf0e10cSrcweir }
331cdf0e10cSrcweir 
SetGraphic(const Graphic & rGraphic)332cdf0e10cSrcweir void SvxContourDlg::SetGraphic( const Graphic& rGraphic )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	pSuperClass->SetGraphic( rGraphic );
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
SetGraphicLinked(sal_Bool bGraphicLinked)337cdf0e10cSrcweir void SvxContourDlg::SetGraphicLinked( sal_Bool bGraphicLinked )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir 	pSuperClass->SetGraphicLinked( bGraphicLinked );
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
GetGraphic() const342cdf0e10cSrcweir const Graphic& SvxContourDlg::GetGraphic() const
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	return pSuperClass->GetGraphic();
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
IsGraphicChanged() const347cdf0e10cSrcweir sal_Bool SvxContourDlg::IsGraphicChanged() const
348cdf0e10cSrcweir {
349cdf0e10cSrcweir 	return pSuperClass->IsGraphicChanged();
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
SetPolyPolygon(const PolyPolygon & rPolyPoly)352cdf0e10cSrcweir void SvxContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	pSuperClass->SetPolyPolygon( rPolyPoly );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
GetPolyPolygon()357cdf0e10cSrcweir PolyPolygon SvxContourDlg::GetPolyPolygon()
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	return pSuperClass->GetPolyPolygon( sal_True );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
SetEditingObject(void * pObj)362cdf0e10cSrcweir void SvxContourDlg::SetEditingObject( void* pObj )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir 	pSuperClass->SetEditingObject( pObj );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
GetEditingObject() const367cdf0e10cSrcweir const void* SvxContourDlg::GetEditingObject() const
368cdf0e10cSrcweir {
369cdf0e10cSrcweir 	return pSuperClass->GetEditingObject();
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
Update(const Graphic & rGraphic,sal_Bool bGraphicLinked,const PolyPolygon * pPolyPoly,void * pEditingObj)372cdf0e10cSrcweir void SvxContourDlg::Update( const Graphic& rGraphic, sal_Bool bGraphicLinked,
373cdf0e10cSrcweir 							const PolyPolygon* pPolyPoly, void* pEditingObj )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir 	pSuperClass->UpdateGraphic( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 
379cdf0e10cSrcweir /*************************************************************************
380cdf0e10cSrcweir |*
381cdf0e10cSrcweir |*
382cdf0e10cSrcweir |*
383cdf0e10cSrcweir \************************************************************************/
384cdf0e10cSrcweir 
SvxSuperContourDlg(SfxBindings * _pBindings,SfxChildWindow * pCW,Window * _pParent,const ResId & rResId)385cdf0e10cSrcweir SvxSuperContourDlg::SvxSuperContourDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
386cdf0e10cSrcweir                                         Window* _pParent, const ResId& rResId ) :
387cdf0e10cSrcweir         SvxContourDlg       ( _pBindings, pCW, _pParent, rResId ),
388cdf0e10cSrcweir         pCheckObj           ( NULL ),
389cdf0e10cSrcweir         aContourItem        ( SID_CONTOUR_EXEC, *this, *_pBindings ),
390cdf0e10cSrcweir         aTbx1               ( this, ResId( TBX1, *rResId.GetResMgr() ) ),
391cdf0e10cSrcweir         aMtfTolerance       ( this, ResId( MTF_TOLERANCE, *rResId.GetResMgr() ) ),
392cdf0e10cSrcweir 		aContourWnd			( this, ResId( CTL_CONTOUR, *rResId.GetResMgr() ) ),
393cdf0e10cSrcweir         aStbStatus          ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
394cdf0e10cSrcweir         nGrfChanged         ( 0UL ),
395cdf0e10cSrcweir         bExecState          ( sal_False ),
396cdf0e10cSrcweir 		bGraphicLinked		( sal_False ),
397cdf0e10cSrcweir 		maImageList			( SVX_RES( CD_IMAPDLG ) ),
398cdf0e10cSrcweir 		maImageListH		( SVX_RES( CDH_IMAPDLG ) )
399cdf0e10cSrcweir {
400cdf0e10cSrcweir 	ApplyImageList();
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 	FreeResource();
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 	SvxContourDlg::SetSuperClass( *this );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	aContourWnd.SetMousePosLink( LINK( this, SvxSuperContourDlg, MousePosHdl ) );
407cdf0e10cSrcweir 	aContourWnd.SetGraphSizeLink( LINK( this, SvxSuperContourDlg, GraphSizeHdl ) );
408cdf0e10cSrcweir 	aContourWnd.SetUpdateLink( LINK( this, SvxSuperContourDlg, StateHdl ) );
409cdf0e10cSrcweir 	aContourWnd.SetPipetteHdl( LINK( this, SvxSuperContourDlg, PipetteHdl ) );
410cdf0e10cSrcweir 	aContourWnd.SetPipetteClickHdl( LINK( this, SvxSuperContourDlg, PipetteClickHdl ) );
411cdf0e10cSrcweir 	aContourWnd.SetWorkplaceClickHdl( LINK( this, SvxSuperContourDlg, WorkplaceClickHdl ) );
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	const Size	    aTbxSize( aTbx1.CalcWindowSizePixel() );
414cdf0e10cSrcweir 	Point		    aPos( aTbx1.GetPosPixel() );
415cdf0e10cSrcweir   	SvtMiscOptions  aMiscOptions;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir     aMiscOptions.AddListenerLink( LINK( this, SvxSuperContourDlg, MiscHdl ) );
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
420cdf0e10cSrcweir 	aTbx1.SetSizePixel( aTbxSize );
421cdf0e10cSrcweir 	aTbx1.SetSelectHdl( LINK( this, SvxSuperContourDlg, Tbx1ClickHdl ) );
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	aPos.X() += aTbxSize.Width() + LogicToPixel( Size( 3, 0 ), MapMode( MAP_APPFONT ) ).Width();
424cdf0e10cSrcweir 	aMtfTolerance.SetPosPixel( aPos );
425cdf0e10cSrcweir 	aMtfTolerance.SetValue( 10L );
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
430cdf0e10cSrcweir 	aStbStatus.InsertItem( 2, 10 + GetTextWidth( String::CreateFromAscii( " 9999,99 cm / 9999,99 cm " ) ), SIB_CENTER | SIB_IN );
431cdf0e10cSrcweir 	aStbStatus.InsertItem( 3, 10 + GetTextWidth( String::CreateFromAscii( " 9999,99 cm x 9999,99 cm " ) ), SIB_CENTER | SIB_IN );
432cdf0e10cSrcweir 	aStbStatus.InsertItem( 4, 20, SIB_CENTER | SIB_IN );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	Resize();
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	aUpdateTimer.SetTimeout( 100 );
437cdf0e10cSrcweir 	aUpdateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, UpdateHdl ) );
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	aCreateTimer.SetTimeout( 50 );
440cdf0e10cSrcweir 	aCreateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, CreateHdl ) );
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 
444cdf0e10cSrcweir /*************************************************************************
445cdf0e10cSrcweir |*
446cdf0e10cSrcweir |* Dtor
447cdf0e10cSrcweir |*
448cdf0e10cSrcweir \************************************************************************/
449cdf0e10cSrcweir 
~SvxSuperContourDlg()450cdf0e10cSrcweir SvxSuperContourDlg::~SvxSuperContourDlg()
451cdf0e10cSrcweir {
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 
455cdf0e10cSrcweir /*************************************************************************
456cdf0e10cSrcweir |*
457cdf0e10cSrcweir |* Resize-Methode
458cdf0e10cSrcweir |*
459cdf0e10cSrcweir \************************************************************************/
460cdf0e10cSrcweir 
Resize()461cdf0e10cSrcweir void SvxSuperContourDlg::Resize()
462cdf0e10cSrcweir {
463cdf0e10cSrcweir 	SfxFloatingWindow::Resize();
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 	Size aMinSize( GetMinOutputSizePixel() );
466cdf0e10cSrcweir 	Size aNewSize( GetOutputSizePixel() );
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	if ( aNewSize.Height() >= aMinSize.Height() )
469cdf0e10cSrcweir 	{
470cdf0e10cSrcweir         Size    _aSize( aStbStatus.GetSizePixel() );
471cdf0e10cSrcweir         Point   aPoint( 0, aNewSize.Height() - _aSize.Height() );
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 		// StatusBar positionieren
474cdf0e10cSrcweir         aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
475cdf0e10cSrcweir 		aStbStatus.Show();
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 		// EditWindow positionieren
478cdf0e10cSrcweir         _aSize.Width() = aNewSize.Width() - 18;
479cdf0e10cSrcweir         _aSize.Height() = aPoint.Y() - aContourWnd.GetPosPixel().Y() - 6;
480cdf0e10cSrcweir         aContourWnd.SetSizePixel( _aSize );
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 		aLastSize = aNewSize;
483cdf0e10cSrcweir 	}
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 
487cdf0e10cSrcweir /*************************************************************************
488cdf0e10cSrcweir |*
489cdf0e10cSrcweir |* Close-Methode
490cdf0e10cSrcweir |*
491cdf0e10cSrcweir \************************************************************************/
492cdf0e10cSrcweir 
Close()493cdf0e10cSrcweir sal_Bool SvxSuperContourDlg::Close()
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 	if ( aTbx1.IsItemEnabled( TBI_APPLY ) )
498cdf0e10cSrcweir 	{
499cdf0e10cSrcweir 		QueryBox	aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
500cdf0e10cSrcweir 						   String( CONT_RESID( STR_CONTOURDLG_MODIFY ) ) );
501cdf0e10cSrcweir 		const long	nRet = aQBox.Execute();
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 		if ( nRet == RET_YES )
504cdf0e10cSrcweir 		{
505cdf0e10cSrcweir 			SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, sal_True );
506cdf0e10cSrcweir 			GetBindings().GetDispatcher()->Execute(
507cdf0e10cSrcweir 				SID_CONTOUR_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
508cdf0e10cSrcweir 		}
509cdf0e10cSrcweir 		else if ( nRet == RET_CANCEL )
510cdf0e10cSrcweir 			bRet = sal_False;
511cdf0e10cSrcweir 	}
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 	return( bRet ? SfxFloatingWindow::Close() : sal_False );
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 
517cdf0e10cSrcweir /*************************************************************************
518cdf0e10cSrcweir |*
519cdf0e10cSrcweir |* Enabled oder disabled alle Controls
520cdf0e10cSrcweir |*
521cdf0e10cSrcweir \************************************************************************/
522cdf0e10cSrcweir 
SetExecState(sal_Bool bEnable)523cdf0e10cSrcweir void SvxSuperContourDlg::SetExecState( sal_Bool bEnable )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir 	bExecState = bEnable;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 
529cdf0e10cSrcweir /*************************************************************************
530cdf0e10cSrcweir |*
531cdf0e10cSrcweir |*
532cdf0e10cSrcweir |*
533cdf0e10cSrcweir \************************************************************************/
534cdf0e10cSrcweir 
SetGraphic(const Graphic & rGraphic)535cdf0e10cSrcweir void SvxSuperContourDlg::SetGraphic( const Graphic& rGraphic )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir 	aUndoGraphic = aRedoGraphic = Graphic();
538cdf0e10cSrcweir 	aGraphic = rGraphic;
539cdf0e10cSrcweir 	nGrfChanged = 0UL;
540cdf0e10cSrcweir 	aContourWnd.SetGraphic( aGraphic );
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 
544cdf0e10cSrcweir /*************************************************************************
545cdf0e10cSrcweir |*
546cdf0e10cSrcweir |*
547cdf0e10cSrcweir |*
548cdf0e10cSrcweir \************************************************************************/
549cdf0e10cSrcweir 
SetPolyPolygon(const PolyPolygon & rPolyPoly)550cdf0e10cSrcweir void SvxSuperContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir 	DBG_ASSERT(  aContourWnd.GetGraphic().GetType() != GRAPHIC_NONE, "Graphic must've been set first!" );
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 	PolyPolygon		aPolyPoly( rPolyPoly );
555cdf0e10cSrcweir 	const MapMode	aMap100( MAP_100TH_MM );
556cdf0e10cSrcweir 	const MapMode	aGrfMap( aGraphic.GetPrefMapMode() );
557cdf0e10cSrcweir 	OutputDevice*	pOutDev = Application::GetDefaultDevice();
558cdf0e10cSrcweir 	sal_Bool			bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 	for ( sal_uInt16 j = 0, nPolyCount = aPolyPoly.Count(); j < nPolyCount; j++ )
561cdf0e10cSrcweir 	{
562cdf0e10cSrcweir 		Polygon& rPoly = aPolyPoly[ j ];
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 		for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
565cdf0e10cSrcweir 		{
566cdf0e10cSrcweir 			Point& rPt = rPoly[ i ];
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 			if ( !bPixelMap )
569cdf0e10cSrcweir 				rPt = pOutDev->LogicToPixel( rPt, aGrfMap );
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 			rPt = pOutDev->PixelToLogic( rPt, aMap100 );
572cdf0e10cSrcweir 		}
573cdf0e10cSrcweir 	}
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	aContourWnd.SetPolyPolygon( aPolyPoly );
576cdf0e10cSrcweir 	aContourWnd.GetSdrModel()->SetChanged( sal_True );
577cdf0e10cSrcweir }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 
580cdf0e10cSrcweir /*************************************************************************
581cdf0e10cSrcweir |*
582cdf0e10cSrcweir |*
583cdf0e10cSrcweir |*
584cdf0e10cSrcweir \************************************************************************/
585cdf0e10cSrcweir 
GetPolyPolygon(sal_Bool bRescaleToGraphic)586cdf0e10cSrcweir PolyPolygon SvxSuperContourDlg::GetPolyPolygon( sal_Bool bRescaleToGraphic )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir 	PolyPolygon	aRetPolyPoly( aContourWnd.GetPolyPolygon() );
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 	if ( bRescaleToGraphic )
591cdf0e10cSrcweir 	{
592cdf0e10cSrcweir 		const MapMode	aMap100( MAP_100TH_MM );
593cdf0e10cSrcweir 		const MapMode	aGrfMap( aGraphic.GetPrefMapMode() );
594cdf0e10cSrcweir 		OutputDevice*	pOutDev = Application::GetDefaultDevice();
595cdf0e10cSrcweir 		sal_Bool			bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 		for ( sal_uInt16 j = 0, nPolyCount = aRetPolyPoly.Count(); j < nPolyCount; j++ )
598cdf0e10cSrcweir 		{
599cdf0e10cSrcweir 			Polygon& rPoly = aRetPolyPoly[ j ];
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 			for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
602cdf0e10cSrcweir 			{
603cdf0e10cSrcweir 				Point& rPt = rPoly[ i ];
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 				rPt = pOutDev->LogicToPixel( rPt, aMap100  );
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 				if ( !bPixelMap )
608cdf0e10cSrcweir 					rPt = pOutDev->PixelToLogic( rPt, aGrfMap  );
609cdf0e10cSrcweir 			}
610cdf0e10cSrcweir 		}
611cdf0e10cSrcweir 	}
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 	return aRetPolyPoly;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 
617cdf0e10cSrcweir /*************************************************************************
618cdf0e10cSrcweir |*
619cdf0e10cSrcweir |*
620cdf0e10cSrcweir |*
621cdf0e10cSrcweir \************************************************************************/
622cdf0e10cSrcweir 
UpdateGraphic(const Graphic & rGraphic,sal_Bool _bGraphicLinked,const PolyPolygon * pPolyPoly,void * pEditingObj)623cdf0e10cSrcweir void SvxSuperContourDlg::UpdateGraphic( const Graphic& rGraphic, sal_Bool _bGraphicLinked,
624cdf0e10cSrcweir 								 const PolyPolygon* pPolyPoly, void* pEditingObj )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir 	aUpdateGraphic = rGraphic;
627cdf0e10cSrcweir     bUpdateGraphicLinked = _bGraphicLinked;
628cdf0e10cSrcweir 	pUpdateEditingObject = pEditingObj;
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 	if ( pPolyPoly )
631cdf0e10cSrcweir 		aUpdatePolyPoly = *pPolyPoly;
632cdf0e10cSrcweir 	else
633cdf0e10cSrcweir 		aUpdatePolyPoly = PolyPolygon();
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 	aUpdateTimer.Start();
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 
639cdf0e10cSrcweir /*************************************************************************
640cdf0e10cSrcweir |*
641cdf0e10cSrcweir |*
642cdf0e10cSrcweir |*
643cdf0e10cSrcweir \************************************************************************/
644cdf0e10cSrcweir 
IsUndoPossible() const645cdf0e10cSrcweir sal_Bool SvxSuperContourDlg::IsUndoPossible() const
646cdf0e10cSrcweir {
647cdf0e10cSrcweir 	return aUndoGraphic.GetType() != GRAPHIC_NONE;
648cdf0e10cSrcweir }
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 
651cdf0e10cSrcweir /*************************************************************************
652cdf0e10cSrcweir |*
653cdf0e10cSrcweir |*
654cdf0e10cSrcweir |*
655cdf0e10cSrcweir \************************************************************************/
656cdf0e10cSrcweir 
IsRedoPossible() const657cdf0e10cSrcweir sal_Bool SvxSuperContourDlg::IsRedoPossible() const
658cdf0e10cSrcweir {
659cdf0e10cSrcweir 	return aRedoGraphic.GetType() != GRAPHIC_NONE;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 
663cdf0e10cSrcweir /*************************************************************************
664cdf0e10cSrcweir |*
665cdf0e10cSrcweir |*
666cdf0e10cSrcweir |*
667cdf0e10cSrcweir \************************************************************************/
668cdf0e10cSrcweir 
DoAutoCreate()669cdf0e10cSrcweir void SvxSuperContourDlg::DoAutoCreate()
670cdf0e10cSrcweir {
671cdf0e10cSrcweir 	aCreateTimer.Start();
672cdf0e10cSrcweir }
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 
675cdf0e10cSrcweir /*************************************************************************
676cdf0e10cSrcweir |*
677cdf0e10cSrcweir |*
678cdf0e10cSrcweir |*
679cdf0e10cSrcweir \************************************************************************/
680cdf0e10cSrcweir 
ReducePoints(const long nTol)681cdf0e10cSrcweir void SvxSuperContourDlg::ReducePoints( const long nTol )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir 	PolyPolygon aPolyPoly( GetPolyPolygon( sal_False ) );
684cdf0e10cSrcweir 
685cdf0e10cSrcweir 	if ( aPolyPoly.Count() )
686cdf0e10cSrcweir 	{
687cdf0e10cSrcweir 		const MapMode	aMapMode( MAP_100TH_MM );
688cdf0e10cSrcweir 		const long		nTol2 = nTol * nTol;
689cdf0e10cSrcweir 		Polygon&		rPoly = aPolyPoly[ 0 ];
690cdf0e10cSrcweir 		OutputDevice*	pOutDev = Application::GetDefaultDevice();
691cdf0e10cSrcweir 		Point			aPtPix;
692cdf0e10cSrcweir 		const sal_uInt16	nSize = rPoly.GetSize();
693cdf0e10cSrcweir 		sal_uInt16			nCounter = 0;
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 		if ( nSize )
696cdf0e10cSrcweir 			aPtPix = pOutDev->LogicToPixel( rPoly[ 0 ], aMapMode );
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 		for( sal_uInt16 i = 1; i < nSize; i++ )
699cdf0e10cSrcweir 		{
700cdf0e10cSrcweir 			const Point&	rNewPt = rPoly[ i ];
701cdf0e10cSrcweir 			const Point		aNewPtPix( pOutDev->LogicToPixel( rNewPt, aMapMode ) );
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 			const long nDistX = aNewPtPix.X() - aPtPix.X();
704cdf0e10cSrcweir 			const long nDistY = aNewPtPix.Y() - aPtPix.Y();
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 			if( ( nDistX * nDistX + nDistY * nDistY ) >= nTol2 )
707cdf0e10cSrcweir 			{
708cdf0e10cSrcweir 				rPoly[ ++nCounter ] = rNewPt;
709cdf0e10cSrcweir 				aPtPix = aNewPtPix;
710cdf0e10cSrcweir 			}
711cdf0e10cSrcweir 		}
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 		rPoly.SetSize( nCounter );
714cdf0e10cSrcweir 		aContourWnd.SetPolyPolygon( aPolyPoly );
715cdf0e10cSrcweir 		aContourWnd.GetSdrModel()->SetChanged( sal_True );
716cdf0e10cSrcweir 	}
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 
720cdf0e10cSrcweir /*************************************************************************
721cdf0e10cSrcweir |*
722cdf0e10cSrcweir |* Click-Hdl fuer ToolBox
723cdf0e10cSrcweir |*
724cdf0e10cSrcweir \************************************************************************/
725cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,Tbx1ClickHdl,ToolBox *,pTbx)726cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, Tbx1ClickHdl, ToolBox*, pTbx )
727cdf0e10cSrcweir {
728cdf0e10cSrcweir 	sal_uInt16 nNewItemId = pTbx->GetCurItemId();
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 	switch( pTbx->GetCurItemId() )
731cdf0e10cSrcweir 	{
732cdf0e10cSrcweir 		case( TBI_APPLY ):
733cdf0e10cSrcweir 		{
734cdf0e10cSrcweir 			SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, sal_True );
735cdf0e10cSrcweir 			GetBindings().GetDispatcher()->Execute(
736cdf0e10cSrcweir 				SID_CONTOUR_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
737cdf0e10cSrcweir 		}
738cdf0e10cSrcweir 		break;
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 		case( TBI_WORKPLACE ):
741cdf0e10cSrcweir 		{
742cdf0e10cSrcweir 			if ( aTbx1.IsItemChecked( TBI_WORKPLACE ) )
743cdf0e10cSrcweir 			{
744cdf0e10cSrcweir 				QueryBox aQBox( this, WB_YES_NO | WB_DEF_NO, String( CONT_RESID( STR_CONTOURDLG_WORKPLACE ) ) );
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 				if ( !aContourWnd.IsContourChanged() || ( aQBox.Execute() == RET_YES ) )
747cdf0e10cSrcweir 					aContourWnd.SetWorkplaceMode( sal_True );
748cdf0e10cSrcweir 				else
749cdf0e10cSrcweir 					aTbx1.CheckItem( TBI_WORKPLACE, sal_False );
750cdf0e10cSrcweir 			}
751cdf0e10cSrcweir 			else
752cdf0e10cSrcweir 				aContourWnd.SetWorkplaceMode( sal_False );
753cdf0e10cSrcweir 		}
754cdf0e10cSrcweir 		break;
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 		case( TBI_SELECT ):
757cdf0e10cSrcweir 		{
758cdf0e10cSrcweir 			pTbx->CheckItem( nNewItemId, sal_True );
759cdf0e10cSrcweir 			aContourWnd.SetEditMode( sal_True );
760cdf0e10cSrcweir 		}
761cdf0e10cSrcweir 		break;
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 		case( TBI_RECT ):
764cdf0e10cSrcweir 		{
765cdf0e10cSrcweir 			pTbx->CheckItem( nNewItemId, sal_True );
766cdf0e10cSrcweir 			aContourWnd.SetObjKind( OBJ_RECT );
767cdf0e10cSrcweir 		}
768cdf0e10cSrcweir 		break;
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 		case( TBI_CIRCLE ):
771cdf0e10cSrcweir 		{
772cdf0e10cSrcweir 			pTbx->CheckItem( nNewItemId, sal_True );
773cdf0e10cSrcweir 			aContourWnd.SetObjKind( OBJ_CIRC );
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 		}
776cdf0e10cSrcweir 		break;
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 		case( TBI_POLY ):
779cdf0e10cSrcweir 		{
780cdf0e10cSrcweir 			pTbx->CheckItem( nNewItemId, sal_True );
781cdf0e10cSrcweir 			aContourWnd.SetObjKind( OBJ_POLY );
782cdf0e10cSrcweir 		}
783cdf0e10cSrcweir 		break;
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 		case( TBI_FREEPOLY ):
786cdf0e10cSrcweir 		{
787cdf0e10cSrcweir 			pTbx->CheckItem( nNewItemId, sal_True );
788cdf0e10cSrcweir 			aContourWnd.SetObjKind( OBJ_FREEFILL );
789cdf0e10cSrcweir 		}
790cdf0e10cSrcweir 		break;
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 		case( TBI_POLYEDIT ):
793cdf0e10cSrcweir 			aContourWnd.SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
794cdf0e10cSrcweir 		break;
795cdf0e10cSrcweir 
796cdf0e10cSrcweir 		case( TBI_POLYMOVE ):
797cdf0e10cSrcweir 			aContourWnd.SetPolyEditMode( SID_BEZIER_MOVE );
798cdf0e10cSrcweir 		break;
799cdf0e10cSrcweir 
800cdf0e10cSrcweir 		case( TBI_POLYINSERT ):
801cdf0e10cSrcweir 			aContourWnd.SetPolyEditMode( SID_BEZIER_INSERT );
802cdf0e10cSrcweir 		break;
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 		case( TBI_POLYDELETE ):
805cdf0e10cSrcweir 			aContourWnd.GetSdrView()->DeleteMarkedPoints();
806cdf0e10cSrcweir 		break;
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 		case( TBI_UNDO ):
809cdf0e10cSrcweir 		{
810cdf0e10cSrcweir 			nGrfChanged = nGrfChanged ? nGrfChanged-- : 0UL;
811cdf0e10cSrcweir 			aRedoGraphic = aGraphic;
812cdf0e10cSrcweir 			aGraphic = aUndoGraphic;
813cdf0e10cSrcweir 			aUndoGraphic = Graphic();
814cdf0e10cSrcweir 			aContourWnd.SetGraphic( aGraphic, sal_False );
815cdf0e10cSrcweir 		}
816cdf0e10cSrcweir 		break;
817cdf0e10cSrcweir 
818cdf0e10cSrcweir 		case( TBI_REDO ):
819cdf0e10cSrcweir 		{
820cdf0e10cSrcweir 			nGrfChanged++;
821cdf0e10cSrcweir 			aUndoGraphic = aGraphic;
822cdf0e10cSrcweir 			aGraphic = aRedoGraphic;
823cdf0e10cSrcweir 			aRedoGraphic = Graphic();
824cdf0e10cSrcweir 			aContourWnd.SetGraphic( aGraphic, sal_False );
825cdf0e10cSrcweir 		}
826cdf0e10cSrcweir 		break;
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 		case( TBI_AUTOCONTOUR ):
829cdf0e10cSrcweir 			aCreateTimer.Start();
830cdf0e10cSrcweir 		break;
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 		case( TBI_PIPETTE ):
833cdf0e10cSrcweir 		{
834cdf0e10cSrcweir 			sal_Bool bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 			if ( !bPipette )
837cdf0e10cSrcweir 				aStbStatus.Invalidate();
838cdf0e10cSrcweir 			else if ( bGraphicLinked )
839cdf0e10cSrcweir 			{
840cdf0e10cSrcweir 				QueryBox aQBox( this, WB_YES_NO | WB_DEF_YES, String( CONT_RESID( STR_CONTOURDLG_LINKED ) ) );
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 				if ( aQBox.Execute() != RET_YES )
843cdf0e10cSrcweir 				{
844cdf0e10cSrcweir 					aTbx1.CheckItem( TBI_PIPETTE, bPipette = sal_False );
845cdf0e10cSrcweir 					aStbStatus.Invalidate();
846cdf0e10cSrcweir 				}
847cdf0e10cSrcweir 			}
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 			aContourWnd.SetPipetteMode( bPipette );
850cdf0e10cSrcweir 		}
851cdf0e10cSrcweir 		break;
852cdf0e10cSrcweir 
853cdf0e10cSrcweir 		default:
854cdf0e10cSrcweir 		break;
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	return 0L;
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 
861cdf0e10cSrcweir /*************************************************************************
862cdf0e10cSrcweir |*
863cdf0e10cSrcweir |*
864cdf0e10cSrcweir |*
865cdf0e10cSrcweir \************************************************************************/
866cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,MousePosHdl,ContourWindow *,pWnd)867cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, MousePosHdl, ContourWindow*, pWnd )
868cdf0e10cSrcweir {
869cdf0e10cSrcweir 	String aStr;
870cdf0e10cSrcweir 	const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
871cdf0e10cSrcweir 	const Point& rMousePos = pWnd->GetMousePos();
872cdf0e10cSrcweir 	LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
873cdf0e10cSrcweir 	const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 	aStr.Assign( GetUnitString( rMousePos.X(), eFieldUnit, cSep ) );
876cdf0e10cSrcweir 	aStr.Append( String::CreateFromAscii( " / " ) );
877cdf0e10cSrcweir 	aStr.Append( GetUnitString( rMousePos.Y(), eFieldUnit, cSep ) );
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	aStbStatus.SetItemText( 2, aStr );
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 	return 0L;
882cdf0e10cSrcweir }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir /*************************************************************************
885cdf0e10cSrcweir |*
886cdf0e10cSrcweir |*
887cdf0e10cSrcweir |*
888cdf0e10cSrcweir \************************************************************************/
889cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,GraphSizeHdl,ContourWindow *,pWnd)890cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, GraphSizeHdl, ContourWindow*, pWnd )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir 	String aStr;
893cdf0e10cSrcweir 	const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
894cdf0e10cSrcweir 	const Size& rSize = pWnd->GetGraphicSize();
895cdf0e10cSrcweir 	LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
896cdf0e10cSrcweir 	const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
897cdf0e10cSrcweir 
898cdf0e10cSrcweir 	aStr.Assign( GetUnitString( rSize.Width(), eFieldUnit, cSep ) );
899cdf0e10cSrcweir 	aStr.Append( String::CreateFromAscii( " x " ) );
900cdf0e10cSrcweir 	aStr.Append( GetUnitString( rSize.Height(), eFieldUnit, cSep ) );
901cdf0e10cSrcweir 
902cdf0e10cSrcweir 	aStbStatus.SetItemText( 3, aStr );
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 	return 0L;
905cdf0e10cSrcweir }
906cdf0e10cSrcweir 
907cdf0e10cSrcweir /*************************************************************************
908cdf0e10cSrcweir |*
909cdf0e10cSrcweir |*
910cdf0e10cSrcweir |*
911cdf0e10cSrcweir \************************************************************************/
912cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,UpdateHdl,Timer *,EMPTYARG)913cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, UpdateHdl, Timer*, EMPTYARG )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir 	aUpdateTimer.Stop();
916cdf0e10cSrcweir 
917cdf0e10cSrcweir 	if ( pUpdateEditingObject != pCheckObj )
918cdf0e10cSrcweir 	{
919cdf0e10cSrcweir 		if( !GetEditingObject() )
920cdf0e10cSrcweir 			aContourWnd.GrabFocus();
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 		SetGraphic( aUpdateGraphic );
923cdf0e10cSrcweir 		SetPolyPolygon( aUpdatePolyPoly );
924cdf0e10cSrcweir 		SetEditingObject( pUpdateEditingObject );
925cdf0e10cSrcweir 		bGraphicLinked = bUpdateGraphicLinked;
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 		aUpdateGraphic = Graphic();
928cdf0e10cSrcweir 		aUpdatePolyPoly = PolyPolygon();
929cdf0e10cSrcweir 		bUpdateGraphicLinked = sal_False;
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 		aContourWnd.GetSdrModel()->SetChanged( sal_False );
932cdf0e10cSrcweir 	}
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 	GetBindings().Invalidate( SID_CONTOUR_EXEC );
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 	return 0L;
937cdf0e10cSrcweir }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir 
940cdf0e10cSrcweir /*************************************************************************
941cdf0e10cSrcweir |*
942cdf0e10cSrcweir |*
943cdf0e10cSrcweir |*
944cdf0e10cSrcweir \************************************************************************/
945cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,CreateHdl,Timer *,EMPTYARG)946cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, CreateHdl, Timer*, EMPTYARG )
947cdf0e10cSrcweir {
948cdf0e10cSrcweir 	aCreateTimer.Stop();
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 	const Rectangle	aWorkRect = aContourWnd.LogicToPixel( aContourWnd.GetWorkRect(), MapMode( MAP_100TH_MM ) );
951cdf0e10cSrcweir 	const Graphic&	rGraphic = aContourWnd.GetGraphic();
952cdf0e10cSrcweir 	const sal_Bool		bValid = aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom();
953cdf0e10cSrcweir 
954cdf0e10cSrcweir 	EnterWait();
955cdf0e10cSrcweir 	SetPolyPolygon( CreateAutoContour( rGraphic, bValid ? &aWorkRect : NULL ) );
956cdf0e10cSrcweir 	LeaveWait();
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 	return 0L;
959cdf0e10cSrcweir }
960cdf0e10cSrcweir 
961cdf0e10cSrcweir 
962cdf0e10cSrcweir /*************************************************************************
963cdf0e10cSrcweir |*
964cdf0e10cSrcweir |*
965cdf0e10cSrcweir |*
966cdf0e10cSrcweir \************************************************************************/
967cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,StateHdl,ContourWindow *,pWnd)968cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, StateHdl, ContourWindow*, pWnd )
969cdf0e10cSrcweir {
970cdf0e10cSrcweir 	const SdrObject*	pObj = pWnd->GetSelectedSdrObject();
971cdf0e10cSrcweir 	const SdrView*		pView = pWnd->GetSdrView();
972cdf0e10cSrcweir 	const sal_Bool			bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
973cdf0e10cSrcweir 	const sal_Bool			bDrawEnabled = !( bPolyEdit && aTbx1.IsItemChecked( TBI_POLYEDIT ) );
974cdf0e10cSrcweir 	const sal_Bool			bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
975cdf0e10cSrcweir 	const sal_Bool			bWorkplace = aTbx1.IsItemChecked( TBI_WORKPLACE );
976cdf0e10cSrcweir 	const sal_Bool			bDontHide = !( bPipette || bWorkplace );
977cdf0e10cSrcweir 	const sal_Bool			bBitmap = pWnd->GetGraphic().GetType() == GRAPHIC_BITMAP;
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_APPLY, bDontHide && bExecState && pWnd->IsChanged() );
980cdf0e10cSrcweir 
981cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_WORKPLACE, !bPipette && bDrawEnabled );
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_SELECT, bDontHide && bDrawEnabled );
984cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_RECT, bDontHide && bDrawEnabled );
985cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_CIRCLE, bDontHide && bDrawEnabled );
986cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_POLY, bDontHide && bDrawEnabled );
987cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_FREEPOLY, bDontHide && bDrawEnabled );
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_POLYEDIT, bDontHide && bPolyEdit );
990cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_POLYMOVE, bDontHide && !bDrawEnabled );
991cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_POLYINSERT, bDontHide && !bDrawEnabled );
992cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_POLYDELETE, bDontHide && !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_AUTOCONTOUR, bDontHide && bDrawEnabled );
995cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_PIPETTE, !bWorkplace && bDrawEnabled && bBitmap );
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_UNDO, bDontHide && IsUndoPossible() );
998cdf0e10cSrcweir 	aTbx1.EnableItem( TBI_REDO, bDontHide && IsRedoPossible() );
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir 	if ( bPolyEdit )
1001cdf0e10cSrcweir 	{
1002cdf0e10cSrcweir 		sal_uInt16 nId = 0;
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 		switch( pWnd->GetPolyEditMode() )
1005cdf0e10cSrcweir 		{
1006cdf0e10cSrcweir 			case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
1007cdf0e10cSrcweir 			case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 			default:
1010cdf0e10cSrcweir 			break;
1011cdf0e10cSrcweir 		}
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 		aTbx1.CheckItem( nId, sal_True );
1014cdf0e10cSrcweir 	}
1015cdf0e10cSrcweir 	else
1016cdf0e10cSrcweir 	{
1017cdf0e10cSrcweir 		aTbx1.CheckItem( TBI_POLYEDIT, sal_False );
1018cdf0e10cSrcweir 		aTbx1.CheckItem( TBI_POLYMOVE, sal_True );
1019cdf0e10cSrcweir 		aTbx1.CheckItem( TBI_POLYINSERT, sal_False );
1020cdf0e10cSrcweir 		pWnd->SetPolyEditMode( 0 );
1021cdf0e10cSrcweir 	}
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 	return 0L;
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir /*************************************************************************
1028cdf0e10cSrcweir |*
1029cdf0e10cSrcweir |*
1030cdf0e10cSrcweir |*
1031cdf0e10cSrcweir \************************************************************************/
1032cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,PipetteHdl,ContourWindow *,pWnd)1033cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, PipetteHdl, ContourWindow*, pWnd )
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir 	const Color& rOldLineColor = aStbStatus.GetLineColor();
1036cdf0e10cSrcweir 	const Color& rOldFillColor = aStbStatus.GetFillColor();
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 	Rectangle		aRect( aStbStatus.GetItemRect( 4 ) );
1039cdf0e10cSrcweir 	const Color&	rColor = pWnd->GetPipetteColor();
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 	aStbStatus.SetLineColor( rColor );
1042cdf0e10cSrcweir 	aStbStatus.SetFillColor( rColor );
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 	aRect.Left() += 4;
1045cdf0e10cSrcweir 	aRect.Top() += 4;
1046cdf0e10cSrcweir 	aRect.Right() -= 4;
1047cdf0e10cSrcweir 	aRect.Bottom() -= 4;
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 	aStbStatus.DrawRect( aRect );
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 	aStbStatus.SetLineColor( rOldLineColor );
1052cdf0e10cSrcweir 	aStbStatus.SetFillColor( rOldFillColor );
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 	return 0L;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir /*************************************************************************
1059cdf0e10cSrcweir |*
1060cdf0e10cSrcweir |*
1061cdf0e10cSrcweir |*
1062cdf0e10cSrcweir \************************************************************************/
1063cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,PipetteClickHdl,ContourWindow *,pWnd)1064cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow*, pWnd )
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir 	if ( pWnd->IsClickValid() )
1067cdf0e10cSrcweir 	{
1068cdf0e10cSrcweir 		Bitmap			aMask;
1069cdf0e10cSrcweir 		const Color&	rColor = pWnd->GetPipetteColor();
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 		EnterWait();
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 		if( aGraphic.GetType() == GRAPHIC_BITMAP )
1074cdf0e10cSrcweir 		{
1075cdf0e10cSrcweir 			Bitmap		aBmp( aGraphic.GetBitmap() );
1076cdf0e10cSrcweir 			const long	nTol = static_cast<long>(aMtfTolerance.GetValue() * 255L / 100L);
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 			aMask = aBmp.CreateMask( rColor, nTol );
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir 			if( aGraphic.IsTransparent() )
1081cdf0e10cSrcweir 				aMask.CombineSimple( aGraphic.GetBitmapEx().GetMask(), BMP_COMBINE_OR );
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 			if( !!aMask )
1084cdf0e10cSrcweir 			{
1085cdf0e10cSrcweir 				QueryBox	aQBox( this, WB_YES_NO | WB_DEF_YES, String( CONT_RESID( STR_CONTOURDLG_NEWPIPETTE ) ) );
1086cdf0e10cSrcweir 				sal_Bool		bNewContour;
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 				aRedoGraphic = Graphic();
1089cdf0e10cSrcweir 				aUndoGraphic = aGraphic;
1090cdf0e10cSrcweir 				aGraphic = Graphic( BitmapEx( aBmp, aMask ) );
1091cdf0e10cSrcweir 				nGrfChanged++;
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 				bNewContour = ( aQBox.Execute() == RET_YES );
1094cdf0e10cSrcweir 				pWnd->SetGraphic( aGraphic, bNewContour );
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir 				if( bNewContour )
1097cdf0e10cSrcweir 					aCreateTimer.Start();
1098cdf0e10cSrcweir 			}
1099cdf0e10cSrcweir 		}
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 		LeaveWait();
1102cdf0e10cSrcweir 	}
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir 	aTbx1.CheckItem( TBI_PIPETTE, sal_False );
1105cdf0e10cSrcweir 	pWnd->SetPipetteMode( sal_False );
1106cdf0e10cSrcweir 	aStbStatus.Invalidate();
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 	return 0L;
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir /*************************************************************************
1113cdf0e10cSrcweir |*
1114cdf0e10cSrcweir |*
1115cdf0e10cSrcweir |*
1116cdf0e10cSrcweir \************************************************************************/
1117cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,WorkplaceClickHdl,ContourWindow *,pWnd)1118cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, WorkplaceClickHdl, ContourWindow*, pWnd )
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir 	aTbx1.CheckItem( TBI_WORKPLACE, sal_False );
1121cdf0e10cSrcweir 	aTbx1.CheckItem( TBI_SELECT, sal_True );
1122cdf0e10cSrcweir 	pWnd->SetWorkplaceMode( sal_False );
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 	return 0L;
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir 
ApplyImageList()1127cdf0e10cSrcweir void SvxSuperContourDlg::ApplyImageList()
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir     ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 	aTbx1.SetImageList( rImgLst );
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)1136cdf0e10cSrcweir void SvxSuperContourDlg::DataChanged( const DataChangedEvent& rDCEvt )
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir     SfxFloatingWindow::DataChanged( rDCEvt );
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1141cdf0e10cSrcweir             ApplyImageList();
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir /*************************************************************************
1145cdf0e10cSrcweir |*
1146cdf0e10cSrcweir |*
1147cdf0e10cSrcweir |*
1148cdf0e10cSrcweir \************************************************************************/
1149cdf0e10cSrcweir 
IMPL_LINK(SvxSuperContourDlg,MiscHdl,void *,EMPTYARG)1150cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, MiscHdl, void*, EMPTYARG )
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir    	SvtMiscOptions aMiscOptions;
1153cdf0e10cSrcweir     aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir     return 0L;
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir 
1158