xref: /AOO41X/main/svx/workben/edittest.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <editeng/editeng.hxx>
32*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33*cdf0e10cSrcweir #include <editeng/editview.hxx>
34*cdf0e10cSrcweir #include <editeng/editobj.hxx>
35*cdf0e10cSrcweir #include <editeng/editstat.hxx>
36*cdf0e10cSrcweir #include <eerdll.hxx>
37*cdf0e10cSrcweir #include <editeng/flditem.hxx>
38*cdf0e10cSrcweir #include <tools/urlobj.hxx>
39*cdf0e10cSrcweir #include <svx/svxacorr.hxx>
40*cdf0e10cSrcweir #include <tools/fsys.hxx>
41*cdf0e10cSrcweir #include <svx/xpoly.hxx>
42*cdf0e10cSrcweir #include <svtools/filedlg.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <vcl/window.hxx>
45*cdf0e10cSrcweir #include <vcl/svapp.hxx>
46*cdf0e10cSrcweir #include <vcl/font.hxx>
47*cdf0e10cSrcweir #include <vcl/sound.hxx>
48*cdf0e10cSrcweir #include <vcl/print.hxx>
49*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
50*cdf0e10cSrcweir #include <vcl/help.hxx>
51*cdf0e10cSrcweir #include <vcl/scrbar.hxx>
52*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
53*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include <dialdll.hxx>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #define SERVICE_SIMPLEREGISTRY             "com.sun.star.registry.SimpleRegistry"
59*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
60*cdf0e10cSrcweir #include <comphelper/regpathhelper.hxx>
61*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
62*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
63*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
64*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
65*cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp>
66*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir // SVX
69*cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
70*cdf0e10cSrcweir #include <editeng/shdditem.hxx>
71*cdf0e10cSrcweir #include <editeng/cntritem.hxx>
72*cdf0e10cSrcweir #include <editeng/crsditem.hxx>
73*cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
74*cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
75*cdf0e10cSrcweir #include <editeng/escpitem.hxx>
76*cdf0e10cSrcweir #include <editeng/kernitem.hxx>
77*cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
78*cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
79*cdf0e10cSrcweir #include <editeng/colritem.hxx>
80*cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
81*cdf0e10cSrcweir #include <editeng/postitem.hxx>
82*cdf0e10cSrcweir #include <editeng/adjitem.hxx>
83*cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
84*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
85*cdf0e10cSrcweir #include <editeng/fontitem.hxx>
86*cdf0e10cSrcweir #include <fwdtitem.hxx>
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir // SVTOOLS
89*cdf0e10cSrcweir #include <svl/undo.hxx>
90*cdf0e10cSrcweir #include <svl/itemset.hxx>
91*cdf0e10cSrcweir #include <svl/itempool.hxx>
92*cdf0e10cSrcweir #include <svl/poolitem.hxx>
93*cdf0e10cSrcweir #include <svtools/printdlg.hxx>
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir #include <osl/file.hxx>
96*cdf0e10cSrcweir #include <osl/process.h>
97*cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir #define TB_LEFT			 1
100*cdf0e10cSrcweir #define TB_RIGHT		 2
101*cdf0e10cSrcweir #define TB_CENTER		 3
102*cdf0e10cSrcweir #define TB_UNDO			 4
103*cdf0e10cSrcweir #define TB_REDO			 5
104*cdf0e10cSrcweir #define TB_FONT1		 6
105*cdf0e10cSrcweir #define TB_FONT2		 7
106*cdf0e10cSrcweir #define TB_ITALIC		 8
107*cdf0e10cSrcweir #define TB_BOLD			 9
108*cdf0e10cSrcweir #define TB_UNDERLINE	10
109*cdf0e10cSrcweir #define TB_BLACK		11
110*cdf0e10cSrcweir #define TB_GREEN		12
111*cdf0e10cSrcweir #define TB_OPEN			13
112*cdf0e10cSrcweir #define TB_SAVE			14
113*cdf0e10cSrcweir #define TB_SBL			15
114*cdf0e10cSrcweir #define TB_SBSA			16
115*cdf0e10cSrcweir #define TB_LR			17
116*cdf0e10cSrcweir #define TB_DRAW			18
117*cdf0e10cSrcweir #define TB_DEFTAB		19
118*cdf0e10cSrcweir #define TB_OPEN2		20
119*cdf0e10cSrcweir #define TB_SAVE2		21
120*cdf0e10cSrcweir #define TB_STDSEL		33
121*cdf0e10cSrcweir #define TB_MOVE			34
122*cdf0e10cSrcweir #define TB_PARATTR1		35
123*cdf0e10cSrcweir #define TB_ROTATE		38
124*cdf0e10cSrcweir #define TB_RED			43
125*cdf0e10cSrcweir #define TB_FLAT			46
126*cdf0e10cSrcweir #define TB_BINOBJ1		47
127*cdf0e10cSrcweir #define TB_BINOBJ3		49
128*cdf0e10cSrcweir #define TB_BINOBJ4		50
129*cdf0e10cSrcweir #define TB_BINOBJ1b		51
130*cdf0e10cSrcweir #define TB_BINOBJ2b		52
131*cdf0e10cSrcweir #define TB_ATTRIBS		54
132*cdf0e10cSrcweir #define TB_IDLE			55
133*cdf0e10cSrcweir #define TB_BLOCK		56
134*cdf0e10cSrcweir #define TB_CLONEBIN		57
135*cdf0e10cSrcweir #define TB_INSERT		58
136*cdf0e10cSrcweir #define TB_PKERN		59
137*cdf0e10cSrcweir #define TB_KERN			60
138*cdf0e10cSrcweir #define TB_SUPER		61
139*cdf0e10cSrcweir #define TB_SUB			62
140*cdf0e10cSrcweir #define TB_PRINT		63
141*cdf0e10cSrcweir #define TB_FONT			64
142*cdf0e10cSrcweir #define TB_COLORS		65
143*cdf0e10cSrcweir #define TB_WLM			66
144*cdf0e10cSrcweir #define TB_OUTL			67
145*cdf0e10cSrcweir #define TB_INSFLD		68
146*cdf0e10cSrcweir #define TB_UPDFLD		69
147*cdf0e10cSrcweir #define TB_ONLINESPELL  70
148*cdf0e10cSrcweir #define TB_REDLINES		71
149*cdf0e10cSrcweir #define TB_AUTOCORRECT	72
150*cdf0e10cSrcweir #define TB_POLY			73
151*cdf0e10cSrcweir #define TB_HYPH			74
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir // VARS...
154*cdf0e10cSrcweir short nRotation = 0;
155*cdf0e10cSrcweir USHORT nZoom = 100;
156*cdf0e10cSrcweir sal_Bool bURLClicked = sal_False;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir using namespace ::com::sun::star::connection;
159*cdf0e10cSrcweir using namespace ::vos;
160*cdf0e10cSrcweir using namespace ::rtl;
161*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
162*cdf0e10cSrcweir using namespace ::com::sun::star::registry;
163*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir Reference< XMultiServiceFactory > createApplicationServiceManager()
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir     Reference< XMultiServiceFactory > xMS;
170*cdf0e10cSrcweir 	try
171*cdf0e10cSrcweir 	{
172*cdf0e10cSrcweir 		Reference< XComponentContext >    xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext();
173*cdf0e10cSrcweir         if ( xComponentContext.is() )
174*cdf0e10cSrcweir 		    xMS = xMS.query( xComponentContext->getServiceManager() );
175*cdf0e10cSrcweir 	}
176*cdf0e10cSrcweir 	catch( ::com::sun::star::uno::Exception& )
177*cdf0e10cSrcweir 	{
178*cdf0e10cSrcweir 	}
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	return xMS;
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir // --- class EditApp -------------------------------------------------
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir SV_DECL_PTRARR_DEL( StringList, String*, 0, 4 );
186*cdf0e10cSrcweir SV_IMPL_PTRARR( StringList, String* );
187*cdf0e10cSrcweir StringList aSimpleHistory;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir class EditApp : public Application
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir public:
192*cdf0e10cSrcweir 	virtual void Main();
193*cdf0e10cSrcweir };
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir class MyEditEngine : public EditEngine
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir public:
198*cdf0e10cSrcweir 	MyEditEngine( SfxItemPool* pPool ) : EditEngine( pPool ) { ; }
199*cdf0e10cSrcweir 	virtual String	CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rTxtColor, Color*& rFldColor );
200*cdf0e10cSrcweir 	virtual void	FieldClicked( const SvxFieldItem& rField, USHORT nPara, USHORT nPos );
201*cdf0e10cSrcweir 	virtual void	FieldSelected( const SvxFieldItem& rField, USHORT nPara, USHORT nPos );
202*cdf0e10cSrcweir };
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir XubString __EXPORT MyEditEngine::CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rpTxtColor, Color*& rpFldColor )
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir 	const SvxFieldData* pField = rField.GetField();
207*cdf0e10cSrcweir 	if ( !pField )
208*cdf0e10cSrcweir 		return String( RTL_CONSTASCII_USTRINGPARAM( "<Empty>" ) );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	if ( pField->ISA( SvxDateField ) )
211*cdf0e10cSrcweir 		return ((const SvxDateField*)pField)->GetFormatted( LANGUAGE_SYSTEM, LANGUAGE_SYSTEM );
212*cdf0e10cSrcweir 	else if ( pField->ISA( SvxURLField ) )
213*cdf0e10cSrcweir 	{
214*cdf0e10cSrcweir 		const SvxURLField* pURL = (const SvxURLField*)pField;
215*cdf0e10cSrcweir 		if ( !bURLClicked )
216*cdf0e10cSrcweir 		{
217*cdf0e10cSrcweir 			delete rpTxtColor;
218*cdf0e10cSrcweir 			rpTxtColor = new Color( COL_BLUE );
219*cdf0e10cSrcweir 		}
220*cdf0e10cSrcweir 		else
221*cdf0e10cSrcweir 		{
222*cdf0e10cSrcweir 			delete rpTxtColor;
223*cdf0e10cSrcweir 			rpTxtColor = new Color( COL_RED );
224*cdf0e10cSrcweir 			delete rpFldColor;
225*cdf0e10cSrcweir 			rpFldColor = new Color( COL_YELLOW );
226*cdf0e10cSrcweir 		}
227*cdf0e10cSrcweir 		if ( pURL->GetFormat() == SVXURLFORMAT_URL )
228*cdf0e10cSrcweir 			return pURL->GetURL();
229*cdf0e10cSrcweir 		return pURL->GetRepresentation();
230*cdf0e10cSrcweir 	}
231*cdf0e10cSrcweir 	return String( RTL_CONSTASCII_USTRINGPARAM( "???" ) );
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir void __EXPORT MyEditEngine::FieldClicked( const SvxFieldItem& rField, USHORT nPara, USHORT nPos )
235*cdf0e10cSrcweir {
236*cdf0e10cSrcweir 	EditEngine::FieldClicked( rField, nPara, nPos );	// Falls URL
237*cdf0e10cSrcweir 	const SvxFieldData* pField = rField.GetField();
238*cdf0e10cSrcweir 	if ( !pField )
239*cdf0e10cSrcweir 		return;
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	if ( pField->ISA( SvxURLField ) )
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		bURLClicked = TRUE;
244*cdf0e10cSrcweir 		UpdateFields();
245*cdf0e10cSrcweir 	}
246*cdf0e10cSrcweir 	else
247*cdf0e10cSrcweir 		Sound::Beep();
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir void __EXPORT MyEditEngine::FieldSelected( const SvxFieldItem& rField, USHORT nPara, USHORT nPos )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	const SvxFieldData* pField = rField.GetField();
253*cdf0e10cSrcweir 	if ( !pField )
254*cdf0e10cSrcweir 		return;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "Feld selektiert!" ) ) ).Execute();
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir class MyView : public WorkWindow
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir private:
263*cdf0e10cSrcweir 	EditEngine*		pEditEngine;
264*cdf0e10cSrcweir 	EditView*		pEditView;
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir public:
267*cdf0e10cSrcweir 					MyView( Window* pParent, EditEngine* pEditEngine );
268*cdf0e10cSrcweir 					~MyView();
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 	virtual void	Paint( const Rectangle& );
271*cdf0e10cSrcweir 	virtual void	Resize();
272*cdf0e10cSrcweir 	virtual void	KeyInput( const KeyEvent& rKeyEvt );
273*cdf0e10cSrcweir 	virtual void	MouseMove( const MouseEvent& rMEvt );
274*cdf0e10cSrcweir 	virtual void	MouseButtonDown( const MouseEvent& rMEvt );
275*cdf0e10cSrcweir 	virtual void	MouseButtonUp( const MouseEvent& rMEvt );
276*cdf0e10cSrcweir 	virtual void	Command( const CommandEvent& rCEvt );
277*cdf0e10cSrcweir 	BOOL    		Drop( const DropEvent& rEvt );
278*cdf0e10cSrcweir 	BOOL    		QueryDrop( DropEvent& rEvt );
279*cdf0e10cSrcweir };
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir MyView::MyView( Window* pParent, EditEngine* pEE ) : WorkWindow( pParent, WinBits( WB_STDWORK ) )
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir 	pEditEngine = pEE;
284*cdf0e10cSrcweir 	pEditView = new EditView( pEditEngine, this );
285*cdf0e10cSrcweir 	pEditEngine->InsertView( pEditView );
286*cdf0e10cSrcweir 	SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Another View..." ) ) );
287*cdf0e10cSrcweir //	EnableDrop();
288*cdf0e10cSrcweir 	SetBackgroundBrush( Brush( Color( COL_LIGHTBLUE ) ) );
289*cdf0e10cSrcweir 	Show();
290*cdf0e10cSrcweir }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir MyView::~MyView()
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir 	pEditEngine->RemoveView( pEditView );
295*cdf0e10cSrcweir 	delete pEditView;
296*cdf0e10cSrcweir }
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir void __EXPORT MyView::Paint( const Rectangle& rRec )
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir 	pEditView->Paint( rRec );
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir void __EXPORT MyView::Resize()
304*cdf0e10cSrcweir {
305*cdf0e10cSrcweir 	Size aPaperSz( GetOutputSize() );
306*cdf0e10cSrcweir //	aPaperSz.Width() /= 2;
307*cdf0e10cSrcweir //	aPaperSz.Height() /= 2;
308*cdf0e10cSrcweir 	pEditView->SetOutputArea( Rectangle( Point( 0,0 ), aPaperSz ) );
309*cdf0e10cSrcweir 	pEditView->SetVisArea( Rectangle( Point( 0,0 ), aPaperSz ) );
310*cdf0e10cSrcweir 	Invalidate();
311*cdf0e10cSrcweir 	pEditView->ShowCursor();
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir // --- MyView::KeyInput() --------------------------------------
315*cdf0e10cSrcweir void __EXPORT MyView::KeyInput( const KeyEvent& rKEvt )
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir 	pEditView->PostKeyEvent( rKEvt );
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir void __EXPORT MyView::MouseMove( const MouseEvent& rMEvt )
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	Point aPos = PixelToLogic( rMEvt.GetPosPixel() );
323*cdf0e10cSrcweir 	if ( pEditView->GetOutputArea().IsInside( aPos ) )
324*cdf0e10cSrcweir 		SetPointer( pEditView->GetPointer() );
325*cdf0e10cSrcweir 	else
326*cdf0e10cSrcweir 		SetPointer( Pointer() );
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	pEditView->MouseMove( rMEvt );
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir void __EXPORT MyView::MouseButtonDown( const MouseEvent& rMEvt )
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir 	pEditView->MouseButtonDown( rMEvt );
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir void __EXPORT MyView::MouseButtonUp( const MouseEvent& rMEvt )
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir 	pEditView->MouseButtonUp( rMEvt );
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir void __EXPORT MyView::Command( const CommandEvent& rCEvt )
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir 	if ( rCEvt.GetCommand() == COMMAND_STARTDRAG )
345*cdf0e10cSrcweir 		pEditView->Command(rCEvt);
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir BOOL __EXPORT MyView::Drop( const DropEvent& rEvt )
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir 	return pEditView->Drop( rEvt );
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir BOOL __EXPORT MyView::QueryDrop( DropEvent& rEvt )
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir 	return pEditView->QueryDrop( rEvt );
356*cdf0e10cSrcweir }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir // --- class EditMainWindow --------------------------------------------
359*cdf0e10cSrcweir DECLARE_LIST( ViewList, MyView* );
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir class EditViewWindow : public Window
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir private:
364*cdf0e10cSrcweir 	MyEditEngine*			pEditEngine;
365*cdf0e10cSrcweir 	EditView*				pEditView;
366*cdf0e10cSrcweir 	Pointer 				aStdPtr;
367*cdf0e10cSrcweir 	Pointer 				aURLPtr;
368*cdf0e10cSrcweir 	WorkWindow* 			pTmpWindow;
369*cdf0e10cSrcweir 	ViewList 				aViewList;
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 	XubString 				aTestStr;
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir public:
375*cdf0e10cSrcweir 					EditViewWindow( Window* pParent );
376*cdf0e10cSrcweir 					~EditViewWindow();
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 	virtual void	Paint( const Rectangle& );
379*cdf0e10cSrcweir 	virtual void	Resize();
380*cdf0e10cSrcweir 	virtual void	KeyInput( const KeyEvent& rKeyEvt );
381*cdf0e10cSrcweir 	virtual void	MouseMove( const MouseEvent& rMEvt );
382*cdf0e10cSrcweir 	virtual void	MouseButtonDown( const MouseEvent& rMEvt );
383*cdf0e10cSrcweir 	virtual void	MouseButtonUp( const MouseEvent& rMEvt );
384*cdf0e10cSrcweir 	virtual void	Command( const CommandEvent& rCEvt );
385*cdf0e10cSrcweir 	void			MarkOutputArea();
386*cdf0e10cSrcweir 	BOOL    		Drop( const DropEvent& rEvt );
387*cdf0e10cSrcweir 	BOOL    		QueryDrop( DropEvent& rEvt );
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 	EditView*		GetEditView() 		{ return pEditView; }
390*cdf0e10cSrcweir };
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir class EditMainWindow : public WorkWindow
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir private:
395*cdf0e10cSrcweir 	ToolBox 				aToolBox;
396*cdf0e10cSrcweir 	ScrollBar				aHScrollBar;
397*cdf0e10cSrcweir 	ScrollBar				aVScrollBar;
398*cdf0e10cSrcweir 	EditViewWindow			aViewWin;
399*cdf0e10cSrcweir 	Printer*				pPrinter;
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	WorkWindow* 			pTmpWindow;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 	EditTextObject*			pRTFObj;
404*cdf0e10cSrcweir 	EditTextObject*			pBinObj;
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 	FileDialog*				pFileDialogBox;
407*cdf0e10cSrcweir 	FileDialog*				pFileDialogBox2;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir protected:
411*cdf0e10cSrcweir 	void			SetScrollBars();
412*cdf0e10cSrcweir 	void			SetScrollBarRanges();
413*cdf0e10cSrcweir 	void			CreatePolygon();
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	virtual void	GetFocus();
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir public:
418*cdf0e10cSrcweir 					EditMainWindow();
419*cdf0e10cSrcweir 					~EditMainWindow();
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir 	virtual void	Resize();
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 	DECL_LINK( TBSelect, ToolBox * );
424*cdf0e10cSrcweir 	void			UpdateToolBox();
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 	DECL_LINK( HScrollHdl, ScrollBar * );
427*cdf0e10cSrcweir 	DECL_LINK( VScrollHdl, ScrollBar * );
428*cdf0e10cSrcweir 	DECL_LINK( ShowStatus, EditStatus * );
429*cdf0e10cSrcweir 	void			SetTitle();
430*cdf0e10cSrcweir };
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir EditMainWindow::~EditMainWindow()
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir 	delete pRTFObj;
436*cdf0e10cSrcweir 	delete pBinObj;
437*cdf0e10cSrcweir 	delete pFileDialogBox;
438*cdf0e10cSrcweir 	delete pFileDialogBox2;
439*cdf0e10cSrcweir 	delete pTmpWindow;
440*cdf0e10cSrcweir 	delete pPrinter;
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir EditMainWindow::EditMainWindow() :
444*cdf0e10cSrcweir 				WorkWindow( NULL, WB_APP | WB_STDWORK | WB_SVLOOK | WB_CLIPCHILDREN ) ,
445*cdf0e10cSrcweir 				aViewWin( this ),
446*cdf0e10cSrcweir 				aToolBox( this, WinBits( WB_BORDER | WB_SVLOOK | WB_SCROLL | WB_LINESPACING ) ),
447*cdf0e10cSrcweir 				aHScrollBar( this, WinBits( WB_HSCROLL | WB_DRAG ) ),
448*cdf0e10cSrcweir 				aVScrollBar( this, WinBits( WB_VSCROLL | WB_DRAG ) )
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir 	pRTFObj = 0;
451*cdf0e10cSrcweir 	pBinObj = 0;
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 	pFileDialogBox = new FileDialog( this, WinBits( WB_OPEN | WB_SVLOOK ) );
454*cdf0e10cSrcweir 	pFileDialogBox->SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Open" ) ) );
455*cdf0e10cSrcweir 	pFileDialogBox->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Text" )), String( RTL_CONSTASCII_USTRINGPARAM( "*.txt" ) ) );
456*cdf0e10cSrcweir 	pFileDialogBox->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.rtf" ) ) );
457*cdf0e10cSrcweir 	pFileDialogBox->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "HTML" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.htm;*.html" ) ) );
458*cdf0e10cSrcweir 	pFileDialogBox->SetCurFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ) );
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 	pFileDialogBox2 = new FileDialog( this, WinBits( WB_SAVEAS| WB_SVLOOK ) );
461*cdf0e10cSrcweir 	pFileDialogBox2->SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Save" ) ) );
462*cdf0e10cSrcweir 	pFileDialogBox2->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.txt" ) ) );
463*cdf0e10cSrcweir 	pFileDialogBox2->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.rtf" ) ) );
464*cdf0e10cSrcweir 	pFileDialogBox2->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "HTML" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.htm" ) ) );
465*cdf0e10cSrcweir 	pFileDialogBox2->SetCurFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ) );
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir 	pPrinter = new Printer;
468*cdf0e10cSrcweir 	pPrinter->SetMapMode( MAP_100TH_MM );
469*cdf0e10cSrcweir 	aViewWin.SetMapMode( pPrinter->GetMapMode() );
470*cdf0e10cSrcweir 	aViewWin.GetEditView()->GetEditEngine()->SetRefDevice( pPrinter );
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	pTmpWindow = new WorkWindow( this, WB_STDWORK );
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 	aToolBox.SetButtonType( BUTTON_TEXT );
477*cdf0e10cSrcweir 	aToolBox.SetLineCount( 4 );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 	{
480*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_OPEN, String( RTL_CONSTASCII_USTRINGPARAM( "Open" ) ) );
481*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_SAVE, String( RTL_CONSTASCII_USTRINGPARAM( "Save" ) ) );
482*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_PRINT, String( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) );
483*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
484*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_LEFT, String( RTL_CONSTASCII_USTRINGPARAM( "L" ) ) );
485*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_CENTER, String( RTL_CONSTASCII_USTRINGPARAM( "C" ) ) );
486*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_RIGHT, String( RTL_CONSTASCII_USTRINGPARAM( "R" ) ) );
487*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BLOCK, String( RTL_CONSTASCII_USTRINGPARAM( "B" ) ) );
488*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
489*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_UNDO, String( RTL_CONSTASCII_USTRINGPARAM( "Undo" ) ) );
490*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_REDO, String( RTL_CONSTASCII_USTRINGPARAM( "Redo" ) ) );
491*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
492*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_FONT1, String( RTL_CONSTASCII_USTRINGPARAM( "Font1" ) ) );
493*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_FONT2, String( RTL_CONSTASCII_USTRINGPARAM( "Font2" ) ) );
494*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_DEFTAB, String( RTL_CONSTASCII_USTRINGPARAM( "DefTab" ) ) );
495*cdf0e10cSrcweir 	aToolBox.InsertBreak();
496*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_OPEN2, String( RTL_CONSTASCII_USTRINGPARAM( "Read" ) ) );
497*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_SAVE2, String( RTL_CONSTASCII_USTRINGPARAM( "Write" ) ) );
498*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
499*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_FONT, String( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) ) );
500*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_ITALIC, String( RTL_CONSTASCII_USTRINGPARAM( "K" ) ) );
501*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BOLD, String( RTL_CONSTASCII_USTRINGPARAM( "F" ) ) );
502*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_UNDERLINE, String( RTL_CONSTASCII_USTRINGPARAM( "U" ) ) );
503*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_SUPER, String( RTL_CONSTASCII_USTRINGPARAM( "SP" ) ) );
504*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_SUB, String( RTL_CONSTASCII_USTRINGPARAM( "SB" ) ) );
505*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_PKERN, String( RTL_CONSTASCII_USTRINGPARAM( "PK" ) ) );
506*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_KERN, String( RTL_CONSTASCII_USTRINGPARAM( "TK" ) ) );
507*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_WLM, String( RTL_CONSTASCII_USTRINGPARAM( "W!" ) ) );
508*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
509*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BLACK, String( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) );
510*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_GREEN, String( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) );
511*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_RED, String( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) );
512*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
513*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_SBL, String( RTL_CONSTASCII_USTRINGPARAM( "SBL" ) ) );
514*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_SBSA, String( RTL_CONSTASCII_USTRINGPARAM( "SBSA" ) ) );
515*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_LR, String( RTL_CONSTASCII_USTRINGPARAM( "LR" ) ) );
516*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
517*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_DRAW, String( RTL_CONSTASCII_USTRINGPARAM( "Draw!" ) ) );
518*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_ROTATE, String( RTL_CONSTASCII_USTRINGPARAM( "Rotate!" ) ) );
519*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_MOVE, String( RTL_CONSTASCII_USTRINGPARAM( "Move->2" ) ) );
520*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_PARATTR1, String( RTL_CONSTASCII_USTRINGPARAM( "ParaAttr0" ) ) );
521*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_ATTRIBS, String( RTL_CONSTASCII_USTRINGPARAM( "GetAttribs" ) ) );
522*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
523*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_INSFLD, String( RTL_CONSTASCII_USTRINGPARAM( "InsFld" ) ) );
524*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_UPDFLD, String( RTL_CONSTASCII_USTRINGPARAM( "UpdFld" ) ) );
525*cdf0e10cSrcweir 	}
526*cdf0e10cSrcweir 	aToolBox.InsertBreak();
527*cdf0e10cSrcweir 	{
528*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_ONLINESPELL, String( RTL_CONSTASCII_USTRINGPARAM( "Spell" ) ) );
529*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_REDLINES, String( RTL_CONSTASCII_USTRINGPARAM( "RedLine" ) ) );
530*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_AUTOCORRECT, String( RTL_CONSTASCII_USTRINGPARAM( "Auto*" ) ) );
531*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_HYPH, String( RTL_CONSTASCII_USTRINGPARAM( "Hyph" ) ) );
532*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_STDSEL, String( RTL_CONSTASCII_USTRINGPARAM( "StdSel" ) ) );
533*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_FLAT, String( RTL_CONSTASCII_USTRINGPARAM( "FlatMode" ) ) );
534*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_OUTL, String( RTL_CONSTASCII_USTRINGPARAM( "Ocomphelper" ) ) );
535*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_POLY, String( RTL_CONSTASCII_USTRINGPARAM( "Poly" ) ) );
536*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_COLORS, String( RTL_CONSTASCII_USTRINGPARAM( "Colors" ) ));
537*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_IDLE, String( RTL_CONSTASCII_USTRINGPARAM( "Idle!" ) ) );
538*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_INSERT, String( RTL_CONSTASCII_USTRINGPARAM( "Insert" ) ) );
539*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
540*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BINOBJ1, String( RTL_CONSTASCII_USTRINGPARAM( ">BINObj" ) ) );
541*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BINOBJ1b, String( RTL_CONSTASCII_USTRINGPARAM( ">>BINObj" ) ) );
542*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BINOBJ2b, String( RTL_CONSTASCII_USTRINGPARAM( "<<BINObj" ) ) );
543*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_CLONEBIN, String( RTL_CONSTASCII_USTRINGPARAM( "Clone" ) ) );
544*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
545*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BINOBJ3, String( RTL_CONSTASCII_USTRINGPARAM( "StoreBin" ) ) );
546*cdf0e10cSrcweir 	aToolBox.InsertItem( TB_BINOBJ4, String( RTL_CONSTASCII_USTRINGPARAM( "CreatBin" ) ) );
547*cdf0e10cSrcweir 	}
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir 	aToolBox.SetPosPixel( Point( 0, 0 ) );
550*cdf0e10cSrcweir 	aToolBox.SetSelectHdl( LINK( this, EditMainWindow, TBSelect ) );
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir 	SetBackgroundBrush( Brush( Color( COL_LIGHTGRAY ) ) );
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir 	SetPen( PEN_NULL );
555*cdf0e10cSrcweir 	Show();
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 	aVScrollBar.SetScrollHdl ( LINK( this, EditMainWindow, VScrollHdl ) );
558*cdf0e10cSrcweir 	aVScrollBar.SetLineSize( 300 );
559*cdf0e10cSrcweir 	aVScrollBar.SetPageSize( 2000 );
560*cdf0e10cSrcweir 	aHScrollBar.SetScrollHdl ( LINK( this, EditMainWindow, HScrollHdl ) );
561*cdf0e10cSrcweir 	aHScrollBar.SetLineSize( 300 );
562*cdf0e10cSrcweir 	aHScrollBar.SetPageSize( 2000 );
563*cdf0e10cSrcweir 	aHScrollBar.Enable();
564*cdf0e10cSrcweir 	aVScrollBar.Enable();
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 	aViewWin.GetEditView()->GetEditEngine()->SetStatusEventHdl( LINK( this, EditMainWindow, ShowStatus ) );
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 	SetTitle();
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir 	UpdateToolBox();
571*cdf0e10cSrcweir 	aToolBox.Show();
572*cdf0e10cSrcweir 	aViewWin.Show();
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir void EditMainWindow::SetTitle()
576*cdf0e10cSrcweir {
577*cdf0e10cSrcweir 	String aHeading( String( RTL_CONSTASCII_USTRINGPARAM( "SvEdit!  -  Zoom " ) ) );
578*cdf0e10cSrcweir 	aHeading += String::CreateFromInt32(nZoom);
579*cdf0e10cSrcweir 	aHeading += '%';
580*cdf0e10cSrcweir 	EditEngine* pEditEngine = aViewWin.GetEditView()->GetEditEngine();
581*cdf0e10cSrcweir 	if ( pEditEngine->GetControlWord() & EE_CNTRL_STRETCHING )
582*cdf0e10cSrcweir 	{
583*cdf0e10cSrcweir 		USHORT nX, nY;
584*cdf0e10cSrcweir 		pEditEngine->GetGlobalCharStretching( nX, nY );
585*cdf0e10cSrcweir 		aHeading += String( RTL_CONSTASCII_USTRINGPARAM( ", Stretch=(" ) );
586*cdf0e10cSrcweir 		aHeading += String::CreateFromInt32(nX);
587*cdf0e10cSrcweir 		aHeading += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
588*cdf0e10cSrcweir 		aHeading += String::CreateFromInt32(nY);
589*cdf0e10cSrcweir 		aHeading += ')';
590*cdf0e10cSrcweir 	}
591*cdf0e10cSrcweir 	SetText( aHeading );
592*cdf0e10cSrcweir }
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir void EditMainWindow::UpdateToolBox()
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
597*cdf0e10cSrcweir 	EditEngine* pEditEngine = pEditView->GetEditEngine();
598*cdf0e10cSrcweir 	SfxItemSet aCurSet( pEditView->GetAttribs() );
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir 	ULONG nControl = pEditEngine->GetControlWord();
601*cdf0e10cSrcweir 	aToolBox.EnableItem( TB_UNDO, (BOOL)pEditEngine->GetUndoManager().GetUndoActionCount() );
602*cdf0e10cSrcweir 	aToolBox.EnableItem( TB_REDO, (BOOL)pEditEngine->GetUndoManager().GetRedoActionCount() );
603*cdf0e10cSrcweir 	aToolBox.EnableItem( TB_BINOBJ2b, (BOOL)(long)pBinObj );
604*cdf0e10cSrcweir 	aToolBox.EnableItem( TB_MOVE, pEditEngine->GetParagraphCount() > 3 );
605*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_ONLINESPELL, nControl & EE_CNTRL_ONLINESPELLING ? TRUE : FALSE );
606*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_AUTOCORRECT, nControl & EE_CNTRL_AUTOCORRECT ? TRUE : FALSE );
607*cdf0e10cSrcweir //	aToolBox.CheckItem( TB_HYPH, nControl & EE_CNTRL_HYPHENATE ? TRUE : FALSE );
608*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_REDLINES, nControl & EE_CNTRL_NOREDLINES ? FALSE : TRUE );
609*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_STDSEL, pEditView->GetSelectionMode() == EE_SELMODE_STD );
610*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_FLAT, pEditEngine->IsFlatMode() );
611*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_OUTL, ( nControl & EE_CNTRL_OUTLINER ) ? TRUE : FALSE );
612*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_POLY, pEditEngine->GetPolygon() ? TRUE : FALSE );
613*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_COLORS, ( nControl & EE_CNTRL_NOCOLORS ) ? FALSE : TRUE );
614*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_IDLE, pEditEngine->IsIdleFormatterEnabled() );
615*cdf0e10cSrcweir 	aToolBox.CheckItem( TB_INSERT, pEditView->IsInsertMode() );
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir 	for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_ITEMS_END; nWhich++)
618*cdf0e10cSrcweir 	{
619*cdf0e10cSrcweir //		if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF )
620*cdf0e10cSrcweir //			;
621*cdf0e10cSrcweir //		else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE )
622*cdf0e10cSrcweir //			;
623*cdf0e10cSrcweir //		else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_ON )
624*cdf0e10cSrcweir 		{
625*cdf0e10cSrcweir 			const SfxPoolItem& rItem = aCurSet.Get( nWhich );
626*cdf0e10cSrcweir 			switch ( nWhich )
627*cdf0e10cSrcweir 			{
628*cdf0e10cSrcweir 				case EE_PARA_HYPHENATE:
629*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_HYPH, ((SfxBoolItem&)rItem).GetValue() != 0 );
630*cdf0e10cSrcweir 				break;
631*cdf0e10cSrcweir 				case EE_PARA_LRSPACE:
632*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_LR, ((SvxLRSpaceItem&)rItem).GetTxtLeft() != 0 );
633*cdf0e10cSrcweir 				break;
634*cdf0e10cSrcweir 				case EE_PARA_ULSPACE:
635*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_SBSA, ((SvxULSpaceItem&)rItem).GetUpper() != 0 );
636*cdf0e10cSrcweir 				break;
637*cdf0e10cSrcweir 				case EE_PARA_SBL:
638*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_SBL, ((SvxLineSpacingItem&)rItem).GetPropLineSpace() != 100 );
639*cdf0e10cSrcweir 				break;
640*cdf0e10cSrcweir 				case EE_PARA_JUST:
641*cdf0e10cSrcweir 				{
642*cdf0e10cSrcweir 					SvxAdjust e = ((SvxAdjustItem&)rItem).GetAdjust();
643*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_LEFT, e == SVX_ADJUST_LEFT );
644*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_RIGHT, e == SVX_ADJUST_RIGHT);
645*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_CENTER, e == SVX_ADJUST_CENTER);
646*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_BLOCK, e == SVX_ADJUST_BLOCK );
647*cdf0e10cSrcweir 				}
648*cdf0e10cSrcweir 				break;
649*cdf0e10cSrcweir 				case EE_PARA_TABS:
650*cdf0e10cSrcweir 				break;
651*cdf0e10cSrcweir 				case EE_CHAR_COLOR:
652*cdf0e10cSrcweir 				{
653*cdf0e10cSrcweir 					Color aColor( ((SvxColorItem&)rItem).GetValue() );
654*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_BLACK, aColor == COL_BLACK );
655*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_GREEN, aColor == COL_GREEN );
656*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_RED, aColor == COL_RED );
657*cdf0e10cSrcweir 				}
658*cdf0e10cSrcweir 				break;
659*cdf0e10cSrcweir 				case EE_CHAR_FONTINFO:
660*cdf0e10cSrcweir 				{
661*cdf0e10cSrcweir 					FontFamily e = ((SvxFontItem&)rItem).GetFamily();
662*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_FONT1, e == FAMILY_ROMAN );
663*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_FONT2, e == FAMILY_SWISS );
664*cdf0e10cSrcweir 				}
665*cdf0e10cSrcweir 				break;
666*cdf0e10cSrcweir 				case EE_CHAR_FONTHEIGHT:
667*cdf0e10cSrcweir 				break;
668*cdf0e10cSrcweir 				case EE_CHAR_WEIGHT:
669*cdf0e10cSrcweir 				{
670*cdf0e10cSrcweir 					FontWeight e = ((SvxWeightItem&)rItem).GetWeight();
671*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_BOLD, e == WEIGHT_BOLD );
672*cdf0e10cSrcweir 				}
673*cdf0e10cSrcweir 				break;
674*cdf0e10cSrcweir 				case EE_CHAR_UNDERLINE:
675*cdf0e10cSrcweir 				{
676*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_UNDERLINE, ((SvxUnderlineItem&)rItem).GetLineStyle() );
677*cdf0e10cSrcweir 				}
678*cdf0e10cSrcweir 				break;
679*cdf0e10cSrcweir 				case EE_CHAR_WLM:
680*cdf0e10cSrcweir 				{
681*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_WLM, ((SvxWordLineModeItem&)rItem).GetValue() );
682*cdf0e10cSrcweir 				}
683*cdf0e10cSrcweir 				break;
684*cdf0e10cSrcweir 				case EE_CHAR_PAIRKERNING:
685*cdf0e10cSrcweir 				{
686*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_PKERN, ((SvxAutoKernItem&)rItem).GetValue() );
687*cdf0e10cSrcweir 				}
688*cdf0e10cSrcweir 				break;
689*cdf0e10cSrcweir 				case EE_CHAR_KERNING:
690*cdf0e10cSrcweir 				{
691*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_KERN, (BOOL)((SvxKerningItem&)rItem).GetValue() );
692*cdf0e10cSrcweir 				}
693*cdf0e10cSrcweir 				break;
694*cdf0e10cSrcweir 				case EE_CHAR_ESCAPEMENT:
695*cdf0e10cSrcweir 				{
696*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_SUPER, ((SvxEscapementItem&)rItem).GetEsc() > 0 );
697*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_SUB, ((SvxEscapementItem&)rItem).GetEsc() < 0 );
698*cdf0e10cSrcweir 				}
699*cdf0e10cSrcweir 				break;
700*cdf0e10cSrcweir 				case EE_CHAR_STRIKEOUT:
701*cdf0e10cSrcweir 				break;
702*cdf0e10cSrcweir 				case EE_CHAR_ITALIC:
703*cdf0e10cSrcweir 				{
704*cdf0e10cSrcweir 					FontItalic e = ((SvxPostureItem&)rItem).GetPosture();
705*cdf0e10cSrcweir 					aToolBox.CheckItem( TB_ITALIC, e == ITALIC_NORMAL );
706*cdf0e10cSrcweir 				}
707*cdf0e10cSrcweir 				break;
708*cdf0e10cSrcweir 				case EE_CHAR_OUTLINE:
709*cdf0e10cSrcweir 				break;
710*cdf0e10cSrcweir 				case EE_CHAR_SHADOW:
711*cdf0e10cSrcweir 				break;
712*cdf0e10cSrcweir 			}
713*cdf0e10cSrcweir 		}
714*cdf0e10cSrcweir 	}
715*cdf0e10cSrcweir }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir IMPL_LINK( EditMainWindow, TBSelect, ToolBox *, p )
718*cdf0e10cSrcweir {
719*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
720*cdf0e10cSrcweir 	EditEngine* pEditEngine = pEditView->GetEditEngine();
721*cdf0e10cSrcweir 	USHORT nId = aToolBox.GetCurItemId();
722*cdf0e10cSrcweir 	BOOL bChecked = aToolBox.IsItemChecked( nId );
723*cdf0e10cSrcweir 	SfxPoolItem* pNewItem = 0;
724*cdf0e10cSrcweir 	switch ( nId )
725*cdf0e10cSrcweir 	{
726*cdf0e10cSrcweir 		case TB_LEFT:	pNewItem = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST );
727*cdf0e10cSrcweir 						break;
728*cdf0e10cSrcweir 		case TB_RIGHT:	pNewItem = new SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST );
729*cdf0e10cSrcweir 						break;
730*cdf0e10cSrcweir 		case TB_CENTER:	pNewItem = new SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST );
731*cdf0e10cSrcweir 						break;
732*cdf0e10cSrcweir 		case TB_BLOCK:	pNewItem = new SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST );
733*cdf0e10cSrcweir 						break;
734*cdf0e10cSrcweir 		case TB_HYPH: 	pNewItem = new SfxBoolItem( EE_PARA_HYPHENATE, !bChecked );
735*cdf0e10cSrcweir 						break;
736*cdf0e10cSrcweir 		case TB_UNDO:	pEditView->Undo();
737*cdf0e10cSrcweir 						pEditView->ShowCursor();
738*cdf0e10cSrcweir 						break;
739*cdf0e10cSrcweir 		case TB_REDO:	pEditView->Redo();
740*cdf0e10cSrcweir 						pEditView->ShowCursor();
741*cdf0e10cSrcweir 						break;
742*cdf0e10cSrcweir 		case TB_ONLINESPELL: {
743*cdf0e10cSrcweir 							ULONG nControl = pEditView->GetEditEngine()->GetControlWord();
744*cdf0e10cSrcweir 							if ( bChecked )
745*cdf0e10cSrcweir 								nControl = nControl & ~EE_CNTRL_ONLINESPELLING;
746*cdf0e10cSrcweir 							else
747*cdf0e10cSrcweir 								nControl = nControl | EE_CNTRL_ONLINESPELLING;
748*cdf0e10cSrcweir 							pEditView->GetEditEngine()->SetControlWord( nControl );
749*cdf0e10cSrcweir 							}
750*cdf0e10cSrcweir 							break;
751*cdf0e10cSrcweir 		case TB_REDLINES: {
752*cdf0e10cSrcweir 							ULONG nControl = pEditView->GetEditEngine()->GetControlWord();
753*cdf0e10cSrcweir 							if ( !bChecked )
754*cdf0e10cSrcweir 								nControl = nControl & ~EE_CNTRL_NOREDLINES;
755*cdf0e10cSrcweir 							else
756*cdf0e10cSrcweir 								nControl = nControl | EE_CNTRL_NOREDLINES;
757*cdf0e10cSrcweir 							pEditView->GetEditEngine()->SetControlWord( nControl );
758*cdf0e10cSrcweir 							}
759*cdf0e10cSrcweir 							break;
760*cdf0e10cSrcweir 		case TB_AUTOCORRECT: {
761*cdf0e10cSrcweir 							ULONG nControl = pEditView->GetEditEngine()->GetControlWord();
762*cdf0e10cSrcweir 							if ( bChecked )
763*cdf0e10cSrcweir 								nControl = nControl & ~EE_CNTRL_AUTOCORRECT;
764*cdf0e10cSrcweir 							else
765*cdf0e10cSrcweir 								nControl = nControl | EE_CNTRL_AUTOCORRECT;
766*cdf0e10cSrcweir 							pEditView->GetEditEngine()->SetControlWord( nControl );
767*cdf0e10cSrcweir 							}
768*cdf0e10cSrcweir 							break;
769*cdf0e10cSrcweir 		case TB_STDSEL:	if ( bChecked )
770*cdf0e10cSrcweir 							pEditView->SetSelectionMode( EE_SELMODE_TXTONLY );
771*cdf0e10cSrcweir 						else
772*cdf0e10cSrcweir 							pEditView->SetSelectionMode( EE_SELMODE_STD );
773*cdf0e10cSrcweir 						break;
774*cdf0e10cSrcweir 		case TB_FLAT:	pEditEngine->SetFlatMode( !pEditEngine->IsFlatMode() );
775*cdf0e10cSrcweir 						break;
776*cdf0e10cSrcweir 		case TB_COLORS:	{
777*cdf0e10cSrcweir 							ULONG nControl = pEditView->GetEditEngine()->GetControlWord();
778*cdf0e10cSrcweir 							if ( bChecked )
779*cdf0e10cSrcweir 								nControl = nControl | EE_CNTRL_NOCOLORS;
780*cdf0e10cSrcweir 							else
781*cdf0e10cSrcweir 								nControl = nControl & ~EE_CNTRL_NOCOLORS;
782*cdf0e10cSrcweir 							pEditView->GetEditEngine()->SetControlWord( nControl );
783*cdf0e10cSrcweir 						}
784*cdf0e10cSrcweir //						aViewWin.Invalidate();
785*cdf0e10cSrcweir 						pEditView->GetEditEngine()->Draw( pEditView->GetWindow(), pEditView->GetOutputArea(), pEditView->GetVisArea().TopLeft() );
786*cdf0e10cSrcweir 						break;
787*cdf0e10cSrcweir 		case TB_OUTL:	{
788*cdf0e10cSrcweir 							ULONG nControl = pEditView->GetEditEngine()->GetControlWord();
789*cdf0e10cSrcweir 							if ( !bChecked )
790*cdf0e10cSrcweir 								nControl = nControl | EE_CNTRL_OUTLINER;
791*cdf0e10cSrcweir 							else
792*cdf0e10cSrcweir 								nControl = nControl & ~EE_CNTRL_OUTLINER;
793*cdf0e10cSrcweir 							pEditView->GetEditEngine()->SetControlWord( nControl );
794*cdf0e10cSrcweir 						}
795*cdf0e10cSrcweir 						break;
796*cdf0e10cSrcweir 		case TB_POLY:	{
797*cdf0e10cSrcweir 							if ( !bChecked )
798*cdf0e10cSrcweir 								CreatePolygon();
799*cdf0e10cSrcweir 							else
800*cdf0e10cSrcweir 								pEditView->GetEditEngine()->ClearPolygon();
801*cdf0e10cSrcweir 						}
802*cdf0e10cSrcweir 						break;
803*cdf0e10cSrcweir 		case TB_IDLE:	pEditEngine->EnableIdleFormatter( !pEditEngine->IsIdleFormatterEnabled() );
804*cdf0e10cSrcweir 						break;
805*cdf0e10cSrcweir 		case TB_INSFLD:	{
806*cdf0e10cSrcweir 						static BYTE nFld = 0;
807*cdf0e10cSrcweir 						if ( nFld > 2 )
808*cdf0e10cSrcweir 							nFld = 0;
809*cdf0e10cSrcweir 						if ( nFld == 0 )
810*cdf0e10cSrcweir 						{
811*cdf0e10cSrcweir 							SvxFieldItem aFld( SvxURLField( String( RTL_CONSTASCII_USTRINGPARAM( "www.mopo.de" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "Bla" ) ), SVXURLFORMAT_REPR ), EE_FEATURE_FIELD  );
812*cdf0e10cSrcweir 							pEditView->InsertField( aFld );
813*cdf0e10cSrcweir 						}
814*cdf0e10cSrcweir 						else if ( nFld == 1 )
815*cdf0e10cSrcweir 							pEditView->InsertField( SvxFieldItem( SvxURLField( String( RTL_CONSTASCII_USTRINGPARAM( "www.mopo.de" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "Morgenpost" ) ), SVXURLFORMAT_URL ), EE_FEATURE_FIELD  ) );
816*cdf0e10cSrcweir 						else if ( nFld == 2 )
817*cdf0e10cSrcweir 							pEditView->InsertField( SvxFieldItem( SvxDateField( Date( 1,1,1995 ), SVXDATETYPE_FIX, SVXDATEFORMAT_D ), EE_FEATURE_FIELD ) );
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir 						nFld++;
820*cdf0e10cSrcweir 		}
821*cdf0e10cSrcweir 						break;
822*cdf0e10cSrcweir 		case TB_UPDFLD:	pEditEngine->UpdateFields();
823*cdf0e10cSrcweir 						break;
824*cdf0e10cSrcweir 		case TB_INSERT:	pEditView->SetInsertMode( !pEditView->IsInsertMode() );
825*cdf0e10cSrcweir 						break;
826*cdf0e10cSrcweir 		case TB_FONT1:	pNewItem = new SvxFontItem( FAMILY_ROMAN, String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ), String(), PITCH_DONTKNOW, RTL_TEXTENCODING_MS_1252, EE_CHAR_FONTINFO );
827*cdf0e10cSrcweir 						break;
828*cdf0e10cSrcweir 		case TB_FONT2:	pNewItem = new SvxFontItem( FAMILY_SWISS, String( RTL_CONSTASCII_USTRINGPARAM( "Helv" ) ), String(), PITCH_DONTKNOW, RTL_TEXTENCODING_MS_1252, EE_CHAR_FONTINFO );
829*cdf0e10cSrcweir 						break;
830*cdf0e10cSrcweir /*
831*cdf0e10cSrcweir 		case TB_FONT:
832*cdf0e10cSrcweir 		{
833*cdf0e10cSrcweir 			FontDialog* pDlg = new FontDialog( this, WB_SVLOOK );
834*cdf0e10cSrcweir 			pDlg->SetPrinter( pPrinter );
835*cdf0e10cSrcweir 			Font aFont = pEditEngine->CreateFontFromItemSet( pEditView->GetAttribs() );
836*cdf0e10cSrcweir 			MapMode aPntMode( MAP_POINT );
837*cdf0e10cSrcweir 			MapMode aCurrent( aViewWin.GetMapMode() );
838*cdf0e10cSrcweir 			Size aSz(  aViewWin.LogicToLogic( aFont.GetSize(), &aCurrent, &aPntMode ) );
839*cdf0e10cSrcweir 			aSz.Width() *= 10;
840*cdf0e10cSrcweir 			aSz.Height() *= 10;
841*cdf0e10cSrcweir 			aFont.SetSize(  aSz );
842*cdf0e10cSrcweir 			pDlg->SetSelectFont( aFont );
843*cdf0e10cSrcweir 			if ( pDlg->Execute() )
844*cdf0e10cSrcweir 			{
845*cdf0e10cSrcweir 				Font aNewFont( pDlg->GetSelectFont() );
846*cdf0e10cSrcweir 				aSz = aViewWin.LogicToLogic( aNewFont.GetSize(), &aPntMode, &aCurrent );
847*cdf0e10cSrcweir 				aSz.Width() /= 10;
848*cdf0e10cSrcweir 				aSz.Height() /= 10;
849*cdf0e10cSrcweir 				aNewFont.SetSize( aSz );
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 				SfxItemSet aSet( pEditEngine->GetEmptyItemSet() );
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir 				pEditEngine->SetFontInfoInItemSet( aSet, aNewFont );
854*cdf0e10cSrcweir 				pEditView->SetAttribs( aSet );
855*cdf0e10cSrcweir 			}
856*cdf0e10cSrcweir 			delete pDlg;
857*cdf0e10cSrcweir 		}
858*cdf0e10cSrcweir 		break;
859*cdf0e10cSrcweir */
860*cdf0e10cSrcweir 		case TB_BOLD:	if ( bChecked )
861*cdf0e10cSrcweir 							pNewItem = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT);
862*cdf0e10cSrcweir 						else
863*cdf0e10cSrcweir 							pNewItem = new SvxWeightItem( WEIGHT_BOLD, EE_CHAR_WEIGHT);
864*cdf0e10cSrcweir 						break;
865*cdf0e10cSrcweir 		case TB_ITALIC:	if ( bChecked )
866*cdf0e10cSrcweir 							pNewItem = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC );
867*cdf0e10cSrcweir 						else
868*cdf0e10cSrcweir 							pNewItem = new SvxPostureItem( ITALIC_NORMAL, EE_CHAR_ITALIC );
869*cdf0e10cSrcweir 						break;
870*cdf0e10cSrcweir 		case TB_UNDERLINE:	if ( bChecked )
871*cdf0e10cSrcweir 								pNewItem = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE );
872*cdf0e10cSrcweir 							else
873*cdf0e10cSrcweir 								pNewItem = new SvxUnderlineItem( UNDERLINE_SINGLE, EE_CHAR_UNDERLINE );
874*cdf0e10cSrcweir 						break;
875*cdf0e10cSrcweir 		case TB_WLM:	pNewItem = new SvxWordLineModeItem( !bChecked, EE_CHAR_WLM );
876*cdf0e10cSrcweir 						break;
877*cdf0e10cSrcweir 		case TB_PKERN:	pNewItem = new SvxAutoKernItem( !bChecked, EE_CHAR_PAIRKERNING );
878*cdf0e10cSrcweir 						break;
879*cdf0e10cSrcweir 		case TB_KERN:	if ( bChecked )
880*cdf0e10cSrcweir 								pNewItem = new SvxKerningItem( 0, EE_CHAR_KERNING );
881*cdf0e10cSrcweir 							else
882*cdf0e10cSrcweir 								pNewItem = new SvxKerningItem( 100, EE_CHAR_KERNING);
883*cdf0e10cSrcweir 						break;
884*cdf0e10cSrcweir 		case TB_SUPER:	if ( bChecked )
885*cdf0e10cSrcweir 								pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_OFF, EE_CHAR_ESCAPEMENT);
886*cdf0e10cSrcweir 							else
887*cdf0e10cSrcweir //								pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT);
888*cdf0e10cSrcweir 								pNewItem = new SvxEscapementItem( 50, 100, EE_CHAR_ESCAPEMENT );
889*cdf0e10cSrcweir 						break;
890*cdf0e10cSrcweir 		case TB_SUB:	if ( bChecked )
891*cdf0e10cSrcweir 								pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_OFF, EE_CHAR_ESCAPEMENT);
892*cdf0e10cSrcweir 							else
893*cdf0e10cSrcweir //								pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT);
894*cdf0e10cSrcweir 								pNewItem = new SvxEscapementItem( -50, 100, EE_CHAR_ESCAPEMENT );
895*cdf0e10cSrcweir 						break;
896*cdf0e10cSrcweir 		case TB_GREEN:	pNewItem = new SvxColorItem( Color(COL_GREEN), EE_CHAR_COLOR);
897*cdf0e10cSrcweir 						break;
898*cdf0e10cSrcweir 		case TB_RED:	pNewItem = new SvxColorItem( Color(COL_RED), EE_CHAR_COLOR);
899*cdf0e10cSrcweir 						break;
900*cdf0e10cSrcweir 		case TB_BLACK:	pNewItem = new SvxColorItem( Color(COL_BLACK), EE_CHAR_COLOR);
901*cdf0e10cSrcweir 						break;
902*cdf0e10cSrcweir 		case TB_SBL:	pNewItem = new SvxLineSpacingItem( 0, EE_PARA_SBL );
903*cdf0e10cSrcweir 						if ( bChecked )
904*cdf0e10cSrcweir 						{
905*cdf0e10cSrcweir 							((SvxLineSpacingItem*)pNewItem)->SetInterLineSpace( 0 );
906*cdf0e10cSrcweir 						}
907*cdf0e10cSrcweir 						else
908*cdf0e10cSrcweir 						{
909*cdf0e10cSrcweir 							((SvxLineSpacingItem*)pNewItem)->SetPropLineSpace( 150 );
910*cdf0e10cSrcweir 						}
911*cdf0e10cSrcweir 						break;
912*cdf0e10cSrcweir 		case TB_SBSA:	pNewItem = new SvxULSpaceItem( EE_PARA_ULSPACE );
913*cdf0e10cSrcweir 						if ( !bChecked )
914*cdf0e10cSrcweir 						{
915*cdf0e10cSrcweir 							((SvxULSpaceItem*)pNewItem)->SetUpper( 400 );
916*cdf0e10cSrcweir 							((SvxULSpaceItem*)pNewItem)->SetLower( 400 );
917*cdf0e10cSrcweir 						}
918*cdf0e10cSrcweir 						break;
919*cdf0e10cSrcweir 		case TB_LR:		pNewItem = new SvxLRSpaceItem( EE_PARA_LRSPACE );
920*cdf0e10cSrcweir 						if ( !bChecked )
921*cdf0e10cSrcweir 						{
922*cdf0e10cSrcweir 							((SvxLRSpaceItem*)pNewItem)->SetTxtLeft( 1000 );
923*cdf0e10cSrcweir 							((SvxLRSpaceItem*)pNewItem)->SetTxtFirstLineOfst( -500 );
924*cdf0e10cSrcweir 							((SvxLRSpaceItem*)pNewItem)->SetRight( 500 );
925*cdf0e10cSrcweir 						}
926*cdf0e10cSrcweir 						break;
927*cdf0e10cSrcweir 		case TB_DEFTAB:	if ( bChecked )
928*cdf0e10cSrcweir 							pEditEngine->SetDefTab( 2000 );
929*cdf0e10cSrcweir 						else
930*cdf0e10cSrcweir 							pEditEngine->SetDefTab( 600 );
931*cdf0e10cSrcweir 						pEditView->ShowCursor();
932*cdf0e10cSrcweir 						aToolBox.CheckItem( nId, !bChecked );
933*cdf0e10cSrcweir 						break;
934*cdf0e10cSrcweir 		case TB_DRAW:   {
935*cdf0e10cSrcweir 							pTmpWindow->SetMapMode( aViewWin.GetMapMode() );
936*cdf0e10cSrcweir 							pTmpWindow->SetBackgroundBrush( Brush( Color( COL_GRAY ) ) );
937*cdf0e10cSrcweir 							pTmpWindow->SetFillInBrush( Brush( Color( COL_LIGHTGRAY ) ) );
938*cdf0e10cSrcweir 							pTmpWindow->Show();
939*cdf0e10cSrcweir 							pTmpWindow->Invalidate();
940*cdf0e10cSrcweir 							pTmpWindow->Update();
941*cdf0e10cSrcweir 							pTmpWindow->DrawText( Point( 20, 20 ), String( RTL_CONSTASCII_USTRINGPARAM( "It's a Test..." ) ) );
942*cdf0e10cSrcweir 							Rectangle aRect( Point( 500, 500 ), Size( 10000, 4000 ) );
943*cdf0e10cSrcweir 							pTmpWindow->DrawRect( aRect );
944*cdf0e10cSrcweir 							pEditEngine->Draw( pTmpWindow, aRect, Point( 0, 0 ) );
945*cdf0e10cSrcweir 							nRotation = 0;
946*cdf0e10cSrcweir 						}
947*cdf0e10cSrcweir 						break;
948*cdf0e10cSrcweir 		case TB_ROTATE:   {
949*cdf0e10cSrcweir 							nRotation += 100;
950*cdf0e10cSrcweir 							if ( nRotation == 3600 )
951*cdf0e10cSrcweir 								nRotation = 0;
952*cdf0e10cSrcweir 							pTmpWindow->SetMapMode( aViewWin.GetMapMode() );
953*cdf0e10cSrcweir 							pTmpWindow->SetBackgroundBrush( Brush( Color( COL_LIGHTGRAY ) ) );
954*cdf0e10cSrcweir 							pTmpWindow->SetFillInBrush( Brush( Color( COL_LIGHTGRAY ) ) );
955*cdf0e10cSrcweir 							pTmpWindow->Show();
956*cdf0e10cSrcweir 							pTmpWindow->Invalidate();
957*cdf0e10cSrcweir 							pTmpWindow->Update();
958*cdf0e10cSrcweir 							pTmpWindow->DrawText( Point( 20, 20 ), String( RTL_CONSTASCII_USTRINGPARAM( "It's a Test..." ) ) );
959*cdf0e10cSrcweir 							Rectangle aRect( Point( 500, 500 ), Size( 10000, 4000 ) );
960*cdf0e10cSrcweir 							pEditEngine->Draw( pTmpWindow, Point( 2000, 4000 ), nRotation );
961*cdf0e10cSrcweir 						}
962*cdf0e10cSrcweir 						break;
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir 		case TB_MOVE:
965*cdf0e10cSrcweir 		{
966*cdf0e10cSrcweir 			ESelection aESel = pEditView->GetSelection();
967*cdf0e10cSrcweir 			USHORT nStartPara = Min( aESel.nStartPara, aESel.nEndPara );
968*cdf0e10cSrcweir 			USHORT nEndPara = Max( aESel.nStartPara, aESel.nEndPara );
969*cdf0e10cSrcweir 			pEditView->MoveParagraphs( Range(nStartPara,nEndPara), 2 );
970*cdf0e10cSrcweir 		}
971*cdf0e10cSrcweir 		break;
972*cdf0e10cSrcweir 		case TB_PARATTR1:
973*cdf0e10cSrcweir 		{
974*cdf0e10cSrcweir 			pEditEngine->SetUpdateMode( FALSE );
975*cdf0e10cSrcweir 			USHORT nPara = 0;
976*cdf0e10cSrcweir 			SfxItemSet aSet( pEditEngine->GetEmptyItemSet() );
977*cdf0e10cSrcweir 			aSet.Put( SvxFontItem( FAMILY_DECORATIVE, String( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) ), String(),PITCH_DONTKNOW, RTL_TEXTENCODING_MS_1252, EE_CHAR_FONTINFO ) );
978*cdf0e10cSrcweir 			aSet.Put( SvxColorItem( Color(COL_MAGENTA), EE_CHAR_COLOR ) );
979*cdf0e10cSrcweir 			aSet.Put( SvxFontHeightItem(600, 100, EE_CHAR_FONTHEIGHT) );
980*cdf0e10cSrcweir 			aSet.Put( SvxPostureItem( ITALIC_NORMAL, EE_CHAR_ITALIC ) );
981*cdf0e10cSrcweir 			aSet.Put( SvxLRSpaceItem( 0, 0, 1000, 0, EE_PARA_LRSPACE ) );
982*cdf0e10cSrcweir 			pEditView->SetParaAttribs( aSet, nPara );
983*cdf0e10cSrcweir 			pEditEngine->SetUpdateMode( TRUE );
984*cdf0e10cSrcweir 			pEditView->ShowCursor();
985*cdf0e10cSrcweir 		}
986*cdf0e10cSrcweir 		break;
987*cdf0e10cSrcweir 		case TB_BINOBJ1:
988*cdf0e10cSrcweir 		{
989*cdf0e10cSrcweir 			delete pBinObj;
990*cdf0e10cSrcweir 			pBinObj = pEditEngine->CreateTextObject();
991*cdf0e10cSrcweir 		}
992*cdf0e10cSrcweir 		break;
993*cdf0e10cSrcweir 		case TB_BINOBJ1b:
994*cdf0e10cSrcweir 		{
995*cdf0e10cSrcweir 			delete pBinObj;
996*cdf0e10cSrcweir 			pBinObj = pEditView->CreateTextObject();
997*cdf0e10cSrcweir 		}
998*cdf0e10cSrcweir 		break;
999*cdf0e10cSrcweir 		case TB_CLONEBIN:
1000*cdf0e10cSrcweir 		{
1001*cdf0e10cSrcweir 			if ( pBinObj )
1002*cdf0e10cSrcweir 			{
1003*cdf0e10cSrcweir 				EditTextObject* p = pBinObj->Clone();
1004*cdf0e10cSrcweir 				delete pBinObj;
1005*cdf0e10cSrcweir 				pBinObj = p;
1006*cdf0e10cSrcweir 			}
1007*cdf0e10cSrcweir 		}
1008*cdf0e10cSrcweir 		break;
1009*cdf0e10cSrcweir 		case TB_BINOBJ2b:
1010*cdf0e10cSrcweir 		{
1011*cdf0e10cSrcweir 			if ( pBinObj )
1012*cdf0e10cSrcweir 			{
1013*cdf0e10cSrcweir 				pEditView->InsertText( *pBinObj );
1014*cdf0e10cSrcweir 			}
1015*cdf0e10cSrcweir 		}
1016*cdf0e10cSrcweir 		break;
1017*cdf0e10cSrcweir 		case TB_BINOBJ3:
1018*cdf0e10cSrcweir 		{
1019*cdf0e10cSrcweir 			if ( !pFileDialogBox2->Execute() )
1020*cdf0e10cSrcweir 				return FALSE;
1021*cdf0e10cSrcweir 			DirEntry aDirEntry( pFileDialogBox2->GetPath() );
1022*cdf0e10cSrcweir 			SvFileStream aStrm( aDirEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC );
1023*cdf0e10cSrcweir 			EditTextObject* pTmpObj = pEditEngine->CreateTextObject();
1024*cdf0e10cSrcweir 			pTmpObj->Store( aStrm );
1025*cdf0e10cSrcweir 			DBG_ASSERT( !aStrm.GetError(), "Store: Error!" );
1026*cdf0e10cSrcweir 			delete pTmpObj;
1027*cdf0e10cSrcweir 		}
1028*cdf0e10cSrcweir 		break;
1029*cdf0e10cSrcweir 		case TB_BINOBJ4:
1030*cdf0e10cSrcweir 		{
1031*cdf0e10cSrcweir 			if ( !pFileDialogBox->Execute() )
1032*cdf0e10cSrcweir 				return FALSE;
1033*cdf0e10cSrcweir 			DirEntry aDirEntry( pFileDialogBox->GetPath() );
1034*cdf0e10cSrcweir 			SvFileStream aStrm( aDirEntry.GetFull(), STREAM_READ );
1035*cdf0e10cSrcweir 			delete pBinObj;
1036*cdf0e10cSrcweir 			pBinObj = EditTextObject::Create( aStrm );
1037*cdf0e10cSrcweir //			EditTextObject* pTmpObj = pEditEngine->CreateTextObject( aStrm );
1038*cdf0e10cSrcweir //			pEditEngine->SetText( *pTmpObj );
1039*cdf0e10cSrcweir //			pEditView->ShowCursor();
1040*cdf0e10cSrcweir //			delete pTmpObj;
1041*cdf0e10cSrcweir 		}
1042*cdf0e10cSrcweir 		break;
1043*cdf0e10cSrcweir 		case TB_OPEN:
1044*cdf0e10cSrcweir 		case TB_OPEN2:
1045*cdf0e10cSrcweir 		{
1046*cdf0e10cSrcweir 			if ( !pFileDialogBox->Execute() )
1047*cdf0e10cSrcweir 				return FALSE;
1048*cdf0e10cSrcweir 			DirEntry aDirEntry( pFileDialogBox->GetPath() );
1049*cdf0e10cSrcweir 			aDirEntry.ToAbs();
1050*cdf0e10cSrcweir 			String aFileName( aDirEntry.GetFull() );
1051*cdf0e10cSrcweir 			SvFileStream aStrm( aFileName, STREAM_READ );
1052*cdf0e10cSrcweir 			if ( aStrm.GetError() )
1053*cdf0e10cSrcweir 				InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "StreamError!" ) ) ).Execute();
1054*cdf0e10cSrcweir 			Application::EnterWait();
1055*cdf0e10cSrcweir 			if ( nId == TB_OPEN )
1056*cdf0e10cSrcweir 			{
1057*cdf0e10cSrcweir 				if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) )
1058*cdf0e10cSrcweir 					pEditEngine->Read( aStrm, EE_FORMAT_RTF );
1059*cdf0e10cSrcweir 				if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1060*cdf0e10cSrcweir 					pEditEngine->Read( aStrm, EE_FORMAT_HTML );
1061*cdf0e10cSrcweir 				if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1062*cdf0e10cSrcweir 					pEditEngine->Read( aStrm, EE_FORMAT_HTML );
1063*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1064*cdf0e10cSrcweir 					pEditEngine->Read( aStrm, EE_FORMAT_BIN );
1065*cdf0e10cSrcweir 				else
1066*cdf0e10cSrcweir 					pEditEngine->Read( aStrm, EE_FORMAT_TEXT );
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir 				pEditView->ShowCursor();
1069*cdf0e10cSrcweir 			}
1070*cdf0e10cSrcweir 			else
1071*cdf0e10cSrcweir 			{
1072*cdf0e10cSrcweir 				if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) )
1073*cdf0e10cSrcweir 					pEditView->Read( aStrm, EE_FORMAT_RTF );
1074*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1075*cdf0e10cSrcweir 					pEditView->Read( aStrm, EE_FORMAT_BIN );
1076*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1077*cdf0e10cSrcweir 					pEditView->Read( aStrm, EE_FORMAT_HTML );
1078*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1079*cdf0e10cSrcweir 					pEditView->Read( aStrm, EE_FORMAT_HTML );
1080*cdf0e10cSrcweir 				else
1081*cdf0e10cSrcweir 					pEditView->Read( aStrm, EE_FORMAT_TEXT );
1082*cdf0e10cSrcweir 			}
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir 			Application::LeaveWait();
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir 		}
1087*cdf0e10cSrcweir 		break;
1088*cdf0e10cSrcweir 		case TB_PRINT:
1089*cdf0e10cSrcweir 		{
1090*cdf0e10cSrcweir 			pPrinter->SetPageQueueSize( 1 );
1091*cdf0e10cSrcweir 			PrintDialog aPrnDlg( this );
1092*cdf0e10cSrcweir 			aPrnDlg.SetPrinter( pPrinter );
1093*cdf0e10cSrcweir 			if ( aPrnDlg.Execute() )
1094*cdf0e10cSrcweir 			{
1095*cdf0e10cSrcweir 				pPrinter->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "SvEdit - PrinterTest" ) ) );
1096*cdf0e10cSrcweir 				pPrinter->StartPage();
1097*cdf0e10cSrcweir 				Size aSz( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() );
1098*cdf0e10cSrcweir 				Pen aPen( PEN_SOLID );
1099*cdf0e10cSrcweir 				aPen.SetColor( Color( COL_BLACK ) );
1100*cdf0e10cSrcweir 				pPrinter->SetPen( aPen );
1101*cdf0e10cSrcweir 				Rectangle aR( Point( 2000, 4000 ), aSz );
1102*cdf0e10cSrcweir 				pPrinter->DrawRect( aR );
1103*cdf0e10cSrcweir 				// So folgt auf IIISi, 75DPI kein Ausdruck!
1104*cdf0e10cSrcweir //				pPrinter->SetClipRegion( Region( aR ) );
1105*cdf0e10cSrcweir 				pEditEngine->Draw( pPrinter, Point( 2000, 4000 ), nRotation );
1106*cdf0e10cSrcweir //				pPrinter->SetClipRegion();
1107*cdf0e10cSrcweir 				pPrinter->EndPage();
1108*cdf0e10cSrcweir 				pPrinter->EndJob();
1109*cdf0e10cSrcweir 			}
1110*cdf0e10cSrcweir 		}
1111*cdf0e10cSrcweir 		break;
1112*cdf0e10cSrcweir 		case TB_SAVE:
1113*cdf0e10cSrcweir 		case TB_SAVE2:
1114*cdf0e10cSrcweir 		{
1115*cdf0e10cSrcweir 			if ( !pFileDialogBox2->Execute() )
1116*cdf0e10cSrcweir 				return FALSE;
1117*cdf0e10cSrcweir 			DirEntry aDirEntry( pFileDialogBox2->GetPath() );
1118*cdf0e10cSrcweir //			DirEntry aDirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\xxx.rtf" ) ) );
1119*cdf0e10cSrcweir 			SvFileStream aStrm( aDirEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC );
1120*cdf0e10cSrcweir 			Application::EnterWait();
1121*cdf0e10cSrcweir 			if ( nId == TB_SAVE )
1122*cdf0e10cSrcweir 			{
1123*cdf0e10cSrcweir 				if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf") )
1124*cdf0e10cSrcweir 					pEditEngine->Write( aStrm, EE_FORMAT_RTF );
1125*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1126*cdf0e10cSrcweir 					pEditEngine->Write( aStrm, EE_FORMAT_BIN );
1127*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1128*cdf0e10cSrcweir 					pEditEngine->Write( aStrm, EE_FORMAT_HTML );
1129*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1130*cdf0e10cSrcweir 					pEditEngine->Write( aStrm, EE_FORMAT_HTML );
1131*cdf0e10cSrcweir 				else
1132*cdf0e10cSrcweir 					pEditEngine->Write( aStrm, EE_FORMAT_TEXT );
1133*cdf0e10cSrcweir 			}
1134*cdf0e10cSrcweir 			else
1135*cdf0e10cSrcweir 			{
1136*cdf0e10cSrcweir 				if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) )
1137*cdf0e10cSrcweir 					pEditView->Write( aStrm, EE_FORMAT_RTF );
1138*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1139*cdf0e10cSrcweir 					pEditView->Write( aStrm, EE_FORMAT_BIN );
1140*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1141*cdf0e10cSrcweir 					pEditView->Write( aStrm, EE_FORMAT_HTML );
1142*cdf0e10cSrcweir 				else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1143*cdf0e10cSrcweir 					pEditView->Write( aStrm, EE_FORMAT_HTML );
1144*cdf0e10cSrcweir 				else
1145*cdf0e10cSrcweir 					pEditView->Write( aStrm, EE_FORMAT_TEXT );
1146*cdf0e10cSrcweir 			}
1147*cdf0e10cSrcweir 			Application::LeaveWait();
1148*cdf0e10cSrcweir 		}
1149*cdf0e10cSrcweir 		break;
1150*cdf0e10cSrcweir 		case TB_ATTRIBS:
1151*cdf0e10cSrcweir 		{
1152*cdf0e10cSrcweir 			SfxItemSet aCurSet = pEditView->GetAttribs();
1153*cdf0e10cSrcweir 			XubString aDebStr( String( RTL_CONSTASCII_USTRINGPARAM( "Attribute in Selektion:" ) ) );
1154*cdf0e10cSrcweir 			aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "\nVorlage:" ) );
1155*cdf0e10cSrcweir 			XubString aStyle;
1156*cdf0e10cSrcweir //			pEditView->GetStyleSheet( aStyle, eFam );
1157*cdf0e10cSrcweir 			aDebStr += aStyle;
1158*cdf0e10cSrcweir 			for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_ITEMS_END; nWhich++)
1159*cdf0e10cSrcweir 			{
1160*cdf0e10cSrcweir 				aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "\n" ) );
1161*cdf0e10cSrcweir 				aDebStr += String::CreateFromInt32( nWhich );
1162*cdf0e10cSrcweir 				aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "\t" ) );
1163*cdf0e10cSrcweir 				if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF )
1164*cdf0e10cSrcweir 					aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "---" ) );
1165*cdf0e10cSrcweir 				else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE )
1166*cdf0e10cSrcweir 					aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) );
1167*cdf0e10cSrcweir 				else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_ON )
1168*cdf0e10cSrcweir 				{
1169*cdf0e10cSrcweir 					const SfxPoolItem& rItem = aCurSet.Get( nWhich );
1170*cdf0e10cSrcweir 					switch ( nWhich )
1171*cdf0e10cSrcweir 					{
1172*cdf0e10cSrcweir 						case EE_PARA_LRSPACE:
1173*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FI=" ) );
1174*cdf0e10cSrcweir                             aDebStr += String::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetTxtFirstLineOfst() );
1175*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", LI=" ) );
1176*cdf0e10cSrcweir                             aDebStr += String::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetTxtLeft() );
1177*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", RI=" ) );
1178*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetRight() );
1179*cdf0e10cSrcweir 						break;
1180*cdf0e10cSrcweir 						case EE_PARA_ULSPACE:
1181*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "SB=" ) );
1182*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxULSpaceItem&)rItem).GetUpper() );
1183*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", SA=" ) );
1184*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxULSpaceItem&)rItem).GetLower() );
1185*cdf0e10cSrcweir 						break;
1186*cdf0e10cSrcweir 						case EE_PARA_SBL:
1187*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "SBL=" ) );
1188*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxLineSpacingItem&)rItem).GetInterLineSpace() );
1189*cdf0e10cSrcweir 						break;
1190*cdf0e10cSrcweir 						case EE_PARA_JUST:
1191*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "SvxAdust=" ) );
1192*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( (USHORT)((SvxAdjustItem&)rItem).GetAdjust() );
1193*cdf0e10cSrcweir 						break;
1194*cdf0e10cSrcweir 						case EE_PARA_TABS:
1195*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Tabs = ?" ) );
1196*cdf0e10cSrcweir 						break;
1197*cdf0e10cSrcweir 						case EE_CHAR_COLOR:
1198*cdf0e10cSrcweir 						{
1199*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Color= " ) );
1200*cdf0e10cSrcweir 							Color aColor( ((SvxColorItem&)rItem).GetValue() );
1201*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( aColor.GetRed() );
1202*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1203*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( aColor.GetGreen() );
1204*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1205*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( aColor.GetBlue() );
1206*cdf0e10cSrcweir 						}
1207*cdf0e10cSrcweir 						break;
1208*cdf0e10cSrcweir 						case EE_CHAR_FONTINFO:
1209*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Font=" ) );
1210*cdf0e10cSrcweir 							aDebStr += ((SvxFontItem&)rItem).GetFamilyName();
1211*cdf0e10cSrcweir 						break;
1212*cdf0e10cSrcweir 						case EE_CHAR_FONTHEIGHT:
1213*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Groesse=" ) );
1214*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxFontHeightItem&)rItem).GetHeight() );
1215*cdf0e10cSrcweir 						break;
1216*cdf0e10cSrcweir 						case EE_CHAR_WEIGHT:
1217*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontWeight=" ) );
1218*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxWeightItem&)rItem).GetWeight() );
1219*cdf0e10cSrcweir 						break;
1220*cdf0e10cSrcweir 						case EE_CHAR_UNDERLINE:
1221*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline=" ) );
1222*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxUnderlineItem&)rItem).GetLineStyle() );
1223*cdf0e10cSrcweir 						break;
1224*cdf0e10cSrcweir 						case EE_CHAR_WLM:
1225*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "WordLineMode=" ) );
1226*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxWordLineModeItem&)rItem).GetValue() );
1227*cdf0e10cSrcweir 						break;
1228*cdf0e10cSrcweir 						case EE_CHAR_STRIKEOUT:
1229*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout=" ) );
1230*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxCrossedOutItem&)rItem).GetStrikeout() );
1231*cdf0e10cSrcweir 						break;
1232*cdf0e10cSrcweir 						case EE_CHAR_ITALIC:
1233*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontPosture=" ) );
1234*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxPostureItem&)rItem).GetPosture() );
1235*cdf0e10cSrcweir 						break;
1236*cdf0e10cSrcweir 						case EE_CHAR_OUTLINE:
1237*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontOutline=" ) );
1238*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxContourItem&)rItem).GetValue() );
1239*cdf0e10cSrcweir 						break;
1240*cdf0e10cSrcweir 						case EE_CHAR_SHADOW:
1241*cdf0e10cSrcweir 							aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontShadowed=" ) );
1242*cdf0e10cSrcweir 							aDebStr += String::CreateFromInt32( ((SvxShadowedItem&)rItem).GetValue() );
1243*cdf0e10cSrcweir 						break;
1244*cdf0e10cSrcweir 					}
1245*cdf0e10cSrcweir 				}
1246*cdf0e10cSrcweir 				else
1247*cdf0e10cSrcweir 					aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "?" ) );
1248*cdf0e10cSrcweir 			}
1249*cdf0e10cSrcweir 			InfoBox( 0, aDebStr ).Execute();
1250*cdf0e10cSrcweir 		}
1251*cdf0e10cSrcweir 		break;
1252*cdf0e10cSrcweir 	}
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir 	if ( pNewItem )
1255*cdf0e10cSrcweir 	{
1256*cdf0e10cSrcweir 		SfxItemSet aSet = pEditView->GetEmptyItemSet();
1257*cdf0e10cSrcweir 		aSet.Put( *pNewItem );
1258*cdf0e10cSrcweir 		pEditView->SetAttribs( aSet );
1259*cdf0e10cSrcweir 		delete pNewItem;
1260*cdf0e10cSrcweir 	}
1261*cdf0e10cSrcweir 	UpdateToolBox();
1262*cdf0e10cSrcweir 	return 0;
1263*cdf0e10cSrcweir }
1264*cdf0e10cSrcweir 
1265*cdf0e10cSrcweir void EditMainWindow::CreatePolygon()
1266*cdf0e10cSrcweir {
1267*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1268*cdf0e10cSrcweir 	Size aSz = pEditView->GetWindow()->GetOutputSize();
1269*cdf0e10cSrcweir 	Point aOffset( aSz.Width()/8, aSz.Height()/8 );
1270*cdf0e10cSrcweir 	aSz.Width() *= 3;
1271*cdf0e10cSrcweir 	aSz.Width() /= 4;
1272*cdf0e10cSrcweir 	aSz.Height() *= 3;
1273*cdf0e10cSrcweir 	aSz.Height() /= 4;
1274*cdf0e10cSrcweir 	Polygon aPoly( 5 );
1275*cdf0e10cSrcweir 	aPoly.SetPoint( Point( aSz.Width()/2, 0 ), 0 );
1276*cdf0e10cSrcweir 	aPoly.SetPoint( Point( aSz.Width(), aSz.Height()/3 ), 1 );
1277*cdf0e10cSrcweir 	aPoly.SetPoint( Point( aSz.Width()/2, aSz.Height() ), 2 );
1278*cdf0e10cSrcweir 	aPoly.SetPoint( Point( 0, aSz.Height()/2 ), 3 );
1279*cdf0e10cSrcweir 	aPoly.SetPoint( Point( aSz.Width()/2, 0 ), 4 );
1280*cdf0e10cSrcweir 	PolyPolygon aPPoly( aPoly );
1281*cdf0e10cSrcweir 	pEditView->GetEditEngine()->SetPolygon( aPPoly );
1282*cdf0e10cSrcweir 	pEditView->SetOutputArea( Rectangle( aOffset, aSz ) );
1283*cdf0e10cSrcweir 	ULONG nWord = pEditView->GetControlWord();
1284*cdf0e10cSrcweir 	nWord &= ~(EV_CNTRL_AUTOSCROLL);
1285*cdf0e10cSrcweir 	pEditView->SetControlWord( nWord );
1286*cdf0e10cSrcweir 	aViewWin.Invalidate();
1287*cdf0e10cSrcweir }
1288*cdf0e10cSrcweir 
1289*cdf0e10cSrcweir void __EXPORT EditMainWindow::GetFocus()
1290*cdf0e10cSrcweir {
1291*cdf0e10cSrcweir 	aViewWin.GrabFocus();
1292*cdf0e10cSrcweir }
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir IMPL_LINK_INLINE_START( EditMainWindow, HScrollHdl, ScrollBar *, pScrl )
1295*cdf0e10cSrcweir {
1296*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1297*cdf0e10cSrcweir 	pEditView->Scroll( -pScrl->GetDelta(), 0, RGCHK_PAPERSZ1 );
1298*cdf0e10cSrcweir 	return 0;
1299*cdf0e10cSrcweir }
1300*cdf0e10cSrcweir IMPL_LINK_INLINE_END( EditMainWindow, HScrollHdl, ScrollBar *, pScrl )
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir IMPL_LINK_INLINE_START( EditMainWindow, VScrollHdl, ScrollBar *, pScrl )
1303*cdf0e10cSrcweir {
1304*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1305*cdf0e10cSrcweir 	pEditView->Scroll( 0, -pScrl->GetDelta(), RGCHK_PAPERSZ1 );
1306*cdf0e10cSrcweir 	return 0;
1307*cdf0e10cSrcweir }
1308*cdf0e10cSrcweir IMPL_LINK_INLINE_END( EditMainWindow, VScrollHdl, ScrollBar *, pScrl )
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir void EditMainWindow::SetScrollBarRanges()
1311*cdf0e10cSrcweir {
1312*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1313*cdf0e10cSrcweir 	long y = pEditView->GetEditEngine()->GetTextHeight();
1314*cdf0e10cSrcweir 	long x = pEditView->GetEditEngine()->GetPaperSize().Width();
1315*cdf0e10cSrcweir 
1316*cdf0e10cSrcweir 	aHScrollBar.SetRange( Range( 0, x ) );
1317*cdf0e10cSrcweir 	aVScrollBar.SetRange( Range( 0, y ) );
1318*cdf0e10cSrcweir }
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir void EditMainWindow::SetScrollBars()
1321*cdf0e10cSrcweir {
1322*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1323*cdf0e10cSrcweir 	Size aSz = GetOutputSizePixel();
1324*cdf0e10cSrcweir 	Size aRealSz( aSz );
1325*cdf0e10cSrcweir 	long nScrollbarWidthPixel = aVScrollBar.GetSizePixel().Width();
1326*cdf0e10cSrcweir 	long nTBHeight = aToolBox.GetSizePixel().Height();
1327*cdf0e10cSrcweir 	aSz.Height() -= nTBHeight;
1328*cdf0e10cSrcweir 	Size aOrgSz( aSz );
1329*cdf0e10cSrcweir 
1330*cdf0e10cSrcweir 	// VScroll...
1331*cdf0e10cSrcweir 	aSz.Height() += 2;
1332*cdf0e10cSrcweir 	Point aPoint( ( aSz.Width()- nScrollbarWidthPixel+1 ), -1+nTBHeight);
1333*cdf0e10cSrcweir 	aSz.Width() = nScrollbarWidthPixel;
1334*cdf0e10cSrcweir 	aVScrollBar.SetPosSizePixel( aPoint, aSz );
1335*cdf0e10cSrcweir 
1336*cdf0e10cSrcweir 	// HScroll...
1337*cdf0e10cSrcweir 	aSz = aOrgSz;
1338*cdf0e10cSrcweir 	Point aPoint2( 0, aRealSz.Height()-aHScrollBar.GetSizePixel().Height()+1 ); // TB-Height schon drin!
1339*cdf0e10cSrcweir 	aSz.Width() -= aVScrollBar.GetSizePixel().Width();
1340*cdf0e10cSrcweir 	aSz.Width() += 2;
1341*cdf0e10cSrcweir 
1342*cdf0e10cSrcweir 	aSz.Height() = nScrollbarWidthPixel;
1343*cdf0e10cSrcweir 	aHScrollBar.SetPosSizePixel( aPoint2, aSz );
1344*cdf0e10cSrcweir 
1345*cdf0e10cSrcweir 	aHScrollBar.SetVisibleSize( pEditView->GetOutputArea().GetWidth() );
1346*cdf0e10cSrcweir 	aVScrollBar.SetVisibleSize( pEditView->GetOutputArea().GetHeight() );
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir 	SetScrollBarRanges();
1349*cdf0e10cSrcweir 
1350*cdf0e10cSrcweir 	aVScrollBar.Show();
1351*cdf0e10cSrcweir 	aHScrollBar.Show();
1352*cdf0e10cSrcweir }
1353*cdf0e10cSrcweir 
1354*cdf0e10cSrcweir void __EXPORT EditMainWindow::Resize()
1355*cdf0e10cSrcweir {
1356*cdf0e10cSrcweir 	long nBorder = aVScrollBar.GetSizePixel().Width();
1357*cdf0e10cSrcweir 	long nExtra = 10;
1358*cdf0e10cSrcweir 	Size aTBSz = aToolBox.CalcWindowSizePixel();
1359*cdf0e10cSrcweir 	Size aOutSzPixel( GetOutputSizePixel() );
1360*cdf0e10cSrcweir 	aToolBox.SetSizePixel( Size( aOutSzPixel.Width(), aTBSz.Height()) );
1361*cdf0e10cSrcweir 
1362*cdf0e10cSrcweir 	aViewWin.SetSizePixel( Size( aOutSzPixel.Width()-nBorder-2*nExtra, aOutSzPixel.Height()-aTBSz.Height()-2*nExtra-nBorder) );
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir 	aViewWin.SetPosPixel( Point( nExtra, aTBSz.Height()+nExtra ) );
1365*cdf0e10cSrcweir 
1366*cdf0e10cSrcweir 	SetScrollBars();
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1369*cdf0e10cSrcweir 	if ( pEditView && pEditView->GetEditEngine()->GetPolygon() )
1370*cdf0e10cSrcweir 		CreatePolygon();
1371*cdf0e10cSrcweir }
1372*cdf0e10cSrcweir 
1373*cdf0e10cSrcweir IMPL_LINK( EditMainWindow, ShowStatus, EditStatus *, pStat )
1374*cdf0e10cSrcweir {
1375*cdf0e10cSrcweir 	EditView* pEditView = aViewWin.GetEditView();
1376*cdf0e10cSrcweir 	EditEngine* pEditEngine = pEditView->GetEditEngine();
1377*cdf0e10cSrcweir 	if ( ( pStat->GetStatusWord() & EE_STAT_TEXTWIDTHCHANGED ) || ( pStat->GetStatusWord() & EE_STAT_TEXTHEIGHTCHANGED ) )
1378*cdf0e10cSrcweir 	{
1379*cdf0e10cSrcweir 		aViewWin.MarkOutputArea();
1380*cdf0e10cSrcweir 		if ( pEditEngine->GetTextHeight() < (ULONG)pEditView->GetOutputArea().GetHeight() )
1381*cdf0e10cSrcweir 		{
1382*cdf0e10cSrcweir 			// Wird durch RGCHK_PAPERSZ1 'geklippt'
1383*cdf0e10cSrcweir 			if ( !( pEditEngine->GetControlWord() & EE_CNTRL_AUTOPAGESIZE) )
1384*cdf0e10cSrcweir 				pEditView->Scroll( -(long)pEditEngine->CalcTextWidth(), -(long)pEditEngine->GetTextHeight(), RGCHK_PAPERSZ1 );
1385*cdf0e10cSrcweir 		}
1386*cdf0e10cSrcweir 		SetScrollBarRanges();
1387*cdf0e10cSrcweir 	}
1388*cdf0e10cSrcweir 	if ( pStat->GetStatusWord() & EE_STAT_HSCROLL )
1389*cdf0e10cSrcweir 		aHScrollBar.SetThumbPos( pEditView->GetVisArea().Left() );
1390*cdf0e10cSrcweir 	if ( pStat->GetStatusWord() & EE_STAT_VSCROLL )
1391*cdf0e10cSrcweir 		aVScrollBar.SetThumbPos( pEditView->GetVisArea().Top() );
1392*cdf0e10cSrcweir 
1393*cdf0e10cSrcweir 	return 0;
1394*cdf0e10cSrcweir }
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir EditViewWindow::~EditViewWindow()
1398*cdf0e10cSrcweir {
1399*cdf0e10cSrcweir 	// erst die angemeldeten Views zerstoeren
1400*cdf0e10cSrcweir 	// (melden sich selbst ab)
1401*cdf0e10cSrcweir 	MyView* pView = aViewList.First();
1402*cdf0e10cSrcweir 	while ( pView )
1403*cdf0e10cSrcweir 	{
1404*cdf0e10cSrcweir 		delete pView;
1405*cdf0e10cSrcweir 		pView = aViewList.Next();
1406*cdf0e10cSrcweir 	}
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir 	pEditEngine->RemoveView( pEditView );
1409*cdf0e10cSrcweir 	delete pEditView;
1410*cdf0e10cSrcweir 	// Beim Zerstoeren der Styles am Ende, EditEngine noch nicht kaputt,
1411*cdf0e10cSrcweir 	// wird der Handler gerufen, ich zerstore hier aber schon die View!
1412*cdf0e10cSrcweir 	pEditEngine->SetStatusEventHdl( Link() );
1413*cdf0e10cSrcweir //	SvxAutoCorrect* pAutoCorrekt = pEditEngine->GetAutoCorrect();
1414*cdf0e10cSrcweir //	pEditEngine->SetAutoCorrect( 0 );
1415*cdf0e10cSrcweir //	delete pAutoCorrekt;
1416*cdf0e10cSrcweir 	delete pEditEngine;
1417*cdf0e10cSrcweir }
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir EditViewWindow::EditViewWindow( Window* pParent ) :
1420*cdf0e10cSrcweir 				Window( pParent ), aURLPtr( POINTER_HAND )
1421*cdf0e10cSrcweir {
1422*cdf0e10cSrcweir 	SetBackgroundBrush( Brush( Color( COL_WHITE ) ) );
1423*cdf0e10cSrcweir 	SetMapMode( MAP_100TH_MM );
1424*cdf0e10cSrcweir //	EnableDrop();
1425*cdf0e10cSrcweir 
1426*cdf0e10cSrcweir 	SfxItemPool* pPool = EditEngine::CreatePool();
1427*cdf0e10cSrcweir 	Font aFont = GetSettings().GetStyleSettings().GetAppFont();
1428*cdf0e10cSrcweir 	MapMode aPntMode( MAP_POINT );
1429*cdf0e10cSrcweir 	MapMode aCurrent( GetMapMode() );
1430*cdf0e10cSrcweir 	Size aSz( LogicToLogic( Size( 12, 0 ), &aPntMode, &aCurrent ) );
1431*cdf0e10cSrcweir 	aFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ) );
1432*cdf0e10cSrcweir 	pPool->SetPoolDefaultItem( SvxFontItem( aFont.GetFamily(), aFont.GetName(), String(),aFont.GetPitch(), aFont.GetCharSet(), EE_CHAR_FONTINFO ) );
1433*cdf0e10cSrcweir 	pPool->SetPoolDefaultItem( SvxFontHeightItem( aSz.Width(), 100, EE_CHAR_FONTHEIGHT ) );
1434*cdf0e10cSrcweir 	pEditEngine = new MyEditEngine( pPool );
1435*cdf0e10cSrcweir 
1436*cdf0e10cSrcweir 	Size aPaperSz( 10000,8000 );
1437*cdf0e10cSrcweir 	pEditEngine->SetPaperSize( aPaperSz );
1438*cdf0e10cSrcweir 
1439*cdf0e10cSrcweir 	pEditView = new EditView( pEditEngine, this );
1440*cdf0e10cSrcweir 	pEditView->SetBackgroundColor( Color( COL_WHITE ) );
1441*cdf0e10cSrcweir 	pEditView->SetOutputArea( Rectangle( Point( 100, 100 ), aPaperSz ) );
1442*cdf0e10cSrcweir 	pEditEngine->SetDefaultLanguage( LANGUAGE_ENGLISH );
1443*cdf0e10cSrcweir 	pEditEngine->InsertView( pEditView );
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir 	SetPosSizePixel( Point( 10, 10 ), Size( 600, 400 ) );
1446*cdf0e10cSrcweir 	SetPen( PEN_NULL );
1447*cdf0e10cSrcweir 	Show();
1448*cdf0e10cSrcweir 
1449*cdf0e10cSrcweir 	// Feldbefehle grau hinterlegen
1450*cdf0e10cSrcweir 	ULONG n = pEditEngine->GetControlWord();
1451*cdf0e10cSrcweir 	n = n | (EE_CNTRL_MARKFIELDS|EE_CNTRL_AUTOCOMPLETE);
1452*cdf0e10cSrcweir 	pEditEngine->SetControlWord( n );
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir 	// Test: Autozentrierung
1455*cdf0e10cSrcweir //	ULONG n = pEditEngine->GetControlWord();
1456*cdf0e10cSrcweir //	n = n | EE_CNTRL_AUTOPAGESIZE;
1457*cdf0e10cSrcweir //	pEditEngine->SetControlWord( n );
1458*cdf0e10cSrcweir 
1459*cdf0e10cSrcweir 	// OneLineSpeling
1460*cdf0e10cSrcweir #ifdef WNT
1461*cdf0e10cSrcweir //	pEditEngine->CreateSpeller( DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "n:\\offenv\\wnti" ) ) ),
1462*cdf0e10cSrcweir //								DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "n:\\offenv\\wnti" ) ) ) );
1463*cdf0e10cSrcweir //	pEditEngine->GetSpeller()->SetActualLanguage( LANGUAGE_GERMAN );
1464*cdf0e10cSrcweir //	pEditEngine->GetSpeller()->SetDefaultLanguage( LANGUAGE_GERMAN );
1465*cdf0e10cSrcweir //	pEditEngine->GetSpeller()->SetMinTrail( 2 );
1466*cdf0e10cSrcweir 
1467*cdf0e10cSrcweir 	// AutoCorrect wird nie zerstoert
1468*cdf0e10cSrcweir //	pEditEngine->SetAutoCorrect( new SvxAutoCorrect( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\prj\\office\\autotext\\autocorr.dat" ) ) ) );
1469*cdf0e10cSrcweir #endif
1470*cdf0e10cSrcweir }
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir void __EXPORT EditViewWindow::Paint( const Rectangle& rRec )
1473*cdf0e10cSrcweir {
1474*cdf0e10cSrcweir 	if ( pEditView->GetEditEngine()->GetPolygon() )
1475*cdf0e10cSrcweir 	{
1476*cdf0e10cSrcweir 		// Die Punkte des Polygons beziehen sich auf die View...
1477*cdf0e10cSrcweir 		MapMode aMapMode( GetMapMode() );
1478*cdf0e10cSrcweir 		aMapMode.SetOrigin( pEditView->GetOutputArea().TopLeft() );
1479*cdf0e10cSrcweir 		SetMapMode( aMapMode );
1480*cdf0e10cSrcweir 		DrawPolyPolygon( *pEditView->GetEditEngine()->GetPolygon() );
1481*cdf0e10cSrcweir 		aMapMode.SetOrigin( Point() );
1482*cdf0e10cSrcweir 		SetMapMode( aMapMode );
1483*cdf0e10cSrcweir 	}
1484*cdf0e10cSrcweir 	pEditView->Paint( rRec );
1485*cdf0e10cSrcweir 	MarkOutputArea();
1486*cdf0e10cSrcweir }
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir void EditViewWindow::MarkOutputArea()
1489*cdf0e10cSrcweir {
1490*cdf0e10cSrcweir 	static Rectangle aCurFrame;
1491*cdf0e10cSrcweir 	Rectangle aOutArea( pEditView->GetOutputArea() );
1492*cdf0e10cSrcweir 	aOutArea = LogicToPixel( aOutArea );
1493*cdf0e10cSrcweir 	aOutArea.Left()--;
1494*cdf0e10cSrcweir 	aOutArea.Right()++;
1495*cdf0e10cSrcweir 	aOutArea.Top()--;
1496*cdf0e10cSrcweir 	aOutArea.Bottom()++;
1497*cdf0e10cSrcweir 	aOutArea = PixelToLogic( aOutArea );
1498*cdf0e10cSrcweir 	SetPen( Pen( Color( COL_RED ) ) );
1499*cdf0e10cSrcweir 	SetFillInBrush( Brush( BRUSH_NULL ) );
1500*cdf0e10cSrcweir 	DrawRect( aOutArea );
1501*cdf0e10cSrcweir 	if ( !aCurFrame.IsEmpty() )
1502*cdf0e10cSrcweir 	{
1503*cdf0e10cSrcweir 		if ( aCurFrame.Left() < aOutArea.Left() )
1504*cdf0e10cSrcweir 			Invalidate( Rectangle( aCurFrame.TopLeft(), Size( aOutArea.Left()-aCurFrame.Left(), aCurFrame.GetHeight() ) ) );
1505*cdf0e10cSrcweir 		if ( aCurFrame.Right() > aOutArea.Right() )
1506*cdf0e10cSrcweir 		{
1507*cdf0e10cSrcweir 			long nW = aCurFrame.Right() - aOutArea.Right();
1508*cdf0e10cSrcweir 			Point aPos( aCurFrame.TopRight() );
1509*cdf0e10cSrcweir 			aPos.X() -= nW;
1510*cdf0e10cSrcweir 			Invalidate( Rectangle( aPos, Size( nW, aCurFrame.GetHeight() ) ) );
1511*cdf0e10cSrcweir 		}
1512*cdf0e10cSrcweir 		if ( aCurFrame.Top() < aOutArea.Top() )
1513*cdf0e10cSrcweir 			Invalidate( Rectangle( aCurFrame.TopLeft(), Size( aCurFrame.GetWidth(), aOutArea.Top() - aCurFrame.Top() ) ) );
1514*cdf0e10cSrcweir 		if ( aCurFrame.Bottom() > aOutArea.Bottom() )
1515*cdf0e10cSrcweir 		{
1516*cdf0e10cSrcweir 			long nH = aCurFrame.Bottom() - aOutArea.Bottom();
1517*cdf0e10cSrcweir 			Point aPos( aCurFrame.BottomLeft() );
1518*cdf0e10cSrcweir 			aPos.Y() -= nH;
1519*cdf0e10cSrcweir 			Invalidate( Rectangle( aPos, Size( aCurFrame.GetWidth(), nH ) ) );
1520*cdf0e10cSrcweir 		}
1521*cdf0e10cSrcweir 	}
1522*cdf0e10cSrcweir 	aCurFrame = aOutArea;
1523*cdf0e10cSrcweir }
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir void __EXPORT EditViewWindow::Resize()
1526*cdf0e10cSrcweir {
1527*cdf0e10cSrcweir 	Size aPaperSz( GetOutputSize() );
1528*cdf0e10cSrcweir 	pEditView->SetOutputArea( Rectangle( Point(0,0), aPaperSz ) );
1529*cdf0e10cSrcweir 	pEditEngine->SetPaperSize( Size( aPaperSz.Width()*1, aPaperSz.Height()*1 ) );
1530*cdf0e10cSrcweir 	pEditView->ShowCursor();
1531*cdf0e10cSrcweir 	Invalidate();
1532*cdf0e10cSrcweir }
1533*cdf0e10cSrcweir 
1534*cdf0e10cSrcweir void __EXPORT EditViewWindow::KeyInput( const KeyEvent& rKEvt )
1535*cdf0e10cSrcweir {
1536*cdf0e10cSrcweir 	sal_Unicode nCharCode = rKEvt.GetCharCode();
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir 	USHORT nCode = rKEvt.GetKeyCode().GetCode();
1539*cdf0e10cSrcweir 	// Auswertung fuer besondere Einstellungen....
1540*cdf0e10cSrcweir 	if ( ( nCode == KEY_A) && rKEvt.GetKeyCode().IsMod1() )
1541*cdf0e10cSrcweir 		pEditView->SetSelection( ESelection( 0, 0, 0xFFFF, 0xFFFF ) );
1542*cdf0e10cSrcweir 	else if ( ( nCode == KEY_R ) && rKEvt.GetKeyCode().IsMod2() )
1543*cdf0e10cSrcweir 		Invalidate();
1544*cdf0e10cSrcweir 	else if ( ( nCode == KEY_L ) && rKEvt.GetKeyCode().IsMod2() )
1545*cdf0e10cSrcweir 	{
1546*cdf0e10cSrcweir 		ULONG n = pEditEngine->GetControlWord();
1547*cdf0e10cSrcweir 		n = n | EE_CNTRL_ONECHARPERLINE;
1548*cdf0e10cSrcweir 		pEditEngine->SetControlWord( n );
1549*cdf0e10cSrcweir 		pEditEngine->QuickFormatDoc();
1550*cdf0e10cSrcweir 	}
1551*cdf0e10cSrcweir 	else if ( ( nCode == KEY_Z ) && rKEvt.GetKeyCode().IsMod2() )
1552*cdf0e10cSrcweir 	{
1553*cdf0e10cSrcweir 		pEditView->RemoveAttribs();
1554*cdf0e10cSrcweir 	}
1555*cdf0e10cSrcweir 	else if ( ( nCode == KEY_V ) && rKEvt.GetKeyCode().IsMod2() )
1556*cdf0e10cSrcweir 	{
1557*cdf0e10cSrcweir 		pEditEngine->SetVertical( TRUE );
1558*cdf0e10cSrcweir 		Invalidate();
1559*cdf0e10cSrcweir 	}
1560*cdf0e10cSrcweir 	else if ( ( ( nCode == KEY_ADD ) || ( nCode == KEY_SUBTRACT ) )&& rKEvt.GetKeyCode().IsMod2() )
1561*cdf0e10cSrcweir 	{
1562*cdf0e10cSrcweir 		short nDiff = ( nCode == KEY_ADD ) ? (+5) : (-5);
1563*cdf0e10cSrcweir 		if ( nZoom > 1000 )
1564*cdf0e10cSrcweir 			nDiff *= 20;
1565*cdf0e10cSrcweir 		if ( nZoom <= 25 )
1566*cdf0e10cSrcweir 			nDiff /= 5;
1567*cdf0e10cSrcweir 		if ( ( nZoom + nDiff ) > 0 )
1568*cdf0e10cSrcweir 			nZoom += nDiff;
1569*cdf0e10cSrcweir 		MapMode aMapMode( MAP_100TH_MM, Point(0,0), Fraction(nZoom,100), Fraction(nZoom,100) );
1570*cdf0e10cSrcweir 		SetMapMode( aMapMode );
1571*cdf0e10cSrcweir 		((EditMainWindow*)GetParent())->SetTitle();
1572*cdf0e10cSrcweir 
1573*cdf0e10cSrcweir 		if ( rKEvt.GetKeyCode().IsMod1() )
1574*cdf0e10cSrcweir 		{
1575*cdf0e10cSrcweir 			InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "ChangingRefMapMode..." ) ) ).Execute();
1576*cdf0e10cSrcweir 			pEditEngine->SetRefMapMode( aMapMode );
1577*cdf0e10cSrcweir 		}
1578*cdf0e10cSrcweir 		Invalidate();
1579*cdf0e10cSrcweir 	}
1580*cdf0e10cSrcweir 	else if ( rKEvt.GetKeyCode().IsMod2() &&
1581*cdf0e10cSrcweir 			( ( nCode == KEY_UP) || ( nCode == KEY_DOWN ) ||
1582*cdf0e10cSrcweir 			  ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) ) )
1583*cdf0e10cSrcweir 	{
1584*cdf0e10cSrcweir 		if( rKEvt.GetKeyCode().IsMod1() )
1585*cdf0e10cSrcweir 		{
1586*cdf0e10cSrcweir 			ULONG nCtrl = pEditEngine->GetControlWord();
1587*cdf0e10cSrcweir 			if ( ! ( nCtrl & EE_CNTRL_STRETCHING ) )
1588*cdf0e10cSrcweir 			{
1589*cdf0e10cSrcweir 				nCtrl |= EE_CNTRL_STRETCHING;
1590*cdf0e10cSrcweir 				pEditEngine->SetControlWord( nCtrl );
1591*cdf0e10cSrcweir 			}
1592*cdf0e10cSrcweir 			USHORT nX, nY;
1593*cdf0e10cSrcweir 			pEditEngine->GetGlobalCharStretching( nX, nY );
1594*cdf0e10cSrcweir 			if ( ( nCode == KEY_DOWN ) && ( nY > 5 ) )
1595*cdf0e10cSrcweir 				nY += 5;
1596*cdf0e10cSrcweir 			else if ( nCode == KEY_UP )
1597*cdf0e10cSrcweir 				nY -= 5;
1598*cdf0e10cSrcweir 			else if ( nCode == KEY_RIGHT )
1599*cdf0e10cSrcweir 				nX += 5;
1600*cdf0e10cSrcweir 			else if ( ( nCode == KEY_LEFT ) && ( nX > 5 ) )
1601*cdf0e10cSrcweir 				nX -= 5;
1602*cdf0e10cSrcweir 			pEditEngine->SetGlobalCharStretching( nX, nY );
1603*cdf0e10cSrcweir 			((EditMainWindow*)GetParent())->SetTitle();
1604*cdf0e10cSrcweir 		}
1605*cdf0e10cSrcweir 		else	// ZeichenAttr
1606*cdf0e10cSrcweir 		{
1607*cdf0e10cSrcweir 			SfxItemSet aAttrs( pEditView->GetAttribs() );
1608*cdf0e10cSrcweir 			SfxItemSet aNewAttrs( pEditEngine->GetEmptyItemSet() );
1609*cdf0e10cSrcweir 			const SvxFontWidthItem& rItem = (const SvxFontWidthItem&)aAttrs.Get( EE_CHAR_FONTWIDTH );
1610*cdf0e10cSrcweir 			USHORT nProp = rItem.GetProp();
1611*cdf0e10cSrcweir 			if ( nCode == KEY_RIGHT )
1612*cdf0e10cSrcweir 				nProp += 5;
1613*cdf0e10cSrcweir 			else if ( ( nCode == KEY_LEFT ) && ( nProp > 5 ) )
1614*cdf0e10cSrcweir 				nProp -= 5;
1615*cdf0e10cSrcweir 			aNewAttrs.Put( SvxFontWidthItem( 0, nProp, EE_CHAR_FONTWIDTH ) );
1616*cdf0e10cSrcweir 			pEditView->SetAttribs( aNewAttrs );
1617*cdf0e10cSrcweir 		}
1618*cdf0e10cSrcweir 	}
1619*cdf0e10cSrcweir 	else if ( ( nCode == KEY_O ) && rKEvt.GetKeyCode().IsMod2() )
1620*cdf0e10cSrcweir 	{
1621*cdf0e10cSrcweir 		MapMode aMapMode( GetMapMode() );
1622*cdf0e10cSrcweir 		aMapMode.SetOrigin( Point( 41, 41 ) );
1623*cdf0e10cSrcweir 		SetMapMode( aMapMode );
1624*cdf0e10cSrcweir 		Invalidate();
1625*cdf0e10cSrcweir 	}
1626*cdf0e10cSrcweir 	else if ( ( nCode == KEY_B ) && rKEvt.GetKeyCode().IsMod2() )
1627*cdf0e10cSrcweir 	{
1628*cdf0e10cSrcweir 		SfxItemSet aSet = pEditView->GetEmptyItemSet();
1629*cdf0e10cSrcweir 		aSet.Put( SvxFontHeightItem(800, 100, EE_CHAR_FONTHEIGHT) );
1630*cdf0e10cSrcweir 		pEditView->SetAttribs( aSet );
1631*cdf0e10cSrcweir 	}
1632*cdf0e10cSrcweir 	else if ( ( nCode == KEY_P ) && rKEvt.GetKeyCode().IsMod2() )
1633*cdf0e10cSrcweir 	{
1634*cdf0e10cSrcweir //				ESelection aSel = pEditView->GetSelection();
1635*cdf0e10cSrcweir //				for ( ULONG n = aSel.nStartPara; n <= aSel.nEndPara; n++ )
1636*cdf0e10cSrcweir //				{
1637*cdf0e10cSrcweir //					InfoBox( 0, pEditEngine->GetText( n ) ).Execute();
1638*cdf0e10cSrcweir //				}
1639*cdf0e10cSrcweir 		InfoBox( 0, pEditView->GetSelected() ).Execute();
1640*cdf0e10cSrcweir 
1641*cdf0e10cSrcweir 	}
1642*cdf0e10cSrcweir 	else if ( rKEvt.GetKeyCode().IsMod2() &&
1643*cdf0e10cSrcweir 				( nCode >= KEY_1 ) && ( nCode <= KEY_9 ) )
1644*cdf0e10cSrcweir 	{
1645*cdf0e10cSrcweir 		ULONG nEECtrl = pEditEngine->GetControlWord();
1646*cdf0e10cSrcweir 		nEECtrl = nEECtrl | EE_CNTRL_AUTOPAGESIZE;
1647*cdf0e10cSrcweir 		pEditEngine->SetControlWord( nEECtrl );
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir 		ULONG nEVCtrl = pEditView->GetControlWord();
1650*cdf0e10cSrcweir 		nEVCtrl |= EV_CNTRL_AUTOSIZE;
1651*cdf0e10cSrcweir 		pEditView->SetControlWord( nEVCtrl );
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir 		pEditView->SetAnchorMode( (EVAnchorMode)(nCode-KEY_1) );
1654*cdf0e10cSrcweir 		pEditView->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) );
1655*cdf0e10cSrcweir 		pEditEngine->SetMaxAutoPaperSize( GetOutputSize() );
1656*cdf0e10cSrcweir 		pEditEngine->SetPaperSize( Size( 0, 0 ) );
1657*cdf0e10cSrcweir 	}
1658*cdf0e10cSrcweir 	else if ( rKEvt.GetKeyCode().IsMod2() && ( nCode == KEY_0 ) )
1659*cdf0e10cSrcweir 	{
1660*cdf0e10cSrcweir 		ULONG nEVCtrl = pEditView->GetControlWord();
1661*cdf0e10cSrcweir 		nEVCtrl = nEVCtrl | EV_CNTRL_AUTOSIZE;
1662*cdf0e10cSrcweir 		pEditView->SetControlWord( nEVCtrl );
1663*cdf0e10cSrcweir 
1664*cdf0e10cSrcweir 		Size aOutSz( GetOutputSize() );
1665*cdf0e10cSrcweir 		Size aPaperSz( aOutSz.Width() / 2, 0 );
1666*cdf0e10cSrcweir 		pEditView->SetOutputArea( Rectangle( Point(), aPaperSz ) );
1667*cdf0e10cSrcweir 		pEditEngine->SetPaperSize( aPaperSz );
1668*cdf0e10cSrcweir 		// Max-Height wird bei View verwendet,
1669*cdf0e10cSrcweir 		// MinSize/MaxSize nur, wenn AUTOPAGESIZE ( KEY_1 - KEY_9 )
1670*cdf0e10cSrcweir 		pEditEngine->SetMaxAutoPaperSize( Size( aOutSz.Width() / 2, aOutSz.Height() / 2 ) );
1671*cdf0e10cSrcweir 		pEditEngine->SetMinAutoPaperSize( Size( aOutSz.Width() / 8, aOutSz.Height() / 8 ) );
1672*cdf0e10cSrcweir 	}
1673*cdf0e10cSrcweir 	else if ( ( nCode == KEY_J ) && rKEvt.GetKeyCode().IsMod2() )
1674*cdf0e10cSrcweir 	{
1675*cdf0e10cSrcweir 		Size aTextSz( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() );
1676*cdf0e10cSrcweir 		Rectangle aRect( pEditView->GetOutputArea().TopLeft(), aTextSz );
1677*cdf0e10cSrcweir 		Brush aTmpBrush( Color( COL_LIGHTBLUE ), BRUSH_25 );
1678*cdf0e10cSrcweir 		Brush aOldBrush( GetFillInBrush() );
1679*cdf0e10cSrcweir 		SetFillInBrush( aTmpBrush );
1680*cdf0e10cSrcweir 		DrawRect( aRect );
1681*cdf0e10cSrcweir 		SetFillInBrush( aOldBrush );
1682*cdf0e10cSrcweir 		pEditView->Paint( aRect );
1683*cdf0e10cSrcweir 	}
1684*cdf0e10cSrcweir 	else if ( ( nCode == KEY_H ) && rKEvt.GetKeyCode().IsMod2() )
1685*cdf0e10cSrcweir 	{
1686*cdf0e10cSrcweir 		Push();
1687*cdf0e10cSrcweir 		Size aSz( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() );
1688*cdf0e10cSrcweir 		Pen aPen( PEN_SOLID );
1689*cdf0e10cSrcweir 		Brush aBrush( Color( COL_GRAY ), BRUSH_SOLID );
1690*cdf0e10cSrcweir 		aPen.SetColor( Color( COL_BLACK ) );
1691*cdf0e10cSrcweir 		SetPen( aPen );
1692*cdf0e10cSrcweir 		SetFillInBrush( aBrush );
1693*cdf0e10cSrcweir 		Rectangle aR( pEditView->GetOutputArea().TopLeft(), aSz );
1694*cdf0e10cSrcweir 		DrawRect( aR );
1695*cdf0e10cSrcweir 		Pop();
1696*cdf0e10cSrcweir 		pEditEngine->Draw( this, pEditView->GetOutputArea() );
1697*cdf0e10cSrcweir 		pEditView->ShowCursor( TRUE, TRUE );
1698*cdf0e10cSrcweir 	}
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir 	// Eingabe an EditEngine...
1701*cdf0e10cSrcweir 	else
1702*cdf0e10cSrcweir 	{
1703*cdf0e10cSrcweir 		BOOL bDone = pEditView->PostKeyEvent( rKEvt );
1704*cdf0e10cSrcweir 		if ( !bDone )
1705*cdf0e10cSrcweir 			Window::KeyInput( rKEvt );
1706*cdf0e10cSrcweir 	}
1707*cdf0e10cSrcweir 
1708*cdf0e10cSrcweir 	((EditMainWindow*)GetParent())->UpdateToolBox();
1709*cdf0e10cSrcweir }
1710*cdf0e10cSrcweir 
1711*cdf0e10cSrcweir void __EXPORT EditViewWindow::MouseMove( const MouseEvent& rMEvt )
1712*cdf0e10cSrcweir {
1713*cdf0e10cSrcweir 	Point aPos = PixelToLogic( rMEvt.GetPosPixel() );
1714*cdf0e10cSrcweir 	if ( pEditView->GetOutputArea().IsInside( aPos ) )
1715*cdf0e10cSrcweir 	{
1716*cdf0e10cSrcweir 		const SvxFieldItem* pField = pEditView->GetFieldUnderMousePointer();
1717*cdf0e10cSrcweir 		if ( pField )
1718*cdf0e10cSrcweir 			SetPointer( aURLPtr );
1719*cdf0e10cSrcweir 		else
1720*cdf0e10cSrcweir 			SetPointer( pEditView->GetPointer() );
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir //		aPos -= pEditView->GetOutputArea().TopLeft();
1723*cdf0e10cSrcweir //		aPos += pEditView->GetVisArea().TopLeft();
1724*cdf0e10cSrcweir //		if ( pEditView->GetEditEngine()->IsTextPos( aPos, PixelToLogic( Size( 5, 0 ) ).Width() ) )
1725*cdf0e10cSrcweir //			SetPointer( pEditView->GetPointer() );
1726*cdf0e10cSrcweir //		else
1727*cdf0e10cSrcweir //			SetPointer( Pointer( POINTER_REFHAND ) );
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir 	}
1730*cdf0e10cSrcweir 	else
1731*cdf0e10cSrcweir 		SetPointer( aStdPtr );
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir //	static long x = 0;
1734*cdf0e10cSrcweir //	x++;
1735*cdf0e10cSrcweir //	DBG_ASSERT( x < 1000, String( RTL_CONSTASCII_USTRINGPARAM( "?" ) ) );
1736*cdf0e10cSrcweir 	pEditView->MouseMove( rMEvt );
1737*cdf0e10cSrcweir }
1738*cdf0e10cSrcweir 
1739*cdf0e10cSrcweir void __EXPORT EditViewWindow::MouseButtonDown( const MouseEvent& rMEvt )
1740*cdf0e10cSrcweir {
1741*cdf0e10cSrcweir 	GrabFocus();
1742*cdf0e10cSrcweir 	pEditView->MouseButtonDown( rMEvt );
1743*cdf0e10cSrcweir }
1744*cdf0e10cSrcweir 
1745*cdf0e10cSrcweir void __EXPORT EditViewWindow::MouseButtonUp( const MouseEvent& rMEvt )
1746*cdf0e10cSrcweir {
1747*cdf0e10cSrcweir 	pEditView->MouseButtonUp( rMEvt );
1748*cdf0e10cSrcweir 	((EditMainWindow*)GetParent())->UpdateToolBox();
1749*cdf0e10cSrcweir }
1750*cdf0e10cSrcweir 
1751*cdf0e10cSrcweir void __EXPORT EditViewWindow::Command( const CommandEvent& rCEvt )
1752*cdf0e10cSrcweir {
1753*cdf0e10cSrcweir 	if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
1754*cdf0e10cSrcweir 	{
1755*cdf0e10cSrcweir 		if( pEditView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel() ) )
1756*cdf0e10cSrcweir 			pEditView->ExecuteSpellPopup( rCEvt.GetMousePosPixel() );
1757*cdf0e10cSrcweir 	}
1758*cdf0e10cSrcweir 	else
1759*cdf0e10cSrcweir 		pEditView->Command(rCEvt);
1760*cdf0e10cSrcweir 
1761*cdf0e10cSrcweir }
1762*cdf0e10cSrcweir 
1763*cdf0e10cSrcweir BOOL __EXPORT EditViewWindow::Drop( const DropEvent& rEvt )
1764*cdf0e10cSrcweir {
1765*cdf0e10cSrcweir 	return pEditView->Drop( rEvt );
1766*cdf0e10cSrcweir }
1767*cdf0e10cSrcweir 
1768*cdf0e10cSrcweir BOOL __EXPORT EditViewWindow::QueryDrop( DropEvent& rEvt )
1769*cdf0e10cSrcweir {
1770*cdf0e10cSrcweir 	return pEditView->QueryDrop( rEvt );
1771*cdf0e10cSrcweir }
1772*cdf0e10cSrcweir 
1773*cdf0e10cSrcweir // --- aEditApp ------------------------------------------------------
1774*cdf0e10cSrcweir 
1775*cdf0e10cSrcweir void __EXPORT EditApp::Main()
1776*cdf0e10cSrcweir {
1777*cdf0e10cSrcweir #ifdef WNT
1778*cdf0e10cSrcweir 	SvFactory::Init();
1779*cdf0e10cSrcweir #endif
1780*cdf0e10cSrcweir 
1781*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >  xSMgr = createApplicationServiceManager();
1782*cdf0e10cSrcweir 	::comphelper::setProcessServiceFactory( xSMgr );
1783*cdf0e10cSrcweir 
1784*cdf0e10cSrcweir 	EditDLL aEditDll;
1785*cdf0e10cSrcweir 	SvxGlobalItemData aItemData;
1786*cdf0e10cSrcweir 	SvxFieldItem::GetClassManager().SV_CLASS_REGISTER( SvxDateField );
1787*cdf0e10cSrcweir 	SvxFieldItem::GetClassManager().SV_CLASS_REGISTER( SvxURLField );
1788*cdf0e10cSrcweir 
1789*cdf0e10cSrcweir 	Help::EnableQuickHelp();
1790*cdf0e10cSrcweir 
1791*cdf0e10cSrcweir 	EditMainWindow aWindow;
1792*cdf0e10cSrcweir 	Execute();
1793*cdf0e10cSrcweir }
1794*cdf0e10cSrcweir 
1795*cdf0e10cSrcweir EditApp aEditApp;
1796