/*************************************************************************
 *
 *  $RCSfile: wrttxatr.cxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000/09/18 17:14:57 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#ifdef PRECOMPILED
#include "filt_pch.hxx"
#endif

#pragma hdrstop

#ifndef _REF_HXX
#include <tools/ref.hxx>
#endif

#ifndef _SHELLIO_HXX
#include <shellio.hxx>
#endif
#ifndef _WRT_FN_HXX
#include <wrt_fn.hxx>
#endif
#ifndef _WRTTXATR_HXX
#include <wrttxatr.hxx>
#endif
#ifndef _TXATBASE_HXX
#include <txatbase.hxx>
#endif



// SV_IMPL_PTRARR( _SwpTxtHts, SwTxtAttr* )
SV_IMPL_PTRARR( _EndPosLst, SttEndPos* )


SttEndPos::SttEndPos( const SwTxtAttr* pAttr, xub_StrLen nStt,
					xub_StrLen nEd, USHORT nFSize )
	: nStart( nStt ), nEnd( nEd ), nFontSize( nFSize )
{
	aArr.Insert( pAttr, 0 );
}

SttEndPos::SttEndPos( const SttEndPos & rSEPos )
	: nStart( rSEPos.nStart ), nEnd( rSEPos.nEnd ),
	nFontSize( rSEPos.nFontSize )
{
	aArr.Insert( &rSEPos.aArr, 0 );
}


EndPosLst::EndPosLst()
	: _EndPosLst( 5 )
{
}

int EndPosLst::Insert( SttEndPos* pNew )
{
	// kein Bereich ?? dann nicht aufnehmen, wird nie wirksam !!
	if( pNew->nStart == pNew->nEnd )
	{
		delete pNew;
		return FALSE;
	}

	for( USHORT nPos = 0; nPos < Count(); nPos++ )
	{
		SttEndPos* pTmp = _EndPosLst::operator[]( nPos );
		if( *pNew == *pTmp )
		{
			pTmp->aArr.Insert( &pNew->aArr, pTmp->aArr.Count() );
			delete pNew;		// Pointer noch loeschen
			return FALSE;		// schon vorhanden
		}
		if( pNew->nEnd < pTmp->nEnd )
		{
			_EndPosLst::C40_INSERT( SttEndPos, pNew, nPos );
			return TRUE;
		}
	}
	_EndPosLst::C40_INSERT( SttEndPos, pNew, nPos );
	return TRUE;
}

#ifndef WTC
void EndPosLst::OutAttrs( Writer& rWrt, SwAttrFnTab& aAttrFnTab,
							xub_StrLen  nStrPos )
#else
void EndPosLst::OutAttrs( Writer& rWrt, SwAttrFnTab aAttrFnTab,
							xub_StrLen  nStrPos )
#endif
{
	SttEndPos* pStt;
//	SwAttrFnTab* pW95 =  (SwAttrFnTab*)&aAttrFnTab;
	for( USHORT n = Count(); n ;  )
		if( nStrPos == (pStt = (*this)[ --n ])->nStart )
		{
			for( USHORT i = 0; i < pStt->aArr.Count(); ++i )
//				Out( *pW95, pStt->aArr[i]->GetAttr(), rWrt );
				Out( aAttrFnTab, pStt->aArr[i]->GetAttr(), rWrt );
		}
}

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

	  Source Code Control System - Header

	  $Header: /cvs/oo/sw/sw/source/filter/writer/wrttxatr.cxx,v 1.1.1.1 2000/09/18 17:14:57 hr Exp $

	  Source Code Control System - Update

	  $Log: wrttxatr.cxx,v $
	  Revision 1.1.1.1  2000/09/18 17:14:57  hr
	  initial import
	
	  Revision 1.14  2000/09/18 16:04:55  willem.vandorp
	  OpenOffice header added.
	
	  Revision 1.13  2000/05/08 16:51:57  jp
	  Changes for Unicode
	
	  Revision 1.12  1999/06/29 10:30:56  KZ
	  ins. #include <tools/ref.hxx>


	  Rev 1.11   29 Jun 1999 12:30:56   KZ
   ins. #include <tools/ref.hxx>

	  Rev 1.10   26 Nov 1997 14:29:14   MA
   headerfiles

	  Rev 1.9   03 Nov 1997 14:12:48   MA
   precomp entfernt

	  Rev 1.8   20 Aug 1996 15:10:06   TRI
   OutAttrs unter WTC bekommt keine Referenz als 2 Parameter

	  Rev 1.7   01 Jul 1996 16:03:14   MA
   includes

	  Rev 1.6   30 Apr 1996 16:39:26   TRI
   WTC Anpassung

	  Rev 1.5   24 Nov 1995 17:24:42   OM
   PCH->PRECOMPILED

	  Rev 1.4   17 Nov 1995 11:14:38   MA
   Segmentierung

	  Rev 1.3   27 Jul 1995 09:46:34   mk
   an SCC4.0.1a angepasst (MDA)

	  Rev 1.2   05 May 1995 19:40:02   JP
   OutAttrs erwartet jetzt eine Referenz

	  Rev 1.1   27 Apr 1995 17:01:04   ER
   win95 Extrawurst

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

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


