/*************************************************************************
 *
 *  $RCSfile: wrttxatr.hxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000/09/18 17:14:54 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _WRTTXATR_HXX
#define _WRTTXATR_HXX

#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif

#include "wrt_fn.hxx"

class SwTxtAttr;
class Writer;
class EndPosLst;

/*
 *	Ausgabe der Texte-Attribute:
 * 		Die Text-Attribute sind in einem VarArray nach ihren Start-Positionen
 * 		sortiert. Fuer den RTF-Writer ist aber auch das Ende von Bedeutung.
 *		Darum die Idee, sobald im SwpHints-Array ein Attribut mit der Start-
 *		Position gefunden wurde, in einem Sortierten-Array die Endposition
 * 		zu speichern. Sobald der Writer die Position erreicht hat, wird die
 *		schliessende Klammer ausgegeben und die Position aus dem Sort.Array
 *		geloescht.
 * 	15.3.93: Es reicht leider nicht aus nur Start und End zuspeichern, denn
 * 		im SwpHints Array stehen sie nicht nach Ende sortiert, so dass
 * 		Attribute die falsche schliessende Klammer bekommen. (z.B
 * 		Bold von 0..3, dann folgt Underline von 0..4. Dann bekommt Underline
 * 		die schliessende Klammer von Bold !!)
 *		Also muessen erst alle Attribute einer Position gesammelt, nach
 *		Ende sortiert und dann erst ausgegeben werden.
 */


SV_DECL_PTRARR( _SwpTxtHts, SwTxtAttr*, 1, 1 )

class SttEndPos
{
	friend class EndPosLst;

	xub_StrLen nStart, nEnd;
	USHORT nFontSize;
	// falls mehrere Attribute den gleichen Bereich umspannen, sammeln
	_SwpTxtHts aArr;

public:
	SttEndPos( const SwTxtAttr* pAttr, xub_StrLen nStt, xub_StrLen nEnd,
				USHORT nFontSize = 0 );
	SttEndPos( const SttEndPos & rSEPos );

	int operator==( const SttEndPos & rSEPos ) const
		{ return nStart == rSEPos.nStart && nEnd == rSEPos.nEnd; }

	xub_StrLen  GetStart() const 			{ return nStart; }
	xub_StrLen  GetEnd() const 				{ return nEnd; }
	USHORT GetFontSize() const 			{ return nFontSize; }

	const _SwpTxtHts& GetAttrs() const	{ return aArr; }
};


SV_DECL_PTRARR_DEL( _EndPosLst, SttEndPos*, 5, 5 )

class EndPosLst : private _EndPosLst
{
public:
	EndPosLst();

	// fuege den Pointer ein (wird nicht kopiert, kann aber
	// geloescht werden)
	int Insert( SttEndPos* pNew );

	// loesche von 0 n Elemente
	void Remove( USHORT n = 1 )
		{	_EndPosLst::DeleteAndDestroy( 0, n );	}

	SttEndPos* operator[]( USHORT nPos )
		{ return _EndPosLst::operator[]( nPos ); }

	USHORT Count()
		{ return _EndPosLst::Count(); }

#ifndef WTC
	void OutAttrs( Writer& rWrt, SwAttrFnTab&, xub_StrLen nStrPos );
#else
	void OutAttrs( Writer& rWrt, SwAttrFnTab, xub_StrLen nStrPos );
#endif
};


/*************************************************************************

	  Source Code Control System - Header

	  $Header: /cvs/oo/sw/sw/source/filter/inc/wrttxatr.hxx,v 1.1.1.1 2000/09/18 17:14:54 hr Exp $

	  Source Code Control System - Update

	  $Log: wrttxatr.hxx,v $
	  Revision 1.1.1.1  2000/09/18 17:14:54  hr
	  initial import
	
	  Revision 1.8  2000/09/18 16:04:49  willem.vandorp
	  OpenOffice header added.
	
	  Revision 1.7  2000/09/09 12:53:28  willem.vandorp
	  Header and footer replaced
	
	  Revision 1.6  2000/05/08 16:52:05  jp
	  Changes for Unicode
	
	  Revision 1.5  1997/08/11 12:00:56  OM
	  Headerfile-Umstellung


	  Rev 1.4   11 Aug 1997 14:00:56   OM
   Headerfile-Umstellung

	  Rev 1.3   20 Aug 1996 14:10:32   TRI
   Unter WTC keine Referenz uebergeben

	  Rev 1.2   28 Jun 1996 10:34:26   MA
   includes

	  Rev 1.1   05 May 1995 19:39:54   JP
   OutAttrs erwartet jetzt eine Referenz

	  Rev 1.0   07 Apr 1995 21:04:12   JP
   Initial revision.

*************************************************************************/
	// #ifndef _...
#endif
