/*************************************************************************
 *
 *  $RCSfile: editview.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: mt $ $Date: 2002/07/05 10:08:28 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

// MyEDITVIEW, wegen exportiertem EditView
#ifndef _MyEDITVIEW_HXX
#define _MyEDITVIEW_HXX

#ifndef _RSCSFX_HXX //autogen
#include <rsc/rscsfx.hxx>
#endif
#ifndef _LANG_HXX //autogen
#include <tools/lang.hxx>
#endif

#ifndef _TOOLS_COLOR_HXX
#include <tools/color.hxx>
#endif

class EditEngine;
class ImpEditEngine;
class ImpEditView;
class SvxSearchItem;
class SvxFieldItem;
class Window;
class Pointer;
class Cursor;
class KeyEvent;
class MouseEvent;
class DropEvent;
class CommandEvent;
class Rectangle;
class Link;
class Pair;
class Point;
class Range;
class SvStream;
class SvKeyValueIterator;
class SfxStyleSheet; 

#ifndef _EDITDATA_HXX
#include <svx/editdata.hxx>
#endif

#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include <com/sun/star/uno/Reference.h>
#endif

namespace com {
namespace sun {
namespace star {
namespace datatransfer {
	class XTransferable;
}}}}

class EditView
{
	friend class EditEngine;
	friend class ImpEditEngine;
	friend class EditSelFunctionSet;

public:	// brauche ich fuer Undo
	ImpEditView*	GetImpEditView() const 		{ return pImpEditView; }
	ImpEditEngine*	GetImpEditEngine() const;

private:
	ImpEditView*	pImpEditView;

					EditView( const EditView& );
	EditView&		operator=( const EditView& );

public:
					EditView( EditEngine* pEng, Window* pWindow );
	virtual			~EditView();

	void			SetEditEngine( EditEngine* pEditEngine );
	EditEngine*		GetEditEngine() const;

	void			SetWindow( Window* pWin );
	Window*			GetWindow() const;

	void			Paint( const Rectangle& rRect );
	void			Invalidate();
	Pair			Scroll( long nHorzScroll, long nVertScroll, BYTE nRangeCheck = RGCHK_NEG );

	void			ShowCursor( BOOL bGotoCursor = TRUE, BOOL bForceVisCursor = TRUE );
	void			HideCursor();

	EESelectionMode	GetSelectionMode() const;
	void			SetSelectionMode( EESelectionMode eMode );

	void			SetReadOnly( BOOL bReadOnly );
	BOOL			IsReadOnly() const;

	BOOL			HasSelection() const;
	ESelection		GetSelection() const;
	void			SetSelection( const ESelection& rNewSel );
	BOOL			SelectCurrentWord();

	void			IndentBlock();
	void			UnindentBlock();

	BOOL			IsInsertMode() const;
	void			SetInsertMode( BOOL bInsert );

	void			ReplaceSelected( const String& rStr );
	String			GetSelected();
	void			DeleteSelected();

	USHORT			GetSelectedScriptType() const;

						// Position der VisArea im Ausgabefenster.
						// Eine Groessenaenderung betrifft auch die VisArea
	void				SetOutputArea( const Rectangle& rRec );
	const Rectangle&	GetOutputArea() const;

						// Dokumentposition.
						// Eine Groessenaenderung betrifft auch die VisArea
	void				SetVisArea( const Rectangle& rRec );
	const Rectangle&	GetVisArea() const;

	void			SetPointer( const Pointer& rPointer );
	const Pointer&	GetPointer() const;

	void			SetCursor( const Cursor& rCursor );
	Cursor*			GetCursor() const;

	void			InsertText( const String& rNew, BOOL bSelect = FALSE );

	BOOL			PostKeyEvent( const KeyEvent& rKeyEvent );

	BOOL			MouseButtonUp( const MouseEvent& rMouseEvent );
	BOOL			MouseButtonDown( const MouseEvent& rMouseEvent );
	BOOL			MouseMove( const MouseEvent& rMouseEvent );
	void			Command( const CommandEvent& rCEvt );

	BOOL    		Drop( const DropEvent& rEvt );
	BOOL    		QueryDrop( DropEvent& rEvt );
	ESelection		GetDropPos();

	void			Cut();
	void			Copy();
	void			Paste();
	void			PasteSpecial();

	void			EnablePaste( BOOL bEnable );
	BOOL			IsPasteEnabled() const;

	void			Undo();
	void			Redo();

	// speziell fuer Olli
	USHORT			GetParagraph( const Point& rMousePosPixel );
	Point			GetWindowPosTopLeft( USHORT nParagraph );
	void			MoveParagraphs( Range aParagraphs, USHORT nNewPos );
    void            MoveParagraphs( long nDiff );

	const SfxItemSet& 	GetEmptyItemSet();
	SfxItemSet			GetAttribs();
	void				SetAttribs( const SfxItemSet& rSet );
	void				SetParaAttribs( const SfxItemSet& rSet, USHORT nPara );
	void				RemoveAttribs( BOOL bRemoveParaAttribs = FALSE, USHORT nWhich = 0 );
	void 				RemoveCharAttribs( USHORT nPara, USHORT nWhich = 0 );

	ULONG			Read( SvStream& rInput, EETextFormat eFormat, BOOL bSelect = FALSE, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
	ULONG			Write( SvStream& rOutput, EETextFormat eFormat );

	void 			SetBackgroundColor( const Color& rColor );
	Color			GetBackgroundColor() const;

	void			SetControlWord( ULONG nWord );
	ULONG			GetControlWord() const;

	EditTextObject*	CreateTextObject();
	void			InsertText( const EditTextObject& rTextObject );
	void			InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj, BOOL bUseSpecial );

	// An EditView, damit bei TRUE flackerfreies Update:
	void			SetEditEngineUpdateMode( BOOL bUpdate );
	void			ForceUpdate();

	SfxStyleSheet*	GetStyleSheet() const;
	void			SetStyleSheet( SfxStyleSheet* pStyle );

	void			SetAnchorMode( EVAnchorMode eMode );
	EVAnchorMode	GetAnchorMode() const;

	BOOL			MatchGroup();

	void			CompleteAutoCorrect();

	EESpellState	StartSpeller( BOOL bMultipleDoc = FALSE );
	EESpellState	StartSpeller( LanguageType eLang, BOOL bMultipleDoc = FALSE );
	EESpellState	StartThesaurus();
	EESpellState	StartThesaurus( LanguageType eLang );
	USHORT			StartSearchAndReplace( const SvxSearchItem& rSearchItem );

	void			TransliterateText( sal_Int32 nTransliterationMode );

	BOOL			IsCursorAtWrongSpelledWord( BOOL bMarkIfWrong = FALSE );
	BOOL			IsWrongSpelledWordAtPos( const Point& rPosPixel, BOOL bMarkIfWrong = FALSE );
	void			SpellIgnoreWord();
	void			ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack = 0 );

	void 				InsertField( const SvxFieldItem& rFld );
	const SvxFieldItem*	GetFieldUnderMousePointer() const;
	const SvxFieldItem*	GetFieldUnderMousePointer( USHORT& nPara, xub_StrLen& nPos ) const;
	const SvxFieldItem*	GetField( const Point& rPos, USHORT* pnPara = NULL, xub_StrLen* pnPos = NULL ) const;

	const SvxFieldItem*	GetFieldAtSelection() const;

	String			GetWordUnderMousePointer() const;
	String			GetWordUnderMousePointer( Rectangle& rWordRect ) const;

	void			SetInvalidateMore( USHORT nPixel );
	USHORT			GetInvalidateMore() const;
};

#endif // _MyEDITVIEW_HXX
