summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ascii/ascatr.cxx486
-rw-r--r--sw/source/filter/ascii/makefile.mk94
-rw-r--r--sw/source/filter/ascii/parasc.cxx1180
-rw-r--r--sw/source/filter/ascii/wrtasc.cxx293
-rw-r--r--sw/source/filter/ascii/wrtasc.hxx90
-rw-r--r--sw/source/filter/html/css1atr.cxx3536
-rw-r--r--sw/source/filter/html/css1kywd.cxx400
-rw-r--r--sw/source/filter/html/css1kywd.hxx320
-rw-r--r--sw/source/filter/html/htmlatr.cxx3165
-rw-r--r--sw/source/filter/html/htmlbas.cxx689
-rw-r--r--sw/source/filter/html/htmlcss1.cxx2596
-rw-r--r--sw/source/filter/html/htmlctxt.cxx934
-rw-r--r--sw/source/filter/html/htmldraw.cxx1070
-rw-r--r--sw/source/filter/html/htmlfld.cxx787
-rw-r--r--sw/source/filter/html/htmlfld.hxx166
-rw-r--r--sw/source/filter/html/htmlfldw.cxx667
-rw-r--r--sw/source/filter/html/htmlfly.cxx2008
-rw-r--r--sw/source/filter/html/htmlfly.hxx175
-rw-r--r--sw/source/filter/html/htmlflyt.cxx673
-rw-r--r--sw/source/filter/html/htmlform.cxx3209
-rw-r--r--sw/source/filter/html/htmlform.hxx86
-rw-r--r--sw/source/filter/html/htmlforw.cxx1635
-rw-r--r--sw/source/filter/html/htmlftn.cxx689
-rw-r--r--sw/source/filter/html/htmlgrin.cxx1656
-rw-r--r--sw/source/filter/html/htmlnum.cxx997
-rw-r--r--sw/source/filter/html/htmlnum.hxx189
-rw-r--r--sw/source/filter/html/htmlplug.cxx1360
-rw-r--r--sw/source/filter/html/htmlsect.cxx1063
-rw-r--r--sw/source/filter/html/htmltab.cxx6187
-rw-r--r--sw/source/filter/html/htmltabw.cxx1571
-rw-r--r--sw/source/filter/html/htmlvsh.hxx91
-rw-r--r--sw/source/filter/html/makefile.mk138
-rw-r--r--sw/source/filter/html/parcss1.cxx1598
-rw-r--r--sw/source/filter/html/parcss1.hxx342
-rw-r--r--sw/source/filter/html/svxcss1.cxx3378
-rw-r--r--sw/source/filter/html/svxcss1.hxx462
-rw-r--r--sw/source/filter/html/swcss1.hxx257
-rw-r--r--sw/source/filter/html/swhtml.cxx5646
-rw-r--r--sw/source/filter/html/swhtml.hxx1068
-rw-r--r--sw/source/filter/html/wrthtml.cxx1477
-rw-r--r--sw/source/filter/html/wrthtml.hxx614
-rw-r--r--sw/source/filter/inc/fltbase.hxx166
-rw-r--r--sw/source/filter/inc/fltglbls.hxx218
-rw-r--r--sw/source/filter/inc/fltini.hxx219
-rw-r--r--sw/source/filter/inc/fltshell.hxx675
-rw-r--r--sw/source/filter/inc/makefile.mk61
-rw-r--r--sw/source/filter/inc/rtf.hxx168
-rw-r--r--sw/source/filter/inc/wrt_fn.hxx103
-rw-r--r--sw/source/filter/inc/wrtswtbl.hxx375
-rw-r--r--sw/source/filter/makefile.mk244
-rw-r--r--sw/source/filter/rtf/makefile.mk106
-rw-r--r--sw/source/filter/rtf/rtfatr.cxx3068
-rw-r--r--sw/source/filter/rtf/rtffld.cxx960
-rw-r--r--sw/source/filter/rtf/rtffly.cxx1745
-rw-r--r--sw/source/filter/rtf/rtfnum.cxx1468
-rw-r--r--sw/source/filter/rtf/rtftbl.cxx978
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx3818
-rw-r--r--sw/source/filter/rtf/swparrtf.hxx437
-rw-r--r--sw/source/filter/rtf/wrtrtf.cxx1593
-rw-r--r--sw/source/filter/rtf/wrtrtf.hxx244
-rw-r--r--sw/source/filter/writer/makefile.mk94
-rw-r--r--sw/source/filter/writer/writer.cxx780
-rw-r--r--sw/source/filter/writer/wrt_fn.cxx230
-rw-r--r--sw/source/filter/writer/wrtswtbl.cxx959
-rw-r--r--sw/source/filter/ww1/fltshell.cxx2357
-rw-r--r--sw/source/filter/ww1/makefile.mk136
-rw-r--r--sw/source/filter/ww1/w1class.cxx1580
-rw-r--r--sw/source/filter/ww1/w1class.hxx1753
-rw-r--r--sw/source/filter/ww1/w1filter.cxx2433
-rw-r--r--sw/source/filter/ww1/w1par.cxx255
-rw-r--r--sw/source/filter/ww1/w1par.hxx81
-rw-r--r--sw/source/filter/ww1/w1sprm.cxx960
-rw-r--r--sw/source/filter/ww1/w1struct.hxx965
-rw-r--r--sw/source/filter/ww8/dump/dump8.cxx259
-rw-r--r--sw/source/filter/ww8/dump/dump8a.cxx3127
-rw-r--r--sw/source/filter/ww8/dump/makefile.mk179
-rw-r--r--sw/source/filter/ww8/dump/msvbasic.cxx598
-rw-r--r--sw/source/filter/ww8/dump/msvbasic.hxx140
-rw-r--r--sw/source/filter/ww8/dump/ww8darr.cxx615
-rw-r--r--sw/source/filter/ww8/dump/ww8darr.hxx77
-rw-r--r--sw/source/filter/ww8/dump/ww8dout.cxx499
-rw-r--r--sw/source/filter/ww8/dump/ww8dout.hxx120
-rw-r--r--sw/source/filter/ww8/dump/ww8scan.cxx6049
-rw-r--r--sw/source/filter/ww8/dump/ww8scan.hxx1498
-rw-r--r--sw/source/filter/ww8/dump/ww8struc.hxx851
-rw-r--r--sw/source/filter/ww8/makefile.mk134
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx1706
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx2002
-rw-r--r--sw/source/filter/ww8/wrtw8num.cxx627
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx1942
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx2226
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx815
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx697
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx3489
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx426
-rw-r--r--sw/source/filter/ww8/ww8glsy.hxx134
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx3174
-rw-r--r--sw/source/filter/ww8/ww8graf.hxx194
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx1363
-rw-r--r--sw/source/filter/ww8/ww8par.cxx2996
-rw-r--r--sw/source/filter/ww8/ww8par.hxx1287
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx3084
-rw-r--r--sw/source/filter/ww8/ww8par2.hxx371
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx2191
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx777
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx3270
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx4883
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx6326
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx1729
-rw-r--r--sw/source/filter/ww8/ww8struc.hxx930
-rw-r--r--sw/source/filter/xml/makefile.mk144
-rw-r--r--sw/source/filter/xml/swxml.cxx314
-rw-r--r--sw/source/filter/xml/wrtxml.cxx238
-rw-r--r--sw/source/filter/xml/wrtxml.hxx89
-rw-r--r--sw/source/filter/xml/xmlbrsh.cxx318
-rw-r--r--sw/source/filter/xml/xmlbrshe.hxx122
-rw-r--r--sw/source/filter/xml/xmlbrshi.hxx113
-rw-r--r--sw/source/filter/xml/xmlexp.cxx550
-rw-r--r--sw/source/filter/xml/xmlexp.hxx254
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx1814
-rw-r--r--sw/source/filter/xml/xmlfmte.cxx1144
-rw-r--r--sw/source/filter/xml/xmlimp.cxx570
-rw-r--r--sw/source/filter/xml/xmlimp.hxx283
-rw-r--r--sw/source/filter/xml/xmliteme.cxx490
-rw-r--r--sw/source/filter/xml/xmlitemi.cxx638
-rw-r--r--sw/source/filter/xml/xmlitemm.cxx548
-rw-r--r--sw/source/filter/xml/xmlmeta.cxx227
-rw-r--r--sw/source/filter/xml/xmltble.cxx1085
-rw-r--r--sw/source/filter/xml/xmltbli.cxx2229
-rw-r--r--sw/source/filter/xml/xmltbli.hxx211
-rw-r--r--sw/source/filter/xml/xmltext.cxx1647
-rw-r--r--sw/source/filter/xml/xmltexte.hxx100
-rw-r--r--sw/source/filter/xml/xmltexti.hxx125
133 files changed, 156309 insertions, 0 deletions
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
new file mode 100644
index 000000000000..bdb0a7398675
--- /dev/null
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -0,0 +1,486 @@
+/*************************************************************************
+ *
+ * $RCSfile: ascatr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_USHORTS
+#include <svtools/svstdarr.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _WRTASC_HXX
+#include <wrtasc.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _FCHRFMT_HXX
+#include <fchrfmt.hxx>
+#endif
+#ifndef _TXTFLD_HXX
+#include <txtfld.hxx>
+#endif
+#ifndef _TXTATR_HXX
+#include <txtatr.hxx>
+#endif
+#ifndef _FMTFTN_HXX
+#include <fmtftn.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _FMTFLD_HXX
+#include <fmtfld.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx>
+#endif
+#ifndef _FTNINFO_HXX //autogen
+#include <ftninfo.hxx>
+#endif
+
+/*
+ * Dieses File enthaelt alle Ausgabe-Funktionen des ASCII-Writers;
+ * fuer alle Nodes, Attribute, Formate und Chars.
+ */
+
+void lcl_WriteString( SvStream& rOut, const String& rStr,
+ rtl_TextEncoding eSrcSet, rtl_TextEncoding eDest );
+
+class SwASC_AttrIter
+{
+ SvPtrarr aTxtAtrArr;
+ SvUShorts aChrSetArr;
+ SwASCWriter& rWrt;
+ const SwTxtNode& rNd;
+ xub_StrLen nAktSwPos;
+ rtl_TextEncoding eNdChrSet;
+
+ xub_StrLen SearchNext( xub_StrLen nStartPos );
+ BOOL SetCharSet( const SwTxtAttr& rTxtAttr, BOOL bStart );
+
+public:
+ SwASC_AttrIter( SwASCWriter& rWrt, const SwTxtNode& rNd, xub_StrLen nStt );
+
+ void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); }
+
+ xub_StrLen WhereNext() const { return nAktSwPos; }
+ rtl_TextEncoding GetNextCharSet() const;
+ rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; }
+
+ BOOL OutAttr( xub_StrLen nSwPos, rtl_TextEncoding eChrSet );
+};
+
+
+SwASC_AttrIter::SwASC_AttrIter( SwASCWriter& rWr, const SwTxtNode& rTxtNd,
+ xub_StrLen nStt )
+ : rWrt( rWr ), rNd( rTxtNd ), nAktSwPos( 0 ),
+ aTxtAtrArr( 0, 4 ), aChrSetArr( 0, 4 )
+{
+ // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen
+ // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben
+ // werden.
+ eNdChrSet = ((SvxFontItem&)rNd.SwCntntNode::GetAttr(
+ RES_CHRATR_FONT )).GetCharSet();
+ nAktSwPos = SearchNext( nStt + 1 );
+}
+
+rtl_TextEncoding SwASC_AttrIter::GetNextCharSet() const
+{
+ if( aChrSetArr.Count() )
+ return (rtl_TextEncoding )aChrSetArr[ aChrSetArr.Count() - 1 ];
+ return eNdChrSet;
+}
+
+xub_StrLen SwASC_AttrIter::SearchNext( xub_StrLen nStartPos )
+{
+ register xub_StrLen nMinPos = STRING_MAXLEN;
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ register USHORT i;
+ register xub_StrLen nPos;
+ const xub_StrLen * pPos;
+
+// kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs
+// nach der Anfangsposition geordnet sind. Dann muessten
+// allerdings noch 2 Indices gemerkt werden
+ for( i = 0; i < pTxtAttrs->Count(); i++ )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen
+ pPos = pHt->GetEnd();
+
+ if( nPos >= nStartPos && nPos <= nMinPos &&
+ ( !pPos || SetCharSet( *pHt, TRUE ) ) )
+ nMinPos = nPos;
+
+ if( pPos ? ( (nPos = *pPos) >= nStartPos && nPos <= nMinPos &&
+ SetCharSet( *pHt, FALSE ) )
+ : (( ++nPos ) >= nStartPos && nPos < nMinPos) )
+ nMinPos = nPos;
+ }
+ }
+ return nMinPos;
+}
+
+BOOL SwASC_AttrIter::SetCharSet( const SwTxtAttr& rAttr, BOOL bStart )
+{
+ void* p = 0;
+ rtl_TextEncoding eChrSet;
+ const SfxPoolItem& rItem = rAttr.GetAttr();
+ switch( rItem.Which() )
+ {
+ case RES_CHRATR_FONT:
+ p = (void*)&rAttr;
+ eChrSet = ((SvxFontItem&)rItem).GetCharSet();
+ break;
+
+ case RES_TXTATR_CHARFMT:
+ {
+ const SfxPoolItem* pItem;
+ if( ((SwFmtCharFmt&)rItem).GetCharFmt() && SFX_ITEM_SET ==
+ ((SwFmtCharFmt&)rItem).GetCharFmt()->GetItemState(
+ RES_CHRATR_FONT, TRUE, &pItem ))
+ {
+ eChrSet = ((SvxFontItem*)pItem)->GetCharSet();
+ p = (void*)&rAttr;
+ }
+ }
+ break;
+ }
+
+ if( p )
+ {
+ USHORT nPos;
+ if( bStart )
+ {
+ nPos = aChrSetArr.Count();
+ aChrSetArr.Insert( eChrSet, nPos );
+ aTxtAtrArr.Insert( p, nPos );
+ }
+ else if( USHRT_MAX != ( nPos = aTxtAtrArr.GetPos( p )) )
+ {
+ aTxtAtrArr.Remove( nPos );
+ aChrSetArr.Remove( nPos );
+ }
+ }
+ return 0 != p;
+}
+
+BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos, rtl_TextEncoding eChrSet )
+{
+ BOOL bRet = FALSE;
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ register USHORT i;
+ for( i = 0; i < pTxtAttrs->Count(); i++ )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ const xub_StrLen * pEnd = pHt->GetEnd();
+ if( !pEnd && nSwPos == *pHt->GetStart() )
+ {
+ bRet = TRUE;
+ String sOut;
+ switch( pHt->Which() )
+ {
+ case RES_TXTATR_FIELD:
+ sOut = ((SwTxtFld*)pHt)->GetFld().GetFld()->Expand();
+ break;
+
+ case RES_TXTATR_HARDBLANK:
+ sOut = ((SwTxtHardBlank*)pHt)->GetChar();
+ break;
+
+ case RES_TXTATR_FTN:
+ {
+ const SwFmtFtn& rFtn = pHt->GetFtn();
+ if( rFtn.GetNumStr().Len() )
+ sOut = rFtn.GetNumStr();
+ else if( rFtn.IsEndNote() )
+ sOut = rWrt.pDoc->GetEndNoteInfo().aFmt.
+ GetNumStr( rFtn.GetNumber() );
+ else
+ sOut = rWrt.pDoc->GetFtnInfo().aFmt.
+ GetNumStr( rFtn.GetNumber() );
+ }
+ break;
+ }
+ if( sOut.Len() )
+ ::lcl_WriteString( rWrt.Strm(), sOut, eChrSet,
+ rWrt.GetAsciiOptions().GetCharSet() );
+ }
+ else if( nSwPos < *pHt->GetStart() )
+ break;
+ }
+ }
+ return bRet;
+}
+
+
+//------------------------
+/* Ausgabe der Nodes */
+//------------------------
+
+static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
+{
+ const SwTxtNode& rNd = (SwTxtNode&)rNode;
+
+ xub_StrLen nStrPos = rWrt.pCurPam->GetPoint()->nContent.GetIndex();
+ xub_StrLen nNodeEnde = rNd.Len(), nEnde = nNodeEnde;
+ BOOL bLastNd = rWrt.pCurPam->GetPoint()->nNode == rWrt.pCurPam->GetMark()->nNode;
+ if( bLastNd )
+ nEnde = rWrt.pCurPam->GetMark()->nContent.GetIndex();
+
+ SwASC_AttrIter aAttrIter( (SwASCWriter&)rWrt, rNd, nStrPos );
+ rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
+ rtl_TextEncoding eSet = rWrt.GetAsciiOptions().GetCharSet();
+
+ if( !nStrPos )
+ ::lcl_WriteString( rWrt.Strm(), rNd.GetNumString(), eChrSet, eSet );
+
+ String aStr( rNd.GetTxt() );
+ if( rWrt.bASCII_ParaAsBlanc )
+ aStr.SearchAndReplaceAll( 0x0A, ' ' );
+
+ do {
+ xub_StrLen nNextAttr = aAttrIter.WhereNext();
+ rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
+
+ if( nNextAttr > nEnde )
+ nNextAttr = nEnde;
+
+ if( !aAttrIter.OutAttr( nStrPos, eChrSet ))
+ ::lcl_WriteString( rWrt.Strm(),
+ aStr.Copy( nStrPos, nNextAttr - nStrPos ),
+ eChrSet, eSet );
+ nStrPos = nNextAttr;
+ eChrSet = eNextChrSet;
+ aAttrIter.NextPos();
+ } while( nStrPos < nEnde );
+
+ if( !bLastNd ||
+ ( !rWrt.bWriteClipboardDoc && !rWrt.bASCII_NoLastLineEnd )
+ && !nStrPos && nEnde == nNodeEnde )
+ ::lcl_WriteString( rWrt.Strm(), ((SwASCWriter&)rWrt).GetLineEnd(),
+ RTL_TEXTENCODING_MS_1252, eSet );
+
+ return rWrt;
+}
+
+void lcl_WriteString( SvStream& rStream, const String& rStr,
+ rtl_TextEncoding eSrcSet, rtl_TextEncoding eDestSet )
+{
+ if( rStr.Len() )
+ {
+ if( RTL_TEXTENCODING_UCS2 == eDestSet )
+ rStream.Write( rStr.GetBuffer(), rStr.Len() * sizeof( sal_Unicode ));
+ else if( RTL_TEXTENCODING_UCS4 == eDestSet )
+ {
+ // ????
+ }
+ else
+ {
+ ByteString sOut( rStr, eDestSet );
+ rStream << sOut.GetBuffer();
+ }
+ }
+}
+
+/*
+ * lege hier jetzt die Tabellen fuer die ASCII-Funktions-Pointer auf
+ * die Ausgabe-Funktionen an.
+ * Es sind lokale Strukturen, die nur innerhalb der ASCII-DLL
+ * bekannt sein muessen.
+ */
+
+SwNodeFnTab aASCNodeFnTab = {
+/* RES_TXTNODE */ OutASC_SwTxtNode,
+/* RES_GRFNODE */ 0,
+/* RES_OLENODE */ 0
+};
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ascii/ascatr.cxx,v 1.1.1.1 2000-09-18 17:14:53 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.59 2000/09/18 16:04:38 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.58 2000/05/08 17:36:58 jp
+ Changes for Unicode
+
+ Revision 1.57 2000/02/11 14:36:19 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.56 1999/11/01 17:49:58 jp
+ own convert from char to UNICODE char
+
+ Revision 1.55 1999/11/01 11:11:14 jp
+ call string-convert with the CharSet of the font
+
+ Revision 1.54 1999/08/26 18:34:10 JP
+ load and save Text with more options (charset/language/lineend/font)
+
+
+ Rev 1.53 26 Aug 1999 20:34:10 JP
+ load and save Text with more options (charset/language/lineend/font)
+
+ Rev 1.52 27 Jun 1998 16:01:50 JP
+ Writer mit neuen Flags; fuer den ASCII-Writer, etwas aufgeraeumt
+
+ Rev 1.51 27 Jan 1998 19:37:12 HR
+ Ueberfluessige Klammern weg, HPUX mag sie nicht
+
+ Rev 1.50 25 Nov 1997 18:55:18 MA
+ includes
+
+ Rev 1.49 03 Nov 1997 14:03:46 MA
+ precomp entfernt
+
+ Rev 1.48 10 Oct 1997 12:19:46 JP
+ beim Clipboard das letzte CR/LF nicht schreiben
+
+ Rev 1.47 14 Jan 1997 08:43:32 MA
+ includes
+
+ Rev 1.46 23 Oct 1996 19:49:00 JP
+ String Umstellung: [] -> GetChar()
+
+ Rev 1.45 28 Jun 1996 13:59:08 MA
+ includes
+
+ Rev 1.44 03 Apr 1996 12:32:26 JP
+ OutSwTxtNode: nur im letzten Node entscheiden, ob CRLF geschrieben wird
+
+ Rev 1.43 26 Mar 1996 15:24:08 JP
+ Bugfix: unbeannte Zeichen richtig schreiben
+
+ Rev 1.42 13 Feb 1996 19:41:30 JP
+ Bug #25428#: LineEnd von SV holen und entsp. auswerten
+
+ Rev 1.41 31 Jan 1996 14:27:36 mk
+ SINIX
+
+ Rev 1.40 24 Nov 1995 17:24:46 OM
+ PCH->PRECOMPILED
+
+ Rev 1.39 30 Oct 1995 13:03:38 MA
+ chg: ConvertUnknown direkt eingebaut.
+
+ Rev 1.38 02 Oct 1995 13:10:48 JP
+ Umstellung auf schreiben verschiedener CodeSets
+
+ Rev 1.37 25 Oct 1994 15:10:22 MA
+ PreHdr.
+
+ Rev 1.36 21 Jul 1994 09:29:52 JP
+ OutASC_SwTxtNode: fuer den ZeilenUmbruch im Translate die Laenge vom Node
+ benutzen und nicht die vom String. Stehen Felder/Nummern/usw. im String
+ kann es nie passen!
+
+ Rev 1.35 04 Mar 1994 10:58:28 JP
+ Translate: auf const char* casten.
+
+ Rev 1.34 25 Feb 1994 12:54:46 JP
+ schreibe mit expandierten Feldern und Numerierung
+
+ Rev 1.33 15 Feb 1994 08:24:10 MI
+ Filter ab jetzt handsegmentiert
+
+ Rev 1.32 28 Jan 1994 11:28:36 MI
+ TCOV() entfernt, SW_... nach SEG_... umbenannt
+
+ Rev 1.31 13 Jan 1994 08:28:28 MI
+ Segmentierung per #define ermoeglicht
+
+ Rev 1.30 12 Jan 1994 11:22:46 MI
+ Segmentierungs-Probleme
+
+*************************************************************************/
diff --git a/sw/source/filter/ascii/makefile.mk b/sw/source/filter/ascii/makefile.mk
new file mode 100644
index 000000000000..eb6f9e64164d
--- /dev/null
+++ b/sw/source/filter/ascii/makefile.mk
@@ -0,0 +1,94 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=ascii
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ ascatr.cxx \
+ parasc.cxx \
+ wrtasc.cxx
+
+
+
+SLOFILES = \
+ $(SLO)$/ascatr.obj \
+ $(SLO)$/parasc.obj \
+ $(SLO)$/wrtasc.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
new file mode 100644
index 000000000000..b26616ec668b
--- /dev/null
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -0,0 +1,1180 @@
+/*************************************************************************
+ *
+ * $RCSfile: parasc.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SFX_PRINTER_HXX
+#include <sfx2/printer.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen wg. SvxFontItem
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX //autogen wg. SvxLanguageItem
+#include <svx/langitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+
+#define ASC_BUFFLEN 4096
+
+
+#ifdef ASYNCHRON
+
+class _SvLockBytes
+{
+ AutoTimer aTimer;
+ SvStream& rIn;
+
+ ULONG nDataRead;
+ Link aCallDataRead;
+
+ DECL_STATIC_LINK( _SvLockBytes, DataRead, Timer* );
+
+public:
+ _SvLockBytes( SvStream& rInput, const Link& rCallBack );
+ ~_SvLockBytes();
+
+ ErrCode ReadAt( ULONG nPos, void* pArr, ULONG nCount, ULONG* pReadCnt );
+
+ SvStream& GetStream() const { return rIn; }
+};
+
+
+// client vom Standard SwPageDesc. Wird dieser geloescht, dann
+// der Reader auch beendet werden!!
+class SwAsynchLoader : public SvRefBase, public SwClient
+{
+protected:
+
+ SwDoc* pDoc;
+ SwPaM* pPam;
+
+ BOOL bInCall;
+ _SvLockBytes* pLoader;
+
+ DECL_STATIC_LINK( SwAsynchLoader, NewData, _SvLockBytes* );
+
+protected:
+ virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
+ virtual ~SwAsynchLoader();
+
+ virtual ULONG NextData() = 0;
+
+public:
+ SwAsynchLoader( SvStream& rIn, const SwPaM& rCrsr );
+
+ ULONG CallParser();
+};
+
+SV_DECL_REF(SwAsynchLoader)
+SV_IMPL_REF(SwAsynchLoader)
+
+
+class SwASCIIParser : public SwAsynchLoader
+{
+ char* pArr, *pStt, *pEnd, *pLastStt;
+
+ long nLineLen;
+ ULONG nError, nReadCnt, nFileSize;
+
+ const SwAsciiOptions& rOpt;
+ char cLastCRLF;
+
+ virtual ULONG NextData();
+
+protected:
+ virtual ~SwASCIIParser();
+
+public:
+ SwASCIIParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ int bReadNewDoc, const SwAsciiOptions& rOpts);
+};
+
+SV_DECL_REF(SwASCIIParser)
+SV_IMPL_REF(SwASCIIParser)
+
+
+// Aufruf fuer die allg. Reader-Schnittstelle
+ULONG AsciiReader::Read( SwDoc &rDoc, SwPaM &rPam, const String & )
+{
+ if( !pStrm )
+ {
+ ASSERT( !this, "ASCII-Read ohne Stream" );
+ return ERR_SWG_READ_ERROR;
+ }
+
+ //JP 18.01.96: Alle Ueberschriften sind normalerweise ohne
+ // Kapitelnummer. Darum hier explizit abschalten
+ // weil das Default jetzt wieder auf AN ist.
+ if( !bInsertMode )
+ Reader::SetNoOutlineNum( rDoc );
+
+ SwASCIIParserRef xParser( new SwASCIIParser( &rDoc, rPam, *pStrm,
+ !bInsertMode, eCodeSet ));
+ ULONG nRet = xParser->CallParser();
+ // nach dem Lesen sofort wieder defaulten
+ eCodeSet = GetSystemCharSet();
+ return ERRCODE_IO_PENDING == nRet ? 0 : nRet;
+}
+
+
+/* */
+
+SwASCIIParser::SwASCIIParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ int bReadNewDoc, CharSet eSrc )
+ : SwAsynchLoader( rIn, rCrsr ),
+ eCodeSet( eSrc )
+{
+ pArr = new char [ ASC_BUFFLEN + 1 ];
+
+ pStt = pEnd = pLastStt = pArr;
+
+ cLastCRLF = 0;
+ nLineLen = 0;
+ nError = 0;
+ nReadCnt = 0;
+
+ rIn.Seek(STREAM_SEEK_TO_END);
+ rIn.ResetError();
+
+ nFileSize = rIn.Tell();
+ rIn.Seek(STREAM_SEEK_TO_BEGIN);
+ rIn.ResetError();
+
+}
+
+SwASCIIParser::~SwASCIIParser()
+{
+ delete pArr;
+}
+
+
+ULONG SwASCIIParser::NextData()
+{
+ SvStream& rInput = pLoader->GetStream();
+ do {
+ if( pStt >= pEnd )
+ {
+ if( pLastStt != pStt )
+ {
+ pDoc->Insert( *pPam, pLastStt, eCodeSet );
+ pLastStt = pStt;
+ }
+
+ // lese einen neuen Block ein
+ ULONG lGCount;
+
+ if (SVSTREAM_OK != rInput.GetError() || 0 != ( nError = pLoader->
+ ReadAt( nReadCnt, pArr, ASC_BUFFLEN, &lGCount )) ||
+ ( rInput.IsEof() && !lGCount ))
+ {
+ if( ERRCODE_IO_PENDING != nError || !lGCount )
+ break; // aus der WHILE-Schleife heraus
+ }
+
+ pEnd = pArr + lGCount;
+ nReadCnt += lGCount;
+ *pEnd = 0;
+ pStt = pLastStt = pArr;
+
+ ::SetProgressState( nReadCnt, pDoc->GetDocShell() );
+
+ if( cLastCRLF )
+ {
+ if( ( 0x0a == *pStt && 0x0d == cLastCRLF ) ||
+ ( 0x0d == *pStt && 0x0a == cLastCRLF ))
+ pLastStt = ++pStt;
+ cLastCRLF = 0;
+ nLineLen = 0;
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ pDoc->SplitNode( *pPam->GetPoint() );
+ }
+ }
+
+ BOOL bIns = TRUE, bSplitNode = FALSE;
+ switch( *pStt )
+ {
+ case 0:
+ pEnd = pStt;
+ bIns = FALSE;
+ break;
+
+ case 0x0a:
+ bIns = FALSE;
+ *pStt = 0;
+ if( ++pStt == pEnd )
+ cLastCRLF = 0x0a;
+ else
+ {
+ if( 0x0d == *pStt )
+ pStt++;
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ bSplitNode = TRUE;
+ }
+ break;
+
+ case 0x0d:
+ bIns = FALSE;
+ *pStt = 0;
+ if( ++pStt == pEnd )
+ cLastCRLF = 0x0d;
+ else
+ {
+ if( 0x0a == *pStt )
+ pStt++;
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ bSplitNode = TRUE;
+ }
+ break;
+
+ case '\t': break;
+
+ case 0x0c:
+ {
+ // dann mal einen harten Seitenumbruch einfuegen
+ *pStt++ = 0;
+ if( nLineLen )
+ pDoc->Insert( *pPam, pLastStt, eCodeSet );
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pDoc->Insert( *pPam, SvxFmtBreakItem(
+ SVX_BREAK_PAGE_BEFORE ));
+ pLastStt = pStt;
+ nLineLen = 0;
+ bIns = FALSE;
+ }
+ break;
+
+ case 0x1a:
+ if( nReadCnt == nFileSize && pStt+1 == pEnd )
+ *pStt = 0;
+ else
+ *pStt = '#'; // Ersatzdarstellung
+ break;
+
+ default:
+
+ if( (BYTE)' ' > (BYTE)*pStt )
+ // Ctrl-Zchn gefunden ersetze durch '#'
+ *pStt = '#';
+ }
+
+ if( bIns )
+ {
+ if( ( nLineLen >= MAX_ASCII_PARA - 100 ) &&
+ ( ( *pStt == ' ' ) || ( nLineLen >= MAX_ASCII_PARA - 1 ) ) )
+ {
+ char c = *pStt;
+ *pStt = 0;
+ pDoc->Insert( *pPam, pLastStt, eCodeSet );
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pLastStt = pStt;
+ nLineLen = 0;
+ *pStt = c;
+ }
+ ++pStt;
+ ++nLineLen;
+ }
+ else if( bSplitNode )
+ {
+ // es wurde ein CR/LF erkannt, also speichere den Text
+ pDoc->Insert( *pPam, pLastStt, eCodeSet );
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pLastStt = pStt;
+ nLineLen = 0;
+ }
+ } while( TRUE );
+
+ return nError;
+}
+
+
+/* */
+
+SwAsynchLoader::SwAsynchLoader( SvStream& rIn, const SwPaM& rCrsr )
+ : SwClient( 0 )
+{
+ bInCall = FALSE;
+ pDoc = (SwDoc*)rCrsr.GetDoc();
+ pPam = new SwPaM( pDoc, *rCrsr.GetPoint() );
+
+ SwPageDesc& rDesc = pDoc->_GetPageDesc( 0 );
+ rDesc.Add( this );
+
+ pLoader = new _SvLockBytes( rIn,
+ STATIC_LINK( this, SwAsynchLoader, NewData ) );
+}
+
+SwAsynchLoader::~SwAsynchLoader()
+{
+ delete pPam;
+ delete pLoader;
+}
+
+void SwAsynchLoader::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
+{
+ switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 )
+ {
+ case RES_OBJECTDYING:
+ if( ((SwPtrMsgPoolItem *)pOld)->pObject == pRegisteredIn )
+ {
+ // dann uns selbst beenden
+ pRegisteredIn->Remove( this );
+ ReleaseRef(); // ansonsten sind wir fertig!
+ }
+ break;
+ }
+}
+
+IMPL_STATIC_LINK( SwAsynchLoader, NewData, _SvLockBytes*, p )
+{
+ ULONG nRet = 0;
+ if( !pThis->bInCall ) // kein mehrfaches Aufrufen
+ {
+ pThis->bInCall = TRUE;
+
+ BOOL bModify = pThis->pDoc->IsModified();
+ nRet = pThis->NextData();
+ if( !bModify )
+ pThis->pDoc->ResetModified();
+
+ if( ERRCODE_IO_PENDING != nRet )
+ pThis->ReleaseRef(); // ansonsten sind wir fertig!
+
+ pThis->bInCall = FALSE;
+ }
+
+ return nRet;
+}
+
+
+ULONG SwAsynchLoader::CallParser()
+{
+ bInCall = TRUE;
+ AddRef();
+ ULONG nRet = NextData();
+ if( ERRCODE_IO_PENDING != nRet )
+ ReleaseRef(); // ansonsten sind wir fertig!
+
+ // Sind wir im Pending-Status, wird ueber den Callback "geidelt" bis
+ // alles gelesen ist oder ein Fehler aufgetreten ist!
+
+ // Was passiert dann ???
+
+ bInCall = FALSE;
+ return nRet;
+}
+
+/* */
+
+_SvLockBytes::_SvLockBytes( SvStream& rInput, const Link& rCallback )
+ : rIn( rInput ), aCallDataRead( rCallback )
+{
+ nDataRead = 0;
+
+ aTimer.SetTimeout( 1000 ); // jede Sekunde 100 Zeichen lesen
+ aTimer.SetTimeoutHdl( STATIC_LINK( this, _SvLockBytes, DataRead ));
+ aTimer.Start();
+}
+
+_SvLockBytes::~_SvLockBytes()
+{
+ aTimer.Stop();
+}
+
+ErrCode _SvLockBytes::ReadAt( ULONG nPos, void* pArr, ULONG nCount,
+ ULONG* pReadCnt )
+{
+ ErrCode nRet = 0;
+ if( nPos + nCount > nDataRead )
+ {
+ nCount = nDataRead - nPos;
+ nRet = ERRCODE_IO_PENDING;
+ }
+
+ if( nCount )
+ {
+ rIn.Seek( nPos );
+ *pReadCnt = rIn.Read( pArr, nCount );
+ }
+ else
+ *pReadCnt = 0;
+ return rIn.GetError() ? rIn.GetError()
+ : ( rIn.IsEof() ? 0 : nRet );
+}
+
+IMPL_STATIC_LINK( _SvLockBytes, DataRead, Timer*, pTimer )
+{
+ pThis->nDataRead += 100;
+ pThis->aCallDataRead.Call( pThis );
+
+ return 0;
+}
+
+/* */
+
+#else
+
+class SwASCIIParser
+{
+ SwDoc* pDoc;
+ SwPaM* pPam;
+ SvStream& rInput;
+ sal_Char* pArr;
+ const SwAsciiOptions& rOpt;
+ SfxItemSet* pItemSet;
+ long nFileSize;
+ BOOL bNewDoc;
+
+ void ReadChars();
+ void ReadUnicode();
+
+public:
+ SwASCIIParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ int bReadNewDoc, const SwAsciiOptions& rOpts );
+ ~SwASCIIParser();
+
+ ULONG CallParser();
+};
+
+
+// Aufruf fuer die allg. Reader-Schnittstelle
+ULONG AsciiReader::Read( SwDoc &rDoc, SwPaM &rPam, const String & )
+{
+ if( !pStrm )
+ {
+ ASSERT( !this, "ASCII-Read ohne Stream" );
+ return ERR_SWG_READ_ERROR;
+ }
+
+ //JP 18.01.96: Alle Ueberschriften sind normalerweise ohne
+ // Kapitelnummer. Darum hier explizit abschalten
+ // weil das Default jetzt wieder auf AN ist.
+ if( !bInsertMode )
+ Reader::SetNoOutlineNum( rDoc );
+
+ SwASCIIParser* pParser = new SwASCIIParser( &rDoc, rPam, *pStrm,
+ !bInsertMode, aOpt.GetASCIIOpts() );
+ ULONG nRet = pParser->CallParser();
+
+ delete pParser;
+ // after Read reset the options
+ aOpt.ResetASCIIOpts();
+ return nRet;
+}
+
+void AsciiReader::SetFltName( const String& rFltNm )
+{
+ if( 5 <= rFltNm.Len() )
+ {
+ SwAsciiOptions aNewOpts;
+ switch( rFltNm.GetChar( 4 ) )
+ {
+ case 'D': aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 );
+ aNewOpts.SetParaFlags( LINEEND_CRLF );
+ if( 5 < rFltNm.Len() )
+ switch( rFltNm.Copy( 5 ).ToInt32() )
+ {
+ case 437: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_437 ); break;
+ case 850: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 ); break;
+ case 860: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_860 ); break;
+ case 861: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_861 ); break;
+ case 863: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_863 ); break;
+ case 865: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_865 ); break;
+ }
+ break;
+
+ case 'A': aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ aNewOpts.SetParaFlags( LINEEND_CRLF );
+ break;
+ case 'M': aNewOpts.SetCharSet( RTL_TEXTENCODING_APPLE_ROMAN );
+ aNewOpts.SetParaFlags( LINEEND_CR );
+ break;
+ case 'X': aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ aNewOpts.SetParaFlags( LINEEND_LF );
+ break;
+
+ default:
+ if( rFltNm.Copy( 4 ).EqualsAscii( "_DLG" ))
+ {
+ // use the options
+ aNewOpts = aOpt.GetASCIIOpts();
+ }
+ }
+ aOpt.SetASCIIOpts( aNewOpts );
+ }
+}
+
+
+SwASCIIParser::SwASCIIParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ int bReadNewDoc, const SwAsciiOptions& rOpts )
+ : pDoc( pD ), rInput( rIn ), rOpt( rOpts ), bNewDoc( bReadNewDoc ),
+ pItemSet( 0 )
+{
+ pPam = new SwPaM( *rCrsr.GetPoint() );
+ pArr = new sal_Char [ ASC_BUFFLEN + 1 ];
+
+ SfxItemSet aDfltSet( pDoc->GetAttrPool(), RES_CHRATR_FONT,
+ RES_CHRATR_LANGUAGE );
+
+ // set defaults from the options
+ if( rOpt.GetLanguage() )
+ {
+ aDfltSet.Put( SvxLanguageItem( (LanguageType)rOpt.GetLanguage(),
+ RES_CHRATR_LANGUAGE ) );
+ }
+ if( rOpt.GetFontName().Len() )
+ {
+ BOOL bDelete = FALSE;
+ const SfxFont* pFnt = 0;
+ if( pDoc->GetPrt() )
+ pFnt = pDoc->GetPrt()->GetFontByName( rOpt.GetFontName() );
+
+ if( !pFnt )
+ {
+ pFnt = new SfxFont( FAMILY_DONTKNOW, rOpt.GetFontName() );
+ bDelete = TRUE;
+ }
+
+ aDfltSet.Put( SvxFontItem( pFnt->GetFamily(), pFnt->GetName(),
+ aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet() ) );
+ }
+
+ if( aDfltSet.Count() )
+ {
+ if( bNewDoc )
+ pDoc->SetDefault( aDfltSet );
+ else
+ pItemSet = new SfxItemSet( aDfltSet );
+ }
+}
+
+SwASCIIParser::~SwASCIIParser()
+{
+ delete pPam;
+ delete pArr;
+ delete pItemSet;
+}
+
+
+// Aufruf des Parsers
+ULONG SwASCIIParser::CallParser()
+{
+ rInput.Seek(STREAM_SEEK_TO_END);
+ rInput.ResetError();
+
+ nFileSize = rInput.Tell();
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+
+ ULONG nError = 0;
+ ::StartProgress( STR_STATSTR_W4WREAD, 0, nFileSize, pDoc->GetDocShell() );
+
+ SwPaM* pInsPam = 0;
+ xub_StrLen nSttCntnt;
+ if( !bNewDoc )
+ {
+ const SwNodeIndex& rTmp = pPam->GetPoint()->nNode;
+ pInsPam = new SwPaM( rTmp, rTmp, 0, -1 );
+ nSttCntnt = pPam->GetPoint()->nContent.GetIndex();
+ }
+
+ if( RTL_TEXTENCODING_UCS2 == rOpt.GetCharSet() )
+ ReadUnicode();
+ else
+ ReadChars();
+
+ if( pInsPam )
+ {
+ if( pItemSet )
+ {
+ // then set over the insert range the defined attributes
+ *pInsPam->GetMark() = *pPam->GetPoint();
+ pInsPam->GetPoint()->nNode++;
+ SwNode* pNd = pInsPam->GetNode();
+ if( pNd->IsCntntNode() )
+ pInsPam->GetPoint()->nContent.Assign(
+ (SwCntntNode*)pNd, nSttCntnt );
+ else
+ pInsPam->GetPoint()->nContent.Assign( 0, 0 );
+
+ // !!!!!
+ ASSERT( !this, "Have to change - hard attr. to para. style" );
+ pDoc->Insert( *pInsPam, *pItemSet );
+
+ delete pItemSet, pItemSet = 0;
+ }
+ delete pInsPam;
+ }
+
+ ::EndProgress( pDoc->GetDocShell() );
+ return nError;
+}
+
+void SwASCIIParser::ReadChars()
+{
+ sal_Char *pStt = pArr, *pEnd = pArr, *pLastStt = pArr;
+ long nReadCnt = 0;
+
+ sal_Char cLastCR = 0;
+ long nLineLen = 0;
+
+ do {
+ if( pStt >= pEnd )
+ {
+ if( pLastStt != pStt )
+ pDoc->Insert( *pPam, String( pLastStt, rOpt.GetCharSet() ));
+
+ // lese einen neuen Block ein
+ ULONG lGCount;
+ if (SVSTREAM_OK != rInput.GetError() ||
+ ((lGCount = rInput.Read(pArr, ASC_BUFFLEN)) == 0))
+ break; // aus der WHILE-Schleife heraus
+
+ if( lGCount == ASC_BUFFLEN )
+ {
+ if( RTL_TEXTENCODING_UTF8 == rOpt.GetCharSet() &&
+ 0 != ( pArr[ ASC_BUFFLEN - 1 ] & 0x80 ) )
+ {
+ // check the last char and skip before the start of it
+ long nBack = 0;
+ while( 0x80 == ( pArr[ ASC_BUFFLEN - 1 + nBack ] & 0xC0 ))
+ --nBack;
+ --nBack;
+ lGCount += nBack;
+ rInput.SeekRel( nBack );
+ }
+ else if( RTL_TEXTENCODING_UTF7 == rOpt.GetCharSet() )
+ {
+ // search any char that may not be convertet
+ long nBack = 0;
+ sal_Char c;
+ while( ' ' < ( c = pArr[ ASC_BUFFLEN - 1 + nBack ] ) &&
+ '+' != c )
+ --nBack;
+ if( '+' == c )
+ --nBack;
+ lGCount += nBack;
+ rInput.SeekRel( nBack );
+ }
+ }
+
+ pEnd = pArr + lGCount;
+ nReadCnt += lGCount;
+ *pEnd = 0;
+ pStt = pLastStt = pArr;
+
+ ::SetProgressState( nReadCnt, pDoc->GetDocShell() );
+
+ if( cLastCR )
+ {
+ if( 0x0a == *pStt && 0x0d == cLastCR )
+ pLastStt = ++pStt;
+ cLastCR = 0;
+ nLineLen = 0;
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ pDoc->SplitNode( *pPam->GetPoint() );
+ }
+ }
+
+ BOOL bIns = TRUE, bSplitNode = FALSE;
+ switch( *pStt )
+ {
+ case 0:
+ pEnd = pStt;
+ bIns = FALSE;
+ break;
+
+ case 0x0a: if( LINEEND_LF == rOpt.GetParaFlags() )
+ {
+ bIns = FALSE;
+ *pStt = 0;
+ ++pStt;
+
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ bSplitNode = TRUE;
+ }
+ break;
+
+ case 0x0d: if( LINEEND_LF != rOpt.GetParaFlags() )
+ {
+ bIns = FALSE;
+ *pStt = 0;
+ ++pStt;
+
+ BOOL bChkSplit = FALSE;
+ if( LINEEND_CRLF == rOpt.GetParaFlags() )
+ {
+ if( pStt == pEnd )
+ cLastCR = 0x0d;
+ else if( 0x0a == *pStt )
+ {
+ ++pStt;
+ bChkSplit = TRUE;
+ }
+ }
+ else
+ bChkSplit = TRUE;
+
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( bChkSplit && ( !rInput.IsEof() ||
+ !(pEnd == pStt || ( !*pEnd && pEnd == pStt+1 ))))
+ bSplitNode = TRUE;
+ }
+ break;
+
+ case 0x0c:
+ {
+ // dann mal einen harten Seitenumbruch einfuegen
+ *pStt++ = 0;
+ if( nLineLen )
+ {
+ // Change to charset system!!!!
+ //rOpt.GetCharSet();
+ pDoc->Insert( *pPam, String( pLastStt,
+ rOpt.GetCharSet() ));
+ }
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pDoc->Insert( *pPam, SvxFmtBreakItem(
+ SVX_BREAK_PAGE_BEFORE ));
+ pLastStt = pStt;
+ nLineLen = 0;
+ bIns = FALSE;
+ }
+ break;
+
+ case 0x1a:
+ if( nReadCnt == nFileSize && pStt+1 == pEnd )
+ *pStt = 0;
+ else
+ *pStt = '#'; // Ersatzdarstellung
+ break;
+
+ case '\t': break;
+
+ default:
+ if( (BYTE)' ' > (BYTE)*pStt )
+ // Ctrl-Zchn gefunden ersetze durch '#'
+ *pStt = '#';
+ break;
+ }
+
+ if( bIns )
+ {
+ if( ( nLineLen >= MAX_ASCII_PARA - 100 ) &&
+ ( ( *pStt == ' ' ) || ( nLineLen >= MAX_ASCII_PARA - 1 ) ) )
+ {
+ sal_Char c = *pStt;
+ *pStt = 0;
+
+ // Change to charset system!!!!
+ //rOpt.GetCharSet();
+ pDoc->Insert( *pPam, String( pLastStt, rOpt.GetCharSet() ));
+
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pLastStt = pStt;
+ nLineLen = 0;
+ *pStt = c;
+ }
+ ++pStt;
+ ++nLineLen;
+ }
+ else if( bSplitNode )
+ {
+ // es wurde ein CR/LF erkannt, also speichere den Text
+
+ // Change to charset system!!!!
+ //rOpt.GetCharSet();
+ pDoc->Insert( *pPam, String( pLastStt, rOpt.GetCharSet() ));
+
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pLastStt = pStt;
+ nLineLen = 0;
+ }
+ } while( TRUE );
+}
+
+void SwASCIIParser::ReadUnicode()
+{
+ BOOL bSwapUnicode = FALSE;
+ long nReadCnt = 0;
+
+ sal_Int16 nFlag;
+ rInput >> nFlag;
+
+ if( -2 == nFlag )
+ bSwapUnicode = TRUE; // must be swapped
+ else if( -257 != nFlag ) // notthing to do
+ rInput.SeekRel( sizeof( nFlag ) ); // no tag at start
+
+ sal_Unicode *pStt = (sal_Unicode*)pArr, *pEnd = pStt, *pLastStt = pStt;
+
+ sal_Unicode cLastCR = 0;
+ long nLineLen = 0;
+
+ do {
+ if( pStt >= pEnd )
+ {
+ if( pLastStt != pStt )
+ pDoc->Insert( *pPam, String( pLastStt ));
+
+ // lese einen neuen Block ein
+ ULONG lGCount;
+ if (SVSTREAM_OK != rInput.GetError() ||
+ ((lGCount = rInput.Read(pArr, ASC_BUFFLEN)) == 0))
+ break; // aus der WHILE-Schleife heraus
+
+ pEnd = (sal_Unicode*)(pArr + lGCount);
+ nReadCnt += lGCount;
+ *pEnd = 0;
+ pStt = pLastStt = (sal_Unicode*)pArr;
+
+ if( bSwapUnicode )
+ {
+ sal_Char* pF = pArr, *pN = pArr + 1;
+ for( ULONG n = 0; n < lGCount; n += 2, pF += 2, pN += 2 )
+ {
+ sal_Char c = *pF;
+ *pF = *pN;
+ *pN = c;
+ }
+ }
+
+ ::SetProgressState( nReadCnt, pDoc->GetDocShell() );
+
+ if( cLastCR )
+ {
+ if( 0x0a == *pStt && 0x0d == cLastCR )
+ pLastStt = ++pStt;
+ cLastCR = 0;
+ nLineLen = 0;
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ pDoc->SplitNode( *pPam->GetPoint() );
+ }
+ }
+
+ BOOL bIns = TRUE, bSplitNode = FALSE;
+ switch( *pStt )
+ {
+ case 0:
+ pEnd = pStt;
+ bIns = FALSE;
+ break;
+
+ case 0x0a: if( LINEEND_LF == rOpt.GetParaFlags() )
+ {
+ bIns = FALSE;
+ *pStt = 0;
+ ++pStt;
+
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( !rInput.IsEof() || !(pEnd == pStt ||
+ ( !*pEnd && pEnd == pStt+1 ) ) )
+ bSplitNode = TRUE;
+ }
+ break;
+
+ case 0x0d: if( LINEEND_LF != rOpt.GetParaFlags() )
+ {
+ bIns = FALSE;
+ *pStt = 0;
+ ++pStt;
+
+ BOOL bChkSplit = FALSE;
+ if( LINEEND_CRLF == rOpt.GetParaFlags() )
+ {
+ if( pStt == pEnd )
+ cLastCR = 0x0d;
+ else if( 0x0a == *pStt )
+ {
+ ++pStt;
+ bChkSplit = TRUE;
+ }
+ }
+ else
+ bChkSplit = TRUE;
+
+ // JP 03.04.96: das letze am Ende nehmen wir nicht
+ if( bChkSplit && ( !rInput.IsEof() ||
+ !(pEnd == pStt || ( !*pEnd && pEnd == pStt+1 ))))
+ bSplitNode = TRUE;
+ }
+ break;
+
+ case 0x0c:
+ {
+ // dann mal einen harten Seitenumbruch einfuegen
+ *pStt++ = 0;
+ if( nLineLen )
+ {
+ // Change to charset system!!!!
+ //rOpt.GetCharSet();
+ pDoc->Insert( *pPam, String( pLastStt ));
+ }
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pDoc->Insert( *pPam, SvxFmtBreakItem(
+ SVX_BREAK_PAGE_BEFORE ));
+ pLastStt = pStt;
+ nLineLen = 0;
+ bIns = FALSE;
+ }
+ break;
+
+ case 0x1a:
+ if( nReadCnt == nFileSize && pStt+1 == pEnd )
+ *pStt = 0;
+ else
+ *pStt = '#'; // Ersatzdarstellung
+ break;
+
+ case '\t': break;
+
+ default:
+ if( ' ' > *pStt )
+ // Ctrl-Zchn gefunden ersetze durch '#'
+ *pStt = '#';
+ break;
+ }
+
+ if( bIns )
+ {
+ if( ( nLineLen >= MAX_ASCII_PARA - 100 ) &&
+ ( ( *pStt == ' ' ) || ( nLineLen >= MAX_ASCII_PARA - 1 ) ) )
+ {
+ sal_Unicode c = *pStt;
+ *pStt = 0;
+
+ // Change to charset system!!!!
+ //rOpt.GetCharSet();
+ pDoc->Insert( *pPam, String( pLastStt ));
+
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pLastStt = pStt;
+ nLineLen = 0;
+ *pStt = c;
+ }
+ ++pStt;
+ ++nLineLen;
+ }
+ else if( bSplitNode )
+ {
+ // es wurde ein CR/LF erkannt, also speichere den Text
+
+ pDoc->Insert( *pPam, String( pLastStt ));
+
+ pDoc->SplitNode( *pPam->GetPoint() );
+ pLastStt = pStt;
+ nLineLen = 0;
+ }
+ } while( TRUE );
+}
+
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ascii/parasc.cxx,v 1.1.1.1 2000-09-18 17:14:53 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.25 2000/09/18 16:04:39 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.24 2000/08/04 16:25:28 jp
+ read/write unicode ascii files
+
+ Revision 1.23 2000/05/08 17:37:02 jp
+ Changes for Unicode
+
+ Revision 1.22 2000/03/16 16:42:31 kz
+ chg. include to sfx2/printer
+
+ Revision 1.21 1999/10/25 19:26:58 jp
+ Bug #69048#: dont change LF to #
+
+ Revision 1.20 1999/10/08 16:31:54 jp
+ Bug #69048#: dont change tab to #
+
+ Revision 1.19 1999/08/26 18:34:10 JP
+ load and save Text with more options (charset/language/lineend/font)
+
+
+ Rev 1.18 26 Aug 1999 20:34:10 JP
+ load and save Text with more options (charset/language/lineend/font)
+
+ Rev 1.17 23 Jul 1998 11:11:14 JP
+ Task #52654#: Einfuegen Doc nicht mit einer CrsrShell sondern mit einen PaM
+
+ Rev 1.16 29 Jun 1998 13:01:16 JP
+ SvxFmtBreakItem ohne Flag!
+
+ Rev 1.15 29 Apr 1998 08:17:14 MIB
+ MUSS-Aenderung: SvStream::operator!() faellt weg
+
+ Rev 1.14 27 Feb 1998 09:19:56 JP
+ ObjectDying-MessageItem umbenannt
+
+ Rev 1.13 22 Jan 1998 20:00:10 JP
+ CTOR des SwPaM umgestellt
+
+ Rev 1.12 30 Oct 1997 17:13:52 AMA
+ Chg: Kein AutoFlag mehr an Break bzw. PageDesc-Attributen
+
+ Rev 1.11 10 Oct 1997 12:20:22 JP
+ Warnings vom Ueberlauf entfernt
+
+ Rev 1.10 09 Oct 1997 14:26:02 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.9 12 Aug 1997 10:06:46 OS
+ Header-Umstellung
+
+ Rev 1.8 07 Aug 1997 15:07:08 OM
+ Headerfile-Umstellung
+
+ Rev 1.7 06 Aug 1997 12:46:52 HJS
+ includes
+
+ Rev 1.6 13 Dec 1996 12:18:58 JP
+ Bug #34482#: nach dem Lesen auf SystemCodeSet umschalten
+
+ Rev 1.5 29 Oct 1996 12:10:24 JP
+ am Doc ist das NodesArray nur noch ueber Get..() zugaenglich
+
+ Rev 1.4 09 Oct 1996 17:58:46 MA
+ Progress
+
+ Rev 1.3 28 Jun 1996 13:59:08 MA
+ includes
+
+ Rev 1.2 02 May 1996 11:48:46 JP
+ zum Testen: asynchrones Laden erweitert
+
+ Rev 1.1 30 Apr 1996 12:09:38 JP
+ Vorbereitung fuer asynchrones laden
+
+ Rev 1.0 29 Apr 1996 18:11:00 JP
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx
new file mode 100644
index 000000000000..463c0ba50560
--- /dev/null
+++ b/sw/source/filter/ascii/wrtasc.cxx
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtasc.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _WRTASC_HXX
+#include <wrtasc.hxx>
+#endif
+
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+
+
+//-----------------------------------------------------------------
+
+SwASCWriter::SwASCWriter( const String& rFltNm )
+{
+ SwAsciiOptions aNewOpts;
+
+ switch( 5 <= rFltNm.Len() ? rFltNm.GetChar( 4 ) : 0 )
+ {
+ case 'D': aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 );
+ aNewOpts.SetParaFlags( LINEEND_CRLF );
+ if( 5 < rFltNm.Len() )
+ switch( rFltNm.Copy( 5 ).ToInt32() )
+ {
+ case 437: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_437 ); break;
+ case 850: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 ); break;
+ case 860: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_860 ); break;
+ case 861: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_861 ); break;
+ case 863: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_863 ); break;
+ case 865: aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_865 ); break;
+ }
+ break;
+
+ case 'A': aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ aNewOpts.SetParaFlags( LINEEND_CRLF );
+ break;
+ case 'M': aNewOpts.SetCharSet( RTL_TEXTENCODING_APPLE_ROMAN );
+ aNewOpts.SetParaFlags( LINEEND_CR );
+ break;
+ case 'X': aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ aNewOpts.SetParaFlags( LINEEND_LF );
+ break;
+
+ default:
+ if( rFltNm.Copy( 4 ).EqualsAscii( "_DLG" ))
+ {
+ // use the options
+ aNewOpts = GetAsciiOptions();
+ }
+ }
+ SetAsciiOptions( aNewOpts );
+}
+
+SwASCWriter::~SwASCWriter() {}
+
+ULONG SwASCWriter::WriteStream()
+{
+ sal_Char cLineEnd[ 3 ];
+ sal_Char* pCEnd = cLineEnd;
+ if( bASCII_ParaAsCR ) // falls vorgegeben ist.
+ *pCEnd++ = '\015';
+ else if( bASCII_ParaAsBlanc )
+ *pCEnd++ = ' ';
+ else
+ switch( GetAsciiOptions().GetParaFlags() )
+ {
+ case LINEEND_CR: *pCEnd++ = '\015'; break;
+ case LINEEND_LF: *pCEnd++ = '\012'; break;
+ case LINEEND_CRLF: *pCEnd++ = '\015', *pCEnd++ = '\012'; break;
+ }
+ *pCEnd = 0;
+
+ sLineEnd.AssignAscii( cLineEnd );
+
+ long nMaxNode = pDoc->GetNodes().Count();
+
+ if( bShowProgress )
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, pDoc->GetDocShell() );
+
+ SwPaM* pPam = pOrigPam;
+
+ BOOL bWriteSttTag = bUCS2_WithStartChar &&
+ RTL_TEXTENCODING_UCS2 == GetAsciiOptions().GetCharSet();
+
+ // gebe alle Bereich des Pams in das ASC-File aus.
+ do {
+ BOOL bTstFly = TRUE;
+ while( pCurPam->GetPoint()->nNode.GetIndex() < pCurPam->GetMark()->nNode.GetIndex() ||
+ (pCurPam->GetPoint()->nNode.GetIndex() == pCurPam->GetMark()->nNode.GetIndex() &&
+ pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
+ {
+ SwTxtNode* pNd = pCurPam->GetPoint()->nNode.GetNode().GetTxtNode();
+ if( pNd )
+ {
+ // sollten nur Rahmen vorhanden sein?
+ // (Moeglich, wenn Rahmen-Selektion ins Clipboard
+ // gestellt wurde)
+ if( bTstFly && bWriteAll &&
+ // keine Laenge
+ !pNd->GetTxt().Len() &&
+ // Rahmen vorhanden
+ pDoc->GetSpzFrmFmts()->Count() &&
+ // nur ein Node im Array
+ pDoc->GetNodes().GetEndOfExtras().GetIndex() + 3 ==
+ pDoc->GetNodes().GetEndOfContent().GetIndex() &&
+ // und genau der ist selektiert
+ pDoc->GetNodes().GetEndOfContent().GetIndex() - 1 ==
+ pCurPam->GetPoint()->nNode.GetIndex() )
+ {
+ // dann den Inhalt vom Rahmen ausgeben.
+ // dieser steht immer an Position 0 !!
+ SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[ 0 ];
+ const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
+ if( pIdx )
+ {
+ delete pCurPam;
+ pCurPam = NewSwPaM( *pDoc, pIdx->GetIndex(),
+ pIdx->GetNode().EndOfSectionIndex() );
+ pCurPam->Exchange();
+ continue; // while-Schleife neu aufsetzen !!
+ }
+ }
+ else
+ {
+ if( bWriteSttTag )
+ {
+ Strm() << short(-257);
+ bWriteSttTag = FALSE;
+ }
+ Out( aASCNodeFnTab, *pNd, *this );
+ }
+ bTstFly = FALSE; // eimal Testen reicht
+ }
+
+ if( !pCurPam->Move( fnMoveForward, fnGoNode ) )
+ break;
+
+ if( bShowProgress )
+ ::SetProgressState( pCurPam->GetPoint()->nNode.GetIndex(),
+ pDoc->GetDocShell() ); // Wie weit ?
+
+ }
+ } while( CopyNextPam( &pPam ) ); // bis alle Pam bearbeitet
+
+ if( bShowProgress )
+ ::EndProgress( pDoc->GetDocShell() );
+
+ return 0;
+}
+
+
+void GetASCWriter( const String& rFltNm, WriterRef& xRet )
+{
+ xRet = new SwASCWriter( rFltNm );
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ascii/wrtasc.cxx,v 1.1.1.1 2000-09-18 17:14:53 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.61 2000/09/18 16:04:39 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.60 2000/08/04 16:25:32 jp
+ read/write unicode ascii files
+
+ Revision 1.59 2000/05/08 17:37:06 jp
+ Changes for Unicode
+
+ Revision 1.58 2000/03/03 16:23:14 pl
+ #73771# workaround for c50 intel compiler
+
+ Revision 1.57 1999/08/30 08:01:52 JP
+ WriteStream - set lineend string
+
+
+ Rev 1.56 30 Aug 1999 10:01:52 JP
+ WriteStream - set lineend string
+
+ Rev 1.55 26 Aug 1999 20:34:10 JP
+ load and save Text with more options (charset/language/lineend/font)
+
+ Rev 1.54 16 Jun 1999 19:47:26 JP
+ Change interface of base class Writer
+
+ Rev 1.53 04 May 1999 14:59:40 JP
+ FilterExportklasse Writer von SvRef abgeleitet, damit sie immer zerstoert wird
+
+ Rev 1.52 27 Jun 1998 16:01:50 JP
+ Writer mit neuen Flags; fuer den ASCII-Writer, etwas aufgeraeumt
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/ascii/wrtasc.hxx b/sw/source/filter/ascii/wrtasc.hxx
new file mode 100644
index 000000000000..25fc7a0fcf60
--- /dev/null
+++ b/sw/source/filter/ascii/wrtasc.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtasc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _WRTASC_HXX
+#define _WRTASC_HXX
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _WRT_FN_HXX
+#include <wrt_fn.hxx>
+#endif
+
+extern SwNodeFnTab aASCNodeFnTab;
+
+
+// der ASC-Writer
+
+class SwASCWriter : public Writer
+{
+ String sLineEnd;
+
+ virtual ULONG WriteStream();
+
+public:
+ SwASCWriter( const String& rFilterName );
+ virtual ~SwASCWriter();
+
+ const String& GetLineEnd() const { return sLineEnd; }
+};
+
+
+#endif // _WRTASC_HXX
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
new file mode 100644
index 000000000000..fac011d27ea5
--- /dev/null
+++ b/sw/source/filter/html/css1atr.cxx
@@ -0,0 +1,3536 @@
+/*************************************************************************
+ *
+ * $RCSfile: css1atr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include "hintids.hxx"
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SFX_WHITER_HXX //autogen
+#include <svtools/whiter.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_BLNKITEM_HXX //autogen
+#include <svx/blnkitem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_KEEPITEM_HXX //autogen
+#include <svx/keepitem.hxx>
+#endif
+#ifndef _SVX_WIDWITEM_HXX //autogen
+#include <svx/widwitem.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _SVX_ORPHITEM_HXX //autogen
+#include <svx/orphitem.hxx>
+#endif
+#ifndef _XOUTBMP_HXX //autogen
+#include <svx/xoutbmp.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _SVX_HTMLMODE_HXX //autogen
+#include <svx/htmlmode.hxx>
+#endif
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _INTN_HXX //autogen
+#include <tools/intn.hxx>
+#endif
+#ifndef _BIGINT_HXX //autogen
+#include <tools/bigint.hxx>
+#endif
+#ifndef _UNOTOOLS_CHARCLASS_HXX
+#include <unotools/charclass.hxx>
+#endif
+
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _FMTCOL_HXX //autogen
+#include <fmtcol.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTTSPLT_HXX //autogen
+#include <fmtlsplt.hxx>
+#endif
+#ifndef _PAGEDESC_HXX //autogen
+#include <pagedesc.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _PAM_HXX //autogen
+#include <pam.hxx>
+#endif
+#ifndef _VIEWSH_HXX //autogen
+#include <viewsh.hxx>
+#endif
+#ifndef _VIEWOPT_HXX //autogen
+#include <viewopt.hxx>
+#endif
+#ifndef _SWTABLE_HXX //autogen
+#include <swtable.hxx>
+#endif
+// FOOTNOTES
+#ifndef _FTNINFO_HXX //autogen
+#include <ftninfo.hxx>
+#endif
+#ifndef _FTNIDX_HXX //autogen
+#include <ftnidx.hxx>
+#endif
+#ifndef _TXTFTN_HXX //autogen
+#include <txtftn.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+// FOOTNOTES
+
+#ifndef _DCONTACT_HXX //autogen
+#include <dcontact.hxx>
+#endif
+
+#include "doc.hxx"
+#include "swerror.h"
+#include "charatr.hxx"
+#include "paratr.hxx"
+#include "frmatr.hxx"
+#include "poolfmt.hxx"
+#include "fltini.hxx"
+#include "css1kywd.hxx"
+#include "wrthtml.hxx"
+#include "htmlnum.hxx"
+
+/*
+ * um nicht immer wieder nach einem Update festzustellen, das irgendwelche
+ * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle
+ * definiert und mit der akt. verglichen. Bei unterschieden wird der
+ * Compiler schon meckern.
+ *
+ * diese Section und die dazugeherigen Tabellen muessen in folgenden Files
+ * gepflegt werden: rtf\rtfatr.cxx, sw6\sw6atr.cxx, w4w\w4watr.cxx
+ */
+#if !defined(UNX) && !defined(MSC) && !defined(PPC) && !defined(CSET) && !defined(__MWERKS__) && !defined(WTC)
+
+#define ATTRFNTAB_SIZE 121
+#if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN
+#error Attribut-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+
+#endif
+
+#define HTML_HEADSPACE (12*20)
+
+#define CSS1_BACKGROUND_ATTR 1
+#define CSS1_BACKGROUND_PAGE 2
+#define CSS1_BACKGROUND_TABLE 3
+#define CSS1_BACKGROUND_FLY 4
+#define CSS1_BACKGROUND_SECTION 5
+
+#define CSS1_FRMSIZE_WIDTH 0x01
+#define CSS1_FRMSIZE_VARHEIGHT 0x02
+#define CSS1_FRMSIZE_MINHEIGHT 0x04
+#define CSS1_FRMSIZE_FIXHEIGHT 0x08
+#define CSS1_FRMSIZE_ANYHEIGHT 0x0e
+#define CSS1_FRMSIZE_PIXEL 0x10
+
+
+//-----------------------------------------------------------------------
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_rule_end, " }" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_span_tag_end, "\">" );
+const sal_Char cCSS1_style_opt_end = '\"';
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sHTML_FTN_fontheight, "57%" );
+
+extern SwAttrFnTab aCSS1AttrFnTab;
+
+static Writer& OutCSS1_SwFmt( Writer& rWrt, const SwFmt& rFmt,
+ SwDoc *pDoc, SwDoc *pTemplate );
+static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rFmt,
+ SwDoc *pDoc, SwDoc *pTemplate,
+ USHORT nRefPoolId, BOOL bExtRef,
+ BOOL bPseudo=TRUE );
+static Writer& OutCSS1_SwFtnInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
+ SwDoc *pDoc, USHORT nNotes, BOOL bEndNote );
+static void OutCSS1_SwFmtDropAttrs( SwHTMLWriter& rHWrt,
+ const SwFmtDrop& rDrop );
+static Writer& OutCSS1_SvxUnderl_SvxCrOut_SvxBlink( Writer& rWrt,
+ const SvxUnderlineItem *pUItem,
+ const SvxCrossedOutItem *pCOItem,
+ const SvxBlinkItem *pBItem );
+static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+ const SvxULSpaceItem *pULSpace,
+ const SvxLRSpaceItem *pLRSpace );
+static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+ const SfxItemSet& rItemSet,
+ BOOL bDeep );
+static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
+ USHORT nMode, const String *pGrfName );
+static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutCSS1_SwFmtFrmSize( Writer& rWrt, const SfxPoolItem& rHt,
+ USHORT nMode );
+static Writer& OutCSS1_SvxFmtBreak_SwFmtPDesc_SvxFmtKeep( Writer& rWrt,
+ const SfxItemSet& rItemSet,
+ BOOL bDeep );
+static Writer& OutCSS1_SwFmtLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt );
+
+static void ConvToHex( USHORT nHex, ByteString& rStr )
+{
+ sal_Char aNToABuf[] = "00";
+
+ // Pointer an das Bufferende setzen
+ sal_Char *pStr = aNToABuf + (sizeof(aNToABuf)-1);
+ for( BYTE n = 0; n < 2; ++n )
+ {
+ *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
+ if( *pStr > '9' )
+ *pStr += 39;
+ nHex >>= 4;
+ }
+
+ rStr.Append( aNToABuf );
+}
+
+static void GetCSS1Color( const Color& rColor, ByteString& rStr )
+{
+ rStr += '#';
+
+ ConvToHex( rColor.GetRed(), rStr );
+ ConvToHex( rColor.GetGreen(), rStr );
+ ConvToHex( rColor.GetBlue(), rStr );
+}
+
+class SwCSS1OutMode
+{
+ SwHTMLWriter& rWrt;
+ USHORT nOldMode;
+
+public:
+
+ SwCSS1OutMode( SwHTMLWriter& rHWrt, USHORT nMode, BOOL bStartFirst=TRUE,
+ const String *pSelector=0 ) :
+ rWrt( rHWrt ),
+ nOldMode( rHWrt.nCSS1OutMode )
+ {
+ rWrt.nCSS1OutMode = nMode;
+ if( bStartFirst )
+ rWrt.bFirstCSS1Property = TRUE;
+ if( pSelector )
+ rWrt.aCSS1Selector = *pSelector;
+ }
+
+ ~SwCSS1OutMode()
+ {
+ rWrt.nCSS1OutMode = nOldMode;
+ }
+};
+
+
+
+void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
+ const sal_Char *pVal,
+ const String *pSVal )
+{
+ ByteString sOut;
+
+ if( bFirstCSS1Rule && (nCSS1OutMode & CSS1_OUTMODE_RULE_ON)!=0 )
+ {
+ bFirstCSS1Rule = FALSE;
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_style );
+ OutNewLine();
+ Strm() << '<' << sHTML_comment;
+
+ IncIndentLevel();
+ }
+
+ if( bFirstCSS1Property )
+ {
+ switch( nCSS1OutMode & CSS1_OUTMODE_ANY_ON )
+ {
+ case CSS1_OUTMODE_SPAN_TAG_ON:
+ case CSS1_OUTMODE_SPAN_TAG1_ON:
+ if( bTagOn )
+ {
+ ((((sOut += '<') += sHTML_span) += ' ') += sHTML_O_style) += "=\"";
+ }
+ else
+ {
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_span, FALSE );
+ return;
+ }
+ break;
+
+ case CSS1_OUTMODE_RULE_ON:
+ {
+ ByteString sTmp( aCSS1Selector, eDestEnc );
+ OutNewLine();
+ (sOut = sTmp) += " { ";
+ }
+ break;
+
+ case CSS1_OUTMODE_STYLE_OPT_ON:
+ ((sOut = ' ') += sHTML_O_style) += "=\"";
+ break;
+ }
+ bFirstCSS1Property = FALSE;
+ }
+ else
+ {
+ sOut += "; ";
+ }
+
+
+ (sOut += pProp) += ": ";
+ if( nCSS1OutMode & CSS1_OUTMODE_ENCODE )
+ {
+ // In STYLE-Optionen den String codieren
+ Strm() << sOut.GetBuffer();
+ sOut.Erase();
+ if( pVal )
+ HTMLOutFuncs::Out_String( Strm(), String::CreateFromAscii(pVal),
+ eDestEnc );
+ else if( pSVal )
+ HTMLOutFuncs::Out_String( Strm(), *pSVal, eDestEnc );
+ }
+ else
+ {
+ // Im STYLE-Tag des String direct ausgeben
+ if( pVal )
+ sOut += pVal;
+ else if( pVal )
+ {
+ ByteString sTmp( *pSVal, eDestEnc );
+ sOut += sTmp;
+ }
+ }
+
+ if( sOut.Len() )
+ Strm() << sOut.GetBuffer();
+}
+
+static void AddUnitPropertyValue( long nVal, FieldUnit eUnit, ByteString& rOut )
+{
+ if( nVal < 0 )
+ {
+ // Vorzeichen extra behandeln
+ nVal = -nVal;
+ rOut += '-';
+ }
+
+ // Die umgerechnete Einheit ergibt sich aus (x * nMul)/(nDiv*nFac*10)
+ long nMul = 1000;
+ long nDiv = 1;
+ long nFac = 100;
+ const sal_Char *pUnit;
+ switch( eUnit )
+ {
+ case FUNIT_100TH_MM:
+ ASSERT( FUNIT_MM == eUnit, "Masseinheit wird nicht unterstuetzt" );
+ case FUNIT_MM:
+ // 0.01mm = 0.57twip
+ nMul = 25400; // 25.4 * 1000
+ nDiv = 1440; // 72 * 20;
+ nFac = 100;
+ pUnit = sCSS1_UNIT_mm;
+ break;
+
+ case FUNIT_M:
+ case FUNIT_KM:
+ ASSERT( FUNIT_CM == eUnit, "Masseinheit wird nicht unterstuetzt" );
+ case FUNIT_CM:
+#ifdef EXACT_VALUES
+ // 0.001cm = 0.57twip
+ nMul = 25400; // 2.54 * 10000
+ nDiv = 1440; // 72 * 20;
+ nFac = 1000;
+#else
+ // 0.01cm = 5.7twip (ist zwar ungenau, aber die UI ist auch ungenau)
+ nMul = 2540; // 2.54 * 1000
+ nDiv = 1440; // 72 * 20;
+ nFac = 100;
+#endif
+ pUnit = sCSS1_UNIT_cm;
+ break;
+
+ case FUNIT_TWIP:
+ ASSERT( FUNIT_POINT == eUnit, "Masseinheit wird nicht unterstuetzt" );
+ case FUNIT_POINT:
+#ifdef EXACT_VALUES
+ // 0.01pt = 0.2twip
+ nMul = 1000;
+ nDiv = 20;
+ nFac = 100;
+#else
+ // 0.1pt = 2.0twip (ist zwar ungenau, aber die UI ist auch ungenau)
+ nMul = 100;
+ nDiv = 20;
+ nFac = 10;
+#endif
+ pUnit = sCSS1_UNIT_pt;
+ break;
+
+ case FUNIT_PICA:
+#ifdef EXACT_VALUES
+ // 0.001pc = 0.24twip
+ nMul = 10000;
+ nDiv = 12 * 20;
+ nFac = 1000;
+#else
+ // 0.01pc = 2.40twip (ist zwar ungenau, aber die UI ist auch ungenau)
+ nMul = 1000;
+ nDiv = 240; // 12 * 20;
+ nFac = 100;
+#endif
+ pUnit = sCSS1_UNIT_pc;
+ break;
+
+ case FUNIT_NONE:
+ case FUNIT_FOOT:
+ case FUNIT_MILE:
+ case FUNIT_CUSTOM:
+ case FUNIT_PERCENT:
+ case FUNIT_INCH:
+ default:
+ ASSERT( FUNIT_INCH == eUnit, "Masseinheit wird nicht unterstuetzt" );
+#ifdef EXACT_VALUES
+ // 0.0001in = 0.144twip
+ nMul = 100000;
+ nDiv = 1440; // 72 * 20;
+ nFac = 10000;
+#else
+ // 0.01in = 14.4twip (ist zwar ungenau, aber die UI ist auch ungenau)
+ nMul = 1000;
+ nDiv = 1440; // 72 * 20;
+ nFac = 100;
+#endif
+ pUnit = sCSS1_UNIT_inch;
+ break;
+ }
+
+ long nLongVal;
+ BOOL bOutLongVal = TRUE;
+ if( nVal > LONG_MAX / nMul )
+ {
+ // Zum Unrechnen der Einheit wird ein BigInt benoetigt
+#ifdef SAL_INT64_IS_STRUCT
+ BigInt nBigVal( nVal );
+ nBigVal *= nMul;
+ nBigVal /= nDiv;
+ nBigVal += 5;
+ nBigVal /= 10;
+
+ if( nBigVal.IsLong() )
+ {
+ // Zum Ausgeben des Wertes reicht ein long.
+ nLongVal = (long)nBigVal;
+ }
+ else
+ {
+ BigInt nBigFac( nFac );
+ BigInt nBig10( 10 );
+ rOut += (long)(nBigVal / nBigFac);
+ if( !(nBigVal % nBigFac).IsZero() )
+ {
+ rOut += '.';
+ while( nFac > 1 && !(nBigVal % nBigFac).IsZero() )
+ {
+ nFac /= 10;
+ nBigFac = nFac;
+ rOut += (int)((nBigVal / nBigFac) % nBig10 );
+ }
+ }
+ bOutLongVal = FALSE;
+ }
+#else
+ sal_Int64 nBigVal( nVal );
+ nBigVal *= nMul;
+ nBigVal /= nDiv;
+ nBigVal += 5;
+ nBigVal /= 10;
+
+ if( nBigVal <= LONG_MAX )
+ {
+ // Zum Ausgeben des Wertes reicht ein long.
+ nLongVal = (long)nBigVal;
+ }
+ else
+ {
+ rOut += ByteString::CreateFromInt64( nBigVal / (sal_Int64)nFac );
+ if( (nBigVal % (sal_Int64)nFac) != 0 )
+ {
+ rOut += '.';
+ while( nFac > 1 && (nBigVal % (sal_Int64)nFac) != 0 )
+ {
+ nFac /= 10;
+ rOut += ByteString::CreateFromInt64(
+ (nBigVal / (sal_Int64)nFac) % (sal_Int64)10 );
+ }
+ }
+ bOutLongVal = FALSE;
+ }
+#endif
+ }
+ else
+ {
+ nLongVal = nVal * nMul;
+ nLongVal /= nDiv;
+ nLongVal += 5;
+ nLongVal /= 10;
+ }
+
+ if( bOutLongVal )
+ {
+ rOut += ByteString::CreateFromInt32( nLongVal/nFac );
+ if( (nLongVal % nFac) != 0 )
+ {
+ rOut += '.';
+ while( nFac > 1 && (nLongVal % nFac) != 0 )
+ {
+ nFac /= 10;
+ rOut += ByteString::CreateFromInt32( (nLongVal / nFac) % 10 );
+ }
+ }
+ }
+
+ rOut.Append( pUnit );
+}
+
+void SwHTMLWriter::OutCSS1_UnitProperty( const sal_Char *pProp, long nVal )
+{
+ ByteString sOut;
+ AddUnitPropertyValue( nVal, eCSS1Unit, sOut );
+ OutCSS1_PropertyAscii( pProp, sOut );
+}
+
+void SwHTMLWriter::OutCSS1_PixelProperty( const sal_Char *pProp, long nVal,
+ BOOL bVert )
+{
+ if( nVal && Application::GetDefaultDevice() )
+ {
+ Size aSz( bVert ? 0 : nVal, bVert ? nVal : 0 );
+ aSz = Application::GetDefaultDevice()->LogicToPixel( aSz, MapMode( MAP_TWIP) );
+ nVal = bVert ? aSz.Height() : aSz.Width();
+ if( !nVal )
+ nVal = 1;
+ }
+
+ ByteString sOut( ByteString::CreateFromInt32( nVal ) );
+ sOut.Append( sCSS1_UNIT_px );
+ OutCSS1_PropertyAscii( pProp, sOut );
+}
+
+void SwHTMLWriter::OutCSS1_SfxItemSet( const SfxItemSet& rItemSet,
+ BOOL bDeep )
+{
+ // den ItemSet ausgeben, und zwar inklusive aller Attribute
+ Out_SfxItemSet( aCSS1AttrFnTab, *this, rItemSet, bDeep );
+
+ // ein par Attribute benoetigen eine Spezial-Behandlung
+ const SfxPoolItem *pItem = 0;
+
+ // Underline, CrossedOut und Blink bilden zusammen eine CSS1-Property
+ // (geht natuerlich nicht bei Hints)
+ if( !IsCSS1Source(CSS1_OUTMODE_HINT) )
+ {
+ const SvxUnderlineItem *pUnderlineItem = 0;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_CHRATR_UNDERLINE, bDeep, &pItem ))
+ pUnderlineItem = (const SvxUnderlineItem *)pItem;
+
+ const SvxCrossedOutItem *pCrossedOutItem = 0;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_CHRATR_CROSSEDOUT, bDeep, &pItem ))
+ pCrossedOutItem = (const SvxCrossedOutItem *)pItem;
+
+ const SvxBlinkItem *pBlinkItem = 0;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_CHRATR_BLINK, bDeep, &pItem ))
+ pBlinkItem = (const SvxBlinkItem *)pItem;
+
+ if( pUnderlineItem || pCrossedOutItem || pBlinkItem )
+ OutCSS1_SvxUnderl_SvxCrOut_SvxBlink( *this, pUnderlineItem,
+ pCrossedOutItem,
+ pBlinkItem );
+
+ OutCSS1_SvxFmtBreak_SwFmtPDesc_SvxFmtKeep( *this, rItemSet, bDeep );
+ }
+
+ if( !bFirstCSS1Property )
+ {
+ // wenn eine Property als Bestandteil einer Style-Option
+ // ausgegeben wurde, muss die Optiomn noch beendet werden
+ ByteString sOut;
+ switch( nCSS1OutMode & CSS1_OUTMODE_ANY_OFF )
+ {
+ case CSS1_OUTMODE_SPAN_TAG_OFF:
+ sOut = sCSS1_span_tag_end;
+ break;
+
+ case CSS1_OUTMODE_STYLE_OPT_OFF:
+ sOut = cCSS1_style_opt_end;
+ break;
+
+ case CSS1_OUTMODE_RULE_OFF:
+ sOut = sCSS1_rule_end;
+ break;
+ }
+ if( sOut.Len() )
+ Strm() << sOut.GetBuffer();
+ }
+}
+
+#if USED
+void SwHTMLWriter::OutCSS1_SfxItem( USHORT nMode,
+ const SfxPoolItem *pItem1,
+ const SfxPoolItem *pItem2 )
+{
+ // den ItemSet ausgeben, und zwar inklusive aller Attribute
+ nSaveMode = nCSS1OutMode;
+ nCSS1OutMode = nMode;
+ bFirstCSS1Property = TRUE;
+
+ Out( aCSS1AttrFnTab, *pItem1, *this );
+ if( pItem2 )
+ Out( aCSS1AttrFnTab, *pItem2, *this );
+
+
+ if( !bFirstCSS1Property )
+ {
+ // wenn eine Property als Bestandteil einer Style-Option
+ // ausgegeben wurde, muss die Optiomn noch beendet werden
+ ByteString sOut;
+ switch( nCSS1OutMode & CSS1_OUTMODE_ANY_OFF )
+ {
+ case CSS1_OUTMODE_SPAN_TAG_OFF:
+ sOut = sCSS1_span_tag_end;
+ break;
+
+ case CSS1_OUTMODE_STYLE_OPT_OFF:
+ sOut = cCSS1_style_opt_end;
+ break;
+
+ case CSS1_OUTMODE_RULE:
+ sOut = sCSS1_rule_end;
+ break;
+ }
+ if( sOut.Len() )
+ rStrm << sOut.GetBuffer();
+ }
+
+ nCSS1OutMode = nSaveMode;
+}
+#endif
+
+void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, BOOL bUsed )
+{
+ bFirstCSS1Rule = TRUE;
+
+// Feature: PrintExt
+ if( IsHTMLMode(HTMLMODE_PRINT_EXT) )
+ {
+ const SwPageDesc *pFirstPageDesc = 0;
+ USHORT nFirstRefPoolId = RES_POOLPAGE_HTML;
+ bCSS1IgnoreFirstPageDesc = TRUE;
+
+ // Erstmal versuchen wir zu erraten, wie das Dokument so augebaut ist.
+ // Erlaubt sind nur die Vorlagen HTML, erste Seite, linke Seite und
+ // rechte Seite.
+ // Eine erste Seite wird nur exportiert, wenn die erste Seite auch
+ // wirklich die Vorlage "erste Seite" ist.
+ // Linke und rechte Seiten werden nur exportiert, wenn diese beiden
+ // Vorlagen untereinander verkettet werden.
+ // Wenn andere Vorlagen verwendet werden, wird nur in sehr einfachen
+ // Faellen etwas exportiert.
+ const SwPageDesc *pPageDesc = &rPageDesc;
+ const SwPageDesc *pFollow = rPageDesc.GetFollow();
+ if( RES_POOLPAGE_FIRST == pPageDesc->GetPoolFmtId() &&
+ pFollow != pPageDesc &&
+ !IsPoolUserFmt( pFollow->GetPoolFmtId() ) )
+ {
+ // Das Dokument hat eine erste Seite
+ pFirstPageDesc = pPageDesc;
+ pPageDesc = pFollow;
+ pFollow = pPageDesc->GetFollow();
+ }
+ if( pPageDesc == pFollow )
+ {
+ // Das Dokument ist einseitig. Egal welche Seite verwendet wird,
+ // es wird kein zweiseitiges Dokument daraus gemacht.
+ // Die Attributierung wird relativ zur HTML-Seitenvorlage
+ // aus der HTML-Vorlage exportiert.
+ OutCSS1_SwPageDesc( *this, *pPageDesc, pDoc, pTemplate,
+ RES_POOLPAGE_HTML, TRUE, FALSE );
+ nFirstRefPoolId = pFollow->GetPoolFmtId();
+ }
+ else if( (RES_POOLPAGE_LEFT == pPageDesc->GetPoolFmtId() &&
+ RES_POOLPAGE_RIGHT == pFollow->GetPoolFmtId()) ||
+ (RES_POOLPAGE_RIGHT == pPageDesc->GetPoolFmtId() &&
+ RES_POOLPAGE_LEFT == pFollow->GetPoolFmtId()) )
+ {
+ // Das Dokument ist zweiseitig
+ OutCSS1_SwPageDesc( *this, *pPageDesc, pDoc, pTemplate,
+ RES_POOLPAGE_HTML, TRUE );
+ OutCSS1_SwPageDesc( *this, *pFollow, pDoc, pTemplate,
+ RES_POOLPAGE_HTML, TRUE );
+ nFirstRefPoolId = RES_POOLPAGE_RIGHT;
+ bCSS1IgnoreFirstPageDesc = FALSE;
+ }
+ // Alles andere bekommen wir nicht hin.
+
+ if( pFirstPageDesc )
+ OutCSS1_SwPageDesc( *this, *pFirstPageDesc, pDoc, pTemplate,
+ nFirstRefPoolId, FALSE );
+ }
+// /Feature: PrintExt
+
+
+ // das Default-TextStyle wir nicht mit ausgegeben !!
+ // das 0-Style ist das Default, wird nie ausgegeben !!
+ USHORT nArrLen = pDoc->GetTxtFmtColls()->Count();
+ for( USHORT i=1; i<nArrLen; i++ )
+ {
+ const SwTxtFmtColl* pColl = (*pDoc->GetTxtFmtColls())[i];
+ if( !bUsed || pDoc->IsUsed( *pColl ) )
+ OutCSS1_SwFmt( *this, *pColl, pDoc, pTemplate );
+ }
+
+ // das Default-TextStyle wir nicht mit ausgegeben !!
+ nArrLen = pDoc->GetCharFmts()->Count();
+ for( i=1; i<nArrLen; i++ )
+ {
+ const SwCharFmt *pCFmt = (*pDoc->GetCharFmts())[i];
+ USHORT nPoolId = pCFmt->GetPoolFmtId();
+ if( !bUsed || nPoolId == RES_POOLCHR_INET_NORMAL ||
+ nPoolId == RES_POOLCHR_INET_VISIT ||
+ pDoc->IsUsed( *pCFmt ) )
+ OutCSS1_SwFmt( *this, *pCFmt, pDoc, pTemplate );
+ }
+
+ const SwFtnIdxs& rIdxs = pDoc->GetFtnIdxs();
+ nArrLen = rIdxs.Count();
+ USHORT nEnd = 0, nFtn = 0;
+ for( i=0; i < nArrLen; i++ )
+ {
+ if( rIdxs[i]->GetFtn().IsEndNote() )
+ nEnd++;
+ else
+ nFtn++;
+ }
+ OutCSS1_SwFtnInfo( *this, pDoc->GetFtnInfo(), pDoc, nFtn, FALSE );
+ OutCSS1_SwFtnInfo( *this, pDoc->GetEndNoteInfo(), pDoc, nEnd, TRUE );
+
+ if( !bFirstCSS1Rule )
+ {
+ DecIndentLevel();
+ OutNewLine();
+ Strm() << "-->";
+
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_style, FALSE );
+ }
+ else
+ {
+ bFirstCSS1Rule = FALSE;
+ }
+
+ nDfltTopMargin = 0;
+ nDfltBottomMargin = 0;
+}
+
+#ifdef OLD_MS_IE
+
+BOOL SwHTMLWriter::IsDfltLRSpace( const SvxLRSpaceItem& rLRItem ) const
+{
+ // Einen linken Rand kann es durch eine Liste bereits in der
+ // Umgebung geben
+ USHORT nLeft = rLRItem.GetTxtLeft() - nLeftMargin;
+
+ // Der Erstzeilen-Einzug kann den Platz fuer eine Numerierung
+ // enthalten
+ short nIndent = rLRItem.GetTxtFirstLineOfst() - nFirstLineIndent;
+
+ // Wenn Spacer exportiert werden, wird ein psositiver Erstzeilen-Einzug
+ // als Spacer exportiert.
+ return nDfltLeftMargin == nLeft &&
+ nDfltRightMargin == rLRItem.GetRight() &&
+ ( (bCfgSpacer && nIndent > 0) ||
+ nDfltFirstLineIndent == nIndent );
+}
+
+BOOL SwHTMLWriter::IsDfltULSpace( const SvxULSpaceItem& rULItem ) const
+{
+ return nDfltTopMargin == rULItem.GetUpper() &&
+ nDfltBottomMargin == rULItem.GetLower();
+}
+
+#endif
+
+//-----------------------------------------------------------------------
+
+// wenn pPseudo gesetzt ist werden Styles-Sheets ausgegeben,
+// sonst wird nur nach Token und Class fuer ein Format gesucht
+USHORT SwHTMLWriter::GetCSS1Selector( const SwFmt *pFmt, ByteString& rToken,
+ String& rClass, USHORT& rRefPoolId,
+ String *pPseudo )
+{
+ USHORT nDeep = 0;
+ rToken.Erase(); rClass.Erase();
+ rRefPoolId = 0;
+ if( pPseudo )
+ pPseudo->Erase();
+
+ BOOL bChrFmt = RES_CHRFMT==pFmt->Which();
+
+ // Nach oben die Formate abklappern, bis man auf eine Standard-
+ // oder eine HTML-Tag-Vorlage trifft
+ const SwFmt *pPFmt = pFmt;
+ while( pPFmt && !pPFmt->IsDefault() )
+ {
+ BOOL bStop = FALSE;
+ USHORT nPoolId = pPFmt->GetPoolFmtId();
+ if( USER_FMT & nPoolId )
+ {
+ // Benutzer-Vorlagen
+ const String& rNm = pPFmt->GetName();
+ switch( rNm.GetChar(0) )
+ {
+ // nicht mehr unterstuetzt:
+ // sHTML_author
+ // sHTML_acronym
+ // sHTML_abbreviation
+ // sHTML_deletedtext
+ // sHTML_insertedtext
+ // sHTML_language
+ // sHTML_person
+ case 'B': if( !bChrFmt && rNm.EqualsAscii(sHTML_blockquote) )
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_BLOCKQUOTE;
+ rToken.Assign( sHTML_blockquote );
+ }
+ break;
+ case 'C': if( bChrFmt )
+ {
+ if( rNm.EqualsAscii(sHTML_citiation) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_CITIATION;
+ rToken.Assign( sHTML_citiation );
+ }
+ else if( rNm.EqualsAscii(sHTML_code) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_CODE;
+ rToken.Assign( sHTML_code );
+ }
+ }
+ break;
+ case 'D': if( bChrFmt && rNm.EqualsAscii(sHTML_definstance) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_DEFINSTANCE;
+ rToken.Assign( sHTML_definstance);
+ }
+ else if( !bChrFmt )
+ {
+ USHORT nDefListLvl = GetDefListLvl( rNm, nPoolId );
+ // Die Vorlagen DD 1/DT 1 werden ausgegeben,
+ // aber keine von ihnen abgeleiteten Vorlagen,
+ // auch nicht DD 2/DT 2 etc.
+ if( nDefListLvl )
+ {
+ if( pPseudo &&
+ (nDeep || (nDefListLvl & 0x0fff) > 1) )
+ {
+ bStop = TRUE;
+ }
+ else if( nDefListLvl & HTML_DLCOLL_DD )
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_DD;
+ rToken.Assign( sHTML_dd );
+ }
+ else
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_DT;
+ rToken.Assign( sHTML_dt );
+ }
+ }
+ }
+ break;
+ case 'E': if( bChrFmt && rNm.EqualsAscii( sHTML_emphasis ) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_EMPHASIS;
+ rToken.Assign( sHTML_emphasis );
+ }
+ break;
+ case 'H': if( !bChrFmt && rNm.EqualsAscii( sHTML_horzrule ) )
+ // HR nicht ausgeben!
+ bStop = (nDeep==0);
+ break;
+ case 'K': if( bChrFmt && rNm.EqualsAscii( sHTML_keyboard ) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_KEYBOARD;
+ rToken.Assign( sHTML_keyboard );
+ }
+ break;
+ case 'L': if( !bChrFmt && rNm.EqualsAscii( sHTML_listing ) )
+ {
+ // Listing als PRE exportieren bzw. von
+ // PRE abgeleitete Vorlage exportieren
+ rToken.Assign( sHTML_preformtxt );
+ rRefPoolId = RES_POOLCOLL_HTML_PRE;
+ nDeep = CSS1_FMT_CMPREF;
+ }
+ break;
+ case 'P': if( !bChrFmt && rNm.EqualsAscii( sHTML_preformtxt ) )
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_PRE;
+ rToken.Assign( sHTML_preformtxt );
+ }
+ break;
+ case 'S': if( bChrFmt )
+ {
+ if( rNm.EqualsAscii( sHTML_sample ) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_SAMPLE;
+ rToken.Assign( sHTML_sample );
+ }
+ else if( rNm.EqualsAscii( sHTML_strong ) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_STRONG;
+ rToken.Assign( sHTML_strong );
+ }
+ }
+ break;
+ case 'T': if( bChrFmt && rNm.EqualsAscii( sHTML_teletype ) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_TELETYPE;
+ rToken.Assign( sHTML_teletype );
+ }
+ break;
+ case 'V': if( bChrFmt && rNm.EqualsAscii( sHTML_variable ) )
+ {
+ rRefPoolId = RES_POOLCHR_HTML_VARIABLE;
+ rToken.Assign( sHTML_variable );
+ }
+ break;
+ case 'X': if( !bChrFmt && rNm.EqualsAscii( sHTML_xmp ) )
+ {
+ // XMP als PRE exportieren (aber nicht die
+ // Vorlage als Style)
+ rToken.Assign( sHTML_preformtxt );
+ rRefPoolId = RES_POOLCOLL_HTML_PRE;
+ nDeep = CSS1_FMT_CMPREF;
+ }
+ break;
+ }
+
+ // Wenn eine PoolId gesetzt ist, entspricht der Name der
+ // Vorlage dem szugehoerigen Token
+ ASSERT( rRefPoolId != 0 == rToken.Len() > 0,
+ "Token missing" );
+ }
+ else
+ {
+ // Pool-Vorlagen
+ switch( nPoolId )
+ {
+ // Absatz-Vorlagen
+ case RES_POOLCOLL_HEADLINE_BASE:
+ case RES_POOLCOLL_STANDARD:
+ // diese Vorlagen nicht ausgeben
+ bStop = (nDeep==0);
+ break;
+ case RES_POOLCOLL_TEXT:
+ rToken.Assign( sHTML_parabreak );
+ break;
+ case RES_POOLCOLL_HEADLINE1:
+ rToken.Assign( sHTML_head1 );
+ break;
+ case RES_POOLCOLL_HEADLINE2:
+ rToken.Assign( sHTML_head2 );
+ break;
+ case RES_POOLCOLL_HEADLINE3:
+ rToken.Assign( sHTML_head3 );
+ break;
+ case RES_POOLCOLL_HEADLINE4:
+ rToken.Assign( sHTML_head4 );
+ break;
+ case RES_POOLCOLL_HEADLINE5:
+ rToken.Assign( sHTML_head5 );
+ break;
+ case RES_POOLCOLL_HEADLINE6:
+ rToken.Assign( sHTML_head6 );
+ break;
+ case RES_POOLCOLL_SENDADRESS:
+ rToken.Assign( sHTML_address );
+ break;
+ case RES_POOLCOLL_HTML_BLOCKQUOTE:
+ rToken.Assign( sHTML_blockquote );
+ break;
+ case RES_POOLCOLL_HTML_PRE:
+ rToken.Assign( sHTML_preformtxt );
+ break;
+
+ case RES_POOLCOLL_HTML_DD:
+ rToken.Assign( sHTML_dd );
+ break;
+ case RES_POOLCOLL_HTML_DT:
+ rToken.Assign( sHTML_dt );
+ break;
+
+ case RES_POOLCOLL_TABLE:
+ if( pPseudo )
+ {
+ rToken.Assign( sHTML_tabledata );
+ rToken.Append( ' ' );
+ rToken.Assign( sHTML_parabreak );
+ }
+ else
+ rToken.Assign( sHTML_parabreak );
+ break;
+ case RES_POOLCOLL_TABLE_HDLN:
+ if( pPseudo )
+ {
+ rToken.Assign( sHTML_tableheader );
+ rToken.Assign( ' ' );
+ rToken.Assign( sHTML_parabreak );
+ }
+ else
+ rToken.Assign( sHTML_parabreak );
+ break;
+ case RES_POOLCOLL_HTML_HR:
+ // HR nicht ausgeben!
+ bStop = (nDeep==0);
+ break;
+ case RES_POOLCOLL_FOOTNOTE:
+ if( !nDeep )
+ {
+ rToken.Assign( sHTML_parabreak );
+ rClass.AssignAscii( sHTML_sdfootnote );
+ rRefPoolId = RES_POOLCOLL_TEXT;
+ nDeep = CSS1_FMT_CMPREF;
+ }
+ break;
+ case RES_POOLCOLL_ENDNOTE:
+ if( !nDeep )
+ {
+ rToken.Assign( sHTML_parabreak );
+ rClass.AssignAscii( sHTML_sdendnote );
+ rRefPoolId = RES_POOLCOLL_TEXT;
+ nDeep = CSS1_FMT_CMPREF;
+ }
+ break;
+
+ // Zeichen-Vorlagen
+ case RES_POOLCHR_HTML_EMPHASIS:
+ rToken.Assign( sHTML_emphasis );
+ break;
+ case RES_POOLCHR_HTML_CITIATION:
+ rToken.Assign( sHTML_citiation );
+ break;
+ case RES_POOLCHR_HTML_STRONG:
+ rToken.Assign( sHTML_strong );
+ break;
+ case RES_POOLCHR_HTML_CODE:
+ rToken.Assign( sHTML_code );
+ break;
+ case RES_POOLCHR_HTML_SAMPLE:
+ rToken.Assign( sHTML_sample );
+ break;
+ case RES_POOLCHR_HTML_KEYBOARD:
+ rToken.Assign( sHTML_keyboard );
+ break;
+ case RES_POOLCHR_HTML_VARIABLE:
+ rToken.Assign( sHTML_variable );
+ break;
+ case RES_POOLCHR_HTML_DEFINSTANCE:
+ rToken.Assign( sHTML_definstance );
+ break;
+ case RES_POOLCHR_HTML_TELETYPE:
+ rToken.Assign( sHTML_teletype );
+ break;
+
+ case RES_POOLCHR_INET_NORMAL:
+ if( pPseudo )
+ {
+ rToken.Assign( sHTML_anchor );
+ pPseudo->AssignAscii( sCSS1_link );
+ }
+ break;
+ case RES_POOLCHR_INET_VISIT:
+ if( pPseudo )
+ {
+ rToken.Assign( sHTML_anchor );
+ pPseudo->AssignAscii( sCSS1_visited );
+ }
+ break;
+ }
+
+ // Wenn ein Token gesetzt ist, enthaelt nPoolId die dazugehoerige
+ // Vorlage
+ if( rToken.Len() && !rRefPoolId )
+ rRefPoolId = nPoolId;
+ }
+
+ if( rToken.Len() || bStop )
+ {
+ // Anhalten wenn eine HTML-Tag-Vorlage gefunden wurde
+ break;
+ }
+ else
+ {
+ // sonst weitersuchen
+ nDeep++;
+ pPFmt = pPFmt->DerivedFrom();
+ }
+ }
+
+ if( rToken.Len() )
+ {
+ // Es ist eine HTML-Tag-Vorlage
+ if( !nDeep )
+ nDeep = CSS1_FMT_ISTAG;
+ }
+ else
+ {
+ // Es ist keine HTML-Tag-Vorlage und auch keine davon abgeleitete
+ nDeep = 0;
+ }
+ if( nDeep > 0 && nDeep < CSS1_FMT_SPECIAL )
+ {
+ // Wenn die Vorlage von einer HTML-Vorlage abgeleitet ist,
+ // wird sie als <TOKEN>.<CLASS> exportiert, sonst als .<CLASS>.
+ // <CLASS> ergibt sich aus dem Namen der Vorlage durch entfernen
+ // aller Zeichen vor und inklusive dem ersten '.'
+ rClass = pFmt->GetName();
+ xub_StrLen nPos = rClass.Search( '.' );
+ if( nPos != STRING_NOTFOUND && rClass.Len() > nPos+1 )
+ {
+ rClass.Erase( 0, nPos+1 );
+ }
+
+ GetAppCharClass().toLower( rClass );
+ while( STRING_NOTFOUND != rClass.SearchAndReplace( '.', '-' ) )
+ ;
+ while( STRING_NOTFOUND != rClass.SearchAndReplace( ' ', '-' ) )
+ ;
+ while( STRING_NOTFOUND != rClass.SearchAndReplace( '_', '-' ) )
+ ;
+ }
+
+ return nDeep;
+}
+
+static USHORT GetCSS1Selector( const SwFmt *pFmt, String& rSelector,
+ USHORT& rRefPoolId )
+{
+ ByteString aToken;
+ String aClass;
+ String aPseudo;
+
+ USHORT nDeep = SwHTMLWriter::GetCSS1Selector( pFmt, aToken, aClass,
+ rRefPoolId, &aPseudo );
+ if( nDeep )
+ {
+ if( aToken.Len() )
+ rSelector = String( aToken, RTL_TEXTENCODING_ASCII_US );
+ else
+ rSelector.Erase();
+
+ if( aClass.Len() )
+ (rSelector += '.') += aClass;
+ if( aPseudo.Len() )
+ (rSelector += ':') += aPseudo;
+ }
+
+ return nDeep;
+}
+
+const SwFmt *SwHTMLWriter::GetTemplateFmt( USHORT nPoolFmtId,
+ SwDoc *pTemplate )
+{
+ const SwFmt *pRefFmt = 0;
+
+ if( pTemplate )
+ {
+ ASSERT( !(USER_FMT & nPoolFmtId),
+ "In der Dok-Vorlage gibt es keine Benutzer-Vorlagen" );
+ if( POOLGRP_NOCOLLID & nPoolFmtId )
+ pRefFmt = pTemplate->GetCharFmtFromPool( nPoolFmtId );
+ else
+ pRefFmt = pTemplate->GetTxtCollFromPool( nPoolFmtId );
+ }
+
+ return pRefFmt;
+}
+
+const SwFmt *SwHTMLWriter::GetParentFmt( const SwFmt& rFmt, USHORT nDeep )
+{
+ ASSERT( nDeep != USHRT_MAX, "GetParent fuer HTML-Vorlage aufgerufen!" );
+ const SwFmt *pRefFmt = 0;
+
+ if( nDeep > 0 )
+ {
+ // hier wird die HTML-Tag-Vorlage, von der die Vorlage abgeleitet
+ // ist als Referenz geholt
+ pRefFmt = &rFmt;
+ for( USHORT i=nDeep; i>0; i-- )
+ pRefFmt = pRefFmt->DerivedFrom();
+
+ if( pRefFmt && pRefFmt->IsDefault() )
+ pRefFmt = 0;
+ }
+
+ return pRefFmt;
+}
+
+BOOL lcl_css1atr_equalFontItems( const SfxPoolItem& r1, const SfxPoolItem& r2 )
+{
+ return ((const SvxFontItem &)r1).GetFamilyName() ==
+ ((const SvxFontItem &)r2).GetFamilyName() &&
+ ((const SvxFontItem &)r1).GetFamily() ==
+ ((const SvxFontItem &)r2).GetFamily() &&
+ ((const SvxFontItem &)r1).GetPitch() ==
+ ((const SvxFontItem &)r2).GetPitch();
+}
+
+void SwHTMLWriter::SubtractItemSet( SfxItemSet& rItemSet,
+ const SfxItemSet& rRefItemSet,
+ BOOL bSetDefaults,
+ BOOL bClearSame )
+{
+ ASSERT( bSetDefaults || bClearSame,
+ "SwHTMLWriter::SubtractItemSet: Bei diesen Flags passiert nix" );
+ SfxItemSet aRefItemSet( *rRefItemSet.GetPool(), rRefItemSet.GetRanges() );
+ aRefItemSet.Set( rRefItemSet );
+
+ // und mit dem Attr-Set der Vorlage vergleichen
+ SfxWhichIter aIter( rItemSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ const SfxPoolItem *pRefItem, *pItem;
+ BOOL bItemSet = ( SFX_ITEM_SET ==
+ rItemSet.GetItemState( nWhich, FALSE, &pItem) );
+ BOOL bRefItemSet = ( SFX_ITEM_SET ==
+ aRefItemSet.GetItemState( nWhich, FALSE, &pRefItem) );
+ if( bItemSet )
+ {
+ if( bClearSame && bRefItemSet &&
+ ( *pItem == *pRefItem ||
+ (RES_CHRATR_FONT == nWhich &&
+ lcl_css1atr_equalFontItems( *pItem, *pRefItem )) ) )
+ {
+ // das Attribut ist mit dem gleichen Wert in beiden
+ // Vorlagen vorhanden und muss nicht ausgegeben werden
+ rItemSet.ClearItem( nWhich );
+ }
+ }
+ else
+ {
+ if( bSetDefaults && bRefItemSet )
+ {
+ // das Attribut ist nur in der Referenz vorhanden. Das
+ // Default muss ggf. ausgegeben werden
+ rItemSet.Put( rItemSet.GetPool()->GetDefaultItem(nWhich) );
+ }
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwHTMLWriter::PrepareFontList( const SvxFontItem& rFontItem,
+ String& rNames,
+ sal_Unicode cQuote, BOOL bGeneric )
+{
+ rNames = aEmptyStr;
+ const String& rName = rFontItem.GetFamilyName();
+ BOOL bContainsKeyword = FALSE;
+ if( rName.Len() )
+ {
+ xub_StrLen nStrPos = 0;
+ while( nStrPos != STRING_NOTFOUND )
+ {
+ String aName = rName.GetToken( 0, ';', nStrPos );
+ aName.EraseTrailingChars().EraseLeadingChars();
+ if( !aName.Len() )
+ continue;
+
+ BOOL bIsKeyword = FALSE;
+ switch( aName.GetChar( 0 ) )
+ {
+ case 'c':
+ case 'C':
+ bIsKeyword = aName.EqualsIgnoreCaseAscii( sCSS1_PV_cursive );
+ break;
+
+ case 'f':
+ case 'F':
+ bIsKeyword = aName.EqualsIgnoreCaseAscii( sCSS1_PV_fantasy );
+ break;
+
+ case 'm':
+ case 'M':
+ bIsKeyword = aName.EqualsIgnoreCaseAscii( sCSS1_PV_monospace );
+ break;
+
+ case 's':
+ case 'S':
+ bIsKeyword =
+ aName.EqualsIgnoreCaseAscii( sCSS1_PV_serif ) ||
+ aName.EqualsIgnoreCaseAscii( sCSS1_PV_sans_serif );
+ break;
+ }
+
+ bContainsKeyword |= bIsKeyword;
+
+ if( rNames.Len() )
+ rNames.AppendAscii( ", " );
+ if( cQuote && !bIsKeyword )
+ rNames += cQuote;
+ rNames += aName;
+ if( cQuote && !bIsKeyword )
+ rNames += cQuote;
+ }
+ }
+
+ if( !bContainsKeyword && bGeneric )
+ {
+ const sal_Char *pStr = 0;
+ switch( rFontItem.GetFamily() )
+ {
+ case FAMILY_ROMAN: pStr = sCSS1_PV_serif; break;
+ case FAMILY_SWISS: pStr = sCSS1_PV_sans_serif; break;
+ case FAMILY_SCRIPT: pStr = sCSS1_PV_cursive; break;
+ case FAMILY_DECORATIVE: pStr = sCSS1_PV_fantasy; break;
+ case FAMILY_MODERN: pStr = sCSS1_PV_monospace; break;
+ }
+
+ if( pStr )
+ {
+ if( rNames.Len() )
+ rNames.AppendAscii( ", " );
+ rNames.AppendAscii( pStr );
+ }
+ }
+}
+
+static Writer& OutCSS1_SwFmt( Writer& rWrt, const SwFmt& rFmt,
+ SwDoc *pDoc, SwDoc *pTemplate )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ BOOL bCharFmt = FALSE;
+ switch( rFmt.Which() )
+ {
+ case RES_CHRFMT:
+ bCharFmt = TRUE;
+ break;
+
+ case RES_TXTFMTCOLL:
+ case RES_CONDTXTFMTCOLL:
+ // diese Vorlagen-Typen koennen exportiert werden
+ break;
+
+ default:
+ // und diese nicht
+ return rWrt;
+ }
+
+ // den Selector und die auszugebende Attr-Set-Tiefe ermitteln
+ String aSelector;
+ USHORT nRefPoolId = 0;
+ USHORT nDeep = GetCSS1Selector( &rFmt, aSelector, nRefPoolId );
+ if( !nDeep )
+ return rWrt; // von keiner HTML-Vorlage abgeleitet
+
+ USHORT nPoolFmtId = rFmt.GetPoolFmtId();
+
+ // Den auszugebenden Attr-Set bestimmen. Hier muessen 3 Faelle
+ // unterschieden werden:
+ // - HTML-Tag-Vorlagen (nDeep==USHRT_MAX):
+ // Es werden die Attrs ausgegeben
+ // - die in der Vorlage gesetzt sind, aber nicht im Original aus
+ // der HTML-Vorlage
+ // - die Default-Attrs fuer die Attrs, die im Original aus der
+ // HTML-Vorlage gesetzt sind, aber nicht in der vorliegeden Vorlage.
+ // - direkt von HTML-Vorlagen abgeleitete Vorlagen (nDeep==1):
+ // Es weren nur die Attribute des Vorlagen-Item-Set ohne seine
+ // Parents ausgegeben.
+ // - indirekt von HTML-Tag-Vorlagen abgeleitete Vorlagen (nDeep>1)
+ // Es werden die Attribute des Vorlagen-Item-Sets inkl. seiner Parents,
+ // aber ohne die Attribute, die in der HTML-Tag-Vorlage gesetzt sind,
+ // ausgegeben.
+
+ // einen Item-Set mit allen Attributen aus der Vorlage anlegen
+ // (ausser fuer nDeep==1)
+ const SfxItemSet& rFmtItemSet = rFmt.GetAttrSet();
+ SfxItemSet aItemSet( *rFmtItemSet.GetPool(), rFmtItemSet.GetRanges() );
+ aItemSet.Set( rFmtItemSet, nDeep!=1 );
+
+ BOOL bSetDefaults = TRUE, bClearSame = TRUE;
+ const SwFmt *pRefFmt = 0;
+ switch( nDeep )
+ {
+ case CSS1_FMT_ISTAG:
+ pRefFmt = SwHTMLWriter::GetTemplateFmt( nRefPoolId, pTemplate );
+ break;
+ case CSS1_FMT_CMPREF:
+ pRefFmt = SwHTMLWriter::GetTemplateFmt( nRefPoolId, pDoc );
+ bClearSame = FALSE;
+ break;
+ default:
+ pRefFmt = SwHTMLWriter::GetParentFmt( rFmt, nDeep );
+ bSetDefaults = FALSE;
+ break;
+ }
+
+ if( pRefFmt )
+ {
+ // Den Item-Set der Referenz-Vorlage (inkl. seiner Parents) vom
+ // ItemSet abziehen
+ SwHTMLWriter::SubtractItemSet( aItemSet, pRefFmt->GetAttrSet(),
+ bSetDefaults, bClearSame );
+ if( !bCharFmt )
+ {
+ const SvxULSpaceItem& rULItem = pRefFmt->GetULSpace();
+ rHTMLWrt.nDfltTopMargin = rULItem.GetUpper();
+ rHTMLWrt.nDfltBottomMargin = rULItem.GetLower();
+ }
+ }
+ else if( CSS1_FMT_ISTAG==nDeep && !bCharFmt )
+ {
+ // die Default-Abstaende nach oben und unten setzen (fuer den
+ // Fall, dass es keine Vorlage als Referenz gibt)
+ rHTMLWrt.nDfltTopMargin = 0;
+ rHTMLWrt.nDfltBottomMargin = HTML_PARSPACE;
+ if( USER_FMT & nPoolFmtId )
+ {
+ // Benutzer-Vorlagen
+ const String& rNm = rFmt.GetName();
+ switch( rNm.GetChar(0) )
+ {
+ case 'D': if( rNm.EqualsAscii("DD 1") || rNm.EqualsAscii("DT 1") )
+ rHTMLWrt.nDfltBottomMargin = 0;
+ break;
+ case 'L': if(rNm.EqualsAscii(sHTML_listing) )
+ rHTMLWrt.nDfltBottomMargin = 0;
+ break;
+ case 'P': if( rNm.EqualsAscii(sHTML_preformtxt) )
+ rHTMLWrt.nDfltBottomMargin = 0;
+ break;
+ case 'X': if( rNm.EqualsAscii(sHTML_xmp) )
+ rHTMLWrt.nDfltBottomMargin = 0;
+ break;
+ }
+ }
+ else
+ {
+ // Pool-Vorlagen
+ switch( nPoolFmtId )
+ {
+ case RES_POOLCOLL_HEADLINE1:
+ case RES_POOLCOLL_HEADLINE2:
+ case RES_POOLCOLL_HEADLINE3:
+ case RES_POOLCOLL_HEADLINE4:
+ case RES_POOLCOLL_HEADLINE5:
+ case RES_POOLCOLL_HEADLINE6:
+ rHTMLWrt.nDfltTopMargin = HTML_HEADSPACE;
+ break;
+ case RES_POOLCOLL_SENDADRESS:
+ case RES_POOLCOLL_HTML_DT:
+ case RES_POOLCOLL_HTML_DD:
+ case RES_POOLCOLL_HTML_PRE:
+ rHTMLWrt.nDfltBottomMargin = 0;
+ break;
+ }
+ }
+ }
+
+ // wo nicht auszugeben ist ...
+ if( !aItemSet.Count() )
+ return rWrt;
+
+ // jetzt die Attribute (inkl. Selektor) ausgeben
+ {
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ TRUE, &aSelector );
+ rHTMLWrt.OutCSS1_SfxItemSet( aItemSet, FALSE );
+
+ if( nPoolFmtId==RES_POOLCOLL_TEXT && !rHTMLWrt.bFirstCSS1Property )
+ rHTMLWrt.bPoolCollTextModified = TRUE;
+ }
+
+ // Drop-Caps ausgeben
+ const SfxPoolItem *pItem;
+ if( rHTMLWrt.IsHTMLMode(HTMLMODE_DROPCAPS) &&
+ SFX_ITEM_SET==aItemSet.GetItemState( RES_PARATR_DROP, FALSE, &pItem ))
+ {
+ String sOut( aSelector );
+ sOut.Append( ':');
+ sOut.AppendAscii( sCSS1_first_letter );
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
+ TRUE, &sOut );
+
+ const SwFmtDrop *pDrop = (const SwFmtDrop *)pItem;
+
+ OutCSS1_SwFmtDropAttrs( rHTMLWrt, *pDrop );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
+ SwDoc *pDoc, SwDoc *pTemplate,
+ USHORT nRefPoolId, BOOL bExtRef,
+ BOOL bPseudo )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SwPageDesc* pRefPageDesc = 0;
+ if( !bExtRef )
+ pRefPageDesc = pDoc->GetPageDescFromPool( nRefPoolId );
+ else if( pTemplate )
+ pRefPageDesc = pTemplate->GetPageDescFromPool( nRefPoolId );
+
+ String aSelector( '@' );
+ aSelector.AppendAscii( sCSS1_page );
+
+ if( bPseudo )
+ {
+ const sal_Char *pPseudo = 0;
+ switch( rPageDesc.GetPoolFmtId() )
+ {
+ case RES_POOLPAGE_FIRST: pPseudo = sCSS1_first; break;
+ case RES_POOLPAGE_LEFT: pPseudo = sCSS1_left; break;
+ case RES_POOLPAGE_RIGHT: pPseudo = sCSS1_right; break;
+ }
+ if( pPseudo )
+ {
+ aSelector.Append( ':' );
+ aSelector.AppendAscii( pPseudo );
+ }
+ }
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE_ON|CSS1_OUTMODE_TEMPLATE,
+ TRUE, &aSelector );
+
+ // Die Groesse: Wenn sie sich nur durch das Landscape-Flag unterscheidet,
+ // wird nur Portrait oder Landscape exportiert. Sonst wird die Groesse
+ // exportiert.
+ BOOL bRefLandscape = pRefPageDesc ? pRefPageDesc->GetLandscape() : FALSE;
+ Size aRefSz;
+ const Size& rSz = rPageDesc.GetMaster().GetFrmSize().GetSize();
+ if( pRefPageDesc )
+ {
+ aRefSz = pRefPageDesc->GetMaster().GetFrmSize().GetSize();
+ if( bRefLandscape != rPageDesc.GetLandscape() )
+ {
+ long nTmp = aRefSz.Height();
+ aRefSz.Height() = aRefSz.Width();
+ aRefSz.Width() = nTmp;
+ }
+ }
+
+ // Boeser uebler Hack: Auf der Seiten-Tabpage gibt es leichte
+ // Rundungsfehler bei der Seitengroesse. Unter anderem wegen bug
+ // 25535 wird dummerweise auch noch immer Size-Item vom Dialog geputtet,
+ // auch wenn man gar nichts geaendert hat. Folge: Sobald man einmal im
+ // Seiten-Dialog war und ihn mit OK verlassen hat, bekommt man eine
+ // neue Seitengroesse, die dann hier exportiert wuerde. Um das
+ // vermeiden erlauben wir hier kleine Abweichungen.
+ if( Abs( rSz.Width() - aRefSz.Width() ) <= 2 &&
+ Abs( rSz.Height() - aRefSz.Height() ) <= 2 )
+ {
+ if( bRefLandscape != rPageDesc.GetLandscape() )
+ {
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_size,
+ rPageDesc.GetLandscape() ? sCSS1_PV_landscape
+ : sCSS1_PV_portrait );
+ }
+ }
+ else
+ {
+ ByteString sVal;
+ AddUnitPropertyValue( rSz.Width(), rHTMLWrt.GetCSS1Unit(), sVal );
+ sVal += ' ';
+ AddUnitPropertyValue( rSz.Height(), rHTMLWrt.GetCSS1Unit(), sVal );
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_size, sVal );
+ }
+
+ // Die Abstand-Attribute koennen auf gwohnte Weise exportiert werden
+ const SwFrmFmt &rMaster = rPageDesc.GetMaster();
+ SfxItemSet aItemSet( *rMaster.GetAttrSet().GetPool(),
+ RES_LR_SPACE, RES_UL_SPACE );
+ aItemSet.Set( rMaster.GetAttrSet(), TRUE );
+
+ if( pRefPageDesc )
+ {
+ SwHTMLWriter::SubtractItemSet( aItemSet,
+ pRefPageDesc->GetMaster().GetAttrSet(),
+ TRUE );
+ }
+
+ OutCSS1_SvxULSpace_SvxLRSpace( rWrt, aItemSet, FALSE );
+
+ // Wenn fuer einen Pseudo-Selektor keine Property ausgegeben wurde, muessen
+ // wir trotzdem etwas ausgeben, damit beim Import die entsprechende
+ // Vorlage angelegt wird.
+ if( rHTMLWrt.bFirstCSS1Property && bPseudo )
+ {
+ rHTMLWrt.OutNewLine();
+ ByteString sTmp( aSelector, rHTMLWrt.eDestEnc );
+ rWrt.Strm() << sTmp.GetBuffer() << " {";
+ rHTMLWrt.bFirstCSS1Property = FALSE;
+ }
+
+ if( !rHTMLWrt.bFirstCSS1Property )
+ rWrt.Strm() << sCSS1_rule_end;
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SwFtnInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
+ SwDoc *pDoc, USHORT nNotes, BOOL bEndNote )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ String aSelector;
+
+ if( nNotes > 0 )
+ {
+ aSelector.AssignAscii( sHTML_anchor );
+ aSelector.Append( '.');
+ aSelector.AppendAscii( bEndNote ? sHTML_sdendnote_anc
+ : sHTML_sdfootnote_anc );
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ TRUE, &aSelector );
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_size,
+ sHTML_FTN_fontheight );
+ rHTMLWrt.Strm() << sCSS1_rule_end;
+ }
+
+ const SwCharFmt *pSymCharFmt = rInfo.GetCharFmt( *pDoc );
+ if( pSymCharFmt )
+ {
+ const SfxItemSet& rFmtItemSet = pSymCharFmt->GetAttrSet();
+ SfxItemSet aItemSet( *rFmtItemSet.GetPool(), rFmtItemSet.GetRanges() );
+ aItemSet.Set( rFmtItemSet, TRUE );
+
+ USHORT nPoolFmtId = pSymCharFmt->GetPoolFmtId();
+ // Wenn es Fuss- bzw. Endnoten gibt, dann muessen alles Attribute
+ // ausgegeben werden, damit Netscape das Dokument richtig anzeigt.
+ // Anderenfalls genuegt es, die Unterschiede zur Fuss-/Endnoten
+ // Vorlage rauszuschreiben.
+ if( nNotes == 0 && rHTMLWrt.pTemplate )
+ {
+ SwFmt *pRefFmt = rHTMLWrt.pTemplate->GetCharFmtFromPool(
+ bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE );
+ if( pRefFmt )
+ SwHTMLWriter::SubtractItemSet( aItemSet, pRefFmt->GetAttrSet(),
+ TRUE );
+ }
+ if( aItemSet.Count() )
+ {
+ aSelector.AssignAscii( sHTML_anchor );
+ aSelector.Append( '.');
+ aSelector.AppendAscii( bEndNote ? sHTML_sdendnote_sym
+ : sHTML_sdfootnote_sym );
+ SwCSS1OutMode aMode( rHTMLWrt,
+ CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
+ TRUE, &aSelector );
+ rHTMLWrt.OutCSS1_SfxItemSet( aItemSet, FALSE );
+ }
+ }
+
+ return rWrt;
+}
+
+Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet,
+ String aEmbBGGrfName )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
+ CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_BODY );
+
+
+ // Es werden nur die Attribute der Seiten-Vorlage ausgegeben.
+ // Die Attribute der Standard-Absatz-Vorlage werden schon beim
+ // Export der Absatz-Vorlagen beruecksichtigt.
+
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, FALSE,
+ &pItem ) )
+ {
+ OutCSS1_SvxBrush( rWrt, *pItem, CSS1_BACKGROUND_PAGE,
+ &aEmbBGGrfName );
+ }
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, FALSE,
+ &pItem ))
+ {
+ OutCSS1_SvxBox( rWrt, *pItem );
+ }
+
+ if( !rHTMLWrt.bFirstCSS1Property )
+ {
+ // wenn eine Property als Bestandteil einer Style-Option
+ // ausgegeben wurde, muss die Optiomn noch beendet werden
+ rWrt.Strm() << '\"';
+ }
+
+ return rWrt;
+}
+
+Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT |
+ CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_PARA );
+ rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, FALSE );
+
+ return rWrt;
+}
+
+Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_SPAN_TAG |
+ CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_HINT );
+
+ Out( aCSS1AttrFnTab, rHt, rWrt );
+
+ if( !rHTMLWrt.bFirstCSS1Property && rHTMLWrt.bTagOn )
+ rWrt.Strm() << sCSS1_span_tag_end;
+
+ return rWrt;
+}
+
+Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
+ CSS1_OUTMODE_ENCODE|
+ CSS1_OUTMODE_HINT );
+
+ Out( aCSS1AttrFnTab, rHt, rWrt );
+
+ if( !rHTMLWrt.bFirstCSS1Property )
+ rWrt.Strm() << '\"';
+
+ return rWrt;
+}
+
+// Wrapper fuer die Ausgabe von Tabellen-Hintergruenden
+Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
+ CSS1_OUTMODE_ENCODE|
+ CSS1_OUTMODE_TABLEBOX );
+ OutCSS1_SvxBrush( rWrt, rHt, CSS1_BACKGROUND_TABLE, 0 );
+
+ if( !rHTMLWrt.bFirstCSS1Property )
+ rWrt.Strm() << '\"';
+
+ return rWrt;
+}
+
+
+Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
+ BYTE nLevel )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT |
+ CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_PARA );
+
+ const SwNumFmt& rNumFmt = rNumRule.Get( nLevel );
+
+ long nLSpace = rNumFmt.GetAbsLSpace();
+ long nFirstLineOffset = rNumFmt.GetFirstLineOffset();
+ long nDfltFirstLineOffset = HTML_NUMBUL_INDENT;
+ if( nLevel > 0 )
+ {
+ const SwNumFmt& rPrevNumFmt = rNumRule.Get( nLevel-1 );
+ nLSpace -= rPrevNumFmt.GetAbsLSpace();
+ nDfltFirstLineOffset = rPrevNumFmt.GetFirstLineOffset();
+ }
+
+ if( rHTMLWrt.IsHTMLMode(HTMLMODE_LSPACE_IN_NUMBUL) &&
+ nLSpace != HTML_NUMBUL_MARGINLEFT )
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLSpace );
+
+ if( rHTMLWrt.IsHTMLMode(HTMLMODE_FRSTLINE_IN_NUMBUL) &&
+ nFirstLineOffset != nDfltFirstLineOffset )
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent, nFirstLineOffset );
+
+ if( !rHTMLWrt.bFirstCSS1Property )
+ rWrt.Strm() << '\"';
+
+ return rWrt;
+}
+
+//-----------------------------------------------------------------------
+
+void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt,
+ ULONG nFrmOpts,
+ const SdrObject *pSdrObj,
+ const SfxItemSet *pItemSet )
+{
+ SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
+ CSS1_OUTMODE_ENCODE|
+ CSS1_OUTMODE_FRAME );
+
+ const SwFmtHoriOrient& rHoriOri = rFrmFmt.GetHoriOrient();
+ SvxLRSpaceItem aLRItem( rFrmFmt.GetLRSpace() );
+ SvxULSpaceItem aULItem( rFrmFmt.GetULSpace() );
+ if( nFrmOpts & HTML_FRMOPT_S_ALIGN )
+ {
+ const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor();
+ switch( rAnchor.GetAnchorId() )
+ {
+ case FLY_AT_CNTNT:
+ case FLY_AUTO_CNTNT:
+ if( FRAME == rHoriOri.GetRelationOrient() ||
+ PRTAREA == rHoriOri.GetRelationOrient() )
+ {
+ if( !(nFrmOpts & HTML_FRMOPT_ALIGN) )
+ {
+ // float
+ const sal_Char *pStr = HORI_RIGHT==rHoriOri.GetHoriOrient()
+ ? sCSS1_PV_right
+ : sCSS1_PV_left;
+ OutCSS1_PropertyAscii( sCSS1_P_float, pStr );
+ }
+ break;
+ }
+
+ case FLY_PAGE:
+ case FLY_AT_FLY:
+ {
+ // position
+ OutCSS1_PropertyAscii( sCSS1_P_position, sCSS1_PV_absolute );
+
+ // Fuer top/left muessen die Abstaende des Rahmens von
+ // der Position abgezogen werden, da sie in CSS1 noch
+ // zur Position addiert werden.
+ // Das funktioniert auch fuer automatisch ausgerichtete
+ // Rahmen, obwohl der Abstand da ja auch im Writer noch
+ // addiert wird. Denn auch in diesem Fall enthalten
+ // die Orient-Attribute die korrekte Position
+
+ // top
+ long nXPos=0, nYPos=0;
+ BOOL bOutXPos = FALSE, bOutYPos = FALSE;
+ if( RES_DRAWFRMFMT == rFrmFmt.Which() )
+ {
+ ASSERT( pSdrObj, "Kein SdrObject uebergeben. Ineffizient" );
+ if( !pSdrObj )
+ pSdrObj = rFrmFmt.FindSdrObject();
+ ASSERT( pSdrObj, "Wo ist das SdrObject" );
+ if( pSdrObj )
+ {
+ Point aPos( pSdrObj->GetRelativePos() );
+ nXPos = aPos.A();
+ nYPos = aPos.B();
+ }
+ bOutXPos = bOutYPos = TRUE;
+ }
+ else
+ {
+ bOutXPos = REL_CHAR != rHoriOri.GetRelationOrient();
+ nXPos = HORI_NONE == rHoriOri.GetHoriOrient()
+ ? rHoriOri.GetPos() : 0;
+
+ const SwFmtVertOrient& rVertOri = rFrmFmt.GetVertOrient();
+ bOutYPos = REL_CHAR != rVertOri.GetRelationOrient();
+ nYPos = VERT_NONE == rVertOri.GetVertOrient()
+ ? rVertOri.GetPos() : 0;
+ }
+
+ if( bOutYPos )
+ {
+ if( IsHTMLMode( HTMLMODE_FLY_MARGINS) )
+ {
+ nYPos -= aULItem.GetUpper();
+ if( nYPos < 0 )
+ {
+ aULItem.SetUpper( (USHORT)(aULItem.GetUpper() + nYPos) );
+ nYPos = 0;
+ }
+ }
+
+ OutCSS1_UnitProperty( sCSS1_P_top, nYPos );
+ }
+
+ if( bOutXPos )
+ {
+ // left
+ if( IsHTMLMode( HTMLMODE_FLY_MARGINS) )
+ {
+ nXPos -= aLRItem.GetLeft();
+ if( nXPos < 0 )
+ {
+ aLRItem.SetLeft( (USHORT)(aLRItem.GetLeft() + nXPos) );
+ nXPos = 0;
+ }
+ }
+
+ OutCSS1_UnitProperty( sCSS1_P_left, nXPos );
+ }
+ }
+ break;
+ }
+ }
+
+ // width/height
+ if( nFrmOpts & HTML_FRMOPT_S_SIZE )
+ {
+ if( RES_DRAWFRMFMT == rFrmFmt.Which() )
+ {
+ ASSERT( pSdrObj, "Kein SdrObject uebergeben. Ineffizient" );
+ if( !pSdrObj )
+ pSdrObj = rFrmFmt.FindSdrObject();
+ ASSERT( pSdrObj, "Wo ist das SdrObject" );
+ if( pSdrObj )
+ {
+ Size aTwipSz( pSdrObj->GetLogicRect().GetSize() );
+ if( nFrmOpts & HTML_FRMOPT_S_WIDTH )
+ {
+ if( nFrmOpts & HTML_FRMOPT_S_PIXSIZE )
+ OutCSS1_PixelProperty( sCSS1_P_width, aTwipSz.Width(),
+ FALSE );
+ else
+ OutCSS1_UnitProperty( sCSS1_P_width, aTwipSz.Width() );
+ }
+ if( nFrmOpts & HTML_FRMOPT_S_HEIGHT )
+ {
+ if( nFrmOpts & HTML_FRMOPT_S_PIXSIZE )
+ OutCSS1_PixelProperty( sCSS1_P_height, aTwipSz.Height(),
+ TRUE );
+ else
+ OutCSS1_UnitProperty( sCSS1_P_height, aTwipSz.Height() );
+ }
+ }
+ }
+ else
+ {
+ ASSERT( HTML_FRMOPT_ABSSIZE & nFrmOpts,
+ "Absolute Groesse wird exportiert" );
+ ASSERT( HTML_FRMOPT_ANYSIZE & nFrmOpts,
+ "Jede Groesse wird exportiert" );
+ USHORT nMode = 0;
+ if( nFrmOpts & HTML_FRMOPT_S_WIDTH )
+ nMode |= CSS1_FRMSIZE_WIDTH;
+ if( nFrmOpts & HTML_FRMOPT_S_HEIGHT )
+ nMode |= (CSS1_FRMSIZE_MINHEIGHT|CSS1_FRMSIZE_FIXHEIGHT);
+ if( nFrmOpts & HTML_FRMOPT_S_PIXSIZE )
+ nMode |= CSS1_FRMSIZE_PIXEL;
+
+ OutCSS1_SwFmtFrmSize( *this, rFrmFmt.GetFrmSize(), nMode );
+ }
+ }
+
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ // margin-*
+ if( (nFrmOpts & HTML_FRMOPT_S_SPACE) &&
+ IsHTMLMode( HTMLMODE_FLY_MARGINS) )
+ {
+ const SvxLRSpaceItem *pLRItem = 0;
+ const SvxULSpaceItem *pULItem = 0;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_LR_SPACE, TRUE ) )
+ pLRItem = &aLRItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_UL_SPACE, TRUE ) )
+ pULItem = &aULItem;
+ if( pLRItem || pULItem )
+ OutCSS1_SvxULSpace_SvxLRSpace( *this, pULItem, pLRItem );
+ }
+
+ // border
+ if( nFrmOpts & HTML_FRMOPT_S_BORDER )
+ {
+ const SfxPoolItem* pItem;
+ if( nFrmOpts & HTML_FRMOPT_S_NOBORDER )
+ OutCSS1_SvxBox( *this, rFrmFmt.GetBox() );
+ else if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BOX, TRUE, &pItem ) )
+ OutCSS1_SvxBox( *this, *pItem );
+ }
+
+ // background (wenn, dann muss auch eine Farbe ausgegeben werden)
+ if( nFrmOpts & HTML_FRMOPT_S_BACKGROUND )
+ OutCSS1_FrmFmtBackground( rFrmFmt );
+
+ if( pItemSet )
+ OutCSS1_SfxItemSet( *pItemSet, FALSE );
+
+ if( !bFirstCSS1Property )
+ Strm() << '\"';
+}
+
+void SwHTMLWriter::OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt )
+{
+ SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
+ CSS1_OUTMODE_ENCODE|
+ CSS1_OUTMODE_TABLE );
+
+ const SfxPoolItem *pItem;
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, FALSE, &pItem ) )
+ OutCSS1_SvxBrush( *this, *pItem, CSS1_BACKGROUND_TABLE, 0 );
+
+ if( IsHTMLMode( HTMLMODE_PRINT_EXT ) )
+ OutCSS1_SvxFmtBreak_SwFmtPDesc_SvxFmtKeep( *this, rItemSet, FALSE );
+
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_LAYOUT_SPLIT, FALSE, &pItem ) )
+ OutCSS1_SwFmtLayoutSplit( *this, *pItem );
+
+ if( !bFirstCSS1Property )
+ Strm() << '\"';
+}
+
+void SwHTMLWriter::OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt )
+{
+ SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
+ CSS1_OUTMODE_ENCODE|
+ CSS1_OUTMODE_SECTION );
+
+ const SfxPoolItem *pItem;
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, FALSE, &pItem ) )
+ OutCSS1_SvxBrush( *this, *pItem, CSS1_BACKGROUND_SECTION, 0 );
+
+ if( !bFirstCSS1Property )
+ Strm() << '\"';
+}
+
+static BOOL OutCSS1_FrmFmtBrush( SwHTMLWriter& rWrt,
+ const SvxBrushItem& rBrushItem )
+{
+ BOOL bWritten = FALSE;
+ if( rBrushItem.GetColor().GetTransparency() ||
+ 0 != rBrushItem.GetGraphicLink() ||
+ 0 != rBrushItem.GetGraphicPos() )
+ {
+ OutCSS1_SvxBrush( rWrt, rBrushItem, CSS1_BACKGROUND_FLY, 0 );
+ bWritten = TRUE;
+ }
+ return bWritten;
+}
+
+void SwHTMLWriter::OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt )
+{
+ // Wenn der Rahmen selbst einen Hintergrund hat, wird der ausgegeben.
+ if( OutCSS1_FrmFmtBrush( *this, rFrmFmt.GetBackground() ) )
+ return;
+
+ // Wenn der Rahmen nicht seitengebunden ist, wird sonst muss der
+ // Hintergrund vom Anker betrachtet
+ const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor();
+ RndStdIds eAnchorId = rAnchor.GetAnchorId();
+ const SwPosition *pAnchorPos = rAnchor.GetCntntAnchor();
+ if( FLY_PAGE != eAnchorId && pAnchorPos )
+ {
+ const SwNode& rNode = pAnchorPos->nNode.GetNode();
+ if( rNode.IsCntntNode() )
+ {
+ // Wenn der Rahmen in einem Content-Node verankert ist,
+ // wird der Hintergrund von Content-Node ausgegeben, wenn
+ // der einen hat.
+ if( OutCSS1_FrmFmtBrush( *this,
+ rNode.GetCntntNode()->GetSwAttrSet().GetBackground()) )
+ return;
+
+ // Sonst koennen wir evtl. auch in einer Tabelle stehen
+ const SwTableNode *pTableNd = rNode.FindTableNode();
+ if( pTableNd )
+ {
+ const SwStartNode *pBoxSttNd = rNode.FindTableBoxStartNode();
+ const SwTableBox *pBox =
+ pTableNd->GetTable().GetTblBox( pBoxSttNd->GetIndex() );
+
+ // Wenn die Box einen Hintergrund hat, nehmen wir den.
+ if( OutCSS1_FrmFmtBrush( *this,
+ pBox->GetFrmFmt()->GetBackground() ) )
+ return;
+
+ // Sonst betrachten wir den der Lines
+ const SwTableLine *pLine = pBox->GetUpper();
+ while( pLine )
+ {
+ if( OutCSS1_FrmFmtBrush( *this,
+ pLine->GetFrmFmt()->GetBackground() ) )
+ return;
+ pBox = pLine->GetUpper();
+ pLine = pBox ? pBox->GetUpper() : 0;
+ }
+
+ // Wenn da auch nichts war den der Tabelle.
+ if( OutCSS1_FrmFmtBrush( *this,
+ pTableNd->GetTable().GetFrmFmt()->GetBackground() ) )
+ return;
+ }
+
+ }
+
+ // Wenn der Anker wieder in einem Fly-Frame steht, dann
+ // wird der Hintergrund des Fly-Frames ausgegeben.
+ const SwFrmFmt *pFrmFmt = rNode.GetFlyFmt();
+ if( pFrmFmt )
+ {
+ OutCSS1_FrmFmtBackground( *pFrmFmt );
+ return;
+ }
+ }
+
+ // Schliesslich bleibt noch der Hintergrund der Seite uebrig und als
+ // letzte Rettung das Item der Config.
+ ASSERT( pCurrPageDesc, "Keine Seiten-Vorlage gemerkt" );
+ if( !OutCSS1_FrmFmtBrush( *this,
+ pCurrPageDesc->GetMaster().GetBackground() ) )
+ {
+ Color aColor( COL_WHITE );
+
+ // Die Hintergrund-Farbe wird normalerweise nur in Browse-Mode
+ // benutzt. Wir benutzen si bei einem HTML-Dokument immer und
+ // bei einem Text-Dokument nur, wenn es im Browse-Mode angezeigt
+ // wird.
+ if( pDoc->IsHTMLMode() || pDoc->IsBrowseMode() )
+ {
+ ViewShell *pVSh = 0;
+ pDoc->GetEditShell( &pVSh );
+ if ( pVSh &&
+ COL_TRANSPARENT != pVSh->GetViewOptions()->GetRetoucheColor().GetColor())
+ aColor = pVSh->GetViewOptions()->GetRetoucheColor().GetColor();
+ }
+
+ ByteString sOut;
+ GetCSS1Color( aColor, sOut );
+ OutCSS1_PropertyAscii( sCSS1_P_background, sOut );
+ }
+}
+
+//-----------------------------------------------------------------------
+
+static Writer& OutCSS1_SvxUnderl_SvxCrOut_SvxBlink( Writer& rWrt,
+ const SvxUnderlineItem *pUItem,
+ const SvxCrossedOutItem *pCOItem,
+ const SvxBlinkItem *pBItem )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const sal_Char *pUStr = 0;
+ if( pUItem )
+ {
+ switch( pUItem->GetUnderline() )
+ {
+ case UNDERLINE_NONE:
+ pUStr = sCSS1_PV_none;
+ break;
+ case UNDERLINE_DONTKNOW:
+ break;
+ default:
+ if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ {
+ // das geht auch in HTML und muss nicht als STYLE-Option
+ // und darf nicht als Hint geschrieben werden
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "Underline als Hint schreiben?" );
+ pUStr = sCSS1_PV_underline;
+ }
+ break;
+ }
+ }
+
+ const sal_Char *pCOStr = 0;
+ if( pCOItem )
+ {
+ switch( pCOItem->GetStrikeout() )
+ {
+ case STRIKEOUT_DONTKNOW:
+ break;
+ case STRIKEOUT_NONE:
+ if( !pUStr )
+ pUStr = sCSS1_PV_none;
+ break;
+ default:
+ if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ {
+ // das geht auch in HTML und muss nicht als STYLE-Option
+ // und darf nicht als Hint geschrieben werden
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "CrossedOut als Hint schreiben?" );
+ pCOStr = sCSS1_PV_line_through;
+ if( pUStr && sCSS1_PV_none == pUStr )
+ pUStr = 0;
+ }
+ break;
+ }
+ }
+
+ const sal_Char *pBStr = 0;
+ if( pBItem && rHTMLWrt.IsHTMLMode(HTMLMODE_BLINK) )
+ {
+ if( !pBItem->GetValue() )
+ {
+ if( !pUStr && !pCOStr )
+ pBStr = sCSS1_PV_none;
+ }
+ else if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ {
+ // das geht auch in HTML und muss nicht als STYLE-Option
+ // und darf nicht als Hint geschrieben werden
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "Blink als Hint schreiben?" );
+ pBStr = sCSS1_PV_blink;
+ if( pUStr && sCSS1_PV_none == pUStr )
+ pUStr = 0;
+ if( pCOStr && sCSS1_PV_none == pCOStr )
+ pCOStr = 0;
+ }
+ }
+
+ ByteString sOut;
+ if( pUStr )
+ sOut.Append( pUStr );
+
+ if( pCOStr )
+ {
+ if( sOut.Len() )
+ sOut += ' ';
+
+ sOut.Append( pCOStr );
+ }
+
+ if( pBStr )
+ {
+ if( sOut.Len() )
+ sOut += ' ';
+
+ sOut.Append( pBStr );
+ }
+
+ if( sOut.Len() )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sOut );
+
+ return rWrt;
+}
+
+
+static Writer& OutCSS1_SvxCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ if( !rHTMLWrt.IsHTMLMode(HTMLMODE_SMALL_CAPS) )
+ return rWrt;
+
+ const sal_Char *pStr = 0;
+ switch( ((const SvxCaseMapItem&)rHt).GetCaseMap() )
+ {
+ case SVX_CASEMAP_NOT_MAPPED: pStr = sCSS1_PV_normal; break;
+ case SVX_CASEMAP_KAPITAELCHEN: pStr = sCSS1_PV_small_caps; break;
+ }
+
+ if( pStr )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, pStr );
+
+ return rWrt;
+}
+
+
+static Writer& OutCSS1_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Farben muessen nicht in der Style-Option ausgegeben werden.
+ if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
+ !rHTMLWrt.bCfgPreferStyles )
+ return rWrt;
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "Farbe wirklich als Hint ausgeben?" );
+
+ const Color& rColor = ((const SvxColorItem&)rHt).GetValue();
+
+ ByteString sOut;
+ GetCSS1Color( rColor, sOut );
+
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_color, sOut );
+
+ return rWrt;
+}
+
+
+static Writer& OutCSS1_SvxCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ // Mit dieser Methode werden nur Hints ausgegeben!
+ // Sonst wird OutCSS1_SvxUnderl_SvxCrOut_SvxBlink() direkt aufgerufen.
+
+ if( ((SwHTMLWriter&)rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ OutCSS1_SvxUnderl_SvxCrOut_SvxBlink( rWrt, 0,
+ (const SvxCrossedOutItem *)&rHt, 0 );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Fonts muessen nicht in der Style-Option ausgegeben werden.
+ if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ return rWrt;
+
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "Font wirklich als Hint ausgeben?" );
+
+ String sOut;
+ // MS IE3b1 hat mit einfachen Haekchen Probleme
+ USHORT nMode = rHTMLWrt.nCSS1OutMode & CSS1_OUTMODE_ANY_ON;
+ sal_Unicode cQuote = nMode == CSS1_OUTMODE_RULE_ON ? '\"' : '\'';
+ SwHTMLWriter::PrepareFontList( ((const SvxFontItem&)rHt), sOut, cQuote,
+ TRUE );
+
+ rHTMLWrt.OutCSS1_Property( sCSS1_P_font_family, sOut );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Font-Hoehen muessen nicht in der Style-Option ausgegeben werden.
+ // Fuer Drop-Caps wird ein andewres font-size ausgegeben
+ if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
+ rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_DROPCAP ) )
+ return rWrt;
+
+ UINT32 nHeight = ((const SvxFontHeightItem&)rHt).GetHeight();
+ if( rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
+ {
+ // einen Hint nur dann ausgeben wenn es auch was bringt
+ USHORT nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
+ if( rHTMLWrt.aFontHeights[nSize-1] == nHeight )
+ return rWrt;
+ }
+ ByteString sHeight( ByteString::CreateFromInt32(
+ (sal_Int32)(nHeight/20) ) );
+ sHeight.Append( sCSS1_UNIT_pt );
+
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_size, sHeight );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const sal_Char *pStr = 0;
+ switch( ((const SvxPostureItem&)rHt).GetPosture() )
+ {
+ case ITALIC_NONE: pStr = sCSS1_PV_normal; break;
+ case ITALIC_OBLIQUE: pStr = sCSS1_PV_oblique; break;
+ case ITALIC_NORMAL:
+ if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ {
+ // das geht auch in HTML und muss nicht als STYLE-Option
+ // und darf nicht als Hint geschrieben werden
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "Italic als Hint schreiben?" );
+ pStr = sCSS1_PV_italic;
+ }
+ break;
+ }
+
+ if( pStr )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_style, pStr );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxKerning( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Kerning-Item nur ausgeben, wenn volle Style-Untersttzung da ist
+ if( !rHTMLWrt.IsHTMLMode(HTMLMODE_FULL_STYLES) )
+ return rWrt;
+
+ INT16 nValue = ((const SvxKerningItem&)rHt).GetValue();
+ if( nValue )
+ {
+ ByteString sOut;
+ if( nValue < 0 )
+ {
+ sOut = '-';
+ nValue = -nValue;
+ }
+
+ // Breite als n.n pt
+ nValue = (nValue + 1) / 2; // 1/10pt
+ sOut.Append( ByteString::CreateFromInt32( (sal_Int32)(nValue / 10) ) );
+ sOut.Append( '.' );
+ sOut.Append( ByteString::CreateFromInt32( (sal_Int32)(nValue % 10) ) );
+ sOut.Append( sCSS1_UNIT_pt );
+
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_letter_spacing, sOut );
+ }
+ else
+ {
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_letter_spacing,
+ sCSS1_PV_normal );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxUnderline( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ // Mit dieser Methode werden nur Hints ausgegeben!
+ // Sonst wird OutCSS1_SvxUnderl_SvxCrOut_SvxBlink() direkt aufgerufen.
+
+ if( ((SwHTMLWriter&)rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ OutCSS1_SvxUnderl_SvxCrOut_SvxBlink( rWrt,
+ (const SvxUnderlineItem *)&rHt, 0, 0 );
+
+ return rWrt;
+}
+
+
+static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const sal_Char *pStr = 0;
+ switch( ((const SvxWeightItem&)rHt).GetWeight() )
+ {
+ case WEIGHT_ULTRALIGHT: pStr = sCSS1_PV_extra_light; break;
+ case WEIGHT_LIGHT: pStr = sCSS1_PV_light; break;
+ case WEIGHT_SEMILIGHT: pStr = sCSS1_PV_demi_light; break;
+ case WEIGHT_NORMAL: pStr = sCSS1_PV_medium; break;
+ case WEIGHT_SEMIBOLD: pStr = sCSS1_PV_demi_bold; break;
+ case WEIGHT_BOLD:
+ if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ {
+ // das geht auch in HTML und muss nicht als STYLE-Option
+ // und darf nicht als Hint geschrieben werden
+ ASSERT( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
+ "Fett als Hint schreiben?" );
+ pStr = sCSS1_PV_bold;
+ }
+ break;
+ case WEIGHT_ULTRABOLD: pStr = sCSS1_PV_extra_bold; break;
+ }
+
+ if( pStr )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_weight, pStr );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxBlink( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ // Mit dieser Methode werden nur Hints ausgegeben!
+ // Sonst wird OutCSS1_SvxUnderl_SvxCrOut_SvxBlink() direkt aufgerufen.
+
+ if( ((SwHTMLWriter&)rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
+ OutCSS1_SvxUnderl_SvxCrOut_SvxBlink( rWrt,
+ 0, 0, (const SvxBlinkItem *)&rHt );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // #60393#: Netscape4 hat massive Probleme mit den Zellenhoehen
+ // wenn der Zeilenabstand innerhalb einer Tabelle geaendert wird
+ // und die Breite der Tabelle nicht automatisch berechnet wird
+ // (also wenn eine WIDTH-Option vorhanden ist).
+ if( rHTMLWrt.bOutTable && rHTMLWrt.bCfgNetscape4 )
+ return rWrt;
+
+ const SvxLineSpacingItem& rLSItem = (const SvxLineSpacingItem&)rHt;
+
+ USHORT nHeight = 0;
+ USHORT nPrcHeight = 0;
+ SvxLineSpace eLineSpace = rLSItem.GetLineSpaceRule();
+ switch( rLSItem.GetInterLineSpaceRule() )
+ {
+ case SVX_INTER_LINE_SPACE_OFF:
+ case SVX_INTER_LINE_SPACE_FIX:
+ {
+ switch( eLineSpace )
+ {
+ case SVX_LINE_SPACE_MIN:
+ case SVX_LINE_SPACE_FIX:
+ nHeight = rLSItem.GetLineHeight();
+ break;
+ case SVX_LINE_SPACE_AUTO:
+ nPrcHeight = 100;
+ break;
+ }
+ }
+ break;
+ case SVX_INTER_LINE_SPACE_PROP:
+ nPrcHeight = rLSItem.GetPropLineSpace();
+ break;
+ }
+
+ if( nHeight )
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_line_height, (long)nHeight );
+ else if( nPrcHeight )
+ {
+ ByteString sHeight(
+ ByteString::CreateFromInt32( (sal_Int32)nPrcHeight ) );
+ sHeight += '%';
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_line_height, sHeight );
+ }
+
+ return rWrt;
+
+}
+
+static Writer& OutCSS1_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Alignment in Style-Option nur ausgeben, wenn das Tag kein
+ // ALIGN=xxx zulaesst
+ if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
+ !rHTMLWrt.bNoAlign)
+ return rWrt;
+
+ const sal_Char* pStr = 0;
+ switch( ((const SvxAdjustItem&)rHt).GetAdjust() )
+ {
+ case SVX_ADJUST_LEFT: pStr = sCSS1_PV_left; break;
+ case SVX_ADJUST_RIGHT: pStr = sCSS1_PV_right; break;
+ case SVX_ADJUST_BLOCK: pStr = sCSS1_PV_justify; break;
+ case SVX_ADJUST_CENTER: pStr = sCSS1_PV_center; break;
+ }
+
+ if( pStr )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_align, pStr );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxFmtSplit( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const sal_Char *pStr = ((const SvxFmtSplitItem&)rHt).GetValue()
+ ? sCSS1_PV_auto
+ : sCSS1_PV_avoid;
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SwFmtLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const sal_Char *pStr = ((const SwFmtLayoutSplit&)rHt).GetValue()
+ ? sCSS1_PV_auto
+ : sCSS1_PV_avoid;
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxWidows( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ ByteString aStr(
+ ByteString::CreateFromInt32( ((const SvxWidowsItem&)rHt).GetValue() ) );
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_widows, aStr );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxOrphans( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ ByteString aStr(
+ ByteString::CreateFromInt32( ((const SvxOrphansItem&)rHt).GetValue() ) );
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_orphans, aStr );
+
+ return rWrt;
+}
+
+static void OutCSS1_SwFmtDropAttrs( SwHTMLWriter& rHWrt,
+ const SwFmtDrop& rDrop )
+{
+ // Text fliesst rechts drumrum
+ rHWrt.OutCSS1_PropertyAscii( sCSS1_P_float, sCSS1_PV_left );
+
+ // Anzahl der Zeilen -> %-Angabe fuer Font-Hoehe!
+ ByteString sOut( ByteString::CreateFromInt32( rDrop.GetLines()*100 ) );
+ sOut += '%';
+ rHWrt.OutCSS1_PropertyAscii( sCSS1_P_font_size, sOut );
+
+ // Abstand zum Text = rechter Rand
+ USHORT nDistance = rDrop.GetDistance();
+ if( nDistance > 0 )
+ rHWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, nDistance );
+
+ const SwCharFmt *pDCCharFmt = rDrop.GetCharFmt();
+ if( pDCCharFmt )
+ rHWrt.OutCSS1_SfxItemSet( pDCCharFmt->GetAttrSet() );
+}
+
+static Writer& OutCSS1_SwFmtDrop( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // nie als Option eines Absatzes ausgeben, sondern nur als Hints
+ if( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
+ return rWrt;
+
+ if( rHTMLWrt.bTagOn )
+ {
+ SwCSS1OutMode aMode( rHTMLWrt,
+ CSS1_OUTMODE_SPAN_TAG1_ON|CSS1_OUTMODE_ENCODE|
+ CSS1_OUTMODE_DROPCAP );
+
+ OutCSS1_SwFmtDropAttrs( rHTMLWrt, (const SwFmtDrop&)rHt );
+ // Ein "> wird schon vom aufrufenden OutCSS1_HintAsSpanTag geschrieben.
+ }
+ else
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_span, FALSE );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SwFmtFrmSize( Writer& rWrt, const SfxPoolItem& rHt,
+ USHORT nMode )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ ByteString sOut;
+ const SwFmtFrmSize& rFSItem = (const SwFmtFrmSize&)rHt;
+
+ if( nMode & CSS1_FRMSIZE_WIDTH )
+ {
+ BYTE nPrcWidth = rFSItem.GetWidthPercent();
+ if( nPrcWidth )
+ {
+ (sOut = ByteString::CreateFromInt32( nPrcWidth) ) += '%';
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_width, sOut );
+ }
+ else if( nMode & CSS1_FRMSIZE_PIXEL )
+ {
+ rHTMLWrt.OutCSS1_PixelProperty( sCSS1_P_width,
+ rFSItem.GetSize().Width(), FALSE );
+ }
+ else
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_width,
+ rFSItem.GetSize().Width() );
+ }
+ }
+
+ if( nMode & CSS1_FRMSIZE_ANYHEIGHT )
+ {
+ BOOL bOutHeight = FALSE;
+ switch( rFSItem.GetSizeType() )
+ {
+ case ATT_FIX_SIZE:
+ bOutHeight = (nMode & CSS1_FRMSIZE_FIXHEIGHT) != 0;
+ break;
+ case ATT_MIN_SIZE:
+ bOutHeight = (nMode & CSS1_FRMSIZE_MINHEIGHT) != 0;
+ break;
+ case ATT_VAR_SIZE:
+ bOutHeight = (nMode & CSS1_FRMSIZE_VARHEIGHT) != 0;
+ break;
+ default:
+ ASSERT( bOutHeight, "Hoehe wird nicht exportiert" );
+ break;
+ }
+
+ if( bOutHeight )
+ {
+ BYTE nPrcHeight = rFSItem.GetHeightPercent();
+ if( nPrcHeight )
+ {
+ (sOut = ByteString::CreateFromInt32( nPrcHeight ) ) += '%';
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_height, sOut );
+ }
+ else if( nMode & CSS1_FRMSIZE_PIXEL )
+ {
+ rHTMLWrt.OutCSS1_PixelProperty( sCSS1_P_height,
+ rFSItem.GetSize().Width(),
+ TRUE );
+ }
+ else
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_height,
+ rFSItem.GetSize().Height() );
+ }
+ }
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&)rHt;
+
+ // Der Export der harten Attributierung ist unnoetig, wenn die
+ // neuen Werte denen der aktuellen Vorlage entsprechen
+
+ // Einen linken Rand kann es durch eine Liste bereits in der
+ // Umgebung geben
+ long nLeftMargin = (long)rLRItem.GetTxtLeft() - rHTMLWrt.nLeftMargin;
+ if( rHTMLWrt.nDfltLeftMargin != nLeftMargin )
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLeftMargin );
+ }
+
+ if( rHTMLWrt.nDfltRightMargin != rLRItem.GetRight() )
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right,
+ (long)rLRItem.GetRight() );
+ }
+
+ // Der Erstzeilen-Einzug kann den Platz fuer eine Numerierung
+ // enthalten
+ long nFirstLineIndent = (long)rLRItem.GetTxtFirstLineOfst() -
+ rHTMLWrt.nFirstLineIndent;
+ if( rHTMLWrt.nDfltFirstLineIndent != nFirstLineIndent )
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent,
+ nFirstLineIndent );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)rHt;
+
+ if( rHTMLWrt.nDfltTopMargin != rULItem.GetUpper() )
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_top,
+ (long)rULItem.GetUpper() );
+ }
+
+ if( rHTMLWrt.nDfltBottomMargin != rULItem.GetLower() )
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_bottom,
+ (long)rULItem.GetLower() );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+ const SvxULSpaceItem *pULItem,
+ const SvxLRSpaceItem *pLRItem )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ if( pLRItem && pULItem &&
+ pLRItem->GetLeft() == pLRItem->GetRight() &&
+ pLRItem->GetLeft() == pULItem->GetUpper() &&
+ pLRItem->GetLeft() == pULItem->GetLower() &&
+ pLRItem->GetLeft() != rHTMLWrt.nDfltLeftMargin &&
+ pLRItem->GetRight() != rHTMLWrt.nDfltRightMargin &&
+ pULItem->GetUpper() != rHTMLWrt.nDfltTopMargin &&
+ pULItem->GetLower() != rHTMLWrt.nDfltBottomMargin )
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin, (long)pLRItem->GetLeft() );
+ }
+ else
+ {
+ if( pLRItem )
+ OutCSS1_SvxLRSpace( rWrt, *pLRItem );
+ if( pULItem )
+ OutCSS1_SvxULSpace( rWrt, *pULItem );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
+ const SfxItemSet& rItemSet,
+ BOOL bDeep )
+{
+ const SvxULSpaceItem *pULSpace = 0;
+ const SvxLRSpaceItem *pLRSpace = 0;
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_LR_SPACE, bDeep, &pItem ) )
+ pLRSpace = (const SvxLRSpaceItem *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_UL_SPACE, bDeep, &pItem ) )
+ pULSpace = (const SvxULSpaceItem *)pItem;
+
+ if( pLRSpace || pULSpace )
+ OutCSS1_SvxULSpace_SvxLRSpace( rWrt, pULSpace, pLRSpace );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxFmtBreak_SwFmtPDesc_SvxFmtKeep( Writer& rWrt,
+ const SvxFmtBreakItem *pBreakItem,
+ const SwFmtPageDesc *pPDescItem,
+ const SvxFmtKeepItem *pKeepItem )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ if( !rHTMLWrt.IsHTMLMode(HTMLMODE_PRINT_EXT) )
+ return rWrt;
+
+ const sal_Char *pBreakBefore = 0;
+ const sal_Char *pBreakAfter = 0;
+
+ if( pKeepItem )
+ {
+ pBreakAfter = pKeepItem->GetValue() ? sCSS1_PV_avoid : sCSS1_PV_auto;
+ }
+ if( pBreakItem )
+ {
+ switch( pBreakItem->GetBreak() )
+ {
+ case SVX_BREAK_NONE:
+ pBreakBefore = sCSS1_PV_auto;
+ if( !pBreakAfter )
+ pBreakAfter = sCSS1_PV_auto;
+ break;
+
+ case SVX_BREAK_PAGE_BEFORE:
+ pBreakBefore = sCSS1_PV_always;
+ break;
+
+ case SVX_BREAK_PAGE_AFTER:
+ pBreakAfter= sCSS1_PV_always;
+ break;
+ }
+ }
+ if( pPDescItem )
+ {
+ const SwPageDesc *pPDesc = pPDescItem->GetPageDesc();
+ if( pPDesc )
+ {
+ switch( pPDesc->GetPoolFmtId() )
+ {
+ case RES_POOLPAGE_LEFT: pBreakBefore = sCSS1_PV_left; break;
+ case RES_POOLPAGE_RIGHT: pBreakBefore = sCSS1_PV_right; break;
+ default: pBreakBefore = sCSS1_PV_always; break;
+ }
+ }
+ else if( !pBreakBefore )
+ {
+ pBreakBefore = sCSS1_PV_auto;
+ }
+ }
+
+ if( pBreakBefore )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_before,
+ pBreakBefore );
+ if( pBreakAfter )
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_after,
+ pBreakAfter );
+
+ return rWrt;
+}
+
+static Writer& OutCSS1_SvxFmtBreak_SwFmtPDesc_SvxFmtKeep( Writer& rWrt,
+ const SfxItemSet& rItemSet,
+ BOOL bDeep )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ const SfxPoolItem *pItem;
+ const SvxFmtBreakItem *pBreakItem = 0;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BREAK, bDeep, &pItem ))
+ pBreakItem = (const SvxFmtBreakItem *)pItem;
+
+ const SwFmtPageDesc *pPDescItem = 0;
+ if( ( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
+ !rHTMLWrt.bCSS1IgnoreFirstPageDesc ||
+ rHTMLWrt.pStartNdIdx->GetIndex() !=
+ rHTMLWrt.pCurPam->GetPoint()->nNode.GetIndex() ) &&
+ SFX_ITEM_SET==rItemSet.GetItemState( RES_PAGEDESC, bDeep, &pItem ))
+ pPDescItem = (const SwFmtPageDesc*)pItem;
+
+ const SvxFmtKeepItem *pKeepItem = 0;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_KEEP, bDeep, &pItem ))
+ pKeepItem = (const SvxFmtKeepItem *)pItem;
+
+ if( pBreakItem || pPDescItem || pKeepItem )
+ OutCSS1_SvxFmtBreak_SwFmtPDesc_SvxFmtKeep( rWrt, pBreakItem,
+ pPDescItem, pKeepItem );
+
+ return rWrt;
+}
+
+// Wrapper fuer OutCSS1_SfxItemSet etc.
+static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Absatz-Hintergruende werden nur fuer den SW ausgegeben
+ if( rHt.Which() < RES_CHRATR_END ||
+ rHTMLWrt.IsHTMLMode(HTMLMODE_FULL_STYLES) )
+ OutCSS1_SvxBrush( rWrt, rHt, CSS1_BACKGROUND_ATTR, 0 );
+
+ return rWrt;
+}
+
+
+static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
+ USHORT nMode, const String *pGrfName )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Das Zeichen-Attribut wird nicht ausgegeben, wenn gerade
+ // Optionen ausgegeben werden
+ if( rHt.Which() < RES_CHRATR_END &&
+ rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
+ return rWrt;
+
+ // Erstmal ein par Werte holen
+// const Brush &rBrush = ((const SvxBrushItem &)rHt).GetBrush();
+ const Color & rColor = ((const SvxBrushItem &)rHt).GetColor();
+ const String *pLink = pGrfName ? pGrfName
+ : ((const SvxBrushItem &)rHt).GetGraphicLink();
+ SvxGraphicPosition ePos = ((const SvxBrushItem &)rHt).GetGraphicPos();
+
+ if( CSS1_BACKGROUND_PAGE==nMode )
+ {
+ // Fuer Seitenvorlagen wurde der Grafik-Name uebergeben. Es wird
+ // nur ein Attribut ausgegeben, wenn die Grafik nicht gekachelt ist.
+ ASSERT( pLink, "Wo ist der Grafik-Name der Seitenvorlage?" );
+ if( !pLink || !pLink->Len() || GPOS_TILED==ePos )
+ return rWrt;
+ }
+
+ // Erstmal die Farbe holen
+ BOOL bColor = FALSE;
+ BOOL bTransparent = rColor.GetTransparency() > 0;
+ Color aColor;
+ if( !bTransparent )
+ {
+ aColor = rColor;
+ bColor = TRUE;
+ }
+
+ // und jetzt eine Grafik
+ String sGrfNm;
+
+ if( !pLink )
+ {
+ // embeddete Grafik -> WriteEmbedded schreiben
+ const Graphic* pGrf = ((const SvxBrushItem &)rHt).GetGraphic();
+ if( pGrf )
+ {
+ // Grafik als (JPG-)File speichern
+ const String* pTempFileName = rHTMLWrt.GetOrigFileName();
+ if(pTempFileName)
+ sGrfNm = *pTempFileName;
+ USHORT nErr = XOutBitmap::WriteGraphic( *pGrf, sGrfNm,
+ String::CreateFromAscii("JPG") );
+ if( !nErr ) // fehlerhaft, da ist nichts auszugeben
+ {
+ sGrfNm = URIHelper::SmartRelToAbs( sGrfNm );
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( sGrfNm );
+ pLink = &sGrfNm;
+ }
+ else
+ {
+ rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
+ }
+ }
+ }
+ else if( !pGrfName && (rHTMLWrt.bCfgCpyLinkedGrfs || rHTMLWrt.HasCId()) )
+ {
+ sGrfNm = *pLink;
+ rWrt.CopyLocalFileToINet( sGrfNm, rHTMLWrt.HasCId() );
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( sGrfNm );
+ pLink = &sGrfNm;
+ }
+
+ // In Tabellen wird nur dann etwas exportiert, wenn eine Grafik
+ // existiert.
+ if( CSS1_BACKGROUND_TABLE==nMode && !pLink )
+ return rWrt;
+
+ // ggf. noch die Ausrichtung der Grafik
+ const sal_Char *pRepeat = 0, *pHori = 0, *pVert = 0;
+ if( pLink )
+ {
+ if( GPOS_TILED==ePos )
+ {
+ pRepeat = sCSS1_PV_repeat;
+ }
+ else
+ {
+ switch( ePos )
+ {
+ case GPOS_LT:
+ case GPOS_MT:
+ case GPOS_RT:
+ pHori = sCSS1_PV_top;
+ break;
+
+ case GPOS_LM:
+ case GPOS_MM:
+ case GPOS_RM:
+ pHori = sCSS1_PV_middle;
+ break;
+
+ case GPOS_LB:
+ case GPOS_MB:
+ case GPOS_RB:
+ pHori = sCSS1_PV_bottom;
+ break;
+ }
+
+ switch( ePos )
+ {
+ case GPOS_LT:
+ case GPOS_LM:
+ case GPOS_LB:
+ pVert = sCSS1_PV_left;
+ break;
+
+ case GPOS_MT:
+ case GPOS_MM:
+ case GPOS_MB:
+ pVert = sCSS1_PV_center;
+ break;
+
+ case GPOS_RT:
+ case GPOS_RM:
+ case GPOS_RB:
+ pVert = sCSS1_PV_right;
+ break;
+ }
+
+ if( pHori || pVert )
+ pRepeat = sCSS1_PV_no_repeat;
+ }
+ }
+
+ // jetzt den String zusammen bauen
+ String sOut;
+ if( !pLink && !bColor )
+ {
+ // keine Farbe und kein Link, aber ein transparenter Brush
+ if( bTransparent && CSS1_BACKGROUND_FLY != nMode )
+ sOut.AssignAscii( sCSS1_PV_transparent );
+ }
+ else
+ {
+ if( bColor )
+ {
+ ByteString sTmp;
+ GetCSS1Color( aColor, sTmp );
+ sOut += String( sTmp, RTL_TEXTENCODING_ASCII_US );
+ }
+
+ if( pLink )
+ {
+ if( bColor )
+ sOut += ' ';
+
+ sOut.AppendAscii( sCSS1_url );
+ sOut.Append( '(' );
+ sOut.Append( INetURLObject::AbsToRel( *pLink,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET ));
+ sOut.Append( ')' );
+
+ if( pRepeat )
+ {
+ sOut.Append( ' ' );
+ sOut.AppendAscii( pRepeat );
+ }
+
+ if( pHori )
+ {
+ sOut.Append( ' ' );
+ sOut.AppendAscii( pHori );
+ }
+ if( pVert )
+ {
+ sOut.Append( ' ' );
+ sOut.AppendAscii( pVert );
+ }
+
+ sOut.Append( ' ' );
+ sOut.AppendAscii( sCSS1_PV_scroll );
+ }
+ }
+
+ if( sOut.Len() )
+ rHTMLWrt.OutCSS1_Property( sCSS1_P_background, sOut );
+
+ return rWrt;
+}
+
+static void OutCSS1_SvxBorderLine( SwHTMLWriter& rHTMLWrt,
+ const sal_Char *pProperty,
+ const SvxBorderLine *pLine )
+{
+ if( !pLine )
+ {
+ rHTMLWrt.OutCSS1_PropertyAscii( pProperty, sCSS1_PV_none );
+ return;
+ }
+
+ BOOL bDouble = FALSE;
+ USHORT nWidth = pLine->GetOutWidth();
+ if( pLine->GetInWidth() )
+ {
+ nWidth += pLine->GetDistance();
+ nWidth += pLine->GetInWidth();
+ bDouble = TRUE;
+ }
+
+ ByteString sOut;
+ if( Application::GetDefaultDevice() &&
+ nWidth <= Application::GetDefaultDevice()->PixelToLogic(
+ Size( 1, 1 ), MapMode( MAP_TWIP) ).Width() )
+ {
+ // Wenn die Breite kleiner ist als ein Pixel, dann als 1px
+ // ausgeben, damit Netscape und IE die Linie auch darstellen.
+ sOut += "1px";
+ }
+ else
+ {
+#ifdef USE_MAPMODE_MM100
+ nWidth = (USHORT)((double)nWidth * (25.4/72)); // 1/100pt
+#else
+ nWidth *= 5; // 1/100pt
+#endif
+
+ // Breite als n.nn pt
+ sOut += ByteString::CreateFromInt32( nWidth / 100 );
+ (((sOut += '.')
+ += ByteString::CreateFromInt32((nWidth/10) % 10))
+ += ByteString::CreateFromInt32(nWidth % 10)) += sCSS1_UNIT_pt;
+ }
+
+ // Linien-Stil: solid oder double
+ ((sOut += ' ')
+ += (bDouble ? sCSS1_PV_double : sCSS1_PV_solid)) += ' ';
+
+ // und noch die Farbe
+ GetCSS1Color( pLine->GetColor(), sOut );
+
+ rHTMLWrt.OutCSS1_PropertyAscii( pProperty, sOut );
+}
+
+static Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Das Zeichen-Attribut wird nicht ausgegeben, wenn gerade
+ // Optionen ausgegeben werden
+ if( !rHTMLWrt.IsHTMLMode(HTMLMODE_PARA_BORDER))
+ return rWrt;
+
+ const SvxBoxItem& rBoxItem = (const SvxBoxItem&)rHt;
+ const SvxBorderLine *pTop = rBoxItem.GetTop();
+ const SvxBorderLine *pBottom = rBoxItem.GetBottom();
+ const SvxBorderLine *pLeft = rBoxItem.GetLeft();
+ const SvxBorderLine *pRight = rBoxItem.GetRight();
+
+ if( (pTop && pBottom && pLeft && pRight &&
+ *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) ||
+ (!pTop && !pBottom && !pLeft && !pRight) )
+ {
+ // alle Linien gesetzt und gleich oder alle Linien nicht gesetzt
+ // => border : ...
+ OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border, pTop );
+ }
+ else
+ {
+ // sonst alle Linien individuell ausgeben
+ OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_top, pTop );
+ OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_bottom, pBottom );
+ OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_left, pLeft );
+ OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_right, pRight );
+ }
+
+ long nTopDist = pTop ? rBoxItem.GetDistance( BOX_LINE_TOP ) : 0;
+ long nBottomDist = pBottom ? rBoxItem.GetDistance( BOX_LINE_BOTTOM ) : 0;
+ long nLeftDist = pLeft ? rBoxItem.GetDistance( BOX_LINE_LEFT ) : 0;
+ long nRightDist = pRight ? rBoxItem.GetDistance( BOX_LINE_RIGHT ) : 0;
+
+ if( nTopDist == nBottomDist && nLeftDist == nRightDist )
+ {
+ ByteString sVal;
+ AddUnitPropertyValue( nTopDist, rHTMLWrt.GetCSS1Unit(), sVal );
+ if( nTopDist != nLeftDist )
+ {
+ sVal += ' ';
+ AddUnitPropertyValue( nLeftDist, rHTMLWrt.GetCSS1Unit(), sVal );
+ }
+ rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_padding, sVal );
+ }
+ else
+ {
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_top, nTopDist );
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_bottom, nBottomDist );
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_left, nLeftDist );
+ rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_right, nRightDist );
+ }
+
+ return rWrt;
+}
+
+/*
+ * lege hier die Tabellen fuer die HTML-Funktions-Pointer auf
+ * die Ausgabe-Funktionen an.
+ * Es sind lokale Strukturen, die nur innerhalb der HTML-DLL
+ * bekannt sein muessen.
+ */
+
+
+SwAttrFnTab aCSS1AttrFnTab = {
+/* RES_CHRATR_CASEMAP */ OutCSS1_SvxCaseMap,
+/* RES_CHRATR_CHARSETCOLOR */ 0,
+/* RES_CHRATR_COLOR */ OutCSS1_SvxColor,
+/* RES_CHRATR_CONTOUR */ 0,
+/* RES_CHRATR_CROSSEDOUT */ OutCSS1_SvxCrossedOut,
+/* RES_CHRATR_ESCAPEMENT */ 0,
+/* RES_CHRATR_FONT */ OutCSS1_SvxFont,
+/* RES_CHRATR_FONTSIZE */ OutCSS1_SvxFontHeight,
+/* RES_CHRATR_KERNING */ OutCSS1_SvxKerning,
+/* RES_CHRATR_LANGUAGE */ 0,
+/* RES_CHRATR_POSTURE */ OutCSS1_SvxPosture,
+/* RES_CHRATR_PROPORTIONALFONTSIZE*/0,
+/* RES_CHRATR_SHADOWED */ 0,
+/* RES_CHRATR_UNDERLINE */ OutCSS1_SvxUnderline,
+/* RES_CHRATR_WEIGHT */ OutCSS1_SvxFontWeight,
+/* RES_CHRATR_WORDLINEMODE */ 0,
+/* RES_CHRATR_AUTOKERN */ 0,
+/* RES_CHRATR_BLINK */ OutCSS1_SvxBlink,
+/* RES_CHRATR_NOHYPHEN */ 0, // Neu: nicht trennen
+/* RES_CHRATR_NOLINEBREAK */ 0, // Neu: nicht umbrechen
+/* RES_CHRATR_BACKGROUND */ OutCSS1_SvxBrush, // Neu: Zeichenhintergrund
+/* RES_CHRATR_CJK_FONT */ 0,
+/* RES_CHRATR_CJK_FONTSIZE */ 0,
+/* RES_CHRATR_CJK_LANGUAGE */ 0,
+/* RES_CHRATR_CJK_POSTURE */ 0,
+/* RES_CHRATR_CJK_WEIGHT */ 0,
+/* RES_CHRATR_CTL_FONT */ 0,
+/* RES_CHRATR_CTL_FONTSIZE */ 0,
+/* RES_CHRATR_CTL_LANGUAGE */ 0,
+/* RES_CHRATR_CTL_POSTURE */ 0,
+/* RES_CHRATR_CTL_WEIGHT */ 0,
+/* RES_CHRATR_WRITING_DIRECTION */ 0,
+/* RES_CHRATR_DUMMY2 */ 0,
+/* RES_CHRATR_DUMMY3 */ 0,
+/* RES_CHRATR_DUMMY4 */ 0,
+/* RES_CHRATR_DUMMY5 */ 0,
+/* RES_CHRATR_DUMMY1 */ 0, // Dummy:
+
+/* RES_TXTATR_NOLINEBREAK */ 0,
+/* RES_TXTATR_NOHYPHEN */ 0,
+/* RES_TXTATR_REFMARK*/ 0,
+/* RES_TXTATR_TOXMARK */ 0,
+/* RES_TXTATR_CHARFMT */ 0,
+/* RES_TXTATR_TWO_LINES */ 0,
+/* RES_TXTATR_CJK_RUBY */ 0,
+/* RES_TXTATR_UNKNOWN_CONTAINER */ 0,
+/* RES_TXTATR_DUMMY5 */ 0,
+/* RES_TXTATR_DUMMY6 */ 0,
+
+/* RES_TXTATR_FIELD */ 0,
+/* RES_TXTATR_FLYCNT */ 0,
+/* RES_TXTATR_FTN */ 0,
+/* RES_TXTATR_SOFTHYPH */ 0,
+/* RES_TXTATR_HARDBLANK*/ 0,
+/* RES_TXTATR_DUMMY1 */ 0, // Dummy:
+/* RES_TXTATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_PARATR_LINESPACING */ OutCSS1_SvxLineSpacing,
+/* RES_PARATR_ADJUST */ OutCSS1_SvxAdjust,
+/* RES_PARATR_SPLIT */ OutCSS1_SvxFmtSplit,
+/* RES_PARATR_WIDOWS */ OutCSS1_SvxWidows,
+/* RES_PARATR_ORPHANS */ OutCSS1_SvxOrphans,
+/* RES_PARATR_TABSTOP */ 0,
+/* RES_PARATR_HYPHENZONE*/ 0,
+/* RES_PARATR_DROP */ OutCSS1_SwFmtDrop,
+/* RES_PARATR_REGISTER */ 0, // neu: Registerhaltigkeit
+/* RES_PARATR_DUMMY1 */ 0, // Dummy:
+/* RES_PARATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_FILL_ORDER */ 0,
+/* RES_FRM_SIZE */ 0,
+/* RES_PAPER_BIN */ 0,
+/* RES_LR_SPACE */ OutCSS1_SvxLRSpace,
+/* RES_UL_SPACE */ OutCSS1_SvxULSpace,
+/* RES_PAGEDESC */ 0,
+/* RES_BREAK */ 0,
+/* RES_CNTNT */ 0,
+/* RES_HEADER */ 0,
+/* RES_FOOTER */ 0,
+/* RES_PRINT */ 0,
+/* RES_OPAQUE */ 0,
+/* RES_PROTECT */ 0,
+/* RES_SURROUND */ 0,
+/* RES_VERT_ORIENT */ 0,
+/* RES_HORI_ORIENT */ 0,
+/* RES_ANCHOR */ 0,
+/* RES_BACKGROUND */ OutCSS1_SvxBrush,
+/* RES_BOX */ OutCSS1_SvxBox,
+/* RES_SHADOW */ 0,
+/* RES_FRMMACRO */ 0,
+/* RES_COL */ 0,
+/* RES_KEEP */ 0,
+/* RES_URL */ 0,
+/* RES_EDIT_IN_READONLY */ 0,
+/* RES_LAYOUT_SPLIT */ 0,
+/* RES_FRMATR_DUMMY1 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY2 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY3 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY4 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY5 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY6 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY7 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY8 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY9 */ 0, // Dummy:
+
+/* RES_GRFATR_MIRRORGRF */ 0,
+/* RES_GRFATR_CROPGRF */ 0,
+/* RES_GRFATR_ROTATION */ 0,
+/* RES_GRFATR_LUMINANCE */ 0,
+/* RES_GRFATR_CONTRAST */ 0,
+/* RES_GRFATR_CHANNELR */ 0,
+/* RES_GRFATR_CHANNELG */ 0,
+/* RES_GRFATR_CHANNELB */ 0,
+/* RES_GRFATR_GAMMA */ 0,
+/* RES_GRFATR_INVERT */ 0,
+/* RES_GRFATR_TRANSPARENCY */ 0,
+/* RES_GRFATR_DRWAMODE */ 0,
+/* RES_GRFATR_DUMMY1 */ 0,
+/* RES_GRFATR_DUMMY2 */ 0,
+/* RES_GRFATR_DUMMY3 */ 0,
+/* RES_GRFATR_DUMMY4 */ 0,
+/* RES_GRFATR_DUMMY5 */ 0,
+
+/* RES_BOXATR_FORMAT */ 0,
+/* RES_BOXATR_FORMULA */ 0,
+/* RES_BOXATR_VALUE */ 0
+};
+
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.110 2000/09/18 16:04:42 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.109 2000/08/30 16:46:22 jp
+ use CharClass instead of international
+
+ Revision 1.108 2000/08/18 13:03:06 jp
+ don't export escaped URLs
+
+ Revision 1.107 2000/07/31 19:24:15 jp
+ new attributes for CJK/CTL and graphic
+
+ Revision 1.106 2000/06/26 12:55:05 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.105 2000/06/26 09:51:49 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.104 2000/05/15 10:06:56 os
+ Chg: GetOrigFileName()
+
+ Revision 1.103 2000/04/28 14:29:10 mib
+ unicode
+
+ Revision 1.102 2000/04/10 12:20:54 mib
+ unicode
+
+ Revision 1.101 2000/03/03 15:21:00 os
+ StarView remainders removed
+
+ Revision 1.100 2000/02/11 14:36:48 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.99 1999/09/21 09:48:39 mib
+ multiple text encodings
+
+ Revision 1.98 1999/09/20 13:16:17 mib
+ COL_WINDOWWORKSPACE->COL-WHITE
+
+ Revision 1.97 1999/07/23 13:34:28 MIB
+ #67578#: Export multicolumned sections as <MULTICOL>, section backgrounds
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/css1kywd.cxx b/sw/source/filter/html/css1kywd.cxx
new file mode 100644
index 000000000000..7a115b661ee3
--- /dev/null
+++ b/sw/source/filter/html/css1kywd.cxx
@@ -0,0 +1,400 @@
+/*************************************************************************
+ *
+ * $RCSfile: css1kywd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "css1kywd.hxx"
+
+/* */
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS_mimetype, "text/css" );
+
+/* */
+
+// ein par allgemeine Strings
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_import, "import" );
+
+// Feature: PrintExt
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_page, "page" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_media, "media" );
+// /Feature: PrintExt
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_important, "important" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_link, "link" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_visited, "visited" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_first_letter, "first-letter" );
+
+// Feature: PrintExt
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_left, "left" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_right, "right" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_first, "first" );
+// /Feature: PrintExt
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_url, "url" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_rgb, "rgb" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_pt, "pt" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_mm, "mm" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_cm, "cm" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_pc, "pc" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_inch, "in" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_px, "px" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_em, "em" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_UNIT_ex, "ex" );
+
+/* */
+
+// Strings fuer Font-Properties
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_font_family, "font-family" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_serif, "serif" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_sans_serif, "sans-serif" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_cursive, "cursive" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_fantasy, "fantasy" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_monospace, "monospace" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_font_style, "font-style" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_normal, "normal" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_italic, "italic" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_oblique, "oblique" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_font_variant, "font-variant" );
+
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_normal, "normal" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_small_caps, "small-caps" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_font_weight, "font-weight" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_extra_light, "extra-light" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_light, "light" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_demi_light, "demi-light" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_medium, "medium" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_demi_bold, "demi-bold" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_bold, "bold" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_extra_bold, "extra-bold" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_lighter, "lighter" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_bolder, "bolder" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_font_size, "font-size" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_xx_small, "xx-small" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_x_small, "x-small" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_small, "small" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_medium, "medium" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_large, "large" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_x_large, "x-large" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_xx_large, "xx-large" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_larger, "larger" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_smaller, "smaller" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_font, "font" );
+
+
+
+/* */
+
+// Strings fuer Farb- und Hintergrund-Properties
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_color, "color" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_background, "background" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_background_color, "background-color" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_transparent, "transparent" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_repeat, "repeat" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_repeat_x, "repeat-x" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_repeat_y, "repeat-y" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_no_repeat, "no-repeat" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_top, "top" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_middle, "middle" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_bottom, "bottom" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_scroll, "scroll" );
+
+
+/* */
+
+// Strings fuer Text-Properties
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_letter_spacing, "letter-spacing" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_text_decoration, "text-decoration" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_none, "none" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_underline, "underline" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_line_through, "line-through" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_blink, "blink" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_text_align, "text-align" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_left, "left" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_center, "center" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_right, "right" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_justify, "justify" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_text_indent, "text-indent" );
+
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_line_height, "line-height" );
+
+
+/* */
+
+// Strings fuer Box-Properties
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_margin_left, "margin-left" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_margin_right, "margin-right" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_margin_top, "margin-top" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_margin_bottom, "margin-bottom" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_margin, "margin" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_padding_top, "padding-top" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_padding_bottom, "padding-bottom" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_padding_left, "padding-left" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_padding_right, "padding-right" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_padding, "padding" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_auto, "auto" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_left_width, "border-left-width" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_right_width, "border-right-width" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_top_width, "border-top-width" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_bottom_width, "border-bottom-width" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_width, "border-width" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_color, "border-color" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_style, "border-style" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_left, "border-left" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_right, "border-right" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_top, "border-top" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border_bottom, "border-bottom" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_border, "border" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_thin, "thin" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_medium, "medium" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_thick, "thick" );
+
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_none, "none" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_dotted, "dotted" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_dashed, "dashed" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_solid, "solid" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_double, "double" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_groove, "groove" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_ridge, "ridge" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_inset, "inset" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_outset, "outset" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_width, "width" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_height, "height" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_float, "float" );
+
+/* */
+
+// Strings fuer Positioning
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_position, "position" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_absolute, "absolute" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_relative, "relative" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_static, "static" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_left, "left" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_top, "top" );
+
+/* */
+
+// Feature: PrintExt
+
+// Strings fuer Printing Extensions
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_page_break_before, "page-break-before" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_page_break_after, "page-break-after" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_page_break_inside, "page-break-inside" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_size, "size" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_widows, "widows" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_orphans, "orphans" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_P_marks, "marks" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_always, "always" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_avoid, "avoid" );
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_portrait, "portrait" );
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_landscape, "landscape" );
+
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_crop, "crop" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_PV_cross, "cross" );
+
+// /Feature: PrintExt
+
+sal_Char __FAR_DATA CSS1_CONSTASCII_DEF( sCSS1_class_abs_pos, "sd-abs-pos" );
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/css1kywd.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.25 2000/09/18 16:04:43 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.24 2000/04/10 12:20:55 mib
+ unicode
+
+ Revision 1.23 1999/06/11 14:44:00 MIB
+ Individuelle Umrandungs-Abstaende
+
+
+ Rev 1.22 11 Jun 1999 16:44:00 MIB
+ Individuelle Umrandungs-Abstaende
+
+ Rev 1.21 15 Apr 1999 13:44:52 MIB
+ background-color
+
+ Rev 1.20 15 Apr 1998 14:40:44 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.19 03 Apr 1998 15:11:32 MIB
+ CSS1-Padding
+
+ Rev 1.18 26 Nov 1997 19:09:04 MA
+ includes
+
+ Rev 1.17 10 Oct 1997 10:14:22 MIB
+ CSS1-Printing-Ext: @page,page-break-before/after (noch kein left/right)
+
+ Rev 1.16 30 Jul 1997 12:27:18 MIB
+ absolute positioning
+
+ Rev 1.15 02 Jul 1997 17:11:28 MIB
+ neue CSS1-Border-Properties
+
+ Rev 1.14 21 May 1997 11:11:42 MIB
+ <LINK REL=STYLESHEET> zum Enbinden von externen Style-Sheets
+
+ Rev 1.13 22 Oct 1996 10:28:38 MIB
+ Umstellung von CSS1 auf Klein-Buchstaben (u.a. wegen Amaya)
+
+ Rev 1.12 15 Oct 1996 13:35:40 MIB
+ letter-spacing/Laufweite imp./exp.
+
+ Rev 1.11 14 Oct 1996 16:42:24 MIB
+ Import CSS1-Umrandung (border)
+
+ Rev 1.10 13 Oct 1996 12:12:40 MIB
+ first-letter-Pseudo-Element/DropCaps
+
+ Rev 1.9 11 Oct 1996 16:48:00 MIB
+ font-variant
+
+ Rev 1.8 24 Sep 1996 12:47:42 MIB
+ bug fix: Einheit fuer Inch ist in nicht inch
+
+ Rev 1.7 19 Aug 1996 18:04:56 MIB
+ Anpassungen an Draft vom 26.Juli 96
+
+ Rev 1.6 12 Aug 1996 10:29:56 MIB
+ Anpassungen an draft vom 26.7.96, Background-Property
+
+ Rev 1.5 07 Aug 1996 13:21:30 MIB
+ Import von color und text-decoration
+
+ Rev 1.4 10 Jul 1996 15:41:36 MIB
+ Includes fuer precompiled header gerichtet
+
+ Rev 1.3 03 Jul 1996 16:51:48 MIB
+ visited und link
+
+ Rev 1.2 18 Jun 1996 12:19:28 MIB
+ margin[-[left|right|top|bottom]]?, text-indent
+
+ Rev 1.1 17 Jun 1996 15:57:26 MIB
+ restliche Keywords fuer Font-Properties
+
+ Rev 1.0 16 Jun 1996 14:32:30 MIB
+ Initial revision.
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/html/css1kywd.hxx b/sw/source/filter/html/css1kywd.hxx
new file mode 100644
index 000000000000..3c884a56604d
--- /dev/null
+++ b/sw/source/filter/html/css1kywd.hxx
@@ -0,0 +1,320 @@
+/*************************************************************************
+ *
+ * $RCSfile: css1kywd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _CSS1KYWD_HXX
+#define _CSS1KYWD_HXX
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+
+#ifndef CSS1_CONSTASCII_DECL
+#define CSS1_CONSTASCII_DECL( n, s ) n[sizeof(s)]
+#endif
+#ifndef CSS1_CONSTASCII_DEF
+#define CSS1_CONSTASCII_DEF( n, s ) n[sizeof(s)] = s
+#endif
+
+/* */
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS_mimetype, "text/css" );
+
+/* */
+
+// ein par allgemeine Strings
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_import, "import" );
+
+// Feature: PrintExt
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_page, "page" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_media, "media" );
+// /Feature: PrintExt
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_important, "important" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_link, "link" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_visited, "visited" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_first_letter, "first-letter" );
+
+// Feature: PrintExt
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_left, "left" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_right, "right" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_first, "first" );
+// /Feature: PrintExt
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_url, "url" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_rgb, "rgb" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_pt, "pt" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_mm, "mm" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_cm, "cm" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_pc, "pc" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_inch, "in" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_px, "px" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_em, "em" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_UNIT_ex, "ex" );
+
+/* */
+
+// Strings fuer Font-Properties
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_font_family, "font-family" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_serif, "serif" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_sans_serif, "sans-serif" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_cursive, "cursive" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_fantasy, "fantasy" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_monospace, "monospace" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_font_style, "font-style" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_normal, "normal" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_italic, "italic" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_oblique, "oblique" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_font_variant, "font-variant" );
+
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_normal, "normal" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_small_caps, "small-caps" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_font_weight, "font-weight" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_extra_light, "extra-light" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_light, "light" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_demi_light, "demi-light" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_medium, "medium" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_demi_bold, "demi-bold" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_bold, "bold" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_extra_bold, "extra-bold" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_lighter, "lighter" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_bolder, "bolder" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_font_size, "font-size" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_xx_small, "xx-small" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_x_small, "x-small" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_small, "small" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_medium, "medium" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_large, "large" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_x_large, "x-large" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_xx_large, "xx-large" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_larger, "larger" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_smaller, "smaller" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_font, "font" );
+
+
+
+/* */
+
+// Strings fuer Farb- und Hintergrund-Properties
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_color, "color" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_background, "background" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_background_color, "background-color" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_transparent, "transparent" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_repeat, "repeat" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_repeat_x, "repeat-x" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_repeat_y, "repeat-y" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_no_repeat, "no-repeat" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_top, "top" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_middle, "middle" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_bottom, "bottom" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_scroll, "scroll" );
+
+
+/* */
+
+// Strings fuer Text-Properties
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_letter_spacing, "letter-spacing" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_text_decoration, "text-decoration" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_none, "none" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_underline, "underline" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_line_through, "line-through" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_blink, "blink" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_text_align, "text-align" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_left, "left" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_center, "center" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_right, "right" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_justify, "justify" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_text_indent, "text-indent" );
+
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_line_height, "line-height" );
+
+
+/* */
+
+// Strings fuer Box-Properties
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_margin_left, "margin-left" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_margin_right, "margin-right" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_margin_top, "margin-top" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_margin_bottom, "margin-bottom" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_margin, "margin" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_padding_top, "padding-top" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_padding_bottom, "padding-bottom" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_padding_left, "padding-left" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_padding_right, "padding-right" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_padding, "padding" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_auto, "auto" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_left_width, "border-left-width" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_right_width, "border-right-width" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_top_width, "border-top-width" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_bottom_width, "border-bottom-width" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_width, "border-width" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_color, "border-color" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_style, "border-style" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_left, "border-left" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_right, "border-right" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_top, "border-top" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border_bottom, "border-bottom" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_border, "border" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_thin, "thin" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_medium, "medium" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_thick, "thick" );
+
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_none, "none" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_dotted, "dotted" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_dashed, "dashed" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_solid, "solid" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_double, "double" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_groove, "groove" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_ridge, "ridge" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_inset, "inset" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_outset, "outset" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_width, "width" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_height, "height" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_float, "float" );
+
+/* */
+
+// Strings fuer Positioning
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_position, "position" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_absolute, "absolute" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_relative, "relative" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_static, "static" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_left, "left" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_top, "top" );
+
+/* */
+
+// Feature: PrintExt
+
+// Strings fuer Printing Extensions
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_page_break_before, "page-break-before" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_page_break_after, "page-break-after" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_page_break_inside, "page-break-inside" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_size, "size" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_widows, "widows" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_orphans, "orphans" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_P_marks, "marks" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_always, "always" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_avoid, "avoid" );
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_portrait, "portrait" );
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_landscape, "landscape" );
+
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_crop, "crop" );
+//sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_PV_cross, "cross" );
+
+// /Feature: PrintExt
+
+extern sal_Char __FAR_DATA CSS1_CONSTASCII_DECL( sCSS1_class_abs_pos, "sd-abs-pos" );
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
new file mode 100644
index 000000000000..1d270c8ca988
--- /dev/null
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -0,0 +1,3165 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlatr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _SFX_WHITER_HXX //autogen
+#include <svtools/whiter.hxx>
+#endif
+#ifndef _SFXMACITEM_HXX //autogen
+#include <svtools/macitem.hxx>
+#endif
+
+#ifndef _SVX_HTMLMODE_HXX
+#include <svx/htmlmode.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_BLNKITEM_HXX //autogen
+#include <svx/blnkitem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+
+
+#ifndef _FCHRFMT_HXX //autogen
+#include <fchrfmt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _TXATBASE_HXX //autogen
+#include <txatbase.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _SWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+
+#ifndef _FMTCOL_HXX
+#include <fmtcol.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+
+#ifndef _WRTTXATR_HXX
+#include <wrttxatr.hxx>
+#endif
+#ifndef _HTMLNUM_HXX
+#include <htmlnum.hxx>
+#endif
+#ifndef _WRTHTML_HXX
+#include <wrthtml.hxx>
+#endif
+#ifndef _HTMLFLY_HXX
+#include <htmlfly.hxx>
+#endif
+
+
+/*
+ * um nicht immer wieder nach einem Update festzustellen, das irgendwelche
+ * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle
+ * definiert und mit der akt. verglichen. Bei unterschieden wird der
+ * Compiler schon meckern.
+ *
+ * diese Section und die dazugeherigen Tabellen muessen in folgenden Files
+ * gepflegt werden: rtf\rtfatr.cxx, sw6\sw6atr.cxx, w4w\w4watr.cxx
+ */
+#if !defined(UNX) && !defined(MSC) && !defined(PPC) && !defined(CSET) && !defined(__MWERKS__) && !defined(WTC)
+
+#define ATTRFNTAB_SIZE 121
+#if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN
+#error Attribut-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+
+#ifdef FORMAT_TABELLE
+// da sie nicht benutzt wird!
+#define FORMATTAB_SIZE 7
+#if FORMATTAB_SIZE != RES_FMT_END - RES_FMT_BEGIN
+#error Format-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+#endif
+
+#define NODETAB_SIZE 3
+#if NODETAB_SIZE != RES_NODE_END - RES_NODE_BEGIN
+#error Node-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+
+#endif
+
+#define HTML_BULLETCHAR_DISC 34
+#define HTML_BULLETCHAR_CIRCLE 38
+#define HTML_BULLETCHAR_SQUARE 36
+
+#define COLFUZZY 20
+
+//-----------------------------------------------------------------------
+
+HTMLOutEvent __FAR_DATA aAnchorEventTable[] =
+{
+ { sHTML_O_SDonclick, sHTML_O_onclick, SFX_EVENT_MOUSECLICK_OBJECT },
+ { sHTML_O_SDonmouseover, sHTML_O_onmouseover, SFX_EVENT_MOUSEOVER_OBJECT },
+ { sHTML_O_SDonmouseout, sHTML_O_onmouseout, SFX_EVENT_MOUSEOUT_OBJECT },
+ { 0, 0, 0 }
+};
+
+static Writer& OutHTML_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt );
+
+static Writer& OutHTML_HoriSpacer( Writer& rWrt, INT16 nSize )
+{
+ ASSERT( nSize>0, "horizontaler SPACER mit negativem Wert?" )
+ if( nSize <= 0 )
+ return rWrt;
+
+ if( Application::GetDefaultDevice() )
+ {
+ nSize = (INT16)Application::GetDefaultDevice()
+ ->LogicToPixel( Size(nSize,0), MapMode(MAP_TWIP) ).Width();
+ }
+
+ ByteString sOut( '<' );
+ (((((((((sOut += sHTML_spacer)
+ += ' ') += sHTML_O_type) += '=') += sHTML_SPTYPE_horizontal)
+ += ' ') += sHTML_O_size) += '=')
+ +=ByteString::CreateFromInt32(nSize)) += '>';
+
+ rWrt.Strm() << sOut.GetBuffer();
+
+ return rWrt;
+}
+
+USHORT SwHTMLWriter::GetDefListLvl( const String& rNm, USHORT nPoolId )
+{
+ if( nPoolId == RES_POOLCOLL_HTML_DD )
+ {
+ return 1 | HTML_DLCOLL_DD;
+ }
+ else if( nPoolId == RES_POOLCOLL_HTML_DT )
+ {
+ return 1 | HTML_DLCOLL_DT;
+ }
+
+ String sDTDD( String::CreateFromAscii(sHTML_dt) );
+ sDTDD += ' ';
+ if( COMPARE_EQUAL == sDTDD.CompareTo( rNm, sDTDD.Len() ) )
+ // DefinitionList - term
+ return (USHORT)rNm.Copy( sDTDD.Len() ).ToInt32() | HTML_DLCOLL_DT;
+
+ sDTDD.AssignAscii( sHTML_dd );
+ sDTDD += ' ';
+ if( COMPARE_EQUAL == sDTDD.CompareTo( rNm, sDTDD.Len() ) )
+ // DefinitionList - definition
+ return (USHORT)rNm.Copy( sDTDD.Len() ).ToInt32() | HTML_DLCOLL_DD;
+
+ return 0;
+}
+
+void SwHTMLWriter::OutAndSetDefList( USHORT nNewLvl )
+{
+ // eventuell muss erst mal eine Liste aufgemacht werden
+ if( nDefListLvl < nNewLvl )
+ {
+ // entsprechend dem Level-Unterschied schreiben!
+ for( USHORT i=nDefListLvl; i<nNewLvl; i++ )
+ {
+ if( bLFPossible )
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_deflist, TRUE );
+ IncIndentLevel();
+ bLFPossible = TRUE;
+ }
+ }
+ else if( nDefListLvl > nNewLvl )
+ {
+ for( USHORT i=nNewLvl ; i < nDefListLvl; i++ )
+ {
+ DecIndentLevel();
+ if( bLFPossible )
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_deflist, FALSE );
+ bLFPossible = TRUE;
+ }
+ }
+
+ nDefListLvl = nNewLvl;
+}
+
+
+void SwHTMLWriter::ChangeParaToken( USHORT nNew )
+{
+ if( nNew != nLastParaToken && HTML_PREFORMTXT_ON == nLastParaToken )
+ {
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_preformtxt, FALSE );
+ bLFPossible = TRUE;
+ }
+ nLastParaToken = nNew;
+}
+
+// fuer die Formate muesste eine einzige Ausgabe-Funktion genuegen !
+/*
+ * Formate wie folgt ausgeben:
+ * - fuer Formate, fuer die es entsprechende HTML-Tags gibt wird das
+ * Tag ausgegeben
+ * - fuer alle anderen wird ein Absatz-Tag <P> ausgegeben und bUserFmt
+ * gesetzt
+ * - Wenn eine Absatz-Ausrichtung am uebergebenen Item-Set des Nodes
+ * oder im Item-Set des Format gesetzt ist, wird ein ALIGN=xxx ausgegeben,
+ * sofern HTML es zulaesst
+ * - in jedem Fall wird harte Attributierung als STYLE-Option geschrieben.
+ * Wenn bUserFmt nicht gesetzt ist, wird nur der uebergebene Item-Set
+ * betrachtet. Sonst werden auch Attribute des Formats ausgegeben.
+ */
+
+struct SwHTMLTxtCollOutputInfo
+{
+ ByteString aToken; // auszugendens End-Token
+ SfxItemSet *pItemSet; // harte Attributierung
+
+ BOOL bInNumBulList; // in einer Aufzaehlungs-Liste;
+ BOOL bParaPossible; // ein </P> darf zusaetzlich ausgegeben werden
+ BOOL bOutPara; // ein </P> soll ausgegeben werden
+ BOOL bOutDiv; // write a </DIV>
+
+ SwHTMLTxtCollOutputInfo() :
+ pItemSet( 0 ),
+ bInNumBulList( FALSE ),
+ bParaPossible( FALSE ),
+ bOutPara( FALSE ),
+ bOutDiv( FALSE )
+ {}
+
+ ~SwHTMLTxtCollOutputInfo();
+
+ BOOL HasParaToken() const { return aToken.Len()==1 && aToken.GetChar(0)=='P'; }
+ BOOL ShouldOutputToken() const { return bOutPara || !HasParaToken(); }
+};
+
+SwHTMLTxtCollOutputInfo::~SwHTMLTxtCollOutputInfo()
+{
+ delete pItemSet;
+}
+
+struct SwHTMLFmtInfo
+{
+ const SwFmt *pFmt; // das Format selbst
+ const SwFmt *pRefFmt; // das Vergleichs-Format
+
+ ByteString aToken; // das auszugebende Token
+ String aClass; // die auszugebende Klasse
+
+ SfxItemSet *pItemSet; // der auszugebende Attribut-Set
+
+ USHORT nLeftMargin; // ein par default-Werte fuer
+ USHORT nRightMargin; // Absatz-Vorlagen
+ short nFirstLineIndent;
+
+ USHORT nTopMargin;
+ USHORT nBottomMargin;
+
+ // Konstruktor fuer einen Dummy zum Suchen
+ SwHTMLFmtInfo( const SwFmt *pF ) :
+ pFmt( pF ), pItemSet( 0 )
+ {}
+
+
+ // Konstruktor zum Erstellen der Format-Info
+ SwHTMLFmtInfo( const SwFmt *pFmt, SwDoc *pDoc, SwDoc *pTemlate,
+ BOOL bOutStyles, BOOL bHardDrop=FALSE );
+ ~SwHTMLFmtInfo();
+
+ friend BOOL operator==( const SwHTMLFmtInfo& rInfo1,
+ const SwHTMLFmtInfo& rInfo2 )
+ {
+ return (long)rInfo1.pFmt == (long)rInfo2.pFmt;
+ }
+
+ friend BOOL operator<( const SwHTMLFmtInfo& rInfo1,
+ const SwHTMLFmtInfo& rInfo2 )
+ {
+ return (long)rInfo1.pFmt < (long)rInfo2.pFmt;
+ }
+
+};
+
+SV_IMPL_OP_PTRARR_SORT( SwHTMLFmtInfos, SwHTMLFmtInfo* )
+
+SwHTMLFmtInfo::SwHTMLFmtInfo( const SwFmt *pF, SwDoc *pDoc, SwDoc *pTemplate,
+ BOOL bOutStyles, BOOL bHardDrop ) :
+ pFmt( pF ), pItemSet( 0 )
+{
+ USHORT nRefPoolId = 0;
+ // Den Selektor des Formats holen
+ USHORT nDeep = SwHTMLWriter::GetCSS1Selector( pFmt, aToken, aClass,
+ nRefPoolId );
+ ASSERT( nDeep ? aToken.Len()>0 : aToken.Len()==0,
+ "Hier stimmt doch was mit dem Token nicht!" );
+ ASSERT( nDeep ? nRefPoolId : !nRefPoolId,
+ "Hier stimmt doch was mit der Vergleichs-Vorlage nicht!" );
+
+ BOOL bTxtColl = pFmt->Which() == RES_TXTFMTCOLL ||
+ pFmt->Which() == RES_CONDTXTFMTCOLL;
+
+ const SwFmt *pRefFmt = 0; // Vergleichs-Format
+ if( nDeep != 0 )
+ {
+ // Es ist eine HTML-Tag-Vorlage oder die Vorlage ist von einer
+ // solchen abgeleitet
+ if( !bOutStyles )
+ {
+ // wenn keine Styles exportiert werden, muss evtl. zusaetlich
+ // harte Attributierung geschrieben werden
+ switch( nDeep )
+ {
+ case CSS1_FMT_ISTAG:
+ case CSS1_FMT_CMPREF:
+ // fuer HTML-Tag-Vorlagen die Unterscheide zum Original
+ // (sofern verfuegbar)
+ if( pTemplate )
+ pRefFmt = SwHTMLWriter::GetTemplateFmt( nRefPoolId,
+ pTemplate );
+ break;
+
+ default:
+ // sonst die zur HTML-Tag-Vorlage des Originals oder des
+ // aktuellen Doks, wenn die nicht verfuegbar ist
+ if( pTemplate )
+ pRefFmt = SwHTMLWriter::GetTemplateFmt( nRefPoolId,
+ pTemplate );
+ else
+ pRefFmt = SwHTMLWriter::GetParentFmt( *pFmt, nDeep );
+ break;
+ }
+ }
+ }
+ else if( bTxtColl )
+ {
+ // Nicht von einer HTML-Tag-Vorlage abgeleitete Absatz-Vorlagen
+ // muessen als harte Attributierung relativ zur Textkoerper-Volage
+ // exportiert werden. Fuer Nicht-Styles-Export sollte die der
+ // HTML-Vorlage als Referenz dienen
+ if( !bOutStyles && pTemplate )
+ pRefFmt = pTemplate->GetTxtCollFromPool( RES_POOLCOLL_TEXT );
+ else
+ pRefFmt = pDoc->GetTxtCollFromPool( RES_POOLCOLL_TEXT );
+ }
+
+ if( pRefFmt || nDeep==0 )
+ {
+ // wenn Unterschiede zu einer anderen Vorlage geschrieben werden
+ // sollen ist harte Attributierung noetig. Fuer Vorlagen, die
+ // nicht von HTML-Tag-Vorlagen abgeleitet sind, gilt das immer
+ pItemSet = new SfxItemSet( *pFmt->GetAttrSet().GetPool(),
+ pFmt->GetAttrSet().GetRanges() );
+
+ pItemSet->Set( pFmt->GetAttrSet(), TRUE );
+ if( pRefFmt )
+ SwHTMLWriter::SubtractItemSet( *pItemSet, pRefFmt->GetAttrSet(), TRUE );
+
+ // einen leeren Item-Set gleich loeschen, das spart speater
+ // Arbeit
+ if( !pItemSet->Count() )
+ {
+ delete pItemSet;
+ pItemSet = 0;
+ }
+ }
+
+ if( bTxtColl )
+ {
+ // Ggf. noch ein DropCap-Attribut uebernehmen
+ if( bOutStyles && bHardDrop && nDeep != 0 )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET==pFmt->GetAttrSet().GetItemState(
+ RES_PARATR_DROP, TRUE, &pItem ) )
+ {
+ BOOL bPut = TRUE;
+ if( pTemplate )
+ {
+ pRefFmt = SwHTMLWriter::GetTemplateFmt( nRefPoolId, pTemplate );
+ const SfxPoolItem *pRefItem;
+ BOOL bRefItemSet =
+ SFX_ITEM_SET==pRefFmt->GetAttrSet().GetItemState(
+ RES_PARATR_DROP, TRUE, &pRefItem );
+ bPut = !bRefItemSet || *pItem!=*pRefItem;
+ }
+ if( bPut )
+ {
+ ASSERT( !pItemSet, "Wo kommt der ItemSet her?" );
+ pItemSet = new SfxItemSet( *pFmt->GetAttrSet().GetPool(),
+ pFmt->GetAttrSet().GetRanges() );
+ pItemSet->Put( *pItem );
+ }
+ }
+ }
+
+
+ // Die diversen default-Abstaende aus der Vorlage oder der
+ // Vergleischs-Vorlage merken
+ const SvxLRSpaceItem &rLRSpace =
+ (pRefFmt ? pRefFmt : pFmt)->GetLRSpace();
+ nLeftMargin = rLRSpace.GetTxtLeft();
+ nRightMargin = rLRSpace.GetRight();
+ nFirstLineIndent = rLRSpace.GetTxtFirstLineOfst();
+
+ const SvxULSpaceItem &rULSpace =
+ (pRefFmt ? pRefFmt : pFmt)->GetULSpace();
+ nTopMargin = rULSpace.GetUpper();
+ nBottomMargin = rULSpace.GetLower();
+ }
+}
+
+SwHTMLFmtInfo::~SwHTMLFmtInfo()
+{
+ delete pItemSet;
+}
+
+void OutHTML_SwFmt( Writer& rWrt, const SwFmt& rFmt,
+ const SfxItemSet *pNodeItemSet,
+ SwHTMLTxtCollOutputInfo& rInfo )
+{
+ ASSERT( RES_CONDTXTFMTCOLL==rFmt.Which() || RES_TXTFMTCOLL==rFmt.Which(),
+ "keine Absatz-Vorlage" );
+
+ SwHTMLWriter & rHWrt = (SwHTMLWriter&)rWrt;
+
+ // Erstmal ein par Flags ...
+ USHORT nNewDefListLvl = 0;
+ USHORT nNumStart = USHRT_MAX;
+ BOOL bForceDL = FALSE;
+ BOOL bDT = FALSE;
+ rInfo.bInNumBulList = FALSE; // Wir sind in einer Liste?
+ BOOL bNumbered = FALSE; // Der aktuelle Absatz ist numeriert
+ BOOL bPara = FALSE; // das aktuelle Token ist <P>
+ rInfo.bParaPossible = FALSE; // ein <P> darf zusaetzlich ausgegeben werden
+ BOOL bNoEndTag = FALSE; // kein End-Tag ausgeben
+
+ rHWrt.bNoAlign = FALSE; // kein ALIGN=... moeglich
+ BOOL bNoStyle = FALSE; // kein STYLE=... moeglich
+ BYTE nBulletGrfLvl = 255; // Die auszugebende Bullet-Grafik
+
+ // Sind wir in einer Aufzaehlungs- oder Numerierungliste?
+ const SwTxtNode* pTxtNd = rWrt.pCurPam->GetNode()->GetTxtNode();
+ ULONG nPos = pTxtNd->GetIndex();
+
+ SwHTMLNumRuleInfo aNumInfo;
+ if( rHWrt.GetNextNumInfo() )
+ {
+ aNumInfo = *rHWrt.GetNextNumInfo();
+ rHWrt.ClearNextNumInfo();
+ }
+ else
+ {
+ aNumInfo.Set( *pTxtNd );
+ }
+
+ if( aNumInfo.GetNumRule() )
+ {
+ rInfo.bInNumBulList = TRUE;
+ nNewDefListLvl = 0;
+
+ // ist der aktuelle Absatz numeriert?
+ bNumbered = aNumInfo.IsNumbered();
+ BYTE nLvl = aNumInfo.GetLevel();
+
+ const SwNodeNum& rAktNum = *pTxtNd->GetNum();
+ ASSERT( GetRealLevel( rAktNum.GetLevel() ) == nLvl,
+ "Gemerkter Num-Level ist falsch" );
+ ASSERT( bNumbered == ((rAktNum.GetLevel() & NO_NUMLEVEL) == 0),
+ "Gemerkter Numerierungs-Zustand ist falsch" );
+
+ if( bNumbered )
+ {
+ nBulletGrfLvl = nLvl; // nur veruebergehend!!!
+ nNumStart = rAktNum.GetSetValue();
+ DBG_ASSERT( rHWrt.nLastParaToken == 0,
+ "<PRE> wurde nicht vor <LI> beendet." );
+ }
+
+#ifndef NUM_RELSPACE
+ // die Absatz-Abstaende/Einzuege muessen beruecksichtigen,
+ // dass wir in einer Liste sind
+ rHWrt.nLeftMargin = (nLvl+1) * HTML_NUMBUL_MARGINLEFT;
+
+ rHWrt.nFirstLineIndent = bNumbered ? HTML_NUMBUL_INDENT : 0;
+#endif
+ }
+
+ // Jetzt holen wir das Token und ggf. die Klasse
+ SwHTMLFmtInfo aFmtInfo( &rFmt );
+ USHORT nArrayPos;
+ const SwHTMLFmtInfo *pFmtInfo;
+ if( rHWrt.aTxtCollInfos.Seek_Entry( &aFmtInfo, &nArrayPos ) )
+ {
+ pFmtInfo = rHWrt.aTxtCollInfos[nArrayPos];
+ }
+ else
+ {
+ pFmtInfo = new SwHTMLFmtInfo( &rFmt, rWrt.pDoc, rHWrt.pTemplate,
+ rHWrt.bCfgOutStyles,
+ !rHWrt.IsHTMLMode(HTMLMODE_DROPCAPS) );
+ rHWrt.aTxtCollInfos.C40_PTR_INSERT( SwHTMLFmtInfo, pFmtInfo );
+ }
+
+ // Jetzt wird festgelegt, was aufgrund des Tokens so moeglich ist
+ USHORT nToken = 0; // Token fuer Tag-Wechsel
+ BOOL bOutNewLine = FALSE; // nur ein LF ausgeben?
+ if( pFmtInfo->aToken.Len() )
+ {
+ // Es ist eine HTML-Tag-Vorlage oder die Vorlage ist von einer
+ // solchen abgeleitet
+ rInfo.aToken = pFmtInfo->aToken;
+
+ // der erste Buchstabe reicht meistens
+ switch( rInfo.aToken.GetChar( 0 ) )
+ {
+ case 'A': ASSERT( rInfo.aToken.Equals(sHTML_address),
+ "Doch kein ADDRESS?" );
+ rInfo.bParaPossible = TRUE;
+ rHWrt.bNoAlign = TRUE;
+ break;
+
+ case 'B': ASSERT( rInfo.aToken.Equals(sHTML_blockquote),
+ "Doch kein BLOCKQUOTE?" );
+ rInfo.bParaPossible = TRUE;
+ rHWrt.bNoAlign = TRUE;
+ break;
+
+ case 'P': if( rInfo.aToken.Len() == 1 )
+ {
+ bPara = TRUE;
+ }
+ else
+ {
+ ASSERT( rInfo.aToken.Equals(sHTML_preformtxt),
+ "Doch kein PRE?" );
+ if( HTML_PREFORMTXT_ON == rHWrt.nLastParaToken )
+ {
+ bOutNewLine = TRUE;
+ }
+ else
+ {
+ nToken = HTML_PREFORMTXT_ON;
+ rHWrt.bNoAlign = TRUE;
+ bNoEndTag = TRUE;
+ }
+ }
+ break;
+
+ case 'D': ASSERT( rInfo.aToken.Equals(sHTML_dt) ||
+ rInfo.aToken.Equals(sHTML_dd),
+ "Doch kein DD/DT?" );
+ bDT = rInfo.aToken.Equals(sHTML_dt);
+ rInfo.bParaPossible = !bDT;
+ rHWrt.bNoAlign = TRUE;
+ bForceDL = TRUE;
+ break;
+ }
+ }
+ else
+ {
+ // alle Vorlagen, die nicht einem HTML-Tag entsprechen oder von
+ // diesem abgeleitet sind, werden als <P> exportiert
+
+ rInfo.aToken = sHTML_parabreak;
+ bPara = TRUE;
+ }
+
+ // Falls noetig, die harte Attributierung der Vorlage uebernehmen
+ if( pFmtInfo->pItemSet )
+ {
+ ASSERT( !rInfo.pItemSet, "Wo kommt der Item-Set her?" );
+ rInfo.pItemSet = new SfxItemSet( *pFmtInfo->pItemSet );
+ }
+
+ // und noch die harte Attributierung des Absatzes dazunehmen
+ if( pNodeItemSet )
+ {
+ if( rInfo.pItemSet )
+ rInfo.pItemSet->Put( *pNodeItemSet );
+ else
+ rInfo.pItemSet = new SfxItemSet( *pNodeItemSet );
+ }
+
+ // den unteren Absatz-Abstand brauchen wir noch
+ const SvxULSpaceItem& rULSpace =
+ pNodeItemSet ? ((const SvxULSpaceItem &)pNodeItemSet->Get(RES_UL_SPACE))
+ : rFmt.GetULSpace();
+
+ if( (rHWrt.bOutHeader &&
+ rWrt.pCurPam->GetPoint()->nNode.GetIndex() ==
+ rWrt.pCurPam->GetMark()->nNode.GetIndex()) ||
+ rHWrt.bOutFooter )
+ {
+ if( rHWrt.bCfgOutStyles )
+ {
+ SvxULSpaceItem aULSpaceItem( rULSpace );
+ if( rHWrt.bOutHeader )
+ aULSpaceItem.SetLower( rHWrt.nHeaderFooterSpace );
+ else
+ aULSpaceItem.SetUpper( rHWrt.nHeaderFooterSpace );
+
+ if( !rInfo.pItemSet )
+ rInfo.pItemSet = new SfxItemSet(
+ *rFmt.GetAttrSet().GetPool(),
+ RES_UL_SPACE, RES_UL_SPACE );
+ rInfo.pItemSet->Put( aULSpaceItem );
+ }
+ rHWrt.bOutHeader = FALSE;
+ rHWrt.bOutFooter = FALSE;
+ }
+
+ if( bOutNewLine )
+ {
+ // nur einen Zeilen-Umbruch (ohne Einrueckung) am Absatz-Anfang
+ // ausgeben
+ rInfo.aToken.Erase(); // kein End-Tag ausgeben
+ rWrt.Strm() << SwHTMLWriter::sNewLine;
+
+ return;
+ }
+
+
+ // soll ein ALIGN=... geschrieben werden?
+ const SfxPoolItem* pAdjItem = 0;
+ const SfxPoolItem* pItem;
+
+ if( rInfo.pItemSet &&
+ SFX_ITEM_SET == rInfo.pItemSet->GetItemState( RES_PARATR_ADJUST,
+ FALSE, &pItem ) )
+ {
+ pAdjItem = pItem;
+ }
+
+ // Unteren Absatz-Abstand beachten ? (nie im letzen Absatz von
+ // Tabellen)
+ BOOL bUseParSpace = !rHWrt.bOutTable ||
+ (rWrt.pCurPam->GetPoint()->nNode.GetIndex() !=
+ rWrt.pCurPam->GetMark()->nNode.GetIndex());
+ // Wenn Styles exportiert werden, wird aus eingerueckten Absaetzen
+ // eine Definitions-Liste
+ const SvxLRSpaceItem& rLRSpace =
+ pNodeItemSet ? ((const SvxLRSpaceItem &)pNodeItemSet->Get(RES_LR_SPACE))
+ : rFmt.GetLRSpace();
+ if( (!rHWrt.bCfgOutStyles || bForceDL) && !rInfo.bInNumBulList )
+ {
+ USHORT nLeftMargin;
+ if( bForceDL )
+ nLeftMargin = rLRSpace.GetTxtLeft();
+ else
+ nLeftMargin = rLRSpace.GetTxtLeft() > pFmtInfo->nLeftMargin
+ ? rLRSpace.GetTxtLeft() - pFmtInfo->nLeftMargin
+ : 0;
+
+ nNewDefListLvl = (nLeftMargin + (rHWrt.nDefListMargin/2)) /
+ rHWrt.nDefListMargin;
+
+ BOOL bIsNextTxtNode =
+ rWrt.pDoc->GetNodes()[rWrt.pCurPam->GetPoint()->nNode.GetIndex()+1]
+ ->IsTxtNode();
+
+ if( bForceDL && bDT )
+ {
+ // Statt eines DD muessen wir hier auch ein DT der Ebene
+ // darueber nehmen
+ nNewDefListLvl++;
+ }
+ else if( !nNewDefListLvl && !rHWrt.bCfgOutStyles && bPara &&
+ rULSpace.GetLower()==0 &&
+ ((bUseParSpace && bIsNextTxtNode) || rHWrt.nDefListLvl==1) &&
+ (!pAdjItem || SVX_ADJUST_LEFT==
+ ((const SvxAdjustItem *)pAdjItem)->GetAdjust()) )
+ {
+ // Absaetze ohne unteren Abstand als DT exportieren
+ nNewDefListLvl = 1;
+ bDT = TRUE;
+ rInfo.bParaPossible = FALSE;
+ rHWrt.bNoAlign = TRUE;
+ }
+ }
+
+ if( nNewDefListLvl != rHWrt.nDefListLvl )
+ rHWrt.OutAndSetDefList( nNewDefListLvl );
+
+ // ggf. eine Aufzaehlung- oder Numerierungsliste beginnen
+ if( rInfo.bInNumBulList )
+ {
+ ASSERT( !rHWrt.nDefListLvl, "DL in OL geht nicht!" );
+ OutHTML_NumBulListStart( rHWrt, aNumInfo );
+
+ if( bNumbered )
+ {
+ if( rHWrt.aBulletGrfs[nBulletGrfLvl].Len() )
+ bNumbered = FALSE;
+ else
+ nBulletGrfLvl = 255;
+ }
+
+#ifndef NUM_RELSPACE
+ // Wenn der Ziel-Browser mit horizontalen Absatz-Abstaenden in
+ // Listen nicht zurechtkommt, loeschen wir das Item.
+ if( !rHWrt.IsHTMLMode( HTMLMODE_LRSPACE_IN_NUMBUL ) &&
+ rInfo.pItemSet )
+ {
+ rInfo.pItemSet->ClearItem( RES_LR_SPACE );
+ }
+#endif
+ }
+
+ // Die Defaults aus der Vorlage merken, denn sie muessen nicht
+ // exportiert werden
+ rHWrt.nDfltLeftMargin = pFmtInfo->nLeftMargin;
+ rHWrt.nDfltRightMargin = pFmtInfo->nRightMargin;
+ rHWrt.nDfltFirstLineIndent = pFmtInfo->nFirstLineIndent;
+
+#ifdef NUM_RELSPACE
+ if( rInfo.bInNumBulList )
+ {
+ if( !rHWrt.IsHTMLMode( HTMLMODE_LSPACE_IN_NUMBUL ) )
+ rHWrt.nDfltLeftMargin = rLRSpace.GetTxtLeft();
+
+ // In Numerierungs-Listen keinen Ertzeilen-Einzug ausgeben.
+ rHWrt.nFirstLineIndent = rLRSpace.GetTxtFirstLineOfst();
+ }
+#endif
+
+ if( rInfo.bInNumBulList && bNumbered && bPara && !rHWrt.bCfgOutStyles )
+ {
+ // ein einzelnes LI hat keinen Abstand
+ rHWrt.nDfltTopMargin = 0;
+ rHWrt.nDfltBottomMargin = 0;
+ }
+ else if( rHWrt.nDefListLvl && bPara )
+ {
+ // ein einzelnes DD hat auch keinen Abstand
+ rHWrt.nDfltTopMargin = 0;
+ rHWrt.nDfltBottomMargin = 0;
+ }
+ else
+ {
+ rHWrt.nDfltTopMargin = pFmtInfo->nTopMargin;
+ // #60393#: Wenn im letzten Absatz einer Tabelle der
+ // untere Absatz-Abstand veraendert wird, vertut sich
+ // Netscape total. Deshalb exportieren wir hier erstmal
+ // nichts, indem wir den Abstand aus dem Absatz als Default
+ // setzen.
+ if( rHWrt.bCfgNetscape4 && !bUseParSpace )
+ rHWrt.nDfltBottomMargin = rULSpace.GetLower();
+ else
+ rHWrt.nDfltBottomMargin = pFmtInfo->nBottomMargin;
+ }
+
+ if( rHWrt.nDefListLvl )
+ {
+ rHWrt.nLeftMargin =
+ (rHWrt.nDefListLvl-1) * rHWrt.nDefListMargin;
+ }
+
+ if( rHWrt.bLFPossible )
+ rHWrt.OutNewLine(); // Absatz-Tag in neue Zeile
+ rInfo.bOutPara = FALSE;
+
+ // das ist jetzt unser neues Token
+ rHWrt.ChangeParaToken( nToken );
+
+ BOOL bHasParSpace = bUseParSpace && rULSpace.GetLower() > 0;
+
+ // ggf ein List-Item aufmachen
+ if( rInfo.bInNumBulList && bNumbered )
+ {
+ ByteString sOut( '<' );
+ sOut += sHTML_li;
+ if( USHRT_MAX != nNumStart )
+ (((sOut += ' ') += sHTML_O_value) += '=')
+ += ByteString::CreateFromInt32(nNumStart);
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+
+ if( rHWrt.nDefListLvl > 0 && !bForceDL )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), bDT ? sHTML_dt : sHTML_dd );
+ }
+
+ if( pAdjItem &&
+ rHWrt.IsHTMLMode( HTMLMODE_NO_CONTROL_CENTERING ) &&
+ rHWrt.HasControls() )
+ {
+ // #64687#: The align=... attribute does behave strange in netscape
+ // if there are controls in a paragraph, because the control and
+ // all text behind the control does not recognize this attribute.
+ ByteString sOut( '<' );
+ sOut += sHTML_division;
+ rWrt.Strm() << sOut.GetBuffer();
+
+ rHWrt.bTxtAttr = FALSE;
+ rHWrt.bOutOpts = TRUE;
+ OutHTML_SvxAdjust( rWrt, *pAdjItem );
+ rWrt.Strm() << '>';
+ pAdjItem = 0;
+ rHWrt.bNoAlign = FALSE;
+ rInfo.bOutDiv = TRUE;
+ rHWrt.IncIndentLevel();
+ rHWrt.bLFPossible = TRUE;
+ rHWrt.OutNewLine();
+ }
+
+ // fuer BLOCKQUOTE, ADDRESS und DD wird noch ein Absatz-Token
+ // ausgegeben, wenn,
+ // - keine Styles geschrieben werden, und
+ // - ein untere Abstand oder eine Absatz-Ausrichtung existiert
+ ByteString aToken = rInfo.aToken;
+ if( !rHWrt.bCfgOutStyles && rInfo.bParaPossible && !bPara &&
+ (bHasParSpace || pAdjItem) )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rInfo.aToken.GetBuffer() );
+ aToken = sHTML_parabreak;
+ bPara = TRUE;
+ rHWrt.bNoAlign = FALSE;
+ bNoStyle = FALSE;
+ }
+
+ // Ein <P> wird nur geschrieben, wenn
+ // - wir in keiner OL/UL/DL sind, oder
+ // - der Absatz einer OL/UL nicht numeriert ist, oder
+ // - keine Styles exportiert werden und
+ // - ein unterer Abstand oder
+ // - eine Absatz-Ausrichtung existiert, ode
+ // - Styles exportiert werden und,
+ // - die Textkoerper-Vorlage geaendert wurde, oder
+ // - ein Benutzer-Format exportiert wird, oder
+ // - Absatz-Attribute existieren
+ if( !bPara ||
+ (!rInfo.bInNumBulList && !rHWrt.nDefListLvl) ||
+ (rInfo.bInNumBulList && !bNumbered) ||
+ (!rHWrt.bCfgOutStyles && (bHasParSpace || pAdjItem)) ||
+ (rHWrt.bCfgOutStyles /*&& rHWrt.bPoolCollTextModified*/) )
+ {
+ // jetzt werden Optionen ausgegeben
+ rHWrt.bTxtAttr = FALSE;
+ rHWrt.bOutOpts = TRUE;
+
+ ByteString sOut( '<' );
+ sOut += aToken;
+
+ if( rHWrt.bCfgOutStyles && pFmtInfo->aClass.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_class) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), pFmtInfo->aClass,
+ rHWrt.eDestEnc );
+ sOut = '\"';
+ }
+ rWrt.Strm() << sOut.GetBuffer();
+
+ // ggf. Ausrichtung ausgeben.
+ if( !rHWrt.bNoAlign && pAdjItem )
+ OutHTML_SvxAdjust( rWrt, *pAdjItem );
+
+ // und nun ggf. noch die STYLE-Option
+ if( rHWrt.bCfgOutStyles && rInfo.pItemSet && !bNoStyle)
+ {
+ OutCSS1_ParaTagStyleOpt( rWrt, *rInfo.pItemSet );
+ }
+
+ rWrt.Strm() << '>';
+
+ // Soll ein </P> geschrieben wenrden
+ rInfo.bOutPara =
+ bPara &&
+ ( rHWrt.bCfgOutStyles ||
+ (!rHWrt.bCfgOutStyles && bHasParSpace) );
+
+ // wenn kein End-Tag geschrieben werden soll, es loeschen
+ if( bNoEndTag )
+ rInfo.aToken.Erase();
+ }
+
+ // ??? Warum nicht ueber den Hint-Mechanismus ???
+ if( rHWrt.IsHTMLMode(HTMLMODE_FIRSTLINE) )
+ {
+ const SvxLRSpaceItem& rLRSpace =
+ pNodeItemSet ? ((const SvxLRSpaceItem &)pNodeItemSet->Get(RES_LR_SPACE))
+ : rFmt.GetLRSpace();
+ if( rLRSpace.GetTxtFirstLineOfst() > 0 )
+ {
+ OutHTML_HoriSpacer( rWrt, rLRSpace.GetTxtFirstLineOfst() );
+ }
+ }
+
+ if( nBulletGrfLvl != 255 )
+ {
+ ASSERT( aNumInfo.GetNumRule(), "Wo ist die Numerierung geblieben???" );
+ ASSERT( nBulletGrfLvl < MAXLEVEL, "So viele Ebenen gibt's nicht" );
+ const SwNumFmt& rNumFmt = aNumInfo.GetNumRule()->Get(nBulletGrfLvl);
+
+ OutHTML_BulletImage( rWrt, sHTML_image, 0,
+ rHWrt.aBulletGrfs[nBulletGrfLvl],
+ rNumFmt.GetGrfSize(), rNumFmt.GetGrfOrient() );
+ }
+
+ rHWrt.GetNumInfo() = aNumInfo;
+
+ // die Defaults zuruecksetzen
+ rHWrt.nDfltLeftMargin = 0;
+ rHWrt.nDfltRightMargin = 0;
+ rHWrt.nDfltFirstLineIndent = 0;
+ rHWrt.nDfltTopMargin = 0;
+ rHWrt.nDfltBottomMargin = 0;
+ rHWrt.nLeftMargin = 0;
+ rHWrt.nFirstLineIndent = 0;
+}
+
+void OutHTML_SwFmtOff( Writer& rWrt, const SwHTMLTxtCollOutputInfo& rInfo )
+{
+ SwHTMLWriter & rHWrt = (SwHTMLWriter&)rWrt;
+
+ // wenn es kein Token gibt haben wir auch nichts auszugeben
+ if( !rInfo.aToken.Len() )
+ {
+ rHWrt.FillNextNumInfo();
+ const SwHTMLNumRuleInfo& rNextInfo = *rHWrt.GetNextNumInfo();
+ // Auch in PRE muss eine Bullet-Liste beendet werden
+ if( rInfo.bInNumBulList )
+ {
+
+ const SwHTMLNumRuleInfo& rInfo = rHWrt.GetNumInfo();
+ if( rNextInfo.GetNumRule() != rInfo.GetNumRule() ||
+ rNextInfo.GetDepth() != rInfo.GetDepth() ||
+ rNextInfo.IsNumbered() || rNextInfo.IsRestart() )
+ rHWrt.ChangeParaToken( 0 );
+ OutHTML_NumBulListEnd( rHWrt, rNextInfo );
+ }
+ else if( rNextInfo.GetNumRule() != 0 )
+ rHWrt.ChangeParaToken( 0 );
+
+ return;
+ }
+
+ if( rInfo.ShouldOutputToken() )
+ {
+ if( rHWrt.bLFPossible )
+ rHWrt.OutNewLine( TRUE );
+
+ // fuer BLOCKQUOTE, ADDRESS und DD wird ggf noch ein
+ // Absatz-Token ausgegeben, wenn
+ // - keine Styles geschrieben werden, und
+ // - ein untere Abstand existiert
+ if( rInfo.bParaPossible && rInfo.bOutPara )
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_parabreak, FALSE );
+
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rInfo.aToken.GetBuffer(),
+ FALSE );
+ rHWrt.bLFPossible = !rInfo.aToken.Equals( sHTML_dt ) &&
+ !rInfo.aToken.Equals( sHTML_dd ) &&
+ !rInfo.aToken.Equals( sHTML_li );
+ }
+ if( rInfo.bOutDiv )
+ {
+ rHWrt.DecIndentLevel();
+ if( rHWrt.bLFPossible )
+ rHWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_division, FALSE );
+ rHWrt.bLFPossible = TRUE;
+ }
+
+ // ggf. eine Aufzaehlung- oder Numerierungsliste beenden
+ if( rInfo.bInNumBulList )
+ {
+ rHWrt.FillNextNumInfo();
+ OutHTML_NumBulListEnd( rHWrt, *rHWrt.GetNextNumInfo() );
+ }
+}
+
+
+class HTMLSttEndPos
+{
+ xub_StrLen nStart;
+ xub_StrLen nEnd;
+ SfxPoolItem* pItem;
+
+public:
+
+ HTMLSttEndPos( const SfxPoolItem& rItem, xub_StrLen nStt, xub_StrLen nE );
+ ~HTMLSttEndPos();
+
+ const SfxPoolItem *GetItem() const { return pItem; }
+
+ void SetStart( xub_StrLen nStt ) { nStart = nStt; }
+ xub_StrLen GetStart() const { return nStart; }
+
+ xub_StrLen GetEnd() const { return nEnd; }
+ void SetEnd( xub_StrLen nE ) { nEnd = nE; }
+};
+
+HTMLSttEndPos::HTMLSttEndPos( const SfxPoolItem& rItem, xub_StrLen nStt,
+ xub_StrLen nE ) :
+ nStart( nStt ),
+ nEnd( nE ),
+ pItem( rItem.Clone() )
+{}
+
+HTMLSttEndPos::~HTMLSttEndPos()
+{
+ delete pItem;
+}
+
+typedef HTMLSttEndPos *HTMLSttEndPosPtr;
+SV_DECL_PTRARR( _HTMLEndLst, HTMLSttEndPosPtr, 5, 5 )
+
+enum HTMLOnOffState { HTML_NOT_SUPPORTED, // nicht unterst. Attribut
+ HTML_REAL_VALUE, // Attribut mit Wert
+ HTML_ON_VALUE, // Attribut entspricht On-Tag
+ HTML_OFF_VALUE, // Attribut entspricht Off-Tag
+ HTML_CHRFMT_VALUE, // Attribut fuer Zeichenvorlage
+ HTML_COLOR_VALUE, // Attribut fuer Vordergrundfarbe
+ HTML_STYLE_VALUE, // Attribut muss als Style exp.
+ HTML_DROPCAP_VALUE }; // DropCap-Attributs
+
+
+class HTMLEndPosLst
+{
+ _HTMLEndLst aStartLst; // nach Anfangs-Psoitionen sortierte Liste
+ _HTMLEndLst aEndLst; // nach End-Psotionen sortierte Liste
+
+ SwDoc *pDoc; // das aktuelle Dokument
+ SwDoc* pTemplate; // die HTML-Vorlage (oder 0)
+ const Color* pDfltColor;// die Default-Vordergrund-Farbe
+
+ ULONG nHTMLMode;
+ BOOL bOutStyles : 1; // werden Styles exportiert
+
+
+ // die Position eines Items in der Start-/Ende-Liste suchen
+ USHORT _FindStartPos( const HTMLSttEndPos *pPos ) const;
+ USHORT _FindEndPos( const HTMLSttEndPos *pPos ) const;
+
+ // Eine SttEndPos in die Start- und Ende-Listen eintragen bzw. aus
+ // ihnen loeschen, wobei die Ende-Position bekannt ist
+ void _InsertItem( HTMLSttEndPos *pPos, USHORT nEndPos );
+ void _RemoveItem( USHORT nEndPos );
+
+ // die "Art" es Attributs ermitteln
+ HTMLOnOffState GetHTMLItemState( const SfxPoolItem& rItem );
+
+ // Existiert ein bestimmtes On-Tag-Item
+ BOOL ExistsOnTagItem( USHORT nWhich, xub_StrLen nPos );
+
+ // Existiert ein Item zum ausschalten eines Attributs, das genauso
+ // exportiert wird wie das uebergebene Item im gleichen Bereich?
+ BOOL ExistsOffTagItem( USHORT nWhich, xub_StrLen nStartPos,
+ xub_StrLen nEndPos );
+
+
+ // das Ende eines gesplitteten Items anpassen
+ void FixSplittedItem( HTMLSttEndPos *pPos, USHORT nStartPos,
+ xub_StrLen nNewEnd );
+
+ // Ein Attribut in die Listen eintragen und ggf. aufteilen
+ void InsertItem( const SfxPoolItem& rItem, xub_StrLen nStart,
+ xub_StrLen nEnd );
+
+ // Ein bereits vorhandenes Attribut aufteilen
+ void SplitItem( const SfxPoolItem& rItem, xub_StrLen nStart,
+ xub_StrLen nEnd );
+
+
+public:
+
+ HTMLEndPosLst( SwDoc *pDoc, SwDoc* pTemplate, const Color* pDfltColor,
+ BOOL bOutStyles, ULONG nHTMLMode );
+ ~HTMLEndPosLst();
+
+ // Ein Attribut einfuegen
+ void Insert( const SfxPoolItem& rItem, xub_StrLen nStart, xub_StrLen nEnd,
+ SwHTMLFmtInfos& rFmtInfos, BOOL bParaAttrs=FALSE );
+ void Insert( const SfxItemSet& rItemSet, xub_StrLen nStart, xub_StrLen nEnd,
+ SwHTMLFmtInfos& rFmtInfos, BOOL bDeep,
+ BOOL bParaAttrs=FALSE );
+ void Insert( const SwDrawFrmFmt& rFmt, xub_StrLen nPos,
+ SwHTMLFmtInfos& rFmtInfos );
+
+ void OutStartAttrs( SwHTMLWriter& rHWrt, xub_StrLen nPos );
+ void OutEndAttrs( SwHTMLWriter& rHWrt, xub_StrLen nPos );
+
+ USHORT Count() const { return aEndLst.Count(); }
+
+ BOOL IsHTMLMode( ULONG nMode ) const { return (nHTMLMode & nMode) != 0; }
+};
+
+
+USHORT HTMLEndPosLst::_FindStartPos( const HTMLSttEndPos *pPos ) const
+{
+ for( USHORT i=0; i<aStartLst.Count() && aStartLst[i]!=pPos; i++ )
+ ;
+
+ ASSERT( i != aStartLst.Count(), "Item nicht in Start-Liste gefunden!" );
+
+ return i==aStartLst.Count() ? USHRT_MAX : i;
+}
+
+USHORT HTMLEndPosLst::_FindEndPos( const HTMLSttEndPos *pPos ) const
+{
+ for( USHORT i=0; i<aEndLst.Count() && aEndLst[i]!=pPos; i++ )
+ ;
+
+ ASSERT( i != aEndLst.Count(), "Item nicht in Ende-Liste gefunden" );
+
+ return i==aEndLst.Count() ? USHRT_MAX : i;
+}
+
+
+void HTMLEndPosLst::_InsertItem( HTMLSttEndPos *pPos, USHORT nEndPos )
+{
+ // In der Start-Liste das Attribut hinter allen vorher und an
+ // der gleichen Position gestarteten Attributen einfuegen
+ xub_StrLen nStart = pPos->GetStart();
+ for( USHORT i=0; i < aStartLst.Count() &&
+ aStartLst[i]->GetStart() <= nStart; i++ )
+ ;
+ aStartLst.Insert( pPos, i );
+
+ // die Position in der Ende-Liste wurde uebergeben
+ aEndLst.Insert( pPos, nEndPos );
+}
+
+void HTMLEndPosLst::_RemoveItem( USHORT nEndPos )
+{
+ HTMLSttEndPos *pPos = aEndLst[nEndPos];
+
+ // jetzt Suchen wir es in der Start-Liste
+ USHORT nStartPos = _FindStartPos( pPos );
+ if( nStartPos != USHRT_MAX )
+ aStartLst.Remove( nStartPos, 1 );
+
+ aEndLst.Remove( nEndPos, 1 );
+
+ delete pPos;
+}
+
+HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem )
+{
+ HTMLOnOffState eState = HTML_NOT_SUPPORTED;
+ switch( rItem.Which() )
+ {
+ case RES_CHRATR_POSTURE:
+ switch( ((const SvxPostureItem&)rItem).GetPosture() )
+ {
+ case ITALIC_NORMAL:
+ eState = HTML_ON_VALUE;
+ break;
+ case ITALIC_NONE:
+ eState = HTML_OFF_VALUE;
+ break;
+ default:
+ if( IsHTMLMode(HTMLMODE_SOME_STYLES) )
+ eState = HTML_STYLE_VALUE;
+ break;
+ }
+ break;
+
+ case RES_CHRATR_CROSSEDOUT:
+ switch( ((const SvxCrossedOutItem&)rItem).GetStrikeout() )
+ {
+ case STRIKEOUT_SINGLE:
+ case STRIKEOUT_DOUBLE:
+ eState = HTML_ON_VALUE;
+ break;
+ case STRIKEOUT_NONE:
+ eState = HTML_OFF_VALUE;
+ break;
+ }
+ break;
+
+ case RES_CHRATR_ESCAPEMENT:
+ switch( (const SvxEscapement)
+ ((const SvxEscapementItem&)rItem).GetEnumValue() )
+ {
+ case SVX_ESCAPEMENT_SUPERSCRIPT:
+ case SVX_ESCAPEMENT_SUBSCRIPT:
+ eState = HTML_ON_VALUE;
+ break;
+ case SVX_ESCAPEMENT_OFF:
+ eState = HTML_OFF_VALUE;
+ break;
+ }
+ break;
+
+ case RES_CHRATR_UNDERLINE:
+ switch( ((const SvxUnderlineItem&)rItem).GetUnderline() )
+ {
+ case UNDERLINE_SINGLE:
+ eState = HTML_ON_VALUE;
+ break;
+ case UNDERLINE_NONE:
+ eState = HTML_OFF_VALUE;
+ break;
+ default:
+ if( IsHTMLMode(HTMLMODE_SOME_STYLES) )
+ eState = HTML_STYLE_VALUE;
+ break;
+ }
+ break;
+
+ case RES_CHRATR_WEIGHT:
+ switch( ((const SvxWeightItem&)rItem).GetWeight() )
+ {
+ case WEIGHT_BOLD:
+ eState = HTML_ON_VALUE;
+ break;
+ case WEIGHT_NORMAL:
+ eState = HTML_OFF_VALUE;
+ break;
+ default:
+ if( IsHTMLMode(HTMLMODE_SOME_STYLES) )
+ eState = HTML_STYLE_VALUE;
+ break;
+ }
+ break;
+
+ case RES_CHRATR_BLINK:
+ if( IsHTMLMode(HTMLMODE_BLINK) )
+ eState = ((const SvxBlinkItem&)rItem).GetValue() ? HTML_ON_VALUE
+ : HTML_OFF_VALUE;
+ break;
+
+ case RES_CHRATR_COLOR:
+ eState = HTML_COLOR_VALUE;
+ break;
+
+ case RES_CHRATR_FONT:
+ case RES_CHRATR_FONTSIZE:
+ case RES_TXTATR_INETFMT:
+ eState = HTML_REAL_VALUE;
+ break;
+
+ case RES_TXTATR_CHARFMT:
+ eState = HTML_CHRFMT_VALUE;
+ break;
+
+ case RES_CHRATR_CASEMAP:
+ if( IsHTMLMode(HTMLMODE_SMALL_CAPS) )
+ eState = HTML_STYLE_VALUE;
+
+ case RES_CHRATR_KERNING:
+ if( IsHTMLMode(HTMLMODE_FULL_STYLES) )
+ eState = HTML_STYLE_VALUE;
+ break;
+
+ case RES_CHRATR_BACKGROUND:
+ if( IsHTMLMode(HTMLMODE_SOME_STYLES) )
+ eState = HTML_STYLE_VALUE;
+ break;
+
+ case RES_PARATR_DROP:
+ eState = HTML_DROPCAP_VALUE;
+ break;
+
+// default:
+// eState = HTML_NOT_SUPPORTED;
+// break;
+ }
+
+ return eState;
+}
+
+BOOL HTMLEndPosLst::ExistsOnTagItem( USHORT nWhich, xub_StrLen nPos )
+{
+ for( USHORT i=0; i<aStartLst.Count(); i++ )
+ {
+ HTMLSttEndPos *pTest = aStartLst[i];
+
+ if( pTest->GetStart() > nPos )
+ {
+ // dieses uns alle folgenden Attribute beginnen spaeter
+ break;
+ }
+ else if( pTest->GetEnd() > nPos )
+ {
+ // das Attribut beginnt vor oder an der aktuellen Position
+ // und endet hinter ihr
+ const SfxPoolItem *pItem = pTest->GetItem();
+ if( pItem->Which() == nWhich &&
+ HTML_ON_VALUE == GetHTMLItemState(*pItem) )
+ {
+ // ein On-Tag-Attibut wurde gefunden
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+BOOL HTMLEndPosLst::ExistsOffTagItem( USHORT nWhich, xub_StrLen nStartPos,
+ xub_StrLen nEndPos )
+{
+ if( nWhich != RES_CHRATR_CROSSEDOUT &&
+ nWhich != RES_CHRATR_UNDERLINE &&
+ nWhich != RES_CHRATR_BLINK )
+ {
+ return FALSE;
+ }
+
+ for( USHORT i=0; i<aStartLst.Count(); i++ )
+ {
+ HTMLSttEndPos *pTest = aStartLst[i];
+
+ if( pTest->GetStart() > nStartPos )
+ {
+ // dieses uns alle folgenden Attribute beginnen spaeter
+ break;
+ }
+ else if( pTest->GetStart()==nStartPos &&
+ pTest->GetEnd()==nEndPos )
+ {
+ // das Attribut beginnt vor oder an der aktuellen Position
+ // und endet hinter ihr
+ const SfxPoolItem *pItem = pTest->GetItem();
+ USHORT nTstWhich = pItem->Which() ;
+ if( (nTstWhich == RES_CHRATR_CROSSEDOUT ||
+ nTstWhich == RES_CHRATR_UNDERLINE ||
+ nTstWhich == RES_CHRATR_BLINK) &&
+ HTML_OFF_VALUE == GetHTMLItemState(*pItem) )
+ {
+ // Ein Off-Tag-Attibut wurde gefunden, das genauso
+ // exportiert wird, wie das aktuelle Item
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+void HTMLEndPosLst::FixSplittedItem( HTMLSttEndPos *pPos, xub_StrLen nNewEnd,
+ USHORT nStartPos )
+{
+ // die End-Position entsprechend fixen
+ pPos->SetEnd( nNewEnd );
+
+ // das Item aus der End-Liste entfernen
+ USHORT nEndPos = _FindEndPos( pPos );
+ if( nEndPos != USHRT_MAX )
+ aEndLst.Remove( nEndPos, 1 );
+
+ // es wird von nun an als letztes an der entsprechenden Position
+ // beendet
+ for( nEndPos=0; nEndPos < aEndLst.Count() &&
+ aEndLst[nEndPos]->GetEnd() <= nNewEnd; nEndPos++ )
+ ;
+ aEndLst.Insert( pPos, nEndPos );
+
+ // jetzt noch die spaeter gestarteten Attribute anpassen
+ for( USHORT i=nStartPos+1; i<aStartLst.Count(); i++ )
+ {
+ HTMLSttEndPos *pTest = aStartLst[i];
+ xub_StrLen nTestEnd = pTest->GetEnd();
+ if( pTest->GetStart() >= nNewEnd )
+ {
+ // das Test-Attribut und alle folgenden beginnen, nachdem das
+ // gesplittete Attribut endet
+ break;
+ }
+ else if( nTestEnd > nNewEnd )
+ {
+ // das Test-Attribut beginnt, bevor das gesplittete Attribut
+ // endet und endet danach, muss also auch gesplittet werden
+
+ // das neue Ende setzen
+ pTest->SetEnd( nNewEnd );
+
+ // das Attribut aus der End-Liste entfernen
+ USHORT nEPos = _FindEndPos( pTest );
+ if( nEPos != USHRT_MAX )
+ aEndLst.Remove( nEPos, 1 );
+
+ // es endet jetzt als erstes Attribut an der entsprechenden
+ // Position. Diese Position in der Ende-Liste kennen wir schon.
+ aEndLst.Insert(pTest, nEndPos );
+
+ // den "Rest" des Attributs neu einfuegen
+ InsertItem( *pTest->GetItem(), nNewEnd, nTestEnd );
+ }
+ }
+}
+
+
+void HTMLEndPosLst::InsertItem( const SfxPoolItem& rItem, xub_StrLen nStart,
+ xub_StrLen nEnd )
+{
+ for( USHORT i=0; i<aEndLst.Count(); i++ )
+ {
+ HTMLSttEndPos *pTest = aEndLst[i];
+ xub_StrLen nTestEnd = pTest->GetEnd();
+ if( nTestEnd <= nStart )
+ {
+ // das Test-Attribut endet, bevor das neue beginnt
+ continue;
+ }
+ else if( nTestEnd < nEnd )
+ {
+ // das Test-Attribut endet, bevor das neue endet. Das
+ // neue Attribut muss deshalb aufgesplittet werden
+ _InsertItem( new HTMLSttEndPos( rItem, nStart, nTestEnd ), i );
+ nStart = nTestEnd;
+ }
+ else
+ {
+ // das Test-Attribut (und alle folgenden) endet, bevor das neue
+ // endet
+ break;
+ }
+ }
+
+ // ein Attribut muss noch eingefuegt werden
+ _InsertItem( new HTMLSttEndPos( rItem, nStart, nEnd ), i );
+}
+
+
+
+void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, xub_StrLen nStart,
+ xub_StrLen nEnd )
+{
+ USHORT nWhich = rItem.Which();
+
+ // erstmal muessen wir die alten Items anhand der Startliste suchen
+ // und die neuen Item-Bereiche festlegen
+
+ for( USHORT i=0; i<aStartLst.Count(); i++ )
+ {
+ HTMLSttEndPos *pTest = aStartLst[i];
+ xub_StrLen nTestStart = pTest->GetStart();
+ xub_StrLen nTestEnd = pTest->GetEnd();
+
+ if( nTestStart >= nEnd )
+ {
+ // dieses und alle nachfolgenden Attribute beginnen spaeter
+ break;
+ }
+ else if( nTestEnd > nStart )
+ {
+ // das Test Attribut endet im zu loeschenenden Bereich
+ const SfxPoolItem *pItem = pTest->GetItem();
+
+ // nur entsprechende On-Tag Attribute muessen beruecksichtigt
+ // werden
+ if( pItem->Which() == nWhich &&
+ HTML_ON_VALUE == GetHTMLItemState( *pItem ) )
+ {
+ BOOL bDelete = TRUE;
+
+ if( nTestStart < nStart )
+ {
+ // der Start des neuen Attribut entspricht
+ // dem neuen Ende des Attribts
+ FixSplittedItem( pTest, nStart, i );
+ bDelete = FALSE;
+ }
+ else
+ {
+ // das Test-Item beginnt erst hinter dem neuen
+ // Ende des Attribts und kann deshalb komplett
+ // geloescht werden
+ aStartLst.Remove( i, 1 );
+ i--;
+
+ USHORT nEndPos = _FindEndPos( pTest );
+ if( nEndPos != USHRT_MAX )
+ aEndLst.Remove( nEndPos, 1 );
+ }
+
+ // ggf den zweiten Teil des gesplitteten Attribts einfuegen
+ if( nTestEnd > nEnd )
+ {
+ InsertItem( *pTest->GetItem(), nEnd, nTestEnd );
+ }
+
+ if( bDelete )
+ delete pTest;
+ }
+ }
+ }
+}
+
+HTMLEndPosLst::HTMLEndPosLst( SwDoc *pD, SwDoc* pTempl,
+ const Color* pDfltCol, BOOL bStyles,
+ ULONG nMode ):
+ pDoc( pD ), pTemplate( pTempl ), pDfltColor( pDfltCol ),
+ bOutStyles( bStyles ), nHTMLMode( nMode )
+{}
+
+HTMLEndPosLst::~HTMLEndPosLst()
+{
+ ASSERT( !aStartLst.Count(), "Start-Liste im Destruktor nicht leer" );
+ ASSERT( !aEndLst.Count(), "End-Liste im Destruktor nicht leer" );
+}
+
+
+
+void HTMLEndPosLst::Insert( const SfxPoolItem& rItem,
+ xub_StrLen nStart, xub_StrLen nEnd,
+ SwHTMLFmtInfos& rFmtInfos, BOOL bParaAttrs )
+{
+ // kein Bereich ?? dann nicht aufnehmen, wird nie wirksam !!
+ if( nStart != nEnd )
+ {
+ BOOL bSet = FALSE, bSplit = FALSE;
+ switch( GetHTMLItemState(rItem) )
+ {
+ case HTML_ON_VALUE:
+ // das Attribut wird ausgegeben, wenn es nicht sowieso
+ // schon an ist
+ if( !ExistsOnTagItem( rItem.Which(), nStart ) )
+ bSet = TRUE;
+ break;
+
+ case HTML_OFF_VALUE:
+ // wenn das entsprechne Attribut an ist, wird es gesplittet,
+ // Zusaetlich wird es aber als Style ausgegeben, wenn es nicht
+ // am ganzen Absatz gesetzt ist, weil es dann ja schon mit dem
+ // ABsatz-Tag ausgegeben wurde.
+ if( ExistsOnTagItem( rItem.Which(), nStart ) )
+ bSplit = TRUE;
+ bSet = bOutStyles && !bParaAttrs &&
+ !ExistsOffTagItem( rItem.Which(), nStart, nEnd );
+ break;
+
+ case HTML_REAL_VALUE:
+ // das Attribut kann immer ausgegeben werden
+ bSet = TRUE;
+ break;
+
+ case HTML_STYLE_VALUE:
+ // Das Attribut kann nur als CSS1 ausgegeben werden. Wenn
+ // es am Absatz gesetzt ist, wurde es schon mit dem
+ // Absatz-Tag ausgegeben. Einzige Ausnahme ist das
+ // Zeichen-Hintergrund-Attribut. Es muss immer wie ein
+ // Hint behandelt werden.
+ bSet = bOutStyles &&
+ (!bParaAttrs || rItem.Which()==RES_CHRATR_BACKGROUND);
+ break;
+
+ case HTML_CHRFMT_VALUE:
+ {
+ ASSERT( RES_TXTATR_CHARFMT == rItem.Which(),
+ "Doch keine Zeichen-Vorlage" );
+ const SwFmtCharFmt& rChrFmt = (const SwFmtCharFmt&)rItem;
+ const SwCharFmt* pFmt = rChrFmt.GetCharFmt();
+
+ const SwHTMLFmtInfo *pFmtInfo;
+ SwHTMLFmtInfo aFmtInfo( pFmt );
+ USHORT nPos;
+ if( rFmtInfos.Seek_Entry( &aFmtInfo, &nPos ) )
+ {
+ pFmtInfo = rFmtInfos[nPos];
+ }
+ else
+ {
+ pFmtInfo = new SwHTMLFmtInfo( pFmt, pDoc, pTemplate,
+ bOutStyles );
+ rFmtInfos.C40_PTR_INSERT( SwHTMLFmtInfo, pFmtInfo );
+ }
+ if( pFmtInfo->aToken.Len() )
+ {
+ // das Zeichenvorlagen-Tag muss vor den harten
+ // Attributen ausgegeben werden
+ InsertItem( rItem, nStart, nEnd );
+ }
+ if( pFmtInfo->pItemSet )
+ {
+ Insert( *pFmtInfo->pItemSet, nStart, nEnd,
+ rFmtInfos, TRUE, bParaAttrs );
+ }
+ }
+ break;
+
+ case HTML_COLOR_VALUE:
+ // Eine Vordergrund-Farbe als Absatz-Attribut wird nur
+ // exportiert, wenn sie nicht der Default-Farbe entspricht.
+ ASSERT( RES_CHRATR_COLOR == rItem.Which(),
+ "Doch keine Vordergrund-Farbe" );
+ bSet = !bParaAttrs || !pDfltColor ||
+ !pDfltColor->IsRGBEqual(
+ ((const SvxColorItem&)rItem).GetValue() );
+ break;
+
+ case HTML_DROPCAP_VALUE:
+ {
+ ASSERT( RES_PARATR_DROP == rItem.Which(),
+ "Doch kein Drop-Cap" );
+ const SwFmtDrop& rDrop = (const SwFmtDrop&)rItem;
+ nEnd = nStart + rDrop.GetChars();
+ if( !bOutStyles )
+ {
+ // Zumindest die Attribute der Zeichenvorlage uebernehmen
+ const SwCharFmt *pCharFmt = rDrop.GetCharFmt();
+ if( pCharFmt )
+ {
+ Insert( pCharFmt->GetAttrSet(), nStart, nEnd,
+ rFmtInfos, TRUE, bParaAttrs );
+ }
+ }
+ else
+ {
+ bSet = TRUE;
+ }
+ }
+ break;
+ }
+
+ if( bSet )
+ InsertItem( rItem, nStart, nEnd );
+ if( bSplit )
+ SplitItem( rItem, nStart, nEnd );
+ }
+}
+
+void HTMLEndPosLst::Insert( const SfxItemSet& rItemSet,
+ xub_StrLen nStart, xub_StrLen nEnd,
+ SwHTMLFmtInfos& rFmtInfos,
+ BOOL bDeep, BOOL bParaAttrs )
+{
+ SfxWhichIter aIter( rItemSet );
+
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( nWhich, bDeep, &pItem ) )
+ {
+ Insert( *pItem, nStart, nEnd, rFmtInfos, bParaAttrs );
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void HTMLEndPosLst::Insert( const SwDrawFrmFmt& rFmt, xub_StrLen nPos,
+ SwHTMLFmtInfos& rFmtInfos )
+{
+ // der Type-Cast ist nur noetig, um nicht seinetwegen
+ // svdrwobt.hxx zu includem
+ const SdrObject* pTextObj =
+ (const SdrObject *)SwHTMLWriter::GetMarqueeTextObj( rFmt );
+
+ if( pTextObj )
+ {
+ // die Edit-Engine-Attribute des Objekts als SW-Attribute holen
+ // und als Hints einsortieren. Wegen der Menge der Hints werden
+ // Styles hierbei nicht beruecksichtigt!
+ const SfxItemSet& rFmtItemSet = rFmt.GetAttrSet();
+ SfxItemSet aItemSet( *rFmtItemSet.GetPool(), RES_CHRATR_BEGIN,
+ RES_CHRATR_END );
+ SwHTMLWriter::GetEEAttrsFromDrwObj( aItemSet, pTextObj, TRUE );
+ BOOL bOutStylesOld = bOutStyles;
+ bOutStyles = FALSE;
+ Insert( aItemSet, nPos, nPos+1, rFmtInfos, FALSE, FALSE );
+ bOutStyles = bOutStylesOld;
+ }
+}
+
+void HTMLEndPosLst::OutStartAttrs( SwHTMLWriter& rHWrt, xub_StrLen nPos )
+{
+ rHWrt.bTagOn = TRUE;
+
+ // die Attribute in der Start-Liste sind aufsteigend sortiert
+ for( USHORT i=0; i< aStartLst.Count(); i++ )
+ {
+ HTMLSttEndPos *pPos = aStartLst[i];
+ xub_StrLen nStart = pPos->GetStart();
+ if( nStart > nPos )
+ {
+ // dieses und alle folgenden Attribute werden erst noch geoeffnet
+ break;
+ }
+ else if( nStart == nPos )
+ {
+ // das Attribut ausgeben
+ Out( aHTMLAttrFnTab, *pPos->GetItem(), rHWrt );
+ }
+ }
+}
+
+void HTMLEndPosLst::OutEndAttrs( SwHTMLWriter& rHWrt, xub_StrLen nPos )
+{
+ rHWrt.bTagOn = FALSE;
+
+ // die Attribute in der End-Liste sind aufsteigend sortiert
+ USHORT i=0;
+ while( i < aEndLst.Count() )
+ {
+ HTMLSttEndPos *pPos = aEndLst[i];
+ xub_StrLen nEnd = pPos->GetEnd();
+
+ if( STRING_MAXLEN==nPos || nEnd == nPos )
+ {
+ Out( aHTMLAttrFnTab, *pPos->GetItem(), rHWrt );
+ _RemoveItem( i );
+ }
+ else if( nEnd > nPos )
+ {
+ // dieses und alle folgenden Attribute werden erst spaeter beendet
+ break;
+ }
+ else
+ {
+ // Das Attribut wird vor der aktuellen Position beendet. Das
+ // darf nicht sein, aber wie koennen trotzdem damit umgehen
+ ASSERT( nEnd >= nPos,
+ "Das Attribut sollte schon laengst beendet sein" );
+ i++;
+ }
+ }
+}
+
+
+/* Ausgabe der Nodes */
+Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode )
+{
+ SwTxtNode * pNd = &((SwTxtNode&)rNode);
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const String& rStr = pNd->GetTxt();
+ xub_StrLen nEnde = rStr.Len();
+
+ // Besonderheit: leere Node und HR-Vorlage (horizontaler Strich)
+ // nur ein <HR> ausgeben
+ USHORT nPoolId = pNd->GetAnyFmtColl().GetPoolFmtId();
+
+ if( !nEnde && (RES_POOLCOLL_HTML_HR==nPoolId ||
+ pNd->GetAnyFmtColl().GetName().EqualsAscii( sHTML_horzrule) ) )
+ {
+ // dann die absatz-gebundenen Grafiken/OLE-Objekte im Absatz
+ // MIB 8.7.97: Ein <PRE> spannen wir um die Linie auf. Dann stimmen
+ // zwar die Abstaende nicht, aber sonst bekommen wir einen leeren
+ // Absatz hinter dem <HR> und das ist noch unschoener.
+ rHTMLWrt.ChangeParaToken( 0 );
+
+ // Alle an dem Node verankerten Rahmen ausgeben
+ rHTMLWrt.OutFlyFrm( rNode.GetIndex(), 0, HTML_POS_ANY );
+
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine(); // Absatz-Tag in eine neue Zeile
+
+ rHTMLWrt.bLFPossible = TRUE;
+
+ ByteString sOut( '<' );
+ sOut += sHTML_horzrule;
+
+ const SfxItemSet* pItemSet = pNd->GetpSwAttrSet();
+ if( !pItemSet )
+ {
+ rWrt.Strm() << sOut.GetBuffer() << '>';
+ return rHTMLWrt;
+ }
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pItemSet->GetItemState( RES_LR_SPACE, FALSE, &pItem ))
+ {
+ USHORT nLeft = ((SvxLRSpaceItem*)pItem)->GetLeft();
+ USHORT nRight = ((SvxLRSpaceItem*)pItem)->GetRight();
+ if( nLeft || nRight )
+ {
+ const SwFrmFmt& rPgFmt =
+ rHTMLWrt.pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML )->GetMaster();
+
+ const SwFmtFrmSize& rSz = rPgFmt.GetFrmSize();
+ const SvxLRSpaceItem& rLR = rPgFmt.GetLRSpace();
+ const SwFmtCol& rCol = rPgFmt.GetCol();
+
+ long nPageWidth = rSz.GetWidth() - rLR.GetLeft() - rLR.GetRight();
+
+ if( 1 < rCol.GetNumCols() )
+ nPageWidth /= rCol.GetNumCols();
+
+ const SwTableNode* pTblNd = pNd->FindTableNode();
+ if( pTblNd )
+ {
+ const SwTableBox* pBox = pTblNd->GetTable().GetTblBox(
+ pNd->StartOfSectionIndex() );
+ if( pBox )
+ nPageWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
+ }
+
+ ((sOut += ' ') += sHTML_O_width) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ rWrt.OutULong( rHTMLWrt.ToPixel(nPageWidth-nLeft-nRight) );
+
+ ((sOut = ' ') += sHTML_O_align) += '=';
+ if( !nLeft )
+ sOut += sHTML_AL_left;
+ else if( !nRight )
+ sOut += sHTML_AL_right;
+ else
+ sOut += sHTML_AL_center;
+ }
+ }
+ rWrt.Strm() << sOut.GetBuffer();
+ if( SFX_ITEM_SET == pItemSet->GetItemState( RES_BOX, FALSE, &pItem ))
+ {
+ const SvxBoxItem* pBoxItem = (const SvxBoxItem*)pItem;
+ const SvxBorderLine* pBorderLine = pBoxItem->GetBottom();
+ if( pBorderLine )
+ {
+ USHORT nWidth = pBorderLine->GetOutWidth() +
+ pBorderLine->GetInWidth() +
+ pBorderLine->GetDistance();
+ ((sOut = ' ') += sHTML_O_size) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ rWrt.OutULong( rHTMLWrt.ToPixel(nWidth) );
+
+ const Color& rBorderColor = pBorderLine->GetColor();
+ if( !rBorderColor.IsRGBEqual( Color(COL_GRAY) ) )
+ {
+ ((sOut = ' ') += sHTML_O_color) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( rWrt.Strm(), rBorderColor,
+ rHTMLWrt.eDestEnc );
+ }
+
+ if( !pBorderLine->GetInWidth() )
+ {
+ (sOut = ' ') += sHTML_O_noshade;
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+ }
+ }
+ rWrt.Strm() << '>';
+ return rHTMLWrt;
+ }
+
+ // Die leeren Nodes mit 2pt Font-Hoehe und der Stand-Vorlage, die
+ // vor Tabellen und Bereichen eingefuegt werden, nicht exportieren,
+ // Bookmarks oder absatzgebundene Grafiken aber schon.
+ // MIB 21.7.97: Ausserdem auch keine leeren Tabellen-Zellen exportieren.
+ if( !nEnde && (nPoolId == RES_POOLCOLL_STANDARD ||
+ nPoolId == RES_POOLCOLL_TABLE ||
+ nPoolId == RES_POOLCOLL_TABLE_HDLN) )
+ {
+ // Der aktuelle Node ist leer und enthaelt Standard-Vorlage ...
+ const SfxPoolItem* pItem;
+ const SfxItemSet *pItemSet = pNd->GetpSwAttrSet();
+ if( pItemSet && pItemSet->Count() &&
+ SFX_ITEM_SET == pItemSet->GetItemState( RES_CHRATR_FONTSIZE, FALSE, &pItem ) &&
+ 40 == ((const SvxFontHeightItem *)pItem)->GetHeight() )
+ {
+ // ... ausserdem ist die 2pt Schrift eingestellt ...
+ ULONG nNdPos = rWrt.pCurPam->GetPoint()->nNode.GetIndex();
+ const SwNode *pNextNd = rWrt.pDoc->GetNodes()[nNdPos+1];
+ const SwNode *pPrevNd = rWrt.pDoc->GetNodes()[nNdPos-1];
+ BOOL bStdColl = nPoolId == RES_POOLCOLL_STANDARD;
+ if( ( bStdColl && (pNextNd->IsTableNode() ||
+ pNextNd->IsSectionNode()) ) ||
+ ( !bStdColl && pNextNd->IsEndNode() &&
+ pPrevNd->IsStartNode() &&
+ SwTableBoxStartNode==
+ pPrevNd->GetStartNode()->GetStartNodeType() ) )
+ {
+ // ... und er steht vor einer Tabelle ohne einem Bereich
+ rHTMLWrt.OutBookmarks();
+ rHTMLWrt.bLFPossible = !rHTMLWrt.nLastParaToken;
+
+ // Alle an dem Node verankerten Rahmen ausgeben
+ rHTMLWrt.OutFlyFrm( rNode.GetIndex(), 0, HTML_POS_ANY );
+ rHTMLWrt.bLFPossible = FALSE;
+
+ return rWrt;
+ }
+ }
+ }
+
+ // PagePreaks uns PagDescs abfangen
+ BOOL bPageBreakBehind = FALSE;
+ if( rHTMLWrt.bCfgFormFeed &&
+ !(rHTMLWrt.bOutTable || rHTMLWrt.GetFlyFrmFmt()) &&
+ rHTMLWrt.pStartNdIdx->GetIndex() !=
+ rHTMLWrt.pCurPam->GetPoint()->nNode.GetIndex() )
+ {
+ BOOL bPageBreakBefore = FALSE;
+ const SfxPoolItem* pItem;
+ const SfxItemSet* pItemSet = pNd->GetpSwAttrSet();
+
+ if( pItemSet )
+ {
+ if( SFX_ITEM_SET ==
+ pItemSet->GetItemState( RES_PAGEDESC, TRUE, &pItem ) &&
+ ((SwFmtPageDesc *)pItem)->GetPageDesc() )
+ bPageBreakBefore = TRUE;
+ else if( SFX_ITEM_SET ==
+ pItemSet->GetItemState( RES_BREAK, TRUE, &pItem ) )
+ {
+ switch( ((SvxFmtBreakItem *)pItem)->GetBreak() )
+ {
+ case SVX_BREAK_PAGE_BEFORE:
+ bPageBreakBefore = TRUE;
+ break;
+ case SVX_BREAK_PAGE_AFTER:
+ bPageBreakBehind = TRUE;
+ break;
+ case SVX_BREAK_PAGE_BOTH:
+ bPageBreakBefore = TRUE;
+ bPageBreakBehind = TRUE;
+ break;
+ }
+ }
+ }
+
+ if( bPageBreakBefore )
+ rWrt.Strm() << '\f';
+ }
+
+ // eventuell eine Form oeffnen
+ rHTMLWrt.OutForm();
+
+ // An dem Node "verankerte" Seitenegebunde Rahmen ausgeben
+ BOOL bFlysLeft = rHTMLWrt.OutFlyFrm( rNode.GetIndex(),
+ 0, HTML_POS_PREFIX );
+ // An dem Node verankerte Rahmen ausgeben, die vor dem
+ // Absatz-Tag geschrieben werden sollen.
+ if( bFlysLeft )
+ bFlysLeft = rHTMLWrt.OutFlyFrm( rNode.GetIndex(),
+ 0, HTML_POS_BEFORE );
+
+ if( rHTMLWrt.pCurPam->GetPoint()->nNode == rHTMLWrt.pCurPam->GetMark()->nNode )
+ nEnde = rHTMLWrt.pCurPam->GetMark()->nContent.GetIndex();
+
+ // gibt es harte Attribute, die als Optionen geschrieben werden muessen?
+ rHTMLWrt.bTagOn = TRUE;
+
+ // jetzt das Tag des Absatzes ausgeben
+ const SwFmt& rFmt = pNd->GetAnyFmtColl();
+ SwHTMLTxtCollOutputInfo aFmtInfo;
+ BOOL bOldLFPossible = rHTMLWrt.bLFPossible;
+ OutHTML_SwFmt( rWrt, rFmt, pNd->GetpSwAttrSet(), aFmtInfo );
+
+ // Wenn vor dem Absatz-Tag keine neue Zeile aufgemacht wurde, dann
+ // tun wir das jetzt
+ rHTMLWrt.bLFPossible = !rHTMLWrt.nLastParaToken;
+ if( !bOldLFPossible && rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+
+
+ // dann die Bookmarks (inkl. End-Tag)
+ rHTMLWrt.bOutOpts = FALSE;
+ rHTMLWrt.OutBookmarks();
+
+ // jetzt ist noch mal eine gute Gelegenheit fuer ein LF, sofern es noch
+ // erlaubt ist
+ if( rHTMLWrt.bLFPossible &&
+ rHTMLWrt.GetLineLen() >= rHTMLWrt.nWhishLineLen )
+ {
+ rHTMLWrt.OutNewLine();
+ }
+ rHTMLWrt.bLFPossible = FALSE;
+
+ // Text, der aus einer Outline-Numerierung kommt ermitteln
+ xub_StrLen nOffset = 0;
+ String aOutlineTxt;
+ if( pNd->GetOutlineNum() && !pNd->GetNum() )
+ {
+ aOutlineTxt = pNd->GetNumString();
+ nOffset += aOutlineTxt.Len();
+ }
+ if( rHTMLWrt.pFmtFtn )
+ nOffset += rHTMLWrt.GetFootEndNoteSymLen( *rHTMLWrt.pFmtFtn );
+
+ // gibt es harte Attribute, die als Tags geschrieben werden muessen?
+ HTMLEndPosLst aEndPosLst( rWrt.pDoc, rHTMLWrt.pTemplate,
+ rHTMLWrt.pDfltColor, rHTMLWrt.bCfgOutStyles,
+ rHTMLWrt.GetHTMLMode() );
+ if( aFmtInfo.pItemSet )
+ {
+ aEndPosLst.Insert( *aFmtInfo.pItemSet, 0, nEnde + nOffset,
+ rHTMLWrt.aChrFmtInfos, FALSE, TRUE );
+ }
+
+
+ if( aOutlineTxt.Len() || rHTMLWrt.pFmtFtn )
+ {
+ // Absatz-Attribute ausgeben, damit der Text die Attribute des
+ // Absatzes bekommt.
+ aEndPosLst.OutStartAttrs( rHTMLWrt, 0 );
+
+ // Theoretisch muesste man hier die Zeichen-Vorlage der Numerierung
+ // beachten. Da man die ueber die UI nicht setzen kann, ignorieren
+ // wir sie erstmal.
+
+ if( aOutlineTxt.Len() )
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aOutlineTxt,
+ rHTMLWrt.eDestEnc );
+
+ if( rHTMLWrt.pFmtFtn )
+ {
+ rHTMLWrt.OutFootEndNoteSym( *rHTMLWrt.pFmtFtn );
+ rHTMLWrt.pFmtFtn = 0;
+ }
+ }
+
+ // erstmal den Start berichtigen. D.h. wird nur ein Teil vom Satz
+ // ausgegeben, so muessen auch da die Attribute stimmen!!
+ rHTMLWrt.bTxtAttr = TRUE;
+
+ USHORT nAttrPos = 0;
+ xub_StrLen nStrPos = rHTMLWrt.pCurPam->GetPoint()->nContent.GetIndex();
+ const SwTxtAttr * pHt = 0;
+ USHORT nCntAttr = pNd->HasHints() ? pNd->GetSwpHints().Count() : 0;
+ if( nCntAttr && nStrPos > *( pHt = pNd->GetSwpHints()[ 0 ] )->GetStart() )
+ {
+ // Ok, es gibt vorher Attribute, die ausgegeben werden muessen
+ do {
+ aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset );
+
+ nAttrPos++;
+ if( RES_TXTATR_FIELD == pHt->Which() ) // Felder nicht
+ continue; // ausgeben
+
+ if( pHt->GetEnd() )
+ {
+ xub_StrLen nHtEnd = *pHt->GetEnd(),
+ nHtStt = *pHt->GetStart();
+ if( !rHTMLWrt.bWriteAll && nHtEnd <= nStrPos )
+ continue;
+
+ // leere Hints am Anfang nicht beachten, oder ??
+ if( nHtEnd == nHtStt )
+ continue;
+
+ // Attribut in die Liste aufnehemen
+ if( rHTMLWrt.bWriteAll )
+ aEndPosLst.Insert( pHt->GetAttr(), nHtStt + nOffset,
+ nHtEnd + nOffset,
+ rHTMLWrt.aChrFmtInfos );
+ else
+ {
+ xub_StrLen nTmpStt = nHtStt < nStrPos ? nStrPos : nHtStt;
+ xub_StrLen nTmpEnd = nHtEnd < nEnde ? nHtEnd : nEnde;
+ aEndPosLst.Insert( pHt->GetAttr(), nTmpStt + nOffset,
+ nTmpEnd + nOffset,
+ rHTMLWrt.aChrFmtInfos );
+ }
+ continue;
+ // aber nicht ausgeben, das erfolgt spaeter !!
+ }
+
+ } while( nAttrPos < nCntAttr && nStrPos >
+ *( pHt = pNd->GetSwpHints()[ nAttrPos ] )->GetStart() );
+
+ // dann gebe mal alle gesammelten Attribute von der String-Pos aus
+ aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset );
+ aEndPosLst.OutStartAttrs( rHTMLWrt, nStrPos + nOffset );
+ }
+
+ BOOL bWriteBreak = (HTML_PREFORMTXT_ON != rHTMLWrt.nLastParaToken);
+ if( bWriteBreak && pNd->GetNum() &&
+ NO_NUMBERING != pNd->GetNum()->GetLevel() )
+ bWriteBreak = FALSE;
+
+ xub_StrLen nPreSplitPos = 0;
+ for( ; nStrPos < nEnde; nStrPos++ )
+ {
+ aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset );
+
+ // Die an der aktuellen Position verankerten Rahmen ausgeben
+ if( bFlysLeft )
+ bFlysLeft = rHTMLWrt.OutFlyFrm( rNode.GetIndex(),
+ nStrPos, HTML_POS_INSIDE );
+
+ BOOL bOutChar = TRUE;
+ const SwTxtAttr * pTxtHt = 0;
+ if( nAttrPos < nCntAttr && *pHt->GetStart() == nStrPos
+ && nStrPos != nEnde )
+ {
+ do {
+ if( pHt->GetEnd() )
+ {
+ if( RES_CHRATR_KERNING == pHt->Which() &&
+ rHTMLWrt.IsHTMLMode(HTMLMODE_FIRSTLINE) &&
+ *pHt->GetEnd() - nStrPos == 1 &&
+ ' ' == rStr.GetChar(nStrPos) &&
+ ((const SvxKerningItem&)pHt->GetAttr()).GetValue() > 0 )
+ {
+ // Wenn erlaubt, wird das Ding als Spacer exportiert
+
+ bOutChar = FALSE; // Space nicht ausgeben
+ bWriteBreak = FALSE; // der Absatz ist aber auch nicht leer
+
+ OutHTML_HoriSpacer( rWrt,
+ ((const SvxKerningItem&)pHt->GetAttr()).GetValue() );
+
+ // Der Hint braucht nun doch nicht weiter
+ // beruecksichtigt werden.
+ }
+ else if( *pHt->GetEnd() != nStrPos )
+ {
+ // Hints mit Ende einsortieren, wenn sie keinen
+ // leeren Bereich aufspannen (Hints, die keinen
+ // Bereich aufspannen werden ignoriert
+ aEndPosLst.Insert( pHt->GetAttr(), nStrPos + nOffset,
+ *pHt->GetEnd() + nOffset,
+ rHTMLWrt.aChrFmtInfos );
+ }
+ else
+ {
+#if 0
+ // leere Hinst gleich ausgeben
+ rHTMLWrt.bTagOn = TRUE;
+ Out( aHTMLAttrFnTab, pHt->GetAttr(), rHTMLWrt );
+ rHTMLWrt.bTagOn = FALSE;
+ Out( aHTMLAttrFnTab, pHt->GetAttr(), rHTMLWrt );
+#endif
+ }
+ }
+ else
+ {
+ // Hints ohne-Ende werden als letztes ausgebeben
+ ASSERT( !pTxtHt,
+ "Wieso gibt es da schon ein Attribut ohne Ende?" );
+ if( rHTMLWrt.nTxtAttrsToIgnore>0 )
+ {
+ rHTMLWrt.nTxtAttrsToIgnore--;
+ }
+ else
+ {
+ pTxtHt = pHt;
+ bWriteBreak = FALSE; // der Absatz ist aber auch nicht leer
+ }
+ bOutChar = FALSE; // keine 255 ausgeben
+ }
+ } while( ++nAttrPos < nCntAttr && nStrPos ==
+ *( pHt = pNd->GetSwpHints()[ nAttrPos ] )->GetStart() );
+ }
+
+ // Manche Draw-Formate koennen auch noch Attribute mitbringen
+ if( pTxtHt && RES_TXTATR_FLYCNT == pTxtHt->Which() )
+ {
+ const SwFrmFmt* pFrmFmt =
+ ((const SwFmtFlyCnt &)pTxtHt->GetAttr()).GetFrmFmt();
+
+ if( RES_DRAWFRMFMT == pFrmFmt->Which() )
+ aEndPosLst.Insert( *((const SwDrawFrmFmt *)pFrmFmt),
+ nStrPos + nOffset,
+ rHTMLWrt.aChrFmtInfos );
+ }
+
+ aEndPosLst.OutEndAttrs( rHTMLWrt, nStrPos + nOffset );
+ aEndPosLst.OutStartAttrs( rHTMLWrt, nStrPos + nOffset );
+
+ if( pTxtHt )
+ {
+ rHTMLWrt.bLFPossible = !rHTMLWrt.nLastParaToken && nStrPos > 0 &&
+ rStr.GetChar(nStrPos-1) == ' ';
+ Out( aHTMLAttrFnTab, pTxtHt->GetAttr(), rHTMLWrt );
+ rHTMLWrt.bLFPossible = FALSE;
+ }
+
+ if( bOutChar )
+ {
+ sal_Unicode c = rStr.GetChar( nStrPos );
+ // versuche nach ungefaehr 255 Zeichen eine neue Zeile zu
+ // beginnen, aber nicht in PRE und nur bei Spaces
+ // MIB 15.4.99: Auf Wunsch von ST wird in Mails auch in einem
+ // PRE ganz bewusst umgebrocheni (#64159#).
+ if( ' '==c && (!rHTMLWrt.nLastParaToken || rHTMLWrt.HasCId()) )
+ {
+ xub_StrLen nLineLen;
+ if( rHTMLWrt.nLastParaToken )
+ nLineLen = nStrPos - nPreSplitPos;
+ else
+ nLineLen = rHTMLWrt.GetLineLen();
+
+ xub_StrLen nWordLen = rStr.Search( ' ', nStrPos+1 );
+ if( nWordLen == STRING_NOTFOUND )
+ nWordLen = nEnde;
+ nWordLen -= nStrPos;
+
+ if( nLineLen >= rHTMLWrt.nWhishLineLen ||
+ (nLineLen+nWordLen) >= rHTMLWrt.nWhishLineLen )
+ {
+ rHTMLWrt.OutNewLine();
+ bOutChar = FALSE;
+ if( rHTMLWrt.nLastParaToken )
+ nPreSplitPos = nStrPos+1;
+ }
+ }
+
+ if( bOutChar )
+ {
+ if( 0x0a == c )
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_linebreak );
+ else
+ HTMLOutFuncs::Out_Char( rWrt.Strm(), c, rHTMLWrt.eDestEnc );
+
+ // Wenn das letzte Zeichen eines Absatzed ein harter
+ // Zeilen-Umbruch ist brauchen wir noch ein <BR> mehr, weil
+ // Netscape & Co in diesem Fall fuer den naechsten Absatz
+ // nicht in die naechste Zeile gehen.
+ bWriteBreak = (0x0a == c) &&
+ (HTML_PREFORMTXT_ON != rHTMLWrt.nLastParaToken);
+ }
+ }
+ }
+
+
+ BOOL bEndAttrsWritten = aEndPosLst.Count() > 0;
+ aEndPosLst.OutEndAttrs( rHTMLWrt, STRING_MAXLEN );
+
+ // Die an der letzten Position verankerten Rahmen ausgeben
+ if( bFlysLeft )
+ bFlysLeft = rHTMLWrt.OutFlyFrm( rNode.GetIndex(),
+ nEnde, HTML_POS_INSIDE );
+ ASSERT( !bFlysLeft, "Es wurden nicht alle Rahmen gespeichert!" );
+
+ rHTMLWrt.bTxtAttr = FALSE;
+
+ if( bWriteBreak )
+ {
+ BOOL bEndOfCell = rHTMLWrt.bOutTable &&
+ rWrt.pCurPam->GetPoint()->nNode.GetIndex() ==
+ rWrt.pCurPam->GetMark()->nNode.GetIndex();
+
+ if( bEndOfCell && !nEnde &&
+ rHTMLWrt.IsHTMLMode(HTMLMODE_NBSP_IN_TABLES) )
+ {
+ // Wenn der letzte Absatz einer Tabellezelle leer ist und
+ // wir fuer den MS-IE exportieren, schreiben wir statt eines
+ // <BR> ein &nbsp;
+ rWrt.Strm() << '&' << sHTML_S_nbsp << ';';
+ }
+ else
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_linebreak );
+ const SvxULSpaceItem& rULSpace =
+ (const SvxULSpaceItem &)pNd->GetSwAttrSet().Get(RES_UL_SPACE);
+ if( rULSpace.GetLower() > 0 && !bEndOfCell &&
+ !rHTMLWrt.IsHTMLMode(HTMLMODE_NO_BR_AT_PAREND) )
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_linebreak );
+ rHTMLWrt.bLFPossible = TRUE;
+ }
+ }
+
+ if( rHTMLWrt.bClearLeft || rHTMLWrt.bClearRight )
+ {
+ const sal_Char *pStr;
+ if( rHTMLWrt.bClearLeft )
+ {
+ if( rHTMLWrt.bClearRight )
+ pStr = sHTML_AL_all;
+ else
+ pStr = sHTML_AL_left;
+ }
+ else
+ pStr = sHTML_AL_right;
+
+ ByteString sOut( sHTML_linebreak );
+ (((sOut += ' ') += sHTML_O_clear) += '=') += pStr;
+
+ HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), sOut.GetBuffer() );
+ rHTMLWrt.bClearLeft = FALSE;
+ rHTMLWrt.bClearRight = FALSE;
+
+ rHTMLWrt.bLFPossible = TRUE;
+ }
+
+ // wenn ein LF nicht schon erlaubt ist wird es erlaubt, wenn der
+ // Absatz mit einem ' ' endet
+ if( !rHTMLWrt.bLFPossible && !rHTMLWrt.nLastParaToken &&
+ nEnde > 0 && ' ' == rStr.GetChar(nEnde-1) )
+ rHTMLWrt.bLFPossible = TRUE;
+
+ rHTMLWrt.bTagOn = FALSE;
+ OutHTML_SwFmtOff( rWrt, aFmtInfo );
+
+ // eventuell eine Form schliessen
+ rHTMLWrt.OutForm( FALSE );
+
+ if( bPageBreakBehind )
+ rWrt.Strm() << '\f';
+
+ return rHTMLWrt;
+}
+
+
+ULONG SwHTMLWriter::ToPixel( ULONG nVal ) const
+{
+ if( Application::GetDefaultDevice() && nVal )
+ {
+ nVal = Application::GetDefaultDevice()->LogicToPixel(
+ Size( nVal, nVal ), MapMode( MAP_TWIP ) ).Width();
+ if( !nVal ) // wo ein Twip ist sollte auch ein Pixel sein
+ nVal = 1;
+ }
+ return nVal;
+}
+
+
+static Writer& OutHTML_CSS1Attr( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ // wenn gerade Hints geschrieben werden versuchen wir den Hint als
+ // CSS1-Attribut zu schreiben
+
+ if( ((SwHTMLWriter&)rWrt).bCfgOutStyles && ((SwHTMLWriter&)rWrt).bTxtAttr )
+ OutCSS1_HintSpanTag( rWrt, rHt );
+
+ return rWrt;
+}
+
+
+/* File CHRATR.HXX: */
+
+static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const Color& rColor = ((const SvxColorItem&)rHt).GetValue();
+
+ // die Default-Farbe nur Schreiben, wenn sie als Hint vorkommt
+ //if( rHTMLWrt.bTagOn && !rHTMLWrt.bTxtAttr && rHTMLWrt.pDfltColor
+ // && rColor == *rHTMLWrt.pDfltColor )
+ // return rWrt;
+
+ if( !rHTMLWrt.bTxtAttr && rHTMLWrt.bCfgOutStyles && rHTMLWrt.bCfgPreferStyles )
+ {
+ // Font-Farbe nicht als Tag schreiben, wenn Styles normalen Tags
+ // vorgezogen werden
+ return rWrt;
+ }
+
+ if( rHTMLWrt.bTagOn )
+ {
+ ByteString sOut( '<' );
+ (((sOut += sHTML_font) += ' ') += sHTML_O_color) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( rWrt.Strm(), rColor ) << '>';
+ }
+ else
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_font, FALSE );
+
+ return rWrt;
+}
+
+
+static Writer& OutHTML_SwPosture( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const FontItalic nPosture = ((const SvxPostureItem&)rHt).GetPosture();
+ if( ITALIC_NORMAL == nPosture )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_italic, rHTMLWrt.bTagOn );
+ }
+ else if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr )
+ {
+ // vielleicht als CSS1-Attribut ?
+ OutCSS1_HintSpanTag( rWrt, rHt );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ if( rHTMLWrt.bTagOn )
+ {
+ String aNames;
+ SwHTMLWriter::PrepareFontList( ((const SvxFontItem&)rHt), aNames, 0,
+ rHTMLWrt.IsHTMLMode(HTMLMODE_FONT_GENERIC) );
+ ByteString sOut( '<' );
+ (((sOut += sHTML_font) += ' ') += sHTML_O_face) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aNames, rHTMLWrt.eDestEnc )
+ << "\">";
+ }
+ else
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_font , FALSE );
+
+ return rWrt;
+}
+
+static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ if( rHTMLWrt.bTagOn )
+ {
+ ByteString sOut( '<' );
+ sOut += sHTML_font;
+
+ UINT32 nHeight = ((const SvxFontHeightItem&)rHt).GetHeight();
+ USHORT nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
+ (((sOut += ' ') += sHTML_O_size) += '=')
+ += ByteString::CreateFromInt32( nSize );
+ rWrt.Strm() << sOut.GetBuffer();
+
+ if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr &&
+ rHTMLWrt.aFontHeights[nSize-1] != nHeight )
+ {
+ // wenn die Groesse keiner HTML-Groesse entspricht,
+ // wird sie noch zusatzlich als Style-Option exportiert
+ OutCSS1_HintStyleOpt( rWrt, rHt );
+ }
+ rWrt.Strm() << '>';
+ }
+ else
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_font, FALSE );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutHTML_SwWeight( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const FontWeight nBold = ((const SvxWeightItem&)rHt).GetWeight();
+ if( WEIGHT_BOLD == nBold )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_bold, rHTMLWrt.bTagOn );
+ }
+ else if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr )
+ {
+ // vielleicht als CSS1-Attribut ?
+ OutCSS1_HintSpanTag( rWrt, rHt );
+ }
+
+ return rWrt;
+}
+
+
+static Writer& OutHTML_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ // Wegen Netscape schrieben wir hier STRIKE und nicht S raus!
+ const FontStrikeout nStrike = ((const SvxCrossedOutItem&)rHt).GetStrikeout();
+ if( STRIKEOUT_NONE != nStrike )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_strike, rHTMLWrt.bTagOn );
+ }
+ else if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr )
+ {
+ // vielleicht als CSS1-Attribut ?
+ OutCSS1_HintSpanTag( rWrt, rHt );
+ }
+
+ return rWrt;
+}
+
+
+static Writer& OutHTML_SvxEscapement( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const SvxEscapement eEscape =
+ (const SvxEscapement)((const SvxEscapementItem&)rHt).GetEnumValue();
+ const sal_Char *pStr = 0;
+ switch( eEscape )
+ {
+ case SVX_ESCAPEMENT_SUPERSCRIPT: pStr = sHTML_superscript; break;
+ case SVX_ESCAPEMENT_SUBSCRIPT: pStr = sHTML_subscript; break;
+ }
+
+ if( pStr )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), pStr, rHTMLWrt.bTagOn );
+ }
+ else if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr )
+ {
+ // vielleicht als CSS1-Attribut ?
+ OutCSS1_HintSpanTag( rWrt, rHt );
+ }
+
+ return rWrt;
+}
+
+
+
+static Writer& OutHTML_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const FontUnderline eUnder = ((const SvxUnderlineItem&)rHt).GetUnderline();
+ if( UNDERLINE_NONE != eUnder )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_underline, rHTMLWrt.bTagOn );
+ }
+ else if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr )
+ {
+ // vielleicht als CSS1-Attribut ?
+ OutCSS1_HintSpanTag( rWrt, rHt );
+ }
+
+ return rWrt;
+}
+
+
+static Writer& OutHTML_SwFlyCnt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+ SwFmtFlyCnt& rFlyCnt = (SwFmtFlyCnt&)rHt;
+
+ const SwFrmFmt& rFmt = *rFlyCnt.GetFrmFmt();
+ const SdrObject *pSdrObj = 0;
+
+ SwHTMLFrmType eType =
+ (SwHTMLFrmType)rHTMLWrt.GuessFrmType( rFmt, pSdrObj );
+ BYTE nMode = aHTMLOutFrmAsCharTable[eType][rHTMLWrt.nExportMode];
+ rHTMLWrt.OutFrmFmt( nMode, rFmt, pSdrObj );
+ return rWrt;
+}
+
+static Writer& OutHTML_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ HTMLOutFuncs::Out_Char( rWrt.Strm(), ((SwFmtHardBlank&)rHt).GetChar(),
+ ((SwHTMLWriter&)rWrt).eDestEnc );
+ return rWrt;
+}
+
+// Das ist jetzt unser Blink-Item. Blinkend wird eingeschaltet, indem man
+// das Item auf TRUE setzt!
+static Writer& OutHTML_SwBlink( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts || !rHTMLWrt.IsHTMLMode(HTMLMODE_BLINK) )
+ return rWrt;
+
+ if( ((const SvxBlinkItem&)rHt).GetValue() )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_blink, rHTMLWrt.bTagOn );
+ }
+ else if( rHTMLWrt.bCfgOutStyles && rHTMLWrt.bTxtAttr )
+ {
+ // vielleicht als CSS1-Attribut ?
+ OutCSS1_HintSpanTag( rWrt, rHt );
+ }
+
+ return rWrt;
+}
+
+Writer& OutHTML_INetFmt( Writer& rWrt, const SwFmtINetFmt& rINetFmt, BOOL bOn )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ String aURL( rINetFmt.GetValue() );
+ const SvxMacroTableDtor *pMacTable = rINetFmt.GetMacroTbl();
+ BOOL bEvents = pMacTable != 0 && pMacTable->Count() > 0;
+
+ // Gibt es ueberhaupt etwas auszugeben?
+ if( !aURL.Len() && !bEvents && !rINetFmt.GetName().Len() )
+ return rWrt;
+
+ // Tag aus? Dann nur ein </A> ausgeben.
+ if( !bOn )
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_anchor, FALSE );
+ return rWrt;
+ }
+
+ ByteString sOut( '<' );
+ sOut += sHTML_anchor;
+ rWrt.Strm() << sOut.GetBuffer();
+
+#define REL_HACK
+#ifdef REL_HACK
+ String sRel;
+#endif
+
+ if( aURL.Len() || bEvents )
+ {
+#ifdef REL_HACK
+ String sTmp( aURL );
+ sTmp.ToUpperAscii();
+ xub_StrLen nPos = sTmp.SearchAscii( "\" REL=" );
+ if( nPos!=STRING_NOTFOUND )
+ {
+ sRel = aURL.Copy( nPos+1 );
+ aURL.Erase( nPos );
+ }
+#endif
+ aURL.EraseLeadingChars().EraseTrailingChars();
+
+ ((sOut = ' ') += sHTML_O_href) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ aURL = INetURLObject::AbsToRel( aURL, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ else
+ sOut.Erase();
+
+ if( rINetFmt.GetName().Len() )
+ {
+ ((sOut += ' ') += sHTML_O_name) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rINetFmt.GetName(),
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ const String& rTarget = rINetFmt.GetTargetFrame();
+ if( rTarget.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_target) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rTarget, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+#ifdef REL_HACK
+ if( sRel.Len() )
+ sOut += ByteString( sRel, RTL_TEXTENCODING_ASCII_US );
+#endif
+ if( sOut.Len() )
+ rWrt.Strm() << sOut.GetBuffer();
+
+ if( bEvents )
+ HTMLOutFuncs::Out_Events( rWrt.Strm(), *pMacTable, aAnchorEventTable,
+ rHTMLWrt.bCfgStarBasic, rHTMLWrt.eDestEnc );
+ rWrt.Strm() << ">";
+
+ return rWrt;
+}
+
+static Writer& OutHTML_SwFmtINetFmt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const SwFmtINetFmt& rINetFmt = (const SwFmtINetFmt&)rHt;
+
+ if( rHTMLWrt.bTagOn )
+ {
+ // ggf. ein noch offenes Attribut voruebergehend beenden
+ if( rHTMLWrt.aINetFmts.Count() )
+ {
+ SwFmtINetFmt *pINetFmt =
+ rHTMLWrt.aINetFmts[ rHTMLWrt.aINetFmts.Count()-1 ];
+ OutHTML_INetFmt( rWrt, *pINetFmt, FALSE );
+ }
+
+ // jetzt das neue aufmachen
+ OutHTML_INetFmt( rWrt, rINetFmt, TRUE );
+
+ // und merken
+ const SwFmtINetFmt *pINetFmt = new SwFmtINetFmt( rINetFmt );
+ rHTMLWrt.aINetFmts.C40_INSERT( SwFmtINetFmt, pINetFmt,
+ rHTMLWrt.aINetFmts.Count() );
+ }
+ else
+ {
+ // das
+ OutHTML_INetFmt( rWrt, rINetFmt, FALSE );
+
+ ASSERT( rHTMLWrt.aINetFmts.Count(), "da fehlt doch ein URL-Attribut" );
+ if( rHTMLWrt.aINetFmts.Count() )
+ {
+ // das eigene Attribut vom Stack holen
+ SwFmtINetFmt *pINetFmt =
+ rHTMLWrt.aINetFmts[ rHTMLWrt.aINetFmts.Count()-1 ];
+
+ rHTMLWrt.aINetFmts.Remove( rHTMLWrt.aINetFmts.Count()-1, 1 );
+ delete pINetFmt;
+ }
+
+ if( rHTMLWrt.aINetFmts.Count() )
+ {
+ // es ist noch ein Attribut auf dem Stack, das wieder geoeffnet
+ // werden muss
+ SwFmtINetFmt *pINetFmt =
+ rHTMLWrt.aINetFmts[ rHTMLWrt.aINetFmts.Count()-1 ];
+ OutHTML_INetFmt( rWrt, *pINetFmt, TRUE );
+ }
+ }
+
+ return rWrt;
+}
+
+static Writer& OutHTML_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bOutOpts )
+ return rWrt;
+
+ const SwFmtCharFmt& rChrFmt = (const SwFmtCharFmt&)rHt;
+ const SwCharFmt* pFmt = rChrFmt.GetCharFmt();
+
+ if( !pFmt )
+ {
+ return rWrt;
+ }
+
+ SwHTMLFmtInfo aFmtInfo( pFmt );
+ USHORT nPos;
+ if( !rHTMLWrt.aChrFmtInfos.Seek_Entry( &aFmtInfo, &nPos ) )
+ return rWrt;
+
+ const SwHTMLFmtInfo *pFmtInfo = rHTMLWrt.aChrFmtInfos[nPos];
+ ASSERT( pFmtInfo, "Wieso gint es keine Infos ueber die Zeichenvorlage?" );
+
+ if( rHTMLWrt.bTagOn )
+ {
+ ByteString sOut( '<' );
+ if( pFmtInfo->aToken.Len() > 0 )
+ sOut += pFmtInfo->aToken;
+ else
+ sOut += sHTML_span;
+ if( rHTMLWrt.bCfgOutStyles && pFmtInfo->aClass.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_class) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), pFmtInfo->aClass,
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+ else
+ {
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(),
+ pFmtInfo->aToken.Len() ? pFmtInfo->aToken.GetBuffer()
+ : sHTML_span,
+ FALSE );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutHTML_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( !rHTMLWrt.bOutOpts || !rHTMLWrt.bTagOn )
+ return rWrt;
+
+ SvxAdjustItem& rAdjust = (SvxAdjustItem&)rHt;
+ const sal_Char* pStr = 0;
+ switch( rAdjust.GetAdjust() )
+ {
+ case SVX_ADJUST_CENTER: pStr = sHTML_AL_center; break;
+ case SVX_ADJUST_LEFT: pStr = sHTML_AL_left; break;
+ case SVX_ADJUST_RIGHT: pStr = sHTML_AL_right; break;
+ case SVX_ADJUST_BLOCK: pStr = sHTML_AL_justify; break;
+ }
+ if( pStr )
+ {
+ ByteString sOut( ' ' );
+ ((sOut += sHTML_O_align) += '=') += pStr;
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+
+ return rWrt;
+}
+
+/*
+ * lege hier die Tabellen fuer die HTML-Funktions-Pointer auf
+ * die Ausgabe-Funktionen an.
+ * Es sind lokale Strukturen, die nur innerhalb der HTML-DLL
+ * bekannt sein muessen.
+ */
+
+
+SwAttrFnTab aHTMLAttrFnTab = {
+/* RES_CHRATR_CASEMAP */ OutHTML_CSS1Attr,
+/* RES_CHRATR_CHARSETCOLOR */ 0,
+/* RES_CHRATR_COLOR */ OutHTML_SvxColor,
+/* RES_CHRATR_CONTOUR */ 0,
+/* RES_CHRATR_CROSSEDOUT */ OutHTML_SwCrossedOut,
+/* RES_CHRATR_ESCAPEMENT */ OutHTML_SvxEscapement,
+/* RES_CHRATR_FONT */ OutHTML_SvxFont,
+/* RES_CHRATR_FONTSIZE */ OutHTML_SvxFontHeight,
+/* RES_CHRATR_KERNING */ OutHTML_CSS1Attr,
+/* RES_CHRATR_LANGUAGE */ 0,
+/* RES_CHRATR_POSTURE */ OutHTML_SwPosture,
+/* RES_CHRATR_PROPORTIONALFONTSIZE*/0,
+/* RES_CHRATR_SHADOWED */ 0,
+/* RES_CHRATR_UNDERLINE */ OutHTML_SwUnderline,
+/* RES_CHRATR_WEIGHT */ OutHTML_SwWeight,
+/* RES_CHRATR_WORDLINEMODE */ 0,
+/* RES_CHRATR_AUTOKERN */ 0,
+/* RES_CHRATR_BLINK */ OutHTML_SwBlink,
+/* RES_CHRATR_NOHYPHEN */ 0, // Neu: nicht trennen
+/* RES_CHRATR_NOLINEBREAK */ 0, // Neu: nicht umbrechen
+/* RES_CHRATR_BACKGROUND */ OutHTML_CSS1Attr, // Neu: Zeichenhintergrund
+/* RES_CHRATR_CJK_FONT */ 0,
+/* RES_CHRATR_CJK_FONTSIZE */ 0,
+/* RES_CHRATR_CJK_LANGUAGE */ 0,
+/* RES_CHRATR_CJK_POSTURE */ 0,
+/* RES_CHRATR_CJK_WEIGHT */ 0,
+/* RES_CHRATR_CTL_FONT */ 0,
+/* RES_CHRATR_CTL_FONTSIZE */ 0,
+/* RES_CHRATR_CTL_LANGUAGE */ 0,
+/* RES_CHRATR_CTL_POSTURE */ 0,
+/* RES_CHRATR_CTL_WEIGHT */ 0,
+/* RES_CHRATR_WRITING_DIRECTION */ 0,
+/* RES_CHRATR_DUMMY2 */ 0,
+/* RES_CHRATR_DUMMY3 */ 0,
+/* RES_CHRATR_DUMMY4 */ 0,
+/* RES_CHRATR_DUMMY5 */ 0,
+/* RES_CHRATR_DUMMY1 */ 0, // Dummy:
+
+/* RES_TXTATR_INETFMT */ OutHTML_SwFmtINetFmt,
+/* RES_TXTATR_DUMMY4 */ 0,
+/* RES_TXTATR_REFMARK*/ 0,
+/* RES_TXTATR_TOXMARK */ 0,
+/* RES_TXTATR_CHARFMT */ OutHTML_SwTxtCharFmt,
+/* RES_TXTATR_TWO_LINES */ 0,
+/* RES_TXTATR_CJK_RUBY */ 0,
+/* RES_TXTATR_UNKNOWN_CONTAINER */ 0,
+/* RES_TXTATR_DUMMY5 */ 0,
+/* RES_TXTATR_DUMMY6 */ 0,
+
+/* RES_TXTATR_FIELD */ OutHTML_SwFmtFld,
+/* RES_TXTATR_FLYCNT */ OutHTML_SwFlyCnt,
+/* RES_TXTATR_FTN */ OutHTML_SwFmtFtn,
+/* RES_TXTATR_SOFTHYPH */ 0,
+/* RES_TXTATR_HARDBLANK*/ OutHTML_SwHardBlank,
+/* RES_TXTATR_DUMMY1 */ 0, // Dummy:
+/* RES_TXTATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_PARATR_LINESPACING */ 0,
+/* RES_PARATR_ADJUST */ OutHTML_SvxAdjust,
+/* RES_PARATR_SPLIT */ 0,
+/* RES_PARATR_WIDOWS */ 0,
+/* RES_PARATR_ORPHANS */ 0,
+/* RES_PARATR_TABSTOP */ 0,
+/* RES_PARATR_HYPHENZONE*/ 0,
+/* RES_PARATR_DROP */ OutHTML_CSS1Attr,
+/* RES_PARATR_REGISTER */ 0, // neu: Registerhaltigkeit
+/* RES_PARATR_DUMMY1 */ 0, // Dummy:
+/* RES_PARATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_FILL_ORDER */ 0,
+/* RES_FRM_SIZE */ 0,
+/* RES_PAPER_BIN */ 0,
+/* RES_LR_SPACE */ 0,
+/* RES_UL_SPACE */ 0,
+/* RES_PAGEDESC */ 0,
+/* RES_BREAK */ 0,
+/* RES_CNTNT */ 0,
+/* RES_HEADER */ 0,
+/* RES_FOOTER */ 0,
+/* RES_PRINT */ 0,
+/* RES_OPAQUE */ 0,
+/* RES_PROTECT */ 0,
+/* RES_SURROUND */ 0,
+/* RES_VERT_ORIENT */ 0,
+/* RES_HORI_ORIENT */ 0,
+/* RES_ANCHOR */ 0,
+/* RES_BACKGROUND */ 0,
+/* RES_BOX */ 0,
+/* RES_SHADOW */ 0,
+/* RES_FRMMACRO */ 0,
+/* RES_COL */ 0,
+/* RES_KEEP */ 0,
+/* RES_URL */ 0,
+/* RES_EDIT_IN_READONLY */ 0,
+/* RES_LAYOUT_SPLIT */ 0,
+/* RES_FRMATR_DUMMY1 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY2 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY3 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY4 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY5 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY6 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY7 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY8 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY9 */ 0, // Dummy:
+
+/* RES_GRFATR_MIRRORGRF */ 0,
+/* RES_GRFATR_CROPGRF */ 0,
+/* RES_GRFATR_ROTATION */ 0,
+/* RES_GRFATR_LUMINANCE */ 0,
+/* RES_GRFATR_CONTRAST */ 0,
+/* RES_GRFATR_CHANNELR */ 0,
+/* RES_GRFATR_CHANNELG */ 0,
+/* RES_GRFATR_CHANNELB */ 0,
+/* RES_GRFATR_GAMMA */ 0,
+/* RES_GRFATR_INVERT */ 0,
+/* RES_GRFATR_TRANSPARENCY */ 0,
+/* RES_GRFATR_DRWAMODE */ 0,
+/* RES_GRFATR_DUMMY1 */ 0,
+/* RES_GRFATR_DUMMY2 */ 0,
+/* RES_GRFATR_DUMMY3 */ 0,
+/* RES_GRFATR_DUMMY4 */ 0,
+/* RES_GRFATR_DUMMY5 */ 0,
+
+/* RES_BOXATR_FORMAT */ 0,
+/* RES_BOXATR_FORMULA */ 0,
+/* RES_BOXATR_VALUE */ 0
+};
+
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlatr.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.246 2000/09/18 16:04:43 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.245 2000/08/18 13:03:11 jp
+ don't export escaped URLs
+
+ Revision 1.244 2000/08/04 10:55:10 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character
+
+ Revision 1.243 2000/07/31 19:24:25 jp
+ new attributes for CJK/CTL and graphic
+
+ Revision 1.242 2000/06/26 09:51:53 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.241 2000/04/28 14:29:10 mib
+ unicode
+
+ Revision 1.240 2000/04/10 12:20:55 mib
+ unicode
+
+ Revision 1.239 2000/02/11 14:36:52 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.238 1999/12/08 13:50:39 jp
+ Task #70258#: textattr for XMLAttrContainer
+
+ Revision 1.237 1999/09/21 09:48:43 mib
+ multiple text encodings
+
+ Revision 1.236 1999/06/22 06:30:08 MIB
+ #64687#: if a center paragraph contains controls add a div tag
+
+
+ Rev 1.235 22 Jun 1999 08:30:08 MIB
+ #64687#: if a center paragraph contains controls add a div tag
+
+ Rev 1.234 10 Jun 1999 10:33:52 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.233 09 Jun 1999 19:35:54 JP
+ have to change: no cast from GetpApp to SfxApp/OffApp, SfxShell only subclass of SfxApp
+
+ Rev 1.232 15 Apr 1999 13:25:30 MIB
+ #64159#: Beim Versenden von Mails auch in PRE umbrechen
+
+ Rev 1.231 23 Mar 1999 15:27:32 MIB
+ #63049#: Relative Einzuege in Numerierungen
+
+ Rev 1.230 17 Mar 1999 16:45:20 MIB
+ #63049#: Numerierungen mit relativen Abstaenden
+
+ Rev 1.229 18 Jan 1999 10:14:38 MIB
+ #60806#: Auch bei <FONT FACE=...> generische Fontnamen exportieren
+
+ Rev 1.228 06 Jan 1999 13:54:42 MIB
+ #60393#: Fuer Nscp4 in Tabellen keine line-spacing und margin-bottom exportieren
+
+ Rev 1.227 06 Jan 1999 10:33:38 MIB
+ #60311#: In Listen fuer nicht-numerierte Absaetze keine <PRE> ausgeben
+
+ Rev 1.226 02 Nov 1998 17:25:58 MIB
+ #58480#: Fuss-/Endnoten
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx
new file mode 100644
index 000000000000..371b46911d18
--- /dev/null
+++ b/sw/source/filter/html/htmlbas.cxx
@@ -0,0 +1,689 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlbas.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#ifndef _SFXINIMGR_HXX //autogen
+#include <svtools/iniman.hxx>
+#endif
+#define _SVSTDARR_STRINGSSORTDTOR
+#include <svtools/svstdarr.hxx>
+#ifndef _SBXCLASS_HXX //autogen
+#include <svtools/sbx.hxx>
+#endif
+#ifndef _BASMGR_HXX //autogen
+#include <basic/basmgr.hxx>
+#endif
+#ifndef _SB_SBSTAR_HXX //autogen
+#include <basic/sbstar.hxx>
+#endif
+#ifndef _SB_SBMOD_HXX //autogen
+#include <basic/sbmod.hxx>
+#endif
+#ifndef _SFX_EVENTCONF_HXX //autogen
+#include <sfx2/evntconf.hxx>
+#endif
+#ifndef _SFXAPP_HXX //autogen
+#include <sfx2/app.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+
+
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+
+#ifndef _SFX_OBJUNO_HXX //autogen
+#include <sfx2/objuno.hxx>
+#endif
+
+#include "doc.hxx"
+#include "docsh.hxx"
+#include "docufld.hxx"
+#include "wrthtml.hxx"
+#include "swhtml.hxx"
+
+
+static HTMLOutEvent __FAR_DATA aBodyEventTable[] =
+{
+ { sHTML_O_SDonload, sHTML_O_onload, SFX_EVENT_OPENDOC },
+ { sHTML_O_SDonunload, sHTML_O_onunload, SFX_EVENT_PREPARECLOSEDOC },
+ { sHTML_O_SDonfocus, sHTML_O_onfocus, SFX_EVENT_ACTIVATEDOC },
+ { sHTML_O_SDonblur, sHTML_O_onblur, SFX_EVENT_DEACTIVATEDOC },
+ { 0, 0, 0 }
+};
+
+
+void SwHTMLParser::NewScript()
+{
+ ParseScriptOptions( aScriptType, eScriptLang, aScriptURL,
+ aBasicLib, aBasicModule );
+
+ BOOL bDownload = aScriptURL.Len();
+ if( bDownload )
+ {
+ // Den Inhalt des Script-Tags ignorieren
+ bIgnoreRawData = TRUE;
+ }
+}
+
+void SwHTMLParser::EndScript()
+{
+ BOOL bInsIntoBasic = FALSE,
+ bInsSrcIntoFld = FALSE;
+
+ switch( eScriptLang )
+ {
+ case HTML_SL_STARBASIC:
+ bInsIntoBasic = TRUE;
+ break;
+ default:
+ bInsSrcIntoFld = TRUE;
+ break;
+ }
+
+
+ bIgnoreRawData = FALSE;
+ aScriptSource.ConvertLineEnd();
+
+// MIB 23.5.97: SGML-Kommentare brauchen nicht mehr entfernt zu werden,
+// weil JS das jetzt selber kann.
+// RemoveSGMLComment( aScriptSource, TRUE );
+
+ // Ausser StarBasic und unbenutzem JavaScript jedes Script oder den
+ // Modulnamen in einem Feld merken merken
+ if( bInsSrcIntoFld )
+ {
+ SwScriptFieldType *pType =
+ (SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD );
+
+ SwScriptField aFld( pType, aScriptType,
+ aScriptURL.Len() ? aScriptURL : aScriptSource,
+ aScriptURL.Len()!=0 );
+ InsertAttr( SwFmtFld( aFld ) );
+ }
+
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( aScriptSource.Len() && pDocSh &&
+ bInsIntoBasic && IsNewDoc() )
+ {
+ // Fuer JavaScript und StarBasic noch ein Basic-Modul anlegen
+ // Das Basic entfernt natuerlich weiterhin keine SGML-Kommentare
+ RemoveSGMLComment( aScriptSource, TRUE );
+
+ SFX_APP()->EnterBasicCall();
+
+ BasicManager *pBasicMan = pDocSh->GetBasicManager();
+ ASSERT( pBasicMan, "Wo ist der BasicManager?" );
+ if( pBasicMan )
+ {
+ StarBASIC *pBasic;
+ if( aBasicLib.Len() )
+ {
+ pBasic = pBasicMan->GetLib( aBasicLib );
+ if( !pBasic )
+ pBasic = pBasicMan->CreateLib( aBasicLib );
+ }
+ else
+ pBasic = pBasicMan->GetStdLib();
+
+ if( pBasic )
+ {
+ if( !aBasicModule.Len() )
+ {
+ BOOL bFound = TRUE;
+ while( bFound )
+ {
+ aBasicModule.AssignAscii( "Modul" );
+ aBasicModule += String::CreateFromInt32(
+ (sal_Int32)(++nSBModuleCnt) );
+ bFound = (pBasic->FindModule( aBasicModule ) != 0);
+ }
+ }
+
+ SbModule *pModule =
+ pBasic->MakeModule( aBasicModule, aScriptSource );
+ if( pModule )
+ pModule->Compile();
+ }
+ }
+
+ SFX_APP()->LeaveBasicCall();
+ }
+
+ aScriptSource.Erase();
+ aScriptType.Erase();
+ aScriptURL.Erase();
+
+ aBasicLib.Erase();
+ aBasicModule.Erase();
+}
+
+void SwHTMLParser::AddScriptSource()
+{
+ // Hier merken wir und nur ein par Strings
+ if( aToken.Len() > 2 &&
+ (HTML_SL_STARBASIC==eScriptLang && aToken.GetChar( 0 ) == '\'') )
+ {
+ xub_StrLen nPos = STRING_NOTFOUND;
+ if( !aBasicLib.Len() )
+ {
+ nPos = aToken.SearchAscii( sHTML_SB_library );
+ if( nPos != STRING_NOTFOUND )
+ {
+ aBasicLib =
+ aToken.Copy( nPos + sizeof(sHTML_SB_library) - 1 );
+ aBasicLib.EraseLeadingChars().EraseTrailingChars();
+ }
+ }
+
+ if( !aBasicModule.Len() && nPos==STRING_NOTFOUND )
+ {
+ nPos = aToken.SearchAscii( sHTML_SB_module );
+ if( nPos != STRING_NOTFOUND )
+ {
+ aBasicModule =
+ aToken.Copy( nPos + sizeof(sHTML_SB_module) - 1 );
+ aBasicModule.EraseLeadingChars().EraseTrailingChars();
+ }
+ }
+
+ if( nPos==STRING_NOTFOUND )
+ {
+ if( aScriptSource.Len() )
+ aScriptSource += '\n';
+ (aScriptSource += aToken);
+ }
+ }
+ else if( aScriptSource.Len() || aToken.Len() )
+ {
+ // Leerzeilen am Anfang werden ignoriert
+ if( aScriptSource.Len() )
+ {
+ aScriptSource += '\n';
+ }
+ else
+ {
+ // Wir stehen hinter dem CR/LF der Zeile davor
+ nScriptStartLineNr = GetLineNr() - 1;
+ }
+ aScriptSource += aToken;
+ }
+}
+
+void SwHTMLParser::InsertBasicDocEvent( USHORT nEvent, const String& rName,
+ ScriptType eScrType,
+ const String& rScrType )
+{
+ ASSERT( rName.Len(), "InsertBasicDocEvent() ohne Macro gerufen" );
+ if( !rName.Len() )
+ return;
+
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ ASSERT( pDocSh, "Wo ist die DocShell?" );
+ if( !pDocSh )
+ return;
+
+ String sEvent( rName );
+ sEvent.ConvertLineEnd();
+ String sScriptType;
+ if( EXTENDED_STYPE == eScrType )
+ sScriptType = rScrType;
+
+ SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig();
+ pECfg->ConfigureEvent( nEvent, SvxMacro( sEvent, sScriptType, eScrType ),
+ pDocSh );
+}
+
+void SwHTMLWriter::OutBasic()
+{
+ if( !bCfgStarBasic )
+ return;
+
+ SFX_APP()->EnterBasicCall();
+
+ BasicManager *pBasicMan = pDoc->GetDocShell()->GetBasicManager();
+ ASSERT( pBasicMan, "Wo ist der Basic-Manager?" );
+ //JP 17.07.96: Bug 29538 - nur das DocumentBasic schreiben
+ if( !pBasicMan || pBasicMan == SFX_APP()->GetBasicManager() )
+ {
+ SFX_APP()->LeaveBasicCall();
+ return;
+ }
+
+ // und jetzt alle StarBasic-Module und alle unbenutzen JavaSrript-Module
+ // ausgeben
+ for( USHORT i=0; i<pBasicMan->GetLibCount(); i++ )
+ {
+ StarBASIC *pBasic = pBasicMan->GetLib( i );
+ const String& rLibName = pBasic->GetName();
+
+ SbxArray *pModules = pBasic->GetModules();
+ for( USHORT j=0; j<pModules->Count(); j++ )
+ {
+ const SbModule *pModule = PTR_CAST( SbModule, pModules->Get(j) );
+ ASSERT( pModule, "Wo ist das Modul?" );
+
+ String sLang(
+ String::CreateFromAscii( SVX_MACRO_LANGUAGE_STARBASIC ) );
+ ScriptType eType = STARBASIC;
+
+ if( 0==i && 0==j )
+ {
+ OutNewLine();
+ ByteString sOut( '<' );
+ sOut.Append( sHTML_meta );
+ sOut.Append( ' ' );
+ sOut.Append( sHTML_O_httpequiv );
+ sOut.Append( "=\"" );
+ sOut.Append( sHTML_META_content_script_type );
+ sOut.Append( "\" " );
+ sOut.Append( sHTML_O_content );
+ sOut.Append( "=\"text/x-" );
+ Strm() << sOut.GetBuffer();
+ // Entities aren't welcome here
+ ByteString sLang8( sLang, eDestEnc );
+ Strm() << sLang8.GetBuffer() << "\">";
+ }
+
+ const String& rModName = pModule->GetName();
+ Strm() << SwHTMLWriter::sNewLine; // nicht einruecken!
+ HTMLOutFuncs::OutScript( Strm(), pModule->GetSource(),
+ sLang, eType, aEmptyStr,
+ &rLibName, &rModName,
+ eDestEnc );
+ }
+ }
+
+ SFX_APP()->LeaveBasicCall();
+}
+
+
+void SwHTMLWriter::OutBasicBodyEvents()
+{
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( !pDocSh )
+ return;
+
+ SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig();
+ ASSERT( pECfg, "Wo ist die Event-Konfiguration?" );
+ if( !pECfg )
+ return;
+
+ SvxMacroTableDtor *pMacTable = pECfg->GetDocEventTable( pDocSh );
+ if( pMacTable && pMacTable->Count() )
+ HTMLOutFuncs::Out_Events( Strm(), *pMacTable, aBodyEventTable,
+ bCfgStarBasic, eDestEnc );
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlbas.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.92 2000/09/18 16:04:43 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.91 2000/08/24 20:17:16 jp
+ Bug #78047#: EndScript - no assert
+
+ Revision 1.90 2000/05/15 10:07:15 os
+ Basic removed
+
+ Revision 1.89 2000/04/28 14:29:11 mib
+ unicode
+
+ Revision 1.88 2000/04/10 12:20:55 mib
+ unicode
+
+ Revision 1.87 2000/03/30 07:31:01 os
+ UNO III
+
+ Revision 1.86 2000/03/16 16:40:32 kz
+ remove include sbjsmod.hxx
+
+ Revision 1.85 2000/03/03 12:44:32 mib
+ Removed JavaScript
+
+ Revision 1.84 1999/11/19 16:40:19 os
+ modules renamed
+
+ Revision 1.83 1999/09/21 09:48:47 mib
+ multiple text encodings
+
+ Revision 1.82 1999/09/17 12:12:45 mib
+ support of multiple and non system text encodings
+
+ Revision 1.81 1999/04/27 14:47:32 JP
+ Bug #65314#: neu: IsJavaScriptEnabled
+
+
+ Rev 1.80 27 Apr 1999 16:47:32 JP
+ Bug #65314#: neu: IsJavaScriptEnabled
+
+ Rev 1.79 27 Jan 1999 09:43:32 OS
+ #56371# TF_ONE51
+
+ Rev 1.78 22 Sep 1998 13:46:50 MIB
+ #56943#: Bei String-Ueberlauf im JavaScript Fehlermeldung ausgeben
+
+ Rev 1.77 11 Sep 1998 15:04:50 MIB
+ generische Events wieder fuer alle Script-Typen erlauben
+
+ Rev 1.76 09 Sep 1998 17:58:10 MIB
+ #55407#: Stat onclosedoc inprepareclodedoc fuer unload-Event benutzen
+
+ Rev 1.75 28 Jul 1998 12:07:12 MIB
+ #52559#: JavaScript-Zeilennummern
+
+ Rev 1.74 27 Jul 1998 10:55:28 MIB
+ #50320#: <SCRIPT SRC=...> wieder aktiviert
+
+ Rev 1.73 08 Jul 1998 17:20:24 MIB
+ StarScript
+
+ Rev 1.72 04 Jul 1998 17:43:48 MIB
+ StarScript in IDE, StarScript-Events
+
+ Rev 1.71 05 May 1998 13:09:28 MIB
+ Scripte aus ANSI-Zeichensetz konvertieren
+
+ Rev 1.70 21 Apr 1998 11:21:46 RG
+ String -> UString
+
+ Rev 1.69 24 Mar 1998 12:36:18 MIB
+ fix #47774#: Nur Dokument-Events exportieren
+
+ Rev 1.68 20 Feb 1998 19:04:28 MA
+ header
+
+ Rev 1.67 20 Feb 1998 15:11:16 MIB
+ include
+
+ Rev 1.66 19 Feb 1998 16:15:02 MIB
+ StarOne-TF: StarOne-Scripte
+
+ Rev 1.65 26 Nov 1997 19:09:18 MA
+ includes
+
+ Rev 1.64 24 Nov 1997 13:49:26 TJ
+ include svhtml.hxx
+
+ Rev 1.63 21 Nov 1997 09:42:40 MIB
+ fix #45422#: Dokument-Basic beim Basic-Import immer anlegen
+
+ Rev 1.62 03 Nov 1997 14:08:42 MA
+ precomp entfernt
+
+ Rev 1.61 09 Oct 1997 14:33:50 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.60 16 Sep 1997 11:11:56 MIB
+ unbenutzte Funktionen entfernt
+
+ Rev 1.59 12 Sep 1997 11:51:58 MIB
+ fix #41136#: &(xxx);-Makros
+
+ Rev 1.58 01 Sep 1997 13:52:46 MIB
+ Zeichensetz-/Zeilenende-Konvertierung fuer Event-Optionen
+
+ Rev 1.57 29 Aug 1997 16:50:28 OS
+ DLL-Umstellung
+
+ Rev 1.56 15 Aug 1997 12:47:48 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.55 11 Aug 1997 14:05:04 OM
+ Headerfile-Umstellung
+
+ Rev 1.54 07 Aug 1997 15:08:56 OM
+ Headerfile-Umstellung
+
+ Rev 1.53 15 Jul 1997 14:07:20 MIB
+ fix: Scripte in System-Zeichensatz wandeln
+
+ Rev 1.52 02 Jul 1997 10:34:40 MIB
+ Assert weg
+
+ Rev 1.51 23 May 1997 16:04:34 MIB
+ Nur noch SGML-Kommentare fuer StarBASIC entfernen
+
+ Rev 1.50 22 May 1997 11:01:30 MIB
+ URL-Flag am Script-Feld
+
+ Rev 1.49 21 May 1997 11:15:04 MIB
+ fix #39768#: <SCRIPT SRC=...> zum Eibindenen externer Scripte
+
+ Rev 1.48 02 May 1997 20:53:00 NF
+ includes weil SfxApplication unbekannt!
+
+ Rev 1.47 11 Apr 1997 14:45:14 MIB
+ fix: Kein Basic/JsvaScript beim einfuegen, JAVA-Basic-IDE-Stuff entfernt
+
+ Rev 1.46 24 Mar 1997 17:41:36 MIB
+ fix #37936#: SCRIPT in SELECT erlauben, opt: OutBasic aus Goodies nutzen
+
+ Rev 1.45 19 Mar 1997 14:43:48 MIB
+ fix #37904#: Vor --> ein // exportieren
+
+ Rev 1.44 23 Feb 1997 14:03:04 MIB
+ LiveScript wie JavaScript behandeln
+
+ Rev 1.43 20 Feb 1997 11:04:52 MIB
+ fix: Script-Sourcen fuer Nicht-JS immer loeschen
+
+ Rev 1.42 11 Feb 1997 16:14:06 HJS
+ fuer segprag
+
+ Rev 1.41 11 Feb 1997 15:53:38 MIB
+ fix #35907# Basic-Source-String loeschen
+
+ Rev 1.40 10 Feb 1997 16:50:20 JP
+ Umstellung JavaScript aufrufen und FrameSet Erkennung
+
+ Rev 1.39 30 Jan 1997 17:31:38 MIB
+ kein JavaScript mehr in Basic-Module
+
+ Rev 1.38 23 Jan 1997 15:02:52 MIB
+ falsches Assert weg
+
+ Rev 1.37 22 Jan 1997 09:27:30 MIB
+ Hack fuer Erkennung von unbenutztem JavaScript richtig gemacht
+
+ Rev 1.36 21 Jan 1997 17:48:44 MIB
+ Events ueber HTMLParser ausgeben
+
+ Rev 1.35 17 Jan 1997 16:44:08 MIB
+ ONFOCUS und ONBLUR am Body-Tag exportieren
+
+ Rev 1.34 16 Jan 1997 19:23:26 MIB
+ JavaScript in Basic-Modulen, unbenutztes JavaScript erkennen
+
+ Rev 1.33 15 Jan 1997 15:34:22 MIB
+ bug fix: auch JavaScript1.1 erkennen, Script-Typ erkennung des HTMLParser nutzen
+
+ Rev 1.32 15 Jan 1997 14:22:40 MIB
+ bug fix: Ohne Medium keine JavaScript laden
+
+ Rev 1.31 13 Jan 1997 12:17:06 MIB
+ JavaScript in Basic Modulen speichern (noch nicht aktiviert)
+
+ Rev 1.30 08 Jan 1997 21:23:00 HJS
+ includes
+
+ Rev 1.29 19 Dec 1996 11:33:56 MIB
+ JavaScript nicht ausfuehren, wenn die Filter-Detection das schon getan hat
+
+ Rev 1.28 18 Dec 1996 14:49:52 MIB
+ Macro-Unstellung am SFX/Script-Unterstuetung am HTMLParser
+
+ Rev 1.27 16 Dec 1996 16:23:36 MIB
+ Bug fix: Script-Felder und Kommentare vor Tabellen
+
+ Rev 1.26 05 Dec 1996 14:44:24 JP
+ Unterscheidung von Basic/JavaScript an den SvxMacros
+
+ Rev 1.25 04 Dec 1996 15:01:16 JP
+ SW_EVENT -> SVX_EVENT/SFX_EVENT
+
+ Rev 1.24 01 Dec 1996 07:51:02 JP
+ JavaScript bis zur 347 ausgebaut (MM)
+
+ Rev 1.23 25 Nov 1996 15:19:14 JP
+ InsertBasicModul: Kommentar an Anfang bis zum ZeilenUmbruch entfernen
+
+ Rev 1.22 23 Nov 1996 13:37:54 JP
+ InsertBasicINetFmtEvent entfernt; wurde ueberfluessig
+
+ Rev 1.21 21 Nov 1996 16:29:10 JP
+ Handler an den Anchor/Images immer speichern
+
+ Rev 1.20 20 Nov 1996 15:09:52 JP
+ Java ueber Eintrag in der Ini freischalten
+
+ Rev 1.19 19 Nov 1996 14:06:18 JP
+ ImageEvents schreiben
+
+ Rev 1.18 15 Nov 1996 18:44:20 JP
+ InsertAndCreate erstmal nur zum Testen
+
+ Rev 1.17 15 Nov 1996 18:25:06 JP
+ JavaScript einfuegen und laufen lassen
+
+ Rev 1.16 13 Nov 1996 14:50:04 JP
+ neu: ScriptFeld am Doc setzen
+
+ Rev 1.15 23 Oct 1996 19:49:00 JP
+ String Umstellung: [] -> GetChar()
+
+ Rev 1.14 09 Oct 1996 13:40:12 MIB
+ Pretty-Printing: Einrueckung auf Absatz-Ebene
+
+ Rev 1.13 19 Sep 1996 12:16:00 MIB
+ StarBasic-Export-Option beachten
+
+ Rev 1.12 02 Sep 1996 18:40:18 JP
+ INetFeld entfernt
+
+ Rev 1.11 21 Aug 1996 16:55:26 MIB
+ Probleme mit dem URLATR-define behoben
+
+ Rev 1.10 21 Aug 1996 14:59:30 MIB
+ Verwendung des URLATTR-defines vervollstaenigt
+
+ Rev 1.9 15 Aug 1996 10:10:46 MIB
+ URL-Attribut exportieren
+
+ Rev 1.8 14 Aug 1996 16:22:22 MIB
+ gcc und msvc: statt *aStr nicht aStr[0] sondern aStr[(USHORT)0]
+
+ Rev 1.7 13 Aug 1996 20:33:14 sdo
+ GCC
+
+ Rev 1.6 06 Aug 1996 12:54:44 MIB
+ Umstellung INet-Felder in INet-Attribut verbereitet
+
+ Rev 1.5 02 Aug 1996 18:41:30 MIB
+ Verwendung von pFlyFmt typsicherer gemacht = bug fix fuer Draw-Formate
+
+ Rev 1.4 19 Jul 1996 15:08:12 JP
+ Bug #29538#: nur das DocBasis schreiben
+
+ Rev 1.3 01 Jul 1996 16:45:12 JP
+ statt SFX_APP pApp benutzen, DocShell muss nicht vorhanden sein (Clipboard)
+
+ Rev 1.2 27 Jun 1996 16:41:38 MIB
+ Kommentare um Basic-Source verbessert entfernen, Includes aufgeraeumt
+
+ Rev 1.1 07 Jun 1996 12:43:10 MIB
+ Macros an INetField/NoTxtNode lesen und schreiben
+
+ Rev 1.0 30 May 1996 15:02:46 MIB
+ Initial revision.
+
+
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
new file mode 100644
index 000000000000..8a20f433d93a
--- /dev/null
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -0,0 +1,2596 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlcss1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#define ITEMID_FONTLIST SID_ATTR_CHAR_FONTLIST
+#include "hintids.hxx"
+
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SFX_WHITER_HXX //autogen
+#include <svtools/whiter.hxx>
+#endif
+#ifndef _INTN_HXX //autogen
+#include <tools/intn.hxx>
+#endif
+#ifndef _SFXDOCFILE_HXX //autogen
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_FLSTITEM_HXX //autogen
+#include <svx/flstitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_KEEPITEM_HXX //autogen
+#include <svx/keepitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include "frmatr.hxx"
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+
+
+#include "doc.hxx"
+#include "pam.hxx"
+#include "ndtxt.hxx"
+#include "poolfmt.hxx"
+#include "docsh.hxx"
+#include "paratr.hxx"
+#include "pagedesc.hxx"
+#include "css1kywd.hxx"
+#include "swcss1.hxx"
+#include "htmlnum.hxx"
+#include "swhtml.hxx"
+
+// Wie viele Zeilen/Zeichen sind fuer DropCaps erlaubt?
+// (Gibt es vielleicht woanders entsprechende Werte?)
+#define MAX_DROPCAP_LINES 9
+#define MAX_DROPCAP_CHARS 9
+
+void lcl_swcss1_setEncoding( SwFmt& rFmt, rtl_TextEncoding eEnc );
+
+/* */
+
+// Implementierung des SwCSS1Parsers (eigentlich swcss1.cxx)
+static struct SwCSS1ItemIds
+{
+ USHORT nFmtBreak;
+ USHORT nFmtPageDesc;
+ USHORT nFmtKeep;
+
+ SwCSS1ItemIds() :
+ nFmtBreak( RES_BREAK ),
+ nFmtPageDesc( RES_PAGEDESC ),
+ nFmtKeep( RES_KEEP )
+ {}
+
+} aItemIds;
+
+void SwCSS1Parser::ChgPageDesc( const SwPageDesc *pPageDesc,
+ const SwPageDesc& rNewPageDesc )
+{
+ USHORT nPageDescs = pDoc->GetPageDescCnt();
+ for( USHORT i=0; i<nPageDescs; i++ )
+ if( pPageDesc == &(pDoc->GetPageDesc(i)) )
+ {
+ pDoc->ChgPageDesc( i, rNewPageDesc );
+ return;
+ }
+
+ ASSERT( i<nPageDescs, "Seitenvorlage nicht gefunden" );
+}
+
+SwCSS1Parser::SwCSS1Parser( SwDoc *pD, ULONG aFHeights[7], BOOL bNewDoc ) :
+ SvxCSS1Parser( pD->GetAttrPool(), MM50/2,
+ (USHORT*)&aItemIds, sizeof(aItemIds) / sizeof(USHORT) ),
+ nDropCapCnt( 0 ), bIsNewDoc( bNewDoc ), pDoc( pD ),
+ bBodyBGColorSet( FALSE ), bBodyBackgroundSet( FALSE ),
+ bBodyTextSet( FALSE ), bBodyLinkSet( FALSE ), bBodyVLinkSet( FALSE ),
+ bSetFirstPageDesc( FALSE ), bSetRightPageDesc( FALSE ),
+ bTableHeaderTxtCollSet( FALSE ), bTableTxtCollSet( FALSE ),
+ bLinkCharFmtsSet( FALSE )
+{
+ aFontHeights[0] = aFHeights[0];
+ aFontHeights[1] = aFHeights[1];
+ aFontHeights[2] = aFHeights[2];
+ aFontHeights[3] = aFHeights[3];
+ aFontHeights[4] = aFHeights[4];
+ aFontHeights[5] = aFHeights[5];
+ aFontHeights[6] = aFHeights[6];
+}
+
+SwCSS1Parser::~SwCSS1Parser()
+{
+}
+
+
+/* */
+
+// Feature: PrintExt
+BOOL SwCSS1Parser::SetFmtBreak( SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rPropInfo )
+{
+ SvxBreak eBreak = SVX_BREAK_NONE;
+ BOOL bKeep = FALSE;
+ BOOL bSetKeep = FALSE, bSetBreak = FALSE, bSetPageDesc = FALSE;
+ const SwPageDesc *pPageDesc = 0;
+ switch( rPropInfo.ePageBreakBefore )
+ {
+ case SVX_CSS1_PBREAK_ALWAYS:
+ eBreak = SVX_BREAK_PAGE_BEFORE;
+ bSetBreak = TRUE;
+ break;
+ case SVX_CSS1_PBREAK_LEFT:
+ pPageDesc = GetLeftPageDesc( TRUE );
+ bSetPageDesc = TRUE;
+ break;
+ case SVX_CSS1_PBREAK_RIGHT:
+ pPageDesc = GetRightPageDesc( TRUE );
+ bSetPageDesc = TRUE;
+ break;
+ case SVX_CSS1_PBREAK_AUTO:
+ bSetBreak = bSetPageDesc = TRUE;
+ break;
+// case SVX_CSS1_PBREAK_AVOID:
+ // Hier koennte man SvxKeepItem am Absatz davor einfuegen
+// break;
+ }
+ switch( rPropInfo.ePageBreakAfter )
+ {
+ case SVX_CSS1_PBREAK_ALWAYS:
+ case SVX_CSS1_PBREAK_LEFT:
+ case SVX_CSS1_PBREAK_RIGHT:
+ // LEFT/RIGHT koennte man auch am Absatz davor setzen
+ eBreak = SVX_BREAK_PAGE_AFTER;
+ bSetBreak = TRUE;
+ break;
+ case SVX_CSS1_PBREAK_AUTO:
+ bSetBreak = bSetKeep = bSetPageDesc = TRUE;
+ break;
+ case SVX_CSS1_PBREAK_AVOID:
+ bKeep = bSetKeep = TRUE;
+ break;
+ }
+
+ if( bSetBreak )
+ rItemSet.Put( SvxFmtBreakItem( eBreak ) );
+ if( bSetPageDesc )
+ rItemSet.Put( SwFmtPageDesc( pPageDesc ) );
+ if( bSetKeep )
+ rItemSet.Put( SvxFmtKeepItem( bKeep ) );
+
+ return bSetBreak;
+}
+// /Feature: PrintExt
+
+static void SetCharFmtAttrs( SwCharFmt *pCharFmt, SfxItemSet& rItemSet )
+{
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_FONTSIZE, FALSE, &pItem ) &&
+ ((const SvxFontHeightItem *)pItem)->GetProp() != 100)
+ {
+ // %-Angaben beim FontHeight-Item werden nicht unterstuetzt
+ rItemSet.ClearItem( RES_CHRATR_FONTSIZE );
+ }
+
+ pCharFmt->SetAttr( rItemSet );
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, FALSE, &pItem ) )
+ {
+ // Ein Brush-Item mit RES_BACKGROUND muss noch in eines mit
+ // RES_CHRATR_BACKGROUND gewandelt werden
+
+ SvxBrushItem aBrushItem( *(const SvxBrushItem *)pItem );
+ aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
+ pCharFmt->SetAttr( aBrushItem );
+ }
+}
+
+void SwCSS1Parser::SetLinkCharFmts()
+{
+ ASSERT( !bLinkCharFmtsSet, "Aufruf von SetLinkCharFmts unnoetig" );
+
+ SvxCSS1MapEntry *pStyleEntry =
+ GetTag( String::CreateFromAscii(sHTML_anchor) );
+ SwCharFmt *pUnvisited = 0, *pVisited = 0;
+ if( pStyleEntry )
+ {
+ SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
+ BOOL bColorSet = (SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
+ FALSE));
+ pUnvisited = GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL );
+ SetCharFmtAttrs( pUnvisited, rItemSet );
+ bBodyLinkSet |= bColorSet;
+
+ pVisited = GetCharFmtFromPool( RES_POOLCHR_INET_VISIT );
+ SetCharFmtAttrs( pVisited, rItemSet );
+ bBodyVLinkSet |= bColorSet;
+ }
+
+ String sTmp( String::CreateFromAscii(sHTML_anchor) );
+ sTmp.Append( ':' );
+ sTmp.AppendAscii( sCSS1_link );
+ pStyleEntry = GetTag( sTmp );
+ if( pStyleEntry )
+ {
+ SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
+ BOOL bColorSet = (SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
+ FALSE));
+ if( !pUnvisited )
+ pUnvisited = GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL );
+ SetCharFmtAttrs( pUnvisited, rItemSet );
+ bBodyLinkSet |= bColorSet;
+ }
+
+ sTmp.AssignAscii( sHTML_anchor );
+ sTmp.Assign( ':' );
+ sTmp.AppendAscii( sCSS1_visited );
+ pStyleEntry = GetTag( sTmp );
+ if( pStyleEntry )
+ {
+ SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
+ BOOL bColorSet = (SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
+ FALSE));
+ if( !pVisited )
+ pVisited = GetCharFmtFromPool( RES_POOLCHR_INET_VISIT );
+ SetCharFmtAttrs( pVisited, rItemSet );
+ bBodyVLinkSet |= bColorSet;
+ }
+
+ bLinkCharFmtsSet = TRUE;
+}
+
+static void SetTxtCollAttrs( SwTxtFmtColl *pColl, SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ SwCSS1Parser *pCSS1Parser )
+{
+ const SfxItemSet& rCollItemSet = pColl->GetAttrSet();
+ const SfxPoolItem *pCollItem, *pItem;
+
+ // linker, rechter Rand und Erstzeilen-Einzug
+ if( (rPropInfo.bLeftMargin || rPropInfo.bRightMargin ||
+ rPropInfo.bTextIndent) &&
+ (!rPropInfo.bLeftMargin || !rPropInfo.bRightMargin ||
+ !rPropInfo.bTextIndent) &&
+ SFX_ITEM_SET == rCollItemSet.GetItemState(RES_LR_SPACE,TRUE,&pCollItem) &&
+ SFX_ITEM_SET == rItemSet.GetItemState(RES_LR_SPACE,FALSE,&pItem) )
+ {
+ const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
+
+ SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem *)pCollItem) );
+ if( rPropInfo.bLeftMargin )
+ aLRItem.SetTxtLeft( pLRItem->GetTxtLeft() );
+ if( rPropInfo.bRightMargin )
+ aLRItem.SetRight( pLRItem->GetRight() );
+ if( rPropInfo.bTextIndent )
+ aLRItem.SetTxtFirstLineOfst( pLRItem->GetTxtFirstLineOfst() );
+
+ rItemSet.Put( aLRItem );
+ }
+
+ // oberer und unterer Rand
+ if( (rPropInfo.bTopMargin || rPropInfo.bBottomMargin) &&
+ (!rPropInfo.bTopMargin || !rPropInfo.bBottomMargin) &&
+ SFX_ITEM_SET == rCollItemSet.GetItemState(RES_UL_SPACE,TRUE,
+ &pCollItem) &&
+ SFX_ITEM_SET == rItemSet.GetItemState(RES_UL_SPACE,FALSE,&pItem) )
+ {
+ const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
+
+ SvxULSpaceItem aULItem( *((const SvxULSpaceItem *)pCollItem) );
+ if( rPropInfo.bTopMargin )
+ aULItem.SetUpper( pULItem->GetUpper() );
+ if( rPropInfo.bBottomMargin )
+ aULItem.SetLower( pULItem->GetLower() );
+
+ rItemSet.Put( aULItem );
+ }
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_FONTSIZE, FALSE,
+ &pItem ) &&
+ ((const SvxFontHeightItem *)pItem)->GetProp() != 100)
+ {
+ // %-Angaben beim FontHeight-Item werden nicht unterstuetzt
+ rItemSet.ClearItem( RES_CHRATR_FONTSIZE );
+ }
+
+// Feature: PrintExt
+ pCSS1Parser->SetFmtBreak( rItemSet, rPropInfo );
+// /Feature: PrintExt
+
+ pColl->SetAttr( rItemSet );
+}
+
+void SwCSS1Parser::SetTableTxtColl( BOOL bHeader )
+{
+ ASSERT( !(bHeader ? bTableHeaderTxtCollSet : bTableTxtCollSet),
+ "Aufruf von SetTableTxtColl unnoetig" );
+
+ USHORT nPoolId;
+ String sTag;
+ if( bHeader )
+ {
+ nPoolId = RES_POOLCOLL_TABLE_HDLN;
+ sTag.AssignAscii( sHTML_tableheader );
+ }
+ else
+ {
+ nPoolId = RES_POOLCOLL_TABLE;
+ sTag.AssignAscii( sHTML_tabledata );
+ }
+
+ SwTxtFmtColl *pColl = 0;
+
+ // The following entries will never be used again and may be changed.
+ SvxCSS1MapEntry *pStyleEntry = GetTag( sTag );
+ if( pStyleEntry )
+ {
+ pColl = GetTxtFmtColl( nPoolId, aEmptyStr );
+ SetTxtCollAttrs( pColl, pStyleEntry->GetItemSet(),
+ pStyleEntry->GetPropertyInfo(), this );
+ }
+
+ String sTmp( sTag );
+ sTmp.Append( ' ' );
+ sTmp.AppendAscii( sHTML_parabreak );
+ pStyleEntry = GetTag( sTmp );
+ if( pStyleEntry )
+ {
+ if( !pColl )
+ pColl = GetTxtFmtColl( nPoolId, aEmptyStr );
+ SetTxtCollAttrs( pColl, pStyleEntry->GetItemSet(),
+ pStyleEntry->GetPropertyInfo(), this );
+ }
+
+ if( bHeader )
+ bTableHeaderTxtCollSet = TRUE;
+ else
+ bTableTxtCollSet = TRUE;
+}
+
+void SwCSS1Parser::SetPageDescAttrs( const SvxBrushItem *pBrush,
+ SfxItemSet *pItemSet )
+{
+ SvxBrushItem aBrushItem;
+ SvxBoxItem aBoxItem;
+ BOOL bSetBrush = pBrush!=0, bSetBox = FALSE;
+ if( pBrush )
+ aBrushItem = *pBrush;
+
+ if( pItemSet )
+ {
+ const SfxPoolItem *pItem = 0;
+ if( SFX_ITEM_SET == pItemSet->GetItemState( RES_BACKGROUND, FALSE,
+ &pItem ) )
+ {
+ // ein Hintergrund wird gesetzt
+ aBrushItem = *((const SvxBrushItem *)pItem);
+ pItemSet->ClearItem( RES_BACKGROUND );
+ bSetBrush = TRUE;
+ }
+
+ if( SFX_ITEM_SET == pItemSet->GetItemState( RES_BOX, FALSE, &pItem ) )
+ {
+ // eine Umrandung wird gesetzt
+ aBoxItem = *((const SvxBoxItem *)pItem);
+ pItemSet->ClearItem( RES_BOX );
+ bSetBox = TRUE;
+ }
+ }
+
+ if( bSetBrush || bSetBox )
+ {
+ static USHORT aPoolIds[] = { RES_POOLPAGE_HTML, RES_POOLPAGE_FIRST,
+ RES_POOLPAGE_LEFT, RES_POOLPAGE_RIGHT };
+ for( USHORT i=0; i<4; i++ )
+ {
+ const SwPageDesc *pPageDesc = GetPageDesc( aPoolIds[i], FALSE );
+ if( pPageDesc )
+ {
+ SwPageDesc aNewPageDesc( *pPageDesc );
+ SwFrmFmt &rMaster = aNewPageDesc.GetMaster();
+ if( bSetBrush )
+ rMaster.SetAttr( aBrushItem );
+ if( bSetBox )
+ rMaster.SetAttr( aBoxItem );
+
+ ChgPageDesc( pPageDesc, aNewPageDesc );
+ }
+ }
+ }
+}
+
+// Feature: PrintExt
+void SwCSS1Parser::SetPageDescAttrs( const SwPageDesc *pPageDesc,
+ SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rPropInfo )
+{
+ if( !pPageDesc )
+ return;
+
+ SwPageDesc aNewPageDesc( *pPageDesc );
+ SwFrmFmt &rMaster = aNewPageDesc.GetMaster();
+ const SfxItemSet& rPageItemSet = rMaster.GetAttrSet();
+ const SfxPoolItem *pPageItem, *pItem;
+ BOOL bChanged = FALSE;
+
+ // linker, rechter Rand und Erstzeilen-Einzug
+ if( (rPropInfo.bLeftMargin || rPropInfo.bRightMargin) &&
+ SFX_ITEM_SET == rItemSet.GetItemState(RES_LR_SPACE,FALSE,&pItem) )
+ {
+ if( (!rPropInfo.bLeftMargin || !rPropInfo.bRightMargin) &&
+ SFX_ITEM_SET == rPageItemSet.GetItemState(RES_LR_SPACE,
+ TRUE,&pPageItem) )
+ {
+ const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
+
+ SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem *)pPageItem) );
+ if( rPropInfo.bLeftMargin )
+ aLRItem.SetLeft( pLRItem->GetLeft() );
+ if( rPropInfo.bRightMargin )
+ aLRItem.SetRight( pLRItem->GetRight() );
+
+ rMaster.SetAttr( aLRItem );
+ }
+ else
+ {
+ rMaster.SetAttr( *pItem );
+ }
+ bChanged = TRUE;
+ }
+
+ // oberer und unterer Rand
+ if( (rPropInfo.bTopMargin || rPropInfo.bBottomMargin) &&
+ SFX_ITEM_SET == rItemSet.GetItemState(RES_UL_SPACE,FALSE,&pItem) )
+ {
+ if( (!rPropInfo.bTopMargin || !rPropInfo.bBottomMargin) &&
+ SFX_ITEM_SET == rPageItemSet.GetItemState(RES_UL_SPACE,
+ TRUE,&pPageItem) )
+ {
+ const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
+
+ SvxULSpaceItem aULItem( *((const SvxULSpaceItem *)pPageItem) );
+ if( rPropInfo.bTopMargin )
+ aULItem.SetUpper( pULItem->GetUpper() );
+ if( rPropInfo.bBottomMargin )
+ aULItem.SetLower( pULItem->GetLower() );
+
+ rMaster.SetAttr( aULItem );
+ }
+ else
+ {
+ rMaster.SetAttr( *pItem );
+ }
+ bChanged = TRUE;
+ }
+
+ // die Groesse
+ if( rPropInfo.eSizeType != SVX_CSS1_STYPE_NONE )
+ {
+ if( rPropInfo.eSizeType == SVX_CSS1_STYPE_TWIP )
+ {
+ rMaster.SetAttr( SwFmtFrmSize( ATT_FIX_SIZE, rPropInfo.nWidth,
+ rPropInfo.nHeight ) );
+ bChanged = TRUE;
+ }
+ else
+ {
+ // Bei "size: auto|portrait|landscape" bleibt die bisherige
+ // Groesse der Vorlage erhalten. Bei "landscape" und "portrait"
+ // wird das Landscape-Flag gesetzt und evtl. die Breite/Hoehe
+ // vertauscht.
+ SwFmtFrmSize aFrmSz( rMaster.GetFrmSize() );
+ BOOL bLandscape = aNewPageDesc.GetLandscape();
+ if( ( bLandscape &&
+ rPropInfo.eSizeType == SVX_CSS1_STYPE_PORTRAIT ) ||
+ ( !bLandscape &&
+ rPropInfo.eSizeType == SVX_CSS1_STYPE_LANDSCAPE ) )
+ {
+ SwTwips nTmp = aFrmSz.GetHeight();
+ aFrmSz.SetHeight( aFrmSz.GetWidth() );
+ aFrmSz.SetWidth( nTmp );
+ rMaster.SetAttr( aFrmSz );
+ aNewPageDesc.SetLandscape( !bLandscape );
+ bChanged = TRUE;
+ }
+ }
+ }
+
+ // Geht das wirklich?
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, FALSE, &pItem ) )
+ {
+ // eine Umrandung wird gesetzt
+ rMaster.SetAttr( *pItem );
+ rItemSet.ClearItem( RES_BACKGROUND );
+ bChanged = TRUE;
+ }
+
+ if( bChanged )
+ ChgPageDesc( pPageDesc, aNewPageDesc );
+}
+// /Feature: PrintExt
+
+const SvxBrushItem& SwCSS1Parser::GetPageDescBackground() const
+{
+ return pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML )
+ ->GetMaster().GetBackground();
+}
+
+static void GetTokenAndClass( const CSS1Selector *pSelector,
+ String& rToken, String& rClass )
+{
+ rToken = pSelector->GetString();
+ rClass.Erase();
+
+ if( CSS1_SELTYPE_ELEM_CLASS == pSelector->GetType() )
+ {
+ xub_StrLen nPos = rToken.Search( '.' );
+ ASSERT( nPos != STRING_NOTFOUND, "kein Punkt in Class-Selektor???" );
+ if( nPos != STRING_NOTFOUND )
+ {
+ rClass = rToken.Copy( nPos+1 );
+ rToken.Erase( nPos );
+ }
+ }
+
+ rToken.ToUpperAscii();
+}
+
+BOOL SwCSS1Parser::StyleParsed( const CSS1Selector *pSelector,
+ SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo )
+{
+ if( !bIsNewDoc )
+ return TRUE;
+
+ CSS1SelectorType eSelType = pSelector->GetType();
+ const CSS1Selector *pNext = pSelector->GetNext();
+
+ if( CSS1_SELTYPE_ID==eSelType && !pNext )
+ {
+ InsertId( pSelector->GetString(), rItemSet, rPropInfo );
+ }
+ else if( CSS1_SELTYPE_CLASS==eSelType && !pNext )
+ {
+ InsertClass( pSelector->GetString(), rItemSet, rPropInfo );
+ }
+ else if( CSS1_SELTYPE_PAGE==eSelType )
+ {
+ if( !pNext ||
+ (CSS1_SELTYPE_PSEUDO == pNext->GetType() &&
+ (pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_left) ||
+ pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_right) ||
+ pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_first)) ) )
+ // || CSS1_SELTYPE_ELEMENT == pNext->GetType() )
+ {
+ String aName;
+ if( pNext )
+ aName = pNext->GetString();
+ InsertPage( aName,
+ pNext != 0 /*CSS1_SELTYPE_PSEUDO == pNext->GetType()*/,
+ rItemSet, rPropInfo );
+ }
+ }
+
+ if( CSS1_SELTYPE_ELEMENT != eSelType &&
+ CSS1_SELTYPE_ELEM_CLASS != eSelType)
+ return TRUE;
+
+ // Token und Class zu dem Selektor holen
+ String aToken, aClass;
+ GetTokenAndClass( pSelector, aToken, aClass );
+ int nToken = GetHTMLToken( aToken );
+
+ // und noch ein ganz par Infos zum naechsten Element
+ CSS1SelectorType eNextType = pNext ? pNext->GetType()
+ : CSS1_SELTYPE_ELEMENT;
+
+ // Erstmal ein par Spezialfaelle
+ if( CSS1_SELTYPE_ELEMENT==eSelType )
+ {
+ switch( nToken )
+ {
+ case HTML_ANCHOR_ON:
+ if( !pNext )
+ {
+ InsertTag( aToken, rItemSet, rPropInfo );
+ return FALSE;
+ }
+ else if( pNext && CSS1_SELTYPE_PSEUDO == eNextType )
+ {
+ // vielleicht A:visited oder A:link
+
+ String aPseudo( pNext->GetString() );
+ aPseudo.ToLowerAscii();
+
+ BOOL bInsert = FALSE;
+ switch( aPseudo.GetChar( 0 ))
+ {
+ case 'l':
+ if( aPseudo.EqualsAscii(sCSS1_link) )
+ {
+ bInsert = TRUE;
+ }
+ break;
+ case 'v':
+ if( aPseudo.EqualsAscii(sCSS1_visited) )
+ {
+ bInsert = TRUE;
+ }
+ break;
+ }
+ if( bInsert )
+ {
+ String sTmp( aToken );
+ (sTmp += ':') += aPseudo;
+ InsertTag( sTmp, rItemSet, rPropInfo );
+ return FALSE;
+ }
+ }
+ break;
+ case HTML_BODY_ON:
+ if( !pNext )
+ {
+ // BODY
+
+ // Den Hintergrund muessen wir vor dem Setzen abfragen,
+ // denn in SetPageDescAttrs wird er geloescht.
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET==rItemSet.GetItemState(RES_BACKGROUND,FALSE,&pItem) )
+ {
+ const SvxBrushItem *pBrushItem =
+ (const SvxBrushItem *)pItem;
+
+ if( !pBrushItem->GetColor().GetTransparency() )
+ bBodyBGColorSet = TRUE;
+ if( GPOS_NONE != pBrushItem->GetGraphicPos() )
+ bBodyBackgroundSet = TRUE;
+ }
+
+ // Border and Padding
+ rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
+
+ // Ein par Attribute muessen an der Seitenvorlage gesetzt werden,
+ // und zwar die, die nicht vererbt werden
+ SetPageDescAttrs( 0, &rItemSet );
+
+ // alle noch uebrigen Optionen koennen an der Standard-Vorlage
+ // gesetzt werden und gelten dann automatisch als defaults
+ if( SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,FALSE) )
+ bBodyTextSet = TRUE;
+ SetTxtCollAttrs(
+ GetTxtCollFromPool( RES_POOLCOLL_STANDARD ),
+ rItemSet, rPropInfo, this );
+
+ return FALSE;
+ }
+ break;
+ }
+ }
+ else if( CSS1_SELTYPE_ELEM_CLASS==eSelType && HTML_ANCHOR_ON==nToken &&
+ !pNext && aClass.Len() >= 9 &&
+ ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0)) )
+ {
+ USHORT nPoolFmtId = 0;
+ if( aClass.EqualsIgnoreCaseAscii(sHTML_sdendnote_sym) )
+ nPoolFmtId = RES_POOLCHR_ENDNOTE;
+ else if( aClass.EqualsIgnoreCaseAscii(sHTML_sdfootnote_sym) )
+ nPoolFmtId = RES_POOLCHR_FOOTNOTE;
+ if( nPoolFmtId )
+ {
+ SetCharFmtAttrs( GetCharFmtFromPool(nPoolFmtId), rItemSet );
+ return FALSE;
+ }
+ }
+
+ // Jetzt werden die Selektoren verarbeitet, die zu einer Absatz-Vorlage
+ // gehoehren
+ USHORT nPoolCollId = 0;
+ switch( nToken )
+ {
+ case HTML_HEAD1_ON:
+ nPoolCollId = RES_POOLCOLL_HEADLINE1;
+ break;
+ case HTML_HEAD2_ON:
+ nPoolCollId = RES_POOLCOLL_HEADLINE2;
+ break;
+ case HTML_HEAD3_ON:
+ nPoolCollId = RES_POOLCOLL_HEADLINE3;
+ break;
+ case HTML_HEAD4_ON:
+ nPoolCollId = RES_POOLCOLL_HEADLINE4;
+ break;
+ case HTML_HEAD5_ON:
+ nPoolCollId = RES_POOLCOLL_HEADLINE5;
+ break;
+ case HTML_HEAD6_ON:
+ nPoolCollId = RES_POOLCOLL_HEADLINE6;
+ break;
+ case HTML_PARABREAK_ON:
+ if( aClass.Len() >= 9 &&
+ ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0)) )
+ {
+ if( aClass.EqualsIgnoreCaseAscii(sHTML_sdendnote) )
+ nPoolCollId = RES_POOLCOLL_ENDNOTE;
+ else if( aClass.EqualsIgnoreCaseAscii(sHTML_sdfootnote) )
+ nPoolCollId = RES_POOLCOLL_FOOTNOTE;
+
+ if( nPoolCollId )
+ aClass = aEmptyStr;
+ else
+ nPoolCollId = RES_POOLCOLL_TEXT;
+ }
+ else
+ {
+ nPoolCollId = RES_POOLCOLL_TEXT;
+ }
+ break;
+ case HTML_ADDRESS_ON:
+ nPoolCollId = RES_POOLCOLL_SENDADRESS;
+ break;
+ case HTML_BLOCKQUOTE_ON:
+ nPoolCollId = RES_POOLCOLL_HTML_BLOCKQUOTE;
+ break;
+ case HTML_DT_ON:
+ nPoolCollId = RES_POOLCOLL_HTML_DT;
+ break;
+ case HTML_DD_ON:
+ nPoolCollId = RES_POOLCOLL_HTML_DD;
+ break;
+ case HTML_PREFORMTXT_ON:
+ nPoolCollId = RES_POOLCOLL_HTML_PRE;
+ break;
+ case HTML_TABLEHEADER_ON:
+ case HTML_TABLEDATA_ON:
+ if( CSS1_SELTYPE_ELEMENT==eSelType && !pNext )
+ {
+ InsertTag( aToken, rItemSet, rPropInfo );
+ return FALSE;
+ }
+ else if( CSS1_SELTYPE_ELEMENT==eSelType && pNext &&
+ (CSS1_SELTYPE_ELEMENT==eNextType ||
+ CSS1_SELTYPE_ELEM_CLASS==eNextType) )
+ {
+ // nicht TH und TD, aber TH P und TD P
+ String aSubToken, aSubClass;
+ GetTokenAndClass( pNext, aSubToken, aSubClass );
+ if( HTML_PARABREAK_ON == GetHTMLToken( aSubToken ) )
+ {
+ aClass = aSubClass;
+ pNext = pNext->GetNext();
+ eNextType = pNext ? pNext->GetType() : CSS1_SELTYPE_ELEMENT;
+
+ if( aClass.Len() || pNext )
+ {
+ nPoolCollId =
+ HTML_TABLEHEADER_ON == nToken ? RES_POOLCOLL_TABLE_HDLN
+ : RES_POOLCOLL_TABLE;
+ }
+ else
+ {
+ String sTmp( aToken );
+ sTmp += ' ';
+ sTmp.AppendAscii( sHTML_parabreak );
+ InsertTag( sTmp, rItemSet, rPropInfo );
+
+ return FALSE;
+ }
+ }
+ }
+ break;
+ }
+
+ if( nPoolCollId )
+ {
+ if( !pNext ||
+ (CSS1_SELTYPE_PSEUDO==eNextType &&
+#ifdef FULL_FIRST_LETTER
+ pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_first_letter)) )
+#else
+ pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_first_letter) &&
+ SVX_ADJUST_LEFT == rPropInfo.eFloat) )
+#endif
+ {
+ // Entweder kein zusammengesetzter Selektor oder
+ // ein X:first-line { float: left; ... }
+
+ // Die Vorlage Suchen bzw. Anlegen
+ SwTxtFmtColl *pColl = GetTxtFmtColl( nPoolCollId, aEmptyStr );
+ if( aClass.Len() )
+ {
+ String aName( pColl->GetName() );
+ AddClassName( aName, aClass );
+
+ SwTxtFmtColl* pParentColl = pColl;
+ pColl = pDoc->FindTxtFmtCollByName( aName );
+ if( !pColl )
+ pColl = pDoc->MakeTxtFmtColl( aName, pParentColl );
+ }
+ if( !pNext )
+ {
+ // nur die Attribute an der Vorlage setzen
+ const SfxPoolItem *pItem;
+ const SvxBoxItem *pBoxItem = 0;
+ if( SFX_ITEM_SET ==
+ pColl->GetAttrSet().GetItemState(RES_BOX,TRUE,&pItem) )
+ pBoxItem = (const SvxBoxItem *)pItem;
+ rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST, pBoxItem );
+ SetTxtCollAttrs( pColl, rItemSet, rPropInfo, this );
+ }
+ else
+ {
+ // ein Drop-Cap-Attribut basteln
+ SwFmtDrop aDrop;
+ aDrop.GetChars() = 1;
+
+ // die Attribute in das DropCap-Attribut einfuegen
+ FillDropCap( aDrop, rItemSet, &pColl->GetName() );
+
+ // Das Attribut nur setzen, wenn float: left angegeben wurde
+ // und das Initial ueber mehrere Zeilen geht. Sonst wird die
+ // ggf. angelegte Zeichen-Vorlage spaeter ueber den Namen
+ // gesucht und gesetzt.
+ if( SVX_ADJUST_LEFT == rPropInfo.eFloat &&
+ aDrop.GetLines() > 1 )
+ {
+ pColl->SetAttr( aDrop );
+ }
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // Jetzt werden die Selektoten verarbeitet, die zu einer Zechenvorlage
+ // gehoehren. Zusammengesetzte gibt es hier allerdings nich nicht.
+ if( pNext )
+ return TRUE;
+
+ SwCharFmt *pCFmt = GetChrFmt( nToken, aEmptyStr );
+ if( pCFmt )
+ {
+ if( aClass.Len() )
+ {
+ String aName( pCFmt->GetName() );
+ AddClassName( aName, aClass );
+ SwCharFmt *pParentCFmt = pCFmt;
+
+ pCFmt = pDoc->FindCharFmtByName( aName );
+ if( !pCFmt )
+ {
+ pCFmt = pDoc->MakeCharFmt( aName, pParentCFmt );
+ pCFmt->SetAuto( FALSE );
+ }
+ }
+
+ SetCharFmtAttrs( pCFmt, rItemSet );
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#ifdef USED
+void SwCSS1Parser::SetFmtAttrs( const SfxItemSet& rItemSet,
+ SwFmt *pChildFmt1,
+ SwFmt *pChildFmt2 )
+{
+ SfxItemIter aIter( rItemSet );
+
+ const SfxItemSet& rItemSet1 = pChildFmt1->GetAttrSet();
+ const SfxItemSet* pItemSet2 = pChildFmt2 ? &pChildFmt2->GetAttrSet() : 0;
+ const SfxPoolItem *pPItem = aIter.FirstItem();
+ while( pPItem )
+ {
+ // wenn das Attribut an einer der abhaengigen Vorlagen nicht gesetzt
+ // ist, muss es dort explizit auf den Wrt gesetzt werden, der
+ // dort bereits aus der Parent-Vorlage geerbt wird.
+
+ USHORT nWhich = pPItem->Which();
+ const SfxPoolItem *pCItem;
+ if( SFX_ITEM_SET != rItemSet1.GetItemState( nWhich, FALSE, &pCItem ) )
+ pChildFmt1->SetAttr( pChildFmt1->GetAttr(nWhich) );
+
+ if( pChildFmt2 &&
+ SFX_ITEM_SET != pItemSet2->GetItemState( nWhich, FALSE, &pCItem ) )
+ pChildFmt2->SetAttr( pChildFmt2->GetAttr(nWhich) );
+
+ // auf zum naechsten Item
+ pPItem = aIter.NextItem();
+ }
+}
+#endif
+
+ULONG SwCSS1Parser::GetFontHeight( USHORT nSize ) const
+{
+ return aFontHeights[ nSize>6 ? 6 : nSize ];
+}
+
+const FontList *SwCSS1Parser::GetFontList() const
+{
+ const FontList *pFList = 0;
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( pDocSh )
+ {
+ const SvxFontListItem *pFListItem =
+ (const SvxFontListItem *)pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
+ if( pFListItem )
+ pFList = pFListItem->GetFontList();
+ }
+
+ return pFList;
+}
+
+/* */
+
+SwCharFmt* SwCSS1Parser::GetChrFmt( USHORT nToken, const String& rClass ) const
+{
+ // die entsprechende Vorlage suchen
+ USHORT nPoolId = 0;
+ const sal_Char* sName = 0;
+ switch( nToken )
+ {
+ case HTML_EMPHASIS_ON: nPoolId = RES_POOLCHR_HTML_EMPHASIS; break;
+ case HTML_CITIATION_ON: nPoolId = RES_POOLCHR_HTML_CITIATION; break;
+ case HTML_STRONG_ON: nPoolId = RES_POOLCHR_HTML_STRONG; break;
+ case HTML_CODE_ON: nPoolId = RES_POOLCHR_HTML_CODE; break;
+ case HTML_SAMPLE_ON: nPoolId = RES_POOLCHR_HTML_SAMPLE; break;
+ case HTML_KEYBOARD_ON: nPoolId = RES_POOLCHR_HTML_KEYBOARD; break;
+ case HTML_VARIABLE_ON: nPoolId = RES_POOLCHR_HTML_VARIABLE; break;
+ case HTML_DEFINSTANCE_ON: nPoolId = RES_POOLCHR_HTML_DEFINSTANCE; break;
+ case HTML_TELETYPE_ON: nPoolId = RES_POOLCHR_HTML_TELETYPE; break;
+
+ case HTML_SHORTQUOTE_ON: sName = sHTML_shortquote; break;
+ case HTML_LANGUAGE_ON: sName = sHTML_language; break;
+ case HTML_AUTHOR_ON: sName = sHTML_author; break;
+ case HTML_PERSON_ON: sName = sHTML_person; break;
+ case HTML_ACRONYM_ON: sName = sHTML_acronym; break;
+ case HTML_ABBREVIATION_ON: sName = sHTML_abbreviation; break;
+ case HTML_INSERTEDTEXT_ON: sName = sHTML_insertedtext; break;
+ case HTML_DELETEDTEXT_ON: sName = sHTML_deletedtext; break;
+ }
+
+ // die Vorlage suchen oder anlegen (geht nur mit Namen)
+ if( !nPoolId && !sName )
+ return 0;
+
+ // Die Vorlage (ohne Class) suchen oder anlegen
+ SwCharFmt *pCFmt = 0;
+ if( nPoolId )
+ {
+ pCFmt = GetCharFmtFromPool( nPoolId );
+ }
+ else
+ {
+ String sCName( String::CreateFromAscii(sName) );
+ pCFmt = pDoc->FindCharFmtByName( sCName );
+ if( !pCFmt )
+ {
+ pCFmt = pDoc->MakeCharFmt( sCName, pDoc->GetDfltCharFmt() );
+ pCFmt->SetAuto( FALSE );
+ }
+ }
+
+ ASSERT( pCFmt, "Keine Zeichen-Vorlage???" );
+
+ // Wenn es eine Klasse gibt, die Klassen-Vorlage suchen aber nicht
+ // neu anlegen.
+ if( rClass.Len() )
+ {
+ String aTmp( pCFmt->GetName() );
+ AddClassName( aTmp, rClass );
+ SwCharFmt *pClassCFmt = pDoc->FindCharFmtByName( aTmp );
+ if( pClassCFmt )
+ {
+ pCFmt = pClassCFmt;
+ }
+ else
+ {
+ SvxCSS1MapEntry *pClass = GetClass( rClass );
+ if( pClass )
+ {
+ pCFmt = pDoc->MakeCharFmt( aTmp, pCFmt );
+ pCFmt->SetAuto( FALSE );
+ SfxItemSet aItemSet( pClass->GetItemSet() );
+ SetCharFmtAttrs( pCFmt, aItemSet );
+ }
+ }
+ }
+
+ return pCFmt;
+}
+
+
+/* */
+
+SwTxtFmtColl *SwCSS1Parser::GetTxtCollFromPool( USHORT nPoolId ) const
+{
+ USHORT nOldArrLen = pDoc->GetTxtFmtColls()->Count();
+
+ SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool( nPoolId );
+
+ if( bIsNewDoc )
+ {
+ USHORT nArrLen = pDoc->GetTxtFmtColls()->Count();
+ for( USHORT i=nOldArrLen; i<nArrLen; i++ )
+ lcl_swcss1_setEncoding( *(*pDoc->GetTxtFmtColls())[i],
+ GetDfltEncoding() );
+ }
+
+ return pColl;
+}
+
+SwCharFmt *SwCSS1Parser::GetCharFmtFromPool( USHORT nPoolId ) const
+{
+ USHORT nOldArrLen = pDoc->GetCharFmts()->Count();
+
+ SwCharFmt *pCharFmt = pDoc->GetCharFmtFromPool( nPoolId );
+
+ if( bIsNewDoc )
+ {
+ USHORT nArrLen = pDoc->GetCharFmts()->Count();
+
+ for( USHORT i=nOldArrLen; i<nArrLen; i++ )
+ lcl_swcss1_setEncoding( *(*pDoc->GetCharFmts())[i],
+ GetDfltEncoding() );
+ }
+
+ return pCharFmt;
+}
+
+SwTxtFmtColl *SwCSS1Parser::GetTxtFmtColl( USHORT nTxtColl,
+ const String& rClass )
+{
+ SwTxtFmtColl* pColl = 0;
+
+ String aClass( rClass );
+ if( RES_POOLCOLL_TEXT == nTxtColl && aClass.Len() >= 9 &&
+ ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0) ) )
+ {
+ if( aClass.EqualsIgnoreCaseAscii(sHTML_sdendnote) )
+ {
+ nTxtColl = RES_POOLCOLL_ENDNOTE;
+ aClass = aEmptyStr;
+ }
+ else if( aClass.EqualsIgnoreCaseAscii(sHTML_sdfootnote) )
+ {
+ nTxtColl = RES_POOLCOLL_FOOTNOTE;
+ aClass = aEmptyStr;
+ }
+ }
+
+ String sName;
+ if( USER_FMT & nTxtColl ) // eine vom Reader angelegte
+ {
+ ASSERT( !this, "Wo kommt die Benutzer-Vorlage her?" );
+ pColl = GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ }
+ else
+ {
+ pColl = GetTxtCollFromPool( nTxtColl );
+ }
+
+ ASSERT( pColl, "Keine Absatz-Vorlage???" );
+ if( aClass.Len() )
+ {
+ String aTmp( pColl->GetName() );
+ AddClassName( aTmp, aClass );
+ SwTxtFmtColl* pClassColl = pDoc->FindTxtFmtCollByName( aTmp );
+
+ if( !pClassColl &&
+ (nTxtColl==RES_POOLCOLL_TABLE ||
+ nTxtColl==RES_POOLCOLL_TABLE_HDLN) )
+ {
+ // Wenn dieser Fall eintritt, dann wurde ein <TD><P CLASS=foo>
+ // gelesen, aber die TD.foo Vorlage nicht gefunden. Dann muessen
+ // wir P.foo nehmen, wenn es sie gibt.
+ SwTxtFmtColl* pCollText =
+ GetTxtCollFromPool( RES_POOLCOLL_TEXT );
+ aTmp = pCollText->GetName();
+ AddClassName( aTmp, aClass );
+ pClassColl = pDoc->FindTxtFmtCollByName( aTmp );
+ }
+
+ if( pClassColl )
+ {
+ pColl = pClassColl;
+ }
+ else
+ {
+ const SvxCSS1MapEntry *pClass = GetClass( aClass );
+ if( pClass )
+ {
+ pColl = pDoc->MakeTxtFmtColl( aTmp, pColl );
+ SfxItemSet aItemSet( pClass->GetItemSet() );
+ SvxCSS1PropertyInfo aPropInfo( pClass->GetPropertyInfo() );
+ aPropInfo.SetBoxItem( aItemSet, MIN_BORDER_DIST );
+ BOOL bPositioned = MayBePositioned( pClass->GetPropertyInfo() );
+ if( bPositioned )
+ aItemSet.ClearItem( RES_BACKGROUND );
+ SetTxtCollAttrs( pColl, aItemSet, aPropInfo,
+ this );
+ }
+ }
+
+ }
+
+ if( pColl )
+ lcl_swcss1_setEncoding( *pColl, GetDfltEncoding() );
+
+ return pColl;
+}
+
+SwPageDesc *SwCSS1Parser::GetMasterPageDesc()
+{
+ return pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML );
+}
+
+static SwPageDesc *FindPageDesc( SwDoc *pDoc, USHORT nPoolId, USHORT& rPage )
+{
+ USHORT nPageDescs = pDoc->GetPageDescCnt();
+ for( rPage=0; rPage < nPageDescs &&
+ pDoc->GetPageDesc(rPage).GetPoolFmtId() != nPoolId; rPage++ )
+ ;
+
+ return rPage < nPageDescs ? &pDoc->_GetPageDesc( rPage ) : 0;
+}
+
+const SwPageDesc *SwCSS1Parser::GetPageDesc( USHORT nPoolId, BOOL bCreate )
+{
+ if( RES_POOLPAGE_HTML == nPoolId )
+ return pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML );
+
+ USHORT nPage;
+ const SwPageDesc *pPageDesc = FindPageDesc( pDoc, nPoolId, nPage );
+ if( !pPageDesc && bCreate )
+ {
+ // Die erste Seite wird aus der rechten Seite erzeugt, wenn es die
+ // gibt.
+ SwPageDesc *pMasterPageDesc = 0;
+ if( RES_POOLPAGE_FIRST == nPoolId )
+ pMasterPageDesc = FindPageDesc( pDoc, RES_POOLPAGE_RIGHT, nPage );
+ if( !pMasterPageDesc )
+ pMasterPageDesc = pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML );
+
+ // Die neue Seitenvorlage entsteht aus dem Master durch kopieren.
+ SwPageDesc *pNewPageDesc = pDoc->GetPageDescFromPool( nPoolId );
+
+ // dazu brauchen wir auch die Nummer der neuen Vorlage
+ pPageDesc = FindPageDesc( pDoc, nPoolId, nPage );
+ ASSERT( pPageDesc==pNewPageDesc, "Seitenvorlage nicht gefunden" );
+
+ pDoc->CopyPageDesc( *pMasterPageDesc, *pNewPageDesc, FALSE );
+
+ // Die Vorlagen an ihren neuen Zweck anpassen.
+ const SwPageDesc *pFollow = 0;
+ BOOL bSetFollowFollow = FALSE;
+ switch( nPoolId )
+ {
+ case RES_POOLPAGE_FIRST:
+ // Wenn es schon eine linke Seite gibt, dann ist das die
+ // Folge-Vorlage, sonst ist es die HTML-Vorlage.
+ pFollow = GetLeftPageDesc();
+ if( !pFollow )
+ pFollow = pMasterPageDesc;
+ break;
+
+ case RES_POOLPAGE_RIGHT:
+ // Wenn die linke Vorlage schon angelegt ist, passiert hier gar
+ // nichts. Sonst wird die linke Vorlage angelegt und sorgt auch
+ // fuer die richtige Verkettung mit der rechten Voralge.
+ GetLeftPageDesc( TRUE );
+ break;
+
+ case RES_POOLPAGE_LEFT:
+ // Die rechte Vorlage wird angelegt, wenn sie noch nicht existiert.
+ // Es findet aber keine Verkettung statt.
+ // Wenn schon eine erste Seitenvorlage existiert, wird die linke
+ // Vorlage die Folge-Vorlage der ersten Seite.
+ pFollow = GetRightPageDesc( TRUE );
+ bSetFollowFollow = TRUE;
+ {
+ const SwPageDesc *pFirstPageDesc = GetFirstPageDesc();
+ if( pFirstPageDesc )
+ {
+ SwPageDesc aNewFirstPageDesc( *pFirstPageDesc );
+ aNewFirstPageDesc.SetFollow( pNewPageDesc );
+ ChgPageDesc( pFirstPageDesc, aNewFirstPageDesc );
+ }
+ }
+ break;
+ }
+
+ if( pFollow )
+ {
+ SwPageDesc aNewPageDesc( *pNewPageDesc );
+ aNewPageDesc.SetFollow( pFollow );
+ ChgPageDesc( pNewPageDesc, aNewPageDesc );
+
+ if( bSetFollowFollow )
+ {
+ SwPageDesc aNewFollowPageDesc( *pFollow );
+ aNewFollowPageDesc.SetFollow( pNewPageDesc );
+ ChgPageDesc( pFollow, aNewFollowPageDesc );
+ }
+ }
+ pPageDesc = pNewPageDesc;
+ }
+
+ return pPageDesc;
+}
+
+
+BOOL SwCSS1Parser::MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
+ BOOL bAutoWidth )
+{
+ // abs-pos
+ // left/top none auto twip perc
+ //
+ // none Z Z - -
+ // auto Z Z - -
+ // twip Z Z S/R -
+ // perc - - - -
+ //
+ // - das Tag wird absolut positioniert und left/top sind beide
+ // gegeben und enthalten auch keine %-Angabe, oder
+ // - das Tag soll fliessen, und
+ // - es wurde eine Breite angegeben (in beiden Faellen noetig)
+ return ( ( SVX_CSS1_POS_ABSOLUTE == rPropInfo.ePosition &&
+ SVX_CSS1_LTYPE_PERCENTAGE != rPropInfo.eLeftType &&
+ SVX_CSS1_LTYPE_PERCENTAGE != rPropInfo.eTopType &&
+ (SVX_CSS1_LTYPE_TWIP == rPropInfo.eLeftType ||
+ SVX_CSS1_LTYPE_TWIP != rPropInfo.eTopType) ) ||
+ ( SVX_ADJUST_END != rPropInfo.eFloat ) ) &&
+ ( bAutoWidth ||
+ SVX_CSS1_LTYPE_TWIP == rPropInfo.eWidthType ||
+ SVX_CSS1_LTYPE_PERCENTAGE == rPropInfo.eWidthType );
+}
+
+
+/* */
+
+void SwCSS1Parser::AddClassName( String& rFmtName, const String& rClass )
+{
+ ASSERT( rClass.Len(), "Style-Klasse ohne Laenge?" );
+
+// ??????????
+// String aTmp( rClass );
+// GetpApp()->GetAppInternational().ToLower( aTmp );
+
+ (rFmtName += '.') += rClass;
+}
+
+/* */
+
+void SwCSS1Parser::FillDropCap( SwFmtDrop& rDrop,
+ SfxItemSet& rItemSet,
+ const String *pName )
+{
+ // die Anzahl der Zeilen entspricht in etwa einer %-Angabe
+ // fuer die Hoehe (was passiert mit absoluten Hoehen???)
+ BYTE nLines = 1;
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_FONTSIZE, FALSE, &pItem ) )
+ {
+ USHORT nProp = ((const SvxFontHeightItem *)pItem)->GetProp();
+ nLines = (BYTE)((nProp + 50) / 100);
+ if( nLines < 1 )
+ nLines = 1;
+ else if( nLines > MAX_DROPCAP_LINES )
+ nLines = MAX_DROPCAP_LINES;
+
+ // Nur wenn nLines>1 ist, wird das Attribut auch gesetzt. Dann
+ // brauchen wir die Font-Hoehe aber auch nicht in der Zeichen-Vorlage.
+ if( nLines > 1 )
+ rItemSet.ClearItem( RES_CHRATR_FONTSIZE );
+ }
+
+ // Bei harter Attributierung (pName==0) koennen wir aufhoehren, wenn
+ // das Initial nur ueber eine Zeile geht.
+#ifdef FULL_FIRST_LETTER
+ if( nLines==1 && !pName )
+#else
+ if( nLines==1 )
+#endif
+ return;
+
+ rDrop.GetLines() = nLines;
+
+ // ein rechter Rand wird der Abstand zum Text!
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_LR_SPACE, FALSE, &pItem ) )
+ {
+ rDrop.GetDistance() =
+ ((const SvxLRSpaceItem *)pItem)->GetRight();
+ rItemSet.ClearItem( RES_LR_SPACE );
+ }
+
+ // Fuer alle anderen Attribute eine Zeichen-Vorlage anlegen
+ if( rItemSet.Count() )
+ {
+ SwCharFmt *pCFmt = 0;
+ String aName;
+ if( pName )
+ {
+ aName = *pName;
+ AddFirstLetterExt( aName );
+ pCFmt = pDoc->FindCharFmtByName( aName );
+ }
+ else
+ {
+ do
+ {
+ aName.AssignAscii( sCSS1_first_letter );
+ aName.Append( ' ' );
+ aName.Append(
+ String::CreateFromInt32( (sal_Int32)(++nDropCapCnt) ) );
+ }
+ while( pDoc->FindCharFmtByName(aName) );
+ }
+
+ if( !pCFmt )
+ {
+ pCFmt = pDoc->MakeCharFmt( aName, pDoc->GetDfltCharFmt() );
+ pCFmt->SetAuto( FALSE );
+ }
+ SetCharFmtAttrs( pCFmt, rItemSet );
+
+ // Die Zeichenvorlage braucht nur im Attribut gesetzt werden, wenn
+ // auch das Attribut gesetzt wird.
+ if( nLines > 1 )
+ rDrop.SetCharFmt( pCFmt );
+ }
+}
+
+/* */
+
+// CSS1-sezifisches des SwHTMLParsers
+
+_HTMLAttr **SwHTMLParser::GetAttrTabEntry( USHORT nWhich )
+{
+ // den zu dem Item gehoehrenden Tabellen-Eintrag ermitteln ...
+ _HTMLAttr **ppAttr = 0;
+ switch( nWhich )
+ {
+ case RES_CHRATR_BLINK:
+ ppAttr = &aAttrTab.pBlink;
+ break;
+ case RES_CHRATR_CASEMAP:
+ ppAttr = &aAttrTab.pCaseMap;
+ break;
+ case RES_CHRATR_COLOR:
+ ppAttr = &aAttrTab.pFontColor;
+ break;
+ case RES_CHRATR_CROSSEDOUT:
+ ppAttr = &aAttrTab.pStrike;
+ break;
+ case RES_CHRATR_ESCAPEMENT:
+ ppAttr = &aAttrTab.pEscapement;
+ break;
+ case RES_CHRATR_FONT:
+ ppAttr = &aAttrTab.pFont;
+ break;
+ case RES_CHRATR_FONTSIZE:
+ ppAttr = &aAttrTab.pFontHeight;
+ break;
+ case RES_CHRATR_KERNING:
+ ppAttr = &aAttrTab.pKerning;
+ break;
+ case RES_CHRATR_POSTURE:
+ ppAttr = &aAttrTab.pItalic;
+ break;
+ case RES_CHRATR_UNDERLINE:
+ ppAttr = &aAttrTab.pUnderline;
+ break;
+ case RES_CHRATR_WEIGHT:
+ ppAttr = &aAttrTab.pBold;
+ break;
+ case RES_CHRATR_BACKGROUND:
+ ppAttr = &aAttrTab.pCharBrush;
+ break;
+
+ case RES_PARATR_LINESPACING:
+ ppAttr = &aAttrTab.pLineSpacing;
+ break;
+ case RES_PARATR_ADJUST:
+ ppAttr = &aAttrTab.pAdjust;
+ break;
+
+ case RES_LR_SPACE:
+ ppAttr = &aAttrTab.pLRSpace;
+ break;
+ case RES_UL_SPACE:
+ ppAttr = &aAttrTab.pULSpace;
+ break;
+ case RES_BOX:
+ ppAttr = &aAttrTab.pBox;
+ break;
+ case RES_BACKGROUND:
+ ppAttr = &aAttrTab.pBrush;
+ break;
+ case RES_BREAK:
+ ppAttr = &aAttrTab.pBreak;
+ break;
+ case RES_PAGEDESC:
+ ppAttr = &aAttrTab.pPageDesc;
+ break;
+ case RES_PARATR_SPLIT:
+ ppAttr = &aAttrTab.pSplit;
+ break;
+ case RES_PARATR_WIDOWS:
+ ppAttr = &aAttrTab.pWidows;
+ break;
+ case RES_PARATR_ORPHANS:
+ ppAttr = &aAttrTab.pOrphans;
+ break;
+ case RES_KEEP:
+ ppAttr = &aAttrTab.pKeep;
+ break;
+ }
+
+ return ppAttr;
+}
+
+void SwHTMLParser::NewStyle()
+{
+ String sType;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ if( HTML_O_TYPE==pOption->GetToken() )
+ sType = pOption->GetString();
+ }
+
+ bIgnoreRawData = sType.Len() &&
+ !sType.GetToken(0,';').EqualsAscii(sCSS_mimetype);
+}
+
+void SwHTMLParser::EndStyle()
+{
+ bIgnoreRawData = FALSE;
+
+ if( aStyleSource.Len() )
+ {
+ pCSS1Parser->ParseStyleSheet( aStyleSource );
+ aStyleSource.Erase();
+ }
+}
+
+BOOL SwHTMLParser::FileDownload( const String& rURL,
+ String& rStr )
+{
+ // View wegschmeissen (wegen Reschedule)
+ ViewShell *pOldVSh = CallEndAction();
+ SetSaveBaseURL();
+
+ // Ein Medium anlegen
+ SfxMedium aDLMedium( rURL, STREAM_READ | STREAM_SHARE_DENYWRITE, FALSE );
+ aDLMedium.SetTransferPriority( SFX_TFPRIO_SYNCHRON );
+
+ // Medium registrieren, damit abgebrochen werden kann
+ if( pDoc->GetDocShell() )
+ pDoc->GetDocShell()->RegisterTransfer( aDLMedium );
+
+ SvStream* pStream = aDLMedium.GetInStream();
+ if( pStream )
+ {
+ SvMemoryStream aStream;
+ aStream << *pStream;
+
+ aStream.Seek( STREAM_SEEK_TO_END );
+ DBG_ASSERT( aStream.Tell() < STRING_MAXLEN,
+ "File zu lang fuer einen String, Ende abgeschnitten" );
+ xub_StrLen nLen = aStream.Tell() < STRING_MAXLEN
+ ? (xub_StrLen)aStream.Tell()
+ : STRING_MAXLEN;
+
+ rStr = String( (const sal_Char *)aStream.GetData(), nLen,
+ GetSrcEncoding() );
+ }
+
+ GetSaveAndSetOwnBaseURL();
+
+ // wurde abgebrochen?
+ if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
+ || 1 == pDoc->GetLinkCnt() )
+ {
+ // wurde der Import vom SFX abgebrochen?
+ eState = SVPAR_ERROR;
+ pStream = 0;
+ }
+
+ // View wieder anlgen
+#ifdef DEBUG
+ ViewShell *pVSh =
+#endif
+ CallStartAction( pOldVSh );
+#ifdef DEBUG
+ ASSERT( pOldVSh == pVSh, "FileDownload: ViewShell wurde ausgetauscht" );
+#endif
+
+ return pStream!=0;
+}
+
+void SwHTMLParser::InsertLink()
+{
+ BOOL bFinishDownload = FALSE;
+ if( pPendStack )
+ {
+ ASSERT( ShouldFinishFileDownload(),
+ "Pending-Stack ohne File-Download?" );
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ ASSERT( !pPendStack, "Wo kommt der Pending-Stack her?" );
+
+ bFinishDownload = TRUE;
+ }
+ else
+ {
+ String sRel, sHRef, sType;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_REL:
+ sRel = pOption->GetString();
+ break;
+ case HTML_O_HREF:
+ ASSERT( INetURLObject::GetBaseURL() == sBaseURL,
+ "<LINK>: Base URL ist zerschossen" );
+ sHRef = INetURLObject::RelToAbs( pOption->GetString() );
+ break;
+ case HTML_O_TYPE:
+ sType = pOption->GetString();
+ break;
+ }
+ }
+
+ if( sHRef.Len() && sRel.EqualsIgnoreCaseAscii( "STYLESHEET" ) &&
+ ( !sType.Len() ||
+ sType.GetToken(0,';').EqualsAscii(sCSS_mimetype) ) )
+ {
+ if( GetMedium() )
+ {
+ // Download des Style-Source starten
+ StartFileDownload( sHRef, 0, pDoc->GetDocShell() );
+ if( IsParserWorking() )
+ {
+ // Der Style wurde synchron geladen und wir koennen
+ // es direkt aufrufen.
+ bFinishDownload = TRUE;
+ }
+ else
+ {
+ // Der Style wird asynchron geladen und ist erst beim
+ // naechsten Continue-Aufruf da. Wir muessen deshalb einen
+ // Pending-Stack anlegen, damit wir hierher zurueckkehren
+ pPendStack = new SwPendingStack( HTML_LINK, pPendStack );
+ }
+ }
+ else
+ {
+ // File synchron holen
+ String sSource;
+ if( FileDownload( sHRef, sSource ) )
+ pCSS1Parser->ParseStyleSheet( sSource );
+ }
+ }
+ }
+
+ if( bFinishDownload )
+ {
+ String sSource;
+ if( FinishFileDownload(sSource) && sSource.Len() )
+ pCSS1Parser->ParseStyleSheet( sSource );
+ }
+}
+
+BOOL SwCSS1Parser::ParseStyleSheet( const String& rIn )
+{
+ if( !SvxCSS1Parser::ParseStyleSheet( rIn ) )
+ return FALSE;
+
+ SwPageDesc *pMasterPageDesc =
+ pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML );
+
+ SvxCSS1MapEntry *pPageEntry = GetPage( aEmptyStr, FALSE );
+ if( pPageEntry )
+ {
+ // @page (wirkt auf alle Seiten, die es schon gibt
+
+ SetPageDescAttrs( pMasterPageDesc, pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+
+ // Fuer alle anderen Seiten-Vorlagen, die es schon gibt,
+ // muessen die Attribute auch noch gesetzt werden
+
+ SetPageDescAttrs( GetFirstPageDesc(), pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+ SetPageDescAttrs( GetLeftPageDesc(), pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+ SetPageDescAttrs( GetRightPageDesc(), pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+// if( pNamedPageDescs )
+// {
+// for( USHORT i=0; i<pNamedPageDescs->Count(); i++ )
+// SetPageDescAttrs( (*pNamedPageDescs)[i],
+// pPageEntry->GetItemSet(),
+// pPageEntry->GetPropertyInfo() );
+// }
+
+ }
+
+ pPageEntry = GetPage( String::CreateFromAscii(sCSS1_first), TRUE );
+ if( pPageEntry )
+ {
+ SetPageDescAttrs( GetFirstPageDesc(TRUE), pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+ bSetFirstPageDesc = TRUE;
+ }
+
+ pPageEntry = GetPage( String::CreateFromAscii(sCSS1_right), TRUE );
+ if( pPageEntry )
+ {
+ SetPageDescAttrs( GetRightPageDesc(TRUE), pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+ bSetRightPageDesc = TRUE;
+ }
+
+ pPageEntry = GetPage( String::CreateFromAscii(sCSS1_left), TRUE );
+ if( pPageEntry )
+ SetPageDescAttrs( GetLeftPageDesc(TRUE), pPageEntry->GetItemSet(),
+ pPageEntry->GetPropertyInfo() );
+
+ // und jetzt noch die benannten Vorlagen
+// for( USHORT i=0; i < GetPageCount(); i++ )
+// {
+// pPageEntry = GetPage( i );
+// const String& rKey = pPageEntry->GetKey();
+// if( !rKey.Len() || rKey.GetChar(0) == ':' )
+// continue;
+//
+// String aName( rKey );
+// GetpApp()->GetAppInternational().ToLower( aName );
+// USHORT nPage = pDoc->MakePageDesc( aName );
+// SwPageDesc *pPageDesc = &pDoc->_GetPageDesc( nPage );
+//
+// // Die neue Seitenvorlage entsteht aus dem Master durch kopieren.
+// pDoc->CopyPageDesc( *pMasterPageDesc, *pPageDesc );
+// SetPageDescAttrs( pPageDesc, pPageEntry->GetItemSet(),
+// pPageEntry->GetPropertyInfo() );
+//
+// if( !pNamedPageDescs )
+// pNamedPageDescs = new SwHTMLPageDescs;
+// pNamedPageDescs->Insert( pPageDesc, pNamedPageDescs->Count() );
+// }
+
+ return TRUE;
+}
+
+BOOL SwHTMLParser::ParseStyleOptions( const String &rStyle,
+ const String &rId,
+ const String &rClass,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo )
+{
+ BOOL bRet = FALSE;
+
+ if( rClass.Len() )
+ {
+ SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( rClass );
+ if( pClass )
+ {
+ pCSS1Parser->MergeStyles( pClass->GetItemSet(),
+ pClass->GetPropertyInfo(),
+ rItemSet, rPropInfo, FALSE );
+ bRet = TRUE;
+ }
+ }
+
+ if( rId.Len() )
+ {
+ SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
+ if( pId )
+ pCSS1Parser->MergeStyles( pId->GetItemSet(),
+ pId->GetPropertyInfo(),
+ rItemSet, rPropInfo, rClass.Len()!=0 );
+ rPropInfo.aId = rId;
+ bRet = TRUE;
+ }
+
+ if( rStyle.Len() )
+ {
+ pCSS1Parser->ParseStyleOption( rStyle, rItemSet, rPropInfo );
+ bRet = TRUE;
+ }
+
+ if( bRet )
+ rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
+
+ return bRet;
+}
+
+void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet &rItemSet,
+ const SvxCSS1PropertyInfo &rPropInfo,
+ SfxItemSet &rFrmItemSet )
+{
+ SwFmtAnchor aAnchor;
+
+ SwHoriOrient eHoriOri = HORI_NONE;
+ SwVertOrient eVertOri = VERT_NONE;
+ SwRelationOrient eHoriRel = FRAME;
+ SwRelationOrient eVertRel = FRAME;
+ SwTwips nHoriPos = 0, nVertPos = 0;
+ SwSurround eSurround = SURROUND_THROUGHT;
+ if( SVX_CSS1_POS_ABSOLUTE == rPropInfo.ePosition )
+ {
+ if( SVX_CSS1_LTYPE_TWIP == rPropInfo.eLeftType &&
+ SVX_CSS1_LTYPE_TWIP == rPropInfo.eTopType )
+ {
+ // Absolut positionierte Objekte sind seitengebunden, wenn
+ // sie nicht schon in einem Rahmen stehen und sonst
+ // Rahmengebunden.
+ const SwStartNode *pFlySttNd =
+ pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode();
+ if( pFlySttNd )
+ {
+ aAnchor.SetType( FLY_AT_FLY );
+ SwPosition aPos( *pFlySttNd );
+ aAnchor.SetAnchor( &aPos );
+ }
+ else
+ {
+ aAnchor.SetType( FLY_PAGE );
+ aAnchor.SetPageNum( 1 );
+ }
+ nHoriPos = rPropInfo.nLeft;
+ nVertPos = rPropInfo.nTop;
+ }
+ else
+ {
+ aAnchor.SetType( FLY_AT_CNTNT );
+ aAnchor.SetAnchor( pPam->GetPoint() );
+ eVertOri = VERT_TOP;
+ eVertRel = REL_CHAR;
+ if( SVX_CSS1_LTYPE_TWIP == rPropInfo.eLeftType )
+ {
+ eHoriOri = HORI_NONE;
+ eHoriRel = REL_PG_FRAME;
+ nHoriPos = rPropInfo.nLeft;
+ }
+ else
+ {
+ eHoriOri = HORI_LEFT;
+ eHoriRel = FRAME; // wird noch umgeschossen
+ }
+ }
+ }
+ else
+ {
+ // fliessende Objekte werden Absatzgebunden eingefuegt, wenn
+ // der Absatz noch leer ist und sonst auto-gebunden.
+ // Auto-gebundene Rahmen werden zunaechst an der Position davor
+ // eingefuegt und erst spaeter verschoben.
+ xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex();
+ if( nCntnt )
+ {
+ aAnchor.SetType( FLY_AUTO_CNTNT );
+ pPam->Move( fnMoveBackward );
+ eVertOri = VERT_CHAR_BOTTOM;
+ eVertRel = REL_CHAR;
+ }
+ else
+ {
+ aAnchor.SetType( FLY_AT_CNTNT );
+ eVertOri = VERT_TOP;
+ eVertRel = PRTAREA;
+ }
+
+ aAnchor.SetAnchor( pPam->GetPoint() );
+
+ if( nCntnt )
+ pPam->Move( fnMoveForward );
+
+ USHORT nLeftSpace = 0, nRightSpace = 0;
+ short nIndent = 0;
+ GetMarginsFromContextWithNumBul( nLeftSpace, nRightSpace, nIndent );
+
+ if( SVX_ADJUST_RIGHT==rPropInfo.eFloat )
+ {
+ eHoriOri = HORI_RIGHT;
+ eHoriRel = nRightSpace ? PRTAREA : FRAME;
+ eSurround = SURROUND_LEFT;
+ }
+ else
+ {
+ eHoriOri = HORI_LEFT;
+ eHoriRel = nLeftSpace ? PRTAREA : FRAME;
+ eSurround = SURROUND_RIGHT;
+ }
+ }
+ rFrmItemSet.Put( aAnchor );
+
+ // Absolut Positioniert mit Durchlauf
+ rFrmItemSet.Put( SwFmtHoriOrient( nHoriPos, eHoriOri, eHoriRel ) );
+ rFrmItemSet.Put( SwFmtVertOrient( nVertPos, eVertOri, eVertRel ) );
+ rFrmItemSet.Put( SwFmtSurround( eSurround ) );
+}
+
+void SwHTMLParser::SetVarSize( SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ SfxItemSet &rFrmItemSet,
+ SwTwips nDfltWidth, BYTE nDfltPrcWidth )
+{
+ SwFrmSize eSize = ATT_MIN_SIZE;
+ SwTwips nWidth = nDfltWidth, nHeight = MINFLY;
+ BYTE nPrcWidth = nDfltPrcWidth, nPrcHeight = 0;
+ switch( rPropInfo.eWidthType )
+ {
+ case SVX_CSS1_LTYPE_PERCENTAGE:
+ nPrcWidth = rPropInfo.nWidth > 0 ? (BYTE)rPropInfo.nWidth : 1;
+ nWidth = MINFLY;
+ break;
+ case SVX_CSS1_LTYPE_TWIP:
+ nWidth = rPropInfo.nWidth > MINFLY ? rPropInfo.nWidth : MINFLY;
+ nPrcWidth = 0;
+ break;
+ }
+ switch( rPropInfo.eHeightType )
+ {
+ case SVX_CSS1_LTYPE_PERCENTAGE:
+ nPrcHeight = rPropInfo.nHeight > 0 ? (BYTE)rPropInfo.nHeight : 1;
+ break;
+ case SVX_CSS1_LTYPE_TWIP:
+ // Netscape und MS-IE interpretieren die Hoehe regelwiedrig
+ // als Mindest-Hoehe, also machwn wir das auch so.
+ nHeight = rPropInfo.nHeight > MINFLY ? rPropInfo.nHeight : MINFLY;
+ break;
+ }
+
+ SwFmtFrmSize aFrmSize( eSize, nWidth, nHeight );
+ aFrmSize.SetWidthPercent( nPrcWidth );
+ aFrmSize.SetHeightPercent( nPrcHeight );
+ rFrmItemSet.Put( aFrmSize );
+}
+
+void SwHTMLParser::SetFrmFmtAttrs( SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ USHORT nFlags,
+ SfxItemSet &rFrmItemSet )
+{
+ const SfxPoolItem *pItem;
+ if( (nFlags & HTML_FF_BOX) != 0 &&
+ SFX_ITEM_SET==rItemSet.GetItemState( RES_BOX, TRUE, &pItem ) )
+ {
+ if( (nFlags & HTML_FF_PADDING) == 0 )
+ {
+ SvxBoxItem aBoxItem( *(const SvxBoxItem *)pItem );
+ // Alle 4 Seiten gleichzeitig auf 0 setzen
+ aBoxItem.SetDistance( 0 );
+ rFrmItemSet.Put( aBoxItem );
+ }
+ else
+ {
+ rFrmItemSet.Put( *pItem );
+ }
+ rItemSet.ClearItem( RES_BOX );
+ }
+
+ if( (nFlags & HTML_FF_BACKGROUND) != 0 &&
+ SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, TRUE, &pItem ) )
+ {
+ rFrmItemSet.Put( *pItem );
+ rItemSet.ClearItem( RES_BACKGROUND );
+ }
+}
+
+
+/* */
+
+_HTMLAttrContext *SwHTMLParser::PopContext( USHORT nToken, USHORT nLimit,
+ BOOL bRemove )
+{
+ USHORT nPos = aContexts.Count();
+ if( nPos <= nContextStMin )
+ return 0;
+
+ BOOL bFound = 0==nToken;
+ if( nToken )
+ {
+ // Stack-Eintrag zu dem Token suchen
+ while( nPos > nContextStMin )
+ {
+ USHORT nCntxtToken = aContexts[--nPos]->GetToken();
+ if( nCntxtToken == nToken )
+ {
+ bFound = TRUE;
+ break;
+ }
+ else if( nCntxtToken == nLimit ) // 0 als Token kommt nicht vor
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ nPos--;
+ }
+
+ _HTMLAttrContext *pCntxt = 0;
+ if( bFound )
+ {
+ pCntxt = aContexts[nPos];
+ if( bRemove )
+ aContexts.Remove( nPos, 1 );
+ }
+
+ return pCntxt;
+}
+
+#ifdef USED
+USHORT SwHTMLParser::GetTxtFmtCollFromContext() const
+{
+ USHORT nPos = aContexts.Count();
+ USHORT nPoolId = 0;
+
+ while( !nPoolId && nPos>0 ) // nicht nMinStack wg. Tabellen!!!
+ nPoolId = aContexts[--nPos]->GetTxtFmtColl();
+
+ if( !nPoolId )
+ nPoolId = aDfltContext.GetTxtFmtColl();
+
+ return nPoolId;
+}
+#endif
+
+BOOL SwHTMLParser::GetMarginsFromContext( USHORT& nLeft,
+ USHORT& nRight,
+ short& nIndent,
+ BOOL bIgnoreTopContext ) const
+{
+ USHORT nPos = aContexts.Count();
+ if( bIgnoreTopContext )
+ {
+ if( !nPos )
+ return FALSE;
+ else
+ nPos--;
+ }
+
+ while( nPos > nContextStAttrMin )
+ {
+ const _HTMLAttrContext *pCntxt = aContexts[--nPos];
+ if( pCntxt->IsLRSpaceChanged() )
+ {
+ pCntxt->GetMargins( nLeft, nRight, nIndent );
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+BOOL SwHTMLParser::GetMarginsFromContextWithNumBul( USHORT& nLeft,
+ USHORT& nRight,
+ short& nIndent ) const
+{
+ BOOL bRet = GetMarginsFromContext( nLeft, nRight, nIndent );
+#ifdef NUM_RELSPACE
+ const SwHTMLNumRuleInfo& rInfo = ((SwHTMLParser*)this)->GetNumInfo();
+ if( rInfo.GetDepth() )
+ {
+ BYTE nLevel = (BYTE)( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
+ : MAXLEVEL) - 1 );
+ const SwNumFmt& rNumFmt = rInfo.GetNumRule()->Get(nLevel);
+ nLeft += rNumFmt.GetAbsLSpace();
+ nIndent = rNumFmt.GetFirstLineOffset();
+ }
+#endif
+
+ return bRet;
+}
+
+void SwHTMLParser::GetULSpaceFromContext( USHORT& nUpper,
+ USHORT& nLower ) const
+{
+ USHORT nDfltColl = 0;
+ String aDfltClass;
+
+ USHORT nPos = aContexts.Count();
+ while( nPos > nContextStAttrMin )
+ {
+ const _HTMLAttrContext *pCntxt = aContexts[--nPos];
+ if( pCntxt->IsULSpaceChanged() )
+ {
+ pCntxt->GetULSpace( nUpper, nLower );
+ return;
+ }
+ else if( !nDfltColl )
+ {
+ nDfltColl = pCntxt->GetDfltTxtFmtColl();
+ if( nDfltColl )
+ aDfltClass = pCntxt->GetClass();
+ }
+ }
+
+ if( !nDfltColl )
+ nDfltColl = RES_POOLCOLL_TEXT;
+
+ const SwTxtFmtColl *pColl =
+ pCSS1Parser->GetTxtFmtColl( nDfltColl, aDfltClass );
+ const SvxULSpaceItem& rULSpace = pColl->GetULSpace();
+ nUpper = rULSpace.GetUpper();
+ nLower = rULSpace.GetLower();
+}
+
+void SwHTMLParser::EndContextAttrs( _HTMLAttrContext *pContext, BOOL bRemove )
+{
+ _HTMLAttrs &rAttrs = pContext->GetAttrs();
+ for( USHORT i=0; i<rAttrs.Count(); i++ )
+ {
+ _HTMLAttr *pAttr = rAttrs[i];
+
+ if( RES_PARATR_DROP==pAttr->GetItem().Which() )
+ {
+ // Fuer DropCaps noch die Anzahl der Zeichen anpassen. Wenn
+ // es am Ende 0 sind, wird das Attribut invalidiert und dann
+ // von _SetAttr gar nicht erst gesetzt.
+ xub_StrLen nChars = pPam->GetPoint()->nContent.GetIndex();
+ if( nChars < 1 )
+ pAttr->Invalidate();
+ else if( nChars > MAX_DROPCAP_CHARS )
+ nChars = MAX_DROPCAP_CHARS;
+ ((SwFmtDrop&)pAttr->GetItem()).GetChars() = (BYTE)nChars;
+ }
+
+ EndAttr( pAttr );
+ }
+
+ if( bRemove && rAttrs.Count() )
+ rAttrs.Remove( 0, rAttrs.Count() );
+}
+
+void SwHTMLParser::InsertParaAttrs( const SfxItemSet& rItemSet )
+{
+ SfxItemIter aIter( rItemSet );
+
+ const SfxPoolItem *pItem = aIter.FirstItem();
+ while( pItem )
+ {
+ // den zu dem Item gehoehrenden Tabellen-Eintrag ermitteln ...
+ USHORT nWhich = pItem->Which();
+ _HTMLAttr **ppAttr = GetAttrTabEntry( nWhich );
+
+ if( ppAttr )
+ {
+ NewAttr( ppAttr, *pItem );
+ if( RES_PARATR_BEGIN > nWhich )
+ (*ppAttr)->SetLikePara();
+ aParaAttrs.Insert( *ppAttr, aParaAttrs.Count() );
+ EndAttr( *ppAttr, 0, FALSE );
+ }
+
+ pItem = aIter.NextItem();
+ }
+}
+
+void SwHTMLParser::AddFormatAttrs( SfxItemSet& rItemSet,
+ const SwFmt& rFmt ) const
+{
+ const SfxItemSet& rFmtItemSet = rFmt.GetAttrSet();
+ const SfxPoolItem *pFmtItem, *pItem;
+ SfxWhichIter aIter( rItemSet );
+
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ if( SFX_ITEM_SET != rItemSet.GetItemState(nWhich,FALSE,&pItem) &&
+ SFX_ITEM_SET == rFmtItemSet.GetItemState(nWhich,TRUE,&pFmtItem) )
+ {
+ rItemSet.Put( *pFmtItem );
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void SwHTMLParser::RemoveFormatAttrs( SfxItemSet& rItemSet,
+ const SwFmt& rFmt ) const
+{
+ const SfxItemSet& rFmtItemSet = rFmt.GetAttrSet();
+ const SfxPoolItem *pItem;
+ SfxWhichIter aIter( rItemSet );
+
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ if( SFX_ITEM_SET == rItemSet.GetItemState(nWhich,FALSE,&pItem) &&
+ SFX_ITEM_SET == rFmtItemSet.GetItemState(nWhich,TRUE,&pItem) )
+ {
+ rItemSet.ClearItem( nWhich );
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void lcl_swcss1_setEncoding( SwFmt& rFmt, rtl_TextEncoding eEnc )
+{
+ if( RTL_TEXTENCODING_DONTKNOW == eEnc )
+ return;
+
+ const SfxItemSet& rItemSet = rFmt.GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_FONT, FALSE,&pItem ) )
+ {
+ const SvxFontItem& rFont = *(const SvxFontItem *)pItem;
+ if( RTL_TEXTENCODING_SYMBOL != rFont.GetCharSet() )
+ {
+ SvxFontItem aFont( rFont.GetFamily(), rFont.GetFamilyName(),
+ rFont.GetStyleName(), rFont.GetPitch(),
+ eEnc );
+ rFmt.SetAttr( aFont );
+ }
+ }
+}
+
+void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
+{
+ if( eEnc != GetDfltEncoding() )
+ {
+ if( bIsNewDoc )
+ {
+ // Set new encoding as pool default
+ const SvxFontItem& rDfltFont =
+ (const SvxFontItem&)pDoc->GetDefault( RES_CHRATR_FONT );
+ SvxFontItem aFont( rDfltFont.GetFamily(), rDfltFont.GetFamilyName(),
+ rDfltFont.GetStyleName(), rDfltFont.GetPitch(),
+ eEnc );
+ pDoc->SetDefault( aFont );
+
+ // Change all paragraph styles that do specify a font.
+ USHORT nArrLen = pDoc->GetTxtFmtColls()->Count();
+ for( USHORT i=1; i<nArrLen; i++ )
+ lcl_swcss1_setEncoding( *(*pDoc->GetTxtFmtColls())[i], eEnc );
+
+ // Change all character styles that do specify a font.
+ nArrLen = pDoc->GetCharFmts()->Count();
+ for( i=1; i<nArrLen; i++ )
+ lcl_swcss1_setEncoding( *(*pDoc->GetCharFmts())[i], eEnc );
+ }
+
+ SvxCSS1Parser::SetDfltEncoding( eEnc );
+ }
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlcss1.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.96 2000/09/18 16:04:43 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.95 2000/08/30 16:46:26 jp
+ use CharClass instead of international
+
+ Revision 1.94 2000/04/28 14:29:11 mib
+ unicode
+
+ Revision 1.93 2000/04/10 12:20:55 mib
+ unicode
+
+ Revision 1.92 2000/03/03 15:21:00 os
+ StarView remainders removed
+
+ Revision 1.91 2000/02/11 14:37:03 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.90 1999/09/17 12:12:49 mib
+ support of multiple and non system text encodings
+
+ Revision 1.89 1999/06/11 14:45:26 MIB
+ Individuelle Umrandungs-Abstaende
+
+
+ Rev 1.88 11 Jun 1999 16:45:26 MIB
+ Individuelle Umrandungs-Abstaende
+
+ Rev 1.87 15 Apr 1999 13:51:30 MIB
+ #41833#: Styles fuer A-Tag
+
+ Rev 1.86 08 Apr 1999 17:35:36 MIB
+ #64522#: Styles fuer TD/TH auswerten
+
+ Rev 1.85 17 Mar 1999 16:45:22 MIB
+ #63049#: Numerierungen mit relativen Abstaenden
+
+ Rev 1.84 25 Feb 1999 16:00:44 MIB
+ #61949#: globale Shell entsorgt
+
+ Rev 1.83 22 Feb 1999 08:40:26 MA
+ 1949globale Shell entsorgt, Shells am RootFrm
+
+ Rev 1.82 27 Jan 1999 09:43:38 OS
+ #56371# TF_ONE51
+
+ Rev 1.81 14 Jan 1999 13:28:26 MIB
+ #60776#: Festen statt minimalen Zeilen-Abstand einstellen
+
+ Rev 1.80 11 Jan 1999 16:05:34 JP
+ Bug #60765#: CopyPageDesc - ggfs die PoolIds nicht mit kopieren
+
+ Rev 1.79 02 Nov 1998 17:28:30 MIB
+ #58480#: Fuss-/Endnoten
+
+ Rev 1.78 21 Apr 1998 13:46:10 MIB
+ fix: Keine Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.77 20 Apr 1998 08:43:44 MIB
+ fix: @page wieder auswerten
+
+ Rev 1.76 15 Apr 1998 14:46:48 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.75 03 Apr 1998 12:18:42 MIB
+ Rahmenhoehe MIN_SIZE statt VAR_SIZE
+
+ Rev 1.74 02 Apr 1998 19:41:00 MIB
+ Positionierung von spaltigen Rahmen
+
+ Rev 1.73 27 Mar 1998 10:01:52 MIB
+ direkte Positionierung von Grafiken etc.
+
+ Rev 1.72 25 Mar 1998 12:08:16 MIB
+ abs.-pos. Container angefangen
+
+ Rev 1.71 24 Mar 1998 14:31:28 MIB
+ obsolete ParseStyleOptions-Methode entfernt
+
+ Rev 1.70 20 Mar 1998 10:42:44 MIB
+ Font-Listen in Font-Attributen
+
+ Rev 1.69 24 Feb 1998 11:31:24 MIB
+ Jetzt auch HTML_LISTING und HTML_XMP vernichtet (wegen #42029#)
+
+ Rev 1.68 20 Feb 1998 19:04:30 MA
+ header
+
+ Rev 1.67 17 Feb 1998 10:51:08 MIB
+ HTML-H6 -> HEADLINE6
+
+ Rev 1.66 19 Jan 1998 16:27:18 MIB
+ Numerierungs-Umbau
+
+ Rev 1.65 26 Nov 1997 19:09:20 MA
+ includes
+
+ Rev 1.64 17 Nov 1997 10:16:48 JP
+ Umstellung Numerierung
+
+ Rev 1.63 21 Oct 1997 09:18:06 MIB
+ Seitengroesse der HTML-Vorlage als Ausgangsbasis verwenden
+
+ Rev 1.62 20 Oct 1997 09:51:02 MIB
+ Nur fuer absolute positioning benoetigten Code groesstenteils auskommentiert
+
+ Rev 1.61 17 Oct 1997 13:20:06 MIB
+ page-break-xxx auch uber STYLE/CLASS und ID-Optionen
+
+ Rev 1.60 14 Oct 1997 14:31:22 MIB
+ fix #44228#: ViewShell-Zerstoerung/Rekonstruktion ueber Clients
+
+ Rev 1.59 10 Oct 1997 10:16:20 MIB
+ CSS1-Printing-Ext: @page,page-break-before/after (noch kein left/right)
+
+ Rev 1.58 16 Sep 1997 17:24:40 MIB
+ abs. Positioning fuer Absatz-Tags
+
+ Rev 1.57 16 Sep 1997 14:55:24 MIB
+ ITEMID_BOXINFOITEM (voreubergendend) definieren
+
+ Rev 1.56 16 Sep 1997 11:13:32 MIB
+ unbenutzte Funktionen entfernt
+
+ Rev 1.55 12 Sep 1997 11:55:22 MIB
+ fix #41136#: &(xxx);-Makros, Nicht benutzen Code entfernt
+
+ Rev 1.54 18 Aug 1997 11:36:14 OS
+ includes
+
+ Rev 1.53 15 Aug 1997 12:47:48 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.52 12 Aug 1997 13:47:00 OS
+ Header-Umstellung
+
+ Rev 1.51 11 Aug 1997 14:07:06 OM
+ Headerfile-Umstellung
+
+ Rev 1.50 07 Aug 1997 15:08:36 OM
+ Headerfile-Umstellung
+
+ Rev 1.49 04 Aug 1997 13:54:06 MIB
+ aboslute psoitioning (fuer fast alle Zeichen-Attribute/-Vorlagen)
+
+ Rev 1.48 31 Jul 1997 10:43:40 MIB
+ absolute positioning (sehr rudimentaer, nicht freigeschaltet)
+
+ Rev 1.47 18 Jul 1997 10:55:08 MIB
+ fix #40951#: In Reschedule/DocDetected absichtlich geaenderte URLs beachten
+
+ Rev 1.46 02 Jul 1997 10:11:40 MIB
+ Transfer-Prio fuer File-Download setzen
+
+ Rev 1.45 01 Jul 1997 08:30:50 MIB
+ fix #41120#: Beim synchronen Laden (Source-View) Styles synchron laden
+
+ Rev 1.44 16 Jun 1997 08:27:56 MIB
+ CLASS/ID auch fier Tabellen
+
+ Rev 1.43 13 Jun 1997 11:55:38 MIB
+ CLASS und ID CSS1-Optionen auswerten
+
+ Rev 1.42 21 May 1997 11:12:22 MIB
+ <LINK REL=STYLESHEET> zum Enbinden von externen Style-Sheets
+
+ Rev 1.41 23 Apr 1997 15:03:48 MIB
+ fixes #39160# und #39162#: BODY-Style und Text, Fontnamen ohne Haekchen
+
+ Rev 1.40 08 Apr 1997 11:06:48 MIB
+ fix #37219#: In Tabellen-Beschriftung alles erlauben
+
+ Rev 1.39 13 Feb 1997 13:03:26 JP
+ DT1-5 und DD1-5 entfernt, es gibt nur noch DD/DT
+
+ Rev 1.38 12 Feb 1997 10:56:00 MIB
+ DL-Ebene ueber harte Attributierung
+
+ Rev 1.37 28 Jan 1997 11:29:00 MIB
+ Hart attributierte DropCaps, neue Namen fuer Class-Vorlagen
+
+ Rev 1.36 10 Dec 1996 15:01:48 MIB
+ Umstellung HTML-Vorlagen aus Pool
+
+ Rev 1.35 09 Dec 1996 20:10:24 JP
+ erstellen/modifizieren der Vorlagen entfernt, umgestellt auf die neuen PoolVorlagen
+
+ Rev 1.34 27 Nov 1996 14:35:34 MIB
+ fix #32725#: Bei harter Attr. oberern/unteren Abstand aus Vorlagen beruecks.
+
+ Rev 1.33 26 Nov 1996 16:22:48 MIB
+ keine abhaengigen Attribute mehr
+
+ Rev 1.32 01 Nov 1996 04:37:04 MH
+ aNodes -> GetNodes()
+
+ Rev 1.31 30 Oct 1996 18:28:58 MIB
+ Zeichenvorlagen fuer DropCaps nur anlegen wenn noetig
+
+ Rev 1.30 29 Oct 1996 16:34:58 MIB
+ DropCaps wieder aktiviert
+
+ Rev 1.29 29 Oct 1996 15:35:26 MIB
+ Flags fuer gesetzte/nicht-gesetzte Attribut-Werte
+
+ Rev 1.28 28 Oct 1996 19:51:44 MIB
+ CLASS an Absatzvorlagen importieren
+
+ Rev 1.27 24 Oct 1996 17:09:56 JP
+ Optimierung: Find...ByName
+
+ Rev 1.26 23 Oct 1996 19:49:00 JP
+ String Umstellung: [] -> GetChar()
+
+ Rev 1.25 23 Oct 1996 09:33:20 MIB
+ Klassen-Namen in Kleinbuchstaben wandeln
+
+ Rev 1.24 22 Oct 1996 10:28:38 MIB
+ Umstellung von CSS1 auf Klein-Buchstaben (u.a. wegen Amaya)
+
+ Rev 1.23 21 Oct 1996 08:56:36 MIB
+ CLASS fuer Zeichen-Vorlagen, STYLE am BODY-Tag
+
+ Rev 1.22 15 Oct 1996 18:44:34 MIB
+ unbenutzte Funktionen entfernt
+
+ Rev 1.21 15 Oct 1996 17:48:34 MIB
+ unbenutzte Funktionen entfernt
+
+ Rev 1.20 15 Oct 1996 13:42:06 MIB
+ letter-spacing/Laufweite imp./exp.
+
+ Rev 1.19 14 Oct 1996 18:49:14 MIB
+ Am Box-Item Abstand zur Umrandung setzen
+
+ Rev 1.18 14 Oct 1996 16:49:54 MIB
+ fix(?) #32660#: BLOCKQUOTE nicht mehr im Blocksatz ausrichten
+
+ Rev 1.17 14 Oct 1996 16:43:02 MIB
+ Import CSS1-Umrandung (border)
+
+ Rev 1.16 13 Oct 1996 12:19:30 MIB
+ first-letter-Pseudo-Element/DropCaps
+
+ Rev 1.15 24 Sep 1996 12:49:42 MIB
+ Tabellenvorlagen wieder von Textkoerper abhaengig
+
+ Rev 1.14 20 Sep 1996 17:59:28 MIB
+ Zeichen-Hintergrund-Farbe/Itemset-Optimierungen
+
+ Rev 1.13 29 Aug 1996 14:12:20 MIB
+ bug fixes: Attrs in Tabellen ausserhalb Zelle loeschen, kein Mem-Verl. bei HR
+
+ Rev 1.12 20 Aug 1996 16:58:20 MIB
+ HTML-Absatzvorlagen importieren
+
+ Rev 1.11 14 Aug 1996 16:22:24 MIB
+ gcc und msvc: statt *aStr nicht aStr[0] sondern aStr[(USHORT)0]
+
+ Rev 1.10 13 Aug 1996 21:20:50 sdo
+ GCC
+
+ Rev 1.9 12 Aug 1996 10:33:22 MIB
+ CSS1-Background-Property
+
+ Rev 1.8 07 Aug 1996 14:41:02 MIB
+ Import von color und text-decoration
+
+ Rev 1.7 29 Jul 1996 15:57:12 MIB
+ Numerierungs-Umbau: linker/rechte Raender und Erstzeilen-Einzug
+
+ Rev 1.6 17 Jul 1996 10:35:00 MIB
+ Umbau: Setzen von Absatz-Vorlagen und deren Attributen
+
+ Rev 1.5 10 Jul 1996 15:06:20 MIB
+ Includes fuer precompiled header gerichtet
+
+ Rev 1.4 09 Jul 1996 13:31:14 MIB
+ Attributierung von Textkoerper in abgleiteten Vorlagen setzen
+
+ Rev 1.3 05 Jul 1996 11:20:18 MIB
+ BLINK-Zeichenvorlage entfernt
+
+ Rev 1.2 03 Jul 1996 16:55:36 MIB
+ Zeichenvorlagen durch Styles aendern
+
+ Rev 1.1 02 Jul 1996 19:18:28 MIB
+ harte CSS1-Attributierung (noch nicht fertig)
+
+ Rev 1.0 28 Jun 1996 18:08:52 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
new file mode 100644
index 000000000000..b25d5b2c4e42
--- /dev/null
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -0,0 +1,934 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlctxt.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "hintids.hxx"
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+
+#include "doc.hxx"
+#include "pam.hxx"
+#include "ndtxt.hxx"
+#include "shellio.hxx"
+#include "paratr.hxx"
+#include "htmlnum.hxx"
+#include "css1kywd.hxx"
+#include "swcss1.hxx"
+#include "swhtml.hxx"
+
+/* */
+
+
+class _HTMLAttrContext_SaveDoc
+{
+ SwHTMLNumRuleInfo aNumRuleInfo; // In Umgebung gueltige Numerierung
+ SwPosition *pPos; // hierhin beim verlassen den
+ // Kontexts zurueckgesprungen
+ _HTMLAttrTable *pAttrTab; // In Umgebung gueltige Attribute,
+ // wenn Attributierung nicht
+ // beibehalten werden soll.
+
+ USHORT nContextStMin; // In Umgebung gueltige Stack-
+ // Untergrenze, wenn der Stack
+ // geschuetzt werden soll.
+ USHORT nContextStAttrMin; // In Umgebung gueltige Stack-
+ // Untergrenze, wenn die Attribute
+ // nicht beibehalten werden sollen.
+
+ BOOL bStripTrailingPara : 1; // letzen Absatz entfernen?
+ BOOL bKeepNumRules : 1; // Numerierung beibehalten?
+ BOOL bPopStack : 1; // Stack-Elemente oberhalb des
+ // zu schliessenden entfernen?
+ BOOL bFixHeaderDist : 1;
+ BOOL bFixFooterDist : 1;
+
+public:
+
+ _HTMLAttrContext_SaveDoc() :
+ pPos( 0 ), pAttrTab( 0 ),
+ nContextStMin( USHRT_MAX ), nContextStAttrMin( USHRT_MAX ),
+ bStripTrailingPara( FALSE ), bKeepNumRules( FALSE ),
+ bPopStack( FALSE ),
+ bFixHeaderDist( FALSE ), bFixFooterDist( FALSE )
+ {}
+
+ ~_HTMLAttrContext_SaveDoc() { delete pPos; delete pAttrTab; }
+
+ // Die Position gehoert uns, muss also angelegt und zerstoert werden
+ void SetPos( const SwPosition& rPos ) { pPos = new SwPosition(rPos); }
+ const SwPosition *GetPos() const { return pPos; }
+
+ // Der Index gehoert uns nicht. Kein Anlgen und Zerstoeren.
+ void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { aNumRuleInfo.Set(rInf); }
+ const SwHTMLNumRuleInfo& GetNumInfo() const { return aNumRuleInfo; }
+
+ _HTMLAttrTable *GetAttrTab( BOOL bCreate= FALSE );
+
+ void SetContextStMin( USHORT nMin ) { nContextStMin = nMin; }
+ USHORT GetContextStMin() const { return nContextStMin; }
+
+ void SetContextStAttrMin( USHORT nMin ) { nContextStAttrMin = nMin; }
+ USHORT GetContextStAttrMin() const { return nContextStAttrMin; }
+
+ void SetStripTrailingPara( BOOL bSet ) { bStripTrailingPara = bSet; }
+ BOOL GetStripTrailingPara() const { return bStripTrailingPara; }
+
+ void SetKeepNumRules( BOOL bSet ) { bKeepNumRules = bSet; }
+ BOOL GetKeepNumRules() const { return bKeepNumRules; }
+
+ void SetFixHeaderDist( BOOL bSet ) { bFixHeaderDist = bSet; }
+ BOOL GetFixHeaderDist() const { return bFixHeaderDist; }
+
+ void SetFixFooterDist( BOOL bSet ) { bFixFooterDist = bSet; }
+ BOOL GetFixFooterDist() const { return bFixFooterDist; }
+};
+
+_HTMLAttrTable *_HTMLAttrContext_SaveDoc::GetAttrTab( BOOL bCreate )
+{
+ if( !pAttrTab && bCreate )
+ {
+ pAttrTab = new _HTMLAttrTable;
+ memset( pAttrTab, 0, sizeof( _HTMLAttrTable ));
+ }
+ return pAttrTab;
+}
+
+/* */
+
+_HTMLAttrContext_SaveDoc *_HTMLAttrContext::GetSaveDocContext( BOOL bCreate )
+{
+ if( !pSaveDocContext && bCreate )
+ pSaveDocContext = new _HTMLAttrContext_SaveDoc;
+
+ return pSaveDocContext;
+}
+
+void _HTMLAttrContext::ClearSaveDocContext()
+{
+ delete pSaveDocContext;
+ pSaveDocContext = 0;
+}
+
+/* */
+
+void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
+{
+ // Hier darf es keine vorlauefigen Absatz-Attribute geben, den die
+ // koennten jetzt gesetzt werden und dann sind die Zeiger ungueltig!!!
+ ASSERT( !aParaAttrs.Count(),
+ "Hoechste Gefahr: Es gibt noch nicht-endgueltige Absatz-Attribute" );
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ const SwNodeIndex* pOldEndPara = &pPam->GetPoint()->nNode;
+ xub_StrLen nOldEndCnt = pPam->GetPoint()->nContent.GetIndex();
+
+ const SwNodeIndex& rNewSttPara = rNewPos.nNode;
+ xub_StrLen nNewSttCnt = rNewPos.nContent.GetIndex();
+
+ BOOL bMoveBack = FALSE;
+
+ // alle noch offenen Attribute beenden und hinter der Tabelle
+ // neu aufspannen
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ for( USHORT nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; ++pTbl )
+ {
+ _HTMLAttr *pAttr = *pTbl;
+ while( pAttr )
+ {
+ _HTMLAttr *pNext = pAttr->GetNext();
+ _HTMLAttr *pPrev = pAttr->GetPrev();
+
+ USHORT nWhich = pAttr->pItem->Which();
+ if( !nOldEndCnt && RES_PARATR_BEGIN <= nWhich &&
+ pAttr->GetSttParaIdx() < pOldEndPara->GetIndex() )
+ {
+ // Das Attribut muss eine Content-Position weiter vorne
+ // beendet werden
+ if( !bMoveBack )
+ {
+ bMoveBack = pPam->Move( fnMoveBackward );
+ nOldEndCnt = pPam->GetPoint()->nContent.GetIndex();
+ }
+ }
+ else if( bMoveBack )
+ {
+ pPam->Move( fnMoveForward );
+ nOldEndCnt = pPam->GetPoint()->nContent.GetIndex();
+ }
+
+ if( RES_PARATR_BEGIN <= nWhich && bMoveBack ||
+ pAttr->GetSttParaIdx() < pOldEndPara->GetIndex() ||
+ (pAttr->GetSttPara() == *pOldEndPara &&
+ pAttr->GetSttCnt() != nOldEndCnt) )
+ {
+ // Das Attribut muss gesetzt werden. Da wir
+ // das Original noch brauchen, weil Zeiger auf das Attribut
+ // noch in den Kontexten existieren, muessen wir es clonen.
+ // Die Next-Liste geht dabei verloren, aber die
+ // Previous-Liste bleibt erhalten
+ _HTMLAttr *pSetAttr = pAttr->Clone( *pOldEndPara, nOldEndCnt );
+
+ if( pNext )
+ pNext->InsertPrev( pSetAttr );
+ else
+ {
+ USHORT nTmp =
+ pSetAttr->bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pSetAttr, nTmp );
+ }
+ }
+ else if( pPrev )
+ {
+ // Wenn das Attribut nicht gesetzt vor der Tabelle
+ // gesetzt werden muss, muessen der Previous-Attribute
+ // trotzdem gesetzt werden.
+ if( pNext )
+ pNext->InsertPrev( pPrev );
+ else
+ {
+ USHORT nTmp = pPrev->bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pPrev, nTmp );
+ }
+ }
+
+ // den Start des Attributs neu setzen
+ pAttr->nSttPara = rNewSttPara;
+ pAttr->nEndPara = rNewSttPara;
+ pAttr->nSttCntnt = nNewSttCnt;
+ pAttr->nEndCntnt = nNewSttCnt;
+ pAttr->pPrev = 0;
+
+ pAttr = pNext;
+ }
+ }
+
+ if( bMoveBack )
+ pPam->Move( fnMoveForward );
+
+}
+
+void SwHTMLParser::SaveDocContext( _HTMLAttrContext *pCntxt,
+ USHORT nFlags,
+ const SwPosition *pNewPos )
+{
+ _HTMLAttrContext_SaveDoc *pSave = pCntxt->GetSaveDocContext( TRUE );
+ pSave->SetStripTrailingPara( (HTML_CNTXT_STRIP_PARA & nFlags) != 0 );
+ pSave->SetKeepNumRules( (HTML_CNTXT_KEEP_NUMRULE & nFlags) != 0 );
+ pSave->SetFixHeaderDist( (HTML_CNTXT_HEADER_DIST & nFlags) != 0 );
+ pSave->SetFixFooterDist( (HTML_CNTXT_FOOTER_DIST & nFlags) != 0 );
+
+ if( pNewPos )
+ {
+ // Wenn der PaM an eine andere Position gesetzt wird, muss
+ // die Numerierung gerettet werden..
+ if( !pSave->GetKeepNumRules() )
+ {
+ // Die Numerierung soll nicht beibehalten werden. Also muss
+ // der aktuelle Zustand gerettet und die Numerierung
+ // anschliessend ausgeschaltet werden.
+ pSave->SetNumInfo( GetNumInfo() );
+ GetNumInfo().Clear();
+ }
+#ifndef NUM_RELSPACE
+ else if( GetNumInfo().GetNumRule() && pTable )
+ {
+ // Die NumRule befindet sich nicht mehr unbedingt in einem
+ // zusammenhaengenden Bereich und muss deshalb vollst.
+ // aktualisiert werden.
+ GetNumInfo().SetUpdateWholeNum( TRUE );
+ }
+#endif
+
+ if( (HTML_CNTXT_KEEP_ATTRS & nFlags) != 0 )
+ {
+ // Attribute an aktueller Position beenden und an neuer neu anfangen
+ SplitAttrTab( *pNewPos );
+ }
+ else
+ {
+ _HTMLAttrTable *pSaveAttrTab = pSave->GetAttrTab( TRUE );
+ SaveAttrTab( *pSaveAttrTab );
+ }
+
+
+ pSave->SetPos( *pPam->GetPoint() );
+ *pPam->GetPoint() = *pNewPos;
+ }
+
+ // Mit dem Setzen von nContextStMin koennen automatisch auch
+ // keine gerade offenen Listen (DL/OL/UL) mehr beendet werden.
+ if( (HTML_CNTXT_PROTECT_STACK & nFlags) != 0 )
+ {
+ pSave->SetContextStMin( nContextStMin );
+ nContextStMin = aContexts.Count();
+
+ if( (HTML_CNTXT_KEEP_ATTRS & nFlags) == 0 )
+ {
+ pSave->SetContextStAttrMin( nContextStAttrMin );
+ nContextStAttrMin = aContexts.Count();
+ }
+ }
+}
+
+void SwHTMLParser::RestoreDocContext( _HTMLAttrContext *pCntxt )
+{
+ _HTMLAttrContext_SaveDoc *pSave = pCntxt->GetSaveDocContext();
+ if( !pSave )
+ return;
+
+ if( pSave->GetStripTrailingPara() )
+ StripTrailingPara();
+
+ if( pSave->GetPos() )
+ {
+ if( pSave->GetFixHeaderDist() || pSave->GetFixFooterDist() )
+ FixHeaderFooterDistance( pSave->GetFixHeaderDist(),
+ pSave->GetPos() );
+
+ _HTMLAttrTable *pSaveAttrTab = pSave->GetAttrTab();
+ if( !pSaveAttrTab )
+ {
+ // Attribute an aktueller Position beenden und an alter neu
+ // anfangen.
+ SplitAttrTab( *pSave->GetPos() );
+ }
+ else
+ {
+ RestoreAttrTab( *pSaveAttrTab );
+ }
+
+ *pPam->GetPoint() = *pSave->GetPos();
+
+ // Die bisherigen Attribute koennen wir schonmal setzen.
+ SetAttr();
+ }
+
+ if( USHRT_MAX != pSave->GetContextStMin() )
+ {
+ nContextStMin = pSave->GetContextStMin();
+ if( USHRT_MAX != pSave->GetContextStAttrMin() )
+ nContextStAttrMin = pSave->GetContextStAttrMin();
+ }
+
+ if( !pSave->GetKeepNumRules() )
+ {
+ // Die bisherige gemerkte Numerierung wieder setzen
+ GetNumInfo().Set( pSave->GetNumInfo() );
+ }
+#ifndef NUM_RELSPACE
+ else if( GetNumInfo().GetNumRule() && pTable )
+ {
+ // Die NumRule befindet sich nicht mehr unbedingt in einem
+ // zusammenhaengenden Bereich und muss deshalb vollst.
+ // aktualisiert werden.
+ GetNumInfo().SetUpdateWholeNum( TRUE );
+ }
+#endif
+
+ pCntxt->ClearSaveDocContext();
+}
+
+/* */
+
+void SwHTMLParser::EndContext( _HTMLAttrContext *pContext )
+{
+ if( pContext->GetPopStack() )
+ {
+ // Alle noch offenen Kontexte beenden. Der eigene
+ // Kontext muss bereits geloscht sein!
+ while( aContexts.Count() > nContextStMin )
+ {
+ _HTMLAttrContext *pCntxt = PopContext();
+ ASSERT( pCntxt != pContext,
+ "Kontext noch im Stack" );
+ if( pCntxt == pContext )
+ break;
+
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+ }
+
+ // Alle noch offenen Attribute beenden
+ if( pContext->HasAttrs() )
+ EndContextAttrs( pContext );
+
+ // Falls ein Bereich geoeffnet wurde, den verlassen. Da Bereiche
+ // auch innerhalb von absolut positionierten Objekten angelegt werden,
+ // muss das passieren, bever ein alter Dokument-Kontext restauriert wird.
+ if( pContext->GetSpansSection() )
+ EndSection();
+
+ // Rahmen und sonstige Sonderbereiche verlassen.
+ if( pContext->HasSaveDocContext() )
+ RestoreDocContext( pContext );
+
+ // Ggf. noch einen Ansatz-Umbruch einfuegen
+ if( AM_NONE != pContext->GetAppendMode() &&
+ pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( pContext->GetAppendMode() );
+
+ // PRE-/LISTING- und XMP-Umgebungen wieder starten
+ if( pContext->IsFinishPREListingXMP() )
+ FinishPREListingXMP();
+
+ if( pContext->IsRestartPRE() )
+ StartPRE();
+
+ if( pContext->IsRestartXMP() )
+ StartXMP();
+
+ if( pContext->IsRestartListing() )
+ StartListing();
+}
+
+void SwHTMLParser::ClearContext( _HTMLAttrContext *pContext )
+{
+ _HTMLAttrs &rAttrs = pContext->GetAttrs();
+ for( USHORT i=0; i<rAttrs.Count(); i++ )
+ {
+ // einfaches Loeschen reicht hier nicht, weil das
+ // Attribut auch aus seiner Liste ausgetragen werden
+ // muss. Theoretisch koennt man natuerlich auch die Liste
+ // und die Attribute getrennt loeschen, aber wenn man
+ // dann was falsch gemacht hat, sieht es uebel aus.
+ DeleteAttr( rAttrs[i] );
+ }
+
+ ASSERT( !pContext->GetSpansSection(),
+ "Bereich kann nicht mehr verlassen werden" );
+
+ ASSERT( !pContext->HasSaveDocContext(),
+ "Rahmen kann nicht mehr verlassen werden" );
+
+ // PRE-/LISTING- und XMP-Umgebungen wieder starten
+ if( pContext->IsFinishPREListingXMP() )
+ FinishPREListingXMP();
+
+ if( pContext->IsRestartPRE() )
+ StartPRE();
+
+ if( pContext->IsRestartXMP() )
+ StartXMP();
+
+ if( pContext->IsRestartListing() )
+ StartListing();
+}
+
+/* */
+
+BOOL SwHTMLParser::DoPositioning( SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ _HTMLAttrContext *pContext )
+{
+ BOOL bRet = FALSE;
+
+ // Unter folgenden Umstaenden wird jetzt ein Rahmen aufgemacht:
+ // - das Tag wird absolut positioniert und left/top sind beide
+ // gegeben und enthalten auch keine %-Angabe, oder
+ // - das Tag soll fliessen, und
+ // - es wurde eine Breite angegeben (in beiden Faellen noetig)
+ if( SwCSS1Parser::MayBePositioned( rPropInfo ) )
+ {
+ SfxItemSet aFrmItemSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs(aFrmItemSet );
+
+ // Ausrichtung setzen
+ SetAnchorAndAdjustment( VERT_NONE, HORI_NONE, rItemSet, rPropInfo,
+ aFrmItemSet );
+
+ // Groesse setzen
+ SetVarSize( rItemSet, rPropInfo, aFrmItemSet );
+
+ // Abstaende setzen
+ SetSpace( Size(0,0), rItemSet, rPropInfo, aFrmItemSet );
+
+ // Sonstige CSS1-Attribute Setzen
+ SetFrmFmtAttrs( rItemSet, rPropInfo,
+ HTML_FF_BOX|HTML_FF_PADDING|HTML_FF_BACKGROUND,
+ aFrmItemSet );
+
+ InsertFlyFrame( aFrmItemSet, pContext, rPropInfo.aId,
+ CONTEXT_FLAGS_ABSPOS );
+ pContext->SetPopStack( TRUE );
+ rPropInfo.aId.Erase();
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+BOOL SwHTMLParser::CreateContainer( const String& rClass,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ _HTMLAttrContext *pContext )
+{
+ BOOL bRet = FALSE;
+ if( rClass.EqualsIgnoreCaseAscii(sCSS1_class_abs_pos) &&
+ pCSS1Parser->MayBePositioned( rPropInfo ) )
+ {
+ // Container-Klasse
+ SfxItemSet *pFrmItemSet = pContext->GetFrmItemSet( pDoc );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( *pFrmItemSet );
+
+ SetAnchorAndAdjustment( VERT_NONE, HORI_NONE,
+ rItemSet, rPropInfo, *pFrmItemSet );
+ Size aDummy(0,0);
+ SetFixSize( aDummy, aDummy, FALSE, FALSE, rItemSet, rPropInfo,
+ *pFrmItemSet );
+ SetSpace( aDummy, rItemSet, rPropInfo, *pFrmItemSet );
+ SetFrmFmtAttrs( rItemSet, rPropInfo, HTML_FF_BOX|HTML_FF_BACKGROUND,
+ *pFrmItemSet );
+
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+/* */
+
+void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ _HTMLAttrContext *pContext,
+ BOOL bCharLvl )
+{
+ // Ein DropCap-Attribut basteln, wenn auf Zeichen-Ebene vor dem
+ // ersten Zeichen ein float: left vorkommt
+ if( bCharLvl && !pPam->GetPoint()->nContent.GetIndex() &&
+ SVX_ADJUST_LEFT == rPropInfo.eFloat )
+ {
+ SwFmtDrop aDrop;
+ aDrop.GetChars() = 1;
+
+ pCSS1Parser->FillDropCap( aDrop, rItemSet );
+
+ // Nur wenn das Initial auch ueber mehrere Zeilen geht, wird das
+ // DropCap-Attribut gesetzt. Sonst setzten wir die Attribute hart.
+ if( aDrop.GetLines() > 1 )
+ {
+ NewAttr( &aAttrTab.pDropCap, aDrop );
+
+ _HTMLAttrs &rAttrs = pContext->GetAttrs();
+ rAttrs.Insert( aAttrTab.pDropCap, rAttrs.Count() );
+
+ return;
+ }
+ }
+
+// Feature: PrintExt
+ if( !bCharLvl )
+ pCSS1Parser->SetFmtBreak( rItemSet, rPropInfo );
+// /Feature: PrintExt
+
+ ASSERT( aContexts.Count() <= nContextStAttrMin ||
+ aContexts[aContexts.Count()-1] != pContext,
+ "SwHTMLParser::InsertAttrs: Kontext doch schon auf dem Stack" );
+
+ SfxItemIter aIter( rItemSet );
+
+ const SfxPoolItem *pItem = aIter.FirstItem();
+ while( pItem )
+ {
+ _HTMLAttr **ppAttr = 0;
+
+ switch( pItem->Which() )
+ {
+ case RES_LR_SPACE:
+ {
+ // Absatz-Einzuege muessen addiert werden und werden immer
+ // nur absatzweise gesetzt (fuer den ersten Absatz hier,
+ // fuer alle folgenden in SetTxtCollAttrs)
+
+ const SvxLRSpaceItem *pLRItem =
+ (const SvxLRSpaceItem *)pItem;
+
+ // die bisherigen Absatz-Abstaende holen (ohne die vom
+ // obersten Kontext, denn den veraendern wir ja gerade) ...
+ USHORT nOldLeft = 0, nOldRight = 0;
+ short nOldIndent = 0;
+ BOOL bIgnoreTop = aContexts.Count() > nContextStMin &&
+ aContexts[aContexts.Count()-1] == pContext;
+ GetMarginsFromContext( nOldLeft, nOldRight, nOldIndent,
+ bIgnoreTop );
+
+
+ // und noch die aktuell gueltigen
+ USHORT nLeft = nOldLeft, nRight = nOldRight;
+ short nIndent = nOldIndent;
+ pContext->GetMargins( nLeft, nRight, nIndent );
+
+ // ... und die neuen Abstaende zu den alten addieren
+ // Hier werden nicht die aus dem Item genommen, sondern die
+ // extra gemerkten, weil die auch negativ sein koennen. Die
+ // Abfrage ueber das Item funktioniert aber trotzdem, denn
+ // fuer negative Werte wird das Item (mit Wert 0) auch
+ // eingefuegt.
+ if( rPropInfo.bLeftMargin )
+ {
+ ASSERT( rPropInfo.nLeftMargin < 0 ||
+ rPropInfo.nLeftMargin == pLRItem->GetTxtLeft(),
+ "linker Abstand stimmt nicht mit Item ueberein" );
+ if( rPropInfo.nLeftMargin < 0 &&
+ -rPropInfo.nLeftMargin > nOldLeft )
+ nLeft = 0;
+ else
+ nLeft = nOldLeft + rPropInfo.nLeftMargin;
+ }
+ if( rPropInfo.bRightMargin )
+ {
+ ASSERT( rPropInfo.nRightMargin < 0 ||
+ rPropInfo.nRightMargin == pLRItem->GetRight(),
+ "rechter Abstand stimmt nicht mit Item ueberein" );
+ if( rPropInfo.nRightMargin < 0 &&
+ -rPropInfo.nRightMargin > nOldRight )
+ nRight = 0;
+ else
+ nRight = nOldRight + rPropInfo.nRightMargin;
+ }
+ if( rPropInfo.bTextIndent )
+ nIndent = pLRItem->GetTxtFirstLineOfst();
+
+ // und die Werte fuer nachfolgende Absaetze merken
+ pContext->SetMargins( nLeft, nRight, nIndent );
+
+#ifndef NUM_RELSPACE
+ // Numerierungen erfordern etwas mehr Aufwand
+ if( GetNumInfo().GetNumRule() )
+ {
+ SwTxtNode *pNumTxtNode = pPam->GetNode()->GetTxtNode();
+
+ if( pNumTxtNode->GetNum() &&
+ !(NO_NUMLEVEL & pNumTxtNode->GetNum()->GetLevel()) )
+ nIndent += HTML_NUMBUL_INDENT;
+
+ // den Absatz muessen wir jetzt selbst attributieren
+ pNumTxtNode->SetNumLSpace( FALSE );
+ }
+#endif
+
+ // das Attribut noch am aktuellen Absatz setzen
+ SvxLRSpaceItem aLRItem( *pLRItem );
+ aLRItem.SetTxtFirstLineOfst( nIndent );
+ aLRItem.SetTxtLeft( nLeft );
+ aLRItem.SetRight( nRight );
+ NewAttr( &aAttrTab.pLRSpace, aLRItem );
+ EndAttr( aAttrTab.pLRSpace, 0, FALSE );
+ }
+ break;
+
+ case RES_UL_SPACE:
+ if( !rPropInfo.bTopMargin || !rPropInfo.bBottomMargin )
+ {
+ USHORT nUpper = 0, nLower = 0;
+ GetULSpaceFromContext( nUpper, nLower );
+ SvxULSpaceItem aULSpace( *((const SvxULSpaceItem *)pItem) );
+ if( !rPropInfo.bTopMargin )
+ aULSpace.SetUpper( nUpper );
+ if( !rPropInfo.bBottomMargin )
+ aULSpace.SetLower( nLower );
+
+ NewAttr( &aAttrTab.pULSpace, aULSpace );
+
+ // ... und noch die Kontext-Information speichern
+ _HTMLAttrs &rAttrs = pContext->GetAttrs();
+ rAttrs.Insert( aAttrTab.pULSpace, rAttrs.Count() );
+
+ pContext->SetULSpace( aULSpace.GetUpper(), aULSpace.GetLower() );
+ }
+ else
+ {
+ ppAttr = &aAttrTab.pULSpace;
+ }
+ break;
+ case RES_CHRATR_FONTSIZE:
+ // es werden keine Attribute mit %-Angaben gesetzt
+ if( ((const SvxFontHeightItem *)pItem)->GetProp() == 100 )
+ ppAttr = &aAttrTab.pFontHeight;
+ break;
+
+ case RES_BACKGROUND:
+ if( bCharLvl )
+ {
+ // das Frame-Attr ggf. in ein Char-Attr umwandeln
+ SvxBrushItem aBrushItem( *(const SvxBrushItem *)pItem );
+ aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
+
+ // Das Attribut setzen ...
+ NewAttr( &aAttrTab.pCharBrush, aBrushItem );
+
+ // ... und noch die Kontext-Information speichern
+ _HTMLAttrs &rAttrs = pContext->GetAttrs();
+ rAttrs.Insert( aAttrTab.pCharBrush, rAttrs.Count() );
+ }
+ else if( pContext->GetToken() != HTML_TABLEHEADER_ON &&
+ pContext->GetToken() != HTML_TABLEDATA_ON )
+ {
+ ppAttr = &aAttrTab.pBrush;
+ }
+ break;
+
+ default:
+ // den zu dem Item gehoehrenden Tabellen-Eintrag ermitteln ...
+ ppAttr = GetAttrTabEntry( pItem->Which() );
+ break;
+ }
+
+ if( ppAttr )
+ {
+ // Das Attribut setzen ...
+ NewAttr( ppAttr, *pItem );
+
+ // ... und noch die Kontext-Information speichern
+ _HTMLAttrs &rAttrs = pContext->GetAttrs();
+ rAttrs.Insert( *ppAttr, rAttrs.Count() );
+ }
+
+ // auf zum naechsten Item
+ pItem = aIter.NextItem();
+ }
+
+ if( rPropInfo.aId.Len() )
+ InsertBookmark( rPropInfo.aId );
+}
+
+void SwHTMLParser::InsertAttr( _HTMLAttr **ppAttr, const SfxPoolItem & rItem,
+ _HTMLAttrContext *pCntxt )
+{
+ if( !ppAttr )
+ {
+ ppAttr = GetAttrTabEntry( rItem.Which() );
+ if( !ppAttr )
+ return;
+ }
+
+ // das Attribut setzen
+ NewAttr( ppAttr, rItem );
+
+ // und im Kontext merken
+ _HTMLAttrs &rAttrs = pCntxt->GetAttrs();
+ rAttrs.Insert( *ppAttr, rAttrs.Count() );
+}
+
+void SwHTMLParser::SplitPREListingXMP( _HTMLAttrContext *pCntxt )
+{
+ // PRE/Listing/XMP soll beim beenden des Kontexts beendet werden.
+ pCntxt->SetFinishPREListingXMP( TRUE );
+
+ // Und die jetzt gueltigen Flags sollen wieder gesetzt werden.
+ if( IsReadPRE() )
+ pCntxt->SetRestartPRE( TRUE );
+ if( IsReadXMP() )
+ pCntxt->SetRestartXMP( TRUE );
+ if( IsReadListing() )
+ pCntxt->SetRestartListing( TRUE );
+
+ // PRE/Listing/XMP wird auuserdem sofort beendet
+ FinishPREListingXMP();
+}
+
+SfxItemSet *_HTMLAttrContext::GetFrmItemSet( SwDoc *pCreateDoc )
+{
+ if( !pFrmItemSet && pCreateDoc )
+ pFrmItemSet = new SfxItemSet( pCreateDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ return pFrmItemSet;
+}
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlctxt.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.33 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.32 2000/04/10 12:20:55 mib
+ unicode
+
+ Revision 1.31 1999/03/26 10:37:28 MIB
+ #63049#: Sofortige Numerierungs-Aktualisierung in Tabellen ist jetzt unnoetig
+
+
+ Rev 1.30 26 Mar 1999 11:37:28 MIB
+ #63049#: Sofortige Numerierungs-Aktualisierung in Tabellen ist jetzt unnoetig
+
+ Rev 1.29 23 Mar 1999 15:28:14 MIB
+ #63049#: Relative Einzuege in Numerierungen
+
+ Rev 1.28 17 Mar 1999 16:46:20 MIB
+ #63049#: Numerierungen mit relativen Abstaenden
+
+ Rev 1.27 06 Nov 1998 15:33:36 MIB
+ #59043#: negative Absatz-Einzuege
+
+ Rev 1.26 21 Apr 1998 13:46:10 MIB
+ fix: Keine Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.25 15 Apr 1998 14:47:42 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.24 03 Apr 1998 12:21:46 MIB
+ Export des Rahmen-Namens als ID
+
+ Rev 1.23 02 Apr 1998 19:43:24 MIB
+ Positionierung von spaltigen Rahmen
+
+ Rev 1.22 27 Mar 1998 10:04:10 MIB
+ direkte Positionierung von Grafiken etc.
+
+ Rev 1.21 25 Mar 1998 12:08:18 MIB
+ abs.-pos. Container angefangen
+
+ Rev 1.20 19 Mar 1998 09:03:28 MIB
+ Abs.-Pos.: Attributierung nicht in Rahmen uebernehmen, Hoehe nun Mindest-Hoehe
+
+ Rev 1.19 15 Mar 1998 16:51:14 MIB
+ abs.-pos.: Abstaende bei Positionierung beachten, Hoehe nur noch Mindest-Hoehe
+
+ Rev 1.18 13 Mar 1998 09:25:52 MIB
+ Abs-Pos: margins als Rahmen-Abstaende uebernehmen
+
+ Rev 1.17 11 Mar 1998 18:25:38 MIB
+ abs. Pos.: Verankerung angepassr
+
+ Rev 1.16 20 Feb 1998 19:04:30 MA
+ header
+
+ Rev 1.15 19 Jan 1998 16:25:56 MIB
+ Numerierungs-Umbau
+
+ Rev 1.14 26 Nov 1997 19:09:22 MA
+ includes
+
+ Rev 1.13 17 Nov 1997 10:16:48 JP
+ Umstellung Numerierung
+
+ Rev 1.12 20 Oct 1997 09:51:56 MIB
+ Nur fuer absolute positioning benoetigten Code groesstenteils auskommentiert
+
+ Rev 1.11 17 Oct 1997 13:20:32 MIB
+ page-break-xxx auch uber STYLE/CLASS und ID-Optionen
+
+ Rev 1.10 09 Oct 1997 14:36:10 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.9 16 Sep 1997 17:25:10 MIB
+ abs. Positioning fuer Absatz-Tags
+
+ Rev 1.8 16 Sep 1997 11:15:00 MIB
+ Kopf-/Fusszeilen ohne Moven von Nodes, autom. Beenden von Bereichen/Rahmen
+
+ Rev 1.7 12 Sep 1997 11:56:16 MIB
+ fix #41253#: Script in PRE (keine Schleifen), MULTICOL ohne Move von Nodes
+
+ Rev 1.6 08 Sep 1997 17:49:12 MIB
+ Verankerung von AUTO_CNTNT-Rahmen nicht mehr verschieben
+
+ Rev 1.5 08 Sep 1997 10:33:44 MIB
+ Keine Schleifen fuer PRE mehr (auch fix #41253#) (nicht freigeschaltet)
+
+ Rev 1.4 15 Aug 1997 12:47:48 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.3 12 Aug 1997 13:44:18 OS
+ Header-Umstellung
+
+ Rev 1.2 07 Aug 1997 15:07:50 OM
+ Headerfile-Umstellung
+
+ Rev 1.1 04 Aug 1997 13:54:08 MIB
+ aboslute psoitioning (fuer fast alle Zeichen-Attribute/-Vorlagen)
+
+ Rev 1.0 04 Aug 1997 13:02:32 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmldraw.cxx b/sw/source/filter/html/htmldraw.cxx
new file mode 100644
index 000000000000..be480628676e
--- /dev/null
+++ b/sw/source/filter/html/htmldraw.cxx
@@ -0,0 +1,1070 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmldraw.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SVDMODEL_HXX //autogen
+#include <svx/svdmodel.hxx>
+#endif
+#ifndef _SVDPAGE_HXX //autogen
+#include <svx/svdpage.hxx>
+#endif
+#ifndef _SVDOBJ_HXX //autogen
+#include <svx/svdobj.hxx>
+#endif
+#ifndef _SVDOTEXT_HXX //autogen
+#include <svx/svdotext.hxx>
+#endif
+#ifndef _EEITEM_HXX //autogen
+#include <svx/eeitem.hxx>
+#endif
+#ifndef _OUTLINER_HXX //autogen
+#define _EEITEMID_HXX
+#include <svx/outliner.hxx>
+#endif
+#ifndef SVX_XFILLIT0_HXX //autogen
+#include <svx/xfillit0.hxx>
+#endif
+#ifndef _SVX_FILLITEM_HXX //autogen
+#include <svx/xfillit.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SFX_WHITER_HXX //autogen
+#include <svtools/whiter.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _SVDPOOL_HXX //autogen
+#include <svx/svdpool.hxx>
+#endif
+
+
+#ifndef _CHARATR_HXX
+#include "charatr.hxx"
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#include "ndtxt.hxx"
+#include "doc.hxx"
+#include "dcontact.hxx"
+#include "poolfmt.hxx"
+#include "swcss1.hxx"
+#include "swhtml.hxx"
+#include "wrthtml.hxx"
+
+
+const sal_uInt32 HTML_FRMOPTS_MARQUEE =
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SPACE;
+
+const sal_uInt32 HTML_FRMOPTS_MARQUEE_CSS1 =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SPACE;
+
+static HTMLOptionEnum __FAR_DATA aHTMLMarqBehaviorTable[] =
+{
+ { sHTML_BEHAV_scroll, SDRTEXTANI_SCROLL },
+ { sHTML_BEHAV_alternate, SDRTEXTANI_ALTERNATE },
+ { sHTML_BEHAV_slide, SDRTEXTANI_SLIDE },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLMarqDirectionTable[] =
+{
+ { sHTML_AL_left, SDRTEXTANI_LEFT },
+ { sHTML_AL_right, SDRTEXTANI_RIGHT },
+ { 0, 0 }
+};
+
+/* */
+void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
+ const Size& rPixSpace,
+ SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ SfxItemSet& rCSS1ItemSet,
+ SvxCSS1PropertyInfo& rCSS1PropInfo,
+ sal_Bool bHidden )
+{
+ // immer ueber dem Text stehen
+ pNewDrawObj->SetLayer( pDoc->GetHeavenId() );
+
+ SfxItemSet aFrmSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aFrmSet );
+
+ sal_uInt16 nLeftSpace = 0, nRightSpace = 0, nUpperSpace = 0, nLowerSpace = 0;
+ if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
+ {
+ Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
+ aTwipSpc =
+ Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
+ MapMode(MAP_TWIP) );
+ nLeftSpace = nRightSpace = (sal_uInt16)aTwipSpc.Width();
+ nUpperSpace = nLowerSpace = (sal_uInt16)aTwipSpc.Height();
+ }
+
+ // linken/rechten Rand setzen
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, sal_True, &pItem ) )
+ {
+ // Ggf. den Erstzeilen-Einzug noch plaetten
+ const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
+ SvxLRSpaceItem aLRItem( *pLRItem );
+ aLRItem.SetTxtFirstLineOfst( 0 );
+ if( rCSS1PropInfo.bLeftMargin )
+ {
+ nLeftSpace = aLRItem.GetLeft();
+ rCSS1PropInfo.bLeftMargin = sal_False;
+ }
+ if( rCSS1PropInfo.bRightMargin )
+ {
+ nRightSpace = aLRItem.GetRight();
+ rCSS1PropInfo.bRightMargin = sal_False;
+ }
+ rCSS1ItemSet.ClearItem( RES_LR_SPACE );
+ }
+ if( nLeftSpace || nRightSpace )
+ {
+ SvxLRSpaceItem aLRItem;
+ aLRItem.SetLeft( nLeftSpace );
+ aLRItem.SetRight( nRightSpace );
+ aFrmSet.Put( aLRItem );
+ }
+
+ // oberen/unteren Rand setzen
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, sal_True, &pItem ) )
+ {
+ // Ggf. den Erstzeilen-Einzug noch plaetten
+ const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
+ if( rCSS1PropInfo.bTopMargin )
+ {
+ nUpperSpace = pULItem->GetUpper();
+ rCSS1PropInfo.bTopMargin = sal_False;
+ }
+ if( rCSS1PropInfo.bBottomMargin )
+ {
+ nLowerSpace = pULItem->GetLower();
+ rCSS1PropInfo.bBottomMargin = sal_False;
+ }
+
+ rCSS1ItemSet.ClearItem( RES_UL_SPACE );
+ }
+ if( nUpperSpace || nLowerSpace )
+ {
+ SvxULSpaceItem aULItem;
+ aULItem.SetUpper( nUpperSpace );
+ aULItem.SetLower( nLowerSpace );
+ aFrmSet.Put( aULItem );
+ }
+
+ SwFmtAnchor aAnchor( FLY_IN_CNTNT );
+ if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition &&
+ SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType &&
+ SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType )
+ {
+ const SwStartNode *pFlySttNd =
+ pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode();
+
+ if( pFlySttNd )
+ {
+ aAnchor.SetType( FLY_AT_FLY );
+ SwPosition aPos( *pFlySttNd );
+ aAnchor.SetAnchor( &aPos );
+ }
+ else
+ {
+ aAnchor.SetType( FLY_PAGE );
+ }
+ pNewDrawObj->SetRelativePos( Point(rCSS1PropInfo.nLeft + nLeftSpace,
+ rCSS1PropInfo.nTop + nUpperSpace) );
+ aFrmSet.Put( SwFmtSurround(SURROUND_THROUGHT) );
+ }
+ else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat ||
+ HORI_LEFT == eHoriOri )
+ {
+ aAnchor.SetType( FLY_AT_CNTNT );
+ aFrmSet.Put( SwFmtSurround(bHidden ? SURROUND_THROUGHT
+ : SURROUND_RIGHT) );
+ pNewDrawObj->SetRelativePos( Point(nLeftSpace, nUpperSpace) );
+ }
+ else if( VERT_NONE != eVertOri )
+ {
+ aFrmSet.Put( SwFmtVertOrient( 0, eVertOri ) );
+ }
+
+ if( FLY_PAGE == aAnchor.GetAnchorId() )
+ aAnchor.SetPageNum( 1 );
+ else if( FLY_AT_FLY != aAnchor.GetAnchorId() )
+ aAnchor.SetAnchor( pPam->GetPoint() );
+ aFrmSet.Put( aAnchor );
+
+ pDoc->Insert( *pPam, *pNewDrawObj, &aFrmSet );
+}
+
+/* */
+
+static void PutEEPoolItem( SfxItemSet &rEEItemSet,
+ const SfxPoolItem& rSwItem )
+{
+
+ sal_uInt16 nEEWhich = 0;
+
+ switch( rSwItem.Which() )
+ {
+ case RES_CHRATR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
+ case RES_CHRATR_CROSSEDOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
+ case RES_CHRATR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
+ case RES_CHRATR_FONT: nEEWhich = EE_CHAR_FONTINFO; break;
+ case RES_CHRATR_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT; break;
+ case RES_CHRATR_KERNING: nEEWhich = EE_CHAR_KERNING; break;
+ case RES_CHRATR_POSTURE: nEEWhich = EE_CHAR_ITALIC; break;
+ case RES_CHRATR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE; break;
+ case RES_CHRATR_WEIGHT: nEEWhich = EE_CHAR_WEIGHT; break;
+ case RES_BACKGROUND:
+ case RES_CHRATR_BACKGROUND:
+ {
+ const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rSwItem;
+ rEEItemSet.Put( XFillStyleItem(XFILL_SOLID) );
+ rEEItemSet.Put( XFillColorItem(aEmptyStr,
+ rBrushItem.GetColor()) );
+ }
+ break;
+ }
+
+ if( nEEWhich )
+ {
+ SfxPoolItem *pEEItem = rSwItem.Clone();
+ pEEItem->SetWhich( nEEWhich );
+ rEEItemSet.Put( *pEEItem );
+ delete pEEItem;
+ }
+}
+
+void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
+{
+
+ ASSERT( !pMarquee, "Marquee in Marquee???" );
+ aContents.Erase();
+
+ String aId, aStyle, aClass;
+
+ long nWidth=0, nHeight=0;
+ sal_Bool bPrcWidth = sal_False, bDirection = sal_False, bBGColor = sal_False;
+ Size aSpace( 0, 0 );
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
+ SdrTextAniKind eAniKind = SDRTEXTANI_SCROLL;
+ SdrTextAniDirection eAniDir = SDRTEXTANI_LEFT;
+ sal_uInt16 nCount = 0, nDelay = 60;
+ sal_Int16 nAmount = -6;
+ Color aBGColor;
+
+ const HTMLOptions *pOptions = GetOptions();
+ sal_uInt16 nArrLen = pOptions->Count();
+ for ( sal_uInt16 i=0; i<nArrLen; i++ )
+ {
+ const HTMLOption *pOption = (*pOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+
+ case HTML_O_BEHAVIOR:
+ eAniKind =
+ (SdrTextAniKind)pOption->GetEnum( aHTMLMarqBehaviorTable,
+ eAniKind );
+ break;
+
+ case HTML_O_BGCOLOR:
+ pOption->GetColor( aBGColor );
+ bBGColor = sal_True;
+ break;
+
+ case HTML_O_DIRECTION:
+ eAniDir =
+ (SdrTextAniDirection)pOption->GetEnum( aHTMLMarqDirectionTable,
+ eAniDir );
+ bDirection = sal_True;
+ break;
+
+ case HTML_O_LOOP:
+ if( pOption->GetString().
+ EqualsIgnoreCaseAscii(sHTML_LOOP_infinite) )
+ {
+ nCount = 0;
+ }
+ else
+ {
+ sal_uInt32 nLoop = pOption->GetSNumber();
+ nCount = (sal_uInt16)(nLoop>0 ? nLoop : 0 );
+ }
+ break;
+
+ case HTML_O_SCROLLAMOUNT:
+ nAmount = -((sal_Int16)pOption->GetNumber());
+ break;
+
+ case HTML_O_SCROLLDELAY:
+ nDelay = (sal_uInt16)pOption->GetNumber();
+ break;
+
+ case HTML_O_WIDTH:
+ // erstmal nur als Pixelwerte merken!
+ nWidth = pOption->GetNumber();
+ bPrcWidth = pOption->GetString().Search('%') != STRING_NOTFOUND;
+ if( bPrcWidth && nWidth>100 )
+ nWidth = 100;
+ break;
+
+ case HTML_O_HEIGHT:
+ // erstmal nur als Pixelwerte merken!
+ nHeight = pOption->GetNumber();
+ if( pOption->GetString().Search('%') != STRING_NOTFOUND )
+ nHeight = 0;
+ break;
+
+ case HTML_O_HSPACE:
+ // erstmal nur als Pixelwerte merken!
+ aSpace.Height() = pOption->GetNumber();
+ break;
+
+ case HTML_O_VSPACE:
+ // erstmal nur als Pixelwerte merken!
+ aSpace.Width() = pOption->GetNumber();
+ break;
+
+ case HTML_O_ALIGN:
+ eVertOri =
+ (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable,
+ VERT_TOP );
+ eHoriOri =
+ (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable,
+ HORI_NONE );
+ break;
+ }
+ }
+
+ // Ein DrawTxtobj anlegen
+ SdrModel* pModel = pDoc->MakeDrawModel();
+ SdrPage* pPg = pModel->GetPage( 0 );
+ pMarquee = SdrObjFactory::MakeNewObject( SdrInventor,
+ OBJ_TEXT, pPg, pModel );
+ if( !pMarquee )
+ return;
+
+ pPg->InsertObject( pMarquee );
+
+ if( aId.Len() )
+ InsertBookmark( aId );
+
+ // (Nur) Alternate leueft per Default von links nach rechts
+ if( SDRTEXTANI_ALTERNATE==eAniKind && !bDirection )
+ eAniDir = SDRTEXTANI_RIGHT;
+
+ // die fuer das Scrollen benoetigten Attribute umsetzen
+ sal_uInt16 aWhichMap[7] = { XATTR_FILL_FIRST, XATTR_FILL_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ EE_CHAR_START, EE_CHAR_END,
+ 0 };
+ SfxItemSet aItemSet( pModel->GetItemPool(), aWhichMap );
+ aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
+ aItemSet.Put( SdrTextAutoGrowHeightItem( sal_True ) );
+ aItemSet.Put( SdrTextAniKindItem( eAniKind ) );
+ aItemSet.Put( SdrTextAniDirectionItem( eAniDir ) );
+ aItemSet.Put( SdrTextAniCountItem( nCount ) );
+ aItemSet.Put( SdrTextAniDelayItem( nDelay ) );
+ aItemSet.Put( SdrTextAniAmountItem( nAmount ) );
+ if( SDRTEXTANI_ALTERNATE==eAniKind )
+ {
+ // (Nur) Alternate startet und stoppt per default Inside
+ aItemSet.Put( SdrTextAniStartInsideItem(sal_True) );
+ aItemSet.Put( SdrTextAniStopInsideItem(sal_True) );
+ if( SDRTEXTANI_LEFT==eAniDir )
+ aItemSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
+ }
+
+ // die Default-Farbe (aus der Standard-Vorlage) setzen, damit ueberhaupt
+ // eine sinnvolle Farbe gesetzt ist.
+ const Color& rDfltColor =
+ pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )
+ ->GetColor().GetValue();
+ aItemSet.Put( SvxColorItem( rDfltColor, EE_CHAR_COLOR ) );
+
+ // Die Attribute der aktuellen Absatzvorlage setzen
+ sal_uInt16 nWhichIds[] =
+ {
+ RES_CHRATR_COLOR, RES_CHRATR_CROSSEDOUT, RES_CHRATR_ESCAPEMENT,
+ RES_CHRATR_FONT, RES_CHRATR_FONTSIZE, RES_CHRATR_KERNING,
+ RES_CHRATR_POSTURE, RES_CHRATR_UNDERLINE, RES_CHRATR_WEIGHT,
+ RES_CHRATR_BACKGROUND, 0
+ };
+ const SwTxtNode *pTxtNd = pDoc->GetNodes()[pPam->GetPoint()->nNode]
+ ->GetTxtNode();
+ if( pTxtNd )
+ {
+ const SfxItemSet& rItemSet = pTxtNd->GetAnyFmtColl().GetAttrSet();
+ const SfxPoolItem *pItem;
+ for( sal_uInt16 i=0; nWhichIds[i]; i++ )
+ {
+ if( SFX_ITEM_SET == rItemSet.GetItemState( nWhichIds[i], sal_True, &pItem ) )
+ PutEEPoolItem( aItemSet, *pItem );
+ }
+ }
+
+ // die Attribute der Umgebung am Draw-Objekt setzen
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; ++pTbl )
+ {
+ _HTMLAttr *pAttr = *pTbl;
+ if( pAttr )
+ PutEEPoolItem( aItemSet, pAttr->GetItem() );
+ }
+
+ if( bBGColor )
+ {
+ aItemSet.Put( XFillStyleItem(XFILL_SOLID) );
+ aItemSet.Put( XFillColorItem(aEmptyStr, aBGColor) );
+ }
+
+ // Styles parsen (funktioniert hier nur fuer Attribute, die auch
+ // am Zeichen-Objekt gesetzt werden koennen)
+ SfxItemSet aStyleItemSet( pDoc->GetAttrPool(),
+ pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) &&
+ ParseStyleOptions( aStyle, aId, aClass, aStyleItemSet, aPropInfo ) )
+ {
+ SfxItemIter aIter( aStyleItemSet );
+
+ const SfxPoolItem *pItem = aIter.FirstItem();
+ while( pItem )
+ {
+ PutEEPoolItem( aItemSet, *pItem );
+ pItem = aIter.NextItem();
+ }
+ }
+
+ // jetzt noch die Groesse setzen
+ Size aTwipSz( bPrcWidth ? 0 : nWidth, nHeight );
+ if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ {
+ aTwipSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
+ }
+
+ if( SVX_CSS1_LTYPE_TWIP== aPropInfo.eWidthType )
+ {
+ aTwipSz.Width() = aPropInfo.nWidth;
+ nWidth = 1; // != 0;
+ bPrcWidth = sal_False;
+ }
+ if( SVX_CSS1_LTYPE_TWIP== aPropInfo.eHeightType )
+ aTwipSz.Height() = aPropInfo.nHeight;
+
+ bFixMarqueeWidth = sal_False;
+ if( !nWidth || bPrcWidth )
+ {
+ if( pTable )
+ {
+ if( !pCurTable )
+ {
+ // Die Laufschrift steht in einer Tabelle, aber nicht
+ // in einer Zelle. Da jetzt keine vernuenftige Zuordung
+ // zu einer Zelle moeglich ist, passen wir hir die
+ // Breite dem Inhalt der Laufschrift an.
+ bFixMarqueeWidth = sal_True;
+ }
+ else if( !nWidth )
+ {
+ // Da wir wissen, in welcher Zelle die Laufschrift ist,
+ // koennen wir die Breite auch anpassen. Keine Breitenangabe
+ // wird wie 100% behandelt.
+ nWidth = 100;
+ bPrcWidth = sal_True;
+ }
+ aTwipSz.Width() = MINLAY;
+ }
+ else
+ {
+ long nBrowseWidth = GetCurrentBrowseWidth();
+ aTwipSz.Width() = !nWidth ? nBrowseWidth
+ : (nWidth*nBrowseWidth) / 100;
+ }
+ }
+
+ // Die Hoehe ist nur eine Mindest-Hoehe
+ if( aTwipSz.Height() < MINFLY )
+ aTwipSz.Height() = MINFLY;
+ aItemSet.Put( SdrTextMinFrameHeightItem( aTwipSz.Height() ) );
+
+ pMarquee->SetAttributes( aItemSet, sal_False );
+
+ if( aTwipSz.Width() < MINFLY )
+ aTwipSz.Width() = MINFLY;
+ pMarquee->SetLogicRect( Rectangle( 0, 0, aTwipSz.Width(), aTwipSz.Height() ) );
+
+ // und das Objekt in das Dok einfuegen
+ InsertDrawObject( pMarquee, aSpace, eVertOri, eHoriOri, aStyleItemSet,
+ aPropInfo );
+
+ // Das Zeichen-Objekt der Tabelle bekanntmachen. Ist ein bisserl
+ // umstaendlich, weil noch ueber den Parser gegangen wird, obwohl die
+ // Tabelle bekannt ist, aber anderenfalls muesste man die Tabelle
+ // oeffentlich machen, und das ist auch nicht schoen. Das globale
+ // pTable kann uebrigens auch nicht verwendet werden, denn die
+ // Laufschrift kann sich auch mal in einer Sub-Tabelle befinden.
+ if( pCurTable && bPrcWidth)
+ RegisterDrawObjectToTable( pCurTable, pMarquee, (sal_uInt8)nWidth );
+}
+
+void SwHTMLParser::EndMarquee()
+{
+ ASSERT( pMarquee && OBJ_TEXT==pMarquee->GetObjIdentifier(),
+ "kein Marquee oder falscher Typ" );
+
+ if( bFixMarqueeWidth )
+ {
+ // Da es keine fixe Hoehe gibt, das Text-Objekt erstmal breiter
+ // als den Text machen, damit nicht umgebrochen wird.
+ const Rectangle& rOldRect = pMarquee->GetLogicRect();
+ pMarquee->SetLogicRect( Rectangle( rOldRect.TopLeft(),
+ Size( USHRT_MAX, 240 ) ) );
+ }
+
+ // den gesammelten Text einfuegen
+ ((SdrTextObj*)pMarquee)->SetText( aContents );
+
+ if( bFixMarqueeWidth )
+ {
+ // die Groesse dem Text anpassen.
+ ((SdrTextObj*)pMarquee)->FitFrameToTextSize();
+ }
+
+ aContents.Erase();
+ pMarquee = 0;
+}
+
+void SwHTMLParser::InsertMarqueeText()
+{
+ ASSERT( pMarquee && OBJ_TEXT==pMarquee->GetObjIdentifier(),
+ "kein Marquee oder falscher Typ" );
+
+ // das akteulle Textstueck an den Text anhaengen
+ aContents += aToken;
+}
+
+void SwHTMLParser::ResizeDrawObject( SdrObject* pObj, SwTwips nWidth )
+{
+ ASSERT( OBJ_TEXT==pObj->GetObjIdentifier(),
+ "kein Marquee oder falscher Typ" );
+
+ if( OBJ_TEXT!=pObj->GetObjIdentifier() )
+ return;
+
+ // die alte Groesse
+ const Rectangle& rOldRect = pObj->GetLogicRect();
+ Size aNewSz( nWidth, rOldRect.GetSize().Height() );
+ pObj->SetLogicRect( Rectangle( rOldRect.TopLeft(), aNewSz ) );
+}
+
+/* */
+
+const SdrObject *SwHTMLWriter::GetMarqueeTextObj( const SwDrawFrmFmt& rFmt )
+{
+ const SdrObject* pObj = rFmt.FindSdrObject();
+ return (pObj && ::IsMarqueeTextObj( *pObj )) ? pObj : 0;
+}
+
+void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
+ const SdrObject *pObj,
+ sal_Bool bSetDefaults )
+{
+ // die Edit ::com::sun::star::script::Engine-Attribute aus dem Objekt holen
+ SfxItemSet aObjItemSet( *pObj->GetItemPool(), EE_CHAR_START,
+ EE_CHAR_END );
+ pObj->TakeAttributes( aObjItemSet, sal_False, sal_False );
+
+ // ueber die Edit ::com::sun::star::script::Engine-Attribute iterieren und die Attribute
+ // in SW-Attrs wandeln bzw. default setzen
+ SfxWhichIter aIter( aObjItemSet );
+ sal_uInt16 nEEWhich = aIter.FirstWhich();
+ while( nEEWhich )
+ {
+ const SfxPoolItem *pEEItem;
+ sal_Bool bSet = SFX_ITEM_SET == aObjItemSet.GetItemState( nEEWhich, sal_False,
+ &pEEItem );
+
+ if( bSet || bSetDefaults )
+ {
+ sal_uInt16 nSwWhich = 0;
+ switch( nEEWhich )
+ {
+ case EE_CHAR_COLOR: nSwWhich = RES_CHRATR_COLOR; break;
+ case EE_CHAR_STRIKEOUT: nSwWhich = RES_CHRATR_CROSSEDOUT; break;
+ case EE_CHAR_ESCAPEMENT: nSwWhich = RES_CHRATR_ESCAPEMENT; break;
+ case EE_CHAR_FONTINFO: nSwWhich = RES_CHRATR_FONT; break;
+ case EE_CHAR_FONTHEIGHT: nSwWhich = RES_CHRATR_FONTSIZE; break;
+ case EE_CHAR_KERNING: nSwWhich = RES_CHRATR_KERNING; break;
+ case EE_CHAR_ITALIC: nSwWhich = RES_CHRATR_POSTURE; break;
+ case EE_CHAR_UNDERLINE: nSwWhich = RES_CHRATR_UNDERLINE; break;
+ case EE_CHAR_WEIGHT: nSwWhich = RES_CHRATR_WEIGHT; break;
+ }
+
+ if( nSwWhich )
+ {
+ // wenn das Item nicht gesetzt ist nehmen wir ggf. das
+ // Default-Item
+ if( !bSet )
+ pEEItem = &aObjItemSet.GetPool()->GetDefaultItem(nEEWhich);
+
+ // jetzt Clonen wir das Item mit der Which-Id des Writers
+ SfxPoolItem *pSwItem = pEEItem->Clone();
+ pSwItem->SetWhich( nSwWhich );
+ rItemSet.Put( *pSwItem );
+ delete pSwItem;
+ }
+ }
+
+ nEEWhich = aIter.NextWhich();
+ }
+}
+
+
+Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt,
+ const SwDrawFrmFmt& rFmt,
+ const SdrObject& rSdrObject )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SdrModel* pModel = rWrt.pDoc->GetDrawModel();
+ ASSERT( pModel, "Da gibt's ein Draw-Obj ohne ein Draw-Model zu haben?" );
+ const SdrTextObj *pTextObj = (const SdrTextObj *)&rSdrObject;
+
+ // Gibt es ueberhaupt auszugebenden Text
+ const OutlinerParaObject *pOutlinerParaObj =
+ pTextObj->GetOutlinerParaObject();
+ if( !pOutlinerParaObj )
+ return rWrt;
+
+ ByteString sOut( '<' );
+ sOut += sHTML_marquee;
+
+ // Die Attribute des Objektd holen
+ sal_uInt16 aWhichMap[5] = { XATTR_FILL_FIRST, XATTR_FILL_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ 0 };
+ SfxItemSet aItemSet( *pTextObj->GetItemPool(), aWhichMap );
+ pTextObj->TakeAttributes( aItemSet, sal_False, sal_False );
+
+ // BEHAVIOUR
+ SdrTextAniKind eAniKind = pTextObj->GetTextAniKind();
+ ASSERT( SDRTEXTANI_SCROLL==eAniKind ||
+ SDRTEXTANI_ALTERNATE==eAniKind ||
+ SDRTEXTANI_SLIDE==eAniKind,
+ "Text-Draw-Objekt nicht fuer Marquee geeignet" )
+
+ const sal_Char *pStr = 0;
+ switch( eAniKind )
+ {
+ case SDRTEXTANI_SCROLL: pStr = sHTML_BEHAV_scroll; break;
+ case SDRTEXTANI_SLIDE: pStr = sHTML_BEHAV_slide; break;
+ case SDRTEXTANI_ALTERNATE: pStr = sHTML_BEHAV_alternate; break;
+ }
+
+ if( pStr )
+ (((sOut += ' ') += sHTML_O_behavior) += '=') += pStr;
+
+ // DIRECTION
+ pStr = 0;
+ SdrTextAniDirection eAniDir = pTextObj->GetTextAniDirection();
+ switch( eAniDir )
+ {
+ case SDRTEXTANI_LEFT: pStr = sHTML_AL_left; break;
+ case SDRTEXTANI_RIGHT: pStr = sHTML_AL_right; break;
+ }
+
+ if( pStr )
+ (((sOut += ' ') += sHTML_O_direction) += '=') += pStr;
+
+ // LOOP
+ sal_Int32 nCount =
+ ((const SdrTextAniCountItem&)aItemSet.Get( SDRATTR_TEXT_ANICOUNT ))
+ .GetValue();
+ if( 0==nCount )
+ nCount = SDRTEXTANI_SLIDE==eAniKind ? 1 : -1;
+ (((sOut += ' ') += sHTML_O_loop) += '=')
+ += ByteString::CreateFromInt32( nCount );
+
+ // SCROLLDELAY
+ sal_uInt16 nDelay =
+ ((const SdrTextAniDelayItem&)aItemSet.Get( SDRATTR_TEXT_ANIDELAY ))
+ .GetValue();
+ (((sOut += ' ') += sHTML_O_scrolldelay) += '=')
+ += ByteString::CreateFromInt32( nDelay );
+
+ // SCROLLAMOUNT
+ sal_Int16 nAmount =
+ ((const SdrTextAniAmountItem&)aItemSet.Get( SDRATTR_TEXT_ANIAMOUNT ))
+ .GetValue();
+ if( nAmount < 0 )
+ {
+ nAmount = -nAmount;
+ }
+ else if( nAmount && Application::GetDefaultDevice() )
+ {
+ nAmount = (sal_uInt16)(Application::GetDefaultDevice()
+ ->LogicToPixel( Size(nAmount,0),
+ MapMode(MAP_TWIP) ).Width());
+ }
+ if( nAmount )
+ (((sOut += ' ') += sHTML_O_scrollamount) += '=')
+ += ByteString::CreateFromInt32( nAmount );
+
+ Size aTwipSz( pTextObj->GetLogicRect().GetSize() );
+ if( pTextObj->IsAutoGrowWidth() )
+ aTwipSz.Width() = 0;
+ // Die Hoehe ist bei MS eine Mindesthoehe, also geben wir auch die
+ // Mindestheoehe aus, wenn es sie gibt. Da eine Mindesthoehe MINFLY
+ // mit hoher Wahrscheinlichkeit vom Import kommt, wird sie nicht mit
+ // ausgegeben. Falsch machen kann man da nichst, denn jeder Font ist
+ // hoeher.
+ if( pTextObj->IsAutoGrowHeight() )
+ {
+ aTwipSz.Height() = pTextObj->GetMinTextFrameHeight();
+ if( MINFLY==aTwipSz.Height() )
+ aTwipSz.Height() = 0;
+ }
+
+ if( (aTwipSz.Width() || aTwipSz.Height()) &&
+ Application::GetDefaultDevice() )
+ {
+ Size aPixelSz =
+ Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
+ MapMode(MAP_TWIP) );
+ if( !aPixelSz.Width() && aTwipSz.Width() )
+ aPixelSz.Width() = 1;
+ if( !aPixelSz.Height() && aTwipSz.Height() )
+ aPixelSz.Height() = 1;
+
+ if( aPixelSz.Width() )
+ (((sOut += ' ') += sHTML_O_width) += '=')
+ += ByteString::CreateFromInt32( aPixelSz.Width() );
+
+ if( aPixelSz.Height() )
+ (((sOut += ' ') += sHTML_O_height) += '=')
+ += ByteString::CreateFromInt32( aPixelSz.Height() );
+ }
+
+ // BGCOLOR
+ XFillStyle eFillStyle =
+ ((const XFillStyleItem&)aItemSet.Get(XATTR_FILLSTYLE)).GetValue();
+ if( XFILL_SOLID==eFillStyle )
+ {
+ const Color& rFillColor =
+ ((const XFillColorItem&)aItemSet.Get(XATTR_FILLCOLOR)).GetValue();
+
+ ((sOut += ' ') += sHTML_O_bgcolor) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( rWrt.Strm(), rFillColor, rHTMLWrt.eDestEnc );
+ sOut.Erase();
+ }
+
+ if( sOut.Len() )
+ rWrt.Strm() << sOut.GetBuffer();
+
+ // und nun noch ALIGN, HSPACE und VSPACE
+ ByteString aEndTags;
+ sal_uInt32 nFrmFlags = HTML_FRMOPTS_MARQUEE;
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
+ nFrmFlags |= HTML_FRMOPTS_MARQUEE_CSS1;
+ rHTMLWrt.OutFrmFmtOptions( rFmt, aEmptyStr, aEndTags, nFrmFlags );
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
+ rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmFlags, &rSdrObject );
+
+
+ rWrt.Strm() << '>';
+
+ // Was jetzt kommt ist das Gegenstueck zu SdrTextObjectt::SetText()
+#if SUPD>601
+ Outliner aOutliner(0, OUTLINERMODE_TEXTOBJECT);
+#else
+ Outliner aOutliner;
+#endif
+ aOutliner.SetUpdateMode( sal_False );
+ aOutliner.SetText( *pOutlinerParaObj );
+#if SUPD>601
+ String aText( aOutliner.GetText( aOutliner.GetParagraph(0),
+ aOutliner.GetParagraphCount() ) );
+#else
+ String aText( aOutliner.GetText( aOutliner.First(),
+ aOutliner.GetParagraphCount() ) );
+#endif
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aText,
+ rHTMLWrt.eDestEnc );
+
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_marquee, sal_False );
+
+ if( aEndTags.Len() )
+ rWrt.Strm() << aEndTags.GetBuffer();
+
+ return rWrt;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmldraw.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.45 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.44 2000/08/24 07:53:38 os
+ Outliner changes
+
+ Revision 1.43 2000/06/26 09:51:57 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.42 2000/04/10 12:20:55 mib
+ unicode
+
+ Revision 1.41 2000/03/21 15:06:17 os
+ UNOIII
+
+ Revision 1.40 2000/03/03 15:21:00 os
+ StarView remainders removed
+
+ Revision 1.39 2000/02/11 14:37:07 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.38 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.37 1999/09/21 09:48:50 mib
+ multiple text encodings
+
+ Revision 1.36 1999/09/17 12:12:52 mib
+ support of multiple and non system text encodings
+
+ Revision 1.35 1999/06/10 08:33:54 JP
+ have to change: no AppWin from SfxApp
+
+
+ Rev 1.34 10 Jun 1999 10:33:54 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.33 09 Jun 1999 19:36:36 JP
+ have to change: no cast from GetpApp to SfxApp/OffApp, SfxShell only subclass of SfxApp
+
+ Rev 1.32 27 Jan 1999 19:00:04 JP
+ Task #61014#: FindSdrObject/FindContactObject als Methoden vom SwFrmFmt
+
+ Rev 1.31 27 Jan 1999 09:43:28 OS
+ #56371# TF_ONE51
+
+ Rev 1.30 11 Dec 1998 09:34:56 JP
+ Bug #58217#: MarqueeTextObjecte erkennen
+
+ Rev 1.29 20 May 1998 15:22:18 MIB
+ Zeichen-Objekte ueber Schnittstelle am Dok einfuegen
+
+ Rev 1.28 02 Apr 1998 19:44:24 MIB
+ Frm-Flags: sal_uInt16 -> sal_uInt32
+
+ Rev 1.27 27 Mar 1998 17:24:34 MIB
+ direkte absolute Positionierung und Groessen-Export von Controls und Marquee
+
+ Rev 1.26 27 Mar 1998 10:03:38 MIB
+ direkte Positionierung von Grafiken etc.
+
+ Rev 1.25 20 Mar 1998 10:49:50 MIB
+ abs.-pos. fuer Zeichen-Objektei, Optimierungen
+
+ Rev 1.24 14 Mar 1998 19:02:34 MIB
+ Export-Umstellung fuer am-zeichen gebundene Rahmen und abs.-pos.
+
+ Rev 1.23 20 Feb 1998 19:04:32 MA
+ header
+
+ Rev 1.22 16 Feb 1998 16:06:18 MIB
+ fix #45523#: Hoehe von Laufschriften als Mindesthoehe interpretieren
+
+ Rev 1.21 16 Feb 1998 12:31:08 MIB
+ DokInfo-Feld jetzt auch fixed
+
+ Rev 1.20 26 Nov 1997 19:09:24 MA
+ includes
+
+ Rev 1.19 03 Nov 1997 14:08:52 MA
+ precomp entfernt
+
+ Rev 1.18 19 Sep 1997 08:38:00 MIB
+ fix #41185#: Laufschrift an Tabellenzellen-Breite anpassen
+
+ Rev 1.17 10 Sep 1997 15:22:06 MIB
+ Styles fuer Marquee
+
+ Rev 1.16 09 Sep 1997 14:13:24 MIB
+ Ueberall Browse-View-Breite statt Seitenbreite verwenden
+
+ Rev 1.15 29 Aug 1997 16:49:50 OS
+ DLL-Umstellung
+
+ Rev 1.14 18 Aug 1997 11:36:14 OS
+ includes
+
+ Rev 1.13 15 Aug 1997 12:47:42 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.12 12 Aug 1997 13:47:02 OS
+ Header-Umstellung
+
+ Rev 1.11 07 Aug 1997 15:08:28 OM
+ Headerfile-Umstellung
+
+ Rev 1.10 05 Aug 1997 14:56:36 TJ
+ include
+
+ Rev 1.9 28 Jul 1997 12:39:00 MIB
+ fix #37237#: Bei Laufschrift auch Attrs aus Absatz-Vorlage uebernehmen
+
+ Rev 1.8 29 Apr 1997 11:21:48 MH
+ add: header
+
+ Rev 1.7 10 Apr 1997 16:45:50 TRI
+ includes
+
+ Rev 1.6 10 Apr 1997 13:15:46 MH
+ add: header
+
+ Rev 1.5 09 Jan 1997 11:20:44 MIB
+ fix #34862#: -Angaben groesser 100 bei MARQUEE abfangen
+
+ Rev 1.4 22 Nov 1996 09:37:50 MIB
+ fix #33414#: MARQUEE in Tabellen an Textbreite anpassen, Farbe aus Standard-Vor
+
+ Rev 1.3 07 Nov 1996 19:06:58 JP
+ NoTxtNode hat Altern.Text, Namen am HREF
+
+ Rev 1.2 07 Nov 1996 16:24:30 MIB
+ Laufschrift exportieren
+
+ Rev 1.1 06 Nov 1996 11:50:24 MIB
+ neue defaults fuer Alternate-Marquee, Anpassung an die 344
+
+ Rev 1.0 05 Nov 1996 12:03:58 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
new file mode 100644
index 000000000000..5752acd53ebf
--- /dev/null
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -0,0 +1,787 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlfld.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _SFXDOCINF_HXX //autogen
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _ZFORMAT_HXX //autogen
+#include <svtools/zformat.hxx>
+#endif
+
+
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen
+#include <ndtxt.hxx>
+#endif
+#include "doc.hxx"
+#include "finder.hxx"
+#include "fldbas.hxx"
+#include "docufld.hxx"
+#include "flddat.hxx"
+#include "htmlfld.hxx"
+#include "swhtml.hxx"
+
+struct HTMLNumFmtTblEntry
+{
+ const sal_Char *pName;
+ NfIndexTableOffset eFmt;
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLFldTypeTable[] =
+{
+ { sHTML_FT_author, RES_AUTHORFLD },
+ { sHTML_FT_sender, RES_EXTUSERFLD },
+ { sHTML_FT_date, RES_DATEFLD },
+ { sHTML_FT_time, RES_TIMEFLD },
+ { sHTML_FT_datetime,RES_DATETIMEFLD },
+ { sHTML_FT_page, RES_PAGENUMBERFLD },
+ { sHTML_FT_docinfo, RES_DOCINFOFLD },
+ { sHTML_FT_docstat, RES_DOCSTATFLD },
+ { sHTML_FT_filename,RES_FILENAMEFLD },
+ { 0, 0 }
+};
+
+static HTMLNumFmtTblEntry __FAR_DATA aHTMLDateFldFmtTable[] =
+{
+ { sHTML_FF_ssys, NF_DATE_SYSTEM_SHORT },
+ { sHTML_FF_lsys, NF_DATE_SYSTEM_LONG },
+ { sHTML_FF_dmy, NF_DATE_SYS_DDMMYY, },
+ { sHTML_FF_dmyy, NF_DATE_SYS_DDMMYYYY, },
+ { sHTML_FF_dmmy, NF_DATE_SYS_DMMMYY, },
+ { sHTML_FF_dmmyy, NF_DATE_SYS_DMMMYYYY, },
+ { sHTML_FF_dmmmy, NF_DATE_DIN_DMMMMYYYY },
+ { sHTML_FF_dmmmyy, NF_DATE_DIN_DMMMMYYYY },
+ { sHTML_FF_ddmmy, NF_DATE_SYS_NNDMMMYY },
+ { sHTML_FF_ddmmmy, NF_DATE_SYS_NNDMMMMYYYY },
+ { sHTML_FF_ddmmmyy, NF_DATE_SYS_NNDMMMMYYYY },
+ { sHTML_FF_dddmmmy, NF_DATE_SYS_NNNNDMMMMYYYY },
+ { sHTML_FF_dddmmmyy, NF_DATE_SYS_NNNNDMMMMYYYY },
+ { sHTML_FF_my, NF_DATE_SYS_MMYY },
+ { sHTML_FF_md, NF_DATE_DIN_MMDD },
+ { sHTML_FF_ymd, NF_DATE_DIN_YYMMDD },
+ { sHTML_FF_yymd, NF_DATE_DIN_YYYYMMDD },
+ { 0, NF_NUMERIC_START }
+};
+
+static HTMLNumFmtTblEntry __FAR_DATA aHTMLTimeFldFmtTable[] =
+{
+ { sHTML_FF_sys, NF_TIME_HHMMSS },
+ { sHTML_FF_ssmm24, NF_TIME_HHMM },
+ { sHTML_FF_ssmm12, NF_TIME_HHMMAMPM },
+ { 0, NF_NUMERIC_START }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLPageNumFldFmtTable[] =
+{
+ { sHTML_FF_uletter, SVX_NUM_CHARS_UPPER_LETTER },
+ { sHTML_FF_lletter, SVX_NUM_CHARS_LOWER_LETTER },
+ { sHTML_FF_uroman, SVX_NUM_ROMAN_UPPER },
+ { sHTML_FF_lroman, SVX_NUM_ROMAN_LOWER },
+ { sHTML_FF_arabic, SVX_NUM_ARABIC },
+ { sHTML_FF_none, SVX_NUM_NUMBER_NONE },
+ { sHTML_FF_char, SVX_NUM_CHAR_SPECIAL },
+ { sHTML_FF_page, SVX_NUM_PAGEDESC },
+ { sHTML_FF_ulettern, SVX_NUM_CHARS_UPPER_LETTER_N },
+ { sHTML_FF_llettern, SVX_NUM_CHARS_LOWER_LETTER_N },
+ { 0, 0 }
+};
+
+
+static HTMLOptionEnum __FAR_DATA aHTMLExtUsrFldSubTable[] =
+{
+ { sHTML_FS_company, EU_COMPANY },
+ { sHTML_FS_firstname, EU_FIRSTNAME },
+ { sHTML_FS_name, EU_NAME },
+ { sHTML_FS_shortcut, EU_SHORTCUT },
+ { sHTML_FS_street, EU_STREET },
+ { sHTML_FS_country, EU_COUNTRY },
+ { sHTML_FS_zip, EU_ZIP },
+ { sHTML_FS_city, EU_CITY },
+ { sHTML_FS_title, EU_TITLE },
+ { sHTML_FS_position, EU_POSITION },
+ { sHTML_FS_pphone, EU_PHONE_PRIVATE },
+ { sHTML_FS_cphone, EU_PHONE_COMPANY },
+ { sHTML_FS_fax, EU_FAX },
+ { sHTML_FS_email, EU_EMAIL },
+ { sHTML_FS_state, EU_STATE },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLAuthorFldFmtTable[] =
+{
+ { sHTML_FF_name, AF_NAME },
+ { sHTML_FF_shortcut, AF_SHORTCUT },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLPageNumFldSubTable[] =
+{
+ { sHTML_FS_random, PG_RANDOM },
+ { sHTML_FS_next, PG_NEXT },
+ { sHTML_FS_prev, PG_PREV },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLDocInfoFldSubTable[] =
+{
+ { sHTML_FS_title, DI_TITEL },
+ { sHTML_FS_theme, DI_THEMA },
+ { sHTML_FS_keys, DI_KEYS },
+ { sHTML_FS_comment, DI_COMMENT },
+ { sHTML_FS_info1, DI_INFO1 },
+ { sHTML_FS_info2, DI_INFO2 },
+ { sHTML_FS_info3, DI_INFO3 },
+ { sHTML_FS_info4, DI_INFO4 },
+ { sHTML_FS_create, DI_CREATE },
+ { sHTML_FS_change, DI_CHANGE },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLDocInfoFldFmtTable[] =
+{
+ { sHTML_FF_author, DI_SUB_AUTHOR },
+ { sHTML_FF_time, DI_SUB_TIME },
+ { sHTML_FF_date, DI_SUB_DATE },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLDocStatFldSubTable[] =
+{
+ { sHTML_FS_page, DS_PAGE },
+ { sHTML_FS_para, DS_PARA },
+ { sHTML_FS_word, DS_WORD },
+ { sHTML_FS_char, DS_CHAR },
+ { sHTML_FS_tbl, DS_TBL },
+ { sHTML_FS_grf, DS_GRF },
+ { sHTML_FS_ole, DS_OLE },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLFileNameFldFmtTable[] =
+{
+ { sHTML_FF_name, FF_NAME },
+ { sHTML_FF_pathname, FF_PATHNAME },
+ { sHTML_FF_path, FF_PATH },
+ { sHTML_FF_name_noext, FF_NAME_NOEXT },
+ { 0, 0 }
+};
+
+/* */
+
+USHORT SwHTMLParser::GetNumType( const String& rStr, USHORT nDfltType )
+{
+ USHORT nType = nDfltType;
+ const HTMLOptionEnum *pOptEnums = aHTMLPageNumFldFmtTable;
+ while( pOptEnums->pName )
+ if( !rStr.EqualsIgnoreCaseAscii( pOptEnums->pName ) )
+ pOptEnums++;
+ else
+ break;
+
+ if( pOptEnums->pName )
+ nType = pOptEnums->nValue;
+
+ return nType;
+}
+
+
+void SwHTMLParser::NewField()
+{
+ BOOL bKnownType = FALSE, bFixed = FALSE,
+ bHasNumFmt = FALSE, bHasNumValue = FALSE;
+ USHORT nType;
+ String aValue, aNumFmt, aNumValue ;
+ const HTMLOption *pSubOption=0, *pFmtOption=0;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_TYPE:
+ bKnownType = pOption->GetEnum( nType, aHTMLFldTypeTable );
+ break;
+ case HTML_O_SUBTYPE:
+ pSubOption = pOption;
+ break;
+ case HTML_O_FORMAT:
+ pFmtOption = pOption;
+ break;
+ case HTML_O_VALUE:
+ aValue = pOption->GetString();
+ break;
+ case HTML_O_SDNUM:
+ aNumFmt = pOption->GetString();
+ bHasNumFmt = TRUE;
+ break;
+ case HTML_O_SDVAL:
+ aNumValue = pOption->GetString();
+ bHasNumValue = TRUE;
+ break;
+ case HTML_O_SDFIXED:
+ bFixed = TRUE;
+ break;
+ }
+ }
+
+ if( !bKnownType )
+ return;
+
+ // Autor und Absender werden nur als als variables Feld eingefuegt,
+ // wenn man das Dok selbst als letztes geaendert hat oder es noch
+ // niemend geandert hat und man das Dok erstellt hat. Sonst
+ // wird ein Fixed-Feld daraus gemacht.
+ if( !bFixed &&
+ (RES_EXTUSERFLD == (RES_FIELDS)nType ||
+ RES_AUTHORFLD == (RES_FIELDS)nType) )
+ {
+ String aUser( pPathFinder->GetUserName() );
+ const SfxDocumentInfo *pDocInfo = pDoc->GetInfo();
+ const String& rChanged = pDocInfo->GetChanged().GetName();
+ const String& rCreated = pDocInfo->GetCreated().GetName();
+ if( !aUser.Len() ||
+ (rChanged.Len() ? aUser!=rChanged : aUser!=rCreated) )
+ bFixed = TRUE;
+ }
+
+ USHORT nWhich = nType;
+ if( RES_DATEFLD==nType || RES_TIMEFLD==nType )
+ nWhich = RES_DATETIMEFLD;
+
+ SwFieldType* pType = pDoc->GetSysFldType( nWhich );
+ SwField *pFld = 0;
+ BOOL bInsOnEndTag = FALSE;
+
+ switch( (RES_FIELDS)nType )
+ {
+ case RES_EXTUSERFLD:
+ if( pSubOption )
+ {
+ USHORT nSub;
+ ULONG nFmt = 0;
+ if( bFixed )
+ {
+ nFmt |= AF_FIXED;
+ bInsOnEndTag = TRUE;
+ }
+ if( pSubOption->GetEnum( nSub, aHTMLExtUsrFldSubTable ) )
+ pFld = new SwExtUserField( (SwExtUserFieldType*)pType,
+ nSub, nFmt );
+ }
+ break;
+
+ case RES_AUTHORFLD:
+ {
+ USHORT nFmt = AF_NAME;
+ if( pFmtOption )
+ pFmtOption->GetEnum( nFmt, aHTMLAuthorFldFmtTable );
+ if( bFixed )
+ {
+ nFmt |= AF_FIXED;
+ bInsOnEndTag = TRUE;
+ }
+
+ pFld = new SwAuthorField( (SwAuthorFieldType *)pType, nFmt );
+ }
+ break;
+
+ case RES_DATEFLD:
+ case RES_TIMEFLD:
+ {
+ ULONG nNumFmt;
+ ULONG nTime = Time().GetTime(), nDate = Date().GetDate();
+ USHORT nSub;
+ BOOL bValidFmt = FALSE;
+ HTMLNumFmtTblEntry * pFmtTbl;
+
+ if( RES_DATEFLD==nType )
+ {
+ nSub = DATEFLD;
+ pFmtTbl = aHTMLDateFldFmtTable;
+ if( aValue.Len() )
+ nDate = (ULONG)aValue.ToInt32();
+ }
+ else
+ {
+ nSub = TIMEFLD;
+ pFmtTbl = aHTMLTimeFldFmtTable;
+ if( aValue.Len() )
+ nTime = (ULONG)aValue.ToInt32();
+ }
+ if( aValue.Len() )
+ nSub |= FIXEDFLD;
+
+ SvNumberFormatter *pFormatter = pDoc->GetNumberFormatter();
+ if( pFmtOption )
+ {
+ const String& rFmt = pFmtOption->GetString();
+ for( USHORT i=0; pFmtTbl[i].pName; i++ )
+ {
+ if( rFmt.EqualsIgnoreCaseAscii( pFmtTbl[i].pName ) )
+ {
+ nNumFmt = pFormatter->GetFormatIndex(
+ pFmtTbl[i].eFmt, LANGUAGE_SYSTEM);
+ bValidFmt = TRUE;
+ break;
+ }
+ }
+ }
+ if( !bValidFmt )
+ nNumFmt = pFormatter->GetFormatIndex( pFmtTbl[i].eFmt,
+ LANGUAGE_SYSTEM);
+
+ pFld = new SwDateTimeField( (SwDateTimeFieldType *)pType,
+ nSub, nNumFmt );
+
+ if (nSub & FIXEDFLD)
+ ((SwDateTimeField *)pFld)->SetDateTime( nDate, nTime );
+ }
+ break;
+
+ case RES_DATETIMEFLD:
+ if( bHasNumFmt )
+ {
+ USHORT nSub = 0;
+
+ SvNumberFormatter *pFormatter = pDoc->GetNumberFormatter();
+ ULONG nNumFmt;
+ LanguageType eLang;
+ double dValue = GetTableDataOptionsValNum(
+ nNumFmt, eLang, aNumValue, aNumFmt,
+ *pDoc->GetNumberFormatter() );
+ short nFmtType = pFormatter->GetType( nNumFmt );
+ switch( nFmtType )
+ {
+ case NUMBERFORMAT_DATE: nSub = DATEFLD; break;
+ case NUMBERFORMAT_TIME: nSub = TIMEFLD; break;
+ }
+
+ if( nSub )
+ {
+ if( bHasNumValue )
+ nSub |= FIXEDFLD;
+
+ pFld = new SwDateTimeField( (SwDateTimeFieldType *)pType,
+ nSub, nNumFmt );
+ if( bHasNumValue )
+ ((SwDateTimeField *)pFld)->SetValue( dValue );
+ }
+ }
+ break;
+
+ case RES_PAGENUMBERFLD:
+ if( pSubOption )
+ {
+ USHORT nSub;
+ if( pSubOption->GetEnum( nSub, aHTMLPageNumFldSubTable ) )
+ {
+ USHORT nFmt = SVX_NUM_PAGEDESC;
+ if( pFmtOption )
+ pFmtOption->GetEnum( nFmt, aHTMLPageNumFldFmtTable );
+
+ short nOff = 0;
+
+ if( (SvxExtNumType)nFmt!=SVX_NUM_CHAR_SPECIAL && aValue.Len() )
+ nOff = (short)aValue.ToInt32();
+ else if( (SwPageNumSubType)nSub == PG_NEXT )
+ nOff = 1;
+ else if( (SwPageNumSubType)nSub == PG_PREV )
+ nOff = -1;
+
+ if( (SvxExtNumType)nFmt==SVX_NUM_CHAR_SPECIAL &&
+ (SwPageNumSubType)nSub==PG_RANDOM )
+ nFmt = SVX_NUM_PAGEDESC;
+
+ pFld = new SwPageNumberField( (SwPageNumberFieldType *)pType, nSub, nFmt, nOff );
+ if( (SvxExtNumType)nFmt==SVX_NUM_CHAR_SPECIAL )
+ ((SwPageNumberField *)pFld)->SetUserString( aValue );
+ }
+ }
+ break;
+
+ case RES_DOCINFOFLD:
+ if( pSubOption )
+ {
+ USHORT nSub;
+ if( pSubOption->GetEnum( nSub, aHTMLDocInfoFldSubTable ) )
+ {
+ USHORT nExtSub = 0;
+ if( DI_CREATE==(SwExtUserSubType)nSub ||
+ DI_CHANGE==(SwExtUserSubType)nSub )
+ {
+ nExtSub = DI_SUB_AUTHOR;
+ if( pFmtOption )
+ pFmtOption->GetEnum( nExtSub, aHTMLDocInfoFldFmtTable );
+ nSub |= nExtSub;
+ }
+
+ ULONG nNumFmt = 0;
+ double dValue = 0;
+ if( bHasNumFmt && (DI_SUB_DATE==nExtSub || DI_SUB_TIME==nExtSub) )
+ {
+ LanguageType eLang;
+ dValue = GetTableDataOptionsValNum(
+ nNumFmt, eLang, aNumValue, aNumFmt,
+ *pDoc->GetNumberFormatter() );
+ bFixed &= bHasNumValue;
+ }
+ else
+ bHasNumValue = FALSE;
+
+ if( bFixed )
+ {
+ nSub |= DI_SUB_FIXED;
+ bInsOnEndTag = TRUE;
+ }
+
+ pFld = new SwDocInfoField( (SwDocInfoFieldType *)pType,
+ nSub, nNumFmt );
+ if( bHasNumValue )
+ ((SwDocInfoField*)pFld)->SetValue( dValue );
+ }
+ }
+ break;
+
+ case RES_DOCSTATFLD:
+ if( pSubOption )
+ {
+ USHORT nSub;
+ if( pSubOption->GetEnum( nSub, aHTMLDocStatFldSubTable ) )
+ {
+ USHORT nFmt = SVX_NUM_ARABIC;
+ if( pFmtOption )
+ pFmtOption->GetEnum( nFmt, aHTMLPageNumFldFmtTable );
+ pFld = new SwDocStatField( (SwDocStatFieldType *)pType,
+ nSub, nFmt );
+ bUpdateDocStat |= (DS_PAGE != nFmt);
+ }
+ }
+ break;
+
+ case RES_FILENAMEFLD:
+ {
+ USHORT nFmt = FF_NAME;
+ if( pFmtOption )
+ pFmtOption->GetEnum( nFmt, aHTMLFileNameFldFmtTable );
+ if( bFixed )
+ {
+ nFmt |= FF_FIXED;
+ bInsOnEndTag = TRUE;
+ }
+
+ pFld = new SwFileNameField( (SwFileNameFieldType *)pType, nFmt );
+ }
+ break;
+ }
+
+ if( pFld )
+ {
+ if( bInsOnEndTag )
+ {
+ pField = pFld;
+ }
+ else
+ {
+ pDoc->Insert( *pPam, SwFmtFld(*pFld) );
+ delete pFld;
+ }
+ bInField = TRUE;
+ }
+}
+
+void SwHTMLParser::EndField()
+{
+ if( pField )
+ {
+ switch( pField->Which() )
+ {
+ case RES_DOCINFOFLD:
+ ASSERT( ((SwDocInfoField*)pField)->IsFixed(),
+ "DokInfo-Feld haette nicht gemerkt werden muessen" );
+ ((SwDocInfoField*)pField)->SetExpansion( aContents );
+ break;
+
+ case RES_EXTUSERFLD:
+ ASSERT( ((SwExtUserField*)pField)->IsFixed(),
+ "ExtUser-Feld haette nicht gemerkt werden muessen" );
+ ((SwExtUserField*)pField)->SetExpansion( aContents );
+ break;
+
+ case RES_AUTHORFLD:
+ ASSERT( ((SwAuthorField*)pField)->IsFixed(),
+ "Author-Feld haette nicht gemerkt werden muessen" );
+ ((SwAuthorField*)pField)->SetExpansion( aContents );
+ break;
+
+ case RES_FILENAMEFLD:
+ ASSERT( ((SwFileNameField*)pField)->IsFixed(),
+ "FileName-Feld haette nicht gemerkt werden muessen" );
+ ((SwFileNameField*)pField)->SetExpansion( aContents );
+ break;
+ }
+
+ pDoc->Insert( *pPam, SwFmtFld(*pField) );
+ delete pField;
+ pField = 0;
+ }
+
+ bInField = FALSE;
+ aContents.Erase();
+}
+
+void SwHTMLParser::InsertFieldText()
+{
+ if( pField )
+ {
+ // das aktuelle Textstueck an den Text anhaengen
+ aContents += aToken;
+ }
+}
+
+void SwHTMLParser::InsertCommentText( const sal_Char *pTag )
+{
+ BOOL bEmpty = aContents.Len() == 0;
+ if( !bEmpty )
+ aContents += '\n';
+
+ aContents += aToken;
+ if( bEmpty && pTag )
+ {
+ String aTmp( aContents );
+ aContents.AssignAscii( "HTML: <" );
+ aContents.AppendAscii( pTag );
+ aContents.Append( '>' );
+ aContents.Append( aTmp );
+ }
+}
+
+void SwHTMLParser::InsertComment( const String& rComment, const sal_Char *pTag )
+{
+ String aComment( rComment );
+ if( pTag )
+ {
+ aComment.AppendAscii( "</" );
+ aComment.AppendAscii( pTag );
+ aComment.Append( '>' );
+ }
+
+ // MIB 24.06.97: Wenn ein PostIt nach einen Space eingefuegt
+ // werden soll, fuegen wir es vor dem Space ein. Dann gibt es
+ // weniger Probleme beim Formatieren (bug #40483#)
+ xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
+ SwTxtNode *pTxtNd = pPam->GetNode()->GetTxtNode();
+ BOOL bMoveFwd = FALSE;
+ if( nPos>0 && pTxtNd && ' '==pTxtNd->GetTxt().GetChar(nPos-1) )
+ {
+ bMoveFwd = TRUE;
+
+ ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
+ xub_StrLen nIdx = pPam->GetPoint()->nContent.GetIndex();
+ for( USHORT i = aSetAttrTab.Count(); i > 0; )
+ {
+ _HTMLAttr *pAttr = aSetAttrTab[--i];
+ if( pAttr->GetSttParaIdx() != nNodeIdx ||
+ pAttr->GetSttCnt() != nIdx )
+ break;
+
+ if( RES_TXTATR_FIELD == pAttr->pItem->Which() &&
+ RES_SCRIPTFLD == ((const SwFmtFld *)pAttr->pItem)->GetFld()
+ ->GetTyp()->Which() )
+ {
+ bMoveFwd = FALSE;
+ break;
+ }
+ }
+
+ if( bMoveFwd )
+ pPam->Move( fnMoveBackward );
+ }
+
+ SwPostItField aPostItFld(
+ (SwPostItFieldType*)pDoc->GetSysFldType( RES_POSTITFLD ),
+ aEmptyStr, aComment, Date() );
+ InsertAttr( SwFmtFld( aPostItFld ) );
+
+ if( bMoveFwd )
+ pPam->Move( fnMoveForward );
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlfld.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.30 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.29 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.28 2000/03/02 11:28:52 mib
+ #73744#: state of ext user field
+
+ Revision 1.27 1999/09/21 13:53:35 os
+ SwExtUserSubType: language
+
+ Revision 1.26 1999/09/17 12:12:56 mib
+ support of multiple and non system text encodings
+
+ Revision 1.25 1998/11/20 10:53:36 MIB
+ #59064#: Unbekannte Token/<NOSCRIPT> und <NOEMEBED> beibehalten
+
+
+ Rev 1.24 20 Nov 1998 11:53:36 MIB
+ #59064#: Unbekannte Token/<NOSCRIPT> und <NOEMEBED> beibehalten
+
+ Rev 1.23 17 Nov 1998 10:44:32 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.22 03 Nov 1998 14:01:14 MIB
+ #58427#: Fixe Filename-Felder
+
+ Rev 1.21 02 Nov 1998 17:17:50 MIB
+ #58480#: Fuss-/Endnoten
+
+ Rev 1.20 25 Mar 1998 12:14:40 MIB
+ Statistk-Feld
+
+ Rev 1.19 05 Mar 1998 17:41:24 OS
+ AF_SHORCUT->AF_SHORTCUT
+
+ Rev 1.18 02 Mar 1998 09:48:58 MIB
+ Fixe Author- und ExtUser-Felder
+
+ Rev 1.17 20 Feb 1998 19:03:28 MA
+ header
+
+ Rev 1.16 20 Feb 1998 12:27:34 MIB
+ SDFIELD-Token/String erst ab 382 aktiviert
+
+ Rev 1.15 16 Feb 1998 12:28:46 MIB
+ DokInfo-Feld jetzt auch fixed
+
+ Rev 1.14 13 Feb 1998 19:18:34 MIB
+ Feldumstelling Teil 1: Date/Time und nicht-fixe Dok-Info
+
+ Rev 1.13 26 Nov 1997 19:09:24 MA
+ includes
+
+ Rev 1.12 25 Nov 1997 11:50:14 TJ
+ include svhtml.hxx
+
+ Rev 1.11 21 Nov 1997 17:22:26 OM
+ Feldbefehl-Umstellung: DocInfo
+
+ Rev 1.10 03 Nov 1997 14:08:52 MA
+ precomp entfernt
+
+ Rev 1.9 14 Oct 1997 14:13:06 OM
+ Feldumstellung
+
+ Rev 1.8 29 Sep 1997 12:16:38 OM
+ Feldumstellung
+
+ Rev 1.7 24 Sep 1997 15:25:02 OM
+ Feldumstellung
+
+ Rev 1.6 15 Aug 1997 12:48:52 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.5 07 Aug 1997 15:07:44 OM
+ Headerfile-Umstellung
+
+ Rev 1.4 26 Jun 1997 14:13:52 OM
+ Feldbefehl Dateiname ohne Extension
+
+ Rev 1.3 11 Jun 1997 11:40:48 OM
+ Neue Datumsformate fuer Datums-Feldbefehl
+
+ Rev 1.2 18 Feb 1997 11:08:02 MIB
+ Optimierung
+
+ Rev 1.1 17 Feb 1997 12:37:22 MIB
+ FileName-Feld im- und exportieren
+
+ Rev 1.0 07 Feb 1997 18:05:10 MIB
+ Initial revision.
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/html/htmlfld.hxx b/sw/source/filter/html/htmlfld.hxx
new file mode 100644
index 000000000000..41c50e1ee597
--- /dev/null
+++ b/sw/source/filter/html/htmlfld.hxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlfld.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _HTMLFLD_HXX
+#define _HTMLFLD_HXX
+
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_author, "AUTHOR" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_sender, "SENDER" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_date, "DATE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_time, "TIME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_datetime, "DATETIME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_page, "PAGE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_docinfo, "DOCINFO" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_docstat, "DOCSTAT" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FT_filename, "FILENAME" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_company, "COMPANY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_firstname, "FIRSTNAME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_name, "NAME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_shortcut, "SHORTCUT" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_street, "STREET" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_country, "COUNTRY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_zip, "ZIP" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_city, "CITY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_title, "TITLE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_position, "POSITION" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_pphone, "PPHONE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_cphone, "CPHONE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_fax, "FAX" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_email, "EMAIL" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_state, "STATE" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_random, "RANDOM" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_next, "NEXT" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_prev, "PREV" );
+
+//sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_title, "TITLE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_theme, "THEME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_keys, "KEYS" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_comment, "COMMENT" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_info1, "INFO1" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_info2, "INFO2" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_info3, "INFO3" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_info4, "INFO4" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_create, "CREATE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_change, "CHANGE" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_page, "PAGE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_para, "PARAGRAPH" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_word, "WORD" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_char, "CHAR" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_tbl, "TABLE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_grf, "GRAPHIC" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FS_ole, "OLE" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_name, "NAME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_shortcut, "SHORTCUT" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ssys, "SSYS" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_lsys, "LSYS" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dmy, "DMY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dmyy, "DMYY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dmmy, "DMMY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dmmyy, "DMMYY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dmmmy, "DMMMY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dmmmyy, "DMMMYY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ddmmy, "DDMMY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ddmmmy, "DDMMMY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ddmmmyy, "DDMMMYY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dddmmmy, "DDDMMMY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_dddmmmyy, "DDDMMMYY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_my, "MY" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_md, "MD" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ymd, "YMD" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_yymd, "YYMD" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_sys, "SYS" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ssmm24, "SSMM24" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ssmm12, "SSMM12" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_uletter, "ULETTER" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_lletter, "LLETTER" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_uroman, "UROMAN" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_lroman, "LROMAN" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_arabic, "ARABIC" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_none, "NONE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_char, "CHAR" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_page, "PAGE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_ulettern, "ULETTERN" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_llettern, "LLETTERN" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_author, "AUTHOR" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_time, "TIME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_date, "DATE" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_all, "ALL" );
+
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_pathname, "PATHNAME" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_path, "PATH" );
+extern sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DECL( sHTML_FF_name_noext, "NAME-NOEXT" );
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
new file mode 100644
index 000000000000..f1eb6b2deecf
--- /dev/null
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -0,0 +1,667 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlfldw.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#include "fldbas.hxx"
+#include "docufld.hxx"
+#include "flddat.hxx"
+#include "htmlfld.hxx"
+#include "wrthtml.hxx"
+
+//-----------------------------------------------------------------------
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_author, "AUTHOR" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_sender, "SENDER" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_date, "DATE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_time, "TIME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_datetime, "DATETIME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_page, "PAGE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_docinfo, "DOCINFO" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_docstat, "DOCSTAT" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FT_filename, "FILENAME" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_company, "COMPANY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_firstname, "FIRSTNAME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_name, "NAME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_shortcut, "SHORTCUT" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_street, "STREET" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_country, "COUNTRY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_zip, "ZIP" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_city, "CITY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_title, "TITLE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_position, "POSITION" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_pphone, "PPHONE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_cphone, "CPHONE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_fax, "FAX" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_email, "EMAIL" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_state, "STATE" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_random, "RANDOM" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_next, "NEXT" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_prev, "PREV" );
+
+//sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_title, "TITLE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_theme, "THEME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_keys, "KEYS" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_comment, "COMMENT" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_info1, "INFO1" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_info2, "INFO2" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_info3, "INFO3" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_info4, "INFO4" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_create, "CREATE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_change, "CHANGE" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_page, "PAGE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_para, "PARAGRAPH" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_word, "WORD" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_char, "CHAR" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_tbl, "TABLE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_grf, "GRAPHIC" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FS_ole, "OLE" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_name, "NAME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_shortcut, "SHORTCUT" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ssys, "SSYS" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_lsys, "LSYS" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dmy, "DMY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dmyy, "DMYY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dmmy, "DMMY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dmmyy, "DMMYY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dmmmy, "DMMMY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dmmmyy, "DMMMYY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ddmmy, "DDMMY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ddmmmy, "DDMMMY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ddmmmyy, "DDMMMYY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dddmmmy, "DDDMMMY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_dddmmmyy, "DDDMMMYY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_my, "MY" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_md, "MD" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ymd, "YMD" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_yymd, "YYMD" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_sys, "SYS" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ssmm24, "SSMM24" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ssmm12, "SSMM12" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_uletter, "ULETTER" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_lletter, "LLETTER" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_uroman, "UROMAN" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_lroman, "LROMAN" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_arabic, "ARABIC" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_none, "NONE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_char, "CHAR" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_page, "PAGE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_ulettern, "ULETTERN" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_llettern, "LLETTERN" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_author, "AUTHOR" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_time, "TIME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_date, "DATE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_all, "ALL" );
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_pathname, "PATHNAME" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_path, "PATH" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_FF_name_noext, "NAME-NOEXT" );
+
+
+const sal_Char *SwHTMLWriter::GetNumFormat( USHORT nFmt )
+{
+ const sal_Char *pFmtStr = 0;
+
+ switch( (SvxExtNumType)nFmt )
+ {
+ case SVX_NUM_CHARS_UPPER_LETTER: pFmtStr = sHTML_FF_uletter; break;
+ case SVX_NUM_CHARS_LOWER_LETTER: pFmtStr = sHTML_FF_lletter; break;
+ case SVX_NUM_ROMAN_UPPER: pFmtStr = sHTML_FF_uroman; break;
+ case SVX_NUM_ROMAN_LOWER: pFmtStr = sHTML_FF_lroman; break;
+ case SVX_NUM_ARABIC: pFmtStr = sHTML_FF_arabic; break;
+ case SVX_NUM_NUMBER_NONE: pFmtStr = sHTML_FF_none; break;
+ case SVX_NUM_CHAR_SPECIAL: pFmtStr = sHTML_FF_char; break;
+ case SVX_NUM_PAGEDESC: pFmtStr = sHTML_FF_page; break;
+ case SVX_NUM_CHARS_UPPER_LETTER_N: pFmtStr = sHTML_FF_ulettern; break;
+ case SVX_NUM_CHARS_LOWER_LETTER_N: pFmtStr = sHTML_FF_llettern; break;
+ }
+
+ return pFmtStr;
+}
+
+static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pFld )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SwFieldType* pFldTyp = pFld->GetTyp();
+ USHORT nField = pFldTyp->Which();
+ ULONG nFmt = pFld->GetFormat();
+
+ const sal_Char *pTypeStr=0, // TYPE
+ *pSubStr=0, // SUBTYPE
+ *pFmtStr=0; // FORMAT (SW)
+ String aValue; // VALUE (SW)
+ BOOL bNumFmt=FALSE; // SDNUM (Number-Formatter-Format)
+ BOOL bNumValue=FALSE; // SDVAL (Number-Formatter-Value)
+ double dNumValue; // SDVAL (Number-Formatter-Value)
+ BOOL bFixed=FALSE; // SDFIXED
+
+ switch( nField )
+ {
+ case RES_EXTUSERFLD:
+ pTypeStr = sHTML_FT_sender;
+ switch( (SwExtUserSubType)pFld->GetSubType() )
+ {
+ case EU_COMPANY: pSubStr = sHTML_FS_company; break;
+ case EU_FIRSTNAME: pSubStr = sHTML_FS_firstname; break;
+ case EU_NAME: pSubStr = sHTML_FS_name; break;
+ case EU_SHORTCUT: pSubStr = sHTML_FS_shortcut; break;
+ case EU_STREET: pSubStr = sHTML_FS_street; break;
+ case EU_COUNTRY: pSubStr = sHTML_FS_country; break;
+ case EU_ZIP: pSubStr = sHTML_FS_zip; break;
+ case EU_CITY: pSubStr = sHTML_FS_city; break;
+ case EU_TITLE: pSubStr = sHTML_FS_title; break;
+ case EU_POSITION: pSubStr = sHTML_FS_position; break;
+ case EU_PHONE_PRIVATE: pSubStr = sHTML_FS_pphone; break;
+ case EU_PHONE_COMPANY: pSubStr = sHTML_FS_cphone; break;
+ case EU_FAX: pSubStr = sHTML_FS_fax; break;
+ case EU_EMAIL: pSubStr = sHTML_FS_email; break;
+ case EU_STATE: pSubStr = sHTML_FS_state; break;
+ }
+ ASSERT( pSubStr, "ubekannter Subtyp fuer SwExtUserField" );
+ bFixed = ((const SwExtUserField*)pFld)->IsFixed();
+ break;
+
+ case RES_AUTHORFLD:
+ pTypeStr = sHTML_FT_author;
+ switch( (SwAuthorFormat)nFmt & 0xff)
+ {
+ case AF_NAME: pFmtStr = sHTML_FF_name; break;
+ case AF_SHORTCUT: pFmtStr = sHTML_FF_shortcut; break;
+ }
+ ASSERT( pFmtStr, "ubekanntes Format fuer SwAuthorField" );
+ bFixed = ((const SwAuthorField*)pFld)->IsFixed();
+ break;
+
+ case RES_DATETIMEFLD:
+ pTypeStr = sHTML_FT_datetime;
+ bNumFmt = TRUE;
+ if( ((SwDateTimeField*)pFld)->IsFixed() )
+ {
+ bNumValue = TRUE;
+ dNumValue = ((SwDateTimeField*)pFld)->GetValue();
+ }
+ break;
+
+ case RES_PAGENUMBERFLD:
+ {
+ pTypeStr = sHTML_FT_page;
+ SwPageNumSubType eSubType = (SwPageNumSubType)pFld->GetSubType();
+ switch( eSubType )
+ {
+ case PG_RANDOM: pSubStr = sHTML_FS_random; break;
+ case PG_NEXT: pSubStr = sHTML_FS_next; break;
+ case PG_PREV: pSubStr = sHTML_FS_prev; break;
+ }
+ ASSERT( pSubStr, "ubekannter Subtyp fuer SwPageNumberField" );
+ pFmtStr = SwHTMLWriter::GetNumFormat( (SvxExtNumType)nFmt );
+
+ if( (SvxExtNumType)nFmt==SVX_NUM_CHAR_SPECIAL )
+ {
+ aValue = ((const SwPageNumberField *)pFld)->GetUserString();
+ }
+ else
+ {
+ const String& rValue = pFld->GetPar2();
+ short nValue = (short)rValue.ToInt32();
+ if( (eSubType == PG_NEXT && nValue!=1) ||
+ (eSubType == PG_PREV && nValue!=-1) ||
+ (eSubType == PG_RANDOM && nValue!=0) )
+ {
+ aValue = rValue;
+ }
+ }
+ }
+ break;
+ case RES_DOCINFOFLD:
+ {
+ USHORT nSubType = pFld->GetSubType();
+ pTypeStr = sHTML_FT_docinfo;
+ USHORT nExtSubType = nSubType & 0x0f00;
+ nSubType &= 0x00ff;
+
+ switch( nSubType )
+ {
+ case DI_TITEL: pSubStr = sHTML_FS_title; break;
+ case DI_THEMA: pSubStr = sHTML_FS_theme; break;
+ case DI_KEYS: pSubStr = sHTML_FS_keys; break;
+ case DI_COMMENT: pSubStr = sHTML_FS_comment; break;
+ case DI_INFO1: pSubStr = sHTML_FS_info1; break;
+ case DI_INFO2: pSubStr = sHTML_FS_info2; break;
+ case DI_INFO3: pSubStr = sHTML_FS_info3; break;
+ case DI_INFO4: pSubStr = sHTML_FS_info4; break;
+ case DI_CREATE: pSubStr = sHTML_FS_create; break;
+ case DI_CHANGE: pSubStr = sHTML_FS_change; break;
+ default: pTypeStr = 0; break;
+ }
+ if( DI_CREATE == nSubType || DI_CHANGE == nSubType )
+ {
+ switch( nExtSubType )
+ {
+ case DI_SUB_AUTHOR:
+ pFmtStr = sHTML_FF_author;
+ break;
+ case DI_SUB_TIME:
+ pFmtStr = sHTML_FF_time;
+ bNumFmt = TRUE;
+ break;
+ case DI_SUB_DATE:
+ pFmtStr = sHTML_FF_date;
+ bNumFmt = TRUE;
+ break;
+ }
+ }
+ bFixed = ((const SwDocInfoField*)pFld)->IsFixed();
+ if( bNumFmt )
+ {
+ if( bFixed )
+ {
+ // Fuer ein fixes Feld och den Num-Value ausgeben.
+ // Fixe Felder ohne Zahlenformate sollte es
+ // eigentlich nicht geben. ASSERT ist unten.
+ dNumValue = ((const SwDocInfoField*)pFld)->GetValue();
+ bNumValue = TRUE;
+ }
+ else if( !nFmt )
+ {
+ // Nicht fixe Felder muessen kein Zahlenformat haben,
+ // wenn sie aus 4.0-Dokumenten stammen.
+ bNumFmt = FALSE;
+ }
+ }
+ }
+ break;
+
+ case RES_DOCSTATFLD:
+ {
+ pTypeStr = sHTML_FT_docstat;
+ USHORT nSubType = pFld->GetSubType();
+ switch( nSubType )
+ {
+ case DS_PAGE: pSubStr = sHTML_FS_page; break;
+ case DS_PARA: pSubStr = sHTML_FS_para; break;
+ case DS_WORD: pSubStr = sHTML_FS_word; break;
+ case DS_CHAR: pSubStr = sHTML_FS_char; break;
+ case DS_TBL: pSubStr = sHTML_FS_tbl; break;
+ case DS_GRF: pSubStr = sHTML_FS_grf; break;
+ case DS_OLE: pSubStr = sHTML_FS_ole; break;
+ default: pTypeStr = 0; break;
+ }
+ pFmtStr = SwHTMLWriter::GetNumFormat( (SvxExtNumType)nFmt );
+ }
+ break;
+
+ case RES_FILENAMEFLD:
+ pTypeStr = sHTML_FT_filename;
+ switch( (SwFileNameFormat)(nFmt & ~FF_FIXED) )
+ {
+ case FF_NAME: pFmtStr = sHTML_FF_name; break;
+ case FF_PATHNAME: pFmtStr = sHTML_FF_pathname; break;
+ case FF_PATH: pFmtStr = sHTML_FF_path; break;
+ case FF_NAME_NOEXT: pFmtStr = sHTML_FF_name_noext; break;
+ }
+ bFixed = ((const SwFileNameField*)pFld)->IsFixed();
+ ASSERT( pFmtStr, "unbekanntes Format fuer SwFileNameField" );
+ break;
+ }
+
+ // <SDFIELD>-Tag ausgeben
+ if( pTypeStr )
+ {
+ ByteString sOut( '<' );
+ ((((sOut += sHTML_sdfield) += ' ') += sHTML_O_type) += '=')
+ += pTypeStr;
+ if( pSubStr )
+ (((sOut += ' ') += sHTML_O_subtype) += '=') += pSubStr;
+ if( pFmtStr )
+ (((sOut += ' ') += sHTML_O_format) += '=') += pFmtStr;
+ if( aValue.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_value) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aValue, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ if( bNumFmt )
+ {
+ ASSERT( nFmt, "Zahlenformat ist 0" );
+ sOut = HTMLOutFuncs::CreateTableDataOptionsValNum( sOut,
+ bNumValue, dNumValue, nFmt,
+ *rHTMLWrt.pDoc->GetNumberFormatter(),
+ rHTMLWrt.eDestEnc );
+
+ }
+ if( bFixed )
+ (sOut += ' ') += sHTML_O_sdfixed;
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+
+ // Inhalt des Feldes ausgeben
+ HTMLOutFuncs::Out_String( rWrt.Strm(), pFld->Expand(),
+ rHTMLWrt.eDestEnc );
+
+ // Off-Tag ausgeben
+ if( pTypeStr )
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_sdfield, FALSE );
+
+ return rWrt;
+}
+
+
+Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwFmtFld & rFld = (SwFmtFld&)rHt;
+ const SwField* pFld = rFld.GetFld();
+ const SwFieldType* pFldTyp = pFld->GetTyp();
+
+ if( RES_SETEXPFLD == pFldTyp->Which() &&
+ (GSE_STRING & pFld->GetSubType()) )
+ {
+ int bOn = FALSE;
+ if( pFldTyp->GetName().EqualsAscii("HTML_ON" ) )
+ bOn = TRUE;
+ else if( !pFldTyp->GetName().EqualsAscii( "HTML_OFF" ) )
+ return rWrt;
+
+ String rTxt( pFld->GetPar2() );
+ rTxt.EraseLeadingChars().EraseTrailingChars();
+ rWrt.Strm() << '<';
+ if( !bOn )
+ rWrt.Strm() << '/';
+ // TODO: HTML-Tags are written without entitities, that for, characters
+ // not contained in the destination encoding are lost!
+ ByteString sTmp( rTxt, ((SwHTMLWriter&)rWrt).eDestEnc );
+ rWrt.Strm() << sTmp.GetBuffer() << '>';
+ }
+ else if( RES_POSTITFLD == pFldTyp->Which() )
+ {
+ // Kommentare werden im ANSI-Zeichensetz, aber mit System-Zeilen-
+ // Umbruechen gesschrieben.
+ const String& rComment = pFld->GetPar2();
+ BOOL bWritten = FALSE;
+
+ if( rComment.Len() >= 6 && '<' == rComment.GetChar(0) &&
+ '>' == rComment.GetChar(rComment.Len()-1) &&
+ rComment.Copy( 1, 4 ).EqualsIgnoreCaseAscii(sHTML_meta) )
+ {
+ // META-Tags direkt ausgeben
+ String sComment( rComment );
+ sComment.ConvertLineEnd( GetSystemLineEnd() );
+ // TODO: HTML-Tags are written without entitities, that for,
+ // characters not contained in the destination encoding are lost!
+ ByteString sTmp( sComment, ((SwHTMLWriter&)rWrt).eDestEnc );
+ rWrt.Strm() << sTmp.GetBuffer();
+ bWritten = TRUE;
+ }
+ else if( rComment.Len() >= 7 &&
+ '>' == rComment.GetChar(rComment.Len()-1) &&
+ rComment.Copy(0,5).EqualsIgnoreCaseAscii("HTML:") )
+ {
+ String sComment( rComment.Copy(5) );
+ sComment.EraseLeadingChars();
+ if( '<' == sComment.GetChar(0) )
+ {
+ sComment.ConvertLineEnd( GetSystemLineEnd() );
+ // TODO: HTML-Tags are written without entitities, that for,
+ // characters not contained in the destination encoding are
+ // lost!
+ ByteString sTmp( sComment, ((SwHTMLWriter&)rWrt).eDestEnc );
+ rWrt.Strm() << sTmp.GetBuffer();
+ bWritten = TRUE;
+ }
+
+ }
+
+ if( !bWritten )
+ {
+ ByteString sOut( '<' );
+
+ String sComment( rComment );
+ sComment.ConvertLineEnd( GetSystemLineEnd() );
+ // TODO: ???
+ (((sOut += sHTML_comment) += ' ')
+ += ByteString( sComment, ((SwHTMLWriter&)rWrt).eDestEnc ))
+ += " -->";
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+ }
+ else if( RES_SCRIPTFLD == pFldTyp->Which() )
+ {
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( TRUE );
+
+ BOOL bURL = ((const SwScriptField *)pFld)->IsCodeURL();
+ const String& rType = pFld->GetPar1();
+ String aContents, aURL;
+ if(bURL)
+ aURL = pFld->GetPar2();
+ else
+ aContents = pFld->GetPar2();
+
+ // sonst ist es der Script-Inhalt selbst. Da nur noh JavaScript
+ // in Feldern landet, muss es sich um JavaSrript handeln ...:)
+ HTMLOutFuncs::OutScript( rWrt.Strm(), aContents, rType, JAVASCRIPT,
+ aURL, 0, 0, rHTMLWrt.eDestEnc );
+
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( TRUE );
+ }
+ else
+ {
+ OutHTML_SwField( rWrt, pFld );
+ }
+ return rWrt;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlfldw.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.36 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.35 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.34 2000/03/02 11:28:52 mib
+ #73744#: state of ext user field
+
+ Revision 1.33 1999/09/21 13:53:35 os
+ SwExtUserSubType: language
+
+ Revision 1.32 1999/09/21 09:48:54 mib
+ multiple text encodings
+
+ Revision 1.31 1998/11/20 10:53:36 MIB
+ #59064#: Unbekannte Token/<NOSCRIPT> und <NOEMEBED> beibehalten
+
+
+ Rev 1.30 20 Nov 1998 11:53:36 MIB
+ #59064#: Unbekannte Token/<NOSCRIPT> und <NOEMEBED> beibehalten
+
+ Rev 1.29 17 Nov 1998 10:44:38 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.28 03 Nov 1998 14:01:14 MIB
+ #58427#: Fixe Filename-Felder
+
+ Rev 1.27 02 Nov 1998 17:17:52 MIB
+ #58480#: Fuss-/Endnoten
+
+ Rev 1.26 08 Jul 1998 17:21:38 MIB
+ StarScript
+
+ Rev 1.25 26 Jun 1998 12:21:56 OM
+ #51184# SubType an ExpressionFields richtig setzen und abfragen
+
+ Rev 1.24 27 Mar 1998 09:33:44 MIB
+ englisch ist besser
+
+ Rev 1.23 25 Mar 1998 12:14:42 MIB
+ Statistk-Feld
+
+ Rev 1.22 05 Mar 1998 17:41:24 OS
+ AF_SHORCUT->AF_SHORTCUT
+
+ Rev 1.21 02 Mar 1998 09:48:58 MIB
+ Fixe Author- und ExtUser-Felder
+
+ Rev 1.20 25 Feb 1998 16:52:16 OM
+ Includes
+
+ Rev 1.19 25 Feb 1998 16:50:54 OM
+ Fixe Author- und ExtUser-Felder
+
+ Rev 1.18 20 Feb 1998 19:04:32 MA
+ header
+
+ Rev 1.17 20 Feb 1998 12:27:34 MIB
+ SDFIELD-Token/String erst ab 382 aktiviert
+
+ Rev 1.16 16 Feb 1998 12:28:50 MIB
+ DokInfo-Feld jetzt auch fixed
+
+ Rev 1.15 13 Feb 1998 19:18:34 MIB
+ Feldumstelling Teil 1: Date/Time und nicht-fixe Dok-Info
+
+ Rev 1.14 26 Nov 1997 19:09:24 MA
+ includes
+
+ Rev 1.13 21 Nov 1997 17:22:26 OM
+ Feldbefehl-Umstellung: DocInfo
+
+ Rev 1.12 03 Nov 1997 14:08:48 MA
+ precomp entfernt
+
+ Rev 1.11 15 Oct 1997 12:00:16 OM
+ Feldumstellung
+
+ Rev 1.10 29 Sep 1997 12:16:38 OM
+ Feldumstellung
+
+ Rev 1.9 24 Sep 1997 15:25:02 OM
+ Feldumstellung
+
+ Rev 1.8 15 Aug 1997 12:46:34 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.7 08 Jul 1997 14:06:20 MIB
+ PostIts und Script-Felder aus 1. Absatz in Header exportieren
+
+ Rev 1.6 26 Jun 1997 14:13:52 OM
+ Feldbefehl Dateiname ohne Extension
+
+ Rev 1.5 11 Jun 1997 11:40:48 OM
+ Neue Datumsformate fuer Datums-Feldbefehl
+
+ Rev 1.4 05 Jun 1997 09:13:42 OS
+ ternaeren Ausdruck aufgeloest
+
+ Rev 1.3 22 May 1997 11:04:22 MIB
+ URL-Flag am Script-Feld
+
+ Rev 1.2 24 Mar 1997 17:42:44 MIB
+ fix: Kommentare uncodiert exportieren, opt: OutBasic aus goodies nutzen
+
+ Rev 1.1 17 Feb 1997 12:37:22 MIB
+ FileName-Feld im- und exportieren
+
+ Rev 1.0 07 Feb 1997 18:00:40 MIB
+ manche Felder als SDFIELD exportieren
+
+ -------------------------------------------------------------------------*/
+
diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx
new file mode 100644
index 000000000000..159630f2e1c5
--- /dev/null
+++ b/sw/source/filter/html/htmlfly.cxx
@@ -0,0 +1,2008 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlfly.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include "hintids.hxx"
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _APP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _IMAP_HXX //autogen
+#include <svtools/imap.hxx>
+#endif
+#ifndef _GOODIES_IMAPOBJ_HXX
+#include <svtools/imapobj.hxx>
+#endif
+
+#ifndef _XOUTBMP_HXX //autogen
+#include <svx/xoutbmp.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+
+
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTURL_HXX //autogen
+#include <fmturl.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _TXTINET_HXX //autogen
+#include <txtinet.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include "frmatr.hxx"
+#endif
+#ifndef _GRFATR_HXX //autogen
+#include <grfatr.hxx>
+#endif
+#ifndef _FLYPOS_HXX //autogen
+#include <flypos.hxx>
+#endif
+
+#ifndef _DOCARY_HXX //autogen
+#include <docary.hxx>
+#endif
+
+#ifndef _NDGRF_HXX //autogen
+#include <ndgrf.hxx>
+#endif
+
+#include "doc.hxx"
+#include "ndtxt.hxx"
+#include "pam.hxx"
+#include "swerror.h"
+#include "frmfmt.hxx"
+#include "wrthtml.hxx"
+#include "css1kywd.hxx"
+#include "htmlfly.hxx"
+
+const ULONG HTML_FRMOPTS_IMG_ALL =
+ HTML_FRMOPT_ALT |
+ HTML_FRMOPT_SIZE |
+ HTML_FRMOPT_ANYSIZE |
+ HTML_FRMOPT_BORDER |
+ HTML_FRMOPT_NAME;
+const ULONG HTML_FRMOPTS_IMG_CNTNR =
+ HTML_FRMOPTS_IMG_ALL |
+ HTML_FRMOPT_ABSSIZE;
+const ULONG HTML_FRMOPTS_IMG =
+ HTML_FRMOPTS_IMG_ALL |
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SPACE |
+ HTML_FRMOPT_BRCLEAR;
+const ULONG HTML_FRMOPTS_IMG_CSS1 =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SPACE;
+
+const ULONG HTML_FRMOPTS_DIV =
+ HTML_FRMOPT_ID |
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SIZE |
+ HTML_FRMOPT_ANYSIZE |
+ HTML_FRMOPT_ABSSIZE |
+ HTML_FRMOPT_S_SPACE |
+ HTML_FRMOPT_S_BORDER |
+ HTML_FRMOPT_S_BACKGROUND |
+ HTML_FRMOPT_BRCLEAR;
+
+const ULONG HTML_FRMOPTS_MULTICOL =
+ HTML_FRMOPT_ID |
+ HTML_FRMOPT_WIDTH |
+ HTML_FRMOPT_ANYSIZE |
+ HTML_FRMOPT_ABSSIZE;
+const ULONG HTML_FRMOPTS_MULTICOL_CNTNR =
+ HTML_FRMOPTS_MULTICOL;
+const ULONG HTML_FRMOPTS_MULTICOL_CSS1 =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SIZE |
+ HTML_FRMOPT_S_SPACE |
+ HTML_FRMOPT_S_BORDER|
+ HTML_FRMOPT_S_BACKGROUND;
+
+const ULONG HTML_FRMOPTS_SPACER =
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SIZE |
+ HTML_FRMOPT_ANYSIZE |
+ HTML_FRMOPT_BRCLEAR |
+ HTML_FRMOPT_MARGINSIZE |
+ HTML_FRMOPT_ABSSIZE;
+
+const ULONG HTML_FRMOPTS_CNTNR =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SPACE |
+ HTML_FRMOPT_S_WIDTH |
+ HTML_FRMOPT_ANYSIZE |
+ HTML_FRMOPT_ABSSIZE |
+ HTML_FRMOPT_S_PIXSIZE;
+
+
+static Writer& OutHTML_FrmFmtTableNode( Writer& rWrt, const SwFrmFmt& rFrmFmt );
+static Writer& OutHTML_FrmFmtAsMulticol( Writer& rWrt, const SwFrmFmt& rFmt,
+ BOOL bInCntnr );
+static Writer& OutHTML_FrmFmtAsSpacer( Writer& rWrt, const SwFrmFmt& rFmt );
+static Writer& OutHTML_FrmFmtAsDivOrSpan( Writer& rWrt,
+ const SwFrmFmt& rFrmFmt, BOOL bSpan );
+static Writer& OutHTML_FrmFmtAsImage( Writer& rWrt, const SwFrmFmt& rFmt,
+ BOOL bInCntnr );
+
+static Writer& OutHTML_FrmFmtGrfNode( Writer& rWrt, const SwFrmFmt& rFmt,
+ BOOL bInCntnr );
+
+static Writer& OutHTML_FrmFmtAsMarquee( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ const SdrObject& rSdrObj );
+//-----------------------------------------------------------------------
+
+extern HTMLOutEvent __FAR_DATA aAnchorEventTable[];
+
+static HTMLOutEvent __FAR_DATA aImageEventTable[] =
+{
+ { sHTML_O_SDonload, sHTML_O_onload, SVX_EVENT_IMAGE_LOAD },
+ { sHTML_O_SDonabort, sHTML_O_onabort, SVX_EVENT_IMAGE_ABORT },
+ { sHTML_O_SDonerror, sHTML_O_onerror, SVX_EVENT_IMAGE_ERROR },
+ { 0, 0, 0 }
+};
+
+static HTMLOutEvent __FAR_DATA aIMapEventTable[] =
+{
+ { sHTML_O_SDonmouseover, sHTML_O_onmouseover, SFX_EVENT_MOUSEOVER_OBJECT },
+ { sHTML_O_SDonmouseout, sHTML_O_onmouseout, SFX_EVENT_MOUSEOUT_OBJECT },
+ { 0, 0, 0 }
+};
+
+
+
+SV_IMPL_OP_PTRARR_SORT( SwHTMLPosFlyFrms, SwHTMLPosFlyFrmPtr )
+
+USHORT SwHTMLWriter::GuessFrmType( const SwFrmFmt& rFrmFmt,
+ const SdrObject*& rpSdrObj )
+{
+ SwHTMLFrmType eType;
+
+ if( RES_DRAWFRMFMT == rFrmFmt.Which() )
+ {
+ // Als Default irgendein Zeichen-Objekt
+ eType = HTML_FRMTYPE_DRAW;
+
+ const SdrObject *pObj =
+ SwHTMLWriter::GetMarqueeTextObj( (const SwDrawFrmFmt &)rFrmFmt );
+ if( pObj )
+ {
+ // Laufschrift
+ rpSdrObj = pObj;
+ eType = HTML_FRMTYPE_MARQUEE;
+ }
+ else
+ {
+ pObj = GetHTMLControl( (const SwDrawFrmFmt &)rFrmFmt );
+
+ if( pObj )
+ {
+ // Form-Control
+ rpSdrObj = pObj;
+ eType = HTML_FRMTYPE_CONTROL;
+ }
+ }
+ }
+ else
+ {
+ // Als Default ein Textrahmen
+ eType = HTML_FRMTYPE_TEXT;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ const SwNode* pNd = pDoc->GetNodes()[ nStt ];
+
+ if( pNd->IsGrfNode() )
+ {
+ // Grafik - Node
+ eType = HTML_FRMTYPE_GRF;
+ }
+ else if( pNd->IsOLENode() )
+ {
+ // Applet, Plugin, Floating-Frame
+ eType = (SwHTMLFrmType)GuessOLENodeFrmType( *pNd );
+ }
+ else
+ {
+ ULONG nEnd = pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
+
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_COL,
+ TRUE, &pItem ) &&
+ ((const SwFmtCol *)pItem)->GetNumCols() > 1 )
+ {
+ // spaltiger Rahmen
+ eType = HTML_FRMTYPE_MULTICOL;
+ }
+ else if( pNd->IsTableNode() )
+ {
+ const SwTableNode *pTblNd = pNd->GetTableNode();
+ ULONG nTblEnd = pTblNd->EndOfSectionIndex();
+
+ if( nTblEnd+1 == nEnd )
+ {
+ // Tabelle
+ eType = HTML_FRMTYPE_TABLE;
+ }
+ else if( nTblEnd+2 == nEnd )
+ {
+ // Tabelle mit Unterschrft
+ eType = HTML_FRMTYPE_TABLE_CAP;
+ }
+ }
+ else if( pNd->IsTxtNode() )
+ {
+ const SwTxtNode *pTxtNd = pNd->GetTxtNode();
+
+ BOOL bEmpty = FALSE;
+ if( nStt==nEnd-1 && !pTxtNd->Len() )
+ {
+ // leerer Rahmen? Nur wenn kein Rahmen am
+ // Text- oder Start-Node verankert ist.
+ bEmpty = TRUE;
+ if( pHTMLPosFlyFrms )
+ {
+ for( USHORT i=0; i<pHTMLPosFlyFrms->Count(); i++ )
+ {
+ ULONG nIdx = (*pHTMLPosFlyFrms)[i]
+ ->GetNdIndex().GetIndex();
+ bEmpty = (nIdx != nStt) && (nIdx != nStt-1);
+ if( !bEmpty || nIdx > nStt )
+ break;
+ }
+ }
+ }
+ if( bEmpty )
+ {
+ // leerer Rahmen
+ eType = HTML_FRMTYPE_EMPTY;
+ }
+ else if( pDoc->GetNodes()[nStt+1]->IsTableNode() )
+ {
+ const SwTableNode *pTblNd =
+ pDoc->GetNodes()[nStt+1]->GetTableNode();
+ if( pTblNd->EndOfSectionIndex()+1 == nEnd )
+ {
+ // Tabelle mit Ueberschrift
+ eType = HTML_FRMTYPE_TABLE_CAP;
+ }
+ }
+ }
+ }
+ }
+
+ return eType;
+}
+
+void SwHTMLWriter::CollectFlyFrms()
+{
+ BYTE nSz = (BYTE)Min( pDoc->GetSpzFrmFmts()->Count(), USHORT(255) );
+ SwPosFlyFrms aFlyPos( nSz, nSz );
+ pDoc->GetAllFlyFmts( aFlyPos, bWriteAll ? 0 : pCurPam, TRUE );
+
+ for( USHORT i=0; i< aFlyPos.Count(); i++ )
+ {
+ const SwFrmFmt& rFrmFmt = aFlyPos[i]->GetFmt();
+ const SdrObject *pSdrObj = 0;
+ const SwPosition *pAPos;
+ const SwCntntNode *pACNd;
+ SwHTMLFrmType eType = (SwHTMLFrmType)GuessFrmType( rFrmFmt, pSdrObj );
+
+ BYTE nMode;
+ const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor();
+ SwRelationOrient eHoriRel = rFrmFmt.GetHoriOrient().GetRelationOrient();
+ switch( rAnchor.GetAnchorId() )
+ {
+ case FLY_PAGE:
+ case FLY_AT_FLY:
+ nMode = aHTMLOutFrmPageFlyTable[eType][nExportMode];
+ break;
+
+ case FLY_AT_CNTNT:
+ // Absatz-gebundene Rahmen werden nur dann vor den
+ // Absatz geschrieben, wenn der Absatz einen Abstand
+ // hat.
+ if( FRAME == eHoriRel &&
+ (pAPos = rAnchor.GetCntntAnchor()) != 0 &&
+ (pACNd = pAPos->nNode.GetNode().GetCntntNode()) != 0 )
+ {
+ const SvxLRSpaceItem& rLRItem =
+ (const SvxLRSpaceItem&)pACNd->GetAttr(RES_LR_SPACE);
+ if( rLRItem.GetTxtLeft() || rLRItem.GetRight() )
+ {
+ nMode = aHTMLOutFrmParaFrameTable[eType][nExportMode];
+ break;
+ }
+ }
+ nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode];
+ break;
+
+ case FLY_AUTO_CNTNT:
+ if( FRAME == eHoriRel || PRTAREA == eHoriRel )
+ nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode];
+ else
+ nMode = aHTMLOutFrmParaOtherTable[eType][nExportMode];
+ break;
+
+ default:
+ nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode];
+ break;
+ }
+
+ if( !pHTMLPosFlyFrms )
+ pHTMLPosFlyFrms = new SwHTMLPosFlyFrms;
+
+ SwHTMLPosFlyFrm *pNew =
+ new SwHTMLPosFlyFrm( *aFlyPos[i], pSdrObj, nMode );
+ pHTMLPosFlyFrms->Insert( pNew );
+ }
+}
+
+BOOL SwHTMLWriter::OutFlyFrm( ULONG nNdIdx, xub_StrLen nCntntIdx, BYTE nPos )
+{
+ BOOL bFlysLeft = FALSE; // Noch Flys an aktueller Node-Position da?
+
+ // OutFlyFrm kan rekursiv aufgerufen werden. Deshalb muss man
+ // manchmal wieder von vorne anfangen, nachdem ein Fly ausgegeben
+ // wurde.
+ BOOL bRestart = TRUE;
+ while( pHTMLPosFlyFrms && bRestart )
+ {
+ bFlysLeft = bRestart = FALSE;
+
+ // suche nach dem Anfang der FlyFrames
+ for( USHORT i=0; i<pHTMLPosFlyFrms->Count() &&
+ (*pHTMLPosFlyFrms)[i]->GetNdIndex().GetIndex() < nNdIdx; i++ )
+ ;
+ for( ; !bRestart && i < pHTMLPosFlyFrms->Count() &&
+ (*pHTMLPosFlyFrms)[i]->GetNdIndex().GetIndex() == nNdIdx; i++ )
+ {
+ SwHTMLPosFlyFrm *pPosFly = (*pHTMLPosFlyFrms)[i];
+ if( ( HTML_POS_ANY == nPos ||
+ pPosFly->GetOutPos() == nPos ) &&
+ pPosFly->GetCntntIndex() == nCntntIdx )
+ {
+ // Erst entfernen ist wichtig, weil in tieferen
+ // Rekursionen evtl. weitere Eintraege oder das
+ // ganze Array geloscht werden koennte.
+ pHTMLPosFlyFrms->Remove( i, 1 );
+ i--;
+ if( !pHTMLPosFlyFrms->Count() )
+ {
+ delete pHTMLPosFlyFrms;
+ pHTMLPosFlyFrms = 0;
+ bRestart = TRUE; // nicht wirklich, nur raus
+ // aus der Schleife
+ }
+
+ OutFrmFmt( pPosFly->GetOutMode(), pPosFly->GetFmt(),
+ pPosFly->GetSdrObject() );
+ switch( pPosFly->GetOutFn() )
+ {
+ case HTML_OUT_DIV:
+ case HTML_OUT_SPAN:
+ case HTML_OUT_MULTICOL:
+ case HTML_OUT_TBLNODE:
+ bRestart = TRUE; // Hier wird's evtl rekursiv
+ break;
+ }
+ delete pPosFly;
+ }
+ else
+ {
+ bFlysLeft = TRUE;
+ }
+ }
+ }
+
+ return bFlysLeft;
+}
+
+void SwHTMLWriter::OutFrmFmt( BYTE nMode, const SwFrmFmt& rFrmFmt,
+ const SdrObject *pSdrObject )
+{
+ BYTE nCntnrMode = SwHTMLPosFlyFrm::GetOutCntnr( nMode );
+ BYTE nOutMode = SwHTMLPosFlyFrm::GetOutFn(nMode);
+ const sal_Char *pCntnrStr = 0;
+ if( HTML_CNTNR_NONE != nCntnrMode )
+ {
+
+ if( bLFPossible && HTML_CNTNR_DIV == nCntnrMode )
+ OutNewLine();
+
+ ByteString sOut( '<' );
+ pCntnrStr = (HTML_CNTNR_DIV == nCntnrMode)
+ ? sHTML_division
+ : sHTML_span;
+ sOut += pCntnrStr;
+ ((((sOut += ' ') += sHTML_O_class) += "=\"")
+ += sCSS1_class_abs_pos) += '\"';
+ Strm() << sOut.GetBuffer();
+
+ // Fuer Nicht-Zeichenobekte eine Breite ausgeben
+ ULONG nFrmFlags = HTML_FRMOPTS_CNTNR;
+
+ // Fuer spaltige Rahmen koennen wir auch noch den Hintergrund ausgeben.
+ if( HTML_OUT_MULTICOL == nOutMode )
+ nFrmFlags |= HTML_FRMOPT_S_BACKGROUND|HTML_FRMOPT_S_BORDER;
+
+ if( IsHTMLMode( HTMLMODE_BORDER_NONE ) )
+ nFrmFlags |= HTML_FRMOPT_S_NOBORDER;
+ OutCSS1_FrmFmtOptions( rFrmFmt, nFrmFlags, pSdrObject );
+ Strm() << '>';
+
+ if( HTML_CNTNR_DIV == nCntnrMode )
+ {
+ IncIndentLevel();
+ bLFPossible = TRUE;
+ }
+ }
+
+ switch( nOutMode )
+ {
+ case HTML_OUT_TBLNODE: // OK
+ ASSERT( !pCntnrStr, "Table: Container ist hier nicht vorgesehen" );
+ OutHTML_FrmFmtTableNode( *this, rFrmFmt );
+ break;
+ case HTML_OUT_GRFNODE: // OK
+ OutHTML_FrmFmtGrfNode( *this, rFrmFmt, pCntnrStr != 0 );
+ break;
+ case HTML_OUT_OLENODE: // OK
+ OutHTML_FrmFmtOLENode( *this, rFrmFmt, pCntnrStr != 0 );
+ break;
+ case HTML_OUT_OLEGRF: // OK
+ OutHTML_FrmFmtOLENodeGrf( *this, rFrmFmt, pCntnrStr != 0 );
+ break;
+ case HTML_OUT_DIV:
+ case HTML_OUT_SPAN:
+ ASSERT( !pCntnrStr, "Div: Container ist hier nicht vorgesehen" );
+ OutHTML_FrmFmtAsDivOrSpan( *this, rFrmFmt, HTML_OUT_SPAN==nOutMode );
+ break;
+ case HTML_OUT_MULTICOL: // OK
+ OutHTML_FrmFmtAsMulticol( *this, rFrmFmt, pCntnrStr != 0 );
+ break;
+ case HTML_OUT_SPACER: // OK
+ ASSERT( !pCntnrStr, "Spacer: Container ist hier nicht vorgesehen" );
+ OutHTML_FrmFmtAsSpacer( *this, rFrmFmt );
+ break;
+ case HTML_OUT_CONTROL: // OK
+ OutHTML_DrawFrmFmtAsControl( *this,
+ (const SwDrawFrmFmt &)rFrmFmt, *pSdrObject,
+ pCntnrStr != 0 );
+ break;
+ case HTML_OUT_AMARQUEE:
+ OutHTML_FrmFmtAsMarquee( *this, rFrmFmt, *pSdrObject );
+ break;
+ case HTML_OUT_MARQUEE:
+ ASSERT( !pCntnrStr, "Marquee: Container ist hier nicht vorgesehen" );
+ OutHTML_DrawFrmFmtAsMarquee( *this,
+ (const SwDrawFrmFmt &)rFrmFmt, *pSdrObject );
+ break;
+ case HTML_OUT_GRFFRM:
+ OutHTML_FrmFmtAsImage( *this, rFrmFmt, pCntnrStr != 0 );
+ break;
+ }
+
+ if( HTML_CNTNR_DIV == nCntnrMode )
+ {
+ DecIndentLevel();
+ if( bLFPossible )
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_division, FALSE );
+ bLFPossible = TRUE;
+ }
+ else if( HTML_CNTNR_SPAN == nCntnrMode )
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_span, FALSE );
+}
+
+
+void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt,
+ const String& rAlternateTxt,
+ ByteString &rEndTags,
+ ULONG nFrmOpts )
+{
+ ByteString sOut;
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+
+ // Name
+ if( (nFrmOpts & (HTML_FRMOPT_ID|HTML_FRMOPT_NAME)) &&
+ rFrmFmt.GetName().Len() )
+ {
+ const sal_Char *pStr =
+ (nFrmOpts & HTML_FRMOPT_ID) ? sHTML_O_id : sHTML_O_name;
+ ((sOut += ' ') += pStr) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), rFrmFmt.GetName(), eDestEnc );
+ sOut = '\"';
+ }
+
+ // ALT
+ if( (nFrmOpts & HTML_FRMOPT_ALT) && rAlternateTxt.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_alt) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), rAlternateTxt, eDestEnc );
+ sOut = '\"';
+ }
+
+ // ALIGN
+ const sal_Char *pStr = 0;
+ RndStdIds eAnchorId = rFrmFmt.GetAnchor().GetAnchorId();
+ if( (nFrmOpts & HTML_FRMOPT_ALIGN) &&
+ (FLY_AT_CNTNT == eAnchorId || FLY_AUTO_CNTNT == eAnchorId) )
+ {
+ // MIB 12.3.98: Ist es nicht schlauer, absatzgebundene
+ // Rahmen notfalls links auszurichten als sie
+ // zeichengebunden einzufuegen???
+ const SwFmtHoriOrient& rHoriOri = rFrmFmt.GetHoriOrient();
+ if( !(nFrmOpts & HTML_FRMOPT_S_ALIGN) ||
+ FRAME == rHoriOri.GetRelationOrient() ||
+ PRTAREA == rHoriOri.GetRelationOrient() )
+ {
+ pStr = HORI_RIGHT == rHoriOri.GetHoriOrient()
+ ? sHTML_AL_right
+ : sHTML_AL_left;
+ }
+ }
+ if( (nFrmOpts & HTML_FRMOPT_ALIGN) && !pStr &&
+ ( (nFrmOpts & HTML_FRMOPT_S_ALIGN) == 0 ||
+ FLY_IN_CNTNT == eAnchorId ) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, TRUE, &pItem ))
+ {
+ switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() )
+ {
+ case VERT_LINE_TOP: pStr = sHTML_VA_top; break;
+ case VERT_CHAR_TOP:
+ case VERT_BOTTOM: pStr = sHTML_VA_texttop; break; // geht nicht
+ case VERT_LINE_CENTER:
+ case VERT_CHAR_CENTER: pStr = sHTML_VA_absmiddle; break; // geht nicht
+ case VERT_CENTER: pStr = sHTML_VA_middle; break;
+ case VERT_LINE_BOTTOM:
+ case VERT_CHAR_BOTTOM: pStr = sHTML_VA_absbottom; break; // geht nicht
+ case VERT_TOP: pStr = sHTML_VA_bottom; break;
+ }
+ }
+ if( pStr )
+ (((sOut += ' ') += sHTML_O_align) += '=') += pStr;
+
+
+ // HSPACE und VSPACE
+ Size aTwipSpc( 0, 0 );
+ if( (nFrmOpts & (HTML_FRMOPT_SPACE|HTML_FRMOPT_MARGINSIZE)) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_LR_SPACE, TRUE, &pItem ))
+ {
+ aTwipSpc.Width() =
+ ( ((SvxLRSpaceItem*)pItem)->GetLeft() +
+ ((SvxLRSpaceItem*)pItem)->GetRight() ) / 2;
+ nDfltLeftMargin = nDfltRightMargin = (USHORT)aTwipSpc.Width();
+ }
+ if( (nFrmOpts & (HTML_FRMOPT_SPACE|HTML_FRMOPT_MARGINSIZE)) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_UL_SPACE, TRUE, &pItem ))
+ {
+ aTwipSpc.Height() =
+ ( ((SvxULSpaceItem*)pItem)->GetUpper() +
+ ((SvxULSpaceItem*)pItem)->GetLower() ) / 2;
+ nDfltTopMargin = nDfltBottomMargin = (USHORT)aTwipSpc.Height();
+ }
+
+ if( (nFrmOpts & HTML_FRMOPT_SPACE) &&
+ (aTwipSpc.Width() || aTwipSpc.Height()) &&
+ Application::GetDefaultDevice() )
+ {
+ Size aPixelSpc =
+ Application::GetDefaultDevice()->LogicToPixel( aTwipSpc,
+ MapMode(MAP_TWIP) );
+ if( !aPixelSpc.Width() && aTwipSpc.Width() )
+ aPixelSpc.Width() = 1;
+ if( !aPixelSpc.Height() && aTwipSpc.Height() )
+ aPixelSpc.Height() = 1;
+
+ if( aPixelSpc.Width() )
+ {
+ (((sOut += ' ') += sHTML_O_hspace) += '=')
+ += ByteString::CreateFromInt32( aPixelSpc.Width() );
+ }
+
+ if( aPixelSpc.Height() )
+ {
+ (((sOut += ' ') += sHTML_O_vspace) += '=')
+ += ByteString::CreateFromInt32( aPixelSpc.Height() );
+ }
+ }
+
+ // Der Abstand muss bei der Groesse beruecksichtigt, wenn das entsprechende
+ // Flag gesetzt ist.
+ if( (nFrmOpts & HTML_FRMOPT_MARGINSIZE) )
+ {
+ aTwipSpc.Width() *= -2;
+ aTwipSpc.Height() *= -2;
+ }
+ else
+ {
+ aTwipSpc.Width() = 0;
+ aTwipSpc.Height() = 0;
+ }
+
+ if( !(nFrmOpts & HTML_FRMOPT_ABSSIZE) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, TRUE, &pItem ))
+ {
+ const SvxBoxItem* pBoxItem = (const SvxBoxItem*)pItem;
+
+ aTwipSpc.Width() += pBoxItem->CalcLineSpace( BOX_LINE_LEFT );
+ aTwipSpc.Width() += pBoxItem->CalcLineSpace( BOX_LINE_RIGHT );
+ aTwipSpc.Height() += pBoxItem->CalcLineSpace( BOX_LINE_TOP );
+ aTwipSpc.Height() += pBoxItem->CalcLineSpace( BOX_LINE_BOTTOM );
+ }
+
+ // WIDTH und/oder HEIGHT
+ // ATT_VAR_SIZE/ATT_MIN_SIZE nur ausgeben, wenn ANYSIZE gesezut ist
+ if( (nFrmOpts & HTML_FRMOPT_SIZE) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, TRUE, &pItem ) &&
+ ( (nFrmOpts & HTML_FRMOPT_ANYSIZE) ||
+ ATT_FIX_SIZE == ((const SwFmtFrmSize *)pItem)->GetSizeType()) )
+ {
+ const SwFmtFrmSize *pFSItem = (const SwFmtFrmSize *)pItem;
+ BYTE nPrcWidth = pFSItem->GetWidthPercent();
+ BYTE nPrcHeight = pFSItem->GetHeightPercent();
+
+ // Groesse des Objekts Twips ohne Raender
+ Size aTwipSz( (nPrcWidth ? 0
+ : pFSItem->GetWidth()-aTwipSpc.Width()),
+ (nPrcHeight ? 0
+ : pFSItem->GetHeight()-aTwipSpc.Height()) );
+
+ ASSERT( aTwipSz.Width() >= 0 && aTwipSz.Height() >= 0,
+ "Rahmengroesse minus Abstand < 0!!!???" );
+ if( aTwipSz.Width() < 0 )
+ aTwipSz.Width() = 0;
+ if( aTwipSz.Height() < 0 )
+ aTwipSz.Height() = 0;
+
+ Size aPixelSz( 0, 0 );
+ if( (aTwipSz.Width() || aTwipSz.Height()) &&
+ Application::GetDefaultDevice() )
+ {
+ aPixelSz =
+ Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
+ MapMode(MAP_TWIP) );
+ if( !aPixelSz.Width() && aTwipSz.Width() )
+ aPixelSz.Width() = 1;
+ if( !aPixelSz.Height() && aTwipSz.Height() )
+ aPixelSz.Height() = 1;
+ }
+
+ if( (nFrmOpts & HTML_FRMOPT_WIDTH) &&
+ ((nPrcWidth && nPrcWidth!=255) || aPixelSz.Width()) )
+ {
+ ((sOut += ' ') += sHTML_O_width) += '=';
+ if( nPrcWidth )
+ (sOut += ByteString::CreateFromInt32( nPrcWidth )) += '%';
+ else
+ sOut += ByteString::CreateFromInt32( aPixelSz.Width() );
+ }
+
+ if( (nFrmOpts & HTML_FRMOPT_HEIGHT) &&
+ ((nPrcHeight && nPrcHeight!=255) || aPixelSz.Height()) )
+ {
+ ((sOut += ' ') += sHTML_O_height) += '=';
+ if( nPrcHeight )
+ (sOut += ByteString::CreateFromInt32( nPrcHeight )) += '%';
+ else
+ sOut += ByteString::CreateFromInt32( aPixelSz.Height() );
+ }
+ }
+
+ if( sOut.Len() )
+ Strm() << sOut.GetBuffer();
+
+ // Umlauf fuer absatzgeb. Grafiken als <BR CLEAR=...> in den String
+ // schreiben
+ if( (nFrmOpts & HTML_FRMOPT_BRCLEAR) &&
+ (FLY_AT_CNTNT== rFrmFmt.GetAnchor().GetAnchorId() ||
+ FLY_AUTO_CNTNT== rFrmFmt.GetAnchor().GetAnchorId()) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_SURROUND, TRUE, &pItem ))
+ {
+ const SwFmtSurround* pSurround = (const SwFmtSurround*)pItem;
+ SwHoriOrient eHoriOri = rFrmFmt.GetHoriOrient().GetHoriOrient();
+ pStr = 0;
+ SwSurround eSurround = pSurround->GetSurround();
+ BOOL bAnchorOnly = pSurround->IsAnchorOnly();
+ switch( eHoriOri )
+ {
+ case HORI_RIGHT:
+ {
+ switch( eSurround )
+ {
+ case SURROUND_NONE:
+ case SURROUND_RIGHT:
+ pStr = sHTML_AL_right;
+ break;
+ case SURROUND_LEFT:
+ case SURROUND_PARALLEL:
+ if( bAnchorOnly )
+ bClearRight = TRUE;
+ break;
+ }
+ }
+ break;
+
+ default:
+ // #67508#: If a frame is centered, it gets left aligned. This
+ // should be taken into account here, too.
+ {
+ switch( eSurround )
+ {
+ case SURROUND_NONE:
+ case SURROUND_LEFT:
+ pStr = sHTML_AL_left;
+ break;
+ case SURROUND_RIGHT:
+ case SURROUND_PARALLEL:
+ if( bAnchorOnly )
+ bClearLeft = TRUE;
+ break;
+ }
+ }
+ break;
+
+ }
+
+ if( pStr )
+ {
+ (((((((sOut = '<') += sHTML_linebreak) += ' ')
+ += sHTML_O_clear) += '=') += pStr) += '>') += rEndTags;
+ rEndTags = sOut;
+ }
+ }
+}
+
+
+Writer& OutHTML_Image( Writer& rWrt, const SwFrmFmt &rFrmFmt,
+ const String &rGrfName, const String& rAlternateTxt,
+ const Size &rRealSize, ULONG nFrmOpts,
+ const sal_Char *pMarkType,
+ const ImageMap *pAltImgMap )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // ggf. ein noch offenes Attribut voruebergehend beenden
+ if( rHTMLWrt.aINetFmts.Count() )
+ {
+ SwFmtINetFmt *pINetFmt =
+ rHTMLWrt.aINetFmts[ rHTMLWrt.aINetFmts.Count()-1 ];
+ OutHTML_INetFmt( rWrt, *pINetFmt, FALSE );
+ }
+
+ String aGrfNm( rGrfName );
+ if( !HTMLOutFuncs::PrivateURLToInternalImg(aGrfNm) )
+ aGrfNm = INetURLObject::AbsToRel( aGrfNm, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+
+ const SwFmtURL *pURLItem = 0;
+
+ // das URL-Attribut nur beruecksichtigen, wenn keine Image-Map
+ // uebergeben wurde
+ if( !pAltImgMap &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_URL, TRUE, &pItem ))
+ {
+ pURLItem = (const SwFmtURL *)pItem;
+ }
+
+ // Image-Map rausschreiben
+ const ImageMap *pIMap = pAltImgMap;
+ if( !pIMap && pURLItem )
+ {
+ pIMap = pURLItem->GetMap();
+ }
+
+ String aIMapName;
+ if( pIMap )
+ {
+ // den Namen eindeutig machen
+ aIMapName = pIMap->GetName();
+ String aNameBase;
+ if( aIMapName.Len() )
+ aNameBase = aIMapName;
+ else
+ aNameBase.AssignAscii( sHTML_map );
+ if( !aIMapName.Len() )
+ (aIMapName = aNameBase)
+ += String::CreateFromInt32( rHTMLWrt.nImgMapCnt );
+
+ BOOL bFound;
+ do
+ {
+ bFound = FALSE;
+ for( USHORT i=0; i<rHTMLWrt.aImgMapNames.Count(); i++ )
+ {
+ // TODO: Unicode: Comparison is case insensitive for ASCII
+ // characters only now!
+ if( aIMapName.EqualsIgnoreCaseAscii(*rHTMLWrt.aImgMapNames[i]) )
+ {
+ bFound = TRUE;
+ break;
+ }
+ }
+ if( bFound )
+ {
+ rHTMLWrt.nImgMapCnt++;
+ (aIMapName = aNameBase)
+ += String::CreateFromInt32( rHTMLWrt.nImgMapCnt );
+ }
+
+ } while( bFound );
+
+ BOOL bScale = FALSE;
+ //Size aGrfSize( rNode.GetTwipSize() );
+ Fraction aScaleX( 1, 1 );
+ Fraction aScaleY( 1, 1 );
+
+ const SwFmtFrmSize& rFrmSize = rFrmFmt.GetFrmSize();
+ const SvxBoxItem& rBox = rFrmFmt.GetBox();
+
+ if( !rFrmSize.GetWidthPercent() && rRealSize.Width() )
+ {
+ SwTwips nWidth = rFrmSize.GetWidth();
+ nWidth -= ( rBox.CalcLineSpace(BOX_LINE_LEFT) +
+ rBox.CalcLineSpace(BOX_LINE_RIGHT) );
+
+ ASSERT( nWidth>0, "Gibt es 0 twip breite Grafiken!?" );
+ if( nWidth<=0 ) // sollte nicht passieren
+ nWidth = 1;
+
+ if( rRealSize.Width() != nWidth )
+ {
+ aScaleX = Fraction( nWidth, rRealSize.Width() );
+ bScale = TRUE;
+ }
+ }
+ if( !rFrmSize.GetHeightPercent() && rRealSize.Height() )
+ {
+ SwTwips nHeight = rFrmSize.GetHeight();
+ nHeight -= ( rBox.CalcLineSpace(BOX_LINE_TOP) +
+ rBox.CalcLineSpace(BOX_LINE_BOTTOM) );
+
+ ASSERT( nHeight>0, "Gibt es 0 twip hohe Grafiken!?" );
+ if( nHeight<=0 )
+ nHeight = 1;
+
+ if( rRealSize.Height() != nHeight )
+ {
+ aScaleY = Fraction( nHeight, rRealSize.Height() );
+ bScale = TRUE;
+ }
+ }
+
+ rHTMLWrt.aImgMapNames.Insert( new String(aIMapName),
+ rHTMLWrt.aImgMapNames.Count() );
+
+ ByteString aIndMap, aIndArea;
+ const sal_Char *pLF = 0, *pIndArea = 0, *pIndMap = 0;
+#if defined(MAC) || defined(UNX)
+ sal_Char aLF[2] = "\x00";
+#endif
+
+ if( rHTMLWrt.bLFPossible )
+ {
+ rHTMLWrt.OutNewLine( TRUE );
+ rHTMLWrt.GetIndentString( aIndMap );
+ rHTMLWrt.GetIndentString( aIndArea, 1 );
+#if defined(MAC) || defined(UNX)
+ aLF[0] = SwHTMLWriter::sNewLine;
+ pLF = aLF;
+#else
+ pLF = SwHTMLWriter::sNewLine;
+#endif
+ pIndArea = aIndArea.GetBuffer();
+ pIndMap = aIndMap.GetBuffer();
+ }
+
+ if( bScale )
+ {
+ ImageMap aScaledIMap( *pIMap );
+ aScaledIMap.Scale( aScaleX, aScaleY );
+ HTMLOutFuncs::Out_ImageMap( rWrt.Strm(), aScaledIMap, aIMapName,
+ aIMapEventTable,
+ rHTMLWrt.bCfgStarBasic,
+ pLF, pIndArea, pIndMap,
+ rHTMLWrt.eDestEnc );
+ }
+ else
+ {
+ HTMLOutFuncs::Out_ImageMap( rWrt.Strm(), *pIMap, aIMapName,
+ aIMapEventTable,
+ rHTMLWrt.bCfgStarBasic,
+ pLF, pIndArea, pIndMap,
+ rHTMLWrt.eDestEnc );
+ }
+ }
+
+ // wenn meoglich vor der Grafik einen Zeilen-Umbruch ausgeben
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( TRUE );
+
+ // Attribute die ausserhelb der Grafik geschreiben werden muessen sammeln
+ ByteString sOut;
+ ByteString aEndTags;
+
+ // implizite Sprungmarke -> <A NAME=...></A>...<IMG ...>
+ if( pMarkType && rFrmFmt.GetName().Len() )
+ rHTMLWrt.OutImplicitMark( rFrmFmt.GetName(), pMarkType );
+
+ // URL -> <A>...<IMG ... >...</A>
+ const SvxMacroItem *pMacItem = 0;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRMMACRO, TRUE, &pItem ))
+ pMacItem = (const SvxMacroItem *)pItem;
+
+ if( pURLItem || pMacItem )
+ {
+ String aMapURL;
+ String aName;
+ String aTarget;
+ if( pURLItem )
+ {
+ aMapURL = pURLItem->GetURL();
+ aName = pURLItem->GetName();
+ aTarget = pURLItem->GetTargetFrameName();
+ }
+ BOOL bEvents = pMacItem && pMacItem->GetMacroTable().Count();
+
+ if( aMapURL.Len() || aName.Len() || aTarget.Len() || bEvents )
+ {
+ (sOut = '<') += sHTML_anchor;
+
+ // Ein HREF nur Ausgaben, wenn es einen Link oder Makros gibt
+ if( aMapURL.Len() || bEvents )
+ {
+ ((sOut += ' ') += sHTML_O_href) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(),
+ INetURLObject::AbsToRel( aMapURL,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET ),
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ if( aName.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_name) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aName,
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ if( aTarget.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_target) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aTarget,
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ if( sOut.Len() )
+ {
+ rWrt.Strm() << sOut.GetBuffer();
+ sOut.Erase();
+ }
+
+ if( pMacItem )
+ {
+ const SvxMacroTableDtor& rMacTable = pMacItem->GetMacroTable();
+ if( rMacTable.Count() )
+ HTMLOutFuncs::Out_Events( rWrt.Strm(), rMacTable,
+ aAnchorEventTable,
+ rHTMLWrt.bCfgStarBasic,
+ rHTMLWrt.eDestEnc );
+ }
+
+ rWrt.Strm() << ">";
+ (((sOut = "</") += sHTML_anchor) += ">") += aEndTags;
+ aEndTags = sOut;
+ }
+ }
+
+ // Umrandung -> <FONT COLOR = ...>...<IMG ... >...</FONT>
+ USHORT nBorderWidth = 0;
+ if( (nFrmOpts & HTML_FRMOPT_BORDER) &&
+ SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, TRUE, &pItem ))
+ {
+ Size aTwipBorder( 0, 0 );
+ const SvxBoxItem* pBoxItem = (const SvxBoxItem*)pItem;
+
+ const SvxBorderLine *pColBorderLine = 0;
+ const SvxBorderLine *pBorderLine = pBoxItem->GetLeft();
+ if( pBorderLine )
+ {
+ pColBorderLine = pBorderLine;
+ aTwipBorder.Width() += pBorderLine->GetOutWidth();
+ }
+
+ pBorderLine = pBoxItem->GetRight();
+ if( pBorderLine )
+ {
+ pColBorderLine = pBorderLine;
+ aTwipBorder.Width() += pBorderLine->GetOutWidth();
+ }
+
+ pBorderLine = pBoxItem->GetTop();
+ if( pBorderLine )
+ {
+ pColBorderLine = pBorderLine;
+ aTwipBorder.Height() += pBorderLine->GetOutWidth();
+ }
+
+ pBorderLine = pBoxItem->GetBottom();
+ if( pBorderLine )
+ {
+ pColBorderLine = pBorderLine;
+ aTwipBorder.Height() += pBorderLine->GetOutWidth();
+ }
+
+ aTwipBorder.Width() /= 2;
+ aTwipBorder.Height() /= 2;
+
+ if( (aTwipBorder.Width() || aTwipBorder.Height()) &&
+ Application::GetDefaultDevice() )
+ {
+ Size aPixelBorder =
+ Application::GetDefaultDevice()->LogicToPixel( aTwipBorder,
+ MapMode(MAP_TWIP) );
+ if( !aPixelBorder.Width() && aTwipBorder.Width() )
+ aPixelBorder.Width() = 1;
+ if( !aPixelBorder.Height() && aTwipBorder.Height() )
+ aPixelBorder.Height() = 1;
+
+ if( aPixelBorder.Width() )
+ aPixelBorder.Height() = 0;
+
+ nBorderWidth =
+ (USHORT)(aPixelBorder.Width() + aPixelBorder.Height());
+ }
+
+ if( pColBorderLine )
+ {
+ sOut = '<';
+ (((sOut += sHTML_font) += ' ') += sHTML_O_color) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( rWrt.Strm(),
+ pColBorderLine->GetColor() ) << '>';
+
+ (((sOut = "</" ) += sHTML_font) += '>') += aEndTags;
+ aEndTags = sOut;
+ }
+ }
+
+ sOut = '<';
+ (((sOut += sHTML_image) += ' ') += sHTML_O_src) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aGrfNm, rHTMLWrt.eDestEnc ) << '\"';
+
+ // Events
+ sOut.Erase();
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRMMACRO, TRUE, &pItem ))
+ {
+ const SvxMacroTableDtor& rMacTable =
+ ((const SvxMacroItem *)pItem)->GetMacroTable();
+ if( rMacTable.Count() )
+ HTMLOutFuncs::Out_Events( rWrt.Strm(), rMacTable, aImageEventTable,
+ rHTMLWrt.bCfgStarBasic, rHTMLWrt.eDestEnc );
+ }
+
+ // ALT, ALIGN, WIDTH, HEIGHT, HSPACE, VSPACE
+ rHTMLWrt.OutFrmFmtOptions( rFrmFmt, rAlternateTxt, aEndTags, nFrmOpts );
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) )
+ rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmOpts );
+
+
+ if( nFrmOpts & HTML_FRMOPT_BORDER )
+ {
+ (((sOut = ' ') += sHTML_O_border) += '=')
+ += ByteString::CreateFromInt32( nBorderWidth );
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+
+ if( pURLItem && pURLItem->IsServerMap() )
+ {
+ (sOut = ' ') += sHTML_O_ismap;
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+ if( aIMapName.Len() )
+ {
+ ((sOut = ' ') += sHTML_O_usemap) += "=\"#";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aIMapName, rHTMLWrt.eDestEnc ) << '\"';
+ }
+
+ rHTMLWrt.Strm() << '>';
+
+ if( aEndTags.Len() )
+ rWrt.Strm() << aEndTags.GetBuffer();
+
+ if( rHTMLWrt.aINetFmts.Count() )
+ {
+ // es ist noch ein Attribut auf dem Stack, das wieder geoeffnet
+ // werden muss
+ SwFmtINetFmt *pINetFmt =
+ rHTMLWrt.aINetFmts[ rHTMLWrt.aINetFmts.Count()-1 ];
+ OutHTML_INetFmt( rWrt, *pINetFmt, TRUE );
+ }
+
+ return rHTMLWrt;
+}
+
+Writer& OutHTML_BulletImage( Writer& rWrt,
+ const sal_Char *pTag,
+ const SvxBrushItem* pBrush,
+ String &rGrfName,
+ const Size &rSize,
+ const SwFmtVertOrient* pVertOrient )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // Wenn es ein BrushItem gibt, muss die Grafiknoch exportiert werden
+ const String *pLink = 0;
+ if( pBrush )
+ {
+ pLink = pBrush->GetGraphicLink();
+
+ // embeddete Grafik -> WriteEmbedded schreiben
+ if( !pLink )
+ {
+ const Graphic* pGrf = pBrush->GetGraphic();
+ if( pGrf )
+ {
+ // Grafik als (JPG-)File speichern
+ if( rHTMLWrt.GetOrigFileName() )
+ rGrfName = *rHTMLWrt.GetOrigFileName();
+ USHORT nErr = XOutBitmap::WriteGraphic( *pGrf, rGrfName,
+ String::CreateFromAscii("JPG"),
+ XOUTBMP_USE_GIF_IF_SENSIBLE);
+ if( !nErr )
+ {
+ rGrfName = URIHelper::SmartRelToAbs( rGrfName );
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( rGrfName );
+ pLink = &rGrfName;
+ }
+ else
+ {
+ rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
+ }
+ }
+ }
+ else
+ {
+ rGrfName = *pLink;
+ if( rHTMLWrt.bCfgCpyLinkedGrfs || rHTMLWrt.HasCId() )
+ {
+ rHTMLWrt.CopyLocalFileToINet( rGrfName, rHTMLWrt.HasCId() );
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( rGrfName );
+ pLink = &rGrfName;
+ }
+ }
+ }
+ else
+ {
+ pLink = &rGrfName;
+ }
+
+ ByteString sOut;
+ if( pTag )
+ (sOut += '<') += pTag;
+
+ if( pLink )
+ {
+ sOut += ' ';
+ String s( *pLink );
+ if( !HTMLOutFuncs::PrivateURLToInternalImg(s) )
+ s = INetURLObject::AbsToRel( s, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ (sOut += sHTML_O_src) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), s, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+
+ // Groesse des Objekts Twips ohne Raender
+ Size aPixelSz( 0, 0 );
+ if( (rSize.Width() || rSize.Height()) && Application::GetDefaultDevice() )
+ {
+ aPixelSz =
+ Application::GetDefaultDevice()->LogicToPixel( rSize,
+ MapMode(MAP_TWIP) );
+ if( !aPixelSz.Width() && rSize.Width() )
+ aPixelSz.Width() = 1;
+ if( !aPixelSz.Height() && rSize.Height() )
+ aPixelSz.Height() = 1;
+ }
+
+ if( aPixelSz.Width() )
+ (((sOut += ' ') += sHTML_O_width) += '=')
+ += ByteString::CreateFromInt32( aPixelSz.Width() );
+
+ if( aPixelSz.Height() )
+ (((sOut += ' ') += sHTML_O_height) += '=')
+ += ByteString::CreateFromInt32( aPixelSz.Height() );
+
+ if( pVertOrient )
+ {
+ const sal_Char *pStr = 0;
+ switch( pVertOrient->GetVertOrient() )
+ {
+ case VERT_LINE_TOP: pStr = sHTML_VA_top; break;
+ case VERT_CHAR_TOP:
+ case VERT_BOTTOM: pStr = sHTML_VA_texttop; break; // geht nicht
+ case VERT_LINE_CENTER:
+ case VERT_CHAR_CENTER: pStr = sHTML_VA_absmiddle; break; // geht nicht
+ case VERT_CENTER: pStr = sHTML_VA_middle; break;
+ case VERT_LINE_BOTTOM:
+ case VERT_CHAR_BOTTOM: pStr = sHTML_VA_absbottom; break; // geht nicht
+ case VERT_TOP: pStr = sHTML_VA_bottom; break;
+ }
+ if( pStr )
+ (((sOut += ' ') += sHTML_O_align) += '=') += pStr;
+ }
+ }
+
+ if( pTag )
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+
+ return rWrt;
+}
+
+
+//-----------------------------------------------------------------------
+
+static Writer& OutHTML_FrmFmtTableNode( Writer& rWrt, const SwFrmFmt& rFrmFmt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ ULONG nEnd = rHTMLWrt.pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
+
+ String aCaption;
+ BOOL bTopCaption = FALSE;
+
+ // Nicht const, weil GetTable spater mal nicht const ist
+ SwNode *pNd = rHTMLWrt.pDoc->GetNodes()[ nStt ];
+ SwTableNode *pTblNd = pNd->GetTableNode();
+ const SwTxtNode *pTxtNd = pNd->GetTxtNode();
+ if( !pTblNd && pTxtNd )
+ {
+ // Tabelle mit Ueberschrift
+ bTopCaption = TRUE;
+ pTblNd = rHTMLWrt.pDoc->GetNodes()[nStt+1]->GetTableNode();
+ }
+ ASSERT( pTblNd, "Rahmen enthaelt keine Tabelle" );
+ if( pTblNd )
+ {
+ ULONG nTblEnd = pTblNd->EndOfSectionIndex();
+ ASSERT( nTblEnd == nEnd - 1 ||
+ (nTblEnd == nEnd - 2 && !bTopCaption),
+ "Ungeuelter Rahmen-Inhalt fuer Tabelle" );
+
+ if( nTblEnd == nEnd - 2 )
+ pTxtNd = rHTMLWrt.pDoc->GetNodes()[nTblEnd+1]->GetTxtNode();
+ }
+ if( pTxtNd )
+ aCaption = pTxtNd->GetTxt();
+
+ {
+ HTMLSaveData aSaveData( rHTMLWrt, pTblNd->GetIndex()+1,
+ pTblNd->EndOfSectionIndex(),
+ (SwFlyFrmFmt*)&rFrmFmt );
+ OutHTML_SwTblNode( rHTMLWrt, *pTblNd, &rFrmFmt, &aCaption,
+ bTopCaption );
+ }
+
+ return rWrt;
+}
+
+static Writer & OutHTML_FrmFmtAsMulticol( Writer& rWrt,
+ const SwFrmFmt& rFrmFmt,
+ BOOL bInCntnr )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ rHTMLWrt.ChangeParaToken( 0 );
+
+ // Die aktulle <DL> beenden!
+ rHTMLWrt.OutAndSetDefList( 0 );
+
+ // als Multicol ausgeben
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+
+ ByteString sOut( '<' );
+ sOut += sHTML_multicol;
+
+ const SwFmtCol& rFmtCol = rFrmFmt.GetCol();
+
+ // die Anzahl der Spalten als COLS ausgeben
+ USHORT nCols = rFmtCol.GetNumCols();
+ if( nCols )
+ (((sOut += ' ') += sHTML_O_cols) += '=')
+ += ByteString::CreateFromInt32( nCols );
+
+ // die Gutter-Breite (Minimalwert) als GUTTER
+ USHORT nGutter = rFmtCol.GetGutterWidth( TRUE );
+ if( nGutter!=USHRT_MAX )
+ {
+ if( nGutter && Application::GetDefaultDevice() )
+ {
+ nGutter = (USHORT)Application::GetDefaultDevice()
+ ->LogicToPixel( Size(nGutter,0),
+ MapMode(MAP_TWIP) ).Width();
+ }
+ (((sOut += ' ') += sHTML_O_gutter) += '=')
+ += ByteString::CreateFromInt32( nGutter );
+ }
+
+ rWrt.Strm() << sOut.GetBuffer();
+
+ // WIDTH
+ ULONG nFrmFlags = bInCntnr ? HTML_FRMOPTS_MULTICOL_CNTNR
+ : HTML_FRMOPTS_MULTICOL;
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
+ nFrmFlags |= HTML_FRMOPTS_MULTICOL_CSS1;
+ ByteString aEndTags;
+ rHTMLWrt.OutFrmFmtOptions( rFrmFmt, aEmptyStr, aEndTags, nFrmFlags );
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
+ rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmFlags );
+
+ rWrt.Strm() << '>';
+
+ rHTMLWrt.bLFPossible = TRUE;
+ rHTMLWrt.IncIndentLevel(); // den Inhalt von Multicol einruecken;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex();
+ const SwStartNode* pSttNd = rWrt.pDoc->GetNodes()[nStt]->GetStartNode();
+ ASSERT( pSttNd, "Wo ist der Start-Node" );
+
+ {
+ // in einem Block damit rechtzeitig vor dem Ende der alte Zustand
+ // wieder hergestellt wird.
+ HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
+ pSttNd->EndOfSectionIndex(),
+ (const SwFlyFrmFmt*)&rFrmFmt );
+ rHTMLWrt.Out_SwDoc( rWrt.pCurPam );
+ }
+
+// rHTMLWrt.ChangeParaToken( 0 ); // MIB 8.7.97: Passiert jetzt in Out_SwDoc
+
+ rHTMLWrt.DecIndentLevel(); // den Inhalt von Multicol einruecken;
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_multicol, FALSE );
+ rHTMLWrt.bLFPossible = TRUE;
+
+ return rWrt;
+}
+
+static Writer& OutHTML_FrmFmtAsSpacer( Writer& rWrt, const SwFrmFmt& rFrmFmt )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // wenn meoglich vor der Grafik einen Zeilen-Umbruch ausgeben
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( TRUE );
+
+ ByteString sOut('<');
+ ((((sOut += sHTML_spacer) += ' ') += sHTML_O_type) += '=')
+ += sHTML_SPTYPE_block;
+ rWrt.Strm() << sOut.GetBuffer();
+
+ // ALIGN, WIDTH, HEIGHT
+ ByteString aEndTags;
+ rHTMLWrt.OutFrmFmtOptions( rFrmFmt, aEmptyStr, aEndTags,
+ HTML_FRMOPTS_SPACER );
+
+ rWrt.Strm() << '>';
+ if( aEndTags.Len() )
+ rWrt.Strm() << aEndTags.GetBuffer();
+
+ return rWrt;
+}
+
+static Writer& OutHTML_FrmFmtAsDivOrSpan( Writer& rWrt,
+ const SwFrmFmt& rFrmFmt, BOOL bSpan)
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const sal_Char *pStr = 0;
+ if( !bSpan )
+ {
+ rHTMLWrt.ChangeParaToken( 0 );
+
+ // Die aktulle <DL> beenden!
+ rHTMLWrt.OutAndSetDefList( 0 );
+ pStr = sHTML_division;
+ }
+ else
+ pStr = sHTML_span;
+
+ // als DIV ausgeben
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+
+ ByteString sOut( '<' );
+ sOut += pStr;
+
+ rWrt.Strm() << sOut.GetBuffer();
+ ByteString aEndTags;
+ ULONG nFrmFlags = HTML_FRMOPTS_DIV;
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_BORDER_NONE ) )
+ nFrmFlags |= HTML_FRMOPT_S_NOBORDER;
+ rHTMLWrt.OutFrmFmtOptions( rFrmFmt, aEmptyStr, aEndTags, nFrmFlags );
+ rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmFlags );
+ rWrt.Strm() << '>';
+
+ rHTMLWrt.IncIndentLevel(); // den Inhalt einruecken
+ rHTMLWrt.bLFPossible = TRUE;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex();
+
+ // Am Start-Node verankerte Rahmen-gebundene Rahmen ausgeben
+ rHTMLWrt.OutFlyFrm( nStt, 0, HTML_POS_ANY );
+
+ const SwStartNode* pSttNd = rWrt.pDoc->GetNodes()[nStt]->GetStartNode();
+ ASSERT( pSttNd, "Wo ist der Start-Node" );
+
+ {
+ // in einem Block damit rechtzeitig vor dem Ende der alte Zustand
+ // wieder hergestellt wird.
+ HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
+ pSttNd->EndOfSectionIndex(),
+ (const SwFlyFrmFmt*)&rFrmFmt );
+ rHTMLWrt.Out_SwDoc( rWrt.pCurPam );
+ }
+
+ rHTMLWrt.DecIndentLevel(); // den Inhalt von Multicol einruecken;
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), pStr, FALSE );
+
+ if( aEndTags.Len() )
+ rWrt.Strm() << aEndTags.GetBuffer();
+
+ return rWrt;
+}
+
+static Writer & OutHTML_FrmFmtAsImage( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ BOOL bInCntnr )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ ImageMap aIMap;
+ Graphic aGrf( ((SwFrmFmt &)rFrmFmt).MakeGraphic( &aIMap ) );
+
+ String aGrfNm;
+ if( rHTMLWrt.GetOrigFileName() )
+ aGrfNm = *rHTMLWrt.GetOrigFileName();
+ if( aGrf.GetType() == GRAPHIC_NONE ||
+ XOutBitmap::WriteGraphic( aGrf, aGrfNm,
+ String::CreateFromAscii( "JPG" ),
+ XOUTBMP_USE_GIF_IF_POSSIBLE ) != 0 )
+ {
+ // leer oder fehlerhaft, da ist nichts auszugeben
+ rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
+ return rWrt;
+ }
+
+ aGrfNm = URIHelper::SmartRelToAbs( aGrfNm );
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( aGrfNm );
+ Size aSz( 0, 0 );
+ ULONG nFrmFlags = bInCntnr ? HTML_FRMOPTS_GENIMG_CNTNR
+ : HTML_FRMOPTS_GENIMG;
+ OutHTML_Image( rWrt, rFrmFmt, aGrfNm, rFrmFmt.GetName(), aSz,
+ HTML_FRMOPTS_GENIMG, pMarkToFrame,
+ aIMap.GetIMapObjectCount() ? &aIMap : 0 );
+ return rWrt;
+}
+
+
+static Writer& OutHTML_FrmFmtGrfNode( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ BOOL bInCntnr )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ SwGrfNode *pGrfNd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetGrfNode();
+ ASSERT( pGrfNd, "Grf-Node erwartet" );
+ if( !pGrfNd )
+ return rWrt;
+
+ const SwMirrorGrf& rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
+
+ String aGrfNm;
+ if( !pGrfNd->IsLinkedFile() || RES_DONT_MIRROR_GRF != rMirror.GetValue() )
+ {
+ // Grafik als File-Referenz speichern (als JPEG-Grafik speichern)
+ if( rHTMLWrt.GetOrigFileName() )
+ aGrfNm = *rHTMLWrt.GetOrigFileName();
+ pGrfNd->SwapIn( TRUE );
+
+ ULONG nFlags = XOUTBMP_USE_GIF_IF_SENSIBLE;
+ switch( rMirror.GetValue() )
+ {
+ case RES_MIRROR_GRF_VERT: nFlags = XOUTBMP_MIRROR_HORZ; break;
+ case RES_MIRROR_GRF_HOR: nFlags = XOUTBMP_MIRROR_VERT; break;
+ case RES_MIRROR_GRF_BOTH:
+ nFlags = XOUTBMP_MIRROR_VERT | XOUTBMP_MIRROR_HORZ;
+ break;
+ }
+
+ Size aMM100Size;
+ const SwFmtFrmSize& rSize = rFrmFmt.GetFrmSize();
+ aMM100Size = OutputDevice::LogicToLogic( rSize.GetSize(),
+ MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ));
+
+ USHORT nErr = XOutBitmap::WriteGraphic( pGrfNd->GetGrf(), aGrfNm,
+ String::CreateFromAscii("JPG"), nFlags, &aMM100Size );
+ if( nErr ) // fehlerhaft, da ist nichts auszugeben
+ {
+ rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
+ return rWrt;
+ }
+ aGrfNm = URIHelper::SmartRelToAbs( aGrfNm );
+ }
+ else
+ {
+ pGrfNd->GetFileFilterNms( &aGrfNm, 0 );
+ if( rHTMLWrt.bCfgCpyLinkedGrfs || rHTMLWrt.HasCId() )
+ rWrt.CopyLocalFileToINet( aGrfNm, rHTMLWrt.HasCId() );
+ }
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( aGrfNm );
+
+ ULONG nFrmFlags = bInCntnr ? HTML_FRMOPTS_IMG_CNTNR : HTML_FRMOPTS_IMG;
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
+ nFrmFlags |= HTML_FRMOPTS_IMG_CSS1;
+ OutHTML_Image( rWrt, rFrmFmt, aGrfNm, pGrfNd->GetAlternateText(),
+ pGrfNd->GetTwipSize(), nFrmFlags, pMarkToGraphic );
+
+ return rWrt;
+}
+
+
+static Writer& OutHTML_FrmFmtAsMarquee( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ const SdrObject& rSdrObj )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // die Edit-Engine-Attribute des Objekts als SW-Attribute holen
+ // und als Hints einsortieren
+ const SfxItemSet& rFmtItemSet = rFrmFmt.GetAttrSet();
+ SfxItemSet aItemSet( *rFmtItemSet.GetPool(), RES_CHRATR_BEGIN,
+ RES_CHRATR_END );
+ SwHTMLWriter::GetEEAttrsFromDrwObj( aItemSet, &rSdrObj, TRUE );
+ BOOL bCfgOutStylesOld = rHTMLWrt.bCfgOutStyles;
+ rHTMLWrt.bCfgOutStyles = FALSE;
+ rHTMLWrt.bTxtAttr = TRUE;
+ rHTMLWrt.bTagOn = TRUE;
+ Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, FALSE );
+ rHTMLWrt.bTxtAttr = FALSE;
+
+ OutHTML_DrawFrmFmtAsMarquee( rHTMLWrt,
+ (const SwDrawFrmFmt &)rFrmFmt,
+ rSdrObj );
+ rHTMLWrt.bTxtAttr = TRUE;
+ rHTMLWrt.bTagOn = FALSE;
+ Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, FALSE );
+ rHTMLWrt.bTxtAttr = FALSE;
+ rHTMLWrt.bCfgOutStyles = bCfgOutStylesOld;
+
+ return rWrt;
+}
+
+//-----------------------------------------------------------------------
+
+Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ BOOL bHeader )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // als Multicol ausgeben
+ rHTMLWrt.OutNewLine();
+ ByteString sOut( sHTML_division );
+ ((sOut += ' ') += sHTML_O_type) += '=';
+ sOut += (bHeader ? "HEADER" : "FOOTER" );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sOut.GetBuffer() );
+
+ rHTMLWrt.IncIndentLevel(); // den Inhalt von Multicol einruecken;
+
+ // Einen Spacer fuer den Absatnd zusammenbasteln. Da durch das
+ // <DL> bzw. </DL> immer einer Absatz-Abstand entsteht, wird der
+ // ggf. abgezogen.
+ const SvxULSpaceItem& rULSpace = rFrmFmt.GetULSpace();
+ USHORT nSize = bHeader ? rULSpace.GetLower() : rULSpace.GetUpper();
+ rHTMLWrt.nHeaderFooterSpace = nSize;
+
+ ByteString aSpacer;
+ if( rHTMLWrt.IsHTMLMode(HTMLMODE_VERT_SPACER) &&
+ nSize > HTML_PARSPACE && Application::GetDefaultDevice() )
+ {
+ nSize -= HTML_PARSPACE;
+ nSize = (INT16)Application::GetDefaultDevice()
+ ->LogicToPixel( Size(nSize,0), MapMode(MAP_TWIP) ).Width();
+
+ ((((((((aSpacer = sHTML_spacer) += ' ')
+ += sHTML_O_type) += '=') += sHTML_SPTYPE_vertical) += ' ')
+ += sHTML_O_size) += '=') += ByteString::CreateFromInt32(nSize);
+ }
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex();
+ const SwStartNode* pSttNd = rWrt.pDoc->GetNodes()[nStt]->GetStartNode();
+ ASSERT( pSttNd, "Wo ist der Start-Node" );
+
+ if( !bHeader && aSpacer.Len() )
+ {
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), aSpacer.GetBuffer() );
+ }
+
+ {
+ // in einem Block damit rechtzeitig vor dem Ende der alte Zustand
+ // wieder hergestellt wird. pFlyFmt braucht hier nicht gestzt zu
+ // werden, denn PageDesc-Attribute koennen hier nicht vorkommen
+ HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
+ pSttNd->EndOfSectionIndex(),
+ rHTMLWrt.GetFlyFrmFmt() );
+
+ if( bHeader )
+ rHTMLWrt.bOutHeader = TRUE;
+ else
+ rHTMLWrt.bOutFooter = TRUE;
+
+ rHTMLWrt.Out_SwDoc( rWrt.pCurPam );
+ }
+
+ if( bHeader && aSpacer.Len() )
+ {
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), aSpacer.GetBuffer() );
+ }
+
+ rHTMLWrt.DecIndentLevel(); // den Inhalt von Multicol einruecken;
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_division, FALSE );
+
+ rHTMLWrt.nHeaderFooterSpace = 0;
+
+ return rWrt;
+}
+
+
+void SwHTMLWriter::AddLinkTarget( const String& rURL )
+{
+ if( !rURL.Len() || rURL.GetChar(0) != '#' )
+ return;
+
+ xub_StrLen nLastPos, nPos = rURL.Search( cMarkSeperator );
+ if( STRING_NOTFOUND == nPos )
+ return;
+
+ while( STRING_NOTFOUND !=
+ ( nLastPos = rURL.Search( cMarkSeperator, nPos + 1 )) )
+ nPos = nLastPos;
+
+ if( nPos<2 ) // mindetsens "#a|..."
+ return;
+
+ String aURL( rURL );
+ aURL.Erase( 0, 1 );
+
+ String sCmp( aURL.Copy( nPos ) ); // nPos-1+1 (-1 wg. Erase)
+ sCmp.EraseAllChars();
+ if( !sCmp.Len() )
+ return;
+
+ sCmp.ToLowerAscii();
+
+ if( sCmp.EqualsAscii( pMarkToRegion ) ||
+ sCmp.EqualsAscii( pMarkToFrame ) ||
+ sCmp.EqualsAscii( pMarkToGraphic ) ||
+ sCmp.EqualsAscii( pMarkToOLE ) ||
+ sCmp.EqualsAscii( pMarkToTable ) )
+ {
+ // Einfach nur in einem sortierten Array merken
+ aImplicitMarks.Insert( new String( aURL ) );
+ }
+ else if( sCmp.EqualsAscii( pMarkToOutline ) )
+ {
+ // Hier brauchen wir Position und Name. Deshalb sortieren wir
+ // ein USHORT und ein String-Array selbst
+ String aOutline( aURL.Copy( 0, nPos-1 ) );
+ SwPosition aPos( *pCurPam->GetPoint() );
+ if( pDoc->GotoOutline( aPos, aOutline ) )
+ {
+ ULONG nIdx = aPos.nNode.GetIndex();
+
+ USHORT nPos=0;
+ while( nPos < aOutlineMarkPoss.Count() &&
+ aOutlineMarkPoss[nPos] < nIdx )
+ nPos++;
+
+ aOutlineMarkPoss.Insert( nIdx, nPos );
+ aOutlineMarks.Insert( new String( aURL ), nPos );
+ }
+ }
+ else if( sCmp.EqualsAscii( pMarkToText ) )
+ {
+ //
+ }
+}
+
+void SwHTMLWriter::CollectLinkTargets()
+{
+ const SwFmtINetFmt* pINetFmt;
+ const SwTxtINetFmt* pTxtAttr;
+ const SwTxtNode* pTxtNd;
+
+ USHORT n, nMaxItems = pDoc->GetAttrPool().GetItemCount( RES_TXTATR_INETFMT );
+ for( n = 0; n < nMaxItems; ++n )
+ {
+ if( 0 != (pINetFmt = (SwFmtINetFmt*)pDoc->GetAttrPool().GetItem(
+ RES_TXTATR_INETFMT, n ) ) &&
+ 0 != ( pTxtAttr = pINetFmt->GetTxtINetFmt()) &&
+ 0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) &&
+ pTxtNd->GetNodes().IsDocNodes() )
+ {
+ AddLinkTarget( pINetFmt->GetValue() );
+ }
+ }
+
+ const SwFmtURL *pURL;
+ nMaxItems = pDoc->GetAttrPool().GetItemCount( RES_URL );
+ for( n = 0; n < nMaxItems; ++n )
+ {
+ if( 0 != (pURL = (SwFmtURL*)pDoc->GetAttrPool().GetItem(
+ RES_URL, n ) ) )
+ {
+ AddLinkTarget( pURL->GetURL() );
+ const ImageMap *pIMap = pURL->GetMap();
+ if( pIMap )
+ {
+ for( USHORT i=0; i<pIMap->GetIMapObjectCount(); i++ )
+ {
+ const IMapObject* pObj = pIMap->GetIMapObject( i );
+ if( pObj )
+ {
+ AddLinkTarget( pObj->GetURL() );
+ }
+ }
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+
+SwHTMLPosFlyFrm::SwHTMLPosFlyFrm( const SwPosFlyFrm& rPosFly,
+ const SdrObject *pSdrObj,
+ BYTE nOutMode ) :
+ pFrmFmt( &rPosFly.GetFmt() ),
+ pSdrObject( pSdrObj ),
+ pNdIdx( new SwNodeIndex( rPosFly.GetNdIndex() ) ),
+ nOrdNum( rPosFly.GetOrdNum() ),
+ nCntntIdx( 0 ),
+ nOutputMode( nOutMode )
+{
+ const SwFmtAnchor& rAnchor = rPosFly.GetFmt().GetAnchor();
+ if( FLY_AUTO_CNTNT==rAnchor.GetAnchorId() &&
+ HTML_POS_INSIDE == GetOutPos() )
+ {
+ // Auto-gebundene Rahmen werden ein Zeichen weiter hinten
+ // ausgegeben, weil dann die Positionierung mit Netscape
+ // uebereinstimmt.
+ ASSERT( rAnchor.GetCntntAnchor(), "Keine Anker-Position?" );
+ if( rAnchor.GetCntntAnchor() )
+ {
+ nCntntIdx = rAnchor.GetCntntAnchor()->nContent.GetIndex();
+ SwRelationOrient eHoriRel = rPosFly.GetFmt().GetHoriOrient().
+ GetRelationOrient();
+ if( FRAME == eHoriRel || PRTAREA == eHoriRel )
+ {
+ const SwCntntNode *pCNd = pNdIdx->GetNode().GetCntntNode();
+ ASSERT( pCNd, "Kein Content-Node an PaM-Position" );
+ if( pCNd && nCntntIdx < pCNd->Len() )
+ nCntntIdx++;
+ }
+ }
+ }
+}
+
+BOOL SwHTMLPosFlyFrm::operator<( const SwHTMLPosFlyFrm& rFrm ) const
+{
+ if( pNdIdx->GetIndex() == rFrm.pNdIdx->GetIndex() )
+ {
+ if( nCntntIdx == rFrm.nCntntIdx )
+ {
+ if( GetOutPos() == rFrm.GetOutPos() )
+ return nOrdNum < rFrm.nOrdNum;
+ else
+ return GetOutPos() < rFrm.GetOutPos();
+ }
+ else
+ return nCntntIdx < rFrm.nCntntIdx;
+ }
+ else
+ return pNdIdx->GetIndex() < rFrm.pNdIdx->GetIndex();
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlfly.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.81 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.80 2000/08/18 13:03:15 jp
+ don't export escaped URLs
+
+ Revision 1.79 2000/06/26 12:55:05 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.78 2000/06/26 09:52:01 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.77 2000/05/15 16:35:52 jp
+ Changes for Unicode
+
+ Revision 1.76 2000/04/28 14:29:11 mib
+ unicode
+
+ Revision 1.75 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.74 2000/02/11 14:36:57 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.73 1999/09/21 09:49:42 mib
+ multiple text encodings
+
+ Revision 1.72 1999/07/09 10:40:20 MIB
+ #67508#: <BR CLEAR> for Frames that are centered
+
+
+ Rev 1.71 09 Jul 1999 12:40:20 MIB
+ #67508#: <BR CLEAR> for Frames that are centered
+
+ Rev 1.70 16 Jun 1999 19:48:10 JP
+ Change interface of base class Writer
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlfly.hxx b/sw/source/filter/html/htmlfly.hxx
new file mode 100644
index 000000000000..3b8c2346f81c
--- /dev/null
+++ b/sw/source/filter/html/htmlfly.hxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlfly.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _HTMLFLY_HXX
+#define _HTMLFLY_HXX
+
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+#ifndef _SVARRAY_H
+#include <svtools/svarray.hxx>
+#endif
+
+class SdrObject;
+class SwFrmFmt;
+class SwNodeIndex;
+class SwPosFlyFrm;
+
+// ACHTUNG: Die Werte dieses Enumgs gehen direkt in die
+// Augabe Tabelle!!!
+enum SwHTMLFrmType
+{
+ HTML_FRMTYPE_TABLE,
+ HTML_FRMTYPE_TABLE_CAP,
+ HTML_FRMTYPE_MULTICOL,
+ HTML_FRMTYPE_EMPTY,
+ HTML_FRMTYPE_TEXT,
+ HTML_FRMTYPE_GRF,
+ HTML_FRMTYPE_PLUGIN,
+ HTML_FRMTYPE_APPLET,
+ HTML_FRMTYPE_IFRAME,
+ HTML_FRMTYPE_OLE,
+ HTML_FRMTYPE_MARQUEE,
+ HTML_FRMTYPE_CONTROL,
+ HTML_FRMTYPE_DRAW,
+ HTML_FRMTYPE_END
+};
+
+#define HTML_OUT_TBLNODE 0x00
+#define HTML_OUT_GRFNODE 0x01
+#define HTML_OUT_OLENODE 0x02
+#define HTML_OUT_DIV 0x03
+#define HTML_OUT_MULTICOL 0x04
+#define HTML_OUT_SPACER 0x05
+#define HTML_OUT_CONTROL 0x06
+#define HTML_OUT_AMARQUEE 0x07
+#define HTML_OUT_MARQUEE 0x08
+#define HTML_OUT_GRFFRM 0x09
+#define HTML_OUT_OLEGRF 0x0a
+#define HTML_OUT_SPAN 0x0b
+#define HTML_OUT_MASK 0x0f
+
+#define HTML_POS_PREFIX 0x00
+#define HTML_POS_BEFORE 0x10
+#define HTML_POS_INSIDE 0x20
+#define HTML_POS_ANY 0x30
+#define HTML_POS_MASK 0x30
+
+#define HTML_CNTNR_NONE 0x00
+#define HTML_CNTNR_SPAN 0x40
+#define HTML_CNTNR_DIV 0x80
+#define HTML_CNTNR_MASK 0xc0
+
+
+const USHORT MAX_FRMTYPES = HTML_FRMTYPE_END;
+const USHORT MAX_BROWSERS = 5;
+
+extern BYTE aHTMLOutFrmPageFlyTable[MAX_FRMTYPES][MAX_BROWSERS];
+extern BYTE aHTMLOutFrmParaFrameTable[MAX_FRMTYPES][MAX_BROWSERS];
+extern BYTE aHTMLOutFrmParaPrtAreaTable[MAX_FRMTYPES][MAX_BROWSERS];
+extern BYTE aHTMLOutFrmParaOtherTable[MAX_FRMTYPES][MAX_BROWSERS];
+extern BYTE aHTMLOutFrmAsCharTable[MAX_FRMTYPES][MAX_BROWSERS];
+
+class SwHTMLPosFlyFrm
+{
+ const SwFrmFmt *pFrmFmt; // der Rahmen
+ const SdrObject *pSdrObject; // ggf. Sdr-Objekt
+ SwNodeIndex *pNdIdx; // Node-Index
+ UINT32 nOrdNum; // Aus SwPosFlyFrm
+ xub_StrLen nCntntIdx; // seine Position im Content
+ BYTE nOutputMode; // Ausgabe-Infos
+
+public:
+
+ SwHTMLPosFlyFrm( const SwPosFlyFrm& rPosFly,
+ const SdrObject *pSdrObj, BYTE nOutMode );
+
+ BOOL operator==( const SwHTMLPosFlyFrm& ) const { return FALSE; }
+ BOOL operator<( const SwHTMLPosFlyFrm& ) const;
+
+ const SwFrmFmt& GetFmt() const { return *pFrmFmt; }
+ const SdrObject *GetSdrObject() const { return pSdrObject; }
+
+ const SwNodeIndex& GetNdIndex() const { return *pNdIdx; }
+
+ xub_StrLen GetCntntIndex() const { return nCntntIdx; }
+
+ BYTE GetOutMode() const { return nOutputMode; }
+
+ static BYTE GetOutFn( BYTE nMode ) { return nMode & HTML_OUT_MASK; }
+ static BYTE GetOutPos( BYTE nMode ) { return nMode & HTML_POS_MASK; }
+ static BYTE GetOutCntnr( BYTE nMode ) { return nMode & HTML_CNTNR_MASK; }
+
+ BYTE GetOutFn() const { return nOutputMode & HTML_OUT_MASK; }
+ BYTE GetOutPos() const { return nOutputMode & HTML_POS_MASK; }
+ BYTE GetOutCntnr() const { return nOutputMode & HTML_CNTNR_MASK; }
+};
+
+typedef SwHTMLPosFlyFrm *SwHTMLPosFlyFrmPtr;
+SV_DECL_PTRARR_SORT( SwHTMLPosFlyFrms, SwHTMLPosFlyFrmPtr, 10, 10 )
+
+
+#endif
diff --git a/sw/source/filter/html/htmlflyt.cxx b/sw/source/filter/html/htmlflyt.cxx
new file mode 100644
index 000000000000..e174f6be41b9
--- /dev/null
+++ b/sw/source/filter/html/htmlflyt.cxx
@@ -0,0 +1,673 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlflyt.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "htmlfly.hxx"
+
+#define TE(t,p,c) (BYTE)( HTML_OUT_##t | HTML_POS_##p | HTML_CNTNR_##c )
+
+BYTE aHTMLOutFrmPageFlyTable[MAX_FRMTYPES][MAX_BROWSERS] =
+{
+ {
+ // Textrahmen mit Tabelle
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(DIV, PREFIX, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(DIV, PREFIX, NONE), // SW
+ TE(DIV, PREFIX, NONE) // Netscape 4!
+ },
+ {
+ // Textrahmen mit Tabelle und Ueberschrift
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(DIV, PREFIX, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(DIV, PREFIX, NONE), // SW
+ TE(DIV, PREFIX, NONE) // Netscape 4
+ },
+ {
+ // spaltiger Rahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, PREFIX, NONE), // IE 4
+ TE(MULTICOL,BEFORE, NONE), // Netscape 3
+ TE(MULTICOL,PREFIX, NONE), // SW
+ TE(MULTICOL,PREFIX, DIV) // Netscape 4
+ },
+ {
+ // leerer Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(DIV, PREFIX, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(DIV, PREFIX, NONE), // SW
+ TE(DIV, PREFIX, NONE) // Netscape 4
+ },
+ {
+ // sonstiger Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(DIV, PREFIX, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(DIV, PREFIX, NONE), // SW
+ TE(DIV, PREFIX, NONE) // Netscape 4
+ },
+ {
+ // Grafik-Node
+ TE(GRFNODE, INSIDE, NONE), // HTML 3.2
+ TE(GRFNODE, PREFIX, NONE), // IE 4
+ TE(GRFNODE, INSIDE, NONE), // Netscape 3
+ TE(GRFNODE, PREFIX, NONE), // SW
+ TE(GRFNODE, PREFIX, SPAN) // Netscape 4
+ },
+ {
+ // Plugin
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, PREFIX, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, PREFIX, NONE), // SW
+ TE(OLENODE, PREFIX, SPAN) // Netscape 4
+ },
+ {
+ // Applet
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, PREFIX, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, PREFIX, NONE), // SW
+ TE(OLENODE, PREFIX, SPAN) // Netscape 4
+ },
+ {
+ // Floating-Frame
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, PREFIX, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, PREFIX, NONE), // SW
+ TE(OLEGRF, PREFIX, SPAN) // Netscape 4
+ },
+ {
+ // sonstige OLE-Objekte
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLEGRF, PREFIX, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLEGRF, PREFIX, NONE), // SW
+ TE(OLEGRF, PREFIX, SPAN) // Netscape 4
+ },
+ {
+ // Laufschrift
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(AMARQUEE,PREFIX, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(AMARQUEE,PREFIX, NONE), // SW
+ TE(GRFFRM, PREFIX, SPAN) // Netscape 4
+ },
+ {
+ // Controls
+ TE(CONTROL, INSIDE, NONE), // HTML 3.2
+ TE(CONTROL, PREFIX, NONE), // IE 4
+ TE(CONTROL, INSIDE, NONE), // Netscape 3
+ TE(CONTROL, PREFIX, NONE), // SW
+ // Netscape schaltet FORM bei Controls in abs.-pos. SPAN aus.
+ TE(CONTROL, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstige Zeichen-Objekte
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, PREFIX, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, PREFIX, NONE), // SW
+ TE(GRFFRM, PREFIX, SPAN) // Netscape 4
+ }
+};
+
+BYTE aHTMLOutFrmParaFrameTable[MAX_FRMTYPES][MAX_BROWSERS] =
+{
+ {
+ // Textrahmen mit Tabelle
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(TBLNODE, BEFORE, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(TBLNODE, BEFORE, NONE), // SW
+ TE(TBLNODE, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Textrahmen mit Tabelle und Ueberschrift
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(DIV, BEFORE, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(DIV, BEFORE, NONE), // SW
+ TE(TBLNODE, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // spaltiger Rahmen
+ TE(GRFFRM, BEFORE, NONE), // HTML 3.2
+ TE(GRFFRM, BEFORE, NONE), // IE 4
+ TE(MULTICOL,BEFORE, NONE), // Netscape 3
+ TE(MULTICOL,BEFORE, NONE), // SW
+ TE(MULTICOL,BEFORE, DIV) // Netscape 4
+ },
+ {
+ // leerer Textreahmen
+ TE(GRFFRM, BEFORE, NONE), // HTML 3.2
+ TE(DIV, BEFORE, NONE), // IE 4
+ TE(SPACER, BEFORE, NONE), // Netscape 3
+ TE(SPACER, BEFORE, NONE), // SW
+ TE(SPACER, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // sonstiger Textreahmen
+ TE(GRFFRM, BEFORE, NONE), // HTML 3.2
+ TE(DIV, BEFORE, NONE), // IE 4
+ TE(GRFFRM, BEFORE, NONE), // Netscape 3
+ TE(DIV, BEFORE, NONE), // SW
+ TE(DIV, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Grafik-Node
+ TE(GRFNODE, BEFORE, NONE), // HTML 3.2
+ TE(GRFNODE, BEFORE, NONE), // IE 4
+ TE(GRFNODE, BEFORE, NONE), // Netscape 3
+ TE(GRFNODE, BEFORE, NONE), // SW
+ TE(GRFNODE, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Plugin
+ TE(OLENODE, BEFORE, NONE), // HTML 3.2
+ TE(OLENODE, BEFORE, NONE), // IE 4
+ TE(OLENODE, BEFORE, NONE), // Netscape 3
+ TE(OLENODE, BEFORE, NONE), // SW
+ TE(OLENODE, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Applet
+ TE(OLENODE, BEFORE, NONE), // HTML 3.2
+ TE(OLENODE, BEFORE, NONE), // IE 4
+ TE(OLENODE, BEFORE, NONE), // Netscape 3
+ TE(OLENODE, BEFORE, NONE), // SW
+ TE(OLENODE, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Floating-Frame
+ TE(OLEGRF, BEFORE, NONE), // HTML 3.2
+ TE(OLENODE, BEFORE, NONE), // IE 4
+ TE(OLEGRF, BEFORE, NONE), // Netscape 3
+ TE(OLENODE, BEFORE, NONE), // SW
+ TE(OLEGRF, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // sonstige OLE-Objekte
+ TE(OLEGRF, BEFORE, NONE), // HTML 3.2
+ TE(OLEGRF, BEFORE, NONE), // IE 4
+ TE(OLEGRF, BEFORE, NONE), // Netscape 3
+ TE(OLEGRF, BEFORE, NONE), // SW
+ TE(OLEGRF, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Laufschrift (fuer Netscape 4 im Container, damit
+ // die LAufschrift an der richtigen Stelle erscheint
+ TE(GRFFRM, BEFORE, NONE), // HTML 3.2
+ TE(AMARQUEE,BEFORE, NONE), // IE 4
+ TE(GRFFRM, BEFORE, NONE), // Netscape 3
+ TE(AMARQUEE,BEFORE, NONE), // SW
+ TE(GRFFRM, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // Controls
+ TE(CONTROL, INSIDE, NONE), // HTML 3.2
+ TE(CONTROL, BEFORE, NONE), // IE 4
+ TE(CONTROL, INSIDE, NONE), // Netscape 3
+ TE(CONTROL, BEFORE, NONE), // SW
+ // hier koennte man einen Container draus machen (Import fehlt)
+ TE(CONTROL, BEFORE, NONE) // Netscape 4
+ },
+ {
+ // sonstige Zeichen-Objekte
+ TE(GRFFRM, BEFORE, NONE), // HTML 3.2
+ TE(GRFFRM, BEFORE, NONE), // IE 4
+ TE(GRFFRM, BEFORE, NONE), // Netscape 3
+ TE(GRFFRM, BEFORE, NONE), // SW
+ TE(GRFFRM, BEFORE, NONE) // Netscape 4
+ }
+};
+
+BYTE aHTMLOutFrmParaPrtAreaTable[MAX_FRMTYPES][MAX_BROWSERS] =
+{
+ {
+ // Textrahmen mit Tabelle
+#if 0
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(TBLNODE, BEFORE, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(TBLNODE, BEFORE, NONE), // SW
+ TE(TBLNODE, BEFORE, NONE) // Netscape 4
+#endif
+ TE(TBLNODE, INSIDE, NONE), // HTML 3.2
+ TE(TBLNODE, INSIDE, NONE), // IE 4
+ TE(TBLNODE, INSIDE, NONE), // Netscape 3
+ TE(TBLNODE, INSIDE, NONE), // SW
+ TE(TBLNODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Textrahmen mit Tabelle und Ueberschrift
+#if 0
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(DIV, BEFORE, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(DIV, BEFORE, NONE), // SW
+ TE(DIV, BEFORE, NONE) // Netscape 4
+#endif
+ TE(TBLNODE, INSIDE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(TBLNODE, INSIDE, NONE), // Netscape 3
+ TE(SPAN, INSIDE, NONE), // SW
+ TE(SPAN, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // spaltiger Rahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(MULTICOL,INSIDE, NONE), // Netscape 3
+ TE(MULTICOL,INSIDE, NONE), // SW
+ TE(MULTICOL,INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // leerer Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(SPACER, INSIDE, NONE), // Netscape 3
+ TE(SPACER, INSIDE, NONE), // SW
+ TE(SPACER, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstiger Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(SPAN, INSIDE, NONE), // SW
+ TE(SPAN, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Grafik-Node
+ TE(GRFNODE, INSIDE, NONE), // HTML 3.2
+ TE(GRFNODE, INSIDE, NONE), // IE 4
+ TE(GRFNODE, INSIDE, NONE), // Netscape 3
+ TE(GRFNODE, INSIDE, NONE), // SW
+ TE(GRFNODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Plugin
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLENODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Applet
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLENODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Floating-Frame
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLEGRF, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstige OLE-Objekte
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLEGRF, INSIDE, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLEGRF, INSIDE, NONE), // SW
+ TE(OLEGRF, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Laufschrift
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(AMARQUEE,INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(AMARQUEE,INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Controls
+ TE(CONTROL, INSIDE, NONE), // HTML 3.2
+ TE(CONTROL, INSIDE, NONE), // IE 4
+ TE(CONTROL, INSIDE, NONE), // Netscape 3
+ TE(CONTROL, INSIDE, NONE), // SW
+ // hier koennte man einen Container draus machen (Import fehlt)
+ TE(CONTROL, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstige Zeichen-Objekte
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, NONE) // Netscape 4
+ }
+};
+
+BYTE aHTMLOutFrmParaOtherTable[MAX_FRMTYPES][MAX_BROWSERS] =
+{
+ {
+ // Textrahmen mit Tabelle
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(SPAN, INSIDE, NONE), // SW
+ TE(SPAN, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Textrahmen mit Tabelle und Ueberschrift
+ TE(TBLNODE, BEFORE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(TBLNODE, BEFORE, NONE), // Netscape 3
+ TE(SPAN, INSIDE, NONE), // SW
+ TE(SPAN, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // spaltiger Rahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(MULTICOL,BEFORE, NONE), // Netscape 3
+ TE(MULTICOL,INSIDE, NONE), // SW
+ TE(MULTICOL,INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // leerer Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(SPAN, INSIDE, NONE), // SW
+ TE(SPAN, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstiger Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(SPAN, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(SPAN, INSIDE, NONE), // SW
+ TE(SPAN, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Grafik-Node
+ TE(GRFNODE, INSIDE, NONE), // HTML 3.2
+ TE(GRFNODE, INSIDE, NONE), // IE 4
+ TE(GRFNODE, INSIDE, NONE), // Netscape 3
+ TE(GRFNODE, INSIDE, NONE), // SW
+ TE(GRFNODE, INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // Plugin
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLENODE, INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // Applet
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLENODE, INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // Floating-Frame
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLEGRF, INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // sonstige OLE-Objekte
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLEGRF, INSIDE, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLEGRF, INSIDE, NONE), // SW
+ TE(OLEGRF, INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // Laufschrift
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(AMARQUEE,INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(AMARQUEE,INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, SPAN) // Netscape 4
+ },
+ {
+ // Controls
+ TE(CONTROL, INSIDE, NONE), // HTML 3.2
+ TE(CONTROL, INSIDE, NONE), // IE 4
+ TE(CONTROL, INSIDE, NONE), // Netscape 3
+ TE(CONTROL, INSIDE, NONE), // SW
+ // Netscape schaltet FORM bei Controls in abs.-pos. SPAN aus.
+ TE(CONTROL, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstige Zeichen-Objekte
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, SPAN) // Netscape 4
+ }
+};
+
+BYTE aHTMLOutFrmAsCharTable[MAX_FRMTYPES][MAX_BROWSERS] =
+{
+ {
+ // Textrahmen mit Tabelle
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Textrahmen mit Tabelle und Ueberschrift
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // spaltiger Rahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(MULTICOL,INSIDE, NONE), // Netscape 3
+ TE(MULTICOL,INSIDE, NONE), // SW
+ TE(MULTICOL,INSIDE, NONE) // Netscape 4
+ },
+ {
+ // leerer Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(SPACER, INSIDE, NONE), // Netscape 3
+ TE(SPACER, INSIDE, NONE), // SW
+ TE(SPACER, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstiger Textreahmen
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Grafik-Node
+ TE(GRFNODE, INSIDE, NONE), // HTML 3.2
+ TE(GRFNODE, INSIDE, NONE), // IE 4
+ TE(GRFNODE, INSIDE, NONE), // Netscape 3
+ TE(GRFNODE, INSIDE, NONE), // SW
+ TE(GRFNODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Plugin
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLENODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Applet
+ TE(OLENODE, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLENODE, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLENODE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Floating-Frame
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLENODE, INSIDE, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLENODE, INSIDE, NONE), // SW
+ TE(OLEGRF, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstige OLE-Objekte
+ TE(OLEGRF, INSIDE, NONE), // HTML 3.2
+ TE(OLEGRF, INSIDE, NONE), // IE 4
+ TE(OLEGRF, INSIDE, NONE), // Netscape 3
+ TE(OLEGRF, INSIDE, NONE), // SW
+ TE(OLEGRF, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Laufschrift (kann immer als MARQUEE exportiert werden, weil
+ // der Inhalt an der richtigen Stelle erscheint
+ TE(MARQUEE, INSIDE, NONE), // HTML 3.2
+ TE(MARQUEE, INSIDE, NONE), // IE 4
+ TE(MARQUEE, INSIDE, NONE), // Netscape 3
+ TE(MARQUEE, INSIDE, NONE), // SW
+ TE(MARQUEE, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // Controls
+ TE(CONTROL, INSIDE, NONE), // HTML 3.2
+ TE(CONTROL, INSIDE, NONE), // IE 4
+ TE(CONTROL, INSIDE, NONE), // Netscape 3
+ TE(CONTROL, INSIDE, NONE), // SW
+ TE(CONTROL, INSIDE, NONE) // Netscape 4
+ },
+ {
+ // sonstige Zeichen-Objekte
+ TE(GRFFRM, INSIDE, NONE), // HTML 3.2
+ TE(GRFFRM, INSIDE, NONE), // IE 4
+ TE(GRFFRM, INSIDE, NONE), // Netscape 3
+ TE(GRFFRM, INSIDE, NONE), // SW
+ TE(GRFFRM, INSIDE, NONE) // Netscape 4
+ }
+};
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlflyt.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.9 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.8 1999/11/17 16:53:54 mib
+ #67938#: Export columned frames as images in MS-IE mode
+
+ Revision 1.7 1998/04/20 07:46:02 MIB
+ IE3-Export weg
+
+
+ Rev 1.6 20 Apr 1998 09:46:02 MIB
+ IE3-Export weg
+
+ Rev 1.5 02 Apr 1998 19:48:30 MIB
+ Spaltige Rahmen fuer SW ohne Container exportieren
+
+ Rev 1.4 31 Mar 1998 11:23:36 MIB
+ Keine Verschiebung von manchen am Zeichen geb. Rahmen und anderes
+
+ Rev 1.3 27 Mar 1998 17:25:50 MIB
+ direkte absolute Positionierung und Groessen-Export von Controls und Marquee
+
+ Rev 1.2 20 Mar 1998 10:50:14 MIB
+ Anpassungen an Netscape
+
+ Rev 1.1 19 Mar 1998 09:18:58 MIB
+ Rahmen-Export verbessert/aufgeraeumt
+
+ Rev 1.0 14 Mar 1998 19:05:18 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
new file mode 100644
index 000000000000..76f4b92c2001
--- /dev/null
+++ b/sw/source/filter/html/htmlform.cxx
@@ -0,0 +1,3209 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlform.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#ifndef _SV_SYSTEM_HXX //autogen
+#include <vcl/system.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _IMGCONS_HXX //autogen
+#include <vcl/imgcons.hxx>
+#endif
+
+#ifndef _TOOLKIT_UNOHLP_HXX
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+
+#ifndef _SFXDOCFILE_HXX //autogen
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _SFX_OBJUNO_HXX //autogen
+#include <sfx2/objuno.hxx>
+#endif
+#ifndef _SFXAPP_HXX
+#include <sfx2/app.hxx>
+#endif
+
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVDOUNO_HXX //autogen
+#include <svx/svdouno.hxx>
+#endif
+#ifndef _SVX_FMGLOB_HXX
+#include <svx/fmglob.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_LISTSOURCETYPE_HPP_
+#include <com/sun/star/form/ListSourceType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_
+#include <com/sun/star/form/FormButtonType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_
+#include <com/sun/star/form/FormSubmitEncoding.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_
+#include <com/sun/star/form/FormSubmitMethod.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHERMANAGER_HPP_
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_SCRIPTEVENTDESCRIPTOR_HPP_
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_WRAPTEXTMODE_HPP_
+#include <com/sun/star/text/WrapTextMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_HORIORIENTATION_HPP_
+#include <com/sun/star/text/HoriOrientation.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HPP_
+#include <com/sun/star/text/VertOrientation.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP_
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_
+#include <com/sun/star/drawing/XControlShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTEXTLAYOUTCONSTRAINS_HPP_
+#include <com/sun/star/awt/XTextLayoutConstrains.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XLAYOUTCONSTRAINS_HPP_
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#endif
+
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX //autogen
+#include <pam.hxx>
+#endif
+#ifndef _SWTABLE_HXX //autogen
+#include <swtable.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _HTMLTBL_HXX //autogen
+#include <htmltbl.hxx>
+#endif
+
+#ifndef _SWDOCSH_HXX //autogen
+#include <docsh.hxx>
+#endif
+#ifndef _VIEWSH_HXX //autogen
+#include <viewsh.hxx>
+#endif
+
+#ifndef _UNODRAW_HXX //autogen
+#include <unodraw.hxx>
+#endif
+#ifndef _UNOOBJ_HXX //autogen
+#include <unoobj.hxx>
+#endif
+#include "dcontact.hxx"
+
+#include "swcss1.hxx"
+#include "swhtml.hxx"
+#include "htmlform.hxx"
+
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx> // helper for implementations
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::form;
+using namespace ::rtl;
+
+const sal_uInt16 TABINDEX_MIN = 0;
+const sal_uInt16 TABINDEX_MAX = 32767;
+
+static HTMLOptionEnum __FAR_DATA aHTMLFormMethodTable[] =
+{
+ { sHTML_METHOD_get, FormSubmitMethod_GET },
+ { sHTML_METHOD_post, FormSubmitMethod_POST },
+ { 0, 0 }
+};
+
+static HTMLOptionEnum __FAR_DATA aHTMLFormEncTypeTable[] =
+{
+ { sHTML_ET_url, FormSubmitEncoding_URL },
+ { sHTML_ET_multipart, FormSubmitEncoding_MULTIPART },
+ { sHTML_ET_text, FormSubmitEncoding_TEXT },
+ { 0, 0 }
+};
+
+enum HTMLWordWrapMode { HTML_WM_OFF, HTML_WM_HARD, HTML_WM_SOFT };
+
+static HTMLOptionEnum __FAR_DATA aHTMLTextAreaWrapTable[] =
+{
+ { sHTML_WW_off, HTML_WM_OFF },
+ { sHTML_WW_hard, HTML_WM_HARD },
+ { sHTML_WW_soft, HTML_WM_SOFT },
+ { sHTML_WW_physical,HTML_WM_HARD },
+ { sHTML_WW_virtual, HTML_WM_SOFT },
+ { 0, 0 }
+};
+
+HTMLEventType __FAR_DATA aEventTypeTable[] =
+{
+ HTML_ET_ONSUBMITFORM,
+ HTML_ET_ONRESETFORM,
+ HTML_ET_ONGETFOCUS,
+ HTML_ET_ONLOSEFOCUS,
+ HTML_ET_ONCLICK,
+ HTML_ET_ONCLICK_ITEM,
+ HTML_ET_ONCHANGE,
+ HTML_ET_ONSELECT,
+ HTML_ET_END
+};
+
+const sal_Char * __FAR_DATA aEventListenerTable[] =
+{
+ "XSubmitListener",
+ "XResetListener",
+ "XFocusListener",
+ "XFocusListener",
+ "XApproveActionListener",
+ "XItemListener",
+ "XChangeListener",
+ ""
+};
+
+const sal_Char * __FAR_DATA aEventMethodTable[] =
+{
+ "approveSubmit",
+ "approveReset",
+ "focusGained",
+ "focusLost",
+ "approveAction",
+ "itemStateChanged",
+ "changed",
+ ""
+};
+
+const sal_Char * __FAR_DATA aEventSDOptionTable[] =
+{
+ sHTML_O_SDonsubmit,
+ sHTML_O_SDonreset,
+ sHTML_O_SDonfocus,
+ sHTML_O_SDonblur,
+ sHTML_O_SDonclick,
+ sHTML_O_SDonclick,
+ sHTML_O_SDonchange,
+ 0
+};
+
+const sal_Char * __FAR_DATA aEventOptionTable[] =
+{
+ sHTML_O_onsubmit,
+ sHTML_O_onreset,
+ sHTML_O_onfocus,
+ sHTML_O_onblur,
+ sHTML_O_onclick,
+ sHTML_O_onclick,
+ sHTML_O_onchange,
+ 0
+};
+
+/* */
+
+class SwHTMLForm_Impl
+{
+ SwDocShell *pDocSh;
+
+ SvKeyValueIterator *pHeaderAttrs;
+
+ // gecachte Interfaces
+ Reference< drawing::XDrawPage > xDrawPage;
+ Reference< container::XIndexContainer > xForms;
+ Reference< drawing::XShapes > xShapes;
+ Reference< XMultiServiceFactory > xServiceFactory;
+
+ Reference< script::XEventAttacherManager > xControlEventManager;
+ Reference< script::XEventAttacherManager > xFormEventManager;
+
+ // Kontext-Informationen
+ Reference< container::XIndexContainer > xFormComps;
+ Reference< beans::XPropertySet > xFCompPropSet;
+ Reference< drawing::XShape > xShape;
+
+ String sText;
+ SvStringsDtor aStringList;
+ SvStringsDtor aValueList;
+ SvUShorts aSelectedList;
+
+public:
+
+ SwHTMLForm_Impl( SwDocShell *pDSh ) :
+ pDocSh( pDSh ),
+ pHeaderAttrs( pDSh ? pDSh->GetHeaderAttributes() : 0 )
+ {
+ ASSERT( pDocSh, "Keine DocShell, keine Controls" );
+ }
+
+ const Reference< XMultiServiceFactory >& GetServiceFactory();
+ const Reference< drawing::XDrawPage >& GetDrawPage();
+ const Reference< drawing::XShapes >& GetShapes();
+ const Reference< script::XEventAttacherManager >& GetControlEventManager();
+ const Reference< script::XEventAttacherManager >& GetFormEventManager();
+ const Reference< container::XIndexContainer >& GetForms();
+
+ const Reference< container::XIndexContainer >& GetFormComps() const
+ {
+ return xFormComps;
+ }
+
+ void SetFormComps( const Reference< container::XIndexContainer >& r )
+ {
+ xFormComps = r;
+ }
+
+ void ReleaseFormComps() { xFormComps = 0; xControlEventManager = 0; }
+
+ const Reference< beans::XPropertySet >& GetFCompPropSet() const
+ {
+ return xFCompPropSet;
+ }
+
+ void SetFCompPropSet( const Reference< beans::XPropertySet >& r )
+ {
+ xFCompPropSet = r;
+ }
+
+ void ReleaseFCompPropSet() { xFCompPropSet = 0; }
+
+ const Reference< drawing::XShape >& GetShape() const { return xShape; }
+ void SetShape( const Reference< drawing::XShape >& r ) { xShape = r; }
+ void ReleaseShape() { xShape = 0; }
+
+ String& GetText() { return sText; }
+ void EraseText() { sText = aEmptyStr; }
+
+ SvStringsDtor& GetStringList() { return aStringList; }
+ void EraseStringList()
+ {
+ aStringList.DeleteAndDestroy( 0, aStringList.Count() );
+ }
+
+ SvStringsDtor& GetValueList() { return aValueList; }
+ void EraseValueList()
+ {
+ aValueList.DeleteAndDestroy( 0, aValueList.Count() );
+ }
+
+ SvUShorts& GetSelectedList() { return aSelectedList; }
+ void EraseSelectedList()
+ {
+ aSelectedList.Remove( 0, aSelectedList.Count() );
+ }
+
+ SvKeyValueIterator *GetHeaderAttrs() const { return pHeaderAttrs; }
+};
+
+const Reference< XMultiServiceFactory >& SwHTMLForm_Impl::GetServiceFactory()
+{
+ if( !xServiceFactory.is() && pDocSh )
+ {
+ xServiceFactory =
+ Reference< XMultiServiceFactory >( pDocSh->GetBaseModel(),
+ UNO_QUERY );
+ ASSERT( xServiceFactory.is(),
+ "XServiceFactory nicht vom Model erhalten" );
+ }
+ return xServiceFactory;
+}
+
+
+const Reference< drawing::XDrawPage >& SwHTMLForm_Impl::GetDrawPage()
+{
+ if( !xDrawPage.is() && pDocSh )
+ {
+ Reference< drawing::XDrawPageSupplier > xTxtDoc( pDocSh->GetBaseModel(),
+ UNO_QUERY );
+ ASSERT( xTxtDoc.is(),
+ "drawing::XDrawPageSupplier nicht vom XModel erhalten" );
+ xDrawPage = xTxtDoc->getDrawPage();
+ ASSERT( xDrawPage.is(), "drawing::XDrawPage nicht erhalten" );
+ }
+ return xDrawPage;
+}
+
+const Reference< container::XIndexContainer >& SwHTMLForm_Impl::GetForms()
+{
+ if( !xForms.is() )
+ {
+ GetDrawPage();
+ if( xDrawPage.is() )
+ {
+ Reference< XFormsSupplier > xFormsSupplier( xDrawPage, UNO_QUERY );
+ ASSERT( xFormsSupplier.is(),
+ "XFormsSupplier nicht vom drawing::XDrawPage erhalten" );
+
+ Reference< container::XNameContainer > xNameCont =
+ xFormsSupplier->getForms();
+ xForms = Reference< container::XIndexContainer >( xNameCont,
+ UNO_QUERY );
+
+ ASSERT( xForms.is(), "XForms nicht erhalten" );
+ }
+ }
+ return xForms;
+}
+
+
+const Reference< drawing::XShapes > & SwHTMLForm_Impl::GetShapes()
+{
+ if( !xShapes.is() )
+ {
+ GetDrawPage();
+ if( xDrawPage.is() )
+ {
+ xShapes = Reference< drawing::XShapes >( xDrawPage, UNO_QUERY );
+ ASSERT( xShapes.is(),
+ "XShapes nicht vom drawing::XDrawPage erhalten" );
+ }
+ }
+ return xShapes;
+}
+
+const Reference< script::XEventAttacherManager >&
+ SwHTMLForm_Impl::GetControlEventManager()
+{
+ if( !xControlEventManager.is() && xFormComps.is() )
+ {
+ xControlEventManager =
+ Reference< script::XEventAttacherManager >( xFormComps, UNO_QUERY );
+ ASSERT( xControlEventManager.is(),
+ "Reference< XEventAttacherManager > nicht von xFormComps erhalten" );
+ }
+
+ return xControlEventManager;
+}
+
+const Reference< script::XEventAttacherManager >&
+ SwHTMLForm_Impl::GetFormEventManager()
+{
+ if( !xFormEventManager.is() )
+ {
+ GetForms();
+ if( xForms.is() )
+ {
+ xFormEventManager =
+ Reference< script::XEventAttacherManager >( xForms, UNO_QUERY );
+ ASSERT( xFormEventManager.is(),
+ "Reference< XEventAttacherManager > nicht von xForms erhalten" );
+ }
+ }
+
+ return xFormEventManager;
+}
+
+class SwHTMLImageWatcher :
+ public cppu::WeakImplHelper2< awt::XImageConsumer, XEventListener >
+{
+ Reference< drawing::XShape > xShape; // das control
+ Reference< XImageProducerSupplier > xSrc;
+ Reference< awt::XImageConsumer > xThis; // man selbst
+ sal_Bool bSetWidth;
+ sal_Bool bSetHeight;
+
+ void clear();
+
+public:
+
+ SwHTMLImageWatcher( const Reference< drawing::XShape > & rShape,
+ sal_Bool bWidth, sal_Bool bHeight );
+ ~SwHTMLImageWatcher();
+
+ // startProduction darf nicht im Konstruktor gerufen werden, weil
+ // wir und ggf. selbst zerstoeren ... Deshlab eine eigene Methode.
+ void start() { xSrc->getImageProducer()->startProduction(); }
+
+ // UNO Anbindung
+
+ // XImageConsumer
+ virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height)
+ throw( uno::RuntimeException );
+ virtual void SAL_CALL setColorModel(
+ sal_Int16 BitCount, const uno::Sequence< sal_Int32 >& RGBAPal,
+ sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask,
+ sal_Int32 AlphaMask)
+ throw( uno::RuntimeException );
+ virtual void SAL_CALL setPixelsByBytes(
+ sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
+ const uno::Sequence< sal_Int8 >& ProducerData,
+ sal_Int32 Offset, sal_Int32 Scansize)
+ throw( uno::RuntimeException );
+ virtual void SAL_CALL setPixelsByLongs(
+ sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height,
+ const uno::Sequence< sal_Int32 >& ProducerData,
+ sal_Int32 Offset, sal_Int32 Scansize)
+ throw( uno::RuntimeException );
+ virtual void SAL_CALL complete(
+ sal_Int32 Status,
+ const Reference< awt::XImageProducer > & Producer)
+ throw( uno::RuntimeException );
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source );
+};
+
+SwHTMLImageWatcher::SwHTMLImageWatcher(
+ const Reference< drawing::XShape >& rShape,
+ sal_Bool bWidth, sal_Bool bHeight ) :
+ xShape( rShape ),
+ bSetWidth( bWidth ), bSetHeight( bHeight )
+{
+ // Die Quelle des Images merken
+ Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
+ Reference< awt::XControlModel > xControlModel(
+ xControlShape->getControl() );
+ xSrc = Reference< XImageProducerSupplier >( xControlModel, UNO_QUERY );
+ ASSERT( xSrc.is(), "Kein XImageProducerSupplier" );
+
+ // Als Event-Listener am Shape anmelden, damit wir es beim dispose
+ // loslassen k”nnen ...
+ Reference< XEventListener > xEvtLstnr = (XEventListener *)this;
+ Reference< XComponent > xComp( xShape, UNO_QUERY );
+ xComp->addEventListener( xEvtLstnr );
+
+ // Zum Schluss halten wir noch eine Referenz auf uns selbst, damit
+ // wir am Leben bleiben ... (eigentlich sollte das nicht neotig sein,
+ // weil wir ja noch an diversen anderen Stellen angemeldet sind)
+ xThis = (awt::XImageConsumer *)this;
+
+ // und am ImageProducer anmelden, um die Groesse zu erehalten ...
+ xSrc->getImageProducer()->addConsumer( xThis );
+}
+
+SwHTMLImageWatcher::~SwHTMLImageWatcher()
+{
+}
+
+void SwHTMLImageWatcher::clear()
+{
+ // Am Shape als Event-Listener abmelden
+ Reference< XEventListener > xEvtLstnr = (XEventListener *)this;
+ Reference< XComponent > xComp( xShape, UNO_QUERY );
+ xComp->removeEventListener( xEvtLstnr );
+
+ // Am ImageProducer abmelden
+ xSrc->getImageProducer()->removeConsumer( xThis );
+}
+
+//------------------------------------------------------------------------------
+
+void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height )
+ throw( uno::RuntimeException )
+{
+ ASSERT( bSetWidth || bSetHeight,
+ "Breite oder Hoehe muss angepasst werden" );
+
+ // Wenn keine Breite oder Hoehe angegeben ist, ist das das init von
+ // der leeren Grafik, die angezeigt wird, bevor der Stream einer
+ // asynchron anzuzeigenden Grfik verfuegbar ist.
+ if( !Width && !Height )
+ return;
+
+ awt::Size aNewSz;
+ aNewSz.Width = Width;
+ aNewSz.Height = Height;
+ if( Application::GetDefaultDevice() )
+ {
+ Size aTmp(aNewSz.Width, aNewSz.Height);
+ aTmp = Application::GetDefaultDevice()
+ ->PixelToLogic( aTmp, MapMode( MAP_100TH_MM ) );
+ aNewSz.Width = aTmp.Width();
+ aNewSz.Height = aTmp.Height();
+ }
+
+ if( !bSetWidth || !bSetHeight )
+ {
+ awt::Size aSz( xShape->getSize() );
+ if( bSetWidth && aNewSz.Height )
+ {
+ aNewSz.Width *= aSz.Height;
+ aNewSz.Width /= aNewSz.Height;
+ aNewSz.Height = aSz.Height;
+ }
+ if( bSetHeight && aNewSz.Width )
+ {
+ aNewSz.Height *= aSz.Width;
+ aNewSz.Height /= aNewSz.Width;
+ aNewSz.Width = aSz.Width;
+ }
+ }
+ if( aNewSz.Width < MINFLY )
+ aNewSz.Width = MINFLY;
+ if( aNewSz.Height < MINFLY )
+ aNewSz.Height = MINFLY;
+
+ xShape->setSize( aNewSz );
+ if( bSetWidth )
+ {
+ // Wenn das Control in einer Tabelle verankert ist, muesen
+ // die Tabellen-Spalten neu berechnet werden
+
+ // Um an den SwXShape* zu gelangen, brauchen wir ein Interface,
+ // das auch vom SwXShape implementiert wird.
+
+ Reference< beans::XPropertySet > xPropSet( xShape, UNO_QUERY );
+
+ Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
+ SwXShape *pSwShape = xTunnel.is()
+ ? (SwXShape *)xTunnel->getSomething(SwXShape::getUnoTunnelId())
+ : 0;
+
+ ASSERT( pSwShape, "Wo ist das SW-Shape?" );
+ if( pSwShape )
+ {
+ SwFrmFmt *pFrmFmt = pSwShape->GetFrmFmt();
+
+ const SwDoc *pDoc = pFrmFmt->GetDoc();
+ const SwPosition* pAPos = pFrmFmt->GetAnchor().GetCntntAnchor();
+ SwNode *pANd;
+ SwTableNode *pTblNd;
+ if( pAPos &&
+ 0 != (pANd = pDoc->GetNodes()[pAPos->nNode]) &&
+ 0 != (pTblNd = pANd->FindTableNode()) )
+ {
+ sal_Bool bLastGrf = !pTblNd->GetTable().DecGrfsThatResize();
+ SwHTMLTableLayout *pLayout =
+ pTblNd->GetTable().GetHTMLTableLayout();
+ if( pLayout )
+ {
+ sal_uInt16 nBrowseWidth =
+ pLayout->GetBrowseWidthByTable( *pDoc );
+
+ if( nBrowseWidth )
+ pLayout->Resize( nBrowseWidth, sal_True, sal_True,
+ bLastGrf ? HTMLTABLE_RESIZE_NOW
+ : 500 );
+ }
+ }
+ }
+ }
+
+ // uns selbst abmelden und loeschen
+ clear();
+ Reference< awt::XImageConsumer > xTmp = (awt::XImageConsumer*)this;
+ xThis = 0;
+}
+
+void SwHTMLImageWatcher::setColorModel(
+ sal_Int16, const Sequence< sal_Int32 >&, sal_Int32, sal_Int32,
+ sal_Int32, sal_Int32 )
+ throw( uno::RuntimeException )
+{
+}
+
+void SwHTMLImageWatcher::setPixelsByBytes(
+ sal_Int32, sal_Int32, sal_Int32, sal_Int32,
+ const Sequence< sal_Int8 >&, sal_Int32, sal_Int32 )
+ throw( uno::RuntimeException )
+{
+}
+
+
+void SwHTMLImageWatcher::setPixelsByLongs(
+ sal_Int32, sal_Int32, sal_Int32, sal_Int32,
+ const Sequence< sal_Int32 >&, sal_Int32, sal_Int32 )
+ throw( uno::RuntimeException )
+{
+}
+
+
+void SwHTMLImageWatcher::complete( sal_Int32 Status,
+ const Reference< awt::XImageProducer >& )
+ throw( uno::RuntimeException )
+{
+ if( IMAGEERROR == Status || IMAGEABORTED == Status )
+ {
+ // uns selbst abmelden und loeschen
+ clear();
+ Reference< awt::XImageConsumer > xTmp = (awt::XImageConsumer*)this;
+ xThis = 0;
+ }
+}
+
+void SwHTMLImageWatcher::disposing(const lang::EventObject& evt)
+{
+ Reference< awt::XImageConsumer > xTmp;
+
+ // Wenn das Shape verschwindet soll muessen wir es loslassen
+ Reference< drawing::XShape > xTmpShape;
+ if( evt.Source == xShape )
+ {
+ clear();
+ xTmp = (awt::XImageConsumer*)this;
+ xThis = 0;
+ }
+}
+
+void SwHTMLParser::DeleteFormImpl()
+{
+ delete pFormImpl;
+ pFormImpl = 0;
+}
+
+static void lcl_html_setFixedFontProperty(
+ const Reference< beans::XPropertySet >& rPropSet )
+{
+ Font aFixedFont( System::GetStandardFont( STDFONT_FIXED ) );
+
+ Any aTmp;
+ aTmp <<= OUString( aFixedFont.GetName() );
+ rPropSet->setPropertyValue( OUString::createFromAscii("FontName"), aTmp );
+
+ aTmp <<= OUString( aFixedFont.GetStyleName() );
+ rPropSet->setPropertyValue( OUString::createFromAscii("FontStyleName"),
+ aTmp );
+
+ aTmp <<= (sal_Int16) aFixedFont.GetFamily();
+ rPropSet->setPropertyValue( OUString::createFromAscii("FontFamily"), aTmp );
+
+ aTmp <<= (sal_Int16) aFixedFont.GetCharSet();
+ rPropSet->setPropertyValue( OUString::createFromAscii("FontCharset"),
+ aTmp );
+
+ aTmp <<= (sal_Int16) aFixedFont.GetPitch();
+ rPropSet->setPropertyValue( OUString::createFromAscii("FontPitch"), aTmp );
+
+ float fVal(10.);
+ aTmp.setValue( &fVal, ::getCppuType(&fVal ));
+ rPropSet->setPropertyValue( OUString::createFromAscii("FontHeight"), aTmp );
+}
+
+class SwHTMLFormPendingStackData_Impl: public SwPendingStackData
+{
+ Reference< drawing::XShape > xShape;
+ Size aTextSz;
+ sal_Bool bMinWidth;
+ sal_Bool bMinHeight;
+
+public:
+
+ SwHTMLFormPendingStackData_Impl(
+ const Reference< drawing::XShape > & rShape, const Size& rTextSz,
+ sal_Bool bMinW, sal_Bool bMinH ) :
+ xShape( rShape ),
+ aTextSz( rTextSz ),
+ bMinWidth( bMinW ),
+ bMinHeight( bMinH )
+ {}
+
+ const Reference< drawing::XShape >& GetShape() const { return xShape; }
+ const Size& GetTextSize() const { return aTextSz; }
+ sal_Bool IsMinWidth() const { return bMinWidth; }
+ sal_Bool IsMinHeight() const { return bMinHeight; }
+};
+
+void SwHTMLParser::SetPendingControlSize( int nToken )
+{
+ ASSERT( pPendStack, "Wo ist der Pending Stack?" );
+ SwHTMLFormPendingStackData_Impl *pData =
+ (SwHTMLFormPendingStackData_Impl *)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ ASSERT( !pPendStack, "Wo kommt der Pending-Stack her?" );
+
+ SetControlSize( pData->GetShape(), pData->GetTextSize(),
+ pData->IsMinWidth(), pData->IsMinHeight(),
+ nToken );
+ delete pData;
+}
+
+void SwHTMLParser::SetControlSize( const Reference< drawing::XShape >& rShape,
+ const Size& rTextSz,
+ sal_Bool bMinWidth,
+ sal_Bool bMinHeight,
+ int nToken )
+{
+ if( !rTextSz.Width() && !rTextSz.Height() && !bMinWidth && !bMinHeight )
+ return;
+
+ // Um an den SwXShape* zu gelangen, brauchen wir ein Interface,
+ // das auch vom SwXShape implementiert wird.
+ Reference< beans::XPropertySet > xPropSet( rShape, UNO_QUERY );
+
+ ViewShell *pVSh;
+ pDoc->GetEditShell( &pVSh );
+ if( !pVSh && !aLoadEnv.Is() )
+ {
+ // If there is no view shell by now and the doc shell is an internal
+ // one, no view shell will be created. That for, we have to do that of
+ // our own. This happens if a linked section is inserted or refreshed.
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( pDocSh && SFX_CREATE_MODE_INTERNAL == pDocSh->GetCreateMode() )
+ {
+ SFX_APP()->CreateViewFrame( *pDocSh, 0, sal_True );
+ CallStartAction();
+ pDoc->GetEditShell( &pVSh );
+ }
+ }
+ if( !pVSh )
+ {
+ // If there is no view shell by now, but the document is loaded
+ // asynchronous, the view shell will be created delayed because
+ // the view was locked during the call to DocumentDetected. If this
+ // is the case we wait until another call to our DataAvailable
+ // link, because the SFX calls it if it creates the view.
+ ASSERT( bDocInitalized, "DocumentDetected nocht nicht augerufen" );
+ ASSERT( !IsParserWorking() || bDataAvailableLinkSet,
+ "Keine ViewShell bei nicht gesetztem DataAvailable-Link" );
+ if( IsParserWorking() && bDocInitalized && bDataAvailableLinkSet )
+ {
+ pPendStack = new SwPendingStack( nToken, pPendStack );
+ pPendStack->pData =
+ new SwHTMLFormPendingStackData_Impl( rShape, rTextSz,
+ bMinWidth, bMinHeight );
+ SaveState( nToken );
+ eState = SVPAR_PENDING;
+ }
+
+ return;
+ }
+
+ Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
+ SwXShape *pSwShape = xTunnel.is()
+ ? (SwXShape *)xTunnel->getSomething(SwXShape::getUnoTunnelId())
+ : 0;
+
+ ASSERT( pSwShape, "Wo ist das SW-Shape?" );
+
+ // es muss ein Draw-Format sein
+ SwFrmFmt *pFrmFmt = pSwShape->GetFrmFmt();
+ ASSERT( RES_DRAWFRMFMT == pFrmFmt->Which(), "Kein DrawFrmFmt" );
+
+ // Schauen, ob es ein SdrObject dafuer gibt
+ const SdrObject *pObj = pFrmFmt->FindSdrObject();
+ ASSERT( pObj, "SdrObject nicht gefunden" );
+ ASSERT( FmFormInventor == pObj->GetObjInventor(), "falscher Inventor" );
+
+ SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pObj );
+ Reference< awt::XControl > xControl =
+ pFormObj->GetUnoControl( pVSh->GetWin() );
+
+ awt::Size aSz( rShape->getSize() );
+ awt::Size aNewSz( 0, 0 );
+ if( bMinWidth || bMinHeight )
+ {
+ Reference< awt::XLayoutConstrains > xLC( xControl, UNO_QUERY );
+ awt::Size aTmpSz( xLC->getPreferredSize() );
+ if( bMinWidth )
+ aNewSz.Width = aTmpSz.Width;
+ if( bMinHeight )
+ aNewSz.Height = aTmpSz.Height;
+ }
+ if( rTextSz.Width() || rTextSz.Height())
+ {
+ Reference< awt::XTextLayoutConstrains > xLC( xControl, UNO_QUERY );
+ ASSERT( xLC.is(), "kein XTextLayoutConstrains" );
+ if( xLC.is() )
+ {
+ awt::Size aTmpSz( rTextSz.Width(), rTextSz.Height() );
+ if( -1 == rTextSz.Width() )
+ {
+ aTmpSz.Width = 0;
+ aTmpSz.Height = nSelectEntryCnt;
+ }
+ aTmpSz = xLC->getMinimumSize( aTmpSz.Width, aTmpSz.Height );
+ if( rTextSz.Width() )
+ aNewSz.Width = aTmpSz.Width;
+ if( rTextSz.Height() )
+ aNewSz.Height = aTmpSz.Height;
+ }
+ }
+
+ if( Application::GetDefaultDevice() )
+ {
+ Size aTmpSz( aNewSz.Width, aNewSz.Height );
+ aTmpSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aTmpSz, MapMode( MAP_100TH_MM ) );
+ aNewSz.Width = aTmpSz.Width();
+ aNewSz.Height = aTmpSz.Height();
+ }
+ if( aNewSz.Width )
+ {
+ if( aNewSz.Width < MINLAY )
+ aNewSz.Width = MINLAY;
+ aSz.Width = aNewSz.Width;
+ }
+ if( aNewSz.Height )
+ {
+ if( aNewSz.Height < MINLAY )
+ aNewSz.Height = MINLAY;
+ aSz.Height = aNewSz.Height;
+ }
+
+ rShape->setSize( aSz );
+}
+
+static void lcl_html_setEvents(
+ const Reference< script::XEventAttacherManager > & rEvtMn,
+ sal_uInt32 nPos, const SvxMacroTableDtor& rMacroTbl,
+ const SvStringsDtor& rUnoMacroTbl,
+ const SvStringsDtor& rUnoMacroParamTbl,
+ const String& rType )
+{
+ // Erstmal muss die Anzahl der Events ermittelt werden ...
+ sal_Int32 nEvents = 0;
+ for( sal_uInt16 i=0; HTML_ET_END != aEventTypeTable[i]; i++ )
+ {
+ const SvxMacro *pMacro = rMacroTbl.Get( aEventTypeTable[i] );
+ // Solange nicht alle Events implementiert sind, enthaelt die
+ // Tabelle auch Leerstrings!
+ if( pMacro && aEventListenerTable[i] )
+ nEvents++;
+ }
+ for( i=0; i< rUnoMacroTbl.Count(); i++ )
+ {
+ const String& rStr = *rUnoMacroTbl[i];
+ xub_StrLen nPos = 0;
+ if( !rStr.GetToken( 0, '-', nPos ).Len() || STRING_NOTFOUND == nPos )
+ continue;
+ if( !rStr.GetToken( 0, '-', nPos ).Len() || STRING_NOTFOUND == nPos )
+ continue;
+ if( nPos < rStr.Len() )
+ nEvents++;
+ }
+
+ if( 0==nEvents )
+ return;
+
+ Sequence<script::ScriptEventDescriptor> aDescs( nEvents );
+ script::ScriptEventDescriptor* pDescs = aDescs.getArray();
+ sal_Int32 nEvent = 0;
+
+ for( i=0; HTML_ET_END != aEventTypeTable[i]; i++ )
+ {
+ const SvxMacro *pMacro = rMacroTbl.Get( aEventTypeTable[i] );
+ if( pMacro && aEventListenerTable[i] )
+ {
+ script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
+ rDesc.ListenerType =
+ OUString::createFromAscii(aEventListenerTable[i]);
+ rDesc.EventMethod = OUString::createFromAscii(aEventMethodTable[i]);
+ rDesc.ScriptType = pMacro->GetLanguage();
+ rDesc.ScriptCode = pMacro->GetMacName();
+ }
+ }
+
+ for( i=0; i< rUnoMacroTbl.Count(); i++ )
+ {
+ const String& rStr = *rUnoMacroTbl[i];
+ xub_StrLen nPos = 0;
+ String sListener( rStr.GetToken( 0, '-', nPos ) );
+ if( !sListener.Len() || STRING_NOTFOUND == nPos )
+ continue;
+
+ String sMethod( rStr.GetToken( 0, '-', nPos ) );
+ if( !sMethod.Len() || STRING_NOTFOUND == nPos )
+ continue;
+
+ String sCode( rStr.Copy( nPos ) );
+ if( !sCode.Len() )
+ continue;
+
+ script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
+ rDesc.ListenerType = sListener;
+ rDesc.EventMethod = sMethod;
+ rDesc.ScriptType = rType;
+ rDesc.ScriptCode = sCode;
+ rDesc.AddListenerParam = OUString();
+
+ if( rUnoMacroParamTbl.Count() )
+ {
+ String sSearch( sListener );
+ sSearch += '-';
+ sSearch += sMethod;
+ sSearch += '-';
+ xub_StrLen nLen = sSearch.Len();
+ for( sal_uInt16 j=0; j < rUnoMacroParamTbl.Count(); j++ )
+ {
+ const String& rParam = *rUnoMacroParamTbl[j];
+ if( rParam.CompareTo( sSearch, nLen ) == COMPARE_EQUAL &&
+ rParam.Len() > nLen )
+ {
+ rDesc.AddListenerParam = rParam.Copy(nLen);
+ break;
+ }
+ }
+ }
+ }
+ rEvtMn->registerScriptEvents( nPos, aDescs );
+}
+
+static void lcl_html_getEvents( const String& rOption, const String& rValue,
+ SvStringsDtor& rUnoMacroTbl,
+ SvStringsDtor& rUnoMacroParamTbl )
+{
+ if( rOption.CompareIgnoreCaseToAscii( sHTML_O_sdevent,
+ sizeof(sHTML_O_sdevent)-1 ) == COMPARE_EQUAL )
+ {
+ String *pEvent = new String( rOption.Copy(sizeof(sHTML_O_sdevent)-1) );
+ *pEvent += '-';
+ *pEvent += rValue;
+ rUnoMacroTbl.Insert( pEvent, rUnoMacroTbl.Count() );
+ }
+ else if( rOption.CompareIgnoreCaseToAscii( sHTML_O_sdaddparam,
+ sizeof(sHTML_O_sdaddparam)-1 ) == COMPARE_EQUAL )
+ {
+ String *pParam =
+ new String( rOption.Copy( sizeof(sHTML_O_sdaddparam)-1 ) );
+ *pParam += '-';
+ *pParam += rValue;
+ rUnoMacroParamTbl.Insert( pParam, rUnoMacroParamTbl.Count() );
+ }
+}
+
+Reference< drawing::XShape > SwHTMLParser::InsertControl(
+ const Reference< XFormComponent > & rFComp,
+ const Reference< beans::XPropertySet > & rFCompPropSet,
+ const Size& rSize, SwVertOrient eVertOri, SwHoriOrient eHoriOri,
+ SfxItemSet& rCSS1ItemSet, SvxCSS1PropertyInfo& rCSS1PropInfo,
+ const SvxMacroTableDtor& rMacroTbl, const SvStringsDtor& rUnoMacroTbl,
+ const SvStringsDtor& rUnoMacroParamTbl, sal_Bool bSetFCompPropSet,
+ sal_Bool bHidden )
+{
+ Reference< drawing::XShape > xShape;
+
+ const Reference< container::XIndexContainer > & rFormComps =
+ pFormImpl->GetFormComps();
+ Any aAny( &rFComp, ::getCppuType( (Reference< XFormComponent>*)0 ) );
+ rFormComps->insertByIndex( rFormComps->getCount(), aAny );
+
+ if( !bHidden )
+ {
+ Any aTmp;
+ sal_uInt16 nLeftSpace = 0, nRightSpace = 0,
+ nUpperSpace = 0, nLowerSpace = 0;
+
+ const Reference< XMultiServiceFactory > & rServiceFactory =
+ pFormImpl->GetServiceFactory();
+ if( !rServiceFactory.is() )
+ return xShape;
+
+ Reference< XInterface > xCreate =
+ rServiceFactory ->createInstance(
+ OUString::createFromAscii("com.sun.star.drawing.ControlShape"));
+ if( !xCreate.is() )
+ return xShape;
+
+ xShape = Reference< drawing::XShape >( xCreate, UNO_QUERY );
+
+ DBG_ASSERT( xShape.is(), "XShape nicht erhalten" );
+ awt::Size aTmpSz;
+ aTmpSz.Width = rSize.Width();
+ aTmpSz.Height = rSize.Height();
+ xShape->setSize( aTmpSz );
+
+ Reference< beans::XPropertySet > xShapePropSet( xCreate, UNO_QUERY );
+
+ // linken/rechten Rand setzen
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, sal_True,
+ &pItem ) )
+ {
+ // Ggf. den Erstzeilen-Einzug noch plaetten
+ const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
+ SvxLRSpaceItem aLRItem( *pLRItem );
+ aLRItem.SetTxtFirstLineOfst( 0 );
+ if( rCSS1PropInfo.bLeftMargin )
+ {
+ nLeftSpace = TWIP_TO_MM100( aLRItem.GetLeft() );
+ rCSS1PropInfo.bLeftMargin = sal_False;
+ }
+ if( rCSS1PropInfo.bRightMargin )
+ {
+ nRightSpace = TWIP_TO_MM100( aLRItem.GetRight() );
+ rCSS1PropInfo.bRightMargin = sal_False;
+ }
+ rCSS1ItemSet.ClearItem( RES_LR_SPACE );
+ }
+ if( nLeftSpace || nRightSpace )
+ {
+ Any aTmp;
+ aTmp <<= (sal_Int32)nLeftSpace;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "LeftMargin" ), aTmp );
+
+ aTmp <<= (sal_Int32)nRightSpace;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "RightMargin" ), aTmp );
+ }
+
+ // oberen/unteren Rand setzen
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, sal_True,
+ &pItem ) )
+ {
+ // Ggf. den Erstzeilen-Einzug noch plaetten
+ const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
+ if( rCSS1PropInfo.bTopMargin )
+ {
+ nUpperSpace = TWIP_TO_MM100( pULItem->GetUpper() );
+ rCSS1PropInfo.bTopMargin = sal_False;
+ }
+ if( rCSS1PropInfo.bBottomMargin )
+ {
+ nLowerSpace = TWIP_TO_MM100( pULItem->GetLower() );
+ rCSS1PropInfo.bBottomMargin = sal_False;
+ }
+
+ rCSS1ItemSet.ClearItem( RES_UL_SPACE );
+ }
+ if( nUpperSpace || nLowerSpace )
+ {
+ uno::Any aTmp;
+ aTmp <<= (sal_Int32)nUpperSpace;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "TopMargin" ), aTmp );
+
+ aTmp <<= (sal_Int32)nLowerSpace;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "BottomMargin" ), aTmp );
+ }
+
+ Reference< beans::XPropertySetInfo > xPropSetInfo =
+ rFCompPropSet->getPropertySetInfo();
+ OUString sPropName = OUString::createFromAscii( "BackgroundColor" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_BACKGROUND, sal_True,
+ &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ const Color &rColor = ((const SvxBrushItem *)pItem)->GetColor();
+ if( !rColor.GetTransparency() )
+ {
+ aTmp <<= (sal_Int32)rColor.GetRGBColor();
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ }
+
+ sPropName = OUString::createFromAscii( "TextColor" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_COLOR, sal_True,
+ &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int32)((const SvxColorItem *)pItem)->GetValue()
+ .GetRGBColor();
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ sPropName = OUString::createFromAscii( "FontHeight" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONTSIZE,
+ sal_True, &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ float fVal =
+ ((float)((SvxFontHeightItem *)pItem)->GetHeight()) / 20.;
+ aTmp.setValue( &fVal, ::getCppuType(&fVal));
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_FONT, sal_True,
+ &pItem ) )
+ {
+ const SvxFontItem *pFontItem = (SvxFontItem *)pItem;
+ sPropName = OUString::createFromAscii( "FontName" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= OUString( pFontItem->GetFamilyName() );
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+ sPropName = OUString::createFromAscii( "FontStyleName" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= OUString( pFontItem->GetStyleName() );
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+ sPropName = OUString::createFromAscii( "FontFamily" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int16)pFontItem->GetFamily() ;
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+ sPropName = OUString::createFromAscii( "FontCharset" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int16)pFontItem->GetCharSet() ;
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+ sPropName = OUString::createFromAscii( "FontPitch" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int16)pFontItem->GetPitch() ;
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+ }
+
+ sPropName = OUString::createFromAscii( "FontWeight" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_WEIGHT,
+ sal_True, &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ float fVal = VCLUnoHelper::ConvertFontWeight(
+ ((SvxWeightItem *)pItem)->GetWeight() );
+ aTmp.setValue( &fVal, ::getCppuType(&fVal));
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ sPropName = OUString::createFromAscii( "FontSlant" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_POSTURE,
+ sal_True, &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int16)((SvxPostureItem *)pItem)->GetPosture();
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ sPropName = OUString::createFromAscii( "FontUnderline" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_UNDERLINE,
+ sal_True, &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int16)((SvxUnderlineItem *)pItem)->GetUnderline();
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ sPropName = OUString::createFromAscii( "FontStrikeout" );
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_CHRATR_CROSSEDOUT,
+ sal_True, &pItem ) &&
+ xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp <<= (sal_Int16)((SvxCrossedOutItem *)pItem)->GetStrikeout();
+ rFCompPropSet->setPropertyValue( sPropName, aTmp );
+ }
+
+ Reference< text::XTextRange > xTxtRg;
+ sal_Int16 nAnchorType = text::TextContentAnchorType_AS_CHARACTER;
+ sal_Int16 nSurround;
+ sal_Bool bSetPos = sal_False, bSetSurround = sal_False;
+ sal_Int32 nXPos, nYPos;
+ if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition &&
+ SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType &&
+ SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType )
+ {
+ const SwStartNode *pFlySttNd =
+ pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode();
+
+ if( pFlySttNd )
+ {
+ nAnchorType = text::TextContentAnchorType_AT_FRAME;
+ SwPaM aPaM( *pFlySttNd );
+
+ Reference< text::XText > xDummyTxtRef; // unsauber, aber laut OS geht das ...
+ xTxtRg = new SwXTextRange( aPaM, xDummyTxtRef );
+ }
+ else
+ {
+ nAnchorType = text::TextContentAnchorType_AT_PAGE;
+ }
+ nXPos = TWIP_TO_MM100( rCSS1PropInfo.nLeft ) + nLeftSpace;
+ nYPos = TWIP_TO_MM100( rCSS1PropInfo.nTop ) + nUpperSpace;
+ bSetPos = sal_True;
+
+ nSurround = text::WrapTextMode_THROUGHT;
+ bSetSurround = sal_True;
+ }
+ else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat ||
+ HORI_LEFT == eHoriOri )
+ {
+ nAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
+ nXPos = nLeftSpace;
+ nYPos = nUpperSpace;
+ bSetPos = sal_True;
+ nSurround = text::WrapTextMode_RIGHT;
+ bSetSurround = sal_True;
+ }
+ else if( VERT_NONE != eVertOri )
+ {
+ sal_Int16 nVertOri;
+ switch( eVertOri )
+ {
+ case VERT_NONE:
+ nVertOri = text::VertOrientation::NONE;
+ break;
+ case VERT_TOP:
+ nVertOri = text::VertOrientation::TOP;
+ break;
+ case VERT_CENTER:
+ nVertOri = text::VertOrientation::CENTER;
+ break;
+ case VERT_BOTTOM:
+ nVertOri = text::VertOrientation::BOTTOM;
+ break;
+ case VERT_CHAR_TOP:
+ nVertOri = text::VertOrientation::CHAR_TOP;
+ break;
+ case VERT_CHAR_CENTER:
+ nVertOri = text::VertOrientation::CHAR_CENTER;
+ break;
+ case VERT_CHAR_BOTTOM:
+ nVertOri = text::VertOrientation::CHAR_BOTTOM;
+ break;
+ case VERT_LINE_TOP:
+ nVertOri = text::VertOrientation::LINE_TOP;
+ break;
+ case VERT_LINE_CENTER:
+ nVertOri = text::VertOrientation::LINE_CENTER;
+ break;
+ case VERT_LINE_BOTTOM:
+ nVertOri = text::VertOrientation::LINE_BOTTOM;
+ break;
+ }
+ aTmp <<= (sal_Int16)nVertOri ;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "VertOrient" ), aTmp );
+ }
+
+ aTmp <<= (sal_Int16)nAnchorType ;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "AnchorType" ), aTmp );
+
+ if( text::TextContentAnchorType_AT_PAGE == nAnchorType )
+ {
+ aTmp <<= (sal_Int16) 1 ;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "AnchorPageNo" ), aTmp );
+ }
+ else
+ {
+ if( !xTxtRg.is() )
+ {
+ Reference< text::XText > xDummyTxtRef; // unsauber, aber laut OS geht das ...
+ xTxtRg = new SwXTextRange( *pPam, xDummyTxtRef );
+ }
+
+ aTmp.setValue( &xTxtRg,
+ ::getCppuType((Reference< text::XTextRange>*)0));
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "TextRange" ), aTmp );
+ }
+
+ if( bSetPos )
+ {
+ aTmp <<= (sal_Int16)text::HoriOrientation::NONE;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "HoriOrient" ), aTmp );
+ aTmp <<= (sal_Int32)nXPos ;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "HoriOrientPosition" ), aTmp );
+
+ aTmp <<= (sal_Int16)text::VertOrientation::NONE;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "VertOrient" ), aTmp );
+ aTmp <<= (sal_Int32)nYPos ;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "VertOrientPosition" ), aTmp );
+ }
+ if( bSetSurround )
+ {
+ aTmp <<= (sal_Int16)nSurround ;
+ xShapePropSet->setPropertyValue(
+ OUString::createFromAscii( "Surround" ), aTmp );
+ }
+
+ pFormImpl->GetShapes()->add(xShape);
+
+ // Das Control-Model am Control-Shape setzen
+ Reference< drawing::XControlShape > xControlShape( xShape, UNO_QUERY );
+ Reference< awt::XControlModel > xControlModel( rFComp, UNO_QUERY );
+ xControlShape->setControl( xControlModel );
+ }
+
+ // Da beim Einfuegen der Controls der Fokus gesetzt wird, werden
+ // auch schon Fokus-Events verschickt. Damit die nicht evtl. schon
+ // vorhendene JavaSCript-Eents rufen, werden die Events nachtraeglich
+ // gesetzt.
+ if( rMacroTbl.Count() || rUnoMacroTbl.Count() )
+ {
+ lcl_html_setEvents( pFormImpl->GetControlEventManager(),
+ rFormComps->getCount() - 1,
+ rMacroTbl, rUnoMacroTbl, rUnoMacroParamTbl,
+ GetScriptTypeString(pFormImpl->GetHeaderAttrs()) );
+ }
+
+ if( bSetFCompPropSet )
+ {
+ pFormImpl->SetFCompPropSet( rFCompPropSet );
+ }
+
+ return xShape;
+}
+
+void SwHTMLParser::NewForm( sal_Bool bAppend )
+{
+ // Gibt es schon eine Form?
+ if( pFormImpl && pFormImpl->GetFormComps().is() )
+ return;
+
+ if( bAppend )
+ {
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SPACE );
+ else
+ AddParSpace();
+ }
+
+ if( !pFormImpl )
+ pFormImpl = new SwHTMLForm_Impl( pDoc->GetDocShell() );
+
+ String aAction( sBaseURL );
+ String sName, sTarget;
+ sal_uInt16 nEncType = FormSubmitEncoding_URL;
+ sal_uInt16 nMethod = FormSubmitMethod_GET;
+ SvxMacroTableDtor aMacroTbl;
+ SvStringsDtor aUnoMacroTbl;
+ SvStringsDtor aUnoMacroParamTbl;
+ SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
+ ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
+ const String& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ ScriptType eScriptType = eDfltScriptType;
+ sal_uInt16 nEvent;
+ sal_Bool bSetEvent = sal_False;
+
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ACTION:
+ aAction = pOption->GetString();
+ break;
+ case HTML_O_METHOD:
+ nMethod = pOption->GetEnum( aHTMLFormMethodTable, nMethod );
+ break;
+ case HTML_O_ENCTYPE:
+ nEncType = pOption->GetEnum( aHTMLFormEncTypeTable, nEncType );
+ break;
+ case HTML_O_TARGET:
+ sTarget = pOption->GetString();
+ break;
+ case HTML_O_NAME:
+ sName = pOption->GetString();
+ break;
+
+ case HTML_O_SDONSUBMIT:
+ eScriptType = STARBASIC;
+ case HTML_O_ONSUBMIT:
+ nEvent = HTML_ET_ONSUBMITFORM;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONRESET:
+ eScriptType = STARBASIC;
+ case HTML_O_ONRESET:
+ nEvent = HTML_ET_ONRESETFORM;
+ bSetEvent = sal_True;
+ break;
+
+ default:
+ lcl_html_getEvents( pOption->GetTokenString(),
+ pOption->GetString(),
+ aUnoMacroTbl, aUnoMacroParamTbl );
+ break;
+ }
+
+ if( bSetEvent )
+ {
+ String sEvent( pOption->GetString() );
+ if( sEvent.Len() )
+ {
+ sEvent.ConvertLineEnd();
+ String aScriptType;
+ if( EXTENDED_STYPE==eScriptType )
+ aScriptType = rDfltScriptType;
+ aMacroTbl.Insert( nEvent, new SvxMacro( sEvent, aScriptType,
+ eScriptType ) );
+ }
+ }
+ }
+
+ const Reference< XMultiServiceFactory > & rSrvcMgr =
+ pFormImpl->GetServiceFactory();
+ if( !rSrvcMgr.is() )
+ return;
+
+ Reference< XInterface > xInt = rSrvcMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.form.component.Form" ) );
+ if( !xInt.is() )
+ return;
+
+ Reference< XForm > xForm( xInt, UNO_QUERY );
+ DBG_ASSERT( xForm.is(), "keine Form?" );
+
+ Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
+ pFormImpl->SetFormComps( xFormComps );
+
+ Reference< beans::XPropertySet > xFormPropSet( xForm, UNO_QUERY );
+
+ Any aTmp;
+ aTmp <<= OUString(sName);
+ xFormPropSet->setPropertyValue( OUString::createFromAscii( "Name" ), aTmp );
+
+ if( aAction.Len() )
+ {
+ aAction = INetURLObject::RelToAbs(aAction);
+ }
+ else
+ {
+ // Bei leerer URL das Directory nehmen
+ INetURLObject aURLObj( aPathToFile );
+ aAction = aURLObj.GetPartBeforeLastName();
+ }
+ aTmp <<= OUString(aAction);
+ xFormPropSet->setPropertyValue( OUString::createFromAscii( "TargetURL" ),
+ aTmp );
+
+ FormSubmitMethod eMethod = (FormSubmitMethod)nMethod;
+ aTmp.setValue( &eMethod, ::getCppuType((const FormSubmitMethod*)0) );
+ xFormPropSet->setPropertyValue( OUString::createFromAscii( "SubmitMethod" ),
+ aTmp );
+
+ FormSubmitEncoding eEncType = (FormSubmitEncoding)nEncType;
+ aTmp.setValue( &eEncType, ::getCppuType((const FormSubmitEncoding*)0) );
+ xFormPropSet->setPropertyValue(
+ OUString::createFromAscii( "SubmitEncoding" ), aTmp );
+
+ if( sTarget.Len() )
+ {
+ aTmp <<= OUString(sTarget);
+ xFormPropSet->setPropertyValue(
+ OUString::createFromAscii( "TargetFrame" ), aTmp );
+ }
+
+ const Reference< container::XIndexContainer > & rForms =
+ pFormImpl->GetForms();
+ Any aAny( &xForm, ::getCppuType((Reference< XForm>*)0) );
+ rForms->insertByIndex( rForms->getCount(), aAny );
+ if( aMacroTbl.Count() )
+ lcl_html_setEvents( pFormImpl->GetFormEventManager(),
+ rForms->getCount() - 1,
+ aMacroTbl, aUnoMacroTbl, aUnoMacroParamTbl,
+ rDfltScriptType );
+}
+
+void SwHTMLParser::EndForm( sal_Bool bAppend )
+{
+ if( pFormImpl && pFormImpl->GetFormComps().is() )
+ {
+ if( bAppend )
+ {
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SPACE );
+ else
+ AddParSpace();
+ }
+
+ pFormImpl->ReleaseFormComps();
+ }
+}
+
+void SwHTMLParser::InsertInput()
+{
+ if( pPendStack )
+ {
+ SetPendingControlSize( HTML_INPUT );
+ return;
+ }
+
+ if( !pFormImpl || !pFormImpl->GetFormComps().is() )
+ return;
+
+ String sImgSrc, aId, aClass, aStyle, sText;
+ String sName;
+ SvxMacroTableDtor aMacroTbl;
+ SvStringsDtor aUnoMacroTbl;
+ SvStringsDtor aUnoMacroParamTbl;
+ sal_uInt16 nSize = 0;
+ sal_Int16 nMaxLen = 0;
+ sal_Int16 nChecked = STATE_NOCHECK;
+ sal_Int32 nTabIndex = TABINDEX_MAX + 1;
+ HTMLInputType eType = HTML_IT_TEXT;
+ sal_Bool bDisabled = sal_False, bValue = sal_False;
+ sal_Bool bSetGrfWidth = sal_False, bSetGrfHeight = sal_False;
+ sal_Bool bHidden = sal_False;
+ long nWidth=0, nHeight=0;
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
+ SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
+ ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
+ const String& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
+
+ sal_uInt16 nKeepCRLFToken = HTML_O_VALUE;
+ const HTMLOptions *pOptions = GetOptions( &nKeepCRLFToken );
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ ScriptType eScriptType = eDfltScriptType;
+ sal_uInt16 nEvent;
+ sal_Bool bSetEvent = sal_False;
+
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_TYPE:
+ eType = pOption->GetInputType();
+ break;
+ case HTML_O_NAME:
+ sName = pOption->GetString();
+ break;
+ case HTML_O_VALUE:
+ sText = pOption->GetString();
+ bValue = sal_True;
+ break;
+ case HTML_O_CHECKED:
+ nChecked = STATE_CHECK;
+ break;
+ case HTML_O_DISABLED:
+ bDisabled = sal_True;
+ break;
+ case HTML_O_MAXLENGTH:
+ nMaxLen = (sal_Int16)pOption->GetNumber();
+ break;
+ case HTML_O_SIZE:
+ nSize = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_SRC:
+ sImgSrc = pOption->GetString();
+ break;
+ case HTML_O_WIDTH:
+ // erstmal nur als Pixelwerte merken!
+ nWidth = pOption->GetNumber();
+ break;
+ case HTML_O_HEIGHT:
+ // erstmal nur als Pixelwerte merken!
+ nHeight = pOption->GetNumber();
+ break;
+ case HTML_O_ALIGN:
+ eVertOri =
+ (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable,
+ eVertOri );
+ eHoriOri =
+ (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable,
+ eHoriOri );
+ break;
+ case HTML_O_TABINDEX:
+ // erstmal nur als Pixelwerte merken!
+ nTabIndex = pOption->GetNumber();
+ break;
+
+ case HTML_O_SDONFOCUS:
+ eScriptType = STARBASIC;
+ case HTML_O_ONFOCUS:
+ nEvent = HTML_ET_ONGETFOCUS;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONBLUR: // eigtl. nur EDIT
+ eScriptType = STARBASIC;
+ case HTML_O_ONBLUR:
+ nEvent = HTML_ET_ONLOSEFOCUS;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONCLICK:
+ eScriptType = STARBASIC;
+ case HTML_O_ONCLICK:
+ nEvent = HTML_ET_ONCLICK;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONCHANGE: // eigtl. nur EDIT
+ eScriptType = STARBASIC;
+ case HTML_O_ONCHANGE:
+ nEvent = HTML_ET_ONCHANGE;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONSELECT: // eigtl. nur EDIT
+ eScriptType = STARBASIC;
+ case HTML_O_ONSELECT:
+ nEvent = HTML_ET_ONSELECT;
+ bSetEvent = sal_True;
+ break;
+
+ default:
+ lcl_html_getEvents( pOption->GetTokenString(),
+ pOption->GetString(),
+ aUnoMacroTbl, aUnoMacroParamTbl );
+ break;
+ }
+
+ if( bSetEvent )
+ {
+ String sEvent( pOption->GetString() );
+ if( sEvent.Len() )
+ {
+ sEvent.ConvertLineEnd();
+ String aScriptType;
+ if( EXTENDED_STYPE==eScriptType )
+ aScriptType = rDfltScriptType;
+ aMacroTbl.Insert( nEvent, new SvxMacro( sEvent, aScriptType,
+ eScriptType ) );
+ }
+ }
+ }
+
+ if( HTML_IT_IMAGE==eType )
+ {
+ // Image-Controls ohne Image-URL werden ignoriert (wie bei MS)
+ if( !sImgSrc.Len() )
+ return;
+ }
+#if 0
+ else if( HTML_IT_HIDDEN!=eType )
+ {
+ // Obwohl Netscape und MS-IE nur Iamge-Buttons ausrichten koennen,
+ // werten wir ALIGN fuer alle Controls aus.
+ if( VERT_NONE == eVertOri )
+ eVertOri = VERT_TOP;
+ }
+#else
+ else
+ {
+ // ALIGN fuer alle Controls auszuwerten ist keine so gute Idee,
+ // solange Absatz-gebundene Controls die Hoehe von Tabellen-Zellen
+ // nicht beeinflussen
+ // (#64110#, http://www.telekom.de/katalog-online/onlineshop.html)
+ eVertOri = VERT_TOP;
+ eHoriOri = HORI_NONE;
+ }
+#endif
+
+ // Defaults entsprechen HTML_IT_TEXT
+ const sal_Char *pType = "TextField";
+ sal_Bool bKeepCRLFInValue = sal_False;
+ switch( eType )
+ {
+ case HTML_IT_CHECKBOX:
+ pType = "CheckBox";
+ bKeepCRLFInValue = sal_True;
+ break;
+
+ case HTML_IT_RADIO:
+ pType = "RadioButton";
+ bKeepCRLFInValue = sal_True;
+ break;
+
+ case HTML_IT_PASSWORD:
+ bKeepCRLFInValue = sal_True;
+ break;
+
+ case HTML_IT_BUTTON:
+ bKeepCRLFInValue = sal_True;
+ case HTML_IT_SUBMIT:
+ case HTML_IT_RESET:
+ pType = "CommandButton";
+ break;
+
+ case HTML_IT_IMAGE:
+ pType = "ImageButton";
+ break;
+
+ case HTML_IT_FILE:
+ pType = "FileControl";
+ break;
+
+ case HTML_IT_HIDDEN:
+ pType = "HiddenControl";
+ bKeepCRLFInValue = sal_True;
+ break;
+ }
+
+ // Fuer ein par Controls mussen CR/LF noch aus dem VALUE
+ // geloescht werden.
+ if( !bKeepCRLFInValue )
+ {
+ sText.EraseAllChars( _CR );
+ sText.EraseAllChars( _LF );
+ }
+
+ const Reference< XMultiServiceFactory > & rServiceFactory =
+ pFormImpl->GetServiceFactory();
+ if( !rServiceFactory.is() )
+ return;
+
+ String sServiceName(
+ OUString::createFromAscii("com.sun.star.form.component.") );
+ sServiceName.AppendAscii( pType );
+ Reference< XInterface > xInt =
+ rServiceFactory->createInstance( sServiceName );
+ if( !xInt.is() )
+ return;
+
+ Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
+ if( !xFComp.is() )
+ return;
+
+ Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
+
+ Any aTmp;
+ aTmp <<= OUString(sName);
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Name" ), aTmp );
+
+ if( HTML_IT_HIDDEN != eType )
+ {
+ if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
+ {
+ aTmp <<= (sal_Int16) (sal_Int16)nTabIndex ;
+ xPropSet->setPropertyValue( OUString::createFromAscii( "TabIndex" ), aTmp );
+ }
+
+ if( bDisabled )
+ {
+ BOOL bFalse = sal_False;
+ aTmp.setValue(&bFalse, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Enabled" ), aTmp );
+ }
+ }
+
+ aTmp <<= OUString(sText);
+
+ Size aSz( 0, 0 ); // defaults
+ Size aTextSz( 0, 0 ); // Text-Size
+ sal_Bool bMinWidth = sal_False, bMinHeight = sal_False;
+ sal_Bool bUseSize = sal_False;
+ switch( eType )
+ {
+ case HTML_IT_CHECKBOX:
+ case HTML_IT_RADIO:
+ {
+ if( !bValue )
+ aTmp <<= OUString::createFromAscii( sHTML_on );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "RefValue" ),
+ aTmp );
+ aTmp <<= OUString();
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Label" ),
+ aTmp );
+ // #53559#: Beim RadioButton darf die DefaultChecked-Property
+ // erst gesetzt werden, wenn das Control angelegt und ein
+ // activateTabOrder gerufen wurde, weil es sonst noch zu der
+ // vorhergehenden Gruppe gehoert.
+ if( HTML_IT_CHECKBOX == eType )
+ {
+ aTmp <<= (sal_Int16) nChecked ;
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "DefaultState" ), aTmp );
+ }
+
+ SvxMacro *pMacro = aMacroTbl.Get( HTML_ET_ONCLICK );
+ if( pMacro )
+ {
+ aMacroTbl.Remove( HTML_ET_ONCLICK );
+ aMacroTbl.Insert( HTML_ET_ONCLICK_ITEM, pMacro );
+ }
+ // SIZE auszuwerten duerfte hier keinen Sinn machen???
+ bMinWidth = bMinHeight = sal_True;
+ }
+ break;
+
+ case HTML_IT_IMAGE:
+ {
+ // SIZE = WIDTH
+ aSz.Width() = nSize ? nSize : nWidth;
+ aSz.Width() = nWidth;
+ aSz.Height() = nHeight;
+ if( (aSz.Width() || aSz.Height()) && Application::GetDefaultDevice() )
+ {
+ aSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aSz, MapMode( MAP_100TH_MM ) );
+ }
+ FormButtonType eButtonType = FormButtonType_SUBMIT;
+ aTmp.setValue( &eButtonType,
+ ::getCppuType((const FormButtonType*)0));
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "ButtonType" ), aTmp );
+
+ aTmp <<= (sal_Int16) 0 ;
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Border" ),
+ aTmp );
+ }
+ break;
+
+ case HTML_IT_BUTTON:
+ case HTML_IT_SUBMIT:
+ case HTML_IT_RESET:
+ {
+ FormButtonType eButtonType;
+ switch( eType )
+ {
+ case HTML_IT_BUTTON:
+ eButtonType = FormButtonType_PUSH;
+ break;
+ case HTML_IT_SUBMIT:
+ eButtonType = FormButtonType_SUBMIT;
+ if( !sText.Len() )
+ sText.AssignAscii( sHTML_IT_submit );
+ break;
+ case HTML_IT_RESET:
+ eButtonType = FormButtonType_RESET;
+ if( !sText.Len() )
+ sText.AssignAscii( sHTML_IT_reset );
+ break;
+ }
+ aTmp <<= OUString(sText);
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Label" ),
+ aTmp );
+
+ aTmp.setValue( &eButtonType,
+ ::getCppuType((const FormButtonType*)0));
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "ButtonType" ), aTmp );
+
+ bMinWidth = bMinHeight = sal_True;
+ bUseSize = sal_True;
+ }
+ break;
+
+ case HTML_IT_PASSWORD:
+ case HTML_IT_TEXT:
+ case HTML_IT_FILE:
+ if( HTML_IT_FILE != eType )
+ {
+ // Beim File-Control wird der VALUE aus Sicherheitsgruenden ignoriert.
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "DefaultText" ), aTmp );
+ if( nMaxLen != 0 )
+ {
+ aTmp <<= (sal_Int16) nMaxLen ;
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "MaxTextLen" ), aTmp );
+ }
+ }
+
+ if( HTML_IT_PASSWORD == eType )
+ {
+ aTmp <<= (sal_Int16)'*' ;
+ xPropSet->setPropertyValue( OUString::createFromAscii( "EchoChar" ),
+ aTmp );
+ }
+
+ lcl_html_setFixedFontProperty( xPropSet );
+
+ if( !nSize )
+ nSize = 20;
+ aTextSz.Width() = nSize;
+ bMinHeight = sal_True;
+ break;
+
+ case HTML_IT_HIDDEN:
+ xPropSet->setPropertyValue( OUString::createFromAscii( "HiddenValue" ),
+ aTmp );
+ bHidden = sal_True;
+ break;
+ }
+
+ if( bUseSize && nSize>0 )
+ {
+ if( Application::GetDefaultDevice() )
+ {
+ Size aNewSz( nSize, 0 );
+ aNewSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aNewSz, MapMode( MAP_100TH_MM ) );
+ aSz.Width() = aNewSz.Width();
+ ASSERT( !aTextSz.Width(), "Text-Breite ist gegeben" );
+ bMinWidth = sal_False;
+ }
+ }
+
+ SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aCSS1PropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
+ if( aId.Len() )
+ InsertBookmark( aId );
+ }
+
+ if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
+ {
+ aSz.Width() = TWIP_TO_MM100( aCSS1PropInfo.nWidth );
+ aTextSz.Width() = 0;
+ bMinWidth = sal_False;
+ }
+ if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
+ {
+ aSz.Height() = TWIP_TO_MM100( aCSS1PropInfo.nHeight );
+ aTextSz.Height() = 0;
+ bMinHeight = sal_False;
+ }
+
+ // Beim Image-Button bei nicht gegebern Groesse einen sinnvollen Default
+ // setzen
+ if( HTML_IT_IMAGE== eType )
+ {
+ if( !aSz.Width() )
+ {
+ aSz.Width() = HTML_DFLT_IMG_WIDTH;
+ bSetGrfWidth = sal_True;
+ if( pTable != 0 )
+ IncGrfsThatResizeTable();
+ }
+ if( !aSz.Height() )
+ {
+ aSz.Height() = HTML_DFLT_IMG_HEIGHT;
+ bSetGrfHeight = sal_True;
+ }
+ }
+ if( aSz.Width() < MINFLY )
+ aSz.Width() = MINFLY;
+ if( aSz.Height() < MINFLY )
+ aSz.Height() = MINFLY;
+
+ Reference< drawing::XShape > xShape = InsertControl(
+ xFComp, xPropSet, aSz,
+ eVertOri, eHoriOri,
+ aCSS1ItemSet, aCSS1PropInfo,
+ aMacroTbl, aUnoMacroTbl,
+ aUnoMacroParamTbl, sal_False,
+ bHidden );
+ if( aTextSz.Width() || aTextSz.Height() || bMinWidth || bMinHeight )
+ {
+ ASSERT( !(bSetGrfWidth || bSetGrfHeight), "Grafikgroesse anpassen???" );
+ SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight, HTML_INPUT );
+ }
+
+ if( HTML_IT_RADIO == eType )
+ {
+ aTmp <<= (sal_Int16) nChecked ;
+ xPropSet->setPropertyValue( OUString::createFromAscii( "DefaultState" ), aTmp );
+ }
+
+ if( HTML_IT_IMAGE == eType )
+ {
+ // Die URL erst nach dem Einfuegen setzen, weil sich der
+ // Download der Grafik erst dann am XModel anmelden kann,
+ // wenn das Control eingefuegt ist.
+ aTmp <<= OUString(INetURLObject::RelToAbs(sImgSrc));
+ xPropSet->setPropertyValue( OUString::createFromAscii( "ImageURL" ),
+ aTmp );
+ }
+
+ if( bSetGrfWidth || bSetGrfHeight )
+ {
+ SwHTMLImageWatcher* pWatcher =
+ new SwHTMLImageWatcher( xShape, bSetGrfWidth, bSetGrfHeight );
+ Reference< awt::XImageConsumer > xCons = pWatcher;
+ pWatcher->start();
+ }
+}
+
+void SwHTMLParser::NewTextArea()
+{
+ if( pPendStack )
+ {
+ SetPendingControlSize( HTML_TEXTAREA_ON );
+ return;
+ }
+
+ ASSERT( !bTextArea, "TextArea in TextArea???" );
+ ASSERT( !pFormImpl || !pFormImpl->GetFCompPropSet().is(),
+ "TextArea in Control???" );
+
+ if( !pFormImpl || !pFormImpl->GetFormComps().is() )
+ {
+ // Spezialbehandlung fuer TextArea auch untem im Parser beenden
+ FinishTextArea();
+ return;
+ }
+
+ String aId, aClass, aStyle;
+ String sName;
+ sal_Int32 nTabIndex = TABINDEX_MAX + 1;
+ SvxMacroTableDtor aMacroTbl;
+ SvStringsDtor aUnoMacroTbl;
+ SvStringsDtor aUnoMacroParamTbl;
+ sal_uInt16 nRows = 0, nCols = 0;
+ sal_uInt16 nWrap = HTML_WM_OFF;
+ sal_Bool bDisabled = sal_False;
+ SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
+ ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
+ const String& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ ScriptType eScriptType = eDfltScriptType;
+ sal_uInt16 nEvent;
+ sal_Bool bSetEvent = sal_False;
+
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_NAME:
+ sName = pOption->GetString();
+ break;
+ case HTML_O_DISABLED:
+ bDisabled = sal_True;
+ break;
+ case HTML_O_ROWS:
+ nRows = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_COLS:
+ nCols = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_WRAP:
+ nWrap = pOption->GetEnum( aHTMLTextAreaWrapTable, nWrap );
+ break;
+
+ case HTML_O_TABINDEX:
+ nTabIndex = pOption->GetSNumber();
+ break;
+
+ case HTML_O_SDONFOCUS:
+ eScriptType = STARBASIC;
+ case HTML_O_ONFOCUS:
+ nEvent = HTML_ET_ONGETFOCUS;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONBLUR:
+ eScriptType = STARBASIC;
+ case HTML_O_ONBLUR:
+ nEvent = HTML_ET_ONLOSEFOCUS;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONCLICK:
+ eScriptType = STARBASIC;
+ case HTML_O_ONCLICK:
+ nEvent = HTML_ET_ONCLICK;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONCHANGE:
+ eScriptType = STARBASIC;
+ case HTML_O_ONCHANGE:
+ nEvent = HTML_ET_ONCHANGE;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONSELECT:
+ eScriptType = STARBASIC;
+ case HTML_O_ONSELECT:
+ nEvent = HTML_ET_ONSELECT;
+ bSetEvent = sal_True;
+ break;
+
+ default:
+ lcl_html_getEvents( pOption->GetTokenString(),
+ pOption->GetString(),
+ aUnoMacroTbl, aUnoMacroParamTbl );
+ break;
+ }
+
+ if( bSetEvent )
+ {
+ String sEvent( pOption->GetString() );
+ if( sEvent.Len() )
+ {
+ sEvent.ConvertLineEnd();
+ if( EXTENDED_STYPE==eScriptType )
+ aScriptType = rDfltScriptType;
+ aMacroTbl.Insert( nEvent, new SvxMacro( sEvent, aScriptType,
+ eScriptType ) );
+ }
+ }
+ }
+
+
+ const Reference< lang::XMultiServiceFactory > & rSrvcMgr =
+ pFormImpl->GetServiceFactory();
+ if( !rSrvcMgr.is() )
+ {
+ FinishTextArea();
+ return;
+ }
+ Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.form.component.TextField" ) );
+ if( !xInt.is() )
+ {
+ FinishTextArea();
+ return;
+ }
+
+ Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
+ DBG_ASSERT( xFComp.is(), "keine FormComponent?" );
+
+ Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
+
+ Any aTmp;
+ aTmp <<= OUString(sName);
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Name" ), aTmp );
+
+ BOOL bTrue = sal_True;
+ aTmp.setValue( &bTrue, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "MultiLine" ),
+ aTmp );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "VScroll" ), aTmp );
+ if( HTML_WM_OFF == nWrap )
+ xPropSet->setPropertyValue( OUString::createFromAscii( "HScroll" ),
+ aTmp );
+ if( HTML_WM_HARD == nWrap )
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "HardLineBreaks" ), aTmp );
+
+ if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
+ {
+ aTmp <<= (sal_Int16)nTabIndex ;
+ xPropSet->setPropertyValue( OUString::createFromAscii( "TabIndex" ),
+ aTmp );
+ }
+
+ lcl_html_setFixedFontProperty( xPropSet );
+
+ if( bDisabled )
+ {
+ BOOL bFalse = sal_False;
+ aTmp.setValue( &bFalse, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Enabled" ),
+ aTmp );
+ }
+
+ ASSERT( !pFormImpl->GetText().Len(), "Text ist nicht leer!" );
+
+ if( !nCols )
+ nCols = 20;
+ if( !nRows )
+ nRows = 1;
+
+ Size aTextSz( nCols, nRows );
+
+ SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aCSS1PropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
+ if( aId.Len() )
+ InsertBookmark( aId );
+ }
+
+ Size aSz( MINFLY, MINFLY );
+ if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
+ {
+ aSz.Width() = TWIP_TO_MM100( aCSS1PropInfo.nWidth );
+ aTextSz.Width() = 0;
+ }
+ if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
+ {
+ aSz.Height() = TWIP_TO_MM100( aCSS1PropInfo.nHeight );
+ aTextSz.Height() = 0;
+ }
+ if( aSz.Width() < MINFLY )
+ aSz.Width() = MINFLY;
+ if( aSz.Height() < MINFLY )
+ aSz.Height() = MINFLY;
+
+ Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
+ VERT_TOP, HORI_NONE,
+ aCSS1ItemSet, aCSS1PropInfo,
+ aMacroTbl, aUnoMacroTbl,
+ aUnoMacroParamTbl );
+ if( aTextSz.Width() || aTextSz.Height() )
+ SetControlSize( xShape, aTextSz, sal_False, sal_False,
+ HTML_TEXTAREA_ON );
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_TEXTAREA_ON );
+
+ // und PRE/Listing/XMP voruebergehend aussetzen
+ SplitPREListingXMP( pCntxt );
+ PushContext( pCntxt );
+
+ bTextArea = sal_True;
+ bTAIgnoreNewPara = sal_True;
+}
+
+void SwHTMLParser::EndTextArea()
+{
+ ASSERT( bTextArea, "keine TextArea oder falscher Typ" );
+ ASSERT( pFormImpl && pFormImpl->GetFCompPropSet().is(),
+ "TextArea fehlt" );
+
+ const Reference< beans::XPropertySet > & rPropSet =
+ pFormImpl->GetFCompPropSet();
+
+ Any aTmp;
+ aTmp <<= OUString(pFormImpl->GetText());
+ rPropSet->setPropertyValue( OUString::createFromAscii( "DefaultText" ),
+ aTmp );
+ pFormImpl->EraseText();
+
+ pFormImpl->ReleaseFCompPropSet();
+
+ // den Kontext holen
+ _HTMLAttrContext *pCntxt = PopContext( HTML_TEXTAREA_ON );
+ if( pCntxt )
+ {
+ // und ggf. die Attribute beenden
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+
+ bTextArea = sal_False;
+}
+
+
+void SwHTMLParser::InsertTextAreaText( sal_uInt16 nToken )
+{
+ ASSERT( bTextArea, "keine TextArea oder falscher Typ" );
+ ASSERT( pFormImpl && pFormImpl->GetFCompPropSet().is(),
+ "TextArea fehlt" );
+
+ String& rText = pFormImpl->GetText();
+ switch( nToken)
+ {
+ case HTML_TEXTTOKEN:
+ rText += aToken;
+ break;
+ case HTML_NEWPARA:
+ if( !bTAIgnoreNewPara )
+ rText += '\n'; // das ist hier richtig!!!
+ break;
+ default:
+ rText += '<';
+ rText += sSaveToken;
+ if( aToken.Len() )
+ {
+ rText += ' ';
+ rText += aToken;
+ }
+ rText += '>';
+ }
+
+ bTAIgnoreNewPara = sal_False;
+}
+
+void SwHTMLParser::NewSelect()
+{
+ if( pPendStack )
+ {
+ SetPendingControlSize( HTML_SELECT_ON );
+ return;
+ }
+
+ ASSERT( !bSelect, "Select in Select???" );
+ ASSERT( !pFormImpl || !pFormImpl->GetFCompPropSet().is(),
+ "Select in Control???" );
+
+ if( !pFormImpl || !pFormImpl->GetFormComps().is() )
+ return;
+
+ String aId, aClass, aStyle;
+ String sName;
+ sal_Int32 nTabIndex = TABINDEX_MAX + 1;
+ SvxMacroTableDtor aMacroTbl;
+ SvStringsDtor aUnoMacroTbl;
+ SvStringsDtor aUnoMacroParamTbl;
+ sal_Bool bMultiple = sal_False;
+ sal_Bool bDisabled = sal_False;
+ nSelectEntryCnt = 1;
+ SvKeyValueIterator *pHeaderAttrs = pFormImpl->GetHeaderAttrs();
+ ScriptType eDfltScriptType = GetScriptType( pHeaderAttrs );
+ const String& rDfltScriptType = GetScriptTypeString( pHeaderAttrs );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ ScriptType eScriptType = eDfltScriptType;
+ sal_uInt16 nEvent;
+ sal_Bool bSetEvent = sal_False;
+
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_NAME:
+ sName = pOption->GetString();
+ break;
+ case HTML_O_MULTIPLE:
+ bMultiple = sal_True;
+ break;
+ case HTML_O_DISABLED:
+ bDisabled = sal_True;
+ break;
+ case HTML_O_SIZE:
+ nSelectEntryCnt = (sal_uInt16)pOption->GetNumber();
+ break;
+
+ case HTML_O_TABINDEX:
+ nTabIndex = pOption->GetSNumber();
+ break;
+
+ case HTML_O_SDONFOCUS:
+ eScriptType = STARBASIC;
+ case HTML_O_ONFOCUS:
+ nEvent = HTML_ET_ONGETFOCUS;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONBLUR:
+ eScriptType = STARBASIC;
+ case HTML_O_ONBLUR:
+ nEvent = HTML_ET_ONLOSEFOCUS;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONCLICK:
+ eScriptType = STARBASIC;
+ case HTML_O_ONCLICK:
+ nEvent = HTML_ET_ONCLICK;
+ bSetEvent = sal_True;
+ break;
+
+ case HTML_O_SDONCHANGE:
+ eScriptType = STARBASIC;
+ case HTML_O_ONCHANGE:
+ nEvent = HTML_ET_ONCHANGE;
+ bSetEvent = sal_True;
+ break;
+
+ default:
+ lcl_html_getEvents( pOption->GetTokenString(),
+ pOption->GetString(),
+ aUnoMacroTbl, aUnoMacroParamTbl );
+ break;
+ }
+
+ if( bSetEvent )
+ {
+ String sEvent( pOption->GetString() );
+ if( sEvent.Len() )
+ {
+ sEvent.ConvertLineEnd();
+ if( EXTENDED_STYPE==eScriptType )
+ aScriptType = rDfltScriptType;
+ aMacroTbl.Insert( nEvent, new SvxMacro( sEvent, aScriptType,
+ eScriptType ) );
+ }
+ }
+ }
+
+ const Reference< lang::XMultiServiceFactory > & rSrvcMgr =
+ pFormImpl->GetServiceFactory();
+ if( !rSrvcMgr.is() )
+ {
+ FinishTextArea();
+ return;
+ }
+ Reference< uno::XInterface > xInt = rSrvcMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.form.component.ListBox" ) );
+ if( !xInt.is() )
+ {
+ FinishTextArea();
+ return;
+ }
+
+ Reference< XFormComponent > xFComp( xInt, UNO_QUERY );
+ DBG_ASSERT(xFComp.is(), "keine FormComponent?")
+
+ Reference< beans::XPropertySet > xPropSet( xFComp, UNO_QUERY );
+
+ Any aTmp;
+ aTmp <<= OUString(sName);
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Name" ), aTmp );
+
+ if( nTabIndex >= TABINDEX_MIN && nTabIndex <= TABINDEX_MAX )
+ {
+ aTmp <<= (sal_Int16)nTabIndex ;
+ xPropSet->setPropertyValue( OUString::createFromAscii( "TabIndex" ),
+ aTmp );
+ }
+
+ if( bDisabled )
+ {
+ BOOL bFalse = sal_False;
+ aTmp.setValue( &bFalse, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Enabled" ),
+ aTmp );
+ }
+
+ Size aTextSz( 0, 0 );
+ sal_Bool bMinWidth = sal_True, bMinHeight = sal_True;
+ if( !bMultiple && 1==nSelectEntryCnt )
+ {
+ BOOL bTrue = sal_True;
+ aTmp.setValue( &bTrue, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( OUString::createFromAscii( "Dropdown" ),
+ aTmp );
+ }
+ else
+ {
+ if( nSelectEntryCnt <= 1 ) // 4 Zeilen als default
+ nSelectEntryCnt = 4;
+
+ if( bMultiple )
+ {
+ BOOL bTrue = sal_True;
+ aTmp.setValue( &bTrue, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "MultiSelection" ), aTmp );
+ }
+ aTextSz.Height() = nSelectEntryCnt;
+ bMinHeight = sal_False;
+ }
+
+ SfxItemSet aCSS1ItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aCSS1PropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ ParseStyleOptions( aStyle, aId, aClass, aCSS1ItemSet, aCSS1PropInfo );
+ if( aId.Len() )
+ InsertBookmark( aId );
+ }
+
+ Size aSz( MINFLY, MINFLY );
+ bFixSelectWidth = bFixSelectHeight = sal_True;
+ if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eWidthType )
+ {
+ aSz.Width() = TWIP_TO_MM100( aCSS1PropInfo.nWidth );
+ bFixSelectWidth = sal_False;
+ bMinWidth = sal_False;
+ }
+ if( SVX_CSS1_LTYPE_TWIP== aCSS1PropInfo.eHeightType )
+ {
+ aSz.Height() = TWIP_TO_MM100( aCSS1PropInfo.nHeight );
+ aTextSz.Height() = sal_False;
+ bMinHeight = sal_False;
+ }
+ if( aSz.Width() < MINFLY )
+ aSz.Width() = MINFLY;
+ if( aSz.Height() < MINFLY )
+ aSz.Height() = MINFLY;
+
+ Reference< drawing::XShape > xShape = InsertControl( xFComp, xPropSet, aSz,
+ VERT_TOP, HORI_NONE,
+ aCSS1ItemSet, aCSS1PropInfo,
+ aMacroTbl, aUnoMacroTbl,
+ aUnoMacroParamTbl );
+ if( bFixSelectWidth )
+ pFormImpl->SetShape( xShape );
+ if( aTextSz.Height() || bMinWidth || bMinHeight )
+ SetControlSize( xShape, aTextSz, bMinWidth, bMinHeight,
+ HTML_SELECT_ON );
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_SELECT_ON );
+
+ // und PRE/Listing/XMP voruebergehend aussetzen
+ SplitPREListingXMP( pCntxt );
+ PushContext( pCntxt );
+
+ bSelect = sal_True;
+}
+
+void SwHTMLParser::EndSelect()
+{
+ if( pPendStack )
+ {
+ SetPendingControlSize( HTML_SELECT_OFF );
+ return;
+ }
+
+ ASSERT( bSelect, "keine Select" );
+ ASSERT( pFormImpl && pFormImpl->GetFCompPropSet().is(),
+ "kein Select-Control" );
+
+ const Reference< beans::XPropertySet > & rPropSet =
+ pFormImpl->GetFCompPropSet();
+
+ // die Groesse anpassen
+ Size aNewSz( MINFLY, MINFLY );
+
+ sal_uInt16 nEntryCnt = pFormImpl->GetStringList().Count();
+ if( nEntryCnt )
+ {
+ Sequence<OUString> aList( (sal_Int32)nEntryCnt );
+ Sequence<OUString> aValueList( (sal_Int32)nEntryCnt );
+ OUString *pStrings = aList.getArray();
+ OUString *pValues = aValueList.getArray();
+ for( sal_uInt16 i=0; i<nEntryCnt; i++ )
+ {
+ String sText( *pFormImpl->GetStringList()[i] );
+ sText.EraseTrailingChars();
+ pStrings[i] = sText;
+
+ sText = *pFormImpl->GetValueList()[i];
+ pValues[i] = sText;
+ }
+
+ Any aAny( &aList, ::getCppuType((uno::Sequence<OUString>*)0) );
+
+ rPropSet->setPropertyValue(
+ OUString::createFromAscii( "StringItemList" ), aAny );
+
+ aAny <<= ListSourceType_VALUELIST;
+ rPropSet->setPropertyValue(
+ OUString::createFromAscii( "ListSourceType" ), aAny );
+
+ aAny.setValue( &aValueList, ::getCppuType((uno::Sequence<OUString>*)0) );
+
+ rPropSet->setPropertyValue( OUString::createFromAscii( "ListSource" ),
+ aAny );
+
+ sal_uInt16 nSelCnt = pFormImpl->GetSelectedList().Count();
+ if( !nSelCnt && 1 == nSelectEntryCnt && nEntryCnt )
+ {
+ // In einer DropDown-Listbox sollte immer ein Eintrag selektiert
+ // sein.
+ pFormImpl->GetSelectedList().Insert( (sal_uInt16)0, (sal_uInt16)0 );
+ nSelCnt = 1;
+ }
+ Sequence<sal_Int16> aSelList( (sal_Int32)nSelCnt );
+ sal_Int16 *pSels = aSelList.getArray();
+ for( i=0; i<nSelCnt; i++ )
+ {
+ pSels[i] = (sal_Int16)pFormImpl->GetSelectedList()[i];
+ }
+ aAny.setValue( &aSelList,
+ ::getCppuType((uno::Sequence<sal_Int16>*)0) );
+
+ rPropSet->setPropertyValue(
+ OUString::createFromAscii( "DefaultSelection" ), aAny );
+
+ pFormImpl->EraseStringList();
+ pFormImpl->EraseValueList();
+ }
+
+ pFormImpl->EraseSelectedList();
+
+ if( bFixSelectWidth )
+ {
+ ASSERT( pFormImpl->GetShape().is(), "Kein Shape gemerkt" );
+ Size aTextSz( -1, 0 );
+ SetControlSize( pFormImpl->GetShape(), aTextSz, sal_False, sal_False,
+ HTML_SELECT_OFF );
+ }
+
+ pFormImpl->ReleaseFCompPropSet();
+
+ // den Kontext holen
+ _HTMLAttrContext *pCntxt = PopContext( HTML_SELECT_ON );
+ if( pCntxt )
+ {
+ // und ggf. die Attribute beenden
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+
+ bSelect = sal_False;
+}
+
+void SwHTMLParser::InsertSelectOption()
+{
+ ASSERT( bSelect, "keine Select" );
+ ASSERT( pFormImpl && pFormImpl->GetFCompPropSet().is(),
+ "kein Select-Control" );
+
+ bLBEntrySelected = sal_False;
+ String aValue;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ // erstmal weglassen!!!
+ break;
+ case HTML_O_SELECTED:
+ bLBEntrySelected = sal_True;
+ break;
+ case HTML_O_VALUE:
+ aValue = pOption->GetString();
+ if( !aValue.Len() )
+ aValue.AssignAscii( "$$$empty$$$" );
+ break;
+ }
+ }
+
+ sal_uInt16 nEntryCnt = pFormImpl->GetStringList().Count();
+ pFormImpl->GetStringList().Insert( new String( aEmptyStr ), nEntryCnt );
+ pFormImpl->GetValueList().Insert( new String( aValue ), nEntryCnt );
+ if( bLBEntrySelected )
+ pFormImpl->GetSelectedList().Insert( nEntryCnt,
+ pFormImpl->GetSelectedList().Count() );
+}
+
+void SwHTMLParser::InsertSelectText()
+{
+ ASSERT( bSelect, "keine Select" );
+ ASSERT( pFormImpl && pFormImpl->GetFCompPropSet().is(),
+ "kein Select-Control" );
+
+ sal_uInt16 nEntryCnt = pFormImpl->GetStringList().Count();
+ if( nEntryCnt )
+ {
+ String& rText = *pFormImpl->GetStringList()[nEntryCnt-1];
+
+ if( aToken.Len() && ' '==aToken.GetChar( 0 ) )
+ {
+ xub_StrLen nLen = rText.Len();
+ if( !nLen || ' '==rText.GetChar( nLen-1 ))
+ aToken.Erase( 0, 1 );
+ }
+ if( aToken.Len() )
+ rText += aToken;
+ }
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlform.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.232 2000/09/18 16:04:44 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.231 2000/06/26 09:52:06 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.230 2000/06/16 12:28:26 os
+ UNO3 error removed
+
+ Revision 1.229 2000/05/16 09:23:09 os
+ project usr removed
+
+ Revision 1.228 2000/04/28 14:29:11 mib
+ unicode
+
+ Revision 1.227 2000/04/11 10:46:28 mib
+ unicode
+
+ Revision 1.226 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.225 2000/03/31 06:16:24 os
+ UNO III: toolkit includes
+
+ Revision 1.224 2000/03/30 07:31:01 os
+ UNO III
+
+ Revision 1.223 2000/03/21 15:06:17 os
+ UNOIII
+
+ Revision 1.222 2000/03/03 15:21:00 os
+ StarView remainders removed
+
+ Revision 1.221 2000/02/14 13:59:45 mib
+ #70473#: unicode
+
+ Revision 1.220 2000/02/10 09:51:53 mib
+ #68571#: text/plain encoding for submit
+
+ Revision 1.219 1999/11/29 11:29:08 os
+ include
+
+ Revision 1.218 1999/11/25 11:46:11 os
+ ...component.Hidden -> ...component.HiddenControl; include clean-up
+
+ Revision 1.217 1999/11/25 11:20:16 os
+ ...component.Edit -> ...component.TextField
+
+ Revision 1.216 1999/11/22 14:04:13 os
+ headers added
+
+ Revision 1.215 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.214 1999/09/17 12:13:21 mib
+ support of multiple and non system text encodings
+
+ Revision 1.213 1999/07/22 16:46:44 MIB
+ Create hidden view on demand if doc shell is an internal one
+
+
+ Rev 1.212 22 Jul 1999 18:46:44 MIB
+ Create hidden view on demand if doc shell is an internal one
+
+ Rev 1.211 10 Jun 1999 10:34:08 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.210 09 Jun 1999 19:36:52 JP
+ have to change: no cast from GetpApp to SfxApp/OffApp, SfxShell only subclass of SfxApp
+
+ Rev 1.209 06 May 1999 08:49:02 MIB
+ #65851#: Keinen TabIndex fuer Hidden-Controls setzen
+
+ Rev 1.208 07 Apr 1999 13:50:56 MIB
+ #64327#: GetBrowseWidth fuer Tabellen in Rahmen richtig
+
+ Rev 1.207 31 Mar 1999 09:07:08 MIB
+ #64110#: ALIGN nur noch bei Image-Buttons auswerten
+
+ Rev 1.206 29 Mar 1999 08:09:32 MIB
+ #63283#: Img-URL wg. Stopp-Knopf/Reload nach dem Einfuegen des Controls setzen
+
+ Rev 1.205 15 Mar 1999 13:10:36 OS
+ #62266# FontHeight float
+
+ Rev 1.204 12 Mar 1999 16:59:08 OS
+ #62845# ServiceManager->ServiceFactory
+
+ Rev 1.203 10 Mar 1999 15:44:04 MIB
+ #62682#: Beim Setzen der Control-Groesse wenn noetig auf die ViewShell warten
+
+ Rev 1.202 05 Mar 1999 20:45:14 HJS
+ muss fuer os
+
+ Rev 1.201 05 Mar 1999 13:49:52 OS
+ HoriOrientation - UPD515
+
+ Rev 1.200 04 Mar 1999 15:02:16 OS
+ #62191# UINT nicht mehr verwenden
+
+ Rev 1.199 03 Mar 1999 11:16:34 MIB
+ #62251#: Fehlende Font-Properties setzen
+
+ Rev 1.198 23 Feb 1999 10:27:04 MIB
+ #61968#: Positionierung von Controls
+
+ Rev 1.197 22 Feb 1999 08:40:46 MA
+ 1949globale Shell entsorgt, Shells am RootFrm
+
+ Rev 1.196 12 Feb 1999 13:04:00 MIB
+ #56371#: TF_ONE51: OS/2
+
+ Rev 1.195 09 Feb 1999 15:36:10 MIB
+ #56371#: TF_ONE51 aufgeraeumt
+
+ Rev 1.194 05 Feb 1999 10:09:26 MIB
+ #56371#: File-Control
+
+ Rev 1.193 04 Feb 1999 19:25:48 MIB
+ #56371#: sal_uInt16-Properties umgetsellt
+
+ Rev 1.192 04 Feb 1999 19:03:34 MIB
+ #56371#: sal_uInt16-Properties umgetsellt
+
+ Rev 1.191 04 Feb 1999 10:18:48 OS
+ #56371# FontDescriptor ist nicht immer im Set, DefaultState sal_Int16
+
+ Rev 1.190 04 Feb 1999 09:18:14 OS
+ #56371# Import funktioniert
+
+ Rev 1.189 01 Feb 1999 11:10:04 MIB
+ #56371#: Listener- und Property-Namen berichtigt
+
+ Rev 1.188 01 Feb 1999 08:26:52 OS
+ #56371# Service- u. Property-Namen berichtigt
+
+ Rev 1.187 27 Jan 1999 19:00:12 JP
+ Task #61014#: FindSdrObject/FindContactObject als Methoden vom SwFrmFmt
+
+ Rev 1.186 27 Jan 1999 12:05:46 OS
+ #56371# TF_ONE51
+
+ Rev 1.185 25 Jan 1999 16:19:04 OS
+ #56371# TF_ONE51 - uebersetzbar
+
+ Rev 1.184 26 Nov 1998 15:20:18 MIB
+ #59904#: Event-sind-noch-nicht-implementiert-Assert weg
+
+ Rev 1.183 26 Nov 1998 10:21:30 MIB
+ #59882#: bei ACTION='' das Verzeichnis als URL nehmen
+
+ Rev 1.182 19 Oct 1998 17:22:50 MIB
+ #57901# Standard-Font, #55311# leerer Listbox-Value, #54997# leerer Checkbox-Value
+
+ Rev 1.181 14 Sep 1998 13:55:52 MIB
+ #55436#: generische Events, #56435#: Event-Setzen opntimiert
+
+ Rev 1.180 10 Sep 1998 08:31:08 MIB
+ #51303#: Zeichen-Attribute fuer Controls uebernehmen
+
+ Rev 1.179 01 Sep 1998 10:22:52 MIB
+ #54997#: VALUE von Checkboxen/Radiobuttons mit 'on' defaulten
+
+ Rev 1.178 24 Aug 1998 16:00:22 MIB
+ #54606#: resetted -> afterReset
+
+ Rev 1.177 24 Aug 1998 15:27:20 MIB
+ #54532#, #55313#: Beim Anpassen der ImageButton-Groesse leere Grafik beachten
+
+ Rev 1.176 27 Jul 1998 15:59:50 MIB
+ 53936#: Events erst nach dem Einfuegen des Controls registrieren (wegen Fokus-Events)
+
+ Rev 1.175 27 Jul 1998 14:52:46 MIB
+ #54008#: In DropDown-Listbox ersten EIntrag selektieren
+
+ Rev 1.174 24 Jul 1998 09:56:20 MIB
+ #53718#: und fuer das Hidden-Control nehmen wir jetzt HiddenValue statt Text
+
+ Rev 1.173 23 Jul 1998 12:25:00 MIB
+ #53611#: Heute nehmen wir statt der ValueSeq mal dir Listbox-Property
+
+ Rev 1.172 23 Jul 1998 09:44:50 MIB
+ fix #53493#: sheet::Border am ImageButton ausschalten
+
+ Rev 1.171 22 Jul 1998 12:01:06 MIB
+ fix #53559#: DefaultChecked-Property bei RadioButtons erst nach dem Einfuegen setzen
+
+ Rev 1.170 15 Jul 1998 20:08:16 MIB
+ #52554#: StarOne-Schnittstelle arbeitet jetzt mit 1/100mm
+
+ Rev 1.169 15 Jul 1998 19:49:02 MIB
+ #52660#: SelectedItems, #52664#: neue Behandlung von Default-Werten
+
+ Rev 1.168 15 Jul 1998 10:12:42 MIB
+ #52098#: Listbox-Select-Property geaender, #52729#: Controls ohne Form ignorieren
+
+ Rev 1.167 14 Jul 1998 18:39:18 MIB
+ #51982#: genererische Events nicht fuer JavaScript/StarBasic zulassen
+
+ Rev 1.166 14 Jul 1998 09:07:04 MIB
+ fix #52729#: Controls gar nicht erst einfuegen, wenn es keine Form gibt
+
+ Rev 1.165 10 Jul 1998 13:55:40 TJ
+ include fuer attacher
+
+ Rev 1.164 08 Jul 1998 17:20:10 MIB
+ StarScript
+
+ Rev 1.163 07 Jul 1998 15:15:54 OM
+ Muss Aenderung SubmitAction->TargetURL u.a.
+
+ Rev 1.162 04 Jul 1998 17:43:50 MIB
+ StarScript in IDE, StarScript-Events
+
+ Rev 1.161 02 Jul 1998 10:43:16 MIB
+ Controls wegen Event-Registrierung erst in dir Form und dann in die Page einfuegen
+
+ Rev 1.160 01 Jul 1998 10:27:18 MIB
+ Muss-Aenderung: Font-Hoehen nun in pt
+
+ Rev 1.159 30 Jun 1998 12:23:18 MIB
+ Muss-Aenderung: Multi-Property
+
+ Rev 1.158 29 Jun 1998 15:07:08 MIB
+ Event-Export, kein Value bei File-Control
+
+ Rev 1.157 26 Jun 1998 17:06:20 MIB
+ ItemListener statt ActionListener bei Checkboxen/radiobuttons
+
+ Rev 1.156 26 Jun 1998 09:57:06 MIB
+ Sumit- und Reset-Events
+
+ Rev 1.155 24 Jun 1998 09:36:54 MIB
+ fix: Hidden-Controls nun wirklich einfuegen
+
+ Rev 1.154 22 Jun 1998 14:26:44 MIB
+ Listbox-Groessenberechnung jetzt richtig
+
+ Rev 1.153 19 Jun 1998 08:32:06 OS
+ SfxModel auf XModel casten
+
+ Rev 1.152 19 Jun 1998 08:28:28 MIB
+ Events setzen
+
+ Rev 1.151 18 Jun 1998 09:37:24 MIB
+ Hidden-Control freigeschaltet, Groessenberchnung verbessert, Events begonnen
+
+ Rev 1.150 15 Jun 1998 18:18:46 MIB
+ Compiler-Fehler
+
+ Rev 1.149 15 Jun 1998 08:57:04 OS
+ Headeraenderung
+
+ Rev 1.148 15 Jun 1998 08:53:16 MIB
+ Groessenberechnungen
+
+ Rev 1.147 14 Jun 1998 19:52:06 MIB
+ Groessenberechnung vorbereitet
+
+ Rev 1.146 14 Jun 1998 17:43:32 MIB
+ Neue Properties, Hidden-Control durch Edit simuliert
+
+ Rev 1.145 12 Jun 1998 11:36:56 MIB
+ form, ImageButton mit URL
+
+ Rev 1.144 10 Jun 1998 10:15:22 OS
+ Package-Umstellung
+
+ Rev 1.143 09 Jun 1998 19:02:26 MIB
+ Form ueber FormComponentFactory erzeugen
+
+ Rev 1.142 09 Jun 1998 13:26:42 MIB
+ insertShape -> insertShapeAtTextPosition
+
+ Rev 1.141 09 Jun 1998 10:15:20 MIB
+ SIZE auch fuer Nicht-Edits auswerten
+
+ Rev 1.140 04 Jun 1998 16:13:20 MIB
+ ImageButton-Verbesserungen
+
+ Rev 1.139 03 Jun 1998 12:49:38 MIB
+ Value-Liste vorbereitet
+
+ Rev 1.138 02 Jun 1998 16:04:16 MIB
+ neue Form-Control-Anbindung
+
+ Rev 1.137 29 May 1998 14:32:56 MIB
+ ImageButton (noch nicht fertig)
+
+ Rev 1.136 26 May 1998 18:08:42 MIB
+ TABINDEX, Multiline-Scrollbars, Checkbox-/Readio-Button-Default, etc.
+
+ Rev 1.135 26 May 1998 12:23:30 MIB
+ Scrollbars an Multiline-Edits aktiviert
+
+ Rev 1.134 20 May 1998 15:22:18 MIB
+ Zeichen-Objekte ueber Schnittstelle am Dok einfuegen
+
+ Rev 1.133 19 May 1998 19:15:02 MIB
+ SW-Properties nun komplett
+
+ Rev 1.132 19 May 1998 14:49:16 MIB
+ HIDDEN-Control erstmal wieder raus, RefValue- statt Value-Property
+
+ Rev 1.131 18 May 1998 16:54:32 MIB
+ SW-Properties setzen
+
+ Rev 1.130 18 May 1998 08:41:10 MIB
+ mehr Properties setzen
+
+ Rev 1.129 15 May 1998 11:31:50 MIB
+ Interface-Aenderungen
+
+ Rev 1.128 15 May 1998 10:04:32 MIB
+ UNO-Controls statt VC-Controls (noch geht nicht viel)
+
+ Rev 1.127 21 Apr 1998 13:46:12 MIB
+ fix: Keine Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.126 31 Mar 1998 11:19:58 MIB
+ Controls auch Rahmengebunden einfuegen
+
+ Rev 1.125 27 Mar 1998 17:27:40 MIB
+ direkte absolute Positionierung und Groessen-Export von Controls und Marquee
+
+ Rev 1.124 27 Mar 1998 10:03:28 MIB
+ direkte Positionierung von Grafiken etc.
+
+ Rev 1.123 27 Feb 1998 14:05:06 MIB
+ Auto-gebundene Rahmen
+
+ Rev 1.122 20 Feb 1998 19:03:28 MA
+ header
+
+ Rev 1.121 26 Nov 1997 19:09:30 MA
+ includes
+
+ Rev 1.120 08 Sep 1997 10:38:20 MIB
+ Keine Schleifen fuer PRE mehr (auch fix #41253#)
+
+ Rev 1.119 01 Sep 1997 13:52:48 MIB
+ Zeichensetz-/Zeilenende-Konvertierung fuer Event-Optionen
+
+ Rev 1.118 29 Aug 1997 16:50:32 OS
+ DLL-Umstellung
+
+ Rev 1.117 18 Aug 1997 11:36:16 OS
+ includes
+
+ Rev 1.116 15 Aug 1997 12:46:30 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.115 12 Aug 1997 13:42:58 OS
+ Header-Umstellung
+
+ Rev 1.114 07 Aug 1997 15:08:52 OM
+ Headerfile-Umstellung
+
+ Rev 1.113 29 Jul 1997 20:38:42 TJ
+ includes - fuer tj
+
+ Rev 1.112 10 Jul 1997 10:29:04 MIB
+ fix #41516#: Hidden-Controls mit Durchlauf versehen
+
+ Rev 1.111 10 Jun 1997 10:32:10 MIB
+ Bei Fonts keine Breite mehr angeben
+
+ Rev 1.110 06 Jun 1997 11:56:08 MIB
+ <TEXTAREA WRAP=PHYSICAL/VIRTUAL> wie HARD/SOFT
+
+ Rev 1.109 06 Jun 1997 09:57:58 MIB
+ WRAP-Option fuer <TEXTAREA>
+
+ Rev 1.108 22 May 1997 13:23:28 MIB
+ In Combo-Boxen selektierten Eintrag ueber uber das Space-Loeschen hinaus retten
+
+ Rev 1.107 22 May 1997 13:06:32 TRI
+ includes
+
+ Rev 1.106 09 Apr 1997 14:22:18 MIB
+ in htmlform.cxx (nur noch Import) und htmlforw.cxx (nur Export) aufgeteilt
+
+ Rev 1.105 04 Apr 1997 17:43:04 NF
+ includes
+
+ Rev 1.104 25 Mar 1997 16:01:50 MIB
+ fix #36224#: CR/LF in machen VALUE-Optionen beibehalten
+
+ Rev 1.103 05 Mar 1997 14:46:06 MIB
+ Absatz-Abstaende verbessert
+
+ Rev 1.102 21 Feb 1997 15:28:28 MIB
+ fix #36692#: Fuer Forms in Tabellen ausserhalb von Zellen keine neuen Absaetze
+
+ Rev 1.101 12 Feb 1997 16:48:04 MIB
+ erstmal keine Warnungen
+
+ Rev 1.100 31 Jan 1997 14:36:38 MIB
+ SDONRESET aktiviert
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlform.hxx b/sw/source/filter/html/htmlform.hxx
new file mode 100644
index 000000000000..9f2318864275
--- /dev/null
+++ b/sw/source/filter/html/htmlform.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlform.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _HTMLFORM_HXX
+#define _HTMLFORM_HXX
+
+
+enum HTMLEventType
+{
+ HTML_ET_ONSUBMITFORM, HTML_ET_ONRESETFORM,
+ HTML_ET_ONGETFOCUS, HTML_ET_ONLOSEFOCUS,
+ HTML_ET_ONCLICK, HTML_ET_ONCLICK_ITEM,
+ HTML_ET_ONCHANGE, HTML_ET_ONSELECT,
+ HTML_ET_END
+};
+
+extern HTMLEventType __FAR_DATA aEventTypeTable[];
+extern const sal_Char * __FAR_DATA aEventListenerTable[];
+extern const sal_Char * __FAR_DATA aEventMethodTable[];
+extern const sal_Char * __FAR_DATA aEventSDOptionTable[];
+extern const sal_Char * __FAR_DATA aEventOptionTable[];
+
+
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
new file mode 100644
index 000000000000..a54155e7127f
--- /dev/null
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -0,0 +1,1635 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlforw.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_
+#include <com/sun/star/form/FormSubmitEncoding.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_
+#include <com/sun/star/form/FormSubmitMethod.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_
+#include <com/sun/star/form/FormButtonType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHER_HPP_
+#include <com/sun/star/script/XEventAttacher.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHERMANAGER_HPP_
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+#include <com/sun/star/form/XFormComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
+#include <com/sun/star/form/FormComponentType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_SCRIPTEVENTDESCRIPTOR_HPP_
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XTEXTLAYOUTCONSTRAINS_HPP_
+#include <com/sun/star/awt/XTextLayoutConstrains.hpp>
+#endif
+
+#ifndef _SV_SYSTEM_HXX //autogen
+#include <vcl/system.hxx>
+#endif
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SFXMACITEM_HXX
+#include <svtools/macitem.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _TOOLKIT_UNOHLP_HXX
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+#ifndef _SVDOUNO_HXX //autogen
+#include <svx/svdouno.hxx>
+#endif
+#ifndef _SVX_FMGLOB_HXX
+#include <svx/fmglob.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _UNOOBJ_HXX //autogen
+#include <unoobj.hxx>
+#endif
+#ifndef _SWDOCSH_HXX //autogen
+#include <docsh.hxx>
+#endif
+
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+
+
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+
+#ifndef _VIEWSH_HXX //autogen
+#include <viewsh.hxx>
+#endif
+#include "pam.hxx"
+#include "doc.hxx"
+#include "ndtxt.hxx"
+#include "dcontact.hxx"
+#include "flypos.hxx"
+#include "wrthtml.hxx"
+#include "htmlfly.hxx"
+#include "htmlform.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::rtl;
+/* */
+
+const sal_uInt32 HTML_FRMOPTS_CONTROL =
+ 0;
+const sal_uInt32 HTML_FRMOPTS_CONTROL_CSS1 =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SIZE |
+ HTML_FRMOPT_S_SPACE |
+ HTML_FRMOPT_BRCLEAR;
+const sal_uInt32 HTML_FRMOPTS_IMG_CONTROL =
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_BRCLEAR;
+const sal_uInt32 HTML_FRMOPTS_IMG_CONTROL_CSS1 =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SPACE;
+
+
+/* */
+
+struct HTMLControl
+{
+ // die Form, zu der das Control gehoert
+ Reference< container::XIndexContainer > xFormComps;
+ sal_uInt32 nNdIdx; // der Node, in dem es verankert ist
+ xub_StrLen nCount; // wie viele Controls sind in dem Node
+
+ HTMLControl( const Reference< container::XIndexContainer > & rForm,
+ sal_uInt32 nIdx );
+ ~HTMLControl();
+
+ // operatoren fuer das Sort-Array
+ sal_Bool operator==( const HTMLControl& rCtrl )
+ {
+ return nNdIdx == rCtrl.nNdIdx;
+ }
+ sal_Bool operator<( const HTMLControl& rCtrl )
+ {
+ return nNdIdx < rCtrl.nNdIdx;
+ }
+};
+
+SV_IMPL_OP_PTRARR_SORT( HTMLControls, HTMLControl* )
+
+/* */
+
+void lcl_html_outEvents( SvStream& rStrm,
+ const Reference< form::XFormComponent > rFormComp,
+ sal_Bool bCfgStarBasic,
+ rtl_TextEncoding eDestEnc )
+{
+ Reference< container::XChild > xChild( rFormComp, UNO_QUERY );
+ Reference< XInterface > xParentIfc = xChild->getParent();
+ ASSERT( xParentIfc.is(), "lcl_html_outEvents: no parent interface" );
+ if( !xParentIfc.is() )
+ return;
+ Reference< container::XIndexAccess > xIndexAcc( xParentIfc, UNO_QUERY );
+ Reference< script::XEventAttacherManager > xEventManager( xParentIfc,
+ UNO_QUERY );
+ if( !xIndexAcc.is() || !xEventManager.is() )
+ return;
+
+ // Und die Position des ControlModel darin suchen
+ sal_Int32 nCount = xIndexAcc->getCount(), nPos;
+ for( nPos = 0 ; nPos < nCount; nPos++ )
+ {
+ Any aTmp = xIndexAcc->getByIndex(nPos);
+ ASSERT( aTmp.getValueType() ==
+ ::getCppuType( (Reference<form::XFormComponent>*)0 ) ||
+ aTmp.getValueType() ==
+ ::getCppuType( (Reference<form::XForm>*)0 ),
+ "lcl_html_outEvents: falsche Reflection" );
+ if( aTmp.getValueType() ==
+ ::getCppuType( (Reference< form::XFormComponent >*)0) )
+
+ {
+ if( rFormComp ==
+ *(Reference< form::XFormComponent > *)aTmp.getValue() )
+ break;
+ }
+ else if( aTmp.getValueType() ==
+ ::getCppuType( (Reference< form::XForm>*)0) )
+ {
+ Reference< form::XFormComponent > xFC(
+ *(Reference< form::XForm > *)aTmp.getValue(), UNO_QUERY );
+ if( rFormComp == xFC )
+ break;
+ }
+ }
+
+ if( nPos == nCount )
+ return;
+
+ Sequence< script::ScriptEventDescriptor > aDescs =
+ xEventManager->getScriptEvents( nPos );
+ nCount = aDescs.getLength();
+ if( !nCount )
+ return;
+
+ const script::ScriptEventDescriptor *pDescs = aDescs.getConstArray();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ ScriptType eScriptType = EXTENDED_STYPE;
+ String aScriptType( pDescs[i].ScriptType );
+ if( aScriptType.EqualsIgnoreCaseAscii(SVX_MACRO_LANGUAGE_JAVASCRIPT) )
+ eScriptType = JAVASCRIPT;
+ else if( aScriptType.EqualsIgnoreCaseAscii(SVX_MACRO_LANGUAGE_STARBASIC ) )
+ eScriptType = STARBASIC;
+ if( JAVASCRIPT != eScriptType && !bCfgStarBasic )
+ continue;
+
+ String sListener( pDescs[i].ListenerType );
+ xub_StrLen nTok = sListener.GetTokenCount( '.' );
+ if( nTok )
+ sListener = sListener.GetToken( nTok-1, '.' );
+ String sMethod( pDescs[i].EventMethod );
+
+ const sal_Char *pOpt = 0;
+ for( sal_uInt16 j=0; aEventListenerTable[j]; j++ )
+ {
+ if( sListener.EqualsAscii( aEventListenerTable[j] ) &&
+ sMethod.EqualsAscii( aEventMethodTable[j] ) )
+ {
+ pOpt = (STARBASIC==eScriptType ? aEventSDOptionTable
+ : aEventOptionTable)[j];
+ break;
+ }
+ }
+
+ ByteString sOut( ' ' );
+ if( pOpt && (EXTENDED_STYPE != eScriptType ||
+ !pDescs[i].AddListenerParam.getLength()) )
+ sOut += pOpt;
+ else
+ (((sOut += sHTML_O_sdevent)
+ += ByteString( sListener, RTL_TEXTENCODING_ASCII_US)) += '-')
+ += ByteString( sMethod, RTL_TEXTENCODING_ASCII_US);
+ sOut += "=\"";
+ rStrm << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rStrm, pDescs[i].ScriptCode, eDestEnc );
+ rStrm << '\"';
+ if( EXTENDED_STYPE == eScriptType &&
+ pDescs[i].AddListenerParam.getLength() )
+ {
+ (((((sOut = ' ') += sHTML_O_sdaddparam)
+ += ByteString( sListener, RTL_TEXTENCODING_ASCII_US)) += '-')
+ += ByteString( sMethod, RTL_TEXTENCODING_ASCII_US))
+ += "=\"";
+ rStrm << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rStrm, pDescs[i].AddListenerParam,
+ eDestEnc );
+ rStrm << '\"';
+ }
+ }
+}
+
+sal_Bool lcl_html_isHTMLControl( sal_Int16 nClassId )
+{
+ sal_Bool bRet = sal_False;
+
+ switch( nClassId )
+ {
+ case form::FormComponentType::TEXTFIELD:
+ case form::FormComponentType::COMMANDBUTTON:
+ case form::FormComponentType::RADIOBUTTON:
+ case form::FormComponentType::CHECKBOX:
+ case form::FormComponentType::LISTBOX:
+ case form::FormComponentType::IMAGEBUTTON:
+ case form::FormComponentType::FILECONTROL:
+ bRet = sal_True;
+ break;
+ }
+
+ return bRet;
+}
+
+sal_Bool SwHTMLWriter::HasControls() const
+{
+ sal_uInt32 nStartIdx = pCurPam->GetPoint()->nNode.GetIndex();
+
+ // Skip all controls in front of the current paragraph
+ for( sal_uInt16 i=0; i < aHTMLControls.Count() &&
+ aHTMLControls[i]->nNdIdx < nStartIdx; i++ )
+ ;
+
+ return i < aHTMLControls.Count() && aHTMLControls[i]->nNdIdx == nStartIdx;
+}
+
+void SwHTMLWriter::OutForm( sal_Bool bTagOn, const SwStartNode *pStartNd )
+{
+ if( bPreserveForm ) // wir sind in einer Tabelle oder einem Bereich
+ return; // ueber dem eine Form aufgespannt wurde
+
+ if( !bTagOn )
+ {
+ // die Form beenden wenn alle Controls ausgegeben wurden
+ if( pxFormComps && pxFormComps->is() &&
+ (*pxFormComps)->getCount() == nFormCntrlCnt )
+ {
+ OutForm( sal_False, *pxFormComps );
+ (*pxFormComps) = 0;
+ }
+ return;
+ }
+
+ Reference< container::XIndexContainer > xNewFormComps; // die neue Form
+ sal_uInt32 nStartIdx = pStartNd ? pStartNd->GetIndex()
+ : pCurPam->GetPoint()->nNode.GetIndex();
+
+ // Ueberspringen von Controls vor dem interesanten Bereich
+ for( sal_uInt16 i=0; i < aHTMLControls.Count() &&
+ aHTMLControls[i]->nNdIdx < nStartIdx; i++ )
+ ;
+
+ if( !pStartNd )
+ {
+ // Check fuer einen einzelnen Node: da ist nur interessant, ob
+ // es zu dem Node ein Control gibt und zu welcher Form es gehoert
+ if( i < aHTMLControls.Count() &&
+ aHTMLControls[i]->nNdIdx == nStartIdx )
+ xNewFormComps = aHTMLControls[i]->xFormComps;
+ }
+ else
+ {
+ // wir klappern eine Tabelle/einen Bereich ab: hier interessiert uns:
+ // - ob es Controls mit unterschiedlichen Start-Nodes gibt
+ // - ob es eine Form gibt, fuer die nicht alle Controls in der
+ // Tabelle/dem Bereich liegen
+
+ Reference< container::XIndexContainer > xCurrentFormComps;// die aktuelle Form in der Tabelle
+ const SwStartNode *pCurrentStNd = 0; // und der Start-Node eines Ctrls
+ xub_StrLen nCurrentCtrls = 0; // und die in ihr gefundenen Controls
+ sal_uInt32 nEndIdx = pStartNd->EndOfSectionIndex();
+ for( ; i < aHTMLControls.Count() &&
+ aHTMLControls[i]->nNdIdx <= nEndIdx; i++ )
+ {
+ const SwStartNode *pCntrlStNd =
+ pDoc->GetNodes()[aHTMLControls[i]->nNdIdx]->FindStartNode();
+
+ if( xCurrentFormComps.is() )
+ {
+ // Wir befinden uns bereits in einer Form ...
+ if( xCurrentFormComps==aHTMLControls[i]->xFormComps )
+ {
+ // ... und das Control befindet sich auch darin ...
+ if( pCurrentStNd!=pCntrlStNd )
+ {
+ // ... aber es liegt in einer anderen Zelle:
+ // Dann muessen eir eine Form ueber der Tabelle
+ // aufmachen
+ xNewFormComps = xCurrentFormComps;
+ break;
+ }
+ nCurrentCtrls += aHTMLControls[i]->nCount;
+ }
+ else
+ {
+ // ... aber das Control liegt in einer anderen Zelle:
+ // Da tun wir so, als ob wir eine neue Form aufmachen
+ // und suchen weiter.
+ xCurrentFormComps = aHTMLControls[i]->xFormComps;
+ pCurrentStNd = pCntrlStNd;
+ nCurrentCtrls = aHTMLControls[i]->nCount;
+ }
+ }
+ else
+ {
+ // Wir befinden uns noch in keiner Form:
+ // Da tun wir mal so, als ob wie wir die Form aufmachen.
+ xCurrentFormComps = aHTMLControls[i]->xFormComps;
+ pCurrentStNd = pCntrlStNd;
+ nCurrentCtrls = aHTMLControls[i]->nCount;
+ }
+ }
+ if( !xNewFormComps.is() && xCurrentFormComps.is() &&
+ nCurrentCtrls != xCurrentFormComps->getCount() )
+ {
+ // In der Tablle/dem Bereich sollte eine Form aufgemacht werden,
+ // die nicht vollstaendig in der Tabelle liegt. Dan muessen
+ // wie die Form jetzt ebenfalls oeffen.
+ xNewFormComps = xCurrentFormComps;
+ }
+ }
+
+ if( xNewFormComps.is() &&
+ (!pxFormComps || !(xNewFormComps == *pxFormComps)) )
+ {
+ // Es soll eine Form aufgemacht werden ...
+ if( pxFormComps && pxFormComps->is() )
+ {
+ // .. es ist aber noch eine Form offen: Das ist in
+ // jedem Fall eine Fehler, aber wir schliessen die alte
+ // Form trotzdem
+ OutForm( sal_False, *pxFormComps );
+
+ //!!!nWarn = 1; // Control wird falscher Form zugeordnet
+ }
+
+ if( !pxFormComps )
+ pxFormComps = new Reference< container::XIndexContainer > ;
+ *pxFormComps = xNewFormComps;
+
+ OutForm( sal_True, *pxFormComps );
+ Reference< beans::XPropertySet > xTmp;
+ OutHiddenControls( *pxFormComps, xTmp );
+ }
+}
+
+void SwHTMLWriter::OutHiddenForms()
+{
+ // Ohne DrawModel kann es auch keine Controls geben. Dann darf man
+ // auch nicht per UNO auf das Dok zugreifen, weil sonst ein DrawModel
+ // angelegt wird.
+ if( !pDoc->GetDrawModel() )
+ return;
+
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( !pDocSh )
+ return;
+
+ Reference< drawing::XDrawPageSupplier > xDPSupp( pDocSh->GetBaseModel(),
+ UNO_QUERY );
+ ASSERT( xDPSupp.is(), "XTextDocument nicht vom XModel erhalten" );
+ Reference< drawing::XDrawPage > xDrawPage = xDPSupp->getDrawPage();
+
+ ASSERT( xDrawPage.is(), "XDrawPage nicht erhalten" );
+ if( !xDrawPage.is() )
+ return;
+
+ Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage, UNO_QUERY );
+ ASSERT( xFormsSupplier.is(),
+ "XFormsSupplier nicht vom XDrawPage erhalten" );
+
+ Reference< container::XNameContainer > xTmp = xFormsSupplier->getForms();
+ ASSERT( xTmp.is(), "XForms nicht erhalten" );
+ Reference< container::XIndexContainer > xForms( xTmp, UNO_QUERY );
+ ASSERT( xForms.is(), "XForms ohne container::XIndexContainer?" );
+
+ sal_Int32 nCount = xForms->getCount();
+ for( sal_Int32 i=0; i<nCount; i++)
+ {
+ Any aTmp = xForms->getByIndex( i );
+ ASSERT( aTmp.getValueType() ==
+ ::getCppuType((Reference< form::XForm >*)0),
+ "OutHiddenForms: falsche Reflection" );
+ if( aTmp.getValueType() ==
+ ::getCppuType((Reference< form::XForm >*)0) )
+ OutHiddenForm( *(Reference< form::XForm > *)aTmp.getValue() );
+ }
+}
+
+void SwHTMLWriter::OutHiddenForm( const Reference< form::XForm > & rForm )
+{
+ Reference< container::XIndexContainer > xFormComps( rForm, UNO_QUERY );
+ if( !xFormComps.is() )
+ return;
+
+ sal_Int32 nCount = xFormComps->getCount();
+ sal_Bool bHiddenOnly = nCount > 0, bHidden = sal_False;
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ Any aTmp = xFormComps->getByIndex( i );
+ ASSERT( aTmp.getValueType() ==
+ ::getCppuType((Reference<form::XFormComponent>*)0),
+ "OutHiddenForm: falsche Reflection" );
+ if( aTmp.getValueType() !=
+ ::getCppuType((Reference<form::XFormComponent>*)0) )
+ continue;
+
+ Reference< form::XFormComponent > xFormComp =
+ *(Reference< form::XFormComponent > *)aTmp.getValue();
+ Reference< form::XForm > xForm( xFormComp, UNO_QUERY );
+ if( xForm.is() )
+ OutHiddenForm( xForm );
+
+ if( bHiddenOnly )
+ {
+ Reference< beans::XPropertySet > xPropSet( xFormComp, UNO_QUERY );
+ OUString sPropName = OUString::createFromAscii( "ClassId" );
+ if( xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
+ {
+ Any aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((sal_Int16*)0) )
+ {
+ if( form::FormComponentType::HIDDENCONTROL ==
+ *(sal_Int16*)aTmp.getValue() )
+ bHidden = sal_True;
+ else if( lcl_html_isHTMLControl(
+ *(sal_Int16*)aTmp.getValue() ) )
+ bHiddenOnly = sal_False;
+ }
+ }
+ }
+ }
+
+ if( bHidden && bHiddenOnly )
+ {
+ OutForm( sal_True, xFormComps );
+ Reference< beans::XPropertySet > xTmp;
+ OutHiddenControls( xFormComps, xTmp );
+ OutForm( sal_False, xFormComps );
+ }
+}
+
+void SwHTMLWriter::OutForm( sal_Bool bOn,
+ const Reference< container::XIndexContainer > & rFormComps )
+{
+ nFormCntrlCnt = 0;
+
+ if( !bOn )
+ {
+ DecIndentLevel(); // Inhalt der Form einruecken
+ if( bLFPossible )
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_form, sal_False );
+ bLFPossible = sal_True;
+
+ return;
+ }
+
+ // die neue Form wird geoeffnet
+ if( bLFPossible )
+ OutNewLine();
+ ByteString sOut( '<' );
+ sOut += sHTML_form;
+
+ Reference< beans::XPropertySet > xFormPropSet( rFormComps, UNO_QUERY );
+
+ Any aTmp = xFormPropSet->getPropertyValue(
+ OUString::createFromAscii( "Name" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ ((sOut += ' ') += sHTML_O_name) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
+ eDestEnc );
+ sOut = '\"';
+ }
+
+ aTmp = xFormPropSet->getPropertyValue(
+ OUString::createFromAscii( "TargetURL" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ ((sOut += ' ') += sHTML_O_action) += "=\"";
+ Strm() << sOut.GetBuffer();
+ String aURL( *(OUString*)aTmp.getValue() );
+ aURL = INetURLObject::AbsToRel( aURL, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ HTMLOutFuncs::Out_String( Strm(), aURL, eDestEnc );
+ sOut = '\"';
+ }
+
+ aTmp = xFormPropSet->getPropertyValue(
+ OUString::createFromAscii( "SubmitMethod" ) );
+ if( aTmp.getValueType() == ::getCppuType((const form::FormSubmitMethod*)0) )
+ {
+ form::FormSubmitMethod eMethod =
+ *( form::FormSubmitMethod*)aTmp.getValue();
+ if( form::FormSubmitMethod_POST==eMethod )
+ {
+ ((((sOut += ' ')
+ += sHTML_O_method) += "=\"")
+ += sHTML_METHOD_post) += '\"';
+ }
+ }
+ aTmp = xFormPropSet->getPropertyValue(
+ OUString::createFromAscii( "SubmitEncoding" ) );
+ if( aTmp.getValueType()==::getCppuType((const form::FormSubmitEncoding*)0) )
+ {
+ form::FormSubmitEncoding eEncType =
+ *( form::FormSubmitEncoding*)aTmp.getValue();
+ const sal_Char *pStr = 0;
+ switch( eEncType )
+ {
+ case form::FormSubmitEncoding_MULTIPART:
+ pStr = sHTML_ET_multipart;
+ break;
+ case form::FormSubmitEncoding_TEXT:
+ pStr = sHTML_ET_text;
+ break;
+ }
+
+ if( pStr )
+ {
+ ((((sOut += ' ')
+ += sHTML_O_enctype) += "=\"")
+ += pStr) += '\"';
+ }
+ }
+
+ aTmp = xFormPropSet->getPropertyValue(
+ OUString::createFromAscii( "TargetFrame" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0)&&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ ((sOut += ' ') += sHTML_O_target) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
+ eDestEnc );
+ sOut = '\"';
+ }
+
+ Strm() << sOut.GetBuffer();
+ Reference< form::XFormComponent > xFormComp( rFormComps, UNO_QUERY );
+ lcl_html_outEvents( Strm(), xFormComp, bCfgStarBasic, eDestEnc );
+ Strm() << '>';
+
+ IncIndentLevel(); // Inhalt der Form einruecken
+ bLFPossible = sal_True;
+}
+
+void SwHTMLWriter::OutHiddenControls(
+ const Reference< container::XIndexContainer > & rFormComps,
+ const Reference< beans::XPropertySet > & rPropSet )
+{
+ sal_Int32 nCount = rFormComps->getCount();
+ sal_Int32 nPos = 0;
+ sal_Bool bDone = sal_False;
+ if( rPropSet.is() )
+ {
+ Reference< form::XFormComponent > xFC( rPropSet, UNO_QUERY );
+ for( nPos=0; !bDone && nPos < nCount; nPos++ )
+ {
+ Any aTmp = rFormComps->getByIndex( nPos );
+ ASSERT( aTmp.getValueType() ==
+ ::getCppuType((Reference< form::XFormComponent>*)0),
+ "OutHiddenControls: falsche Reflection" );
+ bDone = aTmp.getValueType() ==
+ ::getCppuType((Reference< form::XFormComponent>*)0) &&
+ *(Reference< form::XFormComponent > *)aTmp.getValue() ==
+ xFC;
+ }
+ }
+
+ for( ; nPos < nCount; nPos++ )
+ {
+ Any aTmp = rFormComps->getByIndex( nPos );
+ ASSERT( aTmp.getValueType() ==
+ ::getCppuType((Reference< form::XFormComponent>*)0),
+ "OutHiddenControls: falsche Reflection" );
+ if( aTmp.getValueType() !=
+ ::getCppuType((Reference< form::XFormComponent>*)0) )
+ continue;
+ Reference< form::XFormComponent > xFC =
+ *(Reference< form::XFormComponent > *)aTmp.getValue();
+ Reference< beans::XPropertySet > xPropSet( xFC, UNO_QUERY );
+
+ OUString sPropName = OUString::createFromAscii( "ClassId" );
+ if( !xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
+ continue;
+
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() != ::getCppuType((const sal_Int16*)0) )
+ continue;
+
+ if( form::FormComponentType::HIDDENCONTROL ==
+ *(sal_Int16*) aTmp.getValue() )
+ {
+ if( bLFPossible )
+ OutNewLine( sal_True );
+ ByteString sOut( '<' );
+ ((((sOut += sHTML_input) += ' ') +=
+ sHTML_O_type) += '=') += sHTML_IT_hidden;
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "Name" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ (( sOut += ' ' ) += sHTML_O_name ) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
+ eDestEnc );
+ sOut = '\"';
+ }
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "HiddenValue" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ ((sOut += ' ') += sHTML_O_value) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), *(OUString*)aTmp.getValue(),
+ eDestEnc );
+ sOut = '\"';
+ }
+ sOut += '>';
+ Strm() << sOut.GetBuffer();
+
+ nFormCntrlCnt++;
+ }
+ else if( lcl_html_isHTMLControl( *(sal_Int16*) aTmp.getValue() ) )
+ {
+ break;
+ }
+ }
+}
+
+/* */
+
+// hier folgen die Ausgabe-Routinen, dadurch sind die form::Forms gebuendelt:
+
+const SdrObject *SwHTMLWriter::GetHTMLControl( const SwDrawFrmFmt& rFmt )
+{
+ // es muss ein Draw-Format sein
+ ASSERT( RES_DRAWFRMFMT == rFmt.Which(),
+ "GetHTMLControl nuer fuer Draw-Formate erlaubt" );
+
+ // Schauen, ob es ein SdrObject dafuer gibt
+ const SdrObject *pObj = rFmt.FindSdrObject();
+ if( !pObj || FmFormInventor != pObj->GetObjInventor() )
+ return 0;
+
+ SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pObj );
+ Reference< awt::XControlModel > xControlModel =
+ pFormObj->GetUnoControlModel();
+
+ ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
+ if( !xControlModel.is() )
+ return 0;
+
+ Reference< beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY );
+
+ OUString sPropName = OUString::createFromAscii( "ClassId" );
+ if( !xPropSet->getPropertySetInfo()->hasPropertyByName( sPropName ) )
+ return 0;
+
+ Any aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0)&&
+ lcl_html_isHTMLControl( *(sal_Int16*) aTmp.getValue() ) )
+ {
+ return pObj;
+ }
+
+ return 0;
+}
+
+static void GetControlSize( const SdrObject& rSdrObj, Size& rSz,
+ SwDoc *pDoc )
+{
+ ViewShell *pVSh = 0;
+ pDoc->GetEditShell( &pVSh );
+ if( !pVSh )
+ return;
+
+ SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, &rSdrObj );
+ Reference< awt::XControl > xControl =
+ pFormObj->GetUnoControl( pVSh->GetWin() );
+ Reference< awt::XTextLayoutConstrains > xLC( xControl, UNO_QUERY );
+ ASSERT( xLC.is(), "kein XTextLayoutConstrains" );
+ if( !xLC.is() )
+ return;
+
+ sal_Int16 nCols=0, nLines=0;
+ xLC->getColumnsAndLines( nCols, nLines );
+ rSz.Width() = nCols;
+ rSz.Height() = nLines;
+}
+
+Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
+ const SwDrawFrmFmt& rFmt,
+ const SdrObject& rSdrObject,
+ sal_Bool bInCntnr )
+{
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, &rSdrObject );
+ Reference< awt::XControlModel > xControlModel =
+ pFormObj->GetUnoControlModel();
+
+ ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
+ if( !xControlModel.is() )
+ return rWrt;
+
+ Reference< beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY );
+
+//!!! if( rHTMLWrt.pForm != pVCSbxCtrl->GetVCForm() )
+//!!! rHTMLWrt.nWarn = 1; // Control wird falscher Form zugeordnet
+ rHTMLWrt.nFormCntrlCnt++;
+
+ const sal_Char *pTag = sHTML_input, *pType = 0;
+ OUString sValue;
+ ByteString sOptions;
+ sal_Bool bEmptyValue = sal_False;
+ Any aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "ClassId" ) );
+ sal_Int16 nClassId = *(sal_Int16*) aTmp.getValue();
+ sal_uInt32 nFrmOpts = HTML_FRMOPTS_CONTROL;
+ switch( nClassId )
+ {
+ case form::FormComponentType::CHECKBOX:
+ case form::FormComponentType::RADIOBUTTON:
+ pType = (form::FormComponentType::CHECKBOX == nClassId
+ ? sHTML_IT_checkbox
+ : sHTML_IT_radio);
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "DefaultState" ) );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) &&
+ STATE_NOCHECK != *(sal_Int16*) aTmp.getValue() )
+ {
+ (sOptions += ' ') += sHTML_O_checked;
+ }
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "RefValue" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) )
+
+ {
+ const OUString& rVal = *(OUString*)aTmp.getValue();
+ if( !rVal.len() )
+ bEmptyValue = sal_True;
+ else if( rVal.compareToAscii( sHTML_on ) != 0 )
+ sValue = rVal;
+ }
+ break;
+
+ case form::FormComponentType::COMMANDBUTTON:
+ {
+ form::FormButtonType eButtonType = form::FormButtonType_PUSH;
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "ButtonType" ) );
+ if( aTmp.getValueType() ==
+ ::getCppuType((const form::FormButtonType*)0) )
+ eButtonType = *( form::FormButtonType*)aTmp.getValue();
+
+ switch( eButtonType )
+ {
+ case form::FormButtonType_RESET:
+ pType = sHTML_IT_reset;
+ break;
+ case form::FormButtonType_SUBMIT:
+ pType = sHTML_IT_submit;
+ break;
+ case form::FormButtonType_PUSH:
+ default:
+ pType = sHTML_IT_button;
+ }
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "Label" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ sValue = *(OUString*)aTmp.getValue();
+ }
+ }
+ break;
+
+ case form::FormComponentType::LISTBOX:
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( sal_True );
+ pTag = sHTML_select;
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "Dropdown" ) );
+ if( aTmp.getValueType() == ::getBooleanCppuType() &&
+ !*(sal_Bool*)aTmp.getValue() )
+ {
+ Size aSz( 0, 0 );
+ GetControlSize( rSdrObject, aSz, rWrt.pDoc );
+
+ // wieviele sind sichtbar ??
+ if( aSz.Height() )
+ (((sOptions += ' ' ) += sHTML_O_size ) += '=' )
+ += ByteString::CreateFromInt32( aSz.Height() );
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "MultiSelection" ) );
+ if( aTmp.getValueType() == ::getBooleanCppuType() &&
+ *(sal_Bool*)aTmp.getValue() )
+ {
+ (sOptions += ' ' ) += sHTML_O_multiple;
+ }
+ }
+ break;
+
+ case form::FormComponentType::TEXTFIELD:
+ {
+ Size aSz( 0, 0 );
+ GetControlSize( rSdrObject, aSz, rWrt.pDoc );
+
+ sal_Bool bMultiLine = sal_False;
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "MultiLine" ) );
+ bMultiLine = aTmp.getValueType() == ::getBooleanCppuType() &&
+ *(sal_Bool*)aTmp.getValue();
+
+ if( bMultiLine )
+ {
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( sal_True );
+ pTag = sHTML_textarea;
+
+ if( aSz.Height() )
+ (((sOptions += ' ' ) += sHTML_O_rows ) += '=' )
+ += ByteString::CreateFromInt32( aSz.Height() );
+ if( aSz.Width() )
+ (((sOptions += ' ' ) += sHTML_O_cols ) += '=' )
+ += ByteString::CreateFromInt32( aSz.Width() );
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "HScroll" ) );
+ if( aTmp.getValueType() == ::getVoidCppuType() ||
+ (aTmp.getValueType() == ::getBooleanCppuType() &&
+ !*(sal_Bool*)aTmp.getValue()) )
+ {
+ const sal_Char *pWrapStr = 0;
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "HardLineBreaks" ) );
+ pWrapStr =
+ (aTmp.getValueType() == ::getBooleanCppuType() &&
+ *(sal_Bool*)aTmp.getValue()) ? sHTML_WW_hard
+ : sHTML_WW_soft;
+ (((sOptions += ' ') += sHTML_O_wrap) += '=') += pWrapStr;
+ }
+ }
+ else
+ {
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "EchoChar" ) );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) &&
+ *(sal_Int16*)aTmp.getValue() != 0 )
+ pType = sHTML_IT_password;
+ else
+ pType = sHTML_IT_text;
+
+ if( aSz.Width() )
+ (((sOptions += ' ' ) += sHTML_O_size ) += '=' )
+ += ByteString::CreateFromInt32( aSz.Width() );
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "MaxTextLen" ) );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) &&
+ *(sal_Int16*) aTmp.getValue() != 0 )
+ {
+ (((sOptions += ' ' ) += sHTML_O_maxlength ) += '=' )
+ += ByteString::CreateFromInt32(
+ *(sal_Int16*) aTmp.getValue() );
+ }
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "DefaultText" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ sValue = *(OUString*)aTmp.getValue();
+ }
+ }
+ }
+ break;
+
+ case form::FormComponentType::FILECONTROL:
+ {
+ Size aSz( 0, 0 );
+ GetControlSize( rSdrObject, aSz, rWrt.pDoc );
+ pType = sHTML_IT_file;
+
+ if( aSz.Width() )
+ (((sOptions += ' ' ) += sHTML_O_size ) += '=' )
+ += ByteString::CreateFromInt32( aSz.Width() );
+
+ // VALUE vim form aus Sicherheitsgruenden nicht exportieren
+ }
+ break;
+
+
+ case form::FormComponentType::IMAGEBUTTON:
+ pType = sHTML_IT_image;
+ nFrmOpts = HTML_FRMOPTS_IMG_CONTROL;
+ break;
+
+#if 0
+ case FORMCOMPONENT_URLBUTTON:
+ {
+ // in einen Hyperlink wandeln
+ ((((sOut = '<') += sHTML_anchor) += ' ' ) += sHTML_O_href )
+ += "=\"";
+ rWrt.Strm() << sOut.GetStr();
+ HTMLOutFuncs::Out_String( rWrt.Strm(),
+ INetURLObject::AbsToRel( ((VCURLButton*)pVCSbxCtrl)->GetURL(),
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET),
+ rHTMLWrt.eDestEnc, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ const String& rTarget =
+ ((VCURLButton*)pVCSbxCtrl)->GetTargetFrame();
+ if( rTarget.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_target) += "=\"";
+ rWrt.Strm() << sOut.GetStr();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rTarget,
+ rHTMLWrt.eDestEnc, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ sOut += ">";
+ rWrt.Strm() << sOut.GetStr();
+
+ HTMLOutFuncs::Out_String( rWrt.Strm(),
+ ((VCURLButton*)pVCSbxCtrl)->GetText(),
+ rHTMLWrt.eDestEnc, rHTMLWrt.eDestEnc );
+ HTMLOutFuncs::Out_Tag( rWrt.Strm(), sHTML_anchor, sal_False ) << ' ';
+ }
+ break;
+#endif
+ default: // kennt HTML nicht
+ pTag = 0; // also ueberspringen
+ break;
+ }
+
+ if( !pTag )
+ return rWrt;
+
+ ByteString sOut( '<' );
+ sOut += pTag;
+ if( pType )
+ (((sOut += ' ') += sHTML_O_type) += '=') += pType;
+
+ aTmp = xPropSet->getPropertyValue( OUString::createFromAscii( "Name" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ (( sOut += ' ' ) += sHTML_O_name ) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), *(OUString*)aTmp.getValue(),
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ aTmp = xPropSet->getPropertyValue( OUString::createFromAscii( "Enabled" ) );
+ if( aTmp.getValueType() == ::getBooleanCppuType() &&
+ !*(sal_Bool*)aTmp.getValue() )
+ {
+ (( sOut += ' ' ) += sHTML_O_disabled );
+ }
+
+ if( sValue.getLength() || bEmptyValue )
+ {
+ ((sOut += ' ') += sHTML_O_value) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sValue, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ sOut += sOptions;
+
+ if( sHTML_IT_image == pType )
+ {
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "ImageURL" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ ((sOut += ' ') += sHTML_O_src) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+
+ HTMLOutFuncs::Out_String( rWrt.Strm(),
+ INetURLObject::AbsToRel( *(OUString*)aTmp.getValue(),
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET ),
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ Size aTwipSz( rSdrObject.GetLogicRect().GetSize() );
+ Size aPixelSz( 0, 0 );
+ if( (aTwipSz.Width() || aTwipSz.Height()) &&
+ Application::GetDefaultDevice() )
+ {
+ aPixelSz =
+ Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
+ MapMode(MAP_TWIP) );
+ if( !aPixelSz.Width() && aTwipSz.Width() )
+ aPixelSz.Width() = 1;
+ if( !aPixelSz.Height() && aTwipSz.Height() )
+ aPixelSz.Height() = 1;
+ }
+
+ if( aPixelSz.Width() )
+ (((sOut += ' ') += sHTML_O_width) += '=')
+ += ByteString::CreateFromInt32( aPixelSz.Width() );
+
+ if( aPixelSz.Height() )
+ (((sOut += ' ') += sHTML_O_height) += '=')
+ += ByteString::CreateFromInt32( aPixelSz.Height() );
+ }
+
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "TabIndex" ) );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) )
+ {
+ sal_Int16 nTabIndex = *(sal_Int16*) aTmp.getValue();
+ if( nTabIndex > 0 )
+ {
+ if( nTabIndex >= 32767 )
+ nTabIndex = 32767;
+
+ (((sOut += ' ') += sHTML_O_tabindex) += '=')
+ += ByteString::CreateFromInt32( nTabIndex );
+ }
+ }
+
+ if( sOut.Len() )
+ {
+ rWrt.Strm() << sOut.GetBuffer();
+ sOut.Erase();
+ }
+
+ ASSERT( !bInCntnr, "Container wird fuer Controls nicht unterstuertzt" );
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) && !bInCntnr )
+ {
+ // Wenn Zeichen-Objekte nicht absolut positioniert werden duerfen,
+ // das entsprechende Flag loeschen.
+ nFrmOpts |= (sHTML_IT_image == pType
+ ? HTML_FRMOPTS_IMG_CONTROL_CSS1
+ : HTML_FRMOPTS_CONTROL_CSS1);
+ }
+ ByteString aEndTags;
+ if( nFrmOpts != 0 )
+ rHTMLWrt.OutFrmFmtOptions( rFmt, aEmptyStr, aEndTags, nFrmOpts );
+
+ if( rHTMLWrt.bCfgOutStyles )
+ {
+ sal_Bool bEdit = sHTML_textarea == pTag || sHTML_IT_file == pType ||
+ sHTML_IT_text == pType;
+
+ Reference< beans::XPropertySetInfo > xPropSetInfo =
+ xPropSet->getPropertySetInfo();
+ SfxItemSet aItemSet( rHTMLWrt.pDoc->GetAttrPool(), RES_CHRATR_BEGIN,
+ RES_CHRATR_END );
+ OUString sPropName = OUString::createFromAscii( "BackgroundColor" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int32*)0) )
+ {
+ Color aCol(*(sal_Int32*)aTmp .getValue());
+ aItemSet.Put( SvxBrushItem( aCol, RES_CHRATR_BACKGROUND ) );
+ }
+ }
+ sPropName = OUString::createFromAscii( "TextColor" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int32*)0) )
+ {
+ Color aColor( *(sal_Int32*)aTmp .getValue() );
+ aItemSet.Put( SvxColorItem( aColor ) );
+ }
+ }
+ sPropName = OUString::createFromAscii( "FontHeight" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const Float*)0) )
+
+ {
+ float nHeight = *(float*)aTmp.getValue();
+ if( nHeight > 0 && (!bEdit || nHeight != 10.) )
+ aItemSet.Put( SvxFontHeightItem( sal_Int16(nHeight * 20.) ) );
+ }
+ }
+ sPropName = OUString::createFromAscii( "FontName" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ Font aFixedFont( System::GetStandardFont( STDFONT_FIXED ) );
+ String aFName( *(OUString*)aTmp.getValue() );
+ if( !bEdit || aFName != aFixedFont.GetName() )
+ {
+ FontFamily eFamily = FAMILY_DONTKNOW;
+ sPropName = OUString::createFromAscii( "FontFamily" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0))
+ eFamily = (FontFamily)*(sal_Int16*) aTmp.getValue();
+ }
+ SvxFontItem aItem( eFamily, aFName, aEmptyStr );
+ aItemSet.Put( aItem );
+ }
+ }
+ }
+ sPropName = OUString::createFromAscii( "FontWeight" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const Float*)0) )
+ {
+ FontWeight eWeight =
+ VCLUnoHelper::ConvertFontWeight( *(float*)aTmp.getValue() );
+ if( eWeight != WEIGHT_DONTKNOW && eWeight != WEIGHT_NORMAL )
+ aItemSet.Put( SvxWeightItem( eWeight ) );
+ }
+ }
+ sPropName = OUString::createFromAscii( "FontSlant" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0))
+ {
+ FontItalic eItalic = (FontItalic)*(sal_Int16*)aTmp.getValue();
+ if( eItalic != ITALIC_DONTKNOW && eItalic != ITALIC_NONE )
+ aItemSet.Put( SvxPostureItem( eItalic ) );
+ }
+ }
+ sPropName = OUString::createFromAscii( "FontUnderline" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0) )
+ {
+ FontUnderline eUnderline =
+ (FontUnderline)*(sal_Int16*)aTmp.getValue();
+ if( eUnderline != UNDERLINE_DONTKNOW &&
+ eUnderline != UNDERLINE_NONE )
+ aItemSet.Put( SvxUnderlineItem( eUnderline ) );
+ }
+ }
+ sPropName = OUString::createFromAscii( "FontStrikeout" );
+ if( xPropSetInfo->hasPropertyByName( sPropName ) )
+ {
+ aTmp = xPropSet->getPropertyValue( sPropName );
+ if( aTmp.getValueType() == ::getCppuType((const sal_Int16*)0))
+ {
+ FontStrikeout eStrikeout =
+ (FontStrikeout)*(sal_Int16*)aTmp.getValue();
+ if( eStrikeout != STRIKEOUT_DONTKNOW &&
+ eStrikeout != STRIKEOUT_NONE )
+ aItemSet.Put( SvxCrossedOutItem( eStrikeout ) );
+ }
+ }
+
+ rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmOpts, &rSdrObject,
+ &aItemSet );
+ }
+
+ Reference< form::XFormComponent > xFormComp( xControlModel, UNO_QUERY );
+ lcl_html_outEvents( rWrt.Strm(), xFormComp, rHTMLWrt.bCfgStarBasic,
+ rHTMLWrt.eDestEnc );
+
+ rWrt.Strm() << '>';
+
+ if( sHTML_select == pTag )
+ {
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "StringItemList" ) );
+ if( aTmp.getValueType() == ::getCppuType((Sequence<OUString>*)0) )
+ {
+ rHTMLWrt.IncIndentLevel(); // der Inhalt von Select darf
+ // eingerueckt werden
+ Sequence<OUString> aList( *(Sequence<OUString>*)aTmp.getValue() );
+ sal_Int32 nCnt = aList.getLength();
+ const OUString *pStrings = aList.getConstArray();
+
+ const OUString *pValues = 0;
+ sal_Int32 nValCnt = 0;
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "ListSource" ) );
+ Sequence<OUString> aValList;
+ if( aTmp.getValueType() == ::getCppuType((Sequence<OUString>*)0) )
+ {
+ aValList = *(Sequence<OUString>*)aTmp.getValue();
+ nValCnt = aValList.getLength();
+ pValues = aValList.getConstArray();
+ }
+
+ Any aSelTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "DefaultSelection" ) );
+ const sal_Int16 *pSels = 0;
+ sal_Int32 nSel = 0;
+ sal_Int32 nSelCnt = 0;
+ Sequence<sal_Int16> aSelList;
+ if( aSelTmp.getValueType() ==::getCppuType((Sequence<sal_Int16>*)0))
+ {
+ aSelList = *(Sequence<sal_Int16>*)aSelTmp.getValue();
+ nSelCnt = aSelList.getLength();
+ pSels = aSelList.getConstArray();
+ }
+
+ for( sal_Int32 i = 0; i < nCnt; i++ )
+ {
+ OUString sValue;
+ sal_Bool bSelected = sal_False, bEmptyVal = sal_False;
+ if( i < nValCnt )
+ {
+ const OUString& rVal = pValues[i];
+ if( rVal.compareToAscii( "$$$empty$$$" ) == 0 )
+ bEmptyVal = sal_True;
+ else
+ sValue = rVal;
+ }
+
+ bSelected = (nSel < nSelCnt) && pSels[nSel] == i;
+ if( bSelected )
+ nSel++;
+
+ rHTMLWrt.OutNewLine(); // jede Option bekommt eine eigene Zeile
+ (sOut = '<') += sHTML_option;
+ if( sValue.getLength() || bEmptyVal )
+ {
+ ((sOut += ' ') += sHTML_O_value) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sValue,
+ rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ if( bSelected )
+ (sOut += ' ') += sHTML_O_selected;
+
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+
+ HTMLOutFuncs::Out_String( rWrt.Strm(), pStrings[i],
+ rHTMLWrt.eDestEnc );
+ }
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_option, sal_False );
+
+ rHTMLWrt.DecIndentLevel();
+ rHTMLWrt.OutNewLine();// das </SELECT> bekommt eine eigene Zeile
+ }
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_select, sal_False );
+ }
+ else if( sHTML_textarea == pTag )
+ {
+ // In TextAreas duerfen keine zusaetzlichen Spaces oder LF exportiert
+ // werden!
+ String sValue;
+ aTmp = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "DefaultText" ) );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0)&&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ sValue = String( *(OUString*)aTmp.getValue() );
+ }
+ if( sValue.Len() )
+ {
+ sValue.ConvertLineEnd( LINEEND_LF );
+ xub_StrLen nPos = 0;
+ while ( nPos != STRING_NOTFOUND )
+ {
+ if( nPos )
+ rWrt.Strm() << SwHTMLWriter::sNewLine;
+ String aLine = sValue.GetToken( 0, 0x0A, nPos );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aLine,
+ rHTMLWrt.eDestEnc );
+ }
+ }
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_textarea, sal_False );
+ }
+ else if( sHTML_IT_checkbox == pType || sHTML_IT_radio == pType )
+ {
+ aTmp = xPropSet->getPropertyValue( OUString::createFromAscii("Label") );
+ if( aTmp.getValueType() == ::getCppuType((const OUString*)0) &&
+ ((OUString*)aTmp.getValue())->getLength() )
+ {
+ sValue = *(OUString*)aTmp.getValue();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sValue,
+ rHTMLWrt.eDestEnc ) << ' ';
+ }
+ }
+
+ if( aEndTags.Len() )
+ rWrt.Strm() << aEndTags.GetBuffer();
+
+ // Controls sind nicht absatz-gebunden, deshalb kein LF mehr ausgeben!
+ rHTMLWrt.bLFPossible = sal_False;
+
+ if( rHTMLWrt.pxFormComps && rHTMLWrt.pxFormComps->is() )
+ rHTMLWrt.OutHiddenControls( *rHTMLWrt.pxFormComps, xPropSet );
+ return rWrt;
+}
+
+/* */
+
+// Ermitteln, ob eine Format zu einem Control gehoert und wenn ja
+// dessen Form zurueckgeben
+static void AddControl( HTMLControls& rControls,
+ const SdrObject *pSdrObj,
+ sal_uInt32 nNodeIdx )
+{
+ SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pSdrObj );
+ ASSERT( pFormObj, "Doch kein FormObj" );
+ Reference< awt::XControlModel > xControlModel =
+ pFormObj->GetUnoControlModel();
+ if( !xControlModel.is() )
+ return;
+
+ Reference< form::XFormComponent > xFormComp( xControlModel, UNO_QUERY );
+ Reference< XInterface > xIfc = xFormComp->getParent();
+ Reference< form::XForm > xForm(xIfc, UNO_QUERY);
+
+ ASSERT( xForm.is(), "Wo ist die Form?" );
+ if( xForm.is() )
+ {
+ Reference< container::XIndexContainer > xFormComps( xForm, UNO_QUERY );
+ HTMLControl *pHCntrl = new HTMLControl( xFormComps, nNodeIdx );
+ if( !rControls.C40_PTR_INSERT( HTMLControl, pHCntrl ) )
+ {
+ sal_uInt16 nPos = 0;
+ if( rControls.Seek_Entry(pHCntrl,&nPos) &&
+ rControls[nPos]->xFormComps==xFormComps )
+ rControls[nPos]->nCount++;
+ delete pHCntrl;
+ }
+ }
+}
+
+
+void SwHTMLWriter::GetControls()
+{
+ // Idee: die absatz- und zeichengebundenen Controls werden erst einmal
+ // eingesammelt. Dabei wird fuer jedes Control des Absatz-Position
+ // und VCForm in einem Array gemerkt.
+ // Ueber dieses Array laesst sich dann feststellen, wo form::Forms geoeffnet
+ // und geschlossen werden muessen.
+ sal_uInt16 i;
+ if( pHTMLPosFlyFrms )
+ {
+ // die absatz-gebundenen Controls einsammeln
+ for( i=0; i<pHTMLPosFlyFrms->Count(); i++ )
+ {
+ const SwHTMLPosFlyFrm* pPosFlyFrm = pHTMLPosFlyFrms->GetObject( i );
+ if( HTML_OUT_CONTROL != pPosFlyFrm->GetOutFn() )
+ continue;
+
+ const SdrObject *pSdrObj = pPosFlyFrm->GetSdrObject();
+ ASSERT( pSdrObj, "Wo ist das SdrObject?" );
+ if( !pSdrObj )
+ continue;
+
+ AddControl( aHTMLControls, pSdrObj,
+ pPosFlyFrm->GetNdIndex().GetIndex() );
+ }
+ }
+
+ // und jetzt die in einem zeichengebundenen Rahmen
+ const SwSpzFrmFmts* pSpzFrmFmts = pDoc->GetSpzFrmFmts();
+ for( i=0; i<pSpzFrmFmts->Count(); i++ )
+ {
+ const SwFrmFmt *pFrmFmt = (*pSpzFrmFmts)[i];
+ if( RES_DRAWFRMFMT != pFrmFmt->Which() )
+ continue;
+
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ const SwPosition *pPos = rAnchor.GetCntntAnchor();
+ if( FLY_IN_CNTNT != rAnchor.GetAnchorId() || !pPos )
+ continue;
+
+ const SdrObject *pSdrObj =
+ SwHTMLWriter::GetHTMLControl( *(const SwDrawFrmFmt*)pFrmFmt );
+ if( !pSdrObj )
+ continue;
+
+ AddControl( aHTMLControls, pSdrObj, pPos->nNode.GetIndex() );
+ }
+}
+
+/* */
+
+HTMLControl::HTMLControl(
+ const Reference< container::XIndexContainer > & rFormComps,
+ sal_uInt32 nIdx ) :
+ xFormComps( rFormComps ), nNdIdx( nIdx ), nCount( 1 )
+{}
+
+
+HTMLControl::~HTMLControl()
+{}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlforw.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.77 2000/09/18 16:04:45 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.76 2000/08/18 13:03:18 jp
+ don't export escaped URLs
+
+ Revision 1.75 2000/06/26 09:52:10 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.74 2000/04/28 14:29:11 mib
+ unicode
+
+ Revision 1.73 2000/04/11 10:46:30 mib
+ unicode
+
+ Revision 1.72 2000/03/31 06:16:25 os
+ UNO III: toolkit includes
+
+ Revision 1.71 2000/03/30 07:31:01 os
+ UNO III
+
+ Revision 1.70 2000/03/21 15:06:17 os
+ UNOIII
+
+ Revision 1.69 2000/03/03 15:21:00 os
+ StarView remainders removed
+
+ Revision 1.68 2000/02/14 13:59:45 mib
+ #70473#: unicode
+
+ Revision 1.67 2000/02/10 09:51:54 mib
+ #68571#: text/plain encoding for submit
+
+ Revision 1.66 1999/11/22 14:25:04 os
+ headers added
+
+ Revision 1.65 1999/11/19 16:40:20 os
+ modules renamed
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx
new file mode 100644
index 000000000000..7ce227737f62
--- /dev/null
+++ b/sw/source/filter/html/htmlftn.cxx
@@ -0,0 +1,689 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlftn.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+
+#ifndef _ERRHDL_HXX //autogen
+#include <errhdl.hxx>
+#endif
+#ifndef _NDINDEX_HXX //autogen
+#include <ndindex.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _TXTFTN_HXX //autogen
+#include <txtftn.hxx>
+#endif
+#ifndef _FTNINFO_HXX //autogen
+#include <ftninfo.hxx>
+#endif
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen
+#include <ndtxt.hxx>
+#endif
+
+#include "swhtml.hxx"
+#include "wrthtml.hxx"
+
+typedef SwTxtFtn *SwTxtFtnPtr;
+SV_DECL_PTRARR( SwHTMLTxtFtns, SwTxtFtnPtr, 1, 1 )
+
+struct SwHTMLFootEndNote_Impl
+{
+ SwHTMLTxtFtns aTxtFtns;
+ SvStringsDtor aNames;
+
+ String sName;
+ String sContent; // Infos fuer die letzte Fussnote
+ BOOL bEndNote;
+ BOOL bFixed;
+};
+
+
+xub_StrLen lcl_html_getNextPart( String& rPart, const String& rContent,
+ xub_StrLen nPos )
+{
+ rPart = aEmptyStr;
+ xub_StrLen nLen = rContent.Len();
+ if( nPos >= nLen )
+ {
+ nPos = STRING_MAXLEN;
+ }
+ else
+ {
+ BOOL bQuoted = FALSE, bDone = FALSE;
+ for( ; nPos < nLen && !bDone; nPos++ )
+ {
+ sal_Unicode c = rContent.GetChar( nPos );
+ switch( c )
+ {
+ case '\\':
+ if( bQuoted )
+ rPart += c;
+ bQuoted = !bQuoted;
+ break;
+
+ case ';':
+ if( bQuoted )
+ rPart += c;
+ else
+ bDone = TRUE;
+ bQuoted = FALSE;
+ break;
+
+ default:
+ rPart += c;
+ bQuoted = FALSE;
+ break;
+ }
+ }
+ }
+
+ return nPos;
+}
+
+xub_StrLen lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
+ const String& rContent,
+ BOOL bEndNote )
+{
+ xub_StrLen nStrPos = 0;
+ for( USHORT nPart = 0; nPart < 4; nPart++ )
+ {
+ String aPart;
+ if( STRING_MAXLEN != nStrPos )
+ nStrPos = lcl_html_getNextPart( aPart, rContent, nStrPos );
+
+ switch( nPart )
+ {
+ case 0:
+ rInfo.aFmt.eType = bEndNote ? SVX_NUM_ROMAN_LOWER : SVX_NUM_ARABIC;
+ if( aPart.Len() )
+ rInfo.aFmt.eType = (SvxExtNumType)SwHTMLParser::GetNumType( aPart,
+ rInfo.aFmt.eType );
+ break;
+
+ case 1:
+ rInfo.nFtnOffset = aPart.Len() == 0 ? 0 : (USHORT)aPart.ToInt32();
+ break;
+
+ case 2:
+ rInfo.SetPrefix( aPart );
+ break;
+
+ case 3:
+ rInfo.SetSuffix( aPart );
+ break;
+ }
+ }
+
+ return nStrPos;
+}
+
+void SwHTMLParser::FillEndNoteInfo( const String& rContent )
+{
+ SwEndNoteInfo aInfo( pDoc->GetEndNoteInfo() );
+ lcl_html_getEndNoteInfo( aInfo, rContent, TRUE );
+ pDoc->SetEndNoteInfo( aInfo );
+}
+
+void SwHTMLParser::FillFootNoteInfo( const String& rContent )
+{
+ SwFtnInfo aInfo( pDoc->GetFtnInfo() );
+
+ xub_StrLen nStrPos = lcl_html_getEndNoteInfo( aInfo, rContent, FALSE );
+
+ for( USHORT nPart = 4; nPart < 8; nPart++ )
+ {
+ String aPart;
+ if( STRING_MAXLEN != nStrPos )
+ nStrPos = lcl_html_getNextPart( aPart, rContent, nStrPos );
+
+ switch( nPart )
+ {
+ case 4:
+ aInfo.eNum = FTNNUM_DOC;
+ if( aPart.Len() )
+ {
+ switch( aPart.GetChar(0) )
+ {
+ case 'D': aInfo.eNum = FTNNUM_DOC; break;
+ case 'C': aInfo.eNum = FTNNUM_CHAPTER; break;
+ case 'P': aInfo.eNum = FTNNUM_PAGE; break;
+ }
+ }
+ break;
+
+ case 5:
+ aInfo.ePos = FTNPOS_PAGE;
+ if( aPart.Len() )
+ {
+ switch( aPart.GetChar(0) )
+ {
+ case 'C': aInfo.ePos = FTNPOS_CHAPTER; break;
+ case 'P': aInfo.ePos = FTNPOS_PAGE; break;
+ }
+ }
+ break;
+
+ case 6:
+ aInfo.aQuoVadis = aPart;
+ break;
+
+ case 7:
+ aInfo.aErgoSum = aPart;
+ break;
+ }
+ }
+
+ pDoc->SetFtnInfo( aInfo );
+}
+
+void SwHTMLParser::InsertFootEndNote( const String& rName, BOOL bEndNote,
+ BOOL bFixed )
+{
+ if( !pFootEndNoteImpl )
+ pFootEndNoteImpl = new SwHTMLFootEndNote_Impl;
+
+ pFootEndNoteImpl->sName = rName;
+ if( pFootEndNoteImpl->sName.Len() > 3 )
+ pFootEndNoteImpl->sName.Erase( pFootEndNoteImpl->sName.Len() - 3 );
+ // TODO: ToUpperAscii???
+ pFootEndNoteImpl->sName.ToUpperAscii();
+
+ pFootEndNoteImpl->bEndNote = bEndNote;
+ pFootEndNoteImpl->bFixed = bFixed;
+ pFootEndNoteImpl->sContent = aEmptyStr;
+}
+
+void SwHTMLParser::FinishFootEndNote()
+{
+ if( !pFootEndNoteImpl )
+ return;
+
+ SwFmtFtn aFtn( pFootEndNoteImpl->bEndNote );
+ if( pFootEndNoteImpl->bFixed )
+ aFtn.SetNumStr( pFootEndNoteImpl->sContent );
+
+ pDoc->Insert( *pPam, aFtn );
+ SwTxtFtn *pTxtFtn =
+ (SwTxtFtn *)pPam->GetNode()->GetTxtNode()->GetTxtAttr(
+ pPam->GetPoint()->nContent.GetIndex() - 1,
+ RES_TXTATR_FTN );
+ // In Kopf- und Fusszeilen duerfen keine Fussnoten eingefuegt werden.
+ if( pTxtFtn )
+ {
+ pFootEndNoteImpl->aTxtFtns.Insert( pTxtFtn,
+ pFootEndNoteImpl->aTxtFtns.Count() );
+
+ pFootEndNoteImpl->aNames.Insert( new String(pFootEndNoteImpl->sName),
+ pFootEndNoteImpl->aNames.Count() );
+ }
+ pFootEndNoteImpl->sName = aEmptyStr;
+ pFootEndNoteImpl->sContent = aEmptyStr;
+ pFootEndNoteImpl->bFixed = FALSE;
+}
+
+void SwHTMLParser::InsertFootEndNoteText()
+{
+ if( pFootEndNoteImpl && pFootEndNoteImpl->bFixed )
+ pFootEndNoteImpl->sContent += aToken;
+}
+
+void SwHTMLParser::DeleteFootEndNoteImpl()
+{
+ delete pFootEndNoteImpl;
+ pFootEndNoteImpl = 0;
+}
+
+SwNodeIndex *SwHTMLParser::GetFootEndNoteSection( const String& rName )
+{
+ SwNodeIndex *pSttNdIdx = 0;
+
+ if( pFootEndNoteImpl )
+ {
+ String aName( rName );
+ // TODO: ToUpperAscii
+ aName.ToUpperAscii();
+
+ USHORT nCount = pFootEndNoteImpl->aNames.Count();
+ for( USHORT i=0; i<nCount; i++ )
+ {
+ if( *pFootEndNoteImpl->aNames[i] == aName )
+ {
+ pSttNdIdx = pFootEndNoteImpl->aTxtFtns[i]->GetStartNode();
+ pFootEndNoteImpl->aNames.DeleteAndDestroy( i, 1 );
+ pFootEndNoteImpl->aTxtFtns.Remove( i, 1 );
+ if( !pFootEndNoteImpl->aNames.Count() )
+ {
+ delete pFootEndNoteImpl;
+ pFootEndNoteImpl = 0;
+ }
+
+ break;
+ }
+ }
+ }
+
+ return pSttNdIdx;
+}
+
+Writer& OutHTML_SwFmtFtn( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ SwFmtFtn& rFmtFtn = (SwFmtFtn&)rHt;
+ SwTxtFtn *pTxtFtn = rFmtFtn.GetTxtFtn();
+ if( !pTxtFtn )
+ return rWrt;
+
+ String sFtnName, sClass;
+ USHORT nPos;
+ if( rFmtFtn.IsEndNote() )
+ {
+ nPos = rHTMLWrt.pFootEndNotes ? rHTMLWrt.pFootEndNotes->Count() : 0;
+ ASSERT( nPos == rHTMLWrt.nFootNote + rHTMLWrt.nEndNote,
+ "OutHTML_SwFmtFtn: Position falsch" );
+ sClass.AssignAscii( sHTML_sdendnote_anc );
+ sFtnName.AssignAscii( sHTML_sdendnote );
+ sFtnName += String::CreateFromInt32( (sal_Int32)(++rHTMLWrt.nEndNote) );
+ }
+ else
+ {
+ nPos = rHTMLWrt.nFootNote;
+ sClass.AssignAscii( sHTML_sdfootnote_anc );
+ sFtnName.AssignAscii( sHTML_sdfootnote);
+ sFtnName += String::CreateFromInt32( (sal_Int32)(++rHTMLWrt.nFootNote));
+ }
+
+ if( !rHTMLWrt.pFootEndNotes )
+ rHTMLWrt.pFootEndNotes = new SwHTMLTxtFtns;
+ rHTMLWrt.pFootEndNotes->Insert( pTxtFtn, nPos );
+
+ ByteString sOut( '<' );
+ (((sOut += sHTML_anchor) += ' ') += sHTML_O_class) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sClass, rHTMLWrt.eDestEnc );
+ ((sOut += "\" ") += sHTML_O_name) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sFtnName, rHTMLWrt.eDestEnc );
+ (((sOut += sHTML_FTN_anchor) += "\" ") += sHTML_O_href) += "=\"#";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sFtnName, rHTMLWrt.eDestEnc );
+ (sOut += sHTML_FTN_symbol)+= '\"';
+ if( rFmtFtn.GetNumStr().Len() )
+ (sOut += ' ') += sHTML_O_sdfixed;
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_superscript, TRUE );
+
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rFmtFtn.GetViewNumStr(*rWrt.pDoc),
+ rHTMLWrt.eDestEnc );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_superscript, FALSE );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_anchor, FALSE );
+
+ return rWrt;
+}
+
+void SwHTMLWriter::OutFootEndNotes()
+{
+ ASSERT( pFootEndNotes,
+ "SwHTMLWriter::OutFootEndNotes(): unnoetiger Aufruf" );
+ if( !pFootEndNotes )
+ return;
+
+#ifndef PRODUCT
+ USHORT nFtn = nFootNote, nEn = nEndNote;
+#endif
+ nFootNote = 0, nEndNote = 0;
+
+ for( USHORT i=0; i<pFootEndNotes->Count(); i++ )
+ {
+ SwTxtFtn *pTxtFtn = (*pFootEndNotes)[i];
+ pFmtFtn = &pTxtFtn->GetFtn();
+
+ String sFtnName, sClass;
+ if( pFmtFtn->IsEndNote() )
+ {
+ sClass.AssignAscii( sHTML_sdendnote );
+ sFtnName.AssignAscii( sHTML_sdendnote );
+ sFtnName.Append( String::CreateFromInt32((sal_Int32)(++nEndNote)) );
+ }
+ else
+ {
+ sClass.AssignAscii( sHTML_sdfootnote );
+ sFtnName.AssignAscii( sHTML_sdfootnote );
+ sFtnName.Append( String::CreateFromInt32((sal_Int32)(++nFootNote)));
+ }
+
+ if( bLFPossible )
+ OutNewLine();
+ ByteString sOut( '<' );
+ (((sOut += sHTML_division) += ' ') += sHTML_O_id) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), sFtnName, eDestEnc );
+ Strm() << "\">";
+
+ bLFPossible = TRUE;
+ IncIndentLevel(); // Inhalt von <DIV> einruecken
+
+ ASSERT( pTxtFtn, "SwHTMLWriter::OutFootEndNotes: SwTxtFtn fehlt" );
+ SwNodeIndex *pSttNdIdx = pTxtFtn->GetStartNode();
+ ASSERT( pSttNdIdx,
+ "SwHTMLWriter::OutFootEndNotes: StartNode-Index fehlt" );
+ if( pSttNdIdx )
+ {
+ HTMLSaveData aSaveData( *this, pSttNdIdx->GetIndex()+1,
+ pSttNdIdx->GetNode().EndOfSectionIndex(), GetFlyFrmFmt(),
+ FALSE );
+ Out_SwDoc( pCurPam );
+ }
+
+ DecIndentLevel(); // Inhalt von <DIV> einruecken
+ if( bLFPossible )
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_division, FALSE );
+ bLFPossible = TRUE;
+
+ ASSERT( !pFmtFtn,
+ "SwHTMLWriter::OutFootEndNotes: Ftn wurde nicht ausgegeben" );
+ if( pFmtFtn )
+ {
+ if( pFmtFtn->IsEndNote() )
+ nEndNote++;
+ else
+ nFootNote++;
+
+ pFmtFtn = 0;
+ }
+ }
+
+#ifndef PRODUCT
+ ASSERT( nFtn == nFootNote,
+ "SwHTMLWriter::OutFootEndNotes: Anzahl Fussnoten stimmt nicht" );
+ ASSERT( nEn == nEndNote,
+ "SwHTMLWriter::OutFootEndNotes: Anzahl Endnoten stimmt nicht" );
+#endif
+
+ delete pFootEndNotes;
+ pFootEndNotes = 0;
+ nFootNote = nEndNote = 0;
+}
+
+xub_StrLen SwHTMLWriter::GetFootEndNoteSymLen( const SwFmtFtn& rFmtFtn )
+{
+ xub_StrLen nLen = rFmtFtn.GetViewNumStr( *pDoc ).Len();
+
+ if( rFmtFtn.GetNumStr().Len() == 0 )
+ {
+ const SwEndNoteInfo * pInfo =
+ rFmtFtn.IsEndNote() ? &pDoc->GetEndNoteInfo() : &pDoc->GetFtnInfo();
+
+ nLen += pInfo->GetPrefix().Len();
+ nLen += pInfo->GetSuffix().Len();
+ }
+
+ return nLen;
+}
+
+void SwHTMLWriter::OutFootEndNoteSym( const SwFmtFtn& rFmtFtn )
+{
+ const SwEndNoteInfo *pInfo;
+
+ String sFtnName, sClass, sPrefix, sSuffix;
+ if( rFmtFtn.IsEndNote() )
+ {
+ sClass.AssignAscii( sHTML_sdendnote_sym );
+ sFtnName.AssignAscii( sHTML_sdendnote );
+ sFtnName.Append( String::CreateFromInt32((sal_Int32)nEndNote) );
+ pInfo = &pDoc->GetEndNoteInfo();
+ }
+ else
+ {
+ sClass.AssignAscii( sHTML_sdfootnote_sym );
+ sFtnName.AssignAscii( sHTML_sdfootnote );
+ sFtnName.Append( String::CreateFromInt32((sal_Int32)nFootNote));
+ pInfo = &pDoc->GetFtnInfo();
+ }
+
+ ByteString sOut( '<' );
+ (((sOut += sHTML_anchor) += ' ') += sHTML_O_class) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), sClass, eDestEnc );
+ ((sOut += "\" ") += sHTML_O_name) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), sFtnName, eDestEnc );
+ (((sOut += sHTML_FTN_symbol) +="\" ") += sHTML_O_href) += "=\"#";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), sFtnName, eDestEnc );
+ (sOut += sHTML_FTN_anchor) += "\">";
+ Strm() << sOut.GetBuffer();
+
+ BOOL bAuto = rFmtFtn.GetNumStr().Len() == 0;
+ String sNum;
+ if( bAuto )
+ sNum += pInfo->GetPrefix();
+ sNum += rFmtFtn.GetViewNumStr(*pDoc);
+ if( bAuto )
+ sNum += pInfo->GetSuffix();
+ HTMLOutFuncs::Out_String( Strm(), sNum, eDestEnc );
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_anchor, FALSE );
+}
+
+USHORT lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
+ String *pParts,
+ BOOL bEndNote )
+{
+ USHORT nParts = 0;
+ SvxExtNumType eFmt = rInfo.aFmt.eType;
+ if( (bEndNote ? SVX_NUM_ROMAN_LOWER : SVX_NUM_ARABIC) != eFmt )
+ {
+ const sal_Char *pStr = SwHTMLWriter::GetNumFormat( eFmt );
+ if( pStr )
+ {
+ pParts[0] = String::CreateFromAscii( pStr );
+ nParts = 1;
+ }
+ }
+ if( rInfo.nFtnOffset > 0 )
+ {
+ pParts[1] = String::CreateFromInt32( (sal_Int32)rInfo.nFtnOffset );
+ nParts = 2;
+ }
+ if( rInfo.GetPrefix().Len() > 0 )
+ {
+ pParts[2] = rInfo.GetPrefix();
+ nParts = 3;
+ }
+ if( rInfo.GetSuffix().Len() > 0 )
+ {
+ pParts[3] = rInfo.GetSuffix();
+ nParts = 4;
+ }
+
+ return nParts;
+}
+
+void lcl_html_outFootEndNoteInfo( Writer& rWrt, String *pParts,
+ USHORT nParts, const sal_Char *pName )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ String aContent;
+ for( USHORT i=0; i<nParts; i++ )
+ {
+ xub_StrLen nPos = 0;
+ String aTmp( pParts[i] );
+ String aRep( String::CreateFromAscii("\\\\") );
+ while( STRING_NOTFOUND != (nPos = aTmp.SearchAndReplaceAscii( "\\",
+ aRep, nPos ) ) )
+ nPos += 2;
+ nPos = 0;
+ aRep.AssignAscii( "\\;" );
+ while( STRING_NOTFOUND != (nPos = aTmp.SearchAndReplaceAscii( ";",
+ aRep, nPos ) ) )
+ nPos += 2;
+ if( i > 0 )
+ aContent += ';';
+ aContent += aTmp;
+ }
+
+ rHTMLWrt.OutNewLine();
+ ByteString sOut( '<' );
+ (((((((sOut += sHTML_meta) += ' ')
+ += sHTML_O_name) += "=\"") += pName) += "\" ")
+ += sHTML_O_content) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aContent, rHTMLWrt.eDestEnc );
+ rWrt.Strm() << "\">";
+}
+
+void SwHTMLWriter::OutFootEndNoteInfo()
+{
+ // Nummerntyp (1 bzw. i)
+ // Offset (0)
+ // Davor
+ // Dahinter
+ // Dok/Seite/Kap (D)
+ // Position (S)
+ // Folgeseite
+ // Beginn
+
+ {
+ const SwFtnInfo& rInfo = pDoc->GetFtnInfo();
+ String aParts[8];
+ USHORT nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, FALSE );
+ if( rInfo.eNum != FTNNUM_DOC )
+ {
+ aParts[4] = rInfo.eNum == FTNNUM_CHAPTER ? 'C' : 'P';
+ nParts = 5;
+ }
+ if( rInfo.ePos != FTNPOS_PAGE)
+ {
+ aParts[5] = 'C';
+ nParts = 6;
+ }
+ if( rInfo.aQuoVadis.Len() > 0 )
+ {
+ aParts[6] = rInfo.aQuoVadis;
+ nParts = 7;
+ }
+ if( rInfo.aErgoSum.Len() > 0 )
+ {
+ aParts[7] = rInfo.aErgoSum;
+ nParts = 8;
+ }
+ if( nParts > 0 )
+ lcl_html_outFootEndNoteInfo( *this, aParts, nParts,
+ sHTML_META_sdfootnote );
+ }
+
+ {
+ const SwEndNoteInfo& rInfo = pDoc->GetEndNoteInfo();
+ String aParts[4];
+ USHORT nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, TRUE );
+ if( nParts > 0 )
+ lcl_html_outFootEndNoteInfo( *this, aParts, nParts,
+ sHTML_META_sdendnote );
+ }
+}
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.6 2000/09/18 16:04:45 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.5 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.4 1999/09/21 09:49:49 mib
+ multiple text encodings
+
+ Revision 1.3 1999/09/17 12:13:24 mib
+ support of multiple and non system text encodings
+
+ Revision 1.2 1998/11/17 09:44:36 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+
+ Rev 1.1 17 Nov 1998 10:44:36 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.0 02 Nov 1998 17:21:20 MIB
+ #58480#: Fuss-/Endnoten
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
new file mode 100644
index 000000000000..49fa2c68a175
--- /dev/null
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -0,0 +1,1656 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlgrin.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+
+#include "hintids.hxx"
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svtools/stritem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SFXDOCFILE_HXX //autogen
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _IMAP_HXX //autogen
+#include <svtools/imap.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTURL_HXX //autogen
+#include <fmturl.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include "frmatr.hxx"
+#endif
+#ifndef _CHARATR_HXX
+#include "charatr.hxx"
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _SWDOCSH_HXX //autogen
+#include <docsh.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx>
+#endif
+#ifndef _NDGRF_HXX
+#include <ndgrf.hxx>
+#endif
+#ifndef _HTMLNUM_HXX
+#include <htmlnum.hxx>
+#endif
+#ifndef _SWCSS1_HXX
+#include <swcss1.hxx>
+#endif
+#ifndef _SWHTML_HXX
+#include <swhtml.hxx>
+#endif
+
+
+HTMLOptionEnum __FAR_DATA aHTMLImgHAlignTable[] =
+{
+ { sHTML_AL_left, HORI_LEFT },
+ { sHTML_AL_right, HORI_RIGHT },
+ { 0, 0 }
+};
+
+
+HTMLOptionEnum __FAR_DATA aHTMLImgVAlignTable[] =
+{
+ { sHTML_VA_top, VERT_LINE_TOP },
+ { sHTML_VA_texttop, VERT_CHAR_TOP },
+ { sHTML_VA_middle, VERT_CENTER },
+ { sHTML_AL_center, VERT_CENTER },
+ { sHTML_VA_absmiddle, VERT_LINE_CENTER },
+ { sHTML_VA_bottom, VERT_TOP },
+ { sHTML_VA_baseline, VERT_TOP },
+ { sHTML_VA_absbottom, VERT_LINE_BOTTOM },
+ { 0, 0 }
+};
+
+SV_IMPL_PTRARR( ImageMaps, ImageMapPtr )
+
+ImageMap *SwHTMLParser::FindImageMap( const String& rName ) const
+{
+ ImageMap *pImageMap = 0;
+
+ ASSERT( rName.GetChar(0) != '#', "FindImageName: Name beginnt mit #!" );
+
+ if( pImageMaps )
+ {
+ for( USHORT i=0; i<pImageMaps->Count(); i++ )
+ {
+ ImageMap *pIMap = (*pImageMaps)[i];
+ if( rName.EqualsIgnoreCaseAscii( pIMap->GetName() ) )
+ {
+ pImageMap = pIMap;
+ break;
+ }
+ }
+ }
+ return pImageMap;
+}
+
+void SwHTMLParser::ConnectImageMaps()
+{
+ SwNodes& rNds = pDoc->GetNodes();
+ // auf den Start-Node der 1. Section
+ ULONG nIdx = rNds.GetEndOfAutotext().StartOfSectionIndex() + 1;
+ ULONG nEndIdx = rNds.GetEndOfAutotext().GetIndex();
+
+ SwGrfNode* pGrfNd;
+ while( nMissingImgMaps > 0 && nIdx < nEndIdx )
+ {
+ SwNode *pNd = rNds[nIdx + 1];
+ if( 0 != (pGrfNd = pNd->GetGrfNode()) )
+ {
+ SwFrmFmt *pFmt = pGrfNd->GetFlyFmt();
+ SwFmtURL aURL( pFmt->GetURL() );
+ const ImageMap *pIMap = aURL.GetMap();
+ if( pIMap && pIMap->GetIMapObjectCount()==0 )
+ {
+ // Die (leere) Image-Map des Nodes wird entweder
+ // durch die jetzt gefundene Image-Map ersetzt
+ // oder geloescht.
+ ImageMap *pNewIMap =
+ FindImageMap( pIMap->GetName() );
+ aURL.SetMap( pNewIMap );
+ pFmt->SetAttr( aURL );
+ if( !pGrfNd->IsScaleImageMap() )
+ {
+ // die Grafikgroesse ist mitlerweile da oder dir
+ // Grafik muss nicht skaliert werden
+ pGrfNd->ScaleImageMap();
+ }
+ nMissingImgMaps--; // eine Map weniger suchen
+ }
+ }
+ nIdx = rNds[nIdx]->EndOfSectionIndex() + 1;
+ }
+}
+
+
+/* */
+
+void SwHTMLParser::SetAnchorAndAdjustment( SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ const SfxItemSet &rCSS1ItemSet,
+ const SvxCSS1PropertyInfo &rCSS1PropInfo,
+ SfxItemSet& rFrmItemSet )
+{
+ const SfxItemSet *pCntnrItemSet = 0;
+ USHORT i = aContexts.Count();
+ while( !pCntnrItemSet && i > nContextStMin )
+ pCntnrItemSet = aContexts[--i]->GetFrmItemSet();
+
+ if( pCntnrItemSet )
+ {
+ // Wenn wir und in einem Container befinden wird die Verankerung
+ // des Containers uebernommen.
+ rFrmItemSet.Put( *pCntnrItemSet );
+ }
+ else if( pCSS1Parser->MayBePositioned( rCSS1PropInfo, TRUE ) )
+ {
+ // Wenn die Ausrichtung anhand der CSS1-Optionen gesetzt werden kann
+ // werden die benutzt.
+ SetAnchorAndAdjustment( rCSS1ItemSet, rCSS1PropInfo, rFrmItemSet );
+ }
+ else
+ {
+ // Sonst wird die Ausrichtung entsprechend der normalen HTML-Optionen
+ // gesetzt.
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, rFrmItemSet );
+ }
+}
+
+void SwHTMLParser::SetAnchorAndAdjustment( SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ SfxItemSet& rFrmSet,
+ BOOL bDontAppend )
+{
+ BOOL bMoveBackward = FALSE;
+ SwFmtAnchor aAnchor( FLY_IN_CNTNT );
+ SwRelationOrient eVertRel = FRAME;
+
+ if( HORI_NONE != eHoriOri )
+ {
+ // den Absatz-Einzug bestimmen
+ USHORT nLeftSpace = 0, nRightSpace = 0;
+ short nIndent = 0;
+ GetMarginsFromContextWithNumBul( nLeftSpace, nRightSpace, nIndent );
+
+ // Horizonale Ausrichtung und Umlauf bestimmen.
+ SwRelationOrient eHoriRel;
+ SwSurround eSurround;
+ switch( eHoriOri )
+ {
+ case HORI_LEFT:
+ eHoriRel = nLeftSpace ? PRTAREA : FRAME;
+ eSurround = SURROUND_RIGHT;
+ break;
+ case HORI_RIGHT:
+ eHoriRel = nRightSpace ? PRTAREA : FRAME;
+ eSurround = SURROUND_LEFT;
+ break;
+ case HORI_CENTER: // fuer Tabellen
+ eHoriRel = FRAME;
+ eSurround = SURROUND_NONE;
+ break;
+ default:
+ eHoriRel = FRAME;
+ eSurround = SURROUND_PARALLEL;
+ break;
+ }
+
+ // Einen neuen Absatz aufmachen, wenn der aktuelle
+ // absatzgebundene Rahmen ohne Umlauf enthaelt.
+ if( !bDontAppend && HasCurrentParaFlys( TRUE ) )
+ {
+ // Wenn der Absatz nur Grafiken enthaelt, braucht er
+ // auch keinen unteren Absatz-Abstand. Da hier auch bei
+ // Verwendung von Styles kein Abstand enstehen soll, wird
+ // hier auch geweohnlich attributiert !!!
+ USHORT nUpper=0, nLower=0;
+ GetULSpaceFromContext( nUpper, nLower );
+ InsertAttr( SvxULSpaceItem( nUpper, 0 ), FALSE, TRUE );
+
+ AppendTxtNode( AM_NOSPACE );
+
+ if( nUpper )
+ {
+ NewAttr( &aAttrTab.pULSpace, SvxULSpaceItem( 0, nLower ) );
+ aParaAttrs.Insert( aAttrTab.pULSpace, aParaAttrs.Count() );
+ EndAttr( aAttrTab.pULSpace, 0, FALSE );
+ }
+ }
+
+ // Vertikale Ausrichtung und Verankerung bestimmen.
+ xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex();
+ if( nCntnt )
+ {
+ aAnchor.SetType( FLY_AUTO_CNTNT );
+ bMoveBackward = TRUE;
+ eVertOri = VERT_CHAR_BOTTOM;
+ eVertRel = REL_CHAR;
+ }
+ else
+ {
+ aAnchor.SetType( FLY_AT_CNTNT );
+ eVertOri = VERT_TOP;
+ eVertRel = PRTAREA;
+ }
+
+ rFrmSet.Put( SwFmtHoriOrient( 0, eHoriOri, eHoriRel) );
+
+ rFrmSet.Put( SwFmtSurround( eSurround ) );
+ }
+ rFrmSet.Put( SwFmtVertOrient( 0, eVertOri, eVertRel) );
+
+ if( bMoveBackward )
+ pPam->Move( fnMoveBackward );
+
+ aAnchor.SetAnchor( pPam->GetPoint() );
+
+ if( bMoveBackward )
+ pPam->Move( fnMoveForward );
+
+ rFrmSet.Put( aAnchor );
+}
+
+void SwHTMLParser::RegisterFlyFrm( SwFrmFmt *pFlyFmt )
+{
+ // automatisch verankerte Rahmen muessen noch um eine Position
+ // nach vorne verschoben werden.
+ if( RES_DRAWFRMFMT != pFlyFmt->Which() &&
+ FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() &&
+ SURROUND_THROUGHT == pFlyFmt->GetSurround().GetSurround() )
+ {
+ aMoveFlyFrms.Insert( pFlyFmt, aMoveFlyFrms.Count() );
+ aMoveFlyCnts.Insert( pPam->GetPoint()->nContent.GetIndex(),
+ aMoveFlyCnts.Count() );
+ }
+}
+
+/* */
+
+void SwHTMLParser::GetDefaultScriptType( ScriptType& rType,
+ String& rTypeStr ) const
+{
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ SvKeyValueIterator* pHeaderAttrs = pDocSh ? pDocSh->GetHeaderAttributes()
+ : 0;
+ rType = GetScriptType( pHeaderAttrs );
+ rTypeStr = GetScriptTypeString( pHeaderAttrs );
+}
+
+/* */
+
+void SwHTMLParser::InsertImage()
+{
+ // und jetzt auswerten
+ String sGrfNm, sAltNm, aId, aClass, aStyle, aMap, sHTMLGrfName;
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
+ long nWidth=0, nHeight=0;
+ long nVSpace=0, nHSpace=0;
+
+ USHORT nBorder = (aAttrTab.pINetFmt ? 1 : 0);
+ BOOL bIsMap = FALSE;
+ BOOL bPrcWidth = FALSE;
+ BOOL bPrcHeight = FALSE;
+ SvxMacroItem aMacroItem;
+
+ ScriptType eDfltScriptType;
+ String sDfltScriptType;
+ GetDefaultScriptType( eDfltScriptType, sDfltScriptType );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ USHORT nEvent = 0;
+ ScriptType eScriptType = eDfltScriptType;
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_SRC:
+ ASSERT( INetURLObject::GetBaseURL() == sBaseURL,
+ "<IMG>: Base URL ist zerschossen" );
+ sGrfNm = pOption->GetString();
+ if( !InternalImgToPrivateURL(sGrfNm) )
+ sGrfNm = INetURLObject::RelToAbs( sGrfNm );
+ break;
+ case HTML_O_ALIGN:
+ eVertOri =
+ (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable,
+ VERT_TOP );
+ eHoriOri =
+ (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable,
+ HORI_NONE );
+ break;
+ case HTML_O_WIDTH:
+ // erstmal nur als Pixelwerte merken!
+ nWidth = pOption->GetNumber();
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ if( bPrcWidth && nWidth>100 )
+ nWidth = 100;
+ break;
+ case HTML_O_HEIGHT:
+ // erstmal nur als Pixelwerte merken!
+ nHeight = pOption->GetNumber();
+ bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ if( bPrcHeight && nHeight>100 )
+ nHeight = 100;
+ break;
+ case HTML_O_VSPACE:
+ nVSpace = pOption->GetNumber();
+ break;
+ case HTML_O_HSPACE:
+ nHSpace = pOption->GetNumber();
+ break;
+ case HTML_O_ALT:
+ sAltNm = pOption->GetString();
+ break;
+ case HTML_O_BORDER:
+ nBorder = (USHORT)pOption->GetNumber();
+ break;
+ case HTML_O_ISMAP:
+ bIsMap = TRUE;
+ break;
+ case HTML_O_USEMAP:
+ aMap = pOption->GetString();
+ break;
+ case HTML_O_NAME:
+ sHTMLGrfName = pOption->GetString();
+ break;
+
+ case HTML_O_SDONLOAD:
+ eScriptType = STARBASIC;
+ case HTML_O_ONLOAD:
+ nEvent = SVX_EVENT_IMAGE_LOAD;
+ goto IMAGE_SETEVENT;
+
+ case HTML_O_SDONABORT:
+ eScriptType = STARBASIC;
+ case HTML_O_ONABORT:
+ nEvent = SVX_EVENT_IMAGE_ABORT;
+ goto IMAGE_SETEVENT;
+
+ case HTML_O_SDONERROR:
+ eScriptType = STARBASIC;
+ case HTML_O_ONERROR:
+ nEvent = SVX_EVENT_IMAGE_ERROR;
+ goto IMAGE_SETEVENT;
+IMAGE_SETEVENT:
+ {
+ String sTmp( pOption->GetString() );
+ if( sTmp.Len() )
+ {
+ sTmp.ConvertLineEnd();
+ String sScriptType;
+ if( EXTENDED_STYPE == eScriptType )
+ sScriptType = sDfltScriptType;
+ aMacroItem.SetMacro( nEvent,
+ SvxMacro( sTmp, sScriptType, eScriptType ));
+ }
+ }
+ break;
+ }
+ }
+
+ if( !sGrfNm.Len() )
+ return;
+
+ // Wenn wir in einer Numerierung stehen und der Absatz noch leer und
+ // nicht numeriert ist, handelt es sich vielleicht um die Grafik
+ // einer Bullet-Liste
+ if( !pPam->GetPoint()->nContent.GetIndex() &&
+ GetNumInfo().GetDepth() > 0 && GetNumInfo().GetDepth() <= MAXLEVEL &&
+ aBulletGrfs[GetNumInfo().GetDepth()-1].Len() &&
+ aBulletGrfs[GetNumInfo().GetDepth()-1]==sGrfNm )
+ {
+ SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
+ if( pTxtNode && pTxtNode->GetNum() &&
+ NO_NUMLEVEL & pTxtNode->GetNum()->GetLevel() )
+ {
+ SwNodeNum aNum( *pTxtNode->GetNum() );
+ aNum.SetLevel( aNum.GetLevel() & ~NO_NUMLEVEL );
+ ASSERT( aNum.GetLevel() == GetNumInfo().GetLevel(),
+ "Numerierungs-Ebene stimmt nicht" );
+ pTxtNode->UpdateNum( aNum );
+
+ // Rule invalisieren ist noetig, weil zwischem dem einlesen
+ // des LI und der Grafik ein EndAction gerufen worden sein kann.
+ if( GetNumInfo().GetNumRule() )
+ GetNumInfo().GetNumRule()->SetInvalidRule( TRUE );
+
+ // Die Vorlage novh mal setzen. Ist noetig, damit der
+ // Erstzeilen-Einzug stimmt.
+ SetTxtCollAttrs();
+
+ return;
+ }
+ }
+
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
+
+ SfxItemSet aFrmSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aFrmSet );
+
+ // Umrandung setzen
+ long nHBorderWidth = 0, nVBorderWidth = 0;
+ if( nBorder )
+ {
+ nHBorderWidth = (long)nBorder;
+ nVBorderWidth = (long)nBorder;
+ SvxCSS1Parser::PixelToTwip( nVBorderWidth, nHBorderWidth );
+
+ SvxBorderLine aHBorderLine;
+ SvxBorderLine aVBorderLine;
+
+ SvxCSS1Parser::SetBorderWidth( aHBorderLine,
+ (USHORT)nHBorderWidth, FALSE );
+ if( nHBorderWidth == nVBorderWidth )
+ aVBorderLine.SetOutWidth( aHBorderLine.GetOutWidth() );
+ else
+ SvxCSS1Parser::SetBorderWidth( aVBorderLine,
+ (USHORT)nVBorderWidth, FALSE );
+
+ // die tatsaechlich gesetzter Rahmenbreite benutzen und nicht die
+ // Wunschbreite!
+ nHBorderWidth = aHBorderLine.GetOutWidth();
+ nVBorderWidth = aVBorderLine.GetOutWidth();
+
+ if( aAttrTab.pINetFmt )
+ {
+ const String& rURL =
+ ((const SwFmtINetFmt&)aAttrTab.pINetFmt->GetItem()).GetValue();
+
+ pCSS1Parser->SetATagStyles();
+ USHORT nPoolId = pDoc->IsVisitedURL( rURL )
+ ? RES_POOLCHR_INET_VISIT
+ : RES_POOLCHR_INET_NORMAL;
+ const SwCharFmt *pCharFmt = pCSS1Parser->GetCharFmtFromPool( nPoolId );
+ aHBorderLine.SetColor( pCharFmt->GetColor().GetValue() );
+ aVBorderLine.SetColor( aHBorderLine.GetColor() );
+ }
+ else
+ {
+ const SvxColorItem& rColorItem = aAttrTab.pFontColor ?
+ (const SvxColorItem &)aAttrTab.pFontColor->GetItem() :
+ (const SvxColorItem &)pDoc->GetDefault(RES_CHRATR_COLOR);
+ aHBorderLine.SetColor( rColorItem.GetValue() );
+ aVBorderLine.SetColor( aHBorderLine.GetColor() );
+ }
+
+
+ SvxBoxItem aBoxItem;
+ aBoxItem.SetLine( &aHBorderLine, BOX_LINE_TOP );
+ aBoxItem.SetLine( &aHBorderLine, BOX_LINE_BOTTOM );
+ aBoxItem.SetLine( &aVBorderLine, BOX_LINE_LEFT );
+ aBoxItem.SetLine( &aVBorderLine, BOX_LINE_RIGHT );
+ aFrmSet.Put( aBoxItem );
+ }
+
+ // Ausrichtung setzen
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
+
+ // Abstaende setzen
+ SetSpace( Size( nHSpace, nVSpace), aItemSet, aPropInfo, aFrmSet );
+
+ // Sonstige CSS1-Attribute Setzen
+ SetFrmFmtAttrs( aItemSet, aPropInfo, HTML_FF_BOX, aFrmSet );
+
+ Size aTwipSz( bPrcWidth ? 0 : nWidth, bPrcHeight ? 0 : nHeight );
+ if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ {
+ aTwipSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
+ }
+
+ // CSS1-Groesse auf "normale" Groesse umrechnen
+ switch( aPropInfo.eWidthType )
+ {
+ case SVX_CSS1_LTYPE_TWIP:
+ aTwipSz.Width() = aPropInfo.nWidth;
+ nWidth = 1; // != 0
+ bPrcWidth = FALSE;
+ break;
+ case SVX_CSS1_LTYPE_PERCENTAGE:
+ aTwipSz.Width() = 0;
+ nWidth = aPropInfo.nWidth;
+ bPrcWidth = TRUE;
+ break;
+ }
+ switch( aPropInfo.eHeightType )
+ {
+ case SVX_CSS1_LTYPE_TWIP:
+ aTwipSz.Height() = aPropInfo.nHeight;
+ nHeight = 1; // != 0
+ bPrcHeight = FALSE;
+ break;
+ case SVX_CSS1_LTYPE_PERCENTAGE:
+ aTwipSz.Height() = 0;
+ nHeight = aPropInfo.nHeight;
+ bPrcHeight = TRUE;
+ break;
+ }
+
+ Size aGrfSz( 0, 0 );
+ BOOL bSetTwipSize = TRUE; // Twip-Size am Node setzen?
+ BOOL bChangeFrmSize = FALSE; // Frame-Format nachtraeglich anpassen?
+ BOOL bGrfSzValid = FALSE; // aGrfSz enthaelt die Grafik-Groesse
+ BOOL bRequestGrfNow = FALSE;
+ BOOL bSetScaleImageMap = FALSE;
+ BYTE nPrcWidth = 0, nPrcHeight = 0;
+
+ if( !nWidth || !nHeight )
+ {
+ // Es fehlt die Breite oder die Hoehe
+
+ // JP 28.05.96: dann suche doch mal in unserem QuickDraw-Cache, ob
+ // die Groesse dieser Grafik schon vorhanden ist.
+
+// Code for the new GraphicObject
+#ifdef USE_GRFOBJECT
+
+ bGrfSzValid =
+#ifdef NEW_GRFOBJ
+ FindGrfSizeFromCache( sGrfNm, aGrfSz )
+#else
+ FALSE;
+#endif
+ ;
+
+#else
+// USE_GRFOBJECT
+
+ bGrfSzValid = FindGrfSizeFromCache( sGrfNm, aGrfSz );
+
+#endif
+// USE_GRFOBJECT
+
+ // Wenn die Grfik in einer Tabelle steht, wird sie gleich
+ // angefordert, damit sie eventuell schon da ist, bevor die
+ // Tabelle layoutet wird.
+ if( !bGrfSzValid && pTable!=0 && !nWidth )
+ {
+ bRequestGrfNow = TRUE;
+ IncGrfsThatResizeTable();
+ }
+
+ if( bGrfSzValid && aGrfSz.Width() && aGrfSz.Height() )
+ {
+ // wir haben eine Groesse und koenen sie setzen
+ if( !nWidth && !nHeight )
+ {
+ // Hoehe und Breite fehlen
+ aTwipSz = aGrfSz;
+ }
+ else if( nWidth )
+ {
+ // nur die Breite fehlt
+ if( bPrcWidth )
+ {
+ // %-Breite uebernehmen und Hoehe skalieren
+ nPrcWidth = (BYTE)nWidth;
+ nPrcHeight = 255;
+ }
+ else
+ {
+ // Breite uebernehmen und Hoehe berechnen
+ aTwipSz.Height() = (aGrfSz.Height() * aTwipSz.Width())
+ / aGrfSz.Width();
+ }
+ }
+ else if( nHeight )
+ {
+ // nur die Hoehe fehlt
+ if( bPrcHeight )
+ {
+ // %-Hoehe lassen und Breite skalieren
+ nPrcHeight = (BYTE)nHeight;
+ nPrcWidth = 255;
+ }
+ else
+ {
+ // Hoehe uebernehmen und Breite berechnen
+ aTwipSz.Width() = (aGrfSz.Width() * aTwipSz.Height())
+ / aGrfSz.Height();
+ }
+ }
+ }
+ else
+ {
+ // wir haben keine Groesse gefunden (und sind in keiner
+ // Tabelle oder haben zumindest die Breite der Grafik)
+
+ // Die Groesse des Rahmens wird nachtraeglich gesetzt
+ bChangeFrmSize = TRUE;
+ aGrfSz = aTwipSz;
+ if( !nWidth && !nHeight )
+ {
+ aTwipSz.Width() = HTML_DFLT_IMG_WIDTH;
+ aTwipSz.Height() = HTML_DFLT_IMG_HEIGHT;
+ }
+ else if( nWidth )
+ {
+ // eine %-Angabe
+ if( bPrcWidth )
+ {
+ nPrcWidth = (BYTE)nWidth;
+ nPrcHeight = 255;
+ }
+ else
+ {
+ aTwipSz.Height() = HTML_DFLT_IMG_HEIGHT;
+ }
+ }
+ else if( nHeight )
+ {
+ if( bPrcHeight )
+ {
+ nPrcHeight = (BYTE)nHeight;
+ nPrcWidth = 255;
+ }
+ else
+ {
+ aTwipSz.Width() = HTML_DFLT_IMG_WIDTH;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Breite und Hoehe wurden angegeben und brauchen nicht gesetzt
+ // zu werden
+// Code for the new GraphicObject
+#ifdef USE_GRFOBJECT
+
+ bGrfSzValid =
+#ifdef NEW_GRFOBJ
+ FindGrfSizeFromCache( sGrfNm, aGrfSz )
+#else
+ FALSE;
+#endif
+ ;
+
+
+#else
+// USE_GRFOBJECT
+
+ bGrfSzValid = FindGrfSizeFromCache( sGrfNm, aGrfSz );
+#endif
+// USE_GRFOBJECT
+
+ bSetTwipSize = FALSE;
+
+ if( bPrcWidth )
+ nPrcWidth = (BYTE)nWidth;
+
+ if( bPrcHeight )
+ nPrcHeight = (BYTE)nHeight;
+ }
+
+ // Image-Map setzen
+ aMap.EraseTrailingChars();
+ if( aMap.Len() )
+ {
+ // Da wir nur lokale Image-Maps kennen nehmen wireinfach alles
+ // hinter dem # als Namen
+ xub_StrLen nPos = aMap.Search( '#' );
+ String aName;
+ if ( STRING_NOTFOUND==nPos )
+ aName = aMap ;
+ else
+ aName = aMap.Copy(nPos+1);
+
+ ImageMap *pImgMap = FindImageMap( aName );
+ if( pImgMap )
+ {
+ SwFmtURL aURL; aURL.SetMap( pImgMap );//wird kopieiert
+ if( bGrfSzValid )
+ {
+ BOOL bScale = FALSE;
+
+ Fraction aScaleX( 1, 1 ), aScaleY( 1, 1);
+
+ if( !nPrcWidth && aGrfSz.Width() && aTwipSz.Width() &&
+ aGrfSz.Width() != aTwipSz.Width() )
+ {
+ aScaleX = Fraction( aGrfSz.Width(), aTwipSz.Width() );
+ bScale = TRUE;
+ }
+
+ if( !nPrcHeight && aGrfSz.Height() && aTwipSz.Height() &&
+ aGrfSz.Height() != aTwipSz.Height() )
+ {
+ aScaleY = Fraction( aGrfSz.Height(), aTwipSz.Height() );
+ bScale = TRUE;
+ }
+
+ if( bScale )
+ aURL.GetMap()->Scale( aScaleX, aScaleY );
+ }
+ else
+ bSetScaleImageMap = !nPrcWidth || !nPrcHeight;
+ aFrmSet.Put( aURL );
+ }
+ else
+ {
+ ImageMap aEmptyImgMap( aName );
+ SwFmtURL aURL; aURL.SetMap( &aEmptyImgMap );//wird kopieiert
+ aFrmSet.Put( aURL );
+ nMissingImgMaps++; // es fehlen noch Image-Maps
+
+ // die Grafik muss beim SetTwipSize skaliert werden, wenn
+ // wir keine Groesse am Node gesetzt haben oder die Groesse
+ // nicht der Grafikgroesse entsprach.
+ bSetScaleImageMap = !bSetTwipSize || !bGrfSzValid ||
+ !nPrcWidth || !nPrcHeight;
+ }
+ }
+
+ // min. Werte einhalten !!
+ if( nPrcWidth )
+ {
+ ASSERT( !aTwipSz.Width(),
+ "Wieso ist da trotz %-Angabe eine Breite gesetzt?" );
+ aTwipSz.Width() = aGrfSz.Width() ? aGrfSz.Width()
+ : HTML_DFLT_IMG_WIDTH;
+ }
+ else
+ {
+ aTwipSz.Width() += 2*nVBorderWidth;
+ if( aTwipSz.Width() < MINFLY )
+ aTwipSz.Width() = MINFLY;
+ }
+ if( nPrcHeight )
+ {
+ ASSERT( !aTwipSz.Height(),
+ "Wieso ist da trotz %-Angabe eine Hoehe gesetzt?" );
+ aTwipSz.Height() = aGrfSz.Height() ? aGrfSz.Height()
+ : HTML_DFLT_IMG_HEIGHT;
+ }
+ else
+ {
+ aTwipSz.Height() += 2*nHBorderWidth;
+ if( aTwipSz.Height() < MINFLY )
+ aTwipSz.Height() = MINFLY;
+ }
+
+ SwFmtFrmSize aFrmSize( ATT_FIX_SIZE, aTwipSz.Width(), aTwipSz.Height() );
+ aFrmSize.SetWidthPercent( nPrcWidth );
+ aFrmSize.SetHeightPercent( nPrcHeight );
+ aFrmSet.Put( aFrmSize );
+
+ Graphic aEmptyGrf;
+ aEmptyGrf.SetDefaultType();
+ SwFrmFmt *pFlyFmt = pDoc->Insert( *pPam, sGrfNm, aEmptyStr, &aEmptyGrf,
+ &aFrmSet );
+ SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
+ ->GetIndex()+1 ]->GetGrfNode();
+
+ if( sHTMLGrfName.Len() )
+ {
+ pFlyFmt->SetName( sHTMLGrfName );
+
+ // ggfs. eine Grafik anspringen
+ if( JUMPTO_GRAPHIC == eJumpTo && sHTMLGrfName == sJmpMark )
+ {
+ bChkJumpMark = TRUE;
+ eJumpTo = JUMPTO_NONE;
+ }
+ }
+
+ if( sAltNm.Len() )
+ pGrfNd->SetAlternateText( sAltNm );
+
+ if( bSetTwipSize )
+ pGrfNd->SetTwipSize( aGrfSz );
+
+ pGrfNd->SetChgTwipSize( bChangeFrmSize );
+
+ if( bSetScaleImageMap )
+ pGrfNd->SetScaleImageMap( TRUE );
+
+ if( aAttrTab.pINetFmt )
+ {
+ const SwFmtINetFmt &rINetFmt =
+ (const SwFmtINetFmt&)aAttrTab.pINetFmt->GetItem();
+
+ SwFmtURL aURL( pFlyFmt->GetURL() );
+
+ aURL.SetURL( rINetFmt.GetValue(), bIsMap );
+ aURL.SetTargetFrameName( rINetFmt.GetTargetFrame() );
+ aURL.SetName( rINetFmt.GetName() );
+ pFlyFmt->SetAttr( aURL );
+
+ {
+ const SvxMacro *pMacro;
+ static USHORT __READONLY_DATA aEvents[] = {
+ SFX_EVENT_MOUSEOVER_OBJECT,
+ SFX_EVENT_MOUSECLICK_OBJECT,
+ SFX_EVENT_MOUSEOUT_OBJECT,
+ 0 };
+
+ for( USHORT n = 0; aEvents[ n ]; ++n )
+ if( 0 != ( pMacro = rINetFmt.GetMacro( aEvents[ n ] ) ))
+ aMacroItem.SetMacro( aEvents[ n ], *pMacro );
+ }
+
+ if( FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() &&
+ aAttrTab.pINetFmt->GetSttPara() ==
+ pPam->GetPoint()->nNode &&
+ aAttrTab.pINetFmt->GetSttCnt() ==
+ pPam->GetPoint()->nContent.GetIndex() - 1 )
+ {
+ // das Attribut wurde unmitellbar vor einer zeichengeb.
+ // Grafik eingefuegt, also verschieben wir es
+ aAttrTab.pINetFmt->SetStart( *pPam->GetPoint() );
+
+ // Wenn das Attribut auch ein Sprungziel ist, fuegen
+ // wir noch eine Bookmark vor der Grafik ein, weil das
+ // SwFmtURL kein Sprungziel ist.
+ if( rINetFmt.GetName().Len() )
+ {
+ pPam->Move( fnMoveBackward );
+ InsertBookmark( rINetFmt.GetName() );
+ pPam->Move( fnMoveForward );
+ }
+ }
+
+ }
+
+ if( aMacroItem.GetMacroTable().Count() )
+ pFlyFmt->SetAttr( aMacroItem );
+
+ // Wenn die Grafik gleich angeforder wird, muss dies geschehen,
+ // nachdem das Format vollstaendig aufgebaut ist, weil es evtl.
+ // gleich (synchron) angepasst wird (war bug #40983#)
+ if( bRequestGrfNow )
+ {
+ pGrfNd->SetTransferPriority( SFX_TFPRIO_VISIBLE_LOWRES_GRAPHIC );
+ pGrfNd->SwapIn();
+ }
+
+ // Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren
+ RegisterFlyFrm( pFlyFmt );
+
+ if( aId.Len() )
+ InsertBookmark( aId );
+}
+
+/* */
+
+void SwHTMLParser::InsertBodyOptions()
+{
+ pDoc->SetTxtFmtColl( *pPam,
+ pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_TEXT ) );
+
+ String aBackGround, aId, aStyle;
+ Color aBGColor, aTextColor, aLinkColor, aVLinkColor;
+ BOOL bBGColor=FALSE, bTextColor=FALSE;
+ BOOL bLinkColor=FALSE, bVLinkColor=FALSE;
+
+ ScriptType eDfltScriptType;
+ String sDfltScriptType;
+ GetDefaultScriptType( eDfltScriptType, sDfltScriptType );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ ScriptType eScriptType = eDfltScriptType;
+ USHORT nEvent;
+ BOOL bSetEvent = FALSE;
+
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_BACKGROUND:
+ aBackGround = pOption->GetString();
+ break;
+ case HTML_O_BGCOLOR:
+ pOption->GetColor( aBGColor );
+ bBGColor = TRUE;
+ break;
+ case HTML_O_TEXT:
+ pOption->GetColor( aTextColor );
+ bTextColor = TRUE;
+ break;
+ case HTML_O_LINK:
+ pOption->GetColor( aLinkColor );
+ bLinkColor = TRUE;
+ break;
+ case HTML_O_VLINK:
+ pOption->GetColor( aVLinkColor );
+ bVLinkColor = TRUE;
+ break;
+
+ case HTML_O_SDONLOAD:
+ eScriptType = STARBASIC;
+ case HTML_O_ONLOAD:
+ nEvent = SFX_EVENT_OPENDOC;
+ bSetEvent = TRUE;
+ break;
+
+ case HTML_O_SDONUNLOAD:
+ eScriptType = STARBASIC;
+ case HTML_O_ONUNLOAD:
+ nEvent = SFX_EVENT_PREPARECLOSEDOC;
+ bSetEvent = TRUE;
+ break;
+
+ case HTML_O_SDONFOCUS:
+ eScriptType = STARBASIC;
+ case HTML_O_ONFOCUS:
+ nEvent = SFX_EVENT_ACTIVATEDOC;
+ bSetEvent = TRUE;
+ break;
+
+ case HTML_O_SDONBLUR:
+ eScriptType = STARBASIC;
+ case HTML_O_ONBLUR:
+ nEvent = SFX_EVENT_DEACTIVATEDOC;
+ bSetEvent = TRUE;
+ break;
+
+ case HTML_O_ONERROR:
+// if( bAnyStarBasic )
+// InsertBasicDocEvent( SFX_EVENT_ACTIVATEDOC,
+// pOption->GetString() );
+ break;
+
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ bTextColor = TRUE;
+ break;
+ }
+
+ if( bSetEvent )
+ {
+ const String& rEvent = pOption->GetString();
+ if( rEvent.Len() )
+ InsertBasicDocEvent( nEvent, rEvent, eScriptType,
+ sDfltScriptType );
+ }
+ }
+
+ if( bTextColor && !pCSS1Parser->IsBodyTextSet() )
+ {
+ // Die Textfarbe wird an der Standard-Vorlage gesetzt
+ pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )
+ ->SetAttr( SvxColorItem(aTextColor) );
+ pCSS1Parser->SetBodyTextSet();
+ }
+
+
+ // Die Item fuer die Seitenvorlage vorbereiten (Hintergrund, Umrandung)
+ // Beim BrushItem muessen schon gesetzte werte erhalten bleiben!
+ SvxBrushItem aBrushItem( pCSS1Parser->GetPageDescBackground() );
+ BOOL bSetBrush = FALSE;
+
+ if( bBGColor && !pCSS1Parser->IsBodyBGColorSet() )
+ {
+ // Hintergrundfarbe aus "BGCOLOR"
+ String aLink;
+ if( aBrushItem.GetGraphicLink() )
+ aLink = *aBrushItem.GetGraphicLink();
+ SvxGraphicPosition ePos = aBrushItem.GetGraphicPos();
+
+ aBrushItem.SetColor( aBGColor );
+
+ if( aLink.Len() )
+ {
+ aBrushItem.SetGraphicLink( aLink );
+ aBrushItem.SetGraphicPos( ePos );
+ }
+ bSetBrush = TRUE;
+ pCSS1Parser->SetBodyBGColorSet();
+ }
+
+ if( aBackGround.Len() && !pCSS1Parser->IsBodyBackgroundSet() )
+ {
+ // Hintergrundgrafik aus "BACKGROUND"
+ ASSERT( INetURLObject::GetBaseURL() == sBaseURL,
+ "<BODY>: Base URL ist zerschossen" );
+ aBrushItem.SetGraphicLink( INetURLObject::RelToAbs( aBackGround ) );
+ aBrushItem.SetGraphicPos( GPOS_TILED );
+ bSetBrush = TRUE;
+ pCSS1Parser->SetBodyBackgroundSet();
+ }
+
+ if( aStyle.Len() )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ pCSS1Parser->ParseStyleOption( aStyle, aItemSet, aPropInfo );
+
+ // Ein par Attribute muessen an der Seitenvorlage gesetzt werden,
+ // und zwar die, die nicht vererbit werden
+ pCSS1Parser->SetPageDescAttrs( bSetBrush ? &aBrushItem : 0,
+ &aItemSet );
+
+ // alle noch uebrigen Optionen koennen an der Standard-Vorlage
+ // gesetzt werden und gelten dann automatisch als defaults
+ pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )
+ ->SetAttr( aItemSet );
+ }
+ else if( bSetBrush )
+ {
+ pCSS1Parser->SetPageDescAttrs( &aBrushItem );
+ }
+
+ if( bLinkColor && !pCSS1Parser->IsBodyLinkSet() )
+ {
+ SwCharFmt *pCharFmt =
+ pCSS1Parser->GetCharFmtFromPool(RES_POOLCHR_INET_NORMAL);
+ pCharFmt->SetAttr( SvxColorItem(aLinkColor) );
+ pCSS1Parser->SetBodyLinkSet();
+ }
+ if( bVLinkColor && !pCSS1Parser->IsBodyVLinkSet() )
+ {
+ SwCharFmt *pCharFmt =
+ pCSS1Parser->GetCharFmtFromPool(RES_POOLCHR_INET_VISIT);
+ pCharFmt->SetAttr( SvxColorItem(aVLinkColor) );
+ pCSS1Parser->SetBodyVLinkSet();
+ }
+
+ if( aId.Len() )
+ InsertBookmark( aId );
+}
+
+/* */
+
+void SwHTMLParser::NewAnchor()
+{
+ // den voherigen Link beenden, falls es einen gab
+ _HTMLAttrContext *pOldCntxt = PopContext( HTML_ANCHOR_ON );
+ if( pOldCntxt )
+ {
+ // und ggf. die Attribute beenden
+ EndContext( pOldCntxt );
+ delete pOldCntxt;
+ }
+
+ SvxMacroTableDtor aMacroTbl;
+ String sHRef, aName, sTarget;
+ String aId, aStyle, aClass;
+ BOOL bHasHRef = FALSE, bFixed = FALSE;
+
+ ScriptType eDfltScriptType;
+ String sDfltScriptType;
+ GetDefaultScriptType( eDfltScriptType, sDfltScriptType );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ USHORT nEvent = 0;
+ ScriptType eScriptType = eDfltScriptType;
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_NAME:
+ aName = pOption->GetString();
+ break;
+
+ case HTML_O_HREF:
+ sHRef = pOption->GetString();
+ bHasHRef = TRUE;
+ break;
+ case HTML_O_TARGET:
+ sTarget = pOption->GetString();
+ break;
+
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_SDFIXED:
+ bFixed = TRUE;
+ break;
+
+ case HTML_O_SDONCLICK:
+ eScriptType = STARBASIC;
+ case HTML_O_ONCLICK:
+ nEvent = SFX_EVENT_MOUSECLICK_OBJECT;
+ goto ANCHOR_SETEVENT;
+
+ case HTML_O_SDONMOUSEOVER:
+ eScriptType = STARBASIC;
+ case HTML_O_ONMOUSEOVER:
+ nEvent = SFX_EVENT_MOUSEOVER_OBJECT;
+ goto ANCHOR_SETEVENT;
+
+ case HTML_O_SDONMOUSEOUT:
+ eScriptType = STARBASIC;
+ case HTML_O_ONMOUSEOUT:
+ nEvent = SFX_EVENT_MOUSEOUT_OBJECT;
+ goto ANCHOR_SETEVENT;
+ANCHOR_SETEVENT:
+ {
+ String sTmp( pOption->GetString() );
+ if( sTmp.Len() )
+ {
+ sTmp.ConvertLineEnd();
+ String sScriptType;
+ if( EXTENDED_STYPE == eScriptType )
+ sScriptType = sDfltScriptType;
+ aMacroTbl.Insert( nEvent,
+ new SvxMacro( sTmp, sScriptType, eScriptType ));
+ }
+ }
+ break;
+
+ }
+ }
+
+ // Sprungziele, die unseren ipmliziten Zielen entsprechen, schmeissen
+ // wir hier ganz rigoros raus.
+ if( aName.Len() )
+ {
+ xub_StrLen nLastPos, nPos = aName.Search( cMarkSeperator );
+ if( STRING_NOTFOUND != nPos )
+ {
+ while( STRING_NOTFOUND !=
+ ( nLastPos = aName.Search( cMarkSeperator, nPos + 1 )) )
+ nPos = nLastPos;
+
+ String sCmp( aName.Copy( nPos+1 ) );
+ sCmp.EraseAllChars();
+ if( sCmp.Len() )
+ {
+ sCmp.ToLowerAscii();
+ if( sCmp.EqualsAscii( pMarkToRegion ) ||
+ sCmp.EqualsAscii( pMarkToFrame ) ||
+ sCmp.EqualsAscii( pMarkToGraphic ) ||
+ sCmp.EqualsAscii( pMarkToOLE ) ||
+ sCmp.EqualsAscii( pMarkToTable ) ||
+ sCmp.EqualsAscii( pMarkToOutline ) ||
+ sCmp.EqualsAscii( pMarkToText ) )
+ {
+ aName.Erase();
+ }
+ }
+ }
+ }
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_ANCHOR_ON );
+
+ BOOL bEnAnchor = FALSE, bFtnAnchor = FALSE, bFtnEnSymbol = FALSE;
+ String aFtnName;
+ if( aClass.Len() >=9 && bHasHRef && sHRef.Len() > 1 &&
+ ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0)) &&
+ ('d' == aClass.GetChar(1) || 'D' == aClass.GetChar(1)) )
+ {
+ if( aClass.EqualsIgnoreCaseAscii( sHTML_sdendnote_anc ) )
+ bEnAnchor = TRUE;
+ else if( aClass.EqualsIgnoreCaseAscii( sHTML_sdfootnote_anc ) )
+ bFtnAnchor = TRUE;
+ else if( aClass.EqualsIgnoreCaseAscii( sHTML_sdendnote_sym ) ||
+ aClass.EqualsIgnoreCaseAscii( sHTML_sdfootnote_sym ) )
+ bFtnEnSymbol = TRUE;
+ if( bEnAnchor || bFtnAnchor || bFtnEnSymbol )
+ {
+ aFtnName = sHRef.Copy( 1 );
+ aClass = aName = aEmptyStr;
+ bHasHRef = FALSE;
+ }
+ }
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ {
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, TRUE );
+ }
+ }
+
+ if( bHasHRef )
+ {
+ if( sHRef.Len() )
+ {
+ ASSERT( INetURLObject::GetBaseURL() == sBaseURL,
+ "<A>: Base URL ist zerschossen" );
+ sHRef = INetURLObject::RelToAbs( sHRef );
+ }
+ else
+ {
+ // Bei leerer URL das Directory nehmen
+ INetURLObject aURLObj( aPathToFile );
+ sHRef = aURLObj.GetPartBeforeLastName();
+ }
+
+ pCSS1Parser->SetATagStyles();
+ SwFmtINetFmt aINetFmt( sHRef, sTarget );
+ aINetFmt.SetName( aName );
+
+ if( aMacroTbl.Count() )
+ aINetFmt.SetMacroTbl( &aMacroTbl );
+
+ // das Default-Attribut setzen
+ InsertAttr( &aAttrTab.pINetFmt, aINetFmt, pCntxt );
+ }
+ else if( aName.Len() )
+ {
+ InsertBookmark( aName );
+ }
+
+ if( bEnAnchor || bFtnAnchor )
+ {
+ InsertFootEndNote( aFtnName, bEnAnchor, bFixed );
+ bInFootEndNoteAnchor = bCallNextToken = TRUE;
+ }
+ else if( bFtnEnSymbol )
+ {
+ bInFootEndNoteSymbol = bCallNextToken = TRUE;
+ }
+
+ // den Kontext merken
+ PushContext( pCntxt );
+}
+
+void SwHTMLParser::EndAnchor()
+{
+ if( bInFootEndNoteAnchor )
+ {
+ FinishFootEndNote();
+ bInFootEndNoteAnchor = FALSE;
+ }
+ else if( bInFootEndNoteSymbol )
+ {
+ bInFootEndNoteSymbol = FALSE;
+ }
+
+ EndTag( HTML_ANCHOR_OFF );
+}
+
+/* */
+
+void SwHTMLParser::InsertBookmark( const String& rName )
+{
+ _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(),
+ SfxStringItem( RES_FLTR_BOOKMARK, rName ));
+ aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
+}
+
+BOOL SwHTMLParser::HasCurrentParaBookmarks( BOOL bIgnoreStack ) const
+{
+ BOOL bHasMarks = FALSE;
+ ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
+
+ // 1. Schritt: befinden sich noch Bookmarks m Attribut-Stack?
+ // Bookmarks werden hinten in den Stack geschrieben. Wir muessen
+ // also nur die letzte Bookmark betrachten
+ if( !bIgnoreStack )
+ {
+ _HTMLAttr* pAttr;
+ for( USHORT i = aSetAttrTab.Count(); i; )
+ {
+ pAttr = aSetAttrTab[ --i ];
+ if( RES_FLTR_BOOKMARK == pAttr->pItem->Which() )
+ {
+ if( pAttr->GetSttParaIdx() == nNodeIdx )
+ bHasMarks = TRUE;
+ break;
+ }
+ }
+ }
+
+ if( !bHasMarks )
+ {
+ // 2. Schritt: Wenn wir keine Bookmark gefunden haben, schauen wir,
+ // ob schon eine gesetzt ist
+ const SwBookmarks& rBookmarks = pDoc->GetBookmarks();
+ for( USHORT i=0; i<rBookmarks.Count(); i++ )
+ {
+ const SwBookmark* pBookmark = rBookmarks[i];
+ ULONG nBookNdIdx = pBookmark->GetPos().nNode.GetIndex();
+ if( nBookNdIdx==nNodeIdx )
+ {
+ bHasMarks = TRUE;
+ break;
+ }
+ else if( nBookNdIdx > nNodeIdx )
+ break;
+ }
+ }
+
+ return bHasMarks;
+}
+
+/* */
+
+void SwHTMLParser::StripTrailingPara()
+{
+ BOOL bSetSmallFont = FALSE;
+
+ SwCntntNode* pCNd = pPam->GetCntntNode();
+ if( !pPam->GetPoint()->nContent.GetIndex() )
+ {
+ if( pCNd && pCNd->StartOfSectionIndex()+2 <
+ pCNd->EndOfSectionIndex() )
+ {
+ ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
+
+ USHORT i;
+
+ const SwFrmFmt* pFmt;
+ const SwFmtAnchor* pAnchor;
+ const SwPosition* pAPos;
+ const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
+
+ for( i=0; i<rFrmFmtTbl.Count(); i++ )
+ {
+ pFmt = rFrmFmtTbl[i];
+ pAnchor = &pFmt->GetAnchor();
+ if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) &&
+ (FLY_AT_CNTNT == pAnchor->GetAnchorId() ||
+ FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) &&
+ pAPos->nNode == nNodeIdx )
+
+ return; // den Knoten duerfen wir nicht loeschen
+ }
+
+ SetAttr( FALSE ); // die noch offenen Attribute muessen
+ // beendet werden, bevor der Node
+ // geloescht wird, weil sonst der
+ // End-Index in die Botanik zeigt
+
+ if( pCNd->Len() && pCNd->IsTxtNode() )
+ {
+ // es wurden Felder in den Node eingefuegt, die muessen
+ // wir jetzt verschieben
+ SwTxtNode *pPrvNd = pDoc->GetNodes()[nNodeIdx-1]->GetTxtNode();
+ if( pPrvNd )
+ {
+ SwIndex aSrc( pCNd, 0 );
+ pCNd->GetTxtNode()->Cut( pPrvNd, aSrc, pCNd->Len() );
+ }
+ }
+
+ // jetz muessen wir noch eventuell vorhandene Bookmarks
+ // verschieben
+ const SwBookmarks& rBookmarks = pDoc->GetBookmarks();
+ for( i=0; i<rBookmarks.Count(); i++ )
+ {
+ const SwBookmark* pBookmark = rBookmarks[i];
+ ULONG nBookNdIdx = pBookmark->GetPos().nNode.GetIndex();
+ if( nBookNdIdx==nNodeIdx )
+ {
+ SwPosition &rBookmkPos =
+ (SwPosition&)pBookmark->GetPos();
+
+ SwNodeIndex nNewNdIdx( pPam->GetPoint()->nNode );
+ SwCntntNode* pCNd = pDoc->GetNodes().GoPrevious( &nNewNdIdx );
+ if( !pCNd )
+ {
+ ASSERT( !this, "Hoppla, wo ist mein Vorgaenger-Node" );
+ return;
+ }
+
+ rBookmkPos.nNode = nNewNdIdx;
+ rBookmkPos.nContent.Assign( pCNd, pCNd->Len() );
+ }
+ else if( nBookNdIdx > nNodeIdx )
+ break;
+ }
+
+ pPam->GetPoint()->nContent.Assign( 0, 0 );
+ pPam->SetMark();
+ pPam->DeleteMark();
+ pDoc->GetNodes().Delete( pPam->GetPoint()->nNode );
+ pPam->Move( fnMoveBackward, fnGoNode );
+ }
+ else if( pCNd && pCNd->IsTxtNode() && pTable )
+ {
+ // In leeren Zellen stellen wir einen kleinen Font ein, damit die
+ // Zelle nicht hoeher wird als die Grafik bzw. so niedrig wie
+ // moeglich bleibt.
+ bSetSmallFont = TRUE;
+ }
+ }
+ else if( pCNd && pCNd->IsTxtNode() && pTable &&
+ pCNd->StartOfSectionIndex()+2 ==
+ pCNd->EndOfSectionIndex() )
+ {
+ // Wenn die Zelle nur zeichengebundene Grafiken/Rahmen enthaelt
+ // stellen wir ebenfalls einen kleinen Font ein.
+ bSetSmallFont = TRUE;
+ SwTxtNode* pTxtNd = pCNd->GetTxtNode();
+
+ xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
+ while( bSetSmallFont && nPos>0 )
+ {
+ bSetSmallFont = CH_TXTATR_BREAKWORD ==
+ pTxtNd->GetTxt().GetChar( --nPos ) &&
+ 0 != pTxtNd->GetTxtAttr( nPos, RES_TXTATR_FLYCNT );
+ }
+ }
+
+ if( bSetSmallFont )
+ {
+ pCNd->SetAttr( SvxFontHeightItem(40) );
+ }
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlgrin.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.130 2000/09/18 16:04:45 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.129 2000/08/31 10:59:55 jp
+ add missing include
+
+ Revision 1.128 2000/07/20 13:16:10 jp
+ change old txtatr-character to the two new characters
+
+ Revision 1.127 2000/06/26 09:52:14 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.126 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.125 2000/03/03 15:21:01 os
+ StarView remainders removed
+
+ Revision 1.124 2000/03/03 12:44:32 mib
+ Removed JavaScript
+
+ Revision 1.123 2000/02/11 14:37:12 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.122 1999/12/03 08:40:07 jp
+ Task #70407#: use new GrfObj instead of Grafik with Cache (first only with define)
+
+ Revision 1.121 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.120 1999/09/17 12:13:28 mib
+ support of multiple and non system text encodings
+
+ Revision 1.119 1999/06/10 08:34:12 JP
+ have to change: no AppWin from SfxApp
+
+
+ Rev 1.118 10 Jun 1999 10:34:12 JP
+ have to change: no AppWin from SfxApp
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlnum.cxx b/sw/source/filter/html/htmlnum.cxx
new file mode 100644
index 000000000000..8af84175b4aa
--- /dev/null
+++ b/sw/source/filter/html/htmlnum.cxx
@@ -0,0 +1,997 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlnum.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+
+#ifndef _NUMRULE_HXX
+#include <numrule.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+
+#include "htmlnum.hxx"
+#include "swcss1.hxx"
+#include "swhtml.hxx"
+#include "wrthtml.hxx"
+
+// TODO: Unicode: Are these characters the correct ones?
+#define HTML_BULLETCHAR_DISC (0xf000 + 34)
+#define HTML_BULLETCHAR_CIRCLE (0xf000 + 38)
+#define HTML_BULLETCHAR_SQUARE (0xf000 + 36)
+
+
+// <UL TYPE=...>
+static HTMLOptionEnum __FAR_DATA aHTMLULTypeTable[] =
+{
+ { sHTML_ULTYPE_disc, HTML_BULLETCHAR_DISC },
+ { sHTML_ULTYPE_circle, HTML_BULLETCHAR_CIRCLE },
+ { sHTML_ULTYPE_square, HTML_BULLETCHAR_SQUARE },
+ { 0, 0 }
+};
+
+/* */
+
+void SwHTMLNumRuleInfo::Set( const SwTxtNode& rTxtNd )
+{
+ if( rTxtNd.GetNum() )
+ {
+ pNumRule = (SwNumRule *)rTxtNd.GetNumRule();
+ const SwNodeNum& rNum = *rTxtNd.GetNum();
+ nDeep = pNumRule ? GetRealLevel( rNum.GetLevel() )+1 : 0;
+ bNumbered = (rNum.GetLevel() & NO_NUMLEVEL) == 0;
+ bRestart = rTxtNd.GetNum()->IsStart();
+ }
+ else
+ {
+ pNumRule = 0;
+ nDeep = 0;
+ bNumbered = bRestart = sal_False;
+ }
+
+#ifndef NUM_RELSPACE
+ bUpdateWholeNum = sal_False;
+#endif
+}
+
+/* */
+
+void SwHTMLParser::NewNumBulList( int nToken )
+{
+ SwHTMLNumRuleInfo& rInfo = GetNumInfo();
+
+ // Erstmal einen neuen Absatz aufmachen
+ sal_Bool bSpace = (rInfo.GetDepth() + nDefListDeep) == 0;
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( bSpace ? AM_SPACE : AM_NOSPACE, sal_False );
+ else if( bSpace )
+ AddParSpace();
+
+ // Die Numerierung-Ebene erhoehen
+ rInfo.IncDepth();
+ sal_uInt8 nLevel = (sal_uInt8)( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
+ : MAXLEVEL) - 1 );
+
+ // ggf. ein Regelwerk anlegen
+ if( !rInfo.GetNumRule() )
+ {
+ sal_uInt16 nPos = pDoc->MakeNumRule( pDoc->GetUniqueNumRuleName() );
+ rInfo.SetNumRule( pDoc->GetNumRuleTbl()[nPos] );
+ }
+
+ // das Format anpassen, falls es fuer den Level noch nicht
+ // geschehen ist!
+ sal_Bool bNewNumFmt = rInfo.GetNumRule()->GetNumFmt( nLevel ) == 0;
+ sal_Bool bChangeNumFmt = sal_False;
+
+ // das default Numerierungsformat erstellen
+ SwNumFmt aNumFmt( rInfo.GetNumRule()->Get(nLevel) );
+ rInfo.SetNodeStartValue( nLevel );
+ if( bNewNumFmt )
+ {
+ sal_uInt16 nChrFmtPoolId = 0;
+ if( HTML_ORDERLIST_ON == nToken )
+ {
+ aNumFmt.eType = SVX_NUM_ARABIC;
+ nChrFmtPoolId = RES_POOLCHR_NUM_LEVEL;
+ }
+ else
+ {
+ // Wir setzen hier eine Zeichenvorlage, weil die UI das auch
+ // so macht. Dadurch wurd immer auch eine 9pt-Schrift
+ // eingestellt, was in Netscape nicht der Fall ist. Bisher hat
+ // das noch niemanden gestoert.
+ aNumFmt.SetBulletFont( &rInfo.GetNumRule()->GetDefBulletFont() );
+ aNumFmt.eType = SVX_NUM_CHAR_SPECIAL;
+ aNumFmt.SetBulletChar( cBulletChar ); // das Bulletzeichen !!
+ nChrFmtPoolId = RES_POOLCHR_BUL_LEVEL;
+ }
+
+#ifdef NUM_RELSPACE
+ sal_uInt16 nAbsLSpace = HTML_NUMBUL_MARGINLEFT;
+ short nFirstLineIndent = HTML_NUMBUL_INDENT;
+ if( nLevel > 0 )
+ {
+ const SwNumFmt& rPrevNumFmt = rInfo.GetNumRule()->Get( nLevel-1 );
+ nAbsLSpace += rPrevNumFmt.GetAbsLSpace();
+ nFirstLineIndent = rPrevNumFmt.GetFirstLineOffset();
+ }
+ aNumFmt.SetAbsLSpace( nAbsLSpace );
+ aNumFmt.SetFirstLineOffset( nFirstLineIndent );
+#else
+ aNumFmt.SetAbsLSpace( (nLevel+1) * HTML_NUMBUL_MARGINLEFT );
+ aNumFmt.SetFirstLineOffset( HTML_NUMBUL_INDENT );
+#endif
+ aNumFmt.SetCharFmt( pCSS1Parser->GetCharFmtFromPool(nChrFmtPoolId) );
+ bChangeNumFmt = sal_True;
+ }
+ else if( 1 != aNumFmt.GetStartValue() )
+ {
+ // Wenn die Ebene schon mal benutzt wurde, muss der Start-Wert
+ // ggf. hart am Absatz gesetzt werden.
+ rInfo.SetNodeStartValue( nLevel, 1 );
+ }
+
+ // und es ggf. durch die Optionen veraendern
+ String aId, aStyle, aClass, aBulletSrc;
+ SwVertOrient eVertOri = VERT_NONE;
+ sal_uInt16 nWidth=USHRT_MAX, nHeight=USHRT_MAX;
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_TYPE:
+ if( bNewNumFmt && pOption->GetString().Len() )
+ {
+ switch( nToken )
+ {
+ case HTML_ORDERLIST_ON:
+ bChangeNumFmt = sal_True;
+ switch( pOption->GetString().GetChar(0) )
+ {
+ case 'A': aNumFmt.eType = SVX_NUM_CHARS_UPPER_LETTER; break;
+ case 'a': aNumFmt.eType = SVX_NUM_CHARS_LOWER_LETTER; break;
+ case 'I': aNumFmt.eType = SVX_NUM_ROMAN_UPPER; break;
+ case 'i': aNumFmt.eType = SVX_NUM_ROMAN_LOWER; break;
+ default: bChangeNumFmt = sal_False;
+ }
+ break;
+
+ case HTML_UNORDERLIST_ON:
+ aNumFmt.SetBulletChar( (sal_Unicode)pOption->GetEnum(
+ aHTMLULTypeTable,aNumFmt.GetBulletChar() ) );
+ bChangeNumFmt = sal_True;
+ break;
+ }
+ }
+ break;
+ case HTML_O_START:
+ {
+ sal_uInt16 nStart = (sal_uInt16)pOption->GetNumber();
+ if( bNewNumFmt )
+ {
+ aNumFmt.SetStartValue( nStart );
+ bChangeNumFmt = sal_True;
+ }
+ else
+ {
+ rInfo.SetNodeStartValue( nLevel, nStart );
+ }
+ }
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_SRC:
+ if( bNewNumFmt )
+ {
+ aBulletSrc = pOption->GetString();
+ if( !InternalImgToPrivateURL(aBulletSrc) )
+ aBulletSrc = INetURLObject::RelToAbs( aBulletSrc );
+ }
+ break;
+ case HTML_O_WIDTH:
+ nWidth = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_HEIGHT:
+ nHeight = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_ALIGN:
+ eVertOri =
+ (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable,
+ eVertOri );
+ break;
+ }
+ }
+
+ if( aBulletSrc.Len() )
+ {
+ // Eine Bullet-Liste mit Grafiken
+ aNumFmt.eType = SVX_NUM_BITMAP;
+
+ // Die Grafik als Brush anlegen
+ SvxBrushItem aBrushItem;
+ aBrushItem.SetGraphicLink( aBulletSrc );
+ aBrushItem.SetGraphicPos( GPOS_AREA );
+
+ // Die Groesse nur beachten, wenn Breite und Hoehe vorhanden sind
+ Size aTwipSz( nWidth, nHeight), *pTwipSz=0;
+ if( nWidth!=USHRT_MAX && nHeight!=USHRT_MAX )
+ {
+ aTwipSz =
+ Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
+ MapMode(MAP_TWIP) );
+ pTwipSz = &aTwipSz;
+ }
+
+ // Die Ausrichtung auch nur beachten, wenn eine Ausrichtung
+ // angegeben wurde
+ SwFmtVertOrient aVertOri( 0, eVertOri );
+ SwFmtVertOrient *pVertOri = VERT_NONE!=eVertOri ? &aVertOri : 0;
+
+ aNumFmt.SetGrfBrush( &aBrushItem, pTwipSz, pVertOri );
+
+ // Und noch die Grafik merken, um sie in den Absaetzen nicht
+ // einzufuegen
+ aBulletGrfs[nLevel] = aBulletSrc;
+ bChangeNumFmt = sal_True;
+ }
+ else
+ aBulletGrfs[nLevel].Erase();
+
+ // den aktuellen Absatz erst einmal nicht numerieren
+ SetNodeNum( nLevel | NO_NUMLEVEL );
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+#ifndef NUM_RELSPACE
+ // darin auch die Raender merken
+ sal_uInt16 nLeft=0, nRight=0;
+ short nIndent=0;
+ GetMarginsFromContext( nLeft, nRight, nIndent );
+ nLeft += HTML_NUMBUL_MARGINLEFT;
+ pCntxt->SetMargins( nLeft, nRight, nIndent );
+#endif
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ {
+#ifdef NUM_RELSPACE
+ if( bNewNumFmt )
+ {
+ if( aPropInfo.bLeftMargin )
+ {
+ // Der Der Default-Einzug wurde schon eingefuegt.
+ sal_uInt16 nAbsLSpace =
+ aNumFmt.GetAbsLSpace() - HTML_NUMBUL_MARGINLEFT;
+ if( aPropInfo.nLeftMargin < 0 &&
+ nAbsLSpace < -aPropInfo.nLeftMargin )
+ nAbsLSpace = 0U;
+ else if( aPropInfo.nLeftMargin > USHRT_MAX ||
+ (long)nAbsLSpace +
+ aPropInfo.nLeftMargin > USHRT_MAX )
+ nAbsLSpace = USHRT_MAX;
+ else
+ nAbsLSpace = nAbsLSpace + (sal_uInt16)aPropInfo.nLeftMargin;
+
+ aNumFmt.SetAbsLSpace( nAbsLSpace );
+ bChangeNumFmt = sal_True;
+ }
+ if( aPropInfo.bTextIndent )
+ {
+ short nTextIndent =
+ ((const SvxLRSpaceItem &)aItemSet.Get( RES_LR_SPACE ))
+ .GetTxtFirstLineOfst();
+ aNumFmt.SetFirstLineOffset( nTextIndent );
+ bChangeNumFmt = sal_True;
+ }
+ }
+ aPropInfo.bLeftMargin = aPropInfo.bTextIndent = sal_False;
+ if( !aPropInfo.bRightMargin )
+ aItemSet.ClearItem( RES_LR_SPACE );
+#endif
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ if( bChangeNumFmt )
+ {
+ rInfo.GetNumRule()->Set( nLevel, aNumFmt );
+ pDoc->ChgNumRuleFmts( *rInfo.GetNumRule() );
+ }
+
+ PushContext( pCntxt );
+
+ // die Attribute der neuen Vorlage setzen
+ SetTxtCollAttrs( pCntxt );
+}
+
+void SwHTMLParser::EndNumBulList( int nToken )
+{
+ SwHTMLNumRuleInfo& rInfo = GetNumInfo();
+
+ // Ein neuer Absatz muss aufgemacht werden, wenn
+ // - der aktuelle nicht leer ist, also Text oder absatzgebundene Objekte
+ // enthaelt.
+ // - der aktuelle Absatz numeriert ist.
+ sal_Bool bAppend = pPam->GetPoint()->nContent.GetIndex() > 0;
+ if( !bAppend )
+ {
+ SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
+ bAppend = (pTxtNode && pTxtNode->GetNum() &&
+ !(NO_NUMLEVEL & pTxtNode->GetNum()->GetLevel())) ||
+ HasCurrentParaFlys();
+ }
+
+ sal_Bool bSpace = (rInfo.GetDepth() + nDefListDeep) == 1;
+ if( bAppend )
+ AppendTxtNode( bSpace ? AM_SPACE : AM_NOSPACE, sal_False );
+ else if( bSpace )
+ AddParSpace();
+
+ // den aktuellen Kontext vom Stack holen
+ _HTMLAttrContext *pCntxt = nToken!=0 ? PopContext( nToken & ~1 ) : 0;
+
+ // Keine Liste aufgrund eines Tokens beenden, wenn der Kontext
+ // nie angelgt wurde oder nicht beendet werden darf.
+ if( rInfo.GetDepth()>0 && (!nToken || pCntxt) )
+ {
+ rInfo.DecDepth();
+ if( !rInfo.GetDepth() ) // wars der letze Level ?
+ {
+ // Die noch nicht angepassten Formate werden jetzt noch
+ // angepasst, damit es sich besser Editieren laesst.
+ const SwNumFmt *pRefNumFmt = 0;
+ sal_Bool bChanged = sal_False;
+ for( sal_uInt16 i=0; i<MAXLEVEL; i++ )
+ {
+ const SwNumFmt *pNumFmt = rInfo.GetNumRule()->GetNumFmt(i);
+ if( pNumFmt )
+ {
+ pRefNumFmt = pNumFmt;
+ }
+ else if( pRefNumFmt )
+ {
+ SwNumFmt aNumFmt( rInfo.GetNumRule()->Get(i) );
+ aNumFmt.eType = pRefNumFmt->eType != SVX_NUM_BITMAP
+ ? pRefNumFmt->eType : SVX_NUM_CHAR_SPECIAL;
+ if( SVX_NUM_CHAR_SPECIAL == aNumFmt.eType )
+ {
+ aNumFmt.SetBulletFont(
+ &rInfo.GetNumRule()->GetDefBulletFont() );
+ aNumFmt.SetBulletChar( cBulletChar );
+ }
+ aNumFmt.SetAbsLSpace( (i+1) * HTML_NUMBUL_MARGINLEFT );
+ aNumFmt.SetFirstLineOffset( HTML_NUMBUL_INDENT );
+ aNumFmt.SetCharFmt( pRefNumFmt->GetCharFmt() );
+ rInfo.GetNumRule()->Set( i, aNumFmt );
+ bChanged = sal_True;
+ }
+ }
+ if( bChanged )
+ pDoc->ChgNumRuleFmts( *rInfo.GetNumRule() );
+
+ // Beim letzen Append wurde das NumRule-Item und das
+ // NodeNum-Objekt mit kopiert. Beides muessen wir noch
+ // loeschen. Das ResetAttr loescht das NodeNum-Objekt mit!
+ pPam->GetNode()->GetTxtNode()->ResetAttr( RES_PARATR_NUMRULE );
+
+#ifndef NUM_RELSPACE
+ // Die Numerierung komplett beenden.
+ if( pTable )
+ UpdateNumRuleInTable();
+#endif
+ rInfo.Clear();
+ }
+ else
+ {
+ // den naechsten Absatz erstmal nicht numerieren
+ SetNodeNum( rInfo.GetLevel() | NO_NUMLEVEL );
+ }
+ }
+
+ // und noch Attribute beenden
+ sal_Bool bSetAttrs = sal_False;
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ delete pCntxt;
+ bSetAttrs = sal_True;
+ }
+
+ if( nToken )
+ SetTxtCollAttrs();
+
+ if( bSetAttrs )
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+
+}
+
+/* */
+
+void SwHTMLParser::NewNumBulListItem( int nToken )
+{
+ sal_uInt8 nLevel = GetNumInfo().GetLevel();
+ String aId, aStyle, aClass;
+ sal_uInt16 nStart = HTML_LISTHEADER_ON != nToken
+ ? GetNumInfo().GetNodeStartValue( nLevel )
+ : USHRT_MAX;
+ if( USHRT_MAX != nStart )
+ GetNumInfo().SetNodeStartValue( nLevel );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_VALUE:
+ nStart = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Absatz aufmachen
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_NOSPACE, sal_False );
+ bNoParSpace = sal_False; // In <LI> wird kein Abstand eingefuegt!
+
+ if( HTML_LISTHEADER_ON==nToken )
+ nLevel = nLevel | NO_NUMLEVEL;
+
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+ String aNumRuleName;
+ if( GetNumInfo().GetNumRule() )
+ {
+ aNumRuleName = GetNumInfo().GetNumRule()->GetName();
+ }
+ else
+ {
+ aNumRuleName = pDoc->GetUniqueNumRuleName();
+ SwNumRule aNumRule( aNumRuleName );
+ SwNumFmt aNumFmt( aNumRule.Get( 0 ) );
+ aNumFmt.SetBulletFont( &SwNumRule::GetDefBulletFont() );
+ aNumFmt.eType = SVX_NUM_CHAR_SPECIAL;
+ aNumFmt.SetBulletChar( cBulletChar ); // das Bulletzeichen !!
+ aNumFmt.SetCharFmt( pCSS1Parser->GetCharFmtFromPool(RES_POOLCHR_BUL_LEVEL) );
+ aNumFmt.SetLSpace( (sal_uInt16)(-HTML_NUMBUL_INDENT) );
+ aNumFmt.SetFirstLineOffset( HTML_NUMBUL_INDENT );
+ aNumRule.Set( 0, aNumFmt );
+
+ pDoc->MakeNumRule( aNumRuleName, &aNumRule );
+
+#ifndef NUM_RELSPACE
+ // Hier muessen wir hart attributieren
+ sal_uInt16 nLeft=0, nRight=0;
+ short nIndent=0;
+ GetMarginsFromContext( nLeft, nRight, nIndent );
+ nLeft += (sal_uInt16)(-HTML_NUMBUL_INDENT);
+ pCntxt->SetMargins( nLeft, nRight, nIndent );
+#endif
+
+ ASSERT( !nOpenParaToken,
+ "Jetzt geht ein offenes Absatz-Element verloren" );
+ // Wir tun so, als ob wir in einem Absatz sind. Dann wird
+ // beim naechsten Absatz wenigstens die Numerierung
+ // weggeschmissen, die nach dem naechsten AppendTxtNode uebernommen
+ // wird.
+ nOpenParaToken = nToken;
+ }
+
+ SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
+ ((SwCntntNode *)pTxtNode)->SetAttr( SwNumRuleItem(aNumRuleName) );
+ pTxtNode->UpdateNum( SwNodeNum( nLevel, nStart ) );
+#ifndef NUM_RELSPACE
+ pTxtNode->SetNumLSpace( GetNumInfo().GetNumRule()!=0 );
+#endif
+ if( GetNumInfo().GetNumRule() )
+ GetNumInfo().GetNumRule()->SetInvalidRule( sal_True );
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ {
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ PushContext( pCntxt );
+
+ // die neue Vorlage setzen
+ SetTxtCollAttrs( pCntxt );
+
+ // Laufbalkenanzeige aktualisieren
+ ShowStatline();
+}
+
+void SwHTMLParser::EndNumBulListItem( int nToken, sal_Bool bSetColl,
+ sal_Bool bLastPara )
+{
+ // einen neuen Absatz aufmachen
+ if( !nToken && pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_NOSPACE );
+
+ // Kontext zu dem Token suchen und vom Stack holen
+ _HTMLAttrContext *pCntxt = 0;
+ sal_uInt16 nPos = aContexts.Count();
+ nToken &= ~1;
+ while( !pCntxt && nPos>nContextStMin )
+ {
+ sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
+ switch( nCntxtToken )
+ {
+ case HTML_LI_ON:
+ case HTML_LISTHEADER_ON:
+ if( !nToken || nToken == nCntxtToken )
+ {
+ pCntxt = aContexts[nPos];
+ aContexts.Remove( nPos, 1 );
+ }
+ break;
+ case HTML_ORDERLIST_ON:
+ case HTML_UNORDERLIST_ON:
+ case HTML_MENULIST_ON:
+ case HTML_DIRLIST_ON:
+ // keine LI/LH ausserhalb der aktuellen Liste betrachten
+ nPos = nContextStMin;
+ break;
+ }
+ }
+
+ // und noch Attribute beenden
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+ delete pCntxt;
+ }
+
+ // und die bisherige Vorlage setzen
+ if( bSetColl )
+ SetTxtCollAttrs();
+}
+
+/* */
+
+void SwHTMLParser::SetNodeNum( sal_uInt8 nLevel )
+{
+ SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
+ ASSERT( pTxtNode, "Kein Text-Node an PaM-Position" );
+
+ ASSERT( GetNumInfo().GetNumRule(), "Kein Numerierungs-Regel" );
+ const String& rName = GetNumInfo().GetNumRule()->GetName();
+ ((SwCntntNode *)pTxtNode)->SetAttr( SwNumRuleItem(rName) );
+
+ pTxtNode->UpdateNum( SwNodeNum( nLevel ) );
+#ifndef NUM_RELSPACE
+ pTxtNode->SetNumLSpace( sal_True );
+#endif
+
+ // NumRule invalidieren, weil sie durch ein EndAction bereits
+ // auf valid geschaltet worden sein kann.
+ GetNumInfo().GetNumRule()->SetInvalidRule( sal_False );
+}
+
+
+#ifndef NUM_RELSPACE
+void SwHTMLParser::UpdateNumRuleInTable()
+{
+ // Wenn wir in einer Tabelle sind, muss die Numerierung wegen
+ // GetMixMaxSize gliech updatet werden. Wenn die Numerierung
+ // in einen Rahmen rein oder aus einem Rahmen heraus geschoben
+ // muss sie komplett updatet werden. Sonst genuegt es, sie
+ // innerhalb der aktuellen Zelle zu updaten.
+
+ ASSERT( GetNumInfo().GetNumRule(), "UpdateNumRuleInTable: Keine NumRule" );
+ ASSERT( pTable, "UpdateNumRuleInTable: Keine Tabele, Aufruf unneotig" );
+
+ sal_uInt32 nPos = ULONG_MAX;
+ if( !GetNumInfo().IsUpdateWholeNum() )
+ {
+ const SwStartNode *pSttNd = pPam->GetNode()->FindTableBoxStartNode();
+ ASSERT( pSttNd || pPam->GetNode()->FindFlyStartNode(),
+ "UpdateNumRuleInTable: Doch keine Tabelle?" );
+ if( pSttNd )
+ nPos = pSttNd->GetIndex();
+ }
+ pDoc->UpdateNumRule( GetNumInfo().GetNumRule()->GetName(), nPos );
+}
+#endif
+
+/* */
+
+void SwHTMLWriter::FillNextNumInfo()
+{
+ pNextNumRuleInfo = 0;
+
+ sal_uInt32 nPos = pCurPam->GetPoint()->nNode.GetIndex() + 1;
+
+ sal_Bool bDone = sal_False;
+ sal_Bool bTable = sal_False;
+ do
+ {
+ const SwNode* pNd = pDoc->GetNodes()[nPos];
+ if( pNd->IsTxtNode() )
+ {
+ // Der naechste wird als naechstes ausgegeben.
+ pNextNumRuleInfo = new SwHTMLNumRuleInfo( *pNd->GetTxtNode() );
+
+ // Vor einer Tabelle behalten wir erst einmal die alte Ebene bei,
+ // wenn die gleiche Numerierung hinter der Tabelle
+ // fortgesetzt wird und dort nicht von vorne numeriert
+ // wird. Die Tabelle wird ann beim Import so weit eingeruckt,
+ // wie es der Num-Ebene entspricht.
+ if( bTable &&
+ pNextNumRuleInfo->GetNumRule()==GetNumInfo().GetNumRule() &&
+ !pNextNumRuleInfo->IsRestart() )
+ {
+ pNextNumRuleInfo->SetDepth( GetNumInfo().GetDepth() );
+ }
+ }
+ else if( pNd->IsTableNode() )
+ {
+ // Eine Tabelle wird uebersprungen, also den Node
+ // hinter der Tabelle betrachten.
+ nPos = pNd->EndOfSectionIndex() + 1;
+ bTable = sal_True;
+ }
+ else
+ {
+ // In allen anderen Faellen ist die Numerierung erstmal
+ // zu Ende.
+ pNextNumRuleInfo = new SwHTMLNumRuleInfo;
+ }
+ }
+ while( !pNextNumRuleInfo );
+}
+
+void SwHTMLWriter::ClearNextNumInfo()
+{
+ delete pNextNumRuleInfo;
+ pNextNumRuleInfo = 0;
+}
+
+Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
+ const SwHTMLNumRuleInfo& rInfo )
+{
+ SwHTMLNumRuleInfo& rPrevInfo = rWrt.GetNumInfo();
+ sal_Bool bSameRule = rPrevInfo.GetNumRule() == rInfo.GetNumRule();
+ if( bSameRule && rPrevInfo.GetDepth() >= rInfo.GetDepth() &&
+ !rInfo.IsRestart() )
+ {
+ return rWrt;
+ }
+
+ DBG_ASSERT( rWrt.nLastParaToken == 0,
+ "<PRE> wurde nicht vor <OL> beendet." );
+ sal_uInt16 nPrevDepth =
+ (bSameRule && !rInfo.IsRestart()) ? rPrevInfo.GetDepth() : 0;
+
+ for( sal_uInt16 i=nPrevDepth; i<rInfo.GetDepth(); i++ )
+ {
+ rWrt.OutNewLine(); // <OL>/<UL> in eine neue Zeile
+
+ rWrt.aBulletGrfs[i].Erase();
+ ByteString sOut( '<' );
+ const SwNumFmt& rNumFmt = rInfo.GetNumRule()->Get( i );
+ SvxExtNumType eType = rNumFmt.eType;
+ if( SVX_NUM_CHAR_SPECIAL == eType )
+ {
+ // Aufzaehlungs-Liste: <OL>
+ sOut += sHTML_unorderlist;
+
+ // den Typ ueber das Bullet-Zeichen bestimmen
+ const sal_Char *pStr = 0;
+ switch( rNumFmt.GetBulletChar() )
+ {
+ case HTML_BULLETCHAR_DISC:
+ pStr = sHTML_ULTYPE_disc;
+ break;
+ case HTML_BULLETCHAR_CIRCLE:
+ pStr = sHTML_ULTYPE_circle;
+ break;
+ case HTML_BULLETCHAR_SQUARE:
+ pStr = sHTML_ULTYPE_square;
+ break;
+ }
+
+ if( pStr )
+ (((sOut += ' ') += sHTML_O_type) += '=') += pStr;
+ }
+ else if( SVX_NUM_BITMAP == eType )
+ {
+ // Aufzaehlungs-Liste: <OL>
+ sOut += sHTML_unorderlist;
+ rWrt.Strm() << sOut.GetBuffer();
+ sOut.Erase();
+
+ OutHTML_BulletImage( rWrt,
+ 0,
+ rNumFmt.GetGrfBrush(),
+ rWrt.aBulletGrfs[i],
+ rNumFmt.GetGrfSize(),
+ rNumFmt.GetGrfOrient() );
+ }
+ else
+ {
+ // Numerierungs-Liste: <UL>
+ sOut += sHTML_orderlist;
+
+ // den Typ ueber das Format bestimmen
+ sal_Char cType = 0;
+ switch( eType )
+ {
+ case SVX_NUM_CHARS_UPPER_LETTER: cType = 'A'; break;
+ case SVX_NUM_CHARS_LOWER_LETTER: cType = 'a'; break;
+ case SVX_NUM_ROMAN_UPPER: cType = 'I'; break;
+ case SVX_NUM_ROMAN_LOWER: cType = 'i'; break;
+ }
+ if( cType )
+ (((sOut += ' ') += sHTML_O_type) += '=') += cType;
+
+ // und evtl. den Startwert mit ausgeben
+ if( rNumFmt.GetStartValue() != 1 )
+ {
+ (((sOut += ' ') += sHTML_O_start) += '=')
+ += ByteString::CreateFromInt32( rNumFmt.GetStartValue() );
+ }
+ }
+
+ if( sOut.Len() )
+ rWrt.Strm() << sOut.GetBuffer();
+
+#ifdef NUM_RELSPACE
+ if( rWrt.bCfgOutStyles )
+ OutCSS1_NumBulListStyleOpt( rWrt, *rInfo.GetNumRule(), i );
+#endif
+
+ rWrt.Strm() << '>';
+
+ rWrt.IncIndentLevel(); // Inhalt von <OL> einruecken
+ }
+
+ return rWrt;
+}
+
+Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
+ const SwHTMLNumRuleInfo& rNextInfo )
+{
+ SwHTMLNumRuleInfo& rInfo = rWrt.GetNumInfo();
+ sal_Bool bSameRule = rNextInfo.GetNumRule() == rInfo.GetNumRule();
+ if( bSameRule && rNextInfo.GetDepth() >= rInfo.GetDepth() &&
+ !rNextInfo.IsRestart() )
+ {
+ return rWrt;
+ }
+
+ DBG_ASSERT( rWrt.nLastParaToken == 0,
+ "<PRE> wurde nicht vor </OL> beendet." );
+ sal_uInt16 nNextDepth =
+ (bSameRule && !rNextInfo.IsRestart()) ? rNextInfo.GetDepth() : 0;
+
+ // MIB 23.7.97: Die Schleife muss doch rueckwaerts durchlaufen
+ // werden, weil die Reihenfolge von </OL>/</UL> stimmen muss
+ for( sal_uInt16 i=rInfo.GetDepth(); i>nNextDepth; i-- )
+ {
+ rWrt.DecIndentLevel(); // Inhalt von <OL> einruecken
+ if( rWrt.bLFPossible )
+ rWrt.OutNewLine(); // </OL>/</UL> in eine neue Zeile
+
+ // es wird also eine Liste angefangen oder beendet:
+ SvxExtNumType eType = rInfo.GetNumRule()->Get( i-1 ).eType;
+ const sal_Char *pStr;
+ if( SVX_NUM_CHAR_SPECIAL == eType || SVX_NUM_BITMAP == eType)
+ pStr = sHTML_unorderlist;
+ else
+ pStr = sHTML_orderlist;
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), pStr, sal_False );
+ rWrt.bLFPossible = sal_True;
+ }
+
+ return rWrt;
+}
+
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.21 2000/09/18 16:04:45 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.20 2000/06/26 09:52:17 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.19 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.18 2000/03/21 15:06:18 os
+ UNOIII
+
+ Revision 1.17 2000/02/11 14:37:16 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.16 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.15 1999/09/17 12:13:32 mib
+ support of multiple and non system text encodings
+
+ Revision 1.14 1999/03/26 10:37:28 MIB
+ #63049#: Sofortige Numerierungs-Aktualisierung in Tabellen ist jetzt unnoetig
+
+
+ Rev 1.13 26 Mar 1999 11:37:28 MIB
+ #63049#: Sofortige Numerierungs-Aktualisierung in Tabellen ist jetzt unnoetig
+
+ Rev 1.12 23 Mar 1999 15:28:16 MIB
+ #63049#: Relative Einzuege in Numerierungen
+
+ Rev 1.11 17 Mar 1999 16:47:10 MIB
+ #63049#: Numerierungen mit relativen Abstaenden
+
+ Rev 1.10 27 Jan 1999 09:43:54 OS
+ #56371# TF_ONE51
+
+ Rev 1.9 06 Jan 1999 10:33:40 MIB
+ #60311#: In Listen fuer nicht-numerierte Absaetze keine <PRE> ausgeben
+
+ Rev 1.8 17 Nov 1998 10:44:30 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.7 05 Nov 1998 12:34:30 MIB
+ #59042#: Fuer nicht verwendete Numerierungs-Ebenen sinnvolle Defaults setzen
+
+ Rev 1.6 21 Apr 1998 13:46:58 MIB
+ fix: Keine ::com::sun::star::text::Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.5 03 Apr 1998 12:21:48 MIB
+ Export des Rahmen-Namens als ID
+
+ Rev 1.4 25 Mar 1998 12:09:24 MIB
+ unneotige defines weg
+
+ Rev 1.3 02 Mar 1998 18:32:16 MIB
+ fix #47671#: Erste Numerierung auf einer Ebene gewinnt, Startwert
+
+ Rev 1.2 20 Feb 1998 19:01:50 MA
+ header
+
+ Rev 1.1 10 Feb 1998 09:51:24 MIB
+ fix: Fuer Absatz-Abstand am Start-/Ende von Listen auch OL/UL/DL beachten
+
+ Rev 1.0 19 Jan 1998 16:16:26 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlnum.hxx b/sw/source/filter/html/htmlnum.hxx
new file mode 100644
index 000000000000..e032210d25b0
--- /dev/null
+++ b/sw/source/filter/html/htmlnum.hxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlnum.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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 _HTMLNUM_HXX
+#define _HTMLNUM_HXX
+
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#include <string.h>
+
+#define HTML_NUMBUL_MARGINLEFT (MM50*2 + MM50/2)
+#define HTML_NUMBUL_INDENT (-MM50)
+
+class SwTxtNode;
+class SwNumRule;
+
+class SwHTMLNumRuleInfo
+{
+ sal_uInt16 aNumStarts[MAXLEVEL];
+ SwNumRule * pNumRule; // Aktuelle Numerierung
+ sal_uInt16 nDeep; // aktuelle Num-Tiefe (1, 2, 3, ...)
+ sal_Bool bRestart : 1; // Export: Numerierung neu starten
+ sal_Bool bNumbered : 1; // Export: Absatz ist numeriert
+#ifndef NUM_RELSPACE
+ sal_Bool bUpdateWholeNum : 1; // Import: Muss die NumRule
+ // vollstaendig aktualisiert werden
+#endif
+
+public:
+
+ inline void Set( const SwHTMLNumRuleInfo& rInf );
+ void Set( const SwTxtNode& rTxtNd );
+
+ SwHTMLNumRuleInfo() :
+ pNumRule( 0 ), nDeep( 0 ),
+#ifndef NUM_RELSPACE
+ bUpdateWholeNum( sal_False ),
+#endif
+ bRestart( sal_False ), bNumbered( sal_False )
+ {
+ memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
+ }
+
+ SwHTMLNumRuleInfo( const SwHTMLNumRuleInfo& rInf ) :
+ pNumRule( rInf.pNumRule ), nDeep( rInf.nDeep ),
+#ifndef NUM_RELSPACE
+ bUpdateWholeNum( rInf.bUpdateWholeNum ),
+#endif
+ bRestart( rInf.bRestart ), bNumbered( rInf.bNumbered )
+ {
+ memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
+ }
+
+ SwHTMLNumRuleInfo( const SwTxtNode& rTxtNd ) { Set( rTxtNd ); }
+ inline SwHTMLNumRuleInfo& operator=( const SwHTMLNumRuleInfo& rInf );
+
+ inline void Clear();
+
+ void SetNumRule( const SwNumRule *pRule ) { pNumRule = (SwNumRule *)pRule; }
+ SwNumRule *GetNumRule() { return pNumRule; }
+ const SwNumRule *GetNumRule() const { return pNumRule; }
+
+ void SetDepth( sal_uInt16 nDepth ) { nDeep = nDepth; }
+ sal_uInt16 GetDepth() const { return nDeep; }
+ sal_uInt16 IncDepth() { return ++nDeep; }
+ sal_uInt16 DecDepth() { return nDeep==0 ? 0 : --nDeep; }
+ inline sal_uInt8 GetLevel() const;
+
+#ifndef NUM_RELSPACE
+ void SetUpdateWholeNum( sal_Bool bSet ) { bUpdateWholeNum = bSet; }
+ sal_Bool IsUpdateWholeNum() const { return bUpdateWholeNum; }
+#endif
+
+ void SetRestart( sal_Bool bSet ) { bRestart = bSet; }
+ sal_Bool IsRestart() const { return bRestart; }
+
+ void SetNumbered( sal_Bool bSet ) { bNumbered = bSet; }
+ sal_Bool IsNumbered() const { return bNumbered; }
+
+ inline void SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX );
+ sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return aNumStarts[nLvl]; }
+};
+
+inline SwHTMLNumRuleInfo& SwHTMLNumRuleInfo::operator=(
+ const SwHTMLNumRuleInfo& rInf )
+{
+ Set( rInf );
+ return *this;
+}
+
+inline void SwHTMLNumRuleInfo::Set( const SwHTMLNumRuleInfo& rInf )
+{
+ pNumRule = rInf.pNumRule;
+ nDeep = rInf.nDeep;
+#ifndef NUM_RELSPACE
+ bUpdateWholeNum = rInf.bUpdateWholeNum;
+#endif
+ bRestart = rInf.bRestart;
+ bNumbered = rInf.bNumbered;
+ memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
+}
+
+inline void SwHTMLNumRuleInfo::Clear()
+{
+ pNumRule = 0;
+ nDeep = 0;
+#ifndef NUM_RELSPACE
+ bUpdateWholeNum = sal_False;
+#endif
+ bRestart = bNumbered = sal_False;
+ memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
+}
+
+inline sal_uInt8 SwHTMLNumRuleInfo::GetLevel() const
+{
+ return
+ (sal_uInt8)( pNumRule!=0 && nDeep != 0
+ ? ( nDeep<=MAXLEVEL ? nDeep-1 : MAXLEVEL - 1 )
+ : 0 );
+}
+
+inline void SwHTMLNumRuleInfo::SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal )
+{
+ aNumStarts[nLvl] = nVal;
+}
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
new file mode 100644
index 000000000000..81e8112a42d5
--- /dev/null
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -0,0 +1,1360 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlplug.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#define _SVSTDARR_ULONGS
+#include <svtools/svstdarr.hxx>
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _FRMHTML_HXX //autogen
+#include <sfx2/frmhtml.hxx>
+#endif
+#ifndef _FRAMEOBJ_HXX //autogen
+#include <sfx2/frameobj.hxx>
+#endif
+#ifndef _FRMHTMLW_HXX //autogen
+#include <sfx2/frmhtmlw.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+#ifndef _APPLET_HXX //autogen
+#include <so3/applet.hxx>
+#endif
+#ifndef _PLUGIN_HXX //autogen
+#include <so3/plugin.hxx>
+#endif
+#ifndef _XOUTBMP_HXX //autogen
+#include <svx/xoutbmp.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+
+
+#include "pam.hxx"
+#include "doc.hxx"
+#include "ndtxt.hxx"
+#include "swerror.h"
+#include "ndole.hxx"
+#include "swtable.hxx"
+#include "swhtml.hxx"
+#include "wrthtml.hxx"
+#include "htmlfly.hxx"
+#include "swcss1.hxx"
+
+#define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
+#define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
+
+#define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
+#define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
+
+const ULONG HTML_FRMOPTS_EMBED_ALL =
+ HTML_FRMOPT_ALT |
+ HTML_FRMOPT_SIZE |
+ HTML_FRMOPT_NAME;
+const ULONG HTML_FRMOPTS_EMBED_CNTNR =
+ HTML_FRMOPTS_EMBED_ALL |
+ HTML_FRMOPT_ABSSIZE;
+const ULONG HTML_FRMOPTS_EMBED =
+ HTML_FRMOPTS_EMBED_ALL |
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SPACE |
+ HTML_FRMOPT_BRCLEAR |
+ HTML_FRMOPT_NAME;
+const ULONG HTML_FRMOPTS_HIDDEN_EMBED =
+ HTML_FRMOPT_ALT |
+ HTML_FRMOPT_NAME;
+
+const ULONG HTML_FRMOPTS_APPLET_ALL =
+ HTML_FRMOPT_ALT |
+ HTML_FRMOPT_SIZE;
+const ULONG HTML_FRMOPTS_APPLET_CNTNR =
+ HTML_FRMOPTS_APPLET_ALL |
+ HTML_FRMOPT_ABSSIZE;
+const ULONG HTML_FRMOPTS_APPLET =
+ HTML_FRMOPTS_APPLET_ALL |
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SPACE |
+ HTML_FRMOPT_BRCLEAR;
+
+const ULONG HTML_FRMOPTS_IFRAME_ALL =
+ HTML_FRMOPT_ALT |
+ HTML_FRMOPT_SIZE;
+const ULONG HTML_FRMOPTS_IFRAME_CNTNR =
+ HTML_FRMOPTS_IFRAME_ALL |
+ HTML_FRMOPT_ABSSIZE;
+const ULONG HTML_FRMOPTS_IFRAME =
+ HTML_FRMOPTS_IFRAME_ALL |
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SPACE |
+ HTML_FRMOPT_BORDER |
+ HTML_FRMOPT_BRCLEAR;
+
+const ULONG HTML_FRMOPTS_OLE_CSS1 =
+ HTML_FRMOPT_S_ALIGN |
+ HTML_FRMOPT_S_SPACE;
+
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_hidden, "HIDDEN" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_HIDDEN_false, "FALSE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_archive, "ARCHIVE" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_archives, "ARCHIVES" );
+sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_object, "OBJECT" );
+
+/* */
+
+void SwHTMLParser::SetFixSize( const Size& rPixSize,
+ const Size& rTwipDfltSize,
+ BOOL bPrcWidth, BOOL bPrcHeight,
+ SfxItemSet& rCSS1ItemSet,
+ SvxCSS1PropertyInfo& rCSS1PropInfo,
+ SfxItemSet& rFlyItemSet )
+{
+ // absolulte Groessenangaben in Twip umrechnen
+ BYTE nPrcWidth = 0, nPrcHeight = 0;
+ Size aTwipSz( bPrcWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
+ bPrcHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
+ if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ {
+ aTwipSz =
+ Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
+ MapMode(MAP_TWIP) );
+ }
+
+ // die Breite bearbeiten
+ if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eWidthType )
+ {
+ nPrcWidth = (BYTE)rCSS1PropInfo.nWidth;
+ aTwipSz.Width() = rTwipDfltSize.Width();
+ }
+ else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eWidthType )
+ {
+ aTwipSz.Width() = rCSS1PropInfo.nWidth;
+ }
+ else if( bPrcWidth && rPixSize.Width() )
+ {
+ nPrcWidth = (BYTE)rPixSize.Width();
+ if( nPrcWidth > 100 )
+ nPrcWidth = 100;
+
+ aTwipSz.Width() = rTwipDfltSize.Width();
+ }
+ else if( USHRT_MAX==rPixSize.Width() )
+ {
+ aTwipSz.Width() = rTwipDfltSize.Width();
+ }
+ if( aTwipSz.Width() < MINFLY )
+ {
+ aTwipSz.Width() = MINFLY;
+ }
+
+ // Hoehe bearbeiten
+ if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eHeightType )
+ {
+ nPrcHeight = (BYTE)rCSS1PropInfo.nHeight;
+ aTwipSz.Height() = rTwipDfltSize.Height();
+ }
+ else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eHeightType )
+ {
+ aTwipSz.Height() = rCSS1PropInfo.nHeight;
+ }
+ else if( bPrcHeight && rPixSize.Height() )
+ {
+ nPrcHeight = (BYTE)rPixSize.Height();
+ if( nPrcHeight > 100 )
+ nPrcHeight = 100;
+
+ aTwipSz.Height() = rTwipDfltSize.Height();
+ }
+ else if( USHRT_MAX==rPixSize.Height() )
+ {
+ aTwipSz.Height() = rTwipDfltSize.Height();
+ }
+ if( aTwipSz.Height() < MINFLY )
+ {
+ aTwipSz.Height() = MINFLY;
+ }
+
+ // Size setzen
+ SwFmtFrmSize aFrmSize( ATT_FIX_SIZE, aTwipSz.Width(), aTwipSz.Height() );
+ aFrmSize.SetWidthPercent( nPrcWidth );
+ aFrmSize.SetHeightPercent( nPrcHeight );
+ rFlyItemSet.Put( aFrmSize );
+}
+
+void SwHTMLParser::SetSpace( const Size& rPixSpace,
+ SfxItemSet& rCSS1ItemSet,
+ SvxCSS1PropertyInfo& rCSS1PropInfo,
+ SfxItemSet& rFlyItemSet )
+{
+ USHORT nLeftSpace = 0, nRightSpace = 0, nUpperSpace = 0, nLowerSpace = 0;
+ if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
+ {
+ Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
+ aTwipSpc =
+ Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
+ MapMode(MAP_TWIP) );
+ nLeftSpace = nRightSpace = (USHORT)aTwipSpc.Width();
+ nUpperSpace = nLowerSpace = (USHORT)aTwipSpc.Height();
+ }
+
+ // linken/rechten Rand setzen
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, TRUE, &pItem ) )
+ {
+ // Ggf. den Erstzeilen-Einzug noch plaetten
+ const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
+ SvxLRSpaceItem aLRItem( *pLRItem );
+ aLRItem.SetTxtFirstLineOfst( 0 );
+ if( rCSS1PropInfo.bLeftMargin )
+ {
+ nLeftSpace = aLRItem.GetLeft();
+ rCSS1PropInfo.bLeftMargin = FALSE;
+ }
+ if( rCSS1PropInfo.bRightMargin )
+ {
+ nRightSpace = aLRItem.GetRight();
+ rCSS1PropInfo.bRightMargin = FALSE;
+ }
+ rCSS1ItemSet.ClearItem( RES_LR_SPACE );
+ }
+ if( nLeftSpace || nRightSpace )
+ {
+ SvxLRSpaceItem aLRItem;
+ aLRItem.SetLeft( nLeftSpace );
+ aLRItem.SetRight( nRightSpace );
+ rFlyItemSet.Put( aLRItem );
+ if( nLeftSpace )
+ {
+ const SwFmtHoriOrient& rHoriOri =
+ (const SwFmtHoriOrient&)rFlyItemSet.Get( RES_HORI_ORIENT );
+ if( HORI_NONE == rHoriOri.GetHoriOrient() )
+ {
+ SwFmtHoriOrient aHoriOri( rHoriOri );
+ aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
+ rFlyItemSet.Put( aHoriOri );
+ }
+ }
+ }
+
+ // oberen/unteren Rand setzen
+ if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, TRUE, &pItem ) )
+ {
+ // Ggf. den Erstzeilen-Einzug noch plaetten
+ const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
+ if( rCSS1PropInfo.bTopMargin )
+ {
+ nUpperSpace = pULItem->GetUpper();
+ rCSS1PropInfo.bTopMargin = FALSE;
+ }
+ if( rCSS1PropInfo.bBottomMargin )
+ {
+ nLowerSpace = pULItem->GetLower();
+ rCSS1PropInfo.bBottomMargin = FALSE;
+ }
+ rCSS1ItemSet.ClearItem( RES_UL_SPACE );
+ }
+ if( nUpperSpace || nLowerSpace )
+ {
+ SvxULSpaceItem aULItem;
+ aULItem.SetUpper( nUpperSpace );
+ aULItem.SetLower( nLowerSpace );
+ rFlyItemSet.Put( aULItem );
+ if( nUpperSpace )
+ {
+ const SwFmtVertOrient& rVertOri =
+ (const SwFmtVertOrient&)rFlyItemSet.Get( RES_VERT_ORIENT );
+ if( VERT_NONE == rVertOri.GetVertOrient() )
+ {
+ SwFmtVertOrient aVertOri( rVertOri );
+ aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
+ rFlyItemSet.Put( aVertOri );
+ }
+ }
+ }
+}
+
+/* */
+
+void SwHTMLParser::InsertEmbed()
+{
+ String aURL, aType, aName, aAlt, aId, aStyle, aClass;
+ Size aSize( USHRT_MAX, USHRT_MAX );
+ Size aSpace( USHRT_MAX, USHRT_MAX );
+ BOOL bPrcWidth = FALSE, bPrcHeight = FALSE, bHidden = FALSE;
+ SwVertOrient eVertOri = VERT_NONE;
+ SwHoriOrient eHoriOri = HORI_NONE;
+ SvCommandList aCmdLst;
+ const HTMLOptions *pOptions = GetOptions();
+
+ // Die Optionen werden vorwaerts gelesen, weil die Plugins sie in
+ // dieser Reihenfolge erwarten. Trotzdem darf immer nur der erste
+ // Wert einer Option beruecksichtigt werden.
+ USHORT nArrLen = pOptions->Count();
+ for( USHORT i=0; i<nArrLen; i++ )
+ {
+ const HTMLOption *pOption = (*pOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_NAME:
+ aName = pOption->GetString();
+ break;
+ case HTML_O_SRC:
+ if( !aURL.Len() )
+ aURL = pOption->GetString();
+ break;
+ case HTML_O_ALT:
+ aAlt = pOption->GetString();
+ break;
+ case HTML_O_TYPE:
+ if( !aType.Len() )
+ aType = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ if( eVertOri==VERT_NONE && eHoriOri==HORI_NONE )
+ {
+ eVertOri = (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
+ eHoriOri = (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
+ }
+ break;
+ case HTML_O_WIDTH:
+ if( USHRT_MAX==aSize.Width() )
+ {
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Width() = (long)pOption->GetNumber();
+ }
+ break;
+ case HTML_O_HEIGHT:
+ if( USHRT_MAX==aSize.Height() )
+ {
+ bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Height() = (long)pOption->GetNumber();
+ }
+ break;
+ case HTML_O_HSPACE:
+ if( USHRT_MAX==aSpace.Width() )
+ aSpace.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_VSPACE:
+ if( USHRT_MAX==aSpace.Height() )
+ aSpace.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_UNKNOWN:
+ if( pOption->GetTokenString().EqualsIgnoreCaseAscii( sHTML_O_hidden ) )
+ bHidden =
+ !pOption->GetString().EqualsIgnoreCaseAscii( sHTML_HIDDEN_false );
+ break;
+ }
+
+ // Es werden alle Parameter an das Plugin weitergereicht
+ aCmdLst.Append( pOption->GetTokenString(), pOption->GetString() );
+ }
+
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
+
+ // Die Default-Werte umsetzen (ausser Hoehe/Breite, das macht schon
+ // SetFrmSize() fuer uns)
+ if( eVertOri==VERT_NONE && eHoriOri==HORI_NONE )
+ eVertOri = VERT_TOP;
+ if( USHRT_MAX==aSpace.Width() )
+ aSpace.Width() = 0;
+ if( USHRT_MAX==aSpace.Height() )
+ aSpace.Height() = 0;
+ if( bHidden )
+ {
+ // Size (0,0) wird in SetFrmSize auf (MINFLY, MINFLY) umgebogen
+ aSize.Width() = 0; aSize.Height() = 0;
+ aSpace.Width() = 0; aSpace.Height() = 0;
+ bPrcWidth = bPrcHeight = FALSE;
+ }
+
+ // die URL aufbereiten
+ INetURLObject aURLObj;
+ if( aURL.Len() && !aURLObj.SetURL( INetURLObject::RelToAbs(aURL) ) )
+ return;
+
+ // das Plugin anlegen
+ SvStorageRef pStor = new SvStorage( aEmptyStr, STREAM_STD_READWRITE);
+ SvFactory *pPlugInFactory = SvFactory::GetDefaultPlugInFactory();
+ SvPlugInObjectRef pPlugin =
+ &pPlugInFactory->CreateAndInit( *pPlugInFactory, pStor );
+
+ pPlugin->EnableSetModified( FALSE );
+ pPlugin->SetPlugInMode( (USHORT)PLUGIN_EMBEDED );
+ pPlugin->SetURL( aURLObj );
+ pPlugin->SetMimeType( aType );
+ pPlugin->SetCommandList( aCmdLst );
+ pPlugin->EnableSetModified( TRUE );
+
+ SfxItemSet aFrmSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aFrmSet );
+
+ // den Anker setzen
+ if( !bHidden )
+ {
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
+ }
+ else
+ {
+ SwFmtAnchor aAnchor( FLY_AT_CNTNT );
+ aAnchor.SetAnchor( pPam->GetPoint() );
+ aFrmSet.Put( aAnchor );
+ aFrmSet.Put( SwFmtHoriOrient( 0, HORI_LEFT, FRAME) );
+ aFrmSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
+ aFrmSet.Put( SwFmtVertOrient( 0, VERT_TOP, PRTAREA ) );
+ }
+
+ // und noch die Groesse des Rahmens
+ Size aDfltSz( HTML_DFLT_EMBED_WIDTH, HTML_DFLT_EMBED_HEIGHT );
+ SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
+ aFrmSet );
+ SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
+
+ // und in das Dok einfuegen
+ SwFrmFmt* pFlyFmt = pDoc->Insert( *pPam, pPlugin, &aFrmSet );
+
+ // Namen am FrmFmt setzen
+ if( aName.Len() )
+ pFlyFmt->SetName( aName );
+
+ // den alternativen Text setzen
+ SwNoTxtNode *pNoTxtNd =
+ pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
+ ->GetIndex()+1 ]->GetNoTxtNode();
+ pNoTxtNd->SetAlternateText( aAlt );
+
+ // Ggf Frames anlegen und auto-geb. Rahmen registrieren
+ if( !bHidden )
+ {
+ // HIDDEN-Plugins sollen absatzgebunden bleiben. Da RegisterFlyFrm
+ // absatzgebundene Rahmen mit DUrchlauf in am Zeichen gebundene
+ // Rahmen umwandelt, muessen die Frames hier von Hand angelegt werden.
+ RegisterFlyFrm( pFlyFmt );
+ }
+}
+
+/* */
+
+#ifdef SOLAR_JAVA
+class SwHTMLApplet_Impl
+{
+ SvAppletObjectRef xApplet; // das aktuelle Applet
+ SvCommandList aCommandList; // und die szugehorige Command-List
+ SfxItemSet aItemSet;
+ String sAlt;
+
+public:
+
+ SwHTMLApplet_Impl( SfxItemPool& rPool, USHORT nWhich1, USHORT nWhich2 ) :
+ aItemSet( rPool, nWhich1, nWhich2 )
+ {
+ }
+
+ ~SwHTMLApplet_Impl()
+ {
+ xApplet.Clear();
+ }
+
+#ifndef DEBUG
+inline
+#endif
+ void CreateApplet( const String& rCode, const String& rName,
+ BOOL bMayScript, const String& rCodeBase,
+ const String& rAlt );
+
+ void FinishApplet()
+ {
+ xApplet->SetCommandList( aCommandList );
+ xApplet->EnableSetModified( TRUE );
+ }
+
+
+ void AppendParam( const String& rName, const String& rValue )
+ {
+ aCommandList.Append( rName, rValue );
+ }
+
+
+ SvAppletObject* GetApplet() { return &xApplet; }
+ SfxItemSet& GetItemSet() { return aItemSet; }
+ const String& GetAltText() { return sAlt; }
+};
+
+#ifndef DEBUG
+inline
+#endif
+void SwHTMLApplet_Impl::CreateApplet( const String& rCode, const String& rName,
+ BOOL bMayScript, const String& rCodeBase,
+ const String& rAlt )
+{
+ SvStorageRef pStor = new SvStorage( aEmptyStr, STREAM_STD_READWRITE );
+ xApplet = new SvAppletObject();
+ xApplet->DoInitNew( pStor );
+
+ xApplet->EnableSetModified( FALSE );
+ xApplet->SetClass( rCode );
+ xApplet->SetName( rName );
+ xApplet->SetMayScript( bMayScript );
+ xApplet->SetDocBase( INetURLObject::GetBaseURL() );
+
+ String sCodeBase;
+ if( rCodeBase.Len() )
+ {
+ INetURLObject aTmpURL;
+
+ INetProtocol eProt = aTmpURL.CompareProtocolScheme( rCodeBase );
+ if( eProt==INET_PROT_NOT_VALID &&
+ rCodeBase.Search( ':' ) != STRING_NOTFOUND )
+ {
+ // The codebase contains an unknown protocol rather than
+ // a relative URL.
+ sCodeBase = rCodeBase;
+ }
+ else
+ {
+ sCodeBase = INetURLObject::RelToAbs( rCodeBase );
+ }
+ }
+ else
+ {
+ INetURLObject aTmpURL( INetURLObject::GetBaseURL() );
+ sCodeBase = aTmpURL.GetPartBeforeLastName();
+ }
+
+ xApplet->SetCodeBase( sCodeBase );
+
+ sAlt = rAlt;
+}
+
+#endif
+
+void SwHTMLParser::InsertApplet()
+{
+#ifdef SOLAR_JAVA
+ String aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
+ Size aSize( USHRT_MAX, USHRT_MAX );
+ Size aSpace( 0, 0 );
+ BOOL bPrcWidth = FALSE, bPrcHeight = FALSE, bMayScript = FALSE;
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
+
+ // Eine neue Command-List anlegen
+ if( pAppletImpl )
+ delete pAppletImpl;
+ pAppletImpl = new SwHTMLApplet_Impl( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_CODEBASE:
+ aCodeBase = pOption->GetString();
+ break;
+ case HTML_O_CODE:
+ aCode = pOption->GetString();
+ break;
+ case HTML_O_NAME:
+ aName = pOption->GetString();
+ break;
+ case HTML_O_ALT:
+ aAlt = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ eVertOri = (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
+ eHoriOri = (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
+ break;
+ case HTML_O_WIDTH:
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_HEIGHT:
+ bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_HSPACE:
+ aSpace.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_VSPACE:
+ aSpace.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_MAYSCRIPT:
+ bMayScript = TRUE;
+ break;
+ }
+
+ // Es werden alle Parameter auch an das Applet weitergereicht
+ pAppletImpl->AppendParam( pOption->GetTokenString(),
+ pOption->GetString() );
+ }
+
+ if( !aCode.Len() )
+ {
+ delete pAppletImpl;
+ pAppletImpl = 0;
+ return;
+ }
+
+ pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, aAlt );
+
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
+
+ SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( rFrmSet );
+
+ // den Anker und die Ausrichtung setzen
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
+
+ // und noch die Groesse des Rahmens
+ Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
+ SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
+ rFrmSet );
+ SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
+#endif
+}
+
+void SwHTMLParser::EndApplet()
+{
+#ifdef SOLAR_JAVA
+ if( !pAppletImpl )
+ return;
+
+ pAppletImpl->FinishApplet();
+
+ // und in das Dok einfuegen
+ SwFrmFmt* pFlyFmt = pDoc->Insert( *pPam, pAppletImpl->GetApplet(),
+ &pAppletImpl->GetItemSet() );
+
+ // den alternativen Namen setzen
+ SwNoTxtNode *pNoTxtNd =
+ pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
+ ->GetIndex()+1 ]->GetNoTxtNode();
+ pNoTxtNd->SetAlternateText( pAppletImpl->GetAltText() );
+
+ // Ggf Frames anlegen und auto-geb. Rahmen registrieren
+ RegisterFlyFrm( pFlyFmt );
+
+ delete pAppletImpl;
+ pAppletImpl = 0;
+#endif
+}
+
+void SwHTMLParser::InsertParam()
+{
+#ifdef SOLAR_JAVA
+ if( !pAppletImpl )
+ return;
+
+ String aName, aValue;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_NAME:
+ aName = pOption->GetString();
+ break;
+ case HTML_O_VALUE:
+ aValue = pOption->GetString();
+ break;
+ }
+ }
+
+ if( !aName.Len() )
+ return;
+
+ pAppletImpl->AppendParam( aName, aValue );
+#endif
+}
+
+
+/* */
+
+void SwHTMLParser::InsertFloatingFrame()
+{
+ String aAlt, aId, aStyle, aClass;
+ Size aSize( USHRT_MAX, USHRT_MAX );
+ Size aSpace( 0, 0 );
+ BOOL bPrcWidth = FALSE, bPrcHeight = FALSE;
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
+
+ const HTMLOptions *pOptions = GetOptions();
+
+ // Erstmal die Optionen fr das Writer-Frame-Format holen
+ USHORT nArrLen = pOptions->Count();
+ for ( USHORT i=0; i<nArrLen; i++ )
+ {
+ const HTMLOption *pOption = (*pOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_ALT:
+ aAlt = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ eVertOri = (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
+ eHoriOri = (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
+ break;
+ case HTML_O_WIDTH:
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_HEIGHT:
+ bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_HSPACE:
+ aSpace.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_VSPACE:
+ aSpace.Height() = (long)pOption->GetNumber();
+ break;
+ }
+ }
+
+ // und jetzt die fuer den SfxFrame
+ SfxFrameDescriptor *pFrameDesc = new SfxFrameDescriptor( 0 );
+
+ SfxFrameHTMLParser::ParseFrameOptions( pFrameDesc, pOptions );
+
+ // den Floating-Frame anlegen
+ SvStorageRef pStor = new SvStorage( aEmptyStr, STREAM_STD_READWRITE );
+ SfxFrameObjectRef pFrame = new SfxFrameObject();
+ pFrame->DoInitNew( pStor );
+
+ pFrame->EnableSetModified( FALSE );
+ pFrame->SetFrameDescriptor( pFrameDesc );
+ pFrame->EnableSetModified( TRUE );
+
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
+
+ // den Itemset holen
+ SfxItemSet aFrmSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aFrmSet );
+
+ // den Anker und die Ausrichtung setzen
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
+
+ // und noch die Groesse des Rahmens
+ Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
+ SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
+ aFrmSet );
+ SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
+
+ // und in das Dok einfuegen
+ SwFrmFmt* pFlyFmt = pDoc->Insert( *pPam, pFrame, &aFrmSet );
+
+ // den alternativen Namen setzen
+ SwNoTxtNode *pNoTxtNd =
+ pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
+ ->GetIndex()+1 ]->GetNoTxtNode();
+ pNoTxtNd->SetAlternateText( aAlt );
+
+ // Ggf Frames anlegen und auto-geb. Rahmen registrieren
+ RegisterFlyFrm( pFlyFmt );
+
+ bInFloatingFrame = TRUE;
+}
+
+/* */
+
+#define HTML_OPTTYPE_IGNORE 0
+#define HTML_OPTTYPE_TAG 1
+#define HTML_OPTTYPE_PARAM 2
+
+static USHORT GetOptionType( const String& rName, BOOL bApplet )
+{
+ USHORT nType = bApplet ? HTML_OPTTYPE_PARAM : HTML_OPTTYPE_TAG;
+
+ switch( rName.GetChar(0) )
+ {
+ case 'A':
+ case 'a':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_align ) ||
+ rName.EqualsIgnoreCaseAscii( sHTML_O_alt ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ else if( bApplet &&
+ (rName.EqualsIgnoreCaseAscii( sHTML_O_archive ) ||
+ rName.EqualsIgnoreCaseAscii( sHTML_O_archives )) )
+ nType = HTML_OPTTYPE_TAG;
+ break;
+ case 'C':
+ case 'c':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_class ) ||
+ (bApplet && (rName.EqualsIgnoreCaseAscii( sHTML_O_code ) ||
+ rName.EqualsIgnoreCaseAscii( sHTML_O_codebase ))) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'H':
+ case 'h':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_height ) ||
+ rName.EqualsIgnoreCaseAscii( sHTML_O_hspace ) ||
+ (!bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_hidden )) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'I':
+ case 'i':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_id ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'M':
+ case 'm':
+ if( bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_mayscript ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'N':
+ case 'n':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_name ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'O':
+ case 'o':
+ if( bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_object ) )
+ nType = HTML_OPTTYPE_TAG;
+ break;
+ case 'S':
+ case 's':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_style ) ||
+ (!bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_src )) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'T':
+ case 't':
+ if( !bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_type ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'V':
+ case 'v':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_vspace ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ case 'W':
+ case 'w':
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_width ) )
+ nType = HTML_OPTTYPE_IGNORE;
+ break;
+ }
+
+ return nType;
+}
+
+USHORT SwHTMLWriter::GuessOLENodeFrmType( const SwNode& rNode )
+{
+ SwOLEObj& rObj = ((SwOLENode*)rNode.GetOLENode())->GetOLEObj();
+
+ SwHTMLFrmType eType = HTML_FRMTYPE_OLE;
+
+ SvPlugInObjectRef pPlugin( rObj.GetOleRef() );
+ if( pPlugin.Is() )
+ {
+ eType = HTML_FRMTYPE_PLUGIN;
+ }
+ else
+ {
+ SfxFrameObjectRef pFrame( rObj.GetOleRef() );
+ if( pFrame.Is() )
+ {
+ eType = HTML_FRMTYPE_IFRAME;
+ }
+#ifdef SOLAR_JAVA
+ else
+ {
+ SvAppletObjectRef pApplet( rObj.GetOleRef() );
+ if( pApplet.Is() )
+ eType = HTML_FRMTYPE_APPLET;
+ }
+#endif
+ }
+
+ return eType;
+}
+
+Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ BOOL bInCntnr )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
+
+ ASSERT( pOLENd, "OLE-Node erwartet" );
+ if( !pOLENd )
+ return rWrt;
+
+ SwOLEObj &rObj = pOLENd->GetOLEObj();
+ SvPlugInObjectRef pPlugin( rObj.GetOleRef() );
+#ifdef SOLAR_JAVA
+ SvAppletObjectRef pApplet( rObj.GetOleRef() );
+#endif
+ SfxFrameObjectRef pFrame( rObj.GetOleRef() );
+ BOOL bHiddenEmbed = FALSE;
+
+ ASSERT( !pFrame.Is() || rHTMLWrt.IsHTMLMode(HTMLMODE_FLOAT_FRAME),
+ "Floating-Frame wird exportiert, aber Modus ist nicht aktiviert" );
+
+ if( !pPlugin.Is() &&
+#ifdef SOLAR_JAVA
+ !pApplet.Is() &&
+#endif
+ !pFrame.Is() )
+ {
+ ASSERT( pPlugin.Is(), "unbekanntes Inplace-Object" );
+ return rWrt;
+ }
+
+ ByteString aEndTags;
+ ULONG nFrmOpts;
+
+ // wenn meoglich vor dem "Objekt" einen Zeilen-Umbruch ausgeben
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine( TRUE );
+
+ if( rFrmFmt.GetName().Len() )
+ rHTMLWrt.OutImplicitMark( rFrmFmt.GetName(),
+ pMarkToOLE );
+
+ ByteString sOut('<');
+ if( pPlugin.Is() )
+ {
+ // erstmal das Plug-spezifische
+ sOut += sHTML_embed;
+
+ String aURL(
+ INetURLObject::AbsToRel(pPlugin->GetURL()->GetMainURL(),
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET) );
+
+ if( aURL.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_src) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ const String& aType = pPlugin->GetMimeType();
+ if( aType.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_type) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ if( FLY_AT_CNTNT == rFrmFmt.GetAnchor().GetAnchorId() &&
+ SURROUND_THROUGHT == rFrmFmt.GetSurround().GetSurround() )
+ {
+ // Das Plugin ist HIDDEN
+ (sOut += ' ') += sHTML_O_hidden;
+ nFrmOpts = HTML_FRMOPTS_HIDDEN_EMBED;
+ bHiddenEmbed = TRUE;
+ }
+ else
+ {
+ nFrmOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
+ : HTML_FRMOPTS_EMBED;
+ }
+ }
+#ifdef SOLAR_JAVA
+ else if( pApplet.Is() )
+ {
+ // oder das Applet-Spezifische
+
+ sOut += sHTML_applet;
+
+ // CODEBASE
+ const XubString& rURL = pApplet->GetCodeBase();
+ if( rURL.Len() )
+ {
+#ifdef DEBUG
+ String sTmp( INetURLObject::GetBaseURL() );
+#endif
+ String sCodeBase( INetURLObject::AbsToRel(rURL,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET) );
+ if( sCodeBase.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_codebase) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+ }
+
+ // CODE
+ ((sOut += ' ') += sHTML_O_code) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), pApplet->GetClass(), rHTMLWrt.eDestEnc );
+ sOut = '\"';
+
+ // NAME
+ const String &rName = pApplet->GetName();
+ if( rName.Len() )
+ {
+ ((sOut += ' ') += sHTML_O_name) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ if( pApplet->IsMayScript() )
+ (sOut += ' ') += sHTML_O_mayscript;
+
+ nFrmOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
+ : HTML_FRMOPTS_APPLET;
+ }
+#endif
+ else
+ {
+ // oder das Flating-Frame spezifische
+
+ sOut += sHTML_iframe;
+ rWrt.Strm() << sOut.GetBuffer();
+
+ SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(),
+ pFrame->GetFrameDescriptor(),
+ FALSE, 0, rHTMLWrt.eDestEnc );
+ sOut.Erase();
+
+ nFrmOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
+ : HTML_FRMOPTS_IFRAME;
+ }
+
+ rWrt.Strm() << sOut.GetBuffer();
+
+ // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
+ nFrmOpts |= HTML_FRMOPTS_OLE_CSS1;
+ rHTMLWrt.OutFrmFmtOptions( rFrmFmt, pOLENd->GetAlternateText(),
+ aEndTags, nFrmOpts );
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
+ rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmOpts );
+
+#ifdef SOLAR_JAVA
+ if( pApplet.Is() )
+ {
+ // fuer Applets die Parameter als eigene Tags ausgeben
+ // und ein </APPLET> schreiben
+
+ const SvCommandList& rCommands = pApplet->GetCommandList();
+ SvULongs aParams;
+ ULONG i = rCommands.Count();
+ while( i > 0 )
+ {
+ const SvCommand& rCommand = rCommands[ --i ];
+ const String& rName = rCommand.GetCommand();
+ USHORT nType = GetOptionType( rName, TRUE );
+ if( HTML_OPTTYPE_TAG == nType )
+ {
+ const String& rValue = rCommand.GetArgument();
+ rWrt.Strm() << ' ';
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc );
+ rWrt.Strm() << "=\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc ) << '\"';
+ }
+ else if( HTML_OPTTYPE_PARAM == nType )
+ {
+ aParams.Insert( i, aParams.Count() );
+ }
+ }
+
+ rHTMLWrt.Strm() << '>';
+
+ rHTMLWrt.IncIndentLevel(); // Inhalt von Applet einruecken
+
+ USHORT ii = aParams.Count();
+ while( ii > 0 )
+ {
+ const SvCommand& rCommand = rCommands[ aParams[--ii] ];
+ const String& rName = rCommand.GetCommand();
+ const String& rValue = rCommand.GetArgument();
+ rHTMLWrt.OutNewLine();
+ ((((sOut = '<') += sHTML_param) += ' ') += sHTML_O_name)
+ += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc );
+ ((sOut = "\" ") += sHTML_O_value) += "=\"";
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc ) << "\">";
+ }
+
+ rHTMLWrt.DecIndentLevel(); // Inhalt von Applet einruecken
+ if( rCommands.Count() )
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_applet, FALSE );
+ }
+ else
+#endif
+ if( pPlugin.Is() )
+ {
+ // fuer Plugins die Paramater als Optionen schreiben
+
+ const SvCommandList& rCommands = pPlugin->GetCommandList();
+ for( ULONG i=0; i<rCommands.Count(); i++ )
+ {
+ const SvCommand& rCommand = rCommands[ i ];
+ const String& rName = rCommand.GetCommand();
+
+ if( GetOptionType( rName, FALSE ) == HTML_OPTTYPE_TAG )
+ {
+ const String& rValue = rCommand.GetArgument();
+ rWrt.Strm() << ' ';
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc );
+ rWrt.Strm() << "=\"";
+ HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc ) << '\"';
+ }
+ }
+ rHTMLWrt.Strm() << '>';
+ }
+ else
+ {
+ // und fuer Floating-Frames einfach noch ein </IFRAME>
+ // ausgeben
+
+ rHTMLWrt.Strm() << '>';
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_iframe, FALSE );
+ }
+
+ if( aEndTags.Len() )
+ rWrt.Strm() << aEndTags.GetBuffer();
+
+ return rWrt;
+}
+
+Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ BOOL bInCntnr )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
+
+ ASSERT( pOLENd, "OLE-Node erwartet" );
+ if( !pOLENd )
+ return rWrt;
+
+ // Inhalt des Nodes als Grafik speichern
+ SvInPlaceObjectRef xRef = pOLENd->GetOLEObj().GetOleRef();;
+ GDIMetaFile* pPic = NULL;
+ SvData aData( FORMAT_GDIMETAFILE );
+ if( xRef->GetData( &aData ) )
+ aData.GetData( &pPic, TRANSFER_REFERENCE );
+ if( pPic )
+ {
+ Graphic aGrf( *pPic );
+ String aGrfNm;
+ const String* pTempFileName = rHTMLWrt.GetOrigFileName();
+ if(pTempFileName)
+ aGrfNm = *pTempFileName;
+
+ USHORT nErr = XOutBitmap::WriteGraphic( aGrf, aGrfNm,
+ String::CreateFromAscii("JPG"),
+ XOUTBMP_USE_GIF_IF_POSSIBLE );
+ if( nErr ) // fehlerhaft, da ist nichts auszugeben
+ {
+ rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
+ return rWrt;
+ }
+ aGrfNm = URIHelper::SmartRelToAbs( aGrfNm );
+ if( rHTMLWrt.HasCId() )
+ rHTMLWrt.MakeCIdURL( aGrfNm );
+ ULONG nFlags = bInCntnr ? HTML_FRMOPTS_GENIMG_CNTNR
+ : HTML_FRMOPTS_GENIMG;
+ OutHTML_Image( rWrt, rFrmFmt, aGrfNm,
+ pOLENd->GetAlternateText(), pOLENd->GetTwipSize(),
+ nFlags, pMarkToOLE );
+ }
+
+ return rWrt;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlplug.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.95 2000/09/18 16:04:45 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.94 2000/08/18 13:03:22 jp
+ don't export escaped URLs
+
+ Revision 1.93 2000/06/26 12:55:06 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.92 2000/06/26 09:52:22 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.91 2000/05/15 10:06:56 os
+ Chg: GetOrigFileName()
+
+ Revision 1.90 2000/04/28 14:29:11 mib
+ unicode
+
+ Revision 1.89 2000/04/10 12:20:56 mib
+ unicode
+
+ Revision 1.88 2000/02/11 14:37:20 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.87 1999/09/21 09:49:53 mib
+ multiple text encodings
+
+ Revision 1.86 1999/09/17 12:14:02 mib
+ support of multiple and non system text encodings
+
+ Revision 1.85 1999/07/12 07:01:58 MIB
+ #34644#: Applet\'s codebase is set to document base if not specified
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
new file mode 100644
index 000000000000..d390a2675c3b
--- /dev/null
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -0,0 +1,1063 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlsect.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:55 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_H
+#include <svtools/htmlkywd.hxx>
+#endif
+
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include "frmatr.hxx"
+#endif
+#include "doc.hxx"
+#include "pam.hxx"
+#include "ndtxt.hxx"
+#include "shellio.hxx"
+#include "section.hxx"
+#include "poolfmt.hxx"
+#include "pagedesc.hxx"
+#include "swtable.hxx"
+#include "viewsh.hxx"
+#include "swcss1.hxx"
+#include "swhtml.hxx"
+
+#define CONTEXT_FLAGS_MULTICOL (HTML_CNTXT_STRIP_PARA | \
+ HTML_CNTXT_KEEP_NUMRULE | \
+ HTML_CNTXT_KEEP_ATTRS)
+//#define CONTEXT_FLAGS_HDRFTR (HTML_CNTXT_STRIP_PARA|HTML_CNTXT_PROTECT_STACK)
+#define CONTEXT_FLAGS_HDRFTR (CONTEXT_FLAGS_MULTICOL)
+#define CONTEXT_FLAGS_FTN (CONTEXT_FLAGS_MULTICOL)
+
+/* */
+
+void SwHTMLParser::NewDivision( int nToken )
+{
+ String aId, aHRef, aStyle, aClass;
+ SvxAdjust eAdjust = HTML_CENTER_ON==nToken ? SVX_ADJUST_CENTER
+ : SVX_ADJUST_END;
+
+ sal_Bool bHeader=sal_False, bFooter=sal_False;
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ if( HTML_DIVISION_ON==nToken )
+ eAdjust = (SvxAdjust)pOption->GetEnum( aHTMLPAlignTable,
+ eAdjust );
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_HREF:
+ aHRef = INetURLObject::RelToAbs( pOption->GetString() );
+ break;
+ case HTML_O_TYPE:
+ {
+ const String& rType = pOption->GetString();
+ if( rType.EqualsIgnoreCaseAscii( "HEADER" ) )
+ bHeader = sal_True;
+ else if( rType.EqualsIgnoreCaseAscii( "FOOTER" ) )
+ bFooter = sal_True;
+ }
+ }
+ }
+
+ sal_Bool bAppended = sal_False;
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ {
+ AppendTxtNode( bHeader||bFooter||aId.Len()||aHRef.Len() ? AM_NORMAL
+ : AM_NOSPACE );
+ bAppended = sal_True;
+ }
+
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+ sal_Bool bStyleParsed = sal_False, bPositioned = sal_False;
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ bStyleParsed = ParseStyleOptions( aStyle, aId, aClass,
+ aItemSet, aPropInfo );
+ if( bStyleParsed )
+ {
+ bPositioned = HTML_DIVISION_ON == nToken && aClass.Len() &&
+ CreateContainer( aClass, aItemSet, aPropInfo,
+ pCntxt );
+ if( !bPositioned )
+ bPositioned = DoPositioning( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ if( !bPositioned && (bHeader || bFooter) && IsNewDoc() )
+ {
+ SwPageDesc *pPageDesc = pCSS1Parser->GetMasterPageDesc();
+ SwFrmFmt& rPageFmt = pPageDesc->GetMaster();
+
+ SwFrmFmt *pHdFtFmt;
+ sal_Bool bNew = sal_False;
+ sal_uInt16 nFlags = CONTEXT_FLAGS_HDRFTR;
+ if( bHeader )
+ {
+ pHdFtFmt = (SwFrmFmt*)rPageFmt.GetHeader().GetHeaderFmt();
+ if( !pHdFtFmt )
+ {
+ // noch keine Header, dann erzeuge einen.
+ rPageFmt.SetAttr( SwFmtHeader( sal_True ));
+ pHdFtFmt = (SwFrmFmt*)rPageFmt.GetHeader().GetHeaderFmt();
+ bNew = sal_True;
+ }
+ nFlags |= HTML_CNTXT_HEADER_DIST;
+ }
+ else
+ {
+ pHdFtFmt = (SwFrmFmt*)rPageFmt.GetFooter().GetFooterFmt();
+ if( !pHdFtFmt )
+ {
+ // noch keine Footer, dann erzeuge einen.
+ rPageFmt.SetAttr( SwFmtFooter( sal_True ));
+ pHdFtFmt = (SwFrmFmt*)rPageFmt.GetFooter().GetFooterFmt();
+ bNew = sal_True;
+ }
+ nFlags |= HTML_CNTXT_FOOTER_DIST;
+ }
+
+ const SwFmtCntnt& rFlyCntnt = pHdFtFmt->GetCntnt();
+ const SwNodeIndex& rCntntStIdx = *rFlyCntnt.GetCntntIdx();
+ SwCntntNode *pCNd;
+
+ if( bNew )
+ {
+ pCNd = pDoc->GetNodes()[rCntntStIdx.GetIndex()+1]
+ ->GetCntntNode();
+ }
+ else
+ {
+ // Einen neuen Node zu Beginn der Section anlegen
+ SwNodeIndex aSttIdx( rCntntStIdx, 1 );
+ pCNd = pDoc->GetNodes().MakeTxtNode( aSttIdx,
+ pCSS1Parser->GetTxtCollFromPool(RES_POOLCOLL_TEXT));
+
+ // Den bisherigen Inhalt der Section loeschen
+ SwPaM aDelPam( aSttIdx );
+ aDelPam.SetMark();
+
+ const SwStartNode *pStNd =
+ (const SwStartNode *)pDoc->GetNodes()[rCntntStIdx];
+ aDelPam.GetPoint()->nNode = pStNd->EndOfSectionIndex() - 1;
+
+ pDoc->DelFullPara( aDelPam );
+
+ // Die Seitenvorlage aktualisieren
+ for( sal_uInt16 i=0; i < pDoc->GetPageDescCnt(); i++ )
+ {
+ if( RES_POOLPAGE_HTML==pDoc->GetPageDesc(i).GetPoolFmtId() )
+ {
+ pDoc->ChgPageDesc( i, *pPageDesc );
+ break;
+ }
+ }
+ }
+
+ // Kopf- bzw. Fusszeile im Browse-Mode aktivieren
+ ViewShell* pVSh = 0;
+ pDoc->GetEditShell( &pVSh );
+ if( pVSh )
+ {
+ if( bHeader )
+ pVSh->SetHeadInBrowse();
+ else
+ pVSh->SetFootInBrowse();
+ }
+ else
+ {
+ if( bHeader )
+ pDoc->SetHeadInBrowse();
+ else
+ pDoc->SetFootInBrowse();
+ }
+
+ SwPosition aNewPos( SwNodeIndex( rCntntStIdx, 1 ), SwIndex( pCNd, 0 ) );
+ SaveDocContext( pCntxt, nFlags, &aNewPos );
+ }
+ else if( !bPositioned && aId.Len() > 9 &&
+ ('s' == aId.GetChar(0) || 'S' == aId.GetChar(0) ) &&
+ ('d' == aId.GetChar(1) || 'D' == aId.GetChar(1) ) )
+ {
+ sal_Bool bEndNote = sal_False, bFootNote = sal_False;
+ if( aId.CompareIgnoreCaseToAscii( sHTML_sdendnote, 9 ) == COMPARE_EQUAL )
+ bEndNote = sal_True;
+ else if( aId.CompareIgnoreCaseToAscii( sHTML_sdfootnote, 10 ) == COMPARE_EQUAL )
+ bFootNote = sal_True;
+ if( bFootNote || bEndNote )
+ {
+ SwNodeIndex *pSttNdIdx = GetFootEndNoteSection( aId );
+ if( pSttNdIdx )
+ {
+ SwCntntNode *pCNd =
+ pDoc->GetNodes()[pSttNdIdx->GetIndex()+1]->GetCntntNode();
+ SwNodeIndex aTmpSwNodeIndex = SwNodeIndex(*pCNd);
+ SwPosition aNewPos( aTmpSwNodeIndex, SwIndex( pCNd, 0 ) );
+ SaveDocContext( pCntxt, CONTEXT_FLAGS_FTN, &aNewPos );
+ aId = aPropInfo.aId = aEmptyStr;
+ }
+ }
+ }
+
+ // Bereiche fuegen wir in Rahmen nur dann ein, wenn der Bereich gelinkt ist.
+ if( (aId.Len() && !bPositioned) || aHRef.Len() )
+ {
+ // Bereich einfuegen (muss vor dem Setzten von Attributen erfolgen,
+ // weil die Section vor der PaM-Position eingefuegt.
+
+ // wenn wir im ersten Node einer Section stehen, wir die neue
+ // Section nicht in der aktuellen, sondern vor der aktuellen
+ // Section eingefuegt. Deshalb muessen wir dann einen Node
+ // einfuegen. UND IN LOESCHEN!!!
+ if( !bAppended )
+ {
+ SwNodeIndex aPrvNdIdx( pPam->GetPoint()->nNode, -1 );
+ if( (pDoc->GetNodes()[aPrvNdIdx])->IsSectionNode() )
+ {
+ AppendTxtNode();
+ bAppended = sal_True;
+ }
+ }
+ _HTMLAttrs *pPostIts = bAppended ? 0 : new _HTMLAttrs;
+ SetAttr( sal_True, sal_True, pPostIts );
+
+ // Namen der Section eindeutig machen
+ String aName( pDoc->GetUniqueSectionName( aId.Len() ? &aId : 0 ) );
+
+ SwSection aSection( aHRef.Len() ? FILE_LINK_SECTION
+ : CONTENT_SECTION, aName );
+ if( aHRef.Len() )
+ {
+ aSection.SetLinkFileName( aHRef );
+ aSection.SetProtect();
+ }
+
+ SfxItemSet aFrmItemSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs(aFrmItemSet );
+
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == aItemSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ aFrmItemSet.Put( *pItem );
+ aItemSet.ClearItem( RES_BACKGROUND );
+ }
+
+ pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False );
+
+ // ggfs. einen Bereich anspringen
+ if( JUMPTO_REGION == eJumpTo && aName == sJmpMark )
+ {
+ bChkJumpMark = sal_True;
+ eJumpTo = JUMPTO_NONE;
+ }
+
+ SwTxtNode* pOldTxtNd =
+ bAppended ? 0 : pDoc->GetNodes()[pPam->GetPoint()->nNode]
+ ->GetTxtNode();
+
+ pPam->Move( fnMoveBackward );
+
+ // PageDesc- und SwFmtBreak Attribute vom aktuellen Node in den
+ // (ersten) Node des Bereich verschieben.
+ if( pOldTxtNd )
+ MovePageDescAttrs( pOldTxtNd, pPam->GetPoint()->nNode.GetIndex(),
+ sal_True );
+
+ if( pPostIts )
+ {
+ // noch vorhandene PostIts in den ersten Absatz
+ // der Tabelle setzen
+ InsertAttrs( *pPostIts );
+ delete pPostIts;
+ pPostIts = 0;
+ }
+
+ pCntxt->SetSpansSection( sal_True );
+
+ // keine ::com::sun::star::text::Bookmarks mit dem gleichen Namen wie Bereiche einfuegen
+ if( aPropInfo.aId.Len() && aPropInfo.aId==aName )
+ aPropInfo.aId.Erase();
+ }
+ else
+ {
+ pCntxt->SetAppendMode( AM_NOSPACE );
+ }
+
+ if( SVX_ADJUST_END != eAdjust )
+ {
+ InsertAttr( &aAttrTab.pAdjust, SvxAdjustItem(eAdjust), pCntxt );
+ }
+
+ // Style parsen
+ if( bStyleParsed )
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
+
+ PushContext( pCntxt );
+}
+
+void SwHTMLParser::EndDivision( int nToken )
+{
+ // Stack-Eintrag zu dem Token suchen (weil wir noch den Div-Stack
+ // haben unterscheiden wir erst einmal nicht zwischen DIV und CENTER
+ _HTMLAttrContext *pCntxt = 0;
+ sal_uInt16 nPos = aContexts.Count();
+ while( !pCntxt && nPos>nContextStMin )
+ {
+ switch( aContexts[--nPos]->GetToken() )
+ {
+ case HTML_CENTER_ON:
+ case HTML_DIVISION_ON:
+ pCntxt = aContexts[nPos];
+ aContexts.Remove( nPos, 1 );
+ break;
+ }
+ }
+
+ if( pCntxt )
+ {
+ // Attribute beenden
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+
+ delete pCntxt;
+ }
+}
+
+void SwHTMLParser::FixHeaderFooterDistance( sal_Bool bHeader,
+ const SwPosition *pOldPos )
+{
+ SwPageDesc *pPageDesc = pCSS1Parser->GetMasterPageDesc();
+ SwFrmFmt& rPageFmt = pPageDesc->GetMaster();
+
+ SwFrmFmt *pHdFtFmt =
+ bHeader ? (SwFrmFmt*)rPageFmt.GetHeader().GetHeaderFmt()
+ : (SwFrmFmt*)rPageFmt.GetFooter().GetFooterFmt();
+ ASSERT( pHdFtFmt, "Doch keine Kopf- oder Fusszeile" );
+
+ const SwFmtCntnt& rFlyCntnt = pHdFtFmt->GetCntnt();
+ const SwNodeIndex& rCntntStIdx = *rFlyCntnt.GetCntntIdx();
+
+ sal_uInt32 nPrvNxtIdx;
+ if( bHeader )
+ {
+ nPrvNxtIdx = pDoc->GetNodes()[rCntntStIdx]->EndOfSectionIndex()-1;
+ }
+ else
+ {
+ nPrvNxtIdx = pOldPos->nNode.GetIndex() - 1;
+ }
+
+ sal_uInt16 nSpace = 0;
+ SwTxtNode *pTxtNode = pDoc->GetNodes()[nPrvNxtIdx]->GetTxtNode();
+ if( pTxtNode )
+ {
+ const SvxULSpaceItem& rULSpace =
+ ((const SvxULSpaceItem&)pTxtNode
+ ->SwCntntNode::GetAttr( RES_UL_SPACE ));
+
+ // Der untere Absatz-Abstand wird zum Abstand zur
+ // Kopf- oder Fusszeile
+ nSpace = rULSpace.GetLower();
+
+ // und anschliessend auf einen vernuenftigen Wert
+ // gesetzt
+ const SvxULSpaceItem& rCollULSpace =
+ pTxtNode->GetAnyFmtColl().GetULSpace();
+ if( rCollULSpace.GetUpper() == rULSpace.GetUpper() )
+ pTxtNode->ResetAttr( RES_UL_SPACE );
+ else
+ pTxtNode->SwCntntNode::SetAttr(
+ SvxULSpaceItem( rULSpace.GetUpper(),
+ rCollULSpace.GetLower() ) );
+ }
+
+ if( bHeader )
+ {
+ nPrvNxtIdx = pOldPos->nNode.GetIndex();
+ }
+ else
+ {
+ nPrvNxtIdx = rCntntStIdx.GetIndex() + 1;
+ }
+
+ pTxtNode = pDoc->GetNodes()[nPrvNxtIdx]
+ ->GetTxtNode();
+ if( pTxtNode )
+ {
+ const SvxULSpaceItem& rULSpace =
+ ((const SvxULSpaceItem&)pTxtNode
+ ->SwCntntNode::GetAttr( RES_UL_SPACE ));
+
+ // Der obere Absatz-Abstand wird zum Abstand zur
+ // Kopf- oder Fusszeile, wenn er groesser ist als
+ // der untere vom Absatz davor
+ if( rULSpace.GetUpper() > nSpace )
+ nSpace = rULSpace.GetUpper();
+
+ // und anschliessend auf einen vernuenftigen Wert gesetzt
+ const SvxULSpaceItem& rCollULSpace =
+ pTxtNode->GetAnyFmtColl().GetULSpace();
+ if( rCollULSpace.GetLower() == rULSpace.GetLower() )
+ pTxtNode->ResetAttr( RES_UL_SPACE );
+ else
+ pTxtNode->SwCntntNode::SetAttr(
+ SvxULSpaceItem( rCollULSpace.GetUpper(),
+ rULSpace.GetLower() ) );
+ }
+
+ SvxULSpaceItem aULSpace;
+ if( bHeader )
+ aULSpace.SetLower( nSpace );
+ else
+ aULSpace.SetUpper( nSpace );
+
+ pHdFtFmt->SetAttr( aULSpace );
+}
+
+sal_Bool SwHTMLParser::EndSection( sal_Bool bLFStripped )
+{
+ SwEndNode *pEndNd = pDoc->GetNodes()[pPam->GetPoint()->nNode.GetIndex()+1]
+ ->GetEndNode();
+ if( pEndNd && pEndNd->FindStartNode()->IsSectionNode() )
+ {
+ // den Bereich beenden
+ if( !bLFStripped )
+ StripTrailingPara();
+ pPam->Move( fnMoveForward );
+ return sal_True;
+ }
+
+ ASSERT( !this, "Falsche PaM Position Beenden eines Bereichs" );
+
+ return sal_False;
+}
+
+sal_Bool SwHTMLParser::EndSections( sal_Bool bLFStripped )
+{
+ sal_Bool bSectionClosed = sal_False;
+ sal_uInt16 nPos = aContexts.Count();
+ while( nPos>nContextStMin )
+ {
+ _HTMLAttrContext *pCntxt = aContexts[--nPos];
+ if( pCntxt->GetSpansSection() && EndSection( bLFStripped ) )
+ {
+ bSectionClosed = sal_True;
+ pCntxt->SetSpansSection( sal_False );
+ bLFStripped = sal_False;
+ }
+ }
+
+ return bSectionClosed;
+}
+
+/* */
+
+void SwHTMLParser::NewMultiCol()
+{
+ String aId, aStyle, aClass;
+ long nWidth = 100;
+ sal_uInt16 nCols = 0, nGutter = 10;
+ sal_Bool bPrcWidth = sal_True;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_COLS:
+ nCols = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_WIDTH:
+ nWidth = pOption->GetNumber();
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ if( bPrcWidth && nWidth>100 )
+ nWidth = 100;
+ break;
+ case HTML_O_GUTTER:
+ nGutter = (sal_uInt16)pOption->GetNumber();
+ break;
+
+ }
+ }
+
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_MULTICOL_ON );
+
+ //.is the multicol elememt contained in a container? That may be the
+ // case for 5.0 documents.
+ sal_Bool bInCntnr = sal_False;
+ i = aContexts.Count();
+ while( !bInCntnr && i > nContextStMin )
+ bInCntnr = 0 != aContexts[--i]->GetFrmItemSet();
+
+ // Parse style sheets, but don't position anything by now.
+ sal_Bool bStyleParsed = sal_False;
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ bStyleParsed = ParseStyleOptions( aStyle, aId, aClass,
+ aItemSet, aPropInfo );
+
+ // Calculate width.
+ sal_uInt8 nPrcWidth = bPrcWidth ? (sal_uInt8)nWidth : 0;
+ sal_uInt16 nTwipWidth = 0;
+ if( !bPrcWidth && nWidth && Application::GetDefaultDevice() )
+ {
+ nTwipWidth = (sal_uInt16)Application::GetDefaultDevice()
+ ->PixelToLogic( Size(nWidth, 0),
+ MapMode(MAP_TWIP) ).Width();
+ }
+
+ if( !nPrcWidth && nTwipWidth < MINFLY )
+ nTwipWidth = MINFLY;
+
+ // Do positioning.
+ sal_Bool bPositioned = sal_False;
+ if( bInCntnr || pCSS1Parser->MayBePositioned( aPropInfo, sal_True ) )
+ {
+ SfxItemSet aFrmItemSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs(aFrmItemSet );
+
+ SetAnchorAndAdjustment( VERT_NONE, HORI_NONE, aItemSet, aPropInfo,
+ aFrmItemSet );
+
+ // The width is either the WIDTH attribute's value or contained
+ // in some style option.
+ SetVarSize( aItemSet, aPropInfo, aFrmItemSet, nTwipWidth, nPrcWidth );
+
+ SetSpace( Size(0,0), aItemSet, aPropInfo, aFrmItemSet );
+
+ // Set some other frame attributes. If the background is set, its
+ // it will be cleared here. That for, it won't be set at the section,
+ // too.
+ SetFrmFmtAttrs( aItemSet, aPropInfo,
+ HTML_FF_BOX|HTML_FF_BACKGROUND|HTML_FF_PADDING,
+ aFrmItemSet );
+
+ // Insert fly frame. If the are columns, the fly frame's name is not
+ // the sections name but a generated one.
+ String aFlyName( aEmptyStr );
+ if( nCols < 2 )
+ {
+ aFlyName = aId;
+ aPropInfo.aId.Erase();
+ }
+
+ InsertFlyFrame( aFrmItemSet, pCntxt, aFlyName, CONTEXT_FLAGS_ABSPOS );
+
+ pCntxt->SetPopStack( sal_True );
+ bPositioned = sal_True;
+ }
+
+ sal_Bool bAppended = sal_False;
+ if( !bPositioned )
+ {
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ {
+ AppendTxtNode( AM_SPACE );
+ bAppended = sal_True;
+ }
+ else
+ {
+ AddParSpace();
+ }
+ }
+
+ // If there are less then 2 columns, no section is inserted.
+ if( nCols >= 2 )
+ {
+ if( !bAppended )
+ {
+ // If the pam is at the start of a section, a additional text
+ // node must be inserted. Otherwise, the new section will be
+ // inserted in front of the old one.
+ SwNodeIndex aPrvNdIdx( pPam->GetPoint()->nNode, -1 );
+ if( (pDoc->GetNodes()[aPrvNdIdx])->IsSectionNode() )
+ {
+ AppendTxtNode();
+ bAppended = sal_True;
+ }
+ }
+ _HTMLAttrs *pPostIts = bAppended ? 0 : new _HTMLAttrs;
+ SetAttr( sal_True, sal_True, pPostIts );
+
+ // Make section name unique.
+ String aName( pDoc->GetUniqueSectionName( aId.Len() ? &aId : 0 ) );
+ SwSection aSection( CONTENT_SECTION, aName );
+
+ SfxItemSet aFrmItemSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs(aFrmItemSet );
+
+ if( nGutter && Application::GetDefaultDevice() )
+ {
+ nGutter = (sal_uInt16)Application::GetDefaultDevice()
+ ->PixelToLogic( Size(nGutter, 0),
+ MapMode(MAP_TWIP) ).Width();
+ }
+
+ SwFmtCol aFmtCol;
+#ifndef WIDTH_SUPPORTED_BY_SECTIONS
+ nPrcWidth = 100;
+#endif
+
+ aFmtCol.Init( nCols, nGutter, nPrcWidth ? USHRT_MAX : nTwipWidth );
+ aFrmItemSet.Put( aFmtCol );
+
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == aItemSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ aFrmItemSet.Put( *pItem );
+ aItemSet.ClearItem( RES_BACKGROUND );
+ }
+ pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False );
+
+ // Jump to section, if this is requested.
+ if( JUMPTO_REGION == eJumpTo && aName == sJmpMark )
+ {
+ bChkJumpMark = sal_True;
+ eJumpTo = JUMPTO_NONE;
+ }
+
+ SwTxtNode* pOldTxtNd =
+ bAppended ? 0 : pDoc->GetNodes()[pPam->GetPoint()->nNode]
+ ->GetTxtNode();
+
+ pPam->Move( fnMoveBackward );
+
+ // Move PageDesc and SwFmtBreak attributes of the current node
+ // to the section's first node.
+ if( pOldTxtNd )
+ MovePageDescAttrs( pOldTxtNd, pPam->GetPoint()->nNode.GetIndex(),
+ sal_True );
+
+ if( pPostIts )
+ {
+ // Move pending PostIts into the section.
+ InsertAttrs( *pPostIts );
+ delete pPostIts;
+ pPostIts = 0;
+ }
+
+ pCntxt->SetSpansSection( sal_True );
+
+ // Insert a bookmark if its name differs from the section's name only.
+ if( aPropInfo.aId.Len() && aPropInfo.aId==aName )
+ aPropInfo.aId.Erase();
+ }
+
+ // Additional attributes must be set as hard ones.
+ if( bStyleParsed )
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
+
+ PushContext( pCntxt );
+}
+
+/* */
+
+void SwHTMLParser::InsertFlyFrame( const SfxItemSet& rItemSet,
+ _HTMLAttrContext *pCntxt,
+ const String& rName,
+ sal_uInt16 nFlags )
+{
+ RndStdIds eAnchorId =
+ ((const SwFmtAnchor&)rItemSet.Get( RES_ANCHOR )).GetAnchorId();
+
+ // Den Rahmen anlegen
+ SwFlyFrmFmt* pFlyFmt = pDoc->MakeFlySection( eAnchorId, pPam->GetPoint(),
+ &rItemSet );
+ // Ggf. den Namen setzen
+ if( rName.Len() )
+ pFlyFmt->SetName( rName );
+
+ RegisterFlyFrm( pFlyFmt );
+
+ const SwFmtCntnt& rFlyCntnt = pFlyFmt->GetCntnt();
+ const SwNodeIndex& rFlyCntIdx = *rFlyCntnt.GetCntntIdx();
+ SwCntntNode *pCNd = pDoc->GetNodes()[rFlyCntIdx.GetIndex()+1]
+ ->GetCntntNode();
+
+ SwPosition aNewPos( SwNodeIndex( rFlyCntIdx, 1 ), SwIndex( pCNd, 0 ) );
+ SaveDocContext( pCntxt, nFlags, &aNewPos );
+}
+
+
+/* */
+
+void SwHTMLParser::MovePageDescAttrs( SwNode *pSrcNd,
+ sal_uInt32 nDestIdx,
+ sal_Bool bFmtBreak )
+{
+ SwCntntNode* pDestCntntNd =
+ pDoc->GetNodes()[nDestIdx]->GetCntntNode();
+
+ ASSERT( pDestCntntNd, "Wieso ist das Ziel kein Content-Node?" );
+
+ if( pSrcNd->IsCntntNode() )
+ {
+ SwCntntNode* pSrcCntntNd = pSrcNd->GetCntntNode();
+
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pSrcCntntNd->GetSwAttrSet()
+ .GetItemState( RES_PAGEDESC, sal_False, &pItem ) &&
+ ((SwFmtPageDesc *)pItem)->GetPageDesc() )
+ {
+ pDestCntntNd->SetAttr( *pItem );
+ pSrcCntntNd->ResetAttr( RES_PAGEDESC );
+ }
+ if( SFX_ITEM_SET == pSrcCntntNd->GetSwAttrSet()
+ .GetItemState( RES_BREAK, sal_False, &pItem ) )
+ {
+ switch( ((SvxFmtBreakItem *)pItem)->GetBreak() )
+ {
+ case SVX_BREAK_PAGE_BEFORE:
+ case SVX_BREAK_PAGE_AFTER:
+ case SVX_BREAK_PAGE_BOTH:
+ if( bFmtBreak )
+ pDestCntntNd->SetAttr( *pItem );
+ pSrcCntntNd->ResetAttr( RES_BREAK );
+ }
+ }
+ }
+ else if( pSrcNd->IsTableNode() )
+ {
+ SwFrmFmt *pFrmFmt = pSrcNd->GetTableNode()->GetTable().GetFrmFmt();
+
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pFrmFmt->GetAttrSet().
+ GetItemState( RES_PAGEDESC, sal_False, &pItem ) )
+ {
+ pDestCntntNd->SetAttr( *pItem );
+ pFrmFmt->ResetAttr( RES_PAGEDESC );
+ }
+ }
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmlsect.cxx,v 1.1.1.1 2000-09-18 17:14:55 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.57 2000/09/18 16:04:46 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.56 2000/06/26 09:52:25 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.55 2000/04/10 12:20:57 mib
+ unicode
+
+ Revision 1.54 2000/03/21 15:06:18 os
+ UNOIII
+
+ Revision 1.53 2000/02/11 14:37:23 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.52 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.51 1999/09/17 12:14:05 mib
+ support of multiple and non system text encodings
+
+ Revision 1.50 1999/07/23 13:35:08 MIB
+ #67578#: Use multicolumned sections for <MULTICOL>, section backgrounds
+
+
+ Rev 1.49 23 Jul 1999 15:35:08 MIB
+ #67578#: Use multicolumned sections for <MULTICOL>, section backgrounds
+
+ Rev 1.48 22 Jul 1999 18:59:24 MIB
+ Parameters to SwDoc::Insert call for section fixed to avoid updating links
+
+ Rev 1.47 10 Jun 1999 10:34:24 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.46 09 Jun 1999 19:37:46 JP
+ have to change: no cast from GetpApp to SfxApp/OffApp, SfxShell only subclass of SfxApp
+
+ Rev 1.45 27 Jan 1999 09:43:26 OS
+ #56371# TF_ONE51
+
+ Rev 1.44 19 Nov 1998 16:42:44 HJS
+ tempobj fuer linux
+
+ Rev 1.43 13 Nov 1998 14:39:02 MIB
+ Nachtrag zu #58450#: Fuss-/Endnoten: Keine ::com::sun::star::text::Bookmark einfuegen
+
+ Rev 1.42 02 Nov 1998 17:23:46 MIB
+ #58480#: Fuss-/Endnoten
+
+ Rev 1.41 05 Jun 1998 13:57:02 JP
+ Bug #42487#: Sprung zum Mark schon waehrend des Ladens ausfuehren
+
+ Rev 1.40 12 May 1998 15:50:18 JP
+ rund um Flys/DrawObjs im Doc/FESh umgestellt/optimiert
+
+ Rev 1.39 21 Apr 1998 13:46:58 MIB
+ fix: Keine ::com::sun::star::text::Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.38 20 Apr 1998 12:58:06 MIB
+ fix: Fuer DIVs mit IS keinen Bereich einfuegen, wenn ein Rahmen eingefuegt wird
+
+ Rev 1.37 15 Apr 1998 14:47:58 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.36 03 Apr 1998 15:11:52 MIB
+ CSS1-Padding
+
+ Rev 1.35 03 Apr 1998 12:22:16 MIB
+ Export des Rahmen-Namens als ID
+
+ Rev 1.34 02 Apr 1998 19:41:40 MIB
+ Positionierung von spaltigen Rahmen
+
+ Rev 1.33 25 Mar 1998 12:09:24 MIB
+ unneotige defines weg
+
+ Rev 1.32 19 Mar 1998 09:03:30 MIB
+ Abs.-Pos.: Attributierung nicht in Rahmen uebernehmen, Hoehe nun Mindest-Hoehe
+
+ Rev 1.31 11 Mar 1998 18:28:56 MIB
+ fix #47846#: auto-gebundenen Rahmen korrekt verankern
+
+ Rev 1.30 20 Feb 1998 19:01:50 MA
+ header
+
+ Rev 1.29 13 Feb 1998 18:42:48 HR
+ C40_INSERT
+
+ Rev 1.28 22 Jan 1998 19:58:30 JP
+ CTOR des SwPaM umgestellt
+
+ Rev 1.27 02 Dec 1997 09:13:02 MA
+ includes
+
+ Rev 1.26 20 Oct 1997 09:53:32 MIB
+ Nur fuer absolute positioning benoetigten Code groesstenteils auskommentiert
+
+ Rev 1.25 09 Oct 1997 14:35:34 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.24 16 Sep 1997 17:48:58 MIB
+ gleiche Methoden zusammengefasst
+
+ Rev 1.23 16 Sep 1997 11:17:44 MIB
+ Kopf-/Fusszeilen ohne Moven von Nodes, autom. Beenden von Bereichen/Rahmen
+
+ Rev 1.22 12 Sep 1997 11:56:48 MIB
+ MULTICOL ohne Move von Nodes
+
+ Rev 1.21 08 Sep 1997 17:47:56 MIB
+ Verankerung von AUTO_CNTNT-Rahmen nicht mehr verschieben
+
+ Rev 1.20 29 Aug 1997 16:49:42 OS
+ DLL-Umstellung
+
+ Rev 1.19 15 Aug 1997 12:46:40 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.18 12 Aug 1997 13:47:12 OS
+ Header-Umstellung
+
+ Rev 1.17 11 Aug 1997 14:06:46 OM
+ Headerfile-Umstellung
+
+ Rev 1.16 07 Aug 1997 15:07:48 OM
+ Headerfile-Umstellung
+
+ Rev 1.15 04 Aug 1997 13:54:22 MIB
+ aboslute psoitioning (fuer fast alle Zeichen-Attribute/-Vorlagen)
+
+ Rev 1.14 31 Jul 1997 10:44:02 MIB
+ DIV-STack weg, absolute positioning (sehr rudimentaer, nicht freigeschaltet)
+
+ Rev 1.13 08 Jul 1997 14:16:40 MIB
+ Meta-Tags als PostIts und die immer im ersten Body-Absatz verankern
+
+ Rev 1.12 13 Jun 1997 11:55:38 MIB
+ CLASS und ID CSS1-Optionen auswerten
+
+ Rev 1.11 16 Apr 1997 16:36:36 MIB
+ fix #38018#: Attribute wegen JavaScript hauefiger setzen
+
+ Rev 1.10 11 Apr 1997 14:42:48 MIB
+ fix #38645#: Keine Kopf-/fusszeilen beim Einfuegen einfuegen
+
+ Rev 1.9 10 Apr 1997 11:48:00 MIB
+ fix: gelinkte Bereiche nicht updaten aber schutzen
+
+ Rev 1.8 07 Apr 1997 14:42:54 MIB
+ fix: Vor Verschieben von Nodes auf StartNode und nicht auf EndIfIcons testen
+
+ Rev 1.7 05 Mar 1997 14:49:34 MIB
+ Absatz-Abstaende verbessert
+
+ Rev 1.6 20 Feb 1997 10:23:36 MIB
+ Absatnd von Kopf-/Fusszeilen am Absatz loeschen
+
+ Rev 1.5 19 Feb 1997 16:35:14 MIB
+ Absatz-Abstand als Abstand an Kopf- und Fusszeilen uebernehmen
+
+ Rev 1.4 16 Feb 1997 12:15:12 MIB
+ PageDesc-Atts in Kopf-/Fusszeilen und spaltige Bereichen richtig behandeln
+
+ Rev 1.3 14 Feb 1997 15:48:54 MIB
+ bug fix: Referenz auf PageFmt fuer Kopf-/Fusszeilen nehmen
+
+ Rev 1.2 14 Feb 1997 15:16:32 MIB
+ Kopf- und Fusszeilen importieren
+
+ Rev 1.1 05 Feb 1997 15:44:36 MIB
+ keine ::com::sun::star::text::Bookmarks fuer Bereiche anlegen (wegen gelinkten Bereichen)
+
+ Rev 1.0 05 Feb 1997 13:57:54 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
new file mode 100644
index 000000000000..4b1f09167f6d
--- /dev/null
+++ b/sw/source/filter/html/htmltab.cxx
@@ -0,0 +1,6187 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmltab.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//#define TEST_RESIZE
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include "hintids.hxx"
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTTSPLT_HXX //autogen
+#include <fmtlsplt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include "frmatr.hxx"
+#endif
+#include "pam.hxx"
+#include "doc.hxx"
+#include "ndtxt.hxx"
+#include "shellio.hxx"
+#include "poolfmt.hxx"
+#include "swtable.hxx"
+#include "cellatr.hxx"
+#ifdef TEST_RESIZE
+#include "viewsh.hxx"
+#endif
+#include "htmltbl.hxx"
+#include "swtblfmt.hxx"
+#include "htmlnum.hxx"
+#include "swhtml.hxx"
+#include "swcss1.hxx"
+
+#define NETSCAPE_DFLT_BORDER 1
+#define NETSCAPE_DFLT_CELLPADDING 1
+#define NETSCAPE_DFLT_CELLSPACING 2
+
+//#define FIX56334
+
+static HTMLOptionEnum __FAR_DATA aHTMLTblVAlignTable[] =
+{
+ { sHTML_VA_top, VERT_NONE },
+ { sHTML_VA_middle, VERT_CENTER },
+ { sHTML_VA_bottom, VERT_BOTTOM },
+ { 0, 0 }
+};
+
+
+/* */
+
+// Die Optionen eines Table-Tags
+
+struct HTMLTableOptions
+{
+ sal_uInt16 nCols;
+ sal_uInt16 nWidth;
+ sal_uInt16 nHeight;
+ sal_uInt16 nCellPadding;
+ sal_uInt16 nCellSpacing;
+ sal_uInt16 nBorder;
+ sal_uInt16 nHSpace;
+ sal_uInt16 nVSpace;
+
+ SvxAdjust eAdjust;
+ SwVertOrient eVertOri;
+ HTMLTableFrame eFrame;
+ HTMLTableRules eRules;
+
+ sal_Bool bPrcWidth : 1;
+ sal_Bool bTableAdjust : 1;
+ sal_Bool bBGColor : 1;
+
+ Color aBorderColor;
+ Color aBGColor;
+
+ String aBGImage, aStyle, aId, aClass;
+
+ HTMLTableOptions( const HTMLOptions *pOptions, SvxAdjust eParentAdjust );
+};
+
+/* */
+
+class _HTMLTableContext
+{
+ SwHTMLNumRuleInfo aNumRuleInfo; // Vor der Tabelle gueltige Numerierung
+
+ SwTableNode *pTblNd; // der Tabellen-Node
+ SwFrmFmt *pFrmFmt; // der Fly ::com::sun::star::frame::Frame, in dem die Tabelle steht
+ SwPosition *pPos; // die Position hinter der Tabelle
+
+ sal_uInt16 nContextStAttrMin;
+ sal_uInt16 nContextStMin;
+
+ sal_Bool bRestartPRE : 1;
+ sal_Bool bRestartXMP : 1;
+ sal_Bool bRestartListing : 1;
+
+public:
+
+ _HTMLAttrTable aAttrTab; // und die Attribute
+
+ _HTMLTableContext( SwPosition *pPs, sal_uInt16 nCntxtStMin,
+ sal_uInt16 nCntxtStAttrMin ) :
+ pTblNd( 0 ), pFrmFmt( 0 ), pPos( pPs ),
+ nContextStMin( nCntxtStMin ), nContextStAttrMin( nCntxtStAttrMin ),
+ bRestartPRE( sal_False ), bRestartXMP( sal_False ), bRestartListing( sal_False )
+ {
+ memset( &aAttrTab, 0, sizeof( _HTMLAttrTable ));
+ }
+
+ ~_HTMLTableContext();
+
+ void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { aNumRuleInfo.Set(rInf); }
+ const SwHTMLNumRuleInfo& GetNumInfo() const { return aNumRuleInfo; };
+
+ void SavePREListingXMP( SwHTMLParser& rParser );
+ void RestorePREListingXMP( SwHTMLParser& rParser );
+
+ SwPosition *GetPos() const { return pPos; }
+
+ void SetTableNode( SwTableNode *pNd ) { pTblNd = pNd; }
+ SwTableNode *GetTableNode() const { return pTblNd; }
+
+ void SetFrmFmt( SwFrmFmt *pFmt ) { pFrmFmt = pFmt; }
+ SwFrmFmt *GetFrmFmt() const { return pFrmFmt; }
+
+ sal_uInt16 GetContextStMin() const { return nContextStMin; }
+ sal_uInt16 GetContextStAttrMin() const { return nContextStAttrMin; }
+};
+
+/* */
+
+// der Inhalt einer Zelle ist eine verkettete Liste mit SwStartNodes und
+// HTMLTables.
+
+class HTMLTableCnts
+{
+ HTMLTableCnts *pNext; // der naechste Inhalt
+
+ // von den beiden naechsten Pointern darf nur einer gesetzt sein!
+ const SwStartNode *pStartNode; // ein Abastz
+ HTMLTable *pTable; // eine Tabelle
+
+ SwHTMLTableLayoutCnts* pLayoutInfo;
+
+ sal_Bool bNoBreak;
+
+ void InitCtor();
+
+public:
+
+ HTMLTableCnts( const SwStartNode* pStNd );
+ HTMLTableCnts( HTMLTable* pTab );
+
+ ~HTMLTableCnts(); // nur in ~HTMLTableCell erlaubt
+
+ // Ermitteln des SwStartNode bzw. der HTMLTable
+ const SwStartNode *GetStartNode() const { return pStartNode; }
+ const HTMLTable *GetTable() const { return pTable; }
+ HTMLTable *GetTable() { return pTable; }
+
+ // hinzufuegen eines neuen Knotens am Listenende
+ void Add( HTMLTableCnts* pNewCnts );
+
+ // Ermitteln des naechsten Knotens
+ const HTMLTableCnts *Next() const { return pNext; }
+ HTMLTableCnts *Next() { return pNext; }
+
+ inline void SetTableBox( SwTableBox *pBox );
+
+ void SetNoBreak() { bNoBreak = sal_True; }
+
+ SwHTMLTableLayoutCnts *CreateLayoutInfo();
+};
+
+/* */
+
+// Eine Zelle der HTML-Tabelle
+
+class HTMLTableCell
+{
+ // !!!ACHTUNG!!!!! Fuer jeden neuen Pointer muss die SetProtected-
+ // Methode (und natuerlich der Destruktor) bearbeitet werden.
+ HTMLTableCnts *pContents; // der Inhalt der Zelle
+ SvxBrushItem *pBGBrush; // Hintergrund der Zelle
+ // !!!ACHTUNG!!!!!
+
+ sal_uInt32 nNumFmt;
+ sal_uInt16 nRowSpan; // ROWSPAN der Zelle
+ sal_uInt16 nColSpan; // COLSPAN der Zelle
+ sal_uInt16 nWidth; // WIDTH der Zelle
+ double nValue;
+ SwVertOrient eVertOri; // vertikale Ausrichtung der Zelle
+ sal_Bool bProtected : 1; // Zelle darf nicht belegt werden
+ sal_Bool bRelWidth : 1; // nWidth ist %-Angabe
+ sal_Bool bHasNumFmt : 1;
+ sal_Bool bHasValue : 1;
+ sal_Bool bNoWrap : 1;
+
+public:
+
+ HTMLTableCell(); // neue Zellen sind immer leer
+
+ ~HTMLTableCell(); // nur in ~HTMLTableRow erlaubt
+
+ // Belegen einer nicht-leeren Zelle
+ void Set( HTMLTableCnts *pCnts, sal_uInt16 nRSpan, sal_uInt16 nCSpan,
+ SwVertOrient eVertOri, SvxBrushItem *pBGBrush,
+ sal_Bool bHasNumFmt, sal_uInt32 nNumFmt,
+ sal_Bool bHasValue, double nValue, sal_Bool bNoWrap );
+
+ // Schuetzen einer leeren 1x1-Zelle
+ void SetProtected();
+
+ // Setzen/Ermitteln des Inhalts einer Zelle
+ void SetContents( HTMLTableCnts *pCnts ) { pContents = pCnts; }
+ const HTMLTableCnts *GetContents() const { return pContents; }
+ HTMLTableCnts *GetContents() { return pContents; }
+
+ // ROWSPAN/COLSPAN der Zelle Setzen/Ermitteln
+ void SetRowSpan( sal_uInt16 nRSpan ) { nRowSpan = nRSpan; }
+ sal_uInt16 GetRowSpan() const { return nRowSpan; }
+
+ void SetColSpan( sal_uInt16 nCSpan ) { nColSpan = nCSpan; }
+ sal_uInt16 GetColSpan() const { return nColSpan; }
+
+ inline void SetWidth( sal_uInt16 nWidth, sal_Bool bRelWidth );
+
+ const SvxBrushItem *GetBGBrush() const { return pBGBrush; }
+
+ inline sal_Bool GetNumFmt( sal_uInt32& rNumFmt ) const;
+ inline sal_Bool GetValue( double& rValue ) const;
+
+ SwVertOrient GetVertOri() const { return eVertOri; }
+
+ // Ist die Zelle belegt oder geschuetzt?
+ sal_Bool IsUsed() const { return pContents!=0 || bProtected; }
+
+ SwHTMLTableLayoutCell *CreateLayoutInfo();
+};
+
+/* */
+
+// Eine Zeile der HTML-Tabelle
+
+typedef HTMLTableCell* HTMLTableCellPtr;
+SV_DECL_PTRARR_DEL(HTMLTableCells,HTMLTableCellPtr,5,5)
+
+class HTMLTableRow
+{
+ HTMLTableCells *pCells; // die Zellen der Zeile
+
+ sal_Bool bIsEndOfGroup : 1;
+ sal_Bool bSplitable : 1;
+
+ sal_uInt16 nHeight; // Optionen von <TR>/<TD>
+ sal_uInt16 nEmptyRows; // wieviele Leere Zeilen folgen
+
+ SvxAdjust eAdjust;
+ SwVertOrient eVertOri;
+ SvxBrushItem *pBGBrush; // Hintergrund der Zelle aus STYLE
+
+public:
+
+ sal_Bool bBottomBorder; // kommt hinter der Zeile eine Linie?
+
+ HTMLTableRow( sal_uInt16 nCells=0 ); // die Zellen der Zeile sind leer
+
+ ~HTMLTableRow();
+
+ inline void SetHeight( sal_uInt16 nHeight );
+ sal_uInt16 GetHeight() const { return nHeight; }
+
+ // Ermitteln einer Zelle
+ inline HTMLTableCell *GetCell( sal_uInt16 nCell ) const;
+ inline const HTMLTableCells *GetCells() const { return pCells; }
+
+
+ inline void SetAdjust( SvxAdjust eAdj ) { eAdjust = eAdj; }
+ inline SvxAdjust GetAdjust() const { return eAdjust; }
+
+ inline void SetVertOri( SwVertOrient eV) { eVertOri = eV; }
+ inline SwVertOrient GetVertOri() const { return eVertOri; }
+
+ void SetBGBrush( SvxBrushItem *pBrush ) { pBGBrush = pBrush; }
+ const SvxBrushItem *GetBGBrush() const { return pBGBrush; }
+
+ inline void SetEndOfGroup() { bIsEndOfGroup = sal_True; }
+ inline sal_Bool IsEndOfGroup() const { return bIsEndOfGroup; }
+
+ void IncEmptyRows() { nEmptyRows++; }
+ sal_uInt16 GetEmptyRows() const { return nEmptyRows; }
+
+ // Expandieren einer Zeile durch hinzufuegen leerer Zellen
+ void Expand( sal_uInt16 nCells, sal_Bool bOneCell=sal_False );
+
+ // Verkuerzen einer Zeile durch loesen von leeren Zellen
+ void Shrink( sal_uInt16 nCells );
+
+ void SetSplitable( sal_Bool bSet ) { bSplitable = bSet; }
+ sal_Bool IsSplitable() const { return bSplitable; }
+};
+
+/* */
+
+// Eine Spalte der HTML-Tabelle
+
+class HTMLTableColumn
+{
+ sal_Bool bIsEndOfGroup;
+
+ sal_uInt16 nWidth; // Optionen von <COL>
+ sal_Bool bRelWidth;
+
+ SvxAdjust eAdjust;
+ SwVertOrient eVertOri;
+
+ SwFrmFmt *aFrmFmts[6];
+
+ inline sal_uInt16 GetFrmFmtIdx( sal_Bool bBorderLine,
+ SwVertOrient eVertOri ) const;
+
+public:
+
+ sal_Bool bLeftBorder; // kommt vor der Spalte eine Linie
+
+ HTMLTableColumn();
+
+ inline void SetWidth( sal_uInt16 nWidth, sal_Bool bRelWidth);
+
+ inline void SetAdjust( SvxAdjust eAdj ) { eAdjust = eAdj; }
+ inline SvxAdjust GetAdjust() const { return eAdjust; }
+
+ inline void SetVertOri( SwVertOrient eV) { eVertOri = eV; }
+ inline SwVertOrient GetVertOri() const { return eVertOri; }
+
+ inline void SetEndOfGroup() { bIsEndOfGroup = sal_True; }
+ inline sal_Bool IsEndOfGroup() const { return bIsEndOfGroup; }
+
+ inline void SetFrmFmt( SwFrmFmt *pFmt, sal_Bool bBorderLine,
+ SwVertOrient eVertOri );
+ inline SwFrmFmt *GetFrmFmt( sal_Bool bBorderLine,
+ SwVertOrient eVertOri ) const;
+
+ SwHTMLTableLayoutColumn *CreateLayoutInfo();
+};
+
+/* */
+
+// eine HTML-Tabelle
+
+typedef HTMLTableRow* HTMLTableRowPtr;
+SV_DECL_PTRARR_DEL(HTMLTableRows,HTMLTableRowPtr,5,5)
+
+typedef HTMLTableColumn* HTMLTableColumnPtr;
+SV_DECL_PTRARR_DEL(HTMLTableColumns,HTMLTableColumnPtr,5,5)
+
+SV_DECL_PTRARR(SdrObjects,SdrObject *,1,1)
+
+class HTMLTable
+{
+ String aId;
+ String aStyle;
+ String aClass;
+
+ SdrObjects *pResizeDrawObjs;// SDR-Objekte
+ SvUShorts *pDrawObjPrcWidths; // Spalte des Zeichen-Objekts und dessen
+ // relative Breite
+
+ HTMLTableRows *pRows; // die Zeilen der Tabelle
+ HTMLTableColumns *pColumns; // die Spalten der Tabelle
+
+ sal_uInt16 nRows; // Anzahl Zeilen
+ sal_uInt16 nCols; // Anzahl Spalten
+ sal_uInt16 nFilledCols; // Anzahl tatsaechlich gefuellter Spalten
+
+ sal_uInt16 nCurRow; // aktuelle Zeile
+ sal_uInt16 nCurCol; // aktuelle Spalte
+
+ sal_uInt16 nLeftMargin; // Abstand zum linken Rand (aus Absatz)
+ sal_uInt16 nRightMargin; // Abstand zum rechten Rand (aus Absatz)
+
+ sal_uInt16 nCellPadding; // Abstand Umrandung zum Text
+ sal_uInt16 nCellSpacing; // Abstand zwischen zwei Zellen
+ sal_uInt16 nHSpace;
+ sal_uInt16 nVSpace;
+
+ sal_uInt16 nBoxes; // Wievele Boxen enthaelt die Tabelle
+
+ const SwStartNode *pPrevStNd; // der Table-Node oder der Start-Node
+ // der vorhergehenden Section
+ const SwTable *pSwTable; // die SW-Tabelle (nur auf dem Top-Level)
+ SwTableBox *pBox1; // die TableBox, die beim Erstellen
+ // der Top-Level-Tabelle angelegt wird
+
+ SwTableBoxFmt *pBoxFmt; // das ::com::sun::star::frame::Frame-Format einer SwTableBox
+ SwTableLineFmt *pLineFmt; // das ::com::sun::star::frame::Frame-Format einer SwTableLine
+ SwTableLineFmt *pLineFrmFmtNoHeight;
+ SvxBrushItem *pBGBrush; // Hintergrund der Tabelle
+ SvxBrushItem *pInhBGBrush; // "geerbter" Hintergrund der Tabelle
+ const SwStartNode *pCaptionStartNode; // Start-Node der Tabellen-Ueberschrift
+
+ SvxBorderLine aTopBorderLine; // die Linie fuer die Umrandung
+ SvxBorderLine aBottomBorderLine;// die Linie fuer die Umrandung
+ SvxBorderLine aLeftBorderLine; // die Linie fuer die Umrandung
+ SvxBorderLine aRightBorderLine; // die Linie fuer die Umrandung
+ SvxBorderLine aBorderLine; // die Linie fuer die Umrandung
+ SvxBorderLine aInhLeftBorderLine; // die Linie fuer die Umrandung
+ SvxBorderLine aInhRightBorderLine; // die Linie fuer die Umrandung
+ sal_Bool bTopBorder; // besitzt die Tabelle oben eine Linie
+ sal_Bool bRightBorder; // besitzt die Tabelle rechts eine Linie
+ sal_Bool bTopAlwd; // duerfen die Raender gesetzt werden?
+ sal_Bool bRightAlwd;
+ sal_Bool bFillerTopBorder; // bekommt eine linke/rechter Filler-
+ sal_Bool bFillerBottomBorder; // Zelle eine obere/untere Umrandung?
+ sal_Bool bInhLeftBorder;
+ sal_Bool bInhRightBorder;
+ sal_Bool bBordersSet; // die Umrandung wurde bereits gesetzt
+ sal_Bool bForceFrame;
+ sal_Bool bTableAdjustOfTag; // stammt nTableAdjust aus <TABLE>?
+ sal_Bool bHeadlineRepeat; // Ueberschrift wiederholen
+ sal_Bool bIsParentHead;
+ sal_Bool bHasParentSection;
+ sal_Bool bMakeTopSubTable;
+ sal_Bool bHasToFly;
+ sal_Bool bFixedCols;
+ sal_Bool bColSpec; // Gab es COL(GROUP)-Elemente?
+ sal_Bool bPrcWidth; // Breite ist eine %-Angabe
+
+ SwHTMLParser *pParser; // der aktuelle Parser
+ HTMLTable *pTopTable; // die Tabelle auf dem Top-Level
+ HTMLTableCnts *pParentContents;
+
+ _HTMLTableContext *pContext; // der Kontext der Tabelle
+
+ SwHTMLTableLayout *pLayoutInfo;
+
+
+ // die folgenden Parameter stammen aus der dem <TABLE>-Tag
+ sal_uInt16 nWidth; // die Breite der Tabelle
+ sal_uInt16 nHeight; // absolute Hoehe der Tabelle
+ SvxAdjust eTableAdjust; // ::com::sun::star::drawing::Alignment der Tabelle
+ SwVertOrient eVertOri; // Default vertikale Ausr. der Zellen
+ sal_uInt16 nBorder; // Breite der auesseren Umrandung
+ HTMLTableFrame eFrame; // Rahmen um die Tabelle
+ HTMLTableRules eRules; // Ramhen in der Tabelle
+ sal_Bool bTopCaption; // Ueberschrift ueber der Tabelle
+
+ void InitCtor( const HTMLTableOptions *pOptions );
+
+ // Korigieren des Row-Spans fuer alle Zellen oberhalb der
+ // angegeben Zelle und der Zelle selbst, fuer die den anegebenen
+ // Inhalt besitzen. Die angegeben Zelle bekommt den Row-Span 1
+ void FixRowSpan( sal_uInt16 nRow, sal_uInt16 nCol, const HTMLTableCnts *pCnts );
+
+ // Schuetzen der angegeben Zelle und den darunterliegenden
+ void ProtectRowSpan( sal_uInt16 nRow, sal_uInt16 nCol, sal_uInt16 nRowSpan );
+
+ // Suchen des SwStartNodes der logisch vorhergehenden Box
+ // bei nRow==nCell==USHRT_MAX wird der allerletzte Start-Node
+ // der Tabelle zurueckgegeben
+ const SwStartNode* GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 nCell ) const;
+
+ sal_uInt16 GetTopCellSpace( sal_uInt16 nRow, sal_uInt16 nRowSpan,
+ sal_Bool bSwBorders=sal_True ) const;
+ sal_uInt16 GetBottomCellSpace( sal_uInt16 nRow, sal_uInt16 nRowSpan,
+ sal_Bool bSwBorders=sal_True ) const;
+
+ // Anpassen des ::com::sun::star::frame::Frame-Formates einer Box
+ void FixFrameFmt( SwTableBox *pBox, sal_uInt16 nRow, sal_uInt16 nCol,
+ sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
+ sal_Bool bFirstPara=sal_True, sal_Bool bLastPara=sal_True ) const;
+ void FixFillerFrameFmt( SwTableBox *pBox, sal_Bool bRight ) const;
+
+ // den Inhalt (Lines/Boxen) eine Tabelle erstellen
+ void _MakeTable( SwTableBox *pUpper=0 );
+
+ // Anlegen einer neuen SwTableBox, die einen SwStartNode enthaelt
+ SwTableBox *NewTableBox( const SwStartNode *pStNd,
+ SwTableLine *pUpper ) const;
+
+ // Erstellen einer SwTableLine aus den Zellen des Rechtecks
+ // (nTopRow/nLeftCol) inklusive bis (nBottomRow/nRightRow) exklusive
+ SwTableLine *MakeTableLine( SwTableBox *pUpper,
+ sal_uInt16 nTopRow, sal_uInt16 nLeftCol,
+ sal_uInt16 nBottomRow, sal_uInt16 nRightCol );
+
+ // Erstellen einer SwTableBox aus den Zellen des Rechtecks
+ // (nTopRow/nLeftCol) inklusive bis (nBottomRow/nRightRow) exklusive
+ SwTableBox *MakeTableBox( SwTableLine *pUpper,
+ sal_uInt16 nTopRow, sal_uInt16 nLeftCol,
+ sal_uInt16 nBottomRow, sal_uInt16 nRightCol );
+
+ // Erstellen einer SwTableBox aus dem Inhalt einer Zelle
+ SwTableBox *MakeTableBox( SwTableLine *pUpper,
+ HTMLTableCnts *pCnts,
+ sal_uInt16 nTopRow, sal_uInt16 nLeftCol,
+ sal_uInt16 nBootomRow, sal_uInt16 nRightCol );
+
+ // der Autolayout-Algorithmus
+
+ // Setzen der Umrandung anhand der Vorgaben der Parent-Tabelle
+ void InheritBorders( const HTMLTable *pParent,
+ sal_uInt16 nRow, sal_uInt16 nCol,
+ sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
+ sal_Bool bFirstPara, sal_Bool bLastPara );
+
+ // Linke und rechte Umrandung der umgebenen Tabelle erben
+ void InheritVertBorders( const HTMLTable *pParent,
+ sal_uInt16 nCol, sal_uInt16 nColSpan );
+
+
+ // Setzen der Umrandung anhand der Benutzervorgaben
+ void SetBorders();
+
+ // wurde die Umrandung der Tabelle schon gesetzt
+ sal_Bool BordersSet() const { return bBordersSet; }
+
+ const SvxBrushItem *GetBGBrush() const { return pBGBrush; }
+ const SvxBrushItem *GetInhBGBrush() const { return pInhBGBrush; }
+
+ sal_uInt16 GetBorderWidth( const SvxBorderLine& rBLine,
+ sal_Bool bWithDistance=sal_False ) const;
+
+public:
+
+ sal_Bool bFirstCell; // wurde schon eine Zelle angelegt?
+
+ HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab,
+ sal_Bool bParHead, sal_Bool bHasParentSec,
+ sal_Bool bTopTbl, sal_Bool bHasToFly,
+ const HTMLTableOptions *pOptions );
+
+ ~HTMLTable();
+
+ // Ermitteln einer Zelle
+ inline HTMLTableCell *GetCell( sal_uInt16 nRow, sal_uInt16 nCell ) const;
+
+ // Ueberschrift setzen/ermitteln
+ inline void SetCaption( const SwStartNode *pStNd, sal_Bool bTop );
+ const SwStartNode *GetCaptionStartNode() const { return pCaptionStartNode; }
+ sal_Bool IsTopCaption() const { return bTopCaption; }
+
+ SvxAdjust GetTableAdjust( sal_Bool bAny ) const
+ {
+ return (bTableAdjustOfTag || bAny) ? eTableAdjust : SVX_ADJUST_END;
+ }
+ SwVertOrient GetVertOri() const { return eVertOri; }
+
+ sal_uInt16 GetHSpace() const { return nHSpace; }
+ sal_uInt16 GetVSpace() const { return nVSpace; }
+
+ sal_Bool HasPrcWidth() const { return bPrcWidth; }
+ sal_uInt8 GetPrcWidth() const { return bPrcWidth ? (sal_uInt8)nWidth : 0; }
+
+ sal_uInt16 GetMinWidth() const
+ {
+ sal_uInt32 nMin = pLayoutInfo->GetMin();
+ return nMin < USHRT_MAX ? (sal_uInt16)nMin : USHRT_MAX;
+ }
+
+ // von Zeilen oder Spalten geerbtes ::com::sun::star::drawing::Alignment holen
+ SvxAdjust GetInheritedAdjust() const;
+ SwVertOrient GetInheritedVertOri() const;
+
+ // Einfuegen einer Zelle an der aktuellen Position
+ void InsertCell( HTMLTableCnts *pCnts, sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
+ sal_uInt16 nWidth, sal_Bool bRelWidth, sal_uInt16 nHeight,
+ SwVertOrient eVertOri, SvxBrushItem *pBGBrush,
+ sal_Bool bHasNumFmt, sal_uInt32 nNumFmt,
+ sal_Bool bHasValue, double nValue, sal_Bool bNoWrap );
+
+ // Start/Ende einer neuen Zeile bekanntgeben
+ void OpenRow( SvxAdjust eAdjust, SwVertOrient eVertOri,
+ SvxBrushItem *pBGBrush );
+ void CloseRow( sal_Bool bEmpty );
+
+ // Ende einer neuen Section bekanntgeben
+ inline void CloseSection( sal_Bool bHead );
+
+ // Ende einer Spalten-Gruppe bekanntgeben
+ inline void CloseColGroup( sal_uInt16 nSpan, sal_uInt16 nWidth, sal_Bool bRelWidth,
+ SvxAdjust eAdjust, SwVertOrient eVertOri );
+
+ // Einfuegen einer Spalte
+ void InsertCol( sal_uInt16 nSpan, sal_uInt16 nWidth, sal_Bool bRelWidth,
+ SvxAdjust eAdjust, SwVertOrient eVertOri );
+
+ // Beenden einer Tab-Definition (MUSS fuer ALLE Tabs aufgerufen werden)
+ void CloseTable();
+
+ // SwTable konstruieren (inkl. der Child-Tabellen)
+ void MakeTable( SwTableBox *pUpper, sal_uInt16 nAbsAvail,
+ sal_uInt16 nRelAvail=0, sal_uInt16 nAbsLeftSpace=0,
+ sal_uInt16 nAbsRightSpace=0, sal_uInt16 nInhAbsSpace=0 );
+
+ inline sal_Bool IsNewDoc() const { return pParser->IsNewDoc(); }
+
+ void SetHasParentSection( sal_Bool bSet ) { bHasParentSection = bSet; }
+ sal_Bool HasParentSection() const { return bHasParentSection; }
+
+ void SetParentContents( HTMLTableCnts *pCnts ) { pParentContents = pCnts; }
+ HTMLTableCnts *GetParentContents() const { return pParentContents; }
+
+ void MakeParentContents();
+
+ sal_Bool GetIsParentHeader() const { return bIsParentHead; }
+
+ sal_Bool IsMakeTopSubTable() const { return bMakeTopSubTable; }
+ void SetHasToFly() { bHasToFly=sal_True; }
+ sal_Bool HasToFly() const { return bHasToFly; }
+
+ void SetTable( const SwStartNode *pStNd, _HTMLTableContext *pCntxt,
+ sal_uInt16 nLeft, sal_uInt16 nRight,
+ const SwTable *pSwTab=0, sal_Bool bFrcFrame=sal_False );
+
+ _HTMLTableContext *GetContext() const { return pContext; }
+
+ SwHTMLTableLayout *CreateLayoutInfo();
+
+ sal_Bool HasColTags() const { return bColSpec; }
+
+ sal_uInt16 IncGrfsThatResize() { return pSwTable ? ((SwTable *)pSwTable)->IncGrfsThatResize() : 0; }
+
+ void RegisterDrawObject( SdrObject *pObj, sal_uInt8 nPrcWidth );
+
+ const SwTable *GetSwTable() const { return pSwTable; }
+
+ void SetBGBrush( const SvxBrushItem& rBrush ) { delete pBGBrush; pBGBrush = new SvxBrushItem( rBrush ); }
+
+ const String& GetId() const { return aId; }
+ const String& GetClass() const { return aClass; }
+ const String& GetStyle() const { return aStyle; }
+
+ void IncBoxCount() { nBoxes++; }
+ sal_Bool IsOverflowing() const { return nBoxes > 64000; }
+};
+
+SV_IMPL_PTRARR(HTMLTableCells,HTMLTableCellPtr)
+SV_IMPL_PTRARR(HTMLTableRows,HTMLTableRowPtr)
+SV_IMPL_PTRARR(HTMLTableColumns,HTMLTableColumnPtr)
+
+/* */
+
+
+void HTMLTableCnts::InitCtor()
+{
+ pNext = 0;
+ pLayoutInfo = 0;
+
+ bNoBreak = sal_False;
+}
+
+HTMLTableCnts::HTMLTableCnts( const SwStartNode* pStNd ):
+ pStartNode(pStNd), pTable(0)
+{
+ InitCtor();
+}
+
+HTMLTableCnts::HTMLTableCnts( HTMLTable* pTab ):
+ pStartNode(0), pTable(pTab)
+{
+ InitCtor();
+}
+
+HTMLTableCnts::~HTMLTableCnts()
+{
+ delete pTable; // die Tabellen brauchen wir nicht mehr
+ delete pNext;
+}
+
+void HTMLTableCnts::Add( HTMLTableCnts* pNewCnts )
+{
+ HTMLTableCnts *pCnts = this;
+
+ while( pCnts->pNext )
+ pCnts = pCnts->pNext;
+
+ pCnts->pNext = pNewCnts;
+}
+
+inline void HTMLTableCnts::SetTableBox( SwTableBox *pBox )
+{
+ ASSERT( pLayoutInfo, "Da sit noch keine Layout-Info" );
+ if( pLayoutInfo )
+ pLayoutInfo->SetTableBox( pBox );
+}
+
+SwHTMLTableLayoutCnts *HTMLTableCnts::CreateLayoutInfo()
+{
+ if( !pLayoutInfo )
+ {
+ SwHTMLTableLayoutCnts *pNextInfo = pNext ? pNext->CreateLayoutInfo() : 0;
+ SwHTMLTableLayout *pTableInfo = pTable ? pTable->CreateLayoutInfo() : 0;
+
+ pLayoutInfo = new SwHTMLTableLayoutCnts( pStartNode, pTableInfo,
+ bNoBreak, pNextInfo );
+ }
+
+ return pLayoutInfo;
+}
+
+/* */
+
+HTMLTableCell::HTMLTableCell():
+ pContents(0),
+ pBGBrush(0),
+ nRowSpan(1), nColSpan(1), nWidth( 0 ),
+ eVertOri( VERT_NONE ),
+ bProtected(sal_False), bRelWidth( sal_False ),
+ bHasNumFmt(sal_False), nNumFmt(0),
+ bHasValue(sal_False), nValue(0)
+{}
+
+HTMLTableCell::~HTMLTableCell()
+{
+ // der Inhalt ist in mehrere Zellen eingetragen, darf aber nur einmal
+ // geloescht werden
+ if( 1==nRowSpan && 1==nColSpan )
+ {
+ delete pContents;
+ delete pBGBrush;
+ }
+}
+
+void HTMLTableCell::Set( HTMLTableCnts *pCnts, sal_uInt16 nRSpan, sal_uInt16 nCSpan,
+ SwVertOrient eVert, SvxBrushItem *pBrush,
+ sal_Bool bHasNF, sal_uInt32 nNF, sal_Bool bHasV, double nVal,
+ sal_Bool bNWrap )
+{
+ pContents = pCnts;
+ nRowSpan = nRSpan;
+ nColSpan = nCSpan;
+ bProtected = sal_False;
+ eVertOri = eVert;
+ pBGBrush = pBrush;
+
+ bHasNumFmt = bHasNF;
+ bHasValue = bHasV;
+ nNumFmt = nNF;
+ nValue = nVal;
+
+ bNoWrap = bNWrap;
+}
+
+inline void HTMLTableCell::SetWidth( sal_uInt16 nWdth, sal_Bool bRelWdth )
+{
+ nWidth = nWdth;
+ bRelWidth = bRelWdth;
+}
+
+void HTMLTableCell::SetProtected()
+{
+ // Die Inhalte dieser Zelle mussen nich irgenwo anders verankert
+ // sein, weil sie nicht geloescht werden!!!
+
+ // Inhalt loeschen
+ pContents = 0;
+
+ // Hintergrundfarbe kopieren.
+ if( pBGBrush )
+ pBGBrush = new SvxBrushItem( *pBGBrush );
+
+ nRowSpan = 1;
+ nColSpan = 1;
+ bProtected = sal_True;
+}
+
+inline sal_Bool HTMLTableCell::GetNumFmt( sal_uInt32& rNumFmt ) const
+{
+ rNumFmt = nNumFmt;
+ return bHasNumFmt;
+}
+
+inline sal_Bool HTMLTableCell::GetValue( double& rValue ) const
+{
+ rValue = nValue;
+ return bHasValue;
+}
+
+SwHTMLTableLayoutCell *HTMLTableCell::CreateLayoutInfo()
+{
+ SwHTMLTableLayoutCnts *pCntInfo = pContents ? pContents->CreateLayoutInfo() : 0;
+
+ return new SwHTMLTableLayoutCell( pCntInfo, nRowSpan, nColSpan, nWidth,
+ bRelWidth, bNoWrap );
+}
+
+/* */
+
+HTMLTableRow::HTMLTableRow( sal_uInt16 nCells ):
+ pCells(new HTMLTableCells), bIsEndOfGroup(sal_False),
+ eAdjust(SVX_ADJUST_END), eVertOri(VERT_TOP), pBGBrush(0),
+ bBottomBorder(sal_False), nHeight(0), nEmptyRows(0), bSplitable( sal_False )
+{
+ for( sal_uInt16 i=0; i<nCells; i++ )
+ {
+ pCells->Insert( new HTMLTableCell, pCells->Count() );
+ }
+
+ ASSERT( nCells==pCells->Count(),
+ "Zellenzahl in neuer HTML-Tabellenzeile stimmt nicht" );
+}
+
+HTMLTableRow::~HTMLTableRow()
+{
+ delete pCells;
+ delete pBGBrush;
+}
+
+inline void HTMLTableRow::SetHeight( sal_uInt16 nHght )
+{
+ if( nHght > nHeight )
+ nHeight = nHght;
+}
+
+inline HTMLTableCell *HTMLTableRow::GetCell( sal_uInt16 nCell ) const
+{
+ ASSERT( nCell<pCells->Count(),
+ "ungueltiger Zellen-Index in HTML-Tabellenzeile" );
+ return (*pCells)[nCell];
+}
+
+void HTMLTableRow::Expand( sal_uInt16 nCells, sal_Bool bOneCell )
+{
+ // die Zeile wird mit einer einzigen Zelle aufgefuellt, wenn
+ // bOneCell gesetzt ist. Das geht, nur fuer Zeilen, in die keine
+ // Zellen mehr eingefuegt werden!
+
+ sal_uInt16 nColSpan = nCells-pCells->Count();
+ for( sal_uInt16 i=pCells->Count(); i<nCells; i++ )
+ {
+ HTMLTableCell *pCell = new HTMLTableCell;
+ if( bOneCell )
+ pCell->SetColSpan( nColSpan );
+
+ pCells->Insert( pCell, pCells->Count() );
+ nColSpan--;
+ }
+
+ ASSERT( nCells==pCells->Count(),
+ "Zellenzahl in expandierter HTML-Tabellenzeile stimmt nicht" );
+}
+
+void HTMLTableRow::Shrink( sal_uInt16 nCells )
+{
+ ASSERT( nCells < pCells->Count(), "Anzahl Zellen falsch" );
+
+#ifdef DEBUG
+ sal_uInt16 nEnd = pCells->Count();
+ for( sal_uInt16 i=nCells; i<nEnd; i++ )
+ {
+ HTMLTableCell *pCell = (*pCells)[i];
+ ASSERT( pCell->GetRowSpan() == 1,
+ "RowSpan von zu loesender Zelle ist falsch" );
+ ASSERT( pCell->GetColSpan() == nEnd - i,
+ "ColSpan von zu loesender Zelle ist falsch" );
+ ASSERT( !pCell->GetContents(), "Zu loeschende Zelle hat Inhalt" );
+ }
+#endif
+
+ pCells->DeleteAndDestroy( nCells, pCells->Count()-nCells );
+}
+
+/* */
+
+HTMLTableColumn::HTMLTableColumn():
+ bIsEndOfGroup(sal_False),
+ nWidth(0), bRelWidth(sal_False),
+ eAdjust(SVX_ADJUST_END), eVertOri(VERT_TOP),
+ bLeftBorder(sal_False)
+{
+ for( sal_uInt16 i=0; i<6; i++ )
+ aFrmFmts[i] = 0;
+}
+
+inline void HTMLTableColumn::SetWidth( sal_uInt16 nWdth, sal_Bool bRelWdth )
+{
+ if( bRelWidth==bRelWdth )
+ {
+ if( nWdth > nWidth )
+ nWidth = nWdth;
+ }
+ else
+ nWidth = nWdth;
+ bRelWidth = bRelWdth;
+}
+
+inline SwHTMLTableLayoutColumn *HTMLTableColumn::CreateLayoutInfo()
+{
+ return new SwHTMLTableLayoutColumn( nWidth, bRelWidth, bLeftBorder );
+}
+
+inline sal_uInt16 HTMLTableColumn::GetFrmFmtIdx( sal_Bool bBorderLine,
+ SwVertOrient eVertOri ) const
+{
+ ASSERT( VERT_TOP != eVertOri, "Top ist nicht erlaubt" );
+ sal_uInt16 n = bBorderLine ? 3 : 0;
+ switch( eVertOri )
+ {
+ case VERT_CENTER: n+=1; break;
+ case VERT_BOTTOM: n+=2; break;
+ }
+ return n;
+}
+
+inline void HTMLTableColumn::SetFrmFmt( SwFrmFmt *pFmt, sal_Bool bBorderLine,
+ SwVertOrient eVertOri )
+{
+ aFrmFmts[GetFrmFmtIdx(bBorderLine,eVertOri)] = pFmt;
+}
+
+inline SwFrmFmt *HTMLTableColumn::GetFrmFmt( sal_Bool bBorderLine,
+ SwVertOrient eVertOri ) const
+{
+ return aFrmFmts[GetFrmFmtIdx(bBorderLine,eVertOri)];
+}
+
+/* */
+
+
+void HTMLTable::InitCtor( const HTMLTableOptions *pOptions )
+{
+ pResizeDrawObjs = 0;
+ pDrawObjPrcWidths = 0;
+
+ pRows = new HTMLTableRows;
+ pColumns = new HTMLTableColumns;
+ nRows = 0;
+ nCurRow = 0; nCurCol = 0;
+
+ pBox1 = 0;
+ pBoxFmt = 0; pLineFmt = 0;
+ pLineFrmFmtNoHeight = 0;
+ pInhBGBrush = 0;
+
+ pPrevStNd = 0;
+ pSwTable = 0;
+
+ bTopBorder = sal_False; bRightBorder = sal_False;
+ bTopAlwd = sal_True; bRightAlwd = sal_True;
+ bFillerTopBorder = sal_False; bFillerBottomBorder = sal_False;
+ bInhLeftBorder = sal_False; bInhRightBorder = sal_False;
+ bBordersSet = sal_False;
+ bForceFrame = sal_False;
+ bHeadlineRepeat = sal_False;
+
+ nLeftMargin = 0;
+ nRightMargin = 0;
+
+ const Color& rBorderColor = pOptions->aBorderColor;
+
+ long nBorderOpt = (long)pOptions->nBorder;
+ long nPWidth = nBorderOpt==USHRT_MAX ? NETSCAPE_DFLT_BORDER
+ : nBorderOpt;
+ long nPHeight = nBorderOpt==USHRT_MAX ? 0 : nBorderOpt;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+
+ // nBorder gibt die Breite der Umrandung an, wie sie in die
+ // Breitenberechnung in Netscape einfliesst. Wenn pOption->nBorder
+ // == USHRT_MAX, wurde keine BORDER-Option angegeben. Trotzdem fliesst
+ // eine 1 Pixel breite Umrandung in die Breitenberechnung mit ein.
+ nBorder = (sal_uInt16)nPWidth;
+ if( nBorderOpt==USHRT_MAX )
+ nPWidth = 0;
+
+ // HACK: ein Pixel-breite Linien sollen zur Haarlinie werden, wenn
+ // wir mit doppelter Umrandung arbeiten
+ if( pOptions->nCellSpacing!=0 && nBorderOpt==1 )
+ {
+ nPWidth = 1;
+ nPHeight = 1;
+ }
+
+ SvxCSS1Parser::SetBorderWidth( aTopBorderLine, (sal_uInt16)nPHeight,
+ pOptions->nCellSpacing!=0, sal_True );
+ aTopBorderLine.SetColor( rBorderColor );
+ aBottomBorderLine = aTopBorderLine;
+
+ if( nPWidth == nPHeight )
+ {
+ aLeftBorderLine = aTopBorderLine;
+ }
+ else
+ {
+ SvxCSS1Parser::SetBorderWidth( aLeftBorderLine, (sal_uInt16)nPWidth,
+ pOptions->nCellSpacing!=0, sal_True );
+ aLeftBorderLine.SetColor( rBorderColor );
+ }
+ aRightBorderLine = aLeftBorderLine;
+
+ if( pOptions->nCellSpacing != 0 )
+ {
+ aBorderLine.SetOutWidth( DEF_DOUBLE_LINE7_OUT );
+ aBorderLine.SetInWidth( DEF_DOUBLE_LINE7_IN );
+ aBorderLine.SetDistance( DEF_DOUBLE_LINE7_DIST );
+ }
+ else
+ {
+ aBorderLine.SetOutWidth( DEF_LINE_WIDTH_1 );
+ }
+ aBorderLine.SetColor( rBorderColor );
+
+ if( nCellPadding )
+ {
+ if( nCellPadding==USHRT_MAX )
+ nCellPadding = MIN_BORDER_DIST; // default
+ else
+ {
+ nCellPadding = pParser->ToTwips( nCellPadding );
+ if( nCellPadding<MIN_BORDER_DIST )
+ nCellPadding = MIN_BORDER_DIST;
+ }
+ }
+ if( nCellSpacing )
+ {
+ if( nCellSpacing==USHRT_MAX )
+ nCellSpacing = NETSCAPE_DFLT_CELLSPACING;
+ nCellSpacing = pParser->ToTwips( nCellSpacing );
+ }
+
+ nPWidth = pOptions->nHSpace;
+ nPHeight = pOptions->nVSpace;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nHSpace = (sal_uInt16)nPWidth;
+ nVSpace = (sal_uInt16)nPHeight;
+
+ bColSpec = sal_False;
+
+ pBGBrush = pParser->CreateBrushItem(
+ pOptions->bBGColor ? &(pOptions->aBGColor) : 0,
+ pOptions->aBGImage, aEmptyStr, aEmptyStr, aEmptyStr );
+
+ pContext = 0;
+ pParentContents = 0;
+
+ aId = pOptions->aId;
+ aClass = pOptions->aClass;
+ aStyle = pOptions->aStyle;
+}
+
+HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab,
+ sal_Bool bParHead,
+ sal_Bool bHasParentSec, sal_Bool bTopTbl, sal_Bool bHasToFlw,
+ const HTMLTableOptions *pOptions ) :
+ nCols( pOptions->nCols ),
+ nFilledCols( 0 ),
+ nWidth( pOptions->nWidth ), bPrcWidth( pOptions->bPrcWidth ),
+ nHeight( pTopTab ? 0 : pOptions->nHeight ),
+ nBoxes( 1 ),
+ eTableAdjust( pOptions->eAdjust ),
+ bTableAdjustOfTag( pTopTab ? sal_False : pOptions->bTableAdjust ),
+ eVertOri( pOptions->eVertOri ),
+ eFrame( pOptions->eFrame ), eRules( pOptions->eRules ),
+ nCellPadding( pOptions->nCellPadding ),
+ nCellSpacing( pOptions->nCellSpacing ),
+ pParser( pPars ), pTopTable( pTopTab ? pTopTab : this ),
+ pCaptionStartNode( 0 ),
+ bFirstCell( !pTopTab ),
+ bIsParentHead( bParHead ),
+ bHasParentSection( bHasParentSec ), bMakeTopSubTable( bTopTbl ),
+ bHasToFly( bHasToFlw ),
+ bFixedCols( pOptions->nCols>0 ), bTopCaption( sal_False ),
+ pLayoutInfo( 0 )
+{
+ InitCtor( pOptions );
+
+ for( sal_uInt16 i=0; i<nCols; i++ )
+ pColumns->Insert( new HTMLTableColumn, pColumns->Count() );
+}
+
+
+HTMLTable::~HTMLTable()
+{
+ delete pResizeDrawObjs;
+ delete pDrawObjPrcWidths;
+
+ delete pRows;
+ delete pColumns;
+ delete pBGBrush;
+ delete pInhBGBrush;
+
+ delete pContext;
+
+ // pLayoutInfo wurde entweder bereits geloescht oder muss aber es
+ // in den Besitz der SwTable uebergegangen.
+}
+
+SwHTMLTableLayout *HTMLTable::CreateLayoutInfo()
+{
+ sal_uInt16 nW = bPrcWidth ? nWidth : pParser->ToTwips( nWidth );
+
+ sal_uInt16 nBorderWidth = GetBorderWidth( aBorderLine, sal_True );
+ sal_uInt16 nLeftBorderWidth =
+ ((*pColumns)[0])->bLeftBorder ? GetBorderWidth( aLeftBorderLine, sal_True ) : 0;
+ sal_uInt16 nRightBorderWidth =
+ bRightBorder ? GetBorderWidth( aRightBorderLine, sal_True ) : 0;
+ sal_uInt16 nInhLeftBorderWidth = 0;
+ sal_uInt16 nInhRightBorderWidth = 0;
+
+ pLayoutInfo = new SwHTMLTableLayout(
+ pSwTable,
+ nRows, nCols, bFixedCols, bColSpec,
+ nW, bPrcWidth, nBorder, nCellPadding,
+ nCellSpacing, eTableAdjust,
+ nLeftMargin, nRightMargin,
+ nBorderWidth, nLeftBorderWidth, nRightBorderWidth,
+ nInhLeftBorderWidth, nInhRightBorderWidth );
+
+ sal_Bool bExportable = sal_True;
+ sal_uInt16 i;
+ for( i=0; i<nRows; i++ )
+ {
+ HTMLTableRow *pRow = (*pRows)[i];
+ for( sal_uInt16 j=0; j<nCols; j++ )
+ {
+ SwHTMLTableLayoutCell *pLayoutCell =
+ pRow->GetCell(j)->CreateLayoutInfo();
+
+ pLayoutInfo->SetCell( pLayoutCell, i, j );
+
+ if( bExportable )
+ {
+ SwHTMLTableLayoutCnts *pLayoutCnts =
+ pLayoutCell->GetContents();
+ bExportable = !pLayoutCnts ||
+ ( pLayoutCnts->GetStartNode() &&
+ !pLayoutCnts->GetNext() );
+ }
+ }
+ }
+
+ pLayoutInfo->SetExportable( bExportable );
+
+ for( i=0; i<nCols; i++ )
+ pLayoutInfo->SetColumn( ((*pColumns)[i])->CreateLayoutInfo(), i );
+
+ return pLayoutInfo;
+}
+
+inline void HTMLTable::SetCaption( const SwStartNode *pStNd, sal_Bool bTop )
+{
+ pCaptionStartNode = pStNd;
+ bTopCaption = bTop;
+}
+
+void HTMLTable::FixRowSpan( sal_uInt16 nRow, sal_uInt16 nCol,
+ const HTMLTableCnts *pCnts )
+{
+ sal_uInt16 nRowSpan=1;
+ HTMLTableCell *pCell;
+ while( ( pCell=GetCell(nRow,nCol), pCell->GetContents()==pCnts ) )
+ {
+ pCell->SetRowSpan( nRowSpan );
+ if( pLayoutInfo )
+ pLayoutInfo->GetCell(nRow,nCol)->SetRowSpan( nRowSpan );
+
+ if( !nRow ) break;
+ nRowSpan++; nRow--;
+ }
+}
+
+void HTMLTable::ProtectRowSpan( sal_uInt16 nRow, sal_uInt16 nCol, sal_uInt16 nRowSpan )
+{
+ for( sal_uInt16 i=0; i<nRowSpan; i++ )
+ {
+ GetCell(nRow+i,nCol)->SetProtected();
+ if( pLayoutInfo )
+ pLayoutInfo->GetCell(nRow+i,nCol)->SetProtected();
+ }
+}
+
+
+// Suchen des SwStartNodes der letzten belegten Vorgaengerbox
+const SwStartNode* HTMLTable::GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 nCol ) const
+{
+ const HTMLTableCnts *pPrevCnts = 0;
+
+ if( 0==nRow )
+ {
+ // immer die Vorgaenger-Zelle
+ if( nCol>0 )
+ pPrevCnts = GetCell( 0, nCol-1 )->GetContents();
+ else
+ return pPrevStNd;
+ }
+ else if( USHRT_MAX==nRow && USHRT_MAX==nCol )
+ // der Contents der letzten Zelle
+ pPrevCnts = GetCell( nRows-1, nCols-1 )->GetContents();
+ else
+ {
+ sal_uInt16 i;
+ HTMLTableRow *pPrevRow = (*pRows)[nRow-1];
+
+ // evtl. eine Zelle in der aktuellen Zeile
+ i = nCol;
+ while( i )
+ {
+ i--;
+ if( 1 == pPrevRow->GetCell(i)->GetRowSpan() )
+ {
+ pPrevCnts = GetCell(nRow,i)->GetContents();
+ break;
+ }
+ }
+
+ // sonst die letzte gefuellte Zelle der Zeile davor suchen
+ if( !pPrevCnts )
+ {
+ i = nCols;
+ while( !pPrevCnts && i )
+ {
+ i--;
+ pPrevCnts = pPrevRow->GetCell(i)->GetContents();
+ }
+ }
+ }
+ ASSERT( pPrevCnts, "keine gefuellte Vorgaenger-Zelle gefunden" );
+ if( !pPrevCnts )
+ {
+ pPrevCnts = GetCell(0,0)->GetContents();
+ if( !pPrevCnts )
+ return pPrevStNd;
+ }
+
+ while( pPrevCnts->Next() )
+ pPrevCnts = pPrevCnts->Next();
+
+ return ( pPrevCnts->GetStartNode() ? pPrevCnts->GetStartNode()
+ : pPrevCnts->GetTable()->GetPrevBoxStartNode( USHRT_MAX, USHRT_MAX ) );
+}
+
+
+static sal_Bool IsBoxEmpty( const SwTableBox *pBox )
+{
+ const SwStartNode *pSttNd = pBox->GetSttNd();
+ if( pSttNd &&
+ pSttNd->GetIndex() + 2 == pSttNd->EndOfSectionIndex() )
+ {
+ const SwCntntNode *pCNd =
+ pSttNd->GetNodes()[pSttNd->GetIndex()+1]->GetCntntNode();
+ if( pCNd && !pCNd->Len() )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_uInt16 HTMLTable::GetTopCellSpace( sal_uInt16 nRow, sal_uInt16 nRowSpan,
+ sal_Bool bSwBorders ) const
+{
+ sal_uInt16 nSpace = nCellPadding;
+
+ if( nRow == 0 )
+ {
+ nSpace += nBorder + nCellSpacing;
+ if( bSwBorders )
+ {
+ sal_uInt16 nTopBorderWidth =
+ GetBorderWidth( aTopBorderLine, sal_True );
+ if( nSpace < nTopBorderWidth )
+ nSpace = nTopBorderWidth;
+ }
+ }
+ else if( bSwBorders && ((*pRows)[nRow+nRowSpan-1])->bBottomBorder &&
+ nSpace < MIN_BORDER_DIST )
+ {
+ ASSERT( !nCellPadding, "GetTopCellSpace: CELLPADDING!=0" );
+ // Wenn die Gegenueberliegende Seite umrandet ist muessen
+ // wir zumindest den minimalen Abstand zum Inhalt
+ // beruecksichtigen. (Koennte man zusaetzlich auch an
+ // nCellPadding festmachen.)
+ nSpace = MIN_BORDER_DIST;
+ }
+
+ return nSpace;
+}
+
+sal_uInt16 HTMLTable::GetBottomCellSpace( sal_uInt16 nRow, sal_uInt16 nRowSpan,
+ sal_Bool bSwBorders ) const
+{
+ sal_uInt16 nSpace = nCellSpacing + nCellPadding;
+
+ if( nRow+nRowSpan == nRows )
+ {
+ nSpace += nBorder;
+
+ if( bSwBorders )
+ {
+ sal_uInt16 nBottomBorderWidth =
+ GetBorderWidth( aBottomBorderLine, sal_True );
+ if( nSpace < nBottomBorderWidth )
+ nSpace = nBottomBorderWidth;
+ }
+ }
+ else if( bSwBorders )
+ {
+ if( ((*pRows)[nRow+nRowSpan+1])->bBottomBorder )
+ {
+ sal_uInt16 nBorderWidth = GetBorderWidth( aBorderLine, sal_True );
+ if( nSpace < nBorderWidth )
+ nSpace = nBorderWidth;
+ }
+ else if( nRow==0 && bTopBorder && nSpace < MIN_BORDER_DIST )
+ {
+ ASSERT( GetBorderWidth( aTopBorderLine, sal_True ) > 0,
+ "GetBottomCellSpace: |aTopLine| == 0" );
+ ASSERT( !nCellPadding, "GetBottomCellSpace: CELLPADDING!=0" );
+ // Wenn die Gegenueberliegende Seite umrandet ist muessen
+ // wir zumindest den minimalen Abstand zum Inhalt
+ // beruecksichtigen. (Koennte man zusaetzlich auch an
+ // nCellPadding festmachen.)
+ nSpace = MIN_BORDER_DIST;
+ }
+ }
+
+ return nSpace;
+}
+
+void HTMLTable::FixFrameFmt( SwTableBox *pBox,
+ sal_uInt16 nRow, sal_uInt16 nCol,
+ sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
+ sal_Bool bFirstPara, sal_Bool bLastPara ) const
+{
+ SwFrmFmt *pFrmFmt = 0; // ::com::sun::star::frame::Frame-Format
+ SwVertOrient eVOri = VERT_NONE;
+ const SvxBrushItem *pBGBrush = 0; // Hintergrund
+ sal_Bool bTopLine = sal_False, bBottomLine = sal_False, bLastBottomLine = sal_False;
+ sal_Bool bReUsable = sal_False; // Format nochmals verwendbar?
+ sal_uInt16 nEmptyRows = 0;
+ sal_Bool bHasNumFmt = sal_False;
+ sal_Bool bHasValue = sal_False;
+ sal_uInt32 nNumFmt;
+ double nValue;
+
+ HTMLTableColumn *pColumn = (*pColumns)[nCol];
+
+ if( pBox->GetSttNd() )
+ {
+ // die Hintergrundfarbe/-grafik bestimmen
+ const HTMLTableCell *pCell = GetCell( nRow, nCol );
+ pBGBrush = pCell->GetBGBrush();
+ if( !pBGBrush )
+ {
+ // Wenn die Zelle ueber mehrere Zeilen geht muss ein evtl.
+ // an der Zeile gesetzter Hintergrund an die Zelle uebernommen
+ // werden.
+#ifndef FIX56334
+ // Wenn es sich um eine Tabelle in der Tabelle handelt und
+ // die Zelle ueber die gesamte Heoehe der Tabelle geht muss
+ // ebenfalls der Hintergrund der Zeile uebernommen werden, weil
+ // die Line von der GC (zu Recht) wegoptimiert wird.
+ if( nRowSpan > 1 || (this != pTopTable && nRowSpan==nRows) )
+#else
+ if( nRowSpan > 1 )
+#endif
+ {
+ pBGBrush = ((*pRows)[nRow])->GetBGBrush();
+ if( !pBGBrush && this != pTopTable )
+ {
+ pBGBrush = GetBGBrush();
+ if( !pBGBrush )
+ pBGBrush = GetInhBGBrush();
+ }
+ }
+ }
+
+ bTopLine = 0==nRow && bTopBorder && bFirstPara;
+ if( ((*pRows)[nRow+nRowSpan-1])->bBottomBorder && bLastPara )
+ {
+ nEmptyRows = ((*pRows)[nRow+nRowSpan-1])->GetEmptyRows();
+ if( nRow+nRowSpan == nRows )
+ bLastBottomLine = sal_True;
+ else
+ bBottomLine = sal_True;
+ }
+
+ eVOri = pCell->GetVertOri();
+ bHasNumFmt = pCell->GetNumFmt( nNumFmt );
+ if( bHasNumFmt )
+ bHasValue = pCell->GetValue( nValue );
+
+ if( nColSpan==1 && !bTopLine && !bLastBottomLine && !nEmptyRows &&
+ !pBGBrush && !bHasNumFmt )
+ {
+ pFrmFmt = pColumn->GetFrmFmt( bBottomLine, eVOri );
+ bReUsable = !pFrmFmt;
+ }
+ }
+
+ if( !pFrmFmt )
+ {
+ pFrmFmt = pBox->ClaimFrmFmt();
+
+ // die Breite der Box berechnen
+ SwTwips nFrmWidth = (SwTwips)pLayoutInfo->GetColumn(nCol)
+ ->GetRelColWidth();
+ for( sal_uInt16 i=1; i<nColSpan; i++ )
+ nFrmWidth += (SwTwips)pLayoutInfo->GetColumn(nCol+i)
+ ->GetRelColWidth();
+
+ // die Umrandung nur an Edit-Boxen setzen (bei der oberen und unteren
+ // Umrandung muss beruecks. werden, ob es sich um den ersten oder
+ // letzen Absatz der Zelle handelt)
+ if( pBox->GetSttNd() )
+ {
+ sal_Bool bSet = (nCellPadding > 0);
+
+ SvxBoxItem aBoxItem;
+ long nInnerFrmWidth = nFrmWidth;
+
+ if( bTopLine )
+ {
+ aBoxItem.SetLine( &aTopBorderLine, BOX_LINE_TOP );
+ bSet = sal_True;
+ }
+ if( bLastBottomLine )
+ {
+ aBoxItem.SetLine( &aBottomBorderLine, BOX_LINE_BOTTOM );
+ bSet = sal_True;
+ }
+ else if( bBottomLine )
+ {
+ if( nEmptyRows && !aBorderLine.GetInWidth() )
+ {
+ // Leere Zeilen koennen zur Zeit nur dann ueber
+ // dicke Linien simuliert werden, wenn die Linie
+ // einfach ist.
+ SvxBorderLine aThickBorderLine( aBorderLine );
+
+ sal_uInt16 nBorderWidth = aBorderLine.GetOutWidth();
+ nBorderWidth *= (nEmptyRows + 1);
+ SvxCSS1Parser::SetBorderWidth( aThickBorderLine,
+ nBorderWidth, sal_False );
+ aBoxItem.SetLine( &aThickBorderLine, BOX_LINE_BOTTOM );
+ }
+ else
+ {
+ aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
+ }
+ bSet = sal_True;
+ }
+ if( ((*pColumns)[nCol])->bLeftBorder )
+ {
+ const SvxBorderLine& rBorderLine =
+ 0==nCol ? aLeftBorderLine : aBorderLine;
+ aBoxItem.SetLine( &rBorderLine, BOX_LINE_LEFT );
+ nInnerFrmWidth -= GetBorderWidth( rBorderLine );
+ bSet = sal_True;
+ }
+ if( nCol+nColSpan == nCols && bRightBorder )
+ {
+ aBoxItem.SetLine( &aRightBorderLine, BOX_LINE_RIGHT );
+ nInnerFrmWidth -= GetBorderWidth( aRightBorderLine );
+ bSet = sal_True;
+ }
+
+ if( bSet )
+ {
+ // fix #30588#: BorderDist nicht mehr Bestandteil
+ // einer Zelle mit fixer Breite
+ sal_uInt16 nBDist =
+ (2*nCellPadding <= nInnerFrmWidth) ? nCellPadding
+ : (nInnerFrmWidth / 2);
+ // wir setzen das Item nur, wenn es eine Umrandung gibt
+ // oder eine ::com::sun::star::sheet::Border-Distanz vorgegeben ist. Fehlt letztere,
+ // dann gibt es eine Umrandung, und wir muessen die Distanz
+ // setzen
+ aBoxItem.SetDistance( nBDist ? nBDist : MIN_BORDER_DIST );
+ pFrmFmt->SetAttr( aBoxItem );
+ }
+ else
+ pFrmFmt->ResetAttr( RES_BOX );
+
+ if( pBGBrush )
+ {
+ pFrmFmt->SetAttr( *pBGBrush );
+ }
+ else
+ pFrmFmt->ResetAttr( RES_BACKGROUND );
+
+ // fix #41003#: Format nur setzten, wenn es auch einen Value
+ // gibt oder die Box leer ist.
+ if( bHasNumFmt && (bHasValue || IsBoxEmpty(pBox)) )
+ {
+ sal_Bool bLock = pFrmFmt->GetDoc()->GetNumberFormatter()
+ ->IsTextFormat( nNumFmt );
+ SfxItemSet aItemSet( *pFrmFmt->GetAttrSet().GetPool(),
+ RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
+ SvxAdjust eAdjust = SVX_ADJUST_END;
+ SwCntntNode *pCNd = 0;
+ if( !bLock )
+ {
+ const SwStartNode *pSttNd = pBox->GetSttNd();
+ pCNd = pSttNd->GetNodes()[pSttNd->GetIndex()+1]
+ ->GetCntntNode();
+ const SfxPoolItem *pItem;
+ if( pCNd && pCNd->GetpSwAttrSet() &&
+ SFX_ITEM_SET==pCNd->GetpSwAttrSet()->GetItemState(
+ RES_PARATR_ADJUST, sal_False, &pItem ) )
+ {
+ eAdjust = ((const SvxAdjustItem *)pItem)
+ ->GetAdjust();
+ }
+ }
+ aItemSet.Put( SwTblBoxNumFormat(nNumFmt) );
+ if( bHasValue )
+ aItemSet.Put( SwTblBoxValue(nValue) );
+
+ if( bLock )
+ pFrmFmt->LockModify();
+ pFrmFmt->SetAttr( aItemSet );
+ if( bLock )
+ pFrmFmt->UnlockModify();
+ else if( pCNd && SVX_ADJUST_END != eAdjust )
+ {
+ SvxAdjustItem aAdjItem( eAdjust );
+ pCNd->SetAttr( aAdjItem );
+ }
+ }
+ else
+ pFrmFmt->ResetAttr( RES_BOXATR_FORMAT );
+
+ ASSERT( eVOri != VERT_TOP, "VERT_TOP ist nicht erlaubt!" );
+ if( VERT_NONE != eVOri )
+ {
+ pFrmFmt->SetAttr( SwFmtVertOrient( 0, eVOri ) );
+ }
+ else
+ pFrmFmt->ResetAttr( RES_VERT_ORIENT );
+
+ if( bReUsable )
+ pColumn->SetFrmFmt( pFrmFmt, bBottomLine, eVOri );
+ }
+ else
+ {
+ pFrmFmt->ResetAttr( RES_BOX );
+ pFrmFmt->ResetAttr( RES_BACKGROUND );
+ pFrmFmt->ResetAttr( RES_VERT_ORIENT );
+ pFrmFmt->ResetAttr( RES_BOXATR_FORMAT );
+ }
+ }
+ else
+ {
+ ASSERT( pBox->GetSttNd() ||
+ SFX_ITEM_SET!=pFrmFmt->GetAttrSet().GetItemState(
+ RES_VERT_ORIENT, sal_False ),
+ "Box ohne Inhalt hat vertikale Ausrichtung" );
+ pBox->ChgFrmFmt( (SwTableBoxFmt*)pFrmFmt );
+ }
+
+}
+
+void HTMLTable::FixFillerFrameFmt( SwTableBox *pBox, sal_Bool bRight ) const
+{
+ SwFrmFmt *pFrmFmt = pBox->ClaimFrmFmt();
+
+ if( bFillerTopBorder || bFillerBottomBorder ||
+ (!bRight && bInhLeftBorder) || (bRight && bInhRightBorder) )
+ {
+ SvxBoxItem aBoxItem;
+ if( bFillerTopBorder )
+ aBoxItem.SetLine( &aTopBorderLine, BOX_LINE_TOP );
+ if( bFillerBottomBorder )
+ aBoxItem.SetLine( &aBottomBorderLine, BOX_LINE_BOTTOM );
+ if( !bRight && bInhLeftBorder )
+ aBoxItem.SetLine( &aInhLeftBorderLine, BOX_LINE_LEFT );
+ if( bRight && bInhRightBorder )
+ aBoxItem.SetLine( &aInhRightBorderLine, BOX_LINE_RIGHT );
+ aBoxItem.SetDistance( MIN_BORDER_DIST );
+ pFrmFmt->SetAttr( aBoxItem );
+ }
+ else
+ {
+ pFrmFmt->ResetAttr( RES_BOX );
+ }
+
+ if( GetInhBGBrush() )
+ pFrmFmt->SetAttr( *GetInhBGBrush() );
+ else
+ pFrmFmt->ResetAttr( RES_BACKGROUND );
+
+ pFrmFmt->ResetAttr( RES_VERT_ORIENT );
+ pFrmFmt->ResetAttr( RES_BOXATR_FORMAT );
+}
+
+SwTableBox *HTMLTable::NewTableBox( const SwStartNode *pStNd,
+ SwTableLine *pUpper ) const
+{
+ SwTableBox *pBox;
+
+ if( pTopTable->pBox1 &&
+ pTopTable->pBox1->GetSttNd() == pStNd )
+ {
+ // wenn der StartNode dem StartNode der initial angelegten Box
+ // entspricht nehmen wir diese Box
+ pBox = pTopTable->pBox1;
+ pBox->SetUpper( pUpper );
+ pTopTable->pBox1 = 0;
+ }
+ else
+ pBox = new SwTableBox( pBoxFmt, *pStNd, pUpper );
+
+ return pBox;
+}
+
+
+static void ResetLineFrmFmtAttrs( SwFrmFmt *pFrmFmt )
+{
+ pFrmFmt->ResetAttr( RES_FRM_SIZE );
+ pFrmFmt->ResetAttr( RES_BACKGROUND );
+ ASSERT( SFX_ITEM_SET!=pFrmFmt->GetAttrSet().GetItemState(
+ RES_VERT_ORIENT, sal_False ),
+ "Zeile hat vertikale Ausrichtung" );
+}
+
+// !!! kann noch vereinfacht werden
+SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper,
+ sal_uInt16 nTopRow, sal_uInt16 nLeftCol,
+ sal_uInt16 nBottomRow, sal_uInt16 nRightCol )
+{
+ SwTableLine *pLine;
+ if( this==pTopTable && !pUpper && 0==nTopRow )
+ pLine = (pSwTable->GetTabLines())[0];
+ else
+ pLine = new SwTableLine( pLineFrmFmtNoHeight ? pLineFrmFmtNoHeight
+ : pLineFmt,
+ 0, pUpper );
+
+ HTMLTableRow *pTopRow = (*pRows)[nTopRow];
+ sal_uInt16 nHeight = pTopRow->GetHeight();
+ const SvxBrushItem *pBGBrush = 0;
+#ifndef FIX56334
+ if( this == pTopTable || nTopRow>0 || nBottomRow<nRows )
+ {
+ // An der Line eine Frabe zu setzen macht keinen Sinn, wenn sie
+ // die auesserste und gleichzeitig einzige Zeile einer Tabelle in
+ // der Tabelle ist.
+#endif
+ pBGBrush = pTopRow->GetBGBrush();
+
+ if( !pBGBrush && this != pTopTable )
+ {
+ // Ein an einer Tabellen in der Tabelle gesetzter Hintergrund
+ // wird an den Rows gesetzt. Das gilt auch fuer den Hintergrund
+ // der Zelle, in dem die Tabelle vorkommt.
+ pBGBrush = GetBGBrush();
+ if( !pBGBrush )
+ pBGBrush = GetInhBGBrush();
+ }
+#ifndef FIX56334
+ }
+#endif
+ if( nTopRow==nBottomRow-1 && (nHeight || pBGBrush) )
+ {
+ SwTableLineFmt *pFrmFmt = (SwTableLineFmt*)pLine->ClaimFrmFmt();
+ ResetLineFrmFmtAttrs( pFrmFmt );
+
+ if( nHeight )
+ {
+ // Tabellenhoehe einstellen. Da es sich um eine
+ // Mindesthoehe handelt, kann sie genauso wie in
+ // Netscape berechnet werden, also ohne Beruecksichtigung
+ // der tatsaechlichen Umrandungsbreite.
+ nHeight += GetTopCellSpace( nTopRow, 1, sal_False ) +
+ GetBottomCellSpace( nTopRow, 1, sal_False );
+
+ pFrmFmt->SetAttr( SwFmtFrmSize( ATT_MIN_SIZE, 0, nHeight ) );
+ }
+
+ if( pBGBrush )
+ {
+ pFrmFmt->SetAttr( *pBGBrush );
+ }
+
+ }
+ else if( !pLineFrmFmtNoHeight )
+ {
+ // sonst muessen wir die Hoehe aus dem Attribut entfernen
+ // und koennen uns das Format merken
+ pLineFrmFmtNoHeight = (SwTableLineFmt*)pLine->ClaimFrmFmt();
+
+ ResetLineFrmFmtAttrs( pLineFrmFmtNoHeight );
+ }
+
+
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+
+ sal_uInt16 nStartCol = nLeftCol;
+ while( nStartCol<nRightCol )
+ {
+ for( sal_uInt16 nRow=nTopRow; nRow<nBottomRow; nRow++ )
+ (*pRows)[nRow]->SetSplitable( sal_True );
+
+ sal_uInt16 nCol = nStartCol;
+ sal_uInt16 nSplitCol = nRightCol;
+ sal_Bool bSplitted = sal_False;
+ while( !bSplitted )
+ {
+ ASSERT( nCol < nRightCol, "Zu weit gelaufen" );
+
+ // Kann hinter der aktuellen HTML-Tabellen-Spalte gesplittet
+ // werden? Wenn ja, koennte der enstehende Bereich auch noch
+ // in Zeilen zerlegt werden, wenn man die naechste Spalte
+ // hinzunimmt?
+ sal_Bool bSplit = sal_True;
+ sal_Bool bHoriSplitMayContinue = sal_False;
+ sal_Bool bHoriSplitPossible = sal_False;
+ for( sal_uInt16 nRow=nTopRow; nRow<nBottomRow; nRow++ )
+ {
+ HTMLTableCell *pCell = GetCell(nRow,nCol);
+ // Gibt es in allen vorhergehenden Spalten und der gerade
+ // btrachteten Zeile eine gemeinsame Zeile?
+ sal_Bool bHoriSplit = (*pRows)[nRow]->IsSplitable() &&
+ nRow+1 < nBottomRow &&
+ 1 == pCell->GetRowSpan();
+ (*pRows)[nRow]->SetSplitable( bHoriSplit );
+
+ bSplit &= ( 1 == pCell->GetColSpan() );
+ if( bSplit )
+ {
+ bHoriSplitPossible |= bHoriSplit;
+
+ // Gilt das eventuell auch noch, wenn man die naechste
+ // Spalte hinzunimmt?
+ bHoriSplit &= (nCol+1 < nRightCol &&
+ 1 == GetCell(nRow,nCol+1)->GetRowSpan());
+ bHoriSplitMayContinue |= bHoriSplit;
+ }
+ }
+
+#ifndef PRODUCT
+ if( nCol == nRightCol-1 )
+ {
+ ASSERT( bSplit, "Split-Flag falsch" );
+ ASSERT( !bHoriSplitMayContinue,
+ "HoriSplitMayContinue-Flag falsch" );
+ HTMLTableCell *pCell = GetCell( nTopRow, nStartCol );
+ ASSERT( pCell->GetRowSpan() != (nBottomRow-nTopRow) ||
+ !bHoriSplitPossible, "HoriSplitPossible-Flag falsch" );
+ }
+#endif
+ ASSERT( !bHoriSplitMayContinue || bHoriSplitPossible,
+ "bHoriSplitMayContinue, aber nicht bHoriSplitPossible" );
+
+ if( bSplit )
+ {
+ SwTableBox* pBox = 0;
+ HTMLTableCell *pCell = GetCell( nTopRow, nStartCol );
+ if( pCell->GetRowSpan() == (nBottomRow-nTopRow) &&
+ pCell->GetColSpan() == (nCol+1-nStartCol) )
+ {
+ // Die HTML-Tabellen-Zellen bilden genau eine Box.
+ // Dann muss hinter der Box gesplittet werden
+ nSplitCol = nCol + 1;
+
+ // eventuell ist die Zelle noch leer
+ if( !pCell->GetContents() )
+ {
+ ASSERT( 1==pCell->GetRowSpan(),
+ "leere Box ist nicht 1 Zeile hoch" );
+ const SwStartNode* pPrevStNd =
+ GetPrevBoxStartNode( nTopRow, nStartCol );
+ HTMLTableCnts *pCnts = new HTMLTableCnts(
+ pParser->InsertTableSection(pPrevStNd) );
+ SwHTMLTableLayoutCnts *pCntsLayoutInfo =
+ pCnts->CreateLayoutInfo();
+
+ pCell->SetContents( pCnts );
+ pLayoutInfo->GetCell( nTopRow, nStartCol )
+ ->SetContents( pCntsLayoutInfo );
+
+ // ggf. COLSPAN beachten
+ for( sal_uInt16 j=nStartCol+1; j<nSplitCol; j++ )
+ {
+ GetCell(nTopRow,j)->SetContents( pCnts );
+ pLayoutInfo->GetCell( nTopRow, j )
+ ->SetContents( pCntsLayoutInfo );
+ }
+ }
+ pBox = MakeTableBox( pLine, pCell->GetContents(),
+ nTopRow, nStartCol,
+ nBottomRow, nSplitCol );
+ bSplitted = sal_True;
+ }
+ else if( bHoriSplitPossible && bHoriSplitMayContinue )
+ {
+ // Bis hierher lies sich die Box noch in Zeilen zerlegen
+ // und evetutell gillt das auch noch, wenn man die
+ // naechste hinzunimmt. Dann suchen wir weiter, merken
+ // uns aber die Position als moegliche Split-Position.
+ nSplitCol = nCol + 1;
+ }
+ else
+ {
+ // Wenn sich die Box bis hier her noch in Zeilen
+ // zerlegen lies, durch hinzunahmen noch einer
+ // Spalte aber nicht mehr, dann wird genau hinter
+ // dieser Splate gesplittet. (#55447#: Das gilt
+ // insbesondere auch fuer die letzte Spalte).
+ // Hinter der aktuellen Spalte wurd ausserdem gesplittet,
+ // wenn bisher noch gar keine andere Split-Position
+ // gefunden wurde.
+ // In allen anderen Faellen wird die bisher gemerkte
+ // Split-Position benutzt.
+ if( bHoriSplitPossible || nSplitCol > nCol+1 )
+ {
+ ASSERT( !bHoriSplitMayContinue,
+ "bHoriSplitMayContinue==sal_True" );
+ ASSERT( bHoriSplitPossible || nSplitCol == nRightCol,
+ "bHoriSplitPossible-Flag sollte gesetzt sein" );
+
+ nSplitCol = nCol + 1;
+ }
+
+ // Wenn die enstehende Box nicht mehr in Zeilen zerlegt
+ // werden kann, wenn man die naechste Spalte hinzunimmt
+ // muss man ebenfalls Splitten.
+ pBox = MakeTableBox( pLine, nTopRow, nStartCol,
+ nBottomRow, nSplitCol );
+ bSplitted = sal_True;
+ }
+ if( pBox )
+ rBoxes.C40_INSERT( SwTableBox, pBox, rBoxes.Count() );
+ }
+ nCol++;
+ }
+ nStartCol = nSplitCol;
+ }
+
+ return pLine;
+}
+
+// Fuellen einer SwTableBox
+// !!! kann noch vereinfacht werden
+SwTableBox *HTMLTable::MakeTableBox( SwTableLine *pUpper,
+ sal_uInt16 nTopRow, sal_uInt16 nLeftCol,
+ sal_uInt16 nBottomRow, sal_uInt16 nRightCol )
+{
+ SwTableBox *pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+ FixFrameFmt( pBox, nTopRow, nLeftCol,
+ nTopRow-nBottomRow, nRightCol-nLeftCol );
+
+ SwTableLines& rLines = pBox->GetTabLines();
+ sal_Bool bSplitted = sal_False;
+
+ while( !bSplitted )
+ {
+ sal_uInt16 nStartRow = nTopRow;
+ for( sal_uInt16 i=nTopRow; i<nBottomRow; i++ )
+ {
+ // kann hinter der aktuellen HTML-Tabellen-Zeile gesplittet werden?
+ sal_Bool bSplit = sal_True;
+ HTMLTableRow *pRow = (*pRows)[i];
+ for( sal_uInt16 j=nLeftCol; j<nRightCol; j++ )
+ {
+ bSplit = ( 1 == pRow->GetCell(j)->GetRowSpan() );
+ if( !bSplit )
+ break;
+ }
+ if( bSplit && (nStartRow>nTopRow || i+1<nBottomRow) )
+ {
+ // kein Spezialfall fuer die erste Zeile neotig, da wir hier
+ // in einer Box und nicht in der Tabelle sind
+ SwTableLine *pLine = MakeTableLine( pBox, nStartRow, nLeftCol, i+1, nRightCol );
+
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+
+ nStartRow = i+1;
+ bSplitted = sal_True;
+ }
+ }
+ if( !bSplitted )
+ {
+ // jetzt muessen wir die Zelle mit Gewalt Teilen
+
+ nStartRow = nTopRow;
+ while( nStartRow < nBottomRow )
+ {
+ sal_uInt16 nMaxRowSpan=0;
+ HTMLTableRow *pStartRow = (*pRows)[nStartRow];
+ HTMLTableCell *pCell;
+ for( i=nLeftCol; i<nRightCol; i++ )
+ if( ( pCell=pStartRow->GetCell(i),
+ pCell->GetRowSpan() > nMaxRowSpan ) )
+ nMaxRowSpan = pCell->GetRowSpan();
+
+ nStartRow += nMaxRowSpan;
+ if( nStartRow<nBottomRow )
+ {
+ HTMLTableRow *pPrevRow = (*pRows)[nStartRow-1];
+ for( i=nLeftCol; i<nRightCol; i++ )
+ {
+ if( pPrevRow->GetCell(i)->GetRowSpan() > 1 )
+ {
+ // Die Inhalte sind in der Zeile darueber (also
+ // der durch FixRowSpan bearbeiteten) verankert
+ // und koennen/mussen deshalb in den mit
+ // ProtectRowSpan bearbeitetebn Zeilen
+ // geloescht oder kopiert werden
+ HTMLTableCell *pCell = GetCell( nStartRow, i );
+ FixRowSpan( nStartRow-1, i, pCell->GetContents() );
+ ProtectRowSpan( nStartRow, i,
+ pCell->GetRowSpan() );
+ }
+ }
+ }
+ }
+ // und jetzt nochmal von vorne ...
+ }
+ }
+
+ return pBox;
+}
+
+
+SwTableBox *HTMLTable::MakeTableBox( SwTableLine *pUpper,
+ HTMLTableCnts *pCnts,
+ sal_uInt16 nTopRow, sal_uInt16 nLeftCol,
+ sal_uInt16 nBottomRow, sal_uInt16 nRightCol )
+{
+ SwTableBox *pBox;
+ sal_uInt16 nColSpan = nRightCol - nLeftCol;
+ sal_uInt16 nRowSpan = nBottomRow - nTopRow;
+
+ if( !pCnts->Next() )
+ {
+ // nur eine Inhalts-Section
+ if( pCnts->GetStartNode() )
+ {
+ // und die ist keine Tabelle
+ pBox = NewTableBox( pCnts->GetStartNode(), pUpper );
+ pCnts->SetTableBox( pBox );
+ }
+ else
+ {
+ pCnts->GetTable()->InheritVertBorders( this, nLeftCol,
+ nRightCol-nLeftCol );
+ // und die ist eine Tabelle: dann bauen wir eine neue
+ // Box und fuegen die Zeilen der Tabelle in die Zeilen
+ // der Box ein
+ pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+ sal_uInt16 nAbs, nRel;
+ pLayoutInfo->GetAvail( nLeftCol, nColSpan, nAbs, nRel );
+ sal_uInt16 nLSpace = pLayoutInfo->GetLeftCellSpace( nLeftCol, nColSpan );
+ sal_uInt16 nRSpace = pLayoutInfo->GetRightCellSpace( nLeftCol, nColSpan );
+ sal_uInt16 nInhSpace = pLayoutInfo->GetInhCellSpace( nLeftCol, nColSpan );
+ pCnts->GetTable()->MakeTable( pBox, nAbs, nRel, nLSpace, nRSpace,
+ nInhSpace );
+ }
+ }
+ else
+ {
+ // mehrere Inhalts Sections: dann brauchen wir eine Box mit Zeilen
+ pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+ SwTableLines& rLines = pBox->GetTabLines();
+ sal_Bool bFirstPara = sal_True;
+
+ while( pCnts )
+ {
+ if( pCnts->GetStartNode() )
+ {
+ // normale Absaetze werden zu einer Box in einer Zeile
+ SwTableLine *pLine =
+ new SwTableLine( pLineFrmFmtNoHeight ? pLineFrmFmtNoHeight
+ : pLineFmt, 0, pBox );
+ if( !pLineFrmFmtNoHeight )
+ {
+ // Wenn es noch kein Line-Format ohne Hoehe gibt, koennen
+ // wir uns dieses her als soleches merken
+ pLineFrmFmtNoHeight = (SwTableLineFmt*)pLine->ClaimFrmFmt();
+
+ ResetLineFrmFmtAttrs( pLineFrmFmtNoHeight );
+ }
+
+ SwTableBox* pCntBox = NewTableBox( pCnts->GetStartNode(),
+ pLine );
+ pCnts->SetTableBox( pCntBox );
+ FixFrameFmt( pCntBox, nTopRow, nLeftCol, nRowSpan, nColSpan,
+ bFirstPara, 0==pCnts->Next() );
+ pLine->GetTabBoxes().C40_INSERT( SwTableBox, pCntBox,
+ pLine->GetTabBoxes().Count() );
+
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+ }
+ else
+ {
+ pCnts->GetTable()->InheritVertBorders( this, nLeftCol,
+ nRightCol-nLeftCol );
+ // Tabellen werden direkt eingetragen
+ sal_uInt16 nAbs, nRel;
+ pLayoutInfo->GetAvail( nLeftCol, nColSpan, nAbs, nRel );
+ sal_uInt16 nLSpace = pLayoutInfo->GetLeftCellSpace( nLeftCol,
+ nColSpan );
+ sal_uInt16 nRSpace = pLayoutInfo->GetRightCellSpace( nLeftCol,
+ nColSpan );
+ sal_uInt16 nInhSpace = pLayoutInfo->GetInhCellSpace( nLeftCol, nColSpan );
+ pCnts->GetTable()->MakeTable( pBox, nAbs, nRel, nLSpace,
+ nRSpace, nInhSpace );
+ }
+
+ pCnts = pCnts->Next();
+ bFirstPara = sal_False;
+ }
+ }
+
+ FixFrameFmt( pBox, nTopRow, nLeftCol, nRowSpan, nColSpan );
+
+ return pBox;
+}
+
+void HTMLTable::InheritBorders( const HTMLTable *pParent,
+ sal_uInt16 nRow, sal_uInt16 nCol,
+ sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
+ sal_Bool bFirstPara, sal_Bool bLastPara )
+{
+ ASSERT( nRows>0 && nCols>0 && nCurRow==nRows,
+ "Wurde CloseTable nicht aufgerufen?" );
+
+ // Die Child-Tabelle muss einen Rahmen bekommen, wenn die umgebende
+ // Zelle einen Rand an der betreffenden Seite besitzt.
+ // Der obere bzw. untere Rand wird nur gesetzt, wenn die Tabelle
+ // ale erster bzw. letzter Absatz in der Zelle vorkommt. Ansonsten
+ // Fuer den linken/rechten Rand kann noch nicht entschieden werden,
+ // ob eine Umrandung der Tabelle noetig/moeglich ist, weil das davon
+ // abhaengt, ob "Filler"-Zellen eingefuegt werden. Hier werden deshalb
+ // erstmal nur Informationen gesammelt
+ //
+ if( 0==nRow && pParent->bTopBorder && bFirstPara )
+ {
+ bTopBorder = sal_True;
+ bFillerTopBorder = sal_True; // auch Filler bekommt eine Umrandung
+ aTopBorderLine = pParent->aTopBorderLine;
+ }
+ if( ((*pParent->pRows)[nRow+nRowSpan-1])->bBottomBorder && bLastPara )
+ {
+ ((*pRows)[nRows-1])->bBottomBorder = sal_True;
+ bFillerBottomBorder = sal_True; // auch Filler bekommt eine Umrandung
+ aBottomBorderLine =
+ nRow+nRowSpan==pParent->nRows ? pParent->aBottomBorderLine
+ : pParent->aBorderLine;
+ }
+
+
+ // Die Child Tabelle darf keinen oberen oder linken Rahmen bekommen,
+ // wenn der bereits durch die umgebende Tabelle gesetzt ist.
+ // Sie darf jedoch immer einen oberen Rand bekommen, wenn die Tabelle
+ // nicht der erste Absatz in der Zelle ist.
+ bTopAlwd = ( !bFirstPara || (pParent->bTopAlwd &&
+ (0==nRow || !((*pParent->pRows)[nRow-1])->bBottomBorder)) );
+
+ // die Child-Tabelle muss die Farbe der Zelle erben, in der sie
+ // vorkommt, wenn sie keine eigene besitzt
+ const SvxBrushItem *pInhBG = pParent->GetCell(nRow,nCol)->GetBGBrush();
+ if( !pInhBG && pParent != pTopTable &&
+ pParent->GetCell(nRow,nCol)->GetRowSpan() == pParent->nRows )
+ {
+ // die ganze umgebende Tabelle ist eine Tabelle in der Tabelle
+ // und besteht nur aus einer Line, die bei der GC (zu Recht)
+ // wegoptimiert wird. Deshalb muss der Hintergrund der Line in
+ // diese Tabelle uebernommen werden.
+ pInhBG = ((*pParent->pRows)[nRow])->GetBGBrush();
+ if( !pInhBG )
+ pInhBG = pParent->GetBGBrush();
+ if( !pInhBG )
+ pInhBG = pParent->GetInhBGBrush();
+ }
+ if( pInhBG )
+ pInhBGBrush = new SvxBrushItem( *pInhBG );
+}
+
+void HTMLTable::InheritVertBorders( const HTMLTable *pParent,
+ sal_uInt16 nCol, sal_uInt16 nColSpan )
+{
+ sal_uInt16 nInhLeftBorderWidth = 0;
+ sal_uInt16 nInhRightBorderWidth = 0;
+
+ if( nCol+nColSpan==pParent->nCols && pParent->bRightBorder )
+ {
+ bInhRightBorder = sal_True; // erstmal nur merken
+ aInhRightBorderLine = pParent->aRightBorderLine;
+ nInhRightBorderWidth =
+ GetBorderWidth( aInhRightBorderLine, sal_True ) + MIN_BORDER_DIST;
+ }
+
+ if( ((*pParent->pColumns)[nCol])->bLeftBorder )
+ {
+ bInhLeftBorder = sal_True; // erstmal nur merken
+ aInhLeftBorderLine = 0==nCol ? pParent->aLeftBorderLine
+ : pParent->aBorderLine;
+ nInhLeftBorderWidth =
+ GetBorderWidth( aInhLeftBorderLine, sal_True ) + MIN_BORDER_DIST;
+ }
+
+ if( !bInhLeftBorder && (bFillerTopBorder || bFillerBottomBorder) )
+ nInhLeftBorderWidth = 2 * MIN_BORDER_DIST;
+ if( !bInhRightBorder && (bFillerTopBorder || bFillerBottomBorder) )
+ nInhRightBorderWidth = 2 * MIN_BORDER_DIST;
+ pLayoutInfo->SetInhBorderWidths( nInhLeftBorderWidth,
+ nInhRightBorderWidth );
+
+ bRightAlwd = ( pParent->bRightAlwd &&
+ (nCol+nColSpan==pParent->nCols ||
+ !((*pParent->pColumns)[nCol+nColSpan])->bLeftBorder) );
+}
+
+void HTMLTable::SetBorders()
+{
+ sal_uInt16 i;
+ for( i=1; i<nCols; i++ )
+ if( HTML_TR_ALL==eRules || HTML_TR_COLS==eRules ||
+ ((HTML_TR_ROWS==eRules || HTML_TR_GROUPS==eRules) &&
+ ((*pColumns)[i-1])->IsEndOfGroup()) )
+ ((*pColumns)[i])->bLeftBorder = sal_True;
+
+ for( i=0; i<nRows-1; i++ )
+ if( HTML_TR_ALL==eRules || HTML_TR_ROWS==eRules ||
+ ((HTML_TR_COLS==eRules || HTML_TR_GROUPS==eRules) &&
+ ((*pRows)[i])->IsEndOfGroup()) )
+ ((*pRows)[i])->bBottomBorder = sal_True;
+
+ if( bTopAlwd && (HTML_TF_ABOVE==eFrame || HTML_TF_HSIDES==eFrame ||
+ HTML_TF_BOX==eFrame) )
+ bTopBorder = sal_True;
+ if( HTML_TF_BELOW==eFrame || HTML_TF_HSIDES==eFrame ||
+ HTML_TF_BOX==eFrame )
+ ((*pRows)[nRows-1])->bBottomBorder = sal_True;
+ if( /*bRightAlwd &&*/ (HTML_TF_RHS==eFrame || HTML_TF_VSIDES==eFrame ||
+ HTML_TF_BOX==eFrame) )
+ bRightBorder = sal_True;
+ if( HTML_TF_LHS==eFrame || HTML_TF_VSIDES==eFrame || HTML_TF_BOX==eFrame )
+ ((*pColumns)[0])->bLeftBorder = sal_True;
+
+ for( i=0; i<nRows; i++ )
+ {
+ HTMLTableRow *pRow = (*pRows)[i];
+ for( sal_uInt16 j=0; j<nCols; j++ )
+ {
+ HTMLTableCell *pCell = pRow->GetCell(j);
+ if( pCell->GetContents() )
+ {
+ HTMLTableCnts *pCnts = pCell->GetContents();
+ sal_Bool bFirstPara = sal_True;
+ while( pCnts )
+ {
+ HTMLTable *pTable = pCnts->GetTable();
+ if( pTable && !pTable->BordersSet() )
+ {
+ pTable->InheritBorders( this, i, j,
+ pCell->GetRowSpan(),
+ pCell->GetColSpan(),
+ bFirstPara,
+ 0==pCnts->Next() );
+ pTable->SetBorders();
+ }
+ bFirstPara = sal_False;
+ pCnts = pCnts->Next();
+ }
+ }
+ }
+ }
+
+ bBordersSet = sal_True;
+}
+
+sal_uInt16 HTMLTable::GetBorderWidth( const SvxBorderLine& rBLine,
+ sal_Bool bWithDistance ) const
+{
+ sal_uInt16 nWidth = rBLine.GetOutWidth() + rBLine.GetInWidth() +
+ rBLine.GetDistance();
+ if( bWithDistance )
+ {
+ if( nCellPadding )
+ nWidth += nCellPadding;
+ else if( nWidth )
+ nWidth += MIN_BORDER_DIST;
+ }
+
+ return nWidth;
+}
+
+inline HTMLTableCell *HTMLTable::GetCell( sal_uInt16 nRow,
+ sal_uInt16 nCell ) const
+{
+ ASSERT( nRow<pRows->Count(),
+ "ungueltiger Zeilen-Index in HTML-Tabelle" );
+ return ((*pRows)[nRow])->GetCell( nCell );
+}
+
+
+
+SvxAdjust HTMLTable::GetInheritedAdjust() const
+{
+ SvxAdjust eAdjust = (nCurCol<nCols ? ((*pColumns)[nCurCol])->GetAdjust()
+ : SVX_ADJUST_END );
+ if( SVX_ADJUST_END==eAdjust )
+ eAdjust = ((*pRows)[nCurRow])->GetAdjust();
+
+ return eAdjust;
+}
+
+SwVertOrient HTMLTable::GetInheritedVertOri() const
+{
+ // VERT_TOP ist der default!
+ SwVertOrient eVOri = ((*pRows)[nCurRow])->GetVertOri();
+ if( VERT_TOP==eVOri && nCurCol<nCols )
+ eVOri = ((*pColumns)[nCurCol])->GetVertOri();
+ if( VERT_TOP==eVOri )
+ eVOri = eVertOri;
+
+ ASSERT( eVertOri != VERT_TOP, "VERT_TOP ist nicht erlaubt!" );
+ return eVOri;
+}
+
+void HTMLTable::InsertCell( HTMLTableCnts *pCnts,
+ sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
+ sal_uInt16 nWidth, sal_Bool bRelWidth, sal_uInt16 nHeight,
+ SwVertOrient eVertOri, SvxBrushItem *pBGBrush,
+ sal_Bool bHasNumFmt, sal_uInt32 nNumFmt,
+ sal_Bool bHasValue, double nValue, sal_Bool bNoWrap )
+{
+ if( !nRowSpan || (sal_uInt32)nCurRow + nRowSpan > USHRT_MAX )
+ nRowSpan = 1;
+
+ if( !nColSpan || (sal_uInt32)nCurCol + nColSpan > USHRT_MAX )
+ nColSpan = 1;
+
+ sal_uInt16 nColsReq = nCurCol + nColSpan; // benoetigte Spalten
+ sal_uInt16 nRowsReq = nCurRow + nRowSpan; // benoetigte Zeilen
+ sal_uInt16 i, j;
+
+ // falls wir mehr Spalten benoetigen als wir zur Zeit haben,
+ // muessen wir in allen Zeilen noch Zellen hinzufuegen
+ if( nCols < nColsReq )
+ {
+ for( i=nCols; i<nColsReq; i++ )
+ pColumns->Insert( new HTMLTableColumn, pColumns->Count() );
+ for( i=0; i<nRows; i++ )
+ ((*pRows)[i])->Expand( nColsReq, i<nCurRow );
+ nCols = nColsReq;
+ ASSERT( pColumns->Count()==nCols,
+ "Anzahl der Spalten nach Expandieren stimmt nicht" );
+ }
+ if( nColsReq > nFilledCols )
+ nFilledCols = nColsReq;
+
+ // falls wir mehr Zeilen benoetigen als wir zur Zeit haben,
+ // muessen wir noch neue Zeilen hinzufuegen
+ if( nRows < nRowsReq )
+ {
+ for( i=nRows; i<nRowsReq; i++ )
+ pRows->Insert( new HTMLTableRow(nCols), pRows->Count() );
+ nRows = nRowsReq;
+ ASSERT( nRows==pRows->Count(), "Zeilenzahl in Insert stimmt nicht" );
+ }
+
+ // Testen, ob eine Ueberschneidung vorliegt und diese
+ // gegebenfalls beseitigen
+ sal_uInt16 nSpanedCols = 0;
+ if( nCurRow>0 )
+ {
+ HTMLTableRow *pCurRow = (*pRows)[nCurRow];
+ for( i=nCurCol; i<nColsReq; i++ )
+ {
+ HTMLTableCell *pCell = pCurRow->GetCell(i);
+ if( pCell->GetContents() )
+ {
+ // Der Inhalt reicht von einer weiter oben stehenden Zelle
+ // hier herein. Inhalt und Farbe der Zelle sind deshalb in
+ // jedem Fall noch dort verankert und koennen deshalb
+ // ueberschrieben werden bzw. von ProtectRowSpan geloescht
+ // (Inhalt) oder kopiert (Farbe) werden.
+ nSpanedCols = i + pCell->GetColSpan();
+ FixRowSpan( nCurRow-1, i, pCell->GetContents() );
+ if( pCell->GetRowSpan() > nRowSpan )
+ ProtectRowSpan( nRowsReq, i,
+ pCell->GetRowSpan()-nRowSpan );
+ }
+ }
+ for( i=nColsReq; i<nSpanedCols; i++ )
+ {
+ // Auch diese Inhalte sind in jedem Fall nich in der Zeile
+ // darueber verankert.
+ HTMLTableCell *pCell = pCurRow->GetCell(i);
+ FixRowSpan( nCurRow-1, i, pCell->GetContents() );
+ ProtectRowSpan( nCurRow, i, pCell->GetRowSpan() );
+ }
+ }
+
+ // die Zellen fuellen
+ for( i=nColSpan; i>0; i-- )
+ for( j=nRowSpan; j>0; j-- )
+ GetCell( nRowsReq-j, nColsReq-i )
+ ->Set( pCnts, j, i, eVertOri, pBGBrush,
+ bHasNumFmt, nNumFmt, bHasValue, nValue, bNoWrap );
+
+ Size aTwipSz( bRelWidth ? 0 : nWidth, nHeight );
+ if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
+ {
+ aTwipSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
+ }
+
+ // die Breite nur in die erste Zelle setzen!
+ if( nWidth )
+ {
+ sal_uInt16 nTmp = bRelWidth ? nWidth : (sal_uInt16)aTwipSz.Width();
+ GetCell( nCurRow, nCurCol )->SetWidth( nTmp, bRelWidth );
+ }
+
+ // Ausserdem noch die Hoehe merken
+ if( nHeight && 1==nRowSpan )
+ {
+ if( nHeight < MINLAY )
+ nHeight = MINLAY;
+ ((*pRows)[nCurRow])->SetHeight( (sal_uInt16)aTwipSz.Height() );
+ }
+
+ // den Spaltenzaehler hinter die neuen Zellen setzen
+ nCurCol = nColsReq;
+ if( nSpanedCols > nCurCol )
+ nCurCol = nSpanedCols;
+
+ // und die naechste freie Zelle suchen
+ while( nCurCol<nCols && GetCell(nCurRow,nCurCol)->IsUsed() )
+ nCurCol++;
+}
+
+inline void HTMLTable::CloseSection( sal_Bool bHead )
+{
+ // die vorhergende Section beenden, falls es schon eine Zeile gibt
+ ASSERT( nCurRow<=nRows, "ungeultige aktuelle Zeile" );
+ if( nCurRow>0 && nCurRow<=nRows )
+ ((*pRows)[nCurRow-1])->SetEndOfGroup();
+ if( bHead /*&& nCurRow==1*/ )
+ bHeadlineRepeat = sal_True;
+}
+
+void HTMLTable::OpenRow( SvxAdjust eAdjust, SwVertOrient eVertOri,
+ SvxBrushItem *pBGBrush )
+{
+ sal_uInt16 nRowsReq = nCurRow+1; // Anzahl benoetigter Zeilen;
+
+ // die naechste Zeile anlegen, falls sie nicht schon da ist
+ if( nRows<nRowsReq )
+ {
+ for( sal_uInt16 i=nRows; i<nRowsReq; i++ )
+ pRows->Insert( new HTMLTableRow(nCols), pRows->Count() );
+ nRows = nRowsReq;
+ ASSERT( nRows==pRows->Count(),
+ "Zeilenzahl in OpenRow stimmt nicht" );
+ }
+
+ HTMLTableRow *pCurRow = ((*pRows)[nCurRow]);
+ pCurRow->SetAdjust( eAdjust );
+ pCurRow->SetVertOri( eVertOri );
+ if( pBGBrush )
+ ((*pRows)[nCurRow])->SetBGBrush( pBGBrush );
+
+ // den Spaltenzaehler wieder an den Anfang setzen
+ nCurCol=0;
+
+ // und die naechste freie Zelle suchen
+ while( nCurCol<nCols && GetCell(nCurRow,nCurCol)->IsUsed() )
+ nCurCol++;
+}
+
+void HTMLTable::CloseRow( sal_Bool bEmpty )
+{
+ ASSERT( nCurRow<nRows, "aktulle Zeile hinter dem Tabellenende" );
+
+ // leere Zellen bekommen einfach einen etwas dickeren unteren Rand!
+ if( bEmpty )
+ {
+ if( nCurRow > 0 )
+ ((*pRows)[nCurRow-1])->IncEmptyRows();
+ return;
+ }
+
+ HTMLTableRow *pRow = (*pRows)[nCurRow];
+
+ // den COLSPAN aller leeren Zellen am Zeilenende so anpassen, dass
+ // eine Zelle daraus wird. Das kann man hier machen (und auf keinen
+ // Fall frueher), weill jetzt keine Zellen mehr in die Zeile eingefuegt
+ // werden.
+ sal_uInt16 i=nCols;
+ while( i )
+ {
+ HTMLTableCell *pCell = pRow->GetCell(--i);
+ if( !pCell->GetContents() )
+ {
+ sal_uInt16 nColSpan = nCols-i;
+ if( nColSpan > 1 )
+ pCell->SetColSpan( nColSpan );
+ }
+ else
+ break;
+ }
+
+
+ nCurRow++;
+}
+
+inline void HTMLTable::CloseColGroup( sal_uInt16 nSpan, sal_uInt16 nWidth,
+ sal_Bool bRelWidth, SvxAdjust eAdjust,
+ SwVertOrient eVertOri )
+{
+ if( nSpan )
+ InsertCol( nSpan, nWidth, bRelWidth, eAdjust, eVertOri );
+
+ ASSERT( nCurCol<=nCols, "ungueltige Spalte" );
+ if( nCurCol>0 && nCurCol<=nCols )
+ ((*pColumns)[nCurCol-1])->SetEndOfGroup();
+}
+
+void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nWidth, sal_Bool bRelWidth,
+ SvxAdjust eAdjust, SwVertOrient eVertOri )
+{
+ sal_uInt16 i;
+
+ if( !nSpan )
+ nSpan = 1;
+
+ sal_uInt16 nColsReq = nCurCol + nSpan; // benoetigte Spalten
+
+ if( nCols < nColsReq )
+ {
+ for( i=nCols; i<nColsReq; i++ )
+ pColumns->Insert( new HTMLTableColumn, pColumns->Count() );
+ nCols = nColsReq;
+ }
+
+ Size aTwipSz( bRelWidth ? 0 : nWidth, 0 );
+ if( aTwipSz.Width() && Application::GetDefaultDevice() )
+ {
+ aTwipSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
+ }
+
+ for( i=nCurCol; i<nColsReq; i++ )
+ {
+ HTMLTableColumn *pCol = (*pColumns)[i];
+ sal_uInt16 nTmp = bRelWidth ? nWidth : (sal_uInt16)aTwipSz.Width();
+ pCol->SetWidth( nTmp, bRelWidth );
+ pCol->SetAdjust( eAdjust );
+ pCol->SetVertOri( eVertOri );
+ }
+
+ bColSpec = sal_True;
+
+ nCurCol = nColsReq;
+}
+
+
+void HTMLTable::CloseTable()
+{
+ sal_uInt16 i;
+
+ // Die Anzahl der Tabellenzeilen richtet sich nur nach den
+ // <TR>-Elementen (d.h. nach nCurRow). Durch ROWSPAN aufgespannte
+ // Zeilen hinter Zeile nCurRow muessen wir deshalb loeschen
+ // und vor allem aber den ROWSPAN in den darueberliegenden Zeilen
+ // anpassen.
+ if( nRows>nCurRow )
+ {
+ HTMLTableRow *pPrevRow = (*pRows)[nCurRow-1];
+ HTMLTableCell *pCell;
+ for( i=0; i<nCols; i++ )
+ if( ( pCell=pPrevRow->GetCell(i), pCell->GetRowSpan() > 1 ) )
+ {
+ FixRowSpan( nCurRow-1, i, pCell->GetContents() );
+ ProtectRowSpan( nCurRow, i, (*pRows)[nCurRow]->GetCell(i)->GetRowSpan() );
+ }
+ for( i=nRows-1; i>=nCurRow; i-- )
+ pRows->DeleteAndDestroy(i);
+ nRows = nCurRow;
+ }
+
+ // falls die Tabelle keine Spalte hat, muessen wir eine hinzufuegen
+ if( 0==nCols )
+ {
+ pColumns->Insert( new HTMLTableColumn, pColumns->Count() );
+ for( i=0; i<nRows; i++ )
+ ((*pRows)[i])->Expand(1);
+ nCols = 1;
+ nFilledCols = 1;
+ }
+
+ // falls die Tabelle keine Zeile hat, muessen wir eine hinzufuegen
+ if( 0==nRows )
+ {
+ pRows->Insert( new HTMLTableRow(nCols), pRows->Count() );
+ nRows = 1;
+ nCurRow = 1;
+ }
+
+ if( nFilledCols < nCols )
+ {
+ pColumns->DeleteAndDestroy( nFilledCols, nCols-nFilledCols );
+ for( i=0; i<nRows; i++ )
+ ((*pRows)[i])->Shrink( nFilledCols );
+ nCols = nFilledCols;
+ }
+}
+
+void HTMLTable::_MakeTable( SwTableBox *pBox )
+{
+ SwTableLines& rLines = (pBox ? pBox->GetTabLines()
+ : ((SwTable *)pSwTable)->GetTabLines() );
+
+ // jetzt geht's richtig los ...
+ sal_uInt16 nStartRow = 0;
+
+ for( sal_uInt16 i=0; i<nRows; i++ )
+ {
+ // kann hinter der aktuellen HTML-Tabellen-Zeile gesplittet werden?
+ sal_Bool bSplit = sal_True;
+ HTMLTableRow *pRow = (*pRows)[i];
+ for( sal_uInt16 j=0; j<nCols; j++ )
+ {
+ bSplit = ( 1 == pRow->GetCell(j)->GetRowSpan() );
+ if( !bSplit )
+ break;
+ }
+
+ if( bSplit )
+ {
+ SwTableLine *pLine = MakeTableLine( pBox, nStartRow, 0, i+1, nCols );
+ if( pBox || nStartRow>0 )
+ {
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+ }
+ nStartRow = i+1;
+ }
+ }
+}
+
+/* Wie werden Tabellen ausgerichtet?
+
+erste Zeile: ohne Absatz-Einzuege
+zweite Zeile: mit Absatz-Einzuegen
+
+ALIGN= LEFT RIGHT CENTER -
+-------------------------------------------------------------------------
+xxx bei Tabellen mit WIDTH=nn% ist die Prozent-Angabe von Bedeutung:
+xxx nn = 100 HORI_FULL HORI_FULL HORI_FULL HORI_FULL %
+xxx HORI_NONE HORI_NONE HORI_NONE % HORI_NONE %
+xxx nn < 100 Rahmen F Rahmen F HORI_CENTER % HORI_LEFT %
+xxx Rahmen F Rahmen F HORI_CENTER % HORI_NONE %
+
+bei Tabellen mit WIDTH=nn% ist die Prozent-Angabe von Bedeutung:
+nn = 100 HORI_LEFT HORI_RIGHT HORI_CENTER % HORI_LEFT %
+ HORI_LEFT_AND HORI_RIGHT HORI_CENTER % HORI_LEFT_AND %
+nn < 100 Rahmen F Rahmen F HORI_CENTER % HORI_LEFT %
+ Rahmen F Rahmen F HORI_CENTER % HORI_NONE %
+
+sonst die berechnete Breite w
+w = avail* HORI_LEFT HORI_RIGHT HORI_CENTER HORI_LEFT
+ HORI_LEDT_AND HORI_RIGHT HORI_CENTER HORI_LEFT_AND
+w < avail Rahmen L Rahmen L HORI_CENTER HORI_LEFT
+ Rahmen L Rahmen L HORI_CENTER HORI_NONE
+
+xxx *) wenn fuer die Tabelle keine Groesse angegeben wurde, wird immer
+xxx HORI_FULL genommen
+
+*/
+
+void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail,
+ sal_uInt16 nRelAvail, sal_uInt16 nAbsLeftSpace,
+ sal_uInt16 nAbsRightSpace, sal_uInt16 nInhAbsSpace )
+{
+ ASSERT( nRows>0 && nCols>0 && nCurRow==nRows,
+ "Wurde CloseTable nicht aufgerufen?" );
+
+ ASSERT( (pLayoutInfo==0) == (this==pTopTable),
+ "Top-Tabelle hat keine Layout-Info oder umgekehrt" );
+
+ if( this==pTopTable )
+ {
+ // Umrandung der Tabelle und aller in ihr enthaltenen berechnen
+ SetBorders();
+
+ // Schritt 1: Die benoetigten Layout-Strukturen werden angelegt
+ // (inklusive Tabellen in Tabellen).
+ CreateLayoutInfo();
+
+ // Schritt 2: Die minimalen und maximalen Spaltenbreiten werden
+ // berechnet (inklusive Tabellen in Tabellen). Da wir noch keine
+ // Boxen haben, arabeiten wir noch auf den Start-Nodes.
+ pLayoutInfo->AutoLayoutPass1();
+ }
+
+ // Schritt 3: Die tatsaechlichen Spaltenbreiten dieser Tabelle werden
+ // berechnet (nicht von Tabellen in Tabellen). Dies muss jetzt schon
+ // sein, damit wir entscheiden koennen ob Filler-Zellen benoetigt werden
+ // oder nicht (deshalb war auch Pass1 schon noetig).
+ pLayoutInfo->AutoLayoutPass2( nAbsAvail, nRelAvail, nAbsLeftSpace,
+ nAbsRightSpace, nInhAbsSpace );
+
+ if( this!=pTopTable )
+ {
+ // die linke und rechte Umrandung der Tabelle kann jetzt entgueltig
+ // festgelegt werden
+ if( pLayoutInfo->GetRelRightFill() == 0 )
+ {
+ if( !bRightBorder )
+ {
+ // linke Umrandung von auesserer Tabelle uebernehmen
+ if( bInhRightBorder )
+ {
+ bRightBorder = sal_True;
+ aRightBorderLine = aInhRightBorderLine;
+ }
+ }
+ else
+ {
+ // Umrandung nur setzen, wenn es erlaubt ist
+ bRightBorder = bRightAlwd;
+ }
+ }
+
+ if( pLayoutInfo->GetRelLeftFill() == 0 &&
+ !((*pColumns)[0])->bLeftBorder &&
+ bInhLeftBorder )
+ {
+ // ggf. rechte Umrandung von auesserer Tabelle uebernehmen
+ ((*pColumns)[0])->bLeftBorder = sal_True;
+ aLeftBorderLine = aInhLeftBorderLine;
+ }
+ }
+
+ // Fuer die Top-Table muss die Ausrichtung gesetzt werden
+ if( this==pTopTable )
+ {
+ SwHoriOrient eHoriOri;
+ if( bForceFrame )
+ {
+ // Die Tabelle soll in einen Rahmen und ist auch schmaler
+ // als der verfuegbare Platz und nicht 100% breit.
+ // Dann kommt sie in einen Rahmen
+ eHoriOri = bPrcWidth ? HORI_FULL : HORI_LEFT;
+ }
+ else switch( eTableAdjust )
+ {
+ // Die Tabelle passt entweder auf die Seite, soll aber in keinen
+ // Rahmen oder sie ist Breiter als die Seite und soll deshalb
+ // in keinen Rahmen
+
+ case SVX_ADJUST_RIGHT:
+ // in rechtsbuendigen Tabellen kann nicht auf den rechten
+ // Rand Ruecksicht genommen werden
+ eHoriOri = HORI_RIGHT;
+ break;
+ case SVX_ADJUST_CENTER:
+ // zentrierte Tabellen nehmen keine Ruecksicht auf Raender!
+ eHoriOri = HORI_CENTER;
+ break;
+ case SVX_ADJUST_LEFT:
+ default:
+ // linksbuendige Tabellen nehmen nur auf den linken Rand
+ // Ruecksicht
+ eHoriOri = nLeftMargin ? HORI_LEFT_AND_WIDTH : HORI_LEFT;
+ break;
+ }
+
+ // das Tabellenform holen und anpassen
+ SwFrmFmt *pFrmFmt = pSwTable->GetFrmFmt();
+ pFrmFmt->SetAttr( SwFmtHoriOrient(0,eHoriOri) );
+ if( HORI_LEFT_AND_WIDTH==eHoriOri )
+ {
+ ASSERT( nLeftMargin || nRightMargin,
+ "Da gibt's wohl noch Reste von relativen Breiten" );
+
+ // The right margin will be ignored anyway.
+ SvxLRSpaceItem aLRItem( pSwTable->GetFrmFmt()->GetLRSpace() );
+ aLRItem.SetLeft( nLeftMargin );
+ aLRItem.SetRight( nRightMargin );
+ pFrmFmt->SetAttr( aLRItem );
+ }
+
+ if( bPrcWidth && HORI_FULL!=eHoriOri )
+ {
+ pFrmFmt->LockModify();
+ SwFmtFrmSize aFrmSize( pFrmFmt->GetFrmSize() );
+ aFrmSize.SetWidthPercent( (sal_uInt8)nWidth );
+ pFrmFmt->SetAttr( aFrmSize );
+ pFrmFmt->UnlockModify();
+ }
+ }
+
+ // die Default Line- und Box-Formate holen
+ if( this==pTopTable )
+ {
+ // die erste Box merken und aus der ersten Zeile ausketten
+ SwTableLine *pLine1 = (pSwTable->GetTabLines())[0];
+ pBox1 = (pLine1->GetTabBoxes())[0];
+ pLine1->GetTabBoxes().Remove(0);
+
+ pLineFmt = (SwTableLineFmt*)pLine1->GetFrmFmt();
+ pBoxFmt = (SwTableBoxFmt*)pBox1->GetFrmFmt();
+ }
+ else
+ {
+ pLineFmt = (SwTableLineFmt*)pTopTable->pLineFmt;
+ pBoxFmt = (SwTableBoxFmt*)pTopTable->pBoxFmt;
+ }
+
+ // ggf. muessen fuer Tabellen in Tabellen "Filler"-Zellen eingefuegt
+ // werden
+ if( this != pTopTable &&
+ ( pLayoutInfo->GetRelLeftFill() > 0 ||
+ pLayoutInfo->GetRelRightFill() > 0 ) )
+ {
+ ASSERT( pBox, "kein TableBox fuer Tabelle in Tabelle" );
+
+ SwTableLines& rLines = pBox->GetTabLines();
+
+ // dazu brauchen wir erstmal ein eine neue Table-Line in der Box
+ SwTableLine *pLine =
+ new SwTableLine( pLineFrmFmtNoHeight ? pLineFrmFmtNoHeight
+ : pLineFmt, 0, pBox );
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+
+ // Sicherstellen, dass wie ein Format ohne Hoehe erwischt haben
+ if( !pLineFrmFmtNoHeight )
+ {
+ // sonst muessen wir die Hoehe aus dem Attribut entfernen
+ // und koennen uns das Format merken
+ pLineFrmFmtNoHeight = (SwTableLineFmt*)pLine->ClaimFrmFmt();
+
+ ResetLineFrmFmtAttrs( pLineFrmFmtNoHeight );
+ }
+
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ SwTableBox *pNewBox;
+
+ // ggf. links eine Zelle einfuegen
+ if( pLayoutInfo->GetRelLeftFill() > 0 )
+ {
+ // pPrevStNd ist der Vorgaenger-Start-Node der Tabelle. Den
+ // "Filler"-Node fuegen wir einfach dahinter ein ...
+ pPrevStNd = pParser->InsertTableSection( pPrevStNd );
+
+ pNewBox = NewTableBox( pPrevStNd, pLine );
+ rBoxes.C40_INSERT( SwTableBox, pNewBox, rBoxes.Count() );
+ FixFillerFrameFmt( pNewBox, sal_False );
+ pLayoutInfo->SetLeftFillerBox( pNewBox );
+ }
+
+ // jetzt die Tabelle bearbeiten
+ pNewBox = new SwTableBox( pBoxFmt, 0, pLine );
+ rBoxes.C40_INSERT( SwTableBox, pNewBox, rBoxes.Count() );
+
+ SwFrmFmt *pFrmFmt = pNewBox->ClaimFrmFmt();
+ pFrmFmt->ResetAttr( RES_BOX );
+ pFrmFmt->ResetAttr( RES_BACKGROUND );
+ pFrmFmt->ResetAttr( RES_VERT_ORIENT );
+ pFrmFmt->ResetAttr( RES_BOXATR_FORMAT );
+
+
+ _MakeTable( pNewBox );
+
+ // und noch ggf. rechts eine Zelle einfuegen
+ if( pLayoutInfo->GetRelRightFill() > 0 )
+ {
+ const SwStartNode *pStNd =
+ GetPrevBoxStartNode( USHRT_MAX, USHRT_MAX );
+ pStNd = pParser->InsertTableSection( pStNd );
+
+ pNewBox = NewTableBox( pStNd, pLine );
+ rBoxes.C40_INSERT( SwTableBox, pNewBox, rBoxes.Count() );
+
+ FixFillerFrameFmt( pNewBox, sal_True );
+ pLayoutInfo->SetRightFillerBox( pNewBox );
+ }
+ }
+ else
+ {
+ _MakeTable( pBox );
+ }
+
+ // zum Schluss fuehren wir noch eine Garbage-Collection fuer die
+ // Top-Level-Tabelle durch
+ if( this==pTopTable )
+ {
+ if( 1==nRows && nHeight && 1==pSwTable->GetTabLines().Count() )
+ {
+ // Hoehe einer einzeiligen Tabelle als Mindesthoehe der
+ // Zeile setzen. (War mal fixe Hoehe, aber das gibt manchmal
+ // Probleme (fix #34972#) und ist auch nicht Netscape 4.0
+ // konform
+ nHeight = pParser->ToTwips( nHeight );
+ if( nHeight < MINLAY )
+ nHeight = MINLAY;
+
+ (pSwTable->GetTabLines())[0]->ClaimFrmFmt();
+ (pSwTable->GetTabLines())[0]->GetFrmFmt()
+ ->SetAttr( SwFmtFrmSize( ATT_MIN_SIZE, 0, nHeight ) );
+ }
+
+ if( GetBGBrush() )
+ pSwTable->GetFrmFmt()->SetAttr( *GetBGBrush() );
+
+ ((SwTable *)pSwTable)->SetHeadlineRepeat( bHeadlineRepeat );
+ ((SwTable *)pSwTable)->GCLines();
+
+ sal_Bool bIsInFlyFrame = pContext && pContext->GetFrmFmt();
+ if( bIsInFlyFrame && !nWidth )
+ {
+ SvxAdjust eTblAdjust = GetTableAdjust(sal_False);
+ if( eTblAdjust != SVX_ADJUST_LEFT &&
+ eTblAdjust != SVX_ADJUST_RIGHT )
+ {
+ // Wenn eine Tabelle ohne Breitenangabe nicht links oder
+ // rechts umflossen werden soll, dann stacken wir sie
+ // in einem Rahmen mit 100%-Breite, damit ihre Groesse
+ // angepasst wird. Der Rahmen darf nicht angepasst werden.
+ ASSERT( HasToFly(), "Warum ist die Tabelle in einem Rahmen?" );
+ sal_uInt32 nMin = pLayoutInfo->GetMin();
+ if( nMin > USHRT_MAX )
+ nMin = USHRT_MAX;
+ SwFmtFrmSize aFlyFrmSize( ATT_VAR_SIZE, (SwTwips)nMin, MINLAY );
+ aFlyFrmSize.SetWidthPercent( 100 );
+ pContext->GetFrmFmt()->SetAttr( aFlyFrmSize );
+ bIsInFlyFrame = sal_False;
+ }
+ else
+ {
+ // Links und rechts ausgerichtete Tabellen ohne Breite
+ // duerfen leider nicht in der Breite angepasst werden, denn
+ // sie wuerden nur schrumpfen aber nie wachsen.
+ pLayoutInfo->SetMustNotRecalc( sal_True );
+ if( pContext->GetFrmFmt()->GetAnchor().GetCntntAnchor()
+ ->nNode.GetNode().FindTableNode() )
+ {
+ sal_uInt32 nMax = pLayoutInfo->GetMax();
+ if( nMax > USHRT_MAX )
+ nMax = USHRT_MAX;
+ SwFmtFrmSize aFlyFrmSize( ATT_VAR_SIZE, (SwTwips)nMax, MINLAY );
+ pContext->GetFrmFmt()->SetAttr( aFlyFrmSize );
+ bIsInFlyFrame = sal_False;
+ }
+ else
+ {
+ pLayoutInfo->SetMustNotResize( sal_True );
+ }
+ }
+ }
+ pLayoutInfo->SetMayBeInFlyFrame( bIsInFlyFrame );
+
+ // Nur Tabellen mit relativer Breite oder ohne Breite muessen
+ // angepasst werden.
+ pLayoutInfo->SetMustResize( bPrcWidth || !nWidth );
+
+ pLayoutInfo->SetWidths();
+
+ ((SwTable *)pSwTable)->SetHTMLTableLayout( pLayoutInfo );
+
+ if( pResizeDrawObjs )
+ {
+ sal_uInt16 nCount = pResizeDrawObjs->Count();
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SdrObject *pObj = (*pResizeDrawObjs)[i];
+ sal_uInt16 nRow = (*pDrawObjPrcWidths)[3*i];
+ sal_uInt16 nCol = (*pDrawObjPrcWidths)[3*i+1];
+ sal_uInt8 nPrcWidth = (sal_uInt8)(*pDrawObjPrcWidths)[3*i+2];
+
+ SwHTMLTableLayoutCell *pLayoutCell =
+ pLayoutInfo->GetCell( nRow, nCol );
+ sal_uInt16 nColSpan = pLayoutCell->GetColSpan();
+
+ sal_uInt16 nWidth, nDummy;
+ pLayoutInfo->GetAvail( nCol, nColSpan, nWidth, nDummy );
+ nWidth -= pLayoutInfo->GetLeftCellSpace( nCol, nColSpan );
+ nWidth -= pLayoutInfo->GetRightCellSpace( nCol, nColSpan );
+ nWidth = ((long)nWidth * nPrcWidth) / 100;
+
+ pParser->ResizeDrawObject( pObj, nWidth );
+ }
+ }
+ }
+}
+
+void HTMLTable::SetTable( const SwStartNode *pStNd, _HTMLTableContext *pCntxt,
+ sal_uInt16 nLeft, sal_uInt16 nRight,
+ const SwTable *pSwTab, sal_Bool bFrcFrame )
+{
+ pPrevStNd = pStNd;
+ pSwTable = pSwTab;
+ pContext = pCntxt;
+
+ nLeftMargin = nLeft;
+ nRightMargin = nRight;
+
+ bForceFrame = bFrcFrame;
+}
+
+void HTMLTable::RegisterDrawObject( SdrObject *pObj, sal_uInt8 nPrcWidth )
+{
+ if( !pResizeDrawObjs )
+ pResizeDrawObjs = new SdrObjects;
+ pResizeDrawObjs->C40_INSERT( SdrObject, pObj, pResizeDrawObjs->Count() );
+
+ if( !pDrawObjPrcWidths )
+ pDrawObjPrcWidths = new SvUShorts;
+ pDrawObjPrcWidths->Insert( nCurRow, pDrawObjPrcWidths->Count() );
+ pDrawObjPrcWidths->Insert( nCurCol, pDrawObjPrcWidths->Count() );
+ pDrawObjPrcWidths->Insert( (sal_uInt16)nPrcWidth, pDrawObjPrcWidths->Count() );
+}
+
+void HTMLTable::MakeParentContents()
+{
+ if( !GetContext() && !HasParentSection() )
+ {
+ SetParentContents(
+ pParser->InsertTableContents( GetIsParentHeader() ) );
+
+ SetHasParentSection( sal_True );
+ }
+}
+
+_HTMLTableContext::~_HTMLTableContext()
+{
+ delete pPos;
+}
+
+void _HTMLTableContext::SavePREListingXMP( SwHTMLParser& rParser )
+{
+ bRestartPRE = rParser.IsReadPRE();
+ bRestartXMP = rParser.IsReadXMP();
+ bRestartListing = rParser.IsReadListing();
+ rParser.FinishPREListingXMP();
+}
+
+void _HTMLTableContext::RestorePREListingXMP( SwHTMLParser& rParser )
+{
+ rParser.FinishPREListingXMP();
+
+ if( bRestartPRE )
+ rParser.StartPRE();
+
+ if( bRestartXMP )
+ rParser.StartXMP();
+
+ if( bRestartListing )
+ rParser.StartListing();
+}
+
+/* */
+
+const SwStartNode *SwHTMLParser::InsertTableSection
+ ( const SwStartNode *pPrevStNd )
+{
+ ASSERT( pPrevStNd, "Start-Node ist NULL" );
+
+ pCSS1Parser->SetTDTagStyles();
+ SwTxtFmtColl *pColl = pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_TABLE );
+
+ const SwStartNode *pStNd;
+ if( pTable && pTable->bFirstCell )
+ {
+ SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode];
+ pNd->GetTxtNode()->ChgFmtColl( pColl );
+ pStNd = pNd->FindTableBoxStartNode();
+ pTable->bFirstCell = sal_False;
+ }
+ else
+ {
+ const SwNode* pNd;
+ if( pPrevStNd->IsTableNode() )
+ pNd = pPrevStNd;
+ else
+ pNd = pPrevStNd->EndOfSectionNode();
+ SwNodeIndex nIdx( *pNd, 1 );
+ pStNd = pDoc->GetNodes().MakeTextSection( nIdx, SwTableBoxStartNode,
+ pColl );
+ pTable->IncBoxCount();
+ }
+
+ pDoc->GetNodes()[pStNd->GetIndex()+1]
+ ->GetCntntNode()->SetAttr( SvxFontHeightItem(40) );
+
+ return pStNd;
+}
+
+const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
+{
+ switch( nPoolId )
+ {
+ case RES_POOLCOLL_TABLE_HDLN:
+ pCSS1Parser->SetTHTagStyles();
+ break;
+ case RES_POOLCOLL_TABLE:
+ pCSS1Parser->SetTDTagStyles();
+ break;
+ }
+
+ SwTxtFmtColl *pColl = pCSS1Parser->GetTxtCollFromPool( nPoolId );
+
+ SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode];
+ const SwStartNode *pStNd;
+ if( pTable && pTable->bFirstCell )
+ {
+ pNd->GetTxtNode()->ChgFmtColl( pColl );
+ pTable->bFirstCell = sal_False;
+ pStNd = pNd->FindTableBoxStartNode();
+ }
+ else
+ {
+ SwTableNode *pTblNd = pNd->FindTableNode();
+ SwNodeIndex aIdx( *pTblNd->EndOfSectionNode() );
+ pStNd = pDoc->GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pColl );
+
+ pPam->GetPoint()->nNode = pStNd->GetIndex() + 1;
+ SwTxtNode *pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode();
+ pPam->GetPoint()->nContent.Assign( pTxtNd, 0 );
+ pTable->IncBoxCount();
+ }
+
+ return pStNd;
+}
+
+const SwStartNode *SwHTMLParser::InsertEmptyTableSection()
+{
+ ASSERT( !pTable || !pTable->bFirstCell,
+ "erste Zelle der Tabelle nicht genutzt" );
+
+ const SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode];
+ const SwTableNode *pTblNd = pNd->FindTableNode();
+ pTable->IncBoxCount();
+
+ return pDoc->GetNodes().MakeEmptySection(
+ SwNodeIndex( *pTblNd->EndOfSectionNode() ), SwTableBoxStartNode );
+}
+
+SwStartNode *SwHTMLParser::InsertTempTableCaptionSection()
+{
+ SwTxtFmtColl *pColl = pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_TEXT );
+ SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
+ rIdx = pDoc->GetNodes().GetEndOfExtras();
+ SwStartNode *pStNd = pDoc->GetNodes().MakeTextSection( rIdx,
+ SwNormalStartNode, pColl );
+
+ rIdx = pStNd->GetIndex() + 1;
+ pPam->GetPoint()->nContent.Assign( rIdx.GetNode().GetTxtNode(), 0 );
+
+ return pStNd;
+}
+
+
+xub_StrLen SwHTMLParser::StripTrailingLF()
+{
+ xub_StrLen nStripped = 0;
+
+ xub_StrLen nLen = pPam->GetPoint()->nContent.GetIndex();
+ if( nLen )
+ {
+ SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode();
+ // vorsicht, wenn Kommentare nicht uebrlesen werden!!!
+ if( pTxtNd )
+ {
+ xub_StrLen nPos = nLen;
+ xub_StrLen nLFCount = 0;
+ while( nPos && '\x0a' == (pTxtNd->GetTxt()).GetChar(--nPos) )
+ nLFCount++;
+
+ if( nLFCount )
+ {
+// MIB 6.6.97: Warum sollte man bei leeren Absaetzen nur ein LF loeschen?
+// Das stimmt doch irgendwi nicht ...
+// if( nLFCount == nLen )
+// {
+// // nur Lfs, dann nur ein LF loeschen
+// nLFCount = 1;
+// }
+// else if( nLFCount > 2 )
+ if( nLFCount > 2 )
+ {
+ // Bei Netscape entspricht ein Absatz-Ende zwei LFs
+ // (mit einem kommt man in die naechste Zeile, das
+ // zweite erzeugt eine Leerzeile) Diesen Abstand
+ // erreichen wie aber schon mit dem unteren
+ // Absatz-Abstand. Wenn nach den <BR> ein neuer
+ // Absatz aufgemacht wird, wird das Maximum des Abstands,
+ // der sich aus den BR und dem P ergibt genommen.
+ // Deshalb muessen wir 2 bzw. alle bei weniger
+ // als zweien loeschen
+ nLFCount = 2;
+ }
+
+ nPos = nLen - nLFCount;
+ SwIndex nIdx( pTxtNd, nPos );
+ pTxtNd->Erase( nIdx, nLFCount );
+ nStripped = nLFCount;
+ }
+ }
+ }
+
+ return nStripped;
+}
+
+SvxBrushItem* SwHTMLParser::CreateBrushItem( const Color *pColor,
+ const String& rImageURL,
+ const String& rStyle,
+ const String& rId,
+ const String& rClass )
+{
+ SvxBrushItem *pBrushItem = 0;
+
+ if( rStyle.Len() || rId.Len() || rClass.Len() )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_BACKGROUND,
+ RES_BACKGROUND );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( rClass.Len() )
+ {
+ SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( rClass );
+ if( pClass )
+ aItemSet.Put( pClass->GetItemSet() );
+ }
+
+ if( rId.Len() )
+ {
+ SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
+ if( pId )
+ aItemSet.Put( pId->GetItemSet() );
+ }
+
+ pCSS1Parser->ParseStyleOption( rStyle, aItemSet, aPropInfo );
+ const SfxPoolItem *pItem = 0;
+ if( SFX_ITEM_SET == aItemSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ pBrushItem = new SvxBrushItem( *((const SvxBrushItem *)pItem) );
+ }
+ }
+
+ if( !pBrushItem && (pColor || rImageURL.Len()) )
+ {
+ pBrushItem = new SvxBrushItem();
+
+ if( pColor )
+ pBrushItem->SetColor(*pColor);
+
+ if( rImageURL.Len() )
+ {
+ pBrushItem->SetGraphicLink( INetURLObject::RelToAbs(rImageURL) );
+ pBrushItem->SetGraphicPos( GPOS_TILED );
+ }
+ }
+
+ return pBrushItem;
+}
+
+/* */
+
+class _SectionSaveStruct : public SwPendingStackData
+{
+ sal_uInt16 nBaseFontStMinSave, nFontStMinSave, nFontStHeadStartSave;
+ sal_uInt16 nDefListDeepSave, nContextStMinSave, nContextStAttrMinSave;
+
+public:
+
+ HTMLTable *pTable;
+
+ _SectionSaveStruct( SwHTMLParser& rParser );
+ virtual ~_SectionSaveStruct();
+
+ sal_uInt16 GetContextStAttrMin() const { return nContextStAttrMinSave; }
+
+ void Restore( SwHTMLParser& rParser );
+};
+
+_SectionSaveStruct::_SectionSaveStruct( SwHTMLParser& rParser ) :
+ nBaseFontStMinSave(0), nFontStMinSave(0), nFontStHeadStartSave(0),
+ nDefListDeepSave(0), nContextStMinSave(0), nContextStAttrMinSave(0),
+ pTable( 0 )
+{
+ // Font-Stacks einfrieren
+ nBaseFontStMinSave = rParser.nBaseFontStMin;
+ rParser.nBaseFontStMin = rParser.aBaseFontStack.Count();
+
+ nFontStMinSave = rParser.nFontStMin;
+ nFontStHeadStartSave = rParser.nFontStHeadStart;
+ rParser.nFontStMin = rParser.aFontStack.Count();
+
+ // Kontext-Stack einfrieren
+ nContextStMinSave = rParser.nContextStMin;
+ nContextStAttrMinSave = rParser.nContextStAttrMin;
+ rParser.nContextStMin = rParser.aContexts.Count();
+ rParser.nContextStAttrMin = rParser.nContextStMin;
+
+ // und noch ein par Zaehler retten
+ nDefListDeepSave = rParser.nDefListDeep;
+ rParser.nDefListDeep = 0;
+}
+
+_SectionSaveStruct::~_SectionSaveStruct()
+{}
+
+void _SectionSaveStruct::Restore( SwHTMLParser& rParser )
+{
+ // Font-Stacks wieder auftauen
+ sal_uInt16 nMin = rParser.nBaseFontStMin;
+ if( rParser.aBaseFontStack.Count() > nMin )
+ rParser.aBaseFontStack.Remove( nMin,
+ rParser.aBaseFontStack.Count() - nMin );
+ rParser.nBaseFontStMin = nBaseFontStMinSave;
+
+
+ nMin = rParser.nFontStMin;
+ if( rParser.aFontStack.Count() > nMin )
+ rParser.aFontStack.Remove( nMin,
+ rParser.aFontStack.Count() - nMin );
+ rParser.nFontStMin = nFontStMinSave;
+ rParser.nFontStHeadStart = nFontStHeadStartSave;
+
+ // Der Kontext-Stack muss schon aufgeraeumt sein!
+ ASSERT( rParser.aContexts.Count() == rParser.nContextStMin &&
+ rParser.aContexts.Count() == rParser.nContextStAttrMin,
+ "Der Kontext-Stack wurde nicht aufgeraeumt" );
+ rParser.nContextStMin = nContextStMinSave;
+ rParser.nContextStAttrMin = nContextStAttrMinSave;
+
+ // und noch ein par Zaehler rekonstruieren
+ rParser.nDefListDeep = nDefListDeepSave;
+
+ // und ein par Flags zuruecksetzen
+ rParser.bNoParSpace = sal_False;
+ rParser.nOpenParaToken = 0;
+
+ if( rParser.aParaAttrs.Count() )
+ rParser.aParaAttrs.Remove( 0, rParser.aParaAttrs.Count() );
+}
+
+/* */
+
+class _CellSaveStruct : public _SectionSaveStruct
+{
+ String aStyle, aId, aClass;
+ String aBGImage;
+ Color aBGColor;
+
+ HTMLTableCnts* pCnts; // Liste aller Inhalte
+ HTMLTableCnts* pCurrCnts; // der aktuelle Inhalt oder 0
+ SwNodeIndex *pNoBreakEndParaIdx;// Absatz-Index eines </NOBR>
+
+ double nValue;
+
+ sal_uInt32 nNumFmt;
+
+ sal_uInt16 nRowSpan, nColSpan, nWidth, nHeight;
+ xub_StrLen nNoBreakEndCntntPos; // Zeichen-Index eines </NOBR>
+
+ SvxAdjust eAdjust;
+ SwVertOrient eVertOri;
+
+ sal_Bool bHead : 1;
+ sal_Bool bPrcWidth : 1;
+ sal_Bool bHasNumFmt : 1;
+ sal_Bool bHasValue : 1;
+ sal_Bool bBGColor : 1;
+ sal_Bool bNoWrap : 1; // NOWRAP-Option
+ sal_Bool bNoBreak : 1; // NOBREAK-Tag
+
+public:
+
+ _CellSaveStruct( SwHTMLParser& rParser, HTMLTable *pCurTable, sal_Bool bHd,
+ sal_Bool bReadOpt );
+
+ virtual ~_CellSaveStruct();
+
+ void AddContents( HTMLTableCnts *pNewCnts );
+ HTMLTableCnts *GetFirstContents() { return pCnts; }
+
+ void ClearIsInSection() { pCurrCnts = 0; }
+ sal_Bool IsInSection() const { return pCurrCnts!=0; }
+ HTMLTableCnts *GetCurrContents() const { return pCurrCnts; }
+
+ void InsertCell( SwHTMLParser& rParser, HTMLTable *pCurTable );
+
+ sal_Bool IsHeaderCell() const { return bHead; }
+
+ void StartNoBreak( const SwPosition& rPos );
+ void EndNoBreak( const SwPosition& rPos );
+ void CheckNoBreak( const SwPosition& rPos, SwDoc *pDoc );
+};
+
+
+_CellSaveStruct::_CellSaveStruct( SwHTMLParser& rParser, HTMLTable *pCurTable,
+ sal_Bool bHd, sal_Bool bReadOpt ) :
+ _SectionSaveStruct( rParser ),
+ pCnts( 0 ), pCurrCnts( 0 ), pNoBreakEndParaIdx( 0 ),
+ nValue( 0.0 ),
+ nNumFmt( 0 ),
+ nRowSpan( 1 ), nColSpan( 1 ), nWidth( 0 ), nHeight( 0 ),
+ nNoBreakEndCntntPos( 0 ),
+ eAdjust( pCurTable->GetInheritedAdjust() ),
+ bHead( bHd ),
+ eVertOri( pCurTable->GetInheritedVertOri() ),
+ bPrcWidth( sal_False ), bBGColor( sal_False ),
+ bHasNumFmt( sal_False ), bHasValue( sal_False ),
+ bNoWrap( sal_False ), bNoBreak( sal_False )
+{
+ String aNumFmt, aValue;
+
+ if( bReadOpt )
+ {
+ const HTMLOptions *pOptions = rParser.GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_COLSPAN:
+ nColSpan = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_ROWSPAN:
+ nRowSpan = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_ALIGN:
+ eAdjust = (SvxAdjust)pOption->GetEnum(
+ aHTMLPAlignTable, eAdjust );
+ break;
+ case HTML_O_VALIGN:
+ eVertOri = (SwVertOrient)pOption->GetEnum(
+ aHTMLTblVAlignTable, eVertOri );
+ break;
+ case HTML_O_WIDTH:
+ nWidth = (sal_uInt16)pOption->GetNumber(); // nur fuer Netscape
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ if( bPrcWidth && nWidth>100 )
+ nWidth = 100;
+ break;
+ case HTML_O_HEIGHT:
+ nHeight = (sal_uInt16)pOption->GetNumber(); // nur fuer Netscape
+ if( pOption->GetString().Search('%') != STRING_NOTFOUND)
+ nHeight = 0; // keine %-Angaben beruecksichtigen
+ break;
+ case HTML_O_BGCOLOR:
+ // Leere BGCOLOR bei <TABLE>, <TR> und <TD>/<TH> wie Netscape
+ // ignorieren, bei allen anderen Tags *wirklich* nicht.
+ if( pOption->GetString().Len() )
+ {
+ pOption->GetColor( aBGColor );
+ bBGColor = sal_True;
+ }
+ break;
+ case HTML_O_BACKGROUND:
+ aBGImage = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_SDNUM:
+ aNumFmt = pOption->GetString();
+ bHasNumFmt = sal_True;
+ break;
+ case HTML_O_SDVAL:
+ bHasValue = sal_True;
+ aValue = pOption->GetString();
+ break;
+ case HTML_O_NOWRAP:
+ bNoWrap = sal_True;
+ break;
+ }
+ }
+
+ if( aId.Len() )
+ rParser.InsertBookmark( aId );
+ }
+
+ if( bHasNumFmt )
+ {
+ LanguageType eLang;
+ nValue = rParser.GetTableDataOptionsValNum(
+ nNumFmt, eLang, aValue, aNumFmt,
+ *rParser.pDoc->GetNumberFormatter() );
+ }
+
+ // einen neuen Kontext anlegen, aber das ::com::sun::star::drawing::Alignment-Attribut
+ // nicht dort verankern, weil es noch ger keine Section gibt, in der
+ // es gibt.
+ sal_uInt16 nToken, nColl;
+ if( bHead )
+ {
+ nToken = HTML_TABLEHEADER_ON;
+ nColl = RES_POOLCOLL_TABLE_HDLN;
+ }
+ else
+ {
+ nToken = HTML_TABLEDATA_ON;
+ nColl = RES_POOLCOLL_TABLE;
+ }
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken, nColl, aEmptyStr, sal_True );
+ if( SVX_ADJUST_END != eAdjust )
+ rParser.InsertAttr( &rParser.aAttrTab.pAdjust, SvxAdjustItem(eAdjust),
+ pCntxt );
+
+ if( rParser.HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( rParser.pDoc->GetAttrPool(),
+ rParser.pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( rParser.ParseStyleOptions( aStyle, aId, aClass, aItemSet,
+ aPropInfo ) )
+ rParser.InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+
+ rParser.SplitPREListingXMP( pCntxt );
+
+ rParser.PushContext( pCntxt );
+}
+
+_CellSaveStruct::~_CellSaveStruct()
+{
+ delete pNoBreakEndParaIdx;
+}
+
+void _CellSaveStruct::AddContents( HTMLTableCnts *pNewCnts )
+{
+ if( pCnts )
+ pCnts->Add( pNewCnts );
+ else
+ pCnts = pNewCnts;
+
+ pCurrCnts = pNewCnts;
+}
+
+void _CellSaveStruct::InsertCell( SwHTMLParser& rParser,
+ HTMLTable *pCurTable )
+{
+#ifndef PRODUCT
+ // Die Attribute muessen schon beim Auefrauemen des Kontext-Stacks
+ // entfernt worden sein, sonst ist etwas schiefgelaufen. Das
+ // Checken wir mal eben ...
+ // MIB 8.1.98: Wenn ausserhalb einer Zelle Attribute geoeffnet
+ // wurden stehen diese noch in der Attribut-Tabelle und werden erst
+ // ganz zum Schluss durch die CleanContext-Aufrufe in BuildTable
+ // geloescht. Damit es in diesem Fall keine Asserts gibt findet dann
+ // keine Ueberpruefung statt. Erkennen tut man diesen Fall an
+ // nContextStAttrMin: Der gemerkte Wert nContextStAttrMinSave ist der
+ // Wert, den nContextStAttrMin beim Start der Tabelle hatte. Und
+ // der aktuelle Wert von nContextStAttrMin entspricht der Anzahl der
+ // Kontexte, die beim Start der Zelle vorgefunden wurden. Sind beide
+ // Werte unterschiedlich, wurden ausserhalb der Zelle Kontexte
+ // angelegt und wir ueberpruefen nichts.
+
+ if( rParser.nContextStAttrMin == GetContextStAttrMin() )
+ {
+ _HTMLAttr** pTbl = (_HTMLAttr**)&rParser.aAttrTab;
+
+ for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; ++pTbl )
+ {
+ ASSERT( !*pTbl, "Die Attribut-Tabelle ist nicht leer" );
+ }
+ }
+#endif
+
+ // jetzt muessen wir noch die Zelle an der aktuellen Position einfuegen
+ SvxBrushItem *pBrushItem =
+ rParser.CreateBrushItem( bBGColor ? &aBGColor : 0, aBGImage,
+ aStyle, aId, aClass );
+ pCurTable->InsertCell( pCnts, nRowSpan, nColSpan, nWidth,
+ bPrcWidth, nHeight, eVertOri, pBrushItem,
+ bHasNumFmt, nNumFmt, bHasValue, nValue,
+ bNoWrap );
+ Restore( rParser );
+}
+
+void _CellSaveStruct::StartNoBreak( const SwPosition& rPos )
+{
+ if( !pCnts ||
+ (!rPos.nContent.GetIndex() && pCurrCnts==pCnts &&
+ pCnts->GetStartNode() &&
+ pCnts->GetStartNode()->GetIndex() + 1 ==
+ rPos.nNode.GetIndex()) )
+ {
+ bNoBreak = sal_True;
+ }
+}
+
+void _CellSaveStruct::EndNoBreak( const SwPosition& rPos )
+{
+ if( bNoBreak )
+ {
+ delete pNoBreakEndParaIdx;
+ pNoBreakEndParaIdx = new SwNodeIndex( rPos.nNode );
+ nNoBreakEndCntntPos = rPos.nContent.GetIndex();
+ bNoBreak = sal_False;
+ }
+}
+
+void _CellSaveStruct::CheckNoBreak( const SwPosition& rPos, SwDoc *pDoc )
+{
+ if( pCnts && pCurrCnts==pCnts )
+ {
+ if( bNoBreak )
+ {
+ // <NOBR> wurde nicht beendet
+ pCnts->SetNoBreak();
+ }
+ else if( pNoBreakEndParaIdx &&
+ pNoBreakEndParaIdx->GetIndex() == rPos.nNode.GetIndex() )
+ {
+ if( nNoBreakEndCntntPos == rPos.nContent.GetIndex() )
+ {
+ // <NOBR> wurde unmittelbar vor dem Zellen-Ende beendet
+ pCnts->SetNoBreak();
+ }
+ else if( nNoBreakEndCntntPos + 1 == rPos.nContent.GetIndex() )
+ {
+ const SwTxtNode *pTxtNd =
+ pDoc->GetNodes()[rPos.nNode]->GetTxtNode();
+ if( pTxtNd )
+ {
+ register sal_Unicode cLast =
+ pTxtNd->GetTxt().GetChar(nNoBreakEndCntntPos);
+ if( ' '==cLast || '\x0a'==cLast )
+ {
+ // Zwischem dem </NOBR> und dem Zellen-Ende gibt es nur
+ // ein Blank oder einen Zeilenumbruch.
+ pCnts->SetNoBreak();
+ }
+ }
+ }
+ }
+ }
+}
+
+
+
+HTMLTableCnts *SwHTMLParser::InsertTableContents(
+ sal_Bool bHead )
+{
+ // eine neue Section anlegen, der PaM steht dann darin
+ const SwStartNode *pStNd =
+ InsertTableSection( bHead ? RES_POOLCOLL_TABLE_HDLN
+ : RES_POOLCOLL_TABLE );
+
+ if( GetNumInfo().GetNumRule() )
+ {
+ // 1. Absatz auf nicht numeriert setzen
+ SetNodeNum( GetNumInfo().GetLevel() | NO_NUMLEVEL );
+ }
+
+ // Attributierungs-Anfang neu setzen
+ const SwNodeIndex& rSttPara = pPam->GetPoint()->nNode;
+ xub_StrLen nSttCnt = pPam->GetPoint()->nContent.GetIndex();
+
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; ++pTbl )
+ {
+
+ _HTMLAttr *pAttr = *pTbl;
+ while( pAttr )
+ {
+ ASSERT( !pAttr->GetPrev(), "Attribut hat Previous-Liste" );
+ pAttr->nSttPara = rSttPara;
+ pAttr->nEndPara = rSttPara;
+ pAttr->nSttCntnt = nSttCnt;
+ pAttr->nEndCntnt = nSttCnt;
+
+ pAttr = pAttr->GetNext();
+ }
+ }
+
+ return new HTMLTableCnts( pStNd );
+}
+
+sal_uInt16 SwHTMLParser::IncGrfsThatResizeTable()
+{
+ return pTable ? pTable->IncGrfsThatResize() : 0;
+}
+
+void SwHTMLParser::RegisterDrawObjectToTable( HTMLTable *pCurTable,
+ SdrObject *pObj, sal_uInt8 nPrcWidth )
+{
+ pCurTable->RegisterDrawObject( pObj, nPrcWidth );
+}
+
+void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions,
+ sal_Bool bHead )
+{
+ if( !IsParserWorking() && !pPendStack )
+ return;
+
+ _CellSaveStruct* pSaveStruct;
+
+ int nToken = 0;
+ sal_Bool bPending = sal_False;
+ if( pPendStack )
+ {
+ pSaveStruct = (_CellSaveStruct*)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ nToken = pPendStack ? pPendStack->nToken : GetSaveToken();
+ bPending = SVPAR_ERROR == eState && pPendStack != 0;
+
+ SaveState( nToken );
+ }
+ else
+ {
+ // <TH> bzw. <TD> wurde bereits gelesen
+ if( pTable->IsOverflowing() )
+ {
+ SaveState( 0 );
+ return;
+ }
+
+ if( !pCurTable->GetContext() )
+ {
+// MIB: 5.9.2000: Do we need this any longer?
+// bIsWriterDoc = sal_True;
+ sal_Bool bTopTable = pTable==pCurTable;
+
+ // die Tabelle besitzt noch keinen Inhalt, d.h. die eigentliche
+ // Tabelle muss erst noch angelegt werden
+
+ String aStyle, aId, aClass;
+ static sal_uInt16 aWhichIds[] =
+ {
+ RES_PARATR_SPLIT, RES_PARATR_SPLIT,
+ RES_PAGEDESC, RES_PAGEDESC,
+ RES_BREAK, RES_BREAK,
+ RES_BACKGROUND, RES_BACKGROUND,
+ RES_KEEP, RES_KEEP,
+ RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
+ 0
+ };
+
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), aWhichIds );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ sal_Bool bStyleParsed = ParseStyleOptions( pCurTable->GetStyle(),
+ pCurTable->GetId(),
+ pCurTable->GetClass(),
+ aItemSet, aPropInfo );
+ const SfxPoolItem *pItem = 0;
+ if( bStyleParsed )
+ {
+ if( SFX_ITEM_SET == aItemSet.GetItemState(
+ RES_BACKGROUND, sal_False, &pItem ) )
+ {
+ pCurTable->SetBGBrush( *(const SvxBrushItem *)pItem );
+ aItemSet.ClearItem( RES_BACKGROUND );
+ }
+ if( SFX_ITEM_SET == aItemSet.GetItemState(
+ RES_PARATR_SPLIT, sal_False, &pItem ) )
+ {
+ aItemSet.Put(
+ SwFmtLayoutSplit( ((const SvxFmtSplitItem *)pItem)
+ ->GetValue() ) );
+ aItemSet.ClearItem( RES_PARATR_SPLIT );
+ }
+ }
+
+ // Den linken/rechten Absatzeinzug ermitteln
+ sal_uInt16 nLeftSpace = 0;
+ sal_uInt16 nRightSpace = 0;
+ short nIndent;
+ GetMarginsFromContextWithNumBul( nLeftSpace, nRightSpace, nIndent );
+
+ // die aktuelle Position an die wir irgendwann zurueckkehren
+ SwPosition *pSavePos = 0;
+ sal_Bool bForceFrame = sal_False;
+ sal_Bool bAppended = sal_False;
+ sal_Bool bParentLFStripped = sal_False;
+ if( bTopTable )
+ {
+ // Sind wir in einer Tabelle in der Tabelle?
+ const SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode];
+ const SwTableNode *pTblNd = pNd->FindTableNode();
+
+ SvxAdjust eTblAdjust = pTable->GetTableAdjust(sal_False);
+
+ // Wenn das Table-Tag in einem Rahmen stand, den es nicht
+ // mehr gibt, muessen wir die Tabelle in einen Rahmen
+ // stecken.
+ if( pCurTable->IsMakeTopSubTable() && pTblNd!=0 )
+ pCurTable->SetHasToFly();
+
+ // Wenn die Tabelle links oder rechts ausgerivchtet ist,
+ // oder in einen Rahmen soll, dann kommt sie auch in einen
+ // solchen.
+ bForceFrame = eTblAdjust == SVX_ADJUST_LEFT ||
+ eTblAdjust == SVX_ADJUST_RIGHT ||
+ pCurTable->HasToFly();
+
+ // Da Tabelle in Tabelle nicht geht, muss die Tabelle
+ // entweder in einen Rahmen, oder sie steht in einem
+ // Rahmen sie steht in keiner anderen Tabelle.
+ ASSERT( bForceFrame || !pTblNd,
+ "Tabelle in der Tabelle geht nur mit oder in Rahmen" );
+
+ // Entweder kommt die Tabelle in keinen Rahmen und befindet
+ // sich in keinem Rahmen (wird also durch Zellen simuliert),
+ // oder es gibt bereits Inhalt an der entsprechenden Stelle.
+ ASSERT( !bForceFrame || pCurTable->HasParentSection(),
+ "Tabelle im Rahmen hat keine Umgebung!" );
+// SCHOEN WAER'S, aber wie bekommen den Inhalt nicht zurueck
+// in die umgebende Zelle
+// if( bForceFrame && !pCurTable->HasParentSection() )
+// {
+// pCurTable->SetParentContents(
+// InsertTableContents( sal_False, SVX_ADJUST_END ) );
+// pCurTable->SetHasParentSection( sal_True );
+// }
+
+ sal_Bool bAppend = sal_False;
+ if( bForceFrame )
+ {
+ // Wenn die Tabelle in einen Rahmen kommt, muss
+ // nur ein neuer Absatz aufgemacht werden, wenn
+ // der Absatz Rahmen ohne Umlauf enthaelt.
+ bAppend = HasCurrentParaFlys(sal_True);
+ }
+ else
+ {
+ // Sonst muss ein neuer Absatz aufgemacht werden,
+ // wenn der Absatz nicht leer ist, oder Rahmen
+ // oder ::com::sun::star::text::Bookmarks enthaelt.
+ bAppend =
+ pPam->GetPoint()->nContent.GetIndex() ||
+ HasCurrentParaFlys() ||
+ HasCurrentParaBookmarks();
+ }
+ if( bAppend )
+ {
+ if( !pPam->GetPoint()->nContent.GetIndex() )
+ {
+ pDoc->SetTxtFmtColl( *pPam,
+ pCSS1Parser->GetTxtCollFromPool(RES_POOLCOLL_STANDARD) );
+ _HTMLAttr* pTmp =
+ new _HTMLAttr( *pPam->GetPoint(),
+ SvxFontHeightItem( 40 ) );
+ aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
+ pTmp = new _HTMLAttr( *pPam->GetPoint(),
+ SvxULSpaceItem( 0, 0 ) );
+ aSetAttrTab.Insert( pTmp, 0 ); // ja, 0, weil schon
+ // vom Tabellenende vorher
+ // was gesetzt sein kann.
+ }
+ AppendTxtNode( AM_NOSPACE );
+ bAppended = sal_True;
+ }
+ else if( aParaAttrs.Count() )
+ {
+ if( !bForceFrame )
+ {
+ // Der Absatz wird gleich hinter die Tabelle
+ // verschoben. Deshalb entfernen wir alle harten
+ // Attribute des Absatzes
+
+ for( sal_uInt16 i=0; i<aParaAttrs.Count(); i++ )
+ aParaAttrs[i]->Invalidate();
+ }
+
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+ }
+
+ pSavePos = new SwPosition( *pPam->GetPoint() );
+ }
+ else if( pCurTable->HasParentSection() )
+ {
+ bParentLFStripped = StripTrailingLF() > 0;
+
+ // Absaetze bzw. ueberschriften beeenden
+ nOpenParaToken = 0;
+ nFontStHeadStart = nFontStMin;
+
+ // die harten Attribute an diesem Absatz werden nie mehr ungueltig
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+#ifndef NUM_RELSPACE
+ if( GetNumInfo().GetNumRule() )
+ UpdateNumRuleInTable();
+#endif
+ }
+
+ // einen Tabellen Kontext anlegen
+ _HTMLTableContext *pTCntxt =
+ new _HTMLTableContext( pSavePos, nContextStMin,
+ nContextStAttrMin );
+
+ // alle noch offenen Attribute beenden und hinter der Tabelle
+ // neu aufspannen
+ _HTMLAttrs *pPostIts = 0;
+ if( !bForceFrame && (bTopTable || pCurTable->HasParentSection()) )
+ {
+ SplitAttrTab( pTCntxt->aAttrTab, bTopTable );
+ // Wenn wir einen schon vorhandenen Absatz verwenden, duerfen
+ // in den keine PostIts eingefuegt werden, weil der Absatz
+ // ja hinter die Tabelle wandert. Sie werden deshalb in den
+ // ersten Absatz der Tabelle verschoben.
+ // Bei Tabellen in Tabellen duerfen ebenfalls keine PostIts
+ // in einen noch leeren Absatz eingefuegt werden, weil
+ // der sonat nicht geloescht wird.
+ if( (bTopTable && !bAppended) ||
+ (!bTopTable && !bParentLFStripped &&
+ !pPam->GetPoint()->nContent.GetIndex()) )
+ pPostIts = new _HTMLAttrs;
+ SetAttr( bTopTable, bTopTable, pPostIts );
+ }
+ else
+ {
+ SaveAttrTab( pTCntxt->aAttrTab );
+ if( bTopTable && !bAppended )
+ {
+ pPostIts = new _HTMLAttrs;
+ SetAttr( sal_True, sal_True, pPostIts );
+ }
+ }
+ bNoParSpace = sal_False;
+
+ // Aktuelle Numerierung retten und auschalten.
+ pTCntxt->SetNumInfo( GetNumInfo() );
+ GetNumInfo().Clear();
+ pTCntxt->SavePREListingXMP( *this );
+
+ if( bTopTable )
+ {
+ if( bForceFrame )
+ {
+ // Die Tabelle soll in einen Rahmen geschaufelt werden.
+
+ SfxItemSet aFrmSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !pCurTable->IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aFrmSet );
+
+ SwSurround eSurround = SURROUND_NONE;
+ SwHoriOrient eHori;
+
+ switch( pCurTable->GetTableAdjust(sal_True) )
+ {
+ case SVX_ADJUST_RIGHT:
+ eHori = HORI_RIGHT;
+ eSurround = SURROUND_LEFT;
+ break;
+ case SVX_ADJUST_CENTER:
+ eHori = HORI_CENTER;
+ break;
+ case SVX_ADJUST_LEFT:
+ eSurround = SURROUND_RIGHT;
+ default:
+ eHori = HORI_LEFT;
+ break;
+ }
+ SetAnchorAndAdjustment( VERT_NONE, eHori, aFrmSet,
+ sal_True );
+ aFrmSet.Put( SwFmtSurround(eSurround) );
+
+ SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, 20*MM50, MINLAY );
+ aFrmSize.SetWidthPercent( 100 );
+ aFrmSet.Put( aFrmSize );
+
+ sal_uInt16 nSpace = pCurTable->GetHSpace();
+ if( nSpace )
+ aFrmSet.Put( SvxLRSpaceItem(nSpace,nSpace) );
+ nSpace = pCurTable->GetVSpace();
+ if( nSpace )
+ aFrmSet.Put( SvxULSpaceItem(nSpace,nSpace) );
+
+ RndStdIds eAnchorId = ((const SwFmtAnchor&)aFrmSet.
+ Get( RES_ANCHOR )).
+ GetAnchorId();
+ SwFrmFmt *pFrmFmt = pDoc->MakeFlySection(
+ eAnchorId, pPam->GetPoint(), &aFrmSet );
+
+ pTCntxt->SetFrmFmt( pFrmFmt );
+ const SwFmtCntnt& rFlyCntnt = pFrmFmt->GetCntnt();
+ pPam->GetPoint()->nNode = *rFlyCntnt.GetCntntIdx();
+ SwCntntNode *pCNd =
+ pDoc->GetNodes().GoNext( &(pPam->GetPoint()->nNode) );
+ pPam->GetPoint()->nContent.Assign( pCNd, 0 );
+
+ // automatisch verankerte Rahmen muessen noch um
+ // eine Position nach vorne verschoben werden.
+ //if( FLY_AUTO_CNTNT==eAnchorId )
+ // aMoveFlyFrms.C40_INSERT( SwFrmFmt, pFrmFmt,
+ // aMoveFlyFrms.Count() );
+ }
+
+ // eine SwTable mit einer Box anlegen und den PaM in den
+ // Inhalt der Box-Section bewegen (der Ausrichtungs-Parameter
+ // ist erstmal nur ein Dummy und wird spaeter noch richtig
+ // gesetzt)
+ ASSERT( !pPam->GetPoint()->nContent.GetIndex(),
+ "Der Absatz hinter der Tabelle ist nicht leer!" );
+ const SwTable* pSwTable = pDoc->InsertTable( *pPam->GetPoint(),
+ 1, 1, HORI_LEFT );
+
+ if( bForceFrame )
+ {
+ SwNodeIndex aDstIdx( pPam->GetPoint()->nNode );
+ pPam->Move( fnMoveBackward );
+ pDoc->GetNodes().Delete( aDstIdx );
+ }
+ else
+ {
+ if( bStyleParsed )
+ {
+ pCSS1Parser->SetFmtBreak( aItemSet, aPropInfo );
+ pSwTable->GetFrmFmt()->SetAttr( aItemSet );
+ }
+ pPam->Move( fnMoveBackward );
+ }
+
+ const SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode];
+ if( !bAppended && !bForceFrame )
+ {
+ SwTxtNode* pOldTxtNd =
+ pDoc->GetNodes()[pSavePos->nNode]->GetTxtNode();
+ ASSERT( pOldTxtNd, "Wieso stehen wir in keinem Txt-Node?" );
+ SwFrmFmt *pFrmFmt = pSwTable->GetFrmFmt();
+
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pOldTxtNd->GetSwAttrSet()
+ .GetItemState( RES_PAGEDESC, sal_False, &pItem ) &&
+ ((SwFmtPageDesc *)pItem)->GetPageDesc() )
+ {
+ pFrmFmt->SetAttr( *pItem );
+ pOldTxtNd->ResetAttr( RES_PAGEDESC );
+ }
+ if( SFX_ITEM_SET == pOldTxtNd->GetSwAttrSet()
+ .GetItemState( RES_BREAK, sal_True, &pItem ) )
+ {
+ switch( ((SvxFmtBreakItem *)pItem)->GetBreak() )
+ {
+ case SVX_BREAK_PAGE_BEFORE:
+ case SVX_BREAK_PAGE_AFTER:
+ case SVX_BREAK_PAGE_BOTH:
+ pFrmFmt->SetAttr( *pItem );
+ pOldTxtNd->ResetAttr( RES_BREAK );
+ }
+ }
+ }
+
+ if( !bAppended && pPostIts )
+ {
+ // noch vorhandene PostIts in den ersten Absatz
+ // der Tabelle setzen
+ InsertAttrs( *pPostIts );
+ delete pPostIts;
+ pPostIts = 0;
+ }
+
+ pTCntxt->SetTableNode( (SwTableNode *)pNd->FindTableNode() );
+
+ pCurTable->SetTable( pTCntxt->GetTableNode(), pTCntxt,
+ nLeftSpace, nRightSpace,
+ pSwTable, bForceFrame );
+
+ ASSERT( !pPostIts, "ubenutzte PostIts" );
+ }
+ else
+ {
+ // noch offene Bereiche muessen noch entfernt werden
+ if( EndSections( bParentLFStripped ) )
+ bParentLFStripped = sal_False;
+
+ if( pCurTable->HasParentSection() )
+ {
+ // dannach entfernen wir ein ggf. zu viel vorhandenen
+ // leeren Absatz, aber nur, wenn er schon vor dem
+ // entfernen von LFs leer war
+ if( !bParentLFStripped )
+ StripTrailingPara();
+
+ if( pPostIts )
+ {
+ // noch vorhandene PostIts an das Ende des jetzt
+ // aktuellen Absatzes schieben
+ InsertAttrs( *pPostIts );
+ delete pPostIts;
+ pPostIts = 0;
+ }
+ }
+
+ const SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode];
+ const SwStartNode *pStNd = (pTable->bFirstCell ? pNd->FindTableNode()
+ : pNd->FindTableBoxStartNode() );
+
+ pCurTable->SetTable( pStNd, pTCntxt, nLeftSpace, nRightSpace );
+ }
+
+ // Den Kontext-Stack einfrieren, denn es koennen auch mal
+ // irgendwo ausserhalb von Zellen Attribute gesetzt werden.
+ // Darf nicht frueher passieren, weil eventuell noch im
+ // Stack gesucht wird!!!
+ nContextStMin = aContexts.Count();
+ nContextStAttrMin = nContextStMin;
+ }
+
+ pSaveStruct = new _CellSaveStruct( *this, pCurTable, bHead,
+ bReadOptions );
+
+ // ist beim ersten GetNextToken schon pending, muss bei
+ // wiederaufsetzen auf jedenfall neu gelesen werden!
+ SaveState( 0 );
+ }
+
+ if( !nToken )
+ nToken = GetNextToken(); // Token nach <TABLE>
+
+ sal_Bool bDone = sal_False;
+ while( (IsParserWorking() && !bDone) || bPending )
+ {
+ SaveState( nToken );
+
+ nToken = FilterToken( nToken );
+
+ ASSERT( pPendStack || !bCallNextToken || pSaveStruct->IsInSection(),
+ "Wo ist die Section gebieben?" );
+ if( !pPendStack && bCallNextToken && pSaveStruct->IsInSection() )
+ {
+ // NextToken direkt aufrufen (z.B. um den Inhalt von
+ // Floating-Frames oder Applets zu ignorieren)
+ NextToken( nToken );
+ }
+ else switch( nToken )
+ {
+ case HTML_TABLEHEADER_ON:
+ case HTML_TABLEDATA_ON:
+ case HTML_TABLEROW_ON:
+ case HTML_TABLEROW_OFF:
+ case HTML_THEAD_ON:
+ case HTML_THEAD_OFF:
+ case HTML_TFOOT_ON:
+ case HTML_TFOOT_OFF:
+ case HTML_TBODY_ON:
+ case HTML_TBODY_OFF:
+ case HTML_TABLE_OFF:
+ SkipToken(-1);
+ case HTML_TABLEHEADER_OFF:
+ case HTML_TABLEDATA_OFF:
+ bDone = sal_True;
+ break;
+ case HTML_TABLE_ON:
+ {
+ sal_Bool bTopTable = sal_False;
+ sal_Bool bHasToFly = sal_False;
+ SvxAdjust eTabAdjust = SVX_ADJUST_END;
+ if( !pPendStack )
+ {
+ // nur wenn eine neue Tabelle aufgemacht wird, aber
+ // nicht wenn nach einem Pending in der Tabelle
+ // weitergelesen wird!
+ pSaveStruct->pTable = pTable;
+
+ // HACK: Eine Section fuer eine Tabelle anlegen, die
+ // in einen Rahmen kommt.
+ if( !pSaveStruct->IsInSection() )
+ {
+ // Diese Schleife muss vorwartes sein, weil die
+ // erste Option immer gewinnt.
+ sal_Bool bNeedsSection = sal_False;
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i=0; i<pOptions->Count(); i++ )
+ {
+ const HTMLOption *pOption = (*pOptions)[i];
+ if( HTML_O_ALIGN==pOption->GetToken() )
+ {
+ SvxAdjust eAdjust =
+ (SvxAdjust)pOption->GetEnum(
+ aHTMLPAlignTable, SVX_ADJUST_END );
+ bNeedsSection = SVX_ADJUST_LEFT == eAdjust ||
+ SVX_ADJUST_RIGHT == eAdjust;
+ break;
+ }
+ }
+ if( bNeedsSection )
+ {
+ pSaveStruct->AddContents(
+ InsertTableContents(bHead ) );
+ }
+ }
+ else
+ {
+ // Wenn wir mitlerweile in einem Rahmen stehen
+ // koennen wir erneut eine echte Tabelle aufmachen.
+ // Wir erkennen das daran, dass wir keinen
+ // Tabellen-Node mehr finden.
+ bTopTable = pDoc->GetNodes()[pPam->GetPoint()->nNode]
+ ->FindTableNode() == 0;
+
+ // Wenn im aktuellen Absatz Flys verankert sind,
+ // muss die neue Tabelle in einen Rahmen.
+ bHasToFly = HasCurrentParaFlys(sal_False,sal_True);
+ }
+
+ // in der Zelle kann sich ein Bereich befinden!
+ eTabAdjust = aAttrTab.pAdjust
+ ? ((const SvxAdjustItem&)aAttrTab.pAdjust->GetItem()).
+ GetAdjust()
+ : SVX_ADJUST_END;
+ }
+
+ HTMLTable *pSubTable = BuildTable( eTabAdjust,
+ bHead,
+ pSaveStruct->IsInSection(),
+ bTopTable, bHasToFly );
+ if( SVPAR_PENDING != GetStatus() )
+ {
+ // nur wenn die Tabelle wirklich zu Ende ist!
+ if( pSubTable )
+ {
+ ASSERT( pSubTable->GetTableAdjust(sal_False)!= SVX_ADJUST_LEFT &&
+ pSubTable->GetTableAdjust(sal_False)!= SVX_ADJUST_RIGHT,
+ "links oder rechts ausgerichtete Tabellen gehoehren in Rahmen" );
+
+
+ HTMLTableCnts *pParentContents =
+ pSubTable->GetParentContents();
+ if( pParentContents )
+ {
+ ASSERT( !pSaveStruct->IsInSection(),
+ "Wo ist die Section geblieben" );
+
+ // Wenn jetzt keine Tabelle kommt haben wir eine
+ // Section
+ pSaveStruct->AddContents( pParentContents );
+ }
+
+ const SwStartNode *pCapStNd =
+ pSubTable->GetCaptionStartNode();
+
+ if( pSubTable->GetContext() )
+ {
+ ASSERT( !pSubTable->GetContext()->GetFrmFmt(),
+ "Tabelle steht im Rahmen" );
+
+ if( pCapStNd && pSubTable->IsTopCaption() )
+ {
+ pSaveStruct->AddContents(
+ new HTMLTableCnts(pCapStNd) );
+ }
+
+ pSaveStruct->AddContents(
+ new HTMLTableCnts(pSubTable) );
+
+ if( pCapStNd && !pSubTable->IsTopCaption() )
+ {
+ pSaveStruct->AddContents(
+ new HTMLTableCnts(pCapStNd) );
+ }
+
+ // Jetzt haben wir keine Section mehr
+ pSaveStruct->ClearIsInSection();
+ }
+ else if( pCapStNd )
+ {
+ // Da wir diese Sction nicht mehr loeschen
+ // koennen (sie koeente zur erster Box
+ // gehoeren), fuegen wir sie ein.
+ pSaveStruct->AddContents(
+ new HTMLTableCnts(pCapStNd) );
+
+ // Jetzt haben wir keine Section mehr
+ pSaveStruct->ClearIsInSection();
+ }
+ }
+
+ pTable = pSaveStruct->pTable;
+ }
+ }
+ break;
+
+ case HTML_NOBR_ON:
+ // HACK fuer MS: Steht das <NOBR> zu beginn der Zelle?
+ pSaveStruct->StartNoBreak( *pPam->GetPoint() );
+ break;
+
+ case HTML_NOBR_OFF:
+ pSaveStruct->EndNoBreak( *pPam->GetPoint() );
+ break;
+
+ case HTML_COMMENT:
+ // Mit Kommentar-Feldern werden Spaces nicht mehr geloescht
+ // ausserdem wollen wir fuer einen Kommentar keine neue Zelle
+ // anlegen !!!
+ NextToken( nToken );
+ break;
+
+ case HTML_MARQUEE_ON:
+ if( !pSaveStruct->IsInSection() )
+ {
+ // eine neue Section anlegen, der PaM steht dann darin
+ pSaveStruct->AddContents(
+ InsertTableContents( bHead ) );
+ }
+ bCallNextToken = sal_True;
+ NewMarquee( pCurTable );
+ break;
+
+ case HTML_TEXTTOKEN:
+ // keine Section fuer einen leeren String anlegen
+ if( !pSaveStruct->IsInSection() && 1==aToken.Len() &&
+ ' '==aToken.GetChar(0) )
+ break;
+ default:
+ if( !pSaveStruct->IsInSection() )
+ {
+ // eine neue Section anlegen, der PaM steht dann darin
+ pSaveStruct->AddContents(
+ InsertTableContents( bHead ) );
+ }
+
+ if( IsParserWorking() || bPending )
+ NextToken( nToken );
+ break;
+ }
+
+ ASSERT( !bPending || !pPendStack,
+ "SwHTMLParser::BuildTableCell: Es gibt wieder einen Pend-Stack" );
+ bPending = sal_False;
+ if( IsParserWorking() )
+ SaveState( 0 );
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( SVPAR_PENDING == GetStatus() )
+ {
+ pPendStack = new SwPendingStack( bHead ? HTML_TABLEHEADER_ON
+ : HTML_TABLEDATA_ON, pPendStack );
+ pPendStack->pData = pSaveStruct;
+
+ return;
+ }
+
+ // Falls der Inhalt der Zelle leer war, muessen wir noch einen
+ // leeren Inhalt anlegen. Ausserdem legen wir einen leeren Inhalt
+ // an, wenn die Zelle mit einer Tabelle aufgehoert hat und keine
+ // COL-Tags hatte (sonst wurde sie wahrscheinlich von uns exportiert,
+ // und dann wollen wir natuerlich keinen zusaetzlichen Absatz haben).
+ if( !pSaveStruct->GetFirstContents() ||
+ (!pSaveStruct->IsInSection() && !pCurTable->HasColTags()) )
+ {
+ ASSERT( pSaveStruct->GetFirstContents() ||
+ !pSaveStruct->IsInSection(),
+ "Section oder nicht, das ist hier die Frage" );
+ const SwStartNode *pStNd =
+ InsertTableSection( pSaveStruct->IsHeaderCell()
+ ? RES_POOLCOLL_TABLE_HDLN
+ : RES_POOLCOLL_TABLE );
+ pDoc->GetNodes()[pStNd->GetIndex()+1]
+ ->GetCntntNode()->SetAttr( SvxFontHeightItem(40) );
+ pSaveStruct->AddContents( new HTMLTableCnts(pStNd) );
+ pSaveStruct->ClearIsInSection();
+ }
+
+ sal_Bool bLFStripped = sal_False;
+ if( pSaveStruct->IsInSection() )
+ {
+ pSaveStruct->CheckNoBreak( *pPam->GetPoint(), pDoc );
+
+ // Alle noch offenen Kontexte beenden. Wir nehmen hier
+ // AttrMin, weil nContxtStMin evtl. veraendert wurde.
+ // Da es durch EndContext wieder restauriert wird, geht das.
+ while( aContexts.Count() > nContextStAttrMin+1 )
+ {
+ _HTMLAttrContext *pCntxt = PopContext();
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+
+ // LFs am Absatz-Ende entfernen
+ if( StripTrailingLF()==0 && !pPam->GetPoint()->nContent.GetIndex() )
+ StripTrailingPara();
+
+#ifndef NUM_RELSPACE
+ if( GetNumInfo().GetNumRule() )
+ UpdateNumRuleInTable();
+#endif
+
+ // falls fuer die Zelle eine Ausrichtung gesetzt wurde, muessen
+ // wir die beenden
+ _HTMLAttrContext *pCntxt = PopContext();
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+ else
+ {
+ // Alle noch offenen Kontexte beenden
+ while( aContexts.Count() > nContextStAttrMin )
+ {
+ _HTMLAttrContext *pCntxt = PopContext();
+ ClearContext( pCntxt );
+ delete pCntxt;
+ }
+ }
+
+ // auch eine Numerierung muss beendet werden
+ GetNumInfo().Clear();
+
+ SetAttr( sal_False );
+
+ pSaveStruct->InsertCell( *this, pCurTable );
+
+ // wir stehen jetzt (wahrschenlich) vor <TH>, <TD>, <TR> oder </TABLE>
+ delete pSaveStruct;
+}
+
+
+class _RowSaveStruct : public SwPendingStackData
+{
+public:
+ SvxAdjust eAdjust;
+ SwVertOrient eVertOri;
+ sal_Bool bHasCells;
+
+ _RowSaveStruct() :
+ bHasCells( sal_False ), eAdjust( SVX_ADJUST_END ), eVertOri( VERT_TOP )
+ {}
+};
+
+
+void SwHTMLParser::BuildTableRow( HTMLTable *pCurTable, sal_Bool bReadOptions,
+ SvxAdjust eGrpAdjust,
+ SwVertOrient eGrpVertOri )
+{
+ // <TR> wurde bereist gelesen
+
+ if( !IsParserWorking() && !pPendStack )
+ return;
+
+ int nToken = 0;
+ _RowSaveStruct* pSaveStruct;
+
+ sal_Bool bPending = sal_False;
+ if( pPendStack )
+ {
+ pSaveStruct = (_RowSaveStruct*)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ nToken = pPendStack ? pPendStack->nToken : GetSaveToken();
+ bPending = SVPAR_ERROR == eState && pPendStack != 0;
+
+ SaveState( nToken );
+ }
+ else
+ {
+ SvxAdjust eAdjust = eGrpAdjust;
+ SwVertOrient eVertOri = eGrpVertOri;
+ Color aBGColor;
+ String aBGImage, aStyle, aId, aClass;
+ sal_Bool bBGColor = sal_False;
+ pSaveStruct = new _RowSaveStruct;
+
+ if( bReadOptions )
+ {
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ eAdjust = (SvxAdjust)pOption->GetEnum(
+ aHTMLPAlignTable, eAdjust );
+ break;
+ case HTML_O_VALIGN:
+ eVertOri = (SwVertOrient)pOption->GetEnum(
+ aHTMLTblVAlignTable, eVertOri );
+ break;
+ case HTML_O_BGCOLOR:
+ // Leere BGCOLOR bei <TABLE>, <TR> und <TD>/<TH> wie Netsc.
+ // ignorieren, bei allen anderen Tags *wirklich* nicht.
+ if( pOption->GetString().Len() )
+ {
+ pOption->GetColor( aBGColor );
+ bBGColor = sal_True;
+ }
+ break;
+ case HTML_O_BACKGROUND:
+ aBGImage = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass= pOption->GetString();
+ break;
+ }
+ }
+ }
+
+ if( aId.Len() )
+ InsertBookmark( aId );
+
+ SvxBrushItem *pBrushItem =
+ CreateBrushItem( bBGColor ? &aBGColor : 0, aBGImage, aStyle,
+ aId, aClass );
+ pCurTable->OpenRow( eAdjust, eVertOri, pBrushItem );
+ // ist beim ersten GetNextToken schon pending, muss bei
+ // wiederaufsetzen auf jedenfall neu gelesen werden!
+ SaveState( 0 );
+ }
+
+ if( !nToken )
+ nToken = GetNextToken(); // naechstes Token
+
+ sal_Bool bDone = sal_False;
+ while( (IsParserWorking() && !bDone) || bPending )
+ {
+ SaveState( nToken );
+
+ nToken = FilterToken( nToken );
+
+ ASSERT( pPendStack || !bCallNextToken ||
+ pCurTable->GetContext() || pCurTable->HasParentSection(),
+ "Wo ist die Section gebieben?" );
+ if( !pPendStack && bCallNextToken &&
+ (pCurTable->GetContext() || pCurTable->HasParentSection()) )
+ {
+ // NextToken direkt aufrufen (z.B. um den Inhalt von
+ // Floating-Frames oder Applets zu ignorieren)
+ NextToken( nToken );
+ }
+ else switch( nToken )
+ {
+ case HTML_TABLE_ON:
+ if( !pCurTable->GetContext() )
+ {
+ SkipToken( -1 );
+ bDone = sal_True;
+ }
+// else
+// {
+// NextToken( nToken );
+// }
+ break;
+ case HTML_TABLEROW_ON:
+ case HTML_THEAD_ON:
+ case HTML_THEAD_OFF:
+ case HTML_TBODY_ON:
+ case HTML_TBODY_OFF:
+ case HTML_TFOOT_ON:
+ case HTML_TFOOT_OFF:
+ case HTML_TABLE_OFF:
+ SkipToken( -1 );
+ case HTML_TABLEROW_OFF:
+ bDone = sal_True;
+ break;
+ case HTML_TABLEHEADER_ON:
+ case HTML_TABLEDATA_ON:
+ BuildTableCell( pCurTable, sal_True, HTML_TABLEHEADER_ON==nToken );
+ if( SVPAR_PENDING != GetStatus() )
+ {
+ pSaveStruct->bHasCells = sal_True;
+ bDone = pTable->IsOverflowing();
+ }
+ break;
+ case HTML_CAPTION_ON:
+ BuildTableCaption( pCurTable );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_CAPTION_OFF:
+ case HTML_TABLEHEADER_OFF:
+ case HTML_TABLEDATA_OFF:
+ case HTML_COLGROUP_ON:
+ case HTML_COLGROUP_OFF:
+ case HTML_COL_ON:
+ case HTML_COL_OFF:
+ // wo keine Zelle anfing kann auch keine aufhoehren, oder?
+ // und die ganzen anderen Tokens haben hier auch nicht zu
+ // suchen und machen nur die Tabelle kaputt
+ break;
+ case HTML_MULTICOL_ON:
+ // spaltige Rahmen koennen wir hier leider nicht einguegen
+ break;
+ case HTML_FORM_ON:
+ NewForm( sal_False ); // keinen neuen Absatz aufmachen!
+ break;
+ case HTML_FORM_OFF:
+ EndForm( sal_False ); // keinen neuen Absatz aufmachen!
+ break;
+ case HTML_COMMENT:
+ NextToken( nToken );
+ break;
+ case HTML_MAP_ON:
+ // eine Image-Map fuegt nichts ein, deshalb koennen wir sie
+ // problemlos auch ohne Zelle parsen
+ NextToken( nToken );
+ break;
+ case HTML_TEXTTOKEN:
+ if( (pCurTable->GetContext() ||
+ !pCurTable->HasParentSection()) &&
+ 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ break;
+ default:
+ pCurTable->MakeParentContents();
+ NextToken( nToken );
+ break;
+ }
+
+ ASSERT( !bPending || !pPendStack,
+ "SwHTMLParser::BuildTableRow: Es gibt wieder einen Pend-Stack" );
+ bPending = sal_False;
+ if( IsParserWorking() )
+ SaveState( 0 );
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( SVPAR_PENDING == GetStatus() )
+ {
+ pPendStack = new SwPendingStack( HTML_TABLEROW_ON, pPendStack );
+ pPendStack->pData = pSaveStruct;
+ }
+ else
+ {
+ pCurTable->CloseRow( !pSaveStruct->bHasCells );
+ delete pSaveStruct;
+ }
+
+ // wir stehen jetzt (wahrscheinlich) vor <TR> oder </TABLE>
+}
+
+void SwHTMLParser::BuildTableSection( HTMLTable *pCurTable,
+ sal_Bool bReadOptions,
+ sal_Bool bHead )
+{
+ // <THEAD>, <TBODY> bzw. <TFOOT> wurde bereits gelesen
+ if( !IsParserWorking() && !pPendStack )
+ return;
+
+ int nToken = 0;
+ sal_Bool bPending = sal_False;
+ _RowSaveStruct* pSaveStruct;
+
+ if( pPendStack )
+ {
+ pSaveStruct = (_RowSaveStruct*)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ nToken = pPendStack ? pPendStack->nToken : GetSaveToken();
+ bPending = SVPAR_ERROR == eState && pPendStack != 0;
+
+ SaveState( nToken );
+ }
+ else
+ {
+ pSaveStruct = new _RowSaveStruct;
+
+ if( bReadOptions )
+ {
+ const HTMLOptions *pOptions = GetOptions();
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ InsertBookmark( pOption->GetString() );
+ break;
+ case HTML_O_ALIGN:
+ pSaveStruct->eAdjust =
+ (SvxAdjust)pOption->GetEnum( aHTMLPAlignTable,
+ pSaveStruct->eAdjust );
+ break;
+ case HTML_O_VALIGN:
+ pSaveStruct->eVertOri =
+ (SwVertOrient)pOption->GetEnum( aHTMLTblVAlignTable,
+ pSaveStruct->eVertOri );
+ break;
+ }
+ }
+ }
+
+ // ist beim ersten GetNextToken schon pending, muss bei
+ // wiederaufsetzen auf jedenfall neu gelesen werden!
+ SaveState( 0 );
+ }
+
+ if( !nToken )
+ nToken = GetNextToken(); // naechstes Token
+
+ sal_Bool bDone = sal_False;
+ while( (IsParserWorking() && !bDone) || bPending )
+ {
+ SaveState( nToken );
+
+ nToken = FilterToken( nToken );
+
+ ASSERT( pPendStack || !bCallNextToken ||
+ pCurTable->GetContext() || pCurTable->HasParentSection(),
+ "Wo ist die Section gebieben?" );
+ if( !pPendStack && bCallNextToken &&
+ (pCurTable->GetContext() || pCurTable->HasParentSection()) )
+ {
+ // NextToken direkt aufrufen (z.B. um den Inhalt von
+ // Floating-Frames oder Applets zu ignorieren)
+ NextToken( nToken );
+ }
+ else switch( nToken )
+ {
+ case HTML_TABLE_ON:
+ if( !pCurTable->GetContext() )
+ {
+ SkipToken( -1 );
+ bDone = sal_True;
+ }
+// else
+// {
+// NextToken( nToken );
+// }
+ break;
+ case HTML_THEAD_ON:
+ case HTML_TFOOT_ON:
+ case HTML_TBODY_ON:
+ case HTML_TABLE_OFF:
+ SkipToken( -1 );
+ case HTML_THEAD_OFF:
+ case HTML_TBODY_OFF:
+ case HTML_TFOOT_OFF:
+ bDone = sal_True;
+ break;
+ case HTML_CAPTION_ON:
+ BuildTableCaption( pCurTable );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_CAPTION_OFF:
+ break;
+ case HTML_TABLEHEADER_ON:
+ case HTML_TABLEDATA_ON:
+ SkipToken( -1 );
+ BuildTableRow( pCurTable, sal_False, pSaveStruct->eAdjust,
+ pSaveStruct->eVertOri );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_TABLEROW_ON:
+ BuildTableRow( pCurTable, sal_True, pSaveStruct->eAdjust,
+ pSaveStruct->eVertOri );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_MULTICOL_ON:
+ // spaltige Rahmen koennen wir hier leider nicht einguegen
+ break;
+ case HTML_FORM_ON:
+ NewForm( sal_False ); // keinen neuen Absatz aufmachen!
+ break;
+ case HTML_FORM_OFF:
+ EndForm( sal_False ); // keinen neuen Absatz aufmachen!
+ break;
+ case HTML_TEXTTOKEN:
+ // Blank-Strings sind Folge von CR+LF und kein Text
+ if( (pCurTable->GetContext() ||
+ !pCurTable->HasParentSection()) &&
+ 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ break;
+ default:
+ pCurTable->MakeParentContents();
+ NextToken( nToken );
+ }
+
+ ASSERT( !bPending || !pPendStack,
+ "SwHTMLParser::BuildTableSection: Es gibt wieder einen Pend-Stack" );
+ bPending = sal_False;
+ if( IsParserWorking() )
+ SaveState( 0 );
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( SVPAR_PENDING == GetStatus() )
+ {
+ pPendStack = new SwPendingStack( bHead ? HTML_THEAD_ON
+ : HTML_TBODY_ON, pPendStack );
+ pPendStack->pData = pSaveStruct;
+ }
+ else
+ {
+ pCurTable->CloseSection( bHead );
+ delete pSaveStruct;
+ }
+
+ // wir stehen jetzt (wahrscheinlich) vor <TBODY>,... oder </TABLE>
+}
+
+struct _TblColGrpSaveStruct : public SwPendingStackData
+{
+ sal_uInt16 nColGrpSpan;
+ sal_uInt16 nColGrpWidth;
+ sal_Bool bRelColGrpWidth;
+ SvxAdjust eColGrpAdjust;
+ SwVertOrient eColGrpVertOri;
+
+ inline _TblColGrpSaveStruct();
+
+
+ inline void CloseColGroup( HTMLTable *pTable );
+};
+
+inline _TblColGrpSaveStruct::_TblColGrpSaveStruct() :
+ nColGrpSpan( 1 ), nColGrpWidth( 0 ),
+ bRelColGrpWidth( sal_False ), eColGrpAdjust( SVX_ADJUST_END ),
+ eColGrpVertOri( VERT_TOP )
+{}
+
+
+inline void _TblColGrpSaveStruct::CloseColGroup( HTMLTable *pTable )
+{
+ pTable->CloseColGroup( nColGrpSpan, nColGrpWidth,
+ bRelColGrpWidth, eColGrpAdjust, eColGrpVertOri );
+}
+
+void SwHTMLParser::BuildTableColGroup( HTMLTable *pCurTable,
+ sal_Bool bReadOptions )
+{
+ // <COLGROUP> wurde bereits gelesen, wenn bReadOptions
+
+ if( !IsParserWorking() && !pPendStack )
+ return;
+
+ int nToken = 0;
+ sal_Bool bPending = sal_False;
+ _TblColGrpSaveStruct* pSaveStruct;
+
+ if( pPendStack )
+ {
+ pSaveStruct = (_TblColGrpSaveStruct*)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ nToken = pPendStack ? pPendStack->nToken : GetSaveToken();
+ bPending = SVPAR_ERROR == eState && pPendStack != 0;
+
+ SaveState( nToken );
+ }
+ else
+ {
+
+ pSaveStruct = new _TblColGrpSaveStruct;
+ if( bReadOptions )
+ {
+ const HTMLOptions *pColGrpOptions = GetOptions();
+ for( sal_uInt16 i = pColGrpOptions->Count(); i; )
+ {
+ const HTMLOption *pColGrpOption = (*pColGrpOptions)[--i];
+ switch( pColGrpOption->GetToken() )
+ {
+ case HTML_O_ID:
+ InsertBookmark( pColGrpOption->GetString() );
+ break;
+ case HTML_O_SPAN:
+ pSaveStruct->nColGrpSpan = (sal_uInt16)pColGrpOption->GetNumber();
+ break;
+ case HTML_O_WIDTH:
+ pSaveStruct->nColGrpWidth = (sal_uInt16)pColGrpOption->GetNumber();
+ pSaveStruct->bRelColGrpWidth =
+ (pColGrpOption->GetString().Search('*') != STRING_NOTFOUND);
+ break;
+ case HTML_O_ALIGN:
+ pSaveStruct->eColGrpAdjust =
+ (SvxAdjust)pColGrpOption->GetEnum( aHTMLPAlignTable,
+ pSaveStruct->eColGrpAdjust );
+ break;
+ case HTML_O_VALIGN:
+ pSaveStruct->eColGrpVertOri =
+ (SwVertOrient)pColGrpOption->GetEnum( aHTMLTblVAlignTable,
+ pSaveStruct->eColGrpVertOri );
+ break;
+ }
+ }
+ }
+ // ist beim ersten GetNextToken schon pending, muss bei
+ // wiederaufsetzen auf jedenfall neu gelesen werden!
+ SaveState( 0 );
+ }
+
+ if( !nToken )
+ nToken = GetNextToken(); // naechstes Token
+
+ sal_Bool bDone = sal_False;
+ while( (IsParserWorking() && !bDone) || bPending )
+ {
+ SaveState( nToken );
+
+ nToken = FilterToken( nToken );
+
+ ASSERT( pPendStack || !bCallNextToken ||
+ pCurTable->GetContext() || pCurTable->HasParentSection(),
+ "Wo ist die Section gebieben?" );
+ if( !pPendStack && bCallNextToken &&
+ (pCurTable->GetContext() || pCurTable->HasParentSection()) )
+ {
+ // NextToken direkt aufrufen (z.B. um den Inhalt von
+ // Floating-Frames oder Applets zu ignorieren)
+ NextToken( nToken );
+ }
+ else switch( nToken )
+ {
+ case HTML_TABLE_ON:
+ if( !pCurTable->GetContext() )
+ {
+ SkipToken( -1 );
+ bDone = sal_True;
+ }
+// else
+// {
+// NextToken( nToken );
+// }
+ break;
+ case HTML_COLGROUP_ON:
+ case HTML_THEAD_ON:
+ case HTML_TFOOT_ON:
+ case HTML_TBODY_ON:
+ case HTML_TABLEROW_ON:
+ case HTML_TABLE_OFF:
+ SkipToken( -1 );
+ case HTML_COLGROUP_OFF:
+ bDone = sal_True;
+ break;
+ case HTML_COL_ON:
+ {
+ sal_uInt16 nColSpan = 1;
+ sal_uInt16 nColWidth = pSaveStruct->nColGrpWidth;
+ sal_Bool bRelColWidth = pSaveStruct->bRelColGrpWidth;
+ SvxAdjust eColAdjust = pSaveStruct->eColGrpAdjust;
+ SwVertOrient eColVertOri = pSaveStruct->eColGrpVertOri;
+
+ const HTMLOptions *pColOptions = GetOptions();
+ for( sal_uInt16 i = pColOptions->Count(); i; )
+ {
+ const HTMLOption *pColOption = (*pColOptions)[--i];
+ switch( pColOption->GetToken() )
+ {
+ case HTML_O_ID:
+ InsertBookmark( pColOption->GetString() );
+ break;
+ case HTML_O_SPAN:
+ nColSpan = (sal_uInt16)pColOption->GetNumber();
+ break;
+ case HTML_O_WIDTH:
+ nColWidth = (sal_uInt16)pColOption->GetNumber();
+ bRelColWidth =
+ (pColOption->GetString().Search('*') != STRING_NOTFOUND);
+ break;
+ case HTML_O_ALIGN:
+ eColAdjust =
+ (SvxAdjust)pColOption->GetEnum( aHTMLPAlignTable,
+ eColAdjust );
+ break;
+ case HTML_O_VALIGN:
+ eColVertOri =
+ (SwVertOrient)pColOption->GetEnum( aHTMLTblVAlignTable,
+ eColVertOri );
+ break;
+ }
+ }
+ pCurTable->InsertCol( nColSpan, nColWidth, bRelColWidth,
+ eColAdjust, eColVertOri );
+
+ // die Angaben in <COLGRP> sollen ignoriert werden, wenn
+ // <COL>-Elemente existieren
+ pSaveStruct->nColGrpSpan = 0;
+ }
+ break;
+ case HTML_COL_OFF:
+ break; // Ignorieren
+ case HTML_MULTICOL_ON:
+ // spaltige Rahmen koennen wir hier leider nicht einguegen
+ break;
+ case HTML_TEXTTOKEN:
+ if( (pCurTable->GetContext() ||
+ !pCurTable->HasParentSection()) &&
+ 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ break;
+ default:
+ pCurTable->MakeParentContents();
+ NextToken( nToken );
+ }
+
+ ASSERT( !bPending || !pPendStack,
+ "SwHTMLParser::BuildTableColGrp: Es gibt wieder einen Pend-Stack" );
+ bPending = sal_False;
+ if( IsParserWorking() )
+ SaveState( 0 );
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( SVPAR_PENDING == GetStatus() )
+ {
+ pPendStack = new SwPendingStack( HTML_COL_ON, pPendStack );
+ pPendStack->pData = pSaveStruct;
+ }
+ else
+ {
+ pSaveStruct->CloseColGroup( pCurTable );
+ delete pSaveStruct;
+ }
+}
+
+class _CaptionSaveStruct : public _SectionSaveStruct
+{
+ SwPosition aSavePos;
+ SwHTMLNumRuleInfo aNumRuleInfo; // gueltige Numerierung
+
+public:
+
+ _HTMLAttrTable aAttrTab; // und die Attribute
+
+ _CaptionSaveStruct( SwHTMLParser& rParser, const SwPosition& rPos ) :
+ _SectionSaveStruct( rParser ), aSavePos( rPos )
+ {
+ rParser.SaveAttrTab( aAttrTab );
+
+ // Die aktuelle Numerierung wurde gerettet und muss nur
+ // noch beendet werden.
+#ifndef NUM_RELSPACE
+ if( rParser.GetNumInfo().GetNumRule() )
+ rParser.UpdateNumRuleInTable();
+#endif
+ aNumRuleInfo.Set( rParser.GetNumInfo() );
+ rParser.GetNumInfo().Clear();
+ }
+
+ const SwPosition& GetPos() const { return aSavePos; }
+
+ void RestoreAll( SwHTMLParser& rParser )
+ {
+ // Die alten Stack wiederherstellen
+ Restore( rParser );
+
+ // Die alte Attribut-Tabelle wiederherstellen
+ rParser.RestoreAttrTab( aAttrTab );
+
+ // Die alte Numerierung wieder aufspannen
+ rParser.GetNumInfo().Set( aNumRuleInfo );
+ }
+
+ virtual ~_CaptionSaveStruct();
+};
+
+_CaptionSaveStruct::~_CaptionSaveStruct()
+{}
+
+void SwHTMLParser::BuildTableCaption( HTMLTable *pCurTable )
+{
+ // <CAPTION> wurde bereits gelesen
+
+ if( !IsParserWorking() && !pPendStack )
+ return;
+
+ int nToken = 0;
+ _CaptionSaveStruct* pSaveStruct;
+
+ if( pPendStack )
+ {
+ pSaveStruct = (_CaptionSaveStruct*)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ nToken = pPendStack ? pPendStack->nToken : GetSaveToken();
+ ASSERT( !pPendStack, "Wo kommt hier ein Pending-Stack her?" );
+
+ SaveState( nToken );
+ }
+ else
+ {
+ if( pTable->IsOverflowing() )
+ {
+ SaveState( 0 );
+ return;
+ }
+
+ sal_Bool bTop = sal_True;
+ const HTMLOptions *pOptions = GetOptions();
+ for ( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ if( HTML_O_ALIGN == pOption->GetToken() )
+ {
+ if( pOption->GetString().EqualsIgnoreCaseAscii(sHTML_VA_bottom))
+ bTop = sal_False;
+ }
+ }
+
+ // Alte PaM-Position retten.
+ pSaveStruct = new _CaptionSaveStruct( *this, *pPam->GetPoint() );
+
+ // Eine Text-Section im Icons-Bereich als Container fuer die
+ // Ueberschrift anlegen und PaM dort reinstellen.
+ const SwStartNode *pStNd;
+ if( pTable == pCurTable )
+ pStNd = InsertTempTableCaptionSection();
+ else
+ pStNd = InsertTableSection( RES_POOLCOLL_TEXT );
+
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_CAPTION_ON );
+
+ // Tabellen-Ueberschriften sind immer zentriert.
+ NewAttr( &aAttrTab.pAdjust, SvxAdjustItem(SVX_ADJUST_CENTER) );
+
+ _HTMLAttrs &rAttrs = pCntxt->GetAttrs();
+ rAttrs.Insert( aAttrTab.pAdjust, rAttrs.Count() );
+
+ PushContext( pCntxt );
+
+ // StartNode der Section an der Tabelle merken.
+ pCurTable->SetCaption( pStNd, bTop );
+
+ // ist beim ersten GetNextToken schon pending, muss bei
+ // wiederaufsetzen auf jedenfall neu gelesen werden!
+ SaveState( 0 );
+ }
+
+ if( !nToken )
+ nToken = GetNextToken(); // naechstes Token
+
+ // </CAPTION> wird laut DTD benoetigt
+ sal_Bool bDone = sal_False;
+ while( IsParserWorking() && !bDone )
+ {
+ SaveState( nToken );
+
+ nToken = FilterToken( nToken );
+
+ switch( nToken )
+ {
+ case HTML_TABLE_ON:
+ if( !pPendStack )
+ {
+ pSaveStruct->pTable = pTable;
+ sal_Bool bHasToFly = pSaveStruct->pTable!=pCurTable;
+ BuildTable( pCurTable->GetTableAdjust( sal_True ),
+ sal_False, sal_True, sal_True, bHasToFly );
+ }
+ else
+ {
+ BuildTable( SVX_ADJUST_END );
+ }
+ if( SVPAR_PENDING != GetStatus() )
+ {
+ pTable = pSaveStruct->pTable;
+ }
+ break;
+ case HTML_TABLE_OFF:
+ case HTML_COLGROUP_ON:
+ case HTML_THEAD_ON:
+ case HTML_TFOOT_ON:
+ case HTML_TBODY_ON:
+ case HTML_TABLEROW_ON:
+ SkipToken( -1 );
+ bDone = sal_True;
+ break;
+
+ case HTML_CAPTION_OFF:
+ bDone = sal_True;
+ break;
+ default:
+ int nNxtToken = nToken;
+ if( pPendStack )
+ {
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+
+ ASSERT( !pTmp, "weiter kann es nicht gehen!" );
+ nNxtToken = 0; // neu lesen
+ }
+
+ if( IsParserWorking() )
+ NextToken( nToken );
+ break;
+ }
+
+ if( IsParserWorking() )
+ SaveState( 0 );
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( SVPAR_PENDING==GetStatus() )
+ {
+ pPendStack = new SwPendingStack( HTML_CAPTION_ON, pPendStack );
+ pPendStack->pData = pSaveStruct;
+ return;
+ }
+
+ // Alle noch offenen Kontexte beenden
+ while( aContexts.Count() > nContextStAttrMin+1 )
+ {
+ _HTMLAttrContext *pCntxt = PopContext();
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+
+ // LF am Absatz-Ende entfernen
+ sal_Bool bLFStripped = StripTrailingLF() > 0;
+
+ if( pTable==pCurTable )
+ {
+ // Beim spaeteren verschieben der Beschriftung vor oder hinter
+ // die Tabelle wird der letzte Absatz nicht mitverschoben.
+ // Deshalb muss sich am Ende der Section immer ein leerer
+ // Absatz befinden.
+ if( pPam->GetPoint()->nContent.GetIndex() || bLFStripped )
+ AppendTxtNode( AM_NOSPACE );
+ }
+ else
+ {
+ // LFs am Absatz-Ende entfernen
+ if( !pPam->GetPoint()->nContent.GetIndex() && !bLFStripped )
+ StripTrailingPara();
+ }
+
+ // falls fuer die Zelle eine Ausrichtung gesetzt wurde, muessen
+ // wir die beenden
+ _HTMLAttrContext *pCntxt = PopContext();
+ EndContext( pCntxt );
+ delete pCntxt;
+
+ SetAttr( sal_False );
+
+ // Stacks und Attribut-Tabelle wiederherstellen
+ pSaveStruct->RestoreAll( *this );
+
+ // PaM wiederherstellen.
+ *pPam->GetPoint() = pSaveStruct->GetPos();
+
+ delete pSaveStruct;
+}
+
+class _TblSaveStruct : public SwPendingStackData
+{
+public:
+ HTMLTable *pCurTable;
+
+ _TblSaveStruct( HTMLTable *pCurTbl ) :
+ pCurTable( pCurTbl )
+ {}
+
+ virtual ~_TblSaveStruct();
+
+ // Aufbau der Tabelle anstossen und die Tabelle ggf. in einen
+ // Rahmen packen. Wenn sal_True zurueckgegeben wird muss noch ein
+ // Absatz eingefuegt werden!
+ void MakeTable( sal_uInt16 nWidth, SwPosition& rPos, SwDoc *pDoc );
+};
+
+_TblSaveStruct::~_TblSaveStruct()
+{}
+
+
+void _TblSaveStruct::MakeTable( sal_uInt16 nWidth, SwPosition& rPos, SwDoc *pDoc )
+{
+ pCurTable->MakeTable( 0, nWidth );
+
+ _HTMLTableContext *pTCntxt = pCurTable->GetContext();
+ ASSERT( pTCntxt, "Wo ist der Tabellen-Kontext" );
+
+ SwTableNode *pTblNd = pTCntxt->GetTableNode();
+ ASSERT( pTblNd, "Wo ist der Tabellen-Node" );
+
+ if( pDoc->GetRootFrm() && pTblNd )
+ {
+ // Existiert schon ein Layout, dann muss an dieser Tabelle die
+ // BoxFrames neu erzeugt werden.
+
+ if( pTCntxt->GetFrmFmt() )
+ {
+ pTCntxt->GetFrmFmt()->DelFrms();
+ pTblNd->DelFrms();
+ pTCntxt->GetFrmFmt()->MakeFrms();
+ }
+ else
+ {
+ pTblNd->DelFrms();
+ SwNodeIndex aIdx( *pTblNd->EndOfSectionNode(), 1 );
+ ASSERT( aIdx.GetIndex() <= pTCntxt->GetPos()->nNode.GetIndex(),
+ "unerwarteter Node fuer das Tabellen-Layout" );
+ pTblNd->MakeFrms( &aIdx );
+ }
+ }
+
+ rPos = *pTCntxt->GetPos();
+}
+
+
+HTMLTableOptions::HTMLTableOptions( const HTMLOptions *pOptions,
+ SvxAdjust eParentAdjust ) :
+ nCols( 0 ),
+ nWidth( 0 ), nHeight( 0 ),
+ nCellPadding( USHRT_MAX ), nCellSpacing( USHRT_MAX ),
+ nBorder( USHRT_MAX ),
+ nHSpace( 0 ), nVSpace( 0 ),
+ eAdjust( eParentAdjust ), eVertOri( VERT_CENTER ),
+ eFrame( HTML_TF_VOID ), eRules( HTML_TR_NONE ),
+ bPrcWidth( sal_False ),
+ bTableAdjust( sal_False ),
+ bBGColor( sal_False ),
+ aBorderColor( COL_GRAY )
+{
+ sal_Bool bBorderColor = sal_False;
+ sal_Bool bHasFrame = sal_False, bHasRules = sal_False;
+
+ for( sal_uInt16 i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_COLS:
+ nCols = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_WIDTH:
+ nWidth = (sal_uInt16)pOption->GetNumber();
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ if( bPrcWidth && nWidth>100 )
+ nWidth = 100;
+ break;
+ case HTML_O_HEIGHT:
+ nHeight = (sal_uInt16)pOption->GetNumber();
+ if( pOption->GetString().Search('%') != STRING_NOTFOUND )
+ nHeight = 0; // keine %-Anagben benutzen!!!
+ break;
+ case HTML_O_CELLPADDING:
+ nCellPadding = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_CELLSPACING:
+ nCellSpacing = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_ALIGN:
+ {
+ sal_uInt16 nAdjust = eAdjust;
+ if( pOption->GetEnum( nAdjust, aHTMLPAlignTable ) )
+ {
+ eAdjust = (SvxAdjust)nAdjust;
+ bTableAdjust = sal_True;
+ }
+ }
+ break;
+ case HTML_O_VALIGN:
+ eVertOri = (SwVertOrient)pOption->GetEnum( aHTMLTblVAlignTable,
+ eVertOri );
+ break;
+ case HTML_O_BORDER:
+ // BORDER und BORDER=BORDER wie BORDER=1 behandeln
+ if( pOption->GetString().Len() &&
+ !pOption->GetString().EqualsIgnoreCaseAscii(sHTML_O_border) )
+ nBorder = (sal_uInt16)pOption->GetNumber();
+ else
+ nBorder = 1;
+
+ if( !bHasFrame )
+ eFrame = ( nBorder ? HTML_TF_BOX : HTML_TF_VOID );
+ if( !bHasRules )
+ eRules = ( nBorder ? HTML_TR_ALL : HTML_TR_NONE );
+ break;
+ case HTML_O_FRAME:
+ eFrame = pOption->GetTableFrame();
+ bHasFrame = sal_True;
+ break;
+ case HTML_O_RULES:
+ eRules = pOption->GetTableRules();
+ bHasRules = sal_True;
+ break;
+ case HTML_O_BGCOLOR:
+ // Leere BGCOLOR bei <TABLE>, <TR> und <TD>/<TH> wie Netscape
+ // ignorieren, bei allen anderen Tags *wirklich* nicht.
+ if( pOption->GetString().Len() )
+ {
+ pOption->GetColor( aBGColor );
+ bBGColor = sal_True;
+ }
+ break;
+ case HTML_O_BACKGROUND:
+ aBGImage = pOption->GetString();
+ break;
+ case HTML_O_BORDERCOLOR:
+ pOption->GetColor( aBorderColor );
+ bBorderColor = sal_True;
+ break;
+ case HTML_O_BORDERCOLORDARK:
+ if( !bBorderColor )
+ pOption->GetColor( aBorderColor );
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_HSPACE:
+ nHSpace = (sal_uInt16)pOption->GetNumber();
+ break;
+ case HTML_O_VSPACE:
+ nVSpace = (sal_uInt16)pOption->GetNumber();
+ break;
+ }
+ }
+
+ if( nCols && !nWidth )
+ {
+ nWidth = 100;
+ bPrcWidth = sal_True;
+ }
+
+ // Wenn BORDER=0 oder kein BORDER gegeben ist, daan darf es auch
+ // keine Umrandung geben
+ if( 0==nBorder || USHRT_MAX==nBorder )
+ {
+ eFrame = HTML_TF_VOID;
+ eRules = HTML_TR_NONE;
+ }
+}
+
+
+HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust,
+ sal_Bool bIsParentHead,
+ sal_Bool bHasParentSection,
+ sal_Bool bMakeTopSubTable,
+ sal_Bool bHasToFly )
+{
+ if( !IsParserWorking() && !pPendStack )
+ return 0;
+
+ int nToken = 0;
+ sal_Bool bPending = sal_False;
+ _TblSaveStruct* pSaveStruct;
+
+ if( pPendStack )
+ {
+ pSaveStruct = (_TblSaveStruct*)pPendStack->pData;
+
+ SwPendingStack* pTmp = pPendStack->pNext;
+ delete pPendStack;
+ pPendStack = pTmp;
+ nToken = pPendStack ? pPendStack->nToken : GetSaveToken();
+ bPending = SVPAR_ERROR == eState && pPendStack != 0;
+
+ SaveState( nToken );
+ }
+ else
+ {
+ HTMLTableOptions *pTblOptions =
+ new HTMLTableOptions( GetOptions(), eParentAdjust );
+
+ if( pTblOptions->aId.Len() )
+ InsertBookmark( pTblOptions->aId );
+
+ // Wenn die Tabelle in einem Rahmen steht oder link oder rechts
+ // ausgerichtet ist, wird in jedem Fall eine "echte" Tabelle daraus.
+ if( bMakeTopSubTable || bHasToFly ||
+ (pTblOptions->bTableAdjust &&
+ (SVX_ADJUST_LEFT==pTblOptions->eAdjust ||
+ SVX_ADJUST_RIGHT==pTblOptions->eAdjust)) )
+ {
+ pTable = 0;
+ }
+
+ HTMLTable *pCurTable = new HTMLTable( this, pTable,
+ bIsParentHead,
+ bHasParentSection,
+ bMakeTopSubTable,
+ bHasToFly,
+ pTblOptions );
+ if( !pTable )
+ pTable = pCurTable;
+
+ pSaveStruct = new _TblSaveStruct( pCurTable );
+
+ delete pTblOptions;
+
+ // ist beim ersten GetNextToken schon pending, muss bei
+ // wiederaufsetzen auf jedenfall neu gelesen werden!
+ SaveState( 0 );
+ }
+
+ HTMLTable *pCurTable = pSaveStruct->pCurTable;
+
+ // </TABLE> wird laut DTD benoetigt
+ if( !nToken )
+ nToken = GetNextToken(); // naechstes Token
+
+ sal_Bool bDone = sal_False;
+ while( (IsParserWorking() && !bDone) || bPending )
+ {
+ SaveState( nToken );
+
+ nToken = FilterToken( nToken );
+
+ ASSERT( pPendStack || !bCallNextToken ||
+ pCurTable->GetContext() || pCurTable->HasParentSection(),
+ "Wo ist die Section gebieben?" );
+ if( !pPendStack && bCallNextToken &&
+ (pCurTable->GetContext() || pCurTable->HasParentSection()) )
+ {
+ // NextToken direkt aufrufen (z.B. um den Inhalt von
+ // Floating-Frames oder Applets zu ignorieren)
+ NextToken( nToken );
+ }
+ else switch( nToken )
+ {
+ case HTML_TABLE_ON:
+ if( !pCurTable->GetContext() )
+ {
+ // Wenn noch keine Tabelle eingefuegt wurde,
+ // die naechste Tabelle lesen
+ SkipToken( -1 );
+ bDone = sal_True;
+ }
+// else
+// {
+// NextToken( nToken );
+// }
+ break;
+ case HTML_TABLE_OFF:
+ bDone = sal_True;
+ break;
+ case HTML_CAPTION_ON:
+ BuildTableCaption( pCurTable );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_COL_ON:
+ SkipToken( -1 );
+ BuildTableColGroup( pCurTable, sal_False );
+ break;
+ case HTML_COLGROUP_ON:
+ BuildTableColGroup( pCurTable, sal_True );
+ break;
+ case HTML_TABLEROW_ON:
+ case HTML_TABLEHEADER_ON:
+ case HTML_TABLEDATA_ON:
+ SkipToken( -1 );
+ BuildTableSection( pCurTable, sal_False, sal_False );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_THEAD_ON:
+ case HTML_TFOOT_ON:
+ case HTML_TBODY_ON:
+ BuildTableSection( pCurTable, sal_True, HTML_THEAD_ON==nToken );
+ bDone = pTable->IsOverflowing();
+ break;
+ case HTML_MULTICOL_ON:
+ // spaltige Rahmen koennen wir hier leider nicht einguegen
+ break;
+ case HTML_FORM_ON:
+ NewForm( sal_False ); // keinen neuen Absatz aufmachen!
+ break;
+ case HTML_FORM_OFF:
+ EndForm( sal_False ); // keinen neuen Absatz aufmachen!
+ break;
+ case HTML_TEXTTOKEN:
+ // Blank-Strings sind u. U. eine Folge von CR+LF und kein Text
+ if( (pCurTable->GetContext() ||
+ !pCurTable->HasParentSection()) &&
+ 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ break;
+ default:
+ pCurTable->MakeParentContents();
+ NextToken( nToken );
+ break;
+ }
+
+ ASSERT( !bPending || !pPendStack,
+ "SwHTMLParser::BuildTable: Es gibt wieder einen Pend-Stack" );
+ bPending = sal_False;
+ if( IsParserWorking() )
+ SaveState( 0 );
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( SVPAR_PENDING == GetStatus() )
+ {
+ pPendStack = new SwPendingStack( HTML_TABLE_ON, pPendStack );
+ pPendStack->pData = pSaveStruct;
+ return 0;
+ }
+
+ _HTMLTableContext *pTCntxt = pCurTable->GetContext();
+ if( pTCntxt )
+ {
+ // Die Tabelle wurde auch angelegt
+
+ // Tabellen-Struktur anpassen
+ pCurTable->CloseTable();
+
+ // ausserhalb von Zellen begonnene Kontexte beenden
+ // muss vor(!) dem Umsetzten der Attribut Tabelle existieren,
+ // weil die aktuelle danach nicht mehr existiert
+ while( aContexts.Count() > nContextStAttrMin )
+ {
+ _HTMLAttrContext *pCntxt = PopContext();
+ ClearContext( pCntxt );
+ delete pCntxt;
+ }
+
+ nContextStMin = pTCntxt->GetContextStMin();
+ nContextStAttrMin = pTCntxt->GetContextStAttrMin();
+
+ if( pTable==pCurTable )
+ {
+ // Tabellen-Beschriftung setzen
+ const SwStartNode *pCapStNd = pTable->GetCaptionStartNode();
+ if( pCapStNd )
+ {
+ // Der letzte Absatz der Section wird nie mitkopiert. Deshalb
+ // muss die Section mindestens zwei Absaetze enthalten.
+
+ if( pCapStNd->EndOfSectionIndex() - pCapStNd->GetIndex() > 2 )
+ {
+ // Start-Node und letzten Absatz nicht mitkopieren.
+ SwNodeRange aSrcRg( *pCapStNd, 1,
+ *pCapStNd->EndOfSectionNode(), -1 );
+
+ sal_Bool bTop = pTable->IsTopCaption();
+ SwStartNode *pTblStNd = pTCntxt->GetTableNode();
+
+ ASSERT( pTblStNd, "Wo ist der Tabellen-Node" );
+ ASSERT( pTblStNd==pPam->GetNode()->FindTableNode(),
+ "Stehen wir in der falschen Tabelle?" );
+
+ SwNode* pNd;
+ if( bTop )
+ pNd = pTblStNd;
+ else
+ pNd = pTblStNd->EndOfSectionNode();
+ SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 );
+
+ pDoc->Move( aSrcRg, aDstIdx );
+
+ // Wenn die Caption vor der Tabelle eingefuegt wurde muss
+ // eine an der Tabelle gestzte Seitenvorlage noch in den
+ // ersten Absatz der Ueberschrift verschoben werden.
+ // Ausserdem muessen alle gemerkten Indizes, die auf den
+ // Tabellen-Node zeigen noch verschoben werden.
+ if( bTop )
+ {
+ MovePageDescAttrs( pTblStNd, aSrcRg.aStart.GetIndex(),
+ sal_False );
+ }
+ }
+
+ // Die Section wird jetzt nicht mehr gebraucht.
+ pPam->SetMark();
+ pPam->DeleteMark();
+ pDoc->DeleteSection( (SwStartNode *)pCapStNd );
+ pTable->SetCaption( 0, sal_False );
+ }
+
+ // SwTable aufbereiten
+ sal_uInt16 nBrowseWidth = (sal_uInt16)GetCurrentBrowseWidth();
+ pSaveStruct->MakeTable( nBrowseWidth, *pPam->GetPoint(), pDoc );
+
+#ifdef TEST_RESIZE
+ const SwTable *pSwTable = pTable->GetSwTable();
+ SwHTMLTableLayout *pLayoutInfo =
+ pSwTable ? ((SwTable *)pSwTable)->GetHTMLTableLayout() : 0;
+ if( pLayoutInfo )
+ {
+ ViewShell *pVSh = CheckActionViewShell();
+ if( pVSh )
+ {
+ CallEndAction( sal_False, sal_False );
+ CallStartAction( pVSh, sal_False );
+
+ sal_uInt16 nNewBrwoseWidth =
+ (sal_uInt16)GetCurrentBrowseWidth();
+ if( nBrowseWidth != nNewBrowseWidth )
+ pLayoutInfo->Resize( nNewBrowseWidth );
+ }
+ }
+#endif
+ }
+
+ GetNumInfo().Set( pTCntxt->GetNumInfo() );
+ pTCntxt->RestorePREListingXMP( *this );
+ RestoreAttrTab( pTCntxt->aAttrTab );
+
+ if( pTable==pCurTable )
+ {
+ // oberen Absatz-Abstand einstellen
+ bUpperSpace = sal_True;
+ SetTxtCollAttrs();
+
+ nParaCnt -= Min(nParaCnt, pTCntxt->GetTableNode()->GetTable().GetTabSortBoxes().Count());
+
+ // ggfs. eine Tabelle anspringen
+ if( JUMPTO_TABLE == eJumpTo && pTable->GetSwTable() &&
+ pTable->GetSwTable()->GetFrmFmt()->GetName() == sJmpMark )
+ {
+ bChkJumpMark = sal_True;
+ eJumpTo = JUMPTO_NONE;
+ }
+
+ // fix #37886#: Wenn Import abgebrochen wurde kein erneutes Show
+ // aufrufen, weil die ViewShell schon geloescht wurde!
+ // fix #41669#: Genuegt nicht. Auch im ACCEPTING_STATE darf
+ // kein Show aufgerufen werden, weil sonst waehrend des
+ // Reschedules der Parser zerstoert wird, wenn noch ein
+ // DataAvailable-Link kommt. Deshalb: Nur im WORKING-State.
+ if( !nParaCnt && SVPAR_WORKING == GetStatus() )
+ Show();
+ }
+ }
+ else if( pTable==pCurTable )
+ {
+ // Es wurde gar keine Tabelle gelesen.
+
+ // Dann muss eine evtl gelesene Beschriftung noch geloescht werden.
+ const SwStartNode *pCapStNd = pCurTable->GetCaptionStartNode();
+ if( pCapStNd )
+ {
+ pPam->SetMark();
+ pPam->DeleteMark();
+ pDoc->DeleteSection( (SwStartNode *)pCapStNd );
+ pCurTable->SetCaption( 0, sal_False );
+ }
+ }
+
+ if( pTable == pCurTable )
+ {
+ delete pSaveStruct->pCurTable;
+ pSaveStruct->pCurTable = 0;
+ pTable = 0;
+ }
+
+ HTMLTable* pRetTbl = pSaveStruct->pCurTable;
+ delete pSaveStruct;
+
+ return pRetTbl;
+}
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmltab.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.295 2000/09/18 16:04:46 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.294 2000/09/05 14:01:28 mib
+ #78294#: removed support for frameset documents
+
+ Revision 1.293 2000/06/26 09:52:30 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.292 2000/04/28 14:29:12 mib
+ unicode
+
+ Revision 1.291 2000/04/10 12:20:57 mib
+ unicode
+
+ Revision 1.290 2000/03/21 15:06:18 os
+ UNOIII
+
+ Revision 1.289 2000/03/03 15:21:01 os
+ StarView remainders removed
+
+ Revision 1.288 2000/02/11 14:37:28 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.287 2000/02/07 08:24:58 mib
+ #72727#: HORI_LEFT_AND_WIDTH
+
+ Revision 1.286 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.285 1999/09/17 12:14:09 mib
+ support of multiple and non system text encodings
+
+ Revision 1.284 1999/07/29 06:21:52 MIB
+ fix LHS means left border and RHS right border, not vice versa
+
+
+ Rev 1.283 29 Jul 1999 08:21:52 MIB
+ fix LHS means left border and RHS right border, not vice versa
+
+ Rev 1.282 10 Jun 1999 10:34:26 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.281 09 Jun 1999 19:37:00 JP
+ have to change: no cast from GetpApp to SfxApp/OffApp, SfxShell only subclass of SfxApp
+
+ Rev 1.280 20 Apr 1999 10:07:50 MIB
+ bCallNextToken auch in Rows etc. auswerten
+
+ Rev 1.279 15 Apr 1999 13:48:20 MIB
+ #41833#: Styles fuer A-Tag
+
+ Rev 1.278 12 Apr 1999 09:23:28 MIB
+ Korrekt horizontal splitten (auch #64460#)
+
+ Rev 1.277 09 Apr 1999 10:30:36 MIB
+ #64522#: Styles fuer TD/TH auswerten
+
+ Rev 1.276 08 Apr 1999 11:13:10 MIB
+ #56334#: Optimierung fuer Hintergrundfarben wieder ausgebaut
+
+ Rev 1.275 06 Apr 1999 12:07:14 MIB
+ #64308#: ALIGN=? an Tabelle
+
+ Rev 1.274 01 Apr 1999 10:20:08 MIB
+ bug fix: Leere BGColor nicht auswerten
+
+ Rev 1.273 01 Apr 1999 08:57:02 MIB
+ #56334#: Keine Spezialbehandlung der Hintergruende fuer die GC mehr noetig
+
+ Rev 1.272 30 Mar 1999 11:58:36 MIB
+ #62977#: Nicht mehr Spalten einfuegen als Zellen je Zeile vorhanden
+
+ Rev 1.271 30 Mar 1999 11:44:26 MIB
+ #62977#: Nicht mehr Spalten einfuegen als Zellen je Zeile vorhanden (nur>529)
+
+ Rev 1.270 26 Mar 1999 11:39:46 MIB
+ #63049#: Sofortige Numerierungs-Aktualisierung in Tabellen ist jetzt unnoetig
+
+ Rev 1.269 17 Mar 1999 16:47:10 MIB
+ #63049#: Numerierungen mit relativen Abstaenden
+
+ Rev 1.268 10 Mar 1999 15:44:10 MIB
+ #62682#: Beim Setzen der Control-Groesse wenn noetig auf die ViewShell warten
+
+ Rev 1.267 25 Feb 1999 16:00:42 MIB
+ #61949#: globale Shell entsorgt
+
+ Rev 1.266 27 Jan 1999 09:43:56 OS
+ #56371# TF_ONE51
+
+ Rev 1.265 11 Jan 1999 11:17:08 MIB
+ Attribut-Tabellen-Ueberpruefung in NonPro wegen Asserts nicht immer
+
+ Rev 1.264 05 Jan 1999 14:48:00 MIB
+ #60429#: Zeilenhoehe korrekt berechnen
+
+ Rev 1.263 11 Nov 1998 17:42:10 MIB
+ #59059#: Beim Abbrechen Pendung-Stack noch aufraeumen
+
+ Rev 1.262 09 Nov 1998 11:35:18 MIB
+ #59159#: Pending-Stack von fremden Token nicht loeschen
+
+ Rev 1.261 03 Nov 1998 15:37:10 MIB
+ #58840#: bHoriSplittAll-Assert war falsch
+
+ Rev 1.260 25 Sep 1998 08:36:04 MIB
+ #45631#: Tabellen nach 64000 Zellen beenden
+
+ Rev 1.259 14 Sep 1998 11:41:12 MIB
+ #51238#: Beim Setzen des Zeilen-Hintergrundes ROWSPAN>1 beachten
+
+ Rev 1.258 31 Aug 1998 11:19:44 MIB
+ ##: Beim vertikalen Zerlegen auch letzte Spalte auf moegliche vert. Zerlegeung pruefen
+
+ Rev 1.257 27 Aug 1998 09:45:52 MIB
+ #54170#: Line-Format-Attribute zuruecksetzen, bevor Hoehe oder Hintergrund gesetzt wird
+
+ Rev 1.256 26 Aug 1998 09:30:36 MIB
+ #55144#: Umlauf bei Tabellen in Rahmen richtig setzen und beachten
+
+ Rev 1.255 21 Jul 1998 16:55:46 JP
+ Bug #53456#: nie per Add eine Box im Format anmelden, sondern per Box::ChgFrmFmt
+
+ Rev 1.254 05 Jun 1998 13:56:54 JP
+ Bug #42487#: Sprung zum Mark schon waehrend des Ladens ausfuehren
+
+ Rev 1.253 12 May 1998 15:50:24 JP
+ rund um Flys/DrawObjs im Doc/FESh umgestellt/optimiert
+
+ Rev 1.252 15 Apr 1998 14:56:46 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.251 27 Mar 1998 18:02:42 MIB
+ HSPACE/VSPACE
+
+ Rev 1.250 24 Mar 1998 14:31:24 MIB
+ obsolete ParseStyleOptions-Methode entfernt
+
+ Rev 1.249 11 Mar 1998 18:28:54 MIB
+ fix #47846#: auto-gebundenen Rahmen korrekt verankern
+
+ Rev 1.248 02 Mar 1998 18:43:16 MIB
+ fix #45489#: Umrandung ueber mehrere Ebenenen vererben
+
+ Rev 1.247 27 Feb 1998 16:42:38 MIB
+ fix #46450#: Horizontale une vertikale Ausrichtung von Zellen mit NumFmt
+
+ Rev 1.246 27 Feb 1998 14:05:10 MIB
+ Auto-gebundene Rahmen
+
+ Rev 1.245 25 Feb 1998 12:17:36 MIB
+ I like ME and its 0xffs
+
+ Rev 1.244 25 Feb 1998 10:49:54 MIB
+ fix: Tabellen-Ueberschriften in Sub-Tabellen gleich in eine eigene Box packen
+
+ Rev 1.243 24 Feb 1998 17:45:50 MIB
+ Attribute von Tabellen-Zellen ueber AttrTab setzen
+
+ Rev 1.242 20 Feb 1998 18:52:04 MIB
+ fix #45328#: Bessere Behandlung von Styles an Tabellen-Zellen
+
+ Rev 1.241 20 Feb 1998 12:25:12 MIB
+ fix #45631#: Weniger ::com::sun::star::frame::Frame-Formate anlegen
+
+ Rev 1.240 19 Feb 1998 15:14:52 MIB
+ fix #47394#: Tabellen-Zellen wurden unnoetig geteilt
+
+ Rev 1.239 18 Feb 1998 10:57:30 MIB
+ fix #45153#: Bei fixer Tabellenhoehe Tabelle in Tabelle beachten
+
+ Rev 1.238 13 Feb 1998 18:48:42 HR
+ C40_INSERT
+
+ Rev 1.237 29 Jan 1998 21:34:18 JP
+ GetEndOfIcons ersetzt durch GetEndOfExtras, das auf GetEndOfRedlines mappt
+
+ Rev 1.236 19 Jan 1998 16:27:14 MIB
+ Numerierungs-Umbau
+
+ Rev 1.235 26 Nov 1997 19:09:42 MA
+ includes
+
+ Rev 1.234 17 Nov 1997 10:16:40 JP
+ Umstellung Numerierung
+
+ Rev 1.233 09 Oct 1997 14:34:14 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.232 19 Sep 1997 08:40:34 MIB
+ fix #41185#: Laufschrift an Tabellenzellen-Breite anpassen
+
+ Rev 1.231 16 Sep 1997 14:55:28 MIB
+ ITEMID_BOXINFOITEM (voreubergendend) definieren
+
+ Rev 1.230 16 Sep 1997 13:05:08 MIB
+ Abs.-Pos. Rahmen am Tabellen-Ende beenden
+
+ Rev 1.229 16 Sep 1997 11:19:12 MIB
+ Kopf-/Fusszeilen ohne Moven von Nodes, autom. Beenden von Bereichen/Rahmen
+
+ Rev 1.228 12 Sep 1997 11:54:02 MIB
+ fix #41253#: Script in PRE (keine Schleifen)
+
+ Rev 1.227 09 Sep 1997 14:10:48 MIB
+ Ueberall Browse-View-Breite statt Seitenbreite verwenden
+
+ Rev 1.226 08 Sep 1997 10:38:54 MIB
+ Keine Schleifen fuer PRE mehr (auch fix #41253#) (nicht freigeschaltet)
+
+ Rev 1.225 04 Sep 1997 15:45:30 MIB
+ fix: <NOBR> auch beachten, wenn danach ein <BR> folgt
+
+ Rev 1.224 04 Sep 1997 09:37:40 MIB
+ fix #42771#: Tabellen in Rahmen beachten
+
+ Rev 1.223 29 Aug 1997 16:49:44 OS
+ DLL-Umstellung
+
+ Rev 1.222 15 Aug 1997 12:47:38 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.221 12 Aug 1997 13:42:50 OS
+ Header-Umstellung
+
+ Rev 1.220 11 Aug 1997 14:04:42 OM
+ Headerfile-Umstellung
+
+ Rev 1.219 07 Aug 1997 15:08:18 OM
+ Headerfile-Umstellung
+
+ Rev 1.218 04 Aug 1997 13:54:24 MIB
+ aboslute psoitioning (fuer fast alle Zeichen-Attribute/-Vorlagen)
+
+ Rev 1.217 31 Jul 1997 10:44:32 MIB
+ DIV-Stack weg
+
+ Rev 1.216 25 Jul 1997 11:08:30 MIB
+ fix #42109#: Kommentare bei Tabellen in Tabellen beachten
+
+ Rev 1.215 21 Jul 1997 10:55:22 MIB
+ fix #41869#: Keile zusaetlichen Splaten bei selbst exportierten Tabellen
+
+ Rev 1.214 16 Jul 1997 18:33:04 MIB
+ fix #41669#: Kein Show im Accepted-State, weil Parser sonst zerst. werden kann
+
+ Rev 1.213 15 Jul 1997 13:11:54 MIB
+ fix: Tabellen-Ueberschriften immer zentrieren
+
+ Rev 1.212 11 Jul 1997 11:51:30 MIB
+ fix: Bei RULES=COLS auch Zeilen-Gruppen umranden
+
+ Rev 1.211 10 Jul 1997 10:30:30 MIB
+ fix #41516#: Keine Umrandung bei FRAME ohne BORDER
+
+ Rev 1.210 09 Jul 1997 08:45:16 MIB
+ 'Ueberschrift wiederholen' uanhaengig von </THEAD>-Position abktivieren
+
+ Rev 1.209 08 Jul 1997 14:16:42 MIB
+ Meta-Tags als PostIts und die immer im ersten Body-Absatz verankern
+
+ Rev 1.208 03 Jul 1997 09:37:00 MIB
+ HTML-Tabellen: Bei letzter Grafik ohne Groesse sofort anpassen
+
+ Rev 1.207 01 Jul 1997 12:39:14 MIB
+ fix: Beim Vergeben von Filler-Boxen tatsaechliche Umrandung betrachten
+
+ Rev 1.206 28 Jun 1997 11:32:00 MIB
+ fix: Bei Umrandung und CELLPADDING=0 minimalen Abstand zum Inhalte beachten
+
+ Rev 1.205 27 Jun 1997 15:57:40 MIB
+ fix: Pending-Stack bei bCallNextToken beachten
+
+ Rev 1.204 26 Jun 1997 11:54:52 MIB
+ fix #41003#: Nimber-Format nur bei Value oder leerer Zelle setzen
+
+ Rev 1.203 26 Jun 1997 10:56:32 MIB
+ fix #40941#: Tabellen In Tabellen in Rahmen, wenn sie ausweichen muessen
+
+ Rev 1.202 24 Jun 1997 08:59:54 MIB
+ fix: Beim Splitten von Zelle auch Tabellen-Layout anpassen
+
+ Rev 1.201 20 Jun 1997 13:36:08 MIB
+ Auch Grafiken in Tabellen asynchron laden
+
+ Rev 1.200 19 Jun 1997 11:57:04 MIB
+ Tabellen weichen jetzt Rahmen aus
+
+ Rev 1.199 16 Jun 1997 08:27:56 MIB
+ CLASS/ID auch fier Tabellen
+
+ Rev 1.198 12 Jun 1997 15:55:36 MIB
+ 358-Tabellen korrekt importieren
+
+ Rev 1.197 12 Jun 1997 09:13:42 MIB
+ fix: PostIts auch vor Tabellen in Rahmen in die Tabelle verschieben
+
+ Rev 1.196 09 Jun 1997 18:14:08 MIB
+ fix: leere Zellen und Zellen, die nur Grafiken enthalten, bekommen einen 2pt-Font
+
+ Rev 1.195 09 Jun 1997 12:56:46 MIB
+ fix: Kein GPF beim berechnen der Exportierbarkeit des Layouts mehr
+
+ Rev 1.194 09 Jun 1997 09:07:22 MIB
+ fix: Auch aus leeren Absatzen 2 LF entfernen
+
+ Rev 1.193 05 Jun 1997 17:42:38 MIB
+ fix: <NOBR> auch mit Space dahinter, Anpassungen an Export-Moeglichkeit
+
+ Rev 1.192 02 Jun 1997 12:01:18 MIB
+ fix: Bei vorhandener Umrandung deren Breite doch beruecksichtigen
+
+ Rev 1.191 30 May 1997 18:02:42 MIB
+ NOWRAP/NOBR, Einhalten der Mindestbreite bei rel. Tabellen
+
+ Rev 1.190 28 May 1997 19:14:26 MIB
+ fix: Layout-Info nicht im Destr. loeschen, TEST_RESIZE entfernt
+
+ Rev 1.189 28 May 1997 16:11:52 MIB
+ fix: Numerierung ueber Tabellen-Ueberschrift retten
+
+ Rev 1.188 28 May 1997 15:35:34 MIB
+ fix: -Angabe aus dem Format fuer Rahmen zu nehmen war keine gute Idee
+
+ Rev 1.187 27 May 1997 11:47:08 MIB
+ Netscape-konformere Beruecksichtigung von BORDER/CELLPADDING/CELLSPACING
+
+ Rev 1.186 15 May 1997 15:42:36 MIB
+ HTML-Tabellen-Layout an SwTable merken
+
+ Rev 1.185 06 May 1997 12:07:54 MA
+ swtablehxx aufgeteilt
+
+ Rev 1.184 30 Apr 1997 18:10:02 MIB
+ Ermitteln der verfuegbaren Breite ueber Layout
+
+ Rev 1.183 30 Apr 1997 14:54:46 MIB
+ Tabellen-Layout ausgelagert
+
+ Rev 1.182 23 Apr 1997 14:57:04 MIB
+ memory leak beseitig (wie 1.171.1.0)
+
+ Rev 1.181 21 Apr 1997 18:08:18 MIB
+ fix #38931#: 1. Absaetze hinter Tab in Tab nicht numerieren, Zelle hinter T in T
+
+ Rev 1.180 16 Apr 1997 18:23:12 MIB
+ fix #37769#: Tabellenbreite sinnvoll begrenzen und USHRT_MAX-Ueberlauf vermeiden
+
+ Rev 1.179 16 Apr 1997 15:19:26 MIB
+ fix #36787#: Ersatzdarstellung von Frames, Applets etc. auch in Tabellen ignorieren
+
+ Rev 1.178 14 Apr 1997 16:44:48 MIB
+ fixes #36418#, #36819#: Tabellen mit relativen/nicht relativen Spalten gleichz.
+
+ Rev 1.177 11 Apr 1997 17:58:52 MIB
+ fix #36820#: Bei Tabellen in Rahmen Absatz-Abstand beachten
+
+ Rev 1.176 10 Apr 1997 16:40:00 MIB
+ fix #37987#: Andere Berechnung der Spalten-Mindestbreite
+
+ Rev 1.175 09 Apr 1997 16:50:50 MIB
+ fix #38575#: Nicht immer einen Absatz vor Tabellen in Rahmen aufmachen
+
+ Rev 1.174 08 Apr 1997 11:07:02 MIB
+ fix #37219#: In Tabellen-Beschriftung alles erlauben
+
+ Rev 1.173 04 Apr 1997 11:04:22 AMA
+ Chg: Ein weiterer Parameter fuer GetMinMaxSize: das absolute Minimum
+
+ Rev 1.172 01 Apr 1997 10:47:08 MIB
+ fix #38284#: keine gelegentlich vertikale Ausrichtung an Zellen ohne Inhalt mehr
+
+ Rev 1.171 18 Mar 1997 19:06:44 MIB
+ fix #37886#: Kein Show beim Abbrechen mehr aufrufen, weil ViewShell tot sein koennte
+
+ Rev 1.170 18 Mar 1997 09:42:50 MIB
+ fix #37795#: Tabellen in Tabellen-Ueberschriften abfangen
+
+ Rev 1.169 05 Mar 1997 14:48:36 MIB
+ Absatz-Abstaende verbessert
+
+ Rev 1.168 22 Feb 1997 20:30:32 MIB
+ Tabellen-Layout an Netscape 4.0 Preview 2 anpassen
+
+ Rev 1.167 21 Feb 1997 15:28:26 MIB
+ fix #36692#: Fuer ::com::sun::star::form::Forms in Tabellen ausserhalb von Zellen keine neuen Absaetze
+
+ Rev 1.166 20 Feb 1997 17:04:46 MIB
+ bug fix: SaveState auch fuer Col-Groups
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
new file mode 100644
index 000000000000..6ef8019da3b6
--- /dev/null
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -0,0 +1,1571 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmltabw.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _HTMLOUT_HXX //autogen
+#include <svtools/htmlout.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XIMAGEPRODUCERSUPPLIER_HPP_
+#include <com/sun/star/form/XImageProducerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_
+#include <com/sun/star/form/XFormController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+#include <com/sun/star/form/XFormComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLERLISTENER_HPP_
+#include <com/sun/star/form/XFormControllerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
+#include <com/sun/star/container/XNameReplace.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
+#include <com/sun/star/container/XSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_CONTAINEREVENT_HPP_
+#include <com/sun/star/container/ContainerEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_
+#include <com/sun/star/container/XIndexReplace.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _SWRECT_HXX
+#include <swrect.hxx>
+#endif
+#ifndef _CELLATR_HXX
+#include <cellatr.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _HTMLTBL_HXX
+#include <htmltbl.hxx>
+#endif
+#ifndef _HTMLNUM_HXX
+#include <htmlnum.hxx>
+#endif
+#ifndef _WRTHTML_HXX
+#include <wrthtml.hxx>
+#endif
+#ifndef _WRTSWTBL_HXX
+#include <wrtswtbl.hxx>
+#endif
+
+
+
+#ifndef PRODUCT
+#ifndef _VIEWSH_HXX
+#include <viewsh.hxx>
+#endif
+#ifndef _VIEWOPT_HXX
+#include <viewopt.hxx>
+#endif
+#endif
+
+
+//#define MAX_DEPTH (USHRT_MAX)
+#define MAX_DEPTH (3)
+
+
+class SwHTMLWrtTable : public SwWriteTable
+{
+ void Pixelize( sal_uInt16& rValue );
+ void PixelizeBorders();
+
+ void OutTableCell( SwHTMLWriter& rWrt, const SwWriteTableCell *pCell,
+ sal_Bool bOutVAlign ) const;
+
+ void OutTableCells( SwHTMLWriter& rWrt,
+ const SwWriteTableCells& rCells,
+ const SvxBrushItem *pBrushItem ) const;
+
+ virtual sal_Bool ShouldExpandSub( const SwTableBox *pBox,
+ sal_Bool bExpandedBefore, sal_uInt16 nDepth ) const;
+
+ static sal_Bool HasTabBackground( const SwTableLine& rLine,
+ sal_Bool bTop, sal_Bool bBottom, sal_Bool bLeft, sal_Bool bRight );
+ static sal_Bool HasTabBackground( const SwTableBox& rBox,
+ sal_Bool bTop, sal_Bool bBottom, sal_Bool bLeft, sal_Bool bRight );
+
+public:
+ SwHTMLWrtTable( const SwTableLines& rLines, long nWidth, sal_uInt16 nBWidth,
+ sal_Bool bRel, sal_uInt16 nLeftSub=0, sal_uInt16 nRightSub=0 );
+ SwHTMLWrtTable( const SwHTMLTableLayout *pLayoutInfo );
+
+ void Write( SwHTMLWriter& rWrt, SwHoriOrient eAlign=HORI_NONE,
+ sal_Bool bTHead=sal_False, const SwFrmFmt *pFrmFmt=0,
+ const String *pCaption=0, sal_Bool bTopCaption=sal_False,
+ sal_uInt16 nHSpace=0, sal_uInt16 nVSpace=0 ) const;
+};
+
+
+SwHTMLWrtTable::SwHTMLWrtTable( const SwTableLines& rLines, long nWidth,
+ sal_uInt16 nBWidth, sal_Bool bRel,
+ sal_uInt16 nLSub, sal_uInt16 nRSub )
+ : SwWriteTable( rLines, nWidth, nBWidth, bRel, MAX_DEPTH, nLSub, nRSub )
+{
+ PixelizeBorders();
+}
+
+SwHTMLWrtTable::SwHTMLWrtTable( const SwHTMLTableLayout *pLayoutInfo )
+ : SwWriteTable( pLayoutInfo )
+{
+ // Einige Twip-Werte an Pixel-Grenzen anpassen
+ if( bCollectBorderWidth )
+ PixelizeBorders();
+}
+
+void SwHTMLWrtTable::Pixelize( sal_uInt16& rValue )
+{
+ if( rValue && Application::GetDefaultDevice() )
+ {
+ Size aSz( rValue, 0 );
+ aSz = Application::GetDefaultDevice()->LogicToPixel( aSz, MapMode(MAP_TWIP) );
+ if( !aSz.Width() )
+ aSz.Width() = 1;
+ aSz = Application::GetDefaultDevice()->PixelToLogic( aSz, MapMode(MAP_TWIP) );
+ rValue = (sal_uInt16)aSz.Width();
+ }
+}
+
+void SwHTMLWrtTable::PixelizeBorders()
+{
+ Pixelize( nBorder );
+ Pixelize( nCellSpacing );
+ Pixelize( nCellPadding );
+}
+
+sal_Bool SwHTMLWrtTable::HasTabBackground( const SwTableBox& rBox,
+ sal_Bool bTop, sal_Bool bBottom, sal_Bool bLeft, sal_Bool bRight )
+{
+ ASSERT( bTop || bBottom || bLeft || bRight,
+ "HasTabBackground: darf nicht aufgerufen werden" );
+
+ sal_Bool bRet = sal_False;
+ if( rBox.GetSttNd() )
+ {
+ const SvxBrushItem& rBrushItem =
+ rBox.GetFrmFmt()->GetBackground();
+
+ bRet = !rBrushItem.GetColor().GetTransparency() ||
+ rBrushItem.GetGraphicLink() || rBrushItem.GetGraphic();
+ }
+ else
+ {
+ const SwTableLines& rLines = rBox.GetTabLines();
+ sal_uInt16 nCount = rLines.Count();
+ sal_Bool bLeftRight = bLeft || bRight;
+ for( sal_uInt16 i=0; !bRet && i<nCount; i++ )
+ {
+ sal_Bool bT = bTop && 0 == i;
+ sal_Bool bB = bBottom && nCount-1 == i;
+ if( bT || bB || bLeftRight )
+ bRet = HasTabBackground( *rLines[i], bT, bB, bLeft, bRight);
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool SwHTMLWrtTable::HasTabBackground( const SwTableLine& rLine,
+ sal_Bool bTop, sal_Bool bBottom, sal_Bool bLeft, sal_Bool bRight )
+{
+ ASSERT( bTop || bBottom || bLeft || bRight,
+ "HasTabBackground: darf nicht aufgerufen werden" );
+
+ sal_Bool bRet = sal_False;
+ const SvxBrushItem& rBrushItem = rLine.GetFrmFmt()->GetBackground();
+ bRet = !rBrushItem.GetColor().GetTransparency() ||
+ rBrushItem.GetGraphicLink() || rBrushItem.GetGraphic();
+
+ if( !bRet )
+ {
+ const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
+ sal_uInt16 nCount = rBoxes.Count();
+ sal_Bool bTopBottom = bTop || bBottom;
+ for( sal_uInt16 i=0; !bRet && i<nCount; i++ )
+ {
+ sal_Bool bL = bLeft && 0 == i;
+ sal_Bool bR = bRight && nCount-1 == i;
+ if( bTopBottom || bL || bR )
+ bRet = HasTabBackground( *rBoxes[i], bTop, bBottom, bL, bR );
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool lcl_WrtHTMLTbl_HasTabBorders( const SwTableLine*& rpLine, void* pPara );
+
+sal_Bool lcl_WrtHTMLTbl_HasTabBorders( const SwTableBox*& rpBox, void* pPara )
+{
+ sal_Bool *pBorders = (sal_Bool *)pPara;
+ if( *pBorders )
+ return sal_False;
+
+ if( !rpBox->GetSttNd() )
+ {
+ ((SwTableBox *)rpBox)->GetTabLines().ForEach(
+ &lcl_WrtHTMLTbl_HasTabBorders, pPara );
+ }
+ else
+ {
+ const SvxBoxItem& rBoxItem =
+ (const SvxBoxItem&)rpBox->GetFrmFmt()->GetAttr( RES_BOX );
+
+ *pBorders = rBoxItem.GetTop() || rBoxItem.GetBottom() ||
+ rBoxItem.GetLeft() || rBoxItem.GetRight();
+ }
+
+ return !*pBorders;
+}
+
+sal_Bool lcl_WrtHTMLTbl_HasTabBorders( const SwTableLine*& rpLine, void* pPara )
+{
+ sal_Bool *pBorders = (sal_Bool *)pPara;
+ if( *pBorders )
+ return sal_False;
+
+ ((SwTableLine *)rpLine)->GetTabBoxes().ForEach(
+ &lcl_WrtHTMLTbl_HasTabBorders, pPara );
+ return !*pBorders;
+}
+
+
+sal_Bool SwHTMLWrtTable::ShouldExpandSub( const SwTableBox *pBox,
+ sal_Bool bExpandedBefore,
+ sal_uInt16 nDepth ) const
+{
+ sal_Bool bExpand = !pBox->GetSttNd() && nDepth>0;
+ if( bExpand && bExpandedBefore )
+ {
+ // MIB 30.6.97: Wenn schon eine Box expandiert wurde, wird eine
+ // weitere nur expandiert, wenn sie Umrandungen besitzt.
+ sal_Bool bBorders = sal_False;
+ lcl_WrtHTMLTbl_HasTabBorders( pBox, &bBorders );
+ if( !bBorders )
+ bBorders = HasTabBackground( *pBox, sal_True, sal_True, sal_True, sal_True );
+ bExpand = bBorders;
+ }
+
+ return bExpand;
+}
+
+
+// Eine Box als einzelne Zelle schreiben
+void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
+ const SwWriteTableCell *pCell,
+ sal_Bool bOutVAlign ) const
+{
+ const SwTableBox *pBox = pCell->GetBox();
+ sal_uInt16 nRow = pCell->GetRow();
+ sal_uInt16 nCol = pCell->GetCol();
+ sal_uInt16 nRowSpan = pCell->GetRowSpan();
+ sal_uInt16 nColSpan = pCell->GetColSpan();
+
+ SwWriteTableCol *pCol = aCols[nCol];
+
+// sal_Bool bOutWidth = nColSpan>1 || pCol->GetOutWidth();
+ sal_Bool bOutWidth = sal_True; //nColSpan==1 && pCol->GetOutWidth();
+
+ const SwStartNode* pSttNd = pBox->GetSttNd();
+ sal_Bool bHead = sal_False;
+ if( pSttNd )
+ {
+ sal_uInt32 nNdPos = pSttNd->GetIndex()+1;
+
+ // Art der Zelle (TD/TH) bestimmen
+ SwNode* pNd;
+ while( !( pNd = rWrt.pDoc->GetNodes()[nNdPos])->IsEndNode() )
+ {
+ if( pNd->IsTxtNode() )
+ {
+ // nur Absaetzte betrachten, an denen man was erkennt
+ // Das ist der Fall, wenn die Vorlage eine der Tabellen-Vorlagen
+ // ist oder von einer der beiden abgelitten ist.
+ const SwFmt *pFmt = &((SwTxtNode*)pNd)->GetAnyFmtColl();
+ sal_uInt16 nPoolId = pFmt->GetPoolFmtId();
+ while( !pFmt->IsDefault() &&
+ RES_POOLCOLL_TABLE_HDLN!=nPoolId &&
+ RES_POOLCOLL_TABLE!=nPoolId )
+ {
+ pFmt = pFmt->DerivedFrom();
+ nPoolId = pFmt->GetPoolFmtId();
+ }
+
+ if( !pFmt->IsDefault() )
+ {
+ bHead = (RES_POOLCOLL_TABLE_HDLN==nPoolId);
+ break;
+ }
+ }
+ nNdPos++;
+ }
+ }
+
+ rWrt.OutNewLine(); // <TH>/<TD> in neue Zeile
+ ByteString sOut( '<' );
+ sOut += (bHead ? sHTML_tableheader : sHTML_tabledata );
+
+ // ROW- und COLSPAN ausgeben
+ if( nRowSpan>1 )
+ (((sOut += ' ' ) += sHTML_O_rowspan ) += '=')
+ += ByteString::CreateFromInt32( nRowSpan );
+ if( nColSpan > 1 )
+ (((sOut += ' ' ) += sHTML_O_colspan ) += '=')
+ += ByteString::CreateFromInt32( nColSpan );
+
+#ifndef PURE_HTML
+ long nWidth = 0;
+ sal_uInt16 nPrcWidth = USHRT_MAX;
+ if( bOutWidth )
+ {
+ if( bLayoutExport )
+ {
+ if( pCell->HasPrcWidthOpt() )
+ {
+ nPrcWidth = pCell->GetWidthOpt();
+ }
+ else
+ {
+ nWidth = pCell->GetWidthOpt();
+ if( !nWidth )
+ bOutWidth = sal_False;
+ }
+ }
+ else
+ {
+ if( HasRelWidths() )
+ nPrcWidth = (sal_uInt16)GetPrcWidth(nCol,nColSpan);
+ else
+ nWidth = GetAbsWidth( nCol, nColSpan );
+ }
+ }
+
+ long nHeight = pCell->GetHeight() > 0
+ ? GetAbsHeight( pCell->GetHeight(), nRow, nRowSpan )
+ : 0;
+ Size aPixelSz( nWidth, nHeight );
+
+ // WIDTH ausgeben (Grrr: nur fuer Netscape)
+ if( (aPixelSz.Width() || aPixelSz.Height()) && Application::GetDefaultDevice() )
+ {
+ Size aOldSz( aPixelSz );
+ aPixelSz = Application::GetDefaultDevice()->LogicToPixel( aPixelSz,
+ MapMode(MAP_TWIP) );
+ if( aOldSz.Width() && !aPixelSz.Width() )
+ aPixelSz.Width() = 1;
+ if( aOldSz.Height() && !aPixelSz.Height() )
+ aPixelSz.Height() = 1;
+ }
+
+ // WIDTH ausgeben: Aus Layout oder berechnet
+ if( bOutWidth )
+ {
+ ((sOut += ' ' ) += sHTML_O_width ) += '=';
+ if( nPrcWidth != USHRT_MAX )
+ (sOut += ByteString::CreateFromInt32(nPrcWidth)) += '%';
+ else
+ sOut += ByteString::CreateFromInt32(aPixelSz.Width());
+ if( !bLayoutExport && nColSpan==1 )
+ pCol->SetOutWidth( sal_False );
+ }
+
+ if( nHeight )
+ {
+ (((sOut += ' ') += sHTML_O_height) += '=')
+ += ByteString::CreateFromInt32(aPixelSz.Height());
+ }
+#endif
+
+ const SfxItemSet& rItemSet = pBox->GetFrmFmt()->GetAttrSet();
+ const SfxPoolItem *pItem;
+
+ // ALIGN wird jetzt nur noch an den Absaetzen ausgegeben
+
+ // VALIGN ausgeben
+ if( bOutVAlign )
+ {
+ SwVertOrient eVertOri = pCell->GetVertOri();
+ if( VERT_TOP==eVertOri || VERT_BOTTOM==eVertOri )
+ {
+ (((sOut += ' ') += sHTML_O_valign) += '=')
+ += (VERT_TOP==eVertOri ? sHTML_VA_top : sHTML_VA_bottom);
+ }
+ }
+
+ rWrt.Strm() << sOut.GetBuffer();
+ sOut.Erase();
+
+ rWrt.bTxtAttr = sal_False;
+ rWrt.bOutOpts = sal_True;
+ const SvxBrushItem *pBrushItem = 0;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
+ {
+ pBrushItem = (const SvxBrushItem *)pItem;
+ }
+ if( !pBrushItem )
+ pBrushItem = pCell->GetBackground();
+
+ if( pBrushItem )
+ {
+ // Hintergrund ausgeben
+ String aDummy;
+ rWrt.OutBackground( pBrushItem, aDummy, sal_False );
+
+ if( rWrt.bCfgOutStyles )
+ OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
+ }
+
+ sal_uInt32 nNumFmt;
+ double nValue = 0.0;
+ sal_Bool bNumFmt = sal_False, bValue = sal_False;
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BOXATR_FORMAT, sal_False, &pItem ) )
+ {
+ nNumFmt = ((const SwTblBoxNumFormat *)pItem)->GetValue();
+ bNumFmt = sal_True;
+ }
+ if( SFX_ITEM_SET==rItemSet.GetItemState( RES_BOXATR_VALUE, sal_False, &pItem ) )
+ {
+ nValue = ((const SwTblBoxValue *)pItem)->GetValue();
+ bValue = sal_True;
+ if( !bNumFmt )
+ nNumFmt = pBox->GetFrmFmt()->GetTblBoxNumFmt().GetValue();
+ }
+
+ if( bNumFmt || bValue )
+ sOut = HTMLOutFuncs::CreateTableDataOptionsValNum( sOut,
+ bValue, nValue, nNumFmt, *rWrt.pDoc->GetNumberFormatter(),
+ rWrt.eDestEnc );
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+ rWrt.bLFPossible = sal_True;
+
+ rWrt.IncIndentLevel(); // den Inhalt von <TD>...</TD> einruecken
+
+ if( pSttNd )
+ {
+ HTMLSaveData aSaveData( rWrt, pSttNd->GetIndex()+1,
+ pSttNd->EndOfSectionIndex(),
+ rWrt.GetFlyFrmFmt() );
+ rWrt.Out_SwDoc( rWrt.pCurPam );
+// rWrt.ChangeParaToken( 0 ); // MIB 8.7.97: Passiert jetzt in Out_SwDoc
+ }
+ else
+ {
+ sal_uInt16 nTWidth, nBWidth, nLSub, nRSub;
+ if( HasRelWidths() )
+ {
+ nTWidth = 100;
+ nBWidth = GetRawWidth( nCol, nColSpan );
+ nLSub = 0;
+ nRSub = 0;
+ }
+ else
+ {
+ nTWidth = GetAbsWidth( nCol, nColSpan );
+ nBWidth = nTWidth;
+ nLSub = GetLeftSpace( nCol );
+ nRSub = GetRightSpace( nCol, nColSpan );
+ }
+
+ SwHTMLWrtTable aTableWrt( pBox->GetTabLines(), nTWidth,
+ nBWidth, HasRelWidths(), nLSub, nRSub );
+ aTableWrt.Write( rWrt );
+ }
+
+ rWrt.DecIndentLevel(); // den Inhalt von <TD>...</TD> einruecken
+
+ if( rWrt.bLFPossible )
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), bHead ? sHTML_tableheader
+ : sHTML_tabledata,
+ sal_False );
+ rWrt.bLFPossible = sal_True;
+}
+
+
+// Eine Line als Zeilen ausgeben
+void SwHTMLWrtTable::OutTableCells( SwHTMLWriter& rWrt,
+ const SwWriteTableCells& rCells,
+ const SvxBrushItem *pBrushItem ) const
+{
+ // Wenn die Zeile mehr als eine Zelle nethaelt und alle Zellen
+ // die gleiche Ausrichtung besitzen, das VALIGN an der Zeile statt der
+ // Zelle ausgeben
+ SwVertOrient eRowVertOri = VERT_NONE;
+ if( rCells.Count() > 1 )
+ {
+ for( sal_uInt16 nCell = 0; nCell<rCells.Count(); nCell++ )
+ {
+ SwVertOrient eCellVertOri = rCells[nCell]->GetVertOri();
+ if( 0==nCell )
+ {
+ eRowVertOri = eCellVertOri;
+ }
+ else if( eRowVertOri != eCellVertOri )
+ {
+ eRowVertOri = VERT_NONE;
+ break;
+ }
+ }
+ }
+
+ rWrt.OutNewLine(); // <TR> in neuer Zeile
+ rWrt.Strm() << '<' << sHTML_tablerow;
+ if( pBrushItem )
+ {
+ String aDummy;
+ rWrt.OutBackground( pBrushItem, aDummy, sal_False );
+
+ rWrt.bTxtAttr = sal_False;
+ rWrt.bOutOpts = sal_True;
+ if( rWrt.bCfgOutStyles )
+ OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
+ }
+
+ if( VERT_TOP==eRowVertOri || VERT_BOTTOM==eRowVertOri )
+ {
+ ByteString sOut( ' ' );
+ ((sOut += sHTML_O_valign) += '=')
+ += (VERT_TOP==eRowVertOri ? sHTML_VA_top : sHTML_VA_bottom);
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+
+ rWrt.Strm() << '>';
+
+ rWrt.IncIndentLevel(); // Inhalt von <TR>...</TR> einruecken
+
+ for( sal_uInt16 nCell = 0; nCell<rCells.Count(); nCell++ )
+ OutTableCell( rWrt, rCells[nCell], VERT_NONE==eRowVertOri );
+
+ rWrt.DecIndentLevel(); // Inhalt von <TR>...</TR> einruecken
+
+ rWrt.OutNewLine(); // </TR> in neuer Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_tablerow, sal_False );
+}
+
+
+
+void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, SwHoriOrient eAlign,
+ sal_Bool bTHead, const SwFrmFmt *pFrmFmt,
+ const String *pCaption, sal_Bool bTopCaption,
+ sal_uInt16 nHSpace, sal_uInt16 nVSpace ) const
+{
+ sal_uInt16 nRow;
+
+ // Wert fuer FRAME bestimmen
+ sal_uInt16 nFrameMask = 15;
+ if( !(aRows[0])->bTopBorder )
+ nFrameMask &= ~1;
+ if( !(aRows[aRows.Count()-1])->bBottomBorder )
+ nFrameMask &= ~2;
+ if( !(aCols[0])->bLeftBorder )
+ nFrameMask &= ~4;
+ if( !(aCols[aCols.Count()-1])->bRightBorder )
+ nFrameMask &= ~8;
+
+ // Wert fur RULES bestimmen
+ sal_Bool bRowsHaveBorder = sal_False;
+ sal_Bool bRowsHaveBorderOnly = sal_True;
+ SwWriteTableRow *pRow = aRows[0];
+ for( nRow=1; nRow < aRows.Count(); nRow++ )
+ {
+ SwWriteTableRow *pNextRow = aRows[nRow];
+ sal_Bool bBorder = ( pRow->bBottomBorder || pNextRow->bTopBorder );
+ bRowsHaveBorder |= bBorder;
+ bRowsHaveBorderOnly &= bBorder;
+
+ sal_uInt16 nBorder = pRow->bBottomBorder ? pRow->nBottomBorder : USHRT_MAX;
+ if( pNextRow->bTopBorder && pNextRow->nTopBorder < nBorder )
+ nBorder = pNextRow->nTopBorder;
+
+ pRow->bBottomBorder = bBorder;
+ pRow->nBottomBorder = nBorder;
+
+ pNextRow->bTopBorder = bBorder;
+ pNextRow->nTopBorder = nBorder;
+
+ pRow = pNextRow;
+ }
+
+ sal_Bool bColsHaveBorder = sal_False;
+ sal_Bool bColsHaveBorderOnly = sal_True;
+ SwWriteTableCol *pCol = aCols[0];
+ sal_uInt16 nCol;
+ for( nCol=1; nCol<aCols.Count(); nCol++ )
+ {
+ SwWriteTableCol *pNextCol = aCols[nCol];
+ sal_Bool bBorder = ( pCol->bRightBorder || pNextCol->bLeftBorder );
+ bColsHaveBorder |= bBorder;
+ bColsHaveBorderOnly &= bBorder;
+ pCol->bRightBorder = bBorder;
+ pNextCol->bLeftBorder = bBorder;
+ pCol = pNextCol;
+ }
+
+
+ // vorhergende Aufzaehlung etc. beenden
+ rWrt.ChangeParaToken( 0 );
+
+ if( rWrt.bLFPossible )
+ rWrt.OutNewLine(); // <TABLE> in neue Zeile
+ ByteString sOut( '<' );
+ sOut += sHTML_table;
+
+ // COLS ausgeben: Nur bei Export ueber Layout, wenn es beim Import
+ // vorhanden war.
+ if( bColsOption )
+ (((sOut += ' ') += sHTML_O_cols) += '=')
+ += ByteString::CreateFromInt32( aCols.Count() );
+
+ // ALIGN= ausgeben
+ if( HORI_RIGHT == eAlign )
+ (((sOut += ' ') += sHTML_O_align ) += '=') += sHTML_AL_right;
+ else if( HORI_CENTER == eAlign )
+ (((sOut += ' ') += sHTML_O_align ) += '=') += sHTML_AL_center;
+ else if( HORI_LEFT == eAlign )
+ (((sOut += ' ') += sHTML_O_align ) += '=') += sHTML_AL_left;
+
+ // WIDTH ausgeben: Stammt aus Layout oder ist berechnet
+ if( nTabWidth )
+ {
+ ((sOut += ' ') += sHTML_O_width ) += '=';
+ if( HasRelWidths() )
+ (sOut += ByteString::CreateFromInt32( nTabWidth )) += '%';
+ else if( Application::GetDefaultDevice() )
+ {
+ long nPixWidth = Application::GetDefaultDevice()->LogicToPixel(
+ Size(nTabWidth,0), MapMode(MAP_TWIP) ).Width();
+ if( !nPixWidth )
+ nPixWidth = 1;
+
+ sOut += ByteString::CreateFromInt32( nPixWidth );
+ }
+ else
+ {
+ ASSERT( Application::GetDefaultDevice(), "kein Application-Window!?" );
+ sOut += "100%";
+ }
+ }
+
+ if( (nHSpace || nVSpace) && Application::GetDefaultDevice())
+ {
+ Size aPixelSpc =
+ Application::GetDefaultDevice()->LogicToPixel( Size(nHSpace,nVSpace),
+ MapMode(MAP_TWIP) );
+ if( !aPixelSpc.Width() && nHSpace )
+ aPixelSpc.Width() = 1;
+ if( !aPixelSpc.Height() && nVSpace )
+ aPixelSpc.Height() = 1;
+
+ if( aPixelSpc.Width() )
+ {
+ (((sOut += ' ') += sHTML_O_hspace) += '=')
+ += ByteString::CreateFromInt32( aPixelSpc.Width() );
+ }
+
+ if( aPixelSpc.Height() )
+ {
+ (((sOut += ' ') += sHTML_O_vspace) += '=')
+ += ByteString::CreateFromInt32( aPixelSpc.Height() );
+ }
+ }
+
+ // BORDER ausgeben, aber nur wenn wir die Umrandung selbst berechnet
+ // haben oder die Umrandung 0 ist oder es irgendwelche Umrandungen gibt.
+ // Anderenfalls enthaelt nBorder naemlich nur die Breite der Umrandung,
+ // die genutzt wird, wenn gar kein ::com::sun::star::sheet::Border angegeben ist.
+ sal_Bool bHasAnyBorders = nFrameMask || bColsHaveBorder || bRowsHaveBorder;
+ if( bCollectBorderWidth || nBorder==0 || bHasAnyBorders )
+ (((sOut += ' ' ) += sHTML_O_border ) += '=')
+ += ByteString::CreateFromInt32( rWrt.ToPixel( nBorder ) );
+
+ // BORDERCOLOR ausgeben
+
+ if( (sal_uInt32)-1 != nBorderColor && rWrt.bCfgOutStyles && bHasAnyBorders )
+ {
+ ((sOut += ' ' ) += sHTML_O_bordercolor ) += '=';
+ rWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( rWrt.Strm(), nBorderColor );
+ sOut.Erase();
+ }
+
+ // CELLPADDING ausgeben: Stammt aus Layout oder ist berechnet
+ (((sOut += ' ' ) += sHTML_O_cellpadding ) += '=')
+ += ByteString::CreateFromInt32( rWrt.ToPixel( nCellPadding ) );
+
+ // CELLSPACING ausgeben: Stammt aus Layout oder ist berechnet
+ (((sOut += ' ' ) += sHTML_O_cellspacing ) += '=')
+ += ByteString::CreateFromInt32( rWrt.ToPixel( nCellSpacing ) );
+
+ // FRAME/RULES ausgeben (nur sinnvoll, wenn border!=0)
+ if( nBorder!=0 && (bCollectBorderWidth || bHasAnyBorders) )
+ {
+ const sal_Char *pFrame = 0;
+ switch( nFrameMask )
+ {
+ case 0: pFrame = sHTML_TF_void ;break;
+ case 1: pFrame = sHTML_TF_above ;break;
+ case 2: pFrame = sHTML_TF_below ;break;
+ case 3: pFrame = sHTML_TF_hsides ;break;
+ case 4: pFrame = sHTML_TF_lhs ;break;
+ case 8: pFrame = sHTML_TF_rhs ;break;
+ case 12: pFrame = sHTML_TF_vsides ;break;
+ //FRAME=BOX ist der default wenn BORDER>0
+ //case 15:
+ //default: pFrame = sHTML_TF_box ;break; // geht nicht
+ };
+ if( pFrame )
+ (((sOut += ' ' ) += sHTML_O_frame ) += '=') += pFrame;
+
+ const sal_Char *pRules = 0;
+ if( aCols.Count() > 1 && aRows.Count() > 1 )
+ {
+ if( !bColsHaveBorder )
+ {
+ if( !bRowsHaveBorder )
+ pRules = sHTML_TR_none;
+ else if( bRowsHaveBorderOnly )
+ pRules = sHTML_TR_rows;
+ else
+ pRules = sHTML_TR_groups;
+ }
+ else if( bColsHaveBorderOnly )
+ {
+ if( !bRowsHaveBorder || !bRowsHaveBorderOnly )
+ pRules = sHTML_TR_cols;
+ }
+ else
+ {
+ if( !bRowsHaveBorder )
+ pRules = sHTML_TR_groups;
+ else if( bRowsHaveBorderOnly )
+ pRules = sHTML_TR_rows;
+ else
+ pRules = sHTML_TR_groups;
+ }
+ }
+ else if( aRows.Count() > 1 )
+ {
+ if( !bRowsHaveBorder )
+ pRules = sHTML_TR_none;
+ else if( !bRowsHaveBorderOnly )
+ pRules = sHTML_TR_groups;
+ }
+ else if( aCols.Count() > 1 )
+ {
+ if( !bColsHaveBorder )
+ pRules = sHTML_TR_none;
+ else if( !bColsHaveBorderOnly )
+ pRules = sHTML_TR_groups;
+ }
+
+ if( pRules )
+ (((sOut += ' ' ) += sHTML_O_rules ) += '=') += pRules;
+ }
+ rWrt.Strm() << sOut.GetBuffer();
+
+ // Hintergrund ausgeben
+ if( pFrmFmt )
+ {
+ String aDummy;
+ rWrt.OutBackground( pFrmFmt->GetAttrSet(), aDummy, sal_False );
+
+ if( rWrt.bCfgOutStyles && pFrmFmt )
+ rWrt.OutCSS1_TableFrmFmtOptions( *pFrmFmt );
+ }
+
+ sOut = '>';
+ rWrt.Strm() << sOut.GetBuffer();
+
+ rWrt.IncIndentLevel(); // Inhalte von Table einruecken
+
+ // Ueberschrift ausgeben
+ if( pCaption && pCaption->Len() )
+ {
+ rWrt.OutNewLine(); // <CAPTION> in neue Zeile
+ ByteString sOut( sHTML_caption );
+ (((sOut += ' ') += sHTML_O_align) += '=')
+ += (bTopCaption ? sHTML_VA_top : sHTML_VA_bottom);
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sOut.GetBuffer(), sal_True );
+ HTMLOutFuncs::Out_String( rWrt.Strm(), *pCaption, rWrt.eDestEnc );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_caption, sal_False );
+ }
+
+ sal_uInt16 nCols = aCols.Count();
+
+ // <COLGRP>/<COL> ausgeben: Bei Export ueber Layout nur wenn beim
+ // Import welche da waren, sonst immer.
+ sal_Bool bColGroups = (bColsHaveBorder && !bColsHaveBorderOnly);
+ if( bColTags )
+ {
+ if( bColGroups )
+ {
+ rWrt.OutNewLine(); // <COLGRP> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_colgroup, sal_True );
+
+ rWrt.IncIndentLevel(); // Inhalt von <COLGRP> einruecken
+ }
+
+ for( nCol=0; nCol<nCols; nCol++ )
+ {
+ rWrt.OutNewLine(); // <COL> in neue Zeile
+
+ const SwWriteTableCol *pCol = aCols[nCol];
+
+ ByteString sOut( '<' );
+ sOut += sHTML_col;
+
+ sal_uInt16 nWidth;
+ sal_Bool bRel;
+ if( bLayoutExport )
+ {
+ bRel = pCol->HasRelWidthOpt();
+ nWidth = pCol->GetWidthOpt();
+ }
+ else
+ {
+ bRel = HasRelWidths();
+ nWidth = bRel ? GetRelWidth(nCol,1) : GetAbsWidth(nCol,1);
+ }
+
+ ((sOut += ' ' ) += sHTML_O_width ) += '=';
+ if( bRel )
+ {
+ (sOut += ByteString::CreateFromInt32( nWidth ) ) += '*';
+ }
+ else
+ {
+ sOut += ByteString::CreateFromInt32( rWrt.ToPixel( nWidth ) );
+ }
+ sOut += '>';
+ rWrt.Strm() << sOut.GetBuffer();
+
+ if( bColGroups && pCol->bRightBorder && nCol<nCols-1 )
+ {
+ rWrt.DecIndentLevel(); // Inhalt von <COLGRP> einruecken
+ rWrt.OutNewLine(); // </COLGRP> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_colgroup,
+ sal_False );
+ rWrt.OutNewLine(); // <COLGRP> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_colgroup,
+ sal_True );
+ rWrt.IncIndentLevel(); // Inhalt von <COLGRP> einruecken
+ }
+ }
+ if( bColGroups )
+ {
+ rWrt.DecIndentLevel(); // Inhalt von <COLGRP> einruecken
+
+ rWrt.OutNewLine(); // </COLGRP> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_colgroup,
+ sal_False );
+ }
+ }
+
+ // die Lines als Tabellenzeilen rausschreiben
+
+ // <TBODY> ausgeben?
+ sal_Bool bTSections = (bRowsHaveBorder && !bRowsHaveBorderOnly);
+ sal_Bool bTBody = bTSections;
+
+ // Wenn Sections ausgegeben werden muessen darf ein THEAD um die erste
+ // Zeile nur ausgegeben werden, wenn unter der Zeile eine Linie ist
+ if( bTHead &&
+ (bTSections || bColGroups) &&
+ nHeadEndRow<aRows.Count()-1 && !aRows[nHeadEndRow]->bBottomBorder )
+ bTHead = sal_False;
+
+ // <TBODY> aus ausgeben, wenn <THEAD> ausgegeben wird.
+ bTSections |= bTHead;
+
+ if( bTSections )
+ {
+ rWrt.OutNewLine(); // <THEAD>/<TDATA> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(),
+ bTHead ? sHTML_thead : sHTML_tbody, sal_True );
+
+ rWrt.IncIndentLevel(); // Inhalt von <THEAD>/<TDATA> einr.
+ }
+
+ for( nRow = 0; nRow < aRows.Count(); nRow++ )
+ {
+ const SwWriteTableRow *pRow = aRows[nRow];
+ const SwWriteTableCells& rCells = pRow->GetCells();
+
+ OutTableCells( rWrt, pRow->GetCells(), pRow->GetBackground() );
+ if( !nCellSpacing && nRow < aRows.Count()-1 && pRow->bBottomBorder &&
+ pRow->nBottomBorder > DEF_LINE_WIDTH_1 )
+ {
+ sal_uInt16 nCnt = (pRow->nBottomBorder / DEF_LINE_WIDTH_1) - 1;
+ for( ; nCnt; nCnt-- )
+ {
+ rWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_tablerow,
+ sal_True );
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_tablerow,
+ sal_False );
+ }
+ }
+ if( ( (bTHead && nRow==nHeadEndRow) ||
+ (bTBody && pRow->bBottomBorder) ) &&
+ nRow < aRows.Count()-1 )
+ {
+ rWrt.DecIndentLevel(); // Inhalt von <THEAD>/<TDATA> einr.
+ rWrt.OutNewLine(); // </THEAD>/</TDATA> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(),
+ bTHead ? sHTML_thead : sHTML_tbody, sal_False );
+ rWrt.OutNewLine(); // <THEAD>/<TDATA> in neue Zeile
+
+ if( bTHead && nRow==nHeadEndRow )
+ bTHead = sal_False;
+
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(),
+ bTHead ? sHTML_thead : sHTML_tbody, sal_True );
+ rWrt.IncIndentLevel(); // Inhalt von <THEAD>/<TDATA> einr.
+ }
+ }
+
+ if( bTSections )
+ {
+ rWrt.DecIndentLevel(); // Inhalt von <THEAD>/<TDATA> einr.
+
+ rWrt.OutNewLine(); // </THEAD>/</TDATA> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(),
+ bTHead ? sHTML_thead : sHTML_tbody, sal_False );
+ }
+
+ rWrt.DecIndentLevel(); // Inhalt von <TABLE> einr.
+
+ rWrt.OutNewLine(); // </TABLE> in neue Zeile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_table, sal_False );
+}
+
+Writer& OutHTML_SwTblNode( Writer& rWrt, SwTableNode & rNode,
+ const SwFrmFmt *pFlyFrmFmt,
+ const String *pCaption, sal_Bool bTopCaption )
+{
+
+ SwTable& rTbl = rNode.GetTable();
+
+ SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+ rHTMLWrt.bOutTable = sal_True;
+
+ // die horizontale Ausrichtung des Rahmens hat (falls vorhanden)
+ // Prioritaet. NONE bedeutet, dass keine horizontale
+ // Ausrichtung geschrieben wird.
+ SwHoriOrient eFlyHoriOri = HORI_NONE;
+ SwSurround eSurround = SURROUND_NONE;
+ sal_uInt8 nFlyPrcWidth = 0;
+ long nFlyWidth;
+ sal_uInt16 nFlyHSpace = 0;
+ sal_uInt16 nFlyVSpace = 0;
+ if( pFlyFrmFmt )
+ {
+ eSurround = pFlyFrmFmt->GetSurround().GetSurround();
+ const SwFmtFrmSize& rFrmSize = pFlyFrmFmt->GetFrmSize();
+ nFlyPrcWidth = rFrmSize.GetWidthPercent();
+ nFlyWidth = rFrmSize.GetSize().Width();
+
+ eFlyHoriOri = pFlyFrmFmt->GetHoriOrient().GetHoriOrient();
+ if( HORI_NONE == eFlyHoriOri )
+ eFlyHoriOri = HORI_LEFT;
+
+ const SvxLRSpaceItem& rLRSpace = pFlyFrmFmt->GetLRSpace();
+ nFlyHSpace = (rLRSpace.GetLeft() + rLRSpace.GetRight()) / 2;
+
+ const SvxULSpaceItem& rULSpace = pFlyFrmFmt->GetULSpace();
+ nFlyVSpace = (rULSpace.GetUpper() + rULSpace.GetLower()) / 2;
+ }
+
+ // ggf. eine FORM oeffnen
+ sal_Bool bPreserveForm = sal_False;
+ if( !rHTMLWrt.bPreserveForm )
+ {
+ rHTMLWrt.OutForm( sal_True, &rNode );
+ bPreserveForm = (rHTMLWrt.pxFormComps && rHTMLWrt.pxFormComps->is() );
+ rHTMLWrt.bPreserveForm = bPreserveForm;
+ }
+
+ SwFrmFmt *pFmt = rTbl.GetFrmFmt();
+
+ const SwFmtFrmSize& rFrmSize = pFmt->GetFrmSize();
+ long nWidth = rFrmSize.GetSize().Width();
+ sal_uInt8 nPrcWidth = rFrmSize.GetWidthPercent();
+ sal_uInt16 nBaseWidth = (sal_uInt16)nWidth;
+
+ SwHoriOrient eTabHoriOri = pFmt->GetHoriOrient().GetHoriOrient();
+
+ // HORI_NONE und HORI_FULL Tabellen benoetigen relative Breiten
+ sal_uInt16 nNewDefListLvl = 0;
+ sal_Bool bRelWidths = sal_False;
+ sal_Bool bCheckDefList = sal_False;
+ switch( eTabHoriOri )
+ {
+ case HORI_FULL:
+ // Tabellen mit automatischer Ausrichtung werden zu Tabellen
+ // mit 100%-Breite
+ bRelWidths = sal_True;
+ nWidth = 100;
+ eTabHoriOri = HORI_LEFT;
+ break;
+ case HORI_NONE:
+ {
+ const SvxLRSpaceItem& aLRItem = pFmt->GetLRSpace();
+ if( aLRItem.GetRight() )
+ {
+ // Die Tabellenbreite wird anhand des linken und rechten
+ // Abstandes bestimmt. Deshalb versuchen wir die
+ // tatsaechliche Breite der Tabelle zu bestimmen. Wenn
+ // das nicht geht, machen wir eine 100% breite Tabelle
+ // draus.
+ nWidth = pFmt->FindLayoutRect(sal_True).Width();
+ if( !nWidth )
+ {
+ bRelWidths = sal_True;
+ nWidth = 100;
+ }
+
+ }
+ else if( nPrcWidth )
+ {
+ // Ohne rechten Rand bleibt die %-Breite erhalten
+ nWidth = nPrcWidth;
+ bRelWidths = sal_True;
+ }
+ else
+ {
+ // Ohne rechten Rand bleibt auch eine absolute Breite erhalten
+ // Wir versuchen aber trotzdem ueber das Layout die
+ // tatsachliche Breite zu ermitteln.
+ long nRealWidth = pFmt->FindLayoutRect(sal_True).Width();
+ if( nRealWidth )
+ nWidth = nRealWidth;
+ }
+ bCheckDefList = sal_True;
+ }
+ break;
+ case HORI_LEFT_AND_WIDTH:
+ eTabHoriOri = HORI_LEFT;
+ bCheckDefList = sal_True;
+ // no break
+ default:
+ // In allen anderen Faellen kann eine absolute oder relative
+ // Breite direkt uebernommen werden.
+ if( nPrcWidth )
+ {
+ bRelWidths = sal_True;
+ nWidth = nPrcWidth;
+ }
+ break;
+ }
+
+ if( bCheckDefList )
+ {
+ ASSERT( !rHTMLWrt.GetNumInfo().GetNumRule() ||
+ rHTMLWrt.GetNextNumInfo(),
+ "NumInfo fuer naechsten Absatz fehlt!" );
+ const SvxLRSpaceItem& aLRItem = pFmt->GetLRSpace();
+ if( aLRItem.GetLeft() &&
+ ( !rHTMLWrt.GetNumInfo().GetNumRule() ||
+ ( rHTMLWrt.GetNextNumInfo() &&
+ (rHTMLWrt.GetNextNumInfo()->IsRestart() ||
+ rHTMLWrt.GetNumInfo().GetNumRule() !=
+ rHTMLWrt.GetNextNumInfo()->GetNumRule()) ) ) )
+ {
+ // Wenn der Absatz vor der Tabelle nicht numeriert ist oder
+ // der Absatz nach der Tabelle mit einer anderen oder
+ // (gar keiner) Regel numeriert ist, koennen wir
+ // die Einrueckung ueber eine DL regeln. Sonst behalten wir
+ // die Einrueckung der Numerierung bei.
+ nNewDefListLvl =
+ (aLRItem.GetLeft() + (rHTMLWrt.nDefListMargin/2)) /
+ rHTMLWrt.nDefListMargin;
+ }
+ }
+
+ if( !pFlyFrmFmt && nNewDefListLvl != rHTMLWrt.nDefListLvl )
+ rHTMLWrt.OutAndSetDefList( nNewDefListLvl );
+
+ if( nNewDefListLvl )
+ {
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_dd );
+ }
+
+ // eFlyHoriOri und eTabHoriOri besitzen nun nur noch die Werte
+ // LEFT/CENTER und RIGHT!
+ if( eFlyHoriOri!=HORI_NONE )
+ {
+ eTabHoriOri = eFlyHoriOri;
+ // MIB 4.7.97: Wenn die Tabelle eine relative Breite besitzt,
+ // dann richtet sich ihre Breite nach der des Rahmens, also
+ // exportieren wir dessen Breite. Bei fixer Breite ist die Breite
+ // der Tabelle massgeblich. Wer Tabellen mit relativer Breite <100%
+ // in Rahmen steckt, ist selber schuld wenn nix Gutes bei rauskommt.
+ if( bRelWidths )
+ {
+ nWidth = nFlyPrcWidth ? nFlyPrcWidth : nFlyWidth;
+ bRelWidths = nFlyPrcWidth > 0;
+ }
+ }
+
+ SwHoriOrient eDivHoriOri = HORI_NONE;
+ switch( eTabHoriOri )
+ {
+ case HORI_LEFT:
+ // Wenn eine linksbuendigeTabelle keinen rechtsseiigen Durchlauf
+ // hat, brauchen wir auch kein ALIGN=LEFT in der Tabelle.
+ if( eSurround==SURROUND_NONE || eSurround==SURROUND_LEFT )
+ eTabHoriOri = HORI_NONE;
+ break;
+ case HORI_RIGHT:
+ // Aehnliches gilt fuer rechtsbuendigeTabelle, hier nehmen wir
+ // stattdessen ein <DIV ALIGN=RIGHT>.
+ if( eSurround==SURROUND_NONE || eSurround==SURROUND_RIGHT )
+ {
+ eDivHoriOri = HORI_RIGHT;
+ eTabHoriOri = HORI_NONE;
+ }
+ break;
+ case HORI_CENTER:
+ // ALIGN=CENTER versteht so gut wie keiner, deshalb verzichten wir
+ // daruf und nehmen ein <CENTER>.
+ eDivHoriOri = HORI_CENTER;
+ eTabHoriOri = HORI_NONE;
+ break;
+ }
+ if( HORI_NONE==eTabHoriOri )
+ nFlyHSpace = nFlyVSpace = 0;
+
+ if( pFmt->GetName().Len() )
+ rHTMLWrt.OutImplicitMark( pFmt->GetName(), pMarkToTable );
+
+ if( HORI_NONE!=eDivHoriOri )
+ {
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine(); // <CENTER> in neuer Zeile
+ if( HORI_CENTER==eDivHoriOri )
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sHTML_center, sal_True );
+ else
+ {
+ ByteString sOut( sHTML_division );
+ (((sOut += ' ') += sHTML_O_align) += '=') += sHTML_AL_right;
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), sOut.GetBuffer(),
+ sal_True );
+ }
+ rHTMLWrt.IncIndentLevel(); // Inhalt von <CENTER> einruecken
+ rHTMLWrt.bLFPossible = sal_True;
+ }
+
+ // Wenn die Tabelle in keinem Rahmen ist kann man immer ein LF ausgeben.
+ if( HORI_NONE==eTabHoriOri )
+ rHTMLWrt.bLFPossible = sal_True;
+
+ const SwHTMLTableLayout *pLayout = rTbl.GetHTMLTableLayout();
+
+#ifndef PRODUCT
+ ViewShell *pSh;
+ rWrt.pDoc->GetEditShell( &pSh );
+ if ( pSh && pSh->GetViewOptions()->IsTest1() )
+ pLayout = 0;
+#endif
+
+ if( pLayout && pLayout->IsExportable() )
+ {
+ SwHTMLWrtTable aTableWrt( pLayout );
+ aTableWrt.Write( rHTMLWrt, eTabHoriOri, rTbl.IsHeadlineRepeat(),
+ pFmt, pCaption, bTopCaption,
+ nFlyHSpace, nFlyVSpace );
+ }
+ else
+ {
+ SwHTMLWrtTable aTableWrt( rTbl.GetTabLines(), nWidth,
+ nBaseWidth, bRelWidths );
+ aTableWrt.Write( rHTMLWrt, eTabHoriOri, rTbl.IsHeadlineRepeat(),
+ pFmt, pCaption, bTopCaption,
+ nFlyHSpace, nFlyVSpace );
+ }
+
+ // Wenn die Tabelle in keinem Rahmen war kann man immer ein LF ausgeben.
+ if( HORI_NONE==eTabHoriOri )
+ rHTMLWrt.bLFPossible = sal_True;
+
+ if( HORI_NONE!=eDivHoriOri )
+ {
+ rHTMLWrt.DecIndentLevel(); // Inhalt von <CENTER> einruecken
+ rHTMLWrt.OutNewLine(); // </CENTER> in neue Teile
+ HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(),
+ HORI_CENTER==eDivHoriOri ? sHTML_center
+ : sHTML_division, sal_False );
+ rHTMLWrt.bLFPossible = sal_True;
+ }
+
+ // Pam hinter die Tabelle verschieben
+ rHTMLWrt.pCurPam->GetPoint()->nNode = *rNode.EndOfSectionNode();
+
+ if( bPreserveForm )
+ {
+ rHTMLWrt.bPreserveForm = sal_False;
+ rHTMLWrt.OutForm( sal_False );
+ }
+
+ rHTMLWrt.bOutTable = sal_False;
+
+ if( rHTMLWrt.GetNextNumInfo() &&
+ !rHTMLWrt.GetNextNumInfo()->IsRestart() &&
+ rHTMLWrt.GetNextNumInfo()->GetNumRule() ==
+ rHTMLWrt.GetNumInfo().GetNumRule() )
+ {
+ // Wenn der Absatz hinter der Tabelle mit der gleichen Regel
+ // numeriert ist wie der Absatz vor der Tabelle, dann steht in
+ // der NumInfo des naechsten Absatzes noch die Ebene des Absatzes
+ // vor der Tabelle. Es muss deshalb die NumInfo noch einmal geholt
+ // werden um ggf. die Num-Liste noch zu beenden.
+ rHTMLWrt.ClearNextNumInfo();
+ rHTMLWrt.FillNextNumInfo();
+ OutHTML_NumBulListEnd( rHTMLWrt, *rHTMLWrt.GetNextNumInfo() );
+ }
+ return rWrt;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/htmltabw.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.60 2000/09/18 16:04:46 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.59 2000/06/26 09:52:33 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.58 2000/04/28 14:29:12 mib
+ unicode
+
+ Revision 1.57 2000/04/10 12:20:57 mib
+ unicode
+
+ Revision 1.56 2000/03/21 15:06:18 os
+ UNOIII
+
+ Revision 1.55 2000/03/03 15:21:01 os
+ StarView remainders removed
+
+ Revision 1.54 2000/02/11 14:37:33 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.53 2000/02/07 08:24:58 mib
+ #72727#: HORI_LEFT_AND_WIDTH
+
+ Revision 1.52 1999/11/19 16:40:20 os
+ modules renamed
+
+ Revision 1.51 1999/10/29 17:35:38 jp
+ export the class for build a '2D-Table' from a SwTable
+
+ Revision 1.50 1999/09/21 09:49:57 mib
+ multiple text encodings
+
+ Revision 1.49 1999/06/11 14:43:36 MIB
+ Individuelle Umrandungs-Abstaende
+
+
+ Rev 1.48 11 Jun 1999 16:43:36 MIB
+ Individuelle Umrandungs-Abstaende
+
+ Rev 1.47 10 Jun 1999 10:34:30 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.46 09 Jun 1999 19:37:04 JP
+ have to change: no cast from GetpApp to SfxApp/OffApp, SfxShell only subclass of SfxApp
+
+ Rev 1.45 22 Feb 1999 08:40:42 MA
+ 1949globale Shell entsorgt, Shells am RootFrm
+
+ Rev 1.44 25 Jan 1999 16:19:10 OS
+ #56371# TF_ONE51 - uebersetzbar
+
+ Rev 1.43 05 Jan 1999 14:48:04 MIB
+ #60429#: Zeilenhoehe korrekt berechnen
+
+ Rev 1.42 09 Nov 1998 11:40:30 MIB
+ #56461#: Keine Tabelle in Tabelle exportieren, wenn Hintergrund vorhanden
+
+ Rev 1.41 04 Nov 1998 15:04:26 MIB
+ #56461#: Keine Zellen mit Hintergrund als Tabelle in Tabelle exportieren
+
+ Rev 1.40 17 Sep 1998 16:28:36 MIB
+ CSS1-Export aufgeraeumt
+
+ Rev 1.39 10 Jun 1998 10:15:38 OS
+ Package-Umstellung
+
+ Rev 1.38 19 May 1998 14:47:30 MIB
+ VC-Controls raus, UNO-Controls rein
+
+ Rev 1.37 15 Apr 1998 14:57:56 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.36 08 Apr 1998 16:53:22 MIB
+ NumberForamtter-Value mit 0 initialsiert (vielleicht hilft's ja gegen #49395#)
+
+ Rev 1.35 19 Mar 1998 09:28:26 MIB
+ Rahmen-Export verbessert/aufgeraeumt
+
+ Rev 1.34 20 Feb 1998 19:01:52 MA
+ header
+
+ Rev 1.33 13 Feb 1998 19:11:50 HR
+ C42 (Solaris) wie ICC
+
+ Rev 1.32 19 Jan 1998 16:21:50 MIB
+ Numerierungs-Umbau
+
+ Rev 1.31 26 Nov 1997 19:09:46 MA
+ includes
+
+ Rev 1.30 09 Oct 1997 14:35:42 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.29 12 Sep 1997 11:16:24 OS
+ ITEMID_* definiert
+
+ Rev 1.28 29 Aug 1997 16:49:48 OS
+ DLL-Umstellung
+
+ Rev 1.27 15 Aug 1997 12:46:32 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.26 12 Aug 1997 13:42:56 OS
+ Header-Umstellung
+
+ Rev 1.25 07 Aug 1997 15:08:06 OM
+ Headerfile-Umstellung
+
+ Rev 1.24 22 Jul 1997 11:31:10 MIB
+ Zwei Zeilen vertauscht, wegen Opt-Fehler im OS/2 C-Set-Compiler
+
+ Rev 1.23 11 Jul 1997 13:34:18 MIB
+ VALIGN an Zeile ausgeben, wenn Ausr. an allen Zellen gleich, kein VALIGN=MIDDLE
+
+ Rev 1.22 11 Jul 1997 11:54:52 MIB
+ COLGROUP/TBODY nur wo wirklich noetig, FRAMES/RULES fuer einzeile/spaltige Tbls
+
+ Rev 1.21 11 Jul 1997 09:17:50 MIB
+ fix: BORDER/CELLSP bei nur innerer Umrandung, FRAME/RULES nur wenn noetig
+
+ Rev 1.20 11 Jul 1997 07:42:20 MIB
+ Rechts-ausgerichtete Tabellen (auch im Rahmen ohne Umlauf) durch DIV ausrichten
+
+ Rev 1.19 09 Jul 1997 08:46:08 MIB
+ Fix: Bei Export ueber Layout </THEAD> nach 1. nicht 2. Zeile
+
+ Rev 1.18 09 Jul 1997 08:15:30 MIB
+ Kein ALIGN=CENTER in mit <CENTER> zentrierten Tabellen
+
+ Rev 1.17 08 Jul 1997 18:10:44 MIB
+ fix: <PRE> vor Bereichen, spaltigen Rahmen und am Dokende beenden
+
+ Rev 1.16 04 Jul 1997 12:40:16 MIB
+ Verbess. Tbl. in Rahmen: Bei rel. Breite immmer die Rahmenbreite exportieren.
+
+ Rev 1.15 04 Jul 1997 09:23:12 MIB
+ fix: Beim Export ueber Layout kein BORDER ausgeben, wenn keine Umrandung ex.
+
+ Rev 1.14 30 Jun 1997 16:25:16 MIB
+ Die erste Box ohne Inhalt nie als Tabelle in Tabelle exportieren
+
+ Rev 1.13 30 Jun 1997 12:01:52 MIB
+ Tabellen ohne Umrandung immer als Tab in Tab exportieren
+
+ Rev 1.12 21 Jun 1997 12:40:08 MIB
+ Nach <TD> darf ein LF ausgegeben werden
+
+ Rev 1.11 17 Jun 1997 11:45:28 MIB
+ Sprungmarken fuer generierte Links in Verzeichnissen
+
+ Rev 1.10 12 Jun 1997 15:58:42 MIB
+ Ab bestimmter Tiefe Tabellen in Tabellen exportieren
+
+ Rev 1.9 11 Jun 1997 18:11:52 MIB
+ fix: Twip-Werte der Umrandung an Pixel-Breite anpassen
+
+ Rev 1.8 10 Jun 1997 09:49:20 TRI
+ Borland Anpassung
+
+ Rev 1.7 09 Jun 1997 09:35:14 MIB
+ bug fixes fuer Export ueber Layout
+
+ Rev 1.6 05 Jun 1997 17:44:12 MIB
+ Tabellen-Export ueber Layout
+
+ Rev 1.5 05 Jun 1997 11:25:50 MIB
+ keine inlines fuer Borland C
+
+ Rev 1.4 27 May 1997 12:58:40 TRI
+ PRODCT nach PRODUCT
+
+ Rev 1.3 06 May 1997 11:01:04 TRI
+ operatoren bei ICC nicht inline
+
+ Rev 1.2 24 Apr 1997 12:50:04 MIB
+ kleinere Verbesserungen
+
+ Rev 1.1 21 Apr 1997 11:27:58 MIB
+ jetzt mit Hoehenberechnung ueber Layout
+
+ Rev 1.0 19 Apr 1997 13:23:38 MIB
+ Initial revision.
+
+ Rev 1.178 14 Apr 1997 17:33:46 MIB
+ fix #36953#: Keine Tricks gegen Absatz-Abstaende im letzten Tabellen-Absatz
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/htmlvsh.hxx b/sw/source/filter/html/htmlvsh.hxx
new file mode 100644
index 000000000000..f500e738998a
--- /dev/null
+++ b/sw/source/filter/html/htmlvsh.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * $RCSfile: htmlvsh.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _HTMLVSH_HXX
+#define _HTMLVSH_HXX
+
+#ifndef _CALBCK_HXX
+#include <calbck.hxx>
+#endif
+class ViewShell;
+
+
+class SwHTMLViewShellClient : public SwClient
+{
+ virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
+
+public:
+
+ SwHTMLViewShellClient( ViewShell *pVSh );
+
+ virtual ~SwHTMLViewShellClient();
+
+ void Register( ViewShell *pVsh );
+ void DeRegister();
+
+ /*inline*/ ViewShell *GetViewShell(); // im swhtml.cxx
+};
+
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/makefile.mk b/sw/source/filter/html/makefile.mk
new file mode 100644
index 000000000000..43a1cd934faa
--- /dev/null
+++ b/sw/source/filter/html/makefile.mk
@@ -0,0 +1,138 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=html
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(mydebug)" != ""
+CDEFS=$(CDEFS) -Dmydebug
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ css1atr.cxx \
+ css1kywd.cxx \
+ htmlatr.cxx \
+ htmlbas.cxx \
+ htmlcss1.cxx \
+ htmlctxt.cxx \
+ htmldraw.cxx \
+ htmlfld.cxx \
+ htmlfldw.cxx \
+ htmlfly.cxx \
+ htmlflyt.cxx \
+ htmlform.cxx \
+ htmlforw.cxx \
+ htmlftn.cxx \
+ htmlgrin.cxx \
+ htmlnum.cxx \
+ htmlplug.cxx \
+ htmlsect.cxx \
+ htmltab.cxx \
+ htmltabw.cxx \
+ parcss1.cxx \
+ svxcss1.cxx \
+ swhtml.cxx \
+ wrthtml.cxx \
+
+SLOFILES = \
+ $(SLO)$/css1atr.obj \
+ $(SLO)$/css1kywd.obj \
+ $(SLO)$/htmlatr.obj \
+ $(SLO)$/htmlbas.obj \
+ $(SLO)$/htmlcss1.obj \
+ $(SLO)$/htmlctxt.obj \
+ $(SLO)$/htmldraw.obj \
+ $(SLO)$/htmlfld.obj \
+ $(SLO)$/htmlfldw.obj \
+ $(SLO)$/htmlfly.obj \
+ $(SLO)$/htmlflyt.obj \
+ $(SLO)$/htmlform.obj \
+ $(SLO)$/htmlforw.obj \
+ $(SLO)$/htmlftn.obj \
+ $(SLO)$/htmlgrin.obj \
+ $(SLO)$/htmlnum.obj \
+ $(SLO)$/htmlplug.obj \
+ $(SLO)$/htmlsect.obj \
+ $(SLO)$/htmltab.obj \
+ $(SLO)$/htmltabw.obj \
+ $(SLO)$/parcss1.obj \
+ $(SLO)$/svxcss1.obj \
+ $(SLO)$/swhtml.obj \
+ $(SLO)$/wrthtml.obj \
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/html/parcss1.cxx b/sw/source/filter/html/parcss1.cxx
new file mode 100644
index 000000000000..912cbddbd6ea
--- /dev/null
+++ b/sw/source/filter/html/parcss1.cxx
@@ -0,0 +1,1598 @@
+/*************************************************************************
+ *
+ * $RCSfile: parcss1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef _INTN_HXX //autogen
+#include <tools/intn.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_COLOR_HXX //autogen
+#include <vcl/color.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+
+
+
+#include "css1kywd.hxx"
+#include "parcss1.hxx"
+
+
+// Loop-Check: Um Endlos-Schleifen zu vermeiden, wird in jeder
+// Schalife geprueft, ob ein Fortschritt in der Eingabe-Position
+// stattgefunden hat
+#define LOOP_CHECK
+
+#ifdef LOOP_CHECK
+
+#define LOOP_CHECK_DECL \
+ xub_StrLen nOldInPos = STRING_MAXLEN;
+#define LOOP_CHECK_RESTART \
+ nOldInPos = STRING_MAXLEN;
+#define LOOP_CHECK_CHECK( where ) \
+ DBG_ASSERT( nOldInPos!=nInPos || cNextCh==(sal_Unicode)EOF, where ); \
+ if( nOldInPos==nInPos && cNextCh!=(sal_Unicode)EOF ) \
+ break; \
+ else \
+ nOldInPos = nInPos;
+
+#else
+
+#define LOOP_CHECK_DECL
+#define LOOP_CHECK_RESTART
+#define LOOP_CHECK_CHECK( where )
+
+#endif
+
+
+
+const sal_Int32 MAX_LEN = 1024;
+
+/* */
+
+void CSS1Parser::InitRead( const String& rIn )
+{
+ nlLineNr = 0;
+ nlLinePos = 0;
+
+ bWhiteSpace = TRUE; // Wenn noch nichts gelesen wurde ist das wie WS
+ bEOF = FALSE;
+ eState = CSS1_PAR_WORKING;
+ nValue = 0.;
+
+ aIn = rIn;
+ nInPos = 0;
+ cNextCh = GetNextChar();
+ nToken = GetNextToken();
+}
+
+sal_Unicode CSS1Parser::GetNextChar()
+{
+ if( nInPos >= aIn.Len() )
+ {
+ bEOF = TRUE;
+ return (sal_Unicode)EOF;
+ }
+
+ sal_Unicode c = aIn.GetChar( nInPos );
+ nInPos++;
+
+ if( c == '\n' )
+ {
+ IncLineNr();
+ SetLinePos( 1L );
+ }
+ else
+ IncLinePos();
+
+ return c;
+}
+
+/* */
+
+// Diese Funktion realisiert den in
+//
+// http://www.w3.orh/pub/WWW/TR/WD-css1.html
+// bzw. http://www.w3.orh/pub/WWW/TR/WD-css1-960220.html
+//
+// beschriebenen Scanner fuer CSS1. Es handelt sich um eine direkte
+// Umsetzung der dort beschriebenen Lex-Grammatik
+//
+CSS1Token CSS1Parser::GetNextToken()
+{
+ CSS1Token nRet = CSS1_NULL;
+ aToken.Erase();
+
+ do {
+ // Merken, ob davor White-Space gelesen wurde
+ BOOL bPrevWhiteSpace = bWhiteSpace;
+ bWhiteSpace = FALSE;
+
+ BOOL bNextCh = TRUE;
+ switch( cNextCh )
+ {
+ case '/': // COMMENT | '/'
+ {
+ cNextCh = GetNextChar();
+ if( '*' == cNextCh )
+ {
+ // COMMENT
+ cNextCh = GetNextChar();
+
+ BOOL bAsterix = FALSE;
+ while( !(bAsterix && '/'==cNextCh) && !IsEOF() )
+ {
+ bAsterix = ('*'==cNextCh);
+ cNextCh = GetNextChar();
+ }
+ }
+ else
+ {
+ // '/'
+ bNextCh = FALSE;
+ nRet = CSS1_SLASH;
+ }
+ }
+ break;
+
+ case '@': // '@import' | '@XXX'
+ {
+ cNextCh = GetNextChar();
+ if( ('A' <= cNextCh && cNextCh <= 'Z') ||
+ ('a' <= cNextCh && cNextCh <= 'z') )
+ {
+ // den naechsten Identifer scannen
+ ::rtl::OUStringBuffer sTmpBuffer( 32L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( ('A' <= cNextCh && cNextCh <= 'Z') ||
+ ('a' <= cNextCh && cNextCh <= 'z') ||
+ ('0' <= cNextCh && cNextCh <= '9') ||
+ '-'==cNextCh && !IsEOF() );
+
+ aToken += String(sTmpBuffer.makeStringAndClear());
+
+ // und schauen, ob wir ihn kennen
+ switch( aToken.GetChar(0) )
+ {
+ case 'i':
+ case 'I':
+ if( aToken.EqualsIgnoreCaseAscii(sCSS1_import) )
+ nRet = CSS1_IMPORT_SYM;
+ break;
+// /Feature: PrintExt
+ case 'p':
+ case 'P':
+ if( aToken.EqualsIgnoreCaseAscii(sCSS1_page) )
+ nRet = CSS1_PAGE_SYM;
+ break;
+// /Feature: PrintExt
+ }
+
+ // Fehlerbehandlung: '@ident' und alles bis
+ // zu einem Semikolon der dem Ende des folgenden
+ // Blocks ignorieren
+ if( CSS1_NULL==nRet )
+ {
+ aToken.Erase();
+ USHORT nBlockLvl = 0;
+ sal_Unicode cQuoteCh = 0;
+ BOOL bDone = FALSE, bEscape = FALSE;
+ while( !bDone && !IsEOF() )
+ {
+ BOOL bOldEscape = bEscape;
+ bEscape = FALSE;
+ switch( cNextCh )
+ {
+ case '{':
+ if( !cQuoteCh && !bOldEscape )
+ nBlockLvl++;;
+ break;
+ case ';':
+ if( !cQuoteCh && !bOldEscape )
+ bDone = nBlockLvl==0;
+ break;
+ case '}':
+ if( !cQuoteCh && !bOldEscape )
+ bDone = --nBlockLvl==0;
+ break;
+ case '\"':
+ case '\'':
+ if( !bOldEscape )
+ {
+ if( cQuoteCh )
+ {
+ if( cQuoteCh == cNextCh )
+ cQuoteCh = 0;
+ }
+ else
+ {
+ cQuoteCh = cNextCh;
+ }
+ }
+ break;
+ case '\\':
+ if( !bOldEscape )
+ bEscape = TRUE;
+ break;
+ }
+ cNextCh = GetNextChar();
+ }
+ }
+
+ bNextCh = FALSE;
+ }
+ }
+ break;
+
+ case '!': // '!' 'legal' | '!' 'important' | syntax error
+ {
+ // White Space ueberlesen
+ cNextCh = GetNextChar();
+ while( ( ' ' == cNextCh ||
+ (cNextCh >= 0x09 && cNextCh <= 0x0d) ) && !IsEOF() )
+ {
+ bWhiteSpace = TRUE;
+ cNextCh = GetNextChar();
+ }
+
+ if( 'i'==cNextCh || 'I'==cNextCh)
+ {
+ // den naechsten Identifer scannen
+ ::rtl::OUStringBuffer sTmpBuffer( 32L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( ('A' <= cNextCh && cNextCh <= 'Z') ||
+ ('a' <= cNextCh && cNextCh <= 'z') ||
+ ('0' <= cNextCh && cNextCh <= '9') ||
+ '-' == cNextCh && !IsEOF() );
+
+ aToken += String(sTmpBuffer.makeStringAndClear());
+
+ if( ('i'==aToken.GetChar(0) || 'I'==aToken.GetChar(0)) &&
+ aToken.EqualsIgnoreCaseAscii(sCSS1_important) )
+ {
+ // '!' 'important'
+ nRet = CSS1_IMPORTANT_SYM;
+ }
+ else
+ {
+ // Fehlerbehandlung: '!' ignorieren, IDENT nicht
+ nRet = CSS1_IDENT;
+ }
+
+ bWhiteSpace = FALSE;
+ bNextCh = FALSE;
+ }
+ else
+ {
+ // Fehlerbehandlung: '!' ignorieren
+ bNextCh = FALSE;
+ }
+ }
+ break;
+
+ case '\"':
+ case '\'': // STRING
+ {
+ // \... geht noch nicht!!!
+ sal_Unicode cQuoteChar = cNextCh;
+ cNextCh = GetNextChar();
+
+ ::rtl::OUStringBuffer sTmpBuffer( MAX_LEN );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( cQuoteChar != cNextCh && !IsEOF() );
+
+ aToken += String(sTmpBuffer.makeStringAndClear());
+
+ nRet = CSS1_STRING;
+ }
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': // NUMBER | PERCENTAGE | LENGTH
+ {
+ // die aktuelle Position retten
+ xub_StrLen nInPosSave = nInPos;
+ sal_Unicode cNextChSave = cNextCh;
+ sal_uInt32 nlLineNrSave = nlLineNr;
+ sal_uInt32 nlLinePosSave = nlLinePos;
+ BOOL bEOFSave = bEOF;
+
+ // erstmal versuchen eine Hex-Zahl zu scannen
+ ::rtl::OUStringBuffer sTmpBuffer( 16 );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( sTmpBuffer.getLength() < 7 &&
+ ( ('0'<=cNextCh && '9'>=cNextCh) ||
+ ('A'<=cNextCh && 'F'>=cNextCh) ||
+ ('a'<=cNextCh && 'f'>=cNextCh) ) &&
+ !IsEOF() );
+
+ if( sTmpBuffer.getLength()==6 )
+ {
+ // wir haben eine hexadezimale Farbe gefunden
+ aToken += String(sTmpBuffer.makeStringAndClear());
+ nRet = CSS1_HEXCOLOR;
+ bNextCh = FALSE;
+
+ break;
+ }
+
+ // sonst versuchen wir es mit einer Zahl
+ nInPos = nInPosSave;
+ cNextCh = cNextChSave;
+ nlLineNr = nlLineNrSave;
+ nlLinePos = nlLinePosSave;
+ bEOF = bEOFSave;
+
+ // erstmal die Zahl scannen
+ sTmpBuffer.setLength( 0L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( (('0'<=cNextCh && '9'>=cNextCh) || '.'==cNextCh) &&
+ !IsEOF() );
+
+ aToken += String(sTmpBuffer.makeStringAndClear());
+ nValue = aToken.ToDouble();
+
+ // White Space ueberlesen
+ while( ( ' ' == cNextCh ||
+ (cNextCh >= 0x09 && cNextCh <= 0x0d) ) && !IsEOF() )
+ {
+ bWhiteSpace = TRUE;
+ cNextCh = GetNextChar();
+ }
+
+ // und nun Schauen, ob es eine Einheit gibt
+ switch( cNextCh )
+ {
+ case '%': // PERCENTAGE
+ bWhiteSpace = FALSE;
+ nRet = CSS1_PERCENTAGE;
+ break;
+
+ case 'c':
+ case 'C': // LENGTH cm | LENGTH IDENT
+ case 'e':
+ case 'E': // LENGTH (em | ex) | LENGTH IDENT
+ case 'i':
+ case 'I': // LENGTH inch | LENGTH IDENT
+ case 'p':
+ case 'P': // LENGTH (pt | px | pc) | LENGTH IDENT
+ case 'm':
+ case 'M': // LENGTH mm | LENGTH IDENT
+ {
+ // die aktuelle Position retten
+ xub_StrLen nInPosSave = nInPos;
+ sal_Unicode cNextChSave = cNextCh;
+ ULONG nlLineNrSave = nlLineNr;
+ ULONG nlLinePosSave = nlLinePos;
+ BOOL bEOFSave = bEOF;
+
+ // den naechsten Identifer scannen
+ String aIdent;
+ ::rtl::OUStringBuffer sTmpBuffer( 64L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( ( ('A' <= cNextCh && cNextCh <= 'Z') ||
+ ('a' <= cNextCh && cNextCh <= 'z') ||
+ ('0' <= cNextCh && cNextCh <= '9') ||
+ '-'==cNextCh) && !IsEOF() );
+
+ aIdent += String(sTmpBuffer.makeStringAndClear());
+
+ // Ist es eine Einheit?
+ const sal_Char *pCmp1 = 0, *pCmp2 = 0, *pCmp3 = 0;
+ double nScale1 = 1., nScale2 = 1., nScale3 = 1.;
+ CSS1Token nToken1 = CSS1_LENGTH,
+ nToken2 = CSS1_LENGTH,
+ nToken3 = CSS1_LENGTH;
+ switch( aIdent.GetChar(0) )
+ {
+ case 'c':
+ case 'C':
+ pCmp1 = sCSS1_UNIT_cm;
+ nScale1 = (72.*20.)/2.54; // twip
+ break;
+ case 'e':
+ case 'E':
+ pCmp1 = sCSS1_UNIT_em;
+ nToken1 = CSS1_EMS;
+
+ pCmp2 = sCSS1_UNIT_ex;
+ nToken2 = CSS1_EMX;
+ break;
+ case 'i':
+ case 'I':
+ pCmp1 = sCSS1_UNIT_inch;
+ nScale1 = 72.*20.; // twip
+ break;
+ case 'm':
+ case 'M':
+ pCmp1 = sCSS1_UNIT_mm;
+ nScale1 = (72.*20.)/25.4; // twip
+ break;
+ case 'p':
+ case 'P':
+ pCmp1 = sCSS1_UNIT_pt;
+ nScale1 = 20.; // twip
+
+ pCmp2 = sCSS1_UNIT_pc;
+ nScale2 = 12.*20.; // twip
+
+ pCmp3 = sCSS1_UNIT_px;
+ nToken3 = CSS1_PIXLENGTH;
+ break;
+ }
+
+ double nScale;
+ DBG_ASSERT( pCmp1, "Wo kommt das erste Zeichen her?" );
+ if( aIdent.EqualsIgnoreCaseAscii(pCmp1) )
+ {
+ nScale = nScale1;
+ nRet = nToken1;
+ }
+ else if( pCmp2 &&
+ aIdent.EqualsIgnoreCaseAscii(pCmp2) )
+ {
+ nScale = nScale2;
+ nRet = nToken2;
+ }
+ else if( pCmp3 &&
+ aIdent.EqualsIgnoreCaseAscii(pCmp3) )
+ {
+ nScale = nScale3;
+ nRet = nToken3;
+ }
+ else
+ {
+ nRet = CSS1_NUMBER;
+ }
+
+ if( CSS1_LENGTH==nRet && nScale!=1. )
+ nValue *= nScale;
+
+ if( nRet == CSS1_NUMBER )
+ {
+ nInPos = nInPosSave;
+ cNextCh = cNextChSave;
+ nlLineNr = nlLineNrSave;
+ nlLinePos = nlLinePosSave;
+ bEOF = bEOFSave;
+ }
+ else
+ {
+ bWhiteSpace = FALSE;
+ }
+ bNextCh = FALSE;
+ }
+ break;
+ default: // NUMBER IDENT
+ bNextCh = FALSE;
+ nRet = CSS1_NUMBER;
+ break;
+ }
+ }
+ break;
+
+ case ':': // ':'
+ // link/visited/active abfangen !!!
+ nRet = CSS1_COLON;
+ break;
+
+ case '.': // DOT_W_WS | DOT_WO_WS
+ nRet = bPrevWhiteSpace ? CSS1_DOT_W_WS : CSS1_DOT_WO_WS;
+ break;
+
+ // case '/': siehe oben
+
+ case '+': // '+'
+ nRet = CSS1_PLUS;
+ break;
+
+ case '-': // '-'
+ nRet = CSS1_MINUS;
+ break;
+
+ case '{': // '{'
+ nRet = CSS1_OBRACE;
+ break;
+
+ case '}': // '}'
+ nRet = CSS1_CBRACE;
+ break;
+
+ case ';': // ';'
+ nRet = CSS1_SEMICOLON;
+ break;
+
+ case ',': // ','
+ nRet = CSS1_COMMA;
+ break;
+
+ case '#': // '#'
+ cNextCh = GetNextChar();
+ if( ('0'<=cNextCh && '9'>=cNextCh) ||
+ ('a'<=cNextCh && 'f'>=cNextCh) ||
+ ('A'<=cNextCh && 'F'>=cNextCh) )
+ {
+ // die aktuelle Position retten
+ xub_StrLen nInPosSave = nInPos;
+ sal_Unicode cNextChSave = cNextCh;
+ ULONG nlLineNrSave = nlLineNr;
+ ULONG nlLinePosSave = nlLinePos;
+ BOOL bEOFSave = bEOF;
+
+ // erstmal versuchen eine Hex-Zahl zu scannen
+ ::rtl::OUStringBuffer sTmpBuffer( 6L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ cNextCh = GetNextChar();
+ } while( sTmpBuffer.getLength() < 7 &&
+ ( ('0'<=cNextCh && '9'>=cNextCh) ||
+ ('A'<=cNextCh && 'F'>=cNextCh) ||
+ ('a'<=cNextCh && 'f'>=cNextCh) ) &&
+ !IsEOF() );
+
+ if( sTmpBuffer.getLength()==6 || sTmpBuffer.getLength()==3 )
+ {
+ // wir haben eine hexadezimale Farbe gefunden
+ aToken += String(sTmpBuffer.makeStringAndClear());
+ nRet = CSS1_HEXCOLOR;
+ bNextCh = FALSE;
+
+ break;
+ }
+
+ // sonst versuchen wir es mit einer Zahl
+ nInPos = nInPosSave;
+ cNextCh = cNextChSave;
+ nlLineNr = nlLineNrSave;
+ nlLinePos = nlLinePosSave;
+ bEOF = bEOFSave;
+ }
+
+ nRet = CSS1_HASH;
+ bNextCh = FALSE;
+ break;
+
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n': // White-Space
+ bWhiteSpace = TRUE;
+ break;
+
+ case (sal_Unicode)EOF:
+ if( IsEOF() )
+ {
+ eState = CSS1_PAR_ACCEPTED;
+ bNextCh = FALSE;
+ break;
+ }
+ // kein break;
+
+ default: // IDENT | syntax error
+ // TODO IsAlpha
+ if( ('A' <= cNextCh && cNextCh <= 'Z') ||
+ ('a' <= cNextCh && cNextCh <= 'z') )
+ {
+ // IDENT
+
+ BOOL bHexColor = TRUE;
+
+ // den naechsten Identifer scannen
+ ::rtl::OUStringBuffer sTmpBuffer( 64L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ if( bHexColor )
+ {
+ bHexColor = sTmpBuffer.getLength()<7 &&
+ ( ('0'<=cNextCh && '9'>=cNextCh) ||
+ ('A'<=cNextCh && 'F'>=cNextCh) ||
+ ('a'<=cNextCh && 'f'>=cNextCh) );
+ }
+ cNextCh = GetNextChar();
+ // TODO: AlphaNumeric
+ } while( ( ('0'<=cNextCh && '9'>=cNextCh) ||
+ ('A'<=cNextCh && 'Z'>=cNextCh) ||
+ ('a'<=cNextCh && 'z'>=cNextCh) ||
+ '-'==cNextCh ) &&
+ !IsEOF() );
+
+ aToken += String(sTmpBuffer.makeStringAndClear());
+
+ if( bHexColor && sTmpBuffer.getLength()==6 )
+ {
+ bNextCh = FALSE;
+ nRet = CSS1_HEXCOLOR;
+
+ break;
+ }
+ if( '('==cNextCh &&
+ ( (('u'==aToken.GetChar(0) || 'U'==aToken.GetChar(0)) &&
+ aToken.EqualsIgnoreCaseAscii(sCSS1_url)) ||
+ (('r'==aToken.GetChar(0) || 'R'==aToken.GetChar(0)) &&
+ aToken.EqualsIgnoreCaseAscii(sCSS1_rgb)) ) )
+ {
+ USHORT nNestCnt = 0;
+ ::rtl::OUStringBuffer sTmpBuffer( 64L );
+ do {
+ sTmpBuffer.append( cNextCh );
+ switch( cNextCh )
+ {
+ case '(': nNestCnt++; break;
+ case ')': nNestCnt--; break;
+ }
+ cNextCh = GetNextChar();
+ } while( (nNestCnt>1 || ')'!=cNextCh) && !IsEOF() );
+ sTmpBuffer.append( cNextCh );
+ aToken += String(sTmpBuffer.makeStringAndClear());
+ bNextCh = TRUE;
+ nRet = 'u'==aToken.GetChar(0) || 'U'==aToken.GetChar(0)
+ ? CSS1_URL
+ : CSS1_RGB;
+ }
+ else
+ {
+ bNextCh = FALSE;
+ nRet = CSS1_IDENT;
+ }
+ }
+ // Fehlerbehandlung: Zeichen ignorieren
+ break;
+ }
+ if( bNextCh )
+ cNextCh = GetNextChar();
+
+ } while( CSS1_NULL==nRet && IsParserWorking() );
+
+ return nRet;
+}
+
+
+/* */
+
+
+// Dies folegenden Funktionen realisieren den in
+//
+// http://www.w3.orh/pub/WWW/TR/WD-css1.html
+// bzw. http://www.w3.orh/pub/WWW/TR/WD-css1-960220.html
+//
+// beschriebenen Parser fuer CSS1. Es handelt sich um eine direkte
+// Umsetzung der dort beschriebenen Grammatik
+
+// stylesheet
+// : import* rule*
+//
+// import
+// : IMPORT_SYM url
+//
+// url
+// : STRING
+//
+void CSS1Parser::ParseStyleSheet()
+{
+ LOOP_CHECK_DECL
+
+ // import*
+ BOOL bDone = FALSE;
+ while( !bDone && IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseStyleSheet()/import *" )
+
+ switch( nToken )
+ {
+ case CSS1_IMPORT_SYM:
+ // IMPORT_SYM url
+ // url ueberspringen wir ungeprueft
+ nToken = GetNextToken();
+ break;
+ case CSS1_IDENT: // Look-Aheads
+ case CSS1_DOT_W_WS:
+ case CSS1_HASH:
+// /Feature: PrintExt
+ case CSS1_PAGE_SYM:
+// /Feature: PrintExt
+ // rule
+ bDone = TRUE;
+ break;
+ default:
+ // Fehlerbehandlung: ueberlesen
+ break;
+ }
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ LOOP_CHECK_RESTART
+
+ // rule *
+ while( IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseStyleSheet()/rule *" )
+
+ switch( nToken )
+ {
+ case CSS1_IDENT: // Look-Aheads
+ case CSS1_DOT_W_WS:
+ case CSS1_HASH:
+// /Feature: PrintExt
+ case CSS1_PAGE_SYM:
+// /Feature: PrintExt
+ // rule
+ ParseRule();
+ break;
+ default:
+ // Fehlerbehandlung: ueberlesen
+ nToken = GetNextToken();
+ break;
+ }
+ }
+}
+
+// rule
+// : selector [ ',' selector ]*
+// '{' declaration [ ';' declaration ]* '}'
+//
+void CSS1Parser::ParseRule()
+{
+ // selector
+ CSS1Selector *pSelector = ParseSelector();
+ if( !pSelector )
+ return;
+
+ // Selektor verarbeiten
+ if( SelectorParsed( pSelector, TRUE ) )
+ delete pSelector;
+
+ LOOP_CHECK_DECL
+
+ // [ ',' selector ]*
+ while( CSS1_COMMA==nToken && IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseRule()/selector *" )
+
+ // ',' ueberelesen
+ nToken = GetNextToken();
+
+ // selector
+ pSelector = ParseSelector();
+ if( !pSelector )
+ return;
+
+ // Selektor verarbeiten
+ if( SelectorParsed( pSelector, FALSE ) )
+ delete pSelector;
+ }
+
+ // '{'
+ if( CSS1_OBRACE != nToken )
+ return;
+ nToken = GetNextToken();
+
+ // declaration
+ String aProperty;
+ CSS1Expression *pExpr = ParseDeclaration( aProperty );
+ if( !pExpr )
+ return;
+
+ // expression verarbeiten
+ if( DeclarationParsed( aProperty, pExpr ) )
+ delete pExpr;
+
+ LOOP_CHECK_RESTART
+
+ // [ ';' declaration ]*
+ while( CSS1_SEMICOLON==nToken && IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseRule()/declaration *" )
+
+ // ';'
+ nToken = GetNextToken();
+
+ // declaration
+ if( CSS1_IDENT == nToken )
+ {
+ CSS1Expression *pExpr = ParseDeclaration( aProperty );
+ if( pExpr )
+ {
+ // expression verarbeiten
+ if( DeclarationParsed( aProperty, pExpr ) )
+ delete pExpr;
+ }
+ }
+ }
+
+ // '}'
+ if( CSS1_CBRACE == nToken )
+ nToken = GetNextToken();
+}
+
+// selector
+// : simple_selector+ [ ':' pseudo_element ]?
+//
+// simple_selector
+// : element_name [ DOT_WO_WS class ]?
+// | DOT_W_WS class
+// | id_selector
+//
+// element_name
+// : IDENT
+//
+// class
+// : IDENT
+//
+// id_selector
+// : '#' IDENT
+//
+// pseude_element
+// : IDENT
+//
+CSS1Selector *CSS1Parser::ParseSelector()
+{
+ CSS1Selector *pRoot = 0, *pLast = 0;
+
+ BOOL bDone = FALSE;
+ CSS1Selector *pNew = 0;
+
+ LOOP_CHECK_DECL
+
+ // simple_selector+
+ while( !bDone && IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseSelector()" )
+
+ BOOL bNextToken = TRUE;
+
+ switch( nToken )
+ {
+ case CSS1_IDENT:
+ {
+ // element_name [ DOT_WO_WS class ]?
+
+ // element_name
+ String aElement = aToken;
+ CSS1SelectorType eType = CSS1_SELTYPE_ELEMENT;
+ nToken = GetNextToken();
+
+ if( CSS1_DOT_WO_WS == nToken )
+ {
+ // DOT_WO_WS
+ nToken = GetNextToken();
+
+ // class
+ if( CSS1_IDENT == nToken )
+ {
+ (aElement += '.') += aToken;
+ eType = CSS1_SELTYPE_ELEM_CLASS;
+ }
+ else
+ {
+ // class fehlt
+ return pRoot;
+ }
+ }
+ else
+ {
+ // das war jetzt ein Look-Ahead
+ bNextToken = FALSE;
+ }
+ pNew = new CSS1Selector( eType, aElement );
+ }
+ break;
+ case CSS1_DOT_W_WS:
+ // DOT_W_WS class
+
+ // DOT_W_WS
+ nToken = GetNextToken();
+
+ if( CSS1_IDENT==nToken )
+ {
+ // class
+ pNew = new CSS1Selector( CSS1_SELTYPE_CLASS, aToken );
+ }
+ else
+ {
+ // class fehlt
+ return pRoot;
+ }
+ break;
+ case CSS1_HASH:
+ // '#' id_selector
+
+ // '#'
+ nToken = GetNextToken();
+
+ if( CSS1_IDENT==nToken )
+ {
+ // id_selector
+ pNew = new CSS1Selector( CSS1_SELTYPE_ID, aToken );
+ }
+ else
+ {
+ // id_selector fehlt
+ return pRoot;
+ }
+ break;
+
+// /Feature: PrintExt
+ case CSS1_PAGE_SYM:
+ {
+ // @page
+ pNew = new CSS1Selector( CSS1_SELTYPE_PAGE, aToken );
+ }
+ break;
+// /Feature: PrintExt
+
+ default:
+ // wir wissen nicht was kommt, also aufhoehren
+ bDone = TRUE;
+ break;
+ }
+
+ // falls ein Selektor angelegt wurd, ihn speichern
+ if( pNew )
+ {
+ DBG_ASSERT( (pRoot!=0) == (pLast!=0),
+ "Root-Selektor, aber kein Last" );
+ if( pLast )
+ pLast->SetNext( pNew );
+ else
+ pRoot = pNew;
+
+ pLast = pNew;
+ pNew = 0;
+ }
+
+ if( bNextToken && !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( !pRoot )
+ {
+ // simple_selector fehlt
+ return pRoot;
+ }
+
+ // [ ':' pseudo_element ]?
+ if( CSS1_COLON==nToken && IsParserWorking() )
+ {
+ // ':' pseudo element
+ nToken = GetNextToken();
+ if( CSS1_IDENT==nToken )
+ {
+ pLast->SetNext( new CSS1Selector(CSS1_SELTYPE_PSEUDO,aToken) );
+ nToken = GetNextToken();
+ }
+ else
+ {
+ // pseudo_element fehlt
+ return pRoot;
+ }
+ }
+
+ return pRoot;
+}
+
+// declaration
+// : property ':' expr prio?
+// | /* empty */
+//
+// expression
+// : term [ operator term ]*
+//
+// term
+// : unary_operator?
+// [ NUMBER | STRING | PERCENTAGE | LENGTH | EMS | EXS | IDENT |
+// HEXCOLOR | URL | RGB ]
+//
+// operator
+// : '/' | ',' | /* empty */
+//
+// unary_operator
+// : '-' | '+'
+//
+// property
+// : ident
+//
+// das Vorzeichen wird nur fuer numerische Werte (ausser PERCENTAGE)
+// beruecksichtigt und wird auf nValue angewendet!
+CSS1Expression *CSS1Parser::ParseDeclaration( String& rProperty )
+{
+ CSS1Expression *pRoot = 0, *pLast = 0;
+
+ // property
+ if( CSS1_IDENT != nToken )
+ {
+ // property fehlt
+ return pRoot;
+ }
+ rProperty = aToken;
+
+ nToken = GetNextToken();
+
+
+ // ':'
+ if( CSS1_COLON != nToken )
+ {
+ // ':' fehlt
+ return pRoot;
+ }
+ nToken = GetNextToken();
+
+ // term [operator term]*
+ // hier sind wir sehr lax, was die Syntax angeht, sollte aber kein
+ // Problem sein
+ BOOL bDone = FALSE;
+ sal_Unicode cSign = 0, cOp = 0;
+ CSS1Expression *pNew = 0;
+
+ LOOP_CHECK_DECL
+
+ while( !bDone && IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseDeclaration()" )
+
+ switch( nToken )
+ {
+ case CSS1_MINUS:
+ cSign = '-';
+ break;
+
+ case CSS1_PLUS:
+ cSign = '+';
+ break;
+
+ case CSS1_NUMBER:
+ case CSS1_LENGTH:
+ case CSS1_PIXLENGTH:
+ case CSS1_EMS:
+ case CSS1_EMX:
+ if( '-'==cSign )
+ nValue = -nValue;
+ case CSS1_STRING:
+ case CSS1_PERCENTAGE:
+ case CSS1_IDENT:
+ case CSS1_URL:
+ case CSS1_RGB:
+ case CSS1_HEXCOLOR:
+ pNew = new CSS1Expression( nToken, aToken, nValue, cOp );
+ nValue = 0; // sonst landet das auch im naechsten Ident
+ cSign = 0;
+ cOp = 0;
+ break;
+
+ case CSS1_SLASH:
+ cOp = '/';
+ cSign = 0;
+ break;
+
+ case CSS1_COMMA:
+ cOp = ',';
+ cSign = 0;
+ break;
+
+ default:
+ bDone = TRUE;
+ break;
+ }
+
+ // falls ein Expression angelegt wurde, diesen speichern
+ if( pNew )
+ {
+ DBG_ASSERT( (pRoot!=0) == (pLast!=0),
+ "Root-Selektor, aber kein Last" );
+ if( pLast )
+ pLast->SetNext( pNew );
+ else
+ pRoot = pNew;
+
+ pLast = pNew;
+ pNew = 0;
+ }
+
+ if( !bDone )
+ nToken = GetNextToken();
+ }
+
+ if( !pRoot )
+ {
+ // term fehlt
+ return pRoot;
+ }
+
+ // prio?
+ if( CSS1_IMPORTANT_SYM==nToken )
+ {
+ // IMPORTANT_SYM
+ nToken = GetNextToken();
+ }
+
+ return pRoot;
+}
+
+/* */
+
+CSS1Parser::CSS1Parser()
+{
+}
+
+CSS1Parser::~CSS1Parser()
+{
+}
+
+/* */
+
+BOOL CSS1Parser::ParseStyleSheet( const String& rIn )
+{
+ String aTmp( rIn );
+
+ sal_Unicode c;
+ while( aTmp.Len() &&
+ ( ' '==(c=aTmp.GetChar(0)) || '\t'==c || '\r'==c || '\n'==c ) )
+ aTmp.Erase( 0, 1 );
+
+ while( aTmp.Len() && ( ' '==(c=aTmp.GetChar( aTmp.Len()-1))
+ || '\t'==c || '\r'==c || '\n'==c ) )
+ aTmp.Erase( aTmp.Len()-1 );
+
+ // SGML-Kommentare entfernen
+ if( aTmp.Len() >= 4 &&
+ aTmp.CompareToAscii("<!--",4) == COMPARE_EQUAL )
+ aTmp.Erase( 0, 4 );
+
+ if( aTmp.Len() >=3 &&
+ aTmp.Copy(aTmp.Len()-3).CompareToAscii("-->") == COMPARE_EQUAL )
+ aTmp.Erase( aTmp.Len()-3 );
+
+ if( !aTmp.Len() )
+ return TRUE;
+
+ InitRead( aTmp );
+
+ ParseStyleSheet();
+
+ return TRUE;
+}
+
+
+BOOL CSS1Parser::ParseStyleOption( const String& rIn )
+{
+ if( !rIn.Len() )
+ return TRUE;
+
+ InitRead( rIn );
+
+ String aProperty;
+ CSS1Expression *pExpr = ParseDeclaration( aProperty );
+ if( !pExpr )
+ {
+ return FALSE;
+ }
+
+ // expression verarbeiten
+ if( DeclarationParsed( aProperty, pExpr ) )
+ delete pExpr;
+
+ LOOP_CHECK_DECL
+
+ // [ ';' declaration ]*
+ while( CSS1_SEMICOLON==nToken && IsParserWorking() )
+ {
+ LOOP_CHECK_CHECK( "Endlos-Schleife in ParseStyleOption()" )
+
+ nToken = GetNextToken();
+ if( CSS1_IDENT==nToken )
+ {
+ CSS1Expression *pExpr = ParseDeclaration( aProperty );
+ if( pExpr )
+ {
+ // expression verarbeiten
+ if( DeclarationParsed( aProperty, pExpr ) )
+ delete pExpr;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+BOOL CSS1Parser::SelectorParsed( const CSS1Selector *pSelector, BOOL bFirst )
+{
+ // Selektor loeschen
+ return TRUE;
+}
+
+BOOL CSS1Parser::DeclarationParsed( const String& rProperty,
+ const CSS1Expression *pExpr )
+{
+ // Deklaration loeschen
+ return TRUE;
+}
+
+
+/* */
+
+CSS1Selector::~CSS1Selector()
+{
+ delete pNext;
+}
+
+/* */
+
+CSS1Expression::~CSS1Expression()
+{
+ delete pNext;
+}
+
+BOOL CSS1Expression::GetURL( String& rURL ) const
+{
+ DBG_ASSERT( CSS1_URL==eType, "CSS1-Ausruck ist keine Farbe URL" );
+
+ DBG_ASSERT( aValue.CompareIgnoreCaseToAscii( sCSS1_url, 3 ) ==
+ COMPARE_EQUAL &&
+ aValue.Len() > 5 &&
+ '(' == aValue.GetChar(3) &&
+ ')' == aValue.GetChar(aValue.Len()-1),
+ "keine gueltiges URL(...)" );
+
+ BOOL bRet = FALSE;
+
+ if( aValue.Len() > 5 )
+ {
+ rURL = aValue.Copy( 4, aValue.Len()-5 );
+ rURL.EraseTrailingChars();
+ rURL.EraseLeadingChars();
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+BOOL CSS1Expression::GetColor( Color &rColor ) const
+{
+ DBG_ASSERT( CSS1_IDENT==eType || CSS1_RGB==eType ||
+ CSS1_HEXCOLOR==eType || CSS1_STRING==eType,
+ "CSS1-Ausruck kann keine Farbe sein" );
+
+ BOOL bRet = FALSE;
+ ULONG nColor = ULONG_MAX;
+
+ switch( eType )
+ {
+ case CSS1_RGB:
+ {
+ BYTE aColors[3] = { 0, 0, 0 };
+
+ DBG_ASSERT( aValue.CompareIgnoreCaseToAscii( sCSS1_rgb, 3 )
+ == COMPARE_EQUAL &&
+ aValue.Len() > 5 &&
+ '(' == aValue.GetChar( 3 ) &&
+ ')' == aValue.GetChar( aValue.Len()-1),
+ "keine gueltiges RGB(...)" );
+
+ String aColorStr( aValue.Copy( 4, aValue.Len()-1 ) );
+
+ xub_StrLen nPos = 0;
+ USHORT nColor = 0;
+
+ while( nColor<3 && nPos<aColorStr.Len() )
+ {
+ register sal_Unicode c;
+ while( nPos < aColorStr.Len() &&
+ ((c=aColorStr.GetChar(nPos)) == ' ' || c == '\t' ||
+ c == '\n' || c== '\r' ) )
+ nPos++;
+
+ xub_StrLen nEnd = aColorStr.Search( ',', nPos );
+ String aNumber;
+ if( STRING_NOTFOUND==nEnd )
+ {
+ aNumber = aColorStr.Copy(nPos);
+ nPos = aColorStr.Len();
+ }
+ else
+ {
+ aNumber = aColorStr.Copy( nPos, nEnd-nPos );
+ nPos = nEnd+1;
+ }
+
+ USHORT nNumber = (USHORT)aNumber.ToInt32();
+ if( aNumber.Search('%') != STRING_NOTFOUND )
+ {
+ if( nNumber > 100 )
+ nNumber = 100;
+ nNumber *= 255;
+ nNumber /= 100;
+ }
+ else if( nNumber > 255 )
+ nNumber = 255;
+
+ aColors[nColor] = (BYTE)nNumber;
+ nColor ++;
+ }
+
+ rColor.SetRed( aColors[0] );
+ rColor.SetGreen( aColors[1] );
+ rColor.SetBlue( aColors[2] );
+
+ bRet = TRUE; // etwas anderes als eine Farbe kann es nicht sein
+ }
+ break;
+
+ case CSS1_IDENT:
+ case CSS1_STRING:
+ {
+ String aTmp( aValue );
+ aTmp.ToUpperAscii();
+ nColor = GetHTMLColor( aTmp );
+ bRet = nColor != ULONG_MAX;
+ }
+ if( bRet || CSS1_STRING != eType || !aValue.Len() ||
+ aValue.GetChar( 0 )!='#' )
+ break;
+
+ case CSS1_HEXCOLOR:
+ {
+ // HACK fuer MS-IE: DIe Farbe kann auch in einem String stehen
+ xub_StrLen nOffset = CSS1_STRING==eType ? 1 : 0;
+ BOOL bDouble = aValue.Len()-nOffset == 3;
+ xub_StrLen i = nOffset, nEnd = (bDouble ? 3 : 6) + nOffset;
+
+ nColor = 0;
+ for( ; i<nEnd; i++ )
+ {
+ register sal_Unicode c = (i<aValue.Len() ? aValue.GetChar(i)
+ : '0' );
+ if( c >= '0' && c <= '9' )
+ c -= 48;
+ else if( c >= 'A' && c <= 'F' )
+ c -= 55;
+ else if( c >= 'a' && c <= 'f' )
+ c -= 87;
+ else
+ c = 16;
+
+ nColor *= 16;
+ if( c<16 )
+ nColor += c;
+ if( bDouble )
+ {
+ nColor *= 16;
+ if( c<16 )
+ nColor += c;
+ }
+ }
+ // bRet = i==6;
+ bRet = TRUE;
+ }
+ break;
+ }
+
+
+ if( bRet && nColor!=ULONG_MAX )
+ {
+ rColor.SetRed( (BYTE)((nColor & 0x00ff0000UL) >> 16) );
+ rColor.SetGreen( (BYTE)((nColor & 0x0000ff00UL) >> 8) );
+ rColor.SetBlue( (BYTE)(nColor & 0x000000ffUL) );
+ }
+
+ return bRet;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/parcss1.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.35 2000/09/18 16:04:47 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.34 2000/06/16 13:01:33 os
+ Unicode error corrected
+
+ Revision 1.33 2000/04/10 12:20:57 mib
+ unicode
+
+ Revision 1.32 2000/02/11 14:37:36 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.31 1999/04/19 10:46:32 MIB
+ #64963#: EOF beim Zurueckseeken loeschen
+
+
+ Rev 1.30 19 Apr 1999 12:46:32 MIB
+ #64963#: EOF beim Zurueckseeken loeschen
+
+ Rev 1.29 20 Feb 1998 19:02:20 MA
+ header
+
+ Rev 1.28 26 Nov 1997 19:09:48 MA
+ includes
+
+ Rev 1.27 03 Nov 1997 14:08:50 MA
+ precomp entfernt
+
+ Rev 1.26 10 Oct 1997 10:14:36 MIB
+ CSS1-Printing-Ext: @page,page-break-before/after (noch kein left/right)
+
+ Rev 1.25 19 Sep 1997 13:57:54 MIB
+ unbekannte @-Bloecke werden jetzt ueberlesen
+
+ Rev 1.24 29 Aug 1997 13:32:22 JP
+ VCL Color Anpassung
+
+ Rev 1.23 15 Jul 1997 16:52:24 MIB
+ fix: Auch 3-stellige Farben erlauben (fuer www.w3.org/Style
+
+ Rev 1.22 02 Jul 1997 17:13:14 MIB
+ fix: r??() nicht wie rgb() behandeln
+
+ Rev 1.21 13 Jun 1997 17:08:12 MIB
+ Ein par MS-IE Syntax-Goodies nachgebaut
+
+ Rev 1.20 13 Jun 1997 11:58:32 MIB
+ fix: .foo auch am Anfang erkennen
+
+ Rev 1.19 07 May 1997 15:46:38 MIB
+ Destruktoren nicht inline, sonst GPF unter Win16 (Warum auch immer?)
+
+ Rev 1.18 20 Dec 1996 14:00:46 MIB
+ Warnings
+
+ Rev 1.17 28 Oct 1996 19:12:14 MIB
+ Umaute in Identifiern-Erlauben, EOF-Behandlung
+
+ Rev 1.16 23 Oct 1996 19:49:06 JP
+ String Umstellung: [] -> GetChar()
+
+ Rev 1.15 21 Oct 1996 08:57:42 MIB
+ bug fix: H1.foo wurde falsch geparsed
+
+ Rev 1.14 13 Oct 1996 12:31:26 MIB
+ Argument von unbekannten @ident ueberlesen
+
+ Rev 1.13 20 Aug 1996 16:55:40 MIB
+ bug-fix: Hexzahlen muessen 6 Zeichen lang sein
+
+ Rev 1.12 19 Aug 1996 18:11:22 MIB
+ bugfix: PIXLENGTH durchlassen
+
+ Rev 1.11 14 Aug 1996 16:22:24 MIB
+ gcc und msvc: statt *aStr nicht aStr[0] sondern aStr[(USHORT)0]
+
+ Rev 1.10 13 Aug 1996 21:08:32 sdo
+ GCC
+
+ Rev 1.9 12 Aug 1996 10:32:16 MIB
+ Anpassungen an draft vom 26.7.96, Background-Property, Scannen von Farben verb.
+
+ Rev 1.8 07 Aug 1996 13:21:46 MIB
+ Import von color und text-decoration
+
+ Rev 1.7 17 Jul 1996 10:22:50 MIB
+ Loop-Check verbessert
+
+ Rev 1.6 27 Jun 1996 16:44:16 MIB
+ fix #29184#: Endlosschleife bei SGML-Kommentaren und andere Verbesserungen
+
+ Rev 1.5 26 Jun 1996 15:24:24 MIB
+ Anpassung an 324, Includes aufgeraeumt
+
+ Rev 1.4 20 Jun 1996 12:33:26 MIB
+ bug fix: Einheiten sind jetzt case-insensitiv
+
+ Rev 1.3 17 Jun 1996 15:59:50 MIB
+ Length nun in Twips, bug fixes und Erweiterungen
+
+ Rev 1.2 16 Jun 1996 14:32:58 MIB
+ Loops sicherer gemacht, Strings ausgelagert
+
+ Rev 1.1 14 Jun 1996 20:12:56 MIB
+ die erste Endlos-Schleife gefixed
+
+ Rev 1.0 14 Jun 1996 17:42:34 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/parcss1.hxx b/sw/source/filter/html/parcss1.hxx
new file mode 100644
index 000000000000..b1a9c384d93d
--- /dev/null
+++ b/sw/source/filter/html/parcss1.hxx
@@ -0,0 +1,342 @@
+/*************************************************************************
+ *
+ * $RCSfile: parcss1.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _PARCSS1_HXX
+#define _PARCSS1_HXX
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+
+class Color;
+
+/* */
+
+// Die Tokens des CSS1-Parsers
+enum CSS1Token
+{
+ CSS1_NULL,
+ CSS1_UNKOWN,
+
+ CSS1_IDENT,
+ CSS1_STRING,
+ CSS1_NUMBER,
+ CSS1_PERCENTAGE,
+ CSS1_LENGTH, // eine absolute Groesse in 1/100 MM
+ CSS1_PIXLENGTH, // eine Pixel-Groesse
+ CSS1_EMS,
+ CSS1_EMX,
+ CSS1_HEXCOLOR,
+
+ CSS1_DOT_W_WS,
+ CSS1_DOT_WO_WS,
+ CSS1_COLON,
+ CSS1_SLASH,
+ CSS1_PLUS,
+ CSS1_MINUS,
+ CSS1_OBRACE,
+ CSS1_CBRACE,
+ CSS1_SEMICOLON,
+ CSS1_COMMA,
+ CSS1_HASH,
+
+ CSS1_IMPORT_SYM,
+// Feature: PrintExt
+ CSS1_PAGE_SYM,
+// /Feature: PrintExt
+
+ CSS1_IMPORTANT_SYM,
+
+ CSS1_URL,
+ CSS1_RGB
+};
+
+
+// die Zustaende des Parsers
+enum CSS1ParserState
+{
+ CSS1_PAR_ACCEPTED = 0,
+ CSS1_PAR_WORKING,
+ CSS1_PAR_ERROR
+};
+
+
+/* */
+
+enum CSS1SelectorType
+{
+ CSS1_SELTYPE_ELEMENT,
+ CSS1_SELTYPE_ELEM_CLASS,
+ CSS1_SELTYPE_CLASS,
+ CSS1_SELTYPE_ID,
+ CSS1_SELTYPE_PSEUDO,
+// Feature: PrintExt
+ CSS1_SELTYPE_PAGE
+// /Feature: PrintExt
+
+};
+
+// Die folegende Klasse beschreibt einen Simple-Selector, also
+// - einen HTML-Element-Namen
+// - einen HTML-Element-Namen mit Klasse (durch '.' getrennt)
+// - eine Klasse (ohne Punkt)
+// - eine mit ID=xxx gesetzte ID aus einem HTML-Dokument
+// oder
+// - ein Pseudo-Element
+//
+// Die Simple-Sektoren werden in einer Liste zu vollstaendigen
+// Selektoren verkettet
+class CSS1Selector
+{
+ CSS1SelectorType eType; // Art des Selektors
+ String aSelector; // der Selektor selbst
+ CSS1Selector *pNext; // die naechste Komponente
+
+public:
+
+ CSS1Selector( CSS1SelectorType eTyp, const String &rSel )
+ : eType(eTyp), aSelector( rSel ), pNext( 0 )
+ {}
+
+ ~CSS1Selector();
+
+ CSS1SelectorType GetType() const { return eType; }
+ const String& GetString() const { return aSelector; }
+
+ void SetNext( CSS1Selector *pNxt ) { pNext = pNxt; }
+ const CSS1Selector *GetNext() const { return pNext; }
+};
+
+
+/* */
+
+// Die folegende Klasse beschreibt einen Teil-Ausdruck einer
+// CSS1-Deklaration sie besteht aus
+//
+// - dem Typ des Ausdrucks (entspricht dem Token)
+// - dem eigentlichen Wert als String und ggf. double
+// der double-Wert enthaelt das Vorzeichen fuer NUMBER und LENGTH
+// - und dem Operator, mit dem er mit dem *Vorganger*-Ausdruck
+// verknuepft ist.
+//
+struct CSS1Expression
+{
+ sal_Unicode cOp; // Art der Verkuepfung mit dem Vorgaenger
+ CSS1Token eType; // der Typ des Wertes
+ String aValue; // und sein Wert als String
+ double nValue; // und als Zahl (TWIPs fuer LENGTH)
+ CSS1Expression *pNext; // die naechste Komponente
+
+public:
+
+ CSS1Expression( CSS1Token eTyp, const String &rVal,
+ double nVal, sal_Unicode cO = 0 )
+ : cOp(cO), eType(eTyp), aValue(rVal), nValue(nVal), pNext(0)
+ {}
+
+ ~CSS1Expression();
+
+ inline void Set( CSS1Token eTyp, const String &rVal, double nVal,
+ sal_Unicode cO = 0 );
+
+ CSS1Token GetType() const { return eType; }
+ const String& GetString() const { return aValue; }
+ double GetNumber() const { return nValue; }
+ inline sal_uInt32 GetULength() const;
+ inline sal_Int32 GetSLength() const;
+ sal_Unicode GetOp() const { return cOp; }
+
+
+ sal_Bool GetURL( String& rURL ) const;
+ sal_Bool GetColor( Color &rRGB ) const;
+
+ void SetNext( CSS1Expression *pNxt ) { pNext = pNxt; }
+ const CSS1Expression *GetNext() const { return pNext; }
+};
+
+inline void CSS1Expression::Set( CSS1Token eTyp, const String &rVal,
+ double nVal, sal_Unicode cO )
+{
+ cOp = cO; eType = eTyp; aValue = rVal; nValue = nVal; pNext = 0;
+}
+
+inline sal_uInt32 CSS1Expression::GetULength() const
+{
+ return nValue < 0. ? 0UL : (sal_uInt32)(nValue + .5);
+}
+
+inline sal_Int32 CSS1Expression::GetSLength() const
+{
+ return (sal_Int32)(nValue + (nValue < 0. ? -.5 : .5 ));
+}
+
+/* */
+
+// Diese Klasse parst den Inhalt eines Style-Elements oder eine Style-Option
+// und bereitet ihn ein wenig auf.
+//
+// Das Ergebnis des Parsers wird durch die Mehtoden SelectorParsed()
+// und DeclarationParsed() an abgeleitete Parser uebergeben. Bsp:
+//
+// H1, H2 { font-weight: bold; text-align: right }
+// | | | |
+// | | | DeclP( 'text-align', 'right' )
+// | | DeclP( 'font-weight', 'bold' )
+// | SelP( 'H2', sal_False )
+// SelP( 'H1', sal_True )
+//
+class CSS1Parser
+{
+ sal_Bool bWhiteSpace : 1; // White-Space gelesen?
+ sal_Bool bEOF : 1; // Ende des "Files" ?
+
+ sal_Unicode cNextCh; // naechstes Zeichen
+
+ xub_StrLen nInPos; // aktuelle Position im Input-String
+
+ sal_uInt32 nlLineNr; // akt. Zeilen Nummer
+ sal_uInt32 nlLinePos; // akt. Spalten Nummer
+
+ double nValue; // der Wert des Tokens als Zahl
+
+ CSS1ParserState eState; // der akteulle Zustand der Parsers
+ CSS1Token nToken; // das aktuelle Token
+
+ String aIn; // der zu parsende String
+ String aToken; // das Token als String
+
+ // Parsen vorbereiten
+ void InitRead( const String& rIn );
+
+ // das naechste Zeichen holen
+ sal_Unicode GetNextChar();
+
+ // das naechste Token holen
+ CSS1Token GetNextToken();
+
+ // arbeitet der Parser noch?
+ sal_Bool IsParserWorking() const { return CSS1_PAR_WORKING == eState; }
+
+ sal_Bool IsEOF() const { return bEOF; }
+
+ sal_uInt32 IncLineNr() { return ++nlLineNr; }
+ sal_uInt32 IncLinePos() { return ++nlLinePos; }
+ inline sal_uInt32 SetLineNr( sal_uInt32 nlNum ); // inline unten
+ inline sal_uInt32 SetLinePos( sal_uInt32 nlPos ); // inline unten
+
+ // Parsen von Teilen der Grammatik
+ void ParseStyleSheet();
+ void ParseRule();
+ CSS1Selector *ParseSelector();
+ CSS1Expression *ParseDeclaration( String& rProperty );
+
+protected:
+
+ // Den Inhalt eines HTML-Style-Elements parsen.
+ // Fuer jeden Selektor und jede Deklaration wird
+ // SelectorParsed() bzw. DeclarationParsed() aufgerufen.
+ sal_Bool ParseStyleSheet( const String& rIn );
+
+ // Den Inhalt einer HTML-Style-Option parsen.
+ // Fr jede Deklaration wird DeclarationParsed() aufgerufen.
+ sal_Bool ParseStyleOption( const String& rIn );
+
+ // Diese Methode wird aufgerufen, wenn ein Selektor geparsed wurde
+ // Wenn 'bFirst' gesetzt ist, beginnt mit dem Selektor eine neue
+ // Deklaration. Wird sal_True zurueckgegeben, wird der Selektor
+ // geloscht, sonst nicht.
+ // Die Implementierung dieser Methode gibt nur sal_True zuruck.
+ virtual sal_Bool SelectorParsed( const CSS1Selector *pSelector,
+ sal_Bool bFirst );
+
+ // Diese Methode wird fuer jede geparsete Property aufgerufen. Wird
+ // sal_True zurueckgegeben wird der Selektor geloscht, sonst nicht.
+ // Die Implementierung dieser Methode gibt nur sal_True zuruck.
+ virtual sal_Bool DeclarationParsed( const String& rProperty,
+ const CSS1Expression *pExpr );
+
+public:
+
+ CSS1Parser();
+ virtual ~CSS1Parser();
+
+ inline sal_uInt32 GetLineNr() const { return nlLineNr; }
+ inline sal_uInt32 GetLinePos() const { return nlLinePos; }
+};
+
+inline sal_uInt32 CSS1Parser::SetLineNr( sal_uInt32 nlNum )
+{
+ sal_uInt32 nlOld = nlLineNr;
+ nlLineNr = nlNum;
+ return nlOld;
+}
+
+inline sal_uInt32 CSS1Parser::SetLinePos( sal_uInt32 nlPos )
+{
+ sal_uInt32 nlOld = nlLinePos;
+ nlLinePos = nlPos;
+ return nlOld;
+}
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
new file mode 100644
index 000000000000..015925ede94a
--- /dev/null
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -0,0 +1,3378 @@
+/*************************************************************************
+ *
+ * $RCSfile: svxcss1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#include <stdlib.h>
+
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+#ifndef _HINTIDS_HXX
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#define ITEMID_FONT SID_ATTR_CHAR_FONT
+#define ITEMID_POSTURE SID_ATTR_CHAR_POSTURE
+#define ITEMID_WEIGHT SID_ATTR_CHAR_WEIGHT
+#define ITEMID_FONTHEIGHT SID_ATTR_CHAR_FONTHEIGHT
+#define ITEMID_UNDERLINE SID_ATTR_CHAR_UNDERLINE
+#define ITEMID_CROSSEDOUT SID_ATTR_CHAR_STRIKEOUT
+#define ITEMID_COLOR SID_ATTR_CHAR_COLOR
+#define ITEMID_KERNING SID_ATTR_CHAR_KERNING
+#define ITEMID_CASEMAP SID_ATTR_CHAR_CASEMAP
+#define ITEMID_BLINK SID_ATTR_FLASH
+
+#define ITEMID_LINESPACING SID_ATTR_PARA_LINESPACE
+#define ITEMID_ADJUST SID_ATTR_PARA_ADJUST
+#define ITEMID_WIDOWS SID_ATTR_PARA_WIDOWS
+#define ITEMID_ORPHANS SID_ATTR_PARA_ORPHANS
+#define ITEMID_FMTSPLIT SID_ATTR_PARA_SPLIT
+
+#define ITEMID_LRSPACE SID_ATTR_LRSPACE
+#define ITEMID_ULSPACE SID_ATTR_ULSPACE
+#define ITEMID_BOX SID_ATTR_BORDER_OUTER
+#define ITEMID_BRUSH SID_ATTR_BRUSH
+#endif
+
+#ifndef _CTRLTOOL_HXX
+#include <svtools/ctrltool.hxx>
+#endif
+
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_BLNKITEM_HXX //autogen
+#include <svx/blnkitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SFXITEMPOOL_HXX //autogen
+#include <svtools/itempool.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _SVX_WIDWITEM_HXX //autogen
+#include <svx/widwitem.hxx>
+#endif
+#ifndef _SVX_ORPHITEM_HXX //autogen
+#include <svx/orphitem.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SVPARSER_HXX //autogen
+#include <svtools/svparser.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+
+#include "css1kywd.hxx"
+#include "svxcss1.hxx"
+
+// die Funktionen zum Parsen einer CSS1-Property sind von folgendem Typ:
+typedef void (*FnParseCSS1Prop)( const CSS1Expression *pExpr,
+ SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser );
+
+SV_IMPL_PTRARR( CSS1Selectors, CSS1Selector* )
+
+
+/* */
+
+static CSS1PropertyEnum __READONLY_DATA aFontSizeTable[] =
+{
+ { sCSS1_PV_xx_small, 0 },
+ { sCSS1_PV_x_small, 1 },
+ { sCSS1_PV_small, 2 },
+ { sCSS1_PV_medium, 3 },
+ { sCSS1_PV_large, 4 },
+ { sCSS1_PV_x_large, 5 },
+ { sCSS1_PV_xx_large, 6 },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aFontFamilyTable[] =
+{
+ { sCSS1_PV_serif, FAMILY_ROMAN },
+ { sCSS1_PV_sans_serif, FAMILY_SWISS },
+ { sCSS1_PV_cursive, FAMILY_SCRIPT },
+ { sCSS1_PV_fantasy, FAMILY_DECORATIVE },
+ { sCSS1_PV_monospace, FAMILY_MODERN },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aFontWeightTable[] =
+{
+ { sCSS1_PV_extra_light, WEIGHT_NORMAL }, // WEIGHT_ULTRALIGHT (OBS)
+ { sCSS1_PV_light, WEIGHT_NORMAL }, // WEIGHT_LIGHT (OBSOLETE)
+ { sCSS1_PV_demi_light, WEIGHT_NORMAL }, // WEIGHT_SEMILIGHT (OBS)
+ { sCSS1_PV_medium, WEIGHT_NORMAL }, // WEIGHT_MEDIUM (OBS)
+ { sCSS1_PV_normal, WEIGHT_NORMAL }, // WEIGHT_MEDIUM
+ { sCSS1_PV_demi_bold, WEIGHT_NORMAL }, // WEIGHT_SEMIBOLD (OBS)
+ { sCSS1_PV_bold, WEIGHT_BOLD }, // WEIGHT_BOLD (OBSOLETE)
+ { sCSS1_PV_extra_bold, WEIGHT_BOLD }, // WEIGHT_ULTRABOLD (OBS)
+ { sCSS1_PV_bolder, WEIGHT_BOLD },
+ { sCSS1_PV_lighter, WEIGHT_NORMAL },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aFontStyleTable[] =
+{
+ { sCSS1_PV_normal, ITALIC_NONE },
+ { sCSS1_PV_italic, ITALIC_NORMAL },
+ { sCSS1_PV_oblique, ITALIC_NORMAL },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aFontVariantTable[] =
+{
+ { sCSS1_PV_normal, SVX_CASEMAP_NOT_MAPPED },
+ { sCSS1_PV_small_caps, SVX_CASEMAP_KAPITAELCHEN },
+ { 0, 0 }
+};
+
+/* */
+
+static CSS1PropertyEnum __READONLY_DATA aBGRepeatTable[] =
+{
+ { sCSS1_PV_repeat, GPOS_TILED },
+ { sCSS1_PV_repeat_x, GPOS_TILED },
+ { sCSS1_PV_repeat_y, GPOS_TILED },
+ { sCSS1_PV_no_repeat, GPOS_NONE },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aBGHoriPosTable[] =
+{
+ { sCSS1_PV_left, GPOS_LT },
+ { sCSS1_PV_center, GPOS_MT },
+ { sCSS1_PV_right, GPOS_RT },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aBGVertPosTable[] =
+{
+ { sCSS1_PV_top, GPOS_LT },
+ { sCSS1_PV_middle, GPOS_LM },
+ { sCSS1_PV_bottom, GPOS_LB },
+ { 0, 0 }
+};
+
+/* */
+
+static CSS1PropertyEnum __READONLY_DATA aTextAlignTable[] =
+{
+ { sCSS1_PV_left, SVX_ADJUST_LEFT },
+ { sCSS1_PV_center, SVX_ADJUST_CENTER },
+ { sCSS1_PV_right, SVX_ADJUST_RIGHT },
+ { sCSS1_PV_justify, SVX_ADJUST_BLOCK },
+ { 0, 0 }
+};
+
+/* */
+
+static CSS1PropertyEnum __READONLY_DATA aBorderWidthTable[] =
+{
+ { sCSS1_PV_thin, 0 }, // DEF_LINE_WIDTH_0 / DEF_DOUBLE_LINE0
+ { sCSS1_PV_medium, 1 }, // DEF_LINE_WIDTH_1 / DEF_DOUBLE_LINE1
+ { sCSS1_PV_thick, 2 }, // DEF_LINE_WIDTH_2 / DEF_DOUBLE_LINE2
+ { 0, 0 }
+};
+
+enum CSS1BorderStyle { CSS1_BS_NONE, CSS1_BS_SINGLE, CSS1_BS_DOUBLE };
+
+static CSS1PropertyEnum __READONLY_DATA aBorderStyleTable[] =
+{
+ { sCSS1_PV_none, CSS1_BS_NONE },
+ { sCSS1_PV_dotted, CSS1_BS_SINGLE },
+ { sCSS1_PV_dashed, CSS1_BS_SINGLE },
+ { sCSS1_PV_solid, CSS1_BS_SINGLE },
+ { sCSS1_PV_double, CSS1_BS_DOUBLE },
+ { sCSS1_PV_groove, CSS1_BS_SINGLE },
+ { sCSS1_PV_ridge, CSS1_BS_SINGLE },
+ { sCSS1_PV_inset, CSS1_BS_SINGLE },
+ { sCSS1_PV_outset, CSS1_BS_SINGLE },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aFloatTable[] =
+{
+ { sCSS1_PV_left, SVX_ADJUST_LEFT },
+ { sCSS1_PV_right, SVX_ADJUST_RIGHT },
+ { sCSS1_PV_none, SVX_ADJUST_END },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aPositionTable[] =
+{
+ { sCSS1_PV_absolute, SVX_CSS1_POS_ABSOLUTE },
+ { sCSS1_PV_relative, SVX_CSS1_POS_RELATIVE },
+ { sCSS1_PV_static, SVX_CSS1_POS_STATIC },
+ { 0, 0 }
+};
+
+// Feature: PrintExt
+static CSS1PropertyEnum __READONLY_DATA aSizeTable[] =
+{
+ { sCSS1_PV_auto, SVX_CSS1_STYPE_AUTO },
+ { sCSS1_PV_landscape, SVX_CSS1_STYPE_LANDSCAPE },
+ { sCSS1_PV_portrait, SVX_CSS1_STYPE_PORTRAIT },
+ { 0, 0 }
+};
+
+static CSS1PropertyEnum __READONLY_DATA aPageBreakTable[] =
+{
+ { sCSS1_PV_auto, SVX_CSS1_PBREAK_AUTO },
+ { sCSS1_PV_always, SVX_CSS1_PBREAK_ALWAYS },
+ { sCSS1_PV_avoid, SVX_CSS1_PBREAK_AVOID },
+ { sCSS1_PV_left, SVX_CSS1_PBREAK_LEFT },
+ { sCSS1_PV_right, SVX_CSS1_PBREAK_RIGHT },
+ { 0, 0 }
+};
+
+// /Feature: PrintExt
+
+/* */
+
+// Ein Eintrag besteht aus vier USHORTs. Der erste ist die Gesamtbreite,
+// die anderen sind die 3 Einzelbreiten
+
+#define SBORDER_ENTRY( n ) \
+ DEF_LINE_WIDTH_##n, DEF_LINE_WIDTH_##n, 0, 0
+
+#define DBORDER_ENTRY( n ) \
+ DEF_DOUBLE_LINE##n##_OUT + DEF_DOUBLE_LINE##n##_IN + \
+ DEF_DOUBLE_LINE##n##_DIST, \
+ DEF_DOUBLE_LINE##n##_OUT, \
+ DEF_DOUBLE_LINE##n##_IN, \
+ DEF_DOUBLE_LINE##n##_DIST
+
+#define TDBORDER_ENTRY( n ) \
+ DEF_DOUBLE_LINE##n##_OUT, \
+ DEF_DOUBLE_LINE##n##_OUT, \
+ DEF_DOUBLE_LINE##n##_IN, \
+ DEF_DOUBLE_LINE##n##_DIST
+
+
+static USHORT __READONLY_DATA aSBorderWidths[] =
+{
+ SBORDER_ENTRY( 0 ), SBORDER_ENTRY( 1 ), SBORDER_ENTRY( 2 ),
+ SBORDER_ENTRY( 3 ), SBORDER_ENTRY( 4 )
+};
+
+static USHORT __READONLY_DATA aDBorderWidths[] =
+{
+ DBORDER_ENTRY( 0 ),
+ DBORDER_ENTRY( 7 ),
+ DBORDER_ENTRY( 1 ),
+ DBORDER_ENTRY( 8 ),
+ DBORDER_ENTRY( 4 ),
+ DBORDER_ENTRY( 9 ),
+ DBORDER_ENTRY( 3 ),
+ DBORDER_ENTRY( 10 ),
+ DBORDER_ENTRY( 2 ),
+ DBORDER_ENTRY( 5 )
+};
+
+static USHORT __READONLY_DATA aTDBorderWidths[] =
+{
+ TDBORDER_ENTRY( 7 ), TDBORDER_ENTRY( 8 ), TDBORDER_ENTRY( 9 ),
+ TDBORDER_ENTRY( 10 )
+};
+
+#undef SBORDER_ENTRY
+#undef DBORDER_ENTRY
+
+/* */
+
+struct SvxCSS1ItemIds
+{
+ USHORT nFont;
+ USHORT nPosture;
+ USHORT nWeight;
+ USHORT nFontHeight;
+ USHORT nUnderline;
+ USHORT nCrossedOut;
+ USHORT nColor;
+ USHORT nKerning;
+ USHORT nCaseMap;
+ USHORT nBlink;
+
+ USHORT nLineSpacing;
+ USHORT nAdjust;
+ USHORT nWidows;
+ USHORT nOrphans;
+ USHORT nFmtSplit;
+
+ USHORT nLRSpace;
+ USHORT nULSpace;
+ USHORT nBox;
+ USHORT nBrush;
+};
+
+
+static SvxCSS1ItemIds aItemIds;
+
+
+/* */
+
+struct SvxCSS1BorderInfo
+{
+ Color aColor;
+ USHORT nAbsWidth;
+ USHORT nNamedWidth;
+ CSS1BorderStyle eStyle;
+
+ SvxCSS1BorderInfo() :
+ aColor( COL_BLACK ), nAbsWidth( USHRT_MAX ),
+ nNamedWidth( USHRT_MAX ), eStyle( CSS1_BS_NONE )
+ {}
+
+ SvxCSS1BorderInfo( const SvxCSS1BorderInfo& rInfo ) :
+ aColor( rInfo.aColor ), nAbsWidth( rInfo.nAbsWidth ),
+ nNamedWidth( rInfo.nNamedWidth ), eStyle( rInfo.eStyle )
+ {}
+
+ void SetBorderLine( USHORT nLine, SvxBoxItem &rBoxItem ) const;
+};
+
+void SvxCSS1BorderInfo::SetBorderLine( USHORT nLine, SvxBoxItem &rBoxItem ) const
+{
+ if( CSS1_BS_NONE==eStyle || nAbsWidth==0 ||
+ (nAbsWidth==USHRT_MAX && nNamedWidth==USHRT_MAX) )
+ {
+ rBoxItem.SetLine( 0, nLine );
+ return;
+ }
+
+ SvxBorderLine aBorderLine( &aColor );
+
+ // Linien-Stil doppelt oder einfach?
+ BOOL bDouble = eStyle == CSS1_BS_DOUBLE;
+
+ // benannte Breite umrechnenen, wenn keine absolute gegeben ist
+ if( nAbsWidth==USHRT_MAX )
+ {
+ const USHORT *aWidths = bDouble ? aDBorderWidths : aSBorderWidths;
+ USHORT nNWidth = nNamedWidth * 4;
+ aBorderLine.SetOutWidth( aWidths[nNWidth+1] );
+ aBorderLine.SetInWidth( aWidths[nNWidth+2] );
+ aBorderLine.SetDistance( aWidths[nNWidth+3] );
+ }
+ else
+ {
+ SvxCSS1Parser::SetBorderWidth( aBorderLine, nAbsWidth, bDouble );
+ }
+
+ rBoxItem.SetLine( &aBorderLine, nLine );
+}
+
+
+/* */
+
+SvxCSS1PropertyInfo::SvxCSS1PropertyInfo()
+{
+ for( USHORT i=0; i<4; i++ )
+ aBorderInfos[i] = 0;
+
+ Clear();
+}
+
+SvxCSS1PropertyInfo::SvxCSS1PropertyInfo( const SvxCSS1PropertyInfo& rProp ) :
+ aId( rProp.aId ),
+ bTopMargin( rProp.bTopMargin ), bBottomMargin( rProp.bBottomMargin ),
+ bLeftMargin( rProp.bLeftMargin ), bRightMargin( rProp.bRightMargin ),
+ bTextIndent( rProp.bTextIndent ),
+ nLeftMargin( rProp.nLeftMargin ), nRightMargin( rProp.nRightMargin ),
+ eFloat( rProp.eFloat ),
+ ePosition( rProp.ePosition ),
+ nTopBorderDistance( rProp.nTopBorderDistance ),
+ nBottomBorderDistance( rProp.nBottomBorderDistance ),
+ nLeftBorderDistance( rProp.nLeftBorderDistance ),
+ nRightBorderDistance( rProp.nRightBorderDistance ),
+ nLeft( rProp.nLeft ), nTop( rProp.nTop ),
+ nWidth( rProp.nWidth ), nHeight( rProp.nHeight ),
+ eLeftType( rProp.eLeftType ), eTopType( rProp.eTopType ),
+ eWidthType( rProp.eWidthType ), eHeightType( rProp.eHeightType ),
+// Feature: PrintExt
+ eSizeType( rProp.eSizeType ),
+ ePageBreakBefore( rProp.ePageBreakBefore ),
+ ePageBreakAfter( rProp.ePageBreakAfter )
+// /Feature: PrintExt
+{
+ for( USHORT i=0; i<4; i++ )
+ aBorderInfos[i] = rProp.aBorderInfos[i]
+ ? new SvxCSS1BorderInfo( *rProp.aBorderInfos[i] )
+ : 0;
+}
+
+SvxCSS1PropertyInfo::~SvxCSS1PropertyInfo()
+{
+ DestroyBorderInfos();
+}
+
+void SvxCSS1PropertyInfo::DestroyBorderInfos()
+{
+ for( USHORT i=0; i<4; i++ )
+ {
+ delete aBorderInfos[i];
+ aBorderInfos[i] = 0;
+ }
+}
+
+void SvxCSS1PropertyInfo::Clear()
+{
+ aId.Erase();
+ bTopMargin = bBottomMargin = FALSE;
+ bLeftMargin = bRightMargin = bTextIndent = FALSE;
+ nLeftMargin = nRightMargin = 0;
+ eFloat = SVX_ADJUST_END;
+
+ ePosition = SVX_CSS1_POS_NONE;
+ nTopBorderDistance = nBottomBorderDistance =
+ nLeftBorderDistance = nRightBorderDistance = USHRT_MAX;
+ nLeft = nTop = nWidth = nHeight = 0;
+ eLeftType = eTopType = eWidthType = eHeightType = SVX_CSS1_LTYPE_NONE;
+
+// Feature: PrintExt
+ eSizeType = SVX_CSS1_STYPE_NONE;
+ ePageBreakBefore = SVX_CSS1_PBREAK_NONE;
+ ePageBreakAfter = SVX_CSS1_PBREAK_NONE;
+
+ DestroyBorderInfos();
+}
+
+void SvxCSS1PropertyInfo::Merge( const SvxCSS1PropertyInfo& rProp )
+{
+ if( rProp.bTopMargin )
+ bTopMargin = TRUE;
+ if( rProp.bBottomMargin )
+ bBottomMargin = TRUE;
+
+ if( rProp.bLeftMargin )
+ {
+ bLeftMargin = TRUE;
+ nLeftMargin = rProp.nLeftMargin;
+ }
+ if( rProp.bRightMargin )
+ {
+ bRightMargin = TRUE;
+ nRightMargin = rProp.nRightMargin;
+ }
+ if( rProp.bTextIndent )
+ bTextIndent = TRUE;
+
+ for( USHORT i=0; i<4; i++ )
+ {
+ if( rProp.aBorderInfos[i] )
+ {
+ if( aBorderInfos[i] )
+ delete aBorderInfos[i];
+
+ aBorderInfos[i] = new SvxCSS1BorderInfo( *rProp.aBorderInfos[i] );
+ }
+ }
+
+ if( USHRT_MAX != rProp.nTopBorderDistance )
+ nTopBorderDistance = rProp.nTopBorderDistance;
+ if( USHRT_MAX != rProp.nBottomBorderDistance )
+ nBottomBorderDistance = rProp.nBottomBorderDistance;
+ if( USHRT_MAX != rProp.nLeftBorderDistance )
+ nLeftBorderDistance = rProp.nLeftBorderDistance;
+ if( USHRT_MAX != rProp.nRightBorderDistance )
+ nRightBorderDistance = rProp.nRightBorderDistance;
+
+ if( rProp.eFloat != SVX_ADJUST_END )
+ eFloat = rProp.eFloat;
+
+ if( rProp.ePosition != SVX_CSS1_POS_NONE )
+ ePosition = rProp.ePosition;
+
+// Feature: PrintExt
+ if( rProp.eSizeType != SVX_CSS1_STYPE_NONE )
+ {
+ eSizeType = rProp.eSizeType;
+ nWidth = rProp.nWidth;
+ nHeight = rProp.nHeight;
+ }
+
+ if( rProp.ePageBreakBefore != SVX_CSS1_PBREAK_NONE )
+ ePageBreakBefore = rProp.ePageBreakBefore;
+
+ if( rProp.ePageBreakAfter != SVX_CSS1_PBREAK_NONE )
+ ePageBreakAfter = rProp.ePageBreakAfter;
+
+// /Feature: PrintExt
+
+ if( rProp.eLeftType != SVX_CSS1_LTYPE_NONE )
+ {
+ eLeftType = rProp.eLeftType;
+ nLeft = rProp.nLeft;
+ }
+
+ if( rProp.eTopType != SVX_CSS1_LTYPE_NONE )
+ {
+ eTopType = rProp.eTopType;
+ nTop = rProp.nTop;
+ }
+
+ if( rProp.eWidthType != SVX_CSS1_LTYPE_NONE )
+ {
+ eWidthType = rProp.eWidthType;
+ nWidth = rProp.nWidth;
+ }
+
+ if( rProp.eHeightType != SVX_CSS1_LTYPE_NONE )
+ {
+ eHeightType = rProp.eHeightType;
+ nHeight = rProp.nHeight;
+ }
+}
+
+SvxCSS1BorderInfo *SvxCSS1PropertyInfo::GetBorderInfo( USHORT nLine, BOOL bCreate )
+{
+ USHORT nPos = 0;
+ switch( nLine )
+ {
+ case BOX_LINE_TOP: nPos = 0; break;
+ case BOX_LINE_BOTTOM: nPos = 1; break;
+ case BOX_LINE_LEFT: nPos = 2; break;
+ case BOX_LINE_RIGHT: nPos = 3; break;
+ }
+
+ if( !aBorderInfos[nPos] && bCreate )
+ aBorderInfos[nPos] = new SvxCSS1BorderInfo;
+
+ return aBorderInfos[nPos];
+}
+
+void SvxCSS1PropertyInfo::CopyBorderInfo( USHORT nSrcLine, USHORT nDstLine,
+ USHORT nWhat )
+{
+ SvxCSS1BorderInfo *pSrcInfo = GetBorderInfo( nSrcLine, FALSE );
+ if( !pSrcInfo )
+ return;
+
+ SvxCSS1BorderInfo *pDstInfo = GetBorderInfo( nDstLine );
+ if( (nWhat & SVX_CSS1_BORDERINFO_WIDTH) != 0 )
+ {
+ pDstInfo->nAbsWidth = pSrcInfo->nAbsWidth;
+ pDstInfo->nNamedWidth = pSrcInfo->nNamedWidth;
+ }
+
+ if( (nWhat & SVX_CSS1_BORDERINFO_COLOR) != 0 )
+ pDstInfo->aColor = pSrcInfo->aColor;
+
+ if( (nWhat & SVX_CSS1_BORDERINFO_STYLE) != 0 )
+ pDstInfo->eStyle = pSrcInfo->eStyle;
+}
+
+void SvxCSS1PropertyInfo::CopyBorderInfo( USHORT nCount, USHORT nWhat )
+{
+ if( nCount==0 )
+ {
+ CopyBorderInfo( BOX_LINE_BOTTOM, BOX_LINE_TOP, nWhat );
+ CopyBorderInfo( BOX_LINE_TOP, BOX_LINE_LEFT, nWhat );
+ }
+ if( nCount<=1 )
+ {
+ CopyBorderInfo( BOX_LINE_LEFT, BOX_LINE_RIGHT, nWhat );
+ }
+}
+
+void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
+ USHORT nMinBorderDist,
+ const SvxBoxItem *pDfltItem,
+ BOOL bTable )
+{
+ BOOL bChg = nTopBorderDistance != USHRT_MAX ||
+ nBottomBorderDistance != USHRT_MAX ||
+ nLeftBorderDistance != USHRT_MAX ||
+ nRightBorderDistance != USHRT_MAX;
+ for( USHORT i=0; !bChg && i<4; i++ )
+ bChg = aBorderInfos[i]!=0;
+
+ if( !bChg )
+ return;
+
+ SvxBoxItem aBoxItem( aItemIds.nBox );
+ if( pDfltItem )
+ aBoxItem = *pDfltItem;
+
+ SvxCSS1BorderInfo *pInfo = GetBorderInfo( BOX_LINE_TOP, FALSE );
+ if( pInfo )
+ pInfo->SetBorderLine( BOX_LINE_TOP, aBoxItem );
+
+ pInfo = GetBorderInfo( BOX_LINE_BOTTOM, FALSE );
+ if( pInfo )
+ pInfo->SetBorderLine( BOX_LINE_BOTTOM, aBoxItem );
+
+ pInfo = GetBorderInfo( BOX_LINE_LEFT, FALSE );
+ if( pInfo )
+ pInfo->SetBorderLine( BOX_LINE_LEFT, aBoxItem );
+
+ pInfo = GetBorderInfo( BOX_LINE_RIGHT, FALSE );
+ if( pInfo )
+ pInfo->SetBorderLine( BOX_LINE_RIGHT, aBoxItem );
+
+ for( i=0; i<4; i++ )
+ {
+ USHORT nLine, nDist;
+ switch( i )
+ {
+ case 0: nLine = BOX_LINE_TOP;
+ nDist = nTopBorderDistance;
+ nTopBorderDistance = USHRT_MAX;
+ break;
+ case 1: nLine = BOX_LINE_BOTTOM;
+ nDist = nBottomBorderDistance;
+ nBottomBorderDistance = USHRT_MAX;
+ break;
+ case 2: nLine = BOX_LINE_LEFT;
+ nDist = nLeftBorderDistance;
+ nLeftBorderDistance = USHRT_MAX;
+ break;
+ case 3: nLine = BOX_LINE_RIGHT;
+ nDist = nRightBorderDistance;
+ nRightBorderDistance = USHRT_MAX;
+ break;
+ }
+
+ if( aBoxItem.GetLine( nLine ) )
+ {
+ if( USHRT_MAX == nDist )
+ nDist = aBoxItem.GetDistance( nLine );
+
+ if( nDist < nMinBorderDist )
+ nDist = nMinBorderDist;
+ }
+ else
+ {
+ if( USHRT_MAX == nDist )
+ nDist = aBoxItem.GetDistance( nLine );
+
+ if( !bTable )
+ nDist = 0U;
+ else if( nDist && nDist < nMinBorderDist )
+ nDist = nMinBorderDist;
+ }
+
+ aBoxItem.SetDistance( nDist, nLine );
+ }
+
+ rItemSet.Put( aBoxItem );
+
+ DestroyBorderInfos();
+}
+
+
+/* */
+
+SvxCSS1MapEntry::SvxCSS1MapEntry( const String& rKey, const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp ) :
+ aKey( rKey ),
+ aItemSet( rItemSet ),
+ aPropInfo( rProp )
+{
+ // TODO: ToUpperAscii
+ aKey.ToUpperAscii();
+}
+
+#if defined( MAC ) || defined( ICC ) || defined( BLC )
+BOOL operator==( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE2 )
+{
+ return rE1.aKey==rE2.aKey;
+}
+
+BOOL operator<( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE2 )
+{
+ return rE1.aKey<rE2.aKey;
+}
+#endif
+
+SV_IMPL_OP_PTRARR_SORT( SvxCSS1Map, SvxCSS1MapEntryPtr )
+
+/* */
+
+BOOL SvxCSS1Parser::StyleParsed( const CSS1Selector *pSelector,
+ SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo )
+{
+ // wie man sieht passiert hier gar nichts
+ return TRUE;
+}
+
+BOOL SvxCSS1Parser::SelectorParsed( const CSS1Selector *pSelector,
+ BOOL bFirst )
+{
+ if( bFirst )
+ {
+ DBG_ASSERT( pSheetItemSet, "Wo ist der Item-Set fuer Style-Sheets?" );
+
+ // Dieses ist der erste Selektor einer Rule, also muessen
+ // die bisher geparsten Items auf die Styles verteilt werden
+// pSheetPropInfo->CreateBoxItem( *pSheetItemSet, GetDfltBorderDist() );
+ for( USHORT i=0; i<aSelectors.Count(); i++ )
+ {
+ StyleParsed( aSelectors[i], *pSheetItemSet, *pSheetPropInfo );
+ }
+ pSheetItemSet->ClearItem();
+ pSheetPropInfo->Clear();
+
+ // und die naechste Rule vorbereiten
+ if( aSelectors.Count() )
+ aSelectors.DeleteAndDestroy( 0, aSelectors.Count() );
+ }
+
+ aSelectors.C40_INSERT( CSS1Selector, pSelector, aSelectors.Count() );
+
+ return FALSE; // den Selektor haben wir gespeichert. Loeschen toedlich!
+}
+
+
+BOOL SvxCSS1Parser::DeclarationParsed( const String& rProperty,
+ const CSS1Expression *pExpr )
+{
+ DBG_ASSERT( pExpr, "DeclarationParsed() ohne Expression" );
+
+ if( !pExpr )
+ return TRUE;
+
+ ParseProperty( rProperty, pExpr );
+
+ return TRUE; // die Deklaration brauchen wir nicht mehr. Loeschen!
+}
+
+/* */
+
+SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, USHORT nMinFixLineSp,
+ USHORT *pWhichIds, USHORT nWhichIds ) :
+ CSS1Parser(),
+ pSheetItemSet(0), pItemSet(0),
+ nMinFixLineSpace( nMinFixLineSp ),
+ pSearchEntry( 0 ), bIgnoreFontFamily( FALSE ),
+ eDfltEnc( RTL_TEXTENCODING_DONTKNOW )
+{
+ // Item-Ids auch initialisieren
+ aItemIds.nFont = rPool.GetTrueWhich( SID_ATTR_CHAR_FONT, FALSE );
+ aItemIds.nPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_POSTURE, FALSE );
+ aItemIds.nWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_WEIGHT, FALSE );
+ aItemIds.nFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_FONTHEIGHT, FALSE );
+ aItemIds.nUnderline = rPool.GetTrueWhich( SID_ATTR_CHAR_UNDERLINE, FALSE );
+ aItemIds.nCrossedOut = rPool.GetTrueWhich( SID_ATTR_CHAR_STRIKEOUT, FALSE );
+ aItemIds.nColor = rPool.GetTrueWhich( SID_ATTR_CHAR_COLOR, FALSE );
+ aItemIds.nKerning = rPool.GetTrueWhich( SID_ATTR_CHAR_KERNING, FALSE );
+ aItemIds.nCaseMap = rPool.GetTrueWhich( SID_ATTR_CHAR_CASEMAP, FALSE );
+ aItemIds.nBlink = rPool.GetTrueWhich( SID_ATTR_FLASH, FALSE );
+
+ aItemIds.nLineSpacing = rPool.GetTrueWhich( SID_ATTR_PARA_LINESPACE, FALSE );
+ aItemIds.nAdjust = rPool.GetTrueWhich( SID_ATTR_PARA_ADJUST, FALSE );
+ aItemIds.nWidows = rPool.GetTrueWhich( SID_ATTR_PARA_WIDOWS, FALSE );
+ aItemIds.nOrphans = rPool.GetTrueWhich( SID_ATTR_PARA_ORPHANS, FALSE );
+ aItemIds.nFmtSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, FALSE );
+
+ aItemIds.nLRSpace = rPool.GetTrueWhich( SID_ATTR_LRSPACE, FALSE );
+ aItemIds.nULSpace = rPool.GetTrueWhich( SID_ATTR_ULSPACE, FALSE );
+ aItemIds.nBox = rPool.GetTrueWhich( SID_ATTR_BORDER_OUTER, FALSE );
+ aItemIds.nBrush = rPool.GetTrueWhich( SID_ATTR_BRUSH, FALSE );
+
+ aWhichMap.Insert( (USHORT)0, (USHORT)0 );
+ SvParser::BuildWhichTbl( aWhichMap, (USHORT *)&aItemIds,
+ sizeof(aItemIds) / sizeof(USHORT) );
+ if( pWhichIds && nWhichIds )
+ SvParser::BuildWhichTbl( aWhichMap, pWhichIds, nWhichIds );
+
+ pSheetItemSet = new SfxItemSet( rPool, aWhichMap.GetData() );
+ pSheetPropInfo = new SvxCSS1PropertyInfo;
+ pSearchEntry = new SvxCSS1MapEntry( rPool, aWhichMap.GetData() );
+}
+
+SvxCSS1Parser::~SvxCSS1Parser()
+{
+ delete pSheetItemSet;
+ delete pSheetPropInfo;
+ delete pSearchEntry;
+}
+
+
+/* */
+
+BOOL SvxCSS1Parser::ParseStyleSheet( const String& rIn )
+{
+ pItemSet = pSheetItemSet;
+ pPropInfo = pSheetPropInfo;
+
+ BOOL bSuccess = CSS1Parser::ParseStyleSheet( rIn );
+
+ // die bisher geparsten Items auf die Styles verteilt werden
+// pSheetPropInfo->CreateBoxItem( *pSheetItemSet, GetDfltBorderDist() );
+ for( USHORT i=0; i<aSelectors.Count(); i++ )
+ {
+ StyleParsed( aSelectors[i], *pSheetItemSet, *pSheetPropInfo );
+ }
+
+ // und etwas aufrauemen
+ if( aSelectors.Count() )
+ aSelectors.DeleteAndDestroy( 0, aSelectors.Count() );
+ pSheetItemSet->ClearItem();
+ pSheetPropInfo->Clear();
+
+ pItemSet = 0;
+ pPropInfo = 0;
+
+ return bSuccess;
+}
+
+BOOL SvxCSS1Parser::ParseStyleOption( const String& rIn,
+ SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo )
+{
+ pItemSet = &rItemSet;
+ pPropInfo = &rPropInfo;
+
+ BOOL bSuccess = CSS1Parser::ParseStyleOption( rIn );
+// pPropInfo->CreateBoxItem( *pItemSet, GetDfltBorderDist() );
+
+ pItemSet = 0;
+ pPropInfo = 0;
+
+ return bSuccess;
+}
+
+/* */
+
+BOOL SvxCSS1Parser::GetEnum( const CSS1PropertyEnum *pPropTable,
+ const String &rValue, USHORT& rEnum )
+{
+ String aValue( rValue );
+ aValue.ToLowerAscii();
+ while( pPropTable->pName )
+ {
+ if( !rValue.EqualsIgnoreCaseAscii( pPropTable->pName ) )
+ pPropTable++;
+ else
+ break;
+ }
+
+ if( pPropTable->pName )
+ rEnum = pPropTable->nEnum;
+
+ return (pPropTable->pName != 0);
+}
+
+void SvxCSS1Parser::PixelToTwip( long &rWidth, long &rHeight )
+{
+ if( Application::GetDefaultDevice() )
+ {
+ Size aTwipSz( rWidth, rHeight );
+ aTwipSz = Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
+ MapMode(MAP_TWIP) );
+
+ rWidth = aTwipSz.Width();
+ rHeight = aTwipSz.Height();
+ }
+}
+
+void SvxCSS1Parser::SetBorderWidth( SvxBorderLine& aBorderLine, USHORT nWidth,
+ BOOL bDouble, BOOL bTable )
+{
+ const USHORT *aWidths;
+ USHORT nSize;
+ if( !bDouble )
+ {
+ aWidths = aSBorderWidths;
+ nSize = sizeof( aSBorderWidths );
+ }
+ else if( bTable )
+ {
+ aWidths = aTDBorderWidths;
+ nSize = sizeof( aTDBorderWidths );
+ }
+ else
+ {
+ aWidths = aDBorderWidths;
+ nSize = sizeof( aDBorderWidths );
+ }
+
+ USHORT i = (nSize / sizeof(USHORT)) - 4;
+ while( i>0 &&
+ nWidth <= ((aWidths[i] + aWidths[i-4]) / 2) )
+ {
+ DBG_ASSERT( aWidths[i] > aWidths[i-4],
+ "Linienbreiten sind nicht sortiert!" );
+ i -= 4;
+ }
+
+ aBorderLine.SetOutWidth( aWidths[i+1] );
+ aBorderLine.SetInWidth( aWidths[i+2] );
+ aBorderLine.SetDistance( aWidths[i+3] );
+}
+
+ULONG SvxCSS1Parser::GetFontHeight( USHORT nSize ) const
+{
+ USHORT nHeight;
+
+ switch( nSize )
+ {
+ case 0: nHeight = 8*20; break;
+ case 1: nHeight = 10*20; break;
+ case 2: nHeight = 11*20; break;
+ case 3: nHeight = 12*20; break;
+ case 4: nHeight = 17*20; break;
+ case 5: nHeight = 20*20; break;
+ case 6:
+ default: nHeight = 32*20; break;
+ }
+
+ return nHeight;
+}
+
+const FontList *SvxCSS1Parser::GetFontList() const
+{
+ return 0;
+}
+
+SvxCSS1MapEntry *SvxCSS1Parser::GetMapEntry( const String& rKey,
+ const SvxCSS1Map& rMap ) const
+{
+ pSearchEntry->SetKey( rKey );
+
+ SvxCSS1MapEntry *pRet = 0;
+ USHORT nPos;
+ if( rMap.Seek_Entry( pSearchEntry, &nPos ) )
+ pRet = rMap[nPos];
+
+ return pRet;
+}
+
+void SvxCSS1Parser::InsertMapEntry( const String& rKey,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp,
+ SvxCSS1Map& rMap )
+{
+ SvxCSS1MapEntry *pEntry = GetMapEntry( rKey, rMap );
+ if( pEntry )
+ {
+ MergeStyles( rItemSet, rProp,
+ pEntry->GetItemSet(), pEntry->GetPropertyInfo(), TRUE );
+ }
+ else
+ {
+ rMap.Insert( new SvxCSS1MapEntry( rKey, rItemSet, rProp ) );
+ }
+}
+
+
+void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet,
+ const SvxCSS1PropertyInfo& rSrcInfo,
+ SfxItemSet& rTargetSet,
+ SvxCSS1PropertyInfo& rTargetInfo,
+ BOOL bSmart )
+{
+ if( !bSmart )
+ {
+ rTargetSet.Put( rSrcSet );
+ }
+ else
+ {
+ SvxLRSpaceItem aLRSpace( (const SvxLRSpaceItem&)rTargetSet.Get(aItemIds.nLRSpace) );
+ SvxULSpaceItem aULSpace( (const SvxULSpaceItem&)rTargetSet.Get(aItemIds.nULSpace) );
+ SvxBoxItem aBox( (const SvxBoxItem&)rTargetSet.Get(aItemIds.nBox) );
+
+ rTargetSet.Put( rSrcSet );
+
+ if( rSrcInfo.bLeftMargin || rSrcInfo.bRightMargin ||
+ rSrcInfo.bTextIndent )
+ {
+ const SvxLRSpaceItem& rNewLRSpace =
+ (const SvxLRSpaceItem&)rSrcSet.Get( aItemIds.nLRSpace );
+
+ if( rSrcInfo.bLeftMargin )
+ aLRSpace.SetLeft( rNewLRSpace.GetLeft() );
+ if( rSrcInfo.bRightMargin )
+ aLRSpace.SetRight( rNewLRSpace.GetRight() );
+ if( rSrcInfo.bTextIndent )
+ aLRSpace.SetTxtFirstLineOfst( rNewLRSpace.GetTxtFirstLineOfst() );
+
+ rTargetSet.Put( aLRSpace );
+ }
+
+ if( rSrcInfo.bTopMargin || rSrcInfo.bBottomMargin )
+ {
+ const SvxULSpaceItem& rNewULSpace =
+ (const SvxULSpaceItem&)rSrcSet.Get( aItemIds.nULSpace );
+
+ if( rSrcInfo.bTopMargin )
+ aULSpace.SetUpper( rNewULSpace.GetUpper() );
+ if( rSrcInfo.bBottomMargin )
+ aULSpace.SetLower( rNewULSpace.GetLower() );
+
+ rTargetSet.Put( aULSpace );
+ }
+ }
+
+ rTargetInfo.Merge( rSrcInfo );
+}
+
+void SvxCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
+{
+ eDfltEnc = eEnc;
+}
+
+/* */
+
+static void ParseCSS1_font_size( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ ULONG nHeight = 0;
+ USHORT nPropHeight = 100;
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ nHeight = pExpr->GetULength();
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = 0;
+ long nPHeight = (long)pExpr->GetNumber();
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nHeight = (ULONG)nPHeight;
+ }
+ break;
+//#ifdef PERCENTAGE_POSSIBLE
+ case CSS1_PERCENTAGE:
+ // nur fuer Drop-Caps!
+ nPropHeight = (USHORT)pExpr->GetNumber();
+ break;
+//#endif
+ case CSS1_IDENT:
+ {
+ USHORT nSize;
+#ifdef PERCENTAGE_POSSIBLE
+ const String& rValue = pExpr->GetString();
+#endif
+ if( SvxCSS1Parser::GetEnum( aFontSizeTable, pExpr->GetString(),
+ nSize ) )
+ {
+ nHeight = rParser.GetFontHeight( nSize );
+ }
+#ifdef PERCENTAGE_POSSIBLE
+ else if( rValue.EqualsIgnoreCaseAscii( sCSS1_PV_larger ) )
+ {
+ nPropHeight = 150;
+ }
+ else if( rValue.EqualsIgnoreCaseAscii( sCSS1_PV_smaller ) )
+ {
+ nPropHeight = 67;
+ }
+#endif
+ }
+ break;
+ }
+
+ if( nHeight || nPropHeight!=100 )
+ {
+ rItemSet.Put( SvxFontHeightItem( nHeight, nPropHeight,
+ aItemIds.nFontHeight ) );
+ }
+}
+
+/* */
+
+static void ParseCSS1_font_family( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ String aName, aStyleName, aDfltName;
+ FontFamily eFamily = FAMILY_DONTKNOW;
+ FontPitch ePitch = PITCH_DONTKNOW;
+ rtl_TextEncoding eEnc = rParser.GetDfltEncoding();
+ const FontList *pFList = rParser.GetFontList();
+ BOOL bFirst = TRUE;
+ BOOL bFound = FALSE;
+ while( pExpr && (bFirst || ','==pExpr->GetOp() || !pExpr->GetOp()) )
+ {
+ CSS1Token eType = pExpr->GetType();
+ if( CSS1_IDENT==eType || CSS1_STRING==eType )
+ {
+ String aIdent( pExpr->GetString() );
+
+ if( CSS1_IDENT==eType )
+ {
+ // Alle nachfolgenden id's sammeln und mit einem
+ // Space getrennt hintendranhaengen
+ const CSS1Expression *pNext = pExpr->GetNext();
+ while( pNext && !pNext->GetOp() &&
+ CSS1_IDENT==pNext->GetType() )
+ {
+ (aIdent += ' ') += pNext->GetString();
+ pExpr = pNext;
+ pNext = pExpr->GetNext();
+ }
+ }
+ if( aIdent.Len() )
+ {
+ if( !bFound && pFList )
+ {
+ sal_Handle hFont = pFList->GetFirstFontInfo( aIdent );
+ if( 0 != hFont )
+ {
+ const FontInfo& rFInfo = pFList->GetFontInfo( hFont );
+ if( RTL_TEXTENCODING_DONTKNOW != rFInfo.GetCharSet() )
+ {
+ bFound = TRUE;
+ if( RTL_TEXTENCODING_SYMBOL == rFInfo.GetCharSet() )
+ eEnc = RTL_TEXTENCODING_SYMBOL;
+ }
+ }
+ }
+ if( !bFirst )
+ aName += ';';
+ aName += aIdent;
+ }
+ }
+
+ pExpr = pExpr->GetNext();
+ bFirst = FALSE;
+ }
+
+ if( aName.Len() && !rParser.IsIgnoreFontFamily() )
+ rItemSet.Put( SvxFontItem( eFamily, aName, aStyleName, ePitch,
+ eEnc, aItemIds.nFont ) );
+}
+
+/* */
+
+static void ParseCSS1_font_weight( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_IDENT:
+ case CSS1_STRING: // MS-IE, was sonst
+ {
+ USHORT nWeight;
+ if( SvxCSS1Parser::GetEnum( aFontWeightTable, pExpr->GetString(),
+ nWeight ) )
+ {
+ rItemSet.Put( SvxWeightItem( (FontWeight)nWeight,
+ aItemIds.nWeight ) );
+ }
+ }
+ break;
+ case CSS1_NUMBER:
+ {
+ USHORT nWeight = (USHORT)pExpr->GetNumber();
+ rItemSet.Put( SvxWeightItem( nWeight>400 ? WEIGHT_BOLD
+ : WEIGHT_NORMAL,
+ aItemIds.nWeight ) );
+ }
+ break;
+ }
+}
+
+/* */
+
+static void ParseCSS1_font_style( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ BOOL bPosture = FALSE;
+ BOOL bCaseMap = FALSE;
+ FontItalic eItalic;
+ SvxCaseMap eCaseMap;
+
+ // normal | italic || small-caps | oblique || small-caps | small-caps
+ // (wobei nor noch normal | italic und oblique zulaessig sind
+
+ // der Wert kann zwei Werte enthalten!
+ for( USHORT i=0; pExpr && i<2; i++ )
+ {
+ // Auch hier hinterlaesst MS-IEs Parser seine Spuren
+ if( (CSS1_IDENT==pExpr->GetType() || CSS1_STRING==pExpr->GetType()) &&
+ !pExpr->GetOp() )
+ {
+ const String& rValue = pExpr->GetString();
+ // erstmal pruefen, ob es ein Italic-Wert oder 'normal' ist
+ USHORT nItalic;
+ if( SvxCSS1Parser::GetEnum( aFontStyleTable, rValue, nItalic ) )
+ {
+ eItalic = (FontItalic)nItalic;
+ if( !bCaseMap && ITALIC_NONE==eItalic )
+ {
+ // fuer 'normal' muessen wir auch die case-map aussch.
+ eCaseMap = SVX_CASEMAP_NOT_MAPPED;
+ bCaseMap = TRUE;
+ }
+ bPosture = TRUE;
+ }
+ else if( !bCaseMap &&
+ rValue.EqualsIgnoreCaseAscii(sCSS1_PV_small_caps) )
+ {
+ eCaseMap = SVX_CASEMAP_KAPITAELCHEN;
+ bCaseMap = TRUE;
+ }
+ }
+
+ // den naechsten Ausdruck holen
+ pExpr = pExpr->GetNext();
+ }
+
+ if( bPosture )
+ rItemSet.Put( SvxPostureItem( eItalic, aItemIds.nPosture ) );
+
+ if( bCaseMap )
+ rItemSet.Put( SvxCaseMapItem( eCaseMap, aItemIds.nCaseMap ) );
+}
+
+/* */
+
+static void ParseCSS1_font_variant( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ // normal | small-caps
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_IDENT:
+ {
+ USHORT nCaseMap;
+ if( SvxCSS1Parser::GetEnum( aFontVariantTable, pExpr->GetString(),
+ nCaseMap ) )
+ {
+ rItemSet.Put( SvxCaseMapItem( (SvxCaseMap)nCaseMap,
+ aItemIds.nCaseMap ) );
+ }
+ }
+ }
+}
+
+/* */
+
+static void ParseCSS1_color( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_IDENT:
+ case CSS1_RGB:
+ case CSS1_HEXCOLOR:
+ case CSS1_STRING: // Wegen MS-IE
+ {
+ Color aColor;
+ if( pExpr->GetColor( aColor ) )
+ rItemSet.Put( SvxColorItem( aColor, aItemIds.nColor ) );
+ }
+ break;
+
+ }
+}
+
+/* */
+
+static void MergeHori( SvxGraphicPosition& ePos, SvxGraphicPosition eHori )
+{
+ DBG_ASSERT( GPOS_LT==eHori || GPOS_MT==eHori || GPOS_RT==eHori,
+ "vertikale Position nicht oben" );
+
+ switch( ePos )
+ {
+ case GPOS_LT:
+ case GPOS_MT:
+ case GPOS_RT:
+ ePos = eHori;
+ break;
+
+ case GPOS_LM:
+ case GPOS_MM:
+ case GPOS_RM:
+ ePos = GPOS_LT==eHori ? GPOS_LM : (GPOS_MT==eHori ? GPOS_MM : GPOS_RM);
+ break;
+
+ case GPOS_LB:
+ case GPOS_MB:
+ case GPOS_RB:
+ ePos = GPOS_LT==eHori ? GPOS_LB : (GPOS_MT==eHori ? GPOS_MB : GPOS_RB);
+ break;
+ }
+}
+
+static void MergeVert( SvxGraphicPosition& ePos, SvxGraphicPosition eVert )
+{
+ DBG_ASSERT( GPOS_LT==eVert || GPOS_LM==eVert || GPOS_LB==eVert,
+ "horizontale Position nicht links" );
+
+ switch( ePos )
+ {
+ case GPOS_LT:
+ case GPOS_LM:
+ case GPOS_LB:
+ ePos = eVert;
+ break;
+
+ case GPOS_MT:
+ case GPOS_MM:
+ case GPOS_MB:
+ ePos = GPOS_LT==eVert ? GPOS_MT : (GPOS_LM==eVert ? GPOS_MM : GPOS_MB);
+ break;
+
+ case GPOS_RT:
+ case GPOS_RM:
+ case GPOS_RB:
+ ePos = GPOS_LT==eVert ? GPOS_RT : (GPOS_LM==eVert ? GPOS_RM : GPOS_RB);
+ break;
+ }
+}
+
+static void ParseCSS1_background( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ Color aColor;
+ String aURL;
+
+ BOOL bColor = FALSE, bTransparent = FALSE;
+ SvxGraphicPosition eRepeat = GPOS_TILED;
+ SvxGraphicPosition ePos = GPOS_LT;
+ BOOL bHori = FALSE, bVert = FALSE;
+
+ while( pExpr && !pExpr->GetOp() )
+ {
+ switch( pExpr->GetType() )
+ {
+ case CSS1_URL:
+ pExpr->GetURL( aURL );
+ break;
+
+ case CSS1_RGB:
+ bColor = pExpr->GetColor( aColor );
+ break;
+
+ case CSS1_LENGTH:
+ case CSS1_PIXLENGTH:
+ {
+ // da wir keine absolute Positionierung koennen,
+ // unterscheiden wir nur zwischen 0 und !0. Deshalb
+ // koennen Pixel auch wie alle anderen Einheiten behandelt
+ // werden.
+
+ ULONG nLength = (ULONG)pExpr->GetNumber();
+ if( !bHori )
+ {
+ ePos = nLength ? GPOS_MM : GPOS_LT;
+ bHori = TRUE;
+ }
+ else if( !bVert )
+ {
+ MergeVert( ePos, (nLength ? GPOS_LM : GPOS_LT) );
+ bVert = TRUE;
+ }
+ }
+ break;
+
+ case CSS1_PERCENTAGE:
+ {
+ // die %-Angabe wird auf den enum abgebildet
+
+ USHORT nPerc = (USHORT)pExpr->GetNumber();
+ if( !bHori )
+ {
+ ePos = nPerc < 25 ? GPOS_LT
+ : (nPerc < 75 ? GPOS_MM
+ : GPOS_RB);
+ }
+ else if( !bVert )
+ {
+ SvxGraphicPosition eVert =
+ nPerc < 25 ? GPOS_LT: (nPerc < 75 ? GPOS_LM
+ : GPOS_LB);
+ MergeVert( ePos, eVert );
+ }
+ }
+ break;
+
+ case CSS1_IDENT:
+ case CSS1_HEXCOLOR:
+ case CSS1_STRING: // Wegen MS-IE
+ {
+ USHORT nEnum;
+ const String &rValue = pExpr->GetString();
+ if( rValue.EqualsIgnoreCaseAscii( sCSS1_PV_transparent ) )
+ {
+ bTransparent = TRUE;
+ }
+ if( SvxCSS1Parser::GetEnum( aBGRepeatTable, rValue, nEnum ) )
+ {
+ eRepeat = (SvxGraphicPosition)nEnum;
+ }
+ else if( SvxCSS1Parser::GetEnum( aBGHoriPosTable, rValue, nEnum ) )
+ {
+ // <position>, horizontal
+ MergeHori( ePos, (SvxGraphicPosition)nEnum );
+ }
+ else if( SvxCSS1Parser::GetEnum( aBGVertPosTable, rValue, nEnum ) )
+ {
+ // <position>, vertikal
+ MergeVert( ePos, (SvxGraphicPosition)nEnum );
+ }
+ else if( !bColor )
+ {
+ // <color>
+ bColor = pExpr->GetColor( aColor );
+ }
+ // <scroll> kennen wir nicht
+ }
+ break;
+ }
+
+ pExpr = pExpr->GetNext();
+ }
+
+ // transparent schlaegt alles
+ if( bTransparent )
+ {
+ bColor = FALSE;
+ aURL.Erase();
+ }
+
+ // repeat hat prio gegenueber einer Position
+ if( GPOS_NONE == eRepeat )
+ eRepeat = ePos;
+
+ if( bTransparent || bColor || aURL.Len() )
+ {
+ SvxBrushItem aBrushItem( aItemIds.nBrush );
+
+ if( bTransparent )
+ aBrushItem.SetColor( Color(COL_TRANSPARENT));
+ else if( bColor )
+ aBrushItem.SetColor( aColor );
+
+ if( aURL.Len() )
+ {
+ aBrushItem.SetGraphicLink( INetURLObject::RelToAbs( aURL ) );
+ aBrushItem.SetGraphicPos( eRepeat );
+ }
+
+ rItemSet.Put( aBrushItem );
+ }
+}
+
+static void ParseCSS1_background_color( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ Color aColor;
+
+ BOOL bColor = FALSE, bTransparent = FALSE;
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_RGB:
+ bColor = pExpr->GetColor( aColor );
+ break;
+ case CSS1_IDENT:
+ case CSS1_HEXCOLOR:
+ case CSS1_STRING: // Wegen MS-IE
+ if( pExpr->GetString().EqualsIgnoreCaseAscii( sCSS1_PV_transparent ) )
+ {
+ bTransparent = TRUE;
+ }
+ else
+ {
+ // <color>
+ bColor = pExpr->GetColor( aColor );
+ }
+ break;
+ }
+
+ if( bTransparent || bColor )
+ {
+ SvxBrushItem aBrushItem( aItemIds.nBrush );
+
+ if( bTransparent )
+ aBrushItem.SetColor( Color(COL_TRANSPARENT) );
+ else if( bColor )
+ aBrushItem.SetColor( aColor);
+
+ rItemSet.Put( aBrushItem );
+ }
+}
+
+/* */
+
+static void ParseCSS1_line_height( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ USHORT nHeight = 0;
+ BYTE nPropHeight = 0;
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ nHeight = (USHORT)pExpr->GetULength();
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = 0;
+ long nPHeight = (long)pExpr->GetNumber();
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nHeight = (USHORT)nPHeight;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ {
+ USHORT nPHeight = (USHORT)pExpr->GetNumber();
+ nPropHeight = nPHeight <= 200 ? (BYTE)nPHeight : 200;
+ }
+ break;
+ case CSS1_NUMBER:
+ {
+ USHORT nPHeight = (USHORT)(pExpr->GetNumber() * 100);
+ nPropHeight = nPHeight <= 200 ? (BYTE)nPHeight : 200;
+ }
+ break;
+ }
+
+ if( nHeight )
+ {
+ if( nHeight < rParser.GetMinFixLineSpace() )
+ nHeight = rParser.GetMinFixLineSpace();
+ SvxLineSpacingItem aLSItem( nHeight, aItemIds.nLineSpacing );
+ aLSItem.SetLineHeight( nHeight );
+ aLSItem.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
+ aLSItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
+ rItemSet.Put( aLSItem );
+ }
+ else if( nPropHeight )
+ {
+ SvxLineSpacingItem aLSItem( nPropHeight, aItemIds.nLineSpacing );
+ aLSItem.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
+ if( 100 == nPropHeight )
+ aLSItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
+ else
+ aLSItem.SetPropLineSpace( nPropHeight );
+ rItemSet.Put( aLSItem );
+ }
+
+}
+
+/* */
+
+static void ParseCSS1_font( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ FontItalic eItalic = ITALIC_NONE;
+ SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
+ FontWeight eWeight = WEIGHT_NORMAL;
+
+ // [ <font-style> || <font-variant> || <font-weight> ] ?
+ while( pExpr && !pExpr->GetOp() &&
+ (CSS1_IDENT==pExpr->GetType() ||
+ CSS1_STRING==pExpr->GetType() ||
+ CSS1_NUMBER==pExpr->GetType()) )
+ {
+ if( CSS1_IDENT==pExpr->GetType() ||
+ CSS1_STRING==pExpr->GetType() )
+ {
+ const String& rValue = pExpr->GetString();
+
+ USHORT nEnum;
+
+ if( SvxCSS1Parser::GetEnum( aFontStyleTable, rValue, nEnum ) )
+ {
+ eItalic = (FontItalic)nEnum;
+ }
+ else if( SvxCSS1Parser::GetEnum( aFontVariantTable, rValue, nEnum ) )
+ {
+ eCaseMap = (SvxCaseMap)nEnum;
+ }
+ else if( SvxCSS1Parser::GetEnum( aFontWeightTable, rValue, nEnum ) )
+ {
+ eWeight = (FontWeight)nEnum;
+ }
+ }
+ else
+ {
+ eWeight = (USHORT)pExpr->GetNumber() > 400 ? WEIGHT_BOLD
+ : WEIGHT_NORMAL;
+ }
+
+ pExpr = pExpr->GetNext();
+ }
+
+ if( !pExpr || pExpr->GetOp() )
+ return;
+
+ // Da "font" alle Werte zurecksetzt, fuer die nichts angegeben ist,
+ // tun wir das hier.
+ rItemSet.Put( SvxPostureItem( eItalic, aItemIds.nPosture ) );
+ rItemSet.Put( SvxCaseMapItem( eCaseMap, aItemIds.nCaseMap ) );
+ rItemSet.Put( SvxWeightItem( eWeight, aItemIds.nWeight ) );
+
+
+ // font-size
+ CSS1Expression aExpr( pExpr->GetType(), pExpr->GetString(),
+ pExpr->GetNumber() );
+ ParseCSS1_font_size( &aExpr, rItemSet, rPropInfo, rParser );
+ pExpr = pExpr->GetNext();
+
+ if( !pExpr )
+ return;
+
+ // [ '/' line-height ]?
+ if( '/' == pExpr->GetOp() )
+ {
+ // '/' line-height
+ aExpr.Set( pExpr->GetType(), pExpr->GetString(), pExpr->GetNumber() );
+ ParseCSS1_line_height( &aExpr, rItemSet, rPropInfo, rParser );
+
+ pExpr = pExpr->GetNext();
+ }
+
+ if( !pExpr || pExpr->GetOp() )
+ return;
+
+ // font-family
+ ParseCSS1_font_family( pExpr, rItemSet, rPropInfo, rParser );
+}
+
+/* */
+
+static void ParseCSS1_letter_spacing( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ rItemSet.Put( SvxKerningItem( (short)pExpr->GetSLength(),
+ aItemIds.nKerning ) );
+ break;
+
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = (long)pExpr->GetNumber();
+ long nPHeight = 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ rItemSet.Put( SvxKerningItem( (short)nPWidth, aItemIds.nKerning ) );
+ }
+ break;
+
+ case CSS1_NUMBER:
+ if( pExpr->GetNumber() == 0 )
+ {
+ // eigentlich unnoetig, aber wir sind ja tollerant
+ rItemSet.Put( SvxKerningItem( (short)0, aItemIds.nKerning ) );
+ }
+ break;
+
+ case CSS1_IDENT:
+ case CSS1_STRING: // Vorschtshalber auch MS-IE
+ if( pExpr->GetString().EqualsIgnoreCaseAscii(sCSS1_PV_normal) )
+ {
+ rItemSet.Put( SvxKerningItem( (short)0, aItemIds.nKerning ) );
+ }
+ break;
+ }
+}
+
+/* */
+
+static void ParseCSS1_text_decoration( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ BOOL bUnderline = FALSE;
+ BOOL bCrossedOut = FALSE;
+ BOOL bBlink = FALSE;
+ BOOL bBlinkOn;
+ FontUnderline eUnderline;
+ FontStrikeout eCrossedOut;
+
+ // der Wert kann zwei Werte enthalten! Und MS-IE auch Strings
+ while( pExpr && (pExpr->GetType() == CSS1_IDENT ||
+ pExpr->GetType() == CSS1_STRING) && !pExpr->GetOp() )
+ {
+ String aValue = pExpr->GetString();
+ aValue.ToLowerAscii();
+ BOOL bKnown = FALSE;
+
+ switch( aValue.GetChar( 0 ) )
+ {
+ case 'n':
+ if( aValue.EqualsAscii( sCSS1_PV_none ) )
+ {
+ bUnderline = TRUE;
+ eUnderline = UNDERLINE_NONE;
+
+ bCrossedOut = TRUE;
+ eCrossedOut = STRIKEOUT_NONE;
+
+ bBlink = TRUE;
+ bBlinkOn = FALSE;
+
+ bKnown = TRUE;
+ }
+ break;
+
+ case 'u':
+ if( aValue.EqualsAscii( sCSS1_PV_underline ) )
+ {
+ bUnderline = TRUE;
+ eUnderline = UNDERLINE_SINGLE;
+
+ bKnown = TRUE;
+ }
+ break;
+
+ case 'l':
+ if( aValue.EqualsAscii( sCSS1_PV_line_through ) )
+ {
+ bCrossedOut = TRUE;
+ eCrossedOut = STRIKEOUT_SINGLE;
+
+ bKnown = TRUE;
+ }
+ break;
+
+ case 'b':
+ if( aValue.EqualsAscii( sCSS1_PV_blink ) )
+ {
+ bBlink = TRUE;
+ bBlinkOn = TRUE;
+
+ bKnown = TRUE;
+ }
+ break;
+ }
+
+ if( !bKnown )
+ {
+ bUnderline = TRUE;
+ eUnderline = UNDERLINE_SINGLE;
+ }
+
+ pExpr = pExpr->GetNext();
+ }
+
+ if( bUnderline )
+ rItemSet.Put( SvxUnderlineItem( eUnderline, aItemIds.nUnderline ) );
+
+ if( bCrossedOut )
+ rItemSet.Put( SvxCrossedOutItem( eCrossedOut, aItemIds.nCrossedOut ) );
+
+ if( bBlink )
+ rItemSet.Put( SvxBlinkItem( bBlinkOn, aItemIds.nBlink ) );
+}
+
+/* */
+
+static void ParseCSS1_text_align( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ if( CSS1_IDENT==pExpr->GetType() ||
+ CSS1_STRING==pExpr->GetType() ) // MS-IE, mal wieder
+ {
+ USHORT nAdjust;
+ if( SvxCSS1Parser::GetEnum( aTextAlignTable, pExpr->GetString(),
+ nAdjust ) )
+ {
+ rItemSet.Put( SvxAdjustItem( (SvxAdjust)nAdjust,
+ aItemIds.nAdjust ) );
+ }
+ }
+}
+
+/* */
+
+static void ParseCSS1_text_indent( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ short nIndent = 0;
+ BOOL bSet = FALSE;
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ nIndent = (short)pExpr->GetSLength();
+ bSet = TRUE;
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = (long)pExpr->GetNumber();
+ long nPHeight = 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nIndent = (short)nPWidth;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSet )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, FALSE,
+ &pItem ) )
+ {
+ SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
+ aLRItem.SetTxtFirstLineOfst( nIndent );
+ rItemSet.Put( aLRItem );
+ }
+ else
+ {
+ SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
+ aLRItem.SetTxtFirstLineOfst( nIndent );
+ rItemSet.Put( aLRItem );
+ }
+ rPropInfo.bTextIndent = TRUE;
+ }
+}
+
+/* */
+
+static void ParseCSS1_margin_left( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ long nLeft = 0;
+ BOOL bSet = FALSE;
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ {
+ nLeft = pExpr->GetSLength();
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ nLeft = (long)pExpr->GetNumber();
+ long nPHeight = 0;
+ SvxCSS1Parser::PixelToTwip( nLeft, nPHeight );
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSet )
+ {
+ rPropInfo.nLeftMargin = nLeft;
+ if( nLeft < 0 )
+ nLeft = 0;
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, FALSE,
+ &pItem ) )
+ {
+ SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
+ aLRItem.SetTxtLeft( (USHORT)nLeft );
+ rItemSet.Put( aLRItem );
+ }
+ else
+ {
+ SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
+ aLRItem.SetTxtLeft( (USHORT)nLeft );
+ rItemSet.Put( aLRItem );
+ }
+ rPropInfo.bLeftMargin = TRUE;
+ }
+}
+
+/* */
+
+static void ParseCSS1_margin_right( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ long nRight = 0;
+ BOOL bSet = FALSE;
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ {
+ nRight = pExpr->GetSLength();
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ nRight = (long)pExpr->GetNumber();
+ long nPHeight = 0;
+ SvxCSS1Parser::PixelToTwip( nRight, nPHeight );
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSet )
+ {
+ rPropInfo.nRightMargin = nRight;
+ if( nRight < 0 )
+ nRight = 0;
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, FALSE,
+ &pItem ) )
+ {
+ SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
+ aLRItem.SetRight( (USHORT)nRight );
+ rItemSet.Put( aLRItem );
+ }
+ else
+ {
+ SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
+ aLRItem.SetRight( (USHORT)nRight );
+ rItemSet.Put( aLRItem );
+ }
+ rPropInfo.bRightMargin = TRUE;
+ }
+}
+
+/* */
+
+static void ParseCSS1_margin_top( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ USHORT nUpper = 0;
+ BOOL bSet = FALSE;
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ {
+ long nTmp = pExpr->GetSLength();
+ if( nTmp < 0 )
+ nTmp = 0;
+ nUpper = (USHORT)nTmp;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = 0;
+ long nPHeight = (long)pExpr->GetNumber();
+ if( nPHeight < 0 )
+ nPHeight = 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nUpper = (USHORT)nPHeight;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSet )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, FALSE,
+ &pItem ) )
+ {
+ SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
+ aULItem.SetUpper( nUpper );
+ rItemSet.Put( aULItem );
+ }
+ else
+ {
+ SvxULSpaceItem aULItem( aItemIds.nULSpace );
+ aULItem.SetUpper( nUpper );
+ rItemSet.Put( aULItem );
+ }
+ rPropInfo.bTopMargin = TRUE;
+ }
+}
+
+/* */
+
+static void ParseCSS1_margin_bottom( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ USHORT nLower = 0;
+ BOOL bSet = FALSE;
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ {
+ long nTmp = pExpr->GetSLength();
+ if( nTmp < 0 )
+ nTmp = 0;
+ nLower = (USHORT)nTmp;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = 0;
+ long nPHeight = (long)pExpr->GetNumber();
+ if( nPHeight < 0 )
+ nPHeight = 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nLower = (USHORT)nPHeight;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSet )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, FALSE,
+ &pItem ) )
+ {
+ SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
+ aULItem.SetLower( nLower );
+ rItemSet.Put( aULItem );
+ }
+ else
+ {
+ SvxULSpaceItem aULItem( aItemIds.nULSpace );
+ aULItem.SetLower( nLower );
+ rItemSet.Put( aULItem );
+ }
+ rPropInfo.bBottomMargin = TRUE;
+ }
+}
+
+/* */
+
+static void ParseCSS1_margin( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ long nMargins[4] = { 0, 0, 0, 0 };
+ BOOL bSetMargins[4] = { FALSE, FALSE, FALSE, FALSE };
+
+ for( USHORT i=0; pExpr && i<4 && !pExpr->GetOp(); i++ )
+ {
+ BOOL bSetThis = FALSE;
+ long nMargin;
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ {
+ nMargin = pExpr->GetSLength();
+ bSetThis = TRUE;
+ }
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = 0;
+ nMargin = (long)pExpr->GetNumber();
+ SvxCSS1Parser::PixelToTwip( nPWidth, nMargin );
+ bSetThis = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSetThis )
+ {
+ // 0 = top
+ // 1 = right
+ // 2 = bottom
+ // 3 = left
+ switch( i )
+ {
+ case 0:
+ nMargins[0] = nMargins[1] =nMargins[2] = nMargins[3] = nMargin;
+ bSetMargins[0] = bSetMargins[1] =
+ bSetMargins[2] = bSetMargins[3] = TRUE;
+ break;
+ case 1:
+ nMargins[1] = nMargins[3] = nMargin; // right + left
+ bSetMargins[1] = bSetMargins[3] = TRUE;
+ break;
+ case 2:
+ nMargins[2] = nMargin; // bottom
+ bSetMargins[2] = TRUE;
+ break;
+ case 3:
+ nMargins[3] = nMargin; // left
+ bSetMargins[3] = TRUE;
+ break;
+ }
+ }
+ pExpr = pExpr->GetNext();
+ }
+
+ if( bSetMargins[3] || bSetMargins[1] )
+ {
+ if( bSetMargins[3] )
+ {
+ rPropInfo.bLeftMargin = TRUE;
+ rPropInfo.nLeftMargin = nMargins[3];
+ if( nMargins[3] < 0 )
+ nMargins[3] = 0;
+ }
+ if( bSetMargins[1] )
+ {
+ rPropInfo.bRightMargin = TRUE;
+ rPropInfo.nRightMargin = nMargins[1];
+ if( nMargins[1] < 0 )
+ nMargins[1] = 0;
+ }
+
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, FALSE,
+ &pItem ) )
+ {
+ SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
+ if( bSetMargins[3] )
+ aLRItem.SetLeft( (USHORT)nMargins[3] );
+ if( bSetMargins[1] )
+ aLRItem.SetRight( (USHORT)nMargins[1] );
+ rItemSet.Put( aLRItem );
+ }
+ else
+ {
+ SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
+ if( bSetMargins[3] )
+ aLRItem.SetLeft( (USHORT)nMargins[3] );
+ if( bSetMargins[1] )
+ aLRItem.SetRight( (USHORT)nMargins[1] );
+ rItemSet.Put( aLRItem );
+ }
+ }
+
+ if( bSetMargins[0] || bSetMargins[2] )
+ {
+ if( nMargins[0] < 0 )
+ nMargins[0] = 0;
+ if( nMargins[2] < 0 )
+ nMargins[2] = 0;
+
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, FALSE,
+ &pItem ) )
+ {
+ SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
+ if( bSetMargins[0] )
+ aULItem.SetUpper( (USHORT)nMargins[0] );
+ if( bSetMargins[2] )
+ aULItem.SetLower( (USHORT)nMargins[2] );
+ rItemSet.Put( aULItem );
+ }
+ else
+ {
+ SvxULSpaceItem aULItem( aItemIds.nULSpace );
+ if( bSetMargins[0] )
+ aULItem.SetUpper( (USHORT)nMargins[0] );
+ if( bSetMargins[2] )
+ aULItem.SetLower( (USHORT)nMargins[2] );
+ rItemSet.Put( aULItem );
+ }
+
+ rPropInfo.bTopMargin |= bSetMargins[0];
+ rPropInfo.bBottomMargin |= bSetMargins[2];
+ }
+}
+
+/* */
+
+static BOOL ParseCSS1_padding_xxx( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser,
+ USHORT nWhichLine )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ BOOL bSet = FALSE;
+ USHORT nDist = 0;
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_LENGTH:
+ {
+ long nTmp = pExpr->GetSLength();
+ if( nTmp < 0 )
+ nTmp = 0;
+ else if( nTmp > USHRT_MAX-1 )
+ nTmp = USHRT_MAX-1;
+ nDist = (USHORT)nTmp;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PIXLENGTH:
+ {
+ long nPWidth = (long)pExpr->GetNumber();
+ long nPHeight = 0;
+ if( nPWidth < 0 )
+ nPWidth = 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ if( nPWidth > USHRT_MAX-1 )
+ nPWidth = USHRT_MAX-1;
+ nDist = (USHORT)nPWidth;
+ bSet = TRUE;
+ }
+ break;
+ case CSS1_PERCENTAGE:
+ // koennen wir nicht
+ break;
+ }
+
+ if( bSet )
+ {
+ switch( nWhichLine )
+ {
+ case BOX_LINE_TOP: rPropInfo.nTopBorderDistance = nDist; break;
+ case BOX_LINE_BOTTOM: rPropInfo.nBottomBorderDistance = nDist;break;
+ case BOX_LINE_LEFT: rPropInfo.nLeftBorderDistance = nDist; break;
+ case BOX_LINE_RIGHT: rPropInfo.nRightBorderDistance = nDist; break;
+ }
+ }
+
+ return bSet;
+}
+
+/* */
+
+static void ParseCSS1_padding_top( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP );
+}
+
+static void ParseCSS1_padding_bottom( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
+ BOX_LINE_BOTTOM );
+}
+
+static void ParseCSS1_padding_left( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT );
+}
+
+static void ParseCSS1_padding_right( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
+ BOX_LINE_RIGHT );
+}
+
+static void ParseCSS1_padding( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ USHORT n=0;
+ while( n<4 && pExpr && !pExpr->GetOp() )
+ {
+ USHORT nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
+ if( ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
+ nLine ) )
+ {
+ if( n==0 )
+ {
+ rPropInfo.nTopBorderDistance = rPropInfo.nBottomBorderDistance;
+ rPropInfo.nLeftBorderDistance = rPropInfo.nTopBorderDistance;
+ }
+ if( n <= 1 )
+ rPropInfo.nRightBorderDistance = rPropInfo.nLeftBorderDistance;
+ }
+
+ pExpr = pExpr->GetNext();
+ n++;
+ }
+}
+
+/* */
+
+static void ParseCSS1_border_xxx( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser,
+ USHORT nWhichLine, BOOL bAll )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ USHORT nWidth = USHRT_MAX; // die Linien-Dicke
+ USHORT nNWidth = 1; // benannte Linien-Dicke (und default)
+ CSS1BorderStyle eStyle = CSS1_BS_NONE; // Linien-Style
+ Color aColor;
+ BOOL bColor = FALSE;
+
+ while( pExpr && !pExpr->GetOp() )
+ {
+ switch( pExpr->GetType() )
+ {
+ case CSS1_RGB:
+ case CSS1_HEXCOLOR:
+ if( pExpr->GetColor( aColor ) )
+ bColor = TRUE;
+ break;
+
+ case CSS1_IDENT:
+ {
+ const String& rValue = pExpr->GetString();
+ USHORT nValue;
+ if( SvxCSS1Parser::GetEnum( aBorderWidthTable, rValue, nValue ) )
+ {
+ nNWidth = nValue;
+ }
+ else if( SvxCSS1Parser::GetEnum( aBorderStyleTable, rValue, nValue ) )
+ {
+ eStyle = (CSS1BorderStyle)nValue;
+ }
+ else if( pExpr->GetColor( aColor ) )
+ {
+ bColor = TRUE;
+ }
+ }
+ break;
+
+ case CSS1_LENGTH:
+ nWidth = (USHORT)pExpr->GetULength();
+ break;
+
+ case CSS1_PIXLENGTH:
+ {
+ BOOL bHori = nWhichLine == BOX_LINE_TOP ||
+ nWhichLine == BOX_LINE_BOTTOM;
+ // Ein Pixel wird zur Haarlinie (ist huebscher)
+ long nWidthL = (long)pExpr->GetNumber();
+ if( nWidthL > 1 )
+ {
+ long nPWidth = bHori ? 0 : nWidthL;
+ long nPHeight = bHori ? nWidthL : 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nWidth = (USHORT)(bHori ? nPHeight : nPWidth);
+ }
+ else
+ nWidth = 1;
+ }
+ break;
+ }
+
+ pExpr = pExpr->GetNext();
+ }
+
+ for( USHORT i=0; i<4; i++ )
+ {
+ USHORT nLine;
+ switch( i )
+ {
+ case 0: nLine = BOX_LINE_TOP; break;
+ case 1: nLine = BOX_LINE_BOTTOM; break;
+ case 2: nLine = BOX_LINE_LEFT; break;
+ case 3: nLine = BOX_LINE_RIGHT; break;
+ }
+
+ if( bAll || nLine == nWhichLine )
+ {
+ SvxCSS1BorderInfo *pInfo = rPropInfo.GetBorderInfo( nLine );
+ pInfo->eStyle = eStyle;
+ pInfo->nAbsWidth = nWidth;
+ pInfo->nNamedWidth = nNWidth;
+ if( bColor )
+ pInfo->aColor = aColor;
+ }
+ }
+}
+
+static void ParseCSS1_border_xxx_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser,
+ USHORT nWhichLine )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ USHORT nWidth = USHRT_MAX; // die Linien-Dicke
+ USHORT nNWidth = 1; // benannte Linien-Dicke (und default)
+
+ switch( pExpr->GetType() )
+ {
+ case CSS1_IDENT:
+ {
+ USHORT nValue;
+ if( SvxCSS1Parser::GetEnum( aBorderWidthTable, pExpr->GetString(), nValue ) )
+ {
+ nNWidth = nValue;
+ }
+ }
+ break;
+
+ case CSS1_LENGTH:
+ nWidth = (USHORT)pExpr->GetULength();
+ break;
+
+ case CSS1_PIXLENGTH:
+ {
+ BOOL bHori = nWhichLine == BOX_LINE_TOP ||
+ nWhichLine == BOX_LINE_BOTTOM;
+ long nWidthL = (long)pExpr->GetNumber();
+ long nPWidth = bHori ? 0 : nWidthL;
+ long nPHeight = bHori ? nWidthL : 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ nWidth = (USHORT)(bHori ? nPHeight : nPWidth);
+ }
+ break;
+ }
+
+ SvxCSS1BorderInfo *pInfo = rPropInfo.GetBorderInfo( nWhichLine );
+ pInfo->nAbsWidth = nWidth;
+ pInfo->nNamedWidth = nNWidth;
+}
+
+/* */
+
+static void ParseCSS1_border_top_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP );
+}
+
+static void ParseCSS1_border_right_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_RIGHT );
+}
+
+static void ParseCSS1_border_bottom_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_BOTTOM );
+}
+
+static void ParseCSS1_border_left_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT );
+}
+
+static void ParseCSS1_border_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ USHORT n=0;
+ while( n<4 && pExpr && !pExpr->GetOp() )
+ {
+ USHORT nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
+ ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, nLine );
+ rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_WIDTH );
+
+ pExpr = pExpr->GetNext();
+ n++;
+ }
+}
+
+static void ParseCSS1_border_color( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ USHORT n=0;
+ while( n<4 && pExpr && !pExpr->GetOp() )
+ {
+ USHORT nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
+ Color aColor;
+ switch( pExpr->GetType() )
+ {
+ case CSS1_RGB:
+ case CSS1_HEXCOLOR:
+ case CSS1_IDENT:
+ if( pExpr->GetColor( aColor ) )
+ rPropInfo.GetBorderInfo( nLine )->aColor = aColor;
+ break;
+ }
+ rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_COLOR );
+
+ pExpr = pExpr->GetNext();
+ n++;
+ }
+}
+
+static void ParseCSS1_border_style( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ USHORT n=0;
+ while( n<4 && pExpr && !pExpr->GetOp() )
+ {
+ USHORT nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
+ USHORT nValue;
+ if( CSS1_IDENT==pExpr->GetType() &&
+ SvxCSS1Parser::GetEnum( aBorderStyleTable, pExpr->GetString(),
+ nValue ) )
+ {
+ rPropInfo.GetBorderInfo( nLine )->eStyle = (CSS1BorderStyle)nValue;
+ }
+ rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_STYLE );
+
+ pExpr = pExpr->GetNext();
+ n++;
+ }
+}
+
+
+static void ParseCSS1_border_top( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP, FALSE );
+}
+
+static void ParseCSS1_border_right( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_RIGHT, FALSE );
+}
+
+static void ParseCSS1_border_bottom( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_BOTTOM, FALSE );
+}
+
+static void ParseCSS1_border_left( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT, FALSE );
+}
+
+static void ParseCSS1_border( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, 0, TRUE );
+}
+
+/* */
+
+static void ParseCSS1_float( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ if( CSS1_IDENT==pExpr->GetType() )
+ {
+ USHORT nFloat;
+ if( SvxCSS1Parser::GetEnum( aFloatTable, pExpr->GetString(), nFloat ) )
+ rPropInfo.eFloat = (SvxAdjust)nFloat;
+ }
+}
+
+
+/* */
+
+static void ParseCSS1_position( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ DBG_ASSERT( pExpr, "kein Ausdruck" );
+
+ if( CSS1_IDENT==pExpr->GetType() )
+ {
+ USHORT nPos;
+ if( SvxCSS1Parser::GetEnum( aPositionTable, pExpr->GetString(), nPos ) )
+ rPropInfo.ePosition = (SvxCSS1Position)nPos;
+ }
+}
+
+/* */
+
+static void ParseCSS1_length( const CSS1Expression *pExpr,
+ long& rLength,
+ SvxCSS1LengthType& rLengthType,
+ BOOL bHori )
+{
+ switch( pExpr->GetType() )
+ {
+ case CSS1_IDENT:
+ if( pExpr->GetString().EqualsIgnoreCaseAscii( sCSS1_PV_auto ) )
+ {
+ rLength = 0;
+ rLengthType = SVX_CSS1_LTYPE_AUTO;
+ }
+ break;
+
+ case CSS1_LENGTH:
+ rLength = pExpr->GetSLength();
+ rLengthType = SVX_CSS1_LTYPE_TWIP;
+ break;
+
+ case CSS1_PIXLENGTH:
+ case CSS1_NUMBER: // wegen Netscape und IE
+ {
+ long nWidthL = (long)pExpr->GetNumber();
+ long nPWidth = bHori ? 0 : nWidthL;
+ long nPHeight = bHori ? nWidthL : 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ rLength = (bHori ? nPHeight : nPWidth);
+ rLengthType = SVX_CSS1_LTYPE_TWIP;
+ }
+ break;
+
+ case CSS1_PERCENTAGE:
+ rLength = (long)pExpr->GetNumber();
+ if( rLength > 100 )
+ rLength = 100;
+ rLengthType = SVX_CSS1_LTYPE_PERCENTAGE;
+ break;
+ }
+}
+
+/* */
+
+static void ParseCSS1_width( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_length( pExpr, rPropInfo.nWidth, rPropInfo.eWidthType, TRUE );
+}
+
+static void ParseCSS1_height( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_length( pExpr, rPropInfo.nHeight, rPropInfo.eHeightType, FALSE );
+}
+
+static void ParseCSS1_left( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_length( pExpr, rPropInfo.nLeft, rPropInfo.eLeftType, TRUE );
+}
+
+static void ParseCSS1_top( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_length( pExpr, rPropInfo.nTop, rPropInfo.eTopType, FALSE );
+}
+
+/* */
+
+// Feature: PrintExt
+static void ParseCSS1_size( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ USHORT n=0;
+ while( n<2 && pExpr && !pExpr->GetOp() )
+ {
+ switch( pExpr->GetType() )
+ {
+ case CSS1_IDENT:
+ {
+ USHORT nValue;
+ if( SvxCSS1Parser::GetEnum( aSizeTable, pExpr->GetString(),
+ nValue ) )
+ {
+ rPropInfo.eSizeType = (SvxCSS1SizeType)nValue;
+ }
+ }
+ break;
+
+ case CSS1_LENGTH:
+ rPropInfo.nHeight = pExpr->GetSLength();
+ if( n==0 )
+ rPropInfo.nWidth = rPropInfo.nHeight;
+ rPropInfo.eSizeType = SVX_CSS1_STYPE_TWIP;
+ break;
+
+ case CSS1_PIXLENGTH:
+ {
+ long nPHeight = (long)pExpr->GetNumber();
+ long nPWidth = n==0 ? nPHeight : 0;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ rPropInfo.nHeight = nPHeight;
+ if( n==0 )
+ rPropInfo.nWidth = nPWidth;
+ rPropInfo.eSizeType = SVX_CSS1_STYPE_TWIP;
+ }
+ break;
+ }
+
+ pExpr = pExpr->GetNext();
+ n++;
+ }
+}
+
+// /Feature: PrintExt
+
+/* */
+
+// Feature: PrintExt
+
+static void ParseCSS1_page_break_xxx( const CSS1Expression *pExpr,
+ SvxCSS1PageBreak& rPBreak )
+{
+ if( CSS1_IDENT == pExpr->GetType() )
+ {
+ USHORT nValue;
+ if( SvxCSS1Parser::GetEnum( aPageBreakTable, pExpr->GetString(),
+ nValue ) )
+ {
+ rPBreak = (SvxCSS1PageBreak)nValue;
+ }
+ }
+}
+
+static void ParseCSS1_page_break_before( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_page_break_xxx( pExpr, rPropInfo.ePageBreakBefore );
+}
+
+static void ParseCSS1_page_break_after( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ ParseCSS1_page_break_xxx( pExpr, rPropInfo.ePageBreakAfter );
+}
+
+static void ParseCSS1_page_break_inside( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ SvxCSS1PageBreak eBreak;
+ ParseCSS1_page_break_xxx( pExpr, eBreak );
+
+ BOOL bSetSplit = FALSE, bSplit = TRUE;
+ switch( eBreak )
+ {
+ case SVX_CSS1_PBREAK_AUTO:
+ bSetSplit = TRUE;
+ break;
+ case SVX_CSS1_PBREAK_AVOID:
+ bSplit = FALSE;
+ bSetSplit = TRUE;
+ break;
+ }
+
+ if( bSetSplit )
+ rItemSet.Put( SvxFmtSplitItem( bSplit, aItemIds.nFmtSplit ) );
+}
+
+static void ParseCSS1_widows( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ if( CSS1_NUMBER == pExpr->GetType() )
+ {
+ BYTE nVal = pExpr->GetNumber() <= 255
+ ? (BYTE)pExpr->GetNumber()
+ : 255;
+ SvxWidowsItem aWidowsItem( nVal, aItemIds.nWidows );
+ rItemSet.Put( aWidowsItem );
+ }
+}
+
+static void ParseCSS1_orphans( const CSS1Expression *pExpr,
+ SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo,
+ const SvxCSS1Parser& rParser )
+{
+ if( CSS1_NUMBER == pExpr->GetType() )
+ {
+ BYTE nVal = pExpr->GetNumber() <= 255
+ ? (BYTE)pExpr->GetNumber()
+ : 255;
+ SvxOrphansItem aOrphansItem( nVal, aItemIds.nOrphans );
+ rItemSet.Put( aOrphansItem );
+ }
+}
+// /Feature: PrintExt
+
+/* */
+
+// die Zuordung Property zu parsender Funktion
+struct CSS1PropEntry
+{
+ union
+ {
+ const sal_Char *sName;
+ String *pName;
+ };
+ FnParseCSS1Prop pFunc;
+};
+
+#define CSS1_PROP_ENTRY(p) \
+ { sCSS1_P_##p, ParseCSS1_##p }
+
+
+// die Tabelle mit den Zuordnungen
+static CSS1PropEntry __FAR_DATA aCSS1PropFnTab[] =
+{
+ CSS1_PROP_ENTRY(background),
+ CSS1_PROP_ENTRY(background_color),
+ CSS1_PROP_ENTRY(border_top_width),
+ CSS1_PROP_ENTRY(border_right_width),
+ CSS1_PROP_ENTRY(border_bottom_width),
+ CSS1_PROP_ENTRY(border_left_width),
+ CSS1_PROP_ENTRY(border_width),
+ CSS1_PROP_ENTRY(border_color),
+ CSS1_PROP_ENTRY(border_style),
+ CSS1_PROP_ENTRY(border_top),
+ CSS1_PROP_ENTRY(border_right),
+ CSS1_PROP_ENTRY(border_bottom),
+ CSS1_PROP_ENTRY(border_left),
+ CSS1_PROP_ENTRY(border),
+ CSS1_PROP_ENTRY(color),
+ CSS1_PROP_ENTRY(float),
+ CSS1_PROP_ENTRY(font_size),
+ CSS1_PROP_ENTRY(font_family),
+ CSS1_PROP_ENTRY(font_style),
+ CSS1_PROP_ENTRY(font_variant),
+ CSS1_PROP_ENTRY(font_weight),
+ CSS1_PROP_ENTRY(letter_spacing),
+ CSS1_PROP_ENTRY(line_height),
+ CSS1_PROP_ENTRY(font),
+ CSS1_PROP_ENTRY(text_align),
+ CSS1_PROP_ENTRY(text_decoration),
+ CSS1_PROP_ENTRY(text_indent),
+ CSS1_PROP_ENTRY(margin_left),
+ CSS1_PROP_ENTRY(margin_right),
+ CSS1_PROP_ENTRY(margin_top),
+ CSS1_PROP_ENTRY(margin_bottom),
+ CSS1_PROP_ENTRY(margin),
+ CSS1_PROP_ENTRY(padding_top),
+ CSS1_PROP_ENTRY(padding_bottom),
+ CSS1_PROP_ENTRY(padding_left),
+ CSS1_PROP_ENTRY(padding_right),
+ CSS1_PROP_ENTRY(padding),
+ CSS1_PROP_ENTRY(position),
+ CSS1_PROP_ENTRY(left),
+ CSS1_PROP_ENTRY(top),
+ CSS1_PROP_ENTRY(width),
+ CSS1_PROP_ENTRY(height),
+// Feature: PrintExt
+ CSS1_PROP_ENTRY(size),
+ CSS1_PROP_ENTRY(page_break_before),
+ CSS1_PROP_ENTRY(page_break_after),
+ CSS1_PROP_ENTRY(page_break_inside),
+ CSS1_PROP_ENTRY(widows),
+ CSS1_PROP_ENTRY(orphans)
+// /Feature: PrintExt
+};
+
+/* */
+
+static int __FAR_DATA bSortedPropFns = FALSE;
+
+extern "C"
+{
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC )
+ _Optlink
+#endif
+ CSS1PropEntryCompare( const void *pFirst, const void *pSecond)
+{
+ int nRet;
+ if( ((CSS1PropEntry*)pFirst)->pFunc )
+ {
+ if( ((CSS1PropEntry*)pSecond)->pFunc )
+ nRet = strcmp( ((CSS1PropEntry*)pFirst)->sName ,
+ ((CSS1PropEntry*)pSecond)->sName );
+ else
+ nRet = -1 * ((CSS1PropEntry*)pSecond)->pName->CompareToAscii(
+ ((CSS1PropEntry*)pFirst)->sName );
+ }
+ else
+ {
+ if( ((CSS1PropEntry*)pSecond)->pFunc )
+ nRet = ((CSS1PropEntry*)pFirst)->pName->CompareToAscii(
+ ((CSS1PropEntry*)pSecond)->sName );
+ else
+ nRet = ((CSS1PropEntry*)pFirst)->pName->CompareTo(
+ *((CSS1PropEntry*)pSecond)->pName );
+ }
+
+ return nRet;
+}
+}
+
+void SvxCSS1Parser::ParseProperty( const String& rProperty,
+ const CSS1Expression *pExpr )
+{
+ DBG_ASSERT( pItemSet, "DeclarationParsed() ohne ItemSet" );
+
+ if( !bSortedPropFns )
+ {
+ qsort( (void*) aCSS1PropFnTab,
+ sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
+ sizeof( CSS1PropEntry ),
+ CSS1PropEntryCompare );
+ bSortedPropFns = TRUE;
+ }
+
+ String aTmp( rProperty );
+ aTmp.ToLowerAscii();
+
+ CSS1PropEntry aSrch;
+ aSrch.pName = &aTmp;
+
+ void* pFound;
+ if( 0 != ( pFound = bsearch( (char *) &aSrch,
+ (void*) aCSS1PropFnTab,
+ sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
+ sizeof( CSS1PropEntry ),
+ CSS1PropEntryCompare )))
+ {
+ (((CSS1PropEntry*)pFound)->pFunc)( pExpr, *pItemSet, *pPropInfo, *this );
+ }
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/svxcss1.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.70 2000/09/18 16:04:47 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.69 2000/06/26 09:52:38 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.68 2000/04/10 12:20:57 mib
+ unicode
+
+ Revision 1.67 2000/03/03 15:21:01 os
+ StarView remainders removed
+
+ Revision 1.66 2000/02/11 14:37:41 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.65 1999/09/17 12:14:44 mib
+ support of multiple and non system text encodings
+
+ Revision 1.64 1999/06/11 14:44:24 MIB
+ Individuelle Umrandungs-Abstaende
+
+
+ Rev 1.63 11 Jun 1999 16:44:24 MIB
+ Individuelle Umrandungs-Abstaende
+
+ Rev 1.62 15 Apr 1999 13:44:52 MIB
+ background-color
+
+ Rev 1.61 26 Jan 1999 14:44:58 MIB
+ #60875#: Beim Umrechnen von Lanegen in Twip Rundung beachten
+
+ Rev 1.60 14 Jan 1999 13:28:28 MIB
+ #60776#: Festen statt minimalen Zeilen-Abstand einstellen
+
+ Rev 1.59 06 Nov 1998 15:33:36 MIB
+ #59043#: negative Absatz-Einzuege
+
+ Rev 1.58 19 Oct 1998 11:07:00 MIB
+ #58088#: top/left/width/height: Zahlen ohne Einheit wie Pixel behandeln
+
+ Rev 1.57 09 Oct 1998 16:02:50 MIB
+ #57813#: Memory-Leak beseitigt
+
+ Rev 1.56 08 Sep 1998 16:22:52 MIB
+ #56120#: margin-Property kommt jetzt auch mit nicht unterstuetzten Einheiten zurecht
+
+ Rev 1.55 13 Jul 1998 09:20:26 MIB
+ #50966#: Fonts optional ignorieren
+
+ Rev 1.54 21 Apr 1998 13:47:24 MIB
+ fix: Keine Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.53 15 Apr 1998 14:50:48 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.52 03 Apr 1998 15:11:08 MIB
+ CSS1-Padding
+
+ Rev 1.51 31 Mar 1998 11:14:44 MIB
+ 1 Pixel berite Linie wird Haarlinie
+
+ Rev 1.50 25 Mar 1998 12:10:58 MIB
+ unneotige defines weg
+
+ Rev 1.49 20 Mar 1998 10:42:42 MIB
+ Font-Listen in Font-Attributen
+
+ Rev 1.48 14 Mar 1998 19:01:06 MIB
+ Absolute-Positioning freigeschaltet
+
+ Rev 1.47 13 Mar 1998 09:24:30 MIB
+ Item-Ids nur definieren, wenn hintids.hxx nicht includet wird
+
+ Rev 1.46 20 Feb 1998 19:02:22 MA
+ header
+
+ Rev 1.45 02 Dec 1997 09:16:20 MA
+ includes
+
+ Rev 1.44 20 Oct 1997 09:50:24 MIB
+ Nur fuer absolute positioning benoetigten Code groesstenteils auskommentiert
+
+ Rev 1.43 17 Oct 1997 13:18:40 MIB
+ SvxXSS1Parser um fremde Which-Ids erweiterbar
+
+ Rev 1.42 10 Oct 1997 10:15:56 MIB
+ CSS1-Printing-Ext: @page,page-break-before/after (noch kein left/right)
+
+ Rev 1.41 12 Sep 1997 11:16:00 OS
+ ITEMID_* definiert
+
+ Rev 1.40 12 Aug 1997 13:47:08 OS
+ Header-Umstellung
+
+ Rev 1.39 11 Aug 1997 14:05:30 OM
+ Headerfile-Umstellung
+
+ Rev 1.38 31 Jul 1997 10:42:24 MIB
+ absolute poaitioning auch fuer id/class
+
+ Rev 1.37 30 Jul 1997 12:29:00 MIB
+ absolute positioning
+
+ Rev 1.36 02 Jul 1997 17:13:46 MIB
+ neue CSS1-Border-Properties
+
+ Rev 1.35 01 Jul 1997 14:10:56 MIB
+ font-Property an W3C-Recommandation/Netscape 4.0 angepasst
+
+ Rev 1.34 13 Jun 1997 17:07:56 MIB
+ Ein par MS-IE Syntax-Goodies nachgebaut
+
+ Rev 1.33 13 Jun 1997 11:56:24 MIB
+ CLASS und ID CSS1-Optionen auswerten
+
+ Rev 1.32 06 May 1997 11:06:24 TRI
+ ICC brauchte Optlink
+
+ Rev 1.31 23 Apr 1997 12:31:14 MIB
+ fix: font-family: 'sans-serif' wie font-family: sans-serif behandeln
+
+ Rev 1.30 22 Apr 1997 17:44:50 MIB
+ fix #39160#: In font-family auch zusammengestzte Namen ohne Haekchen parsen
+
+ Rev 1.29 17 Apr 1997 19:31:28 MIB
+ memory leak beseitigt
+
+ Rev 1.28 10 Mar 1997 16:57:50 MIB
+ fix #37356#: negative Absatz-Abstaende auf 0 abbilden
+
+ Rev 1.27 28 Jan 1997 11:10:34 MIB
+ float parsen
+
+ Rev 1.26 20 Dec 1996 14:00:44 MIB
+ Warnings
+
+ Rev 1.25 17 Dec 1996 10:41:06 MIB
+ neue Linienstiele ausnutzen
+
+ Rev 1.24 12 Dec 1996 16:55:54 MIB
+ Tabellen mit doppelter Umrandung
+
+ Rev 1.23 25 Nov 1996 16:55:44 MIB
+ fix #32725#: Oberer Absatz-Abstand wurde ignoriert
+
+ Rev 1.22 29 Oct 1996 15:35:28 MIB
+ Flags fuer gesetzte/nicht-gesetzte Attribut-Werte
+
+ Rev 1.21 23 Oct 1996 19:49:06 JP
+ String Umstellung: [] -> GetChar()
+
+ Rev 1.20 22 Oct 1996 10:28:38 MIB
+ Umstellung von CSS1 auf Klein-Buchstaben (u.a. wegen Amaya)
+
+ Rev 1.19 21 Oct 1996 08:58:18 MIB
+ bug fix: boder: solid ging nicht
+
+ Rev 1.18 16 Oct 1996 09:59:22 NF
+ includes...
+
+ Rev 1.17 15 Oct 1996 13:42:36 MIB
+ letter-spacing/Laufweite imp./exp.
+
+ Rev 1.16 14 Oct 1996 18:49:14 MIB
+ Am Box-Item Abstand zur Umrandung setzen
+
+ Rev 1.15 14 Oct 1996 16:42:50 MIB
+ Import CSS1-Umrandung (border)
+
+ Rev 1.14 13 Oct 1996 12:14:16 MIB
+ first-letter-Pseudo-Element/DropCaps
+
+ Rev 1.13 11 Oct 1996 16:49:04 MIB
+ font-variant und andere Anpassungen an Draft vom 11.09.96
+
+ Rev 1.12 20 Sep 1996 18:00:48 MIB
+ Itemset-Optimierungen
+
+ Rev 1.11 19 Aug 1996 18:21:02 MIB
+ Anpassungen an Draft vom 26.Juli 96
+
+ Rev 1.10 14 Aug 1996 16:22:24 MIB
+ gcc und msvc: statt *aStr nicht aStr[0] sondern aStr[(USHORT)0]
+
+ Rev 1.9 13 Aug 1996 21:11:44 sdo
+ GCC
+
+ Rev 1.8 12 Aug 1996 10:31:16 MIB
+ Anpassungen an draft vom 26.7.96, Background-Property, Scannen von Farben verb.
+
+ Rev 1.7 07 Aug 1996 13:21:30 MIB
+ Import von color und text-decoration
+
+ Rev 1.6 10 Jul 1996 15:42:04 MIB
+ Includes fuer precompiled header gerichtet
+
+ Rev 1.5 20 Jun 1996 12:34:16 MIB
+ font-style: oblique nun wie italic
+
+ Rev 1.4 18 Jun 1996 12:19:28 MIB
+ margin[-[left|right|top|bottom]]?, text-indent
+
+ Rev 1.3 17 Jun 1996 16:00:56 MIB
+ Erweiterung um Font-Properties
+
+ Rev 1.2 16 Jun 1996 14:33:36 MIB
+ Loops ausgealgert
+
+ Rev 1.1 14 Jun 1996 20:13:58 MIB
+ Properties koennen mehrere Items erzeugen, font-style-Property
+
+ Rev 1.0 14 Jun 1996 17:43:12 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
new file mode 100644
index 000000000000..85863f5bf82f
--- /dev/null
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -0,0 +1,462 @@
+/*************************************************************************
+ *
+ * $RCSfile: svxcss1.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _SVXCSS1_HXX
+#define _SVXCSS1_HXX
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+
+#ifndef _SFXITEMSET_HXX //autogen
+#include <svtools/itemset.hxx>
+#endif
+
+#ifndef _SVX_SVXENUM_HXX //autogen
+#include <svx/svxenum.hxx>
+#endif
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_USHORTS
+#include <svtools/svstdarr.hxx>
+#endif
+#ifndef _RTL_TEXTENC_H
+#include <rtl/textenc.h>
+#endif
+
+#ifndef _PARCSS1_HXX
+#include "parcss1.hxx"
+#endif
+
+class SfxItemPool;
+class SvxBoxItem;
+class FontList;
+
+/* */
+
+enum SvxCSS1Position
+{
+ SVX_CSS1_POS_NONE, // nichts angegeben
+ SVX_CSS1_POS_STATIC, // normal
+ SVX_CSS1_POS_ABSOLUTE, // absolut
+ SVX_CSS1_POS_RELATIVE, // relativ
+ SVX_CSS1_POS_END
+};
+
+
+enum SvxCSS1LengthType
+{
+ SVX_CSS1_LTYPE_NONE, // nichts angegeben
+ SVX_CSS1_LTYPE_AUTO, // automatisch
+ SVX_CSS1_LTYPE_TWIP, // twip
+ SVX_CSS1_LTYPE_PERCENTAGE, // %-Angabe
+ SVX_CSS1_LTYPE_END
+};
+
+// Feature: PrintExt
+enum SvxCSS1SizeType
+{
+ SVX_CSS1_STYPE_NONE, // nichts angegeben
+ SVX_CSS1_STYPE_AUTO, // automatisch
+ SVX_CSS1_STYPE_TWIP, // twip
+ SVX_CSS1_STYPE_LANDSCAPE, // Landscape
+ SVX_CSS1_STYPE_PORTRAIT, // Landscape
+ SVX_CSS1_STYPE_END
+};
+
+enum SvxCSS1PageBreak
+{
+ SVX_CSS1_PBREAK_NONE, // nichts angegeben
+ SVX_CSS1_PBREAK_AUTO, // automatisch
+ SVX_CSS1_PBREAK_ALWAYS, // immer
+ SVX_CSS1_PBREAK_AVOID, // nie
+ SVX_CSS1_PBREAK_LEFT, // naechste Seite ist eine linke
+ SVX_CSS1_PBREAK_RIGHT, // naechste Seite ist eine rechte
+ SVX_CSS1_PBREAK_END
+};
+
+// /Feature: PrintExt
+
+/* */
+
+struct CSS1PropertyEnum
+{
+ const sal_Char *pName; // Wert einer Property
+ sal_uInt16 nEnum; // und der dazugehoerige Wert eines Enums
+};
+
+
+/* */
+
+class SvxBorderLine;
+
+SV_DECL_PTRARR_DEL( CSS1Selectors, CSS1Selector*, 1, 1 )
+
+#define SVX_CSS1_BORDERINFO_WIDTH 1
+#define SVX_CSS1_BORDERINFO_COLOR 2
+#define SVX_CSS1_BORDERINFO_STYLE 4
+
+struct SvxCSS1BorderInfo;
+class SvxCSS1PropertyInfo
+{
+ SvxCSS1BorderInfo *aBorderInfos[4];
+
+ void DestroyBorderInfos();
+
+public:
+
+ String aId; // ID fuer Bookmarks, Rahmen etc.
+
+ sal_Bool bTopMargin : 1;
+ sal_Bool bBottomMargin : 1;
+
+ sal_Bool bLeftMargin : 1;
+ sal_Bool bRightMargin : 1;
+ sal_Bool bTextIndent : 1;
+
+ SvxAdjust eFloat;
+
+ SvxCSS1Position ePosition;
+
+ sal_uInt16 nTopBorderDistance;
+ sal_uInt16 nBottomBorderDistance;
+ sal_uInt16 nLeftBorderDistance;
+ sal_uInt16 nRightBorderDistance;
+
+ long nLeft, nTop;
+ long nWidth, nHeight;
+ long nLeftMargin, nRightMargin;
+
+ SvxCSS1LengthType eLeftType, eTopType;
+ SvxCSS1LengthType eWidthType, eHeightType;
+
+// Feature: PrintExt
+ SvxCSS1SizeType eSizeType;
+
+ SvxCSS1PageBreak ePageBreakBefore;
+ SvxCSS1PageBreak ePageBreakAfter;
+// /Feature: PrintExt
+
+ SvxCSS1PropertyInfo();
+ SvxCSS1PropertyInfo( const SvxCSS1PropertyInfo& rProp );
+ ~SvxCSS1PropertyInfo();
+
+ void Merge( const SvxCSS1PropertyInfo& rProp );
+
+ void Clear();
+
+ SvxCSS1BorderInfo *GetBorderInfo( sal_uInt16 nLine, sal_Bool bCreate=sal_True );
+ void CopyBorderInfo( sal_uInt16 nSrcLine, sal_uInt16 nDstLine, sal_uInt16 nWhat );
+ void CopyBorderInfo( sal_uInt16 nCount, sal_uInt16 nWhat );
+
+ void SetBoxItem( SfxItemSet& rItemSet, sal_uInt16 nMinBorderDist,
+ const SvxBoxItem* pDflt=0, sal_Bool bTable = sal_False );
+};
+
+class SvxCSS1MapEntry
+{
+ String aKey;
+ SfxItemSet aItemSet;
+ SvxCSS1PropertyInfo aPropInfo;
+
+public:
+
+ SvxCSS1MapEntry( SfxItemPool& rPool, const sal_uInt16 *pWhichMap ) :
+ aItemSet( rPool, pWhichMap )
+ {}
+
+ SvxCSS1MapEntry( const String& rKey, const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp );
+
+
+ const SfxItemSet& GetItemSet() const { return aItemSet; }
+ SfxItemSet& GetItemSet() { return aItemSet; }
+
+ const SvxCSS1PropertyInfo& GetPropertyInfo() const { return aPropInfo; }
+ SvxCSS1PropertyInfo& GetPropertyInfo() { return aPropInfo; }
+
+ const String& GetKey() const { return aKey; }
+ // TODO: ToUpperAscii -> ???
+ void SetKey( const String& rKey ) { aKey = rKey; aKey.ToUpperAscii(); }
+
+ friend sal_Bool operator==( const SvxCSS1MapEntry& rE1,
+ const SvxCSS1MapEntry& rE2 );
+ friend sal_Bool operator<( const SvxCSS1MapEntry& rE1,
+ const SvxCSS1MapEntry& rE2 );
+};
+
+typedef SvxCSS1MapEntry *SvxCSS1MapEntryPtr;
+SV_DECL_PTRARR_SORT_DEL( SvxCSS1Map, SvxCSS1MapEntryPtr, 5, 5 )
+
+
+#if !defined( MAC ) && !defined( ICC ) && !defined( BLC )
+inline sal_Bool operator==( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE2 )
+{
+ return rE1.aKey==rE2.aKey;
+}
+
+inline sal_Bool operator<( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE2 )
+{
+ return rE1.aKey<rE2.aKey;
+}
+#endif
+
+// Diese Klasse bereitet den Output des CSS1-Parsers auf,
+// indem die CSS1-Properties in SvxItem(Set)s umgewandelt werden.
+// Ausserdem werden die Selektoren samt zugehoeriger Item-Set
+// gespeichert.
+// Ein abgeleiteter Parser kann dies fuer einzelne Selektoren unterdruecken,
+// indem er die Methode StyleParsed ueberlaed.
+
+class SvxCSS1Parser : public CSS1Parser
+{
+ CSS1Selectors aSelectors; // Liste der "offenen" Selectoren
+
+ SvxCSS1Map aIds;
+ SvxCSS1Map aClasses;
+ SvxCSS1Map aPages;
+ SvxCSS1Map aTags;
+
+ SfxItemSet *pSheetItemSet; // der Item-Set fuer Style-Sheets
+ SfxItemSet *pItemSet; // der aktuelle Item-Set
+ SvxCSS1MapEntry *pSearchEntry;
+
+ SvxCSS1PropertyInfo *pSheetPropInfo;
+ SvxCSS1PropertyInfo *pPropInfo;
+
+ sal_uInt16 nMinFixLineSpace; // Mindest-Abstand fuer festen Zeilenabstand
+
+ rtl_TextEncoding eDfltEnc;
+
+ sal_Bool bIgnoreFontFamily;
+
+ void ParseProperty( const String& rProperty,
+ const CSS1Expression *pExpr );
+
+ SvUShorts aWhichMap; // Which-Map des Parser
+
+protected:
+
+ // Diese Methode wird fuer jeden Selektor mit dem zugehoerigen
+ // Item-Set aufgerufen. Fuer einen Selektor koennen mehrere
+ // Aufrufe erfolgen.
+ // wenn sal_True zuruckgegeben wird, wird der Item-Set bzw. der
+ // Selektor nicht mehr gespeichert!
+ // Der ItemSet darf entsprechend modifiziert werden!
+ // Die Implementierung dieser Methode gibt sal_False zurueck.
+ virtual sal_Bool StyleParsed( const CSS1Selector *pSelector,
+ SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo );
+
+ // Diese Methode wird aufgerufen, wenn ein Selektor geparst wurde
+ // Wenn bFirst gesetzt ist, wird der Inhalt von aItemSet in alle
+ // zuletzt angelegten Styles kopiert.
+ // Diese Methode sollte in abgleiteten Parsern nicht mehr
+ // ueberladen werden!
+ virtual sal_Bool SelectorParsed( const CSS1Selector *pSelector,
+ sal_Bool bFirst );
+
+ // Diese Methode wird fuer jede geparste Property aufgerufen
+ // sie fuegt das Item in den ItemSet 'pItemSet' ein
+ // Sie sollte in abgeleiteten Parsern nicht mehr ueberladen werden!
+ virtual sal_Bool DeclarationParsed( const String& rProperty,
+ const CSS1Expression *pExpr );
+
+public:
+
+
+ SvxCSS1Parser( SfxItemPool& rPool,
+ sal_uInt16 nMinFixLineSp,
+ sal_uInt16 *pWhichIds=0, sal_uInt16 nWhichIds=0 );
+ virtual ~SvxCSS1Parser();
+
+ sal_Bool IsIgnoreFontFamily() const { return bIgnoreFontFamily; }
+ void SetIgnoreFontFamily( sal_Bool bSet ) { bIgnoreFontFamily = bSet; }
+
+ // Parsen eines Style-Sheets. Fuer jeden gefundenen Selektor
+ // wird StyleParsed mit dem entsprechenem Item-Set aufgerufen
+ virtual sal_Bool ParseStyleSheet( const String& rIn );
+
+ // Parsen einer Style-Option. Hier wird einfach nur der Item-Set
+ // gefuellt.
+ sal_Bool ParseStyleOption( const String& rIn, SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo );
+
+ // Umwandeln eines Strings in den Wert eines Enums
+ static sal_Bool GetEnum( const CSS1PropertyEnum *pPropTable,
+ const String& rValue, sal_uInt16 &rEnum );
+
+ // Pixel in Twips wandeln
+ static void PixelToTwip( long &nWidth, long &nHeight );
+
+ // Die Breite einer Umrandung einstellen
+ static void SetBorderWidth( SvxBorderLine& aBorderLine, sal_uInt16 nWidth,
+ sal_Bool bDouble, sal_Bool bTable=sal_False );
+
+ // Die Font-Hoehe fuer eine bestimmte Font-Groesse (0-6) ermitteln
+ virtual sal_uInt32 GetFontHeight( sal_uInt16 nSize ) const;
+
+ virtual const FontList *GetFontList() const;
+
+ const sal_uInt16 *GetWhichMap() const { return aWhichMap.GetData(); }
+
+ SvxCSS1MapEntry *GetMapEntry( const String& rKey,
+ const SvxCSS1Map& rMap ) const;
+
+ void InsertMapEntry( const String& rKey, const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp, SvxCSS1Map& rMap );
+
+ void InsertId( const String& rId, const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp );
+
+ inline SvxCSS1MapEntry *GetId( const String& rId ) const;
+
+ void InsertClass( const String& rClass, const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp );
+
+ inline SvxCSS1MapEntry *GetClass( const String& rClass ) const;
+
+ inline void InsertPage( const String& rPage, sal_Bool bPseudo,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp );
+
+ inline SvxCSS1MapEntry *GetPage( const String& rPage, sal_Bool bPseudo ) const;
+
+ inline SvxCSS1MapEntry *GetPage( sal_uInt16 i ) const { return aPages[i]; }
+ sal_uInt16 GetPageCount() const { return aPages.Count(); }
+
+ void InsertTag( const String& rTag, const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp );
+
+ inline SvxCSS1MapEntry *GetTag( const String& rTag ) const;
+
+ void MergeStyles( const SfxItemSet& rSrcSet,
+ const SvxCSS1PropertyInfo& rSrcInfo,
+ SfxItemSet& rTargetSet,
+ SvxCSS1PropertyInfo& rTargetInfo,
+ sal_Bool bSmart );
+
+ sal_uInt16 GetMinFixLineSpace() const { return nMinFixLineSpace; }
+
+ virtual void SetDfltEncoding( rtl_TextEncoding eEnc );
+ rtl_TextEncoding GetDfltEncoding() const { return eDfltEnc; }
+};
+
+inline void SvxCSS1Parser::InsertId( const String& rId,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ InsertMapEntry( rId, rItemSet, rProp, aIds );
+}
+
+inline SvxCSS1MapEntry *SvxCSS1Parser::GetId( const String& rId ) const
+{
+ return GetMapEntry( rId, aIds );
+}
+
+inline void SvxCSS1Parser::InsertClass( const String& rClass,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ InsertMapEntry( rClass, rItemSet, rProp, aClasses );
+}
+
+inline SvxCSS1MapEntry *SvxCSS1Parser::GetClass( const String& rClass ) const
+{
+ return GetMapEntry( rClass, aClasses );
+}
+
+inline void SvxCSS1Parser::InsertPage( const String& rPage,
+ sal_Bool bPseudo,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ String aKey( rPage );
+ if( bPseudo )
+ aKey.Insert( ':', 0 );
+ InsertMapEntry( aKey, rItemSet, rProp, aPages );
+}
+
+inline SvxCSS1MapEntry *SvxCSS1Parser::GetPage( const String& rPage,
+ sal_Bool bPseudo ) const
+{
+ String aKey( rPage );
+ if( bPseudo )
+ aKey.Insert( ':', 0 );
+ return GetMapEntry( aKey, aPages );
+}
+
+inline void SvxCSS1Parser::InsertTag( const String& rTag,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ InsertMapEntry( rTag, rItemSet, rProp, aTags );
+}
+
+inline SvxCSS1MapEntry *SvxCSS1Parser::GetTag( const String& rTag ) const
+{
+ return GetMapEntry( rTag, aTags );
+}
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/swcss1.hxx b/sw/source/filter/html/swcss1.hxx
new file mode 100644
index 000000000000..386045d04c1b
--- /dev/null
+++ b/sw/source/filter/html/swcss1.hxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * $RCSfile: swcss1.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _SWCSS1_HXX
+#define _SWCSS1_HXX
+
+#ifndef _POOLFMT_HXX
+#include "poolfmt.hxx"
+#endif
+
+#include "svxcss1.hxx"
+
+class SwDoc;
+class SwFmt;
+class SwCharFmt;
+class SwTxtFmtColl;
+class SvxBrushItem;
+class SwFmtDrop;
+class SwPageDesc;
+
+// Dieser Header seiht zwar harmlos aus, included aber eben doch
+// ganz unauffaellig das ein oder andere! Andererseits wird diese
+// Klasse recht selten benoetigt. Deshalb ein eigener Header.
+
+
+class SwCSS1Parser : public SvxCSS1Parser
+{
+ SwDoc *pDoc;
+
+ ULONG aFontHeights[7];
+
+ USHORT nDropCapCnt;
+
+ BOOL bIsNewDoc : 1;
+
+ BOOL bBodyBGColorSet : 1;
+ BOOL bBodyBackgroundSet : 1;
+ BOOL bBodyTextSet : 1;
+ BOOL bBodyLinkSet : 1;
+ BOOL bBodyVLinkSet : 1;
+
+ BOOL bSetFirstPageDesc : 1;
+ BOOL bSetRightPageDesc : 1;
+
+ BOOL bTableHeaderTxtCollSet : 1;
+ BOOL bTableTxtCollSet : 1;
+
+ BOOL bLinkCharFmtsSet : 1;
+
+ // die Vorlagen fuer DL anlegen
+ SwTxtFmtColl* GetDefListTxtFmtColl( USHORT nCollId, USHORT nDeep );
+
+ const SwPageDesc* GetPageDesc( USHORT nPoolId, BOOL bCreate );
+
+ void SetTableTxtColl( BOOL bHeader );
+ void SetLinkCharFmts();
+
+protected:
+ virtual BOOL StyleParsed( const CSS1Selector *pSelector,
+ SfxItemSet& rItemSet,
+ SvxCSS1PropertyInfo& rPropInfo );
+public:
+ SwCSS1Parser( SwDoc *pDoc, ULONG aFHeight[7], BOOL bNewDoc );
+ virtual ~SwCSS1Parser();
+
+ virtual BOOL ParseStyleSheet( const String& rIn );
+
+ // Die Font-Hoehe fuer eine bestimmte Font-Groesse (0-6) ermitteln
+ virtual ULONG GetFontHeight( USHORT nSize ) const;
+
+ // Die aktuelle Font-Liste holen (auch 0 ist erlaubt)
+ virtual const FontList *GetFontList() const;
+
+ // das Zeichen-Format zu einem Token und einer ggf leeren Klasse
+ // ermitteln
+ SwCharFmt* GetChrFmt( USHORT nToken, const String& rClass ) const;
+
+ // eine TextFmtColl zu einer Pool-Id ermitteln
+ SwTxtFmtColl *GetTxtFmtColl( USHORT nTxtColl, const String& rClass );
+
+ // This methods do the same as the one of SwDoc, but change the
+ // encoding if required.
+ SwTxtFmtColl *GetTxtCollFromPool( USHORT nPoolId ) const;
+ SwCharFmt *GetCharFmtFromPool( USHORT nPoolId ) const;
+
+ // Die linke oder rechte Seiten-Vorlage holen. In Dokumenten mit nur
+ // einer Vorlage gibt es nur eine rechtee Seite.
+ // Ansonsten ist die rechte Seite die HTML-Poolvorlage und die linke
+ // eine Benutzter-Vorlage, die on-demand angelegt wird, wenn
+ // bCreate gesetzt ist.
+ SwPageDesc* GetMasterPageDesc();
+ inline const SwPageDesc* GetFirstPageDesc( BOOL bCreate=FALSE );
+ inline const SwPageDesc* GetRightPageDesc( BOOL bCreate=FALSE );
+ inline const SwPageDesc* GetLeftPageDesc( BOOL bCreate=FALSE );
+
+ // Attribute an der HTML-Seitenvorlage setzen (gesetzte Attribute
+ // werden aus dem Item-Set geloescht ). Wird fuer's BODY-Tag
+ // aufgerufen.
+ void SetPageDescAttrs( const SvxBrushItem *pBrush,
+ SfxItemSet *pItemSet=0 );
+
+ void ChgPageDesc( const SwPageDesc *pPageDesc,
+ const SwPageDesc& rNewPageDesc );
+
+ // Wird fuer @page aufgerufen.
+ void SetPageDescAttrs( const SwPageDesc *pPageDesc, SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rPropInfo );
+
+ // Fuellen eines DropCap-Attributs
+ void FillDropCap( SwFmtDrop& rDrop, SfxItemSet& rItemSet,
+ const String *pName=0 );
+
+ BOOL SetFmtBreak( SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rPropInfo );
+
+
+ static void AddClassName( String& rFmtName, const String& rClass );
+
+ static inline void AddFirstLetterExt( String& rFmtName );
+
+ static BOOL MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
+ BOOL bAutoWidth=FALSE );
+
+ BOOL IsBodyBGColorSet() const { return bBodyBGColorSet; }
+ BOOL IsBodyBackgroundSet() const { return bBodyBackgroundSet; }
+ BOOL IsBodyTextSet() const { return bBodyTextSet; }
+ BOOL IsBodyLinkSet() const { return bBodyLinkSet; }
+ BOOL IsBodyVLinkSet() const { return bBodyVLinkSet; }
+
+ BOOL IsSetFirstPageDesc() const { return bSetFirstPageDesc; }
+ BOOL IsSetRightPageDesc() const { return bSetRightPageDesc; }
+
+ void SetBodyBGColorSet() { bBodyBGColorSet = TRUE; }
+ void SetBodyBackgroundSet() { bBodyBackgroundSet = TRUE; }
+ void SetBodyTextSet() { bBodyTextSet = TRUE; }
+ void SetBodyLinkSet() { bBodyLinkSet = TRUE; }
+ void SetBodyVLinkSet() { bBodyVLinkSet = TRUE; }
+
+ const SvxBrushItem& GetPageDescBackground() const;
+
+ inline void SetTHTagStyles();
+ inline void SetTDTagStyles();
+ inline void SetATagStyles();
+ inline void SetDelayedStyles();
+
+ virtual void SetDfltEncoding( rtl_TextEncoding eEnc );
+};
+
+
+inline void SwCSS1Parser::AddFirstLetterExt( String& rFmtName )
+{
+ rFmtName.AppendAscii( ".FL", 3 ); // first letter
+}
+
+inline const SwPageDesc* SwCSS1Parser::GetFirstPageDesc( BOOL bCreate )
+{
+ return GetPageDesc( RES_POOLPAGE_FIRST, bCreate );
+}
+
+inline const SwPageDesc* SwCSS1Parser::GetRightPageDesc( BOOL bCreate )
+{
+ return GetPageDesc( RES_POOLPAGE_RIGHT, bCreate );
+}
+
+inline const SwPageDesc* SwCSS1Parser::GetLeftPageDesc( BOOL bCreate )
+{
+ return GetPageDesc( RES_POOLPAGE_LEFT, bCreate );
+}
+
+inline void SwCSS1Parser::SetTHTagStyles()
+{
+ if( !bTableHeaderTxtCollSet )
+ SetTableTxtColl( TRUE );
+}
+
+inline void SwCSS1Parser::SetTDTagStyles()
+{
+ if( !bTableTxtCollSet )
+ SetTableTxtColl( FALSE );
+}
+
+
+inline void SwCSS1Parser::SetATagStyles()
+{
+ if( !bLinkCharFmtsSet )
+ SetLinkCharFmts();
+}
+
+inline void SwCSS1Parser::SetDelayedStyles()
+{
+ SetTHTagStyles();
+ SetTDTagStyles();
+ SetATagStyles();
+}
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
new file mode 100644
index 000000000000..767de5bd214e
--- /dev/null
+++ b/sw/source/filter/html/swhtml.cxx
@@ -0,0 +1,5646 @@
+/*************************************************************************
+ *
+ * $RCSfile: swhtml.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 PRODUCT
+#include <stdlib.h>
+#endif
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#define _SVSTDARR_STRINGS
+#include <svtools/svstdarr.hxx>
+
+#ifndef _SFXSTRITEM_HXX //autogen
+#include <svtools/stritem.hxx>
+#endif
+#ifndef _IMAP_HXX //autogen
+#include <svtools/imap.hxx>
+#endif
+#ifndef _HTMLTOKN_H
+#include <svtools/htmltokn.h>
+#endif
+#ifndef _HTMLKYWD_HXX
+#include <svtools/htmlkywd.hxx>
+#endif
+#ifndef _CTRLTOOL_HXX
+#include <svtools/ctrltool.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SFX_INIMGR_HXX
+#include <sfx2/inimgr.hxx>
+#endif
+#ifndef _FSETOBJSH_HXX //autogen
+#include <sfx2/fsetobsh.hxx>
+#endif
+#ifndef _SFX_FCONTNR_HXX //autogen
+#include <sfx2/fcontnr.hxx>
+#endif
+#ifndef _SFXDOCINF_HXX //autogen
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _SFXDOCFILE_HXX //autogen
+#include <sfx2/docfile.hxx>
+#endif
+
+#ifndef _OFF_APP_HXX //autogen
+#include <offmgr/app.hxx>
+#endif
+#ifndef _OFA_HTMLCFG_HXX //autogen
+#include <offmgr/htmlcfg.hxx>
+#endif
+
+#ifndef _SVXLINKMGR_HXX
+#include <svx/linkmgr.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_BLNKITEM_HXX //autogen
+#include <svx/blnkitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_PROTITEM_HXX //autogen
+#include <svx/protitem.hxx>
+#endif
+#ifndef _SVX_FLSTITEM_HXX
+#include <svx/flstitem.hxx>
+#endif
+
+
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+#ifndef _TXTFLD_HXX //autogen
+#include <txtfld.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FCHRFMT_HXX //autogen
+#include <fchrfmt.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _DOCSTAT_HXX //autogen
+#include <docstat.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _EXPFLD_HXX
+#include <expfld.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx> // fuer SwBookmark ...
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _EDITSH_HXX
+#include <editsh.hxx> // fuer Start/EndAction
+#endif
+#ifndef _HINTS_HXX
+#include <hints.hxx> // fuer SwObjectDying
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _SWCSS1_HXX
+#include <swcss1.hxx>
+#endif
+#ifndef _HTMLVSH_HXX
+#include <htmlvsh.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _HTMLTBL_HXX
+#include <htmltbl.hxx>
+#endif
+#ifndef _HTMLNUM_HXX
+#include <htmlnum.hxx>
+#endif
+#ifndef _SWHTML_HXX
+#include <swhtml.hxx>
+#endif
+#ifndef _LINKENUM_HXX
+#include <linkenum.hxx>
+#endif
+
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+
+#define FONTSIZE_MASK 7
+#define FONTCOLOR_MASK (1<<15)
+#define FONT_MASK (1<<14)
+
+#define HTML_ESC_PROP 80
+#define HTML_ESC_SUPER DFLT_ESC_SUPER
+#define HTML_ESC_SUB DFLT_ESC_SUB
+
+#define HTML_SPTYPE_NONE 0
+#define HTML_SPTYPE_BLOCK 1
+#define HTML_SPTYPE_HORI 2
+#define HTML_SPTYPE_VERT 3
+
+#ifndef TOOLS_CONSTASCII_STRINGPARAM
+#define TOOLS_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, sizeof( constAsciiStr )-1
+#endif
+
+// <P ALIGN=xxx>, <Hn ALIGN=xxx>, <TD ALIGN=xxx> usw.
+HTMLOptionEnum __FAR_DATA aHTMLPAlignTable[] =
+{
+ { sHTML_AL_left, SVX_ADJUST_LEFT },
+ { sHTML_AL_center, SVX_ADJUST_CENTER },
+ { sHTML_AL_middle, SVX_ADJUST_CENTER }, // Netscape
+ { sHTML_AL_right, SVX_ADJUST_RIGHT },
+ { sHTML_AL_justify, SVX_ADJUST_BLOCK },
+ { sHTML_AL_char, SVX_ADJUST_LEFT },
+ { 0, 0 }
+};
+
+// <SPACER TYPE=...>
+static HTMLOptionEnum __FAR_DATA aHTMLSpacerTypeTable[] =
+{
+ { sHTML_SPTYPE_block, HTML_SPTYPE_BLOCK },
+ { sHTML_SPTYPE_horizontal, HTML_SPTYPE_HORI },
+ { sHTML_SPTYPE_vertical, HTML_SPTYPE_VERT },
+ { 0, 0 }
+};
+
+SV_IMPL_PTRARR( _HTMLAttrs, _HTMLAttrPtr )
+
+HTMLReader::HTMLReader()
+{
+ bTmplBrowseMode = TRUE;
+
+ String sTemplate(
+ String::CreateFromAscii(TOOLS_CONSTASCII_STRINGPARAM("internal")) );
+ sTemplate += INET_PATH_TOKEN;
+ sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM("html") );
+#ifndef MAC_WITHOUT_EXT
+ sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(".vor") );
+#endif
+
+ if( SFX_INIMANAGER()->SearchFile( sTemplate, SFX_KEY_TEMPLATE_PATH ))
+ SetTemplateName( sTemplate );
+#ifndef PRODUCT
+ else
+ ASSERT( !this,
+ "Die html.vor befindet sich nicht mehr im definierten Directory!");
+#endif
+}
+
+int HTMLReader::SetStrmStgPtr()
+{
+ ASSERT( pMedium, "Wo ist das Medium??" );
+
+ if( pMedium->IsRemote() || !pMedium->IsStorage() )
+ {
+ pStrm = pMedium->GetInStream();
+ return TRUE;
+ }
+ return FALSE;
+
+}
+
+ // Aufruf fuer die allg. Reader-Schnittstelle
+ULONG HTMLReader::Read( SwDoc &rDoc,SwPaM &rPam, const String & rName )
+{
+ if( !pStrm )
+ {
+ ASSERT( pStrm, "HTML-Read ohne Stream" );
+ return ERR_SWG_READ_ERROR;
+ }
+
+ if( !bInsertMode )
+ {
+ Reader::SetNoOutlineNum( rDoc );
+ Reader::ResetFrmFmts( rDoc );
+
+ rDoc.SetBrowseMode( TRUE );
+
+ // Die HTML-Seitenvorlage setzen, wenn des kein HTML-Dokument ist,
+ // sonst ist sie schon gesetzt.
+ if( !rDoc.IsHTMLMode() )
+ {
+ rDoc.Insert( rPam, SwFmtPageDesc(
+ rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML )) );
+ }
+ }
+
+ // damit keiner das Doc klaut!
+ rDoc.AddLink();
+ ULONG nRet = 0;
+ SvParserRef xParser = new SwHTMLParser( &rDoc, rPam, *pStrm,
+ rName, !bInsertMode, pMedium,
+ IsReadUTF8() );
+
+ SvParserState eState = xParser->CallParser();
+
+ if( SVPAR_PENDING == eState )
+ pStrm->ResetError();
+ else if( SVPAR_ACCEPTED != eState )
+ {
+ String sErr( String::CreateFromInt32((sal_Int32)xParser->GetLineNr()));
+ sErr += ',';
+ sErr += String::CreateFromInt32((sal_Int32)xParser->GetLinePos());
+
+ // den Stream als Fehlernummer Transporter benutzen
+ nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+ ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
+ }
+
+
+ return nRet;
+}
+
+
+/* */
+
+SwHTMLParser::SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ const String& rPath, int bReadNewDoc,
+ SfxMedium* pMed, BOOL bReadUTF8 )
+ : SfxHTMLParser( rIn, bReadNewDoc, pMed ),
+ SwClient( 0 ),
+ aPathToFile( rPath ),
+ pDoc( pD ),
+ pTable(0), pFormImpl( 0 ), pMarquee( 0 ),
+ pField( 0 ),
+ pCSS1Parser( 0 ), pNumRuleInfo( new SwHTMLNumRuleInfo ),
+ eParaAdjust( SVX_ADJUST_END ),
+ nScriptStartLineNr( 0 ),
+ nBaseFontStMin( 0 ), nFontStMin( 0 ),
+ nDefListDeep( 0 ),
+ nFontStHeadStart( 0 ),
+ nSBModuleCnt( 0 ),
+ nMissingImgMaps( 0 ),
+ nOpenParaToken( 0 ),
+ pImageMap( 0 ),
+ pImageMaps( 0 ),
+ pSttNdIdx( 0 ),
+ pPendStack( 0 ),
+ nParaCnt( 5 ),
+ pActionViewShell( 0 ),
+ pAppletImpl( 0 ),
+ pFootEndNoteImpl( 0 ),
+ nContextStMin( 0 ),
+ nContextStAttrMin( 0 ),
+ bInFloatingFrame( FALSE ),
+ bInNoEmbed( FALSE ),
+ bInField( FALSE ), bInTitle( FALSE ),
+ bInFootEndNoteAnchor( FALSE ), bInFootEndNoteSymbol( FALSE ),
+ bNoParSpace( FALSE ), bDocInitalized( FALSE ), bCallNextToken( FALSE ),
+ bDataAvailableLinkSet( FALSE ),
+ bIgnoreRawData( FALSE ),
+ bUpdateDocStat( FALSE ),
+ bFixSelectWidth( FALSE ),
+ bFixSelectHeight( FALSE ),
+ bTextArea( FALSE ), bSelect( FALSE ),
+ bSetModEnabled( FALSE ),
+ eJumpTo( JUMPTO_NONE )
+#ifndef PRODUCT
+ ,nContinue( 0 )
+#endif
+{
+
+ bUpperSpace = bViewCreated = bChkJumpMark =
+ bSetCrsr = FALSE;
+
+ eScriptLang = HTML_SL_UNKNOWN;
+ bAnyStarBasic = TRUE;
+
+ pPam = new SwPaM( *rCrsr.GetPoint() );
+ memset( &aAttrTab, 0, sizeof( _HTMLAttrTable ));
+
+ // Die Font-Groessen 1-7 aus der INI-Datei lesen
+ OfaHtmlOptions* pHtmlOptions = OFF_APP()->GetHtmlOptions();
+ aFontHeights[0] = pHtmlOptions->GetFontSize( 0 ) * 20;
+ aFontHeights[1] = pHtmlOptions->GetFontSize( 1 ) * 20;
+ aFontHeights[2] = pHtmlOptions->GetFontSize( 2 ) * 20;
+ aFontHeights[3] = pHtmlOptions->GetFontSize( 3 ) * 20;
+ aFontHeights[4] = pHtmlOptions->GetFontSize( 4 ) * 20;
+ aFontHeights[5] = pHtmlOptions->GetFontSize( 5 ) * 20;
+ aFontHeights[6] = pHtmlOptions->GetFontSize( 6 ) * 20;
+
+ bKeepUnknown = pHtmlOptions->IsImportUnknown();
+
+ pDoc->SetDefault( SvxFontHeightItem(aFontHeights[2]) );
+
+ // Waehrend des Imports in den HTML-Modus schalten, damit die
+ // richrigen Vorlagen angelegt werden
+ bOldIsHTMLMode = pDoc->IsHTMLMode();
+ pDoc->SetHTMLMode( TRUE );
+
+ pCSS1Parser = new SwCSS1Parser( pDoc, aFontHeights, IsNewDoc() );
+ pCSS1Parser->SetIgnoreFontFamily( pHtmlOptions->IsIgnoreFontFamily() );
+
+ if( bReadUTF8 )
+ {
+ SetSrcEncoding( RTL_TEXTENCODING_UTF8 );
+ }
+ else
+ {
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ SvKeyValueIterator *pHeaderAttrs =
+ pDocSh->GetHeaderAttributes();
+ if( pHeaderAttrs )
+ SetEncodingByHTTPHeader( pHeaderAttrs );
+ }
+ pCSS1Parser->SetDfltEncoding( gsl_getSystemTextEncoding() );
+ sBaseURL = INetURLObject::GetBaseURL();
+
+ // Timer nur bei ganz normalen Dokumenten aufsetzen!
+ SwDocShell* pDocSh = pDoc->GetDocShell();
+ if( pDocSh )
+ {
+ if( SFX_CREATE_MODE_INTERNAL == pDocSh->GetCreateMode() ||
+ SFX_CREATE_MODE_PREVIEW == pDocSh->GetCreateMode() )
+ bViewCreated = TRUE; // dann nicht, synchron laden
+
+ // es ist ein Sprungziel vorgegeben.
+
+ if( pMed )
+ {
+ sJmpMark = pMed->GetURLObject().GetMark();
+ if( sJmpMark.Len() )
+ {
+ eJumpTo = JUMPTO_MARK;
+ String sCmp;
+ xub_StrLen nLastPos, nPos = 0;
+ while( STRING_NOTFOUND != ( nLastPos =
+ sJmpMark.Search( cMarkSeperator, nPos + 1 )) )
+ nPos = nLastPos;
+
+ if( nPos && ( sCmp = sJmpMark.Copy( nPos + 1 ) ).
+ EraseAllChars().Len() )
+ {
+ sCmp.ToLowerAscii();
+ if( sCmp.EqualsAscii( pMarkToRegion ) )
+ eJumpTo = JUMPTO_REGION;
+ else if( sCmp.EqualsAscii( pMarkToTable ) )
+ eJumpTo = JUMPTO_TABLE;
+ else if( sCmp.EqualsAscii( pMarkToGraphic ) )
+ eJumpTo = JUMPTO_GRAPHIC;
+ else if( sCmp.EqualsAscii( pMarkToOutline ) ||
+ sCmp.EqualsAscii( pMarkToText ) ||
+ sCmp.EqualsAscii( pMarkToFrame ) )
+ eJumpTo = JUMPTO_NONE; // das ist nichts gueltiges!
+ else
+ // ansonsten ist das ein normaler (Book)Mark
+ nPos = STRING_LEN;
+ }
+ else
+ nPos = STRING_LEN;
+
+ sJmpMark.Erase( nPos );
+ if( !sJmpMark.Len() )
+ eJumpTo = JUMPTO_NONE;
+ }
+ }
+ }
+}
+
+__EXPORT SwHTMLParser::~SwHTMLParser()
+{
+#ifndef PRODUCT
+ ASSERT( !nContinue, "DTOR im Continue - Das geht schief!!!" );
+#endif
+ BOOL bAsync = pDoc->IsInLoadAsynchron();
+ pDoc->SetInLoadAsynchron( FALSE );
+ pDoc->SetHTMLMode( bOldIsHTMLMode );
+
+ if( pDoc->GetDocShell() && aLoadEnv.Is() )
+ {
+ // Den Link vor dem DocumentDetected austragen, damit
+ // wir waehrend des DocumentDetected nicht noch irgendwelche
+ // Daten bekommen, die zum nochmaligen Aufruf von
+ // DocumentDetected (in NextToken) fuehren.
+ ((SfxLoadEnvironment*)&aLoadEnv)->SetDataAvailableLink( Link() );
+ bDataAvailableLinkSet = FALSE;
+
+ // wenn noch nichts entschieden ist, dann aber hier
+ if( !bDocInitalized )
+ {
+ ErrCode eError = ((SfxLoadEnvironment*)&aLoadEnv)->
+ DocumentDetected( pDoc->GetDocShell(), 0 );
+ }
+ }
+
+ // das DocumentDetected kann ggfs. die DocShells loeschen, darum nochmals
+ // abfragen
+ if( pDoc->GetDocShell() )
+ {
+ // Gelinkte Bereiche updaten
+ USHORT nLinkMode = pDoc->GetLinkUpdMode();
+ if( nLinkMode != NEVER && bAsync &&
+ SFX_CREATE_MODE_INTERNAL!=pDoc->GetDocShell()->GetCreateMode() )
+ pDoc->GetLinkManager().UpdateAllLinks( nLinkMode == MANUAL,
+ TRUE, FALSE );
+
+ if( pDoc->GetDocShell()->IsLoading() )
+ pDoc->GetDocShell()->StartLoadFinishedTimer();
+ }
+
+ delete pSttNdIdx;
+
+ if( aSetAttrTab.Count() )
+ {
+ ASSERT( !aSetAttrTab.Count(),"Es stehen noch Attribute auf dem Stack" );
+ aSetAttrTab.DeleteAndDestroy( 0, aSetAttrTab.Count() );
+ }
+
+ delete pPam;
+ delete pCSS1Parser;
+ delete pNumRuleInfo;
+ DeleteFormImpl();
+ DeleteFootEndNoteImpl();
+
+ ASSERT( !pTable, "Es existiert noch eine offene Tabelle" );
+ delete pImageMaps;
+ //delete pTable;
+
+ ASSERT( !pPendStack,
+ "SwHTMLParser::~SwHTMLParser: Hier sollte es keinen Pending-Stack mehr geben" );
+ while( pPendStack )
+ {
+ SwPendingStack* pTmp = pPendStack;
+ pPendStack = pPendStack->pNext;
+ delete pTmp->pData;
+ delete pTmp;
+ }
+
+ if( !pDoc->RemoveLink() )
+ {
+ // keiner will mehr das Doc haben, also weg damit
+ delete pDoc;
+ }
+}
+
+SvParserState __EXPORT SwHTMLParser::CallParser()
+{
+ // einen temporaeren Index anlegen, auf Pos 0 so wird er nicht bewegt!
+ pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
+ if( !IsNewDoc() ) // in ein Dokument einfuegen ?
+ {
+ const SwPosition* pPos = pPam->GetPoint();
+ SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
+
+ pDoc->SplitNode( *pPos );
+
+ *pSttNdIdx = pPos->nNode.GetIndex()-1;
+ pDoc->SplitNode( *pPos );
+
+ pPam->Move( fnMoveBackward );
+ pDoc->SetTxtFmtColl( *pPam,
+ pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
+ }
+
+ if( GetMedium() )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == GetMedium()->GetItemSet()->GetItemState(
+ SID_LOADENVIRONMENT, FALSE, &pItem ))
+ {
+ aLoadEnv = &((SfxRefItem*)pItem)->GetValue();
+ }
+
+ if( !bViewCreated && aLoadEnv.Is() )
+ {
+ ((SfxLoadEnvironment*)&aLoadEnv)->
+ SetDataAvailableLink( GetAsynchCallLink() );
+ bDataAvailableLinkSet = TRUE;
+ }
+ else
+ bViewCreated = TRUE;
+ }
+
+ // Laufbalken anzeigen
+ else if( !GetMedium() || !GetMedium()->IsRemote() )
+ {
+ rInput.Seek(STREAM_SEEK_TO_END);
+ rInput.ResetError();
+ ::StartProgress( STR_STATSTR_W4WREAD, 0, rInput.Tell(),
+ pDoc->GetDocShell() );
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+ }
+
+ SwPageDesc& rDesc = pDoc->_GetPageDesc( 0 );
+ rDesc.Add( this );
+
+ SvParserState eRet = HTMLParser::CallParser();
+
+ return eRet;
+}
+
+void __EXPORT SwHTMLParser::Continue( int nToken )
+{
+#ifndef PRODUCT
+ ASSERT( !nContinue, "Continue im Continue - Das sollte doch nicht sein, oder?" );
+ nContinue++;
+#endif
+
+ // Wenn der Import (vom SFX) abgebrochen wurde, wird ein Fehler
+ // gesetzt aber trotzdem noch weiter gemacht, damit vernuenftig
+ // aufgeraeumt wird.
+ ASSERT( SVPAR_ERROR!=eState,
+ "SwHTMLParser::Continue: bereits ein Fehler gesetzt" );
+ if( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
+ eState = SVPAR_ERROR;
+
+ // Die ViewShell vom Dokument holen, merken und als aktuelle setzen.
+ ViewShell *pInitVSh = CallStartAction();
+
+ if( SVPAR_ERROR != eState && !pInitVSh && GetMedium() && !bViewCreated )
+ {
+ // Beim ersten Aufruf erstmal returnen, Doc anzeigen
+ // und auf Timer Callback warten.
+ // An dieser Stelle wurde im CallParser gerade mal ein Zeichen
+ // gelesen und ein SaveState(0) gerufen.
+ eState = SVPAR_PENDING;
+ bViewCreated = TRUE;
+ pDoc->SetInLoadAsynchron( TRUE );
+
+#ifndef PRODUCT
+ nContinue--;
+#endif
+
+ return;
+ }
+
+ bSetModEnabled = FALSE;
+ if( pDoc->GetDocShell() &&
+ 0 != (bSetModEnabled = pDoc->GetDocShell()->IsEnableSetModified()) )
+ {
+ pDoc->GetDocShell()->EnableSetModified( FALSE );
+ }
+
+ // waehrend des einlesens kein OLE-Modified rufen
+ Link aOLELink( pDoc->GetOle2Link() );
+ pDoc->SetOle2Link( Link() );
+
+ BOOL bModified = pDoc->IsModified();
+ BOOL bWasUndo = pDoc->DoesUndo();
+ pDoc->DoUndo( FALSE );
+
+ GetSaveAndSetOwnBaseURL();
+
+ // Wenn der Import abgebrochen wird, kein Continue mehr rufen.
+ // Falls ein Pending-Stack existiert aber durch einen Aufruf
+ // von NextToken dafuer sorgen, dass der Pending-Stack noch
+ // beendet wird.
+ if( SVPAR_ERROR == eState )
+ {
+ ASSERT( !pPendStack || pPendStack->nToken,
+ "SwHTMLParser::Continue: Pending-Stack ohne Token" );
+ if( pPendStack && pPendStack->nToken )
+ NextToken( pPendStack->nToken );
+ ASSERT( !pPendStack,
+ "SwHTMLParser::Continue: Es gibt wieder einen Pend-Stack" );
+ }
+ else
+ {
+ HTMLParser::Continue( pPendStack ? pPendStack->nToken : nToken );
+ }
+
+ SetSaveBaseURL();
+
+ // Laufbalken wieder abschalten
+ EndProgress( pDoc->GetDocShell() );
+
+ BOOL bLFStripped = FALSE;
+ if( SVPAR_PENDING != GetStatus() )
+ {
+ // noch die letzten Attribute setzen
+ {
+ if( aScriptSource.Len() )
+ {
+ SwScriptFieldType *pType =
+ (SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD );
+
+ SwScriptField aFld( pType, aScriptType, aScriptSource,
+ FALSE );
+ InsertAttr( SwFmtFld( aFld ) );
+ }
+
+ if( pAppletImpl )
+ EndApplet();
+
+ // ggf. ein noch vorhandes LF hinter dem letzen Absatz entfernen
+ if( IsNewDoc() )
+ bLFStripped = StripTrailingLF() > 0;
+
+ // noch offene Nummerierungen beenden.
+ while( GetNumInfo().GetNumRule() )
+ EndNumBulList();
+
+ ASSERT( !nContextStMin, "Es gibt geschuetzte Kontexte" );
+ nContextStMin = 0;
+ while( aContexts.Count() )
+ {
+ _HTMLAttrContext *pCntxt = PopContext();
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+ }
+
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ SetAttr( FALSE );
+
+ // Noch die erst verzoegert gesetzten Styles setzen
+ pCSS1Parser->SetDelayedStyles();
+ }
+
+ // den Start wieder korrigieren
+ if( !IsNewDoc() && pSttNdIdx->GetIndex() )
+ {
+ SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
+ SwNodeIndex aNxtIdx( *pSttNdIdx );
+ if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ))
+ {
+ xub_StrLen nStt = pTxtNode->GetTxt().Len();
+ // wenn der Cursor noch in dem Node steht, dann setze in an das Ende
+ if( pPam->GetPoint()->nNode == aNxtIdx )
+ {
+ pPam->GetPoint()->nNode = *pSttNdIdx;
+ pPam->GetPoint()->nContent.Assign( pTxtNode, nStt );
+ }
+
+#ifndef PRODUCT
+// !!! sollte nicht moeglich sein, oder ??
+ASSERT( pSttNdIdx->GetIndex()+1 != pPam->GetBound( TRUE ).nNode.GetIndex(),
+ "Pam.Bound1 steht noch im Node" );
+ASSERT( pSttNdIdx->GetIndex()+1 != pPam->GetBound( FALSE ).nNode.GetIndex(),
+ "Pam.Bound2 steht noch im Node" );
+
+if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( TRUE ).nNode.GetIndex() )
+{
+ register xub_StrLen nCntPos = pPam->GetBound( TRUE ).nContent.GetIndex();
+ pPam->GetBound( TRUE ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+}
+if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() )
+{
+ register xub_StrLen nCntPos = pPam->GetBound( FALSE ).nContent.GetIndex();
+ pPam->GetBound( FALSE ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+}
+#endif
+ // Zeichen Attribute beibehalten!
+ SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
+ if( pTxtNode->GetTxt().Len() )
+ pDelNd->FmtToTxtAttr( pTxtNode );
+ else
+ pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
+ pTxtNode->JoinNext();
+ }
+ }
+ }
+
+ if( SVPAR_ACCEPTED == eState )
+ {
+ if( nMissingImgMaps )
+ {
+ // es fehlen noch ein paar Image-Map zuordungen.
+ // vielleicht sind die Image-Maps ja jetzt da?
+ ConnectImageMaps();
+ }
+
+ // jetzt noch den letzten ueberfluessigen Absatz loeschen
+ SwPosition* pPos = pPam->GetPoint();
+ if( !pPos->nContent.GetIndex() && !bLFStripped )
+ {
+ SwTxtNode* pAktNd;
+ ULONG nNodeIdx = pPos->nNode.GetIndex();
+
+ BOOL bHasFlysOrMarks =
+ HasCurrentParaFlys() || HasCurrentParaBookmarks( TRUE );
+
+ if( IsNewDoc() )
+ {
+ if( pDoc->GetNodes()[ nNodeIdx -1 ]->IsCntntNode() &&
+ !pPam->GetPoint()->nContent.GetIndex() )
+ {
+ nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
+ SwCntntNode* pCNd = pPam->GetCntntNode();
+ if( pCNd && pCNd->StartOfSectionIndex()+2 <
+ pCNd->EndOfSectionIndex() && !bHasFlysOrMarks )
+ {
+ pPam->GetBound(TRUE).nContent.Assign( 0, 0 );
+ pPam->GetBound(FALSE).nContent.Assign( 0, 0 );
+ pDoc->GetNodes().Delete( pPam->GetPoint()->nNode );
+ }
+ }
+ }
+ else if( 0 != ( pAktNd = pDoc->GetNodes()[ nNodeIdx ]->GetTxtNode()) && !bHasFlysOrMarks )
+ {
+ if( pAktNd->CanJoinNext( &pPos->nNode ))
+ {
+ SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
+ pPos->nContent.Assign( pNextNd, 0 );
+ pPam->SetMark(); pPam->DeleteMark();
+ pNextNd->JoinPrev();
+ }
+ else if( !pAktNd->GetTxt().Len() )
+ {
+ pPos->nContent.Assign( 0, 0 );
+ pPam->SetMark(); pPam->DeleteMark();
+ pDoc->GetNodes().Delete( pPos->nNode, 1 );
+ pPam->Move( fnMoveBackward );
+ }
+ }
+ }
+
+ // nun noch das SplitNode vom Anfang aufheben
+ else if( !IsNewDoc() )
+ {
+ if( pPos->nContent.GetIndex() ) // dann gabs am Ende kein <P>,
+ pPam->Move( fnMoveForward, fnGoNode ); // als zum naechsten Node
+ SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
+ SwNodeIndex aPrvIdx( pPos->nNode );
+ if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) &&
+ *pSttNdIdx <= aPrvIdx )
+ {
+ // eigentlich muss hier ein JoinNext erfolgen, aber alle Cursor
+ // usw. sind im pTxtNode angemeldet, so dass der bestehen
+ // bleiben MUSS.
+
+ // Absatz in Zeichen-Attribute umwandeln, aus dem Prev die
+ // Absatzattribute und die Vorlage uebernehmen!
+ SwTxtNode* pPrev = aPrvIdx.GetNode().GetTxtNode();
+ pTxtNode->ChgFmtColl( pPrev->GetTxtColl() );
+ pTxtNode->FmtToTxtAttr( pPrev );
+ pTxtNode->SwCntntNode::ResetAllAttr();
+
+ if( pPrev->GetpSwAttrSet() )
+ pTxtNode->SwCntntNode::SetAttr( *pPrev->GetpSwAttrSet() );
+
+ if( &pPam->GetBound(TRUE).nNode.GetNode() == pPrev )
+ pPam->GetBound(TRUE).nContent.Assign( pTxtNode, 0 );
+ if( &pPam->GetBound(FALSE).nNode.GetNode() == pPrev )
+ pPam->GetBound(FALSE).nContent.Assign( pTxtNode, 0 );
+
+ pTxtNode->JoinPrev();
+ }
+ }
+
+ // und noch die DocumentInfo aufbereiten
+ if( IsNewDoc() )
+ {
+ const SfxDocumentInfo *pInfo = pDoc->GetInfo();
+ if( pInfo->IsReloadEnabled() &&
+ !pInfo->GetReloadURL().Len() )
+ {
+ SfxDocumentInfo aInfo( *pDoc->GetInfo() );
+ aInfo.SetReloadURL( aPathToFile );
+ pDoc->SetInfo( aInfo );
+ }
+ }
+
+ if( bUpdateDocStat )
+ {
+ SwDocStat aStat( pDoc->GetDocStat() );
+ ViewShell *pTmpVSh = 0;
+ pDoc->GetEditShell( &pTmpVSh );
+ USHORT nPages = pTmpVSh ? pTmpVSh->GetNumPages() : 1;
+ pDoc->UpdateDocStat( aStat, nPages );
+ }
+ }
+
+ if( SVPAR_PENDING != GetStatus() )
+ delete pSttNdIdx, pSttNdIdx = 0;
+
+ // sollte der Parser der Letzte sein, der das Doc haelt, dann braucht
+ // man hier auch nichts mehr tun, Doc wird gleich zerstoert!
+ if( 1 < pDoc->GetLinkCnt() )
+ {
+ if( bWasUndo )
+ {
+ pDoc->DelAllUndoObj();
+ pDoc->DoUndo( TRUE );
+ }
+ else if( !pInitVSh )
+ {
+ // Wenn zu Beginn des Continue keine Shell vorhanden war,
+ // kann trotzdem mitlerweile eine angelegt worden sein.
+ // In dieses Fall stimmt das bWasUndo-Flag nicht und
+ // wir muessen das Undo noch anschalten.
+ ViewShell *pTmpVSh = CheckActionViewShell();
+ if( pTmpVSh )
+ pDoc->DoUndo( TRUE );
+ }
+
+ pDoc->SetOle2Link( aOLELink );
+ if( !bModified )
+ pDoc->ResetModified();
+ if( bSetModEnabled && pDoc->GetDocShell() )
+ {
+ pDoc->GetDocShell()->EnableSetModified( TRUE );
+ bSetModEnabled = FALSE; // this is unnecessary here
+ }
+ }
+
+
+ // Wenn die Dokuemnt-ViewShell noch existiert und eine Action
+ // offen ist (muss bei Abbruch nicht sein), die Action beenden,
+ // uns von der Shell abmelden und schliesslich die alte Shell
+ // wieder rekonstruieren.
+ CallEndAction( TRUE );
+
+#ifndef PRODUCT
+ nContinue--;
+#endif
+}
+
+void SwHTMLParser::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
+{
+ switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 )
+ {
+ case RES_OBJECTDYING:
+ if( ((SwPtrMsgPoolItem *)pOld)->pObject == pRegisteredIn )
+ {
+ // dann uns selbst beenden
+ pRegisteredIn->Remove( this );
+ ReleaseRef(); // ansonsten sind wir fertig!
+ }
+ break;
+ }
+}
+
+void SwHTMLParser::DocumentDetected()
+{
+ ASSERT( !bDocInitalized, "DocumentDetected mehrfach aufgerufen" );
+ bDocInitalized = TRUE;
+ if( IsNewDoc() )
+ {
+ if( IsInHeader() )
+ FinishHeader( TRUE );
+
+ CallEndAction( TRUE, TRUE );
+
+ SetSaveBaseURL();
+
+#ifndef PRODUCT
+ ViewShell *pTmpVSh = 0;
+ pDoc->GetEditShell( &pTmpVSh );
+ ASSERT( pTmpVSh==0,
+ "Dok-ViewShell existiert schon vor DocDetected" );
+#endif
+ ErrCode eError = ((SfxLoadEnvironment*)&aLoadEnv)->
+ DocumentDetected( pDoc->GetDocShell(), 0 );
+ if( eError )
+ {
+ eState = SVPAR_ERROR;
+ return;
+ }
+ GetSaveAndSetOwnBaseURL();
+
+ pDoc->DoUndo( FALSE );
+ // Durch das DocumentDetected wurde im allgemeinen eine
+ // ViewShell angelegt. Es kann aber auch sein, dass sie
+ // erst spaeter angelegt wird, naemlich dann, wenn die UI
+ // gecaptured ist.
+ CallStartAction();
+ }
+}
+
+// wird fuer jedes Token gerufen, das in CallParser erkannt wird
+void __EXPORT SwHTMLParser::NextToken( int nToken )
+{
+ if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
+ || 1 == pDoc->GetLinkCnt() )
+ {
+ // wurde der Import vom SFX abgebrochen? Wenn ein Pending-Stack
+ // existiert den noch aufraumen
+ eState = SVPAR_ERROR;
+ ASSERT( !pPendStack || pPendStack->nToken,
+ "SwHTMLParser::NextToken: Pending-Stack ohne Token" );
+ if( 1 == pDoc->GetLinkCnt() || !pPendStack )
+ return ;
+ }
+
+#ifndef PRODUCT
+ if( pPendStack )
+ {
+ switch( nToken )
+ {
+ // Tabellen werden ueber rekusive Methodenaufrufe gelesen
+ case HTML_TABLE_ON:
+ // Bei CSS-Deklarationen muss evtl. noch auf das
+ // Ende eines File-Downloads gewartet werden.
+ case HTML_LINK:
+ // Bei Controls muss evtl. noch die Groesse gesetzt werden.
+ case HTML_INPUT:
+ case HTML_TEXTAREA_ON:
+ case HTML_SELECT_ON:
+ case HTML_SELECT_OFF:
+ break;
+ default:
+ ASSERT( !pPendStack, "Unbekanntes Token fuer Pending-Stack" );
+ break;
+ }
+ }
+#endif
+
+ // Die folgeneden Spezialfaelle muessen vor der Filter-Detection behandelt
+ // werden, denn der Inhalt des Titels, etc. wird auch in Netcape nicht
+ // zur Filter-Detection herangezogen.
+ if( !pPendStack )
+ {
+ if( bInTitle )
+ {
+ switch( nToken )
+ {
+ case HTML_TITLE_OFF:
+ if( IsNewDoc() && sTitle.Len() )
+ {
+ SfxDocumentInfo aInfo( *pDoc->GetInfo() );
+ aInfo.SetTitle( sTitle );
+ pDoc->SetInfo( aInfo );
+
+ if( pDoc->GetDocShell() )
+ pDoc->GetDocShell()->SetTitle( sTitle );
+ }
+ bInTitle = FALSE;
+ sTitle.Erase();
+ break;
+
+ case HTML_NONBREAKSPACE:
+ sTitle += ' ';
+ break;
+
+ case HTML_SOFTHYPH:
+ sTitle += '-';
+ break;
+
+ case HTML_TEXTTOKEN:
+ sTitle += aToken;
+ break;
+
+ default:
+ sTitle += '<';
+ if( (HTML_TOKEN_ONOFF & nToken) && (1 & nToken) )
+ sTitle += '/';
+ sTitle += sSaveToken;
+ if( aToken.Len() )
+ {
+ sTitle += ' ';
+ sTitle += aToken;
+ }
+ sTitle += '>';
+ break;
+ }
+
+ return;
+ }
+ }
+
+ // Wenn wir noch nicht wissen, was fuer ein Dokument wir vor uns haben,
+ // versuchen wir das erstmal rauszufinden. Das muss fuer Controls in
+ // Fall vor dem Einfuegen des Controls passieren, weil beim Einfuegen
+ // bereits eine View benoetigt wird.
+ if( !bDocInitalized && aLoadEnv.Is() )
+ DocumentDetected();
+
+ BOOL bGetIDOption = FALSE, bInsertUnknown = FALSE;
+ BOOL bUpperSpaceSave = bUpperSpace;
+ bUpperSpace = FALSE;
+
+ // Die folgenden Speziallfaelle muessen oder koennen nach der
+ // Filter-Detection erfolgen.
+ if( !pPendStack )
+ {
+ if( bInFloatingFrame )
+ {
+ // <SCRIPT> wird hier (von uns) ignoriert, weil es auch in
+ // Applets ignoriert wird!
+ if( HTML_IFRAME_OFF == nToken )
+ {
+ bCallNextToken = FALSE;
+ EndFloatingFrame();
+ }
+
+ return;
+ }
+ else if( bInNoEmbed )
+ {
+ switch( nToken )
+ {
+ case HTML_NOEMBED_OFF:
+ aContents.ConvertLineEnd();
+ InsertComment( aContents, sHTML_noembed );
+ aContents.Erase();
+ bCallNextToken = FALSE;
+ bInNoEmbed = FALSE;
+ break;
+
+ case HTML_RAWDATA:
+ InsertCommentText( sHTML_noembed );
+ break;
+
+ default:
+ ASSERT( !this, "SwHTMLParser::NextToken: ungueltiges Tag" );
+ break;
+ }
+
+ return;
+ }
+ else if( pAppletImpl )
+ {
+ // in einem Applet interessieren uns (erstmal) nur <PARAM>-Tags
+ // und das </APPLET>.
+ // <SCRIPT> wird hier (von Netscape) ignoriert!
+
+ switch( nToken )
+ {
+ case HTML_APPLET_OFF:
+ bCallNextToken = FALSE;
+ EndApplet();
+ break;
+
+ case HTML_PARAM:
+ InsertParam();
+ break;
+ }
+
+ return;
+ }
+ else if( bTextArea )
+ {
+ // in einer TextArea wird alles bis zum </TEXTAREA> als Text
+ // eingefuegt
+ // <SCRIPT> wird hier (von Netscape) ignoriert!
+
+ switch( nToken )
+ {
+ case HTML_TEXTAREA_OFF:
+ bCallNextToken = FALSE;
+ EndTextArea();
+ break;
+
+ default:
+ InsertTextAreaText( nToken );
+ break;
+ }
+
+ return;
+ }
+ else if( bSelect )
+ {
+ // MUSS nach bNoScript kommen!
+ switch( nToken )
+ {
+ case HTML_SELECT_OFF:
+ bCallNextToken = FALSE;
+ EndSelect();
+ return;
+
+ case HTML_OPTION:
+ InsertSelectOption();
+ return;
+
+ case HTML_TEXTTOKEN:
+ InsertSelectText();
+ return;
+
+ case HTML_INPUT:
+ case HTML_SCRIPT_ON:
+ case HTML_SCRIPT_OFF:
+ case HTML_NOSCRIPT_ON:
+ case HTML_NOSCRIPT_OFF:
+ case HTML_RAWDATA:
+ // im normalen switch bahandeln
+ break;
+
+ default:
+ // ignorieren
+ return;
+ }
+ }
+ else if( pMarquee )
+ {
+ // in einer TextArea wird alles bis zum </TEXTAREA> als Text
+ // eingefuegt
+ // Die <SCRIPT>-Tags werden vom MS-IE ignoriert, von uns das
+ // geasmte Script
+ switch( nToken )
+ {
+ case HTML_MARQUEE_OFF:
+ bCallNextToken = FALSE;
+ EndMarquee();
+ break;
+
+ case HTML_TEXTTOKEN:
+ InsertMarqueeText();
+ break;
+ }
+
+ return;
+ }
+ else if( bInField )
+ {
+ switch( nToken )
+ {
+ case HTML_SDFIELD_OFF:
+ bCallNextToken = FALSE;
+ EndField();
+ break;
+
+ case HTML_TEXTTOKEN:
+ InsertFieldText();
+ break;
+ }
+
+ return;
+ }
+ else if( bInFootEndNoteAnchor || bInFootEndNoteSymbol )
+ {
+ switch( nToken )
+ {
+ case HTML_ANCHOR_OFF:
+ EndAnchor();
+ bCallNextToken = FALSE;
+ break;
+
+ case HTML_TEXTTOKEN:
+ InsertFootEndNoteText();
+ break;
+ }
+ return;
+ }
+ else if( aUnknownToken.Len() )
+ {
+ // Unbekannte Token im Header werden nur durch ein passendes
+ // End-Token, </HEAD> oder <BODY> wieder beendet. Darin wird Text
+ // ignoriert.
+ switch( nToken )
+ {
+ case HTML_UNKNOWNCONTROL_OFF:
+ if( aUnknownToken.CompareTo(sSaveToken) != COMPARE_EQUAL )
+ return;
+ case HTML_FRAMESET_ON:
+ case HTML_HEAD_OFF:
+ case HTML_BODY_ON:
+ case HTML_IMAGE: // Warum auch immer Netscape das tut.
+ aUnknownToken.Erase();
+ break;
+ case HTML_TEXTTOKEN:
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+ switch( nToken )
+ {
+ case HTML_BODY_ON:
+ if( aStyleSource.Len() )
+ {
+ pCSS1Parser->ParseStyleSheet( aStyleSource );
+ aStyleSource.Erase();
+ }
+ if( IsNewDoc() )
+ {
+ InsertBodyOptions();
+ // Falls es eine Vorlage fuer die erste oder rechte Seite gibt,
+ // setzen wir die hier.
+ const SwPageDesc *pPageDesc = 0;
+ if( pCSS1Parser->IsSetFirstPageDesc() )
+ pPageDesc = pCSS1Parser->GetFirstPageDesc();
+ else if( pCSS1Parser->IsSetRightPageDesc() )
+ pPageDesc = pCSS1Parser->GetRightPageDesc();
+
+ if( pPageDesc )
+ pDoc->Insert( *pPam, SwFmtPageDesc( pPageDesc ) );
+ }
+ break;
+
+ case HTML_LINK:
+ InsertLink();
+ break;
+
+ case HTML_BASE:
+ {
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[ --i ];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_HREF:
+ sBaseURL = pOption->GetString();
+ INetURLObject::SetBaseURL( sBaseURL );
+ break;
+ case HTML_O_TARGET:
+ if( IsNewDoc() )
+ {
+ SfxDocumentInfo aInfo( *pDoc->GetInfo() );
+ aInfo.SetDefaultTarget( pOption->GetString() );
+ pDoc->SetInfo( aInfo );
+ }
+ break;
+ }
+ }
+ }
+ break;
+
+ case HTML_META:
+ if( IsNewDoc() )
+ {
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ SvKeyValueIterator *pHTTPHeader =
+ pDocSh ? pDocSh->GetHeaderAttributes() : 0;
+ SfxDocumentInfo aInfo( *pDoc->GetInfo() );
+
+ if( ParseMetaOptions( &aInfo, pHTTPHeader ) )
+ {
+ pDoc->SetInfo( aInfo );
+ }
+ else
+ {
+ ParseMoreMetaOptions();
+ }
+ }
+ break;
+
+ case HTML_TITLE_ON:
+ bInTitle = TRUE;
+ break;
+
+ case HTML_SCRIPT_ON:
+ NewScript();
+ break;
+
+ case HTML_SCRIPT_OFF:
+ EndScript();
+ break;
+
+ case HTML_NOSCRIPT_ON:
+ case HTML_NOSCRIPT_OFF:
+ bInsertUnknown = TRUE;
+ break;
+
+ case HTML_STYLE_ON:
+ NewStyle();
+ break;
+
+ case HTML_STYLE_OFF:
+ EndStyle();
+ break;
+
+ case HTML_RAWDATA:
+ if( !bIgnoreRawData )
+ {
+ if( IsReadScript() )
+ {
+ AddScriptSource();
+ }
+ else if( IsReadStyle() )
+ {
+ if( aStyleSource.Len() )
+ aStyleSource += '\n';
+ aStyleSource += aToken;
+ }
+ }
+ break;
+
+ case HTML_APPLET_ON:
+#ifdef SOLAR_JAVA
+ InsertApplet();
+ bCallNextToken = pAppletImpl!=0 && pTable!=0;
+#endif
+ break;
+
+ case HTML_IFRAME_ON:
+ InsertFloatingFrame();
+ bCallNextToken = bInFloatingFrame && pTable!=0;
+ break;
+
+ case HTML_LINEBREAK:
+ if( !IsReadPRE() )
+ {
+ InsertLineBreak();
+ break;
+ }
+ else
+ bGetIDOption = TRUE;
+ // <BR>s in <PRE> aehneln echten LFs, deshalb kein break
+
+ case HTML_NEWPARA:
+ // CR in PRE/LISTING/XMP
+ {
+ if( HTML_NEWPARA==nToken ||
+ pPam->GetPoint()->nContent.GetIndex() )
+ {
+ AppendTxtNode(); // lf gibts hier nicht, deshalb unkritisch
+ SetTxtCollAttrs();
+ }
+ // Laufbalkenanzeige
+ if( !GetMedium() || !GetMedium()->IsRemote() )
+ ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
+ }
+ break;
+
+ case HTML_NONBREAKSPACE:
+ pDoc->Insert( *pPam, CHAR_HARDBLANK );
+ break;
+
+ case HTML_SOFTHYPH:
+ pDoc->Insert( *pPam, CHAR_SOFTHYPHEN );
+ break;
+
+ case HTML_LINEFEEDCHAR:
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode();
+ if( !pTable && !pDoc->IsInHeaderFooter( pPam->GetPoint()->nNode ) )
+ {
+ NewAttr( &aAttrTab.pBreak, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE) );
+ EndAttr( aAttrTab.pBreak, 0, FALSE );
+ }
+ break;
+
+ case HTML_TEXTTOKEN:
+ // dann fuege den String ein, ohne das Attribute am Ende
+ // aufgespannt werden.
+ if( aToken.Len() && ' '==aToken.GetChar(0) && !IsReadPRE() )
+ {
+ xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
+ if( nPos )
+ {
+ const String& rText =
+ pDoc->GetNodes()[ pPam->GetPoint()->nNode ]->GetTxtNode()
+ ->GetTxt();
+ register sal_Unicode cLast = rText.GetChar(--nPos);
+ if( ' ' == cLast || '\x0a' == cLast)
+ aToken.Erase(0,1);
+ }
+ else
+ aToken.Erase(0,1);
+
+ if( !aToken.Len() )
+ {
+ bUpperSpace = bUpperSpaceSave;
+ break;
+ }
+ }
+
+ if( aToken.Len() )
+ {
+ if( !bDocInitalized && aLoadEnv.Is() )
+ DocumentDetected();
+ pDoc->Insert( *pPam, aToken );
+
+ // wenn es noch vorlaefige Absatz-Attribute gibt, der Absatz aber
+ // nicht leer ist, dann sind die Absatz-Attribute entgueltig.
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ SetAttr();
+ }
+ break;
+
+ case HTML_HORZRULE:
+ InsertHorzRule();
+ break;
+
+ case HTML_IMAGE:
+ InsertImage();
+ // sollte der Parser der Letzte sein, der das Doc haelt, dann kann
+ // man hier abbrechen und einen Fehler setzen.
+ if( 1 == pDoc->GetLinkCnt() )
+ {
+ eState = SVPAR_ERROR;
+ }
+ break;
+
+ case HTML_SPACER:
+ InsertSpacer();
+ break;
+
+ case HTML_EMBED:
+ InsertEmbed();
+ break;
+
+ case HTML_NOEMBED_ON:
+ bInNoEmbed = TRUE;
+ bCallNextToken = pTable!=0;
+ ReadRawData( sHTML_noembed );
+ break;
+
+ case HTML_DEFLIST_ON:
+ if( nOpenParaToken )
+ EndPara();
+ NewDefList();
+ break;
+ case HTML_DEFLIST_OFF:
+ if( nOpenParaToken )
+ EndPara();
+ EndDefListItem( 0, FALSE, 1==nDefListDeep );
+ EndDefList();
+ break;
+
+ case HTML_DD_ON:
+ case HTML_DT_ON:
+ if( nOpenParaToken )
+ EndPara();
+ EndDefListItem( 0, FALSE );// <DD>/<DT> beenden und keine Vorl. setzen
+ NewDefListItem( nToken );
+ break;
+
+ case HTML_DD_OFF:
+ case HTML_DT_OFF:
+ // siehe HTML_LI_OFF
+ // eigentlich muesste man ein DD/DT jetzt beenden. Da aber sowhl
+ // Netscape als auch Microsoft das nicht tun, machen wir das eben
+ // auch nicht.
+ EndDefListItem( nToken, FALSE );
+ break;
+
+ // Bereiche
+ case HTML_DIVISION_ON:
+ case HTML_CENTER_ON:
+ if( nOpenParaToken )
+ {
+ if( IsReadPRE() )
+ nOpenParaToken = 0;
+ else
+ EndPara();
+ }
+ NewDivision( nToken );
+ break;
+
+ case HTML_DIVISION_OFF:
+ case HTML_CENTER_OFF:
+ if( nOpenParaToken )
+ {
+ if( IsReadPRE() )
+ nOpenParaToken = 0;
+ else
+ EndPara();
+ }
+ EndDivision( nToken );
+ break;
+
+ case HTML_MULTICOL_ON:
+ if( nOpenParaToken )
+ EndPara();
+ NewMultiCol();
+ break;
+
+ case HTML_MULTICOL_OFF:
+ if( nOpenParaToken )
+ EndPara();
+ EndTag( HTML_MULTICOL_ON );
+ break;
+
+ case HTML_MARQUEE_ON:
+ NewMarquee();
+ bCallNextToken = pMarquee!=0 && pTable!=0;
+ break;
+
+ case HTML_FORM_ON:
+ NewForm();
+ break;
+ case HTML_FORM_OFF:
+ EndForm();
+ break;
+
+ // Vorlagen:
+ case HTML_PARABREAK_ON:
+ if( nOpenParaToken )
+ EndPara( TRUE );
+ NewPara();
+ break;
+
+ case HTML_PARABREAK_OFF:
+ EndPara( TRUE );
+ break;
+
+ case HTML_ADDRESS_ON:
+ if( nOpenParaToken )
+ EndPara();
+ NewTxtFmtColl( HTML_ADDRESS_ON, RES_POOLCOLL_SENDADRESS );
+ break;
+
+ case HTML_ADDRESS_OFF:
+ if( nOpenParaToken )
+ EndPara();
+ EndTxtFmtColl( HTML_ADDRESS_OFF );
+ break;
+
+ case HTML_BLOCKQUOTE_ON:
+ case HTML_BLOCKQUOTE30_ON:
+ if( nOpenParaToken )
+ EndPara();
+ NewTxtFmtColl( HTML_BLOCKQUOTE_ON, RES_POOLCOLL_HTML_BLOCKQUOTE );
+ break;
+
+ case HTML_BLOCKQUOTE_OFF:
+ case HTML_BLOCKQUOTE30_OFF:
+ if( nOpenParaToken )
+ EndPara();
+ EndTxtFmtColl( HTML_BLOCKQUOTE_ON );
+ break;
+
+ case HTML_PREFORMTXT_ON:
+ case HTML_LISTING_ON:
+ case HTML_XMP_ON:
+ if( nOpenParaToken )
+ EndPara();
+ NewTxtFmtColl( nToken, RES_POOLCOLL_HTML_PRE );
+ break;
+
+ case HTML_PREFORMTXT_OFF:
+ bNoParSpace = TRUE; // der letzte PRE-Absatz muss einen Zeilenabstand bekommen
+ EndTxtFmtColl( HTML_PREFORMTXT_OFF );
+ break;
+
+ case HTML_LISTING_OFF:
+ case HTML_XMP_OFF:
+ EndTxtFmtColl( nToken );
+ break;
+
+ case HTML_HEAD1_ON:
+ case HTML_HEAD2_ON:
+ case HTML_HEAD3_ON:
+ case HTML_HEAD4_ON:
+ case HTML_HEAD5_ON:
+ case HTML_HEAD6_ON:
+ if( nOpenParaToken )
+ {
+ if( IsReadPRE() )
+ nOpenParaToken = 0;
+ else
+ EndPara();
+ }
+ NewHeading( nToken );
+ break;
+
+ case HTML_HEAD1_OFF:
+ case HTML_HEAD2_OFF:
+ case HTML_HEAD3_OFF:
+ case HTML_HEAD4_OFF:
+ case HTML_HEAD5_OFF:
+ case HTML_HEAD6_OFF:
+ EndHeading();
+ break;
+
+ case HTML_TABLE_ON:
+ if( pPendStack )
+ BuildTable( SVX_ADJUST_END );
+ else
+ {
+ if( nOpenParaToken )
+ EndPara();
+ ASSERT( !pTable, "Tabelle in Tabelle darf hier nicht vorkommen" );
+ if( !pTable && (IsNewDoc() || !pPam->GetNode()->FindTableNode()) &&
+ (pPam->GetPoint()->nNode.GetIndex() >
+ pDoc->GetNodes().GetEndOfExtras().GetIndex() ||
+ !pPam->GetNode()->FindFootnoteStartNode() ) )
+ {
+ if ( nParaCnt < 5 )
+ Show(); // bis hierhin schon mal anzeigen
+
+ SvxAdjust eAdjust = aAttrTab.pAdjust
+ ? ((const SvxAdjustItem&)aAttrTab.pAdjust->GetItem()).
+ GetAdjust()
+ : SVX_ADJUST_END;
+ BuildTable( eAdjust );
+ }
+ else
+ bInsertUnknown = bKeepUnknown;
+ }
+ break;
+
+ // Listen
+ case HTML_DIRLIST_ON:
+ case HTML_MENULIST_ON:
+ case HTML_ORDERLIST_ON:
+ case HTML_UNORDERLIST_ON:
+ if( nOpenParaToken )
+ EndPara();
+ NewNumBulList( nToken );
+ break;
+
+ case HTML_DIRLIST_OFF:
+ case HTML_MENULIST_OFF:
+ case HTML_ORDERLIST_OFF:
+ case HTML_UNORDERLIST_OFF:
+ if( nOpenParaToken )
+ EndPara();
+ EndNumBulListItem( 0, TRUE, GetNumInfo().GetDepth()==1 );
+ EndNumBulList( nToken );
+ break;
+
+ case HTML_LI_ON:
+ case HTML_LISTHEADER_ON:
+ if( nOpenParaToken &&
+ (pPam->GetPoint()->nContent.GetIndex()
+ || HTML_PARABREAK_ON==nOpenParaToken) )
+ {
+ // nure bei <P><LI> den Absatz beenden, aber nicht bei <DD><LI>
+ EndPara();
+ }
+
+ EndNumBulListItem( 0, FALSE );// <LI>/<LH> beenden und keine Vorl. setzen
+ NewNumBulListItem( nToken );
+ break;
+
+ case HTML_LI_OFF:
+ case HTML_LISTHEADER_OFF:
+ EndNumBulListItem( nToken, FALSE );
+ break;
+
+ // Attribute :
+ case HTML_ITALIC_ON:
+ {
+ NewStdAttr( HTML_ITALIC_ON, &aAttrTab.pItalic,
+ SvxPostureItem(ITALIC_NORMAL) );
+ }
+ break;
+
+ case HTML_BOLD_ON:
+ {
+ NewStdAttr( HTML_BOLD_ON, &aAttrTab.pBold,
+ SvxWeightItem(WEIGHT_BOLD) );
+ }
+ break;
+
+
+ case HTML_STRIKE_ON:
+ case HTML_STRIKETHROUGH_ON:
+ {
+ NewStdAttr( HTML_STRIKE_ON, &aAttrTab.pStrike,
+ SvxCrossedOutItem(STRIKEOUT_SINGLE) );
+ }
+ break;
+
+ case HTML_UNDERLINE_ON:
+ {
+ NewStdAttr( HTML_UNDERLINE_ON, &aAttrTab.pUnderline,
+ SvxUnderlineItem(UNDERLINE_SINGLE) );
+ }
+ break;
+
+ case HTML_SUPERSCRIPT_ON:
+ {
+ NewStdAttr( HTML_SUPERSCRIPT_ON, &aAttrTab.pEscapement,
+ SvxEscapementItem(HTML_ESC_SUPER,HTML_ESC_PROP) );
+ }
+ break;
+
+ case HTML_SUBSCRIPT_ON:
+ {
+ NewStdAttr( HTML_SUBSCRIPT_ON, &aAttrTab.pEscapement,
+ SvxEscapementItem(HTML_ESC_SUB,HTML_ESC_PROP) );
+ }
+ break;
+
+ case HTML_BLINK_ON:
+ {
+ NewStdAttr( HTML_BLINK_ON, &aAttrTab.pBlink,
+ SvxBlinkItem( TRUE ) );
+ }
+ break;
+
+ case HTML_SPAN_ON:
+ NewStdAttr( HTML_SPAN_ON );
+ break;
+
+
+ case HTML_ITALIC_OFF:
+ case HTML_BOLD_OFF:
+ case HTML_STRIKE_OFF:
+ case HTML_UNDERLINE_OFF:
+ case HTML_SUPERSCRIPT_OFF:
+ case HTML_SUBSCRIPT_OFF:
+ case HTML_BLINK_OFF:
+ case HTML_SPAN_OFF:
+ EndTag( nToken );
+ break;
+
+ case HTML_STRIKETHROUGH_OFF:
+ EndTag( HTML_STRIKE_OFF );
+ break;
+
+ case HTML_BASEFONT_ON:
+ NewBasefontAttr();
+ break;
+ case HTML_BASEFONT_OFF:
+ EndBasefontAttr();
+ break;
+ case HTML_FONT_ON:
+ case HTML_BIGPRINT_ON:
+ case HTML_SMALLPRINT_ON:
+ NewFontAttr( nToken );
+ break;
+ case HTML_FONT_OFF:
+ case HTML_BIGPRINT_OFF:
+ case HTML_SMALLPRINT_OFF:
+ EndFontAttr( nToken );
+ break;
+
+ case HTML_EMPHASIS_ON:
+ case HTML_CITIATION_ON:
+ case HTML_STRONG_ON:
+ case HTML_CODE_ON:
+ case HTML_SAMPLE_ON:
+ case HTML_KEYBOARD_ON:
+ case HTML_VARIABLE_ON:
+ case HTML_DEFINSTANCE_ON:
+ case HTML_SHORTQUOTE_ON:
+ case HTML_LANGUAGE_ON:
+ case HTML_AUTHOR_ON:
+ case HTML_PERSON_ON:
+ case HTML_ACRONYM_ON:
+ case HTML_ABBREVIATION_ON:
+ case HTML_INSERTEDTEXT_ON:
+ case HTML_DELETEDTEXT_ON:
+
+ case HTML_TELETYPE_ON:
+ NewCharFmt( nToken );
+ break;
+
+ case HTML_SDFIELD_ON:
+ NewField();
+ bCallNextToken = bInField && pTable!=0;
+ break;
+
+ case HTML_EMPHASIS_OFF:
+ case HTML_CITIATION_OFF:
+ case HTML_STRONG_OFF:
+ case HTML_CODE_OFF:
+ case HTML_SAMPLE_OFF:
+ case HTML_KEYBOARD_OFF:
+ case HTML_VARIABLE_OFF:
+ case HTML_DEFINSTANCE_OFF:
+ case HTML_SHORTQUOTE_OFF:
+ case HTML_LANGUAGE_OFF:
+ case HTML_AUTHOR_OFF:
+ case HTML_PERSON_OFF:
+ case HTML_ACRONYM_OFF:
+ case HTML_ABBREVIATION_OFF:
+ case HTML_INSERTEDTEXT_OFF:
+ case HTML_DELETEDTEXT_OFF:
+
+ case HTML_TELETYPE_OFF:
+ EndTag( nToken );
+ break;
+
+ case HTML_HEAD_OFF:
+ if( aStyleSource.Len() )
+ {
+ pCSS1Parser->ParseStyleSheet( aStyleSource );
+ aStyleSource.Erase();
+ }
+ break;
+
+ case HTML_DOCTYPE:
+ case HTML_BODY_OFF:
+ case HTML_HTML_ON:
+ case HTML_HTML_OFF:
+ case HTML_HEAD_ON:
+ case HTML_TITLE_OFF:
+ break; // nicht weiter auswerten, oder???
+
+ case HTML_INPUT:
+ InsertInput();
+ break;
+
+ case HTML_TEXTAREA_ON:
+ NewTextArea();
+ bCallNextToken = bTextArea && pTable!=0;
+ break;
+
+ case HTML_SELECT_ON:
+ NewSelect();
+ bCallNextToken = bSelect && pTable!=0;
+ break;
+
+ case HTML_ANCHOR_ON:
+ NewAnchor();
+ break;
+
+ case HTML_ANCHOR_OFF:
+ EndAnchor();
+ break;
+
+ case HTML_COMMENT:
+ if( aToken.Len() > 5 )
+ {
+ // als Post-It einfuegen
+ String aComment( aToken.Copy( 3, aToken.Len()-5 ) );
+ aComment.EraseLeadingChars().EraseTrailingChars();
+ InsertComment( aComment );
+ }
+ break;
+
+ case HTML_MAP_ON:
+ // Image Maps werden asynchron gelesen: Zunaechst wird nur eine
+ // ImageMap angelegt. Die Bereiche kommen spaeter. Trozdem wird
+ // die ImageMap schon in das IMap-Array eingetragen, denn sie
+ // koennte ja schon verwendet werden.
+ pImageMap = new ImageMap;
+ if( ParseMapOptions( pImageMap) )
+ {
+ if( !pImageMaps )
+ pImageMaps = new ImageMaps;
+ pImageMaps->Insert( pImageMap, pImageMaps->Count() );
+ }
+ else
+ {
+ delete pImageMap;
+ pImageMap = 0;
+ }
+ break;
+
+ case HTML_MAP_OFF:
+ // jetzt gibt es keine ImageMap mehr (IMap nicht Loeschen, denn
+ // die stckt ja schon in dem Array!)
+ pImageMap = 0;
+ break;
+
+ case HTML_AREA:
+ if( pImageMap )
+ ParseAreaOptions( pImageMap, SFX_EVENT_MOUSEOVER_OBJECT,
+ SFX_EVENT_MOUSEOUT_OBJECT );
+ break;
+
+ case HTML_FRAMESET_ON:
+ bInsertUnknown = bKeepUnknown;
+ break;
+
+ case HTML_NOFRAMES_ON:
+ if( IsInHeader() )
+ FinishHeader( TRUE );
+ bInsertUnknown = bKeepUnknown;
+ break;
+
+ case HTML_UNKNOWNCONTROL_ON:
+ // Im Header muss der Inhalt von unbekannten Token ignoriert werden,
+ // es sei denn, das Token faengt mit einem '!' an.
+ if( IsInHeader() && !IsReadPRE() && !aUnknownToken.Len() &&
+ sSaveToken.Len() && '!' != sSaveToken.GetChar(0) &&
+ '%' != sSaveToken.GetChar(0) )
+ aUnknownToken = sSaveToken;
+ // kein break
+
+ default:
+ bInsertUnknown = bKeepUnknown;
+ break;
+ }
+
+ if( bGetIDOption )
+ InsertIDOption();
+
+ if( bInsertUnknown )
+ {
+ String aComment(
+ String::CreateFromAscii(TOOLS_CONSTASCII_STRINGPARAM("HTML: <")) );
+ if( (HTML_TOKEN_ONOFF & nToken) != 0 && (1 & nToken) != 0 )
+ aComment += '/';
+ aComment += sSaveToken;
+ if( aToken.Len() )
+ {
+ UnescapeToken();
+ (aComment += ' ') += aToken;
+ }
+ aComment += '>';
+ InsertComment( aComment );
+ }
+
+ // wenn es noch vorlaefige Absatz-Attribute gibt, der Absatz aber
+ // nicht leer ist, dann sind die Absatz-Attribute entgueltig.
+ if( aParaAttrs.Count() && pPam->GetPoint()->nContent.GetIndex() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+}
+
+/* */
+
+BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum )
+{
+ // Ein harter Zeilen-Umbruch am Ende muss immer entfernt werden.
+ // Einen zweiten ersetzen wir durch einen Absatz-Abstand.
+ xub_StrLen nLFStripped = StripTrailingLF();
+ if( (AM_NOSPACE==eMode || AM_SOFTNOSPACE==eMode) && nLFStripped > 1 )
+ eMode = AM_SPACE;
+
+ // die harten Attribute an diesem Absatz werden nie mehr ungueltig
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ if( AM_SPACE==eMode || AM_NOSPACE==eMode )
+ {
+ SwTxtNode *pTxtNode =
+ pDoc->GetNodes()[pPam->GetPoint()->nNode]->GetTxtNode();
+
+ const SvxULSpaceItem& rULSpace =
+ (const SvxULSpaceItem&)pTxtNode->SwCntntNode::GetAttr( RES_UL_SPACE );
+
+ BOOL bChange = AM_NOSPACE==eMode ? rULSpace.GetLower() > 0
+ : rULSpace.GetLower() == 0;
+
+ if( bChange )
+ {
+ const SvxULSpaceItem& rCollULSpace =
+ pTxtNode->GetAnyFmtColl().GetULSpace();
+
+ BOOL bMayReset = AM_NOSPACE==eMode ? rCollULSpace.GetLower() == 0
+ : rCollULSpace.GetLower() > 0;
+
+ if( bMayReset &&
+ rCollULSpace.GetUpper() == rULSpace.GetUpper() )
+ {
+ pTxtNode->ResetAttr( RES_UL_SPACE );
+ }
+ else
+ {
+ pTxtNode->SwCntntNode::SetAttr(
+ SvxULSpaceItem( rULSpace.GetUpper(),
+ AM_NOSPACE==eMode ? 0 : HTML_PARSPACE ) );
+ }
+ }
+ }
+ bNoParSpace = AM_NOSPACE==eMode || AM_SOFTNOSPACE==eMode;
+
+ SwPosition aOldPos( *pPam->GetPoint() );
+
+ BOOL bRet = pDoc->AppendTxtNode( *pPam->GetPoint() );
+
+ // Zeichen-Attribute aufspalten und ggf keine setzen, die ueber den
+ // ganzen Absatz gesetzt sind
+ const SwNodeIndex& rEndIdx = aOldPos.nNode;
+ xub_StrLen nEndCnt = aOldPos.nContent.GetIndex();
+ const SwPosition& rPos = *pPam->GetPoint();
+
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ for( USHORT nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; ++pTbl )
+ {
+ _HTMLAttr *pAttr = *pTbl;
+ if( pAttr && pAttr->GetItem().Which() < RES_PARATR_BEGIN )
+ {
+ BOOL bWholePara = FALSE;
+
+ while( pAttr )
+ {
+ _HTMLAttr *pNext = pAttr->GetNext();
+ if( pAttr->GetSttParaIdx() < rEndIdx.GetIndex() ||
+ (!bWholePara &&
+ pAttr->GetSttPara() == rEndIdx &&
+ pAttr->GetSttCnt() != nEndCnt) )
+ {
+ // den besehrigen Teil setzen
+ _HTMLAttr *pSetAttr =
+ pAttr->Clone( rEndIdx, nEndCnt );
+ pAttr->ClearPrev();
+
+ bWholePara =
+ pAttr->GetSttPara() == rEndIdx &&
+ pAttr->GetSttCnt() == 0;
+
+ // Wenn das Attribut den gesamten Absatz umspannt, werden
+ // alle auesseren Attribute nicht mehr beachtet. Deshalb
+ // darf es auch nicht in die Prev-Liste eines ausseren
+ // Attributs eingetragen werden, denn dieses wird ja
+ // erstmal nicht gesetzt. Das fuehrt zu verschiebenungen,
+ // wenn Felder ins Rennen kommen (siehe #51020#)
+ if( !pNext || bWholePara )
+ {
+ USHORT nTmp = pAttr->bInsAtStart ? 0
+ : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pSetAttr, nTmp );
+ }
+ else
+ pNext->InsertPrev( pSetAttr );
+ }
+
+ pAttr->SetStart( rPos );
+ pAttr = pNext;
+ }
+ }
+ }
+
+ if( bUpdateNum )
+ {
+ if( GetNumInfo().GetDepth() )
+ SetNodeNum( GetNumInfo().GetLevel() | NO_NUMLEVEL );
+ else
+ pPam->GetNode()->GetTxtNode()->ResetAttr( RES_PARATR_NUMRULE );
+ }
+
+ // Attrubute im Absatz davor sollte man jetzt setzen (wegen JavaScript)
+ SetAttr();
+
+ if( !pTable && !--nParaCnt )
+ Show();
+
+ return bRet;
+}
+
+void SwHTMLParser::AddParSpace()
+{
+ if( !bNoParSpace )
+ return;
+
+ bNoParSpace = FALSE;
+
+ ULONG nNdIdx = pPam->GetPoint()->nNode.GetIndex() - 1;
+
+ SwTxtNode *pTxtNode = pDoc->GetNodes()[nNdIdx]->GetTxtNode();
+ if( !pTxtNode )
+ return;
+
+ SvxULSpaceItem rULSpace =
+ (const SvxULSpaceItem&)pTxtNode->SwCntntNode::GetAttr( RES_UL_SPACE );
+ if( !rULSpace.GetLower() )
+ {
+ const SvxULSpaceItem& rCollULSpace =
+ pTxtNode->GetAnyFmtColl().GetULSpace();
+ if( rCollULSpace.GetLower() &&
+ rCollULSpace.GetUpper() == rULSpace.GetUpper() )
+ {
+ pTxtNode->ResetAttr( RES_UL_SPACE );
+ }
+ else
+ {
+ pTxtNode->SwCntntNode::SetAttr(
+ SvxULSpaceItem( rULSpace.GetUpper(), HTML_PARSPACE ) );
+ }
+ }
+}
+
+
+void SwHTMLParser::Show()
+{
+ // Hier wird
+ // - ein EndAction gerufen, damit formatiert wird
+ // - ein Reschedule gerufen,
+ // - die eiegen View-Shell wieder gesetzt
+ // - und Start-Action gerufen
+
+ ASSERT( SVPAR_WORKING==eState, "Show nicht im Working-State - Das kann ins Auge gehen" );
+ ViewShell *pOldVSh = CallEndAction();
+
+ SetSaveBaseURL();
+ GetpApp()->Reschedule();
+ GetSaveAndSetOwnBaseURL();
+
+ if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
+ || 1 == pDoc->GetLinkCnt() )
+ {
+ // wurde der Import vom SFX abgebrochen?
+ eState = SVPAR_ERROR;
+ }
+
+ // Die ViewShell nochmal holen, denn sie koennte im Reschedule
+ // zerstoert wirden sein.
+ ViewShell *pVSh = CallStartAction( pOldVSh );
+ ASSERT( pOldVSh == pVSh, "Show:: Shell wurde ausgetauscht" );
+
+ // ist der aktuelle Node nicht mehr sichtbar, dann benutzen wir
+ // eine groessere Schrittweite
+ if( pVSh )
+ nParaCnt = pDoc->GetNodes()[pPam->GetPoint()->nNode]
+ ->IsVisible(pVSh) ? 5 : 50;
+}
+
+void SwHTMLParser::ShowStatline()
+{
+ // Hier wird
+ // - ein Reschedule gerufen, damit gescrollt werden kann
+ // - die eiegen View-Shell wieder gesetzt
+ // - ein Start/End-Action gerufen, wenn gescrollt wurde.
+
+ ASSERT( SVPAR_WORKING==eState, "ShowStatLine nicht im Working-State - Das kann ins Auge gehen" );
+
+ // Laufbalkenanzeige
+ SetSaveBaseURL();
+ if( !GetMedium() || !GetMedium()->IsRemote() )
+ {
+ ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
+ GetSaveAndSetOwnBaseURL();
+ CheckActionViewShell();
+ }
+ else
+ {
+ GetpApp()->Reschedule();
+ GetSaveAndSetOwnBaseURL();
+
+ if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
+ || 1 == pDoc->GetLinkCnt() )
+ // wurde der Import vom SFX abgebrochen?
+ eState = SVPAR_ERROR;
+
+ ViewShell *pVSh = CheckActionViewShell();
+ if( pVSh && pVSh->HasInvalidRect() )
+ {
+ CallEndAction( FALSE, FALSE );
+ CallStartAction( pVSh, FALSE );
+ }
+ }
+}
+
+ViewShell *SwHTMLParser::CallStartAction( ViewShell *pVSh, BOOL bChkPtr )
+{
+ ASSERT( !pActionViewShell, "CallStartAction: ViewShell schon gesetzt" );
+
+ if( !pVSh || bChkPtr )
+ {
+ ViewShell *pOldVSh = pVSh;
+ pDoc->GetEditShell( &pVSh );
+ ASSERT( !pVSh || !pOldVSh || pOldVSh == pVSh,
+ "CallStartAction: Wer hat die ViewShell ausgetauscht?" );
+#ifdef DEBUG
+ if( pOldVSh && !pVSh )
+ pVSh = 0;
+#endif
+ }
+ pActionViewShell = pVSh;
+
+ if( pActionViewShell )
+ {
+ if( pActionViewShell->ISA( SwEditShell ) )
+ ((SwEditShell*)pActionViewShell)->StartAction();
+ else
+ pActionViewShell->StartAction();
+ }
+
+ return pActionViewShell;
+}
+
+ViewShell *SwHTMLParser::CallEndAction( BOOL bChkAction, BOOL bChkPtr )
+{
+ if( bChkPtr )
+ {
+ ViewShell *pVSh = 0;
+ pDoc->GetEditShell( &pVSh );
+ ASSERT( !pVSh || pActionViewShell == pVSh,
+ "CallEndAction: Wer hat die ViewShell ausgetauscht?" );
+#ifdef DEBUG
+ if( pActionViewShell && !pVSh )
+ pVSh = 0;
+#endif
+ if( pVSh != pActionViewShell )
+ pActionViewShell = 0;
+ }
+
+ if( !pActionViewShell || (bChkAction && !pActionViewShell->ActionPend()) )
+ return pActionViewShell;
+
+ if( bSetCrsr )
+ {
+ // an allen CrsrEditShells die Cursor auf den Doc-Anfang setzen
+ ViewShell *pSh = pActionViewShell;
+ do {
+ if( pSh->IsA( TYPE( SwCrsrShell ) ) )
+ ((SwCrsrShell*)pSh)->SttDoc();
+ pSh = (ViewShell *)pSh->GetNext();
+ } while( pSh != pActionViewShell );
+
+ bSetCrsr = FALSE;
+ }
+ if( pActionViewShell->ISA( SwEditShell ) )
+ {
+ //Schon gescrollt?, dann dafuer sorgen, dass die View sich nicht bewegt!
+ const FASTBOOL bOldLock = pActionViewShell->IsViewLocked();
+ pActionViewShell->LockView( TRUE );
+ const FASTBOOL bOldEndActionByVirDev = pActionViewShell->IsEndActionByVirDev();
+ pActionViewShell->SetEndActionByVirDev( TRUE );;
+ ((SwEditShell*)pActionViewShell)->EndAction();
+ pActionViewShell->SetEndActionByVirDev( bOldEndActionByVirDev );
+ pActionViewShell->LockView( bOldLock );
+
+ // bChkJumpMark ist nur gesetzt, wenn das Object auch gefunden wurde
+ if( bChkJumpMark )
+ {
+ const Point aVisSttPos( DOCUMENTBORDER, DOCUMENTBORDER );
+ if( GetMedium() && aVisSttPos == pActionViewShell->VisArea().Pos() )
+ ::JumpToSwMark( pActionViewShell,
+ GetMedium()->GetURLObject().GetMark() );
+ bChkJumpMark = FALSE;
+ }
+ }
+ else
+ pActionViewShell->EndAction();
+
+ // sollte der Parser der Letzte sein, der das Doc haelt, dann kann
+ // man hier abbrechen und einen Fehler setzen.
+ if( 1 == pDoc->GetLinkCnt() )
+ {
+ eState = SVPAR_ERROR;
+ }
+
+ ViewShell *pVSh = pActionViewShell;
+ pActionViewShell = 0;
+
+ return pVSh;
+}
+
+ViewShell *SwHTMLParser::CheckActionViewShell()
+{
+ ViewShell *pVSh = 0;
+ pDoc->GetEditShell( &pVSh );
+ ASSERT( !pVSh || pActionViewShell == pVSh,
+ "CheckActionViewShell: Wer hat die ViewShell ausgetauscht?" );
+#ifdef DEBUG
+ if( pActionViewShell && !pVSh )
+ pVSh = 0;
+#endif
+ if( pVSh != pActionViewShell )
+ pActionViewShell = 0;
+
+ return pActionViewShell;
+}
+
+/* */
+
+void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable,
+ _HTMLAttrs *pPostIts )
+{
+ SwPaM* pAttrPam = new SwPaM( *pPam->GetPoint() );
+ const SwNodeIndex& rEndIdx = pPam->GetPoint()->nNode;
+ xub_StrLen nEndCnt = pPam->GetPoint()->nContent.GetIndex();
+ _HTMLAttr* pAttr;
+ SwCntntNode* pCNd;
+
+ _HTMLAttrs aFields( 5, 5 );
+
+ for( USHORT n = aSetAttrTab.Count(); n; )
+ {
+ pAttr = aSetAttrTab[ --n ];
+ USHORT nWhich = pAttr->pItem->Which();
+
+ ULONG nEndParaIdx = pAttr->GetEndParaIdx();
+ BOOL bSetAttr;
+ if( bChkEnd )
+ {
+ // fix #42192#: Zechen-Attribute mit Ende moeglich frueh,
+ // also noch im aktuellen Absatz setzen (wegen JavaScript
+ // und diversen Chats). das darf man aber nicht fuer Attribute,
+ // die ueber den ganzen Absatz aufgspannt werden sollen, weil
+ // sie aus Absatzvorlgen stammen, die nicht gesetzt werden
+ // koennen. Weil die Attribute mit SETATTR_DONTREPLACE
+ // eingefuegt werden, sollte man sie auch anchtraeglich
+ // noch setzen koennen.
+ bSetAttr = ( nEndParaIdx < rEndIdx.GetIndex() &&
+ (RES_LR_SPACE != nWhich || !GetNumInfo().GetNumRule()) ) ||
+ ( !pAttr->IsLikePara() &&
+ nEndParaIdx == rEndIdx.GetIndex() &&
+ pAttr->GetEndCnt() < nEndCnt &&
+ RES_CHRATR_BEGIN <= nWhich &&
+ RES_TXTATR_WITHEND_END > nWhich ) ||
+ ( bBeforeTable &&
+ nEndParaIdx == rEndIdx.GetIndex() &&
+ !pAttr->GetEndCnt() );
+ }
+ else
+ {
+ // Attribiute im Content-Bereich duerfen nicht gesetzt
+ // werden, wenn wir in einem Sonderbereich stehen, aber
+ // umgekekehrt schon.
+ ULONG nEndOfIcons = pDoc->GetNodes().GetEndOfExtras().GetIndex();
+ bSetAttr = nEndParaIdx < rEndIdx.GetIndex() ||
+ rEndIdx.GetIndex() > nEndOfIcons ||
+ nEndParaIdx <= nEndOfIcons;
+ }
+
+ if( bSetAttr )
+ {
+ // Das Attribute darf nicht in der liste der vorlaeufigen
+ // Absatz-Attribute stehen, weil es sonst geloescht wurde.
+ USHORT ii = aParaAttrs.Count();
+ while( ii-- )
+ {
+ ASSERT( pAttr != aParaAttrs[ii],
+ "SetAttr: Attribut duerfte noch nicht gesetzt werden" );
+ aParaAttrs.Remove( ii );
+ }
+
+
+ // dann also setzen
+ aSetAttrTab.Remove( n, 1 );
+
+ while( pAttr )
+ {
+ _HTMLAttr *pPrev = pAttr->GetPrev();
+ if( !pAttr->bValid )
+ {
+ // ungueltige Attribute koennen gloescht werden
+ delete pAttr;
+ pAttr = pPrev;
+ continue; //break;
+ }
+
+
+ pCNd = pDoc->GetNodes()[ pAttr->nSttPara ]->GetCntntNode();
+ if( !pCNd )
+ {
+ // durch die elende Loescherei von Nodes kann auch mal
+ // ein Index auf einen End-Node zeigen :-(
+ if( pAttr->GetSttPara() == pAttr->GetEndPara() &&
+ (nWhich < RES_TXTATR_NOEND_BEGIN ||
+ nWhich >= RES_TXTATR_NOEND_END) )
+ {
+ // wenn der End-Index auch auf den Node zeigt
+ // brauchen wir auch kein Attribut mehr zu setzen,
+ // es sei denn, es ist ein Text-Attribut.
+ delete pAttr;
+ pAttr = pPrev;
+ continue; //break;
+ }
+ pCNd = pDoc->GetNodes().GoNext( &(pAttr->nSttPara) );
+ if( pCNd )
+ pAttr->nSttCntnt = 0;
+ else
+ {
+ ASSERT( !this, "SetAttr: GoNext() failed!" );
+ delete pAttr;
+ pAttr = pPrev;
+ continue; // break;
+ }
+ }
+ pAttrPam->GetPoint()->nNode = pAttr->nSttPara;
+
+
+
+ // durch das Loeschen von BRs kann der Start-Index
+ // auch mal hinter das Ende des Textes zeigen
+ if( pAttr->nSttCntnt > pCNd->Len() )
+ pAttr->nSttCntnt = pCNd->Len();
+ pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt );
+
+ pAttrPam->SetMark();
+ if( pAttr->GetSttPara() != pAttr->GetEndPara() &&
+ (nWhich < RES_TXTATR_NOEND_BEGIN ||
+ nWhich >= RES_TXTATR_NOEND_END) )
+ {
+ pCNd = pDoc->GetNodes()[ pAttr->nEndPara ]->GetCntntNode();
+ if( !pCNd )
+ {
+ pCNd = pDoc->GetNodes().GoPrevious( &(pAttr->nEndPara) );
+ if( pCNd )
+ pAttr->nEndCntnt = pCNd->Len();
+ else
+ {
+ ASSERT( !this, "SetAttr: GoPrevious() failed!" );
+ pAttrPam->DeleteMark();
+ delete pAttr;
+ pAttr = pPrev;
+ continue; // break;
+ }
+ }
+
+ pAttrPam->GetPoint()->nNode = pAttr->nEndPara;
+ }
+ else if( pAttr->IsLikePara() )
+ {
+ pAttr->nEndCntnt = pCNd->Len();
+ }
+
+ // durch das Loeschen von BRs kann der End-Index
+ // auch mal hinter das Ende des Textes zeigen
+ if( pAttr->nEndCntnt > pCNd->Len() )
+ pAttr->nEndCntnt = pCNd->Len();
+
+ pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nEndCntnt );
+ if( bBeforeTable &&
+ pAttrPam->GetPoint()->nNode.GetIndex() ==
+ rEndIdx.GetIndex() )
+ {
+ // wenn wir vor dem Einfuegen einer Tabelle stehen
+ // und das Attribut im aktuellen Node beendet wird,
+ // muessen wir es im Node davor beenden oder wegschmeissen,
+ // wenn es erst in dem Node beginnt
+ if( nWhich != RES_BREAK && nWhich != RES_PAGEDESC &&
+ (nWhich < RES_TXTATR_NOEND_BEGIN ||
+ nWhich >= RES_TXTATR_NOEND_END) )
+ {
+ if( pAttrPam->GetMark()->nNode.GetIndex() !=
+ rEndIdx.GetIndex() )
+ {
+ ASSERT( !pAttrPam->GetPoint()->nContent.GetIndex(),
+ "Content-Position vor Tabelle nicht 0???" );
+ pAttrPam->Move( fnMoveBackward );
+ }
+ else
+ {
+ pAttrPam->DeleteMark();
+ delete pAttr;
+ pAttr = pPrev;
+ continue;
+ }
+ }
+ }
+
+ switch( nWhich )
+ {
+ case RES_FLTR_BOOKMARK: // dann also ein Bookmark einfuegen
+ {
+ String aName( ((SfxStringItem*)pAttr->pItem)->GetValue() );
+ USHORT nBookPos = pDoc->FindBookmark( aName );
+ if( nBookPos != USHRT_MAX )
+ {
+ const SwBookmark *pBkMk =
+ pDoc->GetBookmarks()[nBookPos];
+ if( pBkMk->GetPos() != *pAttrPam->GetPoint() )
+ pDoc->MakeUniqueBookmarkName( aName );
+ else
+ break; // keine doppelte Bookmark an dieser Pos
+ }
+ pAttrPam->DeleteMark();
+ pDoc->MakeBookmark( *pAttrPam, KeyCode(),
+ aName, aEmptyStr );
+
+ // ggfs. ein Bookmark anspringen
+ if( JUMPTO_MARK == eJumpTo &&
+ aName == sJmpMark )
+ {
+ bChkJumpMark = TRUE;
+ eJumpTo = JUMPTO_NONE;
+ }
+ }
+ break;
+ case RES_TXTATR_FIELD:
+ {
+ USHORT nFldWhich =
+ pPostIts ? ((const SwFmtFld *)pAttr->pItem)
+ ->GetFld()->GetTyp()->Which() : 0;
+ if( pPostIts && (RES_POSTITFLD == nFldWhich ||
+ RES_SCRIPTFLD == nFldWhich) )
+ {
+ pPostIts->Insert( pAttr, 0 );
+ }
+ else
+ {
+ aFields.Insert( pAttr, aFields.Count() );
+ }
+ }
+ pAttrPam->DeleteMark();
+ pAttr = pPrev;
+ continue;
+
+ case RES_LR_SPACE:
+ if( pAttrPam->GetPoint()->nNode.GetIndex() ==
+ pAttrPam->GetMark()->nNode.GetIndex() &&
+ pCNd )
+ {
+ // wegen Numerierungen dieses Attribut direkt
+ // am Node setzen
+ pCNd->SetAttr( *pAttr->pItem );
+ break;
+ }
+ ASSERT( !this,
+ "LRSpace ueber mehrere Absaetze gesetzt!" );
+ // kein break (hier sollen wir trotzdem nie hinkommen;
+ default:
+
+ // ggfs. ein Bookmark anspringen
+ if( RES_TXTATR_INETFMT == nWhich &&
+ JUMPTO_MARK == eJumpTo &&
+ sJmpMark == ((SwFmtINetFmt*)pAttr->pItem)->GetName() )
+ {
+ bChkJumpMark = TRUE;
+ eJumpTo = JUMPTO_NONE;
+ }
+
+ pDoc->Insert( *pAttrPam, *pAttr->pItem, SETATTR_DONTREPLACE );
+ }
+ pAttrPam->DeleteMark();
+
+ delete pAttr;
+ pAttr = pPrev;
+ }
+ }
+ }
+
+ for( n = aMoveFlyFrms.Count(); n; )
+ {
+ SwFrmFmt *pFrmFmt = aMoveFlyFrms[ --n ];
+
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ ASSERT( FLY_AT_CNTNT==rAnchor.GetAnchorId(),
+ "Nur Auto-Rahmen brauchen eine Spezialbehandlung" );
+ const SwPosition *pFlyPos = rAnchor.GetCntntAnchor();
+ ULONG nFlyParaIdx = pFlyPos->nNode.GetIndex();
+ BOOL bMoveFly;
+ if( bChkEnd )
+ {
+ bMoveFly = nFlyParaIdx < rEndIdx.GetIndex() ||
+ ( nFlyParaIdx == rEndIdx.GetIndex() &&
+ aMoveFlyCnts[n] < nEndCnt );
+ }
+ else
+ {
+ ULONG nEndOfIcons = pDoc->GetNodes().GetEndOfExtras().GetIndex();
+ bMoveFly = nFlyParaIdx < rEndIdx.GetIndex() ||
+ rEndIdx.GetIndex() > nEndOfIcons ||
+ nFlyParaIdx <= nEndOfIcons;
+ }
+ if( bMoveFly )
+ {
+ pFrmFmt->DelFrms();
+ *pAttrPam->GetPoint() = *pFlyPos;
+ pAttrPam->GetPoint()->nContent.Assign( pAttrPam->GetCntntNode(),
+ aMoveFlyCnts[n] );
+ SwFmtAnchor aAnchor( rAnchor );
+ aAnchor.SetType( FLY_AUTO_CNTNT );
+ aAnchor.SetAnchor( pAttrPam->GetPoint() );
+ pFrmFmt->SetAttr( aAnchor );
+
+ const SwFmtHoriOrient& rHoriOri = pFrmFmt->GetHoriOrient();
+ if( HORI_LEFT == rHoriOri.GetHoriOrient() )
+ {
+ SwFmtHoriOrient aHoriOri( rHoriOri );
+ aHoriOri.SetRelationOrient( REL_CHAR );
+ pFrmFmt->SetAttr( aHoriOri );
+ }
+ const SwFmtVertOrient& rVertOri = pFrmFmt->GetVertOrient();
+ if( VERT_TOP == rVertOri.GetVertOrient() )
+ {
+ SwFmtVertOrient aVertOri( rVertOri );
+ aVertOri.SetRelationOrient( REL_CHAR );
+ pFrmFmt->SetAttr( aVertOri );
+ }
+
+ pFrmFmt->MakeFrms();
+ aMoveFlyFrms.Remove( n, 1 );
+ aMoveFlyCnts.Remove( n, 1 );
+ }
+ }
+ while( aFields.Count() )
+ {
+ pAttr = aFields[0];
+
+ pCNd = pDoc->GetNodes()[ pAttr->nSttPara ]->GetCntntNode();
+ pAttrPam->GetPoint()->nNode = pAttr->nSttPara;
+ pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt );
+
+ if( bBeforeTable &&
+ pAttrPam->GetPoint()->nNode.GetIndex() == rEndIdx.GetIndex() )
+ {
+ ASSERT( !bBeforeTable, "Aha, der Fall tritt also doch ein" );
+ ASSERT( !pAttrPam->GetPoint()->nContent.GetIndex(),
+ "Content-Position vor Tabelle nicht 0???" );
+ // !!!
+ pAttrPam->Move( fnMoveBackward );
+ }
+
+ pDoc->Insert( *pAttrPam, *pAttr->pItem );
+
+ aFields.Remove( 0, 1 );
+ delete pAttr;
+ }
+
+ delete pAttrPam;
+}
+
+void SwHTMLParser::NewAttr( _HTMLAttr **ppAttr, const SfxPoolItem& rItem )
+{
+ // Font-Hoehen und -Farben- sowie Escapement-Attribute duerfen nicht
+ // zusammengefasst werden. Sie werden deshalb in einer Liste gespeichert,
+ // in der das zuletzt aufgespannte Attribut vorne steht und der Count
+ // immer 1 ist. Fuer alle anderen Attribute wird der Count einfach
+ // hochgezaehlt.
+ if( *ppAttr )
+ {
+ _HTMLAttr *pAttr = new _HTMLAttr( *pPam->GetPoint(), rItem,
+ ppAttr );
+ pAttr->InsertNext( *ppAttr );
+ (*ppAttr) = pAttr;
+ }
+ else
+ (*ppAttr) = new _HTMLAttr( *pPam->GetPoint(), rItem, ppAttr );
+}
+
+void SwHTMLParser::EndAttr( _HTMLAttr* pAttr, _HTMLAttr **ppDepAttr,
+ BOOL bChkEmpty )
+{
+ ASSERT( !ppDepAttr, "SwHTMLParser::EndAttr: ppDepAttr-Feature ungetestet?" );
+ // Der Listenkopf ist im Attribut gespeichert
+ _HTMLAttr **ppHead = pAttr->ppHead;
+
+ ASSERT( ppHead, "keinen Attributs-Listenkopf gefunden!" );
+
+ // die aktuelle Psoition als Ende-Position merken
+ const SwNodeIndex* pEndIdx = &pPam->GetPoint()->nNode;
+ xub_StrLen nEndCnt = pPam->GetPoint()->nContent.GetIndex();
+
+ // WIrd das zueltzt gestartete oder ein frueher gestartetes Attribut
+ // beendet?
+ _HTMLAttr *pLast = 0;
+ if( ppHead && pAttr != *ppHead )
+ {
+ // Es wird nicht das zuletzt gestartete Attribut beendet
+
+ // Dann suche wir das unmittelbar danach gestartete Attribut, das
+ // ja ebenfalls noch nicht beendet wurde (sonst stuende es nicht
+ // mehr in der Liste
+ pLast = *ppHead;
+ while( pLast && pLast->GetNext() != pAttr )
+ pLast = pLast->GetNext();
+
+ ASSERT( pLast, "Attribut nicht in eigener Liste gefunden!" );
+
+ // das Attribut nicht an der PaM-Psoition beenden, sondern da,
+ // wo das danch gestartete Attribut anfing???
+ //pEndIdx = &pPrev->GetSttPara();
+ //nEndCnt = pPrev->GetSttCnt();
+ }
+
+ BOOL bMoveBack = FALSE;
+ USHORT nWhich = pAttr->pItem->Which();
+ if( /*!pLast &&*/ !nEndCnt && RES_PARATR_BEGIN <= nWhich &&
+ *pEndIdx != pAttr->GetSttPara() )
+ {
+ // dann eine Cntntnt Position zurueck!
+ bMoveBack = pPam->Move( fnMoveBackward );
+ nEndCnt = pPam->GetPoint()->nContent.GetIndex();
+ }
+
+ // nun das Attrubut beenden
+ _HTMLAttr *pNext = pAttr->GetNext();
+
+ // ein Bereich ??
+ if( !bChkEmpty || (RES_PARATR_BEGIN <= nWhich && bMoveBack) ||
+ RES_PAGEDESC == nWhich || RES_BREAK == nWhich ||
+ *pEndIdx != pAttr->GetSttPara() ||
+ nEndCnt != pAttr->GetSttCnt() )
+ {
+ pAttr->nEndPara = *pEndIdx;
+ pAttr->nEndCntnt = nEndCnt;
+ pAttr->bInsAtStart = RES_TXTATR_INETFMT != nWhich &&
+ RES_TXTATR_CHARFMT != nWhich;
+
+ if( !pNext )
+ {
+ // keine offenen Attribute dieses Typs mehr da,
+ // dann koennen alle gesetzt werden, es sei denn
+ // sie haengen noch von einem anderen Attribut ab,
+ // dann werden sie dort angehaengt
+ if( ppDepAttr && *ppDepAttr )
+ (*ppDepAttr)->InsertPrev( pAttr );
+ else
+ {
+ USHORT nTmp = pAttr->bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pAttr, nTmp );
+ }
+ }
+ else
+ {
+ // es gibt noch andere offene Attribute des Typs,
+ // daher muss das Setzen zurueckgestellt werden.
+ // das aktuelle Attribut wird deshalb hinten an die
+ // Previous-Liste des Nachfolgers angehaengt
+ pNext->InsertPrev( pAttr );
+ }
+ }
+ else
+ {
+ // dann nicht einfuegen, sondern Loeschen. Durch das "tuerken" von
+ // Vorlagen durch harte Attributierung koennen sich auch mal andere
+ // leere Attribute in der Prev-Liste befinden, die dann trotzdem
+ // gesetzt werden muessen
+ _HTMLAttr *pPrev = pAttr->GetPrev();
+ delete pAttr;
+
+ if( pPrev )
+ {
+ // Die Previous-Attribute muessen trotzdem gesetzt werden.
+ if( pNext )
+ pNext->InsertPrev( pPrev );
+ else
+ {
+ USHORT nTmp = pPrev->bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pPrev, nTmp );
+ }
+ }
+
+ }
+
+ // wenn das erste Attribut der Liste gesetzt wurde muss noch der
+ // Listenkopf korrigiert werden.
+ if( pLast )
+ pLast->pNext = pNext;
+ else if( ppHead )
+ *ppHead = pNext;
+
+ if( bMoveBack )
+ pPam->Move( fnMoveForward );
+}
+
+void SwHTMLParser::DeleteAttr( _HTMLAttr* pAttr )
+{
+ // Hier darf es keine vorlauefigen Absatz-Attribute geben, den die
+ // koennten jetzt gesetzt werden und dann sind die Zeiger ungueltig!!!
+ ASSERT( !aParaAttrs.Count(),
+ "Hoechste Gefahr: Es gibt noch nicht-endgueltige Absatz-Attribute" );
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ // Der Listenkopf ist im Attribut gespeichert
+ _HTMLAttr **ppHead = pAttr->ppHead;
+
+ ASSERT( ppHead, "keinen Attributs-Listenkopf gefunden!" );
+
+ // Wird das zueltzt gestartete oder ein frueher gestartetes Attribut
+ // entfernt?
+ _HTMLAttr *pLast = 0;
+ if( ppHead && pAttr != *ppHead )
+ {
+ // Es wird nicht das zuletzt gestartete Attribut beendet
+
+ // Dann suche wir das unmittelbar danach gestartete Attribut, das
+ // ja ebenfalls noch nicht beendet wurde (sonst stuende es nicht
+ // mehr in der Liste
+ pLast = *ppHead;
+ while( pLast && pLast->GetNext() != pAttr )
+ pLast = pLast->GetNext();
+
+ ASSERT( pLast, "Attribut nicht in eigener Liste gefunden!" );
+ }
+
+ // nun das Attrubut entfernen
+ _HTMLAttr *pNext = pAttr->GetNext();
+ _HTMLAttr *pPrev = pAttr->GetPrev();
+ delete pAttr;
+
+ if( pPrev )
+ {
+ // Die Previous-Attribute muessen trotzdem gesetzt werden.
+ if( pNext )
+ pNext->InsertPrev( pPrev );
+ else
+ {
+ USHORT nTmp = pPrev->bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pPrev, nTmp );
+ }
+ }
+
+ // wenn das erste Attribut der Liste entfernt wurde muss noch der
+ // Listenkopf korrigiert werden.
+ if( pLast )
+ pLast->pNext = pNext;
+ else if( ppHead )
+ *ppHead = pNext;
+}
+
+void SwHTMLParser::SaveAttrTab( _HTMLAttrTable& rNewAttrTab )
+{
+ // Hier darf es keine vorlauefigen Absatz-Attribute geben, den die
+ // koennten jetzt gesetzt werden und dann sind die Zeiger ungueltig!!!
+ ASSERT( !aParaAttrs.Count(),
+ "Hoechste Gefahr: Es gibt noch nicht-endgueltige Absatz-Attribute" );
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ _HTMLAttr** pSaveTbl = (_HTMLAttr**)&rNewAttrTab;
+
+ for( USHORT nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; (++pTbl, ++pSaveTbl) )
+ {
+ *pSaveTbl = *pTbl;
+
+ _HTMLAttr *pAttr = *pSaveTbl;
+ while( pAttr )
+ {
+ pAttr->SetHead( pSaveTbl );
+ pAttr = pAttr->GetNext();
+ }
+
+ *pTbl = 0;
+ }
+}
+
+void SwHTMLParser::SplitAttrTab( _HTMLAttrTable& rNewAttrTab,
+ BOOL bMoveEndBack )
+{
+ // Hier darf es keine vorlauefigen Absatz-Attribute geben, den die
+ // koennten jetzt gesetzt werden und dann sind die Zeiger ungueltig!!!
+ ASSERT( !aParaAttrs.Count(),
+ "Hoechste Gefahr: Es gibt noch nicht-endgueltige Absatz-Attribute" );
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ const SwNodeIndex& nSttIdx = pPam->GetPoint()->nNode;
+ SwNodeIndex nEndIdx( nSttIdx );
+
+ // alle noch offenen Attribute beenden und hinter der Tabelle
+ // neu aufspannen
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ _HTMLAttr** pSaveTbl = (_HTMLAttr**)&rNewAttrTab;
+ BOOL bSetAttr = TRUE;
+ xub_StrLen nSttCnt = pPam->GetPoint()->nContent.GetIndex();
+ xub_StrLen nEndCnt = nSttCnt;
+
+ if( bMoveEndBack )
+ {
+ ULONG nOldEnd = nEndIdx.GetIndex();
+ ULONG nTmpIdx;
+ if( ( nTmpIdx = pDoc->GetNodes().GetEndOfExtras().GetIndex()) >= nOldEnd ||
+ ( nTmpIdx = pDoc->GetNodes().GetEndOfAutotext().GetIndex()) >= nOldEnd )
+ {
+ nTmpIdx = pDoc->GetNodes().GetEndOfInserts().GetIndex();
+ }
+ SwCntntNode* pCNd = pDoc->GetNodes().GoPrevious(&nEndIdx);
+
+ // keine Attribute setzen, wenn der PaM aus dem Content-Bereich
+ // herausgeschoben wurde.
+ bSetAttr = pCNd && nTmpIdx < nEndIdx.GetIndex();
+
+ nEndCnt = (bSetAttr ? pCNd->Len() : 0);
+ }
+ for( USHORT nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; (++pTbl, ++pSaveTbl) )
+ {
+ _HTMLAttr *pAttr = *pTbl;
+ *pSaveTbl = 0;
+ while( pAttr )
+ {
+ _HTMLAttr *pNext = pAttr->GetNext();
+ _HTMLAttr *pPrev = pAttr->GetPrev();
+
+ if( bSetAttr &&
+ ( pAttr->GetSttParaIdx() < nEndIdx.GetIndex() ||
+ (pAttr->GetSttPara() == nEndIdx &&
+ pAttr->GetSttCnt() != nEndCnt) ) )
+ {
+ // das Attribut muss vor der Liste gesetzt werden. Da wir
+ // das Original noch brauchen, weil Zeiger auf das Attribut
+ // noch in den Kontexten existieren, muessen wir es clonen.
+ // Die Next-Liste geht dabei verloren, aber die
+ // Previous-Liste bleibt erhalten
+ _HTMLAttr *pSetAttr = pAttr->Clone( nEndIdx, nEndCnt );
+
+ if( pNext )
+ pNext->InsertPrev( pSetAttr );
+ else
+ {
+ USHORT nTmp = pSetAttr->bInsAtStart ? 0
+ : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pSetAttr, nTmp );
+ }
+ }
+ else if( pPrev )
+ {
+ // Wenn das Attribut nicht gesetzt vor der Tabelle
+ // gesetzt werden muss, muessen der Previous-Attribute
+ // trotzdem gesetzt werden.
+ if( pNext )
+ pNext->InsertPrev( pPrev );
+ else
+ {
+ USHORT nTmp = pPrev->bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pPrev, nTmp );
+ }
+ }
+
+ // den Start des Attributs neu setzen und die Verkettungen
+ // aufbrechen
+ pAttr->Reset( nSttIdx, nSttCnt, pSaveTbl );
+
+ if( *pSaveTbl )
+ {
+ _HTMLAttr *pSAttr = *pSaveTbl;
+ while( pSAttr->GetNext() )
+ pSAttr = pSAttr->GetNext();
+ pSAttr->InsertNext( pAttr );
+ }
+ else
+ *pSaveTbl = pAttr;
+
+ pAttr = pNext;
+ }
+
+ *pTbl = 0;
+ }
+}
+
+void SwHTMLParser::RestoreAttrTab( const _HTMLAttrTable& rNewAttrTab,
+ BOOL bSetNewStart )
+{
+ // Hier darf es keine vorlauefigen Absatz-Attribute geben, den die
+ // koennten jetzt gesetzt werden und dann sind die Zeiger ungueltig!!!
+ ASSERT( !aParaAttrs.Count(),
+ "Hoechste Gefahr: Es gibt noch nicht-endgueltige Absatz-Attribute" );
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
+ _HTMLAttr** pSaveTbl = (_HTMLAttr**)&rNewAttrTab;
+
+ for( USHORT nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
+ nCnt--; (++pTbl, ++pSaveTbl) )
+ {
+ ASSERT( !*pTbl, "Die Attribut-Tabelle ist nicht leer!" );
+
+ const SwPosition *pPos = pPam->GetPoint();
+ const SwNodeIndex& rSttPara = pPos->nNode;
+ xub_StrLen nSttCnt = pPos->nContent.GetIndex();
+
+ *pTbl = *pSaveTbl;
+
+ _HTMLAttr *pAttr = *pTbl;
+ while( pAttr )
+ {
+ ASSERT( !pAttr->GetPrev() || !pAttr->GetPrev()->ppHead,
+ "Previous-Attribut hat noch einen Header" );
+ pAttr->SetHead( pTbl );
+ if( bSetNewStart )
+ {
+ pAttr->nSttPara = rSttPara;
+ pAttr->nEndPara = rSttPara;
+ pAttr->nSttCntnt = nSttCnt;
+ pAttr->nEndCntnt = nSttCnt;
+ }
+ pAttr = pAttr->GetNext();
+ }
+
+ *pSaveTbl = 0;
+ }
+}
+
+void SwHTMLParser::InsertAttr( const SfxPoolItem& rItem, BOOL bLikePara,
+ BOOL bInsAtStart )
+{
+ _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(),
+ rItem );
+ if( bLikePara )
+ pTmp->SetLikePara();
+ USHORT nTmp = bInsAtStart ? 0 : aSetAttrTab.Count();
+ aSetAttrTab.Insert( pTmp, nTmp );
+}
+
+void SwHTMLParser::InsertAttrs( _HTMLAttrs& rAttrs )
+{
+ while( rAttrs.Count() )
+ {
+ _HTMLAttr *pAttr = rAttrs[0];
+ InsertAttr( pAttr->GetItem() );
+ rAttrs.Remove( 0, 1 );
+ delete pAttr;
+ }
+}
+
+/* */
+
+void SwHTMLParser::NewStdAttr( int nToken )
+{
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ {
+ if( HTML_SPAN_ON != nToken || !aClass.Len() ||
+ !CreateContainer( aClass, aItemSet, aPropInfo, pCntxt ) )
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, TRUE );
+ }
+ }
+
+ // den Kontext merken
+ PushContext( pCntxt );
+}
+
+void SwHTMLParser::NewStdAttr( int nToken, _HTMLAttr **ppAttr,
+ const SfxPoolItem & rItem )
+{
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ aItemSet.Put( rItem );
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, TRUE );
+ }
+ else
+ {
+ InsertAttr( ppAttr ,rItem, pCntxt );
+ }
+
+ // den Kontext merken
+ PushContext( pCntxt );
+}
+
+void SwHTMLParser::EndTag( int nToken )
+{
+ // den Kontext holen
+ _HTMLAttrContext *pCntxt = PopContext( nToken & ~1 );
+ if( pCntxt )
+ {
+ // und ggf. die Attribute beenden
+ EndContext( pCntxt );
+ delete pCntxt;
+ }
+}
+
+
+void SwHTMLParser::NewBasefontAttr()
+{
+ String aId, aStyle, aClass;
+ USHORT nSize = 3;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_SIZE:
+ nSize = (USHORT)pOption->GetNumber();
+ break;
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ if( nSize < 1 )
+ nSize = 1;
+
+ if( nSize > 7 )
+ nSize = 7;
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_BASEFONT_ON );
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ aItemSet.Put( SvxFontHeightItem( aFontHeights[nSize-1] ) );
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, TRUE );
+ }
+ else
+ {
+ InsertAttr( &aAttrTab.pFontHeight, SvxFontHeightItem( aFontHeights[nSize-1] ), pCntxt );
+ }
+
+ // den Kontext merken
+ PushContext( pCntxt );
+
+ // die Font-Size merken
+ aBaseFontStack.Insert( nSize, aBaseFontStack.Count() );
+}
+
+void SwHTMLParser::EndBasefontAttr()
+{
+ EndTag( HTML_BASEFONT_ON );
+
+ // Stack-Unterlauf in Tabellen vermeiden
+ if( aBaseFontStack.Count() > nBaseFontStMin )
+ aBaseFontStack.Remove( aBaseFontStack.Count()-1, 1 );
+}
+
+void SwHTMLParser::NewFontAttr( int nToken )
+{
+ USHORT nBaseSize =
+ ( aBaseFontStack.Count() > nBaseFontStMin
+ ? (aBaseFontStack[aBaseFontStack.Count()-1] & FONTSIZE_MASK)
+ : 3 );
+ USHORT nFontSize =
+ ( aFontStack.Count() > nFontStMin
+ ? (aFontStack[aFontStack.Count()-1] & FONTSIZE_MASK)
+ : nBaseSize );
+
+ String aFace, aId, aStyle, aClass;
+ Color aColor;
+ ULONG nFontHeight = 0; // tatsaechlich einzustellende Font-Hoehe
+ USHORT nSize = 0; // Fontgroesse in Netscape-Notation (1-7)
+ BOOL bColor = FALSE;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_SIZE:
+ if( HTML_FONT_ON==nToken && pOption->GetString().Len() )
+ {
+ INT32 nSSize;
+ if( '+' == pOption->GetString().GetChar(0) ||
+ '-' == pOption->GetString().GetChar(0) )
+ nSSize = nBaseSize + pOption->GetSNumber();
+ else
+ nSSize = (INT32)pOption->GetNumber();
+
+ if( nSSize < 1 )
+ nSSize = 1;
+ else if( nSSize > 7 )
+ nSSize = 7;
+
+ nSize = (USHORT)nSSize;
+ nFontHeight = aFontHeights[nSize-1];
+ }
+ break;
+ case HTML_O_COLOR:
+ if( HTML_FONT_ON==nToken )
+ {
+ pOption->GetColor( aColor );
+ bColor = TRUE;
+ }
+ break;
+ case HTML_O_FACE:
+ if( HTML_FONT_ON==nToken )
+ aFace = pOption->GetString();
+ break;
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ if( HTML_FONT_ON != nToken )
+ {
+ // HTML_BIGPRINT_ON oder HTML_SMALLPRINT_ON
+
+ // in Ueberschriften bestimmt die aktuelle Ueberschrift
+ // die Font-Hoehe und nicht BASEFONT
+ USHORT nPoolId = GetCurrFmtColl()->GetPoolFmtId();
+ if( (nPoolId>=RES_POOLCOLL_HEADLINE1 &&
+ nPoolId<=RES_POOLCOLL_HEADLINE6) )
+ {
+ // wenn die Schriftgroesse in der Ueberschrift noch
+ // nicht veraendert ist, die aus der Vorlage nehmen
+ if( nFontStHeadStart==aFontStack.Count() )
+ nFontSize = 6 - (nPoolId - RES_POOLCOLL_HEADLINE1);
+ }
+ else
+ nPoolId = 0;
+
+ if( HTML_BIGPRINT_ON == nToken )
+ nSize = ( nFontSize<7 ? nFontSize+1 : 7 );
+ else
+ nSize = ( nFontSize>1 ? nFontSize-1 : 1 );
+
+ // in Ueberschriften wird die neue Fonthoehe wenn moeglich aus
+ // den Vorlagen geholt.
+ if( nPoolId && nSize>=1 && nSize <=6 )
+ nFontHeight =
+ pCSS1Parser->GetTxtCollFromPool(
+ RES_POOLCOLL_HEADLINE1+6-nSize )->GetSize().GetHeight();
+ else
+ nFontHeight = aFontHeights[nSize-1];
+ }
+
+ ASSERT( !nSize == !nFontHeight, "HTML-Font-Size != Font-Height" );
+
+ String aFontName, aStyleName;
+ FontFamily eFamily = FAMILY_DONTKNOW; // Family und Pitch,
+ FontPitch ePitch = PITCH_DONTKNOW; // falls nicht gefunden
+ rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
+
+ if( aFace.Len() && !pCSS1Parser->IsIgnoreFontFamily() )
+ {
+ const FontList *pFList = 0;
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( pDocSh )
+ {
+ const SvxFontListItem *pFListItem =
+ (const SvxFontListItem *)pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
+ if( pFListItem )
+ pFList = pFListItem->GetFontList();
+ }
+
+ BOOL bFound = FALSE;
+ xub_StrLen nStrPos = 0;
+ while( nStrPos!=STRING_NOTFOUND )
+ {
+ String aFName = aFace.GetToken( 0, ',', nStrPos );
+ aFName.EraseTrailingChars().EraseLeadingChars();
+ if( aFName.Len() )
+ {
+ if( !bFound && pFList )
+ {
+ sal_Handle hFont = pFList->GetFirstFontInfo( aFName );
+ if( 0 != hFont )
+ {
+ const FontInfo& rFInfo = pFList->GetFontInfo( hFont );
+ if( RTL_TEXTENCODING_DONTKNOW != rFInfo.GetCharSet() )
+ {
+ bFound = TRUE;
+ if( RTL_TEXTENCODING_SYMBOL == rFInfo.GetCharSet() )
+ eEnc = RTL_TEXTENCODING_SYMBOL;
+ }
+ }
+ }
+ if( aFontName.Len() )
+ aFontName += ';';
+ aFontName += aFName;
+ }
+ }
+ }
+
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( nFontHeight )
+ aItemSet.Put( SvxFontHeightItem( nFontHeight ) );
+ if( bColor )
+ aItemSet.Put( SvxColorItem(aColor) );
+ if( aFontName.Len() )
+ aItemSet.Put( SvxFontItem( eFamily, aFontName, aStyleName,
+ ePitch, eEnc ) );
+
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, TRUE );
+ }
+ else
+ {
+ if( nFontHeight )
+ InsertAttr( &aAttrTab.pFontHeight,
+ SvxFontHeightItem( nFontHeight ), pCntxt );
+ if( bColor )
+ InsertAttr( &aAttrTab.pFontColor, SvxColorItem(aColor), pCntxt );
+ if( aFontName.Len() )
+ InsertAttr( &aAttrTab.pFont,
+ SvxFontItem( eFamily, aFontName, aStyleName, ePitch,
+ eEnc ), pCntxt );
+ }
+
+ // den Kontext merken
+ PushContext( pCntxt );
+
+ aFontStack.Insert( nSize, aFontStack.Count() );
+}
+
+void SwHTMLParser::EndFontAttr( int nToken )
+{
+ EndTag( nToken );
+
+ // Stack-Unterlauf in Tabellen vermeiden
+ if( aFontStack.Count() > nFontStMin )
+ aFontStack.Remove( aFontStack.Count()-1, 1 );
+}
+
+/* */
+
+void SwHTMLParser::NewPara()
+{
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SPACE );
+ else
+ AddParSpace();
+
+ eParaAdjust = SVX_ADJUST_END;
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ eParaAdjust = (SvxAdjust)pOption->GetEnum( aHTMLPAlignTable, eParaAdjust );
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt =
+ aClass.Len() ? new _HTMLAttrContext( HTML_PARABREAK_ON,
+ RES_POOLCOLL_TEXT, aClass )
+ : new _HTMLAttrContext( HTML_PARABREAK_ON );
+
+ // Styles parsen (Class nicht beruecksichtigen. Das geht nur, solange
+ // keine der CSS1-Properties der Klasse hart formatiert werden muss!!!)
+ if( HasStyleOptions( aStyle, aId, aEmptyStr ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo ) )
+ {
+ ASSERT( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
+ "Class wird nicht beruecksichtigt" );
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ if( SVX_ADJUST_END != eParaAdjust )
+ InsertAttr( &aAttrTab.pAdjust, SvxAdjustItem(eParaAdjust), pCntxt );
+
+ // und auf den Stack packen
+ PushContext( pCntxt );
+
+ // die aktuelle Vorlage oder deren Attribute setzen
+ SetTxtCollAttrs( aClass.Len() ? pCntxt : 0 );
+
+ // Laufbalkenanzeige
+ ShowStatline();
+
+ ASSERT( !nOpenParaToken, "Jetzt geht ein offenes Absatz-Element verloren" );
+ nOpenParaToken = HTML_PARABREAK_ON;
+}
+
+void SwHTMLParser::EndPara( BOOL bReal )
+{
+ if( HTML_LI_ON==nOpenParaToken && pTable )
+ {
+ const SwNumRule *pNumRule = pPam->GetNode()->GetTxtNode()->GetNumRule();
+ ASSERT( pNumRule, "Wo ist die Numrule geblieben" );
+ if( pNumRule )
+ pDoc->UpdateNumRule( pNumRule->GetName(),
+ pPam->GetPoint()->nNode.GetIndex() );
+ }
+
+ // leere Absaetze werden von Netscape uebersprungen, von uns jetzt auch
+ if( bReal )
+ {
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SPACE );
+ else
+ AddParSpace();
+ }
+
+ // wenn ein DD oder DT offen war, handelt es sich um eine
+ // implizite Def-Liste, die jetzt beendet werden muss
+ if( (nOpenParaToken==HTML_DT_ON || nOpenParaToken==HTML_DD_ON) &&
+ nDefListDeep)
+ {
+ nDefListDeep--;
+ }
+
+ // den Kontext vom Stack holen. Er kann auch von einer implizit
+ // geoeffneten Definitionsliste kommen
+ _HTMLAttrContext *pCntxt =
+ PopContext( nOpenParaToken ? (nOpenParaToken & ~1)
+ : HTML_PARABREAK_ON );
+
+ // Attribute beenden
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+ delete pCntxt;
+ }
+
+ // und die bisherige Vorlage neu setzen
+ if( bReal )
+ SetTxtCollAttrs();
+
+ nOpenParaToken = 0;
+}
+
+
+void SwHTMLParser::NewHeading( int nToken )
+{
+ eParaAdjust = SVX_ADJUST_END;
+
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_ALIGN:
+ eParaAdjust = (SvxAdjust)pOption->GetEnum( aHTMLPAlignTable, eParaAdjust );
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Absatz aufmachen
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SPACE );
+ else
+ AddParSpace();
+
+ // die passende Vorlage suchen
+ USHORT nTxtColl;
+ switch( nToken )
+ {
+ case HTML_HEAD1_ON: nTxtColl = RES_POOLCOLL_HEADLINE1; break;
+ case HTML_HEAD2_ON: nTxtColl = RES_POOLCOLL_HEADLINE2; break;
+ case HTML_HEAD3_ON: nTxtColl = RES_POOLCOLL_HEADLINE3; break;
+ case HTML_HEAD4_ON: nTxtColl = RES_POOLCOLL_HEADLINE4; break;
+ case HTML_HEAD5_ON: nTxtColl = RES_POOLCOLL_HEADLINE5; break;
+ case HTML_HEAD6_ON: nTxtColl = RES_POOLCOLL_HEADLINE6; break;
+ default: nTxtColl = RES_POOLCOLL_STANDARD; break;
+ }
+
+ // den Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken, nTxtColl, aClass );
+
+ // Styles parsen (zu Class siehe auch NewPara)
+ if( HasStyleOptions( aStyle, aId, aEmptyStr ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo ) )
+ {
+ ASSERT( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
+ "Class wird nicht beruecksichtigt" );
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ if( SVX_ADJUST_END != eParaAdjust )
+ InsertAttr( &aAttrTab.pAdjust, SvxAdjustItem(eParaAdjust), pCntxt );
+
+ // udn auf den Stack packen
+ PushContext( pCntxt );
+
+ // und die Vorlage oder deren Attribute setzen
+ SetTxtCollAttrs( pCntxt );
+
+ nFontStHeadStart = aFontStack.Count();
+
+ // Laufbalkenanzeige
+ ShowStatline();
+}
+
+void SwHTMLParser::EndHeading()
+{
+ // einen neuen Absatz aufmachen
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SPACE );
+ else
+ AddParSpace();
+
+ // Kontext zu dem Token suchen und vom Stack holen
+ _HTMLAttrContext *pCntxt = 0;
+ USHORT nPos = aContexts.Count();
+ while( !pCntxt && nPos>nContextStMin )
+ {
+ switch( aContexts[--nPos]->GetToken() )
+ {
+ case HTML_HEAD1_ON:
+ case HTML_HEAD2_ON:
+ case HTML_HEAD3_ON:
+ case HTML_HEAD4_ON:
+ case HTML_HEAD5_ON:
+ case HTML_HEAD6_ON:
+ pCntxt = aContexts[nPos];
+ aContexts.Remove( nPos, 1 );
+ break;
+ }
+ }
+
+ // und noch Attribute beenden
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+ delete pCntxt;
+ }
+
+ // die bisherige Vorlage neu setzen
+ SetTxtCollAttrs();
+
+ nFontStHeadStart = nFontStMin;
+}
+
+/* */
+
+void SwHTMLParser::NewTxtFmtColl( int nToken, USHORT nColl )
+{
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Absatz aufmachen
+ SwHTMLAppendMode eMode = AM_NORMAL;
+ switch( nToken )
+ {
+ case HTML_LISTING_ON:
+ case HTML_XMP_ON:
+ // Diese beiden Tags werden jetzt auf die PRE-Vorlage gemappt.
+ // Fuer dem Fall, dass ein CLASS angegeben ist, loeschen wir
+ // es damit wir nicht die CLASS der PRE-Vorlage bekommen.
+ aClass = aEmptyStr;
+ case HTML_BLOCKQUOTE_ON:
+ case HTML_BLOCKQUOTE30_ON:
+ case HTML_PREFORMTXT_ON:
+ eMode = AM_SPACE;
+ break;
+ case HTML_ADDRESS_ON:
+ eMode = AM_NOSPACE; // ADDRESS kann auf einen <P> ohne </P> folgen
+ break;
+ case HTML_DT_ON:
+ case HTML_DD_ON:
+ eMode = AM_SOFTNOSPACE;
+ break;
+ default:
+ ASSERT( !this, "unbekannte Vorlage" );
+ break;
+ }
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( eMode );
+ else if( AM_SPACE==eMode )
+ AddParSpace();
+
+ // ... und in einem Kontext merken
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken, nColl, aClass );
+
+ // Styles parsen (zu Class siehe auch NewPara)
+ if( HasStyleOptions( aStyle, aId, aEmptyStr ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo ) )
+ {
+ ASSERT( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
+ "Class wird nicht beruecksichtigt" );
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ PushContext( pCntxt );
+
+ // die neue Vorlage setzen
+ SetTxtCollAttrs( pCntxt );
+
+ // Laufbalkenanzeige aktualisieren
+ ShowStatline();
+}
+
+void SwHTMLParser::EndTxtFmtColl( int nToken )
+{
+ SwHTMLAppendMode eMode = AM_NORMAL;
+ switch( nToken & ~1 )
+ {
+ case HTML_BLOCKQUOTE_ON:
+ case HTML_BLOCKQUOTE30_ON:
+ case HTML_PREFORMTXT_ON:
+ case HTML_LISTING_ON:
+ case HTML_XMP_ON:
+ eMode = AM_SPACE;
+ break;
+ case HTML_ADDRESS_ON:
+ case HTML_DT_ON:
+ case HTML_DD_ON:
+ eMode = AM_SOFTNOSPACE;
+ break;
+ default:
+ ASSERT( !this, "unbekannte Vorlage" );
+ break;
+ }
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( eMode );
+ else if( AM_SPACE==eMode )
+ AddParSpace();
+
+ // den aktuellen Kontext vom Stack holen
+ _HTMLAttrContext *pCntxt = PopContext( nToken & ~1 );
+
+ // und noch Attribute beenden
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+ delete pCntxt;
+ }
+
+ // und die bisherige Vorlage setzen
+ SetTxtCollAttrs();
+}
+
+/* */
+
+void SwHTMLParser::NewDefList()
+{
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Absatz aufmachen
+ BOOL bSpace = (GetNumInfo().GetDepth() + nDefListDeep) == 0;
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( bSpace ? AM_SPACE : AM_SOFTNOSPACE );
+ else if( bSpace )
+ AddParSpace();
+
+ // ein Level mehr
+ nDefListDeep++;
+
+
+ BOOL bInDD = FALSE, bNotInDD = FALSE;
+ USHORT nPos = aContexts.Count();
+ while( !bInDD && !bNotInDD && nPos>nContextStMin )
+ {
+ USHORT nCntxtToken = aContexts[--nPos]->GetToken();
+ switch( nCntxtToken )
+ {
+ case HTML_DEFLIST_ON:
+ case HTML_DIRLIST_ON:
+ case HTML_MENULIST_ON:
+ case HTML_ORDERLIST_ON:
+ case HTML_UNORDERLIST_ON:
+ bNotInDD = TRUE;
+ break;
+ case HTML_DD_ON:
+ bInDD = TRUE;
+ break;
+ }
+ }
+
+
+ // ... und in einem Kontext merken
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_DEFLIST_ON );
+
+ // darin auch die Raender merken
+ USHORT nLeft=0, nRight=0;
+ short nIndent=0;
+ GetMarginsFromContext( nLeft, nRight, nIndent );
+
+ // Die Einrueckung, die sich schon aus einem DL-ergibt, entspricht der
+ // eines DT auf dem aktuellen Level, und die entspricht der eines
+ // DD auf dem Level davor. Fue einen Level >=2 muss also ein DD-Abstand
+ // hinzugefuegt werden
+ if( !bInDD && nDefListDeep > 1 )
+ {
+
+ // und den der DT-Vorlage des aktuellen Levels
+ SvxLRSpaceItem rLRSpace =
+ pCSS1Parser->GetTxtFmtColl( RES_POOLCOLL_HTML_DD, aEmptyStr )
+ ->GetLRSpace();
+ nLeft += rLRSpace.GetTxtLeft();
+ }
+
+ pCntxt->SetMargins( nLeft, nRight, nIndent );
+
+ // Styles parsen
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ {
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt );
+ }
+ }
+
+ PushContext( pCntxt );
+
+ // die Attribute der neuen Vorlage setzen
+ if( nDefListDeep > 1 )
+ SetTxtCollAttrs( pCntxt );
+}
+
+void SwHTMLParser::EndDefList()
+{
+ BOOL bSpace = (GetNumInfo().GetDepth() + nDefListDeep) == 1;
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( bSpace ? AM_SPACE : AM_SOFTNOSPACE );
+ else if( bSpace )
+ AddParSpace();
+
+ // ein Level weniger
+ if( nDefListDeep > 0 )
+ nDefListDeep--;
+
+ // den aktuellen Kontext vom Stack holen
+ _HTMLAttrContext *pCntxt = PopContext( HTML_DEFLIST_ON );
+
+ // und noch Attribute beenden
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+ delete pCntxt;
+ }
+
+ // und Vorlage setzen
+ SetTxtCollAttrs();
+}
+
+void SwHTMLParser::NewDefListItem( int nToken )
+{
+ // festellen, ob das DD/DT in einer DL vorkommt
+ BOOL bInDefList = FALSE, bNotInDefList = FALSE;
+ USHORT nPos = aContexts.Count();
+ while( !bInDefList && !bNotInDefList && nPos>nContextStMin )
+ {
+ USHORT nCntxtToken = aContexts[--nPos]->GetToken();
+ switch( nCntxtToken )
+ {
+ case HTML_DEFLIST_ON:
+ bInDefList = TRUE;
+ break;
+ case HTML_DIRLIST_ON:
+ case HTML_MENULIST_ON:
+ case HTML_ORDERLIST_ON:
+ case HTML_UNORDERLIST_ON:
+ bNotInDefList = TRUE;
+ break;
+ }
+ }
+
+ // wenn nicht, implizit eine neue DL aufmachen
+ if( !bInDefList )
+ {
+ nDefListDeep++;
+ ASSERT( !nOpenParaToken,
+ "Jetzt geht ein offenes Absatz-Element verloren" );
+ nOpenParaToken = nToken;
+ }
+
+ NewTxtFmtColl( nToken, nToken==HTML_DD_ON ? RES_POOLCOLL_HTML_DD
+ : RES_POOLCOLL_HTML_DT );
+}
+
+void SwHTMLParser::EndDefListItem( int nToken, BOOL bSetColl,
+ BOOL bLastPara )
+{
+ // einen neuen Absatz aufmachen
+ if( !nToken && pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_SOFTNOSPACE );
+
+ // Kontext zu dem Token suchen und vom Stack holen
+ nToken &= ~1;
+ _HTMLAttrContext *pCntxt = 0;
+ USHORT nPos = aContexts.Count();
+ while( !pCntxt && nPos>nContextStMin )
+ {
+ USHORT nCntxtToken = aContexts[--nPos]->GetToken();
+ switch( nCntxtToken )
+ {
+ case HTML_DD_ON:
+ case HTML_DT_ON:
+ if( !nToken || nToken == nCntxtToken )
+ {
+ pCntxt = aContexts[nPos];
+ aContexts.Remove( nPos, 1 );
+ }
+ break;
+ case HTML_DEFLIST_ON:
+ // keine DD/DT ausserhalb der aktuelen DefListe betrachten
+ case HTML_DIRLIST_ON:
+ case HTML_MENULIST_ON:
+ case HTML_ORDERLIST_ON:
+ case HTML_UNORDERLIST_ON:
+ // und auch nicht ausserhalb einer anderen Liste
+ nPos = nContextStMin;
+ break;
+ }
+ }
+
+ // und noch Attribute beenden
+ if( pCntxt )
+ {
+ EndContext( pCntxt );
+ SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
+ delete pCntxt;
+ }
+
+ // und die bisherige Vorlage setzen
+ if( bSetColl )
+ SetTxtCollAttrs();
+}
+
+/* */
+
+BOOL SwHTMLParser::HasCurrentParaFlys( BOOL bNoSurroundOnly,
+ BOOL bSurroundOnly ) const
+{
+ // bNoSurroundOnly: Der Absatz enthaelt mindestens einen Rahmen
+ // ohne Umlauf
+ // bSurroundOnly: Der Absatz enthaelt mindestens einen Rahmen
+ // mit Umlauf aber keinen ohne Umlauf
+ // sonst: Der Absatz enthaelt irgendeinen Rahmen
+ SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode;
+
+ SwFrmFmt* pFmt;
+ const SwFmtAnchor* pAnchor;
+ const SwPosition* pAPos;
+ const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
+
+ USHORT i;
+ BOOL bFound = FALSE;
+ for( i=0; i<rFrmFmtTbl.Count(); i++ )
+ {
+ pFmt = rFrmFmtTbl[i];
+ pAnchor = &pFmt->GetAnchor();
+ // Ein Rahmen wurde gefunden, wenn
+ // - er absatzgebunden ist, und
+ // - im aktuellen Absatz verankert ist, und
+ // - jeder absatzgebunene Rahmen zaehlt, oder
+ // - (nur Rahmen oder umlauf zaehlen und ) der Rahmen keinen
+ // Umlauf besitzt
+
+ if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) &&
+ (FLY_AT_CNTNT == pAnchor->GetAnchorId() ||
+ FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) &&
+ pAPos->nNode == rNodeIdx )
+ {
+ if( !(bNoSurroundOnly || bSurroundOnly) )
+ {
+ bFound = TRUE;
+ break;
+ }
+ else
+ {
+ // fix #42282#: Wenn Rahmen mit Umlauf gesucht sind,
+ // auch keine mit Durchlauf beachten. Dabei handelt es
+ // sich (noch) um HIDDEN-Controls, und denen weicht man
+ // besser auch nicht aus.
+ SwSurround eSurround = pFmt->GetSurround().GetSurround();
+ if( bNoSurroundOnly )
+ {
+ if( SURROUND_NONE==eSurround )
+ {
+ bFound = TRUE;
+ break;
+ }
+ }
+ if( bSurroundOnly )
+ {
+ if( SURROUND_NONE==eSurround )
+ {
+ bFound = FALSE;
+ break;
+ }
+ else if( SURROUND_THROUGHT!=eSurround )
+ {
+ bFound = TRUE;
+ // weitersuchen: Es koennten ja noch welche ohne
+ // Umlauf kommen ...
+ }
+ }
+ }
+ }
+ }
+
+ return bFound;
+}
+
+/* */
+
+// die speziellen Methoden zum Einfuegen von Objecten
+
+const SwFmtColl *SwHTMLParser::GetCurrFmtColl() const
+{
+ const SwCntntNode* pCNd = pPam->GetCntntNode();
+ return &pCNd->GetAnyFmtColl();
+}
+
+
+void SwHTMLParser::SetTxtCollAttrs( _HTMLAttrContext *pContext )
+{
+ SwTxtFmtColl *pCollToSet = 0; // die zu setzende Vorlage
+ SfxItemSet *pItemSet = 0; // der Set fuer harte Attrs
+ USHORT nTopColl = pContext ? pContext->GetTxtFmtColl() : 0;
+ const String& rTopClass = pContext ? pContext->GetClass() : (const String&) aEmptyStr;
+ USHORT nDfltColl = RES_POOLCOLL_TEXT;
+
+ BOOL bInPRE=FALSE; // etwas Kontext Info
+
+ USHORT nLeftMargin = 0, nRightMargin = 0; // die Einzuege und
+ short nFirstLineIndent = 0; // Abstaende
+
+ for( USHORT i=nContextStAttrMin; i<aContexts.Count(); i++ )
+ {
+ const _HTMLAttrContext *pCntxt = aContexts[i];
+
+ USHORT nColl = pCntxt->GetTxtFmtColl();
+ if( nColl )
+ {
+ // Es gibt eine Vorlage, die zu setzen ist. Dann
+ // muss zunaechst einmal entschieden werden,
+ // ob die Vorlage auch gesetzt werden kann
+ BOOL bSetThis = TRUE;
+ switch( nColl )
+ {
+ case USHORT(RES_POOLCOLL_HTML_PRE):
+ bInPRE = TRUE;
+ break;
+ case USHORT(RES_POOLCOLL_TEXT):
+ // <TD><P CLASS=xxx> muss TD.xxx werden
+ if( nDfltColl==RES_POOLCOLL_TABLE ||
+ nDfltColl==RES_POOLCOLL_TABLE_HDLN )
+ nColl = nDfltColl;
+ break;
+ case USHORT(RES_POOLCOLL_HTML_HR):
+ // <HR> auch in <PRE> als Vorlage setzen, sonst kann man sie
+ // nicht mehr exportieren
+ break;
+ default:
+ if( bInPRE )
+ bSetThis = FALSE;
+ break;
+ }
+
+ SwTxtFmtColl *pNewColl =
+ pCSS1Parser->GetTxtFmtColl( nColl, pCntxt->GetClass() );
+
+ if( bSetThis )
+ {
+ // wenn jetzt eine andere Vorlage gesetzt werden soll als
+ // bisher, muss die bishere Vorlage durch harte Attributierung
+ // ersetzt werden
+
+ if( pCollToSet )
+ {
+ // die Attribute, die die bisherige Vorlage setzt
+ // hart einfuegen
+ if( !pItemSet )
+ pItemSet = new SfxItemSet( pCollToSet->GetAttrSet() );
+ else
+ {
+ const SfxItemSet& rCollSet = pCollToSet->GetAttrSet();
+ SfxItemSet aItemSet( *rCollSet.GetPool(),
+ rCollSet.GetRanges() );
+ aItemSet.Set( rCollSet );
+ pItemSet->Put( aItemSet );
+ }
+ // aber die Attribute, die aktuelle Vorlage setzt
+ // entfernen, weil sie sonst spaeter ueberschrieben
+ // werden
+ pItemSet->Differentiate( pNewColl->GetAttrSet() );
+ }
+
+ pCollToSet = pNewColl;
+ }
+ else
+ {
+ // hart Attributieren
+ if( !pItemSet )
+ pItemSet = new SfxItemSet( pNewColl->GetAttrSet() );
+ else
+ {
+ const SfxItemSet& rCollSet = pNewColl->GetAttrSet();
+ SfxItemSet aItemSet( *rCollSet.GetPool(),
+ rCollSet.GetRanges() );
+ aItemSet.Set( rCollSet );
+ pItemSet->Put( aItemSet );
+ }
+ }
+ }
+ else
+ {
+ // vielliecht gibt es ja eine Default-Vorlage?
+ nColl = pCntxt->GetDfltTxtFmtColl();
+ if( nColl )
+ nDfltColl = nColl;
+ }
+
+ // ggf. neue Absatz-Einzuege holen
+ if( pCntxt->IsLRSpaceChanged() )
+ {
+ USHORT nLeft=0, nRight=0;
+
+ pCntxt->GetMargins( nLeft, nRight, nFirstLineIndent );
+ nLeftMargin = nLeft;
+ nRightMargin = nRight;
+ }
+ }
+
+ // wenn im aktuellen Kontext eine neue Vorlage gesetzt werden soll,
+ // muessen deren Absatz-Abstaende noch in den Kontext eingetragen werden
+ if( pContext && nTopColl )
+ {
+ // <TD><P CLASS=xxx> muss TD.xxx werden
+ if( nTopColl==RES_POOLCOLL_TEXT &&
+ (nDfltColl==RES_POOLCOLL_TABLE ||
+ nDfltColl==RES_POOLCOLL_TABLE_HDLN) )
+ nTopColl = nDfltColl;
+
+ const SwTxtFmtColl *pTopColl =
+ pCSS1Parser->GetTxtFmtColl( nTopColl, rTopClass );
+ const SfxItemSet& rItemSet = pTopColl->GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState(RES_LR_SPACE,TRUE, &pItem) )
+ {
+ const SvxLRSpaceItem *pLRItem =
+ (const SvxLRSpaceItem *)pItem;
+
+ USHORT nLeft = pLRItem->GetTxtLeft();
+ USHORT nRight = pLRItem->GetRight();
+ nFirstLineIndent = pLRItem->GetTxtFirstLineOfst();
+
+ // In Definitions-Listen enthalten die Abstaende auch die der
+ // vorhergehenden Level
+ if( RES_POOLCOLL_HTML_DD == nTopColl )
+ {
+ const SvxLRSpaceItem& rDTLRSpace = pCSS1Parser
+ ->GetTxtFmtColl( RES_POOLCOLL_HTML_DT, aEmptyStr )
+ ->GetLRSpace();
+ nLeft -= rDTLRSpace.GetTxtLeft();
+ nRight -= rDTLRSpace.GetRight();
+ }
+ else if( RES_POOLCOLL_HTML_DT == nTopColl )
+ {
+ nLeft = 0;
+ nRight = 0;
+ }
+
+ // die Absatz-Abstaende addieren sich
+ nLeftMargin += nLeft;
+ nRightMargin += nRight;
+
+ pContext->SetMargins( nLeftMargin, nRightMargin,
+ nFirstLineIndent );
+ }
+ if( SFX_ITEM_SET == rItemSet.GetItemState(RES_UL_SPACE,TRUE, &pItem) )
+ {
+ const SvxULSpaceItem *pULItem =
+ (const SvxULSpaceItem *)pItem;
+ pContext->SetULSpace( pULItem->GetUpper(), pULItem->GetLower() );
+ }
+ }
+
+ // wenn gar keine Vorlage im Kontext gesetzt ist, Textkoerper nehmen
+ if( !pCollToSet )
+ {
+ pCollToSet = pCSS1Parser->GetTxtCollFromPool( nDfltColl );
+ const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace();
+ if( !nLeftMargin )
+ nLeftMargin = rLRItem.GetTxtLeft();
+ if( !nRightMargin )
+ nRightMargin = rLRItem.GetRight();
+ if( !nFirstLineIndent )
+ nFirstLineIndent = rLRItem.GetTxtFirstLineOfst();
+ }
+
+ // bisherige harte Attributierung des Absatzes entfernen
+ if( aParaAttrs.Count() )
+ {
+ for( i=0; i<aParaAttrs.Count(); i++ )
+ aParaAttrs[i]->Invalidate();
+
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+ }
+
+ // Die Vorlage setzen
+ pDoc->SetTxtFmtColl( *pPam, pCollToSet );
+
+ // ggf. noch den Absatz-Einzug korrigieren
+ const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace();
+ BOOL bSetLRSpace;
+
+#ifndef NUM_RELSPACE
+ SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
+ ASSERT( pTxtNode, "TxtFmtColl an Nicht-Text-Node setzen???" );
+ const SwNodeNum *pNodeNum = pTxtNode->GetNum();
+ if( GetNumInfo().GetDepth() > 0 || pNodeNum )
+ {
+ // Die Werte fuer den linken Rand und den Einzug koennte man auch
+ // aus der NumRule holen. Berechnen ist aber einfacher.
+
+ ASSERT( (GetNumInfo().GetDepth() > 0) ==
+ (GetNumInfo().GetNumRule() != 0),
+ "Keine NumRule in Aufzaehlung oder umgekehrt" );
+
+ ASSERT( pNodeNum, "Kein SwNodeNum am Absatz in Aufzaehlung" );
+
+ BOOL bNumbered = FALSE;
+ if( pNodeNum && !(NO_NUMLEVEL & pNodeNum->GetLevel()) )
+ {
+ // der Erstzeilen-Einzug des List-Items muss noch zu dem
+ // sowieso schon bestehenden addiert werden, weil er im
+ // LI-Kontext nicht gesetzt wurde. Das ist leider nicht moeglich,
+ // weil auch nicht-numerierte Absaetze in diesem Kontext
+ // vorkommen koennen.
+ nFirstLineIndent += HTML_NUMBUL_INDENT;
+ bNumbered = TRUE;
+ }
+
+ // In LI-Absaetzen ausserhalb von OL/UL ist nNumBulListDeep 0, aber
+ // es muss trotzdem um die Breite des Bullet-Zeichens eingerueckt
+ // werden.
+ USHORT nLeftMarginNumBul = (GetNumInfo().GetDepth() * HTML_NUMBUL_MARGINLEFT);
+ if( !nLeftMarginNumBul )
+ nLeftMarginNumBul = (USHORT)(-HTML_NUMBUL_INDENT);
+
+ bSetLRSpace = nLeftMargin != nLeftMarginNumBul ||
+ (bNumbered && nFirstLineIndent != HTML_NUMBUL_INDENT) ||
+ (!bNumbered && nFirstLineIndent) ||
+ nRightMargin != rLRItem.GetRight();
+
+ pTxtNode->SetNumLSpace( !bSetLRSpace );
+ }
+ else
+ {
+#endif
+ bSetLRSpace = nLeftMargin != rLRItem.GetTxtLeft() ||
+ nFirstLineIndent != rLRItem.GetTxtFirstLineOfst() ||
+ nRightMargin != rLRItem.GetRight();
+#ifndef NUM_RELSPACE
+ }
+#endif
+
+ if( bSetLRSpace )
+ {
+ SvxLRSpaceItem aLRItem( rLRItem );
+ aLRItem.SetTxtLeft( nLeftMargin );
+ aLRItem.SetRight( nRightMargin );
+ aLRItem.SetTxtFirstLineOfst( nFirstLineIndent );
+ if( pItemSet )
+ pItemSet->Put( aLRItem );
+ else
+ {
+ NewAttr( &aAttrTab.pLRSpace, aLRItem );
+ aAttrTab.pLRSpace->SetLikePara();
+ aParaAttrs.Insert( aAttrTab.pLRSpace, aParaAttrs.Count() );
+ EndAttr( aAttrTab.pLRSpace, 0, FALSE );
+ }
+ }
+
+ // und nun noch die Attribute setzen
+ if( pItemSet )
+ {
+ InsertParaAttrs( *pItemSet );
+ delete pItemSet;
+ }
+}
+
+/* */
+
+void SwHTMLParser::NewCharFmt( int nToken )
+{
+ String aId, aStyle, aClass;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // einen neuen Kontext anlegen
+ _HTMLAttrContext *pCntxt = new _HTMLAttrContext( nToken );
+
+ // die Vorlage setzen und im Kontext merken
+ SwCharFmt* pCFmt = pCSS1Parser->GetChrFmt( nToken, aClass );
+ ASSERT( pCFmt, "keine Zeichenvorlage zu Token gefunden" );
+
+
+ // Styles parsen (zu Class siehe auch NewPara)
+ if( HasStyleOptions( aStyle, aId, aEmptyStr ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo ) )
+ {
+ ASSERT( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
+ "Class wird nicht beruecksichtigt" );
+ DoPositioning( aItemSet, aPropInfo, pCntxt );
+ InsertAttrs( aItemSet, aPropInfo, pCntxt, TRUE );
+ }
+ }
+
+ // Zeichen-Vorlagen werden in einem eigenen Stack gehalten und
+ // koennen nie durch Styles eingefuegt werden. Das Attribut ist deshalb
+ // auch gar nicht im CSS1-Which-Range enthalten
+ if( pCFmt )
+ InsertAttr( &aAttrTab.pCharFmts, SwFmtCharFmt( pCFmt ), pCntxt );
+
+ // den Kontext merken
+ PushContext( pCntxt );
+}
+
+
+/* */
+
+void SwHTMLParser::InsertSpacer()
+{
+ // und es ggf. durch die Optionen veraendern
+ String aId;
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
+ Size aSize( 0, 0);
+ long nSize = 0;
+ BOOL bPrcWidth = FALSE;
+ BOOL bPrcHeight = FALSE;
+ USHORT nType = HTML_SPTYPE_HORI;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_TYPE:
+ pOption->GetEnum( nType, aHTMLSpacerTypeTable );
+ break;
+ case HTML_O_ALIGN:
+ eVertOri =
+ (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable,
+ eVertOri );
+ eHoriOri =
+ (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable,
+ eHoriOri );
+ break;
+ case HTML_O_WIDTH:
+ // erstmal nur als Pixelwerte merken!
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_HEIGHT:
+ // erstmal nur als Pixelwerte merken!
+ bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_SIZE:
+ // erstmal nur als Pixelwerte merken!
+ nSize = pOption->GetNumber();
+ break;
+ }
+ }
+
+ switch( nType )
+ {
+ case HTML_SPTYPE_BLOCK:
+ {
+ // einen leeren Textrahmen anlegen
+
+ // den Itemset holen
+ SfxItemSet aFrmSet( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aFrmSet );
+
+ // den Anker und die Ausrichtung setzen
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, aFrmSet );
+
+ // und noch die Groesse des Rahmens
+ Size aDfltSz( MINFLY, MINFLY );
+ Size aSpace( 0, 0 );
+ SfxItemSet aDummyItemSet( pDoc->GetAttrPool(),
+ pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aDummyPropInfo;
+
+ SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight,
+ aDummyItemSet, aDummyPropInfo, aFrmSet );
+ SetSpace( aSpace, aDummyItemSet, aDummyPropInfo, aFrmSet );
+
+ // den Inhalt schuetzen
+ SvxProtectItem aProtectItem;
+ aProtectItem.SetCntntProtect( TRUE );
+ aFrmSet.Put( aProtectItem );
+
+ // der Rahmen anlegen
+ RndStdIds eAnchorId =
+ ((const SwFmtAnchor &)aFrmSet.Get(RES_ANCHOR)).GetAnchorId();
+ SwFrmFmt *pFlyFmt = pDoc->MakeFlySection( eAnchorId,
+ pPam->GetPoint(), &aFrmSet );
+ // Ggf Frames anlegen und auto-geb. Rahmen registrieren
+ RegisterFlyFrm( pFlyFmt );
+ }
+ break;
+ case HTML_SPTYPE_VERT:
+ if( nSize > 0 )
+ {
+ if( nSize && Application::GetDefaultDevice() )
+ {
+ nSize = Application::GetDefaultDevice()
+ ->PixelToLogic( Size(0,nSize),
+ MapMode(MAP_TWIP) ).Height();
+ }
+
+ // einen Absatz-Abstand setzen
+ SwTxtNode *pTxtNode = 0;
+ if( !pPam->GetPoint()->nContent.GetIndex() )
+ {
+ // den unteren Absatz-Abstand des vorherigen Nodes aendern,
+ // wenn moeglich
+
+ SetAttr(); // noch offene Absatz-Attribute setzen
+
+ pTxtNode = pDoc->GetNodes()[pPam->GetPoint()->nNode.GetIndex()-1]
+ ->GetTxtNode();
+
+ // Wenn der Abstz davor kein Txtenode ist, dann wird jetzt
+ // ein leere Absatz angelegt, der eh schon eine Zeilenhoehe
+ // Abstand erzeugt.
+ if( !pTxtNode )
+ nSize = nSize>HTML_PARSPACE ? nSize-HTML_PARSPACE : 0;
+ }
+
+ if( pTxtNode )
+ {
+ SvxULSpaceItem aULSpace( (const SvxULSpaceItem&)pTxtNode
+ ->SwCntntNode::GetAttr( RES_UL_SPACE ) );
+ aULSpace.SetLower( aULSpace.GetLower() + (USHORT)nSize );
+ pTxtNode->SwCntntNode::SetAttr( aULSpace );
+ }
+ else
+ {
+ NewAttr( &aAttrTab.pULSpace, SvxULSpaceItem( 0, (USHORT)nSize ) );
+ EndAttr( aAttrTab.pULSpace, 0, FALSE );
+
+ AppendTxtNode(); // nicht am Abstand drehen!
+ }
+ }
+ break;
+ case HTML_SPTYPE_HORI:
+ if( nSize > 0 )
+ {
+ // wenn der Absatz noch leer ist, einen Erstzeilen-Einzug
+ // setzen, sondern Sperrschrift ueber einem Space aufspannen
+
+ if( nSize && Application::GetDefaultDevice() )
+ {
+ nSize = Application::GetDefaultDevice()
+ ->PixelToLogic( Size(nSize,0),
+ MapMode(MAP_TWIP) ).Width();
+ }
+
+ if( !pPam->GetPoint()->nContent.GetIndex() )
+ {
+ USHORT nLeft=0, nRight=0;
+ short nIndent = 0;
+
+ GetMarginsFromContextWithNumBul( nLeft, nRight, nIndent );
+ nIndent += (short)nSize;
+
+ SvxLRSpaceItem aLRItem;
+ aLRItem.SetTxtLeft( nLeft );
+ aLRItem.SetRight( nRight );
+ aLRItem.SetTxtFirstLineOfst( nIndent );
+
+ NewAttr( &aAttrTab.pLRSpace, aLRItem );
+ EndAttr( aAttrTab.pLRSpace, 0, FALSE );
+ }
+ else
+ {
+ NewAttr( &aAttrTab.pKerning, SvxKerningItem( (short)nSize ) );
+ String aTmp( ' ' );
+ pDoc->Insert( *pPam, aTmp /*, CHARSET_ANSI*/ );
+ EndAttr( aAttrTab.pKerning );
+ }
+ }
+ }
+}
+
+USHORT SwHTMLParser::ToTwips( USHORT nPixel ) const
+{
+ if( nPixel && Application::GetDefaultDevice() )
+ {
+ long nTwips = Application::GetDefaultDevice()->PixelToLogic(
+ Size( nPixel, nPixel ), MapMode( MAP_TWIP ) ).Width();
+ return nTwips <= USHRT_MAX ? (USHORT)nTwips : USHRT_MAX;
+ }
+ else
+ return nPixel;
+}
+
+const SwTwips SwHTMLParser::GetCurrentBrowseWidth()
+{
+ SwTwips nWidth = SwHTMLTableLayout::GetBrowseWidth( *pDoc );
+ if( nWidth )
+ return nWidth;
+
+ if( !aHTMLPageSize.Width() )
+ {
+ const SwFrmFmt& rPgFmt = pCSS1Parser->GetMasterPageDesc()->GetMaster();
+
+ const SwFmtFrmSize& rSz = rPgFmt.GetFrmSize();
+ const SvxLRSpaceItem& rLR = rPgFmt.GetLRSpace();
+ const SvxULSpaceItem& rUL = rPgFmt.GetULSpace();
+ const SwFmtCol& rCol = rPgFmt.GetCol();
+
+ aHTMLPageSize.Width() = rSz.GetWidth() - rLR.GetLeft() - rLR.GetRight();
+ aHTMLPageSize.Height() = rSz.GetHeight() - rUL.GetUpper() - rUL.GetLower();
+
+ if( 1 < rCol.GetNumCols() )
+ aHTMLPageSize.Width() /= rCol.GetNumCols();
+ }
+
+ return aHTMLPageSize.Width();
+}
+
+
+/* */
+
+void SwHTMLParser::InsertIDOption()
+{
+ String aId;
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ if( HTML_O_ID==pOption->GetToken() )
+ {
+ aId = pOption->GetString();
+ break;
+ }
+ }
+
+ if( aId.Len() )
+ InsertBookmark( aId );
+}
+
+
+/* */
+
+
+void SwHTMLParser::InsertLineBreak()
+{
+ // <BR CLEAR=xxx> wird wie folgt behandelt:
+ // 1.) Es werden nur nur absatzgebundene Rahmen betrachtet, die
+ // im aktuellen Absatz verankert sind.
+ // 2.) Fuer linksbuendig ausgerichtete Rahmen wird bei CLEAR=LEFT
+ // oder ALL und auf rechtsbuendige ausgerichtete Rahmen bei
+ // CLEAR=RIGHT oder ALL der Durchlauf wie folgt geaendert:
+ // 3.) Wenn der Absatz keinen Text enthaelt, bekommt der Rahmen keinen
+ // Umlauf
+ // 4.) sonst erhaelt ein links ausgerichteter Rahmen eine rechten
+ // "nur Anker" Umlauf und recht rechst ausg. Rahmen einen linken
+ // "nur Anker" Umlauf.
+ // 5.) wenn in einem nicht-leeren Absatz der Umlauf eines Rahmens
+ // geaendert wird, wird ein neuer Absatz aufgemacht
+ // 6.) Wenn von keinem Rahmen der Umlauf geaendert wird, wird ein
+ // harter Zeilenumbruch eingefuegt
+
+ String aId, aStyle, aClass; // die ID der Bookmark
+ BOOL bClearLeft = FALSE, bClearRight = FALSE;
+ BOOL bCleared = FALSE; // wurde ein CLEAR ausgefuehrt?
+
+ // dann holen wir mal die Optionen
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_CLEAR:
+ {
+ const String &aClear = pOption->GetString();
+ if( aClear.EqualsIgnoreCaseAscii( sHTML_AL_all ) )
+ {
+ bClearLeft = TRUE;
+ bClearRight = TRUE;
+ }
+ else if( aClear.EqualsIgnoreCaseAscii( sHTML_AL_left ) )
+ bClearLeft = TRUE;
+ else if( aClear.EqualsIgnoreCaseAscii( sHTML_AL_right ) )
+ bClearRight = TRUE;
+ }
+ break;
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ }
+ }
+
+ // CLEAR wird nur fuer den aktuellen Absaetz unterstuetzt
+ if( bClearLeft || bClearRight )
+ {
+ SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode;
+ SwTxtNode* pTxtNd = rNodeIdx.GetNode().GetTxtNode();
+ if( pTxtNd )
+ {
+ SwFrmFmt* pFmt;
+ const SwFmtAnchor* pAnchor;
+ const SwPosition* pAPos;
+ const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
+
+ for( USHORT i=0; i<rFrmFmtTbl.Count(); i++ )
+ {
+ pFmt = rFrmFmtTbl[i];
+ pAnchor = &pFmt->GetAnchor();
+ if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) &&
+ (FLY_AT_CNTNT == pAnchor->GetAnchorId() ||
+ FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) &&
+ pAPos->nNode == rNodeIdx &&
+ pFmt->GetSurround().GetSurround() != SURROUND_NONE )
+ {
+ SwHoriOrient eHori = RES_DRAWFRMFMT == pFmt->Which()
+ ? HORI_LEFT
+ : pFmt->GetHoriOrient().GetHoriOrient();
+
+ SwSurround eSurround = SURROUND_PARALLEL;
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ {
+ if( bClearLeft && HORI_LEFT==eHori )
+ eSurround = SURROUND_RIGHT;
+ else if( bClearRight && HORI_RIGHT==eHori )
+ eSurround = SURROUND_LEFT;
+ }
+ else if( (bClearLeft && HORI_LEFT==eHori) ||
+ (bClearRight && HORI_RIGHT==eHori) )
+ {
+ eSurround = SURROUND_NONE;
+ }
+
+ if( SURROUND_PARALLEL != eSurround )
+ {
+ SwFmtSurround aSurround( eSurround );
+ if( SURROUND_NONE != eSurround )
+ aSurround.SetAnchorOnly( TRUE );
+ pFmt->SetAttr( aSurround );
+ bCleared = TRUE;
+ }
+ } // Anker ist nicht im Node
+ } // Schleife ueber Fly-Frames
+ } // kein Text-Node
+ } // kein CLEAR
+
+ // Styles parsen
+ SvxFmtBreakItem aBreakItem;
+ BOOL bBreakItem = FALSE;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ {
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+
+ if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
+ {
+ if( pCSS1Parser->SetFmtBreak( aItemSet, aPropInfo ) )
+ {
+ aBreakItem = (const SvxFmtBreakItem &)aItemSet.Get( RES_BREAK );
+ bBreakItem = TRUE;
+ }
+ if( aPropInfo.aId.Len() )
+ InsertBookmark( aPropInfo.aId );
+ }
+ }
+
+ if( bBreakItem && SVX_BREAK_PAGE_AFTER==aBreakItem.GetBreak() )
+ {
+ NewAttr( &aAttrTab.pBreak, aBreakItem );
+ EndAttr( aAttrTab.pBreak, 0, FALSE );
+ }
+
+ if( !bCleared && !bBreakItem )
+ {
+ // wenn kein CLEAR ausgefuehrt werden sollte oder konnte, wird
+ // ein Zeilenumbruch eingefgt
+ String sTmp( (sal_Unicode)0x0a ); // make the Mac happy :-)
+ pDoc->Insert( *pPam, sTmp );
+ }
+ else if( pPam->GetPoint()->nContent.GetIndex() )
+ {
+ // wenn ein Claer in einem nicht-leeren Absatz ausgefuehrt wurde,
+ // muss anschliessen ein neuer Absatz aufgemacht werden
+ // MIB 21.02.97: Eigentlich muesste man hier den unteren Absatz-
+ // Absatnd auf 0 drehen. Das geht aber bei sowas wie <BR ..><P>
+ // schief (>Netacpe). Deshalb lassen wir das erstmal.
+ AppendTxtNode( AM_NOSPACE );
+ }
+ if( bBreakItem && SVX_BREAK_PAGE_BEFORE==aBreakItem.GetBreak() )
+ {
+ NewAttr( &aAttrTab.pBreak, aBreakItem );
+ EndAttr( aAttrTab.pBreak, 0, FALSE );
+ }
+}
+
+void SwHTMLParser::InsertHorzRule()
+{
+ USHORT nSize = 0;
+ USHORT nWidth = 0;
+
+ SvxAdjust eAdjust = SVX_ADJUST_END;
+
+ BOOL bPrcWidth = FALSE;
+ BOOL bNoShade = FALSE;
+ BOOL bColor = FALSE;
+
+ Color aColor;
+ String aId;
+
+ // dann holen wir mal die Optionen
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_SIZE:
+ nSize = (USHORT)pOption->GetNumber();
+ break;
+ case HTML_O_WIDTH:
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ nWidth = (USHORT)pOption->GetNumber();
+ if( bPrcWidth && nWidth>=100 )
+ {
+ // 100%-Linien sind der default-Fall (keine Attrs neotig)
+ nWidth = 0;
+ bPrcWidth = FALSE;
+ }
+ break;
+ case HTML_O_ALIGN:
+ eAdjust =
+ (SvxAdjust)pOption->GetEnum( aHTMLPAlignTable, eAdjust );
+ break;
+ case HTML_O_NOSHADE:
+ bNoShade = TRUE;
+ break;
+ case HTML_O_COLOR:
+ pOption->GetColor( aColor );
+ bColor = TRUE;
+ break;
+ }
+ }
+
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ AppendTxtNode( AM_NOSPACE );
+ if( nOpenParaToken )
+ EndPara();
+ AppendTxtNode();
+ pPam->Move( fnMoveBackward );
+
+ // ... und in einem Kontext merken
+ _HTMLAttrContext *pCntxt =
+ new _HTMLAttrContext( HTML_HORZRULE, RES_POOLCOLL_HTML_HR, aEmptyStr );
+
+ PushContext( pCntxt );
+
+ // die neue Vorlage setzen
+ SetTxtCollAttrs( pCntxt );
+
+ // die harten Attribute an diesem Absatz werden nie mehr ungueltig
+ if( aParaAttrs.Count() )
+ aParaAttrs.Remove( 0, aParaAttrs.Count() );
+
+ if( nSize>0 || bColor || bNoShade )
+ {
+ // Farbe und/oder Breite der Linie setzen
+ if( !bColor )
+ aColor.SetColor( COL_GRAY );
+
+ SvxBorderLine aBorderLine( &aColor );
+ if( nSize )
+ {
+ long nPWidth = 0;
+ long nPHeight = (long)nSize;
+ SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
+ SvxCSS1Parser::SetBorderWidth( aBorderLine, (USHORT)nPHeight,
+ !bNoShade );
+ }
+ else if( bNoShade )
+ {
+ aBorderLine.SetOutWidth( DEF_LINE_WIDTH_2 );
+ }
+ else
+ {
+ aBorderLine.SetOutWidth( DEF_DOUBLE_LINE0_OUT );
+ aBorderLine.SetInWidth( DEF_DOUBLE_LINE0_IN );
+ aBorderLine.SetDistance( DEF_DOUBLE_LINE0_DIST );
+ }
+
+ SvxBoxItem aBoxItem;
+ aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
+ _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(), aBoxItem );
+ aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
+ }
+ if( nWidth )
+ {
+ // Wenn wir in keiner Tabelle sind, wird die Breitenangabe durch
+ // Absatz-Einzuege "getuerkt". In einer Tabelle macht das wenig
+ // Sinn. Um zu Vermeiden, dass die Linie bei der Breitenberechnung
+ // beruecksichtigt wird, bekommt sie aber trotzdem entsprechendes
+ // LRSpace-Item verpasst.
+#ifdef FIX41370
+ const SwFmtColl *pColl = GetCurrFmtColl();
+ SvxLRSpaceItem aLRItem( pColl->GetLRSpace() );
+#endif
+ if( !pTable )
+ {
+ // Laenge und Ausrichtung der Linie ueber Absatz-Einzuege "tuerken"
+ long nBrowseWidth = GetCurrentBrowseWidth();
+ nWidth = bPrcWidth ? (USHORT)((nWidth*nBrowseWidth) / 100)
+ : ToTwips( (USHORT)nBrowseWidth );
+ if( nWidth < MINLAY )
+ nWidth = MINLAY;
+
+ if( (long)nWidth < nBrowseWidth )
+ {
+#ifndef FIX41370
+ const SwFmtColl *pColl = GetCurrFmtColl();
+ SvxLRSpaceItem aLRItem( pColl->GetLRSpace() );
+#endif
+ long nDist = nBrowseWidth - nWidth;
+
+ switch( eAdjust )
+ {
+ case SVX_ADJUST_RIGHT:
+ aLRItem.SetTxtLeft( (USHORT)nDist );
+ break;
+ case SVX_ADJUST_LEFT:
+ aLRItem.SetRight( (USHORT)nDist );
+ break;
+ case SVX_ADJUST_CENTER:
+ default:
+ nDist /= 2;
+ aLRItem.SetTxtLeft( (USHORT)nDist );
+ aLRItem.SetRight( (USHORT)nDist );
+ break;
+ }
+
+#ifndef FIX41370
+ _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(), aLRItem );
+ aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
+#endif
+ }
+ }
+
+#ifdef FIX41370
+ _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(), aLRItem );
+ aSetAttrTab.Insert( pTmp, aSetAttrTab.Count() );
+#endif
+ }
+
+ // Bookmarks koennen nicht in Hyperlinks eingefueht werden
+ if( aId.Len() )
+ InsertBookmark( aId );
+
+ // den aktuellen Kontext vom Stack holen
+ _HTMLAttrContext *pPoppedContext = PopContext( HTML_HORZRULE );
+ ASSERT( pPoppedContext==pCntxt, "wo kommt denn da ein HR-Kontext her?" );
+ delete pPoppedContext;
+
+ pPam->Move( fnMoveForward );
+
+ // und im Absatz danach die dort aktuelle Vorlage setzen
+ SetTxtCollAttrs();
+}
+
+void SwHTMLParser::ParseMoreMetaOptions()
+{
+ String aName, aContent;
+ BOOL bHTTPEquiv = FALSE, bChanged = FALSE;
+
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
+ {
+ const HTMLOption *pOption = (*pOptions)[ --i ];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_NAME:
+ aName = pOption->GetString();
+ bHTTPEquiv = FALSE;
+ break;
+ case HTML_O_HTTPEQUIV:
+ aName = pOption->GetString();
+ bHTTPEquiv = TRUE;
+ break;
+ case HTML_O_CONTENT:
+ aContent = pOption->GetString();
+ break;
+ }
+ }
+
+ // Hier wird es etwas tricky: Wir wissen genau, daá die Dok-Info
+ // nicht geaendert wurde. Deshalb genuegt es, auf Generator und
+ // auf refresh abzufragen, um noch nicht verarbeitete Token zu finden,
+ // denn das sind die einzigen, die die Dok-Info nicht modifizieren.
+ if( aName.EqualsIgnoreCaseAscii( sHTML_META_generator ) ||
+ aName.EqualsIgnoreCaseAscii( sHTML_META_refresh ) ||
+ aName.EqualsIgnoreCaseAscii( sHTML_META_content_type ) ||
+ aName.EqualsIgnoreCaseAscii( sHTML_META_content_script_type ) )
+ return;
+
+ aContent.EraseAllChars( _CR );
+ aContent.EraseAllChars( _LF );
+
+ if( aName.EqualsIgnoreCaseAscii( sHTML_META_sdendnote ) )
+ {
+ FillEndNoteInfo( aContent );
+ return;
+ }
+
+ if( aName.EqualsIgnoreCaseAscii( sHTML_META_sdfootnote ) )
+ {
+ FillFootNoteInfo( aContent );
+ return;
+ }
+
+ String sText(
+ String::CreateFromAscii(TOOLS_CONSTASCII_STRINGPARAM("HTML: <")) );
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(sHTML_meta) );
+ sText.Append( ' ' );
+ if( bHTTPEquiv )
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(sHTML_O_httpequiv) );
+ else
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(sHTML_O_name) );
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM("=\"") );
+ sText.Append( aName );
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM("\" ") );
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(sHTML_O_content) );
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM("=\"") );
+ sText.Append( aContent );
+ sText.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM("\">") );
+
+ SwPostItField aPostItFld(
+ (SwPostItFieldType*)pDoc->GetSysFldType( RES_POSTITFLD ),
+ aEmptyStr, sText, Date() );
+ SwFmtFld aFmtFld( aPostItFld );
+ InsertAttr( aFmtFld );
+}
+
+/* */
+
+#ifdef USED
+void __EXPORT SwHTMLParser::SaveState( int nToken )
+{
+ HTMLParser::SaveState( nToken );
+}
+
+void __EXPORT SwHTMLParser::RestoreState()
+{
+ HTMLParser::RestoreState();
+}
+#endif
+
+/* */
+
+_HTMLAttr::_HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
+ _HTMLAttr **ppHd )
+ : nSttPara( rPos.nNode ), nEndPara( rPos.nNode ),
+ nSttCntnt( rPos.nContent.GetIndex() ),
+ nEndCntnt(rPos.nContent.GetIndex() ),
+ nCount( 1 ), pNext( 0 ), pPrev( 0 ), ppHead( ppHd ),
+ bInsAtStart( TRUE ), bLikePara( FALSE ), bValid( TRUE )
+{
+ pItem = rItem.Clone();
+}
+
+_HTMLAttr::_HTMLAttr( const _HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
+ USHORT nEndCnt, _HTMLAttr **ppHd ) :
+ nSttPara( rAttr.nSttPara ), nEndPara( rEndPara ),
+ nSttCntnt( rAttr.nSttCntnt ), nEndCntnt( nEndCnt ),
+ nCount( rAttr.nCount ), pNext( 0 ), pPrev( 0 ), ppHead( ppHd ),
+ bInsAtStart( rAttr.bInsAtStart ), bLikePara( rAttr.bLikePara ),
+ bValid( rAttr.bValid )
+{
+ pItem = rAttr.pItem->Clone();
+}
+
+_HTMLAttr::~_HTMLAttr()
+{
+ delete pItem;
+}
+
+_HTMLAttr *_HTMLAttr::Clone( const SwNodeIndex& rEndPara, USHORT nEndCnt ) const
+{
+ // das Attribut mit der alten Start-Position neu anlegen
+ _HTMLAttr *pNew = new _HTMLAttr( *this, rEndPara, nEndCnt, ppHead );
+
+ // die Previous-Liste muss uebernommen werden, die Next-Liste nicht!
+ pNew->pPrev = pPrev;
+
+ return pNew;
+}
+
+void _HTMLAttr::Reset( const SwNodeIndex& rSttPara, USHORT nSttCnt,
+ _HTMLAttr **ppHd )
+{
+ // den Anfang (und das Ende) neu setzen
+ nSttPara = rSttPara;
+ nSttCntnt = nSttCnt;
+ nEndPara = rSttPara;
+ nEndCntnt = nSttCnt;
+
+ // den Head korrigieren und die Verkettungen aufheben
+ pNext = 0;
+ pPrev = 0;
+ ppHead = ppHd;
+}
+
+void _HTMLAttr::InsertPrev( _HTMLAttr *pPrv )
+{
+ ASSERT( !pPrv->pNext || pPrv->pNext == this,
+ "_HTMLAttr::InsertPrev: pNext falsch" );
+ pPrv->pNext = 0;
+
+ ASSERT( 0 == pPrv->ppHead || ppHead == pPrv->ppHead,
+ "_HTMLAttr::InsertPrev: ppHead falsch" );
+ pPrv->ppHead = 0;
+
+ _HTMLAttr *pAttr = this;
+ while( pAttr->GetPrev() )
+ pAttr = pAttr->GetPrev();
+
+ pAttr->pPrev = pPrv;
+}
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.494 2000/09/18 16:04:47 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.493 2000/09/05 14:01:29 mib
+ #78294#: removed support for frameset documents
+
+ Revision 1.492 2000/08/04 10:55:23 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character
+
+ Revision 1.491 2000/06/26 09:52:42 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.490 2000/06/13 09:37:51 os
+ using UCB
+
+ Revision 1.489 2000/04/10 12:20:58 mib
+ unicode
+
+ Revision 1.488 2000/03/17 15:19:53 mib
+ #74249#: Call EndAction before collaing DocumentDetected
+
+ Revision 1.487 2000/03/13 15:07:03 jp
+ remove JavaScript
+
+ Revision 1.486 2000/03/03 15:21:01 os
+ StarView remainders removed
+
+ Revision 1.485 2000/03/03 12:44:32 mib
+ Removed JavaScript
+
+ Revision 1.484 2000/02/11 15:41:10 hr
+ #70473# changes for unicode
+
+ Revision 1.483 2000/01/20 11:48:38 jp
+ Bug #72119#: HTML-Template is moved into an other directory
+
+ Revision 1.482 1999/10/21 17:50:12 jp
+ have to change - SearchFile with SfxIniManager, dont use SwFinder for this
+
+ Revision 1.481 1999/09/21 09:50:36 mib
+ multiple text encodings
+
+ Revision 1.480 1999/09/17 12:14:52 mib
+ support of multiple and non system text encodings
+
+ Revision 1.479 1999/07/21 14:11:18 JP
+ Bug #67779#: set any MsgBoxType at the StringErrorInfo
+
+
+ Rev 1.478 21 Jul 1999 16:11:18 JP
+ Bug #67779#: set any MsgBoxType at the StringErrorInfo
+
+ Rev 1.477 11 Jun 1999 10:27:36 MIB
+ #66744#: EnableModified flag
+
+ Rev 1.476 10 Jun 1999 10:34:32 JP
+ have to change: no AppWin from SfxApp
+
+ Rev 1.475 27 Apr 1999 16:42:26 JP
+ Bug #65314#: neu: IsJavaScriptEnabled
+
+ Rev 1.474 15 Apr 1999 13:48:30 MIB
+ #41833#: Styles fuer A-Tag
+
+ Rev 1.473 13 Apr 1999 10:58:56 MIB
+ #64638#: ASP-tags wie unbekannte Tags behandeln
+
+ Rev 1.472 09 Apr 1999 17:52:00 MA
+ #64467# EndAction und VirDev
+
+ Rev 1.471 08 Apr 1999 17:33:44 MIB
+ #64522#: Styles fuer TD/TH auswerten
+
+ Rev 1.470 08 Apr 1999 12:45:54 MA
+ #64467# F?r die EndAction immer alles per VirDev painten
+
+ Rev 1.469 07 Apr 1999 13:50:46 MIB
+ #64327#: GetBrowseWidth fuer Tabellen in Rahmen richtig
+
+ Rev 1.468 29 Mar 1999 16:06:08 MIB
+ #64051#: Undo auch nach JavaScript anschalten
+
+ Rev 1.467 17 Mar 1999 16:41:52 MIB
+ #63049#: Numerierungen mit relativen Abstaenden
+
+ Rev 1.466 15 Mar 1999 13:14:30 JP
+ Bug #63339#: Einfuegen Doc - Absaetze richtig zusammenfassen
+
+ Rev 1.465 11 Mar 1999 23:55:22 JP
+ Task #63171#: Optionen fuer Feld-/LinkUpdate Doc oder Modul lokal
+
+ Rev 1.464 10 Mar 1999 15:43:22 MIB
+ #62682#: Beim Setzen der Control-Groesse wenn noetig auf die ViewShell warten
+
+ Rev 1.463 25 Feb 1999 17:27:10 MIB
+ #61691#: falscher Assert
+
+ Rev 1.462 25 Feb 1999 16:01:58 MIB
+ #61949#: globale Shell entsorgti, #62261#: <BR CLEAR> auch fuer Controls
+
+ Rev 1.461 23 Feb 1999 08:56:34 MA
+ Syntaxfehler fuer Update
+
+ Rev 1.460 22 Feb 1999 08:40:30 MA
+ 1949globale Shell entsorgt, Shells am RootFrm
+
+ Rev 1.459 11 Jan 1999 10:45:30 MIB
+ #60137#: UCS2-/UTF8-Unterstuetzung jetzt auch fuer F-Sets richtig
+
+ Rev 1.458 18 Dec 1998 09:23:34 MIB
+ #60137#: UTF-8-/UCS-2-Unterstuetzung fuer HTML
+
+ Rev 1.457 04 Dec 1998 14:23:58 MIB
+ #54626#: <LH> ausserhalb von <OL>/<UL> verbessert, entspricht #55072#
+
+ Rev 1.456 02 Dec 1998 10:55:12 MIB
+ #59886#: Kein Assert bei Attributen in Previous-Listen mehr
+
+ Rev 1.455 23 Nov 1998 13:12:46 OM
+ #58216# Enum fuer Aktualisieren von Verknuepfungen
+
+ Rev 1.454 20 Nov 1998 11:51:24 MIB
+ #59064#: Unbekannte Token/<NOSCRIPT> und <NOEMEBED> beibehalten
+
+ Rev 1.453 18 Nov 1998 10:24:30 MIB
+ #59579#: Inhalt von <TITLE> und <NOSCRIPT> nicht zur Filter-Detection heranziehen
+
+ Rev 1.452 13 Nov 1998 14:38:26 MIB
+ Nachtrag zu #58450#: Fuss-/Endnoten: Assert bei Verwendung der Vorlegen weg
+
+ Rev 1.451 11 Nov 1998 17:42:02 MIB
+ #59059#: Beim Abbrechen Pendung-Stack noch aufraeumen
+
+ Rev 1.450 02 Nov 1998 17:14:26 MIB
+ #58480#: Fuss-/Endnoten
+
+ Rev 1.449 23 Oct 1998 09:47:16 MIB
+ #58172#: Nach JS-Aufruf falls vorhanden zuletzt aktive ViewShell wieder setzten
+
+ Rev 1.448 13 Oct 1998 17:28:34 MIB
+ #57901#: Fixed-Font-Namen vom System holen, alten Namen entfernt
+
+ Rev 1.447 07 Oct 1998 11:07:26 MIB
+ #57559#: Erstes Token immer im Continue behandeln, 55072 erstmal raus
+
+ Rev 1.446 01 Sep 1998 12:06:50 MIB
+ #55072#: <LI> ohne <OL>/<UL> verbessert
+
+ Rev 1.445 01 Sep 1998 09:52:02 MIB
+ #55248#: Header beenden, wenn Dokuemnttyp erkannt wurde
+
+ Rev 1.444 31 Aug 1998 18:43:54 MIB
+ #55134#: DocumentDetected zum Anlegen der View aufrufen, bevor Controls eingef. werden
+
+ Rev 1.443 26 Aug 1998 13:29:00 MIB
+ #54970#: bCallNextToken nicht setzen, wenn keine Listbox, Applet, etc. einefuegt wurde
+
+ Rev 1.442 26 Aug 1998 09:30:42 MIB
+ #55144#: Umlauf bei Tabellen in Rahmen richtig setzen und beachten
+
+ Rev 1.441 25 Aug 1998 11:09:42 MIB
+ #50455#: Applet erst beim </APPLET> anlegen, weil erst dann alle Parameter da sind
+
+ Rev 1.440 28 Jul 1998 12:04:58 MIB
+ #54025#: Auf ObjectDying der ViewShell achten, #52559#: JavaScript-Zeilennummern
+
+ Rev 1.439 23 Jul 1998 11:14:12 JP
+ Task #52654#: Einfuegen Doc nicht mit einer CrsrShell sondern mit einen PaM
+
+ Rev 1.438 13 Jul 1998 09:20:28 MIB
+ #50966#: Fonts optional ignorieren
+
+ Rev 1.437 08 Jul 1998 17:19:46 MIB
+ StarScript
+
+ Rev 1.436 02 Jul 1998 15:50:10 JP
+ Modules Path ueber den PathFinder herausfinden
+
+ Rev 1.435 26 Jun 1998 12:21:48 OM
+ #51184# SubType an ExpressionFields richtig setzen und abfragen
+
+ Rev 1.434 15 Jun 1998 15:39:02 JP
+ Bug #51132#: _SetAttr - nicht pAttr sonder pAttr->pItem ist das Attribut
+
+ Rev 1.433 15 Jun 1998 13:13:28 MIB
+ fix #51020#: Im AppendTxtNode Attrs die den ganzen Absatz sofort setzen
+
+ Rev 1.432 08 Jun 1998 12:08:42 MIB
+ fix #50795#: <BODY>-Tag ist sicheres Indiz fuer Text-Dokument
+
+ Rev 1.431 05 Jun 1998 14:04:32 JP
+ Bug #42487#: Sprung zum Mark schon waehrend des Ladens ausfuehren
+
+ Rev 1.430 20 May 1998 10:41:04 MIB
+ fix #50341#: Script-Feld fuer nicht beendetes Script einfuegen
+
+ Rev 1.429 15 May 1998 11:31:02 MIB
+ UNO-Controls statt VC-Controls (noch geht nicht viel)
+
+ Rev 1.428 12 May 1998 15:50:44 JP
+ rund um Flys/DrawObjs im Doc/FESh umgestellt/optimiert
+
+ Rev 1.427 29 Apr 1998 17:37:52 MIB
+ fix: HTML-Seitenvorlage in SW-Doks wieder setzen
+
+ Rev 1.426 21 Apr 1998 13:47:26 MIB
+ fix: Keine Bookmark fuer abs-pos Objekte mit ID einfuegen
+
+ Rev 1.425 16 Apr 1998 11:36:42 MIB
+ Keine HTML-Seiten-Vorlage mehr setzen, Warnings
+
+ Rev 1.424 15 Apr 1998 14:54:36 MIB
+ Zwei-seitige Printing-Extensions
+
+ Rev 1.423 03 Apr 1998 12:22:16 MIB
+ Export des Rahmen-Namens als ID
+
+ Rev 1.422 02 Apr 1998 19:42:40 MIB
+ Positionierung von spaltigen Rahmen
+
+ Rev 1.421 27 Mar 1998 17:28:54 MIB
+ direkte absolute Positionierung und Groessen-Export von Controls und Marquee
+
+ Rev 1.420 27 Mar 1998 09:58:32 MIB
+ direkte Positionierung von Grafiken etc.
+
+ Rev 1.419 25 Mar 1998 12:13:26 MIB
+ abs.-pos. Container angefangen, Statistik-Feld
+
+ Rev 1.418 20 Mar 1998 10:46:12 MIB
+ Font-Listen in Font-Attributen
+
+ Rev 1.417 13 Mar 1998 09:29:36 MIB
+ Rahmen-Anker-Verschiebung entfernt
+
+ Rev 1.416 28 Feb 1998 07:28:58 MH
+ chg: [OW|MTF] -> UNX
+
+ Rev 1.415 27 Feb 1998 16:22:42 JP
+ ObjectDying-MessageItem umbenannt
+
+ Rev 1.414 27 Feb 1998 14:05:42 MIB
+ Auto-gebundene Rahmen
+
+ Rev 1.413 24 Feb 1998 11:31:22 MIB
+ Jetzt auch HTML_LISTING und HTML_XMP vernichtet (wegen #42029#)
+
+ Rev 1.412 20 Feb 1998 19:02:22 MA
+ header
+
+ Rev 1.411 20 Feb 1998 13:27:14 MA
+ headerfiles gewandert
+
+ Rev 1.410 17 Feb 1998 10:51:04 MIB
+ HTML-H6 -> HEADLINE6
+
+ Rev 1.409 16 Feb 1998 12:28:42 MIB
+ DokInfo-Feld jetzt auch fixed
+
+ Rev 1.408 10 Feb 1998 09:51:20 MIB
+ fix: Fuer Absatz-Abstand am Start-/Ende von Listen auch OL/UL/DL beachten
+
+ Rev 1.407 29 Jan 1998 21:34:22 JP
+ GetEndOfIcons ersetzt durch GetEndOfExtras, das auf GetEndOfRedlines mappt
+
+ Rev 1.406 23 Jan 1998 16:10:04 MA
+ includes
+
+ Rev 1.405 22 Jan 1998 19:58:26 JP
+ CTOR des SwPaM umgestellt
+
+ Rev 1.404 19 Jan 1998 16:24:02 MIB
+ Numerierungs-Umbau
+
+ Rev 1.403 17 Dec 1997 15:48:26 ER
+ cast fuer IRIX
+
+ Rev 1.402 16 Dec 1997 18:09:04 JP
+ GetSearchDelim gegen SFX_SEARCH_DELIMITER ausgetauscht
+
+ Rev 1.401 03 Dec 1997 12:42:50 JP
+ Extensions auf dem MAC zulassen
+
+ Rev 1.400 26 Nov 1997 19:09:52 MA
+ includes
+
+ Rev 1.399 25 Nov 1997 11:53:20 TJ
+ include svhtml.hxx
+
+ Rev 1.398 17 Nov 1997 10:17:28 JP
+ Umstellung Numerierung
+
+ Rev 1.397 30 Oct 1997 18:19:26 JP
+ DocumentVorlagen-Verwaltung in die Basisklasse verschoben
+
+ Rev 1.396 20 Oct 1997 12:21:42 MIB
+ fix: Kleine CSS1-Attribute aus Class hart setzen, wenn Vorlage benutzt wird.
+
+ Rev 1.395 20 Oct 1997 09:52:58 MIB
+ Nur fuer absolute positioning benoetigten Code groesstenteils auskommentiert
+
+ Rev 1.394 17 Oct 1997 13:21:30 MIB
+ page-break-xxx auch uber STYLE/CLASS und ID-Optionen
+
+ Rev 1.393 14 Oct 1997 14:36:42 JP
+ pNext vom Ring wurde privat; zugriff ueber GetNext()
+
+ Rev 1.392 14 Oct 1997 14:30:20 MIB
+ fix #44228#: ViewShell-Zerstoerung/Rekonstruktion ueber Clients
+
+ Rev 1.391 09 Oct 1997 14:40:46 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.390 06 Oct 1997 15:41:24 OM
+ Feldumstellung
+
+ Rev 1.389 06 Oct 1997 15:27:24 MIB
+ Kein NewApplet aufrufen, wenn SOLAR_JAVA nicht gesetzt
+
+ Rev 1.388 19 Sep 1997 12:20:24 MIB
+ fix: Seiten-Umbruch auch vor Tabellen temporaer setzen
+
+ Rev 1.387 19 Sep 1997 11:27:38 MIB
+ fix #41370#: HRs in Tabellen-Zellen (nicht freigeschaltet)
+
+ Rev 1.386 18 Sep 1997 16:38:12 JP
+ Continue: beim Einfuegen von nur einem Node nicht falsch zusammenfassen
+
+ Rev 1.385 18 Sep 1997 09:18:34 JP
+ Teilfix fuer Bug 42487
+
+ Rev 1.384 16 Sep 1997 17:23:52 MIB
+ abs. Positioning fuer Absatz-Tags
+
+ Rev 1.383 16 Sep 1997 14:55:36 MIB
+ ITEMID_BOXINFOITEM (voreubergendend) definieren
+
+ Rev 1.382 16 Sep 1997 11:00:44 MIB
+ Kopf-/Fusszeilen ohne Moven von Nodes, autom. Beenden von Bereichen/Rahmen
+
+ Rev 1.381 12 Sep 1997 11:51:20 MIB
+ fix #41136#: &(xxx);-Makros
+
+ Rev 1.380 10 Sep 1997 11:00:24 MIB
+ HTMLReader::IsFormat() wieder raus
+
+ Rev 1.379 09 Sep 1997 14:09:48 MIB
+ Ueberall Browse-View-Breite statt Seitenbreite verwenden
+
+ Rev 1.378 08 Sep 1997 17:41:40 MIB
+ Verankerung von AUTO_CNTNT-Rahmen nicht mehr verschieben
+
+ Rev 1.377 04 Sep 1997 12:36:54 JP
+ Umstellungen fuer FilterDetection im SwModule und SwDLL
+
+ Rev 1.376 02 Sep 1997 20:45:32 OS
+ Header
+
+ Rev 1.375 02 Sep 1997 11:12:08 MIB
+ fix #42192#: Attribute schnellstmoeglich setzen
+
+ Rev 1.374 01 Sep 1997 11:54:46 MIB
+ fix #42679#: Im Titel nur auf </TITLE> achten, keine Schleife mehr.
+
+ Rev 1.373 29 Aug 1997 16:50:20 OS
+ DLL-Umstellung
+
+ Rev 1.372 15 Aug 1997 12:47:46 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.371 14 Aug 1997 13:38:10 MA
+ #42534# Error in NextToken abfragen und State setzen
+
+ Rev 1.370 12 Aug 1997 13:44:22 OS
+ Header-Umstellung
+
+ Rev 1.369 11 Aug 1997 14:06:24 OM
+ Headerfile-Umstellung
+
+ Rev 1.368 07 Aug 1997 13:15:18 MIB
+ fix #42192#: Zeichen-Attribute moeglicht frueh setzen. Noch nicht freigeschaltet
+
+ Rev 1.367 04 Aug 1997 13:53:42 MIB
+ aboslute psoitioning (fuer fast alle Zeichen-Attribute/-Vorlagen)
+
+ Rev 1.366 31 Jul 1997 10:44:44 MIB
+ DIV-Stack weg
+
+ Rev 1.365 25 Jul 1997 13:00:38 MIB
+ fix #40408#: <NOEMBED>-Tag
+
+ Rev 1.364 18 Jul 1997 10:54:32 MIB
+ fix #40951#: In Reschedule/DocDetected absichtlich geaenderte URLs beachten
+
+ Rev 1.363 16 Jul 1997 18:38:40 MIB
+ non-pro: Asserts zur Call-Stack-Kontrolle, kein Assert f. frueher gesetze Attrs
+
+ Rev 1.362 10 Jul 1997 16:44:46 MIB
+ fix #41379#: Keine Absatz-Attribute fuer leere Absaetze (auch hinter Tabellen)
+
+ Rev 1.361 10 Jul 1997 12:02:50 MIB
+ fix #41547#: Keine Tabellen in Tabellen einfuegen
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
new file mode 100644
index 000000000000..929243d52c51
--- /dev/null
+++ b/sw/source/filter/html/swhtml.hxx
@@ -0,0 +1,1068 @@
+/*************************************************************************
+ *
+ * $RCSfile: swhtml.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _SWHTML_HXX
+#define _SWHTML_HXX
+
+#if !defined(_SVSTDARR_XUB_STRLEN_DECL) || !defined(_SVSTDARR_LONGS_DECL) || \
+ !defined(_SVSTDARR_USHORTS_DECL) || !defined(_SVSTDARR_STRINGSDTOR_DECL)
+#ifndef _SVSTDARR_XUB_STRLEN_DECL
+#define _SVSTDARR_XUB_STRLEN
+#endif
+#ifndef _SVSTDARR_LONGS_DECL
+#define _SVSTDARR_LONGS
+#endif
+#ifndef _SVSTDARR_USHORTS_DECL
+#define _SVSTDARR_USHORTS
+#endif
+#ifndef _SVSTDARR_STRINGSDTOR_DECL
+#define _SVSTDARR_STRINGSDTOR
+#endif
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _SFXHTML_HXX //autogen
+#include <sfx2/sfxhtml.hxx>
+#endif
+
+#ifndef _SFXMACITEM_HXX //autogen
+#include <svtools/macitem.hxx>
+#endif
+
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+
+#ifndef _SVX_SVXENUM_HXX //autogen
+#include <svx/svxenum.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+#include <com/sun/star/form/XFormComponent.hpp>
+#endif
+
+#include "doc.hxx"
+#include "pam.hxx"
+#include "calbck.hxx"
+
+#include "htmlvsh.hxx"
+
+class SfxMedium;
+class SdrObject;
+class SvxMacroTableDtor;
+class SvStringsDtor;
+
+class ViewShell;
+
+class SwStartNode;
+class SwTxtNode;
+class SwFmtColl;
+class SwTxtFmtColl;
+class SwFmtFld;
+class SwFmtINetFmt;
+class SwField;
+class _HTMLTableContext;
+class SwHTMLForm_Impl;
+class SwHTMLApplet_Impl;
+struct SwHTMLFootEndNote_Impl;
+class HTMLTableCnts;
+struct SwPendingStack;
+class SvxCSS1PropertyInfo;
+
+#define HTML_PARSPACE (MM50)
+
+#define HTML_DFLT_IMG_WIDTH (MM50*4)
+#define HTML_DFLT_IMG_HEIGHT (MM50*2)
+
+// ein par Sachen, die man oefter mal braucht
+extern HTMLOptionEnum __FAR_DATA aHTMLPAlignTable[];
+extern HTMLOptionEnum __FAR_DATA aHTMLImgHAlignTable[];
+extern HTMLOptionEnum __FAR_DATA aHTMLImgVAlignTable[];
+
+
+// der Attribut Stack:
+
+class _HTMLAttr;
+typedef _HTMLAttr *_HTMLAttrPtr;
+SV_DECL_PTRARR( _HTMLAttrs, _HTMLAttrPtr, 5, 5 )
+
+class _HTMLAttr
+{
+ friend class SwHTMLParser;
+ friend class _CellSaveStruct;
+
+ SwNodeIndex nSttPara, nEndPara;
+ xub_StrLen nSttCntnt, nEndCntnt;
+ sal_Bool bInsAtStart : 1;
+ sal_Bool bLikePara : 1; // Attribut ueber dem gesamten Absatz setzen
+ sal_Bool bValid : 1; // ist das Attribut gueltig?
+
+ SfxPoolItem* pItem;
+ sal_uInt16 nCount; // Anzahl noch zu schliessender Attrs mit einem Wert
+ _HTMLAttr *pNext; // noch zu schliessene Attrs mit unterschiedl. Werten
+ _HTMLAttr *pPrev; // bereits geschlossene aber noch nicht gesetze Attrs
+ _HTMLAttr **ppHead; // der Listenkopf
+
+ _HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
+ _HTMLAttr **pHd=0 );
+
+ _HTMLAttr( const _HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
+ xub_StrLen nEndCnt, _HTMLAttr **pHd );
+
+public:
+
+ ~_HTMLAttr();
+
+ _HTMLAttr *Clone( const SwNodeIndex& rEndPara, xub_StrLen nEndCnt ) const;
+ void Reset( const SwNodeIndex& rSttPara, xub_StrLen nSttCnt,
+ _HTMLAttr **pHd );
+ inline void SetStart( const SwPosition& rPos );
+
+ sal_uInt32 GetSttParaIdx() const { return nSttPara.GetIndex(); }
+ sal_uInt32 GetEndParaIdx() const { return nEndPara.GetIndex(); }
+
+ const SwNodeIndex& GetSttPara() const { return nSttPara; }
+ const SwNodeIndex& GetEndPara() const { return nEndPara; }
+
+ xub_StrLen GetSttCnt() const { return nSttCntnt; }
+ xub_StrLen GetEndCnt() const { return nEndCntnt; }
+
+ sal_Bool IsLikePara() const { return bLikePara; }
+ void SetLikePara( sal_Bool bPara=sal_True ) { bLikePara = sal_True; }
+
+ SfxPoolItem& GetItem() { return *pItem; }
+ const SfxPoolItem& GetItem() const { return *pItem; }
+
+ _HTMLAttr *GetNext() const { return pNext; }
+ void InsertNext( _HTMLAttr *pNxt ) { pNext = pNxt; }
+
+ _HTMLAttr *GetPrev() const { return pPrev; }
+ void InsertPrev( _HTMLAttr *pPrv );
+ void ClearPrev() { pPrev = 0; }
+
+ void SetHead( _HTMLAttr **ppHd ) { ppHead = ppHd; }
+
+ // Beim Setzen von Attributen aus Vorlagen kann es passieren,
+ // dass Attribute doch nicht mehr gesetzt werden sollen. Die zu loeschen
+ // waere sehr aufwendig, da man nicht so genau weiss, wo sie eingekettet
+ // sind. Sie werden deshalb einfach invalidiert und erst beim naechsten
+ // _SetAttr() geloescht.
+ void Invalidate() { bValid = sal_False; }
+ sal_Bool IsValid() const { return bValid; }
+};
+
+// Tabelle der Attribute: Hier ist die Reihenfolge wichtig: Die Attribute
+// vorne in der Tabelle werden in EndAllAttrs auch zuerst gesetzt.
+struct _HTMLAttrTable
+{
+ _HTMLAttr
+ *pKeep, // ::com::sun::star::frame::Frame-Attribure
+ *pBox,
+ *pBrush,
+ *pBreak,
+ *pPageDesc,
+
+ *pLRSpace, // Absatz-Attribute
+ *pULSpace,
+ *pLineSpacing,
+ *pAdjust,
+ *pDropCap,
+ *pSplit,
+ *pWidows,
+ *pOrphans,
+
+ *pCharFmts, // Text-Attribute
+ *pINetFmt,
+
+ *pBold, // Zeichen-Attribute
+ *pItalic,
+ *pStrike,
+ *pUnderline,
+ *pBlink,
+ *pFont,
+ *pFontHeight,
+ *pFontColor,
+ *pEscapement,
+ *pCaseMap,
+ *pKerning, // (nur fuer SPACER)
+ *pCharBrush // Zeichen-Hintergrund
+ ;
+};
+
+class _HTMLAttrContext_SaveDoc;
+
+enum SwHTMLAppendMode {
+ AM_NORMAL, // keine Absatz-Abstand-Behandlung
+ AM_NOSPACE, // Abstand hart auf 0cm setzen
+ AM_SPACE, // Abstand hart auf 0.5cm setzen
+ AM_SOFTNOSPACE, // Abstand nicht setzen aber 0cm merken
+ AM_NONE // gar kein Append
+};
+
+class _HTMLAttrContext
+{
+ _HTMLAttrs aAttrs; // die in dem Kontext gestarteten Attribute
+
+ String aClass; // die Klasse des Kontexts
+
+ _HTMLAttrContext_SaveDoc *pSaveDocContext;
+ SfxItemSet *pFrmItemSet;
+
+ sal_uInt16 nToken; // das Token, zu dem der Kontext gehoehrt
+
+ sal_uInt16 nTxtFmtColl; // eine in dem Kontext begonnene Vorlage oder 0
+
+ sal_uInt16 nLeftMargin; // ein veraenderter linker Rand
+ sal_uInt16 nRightMargin; // ein veraenderter rechter Rand
+ sal_uInt16 nFirstLineIndent; // ein veraenderter Erstzeilen-Einzug
+
+ sal_uInt16 nUpperSpace;
+ sal_uInt16 nLowerSpace;
+
+ SwHTMLAppendMode eAppend;
+
+ sal_Bool bLRSpaceChanged : 1;// linker/rechtr Rand, Einzug veraendert?
+ sal_Bool bULSpaceChanged : 1;// oberer/unterer Rand veraendert?
+ sal_Bool bDfltTxtFmtColl : 1;// nTxtFmtColl ist nur ein default
+ sal_Bool bSpansSection : 1; // Der Kontext spannt eine SwSection auf
+ sal_Bool bPopStack : 1; // Oberhalb liegende Stack-Elemente entf.
+ sal_Bool bFinishPREListingXMP : 1;
+ sal_Bool bRestartPRE : 1;
+ sal_Bool bRestartXMP : 1;
+ sal_Bool bRestartListing : 1;
+
+public:
+ void ClearSaveDocContext();
+
+ _HTMLAttrContext( sal_uInt16 nTokn, sal_uInt16 nPoolId, const String& rClass,
+ sal_Bool bDfltColl=sal_False ) :
+ aClass( rClass ),
+ pSaveDocContext( 0 ), pFrmItemSet( 0 ),
+ nToken( nTokn ), nTxtFmtColl( nPoolId ),
+ nLeftMargin( 0 ), nRightMargin( 0 ), nFirstLineIndent( 0 ),
+ nUpperSpace( 0 ), nLowerSpace( 0 ),
+ eAppend( AM_NONE ),
+ bLRSpaceChanged( sal_False ), bULSpaceChanged( sal_False ),
+ bSpansSection( sal_False ), bPopStack( sal_False ),
+ bFinishPREListingXMP( sal_False ),
+ bRestartPRE( sal_False ), bRestartXMP( sal_False ), bRestartListing( sal_False ),
+ bDfltTxtFmtColl( bDfltColl )
+ {}
+
+ _HTMLAttrContext( sal_uInt16 nTokn ) :
+ pSaveDocContext( 0 ), pFrmItemSet( 0 ),
+ nToken( nTokn ), nTxtFmtColl( 0 ),
+ nLeftMargin( 0 ), nRightMargin( 0 ), nFirstLineIndent( 0 ),
+ nUpperSpace( 0 ), nLowerSpace( 0 ),
+ eAppend( AM_NONE ),
+ bLRSpaceChanged( sal_False ), bULSpaceChanged( sal_False ),
+ bSpansSection( sal_False ), bPopStack( sal_False ),
+ bFinishPREListingXMP( sal_False ),
+ bRestartPRE( sal_False ), bRestartXMP( sal_False ), bRestartListing( sal_False ),
+ bDfltTxtFmtColl( sal_False )
+ {}
+
+ ~_HTMLAttrContext() { ClearSaveDocContext(); delete pFrmItemSet; }
+
+ sal_uInt16 GetToken() const { return nToken; }
+
+ sal_uInt16 GetTxtFmtColl() const { return bDfltTxtFmtColl ? 0 : nTxtFmtColl; }
+ sal_uInt16 GetDfltTxtFmtColl() const { return bDfltTxtFmtColl ? nTxtFmtColl : 0; }
+
+ const String& GetClass() const { return aClass; }
+
+ inline void SetMargins( sal_uInt16 nLeft, sal_uInt16 nRight, short nIndent );
+
+ inline sal_Bool IsLRSpaceChanged() const { return bLRSpaceChanged; }
+ inline void GetMargins( sal_uInt16& nLeft, sal_uInt16& nRight,
+ short &nIndent ) const;
+
+ inline void SetULSpace( sal_uInt16 nUpper, sal_uInt16 nLower );
+ inline sal_Bool IsULSpaceChanged() const { return bULSpaceChanged; }
+ inline void GetULSpace( sal_uInt16& rUpper, sal_uInt16& rLower ) const;
+
+ sal_Bool HasAttrs() const { return aAttrs.Count() != 0; }
+ const _HTMLAttrs& GetAttrs() const { return aAttrs; }
+ _HTMLAttrs& GetAttrs() { return aAttrs; }
+
+ void SetSpansSection( sal_Bool bSet ) { bSpansSection = bSet; }
+ sal_Bool GetSpansSection() const { return bSpansSection; }
+
+ void SetPopStack( sal_Bool bSet ) { bPopStack = bSet; }
+ sal_Bool GetPopStack() const { return bPopStack; }
+
+ sal_Bool HasSaveDocContext() const { return pSaveDocContext!=0; }
+ _HTMLAttrContext_SaveDoc *GetSaveDocContext( sal_Bool bCreate=sal_False );
+
+ const SfxItemSet *GetFrmItemSet() const { return pFrmItemSet; }
+ SfxItemSet *GetFrmItemSet( SwDoc *pCreateDoc );
+
+ void SetFinishPREListingXMP( sal_Bool bSet ) { bFinishPREListingXMP = bSet; }
+ sal_Bool IsFinishPREListingXMP() const { return bFinishPREListingXMP; }
+
+ void SetRestartPRE( sal_Bool bSet ) { bRestartPRE = bSet; }
+ sal_Bool IsRestartPRE() const { return bRestartPRE; }
+
+ void SetRestartXMP( sal_Bool bSet ) { bRestartXMP = bSet; }
+ sal_Bool IsRestartXMP() const { return bRestartXMP; }
+
+ void SetRestartListing( sal_Bool bSet ) { bRestartListing = bSet; }
+ sal_Bool IsRestartListing() const { return bRestartListing; }
+
+ void SetAppendMode( SwHTMLAppendMode eMode=AM_NORMAL ) { eAppend = eMode; }
+ SwHTMLAppendMode GetAppendMode() const { return eAppend; }
+};
+
+typedef _HTMLAttrContext *_HTMLAttrContextPtr;
+SV_DECL_PTRARR( _HTMLAttrContexts, _HTMLAttrContextPtr, 5, 5 )
+
+class HTMLTable;
+class SwCSS1Parser;
+class SwHTMLNumRuleInfo;
+
+typedef ImageMap *ImageMapPtr;
+SV_DECL_PTRARR_DEL( ImageMaps, ImageMapPtr, 1, 1 )
+typedef SwFrmFmt *SwFrmFmtPtr;
+SV_DECL_PTRARR( SwHTMLFrmFmts, SwFrmFmtPtr, 2, 2 )
+
+#define HTML_CNTXT_PROTECT_STACK 0x0001
+#define HTML_CNTXT_STRIP_PARA 0x0002
+#define HTML_CNTXT_KEEP_NUMRULE 0x0004
+#define HTML_CNTXT_HEADER_DIST 0x0008
+#define HTML_CNTXT_FOOTER_DIST 0x0010
+#define HTML_CNTXT_KEEP_ATTRS 0x0020
+
+#define CONTEXT_FLAGS_ABSPOS \
+ (HTML_CNTXT_PROTECT_STACK | \
+ HTML_CNTXT_STRIP_PARA)
+
+#define HTML_FF_BOX 0x0001
+#define HTML_FF_BACKGROUND 0x0002
+#define HTML_FF_PADDING 0x0004
+
+class SwHTMLParser : public SfxHTMLParser, public SwClient
+{
+ friend class _SectionSaveStruct;
+ friend class _CellSaveStruct;
+ friend class _CaptionSaveStruct;
+
+ String aPathToFile;
+ String sBaseURL;
+ String sSaveBaseURL;
+ String aBasicLib;
+ String aBasicModule;
+ String aScriptSource; // Inhalt des aktuellen Script-Blocks
+ String aScriptType; // Type des gelesenen Scripts (StarBasic/VB/JAVA)
+ String aScriptURL; // URL eines Scripts
+ String aStyleSource; // Inhalt des aktuellen Style-Sheets
+ String aContents; // Text des akteullen Marquee, Feldes etc.
+ String sTitle;
+ String aUnknownToken; // ein gestartetes unbekanntes Token
+ String aBulletGrfs[MAXLEVEL];
+ String sJmpMark;
+
+ SvUShorts aBaseFontStack; // Stack fuer <BASEFONT>
+ // Bit 0-2: Fontgroesse (1-7)
+ SvUShorts aFontStack; // Stack fuer <FONT>, <BIG>, <SMALL>
+ // Bit 0-2: Fontgroesse (1-7)
+ // Bit 15: Fontfarbe wurde gesetzt
+
+ _HTMLAttrs aSetAttrTab;// "geschlossene", noch nicht gesetzte Attr.
+ _HTMLAttrs aParaAttrs; // vorlauefige Absatz-Attribute
+ _HTMLAttrTable aAttrTab; // "offene" Attribute
+ _HTMLAttrContexts aContexts;// der aktuelle Attribut/Token-Kontext
+ SwHTMLFrmFmts aMoveFlyFrms;// Fly-Frames, deren Anker verschoben wird
+ SvXub_StrLens aMoveFlyCnts;// und deren Content-Positionen
+
+ SwHTMLApplet_Impl *pAppletImpl; // das aktuelle Applet
+
+ SwCSS1Parser *pCSS1Parser; // der Style-Sheet-Parser
+ SwHTMLNumRuleInfo *pNumRuleInfo;
+ SwPendingStack *pPendStack;
+
+ SwDoc *pDoc;
+ SwPaM *pPam; // SwPosition duerfte doch reichen, oder ??
+ ViewShell *pActionViewShell; // ViewShell, an der das StartAction
+ // gerufen wurde.
+ SwNodeIndex *pSttNdIdx;
+
+ HTMLTable *pTable; // die aktuelle "auesserste" Tabelle
+ SwHTMLForm_Impl *pFormImpl;// die aktuelle Form
+ SdrObject *pMarquee; // aktuelles Marquee
+ SwField *pField; // aktuelles Feld
+ ImageMap *pImageMap; // aktuelle Image-Map
+ ImageMaps *pImageMaps;// alle gelesenen Image-Maps
+ SwHTMLFootEndNote_Impl *pFootEndNoteImpl;
+
+ Size aHTMLPageSize; // die Seitengroesse der HTML-Vorlage
+
+ sal_uInt32 aFontHeights[7]; // die Font-Hoehen 1-7
+ sal_uInt32 nScriptStartLineNr; // Zeilennummer eines Script-Blocks
+
+ sal_uInt16 nBaseFontStMin; //
+ sal_uInt16 nFontStMin; //
+ sal_uInt16 nDefListDeep; //
+ sal_uInt16 nFontStHeadStart; // Elemente im Font-Stack bei <Hn>
+ sal_uInt16 nSBModuleCnt; // Zaehler fuer Basic-Module
+ sal_uInt16 nMissingImgMaps; // Wie viele Image-Maps fehlen noch?
+ sal_uInt16 nParaCnt;
+ sal_uInt16 nContextStMin; // Untergrenze fuer PopContext
+ sal_uInt16 nContextStAttrMin; // Untergrenze fuer Attributierung
+ sal_uInt16 nSelectEntryCnt; // Anzahl der Eintraege der akt. Listbox
+ sal_uInt16 nOpenParaToken; // ein geoeffnetes Absatz-Element
+
+ enum JumpToMarks { JUMPTO_NONE, JUMPTO_MARK, JUMPTO_TABLE, JUMPTO_FRAME,
+ JUMPTO_REGION, JUMPTO_GRAPHIC } eJumpTo;
+
+#ifndef PRODUCT
+ sal_uInt16 nContinue; // Tiefe der Continue-Aufrufe
+#endif
+
+ SvxAdjust eParaAdjust; // Ausrichtung des aktuellen Absatz
+ HTMLScriptLanguage eScriptLang; // die aktuelle Script-Language
+
+ sal_Bool bOldIsHTMLMode : 1; // War's mal ein HTML-Dokument?
+
+ sal_Bool bDocInitalized : 1; // Dokument bzw. Shell wurden initialisiert
+ // Flag um doppeltes init durch Rekursion
+ // zu verhindern.
+ sal_Bool bViewCreated : 1; // die View wurde schon erzeugt (asynchron)
+ sal_Bool bSetCrsr : 1; // Crsr wieder auf den Anfang setzen
+ sal_Bool bSetModEnabled : 1;
+
+ sal_Bool bInFloatingFrame : 1; // Wir sind in einen Floating ::com::sun::star::frame::Frame
+ sal_Bool bInField : 1;
+ sal_Bool bKeepUnknown : 1; // unbekannte/nicht unterstuetze Tokens beh.
+ // 8
+ sal_Bool bCallNextToken : 1; // In Tabellen: NextToken in jedem Fall rufen
+ sal_Bool bIgnoreRawData : 1; // Inhalt eines Scripts/Styles ignorieren.
+ sal_Bool bLBEntrySelected : 1; // Ist der aktuelle Listbox-Eintrag selekt.
+ sal_Bool bTAIgnoreNewPara : 1; // naechstes LF in TextArea ignorieren?
+ sal_Bool bFixMarqueeWidth : 1; // Groesse einer Laufschrift anpassen?
+ sal_Bool bFixMarqueeHeight : 1;
+
+ sal_Bool bUpperSpace : 1; // obererer Absatz-Abstand wird benoetigt
+ sal_Bool bNoParSpace : 1;
+ // 16
+
+ sal_Bool bAnyStarBasic : 1; // gibt es ueberhaupt ein StarBasic-Modul
+ sal_Bool bInNoEmbed : 1; // Wir sind in einem NOEMBED-Bereich
+
+ sal_Bool bInTitle : 1; // Wir sind im Titel
+
+ sal_Bool bChkJumpMark : 1; // springe ggfs. zu einem vorgegebenem Mark
+ sal_Bool bUpdateDocStat : 1;
+ sal_Bool bFixSelectWidth : 1; // Breite eines Selects neu setzen?
+ sal_Bool bFixSelectHeight : 1; // Breite eines Selects neu setzen?
+ sal_Bool bTextArea : 1;
+ // 24
+ sal_Bool bSelect : 1;
+ sal_Bool bInFootEndNoteAnchor : 1;
+ sal_Bool bInFootEndNoteSymbol : 1;
+ sal_Bool bDataAvailableLinkSet : 1;
+
+ SvRefBaseRef aLoadEnv;
+
+ void DeleteFormImpl();
+
+ void DocumentDetected();
+ void Show();
+ void ShowStatline();
+ ViewShell *CallStartAction( ViewShell *pVSh = 0, sal_Bool bChkPtr = sal_True );
+ ViewShell *CallEndAction( sal_Bool bChkAction = sal_False, sal_Bool bChkPtr = sal_True );
+ ViewShell *CheckActionViewShell();
+
+ inline void GetSaveAndSetOwnBaseURL();
+ inline void SetSaveBaseURL();
+
+ // Attribute am Dok setzen
+ void _SetAttr( sal_Bool bChkEnd, sal_Bool bBeforeTable, _HTMLAttrs *pPostIts );
+ inline void SetAttr( sal_Bool bChkEnd = sal_True, sal_Bool bBeforeTable = sal_False,
+ _HTMLAttrs *pPostIts = 0 )
+ {
+ if( aSetAttrTab.Count() || aMoveFlyFrms.Count() )
+ _SetAttr( bChkEnd, bBeforeTable, pPostIts );
+ }
+
+ _HTMLAttr **GetAttrTabEntry( sal_uInt16 nWhich );
+
+ // Einen neuen Textknoten an PaM-Position anlegen
+ sal_Bool AppendTxtNode( SwHTMLAppendMode eMode=AM_NORMAL, sal_Bool bUpdateNum=sal_True );
+ void AddParSpace();
+
+ // Ein Attribut beginnen/beenden
+ // ppDepAttr gibt einen Attribut-Tabellen-Eintrag an, dessen Attribute
+ // gesetzt sein muessen, bevor das Attribut beendet werden darf
+ void NewAttr( _HTMLAttr **ppAttr, const SfxPoolItem& rItem );
+ void EndAttr( _HTMLAttr *pAttr, _HTMLAttr **ppDepAttr=0,
+ sal_Bool bChkEmpty=sal_True );
+ void DeleteAttr( _HTMLAttr* pAttr );
+
+ void EndContextAttrs( _HTMLAttrContext *pContext, sal_Bool bRemove=sal_False );
+ void SaveAttrTab( _HTMLAttrTable& rNewAttrTab );
+ void SplitAttrTab( const SwPosition& rNewPos );
+ void SplitAttrTab( _HTMLAttrTable& rNewAttrTab, sal_Bool bMoveEndBack = sal_True );
+ void RestoreAttrTab( const _HTMLAttrTable& rNewAttrTab,
+ sal_Bool bSetNewStart = sal_False );
+ void InsertAttr( const SfxPoolItem& rItem, sal_Bool bLikePara = sal_False,
+ sal_Bool bInsAtStart=sal_False );
+ void InsertAttrs( _HTMLAttrs& rAttrs );
+
+ sal_Bool DoPositioning( SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ _HTMLAttrContext *pContext );
+ sal_Bool CreateContainer( const String& rClass, SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo,
+ _HTMLAttrContext *pContext );
+ sal_Bool EndSection( sal_Bool bLFStripped=sal_False );
+
+ void InsertAttrs( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
+ _HTMLAttrContext *pContext, sal_Bool bCharLvl=sal_False );
+ void InsertAttr( _HTMLAttr **ppAttr, const SfxPoolItem & rItem,
+ _HTMLAttrContext *pCntxt );
+ void SplitPREListingXMP( _HTMLAttrContext *pCntxt );
+ void FixHeaderFooterDistance( sal_Bool bHeader, const SwPosition *pOldPos );
+
+ void EndContext( _HTMLAttrContext *pContext );
+ void ClearContext( _HTMLAttrContext *pContext );
+
+ const SwFmtColl *GetCurrFmtColl() const;
+
+ const SwTwips GetCurrentBrowseWidth() /* const */;
+
+ SwHTMLNumRuleInfo& GetNumInfo() { return *pNumRuleInfo; }
+ void SetNodeNum( sal_uInt8 nLevel );
+#ifndef NUM_RELSPACE
+ void UpdateNumRuleInTable();
+#endif
+
+ // Verwalten von Absatz-Vorlagen
+
+ // die Vorlagen auf dem Stack bzw. deren Attribute setzen
+ void SetTxtCollAttrs( _HTMLAttrContext *pContext = 0 );
+
+ // die Attribute eine Vorlage zu dem Item-Set hinzufuegen
+ void AddFormatAttrs( SfxItemSet& rItemSet, const SwFmt& rFmt ) const;
+
+ // die Attribute einer Vorlage aus dem Item-Set entfernen
+ void RemoveFormatAttrs( SfxItemSet& rItemSet, const SwFmt& rFmt ) const;
+
+ void InsertParaAttrs( const SfxItemSet& rItemSet );
+
+ // Verwalten des Attribut-Kontexts
+
+ // aktuellen Kontext merken
+ inline void PushContext( _HTMLAttrContext *pCntxt );
+
+ // den obersten/spezifizierten Kontext holen, aber nicht ausserhalb
+ // des Kontexts mit Token nLimit suchen. Wenn bRemove gesetzt ist,
+ // wird er entfernt
+ _HTMLAttrContext *PopContext( sal_uInt16 nToken=0, sal_uInt16 nLimit=0,
+ sal_Bool bRemove=sal_True );
+ inline const _HTMLAttrContext *GetTopContext() const;
+
+ sal_Bool GetMarginsFromContext( sal_uInt16 &nLeft, sal_uInt16 &nRight, short& nIndent,
+ sal_Bool bIgnoreCurrent=sal_False ) const;
+ sal_Bool GetMarginsFromContextWithNumBul( sal_uInt16 &nLeft, sal_uInt16 &nRight,
+ short& nIndent ) const;
+ void GetULSpaceFromContext( sal_uInt16 &rUpper, sal_uInt16 &rLower ) const;
+
+
+ void MovePageDescAttrs( SwNode *pSrcNd, sal_uInt32 nDestIdx, sal_Bool bFmtBreak );
+
+ // Behandlung von Tags auf Absatz-Ebene
+
+ // <P> und <H1> bis <H6>
+ void NewPara();
+ void EndPara( sal_Bool bReal = sal_False );
+ void NewHeading( int nToken );
+ void EndHeading();
+
+ // <ADDRESS>, <BLOCKQUOTE> und <PRE>
+ void NewTxtFmtColl( int nToken, sal_uInt16 nPoolId );
+ void EndTxtFmtColl( int nToken );
+
+ // <DIV> und <CENTER>
+ void NewDivision( int nToken );
+ void EndDivision( int nToken );
+
+ // Fly-Frames einfuegen/verlassen
+ void InsertFlyFrame( const SfxItemSet& rItemSet, _HTMLAttrContext *pCntxt,
+ const String& rId, sal_uInt16 nFlags );
+
+ void SaveDocContext( _HTMLAttrContext *pCntxt, sal_uInt16 nFlags,
+ const SwPosition *pNewPos );
+ void RestoreDocContext( _HTMLAttrContext *pCntxt );
+
+ // alle durch <DIV> aufgespannten Bereiche verlassen
+ sal_Bool EndSections( sal_Bool bLFStripped );
+
+ // <MULTICOL>
+ void NewMultiCol();
+ void EndMultiCol();
+
+ // <MARQUEE>
+ void NewMarquee( HTMLTable *pCurTable=0 );
+ void EndMarquee();
+ void InsertMarqueeText();
+
+ // Behandluung von Listen
+
+ // Numerierungs <OL> und Aufzaehlungs-Listen <UL> mit <LI>
+ void NewNumBulList( int nToken );
+ void EndNumBulList( int nToken=0 );
+ void NewNumBulListItem( int nToken );
+ void EndNumBulListItem( int nToken=0, sal_Bool bSetColl=sal_True,
+ sal_Bool bLastPara=sal_False );
+
+ // Definitions-Listen <DL> mit <DD>, <DT>
+ void NewDefList();
+ void EndDefList();
+ void NewDefListItem( int nToken );
+ void EndDefListItem( int nToken=0, sal_Bool bSetColl=sal_True,
+ sal_Bool bLastPara=sal_False );
+
+
+ // Behandlung von Tags auf Zeichen-Ebene
+
+ // Tags wie <B>, <I> etc behandeln, die ein bestimmtes Attribut
+ // an und ausschalten, oder die wie SPAN nur Attribute aus Styles holen
+ void NewStdAttr( int nToken );
+ void NewStdAttr( int nToken, _HTMLAttr **ppAttr,
+ const SfxPoolItem & rItem );
+ void EndTag( int nToken );
+
+ // Font-Attribute behandeln
+ void NewBasefontAttr(); // fuer <BASEFONT>
+ void EndBasefontAttr();
+ void NewFontAttr( int nToken ); // fuer <FONT>, <BIG> und <SMALL>
+ void EndFontAttr( int nToken );
+
+ // Tags, die durch Zeichenvorlagen realisiert werden
+ void NewCharFmt( int nToken );
+
+ // <SDFIELD>
+public:
+ static sal_uInt16 GetNumType( const String& rStr, sal_uInt16 eDfltType );
+private:
+ void NewField();
+ void EndField();
+ void InsertFieldText();
+
+ // <SPACER>
+ void InsertSpacer();
+
+ // Einfuegen von Grafiken, Plugins und Applets
+
+ // Image-Maps suchen und mit Grafik-Nodes verbinden
+ ImageMap *FindImageMap( const String& rURL ) const;
+ void ConnectImageMaps();
+
+ // Verankerung eines Fly-Frames bestimmen und entsprechende Attribute
+ // in den Attrset setzen (htmlgrin.cxx)
+ void SetAnchorAndAdjustment( SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ const SfxItemSet &rItemSet,
+ const SvxCSS1PropertyInfo &rPropInfo,
+ SfxItemSet& rFrmSet );
+ void SetAnchorAndAdjustment( SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ SfxItemSet& rFrmSet,
+ sal_Bool bDontAppend=sal_False );
+ void SetAnchorAndAdjustment( const SfxItemSet &rItemSet,
+ const SvxCSS1PropertyInfo &rPropInfo,
+ SfxItemSet &rFrmItemSet );
+
+ void SetFrmFmtAttrs( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
+ sal_uInt16 nFlags, SfxItemSet &rFrmItemSet );
+
+ // Frames anlegen und Auto-gebundene Rahmen registrieren
+ void RegisterFlyFrm( SwFrmFmt *pFlyFrm );
+
+ // Die Groesse des Fly-Frames an die Vorgaben und Gegebenheiten anpassen
+ // (nicht fuer Grafiken, deshalb htmlplug.cxx)
+ void SetFixSize( const Size& rPixSize, const Size& rTwipDfltSize,
+ sal_Bool bPrcWidth, sal_Bool bPrcHeight,
+ SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
+ SfxItemSet& rFlyItemSet );
+ void SetVarSize( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
+ SfxItemSet& rFlyItemSet, SwTwips nDfltWidth=MINLAY,
+ sal_uInt8 nDltPrcWidth=0 );
+ void SetSpace( const Size& rPixSpace, SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo, SfxItemSet& rFlyItemSet );
+
+ sal_uInt16 IncGrfsThatResizeTable();
+
+ void GetDefaultScriptType( ScriptType& rType,
+ String& rTypeStr ) const;
+
+ // die eigentlichen Einfuege-Methoden fuer <IMG>, <EMBED> und <APPLET>
+ // und <PARAM>
+ void InsertImage(); // htmlgrin.cxx
+ void InsertEmbed(); // htmlplug.cxx
+
+ void InsertApplet(); // htmlplug.cxx
+ void EndApplet(); // CommandLine mit Applet verkn. (htmlplug.cxx)
+ void InsertParam(); // htmlplug.cxx
+
+ void InsertFloatingFrame();
+ void EndFloatingFrame() { bInFloatingFrame = sal_False; }
+
+ // <BODY>-Tag auswerten: Hintergrund-Grafiken und -Farben setzen (htmlgrin.cxx)
+ void InsertBodyOptions();
+
+
+ // Einfuegen von Links und ::com::sun::star::text::Bookmarks (htmlgrin.cxx)
+
+ // <A>-Tag auswerten: einen Link bzw. eine ::com::sun::star::text::Bookmark einfuegen
+ void NewAnchor();
+ void EndAnchor();
+
+ // eine ::com::sun::star::text::Bookmark einfuegen
+ void InsertBookmark( const String& rName );
+
+
+ void InsertCommentText( const sal_Char *pTag = 0 );
+ void InsertComment( const String& rName, const sal_Char *pTag = 0 );
+
+ // sind im aktuellen Absatz ::com::sun::star::text::Bookmarks vorhanden?
+ sal_Bool HasCurrentParaBookmarks( sal_Bool bIgnoreStack=sal_False ) const;
+
+
+ // Einfuegen von Script/Basic-Elementen
+
+ // das zueletzt gelsene Basic-Modul parsen (htmlbas.cxx)
+ void NewScript();
+ void EndScript();
+
+ void AddScriptSource();
+
+ // ein Event in die SFX-Konfiguation eintragen (htmlbas.cxx)
+ void InsertBasicDocEvent( sal_uInt16 nEvent, const String& rName,
+ ScriptType eScrType, const String& rScrType );
+
+ // ein Event an ein VC-Control anhaengen (htmlform.cxx)
+ void InsertBasicCtrlEvent( sal_uInt16 nEvent, const String& rName );
+
+ // Einfuegen von Styles
+
+ // <STYLE>
+ void NewStyle();
+ void EndStyle();
+
+ inline sal_Bool HasStyleOptions( const String &rStyle, const String &rId,
+ const String &rClass );
+ sal_Bool ParseStyleOptions( const String &rStyle, const String &rId,
+ const String &rClass, SfxItemSet &rItemSet,
+ SvxCSS1PropertyInfo &rPropInfo );
+
+
+ // Einfuegen von Controls und ::com::sun::star::form::Forms (htmlform.cxx)
+
+ // Ein Draw-Objekt in das Dokuement eintragen
+ void InsertDrawObject( SdrObject* pNewDrawObj, const Size& rSpace,
+ SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ SfxItemSet& rCSS1ItemSet,
+ SvxCSS1PropertyInfo& rCSS1PropInfo,
+ sal_Bool bHidden=sal_False );
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > InsertControl( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & rFormComp,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rFCompPropSet,
+ const Size& rSize,
+ SwVertOrient eVertOri,
+ SwHoriOrient eHoriOri,
+ SfxItemSet& rCSS1ItemSet,
+ SvxCSS1PropertyInfo& rCSS1PropInfo,
+ const SvxMacroTableDtor& rMacroTbl,
+ const SvStringsDtor& rUnoMacroTbl,
+ const SvStringsDtor& rUnoMacroParamTbl,
+ sal_Bool bSetPropSet = sal_True,
+ sal_Bool bHidden = sal_False );
+ void SetControlSize( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rShape, const Size& rTextSz,
+ sal_Bool bMinWidth, sal_Bool bMinHeight, int nToken );
+ void SetPendingControlSize( int nToken );
+
+public:
+ void ResizeDrawObject( SdrObject* pObj, SwTwips nWidth );
+private:
+ void RegisterDrawObjectToTable( HTMLTable *pCurTable, SdrObject* pObj,
+ sal_uInt8 nWidth );
+
+
+ // eine neue Form beginnen
+ void NewForm( sal_Bool bAppend=sal_True );
+ void EndForm( sal_Bool bAppend=sal_True );
+
+ // die Einfuege-Methoden fuer <INPUT>, <TEXTAREA> und <SELECT>
+ void InsertInput();
+
+ void NewTextArea();
+ void InsertTextAreaText( sal_uInt16 nToken );
+ void EndTextArea();
+
+ void NewSelect();
+ void InsertSelectOption();
+ void InsertSelectText();
+ void EndSelect();
+
+ // Einfuegen von Tabellen (htmltab.cxx)
+
+public: // wird in Tabellen benoetigt
+
+ // einen Boxen-Inhalt hinter dem angegebenen Node einfuegen
+ const SwStartNode *InsertTableSection( const SwStartNode *pPrevStNd );
+
+ // Einen Boxen-Inhalt am Ende der Tabelle einfuegen, in der der PaM
+ // steht un den PaM in die Zelle schieben
+ const SwStartNode *InsertTableSection( sal_uInt16 nPoolId );
+
+ // Einfeuge-Methoden fuer die diversen Tabellen-Tags
+ HTMLTableCnts *InsertTableContents( sal_Bool bHead );
+
+private:
+
+ // Eine leere Boxen am Ende der Tabelle einfuegen. Der PaM wird
+ // NICHT in die Zelle verschoben!
+ const SwStartNode *InsertEmptyTableSection();
+
+
+ // Eine Section fuer die voruebergende Aufnahme der Tabellen-Ueberschrift
+ // anlegen
+ SwStartNode *InsertTempTableCaptionSection();
+
+ void BuildTableCell( HTMLTable *pTable, sal_Bool bReadOptions, sal_Bool bHead );
+ void BuildTableRow( HTMLTable *pTable, sal_Bool bReadOptions,
+ SvxAdjust eGrpAdjust, SwVertOrient eVertOri );
+ void BuildTableSection( HTMLTable *pTable, sal_Bool bReadOptions, sal_Bool bHead );
+ void BuildTableColGroup( HTMLTable *pTable, sal_Bool bReadOptions );
+ void BuildTableCaption( HTMLTable *pTable );
+ HTMLTable *BuildTable( SvxAdjust eCellAdjust,
+ sal_Bool bIsParentHead = sal_False,
+ sal_Bool bHasParentSection=sal_True,
+ sal_Bool bIsInMulticol = sal_False,
+ sal_Bool bHasToFlow = sal_False );
+
+
+ // sonstiges ...
+
+ void ParseMoreMetaOptions();
+
+ sal_Bool FileDownload( const String& rURL, String& rStr );
+ void InsertLink();
+
+ void InsertIDOption();
+ void InsertLineBreak();
+ void InsertHorzRule();
+
+ void FillEndNoteInfo( const String& rContent );
+ void FillFootNoteInfo( const String& rContent );
+ void InsertFootEndNote( const String& rName, sal_Bool bEndNote, sal_Bool bFixed );
+ void FinishFootEndNote();
+ void InsertFootEndNoteText();
+ SwNodeIndex *GetFootEndNoteSection( const String& rName );
+ void DeleteFootEndNoteImpl();
+
+ // Line-Break am Ende eines Absatzes entfernen
+ xub_StrLen StripTrailingLF();
+
+ // Einen leeren Absatz an der PaM-Position entfernen
+ void StripTrailingPara();
+
+ // sind im aktuellen Absatz Fly-Frames vorhanden?
+ sal_Bool HasCurrentParaFlys( sal_Bool bNoSurroundOnly = sal_False,
+ sal_Bool bSurroundOnly = sal_False ) const;
+
+public: // wird in Tabellen benoetigt
+
+ // generieren eines BrushItems (mit new) oder 0
+ SvxBrushItem* CreateBrushItem( const Color *pColor,
+ const String &rImageURL,
+ const String &rStyle,
+ const String &rId,
+ const String &rClass );
+
+protected:
+ // wird fuer jedes Token gerufen, das in CallParser erkannt wird
+ virtual void NextToken( int nToken );
+ virtual ~SwHTMLParser();
+
+ // wird das Dok geloescht, ist auch der Parser zu loeschen
+ virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
+
+public:
+
+ SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ const String& rFileName, int bReadNewDoc = sal_True,
+ SfxMedium* pMed = 0, sal_Bool bReadUTF8 = sal_False );
+
+ virtual SvParserState CallParser(); // Aufruf des Parsers
+
+
+ sal_uInt16 ToTwips( sal_uInt16 nPixel ) const;
+
+ // fuers asynchrone lesen aus dem SvStream
+ virtual void Continue( int nToken );
+};
+
+
+struct SwPendingStackData
+{
+ virtual ~SwPendingStackData() {}
+};
+
+struct SwPendingStack
+{
+ int nToken;
+ SwPendingStackData* pData;
+ SwPendingStack* pNext;
+
+ SwPendingStack( int nTkn, SwPendingStack* pNxt )
+ : nToken( nTkn ), pData( 0 ), pNext( pNxt )
+ {}
+};
+
+inline void _HTMLAttr::SetStart( const SwPosition& rPos )
+{
+ nSttPara = rPos.nNode;
+ nSttCntnt = rPos.nContent.GetIndex();
+ nEndPara = nSttPara;
+ nEndCntnt = nSttCntnt;
+}
+
+inline void _HTMLAttrContext::SetMargins( sal_uInt16 nLeft, sal_uInt16 nRight,
+ short nIndent )
+{
+ nLeftMargin = nLeft;
+ nRightMargin = nRight;
+ nFirstLineIndent = nIndent;
+ bLRSpaceChanged = sal_True;
+}
+
+inline void _HTMLAttrContext::GetMargins( sal_uInt16& nLeft,
+ sal_uInt16& nRight,
+ short& nIndent ) const
+{
+ if( bLRSpaceChanged )
+ {
+ nLeft = nLeftMargin;
+ nRight = nRightMargin;
+ nIndent = nFirstLineIndent;
+ }
+}
+
+inline void _HTMLAttrContext::SetULSpace( sal_uInt16 nUpper, sal_uInt16 nLower )
+{
+ nUpperSpace = nUpper;
+ nLowerSpace = nLower;
+ bULSpaceChanged = sal_True;
+}
+
+inline void _HTMLAttrContext::GetULSpace( sal_uInt16& rUpper,
+ sal_uInt16& rLower ) const
+{
+ if( bULSpaceChanged )
+ {
+ rUpper = nUpperSpace;
+ rLower = nLowerSpace;
+ }
+}
+
+inline sal_Bool SwHTMLParser::HasStyleOptions( const String &rStyle,
+ const String &rId,
+ const String &rClass )
+{
+ return rStyle.Len() || rId.Len() || rClass.Len();
+}
+
+inline const _HTMLAttrContext *SwHTMLParser::GetTopContext() const
+{
+ return aContexts.Count() > nContextStMin
+ ? aContexts[aContexts.Count()-1] : 0;
+}
+
+inline void SwHTMLParser::PushContext( _HTMLAttrContext *pCntxt )
+{
+ aContexts.Insert( pCntxt, aContexts.Count() );
+}
+
+
+inline void SwHTMLParser::GetSaveAndSetOwnBaseURL()
+{
+ sSaveBaseURL = INetURLObject::GetBaseURL();
+ INetURLObject::SetBaseURL( sBaseURL );
+}
+
+inline void SwHTMLParser::SetSaveBaseURL()
+{
+ INetURLObject::SetBaseURL( sSaveBaseURL );
+}
+
+
+#endif
+
+
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
new file mode 100644
index 000000000000..b04a90e8c68b
--- /dev/null
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -0,0 +1,1477 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrthtml.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#include <stdlib.h>
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+#ifndef _SV_WRKWIN_HXX
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _LINKMGR_HXX //autogen
+#include <so3/linkmgr.hxx>
+#endif
+#ifndef _OFA_HTMLCFG_HXX //autogen
+#include <offmgr/htmlcfg.hxx>
+#endif
+#ifndef _OFF_APP_HXX //autogen
+#include <offmgr/app.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _FRMHTMLW_HXX //autogen
+#include <sfx2/frmhtmlw.hxx>
+#endif
+#ifndef _XOUTBMP_HXX //autogen
+#include <svx/xoutbmp.hxx>
+#endif
+#ifndef _SVX_HTMLMODE_HXX //autogen
+#include <svx/htmlmode.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX //autogen
+#include <svtools/stritem.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XIMAGEPRODUCERSUPPLIER_HPP_
+#include <com/sun/star/form/XImageProducerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_
+#include <com/sun/star/form/XFormController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+#include <com/sun/star/form/XFormComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLERLISTENER_HPP_
+#include <com/sun/star/form/XFormControllerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
+#include <com/sun/star/container/XNameReplace.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
+#include <com/sun/star/container/XContainerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
+#include <com/sun/star/container/XSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_CONTAINEREVENT_HPP_
+#include <com/sun/star/container/ContainerEvent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_
+#include <com/sun/star/container/XIndexReplace.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _TXATBASE_HXX //autogen
+#include <txatbase.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include "frmatr.hxx"
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifdef TF_ONE51
+#endif
+
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _VIEWOPT_HXX
+#include <viewopt.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx> // fuer SwBookmark ...
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx>
+#endif
+#ifndef _FMTCLDS_HXX
+#include <fmtclds.hxx>
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _WRTHTML_HXX
+#include <wrthtml.hxx>
+#endif
+#ifndef _HTMLNUM_HXX
+#include <htmlnum.hxx>
+#endif
+#ifndef _HTMLFLY_HXX
+#include <htmlfly.hxx>
+#endif
+
+#ifndef _SWMODULE_HXX //autogen
+#include <swmodule.hxx>
+#endif
+
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+
+#define MAX_INDENT_LEVEL 20
+
+#if defined(MAC)
+const sal_Char SwHTMLWriter::sNewLine = '\015';
+#elif defined(UNX)
+const sal_Char SwHTMLWriter::sNewLine = '\012';
+#else
+const sal_Char __FAR_DATA SwHTMLWriter::sNewLine[] = "\015\012";
+#endif
+
+static sal_Char __FAR_DATA sIndentTabs[MAX_INDENT_LEVEL+2] =
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
+
+SwHTMLWriter::SwHTMLWriter()
+{
+ bFirstLine = sal_True;
+ nBkmkTabPos = USHRT_MAX;
+ pFlyFrmFmt = 0;
+ pDfltColor = 0;
+ nImgMapCnt = 1;
+ pStartNdIdx = 0;
+ pTemplate = 0;
+ pNumRuleInfo = new SwHTMLNumRuleInfo;
+ pNextNumRuleInfo = 0;
+ pFootEndNotes = 0;
+ pFmtFtn = 0;
+ eDestEnc = RTL_TEXTENCODING_MS_1252;
+}
+
+
+__EXPORT SwHTMLWriter::~SwHTMLWriter()
+{
+ delete pNumRuleInfo;
+}
+
+sal_uInt32 SwHTMLWriter::WriteStream()
+{
+ // neue Konfiguration setzen
+ OfaHtmlOptions* pHtmlOptions = OFF_APP()->GetHtmlOptions();
+
+ // die Fontgroessen 1-7
+ aFontHeights[0] = pHtmlOptions->GetFontSize( 0 ) * 20;
+ aFontHeights[1] = pHtmlOptions->GetFontSize( 1 ) * 20;
+ aFontHeights[2] = pHtmlOptions->GetFontSize( 2 ) * 20;
+ aFontHeights[3] = pHtmlOptions->GetFontSize( 3 ) * 20;
+ aFontHeights[4] = pHtmlOptions->GetFontSize( 4 ) * 20;
+ aFontHeights[5] = pHtmlOptions->GetFontSize( 5 ) * 20;
+ aFontHeights[6] = pHtmlOptions->GetFontSize( 6 ) * 20;
+
+ // ueberhaupt Styles ausgeben
+ // (dann auch obere und untere Absatz-Abstaende)
+ nExportMode = pHtmlOptions->GetExportMode();
+ nHTMLMode = GetHtmlMode(0);
+ if( HTML_CFG_WRITER==nExportMode || HTML_CFG_NS30==nExportMode ||
+ HTML_CFG_NS40==nExportMode )
+ nHTMLMode |= HTMLMODE_BLOCK_SPACER;
+
+ if( HTML_CFG_WRITER==nExportMode || HTML_CFG_MSIE==nExportMode )
+ nHTMLMode |= (HTMLMODE_FLOAT_FRAME | HTMLMODE_LSPACE_IN_NUMBUL);
+
+ if( HTML_CFG_NS30==nExportMode )
+ nHTMLMode |= HTMLMODE_VERT_SPACER;
+
+ if( HTML_CFG_MSIE==nExportMode )
+ nHTMLMode |= HTMLMODE_NBSP_IN_TABLES;
+
+ if( HTML_CFG_WRITER==nExportMode || HTML_CFG_NS40==nExportMode ||
+ HTML_CFG_MSIE==nExportMode )
+ nHTMLMode |= HTMLMODE_ABS_POS_FLY;
+
+ if( HTML_CFG_WRITER==nExportMode || HTML_CFG_MSIE==nExportMode )
+ nHTMLMode |= HTMLMODE_ABS_POS_DRAW;
+
+ if( HTML_CFG_WRITER==nExportMode )
+// nHTMLMode |= HTMLMODE_FLY_MARGINS | HTMLMODE_FRSTLINE_IN_NUMBUL;
+ nHTMLMode |= HTMLMODE_FLY_MARGINS;
+
+ if( HTML_CFG_NS40==nExportMode )
+ nHTMLMode |= HTMLMODE_BORDER_NONE;
+
+ if( HTML_CFG_HTML32!=nExportMode )
+ nHTMLMode |= HTMLMODE_FONT_GENERIC;
+
+ if( HTML_CFG_NS30==nExportMode || HTML_CFG_NS40==nExportMode )
+ nHTMLMode |= HTMLMODE_NO_CONTROL_CENTERING;
+
+ bCfgOutStyles = IsHTMLMode(HTMLMODE_SOME_STYLES |
+ HTMLMODE_FULL_STYLES);
+ bCfgNetscape4 = (HTML_CFG_NS40==nExportMode);
+
+ if( IsHTMLMode(HTMLMODE_SOME_STYLES | HTMLMODE_FULL_STYLES) )
+ nHTMLMode |= HTMLMODE_PRINT_EXT;
+
+ const sal_Char *pHelpHack = getenv( "HelpEx" );
+ if( pHelpHack )
+ {
+ ByteString aTmp( pHelpHack );
+ if( aTmp.EqualsIgnoreCaseAscii( "Hilfe" ) )
+ nHTMLMode |= HTMLMODE_NO_BR_AT_PAREND;
+ }
+
+ eCSS1Unit = (FieldUnit)SW_MOD()->GetMetric( pDoc->IsHTMLMode() );
+
+ const sal_Char *pCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( gsl_getSystemTextEncoding() );
+ eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
+
+ // fuer Netscape optimieren heisst Spacer- und Multicol ausgeben
+// bCfgMultiCol = pHtmlOptions->IsNetscape3();
+// bCfgSpacer = pHtmlOptions->IsNetscape3();
+
+ // wenn Styles exportiert werden, wird ein Style einem HTML-Tag manchmal
+ // vorgezogen, wenn nicht fuer Netscape exportiert wird
+ // bCfgPreferStyles = bCfgOutStyles; // && !pHtmlOptions->IsNetscape3();
+
+ // Nur noch fuer den MS-IE ziehen wir den Export von Styles vor.
+ bCfgPreferStyles = HTML_CFG_MSIE==nExportMode;
+
+ bCfgStarBasic = pHtmlOptions->IsStarBasic();
+
+ bCfgFormFeed = !IsHTMLMode(HTMLMODE_PRINT_EXT);
+ bCfgCpyLinkedGrfs = pHtmlOptions->IsSaveGraphicsLocal();
+
+ // die HTML-Vorlage holen
+ sal_Bool bOldHTMLMode;
+ sal_uInt16 nOldTxtFmtCollCnt, nOldCharFmtCnt;
+
+ ASSERT( !pTemplate, "Wo kommt denn die HTML-Vorlage hier her?" );
+ pTemplate = ((HTMLReader*)ReadHTML)->GetTemplateDoc();
+ if( pTemplate )
+ {
+ pTemplate->AddLink();
+ bOldHTMLMode = pTemplate->IsHTMLMode();
+ pTemplate->SetHTMLMode( sal_True );
+
+ nOldTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->Count();
+ nOldCharFmtCnt = pTemplate->GetCharFmts()->Count();
+ }
+
+ if( bShowProgress )
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, pDoc->GetNodes().Count(),
+ pDoc->GetDocShell());
+
+ pFlyFrmFmt = 0; // kein FlyFrmFormat gesetzt
+ pDfltColor = 0;
+ pFootEndNotes = 0;
+ pFmtFtn = 0;
+ bOutTable = bOutHeader = bOutFooter = sal_False;
+ pxFormComps = 0;
+ nFormCntrlCnt = 0;
+ bPreserveForm = sal_False;
+ bClearLeft = bClearRight = sal_False;
+ bLFPossible = sal_False;
+
+ nLeftMargin = nDfltLeftMargin = nDfltRightMargin = 0;
+ nDfltTopMargin = nDfltBottomMargin = 0;
+ nFirstLineIndent = nDfltFirstLineIndent = 0;
+ bPoolCollTextModified = sal_False;
+ bFirstCSS1Property = bFirstCSS1Rule = sal_False;
+ bCSS1IgnoreFirstPageDesc = sal_False;
+ nIndentLvl = 0;
+ nWhishLineLen = 70;
+ nLastLFPos = 0;
+ nDefListLvl = 0;
+ nDefListMargin = ((pTemplate && !bCfgOutStyles) ? pTemplate : pDoc)
+ ->GetTxtCollFromPool( RES_POOLCOLL_HTML_DD )
+ ->GetLRSpace().GetTxtLeft();
+ nHeaderFooterSpace = 0;
+ nTxtAttrsToIgnore = 0;
+ nCSS1OutMode = 0;
+ nFootNote = nEndNote = 0;
+
+ nWarn = 0;
+ GetNumInfo().Clear();
+ pNextNumRuleInfo = 0;
+
+ // Content-Id setzen
+ aCId.Erase();
+ SwDocShell *pDocSh = pDoc->GetDocShell();
+ if( pDocSh )
+ {
+ const SfxPoolItem *pItem = pDocSh->GetItem( SID_ORIGURL );
+ if( pItem )
+ {
+ aCId = ((const SfxStringItem *)pItem)->GetValue();
+ ASSERT( aCId.Len(), "CID ohne Laenge!" );
+ nWhishLineLen = 72;
+ }
+ }
+
+ ByteString aStartTags;
+
+ // Tabellen und Bereiche am Doc.-Anfang beachten
+ {
+ SwTableNode * pTNd = pCurPam->GetNode()->FindTableNode();
+ if( pTNd && bWriteAll )
+ {
+ // mit dem Tabellen-Node anfangen !!
+ pCurPam->GetPoint()->nNode = *pTNd;
+
+ if( bWriteOnlyFirstTable )
+ pCurPam->GetMark()->nNode = *pTNd->EndOfSectionNode();
+ }
+
+ // erster Node (der einen Seitenumbruch enthalten darf)
+ pStartNdIdx = new SwNodeIndex( pCurPam->GetPoint()->nNode );
+
+ SwSectionNode * pSNd = pCurPam->GetNode()->FindSectionNode();
+ while( pSNd )
+ {
+ if( bWriteAll )
+ {
+ // mit dem Section-Node anfangen !!
+ pCurPam->GetPoint()->nNode = *pSNd;
+ }
+ else
+ {
+ ASSERT( FILE_LINK_SECTION != pSNd->GetSection().GetType(),
+ "Export gelinkter Bereiche am Dok-Anfang ist nicht implemntiert" );
+
+ // nur das Tag fuer die Section merken
+ ByteString aName;
+ HTMLOutFuncs::ConvertStringToHTML( pSNd->GetSection().GetName(),
+ aName, eDestEnc );
+
+ ByteString sOut( '<' );
+ (((((((sOut += sHTML_division)
+ += ' ') += sHTML_O_id) += "=\"")
+ += aName) += '\"')
+ += '>') += aStartTags;
+
+ aStartTags = sOut;
+ }
+ // FindSectionNode() an einem SectionNode liefert den selben!
+ pSNd = pSNd->FindStartNode()->FindSectionNode();
+ }
+ }
+
+
+ // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn
+ // das gesamte Dokument geschrieben wird
+ pHTMLPosFlyFrms = 0;
+ CollectFlyFrms();
+ nLastParaToken = 0;
+ GetControls();
+ CollectLinkTargets();
+
+ sal_uInt16 nHeaderAttrs = 0;
+ pCurrPageDesc = MakeHeader( nHeaderAttrs );
+
+ bLFPossible = sal_True;
+
+ // Formulare, die nur HiddenControls enthalten ausgeben.
+ OutHiddenForms();
+
+ if( aStartTags.Len() )
+ Strm() << aStartTags.GetBuffer();
+
+ const SfxPoolItem *pItem;
+ const SfxItemSet& rPageItemSet = pCurrPageDesc->GetMaster().GetAttrSet();
+ if( !bWriteClipboardDoc && pDoc->GetDocShell() &&
+ ( pDoc->IsHeadInBrowse() ||
+ (!pDoc->IsHTMLMode() && !pDoc->IsBrowseMode()) ) &&
+ SFX_ITEM_SET == rPageItemSet.GetItemState( RES_HEADER, sal_True, &pItem) )
+ {
+ const SwFrmFmt *pHeaderFmt =
+ ((const SwFmtHeader *)pItem)->GetHeaderFmt();
+ if( pHeaderFmt )
+ OutHTML_HeaderFooter( *this, *pHeaderFmt, sal_True );
+ }
+
+ nTxtAttrsToIgnore = nHeaderAttrs;
+ Out_SwDoc( pOrigPam );
+ nTxtAttrsToIgnore = 0;
+
+ if( pxFormComps && pxFormComps->is() )
+ OutForm( sal_False, *pxFormComps );
+
+ if( pFootEndNotes )
+ OutFootEndNotes();
+
+ if( !bWriteClipboardDoc && pDoc->GetDocShell() &&
+ ( pDoc->IsFootInBrowse() ||
+ (!pDoc->IsHTMLMode() && !pDoc->IsBrowseMode()) ) &&
+ SFX_ITEM_SET == rPageItemSet.GetItemState( RES_FOOTER, sal_True, &pItem) )
+ {
+ const SwFrmFmt *pFooterFmt =
+ ((const SwFmtFooter *)pItem)->GetFooterFmt();
+ if( pFooterFmt )
+ OutHTML_HeaderFooter( *this, *pFooterFmt, sal_False );
+ }
+
+ if( bLFPossible )
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_body, sal_False );
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_html, sal_False );
+
+ // loesche die Tabelle mit den freifliegenden Rahmen
+ sal_uInt16 i;
+ ASSERT( !pHTMLPosFlyFrms, "Wurden nicht alle Rahmen ausgegeben" );
+ if( pHTMLPosFlyFrms )
+ {
+ pHTMLPosFlyFrms->DeleteAndDestroy( 0, pHTMLPosFlyFrms->Count() );
+ delete pHTMLPosFlyFrms;
+ pHTMLPosFlyFrms = 0;
+ }
+
+ if( aHTMLControls.Count() )
+ aHTMLControls.DeleteAndDestroy( sal_uInt16(0), aHTMLControls.Count() );
+
+ if( aChrFmtInfos.Count() )
+ aChrFmtInfos.DeleteAndDestroy( sal_uInt16(0), aChrFmtInfos.Count() );
+
+ if( aTxtCollInfos.Count() )
+ aTxtCollInfos.DeleteAndDestroy( sal_uInt16(0), aTxtCollInfos.Count() );
+
+ if( aImgMapNames.Count() )
+ aImgMapNames.DeleteAndDestroy( sal_uInt16(0), aImgMapNames.Count() );
+
+ if( aImplicitMarks.Count() )
+ aImplicitMarks.DeleteAndDestroy( sal_uInt16(0), aImplicitMarks.Count() );
+
+ if( aOutlineMarks.Count() )
+ aOutlineMarks.DeleteAndDestroy( sal_uInt16(0), aOutlineMarks.Count() );
+
+ if( aOutlineMarkPoss.Count() )
+ aOutlineMarkPoss.Remove( sal_uInt16(0), aOutlineMarkPoss.Count() );
+
+ delete pDfltColor;
+ pDfltColor = 0;
+
+ delete pStartNdIdx;
+ pStartNdIdx = 0;
+
+ delete pxFormComps;
+ pxFormComps = 0;
+
+ ASSERT( !pFootEndNotes,
+ "SwHTMLWriter::Write: Ftns nicht durch OutFootEndNotes geloescht" );
+
+ pCurrPageDesc = 0;
+
+ ClearNextNumInfo();
+
+ for( i=0; i<MAXLEVEL; i++ )
+ aBulletGrfs[i].Erase();
+
+ if( bShowProgress )
+ ::EndProgress( pDoc->GetDocShell() );
+
+ if( pTemplate )
+ {
+ // Waehrend des Exports angelegte Zeichen- und Abastzvorlagen
+ // loeschen
+ sal_uInt16 nTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->Count();
+ while( nTxtFmtCollCnt > nOldTxtFmtCollCnt )
+ pTemplate->DelTxtFmtColl( --nTxtFmtCollCnt );
+ ASSERT( pTemplate->GetTxtFmtColls()->Count() == nOldTxtFmtCollCnt,
+ "falsche Anzahl TxtFmtColls geloescht" );
+
+ sal_uInt16 nCharFmtCnt = pTemplate->GetCharFmts()->Count();
+ while( nCharFmtCnt > nOldCharFmtCnt )
+ pTemplate->DelCharFmt( --nCharFmtCnt );
+ ASSERT( pTemplate->GetCharFmts()->Count() == nOldCharFmtCnt,
+ "falsche Anzahl CharFmts geloescht" );
+
+ // HTML-Modus wieder restaurieren
+ pTemplate->SetHTMLMode( bOldHTMLMode );
+
+ if( 0 == pTemplate->RemoveLink() )
+ delete pTemplate;
+
+ pTemplate = 0;
+ }
+
+ return nWarn;
+}
+
+const SwFmtCol *lcl_html_GetFmtCol( const SwHTMLWriter& rHTMLWrt,
+ const SwSection& rSection,
+ const SwSectionFmt& rFmt )
+{
+ const SwFmtCol *pCol = 0;
+
+ const SfxPoolItem* pItem;
+ if( rHTMLWrt.IsHTMLMode( HTMLMODE_FRM_COLUMNS ) &&
+ FILE_LINK_SECTION != rSection.GetType() &&
+ SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(RES_COL,sal_False,&pItem) &&
+ ((const SwFmtCol *)pItem)->GetNumCols() > 1 )
+ {
+ pCol = (const SwFmtCol *)pItem;
+ }
+
+ return pCol;
+}
+
+sal_Bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uInt32 nIndex )
+{
+ sal_Bool bRet = sal_False;
+ const SwSectionNode *pSectNd =
+ rHTMLWrt.pDoc->GetNodes()[nIndex]->GetSectionNode();
+ if( pSectNd )
+ {
+ const SwSection& rSection = pSectNd->GetSection();
+ const SwSectionFmt *pFmt = rSection.GetFmt();
+ if( pFmt && lcl_html_GetFmtCol( rHTMLWrt, rSection, *pFmt ) )
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+sal_Bool lcl_html_IsMultiColEnd( const SwHTMLWriter& rHTMLWrt, sal_uInt32 nIndex )
+{
+ sal_Bool bRet = sal_False;
+ const SwEndNode *pEndNd = rHTMLWrt.pDoc->GetNodes()[nIndex]->GetEndNode();
+ if( pEndNd )
+ bRet = lcl_html_IsMultiColStart( rHTMLWrt,
+ pEndNd->StartOfSectionIndex() );
+
+ return bRet;
+}
+
+
+void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
+ const SwSection& rSection,
+ const SwSectionFmt& rFmt,
+ const SwFmtCol *pCol,
+ sal_Bool bContinued=sal_False )
+{
+ ASSERT( pCol || !bContinued, "Continuation of DIV" );
+
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+
+ const sal_Char *pTag = pCol ? sHTML_multicol : sHTML_division;
+
+ ByteString sOut( '<' );
+ sOut += pTag;
+
+ const String& rName = rSection.GetName();
+ if( rName.Len() && !bContinued )
+ {
+ ((sOut += ' ') += sHTML_O_id) += "=\"";
+ rHTMLWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), rName, rHTMLWrt.eDestEnc );
+ sOut = '\"';
+ }
+
+ if( FILE_LINK_SECTION == rSection.GetType() )
+ {
+ ((sOut += ' ') += sHTML_O_href) += "=\"";
+ rHTMLWrt.Strm() << sOut.GetBuffer();
+
+ const String& aFName = rSection.GetLinkFileName();
+ String aURL( aFName.GetToken(0,cTokenSeperator) );
+ String aFilter( aFName.GetToken(1,cTokenSeperator) );
+ String aSection( aFName.GetToken(2,cTokenSeperator) );
+
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(),
+ INetURLObject::AbsToRel(aURL,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET),
+ rHTMLWrt.eDestEnc );
+ const sal_Char *pDelim = "&#255;";
+ if( aFilter.Len() )
+ {
+ rHTMLWrt.Strm() << pDelim;
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter,
+ rHTMLWrt.eDestEnc );
+ }
+ if( aSection.Len() )
+ {
+ if( !aFilter.Len() )
+ rHTMLWrt.Strm() << pDelim;
+ rHTMLWrt.Strm() << pDelim;
+ HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection,
+ rHTMLWrt.eDestEnc );
+ }
+ sOut = '\"';
+ }
+ else if( pCol )
+ {
+ (((sOut += ' ') += sHTML_O_cols) += '=')
+ += ByteString::CreateFromInt32( pCol->GetNumCols() );
+
+ // minumum gutter width
+ sal_uInt16 nGutter = pCol->GetGutterWidth( sal_True );
+ if( nGutter!=USHRT_MAX )
+ {
+ if( nGutter && Application::GetDefaultDevice() )
+ {
+ nGutter = (sal_uInt16)Application::GetDefaultDevice()
+ ->LogicToPixel( Size(nGutter,0),
+ MapMode(MAP_TWIP) ).Width();
+ }
+ (((sOut += ' ') += sHTML_O_gutter) += '=')
+ += ByteString::CreateFromInt32( nGutter );
+ }
+ }
+
+ rHTMLWrt.Strm() << sOut.GetBuffer();
+ if( rHTMLWrt.IsHTMLMode( rHTMLWrt.bCfgOutStyles ) )
+ rHTMLWrt.OutCSS1_SectionFmtOptions( rFmt );
+
+ rHTMLWrt.Strm() << '>';
+
+ rHTMLWrt.bLFPossible = sal_True;
+ if( rName.Len() && !bContinued )
+ rHTMLWrt.OutImplicitMark( rName, pMarkToRegion );
+
+ rHTMLWrt.IncIndentLevel();
+}
+
+void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt,
+ const SwFmtCol *pCol )
+{
+ const sal_Char *pTag = pCol ? sHTML_multicol : sHTML_division;
+
+ rHTMLWrt.DecIndentLevel();
+ if( rHTMLWrt.bLFPossible )
+ rHTMLWrt.OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), pTag, sal_False );
+ rHTMLWrt.bLFPossible = sal_True;
+}
+
+static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
+{
+ SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
+
+ // End <PRE> and any <DL>, because a definition list's level may
+ // change inside the section.
+ rHTMLWrt.ChangeParaToken( 0 );
+ rHTMLWrt.OutAndSetDefList( 0 );
+
+ const SwSection& rSection = rSectNd.GetSection();
+ const SwSectionFmt *pFmt = rSection.GetFmt();
+ ASSERT( pFmt, "Section without a format?" );
+
+ sal_Bool bStartTag = sal_True;
+ sal_Bool bEndTag = sal_True;
+ const SwSectionFmt *pSurrFmt = 0;
+ const SwSectionNode *pSurrSectNd = 0;
+ const SwSection *pSurrSection = 0;
+ const SwFmtCol *pSurrCol = 0;
+
+ sal_uInt32 nSectSttIdx = rSectNd.GetIndex();
+ sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex();
+ const SwFmtCol *pCol = lcl_html_GetFmtCol( rHTMLWrt, rSection, *pFmt );
+ if( pCol )
+ {
+ // If the next node is a columned section node, too, don't export
+ // an empty section.
+ if( lcl_html_IsMultiColStart( rHTMLWrt, nSectSttIdx+1 ) )
+ bStartTag = sal_False;
+
+ // The same applies if the section end with another columned section.
+ if( lcl_html_IsMultiColEnd( rHTMLWrt, nSectEndIdx-1 ) )
+ bEndTag = sal_False;
+
+ //.is there a columned section arround this one?
+ const SwStartNode *pSttNd = rSectNd.FindStartNode();
+ if( pSttNd )
+ {
+ pSurrSectNd = pSttNd->FindSectionNode();
+ if( pSurrSectNd )
+ {
+ const SwStartNode *pBoxSttNd = pSttNd->FindTableBoxStartNode();
+ if( !pBoxSttNd ||
+ pBoxSttNd->GetIndex() < pSurrSectNd->GetIndex() )
+ {
+ pSurrSection = &pSurrSectNd->GetSection();
+ pSurrFmt = pSurrSection->GetFmt();
+ if( pSurrFmt )
+ pSurrCol = lcl_html_GetFmtCol( rHTMLWrt, *pSurrSection,
+ *pSurrFmt );
+ }
+ }
+ }
+ }
+
+ // The surrounding section must be closed before the current one is
+ // opended, except that it start immediatly before the current one or
+ // another end immediately before the current one
+ if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > 1 &&
+ !lcl_html_IsMultiColEnd( rHTMLWrt, nSectSttIdx-1 ) )
+ lcl_html_OutSectionEndTag( rHTMLWrt, pSurrCol );
+
+ if( bStartTag )
+ lcl_html_OutSectionStartTag( rHTMLWrt, rSection, *pFmt, pCol );
+
+ {
+ HTMLSaveData aSaveData( rHTMLWrt,
+ rHTMLWrt.pCurPam->GetPoint()->nNode.GetIndex()+1,
+ rSectNd.EndOfSectionIndex(),
+ rHTMLWrt.GetFlyFrmFmt(),
+ sal_False );
+ rHTMLWrt.Out_SwDoc( rHTMLWrt.pCurPam );
+ }
+
+ rHTMLWrt.pCurPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
+
+ if( bEndTag )
+ lcl_html_OutSectionEndTag( rHTMLWrt, pCol );
+
+ // The surrounding section must be started again, except that it ends
+ // immeditaly behind the current one.
+ if( pSurrCol &&
+ pSurrSectNd->EndOfSectionIndex() - nSectEndIdx > 1 &&
+ !lcl_html_IsMultiColStart( rHTMLWrt, nSectEndIdx+1 ) )
+ lcl_html_OutSectionStartTag( rHTMLWrt, *pSurrSection, *pSurrFmt,
+ pSurrCol, sal_True );
+
+ return rWrt;
+}
+
+void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
+{
+ sal_Bool bSaveWriteAll = bWriteAll; // sichern
+
+
+ // suche die naechste ::com::sun::star::text::Bookmark-Position aus der ::com::sun::star::text::Bookmark-Tabelle
+ nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : USHRT_MAX;
+
+ // gebe alle Bereiche des Pams in das HTML-File aus.
+ do {
+ bWriteAll = bSaveWriteAll;
+ bFirstLine = sal_True;
+
+ // suche den ersten am Pam-auszugebenen FlyFrame
+ // fehlt noch:
+
+ while( pCurPam->GetPoint()->nNode.GetIndex() < pCurPam->GetMark()->nNode.GetIndex() ||
+ (pCurPam->GetPoint()->nNode.GetIndex() == pCurPam->GetMark()->nNode.GetIndex() &&
+ pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
+ {
+ SwNode * pNd = pCurPam->GetNode();
+
+ ASSERT( !(pNd->IsGrfNode() || pNd->IsOLENode()),
+ "Grf- oder OLE-Node hier unerwartet" );
+ if( pNd->IsTxtNode() )
+ {
+ SwTxtNode* pTxtNd = pNd->GetTxtNode();
+
+ if( !bFirstLine )
+ pCurPam->GetPoint()->nContent.Assign( pTxtNd, 0 );
+
+ OutHTML_SwTxtNode( *this, *pTxtNd );
+ }
+ else if( pNd->IsTableNode() )
+ {
+ OutHTML_SwTblNode( *this, *pNd->GetTableNode(), 0 );
+ }
+ else if( pNd->IsSectionNode() )
+ {
+ OutHTML_Section( *this, *pNd->GetSectionNode() );
+ }
+ else if( pNd == &pDoc->GetNodes().GetEndOfContent() )
+ break;
+
+ pCurPam->GetPoint()->nNode++; // Bewegen
+ sal_uInt32 nPos = pCurPam->GetPoint()->nNode.GetIndex();
+
+ if( bShowProgress )
+ ::SetProgressState( nPos, pDoc->GetDocShell() ); // Wie weit ?
+
+ /* sollen nur die Selectierten Bereiche gesichert werden, so
+ * duerfen nur die vollstaendigen Nodes gespeichert werde,
+ * d.H. der 1. und n. Node teilweise, der 2. bis n-1. Node
+ * vollstaendig. (vollstaendig heisst mit allen Formaten! )
+ */
+ bWriteAll = bSaveWriteAll ||
+ nPos != pCurPam->GetMark()->nNode.GetIndex();
+ bFirstLine = sal_False;
+ bOutFooter = sal_False; // Nach einem Node keine Fusszeile mehr
+ }
+
+ ChangeParaToken( 0 ); // MIB 8.7.97: Machen wir jetzt hier und nicht
+ // beim Aufrufer
+ OutAndSetDefList( 0 );
+
+ } while( CopyNextPam( &pPam ) ); // bis alle PaM's bearbeitet
+
+ bWriteAll = bSaveWriteAll; // wieder auf alten Wert zurueck
+}
+
+
+// schreibe die StyleTabelle, algemeine Angaben,Header/Footer/Footnotes
+static void OutBodyColor( const sal_Char *pTag, const SwFmt *pFmt,
+ SwHTMLWriter& rHWrt )
+{
+ const SwFmt *pRefFmt = 0;
+
+ if( rHWrt.pTemplate )
+ pRefFmt = SwHTMLWriter::GetTemplateFmt( pFmt->GetPoolFmtId(),
+ rHWrt.pTemplate );
+
+ const SvxColorItem *pColorItem = 0;
+
+ const SfxItemSet& rItemSet = pFmt->GetAttrSet();
+ const SfxPoolItem *pRefItem, *pItem;
+ sal_Bool bItemSet = SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_COLOR,
+ sal_True, &pItem);
+ sal_Bool bRefItemSet = pRefFmt &&
+ SFX_ITEM_SET == pRefFmt->GetAttrSet().GetItemState( RES_CHRATR_COLOR,
+ sal_True, &pRefItem);
+ if( bItemSet )
+ {
+ // wenn das Item nur in der Vorlage des aktuellen Doks gesetzt
+ // ist oder einen anderen Wert hat, als in der HTML-Vorlage,
+ // wird es gesetzt
+ const SvxColorItem *pCItem = (const SvxColorItem*)pItem;
+ if( !bRefItemSet ||
+ !pCItem->GetValue().IsRGBEqual(
+ ((const SvxColorItem*)pRefItem)->GetValue() ) )
+ pColorItem = pCItem;
+ }
+ else if( bRefItemSet )
+ {
+ // Das Item war in der HTML-Vorlage noch gesetzt, also geben wir
+ // das Default aus
+ pColorItem = (const SvxColorItem*)&rItemSet.GetPool()
+ ->GetDefaultItem( RES_CHRATR_COLOR );
+ }
+
+ if( pColorItem )
+ {
+ ByteString sOut( ' ' );
+ (sOut += pTag) += '=';
+ rHWrt.Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( rHWrt.Strm(), pColorItem->GetValue() );
+ if( RES_POOLCOLL_STANDARD==pFmt->GetPoolFmtId() )
+ rHWrt.pDfltColor = new Color( pColorItem->GetValue() );
+ }
+}
+
+sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
+{
+ sal_uInt32 nIdx = pCurPam->GetPoint()->nNode.GetIndex();
+ sal_uInt32 nEndIdx = pCurPam->GetMark()->nNode.GetIndex();
+
+ SwTxtNode *pTxtNd = 0;
+ while( nIdx<=nEndIdx &&
+ 0==(pTxtNd=pDoc->GetNodes()[nIdx]->GetTxtNode()) )
+ nIdx++;
+
+ ASSERT( pTxtNd, "Kein Text-Node gefunden" );
+ if( !pTxtNd || !pTxtNd->HasHints() )
+ return 0;
+
+ sal_uInt16 nAttrs = 0;
+ sal_uInt16 nCntAttr = pTxtNd->GetSwpHints().Count();
+ xub_StrLen nOldPos = 0;
+ for( sal_uInt16 i=0; i<nCntAttr; i++ )
+ {
+ const SwTxtAttr *pHt = pTxtNd->GetSwpHints()[i];
+ if( !pHt->GetEnd() )
+ {
+ xub_StrLen nPos = *pHt->GetStart();
+ if( nPos-nOldPos > 1 || RES_TXTATR_FIELD != pHt->Which() )
+ break;
+
+ sal_uInt16 nFldWhich = ((const SwFmtFld&)pHt->GetAttr()).GetFld()
+ ->GetTyp()->Which();
+ if( RES_POSTITFLD!=nFldWhich &&
+ RES_SCRIPTFLD!=nFldWhich )
+ break;
+
+ OutNewLine();
+ OutHTML_SwFmtFld( *this, pHt->GetAttr() );
+ nOldPos = nPos;
+ nAttrs++;
+ }
+ }
+
+ return nAttrs;
+}
+
+const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
+{
+ ByteString sOut( sHTML_doctype );
+ (sOut += ' ') += sHTML_doctype32;
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.GetBuffer() );
+
+ // baue den Vorspann
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_html );
+
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_head );
+
+ IncIndentLevel(); // Inhalt von <HEAD> einruecken
+
+ // DokumentInfo
+ ByteString sIndent;
+ GetIndentString( sIndent );
+// OutNewLine();
+ SfxFrameHTMLWriter::Out_DocInfo( Strm(), pDoc->GetpInfo(),
+ sIndent.GetBuffer(), eDestEnc );
+
+ // Kommentare und Meta-Tags des ersten Absatzes
+ rHeaderAttrs = OutHeaderAttrs();
+
+ OutFootEndNoteInfo();
+
+ const SwPageDesc *pPageDesc = 0;
+ //if( !pDoc->IsHTMLMode() )
+ //{
+ // In Nicht-HTML-Dokumenten wird die erste gesetzte Seitenvorlage
+ // exportiert und wenn keine gesetzt ist die Standard-Vorlage
+ sal_uInt32 nNodeIdx = pCurPam->GetPoint()->nNode.GetIndex();
+
+ while( nNodeIdx < pDoc->GetNodes().Count() )
+ {
+ SwNode *pNd = pDoc->GetNodes()[ nNodeIdx ];
+ if( pNd->IsCntntNode() )
+ {
+ pPageDesc = ((const SwFmtPageDesc &)pNd->GetCntntNode()
+ ->GetAttr(RES_PAGEDESC)).GetPageDesc();
+ break;
+ }
+ else if( pNd->IsTableNode() )
+ {
+ pPageDesc = pNd->GetTableNode()->GetTable().GetFrmFmt()
+ ->GetPageDesc().GetPageDesc();
+ break;
+ }
+
+ nNodeIdx++;
+ }
+
+ if( !pPageDesc )
+ pPageDesc = &pDoc->GetPageDesc( 0 );
+ //}
+ //else
+ //{
+ // In HTML-Dokumenten nehmen wir immer die HTML-Vorlage
+ // pPageDesc = pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML );
+ //}
+
+ // und nun ... das Style-Sheet!!!
+ if( bCfgOutStyles )
+ {
+ OutStyleSheet( *pPageDesc );
+ }
+
+ // und nun ... das BASIC und JavaScript!
+ if( pDoc->GetDocShell() ) // nur mit DocShell ist Basic moeglich
+ OutBasic();
+
+ DecIndentLevel(); // Inhalt von <HEAD> einruecken
+ OutNewLine();
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_head, sal_False );
+
+ // der Body wird nicht eingerueckt, weil sonst alles eingerueckt waere!
+ OutNewLine();
+ sOut = '<';
+ sOut += sHTML_body;
+ Strm() << sOut.GetBuffer();
+ sOut.Erase();
+
+ // Textfarbe ausgeben, wenn sie an der Standard-Vorlage gesetzt ist
+ // und sich geaendert hat.
+ OutBodyColor( sHTML_O_text,
+ pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD ),
+ *this );
+
+ // Farben fuer (un)besuchte Links
+ OutBodyColor( sHTML_O_link,
+ pDoc->GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL ),
+ *this );
+ OutBodyColor( sHTML_O_vlink,
+ pDoc->GetCharFmtFromPool( RES_POOLCHR_INET_VISIT ),
+ *this );
+
+ const SfxItemSet& rItemSet = pPageDesc->GetMaster().GetAttrSet();
+
+ String aEmbGrfName;
+ OutBackground( rItemSet, aEmbGrfName, sal_True );
+
+ if( bCfgOutStyles )
+ OutCSS1_BodyTagStyleOpt( *this, rItemSet, aEmbGrfName );
+
+ // Events anhaengen
+ if( pDoc->GetDocShell() ) // nur mit DocShell ist Basic moeglich
+ OutBasicBodyEvents();
+
+ Strm() << '>';
+
+ return pPageDesc;
+}
+
+void SwHTMLWriter::OutAnchor( const String& rName )
+{
+ ByteString sOut( '<' );
+ (((sOut += sHTML_anchor) += ' ') += sHTML_O_name) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), rName, eDestEnc ) << "\">";
+ HTMLOutFuncs::Out_AsciiTag( Strm(), sHTML_anchor, sal_False );
+}
+
+void SwHTMLWriter::OutBookmarks()
+{
+ // hole das aktuelle Bookmark
+ const SwBookmark* pBookmark = USHRT_MAX != nBkmkTabPos ?
+ pDoc->GetBookmarks()[ nBkmkTabPos ] : 0;
+ // Ausgabe aller Bookmarks in diesem Absatz. Die Content-Position
+ // wird vorerst nicht beruecksichtigt!
+ sal_uInt32 nNode = pCurPam->GetPoint()->nNode.GetIndex();
+ while( USHRT_MAX != nBkmkTabPos &&
+ pBookmark->GetPos().nNode.GetIndex() == nNode )
+ {
+ // Der Bereich derBookmark wird erstam ignoriert, da er von uns
+ // auch nicht eingelesen wird.
+
+ // erst die SWG spezifischen Daten:
+ if( pBookmark->IsBookMark() && pBookmark->GetName().Len() )
+ OutAnchor( pBookmark->GetName() );
+
+ if( ++nBkmkTabPos >= pDoc->GetBookmarks().Count() )
+ nBkmkTabPos = USHRT_MAX;
+ else
+ pBookmark = pDoc->GetBookmarks()[ nBkmkTabPos ];
+ }
+
+ sal_uInt16 nPos;
+ for( nPos = 0; nPos < aOutlineMarkPoss.Count() &&
+ aOutlineMarkPoss[nPos] < nNode; nPos++ )
+ ;
+
+ while( nPos < aOutlineMarkPoss.Count() && aOutlineMarkPoss[nPos] == nNode )
+ {
+ OutAnchor( *aOutlineMarks[nPos] );
+ aOutlineMarkPoss.Remove( nPos, 1 );
+ aOutlineMarks.DeleteAndDestroy( nPos, 1 );
+ }
+}
+
+void SwHTMLWriter::OutImplicitMark( const String& rMark,
+ const sal_Char *pMarkType )
+{
+ if( rMark.Len() && aImplicitMarks.Count() )
+ {
+ String sMark( rMark );
+ sMark.Append( cMarkSeperator );
+ sMark.AppendAscii( pMarkType );
+ sal_uInt16 nPos;
+ if( aImplicitMarks.Seek_Entry( &sMark, &nPos ) )
+ {
+ OutAnchor( sMark );
+ aImplicitMarks.DeleteAndDestroy( nPos, 1 );
+ }
+ }
+}
+
+void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem,
+ String& rEmbGrfNm, sal_Bool bGraphic )
+{
+ const Color &rBackColor = pBrushItem->GetColor();
+ if( !rBackColor.GetTransparency() )
+ {
+ ByteString sOut( ' ' );
+ (sOut += sHTML_O_bgcolor) += '=';
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_Color( Strm(), rBackColor );
+ }
+
+ if( !bGraphic )
+ return;
+
+ const String *pLink = pBrushItem->GetGraphicLink();
+
+ // embeddete Grafik -> WriteEmbedded schreiben
+ if( !pLink )
+ {
+ const Graphic* pGrf = pBrushItem->GetGraphic();
+ if( pGrf )
+ {
+ // Grafik als (JPG-)File speichern
+ const String* pTempFileName = GetOrigFileName();
+ if(pTempFileName)
+ rEmbGrfNm = *pTempFileName;
+ sal_uInt16 nErr = XOutBitmap::WriteGraphic( *pGrf, rEmbGrfNm,
+ String::CreateFromAscii( "JPG" ) );
+ if( !nErr ) // fehlerhaft, da ist nichts auszugeben
+ {
+ rEmbGrfNm = URIHelper::SmartRelToAbs( rEmbGrfNm );
+ if( HasCId() )
+ MakeCIdURL( rEmbGrfNm );
+ pLink = &rEmbGrfNm;
+ }
+ else
+ {
+ nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
+ }
+ }
+ }
+ else
+ {
+ rEmbGrfNm = *pLink;
+ if( HasCId() || bCfgCpyLinkedGrfs )
+ {
+ CopyLocalFileToINet( rEmbGrfNm, HasCId() );
+ if( HasCId() )
+ MakeCIdURL( rEmbGrfNm );
+ pLink = &rEmbGrfNm;
+ }
+ }
+
+ if( pLink )
+ {
+ ByteString sOut( ' ' );
+ String s( INetURLObject::AbsToRel( *pLink,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET ));
+ (sOut += sHTML_O_background) += "=\"";
+ Strm() << sOut.GetBuffer();
+ HTMLOutFuncs::Out_String( Strm(), s, eDestEnc ) << '\"';
+ }
+}
+
+void SwHTMLWriter::OutBackground( const SfxItemSet& rItemSet,
+ String& rEmbGrfNm, sal_Bool bGraphic )
+{
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ))
+ {
+ OutBackground( ((const SvxBrushItem*)pItem), rEmbGrfNm, bGraphic );
+ }
+}
+
+void SwHTMLWriter::GetIndentString( ByteString& rStr, sal_uInt16 nIncLvl )
+{
+ // etwas umstaendlich, aber wir haben nur einen Indent-String!
+ sal_uInt16 nLevel = nIndentLvl + nIncLvl;
+
+ if( nLevel && nLevel <= MAX_INDENT_LEVEL)
+ {
+ sIndentTabs[nLevel] = 0;
+ rStr = sIndentTabs;
+ sIndentTabs[nLevel] = '\t';
+ }
+}
+
+void SwHTMLWriter::OutNewLine( sal_Bool bCheck )
+{
+ if( !bCheck || (Strm().Tell()-nLastLFPos) > nIndentLvl )
+ {
+ Strm() << sNewLine;
+ nLastLFPos = Strm().Tell();
+ }
+
+ if( nIndentLvl && nIndentLvl <= MAX_INDENT_LEVEL)
+ {
+ sIndentTabs[nIndentLvl] = 0;
+ Strm() << sIndentTabs;
+ sIndentTabs[nIndentLvl] = '\t';
+ }
+}
+
+sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
+{
+ sal_uInt16 nSize = 1;
+ for( sal_uInt16 i=6; i>0; i-- )
+ {
+ if( nHeight > (aFontHeights[i] + aFontHeights[i-1])/2 )
+ {
+ nSize = i+1;
+ break;
+ }
+ }
+
+ return nSize;
+}
+
+
+void SwHTMLWriter::MakeCIdURL( String& rURL )
+{
+ if( !aCId.Len() )
+ return;
+
+ INetURLObject aURLObj( rURL );
+ if( INET_PROT_FILE!=aURLObj.GetProtocol() )
+ return;
+
+ String aLastName( aURLObj.GetLastName() );
+ ASSERT( aLastName.Len(), "Dateiname ohne Laenge!" );
+ // TODO: unicode?
+ aLastName.ToLowerAscii();
+
+ rURL.AssignAscii( "cid:" );
+ ((rURL += aLastName) += '.') += aCId;
+}
+
+
+// Struktur speichert die aktuellen Daten des Writers zwischen, um
+// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
+HTMLSaveData::HTMLSaveData( SwHTMLWriter& rWriter, sal_uInt32 nStt, sal_uInt32 nEnd,
+ const SwFlyFrmFmt *pFly, sal_Bool bSaveNum )
+ : rWrt( rWriter ),
+ pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ),
+ pOldFlyFmt( rWrt.GetFlyFrmFmt() ), pOldNumRuleInfo( 0 ),
+ pOldNextNumRuleInfo( 0 ),
+ nOldDefListLvl( rWrt.nDefListLvl ),
+ bOldOutHeader( rWrt.bOutHeader ), bOldOutFooter( rWrt.bOutFooter )
+{
+ bOldWriteAll = rWrt.bWriteAll;
+
+ rWrt.pCurPam = rWrt.NewSwPaM( *rWrt.pDoc, nStt, nEnd );
+
+ // Tabelle in Sonderbereichen erkennen
+ if( nStt != rWrt.pCurPam->GetMark()->nNode.GetIndex() )
+ {
+ const SwNode *pNd = rWrt.pDoc->GetNodes()[ nStt ];
+ if( pNd->IsTableNode() || pNd->IsSectionNode() )
+ rWrt.pCurPam->GetMark()->nNode = nStt;
+ }
+
+ rWrt.SetEndPaM( rWrt.pCurPam );
+ rWrt.pCurPam->Exchange( );
+ rWrt.bWriteAll = sal_True;
+ rWrt.nDefListLvl = 0;
+ rWrt.bOutHeader = rWrt.bOutFooter = sal_False;
+
+ // Ggf. die aktuelle Numerierungs-Info merken, damit sie wieder
+ // neu aufgenommen werden kann. Nur dann belibt auch die Numerierungs-
+ // Info des nachsten Absatz gueltig.
+ if( bSaveNum )
+ {
+ pOldNumRuleInfo = new SwHTMLNumRuleInfo( rWrt.GetNumInfo() );
+ pOldNextNumRuleInfo = rWrt.GetNextNumInfo();
+ rWrt.SetNextNumInfo( 0 );
+ }
+ else
+ {
+ rWrt.ClearNextNumInfo();
+ }
+
+ // Die Numerierung wird in jedem Fall unterbrochen.
+ rWrt.GetNumInfo().Clear();
+ rWrt.SetFlyFrmFmt( pFly );
+}
+
+
+HTMLSaveData::~HTMLSaveData()
+{
+ delete rWrt.pCurPam; // Pam wieder loeschen
+
+ rWrt.pCurPam = pOldPam;
+ rWrt.SetEndPaM( pOldEnd );
+ rWrt.bWriteAll = bOldWriteAll;
+ rWrt.nLastParaToken = 0;
+ rWrt.nDefListLvl = nOldDefListLvl;
+ rWrt.bOutHeader = bOldOutHeader;
+ rWrt.bOutFooter = bOldOutFooter;
+
+ // Ggf. die Numerierung von vor der Section fortsetzen. Die Numerierung
+ // des naecshten Absatz wird in jedem Fall ungueltig.
+ if( pOldNumRuleInfo )
+ {
+ rWrt.GetNumInfo().Set( *pOldNumRuleInfo );
+ delete pOldNumRuleInfo;
+ rWrt.SetNextNumInfo( pOldNextNumRuleInfo );
+ }
+ else
+ {
+ rWrt.GetNumInfo().Clear();
+ rWrt.ClearNextNumInfo();
+ }
+ rWrt.SetFlyFrmFmt( pOldFlyFmt );
+}
+
+
+void GetHTMLWriter( const String&, WriterRef& xRet )
+{
+ xRet = new SwHTMLWriter;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/html/wrthtml.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.163 2000/09/18 16:04:48 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.162 2000/08/18 13:03:26 jp
+ don't export escaped URLs
+
+ Revision 1.161 2000/08/16 15:51:33 jp
+ OutSectionStartTag: write correct HTML
+
+ Revision 1.160 2000/06/26 12:55:06 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.159 2000/06/26 09:52:46 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.158 2000/05/15 10:06:57 os
+ Chg: GetOrigFileName()
+
+ Revision 1.157 2000/04/10 12:20:58 mib
+ unicode
+
+ Revision 1.156 2000/03/21 15:06:18 os
+ UNOIII
+
+ Revision 1.155 2000/03/03 16:29:44 pl
+ #73771# workaround for c50 intel compiler
+
+ Revision 1.154 2000/03/03 15:21:01 os
+ StarView remainders removed
+
+ Revision 1.153 2000/02/11 14:37:47 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.152 1999/11/22 08:31:09 mib
+ #67578#: wrong assert
+
+*************************************************************************/
+
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
new file mode 100644
index 000000000000..71407a1f1dcf
--- /dev/null
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -0,0 +1,614 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrthtml.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _WRTHTML_HXX
+#define _WRTHTML_HXX
+
+
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _SV_FIELD_HXX //autogen
+#include <vcl/field.hxx>
+#endif
+#define _SVSTDARR_STRINGSDTOR
+#define _SVSTDARR_STRINGSSORTDTOR
+#define _SVSTDARR_ULONGS
+#include <svtools/svstdarr.hxx>
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#include "shellio.hxx"
+#include "wrt_fn.hxx"
+
+// einige Forward Deklarationen
+class Color;
+class SwFrmFmt;
+class SwFlyFrmFmt;
+class SwDrawFrmFmt;
+class SwFmtINetFmt;
+class SwFmtVertOrient;
+class SwFmtFtn;
+class SwStartNode;
+class SwTableNode;
+class SwNoTxtNode;
+class SwPageDesc;
+class SwNodeIndex;
+class ImageMap;
+class SwNumRule;
+class SdrObject;
+class SvxBrushItem;
+class SvxFontItem;
+class SwHTMLNumRuleInfo;
+class SwHTMLPosFlyFrms;
+class SwHTMLTxtFtns;
+
+extern SwAttrFnTab aHTMLAttrFnTab;
+
+//#define HTML_PARSPACE ((MM50 * 7) / 10)
+#define HTML_PARSPACE (MM50)
+
+// Flags fuer die Ausgabe von Rahmen aller Art
+// BORDER geht nur bei OutHTML_Image
+// ANYSIZE gibt an, ob auch VAR_SIZE und MIN_SIZE angaben exportiert werden
+// ABSSIZE gibt an, ob Abstand und Umrandung ignoriert werden sollen
+const sal_uInt32 HTML_FRMOPT_ALIGN = 1<<0;
+const sal_uInt32 HTML_FRMOPT_S_ALIGN = 1<<1;
+
+const sal_uInt32 HTML_FRMOPT_WIDTH = 1<<2;
+const sal_uInt32 HTML_FRMOPT_HEIGHT = 1<<3;
+const sal_uInt32 HTML_FRMOPT_SIZE = HTML_FRMOPT_WIDTH|HTML_FRMOPT_HEIGHT;
+const sal_uInt32 HTML_FRMOPT_S_WIDTH = 1<<4;
+const sal_uInt32 HTML_FRMOPT_S_HEIGHT = 1<<5;
+const sal_uInt32 HTML_FRMOPT_S_SIZE = HTML_FRMOPT_S_WIDTH|HTML_FRMOPT_S_HEIGHT;
+const sal_uInt32 HTML_FRMOPT_ANYSIZE = 1<<6;
+const sal_uInt32 HTML_FRMOPT_ABSSIZE = 1<<7;
+const sal_uInt32 HTML_FRMOPT_MARGINSIZE = 1<<8;
+
+const sal_uInt32 HTML_FRMOPT_SPACE = 1<<9;
+const sal_uInt32 HTML_FRMOPT_S_SPACE = 1<<10;
+
+const sal_uInt32 HTML_FRMOPT_BORDER = 1<<11;
+const sal_uInt32 HTML_FRMOPT_S_BORDER = 1<<12;
+const sal_uInt32 HTML_FRMOPT_S_NOBORDER = 1<<13;
+
+const sal_uInt32 HTML_FRMOPT_S_BACKGROUND = 1<<14;
+
+const sal_uInt32 HTML_FRMOPT_NAME = 1<<15;
+const sal_uInt32 HTML_FRMOPT_ALT = 1<<16;
+const sal_uInt32 HTML_FRMOPT_BRCLEAR = 1<<17;
+const sal_uInt32 HTML_FRMOPT_S_PIXSIZE = 1<<18;
+const sal_uInt32 HTML_FRMOPT_ID = 1<<19;
+
+
+const sal_uInt32 HTML_FRMOPTS_GENIMG_ALL =
+ HTML_FRMOPT_ALT |
+ HTML_FRMOPT_SIZE |
+ HTML_FRMOPT_ABSSIZE |
+ HTML_FRMOPT_NAME;
+const sal_uInt32 HTML_FRMOPTS_GENIMG_CNTNR = HTML_FRMOPTS_GENIMG_ALL;
+const sal_uInt32 HTML_FRMOPTS_GENIMG =
+ HTML_FRMOPTS_GENIMG_ALL |
+ HTML_FRMOPT_ALIGN |
+ HTML_FRMOPT_SPACE |
+ HTML_FRMOPT_BRCLEAR;
+
+#define HTMLMODE_BLOCK_SPACER 0x00010000
+#define HTMLMODE_FLOAT_FRAME 0x00020000
+#define HTMLMODE_VERT_SPACER 0x00040000
+#define HTMLMODE_NBSP_IN_TABLES 0x00080000
+#define HTMLMODE_LSPACE_IN_NUMBUL 0x00100000
+#define HTMLMODE_NO_BR_AT_PAREND 0x00200000
+#define HTMLMODE_PRINT_EXT 0x00400000
+#define HTMLMODE_ABS_POS_FLY 0x00800000
+#define HTMLMODE_ABS_POS_DRAW 0x01000000
+#define HTMLMODE_FLY_MARGINS 0x02000000
+#define HTMLMODE_BORDER_NONE 0x04000000
+#define HTMLMODE_FONT_GENERIC 0x08000000
+#define HTMLMODE_FRSTLINE_IN_NUMBUL 0x10000000
+#define HTMLMODE_NO_CONTROL_CENTERING 0x20000000
+
+#define HTML_DLCOLL_DD 0x4000
+#define HTML_DLCOLL_DT 0x8000
+
+#define CSS1_FMT_ISTAG (USHRT_MAX)
+#define CSS1_FMT_CMPREF (USHRT_MAX-1)
+#define CSS1_FMT_SPECIAL (USHRT_MAX-1)
+
+// Die folgenden Flags bestimmen nur, welche Descriptoren, Tags, Optionen etc.
+// ausgegeben werden ...
+#define CSS1_OUTMODE_SPAN_NO_ON 0x0000
+#define CSS1_OUTMODE_SPAN_TAG_ON 0x0001
+#define CSS1_OUTMODE_STYLE_OPT_ON 0x0002
+#define CSS1_OUTMODE_RULE_ON 0x0003
+#define CSS1_OUTMODE_SPAN_TAG1_ON 0x0004
+#define CSS1_OUTMODE_ANY_ON 0x0007
+
+#define CSS1_OUTMODE_SPAN_NO_OFF 0x0000
+#define CSS1_OUTMODE_SPAN_TAG_OFF (0x0001 << 3)
+#define CSS1_OUTMODE_STYLE_OPT_OFF (0x0002 << 3)
+#define CSS1_OUTMODE_RULE_OFF (0x0003 << 3)
+#define CSS1_OUTMODE_SPAN_TAG1_OFF (0x0004 << 3)
+#define CSS1_OUTMODE_ANY_OFF (0x0007 << 3)
+
+#define CSS1_OUTMODE_ONOFF(a) (CSS1_OUTMODE_##a##_ON|CSS1_OUTMODE_##a##_OFF)
+#define CSS1_OUTMODE_SPAN_TAG CSS1_OUTMODE_ONOFF(SPAN_TAG)
+#define CSS1_OUTMODE_STYLE_OPT CSS1_OUTMODE_ONOFF(STYLE_OPT)
+#define CSS1_OUTMODE_RULE CSS1_OUTMODE_ONOFF(RULE)
+#define CSS1_OUTMODE_SPAN_TAG1 CSS1_OUTMODE_ONOFF(TAG1)
+
+// Die folgenden Flags legen fest, was ausgegeben wird
+#define CSS1_OUTMODE_TEMPLATE 0x0000
+#define CSS1_OUTMODE_BODY (0x0001 << 6)
+#define CSS1_OUTMODE_PARA (0x0002 << 6)
+#define CSS1_OUTMODE_HINT (0x0003 << 6)
+#define CSS1_OUTMODE_FRAME (0x0004 << 6)
+#define CSS1_OUTMODE_TABLE (0x0005 << 6)
+#define CSS1_OUTMODE_TABLEBOX (0x0006 << 6)
+#define CSS1_OUTMODE_DROPCAP (0x0007 << 6)
+#define CSS1_OUTMODE_SECTION (0x0008 << 6)
+#define CSS1_OUTMODE_SOURCE (0x000f << 6)
+
+#define CSS1_OUTMODE_ENCODE (0x0001 << 10)
+
+
+// der HTML-Writer
+struct HTMLControl;
+SV_DECL_PTRARR_SORT_DEL( HTMLControls, HTMLControl*, 1, 1 )
+SV_DECL_PTRARR( INetFmts, SwFmtINetFmt*, 1, 1 )
+
+struct SwHTMLFmtInfo;
+SV_DECL_PTRARR_SORT_DEL( SwHTMLFmtInfos, SwHTMLFmtInfo*, 1, 1 )
+
+class SwHTMLWriter : public Writer
+{
+ String aCId; // Content-Id fuer Mail-Export
+
+ SwHTMLPosFlyFrms *pHTMLPosFlyFrms;
+ SwHTMLNumRuleInfo *pNumRuleInfo;// aktuelle Numerierung
+ SwHTMLNumRuleInfo *pNextNumRuleInfo;
+ const SwFlyFrmFmt* pFlyFrmFmt; // liegt der Node in einem FlyFrame, ist
+ // das Format gesetzt, sonst 0. In Tabellen
+ // nur dann, wenn die Tabelle alleine
+ // im Rahmen ist.
+
+ sal_uInt32 nHTMLMode; // Beschreibung der Export-Konfiguration
+
+ FieldUnit eCSS1Unit;
+
+ sal_uInt16 OutHeaderAttrs();
+ const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
+ void GetControls();
+
+ void AddLinkTarget( const String& rURL );
+ void CollectLinkTargets();
+
+protected:
+ sal_uInt32 WriteStream();
+
+public:
+#if defined(MAC) || defined(UNX)
+ static const sal_Char sNewLine; // nur \012 oder \015
+#else
+ static const sal_Char __FAR_DATA sNewLine[]; // \015\012
+#endif
+
+ SvStringsDtor aImgMapNames; // geschriebene Image Maps
+ SvStringsSortDtor aImplicitMarks;// implizite Stprungmarken
+ SvStringsDtor aOutlineMarks; // geschriebene Image Maps
+ SvULongs aOutlineMarkPoss;
+ HTMLControls aHTMLControls; // die zu schreibenden ::com::sun::star::form::Forms
+ SwHTMLFmtInfos aChrFmtInfos;
+ SwHTMLFmtInfos aTxtCollInfos;
+ INetFmts aINetFmts; // die "offenen" INet-Attribute
+ SwHTMLTxtFtns *pFootEndNotes;
+
+ String aCSS1Selector; // der Selektor eines Styles
+ String aBulletGrfs[MAXLEVEL]; // die Grafiken fuer Listen
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > *pxFormComps; // die aktuelle Form
+
+ SwDoc *pTemplate; // die HTML-Vorlage
+ Color *pDfltColor; // default Farbe
+ SwNodeIndex *pStartNdIdx; // Index des ersten Absatz
+ const SwPageDesc *pCurrPageDesc;// Die aktuelle Seiten-Vorlage
+ const SwFmtFtn *pFmtFtn;
+
+ sal_uInt32 aFontHeights[7]; // die Font-Hoehen 1-7
+
+ sal_uInt32 nWarn; // Result-Code fuer Warnungen
+ xub_StrLen nLastLFPos; // letzte Position eines LF
+
+ sal_uInt16 nLastParaToken; // fuers Absaetze zusammenhalten
+ sal_uInt16 nBkmkTabPos; // akt. Position in der Bookmark-Tabelle
+ sal_uInt16 nImgMapCnt; // zum eindeutig
+ sal_uInt16 nFormCntrlCnt;
+ sal_uInt16 nEndNote;
+ sal_uInt16 nFootNote;
+ sal_uInt16 nLeftMargin; // linker Einzug (z.B. aus Listen)
+ sal_uInt16 nDfltLeftMargin; // die dafaults, der nicht geschrieben
+ sal_uInt16 nDfltRightMargin; // werden muessen (aus der Vorlage)
+ short nFirstLineIndent; // Erstzeilen-Einzug (aus Listen)
+ short nDfltFirstLineIndent; // nicht zu schreibender default
+ sal_uInt16 nDfltTopMargin; // die defaults, der nicht geschrieben
+ sal_uInt16 nDfltBottomMargin; // werden muessen (aus der Vorlage)
+ sal_uInt16 nIndentLvl; // wie weit ist eingerueckt?
+ xub_StrLen nWhishLineLen; // wie lang darf eine Zeile werden?
+ sal_uInt16 nDefListLvl; // welcher DL-Level existiert gerade
+ sal_uInt16 nDefListMargin; // Wie weit wird in DL eingerueckt
+ sal_uInt16 nHeaderFooterSpace;
+ sal_uInt16 nTxtAttrsToIgnore;
+ sal_uInt16 nExportMode;
+ sal_uInt16 nCSS1OutMode;
+
+ rtl_TextEncoding eDestEnc;
+
+ // Beschreibung der Export-Konfiguration
+ // 0
+ sal_Bool bCfgOutStyles : 1; // Styles exportieren
+ sal_Bool bCfgPreferStyles : 1; // Styles herkoemmlichen Tags vorziehen
+ sal_Bool bCfgFormFeed : 1; // Form-Feeds exportieren
+ sal_Bool bCfgStarBasic : 1; // StarBasic exportieren
+ sal_Bool bCfgCpyLinkedGrfs : 1;
+
+ // Beschreibung dessen, was exportiert wird
+
+ sal_Bool bFirstLine : 1; // wird die 1. Zeile ausgegeben ?
+ sal_Bool bTagOn : 1; // Tag an oder aus/Attr-Start oder -Ende
+
+ // Die folgenden beiden Flags geben an, wir Attribute exportiert werden:
+ // bTxtAttr bOutOpts
+ // 0 0 Style-Sheets
+ // 1 0 Hints: Jedes Attribut wird als eignes Tag
+ // geschrieben und es gibt ein End-Tag
+ // 0 1 (Absatz-)Attribute: Das Attribut wird als Option
+ // eines bereits geschrieben Tags exportiert. Es
+ // gibt kein End-Tag.
+ sal_Bool bTxtAttr : 1;
+ // 8
+ sal_Bool bOutOpts : 1;
+
+ sal_Bool bOutTable : 1; // wird der Tabelleninhalt geschrieben?
+ sal_Bool bOutHeader : 1;
+ sal_Bool bOutFooter : 1;
+
+ // Flags fuer Style-Export
+
+ sal_Bool bFirstCSS1Rule : 1; // wurde schon eine Property ausgegeben
+ sal_Bool bFirstCSS1Property : 1; // wurde schon eine Property ausgegeben
+ sal_Bool bPoolCollTextModified : 1; // die Textkoerper-Vorlage wurde
+ // modifiziert.
+ sal_Bool bCSS1IgnoreFirstPageDesc : 1;
+ // 16
+
+ // was muss/kann/darf nicht ausgegeben werden?
+
+ sal_Bool bNoAlign : 1; // HTML-Tag erlaubt kein ALIGN=...
+ sal_Bool bClearLeft : 1; // <BR CLEAR=LEFT> am Absatz-Ende ausg.
+ sal_Bool bClearRight : 1; // <BR CLEAR=RIGHT> am Absatz-Ende ausg.
+ sal_Bool bLFPossible : 1; // ein Zeilenumbruch darf eingef. werden
+
+ // sonstiges
+
+ sal_Bool bPreserveForm : 1; // die aktuelle Form beibehalten
+
+ sal_Bool bCfgNetscape4 : 1; // Netscape4 Hacks
+ // 22
+
+ SwHTMLWriter();
+ virtual ~SwHTMLWriter();
+
+ void Out_SwDoc( SwPaM* ); // schreibe den makierten Bereich
+
+ // gebe alle an in aktuellen Ansatz stehenden ::com::sun::star::text::Bookmarks aus
+ void OutAnchor( const String& rName );
+ void OutBookmarks();
+ void OutImplicitMark( const String& rMark, const sal_Char *pMarkType );
+
+ // gebe die evt. an der akt. Position stehenden FlyFrame aus.
+ sal_Bool OutFlyFrm( sal_uInt32 nNdIdx, xub_StrLen nCntntIdx,
+ sal_uInt8 nPos );
+ void OutFrmFmt( sal_uInt8 nType, const SwFrmFmt& rFmt,
+ const SdrObject *pSdrObj );
+
+ void OutForm( sal_Bool bTagOn=sal_True, const SwStartNode *pStNd=0 );
+ void OutHiddenForms();
+ void OutHiddenForm( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::form::XForm > & rForm );
+
+ void OutForm( sal_Bool bOn, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > & rFormComps );
+ void OutHiddenControls( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XIndexContainer > & rFormComps,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropSet );
+ sal_Bool HasControls() const;
+
+ void OutFootEndNoteInfo();
+ void OutFootEndNotes();
+ xub_StrLen GetFootEndNoteSymLen( const SwFmtFtn& rFmtFtn );
+ void OutFootEndNoteSym( const SwFmtFtn& rFmtFtn );
+
+#ifdef JAVA_BASIC_IDE
+ void OutBasicModule( const String& rName, const String& rLanguage );
+#endif
+ void OutBasic();
+
+ void OutAndSetDefList( sal_uInt16 nNewLvl );
+
+ void OutStyleSheet( const SwPageDesc& rPageDesc, sal_Bool bUsed=sal_True );
+
+ inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
+ const sal_Char *pVal );
+ inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
+ const ByteString& rVal );
+ inline void OutCSS1_Property( const sal_Char *pProp, const String& rVal );
+ void OutCSS1_Property( const sal_Char *pProp, const sal_Char *pVal,
+ const String *pSVal );
+ void OutCSS1_UnitProperty( const sal_Char *pProp, long nVal );
+ void OutCSS1_PixelProperty( const sal_Char *pProp, long nVal, sal_Bool bVert );
+ void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, sal_Bool bDeep=sal_True );
+#if USED
+ void OutCSS1_SfxItem( const SfxPoolItem *pItem1,
+ const SfxPoolItem *pItem2 = 0 );
+#endif
+
+ // BODY-Tag-Events aus der SFX-Konfigaurion
+ void OutBasicBodyEvents();
+
+ // BACKGROUND/BGCOLOR-Option
+ void OutBackground( const SvxBrushItem *pBrushItem, String& rEmbGrfNm,
+ sal_Bool bGraphic );
+ void OutBackground( const SfxItemSet& rItemSet, String &rEmbGrfName,
+ sal_Bool bGraphic );
+
+ // ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE-Optionen des aktuellen
+ // Frame-Formats ausgeben und ggf. ein <BR CLEAR=...> vorne an
+ // rEndTags anhaengen
+ void OutFrmFmtOptions( const SwFrmFmt& rFrmFmt, const String& rAltTxt,
+ ByteString &rEndTags, sal_uInt32 nFrmOpts );
+ void OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt );
+ void OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt );
+ void OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, sal_uInt32 nFrmOpts,
+ const SdrObject *pSdrObj=0,
+ const SfxItemSet *pItemSet=0 );
+ void OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt );
+
+ void ChangeParaToken( sal_uInt16 nNew );
+
+ // Umgebendes FlyFrmFmt
+ const SwFlyFrmFmt *GetFlyFrmFmt() const { return pFlyFrmFmt; }
+ void SetFlyFrmFmt( const SwFlyFrmFmt *pFly ) { pFlyFrmFmt = pFly; }
+
+ void IncIndentLevel() { nIndentLvl++; }
+ void DecIndentLevel() { if ( nIndentLvl ) nIndentLvl--; }
+ void GetIndentString( ByteString& rStr, sal_uInt16 nIncLvl=0 );
+
+ xub_StrLen GetLineLen() { return (xub_StrLen)(Strm().Tell()-nLastLFPos); }
+ void OutNewLine( sal_Bool bCheck=sal_False );
+
+ // fuer HTMLSaveData
+ SwPaM* GetEndPaM() { return pOrigPam; }
+ void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; }
+
+ sal_uInt32 ToPixel( sal_uInt32 nVal ) const;
+
+ sal_uInt16 GuessFrmType( const SwFrmFmt& rFrmFmt,
+ const SdrObject*& rpStrObj );
+ sal_uInt16 GuessOLENodeFrmType( const SwNode& rNd );
+
+ void CollectFlyFrms();
+
+ sal_uInt16 GetHTMLFontSize( sal_uInt32 nFontHeight ) const;
+
+ // Die aktuelle Numerierungs-Information holen.
+ SwHTMLNumRuleInfo& GetNumInfo() { return *pNumRuleInfo; }
+
+ // Die Numerierungs-Information des naechsten Absatz holen. Sie
+ // muss noch nicht vorhanden sein!
+ SwHTMLNumRuleInfo *GetNextNumInfo() { return pNextNumRuleInfo; }
+
+ // Die Numerierungs-Information des naechsten Absatz setzen.
+ void SetNextNumInfo( SwHTMLNumRuleInfo *pNxt ) { pNextNumRuleInfo=pNxt; }
+
+ // Die Numerierungs-Information des naeschten Absatz fuellen.
+ void FillNextNumInfo();
+
+ // Die Numerierungs-Information des naeschten Absatz loeschen.
+ void ClearNextNumInfo();
+
+ static const SdrObject *GetHTMLControl( const SwDrawFrmFmt& rFmt );
+ static const SdrObject *GetMarqueeTextObj( const SwDrawFrmFmt& rFmt );
+ static sal_uInt16 GetCSS1Selector( const SwFmt *pFmt, ByteString& rToken,
+ String& rClass, sal_uInt16& rRefPoolId,
+ String *pPseudo=0 );
+
+ static const SwFmt *GetTemplateFmt( sal_uInt16 nPoolId, SwDoc *pTemplate );
+ static const SwFmt *GetParentFmt( const SwFmt& rFmt, sal_uInt16 nDeep );
+
+ static void SubtractItemSet( SfxItemSet& rItemSet,
+ const SfxItemSet& rRefItemSet,
+ sal_Bool bSetDefaults,
+ sal_Bool bClearSame = sal_True );
+
+ static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
+ const SdrObject *pObj,
+ sal_Bool bSetDefaults );
+
+ static sal_uInt16 GetDefListLvl( const String& rNm, sal_uInt16 nPoolId );
+
+ sal_uInt32 GetHTMLMode() const { return nHTMLMode; }
+ sal_Bool IsHTMLMode( sal_uInt32 nMode ) const { return (nHTMLMode & nMode) != 0; }
+
+ inline sal_Bool IsCSS1Source( sal_uInt16 n ) const;
+ sal_Bool HasCId() const { return aCId.Len() > 0; }
+ void MakeCIdURL( String& rURL );
+
+ static const sal_Char *GetNumFormat( sal_uInt16 nFmt );
+ static void PrepareFontList( const SvxFontItem& rFontItem, String& rNames,
+ sal_Unicode cQuote, sal_Bool bGeneric );
+
+ FieldUnit GetCSS1Unit() const { return eCSS1Unit; }
+};
+
+inline sal_Bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
+{
+ return n == (nCSS1OutMode & CSS1_OUTMODE_SOURCE);
+}
+
+inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
+ const sal_Char *pVal )
+{
+ OutCSS1_Property( pProp, pVal, 0 );
+}
+
+inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
+ const ByteString& rVal )
+{
+ OutCSS1_Property( pProp, rVal.GetBuffer(), 0 );
+}
+
+inline void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
+ const String& rVal )
+{
+ OutCSS1_Property( pProp, 0, &rVal );
+}
+
+// Struktur speichert die aktuellen Daten des Writers zwischen, um
+// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
+// Mit den beiden USHORTs im CTOR wird ein neuer PaM erzeugt und auf
+// die Position im Dokument gesetzt.
+// Im Destructor werden alle Daten wieder restauriert und der angelegte
+// Pam wieder geloescht.
+
+struct HTMLSaveData
+{
+ SwHTMLWriter& rWrt;
+ SwPaM* pOldPam, *pOldEnd;
+ SwHTMLNumRuleInfo *pOldNumRuleInfo; // Owner = this
+ SwHTMLNumRuleInfo *pOldNextNumRuleInfo; // Owner = HTML-Writer
+ sal_uInt16 nOldDefListLvl;
+ sal_Bool bOldWriteAll : 1;
+ sal_Bool bOldOutHeader : 1;
+ sal_Bool bOldOutFooter : 1;
+ const SwFlyFrmFmt* pOldFlyFmt;
+
+ HTMLSaveData( SwHTMLWriter&, sal_uInt32 nStt, sal_uInt32 nEnd,
+ const SwFlyFrmFmt* pFly, sal_Bool bSaveNum=sal_True );
+ ~HTMLSaveData();
+};
+
+
+// einige Funktions-Deklarationen
+Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFmt,
+ sal_Bool bInCntnr );
+Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFmt,
+ sal_Bool bInCntnr );
+
+Writer& OutHTML_SwTxtNode( Writer&, const SwCntntNode& );
+Writer& OutHTML_SwTblNode( Writer& , SwTableNode &, const SwFrmFmt *,
+ const String* pCaption=0, sal_Bool bTopCaption=sal_False );
+
+Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt, const SwDrawFrmFmt& rFmt,
+ const SdrObject& rSdrObj, sal_Bool bInCntnr );
+Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt, const SwDrawFrmFmt& rFmt,
+ const SdrObject& rSdrObj );
+
+Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrmFmt& rFrmFmt,
+ sal_Bool bHeader );
+
+Writer& OutHTML_Image( Writer&, const SwFrmFmt& rFmt,
+ const String& rGrfName, const String& rAlternateTxt,
+ const Size& rRealSize, sal_uInt32 nFrmOpts,
+ const sal_Char *pMarkType = 0,
+ const ImageMap *pGenImgMap = 0 );
+Writer& OutHTML_BulletImage( Writer& rWrt, const sal_Char *pTag,
+ const SvxBrushItem* pBrush, String &rGrfName,
+ const Size &rSize,
+ const SwFmtVertOrient* pVertOrient );
+
+Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt );
+Writer& OutHTML_SwFmtFtn( Writer& rWrt, const SfxPoolItem& rHt );
+Writer& OutHTML_INetFmt( Writer&, const SwFmtINetFmt& rINetFmt, sal_Bool bOn );
+
+Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet,
+ String aEmbBGGrfName );
+Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
+
+Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
+Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
+
+Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
+Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
+ sal_uInt8 nLevel );
+
+Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
+ const SwHTMLNumRuleInfo& rInfo );
+Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
+ const SwHTMLNumRuleInfo& rNextInfo );
+
+
+#endif // _WRTHTML_HXX
+
diff --git a/sw/source/filter/inc/fltbase.hxx b/sw/source/filter/inc/fltbase.hxx
new file mode 100644
index 000000000000..b739718d7b42
--- /dev/null
+++ b/sw/source/filter/inc/fltbase.hxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * $RCSfile: fltbase.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 __FLTBASE_HXX__
+#define __FLTBASE_HXX__
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+
+class SwFilterBase
+{
+protected:
+ SvStream *pIn;
+ sal_Char *pReadBuff; // Groessenangabe
+ INT32 nBytesLeft; // noch zu lesende Bytes des aktuelle Records
+
+ CharSet eQuellChar; // Quell-Zeichensatz (interner Zeichensatz)
+// CharSet eZielChar; // Ziel-Zeichensatz
+
+ USHORT nTab; // z.Zt. bearbeitete Tabelle
+ USHORT nReadBuffSize;// temporaerer Lesepuffer mit
+
+ // ----------------------------------------------------------
+ inline void ReadChar( char &rC );
+ inline void ReadByte( BYTE &rN );
+ inline void Read( short &rN );
+ inline void ReadUnicode( sal_Unicode &rU );
+ inline void Read( BYTE &rN0, USHORT &rN1, USHORT &rN2 );
+ inline void Read( USHORT &rN );
+ inline void Read( USHORT &rN1, USHORT &rN2 );
+ inline void Read( USHORT &rN1, USHORT &rN2, USHORT &rN3, USHORT &rN4 );
+ inline void Read( double &rF );
+ void Read( String &rS ); // liest 0-terminierten C-String!
+ inline void ClearBytesLeft( void );
+};
+
+
+inline void SwFilterBase::ReadChar( char &rC )
+ {
+ *pIn >> rC;
+ nBytesLeft--;
+ }
+
+inline void SwFilterBase::ReadByte( BYTE &rN )
+ {
+ *pIn >> rN;
+ nBytesLeft--;
+ }
+
+inline void SwFilterBase::ReadUnicode( sal_Unicode &rU )
+{
+ {
+ sal_Char cC;
+ *pIn >> cC;
+ rU = ByteString::ConvertToUnicode(cC, eQuellChar);
+ nBytesLeft--;
+ }
+}
+
+inline void SwFilterBase::Read( short &rN )
+ {
+ *pIn >> rN;
+ nBytesLeft -= 2;
+ }
+
+inline void SwFilterBase::Read( BYTE &rN0, USHORT &rN1, USHORT &rN2 )
+ {
+ *pIn >> rN0 >> rN1 >> rN2;
+ nBytesLeft -= 5;
+ }
+
+inline void SwFilterBase::Read( USHORT &rN )
+ {
+ *pIn >> rN;
+ nBytesLeft -= 2;
+ }
+
+inline void SwFilterBase::Read( USHORT &rN1, USHORT &rN2 )
+ {
+ *pIn >> rN1 >> rN2;
+ nBytesLeft -= 4;
+ }
+
+inline void SwFilterBase::Read( USHORT &rN1, USHORT &rN2, USHORT &rN3, USHORT &rN4 )
+ {
+ *pIn >> rN1 >> rN2 >> rN3 >> rN4;
+ nBytesLeft -= 8;
+ }
+
+inline void SwFilterBase::Read( double &rF )
+ {
+ *pIn >> rF;
+ nBytesLeft -= 8;
+ }
+
+inline void SwFilterBase::ClearBytesLeft( void )
+ {
+ pIn->SeekRel( nBytesLeft );
+ nBytesLeft = 0;
+ }
+
+
+#endif
+
diff --git a/sw/source/filter/inc/fltglbls.hxx b/sw/source/filter/inc/fltglbls.hxx
new file mode 100644
index 000000000000..e0d1f2f80dc4
--- /dev/null
+++ b/sw/source/filter/inc/fltglbls.hxx
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * $RCSfile: fltglbls.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _FLTGLBS_HXX
+#define _FLTGLBS_HXX
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+#ifndef _LANG_HXX //autogen
+#include <tools/lang.hxx>
+#endif
+#ifndef _SVARRAY_HXX //autogen
+#include <svtools/svarray.hxx>
+#endif
+
+
+class SfxPoolItem;
+class SwDoc;
+class SwPaM;
+class SwTable;
+
+class XF_Buffer;
+class ColorBuffer;
+class FontBuffer;
+class SvNumberFormatter;
+
+
+class ExcGlob;
+extern ExcGlob *pExcGlob;
+
+class LotGlob;
+extern LotGlob *pLotGlob;
+
+// ----- Basis-Klasse ----------------------------------------------------
+class FilterGlobals
+{
+protected:
+ SvPtrarr aTblFmts;
+ USHORT nColStart;
+ USHORT nColEnd;
+ USHORT nRowStart;
+ USHORT nRowEnd;
+ USHORT nAnzCols;
+ USHORT nAnzRows;
+
+public:
+ FilterGlobals( SwDoc& rDoc, const SwPaM& rPam );
+ ~FilterGlobals();
+
+ SwDoc *pD;
+ SwPaM *pPam;
+ const SwTable *pTable;
+
+ SvNumberFormatter *pNumFormatter;
+ LanguageType eDefLanguage;
+ String aStandard; // fuer Excel-Standard-Format
+ ULONG nStandard;
+ ULONG nDefFormat; // = 0xFFFFFFFF
+
+ void SetRange( USHORT nCS, USHORT nCE, USHORT nRS, USHORT nRE );
+
+ BOOL IsInColRange( USHORT nCol )
+ { return ( nCol >= nColStart && nCol <= nColEnd ); }
+ BOOL IsInRowRange( USHORT nRow )
+ { return ( nRow >= nRowStart && nRow <= nRowEnd ); }
+ BOOL IsInRange( USHORT nCol, USHORT nRow )
+ { return IsInRowRange(nRow) && IsInColRange(nCol); }
+
+ void NormalizeCol( USHORT &rCol ) { rCol -= nColStart; }
+ void NormalizeRow( USHORT &rRow ) { rRow -= nRowStart; }
+ void Normalize( USHORT &rCol, USHORT &rRow )
+ { NormalizeCol( rCol ); NormalizeRow( rRow ); }
+
+ USHORT AnzCols() const { return nAnzCols; }
+ USHORT AnzRows() const { return nAnzRows; }
+
+ BOOL ColRangeLimitter( USHORT &rCS, USHORT &rCE );
+
+ void InsertText( USHORT nCol, USHORT nRow, const String& rStr );
+ void CreateTable();
+ void InsertAttr( const SfxPoolItem& rItem );
+
+ inline void ColLimitter( USHORT &rCol );
+ inline void RowLimitter( USHORT &rRow );
+#ifdef USED
+// inline BOOL RowRangeLimitter( USHORT &rRS, USHORT &rRE );
+#endif
+};
+
+
+
+
+
+// ----- for Excel-Import only -------------------------------------------
+
+enum ExcelRecordTypes { ERT_Biff2, ERT_Biff3, ERT_Biff4, ERT_Biff5 };
+
+class ExcGlob : public FilterGlobals
+{
+public:
+ ExcGlob( SwDoc& rDoc, const SwPaM& rPam );
+ ~ExcGlob();
+
+ XF_Buffer *pXF_Buff;
+ FontBuffer *pFontBuff;
+ ColorBuffer *pColorBuff;
+ ExcelRecordTypes eHauptDateiTyp;
+};
+
+// ----- for Lotus-Import only -------------------------------------------
+class LotGlob : public FilterGlobals
+{
+public:
+ LotGlob( SwDoc& rDoc, const SwPaM& rPam )
+ : FilterGlobals( rDoc, rPam ) {}
+};
+
+
+
+
+inline void FilterGlobals::ColLimitter( USHORT &rCol )
+{
+ if( rCol < nColStart )
+ rCol = nColStart;
+ else if( rCol > nColEnd )
+ rCol = nColEnd;
+}
+
+inline void FilterGlobals::RowLimitter( USHORT &rRow )
+{
+ if( rRow < nRowStart )
+ rRow = nRowStart;
+ else if( rRow > nRowEnd )
+ rRow = nRowEnd;
+}
+
+#ifdef USED
+
+inline BOOL FilterGlobals::RowRangeLimitter( USHORT &rRS, USHORT &rRE )
+ {
+ // PREC / POST: analog zu ColRangeLimitter
+ BOOL bRet;
+ DBG_ASSERT( rRS <= rRE,
+ "-FilterGlobals::RowRangeLimitter(): Startzeile > Endzeile!" );
+ if( rRS > nRowEnd || rRE < nRowStart )
+ bRet = FALSE;
+ else
+ {
+ bRet = TRUE;
+ if( rRS < nRowStart ) rRS = nRowStart;
+ if( rRE > nRowEnd ) rRE = nRowEnd;
+ }
+ return bRet;
+ }
+
+#endif
+
+
+#endif
+
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
new file mode 100644
index 000000000000..05abeedfe43c
--- /dev/null
+++ b/sw/source/filter/inc/fltini.hxx
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * $RCSfile: fltini.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _FLTINI_HXX
+#define _FLTINI_HXX
+
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _TOOLS_COLOR_HXX
+#include <tools/color.hxx>
+#endif
+
+class SwNumRuleTbl;
+class SwDoc;
+class SwTxtNode;
+class SwNodeNum;
+class SwNumRule;
+class SwNodeIndex;
+
+
+// die speziellen Reader
+
+class Sw6Reader: public Reader
+{
+ virtual ULONG Read( SwDoc &,SwPaM &,const String &);
+};
+
+class W4WReader: public StgReader
+{
+ String sVersion;
+ USHORT nFilter;
+ BOOL bStorageFlag;
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+ // wir wollen die Streams / Storages nicht geoeffnet haben
+ virtual int SetStrmStgPtr();
+public:
+ W4WReader() : StgReader(), nFilter(0), bStorageFlag(FALSE) {}
+ virtual int GetReaderType();
+ virtual void SetFltName( const String& rFltName );
+
+ USHORT GetFilter() const { return nFilter; }
+ const String& GetVersion() const { return sVersion; }
+};
+
+#ifdef DEBUG_SH
+
+class Internal_W4WReader: public W4WReader
+{
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+};
+
+#endif
+
+class ExcelReader : public StgReader
+{
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+public:
+ virtual int GetReaderType();
+};
+
+class LotusReader : public Reader
+{
+ CharSet eCodeSet;
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+public:
+ virtual void SetFltName( const String& rFltNm );
+};
+
+class HTMLReader: public Reader
+{
+ // wir wollen die Streams / Storages nicht geoeffnet haben
+ virtual int SetStrmStgPtr();
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+public:
+ HTMLReader();
+};
+
+class WW1Reader : public Reader
+{
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+};
+
+class WW8Reader : public StgReader
+{
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+public:
+ virtual int GetReaderType();
+
+ virtual BOOL HasGlossaries() const;
+ virtual BOOL ReadGlossaries( SwTextBlocks&, BOOL bSaveRelFiles ) const;
+};
+
+class XMLReader : public Reader
+{
+ virtual ULONG Read(SwDoc &,SwPaM &,const String &);
+public:
+ XMLReader();
+};
+
+// die speziellen Writer
+
+#if 0
+WriterRef GetW4WWriter( const String& );
+WriterRef GetStgWriter( const String& );
+WriterRef GetWWWriter( const String& );
+WriterRef GetWW8Writer( const String& );
+#if !( defined(PRODUCT) || defined(MAC) || defined(PM2) )
+WriterRef GetDebugWriter( const String& );
+WriterRef GetUndoWriter( const String& );
+#endif
+#else
+void GetW4WWriter( const String&, WriterRef& );
+void GetStgWriter( const String&, WriterRef& );
+void GetWWWriter( const String&, WriterRef& );
+void GetWW8Writer( const String&, WriterRef& );
+#if !( defined(PRODUCT) || defined(MAC) || defined(PM2) )
+void GetDebugWriter( const String&, WriterRef& );
+void GetUndoWriter( const String&, WriterRef& );
+#endif
+#endif
+
+// Zugriff auf die Ini-Datei
+ULONG ReadFilterFlags( const sal_Char* pName, const sal_Char* pAltName = 0 );
+
+// JP 17.03.99 - 63049
+// Umsetzen der LRSpaces im aktuell importierten Doc. Die Fremd-Filter
+// liefern immer absolute Werte fuer die Ebenen einer NumRule. Wir
+// verarbeiten jetzt aber relative Werte bezogen auf das LR-Space-Item.
+// Das hat zur Folge, das bei allen Absaetzen die EInzuege der NumRule vom
+// Absatz-Einzug abgezogen werden muss.
+class SwRelNumRuleSpaces
+{
+ SwNumRuleTbl* pNumRuleTbl; // Liste aller benannten NumRules
+ BOOL bNewDoc;
+
+ void SetNumLSpace( SwTxtNode& rNd, const SwNumRule& rRule );
+
+public:
+ SwRelNumRuleSpaces( SwDoc& rDoc, BOOL bNewDoc );
+ ~SwRelNumRuleSpaces();
+
+ void SetNumRelSpaces( SwDoc& rDoc );
+ void SetOultineRelSpaces( const SwNodeIndex& rStt,
+ const SwNodeIndex& rEnd );
+};
+
+#define SW_SV_BRUSH_25 0
+#define SW_SV_BRUSH_50 1
+#define SW_SV_BRUSH_75 2
+#define SW_SV_BRUSH_NULL 3
+#define SW_SV_BRUSH_SOLID 4
+#define SW_SV_BRUSH_INVALID 5
+
+Color ConvertBrushStyle(const Color& rCol, const Color& rFillCol, BYTE nStyle);
+
+// Get size of fly (if 'automatic' in WW) and check if not too small
+void CalculateFlySize( SfxItemSet& rFlySet, SwNodeIndex& rAnchor,
+ SwTwips nPageWidth );
+
+#endif _FLTINI_HXX
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
new file mode 100644
index 000000000000..7b1379928320
--- /dev/null
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -0,0 +1,675 @@
+/*************************************************************************
+ *
+ * $RCSfile: fltshell.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _FLTSHELL_HXX
+#define _FLTSHELL_HXX
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _KEYCOD_HXX //autogen
+#include <vcl/keycod.hxx>
+#endif
+#ifndef _DATETIME_HXX //autogen
+#include <tools/datetime.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+
+
+#ifndef _FMTCOL_HXX
+#include <fmtcol.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+
+class SwFlyFrmFmt;
+class SwTOXBase;
+class SwNumRule;
+class SwFltShell;
+class SwFmtFld;
+class SwField;
+class Graphic;
+class SwTableLines;
+class SwTableBoxes;
+class SwTableBox;
+class SwTableLine;
+class International;
+class DateTime;
+
+
+inline void SwFltClearFlag(ULONG& rFieldFlags, int no)
+ { rFieldFlags &= ~(1L << no); }
+
+inline void SwFltSetFlag(ULONG& rFieldFlags, int no)
+ { rFieldFlags |= 1L << no; }
+
+inline BOOL SwFltGetFlag(ULONG nFieldFlags, int no)
+ { return (nFieldFlags & (1L << no)) != 0; }
+
+// Stack-Eintrag fuer die Attribute Es werden immer Pointer auf neue Attribute uebergeben.
+class SwFltStackEntry
+{
+public:
+ SwNodeIndex nMkNode;
+ SwNodeIndex nPtNode;
+ SfxPoolItem * pAttr;// Format Attribute
+ long nHandle; // fuer verschachtelte Attrs, z.B. Bookmarks
+ xub_StrLen nMkCntnt;// Nachbildung von Mark()
+ xub_StrLen nPtCntnt;// Nachbildung von GetPoint()
+
+ BOOL bOld; // to mark Attributes *before* skipping field results
+ BOOL bLocked;
+ BOOL bCopied;
+
+ SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt );
+ SwFltStackEntry(const SwFltStackEntry& rEntry);
+ ~SwFltStackEntry();
+
+ void SetStartPos(const SwPosition & rStartPos);
+ void SetEndPos( const SwPosition & rEndPos);
+ BOOL MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck );
+};
+
+// ein Stack fuer die gesamten Text-Attribute
+typedef SwFltStackEntry* SwFltStackEntryPtr;
+
+SV_DECL_PTRARR(SwFltControlStackEntries,SwFltStackEntryPtr,5,10)
+
+class SwFltControlStack : public SwFltControlStackEntries
+{
+ friend SwFltShell;
+
+ ULONG nFieldFlags;
+ KeyCode aEmptyKeyCode; // fuer Bookmarks
+
+ BOOL IsAttrOpen(USHORT nAttrId);
+
+ void MoveAttrs( const SwPosition& rPos );
+
+protected:
+ SwDoc* pDoc;
+ BOOL bIsEndStack;
+
+ virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry);
+
+public:
+ enum Flags
+ {
+ HYPO,
+ TAGS_DO_ID,
+ TAGS_VISIBLE,
+ BOOK_TO_VAR_REF,
+ BOOK_AND_REF,
+ TAGS_IN_TEXT,
+ ALLOW_FLD_CR,
+ NO_FLD_CR,
+ DONT_HARD_PROTECT
+ };
+
+ SwFltControlStack(SwDoc* pDo, ULONG nFieldFl);
+ ~SwFltControlStack();
+
+ BOOL IsFlagSet(Flags no) const { return ::SwFltGetFlag(nFieldFlags, no);}
+
+ void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
+// BOOL SetAttr(const SwPosition& rPos, USHORT nAttrId=0, BOOL bTstEnde=TRUE);
+ // SetAttr mit Handle fuer verschachtelte Attrs, z.B. Bookmarks
+ BOOL SetAttr(const SwPosition& rPos, USHORT nAttrId=0, BOOL bTstEnde=TRUE,
+ long nHand = LONG_MAX);
+
+ void StealAttr(const SwPosition* pPos, USHORT nAttrId = 0);
+ void MoveAttrsToNextNode( const SwNodeIndex& rNdIdx );
+ void MarkAllAttrsOld();
+ void KillUnlockedAttrs(const SwPosition& pPos);
+ SfxPoolItem* GetFmtStackAttr(USHORT nWhich, USHORT * pPos = 0);
+ const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, USHORT nWhich);
+ const SfxPoolItem* GetFmtAttr(const SwPosition& rPos, USHORT nWhich);
+};
+
+class SwFltAnchor : public SfxPoolItem
+{
+ SwFrmFmt* pFrmFmt;
+public:
+ SwFltAnchor(SwFrmFmt* pFlyFmt);
+ SwFltAnchor(const SwFltAnchor&);
+ // "pure virtual Methoden" vom SfxPoolItem
+ virtual int operator==(const SfxPoolItem&) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+ const SwFrmFmt* GetFrmFmt() const { return pFrmFmt; }
+ SwFrmFmt* GetFrmFmt() { return pFrmFmt; }
+};
+
+class SwFltRedline : public SfxPoolItem
+{
+public:
+ DateTime aStamp;
+ DateTime aStampPrev;
+ SwRedlineType eType;
+ SwRedlineType eTypePrev;
+ USHORT nAutorNo;
+ USHORT nAutorNoPrev;
+
+ SwFltRedline(SwRedlineType eType_,
+ USHORT nAutorNo_,
+ const DateTime& rStamp_,
+ SwRedlineType eTypePrev_ = REDLINE_INSERT,
+ USHORT nAutorNoPrev_ = USHRT_MAX,
+ const DateTime* pStampPrev_ = 0)
+ : eType( eType_ ), nAutorNo( nAutorNo_ ), aStamp( rStamp_ ),
+ eTypePrev( eTypePrev_ ), nAutorNoPrev( nAutorNoPrev_ )
+ {
+ if( pStampPrev_ )
+ aStampPrev = *pStampPrev_;
+ }
+
+ SwFltRedline(const SwFltRedline& rCpy):
+ SfxPoolItem(RES_FLTR_REDLINE),
+ eType( rCpy.eType ),
+ nAutorNo( rCpy.nAutorNo ),
+ aStamp( rCpy.aStamp ),
+ eTypePrev( rCpy.eTypePrev ),
+ nAutorNoPrev( rCpy.nAutorNoPrev ),
+ aStampPrev( rCpy.aStampPrev )
+ {}
+ // "pure virtual Methoden" vom SfxPoolItem
+ virtual int operator==(const SfxPoolItem& rItem) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+};
+
+class SwFltBookmark : public SfxPoolItem
+{
+friend class SwFltShell; // darf aName und aVal uebersetzen
+ long nHandle;
+ String aName;
+ String aVal;
+ BOOL bOnlyRef; // "FRAGE"-Feld, Ref/Seitenrf oder nichts
+ BOOL bRef;
+ BOOL bPgRef;
+public:
+ SwFltBookmark( const String& rNa, const String& rVa,
+ long nHand, BOOL bOnlyR );
+ SwFltBookmark( const SwFltBookmark& );
+ // "pure virtual Methoden" vom SfxPoolItem
+ virtual int operator==(const SfxPoolItem&) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+ const String& GetName() const { return aName; }
+ const String& GetValSys() const { return aVal; }
+ BOOL IsOnlyRef() const { return bOnlyRef; }
+ BOOL IsRef() const { return bRef; }
+ void SetRef(BOOL b = TRUE) { bRef = b; }
+ BOOL IsPgRef() const { return bPgRef; }
+ void SetPgRef(BOOL b = TRUE) { bPgRef = b; }
+ long GetHandle() const { return nHandle; }
+};
+
+class SwFltTOX : public SfxPoolItem
+{
+ SwTOXBase* pTOXBase;
+ USHORT nCols;
+ BOOL bHadBreakItem; // there was a break item BEFORE insertion of the TOX
+ BOOL bHadPageDescItem; // ...
+public:
+ SwFltTOX(SwTOXBase* pBase, USHORT _nCols = 0);
+ SwFltTOX(const SwFltTOX&);
+ // "pure virtual Methoden" vom SfxPoolItem
+ virtual int operator==(const SfxPoolItem&) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+ SwTOXBase* GetBase() { return pTOXBase; }
+ USHORT GetCols() const { return nCols; }
+ void SetHadBreakItem( BOOL bVal ) { bHadBreakItem = bVal; }
+ void SetHadPageDescItem( BOOL bVal ) { bHadPageDescItem = bVal; }
+ BOOL HadBreakItem() const { return bHadBreakItem; }
+ BOOL HadPageDescItem() const { return bHadPageDescItem; }
+};
+
+class SwFltSection : public SfxPoolItem
+{
+ SwSection* pSection;
+public:
+ SwFltSection( SwSection* pSect );
+ SwFltSection( const SwFltSection& );
+ // "pure virtual Methoden" vom SfxPoolItem
+ virtual int operator==(const SfxPoolItem&) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* = 0) const;
+ SwSection* GetSection() { return pSection; }
+};
+// Der WWEndStack verhaelt sich wie der WWControlStck, nur dass die Attribute
+// auf ihm bis ans Ende des Dokuments gehortet werden, falls auf sie noch
+// zugegriffen werden muss (z.B. Book/RefMarks, Index u.s.w.)
+class SwFltEndStack : public SwFltControlStack
+{
+public:
+ SwFltEndStack(SwDoc* pDo, ULONG nFieldFl)
+ :SwFltControlStack(pDo, nFieldFl)
+ {
+ bIsEndStack = TRUE;
+ }
+
+ void SetBookRef( const String& rName, BOOL bPgRef = FALSE );
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////
+//
+// hier beginnen die fuer ww1-filter neu erstellten klassen. diese
+// sollen eine simple oberflaeche fuer die komplexen strukturen des
+// writers speziell fuer filter sein. soll etwas in den writer gegeben
+// werden, soll ein << reichen. hierfuer sind neue typen erzeugt
+// worden. ausserdem soll moeglich sein das objekt nach vielen
+// zustaenden der momentanen formatierung zu fragen, sodasz diese der
+// filter nicht selbst verwalten musz.
+//
+// den anfang macht eine vorlagen-oberklasse, die einfachen umgang mit
+// formatvorlagen ermoeglicht:
+//
+
+class SwFltOutBase
+{
+ SwDoc& rDoc;
+protected:
+ RndStdIds eFlyAnchor;
+ BOOL bFlyAbsPos;
+
+ SwDoc& GetDoc() { return rDoc; }
+ SfxItemSet* NewFlyDefaults();
+
+ SwFltOutBase(SwDoc& rDocu)
+ : rDoc(rDocu), bFlyAbsPos(FALSE), eFlyAnchor(FLY_AT_CNTNT)
+ {}
+
+public:
+ virtual SwFltOutBase& operator << (const SfxPoolItem& rItem) = 0;
+
+ virtual const SfxPoolItem& GetAttr(USHORT nWhich) = 0;
+ virtual const SfxPoolItem& GetNodeOrStyAttr(USHORT nWhich) = 0;
+
+ virtual const SfxPoolItem& GetCellAttr(USHORT nWhich);
+ virtual BOOL BeginTable();
+ virtual void NextTableCell();
+ virtual void NextTableRow();
+ virtual void SetTableWidth(SwTwips nW);
+ virtual void SetTableOrient(SwHoriOrient eOri);
+ virtual void SetCellWidth(SwTwips nWidth, USHORT nCell);
+ virtual void SetCellHeight(SwTwips nH);
+ virtual void SetCellBorder(const SvxBoxItem& rFmtBox, USHORT nCell);
+ virtual void SetCellSpace(USHORT nSp);
+ virtual void DeleteCell(USHORT nCell);
+ virtual void EndTable();
+
+ virtual BOOL IsInFly() = 0;
+ virtual void SetFlyFrmAttr(const SfxPoolItem& rAttr) = 0;
+ virtual const SfxPoolItem& GetFlyFrmAttr(USHORT nWhich) = 0;
+ virtual BOOL BeginFly( RndStdIds eAnchor, BOOL bAbsolutePos,
+ const SfxItemSet* pMoreAttrs = 0 );
+ virtual void SetFlyAnchor( RndStdIds eAnchor );
+ virtual void EndFly();
+};
+
+class SwFltOutDoc : public SwFltOutBase
+{
+ SwFltControlStack& rStack;
+ SwFltEndStack& rEndStack;
+ SwPaM* pPaM;
+ SwFrmFmt* pFly;
+// table items:
+ const SwTable* pTable;
+ SwPosition* pTabSavedPos; // set when in table
+ SwPosition* pFlySavedPos; // set when in fly
+ SwTwips nTableWidth;
+ USHORT usTableX;
+ USHORT usTableY;
+ BOOL bReadNoTbl; // Keine Tabellen
+
+ SwTableBox* GetBox(USHORT ny, USHORT nx = USHRT_MAX);
+ BOOL SeekCell( short nRow, short nCol, BOOL bPam );
+ void SplitTable();
+public:
+ SwFltOutDoc(SwDoc& rDocu, SwPaM* pP, SwFltControlStack& rStk, SwFltEndStack& rEStk)
+ :SwFltOutBase(rDocu), pPaM(pP), rStack(rStk), rEndStack(rEStk),
+ pFly(0), pTable(0), pTabSavedPos(0), pFlySavedPos(0),
+ nTableWidth(0), bReadNoTbl(FALSE)
+ {}
+
+ void SetReadNoTable() { bReadNoTbl = TRUE; }
+ BOOL IsTableWidthSet() const { return 0 != nTableWidth; }
+
+ virtual SwFltOutBase& operator << (const SfxPoolItem& rItem);
+
+ virtual const SfxPoolItem& GetAttr(USHORT nWhich);
+ virtual const SfxPoolItem& GetNodeOrStyAttr(USHORT nWhich);
+
+ BOOL IsInTable();
+ virtual const SfxPoolItem& GetCellAttr(USHORT nWhich);
+ virtual BOOL BeginTable();
+ virtual void NextTableCell();
+ virtual void NextTableRow();
+ virtual void SetTableWidth(SwTwips nW);
+ virtual void SetTableOrient(SwHoriOrient eOri);
+ virtual void SetCellWidth(SwTwips nWidth, USHORT nCell);
+ virtual void SetCellHeight(SwTwips nH);
+ virtual void SetCellBorder(const SvxBoxItem& rFmtBox, USHORT nCell);
+ virtual void SetCellSpace(USHORT nSp);
+ virtual void DeleteCell(USHORT nCell);
+ virtual void EndTable();
+
+ SwFrmFmt* MakeFly( RndStdIds eAnchor, SfxItemSet* pSet );
+ virtual BOOL IsInFly();
+ virtual void SetFlyFrmAttr(const SfxPoolItem& rAttr);
+ virtual const SfxPoolItem& GetFlyFrmAttr(USHORT nWhich);
+ virtual BOOL BeginFly( RndStdIds eAnchor, BOOL bAbsolutePos,
+ const SfxItemSet* pMoreAttrs = 0 );
+ virtual void EndFly();
+};
+
+class SwFltFormatCollection : public SwFltOutBase
+{
+ SwTxtFmtColl* pColl;
+ SfxItemSet* pFlyAttrs; // Simulation der Flys in Styles
+ BOOL bHasFly;
+public:
+ SwFltFormatCollection(SwDoc&, RES_POOL_COLLFMT_TYPE nType);
+ SwFltFormatCollection(SwDoc&, const String& rName );
+ ~SwFltFormatCollection() { if( pFlyAttrs ) delete pFlyAttrs; }
+
+ void Reset()
+ {
+ pColl->ResetAllAttr();
+ pColl->SetAuto(FALSE); // nach Empfehlung JP
+ }
+ void Derived(SwTxtFmtColl* pBase)
+ { pColl->SetDerivedFrom(pBase); }
+
+// SwTxtFmtColl* Search(String, CharSet eSrc);
+ SwTxtFmtColl* GetColl() { return pColl; }
+ void SetHasFly() { bHasFly = TRUE; }
+ SfxItemSet* GetpFlyAttrs() { return pFlyAttrs; }
+
+ virtual SwFltOutBase& operator << (const SfxPoolItem& rItem);
+ virtual const SfxPoolItem& GetAttr(USHORT nWhich);
+ virtual const SfxPoolItem& GetNodeOrStyAttr(USHORT nWhich);
+
+ virtual BOOL IsInFly();
+ virtual void SetFlyFrmAttr(const SfxPoolItem& rAttr);
+ virtual const SfxPoolItem& GetFlyFrmAttr(USHORT nWhich);
+ virtual BOOL BeginFly( RndStdIds eAnchor, BOOL bAbsolutePos,
+ const SfxItemSet* pMoreAttrs = 0 );
+ BOOL BeginStyleFly( SwFltOutDoc* pOutDoc );
+ virtual void EndFly();
+};
+
+//
+// dies nun ist die zauberhafteklasse: intention: alle eins nach dem
+// andern hinein'pipe'n. wird eine besondere struktur eingelesen, wird
+// eine klammer geoeffnet (BeginXxx) und nach beendigung geschlossen
+// (EndXxx), wobei Xxx zB fuer Fusznoten, Kopf/Fuszzeilen oder
+// Tabellen steht. Styles funktionieren auch so, haben aber den
+// unterschied, keine buchstaben zu akzeptieren.
+// beginnt ein neuer absatz oder aehnliches, wird NextXxx genutzt.
+// hier ist moeglich, Tab, Zeilenumbruch, Absatzende, Seitenumbruch
+// und Sektionsende einzufuegen.
+//
+class SwFltShell
+{
+ SwFltOutDoc* pOutDoc;
+ SwFltFormatCollection* pColls[256];
+ SwFltOutBase* pOut;
+
+// SwFltFormatCollection* pFormat; // set when in style-mode
+ SwPageDesc* pCurrentPageDesc;
+ SwPosition* pSavedPos; // set, when in footnote or header/footer -mode
+#ifdef None
+#undef None
+#endif
+ enum SubModes {
+ None,
+ Header,
+ Footer,
+ Footnote,
+ Table,
+ Fly,
+ Style,
+ Max
+ } eSubMode;
+
+// Fly items:
+ USHORT nAktStyle; // zur Indizierung pStyleFlyTable
+//
+ SwFltControlStack aStack;
+ SwFltEndStack aEndStack;
+ SwPaM* pPaM;
+//
+ USHORT nPageDescOffset; // fuers update der pagedescs
+ CharSet eSrcCharSet; // charset der quelle
+ friend SwFltControlStack;
+ BOOL bNewDoc;
+ BOOL bStdPD;
+ BOOL bProtect;
+
+public:
+ SwFltShell(SwDoc* , SwPaM& , BOOL bNew, ULONG = 0);
+ ~SwFltShell();
+
+ SwDoc& GetDoc() { return *aStack.pDoc; }
+
+ CharSet SetCharSet(CharSet eNew) { CharSet eOld = eSrcCharSet;
+ eSrcCharSet = eNew;
+ return eOld;
+ }
+ void SetUseStdPageDesc() { bStdPD = TRUE; }
+ void SetProtect() { bProtect = TRUE; }
+ SwPageDesc* MakePageDesc(SwPageDesc* pFirstPageDesc = NULL);
+ SwPageDesc& GetPageDesc() { return *pCurrentPageDesc; }
+ void NextTab() { (*this) << BYTE(0x09); }
+ void NextLine() { (*this) << BYTE(0x0a); }
+ void NextParagraph() { GetDoc().AppendTxtNode(*pPaM->GetPoint()); }
+ void NextPage() { NextParagraph();
+ GetDoc().Insert(*pPaM,
+ SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE));
+ }
+ void NextSection() { pCurrentPageDesc = MakePageDesc(); }
+
+ SwFltShell& AddGraphic( const String& rPicName );
+ SwFltShell& AddError( const sal_Char* pErr );
+ SwFltShell& AddLinkedSection( const String& rFileName );
+ SwFltShell& EndItem( USHORT nId );
+ SwFltShell& SetStyle( USHORT nStyle );
+
+ SwFltShell& operator << ( Graphic& );
+ SwFltShell& operator << ( SwFltBookmark& aBook );
+ void SetBookEnd(long nHandle);
+ SwFltShell& operator << ( const SwFltTOX& );
+ SwFltShell& operator << ( const String& ); // Vorsicht: CHARSET_ANSI
+ SwFltShell& operator << ( const sal_Unicode );
+ SwFltShell& operator << ( const SwField& );
+ SwFltShell& operator << ( const SfxPoolItem& rItem )
+ { *pOut << rItem; return *this; }
+
+// SwFltShell& operator >> (SfxPoolItem&);
+// methode zum beenden einer sub-sektion, zB Fusznote etc
+ void End() { eSubMode = None; }
+// methoden zur verwaltung von Header/Footer
+ void BeginHeader(SwPageDesc* =NULL);
+ void BeginFooter(SwPageDesc* =NULL);
+ void EndHeaderFooter();
+// methoden zur verwaltung von FootNotes
+ void BeginFootnote();
+ void EndFootnote();
+// methoden zur verwaltung von Tabellen
+ BOOL IsInTable() {
+ return ( pOut == pOutDoc ) ? pOutDoc->IsInTable() : 0; }
+ const SfxPoolItem& GetCellAttr(USHORT nWhich) {
+ return pOut->GetCellAttr(nWhich); }
+ BOOL BeginTable() {
+ BOOL b = pOut->BeginTable();
+ if(b) eSubMode = Table;
+ return b; }
+ void NextTableCell() {
+ pOut->NextTableCell(); }
+ void NextTableRow() {
+ pOut->NextTableRow(); }
+ void SetTableWidth(SwTwips nW) {
+ pOut->SetTableWidth(nW); }
+ BOOL IsTableWidthSet() {
+ return pOutDoc->IsTableWidthSet(); }
+ void SetTableOrient(SwHoriOrient eOri) {
+ pOut->SetTableOrient(eOri); }
+ void SetCellWidth(SwTwips nWidth, USHORT nCell = USHRT_MAX ) {
+ pOut->SetCellWidth(nWidth, nCell); }
+ void SetCellHeight(SwTwips nH) {
+ pOut->SetCellHeight(nH); }
+ void SetCellBorder(const SvxBoxItem& rFmtBox, USHORT nCell = USHRT_MAX ){
+ pOut->SetCellBorder(rFmtBox, nCell); }
+ void SetCellSpace(USHORT nSp) {
+ pOut->SetCellSpace(nSp); }
+ void DeleteCell(USHORT nCell = USHRT_MAX) {
+ pOut->DeleteCell(nCell); }
+ void EndTable() {
+ pOut->EndTable(); }
+// methoden zur verwaltung von Flys
+ BOOL IsInFly() { return pOut->IsInFly(); }
+ BOOL BeginFly( RndStdIds eAnchor = FLY_AT_CNTNT, BOOL bAbsolutePos = FALSE );
+ void SetFlyAnchor( RndStdIds eAnchor )
+ { pOut->SetFlyAnchor( eAnchor ); }
+ void SetFlyXPos( short nXPos,SwRelationOrient eHRel = FRAME,
+ SwHoriOrient eHAlign = HORI_NONE );
+ void SetFlyYPos( short nYPos, SwRelationOrient eVRel = FRAME,
+ SwVertOrient eVAlign = VERT_NONE );
+ void SetFlyFrmAttr(const SfxPoolItem& rAttr){
+ pOut->SetFlyFrmAttr( rAttr ); }
+ void EndFly();
+// methoden zur verwaltung von styles:
+ void BeginStyle(USHORT nUserCode, RES_POOL_COLLFMT_TYPE aType)
+ {
+ ASSERT(nUserCode<sizeof(pColls)/sizeof(*pColls), "code out of bounds");
+ ASSERT(pColls[nUserCode] == NULL, "user codes dublicate");
+ if (eSubMode == Style)
+ EndStyle();
+ pOut = pColls[nUserCode] = new SwFltFormatCollection(GetDoc(), aType);
+ nAktStyle = nUserCode;
+ eSubMode = Style;
+ }
+ void BeginStyle( USHORT nUserCode, const String& rName )
+ {
+ ASSERT(nUserCode<sizeof(pColls)/sizeof(*pColls), "code out of bounds");
+ ASSERT(pColls[nUserCode] == NULL, "user codes dublicate");
+ if (eSubMode == Style)
+ EndStyle();
+ pOut = pColls[nUserCode] = new SwFltFormatCollection(GetDoc(), rName );
+ nAktStyle = nUserCode;
+ eSubMode = Style;
+ }
+ BOOL IsStyleImported(USHORT nUserCode)
+ { return pColls[nUserCode] != 0; }
+ void BaseStyle(USHORT nBased)
+ {
+ ASSERT(eSubMode == Style, "wrong state for style");
+ ASSERT(pColls[nBased], "Style based on noexistent style" );
+ if( eSubMode == Style && pColls[nBased]->GetColl() )
+ ((SwFltFormatCollection*)pOut)->Derived(pColls[nBased]->GetColl());
+ }
+ void NextStyle(USHORT nWhich, USHORT nNext);
+
+ void EndStyle()
+ {
+// ASSERT(eSubMode == Style, "wrong state for style");
+ nAktStyle = 0;
+ pOut = pOutDoc;
+ eSubMode = None;
+ }
+
+ BOOL IsFlagSet(SwFltControlStack::Flags no) const
+ { return aStack.IsFlagSet(no); }
+ void ConvertUStr( String& rInOut );
+ void ConvertLStr( String& rInOut );
+ String QuoteStr( const String& rIn );
+// folgende status kann die shell verwalten:
+ const SfxPoolItem& GetNodeOrStyAttr(USHORT nWhich)
+ { return pOut->GetNodeOrStyAttr( nWhich ); }
+ const SfxPoolItem& GetAttr(USHORT nWhich)
+ { return pOut->GetAttr( nWhich ); }
+ const SfxPoolItem& GetFlyFrmAttr(USHORT nWhich)
+ { return pOut->GetFlyFrmAttr( nWhich ); }
+ SwFieldType *GetSysFldType(USHORT eWhich)
+ { return GetDoc().GetSysFldType(eWhich); }
+ BOOL GetWeightBold();
+ BOOL GetPostureItalic();
+ BOOL GetCrossedOut();
+ BOOL GetContour();
+ BOOL GetCaseKapitaelchen();
+ BOOL GetCaseVersalien();
+};
+
+
+#endif
diff --git a/sw/source/filter/inc/makefile.mk b/sw/source/filter/inc/makefile.mk
new file mode 100644
index 000000000000..c6cdee2c9c09
--- /dev/null
+++ b/sw/source/filter/inc/makefile.mk
@@ -0,0 +1,61 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
diff --git a/sw/source/filter/inc/rtf.hxx b/sw/source/filter/inc/rtf.hxx
new file mode 100644
index 000000000000..fc310f45398e
--- /dev/null
+++ b/sw/source/filter/inc/rtf.hxx
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * $RCSfile: rtf.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _RTF_HXX
+#define _RTF_HXX
+
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+
+// Umsetzung einiger FlyFrame-Attribute
+class RTFVertOrient
+{
+ union {
+ struct {
+ USHORT nOrient : 4;
+ USHORT nRelOrient : 1;
+ } Flags;
+ USHORT nVal;
+ } Value;
+
+public:
+ RTFVertOrient( USHORT nValue ) { Value.nVal = nValue; }
+
+ RTFVertOrient( USHORT nOrient, USHORT nRelOrient ) {
+ Value.Flags.nOrient = nOrient;
+ Value.Flags.nRelOrient = nRelOrient;
+ }
+
+ USHORT GetOrient() const { return Value.Flags.nOrient; }
+ USHORT GetRelation() const { return Value.Flags.nRelOrient; }
+ USHORT GetValue() const { return Value.nVal; }
+};
+
+
+class RTFHoriOrient
+{
+ union {
+ struct {
+ USHORT nOrient : 4;
+ USHORT nRelAnchor : 4;
+ USHORT nRelOrient : 1;
+ } Flags;
+ USHORT nVal;
+ } Value;
+
+public:
+ RTFHoriOrient( USHORT nValue ) { Value.nVal = nValue; }
+
+ RTFHoriOrient( USHORT nOrient, USHORT nRelOrient ) {
+ Value.Flags.nOrient = nOrient;
+ Value.Flags.nRelOrient = nRelOrient;
+ Value.Flags.nRelAnchor = 0;
+ }
+
+ USHORT GetOrient() const { return Value.Flags.nOrient; }
+ USHORT GetRelation() const { return Value.Flags.nRelOrient; }
+ USHORT GetValue() const { return Value.nVal; }
+};
+
+class RTFProtect
+{
+ union {
+ struct {
+ BOOL bCntnt : 1;
+ BOOL bSize : 1;
+ BOOL bPos : 1;
+ } Flags;
+ BYTE nVal;
+ } Value;
+public:
+ RTFProtect( BYTE nValue ) { Value.nVal = nValue; }
+
+ RTFProtect( BOOL bCntnt, BOOL bSize, BOOL bPos ) {
+ Value.Flags.bCntnt = bCntnt;
+ Value.Flags.bSize = bSize;
+ Value.Flags.bPos = bPos;
+ }
+
+ BOOL GetCntnt() const { return Value.Flags.bCntnt; }
+ BOOL GetSize() const { return Value.Flags.bSize; }
+ BOOL GetPos() const { return Value.Flags.bPos; }
+ USHORT GetValue() const { return Value.nVal; }
+};
+
+
+class RTFSurround
+{
+ union {
+ struct {
+ USHORT nGoldCut : 1;
+ USHORT nOrder : 4;
+ } Flags;
+ BYTE nVal;
+ } Value;
+public:
+ RTFSurround( BYTE nValue ) { Value.nVal = nValue; }
+
+ RTFSurround( BOOL bGoldCut, BYTE nOrder ) {
+ Value.Flags.nOrder = nOrder;
+ Value.Flags.nGoldCut = bGoldCut;
+ }
+
+ BYTE GetOrder() const { return (BYTE)Value.Flags.nOrder; }
+ BOOL GetGoldCut() const { return (BOOL)Value.Flags.nGoldCut; }
+ USHORT GetValue() const { return Value.nVal; }
+};
+
+#endif // _RTF_HXX
+
+
diff --git a/sw/source/filter/inc/wrt_fn.hxx b/sw/source/filter/inc/wrt_fn.hxx
new file mode 100644
index 000000000000..fe6f000083e7
--- /dev/null
+++ b/sw/source/filter/inc/wrt_fn.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrt_fn.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+ *
+ * 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 _WRT_FN_HXX
+#define _WRT_FN_HXX
+
+#include "hintids.hxx" // fuer die Konstanten
+
+// einige Forward-Deklarationen
+class SwFmt;
+class SwNode;
+class SwCntntNode;
+class Writer;
+class SfxPoolItem;
+class SfxItemSet;
+
+
+/* Funktionspointer auf die Attribut-Write-Funktionen */
+typedef Writer& (*FnAttrOut)( Writer&, const SfxPoolItem& );
+typedef FnAttrOut SwAttrFnTab[ POOLATTR_END - POOLATTR_BEGIN ];
+
+Writer& Out( const SwAttrFnTab, const SfxPoolItem&, Writer& );
+Writer& Out_SfxItemSet( const SwAttrFnTab, Writer&, const SfxItemSet&,
+ BOOL bDeep, BOOL bTstForDefault = TRUE );
+
+
+/* Funktionspointer auf die Node-Write-Funktionen */
+
+enum RES_NODE
+{
+RES_NODE_BEGIN = 0,
+ RES_TXTNODE = RES_NODE_BEGIN,
+ RES_GRFNODE,
+ RES_OLENODE,
+RES_NODE_END
+};
+
+typedef Writer& (*FnNodeOut)( Writer&, SwCntntNode& );
+typedef FnNodeOut SwNodeFnTab[ RES_NODE_END - RES_NODE_BEGIN ];
+
+Writer& Out( const SwNodeFnTab, SwNode&, Writer & rWrt );
+
+
+
+
+#endif // _WRT_FN_HXX
diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx
new file mode 100644
index 000000000000..e0330140aca9
--- /dev/null
+++ b/sw/source/filter/inc/wrtswtbl.hxx
@@ -0,0 +1,375 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtswtbl.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 _WRTSWTBL_HXX
+#define _WRTSWTBL_HXX
+
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+#ifndef _TOOLS_COLOR_HXX
+#include <tools/color.hxx>
+#endif
+#ifndef _SVARRAY_HXX
+#include <svtools/svarray.hxx>
+#endif
+
+#ifndef _ORNTENUM_HXX
+#include <orntenum.hxx>
+#endif
+#ifndef _HORIORNT_HXX
+#include <horiornt.hxx>
+#endif
+
+class Color;
+class SwTableBox;
+class SwTableBoxes;
+class SwTableLine;
+class SwTableLines;
+class SwTable;
+class SwFrmFmt;
+class SwHTMLTableLayout;
+class SvxBrushItem;
+class SvxBoxItem;
+class SvxBorderLine;
+
+
+//---------------------------------------------------------------------------
+// Code aus dem HTML-Filter fuers schreiben von Tabellen
+//---------------------------------------------------------------------------
+
+#define COLFUZZY 20
+#define ROWFUZZY 20
+#define COL_DFLT_WIDTH ((2*COLFUZZY)+1)
+#define ROW_DFLT_HEIGHT (2*ROWFUZZY)+1
+
+
+//-----------------------------------------------------------------------
+
+class SwWriteTableCell
+{
+ const SwTableBox *pBox; // SwTableBox der Zelle
+ const SvxBrushItem *pBackground; // geerbter Hintergrund einer Zeile
+
+ long nHeight; // fixe/Mindest-Hoehe der Zeile
+
+ USHORT nWidthOpt; // Breite aus Option;
+
+ USHORT nRow; // Start-Zeile
+ USHORT nCol; // Start-Spalte
+
+ USHORT nRowSpan; // ueberspannte Zeilen
+ USHORT nColSpan; // ueberspannte Spalten
+
+
+ BOOL bPrcWidthOpt;
+
+public:
+
+ SwWriteTableCell( const SwTableBox *pB, USHORT nR, USHORT nC,
+ USHORT nRSpan, USHORT nCSpan, long nHght,
+ const SvxBrushItem *pBGround ) :
+ pBox( pB ),
+ nRow( nR ), nCol( nC ),
+ nRowSpan( nRSpan ), nColSpan( nCSpan ),
+ nHeight( nHght ), pBackground( pBGround ),
+ nWidthOpt( 0 ), bPrcWidthOpt( FALSE )
+ {}
+
+ const SwTableBox *GetBox() const { return pBox; }
+
+ USHORT GetRow() const { return nRow; }
+ USHORT GetCol() const { return nCol; }
+
+ USHORT GetRowSpan() const { return nRowSpan; }
+ USHORT GetColSpan() const { return nColSpan; }
+
+ long GetHeight() const { return nHeight; }
+ SwVertOrient GetVertOri() const;
+
+ const SvxBrushItem *GetBackground() const { return pBackground; }
+
+ void SetWidthOpt( USHORT nWidth, BOOL bPrc )
+ {
+ nWidthOpt = nWidth; bPrcWidthOpt = bPrc;
+ }
+
+ USHORT GetWidthOpt() const { return nWidthOpt; }
+ BOOL HasPrcWidthOpt() const { return bPrcWidthOpt; }
+};
+
+typedef SwWriteTableCell *SwWriteTableCellPtr;
+SV_DECL_PTRARR_DEL( SwWriteTableCells, SwWriteTableCellPtr, 5, 5 )
+
+
+//-----------------------------------------------------------------------
+
+class SwWriteTableRow
+{
+ SwWriteTableCells aCells; // Alle Zellen der Rows
+
+ const SvxBrushItem *pBackground;// Hintergrund
+
+ long nPos; // End-Position (twips) der Zeile
+
+public:
+
+ USHORT nTopBorder; // Dicke der oberen/unteren Umrandugen
+ USHORT nBottomBorder;
+
+ BOOL bTopBorder : 1; // Welche Umrandungen sind da?
+ BOOL bBottomBorder : 1;
+
+ SwWriteTableRow( long nPos );
+
+ SwWriteTableCell *AddCell( const SwTableBox *pBox,
+ USHORT nRow, USHORT nCol,
+ USHORT nRowSpan, USHORT nColSpan,
+ long nHeight,
+ const SvxBrushItem *pBackground );
+
+ void SetBackground( const SvxBrushItem *pBGround )
+ {
+ pBackground = pBGround;
+ }
+ const SvxBrushItem *GetBackground() const { return pBackground; }
+
+ BOOL HasTopBorder() const { return bTopBorder; }
+ BOOL HasBottomBorder() const { return bBottomBorder; }
+
+ long GetPos() const { return nPos; }
+ const SwWriteTableCells& GetCells() const { return aCells; }
+
+ inline int operator==( const SwWriteTableRow& rRow ) const;
+ inline int operator<( const SwWriteTableRow& rRow2 ) const;
+};
+
+inline int SwWriteTableRow::operator==( const SwWriteTableRow& rRow ) const
+{
+ // etwas Unschaerfe zulassen
+ return (nPos >= rRow.nPos ? nPos - rRow.nPos
+ : rRow.nPos - nPos ) <= ROWFUZZY;
+}
+
+inline int SwWriteTableRow::operator<( const SwWriteTableRow& rRow ) const
+{
+ // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
+ // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
+ return nPos < rRow.nPos - ROWFUZZY;
+}
+
+typedef SwWriteTableRow *SwWriteTableRowPtr;
+SV_DECL_PTRARR_SORT_DEL( SwWriteTableRows, SwWriteTableRowPtr, 5, 5 )
+
+
+//-----------------------------------------------------------------------
+
+class SwWriteTableCol
+{
+ USHORT nPos; // End Position der Spalte
+
+ USHORT nWidthOpt;
+
+ BOOL bRelWidthOpt : 1;
+ BOOL bOutWidth : 1; // Spaltenbreite ausgeben?
+
+public:
+ BOOL bLeftBorder : 1; // Welche Umrandungen sind da?
+ BOOL bRightBorder : 1;
+
+ SwWriteTableCol( USHORT nPosition );
+
+ USHORT GetPos() const { return nPos; }
+
+ void SetLeftBorder( BOOL bBorder ) { bLeftBorder = bBorder; }
+ BOOL HasLeftBorder() const { return bLeftBorder; }
+
+ void SetRightBorder( BOOL bBorder ) { bRightBorder = bBorder; }
+ BOOL HasRightBorder() const { return bRightBorder; }
+
+ void SetOutWidth( BOOL bSet ) { bOutWidth = bSet; }
+ BOOL GetOutWidth() const { return bOutWidth; }
+
+ inline int operator==( const SwWriteTableCol& rCol ) const;
+ inline int operator<( const SwWriteTableCol& rCol ) const;
+
+ void SetWidthOpt( USHORT nWidth, BOOL bRel )
+ {
+ nWidthOpt = nWidth; bRelWidthOpt = bRel;
+ }
+ USHORT GetWidthOpt() const { return nWidthOpt; }
+ BOOL HasRelWidthOpt() const { return bRelWidthOpt; }
+};
+
+inline int SwWriteTableCol::operator==( const SwWriteTableCol& rCol ) const
+{
+ // etwas Unschaerfe zulassen
+ return (nPos >= rCol.nPos ? nPos - rCol.nPos
+ : rCol.nPos - nPos ) <= COLFUZZY;
+}
+
+inline int SwWriteTableCol::operator<( const SwWriteTableCol& rCol ) const
+{
+ // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
+ // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
+ return nPos < rCol.nPos - COLFUZZY;
+}
+
+
+typedef SwWriteTableCol *SwWriteTableColPtr;
+SV_DECL_PTRARR_SORT_DEL( SwWriteTableCols, SwWriteTableColPtr, 5, 5 )
+
+//-----------------------------------------------------------------------
+
+class SwWriteTable
+{
+protected:
+ SwWriteTableCols aCols; // alle Spalten
+ SwWriteTableRows aRows; // alle Zellen
+
+ UINT32 nBorderColor; // Umrandungsfarbe
+
+ USHORT nCellSpacing; // Dicke der inneren Umrandung
+ USHORT nCellPadding; // Absatnd Umrandung-Inhalt
+
+ USHORT nBorder; // Dicke der ausseren Umrandung
+ USHORT nInnerBorder; // Dicke der inneren Umrandung
+ USHORT nBaseWidth; // Bezugsgroesse fur Breiten SwFmtFrmSize
+
+ USHORT nHeadEndRow; // letzte Zeile des Tabellen-Kopfes
+
+ USHORT nLeftSub;
+ USHORT nRightSub;
+
+ long nTabWidth; // Absolute/Relative Breite der Tabelle
+
+ BOOL bRelWidths : 1; // Breiten relativ ausgeben?
+ BOOL bUseLayoutHeights : 1; // Layout zur Hoehenbestimmung nehmen?
+#ifndef PRODUCT
+ BOOL bGetLineHeightCalled : 1;
+#endif
+
+ BOOL bColsOption : 1;
+ BOOL bColTags : 1;
+ BOOL bLayoutExport : 1;
+ BOOL bCollectBorderWidth : 1;
+
+ virtual BOOL ShouldExpandSub( const SwTableBox *pBox,
+ BOOL bExpandedBefore, USHORT nDepth ) const;
+
+ void CollectTableRowsCols( long nStartRPos, USHORT nStartCPos,
+ long nParentLineHeight,
+ USHORT nParentLineWidth,
+ const SwTableLines& rLines,
+ USHORT nDepth );
+
+ void FillTableRowsCols( long nStartRPos, USHORT nStartRow,
+ USHORT nStartCPos, USHORT nStartCol,
+ long nParentLineHeight,
+ USHORT nParentLineWidth,
+ const SwTableLines& rLines,
+ const SvxBrushItem* pLineBrush,
+ USHORT nDepth );
+
+ void MergeBorders( const SvxBorderLine* pBorderLine, BOOL bTable );
+
+ USHORT MergeBoxBorders( const SwTableBox *pBox, USHORT nRow, USHORT nCol,
+ USHORT nRowSpan, USHORT nColSpan,
+ USHORT &rTopBorder, USHORT &rBottomBorder );
+
+ USHORT GetBaseWidth() const { return nBaseWidth; }
+
+ BOOL HasRelWidths() const { return bRelWidths; }
+
+public:
+ static long GetBoxWidth( const SwTableBox *pBox );
+protected:
+
+ long GetLineHeight( const SwTableLine *pLine );
+ long GetLineHeight( const SwTableBox *pBox ) const;
+ const SvxBrushItem *GetLineBrush( const SwTableBox *pBox,
+ SwWriteTableRow *pRow );
+
+ USHORT GetLeftSpace( USHORT nCol ) const;
+ USHORT GetRightSpace( USHORT nCol, USHORT nColSpan ) const;
+
+ USHORT GetRawWidth( USHORT nCol, USHORT nColSpan ) const;
+ USHORT GetAbsWidth( USHORT nCol, USHORT nColSpan ) const;
+ USHORT GetRelWidth( USHORT nCol, USHORT nColSpan ) const;
+ USHORT GetPrcWidth( USHORT nCol, USHORT nColSpan ) const;
+
+ long GetAbsHeight( long nRawWidth, USHORT nRow, USHORT nRowSpan ) const;
+
+public:
+ SwWriteTable( const SwTableLines& rLines, long nWidth, USHORT nBWidth,
+ BOOL bRel, USHORT nMaxDepth = USHRT_MAX,
+ USHORT nLeftSub=0, USHORT nRightSub=0 );
+ SwWriteTable( const SwHTMLTableLayout *pLayoutInfo );
+
+ const SwWriteTableCols& GetCols() const { return aCols; }
+ const SwWriteTableRows& GetRows() const { return aRows; }
+};
+
+
+
+
+#endif
+
diff --git a/sw/source/filter/makefile.mk b/sw/source/filter/makefile.mk
new file mode 100644
index 000000000000..cb186c78dc7b
--- /dev/null
+++ b/sw/source/filter/makefile.mk
@@ -0,0 +1,244 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:53 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=sw
+TARGET=filter
+
+PROJECTPCH=filt_pch
+PDBTARGET=filt_pch
+PROJECTPCHSOURCE=.\filt_1st\filt_pch
+
+.IF "$(CALLTARGETS)"=="filter"
+RC_SUBDIRS=
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+
+# fuer VC++/NT andere Label als Verzeichnisnamen
+.IF "$(RC_SUBDIRS)" == ""
+SWSUBDIRS= \
+ filt_1st \
+ ascii \
+ basflt \
+ excel \
+ html \
+ lotus \
+ rtf \
+ w4w \
+ writer \
+ ww1 \
+ ww8 \
+ xml
+
+.IF "$(product)" == ""
+.IF "$(GUI)" == "WIN" || "$(GUI)" == "WNT" || "$(GUI)" == "UNX"
+SWSUBDIRS+= \
+ debug
+.ENDIF
+.ENDIF
+
+.IF "$(compact)" == ""
+SWSUBDIRS+= \
+ sw6
+.ENDIF
+.ENDIF
+
+SUBLIBS= \
+ $(SLB)$/ascii.lib \
+ $(SLB)$/basflt.lib \
+ $(SLB)$/excel.lib \
+ $(SLB)$/html.lib \
+ $(SLB)$/lotus.lib \
+ $(SLB)$/rtf.lib \
+ $(SLB)$/w4w.lib \
+ $(SLB)$/writer.lib \
+ $(SLB)$/ww1.lib \
+ $(SLB)$/ww8.lib \
+ $(SLB)$/xml.lib
+
+.IF "$(product)" == ""
+.IF "$(GUI)" == "WIN" || "$(GUI)" == "WNT" || "$(GUI)" == "UNX"
+SUBLIBS+= \
+ $(SLB)$/debug.lib
+.ENDIF
+.ENDIF
+.IF "$(compact)" == ""
+SUBLIBS+= \
+ $(SLB)$/sw6.lib
+.ENDIF
+
+# -----------------------------------------------------------
+
+.IF "$(RC_SUBDIRS)" == ""
+.IF "$(depend)" == ""
+filter: \
+ filt_1st \
+ $(SWSUBDIRS) \
+ ALLTAR
+.ELSE
+filter:
+ @+echo Doing nothing in source\filter
+.ENDIF
+.ENDIF
+
+################################################################
+
+LIB1TARGET=$(SLB)$/filter.lib
+LIB1FILES= \
+ $(SUBLIBS)
+
+.INCLUDE : target.mk
+
+################################################################
+
+.IF "$(dbutil)" != ""
+dbutilx += "dbutil=true"
+.ENDIF
+.IF "$(debug)" != ""
+.IF "$(debug)" != "D_FORCE_OPT"
+dbutilx += "debug=true"
+.ENDIF
+.ENDIF
+
+
+.IF "$(CALLTARGETS)"!="filter"
+.IF "$(DOPLD)$(dopld)" == ""
+
+.IF "$(RC_SUBDIRS)" == ""
+#rule lib / subdir
+$(SLB)$/%.lib : %
+ @echo @
+
+filt_1st .SETDIR=filt_1st:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+ascii .SETDIR=ascii:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+basflt .SETDIR=basflt:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+debug .SETDIR=debug:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+excel .SETDIR=excel:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+html .SETDIR=html:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+lotus .SETDIR=lotus:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+rtf .SETDIR=rtf:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+sw6 .SETDIR=sw6:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+w4w .SETDIR=w4w:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+writer .SETDIR=writer:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+ww1 .SETDIR=ww1:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+ww8 .SETDIR=ww8:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+xml .SETDIR=xml:
+ @echo $@
+ @$(MAKECMD) -d $(MFLAGS) $(dbutilx) $(CALLMACROS)
+
+.ENDIF
+.ELSE
+filt_1st:
+ @echo nix
+.ENDIF
+.ENDIF
+
+kill:
+ del $(SLB)$/filter.lib
+
diff --git a/sw/source/filter/rtf/makefile.mk b/sw/source/filter/rtf/makefile.mk
new file mode 100644
index 000000000000..194278f69995
--- /dev/null
+++ b/sw/source/filter/rtf/makefile.mk
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=rtf
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(mydebug)" != ""
+CDEFS=$(CDEFS) -Dmydebug
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ rtfatr.cxx \
+ rtffld.cxx \
+ rtffly.cxx \
+ rtfnum.cxx \
+ rtftbl.cxx \
+ swparrtf.cxx \
+ wrtrtf.cxx
+
+
+
+SLOFILES = \
+ $(SLO)$/rtfatr.obj \
+ $(SLO)$/rtffld.obj \
+ $(SLO)$/rtffly.obj \
+ $(SLO)$/rtfnum.obj \
+ $(SLO)$/rtftbl.obj \
+ $(SLO)$/swparrtf.obj \
+ $(SLO)$/wrtrtf.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx
new file mode 100644
index 000000000000..1ecb25f24ebd
--- /dev/null
+++ b/sw/source/filter/rtf/rtfatr.cxx
@@ -0,0 +1,3068 @@
+/*************************************************************************
+ *
+ * $RCSfile: rtfatr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/*
+ * Dieses File enthaelt alle Ausgabe-Funktionen des RTF-Writers;
+ * fuer alle Nodes, Attribute, Formate und Chars.
+ */
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <fltini.hxx>
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX //autogen
+#include <svtools/stritem.hxx>
+#endif
+#ifndef _RTFKEYWD_HXX //autogen
+#include <svtools/rtfkeywd.hxx>
+#endif
+#ifndef _RTFOUT_HXX
+#include <svtools/rtfout.hxx>
+#endif
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SVX_HYZNITEM_HXX //autogen
+#include <svx/hyznitem.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX //autogen
+#include <svx/langitem.hxx>
+#endif
+#ifndef _SVX_KEEPITEM_HXX //autogen
+#include <svx/keepitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_PROTITEM_HXX //autogen
+#include <svx/protitem.hxx>
+#endif
+#ifndef _SVX_OPAQITEM_HXX //autogen
+#include <svx/opaqitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_PRNTITEM_HXX //autogen
+#include <svx/prntitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_CNTRITEM_HXX //autogen
+#include <svx/cntritem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_SHDDITEM_HXX //autogen
+#include <svx/shdditem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _XOUTBMP_HXX //autogen
+#include <svx/xoutbmp.hxx>
+#endif
+#ifndef _UNOTOOLS_CHARCLASS_HXX
+#include <unotools/charclass.hxx>
+#endif
+
+
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+#ifndef _FCHRFMT_HXX //autogen
+#include <fchrfmt.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _TXTFTN_HXX //autogen
+#include <txtftn.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _TXTINET_HXX //autogen
+#include <txtinet.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx> // fuer SwField ...
+#endif
+#ifndef _WRTRTF_HXX
+#include <wrtrtf.hxx>
+#endif
+#ifndef _RTF_HXX
+#include <rtf.hxx> // fuer SwPictureType
+#endif
+#ifndef _WRTTXATR_HXX
+#include <wrttxatr.hxx> // fuer EndPosList (zwischenspeicher fuer TextAttr.=
+#endif
+#ifndef _NDGRF_HXX
+#include <ndgrf.hxx>
+#endif
+#ifndef _GRFATR_HXX
+#include <grfatr.hxx>
+#endif
+#ifndef _FMTCOL_HXX
+#include <fmtcol.hxx>
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx> // fuer SwPageDesc ...
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx> // fuer SwPageDesc ...
+#endif
+#ifndef _LINETYPE_HXX
+#include <linetype.hxx> // fuer SwPageDesc ...
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _SWRECT_HXX //autogen
+#include <swrect.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen
+#include <section.hxx>
+#endif
+#ifndef _WRTSWTBL_HXX
+#include <wrtswtbl.hxx>
+#endif
+#ifndef _HTMLTBL_HXX
+#include <htmltbl.hxx>
+#endif
+#ifndef _FMTCLBL_HXX
+#include <fmtclbl.hxx>
+#endif
+
+
+/*
+ * um nicht immer wieder nach einem Update festzustellen, das irgendwelche
+ * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle
+ * definiert und mit der akt. verglichen. Bei unterschieden wird der
+ * Compiler schon meckern.
+ *
+ * diese Section und die dazugeherigen Tabellen muessen in folgenden Files
+ * gepflegt werden: rtf\rtfatr.cxx, sw6\sw6atr.cxx, w4w\w4watr.cxx
+ */
+#if !defined(UNX) && !defined(MSC) && !defined(PPC) && !defined(CSET) && !defined(__MWERKS__) && !defined(WTC)
+
+#define ATTRFNTAB_SIZE 121
+#if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN
+#error Attribut-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+
+#ifdef FORMAT_TABELLE
+// da sie nicht benutzt wird!
+#define FORMATTAB_SIZE 7
+#if FORMATTAB_SIZE != RES_FMT_END - RES_FMT_BEGIN
+#error Format-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+#endif
+
+#define NODETAB_SIZE 3
+#if NODETAB_SIZE != RES_NODE_END - RES_NODE_BEGIN
+#error Node-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
+#endif
+
+#endif
+
+#ifdef WNT
+// ueber xoutbmp.hxx wird das winuser.h angezogen. Dort gibt es ein
+// define GetProp das mit unserem SvxEscapement kollidiert!
+#undef GetProp
+#endif
+
+//-----------------------------------------------------------------------
+
+static Writer& OutRTF_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt );
+
+//-----------------------------------------------------------------------
+
+SvStream& OutComment( Writer& rWrt, const sal_Char* pStr )
+{
+ return (rWrt.Strm() << '{' << sRTF_IGNORE << pStr);
+}
+
+SvStream& OutComment( Writer& rWrt, const char* pStr, BOOL bSetFlag )
+{
+ // setze Flag, damit bei der Ausgabe von Attributen zu erkennen,
+ // ob ueberhaupt etwas ausgegeben wurde.
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = bSetFlag;
+ return (rWrt.Strm() << '{' << sRTF_IGNORE << pStr);
+}
+
+Writer& OutRTF_AsByteString( Writer& rWrt, const String& rStr )
+{
+ ByteString sOutStr( rStr, DEF_ENCODING );
+ rWrt.Strm() << sOutStr.GetBuffer();
+ return rWrt;
+}
+
+// fuer die Formate muesste eine einzige Ausgabe-Funktion genuegen !
+/*
+ * Formate wie folgt ausgeben:
+ * - gebe alle Attribute vom Format aus
+ */
+
+Writer& OutRTF_SwFmt( Writer& rWrt, const SwFmt& rFmt )
+{
+ SwRTFWriter & rRTFWrt = (SwRTFWriter&)rWrt;
+ BOOL bOutItemSet = TRUE;
+
+ switch( rFmt.Which() )
+ {
+ case RES_CONDTXTFMTCOLL:
+ case RES_TXTFMTCOLL:
+ {
+ USHORT nId = rRTFWrt.GetId( (const SwTxtFmtColl&)rFmt );
+ if( 0 == nId )
+ return rWrt; // Default-TextStyle nicht ausgeben !!
+
+ rWrt.Strm() << sRTF_S;
+ rWrt.OutULong( nId );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ BYTE nLvl = ((const SwTxtFmtColl&)rFmt).GetOutlineLevel();
+ if( MAXLEVEL > nLvl )
+ {
+ BYTE nWWLvl = 8 >= nLvl ? nLvl : 8;
+ rWrt.Strm() << sRTF_LS;
+ rWrt.OutULong( rWrt.pDoc->GetNumRuleTbl().Count() );
+ rWrt.Strm() << sRTF_ILVL; rWrt.OutULong( nWWLvl );
+ rWrt.Strm() << sRTF_OUTLINELEVEL; rWrt.OutULong( nWWLvl );
+ if( nWWLvl != nLvl ) // RTF-kennt nur 9 Ebenen
+ {
+ OutComment( rWrt, sRTF_SOUTLVL );
+ rWrt.OutULong( nLvl ) << '}';
+ }
+
+ const SwNumFmt* pNFmt = &rWrt.pDoc->GetOutlineNumRule()->Get( nLvl );
+ if( pNFmt->GetAbsLSpace() )
+ {
+ SfxItemSet aSet( *rFmt.GetAttrSet().GetPool(),
+ rFmt.GetAttrSet().GetRanges() );
+ aSet.SetParent( &rFmt.GetAttrSet() );
+ SvxLRSpaceItem aLR( (SvxLRSpaceItem&)aSet.Get( RES_LR_SPACE ) );
+
+ aLR.SetTxtLeft( aLR.GetTxtLeft() + pNFmt->GetAbsLSpace() );
+ aLR.SetTxtFirstLineOfst( pNFmt->GetFirstLineOffset() );
+
+ aSet.Put( aLR );
+ Out_SfxItemSet( aRTFAttrFnTab, rWrt, aSet, TRUE );
+ bOutItemSet = FALSE;
+ }
+ }
+ }
+ break;
+ case RES_CHRFMT:
+ {
+ USHORT nId = rRTFWrt.GetId( (const SwCharFmt&)rFmt );
+ if( 0 == nId )
+ return rWrt; // Default-CharStyle nicht ausgeben !!
+
+ rWrt.Strm() << sRTF_IGNORE << sRTF_CS;
+ rWrt.OutULong( nId );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ break;
+
+// case RES_GRFFMTCOLL:
+// ?????
+ }
+
+ if( bOutItemSet )
+ Out_SfxItemSet( aRTFAttrFnTab, rWrt, rFmt.GetAttrSet(), TRUE );
+ return rWrt;
+}
+
+
+
+void OutRTF_SwFlyFrmFmt( SwRTFWriter& rRTFWrt )
+{
+ // ist der aktuelle Absatz in einem freifliegenden Rahmen ? Dann
+ // muessen noch die Attribute dafuer ausgegeben werden.
+ ASSERT( rRTFWrt.pFlyFmt, "wo ist das Fly-Format?" );
+
+ if( rRTFWrt.bOutFmtAttr )
+ {
+ rRTFWrt.Strm() << ' ';
+ rRTFWrt.bOutFmtAttr = FALSE;
+ }
+ // gebe erstmal alle RTF-Spezifischen Attribute aus
+ rRTFWrt.bRTFFlySyntax = TRUE;
+ OutRTF_SwFmt( rRTFWrt, *rRTFWrt.pFlyFmt );
+
+ // dann gebe alle eigenen Attribute aus
+ {
+ // dazu erzeuge einen temp strstream, um festzustellen ob es
+ // ueberhaupt eigene Attribute gibt !
+ SvMemoryStream aTmpStrm;
+ SvStream* pSaveStrm = &rRTFWrt.Strm();
+ rRTFWrt.SetStrm( aTmpStrm );
+
+ rRTFWrt.bRTFFlySyntax = FALSE;
+ OutRTF_SwFmt( rRTFWrt, *rRTFWrt.pFlyFmt );
+
+ rRTFWrt.SetStrm( *pSaveStrm ); // Stream-Pointer wieder zurueck
+
+ if( aTmpStrm.GetSize() ) // gibt es SWG spezifische Attribute ??
+ {
+ aTmpStrm.Seek( 0L );
+ rRTFWrt.Strm() << '{' << sRTF_IGNORE << aTmpStrm << '}';
+ }
+ }
+// rRTFWrt.pFlyFmt = 0; // wieder zuruecksetzen !!
+}
+
+/* Ausgabe der Nodes */
+
+/*
+ * 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.
+ */
+
+class RTFEndPosLst : public EndPosLst
+{
+public:
+ RTFEndPosLst() {}
+ void OutAttrs( Writer& rWrt, xub_StrLen nStrPos );
+ void EndAttrs( SwRTFWriter& rWrt, xub_StrLen nStrPos );
+};
+
+void RTFEndPosLst::OutAttrs( Writer& rWrt, xub_StrLen nStrPos )
+{
+ SttEndPos* pStt;
+ for( USHORT n = Count(); n ; )
+ if( nStrPos == (pStt = (*this)[ --n ])->GetStart() )
+ {
+ rWrt.Strm() << '{';
+ for( USHORT i = 0; i < pStt->GetAttrs().Count(); ++i )
+ Out( aRTFAttrFnTab, pStt->GetAttrs()[i]->GetAttr(), rWrt );
+ }
+}
+
+void RTFEndPosLst::EndAttrs( SwRTFWriter& rWrt, xub_StrLen nStrPos )
+{
+ SttEndPos* pSEPos;
+ while( 0 != Count() && 0 != (pSEPos = (*this)[ 0 ]) &&
+ ( STRING_MAXLEN == nStrPos || nStrPos == pSEPos->GetEnd() ))
+ {
+ rWrt.Strm() << '}';
+
+ const _SwpTxtHts& rAttrs = pSEPos->GetAttrs();
+ for( USHORT nAttr = rAttrs.Count(); nAttr; )
+ if( RES_TXTATR_INETFMT == rAttrs[ --nAttr ]->Which() )
+ {
+ // Hyperlinks werden als Felder geschrieben, aber der
+ // "FieldResult" steht als Text im TextNode. Also muss
+ // bei diesen Attributen am Ende 2 Klammern stehen!
+ rWrt.Strm() << "}}";
+ }
+
+ rWrt.nFontHeight = pSEPos->GetFontSize();
+ Remove();
+ }
+
+}
+
+static Writer& OutRTF_SwTxtNode( Writer& rWrt, SwCntntNode & rNode )
+{
+ SwTxtNode * pNd = &((SwTxtNode&)rNode);
+ SwRTFWriter & rRTFWrt = (SwRTFWriter&)rWrt;
+ RTFEndPosLst aEndPosLst;
+ SttEndPos* pNewStt;
+ USHORT nAttrPos = 0;
+ xub_StrLen nStrPos = rRTFWrt.pCurPam->GetPoint()->nContent.GetIndex();
+
+ const String& rStr = pNd->GetTxt();
+ xub_StrLen nEnde = rStr.Len();
+ if( rRTFWrt.pCurPam->GetPoint()->nNode == rRTFWrt.pCurPam->GetMark()->nNode )
+ nEnde = Min( nEnde, rRTFWrt.pCurPam->GetMark()->nContent.GetIndex() );
+
+ int bNewFmts = rRTFWrt.pAttrSet != &pNd->GetSwAttrSet();
+ if( bNewFmts )
+ {
+ // harte Attributierung am Node und am Vorgaenger ?
+ const SfxItemSet* pNdSet = pNd->GetpSwAttrSet();
+ if( pNdSet && rRTFWrt.pAttrSet && rRTFWrt.bAutoAttrSet &&
+ pNdSet->GetParent() == rRTFWrt.pAttrSet->GetParent() &&
+ pNdSet->Count() == rRTFWrt.pAttrSet->Count() )
+ {
+ // die beiden Parents sind gleich, dann teste doch mal die
+ // Attribute im Set
+
+ int bEqual = TRUE;
+ if( pNdSet->Count() )
+ {
+ SfxItemIter aIter( *rRTFWrt.pAttrSet );
+ const SfxPoolItem *pItem, *pCurr = aIter.GetCurItem();
+ while( TRUE )
+ {
+ if( SFX_ITEM_SET != pNdSet->GetItemState( pCurr->Which(),
+ FALSE, &pItem ) || *pItem != *pCurr )
+ {
+ bEqual = FALSE;
+ break;
+ }
+
+ if( aIter.IsAtEnd() )
+ break;
+ pCurr = aIter.NextItem();
+ }
+ }
+ if( bEqual )
+ bNewFmts = FALSE;
+ }
+ rRTFWrt.pAttrSet = &pNd->GetSwAttrSet();
+ rRTFWrt.bAutoAttrSet = 0 != pNdSet;
+ }
+
+ // bestimme die aktuelle FontSize aus den Formaten
+ rRTFWrt.nFontHeight = (USHORT)rRTFWrt.pAttrSet->GetSize().GetHeight();
+
+ // Flag zuruecksetzen, damit nach der Ausgabe der Collection
+ // getestet werden kann, ob noch ein Blank auszugeben ist
+ rRTFWrt.bOutFmtAttr = FALSE;
+
+ // in der Ausgabe eines Flys? Dann vorm ausgeben der AbsatzAttribute
+ // den Format-Pointer auf 0 setzen!
+ SwFlyFrmFmt* pSaveFmt = rRTFWrt.pFlyFmt;
+
+ if( bNewFmts && rRTFWrt.bWriteAll )
+ {
+ rRTFWrt.Strm() << sRTF_PARD << sRTF_PLAIN << ' '; // alle Attribute zuruecksetzen
+ if( rRTFWrt.bOutTable )
+ rRTFWrt.Strm() << sRTF_INTBL;
+
+ // ist der aktuelle Absatz in einem freifliegenden Rahmen ? Dann
+ // muessen noch die Attribute dafuer ausgegeben werden.
+ if( pSaveFmt )
+ {
+ OutRTF_SwFlyFrmFmt( rRTFWrt );
+ rRTFWrt.pFlyFmt = 0;
+ }
+
+ rRTFWrt.OutListNum( *pNd );
+
+ OutRTF_SwFmt( rRTFWrt, pNd->GetAnyFmtColl() );
+ }
+
+ // gibt es harte Attributierung ?
+ if( bNewFmts && pNd->GetpSwAttrSet() )
+ {
+ rRTFWrt.pFlyFmt = 0;
+
+ const SfxItemSet& rNdSet = pNd->GetSwAttrSet();
+
+ const SwNumRule* pRule;
+ const SwNodeNum* pNum;
+ if( (( 0 != ( pNum = pNd->GetNum() ) &&
+ 0 != ( pRule = pNd->GetNumRule() )) ||
+ ( 0 != ( pNum = pNd->GetOutlineNum() ) &&
+ 0 != ( pRule = rWrt.pDoc->GetOutlineNumRule() ) ) ) &&
+ pNum->GetLevel() < NO_NUM )
+ {
+ BYTE nLvl = GetRealLevel( pNum->GetLevel() );
+ const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
+ if( !pFmt )
+ pFmt = &pRule->Get( nLvl );
+
+ SfxItemSet aSet( rNdSet );
+ SvxLRSpaceItem aLR( (SvxLRSpaceItem&)rNdSet.Get( RES_LR_SPACE ) );
+
+ aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetAbsLSpace() );
+ if( MAXLEVEL > pNum->GetLevel() )
+ aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
+ else
+ aSet.ClearItem( RES_PARATR_NUMRULE );
+ aSet.Put( aLR );
+ Out_SfxItemSet( aRTFAttrFnTab, rWrt, aSet, FALSE );
+ }
+ else
+ Out_SfxItemSet( aRTFAttrFnTab, rWrt, rNdSet, FALSE );
+ }
+
+ rRTFWrt.pFlyFmt = pSaveFmt;
+
+ // erstmal den Start berichtigen. D.h. wird nur ein Teil vom Satz
+ // ausgegeben, so muessen auch da die Attribute stimmen!!
+ const SwTxtAttr * pHt = 0;
+ USHORT nCntAttr = pNd->HasHints() ? pNd->GetSwpHints().Count() : 0;
+ if( nCntAttr && nStrPos > *( pHt = pNd->GetSwpHints()[ 0 ] )->GetStart() )
+ {
+ rRTFWrt.bTxtAttr = TRUE;
+ // Ok, es gibt vorher Attribute, die ausgegeben werden muessen
+ do {
+ nAttrPos++;
+ if( RES_TXTATR_FIELD == pHt->Which() ) // Felder nicht
+ continue; // ausgeben
+
+ if( pHt->GetEnd() )
+ {
+ xub_StrLen nHtEnd = *pHt->GetEnd(), nHtStt = *pHt->GetStart();
+ if( !rRTFWrt.bWriteAll && nHtEnd <= nStrPos )
+ continue;
+
+ // leere Hints am Anfang nicht beachten, oder ??
+ if( nHtEnd == nHtStt )
+ continue;
+
+ // Attribut in die Liste aufnehemen
+ if( !rRTFWrt.bWriteAll )
+ {
+ if( nHtStt < nStrPos ) nHtStt = nStrPos;
+ if( nHtEnd >= nEnde ) nHtEnd = nEnde;
+ }
+ pNewStt = new SttEndPos( pHt, nHtStt, nHtEnd, rRTFWrt.nFontHeight );
+
+ aEndPosLst.Insert( pNewStt );
+ continue;
+ // aber nicht ausgeben, das erfolgt spaeter !!
+ }
+ Out( aRTFAttrFnTab, pHt->GetAttr(), rRTFWrt );
+
+ } while( nAttrPos < nCntAttr && nStrPos >
+ *( pHt = pNd->GetSwpHints()[ nAttrPos ] )->GetStart() );
+
+ // dann gebe mal alle gesammelten Attribute von der String-Pos aus
+ aEndPosLst.OutAttrs( rRTFWrt, nStrPos );
+
+ rRTFWrt.bTxtAttr = FALSE;
+ }
+
+ if( !rRTFWrt.bWriteAll && rRTFWrt.bFirstLine )
+ {
+ if( rRTFWrt.bOutFmtAttr )
+ {
+ rRTFWrt.Strm() << ' ';
+ rRTFWrt.bOutFmtAttr = FALSE;
+ }
+ OutRTF_SwFmt( rRTFWrt, pNd->GetAnyFmtColl() );
+ }
+
+ if( rRTFWrt.bOutFmtAttr &&
+ ( nAttrPos < nCntAttr ? *pHt->GetStart() != nStrPos : TRUE ))
+ rRTFWrt.Strm() << ' ';
+
+ // das Flag gibt an, ob das SwTxtFld am Ende vom Absatz steht. Denn
+ // dann ist vor dem Absatzumbruch die schliessende Klammer auszugeben
+ xub_StrLen nChrCnt = 0;
+ for( ; nStrPos <= nEnde; nStrPos++ )
+ {
+ if( nStrPos != nEnde && aEndPosLst.Count() )
+ aEndPosLst.EndAttrs( rRTFWrt, nStrPos );
+
+ // versuche nach ungefaehr 255 Zeichen eine neue Zeile zu beginnen
+ if( nChrCnt != ( nStrPos & 0xff00 ))
+ {
+ rWrt.Strm() << SwRTFWriter::sNewLine;
+ nChrCnt = nStrPos & 0xff00;
+ }
+
+ if( nAttrPos < nCntAttr && *pHt->GetStart() == nStrPos
+ && nStrPos != nEnde )
+ {
+ rRTFWrt.bTxtAttr = TRUE;
+ rRTFWrt.bOutFmtAttr = FALSE;
+ do {
+ BOOL bEmpty = FALSE;
+ if( pHt->GetEnd() )
+ {
+ if( FALSE == (bEmpty = *pHt->GetEnd() == nStrPos) )
+ {
+ pNewStt = new SttEndPos( pHt, nStrPos, *pHt->GetEnd(),
+ rRTFWrt.nFontHeight );
+ aEndPosLst.Insert( pNewStt );
+ continue;
+ }
+ rRTFWrt.Strm() << '{';
+ }
+ Out( aRTFAttrFnTab, pHt->GetAttr(), rRTFWrt );
+ if( bEmpty )
+ {
+ rRTFWrt.Strm() << '}';
+ rRTFWrt.bOutFmtAttr = FALSE;
+ }
+ } while( ++nAttrPos < nCntAttr && nStrPos ==
+ *( pHt = pNd->GetSwpHints()[ nAttrPos ] )->GetStart() );
+
+ // dann gebe mal alle gesammelten Attribute von der String-Pos aus
+ aEndPosLst.OutAttrs( rRTFWrt, nStrPos );
+
+ if( rRTFWrt.bOutFmtAttr )
+ rRTFWrt.Strm() << ' ';
+ rRTFWrt.bTxtAttr = FALSE;
+ }
+
+ rRTFWrt.OutBookmarks( nStrPos );
+
+ if( nStrPos != nEnde )
+ RTFOutFuncs::Out_Char( rWrt.Strm(), rStr.GetChar( nStrPos ),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+ }
+
+ // noch eine schliesende Klammer da ??
+ if( aEndPosLst.Count() )
+ aEndPosLst.EndAttrs( rRTFWrt, USHRT_MAX );
+
+ // wenn bis zum Ende vom Node, dann auch das AbsatzEnde ausgeben
+ if( rRTFWrt.pCurPam->GetMark()->nNode.GetIndex() ==
+ rRTFWrt.pCurPam->GetPoint()->nNode.GetIndex() )
+ {
+ if( pNd->Len() != rRTFWrt.pCurPam->GetMark()->nContent.GetIndex() )
+ return rWrt;
+
+ if( rRTFWrt.bOutTable )
+ {
+ rRTFWrt.Strm() << SwRTFWriter::sNewLine;
+ return rWrt;
+ }
+ }
+
+ rRTFWrt.Strm() << SwRTFWriter::sNewLine << sRTF_PAR << ' ';
+ return rRTFWrt;
+}
+
+
+
+static Writer& OutRTF_SwGrfNode( Writer& rWrt, SwCntntNode & rNode )
+{
+ SwRTFWriter & rRTFWrt = (SwRTFWriter&)rWrt;
+ SwGrfNode * pNd = &((SwGrfNode&)rNode);
+
+ // ist der aktuelle Absatz in einem freifliegenden Rahmen ? Dann
+ // muessen noch die Attribute dafuer ausgegeben werden.
+ if( rRTFWrt.pFlyFmt )
+ OutRTF_SwFlyFrmFmt( rRTFWrt );
+ rRTFWrt.Strm() << "{{";
+
+ // damit die eigenen Grafik-Attribute nach der PICT / import Anweisung
+ // stehen, muessen die am Anfang ausgegeben werden.
+ rRTFWrt.bOutFmtAttr = FALSE;
+ OutRTF_SwFmt( rRTFWrt, *pNd->GetFmtColl() );
+
+ if( rRTFWrt.bOutFmtAttr ) // wurde ueberhaupt ein Attrribut
+ rRTFWrt.Strm() << "}{"; // ausgegeben ??
+
+ String aCID;
+ SwDocShell *pDocSh = rWrt.pDoc->GetDocShell();
+ if( pDocSh )
+ {
+ const SfxPoolItem *pItem = pDocSh->GetItem( SID_ORIGURL );
+ if( pItem )
+ {
+ aCID = ((const SfxStringItem *)pItem)->GetValue();
+ ASSERT( aCID.Len(), "CID ohne Laenge!" );
+ }
+ }
+
+ String aGrfNm;
+ const SwMirrorGrf& rMirror = pNd->GetSwAttrSet().GetMirrorGrf();
+ if( !pNd->IsLinkedFile() || RES_DONT_MIRROR_GRF != rMirror.GetValue() )
+ {
+ // Grafik als File-Referenz speichern (als JPEG-Grafik speichern)
+ aGrfNm = *rWrt.GetOrigFileName();
+ pNd->SwapIn( TRUE );
+ ULONG nFlags = 0;
+ switch( rMirror.GetValue() )
+ {
+ case RES_MIRROR_GRF_VERT: nFlags = XOUTBMP_MIRROR_HORZ; break;
+ case RES_MIRROR_GRF_HOR: nFlags = XOUTBMP_MIRROR_VERT; break;
+ case RES_MIRROR_GRF_BOTH:
+ nFlags = XOUTBMP_MIRROR_VERT | XOUTBMP_MIRROR_HORZ;
+ break;
+ }
+
+ Size aMM100Size;
+ Size* pMM100Size = 0;
+ if( rRTFWrt.pFlyFmt )
+ {
+ const SwFmtFrmSize& rSize = rRTFWrt.pFlyFmt->GetFrmSize();
+ aMM100Size = OutputDevice::LogicToLogic( rSize.GetSize(),
+ MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ));
+ pMM100Size = &aMM100Size;
+ }
+
+ USHORT nErr = XOutBitmap::WriteGraphic( pNd->GetGrf(), aGrfNm,
+ String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "JPG" )),
+ nFlags, pMM100Size );
+ if( nErr ) // fehlerhaft, da ist nichts auszugeben
+ {
+ rRTFWrt.Strm() << "}}";
+ return rWrt;
+ }
+
+ // MIB 17.7.97: Wenn Mail-Export, dann in eine file-URL draus machen,
+ // damit wir spaeter auf ein file-Protokoll stossen.
+ if( aCID.Len() )
+ aGrfNm = URIHelper::SmartRelToAbs( aGrfNm );
+ }
+ else
+ {
+ pNd->GetFileFilterNms( &aGrfNm, 0 );
+ if( aCID.Len() )
+ rWrt.CopyLocalFileToINet( aGrfNm, TRUE );
+ }
+
+ if( aCID.Len() )
+ {
+ INetURLObject aURLObj( aGrfNm );
+ if( INET_PROT_FILE==aURLObj.GetProtocol() )
+ {
+ String aLastName( aURLObj.GetLastName(
+ INetURLObject::DECODE_WITH_CHARSET ) );
+ ASSERT( aLastName.Len(), "Dateiname ohne Laenge!" );
+ GetAppCharClass().toLower( aLastName );
+
+ aGrfNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "cid:" ));
+ ((aGrfNm = aLastName) += '.') += aCID;
+ }
+ else
+ aGrfNm = INetURLObject::AbsToRel( aGrfNm,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ }
+ else
+ {
+ // MIB->JP: Warum erst AbsToRel und dann das URL-Objekt? So
+ // kommt bei relativierbaren URLs als Protokoll "unknown" raus.
+ // Ist das Absicht?
+ aGrfNm = INetURLObject::AbsToRel( aGrfNm, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ INetURLObject aUrl( aGrfNm );
+ if( aUrl.GetProtocol() == INET_PROT_FILE )
+ aGrfNm = aUrl.PathToFileName();
+ }
+
+ // Bitmap als File-Referenz speichern
+ rRTFWrt.Strm() << sRTF_FIELD << sRTF_FLDPRIV;
+ OutComment( rRTFWrt, sRTF_FLDINST ) << "{\\\\import ";
+ RTFOutFuncs::Out_String( rWrt.Strm(), aGrfNm, DEF_ENCODING,
+ rRTFWrt.bWriteHelpFmt );
+ rRTFWrt.Strm() << "}}{" << sRTF_FLDRSLT << " }}";
+
+ rRTFWrt.Strm() << '}' << SwRTFWriter::sNewLine;
+ return rRTFWrt;
+}
+
+static Writer& OutRTF_SwOLENode( Writer& rWrt, SwCntntNode & rNode )
+{
+ SwRTFWriter & rRTFWrt = (SwRTFWriter&)rWrt;
+
+ // ist der aktuelle Absatz in einem freifliegenden Rahmen ? Dann
+ // muessen noch die Attribute dafuer ausgegeben werden.
+ if( rRTFWrt.pFlyFmt )
+ OutRTF_SwFlyFrmFmt( rRTFWrt );
+
+ rWrt.Strm() << SwRTFWriter::sNewLine << sRTF_PAR;
+ return rWrt;
+}
+
+
+static void OutTBLBorderLine( SwRTFWriter& rWrt, const SvxBorderLine* pLine,
+ const sal_Char* pStr, USHORT nDist )
+{
+ ByteString sLineStr;
+ if( pLine->GetInWidth() )
+ {
+ // doppelte Linie
+ sLineStr = sRTF_BRDRDB;
+ switch( pLine->GetInWidth() )
+ {
+ case DEF_LINE_WIDTH_0:
+ ( sLineStr += sRTF_BRDRW ) += "15";
+ break;
+ case DEF_LINE_WIDTH_1:
+ ( sLineStr += sRTF_BRDRW ) += "30";
+ break;
+ case DEF_LINE_WIDTH_2:
+ case DEF_LINE_WIDTH_3:
+ ( sLineStr += sRTF_BRDRW ) += "45";
+ break;
+ }
+ }
+ else
+ {
+ // einfache Linie
+ if( DEF_LINE_WIDTH_1 >= pLine->GetOutWidth() )
+ (( sLineStr = sRTF_BRDRS ) += sRTF_BRDRW ) +=
+ ByteString::CreateFromInt32( pLine->GetOutWidth() );
+ else
+ (( sLineStr = sRTF_BRDRTH ) += sRTF_BRDRW ) +=
+ ByteString::CreateFromInt32( pLine->GetOutWidth() / 2 );
+ }
+
+ rWrt.Strm() << pStr << sLineStr.GetBuffer() << sRTF_BRDRCF;
+ rWrt.OutULong( rWrt.GetId( pLine->GetColor() ) ) << sRTF_BRSP;
+ rWrt.OutULong( nDist );
+}
+
+static void OutSwTblBorder( SwRTFWriter& rWrt, const SvxBoxItem& rBox )
+{
+ static USHORT __READONLY_DATA aBorders[] = {
+ BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
+ static const char* __READONLY_DATA aBorderNames[] = {
+ sRTF_CLBRDRT, sRTF_CLBRDRL, sRTF_CLBRDRB, sRTF_CLBRDRR };
+ const USHORT* pBrd = aBorders;
+ const char** pBrdNms = (const char**)aBorderNames;
+ for( int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms )
+ {
+ // funktioniert im WinWord so nicht
+ USHORT nDist = 0; //rBox.GetDistance( *pBrd );
+ const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
+ if( pLn )
+ OutTBLBorderLine( rWrt, pLn, *pBrdNms, nDist );
+ else if( nDist )
+ {
+ rWrt.Strm() << *pBrdNms << sRTF_BRSP;
+ rWrt.OutULong( nDist );
+ }
+ }
+}
+
+static void OutSwTblBackground( SwRTFWriter& rWrt, const SvxBrushItem& rBack )
+{
+ if( !rBack.GetColor().GetTransparency() )
+ {
+ rWrt.Strm() << sRTF_CLCBPAT;
+ rWrt.OutULong( rWrt.GetId( rBack.GetColor() ) );
+ }
+}
+
+
+Writer& OutRTF_SwTblNode( Writer& rWrt, SwTableNode & rNode )
+{
+ SwRTFWriter & rRTFWrt = (SwRTFWriter&)rWrt;
+ const SwTable& rTbl = rNode.GetTable();
+ const SwTableLines& rLns = rTbl.GetTabLines();
+ SwTwips nPageSize = 0, nTblOffset = 0;
+
+/*
+//!!!!!!!!!!!!! for clipboard create any view if the table is complex !!!
+ if( rTbl.IsTblComplex() )
+ {
+ // then we have to create any layout
+ SFX_APP()->CreateViewFrame( *xDocSh, 0, TRUE );
+ }
+*/
+
+ {
+ Point aPt;
+ SwRect aRect( rTbl.GetFrmFmt()->FindLayoutRect( FALSE, &aPt ));
+ if( aRect.IsEmpty() )
+ {
+ // dann besorge mal die Seitenbreite ohne Raender !!
+ const SwFrmFmt* pFmt = rRTFWrt.pFlyFmt ? rRTFWrt.pFlyFmt :
+ rWrt.pDoc->GetPageDesc(0).GetPageFmtOfNode( rNode, FALSE );
+
+ aRect = pFmt->FindLayoutRect( TRUE );
+ if( 0 == ( nPageSize = aRect.Width() ))
+ {
+ const SvxLRSpaceItem& rLR = pFmt->GetLRSpace();
+ nPageSize = pFmt->GetFrmSize().GetWidth() -
+ rLR.GetLeft() - rLR.GetRight();
+ }
+ }
+ else
+ nPageSize = aRect.Width();
+ }
+
+ SwTwips nTblSz = rTbl.GetFrmFmt()->GetFrmSize().GetWidth();
+
+ ByteString aTblAdjust( sRTF_TRQL );
+ switch( rTbl.GetFrmFmt()->GetHoriOrient().GetHoriOrient() )
+ {
+ case HORI_CENTER: aTblAdjust = sRTF_TRQC; break;
+ case HORI_RIGHT: aTblAdjust = sRTF_TRQR; break;
+ case HORI_NONE:
+ case HORI_LEFT_AND_WIDTH:
+ {
+ const SvxLRSpaceItem& rLRSp = rTbl.GetFrmFmt()->GetLRSpace();
+ nTblOffset = rLRSp.GetLeft();
+ nPageSize -= (nTblOffset + rLRSp.GetRight());
+ aTblAdjust += sRTF_TRLEFT;
+ aTblAdjust += ByteString::CreateFromInt32( nTblOffset );
+ }
+ break;
+// case case FLY_HORI_FULL:
+ }
+
+ // ist die Tabelle wesentlich (PageSize + 10%) groesser als die Seite,
+ // dann sind die Box-Breiten relative Angaben.
+ BOOL bRelBoxSize = TRUE /*ALWAYS relativ (nPageSize + ( nPageSize / 10 )) < nTblSz*/;
+
+ SwWriteTable* pTableWrt;
+ const SwHTMLTableLayout *pLayout = rTbl.GetHTMLTableLayout();
+ if( pLayout && pLayout->IsExportable() )
+ pTableWrt = new SwWriteTable( pLayout );
+ else
+ pTableWrt = new SwWriteTable( rTbl.GetTabLines(), (USHORT)nPageSize,
+ (USHORT)nTblSz, FALSE );
+
+ // rCols are the array of all cols of the table
+ const SwWriteTableCols& rCols = pTableWrt->GetCols();
+ USHORT nColCnt = rCols.Count();
+ SwWriteTableCellPtr* pBoxArr = new SwWriteTableCellPtr[ nColCnt ];
+ USHORT* pRowSpans = new USHORT[ nColCnt ];
+ memset( pBoxArr, 0, sizeof( pBoxArr[0] ) * nColCnt );
+ memset( pRowSpans, 0, sizeof( pRowSpans[0] ) * nColCnt );
+ long nLastHeight = 0;
+ const SwWriteTableRows& rRows = pTableWrt->GetRows();
+ for( USHORT nLine = 0; nLine < rRows.Count(); ++nLine )
+ {
+ USHORT nBox;
+
+ const SwWriteTableRow *pRow = rRows[ nLine ];
+ const SwWriteTableCells& rCells = pRow->GetCells();
+
+ BOOL bFixRowHeight = FALSE;
+ for( nColCnt = 0, nBox = 0; nBox < rCells.Count(); ++nColCnt )
+ {
+ if( !pRowSpans[ nColCnt ] )
+ {
+ // set new BoxPtr
+ SwWriteTableCell* pCell = rCells[ nBox++ ];
+ pBoxArr[ nColCnt ] = pCell;
+ pRowSpans[ nColCnt ] = pCell->GetRowSpan();
+ for( USHORT nCellSpan = pCell->GetColSpan(), nCS = 1;
+ nCS < nCellSpan; ++nCS, ++nColCnt )
+ {
+ pBoxArr[ nColCnt+1 ] = pBoxArr[ nColCnt ];
+ pRowSpans[ nColCnt+1 ] = pRowSpans[ nColCnt ];
+ }
+ }
+ if( 1 != pRowSpans[ nColCnt ] )
+ bFixRowHeight = TRUE;
+ }
+
+ for( ; nColCnt < rCols.Count() && pRowSpans[ nColCnt ]; ++nColCnt )
+ bFixRowHeight = TRUE;
+
+ // Start Tabellendefinition
+ rWrt.Strm() << sRTF_TROWD << aTblAdjust.GetBuffer();
+
+ if( !nLine && rTbl.IsHeadlineRepeat() )
+ rWrt.Strm() << sRTF_TRHDR;
+
+ // Zeilenhoehe ausgeben
+ long nHeight = 0;
+ if( bFixRowHeight && rWrt.pDoc->GetRootFrm() )
+ {
+ nHeight = -pRow->GetPos(); //neg. => abs. height!
+ if( nLine )
+ nHeight += rRows[ nLine - 1 ]->GetPos();
+
+ // merged line -> dont split it
+ rWrt.Strm() << sRTF_TRKEEP;
+ }
+ else
+ {
+ const SwTableLine* pLine = pBoxArr[ 0 ]->GetBox()->GetUpper();
+ const SwFmtFrmSize& rLSz = pLine->GetFrmFmt()->GetFrmSize();
+ if( ATT_VAR_SIZE != rLSz.GetSizeType() && rLSz.GetHeight() )
+ nHeight = ATT_MIN_SIZE == rLSz.GetSizeType()
+ ? rLSz.GetHeight()
+ : -rLSz.GetHeight();
+ }
+ if( nHeight )
+ {
+ rWrt.Strm() << sRTF_TRRH;
+ rWrt.OutLong( nHeight );
+ }
+
+ // Breite der Boxen ausgeben
+ SwTwips nSz = 0, nCalc;
+ for( nBox = 0; nBox < nColCnt; ++nBox )
+ {
+ SwWriteTableCell* pCell = pBoxArr[ nBox ];
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+
+ const SwFrmFmt& rFmt = *pCell->GetBox()->GetFrmFmt();
+ if( 1 < pCell->GetRowSpan() )
+ rWrt.Strm() << ( pCell->GetRowSpan() == pRowSpans[ nBox ]
+ ? sRTF_CLVMGF
+ : sRTF_CLVMRG );
+
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(
+ RES_BOX, TRUE, &pItem ) )
+ OutSwTblBorder( rRTFWrt, (SvxBoxItem&)*pItem );
+
+// RTF kennt Schattierung in unserem Sinne nicht!
+// if( SFX_ITEM_SET == pBoxFmt->GetAttrSet().GetItemState(
+// RES_SHADOW, TRUE, &pItem ) )
+// OutSwTblShadow( rRTFWrt, *pItem );
+
+ if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(
+ RES_BACKGROUND, TRUE, &pItem )
+ || 0 != ( pItem = pCell->GetBackground() )
+ || 0 != ( pItem = pRow->GetBackground() ) )
+ OutSwTblBackground( rRTFWrt, (SvxBrushItem&)*pItem );
+
+ if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(
+ RES_VERT_ORIENT, TRUE, &pItem ) )
+ switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() )
+ {
+ case VERT_CENTER: rWrt.Strm() << sRTF_CLVERTALC; break;
+ case VERT_BOTTOM: rWrt.Strm() << sRTF_CLVERTALB; break;
+ default: rWrt.Strm() << sRTF_CLVERTALT; break;
+ }
+
+ const SwFmtFrmSize& rLSz = rFmt.GetFrmSize();
+ nSz += rLSz.GetWidth();
+ rWrt.Strm() << sRTF_CELLX;
+
+ nCalc = nSz;
+ if( bRelBoxSize )
+ {
+ nCalc *= nPageSize;
+ nCalc /= nTblSz;
+ }
+ rWrt.OutLong( nTblOffset + nCalc );
+ }
+
+ // Inhalt der Boxen ausgeben
+ rWrt.Strm() << SwRTFWriter::sNewLine << sRTF_PARD << sRTF_INTBL;
+ for( nBox = 0; nBox < nColCnt; ++nBox )
+ {
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+
+ if( pBoxArr[ nBox ]->GetRowSpan() == pRowSpans[ nBox ] )
+ {
+ // new Box
+ const SwStartNode* pSttNd = pBoxArr[ nBox ]->GetBox()->GetSttNd();
+ RTFSaveData aSaveData( rRTFWrt,
+ pSttNd->GetIndex()+1, pSttNd->EndOfSectionIndex() );
+ rRTFWrt.bOutTable = TRUE;
+ rRTFWrt.Out_SwDoc( rRTFWrt.pCurPam );
+ }
+ rWrt.Strm() << sRTF_CELL;
+ }
+
+ // das wars mit der Line
+ rWrt.Strm() << sRTF_ROW << sRTF_PARD << ' ';
+
+ for( nBox = 0; nBox < nColCnt; ++nBox )
+ --pRowSpans[ nBox ];
+ }
+
+ delete pTableWrt;
+ delete pBoxArr;
+ delete pRowSpans;
+
+ // Pam hinter die Tabelle verschieben
+ rRTFWrt.pCurPam->GetPoint()->nNode = *rNode.EndOfSectionNode();
+
+ return rWrt;
+}
+
+Writer& OutRTF_SwSectionNode( Writer& rWrt, SwSectionNode& rNode )
+{
+ SwRTFWriter & rRTFWrt = (SwRTFWriter&)rWrt;
+ const SwSection& rSect = rNode.GetSection();
+
+ // folgt dahinter noch ein SectionNode? Dann wird erst die innere
+ // Section aktiv. Hier wird die Verschachtelung aufgebrochen, weil
+ // RTF das nicht kennt
+ BOOL bPgDscWrite = FALSE;
+ {
+ SwNodeIndex aIdx( rNode, 1 );
+ const SwNode& rNd = aIdx.GetNode();
+ if( rNd.IsSectionNode() /*&& CONTENT_SECTION ==
+ aIdx.GetNode().GetSectionNode()->GetSection().GetType()*/ )
+ return rWrt;
+
+ // falls als erstes Position ein Content- oder Tabellen-Node steht,
+ // dann kann dieser einen PageDesc gesetzt haben und der muss vor
+ // der Bereichsbeschreibung geschrieben werden!
+ // Umgekehrt muss im OutBreaks dann
+ if( rNd.IsCntntNode() )
+ {
+ bPgDscWrite = rRTFWrt.OutBreaks( ((SwCntntNode&)rNd).GetSwAttrSet() );
+ rRTFWrt.bIgnoreNextPgBreak = TRUE;
+ }
+ else if( rNd.IsTableNode() )
+ {
+ bPgDscWrite = rRTFWrt.OutBreaks( ((SwTableNode&)rNd).GetTable().
+ GetFrmFmt()->GetAttrSet() );
+ rRTFWrt.bIgnoreNextPgBreak = TRUE;
+ }
+ }
+
+
+// if( CONTENT_SECTION == rSect.GetType() )
+ {
+ // als fortlaufenden Abschnittwechsel heraus schreiben
+ if( !bPgDscWrite )
+ rWrt.Strm() << sRTF_SECT << sRTF_SBKNONE;
+ //JP 19.03.99 - es muss fuer den Import auf jedenfall das Cols
+ // Token geschrieben werden. Sonst kann nicht erkannt
+ // werden, wann ein PageDesc & eine Section gueltig ist
+ rWrt.Strm() << sRTF_COLS << '1';
+ rRTFWrt.bOutFmtAttr = TRUE;
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rSet = rSect.GetFmt()->GetAttrSet();
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_COL, FALSE, &pItem ))
+ OutRTF_SwFmtCol( rWrt, *pItem );
+ else
+ rWrt.Strm() << sRTF_COLS << '1' << sRTF_COLSX << '709';
+
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_COLUMNBALANCE,
+ FALSE, &pItem ) && ((SwFmtNoBalancedColumns*)pItem)->GetValue() )
+ OutComment( rWrt, sRTF_BALANCEDCOLUMN ) << '}';
+
+ rWrt.Strm() << SwRTFWriter::sNewLine;
+ }
+
+ return rWrt;
+}
+
+
+/* File CHRATR.HXX: */
+
+static Writer& OutRTF_SwFont( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ /* trage den Font in die Font-Liste vom Writer ein und gebe hier nur
+ * die entsprechende Nummer aus. Der Font wird spaeter ueber diese
+ * Tabelle im RTF-Dokument referenziert.
+ */
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ rRTFWrt.bOutFmtAttr = TRUE;
+
+ rWrt.Strm() << sRTF_F;
+ rWrt.OutULong( rRTFWrt.GetId( (const SvxFontItem&)rHt ) );
+ return rWrt;
+}
+
+static Writer& OutRTF_SwPosture( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const FontItalic nPosture = ((const SvxPostureItem&)rHt).GetPosture();
+ int bTxtOut = rRTFWrt.bTxtAttr && ITALIC_NONE == nPosture;
+ if( ITALIC_NORMAL == nPosture || bTxtOut )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_I;
+ }
+ if( bTxtOut )
+ rWrt.Strm() << '0'; // wieder abschalten
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwWeight( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const FontWeight nBold = ((const SvxWeightItem&)rHt).GetWeight();
+ int bTxtOut = rRTFWrt.bTxtAttr && WEIGHT_NORMAL == nBold;
+ if( WEIGHT_BOLD == nBold || bTxtOut )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_B;
+ }
+ if( bTxtOut )
+ rWrt.Strm() << '0';
+ return rWrt;
+}
+
+
+static Writer& OutRTF_SwShadowed( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const BOOL bShadow = ((const SvxShadowedItem&)rHt).GetValue();
+ int bTxtOut = rRTFWrt.bTxtAttr && !bShadow;
+ if( bShadow || bTxtOut )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_SHAD;
+ }
+ if( bTxtOut )
+ rWrt.Strm() << '0';
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwContour( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const BOOL bContour = ((const SvxContourItem&)rHt).GetValue();
+ int bTxtOut = rRTFWrt.bTxtAttr && !bContour;
+ if( bContour || bTxtOut )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_OUTL;
+ }
+ if( bTxtOut )
+ rWrt.Strm() << '0';
+ return rWrt;
+}
+
+
+
+#ifdef USED
+static Writer& OutRTF_SwKerning( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+
+static Writer& OutRTF_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const FontStrikeout nStrike = ((const SvxCrossedOutItem&)rHt).GetStrikeout();
+ int bTxtOut = rRTFWrt.bTxtAttr && STRIKEOUT_NONE == nStrike;
+
+ if( (STRIKEOUT_NONE != nStrike && STRIKEOUT_DONTKNOW != nStrike) || bTxtOut )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ if( STRIKEOUT_DOUBLE == nStrike )
+ rWrt.Strm() << sRTF_STRIKEDL;
+ else
+ rWrt.Strm() << sRTF_STRIKE;
+ }
+ if( bTxtOut )
+ rWrt.Strm() << '0';
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ switch( ((const SvxCaseMapItem&)rHt).GetValue() )
+ {
+ case SVX_CASEMAP_KAPITAELCHEN:
+ rWrt.Strm() << sRTF_SCAPS;
+ break;
+
+ case SVX_CASEMAP_VERSALIEN:
+ rWrt.Strm() << sRTF_CAPS;
+ break;
+
+ case SVX_CASEMAP_NOT_MAPPED:
+ rWrt.Strm() << sRTF_CAPS << '0' << sRTF_SCAPS << '0'; // beide aus !!
+ break;
+
+ default:
+ return rWrt;
+ }
+
+ rRTFWrt.bOutFmtAttr = TRUE;
+ return rWrt;
+}
+
+
+static Writer& OutRTF_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const char* pStr = 0;
+ switch( ((const SvxUnderlineItem&)rHt).GetUnderline() )
+ {
+ case UNDERLINE_SINGLE: pStr = sRTF_UL; break;
+ case UNDERLINE_DOUBLE: pStr = sRTF_ULDB; break;
+ case UNDERLINE_NONE: pStr = sRTF_ULNONE; break;
+ case UNDERLINE_DOTTED: pStr = sRTF_ULD; break;
+ case UNDERLINE_DASH: pStr = sRTF_ULDASH; break;
+ case UNDERLINE_DASHDOT: pStr = sRTF_ULDASHD; break;
+ case UNDERLINE_DASHDOTDOT: pStr = sRTF_ULDASHDD; break;
+ case UNDERLINE_BOLD: pStr = sRTF_ULTH; break;
+ case UNDERLINE_WAVE: pStr = sRTF_ULWAVE; break;
+ case UNDERLINE_BOLDDOTTED: pStr = sRTF_ULTHD; break;
+ case UNDERLINE_BOLDDASH: pStr = sRTF_ULTHDASH; break;
+ case UNDERLINE_LONGDASH: pStr = sRTF_ULLDASH; break;
+ case UNDERLINE_BOLDLONGDASH: pStr = sRTF_ULTHLDASH; break;
+ case UNDERLINE_BOLDDASHDOT: pStr = sRTF_ULTHDASHD; break;
+ case UNDERLINE_BOLDDASHDOTDOT: pStr = sRTF_ULTHDASHDD; break;
+ case UNDERLINE_BOLDWAVE: pStr = sRTF_ULHWAVE; break;
+ case UNDERLINE_DOUBLEWAVE: pStr = sRTF_ULULDBWAVE; break;
+ }
+
+ if( pStr )
+ {
+ ((SwRTFWriter&)rWrt).Strm() << pStr;
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ }
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwLanguage( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_LANG;
+ rWrt.OutULong( ((const SvxLanguageItem&)rHt).GetLanguage() );
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwEscapement( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const SvxEscapementItem& rEsc = (const SvxEscapementItem&)rHt;
+ const char * pUpDn;
+
+ SwTwips nH;
+ if( !rRTFWrt.bTxtAttr )
+ nH = rRTFWrt.nFontHeight;
+ else
+ nH = rRTFWrt.pAttrSet->GetSize().GetHeight();
+
+ if( 0 < rEsc.GetEsc() )
+ pUpDn = sRTF_UP;
+ else if( 0 > rEsc.GetEsc() )
+ {
+ pUpDn = sRTF_DN;
+ nH = -nH; // den negativen Wert herrausrechnen
+ }
+ else
+ return rWrt;
+
+ // prozentuale Veraenderung speichern !
+ short nEsc = rEsc.GetEsc();
+ short nProp = rEsc.GetProp() * 100;
+ if( DFLT_ESC_AUTO_SUPER == nEsc )
+ {
+ nEsc = 100 - rEsc.GetProp();
+ ++nProp;
+ }
+ else if( DFLT_ESC_AUTO_SUB == nEsc )
+ {
+ nEsc = - 100 + rEsc.GetProp();
+ ++nProp;
+ }
+
+ OutComment( rWrt, sRTF_UPDNPROP, TRUE );
+ rWrt.OutULong( nProp ) << '}' << pUpDn;
+
+ /*
+ * berechne aus der akt. FontSize und dem ProzentWert die Verschiebung,
+ * wobei im RTF File 1/2 Points stehen muessen, waehrend intern
+ * mit Twips gerechnet wird.
+ * Formel : (FontSize * 1/20 ) pts x * 2
+ * ----------------------- = ------------
+ * 100% Escapement
+ */
+
+ rWrt.OutULong( ( (long( nEsc ) * nH) + 500L ) / 1000L );
+ // 500L zum Aufrunden !!
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwSize( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ rRTFWrt.bOutFmtAttr = TRUE;
+
+ USHORT nSize = (USHORT)((const SvxFontHeightItem&)rHt).GetHeight();
+ rWrt.Strm() << sRTF_FS;
+ rWrt.OutULong( nSize / 10 );
+ if( rRTFWrt.bTxtAttr )
+ rRTFWrt.nFontHeight = nSize;
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwColor( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ /* trage die Color in die Color-Liste vom Writer ein und gebe hier nur
+ * die entsprechende Nummer aus. Die Color wird spaeter ueber diese
+ * Tabelle im RTF-Dokument referenziert.
+ */
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_CF;
+ rWrt.OutULong( rRTFWrt.GetId( ((const SvxColorItem&)rHt).GetValue() ));
+ return rWrt;
+}
+
+
+extern void sw3io_ConvertToOldField( const SwField* pFld, USHORT& rWhich,
+ ULONG& rFmt, ULONG nFFVersion );
+
+static Writer& OutRTF_SwField( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwFmtFld & rFld = (SwFmtFld&)rHt;
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+
+ const SwField* pFld = rFld.GetFld();
+
+ ByteString aFldStt( '{' );
+ ((((aFldStt += sRTF_FIELD) += '{' ) += sRTF_IGNORE ) += sRTF_FLDINST) += ' ';
+ switch( pFld->GetTyp()->Which() )
+ {
+ case RES_DBFLD:
+ aFldStt += "MERGEFIELD ";
+ // kein break !!
+ case RES_USERFLD:
+ rWrt.Strm() << aFldStt.GetBuffer();
+ RTFOutFuncs::Out_String( rWrt.Strm(), pFld->GetTyp()->GetName(),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+ break;
+// case RES_CHAPTERFLD:
+// rWrt.Strm() << ' ';
+// break;
+ case RES_PAGENUMBERFLD:
+ rWrt.Strm() << aFldStt.GetBuffer() << "\\\\page";
+ {
+ char __READONLY_DATA
+ sNType0[] = "ALPHABETIC", /* CHARS_UPPER_LETTER*/
+ sNType1[] = "alphabetic", /* CHARS_LOWER_LETTER*/
+ sNType2[] = "ROMAN", /* ROMAN_UPPER */
+ sNType3[] = "roman", /* ROMAN_LOWER */
+ sNType4[] = "ARABIC"; /* ARABIC */
+
+ const char* pFmtStr = 0;
+ switch( pFld->GetFormat() )
+ {
+ case SVX_NUM_CHARS_UPPER_LETTER:
+ case SVX_NUM_CHARS_UPPER_LETTER_N: pFmtStr = sNType0; break;
+ case SVX_NUM_CHARS_LOWER_LETTER:
+ case SVX_NUM_CHARS_LOWER_LETTER_N: pFmtStr = sNType1; break;
+ case SVX_NUM_ROMAN_UPPER: pFmtStr = sNType2; break;
+ case SVX_NUM_ROMAN_LOWER: pFmtStr = sNType3; break;
+ case SVX_NUM_ARABIC: pFmtStr = sNType4; break;
+ }
+
+ if( pFmtStr )
+ rWrt.Strm() << "\\\\* " << pFmtStr;
+ }
+ break;
+ case RES_FILENAMEFLD:
+ rWrt.Strm() << aFldStt.GetBuffer() << "\\\\filename ";
+ break;
+ case RES_DBNAMEFLD:
+ rWrt.Strm() << aFldStt.GetBuffer() << "\\\\data ";
+ RTFOutFuncs::Out_String( rWrt.Strm(), rWrt.pDoc->GetDBName(),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+ break;
+ case RES_AUTHORFLD:
+ rWrt.Strm() << aFldStt.GetBuffer() << "\\\\author ";
+ break;
+
+ case RES_HIDDENTXTFLD:
+ if( TYP_CONDTXTFLD == ((SwHiddenTxtField*)pFld)->GetSubType() )
+ RTFOutFuncs::Out_String( rWrt.Strm(), pFld->Expand(),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+ else
+ {
+ rWrt.Strm() << '{' << sRTF_V << ' ';
+ OutRTF_AsByteString( rWrt, pFld->GetPar2() ).Strm()
+ << '}' << SwRTFWriter::sNewLine;
+ }
+ return rWrt; // nicht bis zum Ende, kein RTF-Feld !!
+
+ case RES_DATETIMEFLD:
+ if (!(pFld->GetSubType() & FIXEDFLD))
+ {
+ USHORT nWhich = RES_DATETIMEFLD;
+ ULONG nFmt = pFld->GetFormat();
+ sw3io_ConvertToOldField(pFld, nWhich, nFmt, SOFFICE_FILEFORMAT_40 );
+ if (pFld->GetSubType() & DATEFLD)
+ {
+ rWrt.Strm() << aFldStt.GetBuffer() << "\\\\date \\\\@\"";
+ switch( nFmt )
+ {
+ case DF_SSYS: rWrt.Strm() << "tt.MM.yy"; break;
+ case DF_LSYS: rWrt.Strm() << "tttt, t. MMMM yyyy"; break;
+ case DF_SHORT: rWrt.Strm() << "tt.MM.yy"; break;
+ case DF_SCENT: rWrt.Strm() << "tt.MM.yyyy"; break;
+ case DF_LMON: rWrt.Strm() << "t. MMM yyyy"; break;
+ case DF_LMONTH: rWrt.Strm() << "t. MMMM yyyy"; break;
+ case DF_LDAYMON: rWrt.Strm() << "ttt, t. MMMM yyyy"; break;
+ case DF_LDAYMONTH: rWrt.Strm() << "tttt, t. MMMM yyyy"; break;
+ }
+ }
+ else
+ {
+ rWrt.Strm() << aFldStt.GetBuffer() << "\\\\date \\\\@\"";
+ switch( nFmt )
+ {
+ case TF_SSMM_24: rWrt.Strm() << "HH:mm"; break;
+ case TF_SSMM_12: rWrt.Strm() << "hh:mm"; break; // ???
+ case TF_SYSTEM: rWrt.Strm() << "HH:mm"; break;
+ }
+ }
+ rWrt.Strm() << '\"';
+ break;
+ }
+ // Kein break: in default-Zweig laufen!
+
+ default:
+ {
+ aFldStt.Erase();
+
+ // JP 20.07.95: warum nicht das Expandierte rausschreiben ?
+ sal_Char cCh;
+ rWrt.Strm().SeekRel(-1);
+ rWrt.Strm() >> cCh;
+ if( ' ' != cCh ) // vorweg immer einen Trenner
+ rWrt.Strm() << ' ';
+ RTFOutFuncs::Out_String( rWrt.Strm(), pFld->Expand(),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+ }
+ break;
+ }
+
+ if( aFldStt.Len() )
+ {
+ rWrt.Strm() << "}{" << sRTF_FLDRSLT << ' ';
+ RTFOutFuncs::Out_String( rWrt.Strm(), pFld->Expand(),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+ rWrt.Strm() << "}}";
+ rRTFWrt.bOutFmtAttr = FALSE;
+ }
+
+ return rWrt;
+}
+
+static Writer& OutRTF_SwFlyCntnt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwFrmFmt* pFmt = ((SwFmtFlyCnt&)rHt).GetFrmFmt();
+ if( RES_DRAWFRMFMT != pFmt->Which() )
+ {
+ OutComment( rWrt, sRTF_FLYINPARA );
+ ((SwRTFWriter&)rWrt).OutRTFFlyFrms( *((SwFlyFrmFmt*)pFmt) );
+ rWrt.Strm() << '}';
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = FALSE;
+ }
+// Zeichengebundene Zeichenobjekte werden ignoriert.
+ return rWrt;
+}
+
+
+
+#ifdef USED
+static Writer& OutRTF_SwTOXMark( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+#ifdef USED
+static Writer& OutRTF_SwNoHyphen( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+
+static Writer& OutRTF_SwFtn( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtFtn& rFtn = (const SwFmtFtn&)rHt;
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+
+ do { // middle-check-loop
+ if( !rFtn.GetTxtFtn() || !rFtn.GetTxtFtn()->GetStartNode() )
+ break; // es gibt keine Kopf-/Fusszeile/Fussnote
+
+ // Hole vom Node und vom letzten Node die Position in der Section
+ ULONG nStart = rFtn.GetTxtFtn()->GetStartNode()->GetIndex()+1,
+ nEnd = rWrt.pDoc->GetNodes()[ nStart-1 ]->EndOfSectionIndex();
+
+ // kein Bereich also kein gueltiger Node
+ if( nStart >= nEnd )
+ break;
+
+ rWrt.Strm() << '{' << sRTF_SUPER << ' ';
+ if( !rFtn.GetNumStr().Len() )
+ {
+ rWrt.Strm() << sRTF_CHFTN;
+ OutComment( rWrt, sRTF_FOOTNOTE );
+ if( rFtn.IsEndNote() )
+ rWrt.Strm() << sRTF_FTNALT;
+ rWrt.Strm() << ' ' << sRTF_CHFTN;
+ }
+ else
+ {
+ OutRTF_AsByteString( rWrt, rFtn.GetNumStr() );
+ OutComment( rWrt, sRTF_FOOTNOTE );
+ if( rFtn.IsEndNote() )
+ rWrt.Strm() << sRTF_FTNALT;
+ rWrt.Strm() << ' ';
+ OutRTF_AsByteString( rWrt, rFtn.GetNumStr() );
+ }
+ RTFSaveData aSaveData( rRTFWrt, nStart, nEnd );
+ // damit kein \par ausgegeben wird !!
+ rRTFWrt.pCurPam->GetMark()->nContent++;
+ rRTFWrt.Out_SwDoc( rRTFWrt.pCurPam );
+
+ rWrt.Strm() << "}}" << SwRTFWriter::sNewLine;
+ rRTFWrt.bOutFmtAttr = FALSE;
+
+ } while( FALSE );
+ return rWrt;
+}
+
+static Writer& OutRTF_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt)
+{
+ RTFOutFuncs::Out_Char( rWrt.Strm(), ((SwFmtHardBlank&)rHt).GetChar(),
+ DEF_ENCODING, ((SwRTFWriter&)rWrt).bWriteHelpFmt );
+ return rWrt;
+}
+
+#ifdef USED
+static Writer& OutRTF_SwRefMark( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+
+#ifdef USED
+static Writer& OutRTF_SwNoLinebreakHere( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+static Writer& OutRTF_SwTxtINetFmt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtINetFmt& rURL = (const SwFmtINetFmt&)rHt;
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( rURL.GetValue().Len() )
+ {
+ rWrt.Strm() << '{' << sRTF_FIELD << '{' << sRTF_IGNORE
+ << sRTF_FLDINST << " HYPERLINK ";
+
+ String sURL( rURL.GetValue() );
+ if( INET_MARK_TOKEN != sURL.GetChar(0) )
+ {
+ INetURLObject aTmp( INetURLObject::AbsToRel( sURL ) );
+ sURL = aTmp.GetURLNoMark( INetURLObject::DECODE_WITH_CHARSET );
+/* if( INET_PROT_FILE == aTmp.GetProtocol() )
+ {
+ // WW97 wollen keine FILE-URL haben, sondern einen normalen
+ // Dateinamen. Aber ab WW2000 kennen sie FileURLs.
+ sURL = aTmp.GetFull();
+ }
+*/ rWrt.Strm() << '\"';
+ RTFOutFuncs::Out_String( rWrt.Strm(), sURL, DEF_ENCODING,
+ rRTFWrt.bWriteHelpFmt ) << "\" ";
+ sURL = aTmp.GetMark();
+ }
+
+ if( sURL.Len() )
+ {
+ rWrt.Strm() << "\\\\l \"";
+ sURL.Erase( 0, 1 );
+ RTFOutFuncs::Out_String( rWrt.Strm(), sURL, DEF_ENCODING,
+ rRTFWrt.bWriteHelpFmt ) << "\" ";
+ }
+
+ if( rURL.GetTargetFrame().Len() )
+ {
+ rWrt.Strm() << "\\\\t \"";
+ RTFOutFuncs::Out_String( rWrt.Strm(), rURL.GetTargetFrame(),
+ DEF_ENCODING, rRTFWrt.bWriteHelpFmt ) << "\" ";
+ }
+
+ rWrt.Strm() << "}{" << sRTF_FLDRSLT << ' ';
+ rRTFWrt.bOutFmtAttr = FALSE;
+
+ // und dann noch die Attributierung ausgeben
+ const SwCharFmt* pFmt;
+ const SwTxtINetFmt* pTxtAtr = rURL.GetTxtINetFmt();
+ if( pTxtAtr && 0 != ( pFmt = pTxtAtr->GetCharFmt() ))
+ OutRTF_SwFmt( rWrt, *pFmt );
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtCharFmt& rChrFmt = (const SwFmtCharFmt&)rHt;
+ const SwCharFmt* pFmt = rChrFmt.GetCharFmt();
+
+ if( pFmt )
+ OutRTF_SwFmt( rWrt, *pFmt );
+ return rWrt;
+}
+
+/* File FRMATR.HXX */
+
+static Writer& OutRTF_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const SwFmtFrmSize& rSz = (const SwFmtFrmSize&)rHt;
+ if( rRTFWrt.pFlyFmt ) // wird das FlyFrmFmt ausgegeben ?
+ {
+ if( !rRTFWrt.bRTFFlySyntax )
+ return rWrt;
+
+ if( rSz.GetWidth() )
+ {
+ rWrt.Strm() << sRTF_ABSW;
+ rWrt.OutLong( rSz.GetWidth() );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+
+ if( rSz.GetHeight() )
+ {
+ long nH = rSz.GetHeight();
+ if( ATT_FIX_SIZE == rSz.GetSizeType() )
+ nH = -nH;
+ rWrt.Strm() << sRTF_ABSH;
+ rWrt.OutLong( nH );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ }
+ else if( rRTFWrt.bOutPageDesc )
+ {
+ rWrt.Strm() << sRTF_PGWSXN;
+ rWrt.OutLong( rSz.GetWidth() );
+ rWrt.Strm() << sRTF_PGHSXN;
+ rWrt.OutLong( rSz.GetHeight() );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ return rWrt;
+}
+
+
+
+#ifdef USED
+static Writer& OutRTF_SwFillOrder( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+
+#ifdef USED
+static Writer& OutRTF_SwFmtPaperBin( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+
+
+static Writer& OutRTF_SwFmtLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const SvxLRSpaceItem & rLR = (const SvxLRSpaceItem&) rHt;
+ if( !rRTFWrt.pFlyFmt )
+ {
+ if( rRTFWrt.bOutPageDesc )
+ {
+ if( rLR.GetLeft() )
+ {
+ rWrt.Strm() << sRTF_MARGLSXN;
+ rWrt.OutLong( rLR.GetLeft() );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ if( rLR.GetRight() )
+ {
+ rWrt.Strm() << sRTF_MARGRSXN;
+ rWrt.OutLong( rLR.GetRight() );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ }
+ else
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_LI;
+ rWrt.OutLong( rLR.GetTxtLeft() ) << sRTF_RI;
+ rWrt.OutLong( rLR.GetRight() );
+ rWrt.Strm() << sRTF_FI;
+ rWrt.OutLong( rLR.GetTxtFirstLineOfst() );
+ }
+ }
+ else if( rLR.GetLeft() == rLR.GetRight() && rRTFWrt.bRTFFlySyntax )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_DFRMTXTX;
+ rWrt.OutLong( rLR.GetLeft() );
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SwFmtULSpace( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const SvxULSpaceItem & rUL = (const SvxULSpaceItem&) rHt;
+ if( rRTFWrt.pFlyFmt )
+ {
+ if( rUL.GetUpper() == rUL.GetLower() && rRTFWrt.bRTFFlySyntax )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_DFRMTXTY;
+ rWrt.OutLong( rUL.GetLower() );
+ }
+ }
+ else
+ {
+ const char* p;
+ USHORT nValue = rUL.GetUpper();
+ if( rRTFWrt.bOutPageDesc )
+ {
+ p = sRTF_MARGTSXN;
+ if( !rRTFWrt.bOutPageDescTbl )
+ {
+ SwRect aRect;
+ const SwFmtHeader* pHdr;
+ if( SFX_ITEM_SET == rRTFWrt.pAktPageDesc->GetMaster().
+ GetItemState( RES_HEADER, FALSE,
+ (const SfxPoolItem**)&pHdr ) && pHdr->IsActive() )
+ {
+ aRect = pHdr->GetHeaderFmt()->FindLayoutRect( FALSE );
+ if( aRect.Height() )
+ nValue += aRect.Height();
+ else
+ {
+ const SwFmtFrmSize& rSz = pHdr->GetHeaderFmt()->GetFrmSize();
+ if( ATT_VAR_SIZE != rSz.GetSizeType() )
+ nValue += rSz.GetHeight();
+ else
+ nValue += 274; // defaulten fuer 12pt Schrift
+ nValue += pHdr->GetHeaderFmt()->GetULSpace().GetLower();
+ }
+ }
+ }
+ }
+ else
+ p = sRTF_SB;
+
+ if( rRTFWrt.bOutPageDesc || nValue )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << p;
+ rWrt.OutLong( nValue );
+ }
+
+
+ nValue = rUL.GetLower();
+ if( rRTFWrt.bOutPageDesc )
+ {
+ p = sRTF_MARGBSXN;
+ if( !rRTFWrt.bOutPageDescTbl )
+ {
+ SwRect aRect;
+ const SwFmtFooter* pFtr;
+ if( SFX_ITEM_SET == rRTFWrt.pAktPageDesc->GetMaster().
+ GetItemState( RES_FOOTER, FALSE,
+ (const SfxPoolItem**)&pFtr ) && pFtr->IsActive() )
+ {
+ aRect = pFtr->GetFooterFmt()->FindLayoutRect( FALSE );
+ if( aRect.Height() )
+ nValue += aRect.Height();
+ else
+ {
+ const SwFmtFrmSize& rSz = pFtr->GetFooterFmt()->GetFrmSize();
+ if( ATT_VAR_SIZE != rSz.GetSizeType() )
+ nValue += rSz.GetHeight();
+ else
+ nValue += 274; // defaulten fuer 12pt Schrift
+ nValue += pFtr->GetFooterFmt()->GetULSpace().GetUpper();
+ }
+ }
+ }
+ }
+ else
+ p = sRTF_SA;
+
+ if( rRTFWrt.bOutPageDesc || nValue )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << p;
+ rWrt.OutLong( nValue );
+ }
+ }
+ return rWrt;
+}
+
+// Header-Footer werden auch vom RTF-Writer direkt gerufen, also kein static!
+
+
+Writer& OutRTF_SwFmtHeader( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtHeader& rHd = (const SwFmtHeader&)rHt;
+ if( !rHd.IsActive() ) // nicht aktiv, dann nichts weiter ausgeben
+ return rWrt;
+
+ // hole einen Node zu dem Request
+ SwStartNode *pSttNode = 0;
+ const SwFmtCntnt& rCntnt = rHd.GetHeaderFmt()->GetCntnt();
+ if( rCntnt.GetCntntIdx() )
+ pSttNode = rCntnt.GetCntntIdx()->GetNode().GetStartNode();
+
+ do { // middle-check-loop
+ if( !pSttNode )
+ break; // es gibt keine Kopf-/Fusszeile/Fussnote
+
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+
+ // Hole vom Node und vom letzten Node die Position in der Section
+ ULONG nStart = pSttNode->GetIndex() + 1,
+ nEnd = pSttNode->EndOfSectionIndex();
+
+ // kein Bereich also kein gueltiger Node
+ if( nStart >= nEnd )
+ break;
+ ASSERT( rRTFWrt.pAktPageDesc, "Header-Attribut ohne PageDesc" );
+
+ const sal_Char * pHdNm = sRTF_HEADER;
+ rWrt.Strm() << pHdNm << 'y';
+ if( rRTFWrt.bOutPageDescTbl )
+ {
+ // hole die Ober-/Unterkanten vom Header
+ const SvxULSpaceItem& rUL = rHd.GetHeaderFmt()->GetULSpace();
+ const SvxLRSpaceItem& rLR = rHd.GetHeaderFmt()->GetLRSpace();
+ const SwFmtFrmSize& rSz = rHd.GetHeaderFmt()->GetFrmSize();
+
+ rWrt.OutLong( rUL.GetUpper() );
+ OutComment( rWrt, pHdNm ) << "yb";
+ rWrt.OutLong( rUL.GetLower() ) << pHdNm << "xl";
+ rWrt.OutLong( rLR.GetLeft() ) << pHdNm << "xr";
+ rWrt.OutLong( rLR.GetRight() ) << pHdNm << "yh";
+ rWrt.OutLong( ATT_FIX_SIZE == rSz.GetSizeType()
+ ? -rSz.GetHeight()
+ : rSz.GetHeight() ) << '}';
+ }
+ else
+ rWrt.OutLong( rRTFWrt.pAktPageDesc->GetMaster().
+ GetULSpace().GetUpper() );
+
+ // wird nicht die PageDesc-Tabelle ausgegeben und gibt es einen
+ // Nachfolger, dann handelt es sich um die "1.Seite" nach RTF.
+ sal_Char cTyp = 0;
+ if( !rRTFWrt.bOutPageDesc && rRTFWrt.pAktPageDesc->GetFollow() &&
+ rRTFWrt.pAktPageDesc->GetFollow() != rRTFWrt.pAktPageDesc )
+ cTyp = 'f'; // dann FirstPage-Header
+ else if( !rRTFWrt.pAktPageDesc->IsHeaderShared() )
+ cTyp = rRTFWrt.bOutLeftHeadFoot ? 'l' : 'r';
+
+ rWrt.Strm() << '{'<< pHdNm;
+ if( cTyp ) rWrt.Strm() << cTyp;
+ rWrt.Strm() << ' ';
+
+ {
+ RTFSaveData aSaveData( rRTFWrt, nStart, nEnd );
+ rRTFWrt.Out_SwDoc( rRTFWrt.pCurPam );
+ }
+
+ rWrt.Strm() << '}' << SwRTFWriter::sNewLine;
+
+ } while( FALSE );
+ return rWrt;
+}
+// Header-Footer werden auch vom RTF-Writer direkt gerufen, also kein static!
+
+
+Writer& OutRTF_SwFmtFooter( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtFooter& rFt = (const SwFmtFooter&)rHt;
+ if( !rFt.IsActive() ) // nicht aktiv, dann nichts weiter ausgeben
+ return rWrt;
+
+ SwStartNode *pSttNode = 0;
+ const SwFmtCntnt& rCntnt = rFt.GetFooterFmt()->GetCntnt();
+ if( rCntnt.GetCntntIdx() )
+ pSttNode = rCntnt.GetCntntIdx()->GetNode().GetStartNode();
+
+ do { // middle-check-loop
+ if( !pSttNode )
+ break; // es gibt keine Kopf-/Fusszeile/Fussnote
+
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+
+ // Hole vom Node und vom letzten Node die Position in der Section
+ ULONG nStart = pSttNode->GetIndex()+1,
+ nEnd = pSttNode->EndOfSectionIndex();
+
+ // kein Bereich also kein gueltiger Node
+ if( nStart >= nEnd )
+ break;
+ ASSERT( rRTFWrt.pAktPageDesc, "Footer-Attribut ohne PageDesc" );
+
+ const sal_Char * pFtNm = sRTF_FOOTER;
+ rWrt.Strm() << pFtNm << 'y';
+ if( rRTFWrt.bOutPageDescTbl )
+ {
+ // hole die Ober-/Unterkanten vom Footer
+ const SvxULSpaceItem& rUL = rFt.GetFooterFmt()->GetULSpace();
+ const SvxLRSpaceItem& rLR = rFt.GetFooterFmt()->GetLRSpace();
+ const SwFmtFrmSize& rSz = rFt.GetFooterFmt()->GetFrmSize();
+
+ rWrt.OutLong( rUL.GetLower() );
+ OutComment( rWrt, pFtNm ) << "yt";
+ rWrt.OutLong( rUL.GetUpper() ) << pFtNm << "xl";
+ rWrt.OutLong( rLR.GetLeft() ) << pFtNm << "xr";
+ rWrt.OutLong( rLR.GetRight() ) << pFtNm << "yh";
+ rWrt.OutLong( ATT_FIX_SIZE == rSz.GetSizeType()
+ ? -rSz.GetHeight()
+ : rSz.GetHeight() ) << '}';
+ }
+ else
+ rWrt.OutLong( rRTFWrt.pAktPageDesc->GetMaster().
+ GetULSpace().GetLower() );
+
+ // wird nicht die PageDesc-Tabelle ausgegeben und gibt es einen
+ // Nachfolger, dann handelt es sich um die "1.Seite" nach RTF.
+ sal_Char cTyp = 0;
+ if( !rRTFWrt.bOutPageDesc && rRTFWrt.pAktPageDesc->GetFollow() &&
+ rRTFWrt.pAktPageDesc->GetFollow() != rRTFWrt.pAktPageDesc )
+ cTyp = 'f'; // dann FirstPage-Header
+ else if( !rRTFWrt.pAktPageDesc->IsFooterShared() )
+ cTyp = rRTFWrt.bOutLeftHeadFoot ? 'l' : 'r';
+
+ rWrt.Strm() << '{'<< pFtNm;
+ if( cTyp ) rWrt.Strm() << cTyp;
+ rWrt.Strm() << ' ';
+
+ {
+ RTFSaveData aSaveData( rRTFWrt, nStart, nEnd );
+ rRTFWrt.Out_SwDoc( rRTFWrt.pCurPam );
+ }
+
+ rWrt.Strm() << '}' << SwRTFWriter::sNewLine;
+
+ } while( FALSE );
+ return rWrt;
+}
+
+static Writer& OutRTF_SwFmtPrint( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( !rRTFWrt.bRTFFlySyntax && !((const SvxPrintItem&)rHt).GetValue() )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_FLYPRINT;
+ }
+ return rWrt;
+}
+
+
+static Writer& OutRTF_SwFmtOpaque( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( !rRTFWrt.bRTFFlySyntax && !((const SvxOpaqueItem&)rHt).GetValue() )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_FLYOPAQUE;
+ }
+ return rWrt;
+}
+
+
+static Writer& OutRTF_SwFmtProtect( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( !rRTFWrt.bRTFFlySyntax )
+ {
+ const SvxProtectItem & rFlyProtect = (const SvxProtectItem&) rHt;
+ RTFProtect aP( rFlyProtect.IsCntntProtected(),
+ rFlyProtect.IsSizeProtected(),
+ rFlyProtect.IsPosProtected() );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_FLYPRTCTD;
+ rWrt.OutULong( aP.GetValue() );
+ }
+ return rWrt;
+}
+
+
+static Writer& OutRTF_SwFmtSurround( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtSurround& rFlySurround = (const SwFmtSurround&) rHt;
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( rRTFWrt.bRTFFlySyntax )
+ {
+ if( SURROUND_NONE == rFlySurround.GetSurround() )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_NOWRAP;
+ }
+ }
+ else
+ {
+ SwSurround eSurround = rFlySurround.GetSurround();
+ BOOL bGold = SURROUND_IDEAL == eSurround;
+ if( bGold )
+ eSurround = SURROUND_PARALLEL;
+ RTFSurround aMC( bGold, eSurround );
+ rWrt.Strm() << sRTF_FLYMAINCNT;
+ rWrt.OutULong( aMC.GetValue() );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SwFmtVertOrient ( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtVertOrient& rFlyVert = (const SwFmtVertOrient&) rHt;
+ RTFVertOrient aVO( rFlyVert.GetVertOrient(), rFlyVert.GetRelationOrient() );
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+
+ if( rRTFWrt.bRTFFlySyntax && rRTFWrt.pFlyFmt )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ const char* pOrient;
+ RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId();
+ SwRelationOrient eOrient = rFlyVert.GetRelationOrient();
+ if( FLY_PAGE == eAnchor )
+ {
+ if( REL_PG_FRAME == eOrient || FRAME == eOrient )
+ pOrient = sRTF_PVPG;
+ else
+ pOrient = sRTF_PVMRG;
+ }
+ else
+ pOrient = sRTF_PVPARA;
+ rWrt.Strm() << pOrient;
+
+ switch( rFlyVert.GetVertOrient() )
+ {
+ case VERT_TOP:
+ case VERT_LINE_TOP: rWrt.Strm() << sRTF_POSYT; break;
+ case VERT_BOTTOM:
+ case VERT_LINE_BOTTOM: rWrt.Strm() << sRTF_POSYB; break;
+ case VERT_CENTER:
+ case VERT_LINE_CENTER: rWrt.Strm() << sRTF_POSYC; break;
+ case VERT_NONE:
+ {
+ rWrt.Strm() << sRTF_POSY;
+ rWrt.OutULong( rFlyVert.GetPos() );
+ }
+ break;
+ }
+ }
+ else if( !rRTFWrt.bRTFFlySyntax )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_FLYVERT;
+ rWrt.OutULong( aVO.GetValue() );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutRTF_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtHoriOrient& rFlyHori = (const SwFmtHoriOrient&) rHt;
+ RTFHoriOrient aHO( rFlyHori.GetHoriOrient(),
+ rFlyHori.GetRelationOrient() );
+
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( rRTFWrt.bRTFFlySyntax && rRTFWrt.pFlyFmt )
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ const char* pS;
+ RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId();
+ SwRelationOrient eOrient = rFlyHori.GetRelationOrient();
+ if( FLY_PAGE == eAnchor )
+ {
+ if( REL_PG_FRAME == eOrient || FRAME == eOrient )
+ pS = sRTF_PHPG;
+ else
+ pS = sRTF_PHMRG;
+ }
+ else
+ pS = sRTF_PHCOL;
+ rWrt.Strm() << pS;
+
+ pS = 0;
+ switch( rFlyHori.GetHoriOrient() )
+ {
+ case HORI_RIGHT: pS = rFlyHori.IsPosToggle()
+ ? sRTF_POSXO
+ : sRTF_POSXR;
+ break;
+ case HORI_LEFT: pS = rFlyHori.IsPosToggle()
+ ? sRTF_POSXI
+ : sRTF_POSXL;
+ break;
+ case HORI_CENTER: pS = sRTF_POSXC; break;
+ case HORI_NONE:
+ {
+ rWrt.Strm() << sRTF_POSX;
+ rWrt.OutULong( rFlyHori.GetPos() );
+ }
+ break;
+ }
+ if( pS )
+ rWrt.Strm() << pS;
+ }
+ else
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_FLYHORZ;
+ rWrt.OutULong( aHO.GetValue() );
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( !rRTFWrt.bRTFFlySyntax )
+ {
+ const SwFmtAnchor& rAnchor = (const SwFmtAnchor&) rHt;
+ USHORT nId = rAnchor.GetAnchorId();
+ rWrt.Strm() << sRTF_FLYANCHOR;
+ rWrt.OutULong( nId );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ switch( nId )
+ {
+ case FLY_PAGE:
+ rWrt.Strm() << sRTF_FLYPAGE;
+ rWrt.OutULong( rAnchor.GetPageNum() );
+ break;
+ case FLY_AT_CNTNT:
+ case FLY_IN_CNTNT:
+ rWrt.Strm() << sRTF_FLYCNTNT;
+ break;
+ }
+ }
+ return rWrt;
+}
+
+
+
+static Writer& OutRTF_SwFmtBackground( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ // wird das FlyFrmFmt ausgegeben, dann Background nur ausgeben, wenn
+ // RTF-Syntax gesetzt ist !
+ if( !rRTFWrt.pFlyFmt || !rRTFWrt.bRTFFlySyntax )
+ {
+ const SvxBrushItem& rBack = (const SvxBrushItem&)rHt;
+ if( !rBack.GetColor().GetTransparency() )
+ {
+ ByteString sOut( sRTF_CBPAT );
+ sOut += ByteString::CreateFromInt32(
+ rRTFWrt.GetId( rBack.GetColor() ));
+
+ if( rRTFWrt.pFlyFmt || rRTFWrt.bOutPageDesc )
+ {
+ rWrt.Strm() << '{' << sOut.GetBuffer() << '}';
+ }
+ else
+ {
+ rRTFWrt.bOutFmtAttr = TRUE;
+ rWrt.Strm() << sOut.GetBuffer();
+ }
+ }
+ }
+ return rWrt;
+}
+
+
+static Writer& OutRTF_SwFmtShadow( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ // wird das FlyFrmFmt ausgegeben, dann Schatten nur ausgeben, wenn
+ // nicht RTF-Syntax gesetzt ist !
+ if( rRTFWrt.pFlyFmt && rRTFWrt.bRTFFlySyntax )
+ return rWrt;
+
+ const SvxShadowItem& rShadow = (const SvxShadowItem&)rHt;
+ // FALSE wegen schliessender Klammer !!
+ OutComment( rWrt, sRTF_SHADOW, FALSE );
+ rWrt.OutULong( rShadow.GetLocation() ) << sRTF_SHDWDIST;
+ rWrt.OutULong( rShadow.GetWidth() ) << sRTF_SHDWSTYLE;
+ const Color& rColor = rShadow.GetColor();
+ rWrt.OutULong( rColor.GetTransparency() ? SW_SV_BRUSH_NULL : SW_SV_BRUSH_SOLID );
+ rWrt.OutULong( rRTFWrt.GetId( rColor ) ) << sRTF_SHDWFCOL;
+ rWrt.OutULong( 0 ) << '}';
+ return rWrt;
+}
+
+
+static void OutBorderLine( SwRTFWriter& rWrt, const SvxBorderLine* pLine,
+ const char* pStr )
+{
+ rWrt.Strm() << pStr << sRTF_BRDLNCOL;
+ rWrt.OutULong( rWrt.GetId( pLine->GetColor() ) ) << sRTF_BRDLNIN;
+ rWrt.OutULong( pLine->GetInWidth() ) << sRTF_BRDLNOUT;
+ rWrt.OutULong( pLine->GetOutWidth() ) << sRTF_BRDLNDIST;
+ rWrt.OutULong( pLine->GetDistance() );
+}
+
+
+static Writer& OutRTF_SwFmtBox( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+
+ const SvxBoxItem& rBox = (const SvxBoxItem&)rHt;
+
+ static USHORT __READONLY_DATA aBorders[] = {
+ BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
+ static const sal_Char* __READONLY_DATA aBorderNames[] = {
+ sRTF_BRDRT, sRTF_BRDRL, sRTF_BRDRB, sRTF_BRDRR };
+
+ USHORT nDist = rBox.GetDistance();
+
+ // wird das FlyFrmFmt ausgegeben, dann Border nur ausgeben, wenn
+ // nicht RTF-Syntax gesetzt ist!
+ if( rRTFWrt.pFlyFmt && rRTFWrt.bRTFFlySyntax )
+ {
+/*
+RTF kennt keine Rahmen Umrandung!
+ // die normale RTF-Definition
+ if( rBox.GetTop() && rBox.GetBottom() &&
+ rBox.GetLeft() && rBox.GetRight() &&
+ *rBox.GetTop() == *rBox.GetBottom() &&
+ *rBox.GetTop() == *rBox.GetLeft() &&
+ *rBox.GetTop() == *rBox.GetRight() )
+ OutTBLBorderLine( rRTFWrt, rBox.GetTop(), sRTF_BOX, nDist );
+ else
+ {
+ OUT_BRDLINE( rBox.GetTop(), sRTF_BRDRT, nDist );
+ OUT_BRDLINE( rBox.GetBottom(), sRTF_BRDRB, nDist );
+ OUT_BRDLINE( rBox.GetLeft(), sRTF_BRDRL, nDist );
+ OUT_BRDLINE( rBox.GetRight(), sRTF_BRDRR, nDist );
+ }
+*/
+ return rWrt;
+ }
+ else if( !rRTFWrt.pFlyFmt )
+ {
+ // erst die normale RTF-Definition, dann unsere eigene
+ if( rBox.GetTop() && rBox.GetBottom() &&
+ rBox.GetLeft() && rBox.GetRight() &&
+ *rBox.GetTop() == *rBox.GetBottom() &&
+ *rBox.GetTop() == *rBox.GetLeft() &&
+ *rBox.GetTop() == *rBox.GetRight() &&
+ nDist == rBox.GetDistance( BOX_LINE_TOP ) &&
+ nDist == rBox.GetDistance( BOX_LINE_LEFT ) &&
+ nDist == rBox.GetDistance( BOX_LINE_BOTTOM ) &&
+ nDist == rBox.GetDistance( BOX_LINE_RIGHT ))
+ OutTBLBorderLine( rRTFWrt, rBox.GetTop(), sRTF_BOX, nDist );
+ else
+ {
+ const USHORT* pBrd = aBorders;
+ const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
+ for( int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms )
+ {
+ const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
+ if( pLn )
+ OutTBLBorderLine( rRTFWrt, pLn, *pBrdNms,
+ rBox.GetDistance( *pBrd ) );
+ }
+ }
+ }
+
+ const USHORT* pBrd = aBorders;
+ const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
+ for( int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms )
+ {
+ const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
+ if( pLn )
+ {
+ rWrt.Strm() << '{' << sRTF_IGNORE;
+ OutBorderLine( rRTFWrt, pLn, *pBrdNms );
+ rWrt.Strm() << '}' << sRTF_BRSP;
+ rWrt.OutULong( rBox.GetDistance( *pBrd ));
+ }
+ }
+
+ rRTFWrt.bOutFmtAttr = FALSE;
+ return rWrt;
+}
+
+
+#ifdef USED
+static Writer& OutRTF_SwFmtFrmMacro( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+static Writer& OutRTF_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = ((SwRTFWriter&)rWrt);
+ if( rRTFWrt.pFlyFmt && rRTFWrt.bRTFFlySyntax )
+ return rWrt;
+
+ const SwFmtCol& rCol = (const SwFmtCol&)rHt;
+ const SwColumns& rColumns = rCol.GetColumns();
+
+ USHORT nCols = rColumns.Count();
+ if( 1 < nCols )
+ {
+ // dann besorge mal die Seitenbreite ohne Raender !!
+ const SwFrmFmt* pFmt;
+
+ if( rRTFWrt.pFlyFmt )
+ pFmt = rRTFWrt.pFlyFmt;
+ else if( rRTFWrt.pAktPageDesc )
+ pFmt = &rRTFWrt.pAktPageDesc->GetMaster();
+ else
+ pFmt = &rWrt.pDoc->GetPageDesc(0).GetMaster();
+
+ const SvxLRSpaceItem& rLR = pFmt->GetLRSpace();
+
+ USHORT nPageSize = pFmt->GetFrmSize().GetWidth() -
+ rLR.GetLeft() - rLR.GetRight();
+
+ rWrt.Strm() << sRTF_COLS;
+ rWrt.OutLong( nCols );
+
+ if( rCol.IsOrtho() )
+ {
+ rWrt.Strm() << sRTF_COLSX;
+ rWrt.OutLong( rCol.GetGutterWidth( TRUE ) );
+ }
+ else
+ for( USHORT n = 0; n < nCols; )
+ {
+ rWrt.Strm() << sRTF_COLNO;
+ rWrt.OutLong( n+1 );
+
+ rWrt.Strm() << sRTF_COLW;
+ rWrt.OutLong( rCol.CalcPrtColWidth( n, nPageSize ) );
+ if( ++n != nCols )
+ {
+ rWrt.Strm() << sRTF_COLSR;
+ rWrt.OutLong( rColumns[ n-1 ]->GetRight() +
+ rColumns[ n ]->GetLeft() );
+ }
+ }
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SvxFmtKeep( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxFmtKeepItem& rItem = (const SvxFmtKeepItem&)rHt;
+ if( rItem.GetValue() )
+ {
+ rWrt.Strm() << sRTF_KEEPN;
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ }
+ return rWrt;
+}
+
+/* File GRFATR.HXX */
+
+static Writer& OutRTF_SwMirrorGrf( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwMirrorGrf & rMirror = (const SwMirrorGrf&)rHt;
+ if( RES_DONT_MIRROR_GRF == rMirror.GetValue() )
+ return rWrt;
+
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_IGNORE << sRTF_GRFMIRROR;
+ rWrt.OutULong( rMirror.GetValue() );
+ return rWrt;
+}
+
+static Writer& OutRTF_SwCropGrf( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwCropGrf & rCrop = (const SwCropGrf&)rHt;
+ ByteString aStr;
+ if( rCrop.GetLeft() )
+ ( aStr += sRTF_PICCROPL ) +=
+ ByteString::CreateFromInt32( (short)rCrop.GetLeft() );
+ if( rCrop.GetRight() )
+ ( aStr += sRTF_PICCROPR ) +=
+ ByteString::CreateFromInt32( (short)rCrop.GetRight() );
+ if( rCrop.GetTop() )
+ ( aStr += sRTF_PICCROPT ) +=
+ ByteString::CreateFromInt32( (short)rCrop.GetTop() );
+ if( rCrop.GetBottom() )
+ ( aStr += sRTF_PICCROPB ) +=
+ ByteString::CreateFromInt32( (short)rCrop.GetBottom() );
+ if( aStr.Len() )
+ {
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ rWrt.Strm() << aStr.GetBuffer();
+ }
+ return rWrt;
+}
+
+
+
+/* File PARATR.HXX */
+
+static Writer& OutRTF_SwLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxLineSpacingItem &rLs = (const SvxLineSpacingItem&)rHt;
+
+ switch( rLs.GetLineSpaceRule() )
+ {
+ case SVX_LINE_SPACE_AUTO:
+ case SVX_LINE_SPACE_FIX:
+ case SVX_LINE_SPACE_MIN:
+ {
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ rWrt.Strm() << sRTF_SL;
+ sal_Char cMult = '0';
+ switch( rLs.GetInterLineSpaceRule() )
+ {
+ case SVX_INTER_LINE_SPACE_FIX: // unser Durchschuss
+ // gibt es aber nicht in WW - also wie kommt man an
+ // die MaxLineHeight heran?
+ rWrt.OutLong( (short)rLs.GetInterLineSpace() );
+ break;
+
+ case SVX_INTER_LINE_SPACE_PROP:
+ rWrt.OutLong( (240L * rLs.GetPropLineSpace()) / 100L );
+ cMult = '1';
+ break;
+
+ default:
+ if( SVX_LINE_SPACE_FIX == rLs.GetLineSpaceRule() )
+ rWrt.Strm() << '-';
+
+ rWrt.OutLong( rLs.GetLineHeight() );
+ break;
+ }
+ rWrt.Strm() << sRTF_SLMULT << cMult;
+ }
+ break;
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SwAdjust( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxAdjustItem & rAdjust = ((const SvxAdjustItem&)rHt);
+ ByteString aAttr( "\\q" );
+ switch( rAdjust.GetAdjust() )
+ {
+ case SVX_ADJUST_LEFT: aAttr += 'l'; break;
+ case SVX_ADJUST_RIGHT: aAttr += 'r'; break;
+ case SVX_ADJUST_BLOCKLINE:
+ case SVX_ADJUST_BLOCK: aAttr += 'j'; break;
+ case SVX_ADJUST_CENTER: aAttr += 'c'; break;
+
+ default:
+ return rWrt; // kein gueltiges Attriut, also returnen
+ }
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ rWrt.Strm() << aAttr.GetBuffer();
+ return rWrt;
+}
+
+static Writer& OutRTF_SvxFmtSplit( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxFmtSplitItem& rItem = (const SvxFmtSplitItem&)rHt;
+ if( !rItem.GetValue() )
+ {
+ rWrt.Strm() << sRTF_KEEP;
+ ((SwRTFWriter&)rWrt).bOutFmtAttr = TRUE;
+ }
+ return rWrt;
+}
+
+
+#ifdef USED
+static Writer& OutRTF_SwWidows( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+#ifdef USED
+static Writer& OutRTF_SwOrphans( Writer& rWrt, const SfxPoolItem& )
+{
+ return rWrt;
+}
+#endif
+
+
+
+static Writer& OutRTF_SwTabStop( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ const SvxTabStopItem & rTStops = (const SvxTabStopItem&)rHt;
+ long nOffset = rRTFWrt.pAttrSet->GetLRSpace().GetTxtLeft();
+ for( USHORT n = 0; n < rTStops.Count(); n++ )
+ {
+ const SvxTabStop & rTS = rTStops[ n ];
+ if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() )
+ {
+ BOOL bOutDecimal = TRUE;
+ const char* pFill = 0;
+ switch( rTS.GetFill() )
+ {
+ case cDfltFillChar:
+ break;
+
+ case '.': pFill = sRTF_TLDOT; break;
+ case '_': pFill = sRTF_TLUL; break;
+ case '-': pFill = sRTF_TLTH; break;
+ case '=': pFill = sRTF_TLEQ; break;
+ default:
+ if( !rRTFWrt.bWriteHelpFmt )
+ {
+ OutComment( rWrt, sRTF_TLSWG, FALSE );
+ rWrt.OutULong( (((USHORT)rTS.GetFill()) << 8 ) +
+ rTS.GetDecimal() )
+ << '}';
+ bOutDecimal = FALSE;
+ }
+ }
+ if( pFill )
+ rWrt.Strm() << pFill;
+
+ if( !rRTFWrt.bWriteHelpFmt && bOutDecimal &&
+ rTS.GetDecimal() != ((SvxTabStopItem&)*GetDfltAttr(
+ RES_PARATR_TABSTOP ))[ 0 ].GetDecimal() )
+ {
+ OutComment( rWrt, sRTF_TLSWG, FALSE );
+ rWrt.OutULong( (((USHORT)rTS.GetFill()) << 8 ) +
+ rTS.GetDecimal() ) << '}';
+ }
+
+ const sal_Char* pAdjStr = 0;
+ switch( rTS.GetAdjustment() )
+ {
+ case SVX_TAB_ADJUST_RIGHT: pAdjStr = sRTF_TQR; break;
+ case SVX_TAB_ADJUST_DECIMAL: pAdjStr = sRTF_TQDEC; break;
+ case SVX_TAB_ADJUST_CENTER: pAdjStr = sRTF_TQC; break;
+ }
+ if( pAdjStr )
+ rWrt.Strm() << pAdjStr;
+ rWrt.Strm() << sRTF_TX;
+ rWrt.OutLong( rTS.GetTabPos() + nOffset );
+ }
+ }
+ rRTFWrt.bOutFmtAttr = TRUE;
+ return rWrt;
+}
+
+static Writer& OutRTF_SwHypenZone( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ if( !((SwRTFWriter&)rWrt).bWriteHelpFmt )
+ {
+ const SvxHyphenZoneItem& rAttr = (const SvxHyphenZoneItem&)rHt;
+
+ USHORT nFlags = rAttr.IsHyphen() ? 1 : 0;
+ if( rAttr.IsPageEnd() ) nFlags += 2;
+
+ OutComment( rWrt, sRTF_HYPHEN, FALSE );
+ rWrt.OutULong( nFlags ) << sRTF_HYPHLEAD;
+ rWrt.OutULong( rAttr.GetMinLead() ) << sRTF_HYPHTRAIL;
+ rWrt.OutULong( rAttr.GetMinTrail() ) << sRTF_HYPHMAX;
+ rWrt.OutULong( rAttr.GetMaxHyphens() ) << '}';
+ }
+ return rWrt;
+}
+
+static Writer& OutRTF_SwNumRule( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwRTFWriter& rRTFWrt = (SwRTFWriter&)rWrt;
+ if( !rRTFWrt.bOutListNumTxt )
+ {
+ const SwNumRuleItem& rAttr = (const SwNumRuleItem&)rHt;
+ USHORT nId;
+ if( rAttr.GetValue().Len() &&
+ USHRT_MAX != (nId = rRTFWrt.GetId( rAttr ) ) )
+ {
+ rWrt.Strm() << sRTF_LS;
+ rWrt.OutULong( nId );
+ rRTFWrt.bOutFmtAttr = TRUE;
+ }
+ }
+ return rWrt;
+}
+
+/*
+ * lege hier die Tabellen fuer die RTF-Funktions-Pointer auf
+ * die Ausgabe-Funktionen an.
+ * Es sind lokale Strukturen, die nur innerhalb der RTF-DLL
+ * bekannt sein muessen.
+ */
+
+SwAttrFnTab aRTFAttrFnTab = {
+/* RES_CHRATR_CASEMAP */ OutRTF_SwCaseMap,
+/* RES_CHRATR_CHARSETCOLOR */ 0,
+/* RES_CHRATR_COLOR */ OutRTF_SwColor,
+/* RES_CHRATR_CONTOUR */ OutRTF_SwContour,
+/* RES_CHRATR_CROSSEDOUT */ OutRTF_SwCrossedOut,
+/* RES_CHRATR_ESCAPEMENT */ OutRTF_SwEscapement,
+/* RES_CHRATR_FONT */ OutRTF_SwFont,
+/* RES_CHRATR_FONTSIZE */ OutRTF_SwSize,
+/* RES_CHRATR_KERNING */ 0, // NOT USED!! OutRTF_SwKerning,
+/* RES_CHRATR_LANGUAGE */ OutRTF_SwLanguage,
+/* RES_CHRATR_POSTURE */ OutRTF_SwPosture,
+/* RES_CHRATR_PROPORTIONALFONTSIZE*/0,
+/* RES_CHRATR_SHADOWED */ OutRTF_SwShadowed,
+/* RES_CHRATR_UNDERLINE */ OutRTF_SwUnderline,
+/* RES_CHRATR_WEIGHT */ OutRTF_SwWeight,
+/* RES_CHRATR_WORDLINEMODE */ 0, // Neu: Wortweises Unter-/Durchstreichen
+/* RES_CHRATR_AUTOKERN */ 0, // Neu: Automatisches Pairkerning
+/* RES_CHRATR_BLINK */ 0, // Neu: Blinkender Text
+/* RES_CHRATR_NOHYPHEN */ 0, // Neu: nicht trennen
+/* RES_CHRATR_NOLINEBREAK */ 0, // Neu: nicht umbrechen
+/* RES_CHRATR_BACKGROUND */ 0, // Neu: Zeichenhintergrund
+/* RES_CHRATR_CJK_FONT */ 0,
+/* RES_CHRATR_CJK_FONTSIZE */ 0,
+/* RES_CHRATR_CJK_LANGUAGE */ 0,
+/* RES_CHRATR_CJK_POSTURE */ 0,
+/* RES_CHRATR_CJK_WEIGHT */ 0,
+/* RES_CHRATR_CTL_FONT */ 0,
+/* RES_CHRATR_CTL_FONTSIZE */ 0,
+/* RES_CHRATR_CTL_LANGUAGE */ 0,
+/* RES_CHRATR_CTL_POSTURE */ 0,
+/* RES_CHRATR_CTL_WEIGHT */ 0,
+/* RES_CHRATR_WRITING_DIRECTION */ 0,
+/* RES_CHRATR_DUMMY2 */ 0,
+/* RES_CHRATR_DUMMY3 */ 0,
+/* RES_CHRATR_DUMMY4 */ 0,
+/* RES_CHRATR_DUMMY5 */ 0,
+/* RES_CHRATR_DUMMY1 */ 0, // Dummy:
+
+/* RES_TXTATR_INETFMT */ OutRTF_SwTxtINetFmt, // Dummy
+/* RES_TXTATR_NOHYPHEN */ 0, // Dummy
+/* RES_TXTATR_REFMARK*/ 0, // NOT USED!! OutRTF_SwRefMark,
+/* RES_TXTATR_TOXMARK */ 0, // NOT USED!! OutRTF_SwTOXMark,
+/* RES_TXTATR_CHARFMT */ OutRTF_SwTxtCharFmt,
+/* RES_TXTATR_TWO_LINES */ 0,
+/* RES_TXTATR_CJK_RUBY */ 0,
+/* RES_TXTATR_UNKNOWN_CONTAINER */ 0,
+/* RES_TXTATR_DUMMY5 */ 0,
+/* RES_TXTATR_DUMMY6 */ 0,
+
+/* RES_TXTATR_FIELD */ OutRTF_SwField,
+/* RES_TXTATR_FLYCNT */ OutRTF_SwFlyCntnt,
+/* RES_TXTATR_FTN */ OutRTF_SwFtn,
+/* RES_TXTATR_SOFTHYPH */ 0, // old attr. - coded now by character
+/* RES_TXTATR_HARDBLANK*/ OutRTF_SwHardBlank,
+/* RES_TXTATR_DUMMY1 */ 0, // Dummy:
+/* RES_TXTATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_PARATR_LINESPACING */ OutRTF_SwLineSpacing,
+/* RES_PARATR_ADJUST */ OutRTF_SwAdjust,
+/* RES_PARATR_SPLIT */ OutRTF_SvxFmtSplit,
+/* RES_PARATR_WIDOWS */ 0, // NOT USED!! OutRTF_SwWidows,
+/* RES_PARATR_ORPHANS */ 0, // NOT USED!! OutRTF_SwOrphans,
+/* RES_PARATR_TABSTOP */ OutRTF_SwTabStop,
+/* RES_PARATR_HYPHENZONE*/ OutRTF_SwHypenZone,
+/* RES_PARATR_DROP */ 0,
+/* RES_PARATR_REGISTER */ 0, // neu: Registerhaltigkeit
+/* RES_PARATR_NUMRULE */ OutRTF_SwNumRule,
+/* RES_PARATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_FILL_ORDER */ 0, // NOT USED!! OutRTF_SwFillOrder,
+/* RES_FRM_SIZE */ OutRTF_SwFrmSize,
+/* RES_PAPER_BIN */ 0, // NOT USED!! OutRTF_SwFmtPaperBin,
+/* RES_LR_SPACE */ OutRTF_SwFmtLRSpace,
+/* RES_UL_SPACE */ OutRTF_SwFmtULSpace,
+/* RES_PAGEDESC */ 0,
+/* RES_BREAK */ 0,
+/* RES_CNTNT */ 0,
+/* RES_HEADER */ OutRTF_SwFmtHeader,
+/* RES_FOOTER */ OutRTF_SwFmtFooter,
+/* RES_PRINT */ OutRTF_SwFmtPrint,
+/* RES_OPAQUE */ OutRTF_SwFmtOpaque,
+/* RES_PROTECT */ OutRTF_SwFmtProtect,
+/* RES_SURROUND */ OutRTF_SwFmtSurround,
+/* RES_VERT_ORIENT */ OutRTF_SwFmtVertOrient,
+/* RES_HORI_ORIENT */ OutRTF_SwFmtHoriOrient,
+/* RES_ANCHOR */ OutRTF_SwFmtAnchor,
+/* RES_BACKGROUND */ OutRTF_SwFmtBackground,
+/* RES_BOX */ OutRTF_SwFmtBox,
+/* RES_SHADOW */ OutRTF_SwFmtShadow,
+/* RES_FRMMACRO */ 0, // NOT USED!! OutRTF_SwFmtFrmMacro,
+/* RES_COL */ OutRTF_SwFmtCol,
+/* RES_KEEP */ OutRTF_SvxFmtKeep,
+/* RES_URL */ 0, // URL
+/* RES_EDIT_IN_READONLY */ 0,
+/* RES_LAYOUT_SPLIT */ 0,
+/* RES_FRMATR_DUMMY1 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY2 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY3 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY4 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY5 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY6 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY7 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY8 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY9 */ 0, // Dummy:
+
+/* RES_GRFATR_MIRRORGRF */ OutRTF_SwMirrorGrf,
+/* RES_GRFATR_CROPGRF */ OutRTF_SwCropGrf,
+/* RES_GRFATR_ROTATION */ 0,
+/* RES_GRFATR_LUMINANCE */ 0,
+/* RES_GRFATR_CONTRAST */ 0,
+/* RES_GRFATR_CHANNELR */ 0,
+/* RES_GRFATR_CHANNELG */ 0,
+/* RES_GRFATR_CHANNELB */ 0,
+/* RES_GRFATR_GAMMA */ 0,
+/* RES_GRFATR_INVERT */ 0,
+/* RES_GRFATR_TRANSPARENCY */ 0,
+/* RES_GRFATR_DRWAMODE */ 0,
+/* RES_GRFATR_DUMMY1 */ 0,
+/* RES_GRFATR_DUMMY2 */ 0,
+/* RES_GRFATR_DUMMY3 */ 0,
+/* RES_GRFATR_DUMMY4 */ 0,
+/* RES_GRFATR_DUMMY5 */ 0,
+
+/* RES_BOXATR_FORMAT */ 0,
+/* RES_BOXATR_FORMULA */ 0,
+/* RES_BOXATR_VALUE */ 0,
+
+/* RES_UNKNOWNATR_CONTAINER */ 0
+};
+
+SwNodeFnTab aRTFNodeFnTab = {
+/* RES_TXTNODE */ OutRTF_SwTxtNode,
+/* RES_GRFNODE */ OutRTF_SwGrfNode,
+/* RES_OLENODE */ OutRTF_SwOLENode
+};
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/rtf/rtfatr.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.344 2000/09/18 16:04:50 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.343 2000/08/30 16:46:03 jp
+ use CharClass instead of international
+
+ Revision 1.342 2000/08/25 12:28:03 jp
+ Graphic Crop-Attribut exported to SVX
+
+ Revision 1.341 2000/08/18 13:02:02 jp
+ don't export escaped URLs
+
+ Revision 1.340 2000/08/04 10:48:05 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character; use rtfout functions
+
+ Revision 1.339 2000/07/31 19:24:34 jp
+ new attributes for CJK/CTL and graphic
+
+ Revision 1.338 2000/07/20 13:16:22 jp
+ change old txtatr-character to the two new characters
+
+ Revision 1.337 2000/06/26 12:53:08 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.336 2000/05/09 17:22:42 jp
+ Changes for Unicode
+
+ Revision 1.335 2000/03/24 14:10:38 jp
+ Bug #74428#: LRSpace - GetLeft returns the right value for pagedescs
+
+ Revision 1.334 2000/03/15 13:50:27 jp
+ Bug #74070#: WriteTable - look for colspans
+
+ Revision 1.333 2000/03/03 15:21:02 os
+ StarView remainders removed
+
+ Revision 1.332 2000/02/24 18:33:21 jp
+ Bug #73098#: read & write list entries without number
+
+ Revision 1.331 2000/02/11 14:37:51 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.330 2000/01/25 20:11:50 jp
+ Bug #72146#: OutSwChar - write the original character code if it can not be converted
+
+ Revision 1.329 2000/01/07 12:26:49 jp
+ Task #71411#: read/write NoBalancedColumns
+
+ Revision 1.328 1999/12/08 13:51:01 jp
+ Task #70258#: textattr for XMLAttrContainer
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx
new file mode 100644
index 000000000000..c2e7c41c399b
--- /dev/null
+++ b/sw/source/filter/rtf/rtffld.cxx
@@ -0,0 +1,960 @@
+/*************************************************************************
+ *
+ * $RCSfile: rtffld.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#include <ctype.h>
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _GRAPH_HXX //autogen
+#include <vcl/graph.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _RTFTOKEN_H
+#include <svtools/rtftoken.h>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx>
+#endif
+#ifndef _SWPARRTF_HXX
+#include <swparrtf.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _DBFLD_HXX
+#include <dbfld.hxx>
+#endif
+#ifndef _USRFLD_HXX
+#include <usrfld.hxx>
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx>
+#endif
+
+
+// bestimme, ob es sich um ein IMPORT/TOC - Feld handelt.
+// return: 0 - weder noch,
+// 1 - TOC
+// 2 - IMPORT
+// 3 - INDEX
+enum RTF_FLD_TYPES {
+ RTFFLD_UNKNOWN = 0,
+ RTFFLD_TOC,
+ RTFFLD_IMPORT,
+ RTFFLD_INDEX,
+ RTFFLD_SYMBOL,
+ RTFFLD_PAGE,
+ RTFFLD_DATE,
+ RTFFLD_DATA,
+ RTFFLD_MERGEFLD,
+ RTFFLD_HYPERLINK
+};
+
+static RTF_FLD_TYPES _WhichFld( String& rName, String& rNext )
+{
+ // Strings sind PascalStrings; Laenge steht an 1. Stellen, dadurch wird
+ // sich der Aufruf von strlen erspart!!!
+ sal_Char __READONLY_DATA sTOC[]= "\3toc";
+ sal_Char __READONLY_DATA sIMPORT[]= "\6import";
+ sal_Char __READONLY_DATA sINDEX[]= "\5index";
+ sal_Char __READONLY_DATA sSYMBOL[]= "\6symbol";
+ sal_Char __READONLY_DATA sPAGE[]= "\4page";
+ sal_Char __READONLY_DATA sDATE[]= "\4date";
+ sal_Char __READONLY_DATA sDATA[]= "\4data";
+ sal_Char __READONLY_DATA sMERGEFLD[]= "\10mergefield";
+ sal_Char __READONLY_DATA sIMPORT2[]= "\16includepicture";
+ sal_Char __READONLY_DATA sHYPERLINK[]= "\x9hyperlink";
+
+ struct _Dummy_RTF_FLD_TYPES
+ {
+ RTF_FLD_TYPES eFldType;
+ const sal_Char* pFldNm;
+ };
+ __READONLY_DATA _Dummy_RTF_FLD_TYPES aFldNmArr[ RTFFLD_HYPERLINK+1 ] = {
+ RTFFLD_TOC, sTOC,
+ RTFFLD_IMPORT, sIMPORT,
+ RTFFLD_INDEX, sINDEX,
+ RTFFLD_SYMBOL, sSYMBOL,
+ RTFFLD_PAGE, sPAGE,
+ RTFFLD_DATE, sDATE,
+ RTFFLD_DATA, sDATA,
+ RTFFLD_MERGEFLD, sMERGEFLD,
+ RTFFLD_IMPORT, sIMPORT2,
+ RTFFLD_HYPERLINK, sHYPERLINK
+ };
+
+
+ if( !rName.Len() )
+ return RTFFLD_UNKNOWN;
+
+ String sNm( rName );
+ sNm = sNm.EraseLeadingChars().GetToken(0, ' ');
+ ASSERT( sNm.Len(), "Feldname hat keine Laenge!" );
+ if( !sNm.Len() )
+ return RTFFLD_UNKNOWN;
+
+ xub_StrLen nTokenStt = rName.Search( sNm );
+ sNm.ToLowerAscii();
+
+ for( int n = 0; n < sizeof( aFldNmArr ) / sizeof( aFldNmArr[0]); ++n )
+ {
+ const sal_Char* pCmp = aFldNmArr[n].pFldNm;
+ int nLen = *pCmp++;
+ xub_StrLen nFndPos = sNm.SearchAscii( pCmp );
+ if( STRING_NOTFOUND != nFndPos &&
+ ( !nFndPos || !isalpha(sNm.GetChar( nFndPos-1 )) ) &&
+ ( nFndPos+nLen == sNm.Len() || !isalpha(sNm.GetChar(nFndPos+nLen) ) ) )
+ {
+// rName = sNm.Copy( nFndPos, nLen );
+ rName = rName.Copy( nFndPos, nLen );
+ nFndPos += nTokenStt + nLen;
+ while( rNext.GetChar( nFndPos ) == ' ' ) ++nFndPos;
+ rNext.Erase( 0, nFndPos );
+ rNext.EraseTrailingChars();
+ return aFldNmArr[n].eFldType;
+ }
+ }
+ return RTFFLD_UNKNOWN; // nichts gefunden.
+}
+
+static USHORT CheckNumberFmtStr( const String& rNStr )
+{
+ // zur Kontrolle, falls jemand meint, neue Werte zufuegen zu muessen
+#define NUMBERTAB_SZ 8
+ sal_Char __READONLY_DATA
+ sNType0[] = "\10ALPHABETIC", /* CHARS_UPPER_LETTER*/
+ sNType1[] = "\10alphabetic", /* CHARS_LOWER_LETTER*/
+ sNType2[] = "\5ROMAN", /* ROMAN_UPPER */
+ sNType3[] = "\5roman", /* ROMAN_LOWER */
+ sNType4[] = "\6ARABIC", /* ARABIC */
+ sNType5[] = "\4NONE", /* NUMBER_NONE */
+ sNType6[] = "\4CHAR", /* CHAR_SPECIAL */
+ sNType7[] = "\4PAGE"; /* PAGEDESC */
+ static const sal_Char* __READONLY_DATA aNumberTypeTab[ NUMBERTAB_SZ ] =
+ {
+ sNType0, sNType1, sNType2, sNType3, sNType4,
+ sNType5, sNType6, sNType7
+ };
+
+
+ for( USHORT n = SVX_NUM_CHARS_UPPER_LETTER; n <= SVX_NUM_PAGEDESC; n++ )
+ {
+ const sal_Char* pCmp = aNumberTypeTab[ n ];
+ int nLen = *pCmp++;
+ if( rNStr.EqualsAscii( pCmp, 0, nLen ))
+ return 2 <= n ? n : (n + SVX_NUM_CHARS_UPPER_LETTER_N);
+ }
+ return SVX_NUM_PAGEDESC; // default-Wert
+}
+
+extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich,
+ USHORT& rSubType, ULONG &rFmt,
+ USHORT nVersion );
+
+class RtfFieldSwitch
+{
+ String sParam;
+ xub_StrLen nCurPos;
+public:
+ RtfFieldSwitch( const String& rParam );
+ sal_Unicode GetSwitch( String& rParam );
+
+ BOOL IsAtEnd() const { return nCurPos >= sParam.Len(); }
+};
+
+RtfFieldSwitch::RtfFieldSwitch( const String& rParam )
+ : sParam( rParam ), nCurPos( 0 )
+{
+ sParam.EraseTrailingChars().EraseLeadingChars();
+}
+
+sal_Unicode RtfFieldSwitch::GetSwitch( String& rParam )
+{
+ // beginnt ein Schalter?
+ sal_Unicode c, cKey = 0;
+ if( '\\' == (c = sParam.GetChar( nCurPos )) )
+ {
+ if( '\\' == ( c = sParam.GetChar( ++nCurPos )) )
+ c = sParam.GetChar( ++nCurPos );
+
+ cKey = c;
+
+ while( ++nCurPos < sParam.Len() &&
+ ' ' == ( c = sParam.GetChar( nCurPos )) )
+ ;
+ }
+
+ // dann alles in Hochkommatas oder bis zum naechsten // als
+ // Param returnen
+ USHORT nOffset;
+ if( '"' != c && '\'' != c )
+ c = '\\', nOffset = 0;
+ else
+ nOffset = 1;
+
+ sParam.Erase( 0, nCurPos + nOffset );
+ rParam = sParam.GetToken( 0, c );
+ sParam.Erase( 0, rParam.Len() + nOffset ).EraseLeadingChars();
+ if( '\\' == c )
+ rParam.EraseTrailingChars();
+ nCurPos = 0;
+
+ return cKey;
+}
+
+int SwRTFParser::MakeFieldInst( String& rFieldStr )
+{
+ // sicher den Original-String fuer die FeldNamen (User/Datenbank)
+ String aSaveStr( rFieldStr );
+ SwFieldType * pFldType;
+ xub_StrLen nPos = 0;
+ USHORT nSubType;
+ int nRet;
+
+ switch( nRet = _WhichFld( rFieldStr, aSaveStr ) )
+ {
+ case RTFFLD_IMPORT:
+ {
+//JP 11.03.96: vertraegt sich nicht so ganz mit Internet!
+// if( STRING_NOTFOUND != ( nPos = aSaveStr.Search( '.' )))
+// aSaveStr.Erase( nPos+4 );
+
+ if( aSaveStr.Len() )
+ {
+ sal_Unicode c = aSaveStr.GetChar( 0 );
+ if( '"' == c || '\'' == c )
+ {
+ aSaveStr.Erase( 0, 1 );
+ aSaveStr = aSaveStr.GetToken( 0, c );
+ }
+
+ rFieldStr = INetURLObject::RelToAbs( aSaveStr );
+ }
+// SkipGroup(); // ueberlese den Rest
+ }
+ break;
+
+ case RTFFLD_PAGE:
+ {
+ pFldType = pDoc->GetSysFldType( RES_PAGENUMBERFLD );
+ SwPageNumberField aPF( (SwPageNumberFieldType*)pFldType,
+ PG_RANDOM, SVX_NUM_ARABIC );
+ if( STRING_NOTFOUND != ( nPos = aSaveStr.SearchAscii( "\\*" )) )
+ {
+ nPos += 2;
+ while( aSaveStr.GetChar(nPos) == ' ' ) nPos++;
+ aSaveStr.Erase( 0, nPos );
+
+ // steht jetzt geanu auf dem Format-Namen
+ aPF.ChangeFormat( CheckNumberFmtStr( aSaveStr ));
+ }
+ pDoc->Insert( *pPam, SwFmtFld( aPF ) );
+ SkipGroup(); // ueberlese den Rest
+ }
+ break;
+ case RTFFLD_DATE:
+ {
+ if( STRING_NOTFOUND == ( nPos = aSaveStr.SearchAscii( "\\@" )) )
+ {
+ // es fehlt die Format - Angabe: defaulten auf Datum
+ pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD );
+ pDoc->Insert( *pPam, SwFmtFld( SwDateTimeField(
+ (SwDateTimeFieldType*)pFldType, DATEFLD )));
+ }
+ else
+ {
+ // versuche aus dem Formatstring zu erkennen, ob es ein
+ // Datum oder Zeit oder Datum & Zeit Field ist
+ // nur das Format interressiert
+ aSaveStr.Erase( 0, aSaveStr.Search( '\"' )+1 );
+ // alles hinter dem Format interressiert auch nicht mehr.
+ aSaveStr.Erase( aSaveStr.Search( '\"' ) );
+ aSaveStr.SearchAndReplaceAscii( "AM", aEmptyStr );
+ aSaveStr.SearchAndReplaceAscii( "PM", aEmptyStr );
+
+ xub_StrLen nDPos = aSaveStr.Search( 'M' ), // M -> Datum
+ nTPos = aSaveStr.Search( 'H' ); // H -> 24h
+ if( STRING_NOTFOUND == nTPos )
+ nTPos = aSaveStr.Search( 'h' ); // h -> 12h
+
+ SwField *pTFld = 0, *pDFld = 0;
+
+ if( STRING_NOTFOUND != nTPos )
+ {
+ pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD );
+ pTFld = new SwDateTimeField( (SwDateTimeFieldType*)pFldType, TIMEFLD );
+ ((SwDateTimeField*)pTFld)->ChangeFormat(
+ 'H' == aSaveStr.GetChar( nTPos )
+ ? TF_SSMM_24
+ : TF_SSMM_12);
+ }
+
+ if( STRING_NOTFOUND != nDPos ) // Datum ?
+ {
+ static SwDateFormat aDateA[16] = {
+ DF_SHORT, DF_LMON, DF_LDAYMON, DF_LDAYMON,
+ DF_SCENT, DF_LDAYMON, DF_LDAYMON, DF_LDAYMON,
+ DF_SHORT, DF_LMON, DF_LDAYMONTH, DF_LDAYMONTH,
+ DF_SCENT, DF_LDAYMONTH, DF_LDAYMONTH, DF_LDAYMONTH
+ };
+ // t, tt, T, TT -> no day of week
+ // ttt, tttt, TTT, TTTT -> day of week
+ BOOL bDayOfWeek = STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "ttt" ) ||
+ STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "TTT" ) ||
+ STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "ddd" ) ||
+ STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "DDD" );
+ // M, MM -> numeric month
+ // MMM, MMMM -> text. month
+ BOOL bLitMonth = STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "MMM" );
+ // MMMM -> full month
+ BOOL bFullMonth = STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "MMMM" );
+ // jj, JJ -> 2-col-year
+ // jjjj, JJJJ -> 4-col-year
+ BOOL bFullYear = STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "jjj" ) ||
+ STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "JJJ" ) ||
+ STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "yyy" ) ||
+ STRING_NOTFOUND !=
+ aSaveStr.SearchAscii( "YYY" );
+
+ USHORT i = ( bLitMonth & 1 ) |
+ ( ( bDayOfWeek & 1 ) << 1 ) |
+ ( ( bFullYear & 1 ) << 2 ) |
+ ( ( bFullMonth & 1 ) << 3 );
+
+ pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD );
+
+ nSubType = DATEFLD;
+ USHORT nWhich = RES_DATEFLD;
+ ULONG nFormat = aDateA[ i ];
+ sw3io_ConvertFromOldField( *pDoc, nWhich, nSubType, nFormat, 0x0110 );
+ pDFld = new SwDateTimeField( (SwDateTimeFieldType*)pFldType, DATEFLD, nFormat );
+ }
+
+ // Zeit kommt vor Date, alos Feld-Pointer swappen
+ if( nTPos < nDPos )
+ {
+ SwField* pTmp = pTFld;
+ pTFld = pDFld;
+ pDFld = pTmp;
+ }
+
+ if( pDFld )
+ {
+ pDoc->Insert( *pPam, SwFmtFld( *pDFld ));
+ delete pDFld;
+ }
+ if( pTFld )
+ {
+ pDoc->Insert( *pPam, SwFmtFld( *pTFld ));
+ delete pTFld;
+ }
+ }
+ SkipGroup(); // ueberlese den Rest
+ }
+ break;
+ case RTFFLD_DATA:
+ {
+ // Datenbank-FileName: nur der Filename interressiert
+ // Zur Zeit werden nur SDF-Files verarbeitet, also suche nach
+ // der Extension
+
+ // im SWG geben die DATA Felder den Namen der Datenbank
+ // an. Dieser kann als Field oder als DBInfo interpretiert
+ // werden:
+ // \\data -> Datenbank-Name als Field
+ // DATA -> Datenbank-Info
+ BOOL bField = rFieldStr.GetChar( 0 ) != 'D';
+
+ // nur der Name interressiert
+ if( STRING_NOTFOUND != (nPos = aSaveStr.Search( '.' )) )
+ aSaveStr.Erase( nPos );
+
+ if( bField )
+ {
+ pFldType = pDoc->GetSysFldType( RES_DBNAMEFLD );
+ pDoc->Insert( *pPam, SwFmtFld( SwDBNameField(
+ (SwDBNameFieldType*)pFldType, aEmptyStr ) ));
+ }
+ else
+ pDoc->ChgDBName( aSaveStr ); // MS: Keine DBInfo verwenden
+ SkipGroup(); // ueberlese den Rest
+ }
+ break;
+ case RTFFLD_MERGEFLD:
+ {
+ // ein Datenbank - Feld: nur der Name interressiert
+ // bis zum Ende vom String ist das der Feldname
+ SwDBFieldType aTmp( pDoc, aSaveStr, aEmptyStr ); // Hack(OM): Erstmal Leerstring
+ SwDBField aDBFld( (SwDBFieldType*)pDoc->InsertFldType( aTmp ));
+
+ aDBFld.ChangeFormat( UF_STRING );
+ pDoc->Insert( *pPam, SwFmtFld( aDBFld ));
+ SkipGroup(); // ueberlese den Rest
+ }
+ break;
+
+ case RTFFLD_SYMBOL:
+ {
+ // loesche fuehrende Blanks
+ if( IsNewGroup() ) GetAttrSet();
+ SetNewGroup( TRUE );
+
+ SfxItemSet& rSet = GetAttrSet();
+
+ BOOL bCharIns = FALSE;
+ RtfFieldSwitch aRFS( aSaveStr );
+ while( !aRFS.IsAtEnd() )
+ {
+ String sParam;
+ sal_Unicode cKey = aRFS.GetSwitch( sParam );
+ if( sParam.Len() )
+ switch( cKey )
+ {
+ case 0:
+ if( !bCharIns )
+ {
+ sal_Unicode nChar = sParam.ToInt32();
+ if( nChar )
+ {
+ pDoc->Insert( *pPam, nChar );
+ bCharIns = TRUE;
+ }
+ }
+ break;
+
+ case 'f': case 'F':
+ // Font setzen
+ {
+ SvxRTFFontTbl& rTbl = GetFontTbl();
+ for( Font* pFont = rTbl.First(); pFont;
+ pFont = rTbl.Next() )
+ if( pFont->GetName() == sParam )
+ {
+ rSet.Put( SvxFontItem(
+ pFont->GetFamily(),
+ sParam,
+ pFont->GetStyleName(),
+ pFont->GetPitch(),
+ pFont->GetCharSet(),
+ RES_CHRATR_FONT ));
+ break;
+ }
+ }
+ break;
+ case 'h': case 'H':
+ //??
+ break;
+ case 's': case 'S':
+ // Fontsize setzen
+ {
+ USHORT nVal = sParam.ToInt32();
+ nVal *= 20;
+ rSet.Put( SvxFontHeightItem( (const USHORT)nVal,
+ 100, RES_CHRATR_FONTSIZE ));
+ }
+ break;
+ }
+ }
+
+ if( !IsNewGroup() ) AttrGroupEnd();
+ SetNewGroup( FALSE );
+
+ SkipGroup(); // ueberlese den Rest
+ }
+ break;
+
+ case RTFFLD_HYPERLINK:
+ rFieldStr.Erase();
+ if( aSaveStr.Len() )
+ {
+ // return String ist URL, # Mark, \1 Frame
+ String sMark, sFrame;
+ RtfFieldSwitch aRFS( aSaveStr );
+ while( !aRFS.IsAtEnd() )
+ {
+ String sParam;
+ sal_Unicode cKey = aRFS.GetSwitch( sParam );
+ if( sParam.Len() )
+ switch( cKey )
+ {
+ case 0:
+ if( !rFieldStr.Len() )
+ rFieldStr = INetURLObject::RelToAbs( sParam );
+ break;
+
+ case 'l': case 'L': sMark = sParam; break;
+ case 't': case 'T': sFrame = sParam; break;
+ }
+ }
+
+ if( sMark.Len() )
+ ( rFieldStr += INET_MARK_TOKEN ) += sMark;
+ if( sFrame.Len() )
+ ( rFieldStr += '\1' ) += sFrame;
+ }
+ break;
+
+ case RTFFLD_TOC:
+ case RTFFLD_INDEX:
+ break;
+
+ default:
+ {
+ // keines von den bekannten Feldern, also eine neues UserField
+ aSaveStr.EraseLeadingChars().EraseTrailingChars();
+ SwUserFieldType aTmp( pDoc, aSaveStr );
+ SwUserField aUFld( (SwUserFieldType*)pDoc->InsertFldType( aTmp ));
+ aUFld.ChangeFormat( UF_STRING );
+ pDoc->Insert( *pPam, SwFmtFld( aUFld ));
+ nRet = RTFFLD_UNKNOWN;
+ }
+ break;
+ }
+ return nRet;
+}
+
+void SwRTFParser::ReadField()
+{
+ int nRet = 0;
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ int bFldInst = FALSE, bFldRslt = FALSE;
+ String sFieldStr, sFieldNm;
+ BYTE cCh;
+
+ while( nOpenBrakets && IsParserWorking() )
+ switch( GetNextToken() )
+ {
+ case '}':
+ {
+ --nOpenBrakets;
+ if( 1 != nOpenBrakets || !bFldInst )
+ break;
+
+ if( !bFldRslt )
+ {
+ // FieldInst vollstaendig eingelesen, was ist es denn?
+ nRet = MakeFieldInst( sFieldStr );
+
+ // erstmal Index/Inhaltsverzeichniss ueberspringen
+ // und als normalen Text einfuegen. Spaeter mal auch dem
+ // SwPaM darum aufspannen.
+ if( RTFFLD_TOC == nRet || RTFFLD_INDEX == nRet )
+ return;
+
+ if( RTFFLD_IMPORT == nRet || RTFFLD_HYPERLINK == nRet )
+ sFieldNm = sFieldStr;
+
+ sFieldStr.Erase();
+ }
+ else if( RTFFLD_UNKNOWN == nRet ) // FieldResult wurde eingelesen
+ {
+ // der String ist der Wert vom Feld
+// sFieldStr.Insert( '"', 0 );
+// sFieldStr.Insert( '"' );
+
+ // besorge mal das Feld:
+ SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode();
+ SwTxtAttr* pFldAttr = pTxtNd->GetTxtAttr(
+ pPam->GetPoint()->nContent.GetIndex()-1 );
+
+ ((SwUserFieldType*)pFldAttr->GetFld().GetFld()->GetTyp())->
+ SetContent( sFieldStr );
+ }
+ else if( sFieldNm.Len() )
+ {
+ if( RTFFLD_IMPORT == nRet )
+ {
+ // Grafik einfuegen
+ InsPicture( sFieldNm );
+ nRet = INT_MAX;
+ }
+ else if( RTFFLD_HYPERLINK == nRet && sFieldStr.Len() )
+ {
+ // im FieldStr steht der anzuzeigenden Text, im
+ pDoc->Insert( *pPam, sFieldStr );
+
+ String sTarget( sFieldNm.GetToken( 1, '\1' ));
+ if( sTarget.Len() )
+ sFieldNm.Erase( sFieldNm.Len() - sTarget.Len() -1 );
+
+ // oder ueber den Stack setzen??
+ pPam->SetMark();
+ pPam->GetMark()->nContent -= sFieldStr.Len();
+ pDoc->Insert( *pPam,
+ SwFmtINetFmt( sFieldNm, sTarget ),
+ SETATTR_DONTEXPAND );
+ pPam->DeleteMark();
+ }
+ }
+ }
+ break;
+
+ case '{':
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ SkipToken( -1 );
+ // Unknown und alle bekannten nicht ausgewerteten Gruppen
+ // sofort ueberspringen
+ else if( RTF_UNKNOWNCONTROL != GetNextToken() )
+ SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ if( '}' != GetNextToken() )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++nOpenBrakets;
+ break;
+
+ case RTF_DATAFIELD:
+ case RTF_FIELD:
+ SkipGroup();
+ break;
+
+ case RTF_FLDINST:
+ bFldInst = TRUE;
+ break;
+
+ case RTF_FLDRSLT:
+ bFldRslt = TRUE;
+ break;
+
+ case RTF_U:
+ {
+ if( nTokenValue )
+ sFieldStr += (sal_Unicode)nTokenValue;
+ else
+ sFieldStr += aToken;
+ }
+ break;
+
+ case RTF_LINE: cCh = '\n'; goto INSINGLECHAR;
+ case RTF_TAB: cCh = '\t'; goto INSINGLECHAR;
+ case RTF_SUBENTRYINDEX: cCh = ':'; goto INSINGLECHAR;
+ case RTF_EMDASH: cCh = 151; goto INSINGLECHAR;
+ case RTF_ENDASH: cCh = 150; goto INSINGLECHAR;
+ case RTF_BULLET: cCh = 149; goto INSINGLECHAR;
+ case RTF_LQUOTE: cCh = 145; goto INSINGLECHAR;
+ case RTF_RQUOTE: cCh = 146; goto INSINGLECHAR;
+ case RTF_LDBLQUOTE: cCh = 147; goto INSINGLECHAR;
+ case RTF_RDBLQUOTE: cCh = 148; goto INSINGLECHAR;
+INSINGLECHAR:
+ sFieldStr += ByteString::ConvertToUnicode( cCh,
+ RTL_TEXTENCODING_MS_1252 );
+ break;
+
+ // kein Break, aToken wird als Text gesetzt
+ case RTF_TEXTTOKEN:
+ sFieldStr += aToken;
+ break;
+
+ case RTF_PICT: // Pic-Daten einlesen!
+ if( RTFFLD_IMPORT == nRet )
+ {
+ Graphic aGrf;
+ SvxRTFPictureType aPicType;
+ if( ReadBmpData( aGrf, aPicType ) )
+ {
+ InsPicture( sFieldNm, &aGrf, &aPicType );
+ nRet = INT_MAX;
+ }
+ SkipGroup();
+ }
+ break;
+
+ case RTF_BKMKSTART:
+ case RTF_BKMKEND:
+ case RTF_BKMK_KEY:
+ case RTF_XE:
+ case RTF_TC:
+ case RTF_NEXTFILE:
+ case RTF_TEMPLATE:
+ case RTF_SHPRSLT:
+ SkipGroup();
+ break;
+ }
+
+ if( RTFFLD_IMPORT == nRet && sFieldNm.Len() )
+ {
+ // Grafik einfuegen
+ InsPicture( sFieldNm );
+ }
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/rtf/rtffld.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.51 2000/09/18 16:04:50 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.50 2000/05/09 17:22:46 jp
+ Changes for Unicode
+
+ Revision 1.49 2000/03/23 19:01:03 jp
+ Bug #74426#: ReadField: skip over some groups
+
+ Revision 1.48 2000/03/10 15:56:55 jp
+ Bug #74100#: read W2000 rtf-format
+
+ Revision 1.47 2000/02/17 13:46:51 jp
+ Bug #73098#: Import / Export problems
+
+ Revision 1.46 2000/02/11 14:37:57 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.45 2000/01/25 20:12:58 jp
+ Bug #72146#: read UniCode character
+
+ Revision 1.44 1999/03/03 13:59:16 JP
+ Bug #62735#: Symbolfelder komplett lesen
+
+
+ Rev 1.43 03 Mar 1999 14:59:16 JP
+ Bug #62735#: Symbolfelder komplett lesen
+
+ Rev 1.42 16 Feb 1999 11:57:16 JP
+ Task #61942#: Hyperlinks einlesen
+
+ Rev 1.41 17 Nov 1998 10:45:58 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.40 11 Aug 1998 12:16:32 JP
+ Bug #54796#: fehlender Numerierunstyp und Bugfixes
+
+ Rev 1.39 06 Aug 1998 21:43:28 JP
+ Bug #54796#: neue NumerierungsTypen (WW97 kompatibel)
+
+ Rev 1.38 13 May 1998 18:07:18 JP
+ PageField: auf PageDesc Format defaulten
+
+ Rev 1.37 20 Feb 1998 13:36:30 MA
+ headerfiles gewandert
+
+ Rev 1.36 13 Feb 1998 19:22:02 MIB
+ Felder: Schnittstellen-Anpassung fuer Konvertierungs-Funktionen
+
+ Rev 1.35 27 Jan 1998 19:00:38 HR
+ HP9000 Krams entfernt
+
+ Rev 1.34 26 Nov 1997 15:05:34 MA
+ headerfiles
+
+ Rev 1.33 25 Nov 1997 12:03:02 TJ
+ include svrtf.hxx
+
+ Rev 1.32 03 Nov 1997 14:10:34 MA
+ precomp entfernt
+
+ Rev 1.31 15 Oct 1997 11:59:44 OM
+ Feldumstellung
+
+ Rev 1.30 14 Oct 1997 14:12:06 OM
+ Feldumstellung
+
+ Rev 1.29 09 Oct 1997 16:16:44 OM
+ Feldumstellung
+
+ Rev 1.28 29 Sep 1997 12:14:38 OM
+ Feldumstellung
+
+ Rev 1.27 24 Sep 1997 15:23:20 OM
+ Feldumstellung
+
+ Rev 1.26 15 Aug 1997 12:51:44 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.25 12 Nov 1996 18:28:12 sdo
+ GCC-Parser
+
+ Rev 1.24 29 Oct 1996 12:58:48 JP
+ am Doc ist das NodesArray nur noch ueber Get..() zugaenglich
+
+ Rev 1.23 23 Oct 1996 19:49:08 JP
+ String Umstellung: [] -> GetChar()
+
+ Rev 1.22 28 Jun 1996 15:07:26 MA
+ includes
+
+ Rev 1.21 19 Jun 1996 11:57:52 MA
+ headerfiles 323
+
+ Rev 1.20 10 Jun 1996 11:23:38 JP
+ ImportFeld: jetzt auch mit dem neuen WinWord 6.0 Format
+
+ Rev 1.19 30 Apr 1996 09:36:28 OM
+ Mehrere Datenbanken pro Dok
+
+ Rev 1.17 11 Apr 1996 17:31:38 JP
+ Umstellung - RelToAbs/AbsToRel
+
+ Rev 1.16 10 Apr 1996 18:59:00 JP
+ Umstellung relative/absolute Pfade fuer Grafiken
+
+ Rev 1.15 11 Mar 1996 23:08:24 JP
+ InsPicture: keine Extension abschneiden
+
+ Rev 1.14 11 Jan 1996 22:04:00 JP
+ Date/Time - Felder: die Formate richtig lesen/schreiben
+
+ Rev 1.13 13 Dec 1995 21:04:10 JP
+ Warnings entfernt
+
+ Rev 1.12 24 Nov 1995 17:24:10 OM
+ PCH->PRECOMPILED
+
+ Rev 1.11 07 Nov 1995 20:06:20 JP
+ Readonly-Daten hinter segeofglobals verschoben
+
+ Rev 1.10 21 Aug 1995 21:30:38 JP
+ svxitems-HeaderFile entfernt
+
+ Rev 1.9 18 Aug 1995 19:05:50 mk
+ HP9000 (MDA)
+
+ Rev 1.8 09 Aug 1995 18:15:02 JP
+ Daten vors SEG_EOFGLOBAL verschoben
+
+ Rev 1.7 03 Apr 1995 20:51:30 JP
+ fuer PreComp.Header eingerichtet
+
+ Rev 1.6 13 Mar 1995 14:56:20 KH
+ Mac jetzt richtig
+
+ Rev 1.5 08 Feb 1995 09:43:08 JP
+ alten RTF-Parser entfernt, Sw_RTF -> SwRTF
+
+ Rev 1.4 18 Jan 1995 21:05:12 ER
+ fld.hxx -> *fld*.hxx
+
+ Rev 1.3 11 Jan 1995 19:36:28 JP
+ RTF-Reader fertiggestellt
+
+ Rev 1.2 09 Jan 1995 19:35:30 JP
+ Symbolzeichen: kein Wert, nicht einfuegen
+
+ Rev 1.1 06 Jan 1995 12:07:08 JP
+ originalen Feldnamen returnen
+
+ Rev 1.0 22 Dec 1994 17:34:36 JP
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx
new file mode 100644
index 000000000000..ac7f12190150
--- /dev/null
+++ b/sw/source/filter/rtf/rtffly.cxx
@@ -0,0 +1,1745 @@
+/*************************************************************************
+ *
+ * $RCSfile: rtffly.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _LIST_HXX //autogen
+#include <tools/list.hxx>
+#endif
+#ifndef _CACHESTR_HXX //autogen
+#include <tools/cachestr.hxx>
+#endif
+#ifndef _RTFTOKEN_H
+#include <svtools/rtftoken.h>
+#endif
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SVX_PRNTITEM_HXX //autogen
+#include <svx/prntitem.hxx>
+#endif
+#ifndef _SVX_OPAQITEM_HXX //autogen
+#include <svx/opaqitem.hxx>
+#endif
+#ifndef _SVX_PROTITEM_HXX //autogen
+#include <svx/protitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen wg. SvxBoxItem
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _SWPARRTF_HXX
+#include <swparrtf.hxx>
+#endif
+#ifndef _GRFATR_HXX
+#include <grfatr.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _RTF_HXX
+#include <rtf.hxx>
+#endif
+#ifndef _NDGRF_HXX
+#include <ndgrf.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _TXTFLCNT_HXX
+#include <txtflcnt.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+
+
+#define ANCHOR(p) ((SwFmtAnchor*)p)
+
+// steht in shellio.hxx
+extern SwCntntNode* GoNextNds( SwNodeIndex * pIdx, FASTBOOL bChk );
+
+SV_IMPL_PTRARR( SwFlySaveArr, SwFlySave* )
+
+inline const SwFmtFrmSize GetFrmSize(const SfxItemSet& rSet, BOOL bInP=TRUE)
+ { return (const SwFmtFrmSize&)rSet.Get( RES_FRM_SIZE,bInP); }
+
+
+/* */
+
+
+SwFlySave::SwFlySave( const SwPaM& rPam, SfxItemSet& rSet )
+ : aFlySet( rSet ),
+ nSttNd( rPam.GetPoint()->nNode ), nEndNd( nSttNd ),
+ nEndCnt( 0 ), nPageWidth( ATT_MIN_SIZE ),
+ nDropLines( 0 ), nDropAnchor( 0 )
+{
+}
+
+int SwFlySave::IsEqualFly( const SwPaM& rPos, SfxItemSet& rSet )
+{
+ if( rSet.Count() != aFlySet.Count() || nDropAnchor )
+ return FALSE;
+
+ // nur TextNodes zusammenfassen
+ if( nSttNd == nEndNd && nEndNd.GetNode().IsNoTxtNode() )
+ return FALSE;
+
+ // teste auf gleiche / naechste Position
+ if( rPos.GetPoint()->nNode.GetIndex() == nEndNd.GetIndex() )
+ {
+ if( 1 < (rPos.GetPoint()->nContent.GetIndex() - nEndCnt) )
+ return FALSE;
+ }
+ else if( rPos.GetPoint()->nContent.GetIndex() )
+ return FALSE;
+ else
+ {
+ SwNodeIndex aIdx( nEndNd );
+ SwCntntNode* pCNd = rPos.GetDoc()->GetNodes()[ aIdx ]->GetCntntNode();
+ if( !GoNextNds( &aIdx, TRUE ) ||
+ aIdx.GetIndex() != rPos.GetPoint()->nNode.GetIndex() ||
+ ( pCNd && pCNd->Len() != nEndCnt ))
+ {
+ return FALSE;
+ }
+ }
+
+ if( rSet.Count() )
+ {
+ SfxItemIter aIter( rSet );
+ const SfxPoolItem *pItem, *pCurr = aIter.GetCurItem();
+ while( TRUE )
+ {
+ if( SFX_ITEM_SET != aFlySet.GetItemState( pCurr->Which(),
+ FALSE, &pItem ) ||
+ // Ankerattribute gesondert behandeln
+ ( RES_ANCHOR == pCurr->Which()
+ ? (ANCHOR(pCurr)->GetAnchorId() != ANCHOR(pItem)->GetAnchorId() ||
+ ANCHOR(pCurr)->GetPageNum() != ANCHOR(pItem)->GetPageNum())
+ : *pItem != *pCurr ))
+ return FALSE;
+
+ if( aIter.IsAtEnd() )
+ break;
+ pCurr = aIter.NextItem();
+ }
+ }
+ return TRUE;
+}
+
+void SwFlySave::SetFlySize( const SwTableNode& rTblNd )
+{
+ // sollte der Fly kleiner als diese Tabelle sein, dann
+ // korrigiere diesen (nur bei abs. Angaben!)
+ SwTwips nWidth = rTblNd.GetTable().GetFrmFmt()->GetFrmSize().GetWidth();
+ const SwFmtFrmSize& rSz = GetFrmSize( aFlySet );
+ if( nWidth > rSz.GetWidth() )
+ aFlySet.Put( SwFmtFrmSize( rSz.GetSizeType(), nWidth, rSz.GetHeight() ));
+}
+
+BOOL lcl_HasBreakAttrs( const SwCntntNode& rNd )
+{
+ BOOL bRet = FALSE;
+ const SfxItemSet& rSet = rNd.GetSwAttrSet();
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, TRUE, &pItem ) &&
+ SVX_BREAK_NONE != ((SvxFmtBreakItem*)pItem)->GetBreak() )
+ bRet = TRUE;
+ else if( SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, TRUE, &pItem )&&
+ 0 != ((SwFmtPageDesc*)pItem)->GetPageDesc() )
+ bRet = TRUE;
+ return bRet;
+}
+
+
+void lcl_CpyBreakAttrs( SwCntntNode* pSrcNd, SwCntntNode* pDstNd,
+ SwNodeIndex* pNewIdx )
+{
+ SwAttrSet* pSet;
+ if( pSrcNd && pDstNd && 0 != ( pSet = pSrcNd->GetpSwAttrSet() ) )
+ {
+ const SfxPoolItem *pDescItem, *pBreakItem;
+
+ if( SFX_ITEM_SET != pSet->GetItemState( RES_BREAK,
+ FALSE, &pBreakItem ) )
+ pBreakItem = 0;
+
+ if( SFX_ITEM_SET != pSet->GetItemState( RES_PAGEDESC,
+ FALSE, &pDescItem ) )
+ pDescItem = 0;
+
+ if( pDescItem || pBreakItem )
+ {
+ if( lcl_HasBreakAttrs( *pDstNd ))
+ {
+ SwPosition aPos( *pDstNd, SwIndex( pDstNd ));
+ aPos.nNode--;
+ pDstNd->GetDoc()->AppendTxtNode( aPos );
+ if( pNewIdx )
+ *pNewIdx = aPos.nNode;
+
+ SwCntntNode* pOldNd = pDstNd;
+ pDstNd = aPos.nNode.GetNode().GetCntntNode();
+ pDstNd->ChgFmtColl( pOldNd->GetFmtColl() );
+ if( pDstNd->GetpSwAttrSet() )
+ {
+ SfxItemSet aSet( *pDstNd->GetpSwAttrSet() );
+ aSet.ClearItem( RES_BREAK );
+ aSet.ClearItem( RES_PAGEDESC );
+ pDstNd->SetAttr( aSet );
+ }
+ }
+ if( pBreakItem )
+ {
+ pDstNd->SetAttr( *pBreakItem );
+ pSrcNd->ResetAttr( RES_BREAK );
+ }
+ if( pDescItem )
+ {
+ pDstNd->SetAttr( *pDescItem );
+ pSrcNd->ResetAttr( RES_PAGEDESC );
+ }
+ }
+ }
+}
+
+
+void SwRTFParser::SetFlysInDoc()
+{
+ // !! von Oben abarbeiten, CntntPos ist kein Index !
+ SwNodes & rNds = pDoc->GetNodes();
+ SvPtrarr aPrevFmts( 255 < aFlyArr.Count() ? aFlyArr.Count() : 255 );
+ SwFrmFmt* pParent = pDoc->GetFrmFmtFromPool( RES_POOLFRM_FRAME );
+ for( USHORT n = 0; n < aFlyArr.Count(); ++n )
+ {
+ SwFlySave* pFlySave = aFlyArr[ n ];
+
+ ASSERT( !pFlySave->nSttNd.GetNode().FindFlyStartNode(),
+ "Content vom Fly steht in einem Fly" );
+ ASSERT( pFlySave->nSttNd.GetIndex() <= pFlySave->nEndNd.GetIndex(),
+ "Fly hat falschen Bereich" );
+
+ //JP 21.09.98: wenn ein DropCap ist, dann Text im Node belassen, am
+ // Absatz das Absatz Attribut setzen. Ggfs noch die
+ // FontSize zuruecksetzen, damit das DropCap nicht zu
+ // groá wird.
+ if( pFlySave->nDropAnchor )
+ {
+ SwTxtNode* pSttNd = pFlySave->nSttNd.GetNode().GetTxtNode(),
+ * pEndNd = pFlySave->nEndNd.GetNode().GetTxtNode();
+ if( pSttNd && pEndNd &&
+ pSttNd->GetIndex() + 1 == pEndNd->GetIndex() )
+ {
+ BOOL bJoined;
+ {
+ SwPaM aTmp( *pEndNd, 0, *pSttNd, pSttNd->GetTxt().Len() );
+ bJoined = pDoc->DeleteAndJoin( aTmp );
+ }
+ if( bJoined )
+ {
+ SwFmtDrop aDropCap;
+ aDropCap.GetLines() = (BYTE)pFlySave->nDropLines;
+ aDropCap.GetChars() = 1;
+
+ SwIndex aIdx( pEndNd );
+ pEndNd->RstAttr( aIdx, 1, RES_CHRATR_FONTSIZE );
+ pEndNd->SwCntntNode::SetAttr( aDropCap );
+ }
+ }
+ delete pFlySave;
+ continue;
+ }
+
+ // liegt Ende und Start vom Naechsten im gleichen Node, dann muss
+ // gesplittet werden
+ if( n + 1 < aFlyArr.Count() && pFlySave->nEndCnt &&
+ pFlySave->nEndNd == aFlyArr[ n + 1 ]->nSttNd )
+ {
+ SwCntntNode* pCNd = rNds[ pFlySave->nEndNd ]->GetCntntNode();
+ if( pCNd )
+ {
+ SwPosition aPos( pFlySave->nEndNd,
+ SwIndex( pCNd, pFlySave->nEndCnt ));
+ pDoc->SplitNode( aPos );
+ pFlySave->nEndNd--;
+ }
+ else
+ pFlySave->nEndCnt = 0;
+ }
+
+ // verschiebe den Inhalt von diesem Anchor in den Auto-TextBereich
+ // und erzeuge dadurch den richtigen SwG-Rahmen
+ SwNodeRange aRg( pFlySave->nSttNd, 0, pFlySave->nEndNd,
+ (pFlySave->nEndCnt ? 1 : 0) );
+ BOOL bMakeEmptySection = aRg.aStart < aRg.aEnd;
+
+ {
+ // Nur TextNodes koennen in Tabellen stehen !!
+ const SwNode* pNd = &pFlySave->nSttNd.GetNode();
+ if( pNd->IsNoTxtNode() )
+ {
+ // die Size muss noch korrigiert werden!
+ nAktPageDesc = 0; // Standart PageDesc
+ if( SFX_ITEM_SET != pFlySave->aFlySet.GetItemState(
+ RES_FRM_SIZE, FALSE ) )
+ _SetPictureSize( *(SwNoTxtNode*)pNd, aRg.aStart,
+ pFlySave->aFlySet );
+ if( 0 != ( pNd = pNd->FindTableNode() ) )
+ pFlySave->SetFlySize( *(SwTableNode*)pNd );
+ }
+ else
+ {
+ // TabelleNodes beachten
+ BOOL bMoveFromCell = FALSE;
+ pNd = pNd->FindTableNode();
+ if( pNd ) // am Anfang eine Tabelle, -> Bereich auf TabStart
+ {
+ if( pFlySave->nSttNd.GetNode().FindStartNode() ==
+ pFlySave->nEndNd.GetNode().FindStartNode() )
+ {
+ // dann nur den Node verschieben
+ SwNodeIndex& rIdx = pFlySave->nSttNd;
+ if( rIdx.GetNode().EndOfSectionIndex() -
+ rIdx.GetNode().FindStartNode()->GetIndex() ==
+ aRg.aEnd.GetIndex() - aRg.aStart.GetIndex() + 1 )
+ {
+ // dann bliebe kein Node mehr stehen, also
+ // erzeuge eine leere Text Section!
+ bMakeEmptySection = FALSE;
+ }
+ bMoveFromCell = TRUE;
+ }
+ else
+ aRg.aStart = *pNd;
+ }
+
+ if( bMakeEmptySection )
+ {
+ pNd = &aRg.aEnd.GetNode();
+ ULONG nSectEnd = pNd->EndOfSectionIndex();
+ if( !pFlySave->nEndCnt )
+ ++nSectEnd;
+
+ if( !bMoveFromCell && !pNd->IsTableNode() &&
+ 0 != (pNd = pNd->FindTableNode() ) )
+ {
+ const SwNode* pTblBxNd;
+ // Ende der Tabelle ist hinter dieser Box ??
+ if( pNd->EndOfSectionIndex() == nSectEnd )
+ aRg.aEnd = nSectEnd+1;
+ // is the end in the first box of the table, then
+ // move before the table (Bug 67663)
+ else if( 0 != ( pTblBxNd = aRg.aEnd.GetNode().
+ FindTableBoxStartNode()) &&
+ pTblBxNd->GetIndex() - 1 == pNd->GetIndex())
+ aRg.aEnd = *pNd;
+ else
+ {
+ // Tabelle ist noch groesser, also splitte sie hier.
+ rNds.SplitTable( aRg.aEnd, TRUE );
+ aRg.aEnd = pNd->EndOfSectionIndex() + 1;
+ }
+ }
+ }
+ }
+ }
+
+ // vorm verschieben muss sich der Index auf die alte Position
+ // gemerkt werden, der Index wird mit verschoben !!!
+
+ SwNodeIndex aTmpIdx( rNds.GetEndOfAutotext() );
+ SwStartNode* pSttNd = bMakeEmptySection
+ ? rNds.MakeEmptySection( aTmpIdx, SwFlyStartNode )
+ : rNds.MakeTextSection( aTmpIdx, SwFlyStartNode,
+ (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
+
+ // das ist die Verankerungs-Position (fuers Layout!)
+ pFlySave->nSttNd = aRg.aStart.GetIndex()-1;
+ if( bMakeEmptySection )
+ {
+ // check: the move does not clear the surrounded section. If all
+ // nodes moved away, then create a new TxtNode
+ {
+ SwNodeIndex aPrev( aRg.aStart, -1 );
+ if( aPrev.GetNode().IsStartNode() &&
+ aPrev.GetNode().EndOfSectionNode() == &aRg.aEnd.GetNode())
+ {
+ // create new txtnode, because the section does never be empty
+ pDoc->GetNodes().MakeTxtNode( aRg.aEnd,
+ (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
+ aRg.aEnd--;
+ }
+ }
+ aTmpIdx = *pSttNd->EndOfSectionNode();
+ pDoc->Move( aRg, aTmpIdx );
+ }
+
+ pFlySave->aFlySet.Put( SwFmtCntnt( pSttNd ));
+
+ CalculateFlySize( pFlySave->aFlySet, pFlySave->nSttNd,
+ pFlySave->nPageWidth );
+
+ // if the section only contains one Node and this has a
+ // border or backgorund, then put it to the frame
+ // Not in our own RTF-Format!
+ if( pSttNd->GetIndex() + 2 == pSttNd->EndOfSectionIndex() &&
+ !bSwPageDesc )
+ {
+ SwTxtNode* pSrcNd = pDoc->GetNodes()[ pSttNd->GetIndex() + 1 ]
+ ->GetTxtNode();
+ if( pSrcNd && pSrcNd->GetpSwAttrSet() )
+ {
+ SfxItemSet aTmpSet( pDoc->GetAttrPool(),
+ RES_BACKGROUND, RES_BOX );
+ aTmpSet.Put( *pSrcNd->GetpSwAttrSet() );
+ if( aTmpSet.Count() )
+ {
+ pFlySave->aFlySet.Put( aTmpSet );
+ pSrcNd->ResetAttr( RES_BACKGROUND, RES_BOX );
+ }
+ }
+ }
+
+ SwFlyFrmFmt* pFmt = pDoc->MakeFlyFrmFmt( aEmptyStr, pParent );
+ pFmt->SetAttr( pFlySave->aFlySet );
+
+ const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
+ if( FLY_IN_CNTNT != rAnchor.GetAnchorId() )
+ {
+ // korrigiere noch den Absatz, ist immer der vorhergehende !
+ // JP 20.09.95: wenn es diesen gibt! (DocAnfang!)
+
+ //JP 02.08.99: that is wrong. The anchor is ever the NEXT!
+ //JP 05.08.99: there are an Bug in the ExportFilter which will
+ // be fixed in the Version 517 - by SWG-Export
+ // the fly will be after the paragraph - but in RTF
+ // the flys will be before the paragraph.
+ if( !bSwPageDesc || 5430 < GetVersionNo() )
+ pFlySave->nSttNd++;
+
+// if( !pFlySave->nSttNd.GetNode().IsCntntNode() )
+ {
+ // Seitenumbrueche in den Bodybereich verschieben!
+ SwCntntNode* pSrcNd = aRg.aStart.GetNode().GetCntntNode();
+ SwCntntNode* pDstNd = pFlySave->nSttNd.GetNode().GetCntntNode();
+ if( !pDstNd )
+ pDstNd = pDoc->GetNodes().GoNext( &pFlySave->nSttNd );
+
+ ::lcl_CpyBreakAttrs( pSrcNd, pDstNd, &pFlySave->nSttNd );
+ }
+
+
+ SwPosition aPos( pFlySave->nSttNd );
+ SwFmtAnchor aAnchor( rAnchor );
+ aAnchor.SetAnchor( &aPos );
+ pFmt->SetAttr( aAnchor );
+
+ // check if the new Frame contains any anchors to previous
+ // flys. This is in RTF not allowed, so move all anchors to
+ // the prev position
+ {
+ ULONG nSttNd = pSttNd->GetIndex(),
+ nEndNd = pSttNd->EndOfSectionIndex();
+ for( USHORT nPrevFmts = aPrevFmts.Count(); nPrevFmts; )
+ {
+ SwFmt* pTmpFmt = (SwFmt*)aPrevFmts[ --nPrevFmts ];
+ const SwFmtAnchor& rAn = pTmpFmt->GetAnchor();
+ ULONG nNd = rAn.GetCntntAnchor()->nNode.GetIndex();
+ if( nSttNd < nNd && nNd < nEndNd )
+ {
+ SwFmtAnchor aAnchor( rAn );
+ aAnchor.SetAnchor( &aPos );
+ pTmpFmt->SetAttr( aAnchor );
+ }
+ else
+ // then forget it
+ aPrevFmts.Remove( nPrevFmts, 1 );
+ }
+
+ void* p = (void*)pFmt;
+ aPrevFmts.Insert( p, aPrevFmts.Count() );
+ }
+ }
+ delete pFlySave;
+ }
+ aFlyArr.Remove( 0, aFlyArr.Count() );
+}
+
+void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet )
+{
+ // ein Set fuer die FrmFmt-Attribute
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( aSet );
+
+ // der Fly beginnt immer in einem neuen Absatz
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ InsertPara();
+
+ // RTF-Defaults setzen:
+ SwFmtAnchor aAnchor( FLY_PAGE, 1 );
+ SwFmtHoriOrient aHori( 0, HORI_LEFT, /*FRAME*/REL_PG_PRTAREA );
+ SwFmtVertOrient aVert( 0, VERT_TOP, REL_PG_PRTAREA );
+
+ USHORT nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0;
+ SvUShorts aColumns;
+
+ BOOL bChkDropCap = 0 == pSet;
+ USHORT nDropCapLines = 0, nDropCapAnchor = 0;
+ int nOpenBrakets = GetOpenBrakets();
+
+ if( !pSet )
+ pSet = &aSet;
+ else
+ {
+ // die Werte aus dem uebergebenen!
+ aAnchor = (SwFmtAnchor&)pSet->Get( RES_ANCHOR );
+ aHori = (SwFmtHoriOrient&)pSet->Get( RES_HORI_ORIENT );
+ aVert = (SwFmtVertOrient&)pSet->Get( RES_VERT_ORIENT );
+ }
+
+ // dann sammel mal alle Attribute zusammen
+ int bWeiter = TRUE;
+ do {
+ USHORT nVal = USHORT(nTokenValue);
+ switch( nToken )
+ {
+ case RTF_ABSW:
+ {
+ SwFmtFrmSize aSz( ATT_MIN_SIZE, nTokenValue, 0 );
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_FRM_SIZE, TRUE,
+ &pItem ))
+ {
+ aSz.SetSizeType( ((SwFmtFrmSize*)pItem)->GetSizeType() );
+ aSz.SetHeight( ((SwFmtFrmSize*)pItem)->GetHeight() );
+ }
+ if( MINFLY > nTokenValue ) nTokenValue = MINFLY;
+ aSet.Put( aSz );
+ }
+ break;
+ case RTF_ABSH:
+ {
+ SwFmtFrmSize aSz( ATT_MIN_SIZE, 0, MINFLY );
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_FRM_SIZE, TRUE,
+ &pItem ))
+ {
+ aSz.SetWidth( ((SwFmtFrmSize*)pItem)->GetWidth() );
+ }
+
+ if( 0 > nTokenValue )
+ {
+ nTokenValue = -nTokenValue;
+ aSz.SetSizeType( ATT_FIX_SIZE );
+ }
+ if( MINFLY > nTokenValue ) nTokenValue = MINFLY;
+ aSz.SetHeight( nTokenValue );
+ aSet.Put( aSz );
+ }
+ break;
+
+ case RTF_NOWRAP:
+ {
+ pSet->Put( SwFmtSurround( SURROUND_NONE ));
+ }
+ break;
+ case RTF_DXFRTEXT:
+ {
+ SvxULSpaceItem aUL;
+ SvxLRSpaceItem aLR;
+ aUL.SetUpper( nVal ); aUL.SetLower( nVal );
+ aLR.SetLeft( nVal ); aLR.SetRight( nVal );
+ pSet->Put( aUL );
+ pSet->Put( aLR );
+ }
+ break;
+
+ case RTF_DFRMTXTX:
+ {
+ SvxLRSpaceItem aLR;
+ aLR.SetLeft( nVal ); aLR.SetRight( nVal );
+ pSet->Put( aLR );
+ }
+ break;
+ case RTF_DFRMTXTY:
+ {
+ SvxULSpaceItem aUL;
+ aUL.SetUpper( nVal ); aUL.SetLower( nVal );
+ pSet->Put( aUL );
+ }
+ break;
+
+ case RTF_POSNEGX:
+ case RTF_POSX: aHori.SetHoriOrient( HORI_NONE );
+ aHori.SetPos( (long)nTokenValue );
+ break;
+ case RTF_POSXC: aHori.SetHoriOrient( HORI_CENTER ); break;
+ case RTF_POSXI: aHori.SetHoriOrient( HORI_LEFT );
+ aHori.SetPosToggle( TRUE );
+ break;
+ case RTF_POSXO: aHori.SetHoriOrient( HORI_RIGHT );
+ aHori.SetPosToggle( TRUE );
+ break;
+ case RTF_POSXL: aHori.SetHoriOrient( HORI_LEFT ); break;
+ case RTF_POSXR: aHori.SetHoriOrient( HORI_RIGHT ); break;
+
+ case RTF_POSNEGY:
+ case RTF_POSY: aVert.SetVertOrient( VERT_NONE );
+ aVert.SetPos( (long)nTokenValue );
+ break;
+ case RTF_POSYT: aVert.SetVertOrient( VERT_TOP ); break;
+ case RTF_POSYB: aVert.SetVertOrient( VERT_BOTTOM ); break;
+ case RTF_POSYC: aVert.SetVertOrient( VERT_CENTER ); break;
+
+ case RTF_PHMRG: aHori.SetRelationOrient( REL_PG_PRTAREA ); break;
+ case RTF_PVMRG: aVert.SetRelationOrient( REL_PG_PRTAREA ); break;
+ case RTF_PHPG: aHori.SetRelationOrient( REL_PG_FRAME ); break;
+ case RTF_PVPG: aVert.SetRelationOrient( REL_PG_FRAME );break;
+ case RTF_PHCOL: aHori.SetRelationOrient( FRAME ); break;
+ case RTF_PVPARA: aVert.SetRelationOrient( FRAME ); break;
+
+ case RTF_POSYIL:
+ case RTF_ABSLOCK:
+ break;
+
+ case RTF_DROPCAPLI: // Dropcaps !!
+ if( bChkDropCap )
+ {
+ nDropCapLines = USHORT( nTokenValue );
+ if( !nDropCapAnchor )
+ nDropCapAnchor = 1;
+ }
+ break;
+ case RTF_DROPCAPLT:
+ if( bChkDropCap )
+ {
+ nDropCapAnchor = USHORT( nTokenValue );
+ if( !nDropCapLines )
+ nDropCapLines = 3;
+ }
+ break;
+
+
+ // fuer die "alten" Writer - haben die Spaltigkeit falsch heraus-
+ // geschrieben
+ case RTF_COLS: nCols = USHORT( nTokenValue ); break;
+ case RTF_COLSX: nColSpace = USHORT( nTokenValue ); break;
+ case RTF_COLNO:
+ nAktCol = USHORT( nTokenValue );
+ if( RTF_COLW == GetNextToken() )
+ {
+ USHORT nWidth = USHORT( nTokenValue ), nSpace = 0;
+ if( RTF_COLSR == GetNextToken() )
+ nSpace = USHORT( nTokenValue );
+ else
+ SkipToken( -1 ); // wieder zurueck
+
+ if( --nAktCol == ( aColumns.Count() / 2 ) )
+ {
+ aColumns.Insert( nWidth + nSpace, aColumns.Count() );
+ aColumns.Insert( nSpace, aColumns.Count() );
+ }
+ }
+ break;
+
+ case '{':
+ {
+ short nSkip = 0;
+ if( RTF_IGNOREFLAG != ( nToken = GetNextToken() ))
+ {
+ if( RTF_SHADINGDEF == (nToken & ~0xff) )
+ {
+ ReadBackgroundAttr( nToken, aSet );
+ GetNextToken(); // Klammer ueberlesen
+ }
+ else
+ nSkip = -1;
+ }
+ else if( RTF_APOCTL ==
+ ((nToken = GetNextToken() ) & ~(0xff | RTF_SWGDEFS)) )
+ {
+ bReadSwFly = TRUE; // alles kommt in den akt. Fly
+ SvxLRSpaceItem aLR;
+ SvxULSpaceItem aUL;
+ nCols = USHRT_MAX; // neu aufsetzen
+ nColSpace = USHRT_MAX;
+ do {
+ nVal = USHORT(nTokenValue);
+ switch( nToken )
+ {
+ // Swg-Frame-Tokens
+ case RTF_FLYPRINT:
+ {
+ pSet->Put( SvxPrintItem( RES_PRINT, FALSE ));
+ }
+ break;
+ case RTF_FLYOPAQUE:
+ {
+ pSet->Put( SvxOpaqueItem( RES_OPAQUE, FALSE ));
+ }
+ break;
+
+ case RTF_FLYPRTCTD:
+ {
+ RTFProtect aP( (BYTE)nTokenValue );
+ SvxProtectItem aProtectItem;
+ aProtectItem.SetCntntProtect( aP.GetCntnt() );
+ aProtectItem.SetSizeProtect( aP.GetSize() );
+ aProtectItem.SetPosProtect( aP.GetPos() );
+ pSet->Put( aProtectItem );
+ }
+ break;
+
+ case RTF_FLYMAINCNT:
+ {
+ RTFSurround aMC( (BYTE)nTokenValue );
+ SwFmtSurround aSurr( (SwSurround)aMC.GetOrder());
+ if( aMC.GetGoldCut() )
+ aSurr.SetSurround( SURROUND_IDEAL );
+ pSet->Put( aSurr );
+ }
+ break;
+ case RTF_FLYVERT:
+ {
+ RTFVertOrient aVO( nVal );
+ aVert.SetVertOrient( (SwVertOrient)aVO.GetOrient() );
+ aVert.SetRelationOrient( (SwRelationOrient)aVO.GetRelation() );
+ }
+ break;
+ case RTF_FLYHORZ:
+ {
+ RTFHoriOrient aHO( nVal );
+ aHori.SetHoriOrient( (SwHoriOrient)aHO.GetOrient() );
+ aHori.SetRelationOrient( (SwRelationOrient)aHO.GetRelation() );
+ }
+ break;
+ case RTF_FLYOUTLEFT: aLR.SetLeft( nVal ); break;
+ case RTF_FLYOUTRIGHT: aLR.SetRight( nVal ); break;
+ case RTF_FLYOUTUPPER: aUL.SetUpper( nVal ); break;
+ case RTF_FLYOUTLOWER: aUL.SetLower( nVal ); break;
+ case RTF_FLYANCHOR:
+ switch( GetNextToken() )
+ {
+ case RTF_FLY_PAGE:
+ aAnchor.SetType( FLY_PAGE );
+ aAnchor.SetPageNum( USHORT(nTokenValue));
+ aAnchor.SetAnchor( 0 );
+ break;
+
+ case RTF_FLY_CNTNT:
+ {
+ SwNodeIndex aIdx( pPam->GetPoint()->nNode );
+ pDoc->GetNodes().GoPrevious( &aIdx );
+ SwPosition aPos( aIdx );
+ aAnchor.SetType( FLY_AT_CNTNT );
+ aAnchor.SetAnchor( &aPos );
+ }
+ break;
+
+// JP 26.09.94: die Bindung an die Spalte gibt es nicht mehr !!
+// case RTF_FLY_COLUMN:
+ }
+ break;
+ case RTF_COLS: nCols = USHORT( nTokenValue ); break;
+ case RTF_COLSX: nColSpace = USHORT( nTokenValue ); break;
+ case RTF_COLNO:
+ nAktCol = USHORT( nTokenValue );
+ if( RTF_COLW == GetNextToken() )
+ {
+ USHORT nWidth = USHORT( nTokenValue ), nSpace = 0;
+ if( RTF_COLSR == GetNextToken() )
+ nSpace = USHORT( nTokenValue );
+ else
+ SkipToken( -1 ); // wieder zurueck
+
+ if( --nAktCol == ( aColumns.Count() / 2 ) )
+ {
+ aColumns.Insert( nWidth + nSpace, aColumns.Count() );
+ aColumns.Insert( nSpace, aColumns.Count() );
+ }
+ }
+ break;
+
+ case '{':
+ if( RTF_BRDBOX == ( nToken = GetNextToken() ) )
+ ReadBorderAttr( nToken, aSet );
+ else if( RTF_SHADINGDEF == (nToken & ~0xff ) )
+ ReadBackgroundAttr( nToken, aSet );
+ else if( RTF_IGNOREFLAG == nToken )
+ {
+ int bSkipGrp = TRUE;
+ switch( nToken = GetNextToken() )
+ {
+ case RTF_SHADOW:
+ case RTF_BRDBOX:
+ ReadAttr( SkipToken( -2 ), &aSet );
+ bSkipGrp = FALSE;
+ break;
+
+ case RTF_BRDRT:
+ case RTF_BRDRB:
+ case RTF_BRDRR:
+ case RTF_BRDRL:
+ bSkipGrp = FALSE;
+ ReadBorderAttr( SkipToken( -2 ), aSet );
+ break;
+ }
+
+ // keine weitere Klammer mehr ueberlesen!!!
+ if( !bSkipGrp )
+ break;
+
+ SkipGroup();
+ }
+ else
+ SkipGroup();
+ GetNextToken(); // Klammer ueberlesen
+ break;
+ }
+ } while( IsParserWorking() &&
+ '}' != ( nToken = GetNextToken() ));
+
+ if( aUL.GetUpper() || aUL.GetLower() )
+ pSet->Put( aUL );
+ if( aLR.GetLeft() || aLR.GetRight() )
+ pSet->Put( aLR );
+ }
+ else if( RTF_BRDBOX == nToken )
+ ReadBorderAttr( nToken, aSet );
+ else if( RTF_SHADOW == nToken )
+ ReadAttr( SkipToken( -2 ), &aSet );
+ else if( RTF_SHADINGDEF == (nToken & ~0xff ) )
+ ReadBackgroundAttr( nToken, aSet );
+ else if( RTF_UNKNOWNCONTROL == nToken )
+ SkipGroup();
+ else
+ nSkip = -2;
+
+ if( nSkip )
+ {
+ nToken = SkipToken( nSkip );
+ bWeiter = FALSE;
+ }
+ }
+ break;
+
+ default:
+ bWeiter = FALSE;
+ }
+
+ if( bWeiter )
+ nToken = GetNextToken();
+ } while( bWeiter && IsParserWorking() );
+
+ if( !bReadSwFly && ( FRAME == aVert.GetRelationOrient() ||
+ //JP 21.07.99: for Bug 67630 - it read into Header od Footer, set
+ // never the anchor to Page. Because it is then only
+ // on the first used page .
+ ( FLY_PAGE == aAnchor.GetAnchorId() &&
+ pPam->GetPoint()->nNode < pDoc->GetNodes().GetEndOfExtras() &&
+ ( pPam->GetNode()->FindHeaderStartNode() ||
+ pPam->GetNode()->FindFooterStartNode() )) ))
+ aAnchor.SetType( FLY_AT_CNTNT );
+
+ pSet->Put( aAnchor );
+ pSet->Put( aHori );
+ pSet->Put( aVert );
+
+ if( nCols && USHRT_MAX != nCols )
+ {
+ SwFmtCol aCol;
+ if( USHRT_MAX == nColSpace )
+ nColSpace = 720;
+
+ const SvxLRSpaceItem& rLR = (SvxLRSpaceItem&)pSet->Get( RES_LR_SPACE );
+ ULONG nWidth = USHRT_MAX;
+ aCol.Init( nCols, nColSpace, USHORT( nWidth ) );
+ if( nCols == ( aColumns.Count() / 2 ) )
+ {
+ for( USHORT n = 0, i = 0; n < aColumns.Count(); n += 2, ++i )
+ {
+ SwColumn* pCol = aCol.GetColumns()[ i ];
+ ULONG nTmp = aColumns[ n ];
+ nTmp *= USHRT_MAX;
+ nTmp /= nWidth;
+ pCol->SetWishWidth( USHORT(nTmp) );
+/*
+ JP 07.07.95: der Dialog kennt nur eine Breite fuer alle Spalten
+ darum hier nicht weiter beachten
+ nTmp = aColumns[ n+1 ];
+ if( nTmp )
+ pCol->SetRight( USHORT(nTmp) );
+ else
+ pCol->SetRight( 0 );
+ pCol->SetLeft( 0 );
+*/
+ }
+ }
+ pSet->Put( aCol );
+ }
+
+ if( pSet != &aSet ) // wurde der Set uebergeben, dann wars das
+ return ;
+
+ // ein neues FlyFormat anlegen oder das alte benutzen ?
+ // (teste ob es die selben Attribute besitzt!)
+ SwFlySave* pFlySave;
+ USHORT nFlyArrCnt = aFlyArr.Count();
+ if( !nFlyArrCnt ||
+ !( pFlySave = aFlyArr[ nFlyArrCnt-1 ])->IsEqualFly( *pPam, aSet ))
+ {
+ pFlySave = new SwFlySave( *pPam, aSet );
+ Size aPgSize;
+ GetPageSize( aPgSize );
+ pFlySave->nPageWidth = aPgSize.Width();
+
+ if( nDropCapAnchor )
+ {
+ pFlySave->nDropAnchor = nDropCapAnchor;
+ pFlySave->nDropLines = nDropCapLines;
+ }
+ aFlyArr.Insert( pFlySave, nFlyArrCnt++ );
+ }
+
+ SetPardTokenRead( FALSE );
+ const SwTableNode* pTblNd = pPam->GetNode()->FindTableNode();
+
+ while( !IsPardTokenRead() && IsParserWorking() )
+ {
+ if( RTF_PARD == nToken || nOpenBrakets > GetOpenBrakets() )
+ break;
+
+ NextToken( nToken );
+
+ if( !IsPardTokenRead() )
+ {
+ nToken = GetNextToken();
+
+ // BUG 22036: kommt zwischen Fly-Attributen ein unbekanntes,
+ // dann erzeuge nie 2 FlyFrames, sondern fasse
+ // beide zusammen !!!
+ while( RTF_APOCTL == ( nToken & ~(0xff | RTF_SWGDEFS) ))
+ {
+ if( RTF_FLY_INPARA == nToken )
+ break;
+
+ if( RTF_IGNOREFLAG == SkipToken( -1 ) )
+ {
+ if( '{' == SkipToken( -1 ) )
+ nToken = '{';
+ else
+ SkipToken( 2 );
+ }
+ else
+ SkipToken( 1 );
+
+ ReadFly( nToken, &pFlySave->aFlySet );
+ nToken = GetNextToken();
+ }
+ }
+ }
+
+ if( pTblNd && !pPam->GetPoint()->nContent.GetIndex() &&
+ pTblNd->EndOfSectionIndex() + 1 ==
+ pPam->GetPoint()->nNode.GetIndex() )
+ {
+ // nicht mehr in der Tabelle, sondern dahinter ?
+ // Dann aber wieder zurueck in die Tabelle
+ pPam->Move( fnMoveBackward );
+ }
+ else
+ pTblNd = 0;
+
+ // wurde garnichts eingefuegt?
+ if( !pTblNd &&
+ pPam->GetPoint()->nNode == pFlySave->nSttNd &&
+ !pPam->GetPoint()->nContent.GetIndex() )
+ {
+// // dann erzeuge mindestens einen leeren TextNode
+// pDoc->AppendTxtNode(*pPam);
+ // dann zerstoere den FlySave wieder.
+ aFlyArr.DeleteAndDestroy( --nFlyArrCnt );
+
+ }
+ else
+ {
+ FASTBOOL bMovePaM = 0 != pTblNd;
+
+ pFlySave->nEndNd = pPam->GetPoint()->nNode;
+ pFlySave->nEndCnt = pPam->GetPoint()->nContent.GetIndex();
+
+ if( bMovePaM )
+ pPam->Move( fnMoveForward );
+
+ pTblNd = pFlySave->nSttNd.GetNode().FindTableNode();
+ if( pTblNd && !pFlySave->nEndCnt &&
+ pTblNd == pFlySave->nEndNd.GetNode().FindTableNode() )
+ {
+ // dann teste mal, ob das \pard nicht zu spaet kam und
+ // eigentlich in die vorherige Zelle gehoert
+ const SwStartNode* pSttBoxNd = pFlySave->nSttNd.GetNode().
+ FindTableBoxStartNode(),
+ * pEndBoxNd = pFlySave->nEndNd.GetNode().
+ FindTableBoxStartNode();
+ if( pSttBoxNd && pEndBoxNd &&
+ bMovePaM ? ( pSttBoxNd == pEndBoxNd )
+ : ( pSttBoxNd->EndOfSectionIndex() + 1 ==
+ pEndBoxNd->GetIndex() &&
+ pEndBoxNd->GetIndex() + 1 ==
+ pFlySave->nEndNd.GetIndex() ))
+ {
+ // dann gehoert das Ende in die vorherige Box!
+ SwPosition aPos( *pPam->GetPoint() );
+ pPam->GetPoint()->nNode = *pSttBoxNd->EndOfSectionNode();
+ pPam->Move( fnMoveBackward, fnGoNode );
+
+ DelLastNode();
+
+ pPam->GetPoint()->nNode = *pSttBoxNd->EndOfSectionNode();
+ pPam->Move( fnMoveBackward, fnGoNode );
+
+ pFlySave->nEndNd = pPam->GetPoint()->nNode;
+ pFlySave->nEndCnt = pPam->GetPoint()->nContent.GetIndex();
+
+ *pPam->GetPoint() = aPos;
+ }
+ }
+ else if( !bReadSwFly && !pFlySave->nEndCnt &&
+ pFlySave->nSttNd.GetIndex() + 1 == pFlySave->nEndNd.GetIndex() &&
+ pFlySave->nSttNd.GetNode().IsTxtNode() )
+ {
+
+ SwTxtNode* pTxtNd = pFlySave->nSttNd.GetNode().GetTxtNode();
+ SwTxtFlyCnt* pFlyCnt;
+ if( 1 == pTxtNd->GetTxt().Len() &&
+ 0 != ( pFlyCnt = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr(
+ 0, RES_TXTATR_FLYCNT )) &&
+ pFlyCnt->GetFlyCnt().GetFrmFmt() )
+ {
+ // then move the content into the surrounded fly
+ SwFrmFmt* pFlyFmt = pFlyCnt->GetFlyCnt().GetFrmFmt();
+ const SwNodeIndex* pFlySNd = pFlyFmt->GetCntnt().GetCntntIdx();
+ SwNodeRange aRg( *pFlySNd, 1,
+ *pFlySNd->GetNode().EndOfSectionNode(), 0 );
+
+ // merge the itemsets
+ SwFmtFrmSize aSz1( (SwFmtFrmSize&)pFlyFmt->GetAttrSet().
+ Get( RES_FRM_SIZE ));
+ SwFmtFrmSize aSz2( (SwFmtFrmSize&)pFlySave->aFlySet.
+ Get( RES_FRM_SIZE ));
+ // if
+ if( !aRg.aStart.GetNode().IsNoTxtNode() ||
+ !aSz1.GetHeight() || !aSz1.GetWidth() ||
+ !aSz2.GetHeight() || !aSz2.GetWidth() ||
+ ( aSz1.GetHeight() == aSz2.GetHeight() &&
+ aSz1.GetWidth() == aSz2.GetWidth() ) )
+ {
+ SfxItemSet aDiffs( pFlyFmt->GetAttrSet() );
+ aDiffs.ClearItem( RES_ANCHOR );
+ aDiffs.ClearItem( RES_FRM_SIZE );
+ aDiffs.ClearItem( RES_CNTNT );
+ aDiffs.Differentiate( pFlySave->aFlySet );
+ pFlySave->aFlySet.Put( aDiffs );
+
+ BOOL bSet = FALSE;
+ if( aSz1.GetHeight() && !aSz2.GetHeight() )
+ {
+ bSet = TRUE;
+ aSz2.SetHeight( aSz1.GetHeight() );
+ }
+ if( aSz1.GetWidth() && !aSz2.GetWidth() )
+ {
+ bSet = TRUE;
+ aSz2.SetWidth( aSz1.GetWidth() );
+ }
+ if( bSet )
+ pFlySave->aFlySet.Put( aSz2 );
+
+ // move any PageBreak/Desc Attr to the next Para
+ {
+ SwCntntNode* pSrcNd = pFlySave->nSttNd.GetNode().GetCntntNode();
+ SwCntntNode* pDstNd = pFlySave->nEndNd.GetNode().GetCntntNode();
+
+ ::lcl_CpyBreakAttrs( pSrcNd, pDstNd, &pFlySave->nEndNd );
+ }
+
+ // create new txtnode, because the section does never be empty
+ pDoc->GetNodes().MakeTxtNode( aRg.aStart,
+ (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
+
+ SwNodeIndex aTmp( pFlySave->nSttNd, +1 );
+ pDoc->Move( aRg, aTmp );
+
+ // now delete the redundant txtnode
+ pDoc->GetNodes().Delete( pFlySave->nSttNd, 1 );
+ }
+ }
+ }
+ }
+
+ bReadSwFly = FALSE;
+ SkipToken( -1 );
+}
+
+
+void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf,
+ const SvxRTFPictureType* pPicType )
+{
+ // kennzeichen fuer Swg-Dokumente:
+ // (dann ist das FlyFmt fuer die Grafik!)
+ SwGrfNode * pGrfNd;
+ if( bReadSwFly )
+ {
+ // erzeuge nur einen normalen GrafikNode und ersetze diesen gegen
+ // den vorhandenen Textnode
+ SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
+ pGrfNd = pDoc->GetNodes().MakeGrfNode( rIdx,
+ rGrfNm, aEmptyStr, // Name der Graphic !!
+ pGrf,
+ (SwGrfFmtColl*)pDoc->GetDfltGrfFmtColl() );
+
+ if( pGrfAttrSet )
+ pGrfNd->SetAttr( *pGrfAttrSet );
+
+ SwFlySave* pFlySave = aFlyArr[ aFlyArr.Count()-1 ];
+ pFlySave->nSttNd = rIdx.GetIndex() - 1;
+
+ if( 1 < aFlyArr.Count() )
+ {
+ pFlySave = aFlyArr[ aFlyArr.Count() - 2 ];
+ if( pFlySave->nEndNd == rIdx )
+ pFlySave->nEndNd = rIdx.GetIndex() - 1;
+ }
+ }
+ else
+ {
+ // wenn normale RTF-Grafik, dann steht diese im Textfluss !
+ SwAttrSet aFlySet( pDoc->GetAttrPool(), RES_VERT_ORIENT, RES_ANCHOR );
+ const SwPosition* pPos = pPam->GetPoint();
+
+ SwFmtAnchor aAnchor( FLY_IN_CNTNT );
+ aAnchor.SetAnchor( pPos );
+ aFlySet.Put( aAnchor );
+ aFlySet.Put( SwFmtVertOrient( 0, VERT_TOP ));
+
+ SwFrmFmt* pFlyFmt = pDoc->Insert( *pPam,
+ rGrfNm, aEmptyStr, // Name der Graphic !!
+ pGrf,
+ &aFlySet, // Attribute fuer den FlyFrm
+ pGrfAttrSet ); // Attribute fuer die Grafik
+
+ pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()->
+ GetIndex()+1 ]->GetGrfNode();
+
+ _SetPictureSize( *pGrfNd, pPos->nNode,
+ (SfxItemSet&)pFlyFmt->GetAttrSet(),
+ pPicType );
+ }
+
+ if( pGrfAttrSet )
+ DELETEZ( pGrfAttrSet );
+}
+
+void SwRTFParser::_SetPictureSize( const SwNoTxtNode& rNd,
+ const SwNodeIndex& rAnchor,
+ SfxItemSet& rSet,
+ const SvxRTFPictureType* pPicType )
+{
+ Size aSize( ((SwNoTxtNode&)rNd).GetTwipSize() );
+ if( pPicType )
+ {
+ if( rNd.IsGrfNode() )
+ {
+ if( SvxRTFPictureType::WIN_METAFILE != pPicType->eStyle &&
+ pPicType->nGoalWidth && pPicType->nGoalHeight )
+ {
+ aSize.Width() = pPicType->nGoalWidth;
+ aSize.Height() =pPicType->nGoalHeight;
+ }
+ else if( SvxRTFPictureType::MAC_QUICKDRAW == pPicType->eStyle )
+ {
+ // IMMER auf 72 DPI bezogen, also 1pt == 20 Twip !!
+ aSize.Width() = pPicType->nWidth * 20;
+ aSize.Height() = pPicType->nHeight * 20;
+ }
+ else
+ {
+ // von 100TH_MM nach TWIP umrechenen!
+ aSize.Width() = pPicType->nWidth * 144 / 254;
+ aSize.Height() = pPicType->nHeight * 144 / 254;
+ }
+ ((SwGrfNode&)rNd).SetTwipSize( aSize );
+ }
+
+ if( 100 != pPicType->nScalX )
+ aSize.Width() = (((long)pPicType->nScalX) * ( aSize.Width() -
+ ( pPicType->nCropL + pPicType->nCropR ))) / 100L;
+
+ if( 100 != pPicType->nScalY )
+ aSize.Height() = (((long)pPicType->nScalY) * ( aSize.Height() -
+ ( pPicType->nCropT + pPicType->nCropB ))) / 100L;
+ }
+
+ // sorge dafuer, das der Rahmen nicht groesser als der akt.
+ // Pagedescriptor wird.
+ Size aPgSize;
+ GetPageSize( aPgSize );
+
+ if( aSize.Height() > aPgSize.Height() )
+ aSize.Height() = aPgSize.Height();
+
+ if( aSize.Width() > aPgSize.Width() )
+ aSize.Width() = aPgSize.Width();
+
+ //steht der Fly etwa in einer Tabelle ?
+ const SwNode* pAnchorNd = pDoc->GetNodes()[ rAnchor ];
+ const SwTableNode* pTblNd = pAnchorNd->FindTableNode();
+ if( pTblNd )
+ {
+ // Box feststellen:
+ const SwTableBox* pBox = pTblNd->GetTable().GetTblBox(
+ pAnchorNd->StartOfSectionIndex() );
+ if( pBox )
+ {
+ long nBoxWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
+ if( aSize.Width() > nBoxWidth )
+ aSize.Width() = nBoxWidth;
+ }
+ }
+
+ // min. Werte einhalten !!
+ if( aSize.Width() < /*2268*/MINFLY )
+ aSize.Width() = /*2268*/MINFLY;
+ if( aSize.Height() < MINFLY)
+ aSize.Height() = MINFLY;
+
+ if( pPicType )
+ {
+ BOOL bChg = FALSE;
+ SwCropGrf aCrop;
+
+/*
+ JP 28.07.99: Bug 67800 - no crop by MAC_QUICKDRAW. At time i dont know why
+ it has been coded. But this has used for any
+ RTF-File, but i dont found them.
+ if( SvxRTFPictureType::MAC_QUICKDRAW == pPicType->eStyle )
+ {
+ // evt. ein wenig Croppen ??
+ // IMMER auf 72 DPI bezogen, also 1pt == 20 Twip !!
+ long nTmp = pPicType->nWidth * 20;
+ if( nTmp != aSize.Width() )
+ {
+ // in der Breite (also rechts) croppen
+ aCrop.Right() = nTmp - aSize.Width();
+ aSize.Width() = nTmp;
+ bChg = TRUE;
+ }
+
+ nTmp = pPicType->nHeight * 20;
+ if( nTmp != aSize.Height() )
+ {
+ // in der Hoehe (also unten) croppen
+ aCrop.Bottom() = nTmp - aSize.Height();
+ aSize.Height() = nTmp;
+ bChg = TRUE;
+ }
+ }
+*/
+ if( pPicType->nCropT )
+ aCrop.SetTop( pPicType->nCropT ), bChg = TRUE;
+ if( pPicType->nCropB )
+ aCrop.SetBottom( pPicType->nCropB ), bChg = TRUE;
+ if( pPicType->nCropL )
+ aCrop.SetLeft( pPicType->nCropL ), bChg = TRUE;
+ if( pPicType->nCropR )
+ aCrop.SetRight( pPicType->nCropR ), bChg = TRUE;
+
+ if( bChg )
+ {
+ // dann mal an die CropWerte an die GrafikSize anpassen.
+ ((SwNoTxtNode&)rNd).SetAttr( aCrop );
+ }
+ }
+ rSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aSize.Width(), aSize.Height() ));
+}
+
+void SwRTFParser::GetPageSize( Size& rSize )
+{
+ const SwFrmFmt& rPgFmt = pDoc->GetPageDesc(nAktPageDesc).GetMaster();
+
+ const SwFmtFrmSize& rSz = rPgFmt.GetFrmSize();
+ const SvxLRSpaceItem& rLR = rPgFmt.GetLRSpace();
+ const SvxULSpaceItem& rUL = rPgFmt.GetULSpace();
+ const SwFmtCol& rCol = rPgFmt.GetCol();
+
+ rSize.Width() = rSz.GetWidth() - rLR.GetLeft() - rLR.GetRight();
+ rSize.Height() = rSz.GetHeight() - rUL.GetUpper() - rUL.GetLower();
+
+ if( 1 < rCol.GetNumCols() )
+ {
+ rSize.Width() /= rCol.GetNumCols();
+ rSize.Height() /= rCol.GetNumCols();
+ }
+}
+
+void __EXPORT SwRTFParser::ReadBitmapData()
+{
+ Graphic aGrf;
+ SvxRTFPictureType aPicType;
+ if( ReadBmpData( aGrf, aPicType ) )
+ InsPicture( aEmptyStr, &aGrf, &aPicType );
+}
+
+#ifdef READ_OLE_OBJECT
+void __EXPORT SwRTFParser::ReadOLEData()
+{
+ SvCacheStream aTmpFile( 0xA000 );
+ Graphic aGrf;
+ SvxRTFPictureType aPicType, aOleType;
+
+ int nToken, bValidOle = TRUE, bWeiter = TRUE;
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+
+ String* pStr = 0;
+ String sObjClass, sObjName, sObjData;
+
+ while( nOpenBrakets && IsParserWorking() && bWeiter && bValidOle )
+ {
+ nToken = GetNextToken();
+ USHORT nVal = USHORT( nTokenValue );
+ switch( nToken )
+ {
+ case '}': --nOpenBrakets; pStr = 0; break;
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ else if( RTF_UNKNOWNCONTROL != GetNextToken() )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++nOpenBrakets;
+ }
+ break;
+
+ case RTF_OBJECT:
+ case RTF_OBJEMB: // default ist embedded
+ case RTF_LINKSELF: // ??
+ case RTF_OBJLOCK: // ??
+ case RTF_OBJUPDATE: // ??
+ case RTF_OBJTIME: // ??
+ case RTF_OBJSETSIZE:
+ case RTF_OBJALIGN:
+ case RTF_OBJTRANSY:
+ case RTF_OBJATTPH:
+ break;
+
+ case RTF_OBJLINK: // ?? welche Daten sind das ??
+ case RTF_OBJAUTLINK: // ?? -""- ??
+ case RTF_OBJSUB:
+ case RTF_OBJPUB:
+ case RTF_OBJICEMB:
+ case RTF_OBJOCX:
+ case RTF_OBJHTML:
+ case RTF_OBJALIAS:
+ case RTF_OBJSECT:
+ bValidOle = FALSE; // diese Typen koennen wir nicht
+ break;
+
+ case RTF_OBJCLASS:
+ // Daten lesen
+ pStr = &sObjClass;
+ break;
+
+ case RTF_OBJNAME:
+ // Daten lesen
+ pStr = &sObjName;
+ break;
+
+ case RTF_OBJDATA:
+ pStr = &sObjData;
+ break;
+
+ case RTF_RESULT:
+ {
+ // hier weitermachen, wenn das OLE-Object ungueltig ist
+ bWeiter = FALSE;
+ }
+ break;
+ case RTF_RSLTBMP: // diese sollten wir ignorieren
+ case RTF_RSLTMERGE:
+ case RTF_RSLTPICT:
+ case RTF_RSLTRTF:
+ case RTF_RSLTTXT:
+ break;
+
+ case RTF_OBJW: aOleType.nWidth = nVal; break;
+ case RTF_OBJH: aOleType.nHeight = nVal; break;
+ case RTF_OBJCROPT: aOleType.nCropT = (short)nTokenValue; break;
+ case RTF_OBJCROPB: aOleType.nCropB = (short)nTokenValue; break;
+ case RTF_OBJCROPL: aOleType.nCropL = (short)nTokenValue; break;
+ case RTF_OBJCROPR: aOleType.nCropR = (short)nTokenValue; break;
+ case RTF_OBJSCALEX: aOleType.nScalX = nVal; break;
+ case RTF_OBJSCALEY: aOleType.nScalY = nVal; break;
+
+ case RTF_TEXTTOKEN:
+ if( 1 < nOpenBrakets && pStr )
+ {
+ if( pStr == &sObjData )
+ {
+ xub_StrLen nHexLen = HexToBin( aToken );
+ if( STRING_NOTFOUND != nHexLen )
+ bValidOle = FALSE;
+ else
+ {
+ aTmpFile.Write( (sal_Char*)aToken.GetBuffer(), nHexLen );
+ bValidOle = 0 == aTmpFile.GetError();
+ }
+ }
+ else
+ *pStr += aToken;
+ }
+ break;
+ }
+ }
+
+ if( bValidOle )
+ {
+ bValidOle = FALSE; // erstmal
+ }
+
+ if( !bWeiter ) // dann stehen wir noch im Result
+ {
+ // ist das Ole-Object Ok?
+ // -> dann solange SkipGroup rufen, bis zur letzten
+ // schliessenden Klammer
+ // ansonsten alle Token verarbeiten, bis zur letzten
+ // schliessenden Klammer
+
+ bWeiter = TRUE;
+ while( nOpenBrakets && IsParserWorking() && bWeiter )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case '}': --nOpenBrakets; break;
+ case '{': ++nOpenBrakets; break;
+ }
+ if( nOpenBrakets && !bValidOle )
+ NextToken( nToken );
+ }
+ }
+
+ if( !bValidOle && '}' != nToken )
+ SkipGroup();
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/rtf/rtffly.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.86 2000/09/18 16:04:50 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.85 2000/08/25 12:27:59 jp
+ Graphic Crop-Attribut exported to SVX
+
+ Revision 1.84 2000/05/09 17:22:49 jp
+ Changes for Unicode
+
+ Revision 1.83 2000/04/14 14:06:17 khz
+ Task #70451# use CalculateFlySize() for WW frames with 'auto'width
+
+ Revision 1.82 1999/12/13 13:17:43 jp
+ Bug #70652#: read tokens posnegx/y
+
+ Revision 1.81 1999/08/19 10:33:32 JP
+ Bug #68304#: by windows metafile ignore the picgoal size, dont delete sourrounded flys if the size unequal
+
+
+ Rev 1.80 19 Aug 1999 12:33:32 JP
+ Bug #68304#: by windows metafile ignore the picgoal size, dont delete sourrounded flys if the size unequal
+
+ Rev 1.79 09 Aug 1999 17:37:48 JP
+ read owne border of flyframes
+
+ Rev 1.78 05 Aug 1999 23:04:16 JP
+ Bug #67974#: SetFlysInDoc - anchor to next or cur paragraph
+
+ Rev 1.77 03 Aug 1999 19:46:44 JP
+ Bug #68007#,#67978#: changes for import of flys from interleave/WP7/Aplixware
+
+ Rev 1.76 28 Jul 1999 14:21:32 JP
+ Bug #67800#: set no crop by MAC-Pictures, if the size not equal
+
+ Rev 1.75 21 Jul 1999 18:27:02 JP
+ Bug #67630#,#67663#: changes for read of flys
+
+ Rev 1.74 08 Jul 1999 21:24:24 JP
+ has an APO no framesize, then get from the txtnode the min/max size
+
+ Rev 1.73 17 Jun 1999 14:46:20 JP
+ Bug #66301#: SetFlyInDoc - create new Node if the 'anchor' Node has pagebreak attrs
+
+ Rev 1.72 19 Apr 1999 12:48:44 JP
+ Vorbereitungen fuer OLE-Objecte in RTF lesen (anstoss ist Bug #60140#)
+
+ Rev 1.71 24 Mar 1999 14:48:58 JP
+ Bug #63882#: Flys in/mit Tabellen korrekt lesen
+
+ Rev 1.70 19 Nov 1998 22:05:58 JP
+ Bug #59697#: Token ABSLOCK ignorieren, inner/out richtig behandeln
+
+ Rev 1.69 21 Sep 1998 17:16:14 JP
+ DropCaps unterstuetzen
+
+ Rev 1.68 27 Jul 1998 14:57:06 JP
+ Bug #54001#: Wert vom AbsH an der Size setzen
+
+ Rev 1.67 06 Jul 1998 13:36:00 MH
+ int. comp. error
+
+ Rev 1.66 13 May 1998 18:16:20 JP
+ CheckSize: nicht mit undefiniertem Pointer arbeiten
+
+ Rev 1.65 12 May 1998 15:51:20 JP
+ rund um Flys/DrawObjs im Doc/FESh umgestellt/optimiert
+
+ Rev 1.64 07 May 1998 15:40:08 JP
+ MacPict Grafiken haben Point und keine MM100 angaben
+
+ Rev 1.63 08 Apr 1998 14:28:34 RG
+ C40_INSERT ging unter unxsols nicht
+
+ Rev 1.62 20 Feb 1998 13:36:32 MA
+ headerfiles gewandert
+
+ Rev 1.61 17 Feb 1998 12:24:54 RG
+ Mac: sysdep.hxx raus
+
+ Rev 1.60 11 Feb 1998 14:07:16 JP
+ kleinere Bugs behoben bei Rahmen & Tabellen
+
+ Rev 1.59 29 Jan 1998 21:35:24 JP
+ GetEndOfIcons ersetzt durch GetEndOfExtras, das auf GetEndOfRedlines mappt
+
+ Rev 1.58 25 Nov 1997 15:11:30 JP
+ Headerfiles
+
+ Rev 1.57 20 Nov 1997 12:16:50 AMA
+ Opt. SwSurround: GoldCut jetzt als Enum; nicht implementierte Enums entfernt
+
+ Rev 1.56 03 Nov 1997 14:10:36 MA
+ precomp entfernt
+
+ Rev 1.55 30 Oct 1997 17:49:32 AMA
+ Chg: Kein AutoFlag mehr an Break bzw. PageDesc-Attributen
+
+ Rev 1.54 09 Oct 1997 14:27:50 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.53 15 Aug 1997 12:51:44 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.52 13 Aug 1997 19:18:30 JP
+ Bug #41892#: ReadFly - nur bei RTF-Absatzbindung ggfs. auf die Seienbind. umschalten
+
+ Rev 1.51 13 Aug 1997 18:35:02 JP
+ Bug #42480#: spaltige Rahmen kennt RTF nicht, nur wir
+
+ Rev 1.50 11 Aug 1997 17:49:34 OS
+ Header-Umstellung
+
+ Rev 1.49 07 Aug 1997 15:06:24 OM
+ Headerfile-Umstellung
+
+ Rev 1.48 22 May 1997 20:39:54 JP
+ Bug #40118#: kein Inhalt im Fly -> verwerfen
+
+ Rev 1.47 07 Jan 1997 16:53:22 JP
+ Bug #34627#: GrafikGroesse setzen
+
+ Rev 1.46 06 Jan 1997 19:04:10 JP
+ IsEqual: Flys zusammenfassen, wenns die akt. Position vom vorhergeheden ist
+
+ Rev 1.45 06 Jan 1997 15:15:48 JP
+ Bug #34622#: TeilNodes bei Flys absplitten, FlyInFlys korrekt lesen
+
+ Rev 1.44 29 Oct 1996 12:58:50 JP
+ am Doc ist das NodesArray nur noch ueber Get..() zugaenglich
+
+ Rev 1.43 09 Oct 1996 13:05:18 JP
+ SwNodes::GoNext/-Prev (-Sect) returnt statt BOOL den gefundenen ContentNode
+
+ Rev 1.42 08 Oct 1996 13:53:42 JP
+ IsEqualFly: Header/Footer Absaetze nicht zusammenfassen;absatzgebundene Flys
+
+ Rev 1.41 27 Sep 1996 17:59:46 MIB
+ In Filtern in Rahmenvorlagen Umrandungs/Abstaende loeschen
+
+ Rev 1.40 29 Aug 1996 10:10:46 JP
+ beim StartNode muss jetzt ein spz. Sectiontype gesetzt werden
+
+ Rev 1.39 20 Aug 1996 14:53:34 TRI
+ C40_INSERT statt Insert
+
+ Rev 1.38 04 Jul 1996 15:01:20 JP
+ ReadFly: auch bei eigenen APOCTL ReadFly rufen
+
+ Rev 1.37 28 Jun 1996 15:07:30 MA
+ includes
+
+ Rev 1.36 18 Jun 1996 16:36:04 JP
+ ReadFly: erweitert um optionalen Itemset erweitert(FlyInFly lesen); MACPict: ggfs. Croppen
+
+ Rev 1.35 13 Jun 1996 09:21:26 JP
+ Flys lesen: bei Fly in Fly eine while schleife
+
+ Rev 1.34 10 Jun 1996 11:24:24 JP
+ Crop-Werte im CropAttribut setzen
+
+ Rev 1.33 25 Apr 1996 13:56:42 MIB
+ Verschiebung SvHTMLParser in Gooedies
+
+ Rev 1.32 25 Apr 1996 09:23:44 JP
+ lesen der Grafik-Daten in svxparser verschoben
+
+*************************************************************************/
+
diff --git a/sw/source/filter/rtf/rtfnum.cxx b/sw/source/filter/rtf/rtfnum.cxx
new file mode 100644
index 000000000000..5b5b42f75d43
--- /dev/null
+++ b/sw/source/filter/rtf/rtfnum.cxx
@@ -0,0 +1,1468 @@
+/*************************************************************************
+ *
+ * $RCSfile: rtfnum.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _RTFTOKEN_H
+#include <svtools/rtftoken.h>
+#endif
+#ifndef _RTFKEYWD_HXX //autogen
+#include <svtools/rtfkeywd.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX //autogen
+#include <svtools/intitem.hxx>
+#endif
+#ifndef _RTFOUT_HXX
+#include <svtools/rtfout.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_WRLMITEM_HXX //autogen
+#include <svx/wrlmitem.hxx>
+#endif
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _SWPARRTF_HXX
+#include <swparrtf.hxx>
+#endif
+#ifndef _WRTRTF_HXX
+#include <wrtrtf.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _NUMRULE_HXX
+#include <numrule.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+
+#define RTF_NUMRULE_NAME "RTF_Num"
+
+SV_IMPL_VARARR( SwListArr, SwListEntry )
+
+
+void lcl_ExpandNumFmts( SwNumRule& rRule )
+{
+ // dann noch das NumFormat in alle Ebenen setzen
+ for( BYTE n = 1; n < MAXLEVEL; ++n )
+ if( !rRule.GetNumFmt( n ) )
+ {
+ SwNumFmt aNumFmt( rRule.Get( 0 ));
+ aNumFmt.SetAbsLSpace( aNumFmt.GetAbsLSpace() * ( n + 1 ) );
+ rRule.Set( n, aNumFmt );
+ }
+}
+
+SfxItemSet& GetNumChrFmt( SwDoc& rDoc, SwNumRule& rRule, BYTE nNumLvl )
+{
+ SwCharFmt* pChrFmt = rRule.Get( nNumLvl ).GetCharFmt();
+ if( !pChrFmt )
+ {
+ String sNm( rRule.GetName() );
+ ( sNm += ' ' ) += String::CreateFromInt32( nNumLvl + 1 );
+ pChrFmt = rDoc.MakeCharFmt( sNm, rDoc.GetDfltCharFmt() );
+ if( !rRule.GetNumFmt( nNumLvl ))
+ rRule.Set( nNumLvl, rRule.Get( nNumLvl ) );
+ ((SwNumFmt*)rRule.GetNumFmt( nNumLvl ))->SetCharFmt( pChrFmt );
+ }
+ return (SfxItemSet&)pChrFmt->GetAttrSet();
+}
+
+void SwRTFParser::ReadListLevel( SwNumRule& rRule, BYTE nNumLvl )
+{
+ int nToken;
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ int nLvlTxtLevel = 0, nLvlNumberLevel = 0;
+ String sLvlText, sLvlNumber;
+ SwNumFmt* pCurNumFmt;
+ if( MAXLEVEL >= nNumLvl )
+ {
+ pCurNumFmt = (SwNumFmt*)rRule.GetNumFmt( nNumLvl );
+ pCurNumFmt->SetAbsLSpace( 0 );
+ pCurNumFmt->SetFirstLineOffset( 0 );
+ }
+ else
+ pCurNumFmt = 0;
+
+ while( nOpenBrakets && IsParserWorking() )
+ {
+ switch( ( nToken = GetNextToken() ))
+ {
+ case '}':
+ if( nOpenBrakets )
+ {
+ if( nLvlTxtLevel == nOpenBrakets )
+ {
+ if( DelCharAtEnd( sLvlText, ';' ).Len() &&
+ sLvlText.Len() && sLvlText.Len() ==
+ (USHORT)(sLvlText.GetChar( 0 )) + 1 )
+ sLvlText.Erase( 0, 1 );
+ nLvlTxtLevel = 0;
+ }
+ if( nLvlNumberLevel == nOpenBrakets )
+ {
+ DelCharAtEnd( sLvlNumber, ';' );
+ nLvlNumberLevel = 0;
+ }
+ }
+ --nOpenBrakets;
+ break;
+
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ // Unknown und alle bekannten nicht ausgewerteten Gruppen
+ // sofort ueberspringen
+ else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
+// RTF_PANOSE != nToken && RTF_FALT != nToken &&
+// RTF_FALT != nToken && RTF_FNAME != nToken &&
+// RTF_FONTEMB != nToken && RTF_FONTFILE != nToken )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++nOpenBrakets;
+ }
+ break;
+
+ case RTF_LEVELNFC:
+ {
+ SvxExtNumType eType = SVX_NUM_ARABIC;
+ switch( nTokenValue )
+ {
+ case 1: eType = SVX_NUM_ROMAN_UPPER; break;
+ case 2: eType = SVX_NUM_ROMAN_LOWER; break;
+ case 3: eType = SVX_NUM_CHARS_UPPER_LETTER_N; break;
+ case 4: eType = SVX_NUM_CHARS_LOWER_LETTER_N; break;
+ case 255:
+ case 23: eType = SVX_NUM_CHAR_SPECIAL; break;
+ }
+ if( pCurNumFmt )
+ pCurNumFmt->eType = eType;
+ }
+ break;
+
+ case RTF_LEVELJC:
+ {
+ SvxAdjust eAdj = SVX_ADJUST_LEFT;
+ switch( nTokenValue )
+ {
+ case 1: eAdj = SVX_ADJUST_CENTER; break;
+ case 2: eAdj = SVX_ADJUST_RIGHT; break;
+ }
+ if( pCurNumFmt )
+ pCurNumFmt->SetAdjust( eAdj );
+ }
+ break;
+
+ case RTF_LEVELSTARTAT:
+ if( pCurNumFmt && -1 != nTokenValue )
+ pCurNumFmt->SetStartValue( USHORT( nTokenValue ));
+ break;
+
+ case RTF_LEVELTEXT:
+ nLvlTxtLevel = nOpenBrakets;
+ break;
+
+ case RTF_LEVELNUMBERS:
+ nLvlNumberLevel = nOpenBrakets;
+ break;
+
+ case RTF_LI:
+ if( pCurNumFmt && -1 != nTokenValue )
+ {
+ if( 0 > nTokenValue )
+ nTokenValue =- nTokenValue;
+ pCurNumFmt->SetAbsLSpace( USHORT( nTokenValue ));
+ }
+ break;
+
+ case RTF_FI:
+ if( pCurNumFmt && -1 != nTokenValue )
+ {
+ if( 0 < short( nTokenValue ))
+ nTokenValue = - short( nTokenValue );
+ pCurNumFmt->SetFirstLineOffset( short( nTokenValue ));
+ }
+ break;
+
+ case RTF_TEXTTOKEN:
+ if( nLvlTxtLevel == nOpenBrakets )
+ sLvlText += aToken;
+ else if( nLvlNumberLevel == nOpenBrakets )
+ sLvlNumber += aToken;
+ break;
+
+ case RTF_LEVELOLD:
+ case RTF_LEVELPREV:
+ case RTF_LEVELPREVSPACE:
+ case RTF_LEVELINDENT:
+ case RTF_LEVELSPACE:
+ case RTF_LEVELFOLLOW:
+ case RTF_LEVELLEGAL:
+ case RTF_LEVELNORESTART:
+ break;
+
+ default:
+ if( pCurNumFmt &&
+ RTF_CHRFMT == (nToken & ~(0xff | RTF_SWGDEFS) ))
+ {
+ ReadAttr( nToken, &GetNumChrFmt( *pDoc, rRule, nNumLvl ) );
+
+ // dann aus der Vorlage den Font holen
+ if( SVX_NUM_CHAR_SPECIAL == pCurNumFmt->eType )
+ pCurNumFmt->SetBulletFont( FindFontOfItem(
+ pCurNumFmt->GetCharFmt()->GetFont() ) );
+ }
+ break;
+ }
+ }
+
+ if( IsParserWorking() && pCurNumFmt )
+ {
+ // dann erzeuge mal die Pre/Postfix-Strings
+ if( sLvlText.Len() &&
+ SVX_NUM_CHAR_SPECIAL == pCurNumFmt->eType )
+ {
+ pCurNumFmt->SetBulletChar( sLvlText.GetChar( 0 ) );
+ // dann aus der Vorlage den Font holen
+ if( pCurNumFmt->GetCharFmt() )
+ pCurNumFmt->SetBulletFont( FindFontOfItem(
+ pCurNumFmt->GetCharFmt()->GetFont() ) );
+ }
+ else if( sLvlNumber.Len() && sLvlText.Len() )
+ {
+ // in sLvlText steht der Text, in sLvlNumber die Position
+ // der Ebenen in sLvlText
+ pCurNumFmt->SetPrefix(
+ sLvlText.Copy( 0, USHORT( sLvlNumber.GetChar( 0 ))-1 ));
+ pCurNumFmt->SetPostfix( sLvlText.Copy(
+ USHORT( sLvlNumber.GetChar( sLvlNumber.Len()-1 )) ));
+ // wieviele Levels stehen im String?
+ pCurNumFmt->SetUpperLevel( (BYTE)sLvlNumber.Len() );
+ }
+ else if( !sLvlText.Len() )
+ {
+ pCurNumFmt->eType = SVX_NUM_NUMBER_NONE;
+ pCurNumFmt->SetPostfix( aEmptyStr );
+ }
+ }
+
+ SkipToken( -1 );
+}
+
+void SwRTFParser::ReadListTable()
+{
+ int nToken;
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ bNewNumList = TRUE;
+
+ USHORT nRuleCount = 0;
+ BYTE nNumLvl = 0;
+ SwNumRule* pCurRule = 0;
+ SwListEntry aEntry;
+
+ while( nOpenBrakets && IsParserWorking() )
+ {
+ switch( ( nToken = GetNextToken() ))
+ {
+ case '}': if( --nOpenBrakets && IsParserWorking() )
+ {
+ // Style konnte vollstaendig gelesen werden,
+ // also ist das noch ein stabiler Status
+ SaveState( RTF_LISTTABLE );
+ if( 1 == nOpenBrakets )
+ {
+ if( aEntry.nListId )
+ aListArr.Insert( aEntry, aListArr.Count() );
+ aEntry.Clear();
+ }
+ }
+ break;
+
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ // Unknown und alle bekannten nicht ausgewerteten Gruppen
+ // sofort ueberspringen
+ else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
+// RTF_PANOSE != nToken && RTF_FALT != nToken &&
+// RTF_FALT != nToken && RTF_FNAME != nToken &&
+// RTF_FONTEMB != nToken && RTF_FONTFILE != nToken )
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++nOpenBrakets;
+ }
+ break;
+
+ case RTF_LIST:
+ {
+ if( pCurRule && pCurRule->IsContinusNum() )
+ lcl_ExpandNumFmts( *pCurRule );
+
+ String sTmp( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( RTF_NUMRULE_NAME " 1" )));
+ aEntry.nListDocPos = pDoc->MakeNumRule( sTmp );
+ pCurRule = pDoc->GetNumRuleTbl()[ aEntry.nListDocPos ];
+ pCurRule->SetName( pDoc->GetUniqueNumRuleName( &sTmp, FALSE ) );
+ pCurRule->SetAutoRule( FALSE );
+ nNumLvl = (BYTE)-1;
+ }
+ break;
+
+ case RTF_LISTID: aEntry.nListId = nTokenValue; break;
+ case RTF_LISTTEMPLATEID: aEntry.nListTemplateId = nTokenValue; break;
+
+ case RTF_LISTRESTARTHDN:
+ break;
+ case RTF_LISTNAME:
+ if( RTF_TEXTTOKEN == GetNextToken() )
+ {
+ String sTmp( DelCharAtEnd( aToken, ';' ));
+ if( sTmp.Len() && !pDoc->FindNumRulePtr( sTmp ))
+ pCurRule->SetName( sTmp );
+ }
+ SkipGroup();
+ break;
+
+ case RTF_LISTSIMPLE:
+ pCurRule->SetContinusNum( TRUE );
+ break;
+
+ case RTF_LISTLEVEL:
+ {
+ if( ++nNumLvl < MAXLEVEL )
+ pCurRule->Set( nNumLvl, pCurRule->Get( nNumLvl ));
+ ReadListLevel( *pCurRule, nNumLvl );
+ }
+ break;
+ }
+ }
+
+ if( pCurRule && pCurRule->IsContinusNum() )
+ lcl_ExpandNumFmts( *pCurRule );
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+}
+
+BOOL lcl_IsEqual( SwNumRule* pOrigRule, SwNumRule* pRule )
+{
+ BOOL bRet = 0;
+ if( pOrigRule && pRule )
+ {
+ bRet = pOrigRule->GetRuleType() == pRule->GetRuleType() &&
+ pOrigRule->IsContinusNum() == pRule->IsContinusNum() &&
+ pOrigRule->IsAbsSpaces() == pRule->IsAbsSpaces();
+ if( bRet )
+ for( BYTE n = 0; bRet && n < MAXLEVEL; ++n )
+ {
+ const SwNumFmt* pOFmt = pOrigRule->GetNumFmt( n ),
+ * pFmt = pRule->GetNumFmt( n );
+ if( pFmt && pOFmt )
+ {
+ SwCharFmt* pOCFmt = pOFmt->GetCharFmt(),
+ * pCFmt = pFmt->GetCharFmt();
+ if( pOCFmt && pCFmt )
+ {
+ bRet = pCFmt->GetAttrSet() == pOCFmt->GetAttrSet();
+ }
+ else
+ bRet = !pCFmt && !pOCFmt;
+ if( bRet )
+ {
+ ((SwNumFmt*)pOFmt)->SetCharFmt( 0 );
+ ((SwNumFmt*)pFmt)->SetCharFmt( 0 );
+ bRet = *pOFmt == *pFmt;
+ ((SwNumFmt*)pOFmt)->SetCharFmt( pOCFmt );
+ ((SwNumFmt*)pFmt)->SetCharFmt( pCFmt );
+ }
+ }
+ else
+ bRet = !pFmt && !pOFmt;
+ }
+ }
+ return bRet;
+}
+
+void SwRTFParser::ReadListOverrideTable()
+{
+ int nToken;
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ SwListEntry aEntry;
+ SwNumRule* pRule = 0, *pOrigRule = 0;
+ BYTE nNumLvl = 0;
+ BOOL bOverrideFormat = FALSE, bOverrideStart = FALSE;
+
+ while( nOpenBrakets && IsParserWorking() )
+ {
+ switch( ( nToken = GetNextToken() ))
+ {
+ case '}':
+ if( --nOpenBrakets && IsParserWorking() )
+ {
+ // Style konnte vollstaendig gelesen werden,
+ // also ist das noch ein stabiler Status
+ SaveState( RTF_LISTOVERRIDETABLE );
+
+ if( 1 == nOpenBrakets )
+ {
+ bOverrideFormat = FALSE, bOverrideStart = FALSE;
+ if( pRule )
+ {
+ if( lcl_IsEqual( pOrigRule, pRule ))
+ {
+ // no changes on the rule -> use the original rule
+ aEntry.nListDocPos = pDoc->FindNumRule(
+ pOrigRule->GetName() );
+ // delete the temp Rule
+ RemoveUnusedNumRule( pRule );
+ }
+ else if( pRule->IsContinusNum() )
+ lcl_ExpandNumFmts( *pRule );
+ }
+
+ if( aEntry.nListId && aEntry.nListNo )
+ for( USHORT n = aListArr.Count(); n; )
+ if( aListArr[ --n ].nListId == aEntry.nListId &&
+ !aListArr[ n ].nListNo )
+ {
+ aListArr[ n ].nListNo = aEntry.nListNo;
+ if( pOrigRule )
+ aListArr[ n ].nListDocPos = aEntry.nListDocPos;
+ break;
+ }
+ aEntry.Clear();
+ pOrigRule = 0;
+ pRule = 0;
+ }
+ }
+ break;
+
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ // Unknown und alle bekannten nicht ausgewerteten Gruppen
+ // sofort ueberspringen
+ else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++nOpenBrakets;
+ }
+ break;
+
+ case RTF_LISTOVERRIDE: aEntry.Clear(); break;
+ case RTF_LISTID: aEntry.nListId = nTokenValue; break;
+ case RTF_LS: aEntry.nListNo = nTokenValue; break;
+ case RTF_LISTOVERRIDECOUNT:
+ if( nTokenValue )
+ {
+ pRule = 0;
+ // dann erzeugen wir mal schnell eine Kopie von der NumRule,
+ // denn diese wird jetzt mal kurz veraendert.
+ if( aEntry.nListId )
+ for( USHORT n = 0; n < aListArr.Count(); ++n )
+ if( aListArr[ n ].nListId == aEntry.nListId )
+ {
+ pRule = pDoc->GetNumRuleTbl()[
+ aListArr[ n ].nListDocPos ];
+ pOrigRule = pRule;
+
+ String sTmp( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( RTF_NUMRULE_NAME " 1" )));
+ aEntry.nListDocPos = pDoc->MakeNumRule( sTmp, pRule );
+ pRule = pDoc->GetNumRuleTbl()[ aEntry.nListDocPos ];
+ pRule->SetName( pDoc->GetUniqueNumRuleName( &sTmp, FALSE ) );
+ pRule->SetAutoRule( FALSE );
+ nNumLvl = (BYTE)-1;
+ aListArr.Insert( aEntry, aListArr.Count() );
+ break;
+ }
+
+ }
+ break;
+
+ case RTF_LISTLEVEL:
+ if( pRule && bOverrideFormat )
+ {
+ if( ++nNumLvl < MAXLEVEL )
+ pRule->Set( nNumLvl, pRule->Get( nNumLvl ));
+ ReadListLevel( *pRule, nNumLvl );
+ }
+ break;
+
+ case RTF_LEVELSTARTAT:
+ if( pRule && bOverrideStart )
+ {
+ }
+ break;
+
+ case RTF_LISTOVERRIDESTART:
+ bOverrideStart = TRUE;
+ break;
+
+ case RTF_LISTOVERRIDEFORMAT:
+ bOverrideFormat = TRUE;
+ break;
+
+ case RTF_LFOLEVEL:
+ // was fehlt noch?
+ break;
+ }
+ }
+
+ // search the outline numrule and set it into the doc
+ if( GetStyleTbl().Count() )
+ {
+ if( !bStyleTabValid )
+ MakeStyleTab();
+
+ const SfxPoolItem* pItem;
+ const SwTxtFmtColl* pColl;
+ SvxRTFStyleType* pStyle = GetStyleTbl().First();
+ do {
+ if( MAXLEVEL > pStyle->nOutlineNo &&
+ 0 != ( pColl = aTxtCollTbl.Get( (USHORT)GetStyleTbl().
+ GetCurKey() )) &&
+ SFX_ITEM_SET == pColl->GetItemState( RES_PARATR_NUMRULE,
+ FALSE, &pItem ))
+ {
+ USHORT nRulePos = pDoc->FindNumRule(
+ ((SwNumRuleItem*)pItem)->GetValue() );
+ if( USHRT_MAX != nRulePos )
+ {
+ const SwNumRule *pRule = pDoc->GetNumRuleTbl()[ nRulePos ];
+ pDoc->SetOutlineNumRule( *pRule );
+ pDoc->DelNumRule( pRule->GetName() );
+ // now pRule pointer is invalid !!!
+
+ // now decrement all position in the listtable, which will
+ // behind the doc-rule position
+ for( USHORT n = aListArr.Count(); n; )
+ {
+ SwListEntry& rEntry = aListArr[ --n ];
+ if( rEntry.nListDocPos == nRulePos )
+ aListArr.Remove( n );
+ else if( rEntry.nListDocPos > nRulePos )
+ --rEntry.nListDocPos;
+ }
+ break;
+ }
+ }
+
+ pStyle->aAttrSet.ClearItem( FN_PARAM_NUM_LEVEL );
+
+ } while( 0 != (pStyle = GetStyleTbl().Next()) );
+ }
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+}
+
+SwNumRule* SwRTFParser::GetNumRuleOfListNo( long nListNo, BOOL bRemoveFromList )
+{
+ SwNumRule* pRet = 0;
+ SwListEntry* pEntry;
+ for( USHORT n = aListArr.Count(); n; )
+ if( ( pEntry = &aListArr[ --n ])->nListNo == nListNo )
+ {
+ if( bRemoveFromList )
+ aListArr.Remove( n );
+ else
+ {
+ pEntry->bRuleUsed = TRUE;
+ pRet = pDoc->GetNumRuleTbl()[ pEntry->nListDocPos ];
+ }
+ break;
+ }
+ return pRet;
+}
+
+void SwRTFParser::RemoveUnusedNumRule( SwNumRule* pRule )
+{
+ if( pRule )
+ {
+ for ( BYTE nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
+ {
+ SwNumFmt& rNFmt = (SwNumFmt&)pRule->Get( nLvl );
+ SwCharFmt* pCFmt = rNFmt.GetCharFmt();
+ if( pCFmt )
+ {
+ pCFmt->Remove( &rNFmt );
+ if( !pCFmt->GetDepends() )
+ pDoc->DelCharFmt( pCFmt );
+ }
+ }
+ pDoc->DelNumRule( pRule->GetName() );
+ }
+#ifndef PRODUCT
+ else
+ {
+ ASSERT( pRule, "NumRulePointer 0 kann nicht geloescht werden" );
+ }
+#endif
+}
+
+void SwRTFParser::RemoveUnusedNumRules()
+{
+ SwListEntry* pEntry;
+ SvPtrarr aDelArr;
+ USHORT n;
+ for( n = aListArr.Count(); n; )
+ if( !( pEntry = &aListArr[ --n ])->bRuleUsed )
+ {
+ void * p = pDoc->GetNumRuleTbl()[pEntry->nListDocPos];
+ // dont delete named char formats
+ if( USHRT_MAX == aDelArr.GetPos( p ) &&
+ ((SwNumRule*)p)->GetName().EqualsAscii( RTF_NUMRULE_NAME, 0,
+ sizeof( RTF_NUMRULE_NAME )) )
+ aDelArr.Insert( p, aDelArr.Count() );
+ }
+
+ for( n = aDelArr.Count(); n; )
+ {
+ SwNumRule* pDel = (SwNumRule*)aDelArr[ --n ];
+ RemoveUnusedNumRule( pDel );
+ }
+}
+
+const Font* SwRTFParser::FindFontOfItem( const SvxFontItem& rItem ) const
+{
+ SvxRTFFontTbl& rFntTbl = ((SwRTFParser*)this)->GetFontTbl();
+ const Font* pFnt = rFntTbl.First();
+ while( pFnt )
+ {
+ if( pFnt->GetFamily() == rItem.GetFamily() &&
+ pFnt->GetName() == rItem.GetFamilyName() &&
+ pFnt->GetStyleName() == rItem.GetStyleName() &&
+ pFnt->GetPitch() == rItem.GetPitch() &&
+ pFnt->GetCharSet() == rItem.GetCharSet() )
+ return pFnt;
+
+ pFnt = rFntTbl.Next();
+ }
+ return 0;
+}
+
+
+void SwRTFParser::ReadNumSecLevel( int nToken )
+{
+ // lese die \pnseclvl - Gruppe
+ // nTokenValue gibt schon den richtigen Level vor 1 - 9!
+ BYTE nLevel = 0;
+ long nListNo = 0;
+ BOOL bContinus = TRUE;
+
+ if( RTF_PNSECLVL == nToken )
+ {
+ // suche die Rule - steht unter Nummer 3
+ nListNo = 3;
+ bContinus = FALSE;
+ nLevel = MAXLEVEL <= nTokenValue ? MAXLEVEL - 1
+ : BYTE( nTokenValue - 1 );
+ }
+ else
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case RTF_PNLVL: nListNo = 3;
+ bContinus = FALSE;
+ nLevel = MAXLEVEL <= nTokenValue
+ ? MAXLEVEL - 1
+ : BYTE( nTokenValue-1 );
+ break;
+
+ case RTF_PNLVLBODY: nListNo = 2; break;
+ case RTF_PNLVLBLT: nListNo = 1; break;
+ case RTF_PNLVLCONT: nListNo = 4; break;
+
+ default:
+ SkipGroup();
+ return ;
+ }
+ }
+
+ // suche die Rule - steht unter Nummer 3
+ USHORT nNewFlag = 1 << nListNo;
+ SwNumRule* pCurRule = GetNumRuleOfListNo( nListNo,
+ 0 != ( nNewNumSectDef & nNewFlag ) );
+ if( !pCurRule )
+ {
+ // dann muessen wir die mal anlegen
+ nNewNumSectDef &= ~nNewFlag;
+ String sTmp( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( RTF_NUMRULE_NAME " 1" )));
+ SwListEntry aEntry( nListNo, 0, pDoc->MakeNumRule( sTmp ));
+ aEntry.nListNo = nListNo;
+ aListArr.Insert( aEntry, aListArr.Count() );
+ pCurRule = pDoc->GetNumRuleTbl()[ aEntry.nListDocPos ];
+ pCurRule->SetName( pDoc->GetUniqueNumRuleName( &sTmp, FALSE ));
+ pCurRule->SetAutoRule( FALSE );
+ pCurRule->SetContinusNum( bContinus );
+ }
+
+ if( !pCurRule->GetNumFmt( nLevel ))
+ pCurRule->Set( nLevel, pCurRule->Get( nLevel ));
+ SwNumFmt* pCurNumFmt = (SwNumFmt*)pCurRule->GetNumFmt( nLevel );
+ if( RTF_PNLVLBLT == nToken )
+ pCurNumFmt->eType = SVX_NUM_CHAR_SPECIAL;
+ pCurNumFmt->SetPostfix( aEmptyStr );
+ pCurNumFmt->SetPrefix( aEmptyStr );
+ pCurNumFmt->eType = SVX_NUM_NUMBER_NONE;
+
+ if( bStyleTabValid && RTF_PNSECLVL != nToken )
+ {
+ // dann den akt. Lvl und Rule am Absatz setzen.
+ // Dieses muss aber in den vorherigen "Kontext", sprich in den vor
+ // der Klammer offenen Attrset. Darum das SetNewGroup davor und dahinter
+ SetNewGroup( FALSE );
+ GetAttrSet().Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, nLevel ));
+ GetAttrSet().Put( SwNumRuleItem( pCurRule->GetName() ));
+ SetNewGroup( TRUE );
+ }
+
+ FontUnderline eUnderline;
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+ while( nOpenBrakets && IsParserWorking() )
+ {
+ switch( ( nToken = GetNextToken() ))
+ {
+ case '}':
+ if( --nOpenBrakets && IsParserWorking() )
+ {
+ // Style konnte vollstaendig gelesen werden,
+ // also ist das noch ein stabiler Status
+ SaveState( RTF_PNSECLVL );
+ }
+ break;
+
+ case '{':
+ {
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nToken = SkipToken( -1 );
+ // Unknown und alle bekannten nicht ausgewerteten Gruppen
+ // sofort ueberspringen
+ else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ))
+ nToken = SkipToken( -2 );
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break;
+ }
+ ++nOpenBrakets;
+ }
+ break;
+
+ case RTF_PNCARD:
+ case RTF_PNORD:
+ case RTF_PNORDT:
+ case RTF_PNDEC: pCurNumFmt->eType = SVX_NUM_ARABIC; break;
+ case RTF_PNUCLTR: pCurNumFmt->eType = SVX_NUM_CHARS_UPPER_LETTER_N; break;
+ case RTF_PNUCRM: pCurNumFmt->eType = SVX_NUM_ROMAN_UPPER; break;
+ case RTF_PNLCLTR: pCurNumFmt->eType = SVX_NUM_CHARS_LOWER_LETTER_N; break;
+ case RTF_PNLCRM: pCurNumFmt->eType = SVX_NUM_ROMAN_LOWER; break;
+
+ case RTF_PNF:
+ {
+ const Font& rSVFont = GetFont( USHORT(nTokenValue) );
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
+ SvxFontItem( rSVFont.GetFamily(),
+ rSVFont.GetName(), rSVFont.GetStyleName(),
+ rSVFont.GetPitch(), rSVFont.GetCharSet() ));
+ if( SVX_NUM_CHAR_SPECIAL == pCurNumFmt->eType )
+ pCurNumFmt->SetBulletFont( &rSVFont );
+ }
+ break;
+ case RTF_PNFS:
+ {
+ if( -1 == nTokenValue )
+ nTokenValue = 240;
+ else
+ nTokenValue *= 10;
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
+ SvxFontHeightItem( (const USHORT)nTokenValue ));
+ }
+ break;
+
+ case RTF_PNB:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxWeightItem(
+ nTokenValue ? WEIGHT_BOLD : WEIGHT_NORMAL ));
+ }
+ break;
+
+ case RTF_PNI:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxPostureItem(
+ nTokenValue ? ITALIC_NORMAL : ITALIC_NONE ));
+ }
+ break;
+
+ case RTF_PNCAPS:
+ case RTF_PNSCAPS:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxCaseMapItem(
+ nTokenValue ? SVX_CASEMAP_KAPITAELCHEN
+ : SVX_CASEMAP_NOT_MAPPED ));
+ }
+ break;
+ case RTF_PNSTRIKE:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxCrossedOutItem(
+ nTokenValue ? STRIKEOUT_SINGLE : STRIKEOUT_NONE ));
+ }
+ break;
+
+ case RTF_PNCF:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put( SvxColorItem(
+ GetColor( USHORT(nTokenValue) ) ));
+ }
+ break;
+
+
+ case RTF_PNUL:
+ eUnderline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
+ goto NUMATTR_SETUNDERLINE;
+ case RTF_PNULD:
+ eUnderline = UNDERLINE_DOTTED;
+ goto NUMATTR_SETUNDERLINE;
+ case RTF_PNULDB:
+ eUnderline = UNDERLINE_DOUBLE;
+ goto NUMATTR_SETUNDERLINE;
+ case RTF_PNULNONE:
+ eUnderline = UNDERLINE_NONE;
+ goto NUMATTR_SETUNDERLINE;
+ case RTF_PNULW:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
+ SvxWordLineModeItem( TRUE ));
+ }
+ eUnderline = UNDERLINE_SINGLE;
+ goto NUMATTR_SETUNDERLINE;
+
+NUMATTR_SETUNDERLINE:
+ {
+ GetNumChrFmt( *pDoc, *pCurRule, nLevel ).Put(
+ SvxUnderlineItem( eUnderline ));
+ }
+ break;
+
+ case RTF_PNINDENT:
+ if( 0 > short( nTokenValue ) )
+ nTokenValue = - (short)nTokenValue;
+ pCurNumFmt->SetFirstLineOffset( - short( nTokenValue ));
+ pCurNumFmt->SetAbsLSpace( (nLevel + 1 ) * USHORT( nTokenValue ));
+ break;
+ case RTF_PNSP:
+ pCurNumFmt->SetCharTextOffset( USHORT( nTokenValue ));
+ break;
+
+ case RTF_PNPREV:
+ if( nLevel )
+ {
+ BYTE nPrev = 2, nLast = nLevel;
+ while( nLast && 1 < pCurRule->Get( --nLast ).GetUpperLevel() )
+ ++nPrev;
+ pCurNumFmt->SetUpperLevel( nPrev );
+ }
+ break;
+
+ case RTF_PNQC: pCurNumFmt->SetAdjust( SVX_ADJUST_CENTER ); break;
+ case RTF_PNQL: pCurNumFmt->SetAdjust( SVX_ADJUST_LEFT ); break;
+ case RTF_PNQR: pCurNumFmt->SetAdjust( SVX_ADJUST_RIGHT ); break;
+
+ case RTF_PNSTART:
+ pCurNumFmt->SetStartValue( USHORT( nTokenValue ));
+ break;
+
+ case RTF_PNNUMONCE:
+ case RTF_PNACROSS:
+ case RTF_PNHANG:
+ case RTF_PNRESTART: break;
+
+ case RTF_PNTXTA:
+ {
+ String sTmp;
+ GetTextToEndGroup( sTmp );
+ if( SVX_NUM_CHAR_SPECIAL == pCurNumFmt->eType )
+ {
+ pCurNumFmt->SetBulletChar( sTmp.GetChar( 0 ) );
+ if( pCurNumFmt->GetCharFmt() )
+ pCurNumFmt->SetBulletFont( FindFontOfItem(
+ pCurNumFmt->GetCharFmt()->GetFont() ) );
+ sTmp.Erase();
+ }
+ pCurNumFmt->SetPostfix( sTmp );
+ }
+ break;
+
+ case RTF_PNTXTB:
+ {
+ String sTmp;
+ pCurNumFmt->SetPrefix( GetTextToEndGroup( sTmp ) );
+ }
+ break;
+ }
+ }
+
+ // falls vollstaendige Numerierung an ist und das Zeichen davor ein
+ // Punkt ist, dann will RTF den Punkt als Trenner zwischen den Ebenen
+ // haben - das haben wir aber schon als default
+ if( 1 < pCurNumFmt->GetUpperLevel() &&
+ 1 == pCurNumFmt->GetPrefix().Len() &&
+ '.' == pCurNumFmt->GetPrefix().GetChar( 0 ) &&
+ SVX_NUM_CHAR_SPECIAL != pCurNumFmt->eType )
+ pCurNumFmt->SetPrefix( aEmptyStr );
+
+ // falls das ein nicht numerierter Absatz mit ein Prefix-Text mit
+ // einem Zeichen ist, dann setze den als Bulletzeichen
+ if( pCurNumFmt->GetCharFmt() && SVX_NUM_NUMBER_NONE == pCurNumFmt->eType &&
+ 3 == nListNo && 1 == pCurNumFmt->GetPrefix().Len() )
+ {
+ SwCharFmt* pChFmt = pCurNumFmt->GetCharFmt();
+ pCurNumFmt->eType = SVX_NUM_CHAR_SPECIAL;
+ pCurNumFmt->SetBulletFont( FindFontOfItem( pChFmt->GetFont() ) );
+
+ pCurNumFmt->SetBulletChar( pCurNumFmt->GetPrefix().GetChar( 0 ) );
+ pCurNumFmt->SetPrefix( aEmptyStr );
+
+ // den Font oder sogar das gesamte CharFormat loeschen?
+ if( SFX_ITEM_SET == pChFmt->GetItemState( RES_CHRATR_FONT, FALSE ))
+ {
+ if( 1 == pChFmt->GetAttrSet().Count() )
+ {
+ pCurNumFmt->SetCharFmt( 0 );
+ pDoc->DelCharFmt( pChFmt );
+ }
+ else
+ pChFmt->ResetAttr( RES_CHRATR_FONT );
+ }
+ }
+
+ SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet
+}
+
+
+/* */
+
+// dann noch die Ausgabe-Funktionen (nur fuer WinWord 97)
+
+void SwRTFWriter::OutRTFListTab()
+{
+ ByteString sOverrideList;
+ const SwNumRuleTbl& rListTbl = pDoc->GetNumRuleTbl();
+ USHORT nId = 1, nTmplId = 1, n;
+
+ // prepare the NodeNum to generate the NumString
+ SwNodeNum aNdNum( 0 );
+ for( n = 0; n < MAXLEVEL; ++n )
+ aNdNum.GetLevelVal()[ n ] = n;
+ BYTE aNumLvlPos[ MAXLEVEL ];
+
+ for( n = rListTbl.Count()+1; n; )
+ {
+ const SwNumRule* pRule;
+ --n;
+ if( n == rListTbl.Count() )
+ pRule = pDoc->GetOutlineNumRule();
+ else
+ {
+ pRule = rListTbl[ n ];
+ if( !pDoc->IsUsed( *pRule ))
+ continue;
+ }
+
+ BYTE nEnd = MAXLEVEL;
+ while( nEnd-- && !pRule->GetNumFmt( nEnd ))
+ ;
+ ++nEnd;
+
+ for( BYTE nLvl = 0; nLvl < nEnd; ++nLvl )
+ if( SVX_NUM_NUMBER_NONE != pRule->Get( nLvl ).eType )
+ break;
+
+ if( nLvl == nEnd ) // alle Level no number -> dont write it
+ continue;
+
+ // mit der ersten Rule wird auch die ListTable geschrieben
+ if( !sOverrideList.Len() )
+ OutComment( *this, sRTF_LISTTABLE );
+
+ Strm() << '{' << sRTF_LIST << sRTF_LISTTEMPLATEID;
+ OutULong( nTmplId );
+ ByteString sTmp;
+
+ if( pRule->IsContinusNum() )
+ Strm() << sRTF_LISTSIMPLE;
+
+ for( nLvl = 0; nLvl < nEnd; ++nLvl )
+ {
+ const SwNumFmt& rFmt = pRule->Get( nLvl );
+ Strm() << sNewLine;
+ if( nLvl > 8 ) // RTF-kennt nur 9 Ebenen
+ OutComment( *this, sRTF_SOUTLVL );
+
+ Strm() << '{' << sRTF_LISTLEVEL << sRTF_LEVELNFC;
+
+ USHORT nVal = 0;
+ switch( rFmt.eType )
+ {
+ case SVX_NUM_ROMAN_UPPER: nVal = 1; break;
+ case SVX_NUM_ROMAN_LOWER: nVal = 2; break;
+ case SVX_NUM_CHARS_UPPER_LETTER:
+ case SVX_NUM_CHARS_UPPER_LETTER_N: nVal = 3; break;
+ case SVX_NUM_CHARS_LOWER_LETTER:
+ case SVX_NUM_CHARS_LOWER_LETTER_N: nVal = 4; break;
+
+ case SVX_NUM_BITMAP:
+ case SVX_NUM_CHAR_SPECIAL: nVal = 23; break;
+ }
+ OutLong( nVal ) << sRTF_LEVELJC;
+
+ switch( rFmt.GetAdjust() )
+ {
+ case SVX_ADJUST_CENTER: nVal = 1; break;
+ case SVX_ADJUST_RIGHT: nVal = 2; break;
+ default: nVal = 0; break;
+ }
+ OutLong( nVal ) << sRTF_LEVELSTARTAT;
+ OutLong( rFmt.GetStartValue() )
+ << sRTF_LEVELFOLLOW << "2{" << sRTF_LEVELTEXT << ' ';
+
+ BOOL bWriteBulletFont = FALSE;
+ memset( aNumLvlPos, 0, MAXLEVEL );
+ if( SVX_NUM_CHAR_SPECIAL == rFmt.eType ||
+ SVX_NUM_BITMAP == rFmt.eType )
+ {
+ Strm() << "\\'01\\'"; OutHex( rFmt.GetBulletChar() );
+ bWriteBulletFont = TRUE;
+ }
+ else if( SVX_NUM_NUMBER_NONE != rFmt.eType )
+ {
+ memset( aNumLvlPos, 0, MAXLEVEL );
+ BYTE* pLvlPos = aNumLvlPos;
+ aNdNum.SetLevel( nLvl );
+ String sNumStr( pRule->MakeNumString( aNdNum, FALSE, TRUE ));
+
+ // now search the nums in the string
+ for( BYTE i = 0; i <= nLvl; ++i )
+ {
+ String sSrch( String::CreateFromInt32( i ));
+ xub_StrLen nFnd = sNumStr.Search( sSrch );
+ if( STRING_NOTFOUND != nFnd )
+ {
+ *pLvlPos = (BYTE)(nFnd + rFmt.GetPrefix().Len() + 1 );
+ ++pLvlPos;
+ sNumStr.SetChar( nFnd, (sal_Unicode)i );
+ }
+ }
+
+ Strm() << "\\'";
+ OutHex( sNumStr.Len() + rFmt.GetPrefix().Len() +
+ rFmt.GetPostfix().Len() );
+
+ if( rFmt.GetPrefix().Len() )
+ RTFOutFuncs::Out_String( Strm(), rFmt.GetPrefix(),
+ DEF_ENCODING, bWriteHelpFmt );
+
+
+ for( xub_StrLen x = 0; x < sNumStr.Len(); ++x )
+ if( sNumStr.GetChar( x ) < 0x20 ||
+ sNumStr.GetChar( x ) > 0xFF )
+ {
+ Strm() << "\\'"; OutHex( sNumStr.GetChar( x ) );
+ }
+ else
+ Strm() << (sal_Char)sNumStr.GetChar( x );
+
+ if( rFmt.GetPostfix().Len() )
+ RTFOutFuncs::Out_String( Strm(), rFmt.GetPostfix(),
+ DEF_ENCODING, bWriteHelpFmt );
+ }
+
+ // write the levelnumbers
+ Strm() << ";}{" << sRTF_LEVELNUMBERS;
+ for( BYTE i = 0; i <= nLvl && aNumLvlPos[ i ]; ++i )
+ {
+ Strm() << "\\'"; OutHex( aNumLvlPos[ i ] );
+ }
+ Strm() << ";}";
+
+ if( rFmt.GetCharFmt() )
+ Out_SfxItemSet( aRTFAttrFnTab, *this,
+ rFmt.GetCharFmt()->GetAttrSet(), TRUE );
+
+ if( bWriteBulletFont )
+ {
+ Strm() << sRTF_F;
+ const Font* pFont = rFmt.GetBulletFont();
+ if( !pFont )
+ pFont = &SwNumRule::GetDefBulletFont();
+ OutULong( GetId( *pFont ));
+ }
+
+ Strm() << sRTF_FI;
+ OutLong( rFmt.GetFirstLineOffset() ) << sRTF_LI;
+ OutLong( rFmt.GetAbsLSpace() );
+
+ Strm() << '}';
+
+ if( nLvl > 8 ) // RTF-kennt nur 9 Ebenen
+ Strm() << '}';
+ }
+
+ if( !pRule->IsAutoRule() )
+ {
+ Strm() << '{' << sRTF_LISTNAME << ' ';
+ RTFOutFuncs::Out_String( Strm(), pRule->GetName(), DEF_ENCODING,
+ bWriteHelpFmt ) << ";}" ;
+ }
+ Strm() << sRTF_LISTID;
+ OutULong( nId ) << '}' << sNewLine;
+
+ sTmp = '{';
+ ((((((( sTmp += sRTF_LISTOVERRIDE ) +=
+ sRTF_LISTID ) += ByteString::CreateFromInt32( nId )) +=
+ sRTF_LISTOVERRIDECOUNT ) += '0' ) +=
+ sRTF_LS ) += ByteString::CreateFromInt32( n )) += '}';
+ sOverrideList += sTmp;
+
+ ++nId, ++nTmplId;
+ }
+
+ if( sOverrideList.Len() )
+ Strm() << "}{" << sRTF_LISTOVERRIDETABLE
+ << sOverrideList.GetBuffer() << '}' << sNewLine;
+}
+
+USHORT SwRTFWriter::GetId( const SwNumRuleItem& rItem ) const
+{
+ return pDoc->FindNumRule( rItem.GetValue() );
+}
+
+void SwRTFWriter::OutListNum( const SwTxtNode& rNd )
+{
+ const SwNumRule* pRule = rNd.GetNumRule();
+ const SwNodeNum* pNdNum = 0;
+ // or is an outlinerule valid?
+ if( pRule )
+ pNdNum = rNd.GetNum();
+ else if( MAXLEVEL > rNd.GetTxtColl()->GetOutlineLevel() &&
+ 0 != ( pNdNum = rNd.GetOutlineNum() ) )
+ pRule = pDoc->GetOutlineNumRule();
+
+ if( pRule && pNdNum && MAXLEVEL > pNdNum->GetLevel() )
+ {
+ bOutFmtAttr = FALSE;
+ bOutListNumTxt = TRUE;
+
+ BOOL bValidNum = MAXLEVEL > pNdNum->GetLevel();
+ BYTE nLvl = GetRealLevel( pNdNum->GetLevel() );
+ const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
+ if( !pFmt )
+ pFmt = &pRule->Get( nLvl );
+
+ const SfxItemSet& rNdSet = rNd.GetSwAttrSet();
+
+ SfxItemSet aSet( *rNdSet.GetPool(), rNdSet.GetRanges() );
+ aSet.SetParent( &rNdSet );
+ SvxLRSpaceItem aLR( (SvxLRSpaceItem&)rNdSet.Get( RES_LR_SPACE ) );
+ aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetAbsLSpace() );
+
+ if( bValidNum )
+ {
+ aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
+ Strm() << '{' << sRTF_LISTTEXT << sRTF_PARD << sRTF_PLAIN << ' ';
+ }
+ aSet.Put( aLR );
+ Out_SfxItemSet( aRTFAttrFnTab, *this, aSet, TRUE );
+
+ if( pFmt->GetCharFmt() )
+ Out_SfxItemSet( aRTFAttrFnTab, *this,
+ pFmt->GetCharFmt()->GetAttrSet(), TRUE );
+
+ if( bValidNum )
+ {
+ String sTxt;
+ if( SVX_NUM_CHAR_SPECIAL == pFmt->eType || SVX_NUM_BITMAP == pFmt->eType )
+ sTxt = pFmt->GetBulletChar();
+ else
+ sTxt = pRule->MakeNumString( *pNdNum );
+
+ if( bOutFmtAttr )
+ {
+ Strm() << ' ';
+ bOutFmtAttr = FALSE;
+ }
+
+ RTFOutFuncs::Out_String( Strm(), sTxt, DEF_ENCODING, bWriteHelpFmt);
+
+ if( OUTLINE_RULE != pRule->GetRuleType() )
+ {
+ Strm() /*<< sRTF_TAB*/ << '}' << sRTF_ILVL;
+ if( nLvl > 8 ) // RTF-kennt nur 9 Ebenen
+ {
+ OutULong( 8 );
+ OutComment( *this, sRTF_SOUTLVL );
+ OutULong( nLvl ) << '}';
+ }
+ else
+ OutULong( nLvl );
+ Strm() << ' ';
+ }
+ else
+ Strm() /*<< sRTF_TAB*/ << '}';
+ }
+ bOutListNumTxt = FALSE;
+ }
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/rtf/rtfnum.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.27 2000/09/18 16:04:51 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.26 2000/08/04 10:48:09 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character; use rtfout functions
+
+ Revision 1.25 2000/05/26 07:22:44 os
+ old SW Basic API Slots removed
+
+ Revision 1.24 2000/05/24 07:57:04 jp
+ Bugfixes for Unicode
+
+ Revision 1.23 2000/05/09 17:22:53 jp
+ Changes for Unicode
+
+ Revision 1.22 2000/03/14 17:25:25 jp
+ Bug #73968#: read and set outline/num-levels
+
+ Revision 1.21 2000/03/14 09:22:24 jp
+ Bug #73941#: remove unused numrules, share override rules
+
+ Revision 1.20 2000/03/10 17:54:09 jp
+ Bug #73965#: ReadListLevel - set no number
+
+ Revision 1.19 2000/03/10 15:56:52 jp
+ Bug #74100#: read W2000 rtf-format
+
+ Revision 1.18 2000/02/24 18:33:17 jp
+ Bug #73098#: read & write list entries without number
+
+ Revision 1.17 2000/02/17 13:46:55 jp
+ Bug #73098#: Import / Export problems
+
+ Revision 1.16 2000/02/11 14:38:01 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.15 2000/01/25 20:13:02 jp
+ Bug #72146#: read UniCode character
+
+ Revision 1.14 1999/08/03 17:47:38 JP
+ Bug #67975#: changes for import of Bulltets from interleave/WP7/Aplixware
+
+
+ Rev 1.13 03 Aug 1999 19:47:38 JP
+ Bug #67975#: changes for import of Bulltets from interleave/WP7/Aplixware
+
+ Rev 1.12 12 Jul 1999 17:35:24 JP
+ read and write outlinelevel/-numrules
+
+ Rev 1.11 30 Mar 1999 14:41:48 JP
+ Task #63049#: Numerierung mit rel. Einzuegen
+
+ Rev 1.10 29 Mar 1999 10:00:32 JP
+ Bug #63990#: NumRules immer mit negativen Erstzeileneinzug
+
+ Rev 1.9 18 Mar 1999 09:51:44 JP
+ Task #63049#: Numerierung mit rel. Einzuegen
+
+ Rev 1.8 16 Mar 1999 23:19:34 JP
+ Task #63049#: Einzuege bei NumRules relativ
+
+ Rev 1.7 05 Mar 1999 14:27:56 JP
+ Bug #57749#: spaltige Bereiche einlesen - jeder Bereich hat eigene NumRules
+
+ Rev 1.6 03 Mar 1999 15:17:22 JP
+ Bug #57749#: spaltige Bereiche einlesen
+
+ Rev 1.5 17 Nov 1998 10:45:30 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.4 21 Sep 1998 17:15:12 JP
+ RTF_LEVELNFC: 255 ist auch ein Bullet
+
+ Rev 1.3 06 Aug 1998 21:43:30 JP
+ Bug #54796#: neue NumerierungsTypen (WW97 kompatibel)
+
+ Rev 1.2 04 Jun 1998 19:28:06 JP
+ Bug #50887#: Font bei Grafik-NumFormaten ist 0, also default Font schreiben
+
+ Rev 1.1 27 May 1998 22:26:14 JP
+ Bug #50585#: ListOverrideTabelle korrekt einlesen
+
+ Rev 1.0 20 Apr 1998 17:44:00 JP
+ neu: Numerierung lesen/schreiben
+
+*************************************************************************/
+
diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx
new file mode 100644
index 000000000000..11da00dbd3b9
--- /dev/null
+++ b/sw/source/filter/rtf/rtftbl.cxx
@@ -0,0 +1,978 @@
+/*************************************************************************
+ *
+ * $RCSfile: rtftbl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#ifdef WTC
+#define private public
+#endif
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SVX_BRKITEM_HXX
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen wg. SvxLRSpaceItem
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _RTFTOKEN_H
+#include <svtools/rtftoken.h>
+#endif
+
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _SWPARRTF_HXX
+#include <swparrtf.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _TBLSEL_HXX
+#include <tblsel.hxx>
+#endif
+#ifndef _SWTBLFMT_HXX
+#include <swtblfmt.hxx>
+#endif
+#ifndef _TBLENUM_HXX
+#include <tblenum.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+
+typedef SwTableBoxFmt* SwTableBoxFmtPtr;
+SV_DECL_PTRARR( SwBoxFrmFmts, SwTableBoxFmtPtr, 25, 50 )
+
+class SwShareBoxFmts;
+extern void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* = 0,
+ BOOL = TRUE, const BOOL = TRUE, SwShareBoxFmts* = 0 );
+
+void SwRTFParser::ReadTable( int nToken )
+{
+ nInsTblRow = USHRT_MAX;
+ if( bReadNoTbl )
+ {
+ // alle Tabellen-Tokens ueberlesen
+ nToken = GetNextToken(); // RTF_TROWD ueberlesen
+ do {
+ if( RTF_TABLEDEF != (nToken & ~(0xff | RTF_SWGDEFS)) &&
+ RTF_UNKNOWNCONTROL != nToken )
+ {
+ SkipToken( -1 );
+ break;
+ }
+ nToken = GetNextToken();
+ } while( IsParserWorking() );
+ return ;
+ }
+
+ // verhinder Tabelle in Tabelle/Footnote
+ SwTwips nTblSz = 0;
+ int bReadNewCell = FALSE, bChkExistTbl = FALSE;
+
+ // kein TROWD aber ein TabellenToken -> zwischen TROWD und Tab.Token
+ // waren andere Zeichen (siehe Bug 27445.rtf)
+ if( RTF_TROWD == nToken || !pTableNode )
+ {
+ if( RTF_TROWD == nToken )
+ nToken = GetNextToken(); // RTF_TROWD ueberlesen
+
+ // Flags fuer die gemergten Boxen loeschen
+ aMergeBoxes.Remove( 0, aMergeBoxes.Count() );
+ aMergeBoxes.Insert( (BOOL)FALSE, USHORT(0) );
+ nAktBox = 0;
+
+ // wenn schon in einer Tabellen, dann splitte oder benutze
+ // die bisherigen Boxen weiter
+ bChkExistTbl = 0 != pDoc->GetNodes()[ pPam->GetPoint()->nNode ]->FindTableNode();
+ }
+ else
+ {
+ bReadNewCell = TRUE;
+ SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
+ SwTableLine* pLine = rLns[ rLns.Count()-1 ];
+ for( USHORT n = nAktBox; n; )
+ nTblSz += pLine->GetTabBoxes()[ --n ]->GetFrmFmt()->
+ GetFrmSize().GetWidth();
+ }
+
+
+ SwHoriOrient eAdjust = HORI_LEFT; // default fuer Tabellen
+ USHORT nLSpace = 0, nBrdDist = MIN_BORDER_DIST;
+ SwVertOrient eVerOrient = VERT_NONE;
+ long nLineHeight = 0;
+ USHORT nBoxCnt = aMergeBoxes.Count()-1;
+ SwBoxFrmFmts aBoxFmts;
+ SwTableBoxFmt* pBoxFmt = pDoc->MakeTableBoxFmt();
+ BOOL bHeadlineRepeat = FALSE;
+
+#ifdef SET_TRGAPH
+ SvxLRSpaceItem aLR;
+#endif
+
+ int bWeiter = TRUE;
+ do {
+ switch( nToken )
+ {
+ case RTF_TRRH:
+ nLineHeight = nTokenValue;
+ break;
+
+ case RTF_CLMRG:
+ aMergeBoxes[ nBoxCnt ] = TRUE;
+ break;
+
+ case RTF_CELLX:
+ {
+ SwTableBoxFmt* pFmt = pBoxFmt;
+ SwTwips nSize = nTokenValue - nTblSz;
+ if( aMergeBoxes[ nBoxCnt ] )
+ {
+ // neue Zellen lesen und noch keine Formate vorhanden,
+ // dann benutze das der vorhergebende
+ if( bReadNewCell && !aBoxFmts.Count() )
+ {
+ SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
+ SwTableLine* pLine = rLns[ rLns.Count()-1 ];
+ --nAktBox;
+ pFmt = (SwTableBoxFmt*)pLine->GetTabBoxes()[ nAktBox ]->GetFrmFmt();
+ }
+ else
+ pFmt = aBoxFmts[ aBoxFmts.Count()-1 ];
+
+ pBoxFmt->ResetAllAttr();
+ nSize += pFmt->GetFrmSize().GetWidth();
+ }
+ else
+ {
+ // Platz zwischen den Spalten angeben und ist
+ // diese auch kleiner als die Breite der Box
+#ifdef SET_TRGAPH
+ if( aLR.GetLeft() && 2L * aLR.GetLeft() < nSize )
+ pBoxFmt->SetAttr( aLR );
+ aLR.SetLeft( 0 ); aLR.SetRight( 0 );
+#endif
+ aBoxFmts.Insert( pBoxFmt, aBoxFmts.Count() );
+ pBoxFmt = pDoc->MakeTableBoxFmt();
+ }
+
+ pFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nSize, 0 ));
+ nTblSz = nTokenValue;
+ aMergeBoxes.Insert( (BOOL)FALSE, ++nBoxCnt );
+ }
+ break;
+
+ case RTF_TRGAPH:
+ {
+ nBrdDist = (USHORT)nTokenValue;
+#ifdef SET_TRGAPH
+ aLR.SetLeft( USHORT( nTokenValue ));
+ aLR.SetRight( USHORT( nTokenValue ));
+#endif
+ }
+ break;
+
+ case RTF_TRQL: eAdjust = HORI_LEFT; break;
+ case RTF_TRQR: eAdjust = HORI_RIGHT; break;
+ case RTF_TRQC: eAdjust = HORI_CENTER; break;
+
+ // mit VERT_TOP kommt der Dialog nicht klar!
+ // Bug #65126#
+ case RTF_CLVERTALT: eVerOrient = VERT_NONE; break;
+
+ case RTF_CLVERTALC: eVerOrient = VERT_CENTER; break;
+ case RTF_CLVERTALB: eVerOrient = VERT_BOTTOM; break;
+
+ case RTF_TRLEFT:
+ if( 0 <= nTokenValue )
+ {
+ if( HORI_LEFT == eAdjust )
+ eAdjust = HORI_LEFT_AND_WIDTH;
+ nLSpace = (USHORT)nTokenValue;
+ }
+ nTblSz = nTokenValue;
+ break;
+
+ case RTF_TRHDR:
+ bHeadlineRepeat = TRUE;
+ break;
+
+ case RTF_CLTXLRTB:
+ case RTF_CLTXTBRL:
+ case RTF_INTBL: // das wissen wir !
+ case RTF_CLMGF:
+ case RTF_CLVMGF:
+ case RTF_CLVMRG:
+ case RTF_LTRROW:
+ case RTF_RTLROW:
+ case RTF_TRBRDRB:
+ case RTF_TRBRDRH:
+ case RTF_TRBRDRL:
+ case RTF_TRBRDRR:
+ case RTF_TRBRDRT:
+ case RTF_TRBRDRV:
+ case RTF_TRKEEP:
+ break;
+
+ default:
+ if( ( nToken & ~(0xff | RTF_TABLEDEF)) == RTF_SHADINGDEF )
+ {
+ if( aMergeBoxes[ nBoxCnt ] )
+ break;
+ ReadBackgroundAttr( nToken,
+ (SfxItemSet&)pBoxFmt->GetAttrSet(), TRUE );
+ }
+ else if( ( nToken & ~(0xff | RTF_TABLEDEF) ) == RTF_BRDRDEF )
+ {
+ if( aMergeBoxes[ nBoxCnt ] )
+ break;
+
+ const SfxPoolItem* pItem;
+ SfxItemSet& rSet = (SfxItemSet&)pBoxFmt->GetAttrSet();
+ ReadBorderAttr( nToken, rSet, TRUE );
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, FALSE, &pItem ))
+ {
+ SvxBoxItem aBox( *(SvxBoxItem*)pItem );
+ BOOL bChg = FALSE;
+ for ( int nLn = 0; nLn < 4; ++nLn )
+ if( aBox.GetLine( nLn ) && !aBox.GetDistance( nLn ) )
+ {
+ aBox.SetDistance( 2 > nLn ? 18 : nBrdDist, nLn );
+ bChg = TRUE;
+ }
+ if( bChg )
+ rSet.Put( aBox );
+ }
+ }
+ else if( RTF_TABLEDEF != (nToken & ~(0xff | RTF_SWGDEFS)) )
+ {
+ if( RTF_UNKNOWNCONTROL == nToken )
+ NextToken( nToken );
+ else
+ bWeiter = FALSE;
+ }
+ break;
+ }
+
+ if( VERT_NONE != eVerOrient )
+ {
+ if( !aMergeBoxes[ nBoxCnt ] )
+ pBoxFmt->SetAttr( SwFmtVertOrient( 0, eVerOrient ));
+ eVerOrient = VERT_NONE;
+ }
+ if( bWeiter )
+ nToken = GetNextToken();
+ } while( bWeiter && IsParserWorking() );
+
+ // das letzte temp. BoxFmt loeschen
+ delete pBoxFmt;
+
+ // es wurde keine einzige Box erkannt
+ if( nAktBox == nBoxCnt || ( bReadNewCell && !pTableNode ))
+ {
+ SkipToken( -1 ); // zum Letzen gueltigen zurueck
+ return;
+ }
+
+ nTblSz -= nLSpace;
+
+ int bNewTbl = TRUE;
+ SwTableLine* pNewLine;
+
+ // lege eine neue Tabelle an oder erweiter die aktuelle um eine neue Line
+ // oder Box !
+ SwNode* pNd;
+
+ if( bChkExistTbl )
+ {
+ // es ist eine Tabelle vorhanden, teste mal ob die weiter benutzt
+ // werden kann oder ob sie abgesplittet und neu gefuellt werden
+ // muss.
+ pTableNode = pPam->GetNode()->FindTableNode();
+
+ // Cursor kann nur in der letzten Line stehen
+
+ // das Attribut darf nicht ueber das Modify an der
+ // Tabelle gesetzt werden, denn sonst werden alle
+ // Boxen wieder auf 0 zurueck gesetzt !!!!!
+ SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
+ const SwFmtFrmSize& rTblSz = pFmt->GetFrmSize();
+ const SwFmtHoriOrient& rHoriz = pFmt->GetHoriOrient();
+
+ const SwTableLines* pLns = &pTableNode->GetTable().GetTabLines();
+
+ if( 1 == pLns->Count() )
+ {
+ if( eAdjust != rHoriz.GetHoriOrient() )
+ {
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( SwFmtHoriOrient( 0,
+ eAdjust ) );
+ }
+ if( rTblSz.GetWidth() != nTblSz )
+ {
+ SwFmtFrmSize aSz( rTblSz );
+ aSz.SetWidth( nTblSz );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
+ }
+
+ if( HORI_LEFT_AND_WIDTH == eAdjust &&
+ nLSpace != pFmt->GetLRSpace().GetLeft() )
+ {
+ SvxLRSpaceItem aL; aL.SetLeft( nLSpace );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aL );
+ }
+ }
+ else if( 1 < pLns->Count() && ( rTblSz.GetWidth() != nTblSz
+ || rHoriz.GetHoriOrient() != eAdjust ||
+ ( HORI_LEFT_AND_WIDTH == eAdjust &&
+ nLSpace != pFmt->GetLRSpace().GetLeft() ) ||
+ bHeadlineRepeat != pTableNode->GetTable().IsHeadlineRepeat() ))
+ {
+ // Tabelle ab der PaM-Position splitten
+ pNewLine = (*pLns)[ pLns->Count() - 2 ]; // die vorherige Line!
+ SwTableBox* pBox = pNewLine->GetTabBoxes()[ 0 ];
+ while( ( pLns = &pBox->GetTabLines() )->Count() )
+ pBox = (*pLns)[ 0 ]->GetTabBoxes()[ 0 ];
+
+ SwNodeIndex aTmpIdx( *pBox->GetSttNd() );
+ pDoc->GetNodes().SplitTable( aTmpIdx, HEADLINE_NONE, FALSE );
+ pTableNode = pPam->GetNode()->FindTableNode();
+ pFmt = pTableNode->GetTable().GetFrmFmt();
+
+ SwFmtFrmSize aSz( rTblSz );
+ aSz.SetWidth( nTblSz );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( SwFmtHoriOrient( 0,
+ eAdjust ) );
+ if( HORI_LEFT_AND_WIDTH == eAdjust && nLSpace )
+ {
+ SvxLRSpaceItem aL; aL.SetLeft( nLSpace );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aL );
+ }
+ pTableNode->GetTable().SetHeadlineRepeat( bHeadlineRepeat );
+ }
+
+ pLns = &pTableNode->GetTable().GetTabLines();
+ pNewLine = (*pLns)[ pLns->Count() - 1 ];
+
+ // jetzt die Boxen abgleichen
+ USHORT nBoxes = Min( pNewLine->GetTabBoxes().Count(), aBoxFmts.Count() );
+ for( USHORT n = 0; n < nBoxes; ++n )
+ {
+ SwTableBox* pBox = pNewLine->GetTabBoxes()[ n ];
+ *pBox->GetFrmFmt() = *aBoxFmts[ n ];
+ delete aBoxFmts[ n ];
+ }
+ aBoxFmts.Remove( 0, n );
+
+ if( aBoxFmts.Count() ) // es muessen noch neue zugefuegt werden
+ nAktBox = n;
+ else // es mussen noch Boxen geloescht werden
+ {
+ // remove ContentIndex of other Bound
+ pPam->SetMark(); pPam->DeleteMark();
+ while( n < pNewLine->GetTabBoxes().Count() )
+ _DeleteBox( pTableNode->GetTable(),
+ pNewLine->GetTabBoxes()[ n ], 0, FALSE, FALSE );
+ }
+
+ pOldTblNd = pTableNode;
+ bNewTbl = FALSE;
+
+ {
+ // JP 13.08.98: TabellenUmrandungen optimieren - Bug 53525
+ void* p = pFmt;
+ aTblFmts.Insert( p, aTblFmts.Count() );
+ }
+ }
+ else
+ {
+ if( !bReadNewCell && ( pNd = pDoc->GetNodes()[
+ pPam->GetPoint()->nNode.GetIndex()-1 ])->IsEndNode() )
+ {
+ pTableNode = pNd->StartOfSectionNode()->GetTableNode();
+ if( pTableNode )
+ {
+ // dann test mal ob wirklich nur eine neue Line eingefuegt
+ // werden soll!
+ SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
+ const SwFmtFrmSize& rTblSz = pFmt->GetFrmSize();
+ const SwFmtHoriOrient& rHoriz = pFmt->GetHoriOrient();
+ if( rTblSz.GetWidth() != nTblSz
+ || rHoriz.GetHoriOrient() != eAdjust )
+ pTableNode = 0;
+ }
+ }
+
+ if( pTableNode )
+ {
+
+ // das Attribut darf nicht ueber das Modify an der
+ // Tabelle gesetzt werden, denn sonst werden alle
+ // Boxen wieder auf 0 zurueck gesetzt !!!!!
+ SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
+ const SwFmtFrmSize& rTblSz = pFmt->GetFrmSize();
+ if( rTblSz.GetWidth() < nTblSz )
+ {
+ SwFmtFrmSize aSz( rTblSz );
+ aSz.SetWidth( nTblSz );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
+ }
+
+ SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
+
+ if( bReadNewCell )
+ pNewLine = rLns[ rLns.Count()-1 ];
+ else
+ {
+ pNewLine = new SwTableLine(
+ (SwTableLineFmt*)rLns[ rLns.Count()-1 ]->GetFrmFmt(),
+ aBoxFmts.Count(), 0 );
+ pNewLine->ClaimFrmFmt();
+ pNewLine->GetFrmFmt()->ResetAttr( RES_FRM_SIZE );
+ rLns.C40_INSERT( SwTableLine, pNewLine, rLns.Count() );
+ }
+ bNewTbl = FALSE;
+ }
+ else
+ {
+ if( pPam->GetPoint()->nContent.GetIndex() )
+ InsertPara();
+
+ pDoc->InsertTable( *pPam->GetPoint(), 1, 1, eAdjust );
+ pTableNode = pDoc->GetNodes()[ pPam->GetPoint()->nNode.
+ GetIndex() - 5 ]->GetTableNode();
+ ASSERT( pTableNode, "Wo ist mein TabellenNode?" );
+
+ SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
+ pNewLine = rLns[ rLns.Count()-1 ];
+
+ SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
+ SwFmtFrmSize aSz( pFmt->GetFrmSize() );
+ aSz.SetWidth( nTblSz );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aSz );
+
+ if( HORI_LEFT_AND_WIDTH == eAdjust && nLSpace )
+ {
+ SvxLRSpaceItem aL; aL.SetLeft( nLSpace );
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( aL );
+ }
+ pTableNode->GetTable().SetHeadlineRepeat( bHeadlineRepeat );
+
+ nAktBox = 0;
+ pOldTblNd = pTableNode;
+
+ {
+ // JP 13.08.98: TabellenUmrandungen optimieren - Bug 53525
+ void* p = pFmt;
+ aTblFmts.Insert( p, aTblFmts.Count() );
+ }
+ }
+ }
+
+ if( nLineHeight )
+ {
+ SwFrmSize eSize;
+ if( 0 > nLineHeight )
+ eSize = ATT_FIX_SIZE, nLineHeight = -nLineHeight;
+ else
+ eSize = ATT_MIN_SIZE;
+ pNewLine->ClaimFrmFmt()->SetAttr( SwFmtFrmSize( eSize, 0, nLineHeight ));
+ }
+
+ if( aBoxFmts.Count() )
+ {
+ // setze das default Style
+ SwTxtFmtColl* pColl = aTxtCollTbl.Get( 0 );
+ if( !pColl )
+ pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+
+ USHORT nStt = 0;
+ if( bNewTbl )
+ {
+ SwTableBox* pBox = pNewLine->GetTabBoxes()[0];
+ pBoxFmt = (SwTableBoxFmt*)pBox->GetFrmFmt();
+ pBoxFmt->Remove( pBox );
+ delete pBoxFmt;
+ aBoxFmts[0]->Add( pBox );
+ SwTxtNode* pTNd = pDoc->GetNodes()[ pBox->GetSttIdx()+1 ]
+ ->GetTxtNode();
+ ASSERT( pTNd, "wo ist der Textnode dieser Box?" );
+ pTNd->ChgFmtColl( pColl );
+ ++nStt;
+ }
+
+ for( ; nStt < aBoxFmts.Count(); ++nStt )
+ {
+ pDoc->GetNodes().InsBoxen( pTableNode, pNewLine,
+ aBoxFmts[ nStt ],
+ // Formate fuer den TextNode der Box
+ pColl, 0,
+ nAktBox + nStt, 1 );
+ }
+ }
+
+ if( bChkExistTbl )
+ nAktBox = 0;
+
+ if( pDoc->GetRootFrm() )
+ {
+ // exitiert schon ein Layout, dann muss an dieser Tabelle die
+ // BoxFrames neu erzeugt werden.
+ pTableNode->DelFrms();
+ pTableNode->MakeFrms( &pPam->GetPoint()->nNode );
+ }
+
+ ULONG nOldPos = pPam->GetPoint()->nNode.GetIndex();
+ SwTableBox* pBox = pNewLine->GetTabBoxes()[ nAktBox ];
+ pPam->GetPoint()->nNode = *pBox->GetSttNd()->EndOfSectionNode();
+ pPam->Move( fnMoveBackward, fnGoCntnt );
+
+ // alle Attribute, die schon auf den nachfolgen zeigen auf die neue
+ // Box umsetzen !!
+ SvxRTFItemStack& rAttrStk = GetAttrStack();
+ const SvxRTFItemStackType* pStk;
+ for( USHORT n = 0; n < rAttrStk.Count(); ++n )
+ if( ( pStk = rAttrStk[ n ])->GetSttNodeIdx() == ULONG(nOldPos) &&
+ !pStk->GetSttCnt() )
+ ((SvxRTFItemStackType*)pStk)->SetStartPos( SwxPosition( pPam ) );
+
+ SkipToken( -1 ); // zum Letzen gueltigen zurueck
+}
+
+
+// in die naechste Box dieser Line (opt.: falls es nicht die letzte ist)
+void SwRTFParser::GotoNextBox()
+{
+ nInsTblRow = USHRT_MAX;
+
+ ASSERT( pTableNode, "Kein Tabellennode, dann auch keine Box" );
+
+ SwTableLines& rLns = pTableNode->GetTable().GetTabLines();
+ SwTableLine* pLine = rLns[ rLns.Count()-1 ];
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ SwTableBox* pBox = rBoxes[ rBoxes.Count()-1 ];
+
+ if( ++nAktBox >= aMergeBoxes.Count() )
+ nAktBox = aMergeBoxes.Count()-1;
+
+ if( !aMergeBoxes[ nAktBox ] )
+ {
+ int bMove = TRUE;
+ if( pBox->GetSttIdx() > pPam->GetPoint()->nNode.GetIndex() )
+ {
+ USHORT nRealBox = 0;
+ for( USHORT nTmp = 0; nTmp < nAktBox; ++nTmp )
+ if( !aMergeBoxes[ nTmp ] )
+ ++nRealBox;
+
+ if( nRealBox < rBoxes.Count() )
+ {
+ pPam->GetPoint()->nNode = *rBoxes[ nRealBox ]->GetSttNd()->EndOfSectionNode();
+ pPam->Move( fnMoveBackward, fnGoCntnt );
+ bMove = FALSE;
+ }
+ }
+
+ if( bMove && nAktBox + 1 == aMergeBoxes.Count() )
+ // dann hinter die Tabelle
+ pPam->Move( fnMoveForward, fnGoNode );
+ }
+ else if( !pDoc->GetNodes()[ pPam->GetPoint()->nNode ]->IsCntntNode() )
+ // dann in die vorherige ans Ende
+ pPam->Move( fnMoveBackward, fnGoCntnt );
+}
+
+
+void SwRTFParser::NewTblLine()
+{
+ nInsTblRow = USHRT_MAX;
+
+ // erweiter die aktuelle um eine neue Line
+ FASTBOOL bMakeCopy = FALSE;
+ SwNode* pNd = pDoc->GetNodes()[ pPam->GetPoint()->nNode.GetIndex()-1 ];
+ if( !pNd->IsEndNode() ||
+ !(pNd = pNd->StartOfSectionNode())->IsTableNode() )
+ {
+ if( !pOldTblNd )
+ return ;
+
+ bMakeCopy = TRUE;
+ pNd = pOldTblNd;
+ }
+ pTableNode = (SwTableNode*)pNd;
+
+ SwTableLines* pLns = &pTableNode->GetTable().GetTabLines();
+ SwTableLine* pLine = (*pLns)[ pLns->Count()-1 ];
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ SwTableBox* pBox = rBoxes[ rBoxes.Count()-1 ];
+
+ if( !bMakeCopy &&
+ 64000 < pTableNode->GetTable().GetTabSortBoxes().Count() )
+ {
+ bMakeCopy = TRUE; // spaetestens jetzt eine neue anfangen!
+ }
+
+ if( bMakeCopy )
+ {
+ // und die Selektion kopieren
+ SwSelBoxes aBoxes;
+ pTableNode->GetTable().SelLineFromBox( pBox, aBoxes );
+ pTableNode->GetTable().MakeCopy( pDoc, *pPam->GetPoint(),
+ aBoxes, FALSE );
+ ULONG nNd = pPam->GetPoint()->nNode.GetIndex()-1;
+ pTableNode = pDoc->GetNodes()[ nNd ]->FindTableNode();
+ pOldTblNd = pTableNode;
+
+ pLns = &pTableNode->GetTable().GetTabLines();
+ }
+ else
+// pDoc->InsertRow( aBoxes );
+ pTableNode->GetTable().AppendRow( pDoc );
+
+ pBox = (*pLns)[ pLns->Count()-1 ]->GetTabBoxes()[0];
+
+ ULONG nOldPos = pPam->GetPoint()->nNode.GetIndex();
+ pPam->GetPoint()->nNode = *pBox->GetSttNd();
+ pPam->Move( fnMoveForward );
+ nAktBox = 0;
+
+ // alle Nodes in den Boxen auf die "default" Vorlage setzten
+ {
+ SwTxtFmtColl* pColl = aTxtCollTbl.Get( 0 );
+ if( !pColl )
+ pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pPam->SetMark();
+
+ pLine = (*pLns)[ pLns->Count()-1 ];
+ pBox = pLine->GetTabBoxes()[ pLine->GetTabBoxes().Count() -1 ];
+ pPam->GetPoint()->nNode = *pBox->GetSttNd()->EndOfSectionNode();
+ pPam->Move( fnMoveBackward );
+ pDoc->SetTxtFmtColl( *pPam, pColl );
+ // Bug 73940 - remove ALL attributes (NumRules/Break/etc.)
+ {
+ SwNodeIndex aIdx( pPam->GetMark()->nNode );
+ SwNodeIndex& rEndIdx = pPam->GetPoint()->nNode;
+ while( aIdx <= rEndIdx )
+ {
+ SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
+ if( pCNd && pCNd->GetpSwAttrSet() )
+ pCNd->ResetAllAttr();
+ aIdx++;
+ }
+ }
+ pPam->Exchange();
+ pPam->DeleteMark();
+ }
+
+ // alle Attribute, die schon auf den nachfolgen zeigen auf die neue
+ // Box umsetzen !!
+ SvxRTFItemStack& rAttrStk = GetAttrStack();
+ const SvxRTFItemStackType* pStk;
+ for( USHORT n = 0; n < rAttrStk.Count(); ++n )
+ if( ( pStk = rAttrStk[ n ])->GetSttNodeIdx() == ULONG(nOldPos) &&
+ !pStk->GetSttCnt() )
+ ((SvxRTFItemStackType*)pStk)->SetStartPos( SwxPosition( pPam ) );
+}
+
+void SwRTFParser::CheckInsNewTblLine()
+{
+ if( USHRT_MAX != nInsTblRow )
+ {
+ if( nInsTblRow > GetOpenBrakets() || IsPardTokenRead() )
+ nInsTblRow = USHRT_MAX;
+ else if( !pTableNode ) // Tabelle nicht mehr vorhanden ?
+ NewTblLine(); // evt. Line copieren
+ }
+}
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.64 2000/09/18 16:04:51 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.63 2000/05/09 17:22:57 jp
+ Changes for Unicode
+
+ Revision 1.62 2000/03/15 18:22:45 jp
+ Bug #73972#: ReadTable - set distance on the borderlines
+
+ Revision 1.61 2000/03/14 09:55:41 jp
+ Bug #73940#: NewTableLine - remove all attributes after copying the row
+
+ Revision 1.60 2000/02/17 13:46:58 jp
+ Bug #73098#: Import / Export problems
+
+ Revision 1.59 1999/09/09 17:46:33 jp
+ Bug #68573#: InsertTable - dont insert paragraph at start doc
+
+ Revision 1.58 1999/08/11 14:52:54 JP
+ Bug #68058#: read/write repeated tableheadlines
+
+
+ Rev 1.57 11 Aug 1999 16:52:54 JP
+ Bug #68058#: read/write repeated tableheadlines
+
+ Rev 1.56 09 Aug 1999 14:34:04 JP
+ Bug #68058#: read/write repeated tableheadlines
+
+ Rev 1.55 05 Aug 1999 22:52:38 JP
+ Bug #68095#: save tablefmt for optimize the tableborders
+
+ Rev 1.54 03 Aug 1999 19:51:12 JP
+ Bug #67984#: read trleft token
+
+ Rev 1.53 22 Jul 1999 19:59:40 JP
+ Bug #54824#: read&write tableposition 'from left'
+
+ Rev 1.52 21 Apr 1999 13:31:20 JP
+ Bug #65126#: kein VertTop bei Tabellenzellen setzen
+
+ Rev 1.51 01 Apr 1999 16:46:12 JP
+ Bug #64291#: Tabellenhoehe lesen/schreiben
+
+ Rev 1.50 29 Mar 1999 16:28:20 JP
+ Bug #62847#: Parameter vom DeleteBox haben sich geaendert
+
+ Rev 1.49 11 Feb 1999 23:43:50 JP
+ Bug #55590#: Schnittstelle geaendert
+
+ Rev 1.48 18 Dec 1998 18:02:38 JP
+ #59571#: Teilfix - Tabelle splitten, wenn die SortBoxes > 64000
+
+ Rev 1.47 15 Dec 1998 17:49:22 JP
+ #59571#: Teilfix - statt InsertRow am Doc das neue AppendRow an der Tabelle benutzen
+
+ Rev 1.46 13 Aug 1998 10:33:24 JP
+ Bug #53525#: Tabellen - an den Kanten keine doppelte Umrandung mehr
+
+ Rev 1.45 27 May 1998 22:27:10 JP
+ Tokens fuer vertikale Ausrichtung in den Boxen beachten
+
+ Rev 1.44 16 Mar 1998 23:21:40 JP
+ SplitTable hat neuen Parameter bekommen
+
+ Rev 1.43 20 Feb 1998 13:36:34 MA
+ headerfiles gewandert
+
+ Rev 1.42 04 Feb 1998 09:18:10 JP
+ DelFrmFmt: bei TabellenBoxen/Lines direkt das FrmFmt loeschen
+
+ Rev 1.41 26 Nov 1997 15:05:34 MA
+ headerfiles
+
+ Rev 1.40 25 Nov 1997 15:11:30 JP
+ Headerfiles
+
+ Rev 1.39 03 Nov 1997 14:10:34 MA
+ precomp entfernt
+
+ Rev 1.38 29 Oct 1997 13:37:50 JP
+ Bug #45159#: PageDesc/-Break wird vom InsertTable schon uebernommen
+
+ Rev 1.37 09 Oct 1997 14:27:50 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.36 15 Aug 1997 12:51:50 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.35 11 Aug 1997 17:48:48 OS
+ Header-Umstellung
+
+ Rev 1.34 07 Aug 1997 15:06:40 OM
+ Headerfile-Umstellung
+
+ Rev 1.33 27 Jun 1997 11:34:36 JP
+ Bug #40723#: erst pard oder neue Ebene nach einem row hebt die Tabelle auf
+
+ Rev 1.32 09 Jun 1997 11:22:30 NF
+ lcl_DeleteBox richtig als extern declariert
+
+ Rev 1.31 06 Jun 1997 13:25:52 JP
+ lcl_DeleteBox: weiterer Parameter
+
+ Rev 1.30 06 May 1997 12:07:14 MA
+ swtablehxx aufgeteilt
+
+ Rev 1.29 17 Apr 1997 15:17:10 JP
+ segmentc entfernt
+
+ Rev 1.28 17 Apr 1997 15:15:56 JP
+ Bug #38923#: beim einfuegen von Zellen, kann die erste eine gemergt sein
+
+ Rev 1.27 20 Jan 1997 19:21:46 JP
+ neu: SwTableFmt/-LineFmt/-BoxFmt statt SwFrmFmt
+
+ Rev 1.26 14 Jan 1997 18:41:40 JP
+ Tabelle: Umbrueche im Tabellenformat beachten
+
+ Rev 1.25 20 Dec 1996 19:37:36 JP
+ Bug #34702#: Tabellentokens hier auswerten, auch unbekannte!
+
+ Rev 1.24 02 Dec 1996 14:51:28 TRI
+ bei WTC ist private jetzt public
+
+ Rev 1.23 29 Oct 1996 12:58:48 JP
+ am Doc ist das NodesArray nur noch ueber Get..() zugaenglich
+
+ Rev 1.22 18 Sep 1996 13:47:06 JP
+ extern Deklaration zum DeleteBox geaendert
+
+ Rev 1.21 20 Aug 1996 14:57:44 TRI
+ C40_INSERT statt Insert
+
+ Rev 1.20 22 Jul 1996 11:53:46 JP
+ Bug #27445#: Attribute zwischen TabellenDef und ZellenDef erkennen
+
+ Rev 1.19 04 Jul 1996 15:01:56 JP
+ Tabellen einlesen korrigiert
+
+ Rev 1.18 28 Jun 1996 15:07:32 MA
+ includes
+
+ Rev 1.17 19 Jun 1996 09:38:30 JP
+ Tabellen bekommen beim Insert schon einen eindeutigen Namen
+
+ Rev 1.16 25 Apr 1996 13:56:42 MIB
+ Verschiebung SvHTMLParser in Gooedies
+
+ Rev 1.15 15 Jan 1996 13:01:22 JP
+ Bug #24234#: Tabellen bekommen einen eindeutigen Namen
+
+ Rev 1.14 09 Jan 1996 11:53:48 JP
+ Bug 23680: ReadTable - TabelleInTabelle immer abpruefen
+
+ Rev 1.13 13 Dec 1995 10:35:50 MA
+ opt: Bessere Defaults fuer Arrays
+
+ Rev 1.12 24 Nov 1995 17:24:04 OM
+ PCH->PRECOMPILED
+
+ Rev 1.11 30 Oct 1995 21:18:56 JP
+ intbl refernziert auch vorher eingelesene Tabellen
+
+ Rev 1.10 21 Aug 1995 21:30:36 JP
+ svxitems-HeaderFile entfernt
+
+ Rev 1.9 27 Jul 1995 09:28:24 mk
+ an SCC4.0.1a angepasst (MDA)
+
+ Rev 1.8 20 Jun 1995 16:49:10 MA
+ SwFmtBreak -> SvxFmtBreakItem
+
+ Rev 1.7 30 May 1995 08:19:54 SWG
+ forward fuer svtool.hxx!!!
+
+ Rev 1.6 03 Apr 1995 20:51:42 JP
+ fuer PreComp.Header eingerichtet
+
+ Rev 1.5 08 Feb 1995 09:43:08 JP
+ alten RTF-Parser entfernt, Sw_RTF -> SwRTF
+
+ Rev 1.4 02 Feb 1995 18:38:14 JP
+ Tabelle: fuege Boxen auch einzeln ein
+
+ Rev 1.3 27 Jan 1995 08:15:50 JP
+ sBoxFmtNm kommt jetzt aus Table-Header
+
+ Rev 1.2 15 Jan 1995 20:34:38 JP
+ verhinder Tabelle in Tabelle/Fussnote
+
+ Rev 1.1 11 Jan 1995 19:36:28 JP
+ RTF-Reader fertiggestellt
+
+ Rev 1.0 06 Jan 1995 12:07:42 JP
+ Initial revision.
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
new file mode 100644
index 000000000000..b59591295a76
--- /dev/null
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -0,0 +1,3818 @@
+/*************************************************************************
+ *
+ * $RCSfile: swparrtf.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+
+#ifndef _TOOLS_TEMPFILE_HXX
+#include <tools/tempfile.hxx>
+#endif
+#ifndef __RSC //autogen
+#include <tools/errinf.hxx>
+#endif
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _RTFTOKEN_H
+#include <svtools/rtftoken.h>
+#endif
+#ifndef _SFXINTITEM_HXX //autogen
+#include <svtools/intitem.hxx>
+#endif
+#ifndef _TEXTCONV_HXX //autogen
+#include <svx/textconv.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _TXTFTN_HXX //autogen
+#include <txtftn.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _DOCSTAT_HXX //autogen
+#include <docstat.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _SWPARRTF_HXX
+#include <swparrtf.hxx>
+#endif
+#ifndef _FMTCOL_HXX
+#include <fmtcol.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _NUMRULE_HXX
+#include <numrule.hxx>
+#endif
+#ifndef _FTNINFO_HXX
+#include <ftninfo.hxx>
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _FCHRFMT_HXX
+#include <fchrfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _SECTIOM_HXX
+#include <section.hxx>
+#endif
+#ifndef _FMTCLBL_HXX
+#include <fmtclbl.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+
+
+// einige Hilfs-Funktionen
+// char
+inline const SvxFontHeightItem& GetSize(const SfxItemSet& rSet,BOOL bInP=TRUE)
+ { return (const SvxFontHeightItem&)rSet.Get( RES_CHRATR_FONTSIZE,bInP); }
+inline const SvxLRSpaceItem& GetLRSpace(const SfxItemSet& rSet,BOOL bInP=TRUE)
+ { return (const SvxLRSpaceItem&)rSet.Get( RES_LR_SPACE,bInP); }
+
+
+/* */
+#ifdef DEBUG_JP
+
+static void OutStyle( const SwPaM& rPam, const SwTxtFmtColl& rColl );
+static void OutSet( const SwPaM& rPam, const SfxItemSet& rSet );
+static void OutText( const SwPaM& rPam, const sal_Char* pText );
+static void DumpStart();
+static void DumpEnde();
+
+#define DUMP_INIT DumpStart();
+#define DUMP_FINIT DumpEnde();
+#define DUMP_SET( pam, set ) OutSet( pam, set );
+#define DUMP_STYLE( pam, ss ) OutStyle( pam, ss );
+#define DUMP_TXT( pam, txt ) OutText( pam, txt );
+
+#else
+
+#define DUMP_INIT
+#define DUMP_FINIT
+#define DUMP_SET( pam, set )
+#define DUMP_STYLE( pam, ss )
+#define DUMP_TXT( pam, txt )
+
+#endif
+
+/* */
+
+// Aufruf fuer die allg. Reader-Schnittstelle
+ULONG RtfReader::Read( SwDoc &rDoc,SwPaM &rPam, const String &)
+{
+ if( !pStrm )
+ {
+ ASSERT( FALSE, "RTF-Read ohne Stream" );
+ return ERR_SWG_READ_ERROR;
+ }
+
+ //JP 18.01.96: Alle Ueberschriften sind normalerweise ohne
+ // Kapitelnummer. Darum hier explizit abschalten
+ // weil das Default jetzt wieder auf AN ist.
+ if( !bInsertMode )
+ {
+ Reader::SetNoOutlineNum( rDoc );
+
+ // MIB 27.09.96: Umrandung uns Abstaende aus Frm-Vorlagen entf.
+ Reader::ResetFrmFmts( rDoc );
+ }
+
+ ULONG nRet = 0;
+ SvParserRef xParser = new SwRTFParser( &rDoc, rPam, *pStrm,!bInsertMode );
+ SvParserState eState = xParser->CallParser();
+ if( SVPAR_PENDING != eState && SVPAR_ACCEPTED != eState )
+ {
+ String sErr( String::CreateFromInt32( xParser->GetLineNr() ));
+ sErr += ',';
+ sErr += String::CreateFromInt32( xParser->GetLinePos() );
+
+ nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+ ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
+ }
+ return nRet;
+}
+
+SwRTFParser::SwRTFParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ int bReadNewDoc )
+ : SvxRTFParser( pD->GetAttrPool(), rIn, bReadNewDoc ),
+ pDoc( pD ),
+ pTableNode( 0 ), pOldTblNd( 0 ), nAktBox( 0 ), nNewNumSectDef( USHRT_MAX ),
+ nAktPageDesc( 0 ), nAktFirstPageDesc( 0 ),
+ pGrfAttrSet( 0 ),
+ aMergeBoxes( 0, 5 ),
+ nInsTblRow( USHRT_MAX ),
+ pSttNdIdx( 0 ),
+ pRegionEndIdx( 0 ),
+ pRelNumRule( new SwRelNumRuleSpaces( *pD, bReadNewDoc )),
+ aTblFmts( 0, 10 )
+{
+ bReadNoTbl = bReadSwFly = bSwPageDesc = bStyleTabValid =
+ bInPgDscTbl = bNewNumList = FALSE;
+ bFirstContinue = bFirstDocControl = TRUE;
+
+ pPam = new SwPaM( *rCrsr.GetPoint() );
+ SetInsPos( SwxPosition( pPam ) );
+ SetChkStyleAttr( TRUE );
+ SetCalcValue( FALSE );
+ SetReadDocInfo( TRUE );
+
+ // diese sollen zusaetzlich ueber \pard zurueck gesetzt werden
+ USHORT temp;
+ temp = RES_TXTATR_CHARFMT; AddPlainAttr( temp );
+ temp = RES_PAGEDESC; AddPardAttr( temp );
+ temp = RES_BREAK; AddPardAttr( temp );
+ temp = RES_PARATR_NUMRULE; AddPardAttr( temp );
+ temp = FN_PARAM_NUM_LEVEL; AddPardAttr( temp );
+
+ DUMP_INIT
+}
+
+// Aufruf des Parsers
+SvParserState SwRTFParser::CallParser()
+{
+ bReadNoTbl = FALSE;
+ bFirstContinue = TRUE;
+
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+
+ return SvxRTFParser::CallParser();
+}
+
+
+void SwRTFParser::Continue( int nToken )
+{
+ if( bFirstContinue )
+ {
+ bFirstContinue = FALSE;
+
+ // einen temporaeren Index anlegen, auf Pos 0 so wird er nicht bewegt!
+ pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
+ if( !IsNewDoc() ) // in ein Dokument einfuegen ?
+ {
+ const SwPosition* pPos = pPam->GetPoint();
+ SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
+
+ pDoc->SplitNode( *pPos );
+
+ *pSttNdIdx = pPos->nNode.GetIndex()-1;
+ pDoc->SplitNode( *pPos );
+
+ pPam->Move( fnMoveBackward );
+ pDoc->SetTxtFmtColl( *pPam, pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
+
+ // verhinder das einlesen von Tabellen in Fussnoten / Tabellen
+ ULONG nNd = pPos->nNode.GetIndex();
+ bReadNoTbl = 0 != pSttNd->FindTableNode() ||
+ ( nNd < pDoc->GetNodes().GetEndOfInserts().GetIndex() &&
+ pDoc->GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
+ }
+
+ // Laufbalken anzeigen, aber nur bei synchronem Call
+ ULONG nCurrPos = rInput.Tell();
+ rInput.Seek(STREAM_SEEK_TO_END);
+ rInput.ResetError();
+ ::StartProgress( STR_STATSTR_W4WREAD, 0, rInput.Tell(), pDoc->GetDocShell());
+ rInput.Seek( nCurrPos );
+ rInput.ResetError();
+ }
+
+ SvxRTFParser::Continue( nToken );
+
+ if( SVPAR_PENDING == GetStatus() )
+ return ; // weiter gehts beim naechsten mal
+
+ // Laufbalken bei asynchronen Call nicht einschalten !!!
+ ::EndProgress( pDoc->GetDocShell() );
+
+#ifdef DEBUG_JP
+{
+extern Writer* GetDebugWriter(const String&);
+ Writer* pWriter = GetDebugWriter(aEmptyStr);
+ if( pWriter )
+ {
+ SwWriter( SvFileStream( "f:\\tmp\\$$rtf_1.db", STREAM_WRITE ),
+ *pDoc ).Write( pWriter );
+ }
+}
+#endif
+
+
+ {
+ // JP 13.08.98: TabellenUmrandungen optimieren - Bug 53525
+ for( USHORT n = aTblFmts.Count(); n; )
+ {
+ SwTable* pTbl = SwTable::FindTable( (SwFrmFmt*)aTblFmts[ --n ] );
+ if( pTbl )
+ pTbl->GCBorderLines();
+ }
+ }
+
+ pRelNumRule->SetNumRelSpaces( *pDoc );
+
+ // den Start wieder korrigieren
+ if( !IsNewDoc() && pSttNdIdx->GetIndex() )
+ {
+ //die Flys muessen zuerst zurecht gerueckt werden, denn sonst wird
+ // ein am 1. Absatz verankerter Fly falsch eingefuegt
+ if( SVPAR_ACCEPTED == eState )
+ {
+ if( aFlyArr.Count() )
+ SetFlysInDoc();
+ pRelNumRule->SetOultineRelSpaces( *pSttNdIdx, pPam->GetPoint()->nNode );
+ }
+
+ SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
+ SwNodeIndex aNxtIdx( *pSttNdIdx );
+ if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ))
+ {
+ xub_StrLen nStt = pTxtNode->GetTxt().Len();
+ // wenn der Cursor noch in dem Node steht, dann setze in an das Ende
+ if( pPam->GetPoint()->nNode == aNxtIdx )
+ {
+ pPam->GetPoint()->nNode = *pSttNdIdx;
+ pPam->GetPoint()->nContent.Assign( pTxtNode, nStt );
+ }
+
+#ifndef PRODUCT
+// !!! sollte nicht moeglich sein, oder ??
+ASSERT( pSttNdIdx->GetIndex()+1 != pPam->GetBound( TRUE ).nNode.GetIndex(),
+ "Pam.Bound1 steht noch im Node" );
+ASSERT( pSttNdIdx->GetIndex()+1 != pPam->GetBound( FALSE ).nNode.GetIndex(),
+ "Pam.Bound2 steht noch im Node" );
+
+if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( TRUE ).nNode.GetIndex() )
+{
+ register xub_StrLen nCntPos = pPam->GetBound( TRUE ).nContent.GetIndex();
+ pPam->GetBound( TRUE ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+}
+if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() )
+{
+ register xub_StrLen nCntPos = pPam->GetBound( FALSE ).nContent.GetIndex();
+ pPam->GetBound( FALSE ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+}
+#endif
+ // Zeichen Attribute beibehalten!
+ SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
+ if( pTxtNode->GetTxt().Len() )
+ pDelNd->FmtToTxtAttr( pTxtNode );
+ else
+ pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
+ pTxtNode->JoinNext();
+ }
+ }
+
+ if( SVPAR_ACCEPTED == eState )
+ {
+ // den letzen Bereich wieder zumachen
+ if( pRegionEndIdx )
+ {
+ // JP 06.01.00: Task 71411 - the last section in WW are not a
+ // balanced Section.
+ if( !GetVersionNo() )
+ {
+ SwSectionNode* pSectNd = pRegionEndIdx->GetNode().
+ FindStartNode()->GetSectionNode();
+ if( pSectNd )
+ pSectNd->GetSection().GetFmt()->SetAttr(
+ SwFmtNoBalancedColumns( TRUE ) );
+ }
+
+ DelLastNode();
+ pPam->GetPoint()->nNode = *pRegionEndIdx;
+ pPam->Move( fnMoveForward, fnGoNode );
+ delete pRegionEndIdx, pRegionEndIdx = 0;
+ }
+
+ if( aFlyArr.Count() )
+ SetFlysInDoc();
+
+ // jetzt noch den letzten ueberfluessigen Absatz loeschen
+ SwPosition* pPos = pPam->GetPoint();
+ if( !pPos->nContent.GetIndex() )
+ {
+ SwTxtNode* pAktNd;
+ ULONG nNodeIdx = pPos->nNode.GetIndex();
+ if( IsNewDoc() )
+ {
+ SwNode* pTmp = pDoc->GetNodes()[ nNodeIdx -1 ];
+ if( pTmp->IsCntntNode() && !pTmp->FindTableNode() )
+ DelLastNode();
+ }
+ else if( 0 != ( pAktNd = pDoc->GetNodes()[ nNodeIdx ]->GetTxtNode()) )
+ {
+ if( pAktNd->CanJoinNext( &pPos->nNode ))
+ {
+ SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
+ pPos->nContent.Assign( pNextNd, 0 );
+ pPam->SetMark(); pPam->DeleteMark();
+ pNextNd->JoinPrev();
+ }
+ else if( !pAktNd->GetTxt().Len() &&
+ pAktNd->StartOfSectionIndex()+2 <
+ pAktNd->EndOfSectionIndex() )
+ {
+ pPos->nContent.Assign( 0, 0 );
+ pPam->SetMark(); pPam->DeleteMark();
+ pDoc->GetNodes().Delete( pPos->nNode, 1 );
+ pPam->Move( fnMoveBackward );
+ }
+ }
+ }
+
+ // nun noch das SplitNode vom Ende aufheben
+ else if( !IsNewDoc() )
+ {
+ if( pPos->nContent.GetIndex() ) // dann gabs am Ende kein \par,
+ pPam->Move( fnMoveForward, fnGoNode ); // als zum naechsten Node
+ SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
+ SwNodeIndex aPrvIdx( pPos->nNode );
+ if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) &&
+ *pSttNdIdx <= aPrvIdx )
+ {
+ // eigentlich muss hier ein JoinNext erfolgen, aber alle Cursor
+ // usw. sind im pTxtNode angemeldet, so dass der bestehen
+ // bleiben MUSS.
+
+ // Absatz in Zeichen-Attribute umwandeln, aus dem Prev die
+ // Absatzattribute und die Vorlage uebernehmen!
+ SwTxtNode* pPrev = aPrvIdx.GetNode().GetTxtNode();
+ pTxtNode->ChgFmtColl( pPrev->GetTxtColl() );
+ pTxtNode->FmtToTxtAttr( pPrev );
+ pTxtNode->SwCntntNode::ResetAllAttr();
+
+ if( pPrev->GetpSwAttrSet() )
+ pTxtNode->SwCntntNode::SetAttr( *pPrev->GetpSwAttrSet() );
+
+ if( &pPam->GetBound(TRUE).nNode.GetNode() == pPrev )
+ pPam->GetBound(TRUE).nContent.Assign( pTxtNode, 0 );
+ if( &pPam->GetBound(FALSE).nNode.GetNode() == pPrev )
+ pPam->GetBound(FALSE).nContent.Assign( pTxtNode, 0 );
+
+ pTxtNode->JoinPrev();
+ }
+ }
+ else if( GetDocInfo() )
+ // evt. eingelesen DocInfo setzen
+ pDoc->SetInfo( *GetDocInfo() );
+ }
+ delete pSttNdIdx, pSttNdIdx = 0;
+ delete pRegionEndIdx, pRegionEndIdx = 0;
+ RemoveUnusedNumRules();
+}
+
+SwRTFParser::~SwRTFParser()
+{
+ delete pSttNdIdx;
+ delete pRegionEndIdx;
+ delete pPam;
+ delete pRelNumRule;
+
+ if( aFlyArr.Count() )
+ aFlyArr.DeleteAndDestroy( 0, aFlyArr.Count() );
+
+ if( pGrfAttrSet ) DELETEZ( pGrfAttrSet );
+ DUMP_FINIT
+}
+
+extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich,
+ USHORT& rSubType, ULONG &rFmt,
+ USHORT nVersion );
+
+void SwRTFParser::NextToken( int nToken )
+{
+ USHORT eDateFmt;
+
+ switch( nToken )
+ {
+ case RTF_FOOTNOTE: ReadHeaderFooter( nToken );
+ SkipToken( -1 ); // Klammer wieder zurueck
+ break;
+ case RTF_SWG_PRTDATA: ReadPrtData(); break;
+ case RTF_FIELD: ReadField(); break;
+ case RTF_PICT: ReadBitmapData(); break;
+#ifdef READ_OLE_OBJECT
+ case RTF_OBJECT: ReadOLEData(); break;
+#endif
+ case RTF_TROWD: ReadTable( nToken ); break;
+ case RTF_PGDSCTBL: ReadPageDescTbl(); break;
+ case RTF_LISTTABLE: ReadListTable(); break;
+ case RTF_LISTOVERRIDETABLE: ReadListOverrideTable(); break;
+
+ case RTF_LISTTEXT:
+ GetAttrSet().Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, 0 ));
+ SkipGroup();
+ break;
+
+ case RTF_PN:
+ case RTF_PNSECLVL:
+ if( bNewNumList )
+ SkipGroup();
+ else
+ ReadNumSecLevel( nToken );
+ break;
+
+ case RTF_PNTEXT:
+ SkipGroup();
+ break;
+
+ case RTF_OUTLINELEVEL:
+ {
+ BYTE nLevel = MAXLEVEL <= nTokenValue ? MAXLEVEL - 1
+ : BYTE( nTokenValue );
+ GetAttrSet().Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, nLevel ));
+ }
+ break;
+
+ case RTF_DEFFORMAT:
+ case RTF_DEFTAB:
+ case RTF_DEFLANG:
+ // sind zwar Dok-Controls, werden aber manchmal auch vor der
+ // Font/Style/Color-Tabelle gesetzt!
+ SvxRTFParser::NextToken( nToken );
+ break;
+
+ case RTF_PAGE:
+ {
+ const SwCntntNode* pCNd;
+ const SwAttrSet* pSet;
+ if( pPam->GetPoint()->nContent.GetIndex() ||
+ ( 0 != ( pCNd = pPam->GetCntntNode()) &&
+ 0 != ( pSet = pCNd->GetpSwAttrSet()) &&
+ ( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, FALSE ) ||
+ SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, FALSE ))))
+ InsertPara();
+ CheckInsNewTblLine();
+ pDoc->Insert( *pPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ) );
+ }
+ break;
+
+ case RTF_SECT:
+ ReadSectControls( nToken );
+ break;
+ case RTF_CELL:
+ if( bReadNoTbl )
+ InsertPara();
+ else
+ {
+ if( USHRT_MAX != nInsTblRow && !pTableNode ) // Tabelle nicht mehr vorhanden ?
+ NewTblLine(); // evt. Line copieren
+ GotoNextBox();
+ }
+ break;
+
+ case RTF_ROW:
+ if( !bReadNoTbl )
+ {
+ // aus der Line raus
+ nAktBox = 0;
+ pTableNode = 0;
+ // noch in der Tabelle drin?
+ SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
+ const SwTableNode* pTblNd = rIdx.GetNode().FindTableNode();
+ if( pTblNd )
+ {
+ // search the end of this row
+ const SwStartNode* pBoxStt =
+ rIdx.GetNode().FindTableBoxStartNode();
+ const SwTableBox* pBox = pTblNd->GetTable().GetTblBox(
+ pBoxStt->GetIndex() );
+ const SwTableLine* pLn = pBox->GetUpper();
+ pBox = pLn->GetTabBoxes()[ pLn->GetTabBoxes().Count() - 1 ];
+ rIdx = *pBox->GetSttNd()->EndOfSectionNode();
+ pPam->Move( fnMoveForward, fnGoNode );
+ }
+ nInsTblRow = GetOpenBrakets();
+ SetPardTokenRead( FALSE );
+ }
+ ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
+ break;
+
+ case RTF_INTBL:
+ if( !bReadNoTbl )
+ {
+ if( !pTableNode ) // Tabelle nicht mehr vorhanden ?
+ NewTblLine(); // evt. Line copieren
+ else
+ {
+ // Crsr nicht mehr in der Tabelle ?
+ if( !pPam->GetNode()->FindTableNode() )
+ {
+ // dann wieder in die letzte Box setzen
+ // (kann durch einlesen von Flys geschehen!)
+ pPam->GetPoint()->nNode = *pTableNode->EndOfSectionNode();
+ pPam->Move( fnMoveBackward );
+ }
+ }
+ }
+ break;
+
+ case RTF_FLY_INPARA:
+ // \pard und plain ueberlesen !
+ if( '}' != GetNextToken() && '}' != GetNextToken() )
+ {
+ // Zeichengebundener Fly in Fly
+ ReadHeaderFooter( nToken );
+ SetPardTokenRead( FALSE );
+ }
+ break;
+
+ case RTF_PGDSCNO:
+ if( IsNewDoc() && bSwPageDesc &&
+ USHORT(nTokenValue) < pDoc->GetPageDescCnt() )
+ {
+ const SwPageDesc* pPgDsc = &pDoc->GetPageDesc( USHORT(nTokenValue) );
+ CheckInsNewTblLine();
+ pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ));
+ }
+ break;
+
+ case RTF_COLUM:
+ pDoc->Insert( *pPam, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE ));
+ break;
+
+ case RTF_DXFRTEXT: // werden nur im Zusammenhang mit Flys ausgewertet
+ case RTF_DFRMTXTX:
+ case RTF_DFRMTXTY:
+ break;
+
+ case RTF_CHDATE: eDateFmt = DF_SHORT; goto SETCHDATEFIELD;
+ case RTF_CHDATEA: eDateFmt = DF_SSYS; goto SETCHDATEFIELD;
+ case RTF_CHDATEL: eDateFmt = DF_LSYS; goto SETCHDATEFIELD;
+SETCHDATEFIELD:
+ {
+ USHORT nSubType = DATEFLD, nWhich = RES_DATEFLD;
+ ULONG nFormat = eDateFmt;
+ sw3io_ConvertFromOldField( *pDoc, nWhich, nSubType, nFormat, 0x0110 );
+
+ SwDateTimeField aDateFld( (SwDateTimeFieldType*)
+ pDoc->GetSysFldType( RES_DATETIMEFLD ), DATEFLD, nFormat);
+ CheckInsNewTblLine();
+ pDoc->Insert( *pPam, SwFmtFld( aDateFld ));
+ }
+ break;
+
+ case RTF_CHTIME:
+ {
+ USHORT nSubType = TIMEFLD, nWhich = RES_TIMEFLD;
+ ULONG nFormat = TF_SSMM_24;
+ sw3io_ConvertFromOldField( *pDoc, nWhich, nSubType, nFormat, 0x0110 );
+ SwDateTimeField aTimeFld( (SwDateTimeFieldType*)
+ pDoc->GetSysFldType( RES_DATETIMEFLD ), TIMEFLD, nFormat);
+ CheckInsNewTblLine();
+ pDoc->Insert( *pPam, SwFmtFld( aTimeFld ));
+ }
+ break;
+
+ case RTF_CHPGN:
+ {
+ SwPageNumberField aPageFld( (SwPageNumberFieldType*)
+ pDoc->GetSysFldType( RES_PAGENUMBERFLD ),
+ PG_RANDOM, SVX_NUM_ARABIC );
+ CheckInsNewTblLine();
+ pDoc->Insert( *pPam, SwFmtFld( aPageFld));
+ }
+ break;
+
+ case RTF_CHFTN:
+ bFootnoteAutoNum = TRUE;
+ break;
+
+ case RTF_NOFPAGES:
+ if( IsNewDoc() && nTokenValue && -1 != nTokenValue )
+ ((SwDocStat&)pDoc->GetDocStat()).nPage = (USHORT)nTokenValue;
+ break;
+
+ case RTF_NOFWORDS:
+ if( IsNewDoc() && nTokenValue && -1 != nTokenValue )
+ ((SwDocStat&)pDoc->GetDocStat()).nWord = (USHORT)nTokenValue;
+ break;
+ case RTF_NOFCHARS:
+ if( IsNewDoc() && nTokenValue && -1 != nTokenValue )
+ ((SwDocStat&)pDoc->GetDocStat()).nChar = (USHORT)nTokenValue;
+ break;
+
+ case RTF_U:
+ {
+ CheckInsNewTblLine();
+ if( nTokenValue )
+ aToken = (sal_Unicode )nTokenValue;
+ pDoc->Insert( *pPam, aToken );
+ }
+ break;
+
+// case RTF_REVDTTM:
+// UnknownAttrToken( nToken, &GetAttrSet() );
+// break;
+
+
+// RTF_SUBENTRYINDEX
+
+ default:
+ switch( nToken & ~(0xff | RTF_SWGDEFS) )
+ {
+ case RTF_DOCFMT:
+ ReadDocControls( nToken );
+ break;
+ case RTF_SECTFMT:
+ ReadSectControls( nToken );
+ break;
+ case RTF_APOCTL:
+ ReadFly( nToken );
+ break;
+ case RTF_BRDRDEF | RTF_TABLEDEF:
+ case RTF_SHADINGDEF | RTF_TABLEDEF:
+ case RTF_TABLEDEF:
+ ReadTable( nToken );
+ break;
+
+ case RTF_INFO:
+ ReadInfo();
+ break;
+
+ default:
+ if( USHRT_MAX != nInsTblRow &&
+ (nInsTblRow > GetOpenBrakets() || IsPardTokenRead() ))
+ nInsTblRow = USHRT_MAX;
+
+ SvxRTFParser::NextToken( nToken );
+ break;
+ }
+ }
+ if( USHRT_MAX != nInsTblRow &&
+ (nInsTblRow > GetOpenBrakets() || IsPardTokenRead() ))
+ nInsTblRow = USHRT_MAX;
+}
+
+
+void SwRTFParser::InsertText()
+{
+ DUMP_TXT( *pPam, aToken )
+ // dann fuege den String ein, ohne das Attribute am Ende
+ // aufgespannt werden.
+ CheckInsNewTblLine();
+ pDoc->Insert( *pPam, aToken );
+}
+
+
+void SwRTFParser::InsertPara()
+{
+ CheckInsNewTblLine();
+ pDoc->AppendTxtNode(*pPam->GetPoint());
+
+ // setze das default Style
+ if( !bStyleTabValid )
+ MakeStyleTab();
+
+ SwTxtFmtColl* pColl = aTxtCollTbl.Get( 0 );
+ if( !pColl )
+ pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pDoc->SetTxtFmtColl( *pPam, pColl );
+
+ ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
+}
+
+
+
+void SwRTFParser::MovePos( int bForward )
+{
+ if( bForward )
+ pPam->Move( fnMoveForward );
+ else
+ pPam->Move( fnMoveBackward );
+}
+
+int SwRTFParser::IsEndPara( SvxNodeIdx* pNd, xub_StrLen nCnt ) const
+{
+ SwCntntNode *pNode = pDoc->GetNodes()[pNd->GetIdx()]->GetCntntNode();
+ return pNode && pNode->Len() == nCnt;
+}
+
+void SwRTFParser::SetEndPrevPara( SvxNodeIdx*& rpNodePos, xub_StrLen& rCntPos )
+{
+ SwNodeIndex aIdx( pPam->GetPoint()->nNode );
+ SwCntntNode* pNode = pDoc->GetNodes().GoPrevious( &aIdx );
+ if( !pNode )
+ ASSERT( FALSE, "keinen vorherigen ContentNode gefunden" );
+
+ rpNodePos = new SwNodeIdx( aIdx );
+ rCntPos = pNode->Len();
+}
+
+void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
+{
+ ULONG nSNd = rSet.GetSttNodeIdx(), nENd = rSet.GetEndNodeIdx();
+ xub_StrLen nSCnt = rSet.GetSttCnt(), nECnt = rSet.GetEndCnt();
+
+ SwPaM aPam( *pPam->GetPoint() );
+
+#ifndef PRODUCT
+ ASSERT( nSNd <= nENd, "Start groesser als Ende" );
+ SwNode* pDebugNd = pDoc->GetNodes()[ nSNd ];
+ ASSERT( pDebugNd->IsCntntNode(), "Start kein ContentNode" );
+ pDebugNd = pDoc->GetNodes()[ nENd ];
+ ASSERT( pDebugNd->IsCntntNode(), "Ende kein ContentNode" );
+#endif
+
+ SwCntntNode* pCNd = pDoc->GetNodes()[ nSNd ]->GetCntntNode();
+ aPam.GetPoint()->nNode = nSNd;
+ aPam.GetPoint()->nContent.Assign( pCNd, nSCnt );
+ aPam.SetMark();
+ if( nENd == nSNd )
+ aPam.GetPoint()->nContent = nECnt;
+ else
+ {
+ aPam.GetPoint()->nNode = nENd;
+ pCNd = aPam.GetCntntNode();
+ aPam.GetPoint()->nContent.Assign( pCNd, nECnt );
+ }
+
+ // setze ueber den Bereich das entsprechende Style
+ if( rSet.StyleNo() )
+ {
+ // setze jetzt das Style
+ if( !bStyleTabValid )
+ MakeStyleTab();
+ SwTxtFmtColl* pColl = aTxtCollTbl.Get( rSet.StyleNo() );
+ if( pColl )
+ {
+ pDoc->SetTxtFmtColl( aPam, pColl, FALSE );
+ DUMP_STYLE( aPam, *pColl )
+ }
+ }
+
+ const SfxPoolItem* pItem;
+ if( rSet.GetAttrSet().Count() )
+ {
+
+ // falls eine Zeichenvorlage im Set steht, deren Attribute
+ // aus dem Set loeschen. Sonst sind diese doppelt, was man ja
+ // nicht will.
+ if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(
+ RES_TXTATR_CHARFMT, FALSE, &pItem ) &&
+ ((SwFmtCharFmt*)pItem)->GetCharFmt() )
+ {
+ const String& rName = ((SwFmtCharFmt*)pItem)->GetCharFmt()->GetName();
+ SvxRTFStyleType* pStyle = GetStyleTbl().First();
+ do {
+ if( pStyle->bIsCharFmt && pStyle->sName == rName )
+ {
+ // alle Attribute, die schon vom Style definiert sind, aus dem
+ // akt. AttrSet entfernen
+ SfxItemSet &rAttrSet = rSet.GetAttrSet(),
+ &rStyleSet = pStyle->aAttrSet;
+ SfxItemIter aIter( rAttrSet );
+ USHORT nWhich = aIter.GetCurItem()->Which();
+ while( TRUE )
+ {
+ if( SFX_ITEM_SET == rStyleSet.GetItemState(
+ nWhich, FALSE, &pItem ) && *pItem == *aIter.GetCurItem())
+ rAttrSet.ClearItem( nWhich ); // loeschen
+
+ if( aIter.IsAtEnd() )
+ break;
+ nWhich = aIter.NextItem()->Which();
+ }
+ break;
+ }
+ } while( 0 != (pStyle = GetStyleTbl().Next()) );
+ }
+ // dann setze ueber diesen Bereich die Attrbiute
+ SetSwgValues( rSet.GetAttrSet() );
+
+
+#if 0
+///!!!!!!!!!!!!!!!!!!!!!
+ if( !rSet.GetAttrSet().GetParent() )
+ {
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ SfxItemSet &rAttrSet = rSet.GetAttrSet();
+ SfxItemIter aIter( rAttrSet );
+ USHORT nWhich = aIter.GetCurItem()->Which();
+ while( TRUE )
+ {
+ if( SFX_WHICH_MAX < nWhich ||
+ rPool.GetDefaultItem( nWhich ) == *aIter.GetCurItem() )
+ rAttrSet.ClearItem( nWhich ); // loeschen
+
+ if( aIter.IsAtEnd() )
+ break;
+ nWhich = aIter.NextItem()->Which();
+ }
+ }
+ if( rSet.GetAttrSet().Count() )
+#endif
+
+ pDoc->Insert( aPam, rSet.GetAttrSet(), SETATTR_DONTCHGNUMRULE );
+ DUMP_SET( aPam, rSet.GetAttrSet() )
+ }
+
+ if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(
+ FN_PARAM_NUM_LEVEL, FALSE, &pItem ))
+ {
+ // dann ueber den Bereich an den Nodes das NodeNum setzen
+ for( ULONG n = nSNd; n <= nENd; ++n )
+ {
+ SwTxtNode* pTxtNd = pDoc->GetNodes()[ n ]->GetTxtNode();
+ if( pTxtNd )
+ {
+ pTxtNd->UpdateNum( SwNodeNum( (BYTE)
+ ((SfxUInt16Item*)pItem)->GetValue() ));
+ // Update vom LR-Space abschalten?
+ }
+ }
+ }
+
+ if( SFX_ITEM_SET == rSet.GetAttrSet().GetItemState(
+ RES_PARATR_NUMRULE, FALSE, &pItem ))
+ {
+ const SwNumRule* pRule = pDoc->FindNumRulePtr(
+ ((SwNumRuleItem*)pItem)->GetValue() );
+ if( pRule && ( pRule->IsContinusNum() || !bNewNumList ))
+ {
+ // diese Rule hat keinen Level, also muss die Einrueckung
+ // erhalten bleiben!
+ // dann ueber den Bereich an den Nodes das Flag zuruecksetzen
+ SwNodeNum aNdNum( 0 );
+ for( ULONG n = nSNd; n <= nENd; ++n )
+ {
+ SwTxtNode* pTxtNd = pDoc->GetNodes()[ n ]->GetTxtNode();
+ if( pTxtNd )
+ {
+ if( !pTxtNd->GetNum() )
+ pTxtNd->UpdateNum( aNdNum );
+ // Update vom LR-Space abschalten
+ pTxtNd->SetNumLSpace( FALSE );
+ }
+ }
+ }
+ }
+}
+
+
+// lese alle Dokument-Controls ein
+void SwRTFParser::ReadDocControls( int nToken )
+{
+ int bWeiter = TRUE;
+
+ SwFmtFrmSize aFrmSize(ATT_FIX_SIZE, 12240, 15840 );
+ SvxULSpaceItem aUL;
+ SvxLRSpaceItem aLR;
+ SwFtnInfo aFtnInfo;
+ SwEndNoteInfo aEndInfo;
+ UseOnPage eUseOn;
+ USHORT nPgStart = USHRT_MAX;
+ if( bFirstDocControl )
+ {
+ // RTF-Defaults setzen
+ SwFmtFrmSize aFrmSize(ATT_FIX_SIZE, 12240, 15840 );
+
+ aUL.SetUpper( 1440 ); aUL.SetLower( 1440 );
+ aLR.SetRight( 1800 ); aLR.SetLeft( 1800 );
+ eUseOn = UseOnPage(PD_ALL | PD_HEADERSHARE | PD_FOOTERSHARE);
+ aFtnInfo.ePos = FTNPOS_CHAPTER; aFtnInfo.eNum = FTNNUM_DOC;
+ bFirstDocControl = FALSE;
+ }
+ else
+ {
+ const SwPageDesc& rStdPgDsc = pDoc->GetPageDesc( 0 );
+ aFrmSize = rStdPgDsc.GetMaster().GetFrmSize();
+ aUL = rStdPgDsc.GetMaster().GetULSpace();
+ aLR = rStdPgDsc.GetMaster().GetLRSpace();
+
+ eUseOn = rStdPgDsc.ReadUseOn();
+
+ aEndInfo = pDoc->GetEndNoteInfo();
+ aFtnInfo = pDoc->GetFtnInfo();
+ }
+
+ BOOL bEndInfoChgd = FALSE, bFtnInfoChgd = FALSE;
+
+ do {
+ USHORT nValue = USHORT( nTokenValue );
+ switch( nToken )
+ {
+/* case '}': --nOpenBrakets; nToken = RTF_DOCFMT; break;
+ case '{': ++nOpenBrakets; nToken = RTF_DOCFMT; break;
+ case RTF_IGNOREFLAG: nToken = RTF_DOCFMT; break;
+*/
+ case RTF_PAPERW:
+ if( 0 < nTokenValue )
+ aFrmSize.SetWidth( nTokenValue );
+ break;
+ case RTF_PAPERH:
+ if( 0 < nTokenValue )
+ aFrmSize.SetHeight( nTokenValue );
+ break;
+ case RTF_MARGL:
+ if( 0 <= nTokenValue )
+ aLR.SetLeft( nValue );
+ break;
+ case RTF_MARGR:
+ if( 0 <= nTokenValue )
+ aLR.SetRight( nValue );
+ break;
+ case RTF_MARGT:
+ if( 0 <= nTokenValue )
+ aUL.SetUpper( nValue );
+ break;
+ case RTF_MARGB:
+ if( 0 <= nTokenValue )
+ aUL.SetLower( nValue );
+ break;
+
+ case RTF_FACINGP: eUseOn = UseOnPage(PD_MIRROR | PD_HEADERSHARE | PD_FOOTERSHARE);
+ break;
+ case RTF_PGNSTART: nPgStart = nValue; break;
+
+ case RTF_ENDDOC:
+ case RTF_ENDNOTES:
+ aFtnInfo.ePos = FTNPOS_CHAPTER; bFtnInfoChgd = TRUE;
+ break;
+ case RTF_FTNTJ:
+ case RTF_FTNBJ:
+ aFtnInfo.ePos = FTNPOS_PAGE; bFtnInfoChgd = TRUE;
+ break;
+
+ case RTF_AENDDOC:
+ case RTF_AENDNOTES:
+ case RTF_AFTNTJ:
+ case RTF_AFTNBJ:
+ case RTF_AFTNRESTART:
+ case RTF_AFTNRSTCONT:
+ break; // wir kenn nur am Doc Ende und Doc weite Num.!
+
+ case RTF_FTNSTART:
+ if( nValue )
+ {
+ aFtnInfo.nFtnOffset = nValue-1;
+ bFtnInfoChgd = TRUE;
+ }
+ break;
+ case RTF_AFTNSTART:
+ if( nValue )
+ {
+ aEndInfo.nFtnOffset = nValue-1;
+ bEndInfoChgd = TRUE;
+ }
+ break;
+ case RTF_FTNRSTPG:
+ aFtnInfo.eNum = FTNNUM_PAGE; bFtnInfoChgd = TRUE;
+ break;
+ case RTF_FTNRESTART:
+ aFtnInfo.eNum = FTNNUM_CHAPTER; bFtnInfoChgd = TRUE;
+ break;
+ case RTF_FTNRSTCONT:
+ aFtnInfo.eNum = FTNNUM_DOC; bFtnInfoChgd = TRUE;
+ break;
+
+ case RTF_FTNNAR:
+ aFtnInfo.aFmt.eType = SVX_NUM_ARABIC; bFtnInfoChgd = TRUE; break;
+ case RTF_FTNNALC:
+ aFtnInfo.aFmt.eType = SVX_NUM_CHARS_LOWER_LETTER_N; bFtnInfoChgd = TRUE; break;
+ case RTF_FTNNAUC:
+ aFtnInfo.aFmt.eType = SVX_NUM_CHARS_UPPER_LETTER_N; bFtnInfoChgd = TRUE; break;
+ case RTF_FTNNRLC:
+ aFtnInfo.aFmt.eType = SVX_NUM_ROMAN_LOWER; bFtnInfoChgd = TRUE; break;
+ case RTF_FTNNRUC:
+ aFtnInfo.aFmt.eType = SVX_NUM_ROMAN_UPPER; bFtnInfoChgd = TRUE; break;
+ case RTF_FTNNCHI:
+ aFtnInfo.aFmt.eType = SVX_NUM_CHAR_SPECIAL; bFtnInfoChgd = TRUE; break;
+
+ case RTF_AFTNNAR:
+ aEndInfo.aFmt.eType = SVX_NUM_ARABIC; bEndInfoChgd = TRUE; break;
+ case RTF_AFTNNALC:
+ aEndInfo.aFmt.eType = SVX_NUM_CHARS_LOWER_LETTER_N; bEndInfoChgd = TRUE; break;
+ case RTF_AFTNNAUC:
+ aEndInfo.aFmt.eType = SVX_NUM_CHARS_UPPER_LETTER_N; bEndInfoChgd = TRUE; break;
+ case RTF_AFTNNRLC:
+ aEndInfo.aFmt.eType = SVX_NUM_ROMAN_LOWER; bEndInfoChgd = TRUE; break;
+ case RTF_AFTNNRUC:
+ aEndInfo.aFmt.eType = SVX_NUM_ROMAN_UPPER; bEndInfoChgd = TRUE; break;
+ case RTF_AFTNNCHI:
+ aEndInfo.aFmt.eType = SVX_NUM_CHAR_SPECIAL; bEndInfoChgd = TRUE; break;
+
+
+ case '{':
+ {
+ short nSkip = 0;
+ if( RTF_IGNOREFLAG != GetNextToken() )
+ nSkip = -1;
+ else if( RTF_DOCFMT != (( nToken = GetNextToken() )
+ & ~(0xff | RTF_SWGDEFS)) )
+ nSkip = -2;
+ else
+ {
+ SkipGroup(); // erstmal komplett ueberlesen
+ // ueberlese noch die schliessende Klammer
+ GetNextToken();
+ }
+ if( nSkip )
+ {
+ SkipToken( nSkip ); // Ignore wieder zurueck
+ bWeiter = FALSE;
+ }
+ }
+ break;
+
+ default:
+ if( RTF_DOCFMT == (nToken & ~(0xff | RTF_SWGDEFS)) ||
+ RTF_UNKNOWNCONTROL == nToken )
+ SvxRTFParser::NextToken( nToken );
+ else
+ bWeiter = FALSE;
+ break;
+ }
+ if( bWeiter )
+ nToken = GetNextToken();
+ } while( bWeiter && IsParserWorking() );
+
+ if( IsNewDoc() )
+ {
+ if( bEndInfoChgd )
+ pDoc->SetEndNoteInfo( aEndInfo );
+ if( bFtnInfoChgd )
+ pDoc->SetFtnInfo( aFtnInfo );
+ }
+
+ if( !bSwPageDesc )
+ {
+ if( IsNewDoc() )
+ {
+ // direkt an der Standartseite drehen
+ SwPageDesc& rPg = pDoc->_GetPageDesc( 0 );
+ rPg.WriteUseOn( eUseOn );
+ SwFrmFmt &rFmt1 = rPg.GetMaster(), &rFmt2 = rPg.GetLeft();
+
+ rFmt1.SetAttr( aFrmSize ); rFmt2.SetAttr( aFrmSize );
+ rFmt1.SetAttr( aLR ); rFmt2.SetAttr( aLR );
+ rFmt1.SetAttr( aUL ); rFmt2.SetAttr( aUL );
+
+ // StartNummer der Seiten setzen
+ if( USHRT_MAX != nPgStart )
+ {
+ const SfxPoolItem* pItem;
+ const SwCntntNode* pNd = pPam->GetCntntNode();
+ if( pNd && pNd->GetpSwAttrSet() && SFX_ITEM_SET ==
+ pNd->GetpSwAttrSet()->GetItemState( RES_PAGEDESC,
+ FALSE, &pItem ) )
+ {
+ // set a new PageNum
+ ((SwFmtPageDesc*)pItem)->SetNumOffset( nPgStart );
+ }
+ else
+ {
+ SwFmtPageDesc aPgDsc( &rPg );
+ aPgDsc.SetNumOffset( nPgStart );
+ pDoc->Insert( *pPam, aPgDsc );
+ }
+ }
+ }
+
+ MakeStyleTab();
+ // das default-Style schon gleich am ersten Node setzen
+// if( IsNewDoc() )
+ {
+ SwTxtFmtColl* pColl = aTxtCollTbl.Get( 0 );
+ if( !pColl )
+ pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pDoc->SetTxtFmtColl( *pPam, pColl );
+ }
+ }
+
+ SkipToken( -1 );
+}
+
+void SwRTFParser::MakeStyleTab()
+{
+ // dann erzeuge aus der SvxStyle-Tabelle die Swg-Collections
+ if( GetStyleTbl().Count() )
+ {
+ USHORT nValidOutlineLevels = 0;
+ if( !IsNewDoc() )
+ {
+ // search all outlined collections
+ BYTE nLvl;
+ const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
+ for( USHORT n = rColls.Count(); n; )
+ if( MAXLEVEL > (nLvl = rColls[ --n ]->GetOutlineLevel() ))
+ nValidOutlineLevels |= 1 << nLvl;
+ }
+
+ SvxRTFStyleType* pStyle = GetStyleTbl().First();
+ do {
+ USHORT nNo = USHORT( GetStyleTbl().GetCurKey() );
+ if( pStyle->bIsCharFmt )
+ {
+ if( !aCharFmtTbl.Get( nNo ) )
+ // existiert noch nicht, also anlegen
+ MakeCharStyle( nNo, *pStyle );
+ }
+ else if( !aTxtCollTbl.Get( nNo ) )
+ {
+ // existiert noch nicht, also anlegen
+ if( MAXLEVEL > pStyle->nOutlineNo )
+ {
+ USHORT nOutlFlag = 1 << pStyle->nOutlineNo;
+ if( nValidOutlineLevels & nOutlFlag )
+ pStyle->nOutlineNo = (BYTE)-1;
+ else
+ nValidOutlineLevels |= nOutlFlag;
+ }
+
+ MakeStyle( nNo, *pStyle );
+ }
+
+ } while( 0 != (pStyle = GetStyleTbl().Next()) );
+ bStyleTabValid = TRUE;
+ }
+}
+
+SwPageDesc* SwRTFParser::_MakeNewPageDesc( int bFirst )
+{
+ USHORT* pNo = &nAktPageDesc;
+ String aNm( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "RTF-SectionPage(" )));
+
+ if( bFirst )
+ {
+ aNm.InsertAscii( "First", 4 );
+ pNo = &nAktFirstPageDesc;
+ }
+ aNm += String::CreateFromInt32( pDoc->GetPageDescCnt() );
+ aNm += ')';
+
+ USHORT nNew = pDoc->MakePageDesc( aNm, 0 );
+ SwPageDesc& rAkt = pDoc->_GetPageDesc( nNew );
+ SwPageDesc& rOld = pDoc->_GetPageDesc( *pNo );
+ pDoc->CopyPageDesc( rOld, rAkt, FALSE );
+
+ *pNo = nNew;
+
+ // setze den Follow-PageDesc immer auf sich selbst
+ rAkt.SetFollow( &rAkt );
+
+ // falls auf \\page ein \\setd folgt, dann muss noch ein neuer
+ // Absatz eingefuegt werden.
+ SwCntntNode* pCNd = pPam->GetCntntNode();
+ ASSERT( pCNd, "wo ist mein Content-Node" );
+ if( SFX_ITEM_SET == pCNd->GetSwAttrSet().GetItemState( RES_BREAK, FALSE )
+ // sollten nicht am NodeAnfang stehen, erzeuge einen neuen Absatz
+ || pPam->GetPoint()->nContent.GetIndex() )
+ InsertPara();
+
+ return &rAkt;
+}
+
+BOOL lcl_CompareRTFPageDesc( const SwPageDesc& rOld, const SwPageDesc& rAkt )
+{
+ BOOL bRet = /*rAkt.ReadUseOn() == rOld.ReadUseOn() && Bug 63599 */
+ rAkt.GetLandscape() == rOld.GetLandscape() &&
+ rAkt.GetNumType().eType == rOld.GetNumType().eType;
+
+ if( bRet )
+ {
+ // dann ein paar Attribute vergleichen
+ USHORT __READONLY_DATA aIdArr[] = { RES_FRM_SIZE, RES_UL_SPACE,
+ RES_BACKGROUND, RES_SHADOW,
+ 0 };
+ const SfxPoolItem* pOldItem, *pAktItem;
+ for( USHORT n = 0; aIdArr[ n ] && bRet; n += 2 )
+ {
+ for( USHORT nId = aIdArr[ n ]; nId <= aIdArr[ n+1]; ++nId )
+ {
+ int eOldSt = rOld.GetMaster().GetItemState( nId, FALSE, &pOldItem ),
+ eAktSt = rAkt.GetMaster().GetItemState( nId, FALSE, &pAktItem );
+ if( eOldSt != eAktSt ||
+ ( SFX_ITEM_SET == eOldSt && *pOldItem != *pAktItem ))
+ {
+ bRet = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ return bRet;
+}
+
+BOOL lcl_SetFmtCol( SwFmt& rFmt, USHORT nCols, USHORT nColSpace,
+ const SvUShorts& rColumns )
+{
+ BOOL bSet = FALSE;
+ if( nCols && USHRT_MAX != nCols )
+ {
+ SwFmtCol aCol;
+ if( USHRT_MAX == nColSpace )
+ nColSpace = 720;
+
+ aCol.Init( nCols, nColSpace, USHRT_MAX );
+ if( nCols == ( rColumns.Count() / 2 ) )
+ {
+ aCol._SetOrtho( FALSE );
+ USHORT nWishWidth = 0, nHalfPrev = 0;
+ for( USHORT n = 0, i = 0; n < rColumns.Count(); n += 2, ++i )
+ {
+ SwColumn* pCol = aCol.GetColumns()[ i ];
+ pCol->SetLeft( nHalfPrev );
+ USHORT nSp = rColumns[ n+1 ];
+ nHalfPrev = nSp / 2;
+ pCol->SetRight( nSp - nHalfPrev );
+ pCol->SetWishWidth( rColumns[ n ] +
+ pCol->GetLeft() + pCol->GetRight() );
+ nWishWidth += pCol->GetWishWidth();
+ }
+ aCol.SetWishWidth( nWishWidth );
+ }
+ rFmt.SetAttr( aCol );
+ bSet = TRUE;
+ }
+ return bSet;
+}
+
+// lese alle Section-Controls ein
+void SwRTFParser::ReadSectControls( int nToken )
+{
+ int bWeiter = TRUE;
+
+ // werden die eigenen PageDesc - Informationen gelesen, dann alles
+ // ueberlesen
+ // Wird in ein bestehendes Doc eingelesen oder wurden eigene PageDesc
+ // gelesen, dann sind nur die Bereiche von interresse
+ BOOL bInsPageDesc = IsNewDoc() && !bSwPageDesc;
+
+ if( bInPgDscTbl )
+ {
+ do {
+ if( '{' == nToken )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case RTF_IGNOREFLAG:
+ if( RTF_SECTFMT != (( nToken = GetNextToken() )
+ & ~(0xff | RTF_SWGDEFS)) )
+ {
+ SkipToken( -2 ); // Ignore und Token wieder zurueck
+ bWeiter = FALSE;
+ break;
+ }
+ // kein break, Gruppe ueberspringen
+
+ case RTF_FOOTER:
+ case RTF_HEADER:
+ case RTF_FOOTERR:
+ case RTF_HEADERR:
+ case RTF_FOOTERL:
+ case RTF_HEADERL:
+ case RTF_FOOTERF:
+ case RTF_HEADERF:
+ SkipGroup(); // erstmal komplett ueberlesen
+ // ueberlese noch die schliessende Klammer
+ GetNextToken();
+ break;
+
+ default:
+ SkipToken( -1 ); // Ignore wieder zurueck
+ bWeiter = FALSE;
+ break;
+ }
+ }
+ else if( RTF_SECTFMT == (nToken & ~(0xff | RTF_SWGDEFS)) ||
+ RTF_UNKNOWNCONTROL == nToken )
+ SvxRTFParser::NextToken( nToken );
+ else
+ bWeiter = FALSE;
+ if( bWeiter )
+ nToken = GetNextToken();
+ } while( bWeiter && IsParserWorking() );
+ SkipToken( -1 ); // letztes Token wieder zurueck
+ return;
+ }
+
+ // RTF-Defaults setzen
+ BOOL bFirstCall = 1 == pDoc->GetPageDescCnt();
+ BOOL bHeaderUL = FALSE, bHeaderLR = FALSE,
+ bFooterUL = FALSE, bFooterLR = FALSE;
+
+ USHORT nLastPageDesc = nAktPageDesc,
+ nLastFirstPageDesc = nAktFirstPageDesc;
+
+ BOOL bMakeNewPageDesc = RTF_SECT == nToken;
+ BOOL bInsNewPageDesc = bMakeNewPageDesc || bFirstCall || bSwPageDesc;
+ SwPageDesc* pAkt, *pFirst = 0;
+ if( bInsNewPageDesc )
+ {
+ pAkt = _MakeNewPageDesc( FALSE );
+ if( bMakeNewPageDesc )
+ {
+ nToken = GetNextToken();
+ // some export filter write the RTF_SECT in brakets -> skip over
+ while( '}' == nToken )
+ {
+ NextToken( nToken );
+ nToken = GetNextToken();
+ }
+ }
+ }
+ else
+ {
+ pAkt = &pDoc->_GetPageDesc( nAktPageDesc );
+ if( nAktFirstPageDesc )
+ pFirst = &pDoc->_GetPageDesc( nAktFirstPageDesc );
+ }
+
+ SwFmtFrmSize aSz( pAkt->GetMaster().GetFrmSize() ),
+ aHSz( ATT_MIN_SIZE );
+ SvxULSpaceItem aUL( pAkt->GetMaster().GetULSpace() ), aHUL, aFUL;
+ SvxLRSpaceItem aLR( pAkt->GetMaster().GetLRSpace() ), aHLR, aFLR;
+ BOOL bPgWiChgd = FALSE, bPgHeChgd = FALSE,
+ bPgUpChgd = FALSE, bPgLoChgd = FALSE,
+ bPgLeChgd = FALSE, bPgRiChgd = FALSE,
+ bPgFcChgd = FALSE,
+ bNoBalancedCols = FALSE;
+
+ USHORT nRestoreUpper = USHRT_MAX, nRestoreLower = USHRT_MAX;
+ SwFrmFmt* pFmt = (SwFrmFmt*)pAkt->GetMaster().GetHeader().GetHeaderFmt();
+ if( pFmt )
+ {
+ aHUL = pFmt->GetULSpace();
+ aHLR = pFmt->GetLRSpace();
+ aHSz = pFmt->GetFrmSize();
+ if( aHSz.GetHeight() )
+ {
+ nRestoreUpper = (USHORT)aHSz.GetHeight();
+ aUL.SetUpper( aUL.GetUpper() + nRestoreUpper );
+ aHSz.SetHeight( 0 );
+ }
+ }
+
+ if( 0 != (pFmt = (SwFrmFmt*)pAkt->GetMaster().GetFooter().GetFooterFmt()) )
+ {
+ aFUL = pFmt->GetULSpace();
+ aFLR = pFmt->GetLRSpace();
+ if( aFUL.GetUpper() )
+ {
+ nRestoreLower = aFUL.GetUpper();
+ aUL.SetLower( aUL.GetLower() + nRestoreLower );
+ aFUL.SetUpper( 0 );
+ }
+ }
+
+ BOOL bCheckEqualPgDesc = TRUE, bPgDescChgd = FALSE;
+ SvxBreak eBreak = SVX_BREAK_PAGE_BEFORE;
+
+ USHORT nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0;
+ SvUShorts aColumns;
+
+ USHORT nPgStart = USHRT_MAX;
+ SwNumType aNumType;
+
+ do {
+ BOOL bIsSectToken = FALSE;
+ USHORT nValue = USHORT( nTokenValue );
+ switch( nToken )
+ {
+ case RTF_SECT:
+ bWeiter = FALSE;
+ break;
+
+ case RTF_SECTD:
+ {
+ // Wert von der StandardPage holen !
+ const SwFrmFmt& rFmt = pDoc->GetPageDesc(0).GetMaster();
+ aSz = rFmt.GetFrmSize();
+ aUL = rFmt.GetULSpace();
+ aLR = rFmt.GetLRSpace();
+
+ nRestoreUpper = USHRT_MAX, nRestoreLower = USHRT_MAX;
+ aHUL.SetUpper( 720 ); aHUL.SetLower( 0 );
+ aFUL.SetUpper( 0 ); aFUL.SetLower( 720 );
+ aHLR.SetLeft( 0 ); aHLR.SetRight( 0 );
+ aFLR.SetLeft( 0 ); aFLR.SetRight( 0 );
+ pAkt->WriteUseOn( UseOnPage(PD_ALL | PD_HEADERSHARE | PD_FOOTERSHARE) );
+ pAkt->SetLandscape( FALSE );
+
+ // remove Columns/Header/Footer
+ pAkt->GetMaster().ResetAttr( RES_COL );
+ if( pFirst )
+ pFirst->GetMaster().ResetAttr( RES_COL );
+
+ nPgStart = USHRT_MAX;
+ nCols = USHRT_MAX;
+ nColSpace = USHRT_MAX;
+ aNumType.eType = SVX_NUM_ARABIC;
+ bHeaderUL = bHeaderLR = bFooterUL = bFooterLR = TRUE;
+ eBreak = SVX_BREAK_PAGE_BEFORE;
+ nNewNumSectDef = USHRT_MAX;
+
+ bPgWiChgd = bPgHeChgd = bPgUpChgd = bPgLoChgd = bPgLeChgd =
+ bPgRiChgd = bPgFcChgd = TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+
+ case RTF_PGWSXN:
+ if( 0 < nTokenValue )
+ {
+ aSz.SetWidth( nTokenValue );
+ bPgWiChgd = TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+
+ case RTF_PGHSXN:
+ if( 0 < nTokenValue )
+ {
+ aSz.SetHeight( nTokenValue );
+ bPgHeChgd = TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+ case RTF_MARGLSXN:
+ if( 0 <= nTokenValue )
+ {
+ aLR.SetLeft( nValue );
+ bPgLeChgd =TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+ case RTF_MARGRSXN:
+ if( 0 <= nTokenValue )
+ {
+ aLR.SetRight( nValue );
+ bPgRiChgd = TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+
+ case RTF_MARGTSXN:
+ if( 0 <= nTokenValue )
+ {
+ nRestoreUpper = USHRT_MAX;
+ aUL.SetUpper( nValue );
+ bPgUpChgd = TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+
+ case RTF_MARGBSXN:
+ if( 0 <= nTokenValue )
+ {
+ nRestoreLower = USHRT_MAX;
+ aUL.SetLower( nValue );
+ bPgLoChgd = TRUE;
+ bPgDescChgd = TRUE;
+ }
+ break;
+
+ case RTF_FACPGSXN:
+ pAkt->SetUseOn( UseOnPage(PD_MIRROR | ( pAkt->GetUseOn() &
+ ~(PD_HEADERSHARE | PD_FOOTERSHARE) )));
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_HEADERY:
+ aHUL.SetUpper( nValue );
+ bHeaderUL = TRUE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_FOOTERY:
+ aFUL.SetLower( nValue );
+ bFooterUL = TRUE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_LNDSCPSXN:
+ pAkt->SetLandscape( TRUE );
+ bPgFcChgd = TRUE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_PGNSTARTS:
+ nPgStart = nValue;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_PGNDEC:
+ aNumType.eType = SVX_NUM_ARABIC;
+ bPgDescChgd = TRUE;
+ break;
+ case RTF_PGNUCRM:
+ aNumType.eType = SVX_NUM_ROMAN_UPPER;
+ bPgDescChgd = TRUE;
+ break;
+ case RTF_PGNLCRM:
+ aNumType.eType = SVX_NUM_ROMAN_LOWER;
+ bPgDescChgd = TRUE;
+ break;
+ case RTF_PGNUCLTR:
+ aNumType.eType = SVX_NUM_CHARS_UPPER_LETTER_N;
+ bPgDescChgd = TRUE;
+ break;
+ case RTF_PGNLCLTR:
+ aNumType.eType = SVX_NUM_CHARS_LOWER_LETTER_N;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_SBKNONE:
+ bIsSectToken = TRUE;
+ eBreak = SVX_BREAK_NONE;
+ bPgDescChgd = !bFirstCall;
+ break;
+
+ case RTF_SBKCOL:
+ eBreak = SVX_BREAK_COLUMN_BEFORE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_ENDNHERE:
+ case RTF_BINFSXN:
+ case RTF_BINSXN:
+ case RTF_SBKPAGE:
+ case RTF_SBKEVEN:
+ case RTF_SBKODD:
+ case RTF_LINEBETCOL:
+ case RTF_LINEMOD:
+ case RTF_LINEX:
+ case RTF_LINESTARTS:
+ case RTF_LINERESTART:
+ case RTF_LINEPAGE:
+ case RTF_LINECONT:
+ case RTF_GUTTERSXN:
+ case RTF_PGNCONT:
+ case RTF_PGNRESTART:
+ case RTF_PGNX:
+ case RTF_PGNY:
+ case RTF_VERTALT:
+ case RTF_VERTALB:
+ case RTF_VERTALC:
+ case RTF_VERTALJ:
+ break;
+
+ case RTF_TITLEPG:
+ if( bInsPageDesc && !pFirst )
+ pFirst = _MakeNewPageDesc( TRUE );
+ bCheckEqualPgDesc = FALSE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_HEADER:
+ case RTF_HEADERL:
+ case RTF_HEADERR:
+ case RTF_FOOTER:
+ case RTF_FOOTERL:
+ case RTF_FOOTERR:
+ if( bInsPageDesc )
+ ReadHeaderFooter( nToken, pAkt );
+ else
+ SkipGroup(), GetNextToken(); //Gruppe mit schl. Klammer lesen
+ bCheckEqualPgDesc = FALSE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_FOOTERF:
+ case RTF_HEADERF:
+ if( bInsPageDesc )
+ {
+ if( !pFirst )
+ pFirst = _MakeNewPageDesc( TRUE );
+ ReadHeaderFooter( nToken, pFirst );
+ }
+ else
+ SkipGroup(), GetNextToken(); //Gruppe mit schl. Klammer lesen
+ bCheckEqualPgDesc = FALSE;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_COLS:
+ bIsSectToken = TRUE;
+ nCols = nValue;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_COLSX:
+ bIsSectToken = TRUE;
+ nColSpace = nValue;
+ bPgDescChgd = TRUE;
+ break;
+
+ case RTF_COLNO:
+ bIsSectToken = TRUE;
+ nAktCol = nValue;
+ if( RTF_COLW == GetNextToken() )
+ {
+ USHORT nWidth = USHORT( nTokenValue ), nSpace = 0;
+ if( RTF_COLSR == GetNextToken() )
+ nSpace = USHORT( nTokenValue );
+ else
+ SkipToken( -1 ); // wieder zurueck
+
+ if( --nAktCol == ( aColumns.Count() / 2 ) )
+ {
+ aColumns.Insert( nWidth, aColumns.Count() );
+ aColumns.Insert( nSpace, aColumns.Count() );
+ }
+ }
+ bPgDescChgd = TRUE;
+ break;
+
+
+ case '{':
+ {
+ short nSkip = 0;
+ if( RTF_IGNOREFLAG != ( nToken = GetNextToken() ))
+ nSkip = -1;
+ else if( RTF_SECTFMT != (( nToken = GetNextToken() )
+ & ~(0xff | RTF_SWGDEFS)) &&
+ ( RTF_DOCFMT != ( nToken & ~(0xff | RTF_SWGDEFS))) )
+ nSkip = -2;
+ else
+ {
+ bPgDescChgd = TRUE;
+ switch( nToken )
+ {
+ case RTF_HEADER_YB:
+ aHUL.SetLower( USHORT(nTokenValue) );
+ bHeaderUL = TRUE;
+ if( RTF_HEADER_XL == GetNextToken() &&
+ RTF_HEADER_XR == GetNextToken() )
+ {
+ bHeaderLR = TRUE;
+ aHLR.SetLeft( USHORT(GetStackPtr( -1 )->nTokenValue) );
+ aHLR.SetRight( USHORT(nTokenValue));
+ }
+ else
+ SkipGroup();
+ break;
+
+ case RTF_FOOTER_YT:
+ aFUL.SetUpper( USHORT(nTokenValue));
+ bFooterUL = TRUE;
+ if( RTF_FOOTER_XL == GetNextToken() &&
+ RTF_FOOTER_XR == GetNextToken() )
+ {
+ bFooterLR = TRUE;
+ aFLR.SetLeft( USHORT(GetStackPtr( -1 )->nTokenValue) );
+ aFLR.SetRight( USHORT(nTokenValue));
+ }
+ else
+ SkipGroup();
+ break;
+
+ case RTF_BALANCED_COLUMN:
+ bIsSectToken = TRUE;
+ bPgDescChgd = TRUE;
+ bNoBalancedCols = TRUE;
+ break;
+
+ default:
+ SkipGroup(); // erstmal komplett ueberlesen
+ break;
+ }
+
+ // ueberlese noch die schliessende Klammer
+ GetNextToken();
+ }
+ if( nSkip )
+ {
+ bWeiter = -1 == nSkip && (
+ RTF_FOOTER == nToken || RTF_HEADER == nToken ||
+ RTF_FOOTERR == nToken || RTF_HEADERR == nToken ||
+ RTF_FOOTERL == nToken || RTF_HEADERL == nToken ||
+ RTF_FOOTERF == nToken || RTF_HEADERF == nToken );
+ SkipToken( nSkip ); // Ignore wieder zurueck
+ }
+ }
+ break;
+
+ case RTF_PAPERW:
+ case RTF_PAPERH:
+ case RTF_MARGL:
+ case RTF_MARGR:
+ case RTF_MARGT:
+ case RTF_MARGB:
+ case RTF_FACINGP:
+ {
+ ReadDocControls( nToken );
+
+ // set the new Values
+ const SwPageDesc& rStdPgDsc = pDoc->GetPageDesc( 0 );
+ const SwFmtFrmSize& rSz = rStdPgDsc.GetMaster().GetFrmSize();
+ const SvxULSpaceItem rUL = rStdPgDsc.GetMaster().GetULSpace();
+ const SvxLRSpaceItem rLR = rStdPgDsc.GetMaster().GetLRSpace();
+
+ if( !bPgWiChgd ) aSz.SetWidth( rSz.GetWidth() );
+ if( !bPgHeChgd ) aSz.SetHeight( rSz.GetHeight() );
+ if( !bPgUpChgd ) aUL.SetUpper( rUL.GetUpper() );
+ if( !bPgLoChgd ) aUL.SetLower( rUL.GetLower() );
+ if( !bPgLeChgd ) aLR.SetLeft( rLR.GetLeft() );
+ if( !bPgRiChgd ) aLR.SetRight( rLR.GetRight() );
+ if( !bPgFcChgd ) pAkt->SetLandscape( rStdPgDsc.GetLandscape() );
+ }
+ break;
+ default:
+ if( RTF_DOCFMT == (nToken & ~(0xff | RTF_SWGDEFS)) )
+ ReadDocControls( nToken );
+ else if( RTF_SECTFMT == (nToken & ~(0xff | RTF_SWGDEFS)) ||
+ RTF_UNKNOWNCONTROL == nToken )
+ SvxRTFParser::NextToken( nToken );
+ else
+ bWeiter = FALSE;
+ break;
+ }
+
+
+ if( bWeiter )
+ {
+ // kein eigener Bereich und kein Section Attribut?
+ if( !bInsPageDesc && !bIsSectToken )
+ bCheckEqualPgDesc = FALSE;
+ nToken = GetNextToken();
+ }
+ } while( bWeiter && IsParserWorking() );
+
+
+ if( !bPgDescChgd )
+ {
+ // der aktuelle muss wieder entnfernt werden
+ if( bInsNewPageDesc )
+ {
+ pDoc->DelPageDesc( nAktPageDesc );
+ if( pFirst )
+ pDoc->DelPageDesc( nAktFirstPageDesc );
+ nAktPageDesc = nLastPageDesc;
+ nAktFirstPageDesc = nLastFirstPageDesc;
+ }
+ SkipToken( -1 );
+ return ;
+ }
+
+
+ // den letzen Bereich wieder zumachen
+ if( pRegionEndIdx )
+ {
+ DelLastNode();
+ pPam->GetPoint()->nNode = *pRegionEndIdx;
+ pPam->Move( fnMoveForward, fnGoNode );
+ delete pRegionEndIdx, pRegionEndIdx = 0;
+ }
+
+
+ pFmt = &pAkt->GetMaster();
+
+ if( bInsPageDesc )
+ {
+ if( bHeaderUL )
+ {
+ if( aUL.GetUpper() > aHUL.GetUpper() )
+ {
+ aHSz.SetHeight( aUL.GetUpper() - aHUL.GetUpper() );
+ aHUL.SetUpper( 0 );
+ aUL.SetUpper( USHORT(aUL.GetUpper() - aHSz.GetHeight()) );
+
+ if( !pFmt->GetHeader().GetHeaderFmt() )
+ pFmt->SetAttr( SwFmtHeader( (BOOL)TRUE ));
+ if( pFirst && !pFirst->GetMaster().GetHeader().GetHeaderFmt() )
+ pFirst->GetMaster().SetAttr( SwFmtHeader( (BOOL)TRUE ));
+ }
+ }
+ else if( USHRT_MAX != nRestoreUpper )
+ aUL.SetUpper( aUL.GetUpper() - nRestoreUpper );
+
+ if( bFooterUL )
+ {
+ if( aUL.GetLower() > aFUL.GetLower() )
+ {
+ aFUL.SetUpper( aUL.GetLower() - aFUL.GetLower() );
+ aUL.SetLower( aFUL.GetLower() );
+ aFUL.SetLower( 0 );
+ if( !pFmt->GetFooter().GetFooterFmt() )
+ pFmt->SetAttr( SwFmtFooter( (BOOL)TRUE ));
+ if( pFirst && !pFirst->GetMaster().GetFooter().GetFooterFmt() )
+ pFirst->GetMaster().SetAttr( SwFmtFooter( (BOOL)TRUE ));
+ }
+ else
+ {
+ aUL.SetLower( aFUL.GetLower() );
+ aFUL.SetLower( 0 );
+ }
+ }
+ else if( USHRT_MAX != nRestoreLower )
+ aUL.SetLower( aUL.GetLower() - nRestoreLower );
+
+ pFmt->SetAttr( aSz );
+ pFmt->SetAttr( aLR );
+ pFmt->SetAttr( aUL );
+
+ pAkt->SetNumType( aNumType );
+ if( pFirst )
+ pFirst->SetNumType( aNumType );
+
+ if( ( bHeaderUL || bHeaderLR ) &&
+ 0 != (pFmt = (SwFrmFmt*)pAkt->GetMaster().GetHeader().GetHeaderFmt()) )
+ {
+ if( bHeaderUL && aHSz.GetHeight() ) pFmt->SetAttr( aHSz );
+ if( bHeaderLR ) pFmt->SetAttr( aHLR );
+ }
+
+ if( ( bFooterUL || bFooterLR ) &&
+ 0 != ( pFmt = (SwFrmFmt*)pAkt->GetMaster().GetFooter().GetFooterFmt()) )
+ {
+ if( bFooterUL ) pFmt->SetAttr( aFUL );
+ if( bFooterLR ) pFmt->SetAttr( aFLR );
+ }
+ }
+
+
+ if( nCols && USHRT_MAX != nCols )
+ {
+ if( ::lcl_SetFmtCol( pAkt->GetMaster(), nCols, nColSpace, aColumns )
+ && pFirst )
+ pFirst->GetMaster().SetAttr( pAkt->GetMaster().GetAttr( RES_COL ));
+
+ //JP 19.03.99 - Spaltigkeit NIE an der Seite setzen - dieses
+ // ist immer ein Kennzeichen fuer einen Bereich, weil
+ // die Seitenspalten NIE vom Layout aufgebrochen werden.
+ //JP 24.02.00 - but dont insert column section into a column page
+ // Bug 73480
+ if( bSwPageDesc )
+ {
+ const SwPageDesc& rOld = pDoc->GetPageDesc( nLastPageDesc );
+ if( rOld.GetMaster().GetAttr( RES_COL ) !=
+ pAkt->GetMaster().GetAttr( RES_COL ) )
+ {
+ bCheckEqualPgDesc = TRUE;
+ bInsPageDesc = FALSE;
+ eBreak = SVX_BREAK_NONE;
+
+// !! ???? muss das hier passieren ??
+ // fuer den Absatz dahinter sorgen
+ pDoc->AppendTxtNode(*pPam->GetPoint());
+ pPam->Move( fnMoveBackward );
+ pPam->SetMark();
+ }
+ }
+ }
+ else if( bInsNewPageDesc )
+ {
+ pAkt->GetMaster().ResetAttr( RES_COL );
+ if( pFirst )
+ pFirst->GetMaster().ResetAttr( RES_COL );
+ }
+
+ if( pFirst )
+ {
+ // setze am ersten den richtigen Follow
+ pFirst->SetFollow( pAkt );
+
+ // und setze noch die die Werte aus PageDesc:
+ pFirst->SetLandscape( pAkt->GetLandscape() );
+
+ pFmt = &pFirst->GetMaster();
+
+ pFmt->SetAttr( aSz );
+ pFmt->SetAttr( aLR );
+ pFmt->SetAttr( aUL );
+
+ if( ( bHeaderUL || bHeaderLR ) &&
+ 0 != (pFmt = (SwFrmFmt*)pFirst->GetMaster().GetHeader().GetHeaderFmt()) )
+ {
+ if( bHeaderUL && aHSz.GetHeight() ) pFmt->SetAttr( aHSz );
+ if( bHeaderLR ) pFmt->SetAttr( aHLR );
+ }
+
+ if( ( bFooterUL || bFooterLR ) &&
+ 0 != ( pFmt = (SwFrmFmt*)pFirst->GetMaster().GetFooter().GetFooterFmt()) )
+ {
+ if( bFooterUL ) pFmt->SetAttr( aFUL );
+ if( bFooterLR ) pFmt->SetAttr( aFLR );
+ }
+ }
+
+ const SwPageDesc& rOld = pDoc->GetPageDesc( nLastPageDesc );
+ if( bInsNewPageDesc && pFirst &&
+ pDoc->GetPageDesc( nLastFirstPageDesc ).GetFollow() != &rOld )
+ {
+ bCheckEqualPgDesc = FALSE;
+ }
+
+ if( bInsPageDesc && ( !bCheckEqualPgDesc || !bInsNewPageDesc ||
+ // dann pruefe ob die Attribute beider PageDesc gleich sind
+ !::lcl_CompareRTFPageDesc(pDoc->GetPageDesc( nLastPageDesc ), *pAkt ))
+ || ( bMakeNewPageDesc && SVX_BREAK_NONE != eBreak ) )
+ {
+ // Pagedescriptoren am Dokument updaten (nur so werden auch die
+ // linken Seiten usw. eingestellt).
+
+ // Spaltigkeit in den Set uebernehmen
+ SfxItemSet* pSet = 0;
+ const SfxPoolItem* pItem;
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_COL, RES_COLUMNBALANCE );
+ if( SFX_ITEM_SET == pAkt->GetMaster().GetItemState(
+ RES_COL, FALSE, &pItem )
+ && 1 < ((SwFmtCol*)pItem)->GetColumns().Count() )
+ {
+ aSet.Put( *pItem );
+ pSet = &aSet;
+ pAkt->GetMaster().ResetAttr( RES_COL );
+ if( pFirst )
+ pFirst->GetMaster().ResetAttr( RES_COL );
+ }
+
+ pDoc->ChgPageDesc( nAktPageDesc, *pAkt );
+
+ if( pSet )
+ {
+ SwSection aSect( CONTENT_SECTION, pDoc->GetUniqueSectionName() );
+ SwSection* pSect = pDoc->Insert( *pPam, aSect, pSet );
+ pPam->DeleteMark();
+
+ SwSectionNode* pSectNd = pSect->GetFmt()->GetSectionNode( TRUE );
+ if( pRegionEndIdx )
+ *pRegionEndIdx = *pSectNd->EndOfSectionNode();
+ else
+ pRegionEndIdx = new SwNodeIndex( *pSectNd->EndOfSectionNode());
+
+ pPam->GetPoint()->nNode = *pSectNd;
+ pPam->Move( fnMoveForward, fnGoNode );
+
+ // Attribut Enden ggfs. anpassen!!!!
+ if( GetAttrStack().Count() )
+ {
+ // Attribut Stack-Eintraege, muessen ans Ende des vorherigen
+ // Nodes verschoben werden.
+ for( USHORT n = GetAttrStack().Count(); n; )
+ {
+ SvxRTFItemStackType* pStkEntry = (SvxRTFItemStackType*)
+ GetAttrStack()[ --n ];
+ if( pRegionEndIdx->GetIndex() == pStkEntry->GetSttNode().GetIdx() )
+ pStkEntry->SetStartPos( SwxPosition( pPam ) );
+ }
+ }
+ }
+
+ if( bInsNewPageDesc )
+ {
+ SwFmtPageDesc aPgDsc( pAkt );
+
+ if( pFirst )
+ {
+ // Pagedescriptoren am Dokument updaten (nur so werden auch die
+ // linken Seiten usw. eingestellt).
+ pDoc->ChgPageDesc( nAktFirstPageDesc, *pFirst );
+ pFirst->Add( &aPgDsc );
+ }
+
+ if( USHRT_MAX != nPgStart )
+ aPgDsc.SetNumOffset( nPgStart );
+ pDoc->Insert( *pPam, aPgDsc );
+ }
+ }
+ else
+ {
+ // sollte es ein BereichsWechsel sein?
+ if( bCheckEqualPgDesc && SVX_BREAK_NONE == eBreak
+ /*&& (!bInsPageDesc || neuen Bereich aufsetzen
+ rOld.GetMaster().GetCol() != pAkt->GetMaster().GetCol() )*/ )
+ {
+ // Spaltigkeit in den Set uebernehmen
+ SfxItemSet* pSet = 0;
+ const SfxPoolItem* pItem;
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_COL, RES_COLUMNBALANCE);
+ if( SFX_ITEM_SET == pAkt->GetMaster().GetItemState(
+ RES_COL, FALSE, &pItem )
+ && 1 < ((SwFmtCol*)pItem)->GetColumns().Count() )
+ {
+ aSet.Put( *pItem );
+ pSet = &aSet;
+ }
+
+ if( bNoBalancedCols )
+ {
+ aSet.Put( SwFmtNoBalancedColumns( TRUE ) );
+ pSet = &aSet;
+ }
+
+ if( !bFirstCall || pSet )
+ {
+ SwSection aSect( CONTENT_SECTION, pDoc->GetUniqueSectionName() );
+ SwSection* pSect = pDoc->Insert( *pPam, aSect, pSet );
+ pPam->DeleteMark();
+
+ SwSectionNode* pSectNd = pSect->GetFmt()->GetSectionNode( TRUE );
+ if( pRegionEndIdx )
+ *pRegionEndIdx = *pSectNd->EndOfSectionNode();
+ else
+ pRegionEndIdx = new SwNodeIndex( *pSectNd->EndOfSectionNode());
+
+ pPam->GetPoint()->nNode = *pSectNd;
+ pPam->Move( fnMoveForward, fnGoNode );
+
+ // Attribut Enden ggfs. anpassen!!!!
+ if( GetAttrStack().Count() )
+ {
+ // Attribut Stack-Eintraege, muessen ans Ende des vorherigen
+ // Nodes verschoben werden.
+ for( USHORT n = GetAttrStack().Count(); n; )
+ {
+ SvxRTFItemStackType* pStkEntry = (SvxRTFItemStackType*)
+ GetAttrStack()[ --n ];
+ if( pRegionEndIdx->GetIndex() == pStkEntry->GetSttNode().GetIdx() )
+ pStkEntry->SetStartPos( SwxPosition( pPam ) );
+ }
+ }
+ }
+ }
+ else if( bInsPageDesc )
+ {
+ if(SVX_BREAK_COLUMN_BEFORE == eBreak )
+ pDoc->Insert( *pPam, SvxFmtBreakItem( eBreak ));
+ else if( SVX_BREAK_NONE != eBreak )
+ {
+ SwFmtPageDesc aPgDsc( ( pFirst && &rOld ==
+ pDoc->GetPageDesc( nLastFirstPageDesc ).GetFollow() )
+ ? &pDoc->_GetPageDesc( nLastFirstPageDesc )
+ : &rOld );
+
+ if( USHRT_MAX != nPgStart )
+ aPgDsc.SetNumOffset( nPgStart );
+ pDoc->Insert( *pPam, aPgDsc );
+ }
+ }
+
+ // der aktuelle muss wieder entnfernt werden
+ if( bInsNewPageDesc )
+ {
+ pDoc->DelPageDesc( nAktPageDesc );
+ if( pFirst )
+ pDoc->DelPageDesc( nAktFirstPageDesc );
+ nAktPageDesc = nLastPageDesc;
+ nAktFirstPageDesc = nLastFirstPageDesc;
+ }
+ }
+
+ SkipToken( -1 );
+}
+
+
+
+void SwRTFParser::ReadPageDescTbl()
+{
+ if( !IsNewDoc() )
+ {
+ SkipGroup();
+ return;
+ }
+
+ // dann erzeuge aus der SvxStyle-Tabelle die Swg-Collections, damit
+ // diese auch in den Headers/Footer benutzt werden koennen!
+ MakeStyleTab();
+ // das default-Style schon gleich am ersten Node setzen
+ SwTxtFmtColl* pColl = aTxtCollTbl.Get( 0 );
+ if( !pColl )
+ pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pDoc->SetTxtFmtColl( *pPam, pColl );
+
+ int nToken, bSaveChkStyleAttr = IsChkStyleAttr();
+ int nOpenBrakets = 1; // die erste wurde schon vorher erkannt !!
+
+ SetChkStyleAttr(FALSE); // Attribute nicht gegen die Styles checken
+
+ bInPgDscTbl = TRUE;
+ USHORT nPos = 0;
+ SwPageDesc* pPg;
+ SwFrmFmt* pPgFmt;
+
+ SvxULSpaceItem aUL, aHUL, aFUL;
+ SvxLRSpaceItem aLR, aHLR, aFLR;
+ SwFmtFrmSize aSz( ATT_FIX_SIZE, 11905, 16837 ); // DIN A4 defaulten
+ SwFmtFrmSize aFSz( ATT_MIN_SIZE ), aHSz( ATT_MIN_SIZE );
+
+ USHORT nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0;
+ SvUShorts aColumns;
+
+ while( nOpenBrakets && IsParserWorking() )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case '{':
+ ++nOpenBrakets;
+ break;
+
+ case '}':
+ if( 1 == --nOpenBrakets )
+ {
+ // PageDesc ist fertig, setze am Doc
+ pPgFmt->SetAttr( aLR );
+ pPgFmt->SetAttr( aUL );
+ pPgFmt->SetAttr( aSz );
+ ::lcl_SetFmtCol( *pPgFmt, nCols, nColSpace, aColumns );
+ if( pPgFmt->GetHeader().GetHeaderFmt() )
+ {
+ SwFrmFmt* pHFmt = (SwFrmFmt*)pPgFmt->GetHeader().GetHeaderFmt();
+ pHFmt->SetAttr( aHUL );
+ pHFmt->SetAttr( aHLR );
+ pHFmt->SetAttr( aHSz );
+ }
+ if( pPgFmt->GetFooter().GetFooterFmt() )
+ {
+ SwFrmFmt* pFFmt = (SwFrmFmt*)pPgFmt->GetFooter().GetFooterFmt();
+ pFFmt->SetAttr( aHUL );
+ pFFmt->SetAttr( aHLR );
+ pFFmt->SetAttr( aHSz );
+ }
+ pDoc->ChgPageDesc( nPos++, *pPg );
+ }
+ break;
+
+ case RTF_PGDSC:
+ if( nPos) // kein && wg MAC
+ if (nPos != pDoc->MakePageDesc(
+ String::CreateFromInt32( nTokenValue ) ) )
+ ASSERT( FALSE, "PageDesc an falscher Position" );
+
+ pPg = &pDoc->_GetPageDesc( nPos );
+ pPg->SetLandscape( FALSE );
+ pPgFmt = &pPg->GetMaster();
+#ifndef CFRONT
+ SETPAGEDESC_DEFAULTS:
+#endif
+ // aSz = pPgFmt->GetFrmSize();
+ aSz.SetWidth( 11905 ); aSz.SetHeight( 16837 ); // DIN A4 defaulten
+ aLR.SetLeft( 0 ); aLR.SetRight( 0 );
+ aUL.SetLower( 0 ); aUL.SetUpper( 0 );
+ aHLR.SetLeft( 0 ); aHLR.SetRight( 0 );
+ aHUL.SetLower( 0 ); aHUL.SetUpper( 0 );
+ aFLR.SetLeft( 0 ); aFLR.SetRight( 0 );
+ aFUL.SetLower( 0 ); aFUL.SetUpper( 0 );
+ nCols = USHRT_MAX; nColSpace = USHRT_MAX; nAktCol = 0;
+ aFSz.SetSizeType( ATT_MIN_SIZE ); aFSz.SetHeight( 0 );
+ aHSz.SetSizeType( ATT_MIN_SIZE ); aHSz.SetHeight( 0 );
+ break;
+
+ case RTF_PGDSCUSE:
+ pPg->WriteUseOn( (UseOnPage)nTokenValue );
+ break;
+
+ case RTF_PGDSCNXT:
+ // setze erstmal nur die Nummer als Follow. Am Ende der
+ // Tabelle wird diese entsprechend korrigiert !!
+ if( nTokenValue )
+ pPg->SetFollow( (const SwPageDesc*)nTokenValue );
+ else
+ pPg->SetFollow( &pDoc->GetPageDesc( 0 ) );
+ break;
+
+ case RTF_FORMULA: /* Zeichen "\|" !!! */
+ pPgFmt->SetAttr( aLR );
+ pPgFmt->SetAttr( aUL );
+ pPgFmt->SetAttr( aSz );
+ ::lcl_SetFmtCol( *pPgFmt, nCols, nColSpace, aColumns );
+ if( pPgFmt->GetHeader().GetHeaderFmt() )
+ {
+ SwFrmFmt* pHFmt = (SwFrmFmt*)pPgFmt->GetHeader().GetHeaderFmt();
+ pHFmt->SetAttr( aHUL );
+ pHFmt->SetAttr( aHLR );
+ pHFmt->SetAttr( aHSz );
+ }
+ if( pPgFmt->GetFooter().GetFooterFmt() )
+ {
+ SwFrmFmt* pFFmt = (SwFrmFmt*)pPgFmt->GetFooter().GetFooterFmt();
+ pFFmt->SetAttr( aHUL );
+ pFFmt->SetAttr( aHLR );
+ pFFmt->SetAttr( aHSz );
+ }
+
+ pPgFmt = &pPg->GetLeft();
+#ifndef CFRONT
+ goto SETPAGEDESC_DEFAULTS;
+#else
+ aLR.SetLeft( 0 ); aLR.SetRight( 0 );
+ aUL.SetLower( 0 ); aUL.SetUpper( 0 );
+ aHLR.SetLeft( 0 ); aHLR.SetRight( 0 );
+ aHUL.SetLower( 0 ); aHUL.SetUpper( 0 );
+ aFLR.SetLeft( 0 ); aFLR.SetRight( 0 );
+ aFUL.SetLower( 0 ); aFUL.SetUpper( 0 );
+// aSz = pPgFmt->GetFrmSize();
+ aSz.SetWidth( 11905 ); aSz.SetHeight( 16837 ); // DIN A4 defaulten
+ nCols = USHRT_MAX; nColSpace = USHRT_MAX; nAktCol = 0;
+ aFSz.SetSizeType( ATT_MIN_SIZE ); aFSz.SetHeight( 0 );
+ aHSz.SetSizeType( ATT_MIN_SIZE ); aHSz.SetHeight( 0 );
+ break;
+#endif
+
+ // alt: LI/RI/SA/SB, neu: MARG?SXN
+ case RTF_MARGLSXN:
+ case RTF_LI: aLR.SetLeft( (USHORT)nTokenValue ); break;
+ case RTF_MARGRSXN:
+ case RTF_RI: aLR.SetRight( (USHORT)nTokenValue ); break;
+ case RTF_MARGTSXN:
+ case RTF_SA: aUL.SetUpper( (USHORT)nTokenValue ); break;
+ case RTF_MARGBSXN:
+ case RTF_SB: aUL.SetLower( (USHORT)nTokenValue ); break;
+ case RTF_PGWSXN: aSz.SetWidth( nTokenValue ); break;
+ case RTF_PGHSXN: aSz.SetHeight( nTokenValue ); break;
+
+ case RTF_HEADERY: aHUL.SetUpper( (USHORT)nTokenValue ); break;
+ case RTF_HEADER_YB: aHUL.SetLower( (USHORT)nTokenValue ); break;
+ case RTF_HEADER_XL: aHLR.SetLeft( (USHORT)nTokenValue ); break;
+ case RTF_HEADER_XR: aHLR.SetRight( (USHORT)nTokenValue ); break;
+ case RTF_FOOTERY: aFUL.SetLower( (USHORT)nTokenValue ); break;
+ case RTF_FOOTER_YT: aFUL.SetUpper( (USHORT)nTokenValue ); break;
+ case RTF_FOOTER_XL: aFLR.SetLeft( (USHORT)nTokenValue ); break;
+ case RTF_FOOTER_XR: aFLR.SetRight( (USHORT)nTokenValue ); break;
+
+ case RTF_HEADER_YH:
+ if( 0 > nTokenValue )
+ {
+ aHSz.SetSizeType( ATT_FIX_SIZE );
+ nTokenValue = -nTokenValue;
+ }
+ aHSz.SetHeight( (USHORT)nTokenValue );
+ break;
+
+ case RTF_FOOTER_YH:
+ if( 0 > nTokenValue )
+ {
+ aFSz.SetSizeType( ATT_FIX_SIZE );
+ nTokenValue = -nTokenValue;
+ }
+ aFSz.SetHeight( (USHORT)nTokenValue );
+ break;
+
+
+ case RTF_LNDSCPSXN: pPg->SetLandscape( TRUE ); break;
+
+ case RTF_COLS: nCols = (USHORT)nTokenValue; break;
+ case RTF_COLSX: nColSpace = (USHORT)nTokenValue; break;
+
+ case RTF_COLNO:
+ nAktCol = (USHORT)nTokenValue;
+ if( RTF_COLW == GetNextToken() )
+ {
+ USHORT nWidth = USHORT( nTokenValue ), nSpace = 0;
+ if( RTF_COLSR == GetNextToken() )
+ nSpace = USHORT( nTokenValue );
+ else
+ SkipToken( -1 ); // wieder zurueck
+
+ if( --nAktCol == ( aColumns.Count() / 2 ) )
+ {
+ aColumns.Insert( nWidth, aColumns.Count() );
+ aColumns.Insert( nSpace, aColumns.Count() );
+ }
+ }
+ break;
+
+ case RTF_PAGEBB:
+ {
+ pPgFmt->SetAttr( SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ) );
+ }
+ break;
+
+ case RTF_HEADER:
+ case RTF_HEADERL:
+ case RTF_HEADERR:
+ case RTF_FOOTER:
+ case RTF_FOOTERL:
+ case RTF_FOOTERR:
+ case RTF_FOOTERF:
+ case RTF_HEADERF:
+ ReadHeaderFooter( nToken, pPg );
+
+ --nOpenBrakets; // Klammer wird im ReadAttr ueberlesen!
+ break;
+
+
+ case RTF_TEXTTOKEN:
+ if( !DelCharAtEnd( aToken, ';' ).Len() )
+ break;
+ pPg->SetName( aToken );
+
+ {
+ // sollte es eine Vorlage aus dem Pool sein ??
+ USHORT n = pDoc->GetPoolId( aToken, GET_POOLID_PAGEDESC );
+ if( USHRT_MAX != n )
+ // dann setze bei der Neuen die entsp. PoolId
+ pPg->SetPoolFmtId( n );
+ }
+ break;
+
+ case RTF_BRDBOX:
+ if( 3 == nOpenBrakets )
+ {
+ ReadBorderAttr( SkipToken( -2 ), (SfxItemSet&)pPgFmt->GetAttrSet() );
+ --nOpenBrakets; // Klammer wird im ReadAttr ueberlesen!
+ }
+ break;
+
+ case RTF_SHADOW:
+ if( 3 == nOpenBrakets )
+ {
+ ReadAttr( SkipToken( -2 ), (SfxItemSet*)&pPgFmt->GetAttrSet() );
+ --nOpenBrakets; // Klammer wird im ReadAttr ueberlesen!
+ }
+ break;
+
+
+ default:
+ if( (nToken & ~0xff ) == RTF_SHADINGDEF )
+ ReadBackgroundAttr( nToken, (SfxItemSet&)pPgFmt->GetAttrSet() );
+ break;
+ }
+ }
+
+
+ // setze jetzt noch bei allen die entsprechenden Follows !!
+ // Die, die ueber die Tabelle eingelesen wurden und einen
+ // Follow definiert haben, ist dieser als Tabposition im
+ // Follow schon gesetzt.
+ for( nPos = 0; nPos < pDoc->GetPageDescCnt(); ++nPos )
+ {
+ SwPageDesc* pPgDsc = &pDoc->_GetPageDesc( nPos );
+ if( (USHORT)(long)pPgDsc->GetFollow() < pDoc->GetPageDescCnt() )
+ pPgDsc->SetFollow( &pDoc->GetPageDesc(
+ (USHORT)(long)pPgDsc->GetFollow() ));
+ }
+
+ SetChkStyleAttr( bSaveChkStyleAttr );
+
+ bInPgDscTbl = FALSE;
+ nAktPageDesc = 0;
+ nAktFirstPageDesc = 0;
+ bSwPageDesc = TRUE;
+ SkipToken( -1 );
+}
+
+// -------------- Methoden --------------------
+
+/*
+void SwRTFParser::ReadUnknownData()
+{
+ SvRTFParser::ReadUnknownData();
+}
+
+void SwRTFParser::ReadOLEData()
+{
+ SvRTFParser::ReadOLEData();
+}
+*/
+
+void SwRTFParser::ReadPrtData()
+{
+ // der Eingabe Stream steht auf der aktuellen Position
+ USHORT nLen = USHORT( nTokenValue ), nCnt = 0;
+ BYTE * pData = new BYTE[ nLen ];
+
+ while( IsParserWorking() ) // lese bis zur schliessenden Klammer
+ {
+ int nToken = GetNextToken();
+ if( RTF_TEXTTOKEN == nToken )
+ {
+ xub_StrLen nTknLen = HexToBin( aToken );
+ if( STRING_NOTFOUND != nTknLen )
+ {
+ memcpy( pData + nCnt, (sal_Char*)aToken.GetBuffer(), nTknLen );
+ nCnt += nTknLen;
+ }
+ }
+ else if( '}' == nToken )
+ break;
+ }
+
+/*-----------------25.10.94 16:37-------------------
+!!! OK 25.10.94 16:37
+ // um Byte-Dreher (Mac/Unix/Win) bei der Laenge auszuschliessen,
+ // setze hier expliziet die Laenge.
+ ((JobSetup*)pData)->nLen = nLen;
+
+ // so, jetzt sind alle Daten gelesen, setze den Bitsack am Document
+ // dieser kopiert die Daten !!
+ pDoc->SetJobsetup( (JobSetup*)pData );
+ delete pData;
+--------------------------------------------------*/
+ SkipToken( -1 ); // schliessende Klammer wieder zurueck!!
+}
+
+static const SwNodeIndex* SetHeader(SwFrmFmt* pHdFtFmt, BOOL bCheck )
+{
+ SwFrmFmt* pTmp = pHdFtFmt;
+ pHdFtFmt = bCheck ? (SwFrmFmt*)pHdFtFmt->GetHeader().GetHeaderFmt() : 0;
+ if( !pHdFtFmt )
+ {
+ // noch keine Header, dann erzeuge einen. Ob die Kopf/Fuss-
+ // zeilen angezeigt werden, bestimmen \header? \footer? ...
+ pTmp->SetAttr( SwFmtHeader( TRUE ));
+ pHdFtFmt = (SwFrmFmt*)pTmp->GetHeader().GetHeaderFmt();
+ }
+ return pHdFtFmt->GetCntnt().GetCntntIdx();
+}
+
+static const SwNodeIndex* SetFooter(SwFrmFmt* pHdFtFmt, BOOL bCheck)
+{
+ SwFrmFmt* pTmp = pHdFtFmt;
+ pHdFtFmt = bCheck ? (SwFrmFmt*)pHdFtFmt->GetFooter().GetFooterFmt() : 0;
+ if( !pHdFtFmt )
+ {
+ // noch keine Header, dann erzeuge einen. Ob die Kopf/Fuss-
+ // zeilen angezeigt werden, bestimmen \header? \footer? ...
+ pTmp->SetAttr( SwFmtFooter( TRUE ));
+ pHdFtFmt = (SwFrmFmt*)pTmp->GetFooter().GetFooterFmt();
+ }
+ return pHdFtFmt->GetCntnt().GetCntntIdx();
+}
+
+
+void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc )
+{
+ ASSERT( RTF_FOOTNOTE == nToken ||
+ RTF_FLY_INPARA == nToken ||
+ pPageDesc, "PageDesc fehlt" );
+
+ // alle wichtigen Sachen sichern
+ SwPosition aSavePos( *pPam->GetPoint() );
+ SvxRTFItemStack aSaveStack;
+ aSaveStack.Insert( &GetAttrStack(), 0 );
+ GetAttrStack().Remove( 0, GetAttrStack().Count() );
+
+ // save the fly array - after read, all flys may be set into
+ // the header/footer
+ SwFlySaveArr aSaveArray( 255 < aFlyArr.Count() ? aFlyArr.Count() : 255 );
+ aSaveArray.Insert( &aFlyArr, 0 );
+ aFlyArr.Remove( 0, aFlyArr.Count() );
+ BOOL bSetFlyInDoc = TRUE;
+
+ const SwNodeIndex* pSttIdx = 0;
+ SwFrmFmt* pHdFtFmt = 0;
+ SwTxtAttr* pTxtAttr = 0;
+ int bDelFirstChar = FALSE, bIsFootnote = FALSE;
+ BOOL bOldGrpStt = IsNewGroup();
+
+ int nOpenBrakets = GetOpenBrakets() - 1;
+
+ switch( nToken )
+ {
+ case RTF_FOOTNOTE:
+ {
+ BOOL bIsEndNote = RTF_FTNALT == GetNextToken();
+ if( !bIsEndNote )
+ SkipToken( -1 );
+
+ SwTxtNode* pTxtNd = pPam->GetNode()->GetTxtNode();
+ SwFmtFtn aFtnNote( bIsEndNote );
+ xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
+
+ if( nPos && !bFootnoteAutoNum )
+ {
+ pPam->GetPoint()->nContent--;
+ nPos--;
+ aFtnNote.SetNumStr( pTxtNd->GetTxt().GetChar( nPos ) );
+ ((String&)pTxtNd->GetTxt()).SetChar( nPos, CH_TXTATR_INWORD );
+ bDelFirstChar = TRUE;
+ }
+
+ pTxtAttr = pTxtNd->Insert( aFtnNote, nPos, nPos,
+ bDelFirstChar ? SETATTR_NOTXTATRCHR : 0 );
+
+ ASSERT( pTxtAttr, "konnte die Fussnote nicht einfuegen/finden" );
+
+ if( pTxtAttr )
+ pSttIdx = ((SwTxtFtn*)pTxtAttr)->GetStartNode();
+ bIsFootnote = TRUE;
+
+ // wurde an der Position ein Escapement aufgespannt, so entferne
+ // das jetzt. Fussnoten sind bei uns immer hochgestellt.
+ SvxRTFItemStackTypePtr pTmp = aSaveStack.Top();
+ if( pTmp && pTmp->GetSttNodeIdx() ==
+ pPam->GetPoint()->nNode.GetIndex() &&
+ pTmp->GetSttCnt() == nPos )
+ pTmp->GetAttrSet().ClearItem( RES_CHRATR_ESCAPEMENT );
+ }
+ break;
+
+ case RTF_FLY_INPARA:
+ {
+ xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
+ RES_FRMATR_END-1 );
+ aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ));
+ pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet );
+
+ pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttr(
+ nPos, RES_TXTATR_FLYCNT );
+ ASSERT( pTxtAttr, "konnte den Fly nicht einfuegen/finden" );
+
+ pSttIdx = pHdFtFmt->GetCntnt().GetCntntIdx();
+ bSetFlyInDoc = FALSE;
+ }
+ break;
+
+ case RTF_HEADERF:
+ case RTF_HEADER:
+ pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() | PD_HEADERSHARE) );
+ pHdFtFmt = &pPageDesc->GetMaster();
+ pSttIdx = SetHeader( pHdFtFmt, FALSE );
+ break;
+
+ case RTF_HEADERL:
+ // wir koennen keine linken oder rechten haben, immer beide
+ pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() & ~PD_HEADERSHARE) );
+ SetHeader( pPageDesc->GetRightFmt(), TRUE );
+ pHdFtFmt = pPageDesc->GetLeftFmt();
+ pSttIdx = SetHeader(pHdFtFmt, FALSE );
+ break;
+
+ case RTF_HEADERR:
+ // wir koennen keine linken oder rechten haben, immer beide
+ pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() & ~PD_HEADERSHARE) );
+ SetHeader( pPageDesc->GetLeftFmt(), TRUE );
+ pHdFtFmt = pPageDesc->GetRightFmt();
+ pSttIdx = SetHeader(pHdFtFmt, FALSE );
+ break;
+
+ case RTF_FOOTERF:
+ case RTF_FOOTER:
+ pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() | PD_FOOTERSHARE) );
+ pHdFtFmt = &pPageDesc->GetMaster();
+ pSttIdx = SetFooter(pHdFtFmt, FALSE );
+ break;
+
+ case RTF_FOOTERL:
+ // wir koennen keine linken oder rechten haben, immer beide
+ pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() & ~PD_FOOTERSHARE) );
+ SetFooter( pPageDesc->GetRightFmt(), TRUE );
+ pHdFtFmt = pPageDesc->GetLeftFmt();
+ pSttIdx = SetFooter(pHdFtFmt, FALSE );
+ break;
+
+ case RTF_FOOTERR:
+ // wir koennen keine linken oder rechten haben, immer beide
+ pPageDesc->WriteUseOn( (UseOnPage)(pPageDesc->ReadUseOn() & ~PD_FOOTERSHARE) );
+ SetFooter( pPageDesc->GetLeftFmt(), TRUE );
+ pHdFtFmt = pPageDesc->GetRightFmt();
+ pSttIdx = SetFooter(pHdFtFmt, FALSE );
+ break;
+ }
+
+ if( !pSttIdx )
+ SkipGroup();
+ else
+ {
+ // es ist auf jedenfall jetzt ein TextNode im Kopf/Fusszeilen-Bereich
+ // vorhanden. Dieser muss jetzt nur noch gefunden und der neue Cursor
+ // dort hinein gesetzt werden.
+ SwCntntNode *pNode = pDoc->GetNodes()[ pSttIdx->GetIndex()+1 ]->
+ GetCntntNode();
+
+ // immer ans Ende der Section einfuegen !!
+ pPam->GetPoint()->nNode = *pNode->EndOfSectionNode();
+ pPam->Move( fnMoveBackward );
+
+ SetNewGroup( TRUE );
+
+ while( !( nOpenBrakets == GetOpenBrakets() && !GetStackPos()) && IsParserWorking() )
+ {
+ switch( nToken = GetNextToken() )
+ {
+ case RTF_U:
+ if( bDelFirstChar )
+ {
+ bDelFirstChar = FALSE;
+ nToken = 0;
+ }
+ break;
+
+ case RTF_TEXTTOKEN:
+ if( bDelFirstChar )
+ {
+ if( !aToken.Erase( 0, 1 ).Len() )
+ nToken = 0;
+ bDelFirstChar = FALSE;
+ }
+ break;
+ }
+ if( nToken )
+ NextToken( nToken );
+ }
+
+ SetAllAttrOfStk();
+ if( aFlyArr.Count() && bSetFlyInDoc )
+ SetFlysInDoc();
+
+ // sollte der letze Node leer sein, dann loesche ihn
+ // (\par heisst ja Absatzende und nicht neuer Absatz!)
+ DelLastNode();
+ }
+
+ // vom FlyFmt noch die richtigen Attribute setzen
+ if( pTxtAttr && RES_TXTATR_FLYCNT == pTxtAttr->Which() )
+ {
+ ASSERT( aFlyArr.Count(), "kein Fly definiert" );
+ SwFlySave* pFlySave = aFlyArr[ aFlyArr.Count()-1 ];
+ pFlySave->aFlySet.ClearItem( RES_ANCHOR );
+ pHdFtFmt->SetAttr( pFlySave->aFlySet );
+ aFlyArr.DeleteAndDestroy( aFlyArr.Count() - 1 );
+ }
+
+ bFootnoteAutoNum = FALSE; // default auf aus!
+
+ // und alles wieder zurueck
+ *pPam->GetPoint() = aSavePos;
+ if( bIsFootnote )
+ SetNewGroup( bOldGrpStt ); // Status wieder zurueck
+ else
+ SetNewGroup( FALSE ); // { - Klammer war kein Group-Start!
+ GetAttrStack().Insert( &aSaveStack, 0 );
+
+ aFlyArr.Insert( &aSaveArray, 0 );
+ aSaveArray.Remove( 0, aSaveArray.Count() );
+}
+
+void SwRTFParser::SetSwgValues( SfxItemSet& rSet )
+{
+ const SfxPoolItem* pItem;
+ // Escapement korrigieren
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_ESCAPEMENT, FALSE, &pItem ))
+ {
+ /* prozentuale Veraenderung errechnen !
+ * Formel : (FontSize * 1/20 ) pts Escapement * 2
+ * ----------------------- = ----------------
+ * 100% x
+ */
+
+ // die richtige
+ long nEsc = ((SvxEscapementItem*)pItem)->GetEsc();
+
+ // automatische Ausrichtung wurde schon richtig berechnet
+ if( DFLT_ESC_AUTO_SUPER != nEsc && DFLT_ESC_AUTO_SUB != nEsc )
+ {
+ const SvxFontHeightItem& rFH = GetSize( rSet );
+ nEsc *= 1000L;
+ nEsc /= long(rFH.GetHeight());
+
+ SvxEscapementItem aEsc( (short) nEsc,
+ ((SvxEscapementItem*)pItem)->GetProp());
+ rSet.Put( aEsc );
+ }
+ }
+
+ // TabStops anpassen
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, FALSE, &pItem ))
+ {
+ const SvxLRSpaceItem& rLR = GetLRSpace( rSet );
+ SvxTabStopItem aTStop( *(SvxTabStopItem*)pItem );
+
+ register long nOffset = rLR.GetTxtLeft();
+ if( nOffset )
+ {
+ // Tabs anpassen !!
+ SvxTabStop* pTabs = (SvxTabStop*)aTStop.GetStart();
+ for( USHORT n = aTStop.Count(); n; --n, ++pTabs)
+ if( SVX_TAB_ADJUST_DEFAULT != pTabs->GetAdjustment() )
+ pTabs->GetTabPos() -= nOffset;
+
+ // negativer Einzug, dann auf 0 Pos einen Tab setzen
+ if( rLR.GetTxtFirstLineOfst() < 0 )
+ aTStop.Insert( SvxTabStop() );
+ }
+
+ if( !aTStop.Count() )
+ {
+ const SvxTabStopItem& rDflt = (const SvxTabStopItem&)rSet.
+ GetPool()->GetDefaultItem(RES_PARATR_TABSTOP);
+ if( rDflt.Count() )
+ aTStop.Insert( &rDflt, 0 );
+ }
+ rSet.Put( aTStop );
+ }
+ else if( SFX_ITEM_SET == rSet.GetItemState( RES_LR_SPACE, FALSE, &pItem )
+ && ((SvxLRSpaceItem*)pItem)->GetTxtFirstLineOfst() < 0 )
+ {
+ // negativer Einzug, dann auf 0 Pos einen Tab setzen
+ rSet.Put( SvxTabStopItem( 1, 0 ));
+ }
+
+ // NumRules anpassen
+ if( !bStyleTabValid &&
+ SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, FALSE, &pItem ))
+ {
+ // dann steht im Namen nur ein Verweis in das ListArray
+ SwNumRule* pRule = GetNumRuleOfListNo( ((SwNumRuleItem*)pItem)->
+ GetValue().ToInt32() );
+ if( pRule )
+ rSet.Put( SwNumRuleItem( pRule->GetName() ));
+ else
+ rSet.ClearItem( RES_PARATR_NUMRULE );
+ }
+
+
+/*
+ ????????????????????????????????????????????????????????????????????
+ ?? muss die LineSpacing Hoehe 200Twip betragen ??
+ ?? in rtfitem.hxx wird es auf 0 defaultet. Wenn ja, dann muss hier
+ ?? ein neues Item gesetzt werden!!!!
+ ????????????????????????????????????????????????????????????????????
+
+ // LineSpacing korrigieren
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_LINESPACING, FALSE, &pItem ))
+ {
+ const SvxLineSpacingItem* pLS = (const SvxLineSpacingItem*)pItem;
+ SvxLineSpacingItem aNew;
+
+ aNew.SetInterLineSpace( pLS->GetInterLineSpace() );
+ aNew.GetLineSpaceRule() = pLS->GetLineSpaceRule();
+ aNew.SetPropLineSpace( pLS->GetPropLineSpace() );
+ aNew.GetInterLineSpaceRule() = pLS->GetInterLineSpaceRule();
+
+ rSet.Put( aNew );
+ }
+?????????????????????????????????????????????????????????????????? */
+
+}
+
+
+SwTxtFmtColl* SwRTFParser::MakeColl( const String& rName, USHORT nPos,
+ BYTE nOutlineLevel, int& rbCollExist )
+{
+ if( BYTE(-1) == nOutlineLevel )
+ nOutlineLevel = NO_NUMBERING;
+
+ rbCollExist = FALSE;
+ SwTxtFmtColl* pColl;
+ String aNm( rName );
+ if( !aNm.Len() )
+ {
+ if( !nPos )
+ {
+ pColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pColl->SetOutlineLevel( nOutlineLevel );
+ return pColl;
+ }
+
+ aNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NoName(" )); // erzeuge einen Namen
+ aNm += String::CreateFromInt32( nPos );
+ aNm += ')';
+ }
+
+ // suche jetzt nach einem Style mit dem gleichen Namen (0=dflt. FmtColl)
+ if( 0 != (pColl = pDoc->FindTxtFmtCollByName( aNm ) ) )
+ {
+ // neues Doc: keine alten Attribute behalten !!
+ if( IsNewDoc() )
+ {
+ pColl->ResetAllAttr();
+ pColl->SetOutlineLevel( nOutlineLevel );
+ }
+ else
+ rbCollExist = TRUE;
+ return pColl;
+ }
+
+ // Collection neu erzeugen
+ pColl = pDoc->MakeTxtFmtColl( aNm,
+ pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
+
+ // sollte es eine Vorlage aus dem Pool sein ??
+ USHORT n = pDoc->GetPoolId( aNm, GET_POOLID_TXTCOLL );
+ if( USHRT_MAX != n )
+ // dann setze bei der Neuen die entsp. PoolId
+ pColl->SetPoolFmtId( n );
+
+ pColl->SetOutlineLevel( nOutlineLevel );
+ return pColl;
+}
+
+SwCharFmt* SwRTFParser::MakeCharFmt( const String& rName, USHORT nPos,
+ int& rbCollExist )
+{
+ rbCollExist = FALSE;
+ SwCharFmt* pFmt;
+ String aNm( rName );
+ if( !aNm.Len() )
+ {
+ aNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NoName(" ));
+ aNm += String::CreateFromInt32( nPos );
+ aNm += ')';
+ }
+
+ // suche jetzt nach einem Style mit dem gleichen Namen (0=dflt. FmtColl)
+ if( 0 != (pFmt = pDoc->FindCharFmtByName( aNm ) ) )
+ {
+ // neues Doc: keine alten Attribute behalten !!
+ if( IsNewDoc() )
+ pFmt->ResetAllAttr();
+ else
+ rbCollExist = TRUE;
+ return pFmt;
+ }
+
+ // Format neu erzeugen
+ pFmt = pDoc->MakeCharFmt( aNm, pDoc->GetDfltCharFmt() );
+
+ // sollte es eine Vorlage aus dem Pool sein ??
+ USHORT n = pDoc->GetPoolId( aNm, GET_POOLID_CHRFMT );
+ if( USHRT_MAX != n )
+ // dann setze bei der Neuen die entsp. PoolId
+ pFmt->SetPoolFmtId( n );
+
+ return pFmt;
+}
+
+void SwRTFParser::SetStyleAttr( SfxItemSet& rCollSet,
+ const SfxItemSet& rStyleSet,
+ const SfxItemSet& rDerivedSet )
+{
+ rCollSet.Put( rStyleSet );
+ if( rDerivedSet.Count() )
+ {
+ // suche alle Attribute, die neu gesetzt werden:
+ const SfxPoolItem* pItem;
+ SfxItemIter aIter( rDerivedSet );
+ USHORT nWhich = aIter.GetCurItem()->Which();
+ while( TRUE )
+ {
+ switch( rStyleSet.GetItemState( nWhich, FALSE, &pItem ) )
+ {
+ case SFX_ITEM_DEFAULT:
+ // auf default zuruecksetzen
+ if( RES_FRMATR_END > nWhich )
+ rCollSet.Put( rCollSet.GetPool()->GetDefaultItem( nWhich ));
+ break;
+ case SFX_ITEM_SET:
+ if( *pItem == *aIter.GetCurItem() ) // gleiches Attribut?
+ // definition kommt aus dem Parent
+ rCollSet.ClearItem( nWhich ); // loeschen
+ break;
+ }
+
+ if( aIter.IsAtEnd() )
+ break;
+ nWhich = aIter.NextItem()->Which();
+ }
+ }
+ // und jetzt noch auf unsere Werte abgleichen
+ SetSwgValues( rCollSet );
+}
+
+SwTxtFmtColl* SwRTFParser::MakeStyle( USHORT nNo, const SvxRTFStyleType& rStyle )
+{
+ int bCollExist;
+ SwTxtFmtColl* pColl = MakeColl( rStyle.sName, USHORT(nNo),
+ rStyle.nOutlineNo, bCollExist );
+ aTxtCollTbl.Insert( nNo, pColl );
+
+ // in bestehendes Dok einfuegen, dann keine Ableitung usw. setzen
+ if( bCollExist )
+ return pColl;
+
+ USHORT nStyleNo = rStyle.nBasedOn;
+ if( nStyleNo != nNo )
+ {
+ SvxRTFStyleType* pDerivedStyle = GetStyleTbl().Get( nStyleNo );
+ SwTxtFmtColl* pDerivedColl = aTxtCollTbl.Get( nStyleNo );
+ if( !pDerivedColl ) // noch nicht vorhanden, also anlegen
+ {
+ // ist die ueberhaupt als Style vorhanden ?
+ pDerivedColl = pDerivedStyle
+ ? MakeStyle( nStyleNo, *pDerivedStyle )
+ : pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ }
+
+ if( pColl == pDerivedColl )
+ ((SfxItemSet&)pColl->GetAttrSet()).Put( rStyle.aAttrSet );
+ else
+ {
+ pColl->SetDerivedFrom( pDerivedColl );
+
+ // setze die richtigen Attribute
+ const SfxItemSet* pDerivedSet;
+ if( pDerivedStyle )
+ pDerivedSet = &pDerivedStyle->aAttrSet;
+ else
+ pDerivedSet = &pDerivedColl->GetAttrSet();
+
+ SetStyleAttr( (SfxItemSet&)pColl->GetAttrSet(),
+ rStyle.aAttrSet, *pDerivedSet );
+ }
+ }
+ else
+ ((SfxItemSet&)pColl->GetAttrSet()).Put( rStyle.aAttrSet );
+
+
+ nStyleNo = rStyle.nNext;
+ if( nStyleNo != nNo )
+ {
+ SwTxtFmtColl* pNext = aTxtCollTbl.Get( nStyleNo );
+ if( !pNext ) // noch nicht vorhanden, also anlegen
+ {
+ // ist die ueberhaupt als Style vorhanden ?
+ SvxRTFStyleType* pMkStyle = GetStyleTbl().Get( nStyleNo );
+ pNext = pMkStyle
+ ? MakeStyle( nStyleNo, *pMkStyle )
+ : pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ }
+ pColl->SetNextTxtFmtColl( *pNext );
+ }
+ return pColl;
+}
+
+SwCharFmt* SwRTFParser::MakeCharStyle( USHORT nNo, const SvxRTFStyleType& rStyle )
+{
+ int bCollExist;
+ SwCharFmt* pFmt = MakeCharFmt( rStyle.sName, USHORT(nNo), bCollExist );
+ aCharFmtTbl.Insert( nNo, pFmt );
+
+ // in bestehendes Dok einfuegen, dann keine Ableitung usw. setzen
+ if( bCollExist )
+ return pFmt;
+
+ USHORT nStyleNo = rStyle.nBasedOn;
+ if( nStyleNo != nNo )
+ {
+ SvxRTFStyleType* pDerivedStyle = GetStyleTbl().Get( nStyleNo );
+ SwCharFmt* pDerivedFmt = aCharFmtTbl.Get( nStyleNo );
+ if( !pDerivedFmt ) // noch nicht vorhanden, also anlegen
+ {
+ // ist die ueberhaupt als Style vorhanden ?
+ pDerivedFmt = pDerivedStyle
+ ? MakeCharStyle( nStyleNo, *pDerivedStyle )
+ : pDoc->GetDfltCharFmt();
+ }
+
+ if( pFmt == pDerivedFmt )
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( rStyle.aAttrSet );
+ else
+ {
+ pFmt->SetDerivedFrom( pDerivedFmt );
+
+ // setze die richtigen Attribute
+ const SfxItemSet* pDerivedSet;
+ if( pDerivedStyle )
+ pDerivedSet = &pDerivedStyle->aAttrSet;
+ else
+ pDerivedSet = &pDerivedFmt->GetAttrSet();
+
+ SetStyleAttr( (SfxItemSet&)pFmt->GetAttrSet(),
+ rStyle.aAttrSet, *pDerivedSet );
+ }
+ }
+ else
+ ((SfxItemSet&)pFmt->GetAttrSet()).Put( rStyle.aAttrSet );
+
+ return pFmt;
+}
+
+// loesche den letzten Node (Tabelle/Fly/Ftn/..)
+void SwRTFParser::DelLastNode()
+{
+ // sollte der letze Node leer sein, dann loesche ihn
+ // (\par heisst ja Absatzende und nicht neuer Absatz!)
+ if( !pPam->GetPoint()->nContent.GetIndex() )
+ {
+ ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
+ SwCntntNode* pCNd = pDoc->GetNodes()[ nNodeIdx ]->GetCntntNode();
+ if( pCNd && pCNd->StartOfSectionIndex()+2 <
+ pCNd->EndOfSectionIndex() )
+ {
+ if( GetAttrStack().Count() )
+ {
+ // Attribut Stack-Eintraege, muessen ans Ende des vorherigen
+ // Nodes verschoben werden.
+ BOOL bMove = FALSE;
+ for( USHORT n = GetAttrStack().Count(); n; )
+ {
+ SvxRTFItemStackType* pStkEntry = (SvxRTFItemStackType*)
+ GetAttrStack()[ --n ];
+ if( nNodeIdx == pStkEntry->GetSttNode().GetIdx() )
+ {
+ if( !bMove )
+ {
+ pPam->Move( fnMoveBackward );
+ bMove = TRUE;
+ }
+ pStkEntry->SetStartPos( SwxPosition( pPam ) );
+ }
+ }
+ if( bMove )
+ pPam->Move( fnMoveForward );
+ }
+ pPam->GetPoint()->nContent.Assign( 0, 0 );
+ pPam->SetMark();
+ pPam->DeleteMark();
+ pDoc->GetNodes().Delete( pPam->GetPoint()->nNode );
+ }
+ }
+}
+
+ // fuer Tokens, die im ReadAttr nicht ausgewertet werden
+void SwRTFParser::UnknownAttrToken( int nToken, SfxItemSet* pSet )
+{
+ switch( nToken )
+ {
+ case RTF_INTBL:
+ {
+ if( !pTableNode ) // Tabelle nicht mehr vorhanden ?
+ NewTblLine(); // evt. Line copieren
+ else
+ {
+ // Crsr nicht mehr in der Tabelle ?
+ if( !pPam->GetNode()->FindTableNode() )
+ {
+ ULONG nOldPos = pPam->GetPoint()->nNode.GetIndex();
+
+ // dann wieder in die letzte Box setzen
+ // (kann durch einlesen von Flys geschehen!)
+ pPam->GetPoint()->nNode = *pTableNode->EndOfSectionNode();
+ pPam->Move( fnMoveBackward );
+
+ // alle Attribute, die schon auf den nachfolgen zeigen
+ // auf die neue Box umsetzen !!
+ SvxRTFItemStack& rAttrStk = GetAttrStack();
+ const SvxRTFItemStackType* pStk;
+ for( USHORT n = 0; n < rAttrStk.Count(); ++n )
+ if( ( pStk = rAttrStk[ n ])->GetSttNodeIdx() == nOldPos &&
+ !pStk->GetSttCnt() )
+ ((SvxRTFItemStackType*)pStk)->SetStartPos( SwxPosition( pPam ) );
+ }
+ }
+ }
+ break;
+
+ case RTF_PAGEBB:
+ {
+ pSet->Put( SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ));
+ }
+ break;
+
+ case RTF_PGBRK:
+ {
+ pSet->Put( SvxFmtBreakItem( 1 == nTokenValue ?
+ SVX_BREAK_PAGE_BOTH : SVX_BREAK_PAGE_AFTER ));
+ }
+ break;
+
+ case RTF_PGDSCNO:
+ if( IsNewDoc() && bSwPageDesc &&
+ USHORT(nTokenValue) < pDoc->GetPageDescCnt() )
+ {
+ const SwPageDesc* pPgDsc = &pDoc->GetPageDesc( (USHORT)nTokenValue );
+ pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ));
+ }
+ break;
+
+ case RTF_V:
+ if( 0 != nTokenValue )
+ {
+ // alles ueberlesen bis dieses wieder abgeschaltet wird. Durch
+ // plain in der Gruppe oder durch V0
+ String sHiddenTxt;
+ int nOpenBrakets = 0;
+ int nOpenHiddens = 1;
+ do {
+ switch( nToken = GetNextToken() )
+ {
+ case '}':
+ if( !--nOpenBrakets /*&& IsNewGroup()*/ )
+ // die Klammer wird noch gebraucht!
+ SkipToken( -1 );
+ break;
+ case '{':
+ ++nOpenBrakets;
+ break;
+
+ case RTF_V:
+ if( nTokenValue )
+ ++nOpenHiddens;
+ else if( !--nOpenHiddens && 1 == nOpenBrakets )
+ // das wars
+ nOpenBrakets = 0;
+ break;
+
+ case RTF_U:
+ {
+ if( nTokenValue )
+ sHiddenTxt += (sal_Unicode)nTokenValue;
+ else
+ sHiddenTxt += aToken;
+ }
+ break;
+
+ case RTF_TEXTTOKEN:
+ sHiddenTxt += aToken;
+ break;
+
+ case RTF_PLAIN:
+ if( !nOpenHiddens && 1 == nOpenBrakets )
+ {
+ nOpenBrakets = 0;
+ SkipToken( -1 );
+ }
+ break;
+ }
+ } while( nOpenBrakets && IsParserWorking() );
+ if( sHiddenTxt.Len() )
+ {
+ SwHiddenTxtField aFld( (SwHiddenTxtFieldType*)
+ pDoc->GetSysFldType( RES_HIDDENTXTFLD ),
+ TRUE, aEmptyStr, sHiddenTxt, TRUE );
+
+ pDoc->Insert( *pPam, SwFmtFld( aFld ) );
+ }
+ }
+ break;
+
+ case RTF_CS:
+ {
+ SwCharFmt* pFmt = aCharFmtTbl.Get( nTokenValue );
+ if( pFmt )
+ pSet->Put( SwFmtCharFmt( pFmt ));
+ }
+ break;
+
+ case RTF_LS:
+ if( -1 != nTokenValue )
+ {
+ if( bStyleTabValid )
+ {
+ // dann ist auch die ListTabelle gueltig, also suche die
+ // enstprechende NumRule
+ SwNumRule* pRule = GetNumRuleOfListNo( nTokenValue );
+ if( pRule )
+ pSet->Put( SwNumRuleItem( pRule->GetName() ));
+
+ if( SFX_ITEM_SET != pSet->GetItemState( FN_PARAM_NUM_LEVEL, FALSE ))
+ pSet->Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, 0 ));
+ }
+ else
+ // wir sind in der Style-Definitions - Phase. Der Name
+ // wird dann spaeter umgesetzt
+ pSet->Put( SwNumRuleItem( String::CreateFromInt32( nTokenValue )));
+ }
+ break;
+
+ case RTF_ILVL:
+ case RTF_SOUTLVL:
+ {
+ BYTE nLevel = MAXLEVEL <= nTokenValue ? MAXLEVEL - 1
+ : BYTE( nTokenValue );
+ pSet->Put( SfxUInt16Item( FN_PARAM_NUM_LEVEL, nLevel ));
+ }
+ break;
+
+/*
+ case RTF_SBYS:
+ case RTF_EXPND:
+ case RTF_KEEP:
+ case RTF_KEEPN:
+*/
+
+
+ // Revision Time Stamp
+/* case RTF_REVDTTM:
+ {
+ USHORT nMin, nHour, nDay, nMon, nYear, nDayOfWeek;
+// long wird gelesen, wird haben aber nur einen short!!!
+ ULONG nDtm = aToken.Copy( 7 );
+ // 3 2 1 0
+ // 10987654321098765432109876543210
+ // DOW| Y | M | D | H | Min
+ //
+ nMin = 0x3F & ( nDtm >>= 0 );
+ nHour = 0x1f & ( nDtm >>= 6 );
+ nDay = 0x1f & ( nDtm >>= 5 );
+ nMon = 0x0F & ( nDtm >>= 5 );
+ nYear =(0x7F & ( nDtm >>= 4 )) + 1900;
+ nDayOfWeek = 0x07 & ( nDtm >>= 7 );
+
+ Time aTime( nHour, nMin );
+ Date aDate( nDay, nMon, nYear );
+ }
+ break;
+*/
+ }
+}
+
+void SwRTFParser::ReadInfo( const sal_Char* pChkForVerNo )
+{
+sal_Char __READONLY_DATA aChkForVerNo[] = "StarWriter";
+
+ // falls nicht schon was vorgegeben wurde, setzen wir unseren Namen
+ // rein. Wenn das im Kommentar match, wird im Parser die VersionNummer
+ // gelesen und gesetzt
+ if( !pChkForVerNo )
+ pChkForVerNo = aChkForVerNo;
+
+ SvxRTFParser::ReadInfo( pChkForVerNo );
+}
+
+
+#ifdef USED
+void SwRTFParser::SaveState( int nToken )
+{
+ SvxRTFParser::SaveState( nToken );
+}
+
+void SwRTFParser::RestoreState()
+{
+ SvxRTFParser::RestoreState();
+}
+#endif
+
+/* */
+
+ULONG SwNodeIdx::GetIdx() const
+{
+ return aIdx.GetIndex();
+}
+
+SvxNodeIdx* SwNodeIdx::Clone() const
+{
+ return new SwNodeIdx( aIdx );
+}
+
+SvxPosition* SwxPosition::Clone() const
+{
+ return new SwxPosition( pPam );
+}
+
+SvxNodeIdx* SwxPosition::MakeNodeIdx() const
+{
+ return new SwNodeIdx( pPam->GetPoint()->nNode );
+}
+
+ULONG SwxPosition::GetNodeIdx() const
+{
+ return pPam->GetPoint()->nNode.GetIndex();
+}
+
+xub_StrLen SwxPosition::GetCntIdx() const
+{
+ return pPam->GetPoint()->nContent.GetIndex();
+}
+
+
+/* */
+
+#ifdef DEBUG_JP
+
+#include <string.h> // fuer sprintf
+#include <stdio.h>
+#include <svx/cmapitem.hxx>
+#include <svx/colritem.hxx>
+#include <svx/cntritem.hxx>
+#include <svx/crsditem.hxx>
+#include <svx/fontitem.hxx>
+#include <svx/kernitem.hxx>
+#include <svx/langitem.hxx>
+#include <svx/postitem.hxx>
+#include <svx/shdditem.hxx>
+#include <svx/udlnitem.hxx>
+#include <svx/wghtitem.hxx>
+#include <svx/wrlmitem.hxx>
+#include <svx/adjitem.hxx>
+
+static SvFileStream* pOut = 0;
+static void OutAttr( const SfxItemSet& rSet )
+{
+ if( !rSet.Count() )
+ return;
+
+ char sOut[ 200 ];
+ SfxItemIter aIter( rSet );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ while( TRUE )
+ {
+ sOut[0] = 0;
+ switch( pItem->Which() )
+ {
+ case RES_CHRATR_CASEMAP:
+ {
+ sprintf( sOut,
+ "CaseMap: Style[%d]",
+ ((const SvxCaseMapItem*)pItem)->GetValue() );
+ }
+ break;
+ case RES_CHRATR_COLOR:
+ {
+ sprintf( sOut,
+ "Color: Red[%d] Green[%d] Blue[%d]",
+ ((const SvxColorItem*)pItem)->GetValue().GetRed(),
+ ((const SvxColorItem*)pItem)->GetValue().GetGreen(),
+ ((const SvxColorItem*)pItem)->GetValue().GetBlue() );
+ }
+ break;
+
+ case RES_CHRATR_CONTOUR:
+ {
+ sprintf( sOut,
+ "Contour: Style[%s]",
+ ( ((const SvxContourItem*)pItem)->GetValue() ? "ON" : "OFF" ) );
+ }
+ break;
+ case RES_CHRATR_CROSSEDOUT:
+ {
+ sprintf( sOut,
+ "CrossedOut: Style[%d]",
+ ((const SvxCrossedOutItem*)pItem)->GetValue() );
+ }
+ break;
+ case RES_CHRATR_ESCAPEMENT:
+ {
+ sprintf( sOut,
+ "Escapement: Style[%d, %d]",
+ ((const SvxEscapementItem*)pItem)->GetEsc(),
+ ((const SvxEscapementItem*)pItem)->GetProp() );
+ }
+ break;
+ case RES_CHRATR_FONT:
+ {
+ const SvxFontItem& rFont = *(const SvxFontItem*)pItem;
+ sprintf( sOut,
+ "Font: Fam[%d] Nm[%s] Pitch[%d] CharSet[%d]",
+ rFont.GetFamily(),
+ rFont.GetFamilyName().GetStr(),
+ rFont.GetPitch(),
+ rFont.GetCharSet() );
+ }
+ break;
+ case RES_CHRATR_FONTSIZE:
+ {
+ sprintf( sOut,
+ "FontSize: Height[%d]",
+ ((const SvxFontHeightItem*)pItem)->GetHeight() );
+ }
+ break;
+ case RES_CHRATR_KERNING:
+ {
+ sprintf( sOut,
+ "Kerning: Style[%d]",
+ ((const SvxKerningItem*)pItem)->GetValue() );
+ }
+ break;
+ case RES_CHRATR_LANGUAGE:
+ {
+ sprintf( sOut,
+ "Language: Style[%d]",
+ ((const SvxLanguageItem*)pItem)->GetValue() );
+ }
+ break;
+ case RES_CHRATR_POSTURE:
+ {
+ sprintf( sOut,
+ "Posture: Style[%d]",
+ ((const SvxPostureItem*)pItem)->GetValue() );
+ }
+ break;
+
+ case RES_CHRATR_SHADOWED:
+ {
+ sprintf( sOut,
+ "Shadowed: Style[%s]",
+ ( ((const SvxShadowedItem*)pItem)->GetValue() ? "ON" : "OFF" ) );
+ }
+ break;
+
+ case RES_CHRATR_UNDERLINE:
+ {
+ sprintf( sOut,
+ "Underline: Style[%d]",
+ ((const SvxUnderlineItem*)pItem)->GetValue() );
+ }
+ break;
+ case RES_CHRATR_WEIGHT:
+ {
+ sprintf( sOut,
+ "Weight: Style[%d]",
+ ((const SvxWeightItem*)pItem)->GetValue() );
+ }
+ break;
+ case RES_CHRATR_WORDLINEMODE:
+ {
+ sprintf( sOut,
+ "WordLine: Style[%s]",
+ ( ((const SvxWordLineModeItem*)pItem)->GetValue() ? "ON" : "OFF" ) );
+ }
+ break;
+
+ case RES_TXTATR_CHARFMT:
+ *pOut << "CharFmt: "
+ << ((SwFmtCharFmt*)pItem)->GetCharFmt()->GetName()->GetStr()
+ << endl;
+ }
+ break;
+ case RES_PARATR_LINESPACING:
+ {
+ sprintf( sOut,
+ "LineSpacing: Size[%d] Sp.Rule[%d] In.Sp.Rule[%d] In.Space[%d] Height[%d]",
+ ((const SvxLineSpacingItem*)pItem)->GetPropLineSpace(),
+ ((const SvxLineSpacingItem*)pItem)->GetLineSpaceRule(),
+ ((const SvxLineSpacingItem*)pItem)->GetInterLineSpaceRule(),
+ ((const SvxLineSpacingItem*)pItem)->GetInterLineSpace(),
+ ((const SvxLineSpacingItem*)pItem)->GetLineHeight() );
+ }
+ break;
+
+ case RES_PARATR_ADJUST:
+ {
+ sprintf( sOut,
+ "Adjust: Style[%d]",
+ ((const SvxAdjustItem*)pItem)->GetAdjust() );
+ }
+ break;
+ case RES_PARATR_TABSTOP:
+ {
+ const SvxTabStopItem & rAttr = *(const SvxTabStopItem*)pItem;
+ *pOut << "TabStops: (" << endl;
+ for( USHORT n = 0; n < rAttr.Count(); n++ )
+ {
+ const SvxTabStop & rTab = rAttr[ n ];
+ sprintf( sOut,
+ "\t\tTabStop: Style[%d] Pos[%d] Around[%c] Fill[%c]",
+ rTab.GetAdjustment(),
+ rTab.GetTabPos(),
+ rTab.GetDecimal(),
+ rTab.GetFill() );
+ *pOut << sOut << endl;
+ }
+ *pOut << ')' << endl;
+ sOut[0] = 0;
+ }
+ break;
+ case RES_PARATR_HYPHENZONE:
+ *pOut << "HYPHENZONE" << endl;
+ break;
+
+ case RES_LR_SPACE:
+ {
+ sprintf( sOut,
+ "LRSpace: Left[%d], Right[%d]",
+ ((const SvxLRSpaceItem*)pItem)->GetLeft(),
+ ((const SvxLRSpaceItem*)pItem)->GetRight() );
+ }
+ break;
+ case RES_UL_SPACE:
+ {
+ sprintf( sOut,
+ "ULSpace: Upper[%d], Lower[%d]",
+ ((const SvxULSpaceItem*)pItem)->GetUpper(),
+ ((const SvxULSpaceItem*)pItem)->GetLower() );
+ }
+ break;
+
+ case RES_BACKGROUND:
+ *pOut << "BACKGROUND" << endl;
+ break;
+ case RES_BOX:
+ *pOut << "BOX" << endl;
+ break;
+ case RES_SHADOW:
+ *pOut << "SHADOW" << endl;
+ break;
+
+ default:
+ sprintf( sOut, "UnknownItem: %d", pItem->Which() );
+ }
+
+ if( sOut[0] )
+ *pOut << sOut << endl;
+
+ if( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+}
+
+static void OutStyle( const SwPaM& rPam, const SwTxtFmtColl& rColl )
+{
+ char sOut[ 200 ];
+ sprintf( sOut, "Style: [%5d|%5d] - [%5d|%5d]",
+ rPam.GetMark()->nNode.GetIndex(),
+ rPam.GetMark()->nContent.GetIndex(),
+ rPam.GetPoint()->nNode.GetIndex(),
+ rPam.GetPoint()->nContent.GetIndex() );
+ *pOut << sOut
+ << " ®"
+ << rColl.GetName()->GetStr()
+ << "¯ {" << endl;
+ OutAttr( rColl.GetAttrSet() );
+ *pOut << '}' << endl;
+}
+
+static void OutSet( const SwPaM& rPam, const SfxItemSet& rSet )
+{
+ char sOut[ 200 ];
+ sprintf( sOut, "Attr: [%5d|%5d] - [%5d|%5d] {",
+ rPam.GetMark()->nNode.GetIndex(),
+ rPam.GetMark()->nContent.GetIndex(),
+ rPam.GetPoint()->nNode.GetIndex(),
+ rPam.GetPoint()->nContent.GetIndex() );
+ *pOut << sOut << endl;
+ OutAttr( rSet );
+ *pOut << '}' << endl;
+}
+
+static void OutText( const SwPaM& rPam, const char* pText )
+{
+ char sOut[ 200 ];
+ sprintf( sOut, "Text: [%5d|%5d] - [%5d|%5d]",
+ rPam.GetMark()->nNode.GetIndex(),
+ rPam.GetMark()->nContent.GetIndex(),
+ rPam.GetPoint()->nNode.GetIndex(),
+ rPam.GetPoint()->nContent.GetIndex() );
+ *pOut << sOut
+ << " ®"
+ << pText
+ << '¯' << endl;
+}
+
+static void DumpStart()
+{
+ TempFile aTempFile;
+
+ pOut = new SvFileStream( aTempFile.GetName(),
+ STREAM_WRITE | STREAM_TRUNC );
+ *pOut << "Dump des RTF30-Parsers" << endl;
+}
+
+static void DumpEnde()
+{
+ *pOut << endl<< "Das wars" << endl;
+ delete pOut;
+ pOut = 0;
+}
+
+#endif
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/rtf/swparrtf.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.159 2000/09/18 16:04:51 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.158 2000/08/07 15:13:02 jp
+ Bug #77342#: use String::CreateFromInt32
+
+ Revision 1.157 2000/08/04 10:48:19 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character; use rtfout functions
+
+ Revision 1.156 2000/07/20 13:16:26 jp
+ change old txtatr-character to the two new characters
+
+ Revision 1.155 2000/06/13 09:42:01 os
+ using UCB
+
+ Revision 1.154 2000/05/26 07:22:44 os
+ old SW Basic API Slots removed
+
+ Revision 1.153 2000/05/09 17:23:01 jp
+ Changes for Unicode
+
+ Revision 1.152 2000/03/21 16:30:56 jp
+ Bug #74351# ReadSectControls: reset column from the first pagedesc too
+
+ Revision 1.151 2000/03/14 17:25:21 jp
+ Bug #73968#: read and set outline/num-levels
+
+ Revision 1.150 2000/03/14 09:22:29 jp
+ Bug #73941#: remove unused numrules, share override rules
+
+ Revision 1.149 2000/02/24 18:31:42 jp
+ Bug #73480#: ReadSectControls - dont set columns at PageDesc and Region
+
+ Revision 1.148 2000/02/11 17:36:06 jp
+ Bug #72146#: read UniCode character
+
+ Revision 1.147 2000/02/11 14:38:06 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.146 2000/01/25 20:13:27 jp
+ Bug #72146#: read UniCode character
+
+ Revision 1.145 2000/01/07 12:26:54 jp
+ Task #71411#: read/write NoBalancedColumns
+
+ Revision 1.144 1999/12/13 13:15:42 jp
+ Bug #70916#: ROW - skip to the end of the current line and then move the cursor one node forward
+
+*************************************************************************/
+
diff --git a/sw/source/filter/rtf/swparrtf.hxx b/sw/source/filter/rtf/swparrtf.hxx
new file mode 100644
index 000000000000..a6a889e8d985
--- /dev/null
+++ b/sw/source/filter/rtf/swparrtf.hxx
@@ -0,0 +1,437 @@
+/*************************************************************************
+ *
+ * $RCSfile: swparrtf.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _SWPARRTF_HXX
+#define _SWPARRTF_HXX
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_BOOLS
+#include <svtools/svstdarr.hxx>
+#endif
+#ifndef _SVXRTF_HXX //autogen
+#include <svx/svxrtf.hxx>
+#endif
+
+#ifndef _NDINDEX_HXX
+#include <ndindex.hxx>
+#endif
+
+class Font;
+class Graphic;
+
+class SwNoTxtNode;
+class Size;
+class SwPaM;
+class SwDoc;
+class SwPageDesc;
+class SwTxtFmtColl;
+class SwTableNode;
+class SwCharFmt;
+class SwNumFmt;
+class SwNumRule;
+class SwRTFParser;
+class SvxFontItem;
+class SwRelNumRuleSpaces;
+class SwNodeNum;
+class SwTxtNode;
+struct SvxRTFPictureType;
+
+
+class SwNodeIdx : public SvxNodeIdx
+{
+ SwNodeIndex aIdx;
+public:
+ SwNodeIdx( const SwNodeIndex& rIdx ) : aIdx( rIdx ) {}
+ virtual ULONG GetIdx() const;
+ virtual SvxNodeIdx* Clone() const;
+};
+
+class SwxPosition : public SvxPosition
+{
+ SwPaM* pPam;
+public:
+ SwxPosition( SwPaM* pCrsr ) : pPam( pCrsr ) {}
+
+ virtual ULONG GetNodeIdx() const;
+ virtual xub_StrLen GetCntIdx() const;
+
+ // erzeuge von sich selbst eine Kopie
+ virtual SvxPosition* Clone() const;
+ // erzeuge vom NodeIndex eine Kopie
+ virtual SvxNodeIdx* MakeNodeIdx() const;
+};
+
+
+// zum zwischenspeichern der Flys:
+struct SwFlySave
+{
+ SfxItemSet aFlySet;
+ SwNodeIndex nSttNd, nEndNd;
+ SwTwips nPageWidth;
+ xub_StrLen nEndCnt;
+ USHORT nDropLines, nDropAnchor;
+
+ SwFlySave( const SwPaM& rPam, SfxItemSet& rSet );
+ int IsEqualFly( const SwPaM& rPos, SfxItemSet& rSet );
+ void SetFlySize( const SwTableNode& rTblNd );
+};
+
+struct SwListEntry
+{
+ long nListId, nListTemplateId, nListNo;
+ USHORT nListDocPos;
+ BOOL bRuleUsed;
+
+ SwListEntry()
+ : nListId( 0 ), nListTemplateId( 0 ), nListNo( 0 ), nListDocPos( 0 ),
+ bRuleUsed( FALSE )
+ {}
+ SwListEntry( long nLstId, long nLstTmplId, USHORT nLstDocPos )
+ : nListId( nLstId ), nListTemplateId( nLstTmplId ), nListNo( 0 ),
+ nListDocPos( nLstDocPos ), bRuleUsed( FALSE )
+ {}
+
+ void Clear() { nListId = nListTemplateId = nListNo = 0, nListDocPos = 0;
+ bRuleUsed = FALSE; }
+};
+
+DECLARE_TABLE( SwRTFStyleTbl, SwTxtFmtColl* )
+DECLARE_TABLE( SwRTFCharStyleTbl, SwCharFmt* )
+typedef SwFlySave* SwFlySavePtr;
+SV_DECL_PTRARR_DEL( SwFlySaveArr, SwFlySavePtr, 0, 20 )
+SV_DECL_VARARR( SwListArr, SwListEntry, 0, 20 )
+
+
+class SwRTFParser : public SvxRTFParser
+{
+ SwRTFStyleTbl aTxtCollTbl;
+ SwRTFCharStyleTbl aCharFmtTbl;
+ SwFlySaveArr aFlyArr; // Flys als Letzes im Doc setzen
+ SvBools aMergeBoxes; // Flags fuer gemergte Zellen
+ SwListArr aListArr;
+ SvPtrarr aTblFmts;
+
+ SfxItemSet* pGrfAttrSet;
+ SwTableNode* pTableNode, *pOldTblNd; // fuers Lesen von Tabellen: akt. Tab
+ SwNodeIndex* pSttNdIdx;
+ SwNodeIndex* pRegionEndIdx;
+ SwDoc* pDoc;
+ SwPaM* pPam; // SwPosition duerfte doch reichen, oder ??
+ SwRelNumRuleSpaces* pRelNumRule; // Liste aller benannten NumRules
+
+ USHORT nAktPageDesc, nAktFirstPageDesc;
+ USHORT nAktBox; // akt. Box
+ USHORT nInsTblRow; // beim nach \row kein \pard -> neue Line anlegen
+ USHORT nNewNumSectDef; // jeder SectionWechsel kann neue Rules definieren
+
+ BOOL bSwPageDesc : 1;
+ BOOL bReadSwFly : 1; // lese Swg-Fly (wichtig fuer Bitmaps!)
+ BOOL bReadNoTbl : 1; // verhinder Tabelle in Tabelle/FootNote
+ BOOL bFootnoteAutoNum : 1; // automatische Numerierung ?
+ BOOL bStyleTabValid : 1; // Styles schon erzeugt ?
+ BOOL bInPgDscTbl : 1; // beim PageDescTbl lesen
+ BOOL bNewNumList : 1; // Word 7.0 NumList gelesen, 6.0 ueberspringen
+ BOOL bFirstContinue: 1; // 1.Call ins Continue
+ BOOL bFirstDocControl: 1; // 1.Call of ReadDocControl
+
+
+ virtual void InsertPara();
+ virtual void InsertText();
+ virtual void MovePos( int bForward = TRUE );
+ virtual void SetEndPrevPara( SvxNodeIdx*& rpNodePos, xub_StrLen& rCntPos );
+
+ void CheckInsNewTblLine();
+
+ // setze RTF-Werte auf Swg-Werte
+ void SetSwgValues( SfxItemSet& rSet );
+
+ virtual void ReadInfo( const sal_Char* pChkForVerNo = 0 );
+
+ void ReadListLevel( SwNumRule& rRule, BYTE nLvl );
+ void ReadListTable();
+ void ReadListOverrideTable();
+ void ReadNumSecLevel( int nToken );
+ SwNumRule* GetNumRuleOfListNo( long nListNo,
+ BOOL bRemoveFromList = FALSE );
+ void RemoveUnusedNumRule( SwNumRule* );
+ void RemoveUnusedNumRules();
+ const Font* FindFontOfItem( const SvxFontItem& rItem ) const;
+
+ // 3 Methoden zum Aufbauen der Styles
+ SwTxtFmtColl* MakeColl( const String&, USHORT nPos, BYTE nOutlineLevel,
+ int& rbCollExist );
+ SwCharFmt* MakeCharFmt( const String& rName, USHORT nPos,
+ int& rbCollExist );
+ void SetStyleAttr( SfxItemSet& rCollSet,
+ const SfxItemSet& rStyleSet,
+ const SfxItemSet& rDerivedSet );
+ SwTxtFmtColl* MakeStyle( USHORT nNo, const SvxRTFStyleType& rStyle );
+ SwCharFmt* MakeCharStyle( USHORT nNo, const SvxRTFStyleType& rStyle );
+ void MakeStyleTab();
+
+ int MakeFieldInst( String& rFieldStr );
+ SwPageDesc* _MakeNewPageDesc( int bFirst );
+
+ // einlesen/einfuegen von Bitmaps
+ void InsPicture( const String& rNm,
+ const Graphic* = 0, const SvxRTFPictureType* = 0 );
+ void _SetPictureSize( const SwNoTxtNode& rNd, const SwNodeIndex& rAnchor,
+ SfxItemSet& rSet, const SvxRTFPictureType* = 0 );
+
+ void SetFlysInDoc();
+ void GetPageSize( Size& rSize ); // Groesse der PagePrintArea
+
+ // fuers Einlesen von Tabellen
+ void GotoNextBox();
+ void NewTblLine();
+
+ void DelLastNode(); // loesche den letzten Node (Tabelle/Fly/Ftn/..)
+
+ void AddNumRule( SwNumRule* pRule );
+ void SetNumRelSpaces();
+ void SetOultineRelSpaces( const SwNodeIndex& rStt,
+ const SwNodeIndex& rEnd );
+ void SetNumLSpace( SwTxtNode& rNd, const SwNodeNum& rNum,
+ const SwNumRule& rRule );
+
+protected:
+ // wird fuer jedes Token gerufen, das in CallParser erkannt wird
+ virtual void NextToken( int nToken );
+
+// virtual void ReadUnknownData();
+ virtual void ReadBitmapData();
+#ifdef READ_OLE_OBJECT
+ virtual void ReadOLEData();
+#endif
+ virtual void SetAttrInDoc( SvxRTFItemStackType &rSet );
+ // fuer Tokens, die im ReadAttr nicht ausgewertet werden
+ virtual void UnknownAttrToken( int nToken, SfxItemSet* pSet );
+
+ void ReadPrtData();
+ void ReadField();
+ void ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc = 0 );
+ void ReadDocControls( int nToken );
+ void ReadSectControls( int nToken );
+ void ReadFly( int nToken, SfxItemSet* pFillSet = 0 );
+ void ReadTable( int nToken );
+ void ReadPageDescTbl();
+
+ virtual ~SwRTFParser();
+
+public:
+ SwRTFParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
+ int bReadNewDoc = TRUE );
+
+ virtual SvParserState CallParser(); // Aufruf des Parsers
+ virtual int IsEndPara( SvxNodeIdx* pNd, xub_StrLen nCnt ) const;
+
+ // fuers asynchrone lesen aus dem SvStream
+// virtual void SaveState( int nToken );
+// virtual void RestoreState();
+ virtual void Continue( int nToken );
+};
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.45 2000/09/18 16:04:51 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.44 2000/09/09 12:53:29 willem.vandorp
+ Header and footer replaced
+
+ Revision 1.43 2000/05/09 17:23:05 jp
+ Changes for Unicode
+
+ Revision 1.42 2000/04/14 14:00:41 khz
+ Task #70451# use CalculateFlySize() for WW frames with 'auto'width
+
+ Revision 1.41 2000/03/14 09:22:33 jp
+ Bug #73941#: remove unused numrules, share override rules
+
+ Revision 1.40 1999/08/03 17:43:08 JP
+ Bug #68028#,#68026#,#67983#,#67982#: changes for import of PageDesc from interleave/WP7/Aplixware
+
+
+ Rev 1.39 03 Aug 1999 19:43:08 JP
+ Bug #68028#,#68026#,#67983#,#67982#: changes for import of PageDesc from interleave/WP7/Aplixware
+
+ Rev 1.38 19 Apr 1999 12:48:50 JP
+ Vorbereitungen fuer OLE-Objecte in RTF lesen (anstoss ist Bug #60140#)
+
+ Rev 1.37 18 Mar 1999 09:51:50 JP
+ Task #63049#: Numerierung mit rel. Einzuegen
+
+ Rev 1.36 16 Mar 1999 23:20:00 JP
+ Task #63049#: Einzuege bei NumRules relativ
+
+ Rev 1.35 05 Mar 1999 14:27:58 JP
+ Bug #57749#: spaltige Bereiche einlesen - jeder Bereich hat eigene NumRules
+
+ Rev 1.34 03 Mar 1999 15:17:24 JP
+ Bug #57749#: spaltige Bereiche einlesen
+
+ Rev 1.33 24 Feb 1999 19:51:32 JP
+ Task #62314#: Asynchrone DDE-Links/-Requests
+
+ Rev 1.32 21 Sep 1998 17:16:14 JP
+ DropCaps unterstuetzen
+
+ Rev 1.31 13 Aug 1998 10:33:24 JP
+ Bug #53525#: Tabellen - an den Kanten keine doppelte Umrandung mehr
+
+ Rev 1.30 27 May 1998 22:26:16 JP
+ Bug #50585#: ListOverrideTabelle korrekt einlesen
+
+ Rev 1.29 20 Apr 1998 17:43:20 JP
+ neu: Numerierung lesen/schreiben
+
+ Rev 1.28 06 Apr 1998 14:46:30 JP
+ Erweiterungen fuer Numerierungen (97-Vers.)
+
+ Rev 1.27 03 Apr 1998 18:51:52 JP
+ RTF-Parser um neue Tokens erweitert
+
+ Rev 1.26 11 Feb 1998 14:07:20 JP
+ kleinere Bugs behoben bei Rahmen & Tabellen
+
+ Rev 1.25 26 Jan 1998 20:54:50 JP
+ Bug #45958#: Continue - die gesplitteten Nodes richtig zusammenfassen, neu: Zeichenvorlagen lesen
+
+ Rev 1.24 09 Oct 1997 14:27:52 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.23 01 Sep 1997 20:09:02 JP
+ Bug #43126#: Flag fuers Einfuegen in Numerierungen
+
+ Rev 1.22 11 Aug 1997 13:59:42 OM
+ Headerfile-Umstellung
+
+ Rev 1.21 27 Jun 1997 11:34:36 JP
+ Bug #40723#: erst pard oder neue Ebene nach einem row hebt die Tabelle auf
+
+ Rev 1.20 23 Oct 1996 12:42:24 JP
+ SVMEM -> SVSTDARR Umstellung
+
+ Rev 1.19 04 Jul 1996 15:02:30 JP
+ Tabellen einlesen korrigiert
+
+ Rev 1.18 28 Jun 1996 15:07:26 MA
+ includes
+
+ Rev 1.17 18 Jun 1996 16:35:38 JP
+ ReadFly: erweitert um optionalen Itemset erweitert(FlyInFly lesen)
+
+ Rev 1.16 12 Jun 1996 16:49:36 JP
+ PageDesc: Header/Footer richtig einlesen
+
+ Rev 1.15 08 May 1996 18:33:20 JP
+ Erweiterung fuers asynchrone Laden
+
+ Rev 1.14 25 Apr 1996 13:57:16 MIB
+ Verschiebung SvHTMLParser in Gooedies
+
+ Rev 1.13 25 Apr 1996 09:24:30 JP
+ SwPictureType in svx exportiert
+
+ Rev 1.12 12 Feb 1996 12:45:50 JP
+ StyleTabelle auch aufbauen wenn sie gebraucht wird
+
+ Rev 1.11 13 Dec 1995 10:35:58 MA
+ opt: Bessere Defaults fuer Arrays
+
+ Rev 1.10 30 Oct 1995 21:18:58 JP
+ intbl refernziert auch vorher eingelesene Tabellen
+
+ Rev 1.9 11 Oct 1995 20:31:48 HJS
+ umbenennung
+
+ Rev 1.8 23 Feb 1995 09:37:06 JP
+ Methode RTFPardPlain wird nicht mehr benoetigt
+
+ Rev 1.7 08 Feb 1995 09:49:14 JP
+ alten RTF-Parser entfernt, Sw_RTF -> SwRTF
+
+ Rev 1.6 18 Jan 1995 19:53:48 JP
+ Footnote: beachte fuehrende Zeichen
+
+ Rev 1.5 15 Jan 1995 20:34:12 JP
+ Einfuegen in bestehendes Doc: Vorlagen richtig behandeln
+
+ Rev 1.4 11 Jan 1995 19:45:30 JP
+ RTF-Reader fertiggestellt
+
+ Rev 1.3 09 Jan 1995 08:25:12 JP
+ aus rtffly.cxx SwFlySave public gemacht
+
+ Rev 1.2 06 Jan 1995 12:08:28 JP
+ lesen von Tabellen zugefuegt
+
+ Rev 1.1 23 Dec 1994 08:39:28 JP
+ forward deklaration zugefuegt
+
+ Rev 1.0 22 Dec 1994 17:38:36 JP
+ Initial revision.
+
+*************************************************************************/
+
+#endif
+ //_SWPARRTF_HXX
+
diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx
new file mode 100644
index 000000000000..c5abaa8a64c7
--- /dev/null
+++ b/sw/source/filter/rtf/wrtrtf.cxx
@@ -0,0 +1,1593 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtrtf.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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
+
+#include <stdlib.h>
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _DATETIME_HXX //autogen
+#include <tools/datetime.hxx>
+#endif
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+#ifndef _RTFKEYWD_HXX //autogen
+#include <svtools/rtfkeywd.hxx>
+#endif
+#ifndef _RTFOUT_HXX
+#include <svtools/rtfout.hxx>
+#endif
+#ifndef _SFXDOCINF_HXX //autogen
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _SVX_PAPERINF_HXX //autogen
+#include <svx/paperinf.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+
+
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _WRTRTF_HXX
+#include <wrtrtf.hxx>
+#endif
+#ifndef _FMTCOL_HXX
+#include <fmtcol.hxx>
+#endif
+#ifndef _FLYPOS_HXX
+#include <flypos.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx> // fuer SwBookmark ...
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx> // fuer SwPageDesc...
+#endif
+#ifndef _NUMRULE_HXX
+#include <numrule.hxx>
+#endif
+#ifndef _FTNINFO_HXX
+#include <ftninfo.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen
+#include <section.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx> // fuer SwPageDesc ...
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+
+#if defined(MAC)
+const sal_Char SwRTFWriter::sNewLine = '\015';
+#elif defined(UNX)
+const sal_Char SwRTFWriter::sNewLine = '\012';
+#else
+const sal_Char __FAR_DATA SwRTFWriter::sNewLine[] = "\015\012";
+#endif
+
+
+
+SV_DECL_VARARR( RTFColorTbl, Color, 5, 2 )
+SV_IMPL_VARARR( RTFColorTbl, Color )
+
+
+SwRTFWriter::SwRTFWriter( const String& rFltName )
+{
+ // schreibe Win-RTF-HelpFileFmt
+ bWriteHelpFmt = 'W' == rFltName.GetChar( 0 );
+ // schreibe nur Gliederungs Absaetze
+ bOutOutlineOnly = 'O' == rFltName.GetChar( 0 );
+}
+
+
+SwRTFWriter::~SwRTFWriter() {}
+
+
+
+ULONG SwRTFWriter::WriteStream()
+{
+ bOutPageAttr = bOutSection = TRUE;
+
+ bOutStyleTab = bOutTable = bOutPageDesc = bOutPageDescTbl =
+ bAutoAttrSet = bOutListNumTxt = bOutLeftHeadFoot = bIgnoreNextPgBreak =
+ FALSE;
+
+ nFontHeight = 0;
+ nBkmkTabPos = USHRT_MAX;
+ pAktPageDesc = 0;
+ pAttrSet = 0;
+ pFlyFmt = 0; // kein FlyFrmFormat gesetzt
+
+ pColTbl = new RTFColorTbl;
+
+ BYTE nSz = (BYTE)Min( pDoc->GetSpzFrmFmts()->Count(), USHORT(255) );
+ SwPosFlyFrms aFlyPos( nSz, nSz );
+
+ //Abkuerzung wenn nur Gliederung ausgegeben werden soll, und keine
+ //Gliederungsabsaetze ausserhalb des Body stehen.
+ if ( bOutOutlineOnly &&
+ pDoc->GetNodes().GetOutLineNds().Count() &&
+ pDoc->GetNodes().GetOutLineNds()[0]->GetIndex() >
+ pDoc->GetNodes().GetEndOfExtras().GetIndex() )
+ {
+ nAktFlyPos = 0;
+ pFlyPos = 0;
+ MakeHeader();
+
+ const SwOutlineNodes &rOutLine = pDoc->GetNodes().GetOutLineNds();
+ for ( USHORT i = 0; i < rOutLine.Count(); ++i )
+ {
+ const SwNode *pNd = pDoc->GetNodes()[*rOutLine[i]];
+ ASSERT( pNd->IsCntntNode(), "Outlinenode and no CntNode!?" );
+
+ SwCntntNode* pCNd = (SwCntntNode*)pNd;
+
+ // erfrage den aktuellen PageDescriptor.
+ const SwPageDesc* pTmp = pCNd->GetSwAttrSet().GetPageDesc().GetPageDesc();
+ if( pTmp )
+ pAktPageDesc = pTmp;
+ pCurPam->GetPoint()->nContent.Assign( pCNd, 0 );
+ Out( aRTFNodeFnTab, *pCNd, *this );
+ }
+ }
+ else
+ {
+ long nMaxNode = pDoc->GetNodes().Count();
+
+ if( bShowProgress )
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, pDoc->GetDocShell() );
+
+ // Tabelle am Doc.-Anfang beachten
+ {
+ SwTableNode * pTNd = pCurPam->GetNode()->FindTableNode();
+ if( pTNd && bWriteAll )
+ {
+ // mit dem TabellenNode anfangen !!
+ pCurPam->GetPoint()->nNode = *pTNd;
+
+ if( bWriteOnlyFirstTable )
+ pCurPam->GetMark()->nNode = *pTNd->EndOfSectionNode();
+ }
+ }
+
+ // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn
+ // das gesamte Dokument geschrieben wird
+ nAktFlyPos = 0;
+ pDoc->GetAllFlyFmts( aFlyPos, bWriteAll ? 0 : pOrigPam );
+
+ // sollten nur Rahmen vorhanden sein?
+ // (Moeglich, wenn eine Rahmen-Selektion ins Clipboard
+ // gestellt wurde)
+ if( bWriteAll &&
+ // keine Laenge
+ *pCurPam->GetPoint() == *pCurPam->GetMark() &&
+ // Rahmen vorhanden
+ pDoc->GetSpzFrmFmts()->Count() && !aFlyPos.Count() &&
+ // nur ein Node im Array
+ pDoc->GetNodes().GetEndOfExtras().GetIndex() + 3 ==
+ pDoc->GetNodes().GetEndOfContent().GetIndex() &&
+ // und genau der ist selektiert
+ pDoc->GetNodes().GetEndOfContent().GetIndex() - 1 ==
+ pCurPam->GetPoint()->nNode.GetIndex() )
+ {
+ // dann den Inhalt vom Rahmen ausgeben.
+ // dieser steht immer an Position 0 !!
+ SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[ 0 ];
+ const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
+ if( pIdx )
+ {
+ SwPosFlyFrm* pFPos = new SwPosFlyFrm( pCurPam->GetPoint()->nNode,
+ pFmt, aFlyPos.Count() );
+ aFlyPos.Insert( pFPos );
+ }
+ }
+
+ pFlyPos = &aFlyPos;
+
+ // schreibe die StyleTabelle, allgemeine Angaben,Header/Footer/Footnotes
+ MakeHeader();
+
+ Out_SwDoc( pOrigPam );
+
+ if( bShowProgress )
+ ::EndProgress( pDoc->GetDocShell() );
+ }
+
+ Strm() << '}';
+
+ // loesche die Tabelle mit den freifliegenden Rahmen
+ for( USHORT i = aFlyPos.Count(); i > 0; )
+ delete aFlyPos[ --i ];
+
+ pFlyPos = 0;
+ delete pColTbl;
+
+ // schreibe Win-RTF-HelpFileFmt
+ bOutOutlineOnly = bWriteHelpFmt = FALSE;
+ pAttrSet = 0;
+
+ return 0;
+}
+
+
+void SwRTFWriter::Out_SwDoc( SwPaM* pPam )
+{
+ BOOL bSaveWriteAll = bWriteAll; // sichern
+ // suche die naechste Bookmark-Position aus der Bookmark-Tabelle
+ nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : USHRT_MAX;
+
+ // gebe alle Bereiche des Pams in das RTF-File aus.
+ do {
+ bWriteAll = bSaveWriteAll;
+ bFirstLine = TRUE;
+
+ // suche den ersten am Pam-auszugebenen FlyFrame
+ // fehlt noch:
+
+ while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode ||
+ (pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode &&
+ pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
+ {
+ SwNode& rNd = pCurPam->GetPoint()->nNode.GetNode();
+
+ if( &rNd == &pDoc->GetNodes().GetEndOfContent() )
+ break;
+
+ if( rNd.IsCntntNode() )
+ {
+ SwCntntNode& rCNd = (SwCntntNode&)rNd;
+
+ OutBreaks( rCNd.GetSwAttrSet() );
+ OutFlyFrm();
+
+ if( !bFirstLine )
+ pCurPam->GetPoint()->nContent.Assign( &rCNd, 0 );
+
+ if( !bOutOutlineOnly ||
+ ( rCNd.IsTxtNode() && NO_NUMBERING !=
+ ((SwTxtNode&)rCNd).GetTxtColl()->GetOutlineLevel() ))
+ Out( aRTFNodeFnTab, rCNd, *this );
+
+ }
+ else if( !bOutOutlineOnly )
+ {
+ if( rNd.IsTableNode() )
+ {
+ OutBreaks( ((SwTableNode&)rNd).GetTable().GetFrmFmt()
+ ->GetAttrSet() );
+ OutRTF_SwTblNode( *this, (SwTableNode&)rNd );
+ }
+ else if( rNd.IsSectionNode() )
+ {
+ OutBreaks( ((SwSectionNode&)rNd).GetSection().GetFmt()
+ ->GetAttrSet() );
+ OutRTF_SwSectionNode( *this, (SwSectionNode&)rNd );
+ }
+ else if( rNd.IsEndNode() )
+ CheckEndNodeForSection( rNd );
+ }
+
+ ULONG nPos = pCurPam->GetPoint()->nNode++; // Bewegen
+
+ if( bShowProgress )
+ ::SetProgressState( nPos, pDoc->GetDocShell() ); // Wie weit ?
+
+ /* sollen nur die Selectierten Bereiche gesichert werden, so
+ * duerfen nur die vollstaendigen Nodes gespeichert werde,
+ * d.H. der 1. und n. Node teilweise, der 2. bis n-1. Node
+ * vollstaendig. (vollstaendig heisst mit allen Formaten! )
+ */
+ bWriteAll = bSaveWriteAll ||
+ pCurPam->GetPoint()->nNode != pCurPam->GetMark()->nNode;
+ bFirstLine = FALSE;
+ }
+ } while( CopyNextPam( &pPam ) ); // bis alle PaM's bearbeitet
+
+ bWriteAll = bSaveWriteAll; // wieder auf alten Wert zurueck
+}
+
+
+// schreibe die StyleTabelle, algemeine Angaben,Header/Footer/Footnotes
+
+
+void SwRTFWriter::MakeHeader()
+{
+ // baue den Vorspann wie Header, ColorTbl, FontTbl
+ Strm() << '{' << sRTF_RTF << '1'
+#ifdef MAC
+ << sRTF_MAC
+#else
+ << sRTF_ANSI
+#endif
+ ;
+ if( bWriteAll )
+ {
+ Strm() << sRTF_DEFF;
+ OutULong( GetId( (SvxFontItem&)pDoc->GetAttrPool().GetDefaultItem(
+ RES_CHRATR_FONT ) ));
+ }
+
+
+ OutRTFFontTab();
+ OutRTFColorTab();
+ OutRTFStyleTab();
+ OutRTFListTab();
+
+ Strm() << SwRTFWriter::sNewLine; // ein Trenner
+
+ // wenn teilweise ausgegeben wird, die globalen Daten nicht speichern
+ if( !bWriteAll )
+ return;
+
+ // Ausgeben der Doc-Info/-Statistik
+ OutDocInfoStat();
+
+ // einige globale Daten Schreiben
+ { // Default-TabSize
+ const SvxTabStopItem& rTabs = (const SvxTabStopItem&)
+ pDoc->GetAttrPool().GetDefaultItem( RES_PARATR_TABSTOP );
+ Strm() << sRTF_DEFTAB;
+ OutLong( rTabs[0].GetTabPos() );
+ }
+
+ // PageDescriptor ausgeben (??nur wenn das gesamte Dokument??)
+ OutPageDesc();
+
+ // gebe die Groesse und die Raender der Seite aus
+ if( pDoc->GetPageDescCnt() )
+ {
+ //JP 06.04.99: Bug 64361 - suche den ersten SwFmtPageDesc. Ist
+ // keiner gesetzt, so ist der Standard gueltig
+ const SwFmtPageDesc* pSttPgDsc = 0;
+ {
+ const SwNode& rSttNd = *pDoc->GetNodes()[
+ pDoc->GetNodes().GetEndOfExtras().GetIndex() + 2 ];
+ const SfxItemSet* pSet = 0;
+
+ if( rSttNd.IsCntntNode() )
+ pSet = &rSttNd.GetCntntNode()->GetSwAttrSet();
+ else if( rSttNd.IsTableNode() )
+ pSet = &rSttNd.GetTableNode()->GetTable().
+ GetFrmFmt()->GetAttrSet();
+ else if( rSttNd.IsSectionNode() )
+ pSet = &rSttNd.GetSectionNode()->GetSection().
+ GetFmt()->GetAttrSet();
+
+ if( pSet )
+ {
+ USHORT nPosInDoc;
+ pSttPgDsc = (SwFmtPageDesc*)&pSet->Get( RES_PAGEDESC );
+ if( !pSttPgDsc->GetPageDesc() )
+ pSttPgDsc = 0;
+ else if( pDoc->FindPageDescByName( pSttPgDsc->
+ GetPageDesc()->GetName(), &nPosInDoc ))
+ {
+ // FALSE wegen schliessender Klammer !!
+ OutComment( *this, sRTF_PGDSCNO, FALSE );
+ OutULong( nPosInDoc ) << '}';
+ }
+ }
+ }
+ const SwPageDesc& rPageDesc = pSttPgDsc ? *pSttPgDsc->GetPageDesc()
+ : pDoc->GetPageDesc( 0 );
+ const SwFrmFmt &rFmtPage = rPageDesc.GetMaster();
+
+ {
+ if( rPageDesc.GetLandscape() )
+ Strm() << sRTF_LANDSCAPE;
+
+ const SwFmtFrmSize& rSz = rFmtPage.GetFrmSize();
+ // Clipboard-Dokument wird immer ohne Drucker angelegt, so ist
+ // der Std.PageDesc immer aug LONG_MAX !! Mappe dann auf DIN A4
+ if( LONG_MAX == rSz.GetHeight() || LONG_MAX == rSz.GetWidth() )
+ {
+ Strm() << sRTF_PAPERH;
+ OutULong( lA4Height ) << sRTF_PAPERW;
+ OutULong( lA4Width );
+ }
+ else
+ {
+ Strm() << sRTF_PAPERH;
+ OutULong( rSz.GetHeight() ) << sRTF_PAPERW;
+ OutULong( rSz.GetWidth() );
+ }
+ }
+
+ {
+ const SvxLRSpaceItem& rLR = rFmtPage.GetLRSpace();
+ Strm() << sRTF_MARGL;
+ OutLong( rLR.GetLeft() ) << sRTF_MARGR;
+ OutLong( rLR.GetRight() );
+ }
+
+ {
+ const SvxULSpaceItem& rUL = rFmtPage.GetULSpace();
+ Strm() << sRTF_MARGT;
+ OutLong( rUL.GetUpper() ) << sRTF_MARGB;
+ OutLong( rUL.GetLower() );
+ }
+
+ Strm() << sRTF_SECTD << sRTF_SBKNONE;
+ OutRTFPageDescription( rPageDesc, FALSE, FALSE );
+ if( pSttPgDsc )
+ {
+ bIgnoreNextPgBreak = TRUE;
+ pAktPageDesc = &rPageDesc;
+ }
+ }
+
+
+ {
+ // schreibe die Fussnoten- und Endnoten-Info raus
+ const SwFtnInfo& rFtnInfo = pDoc->GetFtnInfo();
+
+ const char* pOut = FTNPOS_CHAPTER == rFtnInfo.ePos
+ ? sRTF_ENDDOC
+ : sRTF_FTNBJ;
+ Strm() << pOut << sRTF_FTNSTART;
+ OutLong( rFtnInfo.nFtnOffset + 1 );
+
+ switch( rFtnInfo.eNum )
+ {
+ case FTNNUM_PAGE: pOut = sRTF_FTNRSTPG; break;
+ case FTNNUM_DOC: pOut = sRTF_FTNRSTCONT; break;
+// case FTNNUM_CHAPTER:
+ default: pOut = sRTF_FTNRESTART; break;
+ }
+ Strm() << pOut;
+
+ switch( rFtnInfo.aFmt.eType )
+ {
+ case SVX_NUM_CHARS_LOWER_LETTER:
+ case SVX_NUM_CHARS_LOWER_LETTER_N: pOut = sRTF_FTNNALC; break;
+ case SVX_NUM_CHARS_UPPER_LETTER:
+ case SVX_NUM_CHARS_UPPER_LETTER_N: pOut = sRTF_FTNNAUC; break;
+ case SVX_NUM_ROMAN_LOWER: pOut = sRTF_FTNNRLC; break;
+ case SVX_NUM_ROMAN_UPPER: pOut = sRTF_FTNNRUC; break;
+ case SVX_NUM_CHAR_SPECIAL: pOut = sRTF_FTNNCHI; break;
+// case SVX_NUM_ARABIC:
+ default: pOut = sRTF_FTNNAR; break;
+ }
+ Strm() << pOut;
+
+
+ const SwEndNoteInfo& rEndNoteInfo = pDoc->GetEndNoteInfo();
+
+ Strm() << sRTF_AENDDOC << sRTF_AFTNRSTCONT
+ << sRTF_AFTNSTART;
+ OutLong( rEndNoteInfo.nFtnOffset + 1 );
+
+ switch( rEndNoteInfo.aFmt.eType )
+ {
+ case SVX_NUM_CHARS_LOWER_LETTER:
+ case SVX_NUM_CHARS_LOWER_LETTER_N: pOut = sRTF_AFTNNALC; break;
+ case SVX_NUM_CHARS_UPPER_LETTER:
+ case SVX_NUM_CHARS_UPPER_LETTER_N: pOut = sRTF_AFTNNAUC; break;
+ case SVX_NUM_ROMAN_LOWER: pOut = sRTF_AFTNNRLC; break;
+ case SVX_NUM_ROMAN_UPPER: pOut = sRTF_AFTNNRUC; break;
+ case SVX_NUM_CHAR_SPECIAL: pOut = sRTF_AFTNNCHI; break;
+// case SVX_NUM_ARABIC:
+ default: pOut = sRTF_AFTNNAR; break;
+ }
+ Strm() << pOut;
+ }
+
+ if( pDoc->_GetDBDesc().Len() )
+ {
+ // stelle erstmal fest, ob ueberhaupt Datenbankfelder benutzt werden!
+ const SwFldTypes* pTypes = pDoc->GetFldTypes();
+ for( USHORT nCnt = pTypes->Count(); nCnt >= INIT_FLDTYPES; )
+ if( RES_DBFLD == (*pTypes)[ --nCnt ]->Which() &&
+ (*pTypes)[ nCnt ]->GetDepends() )
+ {
+ Strm() << '{' << sRTF_FIELD;
+ OutComment( *this, sRTF_FLDINST ) << " DATA ";
+ RTFOutFuncs::Out_String( Strm(), pDoc->GetDBName(),
+ DEF_ENCODING, bWriteHelpFmt );
+ Strm() << "}{" << sRTF_FLDRSLT << " }}";
+ break;
+ }
+ }
+
+ pAttrSet = 0;
+
+ Strm() << SwRTFWriter::sNewLine; // ein Trenner
+}
+
+void SwRTFWriter::OutInfoDateTime( const DateTime& rDT, const char* pStr )
+{
+ Strm() << '{' << pStr << sRTF_YR;
+ OutLong( Strm(), rDT.GetYear() ) << sRTF_MO;
+ OutLong( Strm(), rDT.GetMonth() ) << sRTF_DY;
+ OutLong( Strm(), rDT.GetDay() ) << sRTF_HR;
+ OutLong( Strm(), rDT.GetHour() ) << sRTF_MIN;
+ OutLong( Strm(), rDT.GetMin() ) << '}';
+}
+
+void SwRTFWriter::OutDocInfoStat()
+{
+ Strm() << '{' << sRTF_INFO;
+
+ const SfxDocumentInfo* pInfo = pDoc->GetpInfo();
+ if( pInfo )
+ {
+ const String* pStr = &pInfo->GetTitle();
+ if( pStr->Len() )
+ {
+ Strm() << '{' << sRTF_TITLE << ' ';
+ RTFOutFuncs::Out_String( Strm(), *pStr, DEF_ENCODING,
+ bWriteHelpFmt ) << '}';
+ }
+ if( (pStr = &pInfo->GetTheme())->Len() )
+ {
+ Strm() << '{' << sRTF_SUBJECT << ' ';
+ RTFOutFuncs::Out_String( Strm(), *pStr, DEF_ENCODING,
+ bWriteHelpFmt ) << '}';
+ }
+ if( (pStr = &pInfo->GetKeywords())->Len() )
+ {
+ Strm() << '{' << sRTF_KEYWORDS << ' ';
+ RTFOutFuncs::Out_String( Strm(), *pStr, DEF_ENCODING,
+ bWriteHelpFmt ) << '}';
+ }
+ if( (pStr = &pInfo->GetComment())->Len() )
+ {
+ Strm() << '{' << sRTF_DOCCOMM << ' ';
+ RTFOutFuncs::Out_String( Strm(), *pStr, DEF_ENCODING,
+ bWriteHelpFmt ) << '}';
+ }
+
+ const SfxStamp* pStamp = &pInfo->GetCreated();
+ if( ( pStr = &pStamp->GetName())->Len() )
+ {
+ Strm() << '{' << sRTF_AUTHOR << ' ';
+ RTFOutFuncs::Out_String( Strm(), *pStr, DEF_ENCODING,
+ bWriteHelpFmt ) << '}';
+ }
+ OutInfoDateTime( pStamp->GetTime(), sRTF_CREATIM );
+
+ pStamp = &pInfo->GetChanged();
+ if( ( pStr = &pStamp->GetName())->Len() )
+ {
+ Strm() << '{' << sRTF_OPERATOR << ' ';
+ RTFOutFuncs::Out_String( Strm(), *pStr, DEF_ENCODING,
+ bWriteHelpFmt ) << '}';
+ }
+ OutInfoDateTime( pStamp->GetTime(), sRTF_REVTIM );
+
+ OutInfoDateTime( pInfo->GetPrinted().GetTime(), sRTF_PRINTIM );
+ }
+
+
+ // fuer interne Zwecke - Versionsnummer rausschreiben
+ Strm() << '{' << sRTF_COMMENT << " StarWriter}{" << sRTF_VERN;
+ OutLong( Strm(), SOFFICE_FILEFORMAT_NOW ) << '}';
+
+ Strm() << '}';
+}
+
+
+static void InsColor( RTFColorTbl& rTbl, const Color& rCol )
+{
+ for( USHORT n = 0; n < rTbl.Count(); ++n )
+ if( rTbl[n] == rCol )
+ return; // schon vorhanden, zurueck
+
+ rTbl.Insert( rCol, rTbl.Count() );
+}
+
+static void InsColorLine( RTFColorTbl& rTbl, const SvxBoxItem& rBox )
+{
+ const SvxBorderLine* pLine = 0;
+
+ if( rBox.GetTop() )
+ InsColor( rTbl, (pLine = rBox.GetTop())->GetColor() );
+ if( rBox.GetBottom() && pLine != rBox.GetBottom() )
+ InsColor( rTbl, (pLine = rBox.GetBottom())->GetColor() );
+ if( rBox.GetLeft() && pLine != rBox.GetLeft() )
+ InsColor( rTbl, (pLine = rBox.GetLeft())->GetColor() );
+ if( rBox.GetRight() && pLine != rBox.GetRight() )
+ InsColor( rTbl, rBox.GetRight()->GetColor() );
+}
+
+
+void SwRTFWriter::OutRTFColorTab()
+{
+ ASSERT( pColTbl, "Wo ist meine Color-Tabelle?" );
+
+ // dann baue die ColorTabelle aus allen Attributen, die Colors
+ // enthalten und im Pool angemeldet sind auf.
+ USHORT n, nMaxItem;
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+
+ // das Charakter - Color Attribut
+ {
+ const SvxColorItem* pCol = (const SvxColorItem*)GetDfltAttr(
+ RES_CHRATR_COLOR );
+ InsColor( *pColTbl, pCol->GetValue() );
+ if( 0 != ( pCol = (const SvxColorItem*)rPool.GetPoolDefaultItem(
+ RES_CHRATR_COLOR ) ))
+ InsColor( *pColTbl, pCol->GetValue() );
+ nMaxItem = rPool.GetItemCount(RES_CHRATR_COLOR);
+ for( n = 0; n < nMaxItem; ++n )
+ if( 0 != (pCol = (const SvxColorItem*)rPool.GetItem(
+ RES_CHRATR_COLOR, n ) ) )
+ InsColor( *pColTbl, pCol->GetValue() );
+ }
+
+ // das Frame Hintergrund - Attribut
+ {
+ const SvxBrushItem* pBkgrd = (const SvxBrushItem*)GetDfltAttr(
+ RES_BACKGROUND );
+ InsColor( *pColTbl, pBkgrd->GetColor() );
+// InsColor( *pColTbl, pBkgrd->GetBrush().GetFillColor() );
+ if( 0 != ( pBkgrd = (const SvxBrushItem*)rPool.GetPoolDefaultItem(
+ RES_BACKGROUND ) ))
+ {
+ InsColor( *pColTbl, pBkgrd->GetColor() );
+// InsColor( *pColTbl, pBkgrd->GetBrush().GetFillColor() );
+ }
+ nMaxItem = rPool.GetItemCount(RES_BACKGROUND);
+ for( n = 0; n < nMaxItem; ++n )
+ if( 0 != (pBkgrd = (const SvxBrushItem*)rPool.GetItem(
+ RES_BACKGROUND, n ) ))
+ {
+ InsColor( *pColTbl, pBkgrd->GetColor() );
+// InsColor( *pColTbl, pBkgrd->GetBrush().GetFillColor() );
+ }
+ }
+
+ // das Frame Schatten - Attribut
+ {
+ const SvxShadowItem* pShadow = (const SvxShadowItem*)GetDfltAttr(
+ RES_SHADOW );
+ InsColor( *pColTbl, pShadow->GetColor() );
+// InsColor( *pColTbl, pShadow->GetBrush().GetFillColor() );
+ if( 0 != ( pShadow = (const SvxShadowItem*)rPool.GetPoolDefaultItem(
+ RES_SHADOW ) ))
+ {
+ InsColor( *pColTbl, pShadow->GetColor() );
+// InsColor( *pColTbl, pShadow->GetBrush().GetFillColor() );
+ }
+ nMaxItem = rPool.GetItemCount(RES_SHADOW);
+ for( n = 0; n < nMaxItem; ++n )
+ if( 0 != (pShadow = (const SvxShadowItem*)rPool.GetItem(
+ RES_SHADOW, n ) ) )
+ {
+ InsColor( *pColTbl, pShadow->GetColor() );
+// InsColor( *pColTbl, pShadow->GetBrush().GetFillColor() );
+ }
+ }
+
+ // das Frame Umrandungs - Attribut
+ {
+ // Box muesste noch gemacht werden, aber default nie eine Line gesetzt!
+ const SvxBoxItem* pBox;
+ if( 0 != ( pBox = (const SvxBoxItem*)rPool.GetPoolDefaultItem(
+ RES_BOX ) ))
+ InsColorLine( *pColTbl, *pBox );
+ nMaxItem = rPool.GetItemCount(RES_BOX);
+ for( n = 0; n < nMaxItem; ++n )
+ if( 0 != (pBox = (const SvxBoxItem*)rPool.GetItem( RES_BOX, n ) ))
+ InsColorLine( *pColTbl, *pBox );
+ }
+
+ // und raus damit
+ Strm() << SwRTFWriter::sNewLine << '{' << sRTF_COLORTBL;
+
+ for( n = 0; n < pColTbl->Count(); n++ )
+ {
+ const Color& rCol = (*pColTbl)[ n ];
+ Strm() << sRTF_RED;
+#ifdef VCL
+ OutULong( rCol.GetRed() ) << sRTF_GREEN;
+ OutULong( rCol.GetGreen() ) << sRTF_BLUE;
+ OutULong( rCol.GetBlue() ) << ';';
+#else
+ OutULong( ( rCol.GetRed() & 0xff00 ) >> 8 ) << sRTF_GREEN;
+ OutULong( ( rCol.GetGreen() & 0xff00 ) >> 8 ) << sRTF_BLUE;
+ OutULong( ( rCol.GetBlue() & 0xff00 ) >> 8 ) << ';';
+#endif
+ }
+ Strm() << '}';
+}
+
+
+static void _OutFont( SwRTFWriter& rWrt, const SvxFontItem& rFont, USHORT nNo )
+{
+ rWrt.Strm() << '{' << sRTF_F;
+
+ const char* pStr = sRTF_FNIL;
+ switch( rFont.GetFamily() )
+ {
+ case FAMILY_ROMAN: pStr = sRTF_FROMAN; break;
+ case FAMILY_SWISS: pStr = sRTF_FSWISS; break;
+ case FAMILY_MODERN: pStr = sRTF_FMODERN; break;
+ case FAMILY_SCRIPT: pStr = sRTF_FSCRIPT; break;
+ case FAMILY_DECORATIVE: pStr = sRTF_FDECOR; break;
+ }
+ rWrt.OutULong( nNo ) << pStr << sRTF_FPRQ;
+
+ USHORT nVal = 0;
+ switch( rFont.GetPitch() )
+ {
+ case PITCH_FIXED: nVal = 1; break;
+ case PITCH_VARIABLE: nVal = 2; break;
+ }
+ rWrt.OutULong( nVal );
+
+ rtl_TextEncoding eChrSet = rFont.GetCharSet();
+ if( RTL_TEXTENCODING_DONTKNOW == eChrSet )
+ {
+ ASSERT( FALSE, "Wrong font encoding" );
+ eChrSet = RTL_TEXTENCODING_MS_1252;
+ }
+ rWrt.Strm() << sRTF_FCHARSET;
+ rWrt.OutULong( rtl_getBestWindowsCharsetFromTextEncoding( eChrSet ) );
+
+ rWrt.Strm() << ' ';
+ RTFOutFuncs::Out_String( rWrt.Strm(), rFont.GetFamilyName(), DEF_ENCODING,
+ rWrt.bWriteHelpFmt ) << ";}";
+}
+
+void SwRTFWriter::OutRTFFontTab()
+{
+ USHORT n = 0;
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ const SvxFontItem* pFont = (const SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT );
+
+ Strm() << SwRTFWriter::sNewLine << '{' << sRTF_FONTTBL;
+ _OutFont( *this, *pFont, n++ );
+
+ if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem(
+ RES_CHRATR_FONT )))
+ _OutFont( *this, *pFont, n++ );
+
+ PutNumFmtFontsInAttrPool();
+
+ USHORT nMaxItem = rPool.GetItemCount( RES_CHRATR_FONT );
+ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
+ if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem(
+ RES_CHRATR_FONT, nGet )) )
+ _OutFont( *this, *pFont, n++ );
+
+ Strm() << '}';
+}
+
+
+
+void SwRTFWriter::OutRTFStyleTab()
+{
+ // das 0-Style ist das Default, wird nie ausgegeben !!
+ USHORT nArrLen = pDoc->GetTxtFmtColls()->Count();
+ if( nArrLen <= 1 && pDoc->GetCharFmts()->Count() <= 1 )
+ return;
+
+ bOutStyleTab = TRUE;
+ Strm() << SwRTFWriter::sNewLine << '{' << sRTF_STYLESHEET;
+
+ // das Default-TextStyle wird nicht mit ausgegeben !!
+ for( USHORT n = 1; n < nArrLen; ++n )
+ {
+ const SwTxtFmtColl* pColl = (*pDoc->GetTxtFmtColls())[ n ];
+ pAttrSet = &pColl->GetAttrSet();
+
+ Strm() << '{';
+ // gebe Attribute aus
+ OutRTF_SwFmt( *this, *pColl );
+
+ if( pColl->DerivedFrom() )
+ // suche die Id vom "Parent" Format
+ for( USHORT nBasedOn=1; nBasedOn < nArrLen; nBasedOn++)
+ if( (*pDoc->GetTxtFmtColls())[ nBasedOn ] ==
+ pColl->DerivedFrom() )
+ {
+ // die Ableitung vom Format
+ Strm() << sRTF_SBASEDON;
+ OutULong( nBasedOn );
+ break;
+ }
+
+ if( pColl == &pColl->GetNextTxtFmtColl() )
+ {
+ Strm() << sRTF_SNEXT;
+ OutULong( n );
+ }
+ else
+ // suche die Id vom "Naechsten" Format
+ for( USHORT nNext=1; nNext < nArrLen; nNext++)
+ if( (*pDoc->GetTxtFmtColls())[ nNext ] ==
+ &pColl->GetNextTxtFmtColl() )
+ {
+ // die Ableitung vom Format
+ Strm() << sRTF_SNEXT;
+ OutULong( nNext );
+ break;
+ }
+
+ if( NO_NUMBERING != pColl->GetOutlineLevel() )
+ {
+ Strm() << '{' << sRTF_IGNORE << sRTF_SOUTLVL;
+ OutULong( pColl->GetOutlineLevel() ) << '}';
+ }
+
+ Strm() << ' ';
+ RTFOutFuncs::Out_String( Strm(), pColl->GetName(), DEF_ENCODING,
+ bWriteHelpFmt ) << ";}" << SwRTFWriter::sNewLine;
+ }
+
+ USHORT nChrArrLen = pDoc->GetCharFmts()->Count();
+ for( n = 1; n < nChrArrLen; ++n )
+ {
+ const SwCharFmt* pFmt = (*pDoc->GetCharFmts())[ n ];
+ pAttrSet = &pFmt->GetAttrSet();
+
+ Strm() << '{';
+ // gebe Attribute aus
+ OutRTF_SwFmt( *this, *pFmt );
+
+ if( pFmt->DerivedFrom() )
+ // suche die Id vom "Parent" Format
+ for( USHORT nBasedOn=1; nBasedOn < nChrArrLen; nBasedOn++)
+ if( (*pDoc->GetCharFmts())[ nBasedOn ] ==
+ pFmt->DerivedFrom() )
+ {
+ // die Ableitung vom Format
+ Strm() << sRTF_SBASEDON;
+ OutULong( nArrLen + nBasedOn );
+ break;
+ }
+
+ Strm() << ' ';
+ RTFOutFuncs::Out_String( Strm(), pFmt->GetName(), DEF_ENCODING,
+ bWriteHelpFmt ) << ";}" << SwRTFWriter::sNewLine;
+ }
+
+ Strm() << '}';
+ bOutStyleTab = FALSE;
+}
+
+
+void SwRTFWriter::OutRTFFlyFrms( const SwFlyFrmFmt& rFlyFrmFmt )
+{
+ // ein FlyFrame wurde erkannt, gebe erstmal den aus
+
+ // Hole vom Node und vom letzten Node die Position in der Section
+ const SwFmtCntnt& rFlyCntnt = rFlyFrmFmt.GetCntnt();
+
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ ULONG nEnd = pDoc->GetNodes()[ nStt - 1 ]->EndOfSectionIndex();
+
+ if( nStt >= nEnd ) // kein Bereich, also kein gueltiger Node
+ return;
+
+ Strm() << SwRTFWriter::sNewLine << sRTF_PARD << sRTF_PLAIN;
+
+ {
+ RTFSaveData aSaveData( *this, nStt, nEnd );
+ pFlyFmt = (SwFlyFrmFmt*)&rFlyFrmFmt;
+ Out_SwDoc( pCurPam );
+ }
+
+ Strm() << sRTF_PARD << SwRTFWriter::sNewLine;
+}
+
+
+void SwRTFWriter::OutBookmarks( xub_StrLen nCntntPos )
+{
+ // hole das aktuelle Bookmark
+ const SwBookmark* pBookmark = USHRT_MAX != nBkmkTabPos ?
+ pDoc->GetBookmarks()[ nBkmkTabPos ] : 0;
+ // Ausgabe von Bookmarks
+ while( USHRT_MAX != nBkmkTabPos &&
+ pBookmark->GetPos().nNode.GetIndex() ==
+ pCurPam->GetPoint()->nNode.GetIndex() &&
+ pBookmark->GetPos().nContent.GetIndex() == nCntntPos )
+ {
+ // zur Zeit umspannt das SwBookmark keinen Bereich also kann
+ // es hier vollstaendig ausgegeben werden.
+
+ // erst die SWG spezifischen Daten:
+ if( pBookmark->GetShortName().Len() ||
+ pBookmark->GetKeyCode().GetCode() )
+ {
+ OutComment( *this, sRTF_BKMKKEY );
+ OutULong( ( pBookmark->GetKeyCode().GetCode() |
+ pBookmark->GetKeyCode().GetModifier() ));
+ if( !pBookmark->GetShortName().Len() )
+ Strm() << " " ;
+ else
+ {
+ Strm() << ' ';
+ OutRTF_AsByteString( *this, pBookmark->GetShortName() );
+ }
+ Strm() << '}';
+ }
+ OutComment( *this, sRTF_BKMKSTART ) << ' ';
+ RTFOutFuncs::Out_String( Strm(), pBookmark->GetName(),
+ DEF_ENCODING, bWriteHelpFmt ) << '}';
+
+ OutComment( *this, sRTF_BKMKEND ) << ' ';
+ RTFOutFuncs::Out_String( Strm(), pBookmark->GetName(),
+ DEF_ENCODING, bWriteHelpFmt ) << '}';
+
+ if( ++nBkmkTabPos >= pDoc->GetBookmarks().Count() )
+ nBkmkTabPos = USHRT_MAX;
+ else
+ pBookmark = pDoc->GetBookmarks()[ nBkmkTabPos ];
+ }
+}
+
+
+void SwRTFWriter::OutFlyFrm()
+{
+ if( !pFlyPos )
+ return;
+
+ // gebe alle freifliegenden Rahmen die sich auf den akt. Absatz
+ // und evt. auf das aktuelle Zeichen beziehen, aus.
+
+ // suche nach dem Anfang der FlyFrames
+ for( USHORT n = 0; n < pFlyPos->Count() &&
+ (*pFlyPos)[n]->GetNdIndex().GetIndex() <
+ pCurPam->GetPoint()->nNode.GetIndex(); ++n )
+ ;
+ if( n < pFlyPos->Count() )
+ while( n < pFlyPos->Count() &&
+ pCurPam->GetPoint()->nNode.GetIndex() ==
+ (*pFlyPos)[n]->GetNdIndex().GetIndex() )
+ {
+ // den Array-Iterator weiterschalten, damit nicht doppelt
+ // ausgegeben wird !!
+ OutRTFFlyFrms( (const SwFlyFrmFmt&)(*pFlyPos)[n++]->GetFmt() );
+ }
+}
+
+
+USHORT SwRTFWriter::GetId( const Color& rColor ) const
+{
+ ASSERT( pColTbl, "Wo ist meine Color-Tabelle?" );
+ for( USHORT n = 0; n < pColTbl->Count(); n++ )
+ if( rColor == (*pColTbl)[ n ] )
+ return n;
+
+ ASSERT( FALSE, "Color nicht in der Tabelle" );
+ return 0;
+}
+
+USHORT SwRTFWriter::GetId( const SvxFontItem& rFont ) const
+{
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ const SvxFontItem* pFont = (const SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT );
+ if( rFont == *pFont )
+ return 0;
+
+ USHORT n = 1;
+ if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem(
+ RES_CHRATR_FONT )))
+ {
+ if( rFont == *pFont )
+ return 1;
+ ++n;
+ }
+
+ USHORT nMaxItem = rPool.GetItemCount( RES_CHRATR_FONT );
+ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
+ if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem(
+ RES_CHRATR_FONT, nGet )) )
+ {
+ if( rFont == *pFont )
+ return n;
+ ++n;
+ }
+
+ ASSERT( FALSE, "Font nicht in der Tabelle" );
+ return 0;
+}
+
+USHORT SwRTFWriter::GetId( const Font& rFont ) const
+{
+ return GetId( SvxFontItem( rFont.GetFamily(), rFont.GetName(),
+ rFont.GetStyleName(), rFont.GetPitch(),
+ rFont.GetCharSet() ) );
+}
+
+USHORT SwRTFWriter::GetId( const SwTxtFmtColl& rColl ) const
+{
+ // suche das angegebene Format
+ const SvPtrarr & rArr = *pDoc->GetTxtFmtColls();
+ for( USHORT n = 0; n < rArr.Count(); n++ )
+ if( (SwTxtFmtColl*)rArr[ n ] == &rColl )
+ return n;
+ ASSERT( FALSE, "TextCollection nicht in der Tabelle" );
+ return 0;
+}
+
+USHORT SwRTFWriter::GetId( const SwCharFmt& rFmt ) const
+{
+ // suche das angegebene Format
+ const SvPtrarr & rArr = *pDoc->GetCharFmts();
+ for( USHORT n = 0; n < rArr.Count(); n++ )
+ if( (SwCharFmt*)rArr[ n ] == &rFmt )
+ return n + pDoc->GetTxtFmtColls()->Count();
+ ASSERT( FALSE, "CharDFFormat nicht in der Tabelle" );
+ return 0;
+}
+
+void SwRTFWriter::OutPageDesc()
+{
+ // Ausgabe der Page-Descriptoren
+ USHORT nSize = pDoc->GetPageDescCnt();
+ if( !nSize )
+ return;
+
+ Strm() << SwRTFWriter::sNewLine; // ein Trenner
+ bOutPageDesc = bOutPageDescTbl = TRUE;
+ OutComment( *this, sRTF_PGDSCTBL );
+ for( USHORT n = 0; n < nSize; ++n )
+ {
+ const SwPageDesc& rPageDesc = pDoc->GetPageDesc( n );
+
+ Strm() << SwRTFWriter::sNewLine << '{' << sRTF_PGDSC;
+ OutULong( n ) << sRTF_PGDSCUSE;
+ OutULong( rPageDesc.ReadUseOn() );
+
+ OutRTFPageDescription( rPageDesc, FALSE, FALSE );
+
+ // suche den Folge-PageDescriptor:
+ USHORT i = nSize;
+ while( i )
+ if( rPageDesc.GetFollow() == &pDoc->GetPageDesc( --i ) )
+ break;
+ Strm() << sRTF_PGDSCNXT;
+ OutULong( i ) << ' ';
+ RTFOutFuncs::Out_String( Strm(), rPageDesc.GetName(),
+ DEF_ENCODING, bWriteHelpFmt ) << ";}";
+ }
+ Strm() << '}' << SwRTFWriter::sNewLine;
+ bOutPageDesc = bOutPageDescTbl = FALSE;
+}
+
+void SwRTFWriter::OutRTFPageDescription( const SwPageDesc& rPgDsc,
+ BOOL bWriteReset,
+ BOOL bCheckForFirstPage )
+{
+ // jetzt noch den Teil fuer alle anderen Applikationen:
+ const SwPageDesc *pSave = pAktPageDesc;
+ BOOL bOldOut = bOutPageDesc, bOldHDFT = bOutLeftHeadFoot;
+
+ // falls es einen Follow gibt,
+ pAktPageDesc = &rPgDsc;
+ if( bCheckForFirstPage && pAktPageDesc->GetFollow() &&
+ pAktPageDesc->GetFollow() != pAktPageDesc )
+ pAktPageDesc = pAktPageDesc->GetFollow();
+
+ bOutPageDesc = TRUE;
+ bOutLeftHeadFoot = FALSE;
+
+ if( bWriteReset )
+ {
+ if( bFirstLine && bWriteAll &&
+ pCurPam->GetPoint()->nNode == pOrigPam->Start()->nNode )
+ Strm() << sRTF_SECTD << sRTF_SBKNONE;
+ else
+ Strm() << sRTF_SECT << sRTF_SECTD;
+ }
+
+ if( pAktPageDesc->GetLandscape() )
+ Strm() << sRTF_LNDSCPSXN;
+
+ const SwFmt *pFmt = &pAktPageDesc->GetMaster(); //GetLeft();
+ OutRTF_SwFmt( *this, *pFmt );
+
+ // falls es gesharte Heaer/Footer gibt, so gebe diese auch noch aus
+ if( PD_MIRROR & pAktPageDesc->GetUseOn() &&
+ !pAktPageDesc->IsFooterShared() || !pAktPageDesc->IsHeaderShared() )
+ {
+ bOutLeftHeadFoot = TRUE;
+ const SfxPoolItem* pHt;
+ if( !pAktPageDesc->IsHeaderShared() &&
+ SFX_ITEM_SET == pAktPageDesc->GetLeft().GetAttrSet().
+ GetItemState( RES_HEADER, FALSE, &pHt ))
+ OutRTF_SwFmtHeader( *this, *pHt );
+
+ if( !pAktPageDesc->IsFooterShared() &&
+ SFX_ITEM_SET == pAktPageDesc->GetLeft().GetAttrSet().
+ GetItemState( RES_FOOTER, FALSE, &pHt ))
+ OutRTF_SwFmtFooter( *this, *pHt );
+ bOutLeftHeadFoot = FALSE;
+ }
+
+ if( pAktPageDesc != &rPgDsc )
+ {
+ pAktPageDesc = &rPgDsc;
+ Strm() << sRTF_TITLEPG;
+
+ // die Header/Footer der 1. Seite ausgeben
+ const SfxPoolItem* pHt;
+ if( SFX_ITEM_SET == pAktPageDesc->GetMaster().GetAttrSet().
+ GetItemState( RES_HEADER, FALSE, &pHt ))
+ OutRTF_SwFmtHeader( *this, *pHt );
+
+ if( SFX_ITEM_SET == pAktPageDesc->GetMaster().GetAttrSet().
+ GetItemState( RES_FOOTER, FALSE, &pHt ))
+ OutRTF_SwFmtFooter( *this, *pHt );
+ }
+
+ pAktPageDesc = pSave;
+ bOutPageDesc = bOldOut;
+ bOutLeftHeadFoot = bOldHDFT;
+}
+
+BOOL SwRTFWriter::OutBreaks( const SfxItemSet& rSet )
+{
+ // dann nie Seitenumbrueche ausgeben
+ BOOL bPgDscWrite = FALSE;
+
+ if( !bOutOutlineOnly && bOutPageAttr && !bIgnoreNextPgBreak)
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, TRUE, &pItem )
+ && ((SwFmtPageDesc*)pItem)->GetPageDesc() )
+ {
+ const SwFmtPageDesc& rPgDsc = *(SwFmtPageDesc*)pItem;
+ for( USHORT nPos = pDoc->GetPageDescCnt(); nPos; )
+ if( &pDoc->GetPageDesc( --nPos ) == rPgDsc.GetPageDesc() )
+ {
+ pAktPageDesc = ((SwFmtPageDesc*)pItem)->GetPageDesc();
+ // FALSE wegen schliessender Klammer !!
+ OutComment( *this, sRTF_PGDSCNO, FALSE );
+ OutULong( nPos ) << '}';
+
+ // nicht weiter, in Styles gibts keine SectionControls !!
+ if( !bOutStyleTab )
+ OutRTFPageDescription( *rPgDsc.GetPageDesc(),
+ TRUE, TRUE );
+ bPgDscWrite = TRUE;
+ break;
+ }
+ }
+ else if( SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, TRUE, &pItem ) )
+ {
+ const SvxFmtBreakItem &rBreak = *(SvxFmtBreakItem*)pItem;
+ if( bWriteHelpFmt )
+ {
+ if( SVX_BREAK_PAGE_BEFORE == rBreak.GetBreak() ||
+ SVX_BREAK_PAGE_AFTER == rBreak.GetBreak() ||
+ SVX_BREAK_PAGE_BOTH == rBreak.GetBreak() )
+ {
+ bOutFmtAttr = TRUE;
+ Strm() << sRTF_PAGE;
+ }
+ }
+ else
+ switch( rBreak.GetBreak() )
+ {
+ case SVX_BREAK_COLUMN_BEFORE:
+ case SVX_BREAK_COLUMN_AFTER:
+ case SVX_BREAK_COLUMN_BOTH:
+ break;
+
+ case SVX_BREAK_PAGE_BEFORE:
+ bOutFmtAttr = TRUE;
+ Strm() << sRTF_PAGE;
+ break;
+
+ case SVX_BREAK_PAGE_AFTER:
+ OutComment( *this, sRTF_PGBRK, FALSE ) << "0}";
+ break;
+
+ case SVX_BREAK_PAGE_BOTH:
+ OutComment( *this, sRTF_PGBRK, FALSE ) << "1}";
+ break;
+ }
+ }
+ }
+ bIgnoreNextPgBreak = FALSE;
+ return bPgDscWrite;
+}
+
+
+void SwRTFWriter::CheckEndNodeForSection( const SwNode& rNd )
+{
+ const SwSectionNode* pSectNd = rNd.FindStartNode()->GetSectionNode();
+ if( pSectNd /*&& CONTENT_SECTION == pSectNd->GetSection().GetType()*/ )
+ {
+ const SwSectionFmt* pSectFmt = pSectNd->GetSection().GetFmt();
+
+ // diese Section hatte den akt. Abschnitt bestimmt
+ // wer bestimmt den nachsten??
+ SwNodeIndex aIdx( rNd, 1 );
+ pSectNd = aIdx.GetNode().GetSectionNode();
+ if( !( ( pSectNd || aIdx.GetNode().IsEndNode() &&
+ 0 != ( pSectNd = aIdx.GetNode().FindStartNode()->GetSectionNode() ))
+ /*&& CONTENT_SECTION == pSectNd->GetSection().GetType()*/ ))
+ {
+ // wer bestimmt denn nun den neuen Abschnitt?
+ // PageDesc oder eine uebergeordnete Section?
+ SwSection* pParent = pSectFmt->GetParentSection();
+// while( pParent /*&& CONTENT_SECTION != pParent->GetType()*/ )
+// pParent = pParent->GetParent();
+
+ if( pParent /*&& CONTENT_SECTION == pParent->GetType()*/ )
+ OutRTF_SwSectionNode( *this, *pParent->
+ GetFmt()->GetSectionNode( TRUE ) );
+ else
+ {
+ Strm() << sRTF_SECT << sRTF_SECTD << sRTF_SBKNONE;
+ OutRTFPageDescription( ( pAktPageDesc
+ ? *pAktPageDesc
+ : pDoc->GetPageDesc(0) ),
+ FALSE, TRUE );
+ Strm() << SwRTFWriter::sNewLine;
+ }
+ }
+ // else
+ // weiter machen, der naechste definiert den neuen Abschnitt
+ }
+}
+
+// Struktur speichert die aktuellen Daten des Writers zwischen, um
+// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
+RTFSaveData::RTFSaveData( SwRTFWriter& rWriter, ULONG nStt, ULONG nEnd )
+ : rWrt( rWriter ),
+ pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ),
+ pOldFlyFmt( rWrt.pFlyFmt ), pOldPageDesc( rWrt.pAktPageDesc ),
+ pOldAttrSet( rWrt.pAttrSet )
+
+{
+ bOldWriteAll = rWrt.bWriteAll;
+ bOldOutTable = rWrt.bOutTable;
+ bOldOutPageAttr = rWrt.bOutPageAttr;
+ bOldAutoAttrSet = rWrt.bAutoAttrSet;
+ bOldOutSection = rWrt.bOutSection;
+
+ rWrt.pCurPam = rWrt.NewSwPaM( *rWrt.pDoc, nStt, nEnd );
+
+ // Tabelle in Sonderbereichen erkennen
+ if( nStt != rWrt.pCurPam->GetMark()->nNode.GetIndex() &&
+ rWrt.pDoc->GetNodes()[ nStt ]->IsTableNode() )
+ rWrt.pCurPam->GetMark()->nNode = nStt;
+
+ rWrt.SetEndPaM( rWrt.pCurPam );
+ rWrt.pCurPam->Exchange( );
+ rWrt.bWriteAll = TRUE;
+ rWrt.bOutTable = FALSE;
+ rWrt.bOutPageAttr = FALSE;
+ rWrt.pAttrSet = 0;
+ rWrt.bAutoAttrSet = FALSE;
+ rWrt.bOutSection = FALSE;
+}
+
+
+RTFSaveData::~RTFSaveData()
+{
+ delete rWrt.pCurPam; // Pam wieder loeschen
+
+ rWrt.pCurPam = pOldPam;
+ rWrt.SetEndPaM( pOldEnd );
+ rWrt.bWriteAll = bOldWriteAll;
+ rWrt.bOutTable = bOldOutTable;
+ rWrt.pFlyFmt = pOldFlyFmt;
+ rWrt.pAktPageDesc = pOldPageDesc;
+ rWrt.pAttrSet = pOldAttrSet;
+ rWrt.bAutoAttrSet = bOldAutoAttrSet;
+ rWrt.bOutPageAttr = bOldOutPageAttr;
+ rWrt.bOutSection = bOldOutSection;
+}
+
+
+void GetRTFWriter( const String& rFltName, WriterRef& xRet )
+{
+ xRet = new SwRTFWriter( rFltName );
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/rtf/wrtrtf.cxx,v 1.1.1.1 2000-09-18 17:14:56 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.202 2000/09/18 16:04:51 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.201 2000/08/22 20:51:18 jp
+ OutHeader: don't ask for DBName
+
+ Revision 1.200 2000/08/04 10:48:32 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character; use rtfout functions
+
+ Revision 1.199 2000/07/04 16:23:30 jp
+ AMA_TEST define removed
+
+ Revision 1.198 2000/05/09 17:23:08 jp
+ Changes for Unicode
+
+ Revision 1.197 2000/03/03 16:22:05 pl
+ #73771# workaround for c50 intel compiler
+
+ Revision 1.196 2000/03/03 15:21:02 os
+ StarView remainders removed
+
+ Revision 1.195 2000/02/24 18:30:25 jp
+ Bug #73485#: write right follow of pagedesc, initialize the akt. pagedesc
+
+ Revision 1.194 2000/01/25 20:10:34 jp
+ Bug #72146#: _OutFont - replace system/dontknow charset to the current charset
+
+ Revision 1.193 1999/11/22 18:00:05 jp
+ OutSectionNode: dont skip to top parent section
+
+ Revision 1.192 1999/10/25 12:16:40 jp
+ get font charset over RTL-Function
+
+ Revision 1.191 1999/08/05 20:53:50 JP
+ write flyfrms before the paragraph and not behind
+
+
+ Rev 1.190 05 Aug 1999 22:53:50 JP
+ write flyfrms before the paragraph and not behind
+
+ Rev 1.189 22 Jul 1999 20:01:10 JP
+ read&write footer and header height
+
+ Rev 1.188 23 Jun 1999 19:12:30 JP
+ optimize for NumRules, interface of FindPos_Bkmk has changed
+
+ Rev 1.187 16 Jun 1999 19:49:06 JP
+ Change interface of base class Writer
+
+ Rev 1.186 04 May 1999 15:00:02 JP
+ FilterExportklasse Writer von SvRef abgeleitet, damit sie immer zerstoert wird
+
+ Rev 1.185 06 Apr 1999 17:00:18 JP
+ Bug #64361#: MakeHeader - ggfs. ersten PageDesc vom 1.Node besorgen
+
+ Rev 1.184 19 Mar 1999 17:08:06 JP
+ Bug #63772#: Spaltige Bereiche im-/exportieren
+
+ Rev 1.183 18 Mar 1999 09:51:54 JP
+ Task #63049#: Numerierung mit rel. Einzuegen
+
+ Rev 1.182 16 Mar 1999 23:20:00 JP
+ Task #63049#: Einzuege bei NumRules relativ
+
+ Rev 1.181 05 Mar 1999 14:44:34 JP
+ Bug #57749#: spaltige Bereiche schreiben - alle Section-Typen
+
+ Rev 1.180 04 Mar 1999 19:59:22 JP
+ Bug #57749#: spaltige Bereiche schreiben
+
+ Rev 1.179 17 Nov 1998 10:45:52 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.178 09 Nov 1998 17:28:46 JP
+ Bug #58817#: StyleTabelle wieder schreiben
+
+ Rev 1.177 30 Oct 1998 18:30:26 JP
+ Task #58596#: neues Flag an der Writerklasse -> schreibe nur die 1. Tabelle
+
+ Rev 1.176 28 Oct 1998 10:36:12 JP
+ Bug #58565#: Assert im OutHeader behoben
+
+ Rev 1.175 11 Aug 1998 12:16:36 JP
+ Bug #54796#: fehlender Numerierunstyp und Bugfixes
+
+ Rev 1.174 06 Aug 1998 21:45:56 JP
+ Bug #54796#: neue NumerierungsTypen (WW97 kompatibel)
+
+ Rev 1.173 04 Jun 1998 19:28:08 JP
+ Bug #50887#: Font bei Grafik-NumFormaten ist 0, also default Font schreiben
+
+ Rev 1.172 13 May 1998 17:15:22 JP
+ OutRTFPageDesc: beim 1.PageDesc keinen Sectionbreak schreiben
+
+ Rev 1.171 11 May 1998 22:50:32 JP
+ Zeichenvorlagen schreiben
+
+ Rev 1.170 11 May 1998 16:46:50 JP
+ RTF-CharFormate ausgeben
+
+ Rev 1.169 05 May 1998 14:00:26 JP
+ linke/rechte Header/Footer korrekt rausschreiben
+
+ Rev 1.168 20 Apr 1998 17:43:20 JP
+ neu: Numerierung lesen/schreiben
+
+ Rev 1.167 03 Apr 1998 18:51:56 JP
+ RTF-Parser um neue Tokens erweitert
+
+ Rev 1.166 20 Feb 1998 13:36:40 MA
+ headerfiles gewandert
+
+ Rev 1.165 29 Jan 1998 21:35:24 JP
+ GetEndOfIcons ersetzt durch GetEndOfExtras, das auf GetEndOfRedlines mappt
+
+ Rev 1.164 27 Jan 1998 21:50:18 JP
+ GetNumDepend durch GetDepends ersetzt
+
+ Rev 1.163 26 Nov 1997 15:05:30 MA
+ headerfiles
+
+ Rev 1.162 09 Oct 1997 14:27:52 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.161 12 Sep 1997 10:57:22 OS
+ ITEMID_* definiert
+
+ Rev 1.160 03 Sep 1997 08:58:52 OS
+ Header
+
+ Rev 1.159 29 Aug 1997 13:53:24 JP
+ VCL Color Anpassung
+
+ Rev 1.158 15 Aug 1997 12:51:42 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.157 11 Aug 1997 17:48:44 OS
+ Header-Umstellung
+
+ Rev 1.156 07 Aug 1997 15:06:36 OM
+ Headerfile-Umstellung
+
+ Rev 1.155 07 Apr 1997 16:35:10 JP
+ Das ShowProgressFlag der Writerklasse auswerten
+
+ Rev 1.154 17 Feb 1997 12:03:44 MA
+ opt: Outline schneller schreiben wenn Gliederung nur im Body
+
+ Rev 1.153 15 Feb 1997 17:57:14 JP
+ OutStyleTab: pAttrSet Pointer wieder clearen
+
+ Rev 1.152 15 Feb 1997 17:00:22 JP
+ neu: nur Gliederungsabsaetze schreiben
+
+ Rev 1.151 14 Jan 1997 08:51:42 MA
+ includes
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/rtf/wrtrtf.hxx b/sw/source/filter/rtf/wrtrtf.hxx
new file mode 100644
index 000000000000..7ee3b41e9d90
--- /dev/null
+++ b/sw/source/filter/rtf/wrtrtf.hxx
@@ -0,0 +1,244 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtrtf.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:56 $
+ *
+ * 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 _WRTRTF_HXX
+#define _WRTRTF_HXX
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _WRT_FN_HXX
+#include <wrt_fn.hxx>
+#endif
+
+// einige Forward Deklarationen
+class Color;
+class Font;
+class SvPtrarr;
+class RTFColorTbl;
+class SwFmt;
+class SwFmtColl;
+class SwFlyFrmFmt;
+class SwPosFlyFrms;
+class SwPageDesc;
+class SwTableNode;
+class SwTxtFmtColl;
+class SwNumRule;
+class SwNumRuleTbl;
+class SwNodeNum;
+class DateTime;
+
+extern SwAttrFnTab aRTFAttrFnTab;
+extern SwNodeFnTab aRTFNodeFnTab;
+
+// the text encoding for the export
+#ifdef MAC
+#define DEF_ENCODING RTL_TEXTENCODING_APPLE_ROMAN
+#else
+#define DEF_ENCODING RTL_TEXTENCODING_MS_1252
+#endif
+
+
+// der RTF-Writer
+
+class SwRTFWriter : public Writer
+{
+ SvPtrarr* pFontRemoveLst;
+ RTFColorTbl* pColTbl;
+ SwPosFlyFrms* pFlyPos; // Pointer auf die aktuelle "FlyFrmTabelle"
+ USHORT nAktFlyPos; // Index auf das naechste "FlyFrmFmt"
+
+ void OutRTFColorTab();
+ void OutRTFFontTab();
+ void OutRTFStyleTab();
+ void OutRTFListTab();
+
+ void MakeHeader();
+ void OutDocInfoStat();
+ void OutInfoDateTime( const DateTime&, const sal_Char* );
+ void CheckEndNodeForSection( const SwNode& rNd );
+
+
+public:
+ // --- public Member --------------------------------------------------
+
+ SwFlyFrmFmt* pFlyFmt; // liegt der Node in einem FlyFrame,
+ // ist das Format gesetzt, sonst 0
+ const SwPageDesc* pAktPageDesc; // aktuell gesetzter PageDesc.
+ const SwAttrSet* pAttrSet; // akt. Format/Collection vom Node
+ // fuer den Zugriff auf einige Attribute
+ // z.B. Font-Size, LR-Space,..
+ USHORT nBkmkTabPos; // akt. Position in der Bookmark-Tabelle
+ USHORT nFontHeight; // akt. Hoehe vom Font
+
+#if defined(MAC) || defined(UNX)
+ static const sal_Char sNewLine; // nur \012 oder \015
+#else
+ static const sal_Char __FAR_DATA sNewLine[]; // \015\012
+#endif
+
+
+ BOOL bFirstLine : 1; // wird die 1. Zeile ausgegeben ?
+ BOOL bOutFmtAttr : 1; // TRUE: beim Schreiben eines Formates
+ // existierte mindestens ein Attribut
+ BOOL bRTFFlySyntax : 1; // gebe nur original RTFSyntax aus
+ // (nur fuer die fliegenden Rahmen)
+ BOOL bOutPageDesc: 1; // gebe einen PageDescriptor aus
+ BOOL bOutPageDescTbl: 1; // gebe die PageDescriptor-Tabelle aus
+ BOOL bOutTable : 1; // gebe eine Tabelle aus
+ BOOL bTxtAttr : 1; // werden TextAttribute ausgegeben ?
+ BOOL bWriteHelpFmt : 1; // schreibe Win-RTF-HelpFileFmt
+ BOOL bOutStyleTab : 1; // gebe die StyleSheet-Tabelle aus
+ BOOL bOutPageAttr : 1; // PageDescAttribut ausgeben?
+ BOOL bAutoAttrSet : 1; // TRUE: pAttrSet ist harte Attributierung
+ // FALSE: pAttrSet ist vom Format/Collection
+ BOOL bOutOutlineOnly : 1; // TRUE: nur Gliederungs-Absaetze schreiben
+ BOOL bOutListNumTxt : 1; // TRUE: der ListNumText wird ausgegeben
+ BOOL bOutLeftHeadFoot : 1; // gebe vom PageDesc. den linkten
+ // Header/Footer aus
+ BOOL bOutSection : 1; // TRUE: Section PageDesc ausgeben
+ BOOL bIgnoreNextPgBreak : 1; // TRUE: naechsten PageDesc/Break ignorieren
+
+ // --- public Methoden ------------------------------------------------
+
+ SwRTFWriter( const String& rFilterName );
+ virtual ~SwRTFWriter();
+ virtual ULONG WriteStream();
+
+ void Out_SwDoc( SwPaM* ); // schreibe den makierten Bereich
+
+ // gebe die evt. an der akt. Position stehenden FlyFrame aus.
+ void OutFlyFrm();
+ void OutRTFFlyFrms( const SwFlyFrmFmt& );
+ // gebe alle an der Position stehenden Bookmarks aus
+ void OutBookmarks( xub_StrLen nCntntPos );
+ // gebe die PageDesc-Daten im normalen RTF-Format aus
+ void OutRTFPageDescription( const SwPageDesc&, BOOL , BOOL );
+ BOOL OutBreaks( const SfxItemSet& rSet );
+
+ // gebe die PageDescriptoren aus
+ USHORT GetId( const Color& ) const;
+ USHORT GetId( const SvxFontItem& ) const;
+ USHORT GetId( const Font& ) const;
+ USHORT GetId( const SwTxtFmtColl& ) const;
+ USHORT GetId( const SwCharFmt& ) const;
+ USHORT GetId( const SwNumRuleItem& rItem ) const;
+
+ void OutPageDesc();
+
+ void OutListNum( const SwTxtNode& rNd );
+
+ // fuer RTFSaveData
+ SwPaM* GetEndPaM() { return pOrigPam; }
+ void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; }
+};
+
+
+// Struktur speichert die aktuellen Daten des Writers zwischen, um
+// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
+// Mit den beiden USHORTs im CTOR wird ein neuer PaM erzeugt und auf
+// die Position im Dokument gesetzt.
+// Im Destructor werden alle Daten wieder restauriert und der angelegte
+// Pam wieder geloescht.
+
+struct RTFSaveData
+{
+ SwRTFWriter& rWrt;
+ SwPaM* pOldPam, *pOldEnd;
+ BOOL bOldWriteAll : 1;
+ BOOL bOldOutTable : 1;
+ BOOL bOldOutPageAttr : 1;
+ BOOL bOldAutoAttrSet : 1;
+ BOOL bOldOutSection : 1;
+
+ SwFlyFrmFmt* pOldFlyFmt;
+ const SwPageDesc* pOldPageDesc;
+ const SwAttrSet* pOldAttrSet; // akt. Attribute vom Node
+
+ RTFSaveData( SwRTFWriter&, ULONG nStt, ULONG nEnd );
+ ~RTFSaveData();
+};
+
+
+// einige Funktions-Deklarationen
+Writer& OutRTF_AsByteString( Writer& rWrt, const String& rStr );
+Writer& OutRTF_SwFmt( Writer& rWrt, const SwFmt& );
+Writer& OutRTF_SwTblNode( Writer& , SwTableNode & );
+Writer& OutRTF_SwSectionNode( Writer& , SwSectionNode & );
+
+
+// Augabe von RTF-Bitmaps (steht im File "wrtpict.cxx")
+//struct SvxRTFPictureType;
+//class Bitmap;
+//USHORT WriteRTFPict( const SwPictureType&, Bitmap&, SvStream& );
+
+// Ausagbe von Footer-/Headers
+Writer& OutRTF_SwFmtHeader( Writer& , const SfxPoolItem& );
+Writer& OutRTF_SwFmtFooter( Writer& , const SfxPoolItem& );
+
+// Kommentar und zusaetzlichen String ausgeben
+SvStream& OutComment( Writer& rWrt, const sal_Char* pStr );
+ // zusaetzlich das bOutFmtAttr-Flag manipulieren
+SvStream& OutComment( Writer& rWrt, const sal_Char* pStr, BOOL bSetFlag );
+
+#endif // _WRTRTF_HXX
+
+
diff --git a/sw/source/filter/writer/makefile.mk b/sw/source/filter/writer/makefile.mk
new file mode 100644
index 000000000000..bea300064a8e
--- /dev/null
+++ b/sw/source/filter/writer/makefile.mk
@@ -0,0 +1,94 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=writer
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ writer.cxx \
+ wrt_fn.cxx \
+ wrtswtbl.cxx \
+ wrttxatr.cxx \
+
+SLOFILES = \
+ $(SLO)$/writer.obj \
+ $(SLO)$/wrt_fn.obj \
+ $(SLO)$/wrtswtbl.obj \
+ $(SLO)$/wrttxatr.obj \
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx
new file mode 100644
index 000000000000..677df928acee
--- /dev/null
+++ b/sw/source/filter/writer/writer.cxx
@@ -0,0 +1,780 @@
+/*************************************************************************
+ *
+ * $RCSfile: writer.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 _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#define _SVSTDARR_STRINGSSORTDTOR
+#include <svtools/svstdarr.hxx>
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _SFXDOCFILE_HXX //autogen
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _FILTER_HXX //autogen
+#include <svtools/filter.hxx>
+#endif
+#ifndef _SVX_IMPGRF_HXX //autogen
+#include <svx/impgrf.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _EEITEM_HXX
+#include <svx/eeitem.hxx>
+#endif
+
+
+#ifndef _TOOLS_TEMPFILE_HXX
+#include <tools/tempfile.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _NODE_HXX
+#include <node.hxx>
+#endif
+#ifndef _FORMAT_HXX
+#include <format.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx> // fuer SwBookmark ...
+#endif
+#ifndef _NUMRULE_HXX //autogen
+#include <numrule.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+
+// Stringbuffer fuer die umgewandelten Zahlen
+static sal_Char aNToABuf[] = "0000000000000000000000000";
+#define NTOABUFLEN (sizeof(aNToABuf))
+
+DECLARE_TABLE( SwBookmarkNodeTable, SvPtrarr* )
+
+struct Writer_Impl
+{
+ SvStringsSortDtor *pSrcArr, *pDestArr;
+ SvPtrarr* pFontRemoveLst, *pBkmkArr;
+ SwBookmarkNodeTable* pBkmkNodePos;
+
+ Writer_Impl( const SwDoc& rDoc );
+ ~Writer_Impl();
+
+ void RemoveFontList( SwDoc& rDoc );
+ void InsertBkmk( const SwBookmark& rBkmk );
+};
+
+Writer_Impl::Writer_Impl( const SwDoc& rDoc )
+ : pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 )
+{
+}
+
+Writer_Impl::~Writer_Impl()
+{
+ delete pSrcArr;
+ delete pDestArr;
+ delete pFontRemoveLst;
+
+ if( pBkmkNodePos )
+ {
+ for( SvPtrarr* p = pBkmkNodePos->First(); p; p = pBkmkNodePos->Next() )
+ delete p;
+ delete pBkmkNodePos;
+ }
+}
+
+void Writer_Impl::RemoveFontList( SwDoc& rDoc )
+{
+ ASSERT( pFontRemoveLst, "wo ist die FontListe?" );
+ for( USHORT i = pFontRemoveLst->Count(); i; )
+ {
+ SvxFontItem* pItem = (SvxFontItem*)(*pFontRemoveLst)[ --i ];
+ rDoc.GetAttrPool().Remove( *pItem );
+ }
+}
+
+void Writer_Impl::InsertBkmk( const SwBookmark& rBkmk )
+{
+ if( !pBkmkNodePos )
+ pBkmkNodePos = new SwBookmarkNodeTable;
+
+ ULONG nNd = rBkmk.GetPos().nNode.GetIndex();
+ SvPtrarr* pArr = pBkmkNodePos->Get( nNd );
+ if( !pArr )
+ {
+ pArr = new SvPtrarr( 1, 4 );
+ pBkmkNodePos->Insert( nNd, pArr );
+ }
+
+ void* p = (void*)&rBkmk;
+ pArr->Insert( p, pArr->Count() );
+
+ if( rBkmk.GetOtherPos() && rBkmk.GetOtherPos()->nNode != nNd )
+ {
+ nNd = rBkmk.GetOtherPos()->nNode.GetIndex();
+ pArr = pBkmkNodePos->Get( nNd );
+ if( !pArr )
+ {
+ pArr = new SvPtrarr( 1, 4 );
+ pBkmkNodePos->Insert( nNd, pArr );
+ }
+ pArr->Insert( p, pArr->Count() );
+ }
+}
+
+/*
+ * Dieses Modul ist die Zentrale-Sammelstelle fuer alle Write-Filter
+ * und ist eine DLL !
+ *
+ * Damit der Writer mit den unterschiedlichen Writern arbeiten kann,
+ * muessen fuer diese die Ausgabe-Funktionen der Inhalts tragenden
+ * Objecte auf die verschiedenen Ausgabe-Funktionen gemappt werden.
+ *
+ * Dazu kann fuer jedes Object ueber den Which-Wert in einen Tabelle ge-
+ * griffen werden, um seine Ausgabe-Funktion zu erfragen.
+ * Diese Funktionen stehen in den entsprechenden Writer-DLL's.
+ */
+
+Writer::Writer()
+ : pImpl( 0 ), pStrm( 0 ), pOrigPam( 0 ), pOrigFileName( 0 ),
+ pCurPam(0), pDoc( 0 )
+{
+ bWriteAll = bShowProgress = bUCS2_WithStartChar = TRUE;
+ bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR =
+ bWriteClipboardDoc = bWriteOnlyFirstTable = FALSE;
+}
+
+Writer::~Writer()
+{
+}
+
+void Writer::ResetWriter()
+{
+ if( pImpl && pImpl->pFontRemoveLst )
+ pImpl->RemoveFontList( *pDoc );
+ delete pImpl, pImpl = 0;
+
+ if( pCurPam )
+ {
+ while( pCurPam->GetNext() != pCurPam )
+ delete pCurPam->GetNext();
+ delete pCurPam;
+ }
+ pCurPam = 0;
+ pOrigFileName = 0;
+ pDoc = 0;
+ pStrm = 0;
+
+ bShowProgress = bUCS2_WithStartChar = TRUE;
+ bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR =
+ bWriteClipboardDoc = bWriteOnlyFirstTable = FALSE;
+}
+
+BOOL Writer::CopyNextPam( SwPaM ** ppPam )
+{
+ if( (*ppPam)->GetNext() == pOrigPam )
+ {
+ *ppPam = pOrigPam; // wieder auf den Anfangs-Pam setzen
+ return FALSE; // Ende vom Ring
+ }
+
+ // ansonsten kopiere den die Werte aus dem naechsten Pam
+ *ppPam = ((SwPaM*)(*ppPam)->GetNext() );
+
+ *pCurPam->GetPoint() = *(*ppPam)->Start();
+ *pCurPam->GetMark() = *(*ppPam)->End();
+
+ return TRUE;
+}
+
+// suche die naechste Bookmark-Position aus der Bookmark-Tabelle
+
+USHORT Writer::FindPos_Bkmk( const SwPosition& rPos ) const
+{
+ USHORT nRet = USHRT_MAX;
+ const SwBookmarks& rBkmks = pDoc->GetBookmarks();
+
+ if( rBkmks.Count() )
+ {
+ SwBookmark aBkmk( rPos );
+ USHORT nPos;
+ if( rBkmks.Seek_Entry( &aBkmk, &nPos ))
+ {
+ // suche abwaerts nach weiteren Bookmarks auf der Cursor-Position
+ while( 0 < nPos &&
+ rBkmks[ nPos-1 ]->IsEqualPos( aBkmk ))
+ --nPos;
+ }
+ else if( nPos < rBkmks.Count() )
+ nRet = nPos;
+ }
+ return nRet;
+}
+
+
+SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx,
+ BOOL bNodesArray ) const
+{
+ SwNodes* pNds = bNodesArray ? &rDoc.GetNodes() : (SwNodes*)rDoc.GetUndoNds();
+
+ SwNodeIndex aStt( *pNds, nStartIdx );
+ SwCntntNode* pCNode = aStt.GetNode().GetCntntNode();
+ if( !pCNode && 0 == ( pCNode = pNds->GoNext( &aStt )) )
+ ASSERT( !this, "An StartPos kein ContentNode mehr" );
+
+ SwPaM* pNew = new SwPaM( aStt );
+ pNew->SetMark();
+ aStt = nEndIdx;
+ if( 0 == (pCNode = aStt.GetNode().GetCntntNode()) &&
+ 0 == (pCNode = pNds->GoPrevious( &aStt )) )
+ ASSERT( !this, "An StartPos kein ContentNode mehr" );
+ pCNode->MakeEndIndex( &pNew->GetPoint()->nContent );
+ pNew->GetPoint()->nNode = aStt;
+ return pNew;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+// Stream-spezifisches
+#ifndef PRODUCT
+SvStream& Writer::Strm()
+{
+ ASSERT( pStrm, "Oh-oh. Dies ist ein Storage-Writer. Gleich knallts!" );
+ return *pStrm;
+}
+#endif
+
+
+SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen )
+{ // in einen Stream aus
+ // Pointer an das Bufferende setzen
+ sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
+ for( BYTE n = 0; n < nLen; ++n )
+ {
+ *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
+ if( *pStr > '9' )
+ *pStr += 39;
+ nHex >>= 4;
+ }
+ return rStrm << pStr;
+}
+
+SvStream& Writer::OutLong( SvStream& rStrm, long nVal )
+{
+ // Pointer an das Bufferende setzen
+ sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
+
+ int bNeg = nVal < 0;
+ if( bNeg )
+ nVal = -nVal;
+
+ do {
+ *(--pStr) = (sal_Char)(nVal % 10 ) + 48;
+ nVal /= 10;
+ } while( nVal );
+
+ // Ist Zahl negativ, dann noch -
+ if( bNeg )
+ *(--pStr) = '-';
+
+ return rStrm << pStr;
+}
+
+SvStream& Writer::OutULong( SvStream& rStrm, ULONG nVal )
+{
+ // Pointer an das Bufferende setzen
+ sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
+
+ do {
+ *(--pStr) = (sal_Char)(nVal % 10 ) + 48;
+ nVal /= 10;
+ } while ( nVal );
+ return rStrm << pStr;
+}
+
+
+ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName )
+{
+ pStrm = &rStrm;
+ pDoc = rPaM.GetDoc();
+ pOrigFileName = pFName;
+ pImpl = new Writer_Impl( *pDoc );
+
+ // PaM kopieren, damit er veraendert werden kann
+ pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ // zum Vergleich auf den akt. Pam sichern
+ pOrigPam = &rPaM;
+
+ ULONG nRet = WriteStream();
+
+ ResetWriter();
+
+ return nRet;
+}
+
+ULONG Writer::Write( SwPaM& rPam, SfxMedium& rMed, const String* pFileName )
+{
+ return IsStgWriter()
+ ? Write( rPam, *rMed.GetStorage(), pFileName )
+ : Write( rPam, *rMed.GetOutStream(), pFileName );
+}
+
+ULONG Writer::Write( SwPaM& rPam, SvStorage&, const String* )
+{
+ ASSERT( !this, "Schreiben in Storages auf einem Stream?" );
+ return ERR_SWG_WRITE_ERROR;
+}
+
+
+BOOL Writer::CopyLocalFileToINet( String& rFileNm, BOOL bCIdTarget )
+{
+ BOOL bRet = FALSE;
+ INetURLObject aFileUrl( rFileNm ), aTargetUrl( *pOrigFileName );
+ if( ( INET_PROT_FILE == aFileUrl.GetProtocol() ||
+ (bCIdTarget && INET_PROT_CID == aFileUrl.GetProtocol()) ) &&
+ ( (bCIdTarget && INET_PROT_FILE == aTargetUrl.GetProtocol()) ||
+ (!bCIdTarget && INET_PROT_FILE != aTargetUrl.GetProtocol() &&
+ INET_PROT_FTP <= aTargetUrl.GetProtocol() &&
+ INET_PROT_NEWS >= aTargetUrl.GetProtocol()) ) )
+ {
+ if( pImpl->pSrcArr )
+ {
+ // wurde die Datei schon verschoben
+ USHORT nPos;
+ if( pImpl->pSrcArr->Seek_Entry( &rFileNm, &nPos ))
+ {
+ rFileNm = *(*pImpl->pDestArr)[ nPos ];
+ return TRUE;
+ }
+ }
+ else
+ {
+ pImpl->pSrcArr = new SvStringsSortDtor( 4, 4 );
+ pImpl->pDestArr = new SvStringsSortDtor( 4, 4 );
+ }
+
+ String* pSrc = new String( rFileNm );
+
+ String* pDest = 0;
+
+ if( INET_PROT_FILE == aFileUrl.GetProtocol() )
+ {
+ SvFileStream aTmp( aFileUrl.PathToFileName(), STREAM_READ );
+
+ pDest = new String( aTargetUrl.GetPartBeforeLastName() );
+ *pDest += aFileUrl.GetName();
+
+ if( INET_PROT_FILE == aTargetUrl.GetProtocol() )
+ {
+ ASSERT( bCIdTarget,
+ "CopyLocalFile: file->file: CId-Flag nicht gesetzt" );
+ INetURLObject aCpyURL( *pDest );
+ SvFileStream aCpy( aCpyURL.PathToFileName(), STREAM_WRITE );
+ aCpy << aTmp;
+
+ aCpy.Close();
+ bRet = SVSTREAM_OK == aCpy.GetError();
+ }
+ else
+ {
+ ASSERT( !bCIdTarget,
+ "CopyLocalFile: file->net: CId-Flag gesetzt" );
+ SfxMedium aMedium( *pDest, STREAM_WRITE | STREAM_SHARE_DENYNONE,
+ FALSE, FALSE );
+
+ SvFileStream aCpy( aMedium.GetPhysicalName(), STREAM_WRITE );
+ aCpy << aTmp;
+ aCpy.Close();
+
+ aMedium.Close();
+ aMedium.Commit();
+
+ bRet = 0 == aMedium.GetError();
+ }
+ }
+ else
+ {
+ ASSERT( INET_PROT_CID == aFileUrl.GetProtocol(),
+ "CopyLocalFile: cid->file: Source-URL nicht cid" );
+ ASSERT( INET_PROT_FILE == aTargetUrl.GetProtocol(),
+ "CopyLocalFile: cid->file: Target-URL nicht file" );
+ ASSERT( bCIdTarget,
+ "CopyLocalFile: cid->file: CId-Flag nicht gesetzt" );
+
+ SfxMedium aMedium( *pSrc, STREAM_READ | STREAM_SHARE_DENYNONE,
+ FALSE, TRUE );
+ if( aMedium.GetInStream() )
+ {
+ // Eine CID-URL wird in eine Datei kopiert, wenn eine
+ // Mail beantworted wird. Die Datei muss dann die richtige
+ // Extension bekommen. Da Netscape-CIDs keine Extensions
+ // enthalten muessen wir sie ueber den Grafik-Typ
+ // bestimmen und koennen sie nicht uas der URL extrahieren.
+ GraphicDescriptor aDesc( *aMedium.GetInStream() );
+ GraphicFilter *pGrfFilter = GetGrfFilter();
+
+ if ( aDesc.Detect( FALSE ) )
+ {
+ String aExt( pGrfFilter->GetImportFormatShortName(
+ aDesc.GetImportFormatNumber( aDesc.GetFileFormat(),
+ pGrfFilter->GetConfig() ) ) );
+
+ INetURLObject aAbsObj(URIHelper::SmartRelToAbs(aTargetUrl.GetMainURL()));
+ aAbsObj.removeSegment();
+ String sPath(aAbsObj.GetMainURL());
+ TempFile aTempFile(aTargetUrl.GetBase(), &aExt, &sPath);
+
+ SvFileStream aCpy( aTempFile.GetName(), STREAM_WRITE );
+ aCpy << *aMedium.GetInStream();
+ aCpy.Close();
+
+ bRet = SVSTREAM_OK == aCpy.GetError();
+ if( bRet )
+ pDest = new String( aTempFile.GetName() );
+ }
+ }
+ }
+
+ if( bRet )
+ {
+ pImpl->pSrcArr->Insert( pSrc );
+ pImpl->pDestArr->Insert( pDest );
+ rFileNm = *pDest;
+ }
+ else
+ {
+ delete pSrc;
+ delete pDest;
+ }
+ }
+
+ return bRet;
+}
+
+void Writer::PutNumFmtFontsInAttrPool()
+{
+ // dann gibt es noch in den NumRules ein paar Fonts
+ // Diese in den Pool putten. Haben sie danach einen RefCount > 1
+ // kann es wieder entfernt werden - ist schon im Pool
+ SfxItemPool& rPool = pDoc->GetAttrPool();
+ const SwNumRuleTbl& rListTbl = pDoc->GetNumRuleTbl();
+ const SwNumRule* pRule;
+ const SwNumFmt* pFmt;
+ const Font *pFont, *pDefFont = &SwNumRule::GetDefBulletFont();
+ BOOL bCheck = FALSE;
+
+ for( USHORT nGet = rListTbl.Count(); nGet; )
+ if( pDoc->IsUsed( *(pRule = rListTbl[ --nGet ] )))
+ for( BYTE nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
+ if( SVX_NUM_CHAR_SPECIAL == (pFmt = &pRule->Get( nLvl ))->eType ||
+ SVX_NUM_BITMAP == pFmt->eType )
+ {
+ if( 0 == ( pFont = pFmt->GetBulletFont() ) )
+ pFont = pDefFont;
+
+ if( bCheck )
+ {
+ if( *pFont == *pDefFont )
+ continue;
+ }
+ else if( *pFont == *pDefFont )
+ bCheck = TRUE;
+
+ _AddFontItem( rPool, SvxFontItem( pFont->GetFamily(),
+ pFont->GetName(), pFont->GetStyleName(),
+ pFont->GetPitch(), pFont->GetCharSet() ));
+ }
+}
+
+void Writer::PutEditEngFontsInAttrPool()
+{
+ SfxItemPool& rPool = pDoc->GetAttrPool();
+ if( rPool.GetSecondaryPool() )
+ {
+ USHORT nW = EE_CHAR_FONTINFO;
+ const SvxFontItem* pFont = (const SvxFontItem*)&rPool.GetDefaultItem( nW );
+ _AddFontItem( rPool, *pFont );
+
+ if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem( nW )) )
+ _AddFontItem( rPool, *pFont );
+
+ USHORT nMaxItem = rPool.GetItemCount( nW );
+ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
+ if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem( nW, nGet )) )
+ _AddFontItem( rPool, *pFont );
+ }
+}
+
+void Writer::_AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont )
+{
+ const SvxFontItem* pItem;
+ if( RES_CHRATR_FONT != rFont.Which() )
+ {
+ SvxFontItem aFont( rFont );
+ aFont.SetWhich( RES_CHRATR_FONT );
+ pItem = (SvxFontItem*)&rPool.Put( aFont );
+ }
+ else
+ pItem = (SvxFontItem*)&rPool.Put( rFont );
+
+ if( 1 < pItem->GetRef() )
+ rPool.Remove( *pItem );
+ else
+ {
+ if( !pImpl->pFontRemoveLst )
+ pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 );
+
+ void* p = (void*)pItem;
+ pImpl->pFontRemoveLst->Insert( p, pImpl->pFontRemoveLst->Count() );
+ }
+}
+
+// build a bookmark table, which is sort by the node position. The
+// OtherPos of the bookmarks also inserted.
+void Writer::CreateBookmarkTbl()
+{
+ const SwBookmarks& rBkmks = pDoc->GetBookmarks();
+ for( USHORT n = rBkmks.Count(); n; )
+ {
+ const SwBookmark& rBkmk = *rBkmks[ --n ];
+ if( rBkmk.IsBookMark() )
+ pImpl->InsertBkmk( rBkmk );
+ }
+}
+
+
+// search alle Bookmarks in the range and return it in the Array
+USHORT Writer::GetBookmarks( const SwCntntNode& rNd, xub_StrLen nStt,
+ xub_StrLen nEnd, SvPtrarr& rArr )
+{
+ ASSERT( !rArr.Count(), "es sind noch Eintraege vorhanden" );
+
+ ULONG nNd = rNd.GetIndex();
+ SvPtrarr* pArr = pImpl->pBkmkNodePos ? pImpl->pBkmkNodePos->Get( nNd ) : 0;
+ if( pArr )
+ {
+ // there exist some bookmarks, search now all which is in the range
+ if( !nStt && nEnd == rNd.Len() )
+ // all
+ rArr.Insert( pArr, 0 );
+ else
+ {
+ USHORT n;
+ xub_StrLen nCntnt;
+ for( n = 0; n < pArr->Count(); ++n )
+ {
+ void* p = (*pArr)[ n ];
+ const SwBookmark& rBkmk = *(SwBookmark*)p;
+ if( rBkmk.GetPos().nNode == nNd &&
+ (nCntnt = rBkmk.GetPos().nContent.GetIndex() ) >= nStt &&
+ nCntnt < nEnd )
+ {
+ rArr.Insert( p, rArr.Count() );
+ }
+ else if( rBkmk.GetOtherPos() && nNd ==
+ rBkmk.GetOtherPos()->nNode.GetIndex() && (nCntnt =
+ rBkmk.GetOtherPos()->nContent.GetIndex() ) >= nStt &&
+ nCntnt < nEnd )
+ {
+ rArr.Insert( p, rArr.Count() );
+ }
+ }
+ }
+ }
+ return rArr.Count();
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+// Storage-spezifisches
+
+ULONG StgWriter::WriteStream()
+{
+ ASSERT( !this, "Schreiben in Streams auf einem Storage?" );
+ return ERR_SWG_WRITE_ERROR;
+}
+
+ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName )
+{
+ pStrm = 0;
+ pStg = &rStg;
+ pDoc = rPaM.GetDoc();
+ pOrigFileName = pFName;
+ pImpl = new Writer_Impl( *pDoc );
+
+ // PaM kopieren, damit er veraendert werden kann
+ pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ // zum Vergleich auf den akt. Pam sichern
+ pOrigPam = &rPaM;
+
+ ULONG nRet = WriteStorage();
+
+ pStg = NULL;
+ ResetWriter();
+
+ return nRet;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/writer/writer.cxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.103 2000/09/18 16:04:55 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.102 2000/08/04 16:25:50 jp
+ read/write unicode ascii files
+
+ Revision 1.101 2000/06/26 13:01:26 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.100 2000/06/13 09:43:46 os
+ using UCB
+
+ Revision 1.99 2000/05/08 16:51:53 jp
+ Changes for Unicode
+
+ Revision 1.98 1999/10/13 10:38:29 jp
+ PutEditEngFontsInAtrPool - check if the editenginepool exist
+
+ Revision 1.97 1999/10/12 20:04:37 jp
+ Writer: put EditEngine fonts into the writer pool
+
+ Revision 1.96 1999/08/12 10:19:56 MIB
+ Don\'t delete impl if it hasn\'t been set (for XML filter)
+
+
+ Rev 1.95 12 Aug 1999 12:19:56 MIB
+ Don't delete impl if it hasn't been set (for XML filter)
+
+ Rev 1.94 30 Jun 1999 18:53:20 JP
+ dtor for impl class
+
+ Rev 1.93 24 Jun 1999 22:51:34 JP
+ new: Writer with internal Impl-structur, build Bookmark table sortet by nodes
+
+ Rev 1.92 23 Jun 1999 19:13:40 JP
+ interface of Writer::FindPos_Bkmk has changed
+
+ Rev 1.91 16 Jun 1999 19:52:14 JP
+ Change interface of base class Writer
+
+ Rev 1.90 28 Jan 1999 14:21:28 JP
+ GraphicFilter-SS hat sich geaendert - Task #59174#
+
+ Rev 1.89 30 Oct 1998 18:30:02 JP
+ Task #58596#: neues Flag an der Writerklasse -> schreibe nur die 1. Tabelle
+
+ Rev 1.88 27 Jun 1998 16:02:08 JP
+ Writer mit neuen Flags; fuer den ASCII-Writer, etwas aufgeraeumt
+
+ Rev 1.87 23 Apr 1998 19:07:44 MIB
+ fix #49729#: Stream beim kopieren von Grafiken ins INet schliessen
+
+ Rev 1.86 22 Jan 1998 20:02:56 JP
+ CTOR des SwPaM umgestellt
+
+ Rev 1.85 26 Nov 1997 14:29:14 MA
+ headerfiles
+
+ Rev 1.84 03 Nov 1997 14:12:48 MA
+ precomp entfernt
+
+ Rev 1.83 13 Oct 1997 16:06:34 JP
+ pNext vom Ring wurde privat; zugriff ueber GetNext()
+
+ Rev 1.82 09 Oct 1997 14:26:24 JP
+ Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.81 03 Sep 1997 11:59:44 JP
+ zusaetzliches include von docary
+
+*************************************************************************/
+
diff --git a/sw/source/filter/writer/wrt_fn.cxx b/sw/source/filter/writer/wrt_fn.cxx
new file mode 100644
index 000000000000..98784a8a3eb9
--- /dev/null
+++ b/sw/source/filter/writer/wrt_fn.cxx
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrt_fn.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 _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SFX_WHITER_HXX //autogen
+#include <svtools/whiter.hxx>
+#endif
+
+
+#include "shellio.hxx"
+#include "wrt_fn.hxx"
+#include "pam.hxx"
+#include "node.hxx"
+#include "format.hxx"
+
+
+
+Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
+{
+ USHORT nId = rHt.Which();
+ ASSERT( nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
+ FnAttrOut pOut;
+ if( 0 != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] ))
+ (*pOut)( rWrt, rHt );
+ return rWrt;
+
+}
+
+Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
+ const SfxItemSet& rSet, BOOL bDeep,
+ BOOL bTstForDefault )
+{
+ // erst die eigenen Attribute ausgeben
+ const SfxItemPool& rPool = *rSet.GetPool();
+ const SfxItemSet* pSet = &rSet;
+ if( !pSet->Count() ) // Optimierung - leere Sets
+ {
+ if( !bDeep )
+ return rWrt;
+ while( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
+ ;
+ if( !pSet )
+ return rWrt;
+ }
+ const SfxPoolItem* pItem;
+ FnAttrOut pOut;
+ if( !bDeep || !pSet->GetParent() )
+ {
+ ASSERT( rSet.Count(), "Wurde doch schon behandelt oder?" );
+ SfxItemIter aIter( *pSet );
+ pItem = aIter.GetCurItem();
+ do {
+ if( 0 != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN] ))
+ (*pOut)( rWrt, *pItem );
+ } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
+ }
+ else
+ {
+ SfxWhichIter aIter( *pSet );
+ register USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ if( SFX_ITEM_SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
+ ( !bTstForDefault || (
+ *pItem != rPool.GetDefaultItem( nWhich )
+ || ( pSet->GetParent() &&
+ *pItem != pSet->GetParent()->Get( nWhich ))
+ )) && 0 != ( pOut = pTab[ nWhich - RES_CHRATR_BEGIN] ))
+ (*pOut)( rWrt, *pItem );
+ nWhich = aIter.NextWhich();
+ }
+ }
+ return rWrt;
+}
+
+
+
+Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt )
+{
+ // es muss ein CntntNode sein !!
+ SwCntntNode * pCNd = rNode.GetCntntNode();
+ if( !pCNd )
+ return rWrt;
+
+ USHORT nId;
+ switch( pCNd->GetNodeType() )
+ {
+ case ND_TEXTNODE: nId = RES_TXTNODE; break;
+ case ND_GRFNODE: nId = RES_GRFNODE; break;
+ case ND_OLENODE: nId = RES_OLENODE; break;
+ default:
+ ASSERT( FALSE, "was fuer ein Node ist es denn nun?" );
+ }
+ FnNodeOut pOut;
+ if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] ))
+ (*pOut)( rWrt, *pCNd );
+ return rWrt;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/writer/wrt_fn.cxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.32 2000/09/18 16:04:55 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.31 1999/07/06 12:55:38 JP
+ Out_SfxItemSet: test to default items optional
+
+
+ Rev 1.30 06 Jul 1999 14:55:38 JP
+ Out_SfxItemSet: test to default items optional
+
+ Rev 1.29 26 Nov 1997 14:29:14 MA
+ headerfiles
+
+ Rev 1.28 03 Nov 1997 14:12:48 MA
+ precomp entfernt
+
+ Rev 1.27 22 Jan 1997 12:01:18 JP
+ neu: Tabellen Box Attribute
+
+ Rev 1.26 16 Oct 1996 16:58:54 JP
+ unbenutzte Methoden entfernt
+
+ Rev 1.25 01 Jul 1996 16:03:14 MA
+ includes
+
+ Rev 1.24 22 Mar 1996 14:52:12 SWG
+ include hinzugefuegt
+
+ Rev 1.23 24 Nov 1995 17:24:42 OM
+ PCH->PRECOMPILED
+
+ Rev 1.22 25 Oct 1994 15:57:12 MA
+ PreHdr.
+
+ Rev 1.21 04 Oct 1994 16:34:06 JP
+ Out_SfxItemSet: optimiert
+
+ Rev 1.20 28 Sep 1994 12:37:34 JP
+ neue Methode: Out_SfxItemSet
+
+ Rev 1.19 25 Aug 1994 18:09:12 JP
+ Umstellung Attribute (von SwHint -> SfxPoolItem)
+
+ Rev 1.18 15 Feb 1994 15:31:30 MI
+ handsegmentierung
+
+ Rev 1.17 28 Jan 1994 11:34:06 MI
+ TCOV() entfernt, SW_... nach SEG_... umbenannt
+
+ Rev 1.16 13 Jan 1994 08:31:32 MI
+ Segmentierung per #define ermoeglicht
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx
new file mode 100644
index 000000000000..308c191c48e4
--- /dev/null
+++ b/sw/source/filter/writer/wrtswtbl.cxx
@@ -0,0 +1,959 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtswtbl.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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _FRACT_HXX
+#include <tools/fract.hxx>
+#endif
+
+#ifndef _WRTSWTBL_HXX
+#include <wrtswtbl.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _FRMFMT_HXX
+#include <frmfmt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTORNT_HXX
+#include <fmtornt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _HTMLTBL_HXX
+#include <htmltbl.hxx>
+#endif
+
+
+SV_IMPL_PTRARR( SwWriteTableCells, SwWriteTableCellPtr )
+SV_IMPL_OP_PTRARR_SORT( SwWriteTableRows, SwWriteTableRowPtr )
+SV_IMPL_OP_PTRARR_SORT( SwWriteTableCols, SwWriteTableColPtr )
+
+//-----------------------------------------------------------------------
+
+SwVertOrient SwWriteTableCell::GetVertOri() const
+{
+ SwVertOrient eCellVertOri = VERT_TOP;
+ if( pBox->GetSttNd() )
+ {
+ const SfxItemSet& rItemSet = pBox->GetFrmFmt()->GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, FALSE, &pItem ) )
+ {
+ SwVertOrient eBoxVertOri =
+ ((const SwFmtVertOrient *)pItem)->GetVertOrient();
+ if( VERT_CENTER==eBoxVertOri || VERT_BOTTOM==eBoxVertOri)
+ eCellVertOri = eBoxVertOri;
+ }
+ }
+
+ return eCellVertOri;
+}
+
+//-----------------------------------------------------------------------
+
+SwWriteTableRow::SwWriteTableRow( long nPosition )
+ : nPos(nPosition), pBackground( 0 ),
+ bTopBorder(TRUE), bBottomBorder(TRUE),
+ nTopBorder(USHRT_MAX), nBottomBorder(USHRT_MAX)
+{
+}
+
+
+SwWriteTableCell *SwWriteTableRow::AddCell( const SwTableBox *pBox,
+ USHORT nRow, USHORT nCol,
+ USHORT nRowSpan, USHORT nColSpan,
+ long nHeight,
+ const SvxBrushItem *pBackground )
+{
+ SwWriteTableCell *pCell =
+ new SwWriteTableCell( pBox, nRow, nCol, nRowSpan, nColSpan,
+ nHeight, pBackground );
+ aCells.Insert( pCell, aCells.Count() );
+
+ return pCell;
+}
+
+//-----------------------------------------------------------------------
+
+SwWriteTableCol::SwWriteTableCol( USHORT nPosition )
+ : nPos(nPosition),
+ bLeftBorder(TRUE), bRightBorder(TRUE),
+ nWidthOpt( 0 ), bRelWidthOpt( FALSE ),
+ bOutWidth( TRUE )
+{
+}
+
+//-----------------------------------------------------------------------
+
+long SwWriteTable::GetBoxWidth( const SwTableBox *pBox )
+{
+ const SwFrmFmt *pFmt = pBox->GetFrmFmt();
+ const SwFmtFrmSize& aFrmSize=
+ (const SwFmtFrmSize&)pFmt->GetAttr( RES_FRM_SIZE );
+
+ return aFrmSize.GetSize().Width();
+}
+
+long SwWriteTable::GetLineHeight( const SwTableLine *pLine )
+{
+#ifndef PRODUCT
+ BOOL bOldGetLineHeightCalled = bGetLineHeightCalled;
+ bGetLineHeightCalled = TRUE;
+#endif
+
+ long nHeight = 0;
+ if( bUseLayoutHeights )
+ {
+ // Erstmal versuchen wir die Hoehe ueber das Layout zu bekommen
+ long nHeight = pLine->GetLineRect( FALSE ).Height();
+ if( nHeight > 0 )
+ return nHeight;
+
+ // Wenn kein Layout gefunden wurde, gehen wir von festen Hoehen aus.
+ bUseLayoutHeights = FALSE;
+
+#ifndef PRODUCT
+ ASSERT( !bOldGetLineHeightCalled, "Layout ungueltig?" );
+#endif
+ }
+
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ USHORT nBoxes = rBoxes.Count();
+
+ for( USHORT nBox=0; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox* pBox = rBoxes[nBox];
+ if( pBox->GetSttNd() )
+ {
+ if( nHeight < ROW_DFLT_HEIGHT )
+ nHeight = ROW_DFLT_HEIGHT;
+ }
+ else
+ {
+ long nTmp = 0;
+ const SwTableLines &rLines = pBox->GetTabLines();
+ for( USHORT nLine=0; nLine<rLines.Count(); nLine++ )
+ {
+ nTmp += GetLineHeight( rLines[nLine] );
+ }
+ if( nHeight < nTmp )
+ nHeight = nTmp;
+ }
+ }
+
+ return nHeight;
+}
+
+long SwWriteTable::GetLineHeight( const SwTableBox *pBox ) const
+{
+ const SwTableLine *pLine = pBox->GetUpper();
+
+ if( !pLine )
+ return 0;
+
+ const SwFrmFmt *pLineFrmFmt = pLine->GetFrmFmt();
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rItemSet = pLineFrmFmt->GetAttrSet();
+
+ long nHeight = 0;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, TRUE, &pItem ))
+ nHeight = ((SwFmtFrmSize*)pItem)->GetHeight();
+
+ return nHeight;
+}
+
+const SvxBrushItem *SwWriteTable::GetLineBrush( const SwTableBox *pBox,
+ SwWriteTableRow *pRow )
+{
+ const SwTableLine *pLine = pBox->GetUpper();
+
+ while( pLine )
+ {
+ const SwFrmFmt *pLineFrmFmt = pLine->GetFrmFmt();
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rItemSet = pLineFrmFmt->GetAttrSet();
+
+ const SvxBrushItem *pBrushItem = 0;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, FALSE,
+ &pItem ) )
+ {
+ if( !pLine->GetUpper() )
+ {
+ if( !pRow->GetBackground() )
+ pRow->SetBackground( (const SvxBrushItem *)pItem );
+ pItem = 0;
+ }
+
+ return (const SvxBrushItem *)pItem;
+ }
+
+ pBox = pLine->GetUpper();
+ pLine = pBox ? pBox->GetUpper() : 0;
+ }
+
+ return 0;
+}
+
+
+void SwWriteTable::MergeBorders( const SvxBorderLine* pBorderLine,
+ BOOL bTable )
+{
+ if( (UINT32)-1 == nBorderColor )
+ {
+ Color aGrayColor( COL_GRAY );
+ if( !pBorderLine->GetColor().IsRGBEqual( aGrayColor ) )
+ nBorderColor = pBorderLine->GetColor().GetColor();
+ }
+
+ if( !bCollectBorderWidth )
+ return;
+
+ USHORT nOutWidth = pBorderLine->GetOutWidth();
+ if( bTable )
+ {
+ if( nOutWidth && (!nBorder || nOutWidth < nBorder) )
+ nBorder = nOutWidth;
+ }
+ else
+ {
+ if( nOutWidth && (!nInnerBorder || nOutWidth < nInnerBorder) )
+ nInnerBorder = nOutWidth;
+ }
+
+ USHORT nDist = pBorderLine->GetInWidth() ? pBorderLine->GetDistance()
+ : 0;
+ if( nDist && (!nCellSpacing || nDist < nCellSpacing) )
+ nCellSpacing = nDist;
+}
+
+
+USHORT SwWriteTable::MergeBoxBorders( const SwTableBox *pBox,
+ USHORT nRow, USHORT nCol,
+ USHORT nRowSpan, USHORT nColSpan,
+ USHORT& rTopBorder,
+ USHORT &rBottomBorder )
+{
+ USHORT nBorderMask = 0;
+
+ const SwFrmFmt *pFrmFmt = pBox->GetFrmFmt();
+ const SvxBoxItem& rBoxItem = (const SvxBoxItem&)pFrmFmt->GetAttr( RES_BOX );
+
+ USHORT nWidth = 0;
+
+ if( rBoxItem.GetTop() )
+ {
+ nBorderMask |= 1;
+ MergeBorders( rBoxItem.GetTop(), nRow==0 );
+ rTopBorder = rBoxItem.GetTop()->GetOutWidth();
+ }
+
+ if( rBoxItem.GetLeft() )
+ {
+ nBorderMask |= 4;
+ MergeBorders( rBoxItem.GetLeft(), nCol==0 );
+ }
+
+ if( rBoxItem.GetBottom() )
+ {
+ nBorderMask |= 2;
+ MergeBorders( rBoxItem.GetBottom(), nRow+nRowSpan==aRows.Count() );
+ rBottomBorder = rBoxItem.GetBottom()->GetOutWidth();
+ }
+
+ if( rBoxItem.GetRight() )
+ {
+ nBorderMask |= 8;
+ MergeBorders( rBoxItem.GetRight(), nCol+nColSpan==aCols.Count() );
+ }
+
+ // If any distance is set, the smallest one is used. This holds for
+ // the four distance of a box as well as for the distances of different
+ // boxes.
+ if( bCollectBorderWidth )
+ {
+ USHORT nDist = rBoxItem.GetDistance( BOX_LINE_TOP );
+ if( nDist && (!nCellPadding || nDist < nCellPadding) )
+ nCellPadding = nDist;
+ nDist = rBoxItem.GetDistance( BOX_LINE_BOTTOM );
+ if( nDist && (!nCellPadding || nDist < nCellPadding) )
+ nCellPadding = nDist;
+ nDist = rBoxItem.GetDistance( BOX_LINE_LEFT );
+ if( nDist && (!nCellPadding || nDist < nCellPadding) )
+ nCellPadding = nDist;
+ nDist = rBoxItem.GetDistance( BOX_LINE_RIGHT );
+ if( nDist && (!nCellPadding || nDist < nCellPadding) )
+ nCellPadding = nDist;
+ }
+
+ return nBorderMask;
+}
+
+
+USHORT SwWriteTable::GetRawWidth( USHORT nCol, USHORT nColSpan ) const
+{
+ USHORT nWidth = aCols[nCol+nColSpan-1]->GetPos();
+ if( nCol > 0 )
+ nWidth -= aCols[nCol-1]->GetPos();
+
+ return nWidth;
+}
+
+USHORT SwWriteTable::GetLeftSpace( USHORT nCol ) const
+{
+ USHORT nSpace = nCellPadding + nCellSpacing;
+
+ // In der ersten Spalte auch noch die Liniendicke abziehen
+ if( nCol==0 )
+ {
+ nSpace += nLeftSub;
+
+ const SwWriteTableCol *pCol = aCols[nCol];
+ if( pCol->HasLeftBorder() )
+ nSpace += nBorder;
+ }
+
+ return nSpace;
+}
+
+USHORT SwWriteTable::GetRightSpace( USHORT nCol, USHORT nColSpan ) const
+{
+ USHORT nSpace = nCellPadding;
+
+ // In der letzten Spalte noch einmal zusaetzlich CELLSPACING und
+ // und die Liniendicke abziehen
+ if( nCol+nColSpan==aCols.Count() )
+ {
+ nSpace += (nCellSpacing + nRightSub);
+
+ const SwWriteTableCol *pCol = aCols[nCol+nColSpan-1];
+ if( pCol->HasRightBorder() )
+ nSpace += nBorder;
+ }
+
+ return nSpace;
+}
+
+USHORT SwWriteTable::GetAbsWidth( USHORT nCol, USHORT nColSpan ) const
+{
+ long nWidth = GetRawWidth( nCol, nColSpan );
+ if( nBaseWidth != nTabWidth )
+ {
+ nWidth *= nTabWidth;
+ nWidth /= nBaseWidth;
+ }
+
+ nWidth -= GetLeftSpace( nCol ) + GetRightSpace( nCol, nColSpan );
+
+ ASSERT( nWidth > 0, "Spaltenbreite <= 0. OK?" );
+ return nWidth > 0 ? (USHORT)nWidth : 0;
+}
+
+USHORT SwWriteTable::GetRelWidth( USHORT nCol, USHORT nColSpan ) const
+{
+ long nWidth = GetRawWidth( nCol, nColSpan );
+
+ return (USHORT)(long)Fraction( nWidth*256 + GetBaseWidth()/2,
+ GetBaseWidth() );
+}
+
+USHORT SwWriteTable::GetPrcWidth( USHORT nCol, USHORT nColSpan ) const
+{
+ long nWidth = GetRawWidth( nCol, nColSpan );
+
+ // sieht komisch aus, ist aber nichts anderes als
+ // [(100 * nWidth) + .5] ohne Rundungsfehler
+ return (USHORT)(long)Fraction( nWidth*100 + GetBaseWidth()/2,
+ GetBaseWidth() );
+}
+
+long SwWriteTable::GetAbsHeight( long nRawHeight, USHORT nRow,
+ USHORT nRowSpan ) const
+{
+ nRawHeight -= (2*nCellPadding + nCellSpacing);
+
+ // In der ersten Zeile noch einmal zusaetzlich CELLSPACING und
+ // und die Liniendicke abziehen
+ const SwWriteTableRow *pRow = 0;
+ if( nRow==0 )
+ {
+ nRawHeight -= nCellSpacing;
+ pRow = aRows[nRow];
+ if( pRow->HasTopBorder() )
+ nRawHeight -= nBorder;
+ }
+
+ // In der letzten Zeile noch die Liniendicke abziehen
+ if( nRow+nRowSpan==aRows.Count() )
+ {
+ if( !pRow || nRowSpan > 1 )
+ pRow = aRows[nRow+nRowSpan-1];
+ if( pRow->HasBottomBorder() )
+ nRawHeight -= nBorder;
+ }
+
+ ASSERT( nRawHeight > 0, "Zeilenheohe <= 0. OK?" );
+ return nRawHeight > 0 ? nRawHeight : 0;
+}
+
+
+
+BOOL SwWriteTable::ShouldExpandSub( const SwTableBox *pBox,
+ BOOL bExpandedBefore,
+ USHORT nDepth ) const
+{
+ return !pBox->GetSttNd() && nDepth > 0;
+}
+
+void SwWriteTable::CollectTableRowsCols( long nStartRPos,
+ USHORT nStartCPos,
+ long nParentLineHeight,
+ USHORT nParentLineWidth,
+ const SwTableLines& rLines,
+ USHORT nDepth )
+{
+ BOOL bSubExpanded = FALSE;
+ USHORT nLines = rLines.Count();
+
+#ifndef PRODUCT
+ USHORT nEndCPos = 0;
+#endif
+
+ long nRPos = nStartRPos;
+ for( USHORT nLine = 0; nLine < nLines; nLine++ )
+ {
+ /*const*/ SwTableLine *pLine = rLines[nLine];
+
+ long nOldRPos = nRPos;
+
+ if( nLine < nLines-1 || nParentLineHeight==0 )
+ {
+ nRPos += GetLineHeight( pLine );
+ SwWriteTableRow *pRow = new SwWriteTableRow( nRPos );
+
+ USHORT nRow;
+ if( aRows.Seek_Entry( pRow, &nRow ) )
+ delete pRow;
+ else
+ aRows.Insert( pRow );
+ }
+ else
+ {
+ long nCheckPos = nRPos + GetLineHeight( pLine );
+ nRPos = nStartRPos + nParentLineHeight;
+#ifndef PRODUCT
+ SwWriteTableRow aRow( nStartRPos + nParentLineHeight );
+ ASSERT( aRows.Seek_Entry(&aRow),
+ "Parent-Zeile nicht gefunden" );
+ ASSERT( !bUseLayoutHeights ||
+ SwWriteTableRow(nCheckPos) == SwWriteTableRow(nRPos),
+ "Hoehe der Zeilen stimmt nicht mit Parent ueberein" );
+#endif
+ }
+
+ // Fuer alle Boxen der Zeile ggf. eine Spalte einfuegen
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ USHORT nBoxes = rBoxes.Count();
+
+ USHORT nCPos = nStartCPos;
+ for( USHORT nBox=0; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ USHORT nOldCPos = nCPos;
+
+ if( nBox < nBoxes-1 || (nParentLineWidth==0 && nLine==0) )
+ {
+ nCPos += (USHORT)GetBoxWidth( pBox );
+ SwWriteTableCol *pCol = new SwWriteTableCol( nCPos );
+
+ USHORT nCol;
+ if( aCols.Seek_Entry( pCol, &nCol ) )
+ delete pCol;
+ else
+ aCols.Insert( pCol );
+
+ if( nBox==nBoxes-1 )
+ {
+ ASSERT( nLine==0 && nParentLineWidth==0,
+ "Jetzt wird die Parent-Breite plattgemacht!" );
+ nParentLineWidth = nCPos-nStartCPos;
+ }
+ }
+ else
+ {
+#ifndef PRODUCT
+ USHORT nCheckPos = nCPos + (USHORT)GetBoxWidth( pBox );
+ if( !nEndCPos )
+ {
+ nEndCPos = nCheckPos;
+ }
+ else
+ {
+ ASSERT( SwWriteTableCol(nCheckPos) ==
+ SwWriteTableCol(nEndCPos),
+ "Zelle enthaelt unterschiedlich breite Zeilen" );
+ }
+#endif
+ nCPos = nStartCPos + nParentLineWidth;
+#ifndef PRODUCT
+ SwWriteTableCol aCol( nStartCPos + nParentLineWidth );
+ ASSERT( aCols.Seek_Entry(&aCol),
+ "Parent-Zelle nicht gefunden" );
+ ASSERT( SwWriteTableCol(nCheckPos) ==
+ SwWriteTableCol(nCPos),
+ "Breite der Zellen stimmt nicht mit Parent ueberein" );
+#endif
+ }
+
+ if( ShouldExpandSub( pBox, bSubExpanded, nDepth ) )
+ {
+ CollectTableRowsCols( nOldRPos, nOldCPos,
+ nRPos - nOldRPos,
+ nCPos - nOldCPos,
+ pBox->GetTabLines(),
+ nDepth-1 );
+ bSubExpanded = TRUE;
+ }
+ }
+ }
+}
+
+
+void SwWriteTable::FillTableRowsCols( long nStartRPos, USHORT nStartRow,
+ USHORT nStartCPos, USHORT nStartCol,
+ long nParentLineHeight,
+ USHORT nParentLineWidth,
+ const SwTableLines& rLines,
+ const SvxBrushItem* pParentBrush,
+ USHORT nDepth )
+{
+ USHORT nLines = rLines.Count();
+ BOOL bSubExpanded = FALSE;
+
+ // Festlegen der Umrandung
+ long nRPos = nStartRPos;
+ USHORT nRow = nStartRow;
+
+ for( USHORT nLine = 0; nLine < nLines; nLine++ )
+ {
+ const SwTableLine *pLine = rLines[nLine];
+
+ // Position der letzten ueberdeckten Zeile ermitteln
+ long nOldRPos = nRPos;
+ if( nLine < nLines-1 || nParentLineHeight==0 )
+ nRPos += GetLineHeight( pLine );
+ else
+ nRPos = nStartRPos + nParentLineHeight;
+
+ // Und ihren Index
+ USHORT nOldRow = nRow;
+ SwWriteTableRow aRow( nRPos );
+ BOOL bFound = aRows.Seek_Entry( &aRow, &nRow );
+ ASSERT( bFound, "Wo ist die Zeile geblieben?" );
+
+ SwWriteTableRow *pRow = aRows[nOldRow];
+ SwWriteTableRow *pEndRow = aRows[nRow];
+ if( nLine==0 && nParentLineHeight==0 )
+ nHeadEndRow = nRow;
+
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+
+ const SwFrmFmt *pLineFrmFmt = pLine->GetFrmFmt();
+ const SfxPoolItem* pItem;
+ const SfxItemSet& rItemSet = pLineFrmFmt->GetAttrSet();
+
+ long nHeight = 0;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, TRUE, &pItem ))
+ nHeight = ((SwFmtFrmSize*)pItem)->GetHeight();
+
+
+ const SvxBrushItem *pBrushItem, *pLineBrush = pParentBrush;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, FALSE,
+ &pItem ) )
+ {
+ pLineBrush = (const SvxBrushItem *)pItem;
+
+ // Wenn die Zeile die gesamte Tabelle umspannt, koennen
+ // Wir den Hintergrund an der Zeile ausgeben. Sonst muessen
+ // wir in an den Zelle ausgeben.
+ BOOL bOutAtRow = !nParentLineWidth;
+ if( !bOutAtRow && nStartCPos==0 )
+ {
+ USHORT nEndCol;
+ SwWriteTableCol aCol( nParentLineWidth );
+ bOutAtRow = aCols.Seek_Entry(&aCol,&nEndCol) &&
+ nEndCol == aCols.Count()-1;
+ }
+ if( bOutAtRow )
+ {
+ pRow->SetBackground( pLineBrush );
+ pBrushItem = 0;
+ }
+ else
+ pBrushItem = pLineBrush;
+ }
+ else
+ {
+ pRow->SetBackground( pLineBrush );
+ pBrushItem = 0;
+ }
+
+ USHORT nBoxes = rBoxes.Count();
+ USHORT nCPos = nStartCPos;
+ USHORT nCol = nStartCol;
+
+ for( USHORT nBox=0; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ // Position der letzten ueberdeckten Spalte ermitteln
+ USHORT nOldCPos = nCPos;
+ if( nBox < nBoxes-1 || (nParentLineWidth==0 && nLine==0) )
+ {
+ nCPos += (USHORT)GetBoxWidth( pBox );
+ if( nBox==nBoxes-1 )
+ nParentLineWidth = nCPos - nStartCPos;
+ }
+ else
+ nCPos = nStartCPos + nParentLineWidth;
+
+ // Und ihren Index
+ USHORT nOldCol = nCol;
+ SwWriteTableCol aCol( nCPos );
+ BOOL bFound = aCols.Seek_Entry( &aCol, &nCol );
+ ASSERT( bFound, "Wo ist die Spalte geblieben?" );
+
+ if( !ShouldExpandSub( pBox, bSubExpanded, nDepth ) )
+ {
+ USHORT nRowSpan = nRow - nOldRow + 1;
+ USHORT nColSpan = nCol - nOldCol + 1;
+ pRow->AddCell( pBox, nOldRow, nOldCol,
+ nRowSpan, nColSpan, nHeight,
+ pBrushItem );
+ nHeight = 0; // Die Hoehe braucht nur einmal geschieben werden
+
+ if( pBox->GetSttNd() )
+ {
+ // Wegen OS/2 schon hier, sonst gibt es einen
+ // Optimierungs-Fehler!!!!
+ SwWriteTableCol *pCol = aCols[nOldCol];
+
+ USHORT nTopBorder = USHRT_MAX, nBottomBorder = USHRT_MAX;
+ USHORT nBorderMask = MergeBoxBorders( pBox, nOldRow, nOldCol,
+ nRowSpan, nColSpan,
+ nTopBorder,
+ nBottomBorder );
+
+ if( !(nBorderMask & 4) )
+ pCol->bLeftBorder = FALSE;
+
+ pCol = aCols[nCol];
+ if( !(nBorderMask & 8) )
+ pCol->bRightBorder = FALSE;
+
+ if( !(nBorderMask & 1) )
+ pRow->bTopBorder = FALSE;
+ else if( !pRow->nTopBorder || nTopBorder < pRow->nTopBorder )
+ pRow->nTopBorder = nTopBorder;
+
+ if( !(nBorderMask & 2) )
+ pEndRow->bBottomBorder = FALSE;
+ else if( !pEndRow->nBottomBorder ||
+ nBottomBorder < pEndRow->nBottomBorder )
+ pEndRow->nBottomBorder = nBottomBorder;
+ }
+ else
+ {
+ aCols[nOldCol]->bLeftBorder = FALSE;
+ aCols[nCol]->bRightBorder = FALSE;
+ pRow->bTopBorder = FALSE;
+ pEndRow->bBottomBorder = FALSE;
+ }
+ }
+ else
+ {
+ FillTableRowsCols( nOldRPos, nOldRow, nOldCPos, nOldCol,
+ nRPos-nOldRPos, nCPos-nOldCPos,
+ pBox->GetTabLines(),
+ pLineBrush, nDepth-1 );
+ bSubExpanded = TRUE;
+ }
+
+ nCol++; // Die naechste Zelle faengt in der nachten Spalte an
+ }
+
+ nRow++;
+ }
+}
+
+SwWriteTable::SwWriteTable( const SwTableLines& rLines, long nWidth,
+ USHORT nBWidth, BOOL bRel, USHORT nMaxDepth,
+ USHORT nLSub, USHORT nRSub )
+ : nBorderColor( (UINT32)-1 ),
+ nBorder( 0 ),
+ nInnerBorder( 0 ),
+ nCellPadding( 0 ),
+ nCellSpacing( 0 ),
+ nTabWidth( nWidth ),
+ nBaseWidth( nBWidth ),
+ nLeftSub( nLSub ), nRightSub( nRSub ),
+ bRelWidths( bRel ),
+ bUseLayoutHeights( TRUE ),
+#ifndef PRODUCT
+ bGetLineHeightCalled( FALSE ),
+#endif
+ nHeadEndRow( USHRT_MAX ),
+ bColsOption( FALSE ),
+ bColTags( TRUE ),
+ bLayoutExport( FALSE ),
+ bCollectBorderWidth( TRUE )
+{
+ USHORT nParentWidth = nBaseWidth + nLeftSub + nRightSub;
+
+ // Erstmal die Tabellen-Struktur festlegen. Hinter der Tabelle ist in
+ // jedem Fall eine Spalte zu Ende
+ SwWriteTableCol *pCol = new SwWriteTableCol( nParentWidth );
+ aCols.Insert( pCol );
+ CollectTableRowsCols( 0, 0, 0, nParentWidth, rLines, nMaxDepth - 1 );
+
+ // Und jetzt mit leben fuellen
+ FillTableRowsCols( 0, 0, 0, 0, 0, nParentWidth, rLines, 0, nMaxDepth - 1 );
+
+ // Einige Twip-Werte an Pixel-Grenzen anpassen
+ if( !nBorder )
+ nBorder = nInnerBorder;
+}
+
+
+
+SwWriteTable::SwWriteTable( const SwHTMLTableLayout *pLayoutInfo )
+ : nBorderColor( (UINT32)-1 ),
+ nBorder( 0 ),
+ nInnerBorder( 0 ),
+ nCellPadding( 0 ),
+ nCellSpacing( 0 ),
+ nTabWidth( pLayoutInfo->GetWidthOption() ),
+ nBaseWidth( pLayoutInfo->GetWidthOption() ),
+ nLeftSub( 0 ), nRightSub( 0 ),
+ bRelWidths( pLayoutInfo->HasPrcWidthOption() ),
+ bUseLayoutHeights( FALSE ),
+#ifndef PRODUCT
+ bGetLineHeightCalled( FALSE ),
+#endif
+ nHeadEndRow( 0 ),
+ bColsOption( pLayoutInfo->HasColsOption() ),
+ bColTags( pLayoutInfo->HasColTags() ),
+ bLayoutExport( TRUE ),
+ bCollectBorderWidth( pLayoutInfo->HaveBordersChanged() )
+{
+ if( !bCollectBorderWidth )
+ {
+ nBorder = pLayoutInfo->GetBorder();
+ nCellPadding = pLayoutInfo->GetCellPadding();
+ nCellSpacing = pLayoutInfo->GetCellSpacing();
+ }
+
+ USHORT nRow, nCol;
+ USHORT nCols = pLayoutInfo->GetColCount();
+ USHORT nRows = pLayoutInfo->GetRowCount();
+
+ // Erstmal die Tabellen-Struktur festlegen.
+ for( nCol=0; nCol<nCols; nCol++ )
+ {
+ SwWriteTableCol *pCol =
+ new SwWriteTableCol( (nCol+1)*COL_DFLT_WIDTH );
+
+ if( bColTags )
+ {
+ const SwHTMLTableLayoutColumn *pLayoutCol =
+ pLayoutInfo->GetColumn( nCol );
+ pCol->SetWidthOpt( pLayoutCol->GetWidthOption(),
+ pLayoutCol->IsRelWidthOption() );
+ }
+
+ aCols.Insert( pCol );
+ }
+
+ for( nRow=0; nRow<nRows; nRow++ )
+ {
+ SwWriteTableRow *pRow =
+ new SwWriteTableRow( (nRow+1)*ROW_DFLT_HEIGHT );
+ pRow->nTopBorder = 0;
+ pRow->nBottomBorder = 0;
+ aRows.Insert( pRow );
+ }
+
+ // Und jetzt mit leben fuellen
+ for( nRow=0; nRow<nRows; nRow++ )
+ {
+ SwWriteTableRow *pRow = aRows[nRow];
+
+ BOOL bHeightExported = FALSE;
+ for( nCol=0; nCol<nCols; nCol++ )
+ {
+ const SwHTMLTableLayoutCell *pLayoutCell =
+ pLayoutInfo->GetCell( nRow, nCol );
+
+ const SwHTMLTableLayoutCnts *pLayoutCnts =
+ pLayoutCell->GetContents();
+
+ // Beginnt die Zelle eigentlich eine Zeile weiter oben oder
+ // weiter vorne?
+ if( ( nRow>0 && pLayoutCnts == pLayoutInfo->GetCell(nRow-1,nCol)
+ ->GetContents() ) ||
+ ( nCol>0 && pLayoutCnts == pLayoutInfo->GetCell(nRow,nCol-1)
+ ->GetContents() ) )
+ {
+ continue;
+ }
+
+ USHORT nRowSpan = pLayoutCell->GetRowSpan();
+ USHORT nColSpan = pLayoutCell->GetColSpan();
+ const SwTableBox *pBox = pLayoutCnts->GetTableBox();
+ ASSERT( pBox,
+ "Tabelle in Tabelle kann nicht ueber Layout exportiert werden" );
+
+ long nHeight = bHeightExported ? 0 : GetLineHeight( pBox );
+ const SvxBrushItem *pBrushItem = GetLineBrush( pBox, pRow );
+
+ SwWriteTableCell *pCell =
+ pRow->AddCell( pBox, nRow, nCol, nRowSpan, nColSpan,
+ nHeight, pBrushItem );
+ pCell->SetWidthOpt( pLayoutCell->GetWidthOption(),
+ pLayoutCell->IsPrcWidthOption() );
+
+ USHORT nTopBorder = USHRT_MAX, nBottomBorder = USHRT_MAX;
+ USHORT nBorderMask =
+ MergeBoxBorders( pBox, nRow, nCol, nRowSpan, nColSpan,
+ nTopBorder, nBottomBorder );
+
+ SwWriteTableCol *pCol = aCols[nCol];
+ if( !(nBorderMask & 4) )
+ pCol->bLeftBorder = FALSE;
+
+ pCol = aCols[nCol+nColSpan-1];
+ if( !(nBorderMask & 8) )
+ pCol->bRightBorder = FALSE;
+
+ if( !(nBorderMask & 1) )
+ pRow->bTopBorder = FALSE;
+
+ SwWriteTableRow *pEndRow = aRows[nRow+nRowSpan-1];
+ if( !(nBorderMask & 2) )
+ pEndRow->bBottomBorder = FALSE;
+
+ // Die Hoehe braucht nur einmal geschieben werden
+ if( nHeight )
+ bHeightExported = TRUE;
+ }
+ }
+
+ // Einige Twip-Werte an Pixel-Grenzen anpassen
+ if( bCollectBorderWidth && !nBorder )
+ nBorder = nInnerBorder;
+}
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/writer/wrtswtbl.cxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.3 2000/09/18 16:04:55 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.2 2000/03/03 15:22:02 os
+ StarView remainders removed
+
+ Revision 1.1 1999/10/29 17:38:03 jp
+ class for build a '2D-Table' from a SwTable
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
new file mode 100644
index 000000000000..3f18bc6ba1fe
--- /dev/null
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -0,0 +1,2357 @@
+/*************************************************************************
+ *
+ * $RCSfile: fltshell.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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include <ctype.h>
+#include <stdio.h> // sprintf
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SYSTEM_HXX //autogen
+#include <vcl/system.hxx>
+#endif
+#ifndef _GRAPH_HXX //autogen
+#include <vcl/graph.hxx>
+#endif
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _SVX_IMPGRF_HXX //autogen
+#include <svx/impgrf.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_ITEM_HXX //autogen
+#include <svx/cntritem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svtools/stritem.hxx>
+#endif
+#ifndef _UNOTOOLS_CHARCLASS_HXX
+#include <unotools/charclass.hxx>
+#endif
+
+#ifndef _TXTFTN_HXX //autogen
+#include <txtftn.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTRFMRK_HXX //autogen
+#include <fmtrfmrk.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _REDLINE_HXX
+#include <redline.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx> // RES_SETEXPFLD
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx> // class SwFmtRefMark
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx> // class SwTableLines, ...
+#endif
+#ifndef _TOX_HXX
+#include <tox.hxx>
+#endif
+#ifndef _EXPFLD_HXX
+#include <expfld.hxx> // SwExpField
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx> // class SwSection
+#endif
+#ifndef _TBLSEL_HXX
+#include <tblsel.hxx> // class SwSelBoxes
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx> // class SwDocSh
+#endif
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx>
+#endif
+
+#define MAX_FIELDLEN 64000
+
+SV_IMPL_PTRARR(SwFltControlStackEntries, SwFltStackEntryPtr)
+
+static SwCntntNode* GetCntntNode(SwDoc* pDoc, SwNodeIndex& rIdx, BOOL bNext)
+{
+ SwCntntNode* pCNd = pDoc->GetNodes()[ rIdx ]->GetCntntNode();
+ if(!pCNd && 0 == (pCNd = bNext ? pDoc->GetNodes().GoNext(&rIdx)
+ : pDoc->GetNodes().GoPrevious(&rIdx)))
+ {
+ pCNd = bNext ? pDoc->GetNodes().GoPrevious(&rIdx)
+ : pDoc->GetNodes().GoNext(&rIdx);
+ ASSERT(pCNd, "kein ContentNode gefunden");
+ }
+ return pCNd;
+}
+
+// ------ Stack-Eintrag fuer die gesamten - Attribute vom Text -----------
+SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt ) :
+ nMkNode(rStartPos.nNode, -1),
+ nPtNode(nMkNode)
+{
+ // Anfang vom Bereich merken
+ nMkCntnt = rStartPos.nContent.GetIndex();
+ pAttr = pHt; // speicher eine Kopie vom Attribut
+ bOld = FALSE; // used for marking Attributes *before* skipping field results
+ bLocked = TRUE; // locke das Attribut --> darf erst
+ bCopied = FALSE; // gesetzt werden, wenn es wieder geunlocked ist
+}
+
+SwFltStackEntry::SwFltStackEntry(const SwFltStackEntry& rEntry) :
+ nMkNode(rEntry.nMkNode),
+ nPtNode(rEntry.nPtNode)
+{
+ pAttr = rEntry.pAttr->Clone();
+ nMkCntnt= rEntry.nMkCntnt;
+ bOld = rEntry.bOld;
+ bLocked = bCopied = TRUE; // when rEntry were NOT bLocked we would never have been called
+}
+
+
+SwFltStackEntry::~SwFltStackEntry()
+{
+ // Attribut kam zwar als Pointer, wird aber hier geloescht
+ if (pAttr)
+ delete pAttr;
+}
+
+void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
+{
+ // Attribut freigeben und das Ende merken.
+ // Alles mit USHORT's, weil sonst beim Einfuegen von neuem Text an der
+ // Cursor-Position auch der Bereich vom Attribut weiter
+ // verschoben wird.
+ // Das ist aber nicht das gewollte!
+ bLocked = FALSE; // freigeben und das ENDE merken
+ nPtNode = rEndPos.nNode.GetIndex()-1;
+ nPtCntnt = rEndPos.nContent.GetIndex();
+}
+
+BOOL SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck )
+{
+ // wird ueberhaupt ein Bereich umspannt ??
+ // - ist kein Bereich, dann nicht returnen wenn am Anfang vom Absatz
+ // - Felder aussortieren, koennen keinen Bereich haben !!
+#ifdef DEBUG
+ USHORT nWhich = pAttr->Which();
+#endif
+ if (nMkNode.GetIndex() == nPtNode.GetIndex()
+ && nMkCntnt == nPtCntnt
+ && nPtCntnt
+ && RES_TXTATR_FIELD != pAttr->Which())
+ return FALSE;
+
+ // !!! Die Content-Indizies beziehen sich immer auf den Node !!!
+ rRegion.GetPoint()->nNode = nMkNode.GetIndex() + 1;
+ SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, TRUE);
+ rRegion.GetPoint()->nContent.Assign(pCNd, nMkCntnt);
+ rRegion.SetMark();
+ if( nMkNode != nPtNode )
+ {
+ rRegion.GetPoint()->nNode = nPtNode.GetIndex() + 1;
+ pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, FALSE);
+ }
+ rRegion.GetPoint()->nContent.Assign(pCNd, nPtCntnt);
+#ifdef DEBUG
+ ASSERT( CheckNodesRange( rRegion.Start()->nNode,
+ rRegion.End()->nNode, TRUE ),
+ "Attribut oder AEhnliches ueber Bereichs-Grenzen" );
+#endif
+ if( bCheck )
+ return CheckNodesRange( rRegion.Start()->nNode,
+ rRegion.End()->nNode, TRUE );
+ else
+ return TRUE;
+}
+
+
+SwFltControlStack::SwFltControlStack(SwDoc* pDo, ULONG nFieldFl) :
+ SwFltControlStackEntries(10, 5),
+ pDoc(pDo),
+ nFieldFlags(nFieldFl),
+ bIsEndStack(FALSE)
+{
+}
+
+
+SwFltControlStack::~SwFltControlStack()
+{
+ ASSERT(!Count(), "noch Attribute auf dem Stack");
+}
+
+// MoveAttrs() ist fuer folgendes Problem:
+// Wenn ueber den Stack ein Feld wie z.B. "Variable setzen" gesetzt wird,
+// verschiebt sich der Text um ein \xff - Zeichen, und alle folgenden
+// Attribute stimmen in ihrer Position nicht mehr.
+// Dann muss MoveAttrs() nach dem Setzen des Attributes ins Doc gerufen werden,
+// so dass alle Attribut-Positionen,
+// die im selben Absatz weiter hinten stehen, um 1 Zeichen weiter
+// nach rechts verschoben werden.
+void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
+{
+ USHORT nCnt = Count();
+ SwFltStackEntry* pEntry;
+ ULONG nPosNd = rPos.nNode.GetIndex();
+ USHORT nPosCt = rPos.nContent.GetIndex() - 1;
+
+ for (USHORT i=0; i < nCnt; i++){
+ pEntry = (*this)[ i ];
+ if(( pEntry->nMkNode.GetIndex() + 1 == nPosNd )
+ &&( pEntry->nMkCntnt >= nPosCt )){
+ pEntry->nMkCntnt++;
+ ASSERT( pEntry->nMkCntnt
+ <= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
+ "Attribut-Anfang hinter Zeilenende" );
+ }
+ if(( pEntry->nPtNode.GetIndex() + 1 == nPosNd )
+ &&( pEntry->nPtCntnt >= nPosCt )){
+ pEntry->nPtCntnt++;
+ ASSERT( pEntry->nPtCntnt
+ <= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
+ "Attribut-Ende hinter Zeilenende" );
+ }
+ }
+}
+
+
+
+// all attributes that are on rPos will but changed so that their Point or their
+// Mark (whichever had been on rPos) will be set to the next node
+void SwFltControlStack::MoveAttrsToNextNode( const SwNodeIndex& rNdIdx )
+{
+ USHORT nCnt = Count();
+ SwFltStackEntry* pEntry;
+
+ for (USHORT i=0; i < nCnt; i++)
+ {
+ pEntry = (*this)[ i ];
+ if( ( pEntry->nMkNode == rNdIdx ) )
+ pEntry->nMkNode++;
+
+ if( ( pEntry->nPtNode == rNdIdx ) )
+ pEntry->nPtNode++;
+ }
+}
+
+
+void SwFltControlStack::MarkAllAttrsOld()
+{
+ USHORT nCnt = Count();
+ for (USHORT i=0; i < nCnt; i++)
+ (*this)[ i ]->bOld = TRUE;
+}
+
+
+void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr )
+{
+ SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
+ register USHORT nWhich = pTmp->pAttr->Which();
+ SetAttr(rPos, nWhich);// Ende von evtl. gleichen Attributen auf dem Stack
+ // Setzen, damit sich die Attribute nicht auf
+ // dem Stack haeufen
+ Insert(pTmp, Count());
+}
+
+// SwFltControlStack::StealAttr() loescht Attribute des angegebenen Typs vom Stack.
+// Als nAttrId sind erlaubt: 0 fuer alle, oder ein spezieller Typ.
+// Damit erscheinen sie nicht in der Doc-Struktur. Dabei werden nur die
+// Attribute entfernt, die im selben Absatz wie pPos stehen.
+// Wird fuer Grafik-Apos -> Grafiken benutzt.
+void SwFltControlStack::StealAttr(const SwPosition* pPos, USHORT nAttrId /* = 0 */)
+{
+ USHORT nCnt = Count();
+
+ register SwFltStackEntry* pEntry;
+
+ while (nCnt)
+ {
+ nCnt --;
+ pEntry = (*this)[ nCnt ];
+ if (pEntry->nPtNode.GetIndex()+1 == pPos->nNode.GetIndex() &&
+ (!nAttrId || nAttrId == pEntry->pAttr->Which()))
+ DeleteAndDestroy(nCnt); // loesche aus dem Stack
+ }
+}
+
+// SwFltControlStack::KillUnlockedAttr() loescht alle Attribute vom Stack,
+// welche punktuell auf pPos aufgespannt sind.
+// Damit erscheinen sie nicht in der Doc-Struktur.
+// Wird im WW Import benoetigt zum ignorieren der auf dem 0x0c Section-
+// Break-Symbol gesetzten Attribute.
+void SwFltControlStack::KillUnlockedAttrs(const SwPosition& pPos)
+{
+ SwNodeIndex aAktNode( pPos.nNode, -1 );
+ USHORT nAktIdx = pPos.nContent.GetIndex();
+
+ USHORT nCnt = Count();
+ register SwFltStackEntry* pEntry;
+ while( nCnt )
+ {
+ nCnt --;
+ pEntry = (*this)[ nCnt ];
+ if( !pEntry->bOld
+ && !pEntry->bLocked
+ && (pEntry->nMkNode == aAktNode)
+ && (pEntry->nMkCntnt == nAktIdx )
+ && (pEntry->nPtNode == aAktNode)
+ && (pEntry->nPtCntnt == nAktIdx ))
+ {
+ DeleteAndDestroy( nCnt ); // loesche aus dem Stack
+ }
+ }
+}
+
+// Alle gelockten Attribute freigeben (unlocken) und das Ende setzen,
+// alle anderen im Document setzen und wieder aus dem Stack loeschen
+// Returned, ob das gesuchte Attribut / die gesuchten Attribute
+// ueberhaupt auf dem Stack standen
+BOOL SwFltControlStack::SetAttr(const SwPosition& rPos, USHORT nAttrId,
+ BOOL bTstEnde, long nHand )
+{
+ ASSERT(!nAttrId ||
+ (POOLATTR_BEGIN <= nAttrId && POOLATTR_END > nAttrId) ||
+ (RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
+ "Falsche Id fuers Attribut")
+
+ BOOL bFound = FALSE;
+ USHORT nCnt = Count();
+
+ SwFltStackEntry* pEntry;
+
+ for (USHORT i=0; i < nCnt; i++)
+ {
+ pEntry = (*this)[ i ];
+ if (pEntry->bLocked)
+ {
+ // setze das Ende vom Attribut
+ BOOL bF = FALSE;
+ if (!nAttrId ){
+ bF = TRUE;
+ }else if( nAttrId == pEntry->pAttr->Which()){
+ if( nAttrId != RES_FLTR_BOOKMARK ){ // Handle abfragen
+ bF = TRUE;
+ }else if( nHand == ((SwFltBookmark*)(pEntry->pAttr))->GetHandle() )
+ {
+ bF = TRUE;
+ }
+ }
+ if( bF ){
+ pEntry->SetEndPos(rPos);
+ bFound = TRUE;
+ }
+#if 0
+ if (!nAttrId || nAttrId == pEntry->pAttr->Which())
+ {
+ pEntry->SetEndPos(rPos);
+ bFound = TRUE;
+ }
+#endif
+ continue;
+ }
+
+ // ist die Endposition die Cursor-Position, dann noch nicht
+ // ins Dokument setzen, es muss noch Text folgen;
+ // ausser am Dokumentende. (Attribut-Expandierung !!)
+ // Beim Ende-Stack niemals ausser am DocEnde reinsetzen
+ if (bTstEnde)
+ {
+ if (bIsEndStack || pEntry->nPtNode.GetIndex()+1 ==
+ rPos.nNode.GetIndex())
+ continue;
+ }
+ SetAttrInDoc(rPos, pEntry);
+ DeleteAndDestroy(i); // loesche aus dem Stack
+ i--; nCnt--; // Danach rutschen alle folgenden nach unten
+ }
+ return bFound;
+}
+
+static void MakePoint(SwFltStackEntry* pEntry, SwDoc* pDoc, SwPaM& rRegion)
+{
+ // der Anker ist der Point vom Pam. Dieser wird beim Einfugen
+ // von Text usw. veraendert; darum wird er auf dem Stack
+ // gespeichert. Das Attribut muss nur noch im Format
+ // gesetzt werden.
+ rRegion.DeleteMark();
+ rRegion.GetPoint()->nNode = pEntry->nMkNode.GetIndex() + 1;
+ SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, TRUE);
+ rRegion.GetPoint()->nContent.Assign(pCNd, pEntry->nMkCntnt);
+}
+
+static void MakeRegionOrPoint(SwFltStackEntry* pEntry, SwDoc* pDoc,
+ SwPaM& rRegion, BOOL bCheck )
+{
+ if (!pEntry->MakeRegion(pDoc, rRegion, bCheck ))
+ MakePoint(pEntry, pDoc, rRegion);
+}
+
+// MakeBookRegionOrPoint() ist wie MakeRegionOrPoint, aber die besonderen
+// Beschraenkungen von Bookmarks in Tabellen werden beachtet.
+// ( Anfang und Ende muessen in selber Zelle sein )
+static void MakeBookRegionOrPoint(SwFltStackEntry* pEntry, SwDoc* pDoc,
+ SwPaM& rRegion, BOOL bCheck )
+{
+ if (pEntry->MakeRegion(pDoc, rRegion, bCheck )){
+ const SwNodes& rNds = pDoc->GetNodes();
+// BOOL b1 = rNds[rRegion.GetPoint()->nNode]->FindTableNode() != 0;
+// const SwStartNode* p1 = rNds[rRegion.GetPoint()->nNode]->FindTableBoxStartNode();
+// const SwStartNode* p2 = rNds[rRegion.GetMark()->nNode]->FindTableBoxStartNode();
+ if( rNds[rRegion.GetPoint()->nNode]->FindTableBoxStartNode()
+ != rNds[rRegion.GetMark()->nNode]->FindTableBoxStartNode() ){
+ rRegion.Exchange(); // Ungueltiger Bereich
+ rRegion.DeleteMark(); // -> beide auf Mark
+ }
+ }else{
+ MakePoint(pEntry, pDoc, rRegion);
+ }
+}
+
+static void MakePosition(SwFltStackEntry* pEntry, SwDoc* pDoc, SwPosition& rPosi)
+{
+ rPosi.nNode = pEntry->nMkNode.GetIndex() + 1;
+ SwCntntNode* pCNd = GetCntntNode(pDoc, rPosi.nNode, TRUE);
+ rPosi.nContent.Assign(pCNd, pEntry->nMkCntnt);
+}
+
+#ifdef DEBUG
+extern FASTBOOL CheckNodesRange( const SwNodeIndex& rStt,
+ const SwNodeIndex& rEnd, FASTBOOL bChkSection );
+#endif
+
+// IterateNumrulePiece() sucht von rTmpStart bis rEnd den ersten
+// fuer Numrules gueltigen Bereich heraus.
+//
+// rNds sind die Doc-Nodes
+// rEnd ist Bereichs-Ende,
+// rTmpStart ist ReinRaus-Parameter: Anfang des zu untersuchenden Bereiches rein,
+// Anfang des gueltigen Bereichs raus
+// rTmpEnd ist raus-Parameter
+// Return-Bool ist TRUE fuer gueltigen Bereich
+static BOOL IterateNumrulePiece( const SwNodeIndex& rEnd,
+ SwNodeIndex& rTmpStart, SwNodeIndex& rTmpEnd )
+{
+ while( ( rTmpStart <= rEnd )
+ && !( rTmpStart.GetNode().IsTxtNode() ) ) // suche gueltigen Anfang
+ rTmpStart++;
+
+ rTmpEnd = rTmpStart;
+ while( ( rTmpEnd <= rEnd )
+ && ( rTmpEnd.GetNode().IsTxtNode() ) ) // suche gueltiges Ende + 1
+ rTmpEnd++;
+
+ rTmpEnd--; // gueltiges Ende
+
+ return rTmpStart <= rTmpEnd; // gueltig ?
+}
+
+void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry)
+{
+ SwPaM aRegion( rTmpPos );
+
+ switch(pEntry->pAttr->Which())
+ {
+ case RES_FLTR_ANCHOR:
+ {
+ MakePoint(pEntry, pDoc, aRegion);
+ SwFrmFmt* pFmt = ((SwFltAnchor*)pEntry->pAttr)->GetFrmFmt();
+ SwFmtAnchor aAnchor(pFmt->GetAnchor());
+ aAnchor.SetAnchor(aRegion.GetPoint());
+ pFmt->SetAttr(aAnchor);
+ // Damit die Frames bei Einfuegen in existierendes Doc
+ // erzeugt werden (erst nach Setzen des Ankers!):
+ if(pDoc->GetRootFrm()
+ && FLY_AT_CNTNT == pFmt->GetAnchor().GetAnchorId()){
+ pFmt->MakeFrms();
+ }
+ }
+ break;
+ case RES_FLTR_STYLESHEET:
+ break;
+ case RES_TXTATR_FIELD:
+ break;
+ case RES_TXTATR_TOXMARK:
+ break;
+ case RES_FLTR_NUMRULE: // Numrule 'reinsetzen
+ {
+ const String& rNumNm = ((SfxStringItem*)pEntry->pAttr)->GetValue();
+ SwNumRule* pRul = pDoc->FindNumRulePtr( rNumNm );
+ if( pRul )
+ {
+ if( pEntry->MakeRegion(pDoc, aRegion, TRUE))
+ {
+ SwNodeIndex aTmpStart( aRegion.Start()->nNode );
+ SwNodeIndex aTmpEnd( aTmpStart );
+ SwNodeIndex& rRegEndNd = aRegion.End()->nNode;
+ while( IterateNumrulePiece( rRegEndNd,
+ aTmpStart, aTmpEnd ) )
+ {
+ SwPaM aTmpPam( aTmpStart, aTmpEnd );
+ pDoc->SetNumRule( aTmpPam, *pRul );
+
+ aTmpStart = aTmpEnd; // Start fuer naechstes Teilstueck
+ aTmpStart++;
+ }
+ }
+ else
+ pDoc->DelNumRule( rNumNm );
+ }
+ }
+ break;
+ case RES_FLTR_NUMRULE_NUM:
+ break;
+ case RES_FLTR_BOOKMARK: // eigentlich nur fuer den Ende-Stack
+ {
+ SwFltBookmark* pB = (SwFltBookmark*)pEntry->pAttr;
+ const String& rName = ((SwFltBookmark*)pEntry->pAttr)->GetName();
+
+ if (IsFlagSet(BOOK_TO_VAR_REF))
+ {
+ if (pB->IsPgRef() && !pB->IsRef())
+ {
+ // XRefs und Bookmarks sind bereits geUpcased
+ MakeBookRegionOrPoint(pEntry, pDoc, aRegion, TRUE);
+ pDoc->Insert(aRegion, SwFmtRefMark(rName));
+ }
+ else if( !pB->IsOnlyRef() )
+ {
+ SwFieldType* pFT = pDoc->GetFldType(RES_SETEXPFLD, rName);
+ if (!pFT)
+ { // FieldType anlegen
+ SwSetExpFieldType aS(pDoc, rName, GSE_STRING);
+ pFT = pDoc->InsertFldType(aS);
+ }
+ SwSetExpField aFld((SwSetExpFieldType*)pFT,
+ pB->GetValSys());
+ aFld.SetSubType(SUB_INVISIBLE);
+ MakePoint(pEntry, pDoc, aRegion);
+ pDoc->Insert(aRegion, SwFmtFld(aFld));
+ MoveAttrs( *(aRegion.GetPoint()) );
+ }
+ }
+ if( !pB->IsOnlyRef() &&
+ ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) )
+ {
+ MakeBookRegionOrPoint(pEntry, pDoc, aRegion, TRUE);
+ pDoc->MakeBookmark( aRegion, aEmptyKeyCode, rName, aEmptyStr);
+ }
+ }
+ break;
+ case RES_FLTR_TOX:
+ {
+ MakePoint(pEntry, pDoc, aRegion);
+
+ SwPosition* pPoint = aRegion.GetPoint();
+
+ SwFltTOX* pTOXAttr = (SwFltTOX*)pEntry->pAttr;
+
+ // test if on this node there had been a pagebreak BEFORE the
+ // tox attribut was put on the stack
+ SfxItemSet aBkSet( pDoc->GetAttrPool(), RES_PAGEDESC, RES_BREAK );
+ SwCntntNode* pNd = 0;
+ if( !pTOXAttr->HadBreakItem() || !pTOXAttr->HadPageDescItem() )
+ {
+ pNd = pPoint->nNode.GetNode().GetCntntNode();
+ if( pNd )
+ {
+ const SfxItemSet* pSet = pNd->GetpSwAttrSet();
+ const SfxPoolItem* pItem;
+ if( pSet )
+ {
+ if( !pTOXAttr->HadBreakItem()
+ && SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, FALSE, &pItem ) )
+ {
+ aBkSet.Put( *pItem );
+ pNd->ResetAttr( RES_BREAK );
+ }
+ if( !pTOXAttr->HadPageDescItem()
+ && SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, FALSE, &pItem ) )
+ {
+ aBkSet.Put( *pItem );
+ pNd->ResetAttr( RES_PAGEDESC );
+ }
+ }
+ }
+ }
+
+ // now insert the TOX
+ const SwTOXBaseSection* pSect
+ = pDoc->InsertTableOf( *pPoint,
+ *pTOXAttr->GetBase(),
+ FALSE );
+ delete pTOXAttr->GetBase();
+
+
+ // set (aboved saved and removed) the break item at the node following the TOX
+ if( aBkSet.Count() )
+ pNd->SetAttr( aBkSet );
+
+
+ USHORT nCols = ((SwFltTOX*)pEntry->pAttr)->GetCols();
+ aRegion.Move( fnMoveBackward );
+ SwTOXBase* pBase = (SwTOXBase*)pDoc->GetCurTOX( *aRegion.GetPoint() );
+ if( pBase )
+ {
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_COL, RES_COL );
+ SwFmtCol aCol;
+ aCol.Init( nCols, 708, USHRT_MAX );
+ aSet.Put( aCol );
+ pBase->SetAttrSet( aSet );
+ }
+ }
+ break;
+ case RES_FLTR_SECTION:
+ MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark
+ pDoc->Insert(aRegion, *((SwFltSection*)pEntry->pAttr)->GetSection(),
+ 0, FALSE);
+ delete(((SwFltSection*)pEntry->pAttr)->GetSection());
+ break;
+ case RES_FLTR_REDLINE:
+ {
+ if (pEntry->MakeRegion(pDoc, aRegion, TRUE))
+ {
+ pDoc->SetRedlineMode( REDLINE_ON
+ | REDLINE_SHOW_INSERT
+ | REDLINE_SHOW_DELETE );
+ SwFltRedline& rFltRedline = *((SwFltRedline*)pEntry->pAttr);
+
+ if( USHRT_MAX != rFltRedline.nAutorNoPrev )
+ {
+ SwRedlineData aData(rFltRedline.eTypePrev,
+ rFltRedline.nAutorNoPrev,
+ rFltRedline.aStampPrev,
+ aEmptyStr,
+ 0
+ );
+ pDoc->AppendRedline(new SwRedline(aData, aRegion));
+ }
+ SwRedlineData aData(rFltRedline.eType,
+ rFltRedline.nAutorNo,
+ rFltRedline.aStamp,
+ aEmptyStr,
+ 0
+ );
+ pDoc->AppendRedline( new SwRedline(aData, aRegion) );
+ pDoc->SetRedlineMode( REDLINE_NONE
+ | REDLINE_SHOW_INSERT
+ | REDLINE_SHOW_DELETE );
+ }
+ }
+ break;
+ default:
+ if (pEntry->MakeRegion(pDoc, aRegion, FALSE))
+ pDoc->Insert(aRegion, *pEntry->pAttr);
+ break;
+ }
+}
+
+SfxPoolItem* SwFltControlStack::GetFmtStackAttr(USHORT nWhich, USHORT * pPos)
+{
+ SwFltStackEntry* pEntry;
+ USHORT nSize = Count();
+
+ while (nSize)
+ {
+ // ist es das gesuchte Attribut ? (gueltig sind nur gelockte,
+ // also akt. gesetzte Attribute!!)
+ if ((pEntry = (*this)[ --nSize ])->bLocked &&
+ pEntry->pAttr->Which() == nWhich)
+ {
+ if (pPos)
+ *pPos = nSize;
+ return (SfxPoolItem*)pEntry->pAttr; // Ok, dann Ende
+ }
+ }
+ return 0;
+}
+
+const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, USHORT nWhich)
+{
+ SwFltStackEntry* pEntry;
+ USHORT nSize = Count();
+ SwNodeIndex aAktNode( rPos.nNode, -1 );
+ USHORT nAktIdx = rPos.nContent.GetIndex();
+
+ while (nSize)
+ {
+ // ist es das gesuchte Attribut ? (gueltig sind nur gelockte,
+ // also akt. gesetzte, noch offene Attribute!!)
+ pEntry = (*this)[ --nSize ];
+ if( pEntry->bLocked
+ && (pEntry->pAttr->Which() == nWhich)
+ && (pEntry->nMkNode == aAktNode)
+ && (pEntry->nMkCntnt == nAktIdx ))
+ {
+ return (SfxPoolItem*)pEntry->pAttr; // Ok, dann Ende
+ }
+ }
+ return 0;
+}
+
+const SfxPoolItem* SwFltControlStack::GetFmtAttr(const SwPosition& rPos, USHORT nWhich)
+{
+ SfxPoolItem* pHt = GetFmtStackAttr(nWhich);
+ if (pHt)
+ return (const SfxPoolItem*)pHt;
+
+ // im Stack ist das Attribut nicht vorhanden, also befrage das Dokument
+// SwCntntNode * pNd = rPaM.GetCntntNode();
+ SwCntntNode * pNd = pDoc->GetNodes()[ rPos.nNode ]->GetCntntNode();
+
+ if (!pNd) // kein ContentNode, dann das dflt. Attribut
+ return &pDoc->GetAttrPool().GetDefaultItem(nWhich);
+ return &pNd->GetAttr(nWhich);
+}
+
+BOOL SwFltControlStack::IsAttrOpen(USHORT nAttrId)
+{
+ USHORT nCnt = Count();
+
+ if (!nCnt) return FALSE;
+
+ SwFltStackEntry* pEntry;
+
+ for (USHORT i=0; i < nCnt; i++)
+ {
+ pEntry = (*this)[ i ];
+ if (pEntry->bLocked && nAttrId == pEntry->pAttr->Which())
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//------ hier stehen die Methoden von SwFltAnchor -----------
+SwFltAnchor::SwFltAnchor(SwFrmFmt* pFmt) :
+ SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(pFmt)
+{
+}
+
+SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) :
+ SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(rCpy.pFrmFmt)
+{
+}
+
+int SwFltAnchor::operator==(const SfxPoolItem& rItem) const
+{
+ return pFrmFmt == ((SwFltAnchor&)rItem).pFrmFmt;
+}
+
+SfxPoolItem* __EXPORT SwFltAnchor::Clone(SfxItemPool*) const
+{
+ return new SwFltAnchor(*this);
+}
+
+//------ hier stehen die Methoden von SwFltRedline -----------
+int SwFltRedline::operator==(const SfxPoolItem& rItem) const
+{
+ return this == &rItem;
+}
+
+SfxPoolItem* SwFltRedline::Clone( SfxItemPool* ) const
+{
+ return new SwFltRedline(*this);
+}
+
+//------ hier stehen die Methoden von SwFltBookmark -----------
+SwFltBookmark::SwFltBookmark( const String& rNa, const String& rVa,
+ long nHand, BOOL bOnlyR )
+ : SfxPoolItem(RES_FLTR_BOOKMARK), nHandle(nHand), aName(rNa), aVal(rVa),
+ bOnlyRef(bOnlyR), bRef(FALSE), bPgRef(FALSE)
+{
+ // eSrc: CHARSET_DONTKNOW fuer keine UEbersetzung bei operator <<
+ // Upcase wird immer gemacht.
+ // bei XXXStack.NewAttr(...) wird nie eine UEbersetzung vorgenommen.
+ // ansonsten: uebergebener Src-Charset fuer aName
+ // im Filter eingestellter Src-Charset fuer aVal ( Text )
+}
+
+SwFltBookmark::SwFltBookmark(const SwFltBookmark& rCpy)
+ : SfxPoolItem(RES_FLTR_BOOKMARK),
+ nHandle(rCpy.nHandle),
+ aName(rCpy.aName),
+ aVal(rCpy.aVal),
+ bOnlyRef(rCpy.bOnlyRef),
+ bRef(rCpy.bRef),
+ bPgRef(rCpy.bPgRef)
+{
+}
+
+int SwFltBookmark::operator==(const SfxPoolItem& rItem) const
+{
+ return (aName == ((SwFltBookmark&)rItem).aName)
+ && (nHandle == ((SwFltBookmark&)rItem).nHandle);
+}
+
+SfxPoolItem* SwFltBookmark::Clone(SfxItemPool*) const
+{
+ return new SwFltBookmark(*this);
+}
+
+//------ hier stehen die Methoden von SwFltTOX -----------
+
+SwFltTOX::SwFltTOX(SwTOXBase* pBase, USHORT _nCols)
+ : SfxPoolItem(RES_FLTR_TOX), pTOXBase(pBase), nCols( _nCols ),
+ bHadBreakItem( FALSE ), bHadPageDescItem( FALSE )
+{
+}
+
+SwFltTOX::SwFltTOX(const SwFltTOX& rCpy)
+ : SfxPoolItem(RES_FLTR_TOX), pTOXBase(rCpy.pTOXBase), nCols( rCpy.nCols ),
+ bHadBreakItem( rCpy.bHadBreakItem ), bHadPageDescItem( rCpy.bHadPageDescItem )
+{
+}
+
+int SwFltTOX::operator==(const SfxPoolItem& rItem) const
+{
+ return pTOXBase == ((SwFltTOX&)rItem).pTOXBase;
+}
+
+SfxPoolItem* SwFltTOX::Clone(SfxItemPool*) const
+{
+ return new SwFltTOX(*this);
+}
+
+//------ hier stehen die Methoden von SwFltSwSection -----------
+
+SwFltSection::SwFltSection(SwSection *pSect) :
+ SfxPoolItem(RES_FLTR_SECTION), pSection(pSect)
+{
+}
+
+SwFltSection::SwFltSection(const SwFltSection& rCpy) :
+ SfxPoolItem(RES_FLTR_SECTION), pSection(rCpy.pSection)
+{
+}
+
+int SwFltSection::operator==(const SfxPoolItem& rItem) const
+{
+ return pSection == ((SwFltSection&)rItem).pSection;
+}
+
+SfxPoolItem* __EXPORT SwFltSection::Clone(SfxItemPool*) const
+{
+ return new SwFltSection(*this);
+}
+
+//------ hier stehen die Methoden von SwFltEndStack -----------
+
+// Bei Auftreten einer Referenz wird die entsprechende Textmarke als
+// RefMark statt als Bookmark behandelt
+
+void SwFltEndStack::SetBookRef( const String& rName, BOOL bPgRef)
+{
+ SfxPoolItem* pAttr;
+ USHORT nSize = Count();
+
+ while( nSize )
+ {
+ // ist es das gesuchte Attribut ?
+ pAttr = (*this)[ --nSize ]->pAttr;
+ if( (pAttr->Which() == RES_FLTR_BOOKMARK ) &&
+//JP 11.05.00 - UNICODE-FRAGE - reicht ein EqualsIgnoreCaseAscii oder
+// muß man das ueber die International machen?
+ ((SwFltBookmark*)pAttr)->GetName().EqualsIgnoreCaseAscii( rName ))
+ {
+ if (bPgRef)
+ ((SwFltBookmark*)pAttr)->SetPgRef();
+ else
+ ((SwFltBookmark*)pAttr)->SetRef();
+ break;
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// hier beginnt der von mdt erzeugte code. dieser ist eine shell auf
+// der writer-seite nach moeglichkeit bald fuer alle filter. die ganze
+// schwierigkeit, texte & formatattribute einzufuegen, die positionen
+// zu verwalten, styles & kopf/fuszzeilen etc.
+//
+
+//////////////////////////////////////////////////////////// SwFltShell
+SwFltShell::SwFltShell(SwDoc* pDoc, SwPaM& rPaM, BOOL bNew, ULONG nFieldFl)
+ : aStack(pDoc, nFieldFl),
+ aEndStack(pDoc, nFieldFl),
+ pCurrentPageDesc(0),
+ eSrcCharSet( RTL_TEXTENCODING_MS_1252 ),
+ nPageDescOffset(GetDoc().GetPageDescCnt()),
+ pPaM(new SwPaM( *(rPaM.GetPoint()))),
+ bNewDoc(bNew),
+ bStdPD(FALSE),
+ bProtect(FALSE),
+ nAktStyle(0),
+ pSavedPos(0),
+ eSubMode(None)
+{
+ memset( pColls, 0, sizeof( pColls ) );
+ pOutDoc = new SwFltOutDoc( *pDoc, pPaM, aStack, aEndStack );
+ pOut = pOutDoc;
+
+ if( !bNewDoc ){ // in ein Dokument einfuegen ?
+ // Da immer ganze Zeile eingelesen werden, muessen
+ // evtl. Zeilen eingefuegt / aufgebrochen werden
+ const SwPosition* pPos = pPaM->GetPoint();
+ const SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
+ USHORT nCntPos = pPos->nContent.GetIndex();
+ if( nCntPos && pSttNd->GetTxt().Len() )
+ // EinfuegePos nicht in leerer Zeile
+ pDoc->SplitNode( *pPos ); // neue Zeile erzeugen
+ if( pSttNd->GetTxt().Len() ){ // EinfuegePos nicht am Ende der Zeile
+ pDoc->SplitNode( *pPos ); // neue Zeile
+ pPaM->Move( fnMoveBackward ); // gehe in leere Zeile
+ }
+
+ // verhinder das Einlesen von Tabellen in Fussnoten / Tabellen
+ ULONG nNd = pPos->nNode.GetIndex();
+ BOOL bReadNoTbl = 0 != pSttNd->FindTableNode() ||
+ ( nNd < pDoc->GetNodes().GetEndOfInserts().GetIndex() &&
+ pDoc->GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
+ if( bReadNoTbl )
+ pOutDoc->SetReadNoTable();
+ }
+ pCurrentPageDesc = &((SwPageDesc&)pDoc->GetPageDesc( 0 )); // Standard
+
+}
+
+SwFltShell::~SwFltShell()
+{
+ USHORT i;
+
+ if (eSubMode == Style)
+ EndStyle();
+ if( pOutDoc->IsInTable() ) // falls nicht ordentlich abgeschlossen
+ EndTable();
+ if( pOutDoc->IsInFly() )
+ EndFly();
+
+ GetDoc().SetUpdateExpFldStat();
+ GetDoc().SetInitDBFields(TRUE);
+ aStack.SetAttr(*pPaM->GetPoint(), 0, FALSE);
+ aStack.SetAttr(*pPaM->GetPoint(), 0, FALSE);
+ aEndStack.SetAttr(*pPaM->GetPoint(), 0, FALSE);
+ aEndStack.SetAttr(*pPaM->GetPoint(), 0, FALSE);
+ if( bProtect ){ // Das ganze Doc soll geschuetzt sein
+
+ SwDoc& rDoc = GetDoc();
+ // 1. SectionFmt und Section anlegen
+ SwSectionFmt* pSFmt = rDoc.MakeSectionFmt( 0 );
+ SwSection aS( CONTENT_SECTION, String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM("PMW-Protect") ));
+ aS.SetProtect( TRUE );
+ // 2. Start- und EndIdx suchen
+ const SwNode* pEndNd = &rDoc.GetNodes().GetEndOfContent();
+ SwNodeIndex aEndIdx( *pEndNd, -1L );
+ const SwStartNode* pSttNd = pEndNd->StartOfSectionNode();
+ SwNodeIndex aSttIdx( *pSttNd, 1L ); // +1 -> hinter StartNode
+ // Section einfuegen
+ // Section einfuegen
+ rDoc.GetNodes().InsertSection( aSttIdx, *pSFmt, aS, &aEndIdx, FALSE );
+
+ if( !IsFlagSet(SwFltControlStack::DONT_HARD_PROTECT) ){
+ SwDocShell* pDocSh = rDoc.GetDocShell();
+ if( pDocSh )
+ pDocSh->SetReadOnlyUI( TRUE );
+ }
+ }
+ // Pagedescriptoren am Dokument updaten (nur so werden auch die
+ // linken Seiten usw. eingestellt).
+
+ GetDoc().ChgPageDesc( 0, GetDoc().GetPageDesc( 0 )); // PageDesc "Standard"
+ for (i=nPageDescOffset;i<GetDoc().GetPageDescCnt();i++)
+ {
+ const SwPageDesc& rPD = GetDoc().GetPageDesc(i);
+ GetDoc().ChgPageDesc(i, rPD);
+ }
+
+ delete pPaM;
+ for (i=0; i<sizeof(pColls)/sizeof(*pColls); i++)
+ if( pColls[i] )
+ delete pColls[i];
+ delete pOutDoc;
+}
+
+SwFltShell& SwFltShell::operator << ( const String& rStr )
+{
+ ASSERT(eSubMode != Style, "char insert while in style-mode");
+ GetDoc().Insert( *pPaM, rStr );
+ return *this;
+}
+
+void SwFltShell::ConvertUStr( String& rInOut )
+{
+ GetAppCharClass().toUpper( rInOut );
+}
+void SwFltShell::ConvertLStr( String& rInOut )
+{
+ GetAppCharClass().toLower( rInOut );
+}
+
+// QuoteString() wandelt CRs abhaengig von nFieldIniFlags in '\n' oder "\0x0d"
+String SwFltShell::QuoteStr( const String& rIn )
+{
+ String sOut( rIn );
+ BOOL bAllowCr = aStack.IsFlagSet( SwFltControlStack::ALLOW_FLD_CR );
+
+ for( xub_StrLen n = 0; n < sOut.Len(); ++n )
+ {
+ switch( sOut.GetChar( n ) )
+ {
+ case 0x0a:
+ sOut.Erase( n, 1 ); // 0xd 0xa wird zu \n
+ break;
+
+ case 0x0b:
+ case 0x0c:
+ case 0x0d:
+ if( bAllowCr )
+ sOut.SetChar( n, '\n' );
+ break;
+ }
+ }
+ return sOut;
+}
+
+SwFltShell& SwFltShell::operator << ( const sal_Unicode c )
+{
+ ASSERT( eSubMode != Style, "char insert while in style-mode");
+ GetDoc().Insert( *pPaM, c );
+ return *this;
+}
+
+SwFltShell& SwFltShell::AddError( const sal_Char* pErr )
+{
+ String aName( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "ErrorTag" )));
+ SwFieldType* pFT = GetDoc().GetFldType( RES_SETEXPFLD, aName );
+ if( pFT == 0)
+ {
+ SwSetExpFieldType aS(&GetDoc(), aName, GSE_STRING);
+ pFT = GetDoc().InsertFldType(aS);
+ }
+ SwSetExpField aFld( (SwSetExpFieldType*)pFT,
+ String::CreateFromAscii( pErr ));
+ //, VVF_INVISIBLE
+ GetDoc().Insert(*pPaM, SwFmtFld(aFld));
+ return *this;
+}
+
+SwFltShell& SwFltShell::AddLinkedSection( const String& rFileName )
+{
+ String aStr( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "Ww1" )));
+ SwSection* pSection = new SwSection( FILE_LINK_SECTION,
+ GetDoc().GetUniqueSectionName( &aStr ));
+ pSection->SetLinkFileName( INetURLObject::RelToAbs( rFileName ) );
+ pSection->SetProtect( TRUE );
+ *this << SwFltSection(pSection);
+ EndItem( RES_FLTR_SECTION);
+ return *this;
+}
+
+SwFltShell& SwFltShell::operator << (Graphic& rGraphic)
+{
+ SwFlyFrmFmt* pFlyFmt = GetDoc().Insert( *pPaM, aEmptyStr, aEmptyStr,
+ &rGraphic); // embedded Grafik !!
+ return *this;
+}
+
+SwFltShell& SwFltShell::AddGraphic( const String& rPicName )
+{
+ if (0) // gelinkt?
+ {
+ SwFlyFrmFmt* pFlyFmt = GetDoc().Insert(*pPaM,
+ INetURLObject::RelToAbs( rPicName ), // Name der Grafik !!
+ aEmptyStr);
+ }
+ else
+ {
+ // embedded:
+ GraphicFilter* pFilter = ::GetGrfFilter();
+ Graphic aGraphic;
+ // one of: GFF_NOT GFF_BMP GFF_GIF GFF_JPG GFF_PCD GFF_PCX GFF_PNG
+ // GFF_TIF GFF_XBM GFF_DXF GFF_MET GFF_PCT GFF_SGF GFF_SVM GFF_WMF
+ // GFF_SGV GFF_XXX
+ INetURLObject aDir( URIHelper::SmartRelToAbs(rPicName) );
+ switch ( pFilter->ImportGraphic( aGraphic, aDir ))
+ {
+ case GRFILTER_OK:
+ *this << aGraphic;
+ break;
+
+ case GRFILTER_OPENERROR:
+ case GRFILTER_IOERROR:
+ case GRFILTER_FORMATERROR:
+ case GRFILTER_VERSIONERROR:
+ case GRFILTER_FILTERERROR:
+ case GRFILTER_ABORT:
+ case GRFILTER_TOOBIG:
+ default:
+ AddError( "picture import error" );
+ break;
+ }
+ }
+ return *this;
+}
+
+/*SwFltShell& SwFltShell::operator << (SwFltCharSet nCharSet)
+{
+ eSrcCharSet = nCharSet;
+ return *this;
+}*/
+
+SwFltShell& SwFltShell::SetStyle( USHORT nStyle )
+{
+#ifndef MAC
+ SwFltFormatCollection* p = pColls[ nStyle ];
+#else
+ SwFltFormatCollection* p = pColls[ nStyle ];
+#endif
+
+ if (p)
+ {
+ if( !pOutDoc->IsInTable() && nStyle != nAktStyle )
+ {
+ if( pColls[nAktStyle]->IsInFly() && pOutDoc->IsInFly() )
+ pOutDoc->EndFly();
+ if( p->IsInFly() )
+ p->BeginStyleFly( pOutDoc );
+ }
+ GetDoc().SetTxtFmtColl(*pPaM, p->GetColl());
+ nAktStyle = nStyle;
+ }
+ else
+ {
+ ASSERT( FALSE, "Ungueltiger SwFltStyleCode" );
+ }
+ return *this;
+}
+
+SwFltShell& SwFltShell::operator << (SwFltBookmark& aBook)
+{
+ ConvertUStr( aBook.aName );
+ aBook.aVal = QuoteStr(aBook.aVal);
+ aEndStack.NewAttr(*pPaM->GetPoint(), aBook);
+ return *this;
+}
+
+void SwFltShell::SetBookEnd(long nHandle)
+{
+ aEndStack.SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK, TRUE, nHandle );
+}
+
+SwFltShell& SwFltShell::EndItem( USHORT nAttrId )
+{
+ switch( nAttrId )
+ {
+ case RES_FLTR_BOOKMARK:
+ ASSERT( FALSE, "Falscher Aufruf fuer Bookmark-Ende" );
+ break;
+
+ case RES_FLTR_TOX:
+ aEndStack.SetAttr(*pPaM->GetPoint(), nAttrId);
+ break;
+
+ default:
+ aStack.SetAttr(*pPaM->GetPoint(), nAttrId);
+ break;
+ }
+ return *this;
+}
+
+SwFltShell& SwFltShell::operator << (const SwField& rField)
+{
+ GetDoc().Insert(*pPaM, SwFmtFld(rField));
+ return *this;
+}
+
+/*virtual*/ SwFltOutBase& SwFltOutDoc::operator << (const SfxPoolItem& rItem)
+{
+ rStack.NewAttr(*pPaM->GetPoint(), rItem);
+ return *this;
+}
+
+SwFltShell& SwFltShell::operator << (const SwFltTOX& rItem)
+{
+ aEndStack.NewAttr(*pPaM->GetPoint(), rItem);
+ return *this;
+}
+
+/*virtual*/ SwFltOutBase& SwFltFormatCollection::operator <<
+ (const SfxPoolItem& rItem)
+{
+ pColl->SetAttr(rItem);
+ return *this;
+}
+
+
+#if 0
+SwFltShell& SwFltShell::operator >> (SfxPoolItem& rItem)
+{
+ //rItem = *GetFmtAttr(rItem.Which());
+#pragma message(__FILE__ "(?) : ^das waer schoen!")
+ //~ mdt: remove from stack if item begins here.
+ return *this;
+}
+#endif
+
+const SfxPoolItem& SwFltOutDoc::GetAttr(USHORT nWhich)
+{
+ return *rStack.GetFmtAttr(*pPaM->GetPoint(), nWhich);
+}
+
+const SfxPoolItem& SwFltFormatCollection::GetAttr(USHORT nWhich)
+{
+ return GetColl()->GetAttr(nWhich); // mit Parents
+}
+
+// GetNodeOrStyAttr holt Attribute fuer Toggle- und Modify-Attribute:
+// Bei Formatdefinitionen aus dem altuellen Style mit Parents
+// sonst aus dem Node mit Parents
+// Im Stack wird nicht nachgesehen
+
+const SfxPoolItem& SwFltOutDoc::GetNodeOrStyAttr(USHORT nWhich)
+{
+ SwCntntNode * pNd = GetDoc().GetNodes()[ pPaM->GetPoint()->nNode ]
+ ->GetCntntNode();
+ if (pNd) // ContentNode: Attribut mit Parent
+ return pNd->GetAttr(nWhich);
+ else // kein ContentNode, dann das dflt. Attribut
+ return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
+}
+
+const SfxPoolItem& SwFltFormatCollection::GetNodeOrStyAttr(USHORT nWhich)
+{
+ return GetColl()->GetAttr(nWhich); // mit Parents
+}
+
+
+BOOL SwFltShell::GetWeightBold()
+{
+ return ((SvxWeightItem&)GetNodeOrStyAttr(RES_CHRATR_WEIGHT)).GetWeight()
+ != WEIGHT_NORMAL;
+}
+
+BOOL SwFltShell::GetPostureItalic()
+{
+ return ((SvxPostureItem&)GetNodeOrStyAttr(RES_CHRATR_POSTURE)).GetPosture()
+ != ITALIC_NONE;
+}
+
+BOOL SwFltShell::GetCrossedOut()
+{
+ return ((SvxCrossedOutItem&)GetNodeOrStyAttr(RES_CHRATR_CROSSEDOUT))
+ .GetStrikeout() != STRIKEOUT_NONE;
+}
+
+BOOL SwFltShell::GetContour()
+{
+ return ((SvxContourItem&)GetNodeOrStyAttr(RES_CHRATR_CONTOUR)).GetValue();
+}
+
+BOOL SwFltShell::GetCaseKapitaelchen()
+{
+ return ((SvxCaseMapItem&)GetNodeOrStyAttr(RES_CHRATR_CASEMAP))
+ .GetCaseMap() == SVX_CASEMAP_KAPITAELCHEN;
+}
+
+BOOL SwFltShell::GetCaseVersalien()
+{
+ return ((SvxCaseMapItem&)GetNodeOrStyAttr(RES_CHRATR_CASEMAP))
+ .GetCaseMap() == SVX_CASEMAP_VERSALIEN;
+}
+
+//-------------------------------------------------------------------------
+// Tabellen
+//-------------------------------------------------------------------------
+const SfxPoolItem& SwFltOutBase::GetCellAttr(USHORT nWhich)
+{
+ ASSERT(FALSE, "GetCellAttr ausserhalb von normalem Text");
+ return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
+}
+
+BOOL SwFltOutBase::BeginTable()
+{
+ ASSERT(FALSE, "BeginTable ausserhalb von normalem Text");
+ return FALSE;
+}
+
+void SwFltOutBase::NextTableCell()
+{
+ ASSERT(FALSE, "NextTableCell ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::NextTableRow()
+{
+ ASSERT(FALSE, "NextTableRow ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::SetTableWidth(SwTwips nW)
+{
+ ASSERT(FALSE, "SetTableWidth ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::SetTableOrient(SwHoriOrient eOri)
+{
+ ASSERT(FALSE, "SetTableOrient ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::SetCellWidth(SwTwips nWidth, USHORT nCell)
+{
+ ASSERT(FALSE, "SetCellWidth ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::SetCellHeight(SwTwips nH)
+{
+ ASSERT(FALSE, "SetCellHeight ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::SetCellBorder(const SvxBoxItem& rFmtBox, USHORT nCell)
+{
+ ASSERT(FALSE, "SetCellBorder ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::SetCellSpace(USHORT nSp)
+{
+ ASSERT(FALSE, "SetCellSpace ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::DeleteCell(USHORT nCell)
+{
+ ASSERT(FALSE, "DeleteCell ausserhalb von normalem Text");
+}
+
+void SwFltOutBase::EndTable()
+{
+ ASSERT(FALSE, "EndTable ausserhalb von normalem Text");
+}
+
+/*virtual*/ BOOL SwFltOutDoc::IsInTable()
+{
+ return pTable != 0;
+};
+
+BOOL SwFltOutDoc::BeginTable()
+{
+ if(bReadNoTbl)
+ return FALSE;
+
+ if (pTable){
+ ASSERT(FALSE, "BeginTable in Table");
+ return FALSE;
+ }
+ // Alle Attribute schliessen, da sonst Attribute
+ // entstehen koennen, die in Flys reinragen
+ rStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ rEndStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+// create table:
+ ASSERT(pTabSavedPos == NULL, "SwFltOutDoc");
+ pTabSavedPos = new SwPosition(*pPaM->GetPoint());
+ pTable = GetDoc().InsertTable(*pTabSavedPos, 1, 1, HORI_LEFT);
+ nTableWidth = 0;
+ ((SwTable*)pTable)->LockModify(); // Nichts automatisch anpassen!
+// set pam in 1. table cell
+ usTableX =
+ usTableY = 0;
+ SeekCell(usTableY, usTableX, TRUE);
+ return TRUE;
+}
+
+SwTableBox* SwFltOutDoc::GetBox(USHORT ny, USHORT nx /*= USHRT_MAX */)
+{
+ if(!pTable){
+ ASSERT(pTable, "GetBox ohne Tabelle");
+ return 0;
+ }
+ if( nx == USHRT_MAX ) // aktuelle Zelle
+ nx = usTableX;
+
+// get structs to table cells
+ const SwTableLines* pTableLines = &pTable->GetTabLines();
+ if(!pTableLines){
+ ASSERT(FALSE, "SwFltOutDoc:GetBox:pTableLines");
+ return 0;
+ }
+ if( ny >= pTableLines->Count() ){ // Notbremse
+ ASSERT( FALSE, "SwFltOutDoc:GetBox:ny >= Count()");
+ ny = pTableLines->Count() - 1;
+ }
+ SwTableLine* pTableLine = (*pTableLines)[ny];
+ if(!pTableLine){
+ ASSERT(FALSE, "SwFltOutDoc:GetBox:pTableLine");
+ return 0;
+ }
+ SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
+ if(!pTableBoxes){
+ ASSERT(FALSE, "SwFltOutDoc:GetBox:pTableBoxes");
+ return 0;
+ }
+ if( nx >= pTableBoxes->Count() ){ // Notbremse
+ ASSERT(FALSE, "SwFltOutDoc:GetBox:nx >= Count()");
+ nx = pTableBoxes->Count() - 1;
+ }
+ SwTableBox* pTableBox = (*pTableBoxes)[nx];
+
+ ASSERT(pTableBox != 0, "SwFltOutDoc:GetBox:pTableBox");
+ return pTableBox;
+}
+
+void SwFltOutDoc::NextTableCell()
+{
+ if(!pTable){
+ ASSERT(pTable, "NextTableCell ohne Tabelle");
+ return;
+ }
+ const SwTableLines* pTableLines = &pTable->GetTabLines();
+ SwTableLine* pTableLine = (*pTableLines)[usTableY];
+ SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
+ SwTableBox* pTableBox = (*pTableBoxes)[usTableX];
+ ASSERT(pTableBox != 0, "SwFltOutDoc:NextTableCell:pTableBox");
+ if(!pTableBox)
+ return;
+//#pragma message(__FILE__ "(?) : Sw's const problem")
+// insert cells:
+ if (++usTableX >= pTableBoxes->Count())
+ GetDoc().GetNodes().InsBoxen(
+ GetDoc().IsIdxInTbl(pPaM->GetPoint()->nNode),
+ pTableLine,
+ (SwTableBoxFmt*)pTableBox->GetFrmFmt(),
+ GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD),
+ 0,
+ pTableBoxes->Count());
+ SeekCell(usTableY, usTableX, TRUE);
+ pTableBox = (*pTableBoxes)[usTableX];
+ ASSERT(pTableBox != 0, "SwFltOutDoc:pTableBox");
+ if(pTableBox)
+ (*pTableBoxes)[usTableX]->ClaimFrmFmt();
+}
+
+void SwFltOutDoc::NextTableRow()
+{
+ SwTableBox* pTableBox = GetBox(usTableY, 0);
+ if(pTableBox){
+// duplicate row:
+ SwSelBoxes aSelBoxes;
+ aSelBoxes.Insert( pTableBox );
+ GetDoc().InsertRow(aSelBoxes);
+// GetDoc().InsertRow(pTable->SelLineFromBox(pTableBox, aSelBoxes));
+#ifdef DEBUG
+ const SwTableLines* pTableLines = &pTable->GetTabLines();
+ SwTableLine* pTableLine = (*pTableLines)[usTableY+1];
+ SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
+ USHORT nBx = pTableBoxes->Count();
+ SwTableBox* pTableBox = (*pTableBoxes)[0];
+ SwFrmFmt* pFmt = pTableBox->GetFrmFmt();
+
+ SwFmtFrmSize &rSz = ((SwFmtFrmSize&)pFmt->GetAttr(RES_FRM_SIZE));
+ SwTwips nW = rSz.GetWidth();
+#endif
+ usTableX = 0;
+ SeekCell(++usTableY, usTableX, TRUE);
+ GetDoc().SetTxtFmtColl(*pPaM,
+ GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD));
+ }
+}
+
+void SwFltOutDoc::SetTableWidth(SwTwips nSwWidth)
+{
+ if(!pTable){
+ ASSERT(pTable, "SetTableWidth ohne Tabelle");
+ return;
+ }
+ ASSERT( nSwWidth > MINLAY, "Tabellenbreite <= MINLAY" );
+ if( nSwWidth != nTableWidth ){
+ if( nTableWidth ) // Nicht beim ersten Setzen
+ SplitTable();
+ pTable->GetFrmFmt()->SetAttr( SwFmtFrmSize(ATT_VAR_SIZE, nSwWidth));
+ nTableWidth = nSwWidth;
+ }
+}
+
+void SwFltOutDoc::SetTableOrient(SwHoriOrient eOri)
+{
+ if(!pTable){
+ ASSERT(pTable, "SetTableOrient ohne Tabelle");
+ return;
+ }
+ pTable->GetFrmFmt()->SetAttr( SwFmtHoriOrient( 0, eOri ));
+}
+
+void SwFltOutDoc::SetCellWidth(SwTwips nWidth, USHORT nCell /* = USHRT_MAX */ )
+{
+ if(!pTable){
+ ASSERT(pTable, "SetCellWidth ohne Tabelle");
+ return;
+ }
+ ASSERT( nWidth > MINLAY, "Tabellenzellenbreite <= MINLAY" );
+ if (nWidth < MINLAY)
+ nWidth = MINLAY;
+
+ SwTableBox* pTableBox = GetBox(usTableY, nCell);
+ if(pTableBox && pTableBox->GetFrmFmt() ){
+ SwFmtFrmSize aFmtFrmSize(ATT_FIX_SIZE);
+ aFmtFrmSize.SetWidth(nWidth);
+ pTableBox->GetFrmFmt()->SetAttr(aFmtFrmSize);
+ }
+}
+
+void SwFltOutDoc::SetCellHeight(SwTwips nHeight)
+{
+ if(!pTable){
+ ASSERT(pTable, "SetCellHeight ohne Tabelle");
+ return;
+ }
+
+ const SwTableLines* pTableLines = &pTable->GetTabLines();
+ SwTableLine* pTableLine = (*pTableLines)[usTableY];
+ SwFmtFrmSize aFmtFrmSize(ATT_MIN_SIZE, 0, 0);
+ if (nHeight < MINLAY)
+ nHeight = MINLAY;
+ aFmtFrmSize.SetHeight(nHeight);
+ pTableLine->GetFrmFmt()->SetAttr(aFmtFrmSize);
+}
+
+const SfxPoolItem& SwFltOutDoc::GetCellAttr(USHORT nWhich)
+{
+ if (!pTable){
+ ASSERT(pTable, "GetCellAttr ohne Table");
+ return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
+ }
+
+ SwTableBox* pTableBox = GetBox(usTableY, usTableX);
+ if(!pTableBox)
+ return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
+ return pTableBox->GetFrmFmt()->GetAttr( nWhich );
+}
+
+void SwFltOutDoc::SetCellBorder(const SvxBoxItem& rFmtBox,
+ USHORT nCell /* = USHRT_MAX */ )
+{
+ SwTableBox* pTableBox = GetBox(usTableY, nCell);
+ if(pTableBox)
+ pTableBox->GetFrmFmt()->SetAttr(rFmtBox);
+}
+
+// nicht aktiviert !!!
+void SwFltOutDoc::SetCellSpace(USHORT nDist)
+{
+ if(!pTable){
+ ASSERT(pTable, "SetCellSpace ohne Tabelle");
+ return;
+ }
+ SwTableBox* pTableBox = GetBox(usTableY, usTableX);
+ if(!pTableBox)
+ return;
+
+ SvxBoxItem aFmtBox( *((SvxBoxItem*)
+ &pTableBox->GetFrmFmt()->GetAttr( RES_BOX )));
+
+ // versteh ich nich, sven: if (!nDist) nDist = 18; // ca. 0.03 cm
+ if (nDist > 42) // max. 0.7 mm
+ nDist = 42;
+ else
+ if (nDist < MIN_BORDER_DIST)
+ nDist = MIN_BORDER_DIST;
+ aFmtBox.SetDistance(nDist);
+ pTableBox->GetFrmFmt()->SetAttr(aFmtBox);
+}
+
+void SwFltOutDoc::DeleteCell(USHORT nCell /* = USHRT_MAX */)
+{
+ SwTableBox* pTableBox = GetBox(usTableY, nCell);
+ if(pTableBox){
+ SwSelBoxes aSelBoxes;
+ aSelBoxes.Insert( pTableBox );
+ GetDoc().DeleteRowCol(aSelBoxes);
+ usTableX--;
+ }
+}
+
+void SwFltOutDoc::SplitTable()
+{
+ if(!pTable){
+ ASSERT(pTable, "SplitTable ohne Tabelle");
+ return;
+ }
+ SwTableBox* pAktBox = GetBox(usTableY, usTableX);
+ SwTableBox* pSplitBox = GetBox(usTableY - 1, 0);
+ BOOL bOk = 0 != GetDoc().GetNodes().SplitTable(
+ SwNodeIndex( *pSplitBox->GetSttNd() ), FALSE );
+ pTable = &pAktBox->GetSttNd()->FindTableNode()->GetTable();
+ usTableY = 0;
+// GetDoc().Insert(*pPaM, "SplitTable", GetSystemCharSet());
+}
+
+void SwFltOutDoc::EndTable()
+{
+ if (!pTable){
+ ASSERT(pTable, "EndTable ohne Table");
+ return;
+ }
+ // Alle Attribute schliessen, da sonst Attribute
+ // entstehen koennen, die in Flys reinragen
+ rStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ rEndStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+ if (GetDoc().GetRootFrm()){
+ SwTableNode* pTableNode = GetDoc().IsIdxInTbl(
+ pPaM->GetPoint()->nNode);
+ pTableNode->DelFrms();
+ pTableNode->MakeFrms(&pPaM->GetPoint()->nNode);
+ }
+
+ *pPaM->GetPoint() = *pTabSavedPos; // restore Cursor
+ delete pTabSavedPos;
+ pTabSavedPos = 0;
+ ((SwTable*)pTable)->UnlockModify(); // Test, nuetzt nichts gegen Assert
+ pTable = 0;
+ nTableWidth = 0;
+}
+
+BOOL SwFltOutDoc::SeekCell(short nRow, short nCol, BOOL bPam)
+{
+// get structs to table cells
+ const SwTableLines* pTableLines = &pTable->GetTabLines();
+ SwTableLine* pTableLine = (*pTableLines)[usTableY];
+ SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
+ SwTableBox* pTableBox = (*pTableBoxes)[usTableX];
+
+ if ((USHORT)nRow >= pTableLines->Count())
+ {
+ ASSERT((USHORT)nRow >= pTableLines->Count(), "SwFltOutDoc");
+ return FALSE;
+ }
+ pTableLine = (*pTableLines)[nRow];
+ pTableBoxes = &pTableLine->GetTabBoxes();
+ if (nCol >= pTableBoxes->Count())
+ return FALSE;
+ pTableBox = (*pTableBoxes)[nCol];
+ if( !pTableBox->GetSttNd() )
+ {
+ ASSERT(pTableBox->GetSttNd(), "SwFltOutDoc");
+ return FALSE;
+ }
+ if(bPam)
+ {
+ pPaM->GetPoint()->nNode = pTableBox->GetSttIdx() + 1;
+ pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
+//#pragma message(__FILE__ "(?) : Sw's const problem")
+#ifdef DEBUG
+ const SwTxtFmtColl* p = GetDoc().GetDfltTxtFmtColl();
+ p = GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD);
+#endif
+ GetDoc().SetTxtFmtColl(*pPaM,
+ GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD));
+ }
+ return TRUE;
+}
+
+
+//-----------------------------------------------------------------------------
+// Flys in SwFltOutBase
+//-----------------------------------------------------------------------------
+
+SfxItemSet* SwFltOutBase::NewFlyDefaults()
+{
+// Unbedingt noetige Standardwerte setzen ( falls diese Werte nicht
+// spaeter explizit gesetzt werden )
+
+ SfxItemSet* p = new SfxItemSet( GetDoc().GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ SwFmtFrmSize aSz( ATT_VAR_SIZE, MINFLY, MINFLY );
+ // Default: Breite 100% ( = PMW:Auto )
+ aSz.SetWidthPercent( 100 ); // Hoehe: Auto
+ p->Put( aSz );
+ p->Put( SwFmtHoriOrient( 0, HORI_NONE, FRAME ));
+ return p;
+}
+
+BOOL SwFltOutBase::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/,
+ BOOL bAbsolutePos /*= FALSE*/,
+ const SfxItemSet* pMoreAttrs /*= 0*/ )
+{
+ ASSERT(!pMoreAttrs, "SwFltOutBase:BeginFly mit pMoreAttrs" );
+ eFlyAnchor = eAnchor;
+ bFlyAbsPos = bAbsolutePos; // Bloedsinn eigentlich
+ return TRUE;
+}
+
+/*virtual*/ void SwFltOutBase::SetFlyAnchor( RndStdIds eAnchor )
+{
+ if( !IsInFly() ){
+ ASSERT( FALSE, "SetFlyAnchor() ohne Fly" );
+ return;
+ }
+ if( eAnchor == FLY_IN_CNTNT ){
+ ASSERT( FALSE, "SetFlyAnchor( FLY_IN_CNTNT ) nicht implementiert" );
+ return;
+ }
+ SwFmtAnchor& rAnchor = (SwFmtAnchor&)GetFlyFrmAttr( RES_ANCHOR );
+ rAnchor.SetType( eAnchor );
+}
+
+void SwFltOutBase::EndFly()
+{
+ if( bFlyAbsPos ){
+ // hier muessen die absoluten Positionen am Fly noch in
+ // die Writer-Koordinaten umgerechnet werden.
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Flys in SwFltDoc
+//-----------------------------------------------------------------------------
+
+/* virtual */ BOOL SwFltOutDoc::IsInFly()
+{
+ return pFly != 0;
+};
+
+SwFrmFmt* SwFltOutDoc::MakeFly( RndStdIds eAnchor, SfxItemSet* pSet )
+{
+ pFly = (SwFlyFrmFmt*)GetDoc().MakeFlySection( eAnchor, pPaM->GetPoint(),
+ pSet );
+ return pFly;
+}
+
+BOOL SwFltOutDoc::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/,
+ BOOL bAbsolutePos /*= FALSE*/,
+ const SfxItemSet* pMoreAttrs /*= 0*/ )
+
+{
+ SwFltOutBase::BeginFly( eAnchor, bAbsolutePos, 0 );
+ SfxItemSet* pSet = NewFlyDefaults();
+
+// Alle Attribute schliessen, da sonst Attribute entstehen koennen,
+// die in Flys reinragen
+ rStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ rEndStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+// create Fly:
+ ASSERT(pFlySavedPos == NULL, "BeginFly in Fly"); // rekursiv geht noch nicht
+ pFlySavedPos = new SwPosition(*pPaM->GetPoint());
+
+
+ SwFmtAnchor aAnchor( eAnchor, 1 );
+
+// Wenn Fly-Attribute im Style waren, dann jetzt als Defaults reinsetzen
+ if (pMoreAttrs)
+ pSet->Put(*pMoreAttrs);
+
+// dieses NICHT bei Seitengebundenem Fly mit Seiten-NUMMER !
+ aAnchor.SetAnchor(pPaM->GetPoint()); // braucht erstaunlicherweise
+ // den Stack nicht
+// aStack.NewAttr( *pPaM->GetPoint(), SwFltAnchor( pFly ) );
+
+ pSet->Put( aAnchor );
+ SwFrmFmt* pF = MakeFly( eAnchor, pSet );
+ delete pSet;
+
+// set pam in Fly
+ const SwFmtCntnt& rCntnt = pF->GetCntnt();
+ ASSERT( rCntnt.GetCntntIdx(), "Kein Inhalt vorbereitet." );
+ pPaM->GetPoint()->nNode = rCntnt.GetCntntIdx()->GetIndex() + 1;
+ SwCntntNode *pNode = pPaM->GetCntntNode();
+ pPaM->GetPoint()->nContent.Assign( pNode, 0 );
+
+ return TRUE;
+}
+
+/*virtual*/ void SwFltOutDoc::SetFlyFrmAttr(const SfxPoolItem& rAttr)
+{
+ if (pFly)
+ pFly->SetAttr( rAttr );
+ else
+ ASSERT(pFly, "SetFlyAttr ohne Doc-Fly");
+}
+
+/*virtual*/ const SfxPoolItem& SwFltOutDoc::GetFlyFrmAttr(USHORT nWhich)
+{
+ if (pFly){
+ return pFly->GetAttr( nWhich );
+ }else{
+ ASSERT(pFly, "GetFlyAttr ohne Fly");
+ return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
+ }
+}
+
+void SwFltOutDoc::EndFly()
+{
+ if( pTable ){
+ ASSERT( FALSE, "SwFltOutDoc::EndFly() in Table" );
+ return;
+ }
+ // Alle Attribute schliessen, da sonst Attribute
+ // entstehen koennen, die aus Flys rausragen
+ rStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ rEndStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+ *pPaM->GetPoint() = *pFlySavedPos; // restore Cursor
+ delete pFlySavedPos;
+ pFlySavedPos = 0;
+ SwFltOutBase::EndFly();
+ pFly = 0;
+}
+
+//-----------------------------------------------------------------------------
+// Flys in SwFltFormatCollection
+//-----------------------------------------------------------------------------
+/*virtual*/ BOOL SwFltFormatCollection::IsInFly()
+{
+ return bHasFly;
+};
+
+/*virtual*/ void SwFltFormatCollection::SetFlyFrmAttr(const SfxPoolItem& rAttr)
+{
+ if (!pFlyAttrs)
+ pFlyAttrs = new SfxItemSet( GetDoc().GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ pFlyAttrs->Put( rAttr );
+}
+
+/*virtual*/ const SfxPoolItem& SwFltFormatCollection::GetFlyFrmAttr(USHORT nWhich)
+{
+// ASSERT( pFlyAttrs, "GetFlyFrmAttr ohne Coll-FlyAttrs" );
+ if( pFlyAttrs )
+ return pFlyAttrs->Get( nWhich, FALSE );
+ else
+ return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
+}
+
+BOOL SwFltFormatCollection::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/,
+ BOOL bAbsolutePos /*= FALSE*/,
+ const SfxItemSet* pMoreAttrs /*= 0*/ )
+
+{
+ SwFltOutBase::BeginFly( eAnchor, bAbsolutePos, pMoreAttrs );
+ bHasFly = TRUE;
+ return TRUE;
+}
+
+void SwFltFormatCollection::EndFly() // Wird nie aufgerufen
+{
+}
+
+BOOL SwFltFormatCollection::BeginStyleFly( SwFltOutDoc* pOutDoc )
+{
+ ASSERT( pOutDoc, "BeginStyleFly ohne pOutDoc" );
+ ASSERT( pOutDoc && !pOutDoc->IsInFly(), "BeginStyleFly in Fly" );
+ if( pOutDoc && !pOutDoc->IsInFly() )
+ return pOutDoc->BeginFly( eFlyAnchor, bFlyAbsPos, pFlyAttrs );
+ else
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// Flys in SwFltShell
+//-----------------------------------------------------------------------------
+
+BOOL SwFltShell::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/,
+ BOOL bAbsolutePos /*= FALSE*/ )
+
+{
+ if (pOut->IsInFly()){
+ ASSERT(FALSE, "BeginFly in Fly");
+ return FALSE;
+ }
+ if (pOutDoc->IsInTable()){
+ ASSERT(FALSE, "BeginFly in Table");
+ return FALSE;
+ }
+ pOut->BeginFly( eAnchor, bAbsolutePos, pColls[nAktStyle]->GetpFlyAttrs() );
+ eSubMode = Fly;
+ return TRUE;
+}
+
+void SwFltShell::SetFlyXPos( short nXPos,SwRelationOrient eHRel /*= FRAME*/,
+ SwHoriOrient eHAlign /*= HORI_NONE*/ )
+{
+ SetFlyFrmAttr( SwFmtHoriOrient( nXPos, eHAlign, eHRel ) );
+}
+
+void SwFltShell::SetFlyYPos( short nYPos, SwRelationOrient eVRel /*= FRAME*/,
+ SwVertOrient eVAlign /*= VERT_NONE*/ )
+{
+ SetFlyFrmAttr( SwFmtVertOrient( nYPos, eVAlign, eVRel ) );
+}
+
+
+void SwFltShell::EndFly()
+{
+ if (!pOut->IsInFly()){
+ ASSERT(FALSE, "EndFly ohne Fly");
+ return;
+ }
+ if (pOutDoc->IsInTable()){ // Table verschraenkt mit Fly macht keinen Sinn
+ ASSERT(FALSE, "EndFly in Table ( verschraenkt )");
+ EndTable(); // -> Table beenden
+ }
+ pOut->EndFly();
+ eSubMode = None;
+}
+
+//-----------------------------------------------------------------------------
+// Fussnoten
+//-----------------------------------------------------------------------------
+
+void SwFltShell::BeginFootnote()
+{
+ if( pOut->IsInFly() ){ // Passiert z.B. bei Fussnote in Fly
+ ASSERT(FALSE, "Fussnote in Fly nicht erlaubt");
+ return;
+ }
+ if( pOutDoc->IsInTable() ){
+ ASSERT(FALSE, "Fussnote in Table z.Zt. nicht erlaubt");
+ return;
+ }
+
+// Alle Attribute schliessen, da sonst Attribute entstehen koennen,
+// die in Fussnoten reinragen
+ aStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+// aEndStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+// EndStack erstmal nicht zwangs-Schliessen, damit Bookmarks ueber
+// Fussnoten im PMW uebernommen werden
+
+ SwFmtFtn aFtn;
+ GetDoc().Insert(*pPaM, aFtn);
+ ASSERT(pSavedPos == NULL, "SwFltShell");
+ pSavedPos = new SwPosition(*pPaM->GetPoint());
+ pPaM->Move(fnMoveBackward, fnGoCntnt);
+ SwTxtNode* pTxt = pPaM->GetNode()->GetTxtNode();
+ SwTxtAttr* pFN = pTxt->GetTxtAttr(pPaM->GetPoint()->nContent,
+ RES_TXTATR_FTN);
+ if( !pFN ){ // Passiert z.B. bei Fussnote in Fly
+ ASSERT(pFN, "Probleme beim Anlegen des Fussnoten-Textes");
+ return;
+ }
+ const SwNodeIndex* pStartIndex = ((SwTxtFtn*)pFN)->GetStartNode();
+ ASSERT(pStartIndex, "Probleme beim Anlegen des Fussnoten-Textes");
+ pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
+ pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
+ eSubMode = Footnote;
+}
+
+void SwFltShell::EndFootnote()
+{
+ if(!pSavedPos)
+ return;
+ // Alle Attribute schliessen, da sonst Attribute
+ // entstehen koennen, die aus Fussnoten rausragen
+ aStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+// aEndStack.SetAttr( *pPaM->GetPoint(), 0, FALSE );
+// EndStack erstmal nicht zwangs-Schliessen, damit Bookmarks ueber
+// Fussnoten im PMW uebernommen werden
+
+ *pPaM->GetPoint() = *pSavedPos; // restore Cursor
+ delete pSavedPos;
+ pSavedPos = 0;
+}
+
+void SwFltShell::BeginHeader(SwPageDesc* pPD)
+{
+ SwFrmFmt* pFmt = &pCurrentPageDesc->GetMaster(
+ ); //(bUseLeft) ? &pCurrentPageDesc->GetLeft() :
+ SwFrmFmt* pHdFtFmt;
+ pFmt->SetAttr(SwFmtHeader(TRUE));
+ pHdFtFmt = (SwFrmFmt*)pFmt->GetHeader().GetHeaderFmt();
+ const SwNodeIndex* pStartIndex = pHdFtFmt->GetCntnt().GetCntntIdx();
+ if (!pStartIndex)
+ return;
+ ASSERT(pSavedPos == NULL, "SwFltShell");
+ pSavedPos = new SwPosition(*pPaM->GetPoint());
+ pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
+ pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
+ eSubMode = Header;
+}
+
+void SwFltShell::BeginFooter(SwPageDesc* pPD)
+{
+ SwFrmFmt* pFmt = &pCurrentPageDesc->GetMaster(
+ ); //(bUseLeft) ? &pCurrentPageDesc->GetLeft() :
+ SwFrmFmt* pHdFtFmt;
+ pFmt->SetAttr(SwFmtFooter(TRUE));
+ pHdFtFmt = (SwFrmFmt*)pFmt->GetFooter().GetFooterFmt();
+ const SwNodeIndex* pStartIndex = pHdFtFmt->GetCntnt().GetCntntIdx();
+ if (!pStartIndex)
+ return;
+ ASSERT(pSavedPos == NULL, "SwFltShell");
+ pSavedPos = new SwPosition(*pPaM->GetPoint());
+ pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
+ pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
+ eSubMode = Footer;
+}
+
+void SwFltShell::EndHeaderFooter()
+{
+ *pPaM->GetPoint() = *pSavedPos; // restore Cursor
+ delete pSavedPos;
+ pSavedPos = 0;
+}
+
+SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc)
+{
+ if(bStdPD) // keine Neuen PageDescs
+ return pCurrentPageDesc;
+
+ BOOL bFollow = (pFirstPageDesc != 0);
+ SwPageDesc* pNewPD;
+ USHORT nPos;
+ if (bFollow && pFirstPageDesc->GetFollow() != pFirstPageDesc)
+ return pFirstPageDesc; // Fehler: hat schon Follow
+// Erkennung doppelter Namen fehlt noch (Wahrscheinlichkeit
+// fuer dopp. Namen ist gering)
+
+// Namen zusammenbasteln
+ String aNm( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "Konvert ")));
+ if (bFollow)
+ aNm.AppendAscii( "Folge" );
+ aNm += String(GetDoc().GetPageDescCnt());
+ if (!bFollow)
+ nPos = GetDoc().MakePageDesc(aNm, 0);
+ else
+ nPos = GetDoc().MakePageDesc(aNm,
+ pFirstPageDesc);// alles uebernehmen
+ pNewPD = &((SwPageDesc&)GetDoc().GetPageDesc(nPos));
+ if (bFollow)
+ { // Dieser ist der folgende von pPageDesc
+ pFirstPageDesc->SetFollow(pNewPD);
+ pNewPD->SetFollow(pNewPD);
+ }
+ else
+ GetDoc().Insert( *pPaM, SwFmtPageDesc( pNewPD ) );
+ pNewPD->WriteUseOn( // alle Seiten
+ (UseOnPage)(PD_ALL | PD_HEADERSHARE | PD_FOOTERSHARE));
+ return pNewPD;
+}
+
+///////////////////////////////////////////////// SwFltFormatCollection
+SwFltFormatCollection::SwFltFormatCollection(
+ SwDoc& rDoc, RES_POOL_COLLFMT_TYPE nType) :
+ SwFltOutBase(rDoc),
+ pColl(rDoc.GetTxtCollFromPool(nType)),
+ pFlyAttrs( 0 ),
+ bHasFly( FALSE )
+{
+ Reset(); // Default-Attrs loeschen und Auto-Flag
+}
+
+SwFltFormatCollection::SwFltFormatCollection(
+ SwDoc& rDoc, const String& rName ) :
+ SwFltOutBase(rDoc),
+ pFlyAttrs( 0 ),
+ bHasFly( FALSE )
+{
+ pColl = rDoc.MakeTxtFmtColl(rName, (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl());
+ Reset(); // Default-Attrs loeschen und Auto-Flag
+}
+
+#if 0
+SwTxtFmtColl* SwFltFormatCollection::Search(String aName, CharSet eSrc)
+{
+ aName.Convert(eSrc);
+ SwTxtFmtColl* pColl = GetDoc().FindTxtFmtCollByName(aName);
+ if(!pColl)
+ {
+ USHORT n = GetDoc().GetPoolId(aName, GET_POOLID_TXTCOLL);
+ if(USHRT_MAX != n)
+ pColl = GetDoc().GetTxtCollFromPool(n);
+ }
+ return pColl;
+}
+#endif
+void SwFltShell::NextStyle(USHORT nWhich, USHORT nNext)
+{
+ ASSERT(pColls[nWhich], "Next style for noexistent style" );
+ ASSERT(pColls[nNext], "Next style to noexistent style" );
+ if( pColls[nWhich] && pColls[nNext] )
+ pColls[nWhich]->GetColl()->SetNextTxtFmtColl(
+ *pColls[nNext]->GetColl() );
+}
+
+/**********************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww1/fltshell.cxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.57 2000/09/18 16:04:55 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.56 2000/08/30 16:46:59 jp
+ use CharClass instead of international
+
+ Revision 1.55 2000/07/28 15:26:54 khz
+ #73796# don't delete NumRule from Attr but set it into pDoc
+
+ Revision 1.54 2000/07/25 16:58:34 khz
+ #74876# MakeRegion() don't use different Nodes for same Node Index
+
+ Revision 1.53 2000/07/24 16:39:49 khz
+ #75701# set Break or PageDesc item BEHIND TOX if not found before the #0x0C
+
+ Revision 1.52 2000/07/12 11:37:05 khz
+ #76503# SwFltStackEntry.bOld prevents from killing attributes in ww8par.cxx
+
+ Revision 1.51 2000/06/28 08:10:17 khz
+ #70915# new: MoveAttrsToNextTextNode() [see coment in ww8/ww8par.cxx]
+
+ Revision 1.50 2000/06/26 12:53:42 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.49 2000/06/13 11:22:33 os
+ SUPD removed
+
+ Revision 1.48 2000/06/13 09:38:40 os
+ using UCB
+
+ Revision 1.47 2000/05/26 11:41:20 hr
+ SwFltShell& SwFltShell::operator << ( const sal_Unicode c )
+
+ Revision 1.46 2000/05/11 16:06:41 jp
+ Changes for Unicode
+
+ Revision 1.45 2000/02/11 14:39:29 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.44 1999/11/25 17:00:35 khz
+ Task #70133# new method SwFltControlStack::KillUnlockedAttrs()
+
+ Revision 1.43 1999/11/25 16:38:15 khz
+ Task #70133# new method SwFltControlStack::KillUnlockedAttrs()
+
+ Revision 1.42 1999/10/29 12:08:16 khz
+ import new TOX_CONTENT and TOX_INDEX features
+
+ Revision 1.41 1999/10/25 19:35:23 tl
+ ongoing ONE_LINGU implementation
+
+ Revision 1.40 1999/10/08 09:29:10 khz
+ Import Redlining
+
+ Revision 1.39 1999/04/27 12:19:10 KHZ
+ Task #65353# Section ins Doc einfuegen nur mit Parameter bUpdate = FALSE
+
+
+ Rev 1.38 27 Apr 1999 14:19:10 KHZ
+ Task #65353# Section ins Doc einfuegen nur mit Parameter bUpdate = FALSE
+
+ Rev 1.37 12 May 1998 15:52:14 JP
+ rund um Flys/DrawObjs im Doc/FESh umgestellt/optimiert
+
+ Rev 1.36 27 Feb 1998 19:12:42 HJS
+ SH 27.02.98
+
+ Rev 1.33 22 Jan 1998 20:06:44 JP
+ CTOR des SwPaM umgestellt
+
+ Rev 1.32 02 Dec 1997 17:25:56 MA
+ includes
+
+ Rev 1.31 29 Nov 1997 17:37:12 MA
+ includes
+
+ Rev 1.30 17 Nov 1997 09:57:14 JP
+ Umstellung Numerierung
+
+ Rev 1.29 30 Oct 1997 18:17:16 AMA
+ Chg: Kein AutoFlag mehr an Break bzw. PageDesc-Attributen
+
+ Rev 1.28 09 Oct 1997 14:14:32 JP
+ Aenderungen von SH und Umstellung NodeIndex/-Array/BigPtrArray
+
+ Rev 1.27 02 Oct 1997 15:26:00 OM
+ Feldumstellung
+
+ Rev 1.26 12 Sep 1997 11:17:24 OS
+ ITEMID_* definiert
+
+ Rev 1.25 04 Sep 1997 11:18:00 JP
+ include
+
+ Rev 1.24 03 Sep 1997 14:17:32 SH
+ Flys, Tabellen ok, Style-Abhaengigkeiten u.v.a.m
+
+ Rev 1.23 15 Aug 1997 12:50:36 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.22 12 Aug 1997 14:16:32 OS
+ Header-Umstellung
+
+ Rev 1.21 11 Aug 1997 14:07:40 OM
+ Headerfile-Umstellung
+
+ Rev 1.20 11 Aug 1997 12:50:34 SH
+ Flys und einfache Tabellen und Tabulatoren
+
+ Rev 1.19 18 Jul 1997 09:31:36 MA
+ Stand von SH, #41738# GPF und Tabellen etwas besser
+
+ Rev 1.16 11 Jul 1997 14:54:44 SH
+ #40772#, #41459#
+
+ Rev 1.15 16 Jun 1997 13:08:58 MA
+ Stand Micheal Dietrich
+
+ Rev 1.13 27 Apr 1997 16:27:28 SH
+ Sonderwunsch Hypo: Ref-Feld auf Frage-Feld
+
+ Rev 1.12 01 Apr 1997 22:41:04 SH
+ MoveAttrs fuer Hypo-Bookmarks
+
+ Rev 1.11 12 Mar 1997 19:13:06 SH
+ MDT: Progressbar, Pagedesc-Bug, Spalten, Anfang Tabellen u.a.
+
+ Rev 1.10 24 Jan 1997 19:49:32 SH
+ Bookmarks verschraenkt und verschachtelt
+
+ Rev 1.9 22 Jan 1997 12:01:52 JP
+ neu: Tabellen Box Attribute
+
+ Rev 1.8 10 Jan 1997 18:42:00 SH
+ Stabiler und mehr von MDT
+
+ Rev 1.7 28 Nov 1996 18:07:52 SH
+ Schneller Schoener Weiter von MDT
+
+ Rev 1.6 29 Oct 1996 13:11:24 JP
+ am Doc ist das NodesArray nur noch ueber Get..() zugaenglich
+
+ Rev 1.5 24 Oct 1996 17:16:44 JP
+ Optimierung: Find...ByName
+
+ Rev 1.4 09 Oct 1996 13:08:14 JP
+ SwNodes::GoNext/-Prev (-Sect) returnt statt BOOL den gefundenen ContentNode
+
+ Rev 1.3 08 Oct 1996 22:09:18 SH
+ Zusammenfassung Anchor + GrafAnchor
+
+ Rev 1.2 30 Sep 1996 23:20:30 SH
+ neu von MDA
+
+**********************************************************************/
+//)}]
diff --git a/sw/source/filter/ww1/makefile.mk b/sw/source/filter/ww1/makefile.mk
new file mode 100644
index 000000000000..e28458357b73
--- /dev/null
+++ b/sw/source/filter/ww1/makefile.mk
@@ -0,0 +1,136 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=ww1
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(mydebug)" != ""
+CDEFS=$(CDEFS) -Dmydebug
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ fltshell.cxx \
+ w1par.cxx \
+ w1class.cxx \
+ w1filter.cxx \
+ w1sprm.cxx \
+
+
+SLOFILES = \
+ $(SLO)$/w1par.obj \
+ $(SLO)$/w1class.obj \
+ $(SLO)$/w1filter.obj \
+ $(SLO)$/w1sprm.obj \
+ $(SLO)$/fltshell.obj \
+
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+run: alltar
+
+#copy all relevant files to a backupdir
+bak:
+ copy ..\inc\fltshell.hxx backup
+ copy *.?xx backup
+ copy makefile* backup
+ copy vcs.cfg backup
+ copy ..\..\..\dump1\src\dump1.cxx backup
+ copy ..\..\..\dump1\src\makefile backup\makefile.dmp
+ copy ..\..\..\WNTMSCI\bin\makefile backup\makefile.bin
+ copy ..\..\..\UTIL\makefile backup\makefile.utl
+ copy s:\solenv\inc\wnt.mak backup
+
+# remove this filter from libs to avoid annoying effects
+upgrade:
+ attrib -r *.?xx
+ attrib -r makefile.*
+ del ..\..\..\WNMSCI\LIB\ww1.lib
+ del ..\..\..\WNMSCI\DBO\w1*.obj
+ del ..\..\..\WNMSCI\DBO\fltshell.obj
+ del ..\..\..\WNMSCI\MISC
+ lib /nologo /REMOVE:..\..\..\WNTMSCI\obj\fltshell.obj /out:..\..\..\WNTMSCI\LIB\filter.lib ..\..\..\WNTMSCI\LIB\filter.lib
+ lib /nologo /REMOVE:..\..\..\WNTMSCI\obj\w1sprm.obj /out:..\..\..\WNTMSCI\LIB\filter.lib ..\..\..\WNTMSCI\LIB\filter.lib
+ lib /nologo /REMOVE:..\..\..\WNTMSCI\obj\w1filter.obj /out:..\..\..\WNTMSCI\LIB\filter.lib ..\..\..\WNTMSCI\LIB\filter.lib
+ lib /nologo /REMOVE:..\..\..\WNTMSCI\obj\w1class.obj /out:..\..\..\WNTMSCI\LIB\filter.lib ..\..\..\WNTMSCI\LIB\filter.lib
+ lib /nologo /REMOVE:..\..\..\WNTMSCI\obj\w1par.obj /out:..\..\..\WNTMSCI\LIB\filter.lib ..\..\..\WNTMSCI\LIB\filter.lib
+ copy backup\makefile.bin ..\..\..\WNTMSCI\bin\makefile
+ diff backup\makefile.utl ..\..\..\UTIL\makefile
+ diff s:\solenv\inc\wnt.mak backup
+
+zip: bak
+ pkzip c:\temp\ww1 backup\*.*
+
diff --git a/sw/source/filter/ww1/w1class.cxx b/sw/source/filter/ww1/w1class.cxx
new file mode 100644
index 000000000000..ad716d419a01
--- /dev/null
+++ b/sw/source/filter/ww1/w1class.cxx
@@ -0,0 +1,1580 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1class.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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <string.h>
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#ifndef _W1CLASS_HXX
+#include <w1class.hxx>
+#endif
+
+
+/////////////////////////////////////////////////////////////////// Fib
+Ww1Fib::Ww1Fib( SvStream& rStream )
+ : rStream(rStream)
+{
+ bOK = 0 == rStream.Seek(0) &&
+ rStream.Read( &aFib, sizeof( aFib )) == sizeof( aFib );
+}
+
+///////////////////////////////////////////////////////////// PlainText
+sal_Unicode Ww1PlainText::operator [] ( ULONG ulOffset )
+{
+ DBG_ASSERT( ulOffset<Count(), "Ww1PlainText" );
+ sal_Unicode cRet;
+ sal_Char cRead;
+ if( rFib.GetStream().Seek( ulFilePos + ulOffset ) == ulFilePos+ulOffset &&
+ rFib.GetStream().Read( &cRead, sizeof( cRead ) ) == sizeof( cRead ) )
+ {
+ cRet = ByteString::ConvertToUnicode( cRead, RTL_TEXTENCODING_MS_1252 );
+ }
+ else
+ cRet = ' ';
+ return cRet;
+}
+
+String Ww1PlainText::GetText( ULONG ulOffset, ULONG nLen ) const
+{
+ String sRet;
+ ByteString aStr;
+ DBG_ASSERT(ulOffset+nLen<Count(), "Ww1PlainText");
+ if( rFib.GetStream().Seek(ulFilePos+ulOffset) == ulFilePos+ulOffset &&
+ rFib.GetStream().Read( aStr.AllocBuffer( nLen ), nLen ) == nLen )
+ sRet = String( aStr, RTL_TEXTENCODING_MS_1252 );
+ return sRet;
+}
+
+///////////////////////////////////////////////////////////////// Style
+Ww1Style::Ww1Style()
+ : stcBase(0),
+ stcNext(0),
+ bUsed(FALSE),
+ pParent(NULL),
+ pPapx(NULL)
+{
+}
+
+Ww1Style::~Ww1Style()
+{
+ delete pPapx;
+}
+
+void Ww1Style::SetDefaults(BYTE stc)
+{
+ if( 222 == stc )
+ {
+ stcBase = 222;
+ stcNext = 222;
+ aChpx.hpsSet(20);
+ }
+}
+
+USHORT Ww1Style::ReadName( BYTE*&p, USHORT& rnCountBytes, USHORT stc )
+{
+ BYTE nCountBytes = SVBT8ToByte(p);
+ p++;
+ rnCountBytes--;
+ if( !nCountBytes ) // default
+ {
+ static sal_Char* __READONLY_DATA names[] =
+ {
+ "W1 Null", //222
+ "W1 Annotation reference", //223
+ "W1 Annotation text", //224
+ "W1 Table of contents 8", //225
+ "W1 Table of contents 7", //226
+ "W1 Table of contents 6", //227
+ "W1 Table of contents 5", //228
+ "W1 Table of contents 4", //229
+ "W1 Table of contents 3", //230
+ "W1 Table of contents 2", //231
+ "W1 Table of contents 1", //232
+ "W1 Index 7", //233
+ "W1 Index 6", //234
+ "W1 Index 5", //235
+ "W1 Index 4", //236
+ "W1 Index 3", //237
+ "W1 Index 2", //238
+ "W1 Index 1", //239
+ "W1 Line number", //240
+ "W1 Index heading", //241
+ "W1 Footer", //242
+ "W1 Header", //243
+ "W1 Footnote reference", //244
+ "W1 Footnote text", //245
+ "W1 Heading 9", //246
+ "W1 Heading 8", //247
+ "W1 Heading 7", //248
+ "W1 Heading 6", //249
+ "W1 Heading 5", //250
+ "W1 Heading 4", //251
+ "W1 Heading 3", //252
+ "W1 Heading 2", //253
+ "W1 Heading 1", //254
+ "W1 Normal indent" //255
+ };//256
+
+ const sal_Char* pStr;
+ if( !stc )
+ pStr = "W1 Normal";
+ else if( stc - 222 >= sizeof( names ) / sizeof( *names ))
+ pStr = "?";
+ else
+ pStr = names[ stc-222 ];
+ SetName( String( pStr, RTL_TEXTENCODING_MS_1252 ));
+ }
+ else if( 255 > nCountBytes ) // unused
+ {
+ SetName( String( (sal_Char*)p, nCountBytes, RTL_TEXTENCODING_MS_1252 ));
+ p += nCountBytes;
+ DBG_ASSERT(rnCountBytes>=nCountBytes, "Ww1Style");
+ rnCountBytes -= nCountBytes;
+ }
+ return 0;
+}
+
+USHORT Ww1Style::ReadChpx( BYTE*&p, USHORT& rnCountBytes )
+{
+ USHORT nCountBytes = SVBT8ToByte(p);
+ p++;
+ rnCountBytes--;
+ if (nCountBytes != 255 // unused
+ && nCountBytes != 0) // default
+ {
+ if (nCountBytes > sizeof(aChpx))
+ nCountBytes = sizeof(aChpx);
+ memcpy( &aChpx, p, nCountBytes );
+ p += nCountBytes;
+ DBG_ASSERT(rnCountBytes>=nCountBytes, "Ww1Style");
+ rnCountBytes -= nCountBytes;
+ }
+ return 0;
+}
+
+USHORT Ww1Style::ReadPapx(BYTE*&p, USHORT& rnCountBytes)
+{
+ USHORT nCountBytes = SVBT8ToByte(p);
+ p++;
+ rnCountBytes--;
+ if (nCountBytes != 255)
+ {
+ pPapx = new Ww1SprmPapx(p, nCountBytes);
+ p += nCountBytes;
+ DBG_ASSERT(rnCountBytes>=nCountBytes, "Ww1Style");
+ rnCountBytes -= nCountBytes;
+ }
+ else
+ pPapx = new Ww1SprmPapx(p, 0);
+ return 0;
+}
+
+USHORT Ww1Style::ReadEstcp(BYTE*&p, USHORT& rnCountBytes)
+{
+ stcNext = SVBT8ToByte(p);
+ p++;
+ rnCountBytes--;
+ stcBase = SVBT8ToByte(p);
+ p++;
+ DBG_ASSERT(rnCountBytes>0, "Ww1Style");
+ rnCountBytes--;
+ return 0;
+}
+
+//////////////////////////////////////////////////////////// StyleSheet
+Ww1StyleSheet::Ww1StyleSheet(Ww1Fib& rFib)
+ : cstcStd(0),
+ rFib(rFib),
+ bOK(FALSE)
+{
+ USHORT cbStshf = rFib.GetFIB().cbStshfGet();
+ DBG_ASSERT(cbStshf>=17, "Ww1StyleSheet");
+ for (USHORT stc=0;stc<Count();stc++)
+ {
+ aStyles[stc].SetParent(this);
+ aStyles[stc].SetDefaults((BYTE)stc);
+ }
+ BYTE* del = NULL;
+ if (rFib.GetStream().Seek(rFib.GetFIB().fcStshfGet())
+ == (ULONG)rFib.GetFIB().fcStshfGet()
+ && (del = new BYTE[cbStshf]) != NULL
+ && rFib.GetStream().Read(del, cbStshf) == (ULONG)cbStshf)
+ {
+ BYTE* p = del;
+ cstcStd = SVBT16ToShort(p);
+ p += sizeof(SVBT16);
+ cbStshf -= sizeof(SVBT16);
+ ReadNames(p, cbStshf);
+ ReadChpx(p, cbStshf);
+ ReadPapx(p, cbStshf);
+ ReadEstcp(p, cbStshf);
+ DBG_ASSERT(cbStshf==0, "Ww1StyleSheet");
+ bOK = cbStshf == 0;
+ }
+ delete del;
+}
+
+USHORT Ww1StyleSheet::ReadNames( BYTE*& p, USHORT& rnCountBytes )
+{
+ USHORT nCountBytes = SVBT16ToShort(p);
+ p += sizeof(SVBT16);
+ DBG_ASSERT(rnCountBytes>=nCountBytes, "Ww1StyleSheet");
+ rnCountBytes -= nCountBytes;
+ nCountBytes -= sizeof(SVBT16);
+ USHORT stcp = 0;
+ while (nCountBytes > 0)
+ {
+ USHORT stc = (stcp - cstcStd) & 255;
+ aStyles[stc].ReadName(p, nCountBytes, stc);
+ stcp++;
+ }
+ DBG_ASSERT(nCountBytes==0, "Ww1StyleSheet");
+ return 0;
+}
+
+USHORT Ww1StyleSheet::ReadChpx(BYTE*& p, USHORT& rnCountBytes)
+{
+ USHORT nCountBytes = SVBT16ToShort(p);
+ p += sizeof(SVBT16);
+ DBG_ASSERT(rnCountBytes>=nCountBytes, "Ww1StyleSheet");
+ rnCountBytes -= nCountBytes;
+ nCountBytes -= sizeof(SVBT16);
+ USHORT stcp = 0;
+ while (nCountBytes > 0)
+ {
+ USHORT stc = (stcp - cstcStd) & 255;
+ aStyles[stc].ReadChpx(p, nCountBytes);
+ stcp++;
+ }
+ DBG_ASSERT(nCountBytes == 0, "Ww1StyleSheet");
+ return 0;
+}
+
+USHORT Ww1StyleSheet::ReadPapx(BYTE*& p, USHORT& rnCountBytes)
+{
+ USHORT nCountBytes = SVBT16ToShort(p);
+ p += sizeof(SVBT16);
+ DBG_ASSERT(rnCountBytes>=nCountBytes, "Ww1StyleSheet");
+ rnCountBytes -= nCountBytes;
+ nCountBytes -= sizeof(SVBT16);
+ USHORT stcp = 0;
+ while (nCountBytes > 0)
+ {
+ USHORT stc = (stcp - cstcStd) & 255;
+ aStyles[stc].ReadPapx(p, nCountBytes);
+ stcp++;
+ }
+ DBG_ASSERT(nCountBytes == 0, "Ww1StyleSheet");
+ return 0;
+}
+
+USHORT Ww1StyleSheet::ReadEstcp(BYTE*& p, USHORT& rnCountBytes)
+{
+ USHORT iMac = SVBT16ToShort(p);
+ p += sizeof(SVBT16);
+ DBG_ASSERT(rnCountBytes>=sizeof(SVBT16), "Ww1StyleSheet");
+ rnCountBytes -= sizeof(SVBT16);
+ for (USHORT stcp=0;stcp<iMac;stcp++)
+ {
+ USHORT stc = (stcp - cstcStd) & 255;
+ aStyles[stc].ReadEstcp(p, rnCountBytes);
+ }
+ DBG_ASSERT(rnCountBytes==0, "Ww1StyleSheet");
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////// Fonts
+
+Ww1Fonts::Ww1Fonts(Ww1Fib& rFib, ULONG nFieldFlgs)
+ : nMax(0), rFib(rFib), pFontA(0), nFieldFlags( nFieldFlgs ), bOK(FALSE)
+{
+ if(rFib.GetFIB().cbSttbfffnGet() > 2 ) // ueberhaupt fonts?
+ {
+ SVBT16 nCountBytes;
+ DBG_ASSERT(rFib.GetFIB().cbSttbfffnGet() > sizeof(nCountBytes), "Ww1Fonts");
+ if (rFib.GetStream().Seek(rFib.GetFIB().fcSttbfffnGet())
+ == (ULONG)rFib.GetFIB().fcSttbfffnGet())
+ if (rFib.GetStream().Read(nCountBytes, sizeof(nCountBytes))
+ == sizeof(nCountBytes)) // Laenge steht hier nochmal
+ {
+ DBG_ASSERT(SVBT16ToShort(nCountBytes)
+ == rFib.GetFIB().cbSttbfffnGet(), "redundant-size missmatch");
+ // hoffentlich sind sie immer gleich
+ W1_FFN* pA = (W1_FFN*)new char[rFib.GetFIB().cbSttbfffnGet()
+ - sizeof(nCountBytes)]; // Alloziere Font-Array
+ //~ Ww1: new-NULL
+ if (rFib.GetStream().Read(pA, rFib.GetFIB().cbSttbfffnGet()
+ - sizeof(nCountBytes)) == (ULONG)rFib.GetFIB().cbSttbfffnGet()
+ - sizeof(nCountBytes)) // lese alle Fonts
+ {} //nothing
+
+ long nLeft = rFib.GetFIB().cbSttbfffnGet()
+ - sizeof(nCountBytes); // Zaehle, wieviele Fonts enthalten
+ W1_FFN* p = pA;
+ while (1)
+ {
+ USHORT nNextSiz;
+ nNextSiz = p->cbFfnM1Get() + 1;
+ if(nNextSiz > nLeft)
+ break;
+ nMax++;
+ nLeft -= nNextSiz;
+ if(nLeft < 1) // naechste Laenge muss gelesen werden koennen
+ break;
+ p = (W1_FFN *)(((char*)p) + nNextSiz);
+ }
+ if (nMax)
+ {
+ pFontA = new W1_FFN*[nMax]; // alloziere Index-Array
+ //~ Ww1: new-NULL
+ pFontA[0] = pA; // fuelle Index-Array
+ USHORT i;
+ for(i=1, p=pA; i<nMax; i++)
+ {
+ p = (W1_FFN*)(((char*)p) + p->cbFfnM1Get() + 1);
+ pFontA[i] = p;
+ }
+ }
+ else
+ pFontA = 0; // Keine Eintraege -> kein Array
+ }
+ }
+ bOK = TRUE;
+}
+
+W1_FFN* Ww1Fonts::GetFFN(USHORT nNum)
+{
+ W1_FFN* pRet = NULL;
+ if (pFontA)
+ if (nNum < nMax)
+ pRet = pFontA[nNum];
+ return pRet;
+}
+
+/////////////////////////////////////////////////////////////////// DOP
+Ww1Dop::Ww1Dop(Ww1Fib& rFib)
+ : rFib(rFib)
+{
+ long nRead;
+ memset(&aDop, 0, sizeof(aDop)); // set defaults
+ if(rFib.GetFIB().cbDopGet() >= sizeof(aDop))
+ nRead = sizeof(aDop);
+ else
+ nRead = rFib.GetFIB().cbDopGet();
+ bOK = rFib.GetStream().Seek(rFib.GetFIB().fcDopGet()) ==
+ (ULONG)rFib.GetFIB().fcDopGet() &&
+ rFib.GetStream().Read(&aDop, nRead) == (ULONG)nRead;
+}
+
+/////////////////////////////////////////////////////////////// Picture
+Ww1Picture::Ww1Picture(SvStream& rStream, ULONG ulFilePos)
+ : pPic(NULL), bOK(FALSE)
+{
+ ulFilePos &= 0xffffff; //~ ww1: warum auch immer - im highbyte steht eine 5?!?!
+ SVBT32 lcb;
+ if (rStream.Seek(ulFilePos) == (ULONG)ulFilePos)
+ if (rStream.Read(&lcb, sizeof(lcb)) == (ULONG)sizeof(lcb))
+ if (sizeof(int)>=4 || SVBT32ToLong(lcb) < 0x8000) //~ mdt: 64K & 16bit
+ if ((pPic = (W1_PIC*)(new BYTE[SVBT32ToLong(lcb)])) != NULL)
+ if (rStream.Seek(ulFilePos) == (ULONG)ulFilePos)
+ if (rStream.Read(pPic, SVBT32ToLong(lcb)) == (ULONG)SVBT32ToLong(lcb))
+ {
+ DBG_ASSERT(pPic->cbHeaderGet()==sizeof(*pPic)-sizeof(pPic->rgb), "Ww1Picture");
+ bOK = TRUE;
+ }
+}
+
+////////////////////////////////////////////////////////////////// Sprm
+Ww1Sprm::Ww1Sprm(BYTE* x, USHORT nCountBytes)
+ : p(NULL),
+ nCountBytes(nCountBytes),
+ bOK(FALSE),
+ pArr(NULL),
+ count(0)
+{
+ if (nCountBytes == 0)
+ bOK = TRUE;
+ else
+ if ((p = new BYTE[nCountBytes]) != NULL)
+ {
+ memcpy(p, x, nCountBytes);
+ if (ReCalc())
+ bOK = TRUE;
+ }
+}
+
+Ww1Sprm::Ww1Sprm(SvStream& rStream, ULONG ulFilePos)
+ : p(NULL),
+ nCountBytes(0),
+ bOK(FALSE),
+ pArr(NULL),
+ count(0)
+{
+ SVBT8 x;
+ ByteToSVBT8(0, x);
+ if (rStream.Seek(ulFilePos) == (ULONG)ulFilePos)
+ if (rStream.Read(&x, sizeof(x)) == (ULONG)sizeof(x))
+ if ((nCountBytes = SVBT8ToByte(x)) == 255
+ || !nCountBytes
+ || (p = new BYTE[nCountBytes]) != NULL)
+ if (nCountBytes == 255
+ || !nCountBytes
+ || rStream.Read(p, nCountBytes) == (ULONG)nCountBytes)
+ if (ReCalc())
+ bOK = TRUE;
+}
+
+Ww1Sprm::~Ww1Sprm()
+{
+ delete pArr;
+ delete p;
+}
+
+USHORT Ww1SingleSprm::Size(BYTE* pSprm)
+{
+ return nCountBytes;
+}
+
+USHORT Ww1SingleSprmTab::Size(BYTE* pSprm) // Doc 24/25, Fastsave-Sprm
+{
+ DBG_ASSERT(nCountBytes==0, "Ww1SingleSprmTab");
+ USHORT nRet = sizeof(SVBT8);
+ USHORT nSize = SVBT8ToByte(pSprm);
+ if (nSize != 255)
+ nRet += nSize;
+ else
+ {
+ USHORT nDel = SVBT8ToByte(pSprm+1) * 4;
+ USHORT nIns = SVBT8ToByte(pSprm + 3 + nDel) * 3;
+ nRet += nDel + nIns;
+ }
+ DBG_ASSERT(nRet <= 354, "Ww1SingleSprmTab");
+ if (nRet > 354)
+ nRet = 0;
+ return nRet;
+}
+
+USHORT Ww1SingleSprmByteSized::Size(BYTE* pSprm)
+{
+ USHORT nRet;
+ nRet = SVBT8ToByte(pSprm);
+ nRet += sizeof(SVBT8); // var. l. byte-size
+// pSprm += sizeof(SVBT8); // var. l. byte-size
+ nRet += nCountBytes;
+ return nRet;
+}
+
+USHORT Ww1SingleSprmWordSized::Size(BYTE* pSprm)
+{
+ USHORT nRet;
+ nRet = SVBT16ToShort(pSprm);
+ nRet += sizeof(SVBT16); // var. l. word-size
+// pSprm += sizeof(SVBT16); // var. l. word-size
+ nRet += nCountBytes;
+ return nRet;
+}
+
+static BYTE nLast = 0;
+static BYTE nCurrent = 0;
+USHORT Ww1Sprm::GetSize(BYTE nId, BYTE* pSprm)
+{
+ DBG_ASSERT(nId<sizeof(aTab)/sizeof(*aTab), "Ww1Sprm");
+ USHORT nL = 0;
+ nL = GetTab(nId).Size(pSprm);
+nLast = nCurrent;
+nCurrent = nId;
+ return nL;
+}
+
+BOOL Ww1Sprm::Fill(USHORT index, BYTE& nId, USHORT& nL, BYTE*& pSprm)
+{
+ DBG_ASSERT(nId<sizeof(aTab)/sizeof(*aTab), "Ww1Sprm");
+ DBG_ASSERT(index < Count(), "Ww1Sprm");
+ pSprm = p + pArr[index];
+ nId = SVBT8ToByte(pSprm);
+ pSprm++;
+ nL = GetTab(nId).Size(pSprm);
+ return TRUE;
+}
+
+BOOL Ww1Sprm::ReCalc()
+{
+ BOOL bRet = TRUE;
+ delete pArr;
+ pArr = NULL;
+ count = 0;
+ if (nCountBytes != 255) // not unused?
+ {
+ USHORT cbsik = nCountBytes;
+ BYTE* psik = p;
+ while (cbsik > 0)
+ {
+ USHORT iLen = GetSizeBrutto(psik);
+ DBG_ASSERT(iLen<=cbsik, "Ww1Sprm");
+ if (iLen > cbsik)
+ cbsik = 0; // ignore the rest: we are wrong...
+ else
+ {
+ psik += iLen;
+ cbsik -= iLen;
+ count++;
+ }
+ }
+ if (bRet
+ && (pArr = new USHORT[count]) != NULL)
+ {
+ cbsik = nCountBytes;
+ USHORT offset = 0;
+ USHORT current = 0;
+ psik = p;
+ while (current<count)
+ {
+ pArr[current++] = offset;
+ USHORT iLen = GetSizeBrutto(psik);
+ psik += iLen;
+ if (iLen > cbsik)
+ cbsik = 0;
+ else
+ cbsik -= iLen;
+ offset += iLen;
+ }
+
+ }
+ else
+ count = 0;
+ }
+ return bRet;
+}
+
+Ww1SingleSprm* Ww1Sprm::aTab[256];
+
+void Ww1Sprm::DeinitTab()
+{
+ for (int i=0;i<sizeof(aTab)/sizeof(*aTab);i++)
+ {
+ delete aTab[i];
+ aTab[i] = NULL;
+ }
+}
+
+void Ww1Sprm::InitTab()
+{
+ int i = 0;
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 0
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 1
+ aTab[i++] = new Ww1SingleSprmByte("sprmPStc"); // 2 pap.istd (style code)
+ aTab[i++] = new Ww1SingleSprmByteSized(0, "sprmPIstdPermute"); // 3 pap.istd permutation
+ aTab[i++] = new Ww1SingleSprmByte("sprmPIncLevel"); // 4 pap.istddifference
+ aTab[i++] = new Ww1SingleSprmPJc("sprmPJc"); // 5 pap.jc (justification)
+ aTab[i++] = new Ww1SingleSprmBool("sprmPFSideBySide"); // 6 pap.fSideBySide
+ aTab[i++] = new Ww1SingleSprmPFKeep("sprmPFKeep"); // 7 pap.fKeep
+ aTab[i++] = new Ww1SingleSprmPFKeepFollow("sprmPFKeepFollow"); // 8 pap.fKeepFollow
+ aTab[i++] = new Ww1SingleSprmPPageBreakBefore("sprmPPageBreakBefore"); // 9 pap.fPageBreakBefore
+ aTab[i++] = new Ww1SingleSprmByte("sprmPBrcl"); // 10 pap.brcl
+ aTab[i++] = new Ww1SingleSprmByte("sprmPBrcp"); // 11 pap.brcp
+ aTab[i++] = new Ww1SingleSprmByteSized(0, "sprmPAnld"); // 12 pap.anld (ANLD structure)
+ aTab[i++] = new Ww1SingleSprmByte("sprmPNLvlAnm"); // 13 pap.nLvlAnm nn
+ aTab[i++] = new Ww1SingleSprmBool("sprmPFNoLineNumb"); // 14 ap.fNoLnn
+ aTab[i++] = new Ww1SingleSprmPChgTabsPapx("sprmPChgTabsPapx"); // 15 pap.itbdMac, ...
+ aTab[i++] = new Ww1SingleSprmPDxaRight("sprmPDxaRight"); // 16 pap.dxaRight
+ aTab[i++] = new Ww1SingleSprmPDxaLeft("sprmPDxaLeft"); // 17 pap.dxaLeft
+ aTab[i++] = new Ww1SingleSprmWord("sprmPNest"); // 18 pap.dxaNest
+ aTab[i++] = new Ww1SingleSprmPDxaLeft1("sprmPDxaLeft1"); // 19 pap.dxaLeft1
+ aTab[i++] = new Ww1SingleSprmPDyaLine("sprmPDyaLine"); // 20 pap.lspd an LSPD
+ aTab[i++] = new Ww1SingleSprmPDyaBefore("sprmPDyaBefore"); // 21 pap.dyaBefore
+ aTab[i++] = new Ww1SingleSprmPDyaAfter("sprmPDyaAfter"); // 22 pap.dyaAfter
+ aTab[i++] = new Ww1SingleSprmTab(0, "?"); // 23 pap.itbdMac, pap.rgdxaTab
+ aTab[i++] = new Ww1SingleSprmPFInTable("sprmPFInTable"); // 24 pap.fInTable
+ aTab[i++] = new Ww1SingleSprmPTtp("sprmPTtp"); // 25 pap.fTtp
+ aTab[i++] = new Ww1SingleSprmPDxaAbs("sprmPDxaAbs"); // 26 pap.dxaAbs
+ aTab[i++] = new Ww1SingleSprmPDyaAbs("sprmPDyaAbs"); // 27 pap.dyaAbs
+ aTab[i++] = new Ww1SingleSprmPDxaWidth("sprmPDxaWidth"); // 28 pap.dxaWidth
+ aTab[i++] = new Ww1SingleSprmPpc("sprmPPc"); // 29 pap.pcHorz, pap.pcVert
+ aTab[i++] = new Ww1SingleSprmPBrc10(BRC_TOP, "sprmPBrcTop10"); // 30 pap.brcTop BRC10
+ aTab[i++] = new Ww1SingleSprmPBrc10(BRC_LEFT, "sprmPBrcLeft10"); // 31 pap.brcLeft BRC10
+ aTab[i++] = new Ww1SingleSprmPBrc10(BRC_BOTTOM, "sprmPBrcBottom10"); // 32 pap.brcBottom BRC10
+ aTab[i++] = new Ww1SingleSprmPBrc10(BRC_RIGHT, "sprmPBrcRight10"); // 33 pap.brcRight BRC10
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcBetween10"); // 34 pap.brcBetween BRC10
+ aTab[i++] = new Ww1SingleSprmPBrc10(BRC_LEFT, "sprmPBrcBar10"); // 35 pap.brcBar BRC10
+ aTab[i++] = new Ww1SingleSprmPFromText("sprmPFromText10"); // 36 pap.dxaFromText dxa
+ aTab[i++] = new Ww1SingleSprmByte("sprmPWr"); // 37 pap.wr wr
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcTop"); // 38 pap.brcTop BRC
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcLeft"); // 39 pap.brcLeft BRC
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcBottom"); // 40 pap.brcBottom BRC
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcRight"); // 41 pap.brcRight BRC
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcBetween"); // 42 pap.brcBetween BRC
+ aTab[i++] = new Ww1SingleSprmWord("sprmPBrcBar"); // 43 pap.brcBar BRC word
+ aTab[i++] = new Ww1SingleSprmBool("sprmPFNoAutoHyph"); // 44 pap.fNoAutoHyph
+ aTab[i++] = new Ww1SingleSprmWord("sprmPWHeightAbs"); // 45 pap.wHeightAbs w
+ aTab[i++] = new Ww1SingleSprmWord("sprmPDcs"); // 46 pap.dcs DCS
+ aTab[i++] = new Ww1SingleSprmWord("sprmPShd"); // 47 pap.shd SHD
+ aTab[i++] = new Ww1SingleSprmWord("sprmPDyaFromText"); // 48 pap.dyaFromText dya
+ aTab[i++] = new Ww1SingleSprmWord("sprmPDxaFromText"); // 49 pap.dxaFromText dxa
+ aTab[i++] = new Ww1SingleSprmBool("sprmPFLocked"); // 50 pap.fLocked 0 or 1 byte
+ aTab[i++] = new Ww1SingleSprmBool("sprmPFWidowControl"); // 51 pap.fWidowControl 0 or 1 byte
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 52 sprmPRuler ?
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 53
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 54
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 55
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 56
+ aTab[i++] = new Ww1SingleSprmByteSized(0, "sprmCDefault"); // 57 whole CHP (see below) none variable length
+ aTab[i++] = new Ww1SingleSprm(0, "sprmCPlain"); // 58 whole CHP (see below) none 0
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 59
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFBold"); // 60 chp.fBold 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFItalic"); // 61 chp.fItalic 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFStrike"); // 62 chp.fStrike 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFOutline"); // 63 chp.fOutline 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFShadow"); // 64 chp.fShadow 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFSmallCaps"); // 65 chp.fSmallCaps 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFCaps"); // 66 chp.fCaps 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprm4State("sprmCFVanish"); // 67 chp.fVanish 0,1, 128, or 129 (see below) byte
+ aTab[i++] = new Ww1SingleSprmWord("sprmCFtc"); // 68 chp.ftc ftc word
+ aTab[i++] = new Ww1SingleSprmByte("sprmCKul"); // 69 chp.kul kul byte
+ aTab[i++] = new Ww1SingleSprm(3, "sprmCSizePos"); // 70 chp.hps, chp.hpsPos (see below) 3 bytes
+ aTab[i++] = new Ww1SingleSprmWord("sprmCDxaSpace"); // 71 chp.dxaSpace dxa word
+ aTab[i++] = new Ww1SingleSprmWord("//"); // 72 //
+ aTab[i++] = new Ww1SingleSprmByte("sprmCIco"); // 73 chp.ico ico byte
+ aTab[i++] = new Ww1SingleSprmByte("sprmCHps"); // 74 chp.hps hps !byte!
+ aTab[i++] = new Ww1SingleSprmByte("sprmCHpsInc"); // 75 chp.hps (see below) byte
+ aTab[i++] = new Ww1SingleSprmWord("sprmCHpsPos"); // 76 chp.hpsPos hps !word!
+ aTab[i++] = new Ww1SingleSprmByte("sprmCHpsPosAdj"); // 77 chp.hpsPos hps (see below) byte
+ aTab[i++] = new Ww1SingleSprmByteSized(0, "?"); // 78 ?chp.fBold, chp.fItalic, chp.fSmallCaps, ...
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 79
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 80
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 81
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 82
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 83
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 84
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 85
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 86
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 87
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 88
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 89
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 90
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 91
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 92
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 93
+ aTab[i++] = new Ww1SingleSprmByte("sprmPicBrcl"); // 94 pic.brcl brcl (see PIC structure definition) byte
+ aTab[i++] = new Ww1SingleSprmByteSized(0, "sprmPicScale"); // 95 pic.mx, pic.my, pic.dxaCropleft,
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 96
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 97
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 99
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 99
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 100
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 101
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 102
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 103
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 104
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 105
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 106
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 107
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 108
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 109
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 110
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 111
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 112
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 113
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 114
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 115
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 116
+ aTab[i++] = new Ww1SingleSprmByte("sprmSBkc"); // 117 sep.bkc bkc byte
+ aTab[i++] = new Ww1SingleSprmBool("sprmSFTitlePage"); // 118 sep.fTitlePage 0 or 1 byte
+ aTab[i++] = new Ww1SingleSprmSColumns("sprmSCcolumns"); // 119 sep.ccolM1 # of cols - 1 word
+ aTab[i++] = new Ww1SingleSprmWord("sprmSDxaColumns"); // 120 sep.dxaColumns dxa word
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 121 sep.fAutoPgn obsolete byte
+ aTab[i++] = new Ww1SingleSprmByte("sprmSNfcPgn"); // 122 sep.nfcPgn nfc byte
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 123 sep.dyaPgn dya short
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 124 sep.dxaPgn dya short
+ aTab[i++] = new Ww1SingleSprmBool("sprmSFPgnRestart"); // 125 sep.fPgnRestart 0 or 1 byte
+ aTab[i++] = new Ww1SingleSprmBool("sprmSFEndnote"); // 126 sep.fEndnote 0 or 1 byte
+ aTab[i++] = new Ww1SingleSprmByte("sprmSLnc"); // 127 sep.lnc lnc byte
+ aTab[i++] = new Ww1SingleSprmSGprfIhdt("sprmSGprfIhdt"); // 128 sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
+ aTab[i++] = new Ww1SingleSprmWord("sprmSNLnnMod"); // 129 sep.nLnnMod non-neg int. word
+ aTab[i++] = new Ww1SingleSprmWord("sprmSDxaLnn"); // 130 sep.dxaLnn dxa word
+ aTab[i++] = new Ww1SingleSprmWord("sprmSDyaHdrTop"); // 131 sep.dyaHdrTop dya word
+ aTab[i++] = new Ww1SingleSprmWord("sprmSDyaHdrBottom"); // 132 sep.dyaHdrBottom dya word
+ aTab[i++] = new Ww1SingleSprmBool("sprmSLBetween"); // 133 sep.fLBetween 0 or 1 byte
+ aTab[i++] = new Ww1SingleSprmByte("sprmSVjc"); // 134 sep.vjc vjc byte
+ aTab[i++] = new Ww1SingleSprmWord("sprmSLnnMin"); // 135 sep.lnnMin lnn word
+ aTab[i++] = new Ww1SingleSprmWord("sprmSPgnStart"); // 136 sep.pgnStart pgn word
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 137
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 138
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 139
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 140
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 141
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 142
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 143
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 144
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 145
+ aTab[i++] = new Ww1SingleSprmWord("sprmTJc"); // 146 tap.jc jc word (low order byte is significant)
+ aTab[i++] = new Ww1SingleSprmWord("sprmTDxaLeft"); // 147 tap.rgdxaCenter (see below) dxa word
+ aTab[i++] = new Ww1SingleSprmWord("sprmTDxaGapHalf"); // 148 tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 149 ???tap.fCantSplit 1 or 0 byte
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 150 ???tap.fTableHeader 1 or 0 byte
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 151 ???tap.rgbrcTable complex(see below) 12 bytes
+ aTab[i++] = new Ww1SingleSprmTDefTable10("sprmTDefTable10"); // 152 tap.rgdxaCenter, tap.rgtc complex (see below) variable length
+ aTab[i++] = new Ww1SingleSprmWord("sprmTDyaRowHeight"); // 153 tap.dyaRowHeight dya word
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 154 ???tap.rgtc complex (see below)
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 155 ???tap.rgshd complex (see below)
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 156 ???tap.tlp TLP 4 bytes
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 157 ???tap.rgtc[].rgbrc complex (see below) 5 bytes
+ aTab[i++] = new Ww1SingleSprm(4, "sprmTInsert"); // 158 tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
+ aTab[i++] = new Ww1SingleSprmWord("sprmTDelete"); // 159 tap.rgdxaCenter, tap.rgtc complex (see below) word
+ aTab[i++] = new Ww1SingleSprm(4, "sprmTDxaCol"); // 160 tap.rgdxaCenter complex (see below) 4 bytes
+ aTab[i++] = new Ww1SingleSprmWord("sprmTMerge"); // 161 tap.fFirstMerged, tap.fMerged complex (see below) word
+ aTab[i++] = new Ww1SingleSprmWord("sprmTSplit"); // 162 tap.fFirstMerged, tap.fMerged complex (see below) word
+ aTab[i++] = new Ww1SingleSprm(5, "sprmTSetBrc10"); // 163 tap.rgtc[].rgbrc complex (see below) 5 bytes
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 164
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 165
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 166
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 167
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 168
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 169
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 170
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 171
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 172
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 173
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 174
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 175
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 176
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 177
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 178
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 179
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 180
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 181
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 182
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 183
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 184
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 185
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 186
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 187
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 188
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 189
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 190
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 191
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 192
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 193
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 194
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 195
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 196
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 197
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 198
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 199
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 200
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 201
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 202
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 203
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 204
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 205
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 206
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 207
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 208
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 209
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 210
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 211
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 212
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 213
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 214
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 215
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 216
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 217
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 218
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 219
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 220
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 221
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 222
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 223
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 224
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 225
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 226
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 227
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 228
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 229
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 230
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 231
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 232
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 233
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 234
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 235
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 236
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 237
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 238
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 239
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 240
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 241
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 242
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 243
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 244
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 245
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 246
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 247
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 248
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 249
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 250
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 251
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 252
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 253
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 254
+ aTab[i++] = new Ww1SingleSprm(0, "?"); // 255
+ if (aTab[i-1] == NULL)
+ DeinitTab(); //~ mdt: low mem und nu?
+ DBG_ASSERT(i==sizeof(aTab)/sizeof(*aTab), "Ww1Sprm");
+}
+
+////////////////////////////////////////////////////////////// SprmPapx
+Ww1SprmPapx::Ww1SprmPapx(BYTE* p, USHORT nSize) :
+ Ww1Sprm(Sprm(p, nSize), SprmSize(p, nSize))
+{
+ memset(&aPapx, 0, sizeof(aPapx));
+ memcpy(&aPapx, p, nSize<sizeof(aPapx)?nSize:sizeof(aPapx));
+}
+
+USHORT Ww1SprmPapx::SprmSize(BYTE*, USHORT nSize)
+{
+ USHORT nRet = 0;
+ if (nSize >= sizeof(W1_PAPX))
+ nRet = nSize - ( sizeof(W1_PAPX) - 1 ); // im W1_PAPX ist das
+ // 1. SprmByte enthalten
+ return nRet;
+}
+
+BYTE* Ww1SprmPapx::Sprm(BYTE* p, USHORT nSize)
+{
+ BYTE* pRet = NULL;
+ if (nSize >= sizeof(W1_PAPX))
+ pRet = ((W1_PAPX*)(p))->grpprlGet();
+ return pRet;
+}
+
+/////////////////////////////////////////////////////////////////// Plc
+Ww1Plc::Ww1Plc(Ww1Fib& rFib, ULONG ulFilePos, USHORT nCountBytes, USHORT nItemSize) :
+ p(NULL),
+ nCountBytes(nCountBytes),
+ iMac(0),
+ bOK(FALSE),
+ nItemSize(nItemSize),
+ rFib(rFib)
+{
+ if (!nCountBytes)
+ bOK = TRUE;
+ else
+ if (rFib.GetStream().Seek(ulFilePos) == (ULONG)ulFilePos)
+ if ((p = new BYTE[nCountBytes]) != NULL)
+ if (rFib.GetStream().Read(p, nCountBytes) == (ULONG)nCountBytes)
+ {
+ bOK = TRUE;
+ iMac = (nCountBytes - sizeof(SVBT32)) / (sizeof(SVBT32) + nItemSize);
+ DBG_ASSERT(iMac * ((USHORT)sizeof(ULONG) + nItemSize) +
+ (USHORT)sizeof(SVBT32) == nCountBytes, "Ww1Plc");
+ }
+}
+
+Ww1Plc::~Ww1Plc()
+{
+ delete p;
+}
+
+void Ww1Plc::Seek(ULONG ulSeek, USHORT& nIndex)
+{
+ if (iMac)
+ for (;nIndex <= iMac && Where(nIndex) < ulSeek;nIndex++)
+ ;
+}
+
+ULONG Ww1Plc::Where(USHORT nIndex)
+{
+ ULONG ulRet = 0xffffffff;
+ DBG_ASSERT(nIndex <= iMac, "index out of bounds");
+ if (iMac && nIndex <= iMac)
+ ulRet = SVBT32ToLong(p + sizeof(SVBT32) * nIndex);
+ return ulRet;
+}
+
+BYTE* Ww1Plc::GetData(USHORT nIndex)
+{
+ BYTE* pRet = NULL;
+ DBG_ASSERT(nIndex < iMac, "index out of bounds");
+ if (nIndex < iMac)
+ pRet = p + (iMac + 1) * sizeof(SVBT32) +
+ nIndex * nItemSize; // Pointer auf Inhalts-Array
+ return pRet;
+}
+
+/////////////////////////////////////////////////////////////////// Sep
+
+//////////////////////////////////////////////////////////////// PlcSep
+
+//////////////////////////////////////////////////////////////// PlcPap
+
+//////////////////////////////////////////////////////////////// PlcChp
+
+//////////////////////////////////////////////////////////////// PlcFnr
+
+///////////////////////////////////////////////////////////// PlcFnText
+
+///////////////////////////////////////////////////////////// PlcFields
+
+///////////////////////////////////////////////////////////// PlcBookmarks
+// class Ww1StringList liest im Ctor eine Anzahl von P-Strings aus dem Stream
+// in den Speicher und patcht sie zu C-Strings um.
+// Die Anzahl wird in nMax zurueckgeliefert.
+// im Index 0 stehen alle Strings nacheinander, ab Index 1 werden
+// die einzelnen Strings referenziert.
+Ww1StringList::Ww1StringList( SvStream& rSt, ULONG nFc, USHORT nCb )
+ : pIdxA(0), nMax(0)
+{
+ if( nCb > 2 ) // ueberhaupt Eintraege ?
+ {
+ SVBT16 nCountBytes;
+ DBG_ASSERT(nCb > sizeof(nCountBytes), "Ww1StringList");
+ if (rSt.Seek(nFc) == (ULONG)nFc)
+ if (rSt.Read(nCountBytes, sizeof(nCountBytes))
+ == sizeof(nCountBytes)) // Laenge steht hier nochmal
+ {
+ DBG_ASSERT(SVBT16ToShort(nCountBytes)
+ == nCb, "redundant-size missmatch");
+ // hoffentlich sind sie immer gleich
+ sal_Char* pA = new sal_Char[nCb - sizeof(nCountBytes) + 1];
+ // Alloziere PString-Array
+ //~ Ww1: new-NULL
+ if (rSt.Read(pA, nCb - sizeof(nCountBytes))
+ == (ULONG)nCb - sizeof(nCountBytes)) // lese alle
+ {}// do nothing
+ // Zaehle, wieviele Fonts enthalten
+ long nLeft = nCb - sizeof(nCountBytes);
+ sal_Char* p = pA;
+ while (1)
+ {
+ USHORT nNextSiz;
+ nNextSiz = *p + 1;
+ if(nNextSiz > nLeft)
+ break;
+ nMax++;
+ nLeft -= nNextSiz;
+ if(nLeft < 1) // naechste Laenge muss gelesen werden koennen
+ break;
+ p = p + nNextSiz;
+ }
+ if (nMax)
+ {
+ pIdxA = new sal_Char*[nMax+1]; // alloziere Index-Array
+ pIdxA[0] = pA; // Index 0 : alles
+ // ab Index 1 C-Strings
+ pIdxA[1] = pA + 1; // fuelle Index-Array
+ USHORT i = 2;
+ p = pA;
+ BYTE nL = *p;
+ while(1)
+ {
+ p += nL + 1; // Neues Laengen-Byte
+ nL = *p; // merke Laenge
+ *p = '\0'; // mach C-String draus
+ if( i > nMax )
+ break;
+ pIdxA[i] = p + 1; // Ptr auf C-String
+ i++;
+ }
+ }
+ else
+ pIdxA = 0; // Keine Eintraege -> kein Array
+ }
+ }
+}
+const String Ww1StringList::GetStr( USHORT nNum ) const
+{
+ String sRet;
+ if( nNum <= nMax )
+ sRet = String( pIdxA[ nNum+1 ], RTL_TEXTENCODING_MS_1252 );
+ return sRet;
+}
+
+Ww1Bookmarks::Ww1Bookmarks(Ww1Fib& rFib)
+ : rFib(rFib), aNames(rFib), nIsEnd(0)
+{
+ pPos[0] = new Ww1PlcBookmarkPos(rFib, rFib.GetFIB().fcPlcfbkfGet(),
+ rFib.GetFIB().cbPlcfbkfGet(), FALSE);
+ nPlcIdx[0] = 0;
+ pPos[1] = new Ww1PlcBookmarkPos(rFib, rFib.GetFIB().fcPlcfbklGet(),
+ rFib.GetFIB().cbPlcfbklGet(), TRUE);
+ nPlcIdx[1] = 0;
+ bOK = !aNames.GetError() && !pPos[0]->GetError() && !pPos[1]->GetError();
+}
+
+
+// Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
+// sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
+// Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
+// erst der Anfang und dann das Ende gefunden werden.
+// Der Fall: ][
+// [...]
+// ][
+// ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
+// vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
+// oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
+// noetig wird.
+void Ww1Bookmarks::operator ++( int )
+{
+ if( bOK )
+ {
+ nPlcIdx[nIsEnd]++;
+
+ register ULONG l0 = pPos[0]->Where(nPlcIdx[0]);
+ register ULONG l1 = pPos[1]->Where(nPlcIdx[1]);
+ if( l0 < l1 )
+ nIsEnd = 0;
+ else if( l1 < l0 )
+ nIsEnd = 1;
+ else
+ nIsEnd = ( nIsEnd ) ? 0 : 1;
+ }
+}
+
+long Ww1Bookmarks::GetHandle() const
+{
+ if( bOK )
+ {
+ if( nIsEnd )
+ return nPlcIdx[1];
+
+ const BYTE* p = pPos[0]->GetData( nPlcIdx[0] );
+ if( p )
+ return SVBT16ToShort( p );
+ }
+ return LONG_MAX;
+}
+
+long Ww1Bookmarks::Len() const
+{
+ if( nIsEnd )
+ {
+ DBG_ASSERT( FALSE, "Falscher Aufruf (1) von Ww1Bookmarks::Len()" );
+ return 0;
+ }
+ USHORT nEndIdx = SVBT16ToShort(pPos[0]->GetData(nPlcIdx[0]));
+ return pPos[1]->Where(nEndIdx) - pPos[0]->Where(nPlcIdx[0]);
+}
+
+const String Ww1Bookmarks::GetName() const
+{
+ if( nIsEnd )
+ return String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "???" ));
+ return aNames.GetStr( nPlcIdx[0] );
+}
+
+/////////////////////////////////////////////////////////////////// Fkp
+Ww1Fkp::Ww1Fkp(SvStream& rStream, ULONG ulFilePos, USHORT nItemSize) :
+ nItemSize(nItemSize),
+ bOK(FALSE)
+{
+ if (rStream.Seek(ulFilePos) == (ULONG)ulFilePos)
+ if (rStream.Read(aFkp, sizeof(aFkp)) == sizeof(aFkp))
+ bOK = TRUE;
+}
+
+ULONG Ww1Fkp::Where(USHORT nIndex)
+{
+ ULONG lRet = 0xffffffff;
+ DBG_ASSERT(nIndex<=Count(), "index out of bounds");
+ if (nIndex<=Count())
+ lRet = SVBT32ToLong(aFkp+nIndex*sizeof(SVBT32));
+ return lRet;
+}
+
+BYTE* Ww1Fkp::GetData(USHORT nIndex)
+{
+ BYTE* pRet = NULL;
+ DBG_ASSERT(nIndex<=Count(), "index out of bounds");
+ if (nIndex<=Count())
+ pRet = aFkp + (Count()+1) * sizeof(SVBT32) +
+ nIndex * nItemSize; // beginn der strukturen
+ return pRet;
+}
+
+//////////////////////////////////////////////////////////////// FkpPap
+BOOL Ww1FkpPap::Fill(USHORT nIndex, BYTE*& p, USHORT& rnCountBytes)
+{
+ DBG_ASSERT( nIndex < Count(), "Ww1FkpPap::Fill() Index out of Range" );
+ USHORT nOffset = SVBT8ToByte(GetData(nIndex)) * 2;
+ if (nOffset)
+ {
+ DBG_ASSERT(nOffset>(USHORT)(Count()*sizeof(SVBT32)), "calc error");
+// rnCountBytes = SVBT8ToByte(aFkp+nOffset) * 2 + 1; // SH: +1 ?????
+ rnCountBytes = SVBT8ToByte(aFkp+nOffset) * 2;
+ nOffset += sizeof(SVBT8);
+ if( nOffset + rnCountBytes < 511 ) // SH: Assert schlug 1 zu frueh zu
+ rnCountBytes++; // SH: Ich weiss nicht genau,
+ // ob das letzte Byte des PAPX
+ // genutzt wird, aber so vergessen
+ // wir keins und sind trotzdem
+ // auf der sicheren Seite
+ DBG_ASSERT(nOffset+rnCountBytes <= 511, "calc error");
+ p = aFkp + nOffset;
+ }
+ else
+ {
+ p = NULL;
+ rnCountBytes = 0;
+ }
+ return TRUE;
+}
+
+BOOL Ww1FkpPap::Fill(
+ USHORT nIndex, BYTE*& p, USHORT& rnCountBytes, ULONG& rulStart, ULONG& rulEnd)
+{
+ rulStart = Where(nIndex);
+ rulEnd = Where(nIndex+1);
+ Fill(nIndex, p, rnCountBytes);
+ return TRUE;
+}
+
+//////////////////////////////////////////////////////////////// FkpChp
+BOOL Ww1FkpChp::Fill(USHORT nIndex, W1_CHP& aChp)
+{
+ DBG_ASSERT( nIndex < Count(), "Ww1FkpChp::Fill() Index out of Range" );
+ memset(&aChp, 0, sizeof(aChp)); // Default, da verkuerzt gespeichert
+ USHORT nOffset = GetData(nIndex)[0] * 2;
+ if (nOffset)
+ {
+ DBG_ASSERT(nOffset>(USHORT)(Count()*sizeof(SVBT32)), "calc error");
+ USHORT nCountBytes = aFkp[nOffset];
+ nOffset += sizeof(SVBT8);
+ DBG_ASSERT(nCountBytes <= 511-nOffset, "calc error");
+ DBG_ASSERT(nCountBytes <= sizeof(aChp), "calc error");
+ memcpy(&aChp, aFkp+nOffset, nCountBytes);
+ }
+ return TRUE;
+}
+
+BOOL Ww1FkpChp::Fill(USHORT nIndex, W1_CHP& aChp, ULONG& rulStart, ULONG& rulEnd)
+{
+ DBG_ASSERT( nIndex < Count(), "Ww1FkpChp::Fill() Index out of Range" );
+ rulStart = Where(nIndex);
+ rulEnd = Where(nIndex+1);
+ memset(&aChp, 0, sizeof(aChp)); // Default, da verkuerzt gespeichert
+ USHORT nOffset = GetData(nIndex)[0] * 2;
+ if (nOffset)
+ {
+ DBG_ASSERT(nOffset>(USHORT)(Count()*sizeof(SVBT32)), "calc error");
+ USHORT nCountBytes = aFkp[nOffset];
+ nOffset += sizeof(SVBT8);
+ DBG_ASSERT(nCountBytes <= 511-nOffset, "calc error");
+ DBG_ASSERT(nCountBytes <= sizeof(aChp), "calc error");
+ memcpy(&aChp, aFkp+nOffset, nCountBytes);
+ }
+ return TRUE;
+}
+
+///////////////////////////////////////////////////////////////// Assoc
+Ww1Assoc::Ww1Assoc(Ww1Fib& rFib)
+ : rFib(rFib), pBuffer(NULL), bOK(FALSE)
+{
+ USHORT cb = rFib.GetFIB().cbSttbfAssocGet();
+ for (USHORT i=0;i<MaxFields;i++)
+ pStrTbl[i] = NULL;
+ if ((pBuffer = new sal_Char[cb]) != NULL
+ && rFib.GetStream().Seek(rFib.GetFIB().fcSttbfAssocGet()) ==
+ rFib.GetFIB().fcSttbfAssocGet()
+ && rFib.GetStream().Read(pBuffer, cb) == cb)
+ {
+ USHORT j;
+ DBG_ASSERT( cb == SVBT16ToShort( *(SVBT16*)pBuffer ), "size missmatch");
+ for (i=0,j=sizeof(SVBT16);j<cb && i<Criteria1;i++)
+ {
+ pStrTbl[i] = pBuffer+j;
+ j += (*pBuffer + j) + 1;
+ }
+ bOK = TRUE;
+ }
+}
+
+String Ww1Assoc::GetStr(USHORT code)
+{
+ String sRet;
+ DBG_ASSERT(code<MaxFields, "out of range");
+ if (pStrTbl[code] != NULL)
+ for( USHORT i=0;i<pStrTbl[code][0];i++ )
+ sRet += String( pStrTbl[code][i+1], RTL_TEXTENCODING_MS_1252 );
+ return sRet;
+}
+
+/////////////////////////////////////////////////////////////////// Pap
+Ww1Pap::Ww1Pap(Ww1Fib& rFib) :
+ Ww1PlcPap(rFib),
+ nPlcIndex(0),
+ nFkpIndex(0),
+ nPushedPlcIndex(0xffff),
+ nPushedFkpIndex(0xffff),
+ ulOffset(0),
+ pPap(0)
+{
+}
+
+void Ww1Pap::Seek(ULONG ulSeek)
+{
+ while (ulSeek > Where())
+ (*this)++;
+}
+
+// SH: Where hat einen Parameter mitbekommen, der sagt, ob bei Neuanlegen eines
+// Fkps der zugehoerige Index auf 0 gesetzt werden soll
+// ( darf fuer Push/Pop nicht passieren )
+// Ein eleganterer Weg faellt mir auf die Schnelle nicht ein
+ULONG Ww1Pap::Where( BOOL bSetIndex )
+{
+ ULONG ulRet = 0xffffffff;
+ if (pPap == NULL)
+ if (nPlcIndex < Count())
+ {
+ pPap = new Ww1FkpPap(rFib.GetStream(),
+ SVBT16ToShort(GetData(nPlcIndex)) << 9);
+ if( bSetIndex )
+ nFkpIndex = 0;
+ }
+ if (pPap != NULL)
+// if (nFkpIndex < pPap->Count())
+ if (nFkpIndex <= pPap->Count())
+ ulRet = pPap->Where(nFkpIndex) - rFib.GetFIB().fcMinGet();
+ return ulRet;
+}
+
+void Ww1Pap::operator++(int)
+{
+ if (pPap != NULL)
+// if (++nFkpIndex >= pPap->Count())
+ if (++nFkpIndex > pPap->Count())
+ {
+ delete pPap;
+ pPap = NULL;
+ nPlcIndex++;
+ }
+}
+
+// SH: FindSprm sucht in grpprl nach Sprm nId
+// Rueckgabe: Pointer oder 0
+BOOL Ww1Pap::FindSprm(USHORT nId, BYTE* pStart, BYTE* pEnd)
+{
+ Ww1Sprm aSprm( pStart, pEnd-pStart );
+ USHORT nC = aSprm.Count();
+ int i;
+ BYTE nI;
+ USHORT nLen;
+ BYTE *pData;
+ for( i = 0; i < nC; i++ ){
+ aSprm.Fill( i, nI, nLen, pData );
+ if( nI == nId )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL Ww1Pap::HasId0(USHORT nId)
+{
+ BOOL bRet = FALSE;
+ UpdateIdx();
+
+ if( !pPap ){
+ DBG_ASSERT( FALSE, "Ww1Pap::HasId():: kann kein pPap erzeugen" );
+ return FALSE;
+ }
+
+ BYTE* p;
+ USHORT n;
+ if( pPap->Fill(nFkpIndex, p, n) ){
+ BYTE* p2 = ((W1_PAPX*)(p))->grpprlGet(); // SH: Offset fehlte
+ bRet = FindSprm( nId, p2, p+n );
+ }
+ return bRet;
+}
+
+BOOL Ww1Pap::HasId(USHORT nId)
+{
+ BOOL bRet = FALSE;
+ USHORT nPushedPlcIndex = nPlcIndex;
+ USHORT nPushedFkpIndex = nFkpIndex;
+ bRet = HasId0( nId );
+ if (nPlcIndex != nPushedPlcIndex)
+ {
+ delete pPap;
+ pPap = NULL;
+ }
+ nPlcIndex = nPushedPlcIndex;
+ nFkpIndex = nPushedFkpIndex;
+ Where( FALSE );
+ return bRet;
+}
+
+BOOL Ww1Pap::NextHas(USHORT nId)
+{
+ BOOL bRet = FALSE;
+ USHORT nPushedPlcIndex = nPlcIndex;
+ USHORT nPushedFkpIndex = nFkpIndex;
+ (*this)++;
+ bRet = HasId0( nId );
+ if (nPlcIndex != nPushedPlcIndex)
+ {
+ delete pPap;
+ pPap = NULL;
+ }
+ nPlcIndex = nPushedPlcIndex;
+ nFkpIndex = nPushedFkpIndex;
+ Where( FALSE );
+ return bRet;
+}
+
+/////////////////////////////////////////////////////////////////// Chp
+Ww1Chp::Ww1Chp(Ww1Fib& rFib) :
+ Ww1PlcChp(rFib),
+ nPlcIndex(0),
+ nFkpIndex(0),
+ nPushedPlcIndex(0xffff),
+ nPushedFkpIndex(0xffff),
+ ulOffset(0),
+ pChp(0)
+{
+}
+
+void Ww1Chp::Seek(ULONG ulSeek)
+{
+ while (ulSeek > Where())
+ (*this)++;
+}
+
+// SH: Where hat einen Parameter mitbekommen, der sagt, ob bei Neuanlegen eines
+// Fkps der zugehoerige Index auf 0 gesetzt werden soll
+// ( darf fuer Push/Pop nicht passieren )
+// Ein eleganterer Weg faellt mir auf die Schnelle nicht ein
+ULONG Ww1Chp::Where( BOOL bSetIndex )
+{
+ ULONG ulRet = 0xffffffff;
+ if (pChp == NULL)
+ if (nPlcIndex < Count())
+ {
+ pChp = new Ww1FkpChp(rFib.GetStream(),
+ SVBT16ToShort(GetData(nPlcIndex)) << 9);
+ if( bSetIndex )
+ nFkpIndex = 0;
+ }
+ if (pChp != NULL)
+// if (nFkpIndex < pChp->Count())
+ if (nFkpIndex <= pChp->Count())
+ ulRet = pChp->Where(nFkpIndex) -
+ rFib.GetFIB().fcMinGet() - ulOffset;
+ return ulRet;
+}
+
+void Ww1Chp::operator++(int)
+{
+ if (pChp != NULL)
+// if (++nFkpIndex >= pChp->Count())
+ if (++nFkpIndex > pChp->Count())
+ {
+ delete pChp;
+ pChp = NULL;
+ nPlcIndex++;
+ }
+}
+
+////////////////////////////////////////////////////////////// Manager
+Ww1Manager::Ww1Manager(SvStream& rStrm, ULONG nFieldFlgs) :
+ bOK(FALSE),
+ bInTtp(FALSE),
+ bInStyle(FALSE),
+ bStopAll(FALSE),
+ aFib(rStrm),
+ aDop(aFib),
+ aFonts(aFib, nFieldFlgs),
+ aSep(aFib, aDop.GetDOP().grpfIhdtGet()),
+ aDoc(aFib),
+ pDoc(&aDoc),
+ ulDocSeek(0),
+ pSeek(&ulDocSeek),
+ aPap(aFib),
+ aChp(aFib),
+ aFld(aFib),
+ pFld(&aFld),
+ aFtn(aFib),
+ aBooks(aFib)
+{
+ bOK = !aFib.GetError()
+ && !aFib.GetFIB().fComplexGet()
+ && !aDoc.GetError()
+ && !aSep.GetError()
+ && !aPap.GetError()
+ && !aChp.GetError()
+ && !aFld.GetError()
+ && !aFtn.GetError()
+ && !aBooks.GetError();
+}
+
+BOOL Ww1Manager::IsValidFib(const BYTE*p, USHORT size)
+{
+ return ((
+ ((W1_FIB*)p)->wIdentGet() == 42396
+ && ((W1_FIB*)p)->nFibGet() == 33 // ww1
+#ifdef DEBUG
+ || ((W1_FIB*)p)->wIdentGet() == 42459
+ && ((W1_FIB*)p)->nFibGet() == 45 // ww2b
+#endif
+ )
+// && ((W1_FIB*)p)->nProductGet() == 8413
+ && ((W1_FIB*)p)->fComplexGet() == 0);
+}
+
+BOOL Ww1Manager::HasInTable()
+{
+ return aPap.HasId(24); // Ww1SingleSprmPFInTable
+}
+
+BOOL Ww1Manager::HasTtp()
+{
+ return aPap.HasId(25); // Ww1SingleSprmPTtp
+}
+
+BOOL Ww1Manager::NextHasTtp()
+{
+ return aPap.NextHas(25); // Ww1SingleSprmPTtp
+}
+
+BOOL Ww1Manager::HasPPc()
+{
+ return aPap.HasId(29); // Ww1SingleSprmPPc
+}
+
+BOOL Ww1Manager::HasPDxaAbs()
+{
+ return aPap.HasId(26); // Ww1SingleSprmPDxaAbs
+}
+
+/**********************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww1/w1class.cxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.19 2000/09/18 16:04:56 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.18 2000/05/11 16:06:45 jp
+ Changes for Unicode
+
+ Revision 1.17 1998/02/19 16:00:42 HJS
+ fuer sh eingechecked
+
+
+ Rev 1.16 19 Feb 1998 17:00:42 HJS
+ fuer sh eingechecked
+
+ Rev 1.15 29 Nov 1997 17:37:08 MA
+ includes
+
+ Rev 1.14 09 Oct 1997 14:13:46 JP
+ Aenderungen von SH
+
+ Rev 1.13 03 Sep 1997 14:15:58 SH
+ Flys, Tabellen ok, Style-Abhaengigkeiten u.v.a.m
+
+ Rev 1.12 11 Aug 1997 12:49:08 SH
+ Flys und einfache Tabellen und Tabulatoren
+
+ Rev 1.11 18 Jul 1997 09:31:38 MA
+ Stand von SH, #41738# GPF und Tabellen etwas besser
+
+ Rev 1.9 16 Jun 1997 13:08:56 MA
+ Stand Micheal Dietrich
+
+ Rev 1.7 12 Mar 1997 19:11:52 SH
+ MDT: Progressbar, Pagedesc-Bug, Spalten, Anfang Tabellen u.a.
+
+ Rev 1.6 10 Jan 1997 18:42:40 SH
+ Stabiler und mehr von MDT
+
+ Rev 1.5 28 Nov 1996 18:08:28 SH
+ Schneller Schoener Weiter von MDT
+
+ Rev 1.4 05 Nov 1996 12:47:28 mda
+ kein io.h unter Unix includen
+
+ Rev 1.3 14 Oct 1996 13:07:12 KH
+ explizite Feldlaenge wg. compiler bug
+
+ Rev 1.2 30 Sep 1996 23:27:52 SH
+ neu von MDA
+
+ Rev 1.1 11 Sep 1996 11:23:40 TRI
+ WIN16 brauchte Cast
+
+ Rev 1.0 10 Sep 1996 02:10:06 SH
+ Initial revision.
+
+
+**********************************************************************/
+//]})
diff --git a/sw/source/filter/ww1/w1class.hxx b/sw/source/filter/ww1/w1class.hxx
new file mode 100644
index 000000000000..d4ac0cfe510c
--- /dev/null
+++ b/sw/source/filter/ww1/w1class.hxx
@@ -0,0 +1,1753 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1class.hxx,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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+// local
+#ifndef _W1STRUCT_HXX
+#include <w1struct.hxx>
+#endif
+
+#ifdef DUMP
+#include <fstream.h>
+#endif
+
+class ostream;
+class SvxFontItem;
+class SvxBorderLine;
+class SvxBoxItem;
+class SvStream;
+class SfxPoolItem;
+class SwField;
+class Ww1Annotation;
+class Ww1AtnText;
+class Ww1Chp;
+class Ww1DocText;
+class Ww1Dop;
+class Ww1Fib;
+class Ww1Fkp;
+class Ww1FkpChp;
+class Ww1FkpPap;
+class Ww1Fonts;
+class Ww1Manager;
+class Ww1McrText;
+class Ww1Pap;
+class Ww1PlainText;
+class Ww1Plc;
+class Ww1PlcAnnotationRef;
+class Ww1PlcAnnotationTxt;
+class Ww1PlcChp;
+class Ww1PlcFields;
+class Ww1PlcFieldFootnote;
+class Ww1PlcFieldHeaderFooter;
+class Ww1PlcFieldMacro;
+class Ww1PlcFieldText;
+class Ww1PlcFootnoteRef;
+class Ww1PlcFootnoteTxt;
+class Ww1PlcGlossary;
+class Ww1PlcHdd;
+class Ww1PlcPap;
+class Ww1PlcSep;
+class Ww1Shell;
+class Ww1Sprm;
+class Ww1SprmPapx;
+class Ww1SprmSep;
+class Ww1Style;
+class Ww1StyleSheet;
+
+///////////////////////////////////////////////////////////////////////
+//
+// nach moeglichkeit wurden in diesem modul methoden aehnlicher
+// funktionalitaet gleich benannt. Die namen wurden wenn moeglich vom
+// ww-filter uebernommen.
+// Where() gibt die position eines elements. dies kann sowohl eine
+// seek-position im stream als auch ein relativer offset sein, da dies
+// bei word durcheinander geht. die methoden sind durch kommentare
+// gekennzeichnet, ob sie sich auf positionen in der datei oder
+// innerhalb des textes beziehen. vorsicht: innerhalb des textes kann
+// verschiedene texte in der datei bedeuten.
+// Count() gibt die anzahl der elemente zurueck. vorsicht bei
+// n/n-1-feldern (word speichert strukturen gern in doppel-arrays, in
+// denen das erste n elemente, das zweite jedoch n-1 elemente
+// enthaelt.
+// Fill() fuellt uebergebene referenzen mit daten aus den
+// word-strukturen.
+// GetData() gibt zeiger auf den datenbereich zurueck
+// GetError() gibt zurueck, ob fehler aufgetreten ist
+// Start(), Stop(), Out(), op<< siehe modul w1filter
+// Dump() siehe modul w1dump
+//
+
+/////////////////////////////////////////////////////////////////// Fib
+//
+// file information block: wurzel des uebels: steht am beginn der
+// datei (seek(0)) und enthaelt alle positionen der strukturen der
+// datei
+//
+class Ww1Fib
+{
+ W1_FIB aFib;
+ BOOL bOK;
+ SvStream& rStream;
+public:
+ Ww1Fib(SvStream&);
+ friend ostream& operator <<(ostream&, Ww1Fib&);
+ W1_FIB& GetFIB() { return aFib; }
+ BOOL GetError() { return !bOK; }
+ SvStream& GetStream() { return rStream; }
+};
+
+/////////////////////////////////////////////////////////////////// Dop
+//
+// document property: eigenschaften des gesamten dokuments
+//
+class Ww1Dop
+{
+ W1_DOP aDop;
+ Ww1Fib& rFib;
+ BOOL bOK;
+public:
+ Ww1Dop(Ww1Fib&);
+ BOOL GetError() {
+ return !bOK; }
+ W1_DOP& GetDOP() {
+ return aDop; }
+ friend ostream& operator <<(ostream&, Ww1Dop&);
+ void Out(Ww1Shell&);
+};
+
+///////////////////////////////////////////////////////////// PlainText
+//
+// ww-dateien koennen mehrere textbloecke enthalten (main-text,
+// fusznoten etc). PlainText vereinigt die gemeinsamkeiten
+//
+class Ww1PlainText
+{
+protected:
+ Ww1Fib& rFib;
+ ULONG ulFilePos;
+ ULONG ulCountBytes;
+ ULONG ulSeek;
+ BOOL bOK;
+public:
+ Ww1PlainText( Ww1Fib& rFib, ULONG ulFilePos, ULONG ulCountBytes )
+ : rFib( rFib ), ulCountBytes( ulCountBytes ),
+ ulFilePos( ulFilePos ), ulSeek( 0 ), bOK(TRUE)
+ {}
+
+ // innerhalb des textes
+ ULONG Where() const { return ulSeek; }
+ void Seek( ULONG ulNew )
+ {
+ DBG_ASSERT(ulNew < ulCountBytes, "Ww1PlainText")
+ if (ulNew < ulCountBytes)
+ ulSeek = ulNew;
+ }
+
+ ULONG Count() const { return ulCountBytes; }
+ void SetCount(ULONG ulNew)
+ {
+ ulNew += ulSeek;
+ if (ulCountBytes > ulNew)
+ ulCountBytes = ulNew;
+ }
+ void operator++(int)
+ {
+ DBG_ASSERT(ulSeek+1<ulCountBytes, "Ww1PlainText");
+ ulSeek++;
+ }
+ BOOL GetError() { return !bOK; }
+ sal_Unicode Out( Ww1Shell&, ULONG& );
+ sal_Unicode Out( String&, ULONG=0xffffffff);
+ sal_Unicode Out( sal_Unicode& );
+ friend ostream& operator <<(ostream&, Ww1PlainText&);
+ String& Fill( String&, ULONG=0, ULONG=0xffffffff );
+ sal_Unicode operator []( ULONG );
+ String GetText( ULONG ulOffset, ULONG nLen ) const;
+
+ enum Consts { MinChar = 32 };
+ static BOOL IsChar( sal_Unicode c ) { return c >= MinChar; }
+};
+
+/////////////////////////////////////////////////////////////// DocText
+class Ww1DocText : public Ww1PlainText
+{
+public:
+ Ww1DocText(Ww1Fib& rFib) :
+ Ww1PlainText(rFib, rFib.GetFIB().fcMinGet(),
+ rFib.GetFIB().ccpTextGet()) {
+ }
+};
+
+/////////////////////////////////////////////////////////////// FtnText
+class Ww1FtnText : public Ww1PlainText
+{
+public:
+ ULONG Offset(Ww1Fib& rFib) {
+ return rFib.GetFIB().ccpTextGet(); }
+ Ww1FtnText(Ww1Fib& rFib) :
+ Ww1PlainText(rFib, rFib.GetFIB().fcMinGet() +
+ Offset(rFib), rFib.GetFIB().ccpFtnGet()) {
+ }
+};
+
+/////////////////////////////////////////////////////////////// HddText
+class Ww1HddText : public Ww1PlainText
+{
+public:
+ ULONG Offset(Ww1Fib& rFib) {
+ return rFib.GetFIB().ccpTextGet() + rFib.GetFIB().ccpFtnGet(); }
+ Ww1HddText(Ww1Fib& rFib) :
+ Ww1PlainText(rFib, rFib.GetFIB().fcMinGet() +
+ Offset(rFib), rFib.GetFIB().ccpHddGet()) {
+ }
+};
+
+/////////////////////////////////////////////////////////////// McrText
+class Ww1McrText : public Ww1PlainText
+{
+public:
+ ULONG Offset(Ww1Fib& rFib) {
+ return rFib.GetFIB().ccpTextGet() + rFib.GetFIB().ccpFtnGet()
+ + rFib.GetFIB().ccpHddGet(); }
+ Ww1McrText(Ww1Fib& rFib) :
+ Ww1PlainText(rFib, rFib.GetFIB().fcMinGet() +
+ Offset(rFib), rFib.GetFIB().ccpMcrGet()) {
+ }
+};
+
+/////////////////////////////////////////////////////////////// AtnText
+class Ww1AtnText : public Ww1PlainText
+{
+public:
+ ULONG Offset(Ww1Fib& rFib) {
+ return rFib.GetFIB().ccpTextGet() + rFib.GetFIB().ccpFtnGet()
+ + rFib.GetFIB().ccpHddGet() + rFib.GetFIB().ccpMcrGet(); }
+ Ww1AtnText(Ww1Fib& rFib) :
+ Ww1PlainText(rFib, rFib.GetFIB().fcMinGet() +
+ Offset(rFib), rFib.GetFIB().ccpAtnGet()) {
+ }
+};
+
+///////////////////////////////////////////////////////////////// Style
+//
+// ein einzelner style oder vorlage
+//
+class Ww1Style
+{
+ String aName;
+ W1_CHP aChpx;
+ Ww1SprmPapx* pPapx;
+ Ww1StyleSheet* pParent;
+ BYTE stcBase;
+ BYTE stcNext;
+ BOOL bUsed;
+public:
+ Ww1Style();
+ ~Ww1Style();
+ BOOL IsUsed() const { return bUsed; }
+ void SetDefaults(BYTE);
+ void SetParent(Ww1StyleSheet* newParent) { pParent = newParent; }
+ void SetName(const String& rName) { bUsed = TRUE; aName = rName; }
+ const String& GetName() const { return aName; }
+// Ww1Style& GetNext();
+ Ww1Style& GetBase();
+ USHORT GetnBase() const { return stcBase; }
+ USHORT GetnNext() const { return stcNext; }
+ USHORT ReadName(BYTE*&, USHORT&, USHORT stc);
+ USHORT ReadChpx(BYTE*&, USHORT&);
+ USHORT ReadPapx(BYTE*&, USHORT&);
+ USHORT ReadEstcp(BYTE*&, USHORT&);
+ friend ostream& operator <<(ostream&, Ww1Style&);
+ void Out(Ww1Shell&, Ww1Manager&);
+};
+
+//////////////////////////////////////////////////////////// StyleSheet
+//
+// die sammlung aller vorlagen (max. 256)
+//
+class Ww1StyleSheet
+{
+ Ww1Style aStyles[256];
+ USHORT cstcStd; // count style code standard
+ Ww1Fib& rFib;
+ BOOL bOK;
+ USHORT ReadNames(BYTE*&, USHORT&);
+ USHORT ReadChpx(BYTE*&, USHORT&);
+ USHORT ReadPapx(BYTE*&, USHORT&);
+ USHORT ReadEstcp(BYTE*&, USHORT&);
+
+ void OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc);
+ void OutOne(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc);
+ void OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc,
+ BYTE* pbStopRecur );
+public:
+ Ww1StyleSheet(Ww1Fib& rFib);
+ Ww1Style& GetStyle(USHORT stc) {
+ return aStyles[stc]; }
+ USHORT Count() {
+ return 256; }
+ friend ostream& operator <<(ostream&, Ww1StyleSheet&);
+ void Out(Ww1Shell&, Ww1Manager&);
+ friend Ww1Style;
+ BOOL GetError() {
+ return !bOK; }
+};
+
+///////////////////////////////////////////////////////////////// Fonts
+//
+// ww kennt nur font-nummern beim formatieren. nebenher gibts ein
+// array von fonts, damit man aus der nummer einen konkreten font
+// machen kann.
+//
+class Ww1Fonts
+{
+protected:
+ W1_FFN** pFontA; // Array of Pointers to Font Description
+ Ww1Fib& rFib;
+ ULONG nFieldFlags;
+ USHORT nMax; // Array-Groesse
+ BOOL bOK;
+public:
+ Ww1Fonts(Ww1Fib&, ULONG nFieldFlgs);
+ ~Ww1Fonts() {
+ if (pFontA)
+ DELETEZ(pFontA[0]);
+ DELETEZ(pFontA); }
+ W1_FFN* GetFFN(USHORT nNum);
+ USHORT Count() {
+ return nMax; }
+ friend ostream& operator <<(ostream&, Ww1Fonts&);
+ BOOL GetError() {
+ return !bOK; }
+ SvxFontItem GetFont(USHORT);
+};
+
+//////////////////////////////////////////////////////////// SingleSprm
+//
+// diese klassen ersetzen die aSprmTab etc des ww6-filters. die
+// funktionspointer sind hier virtuale methoden, fuer die typen (byte,
+// word, var-sized etc) gibt es abgeleitete klassen. diese haben
+// methoden zum bestimmen der groesze, dumpen und shell-ausgeben der
+// Sprms.
+// die klassen werden mit new (in InitTab()) erzeugt und nach ihrem
+// code in die tabelle gestellt. zum aktivieren ruft man nun nur noch
+// die entsprechende methode des objektes in der tabelle auf.
+// wohlgemerkt: SingleSprms sind die _beschreibung_ und _funktion_ der
+// Sprms, nicht deren inhalt. dieser musz uebergeben werden an die
+// einzelnen methoden wie Size, Dump und Start/Stop.
+//
+class Ww1SingleSprm
+{
+public:
+#ifdef DUMP
+//
+// allein die virtuellen methoden stehen in der vtab, also je nachdem,
+// ob fuer dumper oder filter uebersetzt wird ausblenden: das spart
+// platz. ausserdem stehen die methoden fuer dumper bzw filter in
+// verschiedenen modulen, die im jeweils anderen projekt nicht
+// uebersetzt werden. das diese dann beim linken nicht zur verfuegung
+// stehen faellt dann auch nicht auf. Der Namensstring ist nur im
+// Dumper noetig: weg damit im Filter.
+//
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ virtual ostream& Dump(ostream&, BYTE*, USHORT);
+ const sal_Char* sName;
+#else
+ virtual void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ virtual void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ ostream& Dump(ostream&, BYTE*, USHORT);
+#endif
+ virtual USHORT Size(BYTE*);
+ USHORT nCountBytes;
+
+ Ww1SingleSprm(USHORT nCountBytes, const sal_Char* pName = 0 )
+ : nCountBytes(nCountBytes)
+#ifdef DUMP
+ , sName( pName)
+#endif
+ {
+ }
+};
+
+class Ww1SingleSprmByteSized : public Ww1SingleSprm {
+public:
+// ostream& Dump(ostream&, BYTE*, USHORT);
+ USHORT Size(BYTE*);
+ Ww1SingleSprmByteSized(USHORT nCountBytes, sal_Char* sName = 0) :
+ Ww1SingleSprm(nCountBytes, sName) {
+ }
+};
+
+class Ww1SingleSprmWordSized : public Ww1SingleSprm {
+public:
+// ostream& Dump(ostream&, BYTE*, USHORT);
+ USHORT Size(BYTE*);
+ Ww1SingleSprmWordSized(USHORT nCountBytes, sal_Char* sName = 0) :
+ Ww1SingleSprm(nCountBytes, sName) {
+ }
+};
+
+class Ww1SingleSprmByte : public Ww1SingleSprm {
+public:
+ ostream& Dump(ostream&, BYTE*, USHORT);
+// USHORT Size(BYTE*);
+ Ww1SingleSprmByte(sal_Char* sName = 0) :
+ Ww1SingleSprm(1, sName) {
+ }
+};
+
+class Ww1SingleSprmBool : public Ww1SingleSprmByte {
+public:
+ ostream& Dump(ostream&, BYTE*, USHORT);
+// USHORT Size(BYTE*);
+ Ww1SingleSprmBool(sal_Char* sName = 0) :
+ Ww1SingleSprmByte(sName) {
+ }
+};
+
+class Ww1SingleSprm4State : public Ww1SingleSprmByte {
+public:
+ ostream& Dump(ostream&, BYTE*, USHORT);
+// USHORT Size(BYTE*);
+ Ww1SingleSprm4State(sal_Char* sName = 0) :
+ Ww1SingleSprmByte(sName) {
+ }
+};
+
+class Ww1SingleSprmWord : public Ww1SingleSprm {
+public:
+ ostream& Dump(ostream&, BYTE*, USHORT);
+// USHORT Size(BYTE*);
+ Ww1SingleSprmWord(sal_Char* sName = 0) :
+ Ww1SingleSprm(2, sName) {
+ }
+};
+
+class Ww1SingleSprmLong : public Ww1SingleSprm {
+public:
+ ostream& Dump(ostream&, BYTE*, USHORT);
+// USHORT Size(BYTE*);
+ Ww1SingleSprmLong(sal_Char* sName = 0) :
+ Ww1SingleSprm(4, sName) {
+ }
+};
+
+class Ww1SingleSprmTab : public Ww1SingleSprm {
+public:
+ ostream& Dump(ostream&, BYTE*, USHORT);
+ USHORT Size(BYTE*);
+ Ww1SingleSprmTab(USHORT nCountBytes, sal_Char* sName = 0) :
+ Ww1SingleSprm(nCountBytes, sName) {
+ }
+};
+
+class Ww1SingleSprmPJc : public Ww1SingleSprmByte {
+public:
+ Ww1SingleSprmPJc(sal_Char* sName) :
+ Ww1SingleSprmByte(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDxa : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmPDxa(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDxaRight : public Ww1SingleSprmPDxa {
+public:
+ Ww1SingleSprmPDxaRight(sal_Char* sName) :
+ Ww1SingleSprmPDxa(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDxaLeft : public Ww1SingleSprmPDxa {
+public:
+ Ww1SingleSprmPDxaLeft(sal_Char* sName) :
+ Ww1SingleSprmPDxa(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDxaLeft1 : public Ww1SingleSprmPDxa {
+public:
+ Ww1SingleSprmPDxaLeft1(sal_Char* sName) :
+ Ww1SingleSprmPDxa(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPFKeep : public Ww1SingleSprmBool {
+public:
+ Ww1SingleSprmPFKeep(sal_Char* sName) :
+ Ww1SingleSprmBool(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPFKeepFollow : public Ww1SingleSprmBool {
+public:
+ Ww1SingleSprmPFKeepFollow(sal_Char* sName) :
+ Ww1SingleSprmBool(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPPageBreakBefore : public Ww1SingleSprmBool {
+public:
+ Ww1SingleSprmPPageBreakBefore(sal_Char* sName) :
+ Ww1SingleSprmBool(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPBrc : public Ww1SingleSprmWord {
+protected:
+// SvxBorderLine* SetBorder(SvxBorderLine*, W1_BRC*);
+ // spezielle start-routine, je nach sprm verschieden versorgt
+ // mit einem BoxItem.
+ void Start(Ww1Shell&, BYTE, W1_BRC10*, USHORT, Ww1Manager&, SvxBoxItem&);
+ void Start(Ww1Shell&, BYTE, W1_BRC*, USHORT, Ww1Manager&, SvxBoxItem&);
+public:
+ Ww1SingleSprmPBrc(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ // SetBorder() wird auch fuer Tabellen gebraucht, deshalb public
+ static SvxBorderLine* SetBorder(SvxBorderLine*, W1_BRC10*);
+};
+
+#define BRC_TOP ((USHORT)0)
+#define BRC_LEFT ((USHORT)1)
+#define BRC_BOTTOM ((USHORT)2)
+#define BRC_RIGHT ((USHORT)3)
+#define BRC_ANZ ((USHORT)BRC_RIGHT-BRC_TOP+1)
+
+// Die BRC-struktur fuer 1.0 versionen von word sind verschieden von
+// denen der folgenden versionen. diese werden zum glueck aber auch
+// von anderen sprms abgerufen.
+// SH: Ab sofort alle 4 Umrandungen ueber nur 1 Klasse.
+class Ww1SingleSprmPBrc10 : public Ww1SingleSprmPBrc {
+ USHORT nLine; // BRC_TOP, BRC_LEFT, ...
+public:
+ Ww1SingleSprmPBrc10(USHORT nL, sal_Char* sName) :
+ nLine(nL), Ww1SingleSprmPBrc(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmParaSpace : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmParaSpace(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDyaBefore : public Ww1SingleSprmParaSpace {
+public:
+ Ww1SingleSprmPDyaBefore(sal_Char* sName) :
+ Ww1SingleSprmParaSpace(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDyaAfter : public Ww1SingleSprmParaSpace {
+public:
+ Ww1SingleSprmPDyaAfter(sal_Char* sName) :
+ Ww1SingleSprmParaSpace(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDyaLine : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmPDyaLine(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPChgTabsPapx : public Ww1SingleSprmByteSized {
+public:
+ Ww1SingleSprmPChgTabsPapx(sal_Char* sName) :
+ Ww1SingleSprmByteSized(0, sName) {
+ }
+ // Size() ist noch nicht aktiviert !!
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmSGprfIhdt : public Ww1SingleSprmByte {
+public:
+ Ww1SingleSprmSGprfIhdt(sal_Char* sName) :
+ Ww1SingleSprmByte(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmSColumns : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmSColumns(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPFInTable : public Ww1SingleSprmBool {
+public:
+ Ww1SingleSprmPFInTable(sal_Char* sName) :
+ Ww1SingleSprmBool(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPTtp : public Ww1SingleSprmBool {
+public:
+ Ww1SingleSprmPTtp(sal_Char* sName) :
+ Ww1SingleSprmBool(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+ void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTJc : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmTJc(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+//class Ww1SingleSprmTDxaLeft : public Ww1SingleSprmWord {
+//public:
+// Ww1SingleSprmTDxaLeft(sal_Char* sName) :
+// Ww1SingleSprmWord(sName) {
+// }
+// void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+//};
+
+class Ww1SingleSprmTDxaGapHalf : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmTDxaGapHalf(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTDefTable10 : public Ww1SingleSprmWordSized {
+public:
+ Ww1SingleSprmTDefTable10(sal_Char* sName) :
+ Ww1SingleSprmWordSized(0, sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTDyaRowHeight : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmTDyaRowHeight(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+// Klassendefinitionen fuer Tabellen-Fastsave-Attribute
+// Da wir kein Fastsave unterstuetzen, brauchen wir's nicht
+
+#if 0
+
+class Ww1SingleSprmTInsert : public Ww1SingleSprm {
+public:
+ Ww1SingleSprmTInsert(sal_Char* sName) :
+ Ww1SingleSprm(4, sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTDelete : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmTDelete(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTDxaCol : public Ww1SingleSprm {
+public:
+ Ww1SingleSprmTDxaCol(sal_Char* sName) :
+ Ww1SingleSprm(4, sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTMerge : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmTMerge(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTSplit : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmTSplit(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmTSetBrc10 : public Ww1SingleSprm {
+public:
+ Ww1SingleSprmTSetBrc10(sal_Char* sName) :
+ Ww1SingleSprm(5, sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+#endif // 0
+
+// Klassendefinitionen fuer Apos ( == Flys )
+
+class Ww1SingleSprmPpc : public Ww1SingleSprmByte {
+public:
+ Ww1SingleSprmPpc(sal_Char* sName) :
+ Ww1SingleSprmByte(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDxaAbs : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmPDxaAbs(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDyaAbs : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmPDyaAbs(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPDxaWidth : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmPDxaWidth(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+class Ww1SingleSprmPFromText : public Ww1SingleSprmWord {
+public:
+ Ww1SingleSprmPFromText(sal_Char* sName) :
+ Ww1SingleSprmWord(sName) {
+ }
+ void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
+};
+
+////////////////////////////////////////////////////////////////// Sprm
+//
+// der tatsaechlich in der datei auftretende datentyp Sprm
+//
+class Ww1Sprm
+{
+ BOOL ReCalc();
+protected:
+ static Ww1SingleSprm* aTab[256];
+ static void InitTab();
+ Ww1SingleSprm& GetTab(USHORT nId) {
+ if (aTab[0] == 0)
+ InitTab();
+ return *aTab[nId]; }
+ BYTE* p;
+ USHORT nCountBytes;
+ BOOL bOK;
+ USHORT* pArr;
+ USHORT count;
+// ohne Token, mit laengen-byte/word
+ USHORT GetSize(BYTE nId, BYTE* pSprm);
+// mit Token und LaengenByte
+ USHORT GetSizeBrutto(BYTE* pSprm) {
+ BYTE nId = *pSprm++;
+ return GetSize(nId, pSprm) + 1; }
+// gibt fuer nTh element id, size & zeiger auf daten:
+// BOOL Fill(USHORT, BYTE&, USHORT&, BYTE*&);
+public:
+// SH: brauche ich public
+// gibt fuer nTh element id, size & zeiger auf daten:
+ BOOL Fill(USHORT, BYTE&, USHORT&, BYTE*&);
+
+ Ww1Sprm(BYTE*, USHORT);
+ Ww1Sprm(SvStream&, ULONG);
+ ~Ww1Sprm();
+ friend ostream& operator <<(ostream&, Ww1Sprm&);
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Start(Ww1Shell&, Ww1Manager&, USHORT);
+ void Stop(Ww1Shell&, Ww1Manager&);
+ BOOL IsUsed() {
+ return nCountBytes != 255; }
+ USHORT Count() {
+ return count; }
+ BOOL GetError() {
+ return !bOK; }
+ static void DeinitTab();
+};
+
+/////////////////////////////////////////////////////////////// Picture
+//
+// der wrapper um den datentyp PIC, eine struktur, die am beginn eines
+// bild-dateinamens oder eines eingebetteten bildes steht.
+//
+class Ww1Picture
+{
+ BOOL bOK;
+ W1_PIC* pPic;
+public:
+ Ww1Picture(SvStream&, ULONG);
+ ~Ww1Picture() {
+ }
+ BOOL GetError() {
+ return !bOK; }
+ friend ostream& operator <<(ostream&, Ww1Picture&);
+ void Out(Ww1Shell&, Ww1Manager&);
+ void WriteBmp(SvStream&);
+};
+
+/////////////////////////////////////////////////////////////////// Plc
+//
+// eine der wichtigen array-strukturen der ww-dateien. sie beinhalten
+// n+1 dateipositionen und n attribute, die zwischen den
+// dateipositionen gelten.
+//
+class Ww1Plc
+{
+ BYTE* p;
+ USHORT nCountBytes;
+ USHORT iMac;
+ USHORT nItemSize;
+ BOOL bOK;
+protected:
+ Ww1Fib& rFib;
+ BYTE* GetData(USHORT);
+public:
+ Ww1Plc(Ww1Fib&, ULONG, USHORT, USHORT);
+ ~Ww1Plc();
+ friend ostream& operator <<(ostream&, Ww1Plc&);
+ ULONG Where(USHORT); // wie im jeweiligen plc
+ void Seek(ULONG, USHORT&);
+ void Fill(USHORT nIndex, ULONG& begin, ULONG& end) {
+ begin = Where(nIndex);
+ end = Where(nIndex+1); }
+ USHORT Count() {
+ return iMac; }
+ BOOL GetError() {
+ return !bOK; }
+};
+
+// Size Tabs from Sven:
+// CHP, PAP, SEP, HED, FNR, FNT
+//Plc 2, 2, 6, 0, 2, 0
+//Fkp 1, 1, 0, 0, 0, 0
+
+/////////////////////////////////////////////////////////// PlcGlossary
+class Ww1PlcGlossary : public Ww1Plc
+{
+public:
+ Ww1PlcGlossary(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcfglsyGet(),
+ rFib.GetFIB().cbPlcfglsyGet(), 0) {
+ }
+};
+
+////////////////////////////////////////////////////// PlcAnnotationRef
+class Ww1PlcAnnotationRef : public Ww1Plc
+{
+public:
+ Ww1PlcAnnotationRef(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcfandRefGet(),
+ rFib.GetFIB().cbPlcfandRefGet(), 0) {
+ }
+};
+
+////////////////////////////////////////////////////// PlcAnnotationTxt
+class Ww1PlcAnnotationTxt : public Ww1Plc
+{
+public:
+ Ww1PlcAnnotationTxt(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcfandTxtGet(),
+ rFib.GetFIB().cbPlcfandTxtGet(), 0) {
+ }
+};
+
+///////////////////////////////////////////////////////// PlcAnnotation
+class Ww1Annotation {
+ Ww1PlcAnnotationRef aRef;
+ Ww1PlcAnnotationTxt aTxt;
+public:
+ Ww1Annotation(Ww1Fib& rFib) :
+ aRef(rFib),
+ aTxt(rFib) {
+ }
+ friend ostream& operator <<(ostream&, Ww1Annotation&);
+};
+
+//////////////////////////////////////////////////////////////// PlcSep
+class Ww1PlcSep : public Ww1Plc
+{
+public:
+ Ww1PlcSep(Ww1Fib& rFib):
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcfsedGet(),
+ rFib.GetFIB().cbPlcfsedGet(), 6) {
+ }
+ friend ostream& operator <<(ostream&, Ww1PlcSep&);
+};
+
+//////////////////////////////////////////////////////////////// PlcChp
+class Ww1PlcChp : public Ww1Plc
+{
+public:
+ Ww1PlcChp(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcfbteChpxGet(),
+ rFib.GetFIB().cbPlcfbteChpxGet(), 2) {
+ }
+ friend ostream& operator <<(ostream&, Ww1PlcChp&);
+};
+
+//////////////////////////////////////////////////////////////// PlcPap
+class Ww1PlcPap : public Ww1Plc
+{
+public:
+ Ww1PlcPap(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcfbtePapxGet(),
+ rFib.GetFIB().cbPlcfbtePapxGet(), 2) {
+ }
+ friend ostream& operator <<(ostream&, Ww1PlcPap&);
+};
+
+//////////////////////////////////////////////////////// PlcFootnoteRef
+class Ww1PlcFootnoteRef : public Ww1Plc
+{
+public:
+ Ww1PlcFootnoteRef(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcffndRefGet(),
+ rFib.GetFIB().cbPlcffndRefGet(), 2) {
+ }
+ friend ostream& operator <<(ostream&, Ww1PlcFootnoteRef&);
+};
+
+//////////////////////////////////////////////////////// PlcFootnoteTxt
+class Ww1PlcFootnoteTxt : public Ww1Plc
+{
+public:
+ Ww1PlcFootnoteTxt(Ww1Fib& rFib) :
+ Ww1Plc(rFib, rFib.GetFIB().fcPlcffndTxtGet(),
+ rFib.GetFIB().cbPlcffndTxtGet(), 0) {
+ }
+ friend ostream& operator <<(ostream&, Ww1PlcFootnoteTxt&);
+};
+
+///////////////////////////////////////////////////////////// PlcFields
+class Ww1PlcFields : public Ww1Plc
+{
+ //USHORT Fill(USHORT, BYTE&, String&, String&, String&);
+public:
+ Ww1PlcFields(Ww1Fib& rFib, ULONG start, USHORT nCountBytes)
+ : Ww1Plc(rFib, start, nCountBytes, 2)
+ {}
+ W1_FLD* GetData(USHORT nIndex)
+ { return (W1_FLD*)Ww1Plc::GetData(nIndex); }
+ ULONG Where(USHORT nIndex) // absolut im file
+ { return Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet(); }
+ friend ostream& operator <<(ostream&, Ww1PlcFields&);
+};
+
+///////////////////////////////////////////////////////////// PlcBookmarks
+class Ww1StringList
+{
+ sal_Char** pIdxA;
+ USHORT nMax;
+public:
+ Ww1StringList( SvStream& rSt, ULONG nFc, USHORT nCb );
+ ~Ww1StringList()
+ { if( pIdxA ) { delete pIdxA[0]; delete pIdxA; } }
+ const String GetStr( USHORT nNum ) const;
+ USHORT Count() const { return nMax; }
+ BOOL GetError() const { return (nMax != 0) && !pIdxA; }
+};
+
+class Ww1PlcBookmarkTxt: public Ww1StringList
+{
+public:
+ Ww1PlcBookmarkTxt(Ww1Fib& rFib) :
+ Ww1StringList( rFib.GetStream(), rFib.GetFIB().fcSttbfbkmkGet(),
+ rFib.GetFIB().cbSttbfbkmkGet() )
+ {}
+};
+
+class Ww1PlcBookmarkPos : public Ww1Plc
+{
+// USHORT Fill(USHORT, BYTE&, String&, String&, String&);
+public:
+ Ww1PlcBookmarkPos(Ww1Fib& rFib, ULONG start, USHORT nCountBytes, BOOL bEnd)
+ : Ww1Plc(rFib, start, nCountBytes, (bEnd) ? 0 : 2)
+ {}
+
+ BYTE* GetData(USHORT nIndex) { return Ww1Plc::GetData(nIndex); }
+ // Position als CP
+ ULONG WhereCP(USHORT nIndex) { return Ww1Plc::Where(nIndex); }
+ // absolut im file
+ ULONG Where(USHORT nIndex)
+ {
+ return ( nIndex < Count() )
+ ? Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet()
+ : 0xffffffff;
+ }
+// friend ostream& operator <<(ostream&, Ww1PlcBookmarks&);
+};
+
+//////////////////////////////////////////////////////////////// PlcHdd
+class Ww1PlcHdd : public Ww1Plc
+{
+public:
+ Ww1PlcHdd(Ww1Fib& rFib)
+ : Ww1Plc(rFib, rFib.GetFIB().fcPlcfhddGet(),
+ rFib.GetFIB().cbPlcfhddGet(), 0)
+ {}
+};
+
+/////////////////////////////////////////////////////////////////// Fkp
+//
+// aehnlich den plcs aufgebaute arrays, die sich auf eine groesze von
+// 512 byte beschraenken.
+//
+class Ww1Fkp
+{
+protected:
+ BYTE aFkp[512];
+ USHORT nItemSize;
+ BOOL bOK;
+ BYTE* GetData(USHORT);
+public:
+ Ww1Fkp(SvStream&, ULONG, USHORT);
+ friend ostream& operator <<(ostream&, Ww1Fkp&);
+ USHORT Count() const { return SVBT8ToByte(aFkp+511); }
+ ULONG Where(USHORT); // wie im entsprechenden fkp
+};
+
+//////////////////////////////////////////////////////////////// FkpPap
+class Ww1FkpPap : public Ww1Fkp
+{
+public:
+ Ww1FkpPap(SvStream& rStream, ULONG ulFilePos)
+ : Ww1Fkp(rStream, ulFilePos, 1)
+ {}
+ friend ostream& operator <<(ostream&, Ww1FkpPap&);
+ BOOL Fill(USHORT, BYTE*&, USHORT&, ULONG&, ULONG&);
+ BOOL Fill(USHORT, BYTE*&, USHORT&);
+};
+
+//////////////////////////////////////////////////////////////// FkpChp
+class Ww1FkpChp : public Ww1Fkp
+{
+#ifdef DUMP
+ SvStream& rStream;
+ SvStream& GetStream() { return rStream; }
+#endif
+public:
+ Ww1FkpChp(SvStream& rStream, ULONG ulFilePos)
+ : Ww1Fkp(rStream, ulFilePos, 1)
+#ifdef DUMP
+ , rStream(rStream)
+#endif
+ {}
+
+ friend ostream& operator <<(ostream&, Ww1FkpChp&);
+ BOOL Fill(USHORT, W1_CHP&, ULONG&, ULONG&);
+ BOOL Fill(USHORT, W1_CHP&);
+};
+
+////////////////////////////////////////////////////////////// SprmPapx
+class Ww1SprmPapx : public Ww1Sprm
+{
+ W1_PAPX aPapx;
+ BYTE* Sprm(BYTE* p, USHORT nSize);
+ USHORT SprmSize(BYTE* p, USHORT nSize);
+public:
+ Ww1SprmPapx(BYTE* p, USHORT nSize);
+ friend ostream& operator <<(ostream&, Ww1SprmPapx&);
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&);
+};
+
+/////////////////////////////////////////////////////////////// SprmSep
+class Ww1SprmSep : public Ww1Sprm
+{
+public:
+ Ww1SprmSep(Ww1Fib& rFib, ULONG ulFilePos)
+ : Ww1Sprm(rFib.GetStream(), ulFilePos)
+ {}
+ friend ostream& operator <<(ostream&, Ww1SprmSep&);
+};
+
+///////////////////////////////////////////////////////////////// Assoc
+class Ww1Assoc
+{
+ enum fields { FileNext, Dot, Title, Subject, KeyWords, Comments,
+ Author, LastRevBy, DataDoc, HeaderDoc, Criteria1, Criteria2,
+ Criteria3, Criteria4, Criteria5, Criteria6, Criteria7, MaxFields };
+
+ Ww1Fib& rFib;
+ sal_Char* pBuffer;
+ sal_Char* pStrTbl[ MaxFields ];
+ BOOL bOK;
+
+ String GetStr(USHORT);
+
+public:
+ Ww1Assoc(Ww1Fib&);
+ ~Ww1Assoc() { delete pBuffer; }
+ BOOL GetError() const { return !bOK; }
+ friend ostream& operator <<(ostream&, Ww1Assoc&);
+ void Out(Ww1Shell&);
+};
+
+////////////////////////////////////////////////////////// HeaderFooter
+//
+// Header/Footer/Footnoteseparators sind einer nach dem naechsten in
+// einem eigenen text gespeichert. ein plc trennt diesen text in
+// einzelne teile. diese werden durchnummeriert als ihdd. nun gibt es
+// 9 verschiedene funktionen fuer diese texte. wird eine davon
+// angefordert, ist es der erste, beim naechstern der 2 ihdd und so
+// weiter. welcher textteil also welcher typ sein wird laeszt sich
+// nur bei sequenziellem lesen der datei bestimmen. die 9 typen sind:
+// fusznoten-trenner, folge-fusznoten-trenner, folge-fusznoten-notiz,
+// gerade-seiten kopfzeilen, ungerade seiten kopfzeilen, dto 2*
+// fuszzeilen, kopf & fuszzeilen, wenn erste seite andere zeilen hat.
+// HeaderFooter merkt sich fuer jede der 9 die momentane einstellung
+// (jedoch nicht die alten) und den naechstvergebbaren ihdd. ist ein
+// teil nicht vorhanden bekommt er den wert 0xffff.
+//
+class Ww1HeaderFooter : public Ww1PlcHdd
+{
+ USHORT nextIhdd; // naechster textteil im HddText
+ USHORT nFtnSep; // fusznoten trenner
+ USHORT nFtnFollowSep; // folge fusznoten trenner
+ USHORT nFtnNote; // folgefunsznotennotiz
+ USHORT nEvenHeadL; // kopfzeilen grader seiten
+ USHORT nOddHeadL; // kopfzeilen ungrader seiten
+ USHORT nEvenFootL; // fuszzeilen grader seiten
+ USHORT nOddFootL; // fuszzeilen ungerader seiten
+ USHORT nFirstHeadL; // kopfzeilen der ersten seite
+ USHORT nFirstFootL; // fuszzeilen der ersten seite
+ enum HeaderFooterMode {
+ None, FtnSep, FtnFollowSep, FtnNote, EvenHeadL, OddHeadL,
+ EvenFootL, OddFootL, FirstHeadL, MaxHeaderFooterMode
+ } eHeaderFooterMode;
+
+public:
+ Ww1HeaderFooter(Ww1Fib& rFib, USHORT grpfIhdt)
+ : Ww1PlcHdd(rFib),
+ nextIhdd(0),
+ nFtnSep(0xffff),
+ nFtnFollowSep(0xffff),
+ nFtnNote(0xffff),
+ nEvenHeadL(0xffff),
+ nOddHeadL(0xffff),
+ nEvenFootL(0xffff),
+ nOddFootL(0xffff),
+ nFirstHeadL(0xffff),
+ nFirstFootL(0xffff),
+ eHeaderFooterMode(None)
+ {
+ if (grpfIhdt & 0x0001) nFtnSep = nextIhdd++;
+ if (grpfIhdt & 0x0002) nFtnFollowSep = nextIhdd++;
+ if (grpfIhdt & 0x0004) nFtnNote = nextIhdd++;
+ }
+// ~Ww1HeaderFooter() {}
+ void SetGrpfIhdt(USHORT grpfIhdt)
+ {
+ if (grpfIhdt & 0x0001) nEvenHeadL = nextIhdd++;
+ if (grpfIhdt & 0x0002) nOddHeadL = nextIhdd++;
+ if (grpfIhdt & 0x0004) nEvenFootL = nextIhdd++;
+ if (grpfIhdt & 0x0008) nOddFootL = nextIhdd++;
+ if (grpfIhdt & 0x0010) nFirstHeadL = nextIhdd++;
+ if (grpfIhdt & 0x0020) nFirstFootL = nextIhdd++;
+ DBG_ASSERT(nextIhdd<=Count(), "Ww1HeaderFooter");
+ }
+ BOOL operator++(int)
+ {
+ BOOL bRet = TRUE;
+ eHeaderFooterMode = (HeaderFooterMode)((short)eHeaderFooterMode + 1);
+ if( eHeaderFooterMode == MaxHeaderFooterMode)
+ {
+ eHeaderFooterMode = None;
+ bRet = FALSE;
+ }
+ return bRet;
+ }
+ BOOL FillFtnSep(ULONG& begin, ULONG& end)
+ {
+ if (nFtnSep == 0xffff)
+ return FALSE;
+ Fill(nFtnSep, begin, end);
+ return TRUE;
+ }
+ BOOL FillFtnFollowSep(ULONG& begin, ULONG& end)
+ {
+ if (nFtnFollowSep == 0xffff)
+ return FALSE;
+ Fill(nFtnFollowSep, begin, end);
+ return TRUE;
+ }
+ BOOL FillFtnNote(ULONG& begin, ULONG& end)
+ {
+ if (nFtnNote == 0xffff)
+ return FALSE;
+ Fill(nFtnNote, begin, end);
+ return TRUE;
+ }
+ BOOL FillEvenHeadL(ULONG& begin, ULONG& end)
+ {
+ if (nEvenHeadL == 0xffff)
+ return FALSE;
+ Fill(nEvenHeadL, begin, end);
+ return TRUE;
+ }
+ BOOL FillOddHeadL(ULONG& begin, ULONG& end)
+ {
+ if (nOddHeadL == 0xffff)
+ return FALSE;
+ Fill(nOddHeadL, begin, end);
+ return TRUE;
+ }
+ BOOL FillEvenFootL(ULONG& begin, ULONG& end)
+ {
+ if (nEvenFootL == 0xffff)
+ return FALSE;
+ Fill(nEvenFootL, begin, end);
+ return TRUE;
+ }
+ BOOL FillOddFootL(ULONG& begin, ULONG& end)
+ {
+ if (nOddFootL == 0xffff)
+ return FALSE;
+ Fill(nOddFootL, begin, end);
+ return TRUE;
+ }
+ BOOL FillFirstHeadL(ULONG& begin, ULONG& end)
+ {
+ if (nFirstHeadL == 0xffff)
+ return FALSE;
+ Fill(nFirstHeadL, begin, end);
+ return TRUE;
+ }
+ BOOL FillFirstFootL(ULONG& begin, ULONG& end)
+ {
+ if (nFirstFootL == 0xffff)
+ return FALSE;
+ Fill(nFirstFootL, begin, end);
+ return TRUE;
+ }
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
+};
+
+//////////////////////////////////////////////////////////////// Fields
+class Ww1Fields : public Ww1PlcFields
+{
+ USHORT nPlcIndex;
+ String sErgebnis; // das von word errechnete ergebniss
+ SwField* pField;
+ ULONG Where(USHORT nIndex) // innerhalb des textes
+ { return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
+
+public:
+ Ww1Fields(Ww1Fib& rFib, ULONG ulFilePos, USHORT nCountBytes)
+ : Ww1PlcFields(rFib, ulFilePos, nCountBytes), nPlcIndex(0), pField(0)
+ {}
+// ~Ww1Fields() {}
+ // innerhalb des textes
+ ULONG Where() { return Where(nPlcIndex); }
+ void operator++(int)
+ {
+ DBG_ASSERT(nPlcIndex+1 <= Count(), "Ww1Fields");
+ nPlcIndex++;
+ }
+ void Seek(ULONG ulNew) { Ww1PlcFields::Seek(ulNew, nPlcIndex); }
+ W1_FLD* GetData()
+ {
+ DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
+ return Ww1PlcFields::GetData(nPlcIndex);
+ }
+ ULONG GetLength();
+ friend ostream& operator <<(ostream&, Ww1Manager&);
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
+ void Out(Ww1Shell&, Ww1Manager&, USHORT=0);
+};
+
+class Ww1TextFields : public Ww1Fields
+{
+public:
+ Ww1TextFields(Ww1Fib& rFib)
+ : Ww1Fields(rFib, rFib.GetFIB().fcPlcffldMomGet(),
+ rFib.GetFIB().cbPlcffldMomGet())
+ {}
+};
+
+class Ww1FootnoteFields : public Ww1Fields
+{
+public:
+ Ww1FootnoteFields(Ww1Fib& rFib)
+ : Ww1Fields(rFib, rFib.GetFIB().fcPlcffldFtnGet(),
+ rFib.GetFIB().cbPlcffldFtnGet())
+ {}
+};
+
+class Ww1HeaderFooterFields : public Ww1Fields
+{
+public:
+ Ww1HeaderFooterFields(Ww1Fib& rFib)
+ : Ww1Fields(rFib, rFib.GetFIB().fcPlcffldHdrGet(),
+ rFib.GetFIB().cbPlcffldHdrGet())
+ {}
+};
+
+class Ww1MacroFields : public Ww1Fields
+{
+public:
+ Ww1MacroFields(Ww1Fib& rFib)
+ : Ww1Fields(rFib, rFib.GetFIB().fcPlcffldMcrGet(),
+ rFib.GetFIB().cbPlcffldMcrGet())
+ {}
+};
+
+//////////////////////////////////////////////////////////////// Bookmarks
+class Ww1Bookmarks
+{
+ Ww1PlcBookmarkTxt aNames;
+ Ww1PlcBookmarkPos* pPos[2];
+ Ww1Fib& rFib;
+
+ USHORT nPlcIdx[2];
+ USHORT nIsEnd;
+ BOOL bOK;
+// ULONG Where(USHORT nIndex) { // innerhalb des textes
+// return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
+public:
+ Ww1Bookmarks(Ww1Fib& rFib);
+ ~Ww1Bookmarks()
+ {
+ delete pPos[1];
+ delete pPos[0];
+ }
+ ULONG Where() const { return pPos[nIsEnd]->WhereCP(nPlcIdx[nIsEnd]); }
+ void operator++(int);
+ BOOL GetError() const { return !bOK; }
+ long GetHandle() const;
+ BOOL GetIsEnd() const { return ( nIsEnd ) ? TRUE : FALSE; }
+ const String GetName() const;
+ long Len() const;
+ friend ostream& operator <<(ostream&, Ww1Bookmarks&);
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
+ void Out(Ww1Shell&, Ww1Manager&, USHORT=0);
+};
+
+///////////////////////////////////////////////////////////// Footnotes
+class Ww1Footnotes : public Ww1PlcFootnoteRef
+{
+ USHORT nPlcIndex;
+ Ww1PlcFootnoteTxt aText;
+ BOOL bStarted;
+public:
+ Ww1Footnotes(Ww1Fib& rFib)
+ : Ww1PlcFootnoteRef(rFib), nPlcIndex(0), aText(rFib), bStarted(FALSE)
+ {}
+// ~Ww1Footnotes() {}
+ // innerhalb des textes
+ ULONG Where()
+ {
+ ULONG ulRet = 0xffffffff;
+ if (Count())
+ ulRet = Ww1PlcFootnoteRef::Where(nPlcIndex);
+ return ulRet;
+ }
+ void operator++(int)
+ {
+ DBG_ASSERT(nPlcIndex+1 <= Count(), "Ww1Footnotes");
+ nPlcIndex++;
+ }
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
+};
+
+/////////////////////////////////////////////////////////////////// Sep
+class Ww1Sep : public Ww1PlcSep
+{
+ USHORT nPlcIndex;
+ Ww1HeaderFooter aHdd;
+public:
+ Ww1Sep(Ww1Fib& rFib, USHORT grpfIhdt)
+ : Ww1PlcSep(rFib), aHdd(rFib, grpfIhdt),nPlcIndex(0)
+ {}
+// ~Ww1Sep() {}
+
+ Ww1HeaderFooter& GetHdd() { return aHdd; }
+ void operator++(int) { nPlcIndex++; }
+ BYTE* GetData() { return Ww1PlcSep::GetData(nPlcIndex); }
+ // innerhalb des textes
+ ULONG Where() { return Ww1PlcSep::Where(nPlcIndex); }
+ void SetGrpfIhdt(BYTE grpfIhdt)
+ {
+ GetHdd().SetGrpfIhdt(grpfIhdt);
+// GetHdd().Start(rOut, rMan);
+ }
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
+ { aHdd.Stop(rOut, rMan, c); }
+};
+
+/////////////////////////////////////////////////////////////////// Pap
+class Ww1Pap : public Ww1PlcPap
+{
+ USHORT nPlcIndex;
+ USHORT nPushedPlcIndex;
+ USHORT nFkpIndex;
+ USHORT nPushedFkpIndex;
+ ULONG ulOffset;
+ Ww1FkpPap* pPap;
+
+ BOOL FindSprm(USHORT nId, BYTE* pStart, BYTE* pEnd);
+ void UpdateIdx()
+ {
+ if (pPap && nFkpIndex >= pPap->Count() )
+ {
+ delete pPap;
+ pPap = NULL;
+ nPlcIndex++;
+ }
+ if( !pPap )
+ Where();
+ }
+ BOOL HasId0(USHORT nId);
+
+public:
+ Ww1Pap(Ww1Fib& rFib);
+ ~Ww1Pap() { delete pPap; }
+ ULONG Where( BOOL bSetIndex = TRUE ); // innerhalb des textes
+ void operator++(int);
+ BOOL FillStart(BYTE*& p, USHORT& nSize)
+ {
+ UpdateIdx();
+ return pPap->Fill(nFkpIndex, p, nSize);
+ }
+ BOOL FillStop(BYTE*& p, USHORT& nSize)
+ {
+ return nFkpIndex ? pPap->Fill(nFkpIndex-1, p, nSize) : FALSE;
+ }
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
+ void Seek(ULONG);
+ void Push(ULONG ulOffset = 0)
+ {
+ DBG_ASSERT(!Pushed(), "Ww1Pap");
+ nPushedPlcIndex = nPlcIndex;
+ nPushedFkpIndex = nFkpIndex;
+ Seek(ulOffset);
+ this->ulOffset = ulOffset;
+ delete pPap;
+ pPap = NULL;
+ }
+ BOOL Pushed()
+ {
+ return nPushedPlcIndex != 0xffff;
+ }
+ void Pop()
+ {
+ DBG_ASSERT(Pushed(), "Ww1Pap");
+ ulOffset = 0;
+ nPlcIndex = nPushedPlcIndex;
+ nFkpIndex = nPushedFkpIndex;
+ nPushedPlcIndex = 0xffff;
+ nPushedFkpIndex = 0xffff;
+ delete pPap;
+ pPap = NULL;
+ Where( FALSE );
+ }
+ BOOL HasId(USHORT nId);
+ BOOL NextHas(USHORT nId);
+};
+
+/////////////////////////////////////////////////////////////////// Chp
+class Ww1Chp : public Ww1PlcChp
+{
+ USHORT nPlcIndex;
+ USHORT nPushedPlcIndex;
+ USHORT nFkpIndex;
+ USHORT nPushedFkpIndex;
+ ULONG ulOffset;
+ Ww1FkpChp* pChp;
+ void UpdateIdx()
+ {
+ if (pChp && nFkpIndex >= pChp->Count() )
+ {
+ delete pChp;
+ pChp = NULL;
+ nPlcIndex++;
+ }
+ if( !pChp )
+ Where();
+ }
+
+public:
+ Ww1Chp( Ww1Fib& rFib );
+ ~Ww1Chp() { delete pChp; }
+ ULONG Where( BOOL bSetIndex = TRUE ); // innerhalb des textes
+ void operator++(int);
+ BOOL FillStart(W1_CHP& rChp)
+ {
+ UpdateIdx();
+ return pChp->Fill(nFkpIndex, rChp);
+ }
+ BOOL FillStop(W1_CHP& rChp)
+ { return nFkpIndex ? pChp->Fill(nFkpIndex-1, rChp) : FALSE; }
+ void Start(Ww1Shell&, Ww1Manager&);
+ void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
+ void Seek(ULONG);
+ void Push(ULONG ulOffset = 0)
+ {
+ DBG_ASSERT(!Pushed(), "Ww1Chp");
+ nPushedPlcIndex = nPlcIndex;
+ nPushedFkpIndex = nFkpIndex;
+ Seek(ulOffset);
+ this->ulOffset = ulOffset;
+ delete pChp;
+ pChp = NULL;
+ }
+ BOOL Pushed() { return nPushedPlcIndex != 0xffff; }
+ void Pop()
+ {
+ DBG_ASSERT(Pushed(), "Ww1Chp");
+ ulOffset = 0;
+ nPlcIndex = nPushedPlcIndex;
+ nFkpIndex = nPushedFkpIndex;
+ nPushedPlcIndex = 0xffff;
+ nPushedFkpIndex = 0xffff;
+ delete pChp;
+ pChp = NULL;
+ Where( FALSE );
+ }
+};
+
+/////////////////////////////////////////////////////////////// Manager
+//
+// zentraler aufhaenger der ww-seite des filters, konstruiert aus dem
+// inputstream (ww-datei) enthaelt er alles, was noetig ist, um in die
+// shell (pm-seite) gepiped zu werden.
+//
+class Ww1Manager
+{
+ BOOL bOK;
+ BOOL bInTtp;
+ BOOL bInStyle;
+ BOOL bStopAll;
+ Ww1Fib aFib;
+ Ww1Dop aDop;
+ Ww1Fonts aFonts;
+// ab jetzt alles paarig, fuer 'pushed':
+ Ww1DocText aDoc;
+ Ww1PlainText* pDoc;
+ ULONG ulDocSeek;
+ ULONG* pSeek;
+ Ww1TextFields aFld;
+ Ww1Fields* pFld;
+// selbst 'push'bar:
+ Ww1Chp aChp;
+ Ww1Pap aPap;
+// nicht in textbereichen vorhanden, wenn ge'pushed'
+ Ww1Footnotes aFtn;
+ Ww1Bookmarks aBooks;
+ Ww1Sep aSep;
+
+ void OutStop( Ww1Shell&, sal_Unicode );
+ void OutStart( Ww1Shell& );
+ void Out(Ww1Shell&, sal_Unicode );
+
+public:
+ Ww1Manager(SvStream& rStrm, ULONG nFieldFlgs);
+ BOOL GetError() const { return !bOK; }
+
+// Fuer Tabellen
+ void SetInTtp(BOOL bSet = TRUE) { bInTtp = bSet; }
+ BOOL IsInTtp() const { return bInTtp; }
+ void SetInStyle(BOOL bSet = TRUE) { bInStyle = bSet; }
+ BOOL IsInStyle() const { return bInStyle; }
+ void SetStopAll(BOOL bSet = TRUE) { bStopAll = bSet; }
+ BOOL IsStopAll() const { return bStopAll; }
+ BOOL HasInTable();
+ BOOL HasTtp();
+ BOOL NextHasTtp();
+ BOOL LastHasTtp();
+
+// Fuer Flys
+ BOOL HasPPc();
+ BOOL HasPDxaAbs();
+
+ Ww1Fib& GetFib() { return aFib; }
+ Ww1PlainText& GetText() { return *pDoc; }
+ Ww1Dop& GetDop() { return aDop; }
+ Ww1Sep& GetSep() { return aSep; }
+ // innerhalb des textes
+ ULONG Where() { return pDoc->Where(); }
+ void Fill( sal_Unicode& rChr ) { pDoc->Out( rChr ); }
+ BYTE Fill( String& rStr, ULONG ulLen)
+ {
+ ulLen += pDoc->Where();
+ return pDoc->Out(rStr, ulLen);
+ }
+ SvxFontItem GetFont(USHORT nFCode);
+ static BOOL IsValidFib(const BYTE*, USHORT);
+ friend Ww1Shell& operator <<(Ww1Shell&, Ww1Manager&);
+ friend ostream& operator <<(ostream&, Ww1Manager&);
+ BOOL Pushed() { return pDoc != &aDoc; }
+ void Pop();
+ void Push0(Ww1PlainText* pDoc, ULONG, Ww1Fields* = 0);
+ void Push1(Ww1PlainText* pDoc, ULONG ulSeek, ULONG ulSeek2 = 0,
+ Ww1Fields* = 0);
+};
+
+/**********************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww1/w1class.hxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.19 2000/09/18 16:04:56 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.18 2000/09/09 12:53:29 willem.vandorp
+ Header and footer replaced
+
+ Revision 1.17 2000/05/11 16:06:48 jp
+ Changes for Unicode
+
+ Revision 1.16 1998/02/19 16:01:14 HJS
+ fuer sh eingechecked
+
+
+ Rev 1.15 19 Feb 1998 17:01:14 HJS
+ fuer sh eingechecked
+
+ Rev 1.12 14 Nov 1997 10:55:28 OS
+ SH-Aenderung fuer Textmarken
+
+ Rev 1.11 09 Oct 1997 14:13:46 JP
+ Aenderungen von SH
+
+ Rev 1.10 03 Sep 1997 14:16:28 SH
+ Flys, Tabellen ok, Style-Abhaengigkeiten u.v.a.m
+
+ Rev 1.9 11 Aug 1997 12:49:26 SH
+ Flys und einfache Tabellen und Tabulatoren
+
+ Rev 1.8 18 Jul 1997 09:31:38 MA
+ Stand von SH, #41738# GPF und Tabellen etwas besser
+
+ Rev 1.5 16 Jun 1997 13:09:04 MA
+ Stand Micheal Dietrich
+
+ Rev 1.4 12 Mar 1997 19:11:24 SH
+ MDT: Progressbar, Pagedesc-Bug, Spalten, Anfang Tabellen u.a.
+
+ Rev 1.3 10 Jan 1997 18:43:58 SH
+ Stabiler und mehr von MDT
+
+ Rev 1.2 28 Nov 1996 18:08:06 SH
+ Schneller Schoener Weiter von MDT
+
+ Rev 1.1 30 Sep 1996 23:22:18 SH
+ neu von MDA
+
+
+**********************************************************************/
diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx
new file mode 100644
index 000000000000..c547b39315dd
--- /dev/null
+++ b/sw/source/filter/ww1/w1filter.cxx
@@ -0,0 +1,2433 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1filter.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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#include <tools/solar.h>
+#ifndef _SVX_PAPERINF_HXX
+#include <svx/paperinf.hxx>
+#endif
+#ifndef _FILTER_HXX //autogen
+#include <svtools/filter.hxx>
+#endif
+#ifndef _SFXDOCINF_HXX //autogen
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _GRAPH_HXX //autogen
+#include <vcl/graph.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_CNTRITEM_HXX //autogen
+#include <svx/cntritem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_WRLMITEM_HXX //autogen
+#include <svx/wrlmitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx>
+#endif
+#ifndef _REFFLD_HXX
+#include <reffld.hxx>
+#endif
+#ifndef _EXPFLD_HXX
+#include <expfld.hxx>
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _FTNINFO_HXX
+#include <ftninfo.hxx>
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx> // class SwSection
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _W1PAR_HXX
+#include <w1par.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx>
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc>
+#endif
+
+#define MAX_FIELDLEN 64000
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// hier stehen die methoden operator<<, Out, Start und Stop mit
+// folgender Bedeutung: wenn moeglich wird die information aus dem
+// dokument per
+// operator<<()
+// in die shell uebertragen. sind jedoch weitere parameter noetig
+// wurde der name
+// Out()
+// gewaehlt. ist ein bereich zu kennzeichnen (zB bei attributen
+// von/bis), heissen die methoden
+// Start(), Stop()
+// alle diese methoden stehen in diesem modul, das fuer den filter,
+// jedoch nicht fuer den dumper noetig ist. und da alle regeln ihre
+// ausnahme haben: hier stehen auch methoden, die aus anderen gruenden
+// fuer den dumper sinnlos sind, zB wenn sie auf sv-strukturen beruhen
+// wie zB GetFont() auf SvxFontItem.
+//
+
+/////////////////////////////////////////////////////////////// Manager
+Ww1Shell& operator <<(Ww1Shell& rOut, Ww1Manager& This)
+{
+ // verhindern, das bei rekusivem aufruf dies mehrfach passiert:
+ if (!This.Pushed())
+ {
+ { // der wird nur temporaer gebraucht:
+ This.SetInStyle( TRUE );
+ Ww1StyleSheet(This.aFib).Out(rOut, This);
+ This.SetInStyle( FALSE );
+ }
+ { // dieser auch:
+ Ww1Assoc(This.aFib).Out(rOut);
+ }
+ // dieser nicht, der ist bereits member:
+ This.aDop.Out(rOut);
+ // Jetzt entscheiden, wie Seitenvorlagen erzeugt werden
+ if (This.GetSep().Count() <= 1)
+ rOut.SetUseStdPageDesc();
+ }
+ // und jetzt das eigentliche dok:
+ sal_Unicode cUnknown = ' ';
+ while (*This.pSeek < This.pDoc->Count())
+ {
+ // ausgabe des ProgressState nur, wenn im haupttext, da sonst
+ // nicht bestimmt werden kann, wie weit wir sind:
+ if (!This.Pushed())
+ ::SetProgressState(This.Where() * 100 / This.pDoc->Count(),
+ rOut.GetDoc().GetDocShell());
+ // hier werden abwechselnd die attribute und die zeichen in die
+ // shell gepumpt. die positionen werden durch das lesen der
+ // zeichen aus dem manager hoch- gezaehlt. erst alle attribute:
+ This.Out(rOut, cUnknown);
+ // das textdocument pDoc ist ein Ww1PlainText, dessen Out()
+ // methode solange ausgibt, bis entweder ein sonderzeichen
+ // auftaucht oder die anzahl der auszugebenden zeichen erreicht
+ // ist:
+ cUnknown = This.pDoc->Out(rOut, *This.pSeek);
+ }
+ This.SetStopAll(TRUE);
+ This.OutStop(rOut, cUnknown); // Damit die Attribute am Ende geschlossen
+ This.SetStopAll(FALSE); // werden
+ return rOut;
+}
+
+void Ww1Manager::OutStop(Ww1Shell& rOut, sal_Unicode cUnknown)
+{
+ // Bookmarks brauchen nicht beendet werden ???
+ if (pFld)
+ pFld->Stop(rOut, *this, cUnknown);
+ if (!Pushed())
+ aFtn.Stop(rOut, *this, cUnknown);
+ if (1)
+ aChp.Stop(rOut, *this, cUnknown);
+ if (1)
+ aPap.Stop(rOut, *this, cUnknown);
+ if (!Pushed())
+ aSep.Stop(rOut, *this, cUnknown);
+}
+
+void Ww1Manager::OutStart( Ww1Shell& rOut )
+{
+// alle attribute, die's brauchen beginnen
+ if (!Pushed())
+ aSep.Start(rOut, *this);
+ if (1)
+ aPap.Start(rOut, *this);
+ if (1)
+ aChp.Start(rOut, *this);
+ if (!Pushed())
+ aFtn.Start(rOut, *this);
+ if (pFld)
+ pFld->Start(rOut, *this);
+ if (!Pushed())
+ aBooks.Start(rOut, *this);
+// bestimmen, wo das naechste Ereigniss ist:
+ ULONG ulEnd = pDoc->Count(); // spaetestens am textende
+ if (!Pushed())
+ if (ulEnd > aSep.Where()) // naechster Sep vorher?
+ ulEnd = aSep.Where();
+ if (1)
+ if (ulEnd > aPap.Where()) // naechster Pap vorher?
+ ulEnd = aPap.Where();
+ if (1)
+ if (ulEnd > aChp.Where()) // naechster Chp vorher?
+ ulEnd = aChp.Where();
+ if (!Pushed())
+ if (ulEnd > aFtn.Where()) // naechster Ftn vorher?
+ ulEnd = aFtn.Where();
+ if (pFld)
+ if (ulEnd > pFld->Where()) // naechster Fld vorher?
+ ulEnd = pFld->Where();
+ if (!Pushed())
+ if (ulEnd > aBooks.Where()) // naechster Bookmark vorher?
+ ulEnd = aBooks.Where();
+ *pSeek = Where(); // momentane position
+ if (*pSeek < ulEnd) // sind wir bereits weiter?
+ *pSeek = ulEnd;
+}
+
+void Ww1Manager::Out(Ww1Shell& rOut, sal_Unicode cUnknown)
+{
+// Je nach modus wird hier mit feldern, fusznoten, zeichenattributen,
+// absatzatributen und sektionen wie folgt verfahren: von allen wird
+// zuallererst die stop-methoden gerufen. stellt das objekt fest, dasz
+// etwas zu beenden ist (natuerlich nicht im ersten durchgang) beendet
+// es dies, ansonsten ist der aufruf wirkungslos. dann werden
+// unbehandelte sonderzeichen augegeben. das werden genauso alle
+// start-methoden gerufen und danach per where festgestellt, an
+// welcher stelle die naechste aktion zu erwarten ist.
+//
+// ist der manager in einem ge'push'ten mode, werden bestimmte
+// elemente ausgeklammert. felder werden wiederum nur in besonderen
+// faellen augeklammert, wenn naemlich bereiche ausgegeben werden, die
+// keine felder enthalten koennen. charakterattribute und
+// paragraphenattribute werden jedoch nie ausgeklammert. die if (1)
+// wurden zur verdeutlichung der einheitlichkeit eingefuegt.
+
+// Erstmal eine Sonderbehandlung fuer Tabellen:
+// die wichtigen Attribute lassen sich am Besten vor Beendigung derselben
+// abfragen.
+// Optimierung: Sie werden nur auf sinnvolle Werte gesetzt, wenn
+// das 0x07-Zeiche ansteht.
+
+ BOOL bLIsTtp = FALSE;
+ BOOL bLHasTtp = FALSE;
+ if( cUnknown == 0x07 )
+ {
+ bLIsTtp = IsInTtp();
+ bLHasTtp = HasTtp();
+ }
+#if 0
+ ULONG uLlMan = Where();
+ BOOL bLStop = IsStopAll();
+ BOOL bLIsT = rOut.IsInTable();
+ BOOL bLHasT = HasInTable();
+ BOOL bLIsTtp = IsInTtp();
+ BOOL bLHasTtp = HasTtp();
+ BOOL bLNextHasTtp = NextHasTtp();
+#endif
+
+ OutStop( rOut, cUnknown ); // Attrs ggfs. beenden
+
+// meta-zeichen interpretieren:
+ if (!Ww1PlainText::IsChar(cUnknown))
+ switch (cUnknown)
+ {
+ case 0x02:
+ // dontknow
+ break;
+ case 0x07: // table
+#if 0
+{
+ ULONG ulMan = Where();
+ BOOL bStop = IsStopAll();
+ BOOL bIsT = rOut.IsInTable();
+ BOOL bHasT = HasInTable();
+ BOOL bIsTtp = IsInTtp();
+ BOOL bHasTtp = HasTtp();
+ BOOL bNextHasTtp = NextHasTtp();
+#endif
+ if (rOut.IsInTable() && HasInTable() && !bLIsTtp && !bLHasTtp){
+// if (rOut.IsInTable() && HasInTable() && !IsInTtp() && !HasTtp()){
+// if (rOut.IsInTable() && HasInTable() && !HasTtp() && !NextHasTtp()){
+// rOut << 'X';
+ rOut.NextTableCell();
+ }else{
+// rOut << 'O';
+ }
+ break;
+ case 0x09: // tab
+ rOut.NextTab();
+ break;
+ case 0x0a: // linefeed
+ rOut.NextParagraph();
+ break;
+ case 0x0b: // linebreak
+ if (rOut.IsInTable())
+// rOut.NextBand(); // war Stuss
+ ;
+ else
+ rOut.NextLine();
+ break;
+ case 0x0d: // carriage return
+ // ignore
+ break;
+ case 0x0c: // pagebreak
+ rOut.NextPage();
+ break;
+ case 0x14: // sectionendchar
+ // ignore here
+ break;
+ default:
+ {
+#ifdef DEBUG
+ char s[200];
+ sprintf(s, "%s(%d) assert (Ww1PlainText::IsChar(c)) failed"
+ ": unknown char 0x%02x", __FILE__, __LINE__, cUnknown);
+ DBG_ERROR(s);
+#endif
+ }
+ }
+
+ OutStart( rOut ); // Attrs ggfs. starten und Naechste Pos berechnen
+}
+
+#if 0
+void Ww1Manager::Out(Ww1Shell& rOut, BYTE cUnknown)
+{
+// Je nach modus wird hier mit feldern, fusznoten, zeichenattributen,
+// absatzatributen und sektionen wie folgt verfahren: von allen wird
+// zuallererst die stop-methoden gerufen. stellt das objekt fest, dasz
+// etwas zu beenden ist (natuerlich nicht im ersten durchgang) beendet
+// es dies, ansonsten ist der aufruf wirkungslos. dann werden
+// unbehandelte sonderzeichen augegeben. das werden genauso alle
+// start-methoden gerufen und danach per where festgestellt, an
+// welcher stelle die naechste aktion zu erwarten ist.
+//
+// ist der manager in einem ge'push'ten mode, werden bestimmte
+// elemente ausgeklammert. felder werden wiederum nur in besonderen
+// faellen augeklammert, wenn naemlich bereiche ausgegeben werden, die
+// keine felder enthalten koennen. charakterattribute und
+// paragraphenattribute werden jedoch nie ausgeklammert. die if (1)
+// wurden zur verdeutlichung der einheitlichkeit eingefuegt.
+ if (pFld)
+ pFld->Stop(rOut, *this, cUnknown);
+ if (!Pushed())
+ aFtn.Stop(rOut, *this, cUnknown);
+ if (1)
+ aChp.Stop(rOut, *this, cUnknown);
+ if (1)
+ aPap.Stop(rOut, *this, cUnknown);
+ if (!Pushed())
+ aSep.Stop(rOut, *this, cUnknown);
+// meta-zeichen interpretieren:
+ if (!Ww1PlainText::IsChar(cUnknown))
+ switch (cUnknown)
+ {
+ case 0x02:
+ // dontknow
+ break;
+ case 0x07: // table
+// hier muesste etwa stehen:
+// ich probiere es mal in den Sprm::Stop von InTable und Ttp
+// if (IsInTable()){
+// if(IsInDummyCell())
+// if (NextInTable())
+// rOut.NextTableRow();
+// else
+// rOut.NextTableCell();
+// rOut.NextTableCell();
+ break;
+ case 0x09: // tab
+ rOut.NextTab();
+ break;
+ case 0x0a: // linefeed
+ rOut.NextParagraph();
+ break;
+ case 0x0b: // linebreak
+ if (IsInTable())
+// rOut.NextBand(); // war Stuss
+ ;
+ else
+ rOut.NextLine();
+ break;
+ case 0x0d: // carriage return
+ // ignore
+ break;
+ case 0x0c: // pagebreak
+ rOut.NextPage();
+ break;
+ case 0x14: // sectionendchar
+ // ignore here
+ break;
+ default:
+ {
+#ifdef DEBUG
+ char s[200];
+ sprintf(s, "%s(%d) assert (Ww1PlainText::IsChar(c)) failed"
+ ": unknown char 0x%02x", __FILE__, __LINE__, cUnknown);
+ DBG_ERROR(s);
+#endif
+ }
+ }
+// alle attribute, die's brauchen beginnen
+ if (!Pushed())
+ aSep.Start(rOut, *this);
+ if (1)
+ aPap.Start(rOut, *this);
+ if (1)
+ aChp.Start(rOut, *this);
+ if (!Pushed())
+ aFtn.Start(rOut, *this);
+ if (pFld)
+ pFld->Start(rOut, *this);
+// bestimmen, wo das naechste Ereigniss ist:
+ ULONG ulEnd = pDoc->Count(); // spaetestens am textende
+ if (!Pushed())
+ if (ulEnd > aSep.Where()) // naechster Sep vorher?
+ ulEnd = aSep.Where();
+ if (1)
+ if (ulEnd > aPap.Where()) // naechster Pap vorher?
+ ulEnd = aPap.Where();
+ if (1)
+ if (ulEnd > aChp.Where()) // naechster Chp vorher?
+ ulEnd = aChp.Where();
+ if (!Pushed())
+ if (ulEnd > aFtn.Where()) // naechster Ftn vorher?
+ ulEnd = aFtn.Where();
+ if (pFld)
+ if (ulEnd > pFld->Where()) // naechster Fld vorher?
+ ulEnd = pFld->Where();
+ *pSeek = Where(); // momentane position
+ if (*pSeek < ulEnd) // sind wir bereits weiter?
+ *pSeek = ulEnd;
+}
+#endif // 0
+
+SvxFontItem Ww1Manager::GetFont(USHORT nFCode)
+{
+ return aFonts.GetFont(nFCode);
+}
+
+void Ww1Manager::Push0(Ww1PlainText* pDoc, ULONG ulSeek, Ww1Fields* pFld)
+{
+ DBG_ASSERT(!Pushed(), "Ww1Manager");
+ this->pDoc = pDoc;
+ pSeek = new ULONG;
+ *pSeek = pDoc->Where();
+ aPap.Push(ulSeek);
+ aChp.Push(ulSeek);
+ this->pFld = pFld;
+}
+
+// ulSeek ist der FC-Abstand zwischen Hauptest-Start und Sondertext-Start
+// ulSeek2 ist der Offset dieses bestimmten Sondertextes im Sondertext-Bereich,
+// also z.B. der Offset des speziellen K/F-Textes
+void Ww1Manager::Push1(Ww1PlainText* pDoc, ULONG ulSeek, ULONG ulSeek2,
+ Ww1Fields* pFld)
+{
+ DBG_ASSERT(!Pushed(), "Ww1Manager");
+ this->pDoc = pDoc;
+ pSeek = new ULONG;
+ *pSeek = pDoc->Where();
+ aPap.Push(ulSeek + ulSeek2);
+ aChp.Push(ulSeek + ulSeek2);
+ if( pFld )
+ pFld->Seek( ulSeek2 );
+ this->pFld = pFld;
+}
+
+void Ww1Manager::Pop()
+{
+ DBG_ASSERT(Pushed(), "Ww1Manager");
+ delete pDoc;
+ pDoc = &aDoc;
+ delete pSeek;
+ pSeek = &ulDocSeek;
+ aChp.Pop();
+ aPap.Pop();
+ delete pFld;
+ pFld = &aFld;
+}
+
+///////////////////////////////////////////////////////////// Bookmarks
+
+void Ww1Bookmarks::Out(Ww1Shell& rOut, Ww1Manager& rMan, USHORT)
+{
+#ifdef DEBUG
+ const String & rN = GetName();
+ long nHandle = GetHandle();
+#endif
+
+ if( GetIsEnd() ){
+ rOut.SetBookEnd( GetHandle() );
+ return;
+ }
+#if 0
+ eBookStatus eB = pB->GetStatus();
+ if( ( eB & BOOK_IGNORE ) != 0 )
+ return 0; // Bookmark zu ignorieren
+#endif
+
+ const String & rName = GetName();
+ if( rName.EqualsAscii( "_Toc", 0, 4 ) ) // "_Toc*" ist ueberfluessig
+ return;
+
+ if( rOut.IsFlagSet( SwFltControlStack::HYPO )
+ && rName.EqualsIgnoreCaseAscii( "FORMULAR" ) )
+ rOut.SetProtect();
+
+ // Fuer UEbersetzung Bookmark -> Variable setzen
+ long nLen = Len();
+ if( nLen > MAX_FIELDLEN )
+ nLen = MAX_FIELDLEN;
+ // Lese Inhalt des Bookmark
+ // geht vermulich auch ueber Ww1PlainText
+ String aVal( rMan.GetText().GetText( Where(), nLen ) );
+
+ // in 2 Schritten, da OS/2 zu doof ist
+ SwFltBookmark aBook( rName, aVal, GetHandle(), FALSE );
+ rOut << aBook;
+// ( eB & BOOK_ONLY_REF ) != 0, TRUE );
+
+// rOut << GetName(); // Test
+}
+
+void Ww1Bookmarks::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+#ifdef DEBUG
+ ULONG ulMan = rMan.Where();
+ ULONG ulBook = Where();
+#endif
+
+ if (rMan.Where() >= Where())
+ {
+ Out(rOut, rMan);
+ (*this)++;
+ }
+}
+
+///////////////////////////////////////////////////////////// Footnotes
+void Ww1Footnotes::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if (rMan.Where() >= Where())
+ {
+ DBG_ASSERT(nPlcIndex < Count(), "WwFootnotes");
+ sal_Unicode c;
+ rMan.Fill(c);
+ DBG_ASSERT(c==0x02, "Ww1Footnotes");
+ if (c==0x02)
+ {
+ Ww1FtnText* pText = new Ww1FtnText(rMan.GetFib());
+ // beginn des textes dieser fusznote:
+ ULONG start = aText.Where(nPlcIndex);
+ pText->Seek(start);
+ // laenge des textes
+ ULONG count = aText.Where(nPlcIndex+1) - start;
+ pText->SetCount(count);
+ // fusznotenkennung sollte das erste byte sein
+ pText->Out(c);
+ DBG_ASSERT(c==0x02, "Ww1Footnotes");
+ count--; // fuer das eben gelesene kenn-byte
+ // fusznoten mode beginnen:
+ rOut.BeginFootnote();
+ bStarted = TRUE;
+ rMan.Push0(pText, pText->Offset(rMan.GetFib()),
+ new Ww1FootnoteFields(rMan.GetFib()));
+ rOut << rMan;
+ rMan.Pop();
+ rOut.EndFootnote();
+ }
+ else
+ (*this)++;
+ }
+}
+
+void Ww1Footnotes::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
+{
+ if (bStarted && rMan.Where() > Where())
+ {
+ DBG_ASSERT(nPlcIndex < Count(), "Ww1Footnotes");
+// DBG_ASSERT(c==0x02, "Ww1Footnotes"); // scheint Stuss zu sein
+ c = ' ';
+ (*this)++;
+ }
+}
+
+//////////////////////////////////////////////////////////////// Fields
+void Ww1Fields::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if (rMan.Where() >= Where()){
+ DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
+ if (GetData()->chGet() == 19)
+ Out(rOut, rMan);
+ else
+ (*this)++; // ignore
+ }
+}
+
+void Ww1Fields::Stop( Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
+{
+ if (rMan.Where() >= Where())
+ {
+ DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
+ if (GetData()->chGet() != 19)
+ {
+ rMan.Fill( c );
+ DBG_ASSERT(c==21, "Ww1Fields");
+ (*this)++;
+ c = ' ';
+ if (pField)
+ // haben wir ein fertiges feld da, das eingefuegt werden soll?
+ {
+ rOut << *pField;
+ delete pField;
+ pField = 0;
+ // das macht der filter so, damit attribute die ueber das feld
+ // gelten auch wirklich eingelesen werden und dem feld
+ // zugeordnet werden.
+ }
+ if (sErgebnis.Len())
+ rOut << sErgebnis;
+ }
+ }
+}
+
+enum WWDateTime{ WW_DONTKNOW = 0x0, WW_DATE = 0x1, WW_TIME = 0x2, WW_BOTH = 0x3 };
+
+static WWDateTime GetTimeDatePara( const String& rForm,
+ SwTimeFormat* pTime = 0,
+ SwDateFormat* pDate = 0 )
+{
+ WWDateTime eDT = WW_BOTH;
+ if( STRING_NOTFOUND == rForm.Search( 'H' )) // H -> 24h
+ {
+ if( pTime )
+ *pTime = TF_SSMM_24;
+ }
+ else if( STRING_NOTFOUND == rForm.Search( 'H' )) // h -> 24h
+ {
+ if( pTime )
+ *pTime = TF_SSMM_12;
+ }
+ else // keine Zeit
+ {
+ eDT = (WWDateTime)( eDT & ~(USHORT)WW_TIME );
+ }
+
+ xub_StrLen nDPos = 0;
+ while( STRING_NOTFOUND != nDPos )
+ {
+ nDPos = rForm.Search( 'M', nDPos ); // M -> Datum
+ if( !nDPos )
+ break;
+ sal_Unicode cPrev = rForm.GetChar( nDPos - 1 );
+ // ignoriere dabei "AM", "aM", "PM", "pM"
+ if( 'a' != cPrev && 'A' != cPrev && 'p' != cPrev && 'P' != cPrev )
+ break;
+ // else search again
+ ++nDPos;
+ }
+
+ if( STRING_NOTFOUND != nDPos ) // Monat -> Datum ?
+ {
+ static SwDateFormat __READONLY_DATA aDateA[32] =
+ {
+ DFF_DMY, DFF_DMMY, DFF_DMYY, DFF_DMMYY,
+ DFF_DMMMY, DFF_DMMMY, DFF_DMMMYY, DFF_DMMMYY,
+ DFF_DDMMY, DFF_DDMMY, DFF_DDMMMYY, DFF_DDMMMYY,
+ DFF_DDMMMY, DFF_DDMMMY, DFF_DDMMMYY, DFF_DDMMMYY,
+ DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
+ DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
+ DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
+ DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY
+ };
+
+ BOOL bHasDay = STRING_NOTFOUND != rForm.Search( 't' ) ||
+ STRING_NOTFOUND != rForm.Search( 'T' ) ||
+ STRING_NOTFOUND != rForm.Search( 'd' ) ||
+ STRING_NOTFOUND != rForm.Search( 'D' );
+
+ BOOL bLongDayOfWeek= STRING_NOTFOUND != rForm.SearchAscii( "tttt" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "TTTT" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "dddd" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "DDDD" );
+
+ BOOL bDayOfWeek = STRING_NOTFOUND != rForm.SearchAscii( "ttt" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "TTT" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "ddd" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "DDD" );
+
+ // M, MM -> numeric month
+ // MMM, MMMM -> text. month
+ BOOL bLitMonth = STRING_NOTFOUND != rForm.SearchAscii( "MMM" );
+ // MMMM -> full month
+ BOOL bFullMonth = STRING_NOTFOUND != rForm.SearchAscii( "MMMM" );
+ // jj, JJ -> 2-col-year
+ // jjjj, JJJJ -> 4-col-year
+ BOOL bFullYear = STRING_NOTFOUND != rForm.SearchAscii( "jjj" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "JJJ" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "yyy" ) ||
+ STRING_NOTFOUND != rForm.SearchAscii( "YYY" );
+
+ USHORT i = ( bLitMonth & 1 )
+ | ( ( bFullYear & 1 ) << 1 )
+ | ( ( bFullMonth & 1 ) << 2 )
+ | ( ( bDayOfWeek & 1 ) << 3 )
+ | ( ( bLongDayOfWeek & 1 ) << 4 );
+ if( pDate )
+ {
+ if( !bHasDay && !bFullMonth )
+ *pDate = DFF_MY;
+ else
+ *pDate = aDateA[i];
+ }
+ }
+ else
+ {
+ eDT = (WWDateTime)( eDT & ~(USHORT)WW_DATE );
+ }
+ return eDT;
+}
+
+
+extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich,
+ USHORT& rSubType, ULONG &rFmt,
+ USHORT nVersion );
+
+void Ww1Fields::Out(Ww1Shell& rOut, Ww1Manager& rMan, USHORT nDepth)
+{
+ String sType; // der typ als string
+ String sFormel; // die formel
+ String sFormat;
+ String sDTFormat; // Datum / Zeit-Format
+ W1_FLD* pData = GetData(); // die an den plc gebunden daten
+ DBG_ASSERT(pData->chGet()==19, "Ww1Fields"); // sollte beginn sein
+
+ sal_Unicode c;
+ rMan.Fill( c );
+ DBG_ASSERT(c==19, "Ww1Fields"); // sollte auch beginn sein
+ if (pData->chGet()==19 && c == 19)
+ {
+ String aStr;
+ c = rMan.Fill( aStr, GetLength() );
+ DBG_ASSERT(Ww1PlainText::IsChar(c), "Ww1Fields");
+ xub_StrLen pos = aStr.Search(' ');
+ // get type out of text
+ sType = aStr.Copy( 0, pos );
+ aStr.Erase( 0, pos );
+ if ( pos != STRING_NOTFOUND )
+ aStr.Erase(0, 1);
+ sFormel += aStr;
+ BYTE rbType = pData->fltGet();
+ do {
+ // solange den formelteil einlesen, bis das feld entweder
+ // zuende ist oder der ergebnisteil beginnt. dabei koennen
+ // natuerlich neue felder beginnen (word unterstuetzt felder,
+ // die wiederum felder beinhalten).
+ (*this)++;
+ pData = GetData();
+ if (pData->chGet()==19) // nested field
+ {
+ Out(rOut, rMan, nDepth+1);
+ rMan.Fill(c);
+ DBG_ASSERT(c==21, "Ww1PlainText");
+ sFormel.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "Ww" ));
+ sFormel += String::CreateFromInt32( nPlcIndex );
+ c = rMan.Fill(aStr, GetLength());
+ DBG_ASSERT(Ww1PlainText::IsChar(c), "Ww1PlainText");
+ sFormel += aStr;
+ }
+ }
+ while (pData->chGet()==19);
+
+ // get format out of text
+ pos = sFormel.SearchAscii( "\\*" );
+ sFormat = sFormel.Copy( pos );
+ sFormel.Erase( pos );
+
+ pos = sFormel.SearchAscii( "\\@" );
+ sDTFormat = sFormel.Copy( pos );
+ sFormel.Erase( pos );
+
+ // der formelteil ist zuende, kommt ein ergebnisteil?
+ if( pData->chGet() == 20 )
+ {
+ rMan.Fill( c );
+ DBG_ASSERT(c==20, "Ww1PlainText");
+ c = rMan.Fill(sErgebnis, GetLength());
+ if (!Ww1PlainText::IsChar(c))
+ sErgebnis += c; //~ mdt: sonderzeichenbenhandlung
+ (*this)++;
+ pData = GetData();
+ }
+ DBG_ASSERT(pData->chGet()==21, "Ww1PlainText");
+ BOOL bKnown = TRUE;
+ DBG_ASSERT(pField==0, "Ww1PlainText");
+ if (pField != 0)
+ {
+ rOut << *pField;
+ delete pField;
+ pField = 0;
+ }
+// naja, aber info enthaelt alle moeglichkeiten, die auch direkt da sind
+oncemore:
+ switch (rbType)
+ {
+ case 3: // bookmark reference
+ rOut.ConvertUStr( sFormel );
+ pField = new SwGetRefField( (SwGetRefFieldType*)
+ rOut.GetSysFldType( RES_GETREFFLD ),
+ sFormel,
+ REF_BOOKMARK,
+ 0,
+ REF_CONTENT );
+// pField = new SwGetExpField((SwGetExpFieldType*)
+// rOut.GetSysFldType(RES_GETEXPFLD), sFormel, GSE_STRING);
+// ,
+// GSE_STRING, VVF_SYS);
+ break;
+ case 6: // set command
+ {
+ pos = aStr.Search(' ');
+ String aName( aStr.Copy( 0, pos ));
+ aStr.Erase(0, pos );
+ aStr.Erase(0, 1);
+ if( !aName.Len() )
+ break;
+ rOut.ConvertUStr( aName );
+ SwFieldType* pFT = rOut.GetDoc().InsertFldType(
+ SwSetExpFieldType( &rOut.GetDoc(), aName, GSE_STRING ) );
+ pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr);
+ ((SwSetExpField*)pField)->SetSubType(SUB_INVISIBLE);
+// Invisible macht in 378 AErger, soll aber demnaechst gehen
+
+ // das Ignorieren des Bookmarks ist nicht implementiert
+ }
+ break;
+#if 0 // noch nicht fertig, daher disabled
+ case 8: // create index
+ case 13: // create table of contents
+ {
+ TOXTypes eTox; // Baue ToxBase zusammen
+ switch( rbType ){
+ case 8: eTox = TOX_INDEX; break;
+ case 13: eTox = TOX_CONTENT; break;
+ default: eTox = TOX_USER; break;
+ }
+ USHORT nCreateOf = ( eTox == TOX_CONTENT ) ? ( TOX_MARK | TOX_OUTLINELEVEL )
+ : TOX_MARK;
+ BYTE nNum = 0; // wird z.Zt. nicht ausgewertet
+ const SwTOXType* pType = rOut.GetDoc().GetTOXType( eTox, nNum );
+ SwForm aForm( eTox );
+ SwTOXBase* pBase = new SwTOXBase( pType, aForm, nCreateOf, aEmptyStr );
+ // Name des Verzeichnisses
+ switch( eTox ){
+ case TOX_INDEX: pBase->SetOptions( TOI_SAME_ENTRY | TOI_FF | TOI_CASE_SENSITIVE );
+ break;
+ case TOX_CONTENT: break;
+ case TOX_USER: break;
+ } // ToxBase fertig
+
+ rOut.GetDoc().SetUpdateTOX( TRUE ); // Update fuer TOX anstossen
+ rOut << SwFltTOX( pBase );
+ rOut.EndItem(RES_FLTR_TOX);
+ }
+ break;
+#endif
+ case 14: // info var
+ {
+ pos = aStr.Search(' ');
+ String aSubType( aStr.Copy( 0, pos ));
+ aStr.Erase(0, pos );
+ aStr.Erase(0, 1);
+ rOut.ConvertUStr( aSubType );
+
+
+ // ganz grosze schiete: der typ 'info' kann einem der
+ // typen 15..31 entsprechen. er enthaelt als formel
+ // das eingentliche feld der doc-info.
+ // kein ';' benutzen mit folgendem macro:
+#define IS(sd, se, t) \
+ if (aSubType.EqualsAscii( sd ) || aSubType.EqualsAscii( se)) \
+ rbType = t; \
+ else
+
+ // deutsche bez. englische bez. typ-code
+ IS("titel", "title", 15)
+ IS("thema", "subject", 16)
+ IS("autor", "author", 17)
+ IS("stichw?rter", "keywords", 18) //~ mdt: umlaut
+ IS("kommentar", "comment", 19)
+ IS("gespeichertvon", "lastrevisedby", 20)
+ IS("ertelldat", "creationdate", 21)
+ IS("speicherdat", "revisiondate", 22)
+ IS("druckdat", "printdate", 23)
+ IS("version", "revisionnumber", 24)
+ IS("zeit", "edittime", 25)
+ IS("anzseit", "numberofpages", 26)
+ IS("anzw?rter", "numberofwords", 27) //~ mdt: umlaut
+ IS("anzzeichen", "numberofchars", 28)
+ IS("dateiname", "filename", 29)
+ IS("vorlage", "templatename", 30)
+ bKnown = FALSE;
+#undef IS
+ if (rbType != 14)
+ goto oncemore;
+ }
+ break;
+ case 15: // title
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), DI_TITEL, 0);
+ break;
+ case 16: // subject
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), DI_THEMA, 0);
+ break;
+ case 17: // author
+ pField = new SwAuthorField((SwAuthorFieldType*)
+ rOut.GetSysFldType(RES_AUTHORFLD), AF_NAME);
+ break;
+ case 18: // keywords
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), DI_KEYS, 0);
+ break;
+ case 19: // comments
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), DI_COMMENT, 0);
+ break;
+ case 20: // last revised by
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), DI_CHANGE|DI_SUB_AUTHOR);
+ break;
+ case 21: // creation date
+ case 22: // revision date
+ case 23: // print date
+ case 25:{// edit time
+ USHORT nSub;
+ USHORT nReg = 0; // RegInfoFormat, DefaultFormat fuer DocInfoFelder
+
+ switch( rbType )
+ {
+ case 21: nSub = DI_CREATE; nReg = DI_SUB_DATE; break;
+ case 23: nSub = DI_PRINT; nReg = DI_SUB_DATE; break;
+ case 22: nSub = DI_CHANGE; nReg = DI_SUB_DATE; break;
+ case 25: nSub = DI_CHANGE; nReg = DI_SUB_TIME; break;
+ }
+ switch( GetTimeDatePara( sDTFormat ) )
+ {
+ case WW_DATE: nReg = DI_SUB_DATE; break;
+ case WW_TIME: nReg = DI_SUB_TIME; break;
+ case WW_BOTH: nReg = DI_SUB_DATE; break;
+ // WW_DONTKNOW -> Default bereits gesetzt
+ }
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), nSub | nReg);
+ }
+ break;
+ case 24: // revision number
+ pField = new SwDocInfoField((SwDocInfoFieldType*)
+ rOut.GetSysFldType(RES_DOCINFOFLD), DI_DOCNO, 0);
+ break;
+ case 26: // number of pages
+ pField = new SwDocStatField((SwDocStatFieldType*)
+ rOut.GetSysFldType(RES_DOCSTATFLD), DS_PAGE, SVX_NUM_ARABIC);
+ break;
+ case 27: // number of words
+ pField = new SwDocStatField((SwDocStatFieldType*)
+ rOut.GetSysFldType(RES_DOCSTATFLD), DS_WORD, SVX_NUM_ARABIC);
+ break;
+ case 28: // number of chars
+ pField = new SwDocStatField((SwDocStatFieldType*)
+ rOut.GetSysFldType(RES_DOCSTATFLD), DS_CHAR, SVX_NUM_ARABIC);
+ break;
+ case 29: // file name
+ pField = new SwFileNameField((SwFileNameFieldType*)
+ rOut.GetSysFldType(RES_FILENAMEFLD));
+ break;
+ case 30: // doc template name
+ pField = new SwTemplNameField((SwTemplNameFieldType*)
+ rOut.GetSysFldType(RES_TEMPLNAMEFLD), FF_NAME);
+ break;
+ case 31:
+ case 32:{
+ SwDateFormat aDate = DF_SSYS;
+ SwTimeFormat aTime = TF_SYSTEM;
+
+ WWDateTime eDT = GetTimeDatePara(sDTFormat, &aTime, &aDate);
+ if( eDT == WW_DONTKNOW ) // kein D/T-Formatstring
+ eDT = ( rbType == 32 ) ? WW_TIME : WW_DATE; // benutze ID
+
+ if( eDT & WW_DATE )
+ {
+ USHORT nWhich = RES_DATEFLD;
+ USHORT nSubType = DATEFLD;
+ ULONG nFormat = aDate;
+ sw3io_ConvertFromOldField( rOut.GetDoc(),
+ nWhich, nSubType, nFormat, 0x0110 );
+ pField = new SwDateTimeField((SwDateTimeFieldType*)
+ rOut.GetSysFldType(RES_DATETIMEFLD), DATEFLD, nFormat);
+
+ if( eDT == WW_BOTH )
+ rOut << * pField << ' ';
+ // Mogel: direkt einfuegen und Space dahinter
+ }
+ if( eDT & WW_TIME )
+ {
+ USHORT nWhich = RES_TIMEFLD;
+ USHORT nSubType = TIMEFLD;
+ ULONG nFormat = aTime;
+ sw3io_ConvertFromOldField( rOut.GetDoc(),
+ nWhich, nSubType, nFormat, 0x0110 );
+ pField = new SwDateTimeField((SwDateTimeFieldType*)
+ rOut.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat);
+ }
+
+ }
+ break;
+ case 33: // current page
+ pField = new SwPageNumberField((SwPageNumberFieldType*)
+ rOut.GetSysFldType(RES_PAGENUMBERFLD), PG_RANDOM, SVX_NUM_ARABIC);
+ break;
+ case 34: // evaluation exp
+ {
+ if (nDepth == 0)
+ {
+ SwGetExpFieldType* p =
+ (SwGetExpFieldType*)rOut.GetSysFldType(RES_GETEXPFLD);
+ DBG_ASSERT(p!=0, "Ww1Fields");
+ if (p != 0)
+ pField = new SwGetExpField(p, sFormel,
+ GSE_STRING, VVF_SYS);
+ }
+ else // rekursion:
+ {
+ String aName( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "Ww" )));
+ aName += String::CreateFromInt32( nPlcIndex );
+ SwFieldType* pFT = rOut.GetDoc().GetFldType( RES_SETEXPFLD,
+ aName);
+ if (pFT == 0)
+ {
+ SwSetExpFieldType aS(&rOut.GetDoc(), aName, GSE_FORMULA);
+ pFT = rOut.GetDoc().InsertFldType(aS);
+ }
+ SwSetExpField aFld((SwSetExpFieldType*)pFT, sFormel);
+ aFld.SetSubType(SUB_INVISIBLE);
+ rOut << aFld;
+ }
+ }
+ break;
+ case 36: // print command, Einfuegendatei
+ {
+ pos = aStr.Search(' ');
+ String aFName( aStr.Copy( 0, pos ));
+ aStr.Erase(0, pos );
+ aStr.Erase(0, 1);
+ if( !aFName.Len() )
+ break;
+ aFName.SearchAndReplaceAscii( "\\\\", String( '\\' ));
+
+// char* pBook = FindNextPara( pNext, 0 ); //!! Bookmark/Feld-Name
+// //!! erstmal nicht
+
+// ConvertFFileName( aPara, pFName ); //!! WW1 ????
+ aFName = INetURLObject::RelToAbs( aFName );
+
+ String aName( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "WW" )));
+ SwSection* pSection = new SwSection( FILE_LINK_SECTION,
+ rOut.GetDoc().GetUniqueSectionName( &aStr ) );
+ pSection->SetLinkFileName( aFName );
+ pSection->SetProtect( TRUE );
+ rOut << SwFltSection( pSection );
+ rOut.EndItem( RES_FLTR_SECTION );
+ rOut.NextParagraph();
+ }
+ case 37: // page ref
+ pField = new SwGetRefField(
+ (SwGetRefFieldType*)rOut.GetSysFldType(RES_GETREFFLD),
+ sFormel, 0, 0, REF_PAGE);
+ break;
+ case 38: // ask command
+ {
+ pos = aStr.Search(' ');
+ String aName( aStr.Copy( 0, pos ));
+ aStr.Erase(0, pos );
+ aStr.Erase(0, 1);
+ if( !aName.Len() )
+ break;
+
+ SwFieldType* pFT = rOut.GetDoc().InsertFldType(
+ SwSetExpFieldType( &rOut.GetDoc(), aName, GSE_STRING ) );
+ pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr );
+ ((SwSetExpField*)pField)->SetInputFlag( TRUE );
+ ((SwSetExpField*)pField)->SetSubType(SUB_INVISIBLE);
+// pField.SetPromptText( aQ ); //!! fehlt noch
+// aFld.SetPar2( aDef ); //!! dito
+ // das Ignorieren des Bookmarks ist nicht implementiert
+ }
+ case 39: // fillin command
+ pField = new SwInputField(
+ (SwInputFieldType*)rOut.GetSysFldType( RES_INPUTFLD ),
+ aEmptyStr, sFormel,
+ INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders )
+ break;
+ case 51: // macro button
+ {
+ pos = aStr.Search(' ');
+ String aName( aStr.Copy( 0, pos ));
+ aStr.Erase(0, pos );
+ aStr.Erase(0, 1);
+ if( !aName.Len() || !aStr.Len() )
+ break;
+ aName.InsertAscii( "StarOffice.Standard.Modul1.", 0 );
+
+ pField = new SwMacroField( (SwMacroFieldType*)
+ rOut.GetSysFldType( RES_MACROFLD ),
+ aName, aStr );
+ }
+ break;
+ case 55: // read tiff / or better: import anything
+ {
+ const sal_Unicode* pFormel = sFormel.GetBuffer();
+ const sal_Unicode* pDot = 0;
+ String sName;
+ while (*pFormel != '\0' && *pFormel != ' ')
+ {
+ // ab hier koennte eine extension kommen
+ if (*pFormel == '.')
+ pDot = pFormel;
+ else
+ // aha: wir waren bislang noch in dirs
+ if (*pFormel == '\\')
+ {
+ pDot = 0;
+ if (pFormel[1] == '\\')
+ pFormel++;
+ }
+ if (*pFormel != '\0')
+ sName += *pFormel++;
+ }
+ if( pDot )
+ {
+ String sExt;
+ while( *pDot != '\0' && *pDot != ' ')
+ sExt += *pDot++;
+
+ if( sExt.EqualsIgnoreCaseAscii( ".tiff" )
+ || sExt.EqualsIgnoreCaseAscii( ".bmp" )
+ || sExt.EqualsIgnoreCaseAscii( ".gif" )
+ || sExt.EqualsIgnoreCaseAscii( ".pcx" )
+ || sExt.EqualsIgnoreCaseAscii( ".pic" ))
+ rOut.AddGraphic( sName );
+ else
+ bKnown = FALSE;
+ }
+ else
+ bKnown = FALSE;
+ }
+ break;
+ default: // unknown
+ DBG_ASSERT(FALSE, "Ww1PlainText");
+ // unsupported:
+ case 1: // unknown
+ case 2: // possible bookmark
+ case 4: // index entry
+ // wwpar5: 1351/1454
+ case 5: // footnote ref
+// pField = new SwGetRefField(
+// (SwGetRefFieldType*)rDoc.GetSysFldType(RES_GETREFFLD),
+// sFormel, REF_FOOTNOTE, 0, REF_BEGIN);
+ case 7: // if command
+ case 8: // create index
+ // wwpar5: 1351/1454
+ case 9: // table of contents entry
+ // wwpar5: 1351/1454
+ case 10: // style ref
+ case 11: // doc ref
+ case 12: // seq ref
+ case 13: // create table of contents
+ // wwpar5: 1351/1454
+ case 35: // literal text
+ // print merge:
+ case 40: // data command
+ case 41: // next command
+ case 42: // nextif command
+ case 43: // skipif command
+ case 44: // number of record
+ //
+ case 45: // dde ref
+ case 46: // dde auto ref
+ case 47: // glossary entry
+ case 48: // print char
+ case 49: // formula def
+ case 50: // goto button
+ case 52: // auto number outline
+ case 53: // auto number legal
+ case 54: // auto number arabic
+ bKnown = FALSE;
+ break;
+ }
+ if( bKnown || sErgebnis.EqualsAscii( "\0270" ))
+ this->sErgebnis.Erase();
+ else
+ this->sErgebnis = sErgebnis;
+ }
+ else // oops: we are terribly wrong: skip this
+ (*this)++;
+}
+
+ULONG Ww1Fields::GetLength()
+{
+// berechnet die laenge eines feldteiles. nicht mitgerechnet werden
+// die terminierenden zeichen im text (19, 20, 21) die beginn, trenner
+// und ende bedeuten.
+ ULONG ulBeg = Where();
+ ULONG ulEnd = Where(nPlcIndex+1);
+ DBG_ASSERT(ulBeg<ulEnd, "Ww1Fields");
+ return (ulEnd - ulBeg) - 1;
+}
+
+/////////////////////////////////////////////////////////////////// Sep
+void Ww1Sep::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if (rMan.Where() >= Where())
+ {
+ rOut.NextSection();
+ SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
+ W1_DOP& rDOP = rMan.GetDop().GetDOP();
+ rOut.GetPageDesc().SetLandscape(rDOP.fWideGet());
+ SwFmtFrmSize aSz(rFmt.GetFrmSize());
+ aSz.SetWidth(rDOP.xaPageGet());
+ aSz.SetHeight(rDOP.yaPageGet());
+ rFmt.SetAttr(aSz);
+ SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(),
+ rDOP.dxaRightGet());
+ rFmt.SetAttr(aLR);
+ SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet());
+ rFmt.SetAttr(aUL);
+ // sobald wir mit dem lesen der zeichen soweit sind, wo sep's
+ // momentanes attribut beginnt, wird dieses attribut eingefuegt.
+ // diese methode ist bei den meisten start/stop methoden der
+ // memberklassen des managers identisch.
+ BYTE* p = GetData();
+ Ww1SprmSep aSprm(rFib, SVBT32ToLong(p+2));
+ aSprm.Start(rOut, rMan);
+ aSprm.Stop(rOut, rMan);
+ (*this)++;
+ aHdd.Start(rOut, rMan);
+ }
+}
+
+/////////////////////////////////////////////////////////////////// Pap
+void Ww1Pap::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if (rMan.Where() >= Where())
+ {
+ BYTE* p;
+ USHORT cb;
+ // bereitstellen der zu startenden attribute
+ if (FillStart(p, cb))
+ {
+ Ww1SprmPapx aSprm(p, cb);
+ // und ausgeben:
+ aSprm.Start(rOut, rMan);
+ }
+ (*this)++;
+ }
+}
+
+void Ww1Pap::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
+{
+#ifdef DEBUG
+ ULONG ulMan = rMan.Where();
+ ULONG ulPap = Where();
+ BOOL bIsStopAll = rMan.IsStopAll();
+#endif
+ if (rMan.Where() >= Where() || rMan.IsStopAll())
+ {
+ BYTE* p;
+ USHORT cb;
+ if (FillStop(p, cb)){
+ Ww1SprmPapx aSprm(p, cb);
+ aSprm.Stop(rOut, rMan);
+ }else{
+ DBG_ASSERT( !nPlcIndex || rMan.IsStopAll(), "Pap-Attribut-Stop verloren" );
+// rMan.IsStopAll() ist nicht schoen.
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////// W1_CHP
+//
+// momentan laesst sich die ausgabe von W1CHPxen nicht nur per define
+// loesen....
+//
+void W1_CHP::Out(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if (fBoldGet())
+ rOut << SvxWeightItem(
+ rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD);
+ if (fItalicGet())
+ rOut << SvxPostureItem(
+ rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL);
+ if (fStrikeGet())
+ rOut << SvxCrossedOutItem(
+ rOut.GetCrossedOut()?STRIKEOUT_NONE:STRIKEOUT_SINGLE);
+ if (fOutlineGet())
+ rOut << SvxContourItem(!rOut.GetContour());
+ if (fSmallCapsGet())
+ rOut << SvxCaseMapItem(
+ rOut.GetCaseKapitaelchen()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_KAPITAELCHEN);
+ if (fCapsGet())
+ rOut << SvxCaseMapItem(
+ rOut.GetCaseVersalien()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_VERSALIEN);
+ if (fsHpsGet())
+ rOut << SvxFontHeightItem(hpsGet() * 10);
+ if (fsKulGet())
+ switch (kulGet()) {
+ case 0: {
+ rOut << SvxUnderlineItem(UNDERLINE_NONE) <<
+ SvxWordLineModeItem(FALSE);
+ } break;
+ default: DBG_ASSERT(FALSE, "Chpx");
+ case 1: {
+ rOut << SvxUnderlineItem(UNDERLINE_SINGLE);
+ } break;
+ case 2: {
+ rOut << SvxUnderlineItem(UNDERLINE_SINGLE) <<
+ SvxWordLineModeItem(TRUE);
+ } break;
+ case 3: {
+ rOut << SvxUnderlineItem(UNDERLINE_DOUBLE);
+ } break;
+ case 4: {
+ rOut << SvxUnderlineItem(UNDERLINE_DOTTED);
+ } break;
+ }
+
+ if (fsIcoGet())
+ switch(icoGet()) {
+ default: DBG_ASSERT(FALSE, "Chpx");
+ case 0: { rOut.EndItem(RES_CHRATR_COLOR); } break;
+ case 1: { rOut << SvxColorItem(Color(COL_BLACK)); } break;
+ case 2: { rOut << SvxColorItem(Color(COL_LIGHTBLUE)); } break;
+ case 3: { rOut << SvxColorItem(Color(COL_LIGHTCYAN)); } break;
+ case 4: { rOut << SvxColorItem(Color(COL_LIGHTGREEN)); } break;
+ case 5: { rOut << SvxColorItem(Color(COL_LIGHTMAGENTA)); } break;
+ case 6: { rOut << SvxColorItem(Color(COL_LIGHTRED)); } break;
+ case 7: { rOut << SvxColorItem(Color(COL_YELLOW)); } break;
+ case 8: { rOut << SvxColorItem(Color(COL_WHITE)); } break;
+ }
+ if (fsSpaceGet()) {
+ short sQps = qpsSpaceGet();
+ if (sQps > 56)
+ sQps = sQps - 64;
+ rOut << SvxKerningItem(sQps);
+ }
+ if (fsPosGet())
+ if (hpsPosGet() == 0)
+ rOut << SvxEscapementItem(SVX_ESCAPEMENT_OFF);
+ else {
+ short sHps = hpsPosGet();
+ if (sHps > 128)
+ sHps = sHps - 256;
+ sHps *= 100;
+ sHps /= 24;
+ rOut << SvxEscapementItem(sHps, 100);
+ }
+ if (fsFtcGet()) {
+ SvxFontItem aFont(rMan.GetFont(ftcGet()));
+ rOut << aFont;
+ }
+}
+
+/////////////////////////////////////////////////////////////////// Chp
+void Ww1Chp::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+#ifdef DEBUG
+ ULONG ulMan = rMan.Where();
+ ULONG ulChp = Where();
+#endif
+
+ if (rMan.Where() >= Where())
+ {
+ W1_CHP aChpx;
+ if (FillStart(aChpx))
+ {
+ aChpx.Out(rOut, rMan);
+ if (aChpx.fcPicGet())
+ {
+ Ww1Picture aPic(rMan.GetFib().GetStream(),
+ aChpx.fcPicGet());
+ if (!aPic.GetError())
+ aPic.Out(rOut, rMan);
+ }
+ }
+ (*this)++;
+ }
+}
+
+void Ww1Chp::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
+{
+ if (rMan.Where() >= Where())
+ {
+ W1_CHP aChpx;
+ if (FillStop(aChpx))
+ {
+ // zuerst alle toggle-flags
+ if (aChpx.fBoldGet())
+ rOut.EndItem(RES_CHRATR_WEIGHT);
+ if (aChpx.fItalicGet())
+ rOut.EndItem(RES_CHRATR_POSTURE);
+ if (aChpx.fStrikeGet())
+ rOut.EndItem(RES_CHRATR_CROSSEDOUT);
+ if (aChpx.fOutlineGet())
+ rOut.EndItem(RES_CHRATR_CONTOUR);
+ if (aChpx.fSmallCapsGet() || aChpx.fCapsGet())
+ rOut.EndItem(RES_CHRATR_CASEMAP);
+ // dann alle zahl-werte, diese haben flags, wenn sie gesetzt
+ // sind..................
+ if (aChpx.fsHpsGet())
+ rOut.EndItem(RES_CHRATR_FONTSIZE);
+ if (aChpx.fsKulGet())
+ rOut.EndItem(RES_CHRATR_UNDERLINE)
+ .EndItem(RES_CHRATR_WORDLINEMODE);
+ if (aChpx.fsIcoGet())
+ rOut.EndItem(RES_CHRATR_COLOR);
+ if (aChpx.fsSpaceGet())
+ rOut.EndItem(RES_CHRATR_KERNING);
+ if (aChpx.fsPosGet())
+ rOut.EndItem(RES_CHRATR_ESCAPEMENT);
+ if (aChpx.fsFtcGet())
+ rOut.EndItem(RES_CHRATR_FONT);
+ }else{
+ DBG_ASSERT( !nPlcIndex, "Chp-Attribut-Stop verloren" );
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////// Style
+void Ww1Style::Out(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+// Zuerst Basis, damit Attribute des Basis-Styles erkannt werden
+// first: Base................................................
+ if(pParent->GetStyle(stcBase).IsUsed() ) // Basis gueltig ?
+ rOut.BaseStyle(stcBase);
+
+// next of all: CHP...............................................
+ aChpx.Out(rOut, rMan);
+// Last: PAP.......................................................
+ if (pPapx)
+ pPapx->Start(rOut, rMan);
+}
+
+////////////////////////////////////////////////////////// Ww1PlainText
+//
+// die Out() methoden von plaintext fuer den filter geben eine anzahl
+// zeichen aus auf die shell, einen string oder einen char, wieviel
+// zeichen ausgegeben werden, bestimmt ulEnd, das das ende bestimmt,
+// bis zudem ausgegeben wird. ausserdem beenden die methoden die
+// ausgabe bei kontrollzeichen.
+// diese sind definiert durch MinChar. alle zeichen mit wert darunter
+// gelten als kontroll- zeichen. dafuer gibts die methode IsChar, die
+// zurueckgibt, ob es sich um ein standard zeichen handelt. kommt ein
+// solches zeichen, wird dieses zeichen zurueckgegeben und die methode
+// beendet, auch wenn ulEnd noch nicht erreicht wurde. bei nutzung
+// also beachten, dasz wenn !IsChar(Out(...)) gilt, ulEnd unter
+// umstaenden nicht erreicht wurde. dann wurde das kontrollzeichen
+// zwar (weg-)gelesen, jedoch noch nicht ausgegeben.
+//
+sal_Unicode Ww1PlainText::Out( Ww1Shell& rOut, ULONG& ulEnd )
+{
+// gibt die zeichen bis ulEnd aus, es sei den es kommen sonderzeichen
+// die eine bedeutung haben wie absatzende oder seitenumbruch.
+ if (ulEnd > Count())
+ ulEnd = Count();
+ while (ulSeek < ulEnd)
+ {
+ sal_Unicode c = (*this)[ulSeek];
+ (*this)++;
+ if (Ww1PlainText::IsChar(c))
+ rOut << c;
+ else
+ return c;
+ }
+ return Ww1PlainText::MinChar;
+}
+
+sal_Unicode Ww1PlainText::Out( String& rStr, ULONG ulEnd )
+{
+// wie Out(Shell..., jedoch ausgabe auf einen string
+ rStr.Erase();
+ if (ulEnd > Count())
+ ulEnd = Count();
+ while (ulSeek < ulEnd)
+ {
+ sal_Unicode c = (*this)[ulSeek];
+ (*this)++;
+ if( Ww1PlainText::IsChar(c) )
+ rStr += c;
+ else
+ return c;
+ }
+ return Ww1PlainText::MinChar;
+}
+
+//
+// hier eruebrigt sich ulEnd...oder?
+//
+sal_Unicode Ww1PlainText::Out( sal_Unicode& rRead )
+{
+ rRead = (*this)[ulSeek];
+ (*this)++;
+ return rRead;
+}
+
+/////////////////////////////////////////////////////////// Ww1SprmPapx
+
+void Ww1SprmPapx::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if( !rMan.IsInStyle() ){ // Innerhalb Style gehts ueber die
+ // normalen Attribute
+ if (!rOut.IsInFly()
+ && !rOut.IsInTable() // Nicht innerhalb Tabelle!
+ && ( rMan.HasPPc() || rMan.HasPDxaAbs())){ // Fly-Start
+ rOut.BeginFly(); // eAnchor );
+ }
+ if (!rOut.IsInTable() && rMan.HasInTable())
+ {
+ rOut.BeginTable();
+ }
+ rOut.SetStyle(aPapx.stcGet());
+ }
+ Ww1Sprm::Start(rOut, rMan);
+}
+
+void Ww1SprmPapx::Stop(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ Ww1Sprm::Stop(rOut, rMan);
+
+ if( !rMan.IsInStyle() ) // Innerhalb Style gehts ueber die
+ { // normalen Attribute
+ if (rOut.IsInTable() &&( rMan.IsStopAll() || !rMan.HasInTable()))
+ rOut.EndTable();
+
+ if( rOut.IsInFly() &&
+ ( rMan.IsStopAll()
+ || ( !rMan.HasPPc() && !rMan.HasPDxaAbs() // Fly-Ende
+ && !rOut.IsInTable()))) // Nicht innerhalb Tabelle!
+ rOut.EndFly();
+ }
+}
+
+///////////////////////////////////////////////////////////////// Fonts
+SvxFontItem Ww1Fonts::GetFont(USHORT nFCode)
+{
+// erzeugen eine fonts im sw-sinne aus den word-strukturen
+ FontFamily eFamily = FAMILY_DONTKNOW;
+ String aName;
+ FontPitch ePitch = PITCH_DONTKNOW;
+ rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
+ switch (nFCode)
+ {
+// In the Winword 1.x format, the names of the first three fonts were
+// omitted from the table and assumed to be "Tms Rmn" (for ftc = 0),
+// "Symbol", and "Helv"
+ case 0:
+ eFamily = FAMILY_ROMAN;
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Tms Rmn" ));
+ ePitch = PITCH_VARIABLE;
+ eCharSet = RTL_TEXTENCODING_MS_1252;
+ break;
+ case 1:
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Symbol" ));
+ ePitch = PITCH_VARIABLE;
+ eCharSet = RTL_TEXTENCODING_SYMBOL;
+ break;
+ case 2:
+ eFamily = FAMILY_SWISS;
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helv" ));
+ ePitch = PITCH_VARIABLE;
+ eCharSet = RTL_TEXTENCODING_MS_1252;
+ break;
+ default:
+ {
+ W1_FFN* pF = GetFFN(nFCode - 3);
+ if (pF != 0)
+ {
+ // Fontname .........................................
+ aName = String( (sal_Char*)pF->szFfnGet(),
+ RTL_TEXTENCODING_MS_1252 );
+ // Pitch .............................................
+ static FontPitch ePitchA[] =
+ {
+ PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, PITCH_DONTKNOW
+ };
+ ePitch = ePitchA[pF->prgGet()];
+ // CharSet ...........................................
+ eCharSet = RTL_TEXTENCODING_MS_1252;
+ if (aName.EqualsIgnoreCaseAscii("Symbol")
+ || aName.EqualsIgnoreCaseAscii("Symbol Set")
+ || aName.EqualsIgnoreCaseAscii("Wingdings")
+ || aName.EqualsIgnoreCaseAscii("ITC Zapf Dingbats") )
+ eCharSet = RTL_TEXTENCODING_SYMBOL;
+ // FontFamily ........................................
+ USHORT b = pF->ffGet();
+ static FontFamily eFamilyA[] =
+ {
+ FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
+ FAMILY_SCRIPT, FAMILY_DECORATIVE
+ };
+ if (b < sizeof(eFamilyA))
+ eFamily = eFamilyA[b];
+ }
+ else
+ {
+ DBG_ASSERT(FALSE, "WW1Fonts::GetFont: Nicht existenter Font !");
+ eFamily = FAMILY_SWISS;
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helv" ));
+ ePitch = PITCH_VARIABLE;
+ eCharSet = RTL_TEXTENCODING_MS_1252;
+ }
+ }
+ break;
+ }
+ // Extrawurst Hypo
+ if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO )
+ && ( aName.EqualsIgnoreCaseAscii("Helv")
+ || aName.EqualsIgnoreCaseAscii("Helvetica") ) )
+ {
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica Neue" ));
+ if (eFamily==FAMILY_DONTKNOW)
+ eFamily = FAMILY_SWISS;
+ }
+ else
+ {
+ // VCL matcht die Fonts selber
+ // allerdings passiert bei Helv, Tms Rmn und System Monospaced
+ // Scheisse, so dass diese ersetzt werden muessen.
+ // Nach TH sollen diese durch feste Werte ersetzt werden,
+ // also nicht ueber System::GetStandardFont, damit keine
+ // Namenslisten auftauchen ( Dieses koennte den User verwirren )
+ if( aName.EqualsIgnoreCaseAscii("Helv"))
+ {
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica" ));
+ if (eFamily==FAMILY_DONTKNOW)
+ eFamily = FAMILY_SWISS;
+ }
+ else if (aName.EqualsIgnoreCaseAscii("Tms Rmn"))
+ {
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Times New Roman" ));
+ if (eFamily==FAMILY_DONTKNOW)
+ eFamily = FAMILY_ROMAN;
+ }
+ else if (aName.EqualsIgnoreCaseAscii("System Monospaced") )
+ {
+ aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Courier" ));
+ ePitch = PITCH_FIXED;
+ }
+ }
+// nun koennen wir den font basteln: .........................
+ return SvxFontItem(eFamily, aName, aEmptyStr, ePitch, eCharSet);
+}
+
+/////////////////////////////////////////////////////////////////// Dop
+void Ww1Dop::Out(Ww1Shell& rOut)
+{
+ //~ mdt: fehlt
+ // aDop.fWidowControlGet(); // keine Absatztrennung fuer einzelne Zeilen
+ long nDefTabSiz = aDop.dxaTabGet();
+ if (nDefTabSiz < 56)
+ nDefTabSiz = 709;
+
+ // wir wollen genau einen DefaultTab
+ SvxTabStopItem aNewTab(1, USHORT(nDefTabSiz),SVX_TAB_ADJUST_DEFAULT);
+ ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
+ rOut.GetDoc().GetAttrPool().SetPoolDefaultItem( aNewTab); //~ mdt: besser (GetDoc)
+
+ SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
+ W1_DOP& rDOP = GetDOP();
+ rOut.GetPageDesc().SetLandscape(rDOP.fWideGet());
+ SwFmtFrmSize aSz(rFmt.GetFrmSize());
+ aSz.SetWidth(rDOP.xaPageGet());
+ aSz.SetHeight(rDOP.yaPageGet());
+ rFmt.SetAttr(aSz);
+ SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(),
+ rDOP.dxaRightGet());
+ rFmt.SetAttr(aLR);
+ SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet());
+ rFmt.SetAttr(aUL);
+
+ SwFtnInfo aInfo;
+ aInfo = rOut.GetDoc().GetFtnInfo(); // Copy-Ctor privat
+ // wo positioniert ? ( 0 == Section, 1 == Page,
+ // 2 == beim Text -> Page, 3 == Doc )
+ switch( rDOP.fpcGet() ){
+ case 1:
+ case 2: aInfo.ePos = FTNPOS_PAGE; break;
+ default: aInfo.ePos = FTNPOS_CHAPTER; break;
+ }
+// aInfo.eNum = ( rDOP.fFtnRestartGet() ) ? FTNNUM_CHAPTER : FTNNUM_DOC;
+ // Da Sw unter Chapter anscheinend was anderes versteht als PMW
+ // hier also immer Doc !
+ aInfo.eNum = FTNNUM_DOC;
+ // wie neu nummerieren ?
+ // SW-UI erlaubt Nummer nur bei FTNNUM_DOC
+ if( rDOP.nFtnGet() > 0 && aInfo.eNum == FTNNUM_DOC )
+ aInfo.nFtnOffset = rDOP.nFtnGet() - 1;
+ rOut.GetDoc().SetFtnInfo( aInfo );
+
+}
+
+///////////////////////////////////////////////////////////////// Assoc
+void Ww1Assoc::Out(Ww1Shell& rOut)
+{
+ SfxDocumentInfo* pInfo;
+ if (rOut.GetDoc().GetpInfo()) //~ mdt: besser (GetDoc)
+ pInfo = new SfxDocumentInfo(*rOut.GetDoc().GetpInfo());
+ else
+ pInfo = new SfxDocumentInfo();
+//~ mdt: fehlen: FileNext, Dot, DataDoc, HeaderDoc, Criteria1,
+// Criteria2, Criteria3, Criteria4, Criteria5, Criteria6, Criteria7
+ pInfo->SetTitle( GetStr(Title) );
+ pInfo->SetTheme( GetStr(Subject) );
+ pInfo->SetComment( GetStr(Comments) );
+ pInfo->SetKeywords( GetStr(KeyWords) );
+ pInfo->SetCreated( GetStr(Author) );
+ pInfo->SetChanged( GetStr(LastRevBy) );
+ rOut.GetDoc().SetInfo(*pInfo);
+ delete pInfo;
+}
+
+//////////////////////////////////////////////////////////// StyleSheet
+void Ww1StyleSheet::OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc)
+{
+ switch (stc){
+ case 222: // Null
+ rOut << SvxFontHeightItem(240);
+ rOut << SvxFontItem(rMan.GetFont(2));
+ break;
+ case 223: // annotation reference
+ rOut << SvxFontHeightItem(160);
+ break;
+ case 224: // annotation text
+ rOut << SvxFontHeightItem(200);
+ break;
+ case 225: // table of contents 8
+ case 226: // table of contents 7
+ case 227: // table of contents 6
+ case 228: // table of contents 5
+ case 229: // table of contents 4
+ case 230: // table of contents 3
+ case 231: // table of contents 2
+ case 232: // table of contents 1
+ rOut << SvxLRSpaceItem(( 232 - stc ) * 720, 720);
+ // Tabulatoren fehlen noch !
+ break;
+ case 233: // index 7
+ case 234: // und index 6
+ case 235: // und index 5
+ case 236: // und index 4
+ case 237: // und index 3
+ case 238: // und index 2
+ rOut << SvxLRSpaceItem(( 239 - stc ) * 360, 0);
+ break;
+ case 239: // index 1
+ break;
+ case 240: // line number
+ break;
+ case 241: // index heading
+ break;
+ case 242: // footer
+ case 243:{ // ... und header
+ SvxTabStopItem aAttr;
+ SvxTabStop aTabStop;
+ aTabStop.GetTabPos() = 4535; // 8 cm
+ aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
+ aAttr.Insert( aTabStop );
+ aTabStop.GetTabPos() = 9071; // 16 cm
+ aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
+ aAttr.Insert( aTabStop );
+ rOut << aAttr;
+ }
+ break;
+ case 244: // footnote reference
+ rOut << SvxFontHeightItem(160);
+ rOut << SvxEscapementItem(6 * 100 / 24, 100);
+ break;
+ case 245: // footnote text
+ rOut << SvxFontHeightItem(200);
+ break;
+ case 246: // heading 9
+ case 247: // und heading 8
+ case 248: // und heading 7
+ rOut << SvxLRSpaceItem(720, 0);
+ rOut << SvxPostureItem(
+ rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL);
+ rOut << SvxFontHeightItem(200);
+ break;
+ case 249: // heading 6
+ rOut << SvxLRSpaceItem(720, 0);
+ rOut << SvxUnderlineItem(UNDERLINE_SINGLE);
+ rOut << SvxFontHeightItem(200);
+ break;
+ case 250: // heading 5
+ rOut << SvxLRSpaceItem(720, 0);
+ rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD);
+ rOut << SvxFontHeightItem(200);
+ break;
+ case 251: // heading 4
+ rOut << SvxLRSpaceItem(360, 0);
+ rOut << SvxUnderlineItem(UNDERLINE_SINGLE);
+ rOut << SvxFontHeightItem(240);
+ break;
+ case 252: // heading 3
+ rOut << SvxLRSpaceItem(360, 0);
+ rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD);
+ rOut << SvxFontHeightItem(240);
+ break;
+ case 253: // heading 2
+ rOut << SvxULSpaceItem(120, 0);
+ rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD);
+ rOut << SvxFontHeightItem(240);
+ rOut << SvxFontItem(rMan.GetFont(2));
+ break;
+ case 254: // heading 1
+ rOut << SvxULSpaceItem(240, 0);
+ rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD);
+ rOut << SvxUnderlineItem(UNDERLINE_SINGLE);
+ rOut << SvxFontHeightItem(240);
+ rOut << SvxFontItem(rMan.GetFont(2));
+ break;
+ case 255: // Normal indent
+ rOut << SvxLRSpaceItem(720, 0);
+ break;
+ case 0: // Normal
+ rOut << SvxFontHeightItem(200);
+ break;
+ default: // selbstdefiniert
+ rOut << SvxFontHeightItem(200);
+ break;
+ }
+}
+
+void Ww1StyleSheet::OutOne(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc)
+{
+ const RES_POOL_COLLFMT_TYPE RES_NONE = RES_POOLCOLL_DOC_END;
+ RES_POOL_COLLFMT_TYPE aType = RES_NONE;
+// aType = RES_POOLCOLL_JAKETADRESS; break;
+// aType = RES_POOLCOLL_LISTS_BEGIN; break;
+// aType = RES_POOLCOLL_SENDADRESS; break;
+// aType = RES_POOLCOLL_SIGNATURE; break;
+// aType = RES_POOLCOLL_TEXT_NEGIDENT; break;
+// aType = RES_POOLCOLL_TOX_IDXH; break;
+ switch (stc)
+ {
+ case 222: // Null
+ aType = RES_POOLCOLL_TEXT; break; //???
+ break;
+ case 223: // annotation reference
+ break;
+ case 224: // annotation text
+ break;
+ case 225: // table of contents 8
+ aType = RES_POOLCOLL_TOX_CNTNT8; break;
+ case 226: // table of contents 7
+ aType = RES_POOLCOLL_TOX_CNTNT7; break;
+ case 227: // table of contents 6
+ aType = RES_POOLCOLL_TOX_CNTNT6; break;
+ case 228: // table of contents 5
+ aType = RES_POOLCOLL_TOX_CNTNT5; break;
+ case 229: // table of contents 4
+ aType = RES_POOLCOLL_TOX_CNTNT4; break;
+ case 230: // table of contents 3
+ aType = RES_POOLCOLL_TOX_CNTNT3; break;
+ case 231: // table of contents 2
+ aType = RES_POOLCOLL_TOX_CNTNT2; break;
+ case 232: // table of contents 1
+ aType = RES_POOLCOLL_TOX_CNTNT1; break;
+ case 233: // index 7
+ break;
+ case 234: // index 6
+ break;
+ case 235: // index 5
+ break;
+ case 236: // index 4
+ break;
+ case 237: // index 3
+ aType = RES_POOLCOLL_TOX_IDX3; break;
+ case 238: // index 2
+ aType = RES_POOLCOLL_TOX_IDX2; break;
+ case 239: // index 1
+ aType = RES_POOLCOLL_TOX_IDX1; break;
+ case 240: // line number
+ break;
+ case 241: // index heading
+ break;
+ case 242: // footer
+ aType = RES_POOLCOLL_FOOTER; break;
+ case 243: // header
+ aType = RES_POOLCOLL_HEADER; break;
+ case 244: // footnote reference
+ break;
+ case 245: // footnote text
+ aType = RES_POOLCOLL_FOOTNOTE; break;
+ case 246: // heading 9
+ break;
+ case 247: // heading 8
+ break;
+ case 248: // heading 7
+ break;
+ case 249: // heading 6
+ break;
+ case 250: // heading 5
+ aType = RES_POOLCOLL_HEADLINE5; break;
+ case 251: // heading 4
+ aType = RES_POOLCOLL_HEADLINE4; break;
+ case 252: // heading 3
+ aType = RES_POOLCOLL_HEADLINE3; break;
+ case 253: // heading 2
+ aType = RES_POOLCOLL_HEADLINE2; break;
+ case 254: // heading 1
+ aType = RES_POOLCOLL_HEADLINE1; break;
+ case 255: // Normal indent
+ aType = RES_POOLCOLL_TEXT_IDENT; break;
+ case 0: // Normal
+ aType = RES_POOLCOLL_STANDARD; break;
+// aType = RES_POOLCOLL_TEXT; break; // Das ist "textkoerper"
+ }
+ if (aType == RES_NONE)
+ rOut.BeginStyle(stc, GetStyle(stc).GetName() );
+ else
+ rOut.BeginStyle(stc, aType);
+ OutDefaults(rOut, rMan, stc);
+ GetStyle(stc).Out(rOut, rMan);
+ rOut.EndStyle();
+// rMan.SetInApo(FALSE);
+}
+// OutOneWithBase() liest einen Style mit OutOne() einen Style ein
+// Jedoch liest er, wenn noch nicht geschehen, den Basisstyle rekursiv ein
+void Ww1StyleSheet::OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan,
+ USHORT stc, BYTE* pbStopRecur )
+{
+// SH: lineares Einlesen ist Scheisse, da dann BasedOn nicht gesetzt
+// werden kann und ausserdem Toggle- und Modify-Attrs (z.B. Tabs ) nicht gehen.
+
+ Ww1Style& rSty = GetStyle(stc);
+ USHORT nBase = rSty.GetnBase();
+ if( nBase != stc
+ && !rOut.IsStyleImported( nBase )
+ && GetStyle(nBase).IsUsed()
+ && !pbStopRecur[nBase] ){
+
+ pbStopRecur[nBase] = 1;
+ OutOneWithBase( rOut, rMan, nBase, pbStopRecur ); // Rekursiv
+ }
+ OutOne( rOut, rMan, stc );
+}
+
+void Ww1StyleSheet::Out(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ USHORT stc;
+ BYTE bStopRecur[256];
+ memset( bStopRecur, FALSE, sizeof(bStopRecur) );
+
+// 1. Durchlauf: Styles mit Basisstyles rekursiv
+ for (stc=0;stc<Count();stc++)
+ if (GetStyle(stc).IsUsed() && !rOut.IsStyleImported( stc ) )
+ OutOneWithBase( rOut, rMan, stc, bStopRecur );
+
+// 2. Durchlauf: Follow-Styles
+ for (stc=0;stc<Count();stc++){
+ Ww1Style& rSty = GetStyle(stc);
+ if ( rSty.IsUsed() ){
+ USHORT nNext = rSty.GetnNext();
+ if( nNext != stc && GetStyle(nNext).IsUsed() )
+ rOut.NextStyle( stc, nNext );
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////// Picture
+static ULONG GuessPicSize(W1_PIC* pPic)
+{
+ long nSize = pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb));
+ register BYTE* p = pPic->rgbGet();
+ USHORT maxx = pPic->mfp.xExtGet();
+ USHORT padx = ((maxx + 7) / 8) * 8;
+ USHORT maxy = pPic->mfp.yExtGet();
+ return 120L + (ULONG)padx * maxy;
+}
+
+//
+// folgende methode schreibt eine windows-.BMP-datei aus einem
+// embeddeten bild in ww-1 dateien
+// gelesen wird 4-bit format, geschrieben jedoch 8-bit.
+//
+void Ww1Picture::WriteBmp(SvStream& rOut)
+{
+ long nSize = pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb));
+ register BYTE* p = pPic->rgbGet();
+ USHORT maxx = pPic->mfp.xExtGet();
+ USHORT padx = ((maxx + 7) / 8) * 8;
+ USHORT maxy = pPic->mfp.yExtGet();
+ USHORT unknown1 = SVBT16ToShort(p); p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
+ USHORT unknown2 = SVBT16ToShort(p); p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
+ USHORT x = SVBT16ToShort(p); p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
+ DBG_ASSERT(x==maxx, "Ww1Picture");
+ USHORT y = SVBT16ToShort(p); p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
+ DBG_ASSERT(y==maxy, "Ww1Picture");
+ USHORT planes = SVBT16ToShort(p); p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
+ DBG_ASSERT(planes==1, "Ww1Picture");
+ USHORT bitcount = SVBT16ToShort(p); p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
+ DBG_ASSERT(bitcount==4, "Ww1Picture");
+ DBG_ASSERT(16*3+padx*maxy/2==nSize, "Ww1Picture");
+ SVBT32 tmpLong;
+ SVBT16 tmpShort;
+ SVBT8 tmpByte;
+#define wLong(n) \
+ LongToSVBT32(n, tmpLong); \
+ if ((rOut.Write(tmpLong, sizeof(SVBT32))) != sizeof(SVBT32)) goto error;
+#define wShort(n) \
+ ShortToSVBT16(n, tmpShort); \
+ if ((rOut.Write(tmpShort, sizeof(SVBT16))) != sizeof(SVBT16)) goto error;
+#define wByte(n) \
+ ByteToSVBT8(n, tmpByte); \
+ if ((rOut.Write(tmpByte, sizeof(SVBT8))) != sizeof(SVBT8)) goto error;
+ wByte('B'); wByte('M');
+ wLong(54 + 4 * 16 + padx * maxy);
+ wLong(0);
+ wLong(54 + 4 * 16);
+ wLong(40);
+ wLong(maxx);
+ wLong(maxy);
+ wShort(1);
+ wShort(8);
+ wLong(0);
+ wLong(0);
+ wLong(0);
+ wLong(0);
+ wLong(16);
+ wLong(16);
+ register USHORT i;
+ for (i=0;nSize>0&&i<16;i++)
+ {
+ wByte(*p);
+ p++;
+ nSize -= sizeof(BYTE);
+ wByte(*p);
+ p++;
+ nSize -= sizeof(BYTE);
+ wByte(*p);
+ p++;
+ nSize -= sizeof(BYTE);
+ wByte(0);
+ }
+ DBG_ASSERT(padx*maxy/2==nSize, "Ww1Picture");
+ register USHORT j;
+#if 1
+ {
+ BYTE* pBuf = new BYTE[padx];
+ BYTE* q = pBuf;
+ for (j=0;nSize>0&&j<maxy;j++)
+ {
+ register BYTE* q = pBuf;
+ for (i=0;nSize>0&&i<maxx;i+=2)
+ {
+ *q++ = *p>>4;
+ *q++ = *p&0xf;
+ p++;
+ nSize -= sizeof(BYTE);
+ }
+ for (;i<padx;i+=2)
+ {
+ *q++ = 0;
+ p++;
+ nSize -= sizeof(BYTE);
+ }
+ if(rOut.Write(pBuf, padx) != padx){
+ delete pBuf;
+ goto error;
+ }
+ }
+ delete pBuf;
+ }
+#else
+ for (j=0;nSize>0&&j<maxy;j++)
+ {
+ for (i=0;nSize>0&&i<maxx;i+=2)
+ {
+ wByte(*p>>4);
+ wByte(*p&0xf);
+ p++;
+ nSize -= sizeof(BYTE);
+ }
+ for (;i<padx;i+=2)
+ {
+ wByte(0);
+ p++;
+ nSize -= sizeof(BYTE);
+ }
+ }
+#endif
+ DBG_ASSERT(nSize==0, "Ww1Picture");
+#undef wLong
+#undef wShort
+#undef wByte
+ rOut.Seek(0);
+ return;
+error:
+ ;
+}
+
+void Ww1Picture::Out(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ Graphic* pGraphic = 0;
+ USHORT mm;
+ switch (mm = pPic->mfp.mmGet())
+ {
+ case 8: // embedded metafile
+ {
+ SvMemoryStream aOut(8192, 8192);
+ aOut.Write(pPic->rgbGet(), pPic->lcbGet() -
+ (sizeof(*pPic)-sizeof(pPic->rgb)));
+ aOut.Seek(0);
+ GDIMetaFile aWMF;
+ if (ReadWindowMetafile(aOut, aWMF) && aWMF.GetActionCount() > 0)
+ {
+ aWMF.SetPrefMapMode(MapMode(MAP_100TH_MM));
+ Size aOldSiz(aWMF.GetPrefSize());
+ Size aNewSiz(pPic->mfp.xExtGet(), pPic->mfp.yExtGet());
+ Fraction aFracX(aNewSiz.Width(), aOldSiz.Width());
+ Fraction aFracY(aNewSiz.Height(), aOldSiz.Height());
+ aWMF.Scale(aFracX, aFracY);
+ aWMF.SetPrefSize(aNewSiz);
+ pGraphic = new Graphic(aWMF);
+ }
+ break;
+ }
+ case 94: // embedded name SH:??? Was denn nun ? Embeddet oder Name ?
+ case 98: // TIFF-Name
+ {
+ String aDir( (sal_Char*)pPic->rgbGet(),
+ (USHORT)(pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb))),
+ RTL_TEXTENCODING_MS_1252 );
+ //SvFileStream aOut(aDir, STREAM_READ|STREAM_WRITE|STREAM_TRUNC);
+ rOut.AddGraphic( aDir );
+ }
+ break;
+ case 97: // embedded bitmap
+// case 99: // SH: bei meinem BspDoc 41738.doc auch embedded Bitmap,
+ // aber leider anderes Format
+ {
+ ULONG nSiz = GuessPicSize(pPic);
+ SvMemoryStream aOut(nSiz, 8192);
+ WriteBmp(aOut);
+ Bitmap aBmp;
+ aOut >> aBmp;
+ pGraphic = new Graphic(aBmp);
+ }
+ default:
+ DBG_ASSERT(pPic->mfp.mmGet() == 97, "Ww1Picture");
+ }
+ if (pGraphic)
+ rOut << *pGraphic;
+}
+
+////////////////////////////////////////////////////////// HeaderFooter
+void Ww1HeaderFooter::Start(Ww1Shell& rOut, Ww1Manager& rMan)
+{
+// wird sowieso nur bei SEPs aufgerufen, keine weitere pruefung
+// noetig:
+ if (!rMan.Pushed())
+ {
+ while ((*this)++)
+ switch (eHeaderFooterMode)
+ {
+ case FtnSep:
+ break;
+ case FtnFollowSep:
+ break;
+ case FtnNote:
+ break;
+ case EvenHeadL:
+ break;
+ case OddHeadL:
+ {
+ ULONG begin;
+ ULONG end;
+ if (FillOddHeadL(begin, end))
+ {
+ Ww1HddText* pText = new Ww1HddText(rMan.GetFib());
+ pText->Seek(begin);
+ pText->SetCount(end-begin);
+ rOut.BeginHeader();
+ rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin,
+ new Ww1HeaderFooterFields(rMan.GetFib()));
+ rOut << rMan;
+ rMan.Pop();
+ rOut.EndHeaderFooter();
+ return;
+ }
+ }
+ break;
+ case EvenFootL:
+ break;
+ case OddFootL:
+ {
+ ULONG begin;
+ ULONG end;
+ if (FillOddFootL(begin, end))
+ {
+ Ww1HddText* pText = new Ww1HddText(rMan.GetFib());
+ pText->Seek(begin);
+ pText->SetCount(end-begin);
+ rOut.BeginFooter();
+ rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin,
+ new Ww1HeaderFooterFields(rMan.GetFib()));
+ rOut << rMan;
+ rMan.Pop();
+ rOut.EndHeaderFooter();
+ return;
+ }
+ }
+ break;
+ case FirstHeadL:
+ break;
+ }
+ }
+}
+
+void Ww1HeaderFooter::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
+{
+ if (!rMan.Pushed() && eHeaderFooterMode != None
+// && rMan.GetText().Where() >= rMan.GetText().Count()
+ )
+ {
+ Start(rOut, rMan);
+ }
+}
+
+/***********************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww1/w1filter.cxx,v 1.1.1.1 2000-09-18 17:14:57 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.29 2000/09/18 16:04:56 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.28 2000/05/11 16:06:52 jp
+ Changes for Unicode
+
+ Revision 1.27 2000/02/11 14:39:31 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.26 1999/03/16 11:12:24 JP
+ Task #63047#: keine Abfrage mehr auf ein SVX_TAB_DEFDIST
+
+
+ Rev 1.25 16 Mar 1999 12:12:24 JP
+ Task #63047#: keine Abfrage mehr auf ein SVX_TAB_DEFDIST
+
+ Rev 1.24 17 Nov 1998 10:48:18 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.23 27 Feb 1998 19:29:06 HJS
+ SH 27.02.98
+
+ Rev 1.20 09 Dec 1997 17:04:38 JP
+ neue InhaltsVerzeichnis Poolvorlagen -> neuer MaxLevel
+
+ Rev 1.19 29 Nov 1997 17:37:10 MA
+ includes
+
+ Rev 1.18 21 Nov 1997 17:22:44 OM
+ Feldbefehl-Umstellung: DocInfo
+
+ Rev 1.17 14 Oct 1997 14:17:18 OM
+ Feldumstellung
+
+ Rev 1.16 09 Oct 1997 14:13:46 JP
+ Aenderungen von SH
+
+ Rev 1.15 02 Oct 1997 15:26:00 OM
+ Feldumstellung
+
+ Rev 1.14 29 Sep 1997 12:16:56 OM
+ Feldumstellung
+
+ Rev 1.13 24 Sep 1997 15:25:24 OM
+ Feldumstellung
+
+ Rev 1.12 04 Sep 1997 11:18:00 JP
+ include
+
+ Rev 1.11 03 Sep 1997 14:16:58 SH
+ Flys, Tabellen ok, Style-Abhaengigkeiten u.v.a.m
+
+ Rev 1.10 15 Aug 1997 12:50:36 OS
+ charatr/frmatr/txtatr aufgeteilt
+
+ Rev 1.9 12 Aug 1997 14:16:34 OS
+ Header-Umstellung
+
+ Rev 1.8 11 Aug 1997 12:51:02 SH
+ Flys und einfache Tabellen und Tabulatoren
+
+ Rev 1.7 17 Jul 1997 15:20:52 MA
+ Bitmap Typ 99 geht nicht, abgeklemmt
+
+ Rev 1.6 16 Jun 1997 13:08:56 MA
+ Stand Micheal Dietrich
+
+ Rev 1.5 24 Mar 1997 03:04:22 HJS
+ fuer os2 auskommentiert
+
+ Rev 1.4 12 Mar 1997 19:12:18 SH
+ MDT: Progressbar, Pagedesc-Bug, Spalten, Anfang Tabellen u.a.
+
+ Rev 1.3 10 Jan 1997 18:46:30 SH
+ Stabiler und mehr von MDT
+
+ Rev 1.2 28 Nov 1996 18:08:50 SH
+ Schneller Schoener Weiter von MDT
+
+ Rev 1.1 30 Sep 1996 23:23:40 SH
+ neu von MDT
+
+ Rev 1.0 14 Aug 1996 19:32:28 SH
+ Initial revision.
+
+
+***********************************************************************/
+//]})
diff --git a/sw/source/filter/ww1/w1par.cxx b/sw/source/filter/ww1/w1par.cxx
new file mode 100644
index 000000000000..a21f47c61983
--- /dev/null
+++ b/sw/source/filter/ww1/w1par.cxx
@@ -0,0 +1,255 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1par.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _PAM_HXX
+#include <pam.hxx> // fuer SwPam
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx> // class SwTxtNode
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx> // Ww1Reader
+#endif
+#ifndef _W1PAR_HXX
+#include <w1par.hxx>
+#endif
+
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // StatLine...()
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h> // ERR_WW1_...
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+
+//----------------------------------------
+// Initialisieren der Feld-FilterFlags
+//----------------------------------------
+
+static ULONG WW1_Read_FieldIniFlags()
+{
+// USHORT i;
+ ULONG nFieldFlags = ReadFilterFlags( "WW1F" );
+ if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
+ {
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF );
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID );
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT );
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
+ }
+ return nFieldFlags;
+}
+
+////////////////////////////////////////////////// StarWriter-Interface
+//
+// Eine Methode liefern die call-Schnittstelle fuer den Writer.
+// Read() liest eine Datei. hierzu werden zwei Objekte erzeugt, die Shell,
+// die die Informationen aufnimmt und der Manager der sie aus der Datei liest.
+// Diese werden dann einfach per Pipe 'uebertragen'.
+//
+
+ULONG WW1Reader::Read(SwDoc& rDoc, SwPaM& rPam, const String& cName)
+{
+ ULONG nRet = ERR_SWG_READ_ERROR;
+ ASSERT(pStrm!=NULL, "W1-Read ohne Stream");
+ if (pStrm != NULL)
+ {
+ BOOL bNew = !bInsertMode; // Neues Doc ( kein Einfuegen )
+
+ // erstmal eine shell konstruieren: die ist schnittstelle
+ // zum writer-dokument
+ ULONG nFieldFlags = WW1_Read_FieldIniFlags();
+ Ww1Shell* pRdr = new Ww1Shell( rDoc, rPam, bNew, nFieldFlags );
+ if( pRdr )
+ {
+ // dann den manager, der liest die struktur des word-streams
+ Ww1Manager* pMan = new Ww1Manager( *pStrm, nFieldFlags );
+ if( pMan )
+ {
+ if( !pMan->GetError() )
+ {
+ ::StartProgress( STR_STATSTR_W4WREAD, 0, 100,
+ rDoc.GetDocShell() );
+ ::SetProgressState( 0, rDoc.GetDocShell() );
+ // jetzt nur noch alles rueberschieben
+ *pRdr << *pMan;
+ if( !pMan->GetError() )
+ // und nur hier, wenn kein fehler auftrat
+ // fehlerfreiheit melden
+ nRet = 0; // besser waere: WARN_SWG_FEATURES_LOST;
+ ::EndProgress( rDoc.GetDocShell() );
+ }
+ else
+ {
+ if( pMan->GetFib().GetFIB().fComplexGet() )
+ //!!! ACHTUNG: hier muss eigentlich ein Error
+ // wegen Fastsave kommen, das der PMW-Filter
+ // das nicht unterstuetzt. Stattdessen temporaer
+ // nur eine Warnung, bis die entsprechende
+ // Meldung und Behandlung weiter oben eingebaut ist.
+// nRet = WARN_WW6_FASTSAVE_ERR;
+ // Zum Einchecken mit neuem String:
+ nRet = ERR_WW6_FASTSAVE_ERR;
+ }
+ }
+ delete pMan;
+ }
+ delete pRdr;
+ }
+ Ww1Sprm::DeinitTab();
+ return nRet;
+}
+
+///////////////////////////////////////////////////////////////// Shell
+//
+// Die Shell ist die Schnittstelle vom Filter zum Writer. Sie ist
+// abgeleitet von der mit ww-filter gemeinsam benutzten Shell
+// SwFltShell und enthaelt alle fuer ww1 noetigen Erweiterungen. Wie
+// in einen Stream werden alle Informationen, die aus der Datei
+// gelesen werden, in die shell ge'piped'.
+//
+Ww1Shell::Ww1Shell( SwDoc& rD, SwPaM& rPam, BOOL bNew, ULONG nFieldFlags)
+ : SwFltShell(&rD, rPam, bNew, nFieldFlags)
+{
+}
+
+
+
+/**********************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww1/w1par.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.20 2000/09/18 16:04:57 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.19 2000/05/15 16:37:48 jp
+ Changes for Unicode
+
+ Revision 1.18 2000/05/11 16:07:43 jp
+ Changes for Unicode
+
+ Revision 1.17 1998/07/23 09:13:52 JP
+ Task #52654#: Einfuegen Doc nicht mit einer CrsrShell sondern mit einen PaM
+
+
+ Rev 1.16 23 Jul 1998 11:13:52 JP
+ Task #52654#: Einfuegen Doc nicht mit einer CrsrShell sondern mit einen PaM
+
+ Rev 1.15 27 Feb 1998 19:29:46 HJS
+ SH 27.02.98
+
+ Rev 1.13 29 Nov 1997 17:37:08 MA
+ includes
+
+ Rev 1.12 09 Oct 1997 14:13:48 JP
+ Aenderungen von SH
+
+ Rev 1.11 04 Sep 1997 12:37:38 JP
+ Umstellungen fuer FilterDetection im SwModule und SwDLL
+
+ Rev 1.10 03 Sep 1997 14:14:24 SH
+ Flys, Tabellen ok, Style-Abhaengigkeiten u.v.a.m
+
+ Rev 1.9 12 Aug 1997 14:16:36 OS
+ Header-Umstellung
+
+ Rev 1.8 11 Aug 1997 14:07:32 OM
+ Headerfile-Umstellung
+
+ Rev 1.7 16 Jun 1997 13:08:58 MA
+ Stand Micheal Dietrich
+
+ Rev 1.6 12 Mar 1997 19:12:40 SH
+ MDT: Progressbar, Pagedesc-Bug, Spalten, Anfang Tabellen u.a.
+
+ Rev 1.5 10 Jan 1997 18:47:12 SH
+ Stabiler und mehr von MDT
+
+ Rev 1.4 28 Nov 1996 18:09:18 SH
+ Schneller Schoener Weiter von MDT
+
+ Rev 1.3 18 Oct 1996 10:58:36 JP
+ aufbreitet fuer PRJPCH
+
+ Rev 1.2 30 Sep 1996 23:24:10 SH
+ neu von MDA
+
+ Rev 1.0 14 Aug 1996 19:32:28 SH
+ Initial revision.
+
+**********************************************************************/
+//]})
diff --git a/sw/source/filter/ww1/w1par.hxx b/sw/source/filter/ww1/w1par.hxx
new file mode 100644
index 000000000000..48f878987ece
--- /dev/null
+++ b/sw/source/filter/ww1/w1par.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1par.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _W1PAR_HXX
+#define _W1PAR_HXX
+
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx>
+#endif
+#ifndef _W1CLASS_HXX
+#include <w1class.hxx>
+#endif
+
+////////////////////////////////////////////////////////////// Ww1Shell
+class Ww1Shell : public SwFltShell
+{
+public:
+ Ww1Shell(SwDoc&, SwPaM&, BOOL bNew, ULONG nFieldFlags);
+};
+
+
+#endif
+
diff --git a/sw/source/filter/ww1/w1sprm.cxx b/sw/source/filter/ww1/w1sprm.cxx
new file mode 100644
index 000000000000..130f592ab8cc
--- /dev/null
+++ b/sw/source/filter/ww1/w1sprm.cxx
@@ -0,0 +1,960 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1sprm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+// std
+#include <stdio.h> // sprintf
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#include <tools/solar.h>
+#ifndef _SVX_PAPERINF_HXX
+#include <svx/paperinf.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _SVX_KEEPITEM_HXX //autogen
+#include <svx/keepitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+
+
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _ERRHDL_HXX
+#include <errhdl.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx>
+#endif
+#ifndef _REFFLD_HXX
+#include <reffld.hxx>
+#endif
+#ifndef _EXPFLD_HXX
+#include <expfld.hxx>
+#endif
+#ifndef _W1PAR_HXX
+#include <w1par.hxx>
+#endif
+
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx>
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc>
+#endif
+
+/////////////////////////////////////////////////////////////// Ww1Sprm
+void Ww1Sprm::Stop( Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if(IsUsed())
+// for(USHORT i=0;i<Count();i++)
+ for(short i=Count()-1;i>=0;i--){ // rueckwaerts
+ BYTE nId;
+ USHORT nSize;
+ BYTE* pSprm;
+ Fill(i, nId, nSize, pSprm);
+ GetTab(nId).Stop(rOut, nId, pSprm, nSize, rMan);
+ }
+}
+
+void Ww1Sprm::Start(
+ Ww1Shell& rOut, Ww1Manager& rMan, USHORT i)
+{
+ BYTE nId;
+ USHORT nSize;
+ BYTE* pSprm;
+ Fill(i, nId, nSize, pSprm);
+ GetTab(nId).Start(rOut, nId, pSprm, nSize, rMan);
+}
+
+void Ww1Sprm::Start(
+ Ww1Shell& rOut, Ww1Manager& rMan)
+{
+ if(IsUsed())
+ for(USHORT i=0;i<Count();i++)
+ Start(rOut, rMan, i);
+}
+
+//////////////////////////////////////////////////////////// SingleSprm
+void Ww1SingleSprm::Start(
+ Ww1Shell&, BYTE nId, BYTE*, USHORT, Ww1Manager&)
+{
+#ifdef DEBUG
+// ASSERT(FALSE, "Unknown Sprm");
+ if (nId)
+ {
+ char s[200];
+ sprintf(s, "%s(%d) Sprm id %d started.",
+ __FILE__, __LINE__,(int)nId);
+ DBG_ERROR(s);
+ }
+#endif
+}
+
+void Ww1SingleSprm::Stop(
+ Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&)
+{
+// ASSERT(FALSE, "Unknown Sprm");
+}
+
+////////////////////////////////////////////////////////////////// STOP
+//
+// folgende defines werden genutzt zur implementierung der
+// Stop()-Member der SingleSprm-klassen, da diese im normalfalle
+// lediglich EndItem(s) in die shell stellen.
+//
+#define STOP1(Class, Code) \
+ void Class::Stop( \
+ Ww1Shell& rOut, BYTE, BYTE*, USHORT, Ww1Manager&) { \
+ rOut.EndItem(Code); }
+#define STOP2(Class, Code1, Code2) \
+ void Class::Stop( \
+ Ww1Shell& rOut, BYTE, BYTE*, USHORT, Ww1Manager&) { \
+ rOut.EndItem(Code1).EndItem(Code2); }
+
+/////////////////////////////////////////////////////// SingleSprmXxxxx
+//
+// hier beginnt die auswertung der eigentlichen sprms. jeder sprmtyp
+// hat eine eigene klasse, die die virtualen methoden start und stop
+// implementiert. die klassen stehen in der sprm-tab, die statischer
+// member von Ww1Sprm ist. taucht ein sprm im dokument auf, werden die
+// virtualen methoden bei beginn und ende der formatierung gerufen.
+//
+void Ww1SingleSprmPDxaLeft::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
+ short nPara = SVBT16ToShort(pSprm);
+ if(nPara < 0)
+ nPara = 0;
+ if(aLR.GetTxtFirstLineOfst() < -nPara)
+ aLR.SetTxtFirstLineOfst(-nPara); // sonst weigert sich SetTxtLeft()
+ aLR.SetTxtLeft(nPara);
+ rOut << aLR;
+}
+
+void Ww1SingleSprmPDxaRight::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
+ short nPara = SVBT16ToShort(pSprm);
+ if(nPara < 0)
+ nPara = 0;
+ aLR.SetRight(nPara);
+ rOut << aLR;
+}
+
+void Ww1SingleSprmPDxaLeft1::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
+ short nPara = SVBT16ToShort(pSprm);
+ if(-nPara >(short)aLR.GetTxtLeft())
+ nPara = -(short)aLR.GetTxtLeft();
+ aLR.SetTxtFirstLineOfst(nPara);
+ rOut << aLR;
+}
+
+STOP1(Ww1SingleSprmPDxa, RES_LR_SPACE)
+
+void Ww1SingleSprmPJc::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ static SvxAdjust __READONLY_DATA aAdj[] = {
+ SVX_ADJUST_LEFT,
+ SVX_ADJUST_CENTER,
+ SVX_ADJUST_RIGHT,
+ SVX_ADJUST_BLOCK };
+ BYTE nPara = SVBT8ToByte(pSprm);
+ nPara %=(sizeof(aAdj)/sizeof(*aAdj));
+ rOut << SvxAdjustItem(aAdj[nPara]);
+}
+
+STOP1(Ww1SingleSprmPJc, RES_PARATR_ADJUST)
+
+void Ww1SingleSprmPFKeep::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ rOut << SvxFmtSplitItem((SVBT8ToByte(pSprm) & 1) == 0);
+}
+
+STOP1(Ww1SingleSprmPFKeep, RES_PARATR_SPLIT)
+
+void Ww1SingleSprmPFKeepFollow::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ rOut << SvxFmtKeepItem((SVBT8ToByte(pSprm) & 1) != 0);
+}
+
+STOP1(Ww1SingleSprmPFKeepFollow, RES_KEEP)
+
+void Ww1SingleSprmPPageBreakBefore::Start(
+ Ww1Shell& rOut, BYTE, BYTE* pSprm, USHORT, Ww1Manager&)
+{
+ rOut << SvxFmtBreakItem(SVBT8ToByte(pSprm) & 1?
+ SVX_BREAK_PAGE_BEFORE:SVX_BREAK_NONE );
+}
+
+STOP1(Ww1SingleSprmPPageBreakBefore, RES_BREAK)
+
+SvxBorderLine* Ww1SingleSprmPBrc::SetBorder(SvxBorderLine* pLine, W1_BRC10* pBrc)
+{
+ USHORT nCode;
+ if(pBrc->dxpLine2WidthGet() == 0)
+ {
+ switch(pBrc->dxpLine1WidthGet())
+ {
+ default: ASSERT(FALSE, "unknown linewidth");
+ case 0: return 0; // keine Linie
+ case 1: nCode = DEF_LINE_WIDTH_0; break;
+ case 2: nCode = DEF_LINE_WIDTH_1; break;
+ case 3: nCode = DEF_LINE_WIDTH_2; break;
+ case 4: nCode = DEF_LINE_WIDTH_3; break;
+ case 5: nCode = DEF_LINE_WIDTH_4; break;
+ }
+ pLine->SetOutWidth(nCode);
+ pLine->SetInWidth(0);
+ }
+ else
+ {
+ switch(pBrc->dxpLine1WidthGet())
+ {
+ default: ASSERT(FALSE, "unknown linewidth");
+ case 1: nCode = DEF_DOUBLE_LINE0_IN; break;
+ }
+ pLine->SetOutWidth(nCode);
+ switch(pBrc->dxpLine2WidthGet())
+ {
+ default: ASSERT(FALSE, "unknown linewidth");
+ case 1: nCode = DEF_DOUBLE_LINE0_OUT; break;
+ }
+ pLine->SetInWidth(nCode);
+ }
+ switch(pBrc->dxpLine1WidthGet())
+ {
+ default: ASSERT(FALSE, "unknown space");
+ case 0: nCode = DEF_DOUBLE_LINE0_DIST; break;
+ case 1: nCode = DEF_DOUBLE_LINE1_DIST; break;
+ case 2: nCode = DEF_DOUBLE_LINE2_DIST; break;
+ case 3: nCode = DEF_DOUBLE_LINE3_DIST; break;
+ }
+ pLine->SetDistance(nCode);
+ return pLine;
+}
+#if 0
+SvxBorderLine* Ww1SingleSprmPBrc::SetBorder(SvxBorderLine* pLine, W1_BRC* pBrc)
+{
+ static USHORT __READONLY_DATA nOutTab[] = { // Aussenlinie
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0, // No Line -> hair line
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0,
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0,
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0, // Single Thin Dotted / Dashed
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0, // Single Line thin(Idx * 15tw)
+ DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_2,
+ DEF_LINE_WIDTH_2, DEF_LINE_WIDTH_3,
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0, // Single Thin Dotted / Dashed
+ DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_1, // Single Line thick(Idx * 30tw)
+ DEF_LINE_WIDTH_2, DEF_LINE_WIDTH_3,
+ DEF_LINE_WIDTH_4, DEF_LINE_WIDTH_4,
+ DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_1, // Single Thick Dotted / Dashed
+ DEF_DOUBLE_LINE0_OUT, DEF_DOUBLE_LINE0_OUT, // Double Line(Idx * 15tw)
+ DEF_DOUBLE_LINE1_OUT, DEF_DOUBLE_LINE2_OUT,
+ DEF_DOUBLE_LINE2_OUT, DEF_DOUBLE_LINE3_OUT,
+ DEF_DOUBLE_LINE0_OUT, DEF_DOUBLE_LINE0_OUT }; // Double Dotted / Dashed
+ static USHORT __READONLY_DATA nInTab[] = { // Innenlinie
+ 0, 0, 0, 0, 0, 0, 0, 0, // No line / dotted / dashed
+ 0, 0, 0, 0, 0, 0, 0, 0, // Single Line thin(Idx * 15tw)
+ 0, 0, 0, 0, 0, 0, 0, 0, // Single Line thick(Idx * 30tw)
+ DEF_DOUBLE_LINE0_IN, DEF_DOUBLE_LINE0_IN, // Double Line(Idx * 15tw)
+ DEF_DOUBLE_LINE1_IN, DEF_DOUBLE_LINE2_IN,
+ DEF_DOUBLE_LINE2_IN, DEF_DOUBLE_LINE3_IN,
+ DEF_DOUBLE_LINE0_IN, DEF_DOUBLE_LINE0_IN }; // Double Dotted / Dashed
+ static USHORT __READONLY_DATA nDistTab[] = { // Abstand der Linien
+ 0, 0, 0, 0, 0, 0, 0, 0, // No line / dotted / dashed
+ 0, 0, 0, 0, 0, 0, 0, 0, // Single Line thin(Idx * 15tw)
+ 0, 0, 0, 0, 0, 0, 0, 0, // Single Line thick(Idx * 30tw)
+ DEF_DOUBLE_LINE0_DIST, DEF_DOUBLE_LINE0_DIST, // Double Line(Idx * 15tw)
+ DEF_DOUBLE_LINE1_DIST, DEF_DOUBLE_LINE2_DIST,
+ DEF_DOUBLE_LINE2_DIST, DEF_DOUBLE_LINE3_DIST,
+ DEF_DOUBLE_LINE0_DIST, DEF_DOUBLE_LINE0_DIST }; // Double Dotted / Dashed
+ short nIdx = pBrc->dxpLineWidthGet() + 8 * pBrc->brcTypeGet();
+ pLine->SetOutWidth(nOutTab[nIdx]);
+ pLine->SetInWidth(nInTab[nIdx]);
+ pLine->SetDistance(nDistTab[nIdx]);
+ if(pBrc->icoGet())
+ {
+ ColorName nIdx;
+ switch(pBrc->icoGet())
+ {
+ default: ASSERT(FALSE, "unknown color code");
+ case 0:
+ case 1: nIdx = COL_BLACK; break;
+ case 2: nIdx = COL_LIGHTBLUE; break;
+ case 3: nIdx = COL_LIGHTCYAN; break;
+ case 4: nIdx = COL_LIGHTGREEN; break;
+ case 5: nIdx = COL_LIGHTMAGENTA; break;
+ case 6: nIdx = COL_LIGHTRED; break;
+ case 7: nIdx = COL_YELLOW; break;
+ case 8: nIdx = COL_WHITE; break;
+ }
+ Color aCol(nIdx);
+ pLine->SetColor(aCol);
+ }
+ return pLine;
+}
+#endif
+
+void Ww1SingleSprmPBrc::Start(
+ Ww1Shell& rOut, BYTE, W1_BRC10* pBrc, USHORT nSize, Ww1Manager& rMan, SvxBoxItem& aBox)
+{
+ ASSERT(sizeof(W1_BRC10) == nSize, "sizemissmatch");
+ if(pBrc->dxpSpaceGet())
+ aBox.SetDistance(10 + 20 * pBrc->dxpSpaceGet());
+ //??? Warum 10+... ????
+
+ if( rOut.IsInFly() )
+ rOut.SetFlyFrmAttr( aBox );
+ else
+ rOut << aBox;
+
+ if(pBrc->fShadowGet())
+ {
+ Color aBlack(COL_BLACK); // schwarzer...
+ SvxShadowItem aS(ITEMID_SHADOW,(const Color*)&aBlack, 32,
+ SVX_SHADOW_BOTTOMRIGHT); // 1.6 tw breit
+ if( rOut.IsInFly() )
+ rOut.SetFlyFrmAttr( aS );
+ else
+ rOut << aS;
+ }
+}
+
+STOP2(Ww1SingleSprmPBrc, RES_BOX, RES_SHADOW)
+
+static USHORT __READONLY_DATA nBrcTrans[BRC_ANZ] =
+ { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
+
+void Ww1SingleSprmPBrc10::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+
+ W1_BRC10* pBrc =(W1_BRC10*)pSprm;
+ const SfxPoolItem &rItem = ( ( rOut.IsInFly() ) ?
+ rOut.GetFlyFrmAttr(RES_BOX) :rOut.GetAttr(RES_BOX));
+ const SvxBoxItem &rBoxItem = (const SvxBoxItem&)rItem;
+ SvxBoxItem aBox( rBoxItem );
+// rOut >> aBox;
+ SvxBorderLine aLine;
+ aBox.SetLine(SetBorder(&aLine, pBrc), nBrcTrans[nLine] );
+ Ww1SingleSprmPBrc::Start(rOut, nId, pBrc, nSize, rMan, aBox);
+}
+
+STOP1(Ww1SingleSprmParaSpace, RES_UL_SPACE)
+
+void Ww1SingleSprmPDyaBefore::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nPara = SVBT16ToShort(pSprm);
+ if(nPara < 0)
+ nPara = -nPara;
+ SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE));
+ aUL.SetUpper(nPara);
+ rOut << aUL;
+}
+
+void Ww1SingleSprmPDyaAfter::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nPara = SVBT16ToShort(pSprm);
+ if(nPara < 0)
+ nPara = -nPara;
+ SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE));
+ aUL.SetLower(nPara);
+ rOut << aUL;
+}
+
+STOP1(Ww1SingleSprmPDyaLine, RES_PARATR_LINESPACING)
+
+void Ww1SingleSprmPDyaLine::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+ if(nSpace < 0)
+ nSpace = -nSpace;
+ SvxLineSpacingItem aLSpc;
+ if(TRUE)
+ {// MultilineSpace(proportional)
+ long n = nSpace * 100 / 240; // W1: 240 = 100%, SW: 100 = 100%
+ if(n>200)
+ n = 200; // SW_UI-Maximum
+ aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
+ aLSpc.SetPropLineSpace((BYTE)n);
+ }
+ else
+ {// Fixed / Minimum
+ aLSpc.SetLineHeight((USHORT)nSpace);
+ aLSpc.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
+ }
+ rOut << aLSpc;
+}
+
+void Ww1SingleSprmPChgTabsPapx::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+#ifdef DEBUG
+// rOut << 'T';
+#endif
+ short nLeftPMgn = 0; // Koordinaten etwa gleich ??
+// ( pAktColl ) ? pCollA[nAktColl].nLeftParaMgn
+// : nLeftParaMgn; // Absatz L-Space
+
+ short i;
+ BYTE nDel = pSprm[1];
+ BYTE* pDel = pSprm + 2; // Del - Array
+ BYTE nIns = pSprm[nDel*2+2];
+ BYTE* pIns = pSprm + 2*nDel + 3; // Ins - Array
+ W1_TBD* pTyp = (W1_TBD*)(pSprm + 2*nDel + 2*nIns + 3);// Typ - Array
+
+ SvxTabStopItem aAttr( (SvxTabStopItem&)rOut.GetNodeOrStyAttr( RES_PARATR_TABSTOP ));
+
+ SvxTabStop aTabStop;
+
+ for( i=0; i<nDel; i++ ){
+ USHORT nPos = aAttr.GetPos( SVBT16ToShort( pDel + i*2 ) - nLeftPMgn );
+ if( nPos != SVX_TAB_NOTFOUND )
+ aAttr.Remove( nPos, 1 );
+ }
+
+ for( i=0; i<nIns; i++ ){
+ short nPos = SVBT16ToShort( pIns + i*2 ) - nLeftPMgn;
+ if( nPos < 0 )
+ continue;
+ aTabStop.GetTabPos() = nPos;
+ switch( pTyp[i].jcGet() ){
+ case 0: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break;
+ case 1: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; break;
+ case 2: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; break;
+ case 3: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL; break;
+ case 4: continue; // ignoriere Bar
+ }
+
+ switch( pTyp[i].tlcGet() ){
+ case 0: aTabStop.GetFill() = ' '; break;
+ case 1: aTabStop.GetFill() = '.'; break;
+ case 2: aTabStop.GetFill() = '-'; break;
+ case 3:
+ case 4: aTabStop.GetFill() = '_'; break;
+ }
+
+ USHORT nPos2 = aAttr.GetPos( nPos );
+ if( nPos2 != SVX_TAB_NOTFOUND )
+ aAttr.Remove( nPos2, 1 ); // sonst weigert sich das Insert()
+
+ aAttr.Insert( aTabStop );
+ }
+ rOut << aAttr;
+}
+
+STOP1(Ww1SingleSprmPChgTabsPapx, RES_PARATR_TABSTOP)
+
+void Ww1SingleSprmSGprfIhdt::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ rMan.GetSep().SetGrpfIhdt(SVBT8ToByte(pSprm));
+}
+
+void Ww1SingleSprmSColumns::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nColSpace = 708; // default 1,25 cm
+ short nNettoWidth = -1; //~ mdt: dxaLeft/Right missing...
+ short nCols = SVBT16ToShort(pSprm);
+ nCols++;
+ if (nCols < 2)
+ return;
+ SwFmtCol aCol;
+ aCol.Init(nCols, nColSpace, nNettoWidth);
+ rOut.GetPageDesc().GetMaster().SetAttr(aCol);
+}
+
+void Ww1SingleSprmPTtp::Start(
+ Ww1Shell& rOut, BYTE, BYTE*, USHORT, Ww1Manager& rMan)
+{
+ rMan.SetInTtp( TRUE ); // Besonderheit: wird bei InTable::Stop und
+ // nicht bei InTtp::Stop zurueckgesetzt,
+ // da Auswertung in InTable
+}
+
+void Ww1SingleSprmPTtp::Stop(
+ Ww1Shell& rOut, BYTE, BYTE*, USHORT, Ww1Manager& rMan)
+{
+ if (rOut.IsInTable() && rMan.HasInTable())
+ rOut.NextTableRow();
+}
+
+void Ww1SingleSprmPFInTable::Start(
+ Ww1Shell& rOut, BYTE, BYTE*, USHORT,
+ Ww1Manager& rMan)
+{
+}
+
+void Ww1SingleSprmPFInTable::Stop(
+ Ww1Shell& rOut, BYTE, BYTE*, USHORT,
+ Ww1Manager& rMan)
+{
+ ASSERT(rOut.IsInTable(), "");
+// if (rOut.IsInTable() && rMan.HasInTable() && !rMan.IsInTtp() && !rMan.HasTtp())
+// rOut.NextTableCell();
+ rMan.SetInTtp( FALSE );
+}
+
+void Ww1SingleSprmTJc::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+}
+
+#if 0
+void Ww1SingleSprmTDxaLeft::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+ rOut.SetCellWidth(nSpace - rMan.GetX());
+ rMan.SetX(nSpace);
+}
+#endif
+
+void Ww1SingleSprmTDxaGapHalf::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+ rOut.SetCellSpace(nSpace);
+}
+
+void Ww1SingleSprmTDefTable10::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ int i;
+ BYTE *p = pSprm + 2; // LaengenWord ueberlesen
+ BYTE nCount = *p;
+ p++;
+ nSize -= 3;
+// Es fehlt noch:
+// - GapHalf
+// - eventuelle Ausduennung der Zellenumrandungen
+
+ if( nCount < 1 || nCount > 32 || nSize < ( nCount + 1 ) * 2 )
+ return;
+
+// Erstmal die Zellenpositionen einlesen
+ short nPos = SVBT16ToShort( p ); // signed, kann auch neg. sein !!!
+
+// if( !rOut.IsTableWidthSet() ){ // Muss Tabellenbreite und -Ausrichtung
+ // noch gesetzt werden ?
+ {
+ short nWholeWidth = SVBT16ToShort( p + 2 * nCount ) - nPos;
+ rOut.SetTableWidth( (USHORT)nWholeWidth ); // Tabellenbreite setzen
+
+// Pos der Tabelle setzen
+ long nMidTab = nPos + nWholeWidth / 2; // TabellenMitte
+ const SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
+ const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
+ long nRight = rFmt.GetFrmSize().GetWidth()
+ - rLR.GetLeft() - rLR.GetRight();
+
+ SwHoriOrient eOri = HORI_LEFT;
+ if( nPos > MINLAY ){ // per Zuppeln positioniert
+ if ( nMidTab <= nRight / 3 ) // 1/3 der Seite
+ eOri = HORI_LEFT;
+ else if ( nMidTab <= 2 * nRight / 3 ) // 2/3 der Seite
+ eOri = HORI_CENTER;
+ else
+ eOri = HORI_RIGHT;
+ }
+ rOut.SetTableOrient( eOri );
+ }
+
+ BYTE* pEndPos = p+2;
+ BYTE* pTc0 = ( nSize >= nCount * 10 ) ? pEndPos + 2 * nCount : 0;
+ USHORT nCellsDeleted = 0; // fuer gemergte Zellen
+
+ for( i = 0; i < nCount; i++ ){
+// Info sammeln
+ W1_TC* pTc = (W1_TC*)pTc0;
+ BOOL bFirstMerged = (pTc) ? pTc->fFirstMergedGet() : FALSE;
+ BOOL bMerged = (pTc) ? pTc->fMergedGet() : FALSE;
+
+// Zellenbreiten setzen
+ USHORT nPos1 = SVBT16ToShort( pEndPos );
+ if( !bMerged )
+ rOut.SetCellWidth( nPos1 - nPos, i - nCellsDeleted );
+ // Zellenbreite setzen
+ // Wechselwirkung mit GapHalf fehlt noch
+ // ( GapHalf wird noch ignoriert )
+ pEndPos+=2;
+ nPos = nPos1;
+
+ if( pTc0 ){ // gibts TCs ueberhaupt ?
+ W1_TC* pTc = (W1_TC*)pTc0;
+ BOOL bFirstMerged = pTc->fFirstMergedGet();
+ BOOL bMerged = pTc->fMergedGet();
+// ASSERT( !bMerged, "Gemergte Tabellenzellen noch nicht vollstaendig implementiert" );
+ if( !bMerged ){
+// und nun die Umrandungen
+ SvxBoxItem aBox( (SvxBoxItem&)rOut.GetCellAttr( RES_BOX ));
+ SvxBorderLine aLine;
+ W1_BRC10* pBrc = pTc->rgbrcGet();
+ for( USHORT j=0; j<4; j++ ){
+ aBox.SetLine(Ww1SingleSprmPBrc::SetBorder(&aLine, pBrc),
+ nBrcTrans[j]);
+ pBrc++;
+ }
+ rOut.SetCellBorder( aBox, i - nCellsDeleted );
+ }else{
+// gemergte Zellen entfernen
+ rOut.DeleteCell( i - nCellsDeleted );
+ nCellsDeleted++;
+ }
+ pTc0+=sizeof(W1_TC); // 10
+ }
+ }
+}
+
+
+void Ww1SingleSprmTDyaRowHeight::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+ rOut.SetCellHeight(nSpace);
+}
+
+// Fastsave-Attribute brauche ich als Dymmys nicht
+
+#if 0
+
+void Ww1SingleSprmTInsert::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+}
+
+void Ww1SingleSprmTDelete::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+}
+
+void Ww1SingleSprmTDxaCol::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+}
+
+void Ww1SingleSprmTMerge::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+}
+
+void Ww1SingleSprmTSplit::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nSpace = SVBT16ToShort(pSprm);
+}
+
+void Ww1SingleSprmTSetBrc10::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+}
+#endif // 0
+
+void Ww1SingleSprmPpc::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ BYTE nPpc = SVBT8ToByte(pSprm);
+
+ if (rOut.IsInTable()) // Flys in Tabellen kann PMW
+ return; // nicht
+
+ RndStdIds eAnchor; // Bindung
+ SwRelationOrient eHRel; // Seite oder Seitenrand
+ SwRelationOrient eVRel; // Seite oder Seitenrand
+
+ switch ( ( nPpc & 0x30 ) >> 4 ){ // Y - Bindung bestimmt Sw-Bindung
+ case 0: eAnchor = FLY_AT_CNTNT; // Vert Margin
+ eVRel = PRTAREA;
+// if( nYPos < 0 )
+// nYPos = 0; // koennen wir nicht
+ break;
+/* case 1:*/ // Vert. Seite
+ default:eAnchor = FLY_PAGE; // Vert Page oder unknown
+ eVRel = FRAME;
+ break; // 2=Vert. Paragraph, 3=Use Default
+ }
+
+ switch ( ( nPpc & 0xc0 ) >> 6 ){ // X - Bindung -> Koordinatentransformation
+ case 0: // Hor. Spalte
+ case 1: // Hor. Absatz
+ eHRel = PRTAREA;
+// nXPos += nPgLeft; // in Seiten-Koordinaten umrechnen
+ break;
+/* case 2:*/ // Hor. Seite
+ default:
+ eHRel = FRAME;
+ break;
+ }
+
+ if( !rOut.IsInFly() && rMan.IsInStyle() ){
+ rOut.BeginFly( eAnchor ); // Starte StyleFly
+ }else{
+ rOut.SetFlyAnchor( eAnchor ); // Setze Anker
+ }
+}
+
+void Ww1SingleSprmPDxaAbs::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nXPos = SVBT16ToShort(pSprm);
+
+ if( rMan.IsInStyle() && !rOut.IsInFly() ){
+ rOut.BeginFly(); // Fly ohne PPc-Attribut
+ }
+
+ SwRelationOrient eHRel = FRAME;
+ SwHoriOrient eHAlign = HORI_NONE;
+
+ switch( nXPos ){ // besondere X-Positionen ?
+ case 0:
+ case -12: eHAlign = HORI_NONE; nXPos = 0; break; // Mogel: innen -> links
+ // eigentich HORI_LEFT, aber dann verrueckt
+ // ein Abstand nach aussen den Fly
+ case -4: eHAlign = HORI_CENTER; nXPos = 0; break; // zentriert
+ case -8: // rechts
+ case -16: eHAlign = HORI_RIGHT; nXPos = 0; break; // Mogel: aussen -> rechts
+// default: nXPos += (short)nIniFlyDx; break; // Korrekturen per Ini-Datei
+ }
+ rOut.SetFlyXPos( nXPos, eHRel, eHAlign );
+}
+
+void Ww1SingleSprmPDyaAbs::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nYPos = SVBT16ToShort(pSprm);
+ SwRelationOrient eVRel = FRAME;
+ SwVertOrient eVAlign = VERT_NONE;
+
+ switch( nYPos ){ // besondere Y-Positionen ?
+ case -4: eVAlign = VERT_TOP; nYPos = 0; break; // oben
+ case -8: eVAlign = VERT_CENTER; nYPos = 0; break; // zentriert
+ case -12: eVAlign = VERT_BOTTOM; nYPos = 0; break; // unten
+// default: nYPos += (short)nIniFlyDy; break; // Korrekturen per Ini-Datei
+ }
+ rOut.SetFlyYPos( nYPos, eVRel, eVAlign );
+}
+
+void Ww1SingleSprmPDxaWidth::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ short nDxaWidth = SVBT16ToShort(pSprm);
+ rOut.SetFlyFrmAttr( SwFmtFrmSize( ATT_VAR_SIZE, nDxaWidth, MINFLY ) );
+}
+
+void Ww1SingleSprmPFromText::Start(
+ Ww1Shell& rOut, BYTE nId, BYTE* pSprm, USHORT nSize, Ww1Manager& rMan)
+{
+ if( rOut.IsInFly() ){ // Kommt auch ausserhalb eines Flys vor, hat
+ // dann aber offensichtlich nichts zu bedeuten.
+ // Einen impliziten Fly-Anfang bedeutet es
+ // definitiv nicht
+ short nFromText = SVBT16ToShort(pSprm);
+
+ SvxLRSpaceItem aLR;
+ aLR.SetTxtLeft( nFromText );
+ aLR.SetRight( nFromText );
+ rOut.SetFlyFrmAttr( aLR );
+
+ rOut.SetFlyFrmAttr( SvxULSpaceItem( nFromText, nFromText ) );
+ }
+}
+
+#undef STOP1
+#undef STOP2
+
+/**********************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww1/w1sprm.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.19 2000/09/18 16:04:57 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.18 2000/05/11 16:06:59 jp
+ Changes for Unicode
+
+ Revision 1.17 2000/03/03 15:22:12 os
+ StarView remainders removed
+
+ Revision 1.16 1998/06/29 11:01:32 JP
+ SvxFmtBreakItem ohne Flag!
+
+
+ Rev 1.15 29 Jun 1998 13:01:32 JP
+ SvxFmtBreakItem ohne Flag!
+
+ Rev 1.14 19 Feb 1998 17:01:14 HJS
+ fuer sh eingechecked
+
+ Rev 1.12 29 Nov 1997 17:37:08 MA
+ includes
+
+ Rev 1.11 09 Oct 1997 14:13:48 JP
+ Aenderungen von SH
+
+ Rev 1.6 11 Aug 1997 12:52:20 SH
+ Flys und einfache Tabellen und Tabulatoren
+
+ Rev 1.5 18 Jul 1997 09:31:38 MA
+ Stand von SH, #41738# GPF und Tabellen etwas besser
+
+ Rev 1.4 16 Jun 1997 13:08:56 MA
+ Stand Micheal Dietrich
+
+ Rev 1.3 12 Mar 1997 19:12:54 SH
+ MDT: Progressbar, Pagedesc-Bug, Spalten, Anfang Tabellen u.a.
+
+ Rev 1.2 13 Jan 1997 16:42:02 NF
+ __READONLY_DATA fr Win16 korrigiert: Typ __READONLY_DATA identifier ...
+
+ Rev 1.1 10 Jan 1997 18:47:34 SH
+ Stabiler und mehr von MDT
+
+ Rev 1.0 28 Nov 1996 18:09:30 SH
+ Schneller Schoener Weiter von MDT
+
+ Rev 1.0 14 Aug 1996 19:32:28 SH
+ Initial revision.
+
+
+**********************************************************************/
+//]})
diff --git a/sw/source/filter/ww1/w1struct.hxx b/sw/source/filter/ww1/w1struct.hxx
new file mode 100644
index 000000000000..92ebbf4a8609
--- /dev/null
+++ b/sw/source/filter/ww1/w1struct.hxx
@@ -0,0 +1,965 @@
+/*************************************************************************
+ *
+ * $RCSfile: w1struct.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 W1STRUCT_HXX
+#define W1STRUCT_HXX
+
+// star view
+#include <string.h>
+
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+
+class Ww1Shell;
+class Ww1Manager;
+
+struct W1_FIB /////////////////////////////////////////////////////////
+{
+ SVBT16 wIdent;// 0x0 int magic number
+ USHORT wIdentGet() {
+ return SVBT16ToShort(wIdent); }
+ SVBT16 nFib;// 0x2 FIB version written
+ USHORT nFibGet() {
+ return SVBT16ToShort(nFib); }
+ SVBT16 nProduct;// 0x4 product version written by
+ USHORT nProductGet() {
+ return SVBT16ToShort(nProduct); }
+ SVBT16 nlocale;// 0x6 language stamp---localized version;
+ USHORT nlocaleGet() {
+ return SVBT16ToShort(nlocale); }
+ SVBT16 pnNext;// 0x8
+ USHORT pnNextGet() {
+ return SVBT16ToShort(pnNext); }
+ SVBT16 fFlags;
+ USHORT fFlagsGet() {
+ return SVBT16ToShort(fFlags); }
+ // SVBT16 fDot :1;// 0xa 0001
+ BOOL fDotGet() {
+ return ((fFlagsGet() >> 0) & 1); }
+ // SVBT16 fGlsy :1;// 0002
+ BOOL fGlsyGet() {
+ return ((fFlagsGet() >> 1) & 1); }
+ // SVBT16 fComplex :1;// 0004 when 1, file is in complex, fast-saved format.
+ BOOL fComplexGet() {
+ return ((fFlagsGet() >> 2) & 1); }
+ // SVBT16 fHasPic :1;// 0008 file contains 1 or more pictures
+ BOOL fHasPicGet() {
+ return ((fFlagsGet() >> 3) & 1); }
+ // SVBT16 cQuickSaves :4;// 00F0 count of times file was quicksaved
+ USHORT cQuickSavesGet() {
+ return (USHORT)((fFlagsGet() >> 4) & 0xf); }
+ // SVBT16 u1 :8;// FF00 unused
+ USHORT u1Get() {
+ return (USHORT)((fFlagsGet() >> 8) & 0xff); }
+ SVBT16 nFibBack;// 0xc
+ USHORT nFibBackGet() {
+ return SVBT16ToShort(nFibBack); }
+ SVBT16 u2[5];// 0xe reserved
+ SVBT32 fcMin;// 0x18 file offset of first character of text
+ ULONG fcMinGet() {
+ return SVBT32ToLong(fcMin); }
+ SVBT32 fcMac;// 0x1c file offset of last character of text + 1
+ ULONG fcMacGet() {
+ return SVBT32ToLong(fcMac); }
+ SVBT32 cbMac;// 0x20 file offset of last byte written to file + 1.
+ ULONG cbMacGet() {
+ return SVBT32ToLong(cbMac); }
+ SVBT32 u4[4];// 0x24 reserved
+ SVBT32 ccpText;// 0x34 length of main document text stream
+ ULONG ccpTextGet() {
+ return SVBT32ToLong(ccpText); }
+ SVBT32 ccpFtn;// 0x38 length of footnote subdocument text stream
+ ULONG ccpFtnGet() {
+ return SVBT32ToLong(ccpFtn); }
+ SVBT32 ccpHdd;// 0x3c length of header subdocument text stream
+ ULONG ccpHddGet() {
+ return SVBT32ToLong(ccpHdd); }
+ SVBT32 ccpMcr;// 0x40 length of macro subdocument text stream
+ ULONG ccpMcrGet() {
+ return SVBT32ToLong(ccpMcr); }
+ SVBT32 ccpAtn;// 0x44 length of annotation subdocument text stream
+ ULONG ccpAtnGet() {
+ return SVBT32ToLong(ccpAtn); }
+ SVBT32 cp5[4];// 0x48
+ SVBT32 fcStshfOrig;// 0x58 file offset of original allocation for STSH in file
+ ULONG fcStshfOrigGet() {
+ return SVBT32ToLong(fcStshfOrig); }
+ SVBT16 cbStshfOrig;// 0x5c count of bytes of original STSH allocation
+ USHORT cbStshfOrigGet() {
+ return SVBT16ToShort(cbStshfOrig); }
+ SVBT32 fcStshf;// 0x5e file offset of STSH in file.
+ ULONG fcStshfGet() {
+ return SVBT32ToLong(fcStshf); }
+ SVBT16 cbStshf;// 0x62 count of bytes of current STSH allocation
+ USHORT cbStshfGet() {
+ return SVBT16ToShort(cbStshf); }
+ SVBT32 fcPlcffndRef;// 0x64 file offset of footnote reference PLC.
+ ULONG fcPlcffndRefGet() {
+ return SVBT32ToLong(fcPlcffndRef); }
+ SVBT16 cbPlcffndRef;// 0x68 count of bytes of footnote reference PLC
+ USHORT cbPlcffndRefGet() {
+ return SVBT16ToShort(cbPlcffndRef); }
+ // == 0 if no footnotes defined in document.
+
+ SVBT32 fcPlcffndTxt;// 0x6a file offset of footnote text PLC.
+ ULONG fcPlcffndTxtGet() {
+ return SVBT32ToLong(fcPlcffndTxt); }
+ SVBT16 cbPlcffndTxt;// 0x6e count of bytes of footnote text PLC.
+ USHORT cbPlcffndTxtGet() {
+ return SVBT16ToShort(cbPlcffndTxt); }
+ // == 0 if no footnotes defined in document
+
+ SVBT32 fcPlcfandRef;// 0x70 file offset of annotation reference PLC.
+ ULONG fcPlcfandRefGet() {
+ return SVBT32ToLong(fcPlcfandRef); }
+ SVBT16 cbPlcfandRef;// 0x74 count of bytes of annotation reference PLC.
+ USHORT cbPlcfandRefGet() {
+ return SVBT16ToShort(cbPlcfandRef); }
+
+ SVBT32 fcPlcfandTxt;// 0x76 file offset of annotation text PLC.
+ ULONG fcPlcfandTxtGet() {
+ return SVBT32ToLong(fcPlcfandTxt); }
+ SVBT16 cbPlcfandTxt;// 0x7a count of bytes of the annotation text PLC
+ USHORT cbPlcfandTxtGet() {
+ return SVBT16ToShort(cbPlcfandTxt); }
+
+ SVBT32 fcPlcfsed;// 8x7c file offset of section descriptor PLC.
+ ULONG fcPlcfsedGet() {
+ return SVBT32ToLong(fcPlcfsed); }
+ SVBT16 cbPlcfsed;// 0x80 count of bytes of section descriptor PLC.
+ USHORT cbPlcfsedGet() {
+ return SVBT16ToShort(cbPlcfsed); }
+
+ SVBT32 fcPlcfpgd;// 0x82 file offset of paragraph descriptor PLC
+ ULONG fcPlcfpgdGet() {
+ return SVBT32ToLong(fcPlcfpgd); }
+ SVBT16 cbPlcfpgd;// 0x86 count of bytes of paragraph descriptor PLC.
+ USHORT cbPlcfpgdGet() {
+ return SVBT16ToShort(cbPlcfpgd); }
+ // ==0 if file was never repaginated
+ // Should not be written by third party creators
+
+ SVBT32 fcPlcfphe;// 0x88 file offset of PLC of paragraph heights.
+ ULONG fcPlcfpheGet() {
+ return SVBT32ToLong(fcPlcfphe); }
+ SVBT16 cbPlcfphe;// 0x8c count of bytes of paragraph height PLC.
+ USHORT cbPlcfpheGet() {
+ return SVBT16ToShort(cbPlcfphe); }
+ // ==0 when file is non-complex.
+
+ SVBT32 fcSttbfglsy;// 0x8e file offset of glossary string table.
+ ULONG fcSttbfglsyGet() {
+ return SVBT32ToLong(fcSttbfglsy); }
+ SVBT16 cbSttbfglsy;// 0x92 count of bytes of glossary string table.
+ USHORT cbSttbfglsyGet() {
+ return SVBT16ToShort(cbSttbfglsy); }
+ // == 0 for non-glossary documents.
+ // !=0 for glossary documents.
+
+ SVBT32 fcPlcfglsy;// 0x94 file offset of glossary PLC.
+ ULONG fcPlcfglsyGet() {
+ return SVBT32ToLong(fcPlcfglsy); }
+ SVBT16 cbPlcfglsy;// 0x98 count of bytes of glossary PLC.
+ USHORT cbPlcfglsyGet() {
+ return SVBT16ToShort(cbPlcfglsy); }
+ // == 0 for non-glossary documents.
+ // !=0 for glossary documents.
+
+ SVBT32 fcPlcfhdd;// 0x9a byte offset of header PLC.
+ ULONG fcPlcfhddGet() {
+ return SVBT32ToLong(fcPlcfhdd); }
+ SVBT16 cbPlcfhdd;// 0x9e count of bytes of header PLC.
+ USHORT cbPlcfhddGet() {
+ return SVBT16ToShort(cbPlcfhdd); }
+ // == 0 if document contains no headers
+
+ SVBT32 fcPlcfbteChpx;// 0xa0 file offset of character property bin table.PLC.
+ ULONG fcPlcfbteChpxGet() {
+ return SVBT32ToLong(fcPlcfbteChpx); }
+ SVBT16 cbPlcfbteChpx;// 0xa4 count of bytes of character property bin table PLC.
+ USHORT cbPlcfbteChpxGet() {
+ return SVBT16ToShort(cbPlcfbteChpx); }
+
+ SVBT32 fcPlcfbtePapx;// 0xa6 file offset of paragraph property bin table.PLC.
+ ULONG fcPlcfbtePapxGet() {
+ return SVBT32ToLong(fcPlcfbtePapx); }
+ SVBT16 cbPlcfbtePapx;// 0xaa count of bytes of paragraph property bin table PLC.
+ USHORT cbPlcfbtePapxGet() {
+ return SVBT16ToShort(cbPlcfbtePapx); }
+
+ SVBT32 fcPlcfsea;// 0xac file offset of PLC reserved for private use. The SEA is 6 bytes long.
+ ULONG fcPlcfseaGet() {
+ return SVBT32ToLong(fcPlcfsea); }
+ SVBT16 cbPlcfsea;// 0xb0 count of bytes of private use PLC.
+ USHORT cbPlcfseaGet() {
+ return SVBT16ToShort(cbPlcfsea); }
+
+ SVBT32 fcSttbfffn;// 0xb2 file offset of font information STTBF. See the FFN file structure definition.
+ ULONG fcSttbfffnGet() {
+ return SVBT32ToLong(fcSttbfffn); }
+ SVBT16 cbSttbfffn;// 0xb6 count of bytes in sttbfffn.
+ USHORT cbSttbfffnGet() {
+ return SVBT16ToShort(cbSttbfffn); }
+
+ SVBT32 fcPlcffldMom;// 0xb8 offset in doc stream to the PLC of field positions in the main document.
+ ULONG fcPlcffldMomGet() {
+ return SVBT32ToLong(fcPlcffldMom); }
+ SVBT16 cbPlcffldMom;// 0xbc
+ USHORT cbPlcffldMomGet() {
+ return SVBT16ToShort(cbPlcffldMom); }
+
+ SVBT32 fcPlcffldHdr;// 0xbe offset in doc stream to the PLC of field positions in the header subdocument.
+ ULONG fcPlcffldHdrGet() {
+ return SVBT32ToLong(fcPlcffldHdr); }
+ SVBT16 cbPlcffldHdr;// 0xc2
+ USHORT cbPlcffldHdrGet() {
+ return SVBT16ToShort(cbPlcffldHdr); }
+
+ SVBT32 fcPlcffldFtn;// 0xc4 offset in doc stream to the PLC of field positions in the footnote subdocument.
+ ULONG fcPlcffldFtnGet() {
+ return SVBT32ToLong(fcPlcffldFtn); }
+ SVBT16 cbPlcffldFtn;// 0xc8
+ USHORT cbPlcffldFtnGet() {
+ return SVBT16ToShort(cbPlcffldFtn); }
+
+ SVBT32 fcPlcffldAtn;// 0xca offset in doc stream to the PLC of field positions in the annotation subdocument.
+ ULONG fcPlcffldAtnGet() {
+ return SVBT32ToLong(fcPlcffldAtn); }
+ SVBT16 cbPlcffldAtn;// 0xce
+ USHORT cbPlcffldAtnGet() {
+ return SVBT16ToShort(cbPlcffldAtn); }
+
+ SVBT32 fcPlcffldMcr;// 0xd0 offset in doc stream to the PLC of field positions in the macro subdocument.
+ ULONG fcPlcffldMcrGet() {
+ return SVBT32ToLong(fcPlcffldMcr); }
+ SVBT16 cbPlcffldMcr;// 0xd4
+ USHORT cbPlcffldMcrGet() {
+ return SVBT16ToShort(cbPlcffldMcr); }
+
+ SVBT32 fcSttbfbkmk;// 0xd6 offset in document stream of the STTBF that records bookmark names in the main document
+ ULONG fcSttbfbkmkGet() {
+ return SVBT32ToLong(fcSttbfbkmk); }
+ SVBT16 cbSttbfbkmk;// 0xda
+ USHORT cbSttbfbkmkGet() {
+ return SVBT16ToShort(cbSttbfbkmk); }
+
+ SVBT32 fcPlcfbkf;// 0xdc offset in document stream of the PLCF that records the beginning CP offsets of bookmarks in the main document. See BKF
+ ULONG fcPlcfbkfGet() {
+ return SVBT32ToLong(fcPlcfbkf); }
+ SVBT16 cbPlcfbkf;// 0xe0
+ USHORT cbPlcfbkfGet() {
+ return SVBT16ToShort(cbPlcfbkf); }
+
+ SVBT32 fcPlcfbkl;// 0xe2 offset in document stream of the PLCF that records the ending CP offsets of bookmarks recorded in the main document. See the BKL structure definition.
+ ULONG fcPlcfbklGet() {
+ return SVBT32ToLong(fcPlcfbkl); }
+ SVBT16 cbPlcfbkl;// 0xe6 SVBT16
+ USHORT cbPlcfbklGet() {
+ return SVBT16ToShort(cbPlcfbkl); }
+
+ SVBT32 fcCmds;// 0xe8 FC
+ ULONG fcCmdsGet() {
+ return SVBT32ToLong(fcCmds); }
+ SVBT16 cbCmds;// 0xec
+ USHORT cbCmdsGet() {
+ return SVBT16ToShort(cbCmds); }
+
+ SVBT32 fcPlcmcr;// 0xee FC
+ ULONG fcPlcmcrGet() {
+ return SVBT32ToLong(fcPlcmcr); }
+ SVBT16 cbPlcmcr;// 0xf2
+ USHORT cbPlcmcrGet() {
+ return SVBT16ToShort(cbPlcmcr); }
+
+ SVBT32 fcSttbfmcr;// 0xf4 FC
+ ULONG fcSttbfmcrGet() {
+ return SVBT32ToLong(fcSttbfmcr); }
+ SVBT16 cbSttbfmcr;// 0xf8
+ USHORT cbSttbfmcrGet() {
+ return SVBT16ToShort(cbSttbfmcr); }
+
+ SVBT32 fcPrEnv;// 0xfa
+ ULONG fcPrEnvGet() {
+ return SVBT32ToLong(fcPrEnv); }
+ SVBT16 cbPrEnv;// 0xfe
+ USHORT cbPrEnvGet() {
+ return SVBT16ToShort(cbPrEnv); }
+
+ SVBT32 fcWss;// 0x100 file offset of Window Save State data structure. See WSS.
+ ULONG fcWssGet() {
+ return SVBT32ToLong(fcWss); }
+ SVBT16 cbWss;// 0x100 count of bytes of WSS. ==0 if unable to store the window state.
+ USHORT cbWssGet() {
+ return SVBT16ToShort(cbWss); }
+
+ SVBT32 fcDop;// 0x106 file offset of document property data structure.
+ ULONG fcDopGet() {
+ return SVBT32ToLong(fcDop); }
+ SVBT16 cbDop;// 0x10a count of bytes of document properties.
+ USHORT cbDopGet() {
+ return SVBT16ToShort(cbDop); }
+
+
+ SVBT32 fcSttbfAssoc;// 0x10c offset to STTBF of associated strings. See STTBFASSOC.
+ ULONG fcSttbfAssocGet() {
+ return SVBT32ToLong(fcSttbfAssoc); }
+ SVBT16 cbSttbfAssoc;// 0x110
+ USHORT cbSttbfAssocGet() {
+ return SVBT16ToShort(cbSttbfAssoc); }
+
+ SVBT32 fcClx;// 0x112 file offset of beginning of information for complex files.
+ ULONG fcClxGet() {
+ return SVBT32ToLong(fcClx); }
+ SVBT16 cbClx;// 0x116 count of bytes of complex file information. 0 if file is non-complex.
+ USHORT cbClxGet() {
+ return SVBT16ToShort(cbClx); }
+
+ SVBT32 fcPlcfpgdFtn;// 0x118 file offset of page descriptor PLC for footnote subdocument.
+ ULONG fcPlcfpgdFtnGet() {
+ return SVBT32ToLong(fcPlcfpgdFtn); }
+ SVBT16 cbPlcfpgdFtn;// 0x11C count of bytes of page descriptor PLC for footnote subdocument.
+ USHORT cbPlcfpgdFtnGet() {
+ return SVBT16ToShort(cbPlcfpgdFtn); }
+ // ==0 if document has not been paginated. The length of the PGD is 8 bytes.
+
+ SVBT32 fcSpare1;// 0x11e file offset of the name of the original file.
+ ULONG fcSpare1Get() {
+ return SVBT32ToLong(fcSpare1); }
+ SVBT16 cbSpare1;// 0x122 count of bytes of the name of the original file.
+ USHORT cbSpare1Get() {
+ return SVBT16ToShort(cbSpare1); }
+ SVBT32 fcSpare2;// 0x124 file offset of the name of the original file.
+ ULONG fcSpare2Get() {
+ return SVBT32ToLong(fcSpare2); }
+ SVBT16 cbSpare2;// 0x128 count of bytes of the name of the original file.
+ USHORT cbSpare2Get() {
+ return SVBT16ToShort(cbSpare2); }
+ SVBT32 fcSpare3;// 0x12a file offset of the name of the original file.
+ ULONG fcSpare3Get() {
+ return SVBT32ToLong(fcSpare3); }
+ SVBT16 cbSpare3;// 0x12e count of bytes of the name of the original file.
+ USHORT cbSpare3Get() {
+ return SVBT16ToShort(cbSpare3); }
+ SVBT32 fcSpare4;// 0x130 file offset of the name of the original file.
+ ULONG fcSpare4Get() {
+ return SVBT32ToLong(fcSpare4); }
+ SVBT16 cbSpare4;// 0x134 count of bytes of the name of the original file.
+ USHORT cbSpare4Get() {
+ return SVBT16ToShort(cbSpare4); }
+
+ SVBT16 cpnBteChp;// 0x18E count of CHPX FKPs recorded in file. In non-complex files if the number of
+ USHORT cpnBteChpGet() {
+ return SVBT16ToShort(cpnBteChp); }
+ // entries in the plcfbteChpx is less than this, the plcfbteChpx is incomplete.
+ SVBT16 cpnBtePap;// 0x190 count of PAPX FKPs recorded in file. In non-complex files if the number of
+ USHORT cpnBtePapGet() {
+ return SVBT16ToShort(cpnBtePap); }
+ // entries in the plcfbtePapx is less than this, the plcfbtePapx is incomplete.
+};
+
+struct W1_DOP ///////////////////////////////////// Document Properties
+{
+ SVBT16 fFlags;
+ USHORT fFlagsGet() {
+ return SVBT16ToShort(fFlags); }
+ // SVBT16 fFacingPages : 1;// 1 when facing pages should be printed
+ BOOL fFacingPagesGet() {
+ return ((fFlagsGet() >> 0) & 1); }
+ // SVBT16 fWidowControl : 1;// 1 when widow control is in effect. 0 when widow control disabled.
+ BOOL fWidowControlGet() {
+ return ((fFlagsGet() >> 1) & 1); }
+ // SVBT16 : 3;// unused
+ // SVBT16 fpc : 2;// 1 footnote position code: 0 as endnotes, 1 at bottom of page, 2 immediately beneath text
+ USHORT fpcGet() {
+ return (USHORT)((fFlagsGet() >> 5) & 3); }
+ // SVBT16 fWide : 1;// Landscape
+ BOOL fWideGet() {
+ return ((fFlagsGet() >> 7) & 1); }
+ // SVBT16 grpfIhdt : 8;// 0 specification of document headers and footers. See explanation under Headers and Footers topic.
+ USHORT grpfIhdtGet() {
+ return (USHORT)((fFlagsGet() >> 8) & 0xff); }
+ SVBT16 fFtnFlags;
+ USHORT fFtnFlagsGet() {
+ return SVBT16ToShort(fFtnFlags); }
+ // SVBT16 fFtnRestart : 1;
+ BOOL fFtnRestartGet() {
+ return ((fFtnFlagsGet() >> 0) & 1); }
+ // SVBT16 nFtn : 15;// 1 initial footnote number for document
+ USHORT nFtnGet() {
+ return (USHORT)((fFtnFlagsGet() >> 1) & 0x7fff); }
+ SVBT16 fRvsFlags;
+ USHORT fRvsFlagsGet() {
+ return SVBT16ToShort(fRvsFlags); }
+ // SVBT16 irmBar : 8;
+ USHORT irmBarGet() {
+ return (USHORT)((fRvsFlagsGet() >> 0) & 0xff); }
+ // SVBT16 irmProps : 7;
+ USHORT irmPropsGet() {
+ return (USHORT)((fRvsFlagsGet() >> 8) & 0x7f); }
+ // SVBT16 fRevMarking : 1;// when 1, Word will mark revisions as the document is edited
+ BOOL fRevMarkingGet() {
+ return ((fRvsFlagsGet() >> 15) & 1); }
+ SVBT16 fSveFlags;
+ USHORT fSveFlagsGet() {
+ return SVBT16ToShort(fSveFlags); }
+ // SVBT16 fBackup : 1;// always make backup when document saved when 1.
+ BOOL fBackupGet() {
+ return ((fSveFlagsGet() >> 0) & 1); }
+ // SVBT16 fExactCWords : 1;
+ BOOL fExactCWordsGet() {
+ return ((fSveFlagsGet() >> 1) & 1); }
+ // SVBT16 fPagHidden : 1;//
+ BOOL fPagHiddenGet() {
+ return ((fSveFlagsGet() >> 2) & 1); }
+ // SVBT16 fPagResults : 1;
+ BOOL fPagResultsGet() {
+ return ((fSveFlagsGet() >> 3) & 1); }
+ // SVBT16 fLockAtn : 1;// when 1, annotations are locked for editing
+ BOOL fLockAtnGet() {
+ return ((fSveFlagsGet() >> 4) & 1); }
+ // SVBT16 fMirrorMargins : 1;// swap margins on left/right pages when 1.
+ BOOL fMirrorMarginsGet() {
+ return ((fSveFlagsGet() >> 5) & 1); }
+ // SVBT16 : 10;// unused
+ SVBT16 fSpares;
+ USHORT fSparesGet() {
+ return SVBT16ToShort(fSpares); }
+ SVBT16 yaPage;
+ USHORT yaPageGet() {
+ return SVBT16ToShort(yaPage); }
+ SVBT16 xaPage;
+ USHORT xaPageGet() {
+ return SVBT16ToShort(xaPage); }
+ SVBT16 dyaTop;
+ USHORT dyaTopGet() {
+ return SVBT16ToShort(dyaTop); }
+ SVBT16 dxaLeft;
+ USHORT dxaLeftGet() {
+ return SVBT16ToShort(dxaLeft); }
+ SVBT16 dyaBottom;
+ USHORT dyaBottomGet() {
+ return SVBT16ToShort(dyaBottom); }
+ SVBT16 dxaRight;
+ USHORT dxaRightGet() {
+ return SVBT16ToShort(dxaRight); }
+ SVBT16 dxaGutter;
+ USHORT dxaGutterGet() {
+ return SVBT16ToShort(dxaGutter); }
+ SVBT16 dxaTab;// 720 twips default tab width
+ USHORT dxaTabGet() {
+ return SVBT16ToShort(dxaTab); }
+ SVBT16 wSpare;//
+ USHORT wSpareGet() {
+ return SVBT16ToShort(wSpare); }
+ SVBT16 dxaHotZ;// width of hyphenation hot zone measured in twips
+ USHORT dxaHotZGet() {
+ return SVBT16ToShort(dxaHotZ); }
+ SVBT16 rgwSpare[2];// reserved
+ SVBT32 dttmCreated;// DTTM date and time document was created
+ ULONG dttmCreatedGet() {
+ return SVBT32ToLong(dttmCreated); }
+ SVBT32 dttmRevised;// DTTM date and time document was last revised
+ ULONG dttmRevisedGet() {
+ return SVBT32ToLong(dttmRevised); }
+ SVBT32 dttmLastPrint;// DTTM date and time document was last printed
+ ULONG dttmLastPrintGet() {
+ return SVBT32ToLong(dttmLastPrint); }
+ SVBT16 nRevision;// number of times document has been revised since its creation
+ USHORT nRevisionGet() {
+ return SVBT16ToShort(nRevision); }
+ SVBT32 tmEdited;// time document was last edited
+ ULONG tmEditedGet() {
+ return SVBT32ToLong(tmEdited); }
+ SVBT32 cWords;// count of words tallied by last Word Count execution
+ ULONG cWordsGet() {
+ return SVBT32ToLong(cWords); }
+ SVBT32 cCh;// count of characters tallied by last Word Count execution
+ ULONG cChGet() {
+ return SVBT32ToLong(cCh); }
+ SVBT16 cPg;// count of pages tallied by last Word Count execution
+ USHORT cPgGet() {
+ return SVBT16ToShort(cPg); }
+ SVBT16 rgwSpareDocSum[2];
+};
+// cbDOP is 66.
+
+struct W1_CHP /////////////////////////////////////////////////////////
+{
+ SVBT16 fChar;
+ SVBT16 ftc;// Font Code
+ SVBT8 hps;// Font size in half points
+ SVBT8 hpsPos;// Sub/Superscript ( signed number, 0 = normal )
+ SVBT16 fText;
+ SVBT32 fcPic;// not stored in File
+ SVBT8 fnPic;// internal
+ SVBT16 hpsLargeChp;// ???
+
+ W1_CHP() { memset( this, 0, sizeof( *this)); }
+
+ USHORT fCharGet() { return SVBT16ToShort(fChar); }
+ void fCharSet(USHORT n) { ShortToSVBT16(n, fChar); }
+ BOOL fBoldGet() { return ((fCharGet() >> 0) & 1); }
+ void fBoldSet(BOOL b) { fCharSet( ( fCharGet() & 0xfffe ) | ( b << 0 ) ); }
+ BOOL fItalicGet() { return ((fCharGet() >> 1) & 1); }
+ void fItalicSet(BOOL b) { fCharSet( ( fCharGet() & 0xfffd ) | ( b << 1 ) ); }
+ BOOL fStrikeGet() { return ((fCharGet() >> 2) & 1); }
+ BOOL fOutlineGet() { return ((fCharGet() >> 3) & 1); }
+ BOOL fFldVanishGet() { return ((fCharGet() >> 4) & 1); }
+ BOOL fSmallCapsGet() { return ((fCharGet() >> 5) & 1); }
+ BOOL fCapsGet() { return ((fCharGet() >> 6) & 1); }
+ BOOL fVanishGet() { return ((fCharGet() >> 7) & 1); }
+ BOOL fRMarkGet() { return ((fCharGet() >> 8) & 1); }
+ BOOL fSpecGet() { return ((fCharGet() >> 9) & 1); }
+ BOOL fsIcoGet() { return ((fCharGet() >> 10) & 1); }
+ BOOL fsFtcGet() { return ((fCharGet() >> 11) & 1); }
+ void fsFtcSet(BOOL b) { fCharSet( ( fCharGet() & 0xf7ff ) | ( b << 11 ) ); }
+ BOOL fsHpsGet() { return ((fCharGet() >> 12) & 1); }
+ void fsHpsSet(BOOL b) { fCharSet( ( fCharGet() & 0xefff ) | ( b << 12 ) ); }
+ BOOL fsKulGet() { return ((fCharGet() >> 13) & 1); }
+ void fsKulSet(BOOL b) { fCharSet( ( fCharGet() & 0xdfff ) | ( b << 13 ) ); }
+ BOOL fsPosGet() { return ((fCharGet() >> 14) & 1); }
+ BOOL fsSpaceGet() { return ((fCharGet() >> 15) & 1); }
+ // SVBT16 fBold :1;// 1 == opposite boldness of style
+ // SVBT16 fItalic :1;// 1 == opposite of style
+ // SVBT16 fStrike :1;// 1 == opposite of style
+ // SVBT16 fOutline :1;// 1 == opposite of style
+ // SVBT16 fFldVanish :1;// 1 == opposite of style
+ // SVBT16 fSmallCaps :1;// 1 == opposite of style
+ // SVBT16 fCaps :1;// 1 == opposite of style
+ // SVBT16 fVanish :1;// 1 == opposite of style
+ // SVBT16 fRMark :1;// ???
+ // SVBT16 fSpec :1;// 1 == opposite of style
+ // SVBT16 fsIco :1;// 1 == Color (ico) different to style
+ // SVBT16 fsFtc :1;// 1 == FontCode (ftc) different to style
+ // SVBT16 fsHps :1;// 1 == FontSize (hps) different to style
+ // SVBT16 fsKul :1;// 1 == Underline Code (kul) different to style
+ // SVBT16 fsPos :1;// 1 == Char position (hpsPos) different to style
+ // SVBT16 fsSpace :1;// 1 == Char Spacing (qpsSpace) different to style
+
+ USHORT ftcGet() { return SVBT16ToShort(ftc); }
+ void ftcSet(USHORT n) { ShortToSVBT16(n, ftc); }
+ void hpsSet(BYTE n) { ByteToSVBT8(n, hps); }
+ BYTE hpsGet() { return SVBT8ToByte(hps); }
+
+ BYTE hpsPosGet() { return SVBT8ToByte(hpsPos); }
+ USHORT fTextGet() { return SVBT16ToShort(fText); }
+ void fTextSet(USHORT n) { ShortToSVBT16(n, fText); }
+ USHORT qpsSpaceGet() { return (USHORT)((fTextGet() >> 0) & 0x3f); }
+ USHORT wSpare2Get() { return (USHORT)((fTextGet() >> 6) & 3); }
+ USHORT icoGet() { return (USHORT)((fTextGet() >> 8) & 0xf); }
+ USHORT kulGet() { return (USHORT)((fTextGet() >> 12) & 7); }
+ void kulSet(USHORT n) { fTextSet( ( fTextGet() & 0x8fff ) | ( ( n & 7 ) << 12 ) ); }
+ BOOL fSysVanishGet() { return ((fTextGet() >> 15) & 1); }
+ // SVBT16 qpsSpace :6;// Char Spacing, -7 .. 56; 57 = -7, 63 = -1
+ // SVBT16 wSpare2 : 2;// reserved
+ // SVBT16 ico :4;// color of Text: 0=black, 1=blue, 2=cyan, 3=green, 4=magenta, 5=red, 6=yellow, 7=white
+ // SVBT16 kul: 3;// Underline code: 0=none, 1=single, 2=by word, 3=double, 4=dotted
+ // SVBT16 fSysVanish: 1;// used internally
+
+ ULONG fcPicGet() { return SVBT32ToLong(fcPic); }
+ USHORT fnPicGet() { return SVBT8ToByte(fnPic); }
+ USHORT hpsLargeChpGet() { return SVBT16ToShort(hpsLargeChp); }
+
+ void Out(Ww1Shell&, Ww1Manager&);
+};
+
+struct W1_FFN ///////////////////////////////////////// Font Descriptor
+{
+ SVBT8 cbFfnM1;// 0x0 total length of FFN - 1.
+ USHORT cbFfnM1Get() {
+ return SVBT8ToByte(cbFfnM1); }
+ SVBT8 fFlags;
+ USHORT fFlagsGet() {
+ return SVBT8ToByte(fFlags); }
+ // SVBT8 prg : 2;// 0x1:03 pitch request
+ USHORT prgGet() {
+ return (USHORT)((fFlagsGet() >> 0) & 3); }
+ // SVBT8 fTrueType : 1;// 0x1:04 when 1, font is a TrueType font
+ BOOL fTrueTypeGet() {
+ return ((fFlagsGet() >> 2) & 1); }
+ // SVBT8 : 1;// 0x1:08 reserved
+ // SVBT8 ff : 3;// 0x1:70 font family id
+ USHORT ffGet() {
+ return (USHORT)((fFlagsGet() >> 4) & 7); }
+ // SVBT8 : 1;// 0x1:80 reserved
+ BYTE szFfn[65];// 0x6 zero terminated string that records name of font.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the name of an
+ // alternate font to use if the first named font does not exist
+ // on this system. Maximal size of szFfn is 65 characters.
+ BYTE* szFfnGet() { return szFfn; }
+};
+
+struct W1_PHE /////////////////////////////////////// Paragraph Height
+{
+ SVBT16 fFlags;
+ USHORT fFlagsGet() {
+ return SVBT16ToShort(fFlags); }
+ BOOL fSpareGet() {
+ return fFlagsGet() & 1; }
+ BOOL fUnkGet() {
+ return (fFlagsGet() >> 1) & 1; }
+ BOOL fDiffLinesGet() {
+ return (fFlagsGet() >> 2) & 1; }
+ BYTE clMacGet() {
+ return (fFlagsGet() >> 8) & 0xff; }
+ SVBT16 dxaCol;
+ USHORT dxaColGet() {
+ return SVBT16ToShort(dxaCol); }
+ SVBT16 xxx; // beachte die dreifachnutzung.... siehe doc.
+ USHORT dylHeightGet() {
+ return SVBT16ToShort(xxx); }
+ USHORT dylLineGet() {
+ return SVBT16ToShort(xxx); }
+ USHORT fStyleDirtyGet() {
+ return SVBT16ToShort(xxx); }
+};
+
+struct W1_PAPX ///////////////////////// Paragraph Property Difference
+{
+ SVBT8 stc;
+ BYTE stcGet() {
+ return SVBT8ToByte(stc); }
+ W1_PHE phe;
+ BYTE grpprl[1];
+ BYTE* grpprlGet() {
+ return grpprl; }
+};
+
+struct W1_BRC //////////////////////////////////////////// Border Code
+{
+ SVBT16 aBits;
+ USHORT aBitsGet() {
+ return SVBT16ToShort(aBits); }
+ // SVBT16 dxpLineWidth : 3;// 0007 When dxpLineWidth is 0, 1, 2, 3, 4, or 5,
+ // this field is the width of a single line of border
+ // in units of 0.75 points Must be nonzero when brcType
+ // is nonzero. 6 == dotted, 7 == dashed.
+ BYTE dxpLineWidthGet() {
+ return (aBitsGet() >> 0) & 0x0007; }
+ // SVBT16 brcType : 2;// 0018 border type code: 0 == none, 1 == single, 2 == thick,
+ // 3 == double
+ BYTE brcTypeGet() {
+ return (aBitsGet() >> 3) & 0x0003; }
+ // SVBT16 fShadow : 1;// 0020 when 1, border is drawn with shadow. Must be 0
+ // when BRC is a substructure of the TC
+ BYTE fShadowGet() {
+ return (aBitsGet() >> 5) & 0x0001; }
+ // SVBT16 ico : 5;// 07C0 color code (see chp.ico)
+ BYTE icoGet() {
+ return (aBitsGet() >> 6) & 0x001f; }
+ // SVBT16 dxpSpace : 5;// F800 width of space to maintain between border and
+ // text within border. Must be 0 when BRC is a
+ // substructure of the TC. Stored in points for Windows.
+ BYTE dxpSpaceGet() {
+ return (aBitsGet() >> 11) & 0x001f; }
+};
+
+struct W1_BRC10 ///////////////////////////////// Border Code Word 1.0
+{
+ SVBT16 aBits;
+ USHORT aBitsGet() {
+ return SVBT16ToShort(aBits); }
+ BYTE dxpLine2WidthGet() {
+ return (aBitsGet() >> 0) & 0x0007; }
+ BYTE dxpSpaceBetweenGet() {
+ return (aBitsGet() >> 3) & 0x0007; }
+ BYTE dxpLine1WidthGet() {
+ return (aBitsGet() >> 6) & 0x0007; }
+ BYTE dxpSpaceGet() {
+ return (aBitsGet() >> 9) & 0x001f; }
+ BYTE fShadowGet() {
+ return (aBitsGet() >> 14) & 0x0001; }
+ BYTE fSpareGet() {
+ return (aBitsGet() >> 15) & 0x0001; }
+};
+
+struct W1_FLD //////////////////////////////////////// FieldDescriptor
+{
+ SVBT8 ch; // boundary-type (begin(19), separator (20), end (21))
+ BYTE chGet() {
+ return SVBT8ToByte(ch); }
+ SVBT8 flt; // field type / flags
+ BYTE fltGet() {
+ return SVBT8ToByte(flt); }
+ // variant, when ch==21:
+ BOOL fDifferGet() {
+ return (fltGet() >> 0) & 1; }
+ BOOL fResultDirtyGet() {
+ return (fltGet() >> 2) & 1; }
+ BOOL ResultEditedGet() {
+ return (fltGet() >> 3) & 1; }
+ BOOL fLockedGet() {
+ return (fltGet() >> 4) & 1; }
+ BOOL fPrivateResultGet() {
+ return (fltGet() >> 5) & 1; }
+ BOOL fNestedGet() {
+ return (fltGet() >> 6) & 1; }
+};
+
+struct W1_PIC /////////////////////////////////////// PictureStructure
+{
+ SVBT32 lcb;// 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file.
+ ULONG lcbGet() {
+ return SVBT32ToLong(lcb); }
+ SVBT16 cbHeader;// 0x4 number of bytes in the PIC (to allow for future expansion).
+ USHORT cbHeaderGet() {
+ return SVBT16ToShort(cbHeader); }
+ struct MFP {
+ SVBT16 mm;// 0x6 int
+ USHORT mmGet() {
+ return SVBT16ToShort(mm); }
+ SVBT16 xExt;// 0x8 int
+ USHORT xExtGet() {
+ return SVBT16ToShort(xExt); }
+ SVBT16 yExt;// 0xa int
+ USHORT yExtGet() {
+ return SVBT16ToShort(yExt); }
+ SVBT16 hMF;// 0xc int
+ USHORT hMFGet() {
+ return SVBT16ToShort(hMF); }
+ } mfp;
+ union W1_MFP_BMP {
+ SVBT8 bm[14];// 0xe BITMAP(14 bytes) Window's bitmap structure when PIC describes a BITMAP.
+ SVBT8 rcWinMF[14];// 0xe rc (rectangle - 8 bytes) rect for window origin and extents when metafile is stored -- ignored if 0
+ } MFP_BMP;
+ SVBT16 dxaGoal;// 0x1c horizontal measurement in twips of the rectangle the picture should be imaged within.
+ USHORT dxaGoalGet() {
+ return SVBT16ToShort(dxaGoal); }
+ SVBT16 dyaGoal;// 0x1e vertical measurement in twips of the rectangle the picture should be imaged within.
+ USHORT dyaGoalGet() {
+ return SVBT16ToShort(dyaGoal); }
+ SVBT16 mx;// 0x20 horizontal scaling factor supplied by user in .1% units.
+ USHORT mxGet() {
+ return SVBT16ToShort(mx); }
+ SVBT16 my;// 0x22 vertical scaling factor supplied by user in .1% units.
+ USHORT myGet() {
+ return SVBT16ToShort(my); }
+ SVBT16 dxaCropLeft;// 0x24 the amount the picture has been cropped on the left in twips.
+ USHORT dxaCropLeftGet() {
+ return SVBT16ToShort(dxaCropLeft); }
+ SVBT16 dyaCropTop;// 0x26 the amount the picture has been cropped on the top in twips.
+ USHORT dyaCropTopGet() {
+ return SVBT16ToShort(dyaCropTop); }
+ SVBT16 dxaCropRight;// 0x28 the amount the picture has been cropped on the right in twips.
+ USHORT dxaCropRightGet() {
+ return SVBT16ToShort(dxaCropRight); }
+ SVBT16 dyaCropBottom;// 0x2a the amount the picture has been cropped on the bottom in twips.
+ USHORT dyaCropBottomGet() {
+ return SVBT16ToShort(dyaCropBottom); }
+ SVBT16 flags;
+ USHORT flagsGet() {
+ return SVBT16ToShort(flags); }
+// brcl : 4;// 000F Obsolete, superseded by brcTop, etc. In
+ BYTE brclGet() {
+ return flagsGet() & 0xf; }
+// fFrameEmpty : 1;// 0010 picture consists of a single frame
+ BOOL fFrameEmptyGet() {
+ return (flagsGet() >> 4) & 1; }
+// win6 stuff:
+// fBitmap : 1;// 0020 ==1, when picture is just a bitmap
+// BOOL fBitmapGet() {
+// return (flagsGet() >> 5) & 1; }
+// fDrawHatch : 1;// 0040 ==1, when picture is an active OLE object
+// BOOL fDrawHatchGet() {
+// return (flagsGet() >> 6) & 1; }
+// fError : 1;// 0080 ==1, when picture is just an error message
+// BOOL fErrorGet() {
+// return (flagsGet() >> 7) & 1; }
+// bpp : 8;// FF00 bits per pixel, 0 = unknown
+// BYTE bppGet() {
+// return (flagsGet() >> 8) & 0xff; }
+// SVBT16 rgbrc[4];
+// USHORT rgbrcGet(USHORT nIndex) {
+// return SVBT16ToShort(rgbrc[nIndex]); }
+// W1_BRC brcTop;// 0x2e specification for border above picture
+// W1_BRC brcLeft;// 0x30 specification for border to the left
+// W1_BRC brcBottom;// 0x32 specification for border below picture
+// W1_BRC brcRight;// 0x34 specification for border to the right
+// SVBT16 dxaOrigin;// 0x36 horizontal offset of hand annotation origin
+// USHORT dxaOriginGet() {
+// return SVBT16ToShort(dxaOrigin); }
+// SVBT16 dyaOrigin;// 0x38 vertical offset of hand annotation origin
+// USHORT dyaOriginGet() {
+// return SVBT16ToShort(dyaOrigin); }
+ SVBT8 rgb;// 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename.
+ BYTE* rgbGet() {
+ return rgb; }
+};
+
+struct W1_TBD /////////////////////////////////////////////////////////
+{
+ SVBT8 aBits1;
+ BYTE aBits1Get() {
+ return SVBT8ToByte(aBits1); }
+// SVBT8 jc : 3;// 0x07 justification code: 0=left tab, 1=centered tab, 2=right tab, 3=decimal tab, 4=bar
+ BYTE jcGet() {
+ return aBits1Get() & 0x07; }
+// SVBT8 tlc : 3;// 0x38 tab leader code: 0=no leader, 1=dotted leader,
+ // 2=hyphenated leader, 3=single line leader, 4=heavy line leader
+ BYTE tlcGet() {
+ return (aBits1Get() >> 3 ) & 0x07; }
+// * int :2 C0 reserved
+};
+
+struct W1_TC //////////////////////////////////////////////////////////
+{
+ SVBT8 aBits1;
+ BYTE aBits1Get() {
+ return SVBT8ToByte(aBits1); }
+ BYTE fFirstMergedGet() {
+ return aBits1Get() & 0x01; }
+ BYTE fMergedGet() {
+ return (aBits1Get() >> 1 ) & 0x01; }
+ SVBT8 aBits2;
+// SVBT16 fFirstMerged : 1;// 0001 set to 1 when cell is first cell of a range of cells that have been merged.
+// SVBT16 fMerged : 1;// 0002 set to 1 when cell has been merged with preceding cell.
+// SVBT16 fUnused : 14;// FFFC reserved
+ W1_BRC10 rgbrc[4];// notational convenience for referring to brcTop, brcLeft, etc fields.
+ W1_BRC10* rgbrcGet() {
+ return rgbrc; }
+// BRC brcTop;// specification of the top border of a table cell
+// BRC brcLeft;// specification of left border of table row
+// BRC brcBottom;// specification of bottom border of table row
+// BRC brcRight;// specification of right border of table row.
+};
+// cbTC (count of bytes of a TC) is 10(decimal), A(hex).
+
+#if 0
+struct W1_SHD ////////////////////////////////////////////// struct SHD
+{
+ SVBT16 aBits1;
+ // SVBT16 nFore : 5;// 0x001f ForegroundColor
+ USHORT GetFore() { return SVBT16ToShort(aBits1) & 0x01; };
+ void SetFore( short nVal ){
+ ShortToSVBT16((SVBT16ToShort(aBits1)&0xffe0)|(nVal&0x1f), aBits1); };
+ // SVBT16 nBack : 5;// 0x03e0 BackgroundColor
+ W1_SHD() { ShortToSVBT16( 0, aBits1 ); };
+ USHORT GetBack() { return (SVBT16ToShort(aBits1) >> 5 & 0x1f ); };
+ void SetBack( short nVal ){
+ ShortToSVBT16((SVBT16ToShort(aBits1)&0xfc1f)|(nVal&0x1f)<<5, aBits1); };
+ // SVBT16 nStyle : 5;// 0x7c00 Percentage and Style
+ USHORT GetStyle() { return (SVBT16ToShort(aBits1) >> 10 & 0x1f ); };
+ void SetStyle( short nVal ){
+ ShortToSVBT16((SVBT16ToShort(aBits1)&0x83ff)|(nVal&0x1f)<<10, aBits1); };
+ // SVBT16 nDontKnow : 1;// 0x8000 ???
+};
+
+struct W1_ANLV ////////////////////////////////////////////////////////
+{
+ SVBT8 nfc;// 0 number format code, 0=Arabic, 1=Upper case Roman, 2=Lower case Roman
+ // 3=Upper case Letter, 4=Lower case letter, 5=Ordinal
+ SVBT8 cbTextBefore;// 1 offset into anld.rgch limit of prefix text
+ SVBT8 cbTextAfter;// 2
+ SVBT8 aBits1;
+// SVBT8 jc : 2;// 3 : 0x03 justification code, 0=left, 1=center, 2=right, 3=left and right justify
+// SVBT8 fPrev : 1;// 0x04 when ==1, include previous levels
+// SVBT8 fHang : 1;// 0x08 when ==1, number will be displayed using a hanging indent
+// SVBT8 fSetBold : 1;// 0x10 when ==1, boldness of number will be determined by anld.fBold.
+// SVBT8 fSetItalic : 1;// 0x20 when ==1, italicness of number will be determined by anld.fItalic
+// SVBT8 fSetSmallCaps : 1;// 0x40 when ==1, anld.fSmallCaps will determine whether number will be displayed in small caps or not.
+// SVBT8 fSetCaps : 1;// 0x80 when ==1, anld.fCaps will determine whether number will be displayed capitalized or not
+ SVBT8 aBits2;
+// SVBT8 fSetStrike : 1;// 4 : 0x01 when ==1, anld.fStrike will determine whether the number will be displayed using strikethrough or not.
+// SVBT8 fSetKul : 1;// 0x02 when ==1, anld.kul will determine the underlining state of the autonumber.
+// SVBT8 fPrevSpace : 1;// 0x04 when ==1, autonumber will be displayed with a single prefixing space character
+// SVBT8 fBold : 1;// 0x08 determines boldness of autonumber when anld.fSetBold == 1.
+// SVBT8 fItalic : 1;// 0x10 determines italicness of autonumber when anld.fSetItalic == 1.
+// SVBT8 fSmallCaps : 1;// 0x20 determines whether autonumber will be displayed using small caps when anld.fSetSmallCaps == 1.
+// SVBT8 fCaps : 1;// 0x40 determines whether autonumber will be displayed using caps when anld.fSetCaps == 1.
+// SVBT8 fStrike : 1;// 0x80 determines whether autonumber will be displayed using caps when anld.fSetStrike == 1.
+ SVBT8 aBits3;
+// SVBT8 kul : 3;// 5 : 0x07 determines whether autonumber will be displayed with underlining when anld.fSetKul == 1.
+// SVBT8 ico : 5;// 0xF1 color of autonumber
+ SVBT16 ftc;// 6 font code of autonumber
+ SVBT16 hps;// 8 font half point size (or 0=auto)
+ SVBT16 iStartAt;// 0x0a starting value (0 to 65535)
+ SVBT16 dxaIndent;// 0x0c *short?* *USHORT?* width of prefix text (same as indent)
+ SVBT16 dxaSpace;// 0x0e minimum space between number and paragraph
+};
+// *cbANLV (count of bytes of ANLV) is 16 (decimal), 10(hex).
+
+struct W1_ANLD ////////////////////////////////////////////////////////
+{
+ W1_ANLV eAnlv;// 0
+ SVBT8 fNumber1;// 0x10 number only 1 item per table cell
+ SVBT8 fNumberAcross;// 0x11 number across cells in table rows(instead of down)
+ SVBT8 fRestartHdn;// 0x12 restart heading number on section boundary
+ SVBT8 fSpareX;// 0x13 unused( should be 0)
+ sal_Char rgchAnld[32];// 0x14 characters displayed before/after autonumber
+};
+
+
+struct W1_OLST ////////////////////////////////////////////////////////
+{
+ W1_ANLV rganlv[9];// 0 an array of 9 ANLV structures (heading levels)
+ SVBT8 fRestartHdr;// 0x90 when ==1, restart heading on section break
+ SVBT8 fSpareOlst2;// 0x91 reserved
+ SVBT8 fSpareOlst3;// 0x92 reserved
+ SVBT8 fSpareOlst4;// 0x93 reserved
+ sal_Char rgch[64];// 0x94 array of 64 chars text before/after number
+};
+// cbOLST is 212(decimal), D4(hex).
+
+#endif
+#endif
+
diff --git a/sw/source/filter/ww8/dump/dump8.cxx b/sw/source/filter/ww8/dump/dump8.cxx
new file mode 100644
index 000000000000..e0e5970d0ede
--- /dev/null
+++ b/sw/source/filter/ww8/dump/dump8.cxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * $RCSfile: dump8.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+
+#ifndef _FACTORY_HXX //autogen
+#include <so3/factory.hxx>
+#endif
+
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+
+// globale Vars
+
+char** pPara;
+
+// Deklarationen
+
+int PrepareConvert( String& rName, String& rOutName, String& rMess );
+int DoConvert( const String& rName, BYTE nVersion );
+void DeInit();
+
+
+
+// -----------------------------------------------------------------------
+
+class MyApp : public Application
+{
+public:
+ void Main();
+};
+
+// -----------------------------------------------------------------------
+
+MyApp aMyApp;
+
+// -----------------------------------------------------------------------
+
+class MyWin : public WorkWindow
+{
+ String& rMessg;
+public:
+ MyWin( Window* pParent, WinBits aWinStyle, String& rMess ) :
+ WorkWindow(pParent, aWinStyle), rMessg( rMess ) {}
+
+ void Paint( const Rectangle& );
+ void Resize();
+
+ void MouseButtonDown( const MouseEvent& rMEvt );
+ void KeyInput( const KeyEvent& rKEvt );
+};
+
+// -----------------------------------------------------------------------
+
+extern SvStorageStreamRef xStrm;
+
+void MyApp::Main()
+{
+ SvFactory::Init();
+ String aMess, aName, aOutName;
+ BYTE nVersion = 8;
+
+ int nArgs = GetCommandLineParamCount();
+ if (nArgs)
+ {
+ aName = GetCommandLineParam( 0 );
+ if (aName.Search('.') == STRING_NOTFOUND)
+ aName += ".doc";
+ if (nArgs >= 2)
+ {
+ aOutName = GetCommandLineParam( 1 );
+ if (nArgs > 2)
+ {
+ nVersion = (BYTE)(USHORT)GetCommandLineParam( 2 );
+ if( 6 > nVersion || 8 < nVersion )
+ {
+ aMess = "Aufruf: Dump1 InFile [OutFile] [6|7|8]";
+ }
+ }
+ }
+ else
+ {
+ aOutName = aName;
+ aOutName.Erase(aOutName.Search('.'));
+ aOutName += ".dmp";
+ }
+ }
+
+ BOOL bOk = !aMess
+ && !PrepareConvert( aName, aOutName, aMess )
+ && !DoConvert( aName, nVersion );
+
+ if( !bOk )
+ {
+ MyWin aMainWin( NULL, WB_APP | WB_STDWORK, aMess );
+
+ aMainWin.SetText( "WW8-Dumper" );
+ aMainWin.Show();
+ aMainWin.Invalidate();
+
+ Execute();
+ }
+ DeInit();
+// SvFactory::DeInit();
+}
+
+// -----------------------------------------------------------------------
+
+void MyWin::Paint( const Rectangle& )
+{
+ String aText( "Dumper fuer WinWord-Dateien !\n"
+ "Die Wandlung ging schief. Ist es wirklich ein WW-File ?" );
+
+ Size aWinSize = GetOutputSizePixel();
+ Size aTextSize = GetTextSize( aText );
+ Point aPos( aWinSize.Width() / 2 - aTextSize.Width() / 2,
+ aWinSize.Height() / 2 - aTextSize.Height() / 2 );
+
+ DrawText( aPos, aText );
+
+ aPos.Y() += 20;
+ DrawText( aPos, rMessg );
+}
+
+// -----------------------------------------------------------------------
+
+void MyWin::Resize()
+{
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void MyWin::MouseButtonDown( const MouseEvent& )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void MyWin::KeyInput( const KeyEvent& rKEvt )
+{
+ WorkWindow::KeyInput( rKEvt );
+}
+
+
+
+//class XVclComponentPeer;
+XWindowPeer* Window::GetComponentInterface( BOOL )
+{
+return 0;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/dump/dump8.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.8 2000/09/18 16:05:02 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.7 2000/02/14 14:40:00 jp
+ #70473# changes for unicode
+
+ Revision 1.6 2000/01/25 10:44:55 khz
+ change: update the dumper according to import improvements
+
+ Revision 1.5 1999/08/16 10:22:38 JP
+ neu: Dump EscherObjects
+
+
+ Rev 1.4 16 Aug 1999 12:22:38 JP
+ neu: Dump EscherObjects
+
+ Rev 1.3 15 Jun 1999 14:19:16 JP
+ new: ListTable and other Contents
+
+ Rev 1.2 25 Jun 1998 15:43:46 KHZ
+ Strukturaenderung fuer PAPX FKPs
+
+ Rev 1.1 10 Jun 1998 17:22:32 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:29:52 KHZ
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/dump/dump8a.cxx b/sw/source/filter/ww8/dump/dump8a.cxx
new file mode 100644
index 000000000000..9ce9c047b240
--- /dev/null
+++ b/sw/source/filter/ww8/dump/dump8a.cxx
@@ -0,0 +1,3127 @@
+/*************************************************************************
+ *
+ * $RCSfile: dump8a.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+//#include <stdio.h> // SEEK_SET
+#include <string.h> // memset(), ...
+#include <io.h> // access()
+
+
+//#include "defs.hxx"
+#include <tools/solar.h>
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+#include "ww8struc.hxx"
+#include "ww8scan.hxx"
+#include "ww8darr.hxx"
+#include "ww8dout.hxx"
+
+#if 0
+#define DELETEZ( p ) ( delete( p ), p = 0 )
+//#define LONG_MAX ( (long)0x7fffffff )
+#endif
+#define ASSERT( a, b ) ( (a)?(void)0:(void)(*pOut<<endl1<<"ASSERTION failed "<< __FILE__<<__LINE__<< b <<endl1) )
+
+
+#define nWW8MaxListLevel 9
+
+WW8ScannerBase* pSBase = 0;
+//WW8PLCFMan* pPLCFMan = 0;
+
+WW8Fib* pWwFib = 0;
+SvStorageRef* pxStor;
+SvStorageStreamRef xStrm;
+SvStorageStreamRef xTableStream; // ist bei Ver6-7 mit xStrm identisch,
+ // ansonsten entweder 0TABLE oder 1TABLE
+SvStorageStreamRef xDataStream; // ist bei Ver6-7 mit xStrm identisch,
+ // ansonsten DATA
+
+typedef void (*FNDumpData)( void* );
+
+BOOL DumpChar( BYTE c );
+void DumpShortPlainText( WW8_CP nStartCp, long nTextLen, char* pName );
+void DumpPlainText( WW8_CP nStartCp, long nTextLen, char* pName );
+void DumpSprms( BYTE nVersion, SvStream& rSt, short nLen );
+
+
+BOOL WW8ReadINT32( SvStream& rStrm, INT32& rTarget )
+{
+ rStrm >> rTarget;
+ return TRUE;
+
+
+ SVBT32 nData;
+ BOOL bOk = TRUE;
+ if( 4 == rStrm.Read( &nData, 4 ) )
+ rTarget = SVBT32ToLong( nData );
+ else
+ bOk = FALSE;
+ return bOk;
+}
+
+BOOL WW8ReadINT16( SvStream& rStrm, INT16& rTarget )
+{
+ rStrm >> rTarget;
+ return TRUE;
+
+
+ SVBT16 nData;
+ BOOL bOk = TRUE;
+ if( 2 == rStrm.Read( &nData, 2 ) )
+ {
+ rTarget = SVBT16ToShort( nData );
+ }
+ else
+ bOk = FALSE;
+ return bOk;
+}
+
+BOOL WW8ReadBYTE( SvStream& rStrm, BYTE& rTarget )
+{
+ rStrm >> rTarget;
+ return TRUE;
+
+
+ SVBT8 nData;
+ BOOL bOk = TRUE;
+ if( 1 == rStrm.Read( &nData, 1 ) )
+ rTarget = SVBT8ToByte( nData );
+ else
+ bOk = FALSE;
+ return bOk;
+}
+
+BOOL WW8ReadUINT32( SvStream& rStrm, UINT32& rTarget )
+ { return WW8ReadINT32( rStrm, (INT32&) rTarget ); }
+
+BOOL WW8ReadUINT16( SvStream& rStrm, UINT16& rTarget )
+ { return WW8ReadINT16( rStrm, (INT16&) rTarget ); }
+
+
+static void Dump_LVL( UINT16 nLevel )
+{
+ indent( *pOut, *xTableStream );
+
+ long nStart, dxaSpace, dxaIndent;
+ BYTE nfc, nFlags, ixchFollow, cbChpx, cbPapx;
+ BYTE aOfsNumsXCH[nWW8MaxListLevel];
+ *xTableStream >> nStart >> nfc >> nFlags;
+ xTableStream->Read( aOfsNumsXCH, 9 );
+ *xTableStream >> ixchFollow >> dxaSpace >> dxaIndent
+ >> cbChpx >> cbPapx;
+ xTableStream->SeekRel( 2 );
+
+ *pOut << " Level: " << nLevel << endl1;
+ *pOut << indent2 << " Start: " << nStart
+ << " Fmt: " << (USHORT)nfc
+ << " Follow: ";
+ if( 0 == ixchFollow ) *pOut << "tab";
+ else if( 1 == ixchFollow ) *pOut << "blank";
+ else if( 2 == ixchFollow ) *pOut << "nothing";
+ *pOut << endl1 << indent2<< " dxSpace: " << dxaSpace
+ << " dxaIndent: " << dxaIndent << " LevelCharPos: ";
+
+ for( BYTE x = 0; x < nWW8MaxListLevel; ++x )
+ *pOut << (USHORT)aOfsNumsXCH[ x ] << ", ";
+ *pOut << endl1;
+
+ if( cbPapx )
+ {
+ ULONG nXPos = xTableStream->Tell();
+ DumpSprms( pWwFib->nVersion, *xTableStream, cbPapx );
+ xTableStream->Seek( nXPos + cbPapx );
+ }
+ if( cbChpx )
+ {
+ ULONG nXPos = xTableStream->Tell();
+ DumpSprms( pWwFib->nVersion, *xTableStream, cbChpx );
+ xTableStream->Seek( nXPos + cbChpx );
+ }
+
+ USHORT nStrLen, nC;
+ *xTableStream >> nStrLen;
+ char* pStr = new char[ nStrLen+1 ], *p = pStr;
+ while( nStrLen-- )
+ {
+ *xTableStream >> nC;
+ if( 10 > nC ) nC += 0x30;
+ *pStr++ = (char)nC;
+ }
+ *pStr = 0;
+ *pOut << indent2 << "Str: \"" << p << '\"' << endl1 << endl1;
+}
+
+static void DumpNumList()
+{
+ if( pWwFib->lcbSttbListNames )
+ {
+ ULONG nOldPos = xTableStream->Tell();
+ xTableStream->Seek( pWwFib->fcSttbListNames );
+
+ *pOut << endl1;
+ begin( *pOut, *xTableStream ) << "ListNames, Size ";
+
+ UINT16 nDummy;
+ UINT32 nCount;
+ *xTableStream >> nDummy >> nCount;
+
+ *pOut << nCount << ", Dummy: " << nDummy << endl1;
+
+ *pOut << indent2;
+ for( ; nCount; --nCount )
+ {
+ UINT16 nLen, nC;
+ *xTableStream >> nLen;
+ char * pChar = new char[ nLen + 1 ], *p = pChar;
+ while( nLen-- )
+ {
+ *xTableStream >> nC;
+ *pChar++ = (char)nC;
+ }
+ *pChar = 0;
+ *pOut << '\"' << p << '\"';
+ if( 1 < nCount ) *pOut << ", ";
+ delete p;
+ }
+ *pOut << endl1;
+
+ end( *pOut, *xTableStream ) << "ListNames" << endl1;
+ xTableStream->Seek( nOldPos );
+ }
+
+ if( pWwFib->lcbPlcfLst )
+ {
+ ULONG nOldPos = xTableStream->Tell();
+ xTableStream->Seek( pWwFib->fcPlcfLst );
+
+ *pOut << endl1;
+ begin( *pOut, *xTableStream ) << "LiST Data on File, Size ";
+
+ UINT16 nCount;
+ *xTableStream >> nCount;
+ *pOut << nCount << endl1;
+
+ ULONG nLVLPos = pWwFib->fcPlcfLst + ( nCount * 0x1c ) + 2;
+
+ // 1.1 alle LST einlesen
+ for( UINT16 nList = 0; nList < nCount; nList++ )
+ {
+ indent( *pOut, *xTableStream );
+
+ BYTE nByte;
+ UINT32 nLstId, nTplId;
+ *xTableStream >> nLstId >> nTplId;
+
+ USHORT aStyleIdArr[ nWW8MaxListLevel ];
+ for( USHORT nLevel = 0; nLevel < nWW8MaxListLevel; nLevel++ )
+ *xTableStream >> aStyleIdArr[ nLevel ];
+ *xTableStream >> nByte;
+ xTableStream->SeekRel( 1 ); // Dummy ueberlesen
+
+ *pOut << "ListId: " << nLstId
+ << " TemplateId " << nTplId << endl1
+ << indent2 << " StyleIds: ";
+ for( nLevel = 0; nLevel < nWW8MaxListLevel; nLevel++ )
+ *pOut << aStyleIdArr[ nLevel ] << ", ";
+
+ *pOut << endl1;
+ if( 1 & nByte ) *pOut << " <simple List>";
+ if( 2 & nByte ) *pOut << " <restart at new section>";
+ if( 3 & nByte ) *pOut << endl1;
+
+ ULONG nTmpPos = xTableStream->Tell();
+ xTableStream->Seek( nLVLPos );
+
+ // 1.2 alle LVL aller aLST einlesen
+ for( nLevel = 0; nLevel < ((1 & nByte) ? 1 : nWW8MaxListLevel); nLevel++ )
+ Dump_LVL( nLevel );
+
+ nLVLPos = xTableStream->Tell();
+ xTableStream->Seek( nTmpPos );
+ }
+
+ end( *pOut, *xTableStream ) << "LiST Data on File" << endl1;
+ xTableStream->Seek( nOldPos );
+ }
+
+ if( pWwFib->lcbPlfLfo )
+ {
+ ULONG nOldPos = xTableStream->Tell();
+ xTableStream->Seek( pWwFib->fcPlfLfo );
+
+ *pOut << endl1;
+ begin( *pOut, *xTableStream ) << "List Format Override, Size ";
+
+ UINT32 nCount, nLstId;
+ *xTableStream >> nCount;
+ *pOut << nCount << endl1;
+
+ ULONG nLVLPos = pWwFib->fcPlfLfo + ( nCount * 0x10 ) + 4;
+
+ for( ; nCount; --nCount )
+ {
+ indent( *pOut, *xTableStream );
+
+ BYTE nLevels;
+ *xTableStream >> nLstId;
+ xTableStream->SeekRel( 8 );
+ *xTableStream >> nLevels;
+ xTableStream->SeekRel( 3 );
+
+ *pOut << "ListId: " << nLstId
+ << " Override Levels: " << (USHORT)nLevels << endl1;
+
+ ULONG nTmpPos = xTableStream->Tell();
+ xTableStream->Seek( nLVLPos );
+
+ for( BYTE nLvl = 0; nLvl < nLevels; ++nLvl )
+ {
+ UINT32 nStartAt;
+ BYTE nFlags;
+ do {
+ *xTableStream >> nFlags;
+ } while( 0xFF == nFlags );
+ xTableStream->SeekRel( -1 );
+
+ indent( *pOut, *xTableStream );
+ *xTableStream >> nStartAt >> nFlags;
+ xTableStream->SeekRel( 3 );
+
+ if( nFlags & 0x10 ) *pOut << "<Override start>";
+ if( nFlags & 0x20 ) *pOut << "<Override formattting>";
+ if( nFlags & 0x30 ) *pOut << endl1;
+
+ if( nFlags & 0x20 )
+ Dump_LVL( nFlags & 0x0F );
+ }
+ nLVLPos = xTableStream->Tell();
+ xTableStream->Seek( nTmpPos );
+ }
+
+ end( *pOut, *xTableStream ) << "List Format Override" << endl1 << endl1;
+ xTableStream->Seek( nOldPos );
+ }
+}
+
+static void DumpBookLow()
+{
+ *pOut << begin2 << "Bookmarks Low" << endl1;
+ *pOut << indent2 <<"Start: Adr " << hex6 << pWwFib->fcPlcfbkf
+ << ", Len: " << pWwFib->lcbPlcfbkf << endl1;
+ *pOut << indent2 << "End: Adr " << hex6 << pWwFib->fcPlcfbkl
+ << ", Len: " << pWwFib->lcbPlcfbkl << endl1;
+ *pOut << indent2 << "Strings: Adr " << hex6 << pWwFib->fcSttbfbkmk
+ << ", Len: " << pWwFib->lcbSttbfbkmk << endl1;
+ *pOut << endl1;
+
+ WW8PLCFspecial aStarts( &xStrm, pWwFib->fcPlcfbkf, pWwFib->lcbPlcfbkf, 4 );
+ WW8PLCFspecial aEnds( &xStrm, pWwFib->fcPlcfbkl, pWwFib->lcbPlcfbkl, 0, -1, TRUE );
+
+ USHORT i = 0;
+ while( 1 ){
+ long nStart = aStarts.GetPos( i );
+ if( nStart >= LONG_MAX )
+ break;
+
+ *pOut << indent2 << i << ".StartCp: " << hex6 << nStart;
+
+ const void* p = aStarts.GetData( i );
+ if( p ){
+ *pOut << ", EndIdx: ";
+ USHORT nEndIdx = *((USHORT*)p);
+ *pOut << nEndIdx;
+ long nEnd = aEnds.GetPos( nEndIdx );
+ *pOut << ", End: " << hex6 << nEnd << hex
+ << ", Len: " << nEnd - nStart << dec;
+ }else{
+ *pOut << " aStarts.GetData() ging schief.";
+ }
+
+#if 0 // gibt's im wirklichen Leben nicht
+ if( aEnds.Get( n, p ) ){
+ *pOut << " aEnds.iBkf: ";
+ if( p )
+ *pOut << *((USHORT*)p);
+ else
+ *pOut << "NULL-Ptr";
+ }else{
+ *pOut << " aEnds.Get() ging schief.";
+ }
+#endif
+
+ *pOut << endl1;
+ i++;
+ }
+ *pOut << end2 << "Bookmarks Low" << endl1 << endl1;
+}
+
+static void DumpBookHigh()
+{
+ WW8PLCFx_Book aBook( &xStrm, &xTableStream, *pWwFib, 0 );
+ if( !aBook.GetIMax() ){
+ *pOut << indent1 << "No Bookmarks" << endl1 << endl1;
+ return;
+ }
+
+ *pOut << indent1 << begin1 << "Bookmarks High" << endl1;
+
+ USHORT i = 0;
+ while( 1 ){
+ long nPos = aBook.Where();
+ if( nPos >= LONG_MAX )
+ break;
+ *pOut << indent2 << i << ". Cp:" << hex6 << nPos << dec;
+ *pOut << ( ( aBook.GetIsEnd() ) ? " Ende " : " Anfang" );
+ *pOut << " Handle: " << aBook.GetHandle();
+// *pOut << " Len: " << hex4 << aBook.GetLen() << dec;
+ const char* pN = aBook.GetName();
+ if( pN )
+ *pOut << " Name: " << pN << endl1;
+ else
+ *pOut << endl1;
+ aBook++;
+ i++;
+ }
+ *pOut << end2 << "Bookmarks High" << endl1 << endl1;
+}
+
+static BOOL DumpField3( WW8PLCFspecial& rPlc )
+{
+ WW8FieldDesc aF;
+
+ BOOL bOk = WW8GetFieldPara( pWwFib->nVersion, rPlc, aF );
+ if( !bOk )
+ {
+ *pOut << " " << indent1 << "no WW8GetFieldPara()" << endl1;
+ return FALSE;
+ }
+ *pOut << " " << indent1 << begin1 << "Field Cp: " << hex
+ << aF.nSCode << ", Len: " << aF.nLCode << "; Cp: " << aF.nSRes
+ << ", Len: "<< aF.nLRes << ", Typ: " << dec << (USHORT)aF.nId
+ << ", Options: " << hex << (USHORT)aF.nOpt;
+ if( aF.bCodeNest )
+ *pOut << " Code Nested";
+ if( aF.bResNest )
+ *pOut << " Result Nested";
+ *pOut << endl1;
+ DumpShortPlainText( aF.nSCode, aF.nLCode, "Code" );
+ DumpShortPlainText( aF.nSRes, aF.nLRes, "Result" );
+ *pOut << " " << end1 << "Field" << endl1;
+ return TRUE;
+}
+
+static BOOL DumpField2( WW8PLCFspecial& rPlc )
+{
+ WW8_CP nSCode, nECode, nSRes, nERes;
+ void* pData;
+ if( !rPlc.Get( nSCode, pData ) ) // Ende des Plc1 ?
+ return FALSE;
+ rPlc++;
+
+ if( ((BYTE*)pData)[0] != 19 ){
+ *pOut << "Field Error, " << (USHORT)((BYTE*)pData)[0] << endl1;
+ return TRUE; // nicht abbrechen
+ }
+
+ *pOut << " " << indent1 << begin1 << "Field" << " Cp: " << hex
+ << nSCode << " Typ: " << dec << (USHORT)((BYTE*)pData)[1] << endl1;
+
+ if( !rPlc.Get( nECode, pData ) ) // Ende des Plc1 ?
+ return FALSE;
+
+ DumpShortPlainText( nSCode, nECode - nSCode, "Code" ); // Code, bei nested abgeschnitten
+ nSRes = nECode; // Default
+
+
+ while( ((BYTE*)pData)[0] == 19 ){ // immer noch neue (nested) Anfaenge ?
+ DumpField2( rPlc ); // nested Field im Beschreibungsteil
+ if( !rPlc.Get( nSRes, pData ) ) // Ende des Plc1 ?
+ return FALSE;
+ }
+
+ if( ((BYTE*)pData)[0] == 20 ){ // Field Separator ?
+ rPlc++;
+ *pOut << " " << indent1 << "Field Seperator" << " Cp: " << hex << nSRes
+ << ", Flags = 0x" << hex << (USHORT)((BYTE*)pData)[1] << dec << endl1;
+ if( !rPlc.Get( nERes, pData ) ) // Ende des Plc1 ?
+ return FALSE;
+
+ while( ((BYTE*)pData)[0] == 19 ){ // immer noch neue (nested) Anfaenge ?
+ DumpField2( rPlc ); // nested Field im Resultatteil
+ if( !rPlc.Get( nERes, pData ) ) // Ende des Plc1 ?
+ return FALSE;
+ }
+ DumpShortPlainText( nSRes, nERes - nSRes, "Result" ); // Result, bei nested incl. nested Field
+
+ }else{
+ nERes = nSRes; // Kein Result vorhanden
+ }
+
+ rPlc++;
+ if( ((BYTE*)pData)[0] == 21 ){ // Field Ende ?
+ *pOut << " " << end1 << " Field " << " Cp: " << hex << nERes
+ << ", Flags = 0x" << hex << (USHORT)((BYTE*)pData)[1] << dec << endl1;
+ }else{
+ *pOut << " Unknown Field Type" << endl1;
+ *pOut << " " << end1 << " Field " << endl1;
+ }
+
+ return TRUE;
+}
+
+static void DumpField1( WW8_FC nPos, long nLen, char* pName )
+{
+ if( !nLen )
+ {
+ *pOut << pName << ": No Fields" << endl1 << endl1;
+ return;
+ }
+
+ WW8PLCFspecial aPlc( &xTableStream, nPos, nLen, 2 );
+
+ *pOut << hex6 << nPos << dec2 << ' ' << indent1 << begin1;
+ *pOut << "Plc." << pName << ", Len: ";
+ *pOut << nLen << ", ca. " << aPlc.GetIMax()/3 << " Elements"
+
+ << " Idx: " << (long)aPlc.GetIdx()
+ << " IMax: " << aPlc.GetIMax()
+
+ << endl1;
+
+// while( DumpField2( aPlc ) ){}
+ while( (long)aPlc.GetIdx() < aPlc.GetIMax() )
+ {
+ DumpField3( aPlc );
+ aPlc++;
+ }
+
+ end( *pOut, *xStrm ) << "Plcx." << pName << endl1 << endl1;
+}
+
+
+//-----------------------------------------
+static void DumpFonts()
+{
+ WW8Fonts aFonts( *xTableStream, *pWwFib );
+
+ USHORT i;
+
+ *pOut << endl1;
+ *pOut << 'T' << hex6 << pWwFib->fcSttbfffn << dec2 << ' ' << indent1 << begin1 << "FFNs" << endl1;
+
+ for( i=0; i<aFonts.GetMax(); i++){
+ // const
+ WW8_FFN* p = (WW8_FFN*)aFonts.GetFont( i );
+
+ *pOut << "Id:" << i << " Name:\"" << String( p->sFontname ).GetStr() << '"'; // Name
+ if( p->ibszAlt ) // gibt es einen alternativen Font ?
+
+ *pOut << ", Alternativ:" << '"' << String( p->sFontname.Copy( p->ibszAlt ) ).GetStr() << '"';
+
+ *pOut << ", PitchRequest:" << (short)p->prg << ", TrueType:" << (short)p->fTrueType;
+ *pOut << ", FontFamily:" << (short)p->ff;
+ *pOut << ", BaseWeight:" << p->wWeight;
+ *pOut << ", CharacterSet:" << (short)p->chs;
+ *pOut << endl1;
+ }
+ *pOut << " " << end1 << "FFNs" << endl1 << endl1;
+}
+
+
+//-----------------------------------------
+// class DFib
+//-----------------------------------------
+
+class DFib: public WW8Fib
+{
+public:
+ DFib( SvStream& rStrm, BYTE nVersion ) : WW8Fib( rStrm, nVersion ) {}
+ void Dump();
+};
+
+//-----------------------------------------
+
+void DFib::Dump()
+{
+ *pOut << "Adressen: FIB " << hex << 0 << ", Text "
+ << fcMin << ", TextLen " << ccpText
+ << ", Styles " << fcStshf << endl1;
+
+ *pOut << "\twIdent: " << wIdent << endl1;
+ *pOut << "\tnFib: " << nFib << endl1;
+ *pOut << "\tnProduct: " << nProduct << endl1;
+ *pOut << "\tlid: " << lid << endl1;
+ *pOut << "\tpnNext: " << pnNext << endl1;
+
+ *pOut << "\tfDot: " << (fDot ? '1' : '0') << endl1;
+ *pOut << "\tfGlsy: " << (fGlsy ? '1' : '0') << endl1;
+ *pOut << "\tfComplex: " << (fComplex ? '1' : '0') << endl1;
+ *pOut << "\tfHasPic: " << (fHasPic ? '1' : '0') << endl1;
+ *pOut << "\tcQuickSaves: " << (USHORT)cQuickSaves << endl1;
+ *pOut << "\tfEncrypted: " << (fEncrypted ? '1' : '0') << endl1;
+ *pOut << "\tfWhichTblStm: " << (fWhichTblStm ? '1' : '0') << endl1;
+ *pOut << "\tfExtChar: " << (fExtChar ? '1' : '0') << endl1;
+
+ *pOut << "\tnFibBack: " << nFibBack << endl1;
+ *pOut << "\tlKey1: " << lKey1 << endl1;
+ *pOut << "\tlKey2: " << lKey2 << endl1;
+ *pOut << "\tenvr: " << envr << endl1;
+
+ *pOut << "\tfMac: " << (fMac ? '1' : '0') << endl1;
+ *pOut << "\tfEmptySpecial: " << (fEmptySpecial ? '1' : '0') << endl1;
+ *pOut << "\tfLoadOverridePage: " << (fLoadOverridePage ? '1' : '0') << endl1;
+ *pOut << "\tfFuturesavedUndo: " << (fFuturesavedUndo ? '1' : '0') << endl1;
+ *pOut << "\tfWord97Saved: " << (fWord97Saved ? '1' : '0') << endl1;
+
+ *pOut << "\tchse: " << chse << endl1;
+ *pOut << "\tchseTables: " << chseTables << endl1;
+ *pOut << "\tfcMin: " << fcMin << endl1;
+ *pOut << "\tfcMac: " << fcMac << endl1;
+ *pOut << "\tcsw: " << csw << endl1;
+ *pOut << "\twMagicCreated: " << wMagicCreated << endl1;
+ *pOut << "\twMagicRevised: " << wMagicRevised << endl1;
+ *pOut << "\twMagicCreatedPrivate: " << wMagicCreatedPrivate << endl1;
+ *pOut << "\twMagicRevisedPrivate: " << wMagicRevisedPrivate << endl1;
+ *pOut << "\tlidFE: " << lidFE << endl1;
+ *pOut << "\tclw: " << clw << endl1;
+ *pOut << "\tcbMac: " << cbMac << endl1;
+ *pOut << "\tccpText: " << ccpText << endl1;
+ *pOut << "\tccpFtn: " << ccpFtn << endl1;
+ *pOut << "\tccpHdr: " << ccpHdr << endl1;
+ *pOut << "\tccpMcr: " << ccpMcr << endl1;
+ *pOut << "\tccpAtn: " << ccpAtn << endl1;
+ *pOut << "\tccpEdn: " << ccpEdn << endl1;
+ *pOut << "\tccpTxbx: " << ccpTxbx << endl1;
+ *pOut << "\tccpHdrTxbx: " << ccpHdrTxbx << endl1;
+ *pOut << "\tpnFbpChpFirst: " << pnFbpChpFirst << endl1;
+ *pOut << "\tpnFbpPapFirst: " << pnFbpPapFirst << endl1;
+ *pOut << "\tpnFbpLvcFirst: " << pnFbpLvcFirst << endl1;
+ *pOut << "\tpnLvcFirst: " << pnLvcFirst << endl1;
+ *pOut << "\tcpnBteLvc: " << cpnBteLvc << endl1;
+ *pOut << "\tfcIslandFirst: " << fcIslandFirst << endl1;
+ *pOut << "\tfcIslandLim: " << fcIslandLim << endl1;
+ *pOut << "\tcfclcb: " << cfclcb << endl1;
+ *pOut << "\tfcStshfOrig: " << fcStshfOrig << endl1;
+ *pOut << "\tlcbStshfOrig: " << lcbStshfOrig << endl1;
+ *pOut << "\tfcStshf: " << fcStshf << endl1;
+ *pOut << "\tlcbStshf: " << lcbStshf << endl1;
+ *pOut << "\tfcPlcffndRef: " << fcPlcffndRef << endl1;
+ *pOut << "\tlcbPlcffndRef: " << lcbPlcffndRef << endl1;
+ *pOut << "\tfcPlcffndTxt: " << fcPlcffndTxt << endl1;
+ *pOut << "\tlcbPlcffndTxt: " << lcbPlcffndTxt << endl1;
+ *pOut << "\tfcPlcfandRef: " << fcPlcfandRef << endl1;
+ *pOut << "\tlcbPlcfandRef: " << lcbPlcfandRef << endl1;
+ *pOut << "\tfcPlcfandTxt: " << fcPlcfandTxt << endl1;
+ *pOut << "\tlcbPlcfandTxt: " << lcbPlcfandTxt << endl1;
+ *pOut << "\tfcPlcfsed: " << fcPlcfsed << endl1;
+ *pOut << "\tlcbPlcfsed: " << lcbPlcfsed << endl1;
+ *pOut << "\tfcPlcfpad: " << fcPlcfpad << endl1;
+ *pOut << "\tlcbPlcfpad: " << lcbPlcfpad << endl1;
+ *pOut << "\tfcPlcfphe: " << fcPlcfphe << endl1;
+ *pOut << "\tlcbPlcfphe: " << lcbPlcfphe << endl1;
+ *pOut << "\tfcSttbfglsy: " << fcSttbfglsy << endl1;
+ *pOut << "\tlcbSttbfglsy: " << lcbSttbfglsy << endl1;
+ *pOut << "\tfcPlcfglsy: " << fcPlcfglsy << endl1;
+ *pOut << "\tlcbPlcfglsy: " << lcbPlcfglsy << endl1;
+ *pOut << "\tfcPlcfhdd: " << fcPlcfhdd << endl1;
+ *pOut << "\tlcbPlcfhdd: " << lcbPlcfhdd << endl1;
+ *pOut << "\tfcPlcfbteChpx: " << fcPlcfbteChpx << endl1;
+ *pOut << "\tlcbPlcfbteChpx: " << lcbPlcfbteChpx << endl1;
+ *pOut << "\tfcPlcfbtePapx: " << fcPlcfbtePapx << endl1;
+ *pOut << "\tlcbPlcfbtePapx: " << lcbPlcfbtePapx << endl1;
+ *pOut << "\tfcPlcfsea: " << fcPlcfsea << endl1;
+ *pOut << "\tlcbPlcfsea: " << lcbPlcfsea << endl1;
+ *pOut << "\tfcSttbfffn: " << fcSttbfffn << endl1;
+ *pOut << "\tlcbSttbfffn: " << lcbSttbfffn << endl1;
+ *pOut << "\tfcPlcffldMom: " << fcPlcffldMom << endl1;
+ *pOut << "\tlcbPlcffldMom: " << lcbPlcffldMom << endl1;
+ *pOut << "\tfcPlcffldHdr: " << fcPlcffldHdr << endl1;
+ *pOut << "\tlcbPlcffldHdr: " << lcbPlcffldHdr << endl1;
+ *pOut << "\tfcPlcffldFtn: " << fcPlcffldFtn << endl1;
+ *pOut << "\tlcbPlcffldFtn: " << lcbPlcffldFtn << endl1;
+ *pOut << "\tfcPlcffldAtn: " << fcPlcffldAtn << endl1;
+ *pOut << "\tlcbPlcffldAtn: " << lcbPlcffldAtn << endl1;
+ *pOut << "\tfcPlcffldMcr: " << fcPlcffldMcr << endl1;
+ *pOut << "\tlcbPlcffldMcr: " << lcbPlcffldMcr << endl1;
+ *pOut << "\tfcSttbfbkmk: " << fcSttbfbkmk << endl1;
+ *pOut << "\tlcbSttbfbkmk: " << lcbSttbfbkmk << endl1;
+ *pOut << "\tfcPlcfbkf: " << fcPlcfbkf << endl1;
+ *pOut << "\tlcbPlcfbkf: " << lcbPlcfbkf << endl1;
+ *pOut << "\tfcPlcfbkl: " << fcPlcfbkl << endl1;
+ *pOut << "\tlcbPlcfbkl: " << lcbPlcfbkl << endl1;
+ *pOut << "\tfcCmds: " << fcCmds << endl1;
+ *pOut << "\tlcbCmds: " << lcbCmds << endl1;
+ *pOut << "\tfcPlcfmcr: " << fcPlcfmcr << endl1;
+ *pOut << "\tlcbPlcfmcr: " << lcbPlcfmcr << endl1;
+ *pOut << "\tfcSttbfmcr: " << fcSttbfmcr << endl1;
+ *pOut << "\tlcbSttbfmcr: " << lcbSttbfmcr << endl1;
+ *pOut << "\tfcPrDrvr: " << fcPrDrvr << endl1;
+ *pOut << "\tlcbPrDrvr: " << lcbPrDrvr << endl1;
+ *pOut << "\tfcPrEnvPort: " << fcPrEnvPort << endl1;
+ *pOut << "\tlcbPrEnvPort: " << lcbPrEnvPort << endl1;
+ *pOut << "\tfcPrEnvLand: " << fcPrEnvLand << endl1;
+ *pOut << "\tlcbPrEnvLand: " << lcbPrEnvLand << endl1;
+ *pOut << "\tfcWss: " << fcWss << endl1;
+ *pOut << "\tlcbWss: " << lcbWss << endl1;
+ *pOut << "\tfcDop: " << fcDop << endl1;
+ *pOut << "\tlcbDop: " << lcbDop << endl1;
+ *pOut << "\tfcSttbfAssoc: " << fcSttbfAssoc << endl1;
+ *pOut << "\tcbSttbfAssoc: " << cbSttbfAssoc << endl1;
+ *pOut << "\tfcClx: " << fcClx << endl1;
+ *pOut << "\tlcbClx: " << lcbClx << endl1;
+ *pOut << "\tfcPlcfpgdFtn: " << fcPlcfpgdFtn << endl1;
+ *pOut << "\tlcbPlcfpgdFtn: " << lcbPlcfpgdFtn << endl1;
+ *pOut << "\tfcAutosaveSource: " << fcAutosaveSource << endl1;
+ *pOut << "\tlcbAutosaveSource: " << lcbAutosaveSource << endl1;
+ *pOut << "\tfcGrpStAtnOwners: " << fcGrpStAtnOwners << endl1;
+ *pOut << "\tlcbGrpStAtnOwners: " << lcbGrpStAtnOwners << endl1;
+ *pOut << "\tfcSttbfAtnbkmk: " << fcSttbfAtnbkmk << endl1;
+ *pOut << "\tlcbSttbfAtnbkmk: " << lcbSttbfAtnbkmk << endl1;
+ *pOut << "\tfcPlcfdoaMom: " << fcPlcfdoaMom << endl1;
+ *pOut << "\tlcbPlcfdoaMom: " << lcbPlcfdoaMom << endl1;
+ *pOut << "\tfcPlcfdoaHdr: " << fcPlcfdoaHdr << endl1;
+ *pOut << "\tlcbPlcfdoaHdr: " << lcbPlcfdoaHdr << endl1;
+ *pOut << "\tfcPlcfspaMom: " << fcPlcfspaMom << endl1;
+ *pOut << "\tlcbPlcfspaMom: " << lcbPlcfspaMom << endl1;
+ *pOut << "\tfcPlcfspaHdr: " << fcPlcfspaHdr << endl1;
+ *pOut << "\tlcbPlcfspaHdr: " << lcbPlcfspaHdr << endl1;
+ *pOut << "\tfcPlcfAtnbkf: " << fcPlcfAtnbkf << endl1;
+ *pOut << "\tlcbPlcfAtnbkf: " << lcbPlcfAtnbkf << endl1;
+ *pOut << "\tfcPlcfAtnbkl: " << fcPlcfAtnbkl << endl1;
+ *pOut << "\tlcbPlcfAtnbkl: " << lcbPlcfAtnbkl << endl1;
+ *pOut << "\tfcPms: " << fcPms << endl1;
+ *pOut << "\tlcbPMS: " << lcbPMS << endl1;
+ *pOut << "\tfcFormFldSttbf: " << fcFormFldSttbf << endl1;
+ *pOut << "\tlcbFormFldSttbf: " << lcbFormFldSttbf << endl1;
+ *pOut << "\tfcPlcfendRef: " << fcPlcfendRef << endl1;
+ *pOut << "\tlcbPlcfendRef: " << lcbPlcfendRef << endl1;
+ *pOut << "\tfcPlcfendTxt: " << fcPlcfendTxt << endl1;
+ *pOut << "\tlcbPlcfendTxt: " << lcbPlcfendTxt << endl1;
+ *pOut << "\tfcPlcffldEdn: " << fcPlcffldEdn << endl1;
+ *pOut << "\tlcbPlcffldEdn: " << lcbPlcffldEdn << endl1;
+ *pOut << "\tfcPlcfpgdEdn: " << fcPlcfpgdEdn << endl1;
+ *pOut << "\tlcbPlcfpgdEdn: " << lcbPlcfpgdEdn << endl1;
+ *pOut << "\tfcDggInfo: " << fcDggInfo << endl1;
+ *pOut << "\tlcbDggInfo: " << lcbDggInfo << endl1;
+ *pOut << "\tfcSttbfRMark: " << fcSttbfRMark << endl1;
+ *pOut << "\tlcbSttbfRMark: " << lcbSttbfRMark << endl1;
+ *pOut << "\tfcSttbfCaption: " << fcSttbfCaption << endl1;
+ *pOut << "\tlcbSttbfCaption: " << lcbSttbfCaption << endl1;
+ *pOut << "\tfcSttbAutoCaption: " << fcSttbAutoCaption << endl1;
+ *pOut << "\tlcbSttbAutoCaption: " << lcbSttbAutoCaption << endl1;
+ *pOut << "\tfcPlcfwkb: " << fcPlcfwkb << endl1;
+ *pOut << "\tlcbPlcfwkb: " << lcbPlcfwkb << endl1;
+ *pOut << "\tfcPlcfspl: " << fcPlcfspl << endl1;
+ *pOut << "\tlcbPlcfspl: " << lcbPlcfspl << endl1;
+ *pOut << "\tfcPlcftxbxTxt: " << fcPlcftxbxTxt << endl1;
+ *pOut << "\tlcbPlcftxbxTxt: " << lcbPlcftxbxTxt << endl1;
+ *pOut << "\tfcPlcffldTxbx: " << fcPlcffldTxbx << endl1;
+ *pOut << "\tlcbPlcffldTxbx: " << lcbPlcffldTxbx << endl1;
+ *pOut << "\tfcPlcfHdrtxbxTxt: " << fcPlcfHdrtxbxTxt << endl1;
+ *pOut << "\tlcbPlcfHdrtxbxTxt: " << lcbPlcfHdrtxbxTxt << endl1;
+ *pOut << "\tfcPlcffldHdrTxbx: " << fcPlcffldHdrTxbx << endl1;
+ *pOut << "\tlcbPlcffldHdrTxbx: " << lcbPlcffldHdrTxbx << endl1;
+ *pOut << "\tfcPlcfLst: " << fcPlcfLst << endl1;
+ *pOut << "\tlcbPlcfLst: " << lcbPlcfLst << endl1;
+ *pOut << "\tfcPlfLfo: " << fcPlfLfo << endl1;
+ *pOut << "\tlcbPlfLfo: " << lcbPlfLfo << endl1;
+ *pOut << "\tfcPlcftxbxBkd: " << fcPlcftxbxBkd << endl1;
+ *pOut << "\tlcbPlcftxbxBkd: " << lcbPlcftxbxBkd << endl1;
+ *pOut << "\tfcPlcfHdrtxbxBkd: " << fcPlcfHdrtxbxBkd << endl1;
+ *pOut << "\tlcbPlcfHdrtxbxBkd: " << lcbPlcfHdrtxbxBkd << endl1;
+ *pOut << "\tfcSttbListNames: " << fcSttbListNames << endl1;
+ *pOut << "\tlcbSttbListNames: " << lcbSttbListNames << endl1;
+
+ *pOut << "\tpnChpFirst: " << pnChpFirst << endl1;
+ *pOut << "\tpnPapFirst: " << pnPapFirst << endl1;
+ *pOut << "\tcpnBteChp: " << cpnBteChp << endl1;
+ *pOut << "\tcpnBtePap: " << cpnBtePap << endl1;
+
+
+ *pOut << dec << "END FIB" << endl1 << endl1;
+}
+
+//-----------------------------------------
+// class DStyle
+//-----------------------------------------
+
+class DStyle: public WW8Style
+{
+ BYTE nVersion;
+public:
+ DStyle( SvStream& rStream, WW8Fib& rFib )
+ : WW8Style( rStream, rFib ){ nVersion = rFib.nVersion; }
+ void Dump1Style( USHORT nNr );
+ void Dump();
+};
+
+//-----------------------------------------
+// universelle Hilfsroutinen
+//-----------------------------------------
+
+static void DumpIt( SvStream& rSt, short nLen )
+{
+ indent( *pOut, rSt );
+ if( nLen <= 0 ){
+ *pOut << endl1;
+ return;
+ }
+ while ( nLen ){
+ BYTE c;
+ xStrm->Read( &c, sizeof(c) );
+ *pOut << "<0x" << hex2 << (USHORT)c << dec2 << "> ";
+ nLen--;
+ }
+ *pOut << endl1;
+}
+
+static void DumpItSmall( SvStream& rStrm, short nLen )
+{
+ if( nLen <= 0 )
+ return;
+
+ while ( nLen )
+ {
+ BYTE c;
+
+ rStrm.Read( &c, sizeof(c) );
+
+ if( c <= 9 )
+ *pOut << (USHORT)c;
+ else
+ *pOut << "0x" << hex2 << (USHORT)c << dec2;
+
+ nLen--;
+
+ if( nLen )
+ *pOut << ',';
+ }
+}
+
+//-----------------------------------------
+// Hilfsroutinen : Foot-, Endnotes
+//-----------------------------------------
+
+
+#if 0
+void DumpText( WW8_CP nStartCp, long nTextLen, WW8ScannerBase* pBase, short nType, char* pName = "" );
+static void DumpFtnShort( short nId, long nPos, long nFieldLen )
+{
+ ASSERT( nId < 261 && nId > 255, "Falsche Id" );
+
+ *pOut << '<' << hex << nPos << dec << ' ';
+
+ *pOut << 'F' << nId << ' ' << WW8GetSprmDumpInfo( nId ).pName << ' ';
+/*
+ if ( WW8GetSprmDumpInfo( nId ).pOutFnc ){
+ WW8GetSprmDumpInfo( nId ).pOutFnc( nId, nFieldLen ); // Rufe AusgabeFunktion
+ }
+*/
+ *pOut << '>' << endl1;
+
+ pPLCFMan->SavePLCF();
+ WW8PLCFMan* pOldPLCFMan = pPLCFMan;
+
+ pSBase->pChpPLCF->SeekPos( nPos );
+ pSBase->pPapPLCF->SeekPos( nPos );
+
+ DumpText( nPos, nFieldLen, pSBase, MAN_FTN, WW8GetSprmDumpInfo( nId ).pName );
+
+ indent( *pOut, *xStrm );
+
+ pPLCFMan = pOldPLCFMan; // Attributverwaltung restoren
+ pPLCFMan->RestorePLCF();
+}
+#endif
+
+//-----------------------------------------
+// Hilfsroutinen : SPRMS
+//-----------------------------------------
+
+
+/*
+#if 0
+static short DumpSprmShort( short nSprmsLen )
+{
+ long nSprmPos = xStrm->Tell();
+
+ *pOut << '<' << hex << nSprmPos << dec << ' ';
+
+ BYTE x[512];
+ xStrm->Read( x, 512 ); // Token und folgende lesen
+ BYTE i = x[0];
+
+ nSprmsLen -= WW8GetSprmSizeBrutto( nVersion, x ); // so viele Sprm-Bytes folgen noch nach diesem Sprm
+
+ if( nSprmsLen < 0 )
+ *pOut << "!UEberhang um " << -nSprmsLen << " Bytes!" << endl1;
+
+ *pOut << 'A' << (USHORT)i << ' ';
+ *pOut << aSprmTab[i].pName << ' ';
+
+ xStrm->Seek( nSprmPos + 1 + WW8SprmDataOfs( i ) );// gehe zum eigentlichen
+ // Inhalt
+ if ( aSprmTab[i].pOutFnc ){
+ WW8GetSprmDumpInfo( nId ).pOutFnc( i, WW8GetSprmSizeNetto( x ) );// Rufe AusgabeFunktion
+ }else{
+ DumpItSmall( WW8GetSprmSizeNetto( x ) ); // oder Dumper
+ }
+ *pOut << '>';
+
+ return nSprmsLen;
+}
+
+static void DumpSprmsShort( short nLen )
+{
+ if( nLen <= 1 || xStrm->IsEof() ){
+ return;
+ }
+ while ( nLen > 1 ){
+ nLen = DumpSprmShort( nLen );
+ }
+}
+#endif
+*/
+
+
+
+
+static short DumpSprm( BYTE nVersion, SvStream& rSt, short nSprmsLen )
+{
+ long nSprmPos = rSt.Tell();
+ BYTE nDelta;
+
+ indent( *pOut, rSt );
+
+ BYTE x[512];
+ rSt.Read( x, 512 ); // Token und folgende lesen
+
+ USHORT nId = WW8GetSprmId( nVersion, x, &nDelta );
+
+ short nSprmL = WW8GetSprmSizeBrutto( nVersion, x, &nId );
+ short nSprmNL = WW8GetSprmSizeNetto( nVersion, x, &nId );
+
+ nSprmsLen -= nSprmL;
+ if( nSprmsLen < 0 )
+ *pOut << "!UEberhang um " << -nSprmsLen << " Bytes!" << endl1;
+
+ // Ausgabe: Token in Dez
+ if( 8 > nVersion )
+ *pOut << (USHORT)x[0];
+ else
+ *pOut << hex << nId << dec;
+ *pOut << '/' << nSprmL; // Laenge incl. alles in Dez
+ *pOut << '/' << nSprmNL; // Laenge excl Token in Dez
+
+
+ const SprmDumpInfo& rSprm = WW8GetSprmDumpInfo( nId );
+
+ *pOut << " = " << rSprm.pName << ' ';
+
+ rSt.Seek( nSprmPos + 1 + nDelta + WW8SprmDataOfs( nId ) );// gehe zum eigentlichen
+ // Inhalt
+ if( rSprm.pOutFnc )
+ rSprm.pOutFnc( rSt, nSprmNL ); // Rufe Ausgabefunktion
+ else
+ DumpItSmall( rSt, nSprmNL ); // oder Dumper
+ *pOut << endl1;
+
+ return nSprmsLen;
+}
+
+void DumpSprms( BYTE nVersion, SvStream& rSt, short nLen )
+{
+ if( nLen <= 1 || rSt.IsEof() ){
+ return;
+ }
+ begin( *pOut, rSt ) << "Sprms" << endl1;
+ while ( nLen > 1 )
+ {
+ nLen = DumpSprm( nVersion, rSt, nLen );
+ }
+ end( *pOut, rSt ) << "Sprms" << endl1;
+}
+
+// DumpMemSprm() dumpt ein 2-Byte-Sprm, der im WW8_PCD eingebaut ist
+static void DumpMemSprm( BYTE nVersion, INT16* pSprm )
+{
+ BYTE* p = (BYTE*)pSprm;
+ USHORT nId = WW8GetSprmId( nVersion, p, 0 );
+
+ *pOut << (USHORT)p[0]; // Ausgabe: Token in Dez
+ *pOut << '/' << WW8GetSprmSizeBrutto( nVersion, p, &nId ); // Laenge incl. alles in Dez
+ *pOut << '/' << WW8GetSprmSizeNetto( nVersion, p, &nId ); // Laenge excl Token in Dez
+
+ *pOut << " = " << WW8GetSprmDumpInfo( nId ).pName;
+
+ *pOut << " 0x" << hex2 << *(p + 1);
+}
+
+
+//-----------------------------------------
+// Hilfsroutinen: SEPX
+//-----------------------------------------
+void DumpSepx( BYTE nVersion, long nPos )
+{
+ USHORT nLen;
+ xStrm->Seek( nPos );
+ begin( *pOut, *xStrm ) << "Sepx, Len: ";
+ xStrm->Read( &nLen, 2 );
+ *pOut << nLen << endl1;
+
+ DumpSprms( nVersion, *xStrm, nLen );
+
+ end( *pOut, *xStrm ) << "Sepx" << endl1;
+}
+
+
+//-----------------------------------------
+// Hilfsroutinen: FKP.CHPX, FKP.PAPX
+//-----------------------------------------
+static void DumpPhe( WW8_PHE_Base& rPhe )
+{
+ if( rPhe.aBits1 == 0 && rPhe.nlMac == 0
+ && SVBT16ToShort( rPhe.dxaCol ) == 0
+ && SVBT16ToShort( rPhe.dyl ) == 0 )
+ {
+ *pOut << indent2 << " empty PHE" << endl1;
+ }
+ else
+ {
+ *pOut << begin2 << "PHE" << endl1;
+ *pOut << indent2 << "fSpare: " << ( rPhe.aBits1 & 0x1 );
+ *pOut << ", fUnk: " << (( rPhe.aBits1 >> 1 ) & 1 );
+ *pOut << ", fDiffLines: " << (( rPhe.aBits1 >> 2 ) & 1 );
+ *pOut << ", unused: " << (( rPhe.aBits1 >> 3 ) & 0x1F )
+ << " (" << (short)(( rPhe.aBits1 >> 2 ) & 0x3F ) +
+ (((short)rPhe.nlMac) << 8)
+ << ")";
+ *pOut << ", nLines: " << (short)rPhe.nlMac << ',' << endl1;
+ *pOut << indent2 << "dxaCol: " << (short)SVBT16ToShort( rPhe.dxaCol );
+ if( rPhe.aBits1 & 0x4 )
+ {
+ *pOut << ", total height: " << (USHORT)SVBT16ToShort( rPhe.dyl );
+ }
+ else
+ {
+ *pOut << ", height per line: " << (short)SVBT16ToShort( rPhe.dyl );
+ *pOut << ", total height: " << rPhe.nlMac * (short)SVBT16ToShort( rPhe.dyl );
+ }
+ *pOut << endl1;
+ *pOut << end2 << "PHE" << endl1;
+ }
+}
+
+//typedef enum{ CHP=0, PAP, SEP, PLC_END }ePlcT;
+static char* NameTab[PLCF_END+4]={ "chpx", "papx", "sepx", "head",
+ "FootnoteRef", "EndnoteRef",
+ "AnnotationRef" };
+
+void DumpFkp( BYTE nVersion, long nPos, short nItemSize, ePLCFT ePlc )
+{
+ char nElem;
+
+ xStrm->Seek( nPos+511 );
+ xStrm->Read( &nElem, 1 );
+
+
+ *pOut << 'D' << hex6 << nPos << dec2 << ' ' << indent1 << begin1 << "Fkp.";
+ *pOut << NameTab[ePlc] << ", ";
+ *pOut << (USHORT)nElem << " Elements" << endl1;
+
+ int i;
+ WW8_FC aF[2];
+ BYTE c;
+ long nStartOfs = nPos + ( nElem + 1 ) * 4; // bei dieser Pos faengt Offset-Array an
+ short nOfs;
+ WW8_PHE_Base aPhe;
+
+ for( i=0; i<nElem; i++ )
+ {
+ xStrm->Seek( nPos + i * 4 );
+ indent( *pOut, *xStrm );
+ xStrm->Read( aF, sizeof( aF ) ); // lese 2 FCs
+
+ xStrm->Seek( nStartOfs + i * nItemSize );
+ xStrm->Read( &c, 1 ); // lese Word Offset ( evtl. Teil von BX )
+ if( ePlc == PAP )
+ xStrm->Read( &aPhe, sizeof( aPhe ) );
+
+ nOfs= c * 2; // -> Byte Offset
+ xStrm->Seek( nPos + nOfs );
+ xStrm->Read( &c, 1 );
+
+ if( !c )
+ xStrm->Read( &c, 1 );
+
+ *pOut << "Fc: " << hex << aF[0] << ".." << aF[1];
+ *pOut << " Cp: " << pSBase->WW8Fc2Cp( aF[0] )
+ << ".." << pSBase->WW8Fc2Cp( aF[1] );
+ *pOut << " Offset: " << nOfs << dec2;
+ if ( nOfs )
+ {
+ switch ( ePlc )
+ {
+ case CHP:
+ *pOut << ", Len: " << (short)c << endl1;
+ DumpSprms( nVersion, *xStrm, (short)c );
+ break;
+
+ case PAP:
+ short nLen = c * 2; // So weit bis zum naechsten !
+
+ short nIStd;
+
+ WW8ReadINT16( *xStrm, nIStd );
+
+ *pOut << ", Len max: " << nLen << ", ID:" << nIStd << endl1;
+ DumpSprms( nVersion, *xStrm, nLen - 2 );
+ DumpPhe( aPhe );
+ break;
+ }
+ }
+ else
+ {
+ *pOut << dec2 << " No attribute" << endl1;
+ }
+
+ }
+ end( *pOut, *xStrm ) << "Fkp." << NameTab[ePlc] << endl1;
+}
+
+//-----------------------------------------
+// WW8_DOP ( Document Properties )
+//-----------------------------------------
+
+//!!! WW8LoadDop gibt's jetzt auch in WW8scan.cxx
+void DumpDop( WW8Fib& rFib )
+{
+ // nicht loeschen!
+ xTableStream->Seek( rFib.fcDop ); // diese Aktion dient lediglich dazu, die
+ // Positions-Ausgabe der folgenden Anweisung
+ // mit dem alten Dumper uebereinstimmen zu lassen.
+
+// *pOut << begin( *pOut, *xTableStream ) << "Dop, Size " << rFib.lcbDop << ", DefaultSize 84" << endl1;
+ begin( *pOut, *xTableStream ) << "Dop, Size " << rFib.lcbDop << ", DefaultSize 84" << endl1;
+
+ WW8Dop* pD = new WW8Dop( *xTableStream, rFib.nFib, rFib.fcDop, rFib.lcbDop );
+
+ *pOut << indent2 << "fFacingPages : " << pD->fFacingPages << endl1;
+ *pOut << indent2 << "fWidowControl : " << pD->fWidowControl << endl1;
+ *pOut << indent2 << "fPMHMainDoc : " << pD->fPMHMainDoc << endl1;
+ *pOut << indent2 << "grfSuppression : " << pD->grfSuppression << endl1;
+ *pOut << indent2 << "fpc : " << pD->fpc << endl1;
+ *pOut << indent2 << "grpfIhdt : " << pD->grpfIhdt << endl1;
+ *pOut << indent2 << "rncFtn : " << pD->rncFtn << endl1;
+ *pOut << indent2 << "nFtn : " << pD->nFtn << endl1;
+ *pOut << indent2 << "fOutlineDirtySave : " << pD->fOutlineDirtySave << endl1;
+ *pOut << indent2 << "fOnlyMacPics : " << pD->fOnlyMacPics << endl1;
+ *pOut << indent2 << "fOnlyWinPics : " << pD->fOnlyWinPics << endl1;
+ *pOut << indent2 << "fLabelDoc : " << pD->fLabelDoc << endl1;
+ *pOut << indent2 << "fHyphCapitals : " << pD->fHyphCapitals << endl1;
+ *pOut << indent2 << "fAutoHyphen : " << pD->fAutoHyphen << endl1;
+ *pOut << indent2 << "fFormNoFields : " << pD->fFormNoFields << endl1;
+ *pOut << indent2 << "fLinkStyles : " << pD->fLinkStyles << endl1;
+ *pOut << indent2 << "fRevMarking : " << pD->fRevMarking << endl1;
+ *pOut << indent2 << "fBackup : " << pD->fBackup << endl1;
+ *pOut << indent2 << "fExactCWords : " << pD->fExactCWords << endl1;
+ *pOut << indent2 << "fPagHidden : " << pD->fPagHidden << endl1;
+ *pOut << indent2 << "fPagResults : " << pD->fPagResults << endl1;
+ *pOut << indent2 << "fLockAtn : " << pD->fLockAtn << endl1;
+ *pOut << indent2 << "fMirrorMargins : " << pD->fMirrorMargins << endl1;
+ *pOut << indent2 << "fReadOnlyRecommended : " << pD->fReadOnlyRecommended << endl1;
+ *pOut << indent2 << "fDfltTrueType : " << pD->fDfltTrueType << endl1;
+ *pOut << indent2 << "fPagSuppressTopSpacing : " << pD->fPagSuppressTopSpacing << endl1;
+ *pOut << indent2 << "fProtEnabled : " << pD->fProtEnabled << endl1;
+ *pOut << indent2 << "fDispFormFldSel : " << pD->fDispFormFldSel << endl1;
+ *pOut << indent2 << "fRMView : " << pD->fRMView << endl1;
+ *pOut << indent2 << "fRMPrint : " << pD->fRMPrint << endl1;
+ *pOut << indent2 << "fWriteReservation : " << pD->fWriteReservation << endl1;
+ *pOut << indent2 << "fLockRev : " << pD->fLockRev << endl1;
+ *pOut << indent2 << "fEmbedFonts : " << pD->fEmbedFonts << endl1;
+ *pOut << indent2 << "copts_fNoTabForInd : " << pD->copts_fNoTabForInd << endl1;
+ *pOut << indent2 << "copts_fNoSpaceRaiseLower : " << pD->copts_fNoSpaceRaiseLower << endl1;
+ *pOut << indent2 << "copts_fSupressSpbfAfterPgBrk : " << pD->copts_fSupressSpbfAfterPgBrk << endl1;
+ *pOut << indent2 << "copts_fWrapTrailSpaces : " << pD->copts_fWrapTrailSpaces << endl1;
+ *pOut << indent2 << "copts_fMapPrintTextColor : " << pD->copts_fMapPrintTextColor << endl1;
+ *pOut << indent2 << "copts_fNoColumnBalance : " << pD->copts_fNoColumnBalance << endl1;
+ *pOut << indent2 << "copts_fConvMailMergeEsc : " << pD->copts_fConvMailMergeEsc << endl1;
+ *pOut << indent2 << "copts_fSupressTopSpacing : " << pD->copts_fSupressTopSpacing << endl1;
+ *pOut << indent2 << "copts_fOrigWordTableRules : " << pD->copts_fOrigWordTableRules << endl1;
+ *pOut << indent2 << "copts_fTransparentMetafiles : " << pD->copts_fTransparentMetafiles << endl1;
+ *pOut << indent2 << "copts_fShowBreaksInFrames : " << pD->copts_fShowBreaksInFrames << endl1;
+ *pOut << indent2 << "copts_fSwapBordersFacingPgs : " << pD->copts_fSwapBordersFacingPgs << endl1;
+ *pOut << indent2 << "dxaTab : " << pD->dxaTab << endl1;
+ *pOut << indent2 << "wSpare : " << pD->wSpare << endl1;
+ *pOut << indent2 << "dxaHotZ : " << pD->dxaHotZ << endl1;
+ *pOut << indent2 << "cConsecHypLim : " << pD->cConsecHypLim << endl1;
+ *pOut << indent2 << "wSpare2 : " << pD->wSpare2 << endl1;
+ *pOut << indent2 << "dttmCreated : " << pD->dttmCreated << endl1;
+ *pOut << indent2 << "dttmRevised : " << pD->dttmRevised << endl1;
+ *pOut << indent2 << "dttmLastPrint : " << pD->dttmLastPrint << endl1;
+ *pOut << indent2 << "nRevision : " << pD->nRevision << endl1;
+ *pOut << indent2 << "tmEdited : " << pD->tmEdited << endl1;
+ *pOut << indent2 << "cWords : " << pD->cWords << endl1;
+ *pOut << indent2 << "cCh : " << pD->cCh << endl1;
+ *pOut << indent2 << "cPg : " << pD->cPg << endl1;
+ *pOut << indent2 << "cParas : " << pD->cParas << endl1;
+ *pOut << indent2 << "rncEdn : " << pD->rncEdn << endl1;
+ *pOut << indent2 << "nEdn : " << pD->nEdn << endl1;
+ *pOut << indent2 << "epc : " << pD->epc << endl1;
+ *pOut << indent2 << "fPrintFormData : " << pD->fPrintFormData << endl1;
+ *pOut << indent2 << "fSaveFormData : " << pD->fSaveFormData << endl1;
+ *pOut << indent2 << "fShadeFormData : " << pD->fShadeFormData << endl1;
+ *pOut << indent2 << "fWCFtnEdn : " << pD->fWCFtnEdn << endl1;
+ *pOut << indent2 << "cLines : " << pD->cLines << endl1;
+ *pOut << indent2 << "cWordsFtnEnd : " << pD->cWordsFtnEnd << endl1;
+ *pOut << indent2 << "cChFtnEdn : " << pD->cChFtnEdn << endl1;
+ *pOut << indent2 << "cPgFtnEdn : " << pD->cPgFtnEdn << endl1;
+ *pOut << indent2 << "cParasFtnEdn : " << pD->cParasFtnEdn << endl1;
+ *pOut << indent2 << "cLinesFtnEdn : " << pD->cLinesFtnEdn << endl1;
+ *pOut << indent2 << "lKeyProtDoc : " << pD->lKeyProtDoc << endl1;
+ *pOut << indent2 << "wvkSaved : " << pD->wvkSaved << endl1;
+ *pOut << indent2 << "wScaleSaved : " << pD->wScaleSaved << endl1;
+ *pOut << indent2 << "zkSaved : " << pD->zkSaved << endl1;
+ *pOut << indent2 << "fNoTabForInd : " << pD->fNoTabForInd << endl1;
+ *pOut << indent2 << "fNoSpaceRaiseLower : " << pD->fNoSpaceRaiseLower << endl1;
+ *pOut << indent2 << "fSupressSpbfAfterPageBreak : " << pD->fSupressSpbfAfterPageBreak << endl1;
+ *pOut << indent2 << "fWrapTrailSpaces : " << pD->fWrapTrailSpaces << endl1;
+ *pOut << indent2 << "fMapPrintTextColor : " << pD->fMapPrintTextColor << endl1;
+ *pOut << indent2 << "fNoColumnBalance : " << pD->fNoColumnBalance << endl1;
+ *pOut << indent2 << "fConvMailMergeEsc : " << pD->fConvMailMergeEsc << endl1;
+ *pOut << indent2 << "fSupressTopSpacing : " << pD->fSupressTopSpacing << endl1;
+ *pOut << indent2 << "fOrigWordTableRules : " << pD->fOrigWordTableRules << endl1;
+ *pOut << indent2 << "fTransparentMetafiles : " << pD->fTransparentMetafiles << endl1;
+ *pOut << indent2 << "fShowBreaksInFrames : " << pD->fShowBreaksInFrames << endl1;
+ *pOut << indent2 << "fSwapBordersFacingPgs : " << pD->fSwapBordersFacingPgs << endl1;
+ *pOut << indent2 << "fSuppressTopSpacingMac5 : " << pD->fSuppressTopSpacingMac5 << endl1;
+ *pOut << indent2 << "fTruncDxaExpand : " << pD->fTruncDxaExpand << endl1;
+ *pOut << indent2 << "fPrintBodyBeforeHdr : " << pD->fPrintBodyBeforeHdr << endl1;
+ *pOut << indent2 << "fNoLeading : " << pD->fNoLeading << endl1;
+ *pOut << indent2 << "fMWSmallCaps : " << pD->fMWSmallCaps << endl1;
+
+ *pOut << indent2 << "adt : " << pD->adt << endl1;
+
+ *pOut << indent2 << "lvl : " << pD->lvl << endl1;
+ *pOut << indent2 << "fHtmlDoc : " << pD->fHtmlDoc << endl1;
+ *pOut << indent2 << "fSnapBorder : " << pD->fSnapBorder << endl1;
+ *pOut << indent2 << "fIncludeHeader : " << pD->fIncludeHeader << endl1;
+ *pOut << indent2 << "fIncludeFooter : " << pD->fIncludeFooter << endl1;
+ *pOut << indent2 << "fForcePageSizePag : " << pD->fForcePageSizePag << endl1;
+ *pOut << indent2 << "fMinFontSizePag : " << pD->fMinFontSizePag << endl1;
+
+ *pOut << indent2 << "fHaveVersions : " << pD->fHaveVersions << endl1;
+ *pOut << indent2 << "fAutoVersion : " << pD->fAutoVersion << endl1;
+ *pOut << indent2 << "cChWS : " << pD->cChWS << endl1;
+ *pOut << indent2 << "cChWSFtnEdn : " << pD->cChWSFtnEdn << endl1;
+ *pOut << indent2 << "grfDocEvents : " << pD->grfDocEvents << endl1;
+ *pOut << indent2 << "cDBC : " << pD->cDBC << endl1;
+ *pOut << indent2 << "cDBCFtnEdn : " << pD->cDBCFtnEdn << endl1;
+ *pOut << indent2 << "nfcFtnRef : " << pD->nfcFtnRef << endl1;
+ *pOut << indent2 << "nfcEdnRef : " << pD->nfcEdnRef << endl1;
+ *pOut << indent2 << "hpsZoonFontPag : " << pD->hpsZoonFontPag << endl1;
+ *pOut << indent2 << "dywDispPag : " << pD->dywDispPag << endl1;
+
+ end( *pOut, *xStrm ) << "Dop" << endl1 << endl1;
+
+ DELETEZ( pD );
+}
+
+//-----------------------------------------
+// PLCF.PCD ( Piece Table )
+//-----------------------------------------
+
+#ifdef __WW8_NEEDS_PACK
+# pragma pack(2)
+#endif
+
+struct WW8_PCD1
+{
+ BYTE aBits1;
+ BYTE aBits2;
+// INT16 fNoParaLast : 1; // when 1, means that piece contains no end of parag
+// BYTE fPaphNil : 1; // used internally by Word
+// BYTE fCopied : 1; // used internally by Word
+ // * int :5
+// BYTE aBits2; // fn int:8, used internally by Word
+ INT32 fc; // file offset of beginning of piece. The size of th
+ INT16 prm; // PRM contains either a single sprm or else an inde
+};
+
+#ifdef __WW8_NEEDS_PACK
+# pragma pack()
+#endif
+
+static void DumpPLCFPcd( BYTE nVersion, long nPos, long nLen )
+{
+ WW8PLCF aPlc( &xTableStream, nPos , nLen, 8 );
+
+ *pOut << 'D' << hex6 << nPos << dec2 << ' ' << indent1 << begin1;
+ *pOut << "Plcx.Pcd, Len: ";
+ *pOut << nLen << ", " << aPlc.GetIMax() << " Elements" << endl1;
+
+ int i;
+ for( i=0; i<aPlc.GetIMax(); i++ )
+ {
+ long start, ende;
+ void* pData;
+ aPlc.Get( start, ende, pData );
+ *pOut << indent2 << " Cp: " << hex6 << start << ".." << hex6 << ende;
+
+ WW8_PCD1* p = (WW8_PCD1*) pData;
+ *pOut << ", Bits: " << hex2 << (USHORT)p->aBits1 << ' '
+ << hex2 << (USHORT)p->aBits2;
+ *pOut << ", FcStart: ";
+ if( 8 <= nVersion )
+ {
+ BOOL bUniCode;
+ *pOut << hex6
+ << WW8PLCFx_PCD::TransformPieceAddress( p->fc, bUniCode );
+ if( bUniCode )
+ *pOut << " (UniCode)";
+ }
+ else
+ *pOut << hex6 << p->fc;
+
+ *pOut << dec << ", prm ";
+ if( p->prm & 0x1 ){
+ *pOut << "No: " << ( p->prm >> 1 );
+ }else if ( p-> prm == 0 ){
+ *pOut << "-";
+ }else{
+ *pOut << "(Sprm): ";
+ DumpMemSprm( nVersion, &(p->prm) );
+ }
+ *pOut << endl1;
+
+ aPlc++;
+ }
+ end( *pOut, *xTableStream ) << "Plcx.Pcd" << endl1;
+}
+
+static void DumpPcd( BYTE nVersion, long nPos, long nLen )
+{
+ long nLen1 = nLen;
+ xTableStream->Seek( nPos );
+
+ *pOut << 'D' << hex6 << nPos << dec2 << ' ' << indent1 << begin1;
+ *pOut << "PieceTable, Len: " << nLen << endl1;
+ if( sizeof( WW8_PCD1 ) != 8 )
+ *pOut << "!!! Alignment-Problem !!! sizeof( WW8_PCD1 ) != 8 !!! " << endl1;
+
+ long i = 0;
+ while (1){
+ BYTE c;
+ INT16 cb;
+
+ xTableStream->Read( &c, 1 );
+ nLen1 --;
+ if( c == 2 )
+ break;
+ xTableStream->Read( &cb, 2 );
+ nLen1 -= 2;
+ indent( *pOut, *xTableStream ) << "grpprl No. " << i << ", Len: " << cb << endl1;
+
+ long nPos = xTableStream->Tell();
+ DumpSprms( nVersion, *xTableStream, cb ); // Dumpe Sprms
+ xTableStream->Seek( nPos + cb ); // gehe hinter grpprl
+ nLen1 -= cb;
+ i++;
+// *pOut << " " << indent1 << "grpprl: " << cb << "Bytes ueberlesen";
+// *pOut << endl1;
+ }
+ INT32 nLen2;
+ xTableStream->Read( &nLen2, 4 );
+ nLen1 -= 4;
+ if( nLen1 != nLen2 )
+ *pOut << "!!! nLen1 ( " << nLen1 << " ) != nLen2 ( " << nLen2 << " ) !"
+ << endl1;
+
+ DumpPLCFPcd( nVersion, xTableStream->Tell(), nLen2 );
+
+ end( *pOut, *xTableStream ) << "PieceTable" << endl1 << endl1;
+}
+
+//-----------------------------------------
+// PLCF.CHPX, PLCF.PAPX, PLCF.SEPX
+//-----------------------------------------
+
+static void DumpPLCF( long nPos, long nLen, ePLCFT ePlc )
+{
+ static int __READONLY_DATA WW8FkpSizeTabVer6[ PLCF_END ] = {
+ 1, 7, 0 /*, 0, 0, 0*/ };
+ static int __READONLY_DATA PlcSizeTabVer6[ PLCF_END+4 ] = {
+ 2, 2, 12, 0, 2, 2, 20 };
+
+ static int __READONLY_DATA WW8FkpSizeTabVer8[ PLCF_END ] = {
+ 1, 13, 0 /*, 0, 0, 0*/ };
+ static int __READONLY_DATA PlcSizeTabVer8[ PLCF_END+4 ] = {
+ 4, 4, 12, 0, 2, 2, 30 };
+
+ const int* pFkpSizeTab;
+ const int* pPlcSizeTab;
+
+ switch( pWwFib->nVersion )
+ {
+ case 6:
+ case 7: pFkpSizeTab = WW8FkpSizeTabVer6;
+ pPlcSizeTab = PlcSizeTabVer6;
+ break;
+ case 8: pFkpSizeTab = WW8FkpSizeTabVer8;
+ pPlcSizeTab = PlcSizeTabVer8;
+ break;
+ default:// Programm-Fehler!
+ /*
+ ACHTUNG: im FILTER nicht "FALSE" sondern "!this()" schreiben,
+ da sonst Warning unter OS/2
+ */
+ ASSERT( FALSE, "Es wurde vergessen, nVersion zu kodieren!" );
+ return;
+ }
+
+// SvStream* pSt = (SEP == ePlc) ? &xTableStream : &xStrm;
+ SvStream* pSt = &xTableStream;
+
+ WW8PLCF aPlc( pSt, nPos, nLen, pPlcSizeTab[ ePlc ] );
+
+ *pOut << 'T' << hex6 << nPos << dec2 << ' ' << indent1 << begin1;
+ *pOut << "Plcx." << NameTab[ePlc] << ", Len: ";
+ *pOut << nLen << ", " << aPlc.GetIMax() << " Elements" << endl1;
+
+ int i;
+ for( i=0; i<aPlc.GetIMax(); i++ )
+ {
+ long start, ende;
+ void* pData;
+ aPlc.Get( start, ende, pData );
+ *pOut << indent2 << "Plcx." << NameTab[ePlc];
+ switch( ePlc ){
+ case SEP: {
+ *pOut << " Cp: " << hex << start << ".." << ende ;
+ long nPo = *((long*)((char*)pData+2));
+ if( nPo == 0xffffffffL )
+ {
+ *pOut << " Empty" << endl1;
+ }
+ else
+ {
+ *pOut << ", Sepx-Position: " << nPo << dec << endl1;
+ DumpSepx( pWwFib->nVersion, nPo );
+ }
+ }
+ break;
+ case CHP:
+ case PAP: {
+ *pOut << " Fc: " << hex << start << ".." << ende ;
+ long nPo;
+ switch( pWwFib->nVersion )
+ {
+ case 6:
+ case 7: nPo = *((USHORT*)pData);
+ break;
+ case 8: nPo = *((UINT32*)pData);
+ break;
+ default:// Programm-Fehler!
+ /*
+ ACHTUNG: im FILTER nicht "FALSE" sondern "!this()" schreiben,
+ da sonst Warning unter OS/2
+ */
+ ASSERT( FALSE, "Es wurde vergessen, nVersion zu kodieren!" );
+ return;
+ }
+
+ nPo <<= 9;
+ *pOut << ", Offset: " << nPo << dec << endl1;
+ DumpFkp( pWwFib->nVersion, nPo, pFkpSizeTab[ ePlc ], ePlc );
+ }
+ break;
+
+ case PLCF_END+0:
+ *pOut << " Cp: " << hex << start << ".." << ende << dec << endl1;
+ break;
+
+ case PLCF_END+1:
+ case PLCF_END+2:
+ {
+ *pOut << " Cp: " << hex << start;
+ USHORT nFlags= *((USHORT*)pData);
+ *pOut << ", Flags: 0x" << nFlags << dec << endl1;
+ }
+ break;
+
+ case PLCF_END+3:
+ {
+ *pOut << " Cp: " << hex << start << ", Initial: \"";
+ const char* p = (char*)pData;
+ BYTE n = *p++;
+ while( n-- )
+ {
+ if( 8 == pWwFib->nVersion )
+ ++p;
+ *pOut << *p++;
+ }
+
+ long nBkmkId;
+ USHORT nId;
+ if( 8 == pWwFib->nVersion )
+ {
+ nId = SVBT16ToShort( ((WW8_ATRD*)pData)->ibst );
+ nBkmkId = SVBT32ToLong( ((WW8_ATRD*)pData)->ITagBkmk );
+ }
+ else
+ {
+ nId = SVBT16ToShort( ((WW67_ATRD*)pData )->ibst );
+ nBkmkId = SVBT32ToLong( ((WW67_ATRD*)pData )->ITagBkmk );
+ }
+
+ *pOut << "\", AutorId: " << hex << nId
+ << " BkmkId: " << nBkmkId << dec <<endl1;
+ }
+ break;
+
+ }
+ aPlc++;
+ }
+ end( *pOut, *xTableStream ) << "Plcx." << NameTab[ePlc] << endl1 << endl1;
+}
+
+//-----------------------------------------------------
+// PLCF.CHPX, PLCF.PAPX unter Benutzung von PLCF_Fkp
+//-----------------------------------------------------
+#if 0
+static void DumpPLCF2( long nPos, long nLen, ePlcT ePlc )
+{
+ *pOut << 'T' << hex6 << nPos << dec2 << ' ' << indent1 << begin1;
+ *pOut << "Plcx." << NameTab[ePlc] << endl1;
+
+ PLCF* pPLCF;
+ switch( ePlc ){
+ case SEP: pPLCF = new PLCF_Sepx( nPos, nLen, ePlc );
+ break;
+ default: pPLCF = new PLCF_Fkp( nPos, nLen, ePlc );
+ break;
+ }
+
+ while(1){
+ long nSt, nE;
+ short nL;
+
+ WW8_CP nP = pPLCF->WhereNext();
+ pPLCF->SeekNextSprms( nSt, nE, nL ); // wo sind naechste Sprms
+
+ if ( nSt == LONG_MAX )
+ break; // fertig
+
+ *pOut << " " << indent1 << "Cp: " << hex << nP <<" Cp: " << nSt << ".." << nE << dec;
+
+ if( nL ){
+ *pOut << ", Len: " << nL << endl1;
+ DumpSprms( *xStrm, nL );
+ }else{
+ *pOut << ", No Attribute" << endl1;
+ }
+ }
+ end( *pOut, *xStrm ) << "Plcx." << NameTab[ePlc] << endl1 << endl1;
+ DELETEZ( pPLCF );
+}
+#endif
+//-----------------------------------------
+// Text ohne Attribute
+//-----------------------------------------
+
+static void DumpPlainText1( WW8_CP nStartCp, long nTextLen )
+{
+ long l;
+ BYTE c;
+
+
+ xStrm->Seek( pSBase->WW8Cp2Fc( nStartCp ) );
+
+ for (l=0; l<nTextLen; l++)
+ {
+ xStrm->Read( &c, sizeof(c) );
+ if ( DumpChar( c ) )
+ {
+ *pOut << endl1;
+ indent( *pOut, *xStrm );
+ }
+// DumpChar( c );
+ }
+}
+
+void DumpShortPlainText( WW8_CP nStartCp, long nTextLen, char* pName )
+{
+ indent( *pOut, *xStrm ) << pName << " PlainText: Cp: "
+ << hex << nStartCp
+ << ".." << nStartCp + nTextLen << dec
+ << " :\"";
+ DumpPlainText1( nStartCp, nTextLen );
+ *pOut << "\"" << endl1;
+}
+
+void DumpPlainText( WW8_CP nStartCp, long nTextLen, char* pName )
+{
+ begin( *pOut, *xStrm ) << pName << " Text: Cp: " << hex << nStartCp
+ << ".." << nStartCp + nTextLen << dec
+ << endl1;
+ indent( *pOut, *xStrm );
+ DumpPlainText1( nStartCp, nTextLen );
+ *pOut << endl1;
+ end( *pOut, *xStrm ) << pName << " Text" << endl1;
+}
+
+//-----------------------------------------
+// Text mit Attributen
+//-----------------------------------------
+
+BOOL DumpChar( BYTE c )
+{
+ if ( ( c >= 32 ) && ( c <= 127 ) ){
+ *pOut << c;
+ return FALSE;
+ }else{
+ switch (c){
+ case 0xe4: // dt. Umlaute
+ case 0xf6:
+ case 0xfc:
+ case 0xdf:
+ case 0xc4:
+ case 0xd6:
+ case 0xdc: *pOut << c; return FALSE;
+
+ case 0xd: *pOut << "<CR>";
+ return TRUE;
+ case 0x7:
+ case 0xc: *pOut << "<0x" << hex2 << (USHORT)c << dec2 << '>';
+ return TRUE;
+ default: *pOut << "<0x" << hex2 << (USHORT)c << dec2 << '>';
+ return FALSE;
+ }
+ }
+}
+
+#if 0
+void DumpText2( long nTextStart, long nTextLen, long nPlcPos, long nPlcLen, ePlcT ePlc )
+{
+ long l;
+ BYTE c;
+
+ PLCF aPLCF( nPlcPos, nPlcLen, ePlc );
+ long nNxStart = aPLCF.WhereNext();
+ long nNxEnd = LONG_MAX;
+
+ xStrm->Seek( nTextStart );
+
+ begin( *pOut, *xStrm ) << "Text" << endl1;
+ indent( *pOut, xStrm );
+ for (l=0; l<nTextLen; l++){
+
+ if( nTextStart + l == nNxStart ){
+ long nOld = xStrm->Tell();
+ short nL;
+
+ aPLCF.SeekNext( nNxStart, nNxEnd, nL ); // wo ist naechstes Attribut
+ if( nL ){
+ *pOut << '<';
+ DumpSprmsShort( nL );
+ *pOut << '>';
+ }else{
+ *pOut << "<No Attribute>";
+ }
+
+ nNxStart = aPLCF.WhereNext();
+ xStrm->Seek( nOld );
+ }
+ if( nTextStart + l == nNxEnd )
+ *pOut << "<End Attribute>";
+
+ xStrm->Read( &c, sizeof(c) );
+ if ( DumpChar( c ) )
+ {
+ *pOut << endl1;
+ indent( *pOut, xStrm );
+ }
+ }
+ *pOut << endl1;
+ end( *pOut, *xStrm ) << "Text" << endl1 << endl1;
+}
+#endif
+#if 0
+long DumpTxtAttr( WW8PLCFMan& rMan, BOOL& bNl )
+{
+ long nPos, nNext, nOld = xStrm->Tell();
+ short nId;
+ long nL;
+ BYTE nFlags;
+
+ BOOL b = rMan.SeekNext( nPos, nL, nId, nFlags ); // gehe zu Attribut
+
+ if( nFlags & MAN_MASK_NEW_SEP ) // neue Section
+ *pOut << "<Section Break>";
+
+/* if( nFlags & MAN_MASK_NEW_PAP ) // neuer Absatz
+ *pOut << "<ParaStyle:" << pPLCFMan->GetColl( MAN_NUM_PARACOLL ) << '>' << endl1;
+*/
+ if( nId != -1 && nId != -11 ){ // leere Attrs ignorieren
+
+ if ( bNl )
+ *pOut << hex6 << nOld << ' ' << indent1;
+ bNl = FALSE;
+
+ if( nId < 256 ){
+ if( b ){ // WW-Attribute
+ if( nL >= 0 ){ // Attr-Anfang
+ xStrm->Seek( nPos );
+ DumpSprmShort( (short)nL );
+ }else {
+ *pOut << "<A" << nId << " No Attr>";
+ }
+ }else{ // Attr-Ende
+ *pOut << "<End A" << nId << '>';
+ }
+ }else if( nId < 260 ){
+ DumpFtnShort( nId, nPos, nL ); // Footnotes u.ae.
+ }else{
+ *pOut << "<Field>";
+ }
+ }
+
+ nNext = rMan.WhereNext();
+ xStrm->Seek( nOld );
+ return nNext;
+}
+
+void DumpText( WW8_CP nStartCp, long nTextLen, WW8ScannerBase* pBase, short nType, char* pName )
+{
+ pPLCFMan = new WW8PLCFMan( pBase, nType );
+
+ long l;
+ BYTE c;
+
+ long nNext = pPLCFMan->WhereNext();
+
+ xStrm->Seek( WW8Cp2Fc( nStartCpp, pWwFib->fcMin, 8 != pWwFib->nVersion ) );
+
+ begin( *pOut, *xStrm ) << pName << "Text" << endl1;
+ BOOL bNl = TRUE;
+ for (l=nStartCp; l<nStartCp+nTextLen; l++){
+
+ while( l >= nNext )
+ nNext = DumpTxtAttr( *pPLCFMan, bNl );
+
+ if ( bNl ) indent( *pOut, xStrm );
+
+ xStrm->Read( &c, sizeof(c) );
+ bNl = DumpChar( c );
+ if ( bNl ){
+ *pOut << "<ParaStyle:" << pPLCFMan->GetColl( MAN_NUM_PARACOLL ) << '>' << endl1;
+ }
+ }
+
+ while( l >= nNext )
+ nNext = DumpTxtAttr( *pPLCFMan, bNl );
+
+ if( !bNl )
+ *pOut << endl1;
+
+ end( *pOut, *xStrm ) << pName << "Text" << endl1;
+
+ DELETEZ( pPLCFMan );
+}
+#endif
+
+//-----------------------------------------
+// Header / Footer
+//-----------------------------------------
+
+static void DumpPlcText( WW8_FC nPos, long nLen, long nOfs,
+ char* pName, WW8ScannerBase* pBase,
+ long nStruct = 0, FNDumpData pOutFnc = 0 )
+{
+ if( !nLen ) return;
+
+ WW8PLCF aPlc( &xTableStream, nPos , nLen, nStruct );
+
+ *pOut << 'T' << hex6 << nPos << dec2 << ' ' << indent1 << begin1;
+ *pOut << "Plc." << pName << " Text, Len: ";
+ *pOut << nLen << ", " << aPlc.GetIMax() << " Elements" << endl1;
+
+ int i;
+ for( i=0; i < aPlc.GetIMax(); ++i )
+ {
+ WW8_CP start, ende;
+ WW8_FC start2, ende2;
+ void* pData;
+ aPlc.Get( start, ende, pData );
+ start2 = pSBase->WW8Cp2Fc(start + nOfs );
+ ende2 = pSBase->WW8Cp2Fc(ende + nOfs );
+
+ *pOut << " " << indent1 << "Plcx." << pName;
+ *pOut << " Cp: " << hex << start << ".." << ende;
+ *pOut << " entspricht Fc: " << start2 << ".." << ende2 << dec << endl1;
+
+ DumpPlainText( nOfs + start, ende - start - 1, pName );
+
+ if( pOutFnc )
+ (*pOutFnc)( pData );
+ aPlc++;
+ }
+ end( *pOut, *xTableStream ) << "Plcx." << pName << endl1 << endl1;
+}
+
+void DumpHeader( WW8ScannerBase* pBase )
+{
+ DumpPlcText( pWwFib->fcPlcfhdd,
+ pWwFib->lcbPlcfhdd,
+ pWwFib->ccpText + pWwFib->ccpFtn,
+ "Header/Footer", pBase );
+}
+
+static void DumpFootnotes( WW8ScannerBase* pBase )
+{
+ if( !pWwFib->lcbPlcffndRef ){
+ *pOut << "No Footnotes" << endl1 << endl1;
+ return;
+ }
+
+ DumpPLCF( pWwFib->fcPlcffndRef,
+ pWwFib->lcbPlcffndRef,
+ ePLCFT(/*FNR*/PLCF_END + 1) );
+ DumpPlcText( pWwFib->fcPlcffndTxt,
+ pWwFib->lcbPlcffndTxt,
+ pWwFib->ccpText,
+ "FootNote" , pBase );
+}
+
+static void DumpEndnotes( WW8ScannerBase* pBase )
+{
+ if( !pWwFib->lcbPlcfendRef ){
+ *pOut << "No Endnotes" << endl1 << endl1;
+ return;
+ }
+
+ DumpPLCF( pWwFib->fcPlcfendRef,
+ pWwFib->lcbPlcfendRef,
+ ePLCFT(/*ENR*/PLCF_END + 2) );
+ DumpPlcText( pWwFib->fcPlcfendTxt,
+ pWwFib->lcbPlcfendTxt,
+ pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpAtn,
+ "EndNote", pBase );
+}
+
+static void DumpAnnotations( WW8ScannerBase* pBase )
+{
+ if( !pWwFib->lcbPlcfandRef ){
+ *pOut << "No Annotations" << endl1 << endl1;
+ return;
+ }
+
+ DumpPLCF( pWwFib->fcPlcfandRef,
+ pWwFib->lcbPlcfandRef,
+ ePLCFT(/*ENR*/PLCF_END + 3) );
+ DumpPlcText( pWwFib->fcPlcfandTxt,
+ pWwFib->lcbPlcfandTxt,
+ pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr,
+ "Annotation", pBase );
+}
+
+void DumpTxtStoryEntry( void* pData )
+{
+ if( 8 == pWwFib->nVersion )
+ {
+ long* p = (long*)pData;
+ begin( *pOut, *xStrm )
+ << "TextboxStory" << hex << endl1;
+
+ *pOut << " " << indent1 << "cTxbx/iNextReuse: 0x" << *p++;
+ *pOut << " cReusable: 0x" << *p++;
+ short* ps = (short*)p;
+ *pOut << " fReusable: 0x" << *ps++ << endl1;
+ p = (long*)ps;
+ ++p; // reserved
+ *pOut << " " << indent1 << "lid: 0x" << *p++;
+ *pOut << " txidUndo: 0x" << *p++ << dec << endl1;
+
+ end( *pOut, *xStrm ) << "TextboxStory" << endl1 << endl1;
+ }
+}
+
+static void DumpTextBoxs( WW8ScannerBase* pBase )
+{
+ if( pWwFib->lcbPlcftxbxTxt )
+ {
+ DumpPlcText( pWwFib->fcPlcftxbxTxt,
+ pWwFib->lcbPlcftxbxTxt,
+ pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpAtn + pWwFib->ccpEdn,
+ "TextBoxes", pBase,
+ 8 == pWwFib->nVersion ? 22 : 0, &DumpTxtStoryEntry );
+ }
+ else
+ *pOut << "No Textboxes" << endl1 << endl1;
+
+ if( pWwFib->lcbPlcfHdrtxbxTxt )
+ DumpPlcText( pWwFib->fcPlcfHdrtxbxTxt,
+ pWwFib->lcbPlcfHdrtxbxTxt,
+ pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpAtn + pWwFib->ccpEdn
+ + pWwFib->ccpTxbx,
+ "HeaderTextBoxes", pBase,
+ 8 == pWwFib->nVersion ? 22 : 0, &DumpTxtStoryEntry );
+ else
+ *pOut << "No HeaderTextboxes" << endl1 << endl1;
+
+}
+
+
+static void DumpDrawObjects( const char* pNm, long nStart, long nLen,
+ long nOffset )
+{
+ if( nStart && nLen )
+ {
+ WW8PLCFspecial aPLCF( &xTableStream, nStart, nLen,
+ 8 == pWwFib->nVersion ? 26 : 6 );
+ *pOut << 'T' << hex6 << nStart << dec2 << ' ' << indent1 << begin1
+ << pNm << ", Len: " << nLen
+ << ", " << aPLCF.GetIMax() << " Elements" << endl1;
+
+ for( USHORT i = 0; i < aPLCF.GetIMax(); ++i )
+ {
+ long nCp = aPLCF.GetPos( i );
+ if( nCp >= LONG_MAX )
+ break;
+
+ *pOut << indent2 << i << ".Cp: 0x" << hex << nCp + nOffset;
+ long* pFSPA = (long*)aPLCF.GetData( i );
+ if( 8 == pWwFib->nVersion )
+ {
+ *pOut << " ShapeId: 0x" << *pFSPA++;
+ *pOut << " left: " << dec << *pFSPA++;
+ *pOut << " top: " << *pFSPA++;
+ *pOut << " right: " << *pFSPA++;
+ *pOut << " bottom: " << *pFSPA++;
+ USHORT* pU = (USHORT*)pFSPA;
+ *pOut << " flags: 0x" << hex << *pU++;
+ pFSPA = (long*)pU;
+ *pOut << " xTxbx: " << dec << *pFSPA;
+ }
+ else
+ {
+ *pOut << " FC of DO: 0x" << *pFSPA++;
+ *pOut << " ctcbx: " << dec << *(USHORT*)pFSPA;
+ }
+
+ *pOut << endl1;
+ }
+ *pOut << end1;
+ }
+ else
+ *pOut << "No ";
+ *pOut << pNm << endl1 << endl1;
+}
+
+static void DumpTxtboxBrks( const char* pNm, long nStart, long nLen,
+ long nOffset )
+{
+ if( nStart && nLen )
+ {
+ WW8PLCFspecial aPLCF( &xTableStream, nStart, nLen, 6 );
+ *pOut << 'T' << hex6 << nStart << dec2 << ' ' << indent1 << begin1
+ << pNm << ", Len: " << nLen
+ << ", " << aPLCF.GetIMax() << " Elements" << endl1;
+
+ for( USHORT i = 0; i < aPLCF.GetIMax(); ++i )
+ {
+ long nCp = aPLCF.GetPos( i );
+ if( nCp >= LONG_MAX )
+ break;
+
+ USHORT* pBKD = (USHORT*)aPLCF.GetData( i );
+ *pOut << indent2 << i << ".Cp: 0x" << hex << nCp + nOffset
+ << " itxbxs: 0x" << *pBKD++;
+ *pOut << " dcpDepend: 0x" << *pBKD++;
+ *pOut << " flags: 0x" << hex << *pBKD << dec << endl1;
+ }
+ *pOut << end2;
+ }
+ else
+ *pOut << "No ";
+ *pOut << pNm << endl1 << endl1;
+}
+
+static void DumpFdoa( WW8ScannerBase* pBase )
+{
+ long nOffset = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpAtn + pWwFib->ccpEdn;
+
+ if( 8 == pWwFib->nVersion )
+ {
+ DumpDrawObjects( "DrawObjects in Maintext",
+ pWwFib->fcPlcfspaMom, pWwFib->lcbPlcfspaMom,
+ /*nOffset*/0 );
+ // PLCF fuer TextBox-Break-Deskriptoren im Maintext
+ DumpTxtboxBrks( "TextBox-Break-Desk. im Maintext",
+ pWwFib->fcPlcftxbxBkd, pWwFib->lcbPlcftxbxBkd,
+ nOffset );
+ }
+ else
+ DumpDrawObjects( "DrawObjects in Maintext",
+ pWwFib->fcPlcfdoaMom, pWwFib->lcbPlcfdoaMom,
+ /*nOffset*/0 );
+
+ nOffset += pWwFib->ccpHdrTxbx;
+
+ if( 8 == pWwFib->nVersion )
+ {
+ DumpDrawObjects( "DrawObjects in Head/Foot",
+ pWwFib->fcPlcfspaHdr, pWwFib->lcbPlcfspaHdr,
+ /*nOffset*/0 );
+ // PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
+ DumpTxtboxBrks( "TextBox-Break-Desk. im Head/Foot",
+ pWwFib->fcPlcfHdrtxbxBkd, pWwFib->lcbPlcfHdrtxbxBkd,
+ nOffset );
+ }
+ else
+ DumpDrawObjects( "DrawObjects in Head/Foot",
+ pWwFib->fcPlcfdoaHdr, pWwFib->lcbPlcfdoaHdr,
+ /*nOffset*/0 );
+}
+
+BOOL ReadEsherRec( SvStream& rStrm, UINT8& rVer, UINT16& rInst,
+ UINT16& rFbt, UINT32& rLength )
+{
+ UINT16 aBits;
+ if( !WW8ReadUINT16( rStrm, aBits ) ) return FALSE;
+ rVer = aBits & 0x000F;
+ rInst = (aBits & 0xFFF0) >> 4;
+ //----------------------------------------------
+ if( !WW8ReadUINT16( rStrm, rFbt ) ) return FALSE;
+ //----------------------------------------------
+ return WW8ReadUINT32( rStrm, rLength );
+}
+
+const char* _GetShapeTypeNm( UINT16 nId )
+{
+ const char* aNmArr[ 202 + 2 + 1 ] = {
+/* 0*/ "NotPrimitive","Rectangle","RoundRectangle","Ellipse","Diamond","IsocelesTriangle","RightTriangle","Parallelogram","Trapezoid","Hexagon",
+/* 10*/ "Octagon","Plus","Star","Arrow","ThickArrow","HomePlate","Cube","Balloon","Seal","Arc",
+/* 20*/ "Line","Plaque","Can","Donut","TextSimple","TextOctagon","TextHexagon","TextCurve","TextWave","TextRing",
+/* 30*/ "TextOnCurve","TextOnRing","StraightConnector1","BentConnector2","BentConnector3","BentConnector4","BentConnector5","CurvedConnector2","CurvedConnector3","CurvedConnector4",
+/* 40*/ "CurvedConnector5","Callout1","Callout2","Callout3","AccentCallout1","AccentCallout2","AccentCallout3","BorderCallout1","BorderCallout2","BorderCallout3",
+/* 50*/ "AccentBorderCallout1","AccentBorderCallout2","AccentBorderCallout3","Ribbon","Ribbon2","Chevron","Pentagon","NoSmoking","Seal8","Seal16",
+/* 60*/ "Seal32","WedgeRectCallout","WedgeRRectCallout","WedgeEllipseCallout","Wave","FoldedCorner","LeftArrow","DownArrow","UpArrow","LeftRightArrow",
+/* 70*/ "UpDownArrow","IrregularSeal1","IrregularSeal2","LightningBolt","Heart","PictureFrame","QuadArrow","LeftArrowCallout","RightArrowCallout","UpArrowCallout",
+/* 80*/ "DownArrowCallout","LeftRightArrowCallout","UpDownArrowCallout","QuadArrowCallout","Bevel","LeftBracket","RightBracket","LeftBrace","RightBrace","LeftUpArrow",
+/* 90*/ "BentUpArrow","BentArrow","Seal24","StripedRightArrow","NotchedRightArrow","BlockArc","SmileyFace","VerticalScroll","HorizontalScroll","CircularArrow",
+/* 100*/ "NotchedCircularArrow","UturnArrow","CurvedRightArrow","CurvedLeftArrow","CurvedUpArrow","CurvedDownArrow","CloudCallout","EllipseRibbon","EllipseRibbon2","FlowChartProcess",
+/* 110*/ "FlowChartDecision","FlowChartInputOutput","FlowChartPredefinedProcess","FlowChartInternalStorage","FlowChartDocument","FlowChartMultidocument","FlowChartTerminator","FlowChartPreparation","FlowChartManualInput","FlowChartManualOperation",
+/* 120*/ "FlowChartConnector","FlowChartPunchedCard","FlowChartPunchedTape","FlowChartSummingJunction","FlowChartOr","FlowChartCollate","FlowChartSort","FlowChartExtract","FlowChartMerge","FlowChartOfflineStorage",
+/* 130*/ "FlowChartOnlineStorage","FlowChartMagneticTape","FlowChartMagneticDisk","FlowChartMagneticDrum","FlowChartDisplay","FlowChartDelay","TextPlainText","TextStop","TextTriangle","TextTriangleInverted",
+/* 140*/ "TextChevron","TextChevronInverted","TextRingInside","TextRingOutside","TextArchUpCurve","TextArchDownCurve","TextCircleCurve","TextButtonCurve","TextArchUpPour","TextArchDownPour",
+/* 150*/ "TextCirclePour","TextButtonPour","TextCurveUp","TextCurveDown","TextCascadeUp","TextCascadeDown","TextWave1","TextWave2","TextWave3","TextWave4",
+/* 160*/ "TextInflate","TextDeflate","TextInflateBottom","TextDeflateBottom","TextInflateTop","TextDeflateTop","TextDeflateInflate","TextDeflateInflateDeflate","TextFadeRight","TextFadeLeft",
+/* 170*/ "TextFadeUp","TextFadeDown","TextSlantUp","TextSlantDown","TextCanUp","TextCanDown","FlowChartAlternateProcess","FlowChartOffpageConnector","Callout90","AccentCallout90",
+/* 180*/ "BorderCallout90","AccentBorderCallout90","LeftRightUpArrow","Sun","Moon","BracketPair","BracePair","Seal4","DoubleWave","ActionButtonBlank",
+/* 190*/ "ActionButtonHome","ActionButtonHelp","ActionButtonInformation","ActionButtonForwardNext","ActionButtonBackPrevious","ActionButtonEnd","ActionButtonBeginning","ActionButtonReturn","ActionButtonDocument","ActionButtonSound",
+/* 200*/ "ActionButtonMovie","HostControl","TextBox","Nil", "???"
+ };
+ if( 203 < nId )
+ nId = 204;
+ return aNmArr[ nId ];
+}
+
+void DumpEscherProp( UINT16 nId, BOOL bBid, BOOL bComplex, UINT32 nOp,
+ UINT32& rStreamOffset )
+{
+ const char* pRecNm = 0;
+ switch( nId )
+ {
+ case 4: pRecNm = "DFF_Prop_Rotation"; break;
+// Protection
+ case 119: pRecNm = "DFF_Prop_LockRotation"; break;
+ case 120: pRecNm = "DFF_Prop_LockAspectRatio"; break;
+ case 121: pRecNm = "DFF_Prop_LockPosition"; break;
+ case 122: pRecNm = "DFF_Prop_LockAgainstSelect"; break;
+ case 123: pRecNm = "DFF_Prop_LockCropping"; break;
+ case 124: pRecNm = "DFF_Prop_LockVertices"; break;
+ case 125: pRecNm = "DFF_Prop_LockText"; break;
+ case 126: pRecNm = "DFF_Prop_LockAdjustHandles"; break;
+ case 127: pRecNm = "DFF_Prop_LockAgainstGrouping"; break;
+// Text
+ case 128: pRecNm = "DFF_Prop_lTxid"; break;
+ case 129: pRecNm = "DFF_Prop_dxTextLeft"; break;
+ case 130: pRecNm = "DFF_Prop_dyTextTop"; break;
+ case 131: pRecNm = "DFF_Prop_dxTextRight"; break;
+ case 132: pRecNm = "DFF_Prop_dyTextBottom"; break;
+ case 133: pRecNm = "DFF_Prop_WrapText"; break;
+ case 134: pRecNm = "DFF_Prop_scaleText"; break;
+ case 135: pRecNm = "DFF_Prop_anchorText"; break;
+ case 136: pRecNm = "DFF_Prop_txflTextFlow"; break;
+ case 137: pRecNm = "DFF_Prop_cdirFont"; break;
+ case 138: pRecNm = "DFF_Prop_hspNext"; break;
+ case 139: pRecNm = "DFF_Prop_txdir"; break;
+ case 187: pRecNm = "DFF_Prop_SelectText"; break;
+ case 188: pRecNm = "DFF_Prop_AutoTextMargin"; break;
+ case 189: pRecNm = "DFF_Prop_RotateText"; break;
+ case 190: pRecNm = "DFF_Prop_FitShapeToText"; break;
+ case 191: pRecNm = "DFF_Prop_FitTextToShape"; break;
+// GeoText
+ case 192: pRecNm = "DFF_Prop_gtextUNICODE"; break;
+ case 193: pRecNm = "DFF_Prop_gtextRTF"; break;
+ case 194: pRecNm = "DFF_Prop_gtextAlign"; break;
+ case 195: pRecNm = "DFF_Prop_gtextSize"; break;
+ case 196: pRecNm = "DFF_Prop_gtextSpacing"; break;
+ case 197: pRecNm = "DFF_Prop_gtextFont"; break;
+ case 240: pRecNm = "DFF_Prop_gtextFReverseRows"; break;
+ case 241: pRecNm = "DFF_Prop_fGtext"; break;
+ case 242: pRecNm = "DFF_Prop_gtextFVertical"; break;
+ case 243: pRecNm = "DFF_Prop_gtextFKern"; break;
+ case 244: pRecNm = "DFF_Prop_gtextFTight"; break;
+ case 245: pRecNm = "DFF_Prop_gtextFStretch"; break;
+ case 246: pRecNm = "DFF_Prop_gtextFShrinkFit"; break;
+ case 247: pRecNm = "DFF_Prop_gtextFBestFit"; break;
+ case 248: pRecNm = "DFF_Prop_gtextFNormalize"; break;
+ case 249: pRecNm = "DFF_Prop_gtextFDxMeasure"; break;
+ case 250: pRecNm = "DFF_Prop_gtextFBold"; break;
+ case 251: pRecNm = "DFF_Prop_gtextFItalic"; break;
+ case 252: pRecNm = "DFF_Prop_gtextFUnderline"; break;
+ case 253: pRecNm = "DFF_Prop_gtextFShadow"; break;
+ case 254: pRecNm = "DFF_Prop_gtextFSmallcaps"; break;
+ case 255: pRecNm = "DFF_Prop_gtextFStrikethrough"; break;
+// Blip
+ case 256: pRecNm = "DFF_Prop_cropFromTop"; break;
+ case 257: pRecNm = "DFF_Prop_cropFromBottom"; break;
+ case 258: pRecNm = "DFF_Prop_cropFromLeft"; break;
+ case 259: pRecNm = "DFF_Prop_cropFromRight"; break;
+ case 260: pRecNm = "DFF_Prop_pib"; break;
+ case 261: pRecNm = "DFF_Prop_pibName"; break;
+ case 262: pRecNm = "DFF_Prop_pibFlags"; break;
+ case 263: pRecNm = "DFF_Prop_pictureTransparent"; break;
+ case 264: pRecNm = "DFF_Prop_pictureContrast"; break;
+ case 265: pRecNm = "DFF_Prop_pictureBrightness"; break;
+ case 266: pRecNm = "DFF_Prop_pictureGamma"; break;
+ case 267: pRecNm = "DFF_Prop_pictureId"; break;
+ case 268: pRecNm = "DFF_Prop_pictureDblCrMod"; break;
+ case 269: pRecNm = "DFF_Prop_pictureFillCrMod"; break;
+ case 270: pRecNm = "DFF_Prop_pictureLineCrMod"; break;
+ case 271: pRecNm = "DFF_Prop_pibPrint"; break;
+ case 272: pRecNm = "DFF_Prop_pibPrintName"; break;
+ case 273: pRecNm = "DFF_Prop_pibPrintFlags"; break;
+ case 316: pRecNm = "DFF_Prop_fNoHitTestPicture"; break;
+ case 317: pRecNm = "DFF_Prop_pictureGray"; break;
+ case 318: pRecNm = "DFF_Prop_pictureBiLevel"; break;
+ case 319: pRecNm = "DFF_Prop_pictureActive"; break;
+// Geometry
+ case 320: pRecNm = "DFF_Prop_geoLeft"; break;
+ case 321: pRecNm = "DFF_Prop_geoTop"; break;
+ case 322: pRecNm = "DFF_Prop_geoRight"; break;
+ case 323: pRecNm = "DFF_Prop_geoBottom"; break;
+ case 324: pRecNm = "DFF_Prop_shapePath"; break;
+ case 325: pRecNm = "DFF_Prop_pVertices"; break;
+ case 326: pRecNm = "DFF_Prop_pSegmentInfo"; break;
+ case 327: pRecNm = "DFF_Prop_adjustValue"; break;
+ case 328: pRecNm = "DFF_Prop_adjust2Value"; break;
+ case 329: pRecNm = "DFF_Prop_adjust3Value"; break;
+ case 330: pRecNm = "DFF_Prop_adjust4Value"; break;
+ case 331: pRecNm = "DFF_Prop_adjust5Value"; break;
+ case 332: pRecNm = "DFF_Prop_adjust6Value"; break;
+ case 333: pRecNm = "DFF_Prop_adjust7Value"; break;
+ case 334: pRecNm = "DFF_Prop_adjust8Value"; break;
+ case 335: pRecNm = "DFF_Prop_adjust9Value"; break;
+ case 336: pRecNm = "DFF_Prop_adjust10Value"; break;
+ case 378: pRecNm = "DFF_Prop_fShadowOK"; break;
+ case 379: pRecNm = "DFF_Prop_f3DOK"; break;
+ case 380: pRecNm = "DFF_Prop_fLineOK"; break;
+ case 381: pRecNm = "DFF_Prop_fGtextOK"; break;
+ case 382: pRecNm = "DFF_Prop_fFillShadeShapeOK"; break;
+ case 383: pRecNm = "DFF_Prop_fFillOK"; break;
+// FillStyle
+ case 384: pRecNm = "DFF_Prop_fillType"; break;
+ case 385: pRecNm = "DFF_Prop_fillColor"; break;
+ case 386: pRecNm = "DFF_Prop_fillOpacity"; break;
+ case 387: pRecNm = "DFF_Prop_fillBackColor"; break;
+ case 388: pRecNm = "DFF_Prop_fillBackOpacity"; break;
+ case 389: pRecNm = "DFF_Prop_fillCrMod"; break;
+ case 390: pRecNm = "DFF_Prop_fillBlip"; break;
+ case 391: pRecNm = "DFF_Prop_fillBlipName"; break;
+ case 392: pRecNm = "DFF_Prop_fillBlipFlags"; break;
+ case 393: pRecNm = "DFF_Prop_fillWidth"; break;
+ case 394: pRecNm = "DFF_Prop_fillHeight"; break;
+ case 395: pRecNm = "DFF_Prop_fillAngle"; break;
+ case 396: pRecNm = "DFF_Prop_fillFocus"; break;
+ case 397: pRecNm = "DFF_Prop_fillToLeft"; break;
+ case 398: pRecNm = "DFF_Prop_fillToTop"; break;
+ case 399: pRecNm = "DFF_Prop_fillToRight"; break;
+ case 400: pRecNm = "DFF_Prop_fillToBottom"; break;
+ case 401: pRecNm = "DFF_Prop_fillRectLeft"; break;
+ case 402: pRecNm = "DFF_Prop_fillRectTop"; break;
+ case 403: pRecNm = "DFF_Prop_fillRectRight"; break;
+ case 404: pRecNm = "DFF_Prop_fillRectBottom"; break;
+ case 405: pRecNm = "DFF_Prop_fillDztype"; break;
+ case 406: pRecNm = "DFF_Prop_fillShadePreset"; break;
+ case 407: pRecNm = "DFF_Prop_fillShadeColors"; break;
+ case 408: pRecNm = "DFF_Prop_fillOriginX"; break;
+ case 409: pRecNm = "DFF_Prop_fillOriginY"; break;
+ case 410: pRecNm = "DFF_Prop_fillShapeOriginX"; break;
+ case 411: pRecNm = "DFF_Prop_fillShapeOriginY"; break;
+ case 412: pRecNm = "DFF_Prop_fillShadeType"; break;
+ case 443: pRecNm = "DFF_Prop_fFilled"; break;
+ case 444: pRecNm = "DFF_Prop_fHitTestFill"; break;
+ case 445: pRecNm = "DFF_Prop_fillShape"; break;
+ case 446: pRecNm = "DFF_Prop_fillUseRect"; break;
+ case 447: pRecNm = "DFF_Prop_fNoFillHitTest"; break;
+// LineStyle
+ case 448: pRecNm = "DFF_Prop_lineColor"; break;
+ case 449: pRecNm = "DFF_Prop_lineOpacity"; break;
+ case 450: pRecNm = "DFF_Prop_lineBackColor"; break;
+ case 451: pRecNm = "DFF_Prop_lineCrMod"; break;
+ case 452: pRecNm = "DFF_Prop_lineType"; break;
+ case 453: pRecNm = "DFF_Prop_lineFillBlip"; break;
+ case 454: pRecNm = "DFF_Prop_lineFillBlipName"; break;
+ case 455: pRecNm = "DFF_Prop_lineFillBlipFlags"; break;
+ case 456: pRecNm = "DFF_Prop_lineFillWidth"; break;
+ case 457: pRecNm = "DFF_Prop_lineFillHeight"; break;
+ case 458: pRecNm = "DFF_Prop_lineFillDztype"; break;
+ case 459: pRecNm = "DFF_Prop_lineWidth"; break;
+ case 460: pRecNm = "DFF_Prop_lineMiterLimit"; break;
+ case 461: pRecNm = "DFF_Prop_lineStyle"; break;
+ case 462: pRecNm = "DFF_Prop_lineDashing"; break;
+ case 463: pRecNm = "DFF_Prop_lineDashStyle"; break;
+ case 464: pRecNm = "DFF_Prop_lineStartArrowhead"; break;
+ case 465: pRecNm = "DFF_Prop_lineEndArrowhead"; break;
+ case 466: pRecNm = "DFF_Prop_lineStartArrowWidth"; break;
+ case 467: pRecNm = "DFF_Prop_lineStartArrowLength"; break;
+ case 468: pRecNm = "DFF_Prop_lineEndArrowWidth"; break;
+ case 469: pRecNm = "DFF_Prop_lineEndArrowLength"; break;
+ case 470: pRecNm = "DFF_Prop_lineJoinStyle"; break;
+ case 471: pRecNm = "DFF_Prop_lineEndCapStyle"; break;
+ case 507: pRecNm = "DFF_Prop_fArrowheadsOK"; break;
+ case 508: pRecNm = "DFF_Prop_fLine"; break;
+ case 509: pRecNm = "DFF_Prop_fHitTestLine"; break;
+ case 510: pRecNm = "DFF_Prop_lineFillShape"; break;
+ case 511: pRecNm = "DFF_Prop_fNoLineDrawDash"; break;
+// ShadowStyle
+ case 512: pRecNm = "DFF_Prop_shadowType"; break;
+ case 513: pRecNm = "DFF_Prop_shadowColor"; break;
+ case 514: pRecNm = "DFF_Prop_shadowHighlight"; break;
+ case 515: pRecNm = "DFF_Prop_shadowCrMod"; break;
+ case 516: pRecNm = "DFF_Prop_shadowOpacity"; break;
+ case 517: pRecNm = "DFF_Prop_shadowOffsetX"; break;
+ case 518: pRecNm = "DFF_Prop_shadowOffsetY"; break;
+ case 519: pRecNm = "DFF_Prop_shadowSecondOffsetX"; break;
+ case 520: pRecNm = "DFF_Prop_shadowSecondOffsetY"; break;
+ case 521: pRecNm = "DFF_Prop_shadowScaleXToX"; break;
+ case 522: pRecNm = "DFF_Prop_shadowScaleYToX"; break;
+ case 523: pRecNm = "DFF_Prop_shadowScaleXToY"; break;
+ case 524: pRecNm = "DFF_Prop_shadowScaleYToY"; break;
+ case 525: pRecNm = "DFF_Prop_shadowPerspectiveX"; break;
+ case 526: pRecNm = "DFF_Prop_shadowPerspectiveY"; break;
+ case 527: pRecNm = "DFF_Prop_shadowWeight"; break;
+ case 528: pRecNm = "DFF_Prop_shadowOriginX"; break;
+ case 529: pRecNm = "DFF_Prop_shadowOriginY"; break;
+ case 574: pRecNm = "DFF_Prop_fShadow"; break;
+ case 575: pRecNm = "DFF_Prop_fshadowObscured"; break;
+// PerspectiveStyle
+ case 576: pRecNm = "DFF_Prop_perspectiveType"; break;
+ case 577: pRecNm = "DFF_Prop_perspectiveOffsetX"; break;
+ case 578: pRecNm = "DFF_Prop_perspectiveOffsetY"; break;
+ case 579: pRecNm = "DFF_Prop_perspectiveScaleXToX"; break;
+ case 580: pRecNm = "DFF_Prop_perspectiveScaleYToX"; break;
+ case 581: pRecNm = "DFF_Prop_perspectiveScaleXToY"; break;
+ case 582: pRecNm = "DFF_Prop_perspectiveScaleYToY"; break;
+ case 583: pRecNm = "DFF_Prop_perspectivePerspectiveX"; break;
+ case 584: pRecNm = "DFF_Prop_perspectivePerspectiveY"; break;
+ case 585: pRecNm = "DFF_Prop_perspectiveWeight"; break;
+ case 586: pRecNm = "DFF_Prop_perspectiveOriginX"; break;
+ case 587: pRecNm = "DFF_Prop_perspectiveOriginY"; break;
+ case 639: pRecNm = "DFF_Prop_fPerspective"; break;
+// 3D Object
+ case 640: pRecNm = "DFF_Prop_c3DSpecularAmt"; break;
+ case 641: pRecNm = "DFF_Prop_c3DDiffuseAmt"; break;
+ case 642: pRecNm = "DFF_Prop_c3DShininess"; break;
+ case 643: pRecNm = "DFF_Prop_c3DEdgeThickness"; break;
+ case 644: pRecNm = "DFF_Prop_c3DExtrudeForward"; break;
+ case 645: pRecNm = "DFF_Prop_c3DExtrudeBackward"; break;
+ case 646: pRecNm = "DFF_Prop_c3DExtrudePlane"; break;
+ case 647: pRecNm = "DFF_Prop_c3DExtrusionColor"; break;
+ case 648: pRecNm = "DFF_Prop_c3DCrMod"; break;
+ case 700: pRecNm = "DFF_Prop_f3D"; break;
+ case 701: pRecNm = "DFF_Prop_fc3DMetallic"; break;
+ case 702: pRecNm = "DFF_Prop_fc3DUseExtrusionColor"; break;
+ case 703: pRecNm = "DFF_Prop_fc3DLightFace"; break;
+// 3D Style
+ case 704: pRecNm = "DFF_Prop_c3DYRotationAngle"; break;
+ case 705: pRecNm = "DFF_Prop_c3DXRotationAngle"; break;
+ case 706: pRecNm = "DFF_Prop_c3DRotationAxisX"; break;
+ case 707: pRecNm = "DFF_Prop_c3DRotationAxisY"; break;
+ case 708: pRecNm = "DFF_Prop_c3DRotationAxisZ"; break;
+ case 709: pRecNm = "DFF_Prop_c3DRotationAngle"; break;
+ case 710: pRecNm = "DFF_Prop_c3DRotationCenterX"; break;
+ case 711: pRecNm = "DFF_Prop_c3DRotationCenterY"; break;
+ case 712: pRecNm = "DFF_Prop_c3DRotationCenterZ"; break;
+ case 713: pRecNm = "DFF_Prop_c3DRenderMode"; break;
+ case 714: pRecNm = "DFF_Prop_c3DTolerance"; break;
+ case 715: pRecNm = "DFF_Prop_c3DXViewpoint"; break;
+ case 716: pRecNm = "DFF_Prop_c3DYViewpoint"; break;
+ case 717: pRecNm = "DFF_Prop_c3DZViewpoint"; break;
+ case 718: pRecNm = "DFF_Prop_c3DOriginX"; break;
+ case 719: pRecNm = "DFF_Prop_c3DOriginY"; break;
+ case 720: pRecNm = "DFF_Prop_c3DSkewAngle"; break;
+ case 721: pRecNm = "DFF_Prop_c3DSkewAmount"; break;
+ case 722: pRecNm = "DFF_Prop_c3DAmbientIntensity"; break;
+ case 723: pRecNm = "DFF_Prop_c3DKeyX"; break;
+ case 724: pRecNm = "DFF_Prop_c3DKeyY"; break;
+ case 725: pRecNm = "DFF_Prop_c3DKeyZ"; break;
+ case 726: pRecNm = "DFF_Prop_c3DKeyIntensity"; break;
+ case 727: pRecNm = "DFF_Prop_c3DFillX"; break;
+ case 728: pRecNm = "DFF_Prop_c3DFillY"; break;
+ case 729: pRecNm = "DFF_Prop_c3DFillZ"; break;
+ case 730: pRecNm = "DFF_Prop_c3DFillIntensity"; break;
+ case 763: pRecNm = "DFF_Prop_fc3DConstrainRotation"; break;
+ case 764: pRecNm = "DFF_Prop_fc3DRotationCenterAuto"; break;
+ case 765: pRecNm = "DFF_Prop_fc3DParallel"; break;
+ case 766: pRecNm = "DFF_Prop_fc3DKeyHarsh"; break;
+ case 767: pRecNm = "DFF_Prop_fc3DFillHarsh"; break;
+// Shape
+ case 769: pRecNm = "DFF_Prop_hspMaster"; break;
+ case 771: pRecNm = "DFF_Prop_cxstyle"; break;
+ case 772: pRecNm = "DFF_Prop_bWMode"; break;
+ case 773: pRecNm = "DFF_Prop_bWModePureBW"; break;
+ case 774: pRecNm = "DFF_Prop_bWModeBW"; break;
+ case 826: pRecNm = "DFF_Prop_fOleIcon"; break;
+ case 827: pRecNm = "DFF_Prop_fPreferRelativeResize"; break;
+ case 828: pRecNm = "DFF_Prop_fLockShapeType"; break;
+ case 830: pRecNm = "DFF_Prop_fDeleteAttachedObject"; break;
+ case 831: pRecNm = "DFF_Prop_fBackground"; break;
+
+// Callout
+ case 832: pRecNm = "DFF_Prop_spcot"; break;
+ case 833: pRecNm = "DFF_Prop_dxyCalloutGap"; break;
+ case 834: pRecNm = "DFF_Prop_spcoa"; break;
+ case 835: pRecNm = "DFF_Prop_spcod"; break;
+ case 836: pRecNm = "DFF_Prop_dxyCalloutDropSpecified"; break;
+ case 837: pRecNm = "DFF_Prop_dxyCalloutLengthSpecified"; break;
+ case 889: pRecNm = "DFF_Prop_fCallout"; break;
+ case 890: pRecNm = "DFF_Prop_fCalloutAccentBar"; break;
+ case 891: pRecNm = "DFF_Prop_fCalloutTextBorder"; break;
+ case 892: pRecNm = "DFF_Prop_fCalloutMinusX"; break;
+ case 893: pRecNm = "DFF_Prop_fCalloutMinusY"; break;
+ case 894: pRecNm = "DFF_Prop_fCalloutDropAuto"; break;
+ case 895: pRecNm = "DFF_Prop_fCalloutLengthSpecified"; break;
+
+// GroupShape
+ case 896: pRecNm = "DFF_Prop_wzName"; break;
+ case 897: pRecNm = "DFF_Prop_wzDescription"; break;
+ case 898: pRecNm = "DFF_Prop_pihlShape"; break;
+ case 899: pRecNm = "DFF_Prop_pWrapPolygonVertices"; break;
+ case 900: pRecNm = "DFF_Prop_dxWrapDistLeft"; break;
+ case 901: pRecNm = "DFF_Prop_dyWrapDistTop"; break;
+ case 902: pRecNm = "DFF_Prop_dxWrapDistRight"; break;
+ case 903: pRecNm = "DFF_Prop_dyWrapDistBottom"; break;
+ case 904: pRecNm = "DFF_Prop_lidRegroup"; break;
+ case 953: pRecNm = "DFF_Prop_fEditedWrap"; break;
+ case 954: pRecNm = "DFF_Prop_fBehindDocument"; break;
+ case 955: pRecNm = "DFF_Prop_fOnDblClickNotify"; break;
+ case 956: pRecNm = "DFF_Prop_fIsButton"; break;
+ case 957: pRecNm = "DFF_Prop_fOneD"; break;
+ case 958: pRecNm = "DFF_Prop_fHidden"; break;
+ case 959: pRecNm = "DFF_Prop_fPrint"; break;
+ }
+
+ *pOut << " " << indent1 << ' ';
+ if( pRecNm )
+ *pOut << pRecNm;
+ else
+ *pOut << "Prop" ;
+
+ *pOut << " Id: " << dec << nId << " (=0x" << hex << nId << ')';
+ if( bBid )
+ *pOut << " Bid: 0x" << (UINT16)bBid;
+
+ if( bComplex )
+ {
+ *pOut << " Cmpl: 0x" << (UINT16)bComplex;
+ // ....
+ rStreamOffset += nOp;
+ }
+// else
+ *pOut << " op: 0x" << nOp;
+
+ *pOut << dec << endl1;
+}
+
+void DumpEscherRec( ULONG nPos, UINT8 nVer, UINT16 nInst,
+ UINT16 nFbt, UINT32 nLength )
+{
+ const char* pRecNm = 0;
+ switch( nFbt )
+ {
+ case 0xF000: pRecNm = "DFF_msofbtDggContainer"; break;
+ case 0xF006: pRecNm = "DFF_msofbtDgg"; break;
+ case 0xF016: pRecNm = "DFF_msofbtCLSID"; break;
+ case 0xF00B: pRecNm = "DFF_msofbtOPT"; break;
+ case 0xF11A: pRecNm = "DFF_msofbtColorMRU"; break;
+ case 0xF11E: pRecNm = "DFF_msofbtSplitMenuColors"; break;
+ case 0xF001: pRecNm = "DFF_msofbtBstoreContainer"; break;
+ case 0xF007: pRecNm = "DFF_msofbtBSE"; break;
+ case 0xF018: pRecNm = "DFF_msofbtBlipFirst"; break;
+ case 0xF117: pRecNm = "DFF_msofbtBlipLast"; break;
+ case 0xF002: pRecNm = "DFF_msofbtDgContainer"; break;
+ case 0xF008: pRecNm = "DFF_msofbtDg"; break;
+ case 0xF118: pRecNm = "DFF_msofbtRegroupItems"; break;
+ case 0xF120: pRecNm = "DFF_msofbtColorScheme"; break;
+ case 0xF003: pRecNm = "DFF_msofbtSpgrContainer"; break;
+ case 0xF004: pRecNm = "DFF_msofbtSpContainer"; break;
+ case 0xF009: pRecNm = "DFF_msofbtSpgr"; break;
+ case 0xF00A: pRecNm = "DFF_msofbtSp"; break;
+ case 0xF00C: pRecNm = "DFF_msofbtTextbox"; break;
+ case 0xF00D: pRecNm = "DFF_msofbtClientTextbox"; break;
+ case 0xF00E: pRecNm = "DFF_msofbtAnchor"; break;
+ case 0xF00F: pRecNm = "DFF_msofbtChildAnchor"; break;
+ case 0xF010: pRecNm = "DFF_msofbtClientAnchor"; break;
+ case 0xF011: pRecNm = "DFF_msofbtClientData"; break;
+ case 0xF11F: pRecNm = "DFF_msofbtOleObject"; break;
+ case 0xF11D: pRecNm = "DFF_msofbtDeletedPspl"; break;
+ case 0xF005: pRecNm = "DFF_msofbtSolverContainer"; break;
+ case 0xF012: pRecNm = "DFF_msofbtConnectorRule"; break;
+ case 0xF013: pRecNm = "DFF_msofbtAlignRule"; break;
+ case 0xF014: pRecNm = "DFF_msofbtArcRule"; break;
+ case 0xF015: pRecNm = "DFF_msofbtClientRule"; break;
+ case 0xF017: pRecNm = "DFF_msofbtCalloutRule"; break;
+ }
+
+ *pOut << hex6 << nPos << indent1;
+ if( pRecNm )
+ *pOut << pRecNm;
+ else
+ *pOut << "Record:";
+ *pOut << " Id: 0x" << hex << nFbt << " Instance: 0x" << nInst
+ << " Version: 0x" << (UINT16)nVer << " Laenge: 0x" << nLength
+ << dec << endl1;
+
+ switch( nFbt )
+ {
+ case 0xf00b: // DFF_msofbtOPT
+ {
+ UINT16 nId; UINT32 nOp, nStreamOffset = nInst * 6;
+ BOOL bBid, bComplex;
+ for( UINT16 n = 0; n < nInst; ++n )
+ {
+ if( !WW8ReadUINT16( *xTableStream, nId ) ||
+ !WW8ReadUINT32( *xTableStream, nOp ))
+ break;
+ bBid = ( nId >> 14 ) & 1;
+ bComplex = ( nId >> 15 ) & 1;
+ nId &= 0x3fff;
+
+ ::DumpEscherProp( nId, bBid, bComplex, nOp, nStreamOffset );
+ }
+ }
+ break;
+
+ case 0xF00d: // DFF_msofbtClientTextbox
+ case 0xF010: // DFF_msofbtClientAnchor
+ case 0xF011: // DFF_msofbtClientData
+ {
+ UINT32 nData;
+ if( 4 == nLength && WW8ReadUINT32( *xTableStream, nData ))
+ *pOut << " " << indent1 << " Data: "
+ << hex << nData << dec << endl1;
+ }
+ break;
+
+ case 0xf00a: // DFF_msofbtSp
+ {
+ UINT32 nId, nData;
+ if( WW8ReadUINT32( *xTableStream, nId ) &&
+ WW8ReadUINT32( *xTableStream, nData ))
+ {
+ *pOut << " " << indent1 << " \""
+ << _GetShapeTypeNm( nInst )
+ << "\" Id: 0x" << hex << nId
+ << " Flags: 0x" << nData << dec << endl1;
+ }
+ }
+ break;
+
+ case 0xf009: // DFF_msofbtSpgr
+ case 0xf00f: // DFF_msofbtChildAnchor
+ {
+ UINT32 nL, nT, nR, nB;
+ if( WW8ReadUINT32( *xTableStream, nL ) &&
+ WW8ReadUINT32( *xTableStream, nT ) &&
+ WW8ReadUINT32( *xTableStream, nR ) &&
+ WW8ReadUINT32( *xTableStream, nB ) )
+ {
+ *pOut << " " << indent1 << " Rect: (L/T/R/B): " << dec
+ << nL << '/' << nT << '/' << nR << '/' << nB << endl;
+ }
+ }
+ break;
+
+ case 0xf006: //ESCHER_Dgg
+ {
+ UINT32 spidMax, // The current maximum shape ID
+ cidcl, // The number of ID clusters (FIDCLs)
+ cspSaved, // The total number of shapes saved
+ // (including deleted shapes, if undo
+ // information was saved)
+ cdgSaved; // The total number of drawings saved
+
+ if( WW8ReadUINT32( *xTableStream, spidMax ) &&
+ WW8ReadUINT32( *xTableStream, cidcl ) &&
+ WW8ReadUINT32( *xTableStream, cspSaved ) &&
+ WW8ReadUINT32( *xTableStream, cdgSaved ))
+ {
+ *pOut << " " << indent1 << " " << hex
+ << " spidMax: 0x" << spidMax
+ << " cidcl: 0x" << cidcl
+ << " cspSaved: 0x" << cspSaved
+ << " cdgSaved: 0x" << cdgSaved
+ << dec << endl1;
+
+
+ UINT32 dgid, // DG owning the SPIDs in this cluster
+ cspidCur; // number of SPIDs used so far
+
+ for( UINT32 n = 1; n < cidcl; ++n )
+ {
+ if( !WW8ReadUINT32( *xTableStream, dgid ) ||
+ !WW8ReadUINT32( *xTableStream, cspidCur ))
+ break;
+
+ *pOut << " " << indent1 << " " << hex
+ << " dgid: 0x" << dgid
+ << " cspidCur: 0x" << cspidCur
+ << dec << endl1;
+ }
+ }
+ }
+ break;
+
+ case 0xF016: //ESCHER_CLSID
+ case 0xF11A: //ESCHER_ColorMRU
+ case 0xF11E: //ESCHER_SplitMenuColors
+// case 0xF001: //ESCHER_BstoreContainer
+ case 0xF007: //ESCHER_BSE
+ case 0xF018: //ESCHER_BlipFirst
+ case 0xF117: //ESCHER_BlipLast
+ case 0xF118: //ESCHER_RegroupItems
+ case 0xF120: //ESCHER_ColorScheme
+ case 0xF00C: //ESCHER_Textbox
+ case 0xF00E: //ESCHER_Anchor
+ case 0xF11F: //ESCHER_OleObject
+ case 0xF11D: //ESCHER_DeletedPspl
+ case 0xF005: //ESCHER_SolverContainer
+ case 0xF012: //ESCHER_ConnectorRule
+ case 0xF013: //ESCHER_AlignRule
+ case 0xF014: //ESCHER_ArcRule
+ case 0xF015: //ESCHER_ClientRule
+ case 0xF017: //ESCHER_CalloutRule
+ case 0xF119: //ESCHER_Selection
+ case 0xf008: //ESCHER_Dg
+ {
+ int nCnt = 128;
+ while( nLength )
+ {
+ if( 128 == nCnt || 16 == ++nCnt )
+ {
+ if( 128 != nCnt )
+ *pOut << endl1;
+ *pOut << " " << indent1 << " Data: ";
+ nCnt = 0;
+ }
+
+ static char __READONLY_DATA sHex[17] = { "0123456789abcdef" };
+ BYTE c;
+ *xTableStream >> c;
+ *pOut << sHex[ ( c & 0xf0 ) >> 4 ] << sHex[ c & 0x0f ] << ' ';
+ --nLength;
+ }
+ *pOut << dec << endl1;
+ }
+ break;
+ }
+
+
+}
+
+
+void DumpEscherRecs( ULONG nPos, UINT32 nLength )
+{
+ begin( *pOut, *xTableStream ) << endl1;
+
+ UINT16 nOldFbt = 0;
+ ULONG nReadLen = 0;
+ while( nReadLen < nLength )
+ {
+ UINT8 nVer;
+ UINT16 nInst, nFbt;
+ UINT32 nRecLen;
+
+ if( !::ReadEsherRec( *xTableStream, nVer, nInst, nFbt, nRecLen ))
+ break;
+
+ if( !( 0xf000 <= nFbt && nFbt <= 0xf120 ))
+ {
+ xTableStream->Seek( nPos + nReadLen );
+ unsigned char c;
+ *xTableStream >> c;
+
+ ++nReadLen;
+ if( !::ReadEsherRec( *xTableStream, nVer, nInst, nFbt, nRecLen )
+ || !( 0xf000 <= nFbt && nFbt <= 0xf120 ) )
+ break;
+
+ *pOut << hex6 << nPos + nReadLen - 1 << indent1
+ << "DummyChar: 0x" << hex << (int)c << dec << endl1;
+ }
+
+ ::DumpEscherRec( nPos + nReadLen, nVer, nInst,
+ nFbt, nRecLen );
+
+ nReadLen += 2 * sizeof( UINT32 );
+ switch( nFbt )
+ {
+ case 0xF000:
+ case 0xF001: //ESCHER_BstoreContainer
+ case 0xF002:
+ case 0xF003:
+ case 0xF004:
+ DumpEscherRecs( nPos + nReadLen, nRecLen );
+ break;
+ }
+
+ nReadLen += nRecLen;
+ xTableStream->Seek( nPos + nReadLen );
+ nOldFbt = nFbt;
+ }
+ end( *pOut, *xTableStream ) << endl1;
+}
+
+
+void DumpDrawing()
+{
+ if( pWwFib->lcbDggInfo )
+ {
+ ULONG nOldPos = xTableStream->Tell(), nReadLen = 0;
+ xTableStream->Seek( pWwFib->fcDggInfo );
+
+ *pOut << endl << hex6 << pWwFib->fcDggInfo << dec2 << ' ' << indent1
+ << begin1 << "Escher (DggInfo): Len: " << pWwFib->lcbDggInfo
+ << endl1;
+
+ ::DumpEscherRecs( pWwFib->fcDggInfo, (ULONG)pWwFib->lcbDggInfo );
+
+ end( *pOut, *xTableStream ) << endl1 << endl1;
+ xTableStream->Seek( nOldPos );
+ }
+}
+
+
+//-----------------------------------------
+// Hilfroutinen fuer Styles
+//-----------------------------------------
+
+static short DumpStyleUPX( BYTE nVersion, short nLen, BOOL bPAP )
+{
+ short cbUPX;
+ BOOL bEmpty;
+
+
+ if( nLen <= 0 ){
+ indent( *pOut, *xTableStream );
+ *pOut << "very empty UPX." << ((bPAP) ? "papx " : "chpx ");
+ *pOut << "Len:" << nLen << endl1;
+ return nLen;
+ }
+
+ nLen -= WW8SkipOdd( &xTableStream );
+ indent( *pOut, *xTableStream );
+
+ xTableStream->Read( &cbUPX, 2 );
+ nLen-= 2;
+
+ if ( cbUPX > nLen )
+ {
+ *pOut << "!cbUPX auf nLen verkleinert! ";
+ cbUPX = nLen;
+ }
+
+ bEmpty = ( cbUPX <= 0 ) || ( bPAP && ( cbUPX <= 2 ) );
+
+ if ( bEmpty )
+ *pOut << "empty ";
+ else
+ *pOut << begin1;
+
+ *pOut << "UPX." << ((bPAP) ? "papx " : "chpx ");
+ *pOut << "Len:" << nLen << " cbUPX:" << cbUPX << ' ';
+
+ if( bPAP )
+ {
+ USHORT id;
+
+ xTableStream->Read( &id, 2 );
+ cbUPX-= 2;
+ nLen-= 2;
+ *pOut << "ID:" << id;
+ }
+
+ *pOut << endl1;
+
+ ULONG nPos = xTableStream->Tell(); // falls etwas falsch interpretiert
+ // wird, gehts danach wieder richtig
+ DumpSprms( nVersion, *xTableStream, cbUPX );
+
+ if ( xTableStream->Tell() != nPos + cbUPX ){
+ *pOut << "!Um " << xTableStream->Tell() - nPos + cbUPX
+ << " Bytes falsch positioniert!" << endl1;
+ xTableStream->Seek( nPos+cbUPX );
+ }
+
+ nLen -= cbUPX;
+
+ if ( !bEmpty )
+ end( *pOut, *xTableStream ) << "UPX." << ((bPAP) ? "papx " : "chpx ") << endl1;
+
+ return nLen;
+}
+
+static void DumpStyleGrupx( BYTE nVersion, short nLen, BOOL bPara )
+{
+ if( nLen <= 0 )
+ return;
+ nLen -= WW8SkipOdd( &xTableStream );
+
+ begin( *pOut, *xTableStream ) << "Grupx, Len:" << nLen << endl1;
+
+ if( bPara ) nLen = DumpStyleUPX( nVersion, nLen, TRUE ); // Grupx.Papx
+ DumpStyleUPX( nVersion, nLen, FALSE ); // Grupx.Chpx
+
+ end( *pOut, *xTableStream ) << "Grupx" << endl1;
+}
+
+static void PrintStyleId( USHORT nId )
+{
+ switch ( nId ){
+ case 0xffe: *pOut << "User "; break;
+ case 0xfff: *pOut << "Nil "; break;
+ default: *pOut << nId << ' '; break;
+ }
+}
+
+//-----------------------------------------
+// Styles
+//-----------------------------------------
+
+void DStyle::Dump1Style( USHORT nNr )
+{
+ short nSkip, cbStd;
+ BYTE* pStr;
+ char c;
+ indent( *pOut, *xTableStream );
+
+ WW8_STD* pStd = Read1Style( nSkip, &pStr, &cbStd ); // lese Style
+
+ if ( pStr ){ // echter Style
+ *pOut << begin1;
+ switch ( pStd->sgc ){
+ case 1: c = 'P'; break;
+ case 2: c = 'C'; break;
+ default: c = '?'; break;
+ }
+ *pOut << c << "-Style Nr:" << nNr << ' ';
+ *pOut << "ID:"; PrintStyleId( pStd->sti );
+ *pOut << "BasedOn:"; PrintStyleId( pStd->istdBase );
+ *pOut << "Next:" << pStd->istdNext << " Name:\"" << &pStr[1] << "\"";
+ *pOut << endl1 << " ";
+ *pOut << "cbStd:" << cbStd << ' ';
+ *pOut << "No of Upx & Upe:" << pStd->cupx << ' ';
+ *pOut << "bchUpe:" << pStd->bchUpe << ' ';
+ *pOut << "nSkip:" << nSkip << endl1;
+ }else{ // leerer Slot
+ *pOut << "empty Slot Nr:" << nNr << endl1;
+ }
+
+ long nPos = xTableStream->Tell(); // falls etwas falsch interpretiert
+ // wird, gehts danach wieder richtig
+
+ if( pStd && ( pStd->sgc == 1 || pStd->sgc == 2 ) )
+ DumpStyleGrupx( nVersion, nSkip, pStd->sgc == 1 );
+
+ if ( pStr ) // echter Style
+ end( *pOut, *xTableStream ) << c << "-Style" << endl1;
+
+ xTableStream->Seek( nPos+nSkip );
+
+ DELETEZ( pStr );
+ DELETEZ( pStd );
+}
+
+void DStyle::Dump()
+{
+ *pOut << hex6 << nStyleStart << ' ' << dec2 << indent1;
+
+ *pOut << begin1 << cstd << " Styles, ";
+ *pOut << "Base:" << cbSTDBaseInFile;
+ *pOut << ", Written:" << (fStdStylenamesWritten) ? 'T' : 'F';
+ *pOut << ", MaxSti:" << stiMaxWhenSaved;
+ *pOut << ", MaxFix:" << istdMaxFixedWhenSaved;
+ *pOut << ", BuildIn:" << nVerBuiltInNamesWhenSaved;
+ *pOut << ", StdFnt:" << ftcStandardChpStsh << endl1;
+
+ USHORT i;
+ for( i=0; i<cstd; i++ )
+ Dump1Style( i );
+
+ end( *pOut, *xTableStream ) << "Styles" << endl1 << endl1;
+}
+
+//-----------------------------------------
+// Main
+//-----------------------------------------
+
+//char cName [266];
+//char cOutName [266];
+
+int PrepareConvert( String& rName, String& rOutName, String& rMess )
+{
+#if 0
+ if( argc < 2 ) {
+ rMess += "Aufruf: Dump8 InFile [OutFile [StorFile] ] ";
+ return 1;
+ }else{
+ strncpy( cName, *++argv, sizeof( cName )-5 );
+ }
+ if( !strchr( cName, '.' ) )
+ strcat( cName, ".DOC" );
+
+ if( argc >= 3 ){
+ strncpy( cOutName, *++argv, sizeof( cOutName ) );
+ }else{
+ strncpy( cOutName, cName, sizeof( cOutName ) );
+ char* p = strchr( cOutName, '.' );
+ *p = 0;
+ strcat( cOutName, ".DMP" );
+ }
+#endif
+ if( access( rName.GetStr(), 0 ) ){
+ rMess += "Kann ";
+ rMess += rName;
+ rMess += " nicht oeffnen";
+ return 1;
+ }
+
+ pxStor = new SvStorageRef( new SvStorage( rName, STREAM_STD_READ ) );
+ xStrm = (*pxStor)->OpenStream( String( "WordDocument" ), STREAM_STD_READ );
+
+ if ( !xStrm.Is() /* || xStrm->GetError() */ ){
+ rMess += "Kann StorageStream \"WordDocument\" in ";
+ rMess += rName;
+ rMess += " nicht zum Lesen oeffnen";
+ DELETEZ( pxStor );
+ return 1;
+ }
+
+ ULONG nL;
+ if ( xStrm->Read( &nL, sizeof( nL ) ) == 0 ){
+ rMess += "Kann aus StorageStream \"WordDocument\" in ";
+ rMess += rName;
+ rMess += " nicht Lesen";
+ return 1;
+ }
+ xStrm->Seek( 0 );
+
+ pOut = new fstream( rOutName, ios::out );
+ if ( !pOut ){
+ rMess += "Kann Ausgabedatei ";
+ rMess += rOutName;
+ rMess += " nicht zum Schreiben oeffnen";
+ return 1;
+ }
+
+#if 0 // erstmal raus wg. Umstellung
+ if( argc > 3 ) {
+ char StorName[266];
+ strncpy( StorName, *++argv, sizeof( StorName )-5 );
+
+ if( !strchr( StorName, '.' ) )
+ strcat( StorName, ".STO" );
+
+ SvFileStream aStrm( StorName, STREAM_WRITE|STREAM_TRUNC );
+ aStrm << *xStrm;
+
+// fstream aOut2( StorName, ios::out );
+// aOut2 << *xStrm;
+
+ xStrm->Seek( 0 );
+ }
+#endif
+ rMess += "Ausgabe von ";
+ rMess += rName;
+ rMess += " in Datei ";
+ rMess += rOutName;
+ rMess += "......";
+
+ if ( xStrm->Read( &nL, sizeof( nL ) ) == 0 ){
+ return 1;
+ }
+ xStrm->Seek( 0 );
+
+ return 0;
+}
+
+int DoConvert( const String& rName, BYTE nVersion )
+{
+ ULONG nL;
+ if ( xStrm->Read( &nL, sizeof( nL ) ) == 0 ){
+ return 1;
+ }
+ xStrm->Seek( 0 );
+
+ pWwFib = new DFib( *xStrm, nVersion );
+
+ if ( pWwFib->nFibError )
+ return 1;
+
+#if 0
+ *pOut << "Eingabe-Dateiname : \"" << cName << '"' << endl1;
+ if ( cOutName[0] == 0 )
+ *pOut << "Ausgabe auf \"cout\"" << endl1;
+ else
+ *pOut << "Ausgabe-Dateiname : \"" << cOutName << '"' << endl1;
+ *pOut << endl1;
+#endif
+
+
+ // Nachdem wir nun den FIB eingelesen haben, wissen wir ja,
+ // welcher Table-Stream gueltig ist.
+ // Diesen oeffnen wir nun.
+
+ switch( pWwFib->nVersion ) // 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7:
+ xTableStream = &xStrm;
+ xDataStream = &xStrm;
+ break;
+ case 8:
+ xTableStream = (*pxStor)->OpenStream(
+ ( 1 == pWwFib->fWhichTblStm ) ? "1Table" : "0Table" ,
+ STREAM_STD_READ );
+ xDataStream = (*pxStor)->OpenStream( "Data", STREAM_STD_READ | STREAM_NOCREATE );
+ if( !xDataStream.Is() || SVSTREAM_OK != xDataStream->GetError() )
+ xDataStream = &xStrm;
+ break;
+ default:// Programm-Fehler!
+ /*
+ ACHTUNG: im FILTER nicht "FALSE" sondern "!this()" schreiben,
+ da sonst Warning unter OS/2
+ */
+ ASSERT( FALSE, "Es wurde vergessen, nVersion zu kodieren!" );
+ return 1;
+ }
+
+
+ // dann erstmal den Dateinamen schreiben:
+ *pOut << "Datei: " << rName.GetStr() << endl;
+
+ pSBase = new WW8ScannerBase( &xStrm, &xTableStream, &xDataStream, pWwFib );
+
+ // erstmal die Lowlevel-Funktionen
+
+ ((DFib*)pWwFib)->Dump(); // FIB
+ DumpDop( *pWwFib ); // WW8_DOP
+
+ if( ( 8 > pWwFib->nVersion && pWwFib->fComplex ) ||
+ pWwFib->lcbClx )
+ DumpPcd( pWwFib->nVersion, pWwFib->fcClx, pWwFib->lcbClx );
+
+ DumpBookLow();
+
+ DumpBookHigh();
+
+
+ DumpPLCF( pWwFib->fcPlcfsed, pWwFib->lcbPlcfsed, SEP ); // SEPX
+
+ DumpPLCF( pWwFib->fcPlcfbteChpx, pWwFib->lcbPlcfbteChpx, CHP ); // CHPX
+
+ DumpPLCF( pWwFib->fcPlcfbtePapx, pWwFib->lcbPlcfbtePapx, PAP ); // PAPX
+
+ {
+ DStyle aStyle( *xTableStream, *pWwFib ); // Styles
+ aStyle.Dump();
+ }
+
+ DumpFonts(); // WW8_FFN
+
+ // ... und jetzt die High-Level-Funktionen
+
+ WW8_CP nStartCp = 0;
+
+ DumpPlainText( nStartCp, pWwFib->ccpText, "Main" );
+ *pOut << endl1;
+ DumpField1( pWwFib->fcPlcffldMom, pWwFib->lcbPlcffldMom,
+ "MainText Fields" );
+
+ DumpHeader( pSBase ); // Header / Footer
+ DumpField1( pWwFib->fcPlcffldHdr, pWwFib->lcbPlcffldHdr,
+ "Header/Footer Fields" );
+
+ DumpFootnotes( pSBase );
+ DumpField1( pWwFib->fcPlcffldFtn, pWwFib->lcbPlcffldFtn,
+ "Footnote Fields" );
+
+ DumpEndnotes( pSBase );
+ DumpField1( pWwFib->fcPlcffldEdn, pWwFib->lcbPlcffldEdn,
+ "Endnote Fields" );
+
+ DumpAnnotations( pSBase );
+
+ DumpTextBoxs( pSBase );
+
+ DumpField1( pWwFib->fcPlcffldTxbx, pWwFib->lcbPlcffldTxbx,
+ "Textbox Fields" );
+ DumpField1( pWwFib->fcPlcffldHdrTxbx, pWwFib->lcbPlcffldHdrTxbx,
+ "Header/Footer Textbox Fields" );
+
+ if( 8 == pWwFib->nVersion )
+ DumpNumList();
+
+ DumpFdoa( pSBase );
+
+ if( pWwFib->lcbPlcfspaHdr || pWwFib->lcbPlcfspaMom )
+ DumpDrawing();
+
+ DELETEZ( pSBase );
+ DELETEZ( pWwFib );
+ return 0;
+}
+
+void DeInit()
+{
+// DELETEZ( aWwStor );
+ xStrm.Clear();
+ DELETEZ( pxStor );
+ DELETEZ( pOut );
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/dump/dump8a.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.15 2000/09/18 16:05:02 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.14 2000/02/14 14:39:35 jp
+ #70473# changes for unicode
+
+ Revision 1.13 2000/02/14 14:12:01 jp
+ piece table is in the table stream
+
+ Revision 1.12 2000/01/25 10:44:58 khz
+ change: update the dumper according to import improvements
+
+ Revision 1.11 1999/11/18 22:15:11 jp
+ dump fields
+
+ Revision 1.10 1999/11/18 22:09:53 jp
+ dump fields
+
+ Revision 1.9 1999/10/27 17:57:35 jp
+ changes for tables
+
+ Revision 1.8 1999/09/08 11:58:46 jp
+ den neuen WW8Scanner benutzen
+
+ Revision 1.7 1999/09/08 11:14:15 jp
+ Escher dump verbessert
+
+
+ Rev 1.5 16 Aug 1999 12:22:38 JP
+ neu: Dump EscherObjects
+
+ Rev 1.4 15 Jun 1999 14:19:18 JP
+ new: ListTable and other Contents
+
+ Rev 1.3 25 Jun 1998 16:29:52 KHZ
+ doppelte Deklaration von FkpSizeTab in Define umgewandelt
+
+ Rev 1.2 25 Jun 1998 15:43:46 KHZ
+ Strukturaenderung fuer PAPX FKPs
+
+ Rev 1.1 10 Jun 1998 17:22:38 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:29:26 KHZ
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/dump/makefile.mk b/sw/source/filter/ww8/dump/makefile.mk
new file mode 100644
index 000000000000..da4babcc60a7
--- /dev/null
+++ b/sw/source/filter/ww8/dump/makefile.mk
@@ -0,0 +1,179 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=.
+
+PRJNAME=DUMP8
+TARGET=dump8
+VERSION=$(UPD)
+
+# --- Settings ---------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+CXXFILES= dump8.cxx dump8a.cxx ww8dout.cxx ww8darr.cxx ww8scan.cxx msvbasic.cxx
+
+OBJFILES= $(OBJ)$/dump8.obj $(OBJ)$/dump8a.obj $(OBJ)$/ww8dout.obj \
+ $(OBJ)$/ww8darr.obj $(OBJ)$/ww8scan.obj $(OBJ)$/msvbasic.obj
+
+
+.IF "$(depend)" == ""
+
+CFLAGS+= -DDUMP
+
+# --- DUMP8 EXE --------------------------------------------------------
+
+# IENV=$(IENV);..\RES
+
+APP1TARGET=$(PRJNAME)
+
+# RESLIB1NAME=vu
+# RESLIB1SRSFILES=$(SRS)$/main.srs
+
+APP1LIBS=$(LIB1TARGET)
+
+.IF "$(GUI)" == "WNT"
+APP1STDLIBS= $(SVTOOLLIB) $(SVLLIB) $(TOOLSLIB) $(SVLIB) svmem.lib so2.lib
+# irtl.lib
+.IF "$(SO3)" == ""
+APP1STDLIBS+= sdstor.lib
+.ELSE
+APP1STDLIBS+= sot.lib
+.ENDIF
+APP1STDLIBS+= ole32.lib oleaut32.lib uuid.lib shell32.lib advapi32.lib libci.lib msvcirt.lib
+.ELSE
+.IF "$(GUI)" == "OS2"
+APP1STDLIBS=sdstor.lib so2.lib svtool.lib $(SVLIB) tools.lib svmem.lib svx.lib
+.ELSE
+APP1STDLIBS=svtool.lib tools.lib $(SVLIB) svmem.lib sdstor.lib so2.lib svx.lib
+APP1STDLIBS+= ole2 compobj storage shell
+.ENDIF
+.ENDIF
+.IF "$(GUI)"=="WNT"
+APP1DEPN= $(L)$/svtool.lib $(L)$/itools.lib $(SVLIBDEPEND) $(L)$/svmem.lib $(L)$/so2.lib
+.ELSE
+APP1DEPN= $(L)$/svtool.lib $(L)$/tools.lib $(SVLIBDEPEND) $(L)$/svmem.lib $(L)$/so2.lib
+.ENDIF
+APP1OBJS= $(OBJ)$/dump8.obj $(OBJ)$/dump8a.obj $(OBJ)$/ww8dout.obj \
+ $(OBJ)$/ww8darr.obj $(OBJ)$/ww8scan.obj $(OBJ)/msvbasic.obj
+
+APP1DEF= $(MISC)$/$(PRJNAME).def
+#APP1RES= $(RES)$/$(PRJNAME).res
+#SRSFILES= $(SRS)$/main.srs
+
+#-------------------------------------------------------------------------
+# Windows 3.x
+#-------------------------------------------------------------------------
+
+.IF "$(GUI)" == "WIN"
+
+ALL: \
+ ALLTAR
+
+$(MISC)$/$(PRJNAME).def: makefile
+ echo NAME VIEWER >$@
+ echo DESCRIPTION 'StarView - Testprogramm' >>$@
+ echo EXETYPE WINDOWS >>$@
+ echo PROTMODE >>$@
+ echo STUB 'winSTUB.EXE' >>$@
+ echo CODE PRELOAD MOVEABLE DISCARDABLE >>$@
+ echo DATA PRELOAD MULTIPLE MOVEABLE >>$@
+ echo HEAPSIZE 4096 >>$@
+ echo STACKSIZE 30000 >>$@
+
+.ENDIF # GUI == WIN
+
+#-------------------------------------------------------------------------
+# OS/2
+#-------------------------------------------------------------------------
+
+.IF "$(GUI)" == "OS2"
+
+ALL: \
+ $(SRS)$/main.srs \
+ ALLTAR
+
+$(MISC)$/$(PRJNAME).def: makefile
+ echo NAME VIEWER WINDOWAPI >$@
+ echo DESCRIPTION 'Storage Viewer (C)1995 STAR DIVISION GmbH' >>$@
+ echo EXETYPE OS2 >>$@
+ echo PROTMODE >>$@
+ echo STUB 'OS2STUB.EXE' >>$@
+ echo CODE LOADONCALL >>$@
+ echo DATA PRELOAD MULTIPLE >>$@
+ echo HEAPSIZE 4096 >>$@
+ echo STACKSIZE 30000 >>$@
+
+.ENDIF # GUI == OS2
+
+#-------------------------------------------------------------------------
+# Windows NT
+#-------------------------------------------------------------------------
+
+# --- Targets -----------------------------------------------------------
+
+.ENDIF
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/ww8/dump/msvbasic.cxx b/sw/source/filter/ww8/dump/msvbasic.cxx
new file mode 100644
index 000000000000..0808ac5f9659
--- /dev/null
+++ b/sw/source/filter/ww8/dump/msvbasic.cxx
@@ -0,0 +1,598 @@
+/*************************************************************************
+ *
+ * $RCSfile: msvbasic.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <string.h> // memset(), ...
+#ifndef UNX
+#include <io.h> // access()
+#endif
+
+#ifndef _MSVBASIC_HXX
+#include <msvbasic.hxx>
+#endif
+
+/* class VBA_Impl:
+ * The VBA class provides a set of methods to handle Visual Basic For
+ * Applications streams, the constructor is given the root ole2 stream
+ * of the document, Open reads the VBA project file and figures out
+ * the number of VBA streams, and the offset of the data within them.
+ * Decompress decompresses a particular numbered stream, NoStreams returns
+ * this number, and StreamName can give you the streams name. Decompress
+ * will call Output when it has a 4096 byte collection of data to output,
+ * and also with the final remainder of data if there is still some left
+ * at the end of compression. Output is virtual to allow custom handling
+ * of each chunk of decompressed data. So inherit from this to do something
+ * useful with the data.
+ *
+ * cmc
+ * */
+
+BYTE VBA_Impl::ReadPString(SvStorageStreamRef &xVBAProject)
+{
+ UINT16 idlen;
+ BYTE type=0;
+ *xVBAProject >> idlen;
+ BYTE out;
+ int i=0;
+ if (idlen < 6)
+ {
+ type=0;
+ xVBAProject->SeekRel(-2);
+ return(type);
+ }
+
+ for(i=0;i<idlen/2;i++)
+ {
+ *xVBAProject >> out;
+ xVBAProject->SeekRel(1);
+ if (i==2)
+ {
+ type=out;
+ if ((type != 'G') && (type != 'C'))
+ type=0;
+ if (type == 0)
+ {
+ xVBAProject->SeekRel(-8);
+ break;
+ }
+ }
+ }
+
+
+ return(type);
+}
+
+void VBA_Impl::ConfirmFixedOctect(SvStorageStreamRef &xVBAProject)
+{
+ static const BYTE stest[8] =
+ {
+ 0x06, 0x02, 0x01, 0x00, 0x08, 0x02, 0x00, 0x00
+ };
+
+ BYTE test[8];
+ xVBAProject->Read(test,8);
+ if (memcmp(stest,test,8) != 0)
+ DBG_WARNING("Found a different octect, please report");
+}
+
+void VBA_Impl::Confirm12Zeros(SvStorageStreamRef &xVBAProject)
+{
+ static const BYTE stest[12]={0};
+ BYTE test[12];
+ xVBAProject->Read(test,12);
+ if (memcmp(stest,test,12) != 0)
+ DBG_WARNING("Found a Non Zero block, please report");
+}
+
+void VBA_Impl::ConfirmHalfWayMarker(SvStorageStreamRef &xVBAProject)
+{
+ static const BYTE stest[12]={0,0,0,0,0,0,0,0,0,0,1,0};
+ BYTE test[12];
+ xVBAProject->Read(test,12);
+ if (memcmp(stest,test,12) != 0)
+ DBG_WARNING("Found a different halfway marker, please report");
+}
+
+void VBA_Impl::ConfirmFixedMiddle(SvStorageStreamRef &xVBAProject)
+{
+ static const BYTE stest[20] =
+ {
+ 0x00, 0x00, 0xe1, 0x2e, 0x45, 0x0d, 0x8f, 0xe0,
+ 0x1a, 0x10, 0x85, 0x2e, 0x02, 0x60, 0x8c, 0x4d,
+ 0x0b, 0xb4, 0x00, 0x00
+ };
+
+ BYTE test[20];
+ xVBAProject->Read(test,20);
+ if (memcmp(stest,test,20) != 0)
+ {
+ DBG_WARNING("Found a different middle marker, please report");
+ xVBAProject->SeekRel(-20);
+ }
+}
+
+void VBA_Impl::ConfirmFixedMiddle2(SvStorageStreamRef &xVBAProject)
+{
+ static const BYTE stest[20] =
+ {
+ 0x00, 0x00, 0x2e, 0xc9, 0x27, 0x8e, 0x64, 0x12,
+ 0x1c, 0x10, 0x8a, 0x2f, 0x04, 0x02, 0x24, 0x00,
+ 0x9c, 0x02, 0x00, 0x00
+ };
+
+ BYTE test[20];
+ xVBAProject->Read(test,20);
+ if (memcmp(stest,test,20) != 0)
+ {
+ DBG_WARNING("Found a different middle2 marker, please report");
+ xVBAProject->SeekRel(-20);
+ }
+}
+
+
+void VBA_Impl::Output( int nLen, const BYTE *pData)
+{
+ sVBAString += String( (const sal_Char *)pData, nLen );
+/*
+//For debugging purposes
+ for(int i=0;i<len;i++)
+ *pOut << data[i];
+*/
+}
+
+
+int VBA_Impl::ReadVBAProject(const SvStorageRef &rxVBAStorage)
+ {
+ SvStorageStreamRef xVBAProject;
+ xVBAProject = rxVBAStorage->OpenStream( "_VBA_PROJECT",
+ STREAM_STD_READ | STREAM_NOCREATE );
+
+ if( !xVBAProject.Is() || SVSTREAM_OK != xVBAProject->GetError() )
+ {
+ DBG_WARNING("Not able to find vba project, cannot find macros");
+ return(0);
+ }
+ xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ //*pOut << hex;
+ BYTE header[30] =
+ {
+ 0xcc, 0x61, 0x5e, 0x00, 0x00, 0x01, 0x00, 0xff,
+ 0x07, 0x04, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
+ 0xe4, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
+ };
+ BYTE headerin[30];
+
+ xVBAProject->Read(headerin,30);
+ if (memcmp(header,headerin,30) != 0)
+ DBG_WARNING("Warning VBA header is different, please report");
+ UINT16 value;
+ *xVBAProject >> value;
+ //*pOut << "Trigger value 1 is " << value << endl;
+ UINT16 svalue;
+ *xVBAProject >> svalue;
+ if (svalue != 0x02)
+ DBG_WARNING("Warning VBA number is different, please report");
+
+ int count=0;
+ BYTE testc=0;
+
+ //*pOut << "Other strings after the middle are..." << endl;
+ //There appears to be almost any number of strings acceptable
+ //most begin with */G , and sometimes with
+ //*/C. Those with G always have a trailer of 12 bytes, those
+ //with C come in pairs, the first with no trailer, and the
+ //second with one of 12 bytes. The following code attemts
+ //to read these strings and ends when it reaches a sequence of
+ //bytes which fails a test to be a valid string. So this
+ //while loop here is the particular piece of code which is
+ //very suspect and likely to be the cause of any crashes and
+ //problems.
+ while ((testc = ReadPString(xVBAProject)) != 0)
+ {
+ //*pOut << endl;
+ //*pOut << "testcharacter is " << testc << endl;
+ switch (testc)
+ {
+ case 'C':
+ count++;
+ if (count == 2)
+ {
+ Confirm12Zeros(xVBAProject);
+ count=0;
+ }
+ break;
+ default:
+ case 'G':
+ Confirm12Zeros(xVBAProject);
+ break;
+ }
+ }
+
+ //appears to be a fixed 20 byte sequence here, and then the strings
+ //continue
+ ConfirmFixedMiddle(xVBAProject);
+
+ count=0;
+ testc=0;
+
+ while ((testc = ReadPString(xVBAProject)) != 0)
+ {
+ //*pOut << endl;
+ //*pOut << "testcharacter is " << testc << endl;
+ switch (testc)
+ {
+ case 'C':
+ count++;
+ if (count == 2)
+ {
+ Confirm12Zeros(xVBAProject);
+ count=0;
+ }
+ break;
+ default:
+ case 'G':
+ Confirm12Zeros(xVBAProject);
+ break;
+ }
+ }
+
+ //there *may* be another different 20byte fixed string
+ ConfirmFixedMiddle2(xVBAProject);
+
+ //*pOut << "testc is " << testc << endl;
+ //*pOut << "position is " << xVBAProject->Tell() << endl;
+
+ UINT16 nModules;
+ *xVBAProject >> nModules;
+
+ //begin section, this section isn't really 100% correct
+ //*pOut << nModules << hex << " vba modules" << endl;
+ xVBAProject->SeekRel(2*nModules);
+ xVBAProject->SeekRel(4);
+ //*pOut << "position is " << xVBAProject->Tell() << endl;
+ ConfirmFixedOctect(xVBAProject);
+
+ UINT16 junksize;
+ while(junksize != 0xFFFF)
+ {
+ xVBAProject->Read(&junksize,2); // usually 18 02, sometimes 1e 02
+ //but sometimes its a run of numbers until 0xffff, gagh!!!
+ //*pOut << "position is " << xVBAProject->Tell() << "len is "
+ // << junksize << endl;
+ }
+
+ UINT16 ftest;
+ *xVBAProject >> ftest;
+ if (ftest != 0xFFFF)
+ xVBAProject->SeekRel(ftest);
+ *xVBAProject >> ftest;
+ if (ftest != 0xFFFF)
+ xVBAProject->SeekRel(ftest);
+
+ xVBAProject->SeekRel(100);
+ //*pOut << "position is " << xVBAProject->Tell() << endl;
+ //end section
+
+
+ *xVBAProject >> nOffsets;
+ pOffsets = new VBAOffset_Impl[nOffsets];
+ int i;
+ for (i=0;i<nOffsets;i++)
+ {
+ BYTE discard;
+ UINT16 len;
+ *xVBAProject >> len;
+ int j;
+ for (j=0;j<len/2;j++)
+ {
+ *xVBAProject >> discard;
+ pOffsets[i].sName += discard;
+ *xVBAProject >> discard;
+ }
+ *xVBAProject >> len;
+ xVBAProject->SeekRel(len);
+
+ //begin section, another problem area
+ *xVBAProject >> len;
+ if (len == 0xFFFF)
+ {
+ xVBAProject->SeekRel(2);
+ *xVBAProject >> len;
+ xVBAProject->SeekRel(len);
+ }
+ else
+ xVBAProject->SeekRel(len+2);
+ //
+ /* I have a theory that maybe you read a 16bit len, and
+ * if it has 0x02 for the second byte then it is a special
+ * token of its own that affects nothing else, otherwise
+ * it is a len of the following data. C. I must test this
+ * theory later.
+ */
+ //end section
+
+ xVBAProject->SeekRel(8);
+ BYTE no_of_octects;
+ *xVBAProject >> no_of_octects;
+ for(j=0;j<no_of_octects;j++)
+ xVBAProject->SeekRel(8);
+ xVBAProject->SeekRel(6);
+
+ *xVBAProject >> pOffsets[i].nOffset;
+ //*pOut << pOffsets[i].pName.GetStr() << " at 0x" << hex << pOffsets[i].nOffset << endl;
+ xVBAProject->SeekRel(2);
+ }
+
+ //*pOut << endl;
+ return(nOffsets);
+ }
+
+BOOL VBA_Impl::Open( const String &rToplevel,const String &rSublevel )
+{
+ /* beginning test for vba stuff */
+ BOOL bRet = FALSE;
+ SvStorageRef xMacros= xStor->OpenStorage(rToplevel);
+ if( !xMacros.Is() || SVSTREAM_OK != xMacros->GetError() )
+ {
+ DBG_WARNING("No Macros Storage");
+ }
+ else
+ {
+ xVBA = xMacros->OpenStorage(rSublevel);
+ if( !xVBA.Is() || SVSTREAM_OK != xVBA->GetError() )
+ {
+ DBG_WARNING("No Visual Basic in Storage");
+ }
+ else
+ {
+ if (ReadVBAProject(xVBA))
+ bRet = TRUE;
+ }
+ }
+ /* end test for vba stuff */
+ return bRet;
+}
+
+const String &VBA_Impl::Decompress( UINT16 nIndex, int *pOverflow)
+{
+ SvStorageStreamRef xVBAStream;
+ sVBAString.Erase();
+
+ DBG_ASSERT( nIndex < nOffsets, "Index out of range" );
+ xVBAStream = xVBA->OpenStream( pOffsets[nIndex].sName,
+ STREAM_STD_READ | STREAM_NOCREATE );
+ if (pOverflow)
+ *pOverflow=0;
+ if( !xVBAStream.Is() || SVSTREAM_OK !=
+ xVBAStream->GetError() )
+ {
+ DBG_WARNING("Not able to open vb module ");
+ DBG_WARNING((pOffsets[nIndex].sName).GetStr());
+ }
+ else
+ {
+ xVBAStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ DecompressVBA(nIndex,xVBAStream);
+ /*
+ * if len was too big for a single string set that variable ?
+ * if ((len > XX) && (pOverflow))
+ *pOverflow=1;
+ */
+ if (bCommented)
+ {
+ String sTempStringa("\x0D\x0A");
+ String sTempStringb("\x0D\x0ARem ");
+ sVBAString.SearchAndReplaceAll(sTempStringa,sTempStringb);
+ sVBAString.Insert("Rem ",0);
+ }
+ }
+ return sVBAString;
+}
+
+
+int VBA_Impl::DecompressVBA( int nIndex, SvStorageStreamRef &xVBAStream )
+{
+ BYTE leadbyte;
+ unsigned int pos = 0;
+
+ //*pOut << "jumping to " << hex << offsets[nIndex].offset << endl;
+ xVBAStream->Seek(pOffsets[nIndex].nOffset+3);
+
+ int len;
+ UINT16 token;
+ int distance, shift, clean=1;
+
+ while(xVBAStream->Read(&leadbyte,1))
+ {
+ //*pOut << "reading 8 data unit block beginning with " << leadbyte << int(leadbyte) << " at pos " << xVBAStream->Tell() << " real pos " << pos << endl;
+ for(int position=0x01;position < 0x100;position=position<<1)
+ {
+ //we see if the leadbyte has flagged this location as a dataunit
+ //which is actually a token which must be looked up in the history
+ if (leadbyte & position)
+ {
+ *xVBAStream >> token;
+
+ if (clean == 0)
+ clean=1;
+
+ //For some reason the division of the token into the length
+ //field of the data to be inserted, and the distance back into
+ //the history differs depending on how full the history is
+ int pos2 = pos%WINDOWLEN;
+ if (pos2 <= 0x10)
+ shift = 12;
+ else if (pos2 <= 0x20)
+ shift = 11;
+ else if (pos2 <= 0x40)
+ shift = 10;
+ else if (pos2 <= 0x80)
+ shift = 9;
+ else if (pos2 <= 0x100)
+ shift = 8;
+ else if (pos2 <= 0x200)
+ shift = 7;
+ else if (pos2 <= 0x400)
+ shift = 6;
+ else if (pos2 <= 0x800)
+ shift = 5;
+ else
+ shift = 4;
+
+ int i;
+ len=0;
+ for(i=0;i<shift;i++)
+ len |= token & (1<<i);
+
+ //*pOut << endl << "match lookup token " << int(token) << "len " << int(len) << endl;
+
+ len += 3;
+ //*pOut << endl << "len is " << len << "shift is " << shift << endl;
+
+ distance = token >> shift;
+ //*pOut << "distance token shift is " << distance << " " << int(token) << " " << shift << "pos is " << pos << " " << xVBAStream->Tell() << endl;
+
+ //read the len of data from the history, wrapping around the
+ //WINDOWLEN boundary if necessary
+ //data read from the history is also copied into the recent
+ //part of the history as well.
+ for (i = 0; i < len; i++)
+ {
+ unsigned char c;
+ //*pOut << endl << (pos%WINDOWLEN)-distance-1 << " " << pos << " " << distance << endl;
+ c = aHistory[(pos-distance-1)%WINDOWLEN];
+ aHistory[pos%WINDOWLEN] = c;
+ pos++;
+ //*pOut << "real pos is " << pos << endl;
+ //
+ //temp removed
+ //*pOut << c ;
+ }
+ }
+ else
+ {
+ // special boundary case code, not guarantueed to be correct
+ // seems to work though, there is something wrong with the
+ // compression scheme (or maybe a feature) where when
+ // the data ends on a WINDOWLEN boundary and the excess
+ // bytes in the 8 dataunit list are discarded, and not
+ // interpreted as tokens or normal data.
+ if ((pos != 0) && ((pos%WINDOWLEN) == 0) && (clean))
+ {
+ //*pOut << "at boundary position is " << position << " " << xVBAStream->Tell() << " pos is " << pos << endl;
+ //if (position != 0x01)
+ //*pOut << "must restart by eating remainder single byte data units" << endl;
+ xVBAStream->SeekRel(2);
+ clean=0;
+ Output(WINDOWLEN,aHistory);
+ break;
+ }
+ //This is the normal case for when the data unit is not a
+ //token to be looked up, but instead some normal data which
+ //can be output, and placed in the history.
+ if (xVBAStream->Read(&aHistory[pos%WINDOWLEN],1))
+ {
+ pos++;
+ //temp removed
+ //*pOut << aHistory[pos++%WINDOWLEN];
+ }
+ if (clean == 0)
+ clean=1;
+ //*pOut << "pos is " << pos << " " << xVBAStream->Tell() << endl;
+ }
+ }
+ }
+ if (pos%WINDOWLEN)
+ Output(pos%WINDOWLEN,aHistory);
+ return(pos);
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/dump/msvbasic.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.5 2000/09/18 16:05:03 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.4 2000/02/03 09:31:52 cmc
+ #72268# Office 2000 compatibility bug fixed
+
+ Revision 1.2 2000/01/26 16:40:15 cmc
+ Made VBA Project stream reader more robust
+
+ Revision 1.1 2000/01/26 12:34:58 jp
+ #72268#: move form svdraw to here
+
+ Revision 1.4 2000/01/25 16:12:21 rt
+ #65293# includes unnecessary
+
+ Revision 1.3 2000/01/25 11:17:42 cmc
+ #72268# Visual Basic Decompression
+
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/dump/msvbasic.hxx b/sw/source/filter/ww8/dump/msvbasic.hxx
new file mode 100644
index 000000000000..83cdc516541e
--- /dev/null
+++ b/sw/source/filter/ww8/dump/msvbasic.hxx
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * $RCSfile: msvbasic.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _MSVBASIC_HXX
+#define _MSVBASIC_HXX
+
+#ifdef _SOLAR_H
+#include <tools/solar.h>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+
+
+/* class VBA:
+ * The VBA class provides a set of methods to handle Visual Basic For
+ * Applications streams, the constructor is given the root ole2 stream
+ * of the document, Open reads the VBA project file and figures out
+ * the number of VBA streams, and the offset of the data within them.
+ * Decompress decompresses a particular numbered stream, NoStreams returns
+ * this number, and StreamName can give you the streams name. Decompress
+ * will return a string with the decompressed data. The optional extra
+ * argument will be set if not NULL to 1 in the case of a string overflow,
+ * if I can figure out how to do that.
+ *
+ * Otherwise it is possible to inherit from VBA and implement a Output
+ * member which gets called with each 4096 output sized block.
+ *
+ * cmc
+ * */
+
+#define WINDOWLEN 4096
+
+class VBA_Impl
+{
+public:
+ VBA_Impl( SvStorage &rIn, BOOL bCmmntd = TRUE )
+ : xStor(&rIn), pOffsets(0), nOffsets(0), bCommented(bCmmntd)
+ {}
+ ~VBA_Impl() {if (nOffsets) delete [] pOffsets;}
+ //0 for failure, 1 for success
+ BOOL Open( const String &rToplevel, const String &rSublevel);
+ const String & Decompress( UINT16 nIndex, int *pOverflow=0);
+ UINT16 GetNoStreams() const { return nOffsets; }
+ const String &GetStreamName( UINT16 nIndex ) const
+ {
+ DBG_ASSERT( nIndex < nOffsets, "Index out of range" );
+ return pOffsets[ nIndex ].sName;
+ }
+ virtual void Output(int len,const BYTE *data);
+private:
+ struct VBAOffset_Impl
+ {
+ String sName;
+ UINT32 nOffset;
+ };
+
+ SvStorageRef xVBA;
+ String sVBAString;
+ SvStorageRef xStor;
+ VBAOffset_Impl *pOffsets;
+ UINT16 nOffsets;
+ BYTE aHistory[ WINDOWLEN ];
+ BOOL bCommented;
+
+ //0 for failure, anything else for success
+ int ReadVBAProject(const SvStorageRef &rxVBAStorage);
+ int DecompressVBA(int index, SvStorageStreamRef &rxVBAStream);
+ void Confirm12Zeros(SvStorageStreamRef &xVBAProject);
+ void ConfirmHalfWayMarker(SvStorageStreamRef &xVBAProject);
+ void ConfirmFixedMiddle(SvStorageStreamRef &xVBAProject);
+ void ConfirmFixedMiddle2(SvStorageStreamRef &xVBAProject);
+ void ConfirmFixedOctect(SvStorageStreamRef &xVBAProject);
+ BYTE ReadPString(SvStorageStreamRef &xVBAProject);
+};
+
+
+
+
+#endif
diff --git a/sw/source/filter/ww8/dump/ww8darr.cxx b/sw/source/filter/ww8/dump/ww8darr.cxx
new file mode 100644
index 000000000000..3674b34ce6bc
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8darr.cxx
@@ -0,0 +1,615 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8darr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+
+#include "ww8dout.hxx" // OutShort()
+#include "ww8darr.hxx"
+
+
+
+
+//-----------------------------------------
+
+
+
+SprmDumpInfo aSprmDumpTab[] = {
+ 0, (FnOut)0, "NOP(0)",
+ 2, OutShort, "sprmPIstd", // pap.istd (style code)
+ 3, (FnOut)0, "sprmPIstdPermute", // pap.istd permutation
+ 4, OutByte, "sprmPIncLv1", // pap.istddifference
+ 5, OutByte, "sprmPJc", // pap.jc (justification)
+ 6, OutBool, "sprmPFSideBySide", // pap.fSideBySide
+ 7, OutBool, "sprmPFKeep", // pap.fKeep
+ 8, OutBool, "sprmPFKeepFollow ", // pap.fKeepFollow
+ 9, OutBool, "sprmPPageBreakBefore", // pap.fPageBreakBefore
+
+ 10, (FnOut)0, "sprmPBrcl", // pap.brcl
+ 11, (FnOut)0, "sprmPBrcp ", // pap.brcp
+ 12, (FnOut)0, "sprmPAnld", // pap.anld (ANLD structure)
+ 13, OutByte, "sprmPNLvlAnm", // pap.nLvlAnm nn
+ 14, OutBool, "sprmPFNoLineNumb", //ap.fNoLnn
+
+ //??
+ 15, OutTab, "?sprmPChgTabsPapx", // pap.itbdMac, ...
+
+
+ 16, OutShort, "sprmPDxaRight", // pap.dxaRight
+ 17, OutShort, "sprmPDxaLeft", // pap.dxaLeft
+ 18, OutWord, "sprmPNest", // pap.dxaLeft
+ 19, OutShort, "sprmPDxaLeft1", // pap.dxaLeft1
+
+ 20, OutShorts, "sprmPDyaLine", // pap.lspd an LSPD
+ 21, OutWord, "sprmPDyaBefore", // pap.dyaBefore
+ 22, OutWord, "sprmPDyaAfter", // pap.dyaAfter
+
+
+ //??
+ 23, (FnOut)0, "?sprmPChgTabs", // pap.itbdMac, pap.rgdxaTab, ...
+
+
+ 24, OutBool, "sprmPFInTable", // pap.fInTable
+ 25, OutBool, "sprmPTtp", // pap.fTtp
+ 26, OutWord, "sprmPDxaAbs", // pap.dxaAbs
+ 27, OutWord, "sprmPDyaAbs", // pap.dyaAbs
+ 28, OutWord, "sprmPDxaWidth", // pap.dxaWidth
+ 29, (FnOut)0, "sprmPPc", // pap.pcHorz, pap.pcVert
+
+ 30, (FnOut)0, "sprmPBrcTop10", // pap.brcTop BRC10
+ 31, (FnOut)0, "sprmPBrcLeft10", // pap.brcLeft BRC10
+ 32, (FnOut)0, "sprmPBrcBottom10", // pap.brcBottom BRC10
+ 33, (FnOut)0, "sprmPBrcRight10", // pap.brcRight BRC10
+ 34, (FnOut)0, "sprmPBrcBetween10", // pap.brcBetween BRC10
+ 35, (FnOut)0, "sprmPBrcBar10", // pap.brcBar BRC10
+ 36, OutWord, "sprmPFromText10", // pap.dxaFromText dxa
+ 37, (FnOut)0, "sprmPWr", // pap.wr wr
+ 38, OutWordHex, "sprmPBrcTop", // pap.brcTop BRC
+ 39, OutWordHex, "sprmPBrcLeft", // pap.brcLeft BRC
+
+ 40, OutWordHex, "sprmPBrcBottom", // pap.brcBottom BRC
+ 41, OutWordHex, "sprmPBrcRight", // pap.brcRight BRC
+ 42, (FnOut)0, "sprmPBrcBetween", // pap.brcBetween BRC
+ 43, (FnOut)0, "sprmPBrcBar",//pap.brcBar BRC word
+ 44, OutBool, "sprmPFNoAutoHyph",//pap.fNoAutoHyph
+ 45, OutWord, "sprmPWHeightAbs",//pap.wHeightAbs w
+ 46, (FnOut)0, "sprmPDcs",//pap.dcs DCS
+ 47, OutWordHex, "sprmPShd",//pap.shd SHD
+ 48, OutWord, "sprmPDyaFromText",//pap.dyaFromText dya
+ 49, OutWord, "sprmPDxaFromText",//pap.dxaFromText dxa
+
+ 50, OutBool, "sprmPFLocked", // pap.fLocked 0 or 1 byte
+ 51, OutBool, "sprmPFWidowControl", // pap.fWidowControl 0 or 1 byte
+
+
+ //??
+ 52, (FnOut)0, "?sprmPRuler 52", //???
+
+
+ 65, OutBool, "sprmCFStrikeRM", // chp.fRMarkDel 1 or 0 bit
+ 66, OutBool, "sprmCFRMark", // chp.fRMark 1 or 0 bit
+ 67, OutBool, "sprmCFFldVanish", // chp.fFldVanish 1 or 0 bit
+ 68, OutTab68, "sprmCPicLocation", // chp.fcPic and chp.fSpec
+ 69, OutShort, "sprmCIbstRMark", // chp.ibstRMark index into sttbRMark
+
+ 70, (FnOut)0, "sprmCDttmRMark", // chp.dttm DTTM long
+ 71, OutBool, "sprmCFData", // chp.fData 1 or 0 bit
+ 72, OutShort, "sprmCRMReason", // chp.idslRMReason an index to a table
+ 73, (FnOut)0, "sprmCChse", // chp.fChsDiff and chp.chse see below 3 bytes
+ 74, (FnOut)0, "sprmCSymbol", // chp.fSpec, chp.chSym and chp.ftcSym
+ 75, OutBool, "sprmCFOle2", // chp.fOle2 1 or 0 bit
+
+ 80, OutShort, "sprmCIstd", // chp.istd istd, see stylesheet definition short
+ 81, (FnOut)0, "sprmCIstdPermute", // chp.istd permutation vector (see below)
+ 82, (FnOut)0, "sprmCDefault", // whole CHP (see below) none variable length
+ 83, (FnOut)0, "sprmCPlain", // whole CHP (see below) none 0
+ 84, (FnOut)0, "??84",
+ 85, OutBool4, "sprmCFBold", // chp.fBold 0,1, 128, or 129 (see below) byte
+ 86, OutBool4, "sprmCFItalic", // chp.fItalic 0,1, 128, or 129 (see below) byte
+ 87, OutBool4, "sprmCFStrike", // chp.fStrike 0,1, 128, or 129 (see below) byte
+ 88, OutBool4, "sprmCFOutline", // chp.fOutline 0,1, 128, or 129 (see below) byte
+ 89, OutBool4, "sprmCFShadow", // chp.fShadow 0,1, 128, or 129 (see below) byte
+
+ 90, OutBool4, "sprmCFSmallCaps", // chp.fSmallCaps 0,1, 128, or 129 (see below) byte
+ 91, OutBool4, "sprmCFCaps", // chp.fCaps 0,1, 128, or 129 (see below) byte
+ 92, OutBool4, "sprmCFVanish", // chp.fVanish 0,1, 128, or 129 (see below) byte
+ 93, OutWord, "sprmCFtc", // chp.ftc ftc word
+ 94, OutByte, "sprmCKul", // chp.kul kul byte
+ 95, (FnOut)0, "sprmCSizePos", // chp.hps, chp.hpsPos (see below) 3 bytes
+ 96, OutWord, "sprmCDxaSpace", // chp.dxaSpace dxa word
+ 97, OutWord, "sprmCLid", // chp.lid LID word
+ 98, OutByte, "sprmCIco", // chp.ico ico byte
+ 99, OutWord, "sprmCHps", // chp.hps hps word!
+
+ 100, OutByte, "sprmCHpsInc", // chp.hps (see below) byte
+ 101, OutWord, "sprmCHpsPos", // chp.hpsPos hps byte
+ 102, OutByte, "sprmCHpsPosAdj", // chp.hpsPos hps (see below) byte
+
+
+ //??
+ 103, (FnOut)0, "?sprmCMajority", // chp.fBold, chp.fItalic, chp.fSmallCaps, ...
+
+
+ 104, OutByte, "sprmCIss", // chp.iss iss byte
+ 105, (FnOut)0, "sprmCHpsNew50", // chp.hps hps variable width, length always recorded as 2
+ 106, (FnOut)0, "sprmCHpsInc1", // chp.hps complex (see below) variable width, length always recorded as 2
+ 107, OutShort, "sprmCHpsKern", // chp.hpsKern hps short
+ 108, (FnOut)0, "sprmCMajority50", // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, ...
+ 109, OutShort, "sprmCHpsMul", // chp.hps percentage to grow hps short
+
+ 110, OutShort, "sprmCCondHyhen", // chp.ysri ysri short
+ 117, OutBool, "sprmCFSpec", // chp.fSpec 1 or 0 bit
+ 118, OutBool, "sprmCFObj", // chp.fObj 1 or 0 bit
+ 119, (FnOut)0, "sprmPicBrcl", // pic.brcl brcl (see PIC structure definition) byte
+
+ 120, (FnOut)0, "sprmPicScale", // pic.mx, pic.my, pic.dxaCropleft,
+ 121, (FnOut)0, "sprmPicBrcTop", // pic.brcTop BRC word
+ 122, (FnOut)0, "sprmPicBrcLeft", // pic.brcLeft BRC word
+ 123, (FnOut)0, "sprmPicBrcBottom", // pic.brcBottom BRC word
+ 124, (FnOut)0, "sprmPicBrcRight", // pic.brcRight BRC word
+ 131, OutByte, "sprmSScnsPgn", // sep.cnsPgn cns byte
+ 132, (FnOut)0, "sprmSiHeadingPgn", // sep.iHeadingPgn heading number level byte
+ 133, (FnOut)0, "sprmSOlstAnm", // sep.olstAnm OLST variable length
+ 136, (FnOut)0, "sprmSDxaColWidth", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 137, (FnOut)0, "sprmSDxaColSpacing", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 138, OutBool, "sprmSFEvenlySpaced", // sep.fEvenlySpaced 1 or 0 byte
+ 139, OutBool, "sprmSFProtected", // sep.fUnlocked 1 or 0 byte
+
+ 140, OutWord, "sprmSDmBinFirst", // sep.dmBinFirst word
+ 141, OutWord, "sprmSDmBinOther", // sep.dmBinOther word
+ 142, OutByte, "sprmSBkc", // sep.bkc bkc byte
+ 143, OutBool, "sprmSFTitlePage", // sep.fTitlePage 0 or 1 byte
+ 144, OutWord, "sprmSCcolumns", // sep.ccolM1 # of cols - 1 word
+ 145, OutWord, "sprmSDxaColumns", // sep.dxaColumns dxa word
+ 146, (FnOut)0, "sprmSFAutoPgn", // sep.fAutoPgn obsolete byte
+ 147, OutByte, "sprmSNfcPgn", // sep.nfcPgn nfc byte
+ 148, OutShort, "sprmSDyaPgn", // sep.dyaPgn dya short
+ 149, OutShort, "sprmSDxaPgn", // sep.dxaPgn dya short
+
+ 150, OutBool, "sprmSFPgnRestart", // sep.fPgnRestart 0 or 1 byte
+ 151, OutBool, "sprmSFEndnote", // sep.fEndnote 0 or 1 byte
+ 152, OutByte, "sprmSLnc", // sep.lnc lnc byte
+ 153, (FnOut)0, "sprmSGprfIhdt", // sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
+ 154, OutWord, "sprmSNLnnMod", // sep.nLnnMod non-neg int. word
+ 155, OutWord, "sprmSDxaLnn", // sep.dxaLnn dxa word
+ 156, OutWord, "sprmSDyaHdrTop", // sep.dyaHdrTop dya word
+ 157, OutWord, "sprmSDyaHdrBottom", // sep.dyaHdrBottom dya word
+ 158, OutBool, "sprmSLBetween", // sep.fLBetween 0 or 1 byte
+ 159, OutByte, "sprmSVjc", // sep.vjc vjc byte
+
+ 160, OutWord, "sprmSLnnMin", // sep.lnnMin lnn word
+ 161, OutWord, "sprmSPgnStart", // sep.pgnStart pgn word
+ 162, OutByte, "sprmSBOrientation", // sep.dmOrientPage dm byte
+
+
+ //??
+ 163, OutWord, "?SprmSBCustomize 163", //???
+
+
+ 164, OutWord, "sprmSXaPage", // sep.xaPage xa word
+ 165, OutWord, "sprmSYaPage", // sep.yaPage ya word
+ 166, OutWord, "sprmSDxaLeft", // sep.dxaLeft dxa word
+ 167, OutWord, "sprmSDxaRight", // sep.dxaRight dxa word
+ 168, OutWord, "sprmSDyaTop", // sep.dyaTop dya word
+ 169, OutWord, "sprmSDyaBottom", // sep.dyaBottom dya word
+
+ 170, OutWord, "sprmSDzaGutter", // sep.dzaGutter dza word
+ 171, OutWord, "sprmSDMPaperReq", // sep.dmPaperReq dm word
+ 182, OutWord, "sprmTJc", // tap.jc jc word (low order byte is significant)
+ 183, OutWord, "sprmTDxaLeft", // tap.rgdxaCenter (see below) dxa word
+ 184, OutWord, "sprmTDxaGapHalf", // tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
+ 185, OutBool, "sprmTFCantSplit", // tap.fCantSplit 1 or 0 byte
+ 186, OutBool, "sprmTTableHeader", // tap.fTableHeader 1 or 0 byte
+ 187, OutWordsHex, "sprmTTableBorders", // tap.rgbrcTable complex(see below) 12 bytes
+ 188, (FnOut)0, "sprmTDefTable10", // tap.rgdxaCenter, tap.rgtc complex (see below) variable length
+ 189, OutShort, "sprmTDyaRowHeight", // tap.dyaRowHeight dya word
+
+
+ //??
+ 190, OutTab190, "sprmTDefTable", // tap.rgtc complex (see below)
+
+
+ //??
+ 191, OutTab191, "sprmTDefTableShd", // tap.rgshd complex (see below)
+
+
+ 192, OutTab192, "sprmTTlp", // tap.tlp TLP 4 bytes
+ 193, (FnOut)0, "sprmTSetBrc", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+ 194, (FnOut)0, "sprmTInsert", // tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
+ 195, (FnOut)0, "sprmTDelete", // tap.rgdxaCenter, tap.rgtc complex (see below) word
+ 196, (FnOut)0, "sprmTDxaCol", // tap.rgdxaCenter complex (see below) 4 bytes
+ 197, (FnOut)0, "sprmTMerge", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 198, (FnOut)0, "sprmTSplit", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 199, (FnOut)0, "sprmTSetBrc10", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+
+ 200, (FnOut)0, "sprmTSetShd", // tap.rgshd complex (see below) 4 bytes
+
+
+
+ // ab hier Selbstdefinierte Ids
+
+ 256, (FnOut)0, "FootNote",
+ 257, (FnOut)0, "EndNote",
+ 258, (FnOut)0, "??258 selbstdef.",
+ 259, (FnOut)0, "??259 selbstdef.",
+ 260, (FnOut)0, "Field",
+
+//- neue ab Ver8 ------------------------------------------------------------
+
+ 0x4600, OutShort,"sprmPIstd", // pap.istd;istd (style code);short;
+ 0xC601, (FnOut)0,"sprmPIstdPermute", // pap.istd;permutation vector (see below);variable length;
+ 0x2602, OutByte, "sprmPIncLvl", // pap.istd, pap.lvl;difference between istd of base PAP and istd of PAP to be produced (see below);byte;
+ 0x2403, OutByte, "sprmPJc", // pap.jc;jc (justification);byte;
+ 0x2404, OutByte, "sprmPFSideBySide", // pap.fSideBySide;0 or 1;byte;
+ 0x2405, OutByte, "sprmPFKeep", // pap.fKeep;0 or 1;byte;
+ 0x2406, OutByte, "sprmPFKeepFollow", // pap.fKeepFollow;0 or 1;byte;
+ 0x2407, OutByte, "sprmPFPageBreakBefore", // pap.fPageBreakBefore;0 or 1;byte;
+ 0x2408, OutByte, "sprmPBrcl", // pap.brcl;brcl;byte;
+ 0x2409, OutByte, "sprmPBrcp", // pap.brcp;brcp;byte;
+ 0x260A, OutByte, "sprmPIlvl", // pap.ilvl;ilvl;byte;
+ 0x460B, OutShort, "sprmPIlfo", // pap.ilfo;ilfo (list index) ;short;
+ 0x240C, OutByte, "sprmPFNoLineNumb", // pap.fNoLnn;0 or 1;byte;
+ 0xC60D, OutTab, "sprmPChgTabsPapx", // pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length
+ 0x840E, OutWord, "sprmPDxaRight", // pap.dxaRight;dxa;word;
+ 0x840F, OutWord, "sprmPDxaLeft", // pap.dxaLeft;dxa;word;
+ 0x4610, OutWord, "sprmPNest", // pap.dxaLeft;dxa-see below;word;
+ 0x8411, OutWord, "sprmPDxaLeft1", // pap.dxaLeft1;dxa;word;
+ 0x6412,OutLongHex,"sprmPDyaLine", // pap.lspd;an LSPD, a long word structure consisting of a short of dyaLine followed by a short of fMultLinespace - see below;long;
+ 0xA413, OutWord, "sprmPDyaBefore", // pap.dyaBefore;dya;word;
+ 0xA414, OutWord, "sprmPDyaAfter", // pap.dyaAfter;dya;word;
+ 0xC615, (FnOut)0,"sprmPChgTabs", // pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length;
+ 0x2416, OutByte, "sprmPFInTable", // pap.fInTable;0 or 1;byte;
+ 0x2417, OutByte, "sprmPFTtp", // pap.fTtp;0 or 1;byte;
+ 0x8418, OutWord, "sprmPDxaAbs", // pap.dxaAbs;dxa;word;
+ 0x8419, OutWord, "sprmPDyaAbs", // pap.dyaAbs;dya;word;
+ 0x841A, OutWord, "sprmPDxaWidth", // pap.dxaWidth;dxa;word;
+ 0x261B, OutByte, "sprmPPc", // pap.pcHorz, pap.pcVert;complex - see below;byte;
+ 0x461C, OutWord, "sprmPBrcTop10", // pap.brcTop;BRC10;word;
+ 0x461D, OutWord, "sprmPBrcLeft10", // pap.brcLeft;BRC10;word;
+ 0x461E, OutWord, "sprmPBrcBottom10", // pap.brcBottom;BRC10;word;
+ 0x461F, OutWord, "sprmPBrcRight10", // pap.brcRight;BRC10;word;
+ 0x4620, OutWord, "sprmPBrcBetween10", // pap.brcBetween;BRC10;word;
+ 0x4621, OutWord, "sprmPBrcBar10", // pap.brcBar;BRC10;word;
+ 0x4622, OutWord, "sprmPDxaFromText10", // pap.dxaFromText;dxa;word;
+ 0x2423, OutByte, "sprmPWr", // pap.wr;wr (see description of PAP for definition;byte;
+ 0x6424,OutLongHex,"sprmPBrcTop", // pap.brcTop;BRC;long;
+ 0x6425,OutLongHex,"sprmPBrcLeft", // pap.brcLeft;BRC;long;
+ 0x6426,OutLongHex,"sprmPBrcBottom", // pap.brcBottom;BRC;long;
+ 0x6427,OutLongHex,"sprmPBrcRight", // pap.brcRight;BRC;long;
+ 0x6428,OutLongHex,"sprmPBrcBetween", // pap.brcBetween;BRC;long;
+ 0x6629,OutLongHex,"sprmPBrcBar", // pap.brcBar;BRC;long;
+ 0x242A, OutByte, "sprmPFNoAutoHyph", // pap.fNoAutoHyph;0 or 1;byte;
+ 0x442B, OutWord, "sprmPWHeightAbs", // pap.wHeightAbs;w;word;
+ 0x442C, OutShort,"sprmPDcs", // pap.dcs;DCS;short;
+ 0x442D, OutWord, "sprmPShd", // pap.shd;SHD;word;
+ 0x842E, OutWord, "sprmPDyaFromText", // pap.dyaFromText;dya;word;
+ 0x842F, OutWord, "sprmPDxaFromText", // pap.dxaFromText;dxa;word;
+ 0x2430, OutByte, "sprmPFLocked", // pap.fLocked;0 or 1;byte;
+ 0x2431, OutByte, "sprmPFWidowControl", // pap.fWidowControl;0 or 1;byte;
+ 0xC632, (FnOut)0,"sprmPRuler", // ;;variable length;
+ 0x2433, OutByte, "sprmPFKinsoku", // pap.fKinsoku;0 or 1;byte;
+ 0x2434, OutByte, "sprmPFWordWrap", // pap.fWordWrap;0 or 1;byte;
+ 0x2435, OutByte, "sprmPFOverflowPunct", // pap.fOverflowPunct;0 or 1;byte;
+ 0x2436, OutByte, "sprmPFTopLinePunct", // pap.fTopLinePunct;0 or 1;byte;
+ 0x2437, OutByte, "sprmPFAutoSpaceDE", // pap.fAutoSpaceDE;0 or 1;byte;
+ 0x2438, OutByte, "sprmPFAutoSpaceDN", // pap.fAutoSpaceDN;0 or 1;byte;
+ 0x4439, OutWord, "sprmPWAlignFont", // pap.wAlignFont;iFa (see description of PAP for definition);word;
+ 0x443A, OutWord, "sprmPFrameTextFlow", // pap.fVertical pap.fBackward pap.fRotateFont;complex (see description of PAP for definition);word;
+ 0x243B, OutByte, "sprmPISnapBaseLine", // obsolete: not applicable in Word97 and later versions;;byte;
+ 0xC63E, (FnOut)0,"sprmPAnld", // pap.anld;;variable length;
+ 0xC63F, (FnOut)0,"sprmPPropRMark", // pap.fPropRMark;complex (see below);variable length;
+ 0x2640, OutByte, "sprmPOutLvl", // pap.lvl;has no effect if pap.istd is < 1 or is > 9;byte;
+ 0x2441, OutByte, "sprmPFBiDi", // ;;byte;
+ 0x2443, OutBool, "sprmPFNumRMIns", // pap.fNumRMIns;1 or 0;bit;
+ 0x2444, OutByte, "sprmPCrLf", // ;;byte;
+ 0xC645, (FnOut)0,"sprmPNumRM", // pap.numrm;;variable length;
+ 0x6645,OutHugeHex,"sprmPHugePapx", // see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x6646,OutHugeHex,"sprmPHugePapx", // see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x2447, OutByte, "sprmPFUsePgsuSettings", // pap.fUsePgsuSettings;1 or 0;byte;
+ 0x2448, OutByte, "sprmPFAdjustRight", // pap.fAdjustRight;1 or 0;byte;
+ 0x0800, OutBool, "sprmCFRMarkDel", // chp.fRMarkDel;1 or 0;bit;
+ 0x0801, OutBool, "sprmCFRMark", // chp.fRMark;1 or 0;bit;
+ 0x0802, OutBool, "sprmCFFldVanish", // chp.fFldVanish;1 or 0;bit;
+ 0x6A03, OutTab68,"sprmCPicLocation", // chp.fcPic and chp.fSpec;see below;variable length, length recorded is always 4;
+ 0x4804, OutShort,"sprmCIbstRMark", // chp.ibstRMark;index into sttbRMark;short;
+ 0x6805,OutLongHex,"sprmCDttmRMark", // chp.dttmRMark;DTTM;long;
+ 0x0806, OutBool, "sprmCFData", // chp.fData;1 or 0;bit;
+ 0x4807, OutShort, "sprmCIdslRMark", // chp.idslRMReason;an index to a table of strings defined in Word 6.0 executables;short;
+ 0xEA08, (FnOut)0,"sprmCChs", // chp.fChsDiff and chp.chse;see below;3 bytes;
+ 0x6A09, (FnOut)0,"sprmCSymbol", // chp.fSpec, chp.xchSym and chp.ftcSym;see below;variable length, length recorded is always 4;
+ 0x080A, OutBool, "sprmCFOle2", // chp.fOle2;1 or 0;bit;
+//0x480B, obsolete,"sprmCIdCharType", // obsolete: not applicable in Word97 and later versions;;;
+ 0x2A0C, OutByte, "sprmCHighlight", // chp.fHighlight, chp.icoHighlight;ico (fHighlight is set to 1 iff ico is not 0);byte;
+ 0x680E,OutLongHex,"sprmCObjLocation", // chp.fcObj;FC;long;
+//0x2A10, ? ? ? , "sprmCFFtcAsciSymb", // ;;;
+ 0x4A30, OutShort, "sprmCIstd", // chp.istd;istd, see stylesheet definition;short;
+ 0xCA31, (FnOut)0,"sprmCIstdPermute", // chp.istd;permutation vector (see below);variable length;
+ 0x2A32, (FnOut)0,"sprmCDefault", // whole CHP (see below);none;variable length;
+ 0x2A33, (FnOut)0,"sprmCPlain", // whole CHP (see below);none; Laenge: 0;
+//0x2A34, ? ? ?, "sprmCKcd", // ;;;
+ 0x0835, OutByte, "sprmCFBold", // chp.fBold;0,1, 128, or 129 (see below);byte;
+ 0x0836, OutByte, "sprmCFItalic", // chp.fItalic;0,1, 128, or 129 (see below);byte;
+ 0x0837, OutByte, "sprmCFStrike", // chp.fStrike;0,1, 128, or 129 (see below);byte;
+ 0x0838, OutByte, "sprmCFOutline", // chp.fOutline;0,1, 128, or 129 (see below);byte;
+ 0x0839, OutByte, "sprmCFShadow", // chp.fShadow;0,1, 128, or 129 (see below);byte;
+ 0x083A, OutByte, "sprmCFSmallCaps", // chp.fSmallCaps;0,1, 128, or 129 (see below);byte;
+ 0x083B, OutByte, "sprmCFCaps", // chp.fCaps;0,1, 128, or 129 (see below);byte;
+ 0x083C, OutByte, "sprmCFVanish", // chp.fVanish;0,1, 128, or 129 (see below);byte;
+ 0x4A3D, OutWord, "sprmCFtcDefault", // ;ftc, only used internally, never stored in file;word;
+ 0x2A3E, OutByte, "sprmCKul", // chp.kul;kul;byte;
+ 0xEA3F, (FnOut)0,"sprmCSizePos", // chp.hps, chp.hpsPos;(see below);3 bytes;
+ 0x8840, OutWord, "sprmCDxaSpace", // chp.dxaSpace;dxa;word;
+ 0x4A41, OutWord, "sprmCLid", // ;only used internally never stored;word;
+ 0x2A42, OutByte, "sprmCIco", // chp.ico;ico;byte;
+ 0x4A43, OutWord, "sprmCHps", // chp.hps;hps;word;
+ 0x2A44, OutByte, "sprmCHpsInc", // chp.hps;(see below);byte;
+ 0x4845, OutByte, "sprmCHpsPos", // chp.hpsPos;hps;byte;
+ 0x2A46, OutByte, "sprmCHpsPosAdj", // chp.hpsPos;hps (see below);byte;
+ 0xCA47, (FnOut)0,"sprmCMajority", // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.rgftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico, chp.rglid;complex (see below);variable length, length byte plus size of following grpprl;
+ 0x2A48, OutByte, "sprmCIss", // chp.iss;iss;byte;
+ 0xCA49, (FnOut)0,"sprmCHpsNew50", // chp.hps;hps;variable width, length always recorded as 2;
+ 0xCA4A, (FnOut)0,"sprmCHpsInc1", // chp.hps;complex (see below);variable width, length always recorded as 2;
+ 0x484B, OutShort,"sprmCHpsKern", // chp.hpsKern;hps;short;
+ 0xCA4C, (FnOut)0,"sprmCMajority50", // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.ftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico,;complex (see below);variable length;
+ 0x4A4D, OutShort,"sprmCHpsMul", // chp.hps;percentage to grow hps;short;
+ 0x484E, OutShort,"sprmCYsri", // chp.ysri;ysri;short;
+ 0x4A4F, OutShort,"sprmCRgFtc0", // chp.rgftc[0];ftc for ASCII text (see below);short;
+ 0x4A50, OutShort,"sprmCRgFtc1", // chp.rgftc[1];ftc for Far East text (see below);short;
+ 0x4A51, OutShort,"sprmCRgFtc2", // chp.rgftc[2];ftc for non-Far East text (see below);short;
+//0x4852, ? ? ? , "sprmCCharScale", // ;;;
+ 0x2A53, OutByte, "sprmCFDStrike", // chp.fDStrike;;byte;
+ 0x0854, OutBool, "sprmCFImprint", // chp.fImprint;1 or 0;bit;
+ 0x0855, OutBool, "sprmCFSpec", // chp.fSpec ;1 or 0;bit;
+ 0x0856, OutBool, "sprmCFObj", // chp.fObj;1 or 0;bit;
+ 0xCA57, (FnOut)0,"sprmCPropRMark", // chp.fPropRMark, chp.ibstPropRMark, chp.dttmPropRMark;Complex (see below);variable length always recorded as 7 bytes;
+ 0x0858, OutBool, "sprmCFEmboss", // chp.fEmboss;1 or 0;bit;
+ 0x2859, OutByte, "sprmCSfxText", // chp.sfxtText;text animation;byte;
+//0x085A, ? ? ? , "sprmCFBiDi", // ;;;
+//0x085B, ? ? ? , "sprmCFDiacColor", // ;;;
+//0x085C, ? ? ? , "sprmCFBoldBi", // ;;;
+//0x085D, ? ? ? , "sprmCFItalicBi", // ;;;
+//0x4A5E, ? ? ? , "sprmCFtcBi", // ;;;
+//0x485F, ? ? ? , "sprmCLidBi", // ;;;
+//0x4A60, ? ? ? , "sprmCIcoBi", // ;;;
+//0x4A61, ? ? ? , "sprmCHpsBi", // ;;;
+ 0xCA62, (FnOut)0,"sprmCDispFldRMark", // chp.fDispFldRMark, chp.ibstDispFldRMark, chp.dttmDispFldRMark ;Complex (see below);variable length always recorded as 39 bytes;
+ 0x4863, OutShort,"sprmCIbstRMarkDel", // chp.ibstRMarkDel;index into sttbRMark;short;
+ 0x6864,OutLongHex,"sprmCDttmRMarkDel", // chp.dttmRMarkDel;DTTM;long;
+ 0x6865,OutLongHex,"sprmCBrc", // chp.brc;BRC;long;
+ 0x4866, OutShort,"sprmCShd", // chp.shd;SHD;short;
+ 0x4867, OutShort,"sprmCIdslRMarkDel", // chp.idslRMReasonDel;an index to a table of strings defined in Word 6.0 executables;short;
+ 0x0868, OutBool, "sprmCFUsePgsuSettings", // chp.fUsePgsuSettings;1 or 0;bit;
+ 0x486B, OutWord, "sprmCCpg", // ;;word;
+ 0x486D, OutWord, "sprmCRgLid0", // chp.rglid[0];LID: for non-Far East text;word;
+ 0x486E, OutWord, "sprmCRgLid1", // chp.rglid[1];LID: for Far East text;word;
+ 0x286F, OutByte, "sprmCIdctHint", // chp.idctHint;IDCT: (see below);byte;
+ 0x2E00, OutByte, "sprmPicBrcl", // pic.brcl;brcl (see PIC structure definition);byte;
+ 0xCE01, (FnOut)0,"sprmPicScale", // pic.mx, pic.my, pic.dxaCropleft, pic.dyaCropTop pic.dxaCropRight, pic.dyaCropBottom;Complex (see below);length byte plus 12 bytes;
+ 0x6C02,OutLongHex,"sprmPicBrcTop", // pic.brcTop;BRC;long;
+ 0x6C03,OutLongHex,"sprmPicBrcLeft", // pic.brcLeft;BRC;long;
+ 0x6C04,OutLongHex,"sprmPicBrcBottom", // pic.brcBottom;BRC;long;
+ 0x6C05,OutLongHex,"sprmPicBrcRight", // pic.brcRight;BRC;long;
+ 0x3000, OutByte, "sprmScnsPgn", // sep.cnsPgn;cns;byte;
+ 0x3001, OutByte, "sprmSiHeadingPgn", // sep.iHeadingPgn;heading number level;byte;
+ 0xD202, (FnOut)0,"sprmSOlstAnm", // sep.olstAnm;OLST;variable length;
+ 0xF203, (FnOut)0,"sprmSDxaColWidth", // sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0xF204, (FnOut)0,"sprmSDxaColSpacing", // sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0x3005, OutByte, "sprmSFEvenlySpaced", // sep.fEvenlySpaced;1 or 0;byte;
+ 0x3006, OutByte, "sprmSFProtected", // sep.fUnlocked;1 or 0;byte;
+ 0x5007, OutWord, "sprmSDmBinFirst", // sep.dmBinFirst;;word;
+ 0x5008, OutWord, "sprmSDmBinOther", // sep.dmBinOther;;word;
+ 0x3009, OutByte, "sprmSBkc", // sep.bkc;bkc;byte;
+ 0x300A, OutByte, "sprmSFTitlePage", // sep.fTitlePage;0 or 1;byte;
+ 0x500B, OutWord, "sprmSCcolumns", // sep.ccolM1;# of cols - 1;word;
+ 0x900C, OutWord, "sprmSDxaColumns", // sep.dxaColumns;dxa;word;
+ 0x300D, OutByte, "sprmSFAutoPgn", // sep.fAutoPgn;obsolete;byte;
+ 0x300E, OutByte, "sprmSNfcPgn", // sep.nfcPgn;nfc;byte;
+ 0xB00F, OutShort,"sprmSDyaPgn", // sep.dyaPgn;dya;short;
+ 0xB010, OutShort,"sprmSDxaPgn", // sep.dxaPgn;dya;short;
+ 0x3011, OutByte, "sprmSFPgnRestart", // sep.fPgnRestart;0 or 1;byte;
+ 0x3012, OutByte, "sprmSFEndnote", // sep.fEndnote;0 or 1;byte;
+ 0x3013, OutByte, "sprmSLnc", // sep.lnc;lnc;byte;
+ 0x3014, OutByte, "sprmSGprfIhdt", // sep.grpfIhdt;grpfihdt (see Headers and Footers topic);byte;
+ 0x5015, OutWord, "sprmSNLnnMod", // sep.nLnnMod;non-neg int.;word;
+ 0x9016, OutWord, "sprmSDxaLnn", // sep.dxaLnn;dxa;word;
+ 0xB017, OutWord, "sprmSDyaHdrTop", // sep.dyaHdrTop;dya;word;
+ 0xB018, OutWord, "sprmSDyaHdrBottom", // sep.dyaHdrBottom;dya;word;
+ 0x3019, OutByte, "sprmSLBetween", // sep.fLBetween;0 or 1;byte;
+ 0x301A, OutByte, "sprmSVjc", // sep.vjc;vjc;byte;
+ 0x501B, OutWord, "sprmSLnnMin", // sep.lnnMin;lnn;word;
+ 0x501C, OutWord, "sprmSPgnStart", // sep.pgnStart;pgn;word;
+ 0x301D, OutByte, "sprmSBOrientation", // sep.dmOrientPage;dm;byte;
+//0x301E, ? ? ? , "sprmSBCustomize", // ;;;
+ 0xB01F, OutWord, "sprmSXaPage", // sep.xaPage;xa;word;
+ 0xB020, OutWord, "sprmSYaPage", // sep.yaPage;ya;word;
+ 0xB021, OutWord, "sprmSDxaLeft", // sep.dxaLeft;dxa;word;
+ 0xB022, OutWord, "sprmSDxaRight", // sep.dxaRight;dxa;word;
+ 0x9023, OutWord, "sprmSDyaTop", // sep.dyaTop;dya;word;
+ 0x9024, OutWord, "sprmSDyaBottom", // sep.dyaBottom;dya;word;
+ 0xB025, OutWord, "sprmSDzaGutter", // sep.dzaGutter;dza;word;
+ 0x5026, OutWord, "sprmSDmPaperReq", // sep.dmPaperReq;dm;word;
+ 0xD227, (FnOut)0,"sprmSPropRMark", // sep.fPropRMark, sep.ibstPropRMark, sep.dttmPropRMark ;complex (see below);variable length always recorded as 7 bytes;
+//0x3228, ? ? ? , "sprmSFBiDi", // ;;;
+//0x3229, ? ? ? , "sprmSFFacingCol", // ;;;
+//0x322A, ? ? ? , "sprmSFRTLGutter", // ;;;
+ 0x702B,OutLongHex,"sprmSBrcTop", // sep.brcTop;BRC;long;
+ 0x702C,OutLongHex,"sprmSBrcLeft", // sep.brcLeft;BRC;long;
+ 0x702D,OutLongHex,"sprmSBrcBottom", // sep.brcBottom;BRC;long;
+ 0x702E,OutLongHex,"sprmSBrcRight", // sep.brcRight;BRC;long;
+ 0x522F, OutWord, "sprmSPgbProp", // sep.pgbProp;;word;
+ 0x7030,OutLongHex,"sprmSDxtCharSpace", // sep.dxtCharSpace;dxt;long;
+ 0x9031,OutLongHex,"sprmSDyaLinePitch", // sep.dyaLinePitch;dya;long;
+//0x5032, ? ? ? , "sprmSClm", // ;;;
+ 0x5033, OutShort,"sprmSTextFlow", // sep.wTextFlow;complex (see below);short;
+ 0x5400, OutWord, "sprmTJc", // tap.jc;jc;word (low order byte is significant);
+ 0x9601, OutWord, "sprmTDxaLeft", // tap.rgdxaCenter (see below);dxa;word;
+ 0x9602, OutWord, "sprmTDxaGapHalf", // tap.dxaGapHalf, tap.rgdxaCenter (see below);dxa;word;
+ 0x3403, OutByte, "sprmTFCantSplit", // tap.fCantSplit;1 or 0;byte;
+ 0x3404, OutByte, "sprmTTableHeader", // tap.fTableHeader;1 or 0;byte;
+ 0xD605, (FnOut)0,"sprmTTableBorders", // tap.rgbrcTable;complex(see below);24 bytes;
+ 0xD606, (FnOut)0,"sprmTDefTable10", // tap.rgdxaCenter, tap.rgtc;complex (see below);variable length;
+ 0x9407, OutShort, "sprmTDyaRowHeight", // tap.dyaRowHeight;dya;word;
+ 0xD608, OutTabD608,"sprmTDefTable", // tap.rgtc;complex (see below);;
+ 0xD609, OutTabD609,"sprmTDefTableShd", // tap.rgshd;complex (see below);;
+ 0x740A, (FnOut)0,"sprmTTlp", // tap.tlp;TLP;4 bytes;
+//0x560B, ? ? ? , "sprmTFBiDi", // ;;;
+//0x740C, ? ? ? , "sprmTHTMLProps", // ;;;
+ 0xD620, (FnOut)0,"sprmTSetBrc", // tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7621, (FnOut)0,"sprmTInsert", // tap.rgdxaCenter, tap.rgtc;complex (see below);4 bytes;
+ 0x5622, OutWord, "sprmTDelete", // tap.rgdxaCenter, tap.rgtc;complex (see below);word;
+ 0x7623, (FnOut)0,"sprmTDxaCol", // tap.rgdxaCenter;complex (see below);4 bytes;
+ 0x5624, OutWord, "sprmTMerge", // tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0x5625, OutWord, "sprmTSplit", // tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0xD626, (FnOut)0,"sprmTSetBrc10", // tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7627, (FnOut)0,"sprmTSetShd", // tap.rgshd;complex (see below);4 bytes;
+ 0x7628, (FnOut)0,"sprmTSetShdOdd", // tap.rgshd;complex (see below);4 bytes;
+ 0x7629, OutWord, "sprmTTextFlow", // tap.rgtc[].fVerticaltap.rgtc[].fBackwardtap.rgtc[].fRotateFont;0 or 10 or 10 or 1;word;
+//0xD62A, ? ? ? , "sprmTDiagLine", // ;;;
+ 0xD62B, (FnOut)0,"sprmTVertMerge", // tap.rgtc[].vertMerge;complex (see below);variable length always recorded as 2 bytes;
+ 0xD62C, (FnOut)0,"sprmTVertAlign", // tap.rgtc[].vertAlign;complex (see below);variable length always recorded as 3 byte;
+};
+
+
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC )
+ _Optlink
+#endif
+ CompSprmDumpId( const void *pFirst, const void *pSecond)
+{
+ return( ((SprmDumpInfo*)pFirst )->nId - ((SprmDumpInfo*)pSecond)->nId );
+}
+
+
+SprmDumpInfo& WW8GetSprmDumpInfo( USHORT nId )
+{
+ // ggfs. Tab sortieren
+ static BOOL bInit = FALSE;
+ if( !bInit )
+ {
+ qsort( (void*)aSprmDumpTab,
+ sizeof( aSprmDumpTab ) / sizeof (aSprmDumpTab[ 0 ]),
+ sizeof( aSprmDumpTab[ 0 ] ),
+ CompSprmDumpId );
+ bInit = TRUE;
+ }
+ // Sprm heraussuchen
+ void* pFound;
+ SprmDumpInfo aSrch;
+ aSrch.nId = nId;
+ if( 0 == ( pFound = bsearch( (char *) &aSrch,
+ (void*) aSprmDumpTab,
+ sizeof( aSprmDumpTab ) / sizeof (aSprmDumpTab[ 0 ]),
+ sizeof( aSprmDumpTab[ 0 ] ),
+ CompSprmDumpId )))
+ {
+ // im Fehlerfall auf Nulltes Element verweisen
+ pFound = (void*)aSprmDumpTab;
+ }
+ return *(SprmDumpInfo*) pFound;
+}
+
+
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/dump/ww8darr.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.8 2000/09/18 16:05:03 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.7 1999/10/28 20:35:11 jp
+ write table shading vakues
+
+ Revision 1.6 1999/10/28 18:13:47 jp
+ write table height as short
+
+ Revision 1.5 1999/10/27 17:57:53 jp
+ changes for tables
+
+ Revision 1.4 1999/08/16 10:22:38 JP
+ neu: Dump EscherObjects
+
+
+ Rev 1.3 16 Aug 1999 12:22:38 JP
+ neu: Dump EscherObjects
+
+ Rev 1.2 15 Jun 1999 14:12:36 JP
+ new: ListTable and other Contents
+
+ Rev 1.1 10 Jun 1998 17:22:32 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:30:10 KHZ
+ Initial revision.
+
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/ww8/dump/ww8darr.hxx b/sw/source/filter/ww8/dump/ww8darr.hxx
new file mode 100644
index 000000000000..67c22e460f23
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8darr.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8darr.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WW8DARR_HXX
+#define _WW8DARR_HXX
+
+typedef void (*FnOut)( SvStream& rSt, short );
+
+struct SprmDumpInfo
+{
+ USHORT nId;
+ FnOut pOutFnc;
+ char* pName;
+};
+
+SprmDumpInfo& WW8GetSprmDumpInfo( USHORT nId );
+
+
+#endif
diff --git a/sw/source/filter/ww8/dump/ww8dout.cxx b/sw/source/filter/ww8/dump/ww8dout.cxx
new file mode 100644
index 000000000000..48eef00fc183
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8dout.cxx
@@ -0,0 +1,499 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8dout.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h> // getchar
+
+//#include "defs.hxx"
+#include <tools/solar.h> // BYTE
+//#include "wwscan.hxx" // aWwStor
+#include "ww8dout.hxx"
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+
+extern SvStorageStreamRef xStrm;
+extern SvStorageStreamRef xTableStream;
+extern SvStorageStreamRef xDataStream; // ist bei Ver6-7 mit xStrm identisch,
+void DumpSprms( BYTE nVersion, SvStream& rSt, short nLen );
+
+ostream* pOut = 0;
+
+#define DumpVer8
+
+//-----------------------------------------
+// Streams
+//-----------------------------------------
+
+
+static int level = 0;
+static long lastpos = -1;
+
+ostream& __cdecl endl1( ostream& s ){
+//ostream& endl1( ostream& s ) {
+ s << endl;
+ return s;
+}
+
+ostream& __cdecl hex2( ostream& s ) {
+ s.width( 2 ); s.fill( (const char)250 );
+ s << hex;
+ return s;
+}
+
+ostream& __cdecl hex4( ostream& s ) {
+ s.width( 4 ); s.fill( (const char)250 );
+ s << hex ;
+ return s;
+}
+
+ostream& __cdecl hex6( ostream& s ) {
+ s.width( 6 ); s.fill( (const char)250 );
+ s << hex ;
+ return s;
+}
+
+ostream& __cdecl hex8( ostream& s ) {
+ s.width( 8 ); s.fill( (const char)250 );
+ s << hex ;
+ return s;
+}
+
+ostream& __cdecl dec2( ostream& s ) {
+ s << dec;
+ s.width( 0 ); s.fill( 0 );
+ return s;
+}
+
+ostream& __cdecl filepos( ostream& s, SvStream& rSt ) {
+ register long pos = rSt.Tell();
+
+ if ( pos != lastpos ){
+#ifndef DumpVer8
+ if( &rSt == &xStrm )
+ s << "D";
+ else
+ s << "T";
+#endif
+ s.width( 6 );
+ s.fill( (const char)250 );
+ s << hex << pos << dec << ' ';
+ s.width( 0 ); s.fill( 0 );
+ lastpos = pos;
+ }else{
+#ifndef DumpVer8
+ s << " ";
+#else
+ s << " ";
+#endif
+ }
+ return s;
+}
+
+ostream& __cdecl indent( ostream& s, SvStream& rSt ) {
+ filepos( s, rSt );
+ for( int i = 0; i < level; i++ ) s << " ";
+ return s;
+}
+
+ostream& __cdecl indent1( ostream& s ) {
+ for( int i = 0; i < level; i++ ) s << " ";
+ return s;
+}
+
+ostream& __cdecl indent2( ostream& s ) {
+#ifndef DumpVer8
+ s << " " << indent1;
+#else
+ s << " " << indent1;
+#endif
+ return s;
+}
+
+ostream& __cdecl begin( ostream& s, SvStream& rSt ) { indent( s, rSt ) << "BEGIN "; level++; return s; }
+
+// begin1 ohne indent
+ostream& __cdecl begin1( ostream& s ) { s << "BEGIN "; level++; return s; }
+
+// begin2 ohne Nummer
+ostream& __cdecl begin2( ostream& s ) { s << indent2 << "BEGIN "; level++; return s; }
+
+ostream& __cdecl end( ostream& s, SvStream& rSt ) { level--; return indent( s, rSt ) << "END "; }
+
+// end1 ohne filepos
+ostream& __cdecl end1( ostream& s ) { level--; return s << indent1 << "END "; }
+
+// end2 ohne Nummer
+ostream& __cdecl end2( ostream& s ) { level--; return s << indent2 << "END "; }
+
+//-----------------------------------------
+// Ausgabe-Funktionen
+//-----------------------------------------
+
+void OutBool( SvStream& rSt, short )
+{
+ BYTE nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ switch( nPara ){
+ case 0: *pOut << "F"; break;
+ case 1: *pOut << "T"; break;
+ default: *pOut << "ERROR:" << (USHORT)nPara; break;
+ }
+}
+
+void OutBool4( SvStream& rSt, short )
+{
+ BYTE nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ switch( nPara ){
+ case 0: *pOut << "F"; break;
+ case 1: *pOut << "T"; break;
+ case 128: *pOut << "==Style"; break;
+ case 129: *pOut << "!=Style"; break;
+ default: *pOut << "ERROR:" << (USHORT)nPara; break;
+ }
+}
+
+void OutByte( SvStream& rSt, short )
+{
+ BYTE nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << (USHORT)nPara;
+}
+
+void OutShort( SvStream& rSt, short )
+{
+ short nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << nPara;
+}
+
+void OutShorts( SvStream& rSt, short nLen )
+{
+ INT16 nPara;
+
+ for( short i = 0; i < nLen / 2; i++ ){
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << nPara << ' ';
+ }
+}
+
+void OutWord( SvStream& rSt, short )
+{
+ USHORT nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << nPara;
+}
+
+void OutWords( SvStream& rSt, short nLen )
+{
+ USHORT nPara;
+
+ for( short i = 0; i < nLen / 2; i++ ){
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << nPara;
+ }
+}
+
+void OutWordHex( SvStream& rSt, short )
+{
+ USHORT nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << "0x" << hex4 << nPara << dec;
+}
+
+void OutWordsHex( SvStream& rSt, short nLen )
+{
+ USHORT nPara;
+ nLen /= sizeof( nPara );
+ for( short i = 0; i < nLen; i++ ){
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << "0x" << hex4 << nPara << dec;
+ if( i < nLen - 1 )
+ *pOut << ' ';
+ }
+}
+
+void OutLongsHex( SvStream& rSt, short nLen )
+{
+ long nPara;
+ nLen /= sizeof( nPara );
+ for( short i = 0; i < nLen; i++ )
+ {
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << "0x" << hex8 << nPara << dec;
+ if( i < nLen - 1 )
+ *pOut << ' ';
+ }
+}
+
+void OutLongHex( SvStream& rSt, short )
+{
+ ULONG nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ *pOut << "0x" << hex8 << nPara << dec;
+}
+
+void OutTab68( SvStream& rSt, short )
+{
+ ULONG nPara;
+
+ rSt.Read( &nPara, sizeof( nPara ) );
+ if( nPara == 0 )
+ *pOut << "None";
+ else
+ *pOut << "0x" << hex8 << nPara << dec;
+}
+
+
+void OutTab( SvStream& rSt, short )
+{
+ BYTE nDel, nIns, nType;
+ short nPos, i;
+
+ rSt.Read( &nDel, sizeof( nDel ) );
+ *pOut << "Del " << (USHORT)nDel;
+ if ( nDel ) *pOut << ": ";
+ else *pOut << ", ";
+
+ for( i=1; i<=nDel; i++){
+ rSt.Read( &nPos, sizeof( nPos ) );
+ *pOut << nPos;
+ if( i<nDel ) *pOut << ',';
+ else *pOut << ' ';
+ }
+ rSt.Read( &nIns, sizeof( nIns ) );
+ *pOut << "Ins " << (USHORT)nIns;
+ if ( nIns ) *pOut << ": ";
+
+ for( i=1; i<=nIns; i++){
+ rSt.Read( &nPos, sizeof( nPos ) );
+ *pOut << nPos;
+ if( i<nIns ) *pOut << ',';
+ else *pOut << ' ';
+ }
+ if ( nIns ) *pOut << "Typ: ";
+
+ for( i=1; i<=nIns; i++){
+ rSt.Read( &nType, sizeof( nType ) );
+ *pOut << (USHORT)nType;
+ if( i<nIns ) *pOut << ',';
+ else *pOut << ' ';
+ }
+
+// nSiz = 1 + 2 * nDel + 1 + nIns * 3; // genaue Laenge,
+// stimmt auch bei Laenge > 256
+// bei diesem Tab-Befehl anscheinend nicht noetig
+}
+
+void OutTab190( SvStream& rSt, short nLen )
+{
+ BYTE nCols;
+ rSt.Read( &nCols, sizeof( nCols ) );
+ *pOut << (USHORT)nCols << " Cols: ";
+
+ short nPos, i;
+ for( i = 0; i <= nCols; i++ ){
+ rSt.Read( &nPos, sizeof( nPos ) );
+ *pOut << nPos;
+ if( i < nCols )
+ *pOut << ", ";
+ }
+ *pOut << dec << "; ";
+ for( i = 0; i < nCols; i++ ){
+ *pOut << "Col " << i << " TC: ";
+ OutWordsHex( rSt, 10 );
+ if( i < nCols - 1 )
+ *pOut << "; ";
+ }
+}
+
+void OutTab191( SvStream& rSt, short nLen )
+{
+ BYTE nCols;
+ rSt.Read( &nCols, sizeof( nCols ) );
+ *pOut << (USHORT)nCols << " Cols, SHDs: ";
+ OutWordsHex( rSt, ( nCols + 1 ) * 2 );
+}
+
+void OutTab192( SvStream& rSt, short )
+{
+ OutWord( rSt, 0 );
+ OutWordHex( rSt, 0 );
+}
+
+void OutHugeHex( SvStream& rSt, short nLen )
+{
+ long nPos;
+ rSt.Read( &nPos, sizeof( nPos ) );
+
+ long nCurr = xDataStream->Tell();
+ xDataStream->Seek( nPos );
+
+ xDataStream->Read( &nLen, sizeof( nLen ) );
+
+// *pOut << ", Len max: " << nLen << ", ID:" << nIStd << endl1;
+ *pOut << endl1;
+ DumpSprms( 8, *xDataStream, nLen );
+
+ xDataStream->Seek( nCurr );
+}
+
+void OutTabD608( SvStream& rSt, short nLen )
+{
+ BYTE nHi, nCols;
+ rSt.Read( &nHi, sizeof( nHi ) );
+// nLen += ((short)nHi) << 8;
+
+ rSt.Read( &nCols, sizeof( nCols ) );
+ *pOut << " Cols: " << (short)nCols << ' ' << endl1 << indent2;
+
+ short nPos, i;
+ for( i = 0; i <= nCols; ++i )
+ {
+ rSt.Read( &nPos, sizeof( nPos ) );
+ *pOut << nPos;
+ if( i < nCols )
+ *pOut << ", ";
+ }
+ nLen -= ( nCols + 1 ) * 2;
+ nLen /= 20;
+
+ for( i = 0; i < nLen; ++i )
+ {
+ *pOut << endl1 << indent2 << "Col " << i << " TC: ";
+ OutLongsHex( rSt, 20 );
+ if( i < nLen - 1 )
+ *pOut << "; ";
+ }
+}
+
+void OutTabD609( SvStream& rSt, short nLen )
+{
+ *pOut << " Brush(FBS): ";
+ for( short i = 0; i < nLen / 2; ++i )
+ {
+ UINT16 nVal;
+ rSt.Read( &nVal, sizeof( nVal ) );
+ *pOut << (nVal & 0x1f);
+ *pOut << "|" << ((nVal >> 5) & 0x1f);
+ *pOut << "|" << ((nVal >> 10) & 0x3f);
+ if( i < nLen )
+ *pOut << ", ";
+ }
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/dump/ww8dout.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.9 2000/09/18 16:05:03 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.8 2000/02/11 14:39:38 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.7 1999/11/02 18:06:52 jp
+ Dump of hugepapx
+
+ Revision 1.6 1999/10/28 20:35:15 jp
+ write table shading vakues
+
+ Revision 1.5 1999/10/27 17:58:09 jp
+ changes for tables
+
+ Revision 1.4 1999/06/15 12:14:44 JP
+ new: ListTable and other Contents
+
+
+ Rev 1.3 15 Jun 1999 14:14:44 JP
+ new: ListTable and other Contents
+
+ Rev 1.2 25 Jun 1998 15:44:42 KHZ
+ Strukturaenderung fuer PAPX FKPs
+
+ Rev 1.1 10 Jun 1998 17:22:34 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:30:18 KHZ
+ Initial revision.
+
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/ww8/dump/ww8dout.hxx b/sw/source/filter/ww8/dump/ww8dout.hxx
new file mode 100644
index 000000000000..1b7fca2b33fd
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8dout.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8dout.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WW8DOUT_HXX
+#define _WW8DOUT_HXX
+
+#ifndef INC_FSTREAM
+ #include <fstream.h> // ostream
+#endif
+#ifndef SOLAR_H
+ #include <tools/solar.h> // BYTE
+#endif
+
+class SvStream;
+
+void OutByte( SvStream& rSt, short nLen );
+void OutBool( SvStream& rSt, short nLen );
+void OutShort( SvStream& rSt, short );
+void OutShorts( SvStream& rSt, short nLen );
+void OutWord( SvStream& rSt, short );
+void OutWords( SvStream& rSt, short nLen );
+void OutWordHex( SvStream& rSt, short );
+void OutWordsHex( SvStream& rSt, short );
+void OutLongHex( SvStream& rSt, short );
+void OutLongsHex( SvStream& rSt, short nLen );
+void OutTab( SvStream& rSt, short nLen );
+void OutTab68( SvStream& rSt, short nLen );
+void OutTab190( SvStream& rSt, short nLen );
+void OutTab191( SvStream& rSt, short nLen );
+void OutTab192( SvStream& rSt, short nLen );
+void OutBool4( SvStream& rSt, short nLen );
+void OutHugeHex( SvStream& rSt, short nLen );
+void OutTabD608( SvStream& rSt, short nLen );
+void OutTabD609( SvStream& rSt, short nLen );
+
+
+// unter WNTMSCI4 muss das __cdecl sein, damit nicht nur der Fkt-Pointer
+// ausgegeben wird....
+
+ostream& __cdecl filepos( ostream& s, SvStream& rSt );
+
+ostream& __cdecl endl1( ostream& s );
+ostream& __cdecl indent( ostream& s, SvStream& rSt );
+ostream& __cdecl indent1( ostream& s );
+ostream& __cdecl indent2( ostream& s );
+ostream& __cdecl hex2( ostream& s );
+ostream& __cdecl hex4( ostream& s );
+ostream& __cdecl hex6( ostream& s );
+ostream& __cdecl hex8( ostream& s );
+ostream& __cdecl dec2( ostream& s );
+
+ostream& __cdecl begin( ostream& s, SvStream& rSt );
+ostream& __cdecl begin1( ostream& s );
+ostream& __cdecl begin2( ostream& s );
+ostream& __cdecl end( ostream& s, SvStream& rSt );
+ostream& __cdecl end1( ostream& s );
+ostream& __cdecl end2( ostream& s );
+
+extern ostream* pOut;
+
+
+#endif
diff --git a/sw/source/filter/ww8/dump/ww8scan.cxx b/sw/source/filter/ww8/dump/ww8scan.cxx
new file mode 100644
index 000000000000..f9dc437ab63b
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8scan.cxx
@@ -0,0 +1,6049 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8scan.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <stdlib.h>
+
+#ifdef PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef PCH
+#include <string.h> // memset()
+
+#if defined( UNX) || defined( MAC)
+int svstricmp( const char* pStr1, const char* pStr2);
+// tools/source/generic/string2.cxx
+#endif
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_SHORTS
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_USHORTSSORT
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifdef DUMP
+ #define ERR_SWG_READ_ERROR 1234
+ #include <assert.h>
+ #define ASSERT( a, b )
+#else
+ #include "swerror.h" // ERR_WW6_...
+ #include "errhdl.hxx" // ASSERT()
+ #include "swtypes.hxx" // DELETEZ
+#endif
+#endif
+
+#ifndef _DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+
+
+//-----------------------------------------
+// Debug-Code fuer Fastsave-Dateien
+//( Kram, um die Strukturen unter CV besser im Debugger untersuchen zu koennen )
+//-----------------------------------------
+#if defined DEBUG //&& !defined __WW_NEEDS_COPY
+#define DEBUG_STRUCT
+#endif
+
+#ifdef DEBUG_STRUCT
+# ifdef __WW8_NEEDS_PACK
+# pragma pack(2)
+# endif
+struct WW8_PCD1
+{
+ INT16 fNoParaLast : 1; // when 1, means that piece contains no end of paragraph marks.
+// BYTE fPaphNil : 1; // used internally by Word
+// BYTE fCopied : 1; // used internally by Word
+// * int :5
+// BYTE aBits2; // fn int:8, used internally by Word
+ INT32 fc; // file offset of beginning of piece. The size of the
+ INT16 prm; // PRM contains either a single sprm or else an index number
+};
+# ifdef __WW8_NEEDS_PACK
+# pragma pack()
+# endif
+#endif // DEBUG_STRUCT
+
+
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta );
+
+
+
+WW8SprmIter::WW8SprmIter(BYTE* pSprms_, short nLen_, BYTE nVersion_ )
+ : pSprms( pSprms_), nRemLen( nLen_), nVersion( nVersion_),
+ nDelta( ( 8 > nVersion ) ? 0 : 1 )
+{
+ UpdateMyMembers();
+}
+
+void WW8SprmIter::SetSprms(BYTE* pSprms_, short nLen_)
+{
+ pSprms = pSprms_;
+ nRemLen = nLen_;
+ UpdateMyMembers();
+}
+
+BYTE* WW8SprmIter::operator ++( int )
+{
+ if( 0 < nRemLen )
+ {
+ pSprms += nAktSizeBrutto;
+ nRemLen -= nAktSizeBrutto;
+ UpdateMyMembers();
+ }
+ return pSprms;
+}
+
+void WW8SprmIter::UpdateMyMembers()
+{
+ if( pSprms && (0 < nRemLen) )
+ {
+ nAktId = WW8GetSprmId( nVersion, pSprms );
+ pAktParams = pSprms + 1 + nDelta + WW8SprmDataOfs( nAktId );
+ nAktSizeBrutto = WW8GetSprmSizeBrutto( nVersion, pSprms, &nAktId );
+ }
+ else
+ {
+ nAktId = 0;
+ pAktParams = 0;
+ nAktSizeBrutto = 0;
+ nRemLen = 0;
+ }
+}
+
+
+
+//-----------------------------------------
+// temporaerer Test
+//-----------------------------------------
+// WW8PLCFx_PCDAttrs halten sich an WW8PLCF_Pcd fest und besitzen deshalb keine
+// eigenen Iteratoren. Alle sich auf Iteratoren beziehenden Methoden
+// sind deshalb Dummies.
+
+WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs( BYTE nVersion, WW8PLCFx_PCD* pPLCFx_PCD, WW8ScannerBase* pBase )
+: WW8PLCFx( nVersion, TRUE ),
+ pPcd( pPLCFx_PCD ),
+ pGrpprls( pBase->pPieceGrpprls ),
+ nGrpprls( pBase->nPieceGrpprls ),
+ pPcdI( pPLCFx_PCD->GetPLCFIter() )
+{
+}
+
+WW8PLCFx_PCDAttrs::~WW8PLCFx_PCDAttrs()
+{
+}
+
+ULONG WW8PLCFx_PCDAttrs::GetIdx()
+{
+ return 0;
+}
+
+void WW8PLCFx_PCDAttrs::SetIdx( ULONG )
+{
+}
+
+BOOL WW8PLCFx_PCDAttrs::SeekPos( WW8_CP n )
+{
+ return TRUE;
+}
+
+WW8PLCFx& WW8PLCFx_PCDAttrs::operator ++( int )
+{
+ return *this;
+}
+
+WW8_CP WW8PLCFx_PCDAttrs::Where()
+{
+ return ( pPcd ) ? pPcd->Where() : LONG_MAX;
+}
+
+void WW8PLCFx_PCDAttrs::GetSprms( WW8PLCFxDesc* p )
+{
+ void* pData;
+
+ p->bRealLineEnd = FALSE;
+ if( !pPcdI
+ || !pPcdI->Get( p->nStartPos, p->nEndPos, pData ))
+ {
+ p->nStartPos = p->nEndPos = LONG_MAX; // PLCF fertig abgearbeitet
+ p->pMemPos = 0;
+ return;
+ }
+ UINT16 nPrm = SVBT16ToShort( ( (WW8_PCD*)pData )->prm );
+
+ if ( nPrm & 1 )
+ { // PRM Variante 2
+ UINT16 nSprmIdx = nPrm >> 1;
+
+ if( nSprmIdx >= nGrpprls ){
+ p->nStartPos = p->nEndPos = LONG_MAX; // Bloedsinniger Index
+ p->pMemPos = 0;
+ return;
+ }
+ BYTE* pSprms = (BYTE*)( pGrpprls[nSprmIdx] );
+
+ p->nSprmsLen = SVBT16ToShort( pSprms ); // Laenge
+ pSprms += 2;
+ p->pMemPos = pSprms; // Position
+ }
+ else
+ { // PRM Variante 1: Sprm wird direkt in Member-Var abgelegt
+ /*
+ Dies sind die Attr, die in der Piece-Table stehen, statt im Text !
+ */
+
+ if(8 > GetVersion())
+ {
+ aShortSprm[0] = (BYTE)( ( nPrm & 0xfe) >> 1 );
+ aShortSprm[1] = (BYTE)( nPrm >> 8 );
+ p->nSprmsLen = ( nPrm ) ? 2 : 0; // Laenge
+
+ // store Postion of internal mini storage in Data Pointer
+ p->pMemPos = aShortSprm;
+ }
+ else
+ {
+ p->pMemPos = 0;
+ BYTE nSprmListIdx = (BYTE)((nPrm & 0xfe) >> 1);
+ if( nSprmListIdx )
+ {
+ // process Sprm Id Matching as explained in MS Doku
+ //
+ // ''Property Modifier(variant 1) (PRM)''
+ // see file: s62f39.htm
+ //
+ // Since isprm is 7 bits, rgsprmPrm can hold 0x80 entries.
+ static USHORT __READONLY_DATA aSprmId[0x80] = {
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0x2402,0x2403,0x2404,0x2405,// sprmPIncLvl, sprmPJc, sprmPFSideBySide, sprmPFKeep
+ 0x2406,0x2407,0x2408,0x2409,// sprmPFKeepFollow, sprmPFPageBreakBefore, sprmPBrcl, sprmPBrcp
+ 0x260A, 0,0x240C, 0,// sprmPIlvl, sprmNoop, sprmPFNoLineNumb, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0x2416,0x2417, 0, 0,// sprmPFInTable, sprmPFTtp, sprmNoop, sprmNoop
+ 0,0x261B, 0, 0,// sprmNoop, sprmPPc, sprmNoop, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0,0x2423, 0, 0,// sprmNoop, sprmPWr, sprmNoop, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0x242A, 0, 0, 0,// sprmPFNoAutoHyph, sprmNoop, sprmNoop, sprmNoop
+ 0, 0,0x2430,0x2431,// sprmNoop, sprmNoop, sprmPFLocked, sprmPFWidowControl
+ 0,0x2433,0x2434,0x2435,// sprmNoop, sprmPFKinsoku, sprmPFWordWrap, sprmPFOverflowPunct
+ 0x2436,0x2437,0x2438, 0,// sprmPFTopLinePunct, sprmPFAutoSpaceDE, sprmPFAutoSpaceDN, sprmNoop
+ 0,0x243B, 0, 0,// sprmNoop, sprmPISnapBaseLine, sprmNoop, sprmNoop
+ 0,0x0800,0x0801,0x0802,// sprmNoop, sprmCFStrikeRM, sprmCFRMark, sprmCFFldVanish
+ 0, 0, 0,0x0806,// sprmNoop, sprmNoop, sprmNoop, sprmCFData
+ 0, 0, 0,0x080A,// sprmNoop, sprmNoop, sprmNoop, sprmCFOle2
+ 0,0x2A0C,0x0858,0x2859,// sprmNoop, sprmCHighlight, sprmCFEmboss, sprmCSfxText
+ 0, 0, 0,0x2A33,// sprmNoop, sprmNoop, sprmNoop, sprmCPlain
+ 0,0x0835,0x0836,0x0837,// sprmNoop, sprmCFBold, sprmCFItalic, sprmCFStrike
+ 0x0838,0x0839,0x083a,0x083b,// sprmCFOutline, sprmCFShadow, sprmCFSmallCaps, sprmCFCaps,
+ 0x083C, 0,0x2A3E, 0,// sprmCFVanish, sprmNoop, sprmCKul, sprmNoop,
+ 0, 0,0x2A42, 0,// sprmNoop, sprmNoop, sprmCIco, sprmNoop,
+ 0x2A44, 0,0x2A46, 0,// sprmCHpsInc, sprmNoop, sprmCHpsPosAdj, sprmNoop,
+ 0x2A48, 0, 0, 0,// sprmCIss, sprmNoop, sprmNoop, sprmNoop,
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop,
+ 0, 0, 0,0x2A53,// sprmNoop, sprmNoop, sprmNoop, sprmCFDStrike,
+ 0x0854,0x0855,0x0856,0x2E00,// sprmCFImprint, sprmCFSpec, sprmCFObj, sprmPicBrcl,
+ 0x2640, 0, 0, 0,// sprmPOutLvl, sprmNoop, sprmNoop, sprmNoop,
+ 0, 0, 0, 0 // sprmNoop, sprmNoop, sprmPPnbrRMarkNot
+ }; // ^^^^^^^^^^^^^^^^^ unknown name!
+
+ // find real Sprm Id:
+ USHORT nSprmId = aSprmId[ nSprmListIdx ];
+
+ if( nSprmId )
+ {
+ // move Sprm Id and Sprm Param to internal mini storage:
+ aShortSprm[0] = (BYTE)( ( nSprmId & 0x00ff) );
+ aShortSprm[1] = (BYTE)( ( nSprmId & 0xff00) >> 8 );
+ aShortSprm[2] = (BYTE)( nPrm >> 8 );
+
+ // store Sprm Length in member:
+ p->nSprmsLen = ( nPrm ) ? 3 : 0;
+
+ // store Postion of internal mini storage in Data Pointer
+ p->pMemPos = aShortSprm;
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+WW8PLCFx_PCD::WW8PLCFx_PCD( BYTE nVersion, WW8PLCFpcd* pPLCFpcd,
+ WW8_CP nStartCp, BOOL bVer67P )
+ : WW8PLCFx( nVersion, FALSE )
+{
+ pPcdI = new WW8PLCFpcd_Iter( *pPLCFpcd, nStartCp ); // eigenen Iterator konstruieren
+ bVer67= bVer67P;
+}
+
+WW8PLCFx_PCD::~WW8PLCFx_PCD()
+{ // pPcd-Dtor wird in WW8ScannerBase gerufen
+ delete( pPcdI );
+}
+
+ULONG WW8PLCFx_PCD::GetIdx()
+{
+ return ( pPcdI ) ? pPcdI->GetIdx() : 0;
+}
+
+void WW8PLCFx_PCD::SetIdx( ULONG nIdx )
+{
+ if( pPcdI )
+ pPcdI->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_PCD::SeekPos( WW8_CP nCpPos )
+{
+ return ( pPcdI ) ? pPcdI->SeekPos( nCpPos ) : FALSE;
+}
+
+WW8_CP WW8PLCFx_PCD::Where()
+{
+ return ( pPcdI ) ? pPcdI->Where() : LONG_MAX;
+}
+
+long WW8PLCFx_PCD::GetNoSprms( long& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ rLen = 0;
+
+ if( !pPcdI
+ || !pPcdI->Get( rStart, rEnd, pData ) )
+ {
+ rStart = rEnd = LONG_MAX;
+ return -1;
+ }
+ return pPcdI->GetIdx();
+}
+
+WW8PLCFx& WW8PLCFx_PCD::operator ++( int )
+{
+ if( !pPcdI ){
+ ASSERT( ASS_FALSE, "pPcdI fehlt");
+ }else{
+ (*pPcdI)++;
+ }
+ return *this;
+}
+
+WW8_FC WW8PLCFx_PCD::AktPieceStartCp2Fc( WW8_CP nCp )
+{
+ WW8_CP nCpStart, nCpEnd;
+ void* pData;
+
+ if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) ){
+ ASSERT( ASS_FALSE, "AktPieceStartCp2Fc() mit falschem Cp gerufen (1)" );
+ return LONG_MAX;
+ }
+
+ ASSERT( nCp >= nCpStart && nCp < nCpEnd,
+ "AktPieceCp2Fc() mit falschem Cp gerufen (2)" );
+
+ if( nCp < nCpStart )
+ nCp = nCpStart;
+ if( nCp >= nCpEnd )
+ nCp = nCpEnd - 1;
+
+ BOOL bIsUnicode = FALSE;
+ WW8_FC nFC = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( !bVer67 )
+ nFC = WW8PLCFx_PCD::TransformPieceAddress( nFC, bIsUnicode );
+
+ return nFC + (nCp - nCpStart) * (bIsUnicode ? 2 : 1);
+}
+
+
+eCutT WW8PLCFx_PCD::AktPieceFc2Cp( long& rStartPos, long& rEndPos )
+{
+ WW8_CP nCpStart, nCpEnd;
+ void* pData;
+ eCutT eRet = CUT_NONE;
+
+ if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) ){
+ ASSERT( ASS_FALSE, "AktPieceFc2Cp() - Fehler" );
+ rStartPos = rEndPos = LONG_MAX;
+ return CUT_BOTH;
+ }
+
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( !bVer67 )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
+
+ INT32 nUnicodeFactor = bIsUnicode ? 2 : 1;
+
+ if( rStartPos < nFcStart )
+ {
+ rStartPos = nFcStart;
+ eRet = (eCutT)( eRet | CUT_START );
+ }
+ if( rStartPos >= nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
+ {
+ rStartPos = nFcStart + (nCpEnd - nCpStart - 1) * nUnicodeFactor;
+ eRet = (eCutT)( eRet | CUT_START );
+ }
+ // jetzt CP berechnen
+ rStartPos = nCpStart + (rStartPos - nFcStart) / nUnicodeFactor;
+
+
+ if( rEndPos < nFcStart )
+ {
+ rEndPos = nFcStart;
+ eRet = (eCutT)( eRet | CUT_END );
+ }
+ if( rEndPos > nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
+ {
+ rEndPos = nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor;
+ eRet = (eCutT)( eRet | CUT_END );
+ }
+ // jetzt CP berechnen
+ rEndPos = nCpStart + (rEndPos - nFcStart) / nUnicodeFactor;
+#ifdef DEBUG
+ if (0 > rStartPos)
+ {
+ BOOL i = 5;
+ }
+ ASSERT( (0 <= rStartPos), "AktPieceFc2Cp() - rStartPos kleiner Null!" );
+#endif
+ return eRet;
+}
+
+WW8_CP WW8PLCFx_PCD::AktPieceStartFc2Cp( WW8_FC nStartPos )
+{
+ WW8_CP nCpStart, nCpEnd;
+ void* pData;
+
+ if( nStartPos == LONG_MAX )
+ return LONG_MAX;
+
+ if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) )
+ {
+ ASSERT( ASS_FALSE, "AktPieceStartFc2Cp() - Fehler" );
+ return LONG_MAX;
+ }
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( !bVer67 )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
+
+
+ INT32 nUnicodeFactor = bIsUnicode ? 2 : 1;
+
+ if( nStartPos < nFcStart )
+ nStartPos = nFcStart;
+
+ if( nStartPos >= nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
+ nStartPos = nFcStart + (nCpEnd - nCpStart - 1) * nUnicodeFactor;
+
+ return nCpStart + (nStartPos - nFcStart) / nUnicodeFactor;
+}
+
+
+
+//-----------------------------------------
+// Hilfsroutinen fuer alle
+//-----------------------------------------
+
+DateTime WW8ScannerBase::WW8DTTM2DateTime(long lDTTM)
+{
+/*
+mint short :6 0000003F minutes (0-59)
+hr short :5 000007C0 hours (0-23)
+dom short :5 0000F800 days of month (1-31)
+mon short :4 000F0000 months (1-12)
+yr short :9 1FF00000 years (1900-2411)-1900
+wdy short :3 E0000000 weekday(Sunday=0
+ Monday=1
+( wdy can be ignored ) Tuesday=2
+ Wednesday=3
+ Thursday=4
+ Friday=5
+ Saturday=6)
+*/
+ DateTime aDateTime(Date( 0 ), Time( 0 ));
+ if( lDTTM )
+ {
+ USHORT lMin =(USHORT)(lDTTM & 0x0000003F);
+ lDTTM >>= 6;
+ USHORT lHour=(USHORT)(lDTTM & 0x0000001F);
+ lDTTM >>= 5;
+ USHORT lDay =(USHORT)(lDTTM & 0x0000001F);
+ lDTTM >>= 5;
+ USHORT lMon =(USHORT)(lDTTM & 0x0000000F);
+ lDTTM >>= 4;
+ USHORT lYear=(USHORT)(lDTTM & 0x000001FF) + 1900;
+ aDateTime = DateTime(Date(lDay, lMon, lYear), Time(lHour, lMin));
+ }
+ return aDateTime;
+}
+
+WW8_CP WW8ScannerBase::WW8Fc2Cp( WW8_FC nFcPos ) const
+{
+ if( nFcPos == LONG_MAX )
+ return LONG_MAX;
+
+ if( pPieceIter )
+ { // Complex File ?
+ ULONG nOldPos = pPieceIter->GetIdx();
+ pPieceIter->SetIdx( 0 );
+ while( 1 )
+ {
+ long nCpStart, nCpEnd;
+ void* pData;
+ if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
+ { // ausserhalb PLCFfpcd ?
+ ASSERT( !this, "PLCFpcd-WW8Fc2Cp() ging schief" );
+ break;
+// pPieceIter->SetIdx( nOldPos );
+// return 0;
+ }
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( 8 <= pWw8Fib->nVersion )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart,
+ bIsUnicode );
+
+ INT32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1);
+
+ if( nFcPos >= nFcStart && nFcPos < nFcStart + nLen )
+ { // gefunden
+ pPieceIter->SetIdx( nOldPos );
+
+ return nCpStart + ((nFcPos - nFcStart) / (bIsUnicode ? 2 : 1));
+ }
+ (*pPieceIter)++;
+ }
+ pPieceIter->SetIdx( nOldPos ); // nicht gefunden
+ return LONG_MAX;
+ }
+ // No complex file
+ return nFcPos - pWw8Fib->fcMin;
+}
+
+WW8_FC WW8ScannerBase::WW8Cp2Fc( WW8_CP nCpPos, BOOL* pIsUnicode,
+ WW8_CP* pNextPieceCp, BOOL* pTestFlag ) const
+{
+ if( pTestFlag )
+ *pTestFlag = TRUE;
+ if( LONG_MAX == nCpPos )
+ return LONG_MAX;
+
+ if( pPieceIter )
+ { // Complex File
+ if( pNextPieceCp )
+ *pNextPieceCp = LONG_MAX;
+
+ if( !pPieceIter->SeekPos( nCpPos ) )
+ {
+ if( pTestFlag )
+ *pTestFlag = FALSE;
+ else
+ ASSERT( !this, "Falscher CP an WW8Cp2Fc() uebergeben" );
+ return LONG_MAX;
+ }
+ long nCpStart, nCpEnd;
+ void* pData;
+ if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
+ {
+ if( pTestFlag )
+ *pTestFlag = FALSE;
+ else
+ ASSERT( ASS_FALSE, "PLCFfpcd-Get ging schief" );
+ return LONG_MAX;
+ }
+ if( pNextPieceCp )
+ *pNextPieceCp = nCpEnd;
+ BOOL bIsUnicode;
+ if( !pIsUnicode )
+ pIsUnicode = &bIsUnicode;
+
+ WW8_FC nRet = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( 8 > pWw8Fib->nVersion )
+ *pIsUnicode = FALSE;
+ else
+ nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode );
+
+
+ nRet += (nCpPos - nCpStart) * (*pIsUnicode ? 2 : 1);
+
+ return nRet;
+ }
+
+ // No complex file
+ if( pIsUnicode )
+ *pIsUnicode = FALSE;
+ return nCpPos + pWw8Fib->fcMin;
+}
+
+//-----------------------------------------
+// class WW8ScannerBase
+//-----------------------------------------
+
+WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, WW8Fib* pWwF )
+{
+ if( ( (8 > pWw8Fib->nVersion)
+ && !pWwF->fComplex
+ )
+ || !pWwF->lcbClx ) return 0;
+
+ WW8_FC nClxPos = pWwF->fcClx;
+ INT32 nClxLen = pWwF->lcbClx;
+ register INT32 nLeft = nClxLen;
+ INT16 nGrpprl = 0;
+ BYTE clxt;
+
+ pStr->Seek( nClxPos );
+ while( 1 ){ // Zaehle Zahl der Grpprls
+ *pStr >> clxt;
+ nLeft--;
+ if( 2 == clxt ) // PLCFfpcd ?
+ break; // PLCFfpcd gefunden
+ if( 1 == clxt ) // clxtGrpprl ?
+ nGrpprl++;
+ UINT16 nLen;
+ *pStr >> nLen;
+ nLeft -= 2 + nLen;
+ if( nLeft < 0 )
+ return 0; // schiefgegangen
+ pStr->SeekRel( nLen ); // ueberlies grpprl
+ }
+ pStr->Seek( nClxPos );
+ nLeft = nClxLen;
+ pPieceGrpprls = new char*[nGrpprl + 1];
+ memset( pPieceGrpprls, 0, ( nGrpprl + 1 ) * 4 );
+ nPieceGrpprls = nGrpprl;
+ INT16 nAktGrpprl = 0; // lies Grpprls ein
+ while( 1 )
+ {
+ *pStr >> clxt;
+ nLeft--;
+ if( 2 == clxt) // PLCFfpcd ?
+ break; // PLCFfpcd gefunden
+ UINT16 nLen;
+ *pStr >> nLen;
+ nLeft -= 2 + nLen;
+ if( nLeft < 0 )
+ return 0; // schiefgegangen
+ if( 1 == clxt ) // clxtGrpprl ?
+ {
+ char* p = new char[nLen+2]; // alloziere
+ memcpy( p, &nLen, 2 ); // trage Laenge ein
+ pStr->Read( p+2, nLen ); // lies grpprl
+ pPieceGrpprls[nAktGrpprl++] = p; // trage in Array ein
+ }
+ else
+ pStr->SeekRel( nLen ); // ueberlies nicht-Grpprl
+ }
+ // lies Piece Table PLCF ein
+ INT32 nPLCFfLen;
+ *pStr >> nPLCFfLen;
+ ASSERT( 65536 > nPLCFfLen, "PLCFfpcd ueber 64 k" );
+ return new WW8PLCFpcd( pStr, pStr->Tell(), nPLCFfLen, 8 );
+}
+
+void WW8ScannerBase::DeletePieceTable()
+{
+ if( pPieceGrpprls )
+ {
+ for( char** p = pPieceGrpprls; *p; p++ )
+ delete[]( *p );
+ delete[]( pPieceGrpprls );
+ pPieceGrpprls = 0;
+ }
+}
+
+WW8ScannerBase::WW8ScannerBase( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ WW8Fib* pWwFib )
+ : pWw8Fib( pWwFib ), pPieceGrpprls( 0 ),
+ pMainFdoa( 0 ), pHdFtFdoa( 0 ),
+ pMainTxbx( 0 ), pMainTxbxBkd( 0 ), pHdFtTxbx( 0 ), pHdFtTxbxBkd( 0 )
+{
+ pPiecePLCF = OpenPieceTable( pTblSt, pWw8Fib ); // Complex
+ if( pPiecePLCF )
+ {
+ pPieceIter = new WW8PLCFpcd_Iter( *pPiecePLCF );
+ pPLCFx_PCD = new WW8PLCFx_PCD( pWwFib->nVersion, pPiecePLCF, 0,
+ 8 > pWw8Fib->nVersion );
+ pPLCFx_PCDAttrs = new WW8PLCFx_PCDAttrs( pWwFib->nVersion, pPLCFx_PCD, this);
+ }
+ else
+ {
+ pPieceIter = 0;
+ pPLCFx_PCD = 0;
+ pPLCFx_PCDAttrs = 0;
+ }
+
+ // pChpPLCF and pPapPLCF may NOT be created before pPLCFx_PCD !!
+ pChpPLCF = new WW8PLCFx_Cp_FKP( pSt, pTblSt, pDataSt, *this, CHP ); // CHPX
+ pPapPLCF = new WW8PLCFx_Cp_FKP( pSt, pTblSt, pDataSt, *this, PAP ); // PAPX
+
+ pSepPLCF = new WW8PLCFx_SEPX( pSt, pTblSt, *pWwFib, 0 ); // SEPX
+
+ // Footnotes
+ pFtnPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->nVersion, 0,
+ pWwFib->fcPlcffndRef, pWwFib->lcbPlcffndRef,
+ pWwFib->fcPlcffndTxt, pWwFib->lcbPlcffndTxt,
+ 2 );
+ // Endnotes
+ pEdnPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->nVersion, 0,
+ pWwFib->fcPlcfendRef, pWwFib->lcbPlcfendRef,
+ pWwFib->fcPlcfendTxt, pWwFib->lcbPlcfendTxt,
+ 2 );
+ // Anmerkungen
+ pAndPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->nVersion, 0,
+ pWwFib->fcPlcfandRef, pWwFib->lcbPlcfandRef,
+ pWwFib->fcPlcfandTxt, pWwFib->lcbPlcfandTxt,
+ (8 > pWwFib->nVersion) ? 20 : 30 );
+
+ // Fields Main Text
+ pFldPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_MAINTEXT, 0 );
+ // Fields Header / Footer
+ pFldHdFtPLCF= new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_HDFT, 0 );
+ // Fields Footnote
+ pFldFtnPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_FTN, 0 );
+ // Fields Endnote
+ pFldEdnPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_EDN, 0 );
+ // Fields Anmerkungen
+ pFldAndPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_AND, 0 );
+ // Fields in Textboxes in Main Text
+ pFldTxbxPLCF= new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_TXBX, 0 );
+ // Fields in Textboxes in Header / Footer
+ pFldTxbxHdFtPLCF=new WW8PLCFx_FLD(pTblSt,*pWwFib,MAN_TXBX_HDFT,0 );
+
+ switch( pWw8Fib->nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: if( pWwFib->fcPlcfdoaMom && pWwFib->lcbPlcfdoaMom )
+ pMainFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfdoaMom,
+ pWwFib->lcbPlcfdoaMom, 6 );
+ if( pWwFib->fcPlcfdoaHdr && pWwFib->lcbPlcfdoaHdr )
+ pHdFtFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfdoaHdr,
+ pWwFib->lcbPlcfdoaHdr, 6 );
+ break;
+ case 8:
+ if( pWwFib->fcPlcfspaMom && pWwFib->lcbPlcfspaMom )
+ pMainFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfspaMom,
+ pWwFib->lcbPlcfspaMom, 26 );
+ if( pWwFib->fcPlcfspaHdr && pWwFib->lcbPlcfspaHdr )
+ pHdFtFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfspaHdr,
+ pWwFib->lcbPlcfspaHdr, 26 );
+ // PLCF fuer TextBox-Break-Deskriptoren im Maintext
+ if( pWwFib->fcPlcftxbxBkd && pWwFib->lcbPlcftxbxBkd )
+ pMainTxbxBkd = new WW8PLCFspecial( pTblSt,
+ pWwFib->fcPlcftxbxBkd,
+ pWwFib->lcbPlcftxbxBkd, 0);
+ // PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
+ if( pWwFib->fcPlcfHdrtxbxBkd && pWwFib->lcbPlcfHdrtxbxBkd )
+ pHdFtTxbxBkd = new WW8PLCFspecial( pTblSt,
+ pWwFib->fcPlcfHdrtxbxBkd,
+ pWwFib->lcbPlcfHdrtxbxBkd, 0);
+ break;
+
+
+ default:ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+
+ // PLCF fuer TextBox-Stories im Maintext
+ long nLenTxBxS = (8 > pWw8Fib->nVersion) ? 0 : 22;
+ if( pWwFib->fcPlcftxbxTxt && pWwFib->lcbPlcftxbxTxt )
+ pMainTxbx = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcftxbxTxt,
+ pWwFib->lcbPlcftxbxTxt, nLenTxBxS );
+
+ // PLCF fuer TextBox-Stories im Header-/Footer-Bereich
+ if( pWwFib->fcPlcfHdrtxbxTxt && pWwFib->lcbPlcfHdrtxbxTxt )
+ pHdFtTxbx = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfHdrtxbxTxt,
+ pWwFib->lcbPlcfHdrtxbxTxt, nLenTxBxS );
+
+ pBook = new WW8PLCFx_Book( pSt, pTblSt, *pWwFib, 0 );
+}
+
+WW8ScannerBase::~WW8ScannerBase()
+{
+ DeletePieceTable();
+ delete pPLCFx_PCDAttrs;
+ delete pPLCFx_PCD;
+ delete pPieceIter;
+ delete pPiecePLCF;
+ delete pBook;
+ delete pFldEdnPLCF;
+ delete pFldFtnPLCF;
+ delete pFldAndPLCF;
+ delete pFldHdFtPLCF;
+ delete pFldPLCF;
+ delete pFldTxbxPLCF;
+ delete pFldTxbxHdFtPLCF;
+ delete pEdnPLCF;
+ delete pFtnPLCF;
+ delete pAndPLCF;
+ delete pSepPLCF;
+ delete pPapPLCF;
+ delete pChpPLCF;
+ // vergessene Schaeflein
+ delete pMainFdoa;
+ delete pHdFtFdoa;
+ delete pMainTxbx;
+ delete pMainTxbxBkd;
+ delete pHdFtTxbx;
+ delete pHdFtTxbxBkd;
+}
+
+//-----------------------------------------
+// Stack fuer shorts
+//-----------------------------------------
+
+class UShortStk: private SvShorts
+{
+public:
+ UShortStk():SvShorts( 10, 10 ) {}
+ ~UShortStk() {}
+ void Push( USHORT s ) { Insert( (USHORT)s, SvShorts::Count() ); }
+ inline USHORT Top();
+ inline USHORT Pop();
+ USHORT Count() { return SvShorts::Count(); }
+};
+
+inline USHORT UShortStk::Top()
+{
+ USHORT nPos = SvShorts::Count() - 1;
+ USHORT s = (*this)[ nPos ];
+ return s;
+}
+
+inline USHORT UShortStk::Pop()
+{
+ USHORT nPos = SvShorts::Count() - 1;
+ USHORT s = (*this)[ nPos ];
+ Remove( nPos );
+ return s;
+}
+
+
+//-----------------------------------------
+// Fields
+//-----------------------------------------
+
+static BOOL WW8SkipField( WW8PLCFspecial& rPLCF )
+{
+ void* pData;
+ long nP;
+
+ if( !rPLCF.Get( nP, pData ) ) // Ende des PLCFspecial ?
+ return FALSE;
+
+ rPLCF++;
+
+ if((((BYTE*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
+ return TRUE; // Bei Fehler nicht abbrechen
+
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){ // immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Beschreibungsteil
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+ }
+
+ if((((BYTE*)pData)[0] & 0x1f ) == 0x14 ){ // Field Separator ?
+ rPLCF++;
+
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){// immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Resultatteil
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+ }
+ }
+ rPLCF++;
+
+ return TRUE;
+}
+
+BOOL WW8GetFieldPara( BYTE nVersion, WW8PLCFspecial& rPLCF, WW8FieldDesc& rF )
+{
+ void* pData;
+ ULONG nOldIdx = rPLCF.GetIdx();
+
+ rF.nLen = rF.nId = rF.nOpt = rF.bCodeNest = rF.bResNest = 0;
+
+ if( !rPLCF.Get( rF.nSCode, pData ) ) // Ende des PLCFspecial ?
+ goto Err;
+
+ rPLCF++;
+
+ if((((BYTE*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
+ goto Err;
+
+ rF.nId = ((BYTE*)pData)[1];
+
+ if( !rPLCF.Get( rF.nLCode, pData ) )
+ goto Err;
+
+ rF.nSRes = rF.nLCode; // Default
+ rF.nSCode++; // ohne Marken
+ rF.nLCode -= rF.nSCode; // Pos zu Laenge
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){ // immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Beschreibungsteil
+ rF.bCodeNest = TRUE;
+ if( !rPLCF.Get( rF.nSRes, pData ) )
+ goto Err;
+ }
+
+ if((((BYTE*)pData)[0] & 0x1f ) == 0x14 ){ // Field Separator ?
+ rPLCF++;
+
+ if( !rPLCF.Get( rF.nLRes, pData ) )
+ goto Err;
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){// immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Resultatteil
+ rF.bResNest = TRUE;
+ if( !rPLCF.Get( rF.nLRes, pData ) )
+ goto Err;
+ }
+ rF.nLen = rF.nLRes - rF.nSCode + 2; // nLRes ist noch die Endposition
+ rF.nLRes -= rF.nSRes; // nun: nLRes = Laenge
+ rF.nSRes++; // Endpos encl. Marken
+ rF.nLRes--;
+
+ }else{
+ rF.nLRes = 0; // Kein Result vorhanden
+ rF.nLen = rF.nSRes - rF.nSCode + 2; // Gesamtlaenge
+ }
+
+ rPLCF++;
+ if((((BYTE*)pData)[0] & 0x1f ) == 0x15 ){ // Field Ende ?
+ // INDEX-Fld hat Bit7 gesetzt!?!
+ rF.nOpt = ((BYTE*)pData)[1]; // Ja -> Flags uebernehmen
+ }else{
+ rF.nId = 0; // Nein -> Feld ungueltig
+ }
+
+ rPLCF.SetIdx( nOldIdx );
+ return TRUE;
+Err:
+ rPLCF.SetIdx( nOldIdx );
+ return FALSE;
+}
+
+
+//-----------------------------------------
+
+
+// WW8ReadPString liest einen Pascal-String ein und gibt ihn zurueck. Der Pascal-
+// String hat am Ende ein \0, der aber im Laengenbyte nicht mitgezaehlt wird.
+// Der Speicher fuer den Pascalstring wird alloziert.
+UINT8* WW8ReadPString( SvStream& rStrm, BOOL bAtEndSeekRel1 )
+{
+ UINT8 b;
+ rStrm >> b;
+ UINT8* pStr = new UINT8[ b+2 ];
+ pStr[0] = b;
+ rStrm.Read( &pStr[1], b );
+ pStr[b+1] = '\0';
+
+ if( bAtEndSeekRel1 )
+ rStrm.SeekRel( 1 ); // ueberspringe das Null-Byte am Ende.
+
+ return pStr;
+}
+
+// WW8ReadXString liest einen Unicode-String ein und gibt ihn zurueck. Der Pascal-
+// String hat am Ende ein \0, der aber im Laengenbyte nicht mitgezaehlt wird.
+// Der Speicher fuer den Pascalstring wird alloziert.
+/*
+UINT8* WW8Read_xstz(SvStream& rStrm, BOOL bAtEndSeekRel1, USHORT nChars)
+{
+ USHORT b;
+ if( nChars )
+ b = nChars;
+ else
+ WW8ReadUINT16( rStrm, b );
+
+ UniString aTmp;
+ aTmp.AllocStrBuf( b );
+
+ sal_Unicode* pWStr = aTmp.GetCharStr();
+
+ for( BYTE nIdx = 0; nIdx < b; ++nIdx, ++pWStr )
+ {
+ UINT16 nChar;
+ WW8ReadUINT16( rStrm, nChar );
+
+ if( 0xF000 == (nChar & 0xFF00))
+ nChar &= 0x00FF;
+ *pWStr = nChar;
+ }
+ if( bAtEndSeekRel1 )
+ rStrm.SeekRel( 1 ); // ueberspringe das Null-Byte am Ende.
+
+ String sConvert( aTmp, CHARSET_ANSI );
+
+ UINT8* pStr = new UINT8[ sConvert.Len()+2 ];
+ pStr[ 0 ] = (char)b;
+ memcpy( pStr+1, sConvert.GetStr(), sConvert.Len()+1 );
+
+ return pStr;
+}
+*/
+UINT8* WW8Read_xstz( SvStream& rStrm, BOOL bAtEndSeekRel1, USHORT nChars,
+ BOOL bInsLeadingLen, long* pWasRead )
+{
+ USHORT b;
+
+ if( nChars )
+ b = nChars;
+ else
+ rStrm >> b;
+
+ USHORT nDelta = bInsLeadingLen ? 1 : 0;
+
+ UINT8* pStr = new UINT8[ b + nDelta + 1 ];
+
+ for( UINT16 nIdx = 0; nIdx < b; ++nIdx )
+ {
+ UINT16 nChar;
+ rStrm >> nChar;
+ if( 0 != rStrm.GetError() )
+ {
+ ASSERT( 0==b, "Stream Error while reading UCHAR string!" );
+ b = nIdx;
+ break;
+ }
+
+ UINT8 c = String::ConvertFromUnicode( nChar );
+ pStr[ nIdx + nDelta ] = (c ? c : ((UINT8)nChar));
+ }
+
+ if( bInsLeadingLen )
+ pStr[ 0 ] = (UINT8)b; // set count of chars that could be read
+
+ if( pWasRead )
+ *pWasRead = nIdx;
+
+ if( bAtEndSeekRel1 )
+ rStrm.SeekRel( 1 ); // ueberspringe das Null-Byte am Ende.
+
+ pStr[ nIdx + nDelta ] = 0;
+
+ return pStr;
+}
+
+
+USHORT WW8ScannerBase::WW8ReadString( SvStream& rStrm, String* pString,
+ WW8_CP nAktStartCp, long nTotalLen,
+ unsigned char** ppStr ) const
+{
+ // Klartext einlesen, der sich ueber mehrere Pieces erstrecken kann
+ if( pString )
+ pString->Erase();
+
+ if( ppStr && !*ppStr )
+ *ppStr = new unsigned char[ nTotalLen ];
+
+ long nTotalRead = 0;
+ WW8_CP nBehindTextCp = nAktStartCp + nTotalLen;
+ WW8_CP nNextPieceCp = nBehindTextCp; // Initialisierung wichtig fuer Ver6
+ do {
+ BOOL bIsUnicode, bPosOk;
+ WW8_FC fcAct = WW8Cp2Fc( nAktStartCp, &bIsUnicode,
+ &nNextPieceCp, &bPosOk);
+
+ if( !bPosOk ) break; // vermutlich uebers Dateiende hinaus gezielt, macht nix!
+
+ rStrm.Seek( fcAct );
+
+ long nLen = ( (nNextPieceCp < nBehindTextCp)
+ ? nNextPieceCp
+ : nBehindTextCp
+ )
+ - nAktStartCp;
+
+ if( 0 >= nLen ) break;
+
+ if( nLen > USHRT_MAX - 1 )
+ nLen = USHRT_MAX - 1;
+
+ unsigned char* pStr;
+ long nWasRead = 0;
+ if( bIsUnicode )
+ pStr = WW8Read_xstz( rStrm, FALSE, (USHORT)nLen, FALSE, &nWasRead );
+ else
+ {
+ pStr = new unsigned char[ nLen ];
+ nWasRead = rStrm.Read( pStr, nLen );
+ }
+ if( nWasRead != nLen ) break;
+
+ if( pString )
+ *pString += String( (const char*)pStr, (USHORT)nLen );
+ if( ppStr )
+ memcpy( (*ppStr) + nTotalRead, pStr, nLen );
+ delete[]( pStr );
+
+ nTotalRead += nLen;
+ nAktStartCp += nLen;
+ } while( nTotalRead < nTotalLen );
+
+ if( pString )
+ return pString->Len();
+ return (USHORT)nTotalRead;
+}
+
+
+//-----------------------------------------
+// WW8PLCFspecial
+//-----------------------------------------
+
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCFspecial::WW8PLCFspecial( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos, BOOL bNoEnd )
+:nIdx( 0 ), nStru( nStruct )
+{
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+ pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos- u. Struct-Array
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pPLCF_PosArray, nPLCF );
+#ifdef __BIGENDIAN
+ for( nIdx = 0; nIdx <= nIMax; nIdx++ ){
+ pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] );
+ }
+ nIdx = 0;
+#endif // __BIGENDIAN
+ if( bNoEnd ) nIMax++;
+ if( nStruct )
+ pPLCF_Contents = (char*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+ else
+ pPLCF_Contents = 0; // kein Inhalt
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+
+ pSt->Seek( nOldPos );
+}
+
+// WW8PLCFspecial::SeekPos() stellt den WW8PLCFspecial auf die Stelle nPos, wobei auch noch der
+// Eintrag benutzt wird, der vor nPos beginnt und bis hinter nPos reicht.
+// geeignet fuer normale Attribute. Allerdings wird der Attributanfang nicht
+// auf die Position nPos korrigiert.
+BOOL WW8PLCFspecial::SeekPos( long nPos )
+{
+ register long nI;
+ register long nP = nPos;
+
+ if( nP < pPLCF_PosArray[0] ){
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ for( nI=1; nI<=nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nP < pPLCF_PosArray[nI] ){ // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+// WW8PLCFspecial::SeekPosExact() wie SeekPos(), aber es wird sichergestellt, dass kein
+// Attribut angeschnitten wird, d.h. das naechste gelieferte Attribut beginnt
+// auf oder hinter nPos. Wird benutzt fuer Felder + Bookmarks.
+BOOL WW8PLCFspecial::SeekPosExact( long nPos )
+{
+ register long nI;
+ register long nP = nPos;
+
+ if( nP < pPLCF_PosArray[0] ){
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ for( nI=0; nI<nIMax; nI++){ // Suchen
+ if( nP <= pPLCF_PosArray[nI] ){ // Position gefunden
+ nIdx = nI; // nI ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+BOOL WW8PLCFspecial::Get( long& rPos, void*& rpValue )
+{
+ if ( nIdx >= nIMax ){
+ rPos = LONG_MAX;
+ return FALSE;
+ }
+ rPos = pPLCF_PosArray[nIdx];
+ rpValue = pPLCF_Contents ? (void*)&pPLCF_Contents[nIdx * nStru] : 0;
+ return TRUE;
+}
+
+BOOL WW8PLCFspecial::GetData( long nIdx, long& rPos, void*& rpValue )
+{
+ if ( nIdx >= nIMax ){
+ rPos = LONG_MAX;
+ return FALSE;
+ }
+ rPos = pPLCF_PosArray[nIdx];
+ rpValue = pPLCF_Contents ? (void*)&pPLCF_Contents[nIdx * nStru] : 0;
+ return TRUE;
+}
+
+//-----------------------------------------
+// WW8PLCF z.B. fuer SEPX
+//-----------------------------------------
+
+// Ctor fuer *andere* als Fkps
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCF::WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos )
+:nIdx( 0 ), nStru( nStruct )
+{
+ ASSERT( nPLCF, "WW8PLCF: nPLCF ist Null!" );
+
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+
+ ReadPLCF( pSt, nFilePos, nPLCF );
+
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+}
+
+// Ctor *nur* fuer Fkps
+// Die letzten 2 Parameter sind fuer PLCF.Chpx und PLCF.Papx noetig.
+// ist ncpN != 0, dann wird ein unvollstaendiger PLCF vervollstaendigt.
+// Das ist bei WW6 bei Resourcenmangel und bei WordPad (W95) immer noetig.
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCF::WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos, long nPN, long ncpN )
+:nIdx( 0 ), nStru( nStruct )
+{
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+
+ if( nIMax >= (long) ncpN )
+ ReadPLCF( pSt, nFilePos, nPLCF );
+ else
+ GeneratePLCF( pSt, nPN, ncpN );
+
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+
+// Damit man sich den Inhalt im Debugger ansehen kann
+#ifdef DEBUG_STRUCT
+ INT32 (*p1)[200] = (INT32 (*)[200])pPLCF_PosArray;
+ USHORT (*p2)[200] = (USHORT (*)[200])pPLCF_Contents;
+ p2 = p2;
+#endif
+}
+
+void WW8PLCF::ReadPLCF( SvStream* pSt, long nFilePos, long nPLCF )
+{
+ pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos-Array
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pPLCF_PosArray, nPLCF );
+#ifdef __BIGENDIAN
+ for( nIdx = 0; nIdx <= nIMax; nIdx++ ){
+ pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] );
+ }
+ nIdx = 0;
+#endif // __BIGENDIAN
+ pPLCF_Contents = (char*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+
+ pSt->Seek( nOldPos );
+}
+
+void WW8PLCF::GeneratePLCF( SvStream* pSt, long nPN,
+ long ncpN )
+{
+ ASSERT( nIMax < (long)ncpN, "Pcl.Fkp: Warum ist PLCF zu gross ?" );
+ nIMax = ncpN;
+ long nSiz = 6 * nIMax + 4;
+ pPLCF_PosArray = new INT32[ ( nSiz + 3 ) / 4 ]; // Pointer auf Pos-Array
+ memset( pPLCF_PosArray, 0, (size_t)nSiz );
+
+ INT32 nFc;
+ USHORT i;
+
+ for( i = 0; i < ncpN; i++ ){ // Baue FC-Eintraege
+ pSt->Seek( ( nPN + i ) << 9 ); // erster FC-Eintrag jedes Fkp
+ *pSt >> nFc;
+ pPLCF_PosArray[i] = nFc;
+ }
+ ULONG nLastFkpPos = ( ( nPN + nIMax - 1 ) << 9 );
+ pSt->Seek( nLastFkpPos + 511 ); // Anz. Fkp-Eintraege des letzten Fkp
+ BYTE nb;
+ *pSt >> nb;
+ pSt->Seek( nLastFkpPos + nb * 4 ); // letzer FC-Eintrag des letzten Fkp
+ *pSt >> nFc;
+ pPLCF_PosArray[nIMax] = nFc; // Ende des letzten Fkp
+
+ pPLCF_Contents = (char*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+ USHORT* p = (USHORT*)pPLCF_Contents;
+
+ for( i = 0; i < ncpN; i++ ) // Baue PNs
+ p[i] = nPN + i;
+
+#ifdef DEBUG_STRUCT // Damit man sich den Inhalt im Debugger ansehen kann
+ INT32 (*p1)[200] = (INT32 (*)[200])pPLCF_PosArray;
+ USHORT (*p2)[200] = (USHORT (*)[200])pPLCF_Contents;
+ p2 = p2;
+#endif
+}
+
+BOOL WW8PLCF::SeekPos( long nPos )
+{
+ register long nI;
+ register long nP = nPos;
+
+ if( nP < pPLCF_PosArray[0] ){
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ for( nI=1; nI<=nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nP < pPLCF_PosArray[nI] ){ // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+BOOL WW8PLCF::Get( long& rStart, long& rEnd, void*& rpValue )
+{
+ if ( nIdx >= nIMax )
+ {
+ rStart = rEnd = LONG_MAX;
+ return FALSE;
+ }
+ rStart = pPLCF_PosArray[ nIdx ];
+ rEnd = pPLCF_PosArray[ nIdx + 1 ];
+ rpValue = (void*)&pPLCF_Contents[nIdx * nStru];
+ return TRUE;
+}
+
+long WW8PLCF::Where()
+{
+ if ( nIdx >= nIMax )
+ return LONG_MAX;
+
+ return pPLCF_PosArray[nIdx];
+}
+
+//-----------------------------------------
+// WW8PLCFpcd
+//-----------------------------------------
+
+WW8PLCFpcd::WW8PLCFpcd( SvStream* pSt, long nFilePos, long nPLCF, long nStruct )
+:nStru( nStruct )
+{
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+ pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos-Array
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pPLCF_PosArray, nPLCF );
+#ifdef __BIGENDIAN
+ for( long nI = 0; nI <= nIMax; nI++ ){
+ pPLCF_PosArray[nI] = SWAPLONG( pPLCF_PosArray[nI] );
+ }
+#endif // __BIGENDIAN
+
+ pPLCF_Contents = (char*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+
+#ifdef DEBUG_STRUCT // Damit man sich den Inhalt im Debugger ansehen kann
+ INT32 (*p1)[200] = (INT32 (*)[200])pPLCF_PosArray;
+ WW8_PCD1 (*p2)[200] = (WW8_PCD1 (*)[200])pPLCF_Contents;
+#endif
+
+ pSt->Seek( nOldPos );
+}
+
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCFpcd_Iter::WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, long nStartPos /* = -1 */ )
+:rPLCF( rPLCFpcd ), nIdx( 0 )
+{
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+}
+
+BOOL WW8PLCFpcd_Iter::SeekPos( long nPos )
+{
+ register long nI;
+ register long nP = nPos;
+
+ if( nP < rPLCF.pPLCF_PosArray[0] ){
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ for( nI=1; nI<=rPLCF.nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nP < rPLCF.pPLCF_PosArray[nI] ){// Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nIdx = rPLCF.nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+/*
+BOOL WW8PLCFpcd_Iter::SeekMaxMainFC( WW8Fib& rWwF, long& rMaxPosData )
+{
+ long nCpStart, nCpEnd;
+ void* pData;
+ nIdx = rPLCF.nIMax-1;
+ if( !Get( nCpStart, nCpEnd, pData ) )
+ {
+ ASSERT( ASS_FALSE, "SeekMaxMainFC findet Eintrag zu nIdx nicht" );
+ return FALSE;
+ }
+ BOOL bIsUnicode;
+ WW8_FC nActPosData = WW8PLCFx_PCD::TransformPieceAddress(
+ SVBT32ToLong( ( (WW8_PCD*)pData )->fc ),
+ &bIsUnicode );
+
+// rMaxPosData = nActPosData + ((rWwF.ccpText - nCpStart) * (bIsUnicode ? 2 : 1));
+
+ rMaxPosData = nActPosData + rWwF.ccpText - nCpStart;
+
+ return (0 < rMaxPosData);
+}
+*/
+
+BOOL WW8PLCFpcd_Iter::Get( long& rStart, long& rEnd, void*& rpValue )
+{
+ if( nIdx >= rPLCF.nIMax )
+ {
+ rStart = rEnd = LONG_MAX;
+ return FALSE;
+ }
+ rStart = rPLCF.pPLCF_PosArray[nIdx];
+ rEnd = rPLCF.pPLCF_PosArray[nIdx + 1];
+ rpValue = (void*)&rPLCF.pPLCF_Contents[nIdx * rPLCF.nStru];
+#ifdef DEBUG_STRUCT
+ WW8_PCD1* p = (WW8_PCD1*)rpValue;
+ p = p;
+#endif
+ return TRUE;
+}
+
+long WW8PLCFpcd_Iter::Where()
+{
+ if ( nIdx >= rPLCF.nIMax )
+ return LONG_MAX;
+
+ return rPLCF.pPLCF_PosArray[nIdx];
+}
+
+//-----------------------------------------
+
+WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp( BYTE nFibVer, SvStream* pSt, SvStream* pDataSt,
+ long nFilePos, long nItemSiz,
+ ePLCFT ePl, WW8_FC nStartFc )
+:nItemSize( nItemSiz ), ePLCF( ePl ), nIdx( 0 )
+{
+ nVersion = nFibVer;
+
+// pFkp = new BYTE[512]; // 512 Byte
+ pFkp = (BYTE*)new INT32[128]; // 512 Byte
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pFkp, 512 );
+ nIMax = pFkp[511];
+#ifdef __BIGENDIAN
+ register UINT32* p;
+ for( nIdx = 0, p = (UINT32*)pFkp; nIdx <= nIMax; nIdx++, p++ )
+ *p = SWAPLONG( *p );
+#endif // __BIGENDIAN
+
+
+ // Pointer auf Offset-Bereich in *pFkp
+ BYTE* pOfs = pFkp + (nIMax + 1) * 4;
+
+ pGrpprl = new WW8Grpprl[nIMax];
+ memset( pGrpprl, 0, sizeof( WW8Grpprl )*nIMax );
+
+ WW8Grpprl* pTmpGrpprl = pGrpprl;
+ for( nIdx = 0; nIdx < nIMax; nIdx++, pTmpGrpprl++ )
+ {
+ USHORT nOfs = (*(pOfs + nIdx * nItemSize)) * 2;
+
+ if ( nOfs )
+ {
+ switch ( ePLCF )
+ {
+ case CHP:
+ pTmpGrpprl->nLen = (short)pFkp[ nOfs ];
+ pTmpGrpprl->pData = pFkp + nOfs + 1;
+ break;
+ case PAP:
+ BYTE nDelta = 0;//(8 > nVersion) ? 0 : 1;
+ pTmpGrpprl->nLen = pFkp[ nOfs ];
+ if( 8 <= nVersion && !pTmpGrpprl->nLen )
+ {
+ pTmpGrpprl->nLen = pFkp[ nOfs+1 ];
+ nDelta++;
+ }
+ pTmpGrpprl->nIStd = SVBT16ToShort( (unsigned char *) pFkp+nOfs+1+nDelta );
+ pTmpGrpprl->pData = pFkp + nOfs + 3+nDelta ;
+ USHORT nSpId = WW8GetSprmId( nVersion, pTmpGrpprl->pData );
+ if( 0x6645 == nSpId || 0x6646 == nSpId )
+ {
+ UINT32 nPos = *(UINT32*)(pTmpGrpprl->pData + 2);
+ UINT32 nCurr = pDataSt->Tell();
+ pDataSt->Seek( nPos );
+ *pDataSt >> pTmpGrpprl->nLen;
+ pTmpGrpprl->pData = new BYTE[pTmpGrpprl->nLen];
+ pTmpGrpprl->bMustDelete = TRUE;
+ pDataSt->Read( pTmpGrpprl->pData, pTmpGrpprl->nLen );
+
+ pDataSt->Seek( nCurr );
+ }
+ else
+ {
+ pTmpGrpprl->nLen *= 2;
+ pTmpGrpprl->nLen -= 2;
+ }
+ break;
+ }
+ }
+ }
+
+ nIdx = 0;
+
+ if( nStartFc >= 0 )
+ SeekPos( nStartFc );
+
+ pSt->Seek( nOldPos );
+}
+
+WW8PLCFx_Fc_FKP::WW8Fkp::~WW8Fkp()
+{
+ WW8Grpprl* pTmpGrpprl = pGrpprl;
+ for( nIdx = 0; nIdx < nIMax; nIdx++, pTmpGrpprl++ )
+ {
+ if( pTmpGrpprl->bMustDelete )
+ delete pTmpGrpprl->pData;
+ }
+ delete pGrpprl;
+ delete pFkp;
+}
+
+BOOL WW8PLCFx_Fc_FKP::WW8Fkp::SeekPos( WW8_FC nFc )
+{
+ register short nI;
+
+ if( nFc < ((WW8_FC*)pFkp)[0] ){
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ for( nI=1; nI<=nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nFc < ((WW8_FC*)pFkp)[nI] ){ // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+BYTE* WW8PLCFx_Fc_FKP::WW8Fkp::Get( WW8_FC& rStart, WW8_FC& rEnd, short& rLen )
+{
+ rLen = 0;
+
+ if( nIdx >= nIMax ){
+ rStart = LONG_MAX;
+ return 0;
+ }
+
+ rStart = ((WW8_FC*)pFkp)[nIdx ];
+ rEnd = ((WW8_FC*)pFkp)[nIdx+1];
+
+ BYTE* pSprms = GetLenAndIStdAndSprms( rLen );
+ return pSprms;
+}
+
+void WW8PLCFx_Fc_FKP::WW8Fkp::SetIdx( ULONG nI )
+{
+ if( nI < nIMax) nIdx = (short)nI;
+}
+
+BYTE* WW8PLCFx_Fc_FKP::WW8Fkp::GetLenAndIStdAndSprms(short& rLen)
+{
+ WW8Grpprl* pTmpGrpprl = pGrpprl + nIdx;
+
+ rLen = pTmpGrpprl->nLen;
+
+ return pTmpGrpprl->pData;
+}
+
+
+BYTE* WW8FindSprm( USHORT nId, long nLen, BYTE* pSprms, BYTE nVersion )
+{
+ WW8SprmIter aSprmIter( pSprms, nLen, nVersion );
+
+ while( aSprmIter.GetSprms() )
+ {
+ if( aSprmIter.GetAktId() == nId )
+ return aSprmIter.GetAktParams(); // SPRM found!
+ aSprmIter++;
+ }
+
+ return 0; // SPRM _not_ found
+}
+
+
+BYTE* WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm( USHORT nId )
+{
+ if( nIdx >= nIMax )
+ return 0;
+
+ short nLen;
+ BYTE* pSprms = GetLenAndIStdAndSprms( nLen );
+
+ return WW8FindSprm( nId, nLen, pSprms, nVersion );
+}
+
+ULONG WW8PLCFx_Fc_FKP::WW8Fkp::GetParaHeight() const
+{
+ if( ePLCF != PAP ){
+ ASSERT( ASS_FALSE, "Fkp::GetParaHeight: Falscher Fkp" );
+ return 0;
+ }
+ if( nIdx >= nIMax )
+ return 0;
+
+ WW8_PHE_Base* pPhe = (WW8_PHE_Base*)( (pFkp + (nIMax + 1) * 4)
+ + ( nIdx * nItemSize ) + 1 );
+
+ if( pPhe->aBits1 & 0x2 ) // fUnk
+ return 0; // invalid
+
+ if( pPhe->aBits1 & 0x4 ){ // fDiffLines
+ return SVBT16ToShort( pPhe->dyl ); // Gesamthoehe
+ }else{ // nlMac gleich hohe Zeilen
+ INT32 nH = (INT16)SVBT16ToShort( pPhe->dyl ); // Zeilenhoehe
+ if( nH < 0 ) // negative Werte wollen wir
+ nH = 0; // nicht
+ nH *= (INT32)pPhe->nlMac; // Hoehe einer Zeile * Zeilen
+ return (ULONG)nH;
+ }
+}
+
+//-----------------------------------------
+
+#if 0
+BYTE* WW8PLCFx::GetSprms( long& rStart, long& rEnd, long& rLen )
+{
+ ASSERT( FALSE, "Falsches GetSprms gerufen" );
+ rStart = rEnd = LONG_MAX;
+ rLen = 0;
+ return 0;
+}
+#endif
+
+void WW8PLCFx::GetSprms( WW8PLCFxDesc* p )
+{
+ ASSERT( ASS_FALSE, "Falsches GetSprms gerufen" );
+ p->nStartPos = p->nEndPos = LONG_MAX;
+ p->nSprmsLen = 0;
+ p->pMemPos = 0;
+ p->bRealLineEnd = FALSE;
+ return;
+}
+
+long WW8PLCFx::GetNoSprms( long& rStart, long& rEnd, long& rLen )
+{
+ ASSERT( ASS_FALSE, "Falsches GetNoSprms gerufen" );
+ rStart = rEnd = LONG_MAX;
+ rLen = 0;
+ return 0;
+}
+
+#if 0
+WW8PLCFx& WW8PLCFx::operator ++(int)
+{
+ ASSERT( FALSE, "Falsches ++ gerufen" );
+ return *this;
+}
+#endif
+
+// ...Idx2: Default: ignorieren
+ULONG WW8PLCFx::GetIdx2()
+{
+ return 0;
+}
+
+void WW8PLCFx::SetIdx2( ULONG nIdx )
+{
+}
+
+//-----------------------------------------
+BOOL WW8PLCFx_Fc_FKP::NewFkp()
+{
+ long nPLCFStart, nPLCFEnd;
+ void* pPage;
+
+ static int __READONLY_DATA WW8FkpSizeTabVer6[ PLCF_END ] = {
+ 1, 7, 0 /*, 0, 0, 0*/ };
+ static int __READONLY_DATA WW8FkpSizeTabVer8[ PLCF_END ] = {
+ 1, 13, 0 /*, 0, 0, 0*/ };
+ const int* pFkpSizeTab;
+ switch( GetVersion() )
+ {
+ case 6:
+ case 7: pFkpSizeTab = WW8FkpSizeTabVer6;
+ break;
+ case 8: pFkpSizeTab = WW8FkpSizeTabVer8;
+ break;
+ default:// Programm-Fehler!
+ ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ return FALSE;
+ }
+
+#if 0 //!!!!!
+ pFkp = 0; // absichtliches SpeicherLoch fuer besseres Debuggen
+#else
+ DELETEZ( pFkp );
+#endif
+
+ if (!pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ))
+ return FALSE; // PLCF fertig abgearbeitet
+ (*pPLCF)++;
+ long nPo = SVBT16ToShort( (unsigned char *)pPage );
+ nPo <<= 9; // shift als LONG
+ pFkp = new WW8Fkp( GetVersion(), pFKPStrm, pDataStrm, nPo, pFkpSizeTab[ ePLCF ],
+ ePLCF, nStartFc );
+ nStartFc = -1; // Nur das erste Mal
+ return TRUE;
+}
+
+WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTblSt,
+ SvStream* pDataSt, WW8Fib& rFib, ePLCFT ePl,
+ WW8_FC nStartFcL,
+ WW8PLCFx_PCDAttrs* pPLCFx_PCDAttrs_)
+ : WW8PLCFx( rFib.nVersion, TRUE ),
+ pFKPStrm( pSt ),
+ pDataStrm( pDataSt ),
+ ePLCF( ePl ),
+ pFkp( 0 ),
+ nStartFc( nStartFcL ),
+ pPCDAttrs( pPLCFx_PCDAttrs_)
+{
+ long nLenStruct = (8 > rFib.nVersion) ? 2 : 4;
+ if( ePl == CHP )
+ pPLCF = new WW8PLCF( pTblSt, rFib.fcPlcfbteChpx,
+ rFib.lcbPlcfbteChpx,
+ nLenStruct,
+ nStartFc,
+ rFib.pnChpFirst,
+ rFib.cpnBteChp );
+ else
+ pPLCF = new WW8PLCF( pTblSt, rFib.fcPlcfbtePapx,
+ rFib.lcbPlcfbtePapx,
+ nLenStruct,
+ nStartFc,
+ rFib.pnPapFirst,
+ rFib.cpnBtePap );
+}
+
+WW8PLCFx_Fc_FKP::~WW8PLCFx_Fc_FKP()
+{
+ delete pFkp;
+ delete pPLCF;
+}
+
+
+ULONG WW8PLCFx_Fc_FKP::GetIdx()
+{
+ ULONG u = pPLCF->GetIdx() << 8;
+ if( pFkp )
+ u |= pFkp->GetIdx();
+ return u;
+}
+
+void WW8PLCFx_Fc_FKP::SetIdx( ULONG nIdx )
+{
+ if( !( nIdx & 0xffffff00L ) ){
+ pPLCF->SetIdx( nIdx >> 8 );
+ DELETEZ( pFkp );
+
+ }else{ // Es gab einen Fkp
+ // Lese PLCF um 1 Pos zurueck, um
+ pPLCF->SetIdx( ( nIdx >> 8 ) - 1 ); // die Adresse des Fkp wiederzubekommen
+ if ( NewFkp() ) // und lese Fkp wieder ein
+ pFkp->SetIdx( nIdx & 0xff ); // Dann stelle Fkp-Pos wieder ein
+ }
+}
+
+BOOL WW8PLCFx_Fc_FKP::SeekPos( WW8_FC nFcPos )
+{
+ DELETEZ( pFkp ); // FKP ungueltig machen
+ nStartFc = nFcPos; // StartPos fuer naechstes Where()
+ return pPLCF->SeekPos( nFcPos ); // StartPos fuer naechstes pPLCF->Get()
+}
+
+WW8_FC WW8PLCFx_Fc_FKP::Where()
+{
+ if( !pFkp ){
+ if( !NewFkp() )
+ return LONG_MAX;
+ }
+ WW8_FC nP = pFkp->Where();
+ if( nP != LONG_MAX )
+ return nP;
+
+ DELETEZ( pFkp ); // FKP beendet -> hole neuen
+ return Where(); // am einfachsten rekursiv
+}
+
+
+
+BYTE* WW8PLCFx_Fc_FKP::GetSprms( WW8_FC& rStart, WW8_FC& rEnd, long& rLen )
+{
+ rLen = 0; // Default
+ rStart = rEnd = LONG_MAX;
+
+ if( !pFkp ){ // Fkp nicht da ?
+ if( !NewFkp() )
+ return 0;
+ }
+
+ short nLen;
+ BYTE* pPos = pFkp->Get( rStart, rEnd, nLen );
+ if( rStart == LONG_MAX )
+ { // nicht gefunden
+ return 0;
+ }
+ rLen = nLen;
+ return pPos;
+}
+
+
+
+WW8PLCFx& WW8PLCFx_Fc_FKP::operator ++( int )
+{
+ if( !pFkp ){
+// ASSERT( FALSE, "pFkp fehlt");
+// return *this;
+ if( !NewFkp() )
+ return *this;
+ }
+
+ (*pFkp)++;
+ if( pFkp->Where() == LONG_MAX ){
+ NewFkp();
+ }
+ return *this;
+}
+
+USHORT WW8PLCFx_Fc_FKP::GetIstd() const
+{
+ return (pFkp) ? pFkp->GetIstd() : 0xffff;
+}
+
+
+void WW8PLCFx_Fc_FKP::GetPCDSprms( WW8PLCFxDesc& rDesc )
+{
+ rDesc.pMemPos = 0;
+ rDesc.nSprmsLen = 0;
+ if( pPCDAttrs )
+ {
+ if( !pFkp )
+ {
+ DBG_WARNING( "+Problem: GetPCDSprms: NewFkp noetig ( kein const moeglich )" );
+ if( !NewFkp() )
+ return;
+ }
+
+ long nFcPos, nEnd; // FCs
+ short nLen;
+ pFkp->Get( nFcPos, nEnd, nLen );
+
+ WW8PLCFpcd_Iter* pIter = pPCDAttrs->GetIter();
+
+ /**************************************/
+ ULONG nSaveIdx = pIter->GetIdx();
+ BOOL bFirst = TRUE;
+ while( 1 )
+ {
+ long nCpStart, nCpEnd;
+ void* pData;
+ if( !pIter->Get( nCpStart, nCpEnd, pData ) )
+ { // ausserhalb PLCFfpcd ?
+ break;
+ }
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( 7 < GetVersion() )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
+
+ INT32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1);
+
+ if( nFcPos >= nFcStart && nFcPos < nFcStart + nLen )
+ {
+ // gefunden
+ pPCDAttrs->GetSprms( &rDesc );
+ break;
+ }
+ if( bFirst )
+ {
+ pIter->SetIdx( 0 );
+ bFirst = FALSE;
+ }
+ else
+ (*pIter)++;
+ }
+ if( nSaveIdx != pIter->GetIdx() )
+ pIter->SetIdx( nSaveIdx );
+ /**************************************/
+ }
+}
+
+
+BYTE* WW8PLCFx_Fc_FKP::HasSprm( USHORT nId )
+{ // const waere schoener, aber dafuer
+ // muesste NewFkp() ersetzt werden
+ // oder wegfallen
+ if( !pFkp )
+ {
+ DBG_WARNING( "+Motz: HasSprm: NewFkp noetig ( kein const moeglich )" );
+ // Passiert bei BugDoc 31722
+ if( !NewFkp() )
+ return 0;
+ }
+
+ BYTE* pRes = pFkp->HasSprm( nId );
+
+ if( !pRes )
+ {
+ WW8PLCFxDesc aDesc;
+ GetPCDSprms( aDesc );
+
+ if( aDesc.pMemPos )
+ {
+ pRes = WW8FindSprm( nId, aDesc.nSprmsLen,
+ aDesc.pMemPos, pFkp->GetVersion() );
+ }
+ }
+ return pRes;
+}
+
+
+ULONG WW8PLCFx_Fc_FKP::GetParaHeight() const
+{
+ if( !pFkp ){
+ ASSERT( ASS_FALSE, "GetParaHeight: pFkp nicht da" );
+ return 0;
+ }
+ return pFkp->GetParaHeight();
+}
+
+//-----------------------------------------
+
+WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ const WW8ScannerBase& rBase,
+ ePLCFT ePl )
+ : WW8PLCFx_Fc_FKP( pSt, pTblSt, pDataSt, *rBase.pWw8Fib, ePl,
+ rBase.WW8Cp2Fc( 0 ),
+ rBase.pPLCFx_PCDAttrs ),
+ rSBase( rBase ),
+// nFcMin( rBase.pWrFib.fcMin ),
+ nAttrStart( -1 ), nAttrEnd( -1 ),
+ bLineEnd( FALSE ),
+ bComplex( (7 < rBase.pWw8Fib->nVersion) || (0 != rBase.pWw8Fib->fComplex) )
+{
+ ResetAttrStartEnd();
+ pPcd = rSBase.pPiecePLCF ? new WW8PLCFx_PCD(
+ rBase.pWw8Fib->nVersion, rBase.pPiecePLCF, 0,
+ ((6 == GetVersion()) || (7 == GetVersion())) )
+ : 0;
+}
+
+WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP()
+{
+ delete pPcd;
+}
+
+void WW8PLCFx_Cp_FKP::ResetAttrStartEnd()
+{
+ nAttrStart = -1;
+ nAttrEnd = -1;
+ bLineEnd = FALSE;
+}
+
+ULONG WW8PLCFx_Cp_FKP::GetIdx2()
+{
+ return pPcd ? pPcd->GetIdx() : 0;
+}
+
+void WW8PLCFx_Cp_FKP::SetIdx2( ULONG nIdx )
+{
+ if( pPcd )
+ pPcd->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_Cp_FKP::SeekPos( WW8_CP nCpPos )
+{
+/*
+ WW8_FC nTargetFc = WW8Cp2Fc( nCpPos, nFcMin );
+ return (LONG_MAX != nTargetFc)
+ && WW8PLCFx_Fc_FKP::SeekPos( nTargetFc );
+*/
+ if( pPcd ) // Complex
+ {
+ if( !pPcd->SeekPos( nCpPos ) ) // Piece setzen
+ return FALSE;
+ return WW8PLCFx_Fc_FKP::SeekPos( pPcd->AktPieceStartCp2Fc( nCpPos ) );
+ }
+ // KEINE Piece-Table !!!
+ return WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc( nCpPos /*,TRUE*/ ) );
+}
+
+WW8_CP WW8PLCFx_Cp_FKP::Where()
+{
+ WW8_FC nFc = WW8PLCFx_Fc_FKP::Where();
+ if( pPcd )
+ return pPcd->AktPieceStartFc2Cp( nFc ); // Piece ermitteln
+ return rSBase.WW8Fc2Cp( nFc/*,TRUE*/ ); // KEINE Piece-Table !!!
+}
+
+void WW8PLCFx_Cp_FKP::GetSprms( WW8PLCFxDesc* p )
+{
+ p->pMemPos = WW8PLCFx_Fc_FKP::GetSprms( p->nStartPos, p->nEndPos, p->nSprmsLen );
+
+#ifdef DEBUG
+ if( ePLCF == PAP ) // um hier einen Brechpunkt zu setzen
+ ePLCF = PAP;
+#endif
+
+ if( pPcd ) // Piece-Table vorhanden !!!
+ {
+ if( (nAttrStart > nAttrEnd)
+ || (nAttrStart == -1) ) // Init ( noch kein ++ gerufen )
+ {
+ eCutT eC = pPcd->AktPieceFc2Cp( p->nStartPos, p->nEndPos );
+ p->bRealLineEnd = !( eC & CUT_END ) && ePLCF == PAP;
+ }
+ else
+ {
+ p->nStartPos = nAttrStart;
+ p->nEndPos = nAttrEnd;
+ p->bRealLineEnd = bLineEnd;
+ }
+ }
+ else // KEINE Piece-Table !!!
+ {
+ p->nStartPos = rSBase.WW8Fc2Cp( p->nStartPos/*,TRUE*/ );
+ p->nEndPos = rSBase.WW8Fc2Cp( p->nEndPos/*,TRUE*/ );
+ p->bRealLineEnd = ePLCF == PAP;
+ }
+}
+
+
+// WW8PLCF_Cp_Fkp::SearchParaEnd kann einfacher durchgefuehrt werden, wenn das
+// Flag "Zeilenende im Piece" in der Piecetable ausgewertet wird.
+void WW8PLCFx_Cp_FKP::SearchParaEnd( long nOldEndCp )
+{
+ if( !bComplex )
+ {
+ ASSERT( !this, "SearchParaEnd fuer Non-Complex File gerufen" );
+ return;
+ }
+ if( ePLCF != PAP )
+ {
+ ASSERT( !this, "SearchParaEnd fuer Non-PAP gerufen" );
+ return;
+ }
+ long nFkpLen; // Fkp-Eintrag
+ long nPcdStart, nPcdEnd; // Piece-Grenzen
+
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen ); // Fkp-Eintrag holen
+ eCutT eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd );
+ if( eC == CUT_NONE ) // neuer Eintrag ganz im akt. Piece
+ {
+ ASSERT( !this, "Nanu?" );
+ return; // und fertig
+ }
+ WW8PLCFpcd_Iter* pIter = pPcd->GetPLCFIter();
+ void* pData;
+ do{
+ (*pPcd)++; // naechstes Piece
+ if( !pIter->Get( nPcdStart, nPcdEnd, pData ) ){ // Piece-Grenzen holen
+#ifdef DEBUG_STRUCT
+ WW8_PCD1* p = (WW8_PCD1*)pData;
+ p = p;
+#endif
+ nAttrStart = nAttrEnd = LONG_MAX; // kein Piece mehr vorhanden
+ return;
+ }
+#ifdef DEBUG_STRUCT
+ WW8_PCD1* p = (WW8_PCD1*)pData;
+ p = p;
+#endif
+
+ }while( SVBT8ToByte( ( (WW8_PCD*)pData )->aBits1 ) & 0x1 );
+ // bis NL in Piece
+
+ if( !WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc( nPcdStart ) ) )
+ {
+ ASSERT( !this, " Can't seek to Piece Start" );
+ nAttrStart = nAttrEnd = LONG_MAX; // kein Piece mehr vorhanden
+ return;
+ }
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen ); // Fkp-Eintrag holen
+ eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd ); // wird in CPs gebraucht
+
+ nAttrStart = nOldEndCp; // Aufziehen ueber ganzen Absatz, unabhaengig
+ // davon, wieviel Pieces das sind
+}
+
+WW8PLCFx& WW8PLCFx_Cp_FKP::operator ++( int )
+{
+ WW8PLCFx_Fc_FKP::operator ++( 0 );
+ if( !bComplex || !pPcd ) // !pPcd: Notbremse
+ return *this;
+// ohoho
+ long nFkpLen; // Fkp-Eintrag
+ long nPcdStart, nPcdEnd, nPcdLen; // Piece-Grenzen
+ long nOldEndCp = nAttrEnd;
+
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen ); // Fkp-Eintrag holen
+ eCutT eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd );
+ bLineEnd = !( eC & CUT_END ) && ePLCF == PAP;
+ if( !( eC & CUT_START ) ){ // neuer Eintrag faengt im
+ // akt. Piece an
+#ifdef DEBUG
+ if( ePLCF == PAP )
+ ePLCF = PAP; // um hier einen Brechpunkt zu setzen
+ if( ePLCF == CHP )
+ ePLCF = CHP; // um hier einen Brechpunkt zu setzen
+#endif
+ return *this; // und fertig
+ }
+ // naechster Eintrag im naechsten Piece
+
+ if( ePLCF == PAP )
+ {
+ SearchParaEnd( nOldEndCp );
+ bLineEnd = TRUE;
+ return *this;
+ }
+
+ // naechstes Piece
+ bLineEnd = FALSE;
+ (*pPcd)++;
+ pPcd->GetNoSprms( nPcdStart, nPcdEnd, nPcdLen );
+ // Piece-Grenzen holen
+ if( !WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc( nPcdStart ) ) )
+ {
+ ASSERT( nPcdStart == LONG_MAX, "Chp-SeekPos ging schief" );
+ nAttrStart = nAttrEnd = LONG_MAX;
+ goto Ret;
+ }
+ // Fkp-Eintrag holen
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen );
+ eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd );
+Ret:
+ return *this;
+}
+
+//-----------------------------------------
+//-----------------------------------------
+
+WW8PLCFx_SEPX::WW8PLCFx_SEPX( SvStream* pSt, SvStream* pTblSt, WW8Fib& rFib, WW8_CP nStartCp )
+: pStrm( pSt ), WW8PLCFx( rFib.nVersion, TRUE ), nArrMax( 256 ), nSprmSiz( 0 )
+{
+ pPLCF = rFib.lcbPlcfsed
+ ? new WW8PLCF( pTblSt, rFib.fcPlcfsed,
+ rFib.lcbPlcfsed,
+ 12, nStartCp )
+ : 0;
+
+ pSprms = new BYTE[nArrMax]; // maximale Laenge
+}
+
+WW8PLCFx_SEPX::~WW8PLCFx_SEPX()
+{
+ delete pPLCF;
+ delete pSprms;
+}
+
+ULONG WW8PLCFx_SEPX::GetIdx()
+{
+ return pPLCF ? pPLCF->GetIdx() : 0;
+}
+
+void WW8PLCFx_SEPX::SetIdx( ULONG nIdx )
+{
+ if( pPLCF ) pPLCF->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_SEPX::SeekPos( WW8_CP nCpPos )
+{
+ return pPLCF ? pPLCF->SeekPos( nCpPos ) : 0;
+}
+
+WW8_CP WW8PLCFx_SEPX::Where()
+{
+ return pPLCF ? pPLCF->Where() : 0;
+}
+
+void WW8PLCFx_SEPX::GetSprms( WW8PLCFxDesc* p )
+{
+ if( !pPLCF ) return;
+
+ void* pData;
+
+ p->bRealLineEnd = FALSE;
+ if (!pPLCF->Get( p->nStartPos, p->nEndPos, pData ))
+ {
+ p->nStartPos = p->nEndPos = LONG_MAX; // PLCF fertig abgearbeitet
+ p->pMemPos = 0;
+ }
+ else
+ {
+// long nPo = SVBT16ToShort( (unsigned char *)pData );
+// nPo <<= 9; // shift als LONG
+
+ long nPo = SVBT32ToLong( (unsigned char *)pData+2 );
+ //long nPo = SVBT16ToShort( (unsigned char *)pData+2 );
+
+ if ( nPo == 0xffffffffL )
+ {
+ p->nStartPos = p->nEndPos = LONG_MAX; // Sepx empty
+ p->pMemPos = 0;
+ }
+ else
+ {
+ pStrm->Seek( nPo );
+ *pStrm >> nSprmSiz; // read len
+
+ if( nSprmSiz > nArrMax )
+ { // passt nicht
+ delete( pSprms );
+ nArrMax = nSprmSiz; // Hole mehr Speicher
+ pSprms = new BYTE[nArrMax];
+ }
+ pStrm->Read( pSprms, nSprmSiz ); // read Sprms
+
+ p->nSprmsLen = nSprmSiz;
+ p->pMemPos = pSprms; // return Position
+ }
+ }
+}
+
+
+WW8PLCFx& WW8PLCFx_SEPX::operator ++( int )
+{
+ if( pPLCF )
+ (*pPLCF)++;
+ return *this;
+}
+
+
+BYTE* WW8PLCFx_SEPX::HasSprm( USHORT nId ) const
+{
+ return pPLCF ? WW8FindSprm( nId, nSprmSiz, pSprms, GetVersion() )
+ : 0;
+}
+
+
+BYTE* WW8PLCFx_SEPX::HasSprm( USHORT nId, BYTE* pOtherSprms,
+ long nOtherSprmSiz ) const
+{
+ return pPLCF ? WW8FindSprm( nId, nOtherSprmSiz, pOtherSprms, GetVersion() )
+ : 0;
+}
+
+
+
+BOOL WW8PLCFx_SEPX::Find4Sprms(USHORT nId1, USHORT nId2, USHORT nId3, USHORT nId4,
+ BYTE*& p1, BYTE*& p2, BYTE*& p3, BYTE*& p4 ) const
+{
+ if( !pPLCF ) return 0;
+
+ BOOL bFound = FALSE;
+ p1 = 0;
+ p2 = 0;
+ p3 = 0;
+ p4 = 0;
+
+ BYTE* pSp = pSprms;
+ short i;
+ BYTE nDelta = ( 8 > GetVersion()) ? 0 : 1;
+ for( i=0; i+1+nDelta < nSprmSiz; )
+ {
+ // Sprm gefunden?
+ USHORT nAktId = WW8GetSprmId( GetVersion(), pSp );
+ BOOL bOk = TRUE;
+ if( nAktId == nId1 )
+ p1 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId1 );
+ else
+ if( nAktId == nId2 )
+ p2 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId2 );
+ else
+ if( nAktId == nId3 )
+ p3 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId3 );
+ else
+ if( nAktId == nId4 )
+ p4 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId4 );
+ else
+ bOk = FALSE;
+ bFound |= bOk;
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ short x = WW8GetSprmSizeBrutto( GetVersion(), pSp, &nAktId );
+ i += x;
+ pSp += x;
+ }
+ return bFound;
+}
+
+BYTE* WW8PLCFx_SEPX::HasSprm( USHORT nId, BYTE n2nd ) const
+{
+ if( !pPLCF ) return 0;
+
+ BYTE* pSp = pSprms;
+ short i;
+ BYTE nDelta = ( 8 > GetVersion()) ? 0 : 1;
+
+ for( i=0; i+1+nDelta < nSprmSiz; )
+ {
+ // Sprm gefunden?
+ USHORT nAktId = WW8GetSprmId( GetVersion(), pSp );
+ if( ( nAktId == nId )
+ && ( pSp[ 1 + nDelta ] == n2nd ) )
+ return pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId );
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ short x = WW8GetSprmSizeBrutto( GetVersion(), pSp, &nAktId );
+ i += x;
+ pSp += x;
+ }
+ return 0; // Sprm nicht gefunden
+}
+
+//-----------------------------------------
+//-----------------------------------------
+
+WW8PLCFx_SubDoc::WW8PLCFx_SubDoc( SvStream* pSt, BYTE nVersion,
+ WW8_CP nStartCp,
+ long nFcRef, long nLenRef,
+ long nFcTxt, long nLenTxt,
+ long nStruct )
+ : WW8PLCFx( nVersion, FALSE ), pRef( 0 ), pTxt( 0 )
+{
+ if( nLenRef && nLenTxt )
+ {
+ pRef = new WW8PLCF( pSt, nFcRef, nLenRef, nStruct, nStartCp );
+ pTxt = new WW8PLCF( pSt, nFcTxt, nLenTxt, 0, nStartCp );
+ }
+}
+
+WW8PLCFx_SubDoc::~WW8PLCFx_SubDoc()
+{
+ delete pRef;
+ delete pTxt;
+}
+
+ULONG WW8PLCFx_SubDoc::GetIdx()
+{
+ if( pRef )
+ return ( pRef->GetIdx() << 16
+ | pTxt->GetIdx() ); // Wahrscheinlich pTxt... nicht noetig
+ return 0;
+}
+
+void WW8PLCFx_SubDoc::SetIdx( ULONG nIdx )
+{
+ if( pRef )
+ {
+ pRef->SetIdx( nIdx >> 16 );
+ pTxt->SetIdx( nIdx & 0xffff ); // Wahrscheinlich pTxt... nicht noetig
+ }
+}
+
+BOOL WW8PLCFx_SubDoc::SeekPos( WW8_CP nCpPos )
+{
+ return ( pRef ) ? pRef->SeekPos( nCpPos ) : FALSE;
+}
+
+WW8_CP WW8PLCFx_SubDoc::Where()
+{
+ return ( pRef ) ? pRef->Where() : LONG_MAX;
+}
+
+long WW8PLCFx_SubDoc::GetNoSprms( WW8_CP& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ long nSt, nE;
+ rEnd = LONG_MAX;
+
+ if ( !pRef )
+ {
+ rStart = LONG_MAX; // Es gibt keine Noten
+ rLen = 0;
+ return -1;
+ }
+
+ ULONG nNr = pRef->GetIdx();
+
+ if (!pRef->Get( rStart, nE, pData ))
+ {
+ rStart = LONG_MAX; // PLCF fertig abgearbeitet
+ rLen = 0;
+ return -1;
+ }
+ pTxt->SetIdx( nNr );
+
+ if(!pTxt->Get( nSt, rLen, pData ))
+ {
+ rStart = LONG_MAX; // PLCF fertig abgearbeitet
+ rLen = 0;
+ return -1;
+ }
+
+ rLen -= nSt;
+ return nSt;
+}
+
+WW8PLCFx& WW8PLCFx_SubDoc::operator ++( int )
+{
+ if( pRef && pTxt )
+ {
+ (*pRef)++;
+ (*pTxt)++;
+ }
+ return *this;
+}
+
+
+//-----------------------------------------
+// Felder
+//-----------------------------------------
+
+WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, WW8Fib& rMyFib,
+ short nType, WW8_CP nStartCp )
+ : WW8PLCFx( rMyFib.nVersion, FALSE ), rFib( rMyFib ), pPLCF( 0 )
+{
+
+ long nFc, nLen;
+
+ switch( nType )
+ {
+ case MAN_HDFT: nFc = rFib.fcPlcffldHdr;
+ nLen = rFib.lcbPlcffldHdr;
+ break;
+ case MAN_FTN: nFc = rFib.fcPlcffldFtn;
+ nLen = rFib.lcbPlcffldFtn;
+ break;
+ case MAN_EDN: nFc = rFib.fcPlcffldEdn;
+ nLen = rFib.lcbPlcffldEdn;
+ break;
+ case MAN_AND: nFc = rFib.fcPlcffldAtn;
+ nLen = rFib.lcbPlcffldAtn;
+ break;
+ case MAN_TXBX: nFc = rFib.fcPlcffldTxbx;
+ nLen = rFib.lcbPlcffldTxbx;
+ break;
+ case MAN_TXBX_HDFT:
+ nFc = rFib.fcPlcffldHdrTxbx;
+ nLen = rFib.lcbPlcffldHdrTxbx;
+ break;
+ default: nFc = rFib.fcPlcffldMom;
+ nLen = rFib.lcbPlcffldMom;
+ break;
+ }
+
+ if( nLen )
+ pPLCF = new WW8PLCFspecial( pSt, nFc, nLen, 2 );
+}
+
+WW8PLCFx_FLD::~WW8PLCFx_FLD()
+{
+ delete pPLCF;
+}
+
+ULONG WW8PLCFx_FLD::GetIdx()
+{
+ return ( pPLCF ) ? pPLCF->GetIdx() : 0;
+}
+
+void WW8PLCFx_FLD::SetIdx( ULONG nIdx )
+{
+ if( pPLCF )
+ pPLCF->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_FLD::SeekPos( WW8_CP nCpPos )
+{
+ return ( pPLCF ) ? pPLCF->SeekPosExact( nCpPos ) : FALSE;
+}
+
+WW8_CP WW8PLCFx_FLD::Where()
+{
+ return ( pPLCF ) ? pPLCF->Where() : LONG_MAX;
+}
+
+long WW8PLCFx_FLD::GetNoSprms( WW8_CP& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ ULONG nIdx;
+
+ rLen = 0;
+ rEnd = LONG_MAX; // Es gibt keine Ende
+
+ if ( !pPLCF ){
+ rStart = LONG_MAX; // Es gibt keine Felder
+ return -1;
+ }
+
+ if (!pPLCF->Get( rStart, pData )){
+ rStart = LONG_MAX; // PLCF fertig abgearbeitet
+ return -1;
+ }
+
+ nIdx = pPLCF->GetIdx();
+
+ return (long)nIdx;
+}
+
+WW8PLCFx& WW8PLCFx_FLD::operator ++( int )
+{
+ WW8SkipField( *pPLCF ); // gehe zum naechsten Feld
+ return *this;
+}
+
+BOOL WW8PLCFx_FLD::GetPara( long nIdx, WW8FieldDesc& rF )
+{
+ ASSERT( pPLCF, "Aufruf ohne Feld PLCFspecial" );
+ if( !pPLCF )
+ return FALSE;
+
+ ULONG n = pPLCF->GetIdx();
+ pPLCF->SetIdx( (ULONG)nIdx );
+
+ BOOL bOk = WW8GetFieldPara( rFib.nVersion, *pPLCF, rF );
+ pPLCF->SetIdx( n );
+ return bOk;
+}
+
+//-----------------------------------------
+// class WW8PLCF_Book
+//-----------------------------------------
+
+
+// MyMemCpy kopiert immer aufwaerts, d.h. pDest < pSource geht.
+/*inline*/ static void MyMemcpy( char* pDest, char* pSource, size_t nCount )
+{
+ register char* pEnd = pSource + nCount;
+ while( pSource < pEnd )
+ *pDest++ = *pSource++;
+}
+
+
+// ConvertPStrings() konvertiert ein offenes Array von Pascal-Strings
+// in C-Strings. Dieses geschieht am Platz. memcpy wird nicht benutzt,
+// da es nach MSC-Hilfe nicht mit ueberlappenden Bereichen umgehen kann,
+// memmove kann das, ist aber nicht nach ANSI - Standard.
+static void ConvertPStrings( WW8_PSTR** pPS, long nCount )
+{
+ register WW8_PSTR* pP;
+ register long i;
+ for( i=0; i<nCount; i++)
+ {
+ pP = pPS[i];
+ BYTE nLen = pP->nLen;
+ MyMemcpy( (char*)pP, (char*)pP->cStr, nLen );
+ pP->cStr[nLen-1] = 0;
+ }
+}
+
+
+char** WW8ReadSTTBF(BOOL bVer8, SvStream& rStrm, UINT32 nStart, INT32 nLen,
+ long& rCount, USHORT nSkip,BYTE ***pData)
+{
+ ULONG nOldPos = rStrm.Tell();
+ UINT16 nData = nLen - 2;
+
+ rCount = 0;
+
+ WW8_PSTR** pNameA;
+ UINT16 nLen2;
+
+ rStrm.Seek( nStart );
+ rStrm >> nLen2; // bVer67: total length of structure
+ // bVer8 : count of strings
+
+ if( bVer8 )
+ {
+ UINT16 nStrings;
+ BOOL bUnicode = (0xFFFF == nLen2);
+ if( bUnicode )
+ rStrm >> nStrings;
+ else
+ nStrings = nLen2;
+
+ UINT16 nExtra = 0;
+ rCount = nStrings;
+ rStrm >> nExtra;
+
+ pNameA = new WW8_PSTR*[ nStrings ]; // alloziere Index-Array
+ if (pData)
+ *pData = new BYTE*[ nStrings ];
+
+ for(USHORT i=0; i < nStrings; i++)
+ {
+ BYTE nBChar;
+ UINT16 nStrLen;
+ if( bUnicode )
+ rStrm >> nStrLen;
+ else
+ {
+ rStrm >> nBChar;
+ nStrLen = nBChar;
+ }
+
+ UniString aTmp;
+ aTmp.AllocStrBuf( nStrLen );
+
+ sal_Unicode* pWStr = aTmp.GetCharStr();
+
+ UINT16 nWChar;
+ for( BYTE nIdx = 0; nIdx < nStrLen; ++nIdx, ++pWStr )
+ {
+ if( bUnicode )
+ {
+ rStrm >> nWChar;
+ if( 0xF000 == (nWChar & 0xFF00))
+ nWChar &= 0x00FF;
+ *pWStr = nWChar;
+ }
+ else
+ {
+ rStrm >> nBChar;
+ *pWStr = nBChar;
+ }
+ }
+
+ // Skip the extra data
+ if( nExtra )
+ {
+ if (pData)
+ {
+ (*pData)[i] = new BYTE[ nExtra ];
+ for( BYTE nIdx2 = 0; nIdx2 < nExtra; ++nIdx2 )
+ rStrm >> (*pData)[i][nIdx2];
+
+ }
+ else
+ rStrm.SeekRel( nExtra );
+ }
+
+ String sConvert( aTmp, CHARSET_ANSI );
+
+ USHORT nActLen = sConvert.Len();
+ UINT8* pStr = new UINT8[ nActLen+1 ];
+
+ MyMemcpy( (char*)pStr, (char*)sConvert.GetStr(), nActLen );
+ pStr[ nActLen ] = 0;
+
+ pNameA[ i ] = (WW8_PSTR*)pStr;
+ }
+ }
+ else
+ {
+ WW8_PSTR* pA = (WW8_PSTR*)new char[ nData ];
+ // Alloziere Name-Array
+ rStrm.Read( pA, nData ); // lies alle Namen
+
+ long nLeft = nData; // Zaehle, wieviele Namen
+
+ WW8_PSTR* p = pA;
+
+ while( 1 )
+ {
+ short nNextSiz;
+
+ nNextSiz = p->nLen + 1;
+ if( nNextSiz > nLeft )
+ break;
+ rCount++;
+ nLeft -= nNextSiz;
+ if( nLeft < 1 ) // naechste Laenge muss gelesen werden koennen
+ break;
+ p = (WW8_PSTR*)( ( (char*)p ) + nNextSiz + nSkip );
+ }
+
+ if( rCount ) // Keine Eintraege -> kein Array
+ {
+ pNameA = new WW8_PSTR*[ rCount ]; // alloziere Index-Array
+
+ pNameA[0] = pA; // fuelle Index-Array
+
+ short i;
+ for( i=1, p=pA; i < rCount; i++)
+ {
+ p = (WW8_PSTR*)( ( (char*)p ) + p->nLen + 1 + nSkip );
+ pNameA[i] = p;
+ }
+ ConvertPStrings( pNameA, rCount );
+ }
+ else
+ {
+ pNameA = 0;
+ delete pA;
+ }
+ }
+ rStrm.Seek( nOldPos );
+ return (char**)pNameA;
+}
+
+
+WW8PLCFx_Book::WW8PLCFx_Book( SvStream* pSt, SvStream* pTblSt, WW8Fib& rFib, WW8_CP nStartCp )
+: WW8PLCFx( rFib.nVersion, FALSE ), nIsEnd( 0 ), pStatus( 0 )
+{
+ if( !rFib.fcPlcfbkf || !rFib.lcbPlcfbkf
+ || !rFib.fcPlcfbkl || !rFib.lcbPlcfbkl
+ || !rFib.fcSttbfbkmk || !rFib.lcbSttbfbkmk )
+ {
+ pBook[0] = pBook[1] = 0;
+ pBookNames = 0;
+ nIMax = 0;
+ return;
+ }
+ pBook[0] = new WW8PLCFspecial( pTblSt, rFib.fcPlcfbkf,
+ rFib.lcbPlcfbkf, 4 );
+
+ pBook[1] = new WW8PLCFspecial( pTblSt, rFib.fcPlcfbkl,
+ rFib.lcbPlcfbkl, 0, -1, TRUE );
+
+ pBookNames = WW8ReadSTTBF( (7 < rFib.nVersion),
+ *pTblSt,
+ rFib.fcSttbfbkmk,
+ rFib.lcbSttbfbkmk,
+ nIMax );
+
+ if( pBook[0]->GetIMax() < nIMax ) // Anzahl der Bookmarks
+ nIMax = pBook[0]->GetIMax();
+ if( pBook[1]->GetIMax() < nIMax )
+ nIMax = pBook[1]->GetIMax();
+ pStatus = new eBookStatus[ nIMax ];
+ memset( pStatus, 0, nIMax * sizeof( eBookStatus ) );
+}
+
+WW8PLCFx_Book::~WW8PLCFx_Book()
+{
+ delete[] ( pStatus );
+ if( pBookNames )
+ {
+ for( USHORT i=0, nEnd = (8 > GetVersion()) ? 1 : nIMax; i<nEnd; ++i )
+ delete( pBookNames[ i ] );
+ delete[]( pBookNames );
+ }
+ delete( pBook[1] );
+ delete( pBook[0] );
+}
+
+ULONG WW8PLCFx_Book::GetIdx()
+{
+ return ( pBookNames ) ? pBook[0]->GetIdx() : 0;
+}
+
+void WW8PLCFx_Book::SetIdx( ULONG nI )
+{
+ if( pBookNames )
+ pBook[0]->SetIdx( nI );
+}
+
+ULONG WW8PLCFx_Book::GetIdx2()
+{
+ return ( pBookNames )
+ ? ( pBook[1]->GetIdx() | ( ( nIsEnd ) ? 0x80000000 : 0 ) )
+ : 0;
+}
+
+void WW8PLCFx_Book::SetIdx2( ULONG nI )
+{
+ if( pBookNames ){
+ pBook[1]->SetIdx( nI & 0x7fffffff );
+ nIsEnd = (USHORT)( ( nI >> 31 ) & 1 ); // 0 oder 1
+ }
+}
+
+BOOL WW8PLCFx_Book::SeekPos( WW8_CP nCpPos )
+{
+ if( !pBook[0] )
+ return FALSE;
+ BOOL bOk = pBook[0]->SeekPosExact( nCpPos );
+ bOk &= pBook[1]->SeekPosExact( nCpPos );
+ nIsEnd = 0;
+
+ return bOk;
+}
+
+WW8_CP WW8PLCFx_Book::Where()
+{
+ return pBook[nIsEnd]->Where();
+}
+
+long WW8PLCFx_Book::GetNoSprms( long& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ rEnd = LONG_MAX;
+ rLen = 0;
+
+ if ( !pBook[0] || !pBook[1] || !pBookNames
+ || (long)(pBook[nIsEnd]->GetIdx()) >= nIMax ){
+ rStart = rEnd = LONG_MAX;
+ return -1;
+ }
+
+ pBook[nIsEnd]->Get( rStart, pData ); // Pos. abfragen
+
+ return pBook[nIsEnd]->GetIdx();
+}
+
+// Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
+// sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
+// Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
+// erst der Anfang und dann das Ende gefunden werden.
+// Der Fall: ][
+// [...]
+// ][
+// ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
+// vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
+// oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
+// noetig wird.
+WW8PLCFx& WW8PLCFx_Book::operator ++( int )
+{
+ if( pBook[0] && pBook[1] && pBookNames ){
+ (*pBook[nIsEnd])++;
+
+ register ULONG l0 = pBook[0]->Where();
+ register ULONG l1 = pBook[1]->Where();
+ if( l0 < l1 )
+ nIsEnd = 0;
+ else if( l1 < l0 )
+ nIsEnd = 1;
+ else
+ nIsEnd = ( nIsEnd ) ? 0 : 1;
+
+// nIsEnd = ( pBook[1]->Where() <= pBook[0]->Where() ) ? 1 : 0;
+ }
+ return *this;
+}
+
+long WW8PLCFx_Book::GetLen() const
+{
+ if( nIsEnd ){
+ ASSERT( ASS_FALSE, "Falscher Aufruf (1) von PLCF_Book::GetLen()" );
+ return 0;
+ }
+ void * p;
+ WW8_CP nStartPos;
+ if( !pBook[0]->Get( nStartPos, p ) ){
+ ASSERT( ASS_FALSE, "Falscher Aufruf (2) von PLCF_Book::GetLen()" );
+ return 0;
+ }
+ USHORT nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
+// USHORT nEndIdx = *(USHORT*)p;
+ return pBook[1]->GetPos( nEndIdx ) - nStartPos;
+}
+
+// IgnoreBook ist dafuer da, bei Feldern mit implizitem WW-Bookmark
+// die Bookmarks zwischen Anfang und Ende des Feldes zu ignorieren,
+// die den angegebenen Namen tragen.
+BOOL WW8PLCFx_Book::SetStatus( WW8_CP nStartRegion, WW8_CP nEndRegion, char* pName,
+ eBookStatus eStat )
+{
+ ASSERT( nStartRegion < LONG_MAX && nEndRegion < LONG_MAX,
+ "IgnoreBook mit falschen Parametern" );
+
+ if( !pBook[0] || !pBook[1] )
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ long i = 0;
+ WW8_CP nStartAkt, nEndAkt;
+ do{
+ void* p;
+ USHORT nEndIdx;
+
+ if( pBook[0]->GetData( i, nStartAkt, p ) && p ){
+ nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
+// nEndIdx = *((USHORT*)p);
+ }
+ else
+ {
+ ASSERT( ASS_FALSE, "Bookmark-EndIdx nicht lesbar" );
+ nEndIdx = (USHORT)i;
+ }
+ nEndAkt = pBook[1]->GetPos( nEndIdx );
+ if( nStartAkt >= nStartRegion && nEndAkt <= nEndRegion )
+#if defined( UNX) || defined( MAC)
+ if ( 0 == svstricmp( pName, pBookNames[i] ) ){
+#else
+ if ( 0 == stricmp( pName, pBookNames[i] ) ){
+#endif
+ pStatus[nEndIdx] = (eBookStatus)( pStatus[nEndIdx] | eStat );
+ bFound = TRUE;
+ }
+ i++;
+ }while( nStartAkt <= nEndRegion && i < pBook[0]->GetIMax() );
+ return bFound;
+}
+
+eBookStatus WW8PLCFx_Book::GetStatus() const
+{
+ if( !pStatus )
+ return BOOK_NORMAL;
+ long nEndIdx = GetHandle();
+ return ( nEndIdx < nIMax ) ? pStatus[nEndIdx] : BOOK_NORMAL;
+}
+
+long WW8PLCFx_Book::GetHandle() const
+{
+ if( !pBook[0] || !pBook[1] )
+ return LONG_MAX;
+
+ if( nIsEnd ){
+ return pBook[1]->GetIdx();
+ }else{
+// BOOL Get( long& rStart, void*& rpValue );
+ const void* p = pBook[0]->GetData( pBook[0]->GetIdx() );
+ if( p )
+ {
+ return SVBT16ToShort( *((SVBT16*)p) );
+// return *((USHORT*)p);
+ }
+ else
+ return LONG_MAX;
+ }
+}
+
+//-----------------------------------------
+// WW8PLCFMan
+//-----------------------------------------
+
+#ifndef DUMP
+
+// Am Ende eines Absatzes reichen bei WW6 die Attribute bis hinter das <CR>.
+// Das wird fuer die Verwendung mit dem SW um 1 Zeichen zurueckgesetzt, wenn
+// dadurch kein AErger zu erwarten ist.
+void WW8PLCFMan::AdjustEnds( WW8PLCFxDesc& rDesc )
+{
+ if ( (&rDesc == pPap) && rDesc.bRealLineEnd )
+ {
+ if ( pPap->nEndPos != LONG_MAX ) // Para adjust
+ {
+ nLineEnd = pPap->nEndPos; // nLineEnd zeigt *hinter* das <CR>
+ pPap->nEndPos--; // Absatzende um 1 Zeichen verkuerzen
+
+ if( pChp->nEndPos == nLineEnd ) // gibt es bereits ein CharAttr-Ende,
+ // das auf das jetzige Absatzende zeigt ?
+ pChp->nEndPos--; // ... dann auch um 1 Zeichen verkuerzen
+
+ if( pSep->nEndPos == nLineEnd ) // gibt es bereits ein Sep-Ende,
+ // das auf das jetzige Absatzende zeigt ?
+ pSep->nEndPos--; // ... dann auch um 1 Zeichen verkuerzen
+ }
+ }
+ else
+ if( (&rDesc == pChp)
+ || (&rDesc == pSep) )
+ { // Char Adjust oder Sep Adjust
+ if( (rDesc.nEndPos == nLineEnd) // Wenn Ende Char-Attr == Absatzende ...
+ && (rDesc.nEndPos > rDesc.nStartPos) )
+ rDesc.nEndPos--; // ... dann um 1 Zeichen verkuerzen
+ }
+
+ if( rDesc.nStartPos > rDesc.nEndPos ){ // allgemeiner Plausibilitaetstest
+
+ //if( gfhdf
+
+ ASSERT( ASS_FALSE, "+Anfang und Ende des WW86-Attributes stehen ueber Kreuz" );
+ rDesc.nEndPos = rDesc.nStartPos;
+ }
+}
+
+void WW8PLCFMan::GetNewSprms( WW8PLCFxDesc& rDesc )
+{
+ rDesc.pPLCFx->GetSprms( &rDesc );
+
+ //if( rDesc.nStartPos <= rDesc.nEndPos
+
+ ASSERT((LONG_MAX == rDesc.nStartPos) || (rDesc.nStartPos <= rDesc.nEndPos),
+ "Attr-Anfang und -Ende ueber Kreuz" );
+
+ if( rDesc.nStartPos != LONG_MAX ) rDesc.nStartPos -= rDesc.nCpOfs;
+ if( rDesc.nEndPos != LONG_MAX ) rDesc.nEndPos -= rDesc.nCpOfs;
+
+ rDesc.bFirstSprm = TRUE;
+
+ AdjustEnds( rDesc );
+}
+
+void WW8PLCFMan::GetNewNoSprms( WW8PLCFxDesc& rDesc )
+{
+ rDesc.nCp2OrIdx =
+ rDesc.pPLCFx->GetNoSprms(rDesc.nStartPos, rDesc.nEndPos,
+ rDesc.nSprmsLen);
+
+ ASSERT((LONG_MAX == rDesc.nStartPos) || (rDesc.nStartPos <= rDesc.nEndPos),
+ "Attr-Anfang und -Ende ueber Kreuz" );
+
+ if( rDesc.nStartPos != LONG_MAX ) rDesc.nStartPos -= rDesc.nCpOfs;
+ if( rDesc.nEndPos != LONG_MAX ) rDesc.nEndPos -= rDesc.nCpOfs;
+ rDesc.bFirstSprm = TRUE;
+}
+
+static USHORT GetId( BYTE nVersion, WW8PLCFxDesc* p, short nIdx )
+{
+ USHORT nId;
+
+ if( p->nSprmsLen > 0 )
+ // alt: nId = *p->pMemPos;
+ nId = WW8GetSprmId( nVersion, p->pMemPos );
+ else
+ nId = 0; // Id = 0 fuer leeres Attribut
+ return nId;
+}
+
+WW8PLCFMan::WW8PLCFMan( WW8ScannerBase* pBase, short nType, long nStartCp )
+{
+ pWwFib = pBase->pWw8Fib;
+
+ memset( aD, 0, sizeof( aD ) );
+ nLineEnd = LONG_MAX;
+ nManType = nType;
+ long nCpO;
+ USHORT i;
+
+ if( MAN_MAINTEXT == nType )
+ {
+ // Suchreihenfolge der Attribute
+ nPLCF = MAN_ANZ_PLCF;
+ pFld = &aD[0];
+ pBkm = &aD[1];
+ pEdn = &aD[2];
+ pFtn = &aD[3];
+ pAnd = &aD[4];
+ pChp = &aD[5];
+ pPap = &aD[6];
+ pSep = &aD[7];
+ pPcd = ( pBase->pPLCFx_PCD ) ? &aD[8] : 0;
+ pPcdA = ( pBase->pPLCFx_PCDAttrs ) ? &aD[9] : 0;
+ pSep->pPLCFx = pBase->pSepPLCF;
+ pFtn->pPLCFx = pBase->pFtnPLCF;
+ pEdn->pPLCFx = pBase->pEdnPLCF;
+ pBkm->pPLCFx = pBase->pBook;
+ pAnd->pPLCFx = pBase->pAndPLCF;
+ }
+ else
+ {
+ // Suchreihenfolge der Attribute
+ nPLCF = 7;
+ pFld = &aD[0];
+ pBkm = ( pBase->pBook ) ? &aD[1] : 0;
+ pChp = &aD[2];
+ pPap = &aD[3];
+ pSep = &aD[4]; // Dummy
+ pPcd = ( pBase->pPLCFx_PCD ) ? &aD[5] : 0;
+ pPcdA= ( pBase->pPLCFx_PCDAttrs ) ? &aD[6] : 0;
+ pAnd = pFtn = pEdn = 0; // unbenutzt bei SpezText
+ }
+
+ pChp->pPLCFx = pBase->pChpPLCF;
+ pPap->pPLCFx = pBase->pPapPLCF;
+ if( pPcd )
+ pPcd->pPLCFx = pBase->pPLCFx_PCD;
+ if( pPcdA )
+ pPcdA->pPLCFx= pBase->pPLCFx_PCDAttrs;
+ if( pBkm )
+ pBkm->pPLCFx = pBase->pBook;
+
+ switch( nType ) // Feld-Initialisierung
+ {
+ case MAN_HDFT: pFld->pPLCFx = pBase->pFldHdFtPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn;
+ pFdoa = pBase->pHdFtFdoa;
+ pTxbx = pBase->pHdFtTxbx;
+ pTxbxBkd = pBase->pHdFtTxbxBkd;
+ break;
+ case MAN_FTN: pFld->pPLCFx = pBase->pFldFtnPLCF;
+ nCpO = pWwFib->ccpText;
+ pFdoa = pTxbx = pTxbxBkd = 0;
+ break;
+ case MAN_EDN: pFld->pPLCFx = pBase->pFldEdnPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpAtn;
+ pFdoa = pTxbx = pTxbxBkd = 0;
+ break;
+ case MAN_AND: pFld->pPLCFx = pBase->pFldAndPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr;
+ pFdoa = pTxbx = pTxbxBkd = 0;
+ break;
+
+
+ case MAN_TXBX: pFld->pPLCFx = pBase->pFldTxbxPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpMcr
+ + pWwFib->ccpAtn + pWwFib->ccpEdn;
+ pTxbx = pBase->pMainTxbx;
+ pTxbxBkd = pBase->pMainTxbxBkd;
+ pFdoa = 0;
+ break;
+ case MAN_TXBX_HDFT:
+ pFld->pPLCFx = pBase->pFldTxbxHdFtPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpMcr
+ + pWwFib->ccpAtn + pWwFib->ccpEdn
+ + pWwFib->ccpTxbx;
+ pTxbx = pBase->pHdFtTxbx;
+ pTxbxBkd = pBase->pHdFtTxbxBkd;
+ pFdoa = 0;
+ break;
+
+
+ default: pFld->pPLCFx = pBase->pFldPLCF;
+ nCpO = 0;
+ pFdoa = pBase->pMainFdoa;
+ pTxbx = pBase->pMainTxbx;
+ pTxbxBkd = pBase->pMainTxbxBkd;
+ break;
+ }
+
+ if( nStartCp || nCpO ) // PLCFe auf Text-StartPos einstellen
+ {
+ pChp->pPLCFx->SeekPos( nStartCp + nCpO ); // Attribute neu
+ pPap->pPLCFx->SeekPos( nStartCp + nCpO ); // aufsetzen
+ pFld->pPLCFx->SeekPos( nStartCp );
+ if( pPcd )
+ pPcd->pPLCFx->SeekPos( nStartCp + nCpO );
+ if( pBkm )
+ pBkm->pPLCFx->SeekPos( nStartCp + nCpO );
+ }
+
+ // initialisieren der Member-Vars Low-Level
+ GetChpPLCF()->ResetAttrStartEnd();
+ GetPapPLCF()->ResetAttrStartEnd();
+ for( i=0; i<nPLCF; i++)
+ {
+ register WW8PLCFxDesc* p = &aD[i];
+
+ p->nCpOfs = ( p == pChp || p == pPap || p == pBkm ) ? nCpO : 0;
+ p->nCp2OrIdx = 0;
+ p->bFirstSprm = FALSE;
+ p->pIdStk = 0;
+ p->nStartPos = p->nEndPos = LONG_MAX;
+ }
+
+ // initialisieren der Member-Vars High-Level
+ for( i=0; i<nPLCF; i++){
+ register WW8PLCFxDesc* p = &aD[i];
+
+ if( !p->pPLCFx )
+ continue;
+
+ if( p->pPLCFx->IsSprm() )
+ {
+ p->pIdStk = new UShortStk; // Vorsicht: nEndPos muss bereits
+ GetNewSprms( *p ); // bei allen PLCFen initialisiert sein
+ }
+ else
+ {
+ if( p->pPLCFx )
+ GetNewNoSprms( *p );
+ }
+ }
+}
+
+WW8PLCFMan::~WW8PLCFMan()
+{
+ for( USHORT i=0; i<nPLCF; i++)
+ delete aD[i].pIdStk;
+}
+
+// 0. welche Attr.-Klasse,
+// 1. ob ein Attr.-Start ist,
+// 2. CP, wo ist naechste Attr.-Aenderung
+short WW8PLCFMan::WhereIdx( BOOL* pbStart, long* pPos )
+{
+ long next = LONG_MAX; // SuchReihenfolge:
+ short nextIdx = -1; // erst Enden finden ( CHP, PAP, ( SEP ) ),
+ BOOL bStart = TRUE; // dann Anfaenge finden ( ( SEP ), PAP, CHP )
+ short i;
+ register WW8PLCFxDesc* pD;
+ for( i=0; i<(short)nPLCF; i++)
+ {
+ pD = &aD[i];
+ if( ( pD->nEndPos < next )
+ && ( pD->nStartPos == LONG_MAX ) )
+ { // sonst ist Anfang = Ende
+ next = pD->nEndPos;
+ nextIdx = i;
+ bStart = FALSE;
+ }
+ }
+ for( i=(short)nPLCF-1; i>=0; i--)
+ {
+ pD = &aD[i];
+ if( pD->nStartPos < next ){
+ next = pD->nStartPos;
+ nextIdx = i;
+ bStart = TRUE;
+ }
+ }
+ if( pPos )
+ *pPos = next;
+ if( pbStart )
+ *pbStart = bStart;
+ return nextIdx;
+}
+
+WW8_CP WW8PLCFMan::Where() // gibt die CP-Pos der naechsten Attribut-Aenderung zurueck
+{
+ long l;
+ WhereIdx( 0, &l );
+ return l;
+}
+
+void WW8PLCFMan::Save1PLCFx( WW8PLCFxDesc* p, WW8PLCFxSave1* pSave ) const
+{
+ if( !p->pPLCFx )
+ return;
+ pSave->nPLCFxPos = p->pPLCFx->GetIdx();
+ pSave->nPLCFxPos2 = p->pPLCFx->GetIdx2();
+ if( p->pPLCFx->IsSprm() )
+ {
+ WW8PLCFxDesc aD;
+ p->pPLCFx->GetSprms( &aD );
+ pSave->nPLCFxMemOfs = p->pMemPos - aD.pMemPos;
+ }
+}
+
+void WW8PLCFMan::Restore1PLCFx( WW8PLCFxDesc* p, WW8PLCFxSave1* pSave )
+{
+ if( !p->pPLCFx )
+ return;
+ p->pPLCFx->SetIdx( pSave->nPLCFxPos ); // restore PLCF-Pos
+ p->pPLCFx->SetIdx2( pSave->nPLCFxPos2 );
+
+ if( p->pPLCFx->IsSprm() ){
+ WW8PLCFxDesc aD;
+ p->pPLCFx->GetSprms( &aD );
+ p->pMemPos = aD.pMemPos + pSave->nPLCFxMemOfs;
+ }
+}
+
+void WW8PLCFMan::SaveAllPLCFx( WW8PLCFxSaveAll* pSave )
+{
+ for(USHORT i=0; i<nPLCF; i++)
+ Save1PLCFx( &aD[i], &pSave->aS[i] );
+}
+
+void WW8PLCFMan::RestoreAllPLCFx( WW8PLCFxSaveAll* pSave )
+{
+ for(USHORT i=0; i<nPLCF; i++)
+ Restore1PLCFx( &aD[i], &pSave->aS[i] );
+}
+
+void WW8PLCFMan::GetSprmStart( short nIdx, WW8PLCFManResult* pRes )
+{
+
+ // Pruefen !!!
+
+ pRes->nMemLen = 0;
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ if( p->bFirstSprm ){ // erster Sprm einer Gruppe
+ if( p == pPap ) // Anfang neuer Pap ?
+ pRes->nFlags |= MAN_MASK_NEW_PAP; // dann muss Aufrufer auf neuen
+ // Style testen
+ else if( p == pSep ) // Anfang neuer Sep ?
+ pRes->nFlags |= MAN_MASK_NEW_SEP; // dann muss Aufrufer eine neue
+ // Section / Pagedesc erzeugen
+ }
+ pRes->pMemPos = p->pMemPos;
+ pRes->nSprmId = GetId( pWwFib->nVersion, p, nIdx );
+ if( p->nSprmsLen )
+ pRes->nMemLen = WW8GetSprmSizeBrutto( pWwFib->nVersion,
+ pRes->pMemPos,
+ &pRes->nSprmId ); // Laenge des akt. Sprm
+}
+
+void WW8PLCFMan::GetSprmEnd( short nIdx, WW8PLCFManResult* pRes )
+{
+
+ // Pruefen !!!
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ if( p->pIdStk->Count() )
+ pRes->nSprmId = p->pIdStk->Top(); // hole Ende-Position
+ else
+ {
+ ASSERT( ASS_FALSE, "Keine Id auf dem Stack" );
+ pRes->nSprmId = 0;
+ }
+}
+
+void WW8PLCFMan::GetNoSprmStart( short nIdx, WW8PLCFManResult* pRes )
+{
+
+ // Pruefen !!!
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+// long nEnd;
+
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( pRes->nCpPos, nEnd, pRes->nMemLen );
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( p->nStartPos, p->nEndPos,
+// p->nSprmsLen );
+// GetNoSprms( nIdx );
+ pRes->nCpPos = p->nStartPos;
+ pRes->nMemLen = p->nSprmsLen;
+ pRes->nCp2OrIdx = p->nCp2OrIdx;
+
+ if( p == pFld )
+ pRes->nSprmId = 258;
+ else if( p == pFtn )
+ pRes->nSprmId = 256;
+ else if( p == pEdn )
+ pRes->nSprmId = 257;
+ else if( p == pBkm )
+ pRes->nSprmId = 259;
+ else if( p == pPcd )
+ pRes->nSprmId = 260;
+ else if( p == pAnd )
+ pRes->nSprmId = 261;
+ else
+ pRes->nSprmId = 0; // default: nicht gefunden
+}
+
+void WW8PLCFMan::GetNoSprmEnd( short nIdx, WW8PLCFManResult* pRes )
+{
+
+ // Pruefen !!!
+
+ if( &aD[nIdx] == pBkm )
+ pRes->nSprmId = 259;
+ else if( &aD[nIdx] == pPcd )
+ pRes->nSprmId = 260;
+ else
+ pRes->nSprmId = 0;
+
+ pRes->nMemLen = -1; // Ende-Kennzeichen
+}
+
+
+//
+void WW8PLCFMan::AdvSprm( short nIdx, BOOL bStart )
+{
+ register WW8PLCFxDesc* p = &aD[nIdx]; // Sprm-Klasse(!) ermitteln
+
+ p->bFirstSprm = FALSE;
+ if( bStart )
+ {
+ USHORT nLastId = GetId( pWwFib->nVersion, p, nIdx );
+ p->pIdStk->Push( nLastId ); // merke Id fuer Attribut-Ende
+
+ if( p->nSprmsLen )
+ { /*
+ Pruefe, ob noch Sprm(s) abzuarbeiten sind
+ */
+
+ // Laenge des letzten Sprm
+ short nSprmL = WW8GetSprmSizeBrutto( pWwFib->nVersion, p->pMemPos, &nLastId );
+
+ // Gesamtlaenge Sprms um SprmLaenge verringern
+ p->nSprmsLen -= nSprmL;
+
+ // Pos des evtl. naechsten Sprm
+ if( p->nSprmsLen <= 0 )
+ p->pMemPos = 0; // sicherheitshalber auf Null setzen, da Enden folgen!
+ else
+ p->pMemPos += nSprmL;
+ }
+ if( p->nSprmsLen <= 0 )
+ p->nStartPos = LONG_MAX; // es folgen Enden
+ }
+ else
+ {
+ if( p->pIdStk->Count() )
+ p->pIdStk->Pop();
+ if( !p->pIdStk->Count() )
+ { // Kein weiterer Sprm auf dieser Pos ?
+ (*p->pPLCFx)++; // naechste Gruppe von Sprms
+ p->pMemPos = 0; // !!!
+ GetNewSprms( *p );
+ ASSERT( p->nStartPos <= p->nEndPos, "Attribut ueber Kreuz" );
+ }
+ }
+}
+
+void WW8PLCFMan::AdvNoSprm( short nIdx, BOOL bStart )
+{
+
+ // Pruefen !!!
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ if( p == pPcd ){ // NoSprm mit Ende
+ if( bStart ){
+ p->nStartPos = LONG_MAX;
+ }else{ // naechster NoSprm mit Ende
+ (*p->pPLCFx)++;
+ p->pMemPos = 0; // MemPos ungueltig
+ GetNewNoSprms( *p );
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( p->nStartPos, p->nEndPos,
+// p->nSprmsLen );
+ }
+ }else{ // NoSprm ohne Ende
+ (*p->pPLCFx)++;
+ p->pMemPos = 0; // MemPos ungueltig
+ GetNewNoSprms( *p );
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( p->nStartPos, p->nEndPos,
+// p->nSprmsLen );
+ }
+}
+
+WW8PLCFMan& WW8PLCFMan::operator ++(int)
+{
+ BOOL bStart;
+ short nIdx = WhereIdx( &bStart, 0 );
+ if( nPLCF > nIdx )
+ {
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ p->bFirstSprm = TRUE; // Default
+
+ if( p->pPLCFx->IsSprm() )
+ AdvSprm( nIdx, bStart );
+ else // NoSprm
+ AdvNoSprm( nIdx, bStart );
+ }
+ return *this;
+}
+
+// Rueckgabe TRUE fuer Anfang eines Attributes oder Fehler,
+// FALSE fuer Ende d. Attr
+// Restliche Rueckgabewerte werden in der vom Aufrufer zu stellenden Struktur
+// WW8PclxManResults geliefert.
+BOOL WW8PLCFMan::Get( WW8PLCFManResult* pRes )
+{
+ pRes->nMemLen = pRes->nFlags = 0;
+ pRes->nCpPos = 0; // Defaults
+ pRes->pMemPos = 0;
+
+ BOOL bStart;
+ short nIdx = WhereIdx( &bStart, 0 );
+
+ if( nIdx < 0 ){
+ ASSERT( ASS_FALSE, "Position nicht gefunden" );
+ return TRUE;
+ }
+
+ if( aD[nIdx].pPLCFx->IsSprm() ){
+ if( bStart ){
+ GetSprmStart( nIdx, pRes );
+ return TRUE;
+ }else{
+ GetSprmEnd( nIdx, pRes );
+ return FALSE;
+ }
+ }else{
+/*
+ if( &aD[nIdx] == pPcd ){ // Piece-Ende
+ pRes->nId = -4;
+ pRes->nMemLen = ( bStart ) ? 0 : -1;
+ return bStart;
+ }else
+*/
+ if( bStart ){
+ GetNoSprmStart( nIdx, pRes );
+ return TRUE;
+ }else{
+ GetNoSprmEnd( nIdx, pRes );
+ return FALSE;
+ }
+ }
+}
+
+USHORT WW8PLCFMan::GetColl() const
+{
+ if( pPap->pPLCFx ){
+ return pPap->pPLCFx->GetIstd();
+ }else{
+ ASSERT( ASS_FALSE, "GetColl ohne PLCF_Pap" );
+ return 0;
+ }
+}
+
+WW8PLCFx_FLD* WW8PLCFMan::GetFld() const
+{
+ return (WW8PLCFx_FLD*)pFld->pPLCFx;
+}
+
+BYTE* WW8PLCFMan::HasParaSprm( USHORT nId ) const
+{
+ return ((WW8PLCFx_Cp_FKP*)pPap->pPLCFx)->HasSprm( nId );
+}
+
+BYTE* WW8PLCFMan::HasCharSprm( USHORT nId ) const
+{
+ return ((WW8PLCFx_Cp_FKP*)pChp->pPLCFx)->HasSprm( nId );
+}
+
+#endif // !DUMP
+
+//-----------------------------------------
+
+
+WW8Fib::WW8Fib( SvStream& rSt, BYTE nWantedVersion,UINT32 nOffset ): nFibError( 0 )
+{
+ BYTE aBits1;
+ BYTE aBits2;
+ BYTE aVer8Bits1; // nur ab WinWord 8 benutzt
+ rSt.Seek( nOffset );
+ /*
+ Wunsch-Nr vermerken, File-Versionsnummer ermitteln
+ und gegen Wunsch-Nr. checken !
+ */
+ nVersion = nWantedVersion;
+ rSt >> wIdent;
+ rSt >> nFib;
+ rSt >> nProduct;
+ if( 0 != rSt.GetError() )
+ {
+ INT16 nFibMin;
+ INT16 nFibMax;
+ switch( nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6: nFibMin = 0x0065; // von 101 WinWord 6.0
+ // 102 "
+ // und 103 WinWord 6.0 fuer Macintosh
+ // 104 "
+ nFibMax = 0x0069; // bis 105 WinWord 95
+ break;
+ case 7: nFibMin = 0x0069; // von 105 WinWord 95
+ nFibMax = 0x0069; // bis 105 WinWord 95
+ break;
+ case 8: nFibMin = 0x006A; // von 106 WinWord 97
+ nFibMax = 0x00c1; // bis 193 WinWord 97 (?)
+ break;
+ default:nFibMin = 0; // Programm-Fehler!
+ nFibMax = 0;
+ nFib = 1;
+ ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+ if( ( nFib < nFibMin )
+ || ( nFib > nFibMax ) )
+ {
+ nFibError = ERR_SWG_READ_ERROR; // Error melden
+ return; // und hopp raus!
+ }
+ }
+
+ // praktische Hilfsvariablen:
+ BOOL bVer67 = ((6 == nVersion) || (7 == nVersion));
+ BOOL bVer8 = (8 == nVersion);
+
+ // Hilfs-Varis fuer Ver67:
+ INT16 pnChpFirst_Ver67;
+ INT16 pnPapFirst_Ver67;
+ INT16 cpnBteChp_Ver67;
+ INT16 cpnBtePap_Ver67;
+
+ // und auf gehts: FIB einlesen
+ rSt >> lid;
+ rSt >> pnNext;
+ rSt >> aBits1;
+ rSt >> aBits2;
+ rSt >> nFibBack;
+ rSt >> lKey1;
+ rSt >> lKey2;
+ rSt >> envr;
+ rSt >> aVer8Bits1; // unter Ver67 nur leeres Reservefeld
+ // Inhalt von aVer8Bits1
+ //
+ // BYTE fMac :1;
+ // BYTE fEmptySpecial :1;
+ // BYTE fLoadOverridePage :1;
+ // BYTE fFuturesavedUndo :1;
+ // BYTE fWord97Saved :1;
+ // BYTE :3;
+ rSt >> chse;
+ rSt >> chseTables;
+ rSt >> fcMin;
+ rSt >> fcMac;
+
+// Einschub fuer WW8 *****************************************************
+ if( !bVer67 )
+ {
+ rSt >> csw;
+
+ // Marke: "rgsw" Beginning of the array of shorts
+ rSt >> wMagicCreated;
+ rSt >> wMagicRevised;
+ rSt >> wMagicCreatedPrivate;
+ rSt >> wMagicRevisedPrivate;
+ rSt.SeekRel( 9 * sizeof( INT16 ) );
+
+ /*
+ // dies sind die 9 unused Felder:
+ && (bVer67 || WW8ReadINT16( rSt, pnFbpChpFirst_W6 )) // 1
+ && (bVer67 || WW8ReadINT16( rSt, pnChpFirst_W6 )) // 2
+ && (bVer67 || WW8ReadINT16( rSt, cpnBteChp_W6 )) // 3
+ && (bVer67 || WW8ReadINT16( rSt, pnFbpPapFirst_W6 )) // 4
+ && (bVer67 || WW8ReadINT16( rSt, pnPapFirst_W6 )) // 5
+ && (bVer67 || WW8ReadINT16( rSt, cpnBtePap_W6 )) // 6
+ && (bVer67 || WW8ReadINT16( rSt, pnFbpLvcFirst_W6 )) // 7
+ && (bVer67 || WW8ReadINT16( rSt, pnLvcFirst_W6 )) // 8
+ && (bVer67 || WW8ReadINT16( rSt, cpnBteLvc_W6 )) // 9
+ */
+ rSt >> lidFE;
+ rSt >> clw;
+ }
+
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rglw" Beginning of the array of longs
+ rSt >> cbMac;
+
+ // 2 Longs uebergehen, da unwichtiger Quatsch
+ rSt.SeekRel( 2 * sizeof( INT32) );
+
+ // weitere 2 Longs nur bei Ver67 ueberspringen
+ if( bVer67 )
+ rSt.SeekRel( 2 * sizeof( INT32) );
+
+ rSt >> ccpText;
+ rSt >> ccpFtn;
+ rSt >> ccpHdr;
+ rSt >> ccpMcr;
+ rSt >> ccpAtn;
+ rSt >> ccpEdn;
+ rSt >> ccpTxbx;
+ rSt >> ccpHdrTxbx;
+
+ // weiteres Long nur bei Ver67 ueberspringen
+ if( bVer67 )
+ rSt.SeekRel( 1 * sizeof( INT32) );
+ else
+ {
+// Einschub fuer WW8 *****************************************************
+ rSt >> pnFbpChpFirst;
+ rSt >> pnChpFirst;
+ rSt >> cpnBteChp;
+ rSt >> pnFbpPapFirst;
+ rSt >> pnPapFirst;
+ rSt >> cpnBtePap;
+ rSt >> pnFbpLvcFirst;
+ rSt >> pnLvcFirst;
+ rSt >> cpnBteLvc;
+ rSt >> fcIslandFirst;
+ rSt >> fcIslandLim;
+ rSt >> cfclcb;
+ }
+
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
+ rSt >> fcStshfOrig;
+ rSt >> lcbStshfOrig;
+ rSt >> fcStshf;
+ rSt >> lcbStshf;
+ rSt >> fcPlcffndRef;
+ rSt >> lcbPlcffndRef;
+ rSt >> fcPlcffndTxt;
+ rSt >> lcbPlcffndTxt;
+ rSt >> fcPlcfandRef;
+ rSt >> lcbPlcfandRef;
+ rSt >> fcPlcfandTxt;
+ rSt >> lcbPlcfandTxt;
+ rSt >> fcPlcfsed;
+ rSt >> lcbPlcfsed;
+ rSt >> fcPlcfpad;
+ rSt >> lcbPlcfpad;
+ rSt >> fcPlcfphe;
+ rSt >> lcbPlcfphe;
+ rSt >> fcSttbfglsy;
+ rSt >> lcbSttbfglsy;
+ rSt >> fcPlcfglsy;
+ rSt >> lcbPlcfglsy;
+ rSt >> fcPlcfhdd;
+ rSt >> lcbPlcfhdd;
+ rSt >> fcPlcfbteChpx;
+ rSt >> lcbPlcfbteChpx;
+ rSt >> fcPlcfbtePapx;
+ rSt >> lcbPlcfbtePapx;
+ rSt >> fcPlcfsea;
+ rSt >> lcbPlcfsea;
+ rSt >> fcSttbfffn;
+ rSt >> lcbSttbfffn;
+ rSt >> fcPlcffldMom;
+ rSt >> lcbPlcffldMom;
+ rSt >> fcPlcffldHdr;
+ rSt >> lcbPlcffldHdr;
+ rSt >> fcPlcffldFtn;
+ rSt >> lcbPlcffldFtn;
+ rSt >> fcPlcffldAtn;
+ rSt >> lcbPlcffldAtn;
+ rSt >> fcPlcffldMcr;
+ rSt >> lcbPlcffldMcr;
+ rSt >> fcSttbfbkmk;
+ rSt >> lcbSttbfbkmk;
+ rSt >> fcPlcfbkf;
+ rSt >> lcbPlcfbkf;
+ rSt >> fcPlcfbkl;
+ rSt >> lcbPlcfbkl;
+ rSt >> fcCmds;
+ rSt >> lcbCmds;
+ rSt >> fcPlcfmcr;
+ rSt >> lcbPlcfmcr;
+ rSt >> fcSttbfmcr;
+ rSt >> lcbSttbfmcr;
+ rSt >> fcPrDrvr;
+ rSt >> lcbPrDrvr;
+ rSt >> fcPrEnvPort;
+ rSt >> lcbPrEnvPort;
+ rSt >> fcPrEnvLand;
+ rSt >> lcbPrEnvLand;
+ rSt >> fcWss;
+ rSt >> lcbWss;
+ rSt >> fcDop;
+ rSt >> lcbDop;
+ rSt >> fcSttbfAssoc;
+ rSt >> cbSttbfAssoc;
+ rSt >> fcClx;
+ rSt >> lcbClx;
+ rSt >> fcPlcfpgdFtn;
+ rSt >> lcbPlcfpgdFtn;
+ rSt >> fcAutosaveSource;
+ rSt >> lcbAutosaveSource;
+ rSt >> fcGrpStAtnOwners;
+ rSt >> lcbGrpStAtnOwners;
+ rSt >> fcSttbfAtnbkmk;
+ rSt >> lcbSttbfAtnbkmk;
+
+ // weiteres short nur bei Ver67 ueberspringen
+ if( bVer67 )
+ {
+ rSt.SeekRel( 1*sizeof( INT16) );
+
+ // folgende 4 Shorts existieren nur bei Ver67;
+ rSt >> pnChpFirst_Ver67;
+ rSt >> pnPapFirst_Ver67;
+ rSt >> cpnBteChp_Ver67;
+ rSt >> cpnBtePap_Ver67;
+ }
+
+ rSt >> fcPlcfdoaMom;
+ rSt >> lcbPlcfdoaMom;
+ rSt >> fcPlcfdoaHdr;
+ rSt >> lcbPlcfdoaHdr;
+ rSt >> fcPlcfspaMom;
+ rSt >> lcbPlcfspaMom;
+ rSt >> fcPlcfspaHdr;
+ rSt >> lcbPlcfspaHdr;
+
+ rSt >> fcPlcfAtnbkf;
+ rSt >> lcbPlcfAtnbkf;
+ rSt >> fcPlcfAtnbkl;
+ rSt >> lcbPlcfAtnbkl;
+ rSt >> fcPms;
+ rSt >> lcbPMS;
+ rSt >> fcFormFldSttbf;
+ rSt >> lcbFormFldSttbf;
+ rSt >> fcPlcfendRef;
+ rSt >> lcbPlcfendRef;
+ rSt >> fcPlcfendTxt;
+ rSt >> lcbPlcfendTxt;
+ rSt >> fcPlcffldEdn;
+ rSt >> lcbPlcffldEdn;
+ rSt >> fcPlcfpgdEdn;
+ rSt >> lcbPlcfpgdEdn;
+ rSt >> fcDggInfo;
+ rSt >> lcbDggInfo;
+ rSt >> fcSttbfRMark;
+ rSt >> lcbSttbfRMark;
+ rSt >> fcSttbfCaption;
+ rSt >> lcbSttbfCaption;
+ rSt >> fcSttbAutoCaption;
+ rSt >> lcbSttbAutoCaption;
+ rSt >> fcPlcfwkb;
+ rSt >> lcbPlcfwkb;
+ rSt >> fcPlcfspl;
+ rSt >> lcbPlcfspl;
+ rSt >> fcPlcftxbxTxt;
+ rSt >> lcbPlcftxbxTxt;
+ rSt >> fcPlcffldTxbx;
+ rSt >> lcbPlcffldTxbx;
+ rSt >> fcPlcfHdrtxbxTxt;
+ rSt >> lcbPlcfHdrtxbxTxt;
+ rSt >> fcPlcffldHdrTxbx;
+ rSt >> lcbPlcffldHdrTxbx;
+
+ if( 0 == rSt.GetError() )
+ {
+ // Bit-Flags setzen
+ fDot = aBits1 & 0x01 ;
+ fGlsy = ( aBits1 & 0x02 ) >> 1;
+ fComplex = ( aBits1 & 0x04 ) >> 2;
+ fHasPic = ( aBits1 & 0x08 ) >> 3;
+ cQuickSaves = ( aBits1 & 0xf0 ) >> 4;
+ fEncrypted = aBits2 & 0x01 ;
+ fWhichTblStm= ( aBits2 & 0x02 ) >> 1;
+ // dummy = ( aBits2 & 0x0e ) >> 1;
+ fExtChar = ( aBits2 & 0x10 ) >> 4;
+ // dummy = ( aBits2 & 0xe0 ) >> 5;
+
+ /*
+ ggfs. Ziel-Varaiblen, aus xxx_Ver67 fuellen
+ oder Flags setzen
+ */
+ if( bVer67 )
+ {
+ pnChpFirst = pnChpFirst_Ver67;
+ pnPapFirst = pnPapFirst_Ver67;
+ cpnBteChp = cpnBteChp_Ver67;
+ cpnBtePap = cpnBtePap_Ver67;
+ }
+ else if( bVer8 )
+ {
+ fMac = aVer8Bits1 & 0x01 ;
+ fEmptySpecial = ( aVer8Bits1 & 0x02 ) >> 1;
+ fLoadOverridePage = ( aVer8Bits1 & 0x04 ) >> 2;
+ fFuturesavedUndo = ( aVer8Bits1 & 0x08 ) >> 3;
+ fWord97Saved = ( aVer8Bits1 & 0x10 ) >> 4;
+
+ /*
+ speziell fuer WW8:
+ ermittle die Werte fuer PLCF LST und PLF LFO
+ und PLCF fuer TextBox-Break-Deskriptoren
+ */
+ long nOldPos = rSt.Tell();
+ rSt.Seek( 0x02e2 );
+ rSt >> fcPlcfLst;
+ rSt >> lcbPlcfLst;
+ rSt >> fcPlfLfo;
+ rSt >> lcbPlfLfo;
+ rSt >> fcPlcftxbxBkd;
+ rSt >> lcbPlcftxbxBkd;
+ rSt >> fcPlcfHdrtxbxBkd;
+ rSt >> lcbPlcfHdrtxbxBkd;
+ if( 0 != rSt.GetError() )
+ {
+ nFibError = ERR_SWG_READ_ERROR;
+ }
+
+ rSt.Seek( 0x372 ); // fcSttbListNames
+ rSt >> fcSttbListNames;
+ rSt >> lcbSttbListNames;
+ if( 0 != rSt.GetError() )
+ nFibError = ERR_SWG_READ_ERROR;
+
+ rSt.Seek( nOldPos );
+ }
+ }
+ else
+ {
+ nFibError = ERR_SWG_READ_ERROR; // Error melden
+ }
+}
+
+
+WW8Fib::WW8Fib( BYTE nVer )
+{
+ memset( this, 0, sizeof( *this ));
+ nVersion = nVer;
+ if( 8 == nVer )
+ {
+ fcMin = 0x400;
+ wIdent = 0xa5ec;
+ nFib = nFibBack = 0xc1;
+ nProduct = 0x49;
+
+ csw = 0x0e; // muss das sein ???
+ cfclcb = 0x5d; // -""-
+ clw = 0x16; // -""-
+ pnFbpChpFirst = pnFbpPapFirst = pnFbpLvcFirst = 0x000fffff;
+ fExtChar = TRUE;
+
+// diese Flags muessen nicht gesetzt werden; koennen aber.
+// wMagicCreated = wMagicRevised = 0x6a62;
+// wMagicCreatedPrivate = wMagicRevisedPrivate = 0xb3b2;
+// fWord97Saved = TRUE;
+ }
+ else
+ {
+ fcMin = 0x300;
+ wIdent = 0xa5dc;
+ nFib = nFibBack = 0x65;
+ nProduct = 0xc02d;
+ }
+
+ lid = 0x407;
+}
+
+
+BOOL WW8Fib::Write( SvStream& rStrm )
+{
+ BYTE* pData = new BYTE[ fcMin ];
+ BYTE* pDataPtr = pData;
+ memset( pData, 0, fcMin );
+
+ BOOL bVer8 = 8 == nVersion;
+
+ ULONG nPos = rStrm.Tell();
+ cbMac = rStrm.Seek( STREAM_SEEK_TO_END );
+ rStrm.Seek( nPos );
+
+ Set_UInt16( pData, wIdent );
+ Set_UInt16( pData, nFib );
+ Set_UInt16( pData, nProduct );
+ Set_UInt16( pData, lid );
+ Set_UInt16( pData, pnNext );
+
+ UINT16 nBits16 = 0;
+ if( fDot ) nBits16 |= 0x0001;
+ if( fGlsy) nBits16 |= 0x0002;
+ if( fComplex ) nBits16 |= 0x0004;
+ if( fHasPic ) nBits16 |= 0x0008;
+ nBits16 |= (0xf0 & ( cQuickSaves << 4 ));
+ if( fEncrypted ) nBits16 |= 0x0100;
+ if( fWhichTblStm ) nBits16 |= 0x0200;
+ if( fExtChar ) nBits16 |= 0x1000;
+ Set_UInt16( pData, nBits16 );
+
+ Set_UInt16( pData, nFibBack );
+ Set_UInt16( pData, lKey1 );
+ Set_UInt16( pData, lKey2 );
+ Set_UInt8( pData, envr );
+
+ BYTE nBits8 = 0;
+ if( bVer8 )
+ {
+ if( fMac ) nBits8 |= 0x0001;
+ if( fEmptySpecial ) nBits8 |= 0x0002;
+ if( fLoadOverridePage ) nBits8 |= 0x0004;
+ if( fFuturesavedUndo ) nBits8 |= 0x0008;
+ if( fWord97Saved ) nBits8 |= 0x0010;
+ }
+ Set_UInt8( pData, nBits8 ); // unter Ver67 nur leeres Reservefeld
+
+ Set_UInt16( pData, chse );
+ Set_UInt16( pData, chseTables );
+ Set_UInt32( pData, fcMin );
+ Set_UInt32( pData, fcMac );
+
+// Einschub fuer WW8 *****************************************************
+
+ // Marke: "rgsw" Beginning of the array of shorts
+ if( bVer8 )
+ {
+ Set_UInt16( pData, csw );
+ Set_UInt16( pData, wMagicCreated );
+ Set_UInt16( pData, wMagicRevised );
+ Set_UInt16( pData, wMagicCreatedPrivate );
+ Set_UInt16( pData, wMagicRevisedPrivate );
+ pData += 9 * sizeof( INT16 );
+ Set_UInt16( pData, lidFE );
+ Set_UInt16( pData, clw );
+ }
+
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rglw" Beginning of the array of longs
+ Set_UInt32( pData, cbMac );
+
+ // 2 Longs uebergehen, da unwichtiger Quatsch
+ pData += 2 * sizeof( INT32);
+
+ // weitere 2 Longs nur bei Ver67 ueberspringen
+ if( !bVer8 ) pData += 2 * sizeof( INT32);
+
+ Set_UInt32( pData, ccpText );
+ Set_UInt32( pData, ccpFtn );
+ Set_UInt32( pData, ccpHdr );
+ Set_UInt32( pData, ccpMcr );
+ Set_UInt32( pData, ccpAtn );
+ Set_UInt32( pData, ccpEdn );
+ Set_UInt32( pData, ccpTxbx );
+ Set_UInt32( pData, ccpHdrTxbx );
+
+ // weiteres Long nur bei Ver67 ueberspringen
+ if( !bVer8 ) pData += 1 * sizeof( INT32);
+
+// Einschub fuer WW8 *****************************************************
+ if( bVer8 )
+ {
+ Set_UInt32( pData, pnFbpChpFirst );
+ Set_UInt32( pData, pnChpFirst );
+ Set_UInt32( pData, cpnBteChp );
+ Set_UInt32( pData, pnFbpPapFirst );
+ Set_UInt32( pData, pnPapFirst );
+ Set_UInt32( pData, cpnBtePap );
+ Set_UInt32( pData, pnFbpLvcFirst );
+ Set_UInt32( pData, pnLvcFirst );
+ Set_UInt32( pData, cpnBteLvc );
+ Set_UInt32( pData, fcIslandFirst );
+ Set_UInt32( pData, fcIslandLim );
+ Set_UInt16( pData, cfclcb );
+ }
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
+ Set_UInt32( pData, fcStshfOrig );
+ Set_UInt32( pData, lcbStshfOrig );
+ Set_UInt32( pData, fcStshf );
+ Set_UInt32( pData, lcbStshf );
+ Set_UInt32( pData, fcPlcffndRef );
+ Set_UInt32( pData, lcbPlcffndRef );
+ Set_UInt32( pData, fcPlcffndTxt );
+ Set_UInt32( pData, lcbPlcffndTxt );
+ Set_UInt32( pData, fcPlcfandRef );
+ Set_UInt32( pData, lcbPlcfandRef );
+ Set_UInt32( pData, fcPlcfandTxt );
+ Set_UInt32( pData, lcbPlcfandTxt );
+ Set_UInt32( pData, fcPlcfsed );
+ Set_UInt32( pData, lcbPlcfsed );
+ Set_UInt32( pData, fcPlcfpad );
+ Set_UInt32( pData, lcbPlcfpad );
+ Set_UInt32( pData, fcPlcfphe );
+ Set_UInt32( pData, lcbPlcfphe );
+ Set_UInt32( pData, fcSttbfglsy );
+ Set_UInt32( pData, lcbSttbfglsy );
+ Set_UInt32( pData, fcPlcfglsy );
+ Set_UInt32( pData, lcbPlcfglsy );
+ Set_UInt32( pData, fcPlcfhdd );
+ Set_UInt32( pData, lcbPlcfhdd );
+ Set_UInt32( pData, fcPlcfbteChpx );
+ Set_UInt32( pData, lcbPlcfbteChpx );
+ Set_UInt32( pData, fcPlcfbtePapx );
+ Set_UInt32( pData, lcbPlcfbtePapx );
+ Set_UInt32( pData, fcPlcfsea );
+ Set_UInt32( pData, lcbPlcfsea );
+ Set_UInt32( pData, fcSttbfffn );
+ Set_UInt32( pData, lcbSttbfffn );
+ Set_UInt32( pData, fcPlcffldMom );
+ Set_UInt32( pData, lcbPlcffldMom );
+ Set_UInt32( pData, fcPlcffldHdr );
+ Set_UInt32( pData, lcbPlcffldHdr );
+ Set_UInt32( pData, fcPlcffldFtn );
+ Set_UInt32( pData, lcbPlcffldFtn );
+ Set_UInt32( pData, fcPlcffldAtn );
+ Set_UInt32( pData, lcbPlcffldAtn );
+ Set_UInt32( pData, fcPlcffldMcr );
+ Set_UInt32( pData, lcbPlcffldMcr );
+ Set_UInt32( pData, fcSttbfbkmk );
+ Set_UInt32( pData, lcbSttbfbkmk );
+ Set_UInt32( pData, fcPlcfbkf );
+ Set_UInt32( pData, lcbPlcfbkf );
+ Set_UInt32( pData, fcPlcfbkl );
+ Set_UInt32( pData, lcbPlcfbkl );
+ Set_UInt32( pData, fcCmds );
+ Set_UInt32( pData, lcbCmds );
+ Set_UInt32( pData, fcPlcfmcr );
+ Set_UInt32( pData, lcbPlcfmcr );
+ Set_UInt32( pData, fcSttbfmcr );
+ Set_UInt32( pData, lcbSttbfmcr );
+ Set_UInt32( pData, fcPrDrvr );
+ Set_UInt32( pData, lcbPrDrvr );
+ Set_UInt32( pData, fcPrEnvPort );
+ Set_UInt32( pData, lcbPrEnvPort );
+ Set_UInt32( pData, fcPrEnvLand );
+ Set_UInt32( pData, lcbPrEnvLand );
+ Set_UInt32( pData, fcWss );
+ Set_UInt32( pData, lcbWss );
+ Set_UInt32( pData, fcDop );
+ Set_UInt32( pData, lcbDop );
+ Set_UInt32( pData, fcSttbfAssoc );
+ Set_UInt32( pData, cbSttbfAssoc );
+ Set_UInt32( pData, fcClx );
+ Set_UInt32( pData, lcbClx );
+ Set_UInt32( pData, fcPlcfpgdFtn );
+ Set_UInt32( pData, lcbPlcfpgdFtn );
+ Set_UInt32( pData, fcAutosaveSource );
+ Set_UInt32( pData, lcbAutosaveSource );
+ Set_UInt32( pData, fcGrpStAtnOwners );
+ Set_UInt32( pData, lcbGrpStAtnOwners );
+ Set_UInt32( pData, fcSttbfAtnbkmk );
+ Set_UInt32( pData, lcbSttbfAtnbkmk );
+
+ // weiteres short nur bei Ver67 ueberspringen
+ if( !bVer8 )
+ {
+ pData += 1*sizeof( INT16);
+ Set_UInt16( pData, (UINT16)pnChpFirst );
+ Set_UInt16( pData, (UINT16)pnPapFirst );
+ Set_UInt16( pData, (UINT16)cpnBteChp );
+ Set_UInt16( pData, (UINT16)cpnBtePap );
+ }
+
+ Set_UInt32( pData, fcPlcfdoaMom ); // nur bei Ver67, in Ver8 unused
+ Set_UInt32( pData, lcbPlcfdoaMom ); // nur bei Ver67, in Ver8 unused
+ Set_UInt32( pData, fcPlcfdoaHdr ); // nur bei Ver67, in Ver8 unused
+ Set_UInt32( pData, lcbPlcfdoaHdr ); // nur bei Ver67, in Ver8 unused
+
+ Set_UInt32( pData, fcPlcfspaMom ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbPlcfspaMom ); // in Ver67 leere Reserve
+ Set_UInt32( pData, fcPlcfspaHdr ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbPlcfspaHdr ); // in Ver67 leere Reserve
+
+ Set_UInt32( pData, fcPlcfAtnbkf );
+ Set_UInt32( pData, lcbPlcfAtnbkf );
+ Set_UInt32( pData, fcPlcfAtnbkl );
+ Set_UInt32( pData, lcbPlcfAtnbkl );
+ Set_UInt32( pData, fcPms );
+ Set_UInt32( pData, lcbPMS );
+ Set_UInt32( pData, fcFormFldSttbf );
+ Set_UInt32( pData, lcbFormFldSttbf );
+ Set_UInt32( pData, fcPlcfendRef );
+ Set_UInt32( pData, lcbPlcfendRef );
+ Set_UInt32( pData, fcPlcfendTxt );
+ Set_UInt32( pData, lcbPlcfendTxt );
+ Set_UInt32( pData, fcPlcffldEdn );
+ Set_UInt32( pData, lcbPlcffldEdn );
+ Set_UInt32( pData, fcPlcfpgdEdn );
+ Set_UInt32( pData, lcbPlcfpgdEdn );
+ Set_UInt32( pData, fcDggInfo ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbDggInfo ); // in Ver67 leere Reserve
+ Set_UInt32( pData, fcSttbfRMark );
+ Set_UInt32( pData, lcbSttbfRMark );
+ Set_UInt32( pData, fcSttbfCaption );
+ Set_UInt32( pData, lcbSttbfCaption );
+ Set_UInt32( pData, fcSttbAutoCaption );
+ Set_UInt32( pData, lcbSttbAutoCaption );
+ Set_UInt32( pData, fcPlcfwkb );
+ Set_UInt32( pData, lcbPlcfwkb );
+ Set_UInt32( pData, fcPlcfspl ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbPlcfspl ); // in Ver67 leere Reserve
+ Set_UInt32( pData, fcPlcftxbxTxt );
+ Set_UInt32( pData, lcbPlcftxbxTxt );
+ Set_UInt32( pData, fcPlcffldTxbx );
+ Set_UInt32( pData, lcbPlcffldTxbx );
+ Set_UInt32( pData, fcPlcfHdrtxbxTxt );
+ Set_UInt32( pData, lcbPlcfHdrtxbxTxt );
+ Set_UInt32( pData, fcPlcffldHdrTxbx );
+ Set_UInt32( pData, lcbPlcffldHdrTxbx );
+
+ if( bVer8 )
+ {
+ pData += 0x2e2 - 0x27a; // Pos + Offset (fcPlcfLst - fcStwUser)
+ Set_UInt32( pData, fcPlcfLst );
+ Set_UInt32( pData, lcbPlcfLst );
+ Set_UInt32( pData, fcPlfLfo );
+ Set_UInt32( pData, lcbPlfLfo );
+ Set_UInt32( pData, fcPlcftxbxBkd );
+ Set_UInt32( pData, lcbPlcftxbxBkd );
+ Set_UInt32( pData, fcPlcfHdrtxbxBkd );
+ Set_UInt32( pData, lcbPlcfHdrtxbxBkd );
+
+ pData += 0x372 - 0x302; // Pos + Offset (fcSttbListNames - fcDocUndo)
+ Set_UInt32( pData, fcSttbListNames );
+ Set_UInt32( pData, lcbSttbListNames );
+ }
+
+ rStrm.Write( pDataPtr, fcMin );
+ delete pDataPtr;
+ return 0 == rStrm.GetError();
+}
+
+//-----------------------------------------
+
+
+WW8Style::WW8Style( SvStream& rStream, WW8Fib& rFibPara ): rSt( rStream ), rFib( rFibPara )
+{
+ nStyleStart = rFib.fcStshf;
+ nStyleLen = rFib.lcbStshf;
+
+ rSt.Seek( nStyleStart );
+
+ USHORT cbStshi = 0; // 2 bytes size of the following STSHI structure
+
+ // alte Version ?
+ if ( rFib.nFib < 67 )
+ {
+ cbStshi = 4; // -> Laengenfeld fehlt
+ }
+ else // neue Version:
+ // lies die Laenge der in der Datei gespeicherten Struktur
+ rSt >> cbStshi;
+
+ UINT16 nRead = cbStshi;
+ do
+ {
+ UINT16 a16Bit;
+
+ if( 2 > nRead ) break;
+ rSt >> cstd;
+
+ if( 4 > nRead ) break;
+ rSt >> cbSTDBaseInFile;
+
+ if( 6 > nRead ) break;
+ rSt >> a16Bit;
+ fStdStylenamesWritten = a16Bit & 0x0001;
+
+ if( 8 > nRead ) break;
+ rSt >> stiMaxWhenSaved;
+
+ if( 10 > nRead ) break;
+ rSt >> istdMaxFixedWhenSaved;
+
+ if( 12 > nRead ) break;
+ rSt >> nVerBuiltInNamesWhenSaved;
+
+ if( 14 > nRead ) break;
+ rSt >> ftcStandardChpStsh;
+
+ // ggfs. den Rest ueberlesen
+ if( 14 < nRead )
+ rSt.SeekRel( nRead-14 );
+ }
+ while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
+ // und kann vorzeitig per "break" verlassen werden.
+
+ if( 0 != rSt.GetError() )
+ {
+ // wie denn nun den Error melden?
+ }
+}
+
+
+// Read1STDFixed() liest ein Style ein. Wenn der Style vollstaendig vorhanden
+// ist, d.h. kein leerer Slot, dann wird Speicher alloziert und ein Pointer auf
+// die ( evtl. mit Nullen aufgefuellten ) STD geliefert. Ist es ein leerer
+// Slot, dann wird ein Nullpointer zurueckgeliefert.
+WW8_STD* WW8Style::Read1STDFixed( short& rSkip, short* pcbStd )
+{
+ WW8_STD* pStd = (WW8_STD*)0;
+
+ UINT16 cbStd;
+ rSt >> cbStd; // lies Laenge
+
+ UINT16 nRead = cbSTDBaseInFile;
+ if( cbStd >= cbSTDBaseInFile ){ // Fixed part vollst. vorhanden
+
+ // read fixed part of STD
+ pStd = new WW8_STD;
+ memset( pStd, 0, sizeof( *pStd ) );
+
+ do
+ {
+ UINT16 a16Bit;
+
+ if( 2 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->sti = a16Bit & 0x0fff ;
+ pStd->fScratch = 0 != ( a16Bit & 0x1000 );
+ pStd->fInvalHeight = 0 != ( a16Bit & 0x2000 );
+ pStd->fHasUpe = 0 != ( a16Bit & 0x4000 );
+ pStd->fMassCopy = 0 != ( a16Bit & 0x8000 );
+
+ if( 4 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->sgc = a16Bit & 0x000f ;
+ pStd->istdBase = ( a16Bit & 0xfff0 ) >> 4;
+
+ if( 6 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->cupx = a16Bit & 0x000f ;
+ pStd->istdNext = ( a16Bit & 0xfff0 ) >> 4;
+
+ if( 8 > nRead ) break;
+ rSt >> pStd->bchUpe;
+
+ // ab Ver8 sollten diese beiden Felder dazukommen:
+ if(10 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->fAutoRedef = a16Bit & 0x0001 ;
+ pStd->fHidden = ( a16Bit & 0x0002 ) >> 2;
+
+ // man kann nie wissen: vorsichtshalber ueberlesen
+ // wir eventuelle Fuellsel, die noch zum BASE-Part gehoeren...
+ if( 10 < nRead )
+ rSt.SeekRel( nRead-10 );
+ }
+ while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
+ // und kann vorzeitig per "break" verlassen werden.
+
+ if( (0 != rSt.GetError())
+ || !nRead )
+ DELETEZ( pStd ); // per NULL den Error melden
+
+ rSkip = cbStd - cbSTDBaseInFile;
+ }
+ else
+ { // Fixed part zu kurz
+ if( cbStd )
+ rSt.SeekRel( cbStd ); // ueberlies Reste
+ rSkip = 0;
+ }
+ if( pcbStd )
+ *pcbStd = cbStd;
+ return pStd;
+}
+
+WW8_STD* WW8Style::Read1Style( short& rSkip, UINT8** ppStr, short* pcbStd )
+{
+ WW8_STD* pStd;
+
+ pStd = Read1STDFixed( rSkip, pcbStd ); // lese STD
+
+ // String gewuenscht ?
+ if( ppStr )
+ { // echter Style ?
+ if ( pStd )
+ {
+
+ switch( rFib.nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: // lies Pasacl-String
+ *ppStr = WW8ReadPString( rSt );
+ rSkip -= (*ppStr)[0]+2;
+ break;
+ case 8: // lies Unicode-String mit fuehrendem Laengenbyte
+ *ppStr = WW8Read_xstz( rSt );
+ rSkip -= 1+(((*ppStr)[0] + 1 )* 2);
+ break;
+ default:ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+
+ }
+ else
+ {
+ *ppStr = (UINT8*)0; // Kann keinen Namen liefern
+ }
+ }
+ return pStd;
+}
+
+
+//-----------------------------------------
+
+
+struct WW8_FFN_Ver6 : public WW8_FFN_BASE
+{
+ // ab Ver6
+ char szFfn[65]; // 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+ // records name of font.
+ // Maximal size of szFfn is 65 characters.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the
+ // name of an alternate font to use if the first named
+ // font does not exist on this system.
+};
+struct WW8_FFN_Ver8 : public WW8_FFN_BASE
+{
+ // ab Ver8 sind folgende beiden Felder eingeschoben,
+ // werden von uns ignoriert.
+ char panose[ 10 ]; // 0x6 PANOSE
+ char fs[ 24 ]; // 0x10 FONTSIGNATURE
+
+ // ab Ver8 als Unicode
+ UINT16 szFfn[65];// 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+ // records name of font.
+ // Maximal size of szFfn is 65 characters.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the
+ // name of an alternate font to use if the first named
+ // font does not exist on this system.
+};
+
+
+// JP 30.07.98: unter UNX ist sal_Unicode kein UNIT16, sondern ein long
+void lcl_UIn16ToWChar( UniString& rStr, UINT16* pSrc )
+{
+ UINT16* p = pSrc, nCnt = 0;
+ for( ; *p; ++nCnt, ++p )
+ ;
+// rStr.AllocStrBuf( nCnt + 1 );
+ rStr.AllocStrBuf( nCnt );
+ sal_Unicode* pChar = rStr.GetCharStr();
+ for( p = pSrc; nCnt; --nCnt, ++p, ++pChar )
+ *pChar = SVBT16ToShort( *(SVBT16*)p );
+
+// *pChar = 0;
+}
+
+WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
+{
+ if( rFib.lcbSttbfffn <= 2 )
+ {
+ ASSERT( ASS_FALSE, "Fonttabelle kaputt! (rFib.lcbSttbfffn < 2)" );
+ pFontA = 0;
+ nMax = 0;
+ return;
+ }
+
+ BOOL bVer67 = (8 > rFib.nVersion);
+
+ rSt.Seek( rFib.fcSttbfffn );
+
+ // allocate Font Array
+ char* pA = new char[ rFib.lcbSttbfffn - 2 ];
+ WW8_FFN* p = (WW8_FFN*)pA;
+
+ if( !bVer67 )
+ {
+ // bVer8: read the count of strings in nMax
+ rSt >> nMax;
+ }
+
+ // Ver8: skip undefined uint16
+ // Ver67: skip the herein stored total byte of structure
+ // - we already got that information in rFib.lcbSttbfffn
+ rSt.SeekRel( 2 );
+
+ // read all font information
+ rSt.Read( pA, rFib.lcbSttbfffn - 2 );
+
+ if( bVer67 )
+ {
+ // try to figure out how many fonts are defined here
+ nMax = 0;
+ long nLeft = rFib.lcbSttbfffn - 2;
+ for(;;)
+ {
+ short nNextSiz;
+
+ nNextSiz = p->cbFfnM1 + 1;
+ if( nNextSiz > nLeft )
+ break;
+ nMax++;
+ nLeft -= nNextSiz;
+ if( nLeft < 1 ) // can we read the given ammount of bytes ?
+ break;
+ // increase p by nNextSiz Bytes
+ p = (WW8_FFN *)( ( (char*)p ) + nNextSiz );
+ }
+ }
+
+ if( nMax )
+ {
+ // allocate Index Array
+ pFontA = new WW8_FFN[ nMax ];
+ p = pFontA;
+
+ if( bVer67 )
+ {
+ WW8_FFN_Ver6* pVer6 = (WW8_FFN_Ver6*)pA;
+ for(USHORT i=0; i<nMax; ++i, ++p)
+ {
+ p->cbFfnM1 = pVer6->cbFfnM1;
+ p->prg = pVer6->prg;
+ p->fTrueType = pVer6->fTrueType;
+ p->ff = pVer6->ff;
+ p->wWeight = SVBT16ToShort( *(SVBT16*)&pVer6->wWeight );
+ p->chs = pVer6->chs;
+ p->ibszAlt = pVer6->ibszAlt;
+ p->sFontname = pVer6->szFfn;
+ pVer6 = (WW8_FFN_Ver6*)( ( (char*)pVer6 ) + pVer6->cbFfnM1 + 1 );
+ }
+ }
+ else
+ {
+ WW8_FFN_Ver8* pVer8 = (WW8_FFN_Ver8*)pA;
+ char c2;
+ for(USHORT i=0; i<nMax; ++i, ++p)
+ {
+ p->cbFfnM1 = pVer8->cbFfnM1;
+ c2 = *(((char*)pVer8) + 1);
+
+ p->prg = c2 & 0x02;
+ p->fTrueType = (c2 & 0x04) >> 2;
+ // ein Reserve-Bit ueberspringen
+ p->ff = (c2 & 0x70) >> 4;
+
+ p->wWeight = SVBT16ToShort( *(SVBT16*)&pVer8->wWeight );
+ p->chs = pVer8->chs;
+ p->ibszAlt = pVer8->ibszAlt;
+
+ ::lcl_UIn16ToWChar( p->sFontname, pVer8->szFfn );
+
+ // Zeiger auf Ursprungsarray einen Font nach hinten setzen
+// (char*)pVer8 += pVer8->cbFfnM1 + 1;
+ pVer8 = (WW8_FFN_Ver8*)( ( (char*)pVer8 ) + pVer8->cbFfnM1 + 1 );
+ }
+ }
+ }
+ delete pA;
+}
+
+const WW8_FFN* WW8Fonts::GetFont( USHORT nNum ) const
+{
+ if( !pFontA || nNum > nMax )
+ return 0;
+
+ return &pFontA[ nNum ];
+}
+
+
+
+//-----------------------------------------
+
+
+// Suche zu einem Header / Footer den Index in der WW-Liste von Headern / Footern
+//
+// Pferdefuesse bei WinWord6 und -7:
+// 1) Am Anfang des Einlesens muss WWPLCF_HdFt mit Fib und Dop konstruiert werden
+// 2) Der Haupttext muss sequentiell ueber alle Sections gelesen werden
+// 3) Fuer jedes vorkommende Header / Footer - Attribut des Haupttextes
+// ( Darf pro Section maximal eins sein ) muss UpdateIndex() genau einmal
+// mit dem Parameter des Attributes gerufen werden. Dieser Aufruf muss *nach*
+// dem letzten Aufruf von GetTextPos() passieren.
+// 4) GetTextPos() darf mit genau einem der obenstehen WW_... aufgerufen werden
+// ( nicht verodern ! )
+// -> dann liefert GetTextPos() vielleicht auch ein richtiges Ergebnis
+
+WW8PLCF_HdFt::WW8PLCF_HdFt( SvStream* pSt, WW8Fib& rFib, WW8Dop& rDop )
+: aPLCF( pSt, rFib.fcPlcfhdd , rFib.lcbPlcfhdd , 0 )
+{
+ nIdxOffset = 0;
+
+// for( BYTE nI = 0x80; nI >= 0x20; nI >>= 1 ) // Beschreibung stimmt nicht
+
+ for( BYTE nI = 0x1; nI <= 0x4; nI <<= 1 ) // Vorsicht: Beschreibung stimmt nicht
+ if( nI & rDop.grpfIhdt ) // Bit gesetzt ?
+ nIdxOffset++;
+
+ nTextOfs = rFib.ccpText + rFib.ccpFtn; // Groesse des Haupttextes
+ // und der Fussnoten
+}
+
+BOOL WW8PLCF_HdFt::GetTextPos( BYTE grpfIhdt, BYTE nWhich, WW8_CP& rStart, long& rLen )
+{
+ BYTE nI = 0x1;
+ short nIdx = nIdxOffset;
+ while( TRUE ){
+ if( nI & nWhich )
+ break; // gefunden
+ if( grpfIhdt & nI )
+ nIdx++; // uninteressanter Header / Footer
+ nI <<= 1; // naechstes Bit testen
+ if( nI > 0x20 )
+ return FALSE; // nicht gefunden
+ }
+ // nIdx ist HdFt-Index
+ WW8_CP ende;
+ void* pData;
+
+ aPLCF.SetIdx( nIdx ); // dann suche passenden CP
+ aPLCF.Get( rStart, ende, pData );
+ rLen = ende - rStart;
+// Der letzte Header/Footer hat eine Laenge, die um 1 Zeichen zu gross ist
+// ( folgendes CR ). Um diesen passend zu kuerzen muesste man den Index
+// dieses K/F-Textes finden ( es ist nicht der letzte im PLCF ! ).
+// if( (long)aPLCF.GetIdx() == aPLCF.GetIMax() ) // Falsch!
+// rLen--; // Letztes Element ist 1 zu gross
+ aPLCF++;
+ return TRUE;
+}
+
+BOOL WW8PLCF_HdFt::GetTextPosExact( short nIdx, WW8_CP& rStart, long& rLen )
+{
+ WW8_CP ende;
+ void* pData;
+
+ aPLCF.SetIdx( nIdx ); // dann suche passenden CP
+ aPLCF.Get( rStart, ende, pData );
+ rLen = ende - rStart;
+// Der letzte Header/Footer hat eine Laenge, die um 1 Zeichen zu gross ist
+// ( folgendes CR ). Um diesen passend zu kuerzen muesste man den Index
+// dieses K/F-Textes finden ( es ist nicht der letzte im PLCF ! ).
+// if( (long)aPLCF.GetIdx() == aPLCF.GetIMax() ) // Falsch!
+// rLen--; // Letztes Element ist 1 zu gross
+ return TRUE;
+}
+
+void WW8PLCF_HdFt::UpdateIndex( BYTE grpfIhdt )
+{
+ for( BYTE nI = 0x1; nI <= 0x20; nI <<= 1 ) // Vorsicht: Beschreibung stimmt nicht
+ if( nI & grpfIhdt )
+ nIdxOffset++;
+}
+
+//-----------------------------------------
+// WW8Dop
+//-----------------------------------------
+
+
+
+WW8Dop::WW8Dop( SvStream& rSt, INT16 nFib, INT32 nPos, INT32 nSize )
+{
+ BYTE* pData = new BYTE[ 500 ];
+ BYTE* pDataPtr = pData;
+ UINT32 nRead = 500 < nSize ? 500 : nSize;
+ rSt.Seek( nPos );
+ if( 2 > nSize || nRead != rSt.Read( pData, nRead ))
+ {
+ memset( &nDataStart, 0, (&nDataEnd - &nDataStart) );
+ nDopError = ERR_SWG_READ_ERROR; // Error melden
+ }
+ else
+ {
+ if( 500 > nRead )
+ memset( pData + nRead, 0, 500 - nRead );
+
+ // dann mal die Daten auswerten
+ UINT32 a32Bit;
+ UINT16 a16Bit;
+ BYTE a8Bit;
+
+ a16Bit = Get_UShort( pData );
+ fFacingPages = 0 != ( a16Bit & 0x0001 ) ;
+ fWidowControl = 0 != ( a16Bit & 0x0002 ) ;
+ fPMHMainDoc = 0 != ( a16Bit & 0x0004 ) ;
+ grfSuppression = ( a16Bit & 0x0018 ) >> 3;
+ fpc = ( a16Bit & 0x0060 ) >> 5;
+ grpfIhdt = ( a16Bit & 0xff00 ) >> 8;
+
+ a16Bit = Get_UShort( pData );
+ rncFtn = a16Bit & 0x0003 ;
+ nFtn = ( a16Bit & ~0x0003 ) >> 2 ;
+
+ a8Bit = Get_Byte( pData );
+ fOutlineDirtySave = 0 != ( a8Bit & 0x01 );
+
+ a8Bit = Get_Byte( pData );
+ fOnlyMacPics = 0 != ( a8Bit & 0x01 );
+ fOnlyWinPics = 0 != ( a8Bit & 0x02 );
+ fLabelDoc = 0 != ( a8Bit & 0x04 );
+ fHyphCapitals = 0 != ( a8Bit & 0x08 );
+ fAutoHyphen = 0 != ( a8Bit & 0x10 );
+ fFormNoFields = 0 != ( a8Bit & 0x20 );
+ fLinkStyles = 0 != ( a8Bit & 0x40 );
+ fRevMarking = 0 != ( a8Bit & 0x80 );
+
+ a8Bit = Get_Byte( pData );
+ fBackup = 0 != ( a8Bit & 0x01 );
+ fExactCWords = 0 != ( a8Bit & 0x02 );
+ fPagHidden = 0 != ( a8Bit & 0x04 );
+ fPagResults = 0 != ( a8Bit & 0x08 );
+ fLockAtn = 0 != ( a8Bit & 0x10 );
+ fMirrorMargins = 0 != ( a8Bit & 0x20 );
+ fReadOnlyRecommended = 0 != ( a8Bit & 0x40 );
+ fDfltTrueType = 0 != ( a8Bit & 0x80 );
+
+ a8Bit = Get_Byte( pData );
+ fPagSuppressTopSpacing = 0 != ( a8Bit & 0x01 );
+ fProtEnabled = 0 != ( a8Bit & 0x02 );
+ fDispFormFldSel = 0 != ( a8Bit & 0x04 );
+ fRMView = 0 != ( a8Bit & 0x08 );
+ fRMPrint = 0 != ( a8Bit & 0x10 );
+ fWriteReservation = 0 != ( a8Bit & 0x20 );
+ fLockRev = 0 != ( a8Bit & 0x40 );
+ fEmbedFonts = 0 != ( a8Bit & 0x80 );
+
+
+ a8Bit = Get_Byte( pData );
+ copts_fNoTabForInd = 0 != ( a8Bit & 0x01 );
+ copts_fNoSpaceRaiseLower = 0 != ( a8Bit & 0x02 );
+ copts_fSupressSpbfAfterPgBrk = 0 != ( a8Bit & 0x04 );
+ copts_fWrapTrailSpaces = 0 != ( a8Bit & 0x08 );
+ copts_fMapPrintTextColor = 0 != ( a8Bit & 0x10 );
+ copts_fNoColumnBalance = 0 != ( a8Bit & 0x20 );
+ copts_fConvMailMergeEsc = 0 != ( a8Bit & 0x40 );
+ copts_fSupressTopSpacing = 0 != ( a8Bit & 0x80 );
+
+ a8Bit = Get_Byte( pData );
+ copts_fOrigWordTableRules = 0 != ( a8Bit & 0x01 );
+ copts_fTransparentMetafiles = 0 != ( a8Bit & 0x02 );
+ copts_fShowBreaksInFrames = 0 != ( a8Bit & 0x04 );
+ copts_fSwapBordersFacingPgs = 0 != ( a8Bit & 0x08 );
+
+ dxaTab = Get_Short( pData );
+ wSpare = Get_UShort( pData );
+ dxaHotZ = Get_UShort( pData );
+ cConsecHypLim = Get_UShort( pData );
+ wSpare2 = Get_UShort( pData );
+ dttmCreated = Get_Long( pData );
+ dttmRevised = Get_Long( pData );
+ dttmLastPrint = Get_Long( pData );
+ nRevision = Get_Short( pData );
+ tmEdited = Get_Long( pData );
+ cWords = Get_Long( pData );
+ cCh = Get_Long( pData );
+ cPg = Get_Short( pData );
+ cParas = Get_Long( pData );
+
+ a16Bit = Get_UShort( pData );
+ rncEdn = a16Bit & 0x0003 ;
+ nEdn = ( a16Bit & ~0x0003 ) >> 2;
+
+ a16Bit = Get_UShort( pData );
+ epc = a16Bit & 0x0003 ;
+ nfcFtnRef = ( a16Bit & 0x003c ) >> 2;
+ nfcEdnRef = ( a16Bit & 0x03c0 ) >> 6;
+ fPrintFormData = 0 != ( a16Bit & 0x0400 );
+ fSaveFormData = 0 != ( a16Bit & 0x0800 );
+ fShadeFormData = 0 != ( a16Bit & 0x1000 );
+ fWCFtnEdn = 0 != ( a16Bit & 0x8000 );
+
+ cLines = Get_Long( pData );
+ cWordsFtnEnd = Get_Long( pData );
+ cChFtnEdn = Get_Long( pData );
+ cPgFtnEdn = Get_Short( pData );
+ cParasFtnEdn = Get_Long( pData );
+ cLinesFtnEdn = Get_Long( pData );
+ lKeyProtDoc = Get_Long( pData );
+
+ a16Bit = Get_UShort( pData );
+ wvkSaved = a16Bit & 0x0007 ;
+ wScaleSaved = ( a16Bit & 0x0ff8 ) >> 3 ;
+ zkSaved = ( a16Bit & 0x3000 ) >> 12;
+
+ /*
+ bei nFib >= 103 gehts weiter:
+ */
+ if( nFib >= 103 )
+ {
+ a32Bit = Get_ULong( pData );
+ fNoTabForInd = ( a32Bit & 0x00000001 ) ;
+ fNoSpaceRaiseLower = ( a32Bit & 0x00000002 ) >> 1 ;
+ fSupressSpbfAfterPageBreak = ( a32Bit & 0x00000004 ) >> 2 ;
+ fWrapTrailSpaces = ( a32Bit & 0x00000008 ) >> 3 ;
+ fMapPrintTextColor = ( a32Bit & 0x00000010 ) >> 4 ;
+ fNoColumnBalance = ( a32Bit & 0x00000020 ) >> 5 ;
+ fConvMailMergeEsc = ( a32Bit & 0x00000040 ) >> 6 ;
+ fSupressTopSpacing = ( a32Bit & 0x00000080 ) >> 7 ;
+ fOrigWordTableRules = ( a32Bit & 0x00000100 ) >> 8 ;
+ fTransparentMetafiles = ( a32Bit & 0x00000200 ) >> 9 ;
+ fShowBreaksInFrames = ( a32Bit & 0x00000400 ) >> 10 ;
+ fSwapBordersFacingPgs = ( a32Bit & 0x00000800 ) >> 11 ;
+ fSuppressTopSpacingMac5 = ( a32Bit & 0x00010000 ) >> 16 ;
+ fTruncDxaExpand = ( a32Bit & 0x00020000 ) >> 17 ;
+ fPrintBodyBeforeHdr = ( a32Bit & 0x00040000 ) >> 18 ;
+ fNoLeading = ( a32Bit & 0x00080000 ) >> 19 ;
+ fMWSmallCaps = ( a32Bit & 0x00200000 ) >> 21 ;
+ }
+
+ /*
+ bei nFib > 105 gehts weiter:
+ */
+ if( nFib > 105 )
+ {
+ adt = Get_Short( pData );
+
+ memcpy( &doptypography, pData, sizeof( WW8_DOPTYPOGRAPHY ));
+ pData += sizeof( WW8_DOPTYPOGRAPHY );
+
+ memcpy( &dogrid, pData, sizeof( WW8_DOGRID ));
+ pData += sizeof( WW8_DOGRID );
+
+ a16Bit = Get_UShort( pData );
+ // die untersten 9 Bit sind uninteressant
+ fHtmlDoc = ( a16Bit & 0x0200 ) >> 9 ;
+ fSnapBorder = ( a16Bit & 0x0800 ) >> 11 ;
+ fIncludeHeader = ( a16Bit & 0x1000 ) >> 12 ;
+ fIncludeFooter = ( a16Bit & 0x2000 ) >> 13 ;
+ fForcePageSizePag = ( a16Bit & 0x4000 ) >> 14 ;
+ fMinFontSizePag = ( a16Bit & 0x8000 ) >> 15 ;
+
+ a16Bit = Get_UShort( pData );
+ fHaveVersions = 0 != ( a16Bit & 0x0001 );
+ fAutoVersion = 0 != ( a16Bit & 0x0002 );
+
+ pData += 12;
+
+ cChWS = Get_Long( pData );
+ cChWSFtnEdn = Get_Long( pData );
+ grfDocEvents = Get_Long( pData );
+
+ pData += 4+30+8;
+
+ cDBC = Get_Long( pData );
+ cDBCFtnEdn = Get_Long( pData );
+
+ pData += 1 * sizeof( long );
+
+ nfcFtnRef = Get_Short( pData );
+ nfcEdnRef = Get_Short( pData );
+ hpsZoonFontPag = Get_Short( pData );
+ dywDispPag = Get_Short( pData );
+ }
+ }
+ delete pDataPtr;
+}
+
+WW8Dop::WW8Dop()
+{
+ // erstmal alles auf 0 defaulten
+ memset( &nDataStart, 0, (&nDataEnd - &nDataStart) );
+
+ fWidowControl = 1;
+ fpc = 1;
+ nFtn = 1;
+ fOutlineDirtySave = 1;
+ fHyphCapitals = 1;
+ fBackup = 1;
+ fPagHidden = 1;
+ fPagResults = 1;
+ fDfltTrueType = 1;
+ fRMView = 1;
+ fRMPrint = 1;
+ dxaTab = 0x2d0;
+ dxaHotZ = 0x168;
+ dttmCreated = 0x45FBAC69;
+ dttmRevised = 0x45FBAC69;
+ nRevision = 1;
+ nEdn = 1;
+
+ epc = 3;
+ nfcEdnRef = 2;
+ fShadeFormData = 1;
+
+ wvkSaved = 2;
+ wScaleSaved = 100;
+ zkSaved = 0;
+
+ lvl = 9;
+ fIncludeHeader = 1;
+ fIncludeFooter = 1;
+
+ cChWS = /**!!**/ 0;
+ cChWSFtnEdn = /**!!**/ 0;
+
+ cDBC = /**!!**/ 0;
+ cDBCFtnEdn = /**!!**/ 0;
+}
+
+BOOL WW8Dop::Write( SvStream& rStrm, WW8Fib& rFib )
+{
+ INT32 nLen = 8 == rFib.nVersion ? 500 : 84;
+ rFib.fcDop = rStrm.Tell();
+ rFib.lcbDop = nLen;
+
+ BYTE aData[ 500 ];
+ memset( aData, 0, 500 );
+ BYTE* pData = aData;
+
+ // dann mal die Daten auswerten
+ UINT32 a32Bit;
+ UINT16 a16Bit;
+ BYTE a8Bit;
+
+ a16Bit = 0;
+ if( fFacingPages ) a16Bit |= 0x0001;
+ if( fWidowControl ) a16Bit |= 0x0002;
+ if( fPMHMainDoc ) a16Bit |= 0x0004;
+ a16Bit |= ( 0x0018 & (grfSuppression << 3));
+ a16Bit |= ( 0x0060 & (fpc << 5));
+ a16Bit |= ( 0xff00 & (grpfIhdt << 8));
+ Set_UInt16( pData, a16Bit );
+
+ a16Bit = 0;
+ a16Bit |= ( 0x0003 & rncFtn );
+ a16Bit |= ( ~0x0003 & (nFtn << 2));
+ Set_UInt16( pData, a16Bit );
+
+ a8Bit = 0;
+ if( fOutlineDirtySave ) a8Bit |= 0x01;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( fOnlyMacPics ) a8Bit |= 0x01;
+ if( fOnlyWinPics ) a8Bit |= 0x02;
+ if( fLabelDoc ) a8Bit |= 0x04;
+ if( fHyphCapitals ) a8Bit |= 0x08;
+ if( fAutoHyphen ) a8Bit |= 0x10;
+ if( fFormNoFields ) a8Bit |= 0x20;
+ if( fLinkStyles ) a8Bit |= 0x40;
+ if( fRevMarking ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( fBackup ) a8Bit |= 0x01;
+ if( fExactCWords ) a8Bit |= 0x02;
+ if( fPagHidden ) a8Bit |= 0x04;
+ if( fPagResults ) a8Bit |= 0x08;
+ if( fLockAtn ) a8Bit |= 0x10;
+ if( fMirrorMargins ) a8Bit |= 0x20;
+ if( fReadOnlyRecommended ) a8Bit |= 0x40;
+ if( fDfltTrueType ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( fPagSuppressTopSpacing ) a8Bit |= 0x01;
+ if( fProtEnabled ) a8Bit |= 0x02;
+ if( fDispFormFldSel ) a8Bit |= 0x04;
+ if( fRMView ) a8Bit |= 0x08;
+ if( fRMPrint ) a8Bit |= 0x10;
+ if( fWriteReservation ) a8Bit |= 0x20;
+ if( fLockRev ) a8Bit |= 0x40;
+ if( fEmbedFonts ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+
+ a8Bit = 0;
+ if( copts_fNoTabForInd ) a8Bit |= 0x01;
+ if( copts_fNoSpaceRaiseLower ) a8Bit |= 0x02;
+ if( copts_fSupressSpbfAfterPgBrk ) a8Bit |= 0x04;
+ if( copts_fWrapTrailSpaces ) a8Bit |= 0x08;
+ if( copts_fMapPrintTextColor ) a8Bit |= 0x10;
+ if( copts_fNoColumnBalance ) a8Bit |= 0x20;
+ if( copts_fConvMailMergeEsc ) a8Bit |= 0x40;
+ if( copts_fSupressTopSpacing ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( copts_fOrigWordTableRules ) a8Bit |= 0x01;
+ if( copts_fTransparentMetafiles ) a8Bit |= 0x02;
+ if( copts_fShowBreaksInFrames ) a8Bit |= 0x04;
+ if( copts_fSwapBordersFacingPgs ) a8Bit |= 0x08;
+ Set_UInt8( pData, a8Bit );
+
+ Set_UInt16( pData, dxaTab );
+ Set_UInt16( pData, wSpare );
+ Set_UInt16( pData, dxaHotZ );
+ Set_UInt16( pData, cConsecHypLim );
+ Set_UInt16( pData, wSpare2 );
+ Set_UInt32( pData, dttmCreated );
+ Set_UInt32( pData, dttmRevised );
+ Set_UInt32( pData, dttmLastPrint );
+ Set_UInt16( pData, nRevision );
+ Set_UInt32( pData, tmEdited );
+ Set_UInt32( pData, cWords );
+ Set_UInt32( pData, cCh );
+ Set_UInt16( pData, cPg );
+ Set_UInt32( pData, cParas );
+
+ a16Bit = 0;
+ a16Bit |= ( 0x0003 & rncEdn );
+ a16Bit |= (~0x0003 & ( nEdn << 2));
+ Set_UInt16( pData, a16Bit );
+
+ a16Bit = 0;
+ a16Bit |= (0x0003 & epc );
+ a16Bit |= (0x003c & (nfcFtnRef << 2));
+ a16Bit |= (0x03c0 & (nfcEdnRef << 6));
+ if( fPrintFormData ) a16Bit |= 0x0400;
+ if( fSaveFormData ) a16Bit |= 0x0800;
+ if( fShadeFormData ) a16Bit |= 0x1000;
+ if( fWCFtnEdn ) a16Bit |= 0x8000;
+ Set_UInt16( pData, a16Bit );
+
+ Set_UInt32( pData, cLines );
+ Set_UInt32( pData, cWordsFtnEnd );
+ Set_UInt32( pData, cChFtnEdn );
+ Set_UInt16( pData, cPgFtnEdn );
+ Set_UInt32( pData, cParasFtnEdn );
+ Set_UInt32( pData, cLinesFtnEdn );
+ Set_UInt32( pData, lKeyProtDoc );
+
+ a16Bit = 0;
+ if( wvkSaved ) a16Bit |= 0x0007;
+ a16Bit |= (0x0ff8 & (wScaleSaved << 3));
+ a16Bit |= (0x3000 & (zkSaved << 12));
+ Set_UInt16( pData, a16Bit );
+
+ if( 8 == rFib.nVersion )
+ {
+ a32Bit = 0;
+ if( fNoTabForInd ) a32Bit |= 0x00000001;
+ if( fNoSpaceRaiseLower ) a32Bit |= 0x00000002;
+ if( fSupressSpbfAfterPageBreak ) a32Bit |= 0x00000004;
+ if( fWrapTrailSpaces ) a32Bit |= 0x00000008;
+ if( fMapPrintTextColor ) a32Bit |= 0x00000010;
+ if( fNoColumnBalance ) a32Bit |= 0x00000020;
+ if( fConvMailMergeEsc ) a32Bit |= 0x00000040;
+ if( fSupressTopSpacing ) a32Bit |= 0x00000080;
+ if( fOrigWordTableRules ) a32Bit |= 0x00000100;
+ if( fTransparentMetafiles ) a32Bit |= 0x00000200;
+ if( fShowBreaksInFrames ) a32Bit |= 0x00000400;
+ if( fSwapBordersFacingPgs ) a32Bit |= 0x00000800;
+ if( fSuppressTopSpacingMac5 ) a32Bit |= 0x00010000;
+ if( fTruncDxaExpand ) a32Bit |= 0x00020000;
+ if( fPrintBodyBeforeHdr ) a32Bit |= 0x00040000;
+ if( fNoLeading ) a32Bit |= 0x00080000;
+ if( fMWSmallCaps ) a32Bit |= 0x00200000;
+ Set_UInt32( pData, a32Bit );
+
+ Set_UInt16( pData, adt );
+
+ memcpy( pData, &doptypography, sizeof( WW8_DOPTYPOGRAPHY ));
+ pData += sizeof( WW8_DOPTYPOGRAPHY );
+
+ memcpy( pData, &dogrid, sizeof( WW8_DOGRID ));
+ pData += sizeof( WW8_DOGRID );
+
+ a16Bit = 0x12; // lvl auf 9 setzen
+ if( fHtmlDoc ) a16Bit |= 0x0200;
+ if( fSnapBorder ) a16Bit |= 0x0800;
+ if( fIncludeHeader ) a16Bit |= 0x1000;
+ if( fIncludeFooter ) a16Bit |= 0x2000;
+ if( fForcePageSizePag ) a16Bit |= 0x4000;
+ if( fMinFontSizePag ) a16Bit |= 0x8000;
+ Set_UInt16( pData, a16Bit );
+
+ a16Bit = 0;
+ if( fHaveVersions ) a16Bit |= 0x0001;
+ if( fAutoVersion ) a16Bit |= 0x0002;
+ Set_UInt16( pData, a16Bit );
+
+ pData += 12;
+
+ Set_UInt32( pData, cChWS );
+ Set_UInt32( pData, cChWSFtnEdn );
+ Set_UInt32( pData, grfDocEvents );
+
+ pData += 4+30+8;
+
+ Set_UInt32( pData, cDBC );
+ Set_UInt32( pData, cDBCFtnEdn );
+
+ pData += 1 * sizeof( long );
+
+ Set_UInt16( pData, nfcFtnRef );
+ Set_UInt16( pData, nfcEdnRef );
+ Set_UInt16( pData, hpsZoonFontPag );
+ Set_UInt16( pData, dywDispPag );
+ }
+ rStrm.Write( aData, nLen );
+ return 0 == rStrm.GetError();
+}
+
+/***************************************************************************
+# Array zum Bestimmen der Laenge der SPRMs
+#**************************************************************************/
+
+
+/*
+ Werte fuer SprmInfo.nVari
+*/
+#define L_FIX 0
+#define L_VAR 1
+#define L_VAR2 2
+
+struct SprmInfo
+{
+ USHORT nId;
+ BYTE nLen : 6;
+ BYTE nVari: 2;
+};
+
+
+/*
+ Zweck: Laenge und Parameter-Offset eines Sprm erfahren
+*/
+static SprmInfo aWwSprmTab[] = {
+ 0, 0, L_FIX, // "Default-sprm", // wird uebersprungen
+ 2, 2, L_FIX, // "sprmPIstd", // pap.istd (style code)
+ 3, 3, L_VAR, // "sprmPIstdPermute", // pap.istd permutation
+ 4, 1, L_FIX, // "sprmPIncLv1", // pap.istddifference
+ 5, 1, L_FIX, // "sprmPJc", // pap.jc (justification)
+ 6, 1, L_FIX, // "sprmPFSideBySide", // pap.fSideBySide
+ 7, 1, L_FIX, // "sprmPFKeep", // pap.fKeep
+ 8, 1, L_FIX, // "sprmPFKeepFollow ", // pap.fKeepFollow
+ 9, 1, L_FIX, // "sprmPPageBreakBefore", // pap.fPageBreakBefore
+
+ 10, 1, L_FIX, // "sprmPBrcl", // pap.brcl
+ 11, 1, L_FIX, // "sprmPBrcp ", // pap.brcp
+ 12, 0, L_VAR, // "sprmPAnld", // pap.anld (ANLD structure)
+ 13, 1, L_FIX, // "sprmPNLvlAnm", // pap.nLvlAnm nn
+ 14, 1, L_FIX, // "sprmPFNoLineNumb", //ap.fNoLnn
+
+
+ // ???
+ 15, 0, L_VAR, // "?sprmPChgTabsPapx", // pap.itbdMac, ...
+
+
+ 16, 2, L_FIX, // "sprmPDxaRight", // pap.dxaRight
+ 17, 2, L_FIX, // "sprmPDxaLeft", // pap.dxaLeft
+ 18, 2, L_FIX, // "sprmPNest", // pap.dxaLeft
+ 19, 2, L_FIX, // "sprmPDxaLeft1", // pap.dxaLeft1
+
+ 20, 4, L_FIX, // "sprmPDyaLine", // pap.lspd an LSPD
+ 21, 2, L_FIX, // "sprmPDyaBefore", // pap.dyaBefore
+ 22, 2, L_FIX, // "sprmPDyaAfter", // pap.dyaAfter
+
+
+ // ???
+ 23, 0, L_VAR, // "?sprmPChgTabs", // pap.itbdMac, pap.rgdxaTab, ...
+
+
+ 24, 1, L_FIX, // "sprmPFInTable", // pap.fInTable
+ 25, 1, L_FIX, // "sprmPTtp", // pap.fTtp
+ 26, 2, L_FIX, // "sprmPDxaAbs", // pap.dxaAbs
+ 27, 2, L_FIX, // "sprmPDyaAbs", // pap.dyaAbs
+ 28, 2, L_FIX, // "sprmPDxaWidth", // pap.dxaWidth
+ 29, 1, L_FIX, // "sprmPPc", // pap.pcHorz, pap.pcVert
+
+ 30, 2, L_FIX, // "sprmPBrcTop10", // pap.brcTop BRC10
+ 31, 2, L_FIX, // "sprmPBrcLeft10", // pap.brcLeft BRC10
+ 32, 2, L_FIX, // "sprmPBrcBottom10", // pap.brcBottom BRC10
+ 33, 2, L_FIX, // "sprmPBrcRight10", // pap.brcRight BRC10
+ 34, 2, L_FIX, // "sprmPBrcBetween10", // pap.brcBetween BRC10
+ 35, 2, L_FIX, // "sprmPBrcBar10", // pap.brcBar BRC10
+ 36, 2, L_FIX, // "sprmPFromText10", // pap.dxaFromText dxa
+ 37, 1, L_FIX, // "sprmPWr", // pap.wr wr
+ 38, 2, L_FIX, // "sprmPBrcTop", // pap.brcTop BRC
+ 39, 2, L_FIX, // "sprmPBrcLeft", // pap.brcLeft BRC
+
+ 40, 2, L_FIX, // "sprmPBrcBottom", // pap.brcBottom BRC
+ 41, 2, L_FIX, // "sprmPBrcRight", // pap.brcRight BRC
+ 42, 2, L_FIX, // "sprmPBrcBetween", // pap.brcBetween BRC
+ 43, 2, L_FIX, // "sprmPBrcBar",//pap.brcBar BRC word
+ 44, 1, L_FIX, // "sprmPFNoAutoHyph",//pap.fNoAutoHyph
+ 45, 2, L_FIX, // "sprmPWHeightAbs",//pap.wHeightAbs w
+ 46, 2, L_FIX, // "sprmPDcs",//pap.dcs DCS
+ 47, 2, L_FIX, // "sprmPShd",//pap.shd SHD
+ 48, 2, L_FIX, // "sprmPDyaFromText",//pap.dyaFromText dya
+ 49, 2, L_FIX, // "sprmPDxaFromText",//pap.dxaFromText dxa
+
+ 50, 1, L_FIX, // "sprmPFLocked", // pap.fLocked 0 or 1 byte
+
+ 51, 1, L_FIX, // "sprmPFWidowControl", // pap.fWidowControl 0 or 1 byte
+
+
+ // ???
+ 52, 0, L_FIX, // "?sprmPRuler 52", //???
+
+
+ 65, 1, L_FIX, // "sprmCFStrikeRM", // chp.fRMarkDel 1 or 0 bit
+ 66, 1, L_FIX, // "sprmCFRMark", // chp.fRMark 1 or 0 bit
+ 67, 1, L_FIX, // "sprmCFFldVanish", // chp.fFldVanish 1 or 0 bit
+ 68, 0, L_VAR, // "sprmCPicLocation", // chp.fcPic and chp.fSpec
+ 69, 2, L_FIX, // "sprmCIbstRMark", // chp.ibstRMark index into sttbRMark
+
+ 70, 4, L_FIX, // "sprmCDttmRMark", // chp.dttm DTTM long
+ 71, 1, L_FIX, // "sprmCFData", // chp.fData 1 or 0 bit
+ 72, 2, L_FIX, // "sprmCRMReason", // chp.idslRMReason an index to a table
+ 73, 3, L_FIX, // "sprmCChse", // chp.fChsDiff and chp.chse see below 3 bytes
+ 74, 0, L_VAR, // "sprmCSymbol", // chp.fSpec, chp.chSym and chp.ftcSym
+ 75, 1, L_FIX, // "sprmCFOle2", // chp.fOle2 1 or 0 bit
+
+ 80, 2, L_FIX, // "sprmCIstd", // chp.istd istd, see stylesheet definition short
+ 81, 0, L_VAR, // "sprmCIstdPermute", // chp.istd permutation vector (see below)
+ 82, 0, L_VAR, // "sprmCDefault", // whole CHP (see below) none variable length
+ 83, 0, L_FIX, // "sprmCPlain", // whole CHP (see below) none 0
+ 85, 1, L_FIX, // "sprmCFBold", // chp.fBold 0,1, 128, or 129 (see below) byte
+ 86, 1, L_FIX, //"sprmCFItalic", // chp.fItalic 0,1, 128, or 129 (see below) byte
+ 87, 1, L_FIX, // "sprmCFStrike", // chp.fStrike 0,1, 128, or 129 (see below) byte
+ 88, 1, L_FIX, // "sprmCFOutline", // chp.fOutline 0,1, 128, or 129 (see below) byte
+ 89, 1, L_FIX, // "sprmCFShadow", // chp.fShadow 0,1, 128, or 129 (see below) byte
+
+ 90, 1, L_FIX, // "sprmCFSmallCaps", // chp.fSmallCaps 0,1, 128, or 129 (see below) byte
+ 91, 1, L_FIX, // "sprmCFCaps", // chp.fCaps 0,1, 128, or 129 (see below) byte
+ 92, 1, L_FIX, // "sprmCFVanish", // chp.fVanish 0,1, 128, or 129 (see below) byte
+ 93, 2, L_FIX, // "sprmCFtc", // chp.ftc ftc word
+ 94, 1, L_FIX, // "sprmCKul", // chp.kul kul byte
+ 95, 3, L_FIX, // "sprmCSizePos", // chp.hps, chp.hpsPos (see below) 3 bytes
+ 96, 2, L_FIX, // "sprmCDxaSpace", // chp.dxaSpace dxa word
+ 97, 2, L_FIX, // "sprmCLid", // chp.lid LID word
+ 98, 1, L_FIX, // "sprmCIco", // chp.ico ico byte
+ 99, 2, L_FIX, // "sprmCHps", // chp.hps hps !word!
+
+
+ 100, 1, L_FIX, // "sprmCHpsInc", // chp.hps (see below) byte
+ 101, 2, L_FIX, // "sprmCHpsPos", // chp.hpsPos hps !word!
+ 102, 1, L_FIX, // "sprmCHpsPosAdj", // chp.hpsPos hps (see below) byte
+
+
+ // ???
+ 103, 0, L_VAR, // "?sprmCMajority", // chp.fBold, chp.fItalic, chp.fSmallCaps, ...
+
+
+ 104, 1, L_FIX, // "sprmCIss", // chp.iss iss byte
+ 105, 0, L_VAR, // "sprmCHpsNew50", // chp.hps hps variable width, length always recorded as 2
+ 106, 0, L_VAR, // "sprmCHpsInc1", // chp.hps complex (see below) variable width, length always recorded as 2
+ 107, 2, L_FIX, // "sprmCHpsKern", // chp.hpsKern hps short
+ 108, 0, L_VAR, // "sprmCMajority50", // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, ...
+ 109, 2, L_FIX, // "sprmCHpsMul", // chp.hps percentage to grow hps short
+
+ 110, 2, L_FIX, // "sprmCCondHyhen", // chp.ysri ysri short
+ 117, 1, L_FIX, // "sprmCFSpec", // chp.fSpec 1 or 0 bit
+ 118, 1, L_FIX, // "sprmCFObj", // chp.fObj 1 or 0 bit
+ 119, 1, L_FIX, // "sprmPicBrcl", // pic.brcl brcl (see PIC structure definition) byte
+
+ 120,12, L_VAR, // "sprmPicScale", // pic.mx, pic.my, pic.dxaCropleft,
+ 121, 2, L_FIX, // "sprmPicBrcTop", // pic.brcTop BRC word
+ 122, 2, L_FIX, // "sprmPicBrcLeft", // pic.brcLeft BRC word
+ 123, 2, L_FIX, // "sprmPicBrcBottom", // pic.brcBottom BRC word
+ 124, 2, L_FIX, // "sprmPicBrcRight", // pic.brcRight BRC word
+
+ 131, 1, L_FIX, // "sprmSScnsPgn", // sep.cnsPgn cns byte
+ 132, 1, L_FIX, // "sprmSiHeadingPgn", // sep.iHeadingPgn heading number level byte
+ 133, 0, L_VAR, // "sprmSOlstAnm", // sep.olstAnm OLST variable length
+ 136, 3, L_FIX, // "sprmSDxaColWidth", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 137, 3, L_FIX, // "sprmSDxaColSpacing", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 138, 1, L_FIX, // "sprmSFEvenlySpaced", // sep.fEvenlySpaced 1 or 0 byte
+ 139, 1, L_FIX, // "sprmSFProtected", // sep.fUnlocked 1 or 0 byte
+
+ 140, 2, L_FIX, // "sprmSDmBinFirst", // sep.dmBinFirst word
+ 141, 2, L_FIX, // "sprmSDmBinOther", // sep.dmBinOther word
+ 142, 1, L_FIX, // "sprmSBkc", // sep.bkc bkc byte
+ 143, 1, L_FIX, // "sprmSFTitlePage", // sep.fTitlePage 0 or 1 byte
+ 144, 2, L_FIX, // "sprmSCcolumns", // sep.ccolM1 # of cols - 1 word
+ 145, 2, L_FIX, // "sprmSDxaColumns", // sep.dxaColumns dxa word
+ 146, 1, L_FIX, // "sprmSFAutoPgn", // sep.fAutoPgn obsolete byte
+ 147, 1, L_FIX, // "sprmSNfcPgn", // sep.nfcPgn nfc byte
+ 148, 2, L_FIX, // "sprmSDyaPgn", // sep.dyaPgn dya short
+ 149, 2, L_FIX, // "sprmSDxaPgn", // sep.dxaPgn dya short
+
+
+ 150, 1, L_FIX, // "sprmSFPgnRestart", // sep.fPgnRestart 0 or 1 byte
+ 151, 1, L_FIX, // "sprmSFEndnote", // sep.fEndnote 0 or 1 byte
+ 152, 1, L_FIX, // "sprmSLnc", // sep.lnc lnc byte
+ 153, 1, L_FIX, // "sprmSGprfIhdt", // sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
+ 154, 2, L_FIX, // "sprmSNLnnMod", // sep.nLnnMod non-neg int. word
+ 155, 2, L_FIX, // "sprmSDxaLnn", // sep.dxaLnn dxa word
+ 156, 2, L_FIX, // "sprmSDyaHdrTop", // sep.dyaHdrTop dya word
+ 157, 2, L_FIX, // "sprmSDyaHdrBottom", // sep.dyaHdrBottom dya word
+ 158, 1, L_FIX, // "sprmSLBetween", // sep.fLBetween 0 or 1 byte
+ 159, 1, L_FIX, // "sprmSVjc", // sep.vjc vjc byte
+
+ 160, 2, L_FIX, // "sprmSLnnMin", // sep.lnnMin lnn word
+ 161, 2, L_FIX, // "sprmSPgnStart", // sep.pgnStart pgn word
+ 162, 1, L_FIX, // "sprmSBOrientation", // sep.dmOrientPage dm byte
+ 163, 0, L_FIX, // "?SprmSBCustomize 163", //???
+ 164, 2, L_FIX, // "sprmSXaPage", // sep.xaPage xa word
+ 165, 2, L_FIX, // "sprmSYaPage", // sep.yaPage ya word
+ 166, 2, L_FIX, // "sprmSDxaLeft", // sep.dxaLeft dxa word
+ 167, 2, L_FIX, // "sprmSDxaRight", // sep.dxaRight dxa word
+ 168, 2, L_FIX, // "sprmSDyaTop", // sep.dyaTop dya word
+ 169, 2, L_FIX, // "sprmSDyaBottom", // sep.dyaBottom dya word
+
+ 170, 2, L_FIX, // "sprmSDzaGutter", // sep.dzaGutter dza word
+ 171, 2, L_FIX, // "sprmSDMPaperReq", // sep.dmPaperReq dm word
+
+ 182, 2, L_FIX, // "sprmTJc", // tap.jc jc word (low order byte is significant)
+ 183, 2, L_FIX, // "sprmTDxaLeft", // tap.rgdxaCenter (see below) dxa word
+ 184, 2, L_FIX, // "sprmTDxaGapHalf", // tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
+ 185, 1, L_FIX, // "sprmTFCantSplit", // tap.fCantSplit 1 or 0 byte
+ 186, 1, L_FIX, // "sprmTTableHeader", // tap.fTableHeader 1 or 0 byte
+ 187,12, L_FIX, // "sprmTTableBorders", // tap.rgbrcTable complex(see below) 12 bytes
+ 188, 0, L_VAR, // "sprmTDefTable10", // tap.rgdxaCenter, tap.rgtc complex (see below) variable length
+ 189, 2, L_FIX, // "sprmTDyaRowHeight", // tap.dyaRowHeight dya word
+
+ 190, 0, L_VAR2, // "sprmTDefTable", // tap.rgtc complex (see below)
+ 191, 1, L_VAR, // "sprmTDefTableShd", // tap.rgshd complex (see below)
+ 192, 4, L_FIX, // "sprmTTlp", // tap.tlp TLP 4 bytes
+ 193, 5, L_FIX, // "sprmTSetBrc", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+ 194, 4, L_FIX, // "sprmTInsert", // tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
+ 195, 2, L_FIX, // "sprmTDelete", // tap.rgdxaCenter, tap.rgtc complex (see below) word
+ 196, 4, L_FIX, // "sprmTDxaCol", // tap.rgdxaCenter complex (see below) 4 bytes
+ 197, 2, L_FIX, // "sprmTMerge", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 198, 2, L_FIX, // "sprmTSplit", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 199, 5, L_FIX, // "sprmTSetBrc10", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+
+ 200, 4, L_FIX, // "sprmTSetShd", // tap.rgshd complex (see below) 4 bytes
+
+//- neue ab Ver8 ------------------------------------------------------------
+ /*
+ Die neuen Kodes werden einfach hier an die Liste angehaengt.
+ So kann ein und dieselbe Liste fuer Ver6 und Ver8 gemeinsam verwendet werden.
+ MS hat gluecklicherweise darauf geachtet, fuer Ver8 einen anderen Nummernkreis
+ zu nehmen als fuer Ver6-7.
+ */
+ 0x4600, 2, L_FIX, // "sprmPIstd" pap.istd;istd (style code);short;
+ 0xC601, 0, L_VAR, // "sprmPIstdPermute" pap.istd;permutation vector (see below);variable length;
+ 0x2602, 1, L_FIX, // "sprmPIncLvl" pap.istd, pap.lvl;difference between istd of base PAP and istd of PAP to be produced (see below);byte;
+ 0x2403, 1, L_FIX, // "sprmPJc" pap.jc;jc (justification);byte;
+ 0x2404, 1, L_FIX, // "sprmPFSideBySide" pap.fSideBySide;0 or 1;byte;
+ 0x2405, 1, L_FIX, // "sprmPFKeep" pap.fKeep;0 or 1;byte;
+ 0x2406, 1, L_FIX, // "sprmPFKeepFollow" pap.fKeepFollow;0 or 1;byte;
+ 0x2407, 1, L_FIX, // "sprmPFPageBreakBefore" pap.fPageBreakBefore;0 or 1;byte;
+ 0x2408, 1, L_FIX, // "sprmPBrcl" pap.brcl;brcl;byte;
+ 0x2409, 1, L_FIX, // "sprmPBrcp" pap.brcp;brcp;byte;
+ 0x260A, 1, L_FIX, // "sprmPIlvl" pap.ilvl;ilvl;byte;
+ 0x460B, 2, L_FIX, // "sprmPIlfo" pap.ilfo;ilfo (list index) ;short;
+ 0x240C, 1, L_FIX, // "sprmPFNoLineNumb" pap.fNoLnn;0 or 1;byte;
+ 0xC60D, 0, L_VAR, // "sprmPChgTabsPapx" pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length
+ 0x840E, 2, L_FIX, // "sprmPDxaRight" pap.dxaRight;dxa;word;
+ 0x840F, 2, L_FIX, // "sprmPDxaLeft" pap.dxaLeft;dxa;word;
+ 0x4610, 2, L_FIX, // "sprmPNest" pap.dxaLeft;dxa-see below;word;
+ 0x8411, 2, L_FIX, // "sprmPDxaLeft1" pap.dxaLeft1;dxa;word;
+ 0x6412, 4, L_FIX, // "sprmPDyaLine" pap.lspd;an LSPD, a long word structure consisting of a short of dyaLine followed by a short of fMultLinespace - see below;long;
+ 0xA413, 2, L_FIX, // "sprmPDyaBefore" pap.dyaBefore;dya;word;
+ 0xA414, 2, L_FIX, // "sprmPDyaAfter" pap.dyaAfter;dya;word;
+ 0xC615, 0, L_VAR, // "sprmPChgTabs" pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length;
+ 0x2416, 1, L_FIX, // "sprmPFInTable" pap.fInTable;0 or 1;byte;
+ 0x2417, 1, L_FIX, // "sprmPFTtp" pap.fTtp;0 or 1;byte;
+ 0x8418, 2, L_FIX, // "sprmPDxaAbs" pap.dxaAbs;dxa;word;
+ 0x8419, 2, L_FIX, // "sprmPDyaAbs" pap.dyaAbs;dya;word;
+ 0x841A, 2, L_FIX, // "sprmPDxaWidth" pap.dxaWidth;dxa;word;
+ 0x261B, 1, L_FIX, // "sprmPPc" pap.pcHorz, pap.pcVert;complex - see below;byte;
+ 0x461C, 2, L_FIX, // "sprmPBrcTop10" pap.brcTop;BRC10;word;
+ 0x461D, 2, L_FIX, // "sprmPBrcLeft10" pap.brcLeft;BRC10;word;
+ 0x461E, 2, L_FIX, // "sprmPBrcBottom10" pap.brcBottom;BRC10;word;
+ 0x461F, 2, L_FIX, // "sprmPBrcRight10" pap.brcRight;BRC10;word;
+ 0x4620, 2, L_FIX, // "sprmPBrcBetween10" pap.brcBetween;BRC10;word;
+ 0x4621, 2, L_FIX, // "sprmPBrcBar10" pap.brcBar;BRC10;word;
+ 0x4622, 2, L_FIX, // "sprmPDxaFromText10" pap.dxaFromText;dxa;word;
+ 0x2423, 1, L_FIX, // "sprmPWr" pap.wr;wr (see description of PAP for definition;byte;
+ 0x6424, 4, L_FIX, // "sprmPBrcTop" pap.brcTop;BRC;long;
+ 0x6425, 4, L_FIX, // "sprmPBrcLeft" pap.brcLeft;BRC;long;
+ 0x6426, 4, L_FIX, // "sprmPBrcBottom" pap.brcBottom;BRC;long;
+ 0x6427, 4, L_FIX, // "sprmPBrcRight" pap.brcRight;BRC;long;
+ 0x6428, 4, L_FIX, // "sprmPBrcBetween" pap.brcBetween;BRC;long;
+ 0x6629, 4, L_FIX, // "sprmPBrcBar" pap.brcBar;BRC;long;
+ 0x242A, 1, L_FIX, // "sprmPFNoAutoHyph" pap.fNoAutoHyph;0 or 1;byte;
+ 0x442B, 2, L_FIX, // "sprmPWHeightAbs" pap.wHeightAbs;w;word;
+ 0x442C, 2, L_FIX, // "sprmPDcs" pap.dcs;DCS;short;
+ 0x442D, 2, L_FIX, // "sprmPShd" pap.shd;SHD;word;
+ 0x842E, 2, L_FIX, // "sprmPDyaFromText" pap.dyaFromText;dya;word;
+ 0x842F, 2, L_FIX, // "sprmPDxaFromText" pap.dxaFromText;dxa;word;
+ 0x2430, 1, L_FIX, // "sprmPFLocked" pap.fLocked;0 or 1;byte;
+ 0x2431, 1, L_FIX, // "sprmPFWidowControl" pap.fWidowControl;0 or 1;byte;
+ 0xC632, 0, L_VAR, // "sprmPRuler" ;;variable length;
+ 0x2433, 1, L_FIX, // "sprmPFKinsoku" pap.fKinsoku;0 or 1;byte;
+ 0x2434, 1, L_FIX, // "sprmPFWordWrap" pap.fWordWrap;0 or 1;byte;
+ 0x2435, 1, L_FIX, // "sprmPFOverflowPunct" pap.fOverflowPunct;0 or 1;byte;
+ 0x2436, 1, L_FIX, // "sprmPFTopLinePunct" pap.fTopLinePunct;0 or 1;byte;
+ 0x2437, 1, L_FIX, // "sprmPFAutoSpaceDE" pap.fAutoSpaceDE;0 or 1;byte;
+ 0x2438, 1, L_FIX, // "sprmPFAutoSpaceDN" pap.fAutoSpaceDN;0 or 1;byte;
+ 0x4439, 2, L_FIX, // "sprmPWAlignFont" pap.wAlignFont;iFa (see description of PAP for definition);word;
+ 0x443A, 2, L_FIX, // "sprmPFrameTextFlow" pap.fVertical pap.fBackward pap.fRotateFont;complex (see description of PAP for definition);word;
+ 0x243B, 1, L_FIX, // "sprmPISnapBaseLine" obsolete: not applicable in Word97 and later versions;;byte;
+ 0xC63E, 0, L_VAR, // "sprmPAnld" pap.anld;;variable length;
+ 0xC63F, 0, L_VAR, // "sprmPPropRMark" pap.fPropRMark;complex (see below);variable length;
+ 0x2640, 1, L_FIX, // "sprmPOutLvl" pap.lvl;has no effect if pap.istd is < 1 or is > 9;byte;
+ 0x2441, 1, L_FIX, // "sprmPFBiDi" ;;byte;
+ 0x2443, 1, L_FIX, // "sprmPFNumRMIns" pap.fNumRMIns;1 or 0;bit;
+ 0x2444, 1, L_FIX, // "sprmPCrLf" ;;byte;
+ 0xC645, 0, L_VAR, // "sprmPNumRM" pap.numrm;;variable length;
+ 0x6645, 4, L_FIX, // "sprmPHugePapx" see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x6646, 4, L_FIX, // "sprmPHugePapx" see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x2447, 1, L_FIX, // "sprmPFUsePgsuSettings" pap.fUsePgsuSettings;1 or 0;byte;
+ 0x2448, 1, L_FIX, // "sprmPFAdjustRight" pap.fAdjustRight;1 or 0;byte;
+ 0x0800, 1, L_FIX, // "sprmCFRMarkDel" chp.fRMarkDel;1 or 0;bit;
+ 0x0801, 1, L_FIX, // "sprmCFRMark" chp.fRMark;1 or 0;bit;
+ 0x0802, 1, L_FIX, // "sprmCFFldVanish" chp.fFldVanish;1 or 0;bit;
+
+// wahrscheinlich falsch:
+//0x6A03, 0, L_VAR, // "sprmCPicLocation" chp.fcPic and chp.fSpec;see below;variable length, length recorded is always 4;
+
+// eher so:
+ 0x6A03, 4, L_FIX, // "sprmCPicLocation" chp.fcPic and chp.fSpec;see below;
+ // variable length,
+ // ????????
+ // length recorded is always 4;
+ // ====== =========
+
+ 0x4804, 2, L_FIX, // "sprmCIbstRMark" chp.ibstRMark;index into sttbRMark;short;
+ 0x6805, 4, L_FIX, // "sprmCDttmRMark" chp.dttmRMark;DTTM;long;
+ 0x0806, 1, L_FIX, // "sprmCFData" chp.fData;1 or 0;bit;
+ 0x4807, 2, L_FIX, // "sprmCIdslRMark" chp.idslRMReason;an index to a table of strings defined in Word 6.0 executables;short;
+ 0xEA08, 1, L_FIX, // "sprmCChs" chp.fChsDiff and chp.chse;see below;3 bytes;
+ 0x6A09, 4, L_FIX, // "sprmCSymbol" chp.fSpec, chp.xchSym and chp.ftcSym;see below;variable length, length recorded is always 4;
+ 0x080A, 1, L_FIX, // "sprmCFOle2" chp.fOle2;1 or 0;bit;
+//0x480B, 0, L_FIX, // "sprmCIdCharType" obsolete: not applicable in Word97 and later versions;;;
+ 0x2A0C, 1, L_FIX, // "sprmCHighlight" chp.fHighlight, chp.icoHighlight;ico (fHighlight is set to 1 iff ico is not 0);byte;
+ 0x680E, 4, L_FIX, // "sprmCObjLocation" chp.fcObj;FC;long;
+//0x2A10, 0, L_FIX, // "sprmCFFtcAsciSymb" ;;;
+ 0x4A30, 2, L_FIX, // "sprmCIstd" chp.istd;istd, see stylesheet definition;short;
+ 0xCA31, 0, L_VAR, // "sprmCIstdPermute" chp.istd;permutation vector (see below);variable length;
+ 0x2A32, 0, L_VAR, // "sprmCDefault" whole CHP (see below);none;variable length;
+ 0x2A33, 0, L_FIX, // "sprmCPlain" whole CHP (see below);none;0;
+//0x2A34, 0, L_FIX, // "sprmCKcd" ;;;
+ 0x0835, 1, L_FIX, // "sprmCFBold" chp.fBold;0,1, 128, or 129 (see below);byte;
+ 0x0836, 1, L_FIX, // "sprmCFItalic" chp.fItalic;0,1, 128, or 129 (see below);byte;
+ 0x0837, 1, L_FIX, // "sprmCFStrike" chp.fStrike;0,1, 128, or 129 (see below);byte;
+ 0x0838, 1, L_FIX, // "sprmCFOutline" chp.fOutline;0,1, 128, or 129 (see below);byte;
+ 0x0839, 1, L_FIX, // "sprmCFShadow" chp.fShadow;0,1, 128, or 129 (see below);byte;
+ 0x083A, 1, L_FIX, // "sprmCFSmallCaps" chp.fSmallCaps;0,1, 128, or 129 (see below);byte;
+ 0x083B, 1, L_FIX, // "sprmCFCaps" chp.fCaps;0,1, 128, or 129 (see below);byte;
+ 0x083C, 1, L_FIX, // "sprmCFVanish" chp.fVanish;0,1, 128, or 129 (see below);byte;
+ 0x4A3D, 2, L_FIX, // "sprmCFtcDefault" ;ftc, only used internally, never stored in file;word;
+ 0x2A3E, 1, L_FIX, // "sprmCKul" chp.kul;kul;byte;
+ 0xEA3F, 3, L_FIX, // "sprmCSizePos" chp.hps, chp.hpsPos;(see below);3 bytes;
+ 0x8840, 2, L_FIX, // "sprmCDxaSpace" chp.dxaSpace;dxa;word;
+ 0x4A41, 2, L_FIX, // "sprmCLid" ;only used internally never stored;word;
+ 0x2A42, 1, L_FIX, // "sprmCIco" chp.ico;ico;byte;
+ 0x4A43, 2, L_FIX, // "sprmCHps" chp.hps;hps;byte; ACHTUNG: ich nehme mal lieber ein: word;
+ 0x2A44, 1, L_FIX, // "sprmCHpsInc" chp.hps;(see below);byte;
+ 0x4845, 1, L_FIX, // "sprmCHpsPos" chp.hpsPos;hps;byte;
+ 0x2A46, 1, L_FIX, // "sprmCHpsPosAdj" chp.hpsPos;hps (see below);byte;
+ 0xCA47, 0, L_VAR, // "sprmCMajority" chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.rgftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico, chp.rglid;complex (see below);variable length, length byte plus size of following grpprl;
+ 0x2A48, 1, L_FIX, // "sprmCIss" chp.iss;iss;byte;
+ 0xCA49, 0, L_VAR, // "sprmCHpsNew50" chp.hps;hps;variable width, length always recorded as 2;
+ 0xCA4A, 0, L_VAR, // "sprmCHpsInc1" chp.hps;complex (see below);variable width, length always recorded as 2;
+ 0x484B, 2, L_FIX, // "sprmCHpsKern" chp.hpsKern;hps;short;
+ 0xCA4C, 2, L_FIX, // "sprmCMajority50" chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.ftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico,;complex (see below);variable length;
+ 0x4A4D, 2, L_FIX, // "sprmCHpsMul" chp.hps;percentage to grow hps;short;
+ 0x484E, 2, L_FIX, // "sprmCYsri" chp.ysri;ysri;short;
+ 0x4A4F, 2, L_FIX, // "sprmCRgFtc0" chp.rgftc[0];ftc for ASCII text (see below);short;
+ 0x4A50, 2, L_FIX, // "sprmCRgFtc1" chp.rgftc[1];ftc for Far East text (see below);short;
+ 0x4A51, 2, L_FIX, // "sprmCRgFtc2" chp.rgftc[2];ftc for non-Far East text (see below);short;
+//0x4852, 0, L_FIX, // "sprmCCharScale" ;;;
+ 0x2A53, 1, L_FIX, // "sprmCFDStrike" chp.fDStrike;;byte;
+ 0x0854, 1, L_FIX, // "sprmCFImprint" chp.fImprint;1 or 0;bit;
+ 0x0855, 1, L_FIX, // "sprmCFSpec" chp.fSpec ;1 or 0;bit;
+ 0x0856, 1, L_FIX, // "sprmCFObj" chp.fObj;1 or 0;bit;
+ 0xCA57, 0, L_VAR, // "sprmCPropRMark" chp.fPropRMark, chp.ibstPropRMark, chp.dttmPropRMark;Complex (see below);variable length always recorded as 7 bytes;
+ 0x0858, 1, L_FIX, // "sprmCFEmboss" chp.fEmboss;1 or 0;bit;
+ 0x2859, 1, L_FIX, // "sprmCSfxText" chp.sfxtText;text animation;byte;
+//0x085A, 0, L_FIX, // "sprmCFBiDi" ;;;
+//0x085B, 0, L_FIX, // "sprmCFDiacColor" ;;;
+//0x085C, 0, L_FIX, // "sprmCFBoldBi" ;;;
+//0x085D, 0, L_FIX, // "sprmCFItalicBi" ;;;
+//0x4A5E, 0, L_FIX, // "sprmCFtcBi" ;;;
+//0x485F, 0, L_FIX, // "sprmCLidBi" ;;;
+//0x4A60, 0, L_FIX, // "sprmCIcoBi" ;;;
+//0x4A61, 0, L_FIX, // "sprmCHpsBi" ;;;
+ 0xCA62, 0, L_VAR, // "sprmCDispFldRMark" chp.fDispFldRMark, chp.ibstDispFldRMark, chp.dttmDispFldRMark ;Complex (see below);variable length always recorded as 39 bytes;
+ 0x4863, 2, L_FIX, // "sprmCIbstRMarkDel" chp.ibstRMarkDel;index into sttbRMark;short;
+ 0x6864, 4, L_FIX, // "sprmCDttmRMarkDel" chp.dttmRMarkDel;DTTM;long;
+ 0x6865, 4, L_FIX, // "sprmCBrc" chp.brc;BRC;long;
+ 0x4866, 2, L_FIX, // "sprmCShd" chp.shd;SHD;short;
+ 0x4867, 2, L_FIX, // "sprmCIdslRMarkDel" chp.idslRMReasonDel;an index to a table of strings defined in Word 6.0 executables;short;
+ 0x0868, 1, L_FIX, // "sprmCFUsePgsuSettings" chp.fUsePgsuSettings;1 or 0;bit;
+ 0x486B, 2, L_FIX, // "sprmCCpg" ;;word;
+ 0x486D, 2, L_FIX, // "sprmCRgLid0" chp.rglid[0];LID: for non-Far East text;word;
+ 0x486E, 2, L_FIX, // "sprmCRgLid1" chp.rglid[1];LID: for Far East text;word;
+ 0x286F, 1, L_FIX, // "sprmCIdctHint" chp.idctHint;IDCT: (see below);byte;
+ 0x2E00, 1, L_FIX, // "sprmPicBrcl" pic.brcl;brcl (see PIC structure definition);byte;
+ 0xCE01, 0, L_VAR, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft, pic.dyaCropTop pic.dxaCropRight, pic.dyaCropBottom;Complex (see below);length byte plus 12 bytes;
+ 0x6C02, 4, L_FIX, // "sprmPicBrcTop" pic.brcTop;BRC;long;
+ 0x6C03, 4, L_FIX, // "sprmPicBrcLeft" pic.brcLeft;BRC;long;
+ 0x6C04, 4, L_FIX, // "sprmPicBrcBottom" pic.brcBottom;BRC;long;
+ 0x6C05, 4, L_FIX, // "sprmPicBrcRight" pic.brcRight;BRC;long;
+ 0x3000, 1, L_FIX, // "sprmScnsPgn" sep.cnsPgn;cns;byte;
+ 0x3001, 1, L_FIX, // "sprmSiHeadingPgn" sep.iHeadingPgn;heading number level;byte;
+ 0xD202, 0, L_VAR, // "sprmSOlstAnm" sep.olstAnm;OLST;variable length;
+ 0xF203, 3, L_FIX, // "sprmSDxaColWidth" sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0xF204, 3, L_FIX, // "sprmSDxaColSpacing" sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0x3005, 1, L_FIX, // "sprmSFEvenlySpaced" sep.fEvenlySpaced;1 or 0;byte;
+ 0x3006, 1, L_FIX, // "sprmSFProtected" sep.fUnlocked;1 or 0;byte;
+ 0x5007, 2, L_FIX, // "sprmSDmBinFirst" sep.dmBinFirst;;word;
+ 0x5008, 2, L_FIX, // "sprmSDmBinOther" sep.dmBinOther;;word;
+ 0x3009, 1, L_FIX, // "sprmSBkc" sep.bkc;bkc;byte;
+ 0x300A, 1, L_FIX, // "sprmSFTitlePage" sep.fTitlePage;0 or 1;byte;
+ 0x500B, 2, L_FIX, // "sprmSCcolumns" sep.ccolM1;# of cols - 1;word;
+ 0x900C, 2, L_FIX, // "sprmSDxaColumns" sep.dxaColumns;dxa;word;
+ 0x300D, 1, L_FIX, // "sprmSFAutoPgn" sep.fAutoPgn;obsolete;byte;
+ 0x300E, 1, L_FIX, // "sprmSNfcPgn" sep.nfcPgn;nfc;byte;
+ 0xB00F, 2, L_FIX, // "sprmSDyaPgn" sep.dyaPgn;dya;short;
+ 0xB010, 2, L_FIX, // "sprmSDxaPgn" sep.dxaPgn;dya;short;
+ 0x3011, 1, L_FIX, // "sprmSFPgnRestart" sep.fPgnRestart;0 or 1;byte;
+ 0x3012, 1, L_FIX, // "sprmSFEndnote" sep.fEndnote;0 or 1;byte;
+ 0x3013, 1, L_FIX, // "sprmSLnc" sep.lnc;lnc;byte;
+ 0x3014, 1, L_FIX, // "sprmSGprfIhdt" sep.grpfIhdt;grpfihdt (see Headers and Footers topic);byte;
+ 0x5015, 2, L_FIX, // "sprmSNLnnMod" sep.nLnnMod;non-neg int.;word;
+ 0x9016, 2, L_FIX, // "sprmSDxaLnn" sep.dxaLnn;dxa;word;
+ 0xB017, 2, L_FIX, // "sprmSDyaHdrTop" sep.dyaHdrTop;dya;word;
+ 0xB018, 2, L_FIX, // "sprmSDyaHdrBottom" sep.dyaHdrBottom;dya;word;
+ 0x3019, 1, L_FIX, // "sprmSLBetween" sep.fLBetween;0 or 1;byte;
+ 0x301A, 1, L_FIX, // "sprmSVjc" sep.vjc;vjc;byte;
+ 0x501B, 2, L_FIX, // "sprmSLnnMin" sep.lnnMin;lnn;word;
+ 0x501C, 2, L_FIX, // "sprmSPgnStart" sep.pgnStart;pgn;word;
+ 0x301D, 1, L_FIX, // "sprmSBOrientation" sep.dmOrientPage;dm;byte;
+//0x301E, 0, L_FIX, // "sprmSBCustomize" ;;;
+
+ 0xB01F, 2, L_FIX, // "sprmSXaPage" sep.xaPage;xa;word;
+ 0xB020, 2, L_FIX, // "sprmSYaPage" sep.yaPage;ya;word;
+ 0xB021, 2, L_FIX, // "sprmSDxaLeft" sep.dxaLeft;dxa;word;
+ 0xB022, 2, L_FIX, // "sprmSDxaRight" sep.dxaRight;dxa;word;
+ 0x9023, 2, L_FIX, // "sprmSDyaTop" sep.dyaTop;dya;word;
+ 0x9024, 2, L_FIX, // "sprmSDyaBottom" sep.dyaBottom;dya;word;
+
+ 0xB025, 2, L_FIX, // "sprmSDzaGutter" sep.dzaGutter;dza;word;
+ 0x5026, 2, L_FIX, // "sprmSDmPaperReq" sep.dmPaperReq;dm;word;
+ 0xD227, 0, L_VAR, // "sprmSPropRMark" sep.fPropRMark, sep.ibstPropRMark, sep.dttmPropRMark ;complex (see below);variable length always recorded as 7 bytes;
+//0x3228, 0, L_FIX, // "sprmSFBiDi" ;;;
+//0x3229, 0, L_FIX, // "sprmSFFacingCol" ;;;
+//0x322A, 0, L_FIX, // "sprmSFRTLGutter" ;;;
+ 0x702B, 4, L_FIX, // "sprmSBrcTop" sep.brcTop;BRC;long;
+ 0x702C, 4, L_FIX, // "sprmSBrcLeft" sep.brcLeft;BRC;long;
+ 0x702D, 4, L_FIX, // "sprmSBrcBottom" sep.brcBottom;BRC;long;
+ 0x702E, 4, L_FIX, // "sprmSBrcRight" sep.brcRight;BRC;long;
+ 0x522F, 2, L_FIX, // "sprmSPgbProp" sep.pgbProp;;word;
+ 0x7030, 4, L_FIX, // "sprmSDxtCharSpace" sep.dxtCharSpace;dxt;long;
+ 0x9031, 4, L_FIX, // "sprmSDyaLinePitch" sep.dyaLinePitch;dya;long;
+//0x5032, 0, L_FIX, // "sprmSClm" ;;;
+ 0x5033, 2, L_FIX, // "sprmSTextFlow" sep.wTextFlow;complex (see below);short;
+ 0x5400, 2, L_FIX, // "sprmTJc" tap.jc;jc;word (low order byte is significant);
+ 0x9601, 2, L_FIX, // "sprmTDxaLeft" tap.rgdxaCenter (see below);dxa;word;
+ 0x9602, 2, L_FIX, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter (see below);dxa;word;
+ 0x3403, 1, L_FIX, // "sprmTFCantSplit" tap.fCantSplit;1 or 0;byte;
+ 0x3404, 1, L_FIX, // "sprmTTableHeader" tap.fTableHeader;1 or 0;byte;
+ 0xD605, 0, L_VAR, // "sprmTTableBorders" tap.rgbrcTable;complex(see below);24 bytes;
+ 0xD606, 0, L_VAR, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc;complex (see below);variable length;
+ 0x9407, 2, L_FIX, // "sprmTDyaRowHeight" tap.dyaRowHeight;dya;word;
+ 0xD608, 0, L_VAR, // "sprmTDefTable" tap.rgtc;complex (see below);;
+ 0xD609, 0, L_VAR, // "sprmTDefTableShd" tap.rgshd;complex (see below);;
+ 0x740A, 2, L_FIX, // "sprmTTlp" tap.tlp;TLP;4 bytes;
+//0x560B, 0, L_FIX, // "sprmTFBiDi" ;;;
+//0x740C, 0, L_FIX, // "sprmTHTMLProps" ;;;
+ 0xD620, 0, L_VAR, // "sprmTSetBrc" tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7621, 0, L_VAR, // "sprmTInsert" tap.rgdxaCenter, tap.rgtc;complex (see below);4 bytes;
+ 0x5622, 0, L_VAR, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc;complex (see below);word;
+ 0x7623, 0, L_VAR, // "sprmTDxaCol" tap.rgdxaCenter;complex (see below);4 bytes;
+ 0x5624, 0, L_VAR, // "sprmTMerge" tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0x5625, 0, L_VAR, // "sprmTSplit" tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0xD626, 0, L_VAR, // "sprmTSetBrc10" tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7627, 0, L_VAR, // "sprmTSetShd" tap.rgshd;complex (see below);4 bytes;
+ 0x7628, 0, L_VAR, // "sprmTSetShdOdd" tap.rgshd;complex (see below);4 bytes;
+ 0x7629, 0, L_VAR, // "sprmTTextFlow" tap.rgtc[].fVerticaltap.rgtc[].fBackwardtap.rgtc[].fRotateFont;0 or 10 or 10 or 1;word;
+//0xD62A, 0, L_FIX, // "sprmTDiagLine" ;;;
+ 0xD62B, 0, L_VAR, // "sprmTVertMerge" tap.rgtc[].vertMerge;complex (see below);variable length always recorded as 2 bytes;
+ 0xD62C, 0, L_VAR, // "sprmTVertAlign" tap.rgtc[].vertAlign;complex (see below);variable length always recorded as 3 byte;
+
+};
+
+
+
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC )
+ _Optlink
+#endif
+ CompSprmId( const void *pFirst, const void *pSecond)
+{
+ return( ((SprmInfo*)pFirst )->nId - ((SprmInfo*)pSecond)->nId );
+}
+
+
+SprmInfo& WW8GetSprmInfo( USHORT nId )
+{
+ // ggfs. Tab sortieren
+ static BOOL bInit = FALSE;
+ if( !bInit )
+ {
+ qsort( (void*)aWwSprmTab,
+ sizeof( aWwSprmTab ) / sizeof (aWwSprmTab[ 0 ]),
+ sizeof( aWwSprmTab[ 0 ] ),
+ CompSprmId );
+ bInit = TRUE;
+ }
+ // Sprm heraussuchen
+ void* pFound;
+ SprmInfo aSrch;
+ aSrch.nId = nId;
+ if( 0 == ( pFound = bsearch( (char *) &aSrch,
+ (void*) aWwSprmTab,
+ sizeof( aWwSprmTab ) / sizeof (aWwSprmTab[ 0 ]),
+ sizeof( aWwSprmTab[ 0 ] ),
+ CompSprmId )))
+ {
+ // im Fehlerfall auf Nulltes Element verweisen
+ pFound = (void*)aWwSprmTab;
+ }
+ return *(SprmInfo*) pFound;
+}
+
+
+
+//-----------------------------------------
+// Sprms
+//-----------------------------------------
+
+static short WW8GetSprmSize0( USHORT nId, BYTE* pSprm, BYTE nDelta)
+{
+ SprmInfo& rSprm = WW8GetSprmInfo( nId );
+ short nL = 0; // soviel Bytes sind zu lesen
+
+ //sprmPChgTabs
+ switch( nId )
+ {
+ case 23:
+ case 0xC615:
+ if( SVBT16ToShort( &pSprm[1 + nDelta] ) != 255 )
+ nL = SVBT16ToShort( &pSprm[1 + nDelta] ) + rSprm.nLen - 1;
+ else
+ {
+ BYTE nDel = pSprm[2 + nDelta];
+ BYTE nIns = pSprm[3 + nDelta + 4 * nDel];
+
+ nL = 2 + 4 * nDel + 3 * nIns;
+ }
+ break;
+
+ case 0xd608:
+ nL = SVBT16ToShort( &pSprm[1 + nDelta] );
+ break;
+
+ default:
+ switch ( rSprm.nVari )
+ {
+ case L_FIX: nL = rSprm.nLen; // Excl. Token
+ break;
+ case L_VAR: nL = (short)pSprm[1 + nDelta]// Variable 1-Byte Laenge?
+ + rSprm.nLen; // Excl. Token + Var-Laengenbyte
+ break;
+ // case L_VAR2: nL = ( *(short*)&pSprm[1 + nDelta] ) // Variable 2-Byte Laenge?
+ case L_VAR2: nL = SVBT16ToShort( &pSprm[1 + nDelta] ) // Variable 2-Byte Laenge?
+ + rSprm.nLen - 1; // Excl. Token + Var-Laengenbyte
+ break;
+ }
+ break;
+ }
+ return nL;
+}
+
+
+USHORT WW8CountSprms( BYTE nVersion,
+ BYTE* pSp,
+ long nSprmSiz,
+ const SvUShortsSort* pIgnoreSprms )
+{
+ BYTE nDelta = ( 8 > nVersion ) ? 0 : 1;
+ USHORT nMySprms = 0;
+ for(short i=0; i+1+nDelta < nSprmSiz; )
+ {
+ USHORT nSpId = WW8GetSprmId( nVersion, pSp );
+
+ if( !nSpId )
+ break;
+
+ short nSpLen = WW8GetSprmSizeBrutto( nVersion, pSp, &nSpId );
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ i += nSpLen;
+ pSp += nSpLen;
+
+ if( !pIgnoreSprms || USHRT_MAX == pIgnoreSprms->Seek_Entry( nSpId ) )
+ {
+ ++nMySprms;
+ }
+ }
+ return nMySprms;
+}
+
+BOOL WW8PLCFx_SEPX::CompareSprms( BYTE* pOtherSprms,
+ long nOtherSprmSiz,
+ const SvUShortsSort* pIgnoreSprms ) const
+{
+ BOOL bRes = FALSE;
+ BYTE* pSp = pSprms;
+ short i;
+ BYTE nDelta = ( 8 > GetVersion()) ? 0 : 1;
+
+ if( WW8CountSprms(GetVersion(), pSp, nSprmSiz, pIgnoreSprms)
+ == WW8CountSprms(GetVersion(), pOtherSprms, nOtherSprmSiz, pIgnoreSprms) )
+ {
+ bRes = TRUE;
+ for( i=0; i+1+nDelta < nSprmSiz; )
+ {
+ USHORT nSpId = WW8GetSprmId( GetVersion(), pSp );
+
+ if( !nSpId )
+ break;
+
+ short nSpLen = WW8GetSprmSizeBrutto( GetVersion(), pSp, &nSpId );
+
+ if( !pIgnoreSprms || !pIgnoreSprms->Seek_Entry( nSpId ) )
+ {
+ BYTE* pOtherSp = HasSprm( nSpId, pOtherSprms, nOtherSprmSiz );
+
+ if( ( !pOtherSp )
+ || (0 != memcmp( pSp + 1 + nDelta + WW8SprmDataOfs( nSpId ),
+ pOtherSp,
+ WW8GetSprmSize0( nSpId, pSp, nDelta ) ) ) )
+ {
+ bRes = FALSE;
+ break;
+ }
+ }
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ i += nSpLen;
+ pSp += nSpLen;
+ }
+ }
+ return bRes; // unterschiedliche Sprms ?
+}
+
+
+// ein bzw. zwei Byte am Anfang des Sprm sind die Id
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta )
+{
+ USHORT nId = 0;
+ switch( nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: nId = *pSp;
+ if( 0x0100 < nId ) nId = 0;
+ if( pDelta ) *pDelta = 0;
+ break;
+ case 8: nId = SVBT16ToShort( &pSp[ 0 ] );
+ if( 0x0800 > nId )
+ nId = 0;
+ if( pDelta )
+ *pDelta = 1;
+ break;
+ default:ASSERT( nId, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+ return nId;
+}
+
+
+// ohne Token und LaengenByte
+short WW8GetSprmSizeNetto( BYTE nVersion, BYTE* pSprm, USHORT* pId )
+{
+ BYTE nDelta = ( 8 > nVersion ) ? 0 : 1;
+ USHORT nId = pId ? *pId : WW8GetSprmId( nVersion, pSprm );
+ return WW8GetSprmSize0( nId, pSprm, nDelta );
+}
+
+
+// mit Token und LaengenByte
+short WW8GetSprmSizeBrutto( BYTE nVersion, BYTE* pSprm, USHORT* pId )
+{
+ BYTE nDelta = ( 8 > nVersion ) ? 0 : 1;
+ USHORT nId = pId ? *pId : WW8GetSprmId( nVersion, pSprm );
+ return WW8GetSprmSize0( nId, pSprm, nDelta )
+ + 1 + nDelta
+ + WW8GetSprmInfo( nId ).nVari;
+}
+
+BYTE WW8SprmDataOfs( USHORT nId )
+{
+ return WW8GetSprmInfo( nId ).nVari;
+}
+
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/dump/ww8scan.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.12 2000/09/18 16:05:03 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.11 2000/02/11 14:39:42 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.10 2000/02/03 10:09:40 cmc
+ #72268# Allow create fib from offset, added data to STTBF
+
+ Revision 1.75 2000/02/03 10:08:30 cmc
+ #72268# Allow create fib from offset, added data to STTBF
+
+ Revision 1.74 2000/02/02 18:07:47 khz
+ Task #69885# Read SPRMs that are stored in piece table grpprls
+
+ Revision 1.73 1999/12/21 08:02:45 khz
+ Task #68143# nIdx set to Zero caused Hd/Ft to get wrong sprms
+
+ Revision 1.72 1999/12/07 14:29:00 khz
+ Task #69508# import sprmPHugePapx by reading DATA stream
+
+ Revision 1.71 1999/12/07 09:53:04 khz
+ Task #67979# typo-error corrected (was '==' instead of '=')
+
+ Revision 1.70 1999/12/06 19:34:27 khz
+ Task #67979# Absolute Positioned Object must have SPRM 5 or SPRM 29
+
+ Revision 1.69 1999/11/19 15:09:24 khz
+ Task #69910# Use extra PLCF structure for field!
+
+ Revision 1.68 1999/11/03 17:20:04 khz
+ Task #68676# GPF when loading file under Solaris (reading FFN structures)
+
+ Revision 1.67 1999/10/21 15:36:25 khz
+ Import Redlining (4)
+
+ Revision 1.66 1999/10/13 21:06:47 khz
+ Import Redlining (3)
+
+ Revision 1.65 1999/10/08 09:25:29 khz
+ Import Redlining
+
+ Revision 1.64 1999/09/10 15:36:43 khz
+ CharSet matching made by TENCINFO.H::rtl_getTextEncodingFromWindowsCharset()
+
+ Revision 1.63 1999/09/09 18:16:17 khz
+ CharSet matching now done in central methode WW8SCAN.HXX::WW8GetCharSet()
+
+ Revision 1.62 1999/09/08 13:26:13 khz
+ Better performance by reducing use of SWAP..() and SVBT..To..() methods
+
+ Revision 1.61 1999/08/30 19:53:02 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.60 30 Aug 1999 21:53:02 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.59 09 Aug 1999 18:34:38 KHZ
+ Task #67543# Import of Property Modifier(variant 1) (PRM) in WW8 docs
+
+ Rev 1.58 18 Jun 1999 15:53:56 KHZ
+ Reference field (page, bookmark, footnote) part#1
+
+ Rev 1.57 15 Jun 1999 14:34:56 JP
+ for Export: FIB - read/write SttbListNames
+
+ Rev 1.56 14 Jun 1999 16:00:18 KHZ
+ Task #66411# allow import of document even when SEPX is missing completely
+
+ Rev 1.55 03 Jun 1999 16:58:56 KHZ
+ Task #66418# Nach C'tor WW8Fkp ein ''pSt->Seek( nOldPos );'' ausfuehren!
+
+ Rev 1.54 03 Jun 1999 11:42:46 KHZ
+ Task #66398# Variante 1 fuer PRM ist bei Ver67 Ok.
+
+ Rev 1.53 02 Jun 1999 17:07:46 KHZ
+ Task #66393# in WW8Cp2Fc ist *pIsUnicode bei bVer67 zu initialisieren
+
+ Rev 1.52 02 Jun 1999 09:32:44 KHZ
+ Task #66227# a) kein Unicode bei Ver67 ;-) b) Grafik in grupp. Textbox
+
+ Rev 1.51 28 May 1999 09:59:12 JP
+ Fib-CTOR: wichtige Flags fuer den W97-Export setzen
+
+ Rev 1.50 28 May 1999 09:19:22 KHZ
+ Task #66395# Return-Adresse kein komplexer Ausdruck mehr
+
+ Rev 1.49 26 May 1999 10:58:02 JP
+ Fib: einige Konstanten nachgetragen
+
+ Rev 1.48 21 May 1999 01:58:08 JP
+ Export von WW97 Format: DOP in TableStream
+
+ Rev 1.47 19 May 1999 11:12:54 JP
+ WinWord97-ExportFilter
+
+ Rev 1.46 11 May 1999 17:15:32 KHZ
+ Task #66019# FontFamily: andere Bitreihenfolge auf Solaris beachten
+
+ Rev 1.45 14 Apr 1999 14:20:12 KHZ
+ Task #61268# Solaris-Problem wegen drei vergessenen SVBT16-Umwandlungen
+
+ Rev 1.44 13 Apr 1999 16:02:28 KHZ
+ Task #61268# SVBT16 statt USHORT bei Bookmarks eingesetzt
+
+ Rev 1.43 10 Mar 1999 15:11:12 KHZ
+ Task #62521# Einlesen von Sonderzeichen
+
+ Rev 1.42 08 Mar 1999 11:48:48 KHZ
+ Task #57749# Writer kann jetzt spaltige Bereiche
+
+ Rev 1.41 26 Feb 1999 14:43:38 KHZ
+ Task #59715# Behandlung von Section breaks
+
+ Rev 1.40 25 Jan 1999 10:22:38 KHZ
+ Task #60715# in Textobjekt verankerte Grafik als Grafik importieren
+
+ Rev 1.39 19 Jan 1999 10:47:42 KHZ
+ Task #60878# WW8Cp2Fc setzt *pIsUniCode bei Non-Complex auf FALSE
+
+ Rev 1.38 18 Jan 1999 08:57:08 KHZ
+ Task #60878# WW8Dp2Fc nur dann Assertion, wenn kein pTestFlag
+
+ Rev 1.37 11 Dec 1998 11:12:38 JP
+ Task #59580# Unicode (3) - Bug behoben beim Read_Xstz
+
+ Rev 1.36 10 Dec 1998 21:29:00 JP
+ Bug #59643#: benutzerdefinierte Zeichen von Fuss-/EndNoten verarbeiten
+
+ Rev 1.35 07 Dec 1998 18:17:06 KHZ
+ Task #59580# falsches Feldende: WW8SkipField verglich mit 0x7f statt 0x1f
+
+ Rev 1.34 05 Dec 1998 17:10:26 KHZ
+ Task #59580# Unicode (3)
+
+ Rev 1.33 04 Dec 1998 20:19:50 KHZ
+ Task #58766# Textboxen mit Unicode-Inhalt
+
+ Rev 1.32 03 Dec 1998 19:10:02 KHZ
+ Task #58766# Unicode-Import (2)
+
+ Rev 1.31 03 Dec 1998 10:39:50 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.30 02 Dec 1998 16:57:02 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.29 30 Nov 1998 17:46:50 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.28 30 Nov 1998 17:30:36 KHZ
+ Task #54828# Unicode-Import
+
+ Rev 1.27 03 Nov 1998 18:29:54 KHZ
+ Task #57243# Performance-Gewinn durch Vermeiden ueberfluessiger WW8GetSprmId()
+
+ Rev 1.26 02 Nov 1998 17:58:32 KHZ
+ Task #57017# Textmarken-Namen als UNICODE-Strings
+
+ Rev 1.25 16 Oct 1998 16:12:34 KHZ
+ Task #53520# ueberpruefe Feld DRUCKDATUM in DocInfo anhand von WW-internem Feld
+
+ Rev 1.24 22 Sep 1998 19:37:42 KHZ
+ Bug #57018# Fontnamen wurden unrichtig importiert
+
+ Rev 1.23 22 Sep 1998 17:40:24 KHZ
+ Bug #56310# Kopf-/Fusszeilen in Unicode-Dokumenten jetzt korrekt
+
+ Rev 1.22 03 Sep 1998 22:15:40 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.21 27 Aug 1998 10:12:28 KHZ
+ Task #55189# Escher-Import fuer Draw, Calc und Writer
+
+ Rev 1.20 11 Aug 1998 12:26:16 KHZ
+ Task #52607# Optimierung in AdjustEnds(), GetNewSprms(), GetNoNewSprms()
+
+ Rev 1.19 30 Jul 1998 14:47:24 JP
+ Bug #54385#: sal_Unicode ist unter UNX ein long und kein UINT16
+
+ Rev 1.18 30 Jul 1998 00:02:54 KHZ
+ Task #53614# Grafiken, die NICHT ueber dem Text liegen (MSDFF-Quick-Hack)
+
+ Rev 1.17 29 Jul 1998 16:53:18 KHZ
+ Task #52607# Fehler in FKP (Teil 2)
+
+ Rev 1.16 29 Jul 1998 13:56:10 KHZ
+ Task #52607# Fehler in FKP
+
+ Rev 1.15 28 Jul 1998 22:27:28 KHZ
+ Task #52607# nummerierte Listen (Teil 3)
+
+ Rev 1.14 28 Jul 1998 11:05:46 KHZ
+ Task #52607# nummerierte Listen (Teil 1)
+
+ Rev 1.13 22 Jul 1998 15:32:56 KHZ
+ Task #52607#
+
+ Rev 1.12 21 Jul 1998 14:52:28 KHZ
+ Task #52607# (WW 97 Import)
+
+ Rev 1.11 21 Jul 1998 12:32:52 KHZ
+ als MSDrawingObject eingebettete Grafik (Teil 1)
+
+ Rev 1.10 16 Jul 1998 21:50:14 KHZ
+ Task #52607# Compilererror wg. (rLen *= 2) -= 2
+
+ Rev 1.9 15 Jul 1998 15:47:18 KHZ
+ Task #52607# Felder
+
+ Rev 1.8 14 Jul 1998 16:34:18 KHZ
+ Task #52607# Absatz- und Zeichen-Styles
+
+ Rev 1.7 13 Jul 1998 15:29:46 KHZ
+ Task #52607# Seitenvorlage fuer 1st Page, embed. Grafik (NICHT UEBER Text)
+
+ Rev 1.6 30 Jun 1998 21:33:20 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.5 26 Jun 1998 20:50:22 KHZ
+ Absatz-Attribute jetzt weitestgehend ok
+
+ Rev 1.4 23 Jun 1998 20:49:26 KHZ
+ verarbeitet jetzt auch mehrere FKPs
+
+ Rev 1.3 23 Jun 1998 11:24:28 KHZ
+ Zwischenstand: die meisten Zeichenattribute Ok!
+
+ Rev 1.2 18 Jun 1998 09:47:12 KHZ
+ Zwischenstand fur 396c
+
+ Rev 1.1 16 Jun 1998 18:35:30 KHZ
+ DaSi-Stand
+
+ Rev 1.0 16 Jun 1998 10:57:24 KHZ
+ Initial revision.
+
+ Rev 1.1 10 Jun 1998 17:22:32 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:29:02 KHZ
+ Initial revision.
+
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/dump/ww8scan.hxx b/sw/source/filter/ww8/dump/ww8scan.hxx
new file mode 100644
index 000000000000..d49c1a89df69
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8scan.hxx
@@ -0,0 +1,1498 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8scan.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WW8SCAN_HXX
+#define _WW8SCAN_HXX
+
+
+#ifndef _SOLAR_H
+#include <tools/solar.h> // UINTXX
+#endif
+#ifndef _DATETIME_HXX //autogen
+#include <tools/datetime.hxx>
+#endif
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+#ifndef WW8STRUC_HXX
+#include "ww8struc.hxx" // FIB, STSHI, STD
+#endif
+#ifndef LONG_MAX
+#include <limits.h>
+#endif
+#ifndef _SAL_TYPES_H
+#include <sal/types.h>
+#endif
+
+ // ASS_FALSE, um ASSERT( ASS_FALSE, ... ) schreiben
+ // zu koennen, ohne vom Compiler angemeckert zu werden
+#ifndef ASS_FALSE
+#define ASS_FALSE ( !this )
+#endif
+
+#ifndef DELETEZ
+#define DELETEZ( p ) ( delete( p ), p = 0 )
+#endif
+
+
+//class SvStream;
+class UShortStk;
+class WW8Fib;
+class WW8ScannerBase;
+class WW8PLCFspecial;
+struct WW8PLCFxDesc;
+class WW8PLCFx_PCD;
+class SvUShortsSort;
+
+
+
+UINT8* WW8ReadPString( SvStream& rStrm, BOOL bAtEndSeekRel1 = TRUE );
+
+// Folgende Methode liest einen 2-byter-UNICODE-String ein:
+// - falls bAtEndSeekRel1 gesetzt ist, wird am Ende genau EIN Byte uebersprungen,
+// - falls nChars (die Zeichen-Anzahl, NICHT die Byte-Anzahl) nicht gesetzt ist,
+// wird das erste USHORT als Lannengenangabe interpretiert,
+// ansonsten als erstes String-Zeichen genommen.
+UINT8* WW8Read_xstz(SvStream& rStrm, BOOL bAtEndSeekRel1 = TRUE,
+ USHORT nChars = 0, BOOL bInsLeadingLen = TRUE,
+ long* pWasRead = 0 );
+
+
+// read array of strings (see MS documentation: STring TaBle stored in File)
+// returns NOT the original pascal strings but an array of converted char*
+//
+// attention: the *extra data* of each string are SKIPPED and ignored
+char** WW8ReadSTTBF(BOOL bVer8, SvStream& rStrm, UINT32 nStart,
+ INT32 nLen,
+ long& rCount,
+ USHORT nSkip = 0, BYTE ***pData=0);
+
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta = 0 );
+short WW8GetSprmSizeNetto( BYTE nVersion, BYTE* pSprm, USHORT* pId );
+short WW8GetSprmSizeBrutto( BYTE nVersion, BYTE* pSprm, USHORT* pId );
+BYTE WW8SprmDataOfs( USHORT nId );
+
+struct WW8_PSTR // Pascal-String
+{
+ UINT8 nLen;
+ char cStr[2]; // offene Laenge
+};
+
+struct WW8FieldDesc
+{
+ long nLen; // Gesamtlaenge ( zum Text ueberlesen )
+ WW8_CP nSCode; // Anfang Befehlscode
+ long nLCode; // Laenge
+ WW8_CP nSRes; // Anfang Ergebnis
+ long nLRes; // Laenge ( == 0, falls kein Ergebnis )
+ USHORT nId; // WW-Id fuer Felder
+ BYTE nOpt; // WW-Flags ( z.B.: vom User geaendert )
+ BOOL bCodeNest:1; // Befehl rekursiv verwendet
+ BOOL bResNest:1; // Befehl in Resultat eingefuegt
+};
+
+BOOL WW8GetFieldPara( BYTE nVersion, WW8PLCFspecial& rPLCF, WW8FieldDesc& rF );
+
+
+/*
+ u.a. fuer Felder, also genausoviele Attr wie Positionen,
+ falls Ctor-Param bNoEnd = false
+*/
+class WW8PLCFspecial // Iterator fuer PLCFs
+{
+ INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
+ char* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array
+ long nIMax; // Anzahl der Elemente
+ long nIdx; // Merker, wo wir gerade sind
+ long nStru;
+
+public:
+ WW8PLCFspecial( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos = -1, BOOL bNoEnd = FALSE );
+ ~WW8PLCFspecial(){ delete( pPLCF_PosArray ); pPLCF_PosArray = 0; }
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI ) { nIdx = (long)nI; } // geht ueber Nummer
+ long GetIMax(){ return nIMax; }
+ BOOL SeekPos( long nPos ); // geht ueber FC- bzw. CP-Wert
+ // bzw. naechste groesseren Wert
+ BOOL SeekPosExact( long nPos );
+ long Where() { return ( nIdx >= nIMax ) ? LONG_MAX : pPLCF_PosArray[nIdx]; }
+ BOOL Get( long& rStart, void*& rpValue );
+ BOOL GetData( long nIdx, long& rPos, void*& rpValue );
+
+ const void* GetData( long nIdx ) const {
+ return ( nIdx >= nIMax ) ? 0 : (const void*)&pPLCF_Contents[nIdx * nStru]; }
+ long GetPos( long nIdx ){
+ return ( nIdx >= nIMax ) ? LONG_MAX : pPLCF_PosArray[nIdx]; }
+
+ WW8PLCFspecial& operator ++( int ) { nIdx++; return *this; }
+ WW8PLCFspecial& operator --( int ) { nIdx--; return *this; }
+};
+
+
+
+
+/*
+ simple Iterator for SPRMs
+*/
+class WW8SprmIter
+{
+ // these members will be updated
+ BYTE* pSprms; // remaining part of the SPRMs ( == start of akt. SPRM)
+ BYTE* pAktParams; // start of akt. SPRM's parameters
+ USHORT nAktId;
+ short nAktSizeBrutto;
+
+ // these members will *not* be updated by UpdateMyMembers()
+ BYTE nVersion;
+ BYTE nDelta;
+ short nRemLen; // length of remaining SPRMs (including akt. SPRM)
+
+ void UpdateMyMembers();
+public:
+ WW8SprmIter( BYTE* pSprms_, short nLen_, BYTE nVersion_ );
+ void SetSprms( BYTE* pSprms_, short nLen_ );
+ BYTE* operator ++( int );
+ BYTE* GetSprms() const { return ( pSprms && (0 < nRemLen) )
+ ? pSprms
+ : 0; }
+ BYTE* GetAktParams() const { return pAktParams; }
+ USHORT GetAktId() const { return nAktId; }
+};
+
+
+
+/*
+ u.a. fuer FKPs auf normale Attr., also ein Attr weniger als Positionen
+*/
+class WW8PLCF // Iterator fuer PLCFs
+{
+ INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
+ char* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array
+ long nIMax; // Anzahl der Elemente
+ long nIdx;
+ long nStru;
+
+ void ReadPLCF( SvStream* pSt, long nFilePos, long nPLCF );
+
+ /*
+ Falls im Dok ein PLC fehlt und die FKPs solo dastehen,
+ machen wir uns hiermit einen PLC:
+ */
+ void GeneratePLCF( SvStream* pSt, long nPN, long ncpN );
+
+public:
+ WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos = -1 );
+
+ /*
+ folgender Ctor generiert ggfs. einen PLC aus nPN und ncpN
+ */
+ WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos, long nPN, long ncpN );
+
+ ~WW8PLCF(){ delete( pPLCF_PosArray ); pPLCF_PosArray = 0; }
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI ) { nIdx = (long)nI; }
+ long GetIMax(){ return nIMax; }
+ BOOL SeekPos( long nPos );
+ long Where();
+ BOOL Get( long& rStart, long& rEnd, void*& rpValue );
+ WW8PLCF& operator ++( int ) { if( nIdx < nIMax ) nIdx++; return *this; }
+
+ const void* GetData( long nIdx ) const {
+ return ( nIdx >= nIMax ) ? 0 : (const void*)&pPLCF_Contents[nIdx * nStru]; }
+};
+
+/*
+ fuer Piece Table (bei Schnellspeicherung)
+*/
+class WW8PLCFpcd
+{
+friend class WW8PLCFpcd_Iter;
+ INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
+ char* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array
+ long nIMax;
+ long nStru;
+
+public:
+ WW8PLCFpcd( SvStream* pSt, long nFilePos, long nPLCF, long nStruct );
+ ~WW8PLCFpcd(){ delete( pPLCF_PosArray ); }
+};
+
+/*
+ mehrere WW8PLCFpcd_Iter koennen auf die gleiche WW8PLCFpcd zeigen !!!
+*/
+class WW8PLCFpcd_Iter
+{
+ WW8PLCFpcd& rPLCF;
+ long nIdx;
+
+public:
+ WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, long nStartPos = -1 );
+// ~WW8PLCFpcd_Iter() {}
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI ) { nIdx = (long)nI; }
+ long GetIMax(){ return rPLCF.nIMax; }
+ BOOL SeekPos( long nPos );
+// BOOL SeekMaxMainFC( WW8Fib& rWwF, long& rMaxPosData );
+ long Where();
+ BOOL Get( long& rStart, long& rEnd, void*& rpValue );
+ WW8PLCFpcd_Iter& operator ++( int ) { if( nIdx < rPLCF.nIMax ) nIdx++; return *this; }
+};
+
+// PLCF-Typ:
+enum ePLCFT{ CHP=0, PAP, SEP, /*HED, FNR, ENR,*/ PLCF_END };
+
+/*
+ pure virtual:
+*/
+class WW8PLCFx // virtueller Iterator fuer Piece Table Exceptions
+{
+ BYTE nVersion; // Versionsnummer des FIB
+ BOOL bIsSprm; // PLCF von Sprms oder von anderem ( Footnote, ... )
+
+public:
+ WW8PLCFx( BYTE nFibVersion, BOOL bSprm )
+ { bIsSprm = bSprm; nVersion = nFibVersion; }
+
+// virtual ~WW8PLCFx() {}
+ BOOL IsSprm() { return bIsSprm; }
+ virtual ULONG GetIdx() = 0;
+ virtual void SetIdx( ULONG nIdx ) = 0;
+ virtual ULONG GetIdx2();
+ virtual void SetIdx2( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos ) = 0;
+ virtual long Where() = 0;
+// virtual BYTE* GetSprms( long& rStart, long& rEnd, long& rLen );
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int ) = 0;
+ virtual USHORT GetIstd() const { return 0xffff; }
+ BYTE GetVersion() const { return nVersion; }
+};
+
+enum eCutT { CUT_NONE = 0, CUT_START, CUT_END, CUT_BOTH };
+
+class WW8PLCFx_PCDAttrs : public WW8PLCFx
+{
+ WW8PLCFpcd_Iter* pPcdI;
+ WW8PLCFx_PCD* pPcd;
+ char** pGrpprls; // Attribute an Piece-Table
+ SVBT32 aShortSprm; // mini storage: can contain ONE sprm with
+ // 1 byte param
+ UINT16 nGrpprls; // Attribut Anzahl davon
+
+public:
+ WW8PLCFx_PCDAttrs( BYTE nVersion, WW8PLCFx_PCD* pPLCFx_PCD, WW8ScannerBase* pBase );
+ virtual ~WW8PLCFx_PCDAttrs();
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nI );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual WW8PLCFx& operator ++( int );
+
+ WW8PLCFpcd_Iter* GetIter() const { return pPcdI; }
+};
+
+class WW8PLCFx_PCD : public WW8PLCFx // Iterator fuer Piece Table
+{
+ WW8PLCFpcd_Iter* pPcdI;
+ BOOL bVer67;
+
+public:
+ WW8PLCFx_PCD( BYTE nVersion, WW8PLCFpcd* pPLCFpcd, WW8_CP nStartCp, BOOL bVer67P );
+ virtual ~WW8PLCFx_PCD();
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nI );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+// virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ WW8_CP AktPieceStartFc2Cp( WW8_FC nStartPos );
+ WW8_FC AktPieceStartCp2Fc( WW8_CP nCp );
+ eCutT AktPieceFc2Cp( long& rStartPos, long& rEndPos );
+ WW8PLCFpcd_Iter* GetPLCFIter() { return pPcdI; }
+
+ static INT32 TransformPieceAddress(long nfc, BOOL& bIsUnicodeAddress)
+ {
+ bIsUnicodeAddress = 0 == (0x40000000 & nfc);
+ return bIsUnicodeAddress
+ ? nfc
+ : (nfc & 0x3fffFFFF) / 2;
+ }
+ BOOL IsVersion67() const { return bVer67; }
+};
+
+
+class WW8PLCFx_Fc_FKP : public WW8PLCFx // Iterator fuer Piece Table Exceptions of Fkps
+ // arbeitet nur auf FCs, nicht auf CPs !
+ // ( Low-Level )
+{
+
+
+ class WW8Fkp // Iterator fuer Formatted Disk Page
+ {
+ struct WW8Grpprl
+ {
+ BYTE* pData;
+ USHORT nLen;
+ USHORT nIStd; // nur bei Fkp.Papx gueltig (aktuelle Style-Nr)
+ BOOL bMustDelete;
+ };
+
+ WW8Grpprl* pGrpprl; // Pointer of Meta Array (pointing
+
+ BYTE* pFkp; // gesamter Fkp
+
+ long nItemSize; // entweder 1 Byte oder ein komplettes BX
+ short nIdx; // Pos-Merker
+ ePLCFT ePLCF;
+ char nIMax; // Anzahl der Eintraege
+ BYTE nVersion;
+
+ public:
+ WW8Fkp( BYTE nFibVer, SvStream* pFKPStrm, SvStream* pDataStrm,
+ long nFilePos, long nItemSiz,
+ ePLCFT ePl, WW8_FC nStartFc = -1 );
+ ~WW8Fkp();
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI );
+ BOOL SeekPos( long nPos );
+ WW8_FC Where() { return ( nIdx<nIMax)
+ ? ((WW8_FC*)pFkp)[nIdx]
+ : LONG_MAX; }
+ WW8Fkp& operator ++( int ) { if( nIdx < nIMax ) nIdx++;
+ return *this; }
+ BYTE* Get( WW8_FC& rStart, WW8_FC& rEnd, short& rLen );
+ USHORT GetIstd() const { return pGrpprl[ nIdx ].nIStd; }
+
+ /*
+ liefert einen echten Pointer auf das Sprm vom Typ nId,
+ falls ein solches im Fkp drin ist.
+ */
+ BYTE* GetLenAndIStdAndSprms(short& rLen);
+
+ /*
+ ruft GetLenAndIStdAndSprms() auf...
+ */
+ BYTE* HasSprm( USHORT nId );
+
+ ULONG GetParaHeight() const; // fuer Header/Footer bei Papx-Fkps
+
+ BYTE GetVersion() const { return nVersion; }
+ };
+
+
+ WW8PLCFx_PCDAttrs* pPCDAttrs;
+ SvStream* pFKPStrm; // Input-File
+ SvStream* pDataStrm; // Input-File
+ WW8PLCF* pPLCF;
+ WW8Fkp* pFkp;
+ WW8_FC nStartFc;
+
+ BOOL NewFkp();
+
+protected:
+ ePLCFT ePLCF;
+
+public:
+ WW8PLCFx_Fc_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ WW8Fib& rFib, ePLCFT ePl, WW8_FC nStartFcL,
+ WW8PLCFx_PCDAttrs* pPLCFx_PCD );
+ virtual ~WW8PLCFx_Fc_FKP();
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_FC nFcPos );
+ virtual WW8_FC Where();
+ BYTE* GetSprms( WW8_FC& rStart, WW8_FC& rEnd, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ virtual USHORT GetIstd() const;
+ void GetPCDSprms( WW8PLCFxDesc& rDesc );
+ BYTE* HasSprm( USHORT nId );
+ ULONG GetParaHeight() const;
+};
+
+// Iterator fuer Piece Table Exceptions of Fkps arbeitet auf CPs (High-Level)
+class WW8PLCFx_Cp_FKP : public WW8PLCFx_Fc_FKP
+{
+ const WW8ScannerBase& rSBase;
+ WW8PLCFx_PCD* pPcd;
+ WW8_CP nAttrStart, nAttrEnd;
+ BOOL bLineEnd : 1;
+ BOOL bComplex : 1;
+
+ void SearchParaEnd( long nOldEndCp );
+
+public:
+ WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt, const WW8ScannerBase&
+ rBase, ePLCFT ePl );
+ virtual ~WW8PLCFx_Cp_FKP();
+ void ResetAttrStartEnd();
+ ULONG GetIdx2();
+ void SetIdx2( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual WW8_CP Where();
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual WW8PLCFx& operator ++( int );
+};
+
+
+
+class WW8PLCFx_SEPX : public WW8PLCFx // Iterator fuer Piece Table Exceptions of Sepx
+{
+ SvStream* pStrm;
+ WW8PLCF* pPLCF;
+ BYTE* pSprms;
+ USHORT nArrMax;
+ UINT16 nSprmSiz;
+
+public:
+ WW8PLCFx_SEPX( SvStream* pSt, SvStream* pTblxySt, WW8Fib& rFib, WW8_CP nStartCp );
+ virtual ~WW8PLCFx_SEPX();
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nIdx );
+ long GetIMax() const { return ( pPLCF ) ? pPLCF->GetIMax() : 0; }
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual WW8PLCFx& operator ++( int );
+ BYTE* HasSprm( USHORT nId ) const;
+ BYTE* HasSprm( USHORT nId, BYTE n2nd ) const;
+ BYTE* HasSprm( USHORT nId, BYTE* pOtherSprms, long nOtherSprmSiz ) const;
+ BOOL Find4Sprms(USHORT nId1, USHORT nId2, USHORT nId3, USHORT nId4,
+ BYTE*& p1, BYTE*& p2, BYTE*& p3, BYTE*& p4 ) const;
+ BOOL CompareSprms( BYTE* pOtherSprms,
+ long nOtherSprmSiz,
+ const SvUShortsSort* pIgnoreSprms = 0 ) const;
+};
+
+// Iterator fuer Fuss-/Endnoten und Anmerkungen
+class WW8PLCFx_SubDoc : public WW8PLCFx
+{
+ WW8PLCF* pRef;
+ WW8PLCF* pTxt;
+
+public:
+ WW8PLCFx_SubDoc( SvStream* pSt, BYTE nVersion, WW8_CP nStartCp,
+ long nFcRef, long nLenRef,
+ long nFcTxt, long nLenTxt, long nStruc = 0 );
+ virtual ~WW8PLCFx_SubDoc();
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+
+ // liefert Reference Descriptoren
+ const void* GetData( long nIdx = -1 ) const
+ {
+ return pRef ? pRef->GetData( -1L == nIdx ? pRef->GetIdx()
+ : nIdx ) : 0;
+ }
+
+ /*
+ liefert Angabe, wo Kopf und Fusszeilen-Text zu finden ist
+ */
+ BOOL Get( long& rStart, void*& rpValue );
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ long Count() { return ( pRef ) ? pRef->GetIMax() : 0; }
+};
+
+class WW8PLCFx_FLD : public WW8PLCFx // Iterator fuer Fuss- und Endnoten
+{
+ WW8PLCFspecial* pPLCF;
+ WW8Fib& rFib;
+
+public:
+ WW8PLCFx_FLD( SvStream* pSt, WW8Fib& rMyFib, short nType, WW8_CP nStartCp );
+ virtual ~WW8PLCFx_FLD();
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ BOOL GetPara( long nIdx, WW8FieldDesc& rF );
+};
+
+enum eBookStatus { BOOK_NORMAL = 0, BOOK_IGNORE = 0x1, BOOK_ONLY_REF = 0x2 };
+
+class WW8PLCFx_Book : public WW8PLCFx // Iterator fuer Booknotes
+{
+ WW8PLCFspecial* pBook[2]; // Start- und EndPosition
+ char** pBookNames; // Name
+ eBookStatus* pStatus;
+ long nIMax; // Anzahl der Booknotes
+ USHORT nIsEnd;
+public:
+ WW8PLCFx_Book( SvStream* pSt, SvStream* pTblSt, WW8Fib& rFib, WW8_CP nStartCp );
+ virtual ~WW8PLCFx_Book();
+ long GetIMax(){ return nIMax; }
+ virtual ULONG GetIdx();
+ virtual void SetIdx( ULONG nI );
+ virtual ULONG GetIdx2();
+ virtual void SetIdx2( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual long GetNoSprms( long& rStart, long& rEnd, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ const char* GetName() const
+ { return ( !nIsEnd && ( (long)(pBook[0]->GetIdx()) < nIMax ) )
+ ? pBookNames[pBook[0]->GetIdx()] : 0; }
+ WW8_CP GetStartPos() const
+ { return ( nIsEnd ) ? LONG_MAX : pBook[0]->Where(); }
+ long GetLen() const;
+ BOOL GetIsEnd() const { return ( nIsEnd ) ? TRUE : FALSE; }
+ long GetHandle() const;
+ BOOL SetStatus( WW8_CP nStartRegion, WW8_CP nEndRegion, char* pName,
+ eBookStatus eStat );
+ eBookStatus GetStatus() const;
+};
+
+/*
+ hiermit arbeiten wir draussen:
+*/
+struct WW8PLCFManResult
+{
+ WW8_CP nCpPos; // Attribut-Anfangsposition
+ long nMemLen; // Laenge dazu
+ long nCp2OrIdx; // footnote-textpos oder Index in PLCF
+ WW8_CP nAktCp; // wird nur vom Aufrufer benutzt
+ BYTE* pMemPos; // Mem-Pos fuer Sprms
+ USHORT nSprmId; // Sprm-Id ( 0 = ungueltige Id -> ueberspringen! )
+ // (2..255) oder Pseudo-Sprm-Id (256..260)
+ // bzw. ab Winword-Ver8 die Sprm-Id (800..)
+ BYTE nFlags; // Absatz- oder Section-Anfang
+};
+
+/*
+ hiermit arbeitet der Manager drinnen:
+*/
+struct WW8PLCFxDesc
+{
+ WW8PLCFx* pPLCFx;
+ UShortStk* pIdStk;// Speicher fuer Attr-Id fuer Attr-Ende(n)
+ BYTE* pMemPos; // wo liegen die Sprm(s)
+ long nStartPos;
+ long nEndPos;
+ long nCp2OrIdx; // wo liegen die NoSprm(s)
+ long nSprmsLen; // wie viele Bytes fuer weitere Sprms / Laenge Fussnote
+ long nCpOfs; // fuer Offset Header .. Footnote
+ BOOL bFirstSprm; // fuer Erkennung erster Sprm einer Gruppe
+ BOOL bRealLineEnd; // FALSE bei Pap-Piece-Ende
+};
+
+
+#define MAN_ANZ_PLCF 12
+
+struct WW8PLCFxSave1
+{
+ ULONG nPLCFxPos;
+ ULONG nPLCFxPos2; // fuer PLCF_Cp_Fkp: PieceIter-Pos
+ long nPLCFxMemOfs;
+};
+
+struct WW8PLCFxSaveAll
+{
+ WW8PLCFxSave1 aS[MAN_ANZ_PLCF];
+};
+
+#define MAN_MASK_NEW_PAP 1 // neue Zeile
+#define MAN_MASK_NEW_SEP 2 // neue Section
+
+
+#define MAN_MAINTEXT 0 // Defines fuer PLCFMan-ctor
+#define MAN_FTN 1
+#define MAN_EDN 2
+#define MAN_HDFT 3
+#define MAN_AND 4
+#define MAN_TXBX 5
+#define MAN_TXBX_HDFT 6
+
+#ifndef DUMP
+
+class WW8PLCFMan
+{
+ WW8PLCFxDesc aD[MAN_ANZ_PLCF];
+ WW8PLCFxDesc *pChp, *pPap, *pSep, *pFld, *pFldTxbx, *pFldTxbxHdft,
+ *pFtn, *pEdn,
+ *pBkm, *pPcd, *pPcdA, *pAnd;
+ WW8PLCFspecial *pFdoa, *pTxbx, *pTxbxBkd;
+
+ WW8Fib* pWwFib;
+ long nLineEnd; // zeigt *hinter* das <CR>
+
+ USHORT nPLCF; // so viele PLCFe werden verwaltet
+ short nManType;
+
+ short WhereIdx( BOOL* pbStart, long* pPos );
+ void AdjustEnds( WW8PLCFxDesc& rDesc );
+ void GetNewSprms( WW8PLCFxDesc& rDesc );
+ void GetNewNoSprms( WW8PLCFxDesc& rDesc );
+ void GetSprmStart( short nIdx, WW8PLCFManResult* pRes );
+ void GetSprmEnd( short nIdx, WW8PLCFManResult* pRes );
+ void GetNoSprmStart( short nIdx, WW8PLCFManResult* pRes );
+ void GetNoSprmEnd( short nIdx, WW8PLCFManResult* pRes );
+ void AdvSprm( short nIdx, BOOL bStart );
+ void AdvNoSprm( short nIdx, BOOL bStart );
+
+public:
+ WW8PLCFMan( WW8ScannerBase* pBase, short nType, long nStartCp );
+ ~WW8PLCFMan();
+
+ /*
+ Where fragt, an welcher naechsten Position sich irgendein
+ Attr aendert...
+ */
+ long Where();
+
+ BOOL Get( WW8PLCFManResult* pResult );
+ WW8PLCFMan& operator ++( int );
+ USHORT GetColl() const; // liefert aktuellen Style
+ WW8PLCFx_FLD* GetFld() const;
+ WW8PLCFx_SubDoc* GetEdn() const { return (WW8PLCFx_SubDoc*)pEdn->pPLCFx; }
+ WW8PLCFx_SubDoc* GetFtn() const { return (WW8PLCFx_SubDoc*)pFtn->pPLCFx; }
+ WW8PLCFx_SubDoc* GetAtn() const { return (WW8PLCFx_SubDoc*)pAnd->pPLCFx; }
+ WW8PLCFx_Book* GetBook() const { return (WW8PLCFx_Book*)pBkm->pPLCFx; }
+ long GetCpOfs() const { return pChp->nCpOfs; } // fuer Header/Footer...
+
+ /*
+ fragt, ob *aktueller Absatz* einen Sprm diesen Typs hat
+ */
+ BYTE* HasParaSprm( USHORT nId ) const;
+
+ /*
+ fragt, ob *aktueller Textrun* einen Sprm diesen Typs hat
+ */
+ BYTE* HasCharSprm( USHORT nId ) const;
+
+ WW8PLCFx_Cp_FKP* GetChpPLCF(){ return (WW8PLCFx_Cp_FKP*)pChp->pPLCFx; }
+ WW8PLCFx_Cp_FKP* GetPapPLCF(){ return (WW8PLCFx_Cp_FKP*)pPap->pPLCFx; }
+ WW8PLCFx_SEPX* GetSepPLCF(){ return (WW8PLCFx_SEPX*)pSep->pPLCFx; }
+ WW8PLCFxDesc* GetPap(){ return pPap; }
+ void Save1PLCFx( WW8PLCFxDesc* p, WW8PLCFxSave1* pSave ) const;
+ void Restore1PLCFx( WW8PLCFxDesc* p, WW8PLCFxSave1* pSave );
+ void SaveAllPLCFx( WW8PLCFxSaveAll* pSave );
+ void RestoreAllPLCFx( WW8PLCFxSaveAll* pSave );
+ WW8PLCFspecial* GetFdoa() { return pFdoa; }
+ WW8PLCFspecial* GetTxbx() { return pTxbx; }
+ WW8PLCFspecial* GetTxbxBkd(){ return pTxbxBkd; }
+ short GetManType() { return nManType; }
+};
+
+#endif // !DUMP
+
+class WW8ScannerBase
+{
+friend WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs( BYTE nVersion, WW8PLCFx_PCD* pPLCFx_PCD, WW8ScannerBase* pBase );
+friend WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream*, SvStream*, SvStream*,
+ const WW8ScannerBase&, ePLCFT );
+
+#ifdef DUMP
+friend static void DumpPLCFText( WW8_FC nPos, long nLen, long nOfs, char* pName,
+ WW8ScannerBase* pBase );
+friend static void DumpFtnShort( short nId, long nPos, long nFieldLen );
+#else
+friend WW8PLCFMan::WW8PLCFMan( WW8ScannerBase*, short, long );
+friend class SwWw8ImplReader;
+#endif
+
+ WW8Fib* pWw8Fib;
+ WW8PLCFx_Cp_FKP* pChpPLCF; // Character-Attrs
+ WW8PLCFx_Cp_FKP* pPapPLCF; // Para-Attrs
+ WW8PLCFx_SEPX* pSepPLCF; // Section-Attrs
+ WW8PLCFx_SubDoc* pFtnPLCF; // Footnotes
+ WW8PLCFx_SubDoc* pEdnPLCF; // EndNotes
+ WW8PLCFx_SubDoc* pAndPLCF; // Anmerkungen
+ WW8PLCFx_FLD* pFldPLCF; // Fields in Main Text
+ WW8PLCFx_FLD* pFldHdFtPLCF; // Fields in Header / Footer
+ WW8PLCFx_FLD* pFldTxbxPLCF; // Fields in Textboxes in Main Text
+ WW8PLCFx_FLD* pFldTxbxHdFtPLCF; // Fields in Textboxes in Header / Footer
+ WW8PLCFx_FLD* pFldFtnPLCF; // Fields in Footnotes
+ WW8PLCFx_FLD* pFldEdnPLCF; // Fields in Endnotes
+ WW8PLCFx_FLD* pFldAndPLCF; // Fields in Anmerkungen
+ WW8PLCFspecial* pMainFdoa; // Graphic Primitives in Main Text
+ WW8PLCFspecial* pHdFtFdoa; // Graphic Primitives in Header / Footer
+ WW8PLCFspecial* pMainTxbx; // Textboxen in Main Text
+ WW8PLCFspecial* pMainTxbxBkd; // Break-Deskriptoren fuer diese
+ WW8PLCFspecial* pHdFtTxbx; // TextBoxen in Header / Footer
+ WW8PLCFspecial* pHdFtTxbxBkd; // Break-Deskriptoren fuer diese
+ WW8PLCFx_Book* pBook; // Bookmarks
+
+ WW8PLCFpcd* pPiecePLCF; // fuer FastSave ( Basis-PLCF ohne Iterator )
+ WW8PLCFpcd_Iter* pPieceIter; // fuer FastSave ( Iterator dazu )
+ WW8PLCFx_PCD* pPLCFx_PCD; // dito
+ WW8PLCFx_PCDAttrs* pPLCFx_PCDAttrs;
+ char** pPieceGrpprls; // Attribute an Piece-Table
+ UINT16 nPieceGrpprls; // Anzahl davon
+
+ WW8PLCFpcd* OpenPieceTable( SvStream* pStr, WW8Fib* pWwF );
+ void DeletePieceTable();
+
+public:
+ WW8ScannerBase( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ WW8Fib* pWwF );
+ ~WW8ScannerBase();
+ BOOL AreThereFootnotes() { return pFtnPLCF->Count() > 0; };
+ BOOL AreThereEndnotes() { return pEdnPLCF->Count() > 0; };
+ static DateTime WW8DTTM2DateTime(long lDTTM);
+
+ WW8_CP WW8Fc2Cp( WW8_FC nFcPos ) const ;
+ WW8_FC WW8Cp2Fc( WW8_CP nCpPos, BOOL* pIsUnicode = 0,
+ WW8_CP* pNextPieceCp = 0, BOOL* pTestFlag = 0 ) const;
+
+ USHORT WW8ReadString( SvStream& rStrm, String* pString,
+ WW8_CP nAktStartCp, long nTotalLen,
+ unsigned char** ppStr = 0 ) const;
+};
+
+
+
+
+class WW8Fib
+{
+public:
+ /*
+ von uns verlangte Programm-Version:
+ in Ctor wird geprueft, ob sie zu nFib passt
+ */
+ BYTE nVersion; // 6 steht fuer "WinWord 6 oder WinWord 95",
+ // 7 steht fuer "nur WinWord 95"
+ // 8 steht fuer "nur WinWord 97"
+ /*
+ Fehlerstatus
+ */
+ ULONG nFibError;
+ /*
+ vom Ctor aus dem FIB gelesene Daten
+ (entspricht nur ungefaehr der tatsaechlichen Struktur
+ des Winword-FIB)
+ */
+ UINT16 wIdent; // 0x0 int magic number
+ UINT16 nFib; // 0x2 FIB version written
+ UINT16 nProduct; // 0x4 product version written by
+ INT16 lid; // 0x6 language stamp---localized version;
+ WW8_PN pnNext; // 0x8
+
+ UINT16 fDot :1; // 0xa 0001
+ UINT16 fGlsy :1;
+ UINT16 fComplex :1; // 0004 when 1, file is in complex, fast-saved format.
+ UINT16 fHasPic :1; // 0008 file contains 1 or more pictures
+ UINT16 cQuickSaves :4; // 00F0 count of times file was quicksaved
+ UINT16 fEncrypted :1; //0100 1 if file is encrypted, 0 if not
+ UINT16 fWhichTblStm :1; //0200 When 0, this fib refers to the table stream
+ // named "0Table", when 1, this fib refers to the
+ // table stream named "1Table". Normally, a file
+ // will have only one table stream, but under unusual
+ // circumstances a file may have table streams with
+ // both names. In that case, this flag must be used
+ // to decide which table stream is valid.
+ // UINT16 u1 :2;
+ UINT16 fExtChar :1; // 1000 =1, when using extended character set in file
+ // UINT16 u2 :3;
+
+ UINT16 nFibBack; // 0xc
+ INT16 lKey1; // 0xe file encrypted key, only valid if fEncrypted.
+ INT16 lKey2; // 0x10 key in 2 Portionen wg. Misalignment
+ UINT8 envr; // 0x12 environment in which file was created
+ // 0 created by Win Word / 1 created by Mac Word
+ BYTE fMac :1; // 0x13 when 1, this file was last saved in the Mac environment
+ BYTE fEmptySpecial :1;
+ BYTE fLoadOverridePage :1;
+ BYTE fFuturesavedUndo :1;
+ BYTE fWord97Saved :1;
+ BYTE :3;
+
+ UINT16 chse; // 0x14 default extended character set id for text in document stream. (overidden by chp.chse)
+ // 0 = ANSI / 256 Macintosh character set.
+ UINT16 chseTables; // 0x16 default extended character set id for text in
+ // internal data structures: 0 = ANSI, 256 = Macintosh
+ WW8_FC fcMin; // 0x18 file offset of first character of text
+ WW8_FC fcMac; // 0x1c file offset of last character of text + 1
+
+ // Einschub fuer WW8 *****************************************************
+ UINT16 csw; // Count of fields in the array of "shorts"
+
+ // Marke: "rgsw" Beginning of the array of shorts
+ UINT16 wMagicCreated; // unique number Identifying the File's creator
+ // 0x6A62 is the creator ID for Word and is reserved.
+ // Other creators should choose a different value.
+ UINT16 wMagicRevised; // identifies the File's last modifier
+ UINT16 wMagicCreatedPrivate; // private data
+ UINT16 wMagicRevisedPrivate; // private data
+ /*
+ INT16 pnFbpChpFirst_W6; // not used
+ INT16 pnChpFirst_W6; // not used
+ INT16 cpnBteChp_W6; // not used
+ INT16 pnFbpPapFirst_W6; // not used
+ INT16 pnPapFirst_W6; // not used
+ INT16 cpnBtePap_W6; // not used
+ INT16 pnFbpLvcFirst_W6; // not used
+ INT16 pnLvcFirst_W6; // not used
+ INT16 cpnBteLvc_W6; // not used
+ */
+ INT16 lidFE; // Language id if document was written by Far East version
+ // of Word (i.e. FIB.fFarEast is on)
+ UINT16 clw; // Number of fields in the array of longs
+
+ // Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rglw" Beginning of the array of longs
+ WW8_FC cbMac; // 0x20 file offset of last byte written to file + 1.
+
+ // WW8_FC u4[4]; // 0x24
+ WW8_CP ccpText; // 0x34 length of main document text stream
+ WW8_CP ccpFtn; // 0x38 length of footnote subdocument text stream
+ WW8_CP ccpHdr; // 0x3c length of header subdocument text stream
+ WW8_CP ccpMcr; // 0x40 length of macro subdocument text stream
+ WW8_CP ccpAtn; // 0x44 length of annotation subdocument text stream
+ WW8_CP ccpEdn; // 0x48 length of endnote subdocument text stream
+ WW8_CP ccpTxbx; // 0x4c length of textbox subdocument text stream
+ WW8_CP ccpHdrTxbx; // 0x50 length of header textbox subdocument text stream
+
+ // Einschub fuer WW8 *****************************************************
+ INT32 pnFbpChpFirst; // when there was insufficient memory for Word to expand
+ // the PLCFbte at save time, the PLCFbte is written
+ // to the file in a linked list of 512-byte pieces
+ // starting with this pn.
+ /*
+ // folgende Felder existieren zwar so in der Datei,
+ // wir benutzen jedoch unten deklarierte General-Variablen
+ // fuer Ver67 und Ver8 gemeinsam.
+ INT32 pnChpFirst; // the page number of the lowest numbered page in the
+ // document that records CHPX FKP information
+ INT32 cpnBteChp; // count of CHPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbteChpx
+ // is less than this, the PLCFbteChpx is incomplete.
+ */
+ INT32 pnFbpPapFirst; // when there was insufficient memory for Word to expand
+ // the PLCFbte at save time, the PLCFbte is written to
+ // the file in a linked list of 512-byte pieces
+ // starting with this pn
+ /*
+ // folgende Felder existieren zwar so in der Datei,
+ // wir benutzen jedoch unten deklarierte General-Variablen
+ // fuer Ver67 und Ver8 gemeinsam.
+ INT32 pnPapFirst; // the page number of the lowest numbered page in the
+ // document that records PAPX FKP information
+ INT32 cpnBtePap; // count of PAPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbtePapx is
+ // less than this, the PLCFbtePapx is incomplete.
+ */
+ INT32 pnFbpLvcFirst; // when there was insufficient memory for Word to expand
+ // the PLCFbte at save time, the PLCFbte is written to
+ // the file in a linked list of 512-byte pieces
+ // starting with this pn
+ INT32 pnLvcFirst; // the page number of the lowest numbered page in the
+ // document that records LVC FKP information
+ INT32 cpnBteLvc; // count of LVC FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbtePapx is
+ // less than this, the PLCFbtePapx is incomplete.
+ INT32 fcIslandFirst; // ?
+ INT32 fcIslandLim; // ?
+ UINT16 cfclcb; // Number of fields in the array of FC/LCB pairs.
+
+ // Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
+ WW8_FC fcStshfOrig; // file offset of original allocation for STSH in table
+ // stream. During fast save Word will attempt to reuse
+ // this allocation if STSH is small enough to fit.
+ INT32 lcbStshfOrig; // 0x5c count of bytes of original STSH allocation
+ WW8_FC fcStshf; // 0x60 file offset of STSH in file.
+ INT32 lcbStshf; // 0x64 count of bytes of current STSH allocation
+ WW8_FC fcPlcffndRef; // 0x68 file offset of footnote reference PLCF.
+ INT32 lcbPlcffndRef; // 0x6c count of bytes of footnote reference PLCF
+ // == 0 if no footnotes defined in document.
+
+ WW8_FC fcPlcffndTxt; // 0x70 file offset of footnote text PLCF.
+ INT32 lcbPlcffndTxt; // 0x74 count of bytes of footnote text PLCF.
+ // == 0 if no footnotes defined in document
+
+ WW8_FC fcPlcfandRef; // 0x78 file offset of annotation reference PLCF.
+ INT32 lcbPlcfandRef; // 0x7c count of bytes of annotation reference PLCF.
+
+ WW8_FC fcPlcfandTxt; // 0x80 file offset of annotation text PLCF.
+ INT32 lcbPlcfandTxt; // 0x84 count of bytes of the annotation text PLCF
+
+ WW8_FC fcPlcfsed; // 8x88 file offset of section descriptor PLCF.
+ INT32 lcbPlcfsed; // 0x8c count of bytes of section descriptor PLCF.
+
+ WW8_FC fcPlcfpad; // 0x90 file offset of paragraph descriptor PLCF
+ INT32 lcbPlcfpad; // 0x94 count of bytes of paragraph descriptor PLCF.
+ // ==0 if file was never viewed in Outline view.
+ // Should not be written by third party creators
+
+ WW8_FC fcPlcfphe; // 0x98 file offset of PLCF of paragraph heights.
+ INT32 lcbPlcfphe; // 0x9c count of bytes of paragraph height PLCF.
+ // ==0 when file is non-complex.
+
+ WW8_FC fcSttbfglsy; // 0xa0 file offset of glossary string table.
+ INT32 lcbSttbfglsy; // 0xa4 count of bytes of glossary string table.
+ // == 0 for non-glossary documents.
+ // !=0 for glossary documents.
+
+ WW8_FC fcPlcfglsy; // 0xa8 file offset of glossary PLCF.
+ INT32 lcbPlcfglsy; // 0xac count of bytes of glossary PLCF.
+ // == 0 for non-glossary documents.
+ // !=0 for glossary documents.
+
+ WW8_FC fcPlcfhdd; // 0xb0 byte offset of header PLCF.
+ INT32 lcbPlcfhdd; // 0xb4 count of bytes of header PLCF.
+ // == 0 if document contains no headers
+
+ WW8_FC fcPlcfbteChpx; // 0xb8 file offset of character property bin table.PLCF.
+ INT32 lcbPlcfbteChpx;// 0xbc count of bytes of character property bin table PLCF.
+
+ WW8_FC fcPlcfbtePapx; // 0xc0 file offset of paragraph property bin table.PLCF.
+ INT32 lcbPlcfbtePapx;// 0xc4 count of bytes of paragraph property bin table PLCF.
+
+ WW8_FC fcPlcfsea; // 0xc8 file offset of PLCF reserved for private use. The SEA is 6 bytes long.
+ INT32 lcbPlcfsea; // 0xcc count of bytes of private use PLCF.
+
+ WW8_FC fcSttbfffn; // 0xd0 file offset of font information STTBF. See the FFN file structure definition.
+ INT32 lcbSttbfffn; // 0xd4 count of bytes in sttbfffn.
+
+ WW8_FC fcPlcffldMom; // 0xd8 offset in doc stream to the PLCF of field positions in the main document.
+ INT32 lcbPlcffldMom; // 0xdc
+
+ WW8_FC fcPlcffldHdr; // 0xe0 offset in doc stream to the PLCF of field positions in the header subdocument.
+ INT32 lcbPlcffldHdr; // 0xe4
+
+ WW8_FC fcPlcffldFtn; // 0xe8 offset in doc stream to the PLCF of field positions in the footnote subdocument.
+ INT32 lcbPlcffldFtn; // 0xec
+
+ WW8_FC fcPlcffldAtn; // 0xf0 offset in doc stream to the PLCF of field positions in the annotation subdocument.
+ INT32 lcbPlcffldAtn; // 0xf4
+
+ WW8_FC fcPlcffldMcr; // 0xf8 offset in doc stream to the PLCF of field positions in the macro subdocument.
+ INT32 lcbPlcffldMcr; // 9xfc
+
+ WW8_FC fcSttbfbkmk; // 0x100 offset in document stream of the STTBF that records bookmark names in the main document
+ INT32 lcbSttbfbkmk; // 0x104
+
+ WW8_FC fcPlcfbkf; // 0x108 offset in document stream of the PLCF that records the beginning CP offsets of bookmarks in the main document. See BKF
+ INT32 lcbPlcfbkf; // 0x10c
+
+ WW8_FC fcPlcfbkl; // 0x110 offset in document stream of the PLCF that records the ending CP offsets of bookmarks recorded in the main document. See the BKL structure definition.
+ INT32 lcbPlcfbkl; // 0x114 INT32
+
+ WW8_FC fcCmds; // 0x118 FC
+ INT32 lcbCmds; // 0x11c
+
+ WW8_FC fcPlcfmcr; // 0x120 FC
+ INT32 lcbPlcfmcr; // 0x124
+
+ WW8_FC fcSttbfmcr; // 0x128 FC
+ INT32 lcbSttbfmcr; // 0x12c
+
+ WW8_FC fcPrDrvr; // 0x130 file offset of the printer driver information (names of drivers, port etc...)
+ INT32 lcbPrDrvr; // 0x134 count of bytes of the printer driver information (names of drivers, port etc...)
+
+ WW8_FC fcPrEnvPort; // 0x138 file offset of the print environment in portrait mode.
+ INT32 lcbPrEnvPort; // 0x13c count of bytes of the print environment in portrait mode.
+
+ WW8_FC fcPrEnvLand; // 0x140 file offset of the print environment in landscape mode.
+ INT32 lcbPrEnvLand; // 0x144 count of bytes of the print environment in landscape mode.
+
+ WW8_FC fcWss; // 0x148 file offset of Window Save State data structure. See WSS.
+ INT32 lcbWss; // 0x14c count of bytes of WSS. ==0 if unable to store the window state.
+
+ WW8_FC fcDop; // 0x150 file offset of document property data structure.
+ INT32 lcbDop; // 0x154 count of bytes of document properties.
+ // cbDOP is 84 when nFib < 103
+
+
+ WW8_FC fcSttbfAssoc; // 0x158 offset to STTBF of associated strings. See STTBFASSOC.
+ INT32 cbSttbfAssoc; // 0x15C
+
+ WW8_FC fcClx; // 0x160 file offset of beginning of information for complex files.
+ INT32 lcbClx; // 0x164 count of bytes of complex file information. 0 if file is non-complex.
+
+ WW8_FC fcPlcfpgdFtn; // 0x168 file offset of page descriptor PLCF for footnote subdocument.
+ INT32 lcbPlcfpgdFtn; // 0x16C count of bytes of page descriptor PLCF for footnote subdocument.
+ // ==0 if document has not been paginated. The length of the PGD is 8 bytes.
+
+ WW8_FC fcAutosaveSource; // 0x170 file offset of the name of the original file.
+ INT32 lcbAutosaveSource; // 0x174 count of bytes of the name of the original file.
+
+ WW8_FC fcGrpStAtnOwners; // 0x178 group of strings recording the names of the owners of annotations
+ INT32 lcbGrpStAtnOwners; // 0x17C count of bytes of the group of strings
+
+ WW8_FC fcSttbfAtnbkmk; // 0x180 file offset of the sttbf that records names of bookmarks in the annotation subdocument
+ INT32 lcbSttbfAtnbkmk; // 0x184 length in bytes of the sttbf that records names of bookmarks in the annotation subdocument
+
+ // Einschubs fuer WW67 ***************************************************
+
+ // INT16 wSpare4Fib; // Reserve, muss hier nicht deklariert werden
+
+ /*
+ // folgende Felder existieren zwar so in der Datei,
+ // wir benutzen jedoch unten deklarierte General-Variablen
+ // fuer Ver67 und Ver8 gemeinsam.
+ WW8_PN pnChpFirst; // the page number of the lowest numbered page in
+ // the document that records CHPX FKP information
+ WW8_PN pnPapFirst; // the page number of the lowest numbered page in
+ // the document that records PAPX FKP information
+
+ WW8_PN cpnBteChp; // count of CHPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbteChpx is
+ // less than this, the PLCFbteChpx is incomplete.
+ WW8_PN cpnBtePap; // count of PAPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbtePapx is
+ // less than this, the PLCFbtePapx is incomplete.
+ */
+
+ // Ende des Einschubs fuer WW67 ******************************************
+
+ WW8_FC fcPlcfdoaMom; // 0x192 file offset of the FDOA (drawn object) PLCF for main document.
+ // ==0 if document has no drawn objects. The length of the FDOA is 6 bytes.
+ // ab Ver8 unused
+ INT32 lcbPlcfdoaMom; // 0x196 length in bytes of the FDOA PLCF of the main document
+ // ab Ver8 unused
+ WW8_FC fcPlcfdoaHdr; // 0x19A file offset of the FDOA (drawn object) PLCF for the header document.
+ // ==0 if document has no drawn objects. The length of the FDOA is 6 bytes.
+ // ab Ver8 unused
+ INT32 lcbPlcfdoaHdr; // 0x19E length in bytes of the FDOA PLCF of the header document
+ // ab Ver8 unused
+
+ WW8_FC fcPlcfspaMom; // offset in table stream of the FSPA PLCF for main document.
+ // == 0 if document has no office art objects
+ // war in Ver67 nur leere Reserve
+ INT32 lcbPlcfspaMom; // length in bytes of the FSPA PLCF of the main document
+ // war in Ver67 nur leere Reserve
+ WW8_FC fcPlcfspaHdr; // offset in table stream of the FSPA PLCF for header document.
+ // == 0 if document has no office art objects
+ // war in Ver67 nur leere Reserve
+ INT32 lcbPlcfspaHdr; // length in bytes of the FSPA PLCF of the header document
+ // war in Ver67 nur leere Reserve
+
+ WW8_FC fcPlcfAtnbkf; // 0x1B2 file offset of BKF (bookmark first) PLCF of the annotation subdocument
+ INT32 lcbPlcfAtnbkf; // 0x1B6 length in bytes of BKF (bookmark first) PLCF of the annotation subdocument
+
+ WW8_FC fcPlcfAtnbkl; // 0x1BA file offset of BKL (bookmark last) PLCF of the annotation subdocument
+ INT32 lcbPlcfAtnbkl; // 0x1BE length in bytes of BKL (bookmark first) PLCF of the annotation subdocument
+
+ WW8_FC fcPms; // 0x1C2 file offset of PMS (Print Merge State) information block
+ INT32 lcbPMS; // 0x1C6 length in bytes of PMS
+
+ WW8_FC fcFormFldSttbf; // 0x1CA file offset of form field Sttbf which contains strings used in form field dropdown controls
+ INT32 lcbFormFldSttbf; // 0x1CE length in bytes of form field Sttbf
+
+ WW8_FC fcPlcfendRef; // 0x1D2 file offset of PLCFendRef which points to endnote references in the main document stream
+ INT32 lcbPlcfendRef; // 0x1D6
+
+ WW8_FC fcPlcfendTxt; // 0x1DA file offset of PLCFendRef which points to endnote text in the endnote document
+ // stream which corresponds with the PLCFendRef
+ INT32 lcbPlcfendTxt; // 0x1DE
+
+ WW8_FC fcPlcffldEdn; // 0x1E2 offset to PLCF of field positions in the endnote subdoc
+ INT32 lcbPlcffldEdn; // 0x1E6
+
+ WW8_FC fcPlcfpgdEdn; // 0x1EA offset to PLCF of page boundaries in the endnote subdoc.
+ INT32 lcbPlcfpgdEdn; // 0x1EE
+
+
+ WW8_FC fcDggInfo; // offset in table stream of the office art object table data.
+ // The format of office art object table data is found in a separate document.
+ // war in Ver67 nur leere Reserve
+ INT32 lcbDggInfo; // length in bytes of the office art object table data
+ // war in Ver67 nur leere Reserve
+
+ WW8_FC fcSttbfRMark; // 0x1fa offset to STTBF that records the author abbreviations...
+ INT32 lcbSttbfRMark; // 0x1fe
+ WW8_FC fcSttbfCaption; // 0x202 offset to STTBF that records caption titles...
+ INT32 lcbSttbfCaption; // 0x206
+ WW8_FC fcSttbAutoCaption; // offset in table stream to the STTBF that records the object names and
+ // indices into the caption STTBF for objects which get auto captions.
+ INT32 lcbSttbAutoCaption; // 0x20e
+
+ WW8_FC fcPlcfwkb; // 0x212 offset to PLCF that describes the boundaries of contributing documents...
+ INT32 lcbPlcfwkb; // 0x216
+
+ WW8_FC fcPlcfspl; // offset in table stream of PLCF (of SPLS structures) that records spell check state
+ // war in Ver67 nur leere Reserve
+ INT32 lcbPlcfspl; // war in Ver67 nur leere Reserve
+
+ WW8_FC fcPlcftxbxTxt; // 0x222 ...PLCF of beginning CP in the text box subdoc
+ INT32 lcbPlcftxbxTxt; // 0x226
+ WW8_FC fcPlcffldTxbx; // 0x22a ...PLCF of field boundaries recorded in the textbox subdoc.
+ INT32 lcbPlcffldTxbx; // 0x22e
+ WW8_FC fcPlcfHdrtxbxTxt;// 0x232 ...PLCF of beginning CP in the header text box subdoc
+ INT32 lcbPlcfHdrtxbxTxt;// 0x236
+ WW8_FC fcPlcffldHdrTxbx;// 0x23a ...PLCF of field boundaries recorded in the header textbox subdoc.
+ INT32 lcbPlcffldHdrTxbx;// 0x23e
+
+ /*
+ spezielle Listenverwaltung fuer WW8
+ */
+ WW8_FC fcPlcfLst; // 0x02e2 offset in the table stream of list format information.
+ INT32 lcbPlcfLst; // 0x02e6 length
+ WW8_FC fcPlfLfo; // 0x02ea offset in the table stream of list format override information.
+ INT32 lcbPlfLfo; // 0x02ee length
+ /*
+ spezielle Break-Verwaltung fuer Text-Box-Stories in WW8
+ */
+ WW8_FC fcPlcftxbxBkd; // 0x02f2 PLCF fuer TextBox-Break-Deskriptoren im Maintext
+ INT32 lcbPlcftxbxBkd; // 0x02f6
+ WW8_FC fcPlcfHdrtxbxBkd;// 0x02fa PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
+ INT32 lcbPlcfHdrtxbxBkd;// 0x02fe
+
+ // 0x302 - 372 == ignore
+ /*
+ ListNames (skip to here!)
+ */
+ WW8_FC fcSttbListNames;// 0x0372 PLCF for Listname Table
+ INT32 lcbSttbListNames;// 0x0376
+ /*
+ General-Varaiblen, die fuer Ver67 und Ver8 verwendet werden,
+ obwohl sie in der jeweiligen DATEI verschiedene Groesse haben:
+ */
+ INT32 pnChpFirst;
+ INT32 pnPapFirst;
+ INT32 cpnBteChp;
+ INT32 cpnBtePap;
+ /*
+ nun wird lediglich noch ein Ctor benoetigt
+ */
+ WW8Fib( SvStream& rStrm, BYTE nWantedVersion,UINT32 nOffset=0 );
+
+ /* leider falsch, man braucht auch noch einen fuer den Export */
+ WW8Fib( BYTE nVersion = 6 );
+ BOOL Write( SvStream& rStrm );
+};
+
+
+class WW8Style
+{
+protected:
+ WW8Fib& rFib;
+ SvStream& rSt;
+ long nStyleStart;
+ long nStyleLen;
+// WW8_STSHI* pStishi;
+
+ UINT16 cstd; // Count of styles in stylesheet
+ UINT16 cbSTDBaseInFile; // Length of STD Base as stored in a file
+ UINT16 fStdStylenamesWritten : 1; // Are built-in stylenames stored?
+ UINT16 : 15; // Spare flags
+ UINT16 stiMaxWhenSaved; // Max sti known when this file was written
+ UINT16 istdMaxFixedWhenSaved; // How many fixed-index istds are there?
+ UINT16 nVerBuiltInNamesWhenSaved; // Current version of built-in stylenames
+ UINT16 ftcStandardChpStsh; // ftc used by StandardChpStsh for this document
+
+public:
+ WW8Style( SvStream& rSt, WW8Fib& rFibPara );
+// ~WW8Style(){ delete( pStishi ); pStishi = 0; }
+ WW8_STD* Read1STDFixed( short& rSkip, short* pcbStd );
+ WW8_STD* Read1Style( short& rSkip, UINT8** ppStr = 0, short* pcbStd = 0 );
+ const UINT16 GetCount() const { return cstd; }
+};
+
+
+class WW8Fonts
+{
+protected:
+ WW8_FFN* pFontA; // Array of Pointers to Font Description
+ // Hilfs-Vari
+ USHORT nMax; // Array-Groesse
+public:
+ WW8Fonts( SvStream& rSt, WW8Fib& rFib );
+ ~WW8Fonts(){ if( pFontA ) __DELETE( nMax )pFontA; }
+ const WW8_FFN* GetFont( USHORT nNum ) const;
+ USHORT GetMax() const { return nMax; }
+};
+
+
+#define WW8_HEADER_EVEN 0x1
+#define WW8_HEADER_ODD 0x2
+#define WW8_FOOTER_EVEN 0x4
+#define WW8_FOOTER_ODD 0x8
+#define WW8_HEADER_FIRST 0x10
+#define WW8_FOOTER_FIRST 0x20
+
+class WW8Dop // Document Properties
+{
+public:
+ /*
+ Fehlerstatus
+ */
+ ULONG nDopError;
+ /*
+ vom Ctor aus dem FIB gelesene Daten
+ (entspricht nur ungefaehr der tatsaechlichen Struktur
+ des Winword-FIB)
+ */
+ // Initialisier-Dummy:
+ BYTE nDataStart;
+ //-------------------------
+ UINT16 fFacingPages : 1; // 1 when facing pages should be printed
+ UINT16 fWidowControl : 1; // 1 when widow control is in effect. 0 when widow control disabled.
+ UINT16 fPMHMainDoc : 1; // 1 when doc is a main doc for Print Merge Helper, 0 when not; default=0
+ UINT16 grfSuppression : 2; // 0 Default line suppression storage; 0= form letter line suppression; 1= no line suppression; default=0
+ UINT16 fpc : 2; // 1 footnote position code: 0 as endnotes, 1 at bottom of page, 2 immediately beneath text
+ UINT16 : 1; // 0 unused
+ //-------------------------
+ UINT16 grpfIhdt : 8; // 0 specification of document headers and footers. See explanation under Headers and Footers topic.
+ //-------------------------
+ UINT16 rncFtn : 2; // 0 restart index for footnotes, 0 don't restart note numbering, 1 section, 2 page
+ UINT16 nFtn : 14; // 1 initial footnote number for document
+ UINT16 fOutlineDirtySave : 1; // when 1, indicates that information in the hPLCFpad should be refreshed since outline has been dirtied
+ UINT16 : 7; // reserved
+ UINT16 fOnlyMacPics : 1; // when 1, Word believes all pictures recorded in the document were created on a Macintosh
+ UINT16 fOnlyWinPics : 1; // when 1, Word believes all pictures recorded in the document were created in Windows
+ UINT16 fLabelDoc : 1; // when 1, document was created as a print merge labels document
+ UINT16 fHyphCapitals : 1; // when 1, Word is allowed to hyphenate words that are capitalized. When 0, capitalized may not be hyphenated
+ UINT16 fAutoHyphen : 1; // when 1, Word will hyphenate newly typed text as a background task
+ UINT16 fFormNoFields : 1;
+ UINT16 fLinkStyles : 1; // when 1, Word will merge styles from its template
+ UINT16 fRevMarking : 1; // when 1, Word will mark revisions as the document is edited
+ UINT16 fBackup : 1; // always make backup when document saved when 1.
+ UINT16 fExactCWords : 1;
+ UINT16 fPagHidden : 1; //
+ UINT16 fPagResults : 1;
+ UINT16 fLockAtn : 1; // when 1, annotations are locked for editing
+ UINT16 fMirrorMargins : 1; // swap margins on left/right pages when 1.
+ UINT16 fReadOnlyRecommended : 1;// user has recommended that this doc be opened read-only when 1
+ UINT16 fDfltTrueType : 1; // when 1, use TrueType fonts by default (flag obeyed only when doc was created by WinWord 2.x)
+ UINT16 fPagSuppressTopSpacing : 1;//when 1, file created with SUPPRESSTOPSPACING=YES in win.ini. (flag obeyed only when doc was created by WinWord 2.x).
+ UINT16 fProtEnabled : 1; // when 1, document is protected from edit operations
+ UINT16 fDispFormFldSel : 1;// when 1, restrict selections to occur only within form fields
+ UINT16 fRMView : 1; // when 1, show revision markings on screen
+ UINT16 fRMPrint : 1; // when 1, print revision marks when document is printed
+ UINT16 fWriteReservation : 1;
+ UINT16 fLockRev : 1; // when 1, the current revision marking state is locked
+ UINT16 fEmbedFonts : 1; // when 1, document contains embedded True Type fonts
+ // compatability options
+ UINT16 copts_fNoTabForInd : 1; // when 1, don’t add automatic tab stops for hanging indent
+ UINT16 copts_fNoSpaceRaiseLower : 1; // when 1, don’t add extra space for raised or lowered characters
+ UINT16 copts_fSupressSpbfAfterPgBrk : 1; // when 1, supress the paragraph Space Before and Space After options after a page break
+ UINT16 copts_fWrapTrailSpaces : 1; // when 1, wrap trailing spaces at the end of a line to the next line
+ UINT16 copts_fMapPrintTextColor : 1; // when 1, print colors as black on non-color printers
+ UINT16 copts_fNoColumnBalance : 1; // when 1, don’t balance columns for Continuous Section starts
+ UINT16 copts_fConvMailMergeEsc : 1;
+ UINT16 copts_fSupressTopSpacing : 1; // when 1, supress extra line spacing at top of page
+ UINT16 copts_fOrigWordTableRules : 1; // when 1, combine table borders like Word 5.x for the Macintosh
+ UINT16 copts_fTransparentMetafiles : 1; // when 1, don’t blank area between metafile pictures
+ UINT16 copts_fShowBreaksInFrames : 1; // when 1, show hard page or column breaks in frames
+ UINT16 copts_fSwapBordersFacingPgs : 1; // when 1, swap left and right pages on odd facing pages
+
+ INT16 dxaTab; // 720 twips default tab width
+ UINT16 wSpare; //
+ UINT16 dxaHotZ; // width of hyphenation hot zone measured in twips
+ UINT16 cConsecHypLim; // number of lines allowed to have consecutive hyphens
+ UINT16 wSpare2; // reserved
+ INT32 dttmCreated; // DTTM date and time document was created
+ INT32 dttmRevised; // DTTM date and time document was last revised
+ INT32 dttmLastPrint; // DTTM date and time document was last printed
+ INT16 nRevision; // number of times document has been revised since its creation
+ INT32 tmEdited; // time document was last edited
+ INT32 cWords; // count of words tallied by last Word Count execution
+ INT32 cCh; // count of characters tallied by last Word Count execution
+ INT16 cPg; // count of pages tallied by last Word Count execution
+ INT32 cParas; // count of paragraphs tallied by last Word Count execution
+ UINT16 rncEdn : 2; // restart endnote number code: 0 don’t restart endnote numbering, 1 section, 2 page
+ UINT16 nEdn : 14; // beginning endnote number
+ UINT16 epc : 2; // endnote position code: 0 at end of section, 3 at end of document
+ // UINT16 nfcFtnRef : 4; // number format code for auto footnotes: 0 Arabic, 1 Upper case Roman, 2 Lower case Roman
+ // 3 Upper case Letter, 4 Lower case Letter
+ // ersetzt durch gleichlautendes Feld unten
+ // UINT16 nfcEdnRef : 4; // number format code for auto endnotes: 0 Arabic, 1 Upper case Roman, 2 Lower case Roman
+ // 3 Upper case Letter, 4 Lower case Letter
+ // ersetzt durch gleichlautendes Feld unten
+ UINT16 fPrintFormData : 1; // only print data inside of form fields
+ UINT16 fSaveFormData : 1; // only save document data that is inside of a form field.
+ UINT16 fShadeFormData : 1; // shade form fields
+ UINT16 : 2; // reserved
+ UINT16 fWCFtnEdn : 1; // when 1, include footnotes and endnotes in word count
+ INT32 cLines; // count of lines tallied by last Word Count operation
+ INT32 cWordsFtnEnd; // count of words in footnotes and endnotes tallied by last Word Count operation
+ INT32 cChFtnEdn; // count of characters in footnotes and endnotes tallied by last Word Count operation
+ INT16 cPgFtnEdn; // count of pages in footnotes and endnotes tallied by last Word Count operation
+ INT32 cParasFtnEdn; // count of paragraphs in footnotes and endnotes tallied by last Word Count operation
+ INT32 cLinesFtnEdn; // count of paragraphs in footnotes and endnotes tallied by last Word Count operation
+ INT32 lKeyProtDoc; // document protection password key, only valid if dop.fProtEnabled, dop.fLockAtn or dop.fLockRev are 1.
+ UINT16 wvkSaved : 3; // document view kind: 0 Normal view, 1 Outline view, 2 Page View
+ UINT16 wScaleSaved : 9; //
+ UINT16 zkSaved : 2;
+
+ // hier sollte bei nFib < 103 Schluss sein, sonst ist Datei fehlerhaft!
+
+ /*
+ bei nFib >= 103 gehts weiter:
+ */
+ UINT32 fNoTabForInd :1; // see above in compatability options
+ UINT32 fNoSpaceRaiseLower :1; // see above
+ UINT32 fSupressSpbfAfterPageBreak :1; // see above
+ UINT32 fWrapTrailSpaces :1; // see above
+ UINT32 fMapPrintTextColor :1; // see above
+ UINT32 fNoColumnBalance :1; // see above
+ UINT32 fConvMailMergeEsc :1; // see above
+ UINT32 fSupressTopSpacing :1; // see above
+ UINT32 fOrigWordTableRules :1; // see above
+ UINT32 fTransparentMetafiles :1; // see above
+ UINT32 fShowBreaksInFrames :1; // see above
+ UINT32 fSwapBordersFacingPgs :1; // see above
+ UINT32 :4; // reserved
+ UINT32 fSuppressTopSpacingMac5 :1; // Suppress extra line spacing at top
+ // of page like MacWord 5.x
+ UINT32 fTruncDxaExpand :1; // Expand/Condense by whole number of points
+ UINT32 fPrintBodyBeforeHdr :1; // Print body text before header/footer
+ UINT32 fNoLeading :1; // Don't add extra spacebetween rows of text
+ UINT32 :1; // reserved
+ UINT32 fMWSmallCaps :1; // Use larger small caps like MacWord 5.x
+ UINT32 :10;// reserved
+
+ // hier sollte bei nFib <= 105 Schluss sein, sonst ist Datei fehlerhaft!
+
+ /*
+ bei nFib > 105 gehts weiter:
+ */
+ INT16 adt; // Autoformat Document Type:
+ // 0 for normal. 1 for letter, and 2 for email.
+ WW8_DOPTYPOGRAPHY doptypography; // siehe WW8STRUC.HXX
+ WW8_DOGRID dogrid; // siehe WW8STRUC.HXX
+ UINT16 :1; // reserved
+ UINT16 lvl :4; // Which outline levels are showing in outline view
+ UINT16 :4; // reserved
+ UINT16 fHtmlDoc :1; // This file is based upon an HTML file
+ UINT16 :1; // reserved
+ UINT16 fSnapBorder :1; // Snap table and page borders to page border
+ UINT16 fIncludeHeader :1; // Place header inside page border
+ UINT16 fIncludeFooter :1; // Place footer inside page border
+ UINT16 fForcePageSizePag :1; // Are we in online view
+ UINT16 fMinFontSizePag :1; // Are we auto-promoting
+ // fonts to >= hpsZoonFontPag?
+ UINT16 fHaveVersions :1; // versioning is turned on
+ UINT16 fAutoVersion :1; // autoversioning is enabled
+ UINT16 :14; // reserved
+ // hier 12 Byte ueberspringen: ASUMI
+ INT32 cChWS;
+ INT32 cChWSFtnEdn;
+ INT32 grfDocEvents;
+ // hier 4+30+8 Bytes ueberspringen
+ INT32 cDBC;
+ INT32 cDBCFtnEdn;
+ // hier 4 Bytes ueberspringen
+ INT16 nfcFtnRef;
+ INT16 nfcEdnRef;
+ INT16 hpsZoonFontPag;
+ INT16 dywDispPag;
+
+ // 2. Initialisier-Dummy:
+ BYTE nDataEnd;
+
+ /*
+ nun wird lediglich noch ein Ctor benoetigt,
+ dem die FIB-Nummer uebergeben werden muss
+ */
+ WW8Dop( SvStream& rSt, INT16 nFib, INT32 nPos, INT32 nSize );
+
+ /* leider falsch, man braucht auch noch einen fuer den Export */
+ WW8Dop();
+ BOOL Write( SvStream& rStrm, WW8Fib& rFib );
+};
+
+
+inline short WW8SkipOdd(SvStream* pSt )
+{
+#if defined HP9000 || defined SINIX
+ short bRet = pSt->Tell() & 0x1;
+ if (bRet) {
+ UINT8 c;
+ pSt->Read( &c, 1 );
+ }
+ return bRet;
+#else
+ if ( pSt->Tell() & 0x1 ){
+ UINT8 c;
+ pSt->Read( &c, 1 );
+ return 1;
+ }
+ return 0;
+#endif
+}
+
+
+class WW8PLCF_HdFt
+{
+ WW8PLCF aPLCF;
+ long nTextOfs;
+ short nIdxOffset;
+
+public:
+ WW8PLCF_HdFt( SvStream* pSt, WW8Fib& rFib, WW8Dop& rDop );
+// ~WW8PLCF_HdFt() {}
+ BOOL GetTextPos( BYTE grpfIhdt, BYTE nWhich, WW8_CP& rStart, long& rLen );
+ BOOL GetTextPosExact( short nIdx, WW8_CP& rStart, long& rLen );
+ void UpdateIndex( BYTE grpfIhdt );
+};
+
+
+
+#endif
+
diff --git a/sw/source/filter/ww8/dump/ww8struc.hxx b/sw/source/filter/ww8/dump/ww8struc.hxx
new file mode 100644
index 000000000000..27f1d334af62
--- /dev/null
+++ b/sw/source/filter/ww8/dump/ww8struc.hxx
@@ -0,0 +1,851 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8struc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WW8STRUC_HXX
+#define _WW8STRUC_HXX
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+
+// max. Anzahl der Listen-Level in WW8: 1..9
+#define nWW8MaxListLevel 9
+
+
+inline BYTE Get_Byte( BYTE *& p )
+ { BYTE n = SVBT8ToByte( *(SVBT8*)p ); p += 1; return n; }
+
+inline short Get_Short( BYTE *& p )
+ { short n = SVBT16ToShort( *(SVBT16*)p ); p += 2; return n; }
+inline USHORT Get_UShort( BYTE *& p )
+ { USHORT n = SVBT16ToShort( *(SVBT16*)p ); p += 2; return n; }
+
+inline long Get_Long( BYTE *& p )
+ { long n = SVBT32ToLong( *(SVBT32*)p ); p += 4; return n; }
+inline ULONG Get_ULong( BYTE *& p )
+ { ULONG n = SVBT32ToLong( *(SVBT32*)p ); p += 4; return n; }
+
+inline void Set_UInt8( BYTE *& p, UINT8 n )
+ { ByteToSVBT8( n, *(SVBT8*)p ); p+= 1; }
+
+inline void Set_UInt16( BYTE *& p, UINT16 n )
+ { ShortToSVBT16( n, *(SVBT16*)p ); p+= 2; }
+
+inline void Set_UInt32( BYTE *& p, UINT32 n )
+ { LongToSVBT32( n, *(SVBT32*)p ); p+= 4; }
+
+
+#if defined __BIGENDIAN || __ALIGNMENT4 > 2 || defined UNX
+#define __WW8_NEEDS_COPY
+#else
+#if defined WNT || defined WIN || defined OS2
+#define __WW8_NEEDS_PACK
+#pragma pack(2)
+#endif
+#endif
+
+typedef INT16 WW8_PN;
+typedef INT32 WW8_FC;
+typedef INT32 WW8_CP;
+
+// STD: STyle Definition
+// The STD contains the entire definition of a style.
+// It has two parts, a fixed-length base (cbSTDBase bytes long)
+// and a variable length remainder holding the name, and the upx and upe
+// arrays (a upx and upe for each type stored in the style, std.cupx)
+// Note that new fields can be added to the BASE of the STD without
+// invalidating the file format, because the STSHI contains the length
+// that is stored in the file. When reading STDs from an older version,
+// new fields will be zero.
+struct WW8_STD
+{
+ // Base part of STD:
+ UINT16 sti : 12; // invariant style identifier
+ UINT16 fScratch : 1; // spare field for any temporary use,
+ // always reset back to zero!
+ UINT16 fInvalHeight : 1; // PHEs of all text with this style are wrong
+ UINT16 fHasUpe : 1; // UPEs have been generated
+ UINT16 fMassCopy : 1; // std has been mass-copied; if unused at
+ // save time, style should be deleted
+ UINT16 sgc : 4; // style type code
+ UINT16 istdBase : 12; // base style
+ UINT16 cupx : 4; // # of UPXs (and UPEs)
+ UINT16 istdNext : 12; // next style
+ UINT16 bchUpe; // offset to end of upx's, start of upe's
+ //-------- jetzt neu:
+ // ab Ver8 gibts zwei Felder mehr:
+ UINT16 fAutoRedef : 1; /* auto redefine style when appropriate */
+ UINT16 fHidden : 1; /* hidden from UI? */
+ UINT16 : 14; /* unused bits */
+
+ // Variable length part of STD:
+ // UINT8 stzName[2]; /* sub-names are separated by chDelimStyle
+ // char grupx[];
+ // the UPEs are not stored on the file; they are a cache of the based-on
+ // chain
+ // char grupe[];
+};
+
+/*
+ Basis zum Einlesen UND zum Arbeiten (wird jeweils unter
+ schiedlich beerbt)
+*/
+struct WW8_FFN_BASE // Font Descriptor
+{
+ // ab Ver6
+ BYTE cbFfnM1; // 0x0 total length of FFN - 1.
+
+ BYTE prg: 2; // 0x1:03 pitch request
+ BYTE fTrueType : 1; // 0x1:04 when 1, font is a TrueType font
+ // 0x1:08 reserved
+ BYTE ff : 3; // 0x1:70 font family id
+ // 0x1:80 reserved
+
+ short wWeight; // 0x2 base weight of font
+ BYTE chs; // 0x4 character set identifier
+ BYTE ibszAlt; // 0x5 index into ffn.szFfn to the name of the alternate font
+};
+
+/*
+ Hiermit arbeiten wir im Parser (und Dumper)
+*/
+struct WW8_FFN : public WW8_FFN_BASE
+{
+ // ab Ver8 als Unicode
+ UniString sFontname;// 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+ // records name of font.
+ // Maximal size of szFfn is 65 characters.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the
+ // name of an alternate font to use if the first named
+ // font does not exist on this system.
+};
+
+
+
+struct WW8_BRCVer6 // alter Border Code
+{
+ SVBT16 aBits1;
+// UINT16 dxpLineWidth : 3;// 0007 When dxpLineWidth is 0, 1, 2, 3, 4, or 5, this field is the width of
+ // a single line of border in units of 0.75 points
+ // Must be nonzero when brcType is nonzero.
+ // 6 == dotted, 7 == dashed.
+// UINT16 brcType : 2; // 0018 border type code: 0 == none, 1 == single, 2 == thick, 3 == double
+// UINT16 fShadow : 1; // 0020 when 1, border is drawn with shadow. Must be 0 when BRC is a substructure of the TC
+// UINT16 ico : 5; // 07C0 color code (see chp.ico)
+// UINT16 dxpSpace : 5; // F800 width of space to maintain between border and text within border.
+ // Must be 0 when BRC is a substructure of the TC. Stored in points for Windows.
+};
+
+struct WW8_BRC : public WW8_BRCVer6 // Border Code
+{
+ SVBT16 aBits2;
+// UINT16 dxpLineWidth : 3;// 0007 When dxpLineWidth is 0, 1, 2, 3, 4, or 5, this field is the width of
+ // a single line of border in units of 0.75 points
+ // Must be nonzero when brcType is nonzero.
+ // 6 == dotted, 7 == dashed.
+// UINT16 brcType : 2; // 0018 border type code: 0 == none, 1 == single, 2 == thick, 3 == double
+// UINT16 fShadow : 1; // 0020 when 1, border is drawn with shadow. Must be 0 when BRC is a substructure of the TC
+// UINT16 ico : 5; // 07C0 color code (see chp.ico)
+// UINT16 dxpSpace : 5; // F800 width of space to maintain between border and text within border.
+ // Must be 0 when BRC is a substructure of the TC. Stored in points for Windows.
+};
+
+typedef WW8_BRC WW8_BRC5[5]; // 5 * Border Code
+
+#define WW8_TOP 0
+#define WW8_LEFT 1
+#define WW8_BOT 2
+#define WW8_RIGHT 3
+#define WW8_BETW 4
+
+
+
+
+
+struct WW8_BordersSO // fuer StarOffice-Border Code
+{
+ USHORT Out;
+ USHORT In;
+ USHORT Dist;
+};
+
+
+/*
+// Linien-Defaults in Twips: fruehere Writer-Defaults,
+// siehe auch <svx/boxitem.hxx>
+#define DEF_LINE_WIDTH_0 1
+#define DEF_LINE_WIDTH_1 20
+#define DEF_LINE_WIDTH_2 50
+#define DEF_LINE_WIDTH_3 80
+#define DEF_LINE_WIDTH_4 100
+
+#define DEF_MAX_LINE_WIDHT DEF_LINE_WIDTH_4
+#define DEF_MAX_LINE_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE0_OUT DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE0_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE0_DIST DEF_LINE_WIDTH_1
+
+#define DEF_DOUBLE_LINE1_OUT DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE1_IN DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE1_DIST DEF_LINE_WIDTH_1
+
+#define DEF_DOUBLE_LINE2_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE2_IN DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE2_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE3_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE3_IN DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE3_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE4_OUT DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE4_IN DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE4_DIST DEF_LINE_WIDTH_1
+
+#define DEF_DOUBLE_LINE5_OUT DEF_LINE_WIDTH_3
+#define DEF_DOUBLE_LINE5_IN DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE5_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE6_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE6_IN DEF_LINE_WIDTH_3
+#define DEF_DOUBLE_LINE6_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE7_OUT DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE7_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE7_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE8_OUT DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE8_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE8_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE9_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE9_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE9_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE10_OUT DEF_LINE_WIDTH_3
+#define DEF_DOUBLE_LINE10_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE10_DIST DEF_LINE_WIDTH_2
+*/
+// Deklarationen gemaess BOXITEM.HXX
+#define WW8_DECL_LINETAB_ARRAY \
+ static WW8_BordersSO __READONLY_DATA nLineTabVer8[] = \
+ { \
+/* 0*/ { DEF_LINE_WIDTH_0, 0, 0 }, \
+/* 1*/ { DEF_LINE_WIDTH_1, 0, 0 }, \
+/* 2*/ { DEF_LINE_WIDTH_2, 0, 0 }, \
+/* 3*/ { DEF_LINE_WIDTH_3, 0, 0 }, \
+/* 4*/ { DEF_LINE_WIDTH_4, 0, 0 }, \
+/* 5*/ { DEF_DOUBLE_LINE0_OUT, DEF_DOUBLE_LINE0_IN, DEF_DOUBLE_LINE0_DIST },\
+/* 6*/ { DEF_DOUBLE_LINE1_OUT, DEF_DOUBLE_LINE1_IN, DEF_DOUBLE_LINE1_DIST },\
+/* 7*/ { DEF_DOUBLE_LINE2_OUT, DEF_DOUBLE_LINE2_IN, DEF_DOUBLE_LINE2_DIST },\
+/* 8*/ { DEF_DOUBLE_LINE3_OUT, DEF_DOUBLE_LINE3_IN, DEF_DOUBLE_LINE3_DIST },\
+/* 9*/ { DEF_DOUBLE_LINE4_OUT, DEF_DOUBLE_LINE4_IN, DEF_DOUBLE_LINE4_DIST },\
+/*10*/ { DEF_DOUBLE_LINE5_OUT, DEF_DOUBLE_LINE5_IN, DEF_DOUBLE_LINE5_DIST },\
+/*11*/ { DEF_DOUBLE_LINE6_OUT, DEF_DOUBLE_LINE6_IN, DEF_DOUBLE_LINE6_DIST },\
+/*12*/ { DEF_DOUBLE_LINE7_OUT, DEF_DOUBLE_LINE7_IN, DEF_DOUBLE_LINE7_DIST },\
+/*13*/ { DEF_DOUBLE_LINE8_OUT, DEF_DOUBLE_LINE8_IN, DEF_DOUBLE_LINE8_DIST },\
+/*14*/ { DEF_DOUBLE_LINE9_OUT, DEF_DOUBLE_LINE9_IN, DEF_DOUBLE_LINE9_DIST },\
+/*15*/ { DEF_DOUBLE_LINE10_OUT,DEF_DOUBLE_LINE10_IN,DEF_DOUBLE_LINE10_DIST} \
+ };
+
+#define WW8_DECL_LINETAB_OFS_DOUBLE 5 // Beginn des DOUBLE_LINE Abschnitts in meiner Liste
+
+
+
+
+struct WW8_XCHAR // Hilfs-Konstrukt fuer WW8_DOPTYPOGRAPHY
+{
+ char A;
+ char B;
+};
+
+struct WW8_DOPTYPOGRAPHY
+{ /*
+ Document Typography Info (DOPTYPOGRAPHY)
+ These options are Far East only, and are accessible
+ through the Typography tab of the Tools/Options dialog.
+ */
+
+
+
+ /* a c h t u n g : es duerfen keine solchen Bitfelder ueber einen eingelesenes Byte-Array
+ gelegt werden!!
+ stattdessen ist ein aBits1 darueber zu legen, das mit & auszulesen ist
+ GRUND: Compiler auf Intel und Sparc sortieren die Bits unterschiedlich
+ */
+
+
+
+ short fKerningPunct : 1; // true if we're kerning punctuation
+ short iJustification : 2; // Kinsoku method of justification:
+ // 0 = always expand
+ // 1 = compress punctuation
+ // 2 = compress punctuation and kana.
+ short iLevelOfKinsoku: 2; // Level of Kinsoku:
+ // 0 = Level 1
+ // 1 = Level 2
+ // 2 = Custom
+ short f2on1 : 1; // 2-page-on-1 feature is turned on.
+ short :10; // reserved
+ short cchFollowingPunct; // length of rgxchFPunct
+ short cchLeadingPunct; // length of rgxchLPunct
+
+ WW8_XCHAR rgxchFPunct[101]; // array of characters that should
+ // never appear at the start of a line
+ WW8_XCHAR rgxchLPunct[51]; // array of characters that should
+ // never appear at the end of a line
+};
+
+struct WW8_DOGRID
+{
+ short xaGrid; // x-coord of the upper left-hand corner of the grid
+ short yaGrid; // y-coord of the upper left-hand corner of the grid
+ short dxaGrid; // width of each grid square
+ short dyaGrid; // height of each grid square
+
+
+
+ /* a c h t u n g : es duerfen keine solchen Bitfelder ueber einen eingelesenes Byte-Array
+ gelegt werden!!
+ stattdessen ist ein aBits1 darueber zu legen, das mit & auszulesen ist
+ GRUND: Compiler auf Intel und Sparc sortieren die Bits unterschiedlich
+ */
+
+
+
+ short dyGridDisplay:7; // the number of grid squares (in the y direction)
+ // between each gridline drawn on the screen. 0 means
+ // don't display any gridlines in the y direction.
+ short fTurnItOff :1; // suppress display of gridlines
+ short dxGridDisplay:7; // the number of grid squares (in the x direction)
+ // between each gridline drawn on the screen. 0 means
+ // don't display any gridlines in the y direction.
+ short fFollowMargins:1; // if true, the grid will start at the left and top
+ // margins and ignore xaGrid and yaGrid.
+};
+
+struct WW8_PIC
+{
+ INT32 lcb; // 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file.
+ UINT16 cbHeader; // 0x4 number of bytes in the PIC (to allow for future expansion).
+ struct {
+ INT16 mm; // 0x6 int
+ INT16 xExt; // 0x8 int
+ INT16 yExt; // 0xa int
+ INT16 hMF; // 0xc int
+ }MFP;
+// BYTE bm[14]; // 0xe BITMAP(14 bytes) Window's bitmap structure when PIC describes a BITMAP.
+ BYTE rcWinMF[14]; // 0xe rc (rectangle - 8 bytes) rect for window origin
+ // and extents when metafile is stored -- ignored if 0
+ INT16 dxaGoal; // 0x1c horizontal measurement in twips of the rectangle the picture should be imaged within.
+ INT16 dyaGoal; // 0x1e vertical measurement in twips of the rectangle the picture should be imaged within.
+ UINT16 mx; // 0x20 horizontal scaling factor supplied by user in .1% units.
+ UINT16 my; // 0x22 vertical scaling factor supplied by user in .1% units.
+ INT16 dxaCropLeft; // 0x24 the amount the picture has been cropped on the left in twips.
+ INT16 dyaCropTop; // 0x26 the amount the picture has been cropped on the top in twips.
+ INT16 dxaCropRight; // 0x28 the amount the picture has been cropped on the right in twips.
+ INT16 dyaCropBottom;// 0x2a the amount the picture has been cropped on the bottom in twips.
+ INT16 brcl : 4; // 000F Obsolete, superseded by brcTop, etc. In
+ INT16 fFrameEmpty : 1; // 0010 picture consists of a single frame
+ INT16 fBitmap : 1; // 0020 ==1, when picture is just a bitmap
+ INT16 fDrawHatch : 1; // 0040 ==1, when picture is an active OLE object
+ INT16 fError : 1; // 0080 ==1, when picture is just an error message
+ INT16 bpp : 8; // FF00 bits per pixel, 0 = unknown
+ WW8_BRC rgbrc[4];
+// BRC brcTop; // 0x2e specification for border above picture
+// BRC brcLeft; // 0x30 specification for border to the left
+// BRC brcBottom; // 0x32 specification for border below picture
+// BRC brcRight; // 0x34 specification for border to the right
+ INT16 dxaOrigin; // 0x36 horizontal offset of hand annotation origin
+ INT16 dyaOrigin; // 0x38 vertical offset of hand annotation origin
+// BYTE rgb[]; // 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename.
+};
+
+struct WW8_PIC_SHADOW
+{
+ SVBT32 lcb; // 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file.
+ SVBT16 cbHeader; // 0x4 number of bytes in the PIC (to allow for future expansion).
+ struct {
+ SVBT16 mm; // 0x6 int
+ SVBT16 xExt; // 0x8 int
+ SVBT16 yExt; // 0xa int
+ SVBT16 hMF; // 0xc int
+ }MFP;
+// SVBT8 bm[14]; // 0xe BITMAP(14 bytes) Window's bitmap structure when PIC describes a BITMAP.
+ SVBT8 rcWinMF[14]; // 0xe rc (rectangle - 8 bytes) rect for window origin
+ // and extents when metafile is stored -- ignored if 0
+ SVBT16 dxaGoal; // 0x1c horizontal measurement in twips of the rectangle the picture should be imaged within.
+ SVBT16 dyaGoal; // 0x1e vertical measurement in twips of the rectangle the picture should be imaged within.
+ SVBT16 mx; // 0x20 horizontal scaling factor supplied by user in .1% units.
+ SVBT16 my; // 0x22 vertical scaling factor supplied by user in .1% units.
+ SVBT16 dxaCropLeft; // 0x24 the amount the picture has been cropped on the left in twips.
+ SVBT16 dyaCropTop; // 0x26 the amount the picture has been cropped on the top in twips.
+ SVBT16 dxaCropRight; // 0x28 the amount the picture has been cropped on the right in twips.
+ SVBT16 dyaCropBottom;// 0x2a the amount the picture has been cropped on the bottom in twips.
+ SVBT8 aBits1; //0x2c
+ SVBT8 aBits2;
+ WW8_BRC rgbrc[4];
+// BRC brcTop; // 0x2e specification for border above picture
+// BRC brcLeft; // 0x30 specification for border to the left
+// BRC brcBottom; // 0x32 specification for border below picture
+// BRC brcRight; // 0x34 specification for border to the right
+ SVBT16 dxaOrigin; // 0x36 horizontal offset of hand annotation origin
+ SVBT16 dyaOrigin; // 0x38 vertical offset of hand annotation origin
+// SVBT8 rgb[]; // 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename.
+};
+
+
+struct WW8_TBD
+{
+ SVBT8 aBits1;
+// BYTE jc : 3; // 0x07 justification code: 0=left tab, 1=centered tab, 2=right tab, 3=decimal tab, 4=bar
+// BYTE tlc : 3; // 0x38 tab leader code: 0=no leader, 1=dotted leader,
+ // 2=hyphenated leader, 3=single line leader, 4=heavy line leader
+// * int :2 C0 reserved
+};
+
+struct WW8_TCell // hiermit wird weitergearbeitet (entspricht weitestgehend dem Ver8-Format)
+{
+ BOOL bFirstMerged : 1;// 0001 set to 1 when cell is first cell of a range of cells that have been merged.
+ BOOL bMerged : 1;// 0002 set to 1 when cell has been merged with preceding cell.
+ BOOL bVertical : 1;// set to 1 when cell has vertical text flow
+ BOOL bBackward : 1;// for a vertical table cell, text flow is bottom to top when 1 and is bottom to top when 0.
+ BOOL bRotateFont : 1;// set to 1 when cell has rotated characters (i.e. uses @font)
+ BOOL bVertMerge : 1;// set to 1 when cell is vertically merged with the cell(s) above and/or below. When cells are vertically merged, the display area of the merged cells are consolidated. The consolidated area is used to display the contents of the first vertically merged cell (the cell with fVertRestart set to 1), and all other vertically merged cells (those with fVertRestart set to 0) must be empty. Cells can only be merged vertically if their left and right boundaries are (nearly) identical (i.e. if corresponding entries in rgdxaCenter of the table rows differ by at most 3).
+ BOOL bVertRestart : 1;// set to 1 when the cell is the first of a set of vertically merged cells. The contents of a cell with fVertStart set to 1 are displayed in the consolidated area belonging to the entire set of vertically merged cells. Vertically merged cells with fVertRestart set to 0 must be empty.
+ BYTE nVertAlign : 2;// specifies the alignment of the cell contents relative to text flow (e.g. in a cell with bottom to top text flow and bottom vertical alignment, the text is shifted horizontally to match the cell's right boundary):
+ // 0 top
+ // 1 center
+ // 2 bottom
+ UINT16 fUnused : 7;// reserved - nicht loeschen: macht das UINT16 voll !!
+
+ WW8_BRC rgbrc[4]; // border codes
+//notational convenience for referring to brcTop, brcLeft, etc fields.
+// BRC brcTop; // specification of the top border of a table cell
+// BRC brcLeft; // specification of left border of table row
+// BRC brcBottom; // specification of bottom border of table row
+// BRC brcRight; // specification of right border of table row.
+};
+// cbTC (count of bytes of a TC) is 18(decimal), 12(hex).
+
+
+struct WW8_TCellVer6 // wird aus der Datei gelesen
+{
+ SVBT8 aBits1Ver6;
+ SVBT8 aBits2Ver6;
+// UINT16 fFirstMerged : 1;// 0001 set to 1 when cell is first cell of a range of cells that have been merged.
+// UINT16 fMerged : 1; // 0002 set to 1 when cell has been merged with preceding cell.
+// UINT16 fUnused : 14; // FFFC reserved
+ WW8_BRCVer6 rgbrcVer6[4];
+// notational convenience for referring to brcTop, brcLeft, etc fields:
+// BRC brcTop; // specification of the top border of a table cell
+// BRC brcLeft; // specification of left border of table row
+// BRC brcBottom; // specification of bottom border of table row
+// BRC brcRight; // specification of right border of table row.
+};
+// cbTC (count of bytes of a TC) is 10(decimal), A(hex).
+
+struct WW8_TCellVer8 // wird aus der Datei gelesen
+{
+ SVBT16 aBits1Ver8; // Dokumentation siehe oben unter WW8_TCell
+ SVBT16 aUnused; // reserve
+ WW8_BRC rgbrcVer8[4]; // Dokumentation siehe oben unter WW8_TCell
+};
+// cbTC (count of bytes of a TC) is 20(decimal), 14(hex).
+
+
+struct WW8_SHD // struct SHD fehlt in der Beschreibung
+{
+private:
+ UINT16 aBits;
+// UINT16 nFore : 5; // 0x001f ForegroundColor
+// UINT16 nBack : 5; // 0x03e0 BackgroundColor
+// UINT16 nStyle : 5; // 0x7c00 Percentage and Style
+// UINT16 nDontKnow : 1; // 0x8000 ??? ab Ver8: ebenfalls fuer Style
+
+public:
+ WW8_SHD(){ aBits = 0; }
+
+ BYTE GetFore() const { return (BYTE)( aBits & 0x1f); }
+ BYTE GetBack() const { return (BYTE)((aBits >> 5 ) & 0x1f); }
+ BYTE GetStyle(BOOL bVer67) const { return (BYTE)((aBits >> 10) & ( bVer67?0x1f:0x3f ) ); }
+
+ UINT16 GetValue() const { return aBits; }
+
+ void SetValue( UINT16 nVal ){ aBits = nVal; }
+ void SetWWValue( SVBT16 nVal ){ aBits = (UINT16)SVBT16ToShort( nVal ); }
+
+ void SetFore( BYTE nVal ){ aBits = (aBits & 0xffe0) | (nVal & 0x1f); }
+ void SetBack( BYTE nVal ){ aBits = (aBits & 0xfc1f) | ((nVal & 0x1f)<<5); }
+ void SetStyle( BOOL bVer67, BYTE nVal ){
+ aBits = (aBits & ( bVer67?0x83ff:0x03ff ) )
+ | ((nVal & ( bVer67?0x1f:0x2f ))<<10); }
+};
+
+
+struct WW8_ANLV
+{
+ SVBT8 nfc; // 0 number format code, 0=Arabic, 1=Upper case Roman, 2=Lower case Roman
+ // 3=Upper case Letter, 4=Lower case letter, 5=Ordinal
+ SVBT8 cbTextBefore; // 1 offset into anld.rgch limit of prefix text
+ SVBT8 cbTextAfter; // 2
+ SVBT8 aBits1;
+// BYTE jc : 2; // 3 : 0x03 justification code, 0=left, 1=center, 2=right, 3=left and right justify
+// BYTE fPrev : 1; // 0x04 when ==1, include previous levels
+// BYTE fHang : 1; // 0x08 when ==1, number will be displayed using a hanging indent
+// BYTE fSetBold : 1; // 0x10 when ==1, boldness of number will be determined by anld.fBold.
+// BYTE fSetItalic : 1;// 0x20 when ==1, italicness of number will be determined by anld.fItalic
+// BYTE fSetSmallCaps : 1;// 0x40 when ==1, anld.fSmallCaps will determine whether number will be displayed in small caps or not.
+// BYTE fSetCaps : 1; // 0x80 when ==1, anld.fCaps will determine whether number will be displayed capitalized or not
+ SVBT8 aBits2;
+// BYTE fSetStrike : 1;// 4 : 0x01 when ==1, anld.fStrike will determine whether the number will be displayed using strikethrough or not.
+// BYTE fSetKul : 1; // 0x02 when ==1, anld.kul will determine the underlining state of the autonumber.
+// BYTE fPrevSpace : 1;// 0x04 when ==1, autonumber will be displayed with a single prefixing space character
+// BYTE fBold : 1; // 0x08 determines boldness of autonumber when anld.fSetBold == 1.
+// BYTE fItalic : 1; // 0x10 determines italicness of autonumber when anld.fSetItalic == 1.
+// BYTE fSmallCaps : 1;// 0x20 determines whether autonumber will be displayed using small caps when anld.fSetSmallCaps == 1.
+// BYTE fCaps : 1; // 0x40 determines whether autonumber will be displayed using caps when anld.fSetCaps == 1.
+// BYTE fStrike : 1; // 0x80 determines whether autonumber will be displayed using caps when anld.fSetStrike == 1.
+ SVBT8 aBits3;
+// BYTE kul : 3; // 5 : 0x07 determines whether autonumber will be displayed with underlining when anld.fSetKul == 1.
+// BYTE ico : 5; // 0xF1 color of autonumber
+ SVBT16 ftc; // 6 font code of autonumber
+ SVBT16 hps; // 8 font half point size (or 0=auto)
+ SVBT16 iStartAt; // 0x0a starting value (0 to 65535)
+ SVBT16 dxaIndent; // 0x0c *short?* *USHORT?* width of prefix text (same as indent)
+ SVBT16 dxaSpace; // 0x0e minimum space between number and paragraph
+};
+// *cbANLV (count of bytes of ANLV) is 16 (decimal), 10(hex).
+
+struct WW8_ANLD
+{
+ WW8_ANLV eAnlv; // 0
+ SVBT8 fNumber1; // 0x10 number only 1 item per table cell
+ SVBT8 fNumberAcross; // 0x11 number across cells in table rows(instead of down)
+ SVBT8 fRestartHdn; // 0x12 restart heading number on section boundary
+ SVBT8 fSpareX; // 0x13 unused( should be 0)
+ char rgchAnld[32]; // 0x14 characters displayed before/after autonumber
+};
+
+
+struct WW8_OLST
+{
+ WW8_ANLV rganlv[9]; // 0 an array of 9 ANLV structures (heading levels)
+ SVBT8 fRestartHdr; // 0x90 when ==1, restart heading on section break
+ SVBT8 fSpareOlst2; // 0x91 reserved
+ SVBT8 fSpareOlst3; // 0x92 reserved
+ SVBT8 fSpareOlst4; // 0x93 reserved
+ char rgch[64]; // 0x94 array of 64 chars text before/after number
+};
+// cbOLST is 212(decimal), D4(hex).
+
+struct WW8_FDOA
+{
+ SVBT32 fc; // 0 FC pointing to drawing object data
+ SVBT16 ctxbx; // 4 count of textboxes in the drawing object
+};
+
+struct WW8_DO
+{
+ SVBT16 dok; // 0 Drawn Object Kind, currently this is always 0
+ SVBT16 cb; // 2 size (count of bytes) of the entire DO
+ SVBT8 bx; // 4 x position relative to anchor CP
+ SVBT8 by; // 5 y position relative to anchor CP
+ SVBT16 dhgt; // 6 height of DO
+ SVBT16 aBits1;
+// UINT16 fAnchorLock : 1; // 8 1 if the DO anchor is locked
+// BYTE[] rgdp; // 0xa variable length array of drawing primitives
+};
+
+struct WW8_DPHEAD
+{
+ SVBT16 dpk; // 0 Drawn Primitive Kind REVIEW davebu
+ // 0=start of grouping, 1=line, 2=textbox, 3=rectangle,
+ // 4=arc, 5=elipse, 6=polyline, 7=callout textbox,
+ // 8=end of grouping, 9=sample primitve holding default values
+ SVBT16 cb; // 2 size (count of bytes) of this DP
+ SVBT16 xa; // 4 These 2 points describe the rectangle
+ SVBT16 ya; // 6 enclosing this DP relative to the origin of
+ SVBT16 dxa; // 8 the DO
+ SVBT16 dya; // 0xa
+};
+
+
+struct WW8_DP_LINETYPE
+{
+ SVBT32 lnpc; // LiNe Property Color -- RGB color value
+ SVBT16 lnpw; // line property weight in twips
+ SVBT16 lnps; // line property style : 0=Solid, 1=Dashed
+ // 2=Dotted, 3=Dash Dot, 4=Dash Dot Dot, 5=Hollow
+};
+
+struct WW8_DP_SHADOW // Schattierung!
+{
+ SVBT16 shdwpi; // Shadow Property Intensity
+ SVBT16 xaOffset; // x offset of shadow
+ SVBT16 yaOffset; // y offset of shadow
+};
+
+struct WW8_DP_FILL
+{
+ SVBT32 dlpcFg; // FiLl Property Color ForeGround -- RGB color value
+ SVBT32 dlpcBg; // Property Color BackGround -- RGB color value
+ SVBT16 flpp; // FiLl Property Pattern REVIEW davebu
+};
+
+struct WW8_DP_LINEEND
+{
+ SVBT16 aStartBits;
+// UINT16 eppsStart : 2; // Start EndPoint Property Style
+ // 0=None, 1=Hollow, 2=Filled
+// UINT16 eppwStart : 2; // Start EndPoint Property Weight
+// UINT16 epplStart : 2; // Start EndPoint Property length
+// UINT16 dummyStart : 10; // Alignment
+ SVBT16 aEndBits;
+// UINT16 eppsEnd : 2; // End EndPoint Property Style
+// UINT16 eppwEnd : 2; // End EndPoint Property Weight
+// UINT16 epplEnd : 2; // End EndPoint Property length
+// UINT16 dummyEnd : 10; // Alignment
+};
+
+struct WW8_DP_LINE
+{
+// WW8_DPHEAD dphead; // 0 Common header for a drawing primitive
+ SVBT16 xaStart; // starting point for line
+ SVBT16 yaStart; //
+ SVBT16 xaEnd; // ending point for line
+ SVBT16 yaEnd;
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_LINEEND aEpp;
+ WW8_DP_SHADOW aShd;
+};
+
+struct WW8_DP_TXTBOX
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+ SVBT16 aBits1;
+// UINT16 fRoundCorners : 1; //0x24 0001 1 if the textbox has rounded corners
+// UINT16 zaShape : 15; // 0x24 000e REVIEW davebu
+ SVBT16 dzaInternalMargin; // 0x26 REVIEW davebu
+};
+
+struct WW8_DP_RECT
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+ SVBT16 aBits1;
+// UINT16 fRoundCorners : 1; // 0x24 0001 1 if the textbox has rounded corners
+// UINT16 zaShape : 15; // 0x24 000e REVIEW davebu
+};
+
+struct WW8_DP_ARC
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+ SVBT8 fLeft; // 0x24 00ff REVIEW davebu
+ SVBT8 fUp; // 0x24 ff00 REVIEW davebu
+// UINT16 fLeft : 8; // 0x24 00ff REVIEW davebu
+// UINT16 fUp : 8; // 0x24 ff00 REVIEW davebu
+};
+
+struct WW8_DP_ELIPSE
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+};
+
+struct WW8_DP_POLYLINE
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_LINEEND aEpp;
+ WW8_DP_SHADOW aShd;
+ SVBT16 aBits1;
+// UINT16 fPolygon : 1; // 0x28 0001 1 if this is a polygon
+// UINT16 cpt : 15; // 0x28 00fe count of points
+// short xaFirst; // 0x2a These are the endpoints of the first line.
+// short yaFirst; // 0x2c
+// short xaEnd; // 0x2e
+// short yaEnd; // 0x30
+// short rgpta[]; // 0x32 An array of xa,ya pairs for the remaining points
+};
+
+struct WW8_DP_CALLOUT_TXTBOX
+{
+ SVBT16 flags; // 0x0c REVIEW davebu flags
+ SVBT16 dzaOffset; // 0x0e REVIEW davebu
+ SVBT16 dzaDescent; // 0x10 REVIEW davebu
+ SVBT16 dzaLength; // 0x12 REVIEW davebu
+ WW8_DPHEAD dpheadTxbx; // 0x14 DPHEAD for a textbox
+ WW8_DP_TXTBOX dptxbx; // 0x20 DP for a textbox
+ WW8_DPHEAD dpheadPolyLine; // 0x4c DPHEAD for a Polyline
+ WW8_DP_POLYLINE dpPolyLine; // 0x48 DP for a polyline
+};
+
+struct WW8_DP_DEFAULTS
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_LINEEND aEpp;
+ WW8_DP_SHADOW aShd;
+ SVBT16 dzaOffset; // 0x2a REVIEW davebu
+ SVBT16 dzaDescent; // 0x2c REVIEW davebu
+ SVBT16 dzaLength; // 0x2e REVIEW davebu
+
+ SVBT16 aBits3;
+// UINT16 fRoundCorners : 1; // 0x30 0001 1 if the textbox has rounded corners
+// UINT16 zaShape : 15; // 0x30 000fe REVIEW davebu
+ SVBT16 dzaInternalMargin; // 0x32 REVIEW davebu
+};
+
+
+struct WW8_PCD
+{
+ SVBT8 aBits1;
+// BYTE fNoParaLast : 1; // when 1, means that piece contains no end of paragraph marks.
+// BYTE fPaphNil : 1; // used internally by Word
+// BYTE fCopied : 1; // used internally by Word
+// * int :5
+ SVBT8 aBits2; // fn int:8, used internally by Word
+ SVBT32 fc; // file offset of beginning of piece. The size of the
+ // ithpiece can be determined by subtracting rgcp[i] of
+ // the containing plcfpcd from its rgcp[i+1].
+ SVBT16 prm; // PRM contains either a single sprm or else an index number
+ // of the grpprl which contains the sprms that modify the
+ // properties of the piece.
+};
+
+struct WW8_PHE_Base
+{
+ BYTE aBits1; //
+// 0 0 fSpare int :1 0001 reserved
+// fUnk int :1 0002 phe entry is invalid
+// when == 1
+// fDiffLines int :1 0004 when 1, total
+// height of paragraph is known but lines in
+// paragraph have different heights.
+// * int :5 00F8 reserved
+ BYTE nlMac; // when fDiffLines is 0 is number of lines in
+// // paragraph
+ SVBT16 dxaCol; // width of lines in paragraph
+ SVBT16 dyl;
+// 4 4 dylLine int when fDiffLines is 0,
+// is height of every line in paragraph.in pixels
+// 4 4 dylHeight uns when fDiffLines is 1,
+// is the total height in pixels of the paragraph
+};
+
+/*
+eigentlich muessten wir das jetzt in etwa *so* praezisieren:
+
+ struct WW8_PHE_Ver6 : public WW8_PHE_Base
+ {
+ // 6 Bytes gross
+ };
+ struct WW8_PHE_Ver6 : public WW8_PHE_Base
+ {
+ SVBT16 a;
+ SVBT16 b;
+ SVBT16 c; // 12 Byte gross
+ };
+*/
+
+// AnnoTation Refernce Descriptor (ATRD)
+struct WW8_ATRD // fuer die 8-Version
+{
+ SVBT16 xstUsrInitl[ 10 ]; // pascal-style String holding initials
+ // of annotation author
+ SVBT16 ibst; // index into GrpXstAtnOwners
+ SVBT16 ak; // not used
+ SVBT16 grfbmc; // not used
+ SVBT32 ITagBkmk; // when not -1, this tag identifies the
+ // annotation bookmark that locates the
+ // range of CPs in the main document which
+ // this annotation references.
+};
+
+struct WW67_ATRD // fuer die 6/7-Version
+{
+ char xstUsrInitl[ 10 ]; // pascal-style String holding initials
+ // of annotation author
+ SVBT16 ibst; // index into GrpXstAtnOwners
+ SVBT16 ak; // not used
+ SVBT16 grfbmc; // not used
+ SVBT32 ITagBkmk; // when not -1, this tag identifies the
+ // annotation bookmark that locates the
+ // range of CPs in the main document which
+ // this annotation references.
+};
+
+
+#ifdef __WW8_NEEDS_PACK
+#pragma pack()
+#endif
+
+
+#endif
diff --git a/sw/source/filter/ww8/makefile.mk b/sw/source/filter/ww8/makefile.mk
new file mode 100644
index 000000000000..596961827ea3
--- /dev/null
+++ b/sw/source/filter/ww8/makefile.mk
@@ -0,0 +1,134 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=ww8
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(mydebug)" != ""
+CDEFS=$(CDEFS) -Dmydebug
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ wrtw8esh.cxx \
+ wrtw8nds.cxx \
+ wrtw8num.cxx \
+ wrtw8sty.cxx \
+ wrtww8.cxx \
+ wrtww8gr.cxx \
+ ww8atr.cxx \
+ ww8graf.cxx \
+ ww8graf2.cxx \
+ ww8par.cxx \
+ ww8par2.cxx \
+ ww8par3.cxx \
+ ww8par4.cxx \
+ ww8par5.cxx \
+ ww8par6.cxx \
+ ww8glsy.cxx \
+ msocximp.cxx \
+ ww8scan.cxx
+
+
+
+SLOFILES = \
+ $(SLO)$/wrtw8esh.obj \
+ $(SLO)$/wrtw8nds.obj \
+ $(SLO)$/wrtw8num.obj \
+ $(SLO)$/wrtw8sty.obj \
+ $(SLO)$/wrtww8.obj \
+ $(SLO)$/wrtww8gr.obj \
+ $(SLO)$/ww8atr.obj \
+ $(SLO)$/ww8graf.obj \
+ $(SLO)$/ww8graf2.obj \
+ $(SLO)$/ww8par.obj \
+ $(SLO)$/ww8par2.obj \
+ $(SLO)$/ww8par3.obj \
+ $(SLO)$/ww8par4.obj \
+ $(SLO)$/ww8par5.obj \
+ $(SLO)$/ww8par6.obj \
+ $(SLO)$/ww8glsy.obj \
+ $(SLO)$/msocximp.obj \
+ $(SLO)$/ww8scan.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/ww8par5.obj \
+ $(SLO)$/ww8graf.obj \
+ $(SLO)$/ww8graf2.obj \
+ $(SLO)$/msocximp.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
new file mode 100644
index 000000000000..95bee2c3ea31
--- /dev/null
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -0,0 +1,1706 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtw8esh.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+
+#ifndef _SVSTOR_HXX
+#include <so3/svstor.hxx>
+#endif
+#ifndef _IPOBJ_HXX
+#include <so3/ipobj.hxx>
+#endif
+#ifndef _FILTER_HXX
+#include <svtools/filter.hxx>
+#endif
+#ifndef _SFXITEMITER_HXX
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SVDOBJ_HXX
+#include <svx/svdobj.hxx>
+#endif
+#ifndef _SVDOTEXT_HXX
+#include <svx/svdotext.hxx>
+#endif
+#ifndef _SVDMODEL_HXX
+#include <svx/svdmodel.hxx>
+#endif
+#ifndef _SVDPAGE_HXX
+#include <svx/svdpage.hxx>
+#endif
+#ifndef _SVDTRANS_HXX
+#include <svx/svdtrans.hxx>
+#endif
+#ifndef _OUTLOBJ_HXX
+#include <svx/outlobj.hxx>
+#endif
+#ifndef _EDITOBJ_HXX
+#include <svx/editobj.hxx>
+#endif
+#ifndef _ESCHEREX_HXX
+#include <svx/escherex.hxx>
+#endif
+#ifndef _SVX_UNOSHAPE_HXX
+#include <svx/unoshape.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _EEITEM_HXX
+#include <svx/eeitem.hxx>
+#endif
+#ifndef _MyEDITENG_HXX
+#include <svx/editeng.hxx>
+#endif
+
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+#ifndef _FLYPOS_HXX
+#include <flypos.hxx>
+#endif
+#ifndef _FMTCNCT_HXX
+#include <fmtcnct.hxx>
+#endif
+#ifndef _FMTANCHR_HXX
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTSRND_HXX
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTORNT_HXX
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX
+#include <fmtfsize.hxx>
+#endif
+#ifndef _DCONTACT_HXX
+#include <dcontact.hxx>
+#endif
+#ifndef _CALBCK_HXX
+#include <calbck.hxx>
+#endif
+#ifndef _FRMFMT_HXX
+#include <frmfmt.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _NDINDEX_HXX
+#include <ndindex.hxx>
+#endif
+#ifndef _NODE_HXX
+#include <node.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _SWRECT_HXX
+#include <swrect.hxx>
+#endif
+#ifndef _NDGRF_HXX
+#include <ndgrf.hxx>
+#endif
+#ifndef _GRFATR_HXX
+#include <grfatr.hxx>
+#endif
+#ifndef _NDOLE_HXX
+#include <ndole.hxx>
+#endif
+#ifndef _UNODRAW_HXX
+#include <unodraw.hxx>
+#endif
+
+#ifndef _ERRHDL_HXX
+#include <errhdl.hxx>
+#endif
+
+using namespace ::com::sun::star;
+
+SV_DECL_VARARR_SORT( SvULongsSort, ULONG, 1, 1 )
+SV_IMPL_VARARR_SORT( SvULongsSort, ULONG )
+
+#define sEscherStream String::CreateFromAscii( \
+ RTL_CONSTASCII_STRINGPARAM( "tempEsher" ))
+#define sEscherPictStream String::CreateFromAscii( \
+ RTL_CONSTASCII_STRINGPARAM( "EsherPicts" ))
+
+
+WW8_WrPlcDrawObj::WW8_WrPlcDrawObj( BYTE nTyp )
+ : nTTyp( nTyp ), aParentPos( 0, 16 )
+{
+}
+
+WW8_WrPlcDrawObj::~WW8_WrPlcDrawObj()
+{
+ for( USHORT n = aParentPos.Count(); n; )
+ delete (Point*)aParentPos[ --n ];
+}
+
+void WW8_WrPlcDrawObj::WritePlc( SwWW8Writer& rWrt ) const
+{
+ if( 8 != rWrt.pFib->nVersion )
+ return ; // solange kein DrawObjects in 95 exportiert wird
+
+
+ ULONG nFcStart = rWrt.pTableStrm->Tell();
+ USHORT nLen = aCps.Count();
+
+ if( nLen )
+ {
+ // write CPs
+ WW8Fib& rFib = *rWrt.pFib;
+ ULONG nCpOffs = TXT_TXTBOX == nTTyp
+ ? 0 : (rWrt.pFib->ccpText + rWrt.pFib->ccpFtn);
+ register USHORT i;
+ for( i = 0; i < nLen; i++ )
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aCps[ i ] - nCpOffs );
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ rFib.ccpText + rFib.ccpFtn +
+ rFib.ccpHdr + rFib.ccpEdn +
+ rFib.ccpTxbx + rFib.ccpHdrTxbx + 1 );
+
+ for( i = 0; i < nLen; ++i )
+ {
+ // write the fspa-struct
+ const SwFrmFmt& rFmt = *(SwFrmFmt*)aCntnt[ i ];
+ const SdrObject* pObj = rFmt.FindRealSdrObject();
+
+ Rectangle aRect;
+ if( RES_FLYFRMFMT == rFmt.Which() )
+ {
+ Point aObjPos;
+ SwRect aLayRect( rFmt.FindLayoutRect( FALSE, &aObjPos ));
+ if( aLayRect.IsEmpty() )
+ {
+ // the Object is not visible - so get the values from
+ // the format. The Position may not be correct.
+ const SwFmtVertOrient& rVOr = rFmt.GetVertOrient();
+ if( VERT_NONE == rVOr.GetVertOrient() )
+ aObjPos.Y() = rVOr.GetPos();
+ const SwFmtHoriOrient& rHOr = rFmt.GetHoriOrient();
+ if( HORI_NONE == rHOr.GetHoriOrient() )
+ aObjPos.X() = rHOr.GetPos();
+
+ aRect.SetSize( rFmt.GetFrmSize().GetSize() );
+ aRect.SetPos( aObjPos );
+ }
+ else
+ aRect = aLayRect.SVRect();
+ }
+ else
+ {
+ ASSERT( pObj, "wo ist das SDR-Object?" );
+ if( pObj )
+ aRect = pObj->GetSnapRect();
+ }
+ aRect -= *(Point*)aParentPos[ i ];
+
+ // spid
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aShapeIds[ i ] );
+
+ //xaLeft/yaTop/xaRight/yaBottom - rel. to anchor
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRect.Left() );
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRect.Top() );
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRect.Right() );
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRect.Bottom() );
+
+ //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock
+ USHORT nFlags;
+ if( FLY_PAGE == rFmt.GetAnchor().GetAnchorId() )
+ nFlags = 0x0A; // x-rel to top Page, y-rel to top Page
+ else
+ nFlags = 0x14; // x-rel to text, y-rel to text
+
+ const SwFmtSurround& rSurr = rFmt.GetSurround();
+ USHORT nContour = rSurr.IsContour() ? 0x80 : 0x40;
+ switch( rSurr.GetSurround() )
+ {
+ case SURROUND_NONE: nFlags |= 0x020; break;
+ case SURROUND_THROUGHT: nFlags |= 0x060; break;
+ case SURROUND_PARALLEL: nFlags |= 0x000 | nContour; break;
+ case SURROUND_IDEAL: nFlags |= 0x600 | nContour; break;
+ case SURROUND_LEFT: nFlags |= 0x200 | nContour; break;
+ case SURROUND_RIGHT: nFlags |= 0x400 | nContour; break;
+ }
+ if( pObj && pObj->GetLayer() == rWrt.pDoc->GetHellId() )
+ nFlags |= 0x4000;
+
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFlags );
+
+ // cTxbx
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
+ }
+
+
+ if( TXT_TXTBOX == nTTyp )
+ {
+ rFib.fcPlcfspaMom = nFcStart;
+ rFib.lcbPlcfspaMom = rWrt.pTableStrm->Tell() - nFcStart;
+ }
+ else
+ {
+ rFib.fcPlcfspaHdr = nFcStart;
+ rFib.lcbPlcfspaHdr = rWrt.pTableStrm->Tell() - nFcStart;
+ }
+ }
+}
+
+
+BOOL WW8_WrPlcDrawObj::Append( SwWW8Writer& rWrt, WW8_CP nCp,
+ const SwFrmFmt& rFmt,
+ const Point& rNdTopLeft )
+{
+ BOOL bRet = FALSE;
+ if( TXT_HDFT == rWrt.nTxtTyp || TXT_MAINTEXT == rWrt.nTxtTyp )
+ {
+ const SdrObject* pObj = rFmt.FindSdrObject(), *pInsObj = 0;
+ if( RES_FLYFRMFMT == rFmt.Which() )
+ {
+ // check for textflyframe and if it is the first in a Chain
+ const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx();
+ if( pNdIdx )
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ if( bRet )
+ {
+ aCps.Insert( nCp, aCps.Count() );
+ void* p = (void*)&rFmt;
+ aCntnt.Insert( p, aCntnt.Count() );
+ void* pPos = new Point( rNdTopLeft );
+ aParentPos.Insert( pPos, aParentPos.Count() );
+ aShapeIds.Insert( ULONG(0), aShapeIds.Count() );
+ }
+ return bRet;
+}
+
+void WW8_WrPlcDrawObj::SetShapeId( const SwFrmFmt& rFmt, UINT32 nId )
+{
+ const VoidPtr p = (void*)&rFmt;
+ USHORT nPos = aCntnt.GetPos( p );
+ if( USHRT_MAX != nPos )
+ aShapeIds[ nPos ] = nId;
+}
+
+/* */
+
+void WW8_WrPlcTxtBoxes::WriteTxt( SwWW8Writer& rWrt )
+{
+ rWrt.bInWriteEscher = TRUE;
+ long& rccp = TXT_TXTBOX == nTyp ? rWrt.pFib->ccpTxbx
+ : rWrt.pFib->ccpHdrTxbx;
+ WW8_WrPlcSubDoc::WriteTxt( rWrt, nTyp, rccp );
+
+ WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ WW8Fib& rFib = *rWrt.pFib;
+ long nOffset = rFib.ccpText + rFib.ccpFtn + rFib.ccpHdr + rFib.ccpAtn
+ + rFib.ccpEdn;
+ if( TXT_TXTBOX == nTyp )
+ rWrt.pFldTxtBxs->Finish( nCP, nOffset );
+ else
+ rWrt.pFldHFTxtBxs->Finish( nCP, nOffset + rFib.ccpTxbx );
+ rWrt.bInWriteEscher = FALSE;
+}
+
+void WW8_WrPlcTxtBoxes::Append( const SdrObject& rObj, UINT32 nShapeId )
+{
+ void* p = (void*)&rObj;
+ aCntnt.Insert( p, aCntnt.Count() );
+ aShapeIds.Insert( nShapeId, aShapeIds.Count() );
+}
+
+const SvULongs* WW8_WrPlcTxtBoxes::GetShapeIdArr() const
+{
+ return &aShapeIds;
+}
+
+/* */
+
+UINT32 SwWW8Writer::GetSdrOrdNum( const SwFrmFmt& rFmt ) const
+{
+ UINT32 nOrdNum;
+ const SdrObject* pObj = rFmt.FindRealSdrObject();
+ if( pObj )
+ nOrdNum = pObj->GetOrdNum();
+ else
+ {
+ // no Layout for this format, then recalc the ordnum
+ SwFrmFmt* pFmt = (SwFrmFmt*)&rFmt;
+ nOrdNum = pDoc->GetSpzFrmFmts()->GetPos( pFmt );
+
+ const SdrModel* pModel = pDoc->GetDrawModel();
+ if( pModel )
+ nOrdNum += pModel->GetPage( 0 )->GetObjCount();
+ }
+ return nOrdNum;
+}
+
+void SwWW8Writer::AppendFlyInFlys( WW8_CP& rCP, const SwFrmFmt& rFrmFmt,
+ const Point& rNdTopLeft )
+{
+ ASSERT( !pEscher, "der EscherStream wurde schon geschrieben!" );
+ if( pEscher )
+ return ;
+
+ WW8_WrPlcDrawObj *pDrwO = TXT_HDFT == nTxtTyp ? pHFSdrObjs : pSdrObjs;
+ if( pDrwO->Append( *this, rCP, rFrmFmt, rNdTopLeft ))
+ {
+ static BYTE __READONLY_DATA aSpec8[] = {
+ 0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation (wahrscheinlich unnoetig)
+ 0x55, 0x08, 1 // sprmCFSpec
+ };
+ // fSpec-Attribut TRUE
+ // Fuer DrawObjets muss ein Spezial-Zeichen
+ // in den Text und darum ein fSpec-Attribut
+ pChpPlc->AppendFkpEntry( Strm().Tell() );
+ WriteChar( 0x8 );
+ rCP += 1; // to next charakter position
+ pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec8 ), aSpec8 );
+
+ if( RES_FLYFRMFMT == rFrmFmt.Which() )
+ {
+ // search all Flys/DrawObj in Flys and put it behind this
+ // text position.
+ const SwNodeIndex* pNdIdx = rFrmFmt.GetCntnt().GetCntntIdx();
+ ASSERT( pNdIdx, "wo ist der NodeIndex geblieben?" );
+ ULONG nStart = pNdIdx->GetIndex(),
+ nEnd = pNdIdx->GetNode().EndOfSectionIndex(),
+ nIdx;
+
+ USHORT nArrLen = pDoc->GetSpzFrmFmts()->Count();
+ for( USHORT n = 0; n < nArrLen; ++n )
+ {
+ const SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n];
+ const SwFmtAnchor* pAnchor = &pFmt->GetAnchor();
+ const SwPosition* pAPos;
+ if( ( pAnchor->GetAnchorId() == FLY_AT_CNTNT ||
+ pAnchor->GetAnchorId() == FLY_AT_FLY ||
+ pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) &&
+ 0 != ( pAPos = pAnchor->GetCntntAnchor()) &&
+ nStart <= ( nIdx = pAPos->nNode.GetIndex()) &&
+ nIdx < nEnd )
+ {
+ AppendFlyInFlys( rCP, *pFmt, rNdTopLeft );
+ }
+ }
+ }
+ }
+}
+
+
+USHORT SwWW8Writer::TranslateToEditEngineId( USHORT nWhich )
+{
+ switch( nWhich )
+ {
+ case RES_LR_SPACE: nWhich = EE_PARA_LRSPACE; break;
+ case RES_UL_SPACE: nWhich = EE_PARA_ULSPACE; break;
+ case RES_PARATR_LINESPACING: nWhich = EE_PARA_SBL; break;
+ case RES_PARATR_ADJUST: nWhich = EE_PARA_JUST; break;
+ case RES_PARATR_TABSTOP: nWhich = EE_PARA_TABS; break;
+
+ case RES_CHRATR_COLOR: nWhich = EE_CHAR_COLOR; break;
+ case RES_CHRATR_FONT: nWhich = EE_CHAR_FONTINFO; break;
+ case RES_CHRATR_FONTSIZE: nWhich = EE_CHAR_FONTHEIGHT; break;
+ case RES_CHRATR_WEIGHT: nWhich = EE_CHAR_WEIGHT; break;
+ case RES_CHRATR_UNDERLINE: nWhich = EE_CHAR_UNDERLINE; break;
+ case RES_CHRATR_CROSSEDOUT: nWhich = EE_CHAR_STRIKEOUT; break;
+ case RES_CHRATR_POSTURE: nWhich = EE_CHAR_ITALIC; break;
+ case RES_CHRATR_CONTOUR: nWhich = EE_CHAR_OUTLINE; break;
+ case RES_CHRATR_SHADOWED: nWhich = EE_CHAR_SHADOW; break;
+ case RES_CHRATR_ESCAPEMENT: nWhich = EE_CHAR_ESCAPEMENT; break;
+ case RES_CHRATR_AUTOKERN: nWhich = EE_CHAR_PAIRKERNING; break;
+ case RES_CHRATR_KERNING: nWhich = EE_CHAR_KERNING; break;
+ case RES_CHRATR_WORDLINEMODE: nWhich = EE_CHAR_WLM; break;
+ case RES_CHRATR_CHARSETCOLOR: nWhich = EE_FEATURE_NOTCONV; break;
+
+
+ default:
+// case EE_PARA_NUMBULLET:
+// case EE_PARA_HYPHENATE:
+// case EE_PARA_BULLETSTATE:
+// case EE_PARA_OUTLLRSPACE:
+// case EE_PARA_OUTLLEVEL:
+// case EE_PARA_BULLET:
+//ITEMID_FONTWIDTH EE_CHAR_FONTWIDTH
+ nWhich = 0;
+ break;
+ }
+ return nWhich;
+}
+
+USHORT SwWW8Writer::TranslateFromEditEngineId( USHORT nWhich )
+{
+ switch( nWhich )
+ {
+ case EE_PARA_LRSPACE: nWhich = RES_LR_SPACE; break;
+ case EE_PARA_ULSPACE: nWhich = RES_UL_SPACE; break;
+ case EE_PARA_SBL: nWhich = RES_PARATR_LINESPACING; break;
+ case EE_PARA_JUST: nWhich = RES_PARATR_ADJUST; break;
+ case EE_PARA_TABS: nWhich = RES_PARATR_TABSTOP; break;
+
+ case EE_CHAR_COLOR: nWhich = RES_CHRATR_COLOR; break;
+ case EE_CHAR_FONTINFO: nWhich = RES_CHRATR_FONT; break;
+ case EE_CHAR_FONTHEIGHT: nWhich = RES_CHRATR_FONTSIZE; break;
+ case EE_CHAR_WEIGHT: nWhich = RES_CHRATR_WEIGHT; break;
+ case EE_CHAR_UNDERLINE: nWhich = RES_CHRATR_UNDERLINE; break;
+ case EE_CHAR_STRIKEOUT: nWhich = RES_CHRATR_CROSSEDOUT; break;
+ case EE_CHAR_ITALIC: nWhich = RES_CHRATR_POSTURE; break;
+ case EE_CHAR_OUTLINE: nWhich = RES_CHRATR_CONTOUR; break;
+ case EE_CHAR_SHADOW: nWhich = RES_CHRATR_SHADOWED; break;
+ case EE_CHAR_ESCAPEMENT: nWhich = RES_CHRATR_ESCAPEMENT; break;
+ case EE_CHAR_PAIRKERNING: nWhich = RES_CHRATR_AUTOKERN; break;
+ case EE_CHAR_KERNING: nWhich = RES_CHRATR_KERNING; break;
+ case EE_CHAR_WLM: nWhich = RES_CHRATR_WORDLINEMODE; break;
+ case EE_FEATURE_NOTCONV: nWhich = RES_CHRATR_CHARSETCOLOR; break;
+
+ default:
+// case EE_PARA_NUMBULLET:
+// case EE_PARA_HYPHENATE:
+// case EE_PARA_BULLETSTATE:
+// case EE_PARA_OUTLLRSPACE:
+// case EE_PARA_OUTLLEVEL:
+// case EE_PARA_BULLET:
+//ITEMID_FONTWIDTH EE_CHAR_FONTWIDTH
+ nWhich = 0;
+ break;
+ }
+ return nWhich;
+}
+
+class WW8_SdrAttrIter : public WW8_AttrIter
+{
+ const EditTextObject* pEditObj;
+ EECharAttribArray aTxtAtrArr;
+ SvPtrarr aChrTxtAtrArr;
+ SvUShorts aChrSetArr;
+ USHORT nPara;
+ xub_StrLen nAktSwPos;
+ xub_StrLen nTmpSwPos; // fuer HasItem()
+ rtl_TextEncoding eNdChrSet;
+
+ xub_StrLen SearchNext( xub_StrLen nStartPos );
+ void SetCharSet( const EECharAttrib& rTxtAttr, BOOL bStart );
+
+public:
+ WW8_SdrAttrIter( SwWW8Writer& rWr, const EditTextObject& rEditObj );
+ void NextPara( USHORT nPar );
+ void OutParaAttr( BOOL bCharAttr );
+
+ BOOL IsTxtAttr( xub_StrLen nSwPos );
+
+ void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); }
+
+ void OutAttr( xub_StrLen nSwPos );
+ virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const;
+ virtual const SfxPoolItem& GetItem( USHORT nWhich ) const;
+ BOOL OutAttrWithRange( xub_StrLen nPos );
+ xub_StrLen WhereNext() const { return nAktSwPos; }
+ rtl_TextEncoding GetNextCharSet() const;
+ rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; }
+};
+
+
+WW8_SdrAttrIter::WW8_SdrAttrIter( SwWW8Writer& rWr,
+ const EditTextObject& rEditObj )
+ : WW8_AttrIter( rWr ), pEditObj( &rEditObj ),
+ aTxtAtrArr( 0, 4 ), aChrTxtAtrArr( 0, 4 ), aChrSetArr( 0, 4 )
+{
+ NextPara( 0 );
+}
+
+void WW8_SdrAttrIter::NextPara( USHORT nPar )
+{
+ nPara = nPar;
+ // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen
+ // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben
+ // werden.
+ aChrTxtAtrArr.Remove( 0, aChrTxtAtrArr.Count() );
+ aChrSetArr.Remove( 0, aChrSetArr.Count() );
+ nAktSwPos = nTmpSwPos = 0;
+
+ SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
+ eNdChrSet = ((SvxFontItem&)aSet.Get( EE_CHAR_FONTINFO )).GetCharSet();
+ pEditObj->GetCharAttribs( nPara, aTxtAtrArr );
+ nAktSwPos = SearchNext( 1 );
+}
+
+rtl_TextEncoding WW8_SdrAttrIter::GetNextCharSet() const
+{
+ if( aChrSetArr.Count() )
+ return (rtl_TextEncoding)aChrSetArr[ aChrSetArr.Count() - 1 ];
+ return eNdChrSet;
+}
+
+// der erste Parameter in SearchNext() liefert zurueck, ob es ein TxtAtr ist.
+xub_StrLen WW8_SdrAttrIter::SearchNext( xub_StrLen nStartPos )
+{
+ register xub_StrLen nPos;
+ register xub_StrLen nMinPos = STRING_MAXLEN;
+ register xub_StrLen i;
+
+ for( i = 0; i < aTxtAtrArr.Count(); i++ )
+ {
+ const EECharAttrib& rHt = aTxtAtrArr[ i ];
+ nPos = rHt.nStart; // gibt erstes Attr-Zeichen
+ if( nPos >= nStartPos && nPos <= nMinPos )
+ {
+ nMinPos = nPos;
+ SetCharSet( rHt, TRUE );
+ }
+
+//?? if( pHt->GetEnd() ) // Attr mit Ende
+ {
+ nPos = rHt.nEnd; // gibt letztes Attr-Zeichen + 1
+ if( nPos >= nStartPos && nPos < nMinPos )
+ {
+ nMinPos = nPos;
+ SetCharSet( rHt, FALSE );
+ }
+ }
+/* else
+ { // Attr ohne Ende
+ nPos = rHt.nStart + 1; // Laenge 1 wegen CH_TXTATR im Text
+ if( nPos >= nStartPos && nPos < nMinPos )
+ {
+ nMinPos = nPos;
+ SetCharSet( rHt, FALSE );
+ }
+ }
+*/
+ }
+ return nMinPos;
+}
+
+void WW8_SdrAttrIter::SetCharSet( const EECharAttrib& rAttr, BOOL bStart )
+{
+ void* p = 0;
+ rtl_TextEncoding eChrSet;
+ const SfxPoolItem& rItem = *rAttr.pAttr;
+ switch( rItem.Which() )
+ {
+ case EE_CHAR_FONTINFO:
+ p = (void*)&rAttr;
+ eChrSet = ((SvxFontItem&)rItem).GetCharSet();
+ break;
+ }
+
+ if( p )
+ {
+ USHORT nPos;
+ if( bStart )
+ {
+ nPos = aChrSetArr.Count();
+ aChrSetArr.Insert( eChrSet, nPos );
+ aChrTxtAtrArr.Insert( p, nPos );
+ }
+ else if( USHRT_MAX != ( nPos = aChrTxtAtrArr.GetPos( p )) )
+ {
+ aChrTxtAtrArr.Remove( nPos );
+ aChrSetArr.Remove( nPos );
+ }
+ }
+}
+
+void WW8_SdrAttrIter::OutAttr( xub_StrLen nSwPos )
+{
+ OutParaAttr( TRUE );
+
+ if( aTxtAtrArr.Count() )
+ {
+ const SwModify* pOldMod = rWrt.pOutFmtNode;
+ rWrt.pOutFmtNode = 0;
+
+ nTmpSwPos = nSwPos;
+ register USHORT i, nWhich;
+ FnAttrOut pOut;
+ for( i = 0; i < aTxtAtrArr.Count(); i++ )
+ {
+ const EECharAttrib& rHt = aTxtAtrArr[ i ];
+ if( nSwPos >= rHt.nStart && nSwPos < rHt.nEnd &&
+ 0 != ( nWhich = rWrt.TranslateFromEditEngineId(
+ rHt.pAttr->Which() )) &&
+ 0 != ( pOut = aWW8AttrFnTab[ nWhich - RES_CHRATR_BEGIN ] ) )
+
+ (*pOut)( rWrt, *rHt.pAttr );
+
+ else if( nSwPos < rHt.nStart )
+ break;
+ }
+
+ nTmpSwPos = 0; // HasTextItem nur in dem obigen Bereich erlaubt
+ rWrt.pOutFmtNode = pOldMod;
+ }
+}
+
+BOOL WW8_SdrAttrIter::IsTxtAttr( xub_StrLen nSwPos )
+{
+// solange die EditEngine keine Attribute hat, die nur eine Position haben
+return FALSE;
+
+ // search for attrs without end position
+ register USHORT i;
+ for( i = 0; i < aTxtAtrArr.Count(); i++ )
+ if( aTxtAtrArr[ i ].nStart == nSwPos )
+ return TRUE;
+ return FALSE;
+}
+
+// HasItem ist fuer die Zusammenfassung des Doppel-Attributes Underline
+// und WordLineMode als TextItems. OutAttr() ruft die Ausgabefunktion,
+// die dann ueber HasItem() nach anderen Items an der
+// Attribut-Anfangposition fragen kann.
+// Es koennen nur Attribute mit Ende abgefragt werden.
+// Es wird mit bDeep gesucht
+const SfxPoolItem* WW8_SdrAttrIter::HasTextItem( USHORT nWhich ) const
+{
+ const SfxPoolItem* pRet = 0;
+ if( 0 != ( nWhich = rWrt.TranslateToEditEngineId( nWhich )) )
+ {
+ register USHORT i;
+ for( i = 0; i < aTxtAtrArr.Count(); ++i )
+ {
+ const EECharAttrib& rHt = aTxtAtrArr[ i ];
+ if( nWhich == rHt.pAttr->Which() &&
+ nTmpSwPos >= rHt.nStart && nTmpSwPos < rHt.nEnd )
+ {
+ pRet = rHt.pAttr; // gefunden
+ break;
+ }
+ else if( nTmpSwPos < rHt.nStart )
+ break; // dann kommt da nichts mehr
+ }
+ }
+ return pRet;
+}
+
+const SfxPoolItem& WW8_SdrAttrIter::GetItem( USHORT nWhich ) const
+{
+ const SfxPoolItem* pRet = HasTextItem( nWhich );
+ if( !pRet )
+ {
+ SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
+ pRet = &aSet.Get( rWrt.TranslateToEditEngineId( nWhich ) );
+ }
+ return *pRet;
+}
+
+void WW8_SdrAttrIter::OutParaAttr( BOOL bCharAttr )
+{
+ SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
+ if( aSet.Count() )
+ {
+ const SfxItemSet* pOldSet = rWrt.GetCurItemSet();
+ rWrt.SetCurItemSet( &aSet );
+
+ SfxItemIter aIter( aSet );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ FnAttrOut pOut;
+
+ do {
+ USHORT nWhich = rWrt.TranslateFromEditEngineId( pItem->Which() );
+ if( nWhich && 0 != ( pOut =
+ aWW8AttrFnTab[ nWhich - RES_CHRATR_BEGIN ] )
+ && ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN
+ && nWhich < RES_TXTATR_END)
+ : (nWhich >= RES_PARATR_BEGIN
+ && nWhich < RES_FRMATR_END) ) )
+ (*pOut)( rWrt, *pItem );
+
+ } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
+ rWrt.SetCurItemSet( pOldSet );
+ }
+}
+
+void SwWW8Writer::WriteSdrTextObj( const SdrObject& rObj )
+{
+ const SdrTextObj* pTxtObj = PTR_CAST( SdrTextObj, &rObj );
+ ASSERT( pTxtObj, "das ist gar kein SdrTextObj!" );
+
+ BOOL bAnyWrite = FALSE;
+ const OutlinerParaObject* pParaObj = pTxtObj->GetOutlinerParaObject();
+ if( pParaObj )
+ {
+ const EditTextObject& rEditObj = pParaObj->GetTextObject();
+ WW8_SdrAttrIter aAttrIter( *this, rEditObj );
+
+ USHORT nPara = rEditObj.GetParagraphCount();
+ BYTE bNul = 0;
+ for( USHORT n = 0; n < nPara; ++n )
+ {
+ if( n )
+ aAttrIter.NextPara( n );
+
+ rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
+
+ ASSERT( !pO->Count(), " pO ist am Zeilenanfang nicht leer" );
+
+ String aStr( rEditObj.GetText( n ));
+ xub_StrLen nAktPos = 0;
+ xub_StrLen nEnd = aStr.Len();
+ BOOL bUnicode = TRUE;
+ do {
+/*
+ switch( eChrSet )
+ {
+ // case CHARSET_DONTKNOW: ????
+ case CHARSET_SYMBOL:
+ // case CHARSET_WIN_SYMBOL:
+ // case CHARSET_WIN_WINGDINGS:
+ // case CHARSET_MAC_DINGBATS:
+ // case CHARSET_MAC_SYMBOL:
+ // case CHARSET_ADOBE_SYMBOL:
+ // case CHARSET_ADOBE_DINGBATS:
+ // case CHARSET_STAR_STARBATS:
+ // case CHARSET_STAR_STARMATH:
+ bUnicode = bWrtWW8 ? TRUE : FALSE;
+ break;
+ default:
+ bUnicode = FALSE;
+ break;
+ }
+*/
+ xub_StrLen nNextAttr = aAttrIter.WhereNext();
+ rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
+
+ if( nNextAttr > nEnd )
+ nNextAttr = nEnd;
+
+ BOOL bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
+ if( !bTxtAtr )
+ OutSwString( aStr, nAktPos, nNextAttr - nAktPos,
+ bUnicode, eChrSet );
+
+ // Am Zeilenende werden die Attribute bis ueber das CR
+ // aufgezogen. Ausnahme: Fussnoten am Zeilenende
+ if( nNextAttr == nEnd && !bTxtAtr )
+ WriteCR(); // CR danach
+
+ // Ausgabe der Zeichenattribute
+ aAttrIter.OutAttr( nAktPos ); // nAktPos - 1 ??
+ pChpPlc->AppendFkpEntry( Strm().Tell(),
+ pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+
+ // Ausnahme: Fussnoten am Zeilenende
+ if( nNextAttr == nEnd && bTxtAtr )
+ WriteCR(); // CR danach
+
+ nAktPos = nNextAttr;
+ eChrSet = eNextChrSet;
+ aAttrIter.NextPos();
+ }
+ while( nAktPos < nEnd );
+
+ ASSERT( !pO->Count(), " pO ist am ZeilenEnde nicht leer" );
+
+ pO->Insert( bNul, pO->Count() ); // Style # as short
+ pO->Insert( bNul, pO->Count() );
+
+ aAttrIter.OutParaAttr( FALSE );
+
+ ULONG nPos = Strm().Tell();
+ pPapPlc->AppendFkpEntry( Strm().Tell(),
+ pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+ pChpPlc->AppendFkpEntry( nPos );
+ }
+ bAnyWrite = 0 != nPara;
+ }
+ if( !bAnyWrite )
+ WriteStringAsPara( aEmptyStr );
+}
+
+/* */
+
+class SwEscherEx : public EscherEx
+{
+ // private members
+ SvULongs aFollowShpIds;
+ SvPtrarr aSortFmts;
+ SwWW8Writer& rWrt;
+ WW8_WrPlcTxtBoxes *pTxtBxs;
+ SvStream* pEscherStrm, *pPictStrm;
+ long nEmuMul, nEmuDiv;
+
+ // private methods
+ void Init();
+
+ UINT32 GetFlyShapeId( const SwFrmFmt& rFmt );
+ void MakeZOrderArrAndFollowIds( const SvPtrarr& rSrcArr );
+
+ INT32 ToFract16( INT32 nVal, UINT32 nMax ) const
+ {
+ INT32 nMSVal = ( nVal / 65536) * nMax;
+ nMSVal += ( nVal * 65536 ) / nMax;
+ return nMSVal;
+ }
+ INT32 DrawModelToEmu( INT32 nVal ) const
+ { return BigMulDiv( nVal, nEmuMul, nEmuDiv ); }
+
+ void WriteTxtFlyFrame( const SwFrmFmt& rFmt, UINT32 nShapeId,
+ UINT32 nTxtBox );
+ void WriteGrfFlyFrame( const SwFrmFmt& rFmt, UINT32 nShapeId );
+ void WriteOLEFlyFrame( const SwFrmFmt& rFmt, UINT32 nShapeId );
+ void WriteFlyFrameAttr( const SwFrmFmt& rFmt );
+ void WriteGrfAttr( const SwNoTxtNode& rNd );
+
+ UINT32 WriteFlyFrm( const SwFrmFmt& rFmt );
+
+ virtual SvStream* QueryPicStream();
+ virtual UINT32 QueryTextID( const uno::Reference< drawing::XShape>& , UINT32 );
+
+ SwEscherEx( const SwEscherEx& );
+public:
+ SwEscherEx( SvStream* pStrm, SwWW8Writer& rWW8Wrt );
+ virtual ~SwEscherEx();
+
+ void FinishEscher();
+ void WritePictures();
+};
+
+
+/* */
+
+void SwWW8Writer::CreateEscher()
+{
+ if(pHFSdrObjs->GetCntntArr().Count() || pSdrObjs->GetCntntArr().Count())
+ {
+ ASSERT( !pEscher, "wer hat den Pointer nicht geloescht?" );
+ SvStream* pEscherStrm = pStg->OpenStream( sEscherStream,
+ STREAM_READWRITE | STREAM_SHARE_DENYALL );
+ pEscherStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ pEscher = new SwEscherEx( pEscherStrm, *this );
+ }
+}
+
+void SwWW8Writer::WriteEscher()
+{
+ if( pEscher )
+ {
+ ULONG nStart = pTableStrm->Tell();
+
+ pEscher->WritePictures();
+ pEscher->FinishEscher();
+
+ pFib->fcDggInfo = nStart;
+ pFib->lcbDggInfo = pTableStrm->Tell() - nStart;
+ delete pEscher, pEscher = 0;
+ }
+}
+
+
+/* */
+
+// Output- Routines for Escher Export
+
+SwEscherEx::SwEscherEx( SvStream* pStrm, SwWW8Writer& rWW8Wrt )
+/* : SvxEscherEx( *pStrm,
+ rWW8Wrt.pHFSdrObjs->GetCntntArr().Count() ? 2 : 1,
+ *rWW8Wrt.pDoc->GetDrawModel(),
+ 1440 ),
+*/
+ : EscherEx( *pStrm, rWW8Wrt.pHFSdrObjs->GetCntntArr().Count() ? 2 : 1 ),
+ rWrt( rWW8Wrt ), pTxtBxs( 0 ), pEscherStrm( pStrm ), pPictStrm( 0 )
+{
+ Init();
+ OpenContainer( ESCHER_DggContainer );
+ BeginCount();
+ AddColor( 0x08000004 );
+ AddColor( 0x08000001 );
+ AddColor( 0x08000002 );
+ AddColor( 0x100000f7 );
+ EndCount( ESCHER_SplitMenuColors );
+ CloseContainer(); // ESCHER_DggContainer
+
+ BYTE i = 2; // for header/footer and the other
+ WW8_WrPlcDrawObj *pSdrObjs = rWrt.pHFSdrObjs;
+ pTxtBxs = rWrt.pHFTxtBxs;
+
+ if( !pSdrObjs->GetCntntArr().Count() ) // if no header/footer -> skip over
+ {
+ --i;
+ pSdrObjs = rWrt.pSdrObjs;
+ pTxtBxs = rWrt.pTxtBxs;
+ }
+
+ for( ; i--; pSdrObjs = rWrt.pSdrObjs, pTxtBxs = rWrt.pTxtBxs )
+ {
+ // "dummy char" (or any Count ?) - why? This knows only M$
+ GetStream() << (sal_Char)i;
+
+ OpenContainer( ESCHER_DgContainer );
+
+ EnterGroup( 0 );
+
+ ULONG nSecondShapeId = pSdrObjs == rWrt.pSdrObjs
+ ? GetShapeID() : 0;
+
+ // write now all Writer-/DrawObjects
+ MakeZOrderArrAndFollowIds( pSdrObjs->GetCntntArr() );
+
+ ULONG nShapeId;
+ for( USHORT n = 0; n < aSortFmts.Count(); ++n )
+ {
+ const SwFrmFmt& rFmt = *(SwFrmFmt*)aSortFmts[ n ];
+ if( RES_FLYFRMFMT == rFmt.Which() )
+ nShapeId = WriteFlyFrm( rFmt );
+ else
+ {
+ const SdrObject* pObj = rFmt.FindRealSdrObject();
+ if( pObj )
+ {
+ nShapeId = AddSdrObject( *pObj );
+ }
+#ifndef PRODUCT
+ else
+ ASSERT( !this, "wo ist das SDR-Object?" );
+#endif
+ }
+
+ if( !nShapeId )
+ {
+ /*!!!*/ const SdrObject* pObj = 0;
+ nShapeId = AddDummyShape( *pObj );
+ }
+
+ pSdrObjs->SetShapeId( rFmt, nShapeId );
+ }
+
+ EndSdrObjectPage(); // ???? Bugfix for 74724
+
+ LeaveGroup();
+
+ if( nSecondShapeId )
+ {
+ OpenContainer( ESCHER_SpContainer );
+
+ AddShape( ESCHER_ShpInst_Rectangle, 0xe00, nSecondShapeId );
+
+ BeginCount();
+ // default Fuellfarbe ist das StarOffice blau7
+ // ----> von DrawingLayer besorgen !!
+ AddOpt( ESCHER_Prop_fillColor, 0xffb800 );
+ AddOpt( ESCHER_Prop_fillBackColor, 0 );
+ AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00100010 );
+ AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
+ AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
+ AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
+ AddOpt( ESCHER_Prop_lineWidth, 0 );
+
+// winword defaults!
+// AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100000 );
+// AddOpt( ESCHER_Prop_lineWidth, 0 );
+// AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
+// AddOpt( ESCHER_Prop_bWMode, 0x9 );
+// AddOpt( ESCHER_Prop_fBackground, 0x10001 );
+
+ EndCount( ESCHER_OPT, 3 );
+
+ AddAtom( 4, ESCHER_ClientData );
+ GetStream() << 1L;
+
+ CloseContainer(); // ESCHER_SpContainer
+ }
+ CloseContainer(); // ESCHER_DgContainer
+ }
+}
+
+SwEscherEx::~SwEscherEx()
+{
+}
+
+void SwEscherEx::Init()
+{
+ SdrModel& rModel = *rWrt.pDoc->GetDrawModel();
+ // PPT arbeitet nur mit Einheiten zu 576DPI
+ // WW hingegen verwendet twips, dh. 1440DPI.
+ MapUnit eMap = rModel.GetScaleUnit();
+
+// Fraction aFact( nAppScale );
+// aFact /= GetMapFactor( MAP_INCH, eMap ).X();
+ // create little values
+// aFact = Fraction( aFact.GetNumerator(), aFact.GetDenominator() );
+
+ // Bei 100TH_MM -> 2540/576=635/144
+ // Bei Twip -> 1440/576=5/2
+// nMapMul = aFact.GetNumerator();
+// nMapDiv = aFact.GetDenominator();
+// bNeedMap = nMapMul != nMapDiv;
+
+ // MS-DFF-Properties sind grossteils in EMU (English Metric Units) angegeben
+ // 1mm=36000emu, 1twip=635emu
+ Fraction aFact( 360, 1 );
+// aFact = Fraction( 360, 1 );
+ aFact /= GetMapFactor( MAP_100TH_MM, eMap ).X();
+ // create little values
+ aFact = Fraction( aFact.GetNumerator(), aFact.GetDenominator() );
+ nEmuMul = aFact.GetNumerator();
+ nEmuDiv = aFact.GetDenominator();
+
+ // Und noch was fuer typografische Points
+// aFact = Fraction( 1, 1 );
+// aFact /= GetMapFactor(MAP_POINT,eMap).X();
+// nPntMul = aFact.GetNumerator();
+// nPntDiv = aFact.GetDenominator();
+
+ SetHellLayerId( rWrt.pDoc->GetHellId() );
+}
+
+void SwEscherEx::WritePictures()
+{
+ if( pPictStrm )
+ {
+ // set the blip - entries to the correct stream pos
+ INT32 nEndPos = rWrt.Strm().Tell();
+ SetNewBlipStreamOffset( nEndPos );
+
+ pPictStrm->Seek( 0 );
+ rWrt.Strm() << *pPictStrm;
+
+ delete pPictStrm, pPictStrm = 0;
+ rWrt.GetStorage().Remove( sEscherPictStream );
+ }
+ Flush();
+}
+
+void SwEscherEx::FinishEscher()
+{
+ pEscherStrm->Seek( 0 );
+ *rWrt.pTableStrm << *pEscherStrm;
+
+ delete pEscherStrm, pEscherStrm = 0;
+ rWrt.GetStorage().Remove( sEscherStream );
+}
+
+
+UINT32 SwEscherEx::WriteFlyFrm( const SwFrmFmt& rFmt )
+{
+ // check for textflyframe and if it is the first in a Chain
+ UINT32 nShapeId = 0;
+ const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx();
+ if( pNdIdx )
+ {
+ SwNodeIndex aIdx( *pNdIdx, 1 );
+ switch( aIdx.GetNode().GetNodeType() )
+ {
+ case ND_GRFNODE:
+ WriteGrfFlyFrame( rFmt, nShapeId =GetShapeID() );
+ break;
+
+ case ND_OLENODE:
+ WriteOLEFlyFrame( rFmt, nShapeId =GetShapeID() );
+ break;
+
+ default:
+ {
+ const SdrObject* pObj = rFmt.FindRealSdrObject();
+ if( pObj )
+ {
+ // check for the first in a Chain
+ UINT32 nTxtId;
+ USHORT nOff = 0;
+ const SwFrmFmt* pFmt = &rFmt, *pPrev;
+ while( 0 != ( pPrev = pFmt->GetChain().GetPrev() ))
+ {
+ ++nOff;
+ pFmt = pPrev;
+ }
+
+ nShapeId = GetFlyShapeId( rFmt );
+ if( !nOff )
+ {
+ void* p = (void*)pObj;
+ nTxtId = pTxtBxs->GetPos( p );
+ if( USHRT_MAX == nTxtId )
+ {
+ pTxtBxs->Append( *pObj, nShapeId );
+ nTxtId = pTxtBxs->Count();
+ }
+ else
+ ++nTxtId;
+ }
+ else
+ {
+ const SdrObject* pPrevObj = pFmt->FindRealSdrObject();
+ void* p = (void*)pPrevObj;
+ nTxtId = pTxtBxs->GetPos( p );
+ if( USHRT_MAX == nTxtId )
+ {
+ UINT32 nPrevShapeId = GetFlyShapeId( *pFmt );
+ pTxtBxs->Append( *pPrevObj, nPrevShapeId );
+ nTxtId = pTxtBxs->Count();
+ }
+ else
+ ++nTxtId;
+ }
+ nTxtId *= 0x10000;
+ nTxtId += nOff;
+
+ WriteTxtFlyFrame( rFmt, nShapeId, nTxtId );
+ }
+ }
+ }
+ }
+ return nShapeId;
+}
+
+void SwEscherEx::WriteTxtFlyFrame( const SwFrmFmt& rFmt, UINT32 nShapeId,
+ UINT32 nTxtBox )
+{
+ OpenContainer( ESCHER_SpContainer );
+
+ AddShape( ESCHER_ShpInst_TextBox, 0xa00, nShapeId );
+
+ BeginCount();
+
+ AddOpt( ESCHER_Prop_lTxid, nTxtBox );
+
+ const VoidPtr pNext = rFmt.GetChain().GetNext();
+ if( pNext )
+ {
+ USHORT nPos = aSortFmts.GetPos( pNext );
+ if( USHRT_MAX != nPos && aFollowShpIds[ nPos ] )
+ AddOpt( ESCHER_Prop_hspNext, aFollowShpIds[ nPos ] );
+ }
+
+ WriteFlyFrameAttr( rFmt );
+
+ EndCount( ESCHER_OPT, 3 );
+
+ AddAtom( 4, ESCHER_ClientAnchor ); GetStream() << 0L;
+ AddAtom( 4, ESCHER_ClientData ); GetStream() << 1L;
+ AddAtom( 4, ESCHER_ClientTextbox ); GetStream() << nTxtBox;
+
+ CloseContainer(); // ESCHER_SpContainer
+}
+
+void SwEscherEx::WriteGrfFlyFrame( const SwFrmFmt& rFmt, UINT32 nShapeId )
+{
+ OpenContainer( ESCHER_SpContainer );
+
+ AddShape( ESCHER_ShpInst_PictureFrame, 0xa00, nShapeId );
+
+ BeginCount();
+
+ UINT32 nFlags = ESCHER_BlipFlagDefault;
+ SwNodeIndex aIdx( *rFmt.GetCntnt().GetCntntIdx(), 1 );
+ SwGrfNode& rGrfNd = *aIdx.GetNode().GetGrfNode();
+ if( rGrfNd.IsLinkedFile() )
+ {
+ String sURL;
+ rGrfNd.GetFileFilterNms( &sURL, 0 );
+
+ WW8Bytes aBuf;
+ SwWW8Writer::InsAsString16( aBuf, sURL );
+ SwWW8Writer::InsUInt16( aBuf, 0 );
+
+ USHORT nArrLen = aBuf.Count();
+ BYTE* pArr = new BYTE[ nArrLen ];
+ memcpy( pArr, aBuf.GetData(), nArrLen );
+
+ AddOpt( ESCHER_Prop_pibName, TRUE, nArrLen, pArr, nArrLen );
+ nFlags = ESCHER_BlipFlagLinkToFile | ESCHER_BlipFlagURL |
+ ESCHER_BlipFlagDoNotSave;
+ }
+ else
+ {
+ rGrfNd.SwapIn( TRUE );
+ AddOpt( ESCHER_Prop_pib, AddGraphic( *QueryPicStream(),
+ rGrfNd.GetGrf() ), TRUE );
+ }
+ AddOpt( ESCHER_Prop_pibFlags, nFlags );
+
+ WriteFlyFrameAttr( rFmt );
+ WriteGrfAttr( rGrfNd );
+
+ EndCount( ESCHER_OPT, 3 );
+
+ AddAtom( 4, ESCHER_ClientAnchor ); GetStream() << 0L;
+ AddAtom( 4, ESCHER_ClientData ); GetStream() << 1L;
+
+ CloseContainer(); // ESCHER_SpContainer
+}
+
+void SwEscherEx::WriteOLEFlyFrame( const SwFrmFmt& rFmt, UINT32 nShapeId )
+{
+ SwNodeIndex aIdx( *rFmt.GetCntnt().GetCntntIdx(), 1 );
+ SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
+ const SvInPlaceObjectRef xObj( rOLENd.GetOLEObj().GetOleRef() );
+ SvData aData( FORMAT_GDIMETAFILE );
+ GDIMetaFile* pMtf;
+
+ const SdrObject* pSdrObj = rFmt.FindRealSdrObject();
+ if( pSdrObj && xObj->GetData( &aData ) &&
+ aData.GetData( &pMtf, TRANSFER_MOVE ) )
+ {
+ OpenContainer( ESCHER_SpContainer );
+
+ AddShape( ESCHER_ShpInst_PictureFrame, 0xa10, nShapeId );
+
+ BeginCount();
+
+ {
+ SvMemoryStream aGrfStrm;
+ WriteWindowMetafile( aGrfStrm, *pMtf );
+ const BYTE* pMem = (BYTE*)aGrfStrm.GetData();
+ UINT32 nLen = aGrfStrm.GetSize();
+ Size aSz( rOLENd.GetTwipSize() );
+ aSz.Width() = DrawModelToEmu( aSz.Width() );
+ aSz.Height() = DrawModelToEmu( aSz.Height() );
+ Rectangle aRect( Point(0,0), aSz );
+ AddOpt( ESCHER_Prop_pib, AddWMF( *QueryPicStream(),
+ pMem + 22, nLen - 22, aRect ), TRUE );
+ }
+ pTxtBxs->Append( *pSdrObj, nShapeId );
+ UINT32 nPicId = pTxtBxs->Count();
+ nPicId *= 0x10000;
+ AddOpt( ESCHER_Prop_pictureId, nPicId );
+ AddOpt( ESCHER_Prop_pictureActive, 0x10000 );
+
+ WriteFlyFrameAttr( rFmt );
+ WriteGrfAttr( rOLENd );
+
+ EndCount( ESCHER_OPT, 3 );
+
+ AddAtom( 4, ESCHER_ClientAnchor ); GetStream() << 0L;
+ AddAtom( 4, ESCHER_ClientData ); GetStream() << 1L;
+
+ CloseContainer(); // ESCHER_SpContainer
+ }
+}
+
+
+void SwEscherEx::WriteGrfAttr( const SwNoTxtNode& rNd )
+{
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rNd.GetSwAttrSet().GetItemState( RES_GRFATR_CROPGRF,
+ TRUE, &pItem ))
+ {
+ const Size aSz( rNd.GetTwipSize() );
+ INT32 nVal;
+ if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetLeft() ) )
+ AddOpt( ESCHER_Prop_cropFromLeft, ToFract16( nVal, aSz.Width()) );
+ if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetRight() ) )
+ AddOpt( ESCHER_Prop_cropFromRight, ToFract16( nVal, aSz.Width()));
+ if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetTop() ) )
+ AddOpt( ESCHER_Prop_cropFromTop, ToFract16( nVal, aSz.Height()));
+ if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetBottom() ) )
+ AddOpt( ESCHER_Prop_cropFromBottom, ToFract16( nVal, aSz.Height()));
+ }
+ // mirror ??
+}
+
+void SwEscherEx::WriteFlyFrameAttr( const SwFrmFmt& rFmt )
+{
+ const SfxPoolItem* pItem;
+ BOOL bFirstLine = TRUE;
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_BOX, TRUE, &pItem ) )
+ {
+ static UINT16 __READONLY_DATA aExhperProp[ 4 ] = {
+ ESCHER_Prop_dyTextTop, ESCHER_Prop_dyTextBottom,
+ ESCHER_Prop_dxTextLeft, ESCHER_Prop_dxTextRight
+ };
+ const SvxBorderLine* pLine;
+
+ for( int n = 0; n < 4; ++n )
+ if( 0 != ( pLine = ((SvxBoxItem*)pItem)->GetLine( n )) )
+ {
+ if( bFirstLine )
+ {
+ UINT32 nLineColor = GetColor( pLine->GetColor(), FALSE );
+ AddOpt( ESCHER_Prop_lineColor, nLineColor );
+ AddOpt( ESCHER_Prop_lineBackColor, nLineColor ^ 0xffffff );
+
+ UINT32 nLineWidth;
+ ESCHER_LineStyle eStyle;
+ if( pLine->GetInWidth() )
+ {
+ // double line
+ nLineWidth = pLine->GetInWidth() +
+ pLine->GetOutWidth() +
+ pLine->GetDistance();
+ if( pLine->GetInWidth() == pLine->GetOutWidth() )
+ eStyle = ESCHER_LineDouble;
+ else if( pLine->GetInWidth() < pLine->GetOutWidth() )
+ eStyle = ESCHER_LineThickThin;
+ else
+ eStyle = ESCHER_LineThinThick;
+ }
+ else
+ {
+ // simple line
+ eStyle = ESCHER_LineSimple;
+ nLineWidth = pLine->GetOutWidth();
+ }
+
+ AddOpt( ESCHER_Prop_lineStyle, eStyle );
+ AddOpt( ESCHER_Prop_lineWidth, DrawModelToEmu( nLineWidth ));
+
+ bFirstLine = FALSE;
+ }
+
+ AddOpt( aExhperProp[ n ], DrawModelToEmu(
+ ((SvxBoxItem*)pItem)->GetDistance( n ) ));
+ }
+ }
+ if( bFirstLine ) // no valid line found
+ {
+ AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
+ AddOpt( ESCHER_Prop_dyTextTop, 0 );
+ AddOpt( ESCHER_Prop_dyTextBottom, 0 );
+ AddOpt( ESCHER_Prop_dxTextLeft, 0 );
+ AddOpt( ESCHER_Prop_dxTextRight, 0 );
+ }
+
+ // write shadow
+/*
+ WinWord dont know any shadow at textboxes
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_SHADOW, TRUE, &pItem ) )
+ {
+ mpEscherEx->AddOpt( ESCHER_Prop_fshadowObscured, 0x20002 );
+ if( rObj.ImplGetPropertyValue( C2U("ShadowColor") ) )
+ mpEscherEx->AddOpt( ESCHER_Prop_shadowColor,
+ mpEscherEx->GetColor(
+ *((UINT32*)rObj.GetUsrAny().get()) ) );
+
+
+ if ( rObj.ImplGetPropertyValue( C2U("Shadow") ) )
+ {
+ if ( rObj.GetUsrAny().getBOOL() )
+ {
+ if( rObj.ImplGetPropertyValue( C2U("ShadowXDistance") ) )
+ mpEscherEx->AddOpt( ESCHER_Prop_shadowOffsetX,
+ *((INT32*)rObj.GetUsrAny().get()) * 360 );
+ if( rObj.ImplGetPropertyValue( C2U("ShadowYDistance") ) )
+ mpEscherEx->AddOpt( ESCHER_Prop_shadowOffsetY,
+ *((INT32*)rObj.GetUsrAny().get()) * 360 );
+ if( rObj.ImplGetPropertyValue( C2U("ShadowTransparence") ) )
+ mpEscherEx->AddOpt( ESCHER_Prop_shadowOpacity,
+ ( ( 100 - (*((UINT16*)rObj.GetUsrAny().get()) )
+ << 16 ) / 100 ) );
+ }
+ }
+ }
+*/
+
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_BACKGROUND, TRUE, &pItem ) )
+ {
+ if( /* ((SvxBrushItem*)pItem)->GetGraphicLink() || */
+ ((SvxBrushItem*)pItem)->GetGraphic() )
+ {
+/* if( ((SvxBrushItem*)pItem)->GetGraphicLink() )
+ {
+ AddOpt( ESCHER_Prop_fillBlipName, TRUE,
+ // wie jetzt ??
+ AddOpt( UINT16 nPropertyID, BOOL bBlib, UINT32 nPropValue,
+ BYTE* pProp, UINT32 nPropSize );
+ }
+ else
+*/
+ {
+ AddOpt( ESCHER_Prop_fillBlip, AddGraphic( *QueryPicStream(),
+ *((SvxBrushItem*)pItem)->GetGraphic() ),
+ TRUE );
+ }
+ AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture );
+ AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
+ AddOpt( ESCHER_Prop_fillBackColor, 0 );
+ }
+ else if( !((SvxBrushItem*)pItem)->GetColor().GetTransparency() )
+ {
+ UINT32 nFillColor = GetColor( ((SvxBrushItem*)pItem)->
+ GetColor(), FALSE );
+ AddOpt( ESCHER_Prop_fillColor, nFillColor );
+ AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff );
+ AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
+ }
+ else
+ {
+ AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100000 );
+ }
+ }
+
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_LR_SPACE, TRUE, &pItem ))
+ {
+ AddOpt( ESCHER_Prop_dxWrapDistLeft,
+ DrawModelToEmu( ((SvxLRSpaceItem*)pItem)->GetLeft() ) );
+ AddOpt( ESCHER_Prop_dxWrapDistRight,
+ DrawModelToEmu( ((SvxLRSpaceItem*)pItem)->GetRight() ) );
+ }
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_UL_SPACE, TRUE, &pItem ))
+ {
+ AddOpt( ESCHER_Prop_dyWrapDistTop,
+ DrawModelToEmu( ((SvxULSpaceItem*)pItem)->GetUpper() ) );
+ AddOpt( ESCHER_Prop_dyWrapDistBottom,
+ DrawModelToEmu( ((SvxULSpaceItem*)pItem)->GetLower() ) );
+ }
+
+ const SdrObject* pObj = rFmt.FindRealSdrObject();
+ if( pObj && pObj->GetLayer() == GetHellLayerId() )
+ AddOpt( ESCHER_Prop_fPrint, 0x200020 );
+}
+
+void SwEscherEx::MakeZOrderArrAndFollowIds( const SvPtrarr& rSrcArr )
+{
+ if( aSortFmts.Count() )
+ aSortFmts.Remove( 0, aSortFmts.Count() );
+
+ USHORT n, nPos, nCnt = rSrcArr.Count();
+ SvULongsSort aSort( 255 < nCnt ? 255 : nCnt, 255 );
+ for( n = 0; n < nCnt; ++n )
+ {
+ void* p = rSrcArr[ n ];
+ ULONG nOrdNum = rWrt.GetSdrOrdNum( *(SwFrmFmt*)p );
+ aSort.Insert( nOrdNum, nPos );
+ aSortFmts.Insert( p, nPos );
+ }
+
+ if( aFollowShpIds.Count() )
+ aFollowShpIds.Remove( 0, aFollowShpIds.Count() );
+
+ ULONG nShapeId;
+ const SwFmtChain* pChain;
+ for( n = 0; n < nCnt; ++n )
+ {
+ const SwFrmFmt* pFmt = (SwFrmFmt*)aSortFmts[ n ];
+
+ if( RES_FLYFRMFMT == pFmt->Which() &&
+ ( ( pChain = &pFmt->GetChain())->GetPrev() ||
+ pChain->GetNext() ) )
+ {
+ // the format needs a shapeid
+ nShapeId = GetShapeID();
+ }
+ else
+ nShapeId = 0;
+ aFollowShpIds.Insert( nShapeId, n );
+ }
+}
+
+
+UINT32 SwEscherEx::GetFlyShapeId( const SwFrmFmt& rFmt )
+{
+ const VoidPtr pFmt = (void*)&rFmt;
+ USHORT nPos = aSortFmts.GetPos( pFmt );
+ UINT32 nShapeId;
+ if( USHRT_MAX != nPos )
+ {
+ if( 0 == ( nShapeId = aFollowShpIds[ nPos ] ))
+ {
+ nShapeId = GetShapeID();
+ aFollowShpIds[ nPos ] = nShapeId;
+ }
+ }
+ else
+ nShapeId = GetShapeID();
+ return nShapeId;
+}
+
+UINT32 SwEscherEx::QueryTextID( const uno::Reference< drawing::XShape>& xXShapeRef, UINT32 nShapeId )
+{
+ UINT32 nId = 0;
+ uno::Reference< lang::XUnoTunnel > xTunnel(xXShapeRef, uno::UNO_QUERY);
+ SvxShape* pSvxShape = xTunnel.is() ?
+ (SvxShape*)xTunnel->getSomething(SvxShape::getUnoTunnelId()) : 0;
+ if( pSvxShape )
+ {
+ SdrObject* pObj = pSvxShape->GetSdrObject();
+ if( pObj )
+ {
+ pTxtBxs->Append( *pObj, nShapeId );
+ nId = pTxtBxs->Count();
+ nId *= 0x10000;
+ }
+ }
+ return nId;
+}
+
+SvStream* SwEscherEx::QueryPicStream()
+{
+ if( !pPictStrm )
+ {
+ pPictStrm = rWrt.GetStorage().OpenStream( sEscherPictStream,
+ STREAM_READWRITE | STREAM_SHARE_DENYALL );
+ pPictStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ }
+ return pPictStrm;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/wrtw8esh.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.23 2000/09/18 16:04:57 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.22 2000/08/25 12:27:31 jp
+ Graphic Crop-Attribut exported to SVX
+
+ Revision 1.21 2000/07/17 20:28:23 jp
+ WriteGrfFlyFrame: alloc buffer for the linked graphics
+
+ Revision 1.20 2000/05/16 17:39:17 jp
+ Changes for Unicode
+
+ Revision 1.19 2000/05/12 16:13:51 jp
+ Changes for Unicode
+
+ Revision 1.18 2000/04/11 17:35:37 jp
+ Bug #74724#: CTOR SwEscherEx - call the end outproc for the SdrPage
+
+ Revision 1.17 2000/03/24 13:55:29 jp
+ Bug #74452#: after writing the escher delete the escher object
+
+ Revision 1.16 2000/03/21 15:04:57 os
+ UNOIII
+
+ Revision 1.15 2000/03/03 15:20:01 os
+ StarView remainders removed
+
+ Revision 1.14 2000/02/23 18:40:03 jp
+ Task #73176#: AddWmf will have EMU values
+
+ Revision 1.13 2000/02/11 14:39:51 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.12 1999/11/24 14:55:55 hr
+ #65293#: added header
+
+ Revision 1.11 1999/10/14 21:05:57 jp
+ Bug #68617#,#68705# and other little things
+
+ Revision 1.10 1999/10/13 09:08:41 jp
+ write character attributs of SdrObjects
+
+ Revision 1.9 1999/10/11 10:57:30 jp
+ some bugfixes #68745#/#69033#/#68681#
+
+ Revision 1.8 1999/09/10 16:27:59 jp
+ write FlyFrms too if no SdrObject exist
+
+ Revision 1.7 1999/09/08 16:29:18 jp
+ Bug #68618#: recognize the write of escher stream
+
+ Revision 1.6 1999/09/01 17:32:38 JP
+ new: write the text of SdrTextObjects
+
+
+ Rev 1.5 01 Sep 1999 19:32:38 JP
+ new: write the text of SdrTextObjects
+
+ Rev 1.4 31 Aug 1999 09:51:36 JP
+ set NumberFormatInt at streams to littleendian
+
+ Rev 1.3 24 Aug 1999 20:15:48 JP
+ Escher Export
+
+ Rev 1.2 16 Aug 1999 17:16:30 JP
+ W97 Export: experimental escher export (1)
+
+ Rev 1.1 16 Aug 1999 13:05:42 JP
+ write EscherObjects - only a testversion!
+
+ Rev 1.0 21 Jul 1999 18:28:56 JP
+ W97 Export: experimental escher export
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
new file mode 100644
index 000000000000..3834d9192d27
--- /dev/null
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -0,0 +1,2002 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtw8nds.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen wg. SvxFontItem
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen wg. SvxULSpaceItem
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMATR_HXX //autogen
+#include <frmatr.hxx>
+#endif
+#ifndef _PARATR_HXX //autogen
+#include <paratr.hxx>
+#endif
+#ifndef _TXATBASE_HXX //autogen
+#include <txatbase.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen wg. SwFmtINetFmt
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _FMTRFMRK_HXX //autogen wg. SwFmtRefMark
+#include <fmtrfmrk.hxx>
+#endif
+#ifndef _FCHRFMT_HXX //autogen wg. SwFmtCharFmt
+#include <fchrfmt.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen wg. SwCharFmt
+#include <charfmt.hxx>
+#endif
+#ifndef _TOX_HXX //autogen wg. SwTOXMark
+#include <tox.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen
+#include <ndtxt.hxx>
+#endif
+#ifndef _PAM_HXX //autogen
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX //autogen
+#include <docary.hxx>
+#endif
+#ifndef _SWTABLE_HXX //autogen
+#include <swtable.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen
+#include <section.hxx>
+#endif
+#ifndef _PAGEDESC_HXX //autogen
+#include <pagedesc.hxx>
+#endif
+#ifndef _SWRECT_HXX //autogen
+#include <swrect.hxx>
+#endif
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+#ifndef _FLYPOS_HXX
+#include <flypos.hxx> // SwPosFlyFrms
+#endif
+#ifndef _REFFLD_HXX //autogen wg. SwGetRefField
+#include <reffld.hxx>
+#endif
+#ifndef _REDLINE_HXX
+#include <redline.hxx>
+#endif
+#ifndef _WRTSWTBL_HXX
+#include <wrtswtbl.hxx>
+#endif
+#ifndef _HTMLTBL_HXX
+#include <htmltbl.hxx>
+#endif
+#ifndef _TXTTXMRK_HXX
+#include <txttxmrk.hxx>
+#endif
+#ifndef SW_FMTLINE_HXX
+#include <fmtline.hxx>
+#endif
+
+/* */
+
+WW8_AttrIter::WW8_AttrIter( SwWW8Writer& rWr )
+ : rWrt( rWr ), pOld( rWr.pChpIter )
+{
+ rWrt.pChpIter = this;
+}
+
+WW8_AttrIter::~WW8_AttrIter()
+{
+ rWrt.pChpIter = pOld;
+}
+
+void WW8_AttrIter::GetItems( WW8Bytes& rItems ) const
+{
+}
+
+
+/* */
+
+// Die Klasse WW8_SwAttrIter ist eine Hilfe zum Aufbauen der Fkp.chpx.
+// Dabei werden nur Zeichen-Attribute beachtet; Absatz-Attribute brauchen
+// diese Behandlung nicht.
+// Die Absatz- und Textattribute des Writers kommen rein, und es wird
+// mit Where() die naechste Position geliefert, an der sich die Attribute
+// aendern. IsTxtAtr() sagt, ob sich an der mit Where() gelieferten Position
+// ein Attribut ohne Ende und mit \xff im Text befindet.
+// Mit OutAttr() werden die Attribute an der angegebenen SwPos
+// ausgegeben.
+class WW8_SwAttrIter : public WW8_AttrIter
+{
+ const SwTxtNode& rNd;
+ SvPtrarr aTxtAtrArr;
+ SvUShorts aChrSetArr;
+ const SwRedline* pCurRedline;
+ xub_StrLen nAktSwPos;
+ xub_StrLen nTmpSwPos; // fuer HasItem()
+ USHORT nCurRedlinePos;
+ rtl_TextEncoding eNdChrSet;
+
+ xub_StrLen SearchNext( xub_StrLen nStartPos );
+ void SetCharSet( const SwTxtAttr& rTxtAttr, BOOL bStart );
+ void FieldVanish( const String& rTxt );
+
+ void OutSwFmtINetFmt( const SwFmtINetFmt& rAttr, BOOL bStart );
+ void OutSwFmtRefMark( const SwFmtRefMark& rAttr, BOOL bStart );
+ void OutSwTOXMark( const SwTOXMark& rAttr, BOOL bStart );
+
+public:
+ WW8_SwAttrIter( SwWW8Writer& rWr, const SwTxtNode& rNd );
+
+ BOOL IsTxtAttr( xub_StrLen nSwPos );
+ BOOL IsRedlineAtEnd( xub_StrLen nPos ) const;
+
+ void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); }
+
+ void OutAttr( xub_StrLen nSwPos );
+ virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const;
+ virtual const SfxPoolItem& GetItem( USHORT nWhich ) const;
+ virtual void GetItems( WW8Bytes& rItems ) const;
+ BOOL OutAttrWithRange( xub_StrLen nPos );
+ void OutRedlines( xub_StrLen nPos );
+
+ xub_StrLen WhereNext() const { return nAktSwPos; }
+ rtl_TextEncoding GetNextCharSet() const;
+ rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; }
+};
+
+
+WW8_SwAttrIter::WW8_SwAttrIter( SwWW8Writer& rWr, const SwTxtNode& rTxtNd )
+ : WW8_AttrIter( rWr ), rNd( rTxtNd ), nAktSwPos( 0 ), nTmpSwPos( 0 ),
+ aTxtAtrArr( 0, 4 ), aChrSetArr( 0, 4 ), nCurRedlinePos( USHRT_MAX ),
+ pCurRedline( 0 )
+{
+ // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen
+ // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben
+ // werden.
+ eNdChrSet = ((SvxFontItem&)rNd.SwCntntNode::GetAttr(
+ RES_CHRATR_FONT )).GetCharSet();
+ if( rWrt.pDoc->GetRedlineTbl().Count() )
+ {
+ SwPosition aPos( rNd, SwIndex( (SwTxtNode*)&rNd ) );
+ pCurRedline = rWrt.pDoc->GetRedline( aPos, &nCurRedlinePos );
+ }
+ nAktSwPos = SearchNext( 1 );
+}
+
+rtl_TextEncoding WW8_SwAttrIter::GetNextCharSet() const
+{
+ if( aChrSetArr.Count() )
+ return (rtl_TextEncoding)aChrSetArr[ aChrSetArr.Count() - 1 ];
+ return eNdChrSet;
+}
+
+xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos )
+{
+ register xub_StrLen nPos;
+ register xub_StrLen nMinPos = STRING_MAXLEN;
+ register xub_StrLen i;
+
+ // first the redline, then the attributes
+ if( pCurRedline )
+ {
+ const SwPosition* pEnd = pCurRedline->End();
+ if( pEnd->nNode == rNd &&
+ ( i = pEnd->nContent.GetIndex() ) >= nStartPos )
+ nMinPos = i;
+ }
+
+ if( nCurRedlinePos < rWrt.pDoc->GetRedlineTbl().Count() )
+ {
+ // nCurRedlinePos point to the next redline
+ nPos = nCurRedlinePos;
+ if( pCurRedline )
+ ++nPos;
+
+ for( ; nPos < rWrt.pDoc->GetRedlineTbl().Count(); ++nPos )
+ {
+ const SwRedline* pRedl = rWrt.pDoc->GetRedlineTbl()[ nPos ];
+
+ const SwPosition* pStt = pRedl->Start();
+ const SwPosition* pEnd = pStt == pRedl->GetPoint()
+ ? pRedl->GetMark()
+ : pRedl->GetPoint();
+
+ if( pStt->nNode == rNd )
+ {
+ if( ( i = pStt->nContent.GetIndex() ) >= nStartPos &&
+ i < nMinPos )
+ nMinPos = i;
+ }
+ else
+ break;
+
+ if( pEnd->nNode == rNd &&
+ ( i = pEnd->nContent.GetIndex() ) < nMinPos &&
+ i >= nStartPos )
+ nMinPos = i;
+ }
+ }
+
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+
+// kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs
+// nach der Anfangsposition geordnet sind. Dann muessten
+// allerdings noch 2 Indices gemerkt werden
+ for( i = 0; i < pTxtAttrs->Count(); i++ )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen
+ if( nPos >= nStartPos && nPos <= nMinPos )
+ {
+ nMinPos = nPos;
+ SetCharSet( *pHt, TRUE );
+ }
+
+ if( pHt->GetEnd() ) // Attr mit Ende
+ {
+ nPos = *pHt->GetEnd(); // gibt letztes Attr-Zeichen + 1
+ if( nPos >= nStartPos && nPos <= nMinPos )
+ {
+ nMinPos = nPos;
+ SetCharSet( *pHt, FALSE );
+ }
+ }
+ else
+ { // Attr ohne Ende
+ nPos = *pHt->GetStart() + 1; // Laenge 1 wegen CH_TXTATR im Text
+ if( nPos >= nStartPos && nPos <= nMinPos )
+ {
+ nMinPos = nPos;
+ SetCharSet( *pHt, FALSE );
+ }
+ }
+ }
+ }
+ return nMinPos;
+}
+
+void WW8_SwAttrIter::SetCharSet( const SwTxtAttr& rAttr, BOOL bStart )
+{
+ void* p = 0;
+ rtl_TextEncoding eChrSet;
+ const SfxPoolItem& rItem = rAttr.GetAttr();
+ switch( rItem.Which() )
+ {
+ case RES_CHRATR_FONT:
+ p = (void*)&rAttr;
+ eChrSet = ((SvxFontItem&)rItem).GetCharSet();
+ break;
+
+ case RES_TXTATR_CHARFMT:
+ {
+ const SfxPoolItem* pItem;
+ if( ((SwFmtCharFmt&)rItem).GetCharFmt() && SFX_ITEM_SET ==
+ ((SwFmtCharFmt&)rItem).GetCharFmt()->GetItemState(
+ RES_CHRATR_FONT, TRUE, &pItem ))
+ {
+ eChrSet = ((SvxFontItem*)pItem)->GetCharSet();
+ p = (void*)&rAttr;
+ }
+ }
+ break;
+
+// case RES_TXTATR_INETFMT:
+// break;
+ }
+
+ if( p )
+ {
+ USHORT nPos;
+ if( bStart )
+ {
+ nPos = aChrSetArr.Count();
+ aChrSetArr.Insert( eChrSet, nPos );
+ aTxtAtrArr.Insert( p, nPos );
+ }
+ else if( USHRT_MAX != ( nPos = aTxtAtrArr.GetPos( p )) )
+ {
+ aTxtAtrArr.Remove( nPos );
+ aChrSetArr.Remove( nPos );
+ }
+ }
+}
+
+void WW8_SwAttrIter::OutAttr( xub_StrLen nSwPos )
+{
+ if( rNd.GetpSwAttrSet() )
+ rWrt.Out_SfxItemSet( *rNd.GetpSwAttrSet(), FALSE, TRUE );
+
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ const SwModify* pOldMod = rWrt.pOutFmtNode;
+ rWrt.pOutFmtNode = &rNd;
+
+ nTmpSwPos = nSwPos;
+ register xub_StrLen i;
+ for( i = 0; i < pTxtAttrs->Count(); i++ )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ const xub_StrLen* pEnd = pHt->GetEnd();
+
+ if( pEnd ? ( nSwPos >= *pHt->GetStart() && nSwPos < *pEnd )
+ : nSwPos == *pHt->GetStart() )
+ Out( aWW8AttrFnTab, pHt->GetAttr(), rWrt );
+ else if( nSwPos < *pHt->GetStart() )
+ break;
+ }
+
+ nTmpSwPos = 0; // HasTextItem nur in dem obigen Bereich erlaubt
+ rWrt.pOutFmtNode = pOldMod;
+ }
+
+ OutRedlines( nSwPos );
+}
+
+BOOL WW8_SwAttrIter::IsTxtAttr( xub_StrLen nSwPos )
+{
+ // search for attrs without end position
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ register USHORT i;
+ for( i = 0; i < pTxtAttrs->Count(); i++ )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ if( !pHt->GetEnd() && *pHt->GetStart() == nSwPos )
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// HasItem ist fuer die Zusammenfassung des Doppel-Attributes Underline
+// und WordLineMode als TextItems. OutAttr() ruft die Ausgabefunktion,
+// die dann ueber HasItem() nach anderen Items an der
+// Attribut-Anfangposition fragen kann.
+// Es koennen nur Attribute mit Ende abgefragt werden.
+// Es wird mit bDeep gesucht
+const SfxPoolItem* WW8_SwAttrIter::HasTextItem( USHORT nWhich ) const
+{
+ const SfxPoolItem* pRet = 0;
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( !nTmpSwPos && !pTxtAttrs )
+ {
+ ASSERT( !this, "HasTextItem nicht aus OutAttr gerufen !" );
+ }
+ else if( pTxtAttrs )
+ {
+ register USHORT i;
+ for( i = 0; i < pTxtAttrs->Count(); ++i )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ const SfxPoolItem* pItem = &pHt->GetAttr();
+ const xub_StrLen* pAtrEnd = 0;
+ if( 0 != ( pAtrEnd = pHt->GetEnd() ) && // nur Attr mit Ende
+ nWhich == pItem->Which() && //
+ nTmpSwPos >= *pHt->GetStart() && nTmpSwPos < *pAtrEnd )
+ {
+ pRet = pItem; // gefunden
+ break;
+ }
+ else if( nTmpSwPos < *pHt->GetStart() )
+ break; // dann kommt da nichts mehr
+ }
+ }
+ return pRet;
+}
+
+void WW8_SwAttrIter::GetItems( WW8Bytes& rItems ) const
+{
+ WW8Bytes* pO_Sav = rWrt.pO;
+ rWrt.pO = &rItems;
+
+ if( rNd.GetpSwAttrSet() )
+ rWrt.Out_SfxItemSet( *rNd.GetpSwAttrSet(), FALSE, TRUE );
+
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ const SwModify* pOldMod = rWrt.pOutFmtNode;
+ rWrt.pOutFmtNode = &rNd;
+
+ register USHORT i;
+ for( i = 0; i < pTxtAttrs->Count(); i++ )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ const xub_StrLen* pEnd = pHt->GetEnd();
+
+ if( pEnd && nTmpSwPos >= *pHt->GetStart() && nTmpSwPos < *pEnd )
+ Out( aWW8AttrFnTab, pHt->GetAttr(), rWrt );
+ else if( nTmpSwPos < *pHt->GetStart() )
+ break;
+ }
+
+ rWrt.pOutFmtNode = pOldMod;
+ }
+
+// OutRedlines( nTmpSwPos );
+ rWrt.pO = pO_Sav;
+}
+
+const SfxPoolItem& WW8_SwAttrIter::GetItem( USHORT nWhich ) const
+{
+ const SfxPoolItem* pRet = HasTextItem( nWhich );
+ if( !pRet )
+ pRet = &rNd.SwCntntNode::GetAttr( nWhich );
+ return *pRet;
+}
+
+void WW8_SwAttrIter::OutSwFmtINetFmt( const SwFmtINetFmt& rINet, BOOL bStart )
+{
+ if( bStart )
+ {
+ INetURLObject aURL( rINet.GetValue() );
+ String sURL( aURL.GetURLNoMark(INetURLObject::DECODE_WITH_CHARSET) );
+ String sMark( aURL.GetMark(INetURLObject::DECODE_WITH_CHARSET) );
+
+ sURL = INetURLObject::AbsToRel( sURL, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ sURL.Insert( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "HYPERLINK \"" )), 0 );
+ sURL += '\"';
+
+ if( sMark.Len() )
+ (( sURL.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " \\l \"" )))
+ += sMark ) += '\"';
+
+ if( rINet.GetTargetFrame().Len() )
+ ( sURL.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " \\n " )))
+ += rINet.GetTargetFrame();
+
+ rWrt.OutField( 0, 88, sURL,
+ WRITEFIELD_START | WRITEFIELD_CMD_START );
+
+ // write the refence to the "picture" structure
+ ULONG nDataStt = rWrt.pDataStrm->Tell();
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell() );
+
+//I'm leaving this as a define for now for easy removal of this code
+//C.
+#define WRITE_HYPERLINK_IN_DATA_STREAM
+
+#ifdef WRITE_HYPERLINK_IN_DATA_STREAM
+//WinWord 2000 doesn't write this - so its a temp solution by W97
+ rWrt.WriteChar( 0x01 );
+
+ static BYTE aArr1[] = {
+ 0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
+
+ 0x06, 0x08, 0x01, // sprmCFData
+ 0x55, 0x08, 0x01, // sprmCFSpec
+ 0x02, 0x08, 0x01 // sprmCFFldVanish
+ };
+ BYTE* pDataAdr = aArr1 + 2;
+ Set_UInt32( pDataAdr, nDataStt );
+
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ sizeof( aArr1 ), aArr1 );
+#endif
+
+ rWrt.OutField( 0, 88, sURL, WRITEFIELD_CMD_END );
+
+
+#ifdef WRITE_HYPERLINK_IN_DATA_STREAM
+ // now write the picture structur
+ sURL = aURL.GetURLNoMark();
+
+ BOOL bAbsolute = TRUE; //all links end up in the data stream as
+ //absolute references.
+ INetProtocol aProto = aURL.GetProtocol();
+
+ static BYTE __READONLY_DATA aURLData1[] = {
+ 0,0,0,0, // len of struct
+ 0x44,0, // the start of "next" data
+ 0,0,0,0,0,0,0,0,0,0, // PIC-Structure!
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
+ 0,0,0,0, // /
+ };
+ static BYTE __READONLY_DATA MAGIC_A[] = {
+ // start of "next" data
+ 0xD0,0xC9,0xEA,0x79,0xF9,0xBA,0xCE,0x11,
+ 0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B
+ };
+
+ rWrt.pDataStrm->Write( aURLData1, sizeof(aURLData1) );
+ BYTE nAnchor=0x00;
+ if( sMark.Len() )
+ nAnchor=0x08;
+ rWrt.pDataStrm->Write( &nAnchor, 1 );
+ rWrt.pDataStrm->Write( MAGIC_A, sizeof(MAGIC_A) );
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, 0x00000002);
+ UINT32 nFlag=0x01;
+ if (bAbsolute) nFlag |= 0x02;
+ if( sMark.Len() ) nFlag |= 0x08;
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, nFlag );
+
+ if (aProto == INET_PROT_FILE)
+ {
+// version 1 (for a document)
+
+ static BYTE __READONLY_DATA MAGIC_C[] = {
+ 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
+ 0x00, 0x00
+ };
+
+ static BYTE __READONLY_DATA MAGIC_D[] = {
+ 0xFF, 0xFF, 0xAD, 0xDE, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ sURL = aURL.PathToFileName();
+
+ rWrt.pDataStrm->Write( MAGIC_C, sizeof(MAGIC_C) );
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, sURL.Len()+1 );
+ SwWW8Writer::WriteString8( *rWrt.pDataStrm, sURL, TRUE,
+ RTL_TEXTENCODING_MS_1252 );
+ rWrt.pDataStrm->Write( MAGIC_D, sizeof( MAGIC_D) );
+
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, 2*sURL.Len()+6);
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, 2*sURL.Len());
+ SwWW8Writer::WriteShort( *rWrt.pDataStrm, 3 );
+ SwWW8Writer::WriteString16( *rWrt.pDataStrm, sURL, FALSE );
+ }
+ else
+ {
+ // version 2 (simple url)
+ // an write some data to the data stream, but dont ask
+ // what the data mean, except for the URL.
+ // The First piece is the WW8_PIC structure.
+ //
+ static BYTE __READONLY_DATA MAGIC_B[] = {
+ 0xE0,0xC9,0xEA,0x79,0xF9,0xBA,0xCE,0x11,
+ 0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B
+ };
+
+ rWrt.pDataStrm->Write( MAGIC_B, sizeof(MAGIC_B) );
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, 2 * (sURL.Len()+1) );
+ SwWW8Writer::WriteString16( *rWrt.pDataStrm, sURL, TRUE );
+ }
+
+ if( sMark.Len() )
+ {
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, sMark.Len()+1 );
+ SwWW8Writer::WriteString16( *rWrt.pDataStrm, sMark, TRUE );
+ }
+ SwWW8Writer::WriteLong( *rWrt.pDataStrm, nDataStt,
+ rWrt.pDataStrm->Tell() - nDataStt );
+#endif
+
+ }
+ else
+ rWrt.OutField( 0, 0, aEmptyStr, WRITEFIELD_CLOSE );
+}
+
+
+void WW8_SwAttrIter::OutSwFmtRefMark( const SwFmtRefMark& rAttr, BOOL bStart )
+{
+ if( rWrt.HasRefToObject( REF_SETREFATTR, &rAttr.GetRefName(), 0 ))
+ rWrt.AppendBookmark( rWrt.GetBookmarkName( REF_SETREFATTR,
+ &rAttr.GetRefName(), 0 ));
+}
+
+void WW8_SwAttrIter::FieldVanish( const String& rTxt )
+{
+ WW8Bytes aItems;
+ rWrt.pChpIter->GetItems( aItems );
+ USHORT nStt_TxtAtt = aItems.Count();
+
+ // sprmCFFldVanish
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aItems, 0x802 );
+ else
+ aItems.Insert( 67, aItems.Count() );
+ aItems.Insert( 1, aItems.Count() );
+
+ USHORT nStt_sprmCFSpec = aItems.Count();
+
+ // sprmCFSpec -- fSpec-Attribut TRUE
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aItems, 0x855 );
+ else
+ aItems.Insert( 117, aItems.Count() );
+ aItems.Insert( 1, aItems.Count() );
+
+
+// rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), nStt_TxtAtt,
+// aItems.GetData() );
+ rWrt.WriteChar( '\x13' );
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(),
+ aItems.GetData() );
+ rWrt.OutSwString( rTxt, 0, rTxt.Len(), rWrt.IsUnicode(),
+ RTL_TEXTENCODING_MS_1252 );
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), nStt_sprmCFSpec,
+ aItems.GetData() );
+ rWrt.WriteChar( '\x15' );
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(),
+ aItems.GetData() );
+}
+
+void WW8_SwAttrIter::OutSwTOXMark( const SwTOXMark& rAttr, BOOL bStart )
+{
+ // its a field; so get the Text form the Node and build the field
+ ASSERT( !bStart, "calls only with the endposition!" );
+ String sTxt;
+
+ const SwTxtTOXMark& rTxtTOXMark = *rAttr.GetTxtTOXMark();
+ const xub_StrLen* pTxtEnd = rTxtTOXMark.GetEnd();
+ if( pTxtEnd ) // has range?
+ sTxt = rNd.GetExpandTxt( *rTxtTOXMark.GetStart(),
+ *pTxtEnd - *rTxtTOXMark.GetStart() );
+ else
+ sTxt = rAttr.GetAlternativeText();
+
+ switch( rAttr.GetTOXType()->GetType() )
+ {
+ case TOX_INDEX:
+ if( rAttr.GetPrimaryKey().Len() )
+ {
+ sTxt.Insert( ':', 0 );
+ sTxt.Insert( rAttr.GetPrimaryKey(), 0 );
+ }
+ sTxt.InsertAscii( " XE \"", 0 );
+ sTxt.InsertAscii( "\" " );
+ break;
+
+ case TOX_USER:
+ ( sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\" \\f \"" )))
+ += (sal_Char)( 'A' + rWrt.GetId( *rAttr.GetTOXType() ));
+ // kein break;
+ case TOX_CONTENT:
+ {
+ sTxt.InsertAscii( " INHALT \"", 0 );
+ USHORT nLvl = rAttr.GetLevel();
+ if( nLvl > nWW8MaxListLevel )
+ nLvl = nWW8MaxListLevel;
+
+ ((sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\" \\l " )))
+ += String::CreateFromInt32( nLvl )) += ' ';
+ }
+ break;
+ }
+
+ if( sTxt.Len() )
+ FieldVanish( sTxt );
+}
+
+BOOL WW8_SwAttrIter::OutAttrWithRange( xub_StrLen nPos )
+{
+ BOOL bRet = FALSE;
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ nTmpSwPos = nPos;
+ const xub_StrLen* pEnd;
+ register USHORT i;
+ for( i = 0; i < pTxtAttrs->Count(); ++i )
+ {
+ const SwTxtAttr* pHt = (*pTxtAttrs)[i];
+ const SfxPoolItem* pItem = &pHt->GetAttr();
+ switch( pItem->Which() )
+ {
+ case RES_TXTATR_INETFMT:
+ if( rWrt.bWrtWW8 ) // nur WW8 kann Hyperlinks
+ {
+ if( nPos == *pHt->GetStart() )
+ {
+ OutSwFmtINetFmt( (SwFmtINetFmt&)*pItem, TRUE );
+ bRet = TRUE;
+ }
+ else if( nPos == *pHt->GetEnd() )
+ OutSwFmtINetFmt( (SwFmtINetFmt&)*pItem, FALSE );
+ }
+ break;
+
+ case RES_TXTATR_REFMARK:
+ if( nPos == *pHt->GetStart() )
+ OutSwFmtRefMark( (SwFmtRefMark&)*pItem, TRUE );
+ if( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd )
+ OutSwFmtRefMark( (SwFmtRefMark&)*pItem, FALSE );
+ break;
+
+ case RES_TXTATR_TOXMARK:
+ if( 0 != ( pEnd = pHt->GetEnd() ) ? nPos == *pEnd
+ : nPos == *pHt->GetStart())
+ OutSwTOXMark( (SwTOXMark&)*pItem, FALSE );
+ break;
+ }
+ }
+ nTmpSwPos = 0; // HasTextItem nur in dem obigen Bereich erlaubt
+ }
+ return bRet;
+}
+
+BOOL WW8_SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const
+{
+ BOOL bRet = FALSE;
+ // search next Redline
+ for( USHORT nPos = nCurRedlinePos;
+ nPos < rWrt.pDoc->GetRedlineTbl().Count(); ++nPos )
+ {
+ const SwPosition* pEnd = rWrt.pDoc->GetRedlineTbl()[ nPos ]->End();
+ if( pEnd->nNode == rNd )
+ {
+ if( pEnd->nContent.GetIndex() == nEnd )
+ {
+ bRet = TRUE;
+ break;
+ }
+ }
+ else
+ break;
+ }
+ return bRet;
+}
+
+void WW8_SwAttrIter::OutRedlines( xub_StrLen nPos )
+{
+ if( pCurRedline )
+ {
+ const SwPosition* pEnd = pCurRedline->End();
+ if( pEnd->nNode == rNd &&
+ pEnd->nContent.GetIndex() <= nPos )
+ {
+ pCurRedline = 0;
+ ++nCurRedlinePos;
+ }
+ else
+ // write data of current redline
+ rWrt.OutRedline( pCurRedline->GetRedlineData() );
+ }
+
+ if( !pCurRedline )
+ {
+ // search next Redline
+ for( ; nCurRedlinePos < rWrt.pDoc->GetRedlineTbl().Count();
+ ++nCurRedlinePos )
+ {
+ const SwRedline* pRedl = rWrt.pDoc->GetRedlineTbl()[ nCurRedlinePos ];
+
+ const SwPosition* pStt = pRedl->Start();
+ const SwPosition* pEnd = pStt == pRedl->GetPoint()
+ ? pRedl->GetMark()
+ : pRedl->GetPoint();
+
+ if( pStt->nNode == rNd )
+ {
+ if( pStt->nContent.GetIndex() >= nPos )
+ {
+ if( pStt->nContent.GetIndex() == nPos )
+ {
+ // write data of this redline
+ pCurRedline = pRedl;
+ rWrt.OutRedline( pCurRedline->GetRedlineData() );
+ }
+ break;
+ }
+ }
+ else
+ break;
+
+ if( pEnd->nNode == rNd &&
+ pEnd->nContent.GetIndex() < nPos )
+ {
+ pCurRedline = pRedl;
+ break;
+ }
+ }
+ }
+}
+
+/* */
+
+Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ SwTxtNode* pNd = &((SwTxtNode&)rNode);
+
+ BOOL bFlyInTable = rWW8Wrt.pFlyFmt && rWW8Wrt.bIsInTable;
+
+ // akt. Style
+ if( !bFlyInTable )
+ rWW8Wrt.nStyleBeforeFly
+ = rWW8Wrt.GetId( (SwTxtFmtColl&)pNd->GetAnyFmtColl() );
+
+ SVBT16 nSty;
+ ShortToSVBT16( rWW8Wrt.nStyleBeforeFly, nSty );
+
+ WW8Bytes* pO = rWW8Wrt.pO;
+
+ if( rWW8Wrt.bStartTOX )
+ {
+ // ignore TOX header section
+ const SwSectionNode* pSectNd = rNode.FindSectionNode();
+ if( TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() )
+ rWW8Wrt.StartTOX( pSectNd->GetSection() );
+ }
+
+ const SwSection* pTOXSect = 0;
+ if( rWW8Wrt.bInWriteTOX )
+ {
+ // check for end of TOX
+ SwNodeIndex aIdx( *pNd, 1 );
+ if( !aIdx.GetNode().IsTxtNode() )
+ {
+ const SwSectionNode* pTOXSectNd = rNode.FindSectionNode();
+ pTOXSect = &pTOXSectNd->GetSection();
+
+ const SwNode* pNxt = rNode.GetNodes().GoNext( &aIdx );
+ if( pNxt && pNxt->FindSectionNode() == pTOXSectNd )
+ pTOXSect = 0;
+ }
+ }
+
+ WW8_SwAttrIter aAttrIter( rWW8Wrt, *pNd );
+ rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
+
+ ASSERT( !pO->Count(), " pO ist am Zeilenanfang nicht leer" );
+
+ String aStr( pNd->GetTxt() );
+
+ // 0x0a ( Hard Line Break ) -> 0x0b
+ // 0xad ( soft hyphen ) -> 0x1f
+ // 0x2011 ( hard hyphen ) -> 0x1e
+ if( aStr.Len() )
+ {
+ aStr.SearchAndReplaceAll( 0x0A, 0x0B );
+ aStr.SearchAndReplaceAll( CHAR_HARDHYPHEN, 0x1e );
+ aStr.SearchAndReplaceAll( CHAR_SOFTHYPHEN, 0x1f );
+ }
+ xub_StrLen nAktPos = 0;
+ xub_StrLen nEnd = aStr.Len();
+ BOOL bUnicode = TRUE, bRedlineAtEnd = FALSE;
+ do {
+/*
+ if( !bUseAlwaysUnicode )
+ {
+ switch( eChrSet )
+ {
+// case CHARSET_DONTKNOW: ????
+ case CHARSET_SYMBOL:
+// case CHARSET_WIN_SYMBOL:
+// case CHARSET_WIN_WINGDINGS:
+// case CHARSET_MAC_DINGBATS:
+// case CHARSET_MAC_SYMBOL:
+// case CHARSET_ADOBE_SYMBOL:
+// case CHARSET_ADOBE_DINGBATS:
+// case CHARSET_STAR_STARBATS:
+// case CHARSET_STAR_STARMATH:
+ bUnicode = rWW8Wrt.bWrtWW8 ? TRUE : FALSE;
+ break;
+ default:
+ bUnicode = FALSE;
+ break;
+ }
+ }
+*/
+ xub_StrLen nNextAttr = aAttrIter.WhereNext();
+ rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
+
+ if( nNextAttr > nEnd )
+ nNextAttr = nEnd;
+
+ rWW8Wrt.AppendBookmarks( *pNd, nAktPos, nNextAttr - nAktPos );
+ BOOL bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
+ BOOL bAttrWithRange = aAttrIter.OutAttrWithRange( nAktPos );
+
+ if( !bTxtAtr )
+ rWW8Wrt.OutSwString( aStr, nAktPos, nNextAttr - nAktPos,
+ bUnicode, eChrSet );
+
+ // Am Zeilenende werden die Attribute bis ueber das CR
+ // aufgezogen. Ausnahme: Fussnoten am Zeilenende
+ if( nNextAttr == nEnd )
+ {
+ if( !bTxtAtr && !bAttrWithRange )
+ {
+ if( aAttrIter.IsRedlineAtEnd( nEnd ))
+ bRedlineAtEnd = TRUE;
+ else
+ {
+ if( pTOXSect )
+ rWW8Wrt.EndTOX( *pTOXSect );
+ rWW8Wrt.WriteCR(); // CR danach
+ }
+ }
+ }
+ // Ausgabe der Zeichenattribute
+ aAttrIter.OutAttr( nAktPos ); // nAktPos - 1 ??
+ rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+
+ // Ausnahme: Fussnoten am Zeilenende
+ if( nNextAttr == nEnd )
+ {
+ aAttrIter.OutAttrWithRange( nEnd );
+ if( pO->Count() )
+ {
+ rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+ }
+
+ if( bTxtAtr || bAttrWithRange || bRedlineAtEnd )
+ {
+ if( pTOXSect )
+ rWW8Wrt.EndTOX( *pTOXSect );
+
+ rWW8Wrt.WriteCR(); // CR danach
+
+ if( bRedlineAtEnd )
+ {
+ aAttrIter.OutRedlines( nEnd );
+ if( pO->Count() )
+ {
+ rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+ }
+ }
+ }
+ }
+ nAktPos = nNextAttr;
+ eChrSet = eNextChrSet;
+ aAttrIter.NextPos();
+ }
+ while( nAktPos < nEnd );
+
+ ASSERT( !pO->Count(), " pO ist am ZeilenEnde nicht leer" );
+
+// // gibt es harte Absatz-Attributierung oder Fly- oder Table-Attrs ?
+// if( pNd->GetpSwAttrSet() || rWW8Wrt.pFlyFmt || rWW8Wrt.bOutTable ){
+ pO->Insert( (BYTE*)&nSty, 2, pO->Count() ); // Style #
+
+ if( rWW8Wrt.pFlyFmt && !rWW8Wrt.bIsInTable ) // Fly-Attrs
+ rWW8Wrt.Out_SwFmt( *rWW8Wrt.pFlyFmt, FALSE, FALSE, TRUE );
+
+ if( rWW8Wrt.bOutTable )
+ { // Tab-Attr
+ // sprmPFInTable
+ if( rWW8Wrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x2416 );
+ else
+ pO->Insert( 24, pO->Count() );
+ pO->Insert( 1, pO->Count() );
+ }
+
+ if( !bFlyInTable )
+ {
+ SfxItemSet* pTmpSet = 0;
+ const BYTE nPrvNxtNd =
+ ( WWFL_ULSPACE_LIKE_SWG & rWW8Wrt.GetIniFlags())
+ ? (ND_HAS_PREV_LAYNODE|ND_HAS_NEXT_LAYNODE)
+ : pNd->HasPrevNextLayNode();
+
+ if( (ND_HAS_PREV_LAYNODE|ND_HAS_NEXT_LAYNODE ) != nPrvNxtNd )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pNd->GetSwAttrSet().GetItemState(
+ RES_UL_SPACE, TRUE, &pItem ) &&
+ ( ( !( ND_HAS_PREV_LAYNODE & nPrvNxtNd ) &&
+ ((SvxULSpaceItem*)pItem)->GetUpper()) ||
+ ( !( ND_HAS_NEXT_LAYNODE & nPrvNxtNd ) &&
+ ((SvxULSpaceItem*)pItem)->GetLower()) ))
+ {
+ pTmpSet = new SfxItemSet( pNd->GetSwAttrSet() );
+ SvxULSpaceItem aUL( *(SvxULSpaceItem*)pItem );
+ if( !(ND_HAS_PREV_LAYNODE & nPrvNxtNd ))
+ aUL.SetUpper( 0 );
+ if( !(ND_HAS_NEXT_LAYNODE & nPrvNxtNd ))
+ aUL.SetLower( 0 );
+ pTmpSet->Put( aUL );
+ }
+ }
+
+ if( !pTmpSet )
+ pTmpSet = pNd->GetpSwAttrSet();
+
+ const SwNumRule* pRule;
+ const SwNodeNum* pNum;
+ if( (( 0 != ( pNum = pNd->GetNum() ) &&
+ 0 != ( pRule = pNd->GetNumRule() )) ||
+ ( 0 != ( pNum = pNd->GetOutlineNum() ) &&
+ 0 != ( pRule = rWrt.pDoc->GetOutlineNumRule() ) ) ) &&
+ pNum->GetLevel() < NO_NUM )
+ {
+ BYTE nLvl = GetRealLevel( pNum->GetLevel() );
+ const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
+ if( !pFmt )
+ pFmt = &pRule->Get( nLvl );
+
+ if( pTmpSet == pNd->GetpSwAttrSet() )
+ pTmpSet = new SfxItemSet( pNd->GetSwAttrSet() );
+
+ SvxLRSpaceItem aLR( (SvxLRSpaceItem&)pTmpSet->Get( RES_LR_SPACE ) );
+ aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetAbsLSpace() );
+
+ if( MAXLEVEL > pNum->GetLevel() )
+ {
+ aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
+ if( pNum == pNd->GetNum() && SFX_ITEM_SET !=
+ pTmpSet->GetItemState( RES_PARATR_NUMRULE ) )
+ {
+ // NumRule from a template - then put it into the itemset
+ pTmpSet->Put( SwNumRuleItem( pRule->GetName() ));
+ }
+ }
+ else
+ pTmpSet->ClearItem( RES_PARATR_NUMRULE );
+
+ pTmpSet->Put( aLR );
+ SwWW8Writer::CorrTabStopInSet( *pTmpSet, pFmt->GetAbsLSpace() );
+ }
+
+ if( pTmpSet )
+ { // Para-Attrs
+ rWW8Wrt.pStyAttr = &pNd->GetAnyFmtColl().GetAttrSet();
+
+ const SwModify* pOldMod = rWW8Wrt.pOutFmtNode;
+ rWW8Wrt.pOutFmtNode = pNd;
+
+ rWW8Wrt.Out_SfxItemSet( *pTmpSet, TRUE, FALSE ); // Pap-Attrs
+
+ rWW8Wrt.pStyAttr = 0;
+ rWW8Wrt.pOutFmtNode = pOldMod;
+
+ if( pTmpSet != pNd->GetpSwAttrSet() )
+ delete pTmpSet;
+ }
+ }
+ rWW8Wrt.pPapPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+// }else{
+// rWW8Wrt.pPapPlc->AppendFkpEntry( rWrt.Strm().Tell(), sizeof( nSty ), nSty );
+// }
+ return rWrt;
+}
+
+
+/* */
+
+//---------------------------------------------------------------------------
+// Tabellen
+//---------------------------------------------------------------------------
+
+Writer& OutWW8_SwTblNode( Writer& rWrt, SwTableNode & rNode )
+{
+ SwWW8Writer & rWW8Wrt = (SwWW8Writer&)rWrt;
+ SwTable& rTbl = rNode.GetTable();
+ rWW8Wrt.Out_SfxBreakItems( rTbl.GetFrmFmt()->GetAttrSet(), rNode );
+
+ SwTableLines& rLns = rTbl.GetTabLines();
+ SwTwips nPageSize = 0, nTblOffset = 0;
+
+ {
+ Point aPt;
+ SwRect aRect( rTbl.GetFrmFmt()->FindLayoutRect( FALSE, &aPt ));
+ if( aRect.IsEmpty() )
+ {
+ // dann besorge mal die Seitenbreite ohne Raender !!
+ const SwFrmFmt* pFmt = rWW8Wrt.pFlyFmt ? rWW8Wrt.pFlyFmt :
+ rWrt.pDoc->GetPageDesc(0).GetPageFmtOfNode( rNode, FALSE );
+
+ aRect = pFmt->FindLayoutRect( TRUE );
+ if( 0 == ( nPageSize = aRect.Width() ))
+ {
+ const SvxLRSpaceItem& rLR = pFmt->GetLRSpace();
+ nPageSize = pFmt->GetFrmSize().GetWidth() -
+ rLR.GetLeft() - rLR.GetRight();
+ }
+ }
+ else
+ nPageSize = aRect.Width();
+ }
+
+ SwTwips nTblSz = rTbl.GetFrmFmt()->GetFrmSize().GetWidth();
+ WW8Bytes aAt( 128, 128 ); // Attribute fuer's Tabellen-Zeilenende
+
+ static BYTE __READONLY_DATA aNullBytes[] = { 0, 0, 0, 0 };
+
+ // sprmPDxaFromText10
+ if( rWW8Wrt.bWrtWW8 )
+ {
+ static BYTE __READONLY_DATA aTabLineAttr[] = {
+ 0, 0, // Sty # 0
+ 0x16, 0x24, 1, // sprmPFInTable
+ 0x17, 0x24, 1 }; // sprmPFTtp
+ aAt.Insert( aTabLineAttr, sizeof( aTabLineAttr ), aAt.Count() );
+ }
+ else
+ {
+ static BYTE __READONLY_DATA aTabLineAttr[] = {
+ 0, 0, // Sty # 0
+ 24, 1, // sprmPFInTable
+ 25, 1 }; // sprmPFTtp
+ aAt.Insert( aTabLineAttr, sizeof( aTabLineAttr ), aAt.Count() );
+ }
+
+ SwHoriOrient eHOri = rTbl.GetFrmFmt()->GetHoriOrient().GetHoriOrient();
+ switch( eHOri )
+ {
+ case HORI_CENTER:
+ case HORI_RIGHT:
+ if( rWW8Wrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aAt, 0x5400 );
+ else
+ aAt.Insert( 182, aAt.Count() );
+ SwWW8Writer::InsUInt16( aAt, (HORI_RIGHT == eHOri ? 2 : 1 ));
+ break;
+
+ case HORI_NONE:
+ case HORI_LEFT_AND_WIDTH:
+ {
+ const SvxLRSpaceItem& rLRSp = rTbl.GetFrmFmt()->GetLRSpace();
+ nTblOffset = rLRSp.GetLeft();
+ nPageSize -= nTblOffset + rLRSp.GetRight();
+ }
+ break;
+// case FLY_HORI_FULL:
+ }
+
+ BOOL bRelBoxSize = TRUE /*ALWAYS relativ (nPageSize + ( nPageSize / 10 )) < nTblSz*/;
+ USHORT nStdAtLen = aAt.Count();
+
+ SwWriteTable* pTableWrt;
+ const SwHTMLTableLayout *pLayout = rTbl.GetHTMLTableLayout();
+ if( pLayout && pLayout->IsExportable() )
+ pTableWrt = new SwWriteTable( pLayout );
+ else
+ pTableWrt = new SwWriteTable( rTbl.GetTabLines(), (USHORT)nPageSize,
+ (USHORT)nTblSz, FALSE );
+
+ // WW6 / 8 can not have more then 31 / 64 cells
+ const USHORT nMaxCols = rWW8Wrt.bWrtWW8 ? 64 : 31;
+ // rCols are the array of all cols of the table
+ const SwWriteTableCols& rCols = pTableWrt->GetCols();
+ USHORT nColCnt = rCols.Count();
+ SwWriteTableCellPtr* pBoxArr = new SwWriteTableCellPtr[ nColCnt ];
+ USHORT* pRowSpans = new USHORT[ nColCnt ];
+ memset( pBoxArr, 0, sizeof( pBoxArr[0] ) * nColCnt );
+ memset( pRowSpans, 0, sizeof( pRowSpans[0] ) * nColCnt );
+ long nLastHeight = 0;
+ const SwWriteTableRows& rRows = pTableWrt->GetRows();
+ for( USHORT nLine = 0; nLine < rRows.Count(); ++nLine )
+ {
+ USHORT nBox, nRealBox;
+
+ const SwWriteTableRow *pRow = rRows[ nLine ];
+ const SwWriteTableCells& rCells = pRow->GetCells();
+
+ BOOL bFixRowHeight = FALSE;
+ USHORT nRealColCnt = 0;
+ for( nColCnt = 0, nBox = 0; nBox < rCells.Count(); ++nColCnt )
+ {
+ if( !pRowSpans[ nColCnt ] )
+ {
+ // set new BoxPtr
+ SwWriteTableCell* pCell = rCells[ nBox++ ];
+ pBoxArr[ nColCnt ] = pCell;
+ pRowSpans[ nColCnt ] = pCell->GetRowSpan();
+ for( USHORT nCellSpan = pCell->GetColSpan(), nCS = 1;
+ nCS < nCellSpan; ++nCS, ++nColCnt )
+ {
+ pBoxArr[ nColCnt+1 ] = pBoxArr[ nColCnt ];
+ pRowSpans[ nColCnt+1 ] = pRowSpans[ nColCnt ];
+ }
+ ++nRealColCnt;
+ }
+ else if( !nColCnt || pBoxArr[ nColCnt-1 ] != pBoxArr[ nColCnt ] )
+ ++nRealColCnt;
+
+ if( 1 != pRowSpans[ nColCnt ] )
+ bFixRowHeight = TRUE;
+ }
+
+ for( ; nColCnt < rCols.Count() && pRowSpans[ nColCnt ]; ++nColCnt )
+ {
+ if( !nColCnt || pBoxArr[ nColCnt-1 ] != pBoxArr[ nColCnt ] )
+ ++nRealColCnt;
+ bFixRowHeight = TRUE;
+ }
+
+ USHORT nWWColMax = nRealColCnt > nMaxCols ? nMaxCols : nRealColCnt;
+
+ // 1.Zeile eine Headline? sprmTTableHeader
+ if( !nLine && rTbl.IsHeadlineRepeat() )
+ {
+ if( rWW8Wrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aAt, 0x3404 );
+ else
+ aAt.Insert( 186, aAt.Count() );
+ aAt.Insert( 1, aAt.Count() );
+ }
+
+ // Zeilenhoehe ausgeben sprmTDyaRowHeight
+ long nHeight = 0;
+ if( bFixRowHeight )
+ {
+ nHeight = -pRow->GetPos(); //neg. => abs. height!
+ if( nLine )
+ nHeight += rRows[ nLine - 1 ]->GetPos();
+ }
+ else
+ {
+ const SwTableLine* pLine = pBoxArr[ 0 ]->GetBox()->GetUpper();
+ const SwFmtFrmSize& rLSz = pLine->GetFrmFmt()->GetFrmSize();
+ if( ATT_VAR_SIZE != rLSz.GetSizeType() && rLSz.GetHeight() )
+ nHeight = ATT_MIN_SIZE == rLSz.GetSizeType()
+ ? rLSz.GetHeight()
+ : -rLSz.GetHeight();
+ }
+ if( nHeight )
+ {
+ if( rWW8Wrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aAt, 0x9407 );
+ else
+ aAt.Insert( 189, aAt.Count() );
+ SwWW8Writer::InsUInt16( aAt, (USHORT)nHeight );
+ }
+
+ // sprmTFCantSplit - unsere Tabellen duerfen nie in der Zeile
+ // gesplittet werden.
+ if( rWW8Wrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aAt, 0x3403 );
+ else
+ aAt.Insert( 185, aAt.Count() );
+ aAt.Insert( (BYTE)0, aAt.Count() );
+
+ // Inhalt der Boxen ausgeben
+ for( nBox = 0, nRealBox = 0; nBox < nColCnt; ++nBox )
+ {
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+
+ if( pBoxArr[ nBox ]->GetRowSpan() == pRowSpans[ nBox ] )
+ {
+ // new Box
+ const SwStartNode* pSttNd = pBoxArr[ nBox ]->GetBox()->GetSttNd();
+ WW8SaveData aSaveData( rWW8Wrt, pSttNd->GetIndex()+1,
+ pSttNd->EndOfSectionIndex() );
+ rWW8Wrt.bOutTable = TRUE;
+ rWW8Wrt.bIsInTable= TRUE;
+ rWW8Wrt.WriteText();
+ }
+ else
+ {
+ rWW8Wrt.bOutTable = TRUE;
+ rWW8Wrt.WriteStringAsPara( aEmptyStr );
+ rWW8Wrt.bOutTable = FALSE;
+ }
+
+ if( nWWColMax < nRealColCnt )
+ {
+ if( nRealBox+1 < nWWColMax || nRealBox+1 == nRealColCnt )
+ rWW8Wrt.ReplaceCr( (char)0x07 ); // SpaltenEnde
+ }
+ else if( nRealBox < nWWColMax )
+ rWW8Wrt.ReplaceCr( (char)0x07 ); // SpaltenEnde
+ ++nRealBox;
+ }
+
+ // das wars mit der Line
+ rWW8Wrt.WriteChar( (char)0x7 ); // TabellenZeilen-Ende
+
+ if( rWW8Wrt.bWrtWW8 )
+ {
+ // SprmTDefTable
+ // 0+1 - OpCode, 2+3 - Laenge = Cells * (sizeof TC + uint16)
+ // 4 - Cells (max 32!)
+ SwWW8Writer::InsUInt16( aAt, 0xD608 );
+ SwWW8Writer::InsUInt16( aAt, 2 + ( nWWColMax + 1 ) * 2 +
+ ( nWWColMax * 20 ));
+ aAt.Insert( nWWColMax, aAt.Count() ); //
+ }
+ else
+ {
+ // SprmTDefTable
+ // 0 - OpCode, 1,2 - Laenge = Cells * (sizeof TC + uint16)
+ // 3 - Cells (max 32!)
+ aAt.Insert( 190, aAt.Count() );
+ SwWW8Writer::InsUInt16( aAt, nWWColMax * 12 + 4 ); // Sprm-Laenge
+ aAt.Insert( nWWColMax, aAt.Count() ); //
+ }
+
+ SwTwips nSz = 0, nCalc;
+ SwWW8Writer::InsUInt16( aAt, (USHORT)nTblOffset );
+
+ for( nBox = 0, nRealBox = 0; nRealBox < nWWColMax; ++nBox )
+ {
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+
+ const SwFrmFmt* pBoxFmt = pBoxArr[ nBox ]->GetBox()->GetFrmFmt();
+ const SwFmtFrmSize& rLSz = pBoxFmt->GetFrmSize();
+ nSz += rLSz.GetWidth();
+ nCalc = nSz;
+ if( bRelBoxSize )
+ {
+ nCalc *= nPageSize;
+ nCalc /= nTblSz;
+ }
+ SwWW8Writer::InsUInt16( aAt, (USHORT)(nTblOffset + nCalc ));
+ ++nRealBox;
+ }
+
+ for( nBox = 0, nRealBox = 0; nRealBox < nWWColMax; nBox++ )
+ {
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+ // rgf, erstmal alles 0 - WW8: 4, sonst 2 Byte
+ // write vertikal alignment
+ const SwFrmFmt& rFmt = *pBoxArr[ nBox ]->GetBox()->GetFrmFmt();
+ if( rWW8Wrt.bWrtWW8 )
+ {
+ USHORT nFlags = pBoxArr[ nBox ]->GetRowSpan();
+ if( 1 < nFlags )
+ {
+ if( nFlags == pRowSpans[ nBox ] )
+ nFlags = 0x60; // start a new vert. merge
+ else
+ nFlags = 0x20; // continue a vert. merge
+ }
+ else
+ nFlags = 0; // no vert. merge
+
+ switch( rFmt.GetVertOrient().GetVertOrient() )
+ {
+ case VERT_CENTER: nFlags |= 0x080; break;
+ case VERT_BOTTOM: nFlags |= 0x100; break;
+ }
+ SwWW8Writer::InsUInt16( aAt, nFlags );
+ }
+ ++nRealBox;
+ aAt.Insert( aNullBytes, 2, aAt.Count() ); // dummy
+ rWW8Wrt.Out_SwFmtTableBox( aAt, rFmt.GetBox() ); // 8/16 Byte
+ }
+
+ // Background
+ USHORT nBackg;
+ if( pRow->GetBackground() )
+ // over all boxes!
+ nBackg = nWWColMax;
+ else
+ {
+ nBackg = 0;
+ for( nBox = 0, nRealBox = 0; nRealBox < nWWColMax; ++nBox )
+ {
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+
+ SwWriteTableCell* pCell = pBoxArr[ nBox ];
+ if( pCell->GetBackground() ||
+ SFX_ITEM_ON == pCell->GetBox()->GetFrmFmt()->
+ GetItemState( RES_BACKGROUND, FALSE ) )
+ nBackg = nRealBox + 1;
+ ++nRealBox;
+ }
+ }
+
+ if( nBackg )
+ {
+ // TableShade, 0(+1) - OpCode, 1(2) - Count * sizeof( SHD ),
+ // 2..(3..) - SHD
+ if( rWW8Wrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aAt, 0xD609 );
+ else
+ aAt.Insert( (BYTE)191, aAt.Count() );
+ aAt.Insert( (BYTE)(nBackg * 2), aAt.Count() ); // Len
+
+ const SfxPoolItem* pI;
+ for( nBox = 0, nRealBox = 0; nRealBox < nBackg; ++nBox )
+ {
+ if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] )
+ continue;
+
+ USHORT nValue;
+ SwWriteTableCell* pCell = pBoxArr[ nBox ];
+ if( SFX_ITEM_ON == pCell->GetBox()->GetFrmFmt()->
+ GetAttrSet().GetItemState( RES_BACKGROUND, FALSE, &pI )
+ || 0 != ( pI = pCell->GetBackground() )
+ || 0 != ( pI = pRow->GetBackground() ) )
+ {
+ WW8_SHD aShd;
+ rWW8Wrt.TransBrush( ((const SvxBrushItem*)pI)->
+ GetColor(), aShd );
+ nValue = aShd.GetValue();
+ }
+ else
+ nValue = 0;
+ SwWW8Writer::InsUInt16( aAt, nValue );
+ ++nRealBox;
+ }
+ }
+
+ rWW8Wrt.pPapPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ aAt.Count(), aAt.GetData() );
+ if( aAt.Count() > nStdAtLen )
+ aAt.Remove( nStdAtLen, aAt.Count() - nStdAtLen );
+
+ for( nBox = 0; nBox < nColCnt; ++nBox )
+ --pRowSpans[ nBox ];
+ }
+
+ delete pTableWrt;
+ delete pBoxArr;
+ delete pRowSpans;
+
+ // Pam hinter die Tabelle verschieben
+ rWW8Wrt.pCurPam->GetPoint()->nNode = *rNode.EndOfSectionNode();
+
+ return rWrt;
+}
+
+
+/* */
+
+Writer& OutWW8_SwSectionNode( Writer& rWrt, SwSectionNode& rSectionNode )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SwSection& rSection = rSectionNode.GetSection();
+
+ SwNodeIndex aIdx( rSectionNode, 1 );
+ const SwNode& rNd = aIdx.GetNode();
+ if( !rNd.IsSectionNode() )
+ {
+ // Bug 74245 - if the first Node inside the section has an own
+ // PageDesc or PageBreak attribut, then dont write
+ // here the section break
+ ULONG nRstLnNum = 0;
+ const SfxItemSet* pSet;
+ if( rNd.IsTableNode() )
+ pSet = &rNd.GetTableNode()->GetTable().GetFrmFmt()->GetAttrSet();
+ else if( rNd.IsCntntNode() )
+ {
+ pSet = &rNd.GetCntntNode()->GetSwAttrSet();
+ nRstLnNum = ((SwFmtLineNumber&)pSet->Get(
+ RES_LINENUMBER )).GetStartValue();
+ }
+ else
+ pSet = 0;
+
+ const SfxPoolItem* pI;
+ if( pSet && (
+ ( SFX_ITEM_ON != pSet->GetItemState( RES_PAGEDESC, TRUE, &pI )
+ || 0 == ((SwFmtPageDesc*)pI)->GetPageDesc() ) ||
+ ( SFX_ITEM_ON != pSet->GetItemState( RES_BREAK, TRUE, &pI )
+ || SVX_BREAK_NONE == ((SvxFmtBreakItem*)pI)->GetBreak() )))
+ pSet = 0;
+
+ if( !pSet )
+ {
+ // new Section with no own PageDesc/-Break
+ // -> write follow section break;
+ const SwSectionFmt& rFmt = *rSection.GetFmt();
+ rWW8Wrt.ReplaceCr( (char)0xc ); // Indikator fuer Page/Section-Break
+
+ rWW8Wrt.pSepx->AppendSep( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ),
+ rWW8Wrt.pAktPageDesc,
+ &rFmt, nRstLnNum );
+ }
+ }
+ if( TOX_CONTENT_SECTION == rSection.GetType() )
+ rWW8Wrt.bStartTOX = TRUE;
+ return rWrt;
+}
+
+/* */
+
+//---------------------------------------------------------------------------
+// Flys
+//---------------------------------------------------------------------------
+
+void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd )
+{
+ const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
+ if( pTxtAttrs )
+ {
+ for( USHORT n=0; n < pTxtAttrs->Count(); ++n )
+ {
+ const SwTxtAttr* pAttr = (*pTxtAttrs)[ n ];
+ if( RES_TXTATR_FLYCNT == pAttr->Which() )
+ {
+ // zeichengebundenes Attribut
+ const SwFmtFlyCnt& rFlyCntnt = pAttr->GetFlyCnt();
+ const SwFlyFrmFmt& rFlyFrmFmt = *(SwFlyFrmFmt*)rFlyCntnt.GetFrmFmt();
+ const SwNodeIndex* pNodeIndex = rFlyFrmFmt.GetCntnt().GetCntntIdx();
+
+ if( pNodeIndex )
+ {
+ ULONG nStt = pNodeIndex->GetIndex()+1,
+ nEnd = pNodeIndex->GetNode().EndOfSectionIndex();
+
+ if( (nStt < nEnd) && !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() )
+ {
+ Point aOffset;
+ // Rechtecke des Flys und des Absatzes besorgen
+ SwRect aParentRect( rNd.FindLayoutRect( FALSE, &aOffset ) ),
+ aFlyRect( rFlyFrmFmt.FindLayoutRect( FALSE, &aOffset ) );
+
+ aOffset = aFlyRect.Pos() - aParentRect.Pos();
+
+ // PaM umsetzen: auf Inhalt des Fly-Frameformats
+ WW8SaveData aSaveData( *this, nStt, nEnd );
+
+ // wird in Out_SwFmt() ausgewertet
+ pFlyOffset = &aOffset;
+ pFlyFmt = (SwFlyFrmFmt*)&rFlyFrmFmt;
+ // Ok, rausschreiben:
+ WriteText();
+ }
+ }
+ }
+ }
+ }
+}
+
+
+void SwWW8Writer::OutWW8FlyFrm( const SwFrmFmt& rFrmFmt,
+ const Point& rNdTopLeft )
+{
+ if( !bWrtWW8 )
+ {
+ if( RES_DRAWFRMFMT == rFrmFmt.Which() )
+ {
+ ASSERT( !this, "OutWW8FlyFrm: DrawInCnt-Baustelle " );
+ return ;
+ }
+
+ BOOL bDone = FALSE;
+
+ // Hole vom Node und vom letzten Node die Position in der Section
+ /*
+ const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
+
+ ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
+ ULONG nEnd = pDoc->GetNodes()[ nStt - 1 ]->EndOfSectionIndex();
+ */
+ const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
+
+ ULONG nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0;
+ ULONG nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+
+ if( nStt >= nEnd ) // kein Bereich, also kein gueltiger Node
+ return;
+
+ const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor();
+
+ if( !bIsInTable && (FLY_IN_CNTNT == rAnch.GetAnchorId()) )
+ {
+ // ein zeichen(!)gebundener Rahmen liegt vor
+ SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode();
+
+ if( pParTxtNode && !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() )
+ bDone = TRUE;
+ }
+ if( !bDone )
+ {
+ // ein NICHT zeichengebundener Rahmen liegt vor
+
+ const SwFmtFrmSize& rS = rFrmFmt.GetFrmSize();
+ nFlyWidth = rS.GetWidth(); // Fuer Anpassung Graphic-Groesse
+ nFlyHeight = rS.GetHeight();
+
+ ASSERT( !pFlyFmt, "+pFlyFmt ist vor einem Rahmen nicht 0 ( Rahmen in Rahmen ? )" );
+ {
+ WW8SaveData aSaveData( *this, nStt, nEnd );
+ pFlyFmt = (SwFlyFrmFmt*)&rFrmFmt;
+ if( pFlyFmt )
+ {
+ if( bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) )
+ {
+ // Beachten: Flag bOutTable wieder setzen,
+ // denn wir geben ja ganz normalen Content der
+ // Tabelenzelle aus und keinen Rahmen
+ // (Flag wurde oben in aSaveData() geloescht)
+ bOutTable = TRUE;
+ const String& rName = pFlyFmt->GetName();
+ StartCommentOutput( rName );
+ if( !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() )
+ WriteText();
+ EndCommentOutput( rName );
+ }
+ else
+ WriteText();
+ }
+ else
+ ASSERT( !this, "+Fly-Ausgabe ohne FlyFmt" );
+ }
+ // ASSERT( !pFlyFmt, " pFlyFmt ist hinter einem Rahmen nicht 0" );
+ }
+ }
+ else
+ {
+ // write as escher
+ WW8_CP nCP = Fc2Cp( Strm().Tell() );
+ AppendFlyInFlys( nCP, rFrmFmt, rNdTopLeft );
+ }
+}
+
+
+void SwWW8Writer::OutFlyFrms( const SwCntntNode& rNode )
+{
+ if( !pFlyPos )
+ return;
+
+ // gib alle freifliegenden Rahmen die sich auf den akt. Absatz
+ // und evt. auf das aktuelle Zeichen beziehen, aus.
+ ULONG nCurPos = rNode.GetIndex();
+
+ // suche nach dem Anfang der FlyFrames
+ for( USHORT n = 0; n < pFlyPos->Count() &&
+ (*pFlyPos)[n]->GetNdIndex().GetIndex() <
+ nCurPos; ++n )
+ ;
+
+ Point aNdPos, aPgPos;
+ Point* pLayPos;
+ BOOL bValidNdPos = FALSE, bValidPgPos = FALSE;
+
+ if( n < pFlyPos->Count() )
+ {
+ while( ( n < pFlyPos->Count() )
+ && ( nCurPos
+ == (*pFlyPos)[n]->GetNdIndex().GetIndex() ) )
+ {
+ const SwFrmFmt& rFmt = (*pFlyPos)[ n ]->GetFmt();
+ if( FLY_PAGE == rFmt.GetAnchor().GetAnchorId() )
+ {
+ // get the Layout Node-Position.
+ if( !bValidPgPos )
+ {
+ aPgPos = rNode.FindPageFrmRect( FALSE, &aPgPos ).Pos();
+ bValidPgPos = TRUE;
+ }
+ pLayPos = &aPgPos;
+ }
+ else
+ {
+ // get the Layout Node-Position.
+ if( !bValidNdPos )
+ {
+ aNdPos = rNode.FindLayoutRect( FALSE, &aNdPos ).Pos();
+ bValidNdPos = TRUE;
+ }
+ pLayPos = &aNdPos;
+ }
+
+ OutWW8FlyFrm( rFmt, *pLayPos );
+ ++n;
+ }
+ }
+}
+
+/* */
+
+// write data of any redline
+void SwWW8Writer::OutRedline( const SwRedlineData& rRedline )
+{
+ if( rRedline.Next() )
+ OutRedline( *rRedline.Next() );
+
+ static USHORT __READONLY_DATA aSprmIds[ 2 * 2 * 3 ] =
+ {
+ // Ids for insert
+ 0x0801, 0x4804, 0x6805, // for WW8
+ 0x0042, 0x0045, 0x0046, // for WW6
+ // Ids for delete
+ 0x0800, 0x4863, 0x6864, // for WW8
+ 0x0041, 0x0045, 0x0046 // for WW6
+ };
+
+ const USHORT* pSprmIds = 0;
+ switch( rRedline.GetType() )
+ {
+ case REDLINE_INSERT:
+ pSprmIds = aSprmIds;
+ break;
+
+ case REDLINE_DELETE:
+ pSprmIds = aSprmIds + (2 * 3);
+ break;
+
+ case REDLINE_FORMAT:
+ if( bWrtWW8 )
+ {
+ InsUInt16( 0xca57 );
+ pO->Insert( 7, pO->Count() ); // len
+ pO->Insert( 1, pO->Count() );
+ InsUInt16( AddRedlineAuthor( rRedline.GetAuthor() ) );
+ InsUInt32( SwWW8Writer::GetDTTM( rRedline.GetTimeStamp() ));
+ }
+ break;
+ }
+
+ if( pSprmIds )
+ {
+ if( !bWrtWW8 )
+ pSprmIds += 3;
+
+ if( bWrtWW8 )
+ InsUInt16( pSprmIds[0] );
+ else
+ pO->Insert( pSprmIds[0], pO->Count() );
+ pO->Insert( 1, pO->Count() );
+
+ if( bWrtWW8 )
+ InsUInt16( pSprmIds[1] );
+ else
+ pO->Insert( pSprmIds[1], pO->Count() );
+ InsUInt16( AddRedlineAuthor( rRedline.GetAuthor() ) );
+
+ if( bWrtWW8 )
+ InsUInt16( pSprmIds[2] );
+ else
+ pO->Insert( pSprmIds[2], pO->Count() );
+ InsUInt32( SwWW8Writer::GetDTTM( rRedline.GetTimeStamp() ));
+ }
+}
+
+/* */
+
+SwNodeFnTab aWW8NodeFnTab = {
+/* RES_TXTNODE */ OutWW8_SwTxtNode,
+/* RES_GRFNODE */ OutWW8_SwGrfNode,
+/* RES_OLENODE */ OutWW8_SwOleNode,
+};
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/wrtw8nds.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.42 2000/09/18 16:04:57 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.41 2000/08/21 10:13:58 khz
+ Export Line Numbering (restart on new section)
+
+ Revision 1.40 2000/08/18 13:02:21 jp
+ don't export escaped URLs
+
+ Revision 1.39 2000/08/04 10:57:10 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character
+
+ Revision 1.38 2000/07/25 18:51:22 jp
+ Bug #76835#: OutWW8_SwTblNode - count realboxes correct
+
+ Revision 1.37 2000/05/12 16:13:55 jp
+ Changes for Unicode
+
+ Revision 1.36 2000/04/19 18:03:31 jp
+ Bug #75223#: SearchNext - new min pos must be greater than the startpos
+
+ Revision 1.35 2000/04/17 10:33:46 jp
+ Bug #74947#: OutRedlines - set curredline only if the startpos. is the cur.outpos.
+
+ Revision 1.34 2000/03/21 16:22:40 jp
+ Bug #74360#: OutSwTableNode - dont count realboxes only by W97 export
+
+ Revision 1.33 2000/03/21 15:02:52 os
+ StarView remainders removed
+
+ Revision 1.32 2000/03/17 12:33:46 jp
+ Bug #74245#: OutSectionNode - dont write setionbreak if the next node has his own pagebreak
+
+ Revision 1.31 2000/03/15 13:46:31 jp
+ Bug #74070#: WriteTable - look for colspans
+
+ Revision 1.30 2000/03/03 15:20:01 os
+ StarView remainders removed
+
+ Revision 1.29 2000/02/25 09:55:06 jp
+ Bug #73098#: read & write list entries without number
+
+ Revision 1.28 2000/02/21 12:32:50 cmc
+ #69372# Hyperlinks are exported with the extra WW97 data in the Data Stream to activate links in the Word UI
+
+ Revision 1.27 2000/01/25 20:08:49 jp
+ Bug #72146#: OutSwTxtNode - write UNICode if some character can not be converted
+
+ Revision 1.26 1999/12/20 17:41:29 jp
+ Bug #70749#: Date/Time-Numberformats in german format from the formatter
+
+ Revision 1.25 1999/12/14 22:11:57 jp
+ Bug #70846#: OutTxtNode - if numbered Node and no NumRuleItem in Itemset, then put it new
+
+ Revision 1.24 1999/12/13 16:12:35 jp
+ Bug #70789#: TOXMarks may have a position or a range
+
+ Revision 1.23 1999/11/25 21:22:25 jp
+ Bug #70131#: OutFields: append the charattributes of the node to the sprms
+
+ Revision 1.22 1999/11/22 18:26:14 jp
+ export of TOX and TOX entries
+
+ Revision 1.21 1999/11/12 13:08:01 jp
+ OutSwTable: replace CR to 0x7 on the last Box if the SW Table has to much columns
+
+ Revision 1.20 1999/10/29 17:40:14 jp
+ export of 'complex'(vert. merged) tables
+
+ Revision 1.19 1999/10/21 17:53:13 jp
+ Bug #69377#: write redline sprm of formatting correct
+
+ Revision 1.18 1999/10/14 21:06:01 jp
+ Bug #68617#,#68705# and other little things
+
+ Revision 1.17 1999/10/14 11:09:26 jp
+ export Redlines into W95/W97
+
+ Revision 1.16 1999/10/13 18:09:37 jp
+ write redlines
+
+ Revision 1.15 1999/10/11 11:00:10 jp
+ some changes for export EditEngine text in WW-Format
+
+ Revision 1.14 1999/09/10 16:29:58 jp
+ SwTable: get from Layout the upper size, Bug #67922#: dont W95 loop if fly in tablecells
+
+ Revision 1.13 1999/09/09 17:39:52 jp
+ Bug #68634#: write TableLineHeight as int16 and not as int32
+
+ Revision 1.12 1999/08/30 16:55:30 JP
+ write vertical alignment of tablecells
+
+
+ Rev 1.11 30 Aug 1999 18:55:30 JP
+ write vertical alignment of tablecells
+
+ Rev 1.10 23 Jul 1999 11:18:38 KZ
+ rem. CHARSET Symbols
+
+ Rev 1.9 21 Jul 1999 18:28:22 JP
+ W97 Export: experimental escher export
+
+ Rev 1.8 06 Jul 1999 14:53:58 JP
+ W97-Export corrections
+
+ Rev 1.7 30 Jun 1999 19:56:40 JP
+ W97-Export: Fields/PostIts/References
+
+ Rev 1.6 25 Jun 1999 18:43:08 JP
+ W97-Export: hyperlinks and fields, Bug #67174#
+
+ Rev 1.5 24 Jun 1999 22:52:18 JP
+ Export of Bookmarks and Hyperlinks
+
+ Rev 1.4 23 Jun 1999 20:14:42 JP
+ W97-Export: write Bookmarks
+
+ Rev 1.3 23 Jun 1999 12:46:14 JP
+ Export of numbers und outlinenumbers
+
+ Rev 1.2 16 Jun 1999 19:54:54 JP
+ Change interface of base class Writer, Export of W97 NumRules
+
+ Rev 1.1 08 Jun 1999 09:22:36 JP
+ WW97-Export: 1.Teil fuer Tabellen (W95-Funktionalitaet)
+
+ Rev 1.0 04 Jun 1999 17:49:00 JP
+ WW97-Export: Code aufgeteilt
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
new file mode 100644
index 000000000000..f07bc98fb311
--- /dev/null
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -0,0 +1,627 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtw8num.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SV_FONT_HXX //autogen
+#include <vcl/font.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen wg. SvxLRSpaceItem
+#include <svx/lrspitem.hxx>
+#endif
+
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX //autogen
+#include <docary.hxx>
+#endif
+#ifndef _NUMRULE_HXX //autogen
+#include <numrule.hxx>
+#endif
+#ifndef _PARATR_HXX //autogen
+#include <paratr.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+
+
+USHORT SwWW8Writer::GetId( const SwNumRule& rNumRule ) const
+{
+ if( !pUsedNumTbl )
+ {
+ SwWW8Writer* pThis = (SwWW8Writer*)this;
+ pThis->pUsedNumTbl = new SwNumRuleTbl;
+ pThis->pUsedNumTbl->Insert( &pDoc->GetNumRuleTbl(), 0 );
+ for( USHORT n = pUsedNumTbl->Count(); n; )
+ if( !pDoc->IsUsed( *pUsedNumTbl->GetObject( --n )) )
+ pThis->pUsedNumTbl->Remove( n );
+
+ // jetzt noch die OutlineRule einfuegen
+ SwNumRule* pR = (SwNumRule*)pDoc->GetOutlineNumRule();
+ pThis->pUsedNumTbl->Insert( pR, pUsedNumTbl->Count() );
+ }
+ SwNumRule* p = (SwNumRule*)&rNumRule;
+ return pUsedNumTbl->GetPos( p );
+}
+
+void SwWW8Writer::OutListTab()
+{
+ if( !pUsedNumTbl )
+ return ; // no numbering is used
+
+ USHORT nCount = pUsedNumTbl->Count();
+
+ pFib->fcPlcfLst = pTableStrm->Tell();
+ SwWW8Writer::WriteShort( *pTableStrm, nCount );
+
+ // First Loop - write static data of SwNumRule - LSTF
+ for( USHORT n = 0; n < nCount; ++n )
+ {
+ const SwNumRule& rRule = *pUsedNumTbl->GetObject( n );
+
+ SwWW8Writer::WriteLong( *pTableStrm, n + 1 );
+ SwWW8Writer::WriteLong( *pTableStrm, n + 1 );
+
+ // mit keinen Styles verbunden
+ for( int i = 0; i < nWW8MaxListLevel; ++i )
+ SwWW8Writer::WriteShort( *pTableStrm, 0xFFF );
+
+ BYTE nFlags = 0, nDummy = 0;
+ if( rRule.IsContinusNum() )
+ nFlags |= 0x1;
+ *pTableStrm << nFlags << nDummy;
+ }
+
+ // set len to FIB
+ pFib->lcbPlcfLst = pTableStrm->Tell() - pFib->fcPlcfLst;
+
+ // second Loop - write all Levels for all SwNumRules - LVLF
+
+ // prepare the NodeNum to generate the NumString
+ SwNodeNum aNdNum( 0 );
+ for( n = 0; n < nWW8MaxListLevel; ++n )
+ aNdNum.GetLevelVal()[ n ] = n;
+
+ BYTE aPapSprms [] = {
+ 0x0f, 0x84, 0, 0, // sprmPDxaLeft
+ 0x11, 0x84, 0, 0 // sprmPDxaLeft1
+ };
+
+ for( n = 0; n < nCount; ++n )
+ {
+ const SwNumRule& rRule = *pUsedNumTbl->GetObject( n );
+ BYTE nLvl, nFlags,
+ nLevels = rRule.IsContinusNum() ? 1 : nWW8MaxListLevel;
+ for( nLvl = 0; nLvl < nLevels; ++nLvl )
+ {
+ // write the static data of the SwNumFmt of this level
+ BYTE aNumLvlPos[ nWW8MaxListLevel ] = { 0,0,0,0,0,0,0,0,0 };
+
+ const SwNumFmt& rFmt = rRule.Get( nLvl );
+ SwWW8Writer::WriteLong( *pTableStrm, rFmt.GetStartValue() );
+ *pTableStrm << SwWW8Writer::GetNumId( rFmt.eType );
+
+ switch( rFmt.GetAdjust() )
+ {
+ case SVX_ADJUST_CENTER: nFlags = 1; break;
+ case SVX_ADJUST_RIGHT: nFlags = 2; break;
+ default: nFlags = 0; break;
+ }
+ *pTableStrm << nFlags;
+
+ // Build the NumString for this Level
+ String sNumStr;
+ BOOL bWriteBullet = FALSE;
+ rtl_TextEncoding eChrSet = RTL_TEXTENCODING_SYMBOL;
+ if( SVX_NUM_CHAR_SPECIAL == rFmt.eType ||
+ SVX_NUM_BITMAP == rFmt.eType )
+ {
+ sNumStr = rFmt.GetBulletChar();
+ bWriteBullet = TRUE;
+
+ const Font* pFont = rFmt.GetBulletFont();
+ if( !pFont )
+ pFont = &SwNumRule::GetDefBulletFont();
+
+ eChrSet = pFont->GetCharSet();
+ }
+ else if( SVX_NUM_NUMBER_NONE != rFmt.eType )
+ {
+ BYTE* pLvlPos = aNumLvlPos;
+ aNdNum.SetLevel( nLvl );
+ sNumStr = rRule.MakeNumString( aNdNum, FALSE, TRUE );
+
+ // now search the nums in the string
+ for( BYTE i = 0; i <= nLvl; ++i )
+ {
+ String sSrch( String::CreateFromInt32( i ));
+ xub_StrLen nFnd = sNumStr.Search( sSrch );
+ if( STRING_NOTFOUND != nFnd )
+ {
+ *pLvlPos = (BYTE)(nFnd + rFmt.GetPrefix().Len() + 1 );
+ ++pLvlPos;
+ sNumStr.SetChar( nFnd, (char)i );
+ }
+ }
+
+ if( rFmt.GetPrefix().Len() )
+ sNumStr.Insert( rFmt.GetPrefix(), 0 );
+ if( rFmt.GetPostfix().Len() )
+ sNumStr += rFmt.GetPostfix();
+ }
+
+ // write the rgbxchNums[9]
+ pTableStrm->Write( aNumLvlPos, nWW8MaxListLevel );
+
+ nFlags = 2; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing
+ *pTableStrm << nFlags;
+ // dxaSoace/dxaIndent (Word 6 compatibility)
+ SwWW8Writer::WriteLong( *pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *pTableStrm, 0 );
+
+ // cbGrpprlChpx
+ WW8Bytes aCharAtrs;
+ if( rFmt.GetCharFmt() || bWriteBullet )
+ {
+ WW8Bytes* pOldpO = pO;
+ pO = &aCharAtrs;
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN,
+ RES_CHRATR_END );
+ const SfxItemSet* pOutSet;
+ if( bWriteBullet )
+ {
+ const Font* pFont = rFmt.GetBulletFont();
+ if( !pFont )
+ pFont = &SwNumRule::GetDefBulletFont();
+ pOutSet = &aSet;
+
+ if( rFmt.GetCharFmt() )
+ aSet.Put( rFmt.GetCharFmt()->GetAttrSet() );
+ aSet.Put( SvxFontItem( pFont->GetFamily(),
+ pFont->GetName(), pFont->GetStyleName(),
+ pFont->GetPitch(), pFont->GetCharSet() ));
+ }
+ else
+ pOutSet = &rFmt.GetCharFmt()->GetAttrSet();
+
+ Out_SfxItemSet( *pOutSet, FALSE, TRUE );
+ pO = pOldpO;
+ }
+ nFlags = (BYTE)aCharAtrs.Count();
+ *pTableStrm << nFlags;
+
+ // cbGrpprlPapx
+ nFlags = sizeof( aPapSprms );
+ *pTableStrm << nFlags;
+
+ // reserved
+ SwWW8Writer::WriteShort( *pTableStrm, 0 );
+
+ // write Papx
+ BYTE* pData = aPapSprms + 2;
+ Set_UInt16( pData, rFmt.GetAbsLSpace() );
+ pData += 2;
+ Set_UInt16( pData, rFmt.GetFirstLineOffset() );
+ pTableStrm->Write( aPapSprms, sizeof( aPapSprms ));
+
+ // write Chpx
+ if( aCharAtrs.Count() )
+ pTableStrm->Write( aCharAtrs.GetData(), aCharAtrs.Count() );
+
+ // write the num string
+ SwWW8Writer::WriteShort( *pTableStrm, sNumStr.Len() );
+ SwWW8Writer::WriteString16( *pTableStrm, sNumStr, FALSE );
+ }
+ }
+}
+
+void SwWW8Writer::OutOverrideListTab()
+{
+ if( !pUsedNumTbl )
+ return ; // no numbering is used
+
+ // write the "list format override" - LFO
+ USHORT nCount = pUsedNumTbl->Count();
+
+ pFib->fcPlfLfo = pTableStrm->Tell();
+ SwWW8Writer::WriteLong( *pTableStrm, nCount );
+
+ for( USHORT n = 0; n < nCount; ++n )
+ {
+ SwWW8Writer::WriteLong( *pTableStrm, n + 1 );
+ SwWW8Writer::FillCount( *pTableStrm, 12 );
+ }
+ for( n = 0; n < nCount; ++n )
+ SwWW8Writer::WriteLong( *pTableStrm, -1 ); // no overwrite
+
+ // set len to FIB
+ pFib->lcbPlfLfo = pTableStrm->Tell() - pFib->fcPlfLfo;
+}
+
+void SwWW8Writer::OutListNamesTab()
+{
+ if( !pUsedNumTbl )
+ return ; // no numbering is used
+
+ // write the "list format override" - LFO
+ USHORT nNms = 0, nCount = pUsedNumTbl->Count();
+
+ pFib->fcSttbListNames = pTableStrm->Tell();
+ SwWW8Writer::WriteShort( *pTableStrm, -1 );
+ SwWW8Writer::WriteLong( *pTableStrm, nCount );
+
+ for( ; nNms < nCount; ++nNms )
+ {
+ const SwNumRule& rRule = *pUsedNumTbl->GetObject( nNms );
+ String sNm;
+ if( !rRule.IsAutoRule() )
+ sNm = rRule.GetName();
+
+ SwWW8Writer::WriteShort( *pTableStrm, sNm.Len() );
+ if( sNm.Len() )
+ SwWW8Writer::WriteString16( *pTableStrm, sNm, FALSE );
+ }
+
+ SwWW8Writer::WriteLong( *pTableStrm, pFib->fcSttbListNames + 2, nNms );
+ // set len to FIB
+ pFib->lcbSttbListNames = pTableStrm->Tell() - pFib->fcSttbListNames;
+}
+
+/* */
+
+// old WW95-Code
+
+void SwWW8Writer::Out_Olst( const SwNumRule& rRule )
+{
+ static BYTE __READONLY_DATA aAnlvBase[] = { // Defaults
+ 1,0,0, // Upper Roman
+ 0x0C, // Hanging Indent, fPrev
+ 0,0,1,0x80,0,0,1,0,0x1b,1,0,0 };
+
+ static BYTE __READONLY_DATA aSprmOlstHdr[] = { 133, 212 };
+
+ pO->Insert( aSprmOlstHdr, sizeof( aSprmOlstHdr ), pO->Count() );
+ WW8_OLST aOlst;
+ memset( &aOlst, 0, sizeof(aOlst) );
+ BYTE* pC = aOlst.rgch;
+ BYTE* pChars = (BYTE*)pC;
+ USHORT nCharLen = 64;
+
+ USHORT j;
+ for( j = 0; j < nWW8MaxListLevel; j++ ) // 9 variable ANLVs
+ {
+ memcpy( &aOlst.rganlv[j], aAnlvBase, sizeof( WW8_ANLV ) ); // Defaults
+
+ const SwNumFmt* pFmt = rRule.GetNumFmt( j );
+ if( pFmt )
+ BuildAnlvBase( aOlst.rganlv[j], pChars, nCharLen, rRule,
+ *pFmt, (BYTE)j );
+ }
+
+ pO->Insert( (BYTE*)&aOlst, sizeof( aOlst ), pO->Count() );
+}
+
+
+void SwWW8Writer::Out_WwNumLvl( BYTE nWwLevel )
+{
+ pO->Insert( 13, pO->Count() );
+ pO->Insert( nWwLevel, pO->Count() );
+}
+
+void SwWW8Writer::Out_SwNumLvl( BYTE nSwLevel )
+{
+ Out_WwNumLvl( ( nSwLevel == NO_NUM ) ? 0 : nSwLevel + 1 );
+}
+
+void SwWW8Writer::BuildAnlvBulletBase( WW8_ANLV& rAnlv, BYTE*& rpCh,
+ USHORT& rCharLen, const SwNumFmt& rFmt )
+{
+ BYTE nb = 0; // Zahlentyp
+ ByteToSVBT8( 11, rAnlv.nfc );
+
+ switch( rFmt.GetAdjust() )
+ {
+ case SVX_ADJUST_RIGHT: nb = 2; break;
+ case SVX_ADJUST_CENTER: nb = 1; break;
+ case SVX_ADJUST_BLOCK:
+ case SVX_ADJUST_BLOCKLINE: nb = 3; break;
+ }
+ if( rFmt.GetFirstLineOffset() < 0 )
+ nb |= 0x8; // number will be displayed using a hanging indent
+ ByteToSVBT8( nb, rAnlv.aBits1 );
+
+ xub_StrLen nS = rFmt.GetPrefix().Len();
+ if( 1 < rCharLen )
+ {
+ const Font& rFont = rFmt.GetBulletFont()
+ ? *rFmt.GetBulletFont()
+ : SwNumRule::GetDefBulletFont();
+ USHORT nFontId = GetId( rFont );
+ ShortToSVBT16( nFontId, rAnlv.ftc );
+ *rpCh = ByteString::ConvertFromUnicode( rFmt.GetBulletChar(),
+ rFont.GetCharSet() );
+ rpCh++;
+ rCharLen--;
+ ByteToSVBT8( 1, rAnlv.cbTextBefore );
+ }
+ ShortToSVBT16( -rFmt.GetFirstLineOffset(), rAnlv.dxaIndent );
+ ShortToSVBT16( rFmt.GetCharTextOffset(), rAnlv.dxaSpace );
+}
+
+static void SwWw8_InsertAnlText( const String& rStr, BYTE*& rpCh,
+ USHORT& rCharLen, SVBT8& r8Len )
+{
+ BYTE nb = 0;
+ WW8Bytes aO;
+ SwWW8Writer::InsAsString8( aO, rStr, RTL_TEXTENCODING_MS_1252 );
+
+ USHORT nCnt = aO.Count();
+ if( nCnt && nCnt < rCharLen )
+ {
+ nb = (BYTE)nCnt;
+ memcpy( rpCh, aO.GetData(), nCnt );
+ rpCh += nCnt;
+ rCharLen -= nCnt;
+ }
+ ByteToSVBT8( nb, r8Len );
+}
+
+void SwWW8Writer::BuildAnlvBase( WW8_ANLV& rAnlv, BYTE*& rpCh,
+ USHORT& rCharLen, const SwNumRule& rRul,
+ const SwNumFmt& rFmt, BYTE nSwLevel )
+{
+ ByteToSVBT8( SwWW8Writer::GetNumId( rFmt.eType ), rAnlv.nfc );
+
+ BYTE nb = 0;
+ switch( rFmt.GetAdjust() )
+ {
+ case SVX_ADJUST_RIGHT: nb = 2; break;
+ case SVX_ADJUST_CENTER: nb = 1; break;
+ case SVX_ADJUST_BLOCK:
+ case SVX_ADJUST_BLOCKLINE: nb = 3; break;
+ }
+
+ BOOL bInclUpper = rFmt.IsInclUpperLevel();
+ if( bInclUpper )
+ nb |= 0x4; // include previous levels
+
+ if( rFmt.GetFirstLineOffset() < 0 )
+ nb |= 0x8; // number will be displayed using a hanging indent
+ ByteToSVBT8( nb, rAnlv.aBits1 );
+
+ if( bInclUpper && !rRul.IsContinusNum() )
+ {
+ if( (nSwLevel >= 1 )
+ && (nSwLevel<= nWW8MaxListLevel )
+ && (rFmt.eType != SVX_NUM_NUMBER_NONE ) ) // UEberhaupt Nummerierung ?
+ { // -> suche, ob noch Zahlen davor
+ BYTE nUpper = rFmt.GetUpperLevel();
+ if( (nUpper >= 0 )
+ && (nUpper <= nWW8MaxListLevel )
+ && (rRul.Get(nUpper).eType != SVX_NUM_NUMBER_NONE ) ) // Nummerierung drueber ?
+ {
+ // dann Punkt einfuegen
+ SwWw8_InsertAnlText( aDotStr, rpCh, rCharLen,
+ rAnlv.cbTextBefore );
+ }
+
+ }
+ }
+ else
+ {
+ SwWw8_InsertAnlText( rFmt.GetPrefix(), rpCh, rCharLen,
+ rAnlv.cbTextBefore );
+ SwWw8_InsertAnlText( rFmt.GetPostfix(), rpCh, rCharLen,
+ rAnlv.cbTextAfter );
+ }
+
+ ShortToSVBT16( rFmt.GetStartValue(), rAnlv.iStartAt );
+ ShortToSVBT16( -rFmt.GetFirstLineOffset(), rAnlv.dxaIndent );
+ ShortToSVBT16( rFmt.GetCharTextOffset(), rAnlv.dxaSpace );
+}
+
+void SwWW8Writer::Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt,
+ BYTE nSwLevel )
+{
+ static BYTE __READONLY_DATA aSprmAnldDefault[54] = {
+ 12, 52,
+ 1,0,0,0x0c,0,0,1,0x80,0,0,1,0,0x1b,1,0,0,0x2e,
+ 0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+ BYTE aSprmAnld[54];
+
+ memcpy( aSprmAnld, aSprmAnldDefault, sizeof( aSprmAnld ) );
+ WW8_ANLD* pA = (WW8_ANLD*)(aSprmAnld + 2); // handlicher Pointer
+
+ BYTE* pChars = (BYTE*)(pA->rgchAnld);
+ USHORT nCharLen = 31;
+
+ if( nSwLevel == 11 )
+ BuildAnlvBulletBase( pA->eAnlv, pChars, nCharLen, rFmt );
+ else
+ BuildAnlvBase( pA->eAnlv, pChars, nCharLen, rRul, rFmt, nSwLevel );
+
+ // ... und raus damit
+ OutSprmBytes( (BYTE*)&aSprmAnld, sizeof( aSprmAnld ) );
+}
+
+
+// Return: ist es eine Gliederung ?
+BOOL SwWW8Writer::Out_SwNum( const SwTxtNode* pNd )
+{
+ BYTE nSwLevel = pNd->GetNum()->GetLevel();
+ const SwNumRule* pRul = pNd->GetNumRule();
+ if( !pRul || nSwLevel == nWW8MaxListLevel )
+ return FALSE;
+
+ BOOL bNoNum = FALSE;
+ if( nSwLevel == NO_NUM )
+ nSwLevel = NO_NUMLEVEL | 0 ; // alte Codierung...
+ if( ( nSwLevel & NO_NUMLEVEL ) != 0 )
+ {
+ nSwLevel &= ~NO_NUMLEVEL; // 0..nWW8MaxListLevel
+ bNoNum = TRUE;
+ }
+
+ BOOL bRet = TRUE;
+ const SwNumFmt* pFmt = &pRul->Get( nSwLevel );// interessierendes Format
+
+#ifdef NUM_RELSPACE
+ SwNumFmt aFmt( *pFmt );
+ const SvxLRSpaceItem& rLR = (SvxLRSpaceItem&)pNd->SwCntntNode::GetAttr( RES_LR_SPACE );
+ aFmt.SetAbsLSpace( aFmt.GetAbsLSpace() + rLR.GetLeft() );
+ pFmt = &aFmt;
+#endif
+
+#ifdef DEBUG
+ BYTE nIncl = pRul->Get(1).GetUpperLevel();
+#endif
+
+ if( pFmt->eType == SVX_NUM_NUMBER_NONE
+ || pFmt->eType == SVX_NUM_CHAR_SPECIAL
+ || pFmt->eType == SVX_NUM_BITMAP )
+ {
+ // Aufzaehlung
+ Out_WwNumLvl( (bNoNum) ? 12 : 11 );
+ Out_NumRuleAnld( *pRul, *pFmt, 11 );
+ bRet = FALSE;
+ }
+ else if( pRul->IsContinusNum()
+ || ( pRul->Get(1).GetUpperLevel() <= 1 ) )
+ {
+ // Nummerierung
+ Out_WwNumLvl( (bNoNum) ? 12 : 10 );
+ Out_NumRuleAnld( *pRul, *pFmt, 10 );
+ bRet = FALSE;
+ }
+ else
+ {
+ // Gliederung
+ Out_SwNumLvl( (bNoNum) ? 12 :nSwLevel );
+ Out_NumRuleAnld( *pRul, *pFmt, nSwLevel );
+ }
+ return bRet;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/wrtw8num.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.9 2000/09/18 16:04:58 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.8 2000/07/24 13:03:36 jp
+ Bug #76561#: convert Bulletchar to unicode
+
+ Revision 1.7 2000/05/12 16:13:58 jp
+ Changes for Unicode
+
+ Revision 1.6 2000/02/25 09:55:10 jp
+ Bug #73098#: read & write list entries without number
+
+ Revision 1.5 1999/12/09 15:42:43 jp
+ Bug #70669#: GetId without ASSERT
+
+ Revision 1.4 1999/10/13 18:09:41 jp
+ write redlines
+
+ Revision 1.3 1999/06/23 10:46:16 JP
+ Export of numbers und outlinenumbers
+
+
+ Rev 1.2 23 Jun 1999 12:46:16 JP
+ Export of numbers und outlinenumbers
+
+ Rev 1.1 21 Jun 1999 10:06:58 JP
+ write ListOverride table in correct format
+
+ Rev 1.0 16 Jun 1999 19:56:20 JP
+ Change interface of base class Writer, Export of W97 NumRules
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
new file mode 100644
index 000000000000..4f7a9ea24b4d
--- /dev/null
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -0,0 +1,1942 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtw8sty.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#define _SVSTDARR_STRINGSSORTDTOR
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVDOBJ_HXX //autogen wg. SdrObject
+#include <svx/svdobj.hxx>
+#endif
+#ifndef _SVDOTEXT_HXX //autogen wg. SdrTextObj
+#include <svx/svdotext.hxx>
+#endif
+
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX //autogen
+#include <docary.hxx>
+#endif
+#ifndef _POOLFMT_HXX //autogen
+#include <poolfmt.hxx>
+#endif
+#ifndef _FMTCOL_HXX //autogen
+#include <fmtcol.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _PAGEDESC_HXX //autogen
+#include <pagedesc.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen
+#include <ndtxt.hxx>
+#endif
+#ifndef _FTNINFO_HXX //autogen
+#include <ftninfo.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen
+#include <section.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _NDINDEX_HXX //autogen
+#include <ndindex.hxx>
+#endif
+#ifndef _TXTFTN_HXX
+#include <txtftn.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx>
+#endif
+#ifndef _DCONTACT_HXX
+#include <dcontact.hxx>
+#endif
+#ifndef _FMTCNCT_HXX
+#include <fmtcnct.hxx>
+#endif
+#ifndef _FTNIDX_HXX
+#include <ftnidx.hxx>
+#endif
+
+#ifndef SW_LINEINFO_HXX
+#include <lineinfo.hxx>
+#endif
+
+
+struct WW8_SED
+{
+ SVBT16 aBits1; // orientation change + internal, Default: 6
+ SVBT32 fcSepx; // FC file offset to beginning of SEPX for section.
+ // 0xFFFFFFFF for no Sprms
+ SVBT16 fnMpr; // used internally by Windows Word, Default: 0
+ SVBT32 fcMpr; // FC, points to offset in FC space for MacWord
+ // Default: 0xffffffff ( nothing )
+ // cbSED is 12 (decimal)), C (hex).
+};
+
+struct WW8_PdAttrDesc
+{
+ BYTE* pData;
+ USHORT nLen;
+ WW8_FC nSepxFcPos;
+};
+
+
+SV_IMPL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo )
+
+// class WW8_WrPlc0 ist erstmal nur fuer Header / Footer-Positionen, d.h. es gibt
+// keine inhaltstragende Struktur.
+class WW8_WrPlc0
+{
+ SvULongs aPos; // PTRARR von CPs / FCs
+ ULONG nOfs;
+public:
+ WW8_WrPlc0( ULONG nOffset );
+ USHORT Count() const { return aPos.Count(); }
+ void Append( ULONG nStartCpOrFc );
+ void Write( SvStream& rStrm );
+ ULONG GetCP( USHORT n ) const { return aPos[ n ]; }
+};
+
+
+//------------------------------------------------------------
+// Styles
+//------------------------------------------------------------
+
+#define WW8_RESERVED_SLOTS 15
+
+// GetId( SwCharFmt ) zur Benutzung im Text -> nil verboten,
+// "Default Char Style" stattdessen
+USHORT SwWW8Writer::GetId( const SwCharFmt& rFmt ) const
+{
+ USHORT nRet = pStyles->Sty_GetWWSlot( rFmt );
+ return ( nRet != 0xfff ) ? nRet : 10; // Default Char Style
+}
+
+// GetId( SwTxtFmtColl ) zur Benutzung an TextNodes -> nil verboten,
+// "Standard" stattdessen
+USHORT SwWW8Writer::GetId( const SwTxtFmtColl& rColl ) const
+{
+ USHORT nRet = pStyles->Sty_GetWWSlot( rColl );
+ return ( nRet != 0xfff ) ? nRet : 0; // Default TxtFmtColl
+}
+
+
+
+//typedef pFmtT
+WW8WrtStyle::WW8WrtStyle( SwWW8Writer& rWr )
+ : rWrt( rWr ), nPOPosStdLen1( 0 ), nPOPosStdLen2( 0 )
+{
+ rWrt.pO->Remove( 0, rWrt.pO->Count() ); // leeren
+ SwDoc& rDoc = *rWrt.pDoc;
+
+ // if exist any Foot-/End-Notes then get from the EndNoteInfo struct
+ // the CharFormats. They will create it!
+ if( rDoc.GetFtnIdxs().Count() )
+ {
+ rDoc.GetEndNoteInfo().GetAnchorCharFmt( rDoc );
+ rDoc.GetEndNoteInfo().GetCharFmt( rDoc );
+ rDoc.GetFtnInfo().GetAnchorCharFmt( rDoc );
+ rDoc.GetFtnInfo().GetCharFmt( rDoc );
+ }
+ USHORT nAlloc = WW8_RESERVED_SLOTS + rDoc.GetCharFmts()->Count() - 1 +
+ rDoc.GetTxtFmtColls()->Count() - 1;
+ // etwas grosszuegig ( bis zu 15 frei )
+ pFmtA = new SwFmt*[ nAlloc ];
+ memset( pFmtA, 0, nAlloc * sizeof( SwFmt* ) );
+ BuildStyleTab();
+}
+
+WW8WrtStyle::~WW8WrtStyle()
+{
+ delete[]( pFmtA );
+ rWrt.pO->Remove( 0, rWrt.pO->Count() ); // leeren
+}
+
+// Sty_SetWWSlot() fuer Abhaengigkeiten der Styles -> nil ist erlaubt
+USHORT WW8WrtStyle::Sty_GetWWSlot( const SwFmt& rFmt ) const
+{
+ register USHORT n;
+ for( n = 0; n < nUsedSlots; n++ )
+ if( pFmtA[n] == &rFmt )
+ return n;
+ return 0xfff; // 0xfff: WW: nil
+}
+
+USHORT WW8WrtStyle::Build_GetWWSlot( const SwFmt& rFmt )
+{
+ USHORT nRet;
+ switch( nRet = rFmt.GetPoolFmtId() )
+ {
+ case RES_POOLCOLL_STANDARD: nRet = 0; break;
+
+ case RES_POOLCOLL_HEADLINE1:
+ case RES_POOLCOLL_HEADLINE2:
+ case RES_POOLCOLL_HEADLINE3:
+ case RES_POOLCOLL_HEADLINE4:
+ case RES_POOLCOLL_HEADLINE5:
+ case RES_POOLCOLL_HEADLINE6:
+ case RES_POOLCOLL_HEADLINE7:
+ case RES_POOLCOLL_HEADLINE8:
+ case RES_POOLCOLL_HEADLINE9: nRet -= RES_POOLCOLL_HEADLINE1-1; break;
+
+// case RES_POOLCHR_FOOTNOTE_ANCHOR: nRet =
+// case RES_POOLCHR_ENDNOTE_ANCHOR:
+ default:
+ nRet = nUsedSlots++;
+ break;
+ }
+ return nRet;
+}
+
+USHORT WW8WrtStyle::GetWWId( const SwFmt& rFmt ) const
+{
+ USHORT nRet = 0xffe; // User-Style als default
+ USHORT nPoolId = rFmt.GetPoolFmtId();
+ if( nPoolId == RES_POOLCOLL_STANDARD )
+ nRet = 0;
+ else if( nPoolId >= RES_POOLCOLL_HEADLINE1 &&
+ nPoolId <= RES_POOLCOLL_HEADLINE9 )
+ nRet = nPoolId + 1 - RES_POOLCOLL_HEADLINE1;
+ else if( nPoolId >= RES_POOLCOLL_TOX_IDX1 &&
+ nPoolId <= RES_POOLCOLL_TOX_IDX3 )
+ nRet = nPoolId + 10 - RES_POOLCOLL_TOX_IDX1;
+ else if( nPoolId >= RES_POOLCOLL_TOX_CNTNT1 &&
+ nPoolId <= RES_POOLCOLL_TOX_CNTNT5 )
+ nRet = nPoolId + 19 - RES_POOLCOLL_TOX_CNTNT1;
+ else if( nPoolId >= RES_POOLCOLL_TOX_CNTNT6 &&
+ nPoolId <= RES_POOLCOLL_TOX_CNTNT9 )
+ nRet = nPoolId + 24 - RES_POOLCOLL_TOX_CNTNT6;
+ else
+ switch( nPoolId )
+ {
+ case RES_POOLCOLL_FOOTNOTE: nRet = 29; break;
+ case RES_POOLCOLL_HEADER: nRet = 31; break;
+ case RES_POOLCOLL_FOOTER: nRet = 32; break;
+ case RES_POOLCOLL_TOX_IDXH: nRet = 33; break;
+ case RES_POOLCOLL_JAKETADRESS: nRet = 36; break;
+ case RES_POOLCOLL_SENDADRESS: nRet = 37; break;
+ case RES_POOLCOLL_ENDNOTE: nRet = 43; break;
+ case RES_POOLCOLL_LISTS_BEGIN: nRet = 47; break;
+ case RES_POOLCOLL_DOC_TITEL: nRet = 62; break;
+ case RES_POOLCOLL_SIGNATURE: nRet = 64; break;
+ case RES_POOLCOLL_TEXT: nRet = 66; break;
+ case RES_POOLCOLL_TEXT_MOVE: nRet = 67; break;
+ case RES_POOLCOLL_DOC_SUBTITEL: nRet = 74; break;
+ case RES_POOLCOLL_TEXT_IDENT: nRet = 77; break;
+
+ case RES_POOLCHR_FOOTNOTE_ANCHOR: nRet = 38; break;
+ case RES_POOLCHR_ENDNOTE_ANCHOR: nRet = 42; break;
+ case RES_POOLCHR_INET_NORMAL: nRet = 85; break;
+ case RES_POOLCHR_INET_VISIT: nRet = 86; break;
+ case RES_POOLCHR_HTML_STRONG: nRet = 87; break;
+ case RES_POOLCHR_HTML_EMPHASIS: nRet = 88; break;
+ case RES_POOLCHR_LINENUM: nRet = 40; break;
+ case RES_POOLCHR_PAGENO: nRet = 41; break;
+ }
+ return nRet;
+}
+
+void WW8WrtStyle::BuildStyleTab()
+{
+ nUsedSlots = WW8_RESERVED_SLOTS; // soviele sind reserviert fuer
+ // Standard und HeadingX u.a.
+ SwFmt* pFmt;
+ USHORT n;
+ const SvPtrarr& rArr = *rWrt.pDoc->GetCharFmts(); // erst CharFmt
+ // das Default-ZeichenStyle ( 0 ) wird nicht mit ausgegeben !
+ for( n = 1; n < rArr.Count(); n++ )
+ {
+ pFmt = (SwFmt*)rArr[n];
+ pFmtA[ Build_GetWWSlot( *pFmt ) ] = pFmt;
+ }
+ const SvPtrarr& rArr2 = *rWrt.pDoc->GetTxtFmtColls(); // dann TxtFmtColls
+ // das Default-TextStyle ( 0 ) wird nicht mit ausgegeben !
+ for( n = 1; n < rArr2.Count(); n++ )
+ {
+ pFmt = (SwFmt*)rArr2[n];
+ pFmtA[ Build_GetWWSlot( *pFmt ) ] = pFmt;
+ }
+}
+
+void WW8WrtStyle::WriteStyle( SvStream& rStrm )
+{
+ WW8Bytes* pO = rWrt.pO;
+
+ short nLen = pO->Count() - 2; // Laenge des Styles
+ BYTE* p = (BYTE*)pO->GetData() + nPOPosStdLen1;
+ ShortToSVBT16( nLen, p ); // nachtragen
+ p = (BYTE*)pO->GetData() + nPOPosStdLen2;
+ ShortToSVBT16( nLen, p ); // dito
+
+ rStrm.Write( pO->GetData(), pO->Count() ); // ins File damit
+ pO->Remove( 0, pO->Count() ); // leeren fuer naechsten
+}
+
+
+void WW8WrtStyle::BuildStd( const String& rName, BOOL bPapFmt, short nWwBase,
+ short nWwNext, USHORT nWwId )
+{
+ BYTE aWW8_STD[ sizeof( WW8_STD ) ];
+ BYTE* pData = aWW8_STD;
+ memset( &aWW8_STD, 0, sizeof( WW8_STD ) );
+
+ UINT16 nBit16 = 0x1000; // fInvalHeight
+ nBit16 |= (0x0FFF & nWwId);
+ Set_UInt16( pData, nBit16 );
+
+ nBit16 = nWwBase << 4; // istdBase
+ nBit16 |= bPapFmt ? 1 : 2; // sgc
+ Set_UInt16( pData, nBit16 );
+
+ nBit16 = nWwNext << 4; // istdNext
+ nBit16 |= bPapFmt ? 2 : 1; // cupx
+ Set_UInt16( pData, nBit16 );
+
+ pData += sizeof( UINT16 ); // bchUpe
+
+ if( rWrt.bWrtWW8 )
+ {
+ //-------- jetzt neu:
+ // ab Ver8 gibts zwei Felder mehr:
+ //UINT16 fAutoRedef : 1; /* auto redefine style when appropriate */
+ //UINT16 fHidden : 1; /* hidden from UI? */
+ //UINT16 : 14; /* unused bits */
+ pData += sizeof( UINT16 );
+ }
+
+
+ UINT16 nLen = ( pData - aWW8_STD ) + 1 +
+ ((rWrt.bWrtWW8 ? 2 : 1 ) * (rName.Len() + 1)); // vorlaeufig
+
+ WW8Bytes* pO = rWrt.pO;
+ nPOPosStdLen1 = pO->Count(); // Adr1 zum nachtragen der Laenge
+
+ SwWW8Writer::InsUInt16( *pO, nLen );
+ pO->Insert( aWW8_STD, ( pData - aWW8_STD ), pO->Count() );
+
+ nPOPosStdLen2 = nPOPosStdLen1 + 8; // Adr2 zum nachtragen von "end of upx"
+
+ // Namen schreiben
+ if( rWrt.bWrtWW8 )
+ {
+ SwWW8Writer::InsUInt16( *pO, rName.Len() ); // Laenge
+ SwWW8Writer::InsAsString16( *pO, rName );
+ }
+ else
+ {
+ pO->Insert( (BYTE)rName.Len(), pO->Count() ); // Laenge
+ SwWW8Writer::InsAsString8( *pO, rName, RTL_TEXTENCODING_MS_1252 );
+ }
+ pO->Insert( (BYTE)0, pO->Count() ); // Trotz P-String 0 am Ende!
+}
+
+void WW8WrtStyle::SkipOdd() // Ruecke zu gerader Adresse vor
+{
+ WW8Bytes* pO = rWrt.pO;
+ if( ( rWrt.pTableStrm->Tell() + pO->Count() ) & 1 ) // Start auf gerader
+ pO->Insert( (BYTE)0, pO->Count() ); // Adresse
+}
+
+void WW8WrtStyle::Set1StyleDefaults( const SwFmt& rFmt, BOOL bPap )
+{
+ // defaults, that differs between WinWord and SO
+ static USHORT __READONLY_DATA aPapIds[] = {
+ RES_PARATR_WIDOWS, RES_PARATR_HYPHENZONE,
+ 0 };
+ static USHORT __READONLY_DATA aChpIds[] = {
+ RES_CHRATR_FONTSIZE, RES_CHRATR_LANGUAGE,
+ 0 };
+
+ for( const USHORT* pIds = bPap ? aPapIds : aChpIds; *pIds; ++pIds )
+ {
+ if( SFX_ITEM_SET != rFmt.GetItemState( *pIds, FALSE ))
+ Out( aWW8AttrFnTab, rFmt.GetAttr( *pIds, TRUE ), rWrt );
+ }
+}
+
+void WW8WrtStyle::BuildUpx( const SwFmt* pFmt, BOOL bPap, USHORT nPos,
+ BOOL bInsDefCharSiz )
+{
+ WW8Bytes* pO = rWrt.pO;
+
+ SkipOdd();
+ UINT16 nLen = ( bPap ) ? 2 : 0; // Default-Laenge
+ USHORT nLenPos = pO->Count(); // Laenge zum Nachtragen
+ // Keinen Pointer merken, da sich bei
+ // _grow der Pointer aendert !
+
+ SwWW8Writer::InsUInt16( *pO, nLen ); // Style-Len
+
+ UINT16 nStartSiz = pO->Count();
+
+ if( bPap )
+ SwWW8Writer::InsUInt16( *pO, nPos); // Style-Nummer
+
+ rWrt.Out_SwFmt( *pFmt, bPap, !bPap );
+
+ if( bInsDefCharSiz ) // nicht abgeleitet v. anderem Style
+ Set1StyleDefaults( *pFmt, bPap );
+
+ nLen = pO->Count() - nStartSiz;
+ BYTE* pUpxLen = (BYTE*)pO->GetData() + nLenPos; // Laenge zum Nachtragen
+ ShortToSVBT16( nLen, pUpxLen ); // Default-Laenge eintragen
+}
+
+// Out1Style geht fuer TxtFmtColls und CharFmts
+void WW8WrtStyle::Out1Style( SwFmt* pFmt, USHORT nPos )
+{
+ if( pFmt )
+ {
+ BOOL bFmtColl = pFmt->Which() == RES_TXTFMTCOLL ||
+ pFmt->Which() == RES_CONDTXTFMTCOLL;
+ short nWwBase = 0xfff; // Default: none
+
+ if( !pFmt->IsDefault() ) // Abgeleitet von ?
+ nWwBase = Sty_GetWWSlot( *pFmt->DerivedFrom() );
+
+ SwFmt* pNext;
+ if( bFmtColl )
+ pNext = &((SwTxtFmtColl*)pFmt)->GetNextTxtFmtColl();
+ else
+ pNext = pFmt; // CharFmt: Naechstes CharFmt == Selbes
+
+ short nWwNext = Sty_GetWWSlot( *pNext );
+
+ BuildStd( pFmt->GetName(), bFmtColl, nWwBase, nWwNext,
+ GetWWId( *pFmt ) );
+ if( bFmtColl )
+ BuildUpx( pFmt, TRUE, nPos, nWwBase==0xfff ); // UPX.papx
+ BuildUpx( pFmt, FALSE, nPos, bFmtColl && nWwBase==0xfff ); // UPX.chpx
+
+ SkipOdd();
+ WriteStyle( *rWrt.pTableStrm );
+ }
+ else if( nPos == 10 ) // Default Char-Style ( nur WW )
+ {
+ if( rWrt.bWrtWW8 )
+ {
+ static BYTE __READONLY_DATA aDefCharSty[] = {
+ 0x42, 0x00,
+ 0x41, 0x40, 0xF2, 0xFF, 0xA1, 0x00, 0x42, 0x00,
+ 0x00, 0x00, 0x19, 0x00, 0x41, 0x00, 0x62, 0x00,
+ 0x73, 0x00, 0x61, 0x00, 0x74, 0x00, 0x7A, 0x00,
+ 0x2D, 0x00, 0x53, 0x00, 0x74, 0x00, 0x61, 0x00,
+ 0x6E, 0x00, 0x64, 0x00, 0x61, 0x00, 0x72, 0x00,
+ 0x64, 0x00, 0x73, 0x00, 0x63, 0x00, 0x68, 0x00,
+ 0x72, 0x00, 0x69, 0x00, 0x66, 0x00, 0x74, 0x00,
+ 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+ rWrt.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) );
+ }
+ else
+ {
+ static BYTE __READONLY_DATA aDefCharSty[] = {
+ 0x26, 0x00,
+ 0x41, 0x40, 0xF2, 0xFF, 0xA1, 0x00, 0x26, 0x00,
+ 0x19, 0x41, 0x62, 0x73, 0x61, 0x74, 0x7A, 0x2D,
+ 0x53, 0x74, 0x61, 0x6E, 0x64, 0x61, 0x72, 0x64,
+ 0x73, 0x63, 0x68, 0x72, 0x69, 0x66, 0x74, 0x61,
+ 0x72, 0x74, 0x00, 0x00, 0x00, 0x00 };
+ rWrt.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) );
+ }
+ }
+/* else if( nPos == WW8_CSTY_FTN ) // Ftn-CharStyle ( nur WW )
+ {
+ if( rWrt.bWrtWW8 )
+ {
+ static BYTE __READONLY_DATA aFtnCharSty[] = {
+ 0x32, 0x00,
+ 0x26, 0x40, 0xA2, 0x00, 0x01, 0x01, 0x32, 0x00,
+ 0x00, 0x00, 0x0F, 0x00, 0x46, 0x00, 0x75, 0x00,
+ 0xDF, 0x00, 0x6E, 0x00, 0x6F, 0x00, 0x74, 0x00,
+ 0x65, 0x00, 0x6E, 0x00, 0x7A, 0x00, 0x65, 0x00,
+ 0x69, 0x00, 0x63, 0x00, 0x68, 0x00, 0x65, 0x00,
+ 0x6E, 0x00, 0x00, 0x00, 0x03, 0x00, 0x48, 0x2A,
+ 0x01, 0x00 };
+ rWrt.pTableStrm->Write( &aFtnCharSty, sizeof( aFtnCharSty ) );
+ }
+ else
+ {
+ static BYTE __READONLY_DATA aFtnCharSty[] = {
+ 0x1E, 0x00,
+ 0x26, 0x40, 0xA2, 0x00, 0x01, 0x01, 0x1E, 0x00,
+ 0x0F, 0x46, 0x75, 0xDF, 0x6E, 0x6F, 0x74, 0x65,
+ 0x6E, 0x7A, 0x65, 0x69, 0x63, 0x68, 0x65, 0x6E,
+ 0x00, 0x00, 0x02, 0x00, 0x68, 0x01 };
+ rWrt.pTableStrm->Write( &aFtnCharSty, sizeof( aFtnCharSty ) );
+ }
+ }
+*/ else
+ {
+ UINT16 n = 0;
+ rWrt.pTableStrm->Write( &n , 2 ); // leerer Style
+ }
+}
+
+void WW8WrtStyle::OutStyleTab()
+{
+ WW8Fib& rFib = *rWrt.pFib;
+
+ ULONG nCurPos = rWrt.pTableStrm->Tell();
+ if( nCurPos & 1 ) // Start auf gerader
+ {
+ *rWrt.pTableStrm << (char)0; // Adresse
+ ++nCurPos;
+ }
+ rWrt.bStyDef = TRUE;
+ rFib.fcStshfOrig = rFib.fcStshf = nCurPos;
+ ULONG nStyAnzPos = nCurPos + 2; // Anzahl wird nachgetragen
+
+ if( rWrt.bWrtWW8 )
+ {
+ static BYTE __READONLY_DATA aStShi[] = {
+ 0x12, 0x00,
+ 0x0F, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x5B, 0x00,
+ 0x0F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+
+ rWrt.pTableStrm->Write( &aStShi, sizeof( aStShi ) );
+ }
+ else
+ {
+ static BYTE __READONLY_DATA aStShi[] = {
+ 0x0E, 0x00,
+ 0x0F, 0x00, 0x08, 0x00, 0x01, 0x00, 0x4B, 0x00,
+ 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ rWrt.pTableStrm->Write( &aStShi, sizeof( aStShi ) );
+ }
+
+ USHORT n;
+ for( n = 0; n < nUsedSlots; n++ )
+ Out1Style( pFmtA[n], n );
+
+ rFib.lcbStshfOrig = rFib.lcbStshf = rWrt.pTableStrm->Tell() - rFib.fcStshf;
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, nStyAnzPos, nUsedSlots );
+ rWrt.bStyDef = FALSE;
+}
+
+
+/* */
+
+//---------------------------------------------------------------------------
+// Fonts
+//---------------------------------------------------------------------------
+
+USHORT SwWW8Writer::GetId( const SvxFontItem& rFont ) const
+{
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ const SvxFontItem* pFont = (const SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT );
+ USHORT n = 3;
+ if( rFont == *pFont )
+ return n;
+
+ ++n;
+ if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem(
+ RES_CHRATR_FONT )))
+ {
+ if( rFont == *pFont )
+ return n;
+ ++n;
+ }
+
+ USHORT nMaxItem = rPool.GetItemCount( RES_CHRATR_FONT );
+ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
+ if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem(
+ RES_CHRATR_FONT, nGet )) )
+ {
+ if( rFont == *pFont )
+ return n;
+ ++n;
+ }
+
+ ASSERT( !this, "Font nicht in der Tabelle" );
+ return 0;
+}
+
+USHORT SwWW8Writer::GetId( const Font& rFont ) const
+{
+ return GetId( SvxFontItem( rFont.GetFamily(), rFont.GetName(),
+ rFont.GetStyleName(), rFont.GetPitch(),
+ rFont.GetCharSet() ) );
+}
+
+static void _OutFont( SwWW8Writer& rWrt, const SvxFontItem& rFont )
+{
+ BYTE aWW8_FFN[ 6 ];
+ memset( aWW8_FFN, 0, 6 ); // 6 == len of fixed Part
+ if( rWrt.bWrtWW8 )
+ aWW8_FFN[0] = (BYTE)( 6 - 1 + 0x22 + ( 2 *
+ ( 1 + rFont.GetFamilyName().Len() ) ));
+ else
+ aWW8_FFN[0] = (BYTE)( 6 - 1 + 1 + rFont.GetFamilyName().Len() );
+
+ BYTE aB = 0;
+ switch( rFont.GetPitch() )
+ {
+ case PITCH_VARIABLE: aB |= 2; break; // aF.prg = 2
+ case PITCH_FIXED: aB |= 1; break;
+ default: break; // aF.prg = 0 : DEFAULT_PITCH (windows.h)
+ }
+ aB |= 1 << 2; // aF.fTrueType = 1; weiss ich nicht besser;
+
+ switch( rFont.GetFamily() )
+ {
+ case FAMILY_ROMAN: aB |= 1 << 4; break; // aF.ff = 1;
+ case FAMILY_SWISS: aB |= 2 << 4; break; // aF.ff = 2;
+ case FAMILY_MODERN: aB |= 3 << 4; break; // aF.ff = 3;
+ case FAMILY_SCRIPT: aB |= 4 << 4; break; // aF.ff = 4;
+ case FAMILY_DECORATIVE: aB |= 5 << 4; break; // aF.ff = 5;
+ default: break; // aF.ff = 0; FF_DONTCARE (windows.h)
+ }
+ aWW8_FFN[1] = aB;
+
+ ShortToSVBT16( 400, &aWW8_FFN[2] ); // weiss ich nicht besser
+ // 400 == FW_NORMAL (windows.h)
+ if( RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet() )
+ aWW8_FFN[4] = 2;
+ else
+ aWW8_FFN[4] = 0;
+
+ rWrt.pTableStrm->Write( aWW8_FFN, 6 ); // fixed part
+ if( rWrt.bWrtWW8 )
+ {
+ // ab Ver8 sind folgende beiden Felder eingeschoben,
+ // werden von uns ignoriert.
+ //char panose[ 10 ]; // 0x6 PANOSE
+ //char fs[ 24 ]; // 0x10 FONTSIGNATURE
+ SwWW8Writer::FillCount( *rWrt.pTableStrm, 0x22 );
+ SwWW8Writer::WriteString16( *rWrt.pTableStrm, rFont.GetFamilyName(),
+ TRUE );
+ }
+ else
+ SwWW8Writer::WriteString8( *rWrt.pTableStrm, rFont.GetFamilyName(),
+ TRUE, RTL_TEXTENCODING_MS_1252 );
+}
+
+void SwWW8Writer::OutFontTab( WW8Fib& rFib )
+{
+ rFib.fcSttbfffn = pTableStrm->Tell();
+ if( bWrtWW8 )
+ {
+ SwWW8Writer::WriteLong( *pTableStrm, 0 ); // hier wird Laenge nachgetragen ( cbFFN )
+
+ // ab Ver8 sind folgende beiden Felder eingeschoben,
+ // werden von uns ignoriert.
+ //char panose[ 10 ]; // 0x6 PANOSE
+ //char fs[ 24 ]; // 0x10 FONTSIGNATURE
+
+ static BYTE __READONLY_DATA aBase_10[] = {
+ 0x47,0x16,0x90,0x01,0x00,0x00 };
+ static BYTE __READONLY_DATA aBase_11[] = {
+ 'T',0,'i',0,'m',0,'e',0,'s',0,' ',0,
+ 'N',0,'e',0,'w',0,' ',0,'R',0,'o',0,'m',0,'a',0,'n',0,0,0 };
+
+ static BYTE __READONLY_DATA aBase_20[] = {
+ 0x35,0x16,0x90,0x01,0x02,0x00 };
+ static BYTE __READONLY_DATA aBase_21[] = {
+ 'S',0,'y',0,'m',0,'b',0,'o',0,'l',0,0,0 };
+
+ static BYTE __READONLY_DATA aBase_30[] = {
+ 0x33,0x26,0x90,0x01,0x00,0x00 };
+ static BYTE __READONLY_DATA aBase_31[] = {
+ 'A',0,'r',0,'i',0,'a',0,'l',0,0,0 };
+
+ // Base part
+ pTableStrm->Write( aBase_10, sizeof( aBase_10 ) );
+ SwWW8Writer::FillCount( *pTableStrm, 0x22 );
+ pTableStrm->Write( aBase_11, sizeof( aBase_11 ) );
+
+ pTableStrm->Write( aBase_20, sizeof( aBase_20 ) );
+ SwWW8Writer::FillCount( *pTableStrm, 0x22 );
+ pTableStrm->Write( aBase_21, sizeof( aBase_21 ) );
+
+ pTableStrm->Write( aBase_30, sizeof( aBase_30 ) );
+ SwWW8Writer::FillCount( *pTableStrm, 0x22 );
+ pTableStrm->Write( aBase_31, sizeof( aBase_31 ) );
+ }
+ else
+ {
+ SwWW8Writer::WriteShort( *pTableStrm, 0 ); // hier wird Laenge nachgetragen ( cbFFN )
+
+ static BYTE __READONLY_DATA aBase[] = {
+ 0x15,0x16,0x90,0x01,0x00,0x00,'T','i','m','e','s',' ',
+ 'N','e','w',' ','R','o','m','a','n',0,
+ 0x0c,0x16,0x90,0x01,0x02,0x00,'S','y','m','b','o','l',0,
+ 0x0b,0x26,0x90,0x01,0x00,0x00,'A','r','i','a','l',0 };
+ pTableStrm->Write( aBase, sizeof( aBase ) ); // Base part
+ }
+
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ const SvxFontItem* pFont = (const SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT );
+ const SvxFontItem* pDfltFont = (const SvxFontItem*)rPool.GetPoolDefaultItem(
+ RES_CHRATR_FONT );
+
+ _OutFont( *this, *pFont );
+ USHORT nFontCount = 4;
+
+ if( pDfltFont )
+ {
+ _OutFont( *this, *pDfltFont );
+ ++nFontCount;
+ }
+
+ USHORT nMaxItem = rPool.GetItemCount( RES_CHRATR_FONT );
+ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
+ {
+ pFont = (const SvxFontItem*)rPool.GetItem( RES_CHRATR_FONT, nGet );
+ if( pFont )
+ {
+ _OutFont( *this, *pFont );
+ ++nFontCount;
+ }
+ }
+ rFib.lcbSttbfffn = pTableStrm->Tell() - rFib.fcSttbfffn;
+ if( bWrtWW8 )
+ SwWW8Writer::WriteLong( *pTableStrm, rFib.fcSttbfffn, nFontCount );
+ else
+ SwWW8Writer::WriteShort( *pTableStrm, rFib.fcSttbfffn,
+ (INT16)pFib->lcbSttbfffn );
+}
+
+
+/* */
+
+WW8_WrPlc0::WW8_WrPlc0( ULONG nOffset )
+ : aPos( 4, 4 ), nOfs( nOffset )
+{
+}
+
+void WW8_WrPlc0::Append( ULONG nStartCpOrFc )
+{
+ aPos.Insert( nStartCpOrFc - nOfs, aPos.Count() );
+}
+
+void WW8_WrPlc0::Write( SvStream& rStrm )
+{
+ USHORT nLen = aPos.Count();
+ for( USHORT i = 0; i < nLen; ++i )
+ {
+ SVBT32 nP;
+ LongToSVBT32( aPos[i], nP );
+ rStrm.Write( nP, 4 );
+ }
+}
+
+//------------------------------------------------------------------------------
+
+/* */
+//------------------------------------------------------------------------------
+// class WW8_WrPlcSepx : Uebersetzung PageDescs in Sections
+// behandelt auch Header und Footer
+//------------------------------------------------------------------------------
+
+WW8_WrPlcSepx::WW8_WrPlcSepx()
+ : pTxtPos( 0 ), aCps( 4, 4 ), aSects( 4, 4 ), pAttrs( 0 )
+{
+}
+
+WW8_WrPlcSepx::~WW8_WrPlcSepx()
+{
+ USHORT nLen = aSects.Count();
+ if( pAttrs )
+ {
+ while( nLen )
+ {
+ delete[] pAttrs[ --nLen ].pData;
+ }
+ delete[] pAttrs;
+ }
+ delete pTxtPos;
+}
+
+void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp,
+ const SwPageDesc* pPd,
+ const SwSectionFmt* pSectionFmt,
+ ULONG nLnNumRestartNo )
+{
+ aCps.Insert( nStartCp, aCps.Count() );
+ aSects.Insert( WW8_SepInfo( pPd, pSectionFmt, nLnNumRestartNo ),
+ aSects.Count() );
+}
+
+void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPD,
+ const SwNode& rNd, ULONG nLnNumRestartNo )
+{
+ aCps.Insert( nStartCp, aCps.Count() );
+ WW8_SepInfo aI( rPD.GetPageDesc(), 0, nLnNumRestartNo );
+ aI.nPgRestartNo = rPD.GetNumOffset();
+ aI.pPDNd = &rNd;
+ aSects.Insert( aI, aSects.Count() );
+}
+
+// WW8_WrPlcSepx::SetNum() setzt in jeder Section beim 1. Aufruf den
+// Num-Pointer, alle folgenden Aufrufe werden ignoriert. Damit wird
+// die erste Aufzaehlung einer Section uebernommen.
+
+void WW8_WrPlcSepx::SetNum( const SwTxtNode* pNumNd )
+{
+ WW8_SepInfo& rInfo = aSects[ aSects.Count() - 1 ];
+ if( !rInfo.pNumNd ) // noch nicht belegt
+ rInfo.pNumNd = pNumNd;
+}
+
+void WW8_WrPlcSepx::WriteOlst( SwWW8Writer& rWrt, USHORT i )
+{
+ if( !rWrt.bWrtWW8 )
+ {
+ const SwNumRule* pRule;
+ const SwTxtNode* pNd = aSects[i].pNumNd;
+ if( pNd && 0 != ( pRule = pNd->GetNumRule() ))
+ rWrt.Out_Olst( *pRule );
+ }
+}
+
+
+void WW8_WrPlcSepx::WriteFtnEndTxt( SwWW8Writer& rWrt, ULONG nCpStt )
+{
+ BYTE nInfoFlags = 0;
+ const SwFtnInfo& rInfo = rWrt.pDoc->GetFtnInfo();
+ if( rInfo.aErgoSum.Len() ) nInfoFlags |= 0x02;
+ if( rInfo.aQuoVadis.Len() ) nInfoFlags |= 0x04;
+
+ BYTE nEmptyStt = rWrt.bWrtWW8 ? 0 : 6;
+ if( nInfoFlags )
+ {
+ if( rWrt.bWrtWW8 )
+ pTxtPos->Append( nCpStt ); // empty footenote separator
+
+ if( 0x02 & nInfoFlags ) // Footenote contiunation separator
+ {
+ pTxtPos->Append( nCpStt );
+ rWrt.WriteStringAsPara( rInfo.aErgoSum );
+ rWrt.WriteStringAsPara( aEmptyStr );
+ nCpStt = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ }
+ else if( rWrt.bWrtWW8 )
+ pTxtPos->Append( nCpStt );
+
+ if( 0x04 & nInfoFlags ) // Footenote contiunation notice
+ {
+ pTxtPos->Append( nCpStt );
+ rWrt.WriteStringAsPara( rInfo.aQuoVadis );
+ rWrt.WriteStringAsPara( aEmptyStr );
+ nCpStt = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ }
+ else if( rWrt.bWrtWW8 )
+ pTxtPos->Append( nCpStt );
+
+ if( rWrt.bWrtWW8 )
+ nEmptyStt = 3;
+ else
+ rWrt.pDop->grpfIhdt = nInfoFlags;
+ }
+
+ while( 6 > nEmptyStt++ )
+ pTxtPos->Append( nCpStt );
+
+ // gleich die Flags am Dop setzen
+ WW8Dop& rDop = *rWrt.pDop;
+ // Footnote Info
+ switch( rInfo.eNum )
+ {
+ case FTNNUM_PAGE: rDop.rncFtn = 2; break;
+ case FTNNUM_CHAPTER: rDop.rncFtn = 1; break;
+ default: rDop.rncFtn = 0; break;
+ } // rncFtn
+ rDop.nfcFtnRef = SwWW8Writer::GetNumId( rInfo.aFmt.eType );
+ rDop.nFtn = rInfo.nFtnOffset + 1;
+ rDop.fpc = rWrt.bFtnAtTxtEnd ? 2 : 1;
+
+ // Endnote Info
+ rDop.rncEdn = 0; // rncEdn: Don't Restart
+ const SwEndNoteInfo& rEndInfo = rWrt.pDoc->GetEndNoteInfo();
+ rDop.nfcEdnRef = SwWW8Writer::GetNumId( rEndInfo.aFmt.eType );
+ rDop.nEdn = rEndInfo.nFtnOffset + 1;
+ rDop.epc = rWrt.bEndAtTxtEnd ? 3 : 0;
+}
+
+
+void WW8_WrPlcSepx::SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt,
+ BYTE nFlag )
+{
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_HEADER, TRUE, &pItem )
+ && ((SwFmtHeader*)pItem)->IsActive() &&
+ ((SwFmtHeader*)pItem)->GetHeaderFmt() )
+ rHeadFootFlags |= nFlag;
+}
+void WW8_WrPlcSepx::SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt,
+ BYTE nFlag )
+{
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rFmt.GetItemState( RES_FOOTER, TRUE, &pItem )
+ && ((SwFmtFooter*)pItem)->IsActive() &&
+ ((SwFmtFooter*)pItem)->GetFooterFmt() )
+ rHeadFootFlags |= nFlag;
+}
+
+void WW8_WrPlcSepx::OutHeader( SwWW8Writer& rWrt, const SwFmt& rFmt,
+ ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag )
+{
+ if( nFlag & nHFFlags )
+ {
+ const SwFmtHeader& rHd = rFmt.GetHeader();
+ ASSERT( rHd.GetHeaderFmt(), "KopfText nicht richtig da" );
+ const SwFmtCntnt& rCntnt = rHd.GetHeaderFmt()->GetCntnt();
+ pTxtPos->Append( rCpPos );
+ rWrt.WriteKFTxt1( rCntnt );
+ rWrt.WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW )
+ rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ }
+ else if( rWrt.bWrtWW8 )
+ pTxtPos->Append( rCpPos );
+}
+void WW8_WrPlcSepx::OutFooter( SwWW8Writer& rWrt, const SwFmt& rFmt,
+ ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag )
+{
+ if( nFlag & nHFFlags )
+ {
+ const SwFmtFooter& rFt = rFmt.GetFooter();
+ ASSERT( rFt.GetFooterFmt(), "KopfText nicht richtig da" );
+ const SwFmtCntnt& rCntnt = rFt.GetFooterFmt()->GetCntnt();
+ pTxtPos->Append( rCpPos );
+ rWrt.WriteKFTxt1( rCntnt );
+ rWrt.WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW )
+ rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ }
+ else if( rWrt.bWrtWW8 )
+ pTxtPos->Append( rCpPos );
+}
+
+void WW8_WrPlcSepx::CheckForFacinPg( SwWW8Writer& rWrt ) const
+{
+ // 2 Werte werden gesetzt
+ // Dop.fFacingPages == Kopf-/Fusszeilen unterschiedlich
+ // Dop.fSwapBordersFacingPgs == gespiegelte Raender
+ for( USHORT i = 0, nEnde = 0; i < aSects.Count(); ++i )
+ {
+ WW8_SepInfo& rSepInfo = aSects[i];
+ if( !rSepInfo.pSectionFmt )
+ {
+ const SwPageDesc* pPd = rSepInfo.pPageDesc;
+ if( pPd->GetFollow() && pPd != pPd->GetFollow() &&
+ pPd->GetFollow()->GetFollow() == pPd->GetFollow() &&
+ rSepInfo.pPDNd &&
+ pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) )
+ // das ist also 1.Seite und nachfolgende, also nur den
+ // follow beachten
+ pPd = pPd->GetFollow();
+
+ // left-/right chain of pagedescs ?
+ else if( !( 1 & nEnde ) &&
+ pPd->GetFollow() && pPd != pPd->GetFollow() &&
+ pPd->GetFollow()->GetFollow() == pPd &&
+ (( PD_LEFT == ( PD_ALL & pPd->ReadUseOn() ) &&
+ PD_RIGHT == ( PD_ALL & pPd->GetFollow()->ReadUseOn() )) ||
+ ( PD_RIGHT == ( PD_ALL & pPd->ReadUseOn() ) &&
+ PD_LEFT == ( PD_ALL & pPd->GetFollow()->ReadUseOn() )) ))
+ {
+ rWrt.pDop->fFacingPages = rWrt.pDop->fMirrorMargins = TRUE;
+ nEnde |= 1;
+ }
+
+ if( !( 1 & nEnde ) &&
+ ( !pPd->IsHeaderShared() || !pPd->IsFooterShared() ))
+ {
+ rWrt.pDop->fFacingPages = TRUE;
+ nEnde |= 1;
+ }
+ if( !( 2 & nEnde ) &&
+ PD_MIRROR == ( PD_MIRROR & pPd->ReadUseOn() ))
+ {
+ rWrt.pDop->fSwapBordersFacingPgs = rWrt.pDop->fMirrorMargins = TRUE;
+ nEnde |= 2;
+ }
+
+ if( 3 == nEnde )
+ break; // weiter brauchen wird nicht
+ }
+ }
+}
+
+
+int WW8_WrPlcSepx::HasBorderItem( const SwFmt& rFmt )
+{
+ const SfxPoolItem* pItem;
+ return SFX_ITEM_SET == rFmt.GetItemState( RES_BOX,TRUE, &pItem ) &&
+ ( ((SvxBoxItem*)pItem)->GetTop() ||
+ ((SvxBoxItem*)pItem)->GetBottom() ||
+ ((SvxBoxItem*)pItem)->GetLeft() ||
+ ((SvxBoxItem*)pItem)->GetRight() );
+}
+
+void WW8_WrPlcSepx::WriteKFTxt( SwWW8Writer& rWrt )
+{
+ pAttrs = new WW8_PdAttrDesc[ aSects.Count() ];
+ WW8Bytes* pO = rWrt.pO;
+ ULONG nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ BOOL bOldPg = rWrt.bOutPageDescs;
+ rWrt.bOutPageDescs = TRUE;
+
+ ASSERT( !pTxtPos, "wer hat den Pointer gesetzt?" );
+ pTxtPos = new WW8_WrPlc0( nCpStart );
+
+ WriteFtnEndTxt( rWrt, nCpStart );
+ CheckForFacinPg( rWrt );
+
+ WW8Bytes aLineNum;
+ const SwLineNumberInfo& rLnNumInfo = rWrt.pDoc->GetLineNumberInfo();
+ if( rLnNumInfo.IsPaintLineNumbers() )
+ {
+ // sprmSNLnnMod - activate Line Numbering and define Modulo
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aLineNum, 0x5015 );
+ else
+ aLineNum.Insert( 154, aLineNum.Count() );
+ SwWW8Writer::InsUInt16( aLineNum, (UINT16)rLnNumInfo.GetCountBy() );
+
+ // sprmSDxaLnn - xPosition of Line Number
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aLineNum, 0x9016 );
+ else
+ aLineNum.Insert( 155, aLineNum.Count() );
+ SwWW8Writer::InsUInt16( aLineNum, (UINT16)rLnNumInfo.GetPosFromLeft() );
+
+ //
+ }
+
+ USHORT i;
+ for( i = 0; i < aSects.Count(); ++i )
+ {
+ WW8_PdAttrDesc* pA = pAttrs + i;
+ WW8_SepInfo& rSepInfo = aSects[i];
+ const SwPageDesc* pPd = rSepInfo.pPageDesc;
+
+ if( rSepInfo.pSectionFmt && !pPd )
+ pPd = &rWrt.pDoc->GetPageDesc(0);
+
+ rWrt.pAktPageDesc = pPd;
+ pA->nSepxFcPos = 0xffffffff; // Default: none
+
+ if( !pPd )
+ {
+ pA->pData = 0;
+ pA->nLen = 0;
+ continue;
+ }
+
+ pO->Remove( 0, pO->Count() ); // leeren
+ rWrt.bOutPageDescs = TRUE;
+
+
+ if( aLineNum.Count() )
+ {
+ pO->Insert( &aLineNum, pO->Count() );
+
+ // sprmSLnc - restart number: 0 per page, 1 per section, 2 never restart
+ if( rSepInfo.nLnNumRestartNo || !rLnNumInfo.IsRestartEachPage() )
+ {
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x3013 );
+ else
+ pO->Insert( 152, pO->Count() );
+ pO->Insert( rSepInfo.nLnNumRestartNo ? 1 : 2, pO->Count() );
+ }
+
+ // sprmSLnnMin - Restart the Line Number with given value
+ if( rSepInfo.nLnNumRestartNo )
+ {
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x501B );
+ else
+ pO->Insert( 160, pO->Count() );
+ SwWW8Writer::InsUInt16( *pO, (UINT16)rSepInfo.nLnNumRestartNo - 1 );
+ }
+ }
+
+
+ /* sprmSBkc, break code: 0 No break, 1 New column
+ 2 New page, 3 Even page, 4 Odd page
+ */
+ BYTE nBreakCode = 2; // default neue Seite beginnen
+ BOOL bOutPgDscSet = TRUE, bLeftRightPgChain = FALSE;
+ const SwFrmFmt* pPdFmt = &pPd->GetMaster();
+ const SwFrmFmt* pPdFirstPgFmt = pPdFmt;
+ if( rSepInfo.pSectionFmt )
+ {
+ // ist pSectionFmt gesetzt, dann gab es einen SectionNode
+ // gueltiger Pointer -> Section beginnt,
+ // 0xfff -> Section wird beendet
+ nBreakCode = 0; // fortlaufender Abschnitt
+ if( (SwSectionFmt*)0xFFFFFFFF != rSepInfo.pSectionFmt )
+ {
+ // Itemset erzeugen, das das PgDesk-AttrSet beerbt:
+ // als Nachkomme wird bei 'deep'-Out_SfxItemSet
+ // auch der Vorfahr abgeklappert
+ const SfxItemSet* pPdSet = &pPdFmt->GetAttrSet();
+ SfxItemSet aSet( *pPdSet->GetPool(), pPdSet->GetRanges() );
+ aSet.SetParent( pPdSet );
+
+ // am Nachkommen NUR die Spaltigkeit gemaess Sect-Attr. umsetzen
+ aSet.Put( rSepInfo.pSectionFmt->GetAttr( RES_COL ) );
+
+ // und raus damit ins WW-File
+ const SfxItemSet* pOldI = rWrt.pISet;
+ rWrt.pISet = &aSet;
+ Out_SfxItemSet( aWW8AttrFnTab, rWrt, aSet, TRUE );
+ rWrt.pISet = pOldI;
+
+ bOutPgDscSet = FALSE;
+ }
+ }
+
+ if( bOutPgDscSet )
+ {
+ // es ist ein Follow gesetzt und dieser zeigt nicht auf sich
+ // selbst, so liegt eine Seitenverkettung vor.
+ // Falls damit eine "Erste Seite" simuliert werden soll, so
+ // koennen wir das auch als solches schreiben.
+ // Anders sieht es mit Links/Rechts wechseln aus. Dafuer muss
+ // erkannt werden, wo der Seitenwechsel statt findet. Hier ist
+ // es aber dafuer zuspaet!
+ if( pPd->GetFollow() && pPd != pPd->GetFollow() &&
+ pPd->GetFollow()->GetFollow() == pPd->GetFollow() &&
+ rSepInfo.pPDNd &&
+ pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) )
+ {
+ if( rSepInfo.pPDNd )
+ pPdFirstPgFmt = pPd->GetPageFmtOfNode( *rSepInfo.pPDNd );
+ else
+ pPdFirstPgFmt = &pPd->GetMaster();
+
+ rWrt.pAktPageDesc = pPd = pPd->GetFollow();
+ pPdFmt = &pPd->GetMaster();
+
+ // sprmSFTitlePage
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x300A );
+ else
+ pO->Insert( 143, pO->Count() );
+ pO->Insert( 1, pO->Count() );
+ }
+
+ const SfxItemSet* pOldI = rWrt.pISet;
+
+ if( rWrt.bWrtWW8 ) // Seitenumrandung schreiben
+ {
+ USHORT nPgBorder = HasBorderItem( *pPdFmt ) ? 0 : USHRT_MAX;
+ if( pPdFmt != pPdFirstPgFmt )
+ {
+ if( HasBorderItem( *pPdFirstPgFmt ))
+ {
+ if( USHRT_MAX == nPgBorder )
+ {
+ nPgBorder = 1;
+ // nur die 1. Seite umrandet -> BoxItem aus dem
+ // richtigen Format besorgen
+ rWrt.pISet = &pPdFirstPgFmt->GetAttrSet();
+ Out( aWW8AttrFnTab, pPdFirstPgFmt->GetAttr(
+ RES_BOX ), rWrt );
+ }
+ }
+ else if( !nPgBorder )
+ nPgBorder = 2;
+ }
+
+ if( USHRT_MAX != nPgBorder )
+ {
+ // Flag und das Border Attribut schreiben
+ SwWW8Writer::InsUInt16( *pO, 0x522F );
+ SwWW8Writer::InsUInt16( *pO, nPgBorder );
+ }
+ }
+
+ const SfxPoolItem* pItem;
+ if( pPdFmt != pPdFirstPgFmt && SFX_ITEM_SET ==
+ pPdFirstPgFmt->GetItemState( RES_PAPER_BIN, TRUE, &pItem ))
+ {
+ rWrt.pISet = &pPdFirstPgFmt->GetAttrSet();
+ rWrt.bOutFirstPage = TRUE;
+ Out( aWW8AttrFnTab, *pItem, rWrt );
+ rWrt.bOutFirstPage = FALSE;
+ }
+
+
+ // left-/right chain of pagedescs ?
+ if( pPd->GetFollow() && pPd != pPd->GetFollow() &&
+ pPd->GetFollow()->GetFollow() == pPd &&
+ (( PD_LEFT == ( PD_ALL & pPd->ReadUseOn() ) &&
+ PD_RIGHT == ( PD_ALL & pPd->GetFollow()->ReadUseOn() )) ||
+ ( PD_RIGHT == ( PD_ALL & pPd->ReadUseOn() ) &&
+ PD_LEFT == ( PD_ALL & pPd->GetFollow()->ReadUseOn() )) ))
+ {
+ bLeftRightPgChain = TRUE;
+
+ // welches ist der Bezugspunkt ????? (links oder rechts?)
+ // annahme die rechte Seite!
+ if( PD_LEFT == ( PD_ALL & pPd->ReadUseOn() ))
+ {
+ nBreakCode = 3;
+ pPd = pPd->GetFollow();
+ pPdFmt = &pPd->GetMaster();
+ }
+ else
+ nBreakCode = 4;
+ }
+
+ rWrt.pISet = &pPdFmt->GetAttrSet();
+ Out_SfxItemSet( aWW8AttrFnTab, rWrt, pPdFmt->GetAttrSet(),
+ TRUE, FALSE );
+ rWrt.pISet = pOldI;
+
+ // dann noch die restlichen Einstellungen aus dem PageDesc
+
+ // sprmSNfcPgn
+ BYTE nb = SwWW8Writer::GetNumId( pPd->GetNumType().eType );
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x300E );
+ else
+ pO->Insert( 147, pO->Count() );
+ pO->Insert( nb, pO->Count() );
+
+//??? const SwPageFtnInfo& rFtnInfo = pPd->GetFtnInfo();
+
+ if( rSepInfo.nPgRestartNo )
+ {
+ // sprmSFPgnRestart
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x3011 );
+ else
+ pO->Insert( 150, pO->Count() );
+ pO->Insert( 1, pO->Count() );
+ // sprmSPgnStart
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x501C );
+ else
+ pO->Insert( 161, pO->Count() );
+ SwWW8Writer::InsUInt16( *pO, rSepInfo.nPgRestartNo );
+ }
+
+ // werden es nur linke oder nur rechte Seiten?
+ if( 2 == nBreakCode )
+ {
+ if( PD_LEFT == ( PD_ALL & pPd->ReadUseOn() ))
+ nBreakCode = 3;
+ else if( PD_RIGHT == ( PD_ALL & pPd->ReadUseOn() ))
+ nBreakCode = 4;
+ }
+ }
+
+ if( 2 != nBreakCode ) // neue Seite ist default
+ {
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( *pO, 0x3009 );
+ else
+ pO->Insert( 142, pO->Count() );
+ pO->Insert( nBreakCode, pO->Count() );
+ }
+
+ WriteOlst( rWrt, i );
+
+
+ // Header oder Footer
+ BYTE nHeadFootFlags = 0;
+
+ const SwFrmFmt* pPdLeftFmt = bLeftRightPgChain
+ ? &pPd->GetFollow()->GetMaster()
+ : &pPd->GetLeft();
+
+ SetHeaderFlag( nHeadFootFlags, *pPdFmt, WW8_HEADER_ODD );
+ SetFooterFlag( nHeadFootFlags, *pPdFmt, WW8_FOOTER_ODD );
+ if( !pPd->IsHeaderShared() || bLeftRightPgChain )
+ SetHeaderFlag( nHeadFootFlags, *pPdLeftFmt, WW8_HEADER_EVEN );
+ if( !pPd->IsFooterShared() || bLeftRightPgChain )
+ SetFooterFlag( nHeadFootFlags, *pPdLeftFmt, WW8_FOOTER_EVEN );
+ if( pPdFmt != pPdFirstPgFmt )
+ {
+ // es gibt eine ErsteSeite:
+ SetHeaderFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_HEADER_FIRST );
+ SetFooterFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_FOOTER_FIRST );
+ }
+
+ if( nHeadFootFlags && !rWrt.bWrtWW8 )
+ {
+ BYTE nTmpFlags = nHeadFootFlags;
+ if( rWrt.pDop->fFacingPages )
+ {
+ if( !(nTmpFlags & WW8_FOOTER_EVEN) &&
+ (nTmpFlags & WW8_FOOTER_ODD ) )
+ nTmpFlags |= WW8_FOOTER_EVEN;
+
+ if( !(nTmpFlags & WW8_HEADER_EVEN) &&
+ (nTmpFlags & WW8_HEADER_ODD ) )
+ nTmpFlags |= WW8_HEADER_EVEN;
+ }
+
+ // sprmSGprfIhdt, wird nur noch im WW95 benoetigt
+ pO->Insert( 153, pO->Count() );
+ pO->Insert( nTmpFlags, pO->Count() );
+ }
+
+ if( pO->Count() )
+ { // waren Attrs vorhanden ?
+ pA->nLen = pO->Count();
+ pA->pData = new BYTE [pO->Count()];
+ memcpy( pA->pData, pO->GetData(), pO->Count() ); // -> merken
+ pO->Remove( 0, pO->Count() ); // leeren fuer HdFt-Text
+ }
+ else
+ { // keine Attrs da
+ pA->pData = 0;
+ pA->nLen = 0;
+ }
+
+/*
+!!!!!!!!!!!
+ // Umrandungen an Kopf- und Fusstexten muessten etwa so gehen:
+ // Dabei muss etwas wie pOut eingebaut werden,
+ // das bei jeder Spezialtext-Zeile wiederholt wird.
+ const SwFrmFmt* pFFmt = rFt.GetFooterFmt();
+ const SvxBoxItem& rBox = pFFmt->GetBox(FALSE);
+ OutWW8_SwFmtBox1( rWrt.pOut, rBox, FALSE );
+!!!!!!!!!!!
+ Man koennt daraus Absatzattribute machen, die dann bei jedem Absatz
+ beachtet werden. Gilt fuer Hintergrund/Umrandung
+!!!!!!!!!!!
+*/
+
+ ULONG nCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ if( !(nHeadFootFlags & WW8_HEADER_EVEN) && rWrt.pDop->fFacingPages )
+ OutHeader( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD );
+ else
+ OutHeader( rWrt, *pPdLeftFmt, nCpPos, nHeadFootFlags, WW8_HEADER_EVEN );
+ OutHeader( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD );
+
+ if( !(nHeadFootFlags & WW8_FOOTER_EVEN) && rWrt.pDop->fFacingPages )
+ OutFooter( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD );
+ else
+ OutFooter( rWrt, *pPdLeftFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_EVEN );
+ OutFooter( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD );
+
+ OutHeader( rWrt, *pPdFirstPgFmt, nCpPos, nHeadFootFlags, WW8_HEADER_FIRST );
+ OutFooter( rWrt, *pPdFirstPgFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_FIRST );
+ }
+
+ if( pTxtPos->Count() )
+ {
+ // HdFt vorhanden ?
+ ULONG nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ pTxtPos->Append( nCpEnd ); // Ende letzter Hd/Ft fuer PlcfHdd
+
+ if( nCpEnd > nCpStart )
+ {
+ ++nCpEnd;
+ pTxtPos->Append( nCpEnd + 1 ); // Ende letzter Hd/Ft fuer PlcfHdd
+
+ rWrt.WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW )
+ }
+ rWrt.pFldHdFt->Finish( nCpEnd, rWrt.pFib->ccpText + rWrt.pFib->ccpFtn );
+ rWrt.pFib->ccpHdr = nCpEnd - nCpStart;
+ }
+ else
+ delete pTxtPos, pTxtPos = 0;
+
+ rWrt.bOutPageDescs = bOldPg;
+}
+
+
+void WW8_WrPlcSepx::WriteSepx( SvStream& rStrm ) const
+{
+ USHORT i;
+ for( i = 0; i < aSects.Count(); i++ ) // ueber alle Sections
+ {
+ WW8_PdAttrDesc* pA = pAttrs + i;
+ if( pA->nLen )
+ {
+ SVBT16 nL;
+ pA->nSepxFcPos = rStrm.Tell();
+ ShortToSVBT16( pA->nLen, nL );
+ rStrm.Write( nL, 2 );
+ rStrm.Write( pA->pData, pA->nLen );
+ }
+ }
+}
+
+
+void WW8_WrPlcSepx::WritePlcSed( SwWW8Writer& rWrt ) const
+{
+ ASSERT( aCps.Count() == aSects.Count() + 1, "WrPlcSepx: DeSync" );
+ ULONG nFcStart = rWrt.pTableStrm->Tell();
+
+ USHORT i;
+ // ( ueber alle Sections )
+ for( i = 0; i <= aSects.Count(); i++ )
+ {
+ UINT32 nP = aCps[i];
+ SVBT32 nPos;
+ LongToSVBT32( nP, nPos );
+ rWrt.pTableStrm->Write( nPos, 4 );
+ }
+
+ static WW8_SED aSed = { 4, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff };
+
+ // ( ueber alle Sections )
+ for( i = 0; i < aSects.Count(); i++ )
+ {
+ WW8_PdAttrDesc* pA = pAttrs + i;
+ LongToSVBT32( pA->nSepxFcPos, aSed.fcSepx ); // Sepx-Pos
+ rWrt.pTableStrm->Write( &aSed, sizeof( aSed ) );
+ }
+ rWrt.pFib->fcPlcfsed = nFcStart;
+ rWrt.pFib->lcbPlcfsed = rWrt.pTableStrm->Tell() - nFcStart;
+}
+
+
+void WW8_WrPlcSepx::WritePlcHdd( SwWW8Writer& rWrt ) const
+{
+ if( pTxtPos && pTxtPos->Count() )
+ {
+ rWrt.pFib->fcPlcfhdd = rWrt.pTableStrm->Tell();
+ pTxtPos->Write( *rWrt.pTableStrm ); // Plc0
+ rWrt.pFib->lcbPlcfhdd = rWrt.pTableStrm->Tell() -
+ rWrt.pFib->fcPlcfhdd;
+ }
+}
+
+void SwWW8Writer::WriteKFTxt1( const SwFmtCntnt& rCntnt )
+{
+ SwNodePtr pNode;
+
+ if( rCntnt.GetCntntIdx() )
+ pNode = pDoc->GetNodes()[ rCntnt.GetCntntIdx()->GetIndex()+1 ];
+ else
+ pNode = 0;
+
+ if( pNode )
+ {
+ // Hole vom Node und vom letzten Node die Position in der Section
+ ULONG nStart = pNode->StartOfSectionIndex()+1;
+ ULONG nEnd = pNode->EndOfSectionIndex();
+
+ // Bereich also gueltiger Node
+ if( nStart < nEnd )
+ {
+ BOOL bOldKF = bOutKF;
+ bOutKF = TRUE;
+ WriteSpecialText( nStart, nEnd, TXT_HDFT );
+ bOutKF = bOldKF;
+ }
+ else
+ pNode = 0;
+ }
+
+ if( !pNode )
+ {
+ // es gibt keine Kopf-/Fusszeile, aber ein CR ist immer noch noetig
+ ASSERT( pNode, "K/F-Text nicht richtig da" );
+ WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW )
+ }
+}
+
+/* */
+//------------------------------------------------------------------------------
+// class WW8_WrPlcFtnEdn : Sammeln der Fuss/Endnoten und Ausgeben der Texte
+// und Plcs am Ende des Docs.
+// WW8_WrPlcFtnEdn ist die Klasse fuer Fuss- und Endnoten
+//------------------------------------------------------------------------------
+WW8_WrPlcSubDoc::WW8_WrPlcSubDoc()
+ : aCps( 0, 16 ), aCntnt( 0, 16 ), pTxtPos( 0 )
+{
+}
+
+WW8_WrPlcSubDoc::~WW8_WrPlcSubDoc()
+{
+ delete pTxtPos;
+}
+
+void WW8_WrPlcFtnEdn::Append( WW8_CP nCp, const SwFmtFtn& rFtn )
+{
+ aCps.Insert( nCp, aCps.Count() );
+ void* p = (void*)&rFtn;
+ aCntnt.Insert( p, aCntnt.Count() );
+}
+
+void WW8_WrPlcPostIt::Append( WW8_CP nCp, const SwPostItField& rPostIt )
+{
+ aCps.Insert( nCp, aCps.Count() );
+ void* p = (void*)&rPostIt;
+ aCntnt.Insert( p, aCntnt.Count() );
+}
+
+void WW8_WrPlcSubDoc::WriteTxt( SwWW8Writer& rWrt, BYTE nTTyp,
+ long& rCount )
+{
+ USHORT nLen = aCntnt.Count();
+ if( nLen )
+ {
+ ULONG nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ pTxtPos = new WW8_WrPlc0( nCpStart );
+ USHORT i;
+
+ switch( nTTyp )
+ {
+ case TXT_ATN:
+ for( i = 0; i < nLen; i++ )
+ {
+ // Anfaenge fuer PlcfAtnTxt
+ pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
+
+ const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ];
+ rWrt.WritePostItBegin( rPFld );
+ rWrt.WriteStringAsPara( rPFld.GetTxt() );
+ }
+ break;
+
+ case TXT_TXTBOX:
+ case TXT_HFTXTBOX:
+ for( i = 0; i < nLen; i++ )
+ {
+ // textbox - content
+ WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ aCps.Insert( nCP, i );
+ pTxtPos->Append( nCP );
+
+ // is it an writer or sdr - textbox?
+ const SdrObject& rObj = *(SdrObject*)aCntnt[ i ];
+ if( rObj.ISA( SdrTextObj ) )
+ rWrt.WriteSdrTextObj( rObj );
+ else
+ {
+ const SwFrmFmt* pFmt = ::FindFrmFmt( &rObj );
+ ASSERT( pFmt, "wo ist das Format geblieben?" );
+
+ const SwNodeIndex* pNdIdx = pFmt->GetCntnt().GetCntntIdx();
+ ASSERT( pNdIdx, "wo ist der StartNode der Textbox?" );
+ rWrt.WriteSpecialText( pNdIdx->GetIndex() + 1,
+ pNdIdx->GetNode().EndOfSectionIndex(),
+ nTTyp );
+ }
+
+ // CR at end of one textbox text ( otherwise WW gpft :-( )
+ rWrt.WriteStringAsPara( aEmptyStr );
+ }
+ break;
+
+ case TXT_EDN:
+ case TXT_FTN:
+ for( i = 0; i < nLen; i++ )
+ {
+ // Anfaenge fuer PlcfFtnTxt/PlcfEdnTxt
+ pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
+
+ // Noten-Inhalt
+ const SwFmtFtn* pFtn = (SwFmtFtn*)aCntnt[ i ];
+ rWrt.WriteFtnBegin( *pFtn );
+ const SwNodeIndex* pIdx = pFtn->GetTxtFtn()->GetStartNode();
+ ASSERT( pIdx, "wo ist der StartNode der Fuss-/EndNote?" );
+ rWrt.WriteSpecialText( pIdx->GetIndex() + 1,
+ pIdx->GetNode().EndOfSectionIndex(),
+ nTTyp );
+ }
+ break;
+
+ default:
+ ASSERT( !this, "was ist das fuer ein SubDocType?" );
+ }
+
+ pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
+ // CR ans Ende ( sonst mault WW )
+ rWrt.WriteStringAsPara( aEmptyStr );
+
+ ULONG nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() );
+ pTxtPos->Append( nCpEnd );
+ rCount = nCpEnd - nCpStart;
+ }
+}
+
+void WW8_WrPlcSubDoc::WritePlc( SwWW8Writer& rWrt, BYTE nTTyp,
+ long& rTxtStart, long& rTxtCount,
+ long& rRefStart, long& rRefCount ) const
+{
+ ULONG nFcStart = rWrt.pTableStrm->Tell();
+ USHORT nLen = aCps.Count();
+ if( nLen )
+ {
+ ASSERT( aCps.Count() + 2 == pTxtPos->Count(), "WritePlc: DeSync" );
+
+ SvStringsSortDtor aStrArr( 0, 4 );
+ WW8Fib& rFib = *rWrt.pFib; // n+1-te CP-Pos nach Handbuch
+ USHORT i;
+ BOOL bWriteCP = TRUE;
+
+ switch( nTTyp )
+ {
+ case TXT_ATN:
+ // then write first the GrpXstAtnOwners
+ for( i = 0; i < nLen; ++i )
+ {
+ const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ];
+ String* p = new String( rPFld.GetPar1() );
+ if( !aStrArr.Insert( p ))
+ delete p;
+ }
+
+
+ if( rWrt.bWrtWW8 )
+ for( i = 0; i < aStrArr.Count(); ++i )
+ {
+ const String& rStr = *aStrArr[ i ];
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, rStr.Len() );
+ SwWW8Writer::WriteString16( *rWrt.pTableStrm, rStr, FALSE );
+ }
+ else
+ for( i = 0; i < aStrArr.Count(); ++i )
+ {
+ const String& rStr = *aStrArr[ i ];
+ *rWrt.pTableStrm << (BYTE)rStr.Len();
+ SwWW8Writer::WriteString8( *rWrt.pTableStrm, rStr, FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ }
+
+ rFib.fcGrpStAtnOwners = nFcStart;
+ nFcStart = rWrt.pTableStrm->Tell();
+ rFib.lcbGrpStAtnOwners = nFcStart - rFib.fcGrpStAtnOwners;
+ break;
+
+ case TXT_TXTBOX:
+ case TXT_HFTXTBOX:
+ {
+ pTxtPos->Write( *rWrt.pTableStrm );
+ const SvULongs* pShapeIds = GetShapeIdArr();
+ ASSERT( pShapeIds, "wo sind die ShapeIds?" );
+
+ // nLen = pTxtPos->Count();
+ for( i = 0; i < nLen; ++i )
+ {
+ // write textbox story - FTXBXS
+ // is it an writer or sdr - textbox?
+ const SdrObject* pObj = (SdrObject*)aCntnt[ i ];
+ INT32 nCnt = 1;
+ if( !pObj->ISA( SdrTextObj ) )
+ {
+ // find the "highest" SdrObject of this
+ const SwFrmFmt& rFmt = *::FindFrmFmt( pObj );
+
+ const SwFmtChain* pChn = &rFmt.GetChain();
+ while( pChn->GetNext() )
+ {
+ // has a chain?
+ // then calc the cur pos in the chain
+ ++nCnt;
+ pChn = &pChn->GetNext()->GetChain();
+ }
+ }
+ // long cTxbx / iNextReuse
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, nCnt );
+ // long cReusable
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
+ // short fReusable
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ // long reserved
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
+ // long lid
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ (*pShapeIds)[i]);
+ // long txidUndo
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
+ }
+ SwWW8Writer::FillCount( *rWrt.pTableStrm, 22 );
+ bWriteCP = FALSE;
+ }
+ break;
+ }
+
+ if( bWriteCP )
+ {
+ // Schreibe CP-Positionen
+ for( i = 0; i < nLen; i++ )
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, aCps[ i ] );
+
+ // n+1-te CP-Pos nach Handbuch
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ rFib.ccpText + rFib.ccpFtn +
+ rFib.ccpHdr + rFib.ccpEdn +
+ rFib.ccpTxbx + rFib.ccpHdrTxbx + 1 );
+
+ if( TXT_ATN == nTTyp )
+ {
+ USHORT nFndPos;
+ for( i = 0; i < nLen; ++i )
+ {
+ const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ];
+ String sAuthor( rPFld.GetPar1() );
+ aStrArr.Seek_Entry( &sAuthor, &nFndPos );
+ BYTE nLen = (BYTE)sAuthor.Len();
+ if( nLen > 9 )
+ {
+ sAuthor.Erase( 9 );
+ nLen = 9;
+ }
+
+ // xstUsrInitl[ 10 ] pascal-style String holding initials
+ // of annotation author
+ if( rWrt.bWrtWW8 )
+ {
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, nLen );
+ SwWW8Writer::WriteString16( *rWrt.pTableStrm, sAuthor,
+ FALSE );
+ SwWW8Writer::FillCount( *rWrt.pTableStrm, (9 - nLen) * 2 );
+
+ }
+ else
+ {
+ *rWrt.pTableStrm << nLen;
+ SwWW8Writer::WriteString8( *rWrt.pTableStrm, sAuthor,
+ FALSE, RTL_TEXTENCODING_MS_1252 );
+ SwWW8Writer::FillCount( *rWrt.pTableStrm, 9 - nLen );
+ }
+
+ //SVBT16 ibst; // index into GrpXstAtnOwners
+ //SVBT16 ak; // not used
+ //SVBT16 grfbmc; // not used
+ //SVBT32 ITagBkmk; // when not -1, this tag identifies the
+
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos );
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
+ }
+ }
+ else
+ {
+ USHORT nNo = 0;
+ for( i = 0; i < nLen; ++i ) // Schreibe Flags
+ {
+ const SwFmtFtn* pFtn = (SwFmtFtn*)aCntnt[ i ];
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm,
+ pFtn->GetNumStr().Len() ? 0 : ++nNo );
+ }
+ }
+ }
+ rRefStart = nFcStart;
+ nFcStart = rWrt.pTableStrm->Tell();
+ rRefCount = nFcStart - rRefStart;
+
+ pTxtPos->Write( *rWrt.pTableStrm );
+
+ switch( nTTyp )
+ {
+ case TXT_TXTBOX:
+ case TXT_HFTXTBOX:
+ for( i = 0; i < nLen; ++i )
+ {
+ // write break descriptor (BKD)
+ // short itxbxs
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, i );
+ // short dcpDepend
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
+ // short flags : icol/fTableBreak/fColumnBreak/fMarked/
+ // fUnk/fTextOverflow
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x800 );
+ }
+ SwWW8Writer::FillCount( *rWrt.pTableStrm, 6 );
+ break;
+ }
+
+ rTxtStart = nFcStart;
+ rTxtCount = rWrt.pTableStrm->Tell() - nFcStart;
+ }
+}
+
+const SvULongs* WW8_WrPlcSubDoc::GetShapeIdArr() const
+{
+ return 0;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/wrtw8sty.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.28 2000/09/18 16:04:58 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.27 2000/08/21 10:14:03 khz
+ Export Line Numbering (restart on new section)
+
+ Revision 1.26 2000/07/04 08:58:09 jp
+ _OutFont: write zero terminated FontNames
+
+ Revision 1.25 2000/05/12 16:14:02 jp
+ Changes for Unicode
+
+ Revision 1.24 2000/05/04 11:41:34 jp
+ Bug #75550#: standard para.style must have a language sprm
+
+ Revision 1.23 2000/01/25 20:09:30 jp
+ Bug #72146#: convert stylenames only for W95 to ANSI
+
+ Revision 1.22 1999/12/15 17:06:14 jp
+ Bug #70913#: write Ftn-/EndNoteInfo - at end of section or page/doc
+
+ Revision 1.21 1999/11/25 21:19:37 jp
+ Bug #70134#: dont set def values by charstyles
+
+ Revision 1.20 1999/11/22 18:26:11 jp
+ export of TOX and TOX entries
+
+ Revision 1.19 1999/11/12 16:07:16 jp
+ write foot-/endnote attributes with correct charfmts
+
+ Revision 1.18 1999/11/10 16:09:50 jp
+ Bug #67922#: write header/footer for w95
+
+ Revision 1.17 1999/10/22 14:11:01 jp
+ Bug #69408#: if write SfxItemSet set the pointer at writerclass
+
+ Revision 1.16 1999/10/14 21:06:05 jp
+ Bug #68617#,#68705# and other little things
+
+ Revision 1.15 1999/10/13 09:08:46 jp
+ write character attributs of SdrObjects
+
+ Revision 1.14 1999/10/11 10:58:59 jp
+ Bug #69083#: set mirrormargin flag in dop
+
+ Revision 1.13 1999/09/09 17:40:49 jp
+ Bug #68628#: write startvalue of SwFtnInfo and SwEndNoteInfo
+
+ Revision 1.12 1999/09/01 17:32:38 JP
+ new: write the text of SdrTextObjects
+
+
+ Rev 1.11 01 Sep 1999 19:32:38 JP
+ new: write the text of SdrTextObjects
+
+ Rev 1.10 30 Aug 1999 18:55:02 JP
+ write cp's of foot-/endnotes
+
+ Rev 1.9 24 Aug 1999 20:15:48 JP
+ Escher Export
+
+ Rev 1.8 16 Aug 1999 17:16:30 JP
+ W97 Export: experimental escher export (1)
+
+ Rev 1.7 21 Jul 1999 18:28:22 JP
+ W97 Export: experimental escher export
+
+ Rev 1.6 06 Jul 1999 14:54:04 JP
+ W97-Export corrections
+
+ Rev 1.5 30 Jun 1999 19:56:42 JP
+ W97-Export: Fields/PostIts/References
+
+ Rev 1.4 23 Jun 1999 12:46:16 JP
+ Export of numbers und outlinenumbers
+
+ Rev 1.3 16 Jun 1999 19:53:58 JP
+ Change interface of base class Writer
+
+ Rev 1.2 04 Jun 1999 17:47:56 JP
+ WW97-Export: Code aufgeteilt
+
+ Rev 1.1 21 May 1999 01:59:10 JP
+ Export von WW97 Format: StyleSheets
+
+ Rev 1.0 19 May 1999 19:35:16 JP
+ WinWord97-ExportFilter
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
new file mode 100644
index 000000000000..81ac65a89408
--- /dev/null
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -0,0 +1,2226 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtww8.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+
+#include <string.h> // memcpy()
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SV_SALBTYPE_HXX
+#include <vcl/salbtype.hxx>
+#endif
+#ifndef _SVSTOR_HXX
+#include <so3/svstor.hxx>
+#endif
+#ifndef _ZFORMAT_HXX
+#include <svtools/zformat.hxx>
+#endif
+#ifndef _SFXDOCINF_HXX
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _SVX_TSPTITEM_HXX
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVDMODEL_HXX
+#include <svx/svdmodel.hxx>
+#endif
+#ifndef _SVDPAGE_HXX
+#include <svx/svdpage.hxx>
+#endif
+#ifndef _SVX_HYZNITEM_HXX //autogen
+#include <svx/hyznitem.hxx>
+#endif
+
+#if SUPD>593
+#ifndef _MSOLEEXP_HXX
+#include <svx/msoleexp.hxx>
+#endif
+#endif
+
+#ifndef _OFA_FLTRCFG_HXX
+#include <offmgr/fltrcfg.hxx>
+#endif
+#ifndef _OFF_APP_HXX //autogen
+#include <offmgr/app.hxx>
+#endif
+
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _SWRECT_HXX
+#include <swrect.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTPDSC_HXX
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _DOCSTAT_HXX
+#include <docstat.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx>
+#endif
+#ifndef _FLYPOS_HXX
+#include <flypos.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx>
+#endif
+#ifndef _SWTABLE_HXX
+#include <swtable.hxx>
+#endif
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+#ifndef _WW8STRUC_HXX
+#include <ww8struc.hxx>
+#endif
+#ifndef _WRT_FN_HXX
+#include <wrt_fn.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _ERRHDL_HXX
+#include <errhdl.hxx>
+#endif
+#ifndef _SWMODULE_HXX
+#include <swmodule.hxx>
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx>
+#endif
+#include "poolfmt.hxx" // RES_POOLCOLL_STANDARD
+
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // Progress
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+
+#ifndef SW_FMTLINE_HXX
+#include <fmtline.hxx>
+#endif
+
+
+class WW8_WrFkp
+{
+ BYTE* pFkp; // gesamter Fkp ( zuerst nur FCs und Sprms )
+ BYTE* pOfs; // Pointer auf Offset-Bereich, spaeter nach pFkp kopiert
+ ePLCFT ePlc;
+ short nStartGrp; // ab hier grpprls
+ short nOldStartGrp;
+ BYTE nItemSize;
+ BYTE nIMax; // Anzahl der Eintrags-Paare
+ BYTE nOldVarLen;
+ BOOL bCombined; // TRUE : Einfuegen verboten
+
+ BYTE SearchSameSprm( USHORT nVarLen, const BYTE* pSprms );
+public:
+ WW8_WrFkp( ePLCFT ePl, WW8_FC nStartFc, BOOL bWrtWW8 );
+ ~WW8_WrFkp();
+ BOOL Append( WW8_FC nEndFc, USHORT nVarLen = 0, const BYTE* pSprms = 0 );
+ BOOL Combine();
+ void Write( SvStream& rStrm, SwWW8WrGrf& rGrf );
+
+ BOOL IsEqualPos( WW8_FC nEndFc ) const
+ { return !bCombined && nIMax && nEndFc == ((INT32*)pFkp)[nIMax]; }
+ void MergeToNew( short& rVarLen, BYTE *& pNewSprms );
+ BOOL IsEmptySprm() const
+ { return !bCombined && nIMax && !nOldVarLen; }
+ void SetNewEnd( WW8_FC nEnd )
+ { ((INT32*)pFkp)[nIMax] = nEnd; }
+
+#ifdef __WW8_NEEDS_COPY
+ WW8_FC GetStartFc() const;
+ WW8_FC GetEndFc() const;
+#else
+ WW8_FC GetStartFc() const { return ((INT32*)pFkp)[0]; };
+ WW8_FC GetEndFc() const { return ((INT32*)pFkp)[nIMax]; };
+#endif // defined __WW8_NEEDS_COPY
+};
+
+
+// -------------------------------------------------------------------------
+// class WW8_WrPc sammelt alle Piece-Eintraege fuer ein Piece
+// -------------------------------------------------------------------------
+
+class WW8_WrPc
+{
+ WW8_CP nStartCp; // Start ZeichenPosition vom Text
+ WW8_FC nStartFc; // Start File Position vom Text
+ USHORT nStatus; // Absatzende im Piece ?
+
+public:
+ WW8_WrPc(WW8_FC nSFc, WW8_CP nSCp )
+ : nStartCp( nSCp ), nStartFc( nSFc ), nStatus( 0x0040 )
+ {}
+
+ void SetStatus() { nStatus = 0x0050; }
+ USHORT GetStatus() const { return nStatus; }
+ WW8_CP GetStartCp() const { return nStartCp; }
+ WW8_FC GetStartFc() const { return nStartFc; }
+};
+
+
+class WW8_WrtBookmarks
+{
+ SvULongs aSttCps, aEndCps; // Array of Start- and End CPs
+ SvStringsDtor aSwBkmkNms; // Array of Sw - Bookmarknames
+// SvStringsDtor aWWBkmkNms; // Array of WW - Bookmarknames
+
+ USHORT GetPos( const String& rNm );
+public:
+ WW8_WrtBookmarks();
+ ~WW8_WrtBookmarks();
+
+ void Append( WW8_CP nStartCp, const String& rNm );
+ void Write( SwWW8Writer& rWrt );
+
+// String GetWWBkmkName( const String& rName ) const;
+};
+
+class WW8_WrtRedlineAuthor
+{
+ SvStringsDtor aAuthors; // Array of Sw - Bookmarknames
+
+ USHORT GetPos( const String& rNm );
+public:
+ WW8_WrtRedlineAuthor() : aAuthors( 0, 4 ) {}
+
+ USHORT AddName( const String& rNm );
+ void Write( SwWW8Writer& rWrt );
+};
+
+
+#define ANZ_DEFAULT_STYLES 16
+
+// die Namen der StorageStreams
+#define sMainStream String::CreateFromAscii( \
+ RTL_CONSTASCII_STRINGPARAM( "WordDocument" ))
+#define sDataStream String::CreateFromAscii( \
+ RTL_CONSTASCII_STRINGPARAM( "Data" ))
+#define sTableStream String::CreateFromAscii( \
+ RTL_CONSTASCII_STRINGPARAM( "1Table" ))
+
+
+SV_IMPL_VARARR( WW8Bytes, BYTE )
+SV_IMPL_PTRARR( WW8_WrFkpPtrs, WW8_FkpPtr )
+
+typedef WW8_WrPc* WW8_WrPcPtr;
+SV_DECL_PTRARR_DEL( WW8_WrPcPtrs, WW8_WrPcPtr, 4, 4 )
+SV_IMPL_PTRARR( WW8_WrPcPtrs, WW8_WrPcPtr )
+
+static void WriteDop( SwWW8Writer& rWrt )
+{
+ WW8Dop& rDop = *rWrt.pDop;
+
+ // default TabStop schreiben
+ const SvxTabStopItem& rTabStop = (SvxTabStopItem& )rWrt.pDoc->
+ GetAttrPool().GetDefaultItem( RES_PARATR_TABSTOP );
+ rDop.dxaTab = (USHORT)rTabStop[0].GetTabPos();
+
+
+ // Werte aus der DocStatistik (werden aufjedenfall fuer die
+ // DocStat-Felder benoetigt!)
+ rDop.fWCFtnEdn = TRUE; // because they are included in StarWriter
+
+ const SwDocStat& rDStat = rWrt.pDoc->GetDocStat();
+ rDop.cWords = rDStat.nWord;
+ rDop.cCh = rDStat.nChar;
+ rDop.cPg = rDStat.nPage;
+ rDop.cParas = rDStat.nPara;
+ rDop.cLines = rDStat.nPara;
+
+// auch damit werden die DocStat-Felder in Kopf-/Fusszeilen nicht korrekt
+// berechnet.
+// ( we do not have this fields! )
+
+ // und noch fuer die Header und Footers
+ rDop.cWordsFtnEnd = rDStat.nWord;
+ rDop.cChFtnEdn = rDStat.nChar;
+ rDop.cPgFtnEdn = rDStat.nPage;
+ rDop.cParasFtnEdn = rDStat.nPara;
+ rDop.cLinesFtnEdn = rDStat.nPara;
+
+ rDop.Write( *rWrt.pTableStrm, *rWrt.pFib );
+}
+
+
+// HasItem ist fuer die Zusammenfassung der Doppel-Attribute
+// Underline / WordLineMode und Box / Shadow.
+// Es kann nur etwas gefunden werden, wenn diese Methode innerhalb
+// der aufgerufenen Methoden WW8_SwAttrIter::OutAttr() und
+// SwWW8Writer::Out_SfxItemSet() benutzt wird.
+const SfxPoolItem* SwWW8Writer::HasItem( USHORT nWhich ) const
+{
+ const SfxPoolItem* pItem;
+ if( pISet )
+ {
+ // if write a EditEngine text, then the WhichIds are greater as
+ // ourer own Ids. So the Id have to translate from ouer into the
+ // EditEngine Range
+ if( RES_WHICHHINT_END < *pISet->GetRanges() )
+ nWhich = TranslateToEditEngineId( nWhich );
+ if( SFX_ITEM_SET != pISet->GetItemState( nWhich, TRUE, &pItem ) )
+ pItem = 0;
+ }
+ else if( pChpIter )
+ pItem = pChpIter->HasTextItem( nWhich );
+ else
+ {
+ ASSERT( !this, "Wo ist mein ItemSet / pChpIter ?" );
+ pItem = 0;
+ }
+ return pItem;
+}
+
+const SfxPoolItem& SwWW8Writer::GetItem( USHORT nWhich ) const
+{
+ const SfxPoolItem* pItem;
+ if( pISet )
+ {
+ // if write a EditEngine text, then the WhichIds are greater as
+ // ourer own Ids. So the Id have to translate from ouer into the
+ // EditEngine Range
+ if( RES_WHICHHINT_END < *pISet->GetRanges() )
+ nWhich = TranslateToEditEngineId( nWhich );
+ pItem = &pISet->Get( nWhich, TRUE );
+ }
+ else if( pChpIter )
+ pItem = &pChpIter->GetItem( nWhich );
+ else
+ {
+ ASSERT( !this, "Wo ist mein ItemSet / pChpIter ?" );
+ pItem = 0;
+ }
+ return *pItem;
+}
+
+//------------------------------------------------------------------------------
+
+WW8_WrPlc1::WW8_WrPlc1( USHORT nStructSz )
+ : aPos( 16, 16 ), aDat( 16 * (int)nStructSz, 16 * (int)nStructSz ),
+ nStructSiz( nStructSz )
+{
+}
+
+void WW8_WrPlc1::Append( WW8_CP nCp, const void* pData )
+{
+ aPos.Insert( nCp, aPos.Count() );
+ aDat.Insert( (BYTE*)pData, nStructSiz, aDat.Count() );
+}
+
+void WW8_WrPlc1::Finish( ULONG nLastCp, ULONG nSttCp )
+{
+ if( aPos.Count() )
+ {
+ aPos.Insert( nLastCp, aPos.Count() );
+ if( nSttCp )
+ for( USHORT n = 0; n < aPos.Count(); ++n )
+ aPos[ n ] -= nSttCp;
+ }
+}
+
+
+void WW8_WrPlc1::Write( SvStream& rStrm )
+{
+ for( USHORT i = 0; i < aPos.Count(); ++i )
+ SwWW8Writer::WriteLong( rStrm, aPos[i] );
+ rStrm.Write( aDat.GetData(), aDat.Count() ); // Anz Eintraege
+}
+
+//------------------------------------------------------------------------------
+// Klasse WW8_WrPlcFld fuer Felder
+//------------------------------------------------------------------------------
+
+
+BOOL WW8_WrPlcFld::Write( SwWW8Writer& rWrt )
+{
+ if( WW8_WrPlc1::Count() <= 1 )
+ return FALSE;
+
+ long *pfc, *plc;
+ switch( nTxtTyp )
+ {
+ case TXT_MAINTEXT:
+ pfc = &rWrt.pFib->fcPlcffldMom;
+ plc = &rWrt.pFib->lcbPlcffldMom;
+ break;
+ case TXT_HDFT:
+ pfc = &rWrt.pFib->fcPlcffldHdr;
+ plc = &rWrt.pFib->lcbPlcffldHdr;
+ break;
+
+ case TXT_FTN:
+ pfc = &rWrt.pFib->fcPlcffldFtn;
+ plc = &rWrt.pFib->lcbPlcffldFtn;
+ break;
+
+ case TXT_EDN:
+ pfc = &rWrt.pFib->fcPlcffldEdn;
+ plc = &rWrt.pFib->lcbPlcffldEdn;
+ break;
+
+ case TXT_TXTBOX:
+ pfc = &rWrt.pFib->fcPlcffldTxbx;
+ plc = &rWrt.pFib->lcbPlcffldTxbx;
+ break;
+
+ case TXT_HFTXTBOX:
+ pfc = &rWrt.pFib->fcPlcffldHdrTxbx;
+ plc = &rWrt.pFib->lcbPlcffldHdrTxbx;
+ break;
+
+ default:
+ pfc = plc = 0;
+ break;
+ }
+
+ if( pfc && plc )
+ {
+ ULONG nFcStart = rWrt.pTableStrm->Tell();
+ WW8_WrPlc1::Write( *rWrt.pTableStrm );
+ *pfc = nFcStart;
+ *plc = rWrt.pTableStrm->Tell() - nFcStart;
+ }
+ return TRUE;
+}
+
+
+//--------------------------------------------------------------------------
+
+void SwWW8Writer::FillCount( SvStream& rStrm, ULONG nCount )
+{
+ static UINT32 __READONLY_DATA aNulls[16] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; // 64 Byte
+
+ while( nCount > 64 )
+ {
+ rStrm.Write( aNulls, 64 ); // in 64-Byte-Schritten
+ nCount -= 64;
+ }
+ rStrm.Write( aNulls, nCount ); // Rest ( 0 .. 64 Bytes ) schreiben
+}
+
+
+ULONG SwWW8Writer::FillUntil( SvStream& rStrm, ULONG nEndPos )
+{
+ ULONG nCurPos = rStrm.Tell();
+ if( !nEndPos ) // nEndPos == 0 -> next Page
+ nEndPos = nCurPos + 0x1ff & ~0x1ffUL;
+
+ if( nEndPos > nCurPos )
+ SwWW8Writer::FillCount( rStrm, nEndPos - nCurPos );
+#ifndef PRODUCT
+ else
+ ASSERT( nEndPos == nCurPos, "Falsches FillUntil()" );
+#endif
+ return rStrm.Tell();
+}
+
+
+//--------------------------------------------------------------------------
+/* */
+
+WW8_WrPlcPn::WW8_WrPlcPn( SwWW8Writer& rWr, ePLCFT ePl, WW8_FC nStartFc )
+ : rWrt( rWr ), ePlc( ePl ), nFkpStartPage( 0 )
+{
+ WW8_FkpPtr pF = new WW8_WrFkp( ePlc, nStartFc, rWrt.bWrtWW8 );
+ aFkps.Insert( pF, aFkps.Count() );
+}
+
+WW8_WrPlcPn::~WW8_WrPlcPn()
+{
+ aFkps.DeleteAndDestroy( 0, aFkps.Count() );
+}
+
+void WW8_WrPlcPn::AppendFkpEntry( WW8_FC nEndFc, short nVarLen,
+ const BYTE* pSprms )
+{
+ WW8_FkpPtr pF = aFkps.GetObject( aFkps.Count() - 1 );
+
+ // big sprm? build the sprmPHugePapx
+ BYTE* pNewSprms = (BYTE*)pSprms;
+ BYTE aHugePapx[ 8 ];
+ if( rWrt.bWrtWW8 && PAP == ePlc && 488 < nVarLen )
+ {
+ BYTE* p = aHugePapx;
+ *p++ = *pSprms++; // set style Id
+ *p++ = *pSprms++;
+ nVarLen -= 2;
+
+ long nDataPos = rWrt.pDataStrm->Tell();
+ SwWW8Writer::WriteShort( *rWrt.pDataStrm, nVarLen );
+ rWrt.pDataStrm->Write( pSprms, nVarLen );
+
+ Set_UInt16( p, 0x6646 ); // set SprmCode
+ Set_UInt32( p, nDataPos ); // set startpos (FC) in the datastream
+ nVarLen = p - aHugePapx;
+ pSprms = pNewSprms = aHugePapx;
+ }
+ // if append at the same FC-EndPos and there are sprms, then get the old
+ // sprms and erase it; they will append now with the new sprms
+ else if( nVarLen && pF->IsEqualPos( nEndFc ))
+ pF->MergeToNew( nVarLen, pNewSprms );
+ // has the prev EndFC an empty sprm and the current is empty too, then
+ // expand only the old EndFc to the new EndFc
+ else if( !nVarLen && pF->IsEmptySprm() )
+ {
+ pF->SetNewEnd( nEndFc );
+ return ;
+ }
+
+ BOOL bOk = pF->Append( nEndFc, nVarLen, pNewSprms );
+ if( !bOk )
+ {
+ pF->Combine();
+ pF = new WW8_WrFkp( ePlc, pF->GetEndFc(), rWrt.bWrtWW8 );// Anfang neuer Fkp
+ // == Ende alter Fkp
+ aFkps.Insert( pF, aFkps.Count() );
+ if( !pF->Append( nEndFc, nVarLen, pNewSprms ) )
+ {
+ ASSERT( !this, "Sprm liess sich nicht einfuegen" );
+ }
+ }
+ if( pNewSprms != pSprms )
+ delete pNewSprms;
+}
+
+void WW8_WrPlcPn::WriteFkps()
+{
+ nFkpStartPage = (USHORT) ( SwWW8Writer::FillUntil( rWrt.Strm() ) >> 9 );
+
+ for( USHORT i = 0; i < aFkps.Count(); i++ )
+ aFkps.GetObject( i )->Write( rWrt.Strm(), *rWrt.pGrf );
+
+ if( CHP == ePlc )
+ {
+ rWrt.pFib->pnChpFirst = nFkpStartPage;
+ rWrt.pFib->cpnBteChp = aFkps.Count();
+ }
+ else
+ {
+ rWrt.pFib->pnPapFirst = nFkpStartPage;
+ rWrt.pFib->cpnBtePap = aFkps.Count();
+ }
+}
+
+void WW8_WrPlcPn::WritePlc()
+{
+ ULONG nFcStart = rWrt.pTableStrm->Tell();
+ USHORT i;
+
+ for( i = 0; i < aFkps.Count(); i++ )
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ aFkps.GetObject( i )->GetStartFc() );
+
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ aFkps.GetObject( i - 1 )->GetEndFc() );
+
+ // fuer jedes FKP die Page ausgeben
+ if( rWrt.bWrtWW8) // fuer WW97 Long-Ausgabe
+ for ( i = 0; i < aFkps.Count(); i++)
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, i + nFkpStartPage );
+ else // fuer WW95 Short-Ausgabe
+ for ( i = 0; i < aFkps.Count(); i++)
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, i + nFkpStartPage );
+
+ if( CHP == ePlc )
+ {
+ rWrt.pFib->fcPlcfbteChpx = nFcStart;
+ rWrt.pFib->lcbPlcfbteChpx = rWrt.pTableStrm->Tell() - nFcStart;
+ }
+ else
+ {
+ rWrt.pFib->fcPlcfbtePapx = nFcStart;
+ rWrt.pFib->lcbPlcfbtePapx = rWrt.pTableStrm->Tell() - nFcStart;
+ }
+}
+
+//--------------------------------------------------------------------------
+/* */
+
+WW8_WrFkp::WW8_WrFkp( ePLCFT ePl, WW8_FC nStartFc, BOOL bWrtWW8 )
+ : nItemSize( ( CHP == ePl ) ? 1 : ( bWrtWW8 ? 13 : 7 )),
+ nIMax( 0 ), ePlc( ePl ), bCombined( FALSE ), nStartGrp( 511 ),
+ nOldStartGrp( 511 ), nOldVarLen( 0 )
+{
+ pFkp = (BYTE*)new INT32[128]; // 512 Byte
+ pOfs = (BYTE*)new INT32[128]; // 512 Byte
+ memset( pFkp, 0, 4 * 128 );
+ memset( pOfs, 0, 4 * 128 );
+ ( (INT32*)pFkp )[0] = nStartFc; // 0. FC-Eintrag auf nStartFc
+}
+
+WW8_WrFkp::~WW8_WrFkp()
+{
+ delete( pFkp );
+ delete( pOfs );
+}
+
+BYTE WW8_WrFkp::SearchSameSprm( USHORT nVarLen, const BYTE* pSprms )
+{
+ if( 3 < nVarLen )
+ {
+ // if the sprms contained picture-references then never equal!
+ for( BYTE n = nVarLen - 1; 3 < n; --n )
+ if( pSprms[ n ] == GRF_MAGIC_3 &&
+ pSprms[ n-1 ] == GRF_MAGIC_2 &&
+ pSprms[ n-2 ] == GRF_MAGIC_1 )
+ return 0;
+ }
+
+ short i;
+ for( i = 0; i < nIMax; i++ )
+ {
+ BYTE nStart = pOfs[i * nItemSize];
+ if( nStart )
+ { // Hat Sprms
+ const BYTE* p = pFkp + ( (USHORT)nStart << 1 );
+ if( ( CHP == ePlc
+ ? (*p++ == nVarLen)
+ : (((USHORT)*p++ << 1 ) == (( nVarLen+1) & 0xfffe)) )
+ && !memcmp( p, pSprms, nVarLen ) )
+ return nStart; // gefunden
+ }
+ }
+ return 0; // nicht gefunden
+}
+
+BOOL WW8_WrFkp::Append( WW8_FC nEndFc, USHORT nVarLen, const BYTE* pSprms )
+{
+ ASSERT( !nVarLen || pSprms, "Item-Pointer fehlt" );
+ ASSERT( nVarLen < ( ( ePlc == PAP ) ? 497U : 502U ), "Sprms zu lang !" );
+
+ if( bCombined )
+ {
+ ASSERT( !this, "Fkp::Append: Fkp is already combined" );
+ return FALSE;
+ }
+ INT32 n = ((INT32*)pFkp)[nIMax]; // letzter Eintrag
+ if( nEndFc <= n )
+ {
+ ASSERT( nEndFc >= n, "+Fkp: FC rueckwaerts" );
+ ASSERT( !nVarLen || !pSprms || nEndFc != n,
+ "+Fkp: selber FC mehrfach benutzt" );
+ // selber FC ohne Sprm wird ohne zu mosern ignoriert.
+
+ return TRUE; // ignorieren, keinen neuen Fkp anlegen
+ }
+
+ BYTE nOldP = ( nVarLen ) ? SearchSameSprm( nVarLen, pSprms ) : 0;
+ // Kombinieren gleicher Eintraege
+ short nOffset, nPos = nStartGrp;
+ if( nVarLen && !nOldP )
+ {
+ nPos = PAP == ePlc
+ ? ( 13 == nItemSize // HACK: PAP und bWrtWW8 !!
+ ? (nStartGrp & 0xFFFE ) - nVarLen - 1
+ : (nStartGrp - (((nVarLen + 1) & 0xFFFE)+1)) & 0xFFFE )
+ : ((nStartGrp - nVarLen - 1) & 0xFFFE);
+ if( nPos < 0 )
+ return FALSE; // Passt absolut nicht
+ nOffset = nPos; // Offset merken (kann auch ungerade sein!)
+ nPos &= 0xFFFE; // Pos fuer Sprms ( gerade Pos )
+ }
+
+ if( (USHORT)nPos <= ( nIMax + 2U ) * 4U + ( nIMax + 1U ) * nItemSize )
+ // Passt hinter CPs und Offsets ?
+ return FALSE; // Nein
+
+ ((INT32*)pFkp)[nIMax + 1] = nEndFc; // FC eintragen
+
+ nOldVarLen = (BYTE)nVarLen;
+ if( nVarLen && !nOldP )
+ { // echt eintragen
+ nOldStartGrp = nStartGrp;
+
+ nStartGrp = nPos;
+ pOfs[nIMax * nItemSize] = (BYTE)( nStartGrp >> 1 );
+ // ( DatenAnfg >> 1 ) eintragen
+ BYTE nCnt = CHP == ePlc
+ ? ( nVarLen < 256 ) ? (BYTE) nVarLen : 255
+ : ( ( nVarLen + 1 ) >> 1 );
+
+ pFkp[ nOffset ] = nCnt; // DatenLaenge eintragen
+ memcpy( pFkp + nOffset + 1, pSprms, nVarLen ); // Sprms speichern
+ }
+ else
+ {
+ // nicht echt eintragen ( keine Sprms oder Wiederholung )
+ // DatenAnfg 0 ( keine Daten ) oder Wiederholung
+ pOfs[nIMax * nItemSize] = nOldP;
+ }
+ nIMax++;
+ return TRUE;
+}
+
+BOOL WW8_WrFkp::Combine()
+{
+ if( bCombined )
+ return FALSE;
+ if( nIMax )
+ memcpy( pFkp + ( nIMax + 1 ) * 4, pOfs, nIMax * nItemSize );
+ DELETEZ( pOfs );
+ ((BYTE*)pFkp)[511] = nIMax;
+ bCombined = TRUE;
+
+#if defined __BIGENDIAN // Hier werden nur die FCs gedreht, die
+ register USHORT i; // Sprms muessen an anderer Stelle gedreht
+ // werden
+ register UINT32* p;
+ for( i = 0, p = (UINT32*)pFkp; i <= nIMax; i++, p++ )
+ *p = SWAPLONG( *p );
+#endif // ifdef __BIGENDIAN
+
+ return TRUE;
+}
+
+void WW8_WrFkp::Write( SvStream& rStrm, SwWW8WrGrf& rGrf )
+{
+ Combine(); // Falls noch nicht Combined
+
+ register BYTE* p; // Suche Magic fuer nPicLocFc
+ BYTE* pEnd = pFkp + nStartGrp;
+ for( p = pFkp + 511 - 4; p >= pEnd; p-- )
+ {
+ if( *p != GRF_MAGIC_1 ) // Suche nach Signatur 0x12 0x34 0x56 0xXX
+ continue;
+ if( *(p+1) != GRF_MAGIC_2 )
+ continue;
+ if( *(p+2) != GRF_MAGIC_3 )
+ continue;
+
+ SVBT32 nPos; // Signatur gefunden
+ LongToSVBT32( rGrf.GetFPos(), nPos ); // FilePos der Grafik
+ memcpy( p, nPos, 4 ); // Patche FilePos ueber Signatur
+ }
+ rStrm.Write( pFkp, 512 );
+}
+
+void WW8_WrFkp::MergeToNew( short& rVarLen, BYTE *& rpNewSprms )
+{
+ BYTE nStart = pOfs[ (nIMax-1) * nItemSize ];
+ if( nStart )
+ { // Hat Sprms
+ BYTE* p = pFkp + ( (USHORT)nStart << 1 );
+
+ // old and new equal? Then copy only one into the new sprms
+ if( nOldVarLen == rVarLen && !memcmp( p+1, rpNewSprms, nOldVarLen ))
+ {
+ BYTE* pNew = new BYTE[ nOldVarLen ];
+ memcpy( pNew, p+1, nOldVarLen );
+ rpNewSprms = pNew;
+ }
+ else
+ {
+ BYTE* pNew = new BYTE[ nOldVarLen + rVarLen ];
+ memcpy( pNew, p+1, nOldVarLen );
+ memcpy( pNew + nOldVarLen, rpNewSprms, rVarLen );
+
+ rpNewSprms = pNew;
+ rVarLen += nOldVarLen;
+ }
+ --nIMax;
+ // if this sprms dont used from others, remove it
+ FASTBOOL bFnd = FALSE;
+ for( USHORT n = 0; n < nIMax; ++n )
+ if( nStart == pOfs[ n * nItemSize ] )
+ {
+ bFnd = TRUE;
+ break;
+ }
+ if( !bFnd )
+ {
+ nStartGrp = nOldStartGrp;
+ memset( p, 0, nOldVarLen+1 );
+ }
+ }
+}
+
+#ifdef __WW8_NEEDS_COPY
+
+WW8_FC WW8_WrFkp::GetStartFc() const
+{
+// wenn bCombined, dann ist das Array ab pFkp schon Bytemaessig auf LittleEndian
+// umgedreht, d.h. zum Herausholen der Anfangs- und Endpositionen muss
+// zurueckgedreht werden.
+ if( bCombined )
+ return SVBT32ToLong( pFkp ); // 0. Element
+ return ((INT32*)pFkp)[0];
+}
+
+WW8_FC WW8_WrFkp::GetEndFc() const
+{
+ if( bCombined )
+ return SVBT32ToLong( &(pFkp[nIMax*4]) ); // nIMax-tes SVBT32-Element
+ return ((INT32*)pFkp)[nIMax];
+}
+
+#endif // defined __WW8_NEEDS_COPY
+
+
+
+//--------------------------------------------------------------------------
+// Methoden fuer Piece-Table-Verwaltung
+//--------------------------------------------------------------------------
+
+WW8_WrPct::WW8_WrPct( WW8_FC nfcMin )
+ : nOldFc( nfcMin ),bIsUni( FALSE ), pPcts( new WW8_WrPcPtrs )
+{
+ AppendPc( nOldFc, bIsUni );
+}
+
+WW8_WrPct::~WW8_WrPct()
+{
+ delete pPcts;
+}
+
+// Piece fuellen und neues Piece erzeugen
+void WW8_WrPct::AppendPc( WW8_FC nStartFc, BOOL bIsUnicode )
+{
+ WW8_CP nStartCp = nStartFc - nOldFc; // Textbeginn abziehen
+ if ( !nStartCp )
+ {
+ if ( 0 != pPcts->Count() )
+ {
+ ASSERT( 1 == pPcts->Count(), "Leeres Piece !!");
+ pPcts->DeleteAndDestroy( pPcts->Count() - 1 , 1);
+ }
+ }
+
+ nOldFc = nStartFc; // StartFc als alten merken
+
+ if( bIsUni )
+ nStartCp >>= 1; // Bei Unicode Anzahl der Zeichen / 2
+
+
+ if ( !bIsUnicode )
+ {
+ nStartFc <<= 1; // Adresse * 2
+ nStartFc |= 0x40000000; // Vorletztes Bit setzen fuer !Unicode
+ }
+
+ if( pPcts->Count() )
+ nStartCp += pPcts->GetObject( pPcts->Count()- 1 )->GetStartCp();
+
+ WW8_WrPcPtr pPc = new WW8_WrPc( nStartFc, nStartCp );
+ pPcts->Insert( pPc, pPcts->Count() );
+
+ bIsUni = bIsUnicode;
+}
+
+
+void WW8_WrPct::WritePc( SwWW8Writer& rWrt )
+{
+ ULONG nPctStart;
+ ULONG nOldPos, nEndPos;
+ USHORT i;
+
+ nPctStart = rWrt.pTableStrm->Tell(); // Beginn Piece-Table
+ *rWrt.pTableStrm << ( char )0x02; // Statusbyte PCT
+ nOldPos = nPctStart + 1; // Position merken
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 ); // Laenge folgt
+ for( i = 0; i < pPcts->Count(); ++i ) // Bereiche
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm,
+ pPcts->GetObject( i )->GetStartCp() );
+
+
+ // die letzte Pos noch errechnen
+ ULONG nStartCp = rWrt.pFib->fcMac - nOldFc;
+ if( bIsUni )
+ nStartCp >>= 1; // Bei Unicode Anzahl der Zeichen / 2
+ nStartCp += pPcts->GetObject( i-1 )->GetStartCp();
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, nStartCp );
+
+ // Pieceverweise
+ for ( i = 0; i < pPcts->Count(); ++i )
+ {
+ WW8_WrPcPtr pPc = pPcts->GetObject( i );
+
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, pPc->GetStatus());
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, pPc->GetStartFc());
+ SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0); // PRM=0
+ }
+
+ // Eintraege im FIB
+ rWrt.pFib->fcClx = nPctStart;
+ nEndPos = rWrt.pTableStrm->Tell();
+ rWrt.pFib->lcbClx = nEndPos - nPctStart;
+
+ // und noch die Laenge eintragen
+ SwWW8Writer::WriteLong( *rWrt.pTableStrm, nOldPos,
+ nEndPos - nPctStart-5 );
+
+}
+
+void WW8_WrPct::SetParaBreak()
+{
+ ASSERT( pPcts->Count(),"SetParaBreak : aPcts.Count = 0" );
+ pPcts->GetObject( pPcts->Count() - 1)->SetStatus();
+}
+
+ULONG WW8_WrPct::Fc2Cp( ULONG nFc ) const
+{
+ ASSERT( nFc >= (ULONG)nOldFc, "FilePos liegt vorm letzten Piece" );
+ ASSERT( pPcts->Count(), "Fc2Cp noch kein Piece vorhanden" );
+
+ nFc -= nOldFc;
+ if( bIsUni )
+ nFc /= 2;
+ return nFc + pPcts->GetObject( pPcts->Count() - 1 )->GetStartCp();
+}
+
+//--------------------------------------------------------------------------
+/* */
+
+WW8_WrtBookmarks::WW8_WrtBookmarks()
+ : aSttCps( 0, 16 ), aEndCps( 0, 16 ),
+ aSwBkmkNms( 0, 16 )
+// JP 24.06.99: not used at time ,aWWBkmkNms( 0, 16 ),
+{
+}
+
+WW8_WrtBookmarks::~WW8_WrtBookmarks()
+{
+}
+
+void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm )
+{
+ USHORT nPos = GetPos( rNm );
+ if( USHRT_MAX == nPos )
+ {
+ // new -> insert as start position
+ nPos = aSttCps.Count();
+ // sort by startposition
+ // theory: write continuous -> then the new position is at end
+ while( nPos && aSttCps[ nPos - 1 ] > ULONG( nStartCp ))
+ --nPos;
+
+ aSttCps.Insert( nStartCp, nPos );
+ aEndCps.Insert( nStartCp, nPos );
+ String* p = new String( rNm );
+ aSwBkmkNms.Insert( p, nPos );
+// JP 24.06.99: not used at time
+// p = new String( GetWWBkmkName(rNm ));
+// aWWBkmkNms.Insert( p, nPos );
+ }
+ else
+ {
+ // old -> its the end position
+ ASSERT( aEndCps[ nPos ] == aSttCps[ nPos ], "end position is valid" );
+ aEndCps.Replace( nStartCp, nPos );
+ }
+}
+
+
+void WW8_WrtBookmarks::Write( SwWW8Writer& rWrt )
+{
+ USHORT nCount = aSttCps.Count(), i;
+ if( nCount )
+ {
+ SvULongs aEndSortTab( 255 < nCount ? 255 : nCount, 4 );
+ // sort then endpositions
+ for( i = 0; i < nCount; ++i )
+ {
+ ULONG nCP = aEndCps[ i ];
+ USHORT nPos = i;
+ while( nPos && aEndSortTab[ nPos - 1 ] > nCP )
+ --nPos;
+ aEndSortTab.Insert( nCP, nPos );
+ }
+
+ // we have some bookmarks found in the document -> write them
+ // first the Bookmark Name Stringtable
+ rWrt.WriteAsStringTable( (SvStrings&)aSwBkmkNms,
+ rWrt.pFib->fcSttbfbkmk,
+ rWrt.pFib->lcbSttbfbkmk );
+
+ // second the Bookmark start positions as pcf of longs
+ SvStream& rStrm = rWrt.bWrtWW8 ? *rWrt.pTableStrm : rWrt.Strm();
+ rWrt.pFib->fcPlcfbkf = rStrm.Tell();
+ for( i = 0; i < nCount; ++i )
+ SwWW8Writer::WriteLong( rStrm, aSttCps[ i ] );
+ SwWW8Writer::WriteLong( rStrm, rWrt.pFib->ccpText );
+ for( i = 0; i < nCount; ++i )
+ {
+ ULONG nEndCP = aEndCps[ i ];
+ USHORT nPos = i;
+ if( aEndSortTab[ nPos ] > nEndCP )
+ {
+ while( aEndSortTab[ --nPos ] != nEndCP )
+ ;
+ }
+ else if( aEndSortTab[ nPos ] < nEndCP )
+ while( aEndSortTab[ ++nPos ] != nEndCP )
+ ;
+
+ SwWW8Writer::WriteLong( rStrm, nPos );
+ }
+ rWrt.pFib->lcbPlcfbkf = rStrm.Tell() - rWrt.pFib->fcPlcfbkf;
+
+ // third the Bookmark end positions
+ rWrt.pFib->fcPlcfbkl = rStrm.Tell();
+ for( i = 0; i < nCount; ++i )
+ SwWW8Writer::WriteLong( rStrm, aEndSortTab[ i ] );
+ SwWW8Writer::WriteLong( rStrm, rWrt.pFib->ccpText );
+ rWrt.pFib->lcbPlcfbkl = rStrm.Tell() - rWrt.pFib->fcPlcfbkl;
+ }
+}
+
+// JP 24.06.99: not used at time
+/*String WW8_WrtBookmarks::GetWWBkmkName( const String& rName ) const
+{
+ // replace all characters that will WinWord not understand
+ return rName;
+}
+*/
+
+USHORT WW8_WrtBookmarks::GetPos( const String& rNm )
+{
+ USHORT nRet = USHRT_MAX, n;
+ for( n = 0; n < aSttCps.Count(); ++n )
+ if( rNm == *aSwBkmkNms.GetObject( n ))
+ {
+ nRet = n;
+ break;
+ }
+ return nRet;
+}
+
+void SwWW8Writer::AppendBookmarks( const SwTxtNode& rNd,
+ xub_StrLen nAktPos, xub_StrLen nLen )
+{
+ SvPtrarr aArr( 8, 8 );
+ USHORT nCntnt;
+ xub_StrLen nAktEnd = nAktPos + nLen;
+ if( GetBookmarks( rNd, nAktPos, nAktEnd, aArr ))
+ {
+ ULONG nNd = rNd.GetIndex(), nSttCP = Fc2Cp( Strm().Tell() );
+ for( USHORT n = 0; n < aArr.Count(); ++n )
+ {
+ const SwBookmark& rBkmk = *(SwBookmark*)aArr[ n ];
+ const SwPosition* pPos = &rBkmk.GetPos(),
+ * pOPos = rBkmk.GetOtherPos();
+ if( pOPos && pOPos->nNode == pPos->nNode &&
+ pOPos->nContent < pPos->nContent )
+ {
+ pOPos = pPos;
+ pPos = rBkmk.GetOtherPos();
+ }
+
+ if( !pOPos || ( nNd == pPos->nNode.GetIndex() &&
+ ( nCntnt = pPos->nContent.GetIndex() ) >= nAktPos &&
+ nCntnt < nAktEnd ) )
+ {
+ ULONG nCp = nSttCP + pPos->nContent.GetIndex() - nAktPos;
+ pBkmks->Append( nCp, rBkmk.GetName() );
+ }
+ if( pOPos && nNd == pOPos->nNode.GetIndex() &&
+ ( nCntnt = pOPos->nContent.GetIndex() ) >= nAktPos &&
+ nCntnt < nAktEnd )
+ {
+ ULONG nCp = nSttCP + pOPos->nContent.GetIndex() - nAktPos;
+ pBkmks->Append( nCp, rBkmk.GetName() );
+ }
+ }
+ }
+}
+
+void SwWW8Writer::AppendBookmark( const String& rName, USHORT nOffset )
+{
+ ULONG nSttCP = Fc2Cp( Strm().Tell() ) + nOffset;
+ pBkmks->Append( nSttCP, rName );
+}
+
+
+//--------------------------------------------------------------------------
+/* */
+
+USHORT WW8_WrtRedlineAuthor::AddName( const String& rNm )
+{
+ for( USHORT n = 0, nCnt = aAuthors.Count(); n < nCnt; ++n )
+ if( *aAuthors[ n ] == rNm )
+ return n;
+
+ String* pNew = new String( rNm );
+ aAuthors.Insert( pNew, n );
+ return n;
+}
+
+void WW8_WrtRedlineAuthor::Write( SwWW8Writer& rWrt )
+{
+ rWrt.WriteAsStringTable( (SvStrings&)aAuthors,
+ rWrt.pFib->fcSttbfRMark,
+ rWrt.pFib->lcbSttbfRMark,
+ rWrt.bWrtWW8 ? 0 : 2 );
+}
+
+USHORT SwWW8Writer::AddRedlineAuthor( USHORT nId )
+{
+ if( !pRedlAuthors )
+ {
+ pRedlAuthors = new WW8_WrtRedlineAuthor;
+ pRedlAuthors->AddName( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "Unknown" )));
+ }
+ return pRedlAuthors->AddName( SW_MOD()->GetRedlineAuthor( nId ) );
+}
+
+//--------------------------------------------------------------------------
+/* */
+
+void SwWW8Writer::WriteAsStringTable( const SvStrings& rStrings,
+ INT32& rfcSttbf, INT32& rlcbSttbf,
+ USHORT nExtraLen )
+{
+ USHORT n, nCount = rStrings.Count();
+ if( nCount )
+ {
+ // we have some Redlines found in the document -> the
+ // Author Name Stringtable
+ SvStream& rStrm = bWrtWW8 ? *pTableStrm : Strm();
+ rfcSttbf = rStrm.Tell();
+ if( bWrtWW8 )
+ {
+ SwWW8Writer::WriteShort( rStrm, -1 );
+ SwWW8Writer::WriteLong( rStrm, nCount );
+ for( n = 0; n < nCount; ++n )
+ {
+ const String& rNm = *rStrings[ n ];
+ SwWW8Writer::WriteShort( rStrm, rNm.Len() );
+ SwWW8Writer::WriteString16( rStrm, rNm, FALSE );
+ if( nExtraLen )
+ SwWW8Writer::FillCount( rStrm, nExtraLen );
+ }
+ }
+ else
+ {
+ SwWW8Writer::WriteShort( rStrm, 0 );
+ for( n = 0; n < nCount; ++n )
+ {
+ const String aNm( rStrings[ n ]->Copy(0, 255 ));
+ rStrm << (BYTE)aNm.Len();
+ SwWW8Writer::WriteString8( rStrm, aNm, FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ if( nExtraLen )
+ SwWW8Writer::FillCount( rStrm, nExtraLen );
+ }
+ }
+ rlcbSttbf = rStrm.Tell() - rfcSttbf;
+ if( !bWrtWW8 )
+ SwWW8Writer::WriteShort( rStrm, rfcSttbf, (USHORT)rlcbSttbf );
+ }
+}
+
+// WriteShort() traegt an FilePos nPos den Wert nVal ein und seekt auf die
+// alte FilePos zurueck. Benutzt zum Nachtragen von Laengen.
+void SwWW8Writer::WriteShort( SvStream& rStrm, ULONG nPos, INT16 nVal )
+{
+ ULONG nOldPos = rStrm.Tell(); // Pos merken
+ rStrm.Seek( nPos );
+ SwWW8Writer::WriteShort( rStrm, nVal );
+ rStrm.Seek( nOldPos );
+}
+
+void SwWW8Writer::WriteLong( SvStream& rStrm, ULONG nPos, INT32 nVal )
+{
+ ULONG nOldPos = rStrm.Tell(); // Pos merken
+ rStrm.Seek( nPos );
+ SwWW8Writer::WriteLong( rStrm, nVal );
+ rStrm.Seek( nOldPos );
+}
+
+#ifdef __WW8_NEEDS_COPY
+
+void SwWW8Writer::InsUInt16( WW8Bytes& rO, UINT16 n )
+{
+ SVBT16 nL;
+ ShortToSVBT16( n, nL );
+ rO.Insert( nL, 2, rO.Count() );
+}
+void SwWW8Writer::InsUInt32( WW8Bytes& rO, UINT32 n )
+{
+ SVBT32 nL;
+ LongToSVBT32( n, nL );
+ rO.Insert( nL, 4, rO.Count() );
+}
+
+#else
+
+void SwWW8Writer::InsUInt16( WW8Bytes& rO, UINT16 n )
+{
+ rO.Insert( (BYTE*)&n, 2, rO.Count() );
+}
+void SwWW8Writer::InsUInt32( WW8Bytes& rO, UINT32 n )
+{
+ rO.Insert( (BYTE*)&n, 4, rO.Count() );
+}
+
+#endif // defined __WW8_NEEDS_COPY
+
+void SwWW8Writer::InsAsString16( WW8Bytes& rO, const String& rStr )
+{
+ for( const sal_Unicode* pStr = rStr.GetBuffer(); *pStr; ++pStr )
+ SwWW8Writer::InsUInt16( rO, *pStr );
+}
+
+void SwWW8Writer::InsAsString8( WW8Bytes& rO, const String& rStr,
+ rtl_TextEncoding eCodeSet )
+{
+ ByteString sTmp( rStr, eCodeSet );
+ rO.Insert( (BYTE*)sTmp.GetBuffer(), sTmp.Len(), rO.Count() );
+}
+
+void SwWW8Writer::WriteString16( SvStream& rStrm, const String& rStr,
+ BOOL bAddZero )
+{
+ WW8Bytes aBytes;
+ SwWW8Writer::InsAsString16( aBytes, rStr );
+ if( bAddZero )
+ SwWW8Writer::InsUInt16( aBytes, 0 );
+ rStrm.Write( aBytes.GetData(), aBytes.Count() );
+}
+
+void SwWW8Writer::WriteString8( SvStream& rStrm, const String& rStr,
+ BOOL bAddZero, rtl_TextEncoding eCodeSet )
+{
+ WW8Bytes aBytes;
+ SwWW8Writer::InsAsString8( aBytes, rStr, eCodeSet );
+ if( bAddZero )
+ aBytes.Insert( (BYTE)0, aBytes.Count() );
+ rStrm.Write( aBytes.GetData(), aBytes.Count() );
+}
+
+void SwWW8Writer::WriteStringAsPara( const String& rTxt, USHORT nStyleId )
+{
+ if( rTxt.Len() )
+ OutSwString( rTxt, 0, rTxt.Len(), IsUnicode(), RTL_TEXTENCODING_MS_1252 );
+ WriteCR(); // CR danach
+
+ WW8Bytes aArr( 10, 10 );
+ SwWW8Writer::InsUInt16( aArr, nStyleId );
+ if( bOutTable )
+ { // Tab-Attr
+ // sprmPFInTable
+ if( bWrtWW8 )
+ SwWW8Writer::InsUInt16( aArr, 0x2416 );
+ else
+ aArr.Insert( 24, aArr.Count() );
+ aArr.Insert( 1, aArr.Count() );
+ }
+
+ ULONG nPos = Strm().Tell();
+ pPapPlc->AppendFkpEntry( nPos, aArr.Count(), aArr.GetData() );
+ pChpPlc->AppendFkpEntry( nPos );
+}
+
+void SwWW8Writer::WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp )
+{
+ BYTE nOldTyp = nTxtTyp;
+ nTxtTyp = nTTyp;
+ SwPaM* pOldPam = pCurPam; //!! Einfaches Umsetzen des PaM ohne
+ SwPaM* pOldEnd = pOrigPam; // Wiederherstellen muesste es auch tun
+ BOOL bOldPageDescs = bOutPageDescs;
+ bOutPageDescs = FALSE;
+ // bOutKF wird in WriteKF1 gemerkt / gesetzt
+ pCurPam = NewSwPaM( *pDoc, nStart, nEnd );
+
+ // Tabelle in Sonderbereichen erkennen
+ if( (nStart != pCurPam->GetMark()->nNode.GetIndex())
+ && pDoc->GetNodes()[ nStart ]->IsTableNode() )
+ pCurPam->GetMark()->nNode = nStart;
+
+ pOrigPam = pCurPam;
+ pCurPam->Exchange();
+
+ WriteText();
+
+ delete pCurPam; // Pam wieder loeschen
+ bOutPageDescs = bOldPageDescs;
+ pCurPam = pOldPam;
+ pOrigPam = pOldEnd;
+ nTxtTyp = nOldTyp;
+}
+
+void SwWW8Writer::OutSwString( const String& rStr, xub_StrLen nStt,
+ xub_StrLen nLen, BOOL bUnicode,
+ rtl_TextEncoding eChrSet )
+
+{
+ if( nLen )
+ {
+ if ( bUnicode != pPiece->IsUnicode() )
+ pPiece->AppendPc ( Strm().Tell(), bUnicode );
+
+ if( nStt || nLen != rStr.Len() )
+ {
+ String sOut( rStr.Copy( nStt, nLen ) );
+ if( bUnicode )
+ SwWW8Writer::WriteString16( Strm(), sOut, FALSE );
+ else
+ SwWW8Writer::WriteString8( Strm(), sOut, FALSE, eChrSet );
+ }
+ else if( bUnicode )
+ SwWW8Writer::WriteString16( Strm(), rStr, FALSE );
+ else
+ SwWW8Writer::WriteString8( Strm(), rStr, FALSE, eChrSet );
+ }
+}
+
+void SwWW8Writer::WriteCR()
+{
+ WriteChar( '\015' );
+ pPiece->SetParaBreak();
+}
+
+void SwWW8Writer::WriteChar( sal_Unicode c )
+{
+ if( pPiece->IsUnicode() )
+ Strm() << c;
+ else
+ Strm() << (BYTE)c;
+}
+
+long SwWW8Writer::GetDTTM( const DateTime& rDT )
+{
+/*
+mint short :6 0000003F minutes (0-59)
+hr short :5 000007C0 hours (0-23)
+dom short :5 0000F800 days of month (1-31)
+mon short :4 000F0000 months (1-12)
+yr short :9 1FF00000 years (1900-2411)-1900
+wdy short :3 E0000000 weekday(Sunday=0
+ Monday=1
+( wdy can be ignored ) Tuesday=2
+ Wednesday=3
+ Thursday=4
+ Friday=5
+ Saturday=6)
+*/
+
+ long nDT = ( rDT.GetDayOfWeek() + 1 ) % 7;
+ nDT <<= 9;
+ nDT += ( rDT.GetYear() - 1900 ) & 0x1ff;
+ nDT <<= 4;
+ nDT += rDT.GetMonth() & 0xf;
+ nDT <<= 5;
+ nDT += rDT.GetDay() & 0x1f;
+ nDT <<= 5;
+ nDT += rDT.GetHour() & 0x1f;
+ nDT <<= 6;
+ nDT += rDT.GetMin() & 0x3f;
+ return nDT;
+}
+
+/* */
+//---------------------------------------------------------------------------
+// Hilfsroutinen fuer Flys
+//---------------------------------------------------------------------------
+// Struktur speichert die aktuellen Daten des Writers zwischen, um
+// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
+WW8SaveData::WW8SaveData( SwWW8Writer& rWriter, ULONG nStt, ULONG nEnd )
+ : rWrt( rWriter ),
+ pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ),
+ pOldFlyFmt( rWrt.pFlyFmt ), pOldPageDesc( rWrt.pAktPageDesc )
+
+{
+ pOldFlyOffset = rWrt.pFlyOffset;
+ if( rWrt.pO->Count() )
+ {
+ pOOld = rWrt.pO;
+ rWrt.pO = new WW8Bytes( 128, 128 );
+ }
+ else
+ pOOld = 0;
+ bOldWriteAll = rWrt.bWriteAll;
+ bOldOutTable = rWrt.bOutTable;
+ bOldIsInTable= rWrt.bIsInTable;
+ bOldFlyFrmAttrs = rWrt.bOutFlyFrmAttrs;
+ bOldStartTOX = rWrt.bStartTOX;
+ bOldInWriteTOX = rWrt.bInWriteTOX;
+
+ rWrt.pCurPam = rWrt.NewSwPaM( *rWrt.pDoc, nStt, nEnd );
+
+ // Tabelle in Sonderbereichen erkennen
+ if( nStt != rWrt.pCurPam->GetMark()->nNode.GetIndex() &&
+ rWrt.pDoc->GetNodes()[ nStt ]->IsTableNode() )
+ rWrt.pCurPam->GetMark()->nNode = nStt;
+
+ rWrt.SetEndPaM( rWrt.pCurPam );
+ rWrt.pCurPam->Exchange( );
+ rWrt.bWriteAll = TRUE;
+ rWrt.bOutTable = FALSE;
+ // Vorsicht: rWrt.bIsInTable darf hier NICHT veraendert werden!
+ rWrt.bOutFlyFrmAttrs = FALSE;
+// rWrt.pAttrSet = 0;
+ rWrt.bStartTOX = FALSE;
+ rWrt.bInWriteTOX = FALSE;
+}
+
+
+WW8SaveData::~WW8SaveData()
+{
+ delete rWrt.pCurPam; // Pam wieder loeschen
+
+ rWrt.pCurPam = pOldPam;
+ rWrt.SetEndPaM( pOldEnd );
+ rWrt.bWriteAll = bOldWriteAll;
+ rWrt.bOutTable = bOldOutTable;
+ rWrt.bIsInTable= bOldIsInTable;
+ rWrt.bOutFlyFrmAttrs = bOldFlyFrmAttrs;
+ rWrt.bStartTOX = bOldStartTOX;
+ rWrt.bInWriteTOX = bOldInWriteTOX;
+ rWrt.pFlyFmt = pOldFlyFmt;
+ rWrt.pAktPageDesc = pOldPageDesc;
+// rWrt.pAttrSet = pOldAttrSet;
+ ASSERT( !rWrt.pO->Count(), " pO ist am Ende von WW8SaveData nicht leer" );
+ if( pOOld )
+ {
+ delete rWrt.pO;
+ rWrt.pO = pOOld;
+ }
+ rWrt.pFlyOffset = pOldFlyOffset;
+}
+
+
+void SwWW8Writer::WriteText()
+{
+ while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode ||
+ (pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode &&
+ pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
+ {
+ SwNode * pNd = pCurPam->GetNode();
+
+ if( pNd->IsTxtNode() ) // blitzschnelle Methode
+ {
+ const SwTxtNode* pTxtNode = pNd->GetTxtNode();
+ if( pTxtNode->GetpSwAttrSet() )
+ Out_SfxBreakItems( *pTxtNode->GetpSwAttrSet(), *pTxtNode );
+ if( !bIsInTable )
+ OutWW8FlyFrmsInCntnt( *pTxtNode ); // als Zeichen gebundene Flys
+ }
+
+ if( pNd->IsCntntNode() )
+ {
+ SwCntntNode* pCNd = (SwCntntNode*)pNd;
+
+ // erfrage den aktuellen PageDescriptor.
+ if( !bInWriteEscher )
+ OutFlyFrms( *pCNd );
+
+ const SwPageDesc* pTemp = pCNd->GetSwAttrSet().GetPageDesc().GetPageDesc();
+ if( pTemp )
+ pAktPageDesc = pTemp;
+
+ pCurPam->GetPoint()->nContent.Assign( pCNd, 0 );
+ Out( aWW8NodeFnTab, *pCNd, *this );
+ }
+ else if( pNd->IsTableNode() && !bIsInTable )
+ OutWW8_SwTblNode( *this, *(SwTableNode*)pNd );
+ else if( pNd->IsSectionNode() && TXT_MAINTEXT == nTxtTyp )
+ OutWW8_SwSectionNode( *this, *pNd->GetSectionNode() );
+ else if( TXT_MAINTEXT == nTxtTyp && pNd->IsEndNode() &&
+ pNd->FindStartNode()->IsSectionNode() )
+ {
+ const SwSection& rSect = pNd->FindStartNode()->GetSectionNode()
+ ->GetSection();
+ if( bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() )
+ bStartTOX = FALSE;
+
+ SwNodeIndex aIdx( *pNd, 1 );
+ if( aIdx.GetNode().IsEndNode()
+ && aIdx.GetNode().FindStartNode()->IsSectionNode() )
+ ;
+ else
+ if( aIdx.GetNode().IsSectionNode() )
+ ;
+ else
+ {
+ ReplaceCr( (char)0xc ); // Indikator fuer Page/Section-Break
+
+ const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent();
+ if( !pParentFmt )
+ pParentFmt = (SwSectionFmt*)0xFFFFFFFF;
+
+ ULONG nRstLnNum;
+ if( aIdx.GetNode().IsCntntNode() )
+ nRstLnNum = ((SwCntntNode&)aIdx.GetNode()).GetSwAttrSet().
+ GetLineNumber().GetStartValue();
+ else
+ nRstLnNum = 0;
+
+ pSepx->AppendSep( Fc2Cp( Strm().Tell() ),
+ pAktPageDesc, pParentFmt, nRstLnNum );
+ }
+ }
+ else if( pNd == &pNd->GetNodes().GetEndOfContent() )
+ break;
+
+ ULONG nPos = pCurPam->GetPoint()->nNode++; // Bewegen
+ ::SetProgressState( nPos, pCurPam->GetDoc()->GetDocShell() ); // Wie weit ?
+ }
+}
+
+void SwWW8Writer::WriteMainText()
+{
+ pFib->fcMin = Strm().Tell();
+
+ do {
+ WriteText();
+ } while( FALSE ); //!! Temporaer nur 1 Bereich
+// } while( CopyNextPam( &pCurPam ) ); // bis alle Pam bearbeitet
+
+ if( 0 == Strm().Tell() - pFib->fcMin ) // kein Text ?
+ WriteCR(); // dann CR ans Ende ( sonst mault WW )
+
+ pFib->ccpText = Fc2Cp( Strm().Tell() );
+ pFldMain->Finish( pFib->ccpText, 0 );
+
+ // ccpText beinhaltet Ftn- und KF-Texte
+ // deshalb wird pFib->ccpText evtl. noch geupdated
+ // save the StyleId of the last paragraph. Because WW97 take the style
+ // from the last CR, that will be write after footer/Header/fontnotes/
+ // annotation usw.
+ const SwTxtNode* pLastNd = pCurPam->GetMark()->nNode.GetNode().GetTxtNode();
+ if( pLastNd )
+ nLastFmtId = GetId( (SwTxtFmtColl&)pLastNd->GetAnyFmtColl() );
+}
+
+void SwWW8Writer::WriteFkpPlcUsw()
+{
+ if( !bWrtWW8 )
+ {
+ static BYTE __READONLY_DATA aSpec[2] = { 117, 1 };
+
+ pChpPlc->AppendFkpEntry( Strm().Tell() ); // Sepx mit fSpecial
+ pSepx->WriteSepx( Strm() ); // Slcx.Sepx
+ pGrf->Write(); // Grafiken
+ pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec ), aSpec );
+
+ pChpPlc->WriteFkps(); // Fkp.Chpx
+ pPapPlc->WriteFkps(); // Fkp.Papx
+ pStyles->OutStyleTab(); // Styles
+ pFtn->WritePlc( *this ); // Footnote-Ref & Text Plc
+ pEdn->WritePlc( *this ); // Endnote-Ref & Text Plc
+ pAtn->WritePlc( *this ); // Annotation-Ref & Text Plc
+ pSepx->WritePlcSed( *this ); // Slcx.PlcSed
+ pSepx->WritePlcHdd( *this ); // Slcx.PlcHdd
+ pChpPlc->WritePlc(); // Plcx.Chpx
+ pPapPlc->WritePlc(); // Plcx.Papx
+ OutFontTab( *pFib ); // FFNs
+ if( pRedlAuthors )
+ pRedlAuthors->Write( *this ); // sttbfRMark (RedlineAuthors)
+ pFldMain->Write( *this ); // Fields ( Main Text )
+ pFldHdFt->Write( *this ); // Fields ( Header/Footer )
+ pFldFtn->Write( *this ); // Fields ( FootNotes )
+ pFldEdn->Write( *this ); // Fields ( EndNotes )
+ pBkmks->Write( *this ); // Bookmarks - sttbfBkmk/
+ // plcfBkmkf/plcfBkmkl
+ WriteDop( *this ); // Document-Properties
+
+ }
+ else
+ {
+ // Grafiken in den Data-Tream
+//??? static BYTE __READONLY_DATA aSpec[] = { 0x55,0x08,0x01 };
+//??? pChpPlc->AppendFkpEntry( pDataStrm->Tell() ); // Sepx mit fSpecial
+
+ pGrf->Write(); // Grafiken
+//??? pChpPlc->AppendFkpEntry( pDataStrm->Tell(), sizeof( aSpec ), aSpec );
+
+ // Ausgabe in WordDocument-Stream
+ pChpPlc->WriteFkps(); // Fkp.Chpx
+ pPapPlc->WriteFkps(); // Fkp.Papx
+ pSepx->WriteSepx( Strm() ); // Sepx
+
+ // Ausagbe in Table-Stream
+ pStyles->OutStyleTab(); // fuer WW8 StyleTab
+ pFtn->WritePlc( *this ); // Footnote-Ref & Text Plc
+ pEdn->WritePlc( *this ); // Endnote-Ref & Text Plc
+ pTxtBxs->WritePlc( *this ); // Textbox Text Plc
+ pHFTxtBxs->WritePlc( *this ); // Head/Foot-Textbox Text Plc
+ pAtn->WritePlc( *this ); // Annotation-Ref & Text Plc
+
+ pSepx->WritePlcSed( *this ); // Slcx.PlcSed
+ pSepx->WritePlcHdd( *this ); // Slcx.PlcHdd
+
+ pChpPlc->WritePlc(); // Plcx.Chpx
+ pPapPlc->WritePlc(); // Plcx.Papx
+
+ if( pRedlAuthors )
+ pRedlAuthors->Write( *this ); // sttbfRMark (RedlineAuthors)
+ pFldMain->Write( *this ); // Fields ( Main Text )
+ pFldHdFt->Write( *this ); // Fields ( Header/Footer )
+ pFldFtn->Write( *this ); // Fields ( FootNotes )
+ pFldEdn->Write( *this ); // Fields ( EndNotes )
+ pFldTxtBxs->Write( *this ); // Fields ( Textboxes )
+ pFldHFTxtBxs->Write( *this ); // Fields ( Head/Foot-Textboxes )
+
+ // dggInfo - escher stream
+ WriteEscher();
+
+ pSdrObjs->WritePlc( *this );
+ pHFSdrObjs->WritePlc( *this );
+ // spamom - office drawing table
+ // spahdr - header office drawing table
+
+ pBkmks->Write( *this ); // Bookmarks - sttbfBkmk/
+ // plcfBkmkf/plcfBkmkl
+
+ OutListTab(); // listformats - LSTF
+ OutOverrideListTab(); // - "" - - LFO
+ OutListNamesTab(); // - "" - - ListNames
+
+ pPiece->WritePc( *this ); // Piece-Table
+ OutFontTab( *pFib ); // FFNs
+ WriteDop( *this ); // Document-Properties
+ }
+ Strm().Seek( 0 );
+
+ pFib->Write( Strm() ); // FIB
+}
+
+void SwWW8Writer::StoreDoc1()
+{
+ // Start of Text ( Mangel ueber )
+ SwWW8Writer::FillUntil( Strm(), pFib->fcMin );
+
+ WriteMainText(); // HauptText
+ pFtn->WriteTxt( *this ); // Footnote-Text
+ pSepx->WriteKFTxt( *this ); // K/F-Text
+ pAtn->WriteTxt( *this ); // Annotation-Text
+ pEdn->WriteTxt( *this ); // EndNote-Text
+
+ // create the escher streams
+ if( bWrtWW8 )
+ CreateEscher();
+
+ pTxtBxs->WriteTxt( *this ); // Textbox Text Plc
+ pHFTxtBxs->WriteTxt( *this ); // Head/Foot-Textbox Text Plc
+
+ WriteStringAsPara( aEmptyStr, nLastFmtId ); // CR ans Ende ( sonst mault WW )
+
+ pSepx->Finish( Fc2Cp( Strm().Tell() ));// Text + Ftn + HdFt als Section-Ende
+
+ pFib->fcMac = Strm().Tell(); // Ende aller Texte
+
+ WriteFkpPlcUsw(); // FKP, PLC, .....
+}
+
+ULONG SwWW8Writer::StoreDoc()
+{
+ nIniFlags = ReadFilterFlags( "WWWR" );
+ nCharFmtStart = ANZ_DEFAULT_STYLES;
+ nFmtCollStart = nCharFmtStart + pDoc->GetCharFmts()->Count() - 1;
+
+ bStyDef = bBreakBefore = bOutKF =
+ bOutFlyFrmAttrs = bOutPageDescs = bOutTable = bOutFirstPage =
+ bIsInTable = bOutGrf = bInWriteEscher = bStartTOX =
+ bInWriteTOX = FALSE;
+
+ bFtnAtTxtEnd = bEndAtTxtEnd = TRUE;
+
+ pFlyFmt = 0;
+ pFlyOffset = 0;
+ nTxtTyp = TXT_MAINTEXT;
+ nFlyWidth = nFlyHeight = 0;
+ nStyleBeforeFly = nLastFmtId = 0;
+ pStyAttr = 0;
+ pOutFmtNode = 0;
+ pUsedNumTbl = 0;
+ pEscher = 0;
+ pRedlAuthors = 0;
+ if( aTOXArr.Count() )
+ aTOXArr.Remove( 0, aTOXArr.Count() );
+
+#if SUPD>593
+ if( !pOLEExp )
+ {
+ UINT32 nSvxMSDffOLEConvFlags = 0;
+ const OfaFilterOptions* pOpt = OFF_APP()->GetFilterOptions();
+ if( pOpt->IsStarMath2MathType() )
+ nSvxMSDffOLEConvFlags |= OLE_STARMATH_2_MATHTYPE;
+ if( pOpt->IsStarWriter2WinWord() )
+ nSvxMSDffOLEConvFlags |= OLE_STARWRITER_2_WINWORD;
+ if( pOpt->IsStarCalc2Excel() )
+ nSvxMSDffOLEConvFlags |= OLE_STARCALC_2_EXCEL;
+ if( pOpt->IsStarImpress2PowerPoint() )
+ nSvxMSDffOLEConvFlags |= OLE_STARIMPRESS_2_POWERPOINT;
+
+ pOLEExp = new SvxMSExportOLEObjects( nSvxMSDffOLEConvFlags );
+ }
+#endif
+
+ PrepareStorage();
+
+ PutNumFmtFontsInAttrPool();
+ PutEditEngFontsInAttrPool();
+
+ pFib = new WW8Fib( bWrtWW8 ? 8 : 6 );
+
+ SvStream* pOldStrm = pStrm; // JP 19.05.99: wozu das ???
+ SvStorageStreamRef xWwStrm( pStg->OpenStream( aMainStg ) );
+ SvStorageStreamRef xTableStrm( xWwStrm ), xDataStrm( xWwStrm );
+ xWwStrm->SetBufferSize( 32768 );
+
+ if( bWrtWW8 )
+ {
+ pFib->fWhichTblStm = 1;
+ xTableStrm = pStg->OpenStream( sTableStream, STREAM_STD_WRITE );
+ xDataStrm = pStg->OpenStream( sDataStream, STREAM_STD_WRITE );
+
+ xDataStrm->SetBufferSize( 32768 ); // fuer Grafiken
+ xTableStrm->SetBufferSize( 16384 ); // fuer die Font-/Style-Table, usw.
+
+ xTableStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ xDataStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ }
+
+ pStrm = &xWwStrm;
+ pTableStrm = &xTableStrm;
+ pDataStrm = &xDataStrm;
+
+ pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ pAktPageDesc = &pDoc->GetPageDesc( 0 ); // Default: "Standard"
+ pSepx = new WW8_WrPlcSepx; // Sepx
+ {
+ const SfxPoolItem* pI;
+ const SwNode* pNd = pCurPam->GetCntntNode();
+ const SfxItemSet* pSet = pNd ? &((SwCntntNode*)pNd)->GetSwAttrSet()
+ : 0;
+
+ ULONG nRstLnNum = pSet ? ((SwFmtLineNumber&)pSet->Get(
+ RES_LINENUMBER )).GetStartValue()
+ : 0;
+
+ const SwTableNode* pTblNd = pCurPam->GetNode()->FindTableNode();
+ const SwSectionNode* pSectNd;
+ if( pTblNd )
+ {
+ pSet = &pTblNd->GetTable().GetFrmFmt()->GetAttrSet();
+ pNd = pTblNd;
+ }
+ else if( 0 != ( pSectNd = pNd->FindSectionNode() ) )
+ {
+ if( TOX_HEADER_SECTION == pSectNd->GetSection().GetType() &&
+ pSectNd->FindStartNode()->IsSectionNode() )
+ pSectNd = pSectNd->FindStartNode()->GetSectionNode();
+
+ if( TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() )
+ {
+ pNd = pSectNd;
+ pCurPam->GetPoint()->nNode = *pNd;
+ }
+ }
+
+ // Hole evtl. Pagedesc des 1. Nodes
+ if( pSet && SFX_ITEM_ON == pSet->GetItemState(RES_PAGEDESC,TRUE,&pI)
+ && ((SwFmtPageDesc*)pI)->GetPageDesc() )
+ pSepx->AppendSep( 0, *(SwFmtPageDesc*)pI, *pNd, nRstLnNum );
+ else
+ pSepx->AppendSep( 0, pAktPageDesc, 0, nRstLnNum );
+ }
+
+ pFtn = new WW8_WrPlcFtnEdn( TXT_FTN ); // Ftn
+ pEdn = new WW8_WrPlcFtnEdn( TXT_EDN ); // Edn
+ pAtn = new WW8_WrPlcPostIt; // PostIts
+ pTxtBxs = new WW8_WrPlcTxtBoxes( TXT_TXTBOX );
+ pHFTxtBxs = new WW8_WrPlcTxtBoxes( TXT_HFTXTBOX );
+
+ pSdrObjs = new WW8_WrPlcDrawObj( TXT_TXTBOX ); // Draw-/Fly-Objects
+ pHFSdrObjs = new WW8_WrPlcDrawObj( TXT_HFTXTBOX ); // Draw-/Fly-Objects
+ // in header or footer
+
+ pBkmks = new WW8_WrtBookmarks; // Bookmarks
+ CreateBookmarkTbl();
+
+ pPapPlc = new WW8_WrPlcPn( *this, PAP, pFib->fcMin );
+ pChpPlc = new WW8_WrPlcPn( *this, CHP, pFib->fcMin );
+ pO = new WW8Bytes( 128, 128 );
+ pStyles = new WW8WrtStyle( *this );
+ pFldMain = new WW8_WrPlcFld( 2, TXT_MAINTEXT );
+ pFldHdFt = new WW8_WrPlcFld( 2, TXT_HDFT );
+ pFldFtn = new WW8_WrPlcFld( 2, TXT_FTN );
+ pFldEdn = new WW8_WrPlcFld( 2, TXT_EDN );
+ pFldTxtBxs = new WW8_WrPlcFld( 2, TXT_TXTBOX );
+ pFldHFTxtBxs = new WW8_WrPlcFld( 2, TXT_HFTXTBOX );
+
+ pGrf = new SwWW8WrGrf( *this );
+ pPiece = new WW8_WrPct( pFib->fcMin );
+ pDop = new WW8Dop;
+
+ USHORT nRedlineMode = pDoc->GetRedlineMode();
+ pDop->fRevMarking = 0 != (REDLINE_ON & nRedlineMode);
+ pDop->fRMView = 0 != ( REDLINE_SHOW_DELETE & nRedlineMode );
+ if( pDoc->GetRedlineTbl().Count() )
+ pDoc->SetRedlineMode( nRedlineMode | REDLINE_SHOW_DELETE |
+ REDLINE_SHOW_INSERT );
+
+ // set AutoHyphenation flag if found in default para style
+ const SfxPoolItem* pItem;
+ SwTxtFmtColl* pStdTxtFmtColl = pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ if( pStdTxtFmtColl
+ && SFX_ITEM_SET == pStdTxtFmtColl->GetItemState(
+ RES_PARATR_HYPHENZONE, FALSE, &pItem ) )
+ pDop->fAutoHyphen = ((SvxHyphenZoneItem*)pItem)->IsHyphen();
+
+ // make unique OrdNums (Z-Order) for all drawing-/fly Objects
+ if( pDoc->GetDrawModel() )
+ pDoc->GetDrawModel()->GetPage( 0 )->RecalcObjOrdNums();
+
+ StoreDoc1();
+
+ if( nRedlineMode != pDoc->GetRedlineMode() )
+ pDoc->SetRedlineMode( nRedlineMode );
+
+ if( pUsedNumTbl ) // all used NumRules
+ {
+ // clear array - it's an auto delete array
+ pUsedNumTbl->Remove( 0, pUsedNumTbl->Count() );
+ delete pUsedNumTbl;
+ }
+
+ DELETEZ( pGrf );
+ DELETEZ( pFldFtn );
+ DELETEZ( pFldTxtBxs );
+ DELETEZ( pFldHFTxtBxs );
+ DELETEZ( pFldEdn );
+ DELETEZ( pFldHdFt );
+ DELETEZ( pFldMain );
+ DELETEZ( pStyles );
+ DELETEZ( pO );
+ DELETEZ( pChpPlc );
+ DELETEZ( pPapPlc );
+ DELETEZ( pSepx );
+
+ delete pRedlAuthors;
+ delete pSdrObjs;
+ delete pHFSdrObjs;
+ delete pTxtBxs;
+ delete pHFTxtBxs;
+ delete pAtn;
+ delete pEdn;
+ delete pFtn;
+ delete pBkmks;
+ delete pPiece;
+ delete pDop;
+ delete pFib;
+ pStrm = pOldStrm;
+
+
+ xWwStrm->SetBufferSize( 0 );
+ if( bWrtWW8 )
+ {
+ xTableStrm->SetBufferSize( 0 );
+ xDataStrm->SetBufferSize( 0 );
+ if( 0 == pDataStrm->Seek( STREAM_SEEK_TO_END ))
+ {
+ xDataStrm.Clear();
+ pDataStrm = 0;
+ pStg->Remove( sDataStream );
+ }
+ }
+
+ return 0;
+}
+
+
+void SwWW8Writer::PrepareStorage()
+{
+ ULONG nLen;
+ const BYTE* pData;
+ const char* pName;
+ UINT32 nId1;
+
+ if( bWrtWW8 )
+ {
+ static char __READONLY_DATA aUserName[] = "Microsoft Word-Document";
+ static BYTE __READONLY_DATA aCompObj[] = {
+ 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0x09, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x46, 0x18, 0x00, 0x00, 0x00,
+ 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
+ 0x74, 0x20, 0x57, 0x6F, 0x72, 0x64, 0x2D, 0x44,
+ 0x6F, 0x6B, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x00,
+ 0x0A, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x57, 0x6F,
+ 0x72, 0x64, 0x44, 0x6F, 0x63, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x57, 0x6F, 0x72, 0x64, 0x2E, 0x44,
+ 0x6F, 0x63, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x2E,
+ 0x38, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+
+ pName = aUserName;
+ pData = aCompObj;
+ nLen = sizeof( aCompObj );
+ nId1 = 0x00020906L;
+ }
+ else
+ {
+ static char __READONLY_DATA aUserName[] = "Microsoft Word 6.0 Document";
+ static BYTE __READONLY_DATA aCompObj[] = {
+ 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x09, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x46, 0x1C, 0x00, 0x00, 0x00,
+ 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
+ 0x74, 0x20, 0x57, 0x6F, 0x72, 0x64, 0x20, 0x36,
+ 0x2E, 0x30, 0x2D, 0x44, 0x6F, 0x6B, 0x75, 0x6D,
+ 0x65, 0x6E, 0x74, 0x00, 0x0A, 0x00, 0x00, 0x00,
+ 0x4D, 0x53, 0x57, 0x6F, 0x72, 0x64, 0x44, 0x6F,
+ 0x63, 0x00, 0x10, 0x00, 0x00, 0x00, 0x57, 0x6F,
+ 0x72, 0x64, 0x2E, 0x44, 0x6F, 0x63, 0x75, 0x6D,
+ 0x65, 0x6E, 0x74, 0x2E, 0x36, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+
+ pName = aUserName;
+ pData = aCompObj;
+ nLen = sizeof( aCompObj );
+ nId1 = 0x00020900L;
+ }
+
+ SvGlobalName aGName( nId1, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x46 );
+ pStg->SetClass( aGName, 0, String::CreateFromAscii( pName ));
+ SvStorageStreamRef xStor( pStg->OpenStream( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "\1CompObj" ))));
+ xStor->Write( pData, nLen );
+ // noch mal ueberplaetten, um auch Clipboardformat zu setzen
+ pDoc->GetInfo()->SavePropertySet( pStg ); // DocInfo
+}
+
+
+ULONG SwWW8Writer::WriteStorage()
+{
+ long nMaxNode = pDoc->GetNodes().Count();
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, pDoc->GetDocShell() );
+
+ // Tabelle am Doc.-Anfang beachten
+ {
+ SwTableNode * pTNd = pCurPam->GetNode()->FindTableNode();
+ if( pTNd && bWriteAll )
+ // mit dem TabellenNode anfangen !!
+ pCurPam->GetPoint()->nNode = *pTNd;
+ }
+
+ // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn
+ // das gesamte Dokument geschrieben wird
+ nAktFlyPos = 0;
+ SwPosFlyFrms aFlyPos;
+ pDoc->GetAllFlyFmts( aFlyPos, bWriteAll ? 0 : pOrigPam, bWrtWW8 );
+ // Die Sonderbehandlung fuer Teilausgabe fehlt noch ( siehe RTF )
+ pFlyPos = &aFlyPos;
+
+ ULONG nRet = StoreDoc();
+
+ // loesche die Tabelle mit den freifliegenden Rahmen
+ for( USHORT i = aFlyPos.Count(); i > 0; )
+ delete aFlyPos[ --i ];
+
+ ::EndProgress( pDoc->GetDocShell() );
+ bWrtWW8 = FALSE; // sicherheitshalber: Default fuer's naechste Mal
+ return nRet;
+}
+
+SwWW8Writer::SwWW8Writer( const String& rFltName )
+ : pChpIter( 0 ), aMainStg( sMainStream ), pPapPlc( 0 ), pChpPlc( 0 ),
+ pO( 0 ), pAktPageDesc( 0 ), pISet( 0 ), pUsedNumTbl( 0 ), pBmpPal( 0 ),
+ pKeyMap( 0 )
+#if SUPD>593
+ , pOLEExp( 0 )
+#endif
+{
+ bWrtWW8 = rFltName.EqualsAscii( FILTER_WW8 );
+}
+
+SwWW8Writer::~SwWW8Writer()
+{
+ if( pBmpPal )
+ delete pBmpPal;
+ if( pKeyMap )
+ {
+ NfKeywordTable* pDel = (NfKeywordTable*)pKeyMap;
+ delete [] pDel;
+ }
+#if SUPD>593
+ if( pOLEExp )
+ delete pOLEExp;
+#endif
+}
+
+void GetWW8Writer( const String& rFltName, WriterRef& xRet )
+{
+ xRet = new SwWW8Writer( rFltName );
+}
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/wrtww8.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.54 2000/09/18 16:04:58 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.53 2000/08/21 10:14:06 khz
+ Export Line Numbering (restart on new section)
+
+ Revision 1.52 2000/07/25 15:16:21 khz
+ #76811# read/write AutoHyphenation flag from/into Document Properties
+
+ Revision 1.51 2000/07/06 15:55:55 khz
+ Document Statistics
+
+ Revision 1.50 2000/07/05 16:07:30 jp
+ new MS Filteroptions - change StarOffice Objects to OLE-Objects
+
+ Revision 1.49 2000/05/15 16:40:34 jp
+ Changes for Unicode
+
+ Revision 1.48 2000/05/12 16:14:07 jp
+ Changes for Unicode
+
+ Revision 1.47 2000/03/28 18:47:53 jp
+ Bug #74360#: WrFkp::Append - calculate the correct offset for W95
+
+ Revision 1.46 2000/03/09 09:23:04 jp
+ Bug #74053#: write sectionbreaks only in maintext
+
+ Revision 1.45 2000/03/03 16:08:37 pl
+ #73771# workaround for c50 intel compiler
+
+ Revision 1.44 2000/03/01 14:21:03 jp
+ Bug #73720#: StoreDoc1 - search the TOX content section
+
+ Revision 1.43 2000/02/11 14:39:55 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.42 1999/12/20 17:41:33 jp
+ Bug #70749#: Date/Time-Numberformats in german format from the formatter
+
+ Revision 1.41 1999/12/15 17:06:18 jp
+ Bug #70913#: write Ftn-/EndNoteInfo - at end of section or page/doc
+
+ Revision 1.40 1999/12/13 13:56:06 jp
+ Bug #70766#: StoreDoc - look for TOX at start of Document
+
+ Revision 1.39 1999/11/25 21:22:29 jp
+ Bug #70131#: OutFields: append the charattributes of the node to the sprms
+
+ Revision 1.38 1999/11/22 18:26:07 jp
+ export of TOX and TOX entries
+
+ Revision 1.37 1999/11/12 13:06:17 jp
+ write correct PAP-Fkps for Version 8
+
+ Revision 1.36 1999/11/02 09:44:13 jp
+ write sprmPHugePapx
+
+ Revision 1.35 1999/10/29 17:40:18 jp
+ export of 'complex'(vert. merged) tables
+
+ Revision 1.34 1999/10/14 21:06:09 jp
+ Bug #68617#,#68705# and other little things
+
+ Revision 1.33 1999/10/14 11:09:20 jp
+ export Redlines into W95/W97
+
+ Revision 1.32 1999/10/13 18:09:45 jp
+ write redlines
+
+ Revision 1.31 1999/10/13 09:08:51 jp
+ write character attributs of SdrObjects
+
+ Revision 1.30 1999/10/11 11:00:14 jp
+ some changes for export EditEngine text in WW-Format
+
+ Revision 1.29 1999/10/04 16:44:40 jp
+ Bug #68679#: check content range of bookmarkpos
+
+ Revision 1.28 1999/09/08 16:29:21 jp
+ Bug #68618#: recognize the write of escher stream
+
+ Revision 1.27 1999/08/31 07:51:34 JP
+ set NumberFormatInt at streams to littleendian
+
+
+ Rev 1.26 31 Aug 1999 09:51:34 JP
+ set NumberFormatInt at streams to littleendian
+
+ Rev 1.25 24 Aug 1999 20:15:50 JP
+ Escher Export
+
+ Rev 1.24 16 Aug 1999 17:16:28 JP
+ W97 Export: experimental escher export (1)
+
+ Rev 1.23 16 Aug 1999 13:05:44 JP
+ write EscherObjects - only a testversion!
+
+ Rev 1.22 21 Jul 1999 18:28:24 JP
+ W97 Export: experimental escher export
+
+ Rev 1.21 06 Jul 1999 14:54:00 JP
+ W97-Export corrections
+
+ Rev 1.20 30 Jun 1999 19:56:42 JP
+ W97-Export: Fields/PostIts/References
+
+ Rev 1.19 24 Jun 1999 22:52:18 JP
+ Export of Bookmarks and Hyperlinks
+
+ Rev 1.18 23 Jun 1999 20:14:40 JP
+ W97-Export: write Bookmarks
+
+ Rev 1.17 23 Jun 1999 12:46:16 JP
+ Export of numbers und outlinenumbers
+
+ Rev 1.16 16 Jun 1999 19:55:20 JP
+ Change interface of base class Writer, Export of W97 NumRules
+
+ Rev 1.15 04 Jun 1999 17:47:52 JP
+ WW97-Export: Code aufgeteilt
+
+ Rev 1.14 03 Jun 1999 21:04:10 JP
+ Export von Seitenvorlagen verbessert: Abstaende/Umrandung/ErsteSeite/...
+
+ Rev 1.13 02 Jun 1999 18:45:40 JP
+ WinWord-Export um Kopf-/Fusszeilen erweitert
+
+ Rev 1.12 31 May 1999 23:14:24 JP
+ Erweiterungen/Umstellungen fuer Export
+
+ Rev 1.11 31 May 1999 18:54:34 JP
+ Bug #66446#,#66457#: Asserts entfernt
+
+ Rev 1.10 28 May 1999 17:09:06 MPA
+ WinWord97 Export
+
+ Rev 1.9 27 May 1999 23:45:06 JP
+ PiceTable eingebaut, Schnittstellen angepasst, usw.
+
+ Rev 1.8 26 May 1999 16:44:28 MPA
+ Anfaenge Piece-Table
+
+ Rev 1.7 26 May 1999 09:39:30 JP
+ OutStyleTab entfernt, OutFontTab mit Fib-Ref, WritePlc ohne Flag
+
+ Rev 1.6 25 May 1999 17:00:10 MPA
+ Anpassung PAPX/CHPX WW97
+
+ Rev 1.5 21 May 1999 19:20:00 JP
+ kleinere Korrekturen
+
+ Rev 1.4 21 May 1999 17:01:00 MPA
+ Anf,nge WW97
+
+ Rev 1.3 21 May 1999 10:51:52 MPA
+ SwAttrItr:CTor von Pointer nach Ref
+
+ Rev 1.2 21 May 1999 02:00:50 JP
+ Export von WW97 Format: allgemeine Methoden und FontTabelle
+
+ Rev 1.1 19 May 1999 19:34:16 JP
+ WinWord97-ExportFilter
+
+ Rev 1.0 19 May 1999 11:20:02 JP
+ WinWord97-ExportFilter
+
+*************************************************************************/
+
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
new file mode 100644
index 000000000000..7eab24f3d5b6
--- /dev/null
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -0,0 +1,815 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtww8.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _WRTWW8_HXX
+#define _WRTWW8_HXX
+
+#ifndef _SOLAR_H
+#include <tools/solar.h> // UINTXX
+#endif
+#ifndef _SV_GEN_HXX //autogen
+#include <tools/gen.hxx>
+#endif
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_ULONGS
+#define _SVSTDARR_STRINGS
+#define _SVSTDARR_STRINGSDTOR
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef WRT_FN_HXX
+#include <wrt_fn.hxx>
+#endif
+#ifndef WW8STRUC_HXX
+#include <ww8struc.hxx>
+#endif
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+
+
+// einige Forward Deklarationen
+class BitmapPalette;
+class Brush; //JP 04.06.99: die Brush obsolete!!
+class SwEscherEx;
+class DateTime;
+class Font;
+class SdrObject;
+class SfxItemSet;
+class SvStream;
+class SvxBorderLine;
+class SvxFontItem;
+class SvxBoxItem;
+class SwAttrSet;
+class SwBookmark;
+class SwCharFmt;
+class SwCntntNode;
+class SwField;
+class SwFlyFrmFmt;
+class SwFmt;
+class SwFmtCntnt;
+class SwFmtFtn;
+class SwFmtINetFmt;
+class SwFmtRefMark;
+class SwFrmFmt;
+class SwGrfNode;
+class SwModify;
+class SwNodeNum;
+class SwNoTxtNode;
+class SwNumFmt;
+class SwNumRule;
+class SwNumRuleTbl;
+class SwPageDesc;
+class SwFmtPageDesc;
+class SwpHints;
+class SwOLENode;
+class SwPosFlyFrms;
+class SwPostItField;
+class SwRedlineData;
+class SwSection;
+class SwSectionFmt;
+class SwSectionNode;
+class SwTableNode;
+class SwTOXType;
+class SwTOXMark;
+class SwTxtAttr;
+class SwTxtFmtColl;
+class SwTxtNode;
+class SwWW8WrGrf;
+class SwWW8Writer;
+class WW8WrtStyle;
+class WW8Bytes;
+class WW8_AttrIter;
+class WW8_WrFkp;
+class WW8_WrPlc0;
+class WW8_WrPlc1;
+class WW8_WrPlcDrawObj;
+class WW8_WrPlcFld;
+class WW8_WrPlcFtnEdn;
+class WW8_WrPlcPn;
+class WW8_WrPlcPostIt;
+class WW8_WrPlcSepx;
+class WW8_WrPlcTxtBoxes;
+class WW8_WrPct; // Verwaltung
+class WW8_WrPcPtrs;
+class WW8_WrtBookmarks;
+class WW8_WrtRedlineAuthor;
+class SvxMSExportOLEObjects;
+struct WW8_PdAttrDesc;
+struct WW8_SHD;
+
+
+#define WWFL_ULSPACE_LIKE_SWG 0x00000001
+#define WWFL_NO_GRAF 0x00000080
+#define WWFL_NO_OLE 0x00020000
+#define WWFL_KA_DEBUG 0x08000000
+#define WWFL_READ_FROM_FILE 0x40000000
+
+
+#define WW8_CSTY_FTN 15 // Slot# fuer C-Format Fussnotenzeichen
+
+#define GRF_MAGIC_1 0x12 // 3 magic Bytes fuer PicLocFc-Attribute
+#define GRF_MAGIC_2 0x34
+#define GRF_MAGIC_3 0x56
+#define GRF_MAGIC_321 0x563412L
+
+// defines for InsertField- Method
+#define WRITEFIELD_ALL 0xFF
+#define WRITEFIELD_START 0x01
+#define WRITEFIELD_CMD_START 0x02
+#define WRITEFIELD_CMD_END 0x04
+#define WRITEFIELD_END 0x10
+#define WRITEFIELD_CLOSE 0x20
+
+#define TXT_MAINTEXT 0 // Defines fuer TextTyp
+//!!#define TXT_FTNEDN 1
+#define TXT_HDFT 2
+#define TXT_FTN 3
+#define TXT_EDN 4
+#define TXT_ATN 5
+#define TXT_TXTBOX 6
+#define TXT_HFTXTBOX 7
+
+
+extern SwNodeFnTab aWW8NodeFnTab;
+extern SwAttrFnTab aWW8AttrFnTab;
+
+SV_DECL_VARARR( WW8Bytes, BYTE, 128, 128 );
+
+struct WW8_SepInfo
+{
+ const SwPageDesc* pPageDesc;
+ const SwSectionFmt* pSectionFmt;
+ const SwNode* pPDNd;
+ const SwTxtNode* pNumNd;
+ ULONG nLnNumRestartNo;
+ USHORT nPgRestartNo;
+
+ WW8_SepInfo()
+ : pPageDesc(0), pSectionFmt(0), pNumNd(0), pPDNd(0), nPgRestartNo(0),
+ nLnNumRestartNo(0)
+ {}
+
+ WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt, ULONG nLnRestart )
+ : pPageDesc(pPD), pSectionFmt(pFmt), pNumNd(0), nPgRestartNo(0),
+ nLnNumRestartNo( nLnRestart ), pPDNd( 0 )
+ {}
+};
+SV_DECL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo, 4, 4 );
+
+
+class WW8_WrPlcSepx // Plc fuer PageDescs -> Sepx ( Section Extensions )
+{
+ WW8_WrSepInfoPtrs aSects; // PTRARR von SwPageDesc und SwSectionFmt
+ SvULongs aCps; // PTRARR von CPs
+ WW8_PdAttrDesc* pAttrs;
+ WW8_WrPlc0* pTxtPos; // Pos der einzelnen Header / Footer
+
+ void CheckForFacinPg( SwWW8Writer& rWrt ) const;
+ void WriteOlst( SwWW8Writer& rWrt, USHORT i );
+ void WriteFtnEndTxt( SwWW8Writer& rWrt, ULONG nCpStt );
+ void OutHeader( SwWW8Writer& rWrt, const SwFmt& rFmt,
+ ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag );
+ void OutFooter( SwWW8Writer& rWrt, const SwFmt& rFmt,
+ ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag );
+ static void SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt,
+ BYTE nFlag );
+ static void SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt,
+ BYTE nFlag );
+ static int HasBorderItem( const SwFmt& rFmt );
+
+public:
+ WW8_WrPlcSepx();
+ ~WW8_WrPlcSepx();
+ void AppendSep( WW8_CP nStartCp,
+ const SwPageDesc* pPd,
+ const SwSectionFmt* pSectionFmt = 0,
+ ULONG nLnNumRestartNo = 0 );
+ void AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPd,
+ const SwNode& rNd,
+ ULONG nLnNumRestartNo );
+ void Finish( WW8_CP nEndCp ) { aCps.Insert( nEndCp, aCps.Count() ); }
+ void SetNum( const SwTxtNode* pNumNd );
+ void WriteKFTxt( SwWW8Writer& rWrt );
+ void WriteSepx( SvStream& rStrm ) const;
+ void WritePlcSed( SwWW8Writer& rWrt ) const;
+ void WritePlcHdd( SwWW8Writer& rWrt ) const;
+};
+
+//--------------------------------------------------------------------------
+// class WW8_WrPct zum Aufbau der Piece-Table
+//--------------------------------------------------------------------------
+class WW8_WrPct
+{
+ WW8_WrPcPtrs* pPcts;
+ WW8_FC nOldFc;
+ BOOL bIsUni : 1;
+public:
+ WW8_WrPct( WW8_FC nStartFc );
+ ~WW8_WrPct();
+ void AppendPc( WW8_FC nStartFc, BOOL bIsUnicode );
+ void WritePc( SwWW8Writer& rWrt );
+ void SetParaBreak();
+ BOOL IsUnicode() const { return bIsUni; }
+ ULONG Fc2Cp( ULONG nFc ) const;
+};
+
+
+
+// der WW8-Writer
+class SwWW8Writer: public StgWriter
+{
+friend void WW8_WrPlcSepx::WriteKFTxt( SwWW8Writer& rWrt ); // pO
+friend void WW8_WrPlcSepx::WriteOlst( SwWW8Writer& rWrt, USHORT i );
+friend Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode );
+
+ String aMainStg;
+ SvPtrarr aTOXArr;
+ SwPosFlyFrms* pFlyPos; // Pointer auf die aktuelle "FlyFrmTabelle"
+ const SfxItemSet* pISet; // fuer Doppel-Attribute
+ WW8_WrPct* pPiece; // Pointer auf Piece-Table
+ SwNumRuleTbl* pUsedNumTbl; // alle used NumRules
+ WW8_WrtBookmarks* pBkmks;
+ WW8_WrtRedlineAuthor* pRedlAuthors;
+ BitmapPalette* pBmpPal;
+ void* pKeyMap;
+ SvxMSExportOLEObjects* pOLEExp;
+
+ ULONG nIniFlags; // Flags aus der writer.ini
+ USHORT nCharFmtStart;
+ USHORT nFmtCollStart;
+ USHORT nAktFlyPos; // Index auf das naechste "FlyFrmFmt"
+ USHORT nStyleBeforeFly; // Style-Nummer des Nodes,
+ // in/an dem ein Fly verankert ist
+ USHORT nLastFmtId; // Style of last TxtNode in normal range
+
+ virtual ULONG WriteStorage();
+
+ void PrepareStorage();
+ void WriteFkpPlcUsw();
+ void OutFontTab( WW8Fib& pFib );
+ void WriteMainText();
+ void StoreDoc1();
+ ULONG StoreDoc();
+ void Out_Olst( const SwNumRule& rRule );
+ void Out_WwNumLvl( BYTE nWwLevel );
+ void Out_SwNumLvl( BYTE nSwLevel );
+ void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt,
+ BYTE nSwLevel );
+ void BuildAnlvBulletBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen,
+ const SwNumFmt& rFmt );
+ static void BuildAnlvBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen,
+ const SwNumRule& rRul, const SwNumFmt& rFmt, BYTE nSwLevel );
+
+ void Out_BorderLine( WW8Bytes& rO, const SvxBorderLine* pLine,
+ USHORT nDist, USHORT nSprmNo, BOOL bShadow );
+
+ void OutListTab();
+ void OutOverrideListTab();
+ void OutListNamesTab();
+
+
+public:
+ const SwPageDesc* pAktPageDesc;
+ WW8Fib* pFib;
+ WW8Dop* pDop;
+ WW8_WrPlcPn* pPapPlc;
+ WW8_WrPlcPn* pChpPlc;
+ WW8_AttrIter* pChpIter;
+ WW8WrtStyle* pStyles;
+ WW8_WrPlcSepx* pSepx;
+ WW8_WrPlcFtnEdn* pFtn;
+ WW8_WrPlcFtnEdn* pEdn;
+ WW8_WrPlcPostIt* pAtn;
+ WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs;
+
+ SwFlyFrmFmt* pFlyFmt; // liegt der Node in einem FlyFrame, ist
+ // das Format gesetzt, sonst 0
+
+ Point* pFlyOffset; // zur Justierung eines im Writer als Zeichen
+ // gebundenen Flys, der im WW Absatzgebunden wird.
+
+ WW8_WrPlcFld* pFldMain; // Felder im Haupttext
+ WW8_WrPlcFld* pFldHdFt; // Felder in Header/Footer
+ WW8_WrPlcFld* pFldFtn; // Felder in FootNotes
+ WW8_WrPlcFld* pFldEdn; // Felder in EndNotes
+ WW8_WrPlcFld* pFldTxtBxs; // fields in textboxes
+ WW8_WrPlcFld* pFldHFTxtBxs; // fields in header/footer textboxes
+ SwWW8WrGrf* pGrf;
+ const SwAttrSet* pStyAttr; // StyleAttr fuer Tabulatoren
+ const SwModify* pOutFmtNode; // write Format or Node
+
+ WW8_WrPlcDrawObj *pSdrObjs, // Draw-/Fly-Objects
+ *pHFSdrObjs; // Draw-/Fly-Objects in header or footer
+
+ WW8Bytes* pO;
+
+ SvStream *pTableStrm, *pDataStrm; // Streams fuer WW97 Export
+
+ SwEscherEx* pEscher; // escher export class
+ SwTwips nFlyWidth, nFlyHeight; // Fuer Anpassung Graphic
+
+ BYTE nTxtTyp;
+
+ BOOL bStyDef : 1; // wird Style geschrieben ?
+ BOOL bBreakBefore : 1; // Breaks werden 2mal ausgegeben
+ BOOL bOutKF : 1; // Kopf/Fusstexte werden ausgegeben
+ BOOL bOutFlyFrmAttrs : 1; // Rahmen-Attr von Flys werden ausgegeben
+ BOOL bOutPageDescs : 1; // PageDescs werden ausgegeben ( am Doc-Ende )
+ BOOL bOutFirstPage : 1; // write Attrset of FirstPageDesc
+ BOOL bOutTable : 1; // Tabelle wird ausgegeben
+ // ( wird zB bei Flys in Tabelle zurueckgesetzt )
+ BOOL bIsInTable : 1; // wird sind innerhalb der Ausgabe einer Tabelle
+ // ( wird erst nach der Tabelle zurueckgesetzt )
+ BOOL bOutGrf : 1; // Grafik wird ausgegeben
+ BOOL bWrtWW8 : 1; // Schreibe WW95 oder WW97 FileFormat
+ BOOL bInWriteEscher : 1; // in write textboxes
+ BOOL bStartTOX : 1; // TRUE: a TOX is startet
+ BOOL bInWriteTOX : 1; // TRUE: all content are in a TOX
+ BOOL bFtnAtTxtEnd : 1; // TRUE: all FTN at Textend
+ BOOL bEndAtTxtEnd : 1; // TRUE: all END at Textend
+
+
+ SvxMSExportOLEObjects& GetOLEExp() { return *pOLEExp; }
+
+ static USHORT TranslateToEditEngineId( USHORT nWhich );
+ static USHORT TranslateFromEditEngineId( USHORT nWhich );
+ const SfxPoolItem* HasItem( USHORT nWhich ) const;
+ const SfxPoolItem& GetItem( USHORT nWhich ) const;
+
+ USHORT GetId( const SwTxtFmtColl& rColl ) const;
+ USHORT GetId( const SwCharFmt& rFmt ) const;
+ USHORT GetId( const SvxFontItem& rFont ) const;
+ USHORT GetId( const Font& rFont ) const;
+ USHORT GetId( const SwNumRule& rNumRule ) const;
+ USHORT GetId( const SwTOXType& rTOXType );
+
+ void OutRedline( const SwRedlineData& rRedline );
+ USHORT AddRedlineAuthor( USHORT nId );
+
+ void StartTOX( const SwSection& rSect );
+ void EndTOX( const SwSection& rSect );
+
+ void WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp );
+ void WriteKFTxt1( const SwFmtCntnt& rCntnt );
+ void WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pO = 0 );
+ void WritePostItBegin( const SwPostItField& rFld, WW8Bytes* pO = 0 );
+ void OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd );
+ void OutWW8FlyFrm( const SwFrmFmt& rFlyFrmFmt, const Point& rNdTopLeft );
+ void OutFlyFrms( const SwCntntNode& rNode );
+ void AppendFlyInFlys( WW8_CP& rCP, const SwFrmFmt& rFrmFmt,
+ const Point& rNdTopLeft );
+ void WriteSdrTextObj( const SdrObject& rObj );
+
+ UINT32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const;
+ void CreateEscher();
+ void WriteEscher();
+
+ BOOL Out_SwNum( const SwTxtNode* pNd );
+ void Out_SwFmt( const SwFmt& rFmt, BOOL bPapFmt, BOOL bChpFmt,
+ BOOL bFlyFmt = FALSE );
+ BOOL GetNumberFmt( const SwField& rFld, String& rStr );
+ void OutField( const SwField* pFld, BYTE nFldType,
+ const String& rFldCmd, BYTE nMode = WRITEFIELD_ALL );
+ void StartCommentOutput( const String& rName );
+ void EndCommentOutput( const String& rName );
+ void OutGrf( const SwNoTxtNode* pNd );
+ void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen );
+ void AppendBookmark( const String& rName, USHORT nOffset = 0 );
+ String GetBookmarkName( USHORT nTyp, const String* pNm, USHORT nSeqNo );
+ BOOL HasRefToObject( USHORT nTyp, const String* pNm, USHORT nSeqNo );
+
+ void WriteAsStringTable( const SvStrings&, INT32& rfcSttbf,
+ INT32& rlcbSttbf, USHORT nExtraLen = 0 );
+ void WriteText();
+ void WriteCR();
+ void WriteChar( sal_Unicode c );
+ void OutSwString( const String&, xub_StrLen nStt, xub_StrLen nLen,
+ BOOL bUnicode, rtl_TextEncoding eChrSet );
+
+ ULONG ReplaceCr( BYTE nChar );
+
+ ULONG Fc2Cp( ULONG nFc ) const { return pPiece->Fc2Cp( nFc ); }
+
+ // einige z.T. static halb-interne Funktions-Deklarationen
+
+ void OutSprmBytes( BYTE* pBytes, USHORT nSiz )
+ { pO->Insert( pBytes, nSiz, pO->Count() ); }
+
+ ULONG GetIniFlags() const { return nIniFlags; }
+ inline BOOL IsUnicode() const { return pPiece->IsUnicode(); }
+
+ const SfxItemSet* GetCurItemSet() const { return pISet; }
+ void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; }
+
+ void Out_SfxItemSet( const SfxItemSet& rSet, BOOL bPapFmt, BOOL bChpFmt );
+ void Out_SfxBreakItems( const SfxItemSet& rSet, const SwNode& rNd );
+
+ void Out_SwFmtBox( const SvxBoxItem& rBox, BOOL bShadow );
+ void Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox );
+ BYTE TransCol( const Color& rCol );
+ BOOL TransBrush( const Color& rCol, WW8_SHD& rShd );
+ UINT32 TranslateBorderLine( const SvxBorderLine& pLine,
+ USHORT nDist, BOOL bShadow );
+
+ static long GetDTTM( const DateTime& rDT );
+
+ static BYTE GetNumId( USHORT eNumType );
+ static void CorrTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft );
+
+ static ULONG FillUntil( SvStream& rStrm, ULONG nEndPos = 0 );
+ static void FillCount( SvStream& rStrm, ULONG nCount );
+
+ static void WriteShort( SvStream& rStrm, INT16 nVal ) { rStrm << nVal; }
+ static void WriteShort( SvStream& rStrm, ULONG nPos, INT16 nVal );
+
+ static void WriteLong( SvStream& rStrm, INT32 nVal ) { rStrm << nVal; }
+ static void WriteLong( SvStream& rStrm, ULONG nPos, INT32 nVal );
+
+ static void WriteString16( SvStream& rStrm, const String& rStr,
+ BOOL bAddZero );
+ static void WriteString8( SvStream& rStrm, const String& rStr,
+ BOOL bAddZero, rtl_TextEncoding eCodeSet );
+
+ static void InsUInt16( WW8Bytes& rO, UINT16 );
+ static void InsUInt32( WW8Bytes& rO, UINT32 );
+ static void InsAsString16( WW8Bytes& rO, const String& );
+ static void InsAsString8( WW8Bytes& rO, const String& rStr,
+ rtl_TextEncoding eCodeSet );
+
+ void InsUInt16( UINT16 n ) { SwWW8Writer::InsUInt16( *pO, n ); }
+ void InsUInt32( UINT32 n ) { SwWW8Writer::InsUInt32( *pO, n ); }
+ void InsAsString16( const String& rStr )
+ { SwWW8Writer::InsAsString16( *pO, rStr ); }
+ void InsAsString8( const String& rStr, rtl_TextEncoding eCodeSet )
+ { SwWW8Writer::InsAsString8( *pO, rStr, eCodeSet ); }
+ void WriteStringAsPara( const String& rTxt, USHORT nStyleId = 0 );
+
+ // nach aussen interessant
+
+ SwWW8Writer( const String& rFltName );
+ virtual ~SwWW8Writer();
+
+ // fuer WW8SaveData
+ SwPaM* GetEndPaM() { return pOrigPam; }
+ void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; }
+};
+
+
+class WW8_WrPlcSubDoc // Doppel-Plc fuer Foot-/Endnotes und Postits
+{
+protected:
+ SvULongs aCps; // PTRARR CP-Pos der Verweise
+ SvPtrarr aCntnt; // PTRARR von SwFmtFtn/PostIts/..
+ WW8_WrPlc0* pTxtPos; // Pos der einzelnen Texte
+
+ WW8_WrPlcSubDoc();
+ ~WW8_WrPlcSubDoc();
+
+ void WriteTxt( SwWW8Writer& rWrt, BYTE nTTyp, long& rCount );
+ void WritePlc( SwWW8Writer& rWrt, BYTE nTTyp,
+ long& rTxtStt, long& rTxtCnt,
+ long& rRefStt, long& rRefCnt ) const;
+
+ virtual const SvULongs* GetShapeIdArr() const;
+};
+
+// Doppel-Plc fuer Footnotes/Endnotes
+class WW8_WrPlcFtnEdn : public WW8_WrPlcSubDoc
+{
+ BYTE nTyp;
+public:
+ WW8_WrPlcFtnEdn( BYTE nTTyp ) : nTyp( nTTyp ) {}
+
+ inline void WriteTxt( SwWW8Writer& rWrt );
+ inline void WritePlc( SwWW8Writer& rWrt ) const;
+
+ void Append( WW8_CP nCp, const SwFmtFtn& rFtn );
+};
+
+class WW8_WrPlcPostIt : public WW8_WrPlcSubDoc // Doppel-Plc fuer PostIts
+{
+public:
+ WW8_WrPlcPostIt() {}
+
+ void Append( WW8_CP nCp, const SwPostItField& rPostIt );
+ inline void WriteTxt( SwWW8Writer& rWrt );
+ inline void WritePlc( SwWW8Writer& rWrt ) const;
+};
+
+
+class WW8_WrPlcTxtBoxes : public WW8_WrPlcSubDoc // Doppel-Plc fuer Textboxen
+{ // Rahmen/DrawTextboxes!
+ BYTE nTyp;
+ SvULongs aShapeIds; // VARARR of ShapeIds for the SwFrmFmts
+
+ virtual const SvULongs* GetShapeIdArr() const;
+
+public:
+ WW8_WrPlcTxtBoxes( BYTE nTTyp ) : nTyp( nTTyp ) {}
+
+ void WriteTxt( SwWW8Writer& rWrt );
+ inline void WritePlc( SwWW8Writer& rWrt ) const;
+ void Append( const SdrObject& rObj, UINT32 nShapeId );
+ USHORT Count() const { return aCntnt.Count(); }
+ USHORT GetPos( const VoidPtr& p ) const { return aCntnt.GetPos( p ); }
+};
+
+
+class WW8_WrPlcDrawObj // PC for DrawObjects and Text-/OLE-/GRF-Boxes
+{
+ SvULongs aCps; // VARARR CP-Pos der Verweise
+ SvULongs aShapeIds; // VARARR of ShapeIds for the SwFrmFmts
+ SvPtrarr aCntnt; // PTRARR of SwFrmFmt
+ SvPtrarr aParentPos; // PTRARR of Points
+ BYTE nTTyp;
+
+public:
+ WW8_WrPlcDrawObj( BYTE nType );
+ ~WW8_WrPlcDrawObj();
+
+ void WritePlc( SwWW8Writer& rWrt ) const;
+ BOOL Append( SwWW8Writer&, WW8_CP nCp, const SwFrmFmt& rFmt,
+ const Point& rNdTopLeft );
+ const SvPtrarr& GetCntntArr() const { return aCntnt; }
+ void SetShapeId( const SwFrmFmt& rFmt, UINT32 nId );
+ UINT32 GetShapeId( USHORT n ) const { return aShapeIds[ n ]; }
+};
+
+
+typedef WW8_WrFkp* WW8_FkpPtr; // Plc fuer Chpx und Papx ( incl PN-Plc )
+SV_DECL_PTRARR( WW8_WrFkpPtrs, WW8_FkpPtr, 4, 4 );
+
+class WW8_WrPlcPn // Plc fuer Page Numbers
+{
+ SwWW8Writer& rWrt;
+ WW8_WrFkpPtrs aFkps; // PTRARR
+ USHORT nFkpStartPage;
+ ePLCFT ePlc;
+ BOOL bWrtWW8; // Fuer Writererkennung
+
+public:
+ WW8_WrPlcPn( SwWW8Writer& rWrt, ePLCFT ePl, WW8_FC nStartFc );
+ ~WW8_WrPlcPn();
+ void AppendFkpEntry( WW8_FC nEndFc, short nVarLen = 0, const BYTE* pSprms = 0 );
+ void WriteFkps();
+ void WritePlc();
+};
+
+// class WW8_WrPlc1 ist erstmal nur fuer Felder
+class WW8_WrPlc1
+{
+ SvULongs aPos; // PTRARR von CPs
+ WW8Bytes aDat; // Inhalte ( Strukturen )
+ USHORT nStructSiz;
+protected:
+ USHORT Count() const { return aPos.Count(); }
+ void Write( SvStream& rStrm );
+
+public:
+ WW8_WrPlc1( USHORT nStructSz );
+ void Append( WW8_CP nCp, const void* pData );
+ void Finish( ULONG nLastCp, ULONG nStartCp );
+};
+
+// class WW8_WrPlcFld ist fuer Felder
+class WW8_WrPlcFld: public WW8_WrPlc1
+{
+ BYTE nTxtTyp;
+public:
+ WW8_WrPlcFld( USHORT nStructSz, BYTE nTTyp )
+ : WW8_WrPlc1( nStructSz ), nTxtTyp( nTTyp )
+ {}
+ BOOL Write( SwWW8Writer& rWrt );
+};
+
+
+// class SwWW8WrGrf sammelt Grafiken und gibt sie aus
+class SwWW8WrGrf
+{
+ SwWW8Writer& rWrt; // SwWW8Writer fuer Zugriff auf die Vars
+ SvPtrarr aNds; // Positionen der SwGrfNodes und SwOleNodes
+ SvPtrarr aFlys; // Umgebende FlyFrms dazu
+ SvULongs aPos; // FilePos der Grafiken
+ SvUShorts aWid; // Breite der Grafiken
+ SvUShorts aHei; // Hoehe der Grafiken
+ USHORT nIdx; // Index in File-Positionen
+
+ void Write1GrfHdr( SvStream& rStrm, const SwNoTxtNode* pNd,
+ const SwFlyFrmFmt* pFly, UINT16 mm, UINT16 nWidth, UINT16 nHeight );
+ void Write1Grf1( SvStream& rStrm, const SwGrfNode* pGrfNd,
+ const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight );
+ void Write1Grf( SvStream& rStrm, const SwNoTxtNode* pNd,
+ const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight );
+public:
+ SwWW8WrGrf( SwWW8Writer& rW )
+ : rWrt( rW ), aNds( 4, 4 ), aFlys( 4, 4 ), aPos( 4, 4 ),
+ aWid( 4, 4 ), aHei( 4, 4 )
+ {}
+ void Insert( const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly );
+ void Write();
+ ULONG GetFPos() { return ( nIdx < aNds.Count() ) ? aPos[nIdx++] : 0; }
+};
+
+// The class WW8_AttrIter is a helper class to build the Fkp.chpx. This
+// class may be overloaded for output the SwTxtAttrs and the
+// EditEngineTxtAttrs.
+class WW8_AttrIter
+{
+ WW8_AttrIter* pOld;
+protected:
+ SwWW8Writer& rWrt;
+public:
+ WW8_AttrIter( SwWW8Writer& rWrt );
+ ~WW8_AttrIter();
+
+ virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const = 0;
+ virtual const SfxPoolItem& GetItem( USHORT nWhich ) const = 0;
+ virtual void GetItems( WW8Bytes& rItems ) const;
+};
+
+
+class WW8WrtStyle
+{
+ SwWW8Writer& rWrt;
+ SwFmt** pFmtA;
+ USHORT nPOPosStdLen1, nPOPosStdLen2;
+ USHORT nUsedSlots;
+
+ void BuildStyleTab();
+ void BuildUpx( const SwFmt* pFmt, BOOL bPap, USHORT nPos,
+ BOOL bInsDefCharSiz );
+ USHORT Build_GetWWSlot( const SwFmt& rFmt );
+ USHORT GetWWId( const SwFmt& rFmt ) const;
+ void Set1StyleDefaults( const SwFmt& rFmt, BOOL bPap );
+ void Out1Style( SwFmt* pFmt, USHORT nPos );
+
+ void WriteStyle( SvStream& rStrm );
+ void SkipOdd();
+ void BuildStd( const String& rName, BOOL bPapFmt, short nWwBase,
+ short nWwNext, USHORT nWwId );
+
+public:
+ WW8WrtStyle( SwWW8Writer& rWr );
+ ~WW8WrtStyle();
+
+ void OutStyleTab();
+ USHORT Sty_GetWWSlot( const SwFmt& rFmt ) const;
+};
+
+
+struct WW8SaveData
+{
+ SwWW8Writer& rWrt;
+ Point* pOldFlyOffset;
+ WW8Bytes* pOOld;
+ SwPaM* pOldPam, *pOldEnd;
+ SwFlyFrmFmt* pOldFlyFmt;
+ const SwPageDesc* pOldPageDesc;
+
+ BOOL bOldWriteAll : 1;
+ BOOL bOldOutTable : 1;
+ BOOL bOldIsInTable: 1;
+ BOOL bOldFlyFrmAttrs : 1;
+ BOOL bOldStartTOX : 1;
+ BOOL bOldInWriteTOX : 1;
+ // bOutPageDesc muss nicht gesichert werden, da es nur nicht waehrend
+ // der Ausgabe von Spezial-Texten veraendert wird.
+
+ WW8SaveData( SwWW8Writer&, ULONG nStt, ULONG nEnd );
+ ~WW8SaveData();
+};
+
+
+// einige halb-interne Funktions-Deklarationen fuer die Node-Tabelle
+
+Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& rNode );
+Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode );
+Writer& OutWW8_SwSectionNode(Writer& rWrt, SwSectionNode& rSectionNode );
+Writer& OutWW8_SwTblNode( Writer& rWrt, SwTableNode & rNode );
+
+Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt );
+Writer& OutWW8_SwFmtVertOrient( Writer& rWrt, const SfxPoolItem& rHt );
+
+
+// --------------------------- inlines ---------------------------------
+
+inline void WW8_WrPlcFtnEdn::WriteTxt( SwWW8Writer& rWrt )
+{
+ if( TXT_FTN == nTyp )
+ {
+ WW8_WrPlcSubDoc::WriteTxt( rWrt, TXT_FTN, rWrt.pFib->ccpFtn );
+ rWrt.pFldFtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
+ rWrt.pFib->ccpText );
+ }
+ else
+ {
+ WW8_WrPlcSubDoc::WriteTxt( rWrt, TXT_EDN, rWrt.pFib->ccpEdn );
+ rWrt.pFldEdn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
+ rWrt.pFib->ccpText + rWrt.pFib->ccpFtn
+ + rWrt.pFib->ccpHdr + rWrt.pFib->ccpAtn );
+ }
+}
+
+inline void WW8_WrPlcFtnEdn::WritePlc( SwWW8Writer& rWrt ) const
+{
+ if( TXT_FTN == nTyp )
+ WW8_WrPlcSubDoc::WritePlc( rWrt, TXT_FTN,
+ rWrt.pFib->fcPlcffndTxt, rWrt.pFib->lcbPlcffndTxt,
+ rWrt.pFib->fcPlcffndRef, rWrt.pFib->lcbPlcffndRef );
+ else
+ WW8_WrPlcSubDoc::WritePlc( rWrt, TXT_EDN,
+ rWrt.pFib->fcPlcfendTxt, rWrt.pFib->lcbPlcfendTxt,
+ rWrt.pFib->fcPlcfendRef, rWrt.pFib->lcbPlcfendRef );
+}
+
+
+void WW8_WrPlcPostIt::WriteTxt( SwWW8Writer& rWrt )
+{
+ WW8_WrPlcSubDoc::WriteTxt( rWrt, TXT_ATN, rWrt.pFib->ccpAtn );
+}
+
+void WW8_WrPlcPostIt::WritePlc( SwWW8Writer& rWrt ) const
+{
+ WW8_WrPlcSubDoc::WritePlc( rWrt, TXT_ATN,
+ rWrt.pFib->fcPlcfandTxt, rWrt.pFib->lcbPlcfandTxt,
+ rWrt.pFib->fcPlcfandRef, rWrt.pFib->lcbPlcfandRef );
+}
+
+void WW8_WrPlcTxtBoxes::WritePlc( SwWW8Writer& rWrt ) const
+{
+ if( TXT_TXTBOX == nTyp )
+ WW8_WrPlcSubDoc::WritePlc( rWrt, nTyp,
+ rWrt.pFib->fcPlcftxbxBkd, rWrt.pFib->lcbPlcftxbxBkd,
+ rWrt.pFib->fcPlcftxbxTxt, rWrt.pFib->lcbPlcftxbxTxt );
+ else
+ WW8_WrPlcSubDoc::WritePlc( rWrt, nTyp,
+ rWrt.pFib->fcPlcfHdrtxbxBkd, rWrt.pFib->lcbPlcfHdrtxbxBkd,
+ rWrt.pFib->fcPlcfHdrtxbxTxt, rWrt.pFib->lcbPlcfHdrtxbxTxt );
+}
+
+
+
+#endif // _WRTWW8_HXX
+
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
new file mode 100644
index 000000000000..2b5f3fc639b9
--- /dev/null
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -0,0 +1,697 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtww8gr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include <hintids.hxx>
+
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _VIRDEV_HXX //autogen
+#include <vcl/virdev.hxx>
+#endif
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _IPOBJ_HXX //autogen
+#include <so3/ipobj.hxx>
+#endif
+#ifndef _SVSTOR_HXX //autogen wg. SvStorage
+#include <so3/svstor.hxx>
+#endif
+#ifndef _FILTER_HXX //autogen
+#include <svtools/filter.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _MSOLEEXP_HXX
+#include <svx/msoleexp.hxx>
+#endif
+
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _NDGRF_HXX
+#include <ndgrf.hxx>
+#endif
+#ifndef _FRMFMT_HXX
+#include <frmfmt.hxx> // class SwFlyFrmFmt
+#endif
+#ifndef _GRFATR_HXX
+#include <grfatr.hxx> // class SwCropGrf
+#endif
+#ifndef _NDOLE_HXX
+#include <ndole.hxx>
+#endif
+#ifndef _WW8STRUC_HXX
+#include <ww8struc.hxx>
+#endif
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+
+
+#define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))
+
+// Damit KA debuggen kann, ohne sich den ganzen Writer zu holen, ist
+// temporaer dieses Debug gesetzt. Ist ausserdem noch das passende IniFlag
+// gesetzt, dann werden in d:\ Hilfsdateien erzeugt.
+// !! sollte demnaechst wieder entfernt werden !!
+// #define DEBUG_KA
+
+
+// ToDo:
+// 5. Die MapModes, die Win nicht kann, umrechnen
+
+// OutGrf() wird fuer jeden GrafNode im Doc gerufen. Es wird ein PicLocFc-Sprm
+// eingefuegt, der statt Adresse ein Magic ULONG enthaelt. Ausserdem wird
+// in der Graf-Klasse der GrfNode-Ptr gemerkt ( fuers spaetere Ausgeben der
+// Grafiken und Patchen der PicLocFc-Attribute )
+
+Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& rNode )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ rWW8Wrt.OutGrf( rNode.GetGrfNode() );
+
+ rWW8Wrt.pFib->fHasPic = 1;
+
+ return rWrt;
+}
+
+Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ if( !(rWW8Wrt.GetIniFlags() & WWFL_NO_OLE ) )
+ {
+ if( rWW8Wrt.bWrtWW8 )
+ {
+ static BYTE aSpecOLE[] = {
+ 0x03, 0x6a, 0, 0, 0, 0, // sprmCPicLocation
+ 0x0a, 0x08, 1, // sprmCFOLE2
+ 0x56, 0x08, 1 // sprmCFObj
+ };
+
+ const SwOLENode& rOLENd = (SwOLENode&)rNode;
+ UINT32 nPictureId = (long)&rOLENd;
+ BYTE* pDataAdr = aSpecOLE + 2;
+ Set_UInt32( pDataAdr, nPictureId );
+
+ SvStorageRef xObjStg = rWW8Wrt.GetStorage().OpenStorage(
+ String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "ObjectPool" )),
+ STREAM_READWRITE| STREAM_SHARE_DENYALL );
+ if( xObjStg.Is() )
+ {
+ String sStorageName( '_' );
+ sStorageName += String::CreateFromInt32( nPictureId );
+ SvStorageRef xOleStg = xObjStg->OpenStorage( sStorageName,
+ STREAM_READWRITE| STREAM_SHARE_DENYALL );
+ if( xOleStg.Is() )
+ {
+ SvInPlaceObjectRef xObj( ((SwOLENode&)rOLENd).
+ GetOLEObj().GetOleRef() );
+ if( xObj.Is() )
+ {
+ rWW8Wrt.GetOLEExp().ExportOLEObject( *xObj, *xOleStg );
+
+ // write as embedded field - the other things will
+ // be done in the escher export
+ String sServer( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( " EINBETTEN " )));
+ ( sServer += xOleStg->GetUserName() ) += ' ';
+
+ rWW8Wrt.OutField( 0, 58, sServer,
+ WRITEFIELD_START |
+ WRITEFIELD_CMD_START |
+ WRITEFIELD_CMD_END );
+
+ rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(),
+ sizeof( aSpecOLE ), aSpecOLE );
+
+ rWW8Wrt.WriteChar( 0x1 );
+
+ rWW8Wrt.OutField( 0, 58, aEmptyStr,
+ WRITEFIELD_END |
+ WRITEFIELD_CLOSE );
+ rWW8Wrt.WriteCR(); // CR danach
+ }
+ }
+ }
+ }
+ else
+ rWW8Wrt.OutGrf( rNode.GetOLENode() );
+ }
+ return rWrt;
+}
+
+
+void SwWW8Writer::OutGrf( const SwNoTxtNode* pNd )
+{
+ if( nIniFlags & WWFL_NO_GRAF )
+ return; // Iniflags: kein Grafik-Export
+
+ if( !pFlyFmt ) // Grafik mit eigenem Frame ( eigentlich immer )
+ {
+ ASSERT( !this, "+Grafik ohne umgebenden Fly" );
+ return ;
+ }
+
+ // GrfNode fuer spaeteres rausschreiben der Grafik merken
+ pGrf->Insert( pNd, pFlyFmt );
+
+ pChpPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+
+ WriteChar( (char)1 ); // Grafik-Sonderzeichen in Haupttext einfuegen
+
+ BYTE aArr[ 14 ];
+ BYTE* pArr = aArr;
+
+ // sprmCFSpec
+ if( bWrtWW8 )
+ Set_UInt16( pArr, 0x855 );
+ else
+ Set_UInt8( pArr, 117 );
+ Set_UInt8( pArr, 1 );
+
+ // sprmCPicLocation
+ if( bWrtWW8 )
+ Set_UInt16( pArr, 0x6a03 );
+ else
+ {
+ Set_UInt8( pArr, 68 );
+ Set_UInt8( pArr, 4 );
+ }
+ Set_UInt32( pArr, GRF_MAGIC_321 );
+
+ // Magic variieren, damit verschiedene Grafik-Attribute nicht
+ // gemerged werden
+ static BYTE nAttrMagicIdx = 0;
+ --pArr;
+ Set_UInt8( pArr, nAttrMagicIdx++ );
+ pChpPlc->AppendFkpEntry( pStrm->Tell(), pArr - aArr, aArr );
+
+ RndStdIds eAn = pFlyFmt->GetAttrSet().GetAnchor( FALSE ).GetAnchorId();
+ if( eAn == FLY_AT_CNTNT || eAn == FLY_PAGE )
+ {
+ WriteChar( (char)0x0d ); // umgebenden Rahmen mit CR abschliessen
+
+ static BYTE __READONLY_DATA nSty[2] = { 0, 0 };
+ pO->Insert( nSty, 2, pO->Count() ); // Style #0
+ BOOL bOldGrf = bOutGrf;
+ bOutGrf = TRUE;
+
+ Out_SwFmt( *pFlyFmt, FALSE, FALSE, TRUE ); // Fly-Attrs
+
+ bOutGrf = bOldGrf;
+ pPapPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() );
+ pO->Remove( 0, pO->Count() ); // leeren
+ }
+}
+
+void SwWW8WrGrf::Insert( const SwNoTxtNode* pNd, const SwFlyFrmFmt* pFly )
+{
+ aNds.Insert( (VoidPtr)pNd, aNds.Count() );
+ aFlys.Insert( (VoidPtr)pFly, aFlys.Count() );
+ if( rWrt.nFlyWidth > 0 && rWrt.nFlyHeight > 0 )
+ {
+ aWid.Insert( (UINT16)rWrt.nFlyWidth, aWid.Count() ); // hier steht die ware Groesse
+ aHei.Insert( (UINT16)rWrt.nFlyHeight, aHei.Count() ); // naemlich im uebergeordneten Frame
+ }
+ else
+ {
+ Size aGrTwipSz( pNd->GetTwipSize() );
+ //JP 05.12.98: falls die Grafik noch nie angezeigt wurde und es sich
+ // um eine gelinkte handelt, so ist keine Size gesetzt. In
+ // diesem Fall sollte man sie mal reinswappen.
+ if( ( !aGrTwipSz.Width() || !aGrTwipSz.Height() ) &&
+ pNd->IsGrfNode() &&
+ GRAPHIC_DEFAULT == ((SwGrfNode*)pNd)->GetGrf().GetType() )
+ {
+ ((SwGrfNode*)pNd)->SwapIn();
+ aGrTwipSz = pNd->GetTwipSize();
+ }
+
+ aWid.Insert( (UINT16)aGrTwipSz.Width(), aWid.Count() );
+ aHei.Insert( (UINT16)aGrTwipSz.Height(), aHei.Count() );
+ }
+}
+
+void SwWW8WrGrf::Write1GrfHdr( SvStream& rStrm, const SwNoTxtNode* pNd,
+ const SwFlyFrmFmt* pFly,
+ UINT16 mm, UINT16 nWidth, UINT16 nHeight )
+{
+ INT16 nXSizeAdd = 0, nYSizeAdd = 0;
+ INT16 nCropL = 0, nCropR = 0, nCropT = 0, nCropB = 0;
+
+ // Crop-AttributInhalt in Header schreiben ( falls vorhanden )
+ const SwAttrSet* pAttrSet = pNd->GetpSwAttrSet();
+ const SfxPoolItem* pItem;
+ if( pAttrSet && ( SFX_ITEM_ON
+ == pAttrSet->GetItemState( RES_GRFATR_CROPGRF, FALSE, &pItem ) ) )
+ {
+ const SwCropGrf& rCr = *(SwCropGrf*)pItem;
+ nCropL = rCr.GetLeft();
+ nCropR = rCr.GetRight();
+ nCropT = rCr.GetTop();
+ nCropB = rCr.GetBottom();
+ nXSizeAdd -= (INT16)( rCr.GetLeft() - rCr.GetRight() );
+ nYSizeAdd -= (INT16)( rCr.GetTop() - rCr.GetBottom() );
+ }
+
+ Size aGrTwipSz( pNd->GetTwipSize() );
+ //JP 05.12.98: falls die Grafik noch nie angezeigt wurde und es sich
+ // um eine gelinkte handelt, so ist keine Size gesetzt. In
+ // diesem Fall sollte man sie mal reinswappen.
+ if( ( !aGrTwipSz.Width() || !aGrTwipSz.Height() ) &&
+ pNd->IsGrfNode() &&
+ GRAPHIC_DEFAULT == ((SwGrfNode*)pNd)->GetGrf().GetType() )
+ {
+ ((SwGrfNode*)pNd)->SwapIn();
+ aGrTwipSz = pNd->GetTwipSize();
+ }
+
+
+ BOOL bWrtWW8 = rWrt.bWrtWW8;
+ UINT16 nHdrLen = bWrtWW8 ? 0x3A : 0x44;
+
+ BYTE aArr[ sizeof( WW8_PIC_SHADOW ) ];
+ memset( aArr, 0, nHdrLen );
+
+ BYTE* pArr = aArr + 4; //skip lcb
+ Set_UInt16( pArr, nHdrLen ); // set cbHeader
+
+ Set_UInt16( pArr, mm ); // set mm
+ Set_UInt16( pArr, aGrTwipSz.Width() * 254L / 144 ); // set xExt
+ Set_UInt16( pArr, aGrTwipSz.Height() * 254L / 144 ); // set yExt
+ pArr += 16; // skip hMF & rcWinMF
+ Set_UInt16( pArr, (UINT16)aGrTwipSz.Width() ); // set dxaGoal
+ Set_UInt16( pArr, (UINT16)aGrTwipSz.Height() ); // set dyaGoal
+
+ if( aGrTwipSz.Width() + nXSizeAdd ) // set mx
+ Set_UInt16( pArr, ( nWidth * 1000L /
+ ( aGrTwipSz.Width() + nXSizeAdd ) ) );
+ else
+ pArr += 2;
+ if( aGrTwipSz.Height() + nYSizeAdd ) // set my
+ Set_UInt16( pArr, ( nHeight * 1000L /
+ ( aGrTwipSz.Height() + nYSizeAdd ) ) );
+ else
+ pArr += 2;
+
+ Set_UInt16( pArr, nCropL ); // set dxaCropLeft
+ Set_UInt16( pArr, nCropT ); // set dyaCropTop
+ Set_UInt16( pArr, nCropR ); // set dxaCropRight
+ Set_UInt16( pArr, nCropB ); // set dyaCropBottom
+ pArr += 2; // skip Flags
+
+ if( pFly )
+ {
+ const SwAttrSet& rAttrSet = pFly->GetAttrSet();
+ if( SFX_ITEM_ON == rAttrSet.GetItemState( RES_BOX, FALSE, &pItem ) )
+ {
+ const SvxBoxItem* pBox = (const SvxBoxItem*)pItem;
+ if( pBox )
+ {
+ BOOL bShadow = FALSE; // Shadow ?
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_ON
+ == rAttrSet.GetItemState( RES_SHADOW, TRUE, &pItem ) )
+ {
+ const SvxShadowItem* pSI = (const SvxShadowItem*)pItem;
+ bShadow = ( pSI->GetLocation() != SVX_SHADOW_NONE )
+ && ( pSI->GetWidth() != 0 );
+ }
+
+ BYTE aLnArr[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
+ BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
+ for( BYTE i = 0; i < 4; ++i )
+ {
+ const SvxBorderLine* pLn = pBox->GetLine( aLnArr[ i ] );
+ UINT32 nBrd = pLn
+ ? rWrt.TranslateBorderLine( *pLn,
+ pBox->GetDistance( aLnArr[ i ] ),
+ bShadow )
+ : 0;
+
+ if( bWrtWW8 )
+ Set_UInt32( pArr, nBrd );
+ else
+ Set_UInt16( pArr, (USHORT)nBrd );
+ }
+ }
+ }
+ }
+ rStrm.Write( aArr, nHdrLen );
+}
+
+void SwWW8WrGrf::Write1Grf1( SvStream& rStrm, const SwGrfNode* pGrfNd,
+ const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight )
+{
+ if( pGrfNd->IsLinkedFile() ) // Linked File
+ {
+ String aFileN, aFiltN;
+ UINT16 mm;
+ pGrfNd->GetFileFilterNms( &aFileN, &aFiltN );
+
+ aFileN = INetURLObject::AbsToRel( aFileN, INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_WITH_CHARSET );
+ INetURLObject aUrl( aFileN );
+ if( aUrl.GetProtocol() == INET_PROT_FILE )
+ aFileN = aUrl.PathToFileName();
+
+//JP 05.12.98: nach einigen tests hat sich gezeigt, das WW mit 99 nicht
+// klarkommt. Sie selbst schreiben aber bei Verknuepfunfen,
+// egal um welchen Type es sich handelt, immer den Wert 94.
+// Bug 59859
+// if ( COMPARE_EQUAL == aFiltN.ICompare( "TIF", 3 ) )
+// mm = 99; // 99 = TIFF
+// else
+ mm = 94; // 94 = BMP, GIF
+
+ Write1GrfHdr( rStrm, pGrfNd, pFly, mm, nWidth, nHeight ); // Header
+ rStrm << (BYTE)aFileN.Len(); // Pascal-String schreiben
+ SwWW8Writer::WriteString8( rStrm, aFileN, FALSE, RTL_TEXTENCODING_MS_1252 );
+ }
+ else // Embedded File oder DDE oder so was
+ {
+ Graphic& rGrf = (Graphic&)(pGrfNd->GetGrf());
+ BOOL bSwapped = rGrf.IsSwapOut();
+ ((SwGrfNode*)pGrfNd)->SwapIn(); // immer ueber den Node einswappen !!!
+
+ GDIMetaFile aMeta;
+
+ switch ( rGrf.GetType() )
+ {
+ case GRAPHIC_BITMAP: // Bitmap -> in Metafile abspielen
+ {
+ VirtualDevice aVirt;
+ aMeta.Record( &aVirt );
+ aVirt.DrawBitmap( Point( 0,0 ), rGrf.GetBitmap() );
+ aMeta.Stop();
+ aMeta.WindStart();
+ aMeta.SetPrefMapMode( rGrf.GetPrefMapMode());
+ aMeta.SetPrefSize( rGrf.GetPrefSize());
+ }
+ break;
+ case GRAPHIC_GDIMETAFILE : // GDI ( =SV ) Metafile
+#ifndef VCL
+ case GRAPHIC_WINMETAFILE : // WinMetafile
+#endif
+ aMeta = rGrf.GetGDIMetaFile();
+ break;
+ default : return;
+ }
+
+// ASSERT( aMeta.GetPrefMapMode().GetMapUnit() == MAP_100TH_MM,
+// "MapMode der Grafik ist nicht 1/100mm!" );
+
+#ifdef DEBUG
+ BOOL bSchreibsRaus = FALSE;
+ BOOL bSchreibsRein = FALSE;
+ long nSchreibsRausA = rStrm.Tell();
+ long nSchreibsReinA = nSchreibsRausA;
+#endif
+
+ Write1GrfHdr( rStrm, pGrfNd, pFly, 8, nWidth, nHeight ); // Header
+ WriteWindowMetafileBits( rStrm, aMeta ); // eigentliche Grafik
+
+#ifdef DEBUG
+ if( bSchreibsRaus )
+ {
+ long nSchreibsRausZ = rStrm.Tell();
+ SvFileStream aS( WW8_ASCII2STR( "e:\\ww-exp.wmf" ), STREAM_WRITE );
+ rStrm.Seek( nSchreibsRausA );
+ UINT16 nRead1;
+ BYTE* pBuf = new BYTE[ 8192 ];
+ ULONG nRead = nSchreibsRausZ - nSchreibsRausA;
+ do{
+ nRead1 = ( nRead > 8192 ) ? 8192 : (UINT16)nRead;
+ rStrm.Read( pBuf, nRead1 );
+ aS.Write( pBuf, nRead1 );
+ nRead -= nRead1;
+ }while( nRead );
+ aS.Close();
+ rStrm.Seek( nSchreibsRausZ );
+ }
+ if( bSchreibsRein )
+ {
+ SvFileStream aS( WW8_ASCII2STR( "e:\\ww-imp.wmf" ), STREAM_READ );
+ aS.Seek( STREAM_SEEK_TO_END );
+ ULONG nRead = aS.Tell();
+ aS.Seek( 0 );
+ rStrm.Seek( nSchreibsReinA );
+ UINT16 nRead1;
+ BYTE* pBuf = new BYTE[ 8192 ];
+ do{
+ nRead1 = ( nRead > 8192 ) ? 8192 : (UINT16)nRead;
+ aS.Read( pBuf, nRead1 );
+ rStrm.Write( pBuf, nRead1 );
+ nRead -= nRead1;
+ }while( nRead );
+ aS.Close();
+ // kein Seek, da es hier im Stream weitergehen soll...
+ }
+#endif
+
+ if( bSwapped ) rGrf.SwapOut();
+ }
+}
+
+void SwWW8WrGrf::Write1Grf( SvStream& rStrm, const SwNoTxtNode* pNd,
+ const SwFlyFrmFmt* pFly, UINT16 nWidth, UINT16 nHeight )
+{
+ if( !pNd || ( !pNd->IsGrfNode() && !pNd->IsOLENode() ) )
+ return;
+
+ UINT32 nPos = rStrm.Tell(); // Grafik-Anfang merken
+
+ if( pNd->IsGrfNode() )
+ {
+ const SwGrfNode* pGrfNd = pNd->GetGrfNode();
+ Write1Grf1( rStrm, pGrfNd, pFly, nWidth, nHeight );
+ }
+ else if( pNd->IsOLENode() )
+ {
+ SwOLENode* pOleNd = ((SwNoTxtNode*)pNd)->GetOLENode(); // const wegcasten
+ ASSERT( pOleNd, " Wer hat den OleNode versteckt ?" );
+ SwOLEObj& rSObj= pOleNd->GetOLEObj();
+ const SvInPlaceObjectRef rObj( rSObj.GetOleRef() );
+ SvData aData( FORMAT_GDIMETAFILE );
+
+ // das MetaFile wird sich jetzt ueber die SvData-Schnittstelle
+ // besorgt, d.h. SvData-Object anlegen und via GetData
+ // das MetaFile abholen. MakeMetaFile entfaellt,
+ // der Rest ist gleich geblieben (KA 30.09.96)
+ if ( rObj->GetData( &aData ) )
+ {
+ GDIMetaFile* pMtf = NULL;
+
+ if ( aData.GetData( &pMtf, TRANSFER_MOVE ) )
+ {
+ DBG_ASSERT( pMtf, "Wo ist denn nun das MetaFile?" );
+
+ Size aS ( pMtf->GetPrefSize() );
+#ifdef DEBUG
+ MapMode aMap ( pMtf->GetPrefMapMode() );
+ ASSERT( pMtf->GetActionCount(), "OLE schreiben OK ? ( No Meta-Action )" );
+ ASSERT( pMtf->GetPrefMapMode().GetMapUnit() == MAP_100TH_MM,
+ "MapMode des Ole ist nicht 1/100mm!" );
+#endif
+ pMtf->WindStart();
+ pMtf->Play( Application::GetDefaultDevice(),
+ Point( 0, 0 ), Size( 2880, 2880 ) );
+ Write1GrfHdr( rStrm, pNd, pFly, 8, nWidth, nHeight ); // Header
+ WriteWindowMetafileBits( rStrm, *pMtf ); // eigentliche Grafik
+
+#ifdef DEBUG_KA
+
+ if( rWrt.GetIniFlags() & WWFL_KA_DEBUG )
+ {
+ SvFileStream aS( WW8_ASCII2STR( "d:\\xxx.svm" ), STREAM_WRITE | STREAM_TRUNC );
+
+ aS << *pMtf;
+ aS.Close();
+
+ aS.Open( WW8_ASCII2STR( "d:\\xxx.wmf" ), STREAM_WRITE | STREAM_TRUNC );
+ WriteWindowMetafile( aS, *pMtf );
+ }
+
+#endif // DEBUG_KA
+
+ // brauchen wir nicht mehr
+ delete pMtf;
+ }
+ }
+ }
+
+ UINT32 nPos2 = rStrm.Tell(); // Ende merken
+ rStrm.Seek( nPos );
+ SVBT32 nLen;
+ LongToSVBT32( nPos2 - nPos, nLen ); // Grafik-Laenge ausrechnen
+ rStrm.Write( nLen, 4 ); // im Header einpatchen
+ rStrm.Seek( nPos2 ); // Pos wiederherstellen
+}
+
+// SwWW8WrGrf::Write() wird nach dem Text gerufen. Es schreibt die alle
+// Grafiken raus und merkt sich die File-Positionen der Grafiken, damit
+// beim Schreiben der Attribute die Positionen in die PicLocFc-Sprms
+// eingepatcht werden koennen.
+// Das Suchen in den Attributen nach dem Magic ULONG und das Patchen
+// passiert beim Schreiben der Attribute. Die SwWW8WrGrf-Klasse liefert
+// hierfuer nur mit GetFPos() sequentiell die Positionen.
+void SwWW8WrGrf::Write()
+{
+ nIdx = 0; // fuers anschliessende Abfragen
+ SvStream& rStrm = *rWrt.pDataStrm;
+ for( USHORT i = 0; i < aNds.Count(); i++ )
+ {
+ UINT32 nPos = rStrm.Tell(); // auf 4 Bytes alignen
+ if( nPos & 0x3 )
+ SwWW8Writer::FillCount( rStrm, 4 - ( nPos & 0x3 ) );
+
+ aPos.Insert( rStrm.Tell(), aPos.Count() ); // Pos merken
+ const SwNoTxtNode* pNd = (const SwNoTxtNode*)aNds[i];
+ Write1Grf( rStrm, pNd, (const SwFlyFrmFmt*)aFlys[i],
+ aWid[i], aHei[i] );
+ }
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/wrtww8gr.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.16 2000/09/18 16:04:58 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.15 2000/08/25 12:27:35 jp
+ Graphic Crop-Attribut exported to SVX
+
+ Revision 1.14 2000/08/18 13:02:29 jp
+ don't export escaped URLs
+
+ Revision 1.13 2000/07/05 16:07:38 jp
+ new MS Filteroptions - change StarOffice Objects to OLE-Objects
+
+ Revision 1.12 2000/06/26 09:58:38 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.11 2000/05/25 09:19:59 khz
+ Changes for Unicode (for debug mode)
+
+ Revision 1.10 2000/05/12 16:14:14 jp
+ Changes for Unicode
+
+ Revision 1.9 2000/02/11 14:39:59 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.8 1999/12/02 10:41:05 jp
+ Bug #70093#: OutWW8_SwOleNode - write field with storage-username, W97 need it
+
+ Revision 1.7 1999/10/29 17:40:22 jp
+ export of 'complex'(vert. merged) tables
+
+ Revision 1.6 1999/08/24 18:15:52 JP
+ Escher Export
+
+
+ Rev 1.5 24 Aug 1999 20:15:52 JP
+ Escher Export
+
+ Rev 1.4 06 Jul 1999 14:54:06 JP
+ W97-Export corrections
+
+ Rev 1.3 30 Jun 1999 19:56:46 JP
+ W97-Export: Fields/PostIts/References
+
+ Rev 1.2 04 Jun 1999 17:47:56 JP
+ WW97-Export: Code aufgeteilt
+
+ Rev 1.1 27 May 1999 23:42:28 JP
+ Schnittstellen angepasst
+
+ Rev 1.0 19 May 1999 11:20:20 JP
+ WinWord97-ExportFilter
+
+*************************************************************************/
+
+
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
new file mode 100644
index 000000000000..c04ba2896bec
--- /dev/null
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -0,0 +1,3489 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8atr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/*
+ * Dieses File enthaelt alle Ausgabe-Funktionen des WW8-Writers;
+ * fuer alle Nodes, Attribute, Formate und Chars.
+ */
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_SALBTYPE_HXX
+#include <vcl/salbtype.hxx>
+#endif
+#ifndef _ZFORMAT_HXX
+#include <svtools/zformat.hxx>
+#endif
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _SVX_WIDWITEM_HXX //autogen
+#include <svx/widwitem.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_KEEPITEM_HXX //autogen
+#include <svx/keepitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_WRLMITEM_HXX //autogen
+#include <svx/wrlmitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX //autogen
+#include <svx/langitem.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_HYZNITEM_HXX //autogen
+#include <svx/hyznitem.hxx>
+#endif
+#ifndef _SVX_BRKITEM_HXX //autogen
+#include <svx/brkitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_ITEM_HXX //autogen
+#include <svx/cntritem.hxx>
+#endif
+#ifndef _SVX_SHDDITEM_HXX //autogen
+#include <svx/shdditem.hxx>
+#endif
+#ifndef _SVX_AKRNITEM_HXX //autogen wg. SvxAutoKernItem
+#include <svx/akrnitem.hxx>
+#endif
+#ifndef _SVX_PBINITEM_HXX //autogen wg. SvxPaperBinItem
+#include <svx/pbinitem.hxx>
+#endif
+
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FCHRFMT_HXX //autogen
+#include <fchrfmt.hxx>
+#endif
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _FMTINFMT_HXX //autogen wg. SwFmtINetFmt
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _TXTFLD_HXX //autogen wg. SwTxtFld
+#include <txtfld.hxx>
+#endif
+#ifndef _TXTFTN_HXX //autogen wg. SwTxtFtn
+#include <txtftn.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx> // Doc fuer Fussnoten
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx> // fuer SwField ...
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx> // fuer SwField ...
+#endif
+#ifndef _FORMAT_HXX
+#include <format.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx> // fuer SwPageDesc...
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx> // fuer Datum-Felder
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx> // fuer Numrules
+#endif
+#ifndef _NDINDEX_HXX
+#include <ndindex.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+#ifndef _SWRECT_HXX //autogen
+#include <swrect.hxx>
+#endif
+#ifndef _REFFLD_HXX //autogen wg. SwGetRefField
+#include <reffld.hxx>
+#endif
+#ifndef _FTNINFO_HXX
+#include <ftninfo.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx>
+#endif
+#ifndef SW_LINEINFO_HXX
+#include <lineinfo.hxx>
+#endif
+#ifndef SW_FMTLINE_HXX
+#include <fmtline.hxx>
+#endif
+#ifndef _TOX_HXX
+#include <tox.hxx>
+#endif
+#ifndef _FMTFTNTX_HXX
+#include <fmtftntx.hxx>
+#endif
+
+
+#ifdef DEBUG
+# ifndef _FMTCNTNT_HXX
+# include <fmtcntnt.hxx>
+# endif
+#endif
+
+#ifndef _WRTWW8_HXX
+#include <wrtww8.hxx>
+#endif
+
+
+#define APP_ASC(s) AppendAscii( RTL_CONSTASCII_STRINGPARAM( s ))
+#define ASIGN_ASC(s) AssignAscii( RTL_CONSTASCII_STRINGPARAM( s ))
+#define CREA_ASC(s) String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( s ))
+
+/*
+ * um nicht immer wieder nach einem Update festzustellen, das irgendwelche
+ * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle
+ * definiert und mit der akt. verglichen. Bei unterschieden wird der
+ * Compiler schon meckern.
+ *
+ * diese Section und die dazugeherigen Tabellen muessen in folgenden Files
+ * gepflegt werden: rtf\rtfatr.cxx, sw6\sw6atr.cxx, w4w\w4watr.cxx
+*/
+
+#if !defined(MSC) && !defined(UNX) && !defined(PPC) && !defined(CSET) && !defined(__MWERKS__) && !defined(WTC)
+
+#define ATTRFNTAB_SIZE 121
+#if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN
+#error "Attribut-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
+#endif
+
+#if 0
+#define FORMATTAB_SIZE 6
+#if FORMATTAB_SIZE != RES_FMT_END - RES_FMT_BEGIN
+#error "Format-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
+#endif
+#endif
+
+#define NODETAB_SIZE 3
+#if NODETAB_SIZE != RES_NODE_END - RES_NODE_BEGIN
+#error "Node-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
+#endif
+
+#endif
+
+
+
+extern void sw3io_ConvertToOldField( const SwField* pFld, USHORT& rWhich,
+ ULONG& rFmt, ULONG nFFVersion );
+
+
+//#define WW8_OUT( rWrt, a ) ((SwWW8Writer&)rWrt).pO->Insert( (BYTE*)&a,\
+// sizeof( a ), ((SwWW8Writer&)rWrt).pO->Count() )
+
+#define WW8_OUT( rWrt, a ) \
+ ((SwWW8Writer&)rWrt).OutSprmBytes( (BYTE*)&a, sizeof( a ) )
+
+
+
+//------------------------------------------------------------
+// Forward-Declarationen
+//------------------------------------------------------------
+static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt );
+static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt );
+
+//------------------------------------------------------------
+// Hilfsroutinen fuer Styles
+//------------------------------------------------------------
+
+/*
+ * Format wie folgt ausgeben:
+ * - gebe die Attribute aus; ohne Parents!
+ */
+
+void SwWW8Writer::Out_SfxItemSet( const SfxItemSet& rSet,
+ BOOL bPapFmt, BOOL bChpFmt )
+{
+ if( rSet.Count() )
+ {
+ const SfxPoolItem* pItem;
+ FnAttrOut pOut;
+
+ pISet = &rSet; // fuer Doppel-Attribute
+
+ // first the NumRule and than the LRSpace, so will W97 understand it
+ // and move away the paragraph from the left side
+ if( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE,
+ FALSE, &pItem ))
+ {
+ pOut = aWW8AttrFnTab[ RES_PARATR_NUMRULE - RES_CHRATR_BEGIN ];
+ (*pOut)( *this, *pItem );
+ }
+
+ SfxItemIter aIter( rSet );
+ pItem = aIter.GetCurItem();
+
+ do {
+ register USHORT nWhich = pItem->Which();
+ pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN];
+ if( 0 != pOut && (!bPapFmt || RES_PARATR_NUMRULE != nWhich ))
+ {
+ BOOL bChp = nWhich >= RES_CHRATR_BEGIN
+ && nWhich < RES_TXTATR_END;
+ BOOL bPap = nWhich >= RES_PARATR_BEGIN
+ && nWhich < RES_FRMATR_END;
+ if( ( bChpFmt && bChp ) || ( bPapFmt && bPap ) )
+ (*pOut)( *this, *pItem );
+ }
+ } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
+
+ pISet = 0; // fuer Doppel-Attribute
+ }
+}
+
+// Da WW nur Break-After ( Pagebreak und Sectionbreaks ) kennt, im SW aber
+// Bagebreaks "vor" und "nach" und Pagedescs nur "vor" existieren, werden
+// die Breaks 2* durchgeklimpert, naemlich vor und hinter jeder Zeile.
+// Je nach BreakTyp werden sie vor oder nach der Zeile gesetzt.
+// Es duerfen nur Funktionen gerufen werden, die nicht in den
+// Ausgabebereich pO schreiben, da dieser nur einmal fuer CHP und PAP existiert
+// und damit im falschen landen wuerden.
+void SwWW8Writer::Out_SfxBreakItems( const SfxItemSet& rSet, const SwNode& rNd )
+{
+ if( rSet.Count() )
+ {
+ bBreakBefore = TRUE;
+
+ const SfxPoolItem* pItem;
+ if( !bStyDef && !bOutKF && !bOutPageDescs && SFX_ITEM_SET ==
+ rSet.GetItemState( RES_PAGEDESC, FALSE, &pItem ) &&
+ ((SwFmtPageDesc*)pItem)->GetRegisteredIn() )
+ {
+ // Die PageDescs werden beim Auftreten von PageDesc-Attributen nur
+ // in WW8Writer::pSepx mit der entsprechenden Position eingetragen.
+ // Das Aufbauen und die Ausgabe der am PageDesc haengenden Attribute
+ // und Kopf/Fusszeilen passiert nach dem Haupttext und seinen Attributen.
+ const SwFmtPageDesc& rPgDesc = *(SwFmtPageDesc*)pItem;
+ pAktPageDesc = rPgDesc.GetPageDesc();
+ if( pAktPageDesc )
+ {
+ ULONG nFcPos = ReplaceCr( 0x0c ); // Page/Section-Break
+
+ // tatsaechlich wird hier NOCH NICHTS ausgegeben, sondern
+ // nur die Merk-Arrays aCps, aSects entsprechend ergaenzt
+ if( nFcPos )
+ pSepx->AppendSep( Fc2Cp( nFcPos ), rPgDesc, rNd,
+ ((SwFmtLineNumber&)rSet.Get(
+ RES_LINENUMBER )).GetStartValue());
+ }
+ }
+ else if( SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, FALSE, &pItem ) )
+ OutWW8_SwFmtBreak( *this, *pItem );
+
+ bBreakBefore = FALSE;
+ }
+}
+
+void SwWW8Writer::CorrTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft )
+{
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, TRUE, &pItem ))
+ {
+ // dann muss das fuer die Ausgabe korrigiert werden
+ SvxTabStopItem aTStop( *(SvxTabStopItem*)pItem );
+ for( USHORT nCnt = 0; nCnt < aTStop.Count(); ++nCnt )
+ {
+ SvxTabStop& rTab = (SvxTabStop&)aTStop[ nCnt ];
+ if( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() &&
+ rTab.GetTabPos() >= nAbsLeft )
+ rTab.GetTabPos() -= nAbsLeft;
+ else
+ {
+ aTStop.Remove( nCnt );
+ --nCnt;
+ }
+ }
+ rSet.Put( aTStop );
+ }
+}
+
+BYTE SwWW8Writer::GetNumId( USHORT eNumType )
+{
+ BYTE nRet = 0;
+ switch( eNumType )
+ {
+ case SVX_NUM_CHARS_UPPER_LETTER:
+ case SVX_NUM_CHARS_UPPER_LETTER_N: nRet = 3; break;
+ case SVX_NUM_CHARS_LOWER_LETTER:
+ case SVX_NUM_CHARS_LOWER_LETTER_N: nRet = 4; break;
+ case SVX_NUM_ROMAN_UPPER: nRet = 1; break;
+ case SVX_NUM_ROMAN_LOWER: nRet = 2; break;
+
+ case SVX_NUM_BITMAP:
+ case SVX_NUM_CHAR_SPECIAL: nRet = 23; break;
+
+ // nix, macht WW undokumentiert auch so
+ case SVX_NUM_NUMBER_NONE: nRet = 0xff; break;
+ }
+ return nRet;
+}
+
+void SwWW8Writer::Out_SwFmt( const SwFmt& rFmt, BOOL bPapFmt, BOOL bChpFmt,
+ BOOL bFlyFmt )
+{
+ BOOL bCallOutSet = TRUE;
+ const SwModify* pOldMod = pOutFmtNode;
+ pOutFmtNode = &rFmt;
+
+ switch( rFmt.Which() )
+ {
+ case RES_CONDTXTFMTCOLL:
+ case RES_TXTFMTCOLL:
+ if( bPapFmt )
+ {
+ BYTE nLvl = ((const SwTxtFmtColl&)rFmt).GetOutlineLevel();
+ if( MAXLEVEL > nLvl )
+ {
+ // if Write StyleDefinition then write the OutlineRule
+ const SwNumFmt& rNFmt = pDoc->GetOutlineNumRule()->Get(nLvl);
+ if( bStyDef )
+ {
+ if( nLvl >= nWW8MaxListLevel )
+ nLvl = nWW8MaxListLevel-1;
+
+ if( bWrtWW8 )
+ {
+ // write sprmPIlvl and sprmPIlfo
+ SwWW8Writer::InsUInt16( *pO, 0x260a );
+ pO->Insert( nLvl, pO->Count() );
+ SwWW8Writer::InsUInt16( *pO, 0x460b );
+ SwWW8Writer::InsUInt16( *pO, 1 + GetId(
+ *pDoc->GetOutlineNumRule() ) );
+ }
+ else
+ {
+ Out_SwNumLvl( nLvl );
+ if( rNFmt.GetAbsLSpace() )
+ {
+ SwNumFmt aNumFmt( rNFmt );
+ const SvxLRSpaceItem& rLR = (SvxLRSpaceItem&)
+ rFmt.GetAttr( RES_LR_SPACE );
+ aNumFmt.SetAbsLSpace( aNumFmt.GetAbsLSpace() +
+ rLR.GetLeft() );
+ Out_NumRuleAnld( *pDoc->GetOutlineNumRule(),
+ aNumFmt, nLvl );
+ }
+ else
+ Out_NumRuleAnld( *pDoc->GetOutlineNumRule(),
+ rNFmt, nLvl );
+ }
+ }
+
+ if( rNFmt.GetAbsLSpace() )
+ {
+ SfxItemSet aSet( rFmt.GetAttrSet() );
+ SvxLRSpaceItem aLR( (SvxLRSpaceItem&)aSet.Get( RES_LR_SPACE ) );
+
+ aLR.SetTxtLeft( aLR.GetTxtLeft() + rNFmt.GetAbsLSpace() );
+ aLR.SetTxtFirstLineOfst( rNFmt.GetFirstLineOffset() );
+
+ aSet.Put( aLR );
+ SwWW8Writer::CorrTabStopInSet( aSet, rNFmt.GetAbsLSpace() );
+ Out_SfxItemSet( aSet, bPapFmt, bChpFmt );
+ bCallOutSet = FALSE;
+ }
+ }
+ }
+ break;
+
+ case RES_CHRFMT: break;
+ case RES_FLYFRMFMT:
+ if( bFlyFmt )
+ {
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
+ RES_FRMATR_END-1 );
+ aSet.Set( pFlyFmt->GetAttrSet() );
+
+ // Fly als Zeichen werden bei uns zu Absatz-gebundenen
+ // jetzt den Abstand vom Absatz-Rand setzen
+ if( pFlyOffset )
+ {
+ aSet.Put( SwFmtVertOrient( pFlyOffset->Y() ));
+ aSet.Put( SwFmtHoriOrient( pFlyOffset->X() ));
+ }
+
+ if( SFX_ITEM_SET != aSet.GetItemState( RES_SURROUND ))
+ aSet.Put( SwFmtSurround( SURROUND_NONE ) );
+
+ bOutFlyFrmAttrs = TRUE;
+ Out_SfxItemSet( aSet, TRUE, FALSE );
+ bOutFlyFrmAttrs = FALSE;
+
+ bCallOutSet = FALSE;
+ }
+ break;
+ default: ASSERT( !this, "Was wird hier ausgegeben ??? " );
+ break;
+ }
+
+ if( bCallOutSet )
+ Out_SfxItemSet( rFmt.GetAttrSet(), bPapFmt, bChpFmt );
+ pOutFmtNode = pOldMod;
+}
+
+BOOL SwWW8Writer::HasRefToObject( USHORT nTyp, const String* pNm,
+ USHORT nSeqNo )
+{
+ BOOL bFnd = FALSE;
+ const SwTxtNode* pNd;
+ SwClientIter aIter( *pDoc->GetSysFldType( RES_GETREFFLD ));
+ for( SwFmtFld* pFld = (SwFmtFld*)aIter.First( TYPE( SwFmtFld ));
+ pFld && !bFnd; pFld = (SwFmtFld*)aIter.Next() )
+ if( pFld->GetTxtFld() && nTyp == pFld->GetFld()->GetSubType() &&
+ 0 != ( pNd = pFld->GetTxtFld()->GetpTxtNode() ) &&
+ pNd->GetNodes().IsDocNodes() )
+ {
+ const SwGetRefField& rRFld = *(SwGetRefField*)pFld->GetFld();
+ switch( nTyp )
+ {
+ case REF_BOOKMARK:
+ case REF_SETREFATTR: bFnd = *pNm == rRFld.GetSetRefName(); break;
+ case REF_FOOTNOTE:
+ case REF_ENDNOTE: bFnd = nSeqNo == rRFld.GetSeqNo(); break;
+
+ case REF_SEQUENCEFLD: break; // ???
+ case REF_OUTLINE: break; // ???
+ }
+ }
+
+ return bFnd;
+}
+
+String SwWW8Writer::GetBookmarkName( USHORT nTyp, const String* pNm,
+ USHORT nSeqNo )
+{
+ String sRet;
+ switch( nTyp )
+ {
+ case REF_SETREFATTR: (sRet.APP_ASC( "Ref_" )) += *pNm; break;
+ case REF_SEQUENCEFLD: break; // ???
+ case REF_BOOKMARK: sRet = *pNm; break;
+ case REF_OUTLINE: break; // ???
+ case REF_FOOTNOTE: (sRet.APP_ASC( "_RefF" ))
+ += String::CreateFromInt32( nSeqNo );
+ break;
+ case REF_ENDNOTE: (sRet.APP_ASC( "_RefE" ))
+ += String::CreateFromInt32( nSeqNo );
+ break;
+ }
+ return sRet;
+}
+
+//-----------------------------------------------------------------------
+/* */
+/* File CHRATR.HXX: */
+
+static Writer& OutWW8_SwBoldUSW( Writer& rWrt, BYTE nId, BOOL bVal )
+{
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 7 == nId ? 0x2a53 : 0x0835 + nId );
+ else if( 7 == nId )
+ return rWrt; // das Attribut gibt es im WW6 nicht
+ else
+ rWrtWW8.pO->Insert( 85 + nId, rWrtWW8.pO->Count() );
+ rWrtWW8.pO->Insert( bVal ? 1 : 0, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+static Writer& OutWW8_SwFont( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxFontItem& rAttr = (const SvxFontItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ USHORT nFontID= rWrtWW8.GetId( rAttr );
+
+ if( rWrtWW8.bWrtWW8 )
+ {
+ // what about sprmCIdctHint (286F) ??
+ rWrtWW8.InsUInt16( 0x4a4f );
+ rWrtWW8.InsUInt16( nFontID );
+ rWrtWW8.InsUInt16( 0x4a51 );
+ }
+ else
+ rWrtWW8.pO->Insert( 93, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( nFontID );
+ return rWrt;
+}
+
+static Writer& OutWW8_SwPosture( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ return OutWW8_SwBoldUSW( rWrt, 1,
+ ITALIC_NONE != ((const SvxPostureItem&)rHt).GetPosture() );
+}
+
+static Writer& OutWW8_SwWeight( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ return OutWW8_SwBoldUSW( rWrt, 0,
+ WEIGHT_BOLD == ((const SvxWeightItem&)rHt).GetWeight() );
+}
+
+// Shadowed und Contour gibts in WW-UI nicht. JP: ??
+static Writer& OutWW8_SwContour( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ return OutWW8_SwBoldUSW( rWrt, 3,
+ ((const SvxContourItem&)rHt).GetValue() );
+}
+
+static Writer& OutWW8_SwShadow( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ return OutWW8_SwBoldUSW( rWrt, 4,
+ ((const SvxShadowedItem&)rHt).GetValue() );
+}
+
+static Writer& OutWW8_SwKerning( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxKerningItem& rAttr = (const SvxKerningItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x8840 );
+ else
+ rWrtWW8.pO->Insert( 96, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( rAttr.GetValue() );
+ return rWrt;
+}
+
+static Writer& OutWW8_SvxAutoKern( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxAutoKernItem& rAttr = (const SvxAutoKernItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x484B );
+ else
+ rWrtWW8.pO->Insert( 107, rWrtWW8.pO->Count() );
+ rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+
+static Writer& OutWW8_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ FontStrikeout eSt = ((const SvxCrossedOutItem&)rHt).GetStrikeout();
+ if( STRIKEOUT_DOUBLE == eSt )
+ return OutWW8_SwBoldUSW( rWrt, 7, TRUE );
+ if( STRIKEOUT_NONE != eSt )
+ return OutWW8_SwBoldUSW( rWrt, 2, TRUE );
+
+ // dann auch beide ausschalten!
+ OutWW8_SwBoldUSW( rWrt, 7, FALSE );
+ return OutWW8_SwBoldUSW( rWrt, 2, FALSE );
+}
+
+static Writer& OutWW8_SwCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ USHORT eSt = ((const SvxCaseMapItem&)rHt).GetValue();
+ if( SVX_CASEMAP_KAPITAELCHEN == eSt )
+ return OutWW8_SwBoldUSW( rWrt, 5, TRUE );
+ if( SVX_CASEMAP_VERSALIEN == eSt )
+ return OutWW8_SwBoldUSW( rWrt, 6, TRUE );
+
+ // dann auch beide ausschalten!
+ OutWW8_SwBoldUSW( rWrt, 5, FALSE );
+ return OutWW8_SwBoldUSW( rWrt, 6, FALSE );
+}
+
+static Writer& OutWW8_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxUnderlineItem& rAttr = (const SvxUnderlineItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2A3E );
+ else
+ rWrtWW8.pO->Insert( 94, rWrtWW8.pO->Count() );
+
+ const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem(
+ RES_CHRATR_WORDLINEMODE );
+ BOOL bWord = pItem ? ((const SvxWordLineModeItem*)pItem)->GetValue() : FALSE;
+
+ // WW95 - parameters: 0 = none, 1 = single, 2 = by Word,
+ // 3 = double, 4 = dotted, 5 = hidden
+ // WW97 - additional parameters:
+ // 6 = thick, 7 = dash, 8 = dot(not used)
+ // 9 = dotdash 10 = dotdotdash, 11 = wave
+ BYTE b = 0;
+ switch( rAttr.GetUnderline() )
+ {
+ case UNDERLINE_SINGLE: b = ( bWord ) ? 2 : 1; break;
+ case UNDERLINE_BOLD: b = rWrtWW8.bWrtWW8 ? 6 : 1; break;
+ case UNDERLINE_DOUBLE: b = 3; break;
+ case UNDERLINE_DOTTED: b = 4; break;
+ case UNDERLINE_DASH: b = rWrtWW8.bWrtWW8 ? 7 : 4; break;
+ case UNDERLINE_DASHDOT: b = rWrtWW8.bWrtWW8 ? 9 : 4; break;
+ case UNDERLINE_DASHDOTDOT: b = rWrtWW8.bWrtWW8 ? 10 : 4; break;
+ case UNDERLINE_WAVE: b = rWrtWW8.bWrtWW8 ? 11 : 3; break;
+ // ------------- new in WW2000 -------------------------------------
+ case UNDERLINE_BOLDDOTTED: b = rWrtWW8.bWrtWW8 ? 20 : 4; break;
+ case UNDERLINE_BOLDDASH: b = rWrtWW8.bWrtWW8 ? 23 : 4; break;
+ case UNDERLINE_LONGDASH: b = rWrtWW8.bWrtWW8 ? 39 : 4; break;
+ case UNDERLINE_BOLDLONGDASH: b = rWrtWW8.bWrtWW8 ? 55 : 4; break;
+ case UNDERLINE_BOLDDASHDOT: b = rWrtWW8.bWrtWW8 ? 25 : 4; break;
+ case UNDERLINE_BOLDDASHDOTDOT: b = rWrtWW8.bWrtWW8 ? 26 : 4; break;
+ case UNDERLINE_BOLDWAVE: b = rWrtWW8.bWrtWW8 ? 27 : 3; break;
+ case UNDERLINE_DOUBLEWAVE: b = rWrtWW8.bWrtWW8 ? 43 : 3; break;
+ }
+
+ rWrtWW8.pO->Insert( b, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+static Writer& OutWW8_SwLanguage( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxLanguageItem& rAttr = (const SvxLanguageItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x486D ); // use sprmCRgLid0 rather than sprmCLid
+ else
+ rWrtWW8.pO->Insert( 97, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( rAttr.GetLanguage() );
+ return rWrt;
+}
+
+static Writer& OutWW8_SwEscapement( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxEscapementItem& rAttr = (const SvxEscapementItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+
+ BYTE b = 0xFF;
+ short nEsc = rAttr.GetEsc(), nProp = rAttr.GetProp();
+ if( !nEsc )
+ {
+ b = 0;
+ nEsc = 0;
+ nProp = 100;
+ }
+ else if( DFLT_ESC_PROP == nProp )
+ {
+ if( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
+ b = 2;
+ else if( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
+ b = 1;
+ }
+
+ if( 0xFF != b )
+ {
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2A48 );
+ else
+ rWrtWW8.pO->Insert( 104, rWrtWW8.pO->Count() );
+ rWrtWW8.pO->Insert( b, rWrtWW8.pO->Count() );
+ }
+
+ if( 0 == b || 0xFF == b )
+ {
+ long nHeight = ((SvxFontHeightItem&)rWrtWW8.GetItem(
+ RES_CHRATR_FONTSIZE )).GetHeight();
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x4845 );
+ else
+ rWrtWW8.pO->Insert( 101, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( (short)(( nHeight * nEsc + 500 ) / 1000 ));
+
+ if( 100 != nProp || !b )
+ {
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x4A43 );
+ else
+ rWrtWW8.pO->Insert( 99, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( ( nHeight * nProp + 500 ) / 1000 );
+ }
+ }
+ return rWrt;
+}
+
+static Writer& OutWW8_SwSize( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxFontHeightItem& rAttr = (const SvxFontHeightItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x4A43 );
+ else
+ rWrtWW8.pO->Insert( 99, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( (UINT16)(( rAttr.GetHeight() + 5 ) / 10 ) );
+ return rWrt;
+}
+
+
+// TransCol uebersetzt SW-Farben in WW. Heraus kommt die bei WW fuer
+// Text- und Hintergrundfarbe benutzte Codierung.
+// Gibt es keine direkte Entsprechung, dann wird versucht, eine moeglichst
+// aehnliche WW-Farbe zu finden.
+// return: 5-Bit-Wert ( 0..16 )
+BYTE SwWW8Writer::TransCol( const Color& rCol )
+{
+ BYTE nCol = 0; // ->Auto
+ switch( rCol.GetColor() )
+ {
+ case COL_BLACK: nCol = 1; break;
+ case COL_BLUE: nCol = 9; break;
+ case COL_GREEN: nCol = 11; break;
+ case COL_CYAN: nCol = 10; break;
+ case COL_RED: nCol = 13; break;
+ case COL_MAGENTA: nCol = 12; break;
+ case COL_BROWN: nCol = 14; break;
+ case COL_GRAY: nCol = 15; break;
+ case COL_LIGHTGRAY: nCol = 16; break;
+ case COL_LIGHTBLUE: nCol = 2; break;
+ case COL_LIGHTGREEN: nCol = 4; break;
+ case COL_LIGHTCYAN: nCol = 3; break;
+ case COL_LIGHTRED: nCol = 6; break;
+ case COL_LIGHTMAGENTA: nCol = 5; break;
+ case COL_YELLOW: nCol = 7; break;
+ case COL_WHITE: nCol = 8; break;
+
+ default:
+ if( !pBmpPal )
+ {
+ pBmpPal = new BitmapPalette( 16 );
+ static const ColorData aColArr[ 16 ] = {
+ COL_BLACK, COL_LIGHTBLUE, COL_LIGHTCYAN, COL_LIGHTGREEN,
+ COL_LIGHTMAGENTA,COL_LIGHTRED, COL_YELLOW, COL_WHITE,
+ COL_BLUE, COL_CYAN, COL_GREEN, COL_MAGENTA,
+ COL_RED, COL_BROWN, COL_GRAY, COL_LIGHTGRAY
+ };
+
+ for( int i = 0; i < 16; ++i )
+ pBmpPal->operator[]( i ) = Color( aColArr[ i ] );
+ }
+ nCol = pBmpPal->GetBestIndex( rCol ) + 1;
+ break;
+ }
+ return nCol;
+}
+
+// TransBrush uebersetzt SW-Brushes in WW. Heraus kommt WW8_SHD.
+// Nicht-Standardfarben des SW werden noch nicht in die
+// Misch-Werte ( 0 .. 95% ) vom WW uebersetzt.
+// Return: Echte Brush ( nicht transparent )
+// auch bei Transparent wird z.B. fuer Tabellen eine transparente Brush
+// geliefert
+BOOL SwWW8Writer::TransBrush( const Color& rCol, WW8_SHD& rShd )
+{
+ if( rCol.GetTransparency() )
+ rShd = WW8_SHD(); // alles Nullen : transparent
+ else
+ {
+ rShd.SetFore( 8);
+ rShd.SetBack( TransCol( rCol ) );
+ rShd.SetStyle( bWrtWW8, 0 );
+ }
+ return !rCol.GetTransparency();
+}
+
+static Writer& OutWW8_SwColor( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SvxColorItem& rAttr = (const SvxColorItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2A42 );
+ else
+ rWrtWW8.pO->Insert( 98, rWrtWW8.pO->Count() );
+
+ rWrtWW8.pO->Insert( rWrtWW8.TransCol( ((const SvxColorItem&)rHt).
+ GetValue() ), rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+static Writer& OutWW8_SwFmtCharBackground( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+
+ if( rWW8Wrt.bWrtWW8 ) // nur WW8 kann ZeichenHintergrund
+ {
+ const SvxBrushItem& rBack = (const SvxBrushItem&)rHt;
+ WW8_SHD aSHD;
+
+ if( rWW8Wrt.TransBrush( rBack.GetColor(), aSHD ) )
+ {
+ // sprmCShd
+ rWW8Wrt.InsUInt16( 0x4866 );
+ rWW8Wrt.InsUInt16( aSHD.GetValue() );
+ }
+ }
+ return rWrt;
+}
+
+static Writer& OutSwFmtINetFmt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ const SwFmtINetFmt& rINet = (SwFmtINetFmt&)rHt;
+
+ if( rINet.GetValue().Len() )
+ {
+ USHORT nId;
+ const String& rStr = rINet.GetINetFmt();
+ if( rStr.Len() )
+ nId = rINet.GetINetFmtId();
+ else
+ nId = RES_POOLCHR_INET_NORMAL;
+
+ const SwCharFmt* pFmt = IsPoolUserFmt( nId )
+ ? rWrt.pDoc->FindCharFmtByName( rStr )
+ : rWrt.pDoc->GetCharFmtFromPool( nId );
+
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x4A30 );
+ else
+ rWrtWW8.pO->Insert( 80, rWrtWW8.pO->Count() );
+
+ rWrtWW8.InsUInt16( rWrtWW8.GetId( *pFmt ) );
+ }
+ return rWrt;
+}
+
+
+static void InsertSpecialChar( SwWW8Writer& rWrt, BYTE c )
+{
+ WW8Bytes aItems;
+ if( rWrt.pChpIter )
+ rWrt.pChpIter->GetItems( aItems );
+
+ if( 0x13 == c )
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell() );
+ else
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(),
+ aItems.GetData() );
+
+ // at end the attributes writes by the Textnode
+ if( 0x15 == c )
+ aItems.Remove( 0, aItems.Count() );
+
+ rWrt.WriteChar( c );
+
+ // fSpec-Attribut TRUE
+ if( rWrt.bWrtWW8 )
+ SwWW8Writer::InsUInt16( aItems, 0x855 );
+ else
+ aItems.Insert( 117, aItems.Count() );
+ aItems.Insert( 1, aItems.Count() );
+
+ rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(),
+ aItems.GetData() );
+}
+
+
+void SwWW8Writer::OutField( const SwField* pFld, BYTE nFldType,
+ const String& rFldCmd, BYTE nMode )
+{
+ static BYTE aFld13[2] = { 0x13, 0x00 }; // will change
+ static BYTE __READONLY_DATA aFld14[2] = { 0x14, 0xff };
+ static BYTE __READONLY_DATA aFld15[2] = { 0x15, 0x80 };
+
+ BOOL bUnicode = IsUnicode();
+ WW8_WrPlcFld* pFldP;
+ switch ( nTxtTyp )
+ {
+ case TXT_MAINTEXT: pFldP = pFldMain; break;
+ case TXT_HDFT: pFldP = pFldHdFt; break;
+ case TXT_FTN: pFldP = pFldFtn; break;
+ case TXT_EDN: pFldP = pFldEdn; break;
+ case TXT_TXTBOX: pFldP = pFldTxtBxs; break;
+ case TXT_HFTXTBOX: pFldP = pFldHFTxtBxs; break;
+
+ default:
+ ASSERT( !this, "was ist das fuer ein SubDoc-Type?" );
+ break;
+ }
+
+ if( WRITEFIELD_START & nMode )
+ {
+ aFld13[1] = nFldType; // Typ nachtragen
+ pFldP->Append( Fc2Cp( Strm().Tell() ), aFld13 );
+ InsertSpecialChar( *this, 0x13 );
+ }
+ if( WRITEFIELD_CMD_START & nMode )
+ {
+ if( bUnicode )
+ SwWW8Writer::WriteString16( Strm(), rFldCmd, FALSE );
+ else
+ SwWW8Writer::WriteString8( Strm(), rFldCmd, FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ }
+ if( WRITEFIELD_CMD_END & nMode )
+ {
+// Strm() << " \\* FORMATVERBINDEN ";
+ pFldP->Append( Fc2Cp( Strm().Tell() ), aFld14 );
+ InsertSpecialChar( *this, 0x14 );
+ }
+ if( WRITEFIELD_END & nMode )
+ {
+ String sOut;
+ if( pFld )
+ sOut = pFld->Expand();
+ else
+ sOut = rFldCmd;
+ if( sOut.Len() )
+ {
+ if( bUnicode )
+ SwWW8Writer::WriteString16( Strm(), sOut, FALSE );
+ else
+ SwWW8Writer::WriteString8( Strm(), sOut, FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ }
+ }
+ if( WRITEFIELD_CLOSE & nMode )
+ {
+ pFldP->Append( Fc2Cp( Strm().Tell() ), aFld15 );
+ InsertSpecialChar( *this, 0x15 );
+ }
+}
+
+void SwWW8Writer::StartCommentOutput(const String& rName)
+{
+ String aStr( CREA_ASC( " ANGEBEN [" )); ( aStr += rName ).APP_ASC( "] " );
+ OutField( 0, 35, aStr, WRITEFIELD_START | WRITEFIELD_CMD_START );
+}
+
+void SwWW8Writer::EndCommentOutput(const String& rName)
+{
+ String aStr( CREA_ASC( " [" )); ( aStr += rName ).APP_ASC( "] " );
+ OutField( 0, 35, aStr, WRITEFIELD_CMD_END | WRITEFIELD_END |
+ WRITEFIELD_CLOSE );
+}
+
+
+USHORT SwWW8Writer::GetId( const SwTOXType& rTOXType )
+{
+ void* p = (void*)&rTOXType;
+ USHORT nRet = aTOXArr.GetPos( p );
+ if( USHRT_MAX == nRet )
+ aTOXArr.Insert( p, nRet = aTOXArr.Count() );
+ return nRet;
+}
+
+// return values: 1 - no PageNum,
+// 2 - TabStop before PageNum,
+// 3 - Text before PageNum - rTxt hold the text
+// 4 - no Text and no TabStop before PageNum
+int lcl_CheckForm( const SwForm& rForm, BYTE nLvl, String& rText )
+{
+ int nRet = 4;
+ rText.Erase();
+
+ SwFormTokenEnumerator aIter( rForm.CreateTokenEnumerator( nLvl ));
+ BOOL bPgNumFnd = FALSE;
+ FormTokenType eTType;
+ while( TOKEN_END != ( eTType = aIter.GetNextTokenType() ) && !bPgNumFnd )
+ {
+ switch( eTType )
+ {
+ case TOKEN_PAGE_NUMS:
+ bPgNumFnd = TRUE;
+ break;
+
+ case TOKEN_TAB_STOP:
+ nRet = 2;
+ break;
+ case TOKEN_TEXT:
+ nRet = 3;
+ rText = aIter.GetCurToken().sText.Copy( 0, 5 );
+ break;
+
+ case TOKEN_LINK_START:
+ case TOKEN_LINK_END:
+ break;
+
+ default:
+ nRet = 4;
+ break;
+ }
+ }
+
+ if( !bPgNumFnd )
+ nRet = 1;
+
+ return nRet;
+}
+
+
+void SwWW8Writer::StartTOX( const SwSection& rSect )
+{
+ const SwTOXBase* pTOX = rSect.GetTOXBase();
+ if( pTOX )
+ {
+ static sal_Char __READONLY_DATA sContent[] = " VERZEICHNIS \\w \\x ";
+ static sal_Char __READONLY_DATA sIndex[] = " INDEX ";
+ static sal_Char __READONLY_DATA sEntryEnd[] = "\" ";
+
+
+ BYTE nCode;
+ String aStr;
+ switch( pTOX->GetType() )
+ {
+ case TOX_INDEX:
+ {
+ nCode = 8;
+ aStr.AssignAscii( sIndex );
+
+ if( pTOX->GetTOXForm().IsCommaSeparated() )
+ aStr.APP_ASC( "\\r " );
+
+ if( TOI_ALPHA_DELIMITTER & pTOX->GetOptions() )
+ aStr.APP_ASC( "\\h \"A\" " );
+
+ {
+ String aFillTxt;
+ for( BYTE n = 1; n <= 3; ++n )
+ {
+ String aTxt;
+ int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
+ n, aTxt );
+
+ if( 3 == nRet )
+ aFillTxt = aTxt;
+ else if( 4 == nRet )
+ aFillTxt = '\t';
+ else
+ aFillTxt.Erase();
+ }
+ (aStr.APP_ASC( "\\e \"" )) += aFillTxt;
+ aStr.AppendAscii( sEntryEnd );
+ }
+ }
+ break;
+
+// case TOX_AUTHORITIES: nCode = 73; aStr = ???; break;
+
+ case TOX_ILLUSTRATIONS:
+ case TOX_OBJECTS:
+ case TOX_TABLES:
+ if( !pTOX->IsFromObjectNames() )
+ {
+ nCode = 13;
+ aStr.AssignAscii( sContent );
+
+ (( aStr.APP_ASC( "\\c \"" )) += pTOX->GetSequenceName()
+ ).AppendAscii( sEntryEnd );
+ String aTxt;
+ int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(), 1, aTxt );
+ if( 1 == nRet )
+ aStr.APP_ASC( "\\n " );
+ else if( 3 == nRet || 4 == nRet )
+ (( aStr.APP_ASC( "\\p \"" )) += aTxt ).AppendAscii(sEntryEnd);
+ }
+ break;
+
+// case TOX_USER:
+// case TOX_CONTENT:
+ default:
+ {
+ nCode = 13;
+ aStr.AssignAscii( sContent );
+
+ String sTOption;
+ USHORT n, nTOXLvl = pTOX->GetLevel();
+ if( !nTOXLvl )
+ ++nTOXLvl;
+
+ if( TOX_MARK & pTOX->GetCreateType() )
+ {
+ aStr.APP_ASC( "\\f " );
+
+ if( TOX_USER == pTOX->GetType() )
+ (( aStr += '\"' ) +=
+ (sal_Char)( 'A' + GetId( *pTOX->GetTOXType() ))
+ ).AppendAscii( sEntryEnd );
+ }
+
+ if( TOX_OUTLINELEVEL & pTOX->GetCreateType() )
+ {
+ // are the chapter template the normal headline 1 to 9 ?
+ // search all outlined collections
+ BYTE nLvl, nMinLvl = MAXLEVEL;
+ const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
+ const SwTxtFmtColl* pColl;
+ for( n = rColls.Count(); n; )
+ if( MAXLEVEL > (nLvl = ( pColl =
+ rColls[ --n ] )->GetOutlineLevel() ) &&
+ nMinLvl > nLvl &&
+ ( RES_POOLCOLL_HEADLINE1 > pColl->GetPoolFmtId() ||
+ RES_POOLCOLL_HEADLINE9 < pColl->GetPoolFmtId() ))
+ {
+ nMinLvl = nLvl;
+ }
+
+ nLvl = nMinLvl < nTOXLvl ? nMinLvl : (BYTE)nTOXLvl;
+ if( nLvl )
+ {
+ USHORT nTmpLvl = nLvl + 1;
+ if( nTmpLvl > nWW8MaxListLevel )
+ nTmpLvl = nWW8MaxListLevel;
+
+ ((aStr.APP_ASC( "\\o \"1-" )) +=
+ String::CreateFromInt32( nTmpLvl ))
+ .AppendAscii(sEntryEnd);
+ }
+
+ if( nLvl != nMinLvl )
+ {
+ // collect this templates into the \t otion
+ for( n = rColls.Count(); n; )
+ if( MAXLEVEL > (nLvl = ( pColl =
+ rColls[ --n ] )->GetOutlineLevel() ) &&
+ nMinLvl <= nLvl )
+ {
+ if( sTOption.Len() )
+ sTOption += ';';
+ (( sTOption += pColl->GetName() ) += ';' )
+ += String::CreateFromInt32( nLvl + 1 );
+ }
+ }
+ }
+
+ if( TOX_TEMPLATE & pTOX->GetCreateType() )
+ for( n = 0; n < nTOXLvl; ++n )
+ {
+ const String& rStyles = pTOX->GetStyleNames( n );
+ if( rStyles.Len() )
+ {
+ xub_StrLen nPos = 0;
+ String sLvl( ';' );
+ sLvl += String::CreateFromInt32( n + 1 );
+ do {
+ String sStyle( rStyles.GetToken( 0,
+ TOX_STYLE_DELIMITER, nPos ));
+ if( sStyle.Len() )
+ {
+ if( sTOption.Len() )
+ sTOption += ';';
+ ( sTOption += sStyle ) += sLvl;
+ }
+ } while( STRING_NOTFOUND != nPos );
+ }
+ }
+
+ {
+ String aFillTxt;
+ BYTE nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
+ BOOL bFirstFillTxt = TRUE, bOnlyText = TRUE;
+ for( n = 0; n < nTOXLvl; ++n )
+ {
+ String aTxt;
+ int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
+ n+1, aTxt );
+ if( 1 == nRet )
+ {
+ bOnlyText = FALSE;
+ if( MAXLEVEL == nNoPgStt )
+ nNoPgStt = n+1;
+ }
+ else
+ {
+ if( MAXLEVEL != nNoPgStt &&
+ MAXLEVEL == nNoPgEnd )
+ nNoPgEnd = BYTE(n);
+
+ bOnlyText = bOnlyText && 3 == nRet;
+ if( 3 == nRet || 4 == nRet )
+ {
+ if( bFirstFillTxt )
+ aFillTxt = aTxt;
+ else if( aFillTxt != aTxt )
+ aFillTxt.Erase();
+ bFirstFillTxt = FALSE;
+ }
+ }
+ }
+ if( MAXLEVEL != nNoPgStt )
+ {
+ if( nWW8MaxListLevel < nNoPgEnd )
+ nNoPgEnd = nWW8MaxListLevel;
+ aStr.APP_ASC( "\\n " );
+ (aStr += String::CreateFromInt32( nNoPgStt )) += '-';
+ (aStr += String::CreateFromInt32( nNoPgEnd )) += ' ';
+ }
+ if( bOnlyText )
+ ((aStr.APP_ASC( "\\p \"" )) += aFillTxt )
+ .AppendAscii(sEntryEnd);
+ }
+
+ if( sTOption.Len() )
+ (( aStr.APP_ASC( "\\t \"" )) += sTOption )
+ .AppendAscii(sEntryEnd);
+ }
+ break;
+ }
+
+ if( aStr.Len() )
+ {
+ bInWriteTOX = TRUE;
+ OutField( 0, nCode, aStr, WRITEFIELD_START |
+ WRITEFIELD_CMD_START | WRITEFIELD_CMD_END );
+ }
+ }
+ bStartTOX = FALSE;
+}
+
+void SwWW8Writer::EndTOX( const SwSection& rSect )
+{
+ const SwTOXBase* pTOX = rSect.GetTOXBase();
+ if( pTOX )
+ {
+ BYTE nCode = TOX_INDEX == pTOX->GetType() ? 8 : 13;
+ OutField( 0, nCode, aEmptyStr, WRITEFIELD_CLOSE );
+ }
+ bInWriteTOX = FALSE;
+}
+
+
+
+// GetDatePara, GetTimePara, GetNumberPara modifizieren die String-Ref
+// Es werden die deutschen Format-Spezifier benutzt, da im FIB auch dt. als
+// Creator angegeben ist.
+BOOL SwWW8Writer::GetNumberFmt( const SwField& rFld, String& rStr )
+{
+ BOOL bHasFmt = FALSE;
+ SvNumberFormatter* pNFmtr = pDoc->GetNumberFormatter();
+ UINT32 nFmtIdx = rFld.GetFormat();
+ const SvNumberformat* pNumFmt = pNFmtr->GetEntry( nFmtIdx );
+ if( pNumFmt )
+ {
+ USHORT nLng = rFld.GetLanguage();
+ const International aIntl( nLng );
+ if( !pKeyMap )
+ {
+ pKeyMap = new NfKeywordTable;
+ NfKeywordTable& rKeyMap = *(NfKeywordTable*)pKeyMap;
+// aKeyMap[ NF_KEY_NONE = 0,
+// aKeyMap[ NF_KEY_E,
+// aKeyMap[ NF_KEY_AMPM,
+// aKeyMap[ NF_KEY_AP,
+ rKeyMap[ NF_KEY_MI ].ASIGN_ASC( "m" );
+ rKeyMap[ NF_KEY_MMI ].ASIGN_ASC( "mm" );
+ rKeyMap[ NF_KEY_M ].ASIGN_ASC( "M" );
+ rKeyMap[ NF_KEY_MM ].ASIGN_ASC( "MM" );
+ rKeyMap[ NF_KEY_MMM ].ASIGN_ASC( "MMM" );
+ rKeyMap[ NF_KEY_MMMM ].ASIGN_ASC( "MMMM" );
+ rKeyMap[ NF_KEY_H ].ASIGN_ASC( "H" );
+ rKeyMap[ NF_KEY_HH ].ASIGN_ASC( "HH" );
+ rKeyMap[ NF_KEY_S ].ASIGN_ASC( "s" );
+ rKeyMap[ NF_KEY_SS ].ASIGN_ASC( "ss" );
+// aKeyMap[ NF_KEY_Q,
+// aKeyMap[ NF_KEY_QQ,
+ rKeyMap[ NF_KEY_T ].ASIGN_ASC( "t" );
+ rKeyMap[ NF_KEY_TT ].ASIGN_ASC( "tt" );
+ rKeyMap[ NF_KEY_TTT ].ASIGN_ASC( "ttt" );
+ rKeyMap[ NF_KEY_TTTT ].ASIGN_ASC( "tttt" );
+ rKeyMap[ NF_KEY_JJ ].ASIGN_ASC( "jj" );
+ rKeyMap[ NF_KEY_JJJJ ].ASIGN_ASC( "jjjj" );
+ rKeyMap[ NF_KEY_NN ].ASIGN_ASC( "ttt" );
+ rKeyMap[ NF_KEY_NNNN ].ASIGN_ASC( "tttt" );
+// aKeyMap[ NF_KEY_CCC,
+// aKeyMap[ NF_KEY_GENERAL,
+// aKeyMap[ NF_KEY_NNN,
+// aKeyMap[ NF_KEY_WW,
+// aKeyMap[ NF_KEY_QUARTER,
+// aKeyMap[ NF_KEY_TRUE,
+// aKeyMap[ NF_KEY_FALSE,
+// aKeyMap[ NF_KEY_BOOLEAN,
+ }
+
+ String sFmt( pNumFmt->GetMappedFormatstring(
+ *(NfKeywordTable*)pKeyMap, aIntl, TRUE ));
+ if( sFmt.Len() )
+ {
+ (( rStr.APP_ASC( "\\@\"" )) += sFmt ).APP_ASC( "\" " );
+ bHasFmt = TRUE;
+ }
+ }
+ return bHasFmt;
+}
+
+void WW8_GetNumberPara( String& rStr, const SwField& rFld )
+{
+ switch( rFld.GetFormat() )
+ {
+ case SVX_NUM_CHARS_UPPER_LETTER:
+ case SVX_NUM_CHARS_UPPER_LETTER_N: rStr.APP_ASC( "\\*ALPHABETISCH "); break;
+ case SVX_NUM_CHARS_LOWER_LETTER:
+ case SVX_NUM_CHARS_LOWER_LETTER_N: rStr.APP_ASC("\\*alphabetisch "); break;
+ case SVX_NUM_ROMAN_UPPER: rStr.APP_ASC("\\*R\xd6MISCH "); break;
+ case SVX_NUM_ROMAN_LOWER: rStr.APP_ASC("\\*r\xf6misch "); break;
+ case SVX_NUM_ARABIC: rStr.APP_ASC("\\*Arabisch "); break;
+ }
+}
+
+void SwWW8Writer::WritePostItBegin( const SwPostItField& rPostIt,
+ WW8Bytes* pO )
+{
+ BYTE aArr[ 3 ];
+ BYTE* pArr = aArr;
+
+ // sprmCFSpec TRUE
+ if( bWrtWW8 )
+ Set_UInt16( pArr, 0x855 );
+ else
+ Set_UInt8( pArr, 117 );
+ Set_UInt8( pArr, 1 );
+
+ pChpPlc->AppendFkpEntry( Strm().Tell() );
+ WriteChar( 0x05 ); // Annotation reference
+
+ if( pO )
+ pO->Insert( aArr, pArr - aArr, pO->Count() );
+ else
+ pChpPlc->AppendFkpEntry( Strm().Tell(), pArr - aArr, aArr );
+}
+
+static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SwFmtFld& rFld = (SwFmtFld&)rHt;
+ const SwField* pFld = rFld.GetFld();
+ String aStr; // fuer optionale Parameter
+ BOOL bWriteExpand = FALSE;
+ USHORT nSubType = pFld->GetSubType();
+ BYTE nFldTyp = 0;
+
+ switch( pFld->GetTyp()->Which() )
+ {
+// case RES_CHAPTERFLD:
+// break;
+
+ case RES_SETEXPFLD:
+ if( GSE_SEQ == nSubType )
+ {
+ (( aStr.ASIGN_ASC( " SEQ \"" )) += pFld->GetTyp()->GetName() )
+ .APP_ASC( "\" " );
+ ::WW8_GetNumberPara( aStr, *pFld );
+ rWW8Wrt.OutField( pFld, 12, aStr );
+ }
+ else
+ bWriteExpand = TRUE;
+ break;
+
+ case RES_PAGENUMBERFLD:
+ aStr.ASIGN_ASC( " SEITE " );
+ ::WW8_GetNumberPara( aStr, *pFld );
+ rWW8Wrt.OutField( pFld, 33, aStr );
+ break;
+
+ case RES_FILENAMEFLD:
+ rWW8Wrt.OutField( pFld, 29, CREA_ASC( "DATEINAME" ));
+ break;
+
+ case RES_DBNAMEFLD:
+ aStr.ASIGN_ASC( "DATENBANK " ); // ok ??
+ aStr += rWrt.pDoc->GetDBName();
+ rWW8Wrt.OutField( pFld, 78, aStr );
+ break;
+
+ case RES_AUTHORFLD:
+ rWW8Wrt.OutField( pFld, (AF_SHORTCUT & nSubType ? 61 : 60),
+ CREA_ASC( "AUTOR" ));
+ break;
+
+ case RES_TEMPLNAMEFLD:
+ rWW8Wrt.OutField( pFld, 30, CREA_ASC("DOKVORLAGE" ));
+ break;
+
+ case RES_DOCINFOFLD: // Last printed, last edited,...
+ if( DI_SUB_FIXED & nSubType )
+ bWriteExpand = TRUE;
+ else
+ {
+ static sal_Char __READONLY_DATA sFld15[] = "TITLE";
+ static sal_Char __READONLY_DATA sFld16[] = "THEMA";
+ static sal_Char __READONLY_DATA sFld17[] = "AUTOR ";
+ static sal_Char __READONLY_DATA sFld18[] = "STICHW\xd6RTER";
+ static sal_Char __READONLY_DATA sFld19[] = "KOMMENTAR";
+ static sal_Char __READONLY_DATA sFld20[] = "GESPEICHERTVON";
+ static sal_Char __READONLY_DATA sFld21[] = "ERSTELLDAT ";
+ static sal_Char __READONLY_DATA sFld22[] = "SPEICHERDAT ";
+ static sal_Char __READONLY_DATA sFld23[] = "DRUCKDAT ";
+ static sal_Char __READONLY_DATA sFld24[] = "\xdc" "BERARBEITUNGSNUMMER";
+
+ static const sal_Char* __READONLY_DATA aFldArr[] = {
+ sFld15, sFld16, sFld17, sFld18, sFld19,
+ sFld20, sFld21, sFld22, sFld23, sFld24
+ };
+
+ switch( 0xff & nSubType )
+ {
+ case DI_TITEL: nFldTyp = 15; break;
+ case DI_THEMA: nFldTyp = 16; break;
+ case DI_KEYS: nFldTyp = 18; break;
+ case DI_COMMENT: nFldTyp = 19; break;
+ case DI_DOCNO: nFldTyp = 24; break;
+
+ case DI_CREATE:
+ if( DI_SUB_AUTHOR == (nSubType & ~DI_SUB_AUTHOR ))
+ nFldTyp = 17;
+ else if( rWW8Wrt.GetNumberFmt( *pFld, aStr ))
+ nFldTyp = 21;
+ break;
+
+ case DI_CHANGE:
+ if( DI_SUB_AUTHOR == (nSubType & ~DI_SUB_AUTHOR ))
+ nFldTyp = 20;
+ break;
+
+ case DI_PRINT:
+ if( DI_SUB_AUTHOR != (nSubType & ~DI_SUB_AUTHOR ) &&
+ rWW8Wrt.GetNumberFmt( *pFld, aStr ))
+ nFldTyp = 23;
+ break;
+ case DI_EDIT:
+ if( DI_SUB_AUTHOR != (nSubType & ~DI_SUB_AUTHOR ) &&
+ rWW8Wrt.GetNumberFmt( *pFld, aStr ))
+ nFldTyp = 22;
+ break;
+ }
+
+ if( nFldTyp )
+ {
+ aStr.InsertAscii( aFldArr[ nFldTyp - 15 ], 0 );
+ rWW8Wrt.OutField( pFld, nFldTyp, aStr );
+ }
+ else
+ bWriteExpand = TRUE;
+ }
+ break;
+
+ case RES_DATETIMEFLD:
+ if( FIXEDFLD & nSubType || !rWW8Wrt.GetNumberFmt( *pFld, aStr ) )
+ bWriteExpand = TRUE;
+ else
+ {
+ const sal_Char* pAddStr;
+ USHORT nTyp;
+ if( DATEFLD & nSubType )
+ {
+ pAddStr = " AKTUALDAT ";
+ nTyp = 31;
+ }
+ else
+ {
+ pAddStr = " ZEIT ";
+ nTyp = 32;
+ }
+ aStr.InsertAscii( pAddStr, 0 );
+ rWW8Wrt.OutField( pFld, nTyp, aStr );
+ }
+ break;
+
+ case RES_DOCSTATFLD:
+ {
+ switch( nSubType )
+ {
+ case DS_PAGE: aStr.ASIGN_ASC(" ANZSEITEN "); nFldTyp = 26; break;
+ case DS_WORD: aStr.ASIGN_ASC(" ANZW\xd6RTER "); nFldTyp = 27; break;
+ case DS_CHAR: aStr.ASIGN_ASC(" ANZZEICHEN "); nFldTyp = 28; break;
+ }
+
+ if( nFldTyp )
+ {
+ ::WW8_GetNumberPara( aStr, *pFld );
+ rWW8Wrt.OutField( pFld, nFldTyp, aStr );
+ }
+ else
+ bWriteExpand = TRUE;
+ }
+ break;
+ case RES_EXTUSERFLD:
+ {
+ switch( 0xFF & nSubType )
+ {
+ case EU_FIRSTNAME:
+ case EU_NAME:
+ nFldTyp = 60;
+ aStr.ASIGN_ASC("BENUTZERNAME");
+ break;
+
+ case EU_SHORTCUT:
+ nFldTyp = 61;
+ aStr.ASIGN_ASC("BENUTZERINITIALEN");
+ break;
+
+ case EU_STREET:
+ case EU_COUNTRY:
+ case EU_ZIP:
+ case EU_CITY:
+ nFldTyp = 62;
+ aStr.ASIGN_ASC("BENUTZERADR");
+ break;
+ }
+ if( nFldTyp )
+ rWW8Wrt.OutField( pFld, nFldTyp, aStr );
+ else
+ bWriteExpand = TRUE;
+ }
+ break;
+
+ case RES_POSTITFLD:
+ {
+ const SwPostItField& rPFld = *(SwPostItField*)pFld;
+ rWW8Wrt.pAtn->Append( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ), rPFld );
+ rWW8Wrt.WritePostItBegin( rPFld, rWW8Wrt.pO );
+ }
+ break;
+
+ case RES_INPUTFLD:
+ ((aStr.ASIGN_ASC("EINGEBEN \"" )) += pFld->GetPar2() )+= '\"';
+ rWW8Wrt.OutField( pFld, 39, aStr );
+ break;
+
+ case RES_GETREFFLD:
+ {
+ aStr.ASIGN_ASC(" REF ");
+ const SwGetRefField& rRFld = *(SwGetRefField*)pFld;
+ switch( nSubType )
+ {
+ case REF_SETREFATTR:
+ case REF_BOOKMARK:
+ aStr += rWW8Wrt.GetBookmarkName( nSubType,
+ &rRFld.GetSetRefName(), 0 );
+ nFldTyp = 3;
+ break;
+
+ case REF_FOOTNOTE:
+ case REF_ENDNOTE:
+ aStr += rWW8Wrt.GetBookmarkName( nSubType, 0,
+ rRFld.GetSeqNo() );
+ nFldTyp = REF_ENDNOTE == nSubType ? 72 : 5;
+ switch( pFld->GetFormat() )
+ {
+ case REF_PAGE_PGDESC:
+ case REF_PAGE:
+ case REF_UPDOWN:
+ break;
+ default:
+ aStr.InsertAscii( "FUSSENDNOTE", 1 );
+ break;
+ }
+ break;
+
+// case REF_SEQUENCEFLD: // ???
+// case REF_OUTLINE: // 10
+ // page reference - 37
+ // DDE reference - 45
+ // DDE automatic reference - 46
+ }
+
+ if( nFldTyp )
+ {
+ switch( pFld->GetFormat() )
+ {
+ case REF_PAGE_PGDESC:
+ case REF_PAGE:
+ aStr.InsertAscii( "SEITEN", 1 );
+ nFldTyp = 37;
+ break;
+
+ case REF_UPDOWN:
+ aStr.APP_ASC( " \\p" );
+ nFldTyp = 3;
+ break;
+
+ case REF_CHAPTER:
+ case REF_ONLYNUMBER:
+ case REF_ONLYCAPTION:
+ case REF_ONLYSEQNO:
+ break;
+ // default:
+ // case REF_CONTENT:
+ }
+
+ aStr.APP_ASC( " \\h " ); // insert hyperlink
+ rWW8Wrt.OutField( pFld, nFldTyp, aStr );
+
+ }
+ else
+ bWriteExpand = TRUE;
+ }
+ break;
+
+ default:
+ bWriteExpand = TRUE;
+ break;
+ }
+
+ if( bWriteExpand )
+ {
+ if( rWW8Wrt.IsUnicode() )
+ SwWW8Writer::WriteString16( rWrt.Strm(), pFld->Expand(), FALSE );
+ else
+ SwWW8Writer::WriteString8( rWrt.Strm(), pFld->Expand(), FALSE,
+ RTL_TEXTENCODING_MS_1252 );
+ }
+
+ return rWrt;
+}
+
+static Writer& OutWW8_SwFlyCntnt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.pOutFmtNode && rWrtWW8.pOutFmtNode->ISA( SwCntntNode ))
+ {
+ SwTxtNode* pTxtNd = (SwTxtNode*)rWrtWW8.pOutFmtNode;
+
+ Point aLayPos;
+ aLayPos = pTxtNd->FindLayoutRect( FALSE, &aLayPos ).Pos();
+
+ rWrtWW8.OutWW8FlyFrm( *((SwFmtFlyCnt&)rHt).GetFrmFmt(), aLayPos );
+ }
+ return rWrt;
+}
+
+// TOXMarks fehlen noch
+
+// Detaillierte Einstellungen zur Trennung erlaubt WW nur dokumentenweise.
+// Man koennte folgende Mimik einbauen: Die Werte des Style "Standard" werden,
+// falls vorhanden, in die Document Properties ( DOP ) gesetzt.
+// ---
+// ACK. Dieser Vorschlag passt exakt zu unserer Implementierung des Import,
+// daher setze ich das gleich mal um. (KHZ, 07/15/2000)
+static Writer& OutWW8_SvxHyphenZone( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmPFNoAutoHyph
+ const SvxHyphenZoneItem& rAttr = (const SvxHyphenZoneItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x242A );
+ else
+ rWrtWW8.pO->Insert( 44, rWrtWW8.pO->Count() );
+
+ rWrtWW8.pO->Insert( rAttr.IsHyphen() ? 0 : 1, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+// NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden
+
+static Writer& OutWW8_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ ((SwWW8Writer&)rWrt).WriteChar( ((SwFmtHardBlank&)rHt).GetChar() );
+ return rWrt;
+}
+
+// RefMark, NoLineBreakHere fehlen noch
+
+void SwWW8Writer::WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pOutArr )
+{
+ WW8Bytes aAttrArr;
+ BOOL bAutoNum = !rFtn.GetNumStr().Len(); // Auto-Nummer
+ if( bAutoNum )
+ {
+ if( bWrtWW8 )
+ {
+ static BYTE __READONLY_DATA aSpec[] = {
+ 0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation (wahrscheinlich unnoetig)
+ 0x55, 0x08, 1 // sprmCFSpec
+ };
+
+ aAttrArr.Insert( aSpec, sizeof( aSpec ), aAttrArr.Count() );
+ }
+ else
+ {
+ static BYTE __READONLY_DATA aSpec[] = {
+ 117, 1, // sprmCFSpec
+ 68, 4, 0, 0, 0, 0 // sprmCObjLocation (wahrscheinlich unnoetig)
+ };
+ aAttrArr.Insert( aSpec, sizeof( aSpec ), aAttrArr.Count() );
+ }
+ }
+
+ // sprmCIstd
+ const SwEndNoteInfo* pInfo;
+ if( rFtn.IsEndNote() )
+ pInfo = &pDoc->GetEndNoteInfo();
+ else
+ pInfo = &pDoc->GetFtnInfo();
+ const SwCharFmt* pCFmt = pOutArr
+ ? pInfo->GetAnchorCharFmt( *pDoc )
+ : pInfo->GetCharFmt( *pDoc );
+ if( bWrtWW8 )
+ SwWW8Writer::InsUInt16( aAttrArr, 0x4a30 );
+ else
+ aAttrArr.Insert( 80, aAttrArr.Count() );
+ SwWW8Writer::InsUInt16( aAttrArr, GetId( *pCFmt ) );
+
+ // fSpec-Attribut TRUE
+ // Fuer Auto-Nummer muss ein Spezial-Zeichen
+ // in den Text und darum ein fSpec-Attribut
+ pChpPlc->AppendFkpEntry( Strm().Tell() );
+ if( bAutoNum )
+ WriteChar( 0x02 ); // Auto-Nummer-Zeichen
+ else
+ // User-Nummerierung
+ OutSwString( rFtn.GetNumStr(), 0, rFtn.GetNumStr().Len(),
+ IsUnicode(), RTL_TEXTENCODING_MS_1252 );
+
+ if( pOutArr )
+ {
+ // insert at start of array, so the "hard" attribute overrule the
+ // attributes of the character template
+ pOutArr->Insert( &aAttrArr, 0 );
+ }
+ else
+ {
+ WW8Bytes aOutArr;
+
+ // insert at start of array, so the "hard" attribute overrule the
+ // attributes of the character template
+ aOutArr.Insert( &aAttrArr, 0 );
+
+ // write for the ftn number in the content, the font of the anchor
+ const SwTxtFtn* pTxtFtn = rFtn.GetTxtFtn();
+ if( pTxtFtn )
+ {
+ WW8Bytes* pOld = pO;
+ pO = &aOutArr;
+ SfxItemSet aSet( pDoc->GetAttrPool(), RES_CHRATR_FONT,
+ RES_CHRATR_FONT );
+
+ pCFmt = pInfo->GetCharFmt( *pDoc );
+ aSet.Set( pCFmt->GetAttrSet() );
+
+ pTxtFtn->GetTxtNode().GetAttr( aSet, *pTxtFtn->GetStart(),
+ (*pTxtFtn->GetStart()) + 1 );
+ ::OutWW8_SwFont( *this, aSet.Get( RES_CHRATR_FONT ));
+ pO = pOld;
+ }
+ pChpPlc->AppendFkpEntry( Strm().Tell(), aOutArr.Count(),
+ aOutArr.GetData() );
+ }
+}
+
+static BOOL lcl_IsAtTxtEnd( const SwFmtFtn& rFtn )
+{
+ BOOL bRet = TRUE;
+ if( rFtn.GetTxtFtn() )
+ {
+ USHORT nWh = rFtn.IsEndNote() ? RES_END_AT_TXTEND
+ : RES_FTN_AT_TXTEND;
+ const SwSectionNode* pSectNd = rFtn.GetTxtFtn()->GetTxtNode().
+ FindSectionNode();
+ while( pSectNd && FTNEND_ATPGORDOCEND ==
+ ((const SwFmtFtnAtTxtEnd&)pSectNd->GetSection().GetFmt()->
+ GetAttr( nWh, TRUE )).GetValue() )
+ pSectNd = pSectNd->FindStartNode()->FindSectionNode();
+
+ if( !pSectNd )
+ bRet = FALSE; // the is ftn/end collected at Page- or Doc-End
+ }
+ return bRet;
+}
+
+
+static Writer& OutWW8_SwFtn( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtFtn& rFtn = (const SwFmtFtn&)rHt;
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+
+ USHORT nTyp;
+ WW8_WrPlcFtnEdn* pFtnEnd;
+ if( rFtn.IsEndNote() )
+ {
+ pFtnEnd = rWW8Wrt.pEdn;
+ nTyp = REF_ENDNOTE;
+ if( rWW8Wrt.bEndAtTxtEnd )
+ rWW8Wrt.bEndAtTxtEnd = lcl_IsAtTxtEnd( rFtn );
+ }
+ else
+ {
+ pFtnEnd = rWW8Wrt.pFtn;
+ nTyp = REF_FOOTNOTE;
+ if( rWW8Wrt.bFtnAtTxtEnd )
+ rWW8Wrt.bFtnAtTxtEnd = lcl_IsAtTxtEnd( rFtn );
+ }
+
+ // if any reference to this footnote/endnote then insert an internal
+ // Bookmark.
+ String sBkmkNm;
+ if( rWW8Wrt.HasRefToObject( nTyp, 0, rFtn.GetTxtFtn()->GetSeqRefNo() ))
+ {
+ sBkmkNm = rWW8Wrt.GetBookmarkName( nTyp, 0,
+ rFtn.GetTxtFtn()->GetSeqRefNo() );
+ rWW8Wrt.AppendBookmark( sBkmkNm );
+ }
+
+
+ pFtnEnd->Append( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ), rFtn );
+ rWW8Wrt.WriteFtnBegin( rFtn, rWW8Wrt.pO );
+
+ if( sBkmkNm.Len() )
+ rWW8Wrt.AppendBookmark( sBkmkNm );
+
+ return rWrt;
+}
+
+
+
+static Writer& OutWW8_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtCharFmt& rAttr = (const SwFmtCharFmt&)rHt;
+ if( rAttr.GetCharFmt() )
+ {
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x4A30 );
+ else
+ rWrtWW8.pO->Insert( 80, rWrtWW8.pO->Count() );
+
+ rWrtWW8.InsUInt16( rWrtWW8.GetId( *rAttr.GetCharFmt() ) );
+ }
+ return rWrt;
+}
+
+
+static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SwNumRuleItem& rNumRule = (const SwNumRuleItem&)rHt;
+
+ const SwTxtNode* pTxtNd = 0;
+ USHORT nNumId;
+ BYTE nLvl = 0;
+ if( rNumRule.GetValue().Len() )
+ {
+ const SwNumRule* pRule = rWrt.pDoc->FindNumRulePtr(
+ rNumRule.GetValue() );
+ if( pRule && USHRT_MAX != ( nNumId = rWW8Wrt.GetId( *pRule )) )
+ {
+ ++nNumId;
+ if( rWW8Wrt.pOutFmtNode )
+ {
+ if( rWW8Wrt.pOutFmtNode->ISA( SwCntntNode ))
+ {
+ pTxtNd = (SwTxtNode*)rWW8Wrt.pOutFmtNode;
+ const SwNodeNum* pNum = pTxtNd->GetNum();
+
+ if( pNum && NO_NUM > pNum->GetLevel() )
+ nLvl = GetRealLevel( pNum->GetLevel() );
+ }
+ else if( rWW8Wrt.pOutFmtNode->ISA( SwTxtFmtColl ))
+ {
+ const SwTxtFmtColl* pC = (SwTxtFmtColl*)rWW8Wrt.pOutFmtNode;
+ if( pC && MAXLEVEL > pC->GetOutlineLevel() )
+ nLvl = pC->GetOutlineLevel();
+ }
+ }
+ }
+ else
+ nNumId = USHRT_MAX;
+ }
+ else
+ nNumId = 0;
+
+ if( USHRT_MAX != nNumId )
+ {
+ if( nLvl >= nWW8MaxListLevel )
+ nLvl = nWW8MaxListLevel-1;
+ if( rWW8Wrt.bWrtWW8 )
+ {
+ // write sprmPIlvl and sprmPIlfo
+ SwWW8Writer::InsUInt16( *rWW8Wrt.pO, 0x260a );
+ rWW8Wrt.pO->Insert( nLvl, rWW8Wrt.pO->Count() );
+ SwWW8Writer::InsUInt16( *rWW8Wrt.pO, 0x460b );
+ SwWW8Writer::InsUInt16( *rWW8Wrt.pO, nNumId );
+ }
+ else if( pTxtNd && rWW8Wrt.Out_SwNum( pTxtNd ) ) // NumRules
+ rWW8Wrt.pSepx->SetNum( pTxtNd );
+ }
+ return rWrt;
+}
+
+/* File FRMATR.HXX */
+
+static Writer& OutWW8_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SwFmtFrmSize& rSz = (const SwFmtFrmSize&)rHt;
+
+ if( rWW8Wrt.bOutFlyFrmAttrs ) // Flys
+ {
+ if( rWW8Wrt.bOutGrf )
+ return rWrt; // Fly um Grafik -> Auto-Groesse
+
+//???? was ist bei Prozentangaben ???
+ if( rSz.GetWidth() )
+ {
+ //"sprmPDxaWidth"
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x841A );
+ else
+ rWW8Wrt.pO->Insert( 28, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( (USHORT)rSz.GetWidth() );
+ }
+
+ if( rSz.GetHeight() )
+ {
+ // sprmPWHeightAbs
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x442B );
+ else
+ rWW8Wrt.pO->Insert( 45, rWW8Wrt.pO->Count() );
+
+ USHORT nH = 0;
+ switch( rSz.GetSizeType() )
+ {
+ case ATT_VAR_SIZE: break;
+ case ATT_FIX_SIZE: nH = (USHORT)rSz.GetHeight() & 0x7fff; break;
+ default: nH = (USHORT)rSz.GetHeight() | 0x8000; break;
+ }
+ rWW8Wrt.InsUInt16( nH );
+ }
+ }
+ else if( rWW8Wrt.bOutPageDescs ) // PageDesc : Breite + Hoehe
+ {
+ if( rWW8Wrt.pAktPageDesc->GetLandscape() )
+ {
+ /*sprmSBOrientation*/
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x301d );
+ else
+ rWW8Wrt.pO->Insert( 162, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( 2, rWW8Wrt.pO->Count() );
+ }
+
+ /*sprmSXaPage*/
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xB01F );
+ else
+ rWW8Wrt.pO->Insert( 164, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( (USHORT)rSz.GetWidth() );
+
+ /*sprmSYaPage*/
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xB020 );
+ else
+ rWW8Wrt.pO->Insert( 165, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( (USHORT)rSz.GetHeight() );
+ }
+ return rWrt;
+}
+
+// FillOrder fehlt noch
+
+// ReplaceCr() wird fuer Pagebreaks und Pagedescs gebraucht. Es wird ein
+// bereits geschriebenes CR durch ein Break-Zeichen ersetzt. Replace muss
+// direkt nach Schreiben des CR gerufen werden.
+// Rueckgabe: FilePos des ersetzten CRs + 1 oder 0 fuer nicht ersetzt
+
+ULONG SwWW8Writer::ReplaceCr( BYTE nChar )
+{
+ // Bug #49917#
+ ASSERT( nChar, "gegen 0 ersetzt bringt WW97/95 zum Absturz" );
+
+ ULONG nRetPos = 0, nPos = Strm().Tell();
+ Strm().SeekRel( IsUnicode() ? -2 : -1 );
+ BYTE nC1;
+ Strm().Read( &nC1, 1 );
+ if( nC1 == 0x0d ) // CR ?
+ {
+ Strm().SeekRel( -1 ); // CR hinter Zeile
+ Strm().Write( &nChar, 1 ); // durch nChar ersetzen
+ nRetPos = nPos;
+ }
+ Strm().Seek( nPos );
+
+ if( 0x7 == nC1 ) // at end of TableRow ?
+ {
+ // then write as normal char
+ WriteChar( nChar );
+ nRetPos = Strm().Tell();
+ }
+#ifdef PRODUCT
+ else
+ {
+ ASSERT( nRetPos || nPos == (ULONG)pFib->fcMin,
+ "WW8_ReplaceCr an falscher FilePos gerufen" );
+ }
+#endif
+ return nRetPos;
+}
+
+// Breaks schreiben nichts in das Ausgabe-Feld rWrt.pO,
+// sondern nur in den Text-Stream ( Bedingung dafuer, dass sie von Out_Break...
+// gerufen werden duerfen )
+static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt )
+{
+/*UMSTELLEN*/
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SvxFmtBreakItem &rBreak = (const SvxFmtBreakItem&)rHt;
+
+ if( rWW8Wrt.bStyDef )
+ {
+ switch( rBreak.GetBreak() )
+ {
+//JP 21.06.99: column breaks does never change to pagebreaks
+// case SVX_BREAK_COLUMN_BEFORE:
+// case SVX_BREAK_COLUMN_BOTH:
+
+ case SVX_BREAK_PAGE_BEFORE:
+ case SVX_BREAK_PAGE_BOTH:
+ // sprmPPageBreakBefore/sprmPFPageBreakBefore
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x2407 );
+ else
+ rWW8Wrt.pO->Insert( 9, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( rBreak.GetValue() ? 1 : 0, rWW8Wrt.pO->Count() );
+ break;
+ }
+ }
+ else if( !rWW8Wrt.pFlyFmt )
+ {
+ BYTE nC = 0;
+ BOOL bBefore = FALSE;
+
+ switch( rBreak.GetBreak() )
+ {
+ case SVX_BREAK_NONE: // Ausgeschaltet
+ if( !rWW8Wrt.bBreakBefore )
+ {
+ // sprmPPageBreakBefore/sprmPFPageBreakBefore
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x2407 );
+ else
+ rWW8Wrt.pO->Insert( 9, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( (BYTE)0, rWW8Wrt.pO->Count() );
+ }
+ return rWrt;
+
+ case SVX_BREAK_COLUMN_BEFORE: // ColumnBreak
+ bBefore = TRUE;
+ // no break;
+ case SVX_BREAK_COLUMN_AFTER:
+ case SVX_BREAK_COLUMN_BOTH:
+ nC = 0xe;
+ break;
+
+ case SVX_BREAK_PAGE_BEFORE: // PageBreak
+ bBefore = TRUE;
+ // no break;
+ case SVX_BREAK_PAGE_AFTER:
+ case SVX_BREAK_PAGE_BOTH:
+ nC = 0xc;
+ break;
+ }
+
+ if( (bBefore == rWW8Wrt.bBreakBefore ) && nC ) // #49917#
+ rWW8Wrt.ReplaceCr( nC );
+ }
+ return rWrt;
+}
+
+static Writer& OutWW8_SvxPaperBin( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ const SvxPaperBinItem& rItem = (const SvxPaperBinItem&)rHt;
+
+ if( rWrtWW8.bOutPageDescs )
+ {
+ USHORT nVal;
+ switch( rItem.GetValue() )
+ {
+ case 0: nVal = 15; break; // Automatically select
+ case 1: nVal = 1; break; // Upper paper tray
+ case 2: nVal = 4; break; // Manual paper feed
+ default: nVal = 0; break;
+ }
+
+ if( nVal )
+ {
+ // sprmSDmBinFirst 0x5007 word
+ // sprmSDmBinOther 0x5008 word
+ BYTE nOff = rWrtWW8.bOutFirstPage ? 0 : 1;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x5007 + nOff );
+ else
+ rWrtWW8.pO->Insert( 140 + nOff, rWrtWW8.pO->Count() );
+ rWrtWW8.InsUInt16( nVal );
+ }
+ }
+ return rWrt;
+}
+
+static Writer& OutWW8_SwFmtLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SvxLRSpaceItem & rLR = (const SvxLRSpaceItem&) rHt;
+
+
+ // Flys fehlen noch ( siehe RTF )
+
+ if( rWW8Wrt.bOutFlyFrmAttrs ) // Flys
+ {
+ // sprmPDxaFromText10
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x4622 );
+ else
+ rWW8Wrt.pO->Insert( 49, rWW8Wrt.pO->Count() );
+ // Mittelwert nehmen, da WW nur 1 Wert kennt
+ rWW8Wrt.InsUInt16( (USHORT) ( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) );
+ }
+ else if( rWW8Wrt.bOutPageDescs ) // PageDescs
+ {
+ USHORT nLDist, nRDist;
+ const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( RES_BOX );
+ if( pItem )
+ {
+ nRDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_LEFT );
+ nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_RIGHT );
+ }
+ else
+ nLDist = nRDist = 0;
+ nLDist += rLR.GetLeft();
+ nRDist += rLR.GetRight();
+
+ // sprmSDxaLeft
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xB021 );
+ else
+ rWW8Wrt.pO->Insert( 166, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nLDist );
+ // sprmSDxaRight
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xB022 );
+ else
+ rWW8Wrt.pO->Insert( 167, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nRDist );
+ }
+ else
+ { // normale Absaetze
+ // sprmPDxaLeft
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x840F );
+ else
+ rWW8Wrt.pO->Insert( 17, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rLR.GetTxtLeft() );
+ // sprmPDxaRight
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x840E );
+ else
+ rWW8Wrt.pO->Insert( 16, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rLR.GetRight() );
+ // sprmPDxaLeft1
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x8411 );
+ else
+ rWW8Wrt.pO->Insert( 19, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rLR.GetTxtFirstLineOfst() );
+ }
+ return rWrt;
+}
+
+static USHORT lcl_CalcHdFtDist( const SwFrmFmt& rFmt, BOOL bLower )
+{
+ long nDist = 0;
+ SwRect aRect( rFmt.FindLayoutRect( FALSE ));
+ if( aRect.Height() )
+ nDist += aRect.Height();
+ else
+ {
+ const SwFmtFrmSize& rSz = rFmt.GetFrmSize();
+ if( ATT_VAR_SIZE != rSz.GetSizeType() )
+ nDist += rSz.GetHeight();
+ else
+ {
+ nDist += 274; // defaulten fuer 12pt Schrift
+ const SvxULSpaceItem& rUL = rFmt.GetULSpace();
+ nDist += ( bLower ? rUL.GetLower() : rUL.GetUpper() );
+ }
+ }
+ return (USHORT)nDist;
+}
+
+static Writer& OutWW8_SwFmtULSpace( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SvxULSpaceItem & rUL = (const SvxULSpaceItem&) rHt;
+
+ // Flys fehlen noch ( siehe RTF )
+
+ if( rWW8Wrt.bOutFlyFrmAttrs ) // Flys
+ {
+ // sprmPDyaFromText
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x842E );
+ else
+ rWW8Wrt.pO->Insert( 48, rWW8Wrt.pO->Count() );
+ // Mittelwert nehmen, da WW nur 1 Wert kennt
+ rWW8Wrt.InsUInt16( (USHORT) ( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) );
+ }
+ else if( rWW8Wrt.bOutPageDescs ) // Page-UL
+ {
+ USHORT nUDist, nLDist;
+ const SfxPoolItem* pItem = rWW8Wrt.HasItem( RES_BOX );
+ if( pItem )
+ {
+ nUDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_TOP );
+ nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_BOTTOM );
+ }
+ else
+ nUDist = nLDist = 0;
+ nUDist += rUL.GetUpper();
+ nLDist += rUL.GetLower();
+
+ // Kopf-/Fusszeilen beachten:
+ if( 0 != ( pItem = rWW8Wrt.HasItem( RES_HEADER )) &&
+ ((SwFmtHeader*)pItem)->IsActive() )
+ {
+ // dann aufjedenfall schon mal den Abstand der Kopfzeile zum
+ // SeitenAnfang ausgeben
+ // sprmSDyaHdrTop
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xB017 );
+ else
+ rWW8Wrt.pO->Insert( 156, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nUDist );
+ nUDist += ::lcl_CalcHdFtDist( *((SwFmtHeader*)pItem)->
+ GetHeaderFmt(), TRUE );
+ }
+ // sprmSDyaTop
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x9023 );
+ else
+ rWW8Wrt.pO->Insert( 168, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nUDist );
+
+
+ if( 0 != ( pItem = rWW8Wrt.HasItem( RES_FOOTER )) &&
+ ((SwFmtFooter*)pItem)->IsActive() )
+ {
+ // dann aufjedenfall schon mal den Abstand der Fusszeile zum
+ // SeitenEnde ausgeben
+ // sprmSDyaHdrBottom
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xB018 );
+ else
+ rWW8Wrt.pO->Insert( 157, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nLDist );
+ nLDist += ::lcl_CalcHdFtDist( *((SwFmtFooter*)pItem)->
+ GetFooterFmt(), FALSE );
+ }
+ // sprmSDyaBottom
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x9024 );
+ else
+ rWW8Wrt.pO->Insert( 169, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nLDist );
+ }
+ else
+ {
+ // sprmPDyaBefore
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xA413 );
+ else
+ rWW8Wrt.pO->Insert( 21, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rUL.GetUpper() );
+ // sprmPDyaAfter
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xA414 );
+ else
+ rWW8Wrt.pO->Insert( 22, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rUL.GetLower() );
+ }
+ return rWrt;
+}
+
+// Print, Opaque, Protect fehlen noch
+
+static Writer& OutWW8_SwFmtSurround( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ if( rWW8Wrt.bOutFlyFrmAttrs )
+ {
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x2423 );
+ else
+ rWW8Wrt.pO->Insert( 37, rWW8Wrt.pO->Count() );
+
+ rWW8Wrt.pO->Insert( (SURROUND_NONE !=
+ ((const SwFmtSurround&) rHt).GetSurround() )
+ ? 2 : 1, rWW8Wrt.pO->Count() );
+ }
+ return rWrt;
+}
+
+Writer& OutWW8_SwFmtVertOrient( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtVertOrient& rFlyVert = (const SwFmtVertOrient&) rHt;
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+
+//!!!! Ankertyp und entsprechende Umrechnung fehlt noch
+
+ if( rWW8Wrt.bOutFlyFrmAttrs )
+ {
+ const SwFmtVertOrient& rFlyVert = (const SwFmtVertOrient&) rHt;
+
+ short nPos;
+ switch( rFlyVert.GetVertOrient() )
+ {
+ case VERT_NONE: nPos = (short)rFlyVert.GetPos(); break;
+ case VERT_CENTER:
+ case VERT_LINE_CENTER: nPos = -8; break;
+ case VERT_BOTTOM:
+ case VERT_LINE_BOTTOM: nPos = -12; break;
+ case VERT_TOP:
+ case VERT_LINE_TOP:
+ default: nPos = -4; break;
+ }
+
+ // sprmPDyaAbs
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x8419 );
+ else
+ rWW8Wrt.pO->Insert( 27, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nPos );
+ }
+ return rWrt;
+}
+
+
+Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ if( !rWW8Wrt.pFlyFmt )
+ {
+ ASSERT( rWW8Wrt.pFlyFmt, "HoriOrient ohne pFlyFmt !!" );
+ return rWrt;
+ }
+
+//!!!! Ankertyp und entsprechende Umrechnung fehlt noch
+ if( rWW8Wrt.bOutFlyFrmAttrs )
+ {
+ const SwFmtHoriOrient& rFlyHori = (const SwFmtHoriOrient&) rHt;
+
+ short nPos;
+ switch( rFlyHori.GetHoriOrient() )
+ {
+ case HORI_NONE: {
+ nPos = (short)rFlyHori.GetPos();
+ if( !nPos )
+ nPos = 1; // WW: 0 ist reserviert
+#if 0
+// ist nicht noetig, da Bindung an Absatz als hor. Bindung an die
+// Spalte exportiert wird, da so das Verhalten bei Mehrspaltigkeit
+// am AEhnlichsten ist.
+ RndStdIds eAn = rWW8Wrt.pFlyFmt->GetAttrSet().
+ GetAnchor().GetAnchorId();
+ if( eAn == FLY_AT_CNTNT || eAn == FLY_IN_CNTNT )
+ nPos += GetPageL( rWW8Wrt );
+#endif
+ }
+ break;
+
+ case HORI_LEFT: nPos = rFlyHori.IsPosToggle() ? -12 : 0;
+ break;
+ case HORI_RIGHT: nPos = rFlyHori.IsPosToggle() ? -16 : -8;
+ break;
+ case HORI_CENTER:
+ case HORI_FULL: // FULL nur fuer Tabellen
+ default: nPos = -4; break;
+ }
+
+ // sprmPDxaAbs
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x8418 );
+ else
+ rWW8Wrt.pO->Insert( 26, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nPos );
+ }
+ return rWrt;
+}
+
+static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ ASSERT( rWW8Wrt.pFlyFmt, "Anker ohne pFlyFmt !!" );
+
+ if( rWW8Wrt.bOutFlyFrmAttrs )
+ {
+ const SwFmtAnchor& rAnchor = (const SwFmtAnchor&) rHt;
+ BYTE nP = 0;
+ switch( rAnchor.GetAnchorId() )
+ {
+ case FLY_PAGE: nP |= ( 1 << 4 ) // Vert: Page
+ | ( 2 << 6 ); // Horz: Page
+ break;
+ // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!!
+ case FLY_AT_FLY:
+ case FLY_AUTO_CNTNT:
+ case FLY_AT_CNTNT:
+ case FLY_IN_CNTNT: nP |= ( 2 << 4 ) // Vert: Text
+ | ( 0 << 6 ); // Horz: Column
+ break;
+ }
+
+ // sprmPPc
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x261B );
+ else
+ rWW8Wrt.pO->Insert( 29, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( nP, rWW8Wrt.pO->Count() );
+ }
+ return rWrt;
+}
+
+static Writer& OutWW8_SwFmtBackground( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+
+ if( !rWW8Wrt.bOutPageDescs ) // WW kann keinen Hintergrund
+ { // in Section
+ const SvxBrushItem& rBack = (const SvxBrushItem&)rHt;
+ WW8_SHD aSHD;
+
+ if( rWW8Wrt.TransBrush( rBack.GetColor(), aSHD ) )
+ {
+ // sprmPShd
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x442D );
+ else
+ rWW8Wrt.pO->Insert( 47, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( aSHD.GetValue() );
+ }
+ }
+ return rWrt;
+}
+
+
+// TranslateBorderLine() liefert eine UINT32 zurueck, der noch in einen
+// SVBT32 uebersetzt werden muss.
+// bei Export als WW6 sind nur die unteren 16 Bit von Interesse
+// bShadow darf bei Tabellenzellen *nicht* gesetzt sein !
+UINT32 SwWW8Writer::TranslateBorderLine( const SvxBorderLine& rLine,
+ USHORT nDist, BOOL bShadow )
+{
+ UINT32 nBrd = 0;
+ UINT16 nWidth = rLine.GetInWidth() + rLine.GetOutWidth(), brcType = 0;
+ UINT32 nColCode = 0;
+ if( nWidth ) // Linie ?
+ {
+ // BRC.brcType
+ BOOL bDouble = 0 != rLine.GetInWidth() && 0 != rLine.GetOutWidth();
+ BOOL bThick = !bDouble && !bWrtWW8 && nWidth > 75;
+ if( bDouble )
+ brcType = 3;
+ else if( bThick )
+ brcType = 2;
+ else
+ brcType = 1;
+
+ // BRC.dxpLineWidth
+ if( bThick )
+ nWidth /= 2;
+
+ if( bWrtWW8 )
+ {
+ // Angabe in 8tel Punkten, also durch 2.5, da 1 Punkt = 20 Twips
+ nWidth = (( nWidth * 8 ) + 10 ) / 20;
+ if( 0xff < nWidth )
+ nWidth = 0xff;
+ }
+ else
+ {
+ // Angabe in 0.75 pt
+ nWidth = ( nWidth + 7 ) / 15;
+ if( nWidth > 5 )
+ nWidth = 5;
+ }
+
+ if( 0 == nWidth ) // ganz duenne Linie
+ nWidth = 1; // nicht weglassen
+
+ // BRC.ico
+ nColCode = TransCol( rLine.GetColor() );
+ }
+
+ // BRC.dxpSpace
+ long nLDist = nDist;
+ nLDist /= 20; // Masseinheit : pt
+ if( nLDist > 0x1f )
+ nLDist = 0x1f;
+
+ if( bWrtWW8 )
+ {
+ nBrd = nWidth + ( brcType << 8 );
+ nBrd |= nColCode << 16;
+ nBrd |= nLDist << 24;
+
+ // fShadow, keine weiteren Einstellungen im WW moeglich
+ if( bShadow )
+ nBrd |= (0x2000L << 16);
+ }
+ else
+ {
+ nBrd = nWidth + ( brcType << 3 );
+ nBrd |= (nColCode & 0x1f) << 6;
+ nBrd |= nLDist << 11;
+ // fShadow, keine weiteren Einstellungen im WW moeglich
+ if( bShadow )
+ nBrd |= 0x20;
+ }
+
+ return nBrd;
+}
+
+// MakeBorderLine() bekommt einen WW8Bytes* uebergeben, um die Funktion
+// auch fuer die Tabellen-Umrandungen zu benutzen.
+// Wenn nSprmNo == 0, dann wird der Opcode nicht ausgegeben.
+// bShadow darf bei Tabellenzellen *nicht* gesetzt sein !
+void SwWW8Writer::Out_BorderLine( WW8Bytes& rO, const SvxBorderLine* pLine,
+ USHORT nDist, USHORT nOffset,
+ BOOL bShadow )
+{
+ ASSERT( (0 <= nOffset && nOffset <= 3) || USHRT_MAX == nOffset ||
+ ((0x702b - 0x6424) <= nOffset && nOffset <= (0x702e - 0x6424)),
+ "SprmOffset ausserhalb des Bereichs" );
+
+
+ UINT32 nBrdCd = pLine ? TranslateBorderLine( *pLine, nDist, bShadow )
+ : 0;
+ if( bWrtWW8 )
+ {
+// WW97-SprmIds
+// 0x6424, sprmPBrcTop pap.brcTop;BRC;long; !!!!
+// 0x6425, sprmPBrcLeft
+// 0x6426, sprmPBrcBottom
+// 0x6427, sprmPBrcRight
+ if( USHRT_MAX != nOffset ) // mit OpCode-Ausgabe ?
+ SwWW8Writer::InsUInt16( rO, 0x6424 + nOffset );
+
+ SwWW8Writer::InsUInt32( rO, nBrdCd );
+ }
+ else
+ {
+// WW95-SprmIds
+// 38, sprmPBrcTop - pap.brcTop BRC short !!!
+// 39, sprmPBrcLeft
+// 40, sprmPBrcBottom
+// 41, sprmPBrcRight
+ if( USHRT_MAX != nOffset ) // mit OpCode-Ausgabe ?
+ rO.Insert( (BYTE)( 38 + nOffset ), rO.Count() );
+ SwWW8Writer::InsUInt16( rO, (UINT16)nBrdCd );
+ }
+}
+
+// OutWW8_SwFmtBox1() ist fuer alle Boxen ausser in Tabellen.
+// es wird pO des WW8Writers genommen
+void SwWW8Writer::Out_SwFmtBox( const SvxBoxItem& rBox, BOOL bShadow )
+{
+ USHORT nOffset = 0;
+ if( bOutPageDescs )
+ {
+ if( !bWrtWW8 )
+ return ; // WW95 kennt keine Seitenumrandung
+
+// WW97-SprmIds
+// 0x702b, sprmSBrcTop pap.brcTop;BRC;long; !!!!
+// 0x702c, sprmSBrcLeft
+// 0x702d, sprmSBrcBottom
+// 0x702e, sprmSBrcRight
+ nOffset = (0x702b - 0x6424);
+ }
+
+ static USHORT __READONLY_DATA aBorders[] = {
+ BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
+ const USHORT* pBrd = aBorders;
+ for( int i = 0; i < 4; ++i, ++pBrd )
+ {
+ const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
+ Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nOffset+i,
+ bShadow );
+ }
+}
+
+// OutWW8_SwFmtBox2() ist fuer TC-Strukturen in Tabellen. Der Sprm-Opcode
+// wird nicht geschrieben, da es in der TC-Structur ohne Opcode gepackt ist.
+// dxpSpace wird immer 0, da WW das in Tabellen so verlangt
+// ( Tabellenumrandungen fransen sonst aus )
+// Ein WW8Bytes-Ptr wird als Ausgabe-Parameter uebergeben
+
+void SwWW8Writer::Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox )
+{
+ // moeglich und vielleicht besser waere 0xffff
+ static USHORT __READONLY_DATA aBorders[] = {
+ BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
+ const USHORT* pBrd = aBorders;
+ for( int i = 0; i < 4; ++i, ++pBrd )
+ {
+ const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
+ Out_BorderLine( rO, pLn, 0, USHRT_MAX, FALSE );
+ }
+}
+
+static Writer& OutWW8_SwFmtBox( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ // Fly um Grafik-> keine Umrandung hier, da
+ // der GrafikHeader bereits die Umrandung hat
+ SwWW8Writer& rWW8Wrt = ((SwWW8Writer&)rWrt);
+ if( !rWW8Wrt.bOutGrf )
+ {
+ BOOL bShadow = FALSE;
+ const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( RES_SHADOW );
+ if( pItem )
+ {
+ const SvxShadowItem* p = (const SvxShadowItem*)pItem;
+ bShadow = ( p->GetLocation() != SVX_SHADOW_NONE )
+ && ( p->GetWidth() != 0 );
+ }
+
+ rWW8Wrt.Out_SwFmtBox( (SvxBoxItem&)rHt, bShadow );
+ }
+ return rWrt;
+}
+
+
+static Writer& OutWW8_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ const SwFmtCol& rCol = (const SwFmtCol&)rHt;
+ const SwColumns& rColumns = rCol.GetColumns();
+ SwWW8Writer& rWW8Wrt = ((SwWW8Writer&)rWrt);
+
+ USHORT nCols = rColumns.Count();
+ if( 1 < nCols
+ && !rWW8Wrt.bOutFlyFrmAttrs ) // mehrspaltige Rahmen kann WW nicht
+ {
+ // dann besorge mal die Seitenbreite ohne Raender !!
+ SwTwips nPageSize;
+ const SwFrmFmt* pFmt = rWW8Wrt.pAktPageDesc
+ ? &rWW8Wrt.pAktPageDesc->GetMaster()
+ : &rWW8Wrt.pDoc->GetPageDesc(0).GetMaster();
+
+ SwRect aRect( pFmt->FindLayoutRect( TRUE ));
+ if( 0 == ( nPageSize = aRect.Width() ))
+ {
+ const SvxLRSpaceItem& rLR = pFmt->GetLRSpace();
+ nPageSize = pFmt->GetFrmSize().GetWidth() -
+ rLR.GetLeft() - rLR.GetRight();
+ }
+
+ // CColumns
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x500b );
+ else
+ rWW8Wrt.pO->Insert( 144, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( nCols - 1 );
+
+ // DxaColumns
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x900c );
+ else
+ rWW8Wrt.pO->Insert( 145, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rCol.GetGutterWidth( TRUE ) );
+
+ // LBetween
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x3019 );
+ else
+ rWW8Wrt.pO->Insert( 158, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( COLADJ_NONE == rCol.GetLineAdj() ? 0 : 1,
+ rWW8Wrt.pO->Count() );
+
+ // Nachsehen, ob alle Spalten gleich sind
+ BOOL bEven = TRUE;
+ USHORT n;
+ USHORT nColWidth = rCol.CalcPrtColWidth( 0, (USHORT)nPageSize );
+ for( n = 1; n < nCols; n++ )
+ {
+ short nDiff = nColWidth - rCol.CalcPrtColWidth( n, (USHORT)nPageSize );
+ if( nDiff > 10 || nDiff < -10 ) // Toleranz: 10 tw
+ {
+ bEven = FALSE;
+ break;
+ }
+ }
+ if( bEven )
+ {
+ USHORT nSpace = rColumns[0]->GetRight() + rColumns[1]->GetLeft();
+ for( n = 2; n < nCols; n++ )
+ {
+ short nDiff = nSpace - ( rColumns[n - 1]->GetRight()
+ + rColumns[n]->GetLeft() );
+ if( nDiff > 10 || nDiff < -10 )
+ { // Toleranz: 10 tw
+ bEven = FALSE;
+ break;
+ }
+ }
+ }
+
+ // FEvenlySpaced
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0x3005 );
+ else
+ rWW8Wrt.pO->Insert( 138, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( bEven ? 1 : 0, rWW8Wrt.pO->Count() );
+
+ if( !bEven )
+ {
+ for( USHORT n = 0; n < nCols; ++n )
+ {
+ //sprmSDxaColWidth
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xF203 );
+ else
+ rWW8Wrt.pO->Insert( 136, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( n, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rCol.CalcPrtColWidth( n, (USHORT)nPageSize ) );
+
+ if( n+1 != nCols )
+ {
+ //sprmSDxaColSpacing
+ if( rWW8Wrt.bWrtWW8 )
+ rWW8Wrt.InsUInt16( 0xF204 );
+ else
+ rWW8Wrt.pO->Insert( 137, rWW8Wrt.pO->Count() );
+ rWW8Wrt.pO->Insert( n, rWW8Wrt.pO->Count() );
+ rWW8Wrt.InsUInt16( rColumns[ n ]->GetRight() +
+ rColumns[ n + 1 ]->GetLeft() );
+ }
+ }
+ }
+ }
+ return rWrt;
+}
+
+// "Absaetze zusammenhalten"
+static Writer& OutWW8_SvxFmtKeep( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmFKeepFollow
+ const SvxFmtKeepItem& rAttr = (const SvxFmtKeepItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2406 );
+ else
+ rWrtWW8.pO->Insert( 8, rWrtWW8.pO->Count() );
+
+ rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+
+// exclude a paragraph from Line Numbering
+static Writer& OutWW8_SwFmtLineNumber( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmPFNoLineNumb
+ const SwFmtLineNumber& rAttr = (const SwFmtLineNumber&)rHt;
+
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x240C );
+ else
+ rWrtWW8.pO->Insert( 14, rWrtWW8.pO->Count() );
+
+ rWrtWW8.pO->Insert( rAttr.IsCount() ? 0 : 1, rWrtWW8.pO->Count() );
+
+ return rWrt;
+}
+
+
+/* File PARATR.HXX */
+
+static Writer& OutWW8_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmPDyaLine
+ const SvxLineSpacingItem& rAttr = (const SvxLineSpacingItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x6412 );
+ else
+ rWrtWW8.pO->Insert( 20, rWrtWW8.pO->Count() );
+
+ short nSpace = 240, nMulti = 0;
+
+ switch( rAttr.GetLineSpaceRule() )
+ {
+ case SVX_LINE_SPACE_AUTO:
+ case SVX_LINE_SPACE_FIX:
+ case SVX_LINE_SPACE_MIN:
+ {
+ switch( rAttr.GetInterLineSpaceRule() )
+ {
+ case SVX_INTER_LINE_SPACE_FIX: // unser Durchschuss
+ // gibt es aber nicht in WW - also wie kommt man an
+ // die MaxLineHeight heran?
+ nSpace = (short)rAttr.GetInterLineSpace();
+ break;
+
+ case SVX_INTER_LINE_SPACE_PROP:
+ nSpace = (short)(( 240L * rAttr.GetPropLineSpace() ) / 100L );
+ nMulti = 1;
+ break;
+
+ default: // z.B. Minimum oder FIX?
+ if( SVX_LINE_SPACE_FIX == rAttr.GetLineSpaceRule() )
+ nSpace = -(short)rAttr.GetLineHeight();
+ else
+ nSpace = (short)rAttr.GetLineHeight();
+ break;
+ }
+ }
+ break;
+ }
+
+ rWrtWW8.InsUInt16( nSpace );
+ rWrtWW8.InsUInt16( nMulti );
+ return rWrt;
+}
+
+
+static Writer& OutWW8_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmPJc
+ const SvxAdjustItem& rAttr = (const SvxAdjustItem&)rHt;
+ BYTE nAdj = 255;
+ switch( rAttr.GetAdjust() )
+ {
+ case SVX_ADJUST_LEFT: nAdj = 0; break;
+ case SVX_ADJUST_RIGHT: nAdj = 2; break;
+ case SVX_ADJUST_BLOCKLINE:
+ case SVX_ADJUST_BLOCK: nAdj = 3; break;
+ case SVX_ADJUST_CENTER: nAdj = 1; break;
+ default: return rWrt; // kein gueltiges Attribut
+ }
+
+ if( 255 != nAdj ) // gueltiges Attribut?
+ {
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2403 );
+ else
+ rWrtWW8.pO->Insert( 5, rWrtWW8.pO->Count() );
+ rWrtWW8.pO->Insert( nAdj, rWrtWW8.pO->Count() );
+ }
+ return rWrt;
+}
+
+// "Absaetze trennen"
+static Writer& OutWW8_SvxFmtSplit( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmPFKeep
+ const SvxFmtSplitItem& rAttr = (const SvxFmtSplitItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2405 );
+ else
+ rWrtWW8.pO->Insert( 7, rWrtWW8.pO->Count() );
+ rWrtWW8.pO->Insert( rAttr.GetValue() ? 0 : 1, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+// Es wird nur das Item "SvxWidowItem" und nicht die Orphans uebersetzt,
+// da es fuer beides im WW nur ein Attribut "Absatzkontrolle" gibt und
+// im SW wahrscheinlich vom Anwender immer Beide oder keiner gesetzt werden.
+static Writer& OutWW8_SvxWidows( Writer& rWrt, const SfxPoolItem& rHt )
+{
+// sprmPFWidowControl
+ const SvxWidowsItem& rAttr = (const SvxWidowsItem&)rHt;
+ SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt;
+ if( rWrtWW8.bWrtWW8 )
+ rWrtWW8.InsUInt16( 0x2431 );
+ else
+ rWrtWW8.pO->Insert( 51, rWrtWW8.pO->Count() );
+ rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() );
+ return rWrt;
+}
+
+
+class SwWW8WrTabu
+{
+ BYTE* pDel; // DelArray
+ BYTE* pAddPos; // AddPos-Array
+ BYTE* pAddTyp; // AddTyp-Array
+ USHORT nAdd; // so viele Tabs kommen hinzu
+ USHORT nDel; // so viele Tabs fallen weg
+ USHORT nLeftParaMgn; // fuer anderes Wertesystem SW/WW
+public:
+ SwWW8WrTabu( USHORT nDelMax, USHORT nAddMax, USHORT nLeftPara );
+ ~SwWW8WrTabu();
+
+ void Add( const SvxTabStop & rTS );
+ void Del( const SvxTabStop & rTS );
+ void PutAll( SwWW8Writer& rWW8Wrt );
+};
+
+SwWW8WrTabu::SwWW8WrTabu( USHORT nDelMax, USHORT nAddMax, USHORT nLeftPara )
+ : nAdd( 0 ), nDel( 0 ), nLeftParaMgn( nLeftPara )
+{
+ pDel = ( nDelMax ) ? new BYTE[ nDelMax * 2 ] : 0;
+ pAddPos = new BYTE[ nAddMax * 2 ];
+ pAddTyp = new BYTE[ nAddMax ];
+}
+
+SwWW8WrTabu::~SwWW8WrTabu()
+{
+ delete[] pAddTyp;
+ delete[] pAddPos;
+ delete[] pDel;
+}
+
+// Add( const SvxTabStop & rTS ) fuegt einen Tab in die WW-Struktur ein
+void SwWW8WrTabu::Add( const SvxTabStop & rTS )
+{
+ // Tab-Position eintragen
+ ShortToSVBT16( (USHORT)rTS.GetTabPos() + nLeftParaMgn,
+ pAddPos + ( nAdd * 2 ) );
+
+ // Tab-Typ eintragen
+ BYTE nPara = 0;
+ switch( rTS.GetAdjustment() )
+ {
+ case SVX_TAB_ADJUST_RIGHT: nPara = 2; break;
+ case SVX_TAB_ADJUST_CENTER: nPara = 1; break;
+ case SVX_TAB_ADJUST_DECIMAL:
+ nPara = ',' == rTS.GetDecimal() ? 3 : 1;
+ break;
+ }
+
+ switch( rTS.GetFill() )
+ {
+ case '.': nPara |= 1 << 3; break; // dotted leader
+ case '_': nPara |= 3 << 3; break; // Single line leader
+ case '-': nPara |= 2 << 3; break; // hyphenated leader
+ case '=': nPara |= 4 << 3; break; // heavy line leader
+ }
+
+ ByteToSVBT8( nPara, pAddTyp + nAdd );
+ ++nAdd;
+}
+
+// Del( const SvxTabStop & rTS ) fuegt einen zu loeschenden Tab
+// in die WW-Struktur ein
+void SwWW8WrTabu::Del( const SvxTabStop & rTS )
+{
+ // Tab-Position eintragen
+ ShortToSVBT16( (USHORT)rTS.GetTabPos() + nLeftParaMgn,
+ pDel + ( nDel * 2 ) );
+ ++nDel;
+}
+
+// PutAll( SwWW8Writer& rWW8Wrt ) schreibt das Attribut nach rWrt.pO
+void SwWW8WrTabu::PutAll( SwWW8Writer& rWrt )
+{
+ if( nAdd > 255 )
+ {
+ ASSERT( !this, "+ mehr als 255 Tabs dazu ?????" );
+ nAdd = 255;
+ }
+ if( nDel > 255 )
+ {
+ ASSERT( !this, "+ mehr als 255 Tabs weg ?????" );
+ nDel = 255;
+ }
+
+ USHORT nSiz = 2 * nDel + 3 * nAdd + 2;
+ if( nSiz > 255 )
+ nSiz = 255;
+
+ if( rWrt.bWrtWW8 )
+ rWrt.InsUInt16( 0xC60D );
+ else
+ rWrt.pO->Insert( 15, rWrt.pO->Count() );
+ rWrt.pO->Insert( (BYTE)nSiz, rWrt.pO->Count() ); // cch eintragen
+
+ // DelArr schreiben
+ rWrt.pO->Insert( (BYTE)nDel, rWrt.pO->Count() ); // nDel eintragen
+ rWrt.OutSprmBytes( pDel, nDel * 2 );
+ // InsArr schreiben
+ rWrt.pO->Insert( (BYTE)nAdd, rWrt.pO->Count() ); // nAdd schreiben
+ rWrt.OutSprmBytes( pAddPos, 2 * nAdd ); // AddPosArray
+ rWrt.OutSprmBytes( pAddTyp, nAdd ); // AddTypArray
+}
+
+
+static void OutWW8_SwTabStopAdd( Writer& rWrt, const SvxTabStopItem& rTStops,
+ USHORT nLParaMgn )
+{
+ SwWW8WrTabu aTab( 0, rTStops.Count(), nLParaMgn );
+
+ for( USHORT n = 0; n < rTStops.Count(); n++ )
+ {
+ const SvxTabStop& rTS = rTStops[ n ];
+ if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() ) // Def-Tabs ignorieren
+ aTab.Add( rTS );
+ }
+ aTab.PutAll( (SwWW8Writer&)rWrt );
+}
+
+static void OutWW8_SwTabStopDelAdd( Writer& rWrt, const SvxTabStopItem& rTOld,
+ const SvxTabStopItem& rTNew, USHORT nLParaMgn )
+{
+ SwWW8WrTabu aTab( rTOld.Count(), rTNew.Count(), nLParaMgn );
+
+ USHORT nO = 0; // rTOld Index
+ USHORT nN = 0; // rTNew Index
+
+ do {
+ const SvxTabStop* pTO;
+ long nOP;
+ if( nO < rTOld.Count() ) // alt noch nicht am Ende ?
+ {
+ pTO = &rTOld[ nO ];
+ nOP = pTO->GetTabPos();
+ if( SVX_TAB_ADJUST_DEFAULT == pTO->GetAdjustment() )
+ {
+ nO++; // Default-Tab ignorieren
+ continue;
+ }
+ }
+ else
+ {
+ pTO = 0;
+ nOP = LONG_MAX;
+ }
+
+ const SvxTabStop* pTN;
+ long nNP;
+ if( nN < rTNew.Count() ) // neu noch nicht am Ende
+ {
+ pTN = &rTNew[ nN ];
+ nNP = pTN->GetTabPos();
+ if( SVX_TAB_ADJUST_DEFAULT == pTN->GetAdjustment() )
+ {
+ nN++; // Default-Tab ignorieren
+ continue;
+ }
+ }
+ else
+ {
+ pTN = 0;
+ nNP = LONG_MAX;
+ }
+
+ if( nOP == LONG_MAX && nNP == LONG_MAX )
+ break; // alles fertig
+
+ if( nOP < nNP ) // naechster Tab ist alt
+ {
+ aTab.Del( *pTO ); // muss geloescht werden
+ nO++;
+ }
+ else if( nNP < nOP ) // naechster Tab ist neu
+ {
+ aTab.Add( *pTN ); // muss eigefuegt werden
+ nN++;
+ }
+ else if ( pTO->IsEqual( *pTN ) ) // Tabs sind gleich
+ {
+ nO++; // nichts zu tun
+ nN++;
+ }
+ else // Tabs selbe Pos, diff Typ
+ {
+ aTab.Del( *pTO ); // alten loeschen
+ aTab.Add( *pTN ); // neuen einfuegen
+ nO++;
+ nN++;
+ }
+ } while( 1 );
+
+ aTab.PutAll( (SwWW8Writer&)rWrt );
+}
+
+static Writer& OutWW8_SwTabStop( Writer& rWrt, const SfxPoolItem& rHt )
+{
+ SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt;
+ const SvxTabStopItem & rTStops = (const SvxTabStopItem&)rHt;
+ const SfxPoolItem* pLR = rWW8Wrt.HasItem( RES_LR_SPACE );
+ USHORT nOffset = pLR ? ((const SvxLRSpaceItem*)pLR)->GetTxtLeft() : 0;
+
+ const SfxPoolItem* pItem = 0;
+
+ if( rWW8Wrt.bStyDef // StyleDef -> "einfach" eintragen
+ || !rWW8Wrt.pStyAttr // keine Style-Attrs -> dito
+ || ( SFX_ITEM_SET != rWW8Wrt.pStyAttr->GetItemState(
+ RES_PARATR_TABSTOP, TRUE, &pItem ) ) ) // kein Tab-Attr in Styles -> dito
+ {
+ OutWW8_SwTabStopAdd( rWW8Wrt, rTStops, nOffset );
+ }
+ else if ( pItem ) // Harte Attribute: Differenzen zum Style eintragen
+ {
+ OutWW8_SwTabStopDelAdd( rWW8Wrt, *(const SvxTabStopItem*)pItem,
+ rTStops, nOffset );
+ }
+ return rWrt;
+}
+
+//-----------------------------------------------------------------------
+
+/*
+ * lege hier die Tabellen fuer die WW-Funktions-Pointer auf
+ * die Ausgabe-Funktionen an.
+ * Es sind lokale Strukturen, die nur innerhalb
+ * bekannt sein muessen.
+ */
+
+SwAttrFnTab aWW8AttrFnTab = {
+/* RES_CHRATR_CASEMAP */ OutWW8_SwCaseMap,
+/* RES_CHRATR_CHARSETCOLOR */ 0,
+/* RES_CHRATR_COLOR */ OutWW8_SwColor,
+/* RES_CHRATR_CONTOUR */ OutWW8_SwContour,
+/* RES_CHRATR_CROSSEDOUT */ OutWW8_SwCrossedOut,
+/* RES_CHRATR_ESCAPEMENT */ OutWW8_SwEscapement,
+/* RES_CHRATR_FONT */ OutWW8_SwFont,
+/* RES_CHRATR_FONTSIZE */ OutWW8_SwSize,
+/* RES_CHRATR_KERNING */ OutWW8_SwKerning,
+/* RES_CHRATR_LANGUAGE */ OutWW8_SwLanguage,
+/* RES_CHRATR_POSTURE */ OutWW8_SwPosture,
+/* RES_CHRATR_PROPORTIONALFONTSIZE*/0,
+/* RES_CHRATR_SHADOWED */ OutWW8_SwShadow,
+/* RES_CHRATR_UNDERLINE */ OutWW8_SwUnderline,
+/* RES_CHRATR_WEIGHT */ OutWW8_SwWeight,
+/* RES_CHRATR_WORDLINEMODE */ 0, // Wird bei Underline mitbehandelt
+/* RES_CHRATR_AUTOKERN */ OutWW8_SvxAutoKern,
+/* RES_CHRATR_BLINK */ 0, // neu: blinkender Text
+/* RES_CHRATR_NOHYPHEN */ 0, // Neu: nicht trennen
+/* RES_CHRATR_NOLINEBREAK */ 0, // Neu: nicht umbrechen
+/* RES_CHRATR_BACKGROUND */ OutWW8_SwFmtCharBackground,
+/* RES_CHRATR_CJK_FONT */ 0,
+/* RES_CHRATR_CJK_FONTSIZE */ 0,
+/* RES_CHRATR_CJK_LANGUAGE */ 0,
+/* RES_CHRATR_CJK_POSTURE */ 0,
+/* RES_CHRATR_CJK_WEIGHT */ 0,
+/* RES_CHRATR_CTL_FONT */ 0,
+/* RES_CHRATR_CTL_FONTSIZE */ 0,
+/* RES_CHRATR_CTL_LANGUAGE */ 0,
+/* RES_CHRATR_CTL_POSTURE */ 0,
+/* RES_CHRATR_CTL_WEIGHT */ 0,
+/* RES_CHRATR_WRITING_DIRECTION */ 0,
+/* RES_CHRATR_DUMMY2 */ 0,
+/* RES_CHRATR_DUMMY3 */ 0,
+/* RES_CHRATR_DUMMY4 */ 0,
+/* RES_CHRATR_DUMMY5 */ 0,
+/* RES_CHRATR_DUMMY1 */ 0, // Dummy:
+
+/* RES_TXTATR_INETFMT */ OutSwFmtINetFmt,
+/* RES_TXTATR_DUMMY */ 0,
+/* RES_TXTATR_REFMARK */ 0, // handel by SwAttrIter
+/* RES_TXTATR_TOXMARK */ 0, // handel by SwAttrIter
+/* RES_TXTATR_CHARFMT */ OutWW8_SwTxtCharFmt,
+/* RES_TXTATR_TWO_LINES */ 0,
+/* RES_TXTATR_CJK_RUBY */ 0,
+/* RES_TXTATR_UNKNOWN_CONTAINER */ 0,
+/* RES_TXTATR_DUMMY5 */ 0,
+/* RES_TXTATR_DUMMY6 */ 0,
+
+/* RES_TXTATR_FIELD */ OutWW8_SwField,
+/* RES_TXTATR_FLYCNT */ OutWW8_SwFlyCntnt,
+/* RES_TXTATR_FTN */ OutWW8_SwFtn,
+/* RES_TXTATR_SOFTHYPH */ 0, // old attr. - coded now by character
+/* RES_TXTATR_HARDBLANK */ OutWW8_SwHardBlank,
+/* RES_TXTATR_DUMMY1 */ 0, // Dummy:
+/* RES_TXTATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_PARATR_LINESPACING */ OutWW8_SvxLineSpacing,
+/* RES_PARATR_ADJUST */ OutWW8_SvxAdjust,
+/* RES_PARATR_SPLIT */ OutWW8_SvxFmtSplit,
+/* RES_PARATR_ORPHANS */ 0, // OutW4W_SwOrphans, // kann WW nicht unabhaengig von Widows
+/* RES_PARATR_WIDOWS */ OutWW8_SvxWidows,
+/* RES_PARATR_TABSTOP */ OutWW8_SwTabStop,
+/* RES_PARATR_HYPHENZONE*/ OutWW8_SvxHyphenZone,
+/* RES_PARATR_DROP */ 0,
+/* RES_PARATR_REGISTER */ 0, // neu: Registerhaltigkeit
+/* RES_PARATR_NUMRULE */ OutWW8_SwNumRuleItem,
+/* RES_PARATR_DUMMY2 */ 0, // Dummy:
+
+/* RES_FILL_ORDER */ 0, // OutW4W_SwFillOrder,
+/* RES_FRM_SIZE */ OutWW8_SwFrmSize,
+/* RES_PAPER_BIN */ OutWW8_SvxPaperBin,
+/* RES_LR_SPACE */ OutWW8_SwFmtLRSpace,
+/* RES_UL_SPACE */ OutWW8_SwFmtULSpace,
+/* RES_PAGEDESC */ 0, // wird bei OutBreaks beachtet
+/* RES_BREAK */ OutWW8_SwFmtBreak,
+/* RES_CNTNT */ 0, /* 0, // OutW4W_??? */
+/* RES_HEADER */ 0, // wird bei der PageDesc ausgabe beachtet
+/* RES_FOOTER */ 0, // wird bei der PageDesc ausgabe beachtet
+/* RES_PRINT */ 0, // OutW4W_SwFmtPrint,
+/* RES_OPAQUE */ 0, // OutW4W_SwFmtOpaque, // kann WW nicht
+/* RES_PROTECT */ 0, // OutW4W_SwFmtProtect,
+/* RES_SURROUND */ OutWW8_SwFmtSurround,
+/* RES_VERT_ORIENT */ OutWW8_SwFmtVertOrient,
+/* RES_HORI_ORIENT */ OutWW8_SwFmtHoriOrient,
+/* RES_ANCHOR */ OutWW8_SwFmtAnchor,
+/* RES_BACKGROUND */ OutWW8_SwFmtBackground,
+/* RES_BOX */ OutWW8_SwFmtBox,
+/* RES_SHADOW */ 0, // Wird bei SwFmtBox mitbehandelt
+/* RES_FRMMACRO */ 0, /* 0, // OutW4W_??? */
+/* RES_COL */ OutWW8_SwFmtCol,
+/* RES_KEEP */ OutWW8_SvxFmtKeep,
+/* RES_URL */ 0, // URL
+/* RES_EDIT_IN_READONLY */ 0,
+/* RES_LAYOUT_SPLIT */ 0,
+/* RES_CHAIN */ 0,
+/* RES_FRMATR_DUMMY2 */ 0, // Dummy:
+/* RES_LINENUMBER */ OutWW8_SwFmtLineNumber, // Line Numbering
+/* RES_FRMATR_DUMMY4 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY5 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY6 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY7 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY8 */ 0, // Dummy:
+/* RES_FRMATR_DUMMY9 */ 0, // Dummy:
+
+
+/* RES_GRFATR_MIRRORGRF */ 0, // OutW4W_SwMirrorGrf,
+/* RES_GRFATR_CROPGRF */ 0, // OutW4W_SwCropGrf
+/* RES_GRFATR_ROTATION */ 0,
+/* RES_GRFATR_LUMINANCE */ 0,
+/* RES_GRFATR_CONTRAST */ 0,
+/* RES_GRFATR_CHANNELR */ 0,
+/* RES_GRFATR_CHANNELG */ 0,
+/* RES_GRFATR_CHANNELB */ 0,
+/* RES_GRFATR_GAMMA */ 0,
+/* RES_GRFATR_INVERT */ 0,
+/* RES_GRFATR_TRANSPARENCY */ 0,
+/* RES_GRFATR_DRWAMODE */ 0,
+/* RES_GRFATR_DUMMY1 */ 0,
+/* RES_GRFATR_DUMMY2 */ 0,
+/* RES_GRFATR_DUMMY3 */ 0,
+/* RES_GRFATR_DUMMY4 */ 0,
+/* RES_GRFATR_DUMMY5 */ 0,
+
+/* RES_BOXATR_FORMAT */ 0,
+/* RES_BOXATR_FORMULA */ 0,
+/* RES_BOXATR_VALUE */ 0,
+
+/* RES_UNKNOWNATR_CONTAINER */ 0
+};
+
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.51 2000/09/18 16:04:58 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.50 2000/08/21 10:14:14 khz
+ Export Line Numbering (restart on new section)
+
+ Revision 1.49 2000/08/04 10:56:44 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character
+
+ Revision 1.48 2000/07/31 19:24:54 jp
+ new attributes for CJK/CTL and graphic
+
+ Revision 1.47 2000/07/25 14:46:38 khz
+ #76811# save AutoHyphenation flag in Document Properties
+
+ Revision 1.46 2000/07/06 11:05:03 khz
+ Export *result* of field nonexisting in WW as either Unicode or 8bit text
+
+ Revision 1.45 2000/06/19 09:30:59 khz
+ Export the new WW2000 _underlining_ features
+
+ Revision 1.44 2000/06/09 16:30:26 jp
+ Write correct edit-/create-/print-/change - datetime fields
+
+ Revision 1.43 2000/05/12 16:14:18 jp
+ Changes for Unicode
+
+ Revision 1.42 2000/04/18 12:58:03 khz
+ Task #75183# to set char language use sprmCRgLid0 rather than sprmCLid
+
+ Revision 1.41 2000/03/03 15:20:01 os
+ StarView remainders removed
+
+ Revision 1.40 2000/02/21 13:05:36 jp
+ #70473# changes for unicode
+
+ Revision 1.39 2000/02/11 14:40:03 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.38 1999/12/20 17:41:37 jp
+ Bug #70749#: Date/Time-Numberformats in german format from the formatter
+
+ Revision 1.37 1999/12/15 17:06:22 jp
+ Bug #70913#: write Ftn-/EndNoteInfo - at end of section or page/doc
+
+ Revision 1.36 1999/12/08 13:53:01 jp
+ Task #70258#: textattr for XMLAttrContainer
+
+ Revision 1.35 1999/11/29 09:09:49 jp
+ InsertSpecialChar: ask for ChpIter
+
+ Revision 1.34 1999/11/25 21:22:33 jp
+ Bug #70131#: OutFields: append the charattributes of the node to the sprms
+
+ Revision 1.33 1999/11/24 13:14:25 jp
+ remove GetTimePara/GetDatePara, ReplaceCr: insert char at row end
+
+ Revision 1.32 1999/11/22 18:26:04 jp
+ export of TOX and TOX entries
+
+ Revision 1.31 1999/11/12 16:07:12 jp
+ write foot-/endnote attributes with correct charfmts
+
+ Revision 1.30 1999/11/12 13:23:25 jp
+ Escapement: write AUTO-Escapment correct
+
+ Revision 1.29 1999/11/10 16:09:54 jp
+ Bug #67922#: write header/footer for w95
+
+ Revision 1.28 1999/10/29 17:45:57 jp
+ export of 'complex'(vert. merged) tables
+
+ Revision 1.26 1999/10/14 21:06:13 jp
+ Bug #68617#,#68705# and other little things
+
+*************************************************************************/
+
+
+
+
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
new file mode 100644
index 000000000000..a58737628e5e
--- /dev/null
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -0,0 +1,426 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8glsy.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_STRINGS
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _WW8GLSY_HXX
+#include <ww8glsy.hxx>
+#endif
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx>
+#endif
+#ifndef _NDTXT
+#include <ndtxt.hxx>
+#endif
+#include <pam.hxx>
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen wg. SwFmtAnchor
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen wg. SwFrmFmt
+#include <frmfmt.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX //autogen wg. SwDoc
+#include <docary.hxx>
+#endif
+
+
+WW8Glossary::WW8Glossary(SvStorageStreamRef &refStrm,BYTE nVersion,
+ SvStorage *pStg) : rStrm(refStrm), xStg(pStg), nStrings( 0 )
+{
+ refStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ WW8Fib aWwFib( *refStrm, nVersion );
+
+ String sTblNm( WW8_ASCII2STR( "1Table" ));
+ if( 1 != aWwFib.fWhichTblStm )
+ sTblNm.SetChar( 0, '0' );
+
+ xTableStream = pStg->OpenStream( sTblNm, STREAM_STD_READ );
+ xTableStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ pGlossary = new WW8GlossaryFib( *refStrm, nVersion,*xTableStream, aWwFib );
+}
+
+BOOL WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex &rIdx)
+{
+ BOOL bRet=FALSE;
+ for( USHORT nCnt = pDoc->GetSpzFrmFmts()->Count(); nCnt; )
+ {
+ SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ --nCnt ];
+ if ( RES_FLYFRMFMT != pFrmFmt->Which() &&
+ RES_DRAWFRMFMT != pFrmFmt->Which() )
+ continue;
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ const SwPosition* pAPos;
+ if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() ||
+ FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) &&
+ 0 != ( pAPos = rAnchor.GetCntntAnchor()) &&
+ rIdx == pAPos->nNode.GetIndex() )
+ {
+ bRet=TRUE;
+ break;
+ }
+ }
+ return bRet;
+}
+
+BOOL WW8Glossary::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks,
+ BOOL bSaveRelFile, SvStrings& rStrings,
+ SvStrings& rExtra )
+{
+ // this code will be called after reading all text into the
+ // empty sections
+ const String aOldURL( INetURLObject::GetBaseURL() );
+ BOOL bRet=FALSE;
+ if( bSaveRelFile )
+ {
+ INetURLObject::SetBaseURL(
+ URIHelper::SmartRelToAbs( rBlocks.GetFileName()));
+ }
+ else
+ INetURLObject::SetBaseURL( aEmptyStr );
+
+ SwNodeIndex aDocEnd( pD->GetNodes().GetEndOfContent() );
+ SwNodeIndex aStart( *aDocEnd.GetNode().StartOfSectionNode(), 1 );
+
+ // search the first NormalStartNode
+ while( !( aStart.GetNode().IsStartNode() && SwNormalStartNode ==
+ aStart.GetNode().GetStartNode()->GetStartNodeType()) &&
+ aStart < aDocEnd )
+ aStart++;
+
+ if( aStart < aDocEnd )
+ {
+ SwTxtFmtColl* pColl = pD->GetTxtCollFromPool(
+ RES_POOLCOLL_STANDARD );
+ USHORT nGlosEntry = 0;
+ SwCntntNode* pCNd = 0;
+ do {
+ SwPaM aPam( aStart );
+ {
+ SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
+ rIdx++;
+ if( 0 == ( pCNd = rIdx.GetNode().GetTxtNode() ) )
+ {
+ if( rIdx.GetNode().IsTableNode() )
+ pCNd = pD->GetNodes().GoNext( &rIdx );
+ else
+ {
+ pCNd = pD->GetNodes().MakeTxtNode( rIdx, pColl );
+ rIdx = *pCNd;
+ }
+ }
+ }
+ aPam.GetPoint()->nContent.Assign( pCNd, 0 );
+ aPam.SetMark();
+ {
+ SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
+ rIdx = aStart.GetNode().EndOfSectionIndex() - 1;
+ if(( 0 == ( pCNd = rIdx.GetNode().GetCntntNode() ) )
+ || HasBareGraphicEnd(pD,rIdx))
+ {
+ rIdx++;
+ pCNd = pD->GetNodes().MakeTxtNode( rIdx, pColl );
+ rIdx = *pCNd;
+ }
+ }
+ aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
+
+ // now we have the right selection for one entry.
+ // Copy this to the definied TextBlock, but only if
+ // it is not an autocorrection entry (== -1)
+ // otherwise the group indicates the group in
+ // the sttbfglsystyle list that this entry belongs
+ // to. Unused at the moment
+ INT16 group = rExtra[nGlosEntry]->ToInt32() + 2;
+ if (group != -1)
+ {
+ rBlocks.ClearDoc();
+ String sLNm( *rStrings[nGlosEntry] );
+ if( rBlocks.BeginPutDoc( rBlocks.GetValidShortCut(sLNm,TRUE), sLNm ))
+ {
+ SwDoc* pGlDoc = rBlocks.GetDoc();
+ SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(),
+ -1 );
+ pCNd = aIdx.GetNode().GetCntntNode();
+ SwPosition aPos( aIdx, SwIndex( pCNd, pCNd->Len() ));
+ pD->Copy( aPam, aPos );
+ rBlocks.PutDoc();
+ }
+ }
+ aStart = aStart.GetNode().EndOfSectionIndex() + 1;
+ ++nGlosEntry;
+ } while( aStart.GetNode().IsStartNode() &&
+ SwNormalStartNode == aStart.GetNode().
+ GetStartNode()->GetStartNodeType());
+ bRet=TRUE;
+ }
+
+// this code will be called after reading all text into the empty sections
+
+ INetURLObject::SetBaseURL( aOldURL );
+ return bRet;
+}
+
+
+BOOL WW8Glossary::Load( SwTextBlocks &rBlocks, BOOL bSaveRelFile )
+{
+ BOOL bRet = FALSE;
+ if( pGlossary->IsGlossaryFib() && rBlocks.StartPutMuchBlockEntries() )
+ {
+ //read the names of the autotext entries
+ SvStrings aStrings( 0, 64 ), aExtra( 0, 64 );
+
+ rtl_TextEncoding eStructCharSet = 0x0100 == pGlossary->chseTables
+ ? RTL_TEXTENCODING_APPLE_ROMAN
+ : rtl_getTextEncodingFromWindowsCharset(
+ pGlossary->chseTables );
+
+ WW8ReadSTTBF( TRUE, *xTableStream,
+ pGlossary->fcSttbfglsy, pGlossary->lcbSttbfglsy, 0,
+ eStructCharSet, aStrings, &aExtra );
+ rStrm->Seek(0);
+
+ // SwDoc *pD = new SwDoc;
+ // pD->SetDocShell(new SwDocShell(SFX_CREATE_MODE_INTERNAL));
+ SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL));
+ if( xDocSh->DoInitNew( 0 ) )
+ {
+ SwDoc *pD = ((SwDocShell*)(&xDocSh))->GetDoc();
+ SwWW8ImplReader* pRdr = new
+ SwWW8ImplReader( pGlossary->nVersion , xStg, &rStrm, *pD, TRUE );
+
+ SwNodeIndex
+ aIdx( *pD->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
+ if( !aIdx.GetNode().IsTxtNode() )
+ {
+ ASSERT( !this, "wo ist der TextNode?" );
+ pD->GetNodes().GoNext( &aIdx );
+ }
+ SwPaM aPamo( aIdx );
+ aPamo.GetPoint()->nContent.Assign( aIdx.GetNode().GetCntntNode(), 0 );
+ pRdr->LoadDoc(aPamo,this);
+
+ bRet = MakeEntries( pD, rBlocks, bSaveRelFile, aStrings, aExtra );
+
+ delete pRdr;
+ }
+ xDocSh->DoClose();
+ rBlocks.EndPutMuchBlockEntries();
+
+ nStrings = aStrings.Count();
+ aStrings.DeleteAndDestroy( 0, nStrings );
+ aExtra.DeleteAndDestroy( 0, aExtra.Count() );
+ }
+ return bRet;
+}
+
+
+BOOL WW8GlossaryFib::IsGlossaryFib()
+{
+ if( !nFibError )
+ {
+ INT16 nFibMin;
+ INT16 nFibMax;
+ switch( nVersion ) // beachte: 6 steht fuer "6 ODER 7",
+ // 7 steht fuer "NUR 7"
+ {
+ case 6:
+ nFibMin = 0x0065; // von 101 WinWord 6.0
+ // 102 "
+ // und 103 WinWord 6.0 fuer Macintosh
+ // 104 "
+ nFibMax = 0x0069; // bis 105 WinWord 95
+ break;
+ case 7:
+ nFibMin = 0x0069; // von 105 WinWord 95
+ nFibMax = 0x0069; // bis 105 WinWord 95
+ break;
+ case 8:
+ nFibMin = 0x006A; // von 106 WinWord 97
+ nFibMax = 0x00c1; // bis 193 WinWord 97 (?)
+ break;
+ default:
+ nFibMin = 0; // Programm-Fehler!
+ nFibMax = 0;
+ nFib = 1;
+ }
+ if( ( nFib < nFibMin )
+ || ( nFib > nFibMax ) )
+ nFibError = ERR_SWG_READ_ERROR; // Error melden
+ }
+ return(0 == nFibError);
+}
+
+UINT32 WW8GlossaryFib::FindGlossaryFibOffset(SvStream &rTableStrm,
+ SvStream &rStrm, const WW8Fib &rFib)
+{
+ WW8PLCF aPlc( &rTableStrm, rFib.fcPlcfsed, rFib.lcbPlcfsed, 12 );
+ long start,ende;
+ void *pData;
+ aPlc.Get(start,ende,pData);
+ UINT32 nPo = SVBT32ToLong((BYTE *)pData+2);
+ //*pOut << hex << "Offset of last SEPX is " << nPo << endl;
+
+ UINT16 nLen;
+ if (nPo != 0xFFFFFFFF)
+ {
+ rStrm.Seek(nPo);
+ rStrm >> nLen;
+ }
+ else
+ {
+ nPo=0;
+ nLen=0;
+ }
+
+// *pOut << hex << "Ends at " << nPo+len << endl;
+ nPo+=nLen;
+ UINT32 nEndLastPage;
+ if (nPo%512)
+ {
+ nEndLastPage = (nPo)/512;
+ nEndLastPage = (nEndLastPage+1)*512;
+ }
+ else
+ nEndLastPage = nPo;
+
+ //*pOut << hex << "SECOND FIB SHOULD BE FOUND at " << k << endl;
+
+ WW8PLCF xcPLCF( &rTableStrm, rFib.fcPlcfbteChpx,
+ rFib.lcbPlcfbteChpx, (8 > rFib.nVersion) ? 2 : 4);
+
+ xcPLCF.Get(start,ende,pData);
+
+ nPo = SVBT32ToLong((BYTE *)pData);
+ //*pOut << hex << "Offset of last CHPX is " << (nPo+1) *512<< endl;
+ if (((nPo+1)*512) > nEndLastPage) nEndLastPage = (nPo+1)*512;
+
+ WW8PLCF xpPLCF( &rTableStrm, rFib.fcPlcfbtePapx,
+ rFib.lcbPlcfbtePapx, (8 > rFib.nVersion) ? 2 : 4);
+ xpPLCF.Get(start,ende,pData);
+ nPo = SVBT32ToLong((BYTE *)pData);
+ //*pOut << hex << "Offset of last PAPX is " << nPo *512 << endl;
+ if (((nPo+1)*512) > nEndLastPage) nEndLastPage = (nPo+1)*512;
+
+ //*pOut << hex << "SECOND FIB SHOULD BE FOUND at " << nEndLastPage << endl;
+ return nEndLastPage;
+}
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8glsy.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.8 2000/09/18 16:04:59 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.7 2000/06/26 12:59:10 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.6 2000/05/18 10:58:34 jp
+ Changes for Unicode
+
+ Revision 1.5 2000/05/16 11:08:03 khz
+ Unicode code-conversion
+
+ Revision 1.4 2000/03/13 10:22:14 jp
+ Bug #72579#: little/big endian problem
+
+ Revision 1.3 2000/03/03 14:03:39 os
+ precompiled header
+
+ Revision 1.2 2000/02/28 08:33:46 cmc
+ #72579# Enable Glossary Import
+
+ Revision 1.1 2000/02/14 09:05:56 cmc
+ #72579# added ww8glsy.cxx
+
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/ww8glsy.hxx b/sw/source/filter/ww8/ww8glsy.hxx
new file mode 100644
index 000000000000..4bb5fc77df92
--- /dev/null
+++ b/sw/source/filter/ww8/ww8glsy.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8glsy.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _WW8GLSY_HXX
+#define _WW8GLSY_HXX
+
+#ifndef _SVSTOR_HXX
+#include <so3/svstor.hxx>
+#endif
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+
+
+class SwTextBlocks;
+class SwNodeIndex;
+class SwSpzFrmFmts;
+
+/*
+ * GlossaryFib takes the document fib and finds the glossary fib which may
+ * not exist. The glossary fib has the offsets into the autotext subdocument
+ * which is at the end of template .dot's
+ */
+class WW8GlossaryFib : public WW8Fib
+{
+public:
+ WW8GlossaryFib( SvStream& rStrm, BYTE nWantedVersion ,
+ SvStream& rTableStrm, const WW8Fib &rFib) : WW8Fib(rStrm,
+ nWantedVersion,FindGlossaryFibOffset(rTableStrm,rStrm,rFib)) {}
+ BOOL IsGlossaryFib();
+private:
+ UINT32 FindGlossaryFibOffset(SvStream &rTableStrm,SvStream &rStrm,
+ const WW8Fib &rFib);
+};
+
+/*
+ * Imports glossaries from word, given the document it gets the usual word
+ * doc information, then the glossary fib and uses the usual reader class to
+ * wrap the autotext into a star doc. Afterwards taking each section entry and
+ * making it a single star autotext entry.
+ *
+ * ToDo currently all autotext entries become resource hungry star autotext
+ * formatted text, need to use a flag in the ww8reader class to determine if
+ * an entry is formatted or not.
+ */
+class WW8Glossary
+{
+public:
+ WW8Glossary( SvStorageStreamRef &refStrm, BYTE nVersion, SvStorage *pStg=0);
+ BOOL Load( SwTextBlocks &rBlocks, BOOL bSaveRelFile );
+ ~WW8Glossary() { delete pGlossary; }
+ WW8GlossaryFib *GetFib() { return pGlossary; }
+ USHORT GetNoStrings() const { return nStrings; }
+
+private:
+ WW8GlossaryFib *pGlossary;
+ SvStorageStreamRef xTableStream;
+ SvStorageStreamRef &rStrm;
+ SvStorageRef xStg;
+ USHORT nStrings;
+
+ BOOL MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks, BOOL bSaveRelFile,
+ SvStrings& rStrings, SvStrings& rExtra);
+ BOOL HasBareGraphicEnd(SwDoc *pD,SwNodeIndex &rIdx);
+};
+
+
+
+
+
+#endif
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
new file mode 100644
index 000000000000..b72e5aefcef9
--- /dev/null
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -0,0 +1,3174 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8graf.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#include <math.h>
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _SVX_FMGLOB_HXX
+#include <svx/fmglob.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _SDTAITM_HXX
+#include <svx/sdtaitm.hxx>
+#endif
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_SHORTS
+#include <svtools/svstdarr.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_XLINIIT_HXX //autogen
+#include <svx/xlineit.hxx>
+#endif
+#ifndef _SVX_FILLITEM_HXX //autogen
+#include <svx/xfillit.hxx>
+#endif
+#ifndef _SVDMODEL_HXX //autogen
+#include <svx/svdmodel.hxx>
+#endif
+#ifndef _SDTAITM_HXX //autogen
+#include <svx/sdtaitm.hxx>
+#endif
+#ifndef _SVDCAPT_HXX //autogen
+#include <svx/svdocapt.hxx>
+#endif
+#ifndef _SXCTITM_HXX //autogen
+#include <svx/sxctitm.hxx>
+#endif
+#ifndef _MyEDITENG_HXX
+#include <svx/editeng.hxx>
+#endif
+#ifndef _SVDPAGE_HXX //autogen
+#include <svx/svdpage.hxx>
+#endif
+#ifndef _SVDOPATH_HXX //autogen
+#include <svx/svdopath.hxx>
+#endif
+#ifndef _SVDOCIRC_HXX //autogen
+#include <svx/svdocirc.hxx>
+#endif
+#ifndef _OUTLOBJ_HXX //autogen
+#include <svx/outlobj.hxx>
+#endif
+#ifndef _SVDOGRP_HXX //autogen
+#include <svx/svdogrp.hxx>
+#endif
+#ifndef _SVDOGRAF_HXX
+#include <svx/svdograf.hxx>
+#endif
+#ifndef _SVDOOLE2_HXX
+#include <svx/svdoole2.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_CNTRITEM_HXX
+#include <svx/cntritem.hxx>
+#endif
+#ifndef _SVX_SHDDITEM_HXX
+#include <svx/shdditem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _TOOLS_URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _SVX_IMPGRF_HXX
+#include <svx/impgrf.hxx>
+#endif
+#ifndef _MSDFFIMP_HXX
+#include <svx/msdffimp.hxx>
+#endif
+#ifndef _SVDOATTR_HXX
+#include <svx/svdoattr.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_RECTENUM_HXX //autogen
+#include <svx/rectenum.hxx>
+#endif
+#ifndef _SVX_XFLTRIT_HXX
+#include <svx/xfltrit.hxx>
+#endif
+#ifndef _SVX_OPAQITEM_HXX //autogen
+#include <svx/opaqitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+
+#ifndef _IPOBJ_HXX //autogen
+#include <so3/ipobj.hxx>
+#endif
+
+#ifndef _WW8STRUC_HXX
+#include <ww8struc.hxx>
+#endif
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx> // class SwWWImplReader
+#endif
+#ifndef _WW8GRAF_HXX
+#include <ww8graf.hxx>
+#endif
+#ifndef _WW8PAR2_HXX
+#include <ww8par2.hxx> // SwWW8StyInf
+#endif
+#ifndef _GRFATR_HXX
+#include <grfatr.hxx> // class SwCropGrf
+#endif
+#ifndef _FMTORNT_HXX
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDGRF_HXX
+#include <ndgrf.hxx>
+#endif
+#ifndef _DCONTACT_HXX
+#include <dcontact.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // Progress
+#endif
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx>
+#endif
+#ifndef _FMTCNCT_HXX
+#include <fmtcnct.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::uno;
+using namespace ::ucb;
+using namespace ::rtl;
+
+// Hilfsroutinen
+
+// inline geht bei BLC leider nicht mit "for"
+/*inline*/ Color WW8TransCol( SVBT32 nWC )
+{
+#if 1 // 1 = Vordefinierte Farben benutzen, 0 = ignorieren
+
+ // Farbtabelle zum Umrechnen RGB-Werte in vordefinierte Farben
+ // ( Damit bei der Writer-UI die Farbnamen stimmen )
+ // Die Tabelle int im *3er-System* aufgeteilt. Die Grauwerte fehlen,
+ // da sie nicht ins 3er-System passen ( 4 Werte: sw, ws, 2 * grau )
+ static ColorData eColA[] = { // B G R B G R B G R
+ COL_BLACK, COL_RED, COL_LIGHTRED, // 0 0 0, 0 0 1, 0 0 2
+ COL_GREEN, COL_BROWN, COL_BLACK, // 0 1 0, 0 1 1, 0 1 2
+ COL_LIGHTGREEN, COL_BLACK, COL_YELLOW, // 0 2 0, 0 2 1, 0 2 2
+ COL_BLUE, COL_MAGENTA, COL_BLACK, // 1 0 0, 1 0 1, 1 0 2
+ COL_CYAN, COL_LIGHTGRAY, COL_BLACK, // 1 1 0, 1 1 1, 1 1 2
+ COL_BLACK, COL_BLACK, COL_BLACK, // 1 2 0, 1 2 1, 1 2 2
+ COL_LIGHTBLUE, COL_BLACK, COL_LIGHTMAGENTA, // 2 0 0, 2 0 1, 2 0 2
+ COL_BLACK, COL_BLACK, COL_BLACK, // 2 1 0, 2 1 1, 2 1 2
+ COL_LIGHTCYAN, COL_BLACK, COL_WHITE }; // 2 2 0, 2 2 1, 2 2 2
+
+ // In nWC[3] steht ein Byte, dass in der WW-Doku nicht beschrieben ist.
+ // Die Bedeutung ist anscheinend folgende: Bei 0 ist es eine normale
+ // Farbe, dessen RGB-Wert in nWC[0..2] steht. stehen in nWC[3] die
+ // Werte 0x1, 0x7d oder 0x83, dann ist es ein Grauwert, dessen
+ // Schwarzanteil in 1/2 % in nWC[0] steht.
+ // Ich vermute, dass es auf Bit0 in nWV[3] ankommt, ob es RGB oder Grau ist.
+
+ if( !( nWC[3] & 0x1 ) && // keine Spezial-Farbe (grau)
+ ( ( nWC[0] == 0 || nWC[0]== 0x80 || nWC[0] == 0xff ) // R-Anteil
+ && ( nWC[1] == 0 || nWC[1]== 0x80 || nWC[1] == 0xff ) // G-Anteil
+ && ( nWC[2] == 0 || nWC[2]== 0x80 || nWC[2] == 0xff ) ) ){// B-Anteil
+ int nIdx = 0; // und nun: Idx-Berechnung im 3er-System
+ for( int i = 2; i >= 0; i-- ){
+ nIdx *= 3;
+ if( nWC[i] )
+ nIdx += ( ( nWC[i] == 0xff ) ? 2 : 1 );
+ }
+ if( eColA[ nIdx ] != COL_BLACK )
+ return Color( eColA[ nIdx ] ); // Standard-Color
+ }
+#endif
+ if( nWC[3] & 0x1 ){ // Spezialfarbe: Grau
+#ifdef VCL
+ register BYTE u = (BYTE)( (ULONG)( 200 - nWC[0] ) * 256 / 200 );
+#else
+ register USHORT u = (USHORT)( (ULONG)( 200 - nWC[0] ) * 65535L / 200 );
+#endif
+ return Color( u, u, u );
+ }
+ // User-Color
+ return Color( (USHORT)nWC[0] << 8, (USHORT)nWC[1] << 8,
+ (USHORT)nWC[2] << 8 );
+}
+
+
+
+// MakeUniqueGraphName erzeugt einen einzigartigen Namen fuer eine Grafik
+// ( nur falls nicht bNew gesetzt ist )
+
+BOOL SwWW8ImplReader::MakeUniqueGraphName( String& rName,
+ const String& rFixedPart )
+{
+ if( !bNew )
+ return FALSE;
+ nImportedGraphicsCount++;
+ rName = WW8_ASCII2STR( "G" );
+ rName += String::CreateFromInt32( nImportedGraphicsCount );
+ rName += WW8_ASCII2STR( ": " );
+ rName += rFixedPart;
+ return TRUE;
+}
+
+
+
+// ReadGrafStart liest die ObjektDaten ein und erzeugt falls noetig einen Anker
+
+BOOL SwWW8ImplReader::ReadGrafStart( void* pData, short nDataSiz, WW8_DPHEAD* pHd,
+ WW8_DO* pDo )
+{
+ if( (INT16)SVBT16ToShort( pHd->cb )
+ < (short)sizeof( WW8_DPHEAD ) + nDataSiz ){
+ ASSERT( !this, "+Grafik-Element: Size ?" );
+ pStrm->SeekRel( (INT16)SVBT16ToShort( pHd->cb ) - sizeof( WW8_DPHEAD ) );
+ return FALSE;
+ }
+ pStrm->Read( pData, nDataSiz );
+
+ RndStdIds eAnchor = ( SVBT8ToByte( pDo->by ) < 2 ) ? FLY_PAGE : FLY_AT_CNTNT;
+ if( (bIsHeader || bIsFooter) && (FLY_AT_CNTNT != eAnchor) )
+ {
+ eAnchor = FLY_AT_CNTNT;
+ pNode_FLY_AT_CNTNT = &pPaM->GetPoint()->nNode.GetNode();
+ }
+
+ pDrawFmt->SetAttr( SwFmtAnchor( eAnchor, 1 ) );
+ pCtrlStck->NewAttr( *pPaM->GetPoint(), SwFltAnchor( pDrawFmt ) );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_ANCHOR );
+
+ nDrawXOfs2 = nDrawXOfs;
+ nDrawYOfs2 = nDrawYOfs;
+
+ if( eAnchor == FLY_AT_CNTNT ){
+ if( SVBT8ToByte( pDo->bx ) == 1 ) // Pos: echt links
+ nDrawXOfs2 -= nPgLeft;
+ if( bTable ) // Obj in Table
+ nDrawXOfs2 -= GetTableLeft(); // -> siehe Kommentar
+ // bei GetTableLeft()
+ }else{
+ if( SVBT8ToByte( pDo->bx ) != 1 )
+ nDrawXOfs2 += nPgLeft;
+ if( SVBT8ToByte( pDo->by ) == 0 )
+ nDrawYOfs2 += nPgTop;
+ }
+
+ return TRUE;
+}
+
+// SetStdAttr() setzt die Attribute, die jedes Objekt hat
+
+static void SetStdAttr( SfxItemSet& rSet, WW8_DP_LINETYPE& rL,
+ WW8_DP_SHADOW& rSh )
+{
+ if( SVBT16ToShort( rL.lnps ) == 5 ){ // unsichtbar
+ rSet.Put( XLineStyleItem( XLINE_NONE ) );
+ }else{ // sichtbar
+ Color aCol( WW8TransCol( rL.lnpc ) ); // LinienFarbe
+ rSet.Put( XLineColorItem( aEmptyStr, aCol ) );
+ rSet.Put( XLineWidthItem( SVBT16ToShort( rL.lnpw ) ) );
+ // LinienDicke
+ if( SVBT16ToShort( rL.lnps ) >= 1
+ && SVBT16ToShort(rL.lnps ) <= 4 ){ // LinienStil
+ rSet.Put( XLineStyleItem( XLINE_DASH ) );
+ INT16 nLen = SVBT16ToShort( rL.lnpw );
+ XDash aD( XDASH_RECT, 1, 2 * nLen, 1, 5 * nLen, 5 * nLen );
+ switch( SVBT16ToShort( rL.lnps ) ){
+ case 1: aD.SetDots( 0 ); // Dash
+ aD.SetDashLen( 6 * nLen );
+ aD.SetDistance( 4 * nLen );
+ break;
+ case 2: aD.SetDashes( 0 ); break; // Dot
+ case 3: break; // Dash Dot
+ case 4: aD.SetDots( 2 ); break; // Dash Dot Dot
+ }
+ rSet.Put( XLineDashItem( aEmptyStr, aD ) );
+ }else{
+ rSet.Put( XLineStyleItem( XLINE_SOLID ) ); // noetig fuer TextBox
+ }
+ }
+ if( SVBT16ToShort( rSh.shdwpi ) ){ // Schatten
+ rSet.Put( SdrShadowItem( TRUE ) );
+ rSet.Put( SdrShadowXDistItem( SVBT16ToShort( rSh.xaOffset ) ) );
+ rSet.Put( SdrShadowYDistItem( SVBT16ToShort( rSh.yaOffset ) ) );
+ }
+}
+
+// SetFill setzt Fuellattribute wie Vordergrund- und Hintergrund-Farbe
+// und Muster durch Reduktion auf eine Farbe.
+// SetFill() setzt z.Zt kein Muster, da Sdr das nur sehr umstaendlich kann
+// und die Sdr-Schraffur ( XDash ) noch nicht fertig ist.
+// Statt dessen wird eine Mischfarbe gewaehlt, die auf den entsprechenden
+// Farbton zwischen den Farben liegt.
+
+static void SetFill( SfxItemSet& rSet, WW8_DP_FILL& rFill )
+{
+ static BYTE nPatA[] = { 0, 0, 5, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80,
+ 90, 50, 50, 50, 50,50, 50, 33, 33, 33, 33, 33, 33 };
+ register short nPat = SVBT16ToShort( rFill.flpp );
+
+ if( nPat == 0 ){ // durchsichtig
+ rSet.Put( XFillStyleItem( XFILL_NONE ) );
+ }else{
+ rSet.Put( XFillStyleItem( XFILL_SOLID ) ); // noetig fuer TextBox
+ if( nPat <= 1 || nPat > sizeof( nPatA ) ){ // solid Bg oder unbekannt
+ rSet.Put( XFillColorItem( aEmptyStr, WW8TransCol( rFill.dlpcBg ) ) );
+ }else{ // Brush -> Farbmischung
+ Color aB( WW8TransCol( rFill.dlpcBg ) );
+ Color aF( WW8TransCol( rFill.dlpcFg ) );
+#ifdef VCL
+ aB.SetRed( (BYTE)( ( (ULONG)aF.GetRed() * nPatA[nPat]
+ + (ULONG)aB.GetRed() * ( 100 - nPatA[nPat] ) ) / 100 ) );
+ aB.SetGreen( (BYTE)( ( (ULONG)aF.GetGreen() * nPatA[nPat]
+ + (ULONG)aB.GetGreen() * ( 100 - nPatA[nPat] ) ) / 100 ) );
+ aB.SetBlue( (BYTE)( ( (ULONG)aF.GetBlue() * nPatA[nPat]
+ + (ULONG)aB.GetBlue() * ( 100 - nPatA[nPat] ) ) / 100 ) );
+#else
+ aB.SetRed( (USHORT)( ( (ULONG)aF.GetRed() * nPatA[nPat]
+ + (ULONG)aB.GetRed() * ( 100 - nPatA[nPat] ) ) / 100 ) );
+ aB.SetGreen( (USHORT)( ( (ULONG)aF.GetGreen() * nPatA[nPat]
+ + (ULONG)aB.GetGreen() * ( 100 - nPatA[nPat] ) ) / 100 ) );
+ aB.SetBlue( (USHORT)( ( (ULONG)aF.GetBlue() * nPatA[nPat]
+ + (ULONG)aB.GetBlue() * ( 100 - nPatA[nPat] ) ) / 100 ) );
+#endif
+ rSet.Put( XFillColorItem( aEmptyStr, aB ) );
+ }
+ }
+}
+
+static void SetLineEndAttr( SfxItemSet& rSet, WW8_DP_LINEEND& rLe,
+ WW8_DP_LINETYPE& rLt )
+{
+ UINT16 aSB = SVBT16ToShort( rLe.aStartBits );
+ if( aSB & 0x3 ){
+ XPolygon aXP(3);
+ aXP[0] = Point( 0, 330 );
+ aXP[1] = Point( 100, 0 );
+ aXP[2] = Point( 200, 330 );
+ rSet.Put( XLineEndItem( aEmptyStr, aXP ) );
+ USHORT nSiz = SVBT16ToShort( rLt.lnpw )
+ * ( ( aSB >> 2 & 0x3 ) + ( aSB >> 4 & 0x3 ) );
+ if( nSiz < 220 ) nSiz = 220;
+ rSet.Put( XLineEndWidthItem( nSiz ) );
+ rSet.Put( XLineEndCenterItem( FALSE ) );
+ }
+
+ UINT16 aEB = SVBT16ToShort( rLe.aEndBits );
+ if( aEB & 0x3 ){
+ XPolygon aXP(3);
+ aXP[0] = Point( 0, 330 );
+ aXP[1] = Point( 100, 0 );
+ aXP[2] = Point( 200, 330 );
+ rSet.Put( XLineStartItem( aEmptyStr, aXP ) );
+ USHORT nSiz = SVBT16ToShort( rLt.lnpw )
+ * ( ( aEB >> 2 & 0x3 ) + ( aEB >> 4 & 0x3 ) );
+ if( nSiz < 220 ) nSiz = 220;
+ rSet.Put( XLineStartWidthItem( nSiz ) );
+ rSet.Put( XLineStartCenterItem( FALSE ) );
+ }
+}
+
+// Parallel zu dem Obj-Array im Dokument baue ich ein Array auf,
+// dass die Ww-Height ( -> Wer ueberdeckt wen ) beinhaltet.
+// Anhand dieses VARARR wird die Einfuegeposition ermittelt.
+// Der Offset bei Datei in bestehendes Dokument mit Grafiklayer einfuegen
+// muss der Aufrufer den Index um nDrawObjOfs erhoeht werden, damit die
+// neuen Objekte am Ende landen ( Einfuegen ist dann schneller )
+static USHORT SearchPos( SvShorts* pHeight, short nWwHeight )
+{
+ USHORT i, nMax = pHeight->Count();
+ for( i=0; i<nMax; i++ ) // lineare Suche: langsam
+ if( ( pHeight->GetObject( i ) & 0x1fff ) > ( nWwHeight & 0x1fff ) )
+ return i; // vor i-tem Objekt einfuegen
+ return nMax; // am Ende anhaengen
+}
+
+// InsertObj() fuegt das Objekt in die Sw-Page ein und merkt sich die Z-Pos in
+// einem VarArr
+
+void SwWW8ImplReader::InsertObj( SdrObject* pObj, short nWwHeight )
+{
+ if( pDrawGroup )
+ pDrawGroup->InsertObject( pObj, 0 ); // Group: Vorne einfuegen
+ else
+ {
+ SwDrawContact* pContact = new SwDrawContact( pDrawFmt, pObj );
+ USHORT nPos = SearchPos( pDrawHeight, nWwHeight );
+ if( nWwHeight & 0x2000 ) // Heaven ?
+ pObj->SetLayer( nDrawHeaven );
+ else
+ {
+ pObj->SetLayer( nDrawHell );
+ pDrawFmt->SetAttr( SvxOpaqueItem( RES_OPAQUE, FALSE ) );
+ }
+ pDrawFmt->SetAttr( SwFmtSurround( SURROUND_THROUGHT ) );
+
+ pDrawPg->InsertObject( pObj, nDrawObjOfs + nPos );
+ pDrawHeight->Insert( nWwHeight, nPos ); // Pflege WW-Height-Array mit
+
+ // Wenn es sich um seitengebundene Anker handelt, muss man noch
+ // ein Problem umpopeln: Da ich die Seitennummer nicht weiss,
+ // stecke ich den PaM stattdessen in den Anker. MA setzt das
+ // bei der Formatierung dann um. Bis die Formatierung beim Anker
+ // ist, liegen alle seitengebundenen Grafiken auf der 1. Seite,
+ // dann verschwinden sie.
+ // Abhilfe: AnkerPos initial weit auuserhalb des sichtbaren Bereiches
+ // stellen, nach der Formatierung korrigiert MA sie.
+ // schneller waere: ImpSetAnchor() statt NbcSetAnchor, allerdings
+ // muesste dann die Relative Pos aller Objekte um die Ankerpos
+ // korrigiert werden.
+ pObj->NbcSetAnchorPos( Point( USHRT_MAX, USHRT_MAX ) );
+
+ pContact->ConnectToLayout( &pDrawFmt->GetAnchor() );
+ }
+}
+
+// Ab hier folgen die Routinen fuer die einzelnen Objekte
+
+void SwWW8ImplReader::ReadLine( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ WW8_DP_LINE aLine;
+
+ if( !ReadGrafStart( (void*)&aLine, sizeof( aLine ), pHd, pDo ) )
+ return;
+
+ Point aP[2];
+ {
+ Point& rP0 = aP[0];
+ Point& rP1 = aP[1];
+
+ rP0.X() = (INT16)SVBT16ToShort( pHd->xa ) + nDrawXOfs2;
+ rP0.Y() = (INT16)SVBT16ToShort( pHd->ya ) + nDrawYOfs2;
+ rP1 = rP0;
+ rP0.X() += (INT16)SVBT16ToShort( aLine.xaStart );
+ rP0.Y() += (INT16)SVBT16ToShort( aLine.yaStart );
+ rP1.X() += (INT16)SVBT16ToShort( aLine.xaEnd );
+ rP1.Y() += (INT16)SVBT16ToShort( aLine.yaEnd );
+ }
+ SdrObject* pObj = new SdrPathObj( OBJ_LINE, XPolygon( Polygon( 2, aP ) ) );
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ SetStdAttr( aSet, aLine.aLnt, aLine.aShd );
+ SetLineEndAttr( aSet, aLine.aEpp, aLine.aLnt );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+void SwWW8ImplReader::ReadRect( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ WW8_DP_RECT aRect;
+
+ if( !ReadGrafStart( (void*)&aRect, sizeof( aRect ), pHd, pDo ) )
+ return;
+
+ Point aP0( (INT16)SVBT16ToShort( pHd->xa ) + nDrawXOfs2,
+ (INT16)SVBT16ToShort( pHd->ya ) + nDrawYOfs2 );
+ Point aP1( aP0 );
+ aP1.X() += (INT16)SVBT16ToShort( pHd->dxa );
+ aP1.Y() += (INT16)SVBT16ToShort( pHd->dya );
+
+ SdrObject* pObj = new SdrRectObj( Rectangle( aP0, aP1 ) );
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ SetStdAttr( aSet, aRect.aLnt, aRect.aShd );
+ SetFill( aSet, aRect.aFill );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+void SwWW8ImplReader::ReadElipse( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ WW8_DP_ELIPSE aElipse;
+
+ if( !ReadGrafStart( (void*)&aElipse, sizeof( aElipse ), pHd, pDo ) )
+ return;
+
+ Point aP0( (INT16)SVBT16ToShort( pHd->xa ) + nDrawXOfs2,
+ (INT16)SVBT16ToShort( pHd->ya ) + nDrawYOfs2 );
+ Point aP1( aP0 );
+ aP1.X() += (INT16)SVBT16ToShort( pHd->dxa );
+ aP1.Y() += (INT16)SVBT16ToShort( pHd->dya );
+
+ SdrObject* pObj = new SdrCircObj( OBJ_CIRC, Rectangle( aP0, aP1 ) );
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ SetStdAttr( aSet, aElipse.aLnt, aElipse.aShd );
+ SetFill( aSet, aElipse.aFill );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+void SwWW8ImplReader::ReadArc( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ WW8_DP_ARC aArc;
+
+ if( !ReadGrafStart( (void*)&aArc, sizeof( aArc ), pHd, pDo ) )
+ return;
+
+ Point aP0( (INT16)SVBT16ToShort( pHd->xa ) + nDrawXOfs2,
+ (INT16)SVBT16ToShort( pHd->ya ) + nDrawYOfs2 );
+ Point aP1( aP0 );
+ aP1.X() += (INT16)SVBT16ToShort( pHd->dxa ) * 2;
+ aP1.Y() += (INT16)SVBT16ToShort( pHd->dya ) * 2;
+
+ short nA[] = { 2, 3, 1, 0 };
+ short nW = nA[ ( ( SVBT8ToByte( aArc.fLeft ) & 1 ) << 1 )
+ + ( SVBT8ToByte( aArc.fUp ) & 1 ) ];
+ if( !SVBT8ToByte( aArc.fLeft ) ){
+ aP0.Y() -= (INT16)SVBT16ToShort( pHd->dya );
+ aP1.Y() -= (INT16)SVBT16ToShort( pHd->dya );
+ }
+ if( SVBT8ToByte( aArc.fUp ) ){
+ aP0.X() -= (INT16)SVBT16ToShort( pHd->dxa );
+ aP1.X() -= (INT16)SVBT16ToShort( pHd->dxa );
+ }
+
+ SdrObject* pObj = new SdrCircObj( OBJ_SECT, Rectangle( aP0, aP1 ),
+ nW * 9000, ( ( nW + 1 ) & 3 ) * 9000 );
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ SetStdAttr( aSet, aArc.aLnt, aArc.aShd );
+ SetFill( aSet, aArc.aFill );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+void SwWW8ImplReader::ReadPolyLine( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ WW8_DP_POLYLINE aPoly;
+
+ if( !ReadGrafStart( (void*)&aPoly, sizeof( aPoly ), pHd, pDo ) )
+ return;
+
+ UINT16 nCount = SVBT16ToShort( aPoly.aBits1 ) >> 1 & 0x7fff;
+ SVBT16 *pP = new SVBT16[nCount * 2];
+ pStrm->Read( pP, nCount * 4 ); // Punkte einlesen
+ Polygon aP( nCount );
+ Point aPt;
+ USHORT i;
+
+ for( i=0; i<nCount; i++ ){
+ aPt.X() = SVBT16ToShort( pP[i << 1] ) + nDrawXOfs2
+ + (INT16)SVBT16ToShort( pHd->xa );
+ aPt.Y() = SVBT16ToShort( pP[( i << 1 ) + 1] ) + nDrawYOfs2
+ + (INT16)SVBT16ToShort( pHd->ya );
+ aP[i] = aPt;
+ }
+ delete[]( pP );
+
+ SdrObject* pObj = new SdrPathObj(
+ ( SVBT16ToShort( aPoly.aBits1 ) & 0x1 ) ? OBJ_POLY : OBJ_PLIN,
+ XPolygon( aP ) );
+
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ SetStdAttr( aSet, aPoly.aLnt, aPoly.aShd );
+ SetFill( aSet, aPoly.aFill );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+ESelection SwWW8ImplReader::GetESelection( long nCpStart, long nCpEnd )
+{
+ USHORT nPCnt = pDrawEditEngine->GetParagraphCount();
+ USHORT nSP = 0;
+ USHORT nEP = 0;
+ while( (nSP < nPCnt)
+ && (nCpStart >= pDrawEditEngine->GetTextLen( nSP ) + 1) )
+ {
+ nCpStart -= pDrawEditEngine->GetTextLen( nSP ) + 1;
+ nSP++;
+ }
+ // Beim Ende erst 1 Zeichen spaeter auf naechste Zeile umschalten,
+ // da sonst Zeilenattribute immer eine Zeile zu weit reichen.
+ while( (nEP < nPCnt)
+ && (nCpEnd > pDrawEditEngine->GetTextLen( nEP ) + 1) )
+ {
+ nCpEnd -= pDrawEditEngine->GetTextLen( nEP ) + 1;
+ nEP++;
+ }
+ return ESelection( nSP, (USHORT)nCpStart, nEP, (USHORT)nCpEnd );
+}
+
+// GetTxbxCharAttrs() setzt die harten Zeichen-Attribute in den angegebenen Set.
+// Toggle-Attribute werden z.Zt. nicht beruecksichtigt
+void SwWW8ImplReader::GetTxbxPapAndCharAttrs( SfxItemSet& rS,
+ const WW8PLCFManResult& rRes )
+{
+ static SvxAdjust aAdjArr[] = { SVX_ADJUST_LEFT,
+ SVX_ADJUST_CENTER,
+ SVX_ADJUST_RIGHT,
+ SVX_ADJUST_BLOCK };
+
+ BYTE* pData = rRes.pMemPos + 1 + (8 > pWwFib->nVersion ? 0 : 1)
+ + WW8SprmDataOfs( rRes.nSprmId );
+
+ switch( rRes.nSprmId )
+ {
+ //
+ // PAP attributes
+ //
+ case 5:
+ case 0x2403: rS.Put(SvxAdjustItem(
+ aAdjArr[pData[0]&0x3], EE_PARA_JUST ) );
+ // "&0x3 gegen Tabellenueberlauf bei Stuss-Werten
+ break;
+ case 21:
+ case 0xA413:
+ case 22:
+ case 0xA414:
+ {
+ short nPara = SVBT16ToShort( pData );
+ if( nPara < 0 )
+ nPara = -nPara;
+
+ SvxULSpaceItem aUL((SvxULSpaceItem&)rS.Get(EE_PARA_ULSPACE, TRUE));
+
+ if( 1 & rRes.nSprmId ) // 21, 0xA413 resp.
+ aUL.SetUpper( nPara );
+ else // 22, 0xA414 resp.
+ aUL.SetLower( nPara );
+ rS.Put( aUL );
+ };
+ break;
+ //
+ // CHAR attributes
+ //
+ case 85:
+ case 0x0835: rS.Put( SvxWeightItem( (*pData & 0x1)?WEIGHT_BOLD:WEIGHT_NORMAL,
+ EE_CHAR_WEIGHT ) );
+ break;
+ case 86:
+ case 0x0836: rS.Put( SvxPostureItem( (*pData & 0x1)?ITALIC_NORMAL:ITALIC_NONE,
+ EE_CHAR_ITALIC ) );
+ break;
+ case 87:
+ case 0x0837: rS.Put( SvxCrossedOutItem( (*pData & 0x1)?STRIKEOUT_SINGLE:STRIKEOUT_NONE,
+ EE_CHAR_STRIKEOUT ) );
+ break;
+ case 88:
+ case 0x0838: rS.Put( SvxContourItem( *pData & 0x1, EE_CHAR_OUTLINE));
+ break;
+ case 89:
+ case 0x0839: rS.Put( SvxShadowedItem( *pData & 0x1, EE_CHAR_SHADOW));
+ break;
+ case 94:
+ case 0x2A3E:if( (1 > *pData)
+ ||
+ ( (4 < *pData)
+ && (6 != *pData) ) )
+ rS.Put( SvxUnderlineItem(UNDERLINE_NONE,
+ EE_CHAR_UNDERLINE) );
+ else
+ {
+ if( 6 == *pData )
+ rS.Put( SvxWeightItem(WEIGHT_BOLD,
+ EE_CHAR_WEIGHT) );
+ rS.Put( SvxUnderlineItem(UNDERLINE_SINGLE,
+ EE_CHAR_UNDERLINE) );
+ }
+ break;
+ case 98:
+ case 0x2A42: rS.Put( SvxColorItem( Color( GetCol( pData[0] ) ),
+ EE_CHAR_COLOR ) );
+ break;
+ case 99:
+ case 0x4A43:{
+ USHORT nFSize = SVBT16ToShort( pData );
+ // Font-Groesse in halben Point
+ // 10 = 1440 / ( 72 * 2 )
+ rS.Put( SvxFontHeightItem(
+ (const ULONG) ( (ULONG) nFSize * 10 ),
+ 100, EE_CHAR_FONTHEIGHT ) );
+ }
+ break;
+ case 93:
+ case 0x4A4F:{
+ USHORT nFCode = SVBT16ToShort( pData ); // Font-Nummer
+ FontFamily eFamily;
+ String aName;
+ FontPitch ePitch;
+ CharSet eSrcCharSet;
+
+ if( GetFontParams( nFCode, eFamily, aName, ePitch,
+ eSrcCharSet ) )
+ {
+ rS.Put( SvxFontItem( eFamily, aName, aEmptyStr, ePitch,
+ eSrcCharSet, EE_CHAR_FONTINFO ) );
+ }
+ }
+ break;
+ }
+}
+
+/*
+// InsertTxbxCharAttrs() setzt die harten Zeichen-Attribute
+void SwWW8ImplReader::InsertTxbxCharAttrs( long nStartCp, long nEndCp, BOOL bONLYnPicLocFc )
+{
+ nStartCp += nDrawCpO;
+ nEndCp += nDrawCpO;
+ WW8PLCFx_Cp_FKP* pChp = pPlcxMan->GetChpPLCF();
+ pChp->SeekPos( nStartCp );
+
+ nPicLocFc = LONG_MAX;
+ WW8_CP nStart = pChp->Where();
+ while( nStart <= nEndCp )
+ {
+ SfxItemSet aS( pDrawEditEngine->GetEmptyItemSet() );
+ WW8PLCFxDesc aDesc;
+ pChp->GetSprms( &aDesc );
+ (*pChp)++;
+ WW8_CP nNextEnd = pChp->Where();
+ WW8_CP nEnd = ( nNextEnd < nEndCp ) ? nNextEnd : nEndCp;
+
+ if( aDesc.nSprmsLen && aDesc.pMemPos ) // Attribut(e) vorhanden?
+ GetTxbxCharAttrs( aS, aDesc, bONLYnPicLocFc );
+
+ if( bONLYnPicLocFc ) // Picture-Position-Attribut gefunden?
+ {
+ if( LONG_MAX != nPicLocFc ) break;
+ // ==================================
+ }
+ else
+ if( aS.Count() && !bONLYnPicLocFc )
+ pDrawEditEngine->QuickSetAttribs( aS,
+ GetESelection( nStart - nStartCp, nEnd - nStartCp ) );
+ nStart = nNextEnd;
+ }
+ if( LONG_MAX == nPicLocFc ) nPicLocFc = 0;
+}
+
+// GetTxbxParaAttrs() setzt die harten Para-Attribute in den angegebenen Set.
+// z.Zt. wird nur Justify beachtet, da einfacher
+void SwWW8ImplReader::GetTxbxParaAttrs( SfxItemSet& rS, const WW8PLCFxDesc& rD )
+{
+ static SvxAdjust aAdjArr[] = { SVX_ADJUST_LEFT,
+ SVX_ADJUST_CENTER, SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK };
+
+ long nLen = rD.nSprmsLen;
+ BYTE* pSprm = rD.pMemPos;
+
+ while( nLen >= 2 )
+ {
+ BYTE nDelta;
+ USHORT nId = WW8GetSprmId( pWwFib->nVersion, pSprm, &nDelta );
+
+ short nSL = WW8GetSprmSizeBrutto( pWwFib->nVersion, pSprm, &nId );
+
+ if( nLen < nSL )
+ return; // nicht mehr genug Bytes ueber
+
+ BYTE* pData = pSprm + 1 + nDelta + WW8SprmDataOfs( nId );
+
+ switch( nId )
+ {
+ case 5:
+ case 0x2403: rS.Put(SvxAdjustItem(
+ aAdjArr[pData[0]&0x3], EE_PARA_JUST ) );
+ // "&0x3 gegen Tabellenueberlauf bei Stuss-Werten
+ break;
+ case 21:
+ case 0xA413:
+ case 22:
+ case 0xA414:
+ {
+ short nPara = SVBT16ToShort( pData );
+ if( nPara < 0 )
+ nPara = -nPara;
+
+ SvxULSpaceItem aUL( (SvxULSpaceItem&)rS.Get(EE_PARA_ULSPACE,TRUE ));
+
+ switch( nId ){ // keine Versuche
+ case 21:
+ case 0xA413: aUL.SetUpper( nPara ); break;
+ case 22:
+ case 0xA414: aUL.SetLower( nPara ); break;
+ };
+ rS.Put( aUL );
+ };
+ break;
+ }
+ pSprm += nSL;
+ nLen -= nSL;
+ }
+}
+*/
+// InsertTxbxStyAttrs() setzt die Style-Attribute in den uebergebenen ItemSet.
+// Es werden die SW-Styles genommen, die Import-WW-Styles sind zu diesem
+// Zeitpunkt schon destruiert.
+// Die SW-Styles werden per Tiefensuche, d.h. mit Parent-Styles nach den
+// in aSrcTab angegebenen Attributen untersucht. Diese werden per Clone
+// dupliziert, bei den Duplikaten werden die Which-IDs
+// gemaess der Tabelle aDstTab umgesetzt, damit die EditEngine sie nicht
+// ignoriert.
+// Es werden hierbei sowohl Para- wie auch Zeichen-Attribute in den
+// ItemSet gestopft.
+void SwWW8ImplReader::InsertTxbxStyAttrs( SfxItemSet& rS, USHORT nColl )
+{
+ static USHORT __READONLY_DATA aSrcTab[] = {
+ ITEMID_FONT,
+ ITEMID_POSTURE,
+ ITEMID_WEIGHT,
+ ITEMID_SHADOWED,
+ ITEMID_CONTOUR,
+ ITEMID_CROSSEDOUT,
+ ITEMID_UNDERLINE,
+ ITEMID_FONTHEIGHT,
+ ITEMID_COLOR,
+ ITEMID_WORDLINEMODE,
+ ITEMID_ESCAPEMENT,
+ ITEMID_AUTOKERN,
+ ITEMID_KERNING,
+ ITEMID_ADJUST,
+ ITEMID_LINESPACING,
+ ITEMID_TABSTOP,
+ ITEMID_LRSPACE,
+ ITEMID_ULSPACE };
+
+ static USHORT __READONLY_DATA aDstTab[] = {
+ EE_CHAR_FONTINFO,
+ EE_CHAR_ITALIC,
+ EE_CHAR_WEIGHT,
+ EE_CHAR_SHADOW,
+ EE_CHAR_OUTLINE,
+ EE_CHAR_STRIKEOUT,
+ EE_CHAR_UNDERLINE,
+ EE_CHAR_FONTHEIGHT,
+ EE_CHAR_COLOR,
+ EE_CHAR_WLM,
+ EE_CHAR_ESCAPEMENT,
+ EE_CHAR_PAIRKERNING,
+ EE_CHAR_KERNING,
+ EE_PARA_JUST,
+ EE_PARA_SBL,
+ EE_PARA_TABS,
+ EE_PARA_LRSPACE,
+ EE_PARA_ULSPACE };
+
+ if( nColl < nColls && pCollA[nColl].pFmt && pCollA[nColl].bColl ){
+ const SfxPoolItem* pItem;
+ for( USHORT i = 0; i < sizeof(aSrcTab)/sizeof(aSrcTab[0]); i++ ){
+ if( SFX_ITEM_SET == pCollA[nColl].pFmt->GetItemState(
+ aSrcTab[i], TRUE, &pItem ) ){
+ SfxPoolItem* pCopy = pItem->Clone();
+ pCopy->SetWhich( aDstTab[i] );
+ rS.Put( *pCopy );
+ delete pCopy;
+ }
+ }
+ }
+
+}
+/*
+// InsertTxbxParaAttrs() setzt zwischen StartCp und EndCp die Style-
+// uns Absatz-Attribute. Dabei werden Style-Attribute als harte Attribute
+// gesetzt, da die EditEngine-Styles im SW UI-maessig nicht benutzt
+// werden und der Import daher das auch nicht soll.
+// Es werden also harte Para-Attrs und *alle* Style-Attrs gesetzt.
+void SwWW8ImplReader::InsertTxbxParaAttrs( long nStartCp, long nEndCp )
+{
+ nStartCp += nDrawCpO;
+ nEndCp += nDrawCpO;
+ WW8PLCFx_Cp_FKP* pPap = pPlcxMan->GetPapPLCF();
+ pPap->SeekPos( nStartCp );
+
+ WW8_CP nStart = pPap->Where();
+ while( nStart <= nEndCp )
+ {
+ SfxItemSet aS( pDrawEditEngine->GetEmptyItemSet() );
+ WW8PLCFxDesc aDesc;
+ pPap->GetSprms( &aDesc );
+ (*pPap)++;
+ WW8_CP nNextEnd = pPap->Where();
+ WW8_CP nEnd = ( nNextEnd < nEndCp ) ? nNextEnd : nEndCp;
+
+ InsertTxbxStyAttrs( aS, pPap->GetIstd() ); // Style-Kram rein
+
+ if( aDesc.nSprmsLen && aDesc.pMemPos ) // Attribut(e) vorhanden
+ GetTxbxParaAttrs( aS, aDesc );
+
+ if( aS.Count() )
+ pDrawEditEngine->QuickSetAttribs( aS,
+ GetESelection( nStart - nStartCp, nEnd - nStartCp ) );
+ nStart = nNextEnd;
+ }
+}
+*/
+// InsertTxbxAttrs() setzt zwischen StartCp und EndCp die Attribute.
+// Dabei werden Style-Attribute als harte Attribute, Absatz- und Zeichen-
+// attribute gesetzt.
+void SwWW8ImplReader::InsertTxbxAttrs( long nStartCp,
+ long nEndCp,
+ BOOL bONLYnPicLocFc )
+{
+ WW8PLCFManResult aRes;
+ SfxItemSet aS( pDrawEditEngine->GetEmptyItemSet() );
+
+ nStartCp += nDrawCpO;
+ nEndCp += nDrawCpO;
+ WW8ReaderSave aSave(this,nStartCp);
+
+
+ WW8_CP nStart = pPlcxMan->Where();
+ WW8_CP nNext;
+ WW8_CP nEnd;
+ USHORT nIstd = pPlcxMan->GetPapPLCF()->GetIstd();
+ USHORT nNextIstd = USHRT_MAX;
+
+ // store the *first* Style's SPRMs
+ InsertTxbxStyAttrs( aS, nIstd );
+
+ while( nStart <= nEndCp )
+ {
+ // get position of next SPRM
+ if( pPlcxMan->Get( &aRes )
+ && aRes.pMemPos && aRes.nSprmId )
+ {
+ if( bONLYnPicLocFc )
+ {
+ if( ( 68 == aRes.nSprmId)
+ || (0x6A03 == aRes.nSprmId) )
+ {
+ Read_PicLoc( aRes.nSprmId,
+ aRes.pMemPos
+ + 1
+ + (8 > pWwFib->nVersion ? 0 : 1)
+ + WW8SprmDataOfs( aRes.nSprmId ),
+ 4 );
+ // Ok, that's it. Now let's get out of here!
+ break;
+ }
+ }
+ else if( aRes.nSprmId && ( ( 256 > aRes.nSprmId )
+ || ( 0x0800 <= aRes.nSprmId ) ) )
+ {
+ GetTxbxPapAndCharAttrs( aS, aRes );
+ }
+ }
+
+ (*pPlcxMan)++;
+ nNext = pPlcxMan->Where();
+
+ if( (nNext != nStart) && !bONLYnPicLocFc )
+ {
+ nNextIstd = pPlcxMan->GetPapPLCF()->GetIstd();
+ if( nNextIstd != nIstd )
+ {
+ nIstd = nNextIstd;
+ // store the *next* Style's SPRMs
+ InsertTxbxStyAttrs( aS, nIstd );
+ }
+
+ nEnd = ( nNext < nEndCp ) ? nNext : nEndCp;
+ // put the attrs into the doc
+ if( aS.Count() )
+ pDrawEditEngine->QuickSetAttribs( aS,
+ GetESelection( nStart - nStartCp, nEnd - nStartCp ) );
+ }
+ nStart = nNext;
+ }
+
+ aSave.Restore(this);
+}
+
+BOOL SwWW8ImplReader::GetTxbxTextSttEndCp( long& rStartCp, long& rEndCp,
+ USHORT nTxBxS, USHORT nSequence )
+{
+ // rasch den TextBox-PLCF greifen
+ WW8PLCFspecial* pT = pPlcxMan->GetTxbx();
+ if( !pT )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (1) ?" );
+ return FALSE;
+ }
+
+ // ggfs. zuerst die richtige TextBox-Story finden
+ BOOL bCheckTextBoxStory = ( nTxBxS && pT->GetIMax() >= nTxBxS );
+ if( bCheckTextBoxStory )
+ pT->SetIdx( nTxBxS-1 );
+
+ // dann Start und Ende ermitteln
+ void* pT0;
+ if( !pT->Get( rStartCp, pT0 ) )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (2) ?" );
+ return FALSE;
+ }
+
+ if( bCheckTextBoxStory )
+ {
+ BOOL bReusable = (0 != SVBT16ToShort( ((WW8_TXBXS*)pT0)->fReusable ));
+ while( bReusable )
+ {
+ (*pT)++;
+ if( !pT->Get( rStartCp, pT0 ) )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (2-a) ?" );
+ return FALSE;
+ }
+ bReusable = (0 != SVBT16ToShort( ((WW8_TXBXS*)pT0)->fReusable ));
+ }
+ }
+ (*pT)++;
+ if( !pT->Get( rEndCp, pT0 ) )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (3) ?" );
+ return FALSE;
+ }
+
+ // jetzt ggfs. die passende Page in der Break-Table finden
+ if( bCheckTextBoxStory )
+ {
+ // Sonderfall: gesamte(!) Kette soll ermittelt werden,
+ // dann sind wir hier schon fertig!
+ if( USHRT_MAX > nSequence )
+ {
+ long nMinStartCp = rStartCp;
+ long nMaxEndCp = rEndCp;
+ // rasch den TextBox-Break-Deskriptor-PLCF greifen
+ pT = pPlcxMan->GetTxbxBkd();
+ if (!pT) //It can occur on occasion, Caolan
+ return FALSE;
+
+ // den ersten Eintrag fuer diese TextBox-Story finden
+ if( !pT->SeekPos( rStartCp ) )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (4) ?" );
+ return FALSE;
+ }
+ // ggfs. entsprechende Anzahl Eintraege weitergehen
+ for(USHORT iSequence = 0; iSequence < nSequence; iSequence++) (*pT)++;
+ // dann die tatsaechlichen Start und Ende ermitteln
+ if( (!pT->Get( rStartCp, pT0 ))
+ || ( nMinStartCp > rStartCp ) )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (5) ?" );
+ return FALSE;
+ }
+ if( rStartCp >= nMaxEndCp )
+ rEndCp = rStartCp; // kein Error: leerer String!
+ else
+ {
+ (*pT)++;
+ if( (!pT->Get( rEndCp, pT0 ))
+ || ( nMaxEndCp < rEndCp-1 ) )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (6) ?" );
+ return FALSE;
+ }
+ rEndCp -= 1;
+ }
+ }
+ else
+ rEndCp -= 1;
+ }
+ else
+ rEndCp -= 2;
+ return TRUE;
+}
+
+// TxbxText() holt aus WW-File den Text und gibt diesen und den Anfangs- und
+// den um -2 (bzw. -1 bei Ver8) korrigierten End-Cp zurueck
+
+
+BOOL SwWW8ImplReader::GetTxbxText( String& rString,
+ long nStartCp, long nEndCp )
+{
+ nDrawTxbx++;
+ BOOL bOk = FALSE;
+ if( nStartCp > nEndCp )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (7) ?" );
+ }
+ else
+ if( nStartCp == nEndCp )
+ rString.Erase(); // leerer String: durchaus denkbar!
+ else
+ {
+ // den Text einlesen: kann sich ueber mehrere Pieces erstrecken!!!
+ USHORT nLen = pSBase->WW8ReadString( *pStrm, rString,
+ nStartCp + nDrawCpO,
+ nEndCp - nStartCp,
+ eTextCharSet );
+ if( !nLen )
+ {
+ ASSERT( !this, "+Wo ist der Grafik-Text (8) ?" );
+ }
+ else
+ {
+ bOk = TRUE;
+ if( 0x0d == rString.GetChar(nLen - 1) )
+ rString.Erase(nLen - 1);
+ }
+ }
+ return bOk;
+}
+
+
+// InsertTxbxText() fuegt fuer TextBoxen und CaptionBoxen den Text
+// und die Attribute ein
+SwFrmFmt* SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
+ Size* pObjSiz,
+ USHORT nTxBxS,
+ USHORT nSequence,
+ long nPosCp,
+ SwFrmFmt* pOldFlyFmt,
+ BOOL bMakeSdrGrafObj,
+ BOOL& rbEraseTextObj,
+ BOOL* pbTestTxbxContainsText,
+ long* pnStartCp,
+ long* pnEndCp,
+ SvxMSDffImportRec* pRecord)
+{
+ SwFrmFmt* pFlyFmt = 0;
+ ULONG nOld = pStrm->Tell();
+
+ rbEraseTextObj = FALSE;
+
+ String aString;
+ long nStartCp, nEndCp, nNewStartCp;
+ BOOL bTextWasRead = GetTxbxTextSttEndCp( nStartCp, nEndCp,
+ nTxBxS, nSequence ) &&
+ GetTxbxText( aString, nStartCp, nEndCp );
+ nNewStartCp = nStartCp;
+
+ if( !pbTestTxbxContainsText )
+ {
+ if( bTextWasRead )
+ while( STRING_NOTFOUND != aString.SearchAndReplace( 0xb, ' ' ))
+ ; // HardNewline kann EE noch nicht in der EE-Core
+
+ if( !pDrawEditEngine )
+#if SUPD>601
+ pDrawEditEngine = new EditEngine(0);
+#else
+ pDrawEditEngine = new EditEngine;
+#endif
+ if( pObjSiz )
+ pDrawEditEngine->SetPaperSize( *pObjSiz );
+ }
+
+ if( bTextWasRead )
+ {
+ for(USHORT i=0; i < aString.Len(); i++)
+ {
+ if( 0x13 == aString.GetChar( i ) )
+ {
+ do
+ {
+ aString.Erase( i, 1 );
+ nNewStartCp++;
+ }
+ while( aString.Len()
+ && ( i < aString.Len())
+ && (0x14 != aString.GetChar( i ) )
+ && (0x15 != aString.GetChar( i ) ) );
+ if( aString.Len() )
+ {
+ if( 0x14 == aString.GetChar( i ) )
+ {
+ aString.Erase( i, 1 );
+ nNewStartCp++;
+ do
+ {
+ i++;
+ }
+ while( aString.Len()
+ && ( i < aString.Len())
+ && (0x15 != aString.GetChar( i ) ) );
+ if( i < aString.Len() )
+ aString.Erase( i, 1 );
+ }
+ else if( 0x15 == aString.GetChar( i ) )
+ {
+ aString.Erase( i, 1 );
+ }
+ }
+ }
+ }
+ if (1 == aString.Len())
+ {
+ BOOL bDone = TRUE;
+ switch( aString.GetChar(0) )
+ {
+ case 0x1:if( !pbTestTxbxContainsText )
+ {
+ WW8ReaderSave aSave(this,nNewStartCp + nDrawCpO -1);
+ BOOL bOldEmbeddObj = bEmbeddObj;
+ //bEmbedd Ordinarily would have been set by field
+ //parse, but this is impossible here so...
+ bEmbeddObj = TRUE;
+
+ // 1st look for OLE- or Graph-Indicator Sprms
+ WW8PLCFx_Cp_FKP* pChp = pPlcxMan->GetChpPLCF();
+ WW8PLCFxDesc aDesc;
+ pChp->GetSprms( &aDesc );
+ WW8SprmIter aSprmIter( aDesc.pMemPos, aDesc.nSprmsLen,
+ GetFib().nVersion );
+
+ //BOOL bRead_Obj = FALSE;
+ //BOOL bRead_PicLoc = FALSE;
+ BYTE* pParams = aSprmIter.GetAktParams();
+ for( int nLoop = 0; nLoop < 2; ++nLoop )
+ {
+ while( aSprmIter.GetSprms()
+ && (0 != (pParams = aSprmIter.GetAktParams())) )
+ {
+ USHORT nAktId = aSprmIter.GetAktId();
+ switch( nAktId )
+ {
+ case 75:
+ case 118:
+ case 0x080A:
+ case 0x0856:
+ //if( !bRead_Obj )
+ //{
+ Read_Obj(nAktId, pParams, 1);
+ // bRead_Obj = TRUE;
+ //}
+ break;
+ case 68: // Read_Pic()
+ case 0x6A03:
+ case 0x680E:
+ //if( !bRead_PicLoc )
+ //{
+ Read_PicLoc(nAktId, pParams, 1);
+ // bRead_PicLoc = TRUE;
+ //}
+ break;
+ }
+ aSprmIter++;
+ }
+
+ //if( bRead_Obj || bRead_PicLoc ) break;
+ if( !nLoop )
+ {
+ pChp->GetPCDSprms( aDesc );
+ aSprmIter.SetSprms( aDesc.pMemPos,
+ aDesc.nSprmsLen );
+ }
+ //if( bRead_Obj || bRead_PicLoc ) break;
+ }
+ aSave.Restore(this);
+ bEmbeddObj=bOldEmbeddObj;
+
+ // then import either an OLE of a Graphic
+ if( bObj )
+ {
+ pFlyFmt = ImportOle();
+ bObj=FALSE;
+ }
+ else
+ {
+ InsertTxbxAttrs(nNewStartCp,
+ nNewStartCp+1,
+ TRUE);
+ //InsertTxbxCharAttrs(nNewStartCp, nNewStartCp+1, TRUE);
+ pFlyFmt = ImportGraf(
+ bMakeSdrGrafObj ? pTextObj : 0,
+ pOldFlyFmt,
+ pTextObj
+ ? (nDrawHell == pTextObj->GetLayer())
+ : FALSE );
+ }
+ }
+ break;
+ case 0x8:if( !pbTestTxbxContainsText )
+ {
+ if( !bObj )
+ pFlyFmt = Read_GrafLayer( nPosCp );
+ }
+ break;
+ default:bDone = FALSE;
+ break;
+ }
+ if( bDone )
+ {
+ if( pFlyFmt )
+ {
+ if( pRecord )
+ {
+ SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+
+ Rectangle aInnerDist( pRecord->nDxTextLeft,
+ pRecord->nDyTextTop,
+ pRecord->nDxTextRight,
+ pRecord->nDyTextBottom );
+ MatchSdrItemsIntoFlySet( pTextObj,
+ aFlySet,
+ pRecord->eLineStyle,
+ aInnerDist,
+ !pRecord->bLastBoxInChain );
+
+ pFlyFmt->SetAttr( aFlySet );
+
+
+ MatchWrapDistancesIntoFlyFmt( pRecord, pFlyFmt );
+ }
+
+ }
+ aString.Erase();
+ rbEraseTextObj = (0 != pFlyFmt);
+ }
+ }
+
+ }
+
+ if( pbTestTxbxContainsText )
+ {
+ if( pnStartCp ) *pnStartCp = nStartCp;
+ if( pnEndCp ) *pnEndCp = nEndCp;
+ *pbTestTxbxContainsText = bTextWasRead
+ && ! rbEraseTextObj;
+ }
+ else if( !rbEraseTextObj )
+ {
+ if( bTextWasRead )
+ {
+ pDrawEditEngine->SetText( aString );
+ InsertTxbxAttrs( nStartCp, nEndCp, FALSE );
+ // pDrawEditEngine->QuickFormatDoc(); // nach MT nicht noetig
+ }
+
+#if SUPD>600
+#if SUPD>601
+ OutlinerParaObject* pOp = new OutlinerParaObject( *pDrawEditEngine->CreateTextObject() );
+#else
+ OutlinerParaObject* pOp = new OutlinerParaObject( *pDrawEditEngine );
+#endif
+ pTextObj->NbcSetOutlinerParaObject( pOp );
+#endif
+
+ // Fuer die naechste Textbox noch die alten Absatz-Attribute
+ // und Styles entfernen, sonst startet die naechste Box
+ // mit falschen Attributen.
+ // Vorgehen: Text loeschen = auf 1 Absatz reduzieren
+ // und an diesem Absatz die Absatzattribute und Styles loeschen
+ // (Empfehlung JOE)
+ pDrawEditEngine->SetText( aEmptyStr );
+ pDrawEditEngine->SetParaAttribs( 0, pDrawEditEngine->GetEmptyItemSet() );
+#if SUPD>600
+#if SUPD>601
+ pDrawEditEngine->SetStyleSheet( 0, 0 );
+#else
+ pDrawEditEngine->SetStyleSheet( 0, aEmptyStr, SFX_STYLE_FAMILY_PARA );
+#endif
+#endif
+ }
+
+ pStrm->Seek( nOld );
+ return pFlyFmt;
+}
+
+BOOL SwWW8ImplReader::TxbxChainContainsRealText( USHORT nTxBxS,
+ long& rStartCp,
+ long& rEndCp )
+{
+ BOOL bErase, bContainsText;
+ InsertTxbxText( 0,0,nTxBxS,USHRT_MAX,0,0,0, bErase,
+ &bContainsText,
+ &rStartCp,
+ &rEndCp );
+ return bContainsText;
+}
+
+
+// TextBoxes only for Ver67 !!
+void SwWW8ImplReader::ReadTxtBox( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ BOOL bDummy;
+ WW8_DP_TXTBOX aTxtB;
+
+ if( !ReadGrafStart( (void*)&aTxtB, sizeof( aTxtB ), pHd, pDo ) )
+ return;
+
+ Point aP0( (INT16)SVBT16ToShort( pHd->xa ) + nDrawXOfs2,
+ (INT16)SVBT16ToShort( pHd->ya ) + nDrawYOfs2 );
+ Point aP1( aP0 );
+ aP1.X() += (INT16)SVBT16ToShort( pHd->dxa );
+ aP1.Y() += (INT16)SVBT16ToShort( pHd->dya );
+
+ SdrTextObj* pObj = new SdrRectObj( OBJ_TEXT, Rectangle( aP0, aP1 ) );
+ Size aSize( (INT16)SVBT16ToShort( pHd->dxa ) ,
+ (INT16)SVBT16ToShort( pHd->dya ) );
+
+ InsertTxbxText(pObj, &aSize, 0, 0, 0, 0, FALSE, bDummy );
+
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ SetStdAttr( aSet, aTxtB.aLnt, aTxtB.aShd );
+ SetFill( aSet, aTxtB.aFill );
+
+ aSet.Put(SdrTextFitToSizeTypeItem( SDRTEXTFIT_NONE ));
+ aSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
+ aSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
+ aSet.Put( SdrTextLeftDistItem( MIN_BORDER_DIST*2 ) );
+ aSet.Put( SdrTextRightDistItem( MIN_BORDER_DIST*2 ) );
+ aSet.Put( SdrTextUpperDistItem( MIN_BORDER_DIST ) );
+ aSet.Put( SdrTextLowerDistItem( MIN_BORDER_DIST ) );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+
+void SwWW8ImplReader::ReadCaptionBox( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ static SdrCaptionType aCaptA[] = { SDRCAPT_TYPE1, SDRCAPT_TYPE2,
+ SDRCAPT_TYPE3, SDRCAPT_TYPE4 };
+
+ WW8_DP_CALLOUT_TXTBOX aCallB;
+
+ if( !ReadGrafStart( (void*)&aCallB, sizeof( aCallB ), pHd, pDo ) )
+ return;
+
+ UINT16 nCount = SVBT16ToShort( aCallB.dpPolyLine.aBits1 ) >> 1 & 0x7fff;
+ SVBT16 *pP = new SVBT16[nCount * 2];
+ pStrm->Read( pP, nCount * 4 ); // Punkte einlesen
+ BYTE nTyp = (BYTE)nCount - 1;
+ if( nTyp == 1 && SVBT16ToShort( pP[0] ) == SVBT16ToShort( pP[2] ) )
+ nTyp = 0;
+
+ Point aP0( (INT16)SVBT16ToShort( pHd->xa ) +
+ (INT16)SVBT16ToShort( aCallB.dpheadTxbx.xa ) + nDrawXOfs2,
+ (INT16)SVBT16ToShort( pHd->ya )
+ + (INT16)SVBT16ToShort( aCallB.dpheadTxbx.ya ) + nDrawYOfs2 );
+ Point aP1( aP0 );
+ aP1.X() += (INT16)SVBT16ToShort( aCallB.dpheadTxbx.dxa );
+ aP1.Y() += (INT16)SVBT16ToShort( aCallB.dpheadTxbx.dya );
+ Point aP2( (INT16)SVBT16ToShort( pHd->xa )
+ + (INT16)SVBT16ToShort( aCallB.dpheadPolyLine.xa )
+ + nDrawXOfs2 + (INT16)SVBT16ToShort( pP[0] ),
+ (INT16)SVBT16ToShort( pHd->ya )
+ + (INT16)SVBT16ToShort( aCallB.dpheadPolyLine.ya )
+ + nDrawYOfs2 + (INT16)SVBT16ToShort( pP[1] ) );
+ delete[]( pP );
+
+ SdrCaptionObj* pObj = new SdrCaptionObj( Rectangle( aP0, aP1 ), aP2 );
+ Size aSize( (INT16)SVBT16ToShort( aCallB.dpheadTxbx.dxa ),
+ (INT16)SVBT16ToShort( aCallB.dpheadTxbx.dya ) );
+ BOOL bEraseThisObject;
+
+ InsertTxbxText(pObj, &aSize, 0, 0, 0, 0, FALSE, bEraseThisObject );
+
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SfxAllItemSet aSet( pDrawModel->GetItemPool() );
+
+ if( SVBT16ToShort( aCallB.dptxbx.aLnt.lnps ) != 5 ) // Umrandung sichtbar ?
+ SetStdAttr( aSet, aCallB.dptxbx.aLnt, aCallB.dptxbx.aShd );
+ else // nein -> Nimm Linie
+ SetStdAttr( aSet, aCallB.dpPolyLine.aLnt, aCallB.dptxbx.aShd );
+ SetFill( aSet, aCallB.dptxbx.aFill );
+ aSet.Put( SdrCaptionTypeItem( aCaptA[nTyp] ) );
+
+ pObj->SetAttributes( aSet, FALSE );
+}
+
+
+void SwWW8ImplReader::ReadGroup( WW8_DPHEAD* pHd, WW8_DO* pDo )
+{
+ INT16 nGrouped;
+
+ if( !ReadGrafStart( (void*)&nGrouped, sizeof( nGrouped ), pHd, pDo ) )
+ return;
+
+#ifdef __BIGENDIAN
+ nGrouped = (INT16)SWAPSHORT( nGrouped );
+#endif
+
+ nDrawXOfs += (INT16)SVBT16ToShort( pHd->xa );
+ nDrawYOfs += (INT16)SVBT16ToShort( pHd->ya );
+
+ SdrObject* pObj = new SdrObjGroup;
+
+ InsertObj( pObj, SVBT16ToShort( pDo->dhgt ) );
+
+ SdrObjList* pOldGroup = pDrawGroup;
+ pDrawGroup = pObj->GetSubList();
+
+ short nLeft = (INT16)SVBT16ToShort( pHd->cb ) - sizeof( WW8_DPHEAD );
+ for( int i = 0; i < nGrouped; i++ )
+ ReadGrafPrimitive( nLeft, pDo );
+
+ pDrawGroup = pOldGroup;
+ nDrawXOfs -= (INT16)SVBT16ToShort( pHd->xa );
+ nDrawYOfs -= (INT16)SVBT16ToShort( pHd->ya );
+}
+
+void SwWW8ImplReader::ReadGrafPrimitive( short& rLeft, WW8_DO* pDo )
+{
+ WW8_DPHEAD aHd; // Lese Draw-Primitive-Header
+ pStrm->Read( &aHd, sizeof( WW8_DPHEAD ) );
+
+ if( rLeft >= (INT16)SVBT16ToShort( aHd.cb ) ) // Vorsichtsmassmahme
+ {
+ switch( (INT16)SVBT16ToShort( aHd.dpk ) & 0xff )
+ {
+ case 0: ReadGroup( &aHd, pDo );
+ break;
+ case 1: ReadLine( &aHd, pDo );
+ break;
+ case 2: ReadTxtBox( &aHd, pDo );
+ break;
+ case 3: ReadRect( &aHd, pDo );
+ break;
+ case 4: ReadElipse( &aHd, pDo );
+ break;
+ case 5: ReadArc( &aHd, pDo );
+ break;
+ case 6: ReadPolyLine( &aHd, pDo );
+ break;
+ case 7: ReadCaptionBox( &aHd, pDo );
+ break;
+ default: // unbekannt
+ pStrm->SeekRel( (INT16)SVBT16ToShort( aHd.cb )
+ - sizeof( WW8_DPHEAD ) );
+ break;
+ }
+ }
+ else
+ {
+ ASSERT( !this, "+Grafik-Overlap" );
+ }
+ rLeft -= (INT16)SVBT16ToShort( aHd.cb );
+}
+
+void SwWW8ImplReader::ReadGrafLayer1( WW8PLCFspecial* pPF, long nGrafAnchorCp )
+{
+ pPF->SeekPos( nGrafAnchorCp );
+ long nStartFc;
+ void* pF0;
+ if( !pPF->Get( nStartFc, pF0 ) )
+ {
+ ASSERT( !this, "+Wo ist die Grafik (2) ?" );
+ return;
+ }
+ WW8_FDOA* pF = (WW8_FDOA*)pF0;
+ if( !SVBT32ToLong( pF->fc ) )
+ {
+ ASSERT( !this, "+Wo ist die Grafik (3) ?" );
+ return;
+ }
+ WW8_DO aDo;
+ pStrm->Seek( SVBT32ToLong( pF->fc ) ); // Lese Draw-Header
+ pStrm->Read( &aDo, sizeof( WW8_DO ) );
+
+ short nLeft = SVBT16ToShort( aDo.cb ) - sizeof( WW8_DO );
+ while( nLeft > sizeof( WW8_DPHEAD ) )
+ {
+ ReadGrafPrimitive( nLeft, &aDo );
+ }
+}
+
+BOOL SwWW8ImplReader::MatchSdrBoxIntoFlyBoxItem(const Color& rLineColor,
+ MSO_LineStyle eLineStyle,
+ USHORT nLineWidth,
+ SvxBoxItem& rBox )
+{ // Deklarationen gemaess BOXITEM.HXX
+ WW8_DECL_LINETAB_ARRAY
+
+ BOOL bRet = FALSE;
+ USHORT nIdx = USHRT_MAX;
+
+ if( nLineWidth )
+ {
+ /*
+ Beachte: im Gegensatz zu den Winword-ueblichen Tabellen- und
+ Rahmen-Randbreiten-Angaben, bei denen jeweils aus der Staerke
+ *einer* Linie die Gesamt-Randbreite zu errechnen ist,
+ liegen die aus dem ESCHER stammenden Daten bereits als
+ Gesamt-Breite [twips] vor!
+
+ Der Winword default ist 15 tw. Wir nehmen hierfuer unsere 20 tw Linie.
+ ( 0.75 pt uns 1.0 pt sehen sich auf dem Ausdruck naemlich
+ aehnlicher als etwas 0.75 pt und unsere 0.05 pt Haarlinie. )
+ Die Haarlinie setzen wir nur bei Winword-Staerken bis zu
+ maximal 0.5 pt ein.
+ */
+ switch( eLineStyle )
+ {
+ // zuerst die Einzel-Linien
+ case mso_lineSimple: if( nLineWidth < 11) nIdx = 0;// 1 Twip bei uns
+ else if( nLineWidth < 46) nIdx = 1;// 20 Twips
+ else if( nLineWidth < 66) nIdx = 2;// 50
+ else if( nLineWidth < 91) nIdx = 3;// 80
+ else if( nLineWidth <126) nIdx = 4;// 100
+ // Pfusch: fuer die ganz dicken Linien muessen
+ // wir doppelte Linien malen, weil unsere
+ // Einfach-Linie nicht dicker als 5 Punkt wird
+ else if( nLineWidth <166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+2;// 150
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+5;// 180
+ break;
+ // dann die Doppel-Linien, fuer die wir feine Entsprechungen haben :-)))
+ case mso_lineDouble: if( nLineWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nLineWidth < 106) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 2;// 150
+ break;
+ case mso_lineThickThin: if( nLineWidth < 87) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 8;// 71 Twips bei uns
+ else if( nLineWidth < 117) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 9;// 101
+ else if( nLineWidth < 166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+10;// 131
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 5;// 180
+ break;
+ case mso_lineThinThick: if( nLineWidth < 137) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 4;// 90 Twips bei uns
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 6;// 180
+ break;
+ // zu guter Letzt die Dreifach-Linien, an deren Stelle wir eine Doppel-Linie setzen
+ case mso_lineTriple: if( nLineWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nLineWidth < 106) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60
+ else if( nLineWidth < 166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 2;// 150
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 5;// 180
+ break;
+ // no line style is set
+ case (MSO_LineStyle)USHRT_MAX:
+ break;
+ // erroneously not implemented line style is set
+ default: ASSERT( !this, "eLineStyle is not (yet) implemented!" );
+ }
+ }
+
+ if( USHRT_MAX != nIdx )
+ {
+ SvxBorderLine aLine;
+ aLine.SetColor( rLineColor );
+
+ const WW8_BordersSO& rBorders = nLineTabVer8[ nIdx ];
+ aLine.SetOutWidth( rBorders.Out );
+ aLine.SetInWidth ( rBorders.In );
+ aLine.SetDistance( rBorders.Dist );
+
+ for(USHORT nLine = 0; nLine < 4; ++nLine)
+ rBox.SetLine(new SvxBorderLine( aLine ), nLine);
+
+ bRet = TRUE;
+ }
+ return bRet;
+}
+
+
+#define WW8ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject* pSdrObj,
+ SfxItemSet& rFlySet,
+ MSO_LineStyle eLineStyle,
+ Rectangle& rInnerDist,
+ BOOL bFixSize )
+{ /*
+ am Rahmen zu setzende Frame-Attribute
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ SwFmtFrmSize falls noch nicht gesetzt, hier setzen
+ SvxLRSpaceItem hier setzen
+ SvxULSpaceItem hier setzen
+ SvxOpaqueItem (Derzeit bei Rahmen nicht moeglich! khz 10.2.1999)
+ SwFmtSurround bereits gesetzt
+ SwFmtVertOrient bereits gesetzt
+ SwFmtHoriOrient bereits gesetzt
+ SwFmtAnchor bereits gesetzt
+ SvxBoxItem hier setzen
+ SvxBrushItem hier setzen
+ SvxShadowItem hier setzen
+ */
+
+ // 1. GrafikObjekt des Docs?
+ if( !pDrawModel )
+ GrafikCtor();
+
+
+ // im Sdr-Objekt eingestellten Attribute greifen
+ SfxItemSet aOldSet(pDrawModel->GetItemPool());
+ pSdrObj->TakeAttributes( aOldSet, FALSE, FALSE );
+
+ BOOL bIsAAttrObj = pSdrObj->ISA(SdrAttrObj);
+ const XLineAttrSetItem* pLineAttrSetItem
+ = bIsAAttrObj ? ((SdrAttrObj*)pSdrObj)->GetLineAttrSetItem() : 0;
+ const XFillAttrSetItem* pFillAttrSetItem
+ = bIsAAttrObj ? ((SdrAttrObj*)pSdrObj)->GetFillAttrSetItem() : 0;
+
+
+
+ // einige Items koennen direkt so uebernommen werden
+ const USHORT nDirectMatch = 2;
+ static RES_FRMATR __READONLY_DATA aDirectMatch[ nDirectMatch ] =
+ {
+ RES_LR_SPACE, // Aussenabstand links/rechts: SvxLRSpaceItem
+ RES_UL_SPACE // Aussenabstand Oben/unten: SvxULSpaceItem
+ };
+ const SfxPoolItem* pPoolItem;
+ for(USHORT nItem = 0; nItem < nDirectMatch; ++nItem)
+ if( SFX_ITEM_SET == aOldSet.GetItemState( aDirectMatch[ nItem ],
+ FALSE,
+ &pPoolItem) )
+ {
+ rFlySet.Put( *pPoolItem );
+ }
+
+
+ // jetzt die Umrandung berechnen und die Box bauen:
+ // Das Mass wird fuer die Rahmen-GROESSE benoetigt!
+ SvxBoxItem aBox;
+ // dashed oder solid wird zu solid
+ USHORT nLineWidth = 0;
+
+ // check if LineStyle is *really* set!
+ const SfxPoolItem* pItem;
+
+ if( pLineAttrSetItem )
+ {
+ SfxItemState eState = pLineAttrSetItem->GetItemSet().GetItemState(
+ XATTR_LINESTYLE,
+ TRUE, &pItem );
+ if( eState == SFX_ITEM_SET )
+ {
+ // Now, that we know there is a line style we will make use the
+ // parameter given to us when calling the method... :-)
+ /*
+ const XLineStyle eLineStyle =
+ ((const XLineStyleItem*)pItem)->GetValue();
+ if( XLINE_NONE != eLineStyle )
+
+ {
+ */
+ const Color aLineColor
+ = WW8ITEMVALUE( pLineAttrSetItem->GetItemSet(),
+ XATTR_LINECOLOR,
+ XLineColorItem );
+
+ nLineWidth
+ = (USHORT)(WW8ITEMVALUE( pLineAttrSetItem->GetItemSet(),
+ XATTR_LINEWIDTH, XLineWidthItem ));
+
+ if( !nLineWidth )
+ nLineWidth = 15; // WW-default: 0.75 pt
+
+ MatchSdrBoxIntoFlyBoxItem( aLineColor, eLineStyle, nLineWidth, aBox);
+ //}
+ }
+ }
+
+ // set distances from box's border to text contained within the box
+ if( 0 < rInnerDist.Left() )
+ aBox.SetDistance( (USHORT)rInnerDist.Left(), BOX_LINE_LEFT );
+ if( 0 < rInnerDist.Top() )
+ aBox.SetDistance( (USHORT)rInnerDist.Top(), BOX_LINE_TOP );
+ if( 0 < rInnerDist.Right() )
+ aBox.SetDistance( (USHORT)rInnerDist.Right(), BOX_LINE_RIGHT );
+ if( 0 < rInnerDist.Bottom() )
+ aBox.SetDistance( (USHORT)rInnerDist.Bottom(), BOX_LINE_BOTTOM );
+
+ // Groesse: SwFmtFrmSize
+ if( SFX_ITEM_SET != rFlySet.GetItemState(RES_FRM_SIZE, FALSE) )
+ {
+ const Rectangle& rSnapRect = pSdrObj->GetSnapRect();
+ // ggfs. Breite und Position des Rahmens anpassen:
+ // Der beschreibbare Innenraum soll trotz breitem Rand
+ // gleich gross bleiben.
+ long nWidth = rSnapRect.GetWidth() + 2*nLineWidth;
+ long nHeight = rSnapRect.GetHeight() + 2*nLineWidth;
+ rFlySet.Put( SwFmtFrmSize(bFixSize ? ATT_FIX_SIZE : ATT_MIN_SIZE,
+ rSnapRect.GetWidth() + 2*nLineWidth,
+ rSnapRect.GetHeight() + 2*nLineWidth) );
+ }
+
+ /*
+ Traurig: das SvxOpaqueItem macht bei Rahmen etwas ganz anderes,
+ als in /svx/inc/opaqitem.hxx angegeben:
+
+ Statt den Rahmen (un)durchsichtig zu machen, bewirkt es, dass er
+ einfach bloss in einen anderen Layer (Hell/Heaven) gestellt wird.
+ Fuer unsere Zwecke ist es also nicht zu gebrauchen.
+
+ Da auch das Transparent-Flag am SvxBrushItem wirkungslos ist,
+ koennen wir das WinWord-Attribut "Halbtransparent" leider nicht
+ umsetzen.
+
+ :-((
+ */
+ // Durchsichtigkeit: SvxOpaqueItem
+
+ // INT16 nFillTransparence
+ // = WW8ITEMVALUE(aOldSet, XATTR_FILLTRANSPARENCE, XFillTransparenceItem);
+ // if( 0x032 <= nFillTransparence )
+ // rFlySet.Put( SvxOpaqueItem(RES_OPAQUE, FALSE) );
+ //
+
+ // jetzt die Umrandung setzen
+ rFlySet.Put( aBox );
+
+ // Schattenwurf der Box: SvxShadowItem
+ if( WW8ITEMVALUE(aOldSet, SDRATTR_SHADOW, SdrShadowItem) )
+ {
+ SvxShadowItem aShadow;
+
+ const Color aShdColor = WW8ITEMVALUE(aOldSet, SDRATTR_SHADOWCOLOR,
+ SdrShadowColorItem);
+
+ const INT32 nShdDistX = WW8ITEMVALUE(aOldSet, SDRATTR_SHADOWXDIST,
+ SdrShadowXDistItem);
+ const INT32 nShdDistY = WW8ITEMVALUE(aOldSet, SDRATTR_SHADOWYDIST,
+ SdrShadowYDistItem);
+
+ const USHORT nShdTrans= WW8ITEMVALUE(aOldSet, SDRATTR_SHADOWTRANSPARENCE,
+ SdrShadowTransparenceItem);
+ // diese gibt es im Writer nicht :-(
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ //
+ // SfxVoidItem( SDRATTR_SHADOW3D )
+ // SfxVoidItem( SDRATTR_SHADOWPERSP )
+
+ aShadow.SetColor( Color( aShdColor ) );
+
+ aShadow.SetWidth( (Abs( nShdDistX ) + Abs( nShdDistY )) / 2 );
+
+ SvxShadowLocation eShdPosi;
+ if( 0 <= nShdDistX )
+ {
+ if( 0 <= nShdDistY )
+ eShdPosi = SVX_SHADOW_BOTTOMRIGHT;
+ else
+ eShdPosi = SVX_SHADOW_TOPRIGHT;
+ }
+ else
+ {
+ if( 0 <= nShdDistY )
+ eShdPosi = SVX_SHADOW_BOTTOMLEFT;
+ else
+ eShdPosi = SVX_SHADOW_TOPLEFT;
+ }
+ aShadow.SetLocation( eShdPosi );
+
+ rFlySet.Put( aShadow );
+ }
+
+ // Hintergrund: SvxBrushItem
+ if( pFillAttrSetItem )
+ {
+ SfxItemState eState = pFillAttrSetItem->GetItemSet().GetItemState(
+ XATTR_FILLSTYLE,
+ TRUE, &pItem );
+ if( eState == SFX_ITEM_SET )
+ {
+
+ const XFillStyle eFillStyle =
+ ((const XFillStyleItem*)pItem)->GetValue();
+
+ if(eFillStyle != XFILL_NONE)
+ {
+ SvxBrushItem aBrushItem;
+ BOOL bBrushItemOk = FALSE;
+
+ switch( eFillStyle )
+ {
+ case XFILL_NONE :
+ {
+ aBrushItem.SetColor( Color( COL_TRANSPARENT ) );
+ bBrushItemOk = TRUE;
+ }break;
+ case XFILL_SOLID :
+ {
+ const Color aColor =
+ WW8ITEMVALUE( pFillAttrSetItem->GetItemSet(),
+ XATTR_FILLCOLOR,
+ XFillColorItem );
+ aBrushItem.SetColor( aColor );
+ bBrushItemOk = TRUE;
+ }break;
+ case XFILL_GRADIENT :
+ break;
+ case XFILL_HATCH :
+ break;
+ case XFILL_BITMAP :
+ {
+ const Graphic aGraphic(
+ WW8ITEMVALUE( pFillAttrSetItem->GetItemSet(),
+ XATTR_FILLBITMAP,
+ XFillBitmapItem ).GetBitmap() );
+
+ BOOL bTile =
+ WW8ITEMVALUE( pFillAttrSetItem->GetItemSet(),
+ XATTR_FILLBMP_TILE,
+ SfxBoolItem );
+ aBrushItem.SetGraphic( aGraphic );
+ aBrushItem.SetGraphicPos( bTile
+ ? GPOS_TILED
+ : GPOS_AREA );
+ bBrushItemOk = TRUE;
+ }break;
+ }
+ if( bBrushItemOk )
+ rFlySet.Put( aBrushItem, RES_BACKGROUND );
+ }
+ }
+ }
+
+}
+
+
+void SwWW8ImplReader::MatchWrapDistancesIntoFlyFmt( SvxMSDffImportRec* pRecord,
+ SwFrmFmt* pFlyFmt )
+{
+ if( pRecord->nDxWrapDistLeft || pRecord->nDxWrapDistRight )
+ {
+ SvxLRSpaceItem aLR;
+ aLR.SetLeft( (USHORT)pRecord->nDxWrapDistLeft );
+ aLR.SetRight( (USHORT)pRecord->nDxWrapDistRight );
+ pFlyFmt->SetAttr( aLR );
+ }
+ if( pRecord->nDyWrapDistTop || pRecord->nDyWrapDistBottom )
+ {
+ SvxULSpaceItem aUL;
+ aUL.SetUpper( (USHORT)pRecord->nDyWrapDistTop );
+ aUL.SetLower( (USHORT)pRecord->nDyWrapDistBottom );
+ pFlyFmt->SetAttr( aUL );
+ }
+}
+
+
+void SwWW8ImplReader::SetCropAtGrfNode( SvxMSDffImportRec* pRecord,
+ SwFrmFmt* pFlyFmt,
+ WW8_FSPA* pF )
+{
+ if( pRecord->nCropFromTop ||
+ pRecord->nCropFromBottom ||
+ pRecord->nCropFromLeft ||
+ pRecord->nCropFromRight )
+ {
+
+ const SwNodeIndex* pIdx = pFlyFmt->GetCntnt( FALSE ).GetCntntIdx();
+ SwGrfNode* pGrfNd;
+ if( pIdx && 0 != (pGrfNd = rDoc.GetNodes()[ pIdx->GetIndex()
+ + 1 ]->GetGrfNode() ))
+ {
+ Size aSz( pGrfNd->GetTwipSize() );
+ ULONG rHeight = aSz.Height();
+ ULONG rWidth = aSz.Width();
+ if( !rWidth )
+ rWidth = pF->nXaRight - pF->nXaLeft;
+ else if( !rHeight )
+ rHeight = pF->nYaBottom - pF->nYaTop;
+#if SUPD>601
+
+ SwCropGrf aCrop; // Cropping is stored in 'fixed floats'
+ // 16.16 (it est fraction times total
+ if( pRecord->nCropFromTop ) // image width or height resp.)
+ aCrop.SetTop(
+ ( ( (pRecord->nCropFromTop >> 16 ) * rHeight )
+ + (((pRecord->nCropFromTop & 0xffff) * rHeight ) >> 16) ));
+ if( pRecord->nCropFromBottom )
+ aCrop.SetBottom(
+ ( ( (pRecord->nCropFromBottom >> 16 ) * rHeight )
+ + (((pRecord->nCropFromBottom & 0xffff) * rHeight ) >> 16) ));
+ if( pRecord->nCropFromLeft )
+ aCrop.SetLeft(
+ ( ( (pRecord->nCropFromLeft >> 16 ) * rWidth )
+ + (((pRecord->nCropFromLeft & 0xffff) * rWidth ) >> 16) ));
+ if( pRecord->nCropFromRight )
+ aCrop.SetRight(
+ ( ( (pRecord->nCropFromRight >> 16 ) * rWidth )
+ + (((pRecord->nCropFromRight & 0xffff) * rWidth ) >> 16) ));
+
+ pGrfNd->SetAttr( aCrop );
+#endif
+ }
+ }
+}
+
+
+
+SdrObject* SwWW8ImplReader::CreateContactObject( SwFlyFrmFmt* pFlyFmt )
+{
+ if( pFlyFmt )
+ {
+ SdrObject* pNewObject = pFlyFmt->FindSdrObject();
+ if( !pNewObject )
+ {
+ SwFlyDrawContact* pContactObject
+ = new SwFlyDrawContact( pFlyFmt, pDrawModel);
+ pNewObject = pContactObject->GetMaster();
+ }
+ return pNewObject;
+ }
+ return 0;
+}
+
+
+#pragma optimize("",off)
+SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
+{
+ SwFrmFmt* pRetFrmFmt = 0;
+ if( nIniFlags & WW8FL_NO_GRAFLAYER )
+ return pRetFrmFmt;
+
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+ nDrawCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpMcr
+ + pWwFib->ccpAtn + pWwFib->ccpEdn;
+ if( pPlcxMan->GetManType() == MAN_HDFT ) nDrawCpO += pWwFib->ccpTxbx;
+
+ if( bVer67 )
+ {
+ if( bHdFtFtnEdn ) // kann der Writer z.Zt. leider nicht
+ return pRetFrmFmt;
+ // if( pFlyPara ) // sicherheitshalber
+ // return;
+ // if( bTable ) // sicherheitshalber
+ // return;
+
+ // if( bTable )
+ // return; // geht z.Zt. nicht
+
+
+ if( !pDrawModel ) // 1. GrafikObjekt des Docs
+ GrafikCtor();
+
+ WW8PLCFspecial* pPF = pPlcxMan->GetFdoa();
+ if( !pPF ){
+ ASSERT( !this, "+Wo ist die Grafik (1) ?" );
+ return pRetFrmFmt;
+ }
+ long nOldPos = pStrm->Tell();
+ if( !pDrawHeight ){ // 1. Aufruf
+ pDrawHeight = new SvShorts;
+ nDrawObjOfs = pDrawPg->GetObjCount();
+ }
+ nDrawXOfs = nDrawYOfs = 0;
+ pDrawFmt = rDoc.MakeDrawFrmFmt( WW8_ASCII2STR( "DrawObject" ),
+ rDoc.GetDfltFrmFmt() );
+ ReadGrafLayer1( pPF, nGrafAnchorCp );
+ pStrm->Seek( nOldPos );
+ }
+ else
+ {
+ WW8PLCFspecial* pPF = pPlcxMan->GetFdoa();
+ if( !pPF ){
+ ASSERT( !this, "+Wo ist die Grafik (1) ?" );
+ return pRetFrmFmt;
+ }
+ pPF->SeekPos( nGrafAnchorCp );
+
+ long nStartFc;
+ void* pF0;
+ if( !pPF->Get( nStartFc, pF0 ) ){
+ ASSERT( !this, "+Wo ist die Grafik (2) ?" );
+ return pRetFrmFmt;
+ }
+
+ WW8_FSPA_SHADOW* pFS = (WW8_FSPA_SHADOW*)pF0;
+ WW8_FSPA* pF;
+#ifdef __WW8_NEEDS_COPY
+ WW8_FSPA aFSFA;
+ pF = &aFSFA;
+ WW8FSPAShadowToReal( pFS, pF );
+#else
+ pF = (WW8_FSPA*)pFS;
+#endif // defined __WW8_NEEDS_COPY
+ if( !pF->nSpId )
+ {
+ ASSERT( !this, "+Wo ist die Grafik (3) ?" );
+ return pRetFrmFmt;
+ }
+
+ if( !pDrawModel )// 1. GrafikObjekt des Docs
+ GrafikCtor();
+
+ if( !pMSDffManager->GetModel() )
+ pMSDffManager->SetModel(pDrawModel, 1440);
+
+ SdrObject* pObject = 0;
+
+ Rectangle aRect(pF->nXaLeft, pF->nYaTop,
+ pF->nXaRight, pF->nYaBottom);
+ SvxMSDffImportData aData( aRect );
+
+ if( pMSDffManager->GetShape( pF->nSpId, pObject, aData )
+ && pObject )
+ {
+ const SdrObject* pOrgShapeObject = pObject;
+ SvxMSDffImportRec* pRecord;
+ BOOL bDone = FALSE;
+ SdrObject* pOurNewObject = 0;
+ BOOL bSetCrop = FALSE;
+ BOOL bOrgObjectWasReplace
+ = ( (SdrInventor == pObject->GetObjInventor())
+ && ( (UINT16( OBJ_GRAF ) == pObject->GetObjIdentifier())
+ || (UINT16( OBJ_OLE2 ) == pObject->GetObjIdentifier()) ) );
+
+ //FormControl Text, cmc
+ UINT32 nTextId =
+ pMSDffManager->GetPropertyValue(DFF_Prop_pictureId,0);
+ if (nTextId)
+ bOrgObjectWasReplace=TRUE;
+
+
+ // Umfluss-Modus ermitteln
+ SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ SwSurround eSurround = SURROUND_PARALLEL;
+ BOOL bContour = FALSE;
+ switch( pF->nwr )
+ {
+ case 0: ; //0 like 2, but doesn't require absolute object
+ case 2: eSurround = SURROUND_PARALLEL; break; //2 wrap around absolute object
+ case 1: eSurround = SURROUND_NONE; break; //1 no text next to shape
+ case 3: eSurround = SURROUND_THROUGHT; break; //3 wrap as if no object present
+ case 4: ; //4 wrap tightly around object
+ case 5:
+ {
+ eSurround = SURROUND_PARALLEL; //5 wrap tightly, but allow holes
+
+ // ensure the object will be conterted
+ // into a Writer structure!
+ // the Writer doesn't support Contour on Sdr objects
+ if( bOrgObjectWasReplace )
+ bContour = TRUE;
+ }
+ break;
+ }
+ // bei Modus 2 oder 4 auch den Zusatzparameter beruecksichtigen
+ if( ( 2 == pF->nwr ) || ( 4 == pF->nwr ) )
+ {
+ switch( pF->nwrk )
+ {
+ case 0: eSurround = SURROUND_PARALLEL; break; //0 wrap both sides
+ case 1: eSurround = SURROUND_LEFT; break; //1 wrap only on left
+ case 2: eSurround = SURROUND_RIGHT; break; //2 wrap only on right
+ case 3: eSurround = SURROUND_IDEAL; break; //3 wrap only on largest side
+ }
+ }
+ SwFmtSurround aSur( eSurround );
+ aSur.SetContour( bContour );
+ aSur.SetOutside( TRUE ); // Winword kann nur Aussen-Konturen
+ aFlySet.Put( aSur );
+
+ if( bOrgObjectWasReplace )
+ {
+ long nWidthTw = pF->nXaRight -pF->nXaLeft;
+ if( 0>nWidthTw ) nWidthTw =0;
+ long nHeightTw = pF->nYaBottom - pF->nYaTop;
+ if( 0>nHeightTw) nHeightTw=0;
+
+ aFlySet.Put( SwFmtAnchor( FLY_AT_CNTNT ) );
+
+ if( nbxRelPageBorder == pF->nbx )
+ {
+ pF->nXaLeft -= nPgLeft;
+ if( bTable )
+ pF->nXaLeft -= GetTableLeft();
+ }
+ aFlySet.Put(
+ SwFmtHoriOrient( pF->nXaLeft, HORI_NONE, FRAME ) );
+ aFlySet.Put(
+ SwFmtVertOrient( pF->nYaTop, VERT_NONE, FRAME ) );
+
+ aFlySet.Put( SwFmtFrmSize( ATT_VAR_SIZE, nWidthTw, nHeightTw ));
+
+ pRecord = ( aData.HasRecords()
+ && (1 == aData.GetRecCount() ) )
+ ? aData.GetRecord( 0 ) : 0;
+
+ if( pRecord )
+ {
+ Rectangle aInnerDist( pRecord->nDxTextLeft,
+ pRecord->nDyTextTop,
+ pRecord->nDxTextRight,
+ pRecord->nDyTextBottom );
+
+ MatchSdrItemsIntoFlySet( pObject,
+ aFlySet,
+ pRecord->eLineStyle,
+ aInnerDist,
+ !pRecord->bLastBoxInChain );
+ }
+
+ XubString aObjectName( pObject->GetName() );
+ SwFrmFmt *pControl=NULL;
+ if( UINT16( OBJ_OLE2 ) == pObject->GetObjIdentifier() )
+ {
+ SvInPlaceObjectRef xIPRef(
+ ((SdrOle2Obj*)pObject)->GetObjRef() );
+
+ // kein GrafSet uebergeben, da nur fuer Cropping sinnvoll, was die
+ // UI derzeit (27.1.99) noch nicht kann khz.
+ pRetFrmFmt = rDoc.Insert( *pPaM, &xIPRef, &aFlySet );
+ }
+ else if (nTextId) //i.e. This is possibly a FormControl or graphic
+ {
+ UINT16 nTxBxS = (UINT16)(nTextId >> 16);
+ UINT16 nSequence = (UINT16)nTextId;
+ pRecord = aData.GetRecord(0);
+
+ SdrObject* pTrueObject
+ = ( bOrgObjectWasReplace
+ && (pOrgShapeObject == pRecord->pObj) )
+ ? pOurNewObject
+ : pRecord->pObj;
+
+ if( bOrgObjectWasReplace && pTrueObject )
+ {
+ if( pF->bBelowText )
+ pTrueObject->SetLayer( nDrawHell );
+ else
+ pTrueObject->SetLayer( nDrawHeaven );
+ }
+
+ if( pTrueObject == pRecord->pObj )
+ {
+ MatchWrapDistancesIntoFlyFmt( pRecord, pRetFrmFmt );
+ if( bSetCrop )
+ SetCropAtGrfNode( pRecord, pRetFrmFmt, pF );
+ }
+
+ SdrTextObj* pSdrTextObj =
+ PTR_CAST(SdrTextObj,pRecord->pObj);
+
+ if( pSdrTextObj )
+ {
+ Size aObjSize(
+ pSdrTextObj->GetSnapRect().GetWidth(),
+ pSdrTextObj->GetSnapRect().GetHeight());
+
+ BOOL bEraseThisObject=FALSE;
+ BOOL bOldFloatingCtrl=bFloatingCtrl;
+ bFloatingCtrl=TRUE;
+ pControl = InsertTxbxText(
+ pSdrTextObj,
+ &aObjSize,
+ nTxBxS,
+ nSequence,
+ nGrafAnchorCp,
+ pRetFrmFmt,
+ FALSE,
+ bEraseThisObject,
+ FALSE,0,0,
+ pRecord );
+
+ if ((pControl) && (RES_DRAWFRMFMT==pControl->Which()))
+ {
+ SdrObject *pObj = pControl->FindSdrObject();
+ if ((pObj) && (FmFormInventor == pObj->GetObjInventor()))
+ {
+ /*have a control*/
+ pControl->SetAttr(aFlySet.Get(RES_VERT_ORIENT));
+ pControl->SetAttr(aFlySet.Get(RES_HORI_ORIENT));
+ }
+ }
+ bFloatingCtrl=bOldFloatingCtrl;
+ bDone=TRUE;
+ }
+ }
+
+
+ if ((UINT16( OBJ_GRAF ) == pObject->GetObjIdentifier()) && (!pControl))
+ {
+ const Graphic& rGraph = ((SdrGrafObj*)pObject)->GetGraphic();
+ bSetCrop = TRUE;
+ BOOL bDone2 = FALSE;
+
+ if( ((SdrGrafObj*)pObject)->IsLinkedGraphic() )
+ {
+ String aGrfName(
+ INetURLObject::RelToAbs(
+ ((SdrGrafObj*)pObject)->GetFileName() ) );
+
+ BOOL bExist = FALSE;
+ INetURLObject aGrURL(URIHelper::SmartRelToAbs(aGrfName));
+ try
+ {
+ ::ucb::Content aTestContent(
+ aGrURL.GetMainURL(),
+ uno::Reference< XCommandEnvironment >());
+ bExist = aTestContent.isDocument();
+ }
+ catch(...){}
+
+
+ if( bExist
+ || (GRAPHIC_NONE == rGraph.GetType()))
+ {
+ pRetFrmFmt = rDoc.Insert( *pPaM,
+ aGrfName,
+ aEmptyStr,
+ 0, // Graphic*
+ &aFlySet,
+ 0 ); // SwFrmFmt*
+ bDone2 = TRUE;
+ }
+ }
+ if( !bDone2 )
+ pRetFrmFmt = rDoc.Insert( *pPaM,
+ aEmptyStr,
+ aEmptyStr,
+ &rGraph,
+ &aFlySet,
+ 0 ); // SwFrmFmt*
+ bDone = TRUE;
+ }
+
+
+ if( pRetFrmFmt )
+ {
+ if( pRecord )
+ {
+ MatchWrapDistancesIntoFlyFmt( pRecord, pRetFrmFmt );
+ if( bSetCrop ) SetCropAtGrfNode( pRecord, pRetFrmFmt, pF );
+ }
+ // mehrfaches Auftreten gleicher Grafik-Namen vermeiden
+ if( aObjectName.Len() )
+ {
+ String aName;
+ if( MakeUniqueGraphName( aName, aObjectName ))
+ pRetFrmFmt->SetName( aName );
+ }
+ }
+ // falls alles Ok, Zeiger auf neues Objekt ermitteln und
+ // Z-Order-Liste entsprechend korrigieren (oder Eintrag loeschen)
+ pOurNewObject = CreateContactObject( (SwFlyFrmFmt*)pRetFrmFmt );
+
+ // altes Objekt aus der Z-Order-Liste entfernen
+ pMSDffManager->RemoveFromShapeOrder( pObject );
+ // aus der Drawing-Page rausnehmen
+ if( pObject->GetPage() )
+ pDrawPg->RemoveObject( pObject->GetOrdNum() );
+
+ // und das Objekt loeschen
+ DELETEZ( pObject );
+ /*
+ Achtung: ab jetzt nur noch pOrgShapeObject abfragen!
+ */
+
+
+ // Kontakt-Objekt in die Z-Order-Liste und die Page aufnehmen
+ if( pOurNewObject )
+ {
+ if( !bHdFtFtnEdn )
+ pMSDffManager->StoreShapeOrder( pF->nSpId, 0, pOurNewObject, 0 );
+ // Das Kontakt-Objekt MUSS in die Draw-Page gesetzt werden,
+ // damit in SwWW8ImplReader::LoadDoc1() die Z-Order
+ // festgelegt werden kann !!!
+ pDrawPg->InsertObject( pOurNewObject );
+ }
+ }
+ else
+ {
+ // eingelesenes Objekt (kann eine ganze Gruppe sein)
+ // jetzt korrekt positionieren usw.
+ if( pF->bRcaSimple )
+ {
+ pF->nbx = nbxRelPageBorder;
+ pF->nby = nbyRelPageBorder;
+ }
+
+ RndStdIds eAnchor = FLY_AT_CNTNT; //FLY_PAGE
+ if( (nbyRelText != pF->nby) )
+ {
+ if( bIsHeader || bIsFooter)
+ {
+ if( bIsHeader && (nPgTop < pF->nYaTop))
+ pF->nYaTop -= nPgTop;
+ else
+ pF->nYaTop = 0;
+ pNode_FLY_AT_CNTNT = &pPaM->GetPoint()->nNode.GetNode();
+ }
+ else
+ eAnchor = FLY_PAGE;
+ }
+ SwFmtAnchor aAnchor( eAnchor );
+ aAnchor.SetAnchor( pPaM->GetPoint() );
+ aFlySet.Put( aAnchor );
+
+
+ /*
+ Hilfs-Attribute setzen, damit MA die Werte im Layout umrechnen kann
+ ( bugdoc:59640 )
+ */
+ static SwRelationOrient __READONLY_DATA aOrientTab[] = {
+ REL_PG_PRTAREA, // == nbxRelPgMargin
+ REL_PG_FRAME, // == nbxRelPageBorder
+ FRAME // == nbxRelText
+ };
+
+ if( 3 > pF->nby )
+ aFlySet.Put( SwFmtVertOrient( pF->nYaTop, VERT_NONE,
+ aOrientTab[ pF->nby ] ) );
+ if( 3 > pF->nbx )
+ aFlySet.Put( SwFmtHoriOrient( pF->nXaLeft, HORI_NONE,
+ aOrientTab[ pF->nbx ] ) );
+
+
+
+ if( !(nIniFlags1 & WW8FL_NO_FLY_FOR_TXBX) ) // Wer nicht will, der hat gewollt!
+ {
+ BOOL bTextThere = FALSE;
+ pRecord = ( aData.HasRecords()
+ && (1 == aData.GetRecCount() ) )
+ ? aData.GetRecord( 0 ) : 0;
+ long nStartCpFly;
+ long nEndCpFly;
+ if( pRecord && pRecord->bReplaceByFly )
+ {
+ // Pruefen, ob in dieser Textbox-Kette denn Text enthalten ist.
+ // ( Umwandeln einer leeren Kette in Rahmen waere Unsinn. )
+ //
+ bTextThere = TxbxChainContainsRealText( pRecord->aTextId.nTxBxS,
+ nStartCpFly,
+ nEndCpFly );
+ if( bTextThere )
+ {
+ // Der Text wird nicht in das SdrTextObj eingelesen!
+ // Stattdessen wird ein Rahmen eingefuegt und der Text
+ // von nStartCpFly bis nEndCpFy dort hinein gelesen.
+ //
+ // Vorteil: im Rahmen sind viel mehr Attribute moeglich
+ // als in der Edit-Enging, und es koennen
+ // auch Felder, OLEs oder Grafiken darin sein...
+
+ Rectangle aInnerDist( pRecord->nDxTextLeft,
+ pRecord->nDyTextTop,
+ pRecord->nDxTextRight,
+ pRecord->nDyTextBottom );
+ MatchSdrItemsIntoFlySet( pObject,
+ aFlySet,
+ pRecord->eLineStyle,
+ aInnerDist,
+ !pRecord->bLastBoxInChain );
+
+ pRetFrmFmt = rDoc.MakeFlySection( eAnchor, pPaM->GetPoint(), &aFlySet );
+
+ MatchWrapDistancesIntoFlyFmt( pRecord, pRetFrmFmt );
+
+ // falls alles Ok, Zeiger auf neues Objekt ermitteln und
+ // Z-Order-Liste entsprechend korrigieren (oder Eintrag loeschen)
+ pOurNewObject = CreateContactObject( (SwFlyFrmFmt*)pRetFrmFmt );
+
+ // altes Objekt aus der Z-Order-Liste entfernen
+ pMSDffManager->RemoveFromShapeOrder( pObject );
+
+ // und das Objekt loeschen
+ DELETEZ( pObject );
+ /*
+ Achtung: ab jetzt nur noch pOrgShapeObject abfragen!
+ */
+
+
+ if( pOurNewObject )
+ {
+ pMSDffManager->StoreShapeOrder(
+ pF->nSpId,
+ (((ULONG)pRecord->aTextId.nTxBxS) << 16)
+ + pRecord->aTextId.nSequence,
+ pOurNewObject,
+ (SwFlyFrmFmt*)pRetFrmFmt,
+ nActSectionNo
+ + bIsHeader ? 1 : 0
+ + bIsFooter ? 2 : 0 );
+ // Das Kontakt-Objekt MUSS in die Draw-Page gesetzt werden,
+ // damit in SwWW8ImplReader::LoadDoc1() die Z-Order
+ // festgelegt werden kann !!!
+ pDrawPg->InsertObject( pOurNewObject );
+ }
+
+ // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden,
+ // wird in fltshell.cxx beim Setzen des FltAnchor-Attributes
+ // pFlyFrm->MakeFrms() gerufen
+ if( FLY_IN_CNTNT != eAnchor )
+ pCtrlStck->NewAttr( *pPaM->GetPoint(), SwFltAnchor( pRetFrmFmt ) );
+
+ // Box-0 erhaelt den Text fuer die ganze Kette!
+ if( !pRecord->aTextId.nSequence )
+ {
+#if 0
+ // merke Pos im Haupttext
+ SwPosition aMainTextPos( *pPaM->GetPoint() );
+
+ // schliesse Attribute auf dem End-Stack
+ pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+ SwWW8FltControlStack* pOldStck = pCtrlStck;
+ pCtrlStck = new SwWW8FltControlStack( &rDoc, nFieldFlags );
+
+ // rette die Attributverwaltung
+ WW8PLCFxSaveAll aPLCFxSave;
+ pPlcxMan->SaveAllPLCFx( &aPLCFxSave );
+ WW8PLCFMan* pOldPlcxMan = pPlcxMan;
+
+#endif
+ // rette Flags u.ae. und setze sie zurueck
+ WW8ReaderSave aSave( this );
+ // setze Pam in den FlyFrame
+ const SwFmtCntnt& rCntnt = pRetFrmFmt->GetCntnt();
+ ASSERT( rCntnt.GetCntntIdx(), "Kein Inhalt vorbereitet." );
+ pPaM->GetPoint()->nNode = rCntnt.GetCntntIdx()->GetIndex() + 1;
+ pPaM->GetPoint()->nContent.Assign( pPaM->GetCntntNode(), 0 );
+
+
+ // lies den Text ein
+ bTxbxFlySection = TRUE;
+ ReadText( nStartCpFly,
+ (nEndCpFly-nStartCpFly),
+ MAN_MAINTEXT == pPlcxMan->GetManType()
+ ? MAN_TXBX
+ : MAN_TXBX_HDFT );
+
+#if 0
+ // schliesse alle Attribute, da sonst Attribute
+ // entstehen koennen, die aus dem Fly rausragen
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+ // stelle die Writer-Flags wieder her
+ aSave.Restore( this );
+ DeleteCtrlStk();
+ pCtrlStck = pOldStck;
+
+ *pPaM->GetPoint() = aMainTextPos;
+
+ // restauriere die Attributverwaltung
+ pPlcxMan = pOldPlcxMan;
+ pPlcxMan->RestoreAllPLCFx( &aPLCFxSave );
+#else
+ aSave.Restore( this );
+#endif
+ }
+ bDone = TRUE;
+ }
+ }
+ }
+ if( !bDone )
+ {
+ if( pF->bBelowText )
+ pObject->SetLayer( nDrawHell );
+ else
+ pObject->SetLayer( nDrawHeaven );
+
+ pDrawPg->InsertObject( pObject );
+ pRetFrmFmt = rDoc.Insert( *pPaM, *pObject, &aFlySet );
+ }
+ }
+
+
+ /*
+ Innen- und Aussen-Rand-Abstaende einstellen
+ und ggfs. Text in enthaltene Textbox(en) einlesen
+ */
+ if( !bDone && aData.HasRecords() )
+ {
+ USHORT nRecCount = aData.GetRecCount();
+ for(USHORT nTxbx=0; nTxbx < nRecCount; nTxbx++ )
+ {
+ pRecord = aData.GetRecord( nTxbx );
+ if( pRecord && pRecord->pObj )
+ {
+ SdrObject* pTrueObject
+ = ( bOrgObjectWasReplace
+ && (pOrgShapeObject == pRecord->pObj) )
+ ? pOurNewObject
+ : pRecord->pObj;
+
+ if( bOrgObjectWasReplace && pTrueObject )
+ {
+ if( pF->bBelowText )
+ pTrueObject->SetLayer( nDrawHell );
+ else
+ pTrueObject->SetLayer( nDrawHeaven );
+ }
+
+ if( pTrueObject == pRecord->pObj )
+ {
+ MatchWrapDistancesIntoFlyFmt( pRecord, pRetFrmFmt );
+ if( bSetCrop ) SetCropAtGrfNode( pRecord, pRetFrmFmt, pF );
+
+ /*
+ if( pRecord->pClientDataBuffer )
+ {
+ //Auswertung des Client Data Puffers
+
+ }
+ */
+ }
+
+ if( pRecord->aTextId.nTxBxS && !bOrgObjectWasReplace )
+ {
+ SdrTextObj* pSdrTextObj;
+ // Pruefen, ob Gruppenobjekt (z.B. zwei Klammern) vorliegt
+ SdrObjGroup* pThisGroup
+ = PTR_CAST(SdrObjGroup, pRecord->pObj);
+ //if(pRecord->pObj->ISA(SdrObjGroup))
+ if( pThisGroup )
+ {
+ // Gruppenobjekte haben keinen Text. Fuege ein Textobjekt in die
+ // Gruppe ein, um den Text zu halten.
+ pSdrTextObj =
+ new SdrRectObj(OBJ_TEXT, pThisGroup->GetBoundRect());
+
+ SfxItemSet aSet(pDrawModel->GetItemPool());
+ aSet.Put(XFillStyleItem(XFILL_NONE));
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+ //SdrFitToSizeType eFTS = SDRTEXTFIT_PROPORTIONAL;
+ /*
+ aSet.Put(SdrTextVertAdjustItem( SDRTEXTVERTADJUST_TOP ));
+ aSet.Put(SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_LEFT ));
+ */
+ aSet.Put(SdrTextFitToSizeTypeItem( SDRTEXTFIT_NONE ));
+ aSet.Put(SdrTextAutoGrowHeightItem( FALSE ));
+ aSet.Put(SdrTextAutoGrowWidthItem( FALSE ));
+ pSdrTextObj->NbcSetAttributes(aSet, FALSE);
+
+ long nAngle = pRecord->nTextRotationAngle;
+ if( nAngle )
+ {
+ double a = nAngle*nPi180;
+ pSdrTextObj->NbcRotate( pSdrTextObj->GetBoundRect().Center(),
+ nAngle, sin(a), cos(a) );
+ }
+
+ pSdrTextObj->NbcSetLayer( pThisGroup->GetLayer() );
+ pThisGroup->GetSubList()->NbcInsertObject( pSdrTextObj );
+ }
+ else
+ {
+ pSdrTextObj = PTR_CAST(SdrTextObj, pRecord->pObj);
+ /*
+ Die Frage: was tun, wenn hier FALSE hereuskommt,
+ z.B. bei 3D-Objekten (nicht von SdrTextObj abgeleitet)
+
+ Wunsch: neues SdrTextObj hinzufuegen, das mit dem alten
+ in einer neu zu schaffenden Gruppe geklammert wird.
+
+ Implementierung: nicht zur 5.1 (jp und khz am 11.02.1999)
+
+ if( !pSdrTextObj )
+ {
+ ...
+ }
+ */
+ }
+
+ if( pSdrTextObj )
+ {
+ Size aObjSize(
+ pSdrTextObj->GetSnapRect().GetWidth(),
+ pSdrTextObj->GetSnapRect().GetHeight());
+
+ // Objekt ist Bestandteil einer Gruppe?
+ SdrObject* pGroupObject = pSdrTextObj->GetUpGroup();
+
+ UINT32 nOrdNum = pSdrTextObj->GetOrdNum();
+ BOOL bEraseThisObject;
+ InsertTxbxText( pSdrTextObj,
+ &aObjSize,
+ pRecord->aTextId.nTxBxS,
+ pRecord->aTextId.nSequence,
+ nGrafAnchorCp,
+ pRetFrmFmt,
+ (pSdrTextObj != pTrueObject)
+ || (0 != pGroupObject),
+ bEraseThisObject,
+ FALSE,0,0,
+ pRecord );
+
+ // wurde dieses Objekt ersetzt ??
+ if( bEraseThisObject )
+ {
+ if( pGroupObject
+ || (pSdrTextObj != pTrueObject) )
+ {
+ // Objekt wurde bereits (in der Gruppe und)
+ // der Drawing-Page durch ein neues
+ // SdrGrafObj ersetzt.
+
+ SdrObject* pNewObj =
+ pGroupObject
+ ? pGroupObject->GetSubList()->GetObj(
+ nOrdNum )
+ : pTrueObject;
+ // Objekt in der Z-Order-Liste ersetzen
+ pMSDffManager->ExchangeInShapeOrder(
+ pSdrTextObj, 0,0, pNewObj );
+ // Objekt jetzt noch loeschen
+ delete pRecord->pObj;
+ // und das neue Objekt merken.
+ pRecord->pObj = pNewObj;
+ }
+ else
+ {
+ // Objekt aus der Z-Order-Liste loeschen
+ pMSDffManager->RemoveFromShapeOrder( pSdrTextObj );
+ // Objekt aus der Drawing-Page rausnehmen
+ if( pSdrTextObj->GetPage() )
+ pDrawPg->RemoveObject( pSdrTextObj->GetOrdNum() );
+ // und FrameFormat entfernen, da durch Grafik
+ // ersetzt (dies loescht auch das Objekt)
+ rDoc.DelFrmFmt( pRetFrmFmt );
+ // auch den Objektmerker loeschen
+ pRecord->pObj = 0;
+ }
+ }
+ else
+ {
+ // ww8-default Randabstand einsetzen
+ SfxItemSet aItemSet( pDrawModel->GetItemPool(),
+ SDRATTR_TEXT_LEFTDIST,
+ SDRATTR_TEXT_LOWERDIST );
+ aItemSet.Put( SdrTextLeftDistItem( pRecord->nDxTextLeft ) );
+ aItemSet.Put( SdrTextRightDistItem( pRecord->nDxTextRight ) );
+ aItemSet.Put( SdrTextUpperDistItem( pRecord->nDyTextTop ) );
+ aItemSet.Put( SdrTextLowerDistItem( pRecord->nDyTextBottom ) );
+ pSdrTextObj->SetAttributes( aItemSet, FALSE );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ ASSERT( !this, "+Wo ist das Shape ?" );
+ return 0;
+ }
+ }
+ return pRetFrmFmt;
+}
+#pragma optimize("",on)
+
+
+void SwWW8ImplReader::GrafikCtor() // Fuer SVDraw und VCControls und Escher
+{
+ rDoc.MakeDrawModel( );
+ pDrawModel = rDoc.GetDrawModel();ASSERT( pDrawModel,
+ "Kann DrawModel nicht anlegen" );
+ pDrawPg = pDrawModel->GetPage( 0 );
+ nDrawHeaven = rDoc.GetHeavenId();
+ nDrawHell = rDoc.GetHellId();
+}
+
+void SwWW8ImplReader::GrafikDtor()
+{
+ DELETEZ( pDrawEditEngine ); // evtl. von Grafik angelegt
+ DELETEZ( pDrawHeight ); // dito
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8graf.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.93 2000/09/18 16:04:59 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.92 2000/08/28 14:55:42 khz
+ #64941# store Hd./Ft./Section info to prevent prohibited TxBx linkage
+
+ Revision 1.91 2000/08/24 14:39:04 khz
+ #78052# don't store SwFlyDrawContact in ShapeOrder array if bHdFtFtnEdn set
+
+ Revision 1.90 2000/08/24 12:32:54 os
+ Outliner/EditEngine changes
+
+ Revision 1.89 2000/08/24 10:48:52 jp
+ crop export to svx
+
+ Revision 1.88 2000/06/26 12:59:11 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.87 2000/06/15 15:23:38 cmc
+ #75669# 97Controls Import fixes
+
+ Revision 1.86 2000/06/13 08:24:46 os
+ using UCB
+
+ Revision 1.85 2000/05/16 12:12:53 jp
+ ASS_FALSE define removed
+
+ Revision 1.84 2000/05/16 11:14:00 khz
+ Unicode code-conversion
+
+ Revision 1.83 2000/03/08 10:20:26 khz
+ Task #73362# WW6: restore stream position after readind content of textbox
+
+ Revision 1.82 2000/03/03 15:20:01 os
+ StarView remainders removed
+
+ Revision 1.81 2000/02/22 16:00:02 khz
+ Task #72647# Import attributes of winword 6 TEXT OBJECTS
+
+ Revision 1.80 2000/02/22 13:54:32 khz
+ Task #73096# look for OLE- or Graphic-Indicator-Sprms
+
+ Revision 1.79 2000/02/22 11:59:02 khz
+ Task #73096# erase TextObj only when OLE or Graphic propperly imported
+
+ Revision 1.78 2000/02/18 09:35:05 cmc
+ #69372# Improved Hyperlink Importing for WW97
+
+
+ Revision 1.77 2000/02/14 14:36:32 jp
+ #70473# changes for unicode
+
+ Revision 1.76 2000/02/14 08:25:21 cmc
+ #72579 TxtBox NULL test crash fix, revealed by glossary addition
+
+ Revision 1.74 2000/02/09 08:57:16 khz
+ Task #72647# Read SPRMs that are stored in piece table grpprls (2)
+
+ Revision 1.73 2000/01/14 11:28:03 khz
+ Task #68832# -- CORRECTION: Task Number of rev below should have been: 68832 !
+
+ Revision 1.72 2000/01/14 11:11:38 khz
+ Task #71343# look for Sprm 37 (not 5) to recognize APO
+
+ Revision 1.71 2000/01/07 12:29:46 khz
+ Task #64574# believe Layerflag in Winword Struct rather than the one in Escher Data (2)
+
+ Revision 1.70 2000/01/07 12:27:19 khz
+ Task #64574# believe Layerflag in Winword Struct rather than the one in Escher Data
+
+ Revision 1.69 1999/12/14 14:22:45 khz
+ Task #70815# Avoid typecast when calling MatchSdrItemsIntoFlySet()
+
+ Revision 1.68 1999/12/06 16:38:08 khz
+ Task #67435# Import FillStyle on OLE and Graphic viaSdrAttrObj::GetFillAttrSetItem()
+
+ Revision 1.67 1999/12/01 10:18:36 khz
+ Task #67435# Use GetItemState() to find border of graphic
+
+ Revision 1.66 1999/11/23 18:56:17 khz
+ Task #67963# New method SvxMSDffManager::ImportObj() used by Draw, Writer, Calc
+
+ Revision 1.65 1999/11/19 15:02:42 khz
+ Special Task! Use new method to import Shapes: SvxMSDffManager::ImportObj()
+
+ Revision 1.64 1999/09/20 14:24:27 khz
+ Mussaenderung wg. TH apichange 10.09.1999
+
+ Revision 1.63 1999/08/30 19:53:00 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.62 30 Aug 1999 21:53:00 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.61 09 Aug 1999 14:16:02 JP
+ read W95 format from stream
+
+ Rev 1.60 27 Jul 1999 14:41:56 KHZ
+ Task #67886# Import Textboxes without #14 in it's field code
+
+ Rev 1.59 15 Jul 1999 10:56:00 KHZ
+ Task #67659# Do *not* set FillStyle on box with Default fill style
+
+ Rev 1.58 06 Jul 1999 16:38:14 KHZ
+ Task #67435# Borderattributes of graphics that are connected to a #1 char
+
+ Rev 1.57 22 Jun 1999 17:40:22 KHZ
+ Task #64574# adjust z-order for grouped objects2
+
+ Rev 1.56 09 Jun 1999 18:25:04 KHZ
+ use FOUR different inner distances with SvxBoxItem
+
+ Rev 1.55 02 Jun 1999 09:32:24 KHZ
+ Task #66227# a) kein Unicode bei Ver67 ;-) b) Grafik in grupp. Textbox
+
+ Rev 1.54 29 Apr 1999 12:45:40 KHZ
+ Task #65561# (versehentlich war Zuweisung von pRecord auskommentiert)
+
+ Rev 1.53 26 Apr 1999 17:40:22 KHZ
+ Task #61381# Attribute von Textboxen in denen NUR EINE Grafik steht
+
+ Rev 1.52 10 Mar 1999 18:23:12 KHZ
+ Task #63093# Bei FLY_IN_CNTNT nach MakeFlySection *kein* Ankerattribut setzen!
+
+ Rev 1.51 10 Mar 1999 15:11:18 KHZ
+ Task #62521# Einlesen von Sonderzeichen
+
+ Rev 1.50 18 Feb 1999 20:43:48 KHZ
+ Task #61681# in InsertObjekt() immer SURROUND_TROUGH setzen
+
+ Rev 1.49 18 Feb 1999 20:24:38 KHZ
+ Task #61659# Umlauf im Hintergrund
+
+ Rev 1.48 18 Feb 1999 18:52:38 JP
+ Bug #61659#/#61660#: Objecte in einer Gruppe NIE im LayoutConnecten
+
+ Rev 1.47 17 Feb 1999 17:34:26 KHZ
+ Task #61982# Zugriff auf freigegebenen Speicher nach ReplaceObject
+
+ Rev 1.46 17 Feb 1999 15:24:16 KHZ
+ Task #61382# jetzt auch Textbox-Grafiken im Hintergrund ( SvxOpaqItem(FALSE) )
+
+ Rev 1.45 16 Feb 1999 13:03:24 KHZ
+ Task #60326# nur das erste von mehreren PicLoc-Attributen einer Char-Pos ist ok
+
+ Rev 1.44 15 Feb 1999 21:40:04 KHZ
+ Task #61381# jetzt include von boxitem.hxx fuer WW8_DECL_LINETAB_ARRAY
+
+ Rev 1.43 12 Feb 1999 16:51:06 KHZ
+ Task #61381# Ersetzen von Sdr-Text-Objekten im Writer durch Rahmen (3)
+
+ Rev 1.42 05 Feb 1999 19:37:02 KHZ
+ Task #61381# Ersetzen von Sdr-Text-Objekten im Writer durch Rahmen (2)
+
+ Rev 1.41 05 Feb 1999 10:33:48 KHZ
+ Task #61381# Ersetzen von Sdr-Text-Objekten im Writer durch Rahmen
+
+ Rev 1.40 28 Jan 1999 17:10:46 KHZ
+ Task #60715# in SdrTextObj verankerte Grafiken und OLEs (4)
+
+ Rev 1.39 27 Jan 1999 10:58:02 KHZ
+ Task #60715# in SdrTextObj verankerte Grafiken und OLEs (2)
+
+ Rev 1.38 25 Jan 1999 10:25:46 KHZ
+ Task #60715# in Textobjekt verankerte Grafik als Grafik importieren
+
+ Rev 1.37 19 Jan 1999 10:53:06 KHZ
+ Task #60715# in Textbox verankerte Grafiken und OLEs (1)
+
+ Rev 1.36 06 Jan 1999 10:51:52 KHZ
+ Task #59858# Testreihenfolge der While-Schleifen geaendert
+
+ Rev 1.35 22 Dec 1998 09:08:38 KHZ
+ Task #60395# (4) StoreShapeOrder wieder angeklemmt
+
+ Rev 1.34 21 Dec 1998 16:00:42 KHZ
+ StoreShapeOrder voruebergehend abgeklemmt
+
+ Rev 1.33 18 Dec 1998 12:27:22 KHZ
+ Task #60395# (3) jetzt DOCH Layer und Z-Order fuer Grafik oder OLE-Objekt :-)
+
+ Rev 1.32 17 Dec 1998 10:41:26 KHZ
+ Task #60395# (2) KEINE Positionierung bei geloeschten Objekten (Grafik, OLE)
+
+ Rev 1.31 15 Dec 1998 19:54:06 KHZ
+ Task #60395# Positionierung vor/hinter dem Text je nach pRecord->bDrawHell
+
+ Rev 1.30 07 Dec 1998 16:29:38 JP
+ Bug #58766#/#59640#: Zeichenobjecte nach WW97 Import richtig positionieren
+
+ Rev 1.29 05 Dec 1998 17:11:26 KHZ
+ Task #59580# Unicode (3)
+
+ Rev 1.28 04 Dec 1998 20:19:46 KHZ
+ Task #58766# Textboxen mit Unicode-Inhalt
+
+ Rev 1.27 30 Nov 1998 17:46:52 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.26 27 Nov 1998 09:45:22 JP
+ Task #59822#: OLE-Objecte importieren - Namen korrekt ermitteln
+
+ Rev 1.25 25 Nov 1998 18:45:40 JP
+ Compilerfehler unter UNX
+
+ Rev 1.24 24 Nov 1998 20:45:04 JP
+ Task #59822#: OLE-Objecte einlesen
+
+ Rev 1.23 20 Nov 1998 22:04:52 JP
+ Task #59476#: Crop-Werte bei Grafiken setzen
+
+ Rev 1.22 20 Nov 1998 16:35:30 KHZ
+ Task #59640# Hilfsattribute SwFmtVertOrient und SwFmtHoriOrient (2)
+
+ Rev 1.21 20 Nov 1998 16:18:10 KHZ
+ Task #59735# Innen- und Aussenabstaende zwischen Text und Shape (bzw. Grafik)
+
+ Rev 1.20 20 Nov 1998 09:44:54 KHZ
+ Task #59640# Hilfsattribute SwFmtVertOrient und SwFmtHoriOrient eingesetzt
+
+ Rev 1.19 29 Oct 1998 15:28:54 KHZ
+ Task #58199# gedrehter Text in Shapes und Text in Gruppen jetzt moeglich
+
+ Rev 1.18 28 Oct 1998 10:49:30 KHZ
+ Task #55189# Text jetzt auch bei Group-Autoformen (Doppelklammer...) moeglich
+
+ Rev 1.17 21 Oct 1998 13:55:52 KHZ
+ Task #55189# Abstand des Textbereich vom Shape-Rand ist jetzt WW8 Default
+
+ Rev 1.16 20 Oct 1998 17:21:56 KHZ
+ Task #57704# Text-Umlauf um Grafiken und Escher-Objekte
+
+ Rev 1.15 03 Sep 1998 22:14:22 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.14 27 Aug 1998 10:12:30 KHZ
+ Task #55189# Escher-Import fuer Draw, Calc und Writer
+
+ Rev 1.13 05 Aug 1998 17:16:24 KHZ
+ Task #53614# komprimierte WMF, Enh.Metafile und PICT Grafiken
+
+ Rev 1.12 31 Jul 1998 20:43:06 KHZ
+ Task #52607# Fehler wg. Compiler-Optimierung!
+
+ Rev 1.11 30 Jul 1998 23:15:02 KHZ
+ Task #53614# Grafiken in Data und Dokumentstream gemischt
+
+ Rev 1.10 30 Jul 1998 20:52:36 KHZ
+ Task #52607# GPF unter Unix behoben
+
+ Rev 1.9 28 Jul 1998 23:48:20 KHZ
+ Task #52607# Grafik-Textboxen und Absatzformatierung verbessert
+
+ Rev 1.8 28 Jul 1998 11:01:48 KHZ
+ Task #52607# nummerierte Listen (Teil 1)
+
+ Rev 1.7 22 Jul 1998 15:36:18 KHZ
+ Task #52607#
+
+ Rev 1.6 21 Jul 1998 14:51:50 KHZ
+ Task #52607# (WW 97 Import)
+
+ Rev 1.5 21 Jul 1998 12:33:38 KHZ
+ als MSDrawingObject eingebettete Grafik (Teil 1)
+
+ Rev 1.4 13 Jul 1998 15:29:16 KHZ
+ Task #52607# embeded Grafiken (NICHT UEBER den Text gelegte)
+
+ Rev 1.3 30 Jun 1998 21:33:24 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.2 23 Jun 1998 11:24:26 KHZ
+ Zwischenstand: die meisten Zeichenattribute Ok!
+
+ Rev 1.1 18 Jun 1998 09:47:14 KHZ
+ Zwischenstand fur 396c
+
+ Rev 1.0 16 Jun 1998 11:06:34 KHZ
+ Initial revision.
+
+*************************************************************************/
+
+
+
diff --git a/sw/source/filter/ww8/ww8graf.hxx b/sw/source/filter/ww8/ww8graf.hxx
new file mode 100644
index 000000000000..34dcd7156164
--- /dev/null
+++ b/sw/source/filter/ww8/ww8graf.hxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8graf.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _WW8GRAF_HXX
+#define _WW8GRAF_HXX
+
+
+#define nbxRelPageBorder 1 // Blatt-Rand
+#define nbxRelPgMargin 0 // Page Print Area
+#define nbxRelText 2 // Spalten (Absatz) -Rand = FRAME Print Area
+
+#define nbyRelPageBorder 1
+#define nbyRelPgMargin 0
+#define nbyRelText 2
+
+
+struct WW8_FSPA
+{
+ long nSpId; //Shape Identifier. Used in conjunction with the office art data (found via fcDggInfo in the FIB) to find the actual data for this shape.
+ long nXaLeft; //left of rectangle enclosing shape relative to the origin of the shape
+ long nYaTop; //top of rectangle enclosing shape relative to the origin of the shape
+ long nXaRight; //right of rectangle enclosing shape relative to the origin of the shape
+ long nYaBottom;//bottom of the rectangle enclosing shape relative to the origin of the shape
+ USHORT bHdr:1;
+ //0001 1 in the undo doc when shape is from the header doc, 0 otherwise (undefined when not in the undo doc)
+ USHORT nbx:2;
+ //0006 x position of shape relative to anchor CP
+ //0 relative to page margin
+ //1 relative to top of page
+ //2 relative to text (column for horizontal text; paragraph for vertical text)
+ //3 reserved for future use
+ USHORT nby:2;
+ //0018 y position of shape relative to anchor CP
+ //0 relative to page margin
+ //1 relative to top of page
+ //2 relative to text (paragraph for horizontal text; column for vertical text)
+ USHORT nwr:4;
+ //01E0 text wrapping mode
+ //0 like 2, but doesn't require absolute object
+ //1 no text next to shape
+ //2 wrap around absolute object
+ //3 wrap as if no object present
+ //4 wrap tightly around object
+ //5 wrap tightly, but allow holes
+ //6-15 reserved for future use
+ USHORT nwrk:4;
+ //1E00 text wrapping mode type (valid only for wrapping modes 2 and 4
+ //0 wrap both sides
+ //1 wrap only on left
+ //2 wrap only on right
+ //3 wrap only on largest side
+ USHORT bRcaSimple:1;
+ //2000 when set, temporarily overrides bx, by, forcing the xaLeft, xaRight, yaTop, and yaBottom fields to all be page relative.
+ USHORT bBelowText:1;
+ //4000
+ //1 shape is below text
+ //0 shape is above text
+ USHORT bAnchorLock:1;
+ //8000 1 anchor is locked
+ // 0 anchor is not locked
+ long nTxbx; //count of textboxes in shape (undo doc only)
+};
+
+
+struct WW8_FSPA_SHADOW // alle Member an gleicher Position und Groesse,
+{ // wegen: pF = (WW8_FSPA*)pFS;
+ SVBT32 nSpId;
+ SVBT32 nXaLeft;
+ SVBT32 nYaTop;
+ SVBT32 nXaRight;
+ SVBT32 nYaBottom;
+ SVBT16 aBits1;
+ SVBT32 nTxbx;
+};
+
+struct WW8_TXBXS
+{
+ SVBT32 cTxbx__iNextReuse;
+ SVBT32 cReusable;
+ SVBT16 fReusable;
+ SVBT32 reserved;
+ SVBT32 ShapeId;
+ SVBT32 txidUndo;
+};
+
+void WW8FSPAShadowToReal( WW8_FSPA_SHADOW* pFSPAS, WW8_FSPA* pPic );
+
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8graf.hxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:04:59 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/05/16 11:35:11 khz
+ Unicode code-conversion
+
+ Revision 1.9 1998/11/25 17:50:46 JP
+ Compilerfehler unter UNX
+
+
+ Rev 1.8 25 Nov 1998 18:50:46 JP
+ Compilerfehler unter UNX
+
+ Rev 1.7 20 Nov 1998 17:56:00 KHZ
+ Task #59640# Hilfsattribute SwFmtVertOrient und SwFmtHoriOrient (2)
+
+ Rev 1.6 29 Oct 1998 15:27:26 KHZ
+ Task #58199# defines fuer rel. Abstand-Orientierung von Shapes geaendert
+
+ Rev 1.5 03 Sep 1998 22:14:22 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.4 27 Aug 1998 10:12:30 KHZ
+ Task #55189# Escher-Import fuer Draw, Calc und Writer
+
+ Rev 1.3 22 Jul 1998 16:14:16 HR
+ ww8graf fuer UNX
+
+ Rev 1.2 21 Jul 1998 14:51:48 KHZ
+ Task #52607# (WW 97 Import)
+
+ Rev 1.1 21 Jul 1998 12:33:28 KHZ
+ als MSDrawingObject eingebettete Grafik (Teil 1)
+
+ Rev 1.0 16 Jun 1998 10:56:50 KHZ
+ Initial revision.
+
+*************************************************************************/
+#endif
+
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
new file mode 100644
index 000000000000..2771ffd0de06
--- /dev/null
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -0,0 +1,1363 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8graf2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+
+#ifndef _TOOLS_TEMPFILE_HXX
+#include <tools/tempfile.hxx>
+#endif
+#ifndef _SVX_IMPGRF_HXX //autogen
+#include <svx/impgrf.hxx>
+#endif
+#ifndef _SVDPAGE_HXX //autogen
+#include <svx/svdpage.hxx>
+#endif
+#ifndef _SVDMODEL_HXX //autogen
+#include <svx/svdmodel.hxx>
+#endif
+#ifndef _SVDOGRAF_HXX
+#include <svx/svdograf.hxx>
+#endif
+#ifndef _SVDOOLE2_HXX
+#include <svx/svdoole2.hxx>
+#endif
+#ifndef _SVX_OPAQITEM_HXX //autogen
+#include <svx/opaqitem.hxx>
+#endif
+
+#ifndef _MSDFFIMP_HXX
+#include <svx/msdffimp.hxx>
+#endif
+
+
+#ifndef _SFXAPP_HXX
+#include <sfx2/app.hxx>
+#endif
+
+#ifndef _SFXDOCFILE_HXX
+#include <sfx2/docfile.hxx>
+#endif
+
+#ifndef _SFX_FCONTNR_HXX
+#include <sfx2/fcontnr.hxx>
+#endif
+
+
+#ifndef _IPOBJ_HXX //autogen
+#include <so3/ipobj.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _DCONTACT_HXX
+#include <dcontact.hxx>
+#endif
+
+#ifndef _GRFATR_HXX
+#include <grfatr.hxx> // class SwCropGrf
+#endif
+#ifndef _FMTFLCNT_HXX //autogen
+#include <fmtflcnt.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx>
+#endif
+#ifndef _WW8STRUC_HXX
+#include <ww8struc.hxx>
+#endif
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx> // class SwWWImplReader
+#endif
+#ifndef _WW8PAR2_HXX
+#include <ww8par2.hxx> // struct WWFlyPara
+#endif
+#ifndef _WW8GRAF_HXX
+#include <ww8graf.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx> // class SwTxtNode
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // Progress
+#endif
+#ifndef _FSYS_HXX
+#include <tools/fsys.hxx>
+#endif
+
+
+#ifdef __WW8_NEEDS_COPY
+extern void WW8PicShadowToReal( WW8_PIC_SHADOW* pPicS, WW8_PIC* pPic );
+#endif // defined __WW8_NEEDS_COPY
+
+
+//-----------------------------------------
+// los gehts
+//-----------------------------------------
+
+
+#ifdef USE_WMF_GRAF_FILE // Definieren fuer Import WMF ueber File
+ // ( alte Version, kann kein MAC-PICT )
+struct WmfFileHd
+{ // Vorsicht: Struktur ist nicht aligned
+ SVBT16 nTyp; // 0 = Mem, 1 = File
+ SVBT16 nHdSiz; // 0x009
+ SVBT16 nVersion; // 0x300
+ SVBT32 nSize; // filesize in bytes
+ SVBT16 nNoObj; // Number of Objects that exist at same time
+ SVBT32 nMaxRecLen; // largest record
+ SVBT16 nNoParas; // not used
+};
+#define WMF_FILE_HD_SIZ 18 // Groesse der Struktur WmfFileHd
+
+ULONG SwWW8ImplReader::ReadWmfHeader( WmfFileHd* pHd, long nPos )
+{
+ pStrm->Seek( nPos );
+ pStrm->Read( pHd, sizeof( *pHd ) );
+ return SVBT32ToLong( pHd->nSize ) * 2; // FileSize in Bytes
+}
+
+#endif // USE_WMF_GRAF_FILE
+
+
+
+
+struct METAFILEHEADER // ist aligned, deshalb gehts fuer alle Platformen
+{
+ UINT32 key;
+ UINT16 hmf;
+ UINT16 left;
+ UINT16 top;
+ UINT16 right;
+ UINT16 bottom;
+ UINT16 inch;
+ UINT32 reserved;
+ UINT16 checksum;
+};
+
+
+#define METAFILEHEADER_SIZE 22
+
+
+static void WriteWmfPreHd( long nWidth, long nHeight, SvStream& rOStream )
+{
+ METAFILEHEADER aHeader;
+
+ aHeader.key = 0x9AC6CDD7L;
+ aHeader.hmf = 0;
+ aHeader.left = 0;
+ aHeader.top = 0;
+ aHeader.right = (UINT16)( nWidth * 100 / 144 );
+ aHeader.bottom = (UINT16)( nHeight * 100 / 144 );
+ aHeader.inch= 1000;
+ aHeader.reserved = 0;
+ aHeader.checksum = 0;
+ for( USHORT n=0; n < 10; n++ )
+ aHeader.checksum ^= *(((UINT16*)&aHeader)+n);
+
+#ifdef __BIGENDIAN
+ aHeader.key = SWAPLONG( aHeader.key );
+ aHeader.left = 0;
+ aHeader.top = 0;
+ aHeader.right = SWAPSHORT( aHeader.right );
+ aHeader.bottom = SWAPSHORT( aHeader.bottom );
+ aHeader.inch = SWAPSHORT( aHeader.inch );
+ aHeader.checksum = SWAPSHORT( aHeader.checksum );
+#endif // __BIGENDIAN
+
+ rOStream.Write( (char*)&aHeader, METAFILEHEADER_SIZE );
+}
+
+
+#define WWBUFSIZ 4096 // 512 <= WWBUFSIZE <= UINT16_MAX !!!
+
+static void _CopyFilePiece( SvStream* pDst, SvStream* pSrc, ULONG nRead,
+ void* pBuf, UINT16 nBufSize )
+{
+ UINT16 nRead1;
+ do{
+ nRead1 = ( nRead > nBufSize ) ? nBufSize : (UINT16)nRead;
+ pSrc->Read( pBuf, nRead1 );
+ pDst->Write( pBuf, nRead1 );
+ nRead -= nRead1;
+ }while( nRead );
+}
+
+BOOL SwWW8ImplReader::ReadGrafFile( String& rFileName, Graphic*& rpGraphic,
+ const WW8_PIC& rPic, SvStream* pSt, ULONG nFilePos, BOOL* pbInDoc )
+{ // Grafik in File schreiben
+ ASSERT( WWBUFSIZ >= 512,
+ "Au weia, Puffergroesse < 512, keine Mac-Picts moeglich" );
+
+ *pbInDoc = TRUE; // default
+
+ ULONG nPosFc = nFilePos + rPic.cbHeader;
+
+ switch( rPic.MFP.mm ){
+ case 94: // BMP-File ( nicht embeddet ) oder GIF
+ case 99:
+ { // TIFF-File ( nicht embeddet )
+ pSt->Seek( nPosFc );
+ String aStr( WW8ReadPString( *pSt, eStructCharSet, 0 ) );// Name als P-String einlesen
+ rFileName = aStr.GetChar( 0 ); // Wandeln in SV-String
+ *pbInDoc = FALSE; // Datei anschliessend nicht loeschen
+ return rFileName.Len() != 0; // Einlesen OK
+ }
+ }
+#ifndef USE_WMF_GRAF_FILE
+ // Neu:WMF - Variante ohne File
+ {
+ GDIMetaFile aWMF;
+ pSt->Seek( nPosFc );
+ BOOL bOk = ReadWindowMetafile( *pSt, aWMF );
+ // *pSt >> aWMF; geht nicht ohne placable header
+ if( !bOk || pSt->GetError() || !aWMF.GetActionCount() ){
+// ASSERT( bOk, "ReadWindowMetafile ging schief" );
+// ASSERT( !pSt->GetError(), "WMF einlesen ging schief ( Stream-Error )" );
+// ASSERT( aWMF.GetActionCount(), "WMF einlesen ging schief ( No Meta-Action )" );
+ return FALSE;
+ }
+ if( pWwFib->envr != 1 ){ // !MAC als Creator
+
+ aWMF.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
+ // MetaFile auf neue Groesse skalieren und
+ // neue Groesse am MetaFile setzen
+ Size aOldSiz( aWMF.GetPrefSize() );
+ Size aNewSiz( rPic.MFP.xExt, rPic.MFP.yExt );
+ Fraction aFracX( aNewSiz.Width(), aOldSiz.Width() );
+ Fraction aFracY( aNewSiz.Height(), aOldSiz.Height() );
+
+ aWMF.Scale( aFracX, aFracY );
+ aWMF.SetPrefSize( aNewSiz );
+
+ rpGraphic = new Graphic( aWMF );
+ return TRUE;
+ }
+ // MAC - Word als Creator
+ // im WMF steht nur "Benutzen sie Word 6.0c"
+ // Mac-Pict steht dahinter
+ // allerdings ohne die ersten 512 Bytes,
+ // bei einem MAC-PICT egal sind ( werden nicht ausgewertet )
+
+ long nCopy = rPic.lcb - ( pSt->Tell() - nPosFc );
+ if( nCopy <= 0 || WWBUFSIZ < 512 )
+ return FALSE;
+
+ BYTE* pBuf = new BYTE[WWBUFSIZ];
+ String sExt(WW8_ASCII2STR("pct"));
+ TempFile aTempFile(aEmptyStr, &sExt);
+ aTempFile.EnableKillingFile();
+ {
+ SvFileStream aOut(aTempFile.GetName(), STREAM_READ|STREAM_WRITE|STREAM_TRUNC);
+ memset( pBuf, 0, 512 );
+ aOut.Write( pBuf, 512 ); // Anfang Pict: 512 Byte Muell
+ _CopyFilePiece( &aOut, pSt, nCopy, pBuf, WWBUFSIZ ); // Pict-Inhalt
+ delete( pBuf );
+ }
+
+ GraphicFilter& rGF = *::GetGrfFilter(); // lese ueber Filter ein
+ rpGraphic = new Graphic();
+#if SUPD<591
+ bOk = ( rGF.ImportGraphic( *rpGraphic, DirEntry(aTempFile.GetName()), GRFILTER_FORMAT_DONTKNOW )
+ == 0 );
+#else
+ bOk = ( rGF.ImportGraphic( *rpGraphic, INetURLObject(aTempFile.GetName()), GRFILTER_FORMAT_DONTKNOW )
+ == 0 );
+#endif
+ if( !bOk )
+ DELETEZ( rpGraphic );
+
+ return bOk; // Grafik drin
+ }
+#else // ! USE_WMF_GRAF_FILE
+ // alt: ueber File mit selbstgebasteltem Header
+ ULONG nMaxSize = rPic.lcb - rPic.cbHeader;
+ WmfFileHd aHd; // lies Header
+ ULONG nSiz = ReadWmfHeader( &aHd, nPosFc ); // FileSize in Bytes
+
+ if( nSiz > nMaxSize )
+ return FALSE; // irgendwas ist schiefgegangen
+
+ DirEntry aFN = GetTmpFileName();
+ aFN.SetExtension( String( "wmf" ) );
+ aFN.ToAbs();
+ rFileName = aFN.GetFull();
+
+ SvFileStream aOut( rFileName, STREAM_WRITE );
+
+
+ WriteWmfPreHd( rPic.dxaGoal, rPic.dyaGoal, aOut ); // Placeable WMF-Header
+
+ ULONG nRead = nSiz;
+ UINT16 nRead1;
+ BYTE* pBuf = new BYTE[WWBUFSIZ];
+ pSt->Seek( nPosFc );
+ do{
+ nRead1 = ( nRead > WWBUFSIZ ) ? WWBUFSIZ : (UINT16)nRead;
+ pSt->Read( pBuf, nRead1 );
+ aOut.Write( pBuf, nRead1 );
+ nRead -= nRead1;
+ }while( nRead );
+
+ delete( pBuf );
+
+ return TRUE;
+#endif // ! USE_WMF_GRAF_FILE
+}
+
+struct WW8PicDesc
+{
+ INT16 nCL, nCR, nCT, nCB;
+ long nWidth, nHeight;
+
+ WW8PicDesc( const WW8_PIC& rPic );
+};
+
+WW8PicDesc::WW8PicDesc( const WW8_PIC& rPic )
+{
+ long nOriWidth = (long)rPic.dxaGoal; // Groesse in 1/100 mm ?
+ long nOriHeight = (long)rPic.dyaGoal;
+
+ nCL = rPic.dxaCropLeft;
+ nCR = rPic.dxaCropRight;
+ nCT = rPic.dyaCropTop;
+ nCB = rPic.dyaCropBottom;
+
+ long nAddWidth = nOriWidth + nCL + nCR; // Groesse nach Crop
+ long nAddHeight = nOriHeight + nCT + nCB;
+ if(!nAddWidth )
+ nAddWidth = 1;
+ if(!nAddHeight )
+ nAddHeight = 1;
+
+ nCL = (short)((long)nCL * nOriWidth / nAddWidth );// Crop absolut
+ nCR = (short)((long)nCR * nOriWidth / nAddWidth );// -> skaliert
+ nCT = (short)((long)nCT * nOriWidth / nAddWidth );// auf Original-ImageSize
+ nCB = (short)((long)nCB * nOriWidth / nAddWidth );
+
+ nWidth = nAddWidth * rPic.mx / 1000; // entgueltige Sw-Groesse
+ nHeight = nAddHeight * rPic.my / 1000;
+}
+
+/*
+WW8PicDesc::WW8PicDesc( const WW8_FSPA& rFSPA )
+{
+ //long nOriWidth = (long)rPic.dxaGoal; // Groesse in 1/100 mm ?
+ //long nOriHeight = (long)rPic.dyaGoal;
+
+ nCL = rFSPA.nXaLeft;
+ nCR = rFSPA.nXaRight;
+ nCT = rFSPA.nYaTop;
+ nCB = rFSPA.nYaBottom;
+
+ //long nAddWidth = nOriWidth + nCL + nCR; // Groesse nach Crop
+ //long nAddHeight = nOriHeight + nCT + nCB;
+
+ //nCL = (short)((long)nCL * nOriWidth / nAddWidth );// Crop absolut
+ //nCR = (short)((long)nCR * nOriWidth / nAddWidth );// -> skaliert
+ //nCT = (short)((long)nCT * nOriWidth / nAddWidth );// auf Original-ImageSize
+ //nCB = (short)((long)nCB * nOriWidth / nAddWidth );
+
+ nWidth = nCR - nCL;
+ nHeight = nCB - nCT;
+} */
+
+
+// MakeGrafByFlyFmt setzt eine nicht-Zeichengebundene Grafik
+SwFrmFmt* SwWW8ImplReader::MakeGrafByFlyFmt( SdrTextObj* pReplaceTextObj,
+ const SwFrmFmt& rOldFmt, const WW8PicDesc& rPD,
+ const Graphic* pGraph, const String& rFileName,
+ const String& rGrName, const SfxItemSet& rGrfSet,
+ const BOOL bSetToBackground )
+{
+ SwFrmFmt* pRet = 0;
+ if( pReplaceTextObj )
+ {
+ // SdrGrafObj anstatt des SdrTextObj in dessen Gruppe einsetzen
+ SdrObject* pGroupObject = pReplaceTextObj->GetUpGroup();
+ if( pGroupObject )
+ {
+ SdrObjList* pObjectList = pGroupObject->GetSubList();
+
+ // neues Sdr-Grafik-Objekt erzeugen und konfigurieren
+ SdrGrafObj* pGrafObj = new SdrGrafObj;
+
+ if( pGraph )
+ pGrafObj->SetGraphic( *pGraph );
+
+ if( !pDrawModel ) // 1. GrafikObjekt des Docs
+ GrafikCtor();
+
+ pGrafObj->SetModel( pDrawModel );
+
+ pGrafObj->SetLogicRect( pReplaceTextObj->GetBoundRect() );
+
+ pGrafObj->SetLayer( pReplaceTextObj->GetLayer() );
+
+
+ /*
+ schade: Wir koennen bisher keine SdrGrafObjekte mit Umrandung,
+ Schatten oder Hintergrundfuellung,
+ entsprechende Imports aus dem MS-Office muessen daher
+ auf die UEbernahme dieser Attribute verzichten. :-(
+
+ SfxItemSet aOldSet(pDrawModel->GetItemPool(),
+ // Box
+ XATTR_LINE_FIRST, XATTR_LINE_LAST,
+ // Shadow
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
+ // Fill
+ XATTR_FILL_FIRST, XATTR_FILL_LAST,
+ 0 );
+ pReplaceTextObj->TakeAttributes( aOldSet, FALSE, TRUE );
+ */
+
+
+ if( rFileName.Len() )
+ {
+ ((SdrGrafObj*)pGrafObj)->SetFileName( rFileName );
+ if( !pGraph )
+ pGrafObj->SetGraphicLink( rFileName, aEmptyStr );
+ }
+ // altes Objekt raus aus Gruppen-Liste und neues rein
+ // (dies tauscht es ebenfalls in der Drawing-Page aus)
+ pObjectList->ReplaceObject( pGrafObj, pReplaceTextObj->GetOrdNum() );
+
+
+ /*
+ schade: Wir koennen bisher keine SdrGrafObjekte mit Umrandung,
+ Schatten oder Hintergrundfuellung,
+ entsprechende Imports aus dem MS-Office muessen daher
+ auf die UEbernahme dieser Attribute verzichten. :-(
+
+ // Attribute aus dem alten SdrTextObjekt am SdrGrafObjekt setzen
+ pGrafObj->SetAttributes( aOldSet, FALSE );
+ */
+
+ }
+ else
+ {
+ // Riesenmist !!!
+ ASSERT( !this, "keine Gruppe ? (wieso dann Ersetzen?)" );
+
+ // wir haben derzeit nur Ersetzen vorgesehen, falls es ein Gruppen-Obj. ist !!!
+ }
+ }
+ else
+ {
+ SfxItemSet aFlySet( rOldFmt.GetAttrSet() );
+
+ if( bSetToBackground )
+ aFlySet.Put( SvxOpaqueItem(RES_OPAQUE, FALSE) );
+
+ // Groesse des alten Frames als Grafik-Groesse nehmen
+ aFlySet.Put( SwFmtFrmSize( ATT_FIX_SIZE, rPD.nWidth, rPD.nHeight ) );
+
+ // ggfs. horiz. Positionierungs-Relation korrigieren
+ const SwFmtHoriOrient &rHori = rOldFmt.GetHoriOrient();
+ if( FRAME == rHori.GetRelationOrient() )
+ aFlySet.Put( SwFmtHoriOrient( rHori.GetPos(), HORI_NONE,
+ REL_PG_PRTAREA ) );
+ // und rein damit ins Doc
+ pRet = rDoc.Insert( *pPaM, rFileName, aEmptyStr,
+ pGraph, &aFlySet, &rGrfSet );
+
+ // ggfs. fuer eindeutigen Grafik-Namen sorgen
+ if( rGrName.Len() )
+ {
+ String aName;
+ if(MakeUniqueGraphName(aName, rGrName))
+ pRet->SetName( aName );
+ }
+
+ // bei Einfuegen in existierendes Doc: Frames erzeugen:
+ if( rDoc.GetRootFrm()
+ && (FLY_AT_CNTNT == pRet->GetAnchor().GetAnchorId()) )
+ pRet->MakeFrms();
+ }
+ return pRet;
+}
+
+
+// MakeGrafNotInCntnt setzt eine nicht-Zeichengebundene Grafik
+// ( bGrafApo == TRUE )
+SwFrmFmt* SwWW8ImplReader::MakeGrafNotInCntnt( const WW8PicDesc& rPD,
+ const Graphic* pGraph, const String& rFileName,
+ const String& rGrName, const SfxItemSet& rGrfSet )
+{
+
+ UINT32 nWidth = rPD.nWidth;
+ UINT32 nHeight = rPD.nHeight;
+// nWidth += pSFlyPara->nLeMgn + pSFlyPara->nRiMgn;
+// + pSFlyPara->nLeLMgn + pSFlyPara->nRiLMgn;// bei bGrafApo ???
+// nHeight += pSFlyPara->nUpMgn + pSFlyPara->nLoMgn;
+// + pSFlyPara->nUpLMgn + pSFlyPara->nLoLMgn;// bei bGrafApo ???
+
+ // Vertikale Verschiebung durch Zeilenabstand
+ INT32 nNetHeight = nHeight + rPD.nCT + rPD.nCB;
+ if( pSFlyPara->nLineSpace && pSFlyPara->nLineSpace > nNetHeight )
+ pSFlyPara->nYPos =
+ (USHORT)( pSFlyPara->nYPos + pSFlyPara->nLineSpace - nNetHeight );
+
+ WW8FlySet aFlySet( *this, pWFlyPara, pSFlyPara, TRUE );
+
+ SwFmtAnchor aAnchor( pSFlyPara->eAnchor );
+ aAnchor.SetAnchor( pPaM->GetPoint() );
+ aFlySet.Put( aAnchor );
+
+ aFlySet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) );
+
+ SwFlyFrmFmt* pFlyFmt = rDoc.Insert( *pPaM,
+ rFileName, aEmptyStr, // Name der Grafik !!
+ pGraph,
+ &aFlySet, // Attribute fuer den FlyFrm
+ &rGrfSet ); // Attribute fuer die Grafik
+ if( rGrName.Len() )
+ {
+ String aName;
+ if(MakeUniqueGraphName(aName, rGrName))
+ pFlyFmt->SetName( aName );
+ }
+
+ // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden:
+ if( rDoc.GetRootFrm()
+ && (FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId()) )
+ pFlyFmt->MakeFrms();
+ return pFlyFmt;
+}
+
+
+// MakeGrafInCntnt fuegt zeichengebundene Grafiken ein
+SwFrmFmt* SwWW8ImplReader::MakeGrafInCntnt( const WW8_PIC& rPic, const WW8PicDesc& rPD,
+ const Graphic* pGraph, const String& rFileName,
+ const String& rGrName, const SfxItemSet& rGrfSet )
+{
+ WW8FlySet aFlySet( *this, pPaM, rPic, rPD.nWidth, rPD.nHeight );
+
+ SwFrmFmt* pFlyFmt = 0;
+
+ if( !rFileName.Len() && nObjLocFc ) // dann sollte ists ein OLE-Object
+ pFlyFmt = ImportOle( pGraph, &aFlySet );
+
+
+ if( !pFlyFmt ) // dann eben als Graphic
+ pFlyFmt = rDoc.Insert( *pPaM,
+ rFileName, aEmptyStr, // Name der Grafik !!
+ pGraph,
+ &aFlySet, // Attribute fuer den FlyFrm
+ &rGrfSet ); // Attribute fuer die Grafik
+
+ if( rGrName.Len() )
+ {
+ String aName;
+ if( MakeUniqueGraphName( aName, rGrName ))
+ pFlyFmt->SetName( aName );
+ }
+
+ // Grafik im Rahmen ? ok, Rahmen auf Bildgroesse vergroessern
+ // ( nur wenn Auto-Breite )
+ if( pSFlyPara )
+ pSFlyPara->BoxUpWidth( rPD.nWidth );
+ return pFlyFmt;
+}
+
+SwFrmFmt* SwWW8ImplReader::ImportGraf1( WW8_PIC& rPic, SvStream* pSt,
+ ULONG nFilePos )
+{
+ SwFrmFmt* pRet = 0;
+ if( pSt->IsEof() || rPic.fError || rPic.MFP.mm == 99 )
+ return pRet;
+
+ String aFileName;
+ BOOL bInDoc;
+ Graphic* pGraph = 0;
+ BOOL bOk = ReadGrafFile( aFileName, pGraph, rPic, pSt, nFilePos, &bInDoc );
+
+ if ( !bOk )
+ { delete pGraph;
+ return pRet; // Grafik nicht korrekt eingelesen
+ }
+
+ WW8PicDesc aPD( rPic );
+
+
+ SwAttrSet aGrfSet( rDoc.GetAttrPool(), RES_GRFATR_BEGIN, RES_GRFATR_END-1);
+ if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
+ {
+ SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB) ;
+ aGrfSet.Put( aCrop );
+ }
+
+ if( pWFlyPara && pWFlyPara->bGrafApo )
+ pRet = MakeGrafNotInCntnt( aPD, pGraph, aFileName, aEmptyStr, aGrfSet );
+ else
+ pRet = MakeGrafInCntnt( rPic, aPD, pGraph, aFileName, aEmptyStr, aGrfSet );
+ delete pGraph;
+ return pRet;
+}
+
+
+
+BOOL SwWW8ImplReader::WW8QuickHackForMSDFF_DirectBLIPImport(SvStream& rSt,
+ WW8_PIC& rPic,
+ Graphic& rData,
+ String& rGraphName)
+{
+ BOOL bOk = FALSE;
+ ULONG nFilePos = 0;
+ ULONG nBLIPLen = 0;
+ ULONG nLength;
+ ULONG nSpContainerLen;
+ ULONG nCode;
+ rSt >> nSpContainerLen;
+
+ pMSDffManager->RetrieveNameOfBLIP( rSt,
+ rGraphName,
+ nSpContainerLen );
+ rSt.SeekRel( nSpContainerLen );
+ rSt >> nCode;
+ if(0xF0070000 == (nCode & 0xFFFF0000))
+ {
+ ULONG nLenFBSE;
+ rSt >> nLength;
+
+ const ULONG nSkipBLIPLen = 20; // bis zu nBLIPLen zu ueberspringende Bytes
+ const ULONG nSkipShapePos = 4; // dahinter bis zu nShapePos zu skippen
+ const ULONG nSkipBLIP = 4; // dahinter schliesst dann das BLIP an
+
+ nLenFBSE = nLength;
+
+ // ist FBSE gross genug fuer unsere Daten
+ BOOL bOk2 = ( nSkipBLIPLen + 4 + nSkipShapePos + 4 <= nLenFBSE );
+ if( bOk2 )
+ {
+ rSt.SeekRel( nSkipBLIPLen );
+ rSt >> nBLIPLen;
+ rSt.SeekRel( nSkipShapePos );
+ rSt >> nFilePos; // FilePos des Shape!
+ rSt.SeekRel( nSkipBLIP );
+ bOk2 = (0 == rSt.GetError());
+ nLength -= nSkipBLIPLen+ 4 + nSkipShapePos + 4;
+ if( 0 > nLength )
+ nLength = 0;
+ }
+ if( bOk2 )
+ {
+ // das BLIP Atom steht im Daten Stream unmittelbar hinter dem FBSE
+ //
+ bOk = pMSDffManager->GetBLIPDirect( rSt, rData );
+ }
+ }
+ return bOk;
+}
+
+BOOL SwWW8ImplReader::ImportURL(String &sURL,String &sMark,WW8_CP nStart)
+{
+ BOOL bRet=FALSE;
+ /*
+ * Save the reader state and process the sprms for this anchor cp.
+ * Doing so will set the nPicLocFc to the offset to find the hypertext
+ * data in the data stream.
+ */
+ WW8_CP nEndCp = nStart+1; //Only interested in the single 0x01 character
+
+ WW8ReaderSave aSave(this,nStart);
+
+ WW8PLCFManResult aRes;
+ nStart = pPlcxMan->Where();
+ while(nStart <= nEndCp)
+ {
+ if ( pPlcxMan->Get(&aRes)
+ && aRes.pMemPos && aRes.nSprmId )
+ {
+ //only interested in sprms which would set nPicLocFc
+ if ( (68 == aRes.nSprmId) || (0x6A03 == aRes.nSprmId) )
+ {
+ Read_PicLoc( aRes.nSprmId, aRes.pMemPos+ 1+
+ (8 > pWwFib->nVersion ? 0 : 1) + WW8SprmDataOfs(aRes.nSprmId),
+ 4);
+ break;
+ }
+ }
+ (*pPlcxMan)++;
+ nStart = pPlcxMan->Where();
+ }
+ long nOffset = nPicLocFc;
+ aSave.Restore(this);
+
+ long nOldPos = pDataStream->Tell();
+ WW8_PIC aPic;
+ pDataStream->Seek( nOffset);
+#ifdef __WW8_NEEDS_COPY
+ WW8_PIC_SHADOW aPicS;
+ pDataStream->Read( &aPicS, sizeof( aPicS ) );
+ WW8PicShadowToReal( &aPicS, &aPic );
+#else
+ pDataStream->Read( &aPic, sizeof( aPic ) );
+#endif
+ if((aPic.lcb > 0x44) && !pDataStream->GetError() )
+ {
+#ifdef DEBUG
+ pDataStream->SeekRel( 3 );
+ const BYTE MAGIC_A[16] =
+ {
+ 0xd0, 0xc9, 0xea, 0x79, 0xf9, 0xba, 0xce, 0x11,
+ 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b
+ };
+ BYTE test[16];
+
+ pDataStream->Read( test, 16 );
+ ASSERT(!memcmp(MAGIC_A,test,16),
+ "Found a different MAGIC_A, cause for concern");
+#else
+ pDataStream->SeekRel(19);
+#endif
+ ULONG nLen,nFlags;
+ *pDataStream >> nLen;
+ ASSERT(nLen == 2,"Wrong flag len, cause for concern");
+ *pDataStream >> nFlags;
+ /* all bits zero except for the bottom 4 bits which are...
+ * 0: always set. bottom bit set to denote a link ?
+ * 1: set to denote an absolute link
+ * 2: never set ?
+ * 3: set to denote an anchor
+ */
+
+ const BYTE MAGIC_B[16] =
+ {
+ 0xe0, 0xc9, 0xea, 0x79, 0xf9, 0xba, 0xce, 0x11,
+ 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b
+ };
+ const BYTE MAGIC_C[18] =
+ {
+ 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
+ 0x00, 0x00
+ };
+
+ BYTE testb[16];
+ int nVersion=-1;
+
+ pDataStream->Read( testb, 16 );
+ if (memcmp(MAGIC_B,testb,16) == 0)
+ nVersion=1;
+ else if (memcmp(MAGIC_C,testb,16) == 0)
+ nVersion=2;
+ else
+ {
+ ASSERT(!this,"Found neither MAGIC_B or C, cause for concern");
+ nVersion=-1;
+ }
+
+ switch(nVersion)
+ {
+ case 1:
+ {
+ *pDataStream >> nLen;
+ sURL = WW8Read_xstz( *pDataStream, (USHORT)nLen/2, FALSE );
+ if (nFlags & 0x08)
+ {
+ long pos = pDataStream->Tell();
+ *pDataStream >> nLen;
+ sMark = WW8Read_xstz( *pDataStream, (USHORT)nLen, FALSE );
+ bRet = TRUE;
+ }
+ }
+ break;
+ case 2:
+ {
+ pDataStream->SeekRel(2); // skip over the last two bytes
+ *pDataStream >> nLen;
+ pDataStream->SeekRel(nLen); // skip over the 1st filename
+ pDataStream->SeekRel(24); // skip over MAGIC_D
+
+ *pDataStream >> nLen; //full len
+ *pDataStream >> nLen; //real str len
+ pDataStream->SeekRel(2); // skip over the value 00 03
+ sURL = WW8Read_xstz( *pDataStream, (USHORT)nLen/2, FALSE );
+ if (nFlags & 0x08)
+ {
+ *pDataStream >> nLen;
+ sMark = WW8Read_xstz( *pDataStream, (USHORT)nLen, FALSE );
+ bRet = TRUE;
+ }
+ }
+ break;
+ }
+ }
+ return( bRet );
+}
+
+
+SwFrmFmt* SwWW8ImplReader::ImportGraf( SdrTextObj* pTextObj,
+ SwFrmFmt* pOldFlyFmt,
+ BOOL bSetToBackground )
+{
+ SwFrmFmt* pRet = 0;
+ if( ( ( pStrm == pDataStream ) && !nPicLocFc )
+ || ( nIniFlags & WW8FL_NO_GRAF ) )
+ return pRet;
+
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+ /*
+ kleiner Spass von Microsoft: manchmal existiert ein Stream Namens DATA
+ Dieser enthaelt dann den PICF und die entsprechende Grafik !!!
+ Wir mappen ansonsten die Variable pDataStream auf pStream.
+ */
+
+ long nOldPos = pDataStream->Tell();
+ WW8_PIC aPic;
+ pDataStream->Seek( nPicLocFc );
+#ifdef __WW8_NEEDS_COPY
+ WW8_PIC_SHADOW aPicS;
+ pDataStream->Read( &aPicS, sizeof( aPicS ) );
+ WW8PicShadowToReal( &aPicS, &aPic );
+#else
+ pDataStream->Read( &aPic, sizeof( aPic ) );
+#endif // defined __WW8_NEEDS_COPY
+
+ // Plausibilitaetstest ist noetig, da z.B. bei CheckBoxen im
+ // Feld-Result ein WMF-aehnliches Struct vorkommt.
+ if( (aPic.lcb >= 58)
+ && !pDataStream->GetError() )
+ {
+ if( pFlyFmtOfJustInsertedGraphic )
+ {
+ // Soeben haben wir einen Grafik-Link ins Doc inserted.
+ // Wir muessen ihn jetzt noch Positioniern und Skalieren.
+ //
+ WW8PicDesc aPD( aPic );
+
+ WW8FlySet aFlySet( *this, pPaM, aPic, aPD.nWidth, aPD.nHeight );
+
+ pFlyFmtOfJustInsertedGraphic->SetAttr( aFlySet );
+
+
+ // ACHTUNG: Zuschneiden ist hier noch nicht implementiert!
+
+ // einfach die Crop-Infos bauen und in aFlySet setzen ???
+ /*
+ if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
+ {
+ SwCropGrf aCrop;
+ aCrop.Left() = aPD.nCL;
+ aCrop.Right() = aPD.nCR;
+ aCrop.Top() = aPD.nCT;
+ aCrop.Bottom() = aPD.nCB;
+ pFlyFmtOfJustInsertedGraphic->SetAttr( aCrop ); // ? ? ?
+ }
+ */
+
+
+ pFlyFmtOfJustInsertedGraphic = 0;
+ }
+ else if((0x64 == aPic.MFP.mm) || (0x66 == aPic.MFP.mm))
+ {
+ pDataStream->SeekRel( 2 );
+ // Tja, da haben wir wohl ein MSO Drawing File Format am Bein.
+ //
+ SdrObject* pObject = 0;
+ WW8PicDesc aPD( aPic );
+ String aGrName;
+ if( 0x66 == aPic.MFP.mm ) // verlinkte Grafik im Escher-Objekt
+ { // ================ =============
+ BYTE nNameLen;
+ *pDataStream >> nNameLen;
+ pDataStream->SeekRel( nNameLen );
+
+ Rectangle aRect( 0,0, aPD.nWidth, aPD.nHeight);
+ SvxMSDffImportData aData( aRect );
+ pObject =
+// pMSDffManager->ImportObjAtCurrentStreamPos(*pDataStream,
+// aData );
+ pMSDffManager->ImportObj(*pDataStream, &aData, &aRect);
+ if( pObject )
+ {
+ // fuer den Rahmen
+ SfxItemSet aAttrSet( rDoc.GetAttrPool(),
+ RES_FRMATR_BEGIN,
+ RES_FRMATR_END-1 );
+ // fuer die Grafik
+ SfxItemSet aGrSet( rDoc.GetAttrPool(),
+ RES_GRFATR_BEGIN,
+ RES_GRFATR_END-1 );
+
+ if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
+ {
+ SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB );
+ aGrSet.Put( aCrop );
+ }
+
+ SwFrmFmt* pNewFlyFmt = 0;
+ BOOL bTextObjWasGrouped = FALSE;
+ // Groesse aus der WinWord PIC-Struktur als Grafik-Groesse nehmen
+ aAttrSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aPD.nWidth, aPD.nHeight ) );
+
+ // ggfs. altes AttrSet uebernehmen und
+ // horiz. Positionierungs-Relation korrigieren
+ if( pOldFlyFmt )
+ {
+ aAttrSet.Put( pOldFlyFmt->GetAttrSet() );
+ const SwFmtHoriOrient &rHori = pOldFlyFmt->GetHoriOrient();
+ if( FRAME == rHori.GetRelationOrient() )
+ aAttrSet.Put( SwFmtHoriOrient( rHori.GetPos(),
+ HORI_NONE,
+ REL_PG_PRTAREA ) );
+ }
+
+ XubString aObjectName( pObject->GetName() );
+ if( UINT16( OBJ_OLE2 ) == pObject->GetObjIdentifier() )
+ {
+ SvInPlaceObjectRef xIPRef(
+ ((SdrOle2Obj*)pObject)->GetObjRef() );
+
+ // kein GrafSet uebergeben, da nur fuer Cropp sinnvoll,
+ // was die UI derzeit (27.1.99) noch nicht kann khz.
+ pNewFlyFmt = rDoc.Insert( *pPaM, &xIPRef, &aAttrSet );
+ }
+ else
+ {
+ SdrGrafObj* pGraphObject = 0;
+ pGraphObject = PTR_CAST(SdrGrafObj, pObject);
+ if( pGraphObject )
+ {
+ // Nun den Link bzw. die Grafik ins Doc stopfen
+ const Graphic& rGraph = pGraphObject->GetGraphic();
+ BOOL bDone = FALSE;
+
+ if( pGraphObject->IsLinkedGraphic() )
+ {
+ aGrName = pGraphObject->GetFileName();
+ DirEntry aGrfFileEntry( aGrName );
+ if( aGrfFileEntry.Exists()
+ || (GRAPHIC_NONE == rGraph.GetType()))
+ {
+ if( pOldFlyFmt && pTextObj && pTextObj->GetUpGroup() )
+ {
+ bTextObjWasGrouped = TRUE;
+ /*
+ Hier *nichts* ins Doc inserten!
+ ( lediglich in der DrawPage statt
+ dem Sdr-Text-Objekt einen Grafik-
+ Link einbauen )
+ */
+ pNewFlyFmt= MakeGrafByFlyFmt(
+ pTextObj, *pOldFlyFmt,
+ aPD, 0, aGrName,
+ aEmptyStr, aGrSet,
+ bSetToBackground );
+ }
+ else
+ pNewFlyFmt= rDoc.Insert(*pPaM,
+ aGrName,
+ aEmptyStr,
+ 0, // Graphic*
+ &aAttrSet, // SfxItemSet* Rahmen
+ &aGrSet ); // SfxItemSet* Grafik
+ bDone = TRUE;
+ }
+ }
+
+ if( !bDone )
+ pNewFlyFmt= rDoc.Insert(*pPaM,
+ aEmptyStr,
+ aEmptyStr,
+ &rGraph,
+ &aAttrSet, // SfxItemSet* Rahmen
+ &aGrSet ); // SfxItemSet* Grafik
+
+ }
+ }
+ if( pNewFlyFmt ) // also nur, wenn wir ein *Insert* gemacht haben
+ {
+ pRet = pNewFlyFmt;
+ // mehrfaches Auftreten gleicher Grafik-Namen vermeiden
+ if( aObjectName.Len() )
+ {
+ String aName;
+ if( MakeUniqueGraphName( aName, aObjectName ))
+ pNewFlyFmt->SetName( aName );
+ }
+ // Zeiger auf neues Objekt ermitteln und
+ // Z-Order-Liste entsprechend korrigieren (oder Eintrag loeschen)
+ SdrObject* pOurNewObject = pNewFlyFmt->FindSdrObject();
+ if( !pOurNewObject )
+ {
+ if( !pDrawModel ) // 1. GrafikObjekt des Docs
+ GrafikCtor();
+
+ SwFlyDrawContact* pContactObject
+ = new SwFlyDrawContact( (SwFlyFrmFmt*)pNewFlyFmt,
+ pDrawModel );
+ pOurNewObject = pContactObject->GetMaster();
+ }
+ if( pOurNewObject )
+ {
+ pMSDffManager->ExchangeInShapeOrder( pObject, 0, 0, pOurNewObject );
+ // Das Kontakt-Objekt MUSS in die Draw-Page gesetzt werden,
+ // damit in SwWW8ImplReader::LoadDoc1() die Z-Order
+ // festgelegt werden kann !!!
+ pDrawPg->InsertObject( pOurNewObject );
+
+ // altes SdrGrafObj aus der Page loeschen und zerstoeren
+ pDrawPg->RemoveObject( pObject->GetOrdNum() );
+ delete pObject;
+ }
+ else
+ pMSDffManager->RemoveFromShapeOrder( pObject );
+ }
+ else
+ pMSDffManager->RemoveFromShapeOrder( pObject );
+
+ // auch das ggfs. uebergebene alte Sdr-Text-Objekt aus der Page
+ // loeschen, falls nicht gruppiert,
+ if( pTextObj && !bTextObjWasGrouped )
+ {
+ pDrawPg->RemoveObject( pTextObj->GetOrdNum() );
+ }
+ }
+ }
+ else // eingebettete Grafik im Escher-Objekt
+ { // =================== =============
+ Graphic aGraph;
+ ULONG nCode;
+ *pDataStream >> nCode;
+ if(0xF004000F == nCode)
+ {
+ if( !WW8QuickHackForMSDFF_DirectBLIPImport(
+ *pDataStream, aPic, aGraph, aGrName) )
+ {
+ ASSERT( !this, "Wo ist die Grafik ?" );
+ }
+ else
+ {
+ // Positionieren, Skalieren und Zuschneiden des Pictures
+ //
+ SfxItemSet aGrfSet(rDoc.GetAttrPool(), RES_GRFATR_BEGIN,
+ RES_GRFATR_END-1);
+ if( aPD.nCL || aPD.nCR || aPD.nCT || aPD.nCB )
+ {
+ SwCropGrf aCrop( aPD.nCL, aPD.nCR, aPD.nCT, aPD.nCB );
+ aGrfSet.Put( aCrop );
+ }
+ if( pOldFlyFmt )
+ pRet = MakeGrafByFlyFmt(pTextObj, *pOldFlyFmt, aPD,
+ &aGraph,
+ aEmptyStr,
+ aGrName,
+ aGrfSet, bSetToBackground);
+ else
+ if( pWFlyPara && pWFlyPara->bGrafApo )
+ pRet = MakeGrafNotInCntnt( aPD, &aGraph, aEmptyStr, aGrName, aGrfSet );
+ else
+ pRet = MakeGrafInCntnt( aPic, aPD, &aGraph, aEmptyStr, aGrName, aGrfSet );
+ }
+ }
+ else
+ {
+ // leider verloren...
+ ASSERT( !this, "Wo ist das Shape fuer die Grafik ?" );
+ }
+ }
+ }
+ else if( (aPic.lcb >= 58)
+ && aPic.MFP.xExt
+ && aPic.MFP.yExt )
+ {
+ pRet = ImportGraf1( aPic, pDataStream, nPicLocFc );
+ }
+ }
+ pDataStream->Seek( nOldPos );
+ return pRet;
+}
+
+#ifdef __WW8_NEEDS_COPY
+
+void WW8PicShadowToReal( WW8_PIC_SHADOW * pPicS, WW8_PIC * pPic )
+{
+ pPic->lcb = SVBT32ToLong( pPicS->lcb );
+ pPic->cbHeader = SVBT16ToShort( pPicS->cbHeader );
+ pPic->MFP.mm = SVBT16ToShort( pPicS->MFP.mm );
+ pPic->MFP.xExt = SVBT16ToShort( pPicS->MFP.xExt );
+ pPic->MFP.yExt = SVBT16ToShort( pPicS->MFP.yExt );
+ pPic->MFP.hMF = SVBT16ToShort( pPicS->MFP.hMF );
+ for( USHORT i = 0; i < 14 ; i++ )
+ pPic->rcWinMF[i] = SVBT8ToByte( pPicS->rcWinMF[i] );
+ pPic->dxaGoal = SVBT16ToShort( pPicS->dxaGoal );
+ pPic->dyaGoal = SVBT16ToShort( pPicS->dyaGoal );
+ pPic->mx = SVBT16ToShort( pPicS->mx );
+ pPic->my = SVBT16ToShort( pPicS->my );
+ pPic->dxaCropLeft = SVBT16ToShort( pPicS->dxaCropLeft );
+ pPic->dyaCropTop = SVBT16ToShort( pPicS->dyaCropTop );
+ pPic->dxaCropRight = SVBT16ToShort( pPicS->dxaCropRight );
+ pPic->dyaCropBottom = SVBT16ToShort( pPicS->dyaCropBottom );
+ pPic->brcl = pPicS->aBits1[0] & 0x0f;
+ pPic->fFrameEmpty = (pPicS->aBits1[0] & 0x10) >> 4;
+ pPic->fBitmap = (pPicS->aBits1[0] & 0x20) >> 5;
+ pPic->fDrawHatch = (pPicS->aBits1[0] & 0x40) >> 6;
+ pPic->fError = (pPicS->aBits1[0] & 0x80) >> 7;
+ pPic->bpp = pPicS->aBits2[0];
+ for( USHORT j = 0; j < 4; j++ ){
+ pPic->rgbrc[j].aBits1[0] = pPicS->rgbrc[j].aBits1[0];
+ pPic->rgbrc[j].aBits1[1] = pPicS->rgbrc[j].aBits1[1];
+ }
+ pPic->dxaOrigin = SVBT16ToShort( pPicS->dxaOrigin );
+ pPic->dyaOrigin = SVBT16ToShort( pPicS->dyaOrigin );
+}
+
+void WW8FSPAShadowToReal( WW8_FSPA_SHADOW * pFSPAS, WW8_FSPA * pFSPA )
+{
+ //long nSpId; //Shape Identifier. Used in conjunction with the office art data (found via fcDggInfo in the FIB) to find the actual data for this shape.
+ //long nXaLeft; //left of rectangle enclosing shape relative to the origin of the shape
+ //long nYaTop; //top of rectangle enclosing shape relative to the origin of the shape
+ //long nXaRight; //right of rectangle enclosing shape relative to the origin of the shape
+ //long nYaBottom;//bottom of the rectangle enclosing shape relative to the origin of the shape
+ //USHORT bHdr:1;
+ //USHORT nbx:2;
+ //USHORT nby:2;
+ //USHORT nwr:4;
+ //USHORT nwrk:4;
+ //USHORT bRcaSimple:1;
+ //USHORT bAnchorLock:1;
+ //long nTxbx; //count of textboxes in shape (undo doc only)
+
+
+ pFSPA->nSpId = SVBT32ToLong( pFSPAS->nSpId );
+ pFSPA->nXaLeft = SVBT32ToLong( pFSPAS->nXaLeft );
+ pFSPA->nYaTop = SVBT32ToLong( pFSPAS->nYaTop );
+ pFSPA->nXaRight = SVBT32ToLong( pFSPAS->nXaRight );
+ pFSPA->nYaBottom = SVBT32ToLong( pFSPAS->nYaBottom );
+
+ USHORT nBits = (USHORT)SVBT16ToShort( pFSPAS->aBits1 );
+
+ pFSPA->bHdr = 0 != ( nBits & 0x0001 );
+ pFSPA->nbx = ( nBits & 0x0006 ) >> 1;
+ pFSPA->nby = ( nBits & 0x0018 ) >> 3;
+ pFSPA->nwr = ( nBits & 0x01E0 ) >> 5;
+ pFSPA->nwrk = ( nBits & 0x1E00 ) >> 9;
+ pFSPA->bRcaSimple = 0 != ( nBits & 0x2000 );
+ pFSPA->bBelowText = 0 != ( nBits & 0x4000 );
+ pFSPA->bAnchorLock = 0 != ( nBits & 0x8000 );
+ pFSPA->nTxbx = SVBT32ToLong( pFSPAS->nTxbx );
+}
+#endif // defined __WW8_NEEDS_COPY
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8graf2.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.39 2000/09/18 16:04:59 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.38 2000/09/12 13:19:04 kz
+ add. include tools/fsys.hxx
+
+ Revision 1.37 2000/08/25 12:27:43 jp
+ Graphic Crop-Attribut exported to SVX
+
+ Revision 1.36 2000/08/17 10:24:12 khz
+ #77690# prevent division by zero if Picture Size is zero
+
+ Revision 1.35 2000/06/13 08:24:46 os
+ using UCB
+
+ Revision 1.34 2000/05/25 08:07:01 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.33 2000/05/16 12:12:57 jp
+ ASS_FALSE define removed
+
+ Revision 1.32 2000/05/16 11:14:50 khz
+ Unicode code-conversion
+
+ Revision 1.31 2000/04/04 16:05:17 hr
+ #65293#: WW8PicShadowToReal()
+
+ Revision 1.30 2000/02/21 13:08:19 jp
+ #70473# changes for unicode
+
+ Revision 1.29 2000/02/18 09:35:10 cmc
+ #69372# Improved Hyperlink Importing for WW97
+
+ Revision 1.28 2000/02/11 14:40:08 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.27 1999/11/19 15:02:46 khz
+ Special Task! Use new method to import Shapes: SvxMSDffManager::ImportObj()
+
+ Revision 1.26 1999/08/09 12:16:04 JP
+ read W95 format from stream
+
+
+ Rev 1.25 09 Aug 1999 14:16:04 JP
+ read W95 format from stream
+
+ Rev 1.24 06 Aug 1999 18:06:36 KHZ
+ Task #65322# Changes in WW8FSPAShadowToReal() (#2)
+
+ Rev 1.23 08 Jun 1999 19:05:50 KHZ
+ Task #65322# Changes in WW8FSPAShadowToReal()
+
+ Rev 1.22 02 Jun 1999 09:32:26 KHZ
+ Task #66227# a) kein Unicode bei Ver67 ;-) b) Grafik in grupp. Textbox
+
+ Rev 1.21 26 Apr 1999 17:40:24 KHZ
+ Task #61381# Attribute von Textboxen in denen NUR EINE Grafik steht
+
+ Rev 1.20 18 Feb 1999 20:24:38 KHZ
+ Task #61659# Umlauf im Hintergrund
+
+ Rev 1.19 17 Feb 1999 15:23:42 KHZ
+ Task #61382# jetzt auch Textbox-Grafiken im Hintergrund ( SvxOpaqItem(FALSE) )
+
+ Rev 1.18 12 Feb 1999 16:51:06 KHZ
+ Task #61381# Ersetzen von Sdr-Text-Objekten im Writer durch Rahmen (3)
+
+ Rev 1.17 05 Feb 1999 10:32:46 KHZ
+ Task #61381# in SdrTextObj verankerte Grafiken und OLEs (5)
+
+ Rev 1.16 28 Jan 1999 17:10:48 KHZ
+ Task #60715# in SdrTextObj verankerte Grafiken und OLEs (4)
+
+ Rev 1.15 27 Jan 1999 12:22:40 KHZ
+ Task #60715# in SdrTextObj verankerte Grafiken und OLEs (3)
+
+ Rev 1.14 27 Jan 1999 10:58:02 KHZ
+ Task #60715# in SdrTextObj verankerte Grafiken und OLEs (2)
+
+ Rev 1.13 25 Jan 1999 10:25:46 KHZ
+ Task #60715# in Textobjekt verankerte Grafik als Grafik importieren
+
+ Rev 1.12 30 Nov 1998 17:46:54 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.11 24 Nov 1998 20:46:22 JP
+ Task #59822#: OLE-Objecte einlesen
+
+ Rev 1.10 03 Sep 1998 22:14:22 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.9 05 Aug 1998 17:16:24 KHZ
+ Task #53614# komprimierte WMF, Enh.Metafile und PICT Grafiken
+
+ Rev 1.8 30 Jul 1998 20:52:38 KHZ
+ Task #52607# GPF unter Unix behoben
+
+ Rev 1.7 30 Jul 1998 14:31:34 KHZ
+ Task #52607# Grafikimport ueber Quick-Hack auch fuer WMF
+
+ Rev 1.6 30 Jul 1998 00:03:10 KHZ
+ Task #53614# Grafiken, die NICHT ueber dem Text liegen (MSDFF-Quick-Hack)
+
+ Rev 1.5 22 Jul 1998 16:16:04 HR
+ ww8graf fuer UNX
+
+ Rev 1.4 21 Jul 1998 14:52:10 KHZ
+ Task #52607# (WW 97 Import)
+
+ Rev 1.3 21 Jul 1998 12:33:46 KHZ
+ als MSDrawingObject eingebettete Grafik (Teil 1)
+
+ Rev 1.2 13 Jul 1998 15:29:16 KHZ
+ Task #52607# embeded Grafiken (NICHT UEBER den Text gelegte)
+
+ Rev 1.1 30 Jun 1998 21:33:18 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.0 16 Jun 1998 11:06:48 KHZ
+ Initial revision.
+
+*************************************************************************/
+
+
+
+
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
new file mode 100644
index 000000000000..988c30ee44c5
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -0,0 +1,2996 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#define _SVSTDARR_STRINGSDTOR
+
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+#ifndef _SFXDOCINF_HXX //autogen
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _SVX_TSTPITEM_HXX //autogen
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_CSCOITEM_HXX //autogen
+#include <svx/cscoitem.hxx>
+#endif
+
+#ifndef _SVX_SVDOBJ_HXX
+#include <svx/svdobj.hxx>
+#endif
+#ifndef _SVDPAGE_HXX //autogen
+#include <svx/svdpage.hxx>
+#endif
+
+#ifndef _SVX_PAPERINF_HXX //autogen
+#include <svx/paperinf.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX
+#include <svx/lrspitem.hxx> // SvxLRSpaceItem
+#endif
+#ifndef _MSDFFIMP_HXX
+#include <svx/msdffimp.hxx>
+#endif
+
+#ifndef _SVX_LANGITEM_HXX //autogen
+#include <svx/langitem.hxx>
+#endif
+
+#ifndef _SVXMSBAS_HXX
+#include <svx/svxmsbas.hxx>
+#endif
+
+#ifdef DEBUG
+# ifndef _SOUND_HXX //autogen
+# include <vcl/sound.hxx>
+# endif
+#endif
+
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+#ifndef _OFA_FLTRCFG_HXX
+#include <offmgr/fltrcfg.hxx>
+#endif
+#ifndef _OFF_APP_HXX //autogen
+#include <offmgr/app.hxx>
+#endif
+
+#ifndef _FMTFTN_HXX //autogen
+#include <fmtftn.hxx>
+#endif
+#ifndef _FMTFLD_HXX
+#include <fmtfld.hxx>
+#endif
+#ifndef _BOOKMRK_HXX
+#include <bookmrk.hxx>
+#endif
+#ifndef _FTNIDX_HXX
+#include <ftnidx.hxx>
+#endif
+#ifndef _REFFLD_HXX
+#include <reffld.hxx>
+#endif
+#ifndef _TXTFTN_HXX //autogen
+#include <txtftn.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FMTCNCT_HXX
+#include <fmtcnct.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+#ifndef _FTNINFO_HXX //autogen
+#include <ftninfo.hxx>
+#endif
+#ifndef _WW8PAR2_HXX
+#include <ww8par2.hxx> // class WW8RStyle, class WW8AnchorPara
+#endif
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx> // fuer SwPam
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx> // class SwTxtNode
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx> // class SwPageDesc
+#endif
+#ifndef _NUMRULE_HXX //autogen
+#include <numrule.hxx>
+#endif
+#ifndef _PARATR_HXX //autogen
+#include <paratr.hxx>
+#endif
+#ifndef _FMTCOL_HXX
+#include <fmtcol.hxx> // ReadFilterFlags
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx>
+#endif
+#ifndef _FMTCLBL_HXX
+#include <fmtclbl.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx> // ReadFilterFlags
+#endif
+#ifndef _SWDOCSH_HXX //autogen
+#include <docsh.hxx>
+#endif
+#ifndef _DOCUFLD_HXX //autogen
+#include <docufld.hxx>
+#endif
+
+#ifdef DEBUG
+#ifndef _DOCARY_HXX //autogen
+#include <docary.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+
+#endif
+
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // Progress
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h> // ERR_WW8_...
+#endif
+
+
+//-----------------------------------------
+// diverses
+//-----------------------------------------
+
+
+#define MM_250 1417 // WW-Default fuer Hor. Seitenraender: 2.5 cm
+#define MM_200 1134 // WW-Default fuer u.Seitenrand: 2.0 cm
+
+
+
+
+
+SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr )
+ : SvxMSDffManager( *rRdr.pTableStream,
+ rRdr.pWwFib->fcDggInfo,
+ rRdr.pDataStream, 0, 0,
+ COL_WHITE, 12 /* in Point */,
+ rRdr.pStrm ),
+ rReader( rRdr )
+{
+ const OfaFilterOptions* pOpt = OFF_APP()->GetFilterOptions();
+#if SUPD>593
+ nSvxMSDffOLEConvFlags = GetFilterFlags();
+#endif
+}
+
+UINT32 SwMSDffManager::GetFilterFlags()
+{
+#if SUPD>593
+ UINT32 nFlags;
+ const OfaFilterOptions* pOpt = OFF_APP()->GetFilterOptions();
+ if( pOpt->IsMathType2StarMath() )
+ nFlags |= OLE_MATHTYPE_2_STARMATH;
+ if( pOpt->IsWinWord2StarWriter() )
+ nFlags |= OLE_WINWORD_2_STARWRITER;
+ if( pOpt->IsExcel2StarCalc() )
+ nFlags |= OLE_EXCEL_2_STARCALC;
+ if( pOpt->IsPowerPoint2StarImpress() )
+ nFlags |= OLE_POWERPOINT_2_STARIMPRESS;
+ return nFlags;
+#endif
+}
+/***************************************************************************
+# Spezial FastSave - Attribute
+#**************************************************************************/
+
+#if 0
+typedef BYTE Bit256[32];
+
+inline BOOL GetBit( Bit256& rBits, BYTE nBitNo )
+{
+ return ( rBits[nBitNo >> 3] >> ( nBitNo & 0x7 ) ) & 0x1;
+}
+
+inline void SetBit( Bit256& rBits, BYTE nBitNo, BOOL bInp )
+{
+ if( bInp )
+ rBits[nBitNo >> 3] |= 1 << ( nBitNo & 0x7 );
+ else
+ rBits[nBitNo >> 3] &= ~( 1 << ( nBitNo & 0x7 ) );
+}
+#endif
+
+void SwWW8ImplReader::Read_StyleCode( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 )
+ {
+ bCpxStyle = FALSE;
+ return;
+ }
+ INT16 nColl = SVBT16ToShort( pData );
+ if( (USHORT)nColl < nColls )
+ {
+ SetTxtFmtCollAndListLevel( *pPaM, pCollA[ nColl ] );
+ bCpxStyle = TRUE;
+ }
+}
+
+// Read_Majority ist fuer Majority ( 103 ) und Majority50 ( 108 )
+void SwWW8ImplReader::Read_Majority( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){
+ return;
+ }
+}
+
+//-----------------------------------------
+// temp. Test
+//-----------------------------------------
+
+long SwWW8ImplReader::Read_Piece( WW8PLCFManResult* pRes, BOOL bStartAttr )
+{
+ if( !bStartAttr )
+ return 0;
+// pStrm->Seek( WW8Cp2Fc( pRes->nCp2OrIdx, 0 ) ); // nAktCp //!!!Mogel
+ return 0;
+}
+
+
+
+//-----------------------------------------
+// Stack
+//-----------------------------------------
+BOOL SwWW8FltControlStack::IsFtnEdnBkmField(SwFmtFld& rFmtFld, USHORT& nBkmNo)
+{
+ const SwField* pFld = rFmtFld.GetFld();
+ USHORT nSubType;
+ return( pFld
+ && (RES_GETREFFLD == pFld->Which())
+ && ( (REF_FOOTNOTE == (nSubType = pFld->GetSubType()))
+ || (REF_ENDNOTE == nSubType))
+ && ((SwGetRefField*)pFld)->GetSetRefName().Len()
+ // find Sequence No of corresponding Foot-/Endnote
+ && (USHRT_MAX != (nBkmNo = pDoc->FindBookmark(
+ ((SwGetRefField*)pFld)->GetSetRefName() ))));
+}
+
+void SwWW8FltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr)
+{
+ USHORT nBkmNo;
+ if( (RES_TXTATR_FIELD == rAttr.Which())
+ && IsFtnEdnBkmField((SwFmtFld&)rAttr, nBkmNo) )
+ {
+ SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone());
+ Insert(pTmp, Count());
+ }
+ else
+ SwFltControlStack::NewAttr(rPos, rAttr);
+}
+
+void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry)
+{
+ switch( pEntry->pAttr->Which() )
+ {
+ case RES_LR_SPACE:
+ {
+ SwPaM aRegion( rTmpPos );
+ if (pEntry->MakeRegion(pDoc, aRegion, FALSE))
+ {
+ SvxLRSpaceItem aLR( *(SvxLRSpaceItem*)pEntry->pAttr );
+ BOOL bChange1stLine = 1 == aLR.GetTxtFirstLineOfst();
+ ULONG nStart = aRegion.Start()->nNode.GetIndex();
+ ULONG nEnd = aRegion.End()->nNode.GetIndex();
+ const SwNumRule* pRule;
+ const SwNodeNum* pNum;
+ for(; nStart <= nEnd; ++nStart)
+ {
+ SwNode* pNode = pDoc->GetNodes()[ nStart ];
+ if( pNode->IsTxtNode() )
+ {
+ if( bChange1stLine )
+ {
+ if( 0 != (pNum = ((SwTxtNode*)pNode)->GetNum() )
+ && (MAXLEVEL > pNum->GetLevel())
+ && 0 != (pRule = ((SwTxtNode*)pNode)->GetNumRule() ) )
+ {
+ const SwNumFmt rNumFmt = pRule->Get( pNum->GetLevel() );
+ aLR.SetTxtFirstLineOfst( rNumFmt.GetFirstLineOffset() );
+ }
+ else
+ aLR.SetTxtFirstLineOfst( 0 );
+ }
+ ((SwCntntNode*)pNode)->SetAttr( aLR );
+
+ // wenn wir dies nicht tun, ueberschreibt die NumRule uns alle
+ // harten L-Randeinstellungen
+ pNode->SetNumLSpace( FALSE );
+ }
+ }
+ }
+ }
+ break;
+ case RES_TXTATR_FIELD:
+ {
+ SwFmtFld& rFmtFld = *(SwFmtFld*)pEntry->pAttr;
+ const SwField* pFld = rFmtFld.GetFld();
+ USHORT nBkmNo;
+ if( IsFtnEdnBkmField(rFmtFld, nBkmNo) )
+ {
+ SwBookmark& rBkMrk = pDoc->GetBookmark( nBkmNo );
+
+ const SwPosition& rBkMrkPos = rBkMrk.GetPos();
+
+ SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode();
+ if( pTxt && rBkMrkPos.nContent.GetIndex() )
+ {
+ SwTxtAttr* pFtn = pTxt->GetTxtAttr( rBkMrkPos.nContent.GetIndex()-1,
+ RES_TXTATR_FTN );
+ if( pFtn )
+ {
+ USHORT nRefNo = ((SwTxtFtn*)pFtn)->GetSeqRefNo();
+
+ ((SwGetRefField*)pFld)->SetSeqNo( nRefNo );
+
+ if( pFtn->GetFtn().IsEndNote() )
+ ((SwGetRefField*)pFld)->SetSubType( REF_ENDNOTE );
+ }
+ }
+ /*
+ const SwStartNode* pSearchNode =
+ rBkMrkPos.nNode.GetNode().FindFootnoteStartNode();
+
+ if( pSearchNode )
+ {
+ const SwFtnIdxs& rFtnIdxs = pDoc->GetFtnIdxs();
+
+ const USHORT nFtnCnt = rFtnIdxs.Count();
+
+ for(USHORT n = 0; n < nFtnCnt; ++n )
+ {
+ SwTxtFtn* pFtn = rFtnIdxs[ n ];
+ const SwNodeIndex* pSttIdx =
+ ((SwTxtFtn*)pFtn)->GetStartNode();
+ if( pSttIdx &&
+ (pSearchNode ==
+ pSttIdx->GetNode().GetStartNode()) )
+ {
+ USHORT nRefNo = pFtn->SetSeqRefNo();
+
+ ((SwGetRefField*)pFld)->SetSeqNo( nRefNo );
+
+ }
+ }
+ }
+ */
+ }
+ SwNodeIndex aIdx( pEntry->nMkNode, +1 );
+ SwPaM aPaM( aIdx, pEntry->nMkCntnt );
+ pDoc->Insert(aPaM, *pEntry->pAttr);
+ }
+ break;
+ default: SwFltControlStack::SetAttrInDoc(rTmpPos, pEntry);
+ }
+}
+
+
+
+//-----------------------------------------
+// Tabs
+//-----------------------------------------
+#define DEF_TAB_ANZ 13 // So viele Default-Tabs
+
+#if 0 // Nach MA 5.8.96 nicht mehr noetig
+void SwWW8ImplReader::SetImplicitTab()
+{
+ SvxTabStopItem aTabs( *(SvxTabStopItem*)GetFmtAttr( RES_PARATR_TABSTOP ));
+ aTabs.Insert( SvxTabStop( 0, SVX_TAB_ADJUST_DEFAULT ) );
+ NewAttr( aTabs );
+}
+#endif
+
+void SwWW8ImplReader::Read_Tab( USHORT nId, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_TABSTOP );
+ return;
+ }
+
+ // Para L-Space
+ short nLeftPMgn = ( pAktColl ) ? pCollA[nAktColl].nLeftParaMgn
+ : nLeftParaMgn;
+
+ // Para L-Space OR Left Margin of Para's first line respectively
+ short nLeftMostPos = ( pAktColl ) ? pCollA[nAktColl].nTxtFirstLineOfst
+ : nTxtFirstLineOfst;
+ if( 0 < nLeftMostPos )
+ nLeftMostPos = 0;
+
+ short i;
+ BYTE* pDel = pData + 1; // Del - Array
+ BYTE nDel = pData[0];
+ BYTE* pIns = pData + 2*nDel + 2; // Ins - Array
+ BYTE nIns = pData[nDel*2+1];
+ WW8_TBD* pTyp = (WW8_TBD*)(pData + 2*nDel + 2*nIns + 2);// Typ - Array
+
+ SvxTabStopItem aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT );
+
+ SwTxtFmtColl* pSty = 0;
+ USHORT nTabBase;
+ if( pAktColl ){ // StyleDef
+ nTabBase = pCollA[nAktColl].nBase;
+ if( nTabBase < nColls ){ // Based On
+ pSty = (SwTxtFmtColl*)pCollA[nTabBase].pFmt;
+ }
+ }else{ // Text
+ nTabBase = nAktColl;
+ pSty = (SwTxtFmtColl*)pCollA[nAktColl].pFmt;
+ }
+
+ BOOL bFound = FALSE;
+ while( pSty && !bFound ){
+ const SfxPoolItem* pTabs;
+ bFound = pSty->GetAttrSet().GetItemState( RES_PARATR_TABSTOP, FALSE, &pTabs )
+ == SFX_ITEM_SET;
+ if( bFound ){
+ aAttr = *((const SvxTabStopItem*)pTabs);
+ }else{
+ if( nTabBase < nColls // Based On
+ && (nTabBase = pCollA[nTabBase].nBase) < nColls ) // Based On
+ pSty = (SwTxtFmtColl*)pCollA[nTabBase].pFmt;
+ else
+ pSty = 0; // gib die Suche auf
+ }
+ }
+
+ SvxTabStop aTabStop;
+
+ for( i=0; i<nDel; i++ ){
+ USHORT nPos = aAttr.GetPos( SVBT16ToShort( pDel + i*2 ) - nLeftPMgn );
+ if( nPos != SVX_TAB_NOTFOUND )
+ aAttr.Remove( nPos, 1 );
+ }
+ for( i=0; i<nIns; i++ )
+ {
+ short nPos = SVBT16ToShort( pIns + i*2 ) - nLeftPMgn;
+ if( nPos < nLeftMostPos )
+ continue;
+ aTabStop.GetTabPos() = nPos;
+ switch( SVBT8ToByte( pTyp[i].aBits1 ) & 0x7 ){ // pTyp[i].jc
+ case 0: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break;
+ case 1: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; break;
+ case 2: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; break;
+ case 3: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL; break;
+ case 4: continue; // ignoriere Bar
+ }
+
+ switch( SVBT8ToByte( pTyp[i].aBits1 ) >> 3 & 0x7 ){ // pTyp[i].tlc
+ case 0: aTabStop.GetFill() = ' '; break;
+ case 1: aTabStop.GetFill() = '.'; break;
+ case 2: aTabStop.GetFill() = '-'; break;
+ case 3:
+ case 4: aTabStop.GetFill() = '_'; break;
+ }
+
+ USHORT nPos2 = aAttr.GetPos( nPos );
+ if( nPos2 != SVX_TAB_NOTFOUND )
+ aAttr.Remove( nPos2, 1 ); // sonst weigert sich das Insert()
+
+ aAttr.Insert( aTabStop );
+ }
+ NewAttr( aAttr );
+}
+
+//-----------------------------------------
+// DOP
+//-----------------------------------------
+
+void SwWW8ImplReader::ImportDop( BOOL bNewDoc )
+{
+ if( bNewDoc )
+ {
+ // correct the LastPrinted date in DocumentInfo
+ if( rDoc.GetpInfo() )
+ {
+ DateTime aLastPrinted( WW8ScannerBase::WW8DTTM2DateTime( pWDop->dttmLastPrint ));
+ SfxDocumentInfo* pNeuDocInf = new SfxDocumentInfo( *rDoc.GetpInfo() );
+ SfxStamp aPrinted( pNeuDocInf->GetPrinted() );
+ if( aPrinted.GetTime() != aLastPrinted)
+ {
+ // check if WW8 date was set
+ if( aLastPrinted == DateTime(Date( 0 ), Time( 0 )))
+ // create "invalid" value for SfxStamp
+ // (as seen in sfx2/DOSINF.HXX)
+ aPrinted.SetTime(DateTime(Date( 1, 1, 1601 ), Time( 0, 0, 0 )));
+ else
+ aPrinted.SetTime( aLastPrinted );
+ pNeuDocInf->SetPrinted( aPrinted );
+ rDoc.SetInfo( *pNeuDocInf );
+ delete( pNeuDocInf );
+ }
+ }
+
+ // Import Default-Tabs
+ long nDefTabSiz = pWDop->dxaTab;
+ if( nDefTabSiz < 56 )
+ nDefTabSiz = 709;
+
+ // wir wollen genau einen DefaultTab
+ SvxTabStopItem aNewTab( 1, USHORT(nDefTabSiz), SVX_TAB_ADJUST_DEFAULT );
+ ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
+
+ rDoc.GetAttrPool().SetPoolDefaultItem( aNewTab );
+
+ // set default language (from FIB)
+ rDoc.GetAttrPool().SetPoolDefaultItem(
+ SvxLanguageItem( (const LanguageType)pWwFib->lid ) );
+ }
+}
+
+
+
+//-----------------------------------------
+// Fuss- und Endnoten
+//-----------------------------------------
+
+WW8ReaderSave::WW8ReaderSave( SwWW8ImplReader* pRdr ,WW8_CP nStartCp)
+: aTmpPos(*pRdr->pPaM->GetPoint())
+{
+ pWFlyPara = pRdr->pWFlyPara;
+ pSFlyPara = pRdr->pSFlyPara;
+ pTableDesc = pRdr->pTableDesc;
+ cSymbol = pRdr->cSymbol;
+ bSymbol = pRdr->bSymbol;
+ bIgnoreText = pRdr->bIgnoreText;
+ bDontCreateSep = pRdr->bDontCreateSep;
+ bHdFtFtnEdn = pRdr->bHdFtFtnEdn;
+ bApo = pRdr->bApo;
+ bTxbxFlySection = pRdr->bTxbxFlySection;
+ bTable = pRdr->bTable ;
+ bTableInApo = pRdr->bTableInApo;
+ bAnl = pRdr->bAnl;
+ nAktColl = pRdr->nAktColl;
+
+ // Tracking beginnt neu
+ pRdr->bHdFtFtnEdn = TRUE;
+ pRdr->bApo = pRdr->bTxbxFlySection
+ = pRdr->bTable = bTableInApo = pRdr->bAnl = FALSE;
+ pRdr->pWFlyPara = 0;
+ pRdr->pSFlyPara = 0;
+ pRdr->pTableDesc = 0;
+
+ // schliesse Attribute auf dem End-Stack
+ pRdr->pEndStck->SetAttr( *pRdr->pPaM->GetPoint(), 0, FALSE );
+
+ pOldStck = pRdr->pCtrlStck;
+ pRdr->pCtrlStck = new SwWW8FltControlStack(&pRdr->rDoc, pRdr->nFieldFlags);
+
+ // rette die Attributverwaltung: dies ist noetig, da der neu anzulegende
+ // PLCFx Manager natuerlich auf die gleichen FKPs zugreift, wie der alte
+ // und deren Start-End-Positionen veraendert...
+ pRdr->pPlcxMan->SaveAllPLCFx( aPLCFxSave );
+
+ pOldPlcxMan = pRdr->pPlcxMan;
+
+ if (nStartCp != -1)
+ pRdr->pPlcxMan = new WW8PLCFMan( pRdr->pSBase,
+ pOldPlcxMan->GetManType(), nStartCp );
+}
+
+void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
+{
+ pRdr->pWFlyPara = pWFlyPara;
+ pRdr->pSFlyPara = pSFlyPara;
+ pRdr->pTableDesc = pTableDesc;
+ pRdr->cSymbol = cSymbol;
+ pRdr->bSymbol = bSymbol;
+ pRdr->bIgnoreText = bIgnoreText;
+ pRdr->bDontCreateSep= bDontCreateSep;
+ pRdr->bHdFtFtnEdn = bHdFtFtnEdn;
+ pRdr->bApo = bApo;
+ pRdr->bTxbxFlySection=bTxbxFlySection;
+ pRdr->bTable = bTable ;
+ pRdr->bTableInApo = bTableInApo;
+ pRdr->bAnl = bAnl;
+ pRdr->nAktColl = nAktColl;
+
+ // schliesse alle Attribute, da sonst Attribute
+ // entstehen koennen, die aus dem Fly rausragen
+ pRdr->pCtrlStck->SetAttr( *pRdr->pPaM->GetPoint(), 0, FALSE );
+ pRdr->pEndStck->SetAttr( *pRdr->pPaM->GetPoint(), 0, FALSE );
+
+ pRdr->DeleteCtrlStk();
+ pRdr->pCtrlStck = pOldStck;
+
+ *pRdr->pPaM->GetPoint() = aTmpPos;
+
+ DELETEZ( pRdr->pPlcxMan );
+
+ // restauriere die Attributverwaltung
+ pRdr->pPlcxMan = pOldPlcxMan;
+ pRdr->pPlcxMan->RestoreAllPLCFx( aPLCFxSave );
+}
+
+void SwWW8ImplReader::Read_HdFtFtnText( const SwNodeIndex* pSttIdx, long nStartCp,
+ long nLen, short nType )
+{
+#if 0
+ pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ SwWW8FltControlStack* pOldStck = pCtrlStck;
+ pCtrlStck = new SwWW8FltControlStack( &rDoc, nFieldFlags );
+#endif
+ WW8ReaderSave aSave( this ); // rettet Flags u.ae. u. setzt sie zurueck
+
+ pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1; //
+ pPaM->GetPoint()->nContent.Assign( pPaM->GetCntntNode(), 0 );
+
+ // dann Text fuer Header, Footer o. Footnote einlesen
+
+ ReadText( nStartCp, nLen, nType ); // Sepx dabei ignorieren
+#if 0
+ pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ // und zum Schluss Writer-Kram restoren
+ aSave.Restore( this );
+ DeleteCtrlStk();
+ pCtrlStck = pOldStck;
+#else
+ aSave.Restore( this );
+#endif
+}
+
+long SwWW8ImplReader::Read_Ftn( WW8PLCFManResult* pRes, BOOL )
+{
+ BOOL bFtEdOk = FALSE;
+
+ if( nIniFlags & WW8FL_NO_FTN )
+ return 0;
+
+ if ( pPaM->GetPoint()->nNode < rDoc.GetNodes().GetEndOfExtras().GetIndex() )
+ return 0; // ignoriere Footnote ausserhalb des normalen Textes
+
+ USHORT nType;
+ BOOL bAutoNum = TRUE;
+ if( 257 == pRes->nSprmId )
+ {
+ nType = MAN_EDN;
+ if( pPlcxMan->GetEdn() )
+ bAutoNum = 0 != *(short*)pPlcxMan->GetEdn()->GetData();
+ }
+ else
+ {
+ nType = MAN_FTN;
+ if( pPlcxMan->GetFtn() )
+ bAutoNum = 0 != *(short*)pPlcxMan->GetFtn()->GetData();
+ }
+
+ WW8PLCFxSaveAll aSave;
+ pPlcxMan->SaveAllPLCFx( aSave );
+ WW8PLCFMan* pOldPlcxMan = pPlcxMan;
+
+ SwFmtFtn aFtn( 257 == pRes->nSprmId ) ; // erzeuge Fussnote
+ rDoc.Insert( *pPaM, aFtn );
+
+ SwPosition aTmpPos( *pPaM->GetPoint() ); // merke alte Cursorposition
+
+ pPaM->Move( fnMoveBackward, fnGoCntnt ); // hole Index auf Fussnoteninhalt
+ SwTxtNode* pTxt = pPaM->GetNode()->GetTxtNode();
+ SwTxtAttr* pFN = pTxt->GetTxtAttr( pPaM->GetPoint()->nContent.GetIndex(),
+ RES_TXTATR_FTN );
+ ASSERT(pFN, "Probleme beim Anlegen des Fussnoten-Textes");
+ if( pFN )
+ {
+ const SwNodeIndex* pSttIdx = ((SwTxtFtn*)pFN)->GetStartNode();
+ ASSERT(pSttIdx, "Probleme beim Anlegen des Fussnoten-Textes");
+
+ ((SwTxtFtn*)pFN)->SetSeqNo( rDoc.GetFtnIdxs().Count() );
+
+ BOOL bOld = bFtnEdn;
+ bFtnEdn = TRUE;
+
+ // read content of Ft-/End-Note
+ Read_HdFtFtnText( pSttIdx, pRes->nCp2OrIdx, pRes->nMemLen, nType );
+ bFtEdOk = TRUE;
+ bFtnEdn = bOld;
+
+ // falls keine automatische Numerierung eingestellt ist, so hole
+ // das 1. Zeichen aus der Fuss-/End-Note und setze das als Zeichen
+ if( !bAutoNum )
+ {
+ SwNodeIndex& rNIdx = pPaM->GetPoint()->nNode;
+ rNIdx = pSttIdx->GetIndex() + 1;
+ SwTxtNode* pTNd = rNIdx.GetNode().GetTxtNode();
+ if( pTNd )
+ {
+ String sNo( pTNd->GetTxt().GetChar( 0 ));
+ ((SwTxtFtn*)pFN)->SetNumber( 0, &sNo );
+ pPaM->GetPoint()->nContent.Assign( pTNd, 0 );
+ pPaM->SetMark();
+ pPaM->GetMark()->nContent++;
+ rDoc.Delete( *pPaM );
+ pPaM->DeleteMark();
+ }
+ }
+ }
+ *pPaM->GetPoint() = aTmpPos; // restore Cursor
+
+ pPlcxMan = pOldPlcxMan; // Attributverwaltung restoren
+ pPlcxMan->RestoreAllPLCFx( aSave );
+
+ if( bSymbol )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
+ bSymbol = FALSE;
+ }
+
+ // insert Section to get this Ft-/End-Note at the end of the section,
+ // when there is no open section at the moment
+ if( bFtEdOk && pLastPgDeskIdx && !pBehindSection )
+ {
+ const SwNodeIndex aOrgLastPgDeskIdx( *pLastPgDeskIdx );
+
+ (*pLastPgDeskIdx)++;
+ SwPosition aSectStart( *pLastPgDeskIdx );
+ aSectStart.nContent.Assign( pLastPgDeskIdx->GetNode().GetCntntNode(), 0 );
+
+ SwPaM aSectPaM( aSectStart, *pPaM->GetPoint() );
+ InsertSectionWithWithoutCols( aSectPaM, 0 );
+ pPaM->Move( fnMoveBackward );
+ DELETEZ( pLastPgDeskIdx );
+ // set attributes to correct position
+ pCtrlStck->MoveAttrsToNextNode( aOrgLastPgDeskIdx );
+ }
+
+ return 1; // das Fussnotenzeichen ueberlesen!
+}
+
+// JP 03.12.98 - Anmerkungen einlesen
+// - Als default wird erstmal das Initial als Author benutzt. Im Writer wird
+// auch immer das Initial benutzt!
+#undef AUTHOR_AS_AUTHOR
+#define INITIAL_AS_AUTHOR
+
+long SwWW8ImplReader::Read_And( WW8PLCFManResult* pRes, BOOL )
+{
+ WW8PLCFx_SubDoc* pSD = pPlcxMan->GetAtn();
+ if( !pSD )
+ return 0;
+
+ String sAuthor;
+ if( bVer67 )
+ {
+ const WW67_ATRD* pDescri = (WW67_ATRD*)pSD->GetData();
+#ifdef AUTHOR_AS_AUTHOR
+ const String* pA = GetAnnotationAuthor( SVBT16ToShort( pDescri->ibst ) );
+ if( pA )
+ sAuthor = *pA;
+#endif
+
+#ifdef INITIAL_AS_AUTHOR
+ sAuthor = String( pDescri->xstUsrInitl + 1,
+ (USHORT)pDescri->xstUsrInitl[0] );
+#endif
+ }
+ else
+ {
+ const WW8_ATRD* pDescri = (const WW8_ATRD*)pSD->GetData();
+
+#ifdef AUTHOR_AS_AUTHOR
+ const String* pA = GetAnnotationAuthor( SVBT16ToShort( pDescri->ibst ) );
+ if( pA )
+ sAuthor = *pA;
+#endif
+
+#ifdef INITIAL_AS_AUTHOR
+ BYTE nLen = (BYTE)SVBT16ToShort( pDescri->xstUsrInitl[0] );
+ String aTmp;
+ sal_Unicode* pData = aTmp.AllocBuffer( nLen );
+ sal_Unicode* pWork = pData;
+
+ for( BYTE nIdx = 1; nIdx <= nLen; ++nIdx, ++pWork )
+ *pWork = SVBT16ToShort( pDescri->xstUsrInitl[ nIdx ] );
+// {
+// UINT16 nChar = SVBT16ToShort( pDescri->xstUsrInitl[ nIdx ] );
+// if( 0xF000 == (nChar & 0xFF00))
+// nChar &= 0x00FF;
+// *pWStr = nChar;
+// }
+// sAuthor = String( aTmp, CHARSET_ANSI ); // ANSI???
+
+// 2000/03/30 KHZ UNICODE
+// still missing: unicode-back conversion AND 0xF0.. specials
+
+#endif
+ }
+
+ WW8PLCFxSaveAll aSave;
+ pPlcxMan->SaveAllPLCFx( aSave );
+ WW8PLCFMan* pOldPlcxMan = pPlcxMan;
+
+ SwNodeIndex aNdIdx( rDoc.GetNodes().GetEndOfExtras() );
+ aNdIdx = *rDoc.GetNodes().MakeTextSection( aNdIdx, SwNormalStartNode,
+ rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
+
+ SwPosition aTmpPos( *pPaM->GetPoint() ); // merke alte Cursorposition
+ Read_HdFtFtnText( &aNdIdx, pRes->nCp2OrIdx, pRes->nMemLen, MAN_AND );
+ // lese Inhalt ein
+ *pPaM->GetPoint() = aTmpPos; // restore Cursor
+
+ // erzeuge das PostIt
+ Date aDate;
+ String sTxt;
+
+
+ { // Text aus den Nodes in den String uebertragen
+ SwNodeIndex aIdx( aNdIdx, 1 ),
+ aEnd( *aNdIdx.GetNode().EndOfSectionNode() );
+ SwTxtNode* pTxtNd;
+ while( aIdx != aEnd )
+ {
+ if( 0 != ( pTxtNd = aIdx.GetNode().GetTxtNode() ))
+ {
+ if( sTxt.Len() )
+ sTxt += '\x0a'; // Zeilenumbruch
+ sTxt += pTxtNd->GetExpandTxt();
+ }
+ aIdx++;
+ }
+ rDoc.DeleteSection( &aNdIdx.GetNode() );
+ }
+
+ rDoc.Insert( *pPaM, SwFmtFld( SwPostItField(
+ (SwPostItFieldType*)rDoc.GetSysFldType( RES_POSTITFLD ),
+ sAuthor, sTxt, aDate )));
+
+ pPlcxMan = pOldPlcxMan; // Attributverwaltung restoren
+ pPlcxMan->RestoreAllPLCFx( aSave );
+ return 0;
+}
+
+//-----------------------------------------
+// Header und Footer
+//-----------------------------------------
+
+void SwWW8ImplReader::Read_HdFtText( long nStartCp, long nLen, SwPageDesc* pPD,
+ BOOL bUseLeft, BOOL bFooter )
+{
+ SwFrmFmt* pFmt = ( bUseLeft ) ? &pPD->GetLeft() : &pPD->GetMaster();
+ SwFrmFmt* pHdFtFmt;
+
+ if( bFooter ){
+ bIsFooter = TRUE;
+ pFmt->SetAttr( SwFmtFooter( TRUE ) );
+ pHdFtFmt = (SwFrmFmt*)pFmt->GetFooter().GetFooterFmt();
+ }else{
+ bIsHeader = TRUE;
+ pFmt->SetAttr( SwFmtHeader( TRUE ) );
+ pHdFtFmt = (SwFrmFmt*)pFmt->GetHeader().GetHeaderFmt();
+ }
+
+ const SwNodeIndex* pSttIdx = pHdFtFmt->GetCntnt().GetCntntIdx();
+ if( !pSttIdx ) return;
+
+ SwPosition aTmpPos( *pPaM->GetPoint() ); // merke alte Cursorposition
+
+ Read_HdFtFtnText( pSttIdx, nStartCp, nLen - 1, MAN_HDFT );
+
+ *pPaM->GetPoint() = aTmpPos;
+ bIsHeader = bIsFooter = FALSE;
+}
+
+BYTE SwWW8ImplReader::HdFtCorrectPara( BYTE nPara )
+{
+ WW8_CP start;
+ long nLen;
+ BYTE nNewPara = nPara;
+
+ for( BYTE nI = 0x20; nI; nI >>= 1 )
+ if( ( nI & nPara )
+ && pHdFt
+ && ( !pHdFt->GetTextPos( nPara, nI, start, nLen ) || nLen <= 2 ) )
+
+ {
+ nNewPara &= ~nI; // leere KF-Texte nicht anlegen
+ }
+
+// Wenn im Doc keine Facing Pages vorhanden sind, sollen
+// die geraden Header/Footer ignoriert werden.
+// Die Facing Pages lassen sich nur Doc-weit,
+// nicht aber abschnittsweise umschalten !
+ if( pWDop->fFacingPages )
+ { // Wenn pDoc->FacingPages
+// if( nNewPara & WW8_HEADER_ODD ) // und ungerader Header vorhanden
+// nNewPara |= WW8_HEADER_EVEN; // ... dann muss auch ein gerader
+ // Header erzeugt werden
+// if( nNewPara & WW8_FOOTER_ODD ) // Footer ebenso.
+// nNewPara |= WW8_FOOTER_EVEN;
+ }
+ else
+ {
+ nNewPara &= ~( WW8_HEADER_EVEN | WW8_FOOTER_EVEN ); // ergibt bEven = 0
+ }
+ return nNewPara;
+}
+
+void SwWW8ImplReader::Read_HdFt1( BYTE nPara, BYTE nWhichItems, SwPageDesc* pPD )
+{
+ if( pHdFt )
+ {
+ WW8_CP start;
+ long nLen;
+ BYTE nNumber = 5;
+
+ for( BYTE nI = 0x20; nI; nI >>= 1, nNumber-- )
+ if( nI & nWhichItems )
+ {
+ BOOL bOk = TRUE;
+ if( bVer67 )
+ bOk = ( pHdFt->GetTextPos( nPara, nI, start, nLen ) && nLen > 2 );
+ else
+ {
+ pHdFt->GetTextPosExact(nNumber+ (nActSectionNo+1)*6, start, nLen);
+ bOk = ( 2 < nLen );
+ }
+ if( bOk )
+ {
+ BOOL bUseLeft
+ = (nI & ( WW8_HEADER_EVEN | WW8_FOOTER_EVEN )) ? TRUE : FALSE;
+ BOOL bFooter
+ = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) ? TRUE : FALSE;
+ Read_HdFtText( start, nLen, pPD, bUseLeft, bFooter );
+ }
+ }
+ }
+}
+
+static BYTE ReadBSprm( const WW8PLCFx_SEPX* pSep, USHORT nId, BYTE nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ BYTE nVal = ( pS ) ? SVBT8ToByte( pS ) : nDefaultVal;
+ return nVal;
+}
+
+void SwWW8ImplReader::SetHdFt( SwPageDesc* pPageDesc0, SwPageDesc* pPageDesc1,
+ const WW8PLCFx_SEPX* pSep, BYTE nIPara )
+{
+ if( !nCorrIhdt || ( pAktColl != 0 ) ) // Header / Footer nicht da
+ // oder StyleDef
+ return;
+
+ long nOldDoc = pStrm->Tell( ); // WW-Scanner: alles retten
+ long nOldTbl = pTableStream->Tell(); // WW-Scanner: alles retten
+ WW8PLCFxSaveAll aSave;
+ pPlcxMan->SaveAllPLCFx( aSave ); // Attributverwaltung sichern
+ WW8PLCFMan* pOldPlcxMan = pPlcxMan;
+
+ if( !pPageDesc1 ){ // 1 Pagedesc reicht
+
+ Read_HdFt1( nIPara,
+ nCorrIhdt & ~( WW8_HEADER_FIRST | WW8_FOOTER_FIRST ),
+ pPageDesc0 );
+
+ }else{ // 2 Pagedescs noetig: 1.Seite und folgende
+
+
+ // 1. Seite einlesen
+ Read_HdFt1( nIPara,
+ nCorrIhdt & ( WW8_HEADER_FIRST | WW8_FOOTER_FIRST ),
+ pPageDesc0 );
+
+ // Folgeseiten einlesen
+ Read_HdFt1( nIPara,
+ nCorrIhdt & ~( WW8_HEADER_FIRST | WW8_FOOTER_FIRST ),
+ pPageDesc1 );
+ }
+ // dann WW-Scanner-Kram restoren
+ pPlcxMan = pOldPlcxMan; // Attributverwaltung restoren
+ pPlcxMan->RestoreAllPLCFx( aSave );
+ pStrm->Seek( nOldDoc ); // FilePos dito (Sprms)
+ pTableStream->Seek( nOldTbl ); // FilePos dito (Sprms)
+}
+
+//-----------------------------------------
+// PageDescs
+//-----------------------------------------
+
+
+void SwWW8ImplReader::SetLastPgDeskIdx()
+{
+ if( 0 == pWDop->epc // store NodeIndex for adding section when FT-/End-Note
+ || 2 == pWDop->fpc ) // found that shall be on end of section.
+ {
+ if( pLastPgDeskIdx )
+ *pLastPgDeskIdx = pPaM->GetPoint()->nNode;
+ else
+ pLastPgDeskIdx = new SwNodeIndex( pPaM->GetPoint()->nNode );
+ (*pLastPgDeskIdx)--;
+ }
+}
+
+
+SwPageDesc* SwWW8ImplReader::CreatePageDesc( SwPageDesc* pFirstPageDesc,
+ SwPaM** ppPaMWanted )
+{
+ ASSERT( pFirstPageDesc || ppPaMWanted, "!pFirstPageDesc but NO ppPaMWanted" );
+
+
+ BOOL bFollow = ( pFirstPageDesc != 0 );
+ SwPageDesc* pNewPD;
+ USHORT nPos;
+
+ if( bFollow
+ && pFirstPageDesc->GetFollow() != pFirstPageDesc )
+ return pFirstPageDesc; // Fehler: hat schon Follow
+
+ // compose name of PageDescriptor
+ String aNm( WW8_ASCII2STR( "Konvert " ) );
+ if ( bFollow )
+ aNm.AppendAscii( "Folge" );
+ USHORT nPageDescCount = rDoc.GetPageDescCnt();
+ aNm += String::CreateFromInt32( nPageDescCount );
+
+ nPos = rDoc.MakePageDesc( aNm,
+ bFollow // && (pFirstPageDesc != &rDoc._GetPageDesc( 0 ))
+ ? pFirstPageDesc
+ : 0 );
+ pNewPD = &rDoc._GetPageDesc( nPos );
+
+ if ( bFollow ){ // Dieser ist der folgende von pPageDesc
+ pFirstPageDesc->SetFollow( pNewPD );
+ pNewPD->SetFollow( pNewPD );
+ }
+ else
+ { // setze PgDesc-Attr ins Doc
+ if( bApo || bTxbxFlySection )
+ { // PageDesc *muss* ausserhalb des Apo stehen
+ if( pSFlyPara && pSFlyPara->pMainTextPos )
+ {
+ SwPaM aMyPaM( *pSFlyPara->GetMainTextPos() );
+ if( 1 < nPageDescCount )
+ rDoc.AppendTxtNode( *aMyPaM.GetPoint() );
+ SwFmtCol* pCol;
+ RemoveCols( *pNewPD, pCol );
+ rDoc.Insert( aMyPaM, SwFmtPageDesc( pNewPD ) );
+ if( ppPaMWanted )
+ *ppPaMWanted = new SwPaM( aMyPaM );
+ if( pCol )
+ {
+ InsertSectionWithWithoutCols( aMyPaM, pCol );
+ delete pCol;
+ }
+ else
+ SetLastPgDeskIdx();
+ }
+ }
+ else
+ {
+ if( 0 < pPaM->GetPoint()->nContent.GetIndex() )
+ rDoc.AppendTxtNode( *pPaM->GetPoint() );
+ SwFmtCol* pCol;
+ RemoveCols( *pNewPD, pCol );
+ if( ppPaMWanted )
+ *ppPaMWanted = new SwPaM( *pPaM );
+
+ rDoc.Insert( *pPaM, SwFmtPageDesc( pNewPD ) );
+ if( pCol )
+ {
+ InsertSectionWithWithoutCols( *pPaM, pCol );
+ delete pCol;
+ }
+ else
+ SetLastPgDeskIdx();
+ }
+ }
+ return pNewPD;
+}
+
+// UpdatePageDescs muss am Ende des Einlesevorganges aufgerufen werden, damit
+// der Writer den Inhalt der Pagedescs wirklich akzeptiert
+void SwWW8ImplReader::UpdatePageDescs( USHORT nPageDescOffset )
+{
+ USHORT i;
+
+ // Pagedescriptoren am Dokument updaten (nur so werden auch die
+ // linken Seiten usw. eingestellt).
+
+ // PageDesc "Standard"
+ rDoc.ChgPageDesc( 0, rDoc.GetPageDesc( 0 ));
+
+ // PageDescs "Konvert..."
+ for ( i=nPageDescOffset; i < rDoc.GetPageDescCnt(); i++ )
+ {
+ const SwPageDesc* pPD = &rDoc.GetPageDesc( i );
+ rDoc.ChgPageDesc( i, *pPD );
+ }
+}
+
+//-----------------------------------------
+// Text
+//-----------------------------------------
+
+// TestApo() ist die aus ProcessSpecial() herausgeloeste Apo-Abfrage.
+// sie wird auch beim Aufbau der Tabellen-Struktur (ww8par6.cxx)
+// verwendet.
+// Die Parameter rbStartApo, rbStopApo und rbNowStyleApo sind reine
+// Rueckgabeparameter
+BYTE* SwWW8ImplReader::TestApo( BOOL& rbStartApo, BOOL& rbStopApo,
+ BOOL& rbNowStyleApo,
+ BOOL bInTable, BOOL bTableRowEnd,
+ BOOL bStillInTable )
+{
+ BYTE* pSprm37;
+ BYTE* pSprm29;
+ rbNowStyleApo = (0 != pCollA[nAktColl].pWWFly); // Apo in StyleDef
+
+ if( bInTable && rbNowStyleApo )
+ {
+ pSprm37 = 0;
+ pSprm29 = 0;
+ rbNowStyleApo = FALSE;
+ }
+ else
+ {
+ pSprm37 = pPlcxMan->HasParaSprm( bVer67 ? 37 : 0x2423 );
+ pSprm29 = pPlcxMan->HasParaSprm( bVer67 ? 29 : 0x261B );
+ }
+
+ // here Apo
+ BOOL bNowApo = rbNowStyleApo || pSprm29 || pSprm37;
+ BOOL bApoContinuedInTabCell2ndParagraph
+ = (bApo && bTableInApo && bStillInTable) && !bNowApo;
+ bNowApo |= bApoContinuedInTabCell2ndParagraph;
+
+ rbStartApo = bNowApo && !bApo && !bTableRowEnd; // normal APO-start
+ rbStopApo = bApo && !bNowApo && !bTableRowEnd; // normal APO-end
+
+ if( bApo && bNowApo && !bTableRowEnd
+ && !bApoContinuedInTabCell2ndParagraph
+ && !TestSameApo( pSprm29, rbNowStyleApo ) )
+ {
+ rbStopApo = rbStartApo = TRUE; // aneinandergrenzende APOs
+ };
+ return pSprm29;
+}
+
+BOOL SwWW8ImplReader::ProcessSpecial( BOOL bAllEnd, BOOL* pbReSync ) // Apo / Table / Anl
+{
+ *pbReSync = FALSE;
+ if( bAllEnd ){
+ if( bAnl )
+ StopAnl(); // -> bAnl = FALSE
+ if( bTable && !bFtnEdn ) // Tabelle in FtnEdn nicht erlaubt
+ StopTable();
+ if( bApo )
+ StopApo();
+ bTable = bApo = FALSE;
+ return FALSE;
+ }
+
+ BOOL bTableRowEnd = ( pPlcxMan->HasParaSprm( ( bVer67 ? 25 : 0x2417 )) != 0 ); // TabRowEnd
+
+// es muss leider fuer jeden Absatz zuerst nachgesehen werden,
+// ob sich unter den sprms
+// das sprm 29 (bzw. 0x261B) befindet, das ein APO einleitet.
+// Alle weiteren sprms beziehen sich dann naemlich auf das APO und nicht
+// auf den normalen Text drumrum.
+// Dasselbe gilt fuer eine Tabelle ( sprm 24 (bzw. 0x2416) )
+// und Anls ( sprm 13 ).
+// WW: Tabelle in APO geht ( Beide Anfaende treten gleichzeitig auf )
+// WW: APO in Tabelle geht nicht
+// d.h. Wenn eine Tabelle Inhalt eines Apo ist, dann muss der
+// Apo-Anfang zuerst bearbeitet werden, damit die Tabelle im Apo steht
+// und nicht umgekehrt. Am Ende muss dagegen zuerst das Tabellenende
+// bearbeitet werden, da die Apo erst nach der Tabelle abgeschlossen
+// werden darf ( sonst wird das Apo-Ende nie gefunden ).
+// Dasselbe gilt fuer Fly / Anl, Tab / Anl, Fly / Tab / Anl.
+//
+// Wenn die Tabelle in einem Apo steht, fehlen im TabRowEnd-Bereich
+// die Apo-Angaben. Damit hier die Apo nicht beendet wird, wird
+// ProcessApo dann nicht aufgerufen.
+
+// KHZ: When there is a table inside the Apo the Apo-flags are also
+// missing for the 2nd, 3rd... paragraphs of each cell.
+
+
+// 1st look for in-table flag
+ BYTE* pSprm24 = pPlcxMan->HasParaSprm( bVer67
+ ? 24
+ : 0x2416 ); // Flag: Absatz in(!) Tabelle
+
+// then look if we are in an Apo
+
+ BOOL bStartApo, bStopApo, bNowStyleApo;
+ BYTE* pSprm29 = TestApo( bStartApo, bStopApo, bNowStyleApo,
+ bTable, (bTableRowEnd && bTableInApo),
+ bTable && (pSprm24 != 0) );
+
+// look if we are in a Tabelle
+
+ BOOL bStartTab = pSprm24 && !bTable && !bFtnEdn; // Table in FtnEdn nicht erlaubt
+
+ BOOL bStopTab = bTable && (bWasTabRowEnd && !pSprm24) && !bFtnEdn;
+
+ bWasTabRowEnd = FALSE; // must be deactivated right here to prevent next
+ // WW8TabDesc::TableCellEnd() from making nonsense
+
+ if( bTable && !bStopTab && ( bStartApo || bStopApo ) )
+ { // Wenn Apowechsel in Tabelle
+ bStopTab = bStartTab = TRUE; // ... dann auch neue Tabelle
+ }
+
+// Dann auf Anl (Nummerierung) testen
+// und dann alle Ereignisse in der richtigen Reihenfolge bearbeiten
+
+ if( bAnl && !bTableRowEnd )
+ {
+ BYTE* pSprm13 = pPlcxMan->HasParaSprm( 13 );
+ if( pSprm13 )
+ { // Noch Anl ?
+ BYTE nT = GetNumType( *pSprm13 );
+ if( ( nT != WW8_Pause && nT != nWwNumType ) // Anl-Wechsel
+ || bStopApo || bStopTab // erzwungenes Anl-Ende
+ || bStartApo || bStartTab )
+ {
+ StopAnl(); // Anl-Restart ( = Wechsel ) ueber sprms
+ }
+ else
+ {
+ NextAnlLine( pSprm13 ); // naechste Anl-Zeile
+ }
+ }
+ else
+ { // Anl normal zuende
+ StopAnl(); // Wirkliches Ende
+ }
+ }
+ if( bStopTab )
+ {
+ StopTable();
+ bTable = FALSE;
+ }
+ if( bStopApo )
+ {
+ StopApo();
+ bApo = FALSE;
+ }
+
+ if( bStartApo && !( nIniFlags & WW8FL_NO_APO ) )
+ {
+ bApo = StartApo( pSprm29, bNowStyleApo );
+ *pbReSync = TRUE; // nach StartApo ist ein ReSync
+ // noetig ( eigentlich nur, falls
+ // die Apo ueber eine FKP-Grenze
+ // geht
+ }
+ if( bStartTab && !( nIniFlags & WW8FL_NO_TABLE ) ){
+ if( bAnl ) // Nummerierung ueber Zellengrenzen
+ StopAnl(); // fuehrt zu Absturz -> keine Anls
+ // in Tabellen
+ bTable = StartTable();
+ *pbReSync = TRUE; // nach StartTable ist ein ReSync
+ // noetig ( eigentlich nur, falls
+ // die Tabelle ueber eine
+ // FKP-Grenze geht
+ bTableInApo = bTable && bApo;
+ }
+ return bTableRowEnd;
+}
+
+
+#if defined OS2
+// eigentlich besser inline, aber das kann der BLC nicht
+static UCHAR ConvOs2( UCHAR ch, CharSet eDst )
+{
+ switch( ch ){
+ case 132:
+ case 148: return ( eDst == CHARSET_IBMPC_865 ) ? '"' : 175;
+ // typographische "(links) gegen aehnliche
+ // im OS/2-Charset
+ case 147: return ( eDst == CHARSET_IBMPC_865 ) ? '"' : 174;
+ case 173: // kurze, mittellange und lange Striche gegen Minus
+ case 150:
+ case 151: return '-';
+ case 130: return ',';
+ case 145:
+ case 146: return '\''; // typographische ' gegen normale
+ case 139: return '<';
+ case 155: return '>';
+ case 152: return '~';
+ } // ansonsten macht noch TM AErger.
+
+ return 0; // kenn ick nich
+}
+#endif
+
+// Returnwert: TRUE fuer keine Sonderzeichen
+BOOL SwWW8ImplReader::ReadPlainChars( long& rPos, long nEnd, long nCpOfs )
+{
+ // Unicode-Flag neu setzen und notfalls File-Pos korrigieren
+ // merke: Seek kostet nicht viel, da inline geprueft wird,
+ // ob die korrekte FilePos nicht schon erreicht ist.
+ WW8_FC nStreamPos = pSBase->WW8Cp2Fc(nCpOfs+rPos, &bIsUnicode);
+ pStrm->Seek( nStreamPos );
+
+ // ammount of characters to read == length to next attribut
+ ULONG nLen = nEnd - rPos;
+
+ CharSet eSrcCharSet = ( eHardCharSet != RTL_TEXTENCODING_DONTKNOW )
+ ? eHardCharSet
+ : eFontSrcCharSet;
+
+ // (re)alloc UniString data
+ String sPlainCharsBuf;
+
+ sal_Unicode* pWork = sPlainCharsBuf.AllocBuffer( nLen );
+
+ // read the stream data
+ BYTE nBCode;
+ UINT16 nUCode;
+ for( ULONG nL2 = 0; nL2 < nLen; ++nL2, ++pWork )
+ {
+ if( bIsUnicode )
+ *pStrm >> nUCode; // unicode --> read 2 bytes
+ else
+ {
+ *pStrm >> nBCode; // old code --> read 1 byte
+ nUCode = nBCode;
+ }
+
+ if( 0 != pStrm->GetError() )
+ {
+ rPos = LONG_MAX-10; // -> eof or other error
+ sPlainCharsBuf.ReleaseBufferAccess( 0 );
+ return TRUE;
+ }
+
+ if( (32 > nUCode) || (0xa0 == nUCode) )
+ {
+ pStrm->SeekRel( bIsUnicode ? -2 : -1 );
+ sPlainCharsBuf.ReleaseBufferAccess( nL2 );
+ break; // Sonderzeichen < 32, == 0xa0 gefunden
+ }
+
+ if( bIsUnicode )
+ *pWork = nUCode;
+ else
+ *pWork = ByteString::ConvertToUnicode( nBCode, eSrcCharSet );
+ }
+ if( sPlainCharsBuf.Len() )
+ rDoc.Insert( *pPaM, sPlainCharsBuf );
+
+ rPos += nL2;
+ return nL2 >= nLen;
+}
+
+
+// Returnwert: TRUE fuer Zeilenende
+BOOL SwWW8ImplReader::ReadChars( long& rPos, long nNextAttr, long nTextEnd, long nCpOfs )
+{
+ long nEnd = ( nNextAttr < nTextEnd ) ? nNextAttr : nTextEnd;
+
+ if( bSymbol || bIgnoreText )
+ {
+ if( bSymbol ) // Spezialzeichen einfuegen
+ {
+ for(USHORT nCh = 0; nCh < nEnd - rPos; ++nCh)
+ rDoc.Insert( *pPaM, cSymbol );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
+ }
+ pStrm->SeekRel( nEnd- rPos );
+ rPos = nEnd; // ignoriere bis Attributende
+ return FALSE;
+ }
+ while( TRUE )
+ {
+ if( ReadPlainChars( rPos, nEnd, nCpOfs ) )
+ return FALSE; // Fertig, kein CR
+
+ BOOL bStartLine = ReadChar( rPos, nCpOfs );
+ rPos++;
+ if( bPgSecBreak || bStartLine || rPos == nEnd ) // CR oder Fertig
+ return bStartLine;
+ }
+}
+
+BOOL SwWW8ImplReader::ReadChar( long nPosCp, long nCpOfs )
+{
+ // Unicode-Flag neu setzen und notfalls File-Pos korrigieren
+ // merke: Seek kostet nicht viel, da inline geprueft wird,
+ // ob die korrekte FilePos nicht schon erreicht ist.
+ pStrm->Seek( pSBase->WW8Cp2Fc(nCpOfs+nPosCp, &bIsUnicode) );
+
+ BYTE nBCode;
+ UINT16 nWCharVal;
+ if( bIsUnicode )
+ *pStrm >> nWCharVal; // unicode --> read 2 bytes
+ else
+ {
+ *pStrm >> nBCode; // old code --> read 1 byte
+ nWCharVal = nBCode;
+ }
+
+ sal_Char cInsert = '\x0';
+ BOOL bRet = FALSE;
+ switch( nWCharVal )
+ {
+ case 0xe: {
+ SwTxtNode* pNd = pPaM->GetCntntNode()->GetTxtNode();
+ if ( pNd )
+ {
+ const SfxItemSet* pSet = pNd->GetpSwAttrSet();
+ if ( pSet && ( SFX_ITEM_ON == pSet->GetItemState(
+ RES_PAGEDESC, FALSE ) ) )
+ {
+ rDoc.AppendTxtNode( *pPaM->GetPoint() );
+ }
+ else
+ {
+ const SwPosition* pPos = pPaM->GetPoint();
+ const SwTxtNode* pSttNd = rDoc.GetNodes()[ pPos->nNode ]->GetTxtNode();
+ USHORT nCntPos = pPos->nContent.GetIndex();
+ if( nCntPos && pSttNd->GetTxt().Len() )
+ rDoc.SplitNode( *pPos );
+ }
+ }
+ rDoc.Insert( *pPaM, // column break
+ SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE ) );
+ }
+ break;
+
+ case 0x7: TabCellEnd(); // table cell end (Flags abfragen!)
+ if( bWasTabRowEnd )
+ pSBase->SetNoAttrScan( 0 );
+ break;
+
+ case 0xf: if( !bSpec ) // "Satellit"
+ cInsert = '\xa4';
+ break;
+
+ case 0x14: if( !bSpec ) // "Para-Ende"-Zeichen
+ cInsert = '\xb5';
+ break;
+
+ case 0x15: if( !bSpec ) // Juristenparagraph
+ cInsert = '\xa7';
+ break;
+
+ case 0x9: cInsert = '\x9'; // Tab
+ break;
+
+ case 0xb: cInsert = '\xa'; // Hard NewLine
+ break;
+
+ case 0xc: bPgSecBreak = TRUE;
+ // new behavior: insert additional node only WHEN the Pagebreak
+ // ( #74468# ) is in a NODE that is NOT EMPTY
+ if( 0 < pPaM->GetPoint()->nContent.GetIndex() )
+ bRet = TRUE;
+ pCtrlStck->KillUnlockedAttrs( *pPaM->GetPoint() );
+ break;
+
+ case 0x1e: rDoc.Insert( *pPaM, CHAR_HARDHYPHEN );// Non-breaking hyphen
+ break;
+ case 0x1f: rDoc.Insert( *pPaM, CHAR_SOFTHYPHEN ); // Non-required hyphens
+ break;
+ case 0xa0: rDoc.Insert( *pPaM, CHAR_HARDBLANK );// Non-breaking spaces
+ break;
+
+ case 0x1: if( bObj )
+ ImportOle();
+ else if( bEmbeddObj )
+ {
+ // wenn der OLE-Import nicht klappt, dann versuche
+ // zumindest die Grafik zu importieren
+ if( !ImportOle() )
+ ImportGraf();
+ }
+ else
+ ImportGraf();
+ bObj = bEmbeddObj = FALSE; // das Flag auf immer zurueck setzen
+ nObjLocFc = 0;
+ break;
+
+ case 0x8: if( !bObj )
+ Read_GrafLayer( nPosCp );
+ break;
+
+ case 0xd: bRet = TRUE; break; // line end
+
+ case 0x5: // Annotation reference
+ case 0x13:
+ case 0x2: break; // Auto-Fussnoten-Nummer
+
+#ifdef DEBUG
+ default:
+ {
+ String sUnknown( '<' );
+ sUnknown += String::CreateFromInt32( nWCharVal );
+ sUnknown += '>';
+ rDoc.Insert( *pPaM, sUnknown );
+ }
+#endif
+ break;
+ }
+ if( '\x0' != cInsert )
+ rDoc.Insert( *pPaM, ByteString::ConvertToUnicode(
+ cInsert, RTL_TEXTENCODING_MS_1252 ) );
+ return bRet;
+}
+
+
+void SwWW8ImplReader::ProcessAktCollChange( WW8PLCFManResult& rRes,
+ BOOL* pStartAttr,
+ BOOL bCallProcessSpecial )
+{
+ USHORT nOldColl = nAktColl;
+ nAktColl = pPlcxMan->GetColl();
+
+ if( bIsHeader ) // Fuer Kopfzeilenabstaende
+ nHdTextHeight += pPlcxMan->GetPapPLCF()->GetParaHeight();
+ else
+ if( bIsFooter ) // Fuer Kopfzeilenabstaende
+ nFtTextHeight += pPlcxMan->GetPapPLCF()->GetParaHeight();
+
+ if( nAktColl >= nColls || !pCollA[nAktColl].pFmt
+ || !pCollA[nAktColl].bColl )
+ {
+ nAktColl = 0; // Unguelige Style-Id
+ }
+ else
+ {
+ nLeftParaMgn = pCollA[nAktColl].nLeftParaMgn;
+ nTxtFirstLineOfst = pCollA[nAktColl].nTxtFirstLineOfst;
+ }
+ BOOL bTabRowEnd = FALSE;
+ if( pStartAttr && bCallProcessSpecial )
+ {
+ BOOL bReSync;
+ bTabRowEnd = ProcessSpecial( FALSE, &bReSync );// Apo / Table / Anl
+ if( bReSync )
+ *pStartAttr = pPlcxMan->Get( &rRes ); // hole Attribut-Pos neu
+ }
+ if( !bTabRowEnd )
+ {
+ SetTxtFmtCollAndListLevel( *pPaM, pCollA[ nAktColl ]);
+
+ ChkToggleAttr( pCollA[ nOldColl ].n81Flags,
+ pCollA[ nAktColl ].n81Flags );
+ }
+
+ eFontSrcCharSet = pCollA[nAktColl].eFontSrcCharSet; // aus P-Style
+}
+
+
+long SwWW8ImplReader::ReadTextAttr( long& rTxtPos, BOOL& rbStartLine )
+{
+ long nOld = pStrm->Tell();
+ long nSkipChars = 0;
+ WW8PLCFManResult aRes;
+
+ BOOL bStartAttr = pPlcxMan->Get( &aRes ); // hole Attribut-Pos
+
+ if( aRes.nFlags & MAN_MASK_NEW_SEP ){ // neue Section
+ CreateSep( rTxtPos ); // PageDesc erzeugen und fuellen
+ bPgSecBreak = FALSE; // -> 0xc war ein Sectionbreak, aber
+ } // kein Pagebreak;
+
+ if( ( aRes.nFlags & MAN_MASK_NEW_PAP ) // neuer Absatz ueber Plcx.Fkp.papx
+ || rbStartLine )
+ { // oder ueber 0x0d o.ae. im Text
+ ProcessAktCollChange(
+ aRes,
+ &bStartAttr,
+ MAN_MASK_NEW_PAP == (aRes.nFlags & MAN_MASK_NEW_PAP)
+ && !bIgnoreText );
+ rbStartLine = FALSE;
+ }
+
+ // position of last CP that's to be ignored
+ long nSkipPos = -1;
+ BOOL bOldDontCreateSep = bDontCreateSep;
+
+ if( 0 < aRes.nSprmId ) // leere Attrs ignorieren
+ {
+ if( ( 256 > aRes.nSprmId ) || ( 0x0800 <= aRes.nSprmId ) )
+ {
+ if( bStartAttr ) // WW-Attribute
+ {
+ if( aRes.nMemLen >= 0 )
+ { // Attr anschalten
+ ImportSprm( aRes.pMemPos, (short)aRes.nMemLen, aRes.nSprmId );
+ }
+ }
+ else
+ EndSprm( aRes.nSprmId ); // Attr ausschalten
+ }
+ else if( aRes.nSprmId < 0x800 ) // eigene Hilfs-Attribute
+ {
+ aRes.nAktCp = rTxtPos; // Akt. Cp-Pos
+ nSkipChars = ImportExtSprm( &aRes, bStartAttr );
+ if( 256 <= aRes.nSprmId && 258 >= aRes.nSprmId )
+ {
+ rTxtPos += nSkipChars; // Felder/Ftn-/End-Note hier ueberlesen
+ nSkipPos = rTxtPos-1;
+ }
+ }
+ }
+
+ if( bVer8 || nSkipChars || aRes.nSprmId == 260 )
+ // Feld oder Piece
+ // um nSkipChars bewegen bei Feldern und Pieces
+ pStrm->Seek( pSBase->WW8Cp2Fc( pPlcxMan->GetCpOfs() + rTxtPos, &bIsUnicode));
+ else
+ {
+ // sonst alte Pos wiederherstellen und Unicode-Flag ermitteln
+ pStrm->Seek( nOld );
+ }
+
+ // Find next Attr position (and Skip attributes of field contents if needed)
+ if( nSkipChars && !bIgnoreText )
+ pCtrlStck->MarkAllAttrsOld();
+ BOOL bOldIgnoreText = bIgnoreText;
+ bIgnoreText = TRUE;
+ USHORT nOldColl = nAktColl;
+ BOOL bDoPlcxManPlusPLus = TRUE;
+ long nNext;
+ do
+ {
+ if( bDoPlcxManPlusPLus )
+ (*pPlcxMan)++;
+ nNext = pPlcxMan->Where();
+ if( (0 <= nNext) && (nSkipPos >= nNext) )
+ {
+ nNext = ReadTextAttr( rTxtPos, rbStartLine );
+ bDoPlcxManPlusPLus = FALSE;
+ bIgnoreText = TRUE;
+ }
+ }
+ while( nSkipPos >= nNext );
+ bIgnoreText = bOldIgnoreText;
+ bDontCreateSep = bOldDontCreateSep;
+ if( nSkipChars )
+ {
+ pCtrlStck->KillUnlockedAttrs( *pPaM->GetPoint() );
+ if( nOldColl != pPlcxMan->GetColl() )
+ ProcessAktCollChange(aRes, 0, FALSE);
+ }
+
+ return nNext;
+}
+
+void SwWW8ImplReader::ReadAttrs( long& rNext, long& rTxtPos, BOOL& rbStartLine )
+{
+ if( rTxtPos >= rNext )
+ { // Stehen Attribute an ?
+
+ do
+ {
+ rNext = ReadTextAttr( rTxtPos, rbStartLine );
+ }while( rTxtPos >= rNext );
+
+ }
+ else if ( rbStartLine )
+ {
+// keine Attribute, aber trotzdem neue Zeile
+// wenn eine Zeile mit einem Seitenumbruch aufhoert und sich keine
+// Absatzattribute / Absatzvorlagen aendern, ist das Zeilenende
+// nicht im Plcx.Fkp.papx eingetragen, d.h. ( nFlags & MAN_MASK_NEW_PAP )
+// ist FALSE. Deshalb muss als Sonderbehandlung hier die Vorlage gesetzt
+// werden.
+ if( !bCpxStyle )
+ {
+ SetTxtFmtCollAndListLevel( *pPaM, pCollA[ nAktColl ] );
+ }
+ rbStartLine = FALSE;
+ }
+}
+
+// ReadAttrEnds zum Lesen nur der Attributenden am Ende eines Textes oder
+// Textbereiches ( Kopfzeile, Fussnote, ...). Attributanfaenge, Felder
+// werden ignoriert.
+void SwWW8ImplReader::ReadAttrEnds( long& rNext, long& rTxtPos )
+{
+
+ while( rTxtPos >= rNext )
+ {
+ WW8PLCFManResult aRes;
+
+ BOOL b = pPlcxMan->Get( &aRes ); // hole Attribut-Pos
+
+ if( !b
+ && (aRes.nSprmId >= 0) // nur Attributenden noch bearbeiten,
+ && ( (aRes.nSprmId < 256)
+ || (aRes.nSprmId >= 0x0800) )
+ )
+ { // Anfaenge gehoeren zum naechsten Spezialtext
+ EndSprm( aRes.nSprmId ); // Fussnoten und Felder ignorieren
+ }
+ (*pPlcxMan)++;
+ rNext = pPlcxMan->Where();
+ }
+ BOOL bDummyReSync;
+ ProcessSpecial( TRUE, &bDummyReSync );
+}
+
+void SwWW8ImplReader::ReadText( long nStartCp, long nTextLen, short nType )
+{
+ if( nIniFlags & WW8FL_NO_TEXT )
+ return;
+
+ BOOL bStartLine = TRUE;
+ short nCrCount = 0;
+
+ nAktColl = 0;
+ pAktItemSet = 0;
+ nCharFmt = -1;
+ bSpec = FALSE;
+ nHdTextHeight = nFtTextHeight = 0;
+
+ pPlcxMan = new WW8PLCFMan( pSBase, nType, nStartCp );
+ long nCpOfs = pPlcxMan->GetCpOfs(); // Offset fuer Header/Footer, Footnote
+
+ WW8_CP nNext = pPlcxMan->Where();
+
+ pStrm->Seek( pSBase->WW8Cp2Fc( nStartCp + nCpOfs, &bIsUnicode ) );
+
+ if( (0 == nStartCp+nCpOfs)
+ && SetCols( 0, pPlcxMan->GetSepPLCF(), 0, TRUE ) )
+ {
+ // Start of text:
+ //
+ // look for cols and insert a section at the very beginning...
+ //
+ if( !pPageDesc )
+ pPageDesc = &rDoc._GetPageDesc( 0 );
+ SwFrmFmt &rFmt = pPageDesc->GetMaster();
+ USHORT nLIdx = ( ( pWwFib->lid & 0xff ) == 0x9 ) ? 1 : 0;
+ SetPage1( pPageDesc, rFmt, pPlcxMan->GetSepPLCF(), nLIdx, FALSE );
+ const SwFmtCol& rCol = rFmt.GetCol();
+ // if PageDesc has been inserted and has cols
+ // insert a *section* with cols instead
+ if( rCol.GetNumCols() )
+ {
+ InsertSectionWithWithoutCols( *pPaM, &rCol );
+ // remove columns from PageDesc
+ SwFmtCol aCol;
+ rFmt.SetAttr( aCol );
+ }
+ }
+
+ WW8_CP l = nStartCp;
+ while ( l<nStartCp+nTextLen )
+ {
+
+ ReadAttrs( nNext, l, bStartLine );// behandelt auch Section-Breaks
+
+ if( bPgSecBreak ) // Pagebreak, aber kein Sectionbreak
+ {
+ SwPosition& rPt = *pPaM->GetPoint();
+ // new behavior: insert additional node only WHEN the Pagebreak
+ // ( #74468# ) is contained in a NODE that is NOT EMPTY
+ if( (nLastFlyNode == rPt.nNode.GetIndex())
+ || (0 < rPt.nContent.GetIndex()) )
+ {
+ rDoc.AppendTxtNode( rPt );
+ }
+ rDoc.Insert( *pPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ) );
+ bPgSecBreak = FALSE;
+ }
+ if( l>= nStartCp + nTextLen )
+ break;
+
+ bStartLine = ReadChars( l, nNext, nStartCp+nTextLen, nCpOfs );
+
+ if( bStartLine ) // Zeilenende
+ {
+ rDoc.AppendTxtNode( *pPaM->GetPoint() );
+
+ if( ( nCrCount++ & 0x40 ) == 0 // alle 64 CRs aufrufen
+ && nType == MAN_MAINTEXT ){ // nicht fuer Header u. ae.
+ nProgress = (USHORT)( l * 100 / nTextLen );
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+ }
+ }
+ }
+ ReadAttrEnds( nNext, l );
+ JoinNode( pPaM );
+ if( nType == MAN_MAINTEXT )
+ UpdatePageDescs( nPageDescOffset ); // muss passieren, solange es den
+ // PlcxMan noch gibt
+ DELETEZ( pPlcxMan );
+}
+
+/***************************************************************************
+# class SwWW8ImplReader
+#**************************************************************************/
+
+SwWW8ImplReader::SwWW8ImplReader( BYTE nVersionPara,
+ SvStorage* pStorage, SvStream* pSt,
+ SwDoc& rD, BOOL bNewDoc )
+ : pStg( pStorage ), rDoc( rD ), pStrm( pSt ), bNew( 0 != bNewDoc ),
+ pMSDffManager( 0 ), pAtnNames( 0 ), pAuthorInfos( 0 ), pLastPgDeskIdx( 0 ),
+ pDataStream( 0 ), pTableStream( 0 )
+{
+ pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ nWantedVersion = nVersionPara;
+ pCtrlStck = 0;
+ pEndStck = 0;
+ pRefFldStck = 0;
+ pFonts = 0;
+ pSBase = 0;
+ pPlcxMan = 0;
+ pStyles = 0;
+ pAktColl = 0;
+ pLstManager = 0;
+ pAktItemSet = 0;
+ pCollA = 0;
+ pHdFt = 0;
+ pWFlyPara = 0;
+ pSFlyPara = 0;
+ pFlyFmtOfJustInsertedGraphic = 0;
+ nColls = nAktColl = 0;
+ nObjLocFc = nPicLocFc = 0;
+ bReadNoTbl = bPgSecBreak = bSpec = bObj = bApo = bTxbxFlySection
+ = bHasBorder = bSymbol = bIgnoreText = bDontCreateSep = bTable
+ = bTableInApo = bWasTabRowEnd = bTxtCol = FALSE;
+ bShdTxtCol = bCharShdTxtCol = bAnl = bHdFtFtnEdn = bFtnEdn
+ = bIsHeader = bIsFooter = bSectionHasATitlePage
+ = bIsUnicode = bCpxStyle = bStyNormal = bWWBugNormal = FALSE;
+ bNoAttrImport = bPgChpLevel = bEmbeddObj = bFloatingCtrl = FALSE;
+ bAktAND_fNumberAcross = FALSE;
+ bNoLnNumYet = TRUE;
+ bRestartLnNumPerSection = FALSE;
+ nProgress = 0;
+ nHdTextHeight = nFtTextHeight = 0;
+ nPgWidth = lA4Width;
+ nPgLeft = nPgRight = nPgTop = MM_250;
+ nCorrIhdt = 0;
+ nSwNumLevel = nWwNumType = 0xff;
+ pTableDesc = 0;
+ pNumRule = 0;
+ pNumOlst = 0;
+ pBehindSection = 0;
+ pNewSection = 0;
+ pNode_FLY_AT_CNTNT = 0;
+ pDrawFmt = 0;
+ pDrawModel = 0;
+ pDrawPg = 0;
+ pDrawGroup = 0;
+ pDrawHeight = 0;
+ nDrawTxbx = 0;
+ pDrawEditEngine = 0;
+ pFormImpl = 0;
+ nLeftParaMgn = 0;
+ nTxtFirstLineOfst = 0;
+ pNumFldType = 0;
+ nFldNum = 0;
+
+ nLastFlyNode = ULONG_MAX;
+ nImportedGraphicsCount = 0;
+
+ nLFOPosition = USHRT_MAX;
+ nListLevel = nWW8MaxListLevel;
+
+ eFontSrcCharSet = RTL_TEXTENCODING_DONTKNOW;
+ eFontDstCharSet = RTL_TEXTENCODING_DONTKNOW;
+ eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
+ pPageDesc = 0;
+
+ nNfcPgn = nPgChpDelim = nPgChpLevel = 0;
+
+#ifdef DEBUG
+ Sound::Beep();
+#endif
+}
+
+void SwWW8ImplReader::DeleteStk(SwFltControlStack* pStck)
+{
+ if( pStck )
+ {
+ pStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ pStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ delete pStck;
+ }
+ else
+ {
+ ASSERT( !this, "WW-Stack bereits geloescht" );
+ }
+}
+
+ULONG SwWW8ImplReader::LoadDoc1( SwPaM& rPaM ,WW8Glossary *pGloss)
+{
+ ULONG nErrRet = 0;
+
+ if( bNew && pStg && !pGloss)
+ ReadDocInfo();
+
+ pPaM = new SwPaM( *rPaM.GetPoint() );
+
+ pCtrlStck = new SwWW8FltControlStack( &rDoc, nFieldFlags );
+
+ /*
+ Endestack: haelt z.B. Bookmarks und Variablen solange vor,
+ bis er den Befehl zum inserten bekommt.
+ */
+ pEndStck = new SwFltEndStack( &rDoc, nFieldFlags );
+ /*
+ fieldstack holds Reference Fields until the very end of file import
+ */
+ pRefFldStck = new SwWW8FltControlStack( &rDoc, nFieldFlags );
+
+ nPageDescOffset = rDoc.GetPageDescCnt();
+
+ SwNodeIndex aSttNdIdx( rDoc.GetNodes() );
+ SwRelNumRuleSpaces aRelNumRule( rDoc, bNew );
+
+ USHORT eMode = REDLINE_SHOW_INSERT;
+
+ // enum-para mitgeben, welche Versions-Nummern erlaubt sind: ww6, ww8, ...
+
+ if (pGloss)
+ pWwFib = pGloss->GetFib();
+ else
+ pWwFib = new WW8Fib( *pStrm, nWantedVersion ); // Fib einlesen
+
+ if ( pWwFib->nFibError )
+ { // ERR_NO_WW8_FILE
+ nErrRet = ERR_SWG_READ_ERROR; // oder ERR_SW6_READ_ERROR
+ }
+ else if( pWwFib->fEncrypted )
+ {
+ nErrRet = ERR_SW6_PASSWD; // gecryptet geht nicht
+
+
+
+ // Annotation: Crypted files C O U L D be imported if we used the methods
+ // provided by Caolan Mc Nammara.
+ // Written permission (my e-mail) was given by him
+ // but no special document has been signed...
+ // 27. Sept. 1999, K.-H. Zimmer
+
+
+ }
+ else if( ( nIniFlags & WW8FL_NO_COMPLEX ) && pWwFib->fComplex )
+ {
+ nErrRet = WARN_WW6_FASTSAVE_ERR; // Warning melden
+ }
+ else
+ {
+ // praktische Hilfsvariablen besetzen:
+ bVer67 = ( (6 == pWwFib->nVersion)
+ || (7 == pWwFib->nVersion) ); // z.B.: altes Sprm-Id-Format!
+ bVer6 = (6 == pWwFib->nVersion);
+ bVer7 = (7 == pWwFib->nVersion);
+ bVer8 = (8 == pWwFib->nVersion);
+
+ SvStorageStreamRef xTableStream, xDataStream;
+
+ // Nachdem wir nun den FIB eingelesen haben, wissen wir ja,
+ // welcher Table-Stream gueltig ist.
+ // Diesen oeffnen wir nun.
+ switch( pWwFib->nVersion ) // 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: pTableStream = pStrm;
+ pDataStream = pStrm;
+ break;
+
+ case 8:
+ if( !pStg )
+ {
+ ASSERT( pStg, "Version 8 muss immer einen Storage haben!" );
+ nErrRet = ERR_SWG_READ_ERROR;
+ break;
+ }
+ xTableStream = pStg->OpenStream(
+ String( (1 == pWwFib->fWhichTblStm)
+ ? "1Table"
+ : "0Table",
+ RTL_TEXTENCODING_MS_1252 ),
+ STREAM_STD_READ );
+ pTableStream = &xTableStream;
+ pTableStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ xDataStream = pStg->OpenStream(
+ String( "Data", RTL_TEXTENCODING_MS_1252 ),
+ STREAM_STD_READ | STREAM_NOCREATE );
+ if( xDataStream.Is() && SVSTREAM_OK == xDataStream->GetError() )
+ {
+ pDataStream = &xDataStream;
+ pDataStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ }
+ else
+ pDataStream = pStrm;
+
+ if( pWwFib->lcbPlcfspaHdr || pWwFib->lcbPlcfspaMom )
+ pMSDffManager = new SwMSDffManager( *this );
+ break;
+
+ default:// Programm-Fehler!
+ ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ nErrRet = ERR_SWG_READ_ERROR;
+ }
+
+ if( ERR_SWG_READ_ERROR != nErrRet )
+ {
+ if( 0x0100 == pWwFib->chse )
+ eTextCharSet = RTL_TEXTENCODING_APPLE_ROMAN;
+ else
+ eTextCharSet = rtl_getTextEncodingFromWindowsCharset( pWwFib->chse );
+ if( 0x0100 == pWwFib->chseTables )
+ eStructCharSet = RTL_TEXTENCODING_APPLE_ROMAN;
+ else
+ eStructCharSet = rtl_getTextEncodingFromWindowsCharset( pWwFib->chseTables );
+
+ bWWBugNormal = pWwFib->nProduct == 0xc03d;
+
+ if( !bNew )
+ aSttNdIdx = pPaM->GetPoint()->nNode;
+
+ ::StartProgress( STR_STATSTR_W4WREAD, 0, 100, rDoc.GetDocShell() );
+
+
+ rDoc.SetParaSpaceMax( TRUE, TRUE ); // Abstand zwischen zwei Absaetzen ist
+ // die SUMME von unterem Abst. des ersten und oberem Abst. des zweiten
+
+
+ // read Font Table
+ pFonts = new WW8Fonts( *pTableStream, *pWwFib );
+
+
+ pWDop = new WW8Dop( *pTableStream, pWwFib->nFib, pWwFib->fcDop, pWwFib->lcbDop ); // Document Properties
+ ImportDop( bNew != 0 );
+
+
+ /*
+ Import revisioning data: author names
+ */
+ if( pWwFib->lcbSttbfRMark )
+ ReadRevMarkAuthorStrTabl( *pTableStream,
+ pWwFib->fcSttbfRMark,
+ pWwFib->lcbSttbfRMark, rDoc );
+
+ /*
+ zuerst(!) alle Styles importieren (siehe WW8PAR2.CXX)
+ VOR dem Import der Listen !!
+ */
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+ pStyles = new WW8RStyle( *pWwFib, this ); // Styles
+ pStyles->Import();
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+
+
+ /*
+ jetzt erst alle Listen importieren (siehe WW8PAR3.CXX)
+ NACH dem Import der Styles !!
+ */
+ pLstManager = new WW8ListManager( *pTableStream, *this );
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+
+
+ /*
+ zu guter Letzt: (siehe ebenfalls WW8PAR3.CXX)
+ ===============
+ alle Styles durchgehen und ggfs. zugehoeriges Listen-Format anhaengen
+ NACH dem Import der Styles und NACH dem Import der Listen !!
+ */
+ pStyles->RegisterNumFmts();
+
+
+ pSBase = new WW8ScannerBase( pStrm, pTableStream, pDataStream,
+ pWwFib );
+ static SvxExtNumType __READONLY_DATA eNumTA[16] = {
+ SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER, SVX_NUM_CHARS_UPPER_LETTER_N,
+ SVX_NUM_CHARS_LOWER_LETTER_N, SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
+ SVX_NUM_ARABIC, SVX_NUM_ARABIC,
+ SVX_NUM_ARABIC, SVX_NUM_ARABIC,
+ SVX_NUM_ARABIC, SVX_NUM_ARABIC,
+ SVX_NUM_ARABIC, SVX_NUM_ARABIC };
+
+ if( pSBase->AreThereFootnotes() ){
+ static SwFtnNum __READONLY_DATA eNumA[4] = {
+ FTNNUM_DOC, FTNNUM_CHAPTER, FTNNUM_PAGE, FTNNUM_DOC };
+
+ SwFtnInfo aInfo;
+ aInfo = rDoc.GetFtnInfo(); // Copy-Ctor privat
+
+ aInfo.ePos = FTNPOS_PAGE;
+ aInfo.eNum = eNumA[pWDop->rncFtn];
+ aInfo.aFmt.eType = eNumTA[pWDop->nfcFtnRef];
+ if( pWDop->nFtn )
+ aInfo.nFtnOffset = pWDop->nFtn - 1;
+ rDoc.SetFtnInfo( aInfo );
+ }
+ if( pSBase->AreThereEndnotes() ){
+ SwEndNoteInfo aInfo;
+ aInfo = rDoc.GetEndNoteInfo(); // parallel zu Ftn
+
+ // Ich kann nicht setzen, wann neu nummerieren...
+ // aInfo.eNum = eNumA[pWDop->pDop->rncEdn];
+ aInfo.aFmt.eType = eNumTA[pWDop->nfcEdnRef];
+ if( pWDop->nEdn )
+ aInfo.nFtnOffset = pWDop->nEdn - 1;
+ rDoc.SetEndNoteInfo( aInfo );
+ }
+
+ if( pWwFib->lcbPlcfhdd )
+ pHdFt = new WW8PLCF_HdFt( pTableStream, *pWwFib, *pWDop );
+
+ if( !bNew ){ // in ein Dokument einfuegen ?
+ // Da immer ganze Zeile eingelesen werden, muessen
+ // evtl. Zeilen eingefuegt / aufgebrochen werden
+ const SwPosition* pPos = pPaM->GetPoint();
+ const SwTxtNode* pSttNd = rDoc.GetNodes()[ pPos->nNode ]->GetTxtNode();
+ USHORT nCntPos = pPos->nContent.GetIndex();
+
+ if( nCntPos && pSttNd->GetTxt().Len() ) // EinfuegePos nicht in leerer Zeile
+ rDoc.SplitNode( *pPos ); // neue Zeile erzeugen
+
+ if( pSttNd->GetTxt().Len() )
+ { // EinfuegePos nicht am Ende der Zeile
+ rDoc.SplitNode( *pPos ); // neue Zeile
+ pPaM->Move( fnMoveBackward ); // gehe in leere Zeile
+ }
+
+ // verhinder das Einlesen von Tabellen in Fussnoten / Tabellen
+ ULONG nNd = pPos->nNode.GetIndex();
+ bReadNoTbl = 0 != pSttNd->FindTableNode() ||
+ ( nNd < rDoc.GetNodes().GetEndOfInserts().GetIndex() &&
+ rDoc.GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
+
+ }
+
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+ if (pGloss) // loop for each glossary entry and add dummy section node
+ {
+ WW8PLCF aPlc(&xTableStream,pWwFib->fcPlcfglsy,
+ pWwFib->lcbPlcfglsy,0 );
+
+ WW8_CP nStart, nEnd;
+ void* pDummy;
+
+ for (int i=0;i<pGloss->GetNoStrings();i++,aPlc++)
+ //for (int i=0;i<1;i++,aPlc++)
+ {
+ SwNodeIndex aIdx( rDoc.GetNodes().GetEndOfContent());
+ SwTxtFmtColl* pColl =
+ rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD);
+ SwStartNode *pNode =
+ rDoc.GetNodes().MakeTextSection(aIdx,
+ SwNormalStartNode,pColl);
+ pPaM->GetPoint()->nNode = pNode->GetIndex()+1;
+ pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(),0);
+ aPlc.Get( nStart, nEnd, pDummy );
+ ReadText(nStart,nEnd-nStart-1,MAN_MAINTEXT);
+ //ReadText( 0, pWwFib->ccpText, MAN_MAINTEXT );
+ }
+ }
+ else //ordinary case
+ {
+ ReadText( 0, pWwFib->ccpText, MAN_MAINTEXT );
+ }
+
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+ if( pCollA )
+ {
+ SwNumRule aOutlineRule( *rDoc.GetOutlineNumRule() );
+
+ USHORT nI;
+ // Bitfeld, welche Outline-Level bereits an einem
+ // Style gesetzt wurden (vermeiden von Doppeltvergabe)
+ USHORT nFlagsStyleOutlLevel = 0;
+ if( !bNew )
+ {
+ const SwTxtFmtColls& rColls = *rDoc.GetTxtFmtColls();
+ for( nI = 0; nI < rColls.Count(); nI++ )
+ {
+ const SwTxtFmtColl& rColl = *rColls[ nI ];
+ if( MAXLEVEL > rColl.GetOutlineLevel() )
+ {
+ nFlagsStyleOutlLevel |= 1 << rColl.GetOutlineLevel();
+ }
+ }
+ }
+ USHORT nIa=10;
+ USHORT nIz=nColls;
+ for( USHORT nJ = 0; nJ < 2; nJ++ )
+ {
+ for( nI = nIa; nI < nIz; nI++ )
+ {
+ SwWW8StyInf& rSI = pCollA[ nI ];
+
+ if( ( MAXLEVEL > rSI.nOutlineLevel )
+ && rSI.pOutlineNumrule
+ && rSI.pFmt )
+ {
+ USHORT nAktFlags = 1 << rSI.nOutlineLevel;
+ if( nAktFlags & nFlagsStyleOutlLevel )
+ {
+ rSI.pFmt->SetAttr(
+ SwNumRuleItem( rSI.pOutlineNumrule->GetName() ) );
+ ((SwTxtFmtColl*)rSI.pFmt)->SetOutlineLevel( NO_NUMBERING );
+ }
+ else
+ // die Default-Styles im ZWEITEN Durchgang auf jeden Fall
+ // nehmen, die User-definierten nur, wenn auch verwendet.
+ if( nJ || rSI.pFmt->GetDepends() )
+ {
+ // Numformat aus der NumRule nehmen
+ // und bei der OutlineRule setzen.
+ aOutlineRule.Set(
+ rSI.nOutlineLevel,
+ rSI.pOutlineNumrule->Get( rSI.nOutlineLevel ) );
+ // am Style die Outlinenummer eintragen
+ ((SwTxtFmtColl*)rSI.pFmt)->SetOutlineLevel( rSI.nOutlineLevel );
+ // Flag verodern, um Doppeltvergabe zu vermeiden
+ nFlagsStyleOutlLevel |= nAktFlags;
+ }
+ }
+ }
+ nIa = 1;
+ nIz = 10;
+ }
+ if( nFlagsStyleOutlLevel )
+ rDoc.SetOutlineNumRule( aOutlineRule );
+
+ /* // wird nun ueber D'tor erledigt!
+ for( nI = 0; nI < nColls; nI++ ){
+ if( pCollA[nI].pWWFly )
+ delete( pCollA[nI].pWWFly );
+ }
+ */
+ delete[] pCollA;
+ }
+
+ if( pDrawPg && pMSDffManager && pMSDffManager->GetShapeOrders() )
+ {
+ // Hilfsarray zum Verketten der (statt SdrTxtObj) eingefuegten Rahmen
+ SvxMSDffShapeTxBxSort aTxBxSort;
+
+ // korrekte Z-Order der eingelesen Escher-Objekte sicherstellen
+ USHORT nShapeCount = pMSDffManager->GetShapeOrders()->Count();
+ USHORT nNewObjNum = 0;
+ for (USHORT nShapeNum=0; nShapeNum < nShapeCount; nShapeNum++)
+ {
+ SvxMSDffShapeOrder& rOrder = *(SvxMSDffShapeOrder*)
+ (pMSDffManager->GetShapeOrders()->GetObject( nShapeNum ));
+ if( rOrder.pObj )
+ {
+ ULONG nOldObjNum = rOrder.pObj->GetOrdNum();
+ if( (nOldObjNum != nNewObjNum )
+ && (pDrawPg->GetObj( nOldObjNum )) )
+ pDrawPg->NbcSetObjectOrdNum( nOldObjNum, nNewObjNum );
+ ++nNewObjNum;
+ }
+ // Pointer in neues Sort-Array einfuegen
+ if( rOrder.nTxBxComp && rOrder.pFly )
+ aTxBxSort.Insert( &rOrder );
+ }
+ // zu verkettende Rahmen jetzt verketten
+ USHORT nTxBxCount = aTxBxSort.Count();
+ if( nTxBxCount )
+ {
+ SwFmtChain aChain;
+ for (USHORT nTxBxNum=0; nTxBxNum < nTxBxCount; nTxBxNum++)
+ {
+ SvxMSDffShapeOrder& rOrder =
+ *(SvxMSDffShapeOrder*)(aTxBxSort.GetObject( nTxBxNum ));
+
+ // Fly-Frame-Formate initialisieren
+ SwFlyFrmFmt* pFlyFmt = rOrder.pFly;
+ SwFlyFrmFmt* pNextFlyFmt = 0;
+ SwFlyFrmFmt* pPrevFlyFmt = 0;
+ // ggfs. Nachfolger ermitteln
+ if( 1+nTxBxNum < nTxBxCount )
+ {
+ SvxMSDffShapeOrder& rNextOrder =
+ *(SvxMSDffShapeOrder*)(aTxBxSort.GetObject( nTxBxNum+1 ));
+ if( (0xFFFF0000 & rOrder.nTxBxComp)
+ == (0xFFFF0000 & rNextOrder.nTxBxComp)
+ && rOrder.nHdFtSection
+ == rNextOrder.nHdFtSection )
+ pNextFlyFmt = rNextOrder.pFly;
+ }
+ // ggfs. Vorgaenger ermitteln
+ if( nTxBxNum )
+ {
+ SvxMSDffShapeOrder& rPrevOrder =
+ *(SvxMSDffShapeOrder*)(aTxBxSort.GetObject( nTxBxNum-1 ));
+ if( (0xFFFF0000 & rOrder.nTxBxComp)
+ == (0xFFFF0000 & rPrevOrder.nTxBxComp)
+ && rOrder.nHdFtSection
+ == rPrevOrder.nHdFtSection )
+ pPrevFlyFmt = rPrevOrder.pFly;
+ }
+ // Falls Nachfolger oder Vorgaenger vorhanden,
+ // die Verkettung am Fly-Frame-Format eintragen
+ if( pNextFlyFmt || pPrevFlyFmt )
+ {
+ aChain.SetNext( pNextFlyFmt );
+ aChain.SetPrev( pPrevFlyFmt );
+ pFlyFmt->SetAttr( aChain );
+ }
+ }
+
+ }
+
+ }
+
+ if( bNew )
+ {
+ if( pWDop->fRevMarking )
+ eMode |= REDLINE_ON;
+ if( pWDop->fRMView )
+ eMode |= REDLINE_SHOW_DELETE;
+ if(pStg && !pGloss) /*meaningless for a glossary, cmc*/
+ {
+ const OfaFilterOptions* pVBAFlags = OFF_APP()->GetFilterOptions();
+ SvxImportMSVBasic aVBasic(*rDoc.GetDocShell(),*pStg,
+ pVBAFlags->IsLoadWordBasicCode(),
+ pVBAFlags->IsLoadWordBasicStorage() );
+ String s1( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "Macros" )));
+ String s2( String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "VBA" )));
+ int nRet = aVBasic.Import( s1, s2 );
+ if( 2 & nRet )
+ rDoc.SetContainsMSVBasic( TRUE );
+ }
+ }
+
+ DELETEZ( pStyles );
+
+ if( pFormImpl )
+ DeleteFormImpl();
+ GrafikDtor();
+ DELETEZ( pMSDffManager );
+ DELETEZ( pHdFt );
+ DELETEZ( pLstManager );
+ DELETEZ( pSBase );
+ DELETEZ( pWDop );
+ DELETEZ( pFonts );
+ DELETEZ( pAtnNames );
+ DELETEZ( pAuthorInfos );
+ DELETEZ( pLastPgDeskIdx );
+ ::EndProgress( rDoc.GetDocShell() );
+ }
+ pDataStream = 0;
+ pTableStream = 0;
+ }
+ DELETEZ( pBehindSection );
+ if (!pGloss)
+ DELETEZ( pWwFib );
+ DeleteCtrlStk();
+ DeleteEndStk();
+ DeleteRefFldStk();
+
+ // set NoBallanced flag on last inserted section
+ if( pNewSection )
+ {
+ pNewSection->GetFmt()->SetAttr( SwFmtNoBalancedColumns( TRUE ) );
+ }
+
+ // NumRules koennen erst nach dem setzen aller Attribute korrgiert werden
+#ifdef DEBUG
+ {
+ ULONG nN = rDoc.GetNodes().Count();
+ for( ULONG iN = 0; iN < nN; ++iN )
+ {
+ SwTxtNode* pN = rDoc.GetNodes()[ iN ]->GetTxtNode();
+ if( pN && pN->GetNum() )
+ {
+ const SwNumRuleItem& rItem
+ = (SwNumRuleItem&)(pN->SwCntntNode::GetAttr( RES_PARATR_NUMRULE ) );
+ if( !rItem.GetValue().Len() )
+ ASSERT( !this, "NdNum gesetzt, aber KEIN NumRuleItem" );
+ }
+ }
+ }
+#endif
+
+#ifdef DEBUG
+ {
+ const SwSpzFrmFmts& rFmts = *rDoc.GetSpzFrmFmts();
+ for( ULONG iN = 0, nN = rFmts.Count(); iN < nN; ++iN )
+ {
+ const SwFmtAnchor& rA = rFmts[ iN ]->GetAnchor();
+ if( FLY_IN_CNTNT == rA.GetAnchorId() &&
+ !rA.GetCntntAnchor())
+ {
+ int x = 0;
+ }
+ }
+ }
+#endif
+
+ aRelNumRule.SetNumRelSpaces( rDoc );
+ if( !bNew && !nErrRet && aSttNdIdx.GetIndex() )
+ {
+ aSttNdIdx++;
+ aRelNumRule.SetOultineRelSpaces( aSttNdIdx,
+ pPaM->GetPoint()->nNode );
+ }
+
+ UpdateFields();
+
+ DELETEZ( pPaM );
+ // delete the pam before the call for hide all redlines (Bug 73683)
+ if( bNew )
+ rDoc.SetRedlineMode( eMode );
+
+ return nErrRet;
+}
+
+const String* SwWW8ImplReader::GetAnnotationAuthor( short nIdx )
+{
+ if( !pAtnNames && pWwFib->lcbGrpStAtnOwners )
+ {
+ // Authoren bestimmen: steht im TableStream
+ pAtnNames = new SvStringsDtor( 4, 4 );
+ SvStream& rStrm = *pTableStream;
+
+ long nOldPos = rStrm.Tell();
+ rStrm.Seek( pWwFib->fcGrpStAtnOwners );
+
+ long nRead = 0, nCount = pWwFib->lcbGrpStAtnOwners;
+ String* pAutName;
+ while( nRead < nCount )
+ {
+ if( bVer67 )
+ {
+ pAutName = new String( WW8ReadPString( rStrm, FALSE ) );
+ nRead += pAutName->Len() + 1; // Laenge + BYTE Count
+ }
+ else
+ {
+ pAutName = new String( WW8Read_xstz( rStrm, 0, FALSE ) );
+ nRead += pAutName->Len() * 2 + 2;// UNICode: doppelte Laenge + USHORT Count
+ }
+ pAtnNames->Insert( pAutName, pAtnNames->Count() );
+ }
+ rStrm.Seek( nOldPos );
+ }
+
+ return pAtnNames && nIdx < pAtnNames->Count() ? (*pAtnNames)[ nIdx ] : 0;
+}
+
+
+#pragma optimize( "", off )
+
+ULONG SwWW8ImplReader::LoadDoc( SwPaM& rPaM,WW8Glossary *pGloss)
+{
+ ULONG nErrRet = 0;
+
+ pAktColl = 0;
+ pAktItemSet = 0;
+ nIniFlags = ReadFilterFlags( "WW" );
+ nIniFlags1= ReadFilterFlags( "WW8" );
+// nIniHdSiz = ReadFilterFlags( "WWHD" );
+ nIniFtSiz = ReadFilterFlags( "WWFT" );
+ // schiebt Flys um x twips nach rechts o. links
+ nIniFlyDx = ReadFilterFlags( "WWFLX" );
+ nIniFlyDy = ReadFilterFlags( "WWFLY" );// nach oben o. unten
+ Read_FieldIniFlags();
+
+ UINT16 nMagic;
+ *pStrm >> nMagic;
+
+ switch( nWantedVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7:
+ if( 0xa5dc != nMagic )
+ {
+ //JP 06.05.99: teste auf eigenen 97-Fake!
+ if( pStg && 0xa5ec == nMagic )
+ {
+ ULONG nCurPos = pStrm->Tell();
+ UINT32 nfcMin;
+ if( pStrm->Seek( nCurPos + 22 ) )
+ {
+ *pStrm >> nfcMin;
+ if( 0x300 != nfcMin )
+ nErrRet = ERR_WW6_NO_WW6_FILE_ERR;
+ }
+ pStrm->Seek( nCurPos );
+ }
+ else
+ nErrRet = ERR_WW6_NO_WW6_FILE_ERR;
+ }
+ break;
+ case 8: if( 0xa5ec != nMagic )
+ nErrRet = ERR_WW8_NO_WW8_FILE_ERR;
+ break;
+
+ default:
+ nErrRet = ERR_WW8_NO_WW8_FILE_ERR;
+ ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+
+ if( !nErrRet )
+ nErrRet = LoadDoc1( rPaM ,pGloss);
+
+#ifdef DEBUG
+ Sound::Beep();
+#endif
+
+ return nErrRet; // return Errorcode
+}
+
+
+ULONG WW8Reader::Read( SwDoc &rDoc, SwPaM &rPam,
+ const String & /* FileName, falls benoetigt wird */ )
+{
+ USHORT nOldBuffSize = 32768;
+ BOOL bNew = !bInsertMode; // Neues Doc ( kein Einfuegen )
+
+
+ SvStorageStreamRef refStrm; // damit uns keiner den Stream klaut
+ SvStream* pIn = pStrm;
+
+ ULONG nRet = 0;
+ BYTE nVersion = 8;
+
+ String sFltName = GetFltName();
+ if( sFltName.EqualsAscii( "WW6" ) )
+ {
+ if( pStrm )
+ nVersion = 6;
+ else
+ {
+ ASSERT( FALSE, "WinWord 95 Reader-Read ohne Stream" );
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ }
+ else
+ {
+ if( sFltName.EqualsAscii( "CWW6" ) )
+ nVersion = 6;
+ else if( sFltName.EqualsAscii( "CWW7" ) )
+ nVersion = 7;
+
+ if( pStg )
+ {
+ nRet = OpenMainStream( refStrm, nOldBuffSize );
+ pIn = &refStrm;
+ }
+ else
+ {
+ ASSERT( FALSE, "WinWord 95/97 Reader-Read ohne Storage" );
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ }
+
+ if( !nRet )
+ {
+ //JP 18.01.96: Alle Ueberschriften sind normalerweise ohne
+ // Kapitelnummer. Darum hier explizit abschalten
+ // weil das Default jetzt wieder auf AN ist.
+ if( bNew )
+ {
+ Reader::SetNoOutlineNum( rDoc );
+ // MIB 27.09.96: Umrandung uns Abstaende aus Frm-Vorlagen entf.
+ Reader::ResetFrmFmts( rDoc );
+ }
+ SwWW8ImplReader* pRdr = new SwWW8ImplReader( nVersion, pStg,
+ pIn, rDoc, bNew );
+ nRet = pRdr->LoadDoc( rPam );
+ delete pRdr;
+
+ if( refStrm.Is() )
+ {
+ refStrm->SetBufferSize( nOldBuffSize );
+ refStrm.Clear();
+ }
+ }
+ return nRet;
+}
+
+int WW8Reader::GetReaderType()
+{
+ return SW_STORAGE_READER | SW_STREAM_READER;
+}
+
+BOOL WW8Reader::HasGlossaries() const
+{
+ return TRUE;
+}
+
+
+BOOL WW8Reader::ReadGlossaries( SwTextBlocks& rBlocks, BOOL bSaveRelFiles ) const
+{
+ USHORT nOldBuffSize = 32768;
+ SvStorageStreamRef refStrm;
+
+ WW8Reader *pThis = (WW8Reader *)this;
+ ULONG nRet = pThis->OpenMainStream( refStrm, nOldBuffSize );
+
+ WW8Glossary aGloss( refStrm, 8, pStg );
+ return aGloss.Load(rBlocks, bSaveRelFiles );
+}
+
+
+#pragma optimize( "", off )
+
+
+BOOL SwMSDffManager::GetOLEStorageName( long nOLEId, String& rStorageName,
+ SvStorageRef& rSrcStorage,
+ SvStorageRef& rDestStorage ) const
+{
+ BOOL bRet = FALSE;
+
+ long nPictureId = 0;
+ if( !( rReader.nIniFlags & WW8FL_NO_OLE ) && rReader.pStg )
+ {
+ // dann holen wir uns mal ueber den TextBox-PLCF die richtigen
+ // Char Start-/End-Positionen. In dem Bereich sollte dann
+ // das EinbettenFeld und die entsprechenden Sprms zu finden
+ // sein. Wir brauchen hier aber nur das Sprm fuer die Picture Id
+ long nOldPos = rReader.pStrm->Tell();
+ {
+ long nStartCp, nEndCp;
+ rReader.GetTxbxTextSttEndCp( nStartCp, nEndCp,
+ ( nOLEId >> 16 ) & 0xFFFF,
+ nOLEId & 0xFFFF );
+
+ WW8PLCFxSaveAll aSave;
+ memset( &aSave, 0, sizeof( aSave ) );
+ rReader.pPlcxMan->SaveAllPLCFx( aSave );
+
+ nStartCp += rReader.nDrawCpO;
+ nEndCp += rReader.nDrawCpO;
+ WW8PLCFx_Cp_FKP* pChp = rReader.pPlcxMan->GetChpPLCF();
+ pChp->SeekPos( nStartCp );
+
+ WW8_CP nStart = pChp->Where();
+ while( nStart <= nEndCp && !nPictureId )
+ {
+ WW8PLCFxDesc aDesc;
+ pChp->GetSprms( &aDesc );
+ (*pChp)++;
+ WW8_CP nNextEnd = pChp->Where();
+ WW8_CP nEnd = ( nNextEnd < nEndCp ) ? nNextEnd : nEndCp;
+
+ if( aDesc.nSprmsLen && aDesc.pMemPos ) // Attribut(e) vorhanden
+ {
+ long nLen = aDesc.nSprmsLen;
+ BYTE* pSprm = aDesc.pMemPos;
+
+ while( nLen >= 2 && !nPictureId )
+ {
+ BYTE nDelta;
+ USHORT nId = WW8GetSprmId( rReader.pWwFib->nVersion,
+ pSprm, &nDelta );
+ short nSL = WW8GetSprmSizeBrutto(
+ rReader.pWwFib->nVersion, pSprm, &nId );
+
+ if( nLen < nSL )
+ break; // nicht mehr genug Bytes uebrig
+
+ if( 0x6A03 == nId && 0 < nLen )
+ {
+ nPictureId = SVBT32ToLong( pSprm + 1 +
+ nDelta + WW8SprmDataOfs( nId ) );
+ bRet = TRUE;
+ }
+ pSprm += nSL;
+ nLen -= nSL;
+ }
+ }
+ nStart = nNextEnd;
+ }
+
+ rReader.pPlcxMan->RestoreAllPLCFx( aSave );
+ }
+ rReader.pStrm->Seek( nOldPos );
+ }
+
+ if( bRet )
+ {
+ ( rStorageName = '_' ) += String::CreateFromInt32( nPictureId );
+ rSrcStorage = rReader.pStg->OpenStorage( WW8_ASCII2STR( "ObjectPool" ) );
+ SwDocShell *pDocShell = rReader.rDoc.GetDocShell();
+ if (pDocShell == 0)
+ bRet=FALSE;
+ else
+ rDestStorage = pDocShell->GetStorage();
+ }
+ return bRet;
+}
+
+BOOL SwMSDffManager::ShapeHasText( ULONG nShapeId, ULONG nFilePos ) const
+{
+ // Zur Zeit des Einlesens einer einzelnen Box, die womoeglich Teil einer
+ // Gruppe ist, liegen noch nicht genuegend Informationen vor, um
+ // entscheiden zu koennen, ob wir sie nicht doch als Textfeld benoetigen.
+ // Also vorsichtshalber mal alle umwandeln:
+ return TRUE;
+}
+/*
+void SwMSDffManager::ProcessClientAnchor2( SvStream& rSt, DffRecordHeader& rHd, void* pData, DffObjData& rObj )
+{
+ if( rHd.nRecLen && rObj.nShapeId )
+ {
+ SvxMSDffImportData& rData = *(SvxMSDffImportData*)pData;
+
+ SvxMSDffImportRec* pImpRec = 0;
+ // find out if this shape did get a Record already
+ USHORT nRecCnt = rData.GetRecCount();
+ if( nRecCnt )
+ {
+ for(USHORT i = nRecCnt; i; )
+ {
+ i--;
+ SvxMSDffImportRec* pRec = rData.GetRecord( i );
+ if( pRec && (rObj.nShapeId == pRec->nShapeId) )
+ {
+ // Nun hab ich Dich, Du Wicht!
+ pImpRec = pRec;
+ break;
+ }
+ }
+ }
+ if( !pImpRec )
+ {
+ SvxMSDffImportRec* pTmpRec = new SvxMSDffImportRec;
+ pTmpRec->nShapeId = rObj.nShapeId;
+ rData.aRecords.Insert( pTmpRec );
+ pImpRec = rData.GetRecord( nRecCnt );
+ if( !pImpRec )
+ delete pTmpRec;
+ }
+ if( pImpRec )
+ {
+ // new
+ pImpRec->pClientAnchorBuffer = new char[ rHd.nRecLen ];
+ pImpRec->nClientAnchorLen = rHd.nRecLen;
+ rSt.Read( pImpRec->pClientAnchorBuffer, rHd.nRecLen );
+ }
+ }
+}
+*/
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.143 2000/09/18 16:04:59 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.142 2000/08/28 14:54:44 khz
+ #64941# compare Hd./Ft./Section info to prevent prohibited TxBx linkage
+
+ Revision 1.141 2000/08/22 17:08:54 cmc
+ #77743# OLE Import, bad seek & bad FilterOptions
+
+ Revision 1.140 2000/08/18 09:48:24 khz
+ Import Line Numbering (restart on new section)
+
+ Revision 1.139 2000/08/18 06:47:22 khz
+ Import Line Numbering
+
+ Revision 1.138 2000/08/04 10:56:49 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character
+
+ Revision 1.137 2000/07/28 15:37:14 khz
+ #73796# don't delete NumRule from Attr but set it into pDoc
+
+ Revision 1.136 2000/07/27 10:21:30 khz
+ #73796# stop ANList when opening next cell in a row and !pAktANLD->fNumberAcross
+
+ Revision 1.135 2000/07/17 13:47:00 khz
+ #73987# check if sprmSNfcPgn should cause section change or not
+
+ Revision 1.134 2000/07/12 12:20:30 khz
+ #76503# use SwFltStackEntry.bOld to mark attributes before skipping field
+
+ Revision 1.133 2000/07/10 12:52:37 jp
+ new Errormessage
+
+ Revision 1.132 2000/06/29 20:59:03 jp
+ new MS Filteroptions - change OLE-Objects to StarOffice Objects
+
+ Revision 1.131 2000/06/28 08:07:44 khz
+ #70915# Insert Section if end-note with flag 'on end of section' found
+
+ Revision 1.130 2000/06/23 10:30:01 khz
+ #71707# Make sure pNdNum is set to zero when no numbering on node
+
+ Revision 1.129 2000/06/21 12:19:15 khz
+ Task #74876 teilbehoben.
+
+ Revision 1.128 2000/05/31 12:22:50 khz
+ Changes for Unicode
+
+ Revision 1.127 2000/05/25 08:06:41 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.126 2000/05/18 10:58:55 jp
+ Changes for Unicode
+
+ Revision 1.125 2000/05/16 12:13:01 jp
+ ASS_FALSE define removed
+
+ Revision 1.124 2000/05/16 11:21:54 khz
+ Unicode code-conversion
+
+ Revision 1.123 2000/05/05 16:26:00 cmc
+ #75358# WW8 97Controls Import Fix
+
+ Revision 1.122 2000/05/05 15:59:24 khz
+ Task #74474# don't create Sections while skipping result of multi-column index-field
+
+ Revision 1.121 2000/05/04 07:43:51 khz
+ Task #75379# use new Save() and Restore()
+
+ Revision 1.120 2000/04/17 12:01:57 khz
+ Task #74837# prevent from breaking table (in Apo) when Apo-flag is missing
+
+ Revision 1.119 2000/04/12 11:08:31 khz
+ Task #74260# import FLY_PAGE-frames in Header/Footer as FLY_AT_CNTNT
+
+ Revision 1.118 2000/04/07 09:38:20 khz
+ Task #74468# insert new node when Pagebreak is in NOT EMPTY node
+
+ Revision 1.117 2000/03/01 13:32:20 jp
+ Bug #73683#: LoadDoc1 - call setredlinemode after the destroying of the pam
+
+ Revision 1.116 2000/02/25 15:03:33 jp
+ Task #72781#: new filter options for MS-filters
+
+ Revision 1.115 2000/02/22 16:23:23 khz
+ Task #72987# Ignore Sprms covering ONLY a Tab-Row-End Char #7
+
+ Revision 1.114 2000/02/21 13:08:23 jp
+ #70473# changes for unicode
+
+ Revision 1.113 2000/02/18 09:35:14 cmc
+ #69372# Improved Hyperlink Importing for WW97
+
+ Revision 1.107 2000/02/09 11:24:20 khz
+ Task #70473# char_t --> sal_Unicode
+
+ Revision 1.106 2000/02/02 18:12:04 jp
+ Task #72579#: WW8Reader can import glossaries
+
+ Revision 1.105 2000/02/02 18:07:35 khz
+ Task #69885# Read SPRMs that are stored in piece table grpprls
+
+ Revision 1.104 2000/01/26 18:55:59 jp
+ Task #72268#: flag for stored M$-VBasic storage
+
+ Revision 1.103 2000/01/26 10:27:09 cmc
+ #72268# Visual Basic Decompression
+
+ Revision 1.102 2000/01/14 11:27:56 khz
+ Task #68832# -- CORRECTION: Task Number of rev below should have been: 68832 !
+
+ Revision 1.101 2000/01/14 11:11:31 khz
+ Task #71343# look for Sprm 37 (not 5) to recognize APO
+
+ Revision 1.100 2000/01/10 13:38:52 jp
+ Task #64574#: LoadDoc1 - calculate the correct Z-Order for the SDR-Objects
+
+ Revision 1.99 2000/01/10 12:01:58 jp
+ Task #69283#: LoadDoc1 - set redline mode after the last content/attribut is inserted
+
+ Revision 1.98 2000/01/06 15:23:41 khz
+ Task #71411# Let last Section be unbalanced
+
+ Revision 1.97 1999/12/23 16:08:47 khz
+ Task #70788# Set bStartLine on each char 0x0c
+
+ Revision 1.96 1999/12/23 14:02:58 khz
+ Task #68143# avoid attributes atached solely to Cell-End marks
+
+ Revision 1.95 1999/12/22 18:03:09 khz
+ Task #70919# look if ParaStyle is different behind filed than it was before
+
+ Revision 1.94 1999/12/21 09:25:51 khz
+ Task #71111# Prevent from reading CONTENT when skiping field attributes
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
new file mode 100644
index 000000000000..8c68d6f8809b
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -0,0 +1,1287 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _WW8PAR_HXX
+#define _WW8PAR_HXX
+
+
+//#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+//#include <com/sun/star/drawing/XShape.hpp>
+//#endif
+//#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+//#include <com/sun/star/form/XFormComponent.hpp>
+//#endif
+//#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+//#include <com/sun/star/beans/XPropertySet.hpp>
+//#endif
+
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+#ifndef _VCL_COLOR_HXX
+#include <vcl/color.hxx>
+#endif
+#ifndef _SV_FONTTYPE_HXX //autogen
+#include <vcl/fonttype.hxx>
+#endif
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx> // fuer den Attribut Stack
+#endif
+#ifndef _WW8STRUC_HXX
+#include <ww8struc.hxx> // WW8_BRC ( Forward-Declaration mit anschliessender
+#endif // Benutzung von WW8_BRC[4] in Deklaration will der
+ // doofe Os2Blci nicht )
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx> // WW8Fib
+#endif
+
+#ifndef _WW8GLSY_HXX
+#include <ww8glsy.hxx>
+#endif
+
+#ifndef _MSDFFIMP_HXX
+#include <svx/msdffimp.hxx>
+#endif
+
+#ifndef _MSOCXIMP_HXX
+#include <msocximp.hxx>
+#endif
+
+
+#define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))
+
+
+class SvStringsDtor;
+class SwDoc;
+class SwPaM;
+class SfxPoolItem;
+class SwTxtFmtColl;
+class SwPageDesc;
+class SvxBoxItem;
+class SwFmt;
+class SwNodeIndex;
+class SwFlyFrmFmt;
+class SvxTabStopItem;
+class SwAttrSet;
+class SwNumRule;
+class SwFrmFmt;
+
+//class WW8CtrlStack;
+class SwFltControlStack;
+//class WW8EndStack;
+class SwFltEndStack;
+class SwWW8StyInf;
+class WW8Fib;
+class WW8PLCFMan;
+struct WW8PLCFManResult;
+class WW8Fonts;
+class WW8RStyle;
+class WW8PLCF_HdFt;
+class Plcx_Fkp;
+class WW8PLCFx_SEPX;
+class WW8Dop;
+class WW8ScannerBase;
+struct WW8FieldDesc;
+struct WW8FlyPara;
+struct WW8SwFlyPara;
+struct WmfFileHd;
+struct WW8_PIC;
+class WW8TabDesc;
+struct WW8_SHD;
+struct WW8_OLST;
+class SwNumFmt;
+struct WW8_ANLD;
+struct WW8_ANLV;
+struct WW8_DO;
+struct WW8_DPHEAD;
+struct WW8_FSPA;
+class Plc1;
+class SwDrawFrmFmt;
+class SdrModel;
+class SdrPage;
+class SdrObjList;
+class SdrObject;
+class SdrTextObj;
+class Size;
+class EditEngine;
+struct SwPosition;
+class SvShorts;
+class WW8ReaderSave;
+struct WW8PicDesc;
+class Graphic;
+//class String;
+class SwFieldType;
+class SvStorage;
+// alt: class SvStorageRef;
+class SwFlyFrmFmt;
+class SwAttrSet;
+class GDIMetaFile;
+struct ESelection;
+class SfxItemSet;
+struct WW8PLCFxDesc;
+
+struct WW8ULSpaceData;
+class SdrAttrObj;
+struct WW8ULSpaceData;
+
+namespace com{namespace sun {namespace star{
+ namespace beans{ class XPropertySet;}
+ namespace form { class XFormComponent;}
+ namespace drawing{class XShape;}
+ namespace lang{class XMultiServiceFactory;}
+}}}
+
+//#define WW8_CHARBUF_SIZE 1040 // Lese-Puffer fuer nackten Text
+
+// defines nur fuer die WW8-variable der INI-Datei
+
+#define WW8FL_NO_TEXT 1
+#define WW8FL_NO_STYLES 2
+#define WW8FL_NO_ZSTYLES 4 // keine Zeichenstyles importieren
+#define WW8FL_NO_APO 8
+#define WW8FL_NO_HDFT 0x10
+#define WW8FL_NO_FTN 0x20
+#define WW8FL_NO_FLD 0x40 // keine Felder
+#define WW8FL_NO_GRAF 0x80
+#define WW8FL_NO_DEFTABS 0x100 // keine impliziten Tabs
+#define WW8FL_NO_LRUL 0x200
+
+
+#define WW8FL_NO_DEFSTYLES 0x400 // falls gestetzt, werden fuer Writer-Def-Styles
+ // neue Styles mit den WW8-Def-Style-Eigenschaften
+ // erzeugt, statt die Writer-Standards zu ueberschreiben
+
+#define WW8FL_NO_TABLE 0x800
+#define WW8FL_NO_OUTLINE 0x1000
+#define WW8FL_NO_NUMRULE 0x2000
+#define WW8FL_NO_IMPLPASP 0x4000 // no implicit para space
+#define WW8FL_NO_GRAFLAYER 0x8000
+#define WW8FL_NO_COMPLEX 0x10000
+#define WW8FL_NO_OLE 0x20000
+#define WW8FL_OLE_TO_GRAF 0x40000
+#define WW8FL_NO_VCCONTROLS 0x80000
+#define WW8FL_NO_STD_STY_DYA 0x100000
+#define WW8FL_NO_COLS 0x200000
+#define WW8FL_NO_TOX 0x400000
+#define WW8FL_NO_IMPORT 0x20000000
+#define WW8FL_WRITE_TO_FILE 0x40000000
+#define WW8FL_NOWARN_COMPLEX 0x80000000
+
+// Zusatz-Filter-Flags, gueltig ab Winword 8
+#define WW8FL_NO_FLY_FOR_TXBX 1
+#define EQUAL_TAB_BORDERDISTS 2
+
+
+//-----------------------------------------
+// Listen-Manager (ab Ver8)
+//-----------------------------------------
+
+struct WW8LSTInfo;
+struct WW8LFOInfo;
+
+typedef WW8LSTInfo* WW8LSTInfo_Ptr;
+typedef WW8LFOInfo* WW8LFOInfo_Ptr;
+// Zeichenattribute aus GrpprlChpx
+typedef SfxItemSet* WW8aISet[nWW8MaxListLevel ];
+// Zeichen Style Pointer
+typedef SwCharFmt* WW8aCFmt[ nWW8MaxListLevel ];
+// Redlining: match WinWord author ids to StarWriter author ids
+struct WW8AuthorInfo;
+typedef WW8AuthorInfo* WW8AuthorInfo_Ptr;
+
+SV_DECL_PTRARR_SORT_DEL(WW8LSTInfos, WW8LSTInfo_Ptr, 16,16);
+SV_DECL_PTRARR_DEL( WW8LFOInfos, WW8LFOInfo_Ptr, 16,16);
+SV_DECL_PTRARR_SORT_DEL(WW8AuthorInfos, WW8AuthorInfo_Ptr, 16,16);
+
+class SwWW8ImplReader;
+class WW8ListManager
+{
+ SwWW8ImplReader& rReader;
+ SwDoc& rDoc;
+ const WW8Fib& rFib;
+ SvStream& rSt;
+ WW8LSTInfos* pLSTInfos;// Daten aus PLCF LST, sortiert nach LST Id
+ WW8LFOInfos* pLFOInfos;// D. aus PLF LFO, sortiert genau wie im WW8 Stream
+ USHORT nLSTInfos;// geht schneller als Abfrage von pLSTInfos->Count()
+ USHORT nLFOInfos;// dito
+ BYTE* GrpprlHasSprm(USHORT nId, BYTE& rSprms, BYTE nLen);
+ WW8LSTInfo* GetLSTByStreamPos( USHORT nStreamPos ) const;
+ WW8LSTInfo* GetLSTByListId( ULONG nIdLst ) const;
+ BOOL ReadLVL( BYTE nLevel,
+ SwNumFmt& rNumFmt,
+ SfxItemSet*& rpItemSet,
+ USHORT nLevelStyle,
+ BOOL bSetStartNo );
+ void AdjustLVL( BYTE nLevel,
+ SwNumRule& rNumRule,
+ WW8aISet& rListItemSet,
+ WW8aCFmt& aCharFmt,
+ BOOL& bNewCharFmtCreated, // Ausgabe-Parameter
+ String aPrefix = aEmptyStr );
+ BOOL LFOequaltoLST(WW8LFOInfo& rLFOInfo);
+public:
+ WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_);
+ ~WW8ListManager();
+ SwNumRule* GetNumRuleForActivation(USHORT nLFOPosition) const;
+ BOOL IsSimpleList(USHORT nLFOPosition) const;
+};
+
+
+
+//-----------------------------------------
+// Stack
+//-----------------------------------------
+class SwWW8FltControlStack : public SwFltControlStack
+{
+ USHORT nToggleAttrFlags;
+protected:
+ virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry);
+
+public:
+ SwWW8FltControlStack( SwDoc* pDo, ULONG nFieldFl ) :
+ SwFltControlStack( pDo, nFieldFl ), nToggleAttrFlags( 0 )
+ {}
+
+ BOOL IsFtnEdnBkmField(SwFmtFld& rFmtFld, USHORT& nBkmNo);
+ void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
+ void SetToggleAttr( BYTE nId, BOOL bOn )
+ {
+ if( bOn )
+ nToggleAttrFlags |= (1 << nId);
+ else
+ nToggleAttrFlags &= ~(1 << nId);
+ }
+ USHORT GetToggleAttrFlags() const { return nToggleAttrFlags; }
+};
+
+
+
+//-----------------------------------------
+// Redlining Authors
+//-----------------------------------------
+struct WW8AuthorInfo
+{
+ USHORT nWWAuthorId;
+ USHORT nOurId;
+
+ WW8AuthorInfo(USHORT nWWAuthorId_, USHORT nOurId_ = 0):
+ nWWAuthorId( nWWAuthorId_ ),
+ nOurId( nOurId_ )
+ {}
+ BOOL operator==( const WW8AuthorInfo& rEntry ) const
+ {
+ return (nWWAuthorId == rEntry.nWWAuthorId);
+ }
+ BOOL operator<( const WW8AuthorInfo& rEntry ) const
+ {
+ return (nWWAuthorId < rEntry.nWWAuthorId);
+ }
+};
+
+
+
+//-----------------------------------------
+// Mini-Merker fuer einige Flags
+//-----------------------------------------
+class WW8ReaderSave
+{
+ SwPosition aTmpPos;
+ SwWW8FltControlStack* pOldStck;
+ WW8PLCFxSaveAll aPLCFxSave;
+ WW8PLCFMan* pOldPlcxMan;
+
+ WW8FlyPara* pWFlyPara;
+ WW8SwFlyPara* pSFlyPara;
+ WW8TabDesc* pTableDesc;
+ USHORT nAktColl;
+ sal_Unicode cSymbol;
+ BOOL bIgnoreText : 1;
+ BOOL bDontCreateSep : 1;
+ BOOL bSymbol : 1;
+ BOOL bHdFtFtnEdn : 1;
+ BOOL bApo : 1;
+ BOOL bTxbxFlySection: 1;
+ BOOL bTable : 1;
+ BOOL bTableInApo : 1;
+ BOOL bAnl : 1;
+public:
+ WW8ReaderSave( SwWW8ImplReader* pRdr, WW8_CP nStart=-1 );
+ void Restore( SwWW8ImplReader* pRdr );
+};
+
+
+
+enum eF_ResT{ F_OK, F_TEXT, F_TAGIGN, F_TAGTXT, F_READ_FSPA };
+
+struct SwWW8Shade{
+ Color aColor;
+ BOOL bWhiteText;
+ SwWW8Shade( BOOL bVer67, const WW8_SHD& rSHD );
+};
+
+
+//-----------------------------------------
+// Formulas
+//-----------------------------------------
+enum SwWw8ControlType
+{
+ WW8_CT_EDIT,
+ WW8_CT_CHECKBOX,
+ WW8_CT_COMBOBOX
+};
+
+
+class WW8FormulaControl : public OCX_Control
+{
+public:
+ WW8FormulaControl(const UniString& sN,SwWW8ImplReader &rR)
+ : OCX_Control(sN), rRdr(rR) {}
+ void WW8FormulaControl::SetOthersFromDoc(com::sun::star::uno::Reference <com::sun::star::form::XFormComponent> &rFComp,
+ com::sun::star::awt::Size &rSz,
+ com::sun::star::uno::Reference <com::sun::star::beans::XPropertySet> &rPropSet);
+
+ UINT8 fToolTip:1;
+ UINT8 fNoMark:1;
+ UINT8 fUseSize:1;
+ UINT8 fNumbersOnly:1;
+ UINT8 fDateOnly:1;
+ UINT8 fUnused:3;
+ UINT16 nSize;
+
+ UINT16 hpsCheckBox;
+ UINT16 nChecked;
+
+ UniString sTitle;
+ UniString sDefault;
+ UniString sFormatting;
+ UniString sHelp;
+ UniString sToolTip;
+
+ void Read(SwWw8ControlType nWhich,SvStream *pD);
+private:
+ SwWW8ImplReader &rRdr;
+};
+
+class WW8FormulaCheckBox: public WW8FormulaControl
+{
+public:
+ WW8FormulaCheckBox(SwWW8ImplReader &rR)
+ : WW8FormulaControl( WW8_ASCII2STR( "CheckBox" ), rR)
+ {}
+ BOOL Convert(const com::sun::star::uno::Reference <com::sun::star::lang::XMultiServiceFactory> &rServiceFactory,
+ com::sun::star::uno::Reference <com::sun::star::form::XFormComponent> &rFComp,com::sun::star::awt::Size &rSz);
+
+};
+
+class WW8FormulaEditBox: public WW8FormulaControl
+{
+public:
+ WW8FormulaEditBox(SwWW8ImplReader &rR)
+ : WW8FormulaControl( WW8_ASCII2STR( "TextField" ) ,rR)
+ {}
+ BOOL Convert(const com::sun::star::uno::Reference <com::sun::star::lang::XMultiServiceFactory> &rServiceFactory,
+ com::sun::star::uno::Reference <com::sun::star::form::XFormComponent> &rFComp,com::sun::star::awt::Size &rSz);
+
+};
+
+class SwImportControls : public SwImportOCX
+{
+public:
+ SwImportControls( SfxObjectShell *pDSh,SwPaM *pP ) :
+ SwImportOCX( pDSh,pP ) {}
+ BOOL InsertFormula( WW8FormulaControl &rFormula,
+ com::sun::star::uno::Reference <com::sun::star::drawing::XShape> *pShapeRef=0 );
+};
+
+class SwMSDffManager : public SvxMSDffManager
+{
+ SwWW8ImplReader& rReader;
+ virtual BOOL GetOLEStorageName( long nOLEId, String& rStorageName,
+ SvStorageRef& rSrcStorage,
+ SvStorageRef& rDestStorage ) const;
+ virtual BOOL ShapeHasText( ULONG nShapeId, ULONG nFilePos ) const;
+// virtual void ProcessClientAnchor2( SvStream& rStData, DffRecordHeader& rHd, void* pData, DffObjData& );
+
+public:
+ SwMSDffManager( SwWW8ImplReader& rRdr );
+ static UINT32 GetFilterFlags();
+};
+
+
+//-----------------------------------------
+// Storage-Reader
+//-----------------------------------------
+class SwWW8ImplReader
+{
+friend class WW8RStyle;
+friend class WW8TabDesc;
+friend class WW8ReaderSave;
+friend struct WW8FlyPara;
+friend struct WW8SwFlyPara;
+friend class WW8FlySet;
+friend class SwMSDffManager;
+friend class WW8FormulaControl;
+
+ SvStorage* pStg; // Input-Storage
+ SvStream* pStrm; // Input-(Storage)Stream
+ SvStream* pTableStream; // Input-(Storage)Stream
+ SvStream* pDataStream; // Input-(Storage)Stream
+
+// allgemeines
+ SwDoc& rDoc;
+ SwPaM* pPaM;
+
+ SwWW8FltControlStack* pCtrlStck; // Stack fuer die Attribute
+ SwFltEndStack* pEndStck; // End-Stack fuer die Attribute
+ SwWW8FltControlStack* pRefFldStck; // for Reference Fields
+
+// BYTE* pCharBuf; // Puffer fuer nackten Text
+ SwImportControls *pFormImpl; // Control-Implementierung
+
+ SwFlyFrmFmt* pFlyFmtOfJustInsertedGraphic;
+ WW8Fib* pWwFib;
+ WW8Fonts* pFonts;
+ WW8Dop* pWDop;
+ WW8ListManager* pLstManager;
+ WW8ScannerBase* pSBase;
+ WW8PLCFMan* pPlcxMan;
+
+ WW8RStyle* pStyles; // Pointer auf die Style-Einleseklasse
+ SwFmt* pAktColl; // gerade zu erzeugende Collection
+ // ( ist ausserhalb einer Style-Def immer 0 )
+ SfxItemSet* pAktItemSet; // gerade einzulesende Zeichenattribute
+ // ( ausserhalb des WW8ListManager Ctor's immer 0 )
+ SwWW8StyInf* pCollA; // UEbersetzungs-Array der Styles
+ const SwTxtFmtColl* pDfltTxtFmtColl; // Default
+ SwFmt* pStandardFmtColl; // "Standard"
+
+ SwPageDesc* pPageDesc; // fuer uebernommene KF-Zeilen
+ WW8PLCF_HdFt* pHdFt; // Pointer auf Header / Footer - Scannerklasse
+
+ WW8FlyPara* pWFlyPara; // WW-Parameter
+ WW8SwFlyPara* pSFlyPara; // daraus erzeugte Sw-Parameter
+
+ WW8TabDesc* pTableDesc; // Beschreibung der Tabelleneigenschaften
+
+ SwNumRule* pNumRule; // fuer Nummerierung / Aufzaehlungen im Text
+ WW8_OLST* pNumOlst; // Gliederung im Text
+ SwNodeIndex* pBehindSection;// Node-Index zum Zuruecksetzen des PaM nach einem Bereich
+ SwSection* pNewSection; // last Section that was inserted into the doc
+
+ SwNode* pNode_FLY_AT_CNTNT; // set: WW8SwFlyPara() read: CreateSwTable()
+
+ SwDrawFrmFmt *pDrawFmt; // wie FlyFrmFmt
+ SdrModel* pDrawModel;
+ SdrPage* pDrawPg;
+ SdrObjList* pDrawGroup;
+ SvShorts* pDrawHeight; // Welches Objekt ueberdeckt welches ?
+ EditEngine* pDrawEditEngine;
+
+ SwFieldType* pNumFldType; // fuer Nummernkreis
+
+ SvxMSDffManager* pMSDffManager;
+
+ SvStringsDtor* pAtnNames;
+
+ WW8AuthorInfos* pAuthorInfos;
+
+ SwNodeIndex* pLastPgDeskIdx;// for inserting a section when Ft-/End-Note
+ // with flag 'on end of section' set
+
+ // Ini-Flags:
+ ULONG nIniFlags; // Flags aus der writer.ini
+ ULONG nIniFlags1; // dito ( zusaetzliche Flags )
+// ULONG nIniHdSiz; // dito fuer Header
+ ULONG nIniFtSiz; // dito fuer Default-Size Footer
+ ULONG nFieldFlags; // dito fuer Feldern
+ ULONG nFieldTagAlways[3]; // dito fuers Taggen von Feldern
+ ULONG nFieldTagBad[3]; // dito fuers Taggen von nicht importierbaren F.
+
+ ULONG nLastFlyNode; // Node number of last imported Fly
+
+ ULONG nImportedGraphicsCount; // benoetigt fuer MakeUniqueGraphName()
+
+ ULONG nHdTextHeight; // Hoehe des eingelesenen Headers
+ ULONG nFtTextHeight; // Hoehe des eingelesenen Footers
+
+ ULONG nDrawObjOfs;
+ long nDrawCpO; // Anfang der Txbx-SubDocs
+
+ long nPicLocFc; // Picture Location in File (FC)
+ long nObjLocFc; // Object Location in File (FC)
+
+ INT32 nIniFlyDx; // X-Verschiebung von Flys
+ INT32 nIniFlyDy; // Y-Verschiebung von Flys
+
+ rtl_TextEncoding eTextCharSet; // Default-Charset fuer Text
+ rtl_TextEncoding eStructCharSet; // rtl_TextEncoding fuer interne Strukturen
+ rtl_TextEncoding eFontSrcCharSet; // Source-rtl_TextEncoding fuer aktuellen Font
+ rtl_TextEncoding eFontDstCharSet; // Dest-rtl_TextEncoding fuer aktuellen Font
+ rtl_TextEncoding eHardCharSet; // Hartes rtl_TextEncoding-Attribut
+
+ USHORT nProgress; // %-Angabe fuer Progressbar
+ USHORT nColls; // Groesse des Arrays
+ USHORT nAktColl; // gemaess WW-Zaehlung
+ USHORT nPageDescOffset; // fuer UpdatePageDescs
+ USHORT nDrawTxbx; // Nummer der Textbox ( noetig ?? )
+ USHORT nFldNum; // laufende Nummer dafuer
+ USHORT nLFOPosition;
+
+ short nActSectionNo; // aktuelle Abschnitts-Nummer (in CreateSep() gesetzt)
+ short nCharFmt; // gemaess WW-Zaehlung, <0 fuer keine
+ short nAlign2;
+ short nPgWidth;
+ short nPgTop; // fuer APOs
+ short nPgLeft; // Seitenraender, z.B. fuer APOs, Tabellen
+ short nPgRight; // dito
+
+ short nLeftParaMgn; // Absatz L-Space
+ short nTxtFirstLineOfst; // Absatz 1st line ofset
+
+ short nDrawXOfs, nDrawYOfs;
+ short nDrawXOfs2, nDrawYOfs2;
+
+ sal_Unicode cSymbol; // aktuell einzulesendes Symbolzeichen
+
+
+ BYTE nWantedVersion; // urspruenglich vom Writer
+ // angeforderte WW-Doc-Version
+
+
+ BYTE nSwNumLevel; // LevelNummer fuer Outline / Nummerierung
+ BYTE nWwNumType; // Gliederung / Nummerg / Aufzaehlg
+ BYTE nDrawHeaven, nDrawHell;
+ BYTE nListLevel;
+
+ BYTE nNfcPgn; // Formatting of PageNum
+ BYTE nPgChpDelim; // ChapterDelim from PageNum
+ BYTE nPgChpLevel; // ChapterLevel of Heading from PageNum
+
+ BYTE nCorrIhdt; // used in CreateSep()
+ BOOL bSectionHasATitlePage; // used in CreateSep()
+
+ BOOL bNew; // Neues Dokument ?
+ BOOL bReadNoTbl; // Keine Tabellen
+ BOOL bPgSecBreak; // Page- oder Sectionbreak ist noch einzufuegen
+ BOOL bSpec; // Special-Char im Text folgt
+ BOOL bObj; // Obj im Text
+ BOOL bApo; // FlyFrame, der wegen Winword APO eingefuegt wurde
+ BOOL bTxbxFlySection; // FlyFrame, der als Ersatz fuer Winword Textbox eingefuegt wurde
+ BOOL bHasBorder; // fuer Buendelung der Border
+ BOOL bSymbol; // z.B. Symbol statt Times
+ BOOL bIgnoreText; // z.B. fuer FieldVanish
+ BOOL bDontCreateSep; // e.g. when skipping result of multi-column index-field
+ BOOL bTable; // wird gerade eine Tabelle eingelesen
+ BOOL bTableInApo; // Table is contained in Apo
+ BOOL bWasTabRowEnd; // Tabelle : Row End Mark
+ BOOL bTxtCol; // TextFarbe direkt gesetzt
+ BOOL bShdTxtCol; // Textfarbe indirekt gesetzt ( Hintergrund sw )
+ BOOL bCharShdTxtCol; // Textfarbe indirekt gesetzt ( Zeichenhintergrund sw )
+ BOOL bAnl; // Nummerierung in Bearbeitung
+ // Anl heisst Autonumber level
+
+ BOOL bHdFtFtnEdn; // Spezialtext: Kopf- Fuss- usw.
+ BOOL bFtnEdn; // Fussnote oder Endnote
+ BOOL bIsHeader; // Text aus Header wird gelesen ( Zeilenhoehe )
+ BOOL bIsFooter; // Text aus Footer wird gelesen ( Zeilenhoehe )
+
+ BOOL bIsUnicode; // aktuelles Text-Stueck ist als 2-Bytiger-Unicode kodiert
+ // bitte NICHT als Bitfeld kodieren!
+
+ BOOL bCpxStyle; // Style im Complex Part
+ BOOL bStyNormal; // Style mit Id 0 wird gelesen
+ BOOL bWWBugNormal; // WW-Version nit Bug Dya in Style Normal
+ BOOL bNoAttrImport; // Attribute ignorieren zum Ignorieren v. Styles
+
+ // praktische Hilfsvariablen:
+ BOOL bVer67; // ( (6 == nVersion) || (7 == nVersion) );
+ BOOL bVer6; // (6 == nVersion);
+ BOOL bVer7; // (7 == nVersion);
+ BOOL bVer8; // (8 == nVersion);
+
+ BOOL bPgChpLevel; // ChapterLevel of Heading from PageNum
+ BOOL bEmbeddObj; // EmbeddField gelesen
+ BOOL bFloatingCtrl; // Whether to anchor imported controls as char or para
+
+ BOOL bAktAND_fNumberAcross; // current active Annotated List Deskriptor - ROW flag
+
+ BOOL bNoLnNumYet; // no Line Numbering has been activated yet (we import
+ // the very 1st Line Numbering and ignore the rest)
+ BOOL bRestartLnNumPerSection;
+
+
+
+
+//---------------------------------------------
+
+ void SetLastPgDeskIdx();
+
+ SwPageDesc* CreatePageDesc( SwPageDesc* pFirstPageDesc,
+ SwPaM** ppPaMWanted = 0 );
+ void RemoveCols( SwPageDesc& rPageDesc, SwFmtCol*& rpCol );
+ BOOL SetCols( SwFrmFmt* pFmt, const WW8PLCFx_SEPX* pSep,
+ USHORT nNettoWidth,
+ BOOL bTestOnly = FALSE );
+ void SetPage1( SwPageDesc* pPageDesc, SwFrmFmt &rFmt,
+ const WW8PLCFx_SEPX* pSep, USHORT nLIdx,
+ BOOL bIgnoreCols );
+ void SetHdFt( SwPageDesc* pPageDesc0, SwPageDesc* pPageDesc1,
+ const WW8PLCFx_SEPX* pSep, BYTE nIPara );
+ void GetPageULData( const WW8PLCFx_SEPX* pSep,
+ USHORT nLIdx,
+ BOOL bFirst,
+ WW8ULSpaceData& rData );
+ void SetPageULSpaceItems( SwFrmFmt &rFmt, WW8ULSpaceData& rData );
+
+ void SetPageBorder( SwPageDesc* pPageDesc0, SwPageDesc* pPageDesc1,
+ const WW8PLCFx_SEPX* pSep, USHORT nLIdx );
+ void SetUseOn( SwPageDesc* pPageDesc0, SwPageDesc* pPageDesc1,
+ const WW8PLCFx_SEPX* pSep, BYTE nHdFt );
+ void InsertSectionWithWithoutCols( SwPaM& rMyPaM, const SwFmtCol* pCol );
+ void CreateSep( const long nTxtPos );
+
+ void CopyPageDescHdFt( const SwPageDesc* pOrgPageDesc,
+ SwPageDesc* pNewPageDesc, BYTE nCode );
+
+ void UpdatePageDescs( USHORT nPageDescOffset );
+
+ void DeleteStk(SwFltControlStack* prStck);
+ void DeleteCtrlStk() { DeleteStk( pCtrlStck ); pCtrlStck = 0; }
+ void DeleteEndStk() { DeleteStk( pEndStck ); pEndStck = 0; }
+ void DeleteRefFldStk() { DeleteStk( pRefFldStck); pRefFldStck = 0; }
+
+ BOOL ReadChar( long nPosCp, long nCpOfs );
+ BOOL ReadPlainChars( long& rPos, long nEnd, long nCpOfs );
+ BOOL ReadChars( long& rPos, long nNextAttr, long nTextEnd, long nCpOfs );
+
+
+ void ReadPlainText( long nStartCp, long nTextLen );
+ void ProcessAktCollChange( WW8PLCFManResult& rRes,
+ BOOL* pStartAttr,
+ BOOL bCallProcessSpecial );
+ long ReadTextAttr( long& rTxtPos, BOOL& rbStartLine );
+ void ReadAttrs( long& rNext, long& rTxtPos, BOOL& rbStartLine );
+ void ReadAttrEnds( long& rNext, long& rTxtPos );
+ void ReadText( long nStartCp, long nTextLen, short nType );
+
+ void ReadRevMarkAuthorStrTabl( SvStream& rStrm, INT32 nTblPos, INT32 nTblSiz, SwDoc& rDoc );
+
+ void Read_HdFtFtnText( const SwNodeIndex* pSttIdx, long nStartCp,
+ long nLen, short nType );
+ void Read_HdFt1( BYTE nPara, BYTE nWhichItems, SwPageDesc* pPD );
+ void Read_HdFtText( long nStartCp, long nLen, SwPageDesc* pPD,
+ BOOL bUseLeft, BOOL bFooter );
+
+ BYTE* ReadUntilToken( USHORT& rStrLen, USHORT nMaxLen, BYTE nToken );
+ void ImportTox( int nFldId, String aStr );
+
+ void EndSprm( USHORT nId );
+ void NewAttr( const SfxPoolItem& rAttr );
+
+ BOOL GetFontParams( USHORT, FontFamily&, String&, FontPitch&, rtl_TextEncoding& );
+ BOOL SetNewFontAttr( USHORT nFCode, BOOL bSetEnums=TRUE );
+ void ResetCharSetVars();
+
+ const SfxPoolItem* GetFmtAttr( USHORT nWhich );
+ BYTE HdFtCorrectPara( BYTE nPara );
+ BOOL JoinNode( SwPaM* pPam, BOOL bStealAttr = FALSE );
+
+ BOOL IsBorder( const WW8_BRC* pbrc, BOOL bChkBtwn=FALSE );
+ BOOL SetBorder( SvxBoxItem& pBox, const WW8_BRC* pbrc, BOOL bChkBtwn=FALSE );
+ void GetBorderDistance( WW8_BRC* pbrc, Rectangle& rInnerDist );
+ BOOL SetShadow( SvxShadowItem& rShadow, const SvxBoxItem& rBox, const WW8_BRC pbrc[4] );
+
+ void SetFlyBordersShadow( SfxItemSet& rFlySet,
+ const WW8_BRC pbrc[4], USHORT nInnerMgn );
+
+ BOOL MatchSdrBoxIntoFlyBoxItem( const Color& rLineColor,
+ MSO_LineStyle eLineStyle,
+ USHORT nLineWidth,
+ SvxBoxItem& rBox );
+ void MatchSdrItemsIntoFlySet( SdrObject* pSdrObj,
+ SfxItemSet& aFlySet,
+ MSO_LineStyle eLineStyle,
+ Rectangle& rInnerDist,
+ BOOL bFixSize );
+ void MatchWrapDistancesIntoFlyFmt( SvxMSDffImportRec* pRecord,
+ SwFrmFmt* pFlyFmt );
+
+ void SetCropAtGrfNode( SvxMSDffImportRec* pRecord,
+ SwFrmFmt* pFlyFmt,
+ WW8_FSPA* pF );
+
+ BOOL StartApo( BYTE* pSprm29, BOOL bNowStyleApo );
+ void StopApo();
+ BOOL TestSameApo( BYTE* pSprm29, BOOL bNowStyleApo );
+ BYTE* TestApo( BOOL& rbStartApo, BOOL& rbStopApo, BOOL& rbNowStyleApo,
+ BOOL bInTable, BOOL bTableRowEnd,
+ BOOL bStillInTable );
+ BOOL ProcessSpecial( BOOL bAllEnd, BOOL* pbReSync );
+
+ ULONG ReadWmfHeader( WmfFileHd* pHd, long nPos );
+ BOOL ReadGrafFile( String& rFileName, Graphic*& rpGraphic,
+ const WW8_PIC& rPic, SvStream* pSt, ULONG nFilePos, BOOL* pDelIt );
+
+ SwFrmFmt* MakeGrafByFlyFmt( SdrTextObj* pReplaceTextObj,
+ const SwFrmFmt& rOldFmt,const WW8PicDesc& rPD,
+ const Graphic* pGraph, const String& rFileName,
+ const String& rGrName,const SfxItemSet& rGrfSet,
+ const BOOL bSetToBackground );
+ SwFrmFmt* MakeGrafNotInCntnt(const WW8PicDesc& rPD,
+ const Graphic* pGraph, const String& rFileName,
+ const String& rGrName,const SfxItemSet& rGrfSet );
+ SwFrmFmt* MakeGrafInCntnt(const WW8_PIC& rPic, const WW8PicDesc& rPD,
+ const Graphic* pGraph, const String& rFileName,
+ const String& rGrName,const SfxItemSet& rGrfSet );
+
+ SwFrmFmt* ImportGraf1( WW8_PIC& rPic, SvStream* pSt, ULONG nFilePos );
+ SwFrmFmt* ImportGraf( SdrTextObj* pTextObj = 0,
+ SwFrmFmt* pFlyFmt = 0,
+ BOOL bSetToBackground = FALSE );
+ BOOL ImportURL(String &sURL,String &sMark,WW8_CP nStart);
+
+ SwFrmFmt* ImportOle( const Graphic* = 0, const SfxItemSet* pFlySet = 0 );
+
+ BOOL ImportFormulaControl(WW8FormulaControl &rBox,WW8_CP nStart,
+ SwWw8ControlType nWhich);
+
+ void ImportDop( BOOL bNewDoc );
+ void SetImplicitTab();
+ ULONG LoadDoc1( SwPaM& rPaM ,WW8Glossary *pGloss);
+
+ BOOL StartTable();
+ void TabCellEnd();
+ void StopTable();
+ short GetTableLeft();
+ BOOL IsInvalidOrToBeMergedTabCell() const;
+
+// Brush* Shade1( SwWW8Shade& rRet, WW8_SHD* pS );
+
+ ColorData GetCol( BYTE nIco );
+
+// Nummerierungen / Aufzaehlungen ( Autonumbered List Data Descriptor )
+// Liste: ANLD ( Autonumbered List Data Descriptor )
+// eine Ebene: ANLV ( Autonumber Level Descriptor )
+//
+// Chg7-8:
+// Listen sind in WW8 eigene Strukturen, die ueber folgende drei Tabellen
+// verwaltet werden: rglst, hpllfo und hsttbListNames
+// die Strukturen hierfuer sind: LSTF, LVLF, LFO LFOLVL
+
+ void SetAnlvStrings( SwNumFmt* pNum, WW8_ANLV* pAV, BYTE* pTxt,
+ BOOL bOutline );
+ void SetAnld( SwNumRule* pNumR, WW8_ANLD* pAD, BYTE nSwLevel, BOOL bOutLine );
+ void SetNumOlst( SwNumRule* pNumR, WW8_OLST* pO, BYTE nSwLevel );
+ SwNumRule* GetStyRule();
+
+ void StartAnl( BYTE* pSprm13 );
+ void NextAnlLine( BYTE* pSprm13, BYTE* pS12 = 0 );
+ void StopAnl( BOOL bGoBack = TRUE );
+
+// GrafikLayer
+
+ BOOL MakeUniqueGraphName(String& rName, const String& rFixedPart);
+
+ BOOL ReadGrafStart( void* pData, short nDataSiz, WW8_DPHEAD* pHd,
+ WW8_DO* pDo );
+ void InsertObj( SdrObject* pObj, short nWwHeight );
+ void ReadLine( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadRect( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadElipse( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadArc( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadPolyLine( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ ESelection GetESelection( long nCpStart, long nCpEnd );
+ /*
+ void GetTxbxCharAttrs( SfxItemSet& rS, const WW8PLCFxDesc& rD, BOOL bONLYnPicLocFc );
+ void GetTxbxParaAttrs( SfxItemSet& rS, const WW8PLCFxDesc& rD );
+ */
+ void GetTxbxPapAndCharAttrs( SfxItemSet& rS, const WW8PLCFManResult& rRes );
+ //void InsertTxbxCharAttrs( long nStartCp, long nEndCp, BOOL bONLYnPicLocFc );
+ void InsertTxbxStyAttrs( SfxItemSet& rS, USHORT nColl );
+ //void InsertTxbxParaAttrs( long nStartCp, long nEndCp );
+ void InsertTxbxAttrs( long nStartCp, long nEndCp, BOOL bONLYnPicLocFc );
+
+ BOOL GetTxbxTextSttEndCp( long& rStartCp, long& rEndCp,
+ USHORT nTxBxS, USHORT nSequence );
+ BOOL GetTxbxText( String& rString, long StartCp, long nEndCp );
+ SwFrmFmt* InsertTxbxText(SdrTextObj* pTextObj,
+ Size* pObjSiz,
+ USHORT nTxBxS,
+ USHORT nSequence,
+ long nPosCp,
+ SwFrmFmt* pFlyFmt,
+ BOOL bMakeSdrGrafObj,
+ BOOL& rbEraseTextObj,
+ BOOL* pbTestTxbxContainsText = 0,
+ long* pnStartCp = 0,
+ long* pnEndCp = 0,
+ SvxMSDffImportRec* pRecord = 0);
+ BOOL TxbxChainContainsRealText( USHORT nTxBxS,
+ long& rStartCp,
+ long& rEndCp );
+ void ReadTxtBox( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadCaptionBox( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadGroup( WW8_DPHEAD* pHd, WW8_DO* pDo );
+ void ReadGrafPrimitive( short& rLeft, WW8_DO* pDo );
+ void ReadGrafLayer1( WW8PLCFspecial* pPF, long nGrafAnchorCp );
+ SdrObject* CreateContactObject( SwFlyFrmFmt* pFlyFmt );
+ SwFrmFmt* Read_GrafLayer( long nGrafAnchorCp );
+ void GrafikCtor();
+ void GrafikDtor();
+
+// anderes
+ String GetFieldResult( WW8FieldDesc* pF );
+ void QuoteChar( String& rStr, const sal_Unicode _c, BOOL bAllowCr );
+ void QuoteString( String& rStr, const String& rOrg );
+ void MakeTagString( String& rStr, const String& rOrg );
+ void Read_FieldIniFlags();
+ void UpdateFields();
+// void ConvertFName( String& rName );
+ void ConvertFFileName( String& rName, const String& rRaw );
+ long Read_F_Tag( WW8FieldDesc* pF );
+ void InsertTagField( const USHORT nId, const String& rTagText );
+ long ImportExtSprm( WW8PLCFManResult* pRes, BOOL bStart );
+ void ReadDocInfo();
+
+// Ver8-Listen
+
+ void RegisterNumFmtOnTxtNode( USHORT nActLFO,
+ BYTE nActLevel,
+ BOOL bSetAttr = TRUE );
+ void RegisterNumFmtOnStyle( SwWW8StyInf& rStyleInfo,
+ USHORT nActLFO = USHRT_MAX,
+ BYTE nActLevel = nWW8MaxListLevel );
+ void RegisterNumFmt(USHORT nActLFO, BYTE nActLevel);
+
+// Pictures mit Kode 100, die ueber MsoftbSpContainer abgespeichert sind.
+ BOOL WW8QuickHackForMSDFF_DirectBLIPImport( SvStream& rSt,
+ WW8_PIC& rPic,
+ Graphic& rData,
+ String& rGraphName);
+// spaeter zu ersetzen durch Aufruf in entsprechend erweiterten SvxMSDffManager
+
+
+ const String* GetAnnotationAuthor( short nId );
+
+ // Schnittstellen fuer die Toggle-Attribute
+ void SetToggleAttr( BYTE nAttrId, BOOL bOn );
+ void _ChkToggleAttr( USHORT nOldStyle81Mask, USHORT nNewStyle81Mask );
+
+ void ChkToggleAttr( USHORT nOldStyle81Mask, USHORT nNewStyle81Mask )
+ {
+ if( nOldStyle81Mask != nNewStyle81Mask &&
+ pCtrlStck->GetToggleAttrFlags() )
+ _ChkToggleAttr( nOldStyle81Mask, nNewStyle81Mask );
+ }
+
+public: // eigentlich private, geht aber leider nur public
+ void ConvertUFName( String& rName );
+
+ long Read_Ftn( WW8PLCFManResult* pRes, BOOL );
+ long Read_Field( WW8PLCFManResult* pRes, BOOL );
+ long Read_Book( WW8PLCFManResult* pRes, BOOL bStartAttr );
+ long Read_Piece( WW8PLCFManResult* pRes, BOOL bStartAttr );
+ long Read_And( WW8PLCFManResult* pRes, BOOL bStartAttr );
+
+ // Attribute
+
+ void Read_Special( USHORT, BYTE*, short nLen );
+ void Read_Obj( USHORT, BYTE*, short nLen );
+ void Read_PicLoc( USHORT nId, BYTE* pData, short nLen );
+ void Read_BoldUsw( USHORT nId, BYTE*, short nLen );
+ void Read_SubSuper( USHORT, BYTE*, short nLen );
+ void Read_SubSuperProp( USHORT, BYTE*, short nLen );
+ void Read_Underline( USHORT, BYTE*, short nLen );
+ void Read_TxtColor( USHORT, BYTE*, short nLen );
+ void Read_FontCode( USHORT, BYTE*, short nLen );
+ void Read_FontSize( USHORT, BYTE*, short nLen );
+ void Read_CharSet( USHORT nId, BYTE* pData, short nLen );
+ void Read_Language( USHORT, BYTE*, short nLen );
+ void Read_CColl( USHORT, BYTE*, short nLen );
+ void Read_Kern( USHORT, BYTE* pData, short nLen );
+ void Read_FontKern( USHORT, BYTE* pData, short nLen );
+ void Read_Invisible( USHORT, BYTE* pData, short nLen );
+
+ void Read_NoLineNumb( USHORT nId, BYTE* pData, short nLen );
+
+ void Read_LR( USHORT nId, BYTE*, short nLen );
+ void Read_UL( USHORT nId, BYTE*, short nLen );
+ void Read_LineSpace( USHORT, BYTE*, short nLen );
+ void Read_Justify( USHORT, BYTE*, short nLen );
+ void Read_Hyphenation( USHORT, BYTE* pData, short nLen );
+ void Read_WidowControl( USHORT, BYTE* pData, short nLen );
+ void Read_KeepLines( USHORT, BYTE* pData, short nLen );
+ void Read_KeepParas( USHORT, BYTE* pData, short nLen );
+ void Read_BreakBefore( USHORT, BYTE* pData, short nLen );
+ void Read_ApoPPC( USHORT, BYTE* pData, short nLen );
+
+ void Read_Border( USHORT nId, BYTE* pData, short nLen );
+ void Read_Tab( USHORT nId, BYTE* pData, short nLen );
+ void Read_TabCellDelete( USHORT nId, BYTE* pData, short nLen );
+ void Read_TabCellInsert( USHORT nId, BYTE* pData, short nLen );
+ void Read_Symbol( USHORT nId, BYTE* pData, short nLen );
+ void Read_FldVanish( USHORT nId, BYTE* pData, short nLen );
+
+ // Revision Marks ( == Redlining )
+
+ // insert or delete content (change char attributes resp.)
+ void Read_CRevisionMark(SwRedlineType eType,
+ USHORT nId,
+ BYTE* pData,
+ short nLen );
+ // insert new content
+ void Read_CFRMark( USHORT nId, BYTE* pData, short nLen );
+ // delete old content
+ void Read_CFRMarkDel( USHORT nId, BYTE* pData, short nLen );
+ // change properties of content (e.g. char formating)
+ void Read_CPropRMark( USHORT nId, BYTE* pData, short nLen ); // complex!
+
+
+ void Read_TabRowEnd( USHORT, BYTE* pData, short nLen );
+ void Read_Shade( USHORT, BYTE* pData, short nLen );
+ void Read_ANLevelNo( USHORT, BYTE* pData, short nLen );
+ void Read_ANLevelDesc( USHORT, BYTE* pData, short nLen );
+
+ void Read_POutLvl( USHORT nId, BYTE* pData, short nLen ); // Gliederungsebene Ver8
+
+ void Read_OLST( USHORT, BYTE* pData, short nLen );
+
+ void Read_CharShadow( USHORT, BYTE* pData, short nLen );
+ void Read_CharHighlight( USHORT, BYTE* pData, short nLen );
+ // Ver8-Listen
+
+ void Read_ListLevel( USHORT nId, BYTE* pData, short nLen);
+ void Read_LFOPosition( USHORT nId, BYTE* pData, short nLen);
+ BOOL SetTxtFmtCollAndListLevel( const SwPaM& rRg,
+ SwWW8StyInf& rStyleInfo,
+ BOOL bReset = TRUE );
+
+ // FastSave-Attribute
+
+ void Read_StyleCode( USHORT, BYTE* pData, short nLen );
+ void Read_Majority( USHORT, BYTE* pData, short nLen );
+
+ // Felder
+
+ eF_ResT Read_F_Nul( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_Input( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_InputVar( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_ANumber( WW8FieldDesc*, String& );
+ eF_ResT Read_F_DocInfo( WW8FieldDesc* pF, String& rStr );
+ eF_ResT Read_F_Author( WW8FieldDesc*, String& );
+ eF_ResT Read_F_TemplName( WW8FieldDesc*, String& );
+ eF_ResT Read_F_DateTime( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_FileName( WW8FieldDesc*, String& );
+ eF_ResT Read_F_Anz( WW8FieldDesc* pF, String& );
+ eF_ResT Read_F_CurPage( WW8FieldDesc*, String& );
+ eF_ResT Read_F_Ref( WW8FieldDesc* pF, String& );
+
+ eF_ResT Read_F_Set( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_PgRef( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_NoteReference( WW8FieldDesc* pF, String& rStr );
+
+ eF_ResT Read_F_Tox( WW8FieldDesc* pF, String& rStr );
+ eF_ResT Read_F_Symbol( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_Embedd( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr );
+ eF_ResT Read_F_FormCheckBox( WW8FieldDesc* pF, String& rStr );
+ eF_ResT Read_F_FormListBox( WW8FieldDesc* pF, String& rStr );
+ eF_ResT Read_F_Macro( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_DBField( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_DBNext( WW8FieldDesc*, String& );
+ eF_ResT Read_F_DBNum( WW8FieldDesc*, String& );
+ eF_ResT Read_F_IncludePicture( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_IncludeText( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_Seq( WW8FieldDesc*, String& rStr );
+
+ eF_ResT Read_F_OCX( WW8FieldDesc*, String& rStr );
+ eF_ResT Read_F_Hyperlink( WW8FieldDesc*, String& rStr );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> InsertControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rFComp,
+ const ::com::sun::star::awt::Size& rSize,
+ //const ::com::sun::star::uno::Reference< ::com::sun::star::size::XSize>& rSize,
+ BOOL bFloatingCtrl = FALSE );
+
+ void BuildInputField( USHORT eType, const String& rParam );
+ void DeleteFormImpl();
+
+ // Ver8: Listen Manager
+ short ImportSprm( BYTE* pPos, short nSprmsLen, USHORT nId = 0 );
+
+ const WW8Fib& GetFib() const { return *pWwFib; }
+ SwDoc& GetDoc() const { return rDoc; }
+ USHORT GetNAktColl() const { return nAktColl; }
+ void SetNAktColl( USHORT nColl ) { nAktColl = nColl; }
+ //SfxItemSet* GetAktItemSet() { return pAktItemSet; }
+ void SetAktItemSet( SfxItemSet* pItemSet ) { pAktItemSet = pItemSet; }
+ const USHORT StyleUsingLFO( USHORT nLFOIndex ) const ;
+ const SwFmt* GetStyleWithOrgWWName( String& rName ) const ;
+
+
+
+ SwWW8ImplReader( BYTE nVersionPara, SvStorage* pStorage,
+ SvStream* pSt, SwDoc& rD, BOOL bNewDoc );
+
+ const ULONG GetFieldFlags() const{ return nFieldFlags; }
+ const ULONG GetIniFlags() const{ return nIniFlags; }
+ const ULONG GetIniFlags1() const{ return nIniFlags1; }
+
+ // Laden eines kompletten DocFiles
+ ULONG LoadDoc( SwPaM&,WW8Glossary *pGloss=0);
+};
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par.hxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.95 2000/09/18 16:05:00 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.94 2000/08/22 17:40:57 cmc
+ #77315# 95 Formulas, bad string read
+
+ Revision 1.93 2000/08/22 17:08:58 cmc
+ #77743# OLE Import, bad seek & bad FilterOptions
+
+ Revision 1.92 2000/08/18 09:48:28 khz
+ Import Line Numbering (restart on new section)
+
+ Revision 1.91 2000/08/18 06:47:26 khz
+ Import Line Numbering
+
+ Revision 1.90 2000/07/28 15:37:19 khz
+ #73796# don't delete NumRule from Attr but set it into pDoc
+
+ Revision 1.89 2000/07/27 10:21:26 khz
+ #73796# stop ANList when opening next cell in a row and !pAktANLD->fNumberAcross
+
+ Revision 1.88 2000/07/25 15:16:25 khz
+ #76811# read/write AutoHyphenation flag from/into Document Properties
+
+ Revision 1.87 2000/07/17 13:46:56 khz
+ #73987# check if sprmSNfcPgn should cause section change or not
+
+ Revision 1.86 2000/07/11 11:39:10 khz
+ #76673# prepare implementation of sprmTDelete and sprmTInsert
+
+ Revision 1.85 2000/07/07 12:48:54 jp
+ must changes VCL
+
+ Revision 1.84 2000/06/28 08:07:39 khz
+ #70915# Insert Section if end-note with flag 'on end of section' found
+
+ Revision 1.83 2000/06/15 15:23:39 cmc
+ #75669# 97Controls Import fixes
+
+ Revision 1.82 2000/05/31 12:22:57 khz
+ Changes for Unicode
+
+ Revision 1.81 2000/05/25 08:06:45 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.80 2000/05/24 08:56:06 jp
+ Bugfixes for Unicode
+
+ Revision 1.79 2000/05/17 16:41:43 khz
+ Changes for unicode (2)
+
+ Revision 1.78 2000/05/16 11:06:17 khz
+ Unicode code-conversion
+
+ Revision 1.77 2000/03/27 15:55:24 cmc
+ #74329# Ported WW97 Controls to uno codebase
+
+ Revision 1.76 2000/03/24 10:50:36 khz
+ Task #74368# IsInvalidOrToBeMergedTabCell() stops duplicate reset of NumRule
+
+ Revision 1.75 2000/03/21 15:04:57 os
+ UNOIII
+
+ Revision 1.74 2000/03/10 14:29:32 khz
+ Task #65529# improve detection if Section is identical with previous
+
+ Revision 1.73 2000/03/03 15:20:02 os
+ StarView remainders removed
+
+ Revision 1.72 2000/02/18 09:36:56 cmc
+ #69372# Improved Hyperlink Importing for WW97
+
+ Revision 1.71 2000/02/14 14:39:02 jp
+ #70473# changes for unicode
+
+ Revision 1.70 2000/02/14 09:10:28 cmc
+ #72579# working glossary implementation
+
+ Revision 1.68 2000/02/09 08:57:23 khz
+ Task #72647# Read SPRMs that are stored in piece table grpprls (2)
+
+ Revision 1.67 2000/02/02 18:07:39 khz
+ Task #69885# Read SPRMs that are stored in piece table grpprls
+
+ Revision 1.66 2000/01/06 15:23:45 khz
+ Task #71411# Let last Section be unbalanced
+
+ Revision 1.65 1999/12/23 14:03:10 khz
+ Task #68143# avoid attributes atached solely to Cell-End marks
+
+ Revision 1.64 1999/12/22 18:03:16 khz
+ Task #70919# look if ParaStyle is different behind filed than it was before
+
+ Revision 1.63 1999/12/14 14:22:38 khz
+ Task #70815# Avoid typecast when calling MatchSdrItemsIntoFlySet()
+
+ Revision 1.62 1999/12/09 19:12:20 khz
+ Task #65551# nSkipPos had erroneously been a member instead of local variable
+
+ Revision 1.61 1999/12/09 16:46:29 khz
+ Task #69180# allow Tabs if right of 1st-line-start OR right of paragraph margin
+
+ Revision 1.60 1999/12/01 14:35:45 khz
+ Task #68488# Graphics in Sections with more than one Column
+
+ Revision 1.59 1999/11/29 11:09:36 khz
+ Task #70177# SetDerivedFrom( RES_POOL_COL_STANDARD )
+
+ Revision 1.58 1999/11/19 14:57:07 khz
+ Task #68651# Store state of bSymbol and nSymbol in WW8ReaderSave class
+
+ Revision 1.57 1999/11/12 13:04:59 jp
+ new: read sprmCHighlight
+
+ Revision 1.56 1999/11/05 17:05:28 khz
+ prevent from erroneous Table-Restart when sprm24 missing
+
+ Revision 1.55 1999/11/02 15:59:34 khz
+ import new TOX_CONTENT and TOX_INDEX features (2)
+
+ Revision 1.54 1999/10/29 12:07:35 khz
+ import new TOX_CONTENT and TOX_INDEX features
+
+ Revision 1.53 1999/10/08 09:25:39 khz
+ Import Redlining
+
+ Revision 1.52 1999/08/30 19:52:58 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.51 30 Aug 1999 21:52:58 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.50 12 Aug 1999 13:57:52 KHZ
+ Task #67668# TestApo() modified
+
+ Rev 1.49 09 Aug 1999 14:16:08 JP
+ read W95 format from stream
+
+ Rev 1.48 12 Jul 1999 16:58:20 KHZ
+ Task #66194# 1. Sections with cols, 2. App.Node before PgBreak if Fly in node
+
+ Rev 1.47 05 Jul 1999 19:30:52 KHZ
+ Task #66194# Sections with columns
+
+ Rev 1.46 21 Jun 1999 10:24:40 KHZ
+ Reference field (page, bookmark, footnote) part#2
+
+ Rev 1.45 18 Jun 1999 15:53:50 KHZ
+ Reference field (page, bookmark, footnote) part#1
+
+ Rev 1.44 10 Jun 1999 17:58:52 KHZ
+ use FOUR different inner distances with SvxBoxItem
+
+ Rev 1.43 09 Jun 1999 18:25:00 KHZ
+ use FOUR different inner distances with SvxBoxItem
+
+ Rev 1.42 26 Apr 1999 17:40:20 KHZ
+ Task #61381# Attribute von Textboxen in denen NUR EINE Grafik steht
+
+ Rev 1.41 09 Apr 1999 18:01:38 KHZ
+ Task #64348# Bei Listen-Overrides nur bei Ungleichheit neue Liste anlegen!
+
+ Rev 1.40 18 Mar 1999 09:56:52 JP
+ Task #63049#: Numerierung mit rel. Einzuegen
+
+ Rev 1.39 10 Mar 1999 15:11:10 KHZ
+ Task #62521# Einlesen von Sonderzeichen
+
+ Rev 1.38 08 Mar 1999 11:51:30 KHZ
+ Task #57749# Writer kann jetzt spaltige Bereiche
+
+ Rev 1.37 26 Feb 1999 14:43:38 KHZ
+ Task #59715# Behandlung von Section breaks
+
+ Rev 1.36 17 Feb 1999 15:23:42 KHZ
+ Task #61382# jetzt auch Textbox-Grafiken im Hintergrund ( SvxOpaqItem(FALSE) )
+
+*************************************************************************/
+
+#endif
+
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
new file mode 100644
index 000000000000..3a42cb81be0b
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -0,0 +1,3084 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#include <tools/solar.h>
+#include "pam.hxx" // fuer SwPam
+#include "doc.hxx"
+
+#ifndef _DOCARY_HXX
+#include "docary.hxx"
+#endif
+
+#include "ndtxt.hxx" // class SwTxtNode
+#include "hintids.hxx"
+#include "paratr.hxx" // SwNumRuleItem
+
+// Folgende sollten demnaechst ins Precompiled-Header-File
+#include "poolfmt.hxx" // RES_POOLCOLL_STANDARD
+#include "swtable.hxx" // class SwTableLines, ...
+#include "tblsel.hxx" // class _SwSelBox
+#include "mdiexp.hxx" // Progress
+
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SFXDOCINF_HXX //autogen
+#include <sfx2/docinf.hxx>
+#endif
+#ifndef _SVX_ORPHITEM_HXX //autogen
+#include <svx/orphitem.hxx>
+#endif
+#ifndef _SVX_WIDWITEM_HXX //autogen
+#include <svx/widwitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_HYZNITEM_HXX //autogen
+#include <svx/hyznitem.hxx>
+#endif
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifdef DEBUG
+#ifndef _SV_SOUND_HXX //autogen
+ #include <vcl/sound.hxx>
+#endif
+#endif
+
+// Folgende bleiben hier
+#include "fltshell.hxx" // fuer den Attribut Stack
+#include "ww8struc.hxx" // struct TC
+#include "ww8par.hxx"
+#include "ww8par2.hxx"
+
+#ifndef _SV_FONTTYPE_HXX //autogen
+#include <vcl/fonttype.hxx>
+#endif
+#ifndef _SV_FONT_HXX //autogen
+#include <vcl/font.hxx>
+#endif
+
+
+#define DELETEAZ( p ) { delete[]( p ); p = 0; };
+
+
+
+
+//-----------------------------------------
+// Tabellen
+//-----------------------------------------
+
+
+#define MAX_COL 64 // WW6-Beschreibung: 32, WW6-UI: 31
+ // WW8-UI: 63!
+
+struct WW8SelBoxInfo: public SwSelBoxes_SAR
+{
+ short nGroupXStart;
+ short nGroupWidth;
+
+ WW8SelBoxInfo( short nXCenter, short nWidth ): nGroupXStart( nXCenter ), nGroupWidth( nWidth ){}
+};
+
+typedef WW8SelBoxInfo* WW8SelBoxInfoPtr;
+
+SV_DECL_PTRARR_DEL(WW8MergeGroups, WW8SelBoxInfoPtr, 16,16);
+SV_IMPL_PTRARR( WW8MergeGroups, WW8SelBoxInfoPtr );
+
+struct WW8TabBandDesc{
+ WW8TabBandDesc* pNextBand;
+ short nGapHalf;
+ short nLineHeight;
+ short nRows;
+ short nCenter[MAX_COL + 1]; // X-Rand aller Zellen dieses Bandes
+ short nWidth[MAX_COL + 1]; // Laenge aller Zellen dieses Bandes
+ short nWwCols; // BYTE wuerde reichen, alignment -> short
+ short nSwCols; // SW: so viele Spalten fuer den Writer
+ BOOL bLEmptyCol; // SW: Links eine leere Zusatz-Spalte
+ BOOL bREmptyCol; // SW: dito rechts
+ WW8_TCell* pTCs;
+ WW8_SHD* pSHDs;
+
+
+ // nur fuer WW6-7: diese Zelle hat WW-Flag bMerged (horizontal) gesetzt
+ //BOOL bWWMergedVer6[MAX_COL];
+
+
+ BOOL bExist[MAX_COL]; // Existiert diese Zelle ?
+ UINT8 nTransCell[MAX_COL + 2]; // UEbersetzung WW-Index -> SW-Index
+
+ WW8TabBandDesc() { memset( this, 0, sizeof( *this ) ); };
+ WW8TabBandDesc( WW8TabBandDesc& rBand ); // tief kopieren
+ ~WW8TabBandDesc() { delete[]( pTCs ); pTCs = 0; delete[]( pSHDs ); };
+ void ReadDef( BOOL bVer67, BYTE* pS );
+ void ProcessSprmTSetBRC( BOOL bVer67, BYTE* pParamsTSetBRC );
+ void ProcessSprmTDxaCol( BOOL bVer67, BYTE* pParamsTDxaCol );
+ void ProcessSprmTDelete( BOOL bVer67, BYTE* pParamsTDelete );
+ void ReadShd( SVBT16* pS );
+};
+
+class WW8TabDesc
+{
+ WW8_BRC aDefBrcs[6];
+
+ SvStringsDtor aNumRuleNames;
+
+ SwWW8ImplReader* pIo;
+
+ WW8TabBandDesc* pFirstBand;
+ WW8TabBandDesc* pActBand;
+
+ SwPosition* pTmpPos;
+
+ const SwTable* pTable; // Tabelle
+ SwTableNode* pTblNd; // Tabellen-Node
+ const SwTableLines* pTabLines; // Zeilen-Array davon
+ SwTableLine* pTabLine; // akt. Zeile
+ SwTableBoxes* pTabBoxes; // Boxen-Array in akt. Zeile
+ SwTableBox* pTabBox; // akt. Zelle
+
+ WW8MergeGroups* pMergeGroups; // Listen aller zu verknuepfenden Zellen
+
+ WW8_TCell* pAktWWCell;
+
+ short nRows;
+ short nDefaultSwCols;
+ short nBands;
+ short nMinLeft;
+ short nMaxRight;
+ short nSwWidth;
+
+ BOOL bOk;
+ BOOL bHeader;
+ BOOL bBorderDefaults;
+ BOOL bClaimLineFmt;
+ SwHoriOrient eOri;
+ // 2. allgemeine Verwaltungsinfo
+ short nAktRow;
+ short nAktBandRow; // SW: in dieser Zeile des akt. Bandes bin ich
+ // 3. Verwaltungsinfo fuer Writer
+ short nAktCol;
+
+
+ // 4. Methoden
+
+ USHORT GetLogicalWWCol() const;
+ void SetTabBorders( SwTableBox* pBox, short nIdx );
+ void SetTabShades( SwTableBox* pBox, short nWwIdx );
+ void CalcDefaults();
+ BOOL SetPamInCell( short nWwCol, BOOL bPam, BOOL bCheckForMerge );
+ void DeleteCells( short nDelete );
+ void InsertCells( short nIns );
+ void AdjustNewBand( SwWW8ImplReader* pReader );
+
+ // durchsucht pMergeGroups, meldet Index der ersten, passenden Gruppe bzw. -1
+ // Details siehe bei der Implementierung
+ BOOL FindMergeGroup( short nX1, short nWidth, BOOL bExact, short& nMGrIdx );
+
+ // einzelne Box ggfs. in eine Merge-Gruppe aufnehmen
+ // (die Merge-Gruppen werden dann spaeter auf einen Schlag abgearbeitet)
+ SwTableBox* UpdateTableMergeGroup( WW8_TCell& rCell,
+ WW8SelBoxInfo* pActGroup,
+ SwTableBox* pActBox,
+ USHORT nCol );
+public:
+ BOOL IsValidCell( short nCol ) const;
+
+ WW8TabDesc( SwWW8ImplReader* pIoClass );
+ BOOL Ok() const { return bOk; }
+ void CreateSwTable();
+ void TableCellEnd();
+ void FinishSwTable();
+ short GetMinLeft() const { return nMinLeft; }
+ ~WW8TabDesc();
+
+ const WW8_TCell* GetAktWWCell() const { return pAktWWCell; }
+ const short GetAktCol() const { return nAktCol; }
+ const String& GetNumRuleName() const; // find name of numrule valid for current WW-COL
+ void SetNumRuleName( const String& rName );
+};
+
+
+
+
+
+
+//---------------------------------------------------------------------
+// Hilfroutinen fuer Kapitelnummerierung und Aufzaehlung / Gliederung
+//---------------------------------------------------------------------
+
+static void SetBaseAnlv( SwNumFmt* pNum, WW8_ANLV* pAV )
+{
+ static SvxExtNumType eNumA[8] = { SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER,
+ SVX_NUM_CHARS_UPPER_LETTER_N, SVX_NUM_CHARS_LOWER_LETTER_N, SVX_NUM_ARABIC,
+ SVX_NUM_ARABIC, SVX_NUM_ARABIC };
+
+ static SvxAdjust eAdjA[4] = { SVX_ADJUST_LEFT,
+ SVX_ADJUST_RIGHT, SVX_ADJUST_LEFT, SVX_ADJUST_LEFT };
+// eigentlich folgende 2, aber Writer-UI bietet es nicht an
+// SVX_ADJUST_CENTER, SVX_ADJUST_BLOCKLINE };
+
+ pNum->eType = ( SVBT8ToByte( pAV->nfc ) < 8 ) ?
+ eNumA[SVBT8ToByte( pAV->nfc ) ] : SVX_NUM_NUMBER_NONE;
+// pNum->bInclUpperLevel = pAV->fPrev;
+ pNum->SetInclUpperLevel( ( SVBT8ToByte( pAV->aBits1 ) & 0x4 ) >> 2 );
+ pNum->SetStartValue( (USHORT)SVBT16ToShort( pAV->iStartAt ) );
+// pNum->eNumAdjust = eAdjA[pAV->jc];
+ pNum->SetAdjust( eAdjA[SVBT8ToByte( pAV->aBits1 ) & 0x3] );
+
+ pNum->SetCharTextOffset( (USHORT)SVBT16ToShort( pAV->dxaSpace ) );
+ INT16 nIndent = Abs((INT16)SVBT16ToShort( pAV->dxaIndent ));
+ if( SVBT8ToByte( pAV->aBits1 ) & 0x08 ){ // fHang
+ pNum->SetFirstLineOffset( -nIndent );
+ pNum->SetLSpace( nIndent );
+ pNum->SetAbsLSpace( nIndent );
+ }else{
+ pNum->SetCharTextOffset( nIndent ); // Breite der Nummer fehlt
+ }
+ if( SVBT8ToByte( pAV->nfc ) == 5 || SVBT8ToByte( pAV->nfc ) == 7 )
+ {
+ String sP( pNum->GetPostfix() );
+ sP.Insert( '.', 0 );
+ pNum->SetPostfix( sP ); // Ordinalzahlen
+ }
+}
+
+void SwWW8ImplReader::SetAnlvStrings( SwNumFmt* pNum, WW8_ANLV* pAV, BYTE* pTxt,
+ BOOL bOutline )
+{
+ BOOL bInsert = FALSE; // Default
+ CharSet eCharSet = eStructCharSet;
+
+ const WW8_FFN* pF = pFonts->GetFont( SVBT16ToShort( pAV->ftc ) ); // FontInfo
+ BOOL bSymbol = pF && ( pF->chs == 2 ); // Symbol/WingDings/...
+
+ String sTxt( (sal_Char*)pTxt, SVBT8ToByte( pAV->cbTextBefore )
+ + SVBT8ToByte( pAV->cbTextAfter ), eCharSet );
+
+ if( bOutline )
+ { // Gliederung
+ if( !pNum->IsInclUpperLevel() // es sind <= 1 Nummern anzuzeigen
+ || pNum->eType == SVX_NUM_NUMBER_NONE ){ // oder dieser Level hat keine
+ // eigenen Ziffern
+ bInsert = TRUE; // -> dann uebernehme Zeichen
+
+ // replace by simple Bullet ?
+ if( bSymbol )
+ //JP 14.08.96: cBulletChar benutzen, damit auf dem MAC
+ // richtig gemappt wird
+ sTxt.Fill( SVBT8ToByte( pAV->cbTextBefore )
+ + SVBT8ToByte( pAV->cbTextAfter ), cBulletChar );
+ }
+ }
+ else
+ { // Nummerierung / Aufzaehlung
+ bInsert = TRUE;
+// if( SVBT16ToShort( pAV->ftc ) == 1
+// || SVBT16ToShort( pAV->ftc ) == 3 ){ // Symbol / WingDings
+ if( bSymbol )
+ {
+ FontFamily eFamily;
+ String aName;
+ FontPitch ePitch;
+
+ if( GetFontParams( SVBT16ToShort( pAV->ftc ), eFamily, aName,
+ ePitch, eCharSet ) ){
+// USHORT nSiz = ( SVBT16ToShort( pAV->hps ) ) ?
+// SVBT16ToShort( pAV->hps ) : 24; // Groesse in 1/2 Pt
+// darf nach JP nicht gesetzt werden, da immer die Size
+// genommen wird, die am ZeilenAnfang benutzt wird
+ Font aFont;
+ aFont.SetName( aName );
+ aFont.SetFamily( eFamily );
+// aFont.SetPitch( ePitch ); // darf nach JP nicht
+ aFont.SetCharSet( eCharSet );
+ pNum->eType = SVX_NUM_CHAR_SPECIAL;
+// if( pAV->ico ) // geht in UI und SWG-Writer/Reader nicht
+// aFont.SetColor( Color( GetCol( pAV->ico ) ) );
+ pNum->SetBulletFont( &aFont );
+
+ // take only the very first character
+ if( pAV->cbTextBefore || pAV->cbTextAfter)
+ pNum->SetBulletChar( sTxt.GetChar( 0 ) );
+ else
+ pNum->SetBulletChar( 0xF000 + 183 );
+ }
+ }
+ }
+ if( bInsert )
+ {
+ if( pAV->cbTextBefore )
+ {
+ String sP( sTxt.Copy( 0, SVBT8ToByte( pAV->cbTextBefore ) ) );
+ pNum->SetPrefix( sP );
+ }
+ if( SVBT8ToByte( pAV->cbTextAfter ) )
+ {
+ String sP( pNum->GetPostfix() );
+ sP.Insert( sTxt.Copy( SVBT8ToByte( pAV->cbTextBefore ),
+ SVBT8ToByte( pAV->cbTextAfter ) ) );
+ pNum->SetPostfix( sP );
+ }
+// Die Zeichen vor und hinter mehreren Ziffern koennen leider nicht uebernommen
+// werden, da sie der Writer ganz anders behandelt und das Ergebnis i.A.
+// schlechter als ohne waere.
+ }
+}
+
+// SetAnld bekommt einen WW-ANLD-Descriptor und einen Level und modifiziert
+// die durch pNumR anggebeben NumRules. Wird benutzt fuer alles ausser
+// Gliederung im Text
+void SwWW8ImplReader::SetAnld( SwNumRule* pNumR, WW8_ANLD* pAD, BYTE nSwLevel,
+ BOOL bOutLine )
+{
+ SwNumFmt aNF;
+ if( pAD )
+ { // Es gibt einen Anld-Sprm
+ bAktAND_fNumberAcross = 0 != SVBT8ToByte( pAD->fNumberAcross );
+ WW8_ANLV* pAV = &pAD->eAnlv;
+ SetBaseAnlv( &aNF, pAV ); // Setze Basis-Format
+ SetAnlvStrings( &aNF, pAV, pAD->rgchAnld, bOutLine );// und Rest
+ }
+ pNumR->Set( nSwLevel, aNF );
+}
+
+
+
+//-------------------------------------------------------
+// Kapitelnummerierung und Kapitelbullets
+//-------------------------------------------------------
+// Kapitelnummerierung findet in Styledefinionen statt. Sprm 13 gibt den Level
+// an, Sprm 12 den Inhalt
+
+SwNumRule* SwWW8ImplReader::GetStyRule()
+{
+ if( pStyles->pStyRule ) // Bullet-Style bereits vorhanden
+ return pStyles->pStyRule;
+
+ const String aBaseName(WW8_ASCII2STR( "WW8StyleNum" ));
+ const String aName( rDoc.GetUniqueNumRuleName( &aBaseName, FALSE ) );
+
+ USHORT nRul = rDoc.MakeNumRule( aName );
+ pStyles->pStyRule = rDoc.GetNumRuleTbl()[nRul];
+ pStyles->pStyRule->SetAutoRule( FALSE );// Auto == FALSE -> Nummerierungsvorlage
+
+ return pStyles->pStyRule;
+}
+
+void SwWW8ImplReader::Read_ANLevelNo( USHORT, BYTE* pData, short nLen ) // Sprm 13
+{
+ nSwNumLevel = 0xff; // Default: ungueltig
+
+ if( nLen <= 0 )
+ return;
+
+ // StyleDef ?
+ if( pAktColl )
+ {
+ if( pCollA[nAktColl].bColl // nur fuer SwTxtFmtColl, nicht CharFmt
+ && *pData // WW: 0 = no Numbering
+ && !( nIniFlags & WW8FL_NO_OUTLINE ) )
+ {
+ if( *pData <= MAXLEVEL // Bereich WW:1..9 -> SW:0..8
+ && *pData <= 9 ) // keine Aufzaehlung / Nummerierung
+ {
+ nSwNumLevel = *pData - 1;
+ if( !bNoAttrImport )
+ ((SwTxtFmtColl*)pAktColl)->SetOutlineLevel( nSwNumLevel );
+ // Bei WW-NoNumbering koennte auch NO_NUMBERING gesetzt
+ // werden. ( Bei normaler Nummerierung muss NO_NUM gesetzt
+ // werden: NO_NUM : Nummerierungs-Pause,
+ // NO_NUMBERING : ueberhaupt keine Nummerierung )
+
+ }
+ else if( *pData == 10 || *pData == 11 )
+ {
+ pStyles->nWwNumLevel = *pData; // Typ merken, der Rest
+ // geschieht bei Sprm 12
+ }
+ }
+ }
+ else
+ { // !StyleDef
+ if( !bAnl && !( nIniFlags & WW8FL_NO_NUMRULE ) )
+ {
+ StartAnl( pData ); // Anfang der Gliederung / Aufzaehlung
+ }
+ }
+}
+
+void SwWW8ImplReader::Read_ANLevelDesc( USHORT, BYTE* pData, short nLen ) // Sprm 12
+{
+ if( !pAktColl || nLen <= 0 // nur bei Styledef
+ || !pCollA[nAktColl].bColl // CharFmt -> ignorieren
+ || ( nIniFlags & WW8FL_NO_OUTLINE ) ){
+ nSwNumLevel = 0xff;
+ return;
+ }
+ if( nSwNumLevel <= MAXLEVEL // Bereich WW:1..9 -> SW:0..8
+ && nSwNumLevel <= 9 ){ // keine Aufzaehlung / Nummerierung
+
+ // Falls bereits direkt oder durch
+ // Vererbung NumruleItems gesetzt sind,
+ // dann jetzt ausschalten #56163
+ pAktColl->SetAttr( SwNumRuleItem() );
+
+ String aName(WW8_ASCII2STR( "Outline" ));
+ SwNumRule aNR( rDoc.GetUniqueNumRuleName(&aName), OUTLINE_RULE );
+ aNR = *rDoc.GetOutlineNumRule();
+
+ SetAnld( &aNR, (WW8_ANLD*)pData, nSwNumLevel, TRUE );
+
+ // fehlende Level muessen nicht aufgefuellt werden
+
+ rDoc.SetOutlineNumRule( aNR );
+ }else if( pStyles->nWwNumLevel == 10 || pStyles->nWwNumLevel == 11 ){
+ SwNumRule* pNR = GetStyRule();
+ SetAnld( pNR, (WW8_ANLD*)pData, 0, FALSE );
+ pAktColl->SetAttr( SwNumRuleItem( pNR->GetName() ) );
+ pCollA[nAktColl].bHasStyNumRule = TRUE;
+ }
+}
+
+//-----------------------------------------
+// Nummerierung / Aufzaehlung
+//-----------------------------------------
+
+// SetNumOlst() traegt die Numrules fuer diese Zeile ins SwNumFmt ein
+// ( nur fuer Gliederungen im Text; Aufzaehlungen / Nummerierungen laufen
+// ueber ANLDs )
+// dabei wird die Info aus dem OLST geholt und nicht aus dem ANLD ( s.u. )
+void SwWW8ImplReader::SetNumOlst( SwNumRule* pNumR, WW8_OLST* pO, BYTE nSwLevel )
+{
+ SwNumFmt aNF;
+ WW8_ANLV* pAV = &pO->rganlv[nSwLevel];
+ SetBaseAnlv( &aNF, pAV ); // Setze Basis-Format
+ // ... und nun die Strings
+ int i, nTxtOfs = 0;
+ register WW8_ANLV* pAV1; // suche String-Positionen
+ for( i = 0, pAV1 = pO->rganlv; i < nSwLevel; i++, pAV1++ ){
+ nTxtOfs += SVBT8ToByte( pAV1->cbTextBefore )
+ + SVBT8ToByte( pAV1->cbTextAfter );
+ }
+
+ SetAnlvStrings( &aNF, pAV, pO->rgch + nTxtOfs, TRUE ); // und rein
+ pNumR->Set( nSwLevel, aNF );
+}
+
+
+
+
+// der OLST kommt am Anfang jeder Section, die Gliederungen enthaelt. Die ANLDs,
+// die an jeder Gliederungszeile haengen, enthalten nur Stuss, also werden die
+// OLSTs waehrend der Section gemerkt, damit die Informationen beim Auftreten
+// von Gliederungsabsaetzen zugreifbar ist.
+void SwWW8ImplReader::Read_OLST( USHORT, BYTE* pData, short nLen )
+{
+ if( nIniFlags & WW8FL_NO_NUMRULE )
+ return;
+ if( nLen <= 0 ){
+ DELETEZ( pNumOlst );
+ return;
+ }
+ if( pNumOlst )
+ delete( pNumOlst ); // nur sicherheitshalber
+ pNumOlst = new WW8_OLST;
+ if( nLen < sizeof( WW8_OLST ) ) // auffuellen, falls zu kurz
+ memset( pNumOlst, 0, sizeof( *pNumOlst ) );
+ *pNumOlst = *(WW8_OLST*)pData;
+}
+
+// StartAnl wird am Anfang eines Zeilenbereichs gerufen,
+// der Gliederung / Nummerierung / Aufzaehlung enthaelt
+#define MAX_ANLV_NUM 12
+void SwWW8ImplReader::StartAnl( BYTE* pSprm13 )
+{
+ bAktAND_fNumberAcross = FALSE;
+
+ BYTE nT = GetNumType( *pSprm13 );
+ if( nT == WW8_Pause || nT == WW8_None )
+ return;
+
+ nWwNumType = nT;
+
+ // check for COL numbering:
+ BYTE* pS12 = 0;// sprmAnld
+ String sNumRule;
+ if( pTableDesc )
+ {
+ sNumRule = pTableDesc->GetNumRuleName();
+ if( sNumRule.Len() )
+ {
+ pNumRule = rDoc.FindNumRulePtr( sNumRule );
+ if( !pNumRule )
+ sNumRule.Erase();
+ else
+ {
+ // this is ROW numbering ?
+ pS12 = pPlcxMan->HasParaSprm( 12 ); // sprmAnld
+ if( pS12 && 0 != SVBT8ToByte( ((WW8_ANLD*)pS12)->fNumberAcross) )
+ sNumRule.Erase();
+ }
+ }
+ }
+ if( !sNumRule.Len() )
+ {
+ //sNumRule = rDoc.GetUniqueNumRuleName();
+ pNumRule = rDoc.GetNumRuleTbl()[ rDoc.MakeNumRule( sNumRule ) ];
+ if( pTableDesc )
+ {
+ if( !pS12 )
+ pS12 = pPlcxMan->HasParaSprm( 12 ); // sprmAnld
+ if( !pS12 || !SVBT8ToByte( ((WW8_ANLD*)pS12)->fNumberAcross ) )
+ pTableDesc->SetNumRuleName( pNumRule->GetName() );
+ }
+ }
+
+ bAnl = TRUE;
+
+ NextAnlLine( pSprm13, pS12 ); // Einstellungen fuer 1. Zeile
+
+ // NumRules ueber Stack setzen
+ pCtrlStck->NewAttr( *pPaM->GetPoint(),
+ SfxStringItem( RES_FLTR_NUMRULE, pNumRule->GetName() ) );
+}
+
+
+// NextAnlLine() wird fuer jede Zeile einer
+// Gliederung / Nummerierung / Aufzaehlung einmal gerufen
+void SwWW8ImplReader::NextAnlLine( BYTE* pSprm13, BYTE* pS12 )
+{
+ if( !bAnl )
+ return; // pNd->UpdateNum ohne Regelwerk gibt GPF spaetestens
+ // beim Speichern als sdw3
+
+ if( *pSprm13 == 10 || *pSprm13 == 11 ) // WW:10 = Nummerierung -> SW:0
+ // WW:11 = Auffzaehlung -> SW:0
+ {
+ nSwNumLevel = 0;
+ if( !pNumRule->GetNumFmt( nSwNumLevel ) )
+ { // noch nicht definiert
+ if( !pS12 )
+ pS12 = pPlcxMan->HasParaSprm( 12 ); // sprmAnld o. 0
+ SetAnld( pNumRule, (WW8_ANLD*)pS12, nSwNumLevel, FALSE );
+ }
+ }
+ else if( *pSprm13 <= MAXLEVEL ) // Bereich WW:1..9 -> SW:0..8
+ {
+ nSwNumLevel = *pSprm13 - 1; // Gliederung
+ if( !pNumRule->GetNumFmt( nSwNumLevel ) ) // noch nicht definiert
+ {
+ if( pNumOlst ) // es gab ein OLST
+ {
+ SetNumOlst( pNumRule, pNumOlst , nSwNumLevel );
+ }
+ else // kein Olst, nimm Anld
+ {
+ if( !pS12 )
+ pS12 = pPlcxMan->HasParaSprm( 12 ); // sprmAnld
+ SetAnld( pNumRule, (WW8_ANLD*)pS12, nSwNumLevel, FALSE );
+ }
+ }
+ }
+ else
+ {
+ nSwNumLevel = 0xff; // keine Nummer
+ }
+ BYTE nLevel = ( nSwNumLevel < MAXLEVEL ) ? nSwNumLevel : NO_NUMLEVEL;
+ SwNodeNum aNum( nLevel );
+ SwTxtNode* pNd = pPaM->GetNode()->GetTxtNode();
+ pNd->UpdateNum( aNum );
+}
+
+// StopAnl() wird am Ende des Zeilenbereiches gerufen
+void SwWW8ImplReader::StopAnl( BOOL bGoBack )
+{
+ if( bGoBack )
+ {
+ SwPosition aTmpPos( *pPaM->GetPoint() ); // eine Zeile zu spaet
+ // gehe zurueck
+ pPaM->Move( fnMoveBackward, fnGoCntnt );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_NUMRULE ); // Setze NumRules in Stack
+ // restore Pam
+ *pPaM->GetPoint() = aTmpPos;
+ }
+ else
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_NUMRULE ); // Setze NumRules in Stack
+
+ nSwNumLevel = 0xff;
+ nWwNumType = WW8_None;
+ bAnl = FALSE;
+}
+
+
+// Bei der Zaehlung der Tabellenzellen gibt es einige Merkwuerdigkeiten:
+// 1) Ist in einer Zeile eine besondere Zellenumrandung vorhanden, dann werden
+// die WW8_TCell's vom WW generiert, sonst nicht.
+// 2) Existieren die TCs, dann ist bei nicht existenten Zellen fMerged gesetzt.
+// Im Text existieren diese Zellen nicht, d.h. die Indices muessen nicht
+// korrigiert werden. ( Im sprmTDefTable sind die nicht existenten Zellen
+// jedoch vorhanden ). Fuer diese Zellen ist bExist[] TRUE, da keine
+// Anpassung der Indices beim Einlesen der Inhalte passieren muss.
+// 3) Existieren die TCs einer Zeile nicht, dann werden nicht existente Zellen
+// als Zellen mit 0-Breite dargestellt, die auch jeweils einen leeren Absatz
+// beinhalten. Werden diese Zellen mit Breite 0 nicht importiert ( was sehr
+// empfehlenswert ist ), dann muessen die ZellenNummern korrigiert werden.
+// Der Index kann ueber nTransCell[] nachgesehen werden. Fuer diese Zellen
+// ist bExist[] FALSE.
+// 4) Da WW Zellen mit ausgefransten Raendern darstellen kann, der SW aber
+// nicht, werden hier ggfs. leere Zellen links und rechts angefuegt. Auch
+// hier muessen die Zellennummern korrigiert werden.
+//
+// -> bExist[] enthaelt Info darueber, ob im WW vorhandene Zellen im SW fehlen
+// ( Fall 3 )
+// -> nTransCell[] ist die UEbersetzung von WW-Indices auf SW-Indizes
+// ( unterschiedlich bei Fall 3 und 4 )
+
+static BOOL IsEqual( WW8TabBandDesc* p1, WW8TabBandDesc* p2 )
+{
+ if( !p1 || !p2 )
+ return FALSE;
+#if 0 // dieses waere der schnellste Vergleich, aber ich bin mir nicht sicher,
+ // ob gewisse Systeme die struct-Elemente nicht umsortieren oder
+ // Luecken lassen
+ if( !memcmp( &p1->nGapHalf, &p2->nGapHalf,
+ (BYTE*)&p1->pTCs - (BYTE*)&p1->nGapHalf ) )
+ return FALSE;
+#endif
+ if( p1->nWwCols != p2->nWwCols )
+ return FALSE;
+
+ if( p1->nLineHeight != p2->nLineHeight )
+ return FALSE;
+
+ if( p1->nGapHalf != p2->nGapHalf ) // koennte auch mit Toleranz arbeiten ( noetig ? )
+ return FALSE;
+
+ for( int i = 0; i <= p1->nWwCols; i++ ) // nCols+1 Angaben
+ if( p1->nCenter[i] != p2->nCenter[i] ) // Toleranz bei nCenter ?
+ return FALSE;
+
+ if( p1->pTCs || p2->pTCs ){ // mindestens einer mit TCs
+ if( !p1->pTCs || !p2->pTCs )
+ return FALSE; // einer ohne TCs
+
+ if( memcmp( p1->pTCs, p2->pTCs, ( p1->nWwCols ) * sizeof( WW8_TCell ) ) )
+ return FALSE;
+ }
+ if( p1->pSHDs || p2->pSHDs ){ // mindestens einer mit SHDs
+ if( !p1->pSHDs || !p2->pSHDs )
+ return FALSE; // einer ohne SHDs
+
+ if( memcmp( p1->pSHDs, p2->pSHDs, ( p1->nWwCols ) * sizeof( WW8_SHD ) ) )
+ return FALSE;
+ }
+ return TRUE;
+}
+
+WW8TabBandDesc::WW8TabBandDesc( WW8TabBandDesc& rBand )
+{
+ *this = rBand;
+ if( rBand.pTCs ){
+ pTCs = new WW8_TCell[nWwCols];
+ memcpy( pTCs, rBand.pTCs, nWwCols * sizeof( WW8_TCell ) );
+ }
+ if( rBand.pSHDs ){
+ pSHDs = new WW8_SHD[nWwCols];
+ memcpy( pSHDs, rBand.pSHDs, nWwCols * sizeof( WW8_SHD ) );
+ }
+}
+
+// ReadDef liest die Zellenpositionen und ggfs die Umrandungen eines Bandes ein
+void WW8TabBandDesc::ReadDef( BOOL bVer67, BYTE* pS )
+{
+ int i;
+
+ if( !bVer67 ) pS++;
+
+ short nLen = (INT16)SVBT16ToShort( pS - 2 ); // nicht schoen
+ BYTE nCols = *pS; // Anzahl der Zellen
+ short nOldCols = nWwCols;
+
+ if( nCols > MAX_COL )
+ return;
+
+ nWwCols = nCols;
+
+ BYTE* pT = &pS[1];
+ nLen --;
+ for( i=0; i<=nCols; i++, pT+=2 ){
+ nCenter[i] = (INT16)SVBT16ToShort( pT ); // X-Raender
+ }
+ nLen -= 2 * ( nCols + 1 );
+ if( nCols != nOldCols ){ // andere Spaltenzahl
+ DELETEAZ( pTCs );
+ DELETEAZ( pSHDs );
+ }
+
+ short nFileCols = nLen / ( bVer67 ? 10 : 20 ); // wirklich abgespeichert
+
+
+ if( !pTCs )
+ {
+ // lege leere TCs an
+ pTCs = new WW8_TCell[nCols];
+ memset( pTCs, 0, nCols * sizeof( WW8_TCell ) );
+ }
+
+
+ if( nFileCols )
+ {
+ // lies TCs ein
+
+ /*
+ Achtung: ab Ver8 ist ein reserve-ushort je TC eingefuegt und auch
+ der Border-Code ist doppelt so gross, daher ist hier
+ kein simples kopieren moeglich,
+ d.h.: pTCs[i] = *pTc; geht leider nicht.
+ ---
+ Vorteil: Arbeitstruktur ist jetzt viel bequemer zu handhaben!
+ */
+ WW8_TCell* pAktTC = pTCs;
+ if( bVer67 )
+ {
+ WW8_TCellVer6* pTc = (WW8_TCellVer6*)pT;
+ for( i=0; i<nCols; i++, ++pAktTC )
+ {
+ memset( pAktTC, 0, sizeof( WW8_TCell ) );
+ if( i < nFileCols )
+ { // TC aus File ?
+ BYTE aBits1 = SVBT8ToByte( pTc->aBits1Ver6 );
+ pAktTC->bFirstMerged = ( ( aBits1 & 0x01 ) != 0 );
+ pAktTC->bMerged = ( ( aBits1 & 0x02 ) != 0 );
+ memcpy( pAktTC->rgbrc[ WW8_TOP ].aBits1,
+ pTc->rgbrcVer6[ WW8_TOP ].aBits1, sizeof( SVBT16 ) );
+ memcpy( pAktTC->rgbrc[ WW8_LEFT ].aBits1,
+ pTc->rgbrcVer6[ WW8_LEFT ].aBits1, sizeof( SVBT16 ) );
+ memcpy( pAktTC->rgbrc[ WW8_BOT ].aBits1,
+ pTc->rgbrcVer6[ WW8_BOT ].aBits1, sizeof( SVBT16 ) );
+ memcpy( pAktTC->rgbrc[ WW8_RIGHT ].aBits1,
+ pTc->rgbrcVer6[ WW8_RIGHT ].aBits1, sizeof( SVBT16 ) );
+ if( ( pAktTC->bMerged )
+ && ( i > 0 ) )
+ {
+ // Cell gemerged -> merken
+ //bWWMergedVer6[i] = TRUE;
+ memcpy( pTCs[i-1].rgbrc[ WW8_RIGHT ].aBits1,
+ pTc->rgbrcVer6[ WW8_RIGHT ].aBits1, sizeof( SVBT16 ) );
+ // right Border in vorige Zelle uebernehmen
+ // Hier darf bExist nicht auf FALSE gesetzt werden, da WW
+ // in den Textboxen diese Zellen nicht mitzaehlt....
+ }
+ if( i+1 < nFileCols )
+ pTc++;
+ }
+ }
+ }
+ else
+ {
+ WW8_TCellVer8* pTc = (WW8_TCellVer8*)pT;
+ for( i=0; i<nCols; i++, ++pAktTC )
+ {
+ memset( pAktTC, 0, sizeof( WW8_TCell ) );
+ if( i < nFileCols )
+ { // TC aus File ?
+ UINT16 aBits1 = (UINT16)SVBT16ToShort( pTc->aBits1Ver8 );
+ pAktTC->bFirstMerged = ( ( aBits1 & 0x0001 ) != 0 );
+ pAktTC->bMerged = ( ( aBits1 & 0x0002 ) != 0 );
+ pAktTC->bVertical = ( ( aBits1 & 0x0004 ) != 0 );
+ pAktTC->bBackward = ( ( aBits1 & 0x0008 ) != 0 );
+ pAktTC->bRotateFont = ( ( aBits1 & 0x0010 ) != 0 );
+ pAktTC->bVertMerge = ( ( aBits1 & 0x0020 ) != 0 );
+ pAktTC->bVertRestart = ( ( aBits1 & 0x0040 ) != 0 );
+ pAktTC->nVertAlign = ( ( aBits1 & 0x0180 ) >> 7 );
+ // am Rande: im aBits1 verstecken sich noch 7 Reserve-Bits,
+ // anschliessend folgen noch 16 weitere Reserve-Bits
+
+ // In Version 8 koennen wir alle Bordercodes auf einmal kopieren!
+ memcpy( pAktTC->rgbrc, pTc->rgbrcVer8, 4 * sizeof( WW8_BRC ) );
+ // Zellen-Mergeinfo braucht hier nicht extra vermerkt zu werden,
+ // da dies ab Ver8 ja ueber Merge-Gruppen verwaltet wird.
+ if( i+1 < nFileCols )
+ pTc++;
+ }
+ }
+ }
+ }
+}
+
+
+void WW8TabBandDesc::ProcessSprmTSetBRC( BOOL bVer67, BYTE* pParamsTSetBRC )
+{
+ if( pParamsTSetBRC && pTCs ) // set one or more cell border(s)
+ {
+ BYTE nitcFirst= pParamsTSetBRC[0];// first col to be changed
+ BYTE nitcLim = pParamsTSetBRC[1];// (last col to be changed)+1
+ BYTE nFlag = *(pParamsTSetBRC+2);
+
+ BOOL bChangeRight = nFlag & 0x08;
+ BOOL bChangeBottom = nFlag & 0x04;
+ BOOL bChangeLeft = nFlag & 0x02;
+ BOOL bChangeTop = nFlag & 0x01;
+
+ WW8_TCell* pAktTC = pTCs + nitcFirst;
+ if( bVer67 )
+ {
+ WW8_BRCVer6* pBRC = (WW8_BRCVer6*)(pParamsTSetBRC+3);
+
+ for( int i = nitcFirst; i < nitcLim; i++, ++pAktTC )
+ {
+ if( bChangeTop )
+ memcpy( pAktTC->rgbrc[ WW8_TOP ].aBits1,
+ pBRC->aBits1,
+ sizeof( SVBT16 ) );
+ if( bChangeLeft )
+ memcpy( pAktTC->rgbrc[ WW8_LEFT ].aBits1,
+ pBRC->aBits1,
+ sizeof( SVBT16 ) );
+ if( bChangeBottom )
+ memcpy( pAktTC->rgbrc[ WW8_BOT ].aBits1,
+ pBRC->aBits1,
+ sizeof( SVBT16 ) );
+ if( bChangeRight )
+ memcpy( pAktTC->rgbrc[ WW8_RIGHT].aBits1,
+ pBRC->aBits1,
+ sizeof( SVBT16 ) );
+ }
+ }
+ else
+ {
+ WW8_BRC* pBRC = (WW8_BRC*)(pParamsTSetBRC+3);
+
+ for( int i = nitcFirst; i < nitcLim; i++, ++pAktTC )
+ {
+ if( bChangeTop )
+ memcpy( pAktTC->rgbrc[ WW8_TOP ].aBits1,
+ pBRC->aBits1,
+ sizeof( WW8_BRC ) );
+ if( bChangeLeft )
+ memcpy( pAktTC->rgbrc[ WW8_LEFT ].aBits1,
+ pBRC->aBits1,
+ sizeof( WW8_BRC ) );
+ if( bChangeBottom )
+ memcpy( pAktTC->rgbrc[ WW8_BOT ].aBits1,
+ pBRC->aBits1,
+ sizeof( WW8_BRC ) );
+ if( bChangeRight )
+ memcpy( pAktTC->rgbrc[ WW8_RIGHT].aBits1,
+ pBRC->aBits1,
+ sizeof( WW8_BRC ) );
+ }
+
+
+
+ }
+ }
+}
+
+
+void WW8TabBandDesc::ProcessSprmTDxaCol( BOOL bVer67, BYTE* pParamsTDxaCol )
+{
+ // sprmTDxaCol (opcode 0x7623) changes the width of cells
+ // whose index is within a certain range to be a certain value.
+
+ if( nWwCols && pParamsTDxaCol ) // set one or more cell length(s)
+ {
+ BYTE nitcFirst= pParamsTDxaCol[0]; // first col to be changed
+ BYTE nitcLim = pParamsTDxaCol[1]; // (last col to be changed)+1
+ short nDxaCol = (INT16)SVBT16ToShort( pParamsTDxaCol + 2 );
+ short nOrgWidth;
+ short nDelta;
+
+ for( int i = nitcFirst; i < nitcLim, i < nWwCols; i++ )
+ {
+ nOrgWidth = nCenter[i+1] - nCenter[i];
+ nDelta = nDxaCol - nOrgWidth;
+ for( int j = i+1; j < nWwCols; j++ )
+ {
+ nCenter[j] += nDelta;
+ }
+ }
+ }
+}
+
+
+void WW8TabBandDesc::ProcessSprmTDelete( BOOL bVer67, BYTE* pParamsTDelete )
+{
+ // sprmTDxaCol (opcode 0x7623) changes the width of cells
+ // whose index is within a certain range to be a certain value.
+
+ if( nWwCols && pParamsTDelete ) // set one or more cell length(s)
+ {
+ BYTE nitcFirst= pParamsTDelete[0]; // first col to be deleted
+ BYTE nitcLim = pParamsTDelete[1]; // (last col to be deleted)+1
+
+ BYTE nShlCnt = nWwCols - nitcLim; // count of cells to be shifted
+
+
+ WW8_TCell* pAktTC = pTCs + nitcFirst;
+ int i = 0;
+ for( ; i < nShlCnt; i++, ++pAktTC )
+ {
+ // adjust the left x-position
+ nCenter[nitcFirst + i] = nCenter[nitcLim + i];
+
+ // adjust the cell's borders
+ *pAktTC = pTCs[ nitcLim + i];
+ }
+ // adjust the left x-position of the dummy at the very end
+ nCenter[nitcFirst + i] = nCenter[nitcLim + i];
+
+ nWwCols -= (nitcLim - nitcFirst);
+ }
+}
+
+void SwWW8ImplReader::Read_TabCellDelete( USHORT, BYTE* pData, short nLen )
+{
+ // implementation missing: #76673#
+ //
+ // could we use part of ProcessSprmTDelete() ???
+}
+
+void SwWW8ImplReader::Read_TabCellInsert( USHORT, BYTE* pData, short nLen )
+{
+ // implementation missing, analoguous to #76673#
+}
+
+
+
+// ReadShd liest ggfs die Hintergrundfarben einer Zeile ein.
+// Es muss vorher ReadDef aufgerufen worden sein
+void WW8TabBandDesc::ReadShd( SVBT16* pS )
+{
+ BYTE nLen = ( pS ) ? *( (BYTE*)pS - 1 ) : 0 ;
+ if( !nLen )
+ return;
+
+#if 0
+ if( !pS || *( pS - 1 ) < nWwCols * sizeof( WW8_SHD ) )
+ {
+ DELETEAZ( pSHDs ); // nicht vollstaendig -> ignorieren
+ return;
+ }
+#endif
+
+ if( !pSHDs )
+ {
+ pSHDs = new WW8_SHD[nWwCols];
+ memset( pSHDs, 0, nWwCols * sizeof( WW8_SHD ) );
+ }
+
+ BYTE nAnz = nLen >> 1;
+ if( nAnz > nWwCols )
+ nAnz = (BYTE)nWwCols;
+ int i;
+ SVBT16* pShd;
+ for( i=0, pShd = pS; i<nAnz; i++, pShd++ )
+ pSHDs[i].SetWWValue( *pShd );
+
+ //pSHDs[i] = *pShd;
+}
+
+
+
+static BOOL SearchRowEnd( BOOL bVer67, BOOL bComplex, WW8PLCFx_Cp_FKP* pPap )
+{
+ BYTE* pB;
+
+ while( ( ( bVer67 && !bComplex )
+ || ( pPap->GetPCDIdx() < pPap->GetPCDIMax()) )
+ && pPap->HasFkp() )
+ {
+ if( pPap->Where() != LONG_MAX )
+ {
+ pB = pPap->HasSprm( bVer67 ? 25 : 0x2417 );
+ if( pB
+ && *pB == 1 )
+ return TRUE; // RowEnd found
+ }
+ (*pPap)++;
+ }
+ return FALSE;
+}
+
+
+
+WW8TabDesc::WW8TabDesc( SwWW8ImplReader* pIoClass )
+ : pIo( pIoClass ),
+ pFirstBand( 0 ),
+ pActBand( 0 ),
+ pTmpPos( 0 ),
+ pTable( 0 ),
+ pTblNd( 0 ),
+ pTabLines( 0 ),
+ pTabLine( 0 ),
+ pTabBoxes( 0 ),
+ pTabBox( 0 ),
+ pMergeGroups( 0 ),
+ pAktWWCell( 0 ),
+ nRows( 0 ),
+ nDefaultSwCols( 0 ),
+ nBands( 0 ),
+ nMinLeft( 0 ),
+ nMaxRight( 0 ),
+ nSwWidth( 0 ),
+ bOk( TRUE ),
+ bHeader( FALSE ),
+ bBorderDefaults( FALSE ),
+ bClaimLineFmt( FALSE ),
+ eOri( HORI_NONE ),
+ nAktRow( 0 ),
+ nAktBandRow( 0 ),
+ nAktCol( 0 )
+{
+ pIo->bAktAND_fNumberAcross = FALSE;
+
+ static SwHoriOrient aOriArr[] = {
+ HORI_LEFT, HORI_CENTER, HORI_RIGHT, HORI_CENTER };
+
+ BOOL bVer67 = pIo->bVer67;
+ BOOL bComplex = pIo->pWwFib->fComplex;
+
+ WW8TabBandDesc* pNewBand = new WW8TabBandDesc;
+
+
+ // Dies ist auch eine moegliche Erkennung
+ // fuer Dok-Start ( hat immer PageDesc ).
+ // Allerdings werden die PageDescs
+ // bei Bereichswechsel nicht erkannt
+// bStartDoc = ( pIo->pPaM->GetPoint()->nNode.GetIndex()
+// == pIo->rDoc.GetNodes().EndOfIcons.GetIndex() + 2 );
+
+ WW8PLCFxSave1 aSave;
+ pIoClass->pPlcxMan->GetPap()->Save( aSave );
+
+ WW8PLCFx_Cp_FKP* pPap = pIoClass->pPlcxMan->GetPapPLCF();
+
+ // process pPap until end of table found
+ do{
+ short nTabeDxaNew = SHRT_MAX;
+ eOri = HORI_LEFT;
+ pNewBand->nGapHalf = 0;
+ pNewBand->nLineHeight = 0;
+ BOOL bTabRowJustRead = FALSE;
+ BYTE* pShadeSprm = 0;
+ BYTE* pTabDxaColSprm = 0;
+
+
+ if( !SearchRowEnd( bVer67, bComplex, pPap ) ) // Suche Ende einer TabZeile
+ {
+ bOk = FALSE;
+ break;
+ }
+
+
+ // Get the SPRM chains:
+ // first from PAP and then from PCD (of the Piece Table)
+ WW8PLCFxDesc aDesc;
+ pPap->GetSprms( &aDesc );
+ WW8SprmIter aSprmIter( aDesc.pMemPos, aDesc.nSprmsLen,
+ pIo->GetFib().nVersion );
+
+ BYTE* pParams = aSprmIter.GetAktParams();
+ for( int nLoop = 0; nLoop < 2; ++nLoop )
+ {
+ while( aSprmIter.GetSprms()
+ && (0 != (pParams = aSprmIter.GetAktParams())) )
+ {
+ switch( aSprmIter.GetAktId() )
+ {
+ case 187:
+ case 0xD605:
+ if( !nRows )
+ {
+ // sprmTTableBorders
+ if( bVer67 )
+ for( int i = 0; i < 6; ++i )
+ {
+ aDefBrcs[i].aBits1[0] = pParams[ 2*i ];
+ aDefBrcs[i].aBits1[1] = pParams[ 1+2*i ];
+ }
+ else
+ memcpy( aDefBrcs, pParams, 24 ); // aDefBrcs = *(BRC(*)[6])pS;
+ bBorderDefaults = TRUE;
+ }
+ break;
+ case 186:
+ case 0x3404:
+ if( nRows == 0 ) // only 1. Line is Header
+ {
+ // sprmTTableHeader
+ bHeader = TRUE;
+ }
+ break;
+ case 182:
+ case 0x5400:
+ if( nRows == 0 )
+ {
+ // sprmTJc - Justification Code
+ eOri = aOriArr[ *pParams & 0x3 ];
+ }
+ break;
+ case 184:
+ case 0x9602:
+ {
+ // sprmTDxaGapHalf
+ pNewBand->nGapHalf = (INT16)SVBT16ToShort( pParams );
+ }
+ break;
+ case 189:
+ case 0x9407:
+ {
+ // sprmTDyaRowHeight
+ pNewBand->nLineHeight = (INT16)SVBT16ToShort( pParams ); // DyaRowHeight
+ bClaimLineFmt = TRUE;
+ }
+ break;
+ case 190:
+ case 0xD608:
+ {
+ // DefineTabRow
+ pNewBand->ReadDef( bVer67, pParams );
+ bTabRowJustRead = TRUE;
+ }
+ break;
+ case 191:
+ case 0xD609:
+ {
+ // TableShades
+ pShadeSprm = pParams;
+ }
+ break;
+ //
+ // * * * * Bug #69885#: the following codes were added * * * *
+ // (khz, 1.Feb.2000)
+ case 183:
+ case 0x9601:
+ {
+ // sprmTDxaLeft
+ //
+ // our Writer cannot shift single table lines horizontally
+ // so we have to find the smallest parameter (meaning the
+ // left-most position) and then
+ // shift the whole table to that margin (see below)
+ short nDxaNew = (INT16)SVBT16ToShort( pParams );
+ if( nDxaNew < nTabeDxaNew )
+ nTabeDxaNew = nDxaNew;
+ }
+ break;
+ case 193:
+ case 0xD620:
+ {
+ // sprmTSetBrc
+ pNewBand->ProcessSprmTSetBRC( bVer67, pParams );
+ }
+ break;
+ case 196:
+ case 0x7623:
+ {
+ // sprmTDxaCol
+ pTabDxaColSprm = pParams;
+ }
+ break;
+ /* the following is processed by a separate methode
+ case 195: while reading the table's content...
+ case 0x5622:
+ {
+ // sprmTDelete
+ }
+ break;
+ */
+ }
+ aSprmIter++;
+ }
+
+ if( !nLoop )
+ {
+ pPap->GetPCDSprms( aDesc );
+ aSprmIter.SetSprms( aDesc.pMemPos, aDesc.nSprmsLen );
+ }
+ }
+
+
+ // #55171: WW-Tabellen koennen Fly-Wechsel
+ // beinhalten
+ // daher hier Tabellen abbrechen und neu beginnen
+ // noch steht *pPap noch vor TabRowEnd, daher
+ // kann TestApo() mit letztem Parameter FALSE
+ // und damit wirksam gerufen werden.
+
+
+ if( bTabRowJustRead && pShadeSprm )
+ pNewBand->ReadShd( (SVBT16*)pShadeSprm );
+
+ if( nTabeDxaNew < SHRT_MAX )
+ {
+ short* pCenter = pNewBand->nCenter;
+ for( int i = 0; i < pNewBand->nWwCols; i++, ++pCenter )
+ // Shift left x-position
+ *pCenter += nTabeDxaNew;
+ }
+
+ if( pTabDxaColSprm )
+ pNewBand->ProcessSprmTDxaCol( bVer67, pTabDxaColSprm );
+
+
+ // Bei Unterschieden gibt es ein neues Band
+ // Zweite Zeile bekommt immer ein neues Band, damit die erste allein ist
+ if( nRows == 1 || !IsEqual( pNewBand, pActBand ) )
+ {
+ if( !pActBand )
+ {
+ pActBand = pFirstBand = pNewBand;
+ }
+ else
+ {
+ pActBand->pNextBand = pNewBand;
+ pActBand = pNewBand;
+ }
+ pNewBand = new WW8TabBandDesc;
+ nBands++;
+ }
+ else
+ {
+ delete pNewBand;
+ pNewBand = new WW8TabBandDesc;
+ }
+ nRows++;
+ pActBand->nRows++;
+
+ (*pPap)++;
+ if( ( pPap->Where() == LONG_MAX )
+ || ( ( !bVer67 || bComplex )
+ && ( pPap->GetPCDIdx() >= pPap->GetPCDIMax() ) ) )
+ {
+ bOk = FALSE;
+ break;
+ }
+
+ // InTable
+ if( (0 == (pParams = pPap->HasSprm( bVer67 ? 24 : 0x2416 ) ) )
+ || (1 != *pParams) )
+ break;
+
+
+ BOOL bStartApo, bStopApo, bNowStyleApo;
+ pIoClass->TestApo( bStartApo, bStopApo,
+ bNowStyleApo, TRUE, FALSE, TRUE );
+ if( bStopApo ) // Wenn Apo-Ende oder Apo-Wechsel, dann
+ break; // hoert die Tabelle hier auf
+
+ }while( 1 );
+
+ if( bOk )
+ {
+ if( pActBand->nRows > 1 )
+ { // Letztes Band hat mehr als 1 Zeile
+ delete( pNewBand );
+ pNewBand = new WW8TabBandDesc( *pActBand ); // neues machen
+ pActBand->nRows--; // wegen Sonderbehandlung Raender-Defaults
+ pNewBand->nRows = 1;
+ pActBand->pNextBand = pNewBand; // am Ende einschleifen
+ nBands++;
+ pNewBand = 0; // nicht loeschen
+ }
+
+ CalcDefaults();
+ }
+ delete( pNewBand );
+
+ pIoClass->pPlcxMan->GetPap()->Restore( aSave );
+}
+
+WW8TabDesc::~WW8TabDesc()
+{
+ WW8TabBandDesc* pR = pFirstBand;
+ WW8TabBandDesc* pR2;
+
+ while( pR ){
+ pR2 = pR->pNextBand;
+ delete( pR );
+ pR = pR2;
+ }
+ if( pMergeGroups ) DELETEZ( pMergeGroups );
+}
+
+void WW8TabDesc::CalcDefaults()
+{
+ short nMinCols = SHRT_MAX;
+ register WW8TabBandDesc* pR;
+
+ nMinLeft = SHRT_MAX;
+ nMaxRight = SHRT_MIN;
+
+ // 1. Durchlauf: aeusserste L- und R-Grenzen finden
+ for( pR = pFirstBand; pR; pR = pR->pNextBand ){
+ if( pR->nCenter[0] < nMinLeft )
+ nMinLeft = pR->nCenter[0];
+ if( pR->nCenter[pR->nWwCols] > nMaxRight )
+ nMaxRight = pR->nCenter[pR->nWwCols];
+ }
+ nSwWidth = nMaxRight - nMinLeft;
+ // 2. Durchlauf: Zahl der Writer-Spalten feststellen
+ // Die Zahl der Writer Spalten kann um bis zu 2 hoeher
+ // sein als im WW, da der SW im Gegensatz zu WW keine
+ // ausgefransten linken und rechten Raender kann und
+ // diese durch leere Boxen aufgefuellt werden.
+ // Durch nichtexistente Zellen koennen auch Zellen
+ // wegfallen
+
+ for( pR = pFirstBand; pR; pR = pR->pNextBand ){
+ pR->nSwCols = pR->nWwCols;
+ pR->bLEmptyCol = pR->nCenter[0] - nMinLeft > MINLAY;
+ pR->bREmptyCol = nMaxRight - pR->nCenter[pR->nWwCols] > MINLAY;
+
+ short nAddCols = pR->bLEmptyCol + pR->bREmptyCol;
+ USHORT i;
+ USHORT j = ( pR->bLEmptyCol ) ? 1 : 0;
+ for( i = 0; i < pR->nWwCols; i++ ){
+ pR->nTransCell[i] = (INT8)j;
+ if( ( pR->nCenter[i] < pR->nCenter[i+1] )
+ //&& !pR->bWWMergedVer6[i]
+ )
+ { // Zelle existiert wirklich
+ pR->bExist[i] = TRUE;
+ j++;
+ }
+ else
+ {
+ pR->bExist[i] = FALSE;
+ nAddCols--;
+ }
+ }
+ pR->nTransCell[i++] = (INT8)(j++); // Wird u.a. wegen bREmptyCol um
+ pR->nTransCell[i] = (INT8)j; // max. 2 ueberindiziert
+
+ pR->nSwCols += nAddCols;
+ if( pR->nSwCols < nMinCols )
+ nMinCols = pR->nSwCols;
+ }
+ // 3. Durchlauf: Wo noetig die Umrandungen durch die
+ // Defaults ersetzen
+ if( bBorderDefaults ){
+ for( pR = pFirstBand ; pR; pR = pR->pNextBand ){
+ if( !pR->pTCs ){
+ pR->pTCs = new WW8_TCell[ pR->nWwCols ];
+ memset( pR->pTCs, 0, pR->nWwCols * sizeof( WW8_TCell ) );
+ }
+ int k;
+ for( k = 0; k < pR->nWwCols; k++ ){
+ register WW8_TCell* pT = &pR->pTCs[k];
+ int i, j;
+ for( i = 0; i < 4; i ++ ){
+#ifdef DEBUG
+// nur fuer Ver67
+ USHORT nBBrc = SVBT16ToShort( pT->rgbrc[i].aBits1 );
+ USHORT nBWidth = nBBrc >> 0 & 0x7;
+ USHORT nBType = nBBrc >> 3 & 0x3;
+ USHORT nBShadow = nBBrc >> 5 & 0x1;
+ USHORT nBIco = nBBrc >> 6 & 0x1f;
+ USHORT nBSpace = nBBrc >> 11 & 0x1f;
+#endif
+ if( pIo->bVer67
+ ? (( SVBT16ToShort( pT->rgbrc[i].aBits1 ) >> 3 & 0x3 ) == 0)
+ : (( SVBT16ToShort( pT->rgbrc[i].aBits1 ) & 0xFF00 ) == 0) )
+ { // brcType == 0 nichts explizit gesetzt
+ j = i;
+ switch( i )
+ {
+ case 0: j = (pR == pFirstBand ) ? 0 : 4; // Aussen oben / Innen waagerecht
+ break;
+ case 1: j = ( k ) ? 5 : 1; // Aussen links / Innen senkrecht
+ break;
+ case 2: j = ( pR->pNextBand ) ? 4 : 2; // Aussen unten / Innen waagerecht
+ break;
+ case 3: j = (k == pR->nWwCols - 1) ? 3 : 5; // Aussen rechts/ Innen senkrecht
+ break;
+ }
+#ifdef DEBUG
+// nur fuer Ver67
+ USHORT nDBrc = SVBT16ToShort( aDefBrcs[j].aBits1 );
+ USHORT nDWidth = nDBrc >> 0 & 0x7;
+ USHORT nDType = nDBrc >> 3 & 0x3;
+ USHORT nDShadow = nDBrc >> 5 & 0x1;
+ USHORT nDIco = nDBrc >> 6 & 0x1f;
+ USHORT nDSpace = nDBrc >> 11 & 0x1f;
+#endif
+ pT->rgbrc[i] = aDefBrcs[j]; // mangel mit Defaults ueber
+ }
+ }
+ }
+ }
+ }
+ // 4. Ausrichtung der Tabelle
+ long nMidTab = ( (long)nMinLeft + nMaxRight ) / 2; // TabellenMitte
+ long nRight = pIo->nPgWidth - pIo->nPgRight - pIo->nPgLeft;
+
+ // set Position if not on adjusted to left border
+ if((MINLAY < nMinLeft) && (HORI_LEFT == eOri))
+ {
+ if(MINLAY > abs(nMidTab - nRight/2))// very near the center IS centered
+ eOri = HORI_CENTER;
+ else
+ if(MINLAY > abs(nMaxRight - nRight))// very near r.border IS r.adjusted
+ eOri = HORI_RIGHT;
+ else
+ eOri = HORI_LEFT_AND_WIDTH; // absolutely positioned
+ }
+
+ nDefaultSwCols = nMinCols; // da Zellen einfuegen billiger ist als Mergen
+ if( nDefaultSwCols == 0 )
+ bOk = FALSE;
+ pActBand = pFirstBand;
+ nAktBandRow = 0;
+ ASSERT( pActBand, "pActBand ist 0" );
+}
+
+void WW8TabDesc::CreateSwTable()
+{
+
+ ::SetProgressState( pIo->nProgress, pIo->rDoc.GetDocShell() ); // Update
+#ifdef DEBUG
+// Sound::Beep();
+#endif
+
+ // if there is already some content on the Node
+ // append new node to ensure that this content remains
+ // ABOVE the table
+ SwPosition* pPoint = pIo->pPaM->GetPoint();
+ BOOL bInsNode = ( pPoint->nContent.GetIndex() );
+ if( !bInsNode
+ && pIo->pNode_FLY_AT_CNTNT == &pPoint->nNode.GetNode() )
+ {
+ bInsNode = TRUE;
+ // minimize Fontsize to minimize height growth of the header/footer
+ SvxFontHeightItem aSz( 20 );
+ pIo->NewAttr( aSz );
+ pIo->pCtrlStck->SetAttr( *pPoint, RES_CHRATR_FONTSIZE );
+ }
+ if( bInsNode )
+ {
+ // set font size to 1 point to minimize y-growth of Hd/Ft
+ pIo->rDoc.AppendTxtNode( *pPoint );
+ }
+
+
+ pTmpPos = new SwPosition( *pIo->pPaM->GetPoint() );
+
+
+ // Abfrage, ob im Node, in dem die Tabelle eingefuegt werden soll,
+ // bereits ein Pagedesc steht. Dann wuerde der PageDesc in die
+ // naechste Zeile hinter der Tabelle rutschen, wo er nichts zu
+ // suchen hat.
+ // -> loeschen und spaeter an das Tabellenformat setzen
+ SfxPoolItem *pSetAttr = 0;
+ SwTxtNode* pNd = pIo->rDoc.GetNodes()[pTmpPos->nNode]->GetTxtNode();
+ if ( pNd ){
+ const SfxItemSet* pSet = pNd->GetpSwAttrSet();
+ const SfxPoolItem* pItem;
+ if( pSet ){
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, FALSE, &pItem ))
+ {
+ pSetAttr = new SwFmtPageDesc( *(SwFmtPageDesc*)pItem );
+ pNd->ResetAttr( RES_PAGEDESC );
+ }
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, FALSE, &pItem ) )
+ {
+ pSetAttr = new SvxFmtBreakItem( *(SvxFmtBreakItem*)pItem );
+ pNd->ResetAttr( RES_BREAK );
+ }
+ }
+ }
+
+
+ // Die Tabelle ist beim Einfuegen noch recht klein:
+ // Zahl der Spalten ist die kleinste Spaltenanzahl des Originals,
+ // da Spalten einfuegen schneller geht als Loeschen
+ // Zahl der Zeilen ist die Zahl der Baender, da sich die
+ // (identischen) Zeilen eines Bandes prima duplizieren lassen
+ pTable = pIo->rDoc.InsertTable( *pTmpPos, nBands, nDefaultSwCols, eOri );
+ SwFrmFmt* pFrmFmt = pTable->GetFrmFmt();
+
+ // evtl den PageDesc/Break jetzt an der Tabelle setzen
+ if( pSetAttr )
+ {
+ pFrmFmt->SetAttr( *pSetAttr );
+ delete pSetAttr;
+ }
+
+ if( nMaxRight - nMinLeft > MINLAY * nDefaultSwCols ) // Gesamtbreite der Tabelle
+ {
+ pFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nSwWidth ) );//FIX
+ }
+
+ if(HORI_LEFT_AND_WIDTH == eOri)
+ {
+ SvxLRSpaceItem aL;
+ aL.SetLeft( nMinLeft );
+ pFrmFmt->SetAttr( aL );
+ }
+
+ if( pIo->pSFlyPara ){ // Ist Tabelle im Rahmen ?
+ // ok, Rahmen auf Bildgroesse vergroessern
+ // ( nur wenn Auto-Breite )
+ pIo->pSFlyPara->BoxUpWidth( nSwWidth );
+ }
+
+ // globale Varis initialisieren
+ pTabLines = &pTable->GetTabLines();
+ nAktRow = nAktCol
+ = nAktBandRow
+ = 0;
+
+ pTblNd = (SwTableNode*)(*pTabLines)[0]->GetTabBoxes()[0]->GetSttNd()->FindTableNode();
+ ASSERT( pTblNd, "wo ist mein TabellenNode" );
+ pTblNd->GetTable().SetHeadlineRepeat( bHeader );
+
+ // ggfs. Zusatz-Zellen einfuegen u.dgl.
+ AdjustNewBand( pIo );
+
+ // jetzt den PaM korrekt setzen und ggfs. erste Mergegruppe vorbereiten...
+ SetPamInCell( nAktCol, TRUE, TRUE );
+
+ pIo->bWasTabRowEnd = FALSE;
+}
+
+void WW8TabDesc::FinishSwTable()
+{
+ *pIo->pPaM->GetPoint() = *pTmpPos;
+ delete( pTmpPos );
+ pTmpPos = 0;
+ pIo->bWasTabRowEnd = FALSE;
+ if( pIo->rDoc.GetRootFrm() )
+ {
+ // exitiert schon ein Layout, dann muss an dieser Tabelle die
+ // BoxFrames neu erzeugt werden.
+ pTblNd->DelFrms();
+ pTblNd->MakeFrms( &pIo->pPaM->GetPoint()->nNode );
+ }
+ // falls noetig, zu mergende Zellen gruppenweise zusammenfassen
+ if( pMergeGroups )
+ {
+ // bearbeite alle Merge-Gruppen nacheinander
+ SwTableBox* pTargetBox;
+ WW8SelBoxInfo* pActMGroup;
+ USHORT nActBoxCount;
+ for( USHORT iGr = 0; iGr < pMergeGroups->Count(); iGr++ )
+ {
+ pActMGroup = (*pMergeGroups)[ iGr ];
+ // Anzahl der zu mergenden Boxen PLUS Eins (fuer die TargetBox)
+ nActBoxCount = pActMGroup->Count();
+
+ if( ( 1 < nActBoxCount ) && pActMGroup && (*pActMGroup)[ 0 ] )
+ {
+ // beachten: der 0. Eintrag ist die ebenso wie
+ // die obere, linke Box formatierte Target-Box !!!
+ pTargetBox = (*pActMGroup)[ 0 ];
+ //
+ // Target-Box verschoenern: unteren Rand der letzten Box nehmen
+ //
+ SwFrmFmt* pTargetFrmFmt = pTargetBox->GetFrmFmt();
+ SvxBoxItem aBoxItem( pTargetFrmFmt->GetBox() );
+ aBoxItem.SetLine(
+ (*pActMGroup)[ nActBoxCount-1 ]->GetFrmFmt()->GetBox().GetBottom(),
+ BOX_LINE_BOTTOM );
+ pTargetFrmFmt->SetAttr( aBoxItem );
+
+ // oeffne Merge-Array mit passender Groesse
+ SwSelBoxes aBoxes( nActBoxCount-1 );
+
+ // alle Boxen dieser Gruppe in aBoxes versammeln
+ aBoxes.Insert( pActMGroup->GetData()+1, nActBoxCount-1 );
+
+ // Sicherheitspruefung: Gruppe mit nur EINER Box fuehrt beim Mergen
+ // zum Programmabsturz, deshalb diesen unsinnigen Fall abfangen!
+ USHORT nMergeTest;
+ if( 2 == nActBoxCount )
+ // nur 1 Zelle in der Merge-Gruppe: wahrscheinlich Word-Bug
+ nMergeTest = TBLMERGE_TOOCOMPLEX;
+ else
+ { //
+ // Vorsicht: erstmal austesten,
+ // ob sich die aBoxes ueberhaupt mergen lassen wuerden...
+ //
+ nMergeTest = CheckMergeSel( aBoxes ); // siehe /SW/INC/TBLSEL.HXX
+ BYTE nTry = 1;
+ //
+ // Falls das Merge so nicht machbar ist,
+ // pruefen, ob es ginge, wenn wir die letzte Box
+ // oder die beiden letzten Boxen
+ // oder gar die drei letzten Boxen
+ // aus der Merge-Gruppe rausnehmen wuerden
+ while( ( TBLMERGE_TOOCOMPLEX == nMergeTest )
+ && ( 4 > nTry )
+ && ( 3 < nActBoxCount /* wichtig ! */ ) )
+ {
+ nTry++;
+ nActBoxCount--;
+ // letzte Box aus der Gruppe rausnehmen
+ aBoxes.Remove( nActBoxCount-1 );
+ // und nachsehen, ob Merge nun moeglich waere
+ nMergeTest = CheckMergeSel( aBoxes );
+ }
+ }
+ //
+ // Genug geprueft - wir schreiten zur Tat...
+ //
+ switch( nMergeTest )
+ {
+ case TBLMERGE_OK:
+ //
+ // You succeed at last...
+ //
+ ((SwTable*)pTable)->Merge( &pIo->rDoc, aBoxes, pTargetBox );
+ break;
+ case TBLMERGE_NOSELECTION:
+ /*NOP*/ // war wohl nix?
+ break;
+ case TBLMERGE_TOOCOMPLEX:
+ // Pech: Trotz aller Probiererei geht das Merge immer noch nicht!
+ //
+ // Beachten: die Daten der Gruppe schlummern bereits
+ // in der Target-Box. Da kein Merge moeglich ist,
+ // setzen wir die Target-Box in die Tabelle an
+ // die Stelle der oberen linken Box.
+ {
+ const SwTableBox* pBox = (*pActMGroup)[ 1 ];
+ SwTableLine* pLine = (SwTableLine*)pBox->GetUpper();
+
+ USHORT nPos = pLine->GetTabBoxes().GetPos( pBox );
+
+ ASSERT( USHRT_MAX != nPos, "GetPos fehlgeschlagen");
+
+ SwStartNode* pSttNd = (SwStartNode*)pBox->GetSttNd();
+
+ ASSERT( pSttNd, "Box ohne Start-Node ?!");
+
+ pTargetBox->ChgFrmFmt(
+ (SwTableBoxFmt*)pBox->GetFrmFmt() );
+ pTargetBox->SetUpper( pLine );
+
+ // erst die Box loeschen!!
+ pLine->GetTabBoxes().DeleteAndDestroy( nPos );
+ // dann die pTargetBox einfuegen
+ pLine->GetTabBoxes().C40_INSERT( SwTableBox, pTargetBox, nPos );
+ // dann die Nodes loeschen!!
+ pIo->rDoc.DeleteSection( pSttNd );
+ }
+ break;
+ default: // was wollen wir denn hier ???
+ ASSERT( !this, "CheckMergeSel() with undefined return value" );
+ break;
+ }
+ }
+ }
+ DELETEZ( pMergeGroups );
+ }
+ // nun noch ggfs. die doppelten Innenraender korrigieren (Bug #53525#)
+ if( pTable )
+ ((SwTable*)pTable)->GCBorderLines(); // Garbage Collect
+}
+
+
+// durchsucht pMergeGroups, meldet Index der ersten, passenden Gruppe bzw. -1
+//
+// Parameter: nXcenter = Mittenposition der anfragenden Box
+// nWidth = Breite der anfragenden Box
+// bExact = Flag, ob Box in dieser Gruppe passen muss,
+// oder diese nur zu tangieren braucht
+//
+BOOL WW8TabDesc::FindMergeGroup( short nX1, short nWidth, BOOL bExact, short& nMGrIdx )
+{
+ nMGrIdx = -1;
+ if( pMergeGroups )
+ {
+ // noch als gueltig angesehener Bereich in der Naehe der Grenzen
+ const short nToleranz = 4;
+ // die aktuell untersuchte Gruppe
+ WW8SelBoxInfoPtr pActGroup;
+ // Boxgrenzen
+ short nX2 = nX1 + nWidth;
+ // ungefaehre Gruppengrenzen
+ short nGrX1;
+ short nGrX2;
+
+ for( USHORT iGr = 0; iGr < pMergeGroups->Count(); iGr++ )
+ {
+ // die aktuell untersuchte Gruppe
+ pActGroup = (*pMergeGroups)[ iGr ];
+ if( -999 < pActGroup->nGroupXStart )
+ {
+ // ungefaehre Gruppengrenzen mit Toleranz nach *aussen* hin
+ nGrX1 = pActGroup->nGroupXStart - nToleranz;
+ nGrX2 = pActGroup->nGroupXStart
+ +pActGroup->nGroupWidth + nToleranz;
+ //
+ // Falls Box reinpasst, melde auf jeden Fall den Erfolg
+ //
+ if( ( nX1 > nGrX1 ) && ( nX2 < nGrX2 ) )
+ {
+ nMGrIdx = iGr; break;
+ }
+ //
+ // hat die Box Bereiche mit der Gruppe gemeinsam?
+ //
+ if( !bExact )
+ {
+ // melde Erfolg, wenn nX1 *oder* nX2 innerhalb der Gruppe liegen
+ if( ( ( nX1 > nGrX1 )
+ && ( nX1 < nGrX2 - 2*nToleranz ) )
+ || ( ( nX2 > nGrX1 + 2*nToleranz )
+ && ( nX2 < nGrX2 ) )
+ // oder nX1 und nX2 die Gruppe umfassen
+ || ( ( nX1 <=nGrX1 )
+ && ( nX2 >=nGrX2 ) ) )
+ {
+ nMGrIdx = iGr; break;
+ }
+ }
+ }
+ }
+ }
+ return BOOL( -1 < nMGrIdx );
+}
+
+
+BOOL WW8TabDesc::IsValidCell( short nCol ) const
+{
+ return pActBand->bExist[ nCol ]
+ && (USHORT)nAktRow < pTabLines->Count();
+}
+
+
+BOOL WW8TabDesc::SetPamInCell( short nWwCol, BOOL bPam, BOOL bCheckForMerge )
+{
+ ASSERT( pActBand, "pActBand ist 0" );
+
+ if( !IsValidCell( nWwCol ) )
+ return FALSE;
+
+ USHORT nCol = pActBand->nTransCell[nWwCol];
+
+ pTabLine = (*pTabLines)[nAktRow];
+ pTabBoxes = &pTabLine->GetTabBoxes();
+ if ( nCol >= pTabBoxes->Count() )
+ return FALSE;
+ pTabBox = (*pTabBoxes)[nCol];
+ if( !pTabBox->GetSttNd() )
+ {
+ ASSERT(pTabBox->GetSttNd(), "Probleme beim Aufbau der Tabelle");
+ return FALSE;
+ }
+ if( bPam )
+ {
+ pAktWWCell = &pActBand->pTCs[ nWwCol ];
+ pIo->pPaM->GetPoint()->nNode = pTabBox->GetSttIdx() + 1;
+ pIo->pPaM->GetPoint()->nContent.Assign( pIo->pPaM->GetCntntNode(), 0 );
+
+ // Zur Sicherheit schon jetzt setzen, da bei den Zellen, die
+ // zum Randausgleich eingefuegt werden, sonst der Style
+ // nicht gesetzt wird.
+ pIo->rDoc.SetTxtFmtColl( *pIo->pPaM, (SwTxtFmtColl*)pIo->pDfltTxtFmtColl );
+ // uebrigens: da diese Zellen unsichtbare Hilfskonstruktionen sind,
+ // und nur dazu dienen, zerfranste Aussehen der WW-Tabelle
+ // nachzuahmen, braucht NICHT SetTxtFmtCollAndListLevel()
+ // verwendet zu werden.
+ }
+ //
+ // ggfs. aktuelle Box in entsprechende Merge-Gruppe eintragen
+ //
+ if( bCheckForMerge && pActBand->pTCs /*&& !pIo->bVer67*/ )
+ {
+ SwTableBox* pTargetBox;
+ WW8SelBoxInfoPtr pActMGroup = 0;
+ //
+ // ggfs. eine neue Merge-Gruppe beginnen
+ //
+ WW8_TCell& rCell = pAktWWCell ? *pAktWWCell : pActBand->pTCs[ nWwCol ];
+ // ist dies die obere, linke-Zelle einer Merge-Gruppe ?
+ if( rCell.bFirstMerged || ( rCell.bVertRestart && !rCell.bMerged ) )
+ {
+ short nX1 = pActBand->nCenter[ nWwCol ];
+ short nWidth = pActBand->nWidth[ nWwCol ];
+ if( !pMergeGroups )
+ // 0. falls noetig das Array fuer die Merge-Gruppen anlegen
+ pMergeGroups = new WW8MergeGroups;
+ else
+ {
+ // 1. ggfs. alte Mergegruppe(n) schliessen, die den von
+ // unserer neuen Gruppe betroffenen X-Bereich ueberdecken
+ short nMGrIdx;
+ while( FindMergeGroup( nX1, nWidth, FALSE, nMGrIdx ) )
+ {
+ (*pMergeGroups)[ nMGrIdx ]->nGroupXStart = -999;
+ }
+ }
+
+ // 2. aktuelle Merge-Gruppe anlegen
+ pActMGroup = new WW8SelBoxInfo( nX1, nWidth );
+
+ // 3. und in Gruppen-Array eintragen
+ pMergeGroups->Insert( pActMGroup, pMergeGroups->Count() );
+
+ // 4. Target-Box anlegen und als 0. in Merge-Group setzen
+ pIo->rDoc.GetNodes().InsBoxen(pTblNd,
+ pTabLine,
+ (SwTableBoxFmt*)pTabBox->GetFrmFmt(),
+ (SwTxtFmtColl*)pIo->rDoc.GetDfltTxtFmtColl(),
+ 0,
+ nCol );
+
+ pTargetBox = (*pTabBoxes)[ nCol ];
+
+ // eingefuegte Box wieder aus der Row entfernen
+ // (wird vom Merge() dann endgueltig richtig eingebaut)
+ pTabBoxes->Remove( nCol );
+
+ // und ab damit in die Merge-Group
+ pActMGroup->Insert( pTargetBox, pActMGroup->Count() );
+ //
+ // 5. Target-Box formatieren
+ //
+ pTargetBox->SetUpper( 0 );
+
+ // eigenes Frame-Format fuer diese Box anlegen
+ SwFrmFmt* pNewFrmFmt = pTargetBox->ClaimFrmFmt();
+
+ // Border der O-L-Box der Gruppe wird Border der Targetbox
+ pNewFrmFmt->SetAttr( pTabBox->GetFrmFmt()->GetBox() );
+
+ // Gesamtbreite ermitteln und zuweisen
+ short nSizCell = pActBand->nWidth[ nWwCol ];
+ for(USHORT i = nWwCol+1; i < pActBand->nWwCols; i++ )
+ if( pActBand->pTCs[ i ].bMerged
+ && !pActBand->pTCs[ i ].bFirstMerged )
+ nSizCell += pActBand->nWidth[ i ];
+ else
+ break;
+ pActMGroup->nGroupWidth = nSizCell;
+ pNewFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, pActMGroup->nGroupWidth ));
+ }
+
+ // ggfs. akt. Box zu einer Merge-Gruppe hinzufuegen
+ // (dies kann eine soeben angelegte, oder eine andere Gruppe sein)
+ pTargetBox = UpdateTableMergeGroup( rCell, pActMGroup, pTabBox, nWwCol );
+ if( pTargetBox )
+ {
+ // den pCurPaM jetzt ans Ende der Target-Box setzen,
+ // damit der Text direkt in die richtige Box gelesen wird.
+
+ const SwNode* pEndNd =
+ pTargetBox->GetSttNd()->EndOfSectionNode();
+
+ ASSERT(pEndNd, "Gruppen-TargetBox ohne Start-Node ?");
+
+ if( bPam )
+ {
+ pIo->pPaM->GetPoint()->nNode = pEndNd->GetIndex();
+ pIo->pPaM->Move( fnMoveBackward );
+ }
+ }
+ }
+ return TRUE;
+}
+
+#if 0 // wird fuer FastSave-Files noch gebraucht
+void WW8TabDesc::DeleteCells( short nDelete )
+{
+ short nMergeCol = nDefaultSwCols - nDelete - 1;
+
+ SwSelBoxes aBoxes;
+ short i;
+
+ for (i = nMergeCol; i < nMergeCol + nDelete + 1; i++ ){
+ if( !SetPamInCell( i, FALSE, FALSE ) )
+ return;
+ _SwSelBox a_SelBox( pTabBox->GetSttIdx(), pTabBox );
+ aBoxes.Insert( a_SelBox );
+ }
+
+ SetPamInCell( nMergeCol, FALSE, FALSE ); // Cursor u.AE. an alte Pos
+ pIo->rDoc.GetNodes().InsBoxen( pTblNd, pTabLine, pTabBox->GetFrmFmt(),
+ (SwTxtFmtColl*)pIo->rDoc.GetDfltTxtFmtColl(),
+ 0, nMergeCol );
+ SwTableBox* pNewBox = (*pTabBoxes)[nMergeCol];
+ pTabBoxes->Remove( nMergeCol ); // wieder austragen
+ pNewBox->SetUpper( 0 );
+ pNewBox->ClaimFrmFmt();
+
+ pIo->pPaM->GetPoint()->nContent.Assign( 0, 0 ); // Melde ContentIndex pCurPaM ab
+
+ ((SwTable*)pTable)->Merge( &pIo->rDoc, aBoxes, pNewBox );
+}
+#endif
+
+void WW8TabDesc::InsertCells( short nIns )
+{
+ pTabLine = (*pTabLines)[nAktRow];
+ pTabBoxes = &pTabLine->GetTabBoxes();
+ pTabBox = (*pTabBoxes)[0];
+
+ pIo->rDoc.GetNodes().InsBoxen( pTblNd, pTabLine, (SwTableBoxFmt*)pTabBox->GetFrmFmt(),
+ (SwTxtFmtColl*)pIo->pDfltTxtFmtColl, 0, pTabBoxes->Count(), nIns );
+ // mit dem Dritten Parameter wird das FrmFmt der Boxen angegeben.
+ // hier kann man auch noch optimieren, um FrmFmts zu sparen
+}
+
+void WW8TabDesc::SetTabBorders( SwTableBox* pBox, short nWwIdx )
+{
+ if( nWwIdx < 0 || nWwIdx >= pActBand->nWwCols )
+ return; // kuenstlich erzeugte Zellen -> Kein Rand
+
+ SvxBoxItem aFmtBox;
+
+ // nGapHalf bedeutet bei WW ein *horizontaler* Abstand zwischen
+ // Tabellenzelle und -Inhalt
+
+ short nHorDist = (short)pActBand->nGapHalf;
+ short nVertDist = 0;
+
+ if( pActBand->pTCs ) // neither Cell Border nor Default Border defined ?
+ {
+ WW8_TCell* pT = &pActBand->pTCs[nWwIdx];
+ if( pIo->IsBorder( pT->rgbrc ) )
+ {
+ pIo->SetBorder( aFmtBox, pT->rgbrc );
+ if ( nHorDist < MIN_BORDER_DIST )
+ nHorDist = MIN_BORDER_DIST; // Border -> min. MIN_BORDER_DIST
+ }
+ }
+
+ // Vertikal benutzt WW den Absatzabstand oben und unten, um einen Abstand
+ // zu schaffen. Dieser ist hier leider noch unbekannt. :-(
+
+
+ // Frueher stand hier das Hypo-Flag:
+ // Hypo-Tabellen alles einheitlich !
+ // if ( SwFltGetFlag( pIo->GetFieldFlags(), SwFltControlStack::HYPO ) )
+
+ // jetzt musz das alte Verhalten auch von HYPO gesondert aktiviert werden !
+ if( SwFltGetFlag( pIo->GetIniFlags1(), EQUAL_TAB_BORDERDISTS ) )
+ {
+ if ( nHorDist < MIN_BORDER_DIST )
+ nHorDist = MIN_BORDER_DIST; // Border -> min. MIN_BORDER_DIST
+ nVertDist = nHorDist;
+ }
+ else
+ {
+ if( !nVertDist ) // kein Abstand gesetzt
+ nVertDist = 18; // ca. 0.03 cm
+ }
+
+ aFmtBox.SetDistance( nHorDist, BOX_LINE_LEFT );
+ aFmtBox.SetDistance( nVertDist, BOX_LINE_TOP );
+
+ aFmtBox.SetDistance( nHorDist, BOX_LINE_RIGHT );
+ aFmtBox.SetDistance( nVertDist, BOX_LINE_BOTTOM );
+
+ pBox->GetFrmFmt()->SetAttr( aFmtBox );
+}
+
+void WW8TabDesc::SetTabShades( SwTableBox* pBox, short nWwIdx )
+{
+ if( nWwIdx < 0 || nWwIdx >= pActBand->nWwCols )
+ return; // kuenstlich erzeugte Zellen -> Keine Farbe
+ WW8_SHD& rSHD = pActBand->pSHDs[nWwIdx];
+ if( !rSHD.GetValue() ) // alles weiss
+ return;
+
+ SwWW8Shade aSh( pIo->bVer67, rSHD );
+
+ pBox->GetFrmFmt()->SetAttr( SvxBrushItem( aSh.aColor ) );
+}
+
+void WW8TabDesc::AdjustNewBand( SwWW8ImplReader* pReader )
+{
+ if( pActBand->nSwCols > nDefaultSwCols ) // Zellen splitten
+ InsertCells( pActBand->nSwCols - nDefaultSwCols );
+
+ SetPamInCell( 0, FALSE, FALSE );
+ ASSERT( pTabBoxes && pTabBoxes->Count() == (USHORT)pActBand->nSwCols,
+ "Falsche Spaltenzahl in Tabelle" )
+
+ if( bClaimLineFmt ){
+ pTabLine->ClaimFrmFmt(); // noetig wg. Zeilenhoehe
+#if 1
+
+ SwFmtFrmSize aF( ATT_MIN_SIZE, 0, 0 ); // default
+
+ if( pActBand->nLineHeight == 0 ){ // 0 = Auto
+ aF.SetSizeType( ATT_VAR_SIZE );
+ }else{
+ if( pActBand->nLineHeight < 0 ){ // Pos = min, Neg = exakt
+ aF.SetSizeType( ATT_FIX_SIZE );
+ pActBand->nLineHeight = -pActBand->nLineHeight;
+ }
+ if( pActBand->nLineHeight < MINLAY ) // nicht erlaubte Zeilenhoehe
+ pActBand->nLineHeight = MINLAY;
+
+ aF.SetHeight( pActBand->nLineHeight );// Min- / Exakt-Hoehe setzen
+ }
+ pTabLine->GetFrmFmt()->SetAttr( aF );
+#else
+ SwFrmSize eSiz = ATT_MIN_SIZE; // Default
+
+ if( pActBand->nLineHeight < 0 ){ // Pos = min; Neg = exakt
+ pActBand->nLineHeight = -pActBand->nLineHeight;
+ eSiz = ATT_FIX_SIZE;
+ }
+
+ if( pActBand->nLineHeight >= MINLAY ){ // erlaubte Zeilenhoehe, nicht auto
+ pTabLine->GetFrmFmt()->SetAttr(
+ SwFmtFrmSize( eSiz, 0, pActBand->nLineHeight ) );
+ }else{ // Auto oder ungueltig
+ pTabLine->GetFrmFmt()->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, 0 ) );
+ }
+#endif
+ }
+
+ short i; // SW-Index
+ short j; // WW-Index
+ short nW; // Breite
+
+ SwFmtFrmSize aFS( ATT_FIX_SIZE );
+ j = -pActBand->bLEmptyCol;
+ for( i = 0; i < pActBand->nSwCols; i++ )
+ {
+ // setze Zellenbreite
+ if( j < 0 )
+ nW = pActBand->nCenter[0] - nMinLeft;
+ else
+ {
+ if( j < pActBand->nWwCols )
+ nW = pActBand->nCenter[j+1] - pActBand->nCenter[j];
+ else
+ nW = nMaxRight - pActBand->nCenter[j];
+ pActBand->nWidth[ j ] = nW;
+ }
+
+ register SwTableBox* pBox = (*pTabBoxes)[i];
+ pBox->ClaimFrmFmt(); // liesse sich durch intelligentes Umhaengen
+ // der FrmFmts noch weiter verringern
+ // naemlich so: pFrmFmt->Add( pBox );
+ // gibt der Box pBox das FrameFormat pFrmFmt
+
+
+ //pMergeCtrl[ j ].nRowWidth = nW;
+ aFS.SetWidth( nW );
+ pBox->GetFrmFmt()->SetAttr( aFS );
+
+ // setze Umrandung und Hintergrund
+ SetTabBorders( pBox, j ); // und Abstand
+ if( pActBand->pSHDs )
+ SetTabShades( pBox, j );
+ j++;
+ // ueberspringe nicht existente Zellen
+ while( ( j < pActBand->nWwCols ) && !pActBand->bExist[j] )
+ {
+ //pActBand->nWidth[ j ] = 0;
+ pActBand->nWidth[ j ] = pActBand->nCenter[j+1] - pActBand->nCenter[j];
+ pActBand->nCenter[ j ] = -999;
+ j++;
+ }
+ }
+}
+
+void WW8TabDesc::TableCellEnd()
+{
+ ::SetProgressState( pIo->nProgress, pIo->rDoc.GetDocShell() ); // Update
+
+ // neue Zeile
+// BOOL bRowEnded = pIo->bWasTabRowEnd;
+ if( pIo->bWasTabRowEnd ) // bWasTabRowEnd will be deactivated
+ { // in SwWW8ImplReader::ProcessSpecial()
+
+ USHORT iCol = GetLogicalWWCol();
+ if( iCol < aNumRuleNames.Count() )
+ aNumRuleNames.DeleteAndDestroy( iCol, aNumRuleNames.Count()-iCol );
+
+ pIo->pCtrlStck->SetAttr( *pIo->pPaM->GetPoint(), 0, FALSE );
+
+ nAktCol = 0;
+ nAktRow++;
+ nAktBandRow++;
+ ASSERT( pActBand , "pActBand ist 0" );
+ if( pActBand )
+ {
+ if( nAktRow >= nRows ) // am Tabellenende gibt's nichts sinnvolles
+ return; // mehr zu tun
+
+ BOOL bNewBand = nAktBandRow >= pActBand->nRows;
+ if( bNewBand )
+ { // neues Band noetig ?
+ pActBand = pActBand->pNextBand; //
+ nAktBandRow = 0;
+ ASSERT( pActBand, "pActBand ist 0" );
+ AdjustNewBand( pIo );
+ }
+ else
+ {
+ SwTableBox* pBox = (*pTabBoxes)[0];
+ SwSelBoxes aBoxes;
+ pIo->rDoc.InsertRow( pTable->SelLineFromBox( pBox, aBoxes ) );
+ }
+ }
+ }
+ else
+ { // neue Spalte ( Zelle )
+ nAktCol++;
+ }
+ SetPamInCell( nAktCol, TRUE, TRUE );
+
+ // finish Annotated Level Numbering ?
+ if( pIo->bAnl && !pIo->bAktAND_fNumberAcross )
+ pIo->StopAnl( IsValidCell( nAktCol ) );//FALSE );//!bRowEnded ); //
+}
+
+
+// ggfs. die Box in fuer diese Col offene Merge-Gruppe eintragen
+SwTableBox* WW8TabDesc::UpdateTableMergeGroup( WW8_TCell& rCell,
+ WW8SelBoxInfo* pActGroup,
+ SwTableBox* pActBox,
+ USHORT nCol )
+{
+ // Rueckgabewert defaulten
+ SwTableBox* pResult = 0;
+
+ // pruefen, ob die Box zu mergen ist
+ if( rCell.bFirstMerged
+ || rCell.bMerged
+ || rCell.bVertMerge
+ || rCell.bVertRestart )
+ {
+ // passende Merge-Gruppe ermitteln
+ WW8SelBoxInfo* pTheMergeGroup = 0;
+ if( pActGroup )
+ // Gruppe uebernehmen
+ pTheMergeGroup = pActGroup;
+ else
+ {
+ // Gruppe finden
+ short nMGrIdx;
+ if( FindMergeGroup( pActBand->nCenter[ nCol ],
+ pActBand->nWidth[ nCol ], TRUE, nMGrIdx ) )
+ pTheMergeGroup = (*pMergeGroups)[ nMGrIdx ];
+ }
+ if( pTheMergeGroup )
+ {
+ // aktuelle Box der Merge-Gruppe hinzufuegen
+ pTheMergeGroup->Insert( pActBox, pTheMergeGroup->Count() );
+
+ // Target-Box zurueckmelden
+ pResult = (*pTheMergeGroup)[ 0 ];
+ }
+ }
+ return pResult;
+}
+
+
+USHORT WW8TabDesc::GetLogicalWWCol() const // returns number of col as INDICATED within WW6 UI status line -1
+{
+ USHORT nCol = 0;
+ if( pActBand && pActBand->pTCs)
+ {
+ for( USHORT iCol = 1; iCol <= nAktCol; ++iCol )
+ {
+ if( !pActBand->pTCs[ iCol-1 ].bMerged )
+ ++nCol;
+ }
+ }
+ return nCol;
+}
+
+const String& WW8TabDesc::GetNumRuleName() const // find name of numrule valid for current WW-COL
+{
+ USHORT nCol = GetLogicalWWCol();
+ const String* pName = aNumRuleNames.Count() > nCol
+ ? aNumRuleNames.GetObject( nCol )
+ : 0;
+ return pName ? *pName : aEmptyStr;
+}
+
+void WW8TabDesc::SetNumRuleName( const String& rName )
+{
+ USHORT nCol = GetLogicalWWCol();
+ String* pName = 0;
+ while( aNumRuleNames.Count() <= nCol )
+ {
+ aNumRuleNames.Insert( pName, aNumRuleNames.Count() );
+ }
+ String* pOldName = aNumRuleNames.GetObject( nCol );
+ pName = new String( rName );
+ aNumRuleNames.Replace( pName, nCol );
+ if( pOldName )
+ delete pOldName;
+}
+
+
+
+
+BOOL SwWW8ImplReader::StartTable()
+{
+ if( pTableDesc // keine rekursiven Tabellen
+ || bReadNoTbl ) // Nicht bei EinfuegenDatei in Tabelle
+ return FALSE; // oder Fussnote
+
+ pTableDesc = new WW8TabDesc( this );
+ if( pTableDesc->Ok() )
+ pTableDesc->CreateSwTable();
+ else
+ {
+ delete pTableDesc;
+ pTableDesc = 0;
+ }
+ return 0 != pTableDesc;
+}
+
+void SwWW8ImplReader::TabCellEnd()
+{
+ if( bTable && pTableDesc )
+ pTableDesc->TableCellEnd();
+}
+
+void SwWW8ImplReader::Read_TabRowEnd( USHORT, BYTE* pData, short nLen ) // Sprm25
+{
+ if( ( nLen > 0 ) && ( *pData == 1 ) )
+ {
+ bWasTabRowEnd = TRUE;
+ pSBase->SetNoAttrScan( 1 );
+ }
+}
+
+void SwWW8ImplReader::StopTable()
+{
+ pTableDesc->FinishSwTable();
+ delete( pTableDesc );
+ pTableDesc = 0;
+}
+
+// GetTableLeft() wird fuer absatzgebundene Grafikobjekte in Tabellen
+// gebraucht.
+// WW nimmt bei eingerueckten Tabellen den Absatzrand, der ohne Tabelle
+// gueltig waere, als Basis; SW benutzt den linken Tabellenrand.
+short SwWW8ImplReader::GetTableLeft()
+{
+ return (pTableDesc) ? pTableDesc->GetMinLeft() : 0;
+}
+
+
+BOOL SwWW8ImplReader::IsInvalidOrToBeMergedTabCell() const
+{
+ if( !pTableDesc )
+ return FALSE;
+
+ const WW8_TCell* pCell = pTableDesc->GetAktWWCell();
+
+ return !pTableDesc->IsValidCell( pTableDesc->GetAktCol() )
+ || ( pCell
+ && ( !pCell->bFirstMerged
+ && ( pCell->bMerged
+ || ( pCell->bVertMerge
+ && !pCell->bVertRestart
+ )
+ )
+ )
+ );
+}
+
+
+const USHORT SwWW8ImplReader::StyleUsingLFO( USHORT nLFOIndex ) const
+{
+ USHORT nRes = USHRT_MAX;
+ if( pCollA )
+ {
+ for(USHORT nI = 0; nI < pStyles->GetCount(); nI++ )
+ if( pCollA[ nI ].bValid
+ && (nLFOIndex == pCollA[ nI ].nLFOIndex) )
+ nRes = nI;
+ }
+ return nRes;
+}
+
+
+const SwFmt* SwWW8ImplReader::GetStyleWithOrgWWName( String& rName ) const
+{
+ SwFmt* pRet = 0;
+ if( pCollA )
+ {
+ for(USHORT nI = 0; nI < pStyles->GetCount(); nI++ )
+ if( pCollA[ nI ].bValid
+ && (rName.Equals( pCollA[ nI ].GetOrgWWName())) )
+ {
+ pRet = pCollA[ nI ].pFmt;
+ break;
+ }
+ }
+ return pRet;
+}
+
+
+
+//-----------------------------------------
+// class WW8RStyle
+//-----------------------------------------
+
+BYTE* WW8RStyle::HasParaSprm( USHORT nId ) const
+{
+ if( !pParaSprms || !nSprmsLen )
+ return 0;
+
+ BYTE* pSprms = pParaSprms;
+ BYTE nDelta;
+ short i, x;
+
+ for( i=0; i<nSprmsLen; )
+ {
+ USHORT nAktId = WW8GetSprmId( rFib.nVersion, pSprms, &nDelta );
+ // Sprm gefunden?
+ if( nAktId == nId )
+ //alt: if( *pSprms == nId )
+ return pSprms + 1 + nDelta + WW8SprmDataOfs( nId ); // Zeiger auf Daten
+ x = WW8GetSprmSizeBrutto( rFib.nVersion, pSprms, &nAktId );
+ i += x;
+ pSprms += x;
+ }
+ return 0; // Sprm nicht gefunden
+}
+
+
+void WW8RStyle::ImportSprms( long nPosFc, short nLen, BOOL bPap )
+{
+ if( pStStrm->IsEof() )
+ return;
+
+ BYTE *pSprms0 = new BYTE[nLen];
+ if( bPap )
+ {
+ pParaSprms = pSprms0; // fuer HasParaSprms()
+ nSprmsLen = nLen;
+ }
+ BYTE* pSprms1 = pSprms0;
+ pStStrm->Seek( nPosFc );
+ pStStrm->Read( pSprms0, nLen );
+
+ while ( nLen > 0 )
+ {
+ USHORT nL1 = pIo->ImportSprm( pSprms1, nLen );
+ nLen -= nL1;
+ pSprms1 += nL1;
+ }
+ delete[]( pSprms0 );
+ pParaSprms = 0;
+ nSprmsLen = 0;
+}
+
+
+short WW8RStyle::ImportUPX( short nLen, BOOL bPAP )
+{
+ INT16 cbUPX;
+
+ if( 0 < nLen ) // Empty ?
+ {
+ nLen -= WW8SkipOdd( pStStrm );
+
+ *pStStrm >> cbUPX;
+
+ nLen-= 2;
+
+ if ( cbUPX > nLen )
+ cbUPX = nLen; // !cbUPX auf nLen verkleinert!
+
+ if( (1 < cbUPX) || ( (0 < cbUPX) && !bPAP ) )
+ {
+ if( bPAP )
+ {
+ UINT16 id;
+ *pStStrm >> id;
+
+ cbUPX-= 2;
+ nLen-= 2;
+ }
+
+ if( 0 < cbUPX )
+ {
+ ULONG nPos = pStStrm->Tell(); // falls etwas falsch interpretiert
+ // wird, gehts danach wieder richtig
+ ImportSprms( nPos, cbUPX, bPAP );
+
+ if ( pStStrm->Tell() != nPos + cbUPX )
+ pStStrm->Seek( nPos+cbUPX );
+
+ nLen -= cbUPX;
+ }
+ }
+ }
+ return nLen;
+}
+
+
+void WW8RStyle::ImportGrupx( short nLen, BOOL bPara )
+{
+ if( nLen <= 0 )
+ return;
+
+// if( rFib.nVersion < 8 )
+ nLen -= WW8SkipOdd( pStStrm );
+
+ if( bPara ) nLen = ImportUPX( nLen, TRUE ); // Grupx.Papx
+ ImportUPX( nLen, FALSE ); // Grupx.Chpx
+}
+
+WW8RStyle::WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI )
+ : WW8Style( *pI->pTableStream, rFib ), pIo( pI ),
+ pStStrm( pI->pTableStream ),
+nWwNumLevel( 0 ), pStyRule( 0 )
+{
+ pIo->pCollA = new SwWW8StyInf[ cstd ]; // Style-UEbersetzung WW->SW
+ pIo->nColls = cstd;
+}
+
+
+void WW8RStyle::Set1StyleDefaults()
+{
+ if( !bFontChanged ) // Style hat keinen Font ?
+ {
+ short nWwDefaultFont = ftcStandardChpStsh;
+ pIo->SetNewFontAttr( nWwDefaultFont ); // ... dann hart 'reinsetzen
+ }
+ if( pIo->bNoAttrImport )
+ return;
+ if( !bFSizeChanged )
+ { // Style hat keine FontSize ?
+ SvxFontHeightItem aSz( 200 ); // WW-Default: 10pt
+ pIo->pAktColl->SetAttr( aSz );
+ }
+ if( pIo->pWDop->fWidowControl && !bWidowsChanged ) // Widows ?
+ {
+ pIo->pAktColl->SetAttr( SvxWidowsItem( 2 ) );
+ pIo->pAktColl->SetAttr( SvxOrphansItem( 2 ) );
+ }
+}
+
+//-----------------------------------------
+// Zeichenvorlagen
+//-----------------------------------------
+SwCharFmt* WW8RStyle::SearchCharFmt( const String& rName )
+{
+ USHORT n;
+ // Suche zuerst in den Doc-Styles
+ for( n = pIo->rDoc.GetCharFmts()->Count(); n > 0; )
+ if( (*pIo->rDoc.GetCharFmts())[ --n ]->GetName().Equals( rName ) )
+ return (*pIo->rDoc.GetCharFmts())[ n ];
+
+ // Collection noch nicht gefunden, vielleicht im Pool ?
+ n = pIo->rDoc.GetPoolId( rName , GET_POOLID_CHRFMT );
+ if ( n != USHRT_MAX ) // gefunden oder Standard
+ return pIo->rDoc.GetCharFmtFromPool( n );
+
+ return 0;
+}
+
+SwCharFmt* WW8RStyle::MakeNewCharFmt( WW8_STD* pStd, const String& rName )
+{
+ String aName( rName );
+ SwCharFmt* pFmt = 0;
+
+ if( pStd->sti != STI_USER // eingebauter Style, den wir nicht kennen ?
+ || SearchCharFmt( aName ) ){ // oder Namen gibts schon ?
+
+ if( !aName.EqualsAscii( "WW-", 0, 3 ) ) // noch kein "WW-"
+ aName.InsertAscii( "WW-", 0 ); // dann aender ihn
+
+ if( SearchCharFmt( aName ) ) // Namen gibt's immer noch ?
+ for( USHORT n = 1; n < 1000; n++ ){ // dann bastel neuen
+ String aName1( aName );
+ aName1 += String::CreateFromInt32( n );
+ if( ( pFmt = SearchCharFmt( aName1 ) ) == 0 ){
+ aName = aName1;
+ break; // unbenutzten Namen gefunden
+ }
+ }
+ }
+ if( !pFmt ) // unbenutzter Collection-Name gefunden, erzeuge neue Coll
+ pFmt = pIo->rDoc.MakeCharFmt( aName,
+ ( SwCharFmt*)pIo->rDoc.GetDfltCharFmt() ); // const Wegcasten
+
+ return pFmt;
+}
+
+
+SwCharFmt* WW8RStyle::MakeOrGetCharFmt( BOOL* pbStyExist, WW8_STD* pStd, const String& rName )
+{
+#define RES_NO RES_POOLCHR_END
+
+ static USHORT __READONLY_DATA aArr1[]={
+ RES_POOLCHR_FOOTNOTE, 0, RES_POOLCHR_LINENUM,
+ RES_POOLCHR_PAGENO, RES_POOLCHR_ENDNOTE };
+
+ static USHORT __READONLY_DATA aArr2[]={
+ RES_POOLCHR_INET_NORMAL, RES_POOLCHR_INET_VISIT,
+ RES_POOLCHR_HTML_STRONG, RES_POOLCHR_HTML_EMPHASIS };
+
+ if( pIo->bNew // Einfuegen: immer neue Styles generieren
+ && !( pIo->nIniFlags & WW8FL_NO_DEFSTYLES ) ) // nicht abgeschaltet
+ {
+ SwCharFmt* pFmt = 0;
+
+ // Default-Style bekannt ?
+ short nIdx = pStd->sti - 38;
+ if( nIdx >= 0 && nIdx < 5
+ && aArr1[nIdx]!=0 )
+ pFmt = pIo->rDoc.GetCharFmtFromPool( aArr1[ nIdx ] );
+ else
+ {
+ nIdx = pStd->sti - 85;
+ if( nIdx >= 0
+ && nIdx < 4 )
+ pFmt = pIo->rDoc.GetCharFmtFromPool( aArr2[ nIdx ] );
+ }
+ if( pFmt )
+ {
+ *pbStyExist = TRUE;
+ return pFmt;
+ }
+ }
+ {
+ *pbStyExist = FALSE;
+ String aName( rName );
+ USHORT nPos = aName.Search( ',' );
+ if( nPos ) // mehrere Namen mit Komma getrennt gibts im SW nicht
+ aName.Erase( nPos );
+ return MakeNewCharFmt( pStd, aName ); // nicht gefunden
+ }
+}
+
+//-----------------------------------------
+// Absatzvorlagen
+//-----------------------------------------
+
+SwTxtFmtColl* WW8RStyle::SearchFmtColl( const String& rName )
+{
+ // Suche zuerst in den Doc-Styles
+ SwTxtFmtColl* pColl = pIo->rDoc.FindTxtFmtCollByName( rName );
+ if( !pColl )
+ {
+ // Collection noch nicht gefunden, vielleicht im Pool ?
+ USHORT n = pIo->rDoc.GetPoolId( rName , GET_POOLID_TXTCOLL );
+ if ( n != USHRT_MAX ) // gefunden oder Standard
+ pColl = pIo->rDoc.GetTxtCollFromPool( n );
+ }
+ return pColl;
+}
+
+SwTxtFmtColl* WW8RStyle::MakeNewFmtColl( WW8_STD* pStd, const String& rName )
+{
+ String aName( rName );
+ SwTxtFmtColl* pColl = 0;
+
+ if( pStd->sti != STI_USER // eingebauter Style, den wir nicht kennen
+ || SearchFmtColl( aName ) ){ // oder Namen gibts schon ?
+
+ if( !aName.EqualsIgnoreCaseAscii( "WW-", 0, 3 ) ) // noch kein "WW-"
+ aName.Insert( WW8_ASCII2STR( "WW-" ), 0 ); // dann AEnder ihn
+
+ if( SearchFmtColl( aName ) ) // Namen gibt's immer noch ?
+ for( USHORT n = 1; n < 1000; n++ ){ // dann bastel neuen
+ String aName1( aName );
+ aName += String::CreateFromInt32( n );
+ if( ( pColl = SearchFmtColl( aName1 ) ) == 0 ){
+ aName = aName1;
+ break; // unbenutzten Namen gefunden
+ }
+ }
+ }
+ if( !pColl ) // unbenutzter Collection-Name gefunden, erzeuge neue Coll
+ pColl = pIo->rDoc.MakeTxtFmtColl( aName,
+ ( SwTxtFmtColl*)pIo->rDoc.GetDfltTxtFmtColl() ); // const Wegcasten
+
+ return pColl;
+}
+
+SwTxtFmtColl* WW8RStyle::MakeOrGetFmtColl( BOOL* pbStyExist, WW8_STD* pStd, const String& rName )
+{
+#define RES_NONE RES_POOLCOLL_DOC_END
+
+ static const RES_POOL_COLLFMT_TYPE aArr[]={
+ RES_POOLCOLL_STANDARD, RES_POOLCOLL_HEADLINE1, RES_POOLCOLL_HEADLINE2, // Ueberschrift 2
+ RES_POOLCOLL_HEADLINE3, RES_POOLCOLL_HEADLINE4, RES_POOLCOLL_HEADLINE5,
+ RES_POOLCOLL_HEADLINE6, RES_POOLCOLL_HEADLINE7, RES_POOLCOLL_HEADLINE8,
+ RES_POOLCOLL_HEADLINE9,
+
+ RES_POOLCOLL_TOX_IDX1, RES_POOLCOLL_TOX_IDX2, RES_POOLCOLL_TOX_IDX3,
+ RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,
+ RES_POOLCOLL_TOX_CNTNT1,
+
+ RES_POOLCOLL_TOX_CNTNT2, RES_POOLCOLL_TOX_CNTNT3, RES_POOLCOLL_TOX_CNTNT4,
+ RES_POOLCOLL_TOX_CNTNT5, RES_POOLCOLL_TOX_CNTNT6, RES_POOLCOLL_TOX_CNTNT7,
+ RES_POOLCOLL_TOX_CNTNT8, RES_POOLCOLL_TOX_CNTNT9,
+ RES_NONE, RES_POOLCOLL_FOOTNOTE,
+
+ RES_NONE, RES_POOLCOLL_HEADER, RES_POOLCOLL_FOOTER, RES_POOLCOLL_TOX_IDXH,
+ RES_NONE, RES_NONE, RES_POOLCOLL_JAKETADRESS, RES_POOLCOLL_SENDADRESS,
+ RES_NONE, RES_NONE,
+
+ RES_NONE, RES_NONE, RES_NONE, RES_POOLCOLL_ENDNOTE, RES_NONE, RES_NONE, RES_NONE,
+ RES_POOLCOLL_LISTS_BEGIN, RES_NONE, RES_NONE,
+
+ RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,
+ RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,
+
+ RES_NONE,RES_NONE, RES_POOLCOLL_DOC_TITEL, RES_NONE, RES_POOLCOLL_SIGNATURE, RES_NONE,
+ RES_POOLCOLL_TEXT, RES_POOLCOLL_TEXT_MOVE, RES_NONE, RES_NONE,
+
+ RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_POOLCOLL_DOC_SUBTITEL };
+
+
+ ASSERT( ( sizeof( aArr ) / sizeof( RES_POOL_COLLFMT_TYPE ) == 75 ),
+ "Style-UEbersetzungstabelle hat falsche Groesse" );
+
+#if 1
+ if( pStd->sti < sizeof( aArr ) / sizeof( RES_POOL_COLLFMT_TYPE )
+ && aArr[pStd->sti]!=RES_NONE // Default-Style bekannt
+ && !( pIo->nIniFlags & WW8FL_NO_DEFSTYLES ) ){ // nicht abgeschaltet
+
+ SwTxtFmtColl* pCol = pIo->rDoc.GetTxtCollFromPool( aArr[pStd->sti] );
+ if( pCol ){
+ *pbStyExist = TRUE;
+ return pCol;
+ }
+ }
+ {
+ String aName( rName );
+ USHORT nPos = aName.Search( ',' );
+ if( nPos ) // mehrere Namen mit Komma getrennt gibts im SW nicht
+ aName.Erase( nPos );
+ SwTxtFmtColl* pCol = SearchFmtColl( aName );
+ if( pCol ){
+ *pbStyExist = TRUE;
+ return pCol;
+ }
+ *pbStyExist = FALSE;
+ return MakeNewFmtColl( pStd, aName ); // nicht gefunden
+ }
+#else // 1
+ if( pIo->bNew // Einfuegen: immer neue Styles generieren
+ && pStd->sti < sizeof( aArr ) / sizeof( RES_POOL_COLLFMT_TYPE )
+ && aArr[pStd->sti]!=RES_NONE // Default-Style bekannt
+ && !( pIo->nIniFlags & WW8FL_NO_DEFSTYLES ) ){ // nicht abgeschaltet
+
+ SwTxtFmtColl* pCol = pIo->rDoc.GetTxtCollFromPool( aArr[pStd->sti] );
+ if( pCol ){
+ *pbStyExist = TRUE;
+ return pCol;
+ }
+ }
+ {
+ *pbStyExist = FALSE;
+ String aName( rName );
+ USHORT nPos = aName.Search( ',' );
+ if( nPos ) // mehrere Namen mit Komma getrennt gibts im SW nicht
+ aName.Erase( nPos );
+ return MakeNewFmtColl( pStd, aName ); // nicht gefunden
+ }
+#endif // !1
+}
+
+void WW8RStyle::Import1Style( USHORT nNr )
+{
+ SwWW8StyInf* pSI = &pIo->pCollA[nNr];
+
+ if( pSI->bImported || !pSI->bValid )
+ return;
+
+ pSI->bImported = TRUE; // jetzt schon Flag setzen
+ // verhindert endlose Rekursion
+ if( pSI->nBase < cstd // gueltig und nicht NIL
+ && !pIo->pCollA[pSI->nBase].bImported ) // und noch nicht Importiert
+ Import1Style( pSI->nBase );
+
+ pStStrm->Seek( pSI->nFilePos );
+
+ short nSkip, cbStd;
+ String sName;
+
+ WW8_STD* pStd = Read1Style( nSkip, &sName, &cbStd );// lies Style
+
+ if( pStd )
+ pSI->SetOrgWWIdent( sName, pStd->sti );
+
+ if( !pStd
+ || (0 == sName.Len()) // no Name or unused Slot
+ || ((1 != pStd->sgc) && (2 != pStd->sgc)) ) // unknown Style
+ {
+ pStStrm->SeekRel( nSkip );
+ return;
+ }
+ // echter Para- oder Char-Style
+ SwFmt* pColl;
+ BOOL bStyExist;
+ if( pStd->sgc == 1 ) // Para-Style
+ pColl = MakeOrGetFmtColl( &bStyExist, pStd, sName );
+ else // Char-Style
+ pColl = MakeOrGetCharFmt( &bStyExist, pStd, sName );
+
+ BOOL bImport = !bStyExist || pIo->bNew; // Inhalte Importieren ?
+ BOOL bOldNoImp = pIo->bNoAttrImport;
+ pSI->bImportSkipped = !bImport;
+
+ if( !bImport ){
+ pIo->bNoAttrImport = TRUE;
+ }
+ else
+ {
+ if( bStyExist )
+ pColl->ResetAllAttr();
+ pColl->SetAuto( FALSE ); // nach Empfehlung JP
+ } // macht die UI aber anders
+ pIo->pAktColl = pColl;
+ pSI->pFmt = pColl; // UEbersetzung WW->SW merken
+ pSI->bImportSkipped = !bImport;
+
+ // Setze Based on
+ USHORT j = pSI->nBase;
+ if( j != nNr // sinnvoller Index ?
+ && j < cstd )
+ {
+ SwWW8StyInf* pj = &pIo->pCollA[j];
+ if (
+ pSI->pFmt && pj->pFmt // Beide Formate ok ?
+ && pSI->bColl == pj->bColl ) // beides gleicher Typ ?
+ {
+ pSI->pFmt->SetDerivedFrom( pj->pFmt ); // ok, Based on eintragen
+ pSI->eFontSrcCharSet = pj->eFontSrcCharSet; // CharSet als Default
+ }
+ }
+ else if( pIo->bNew && bStyExist )
+ {
+ if( pStd->sgc == 1 )
+ pSI->pFmt->SetDerivedFrom( pIo->pStandardFmtColl );
+ else
+ pSI->pFmt->SetDerivedFrom( pIo->rDoc.GetDfltCharFmt() );
+ }
+
+ pSI->nFollow = pStd->istdNext; // Follow merken
+
+ long nPos = pStStrm->Tell(); // falls etwas falsch interpretiert
+ // wird, gehts danach wieder richtig
+
+ pStyRule = 0; // falls noetig, neu anlegen
+ bFontChanged = bFSizeChanged = bWidowsChanged = FALSE;
+ pIo->SetNAktColl( nNr );
+ pIo->bStyNormal = nNr == 0;
+
+ if( pStd && ( pStd->sgc == 1 || pStd->sgc == 2 ) ){
+ ImportGrupx( nSkip, pStd->sgc == 1 ); // Import des Style-Inhalts
+ // Alle moeglichen Attribut-Flags zuruecksetzen,
+ // da es in Styles keine Attr-Enden gibt
+ pIo->bHasBorder = pIo->bTxtCol = pIo->bShdTxtCol = pIo->bCharShdTxtCol
+ = pIo->bSpec = pIo->bObj = pIo->bSymbol = FALSE;
+ pIo->nCharFmt = -1;
+ }
+
+// if( pStd && pStd->istdBase == 0xfff // Style basiert auf Nichts
+// && pStd->sgc == 1 ){ //! Char-Styles funktionieren aus
+
+ if( pStd
+ && ( pSI->nBase >= cstd // Style basiert auf Nichts
+ || pIo->pCollA[pSI->nBase].bImportSkipped ) // oder Basis ignoriert
+ && pStd->sgc == 1 ){ //! Char-Styles funktionieren aus
+ // unerfindlichen Gruenden nicht
+ // -> dann evtl. harte WW-Defaults
+ // reinsetzen
+ Set1StyleDefaults();
+ }
+
+ pStyRule = 0; // zur Sicherheit
+ pIo->bStyNormal = FALSE;
+ pIo->SetNAktColl( 0 );
+ pIo->bNoAttrImport = bOldNoImp;
+ // rasch nochmal die Listen-Merk-Felder zuruecksetzen,
+ // fuer den Fall dass sie beim einlesen des Styles verwendet wurden
+ pIo->nLFOPosition = USHRT_MAX;
+ pIo->nListLevel = nWW8MaxListLevel;
+
+ pStStrm->Seek( nPos+nSkip );
+
+ DELETEZ( pStd );
+}
+
+
+void WW8RStyle::RegisterNumFmts()
+{
+ for(USHORT i=0; i < cstd; i++)
+ {
+ SwWW8StyInf* pSI = &pIo->pCollA[ i ];
+ if( pSI )
+ pIo->RegisterNumFmtOnStyle( *pSI );
+ }
+}
+
+
+void WW8RStyle::ScanStyles() // untersucht Style-Abhaengigkeiten
+{ // und ermittelt die Filepos fuer jeden Style
+/*
+ WW8_FC nStyleStart = rFib.fcStshf;
+ pStStrm->Seek( nStyleStart );
+ */
+ USHORT i;
+ for( i=0; i<cstd; i++ ){
+ short nSkip;
+ SwWW8StyInf* pSI = &pIo->pCollA[i];
+
+ pSI->nFilePos = pStStrm->Tell(); // merke FilePos
+ WW8_STD* pStd = Read1Style( nSkip, 0, 0 ); // read STD
+ pSI->bValid = ( 0 != pStd );
+ if( pSI->bValid
+ && !(pStd->sgc == 2 && ( pIo->nIniFlags & WW8FL_NO_ZSTYLES ) ) ){
+ pSI->nBase = pStd->istdBase; // merke Basis
+ pSI->bColl = ( pStd->sgc == 1 ); // Para-Style
+ pSI->bValid = TRUE;
+ }
+ else
+ memset( &pSI , 0, sizeof( &pSI ) );
+
+ delete pStd;
+ pStStrm->SeekRel( nSkip ); // ueberlese Namen und Sprms
+ }
+}
+
+void WW8RStyle::Import()
+{
+ pIo->pDfltTxtFmtColl = pIo->rDoc.GetDfltTxtFmtColl();
+ pIo->pStandardFmtColl = pIo->rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+
+ if( pIo->nIniFlags & WW8FL_NO_STYLES )
+ return;
+
+ ScanStyles(); // Scanne Based On
+
+ USHORT i;
+ for( i=0; i<cstd; i++ ) // Styles importieren
+ if( pIo->pCollA[i].bValid )
+ Import1Style( i );
+
+ for( i=0; i<cstd; i++ )
+ { // Follow einstellen
+ SwWW8StyInf* pi = &pIo->pCollA[i];
+ USHORT j = pi->nFollow;
+ if( j < cstd )
+ {
+ SwWW8StyInf* pj = &pIo->pCollA[j];
+ if ( j != i // sinnvoller Index ?
+ && pi->pFmt // Format ok ?
+ && pj->pFmt // Derived-Format ok ?
+ && pi->bColl // geht nur bei Absatz-Vorlagen (WW)
+ && pj->bColl ){ // beides gleicher Typ ?
+ ( (SwTxtFmtColl*)pi->pFmt )->SetNextTxtFmtColl(
+ *(SwTxtFmtColl*)pj->pFmt ); // ok, eintragen
+ }
+ }
+ }
+// Die Sonderbehandlung zur Setzen der
+// Default-Zeichenvorlage "Absatz-Standardschriftart" ( Style-ID 65 ) fehlt
+// Sie ist aber defaultmaessig leer ( WW6 dt und US ) und von der
+// WW-UI nicht zu veraendern, so dass das nicht stoert.
+// Der Mechanismus waere folgender:
+// if( bNew ) rDoc.SetDefault( pDefCharFmt->GetAttrSet() );
+//
+ // fuer z.B. Tabellen wird ein immer gueltiger Std-Style gebraucht
+
+ if( pIo->pCollA[0].pFmt && pIo->pCollA[0].bColl && pIo->pCollA[0].bValid )
+ pIo->pDfltTxtFmtColl = (SwTxtFmtColl*)pIo->pCollA[0].pFmt;
+ else
+ pIo->pDfltTxtFmtColl = pIo->rDoc.GetDfltTxtFmtColl();
+
+
+ // set Hyphenation flag on BASIC para-style
+ if( pIo->bNew
+ && pIo->pWDop->fAutoHyphen
+ && pIo->pStandardFmtColl
+ && SFX_ITEM_SET != pIo->pStandardFmtColl->GetItemState(
+ RES_PARATR_HYPHENZONE, FALSE ) )
+ {
+ SvxHyphenZoneItem aAttr( TRUE );
+ aAttr.GetMinLead() = 2;
+ aAttr.GetMinTrail() = 2;
+ aAttr.GetMaxHyphens() = 0;
+
+ pIo->pStandardFmtColl->SetAttr( aAttr );
+ }
+
+ // wir sind jetzt nicht mehr beim Style einlesen:
+ pIo->pAktColl = 0;
+}
+
+
+//-----------------------------------------
+// Document Info
+//-----------------------------------------
+
+// ReadDocInfo() liegt hier und nicht nicht in wwpar.cxx::LoadDoc1(),
+// da hier das noetige sfxcore.hxx bereits includet ist.
+
+void SwWW8ImplReader::ReadDocInfo()
+{
+ if( pStg )
+ {
+ SfxDocumentInfo* pNeu;
+ if( rDoc.GetpInfo() ) // soo ein Umstand......
+ pNeu = new SfxDocumentInfo( *rDoc.GetpInfo() );
+ else
+ pNeu = new SfxDocumentInfo();
+
+ pNeu->LoadPropertySet( pStg ); // DocInfo laden
+ rDoc.SetInfo( *pNeu );
+ delete( pNeu );
+ }
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par2.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.80 2000/09/18 16:05:00 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.79 2000/08/17 13:49:28 khz
+ #77316# set Default Char Format if no Base Format known
+
+ Revision 1.78 2000/07/28 15:37:27 khz
+ #73796# don't delete NumRule from Attr but set it into pDoc
+
+ Revision 1.77 2000/07/27 10:21:36 khz
+ #73796# stop ANList when opening next cell in a row and !bAktAND_fNumberAcross
+
+ Revision 1.76 2000/07/25 15:17:45 khz
+ #76811# read/write AutoHyphenation flag from/into Document Properties
+
+ Revision 1.75 2000/07/24 12:56:38 jp
+ Bug #76561#: convert Bulletchar to unicode
+
+ Revision 1.74 2000/07/11 11:39:06 khz
+ #76673# prepare implementation of sprmTDelete and sprmTInsert
+
+ Revision 1.73 2000/07/11 11:30:55 khz
+ #76673# prepare implementation of sprmTDelete and sprmTInsert
+
+ Revision 1.72 2000/06/08 16:12:55 khz
+ Piece table optimization only when piece table exists ;-)
+
+ Revision 1.71 2000/05/31 12:23:09 khz
+ Changes for Unicode
+
+ Revision 1.70 2000/05/25 08:06:48 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.69 2000/05/18 10:58:59 jp
+ Changes for Unicode
+
+ Revision 1.68 2000/05/16 12:13:04 jp
+ ASS_FALSE define removed
+
+ Revision 1.67 2000/05/16 11:06:21 khz
+ Unicode code-conversion
+
+ Revision 1.66 2000/05/04 07:40:47 khz
+ Task #75379# use new Save() and Restore()
+
+ Revision 1.65 2000/04/17 12:01:32 khz
+ Task #74837# prevent from breaking table (in Apo) when Apo-flag is missing
+
+*************************************************************************/
+
+
+
+
diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx
new file mode 100644
index 000000000000..542d2e093bdf
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par2.hxx
@@ -0,0 +1,371 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par2.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 _WW8PAR2_HXX
+#define _WW8PAR2_HXX
+
+#ifndef SWTYPES_HXX
+ #include "swtypes.hxx" // enum RndStdIds
+#endif
+
+
+#ifndef _FMTFSIZE_HXX //autogen
+#include <fmtfsize.hxx>
+#endif
+#ifndef _FMTORNT_HXX //autogen
+#include <fmtornt.hxx>
+#endif
+#ifndef _FMTSRND_HXX //autogen
+#include <fmtsrnd.hxx>
+#endif
+
+class SwCharFmt;
+
+#ifndef WW8PAR_HXX
+#include <ww8par.hxx> // WW8_BRC5
+#endif
+
+#ifndef WW8SCAN_HXX
+#include <ww8scan.hxx> // class WW8Style
+#endif
+
+class WW8RStyle;
+
+struct WW8FlyPara
+{ // WinWord-Attribute
+ // Achtung: *Nicht* umsortieren, da Teile mit
+ // memcmp verglichen werden
+ BOOL bVer67;
+ INT16 nSp26, nSp27; // rohe Position
+ INT16 nSp45, nSp28; // Breite / Hoehe
+ INT16 nSp48, nSp49; // Raender
+ BYTE nSp29; // rohe Bindung + Alignment
+ BYTE nSp37; // Wrap-Mode ( 1 / 2; 0 = no Apo ? )
+ WW8_BRC5 brc; // Umrandung Top, Left, Bottom, Right, Between
+ BOOL bBorderLines; // Umrandungslinien
+ BOOL bBorder; // Umrandungs-/Schatten-Struct vorhanden
+ BOOL bDropCap; // Rahmen als DropCap
+ BOOL bGrafApo; // TRUE: Dieser Rahmen dient allein dazu, die
+ // enthaltene Grafik anders als zeichengebunden
+ // zu positionieren
+
+ WW8FlyPara( BOOL bIsVer67, const WW8FlyPara* pSrc = 0 );
+ int operator == ( const WW8FlyPara& rSrc ) const;
+ BOOL Read( BYTE* pSprm29, WW8PLCFx_Cp_FKP* pPap );
+ BOOL ReadFull( BYTE* pSprm29, SwWW8ImplReader* pIo );
+ BOOL Read( BYTE* pSprm29, WW8RStyle* pStyle );
+};
+
+struct WW8SwFlyPara
+{
+ SwFrmFmt* pFlyFmt;
+
+ // 1. Teil: daraus abgeleitete Sw-Attribute
+ INT16 nXPos, nYPos; // Position
+ INT16 nLeMgn, nRiMgn; // Raender
+ INT16 nUpMgn, nLoMgn; // Raender
+ INT16 nWidth, nHeight; // Groesse
+ INT16 nNettoWidth;
+ INT16 nInnerMgn; // Rand innen
+
+ SwFrmSize eHeightFix; // Hoehe Fix oder Min
+ RndStdIds eAnchor; // Bindung
+ SwRelationOrient eHRel; // Seite oder Seitenrand
+ SwRelationOrient eVRel; // Seite oder Seitenrand
+ SwVertOrient eVAlign; // Oben, unten, mittig
+ SwHoriOrient eHAlign; // links, rechts, mittig
+ SwSurround eSurround; // Wrap-Mode
+
+ BYTE nXBind, nYBind; // relativ zu was gebunden
+
+ // 2.Teil: sich waehrend des Einlesens ergebende AEnderungen
+ long nNewNettoWidth;
+ SwPosition* pMainTextPos; // um nach Apo in Haupttext zurueckzukehren
+ USHORT nLineSpace; // LineSpace in tw fuer Graf-Apos
+ BOOL bAutoWidth;
+ BOOL bToggelPos;
+
+
+ WW8SwFlyPara( SwPaM& rPaM, SwWW8ImplReader& rIo, WW8FlyPara& rWW,
+ short nPgTop,
+ short nPgLeft,
+ short nPgWidth, INT32 nIniFlyDx, INT32 nIniFlyDy );
+
+ void BoxUpWidth( long nWidth );
+ const SwPosition* GetMainTextPos() const // Fuer PageDesc aus Apo
+ { return pMainTextPos; };
+};
+
+
+class SwWW8StyInf
+{
+ String sWWStyleName;
+ USHORT nWWStyleId;
+public:
+ SwFmt* pFmt;
+ WW8FlyPara* pWWFly;
+ SwNumRule* pOutlineNumrule;
+ long nFilePos;
+ short nLeftParaMgn;
+ short nTxtFirstLineOfst;
+ USHORT nBase;
+ USHORT nFollow;
+ USHORT nLFOIndex;
+ rtl_TextEncoding eFontSrcCharSet; // rtl_TextEncoding fuer den Font
+ BYTE nListLevel;
+ BYTE nOutlineLevel; // falls Gliederungs-Style
+ BYTE n81Flags; // Fuer Bold, Italic, ...
+ BOOL bValid :1; // leer oder Valid
+ BOOL bImported :1; // fuers rekursive Importieren
+ BOOL bColl :1; // TRUE -> pFmt ist SwTxtFmtColl
+ BOOL bImportSkipped :1; // nur TRUE bei !bNewDoc && vorh. Style
+ BOOL bHasStyNumRule :1; // TRUE -> Benannter NumRule in Style
+
+ SwWW8StyInf() :
+ sWWStyleName( aEmptyStr ),
+ nWWStyleId( 0 ),
+ pFmt( 0 ),
+ pWWFly( 0 ),
+ pOutlineNumrule( 0 ),
+ nFilePos( 0 ),
+ nLeftParaMgn( 0 ),
+ nTxtFirstLineOfst( 0 ),
+ nBase( 0 ),
+ nFollow( 0 ),
+ nLFOIndex( USHRT_MAX ),
+ eFontSrcCharSet( 0 ),
+ nListLevel( nWW8MaxListLevel ),
+ nOutlineLevel( MAXLEVEL ),
+ n81Flags( 0 ),
+ bValid( FALSE ),
+ bImported( FALSE ),
+ bColl( FALSE ),
+ bImportSkipped( FALSE ),
+ bHasStyNumRule( FALSE )
+ {}
+
+ ~SwWW8StyInf()
+ {
+ delete( pWWFly );
+ }
+
+ void SetOrgWWIdent( const String& rName, const USHORT nId )
+ {
+ sWWStyleName = rName;
+ nWWStyleId = nId;
+ }
+ const USHORT GetWWStyleId() const { return nWWStyleId; }
+ const String& GetOrgWWName() const
+ {
+ return sWWStyleName;
+ }
+};
+
+
+class WW8RStyle: public WW8Style
+{
+friend class SwWW8ImplReader;
+ SwWW8ImplReader* pIo; // Parser-Klasse
+ SvStream* pStStrm; // Input-File
+
+ SwNumRule* pStyRule; // Bullets und Aufzaehlungen in Styles
+
+ BYTE* pParaSprms; // alle ParaSprms des UPX falls UPX.Papx
+ short nSprmsLen; // Laenge davon
+
+ BYTE nWwNumLevel; // fuer Bullets und Aufzaehlungen in Styles
+
+ BOOL bFontChanged : 1; // Fuer Simulation Default-Font
+ BOOL bFSizeChanged : 1; // Fuer Simulation Default-FontSize
+ BOOL bWidowsChanged : 1; // Fuer Simulation Default-Widows / Orphans
+
+ void ImportSprms( long nPosFc, short nLen, BOOL bPap );
+ void ImportGrupx( short nLen, BOOL bPara );
+ short ImportUPX( short nLen, BOOL bPAP );
+
+
+ SwCharFmt* SearchCharFmt( const String& rName );
+ SwCharFmt* MakeNewCharFmt( WW8_STD* pStd, const String& rName );
+ SwCharFmt* MakeOrGetCharFmt( BOOL* pbStyExist, WW8_STD* pStd, const String& rName );
+
+ SwTxtFmtColl* SearchFmtColl( const String& rName );
+ SwTxtFmtColl* MakeNewFmtColl( WW8_STD* pStd, const String& rName );
+ SwTxtFmtColl* MakeOrGetFmtColl( BOOL* pbStyExist, WW8_STD* pStd, const String& rName );
+
+ void Set1StyleDefaults();
+ void Import1Style( USHORT nNr );
+ void ScanStyles();
+public:
+ WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
+ void Import();
+ void RegisterNumFmts();
+ BYTE* HasParaSprm( USHORT nId ) const;
+};
+
+class WW8FlySet: public SfxItemSet
+{
+public:
+ WW8FlySet( SwWW8ImplReader& rReader, /*const*/ WW8FlyPara* pFW,
+ /*const*/ WW8SwFlyPara* pFS, BOOL bGraf );
+ WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM,
+ const WW8_PIC& rPic, long nWidth, long nHeight );
+};
+
+enum WW8LvlType { WW8_None, WW8_Outline, WW8_Numbering, WW8_Sequence, WW8_Pause };
+
+inline WW8LvlType GetNumType( BYTE nWwLevelNo )
+{
+ WW8LvlType nRet = WW8_None;
+ if( nWwLevelNo == 12 )
+ nRet = WW8_Pause;
+ else if( nWwLevelNo == 10 )
+ nRet = WW8_Numbering;
+ else if( nWwLevelNo == 11 )
+ nRet = WW8_Sequence;
+ else if( nWwLevelNo > 0 && nWwLevelNo <= 9 )
+ nRet = WW8_Outline;
+ return nRet;
+}
+
+#define STI_USER 0xffe
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par2.hxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.22 2000/09/18 16:05:00 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.21 2000/05/16 12:03:56 jp
+ Changes for unicode
+
+ Revision 1.20 2000/05/16 11:14:53 khz
+ Unicode code-conversion
+
+ Revision 1.19 2000/04/12 11:06:17 khz
+ Task #74260# import FLY_PAGE-frames in Header/Footer as FLY_AT_CNTNT
+
+ Revision 1.18 1999/12/09 16:46:32 khz
+ Task #69180# allow Tabs if right of 1st-line-start OR right of paragraph margin
+
+ Revision 1.17 1999/12/09 14:52:30 khz
+ Task #67145# Don't set NumRule if OutlineNumrule is set on Style
+
+ Revision 1.16 1999/12/01 14:35:48 khz
+ Task #68488# Graphics in Sections with more than one Column
+
+ Revision 1.15 1999/11/05 17:04:13 khz
+ import new TOX_CONTENT and TOX_INDEX features (4)
+
+ Revision 1.14 1999/11/05 10:22:15 khz
+ import new TOX_CONTENT and TOX_INDEX features (3)
+
+ Revision 1.13 1999/11/02 15:59:42 khz
+ import new TOX_CONTENT and TOX_INDEX features (2)
+
+ Revision 1.12 1999/04/28 21:03:30 KHZ
+ Task #65245# Breite eines Rahmens bei WW \'automatisch\' muss PRTAREA sein
+
+
+ Rev 1.11 28 Apr 1999 23:03:30 KHZ
+ Task #65245# Breite eines Rahmens bei WW 'automatisch' muss PRTAREA sein
+
+ Rev 1.10 28 Jan 1999 17:10:42 KHZ
+ Task #60715# in SdrTextObj verankerte Grafiken und OLEs (4)
+
+ Rev 1.9 25 Jan 1999 10:24:58 KHZ
+ Task #60715# in Textobjekt verankerte Grafik als Grafik importieren
+
+ Rev 1.8 08 Dec 1998 18:26:52 KHZ
+ Task #59580# TOC-Import
+
+ Rev 1.7 04 Dec 1998 17:56:40 JP
+ Bug #59619#: falls ein Rahmen eine Umrandung hat, darf der Absatz keine bekommen
+
+ Rev 1.6 19 Nov 1998 22:34:46 JP
+ Task #59476#: Umstellungen fuers korrekte lesen von Umrandungen/Schatten
+
+ Rev 1.5 15 Sep 1998 12:58:24 HJS
+ '#56161#
+
+ Rev 1.4 28 Jul 1998 11:02:06 KHZ
+ Task #52607# nummerierte Listen (Teil 1)
+
+ Rev 1.3 14 Jul 1998 16:33:04 KHZ
+ Task #52607# Absatz- und Zeichen-Styles
+
+ Rev 1.2 30 Jun 1998 21:33:24 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.1 16 Jun 1998 18:34:56 KHZ
+ DaSi-Stand
+
+ Rev 1.0 16 Jun 1998 10:57:16 KHZ
+ Initial revision.
+
+*************************************************************************/
+#endif
+
+
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
new file mode 100644
index 000000000000..28de294b6ee6
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -0,0 +1,2191 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par3.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+
+#pragma hdrstop
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
+#include <com/sun/star/form/XForm.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XIMAGEPRODUCERSUPPLIER_HPP_
+#include <com/sun/star/form/XImageProducerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_
+#include <com/sun/star/form/XFormController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
+#include <com/sun/star/form/XFormComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLERLISTENER_HPP_
+#include <com/sun/star/form/XFormControllerListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
+#include <com/sun/star/frame/XStorable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XCONNECTABLESHAPE_HPP_
+#include <com/sun/star/drawing/XConnectableShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XCONNECTORSHAPE_HPP_
+#include <com/sun/star/drawing/XConnectorShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_
+#include <com/sun/star/drawing/XControlShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPEALIGNER_HPP_
+#include <com/sun/star/drawing/XShapeAligner.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPEGROUP_HPP_
+#include <com/sun/star/drawing/XShapeGroup.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPEDESCRIPTOR_HPP_
+#include <com/sun/star/drawing/XShapeDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XUNIVERSALSHAPEDESCRIPTOR_HPP_
+#include <com/sun/star/drawing/XUniversalShapeDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPEMIRROR_HPP_
+#include <com/sun/star/drawing/XShapeMirror.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPEARRANGER_HPP_
+#include <com/sun/star/drawing/XShapeArranger.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGE_HPP_
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#endif
+//#ifndef _COM_SUN_STAR_DRAWING_XSHAPEBINDER_HPP_
+//#include <com/sun/star/drawing/XShapeBinder.hpp>
+//#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_
+#include <com/sun/star/drawing/XShapes.hpp>
+#endif
+//#ifndef _COM_SUN_STAR_DRAWING_XSHAPEGROUPER_HPP_
+//#include <com/sun/star/drawing/XShapeGrouper.hpp>
+//#endif
+//#ifndef _COM_SUN_STAR_DRAWING_XSHAPECOMBINER_HPP_
+//#include <com/sun/star/drawing/XShapeCombiner.hpp>
+//#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+//#ifndef _COM_SUN_STAR_LOADER_XIMPLEMENTATIONLOADER_HPP_
+//#include <com/sun/star/loader/XImplementationLoader.hpp>
+//#endif
+//#ifndef _COM_SUN_STAR_LOADER_CANNOTACTIVATEFACTORYEXCEPTION_HPP_
+//#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
+//#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HPP_
+#include <com/sun/star/text/VertOrientation.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP_
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#endif
+
+#ifndef _SFXITEMITER_HXX //autogen
+#include <svtools/itemiter.hxx>
+#endif
+
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+
+
+#ifndef _SVX_FHGTITEM_HXX
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX
+#include <svx/postitem.hxx>
+#endif
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_WRKWIN_HXX
+#include <vcl/wrkwin.hxx>
+#endif
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+
+/*
+#ifndef _TOOLKIT_UNOIFACE_HXX
+#include <toolkit/unoiface.hxx>
+#endif
+*/
+
+#ifndef _TOOLKIT_UNOHLP_HXX
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+#ifndef _ERRHDL_HXX //autogen
+#include <errhdl.hxx>
+#endif
+#ifndef _UNOOBJ_HXX //autogen
+#include <unoobj.hxx>
+#endif
+#ifndef _DOC_HXX //autogen
+#include <doc.hxx>
+#endif
+#ifndef _DOCARY_HXX
+#include <docary.hxx>
+#endif
+#ifndef _SWDOCSH_HXX //autogen
+#include <docsh.hxx>
+#endif
+#ifndef _NUMRULE_HXX //autogen
+#include <numrule.hxx>
+#endif
+#ifndef _PARATR_HXX //autogen
+#include <paratr.hxx>
+#endif
+#ifndef _CHARATR_HXX //autogen
+#include <charatr.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen
+#include <charfmt.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen
+#include <ndtxt.hxx>
+#endif
+
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx>
+#endif
+#ifndef _WW8PAR2_HXX
+#include <ww8par2.hxx> // wg. Listen-Attributen in Styles
+#endif
+
+#ifndef _MSOCXIMP_HXX
+#include <msocximp.hxx>
+#endif
+
+#ifdef __WW8_NEEDS_COPY
+void WW8PicShadowToReal( WW8_PIC_SHADOW* pPicS, WW8_PIC* pPic );
+#endif // defined __WW8_NEEDS_COPY
+
+using namespace ::com::sun::star;
+
+
+//-----------------------------------------
+// UNO-Controls
+//-----------------------------------------
+
+#define WW8_DFLT_EDIT_WIDTH 2750
+#define WW8_DFLT_EDIT_HEIGHT 500
+#define WW8_DFLT_CHECKBOX_WIDTH 320
+#define WW8_DFLT_CHECKBOX_HEIGHT 320
+
+static sal_Char sWW8_form[] = "WW-Standard";
+static sal_Char sWW8_edit[] = "TextBox";
+static sal_Char sWW8_checkbox[] = "CheckBox";
+
+
+
+uno::Reference< drawing::XShape> SwWW8ImplReader::InsertControl(
+ //const uno::Reference< form::XFormComponent > & rFComp,
+ const uno::Reference< form::XFormComponent > & rFComp,
+ const awt::Size& rSize,
+ BOOL bFloatingCtrl )
+{
+ return pFormImpl->InsertControl( rFComp, rSize, bFloatingCtrl );
+}
+
+
+void SwWW8ImplReader::BuildInputField( sal_uInt16 nType, const String& rParam )
+{
+ if( nIniFlags & WW8FL_NO_VCCONTROLS )
+ {
+#ifdef DEBUG
+ rDoc.Insert( *pPaM, sal_Unicode ('#') );
+ static long l;
+ l++;
+#endif
+ return;
+ }
+
+ if( !pDrawModel ) // MIB: Braucht man das?
+ GrafikCtor();
+ if( !pFormImpl )
+ pFormImpl = new SwImportControls(rDoc.GetDocShell(),pPaM);
+
+ const uno::Reference< lang::XMultiServiceFactory > & rServiceFactory =
+ pFormImpl->GetServiceFactory();
+ if(!rServiceFactory.is())
+ return;
+
+ String sType;
+ switch( (SwWw8ControlType)nType )
+ {
+ case WW8_CT_CHECKBOX:
+ sType.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CheckBox" ));
+ break;
+// case WW8_CT_EDIT:
+ default:
+ sType.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TextField" ));
+ // see change in ../html/htmlform.cxx
+ break; // as of 1999/11/25 11:20:16 made by O.Specht
+ }
+
+ String sServiceName( WW8_ASCII2STR( "com.sun.star.form.component." ));
+ sServiceName.Append( sType );
+ uno::Reference< uno::XInterface > xCreate = rServiceFactory->createInstance( sServiceName );
+ if( !xCreate.is() )
+ return;
+
+ uno::Reference< form::XFormComponent > xFComp( xCreate, uno::UNO_QUERY );
+ if( !xFComp.is() )
+ return;
+
+ com::sun::star::awt::Size aSz;
+ String sName;
+ sal_uInt16 nControl;
+ switch( (SwWw8ControlType)nType )
+ {
+ case WW8_CT_EDIT:
+ aSz.Width = WW8_DFLT_EDIT_WIDTH; // etwas 20 Zeichen
+ aSz.Height = WW8_DFLT_EDIT_HEIGHT;
+ sName.AssignAscii( sWW8_edit );
+ nControl = pFormImpl->GetEditNum();
+ break;
+
+ case WW8_CT_CHECKBOX:
+ aSz.Width = WW8_DFLT_CHECKBOX_WIDTH;
+ aSz.Height = WW8_DFLT_CHECKBOX_HEIGHT;
+ sName.AssignAscii( sWW8_checkbox );
+ nControl = pFormImpl->GetCheckboxNum();
+ break;
+ }
+
+ uno::Reference< beans::XPropertySet > xPropSet( xCreate, uno::UNO_QUERY );
+
+ String sTmp( nControl );
+ UniString sWTmp( sTmp );
+ sName += sWTmp;
+ uno::Any aTmp;
+ rtl::OUString uTmp(sName);
+ aTmp <<= uTmp;
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
+
+ InsertControl( xFComp, aSz );
+}
+
+//cmc, OCX i.e. word 97 form controls
+eF_ResT SwWW8ImplReader::Read_F_OCX( WW8FieldDesc*, String& rStr )
+{
+ if( bObj && nPicLocFc )
+ nObjLocFc = nPicLocFc;
+ bEmbeddObj = TRUE;
+ return F_TEXT;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr )
+{
+ if (0x01 == rStr.GetChar( pF->nLCode-1 ))
+ {
+ WW8FormulaEditBox aFormula(*this);
+ if (ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1, WW8_CT_EDIT))
+ {
+ if( !pFormImpl )
+ pFormImpl = new SwImportControls(rDoc.GetDocShell(),pPaM);
+ if (pFormImpl->InsertFormula(aFormula))
+ return F_OK;
+ }
+ }
+ ASSERT(0,"New Formula Code Failed!\n");
+ BuildInputField( WW8_CT_EDIT, rStr );
+ return F_OK;
+
+}
+
+eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, String& rStr )
+{
+ if (0x01 == rStr.GetChar( pF->nLCode-1 ))
+ {
+ WW8FormulaCheckBox aFormula(*this);
+ if (ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1,
+ WW8_CT_CHECKBOX))
+ {
+ if( !pFormImpl )
+ pFormImpl = new SwImportControls(rDoc.GetDocShell(),pPaM);
+ if (pFormImpl->InsertFormula(aFormula))
+ return F_OK;
+ }
+ }
+ ASSERT(!this,"New Formula Code Failed!\n");
+ BuildInputField( WW8_CT_CHECKBOX, rStr );
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc*, String& rStr )
+{
+ return F_TAGIGN;
+}
+
+
+void SwWW8ImplReader::DeleteFormImpl()
+{
+ delete pFormImpl;
+ pFormImpl = 0;
+}
+
+//----------------------------------------------------------------------------
+// WW8ListManager oeffentliche Methoden stehen ganz am Ende
+//------------------------- ============ --------------- ============ --------
+
+
+
+// Hilfs-Deklarationen ///////////////////////////////////////////////////////
+//
+// Style Id's for each level
+typedef sal_uInt16 WW8aIdSty[ nWW8MaxListLevel];
+// Zeichenattribute aus GrpprlChpx
+typedef SfxItemSet* WW8aISet[nWW8MaxListLevel];
+// Zeichen Style Pointer
+typedef SwCharFmt* WW8aCFmt[ nWW8MaxListLevel];
+
+struct WW8LST // nur DIE Eintraege, die WIR benoetigen!
+{
+ WW8aIdSty aIdSty; // Style Id's for each level,
+ // nIStDNil if no style linked
+ sal_uInt32 nIdLst; // Unique List ID
+ sal_uInt32 nTplC; // Unique template code - Was ist das bloss?
+ sal_Bool bSimpleList:1; // Flag: Liste hat nur EINEN Level
+ sal_Bool bRestartHdn:1; // WW6-Kompatibilitaets-Flag:
+ // true if the list should start numbering over
+}; // at the beginning of each section
+
+struct WW8LFO // nur DIE Eintraege, die WIR benoetigen!
+{
+ SwNumRule* pNumRule; // Parent NumRule
+ sal_uInt32 nIdLst; // Unique List ID
+ sal_uInt8 nLfoLvl; // count of levels whose format is overridden
+ sal_Bool bSimpleList;
+};
+
+#define nIStDNil 0x0FFF // d.h. KEIN Style ist an den Level gelinkt
+#define nSizeOfLST 0x1C
+
+struct WW8LVL // nur DIE Eintraege, die WIR benoetigen!
+{
+ long nStartAt; // start at value for this value
+ long nV6DxaSpace;// Ver6-Compatible: min Space between Num anf ::com::sun::star::text::Paragraph
+ long nV6Indent; // Ver6-Compatible: Breite des Prefix Textes; ggfs. zur
+ // Definition d. Erstzl.einzug nutzen!
+ // Absatzattribute aus GrpprlPapx
+ sal_uInt16 nDxaLeft; // linker Einzug
+ short nDxaLeft1; // Erstzeilen-Einzug
+
+ sal_uInt8 nNFC; // number format code
+ sal_uInt8 aOfsNumsXCH[nWW8MaxListLevel];// Offset der Feldkodes im Num-X-String
+ sal_uInt8 nLenGrpprlChpx; // length, in bytes, of the LVL's grpprlChpx
+ sal_uInt8 nLenGrpprlPapx; // length, in bytes, of the LVL's grpprlPapx
+ sal_uInt8 nAlign: 2; // alignment (left, right, centered) of the number
+ sal_Bool bLegal: 1; // egal
+ sal_Bool bNoRest:1; // egal
+ sal_Bool bV6Prev:1; // Ver6-Compatible: number will include previous levels
+ sal_Bool bV6PrSp:1; // Ver6-Compatible: egal
+ sal_Bool bV6: 1; // falls sal_True, beachte die V6-Compatible Eintraege!
+ sal_uInt8 bDummy: 1; // (macht das Byte voll)
+
+};
+
+struct WW8LFOLVL
+{
+ long nStartAt; // start-at value if bFormat==false and bStartAt == true
+ // (if bFormat==true, the start-at is stored in the LVL)
+ sal_uInt8 nLevel; // the level to be overridden
+ // dieses Byte ist _absichtlich_ nicht in das folgende Byte hineingepackt !!
+ // (siehe Kommentar unten bei struct WW8LFOInfo)
+
+ sal_Bool bStartAt :1; // true if the start-at value is overridden
+ sal_Bool bFormat :1; // true if the formatting is overriden
+};
+
+
+
+// in den ListenInfos zu speichernde Daten ///////////////////////////////////
+//
+struct WW8LSTInfo // sortiert nach nIdLst (in WW8 verwendete Listen-Id)
+{
+ WW8aIdSty aIdSty; // Style Id's for each level
+ WW8aISet aItemSet; // Zeichenattribute aus GrpprlChpx
+ WW8aCFmt aCharFmt; // Zeichen Style Pointer
+
+ SwNumRule* pNumRule; // Zeiger auf entsprechende Listenvorlage im Writer
+ sal_uInt32 nIdLst; // WW8Id dieser Liste
+ sal_uInt16 nStreamPos; // Reihenfolge des Auftretens des LST im PLCF LST
+ // siehe auch "WW8ListManager::GetLSTByStreamPos()"
+ sal_Bool bSimpleList:1;// Flag, ob diese NumRule nur einen Level verwendet
+ sal_Bool bUsedInDoc :1;// Flag, ob diese NumRule im Doc verwendet wird,
+ // oder beim Reader-Ende geloescht werden sollte
+
+ // Hilfs Ctor, benoetigt innerhalb von WW8ListManager::GetLSTByListId()
+ WW8LSTInfo(sal_uInt32 nIdLst_): nIdLst( nIdLst_){}
+
+ // normaler Ctor
+ WW8LSTInfo(SwNumRule* pNumRule_, WW8LST& aLST, sal_uInt16 nStreamPos_):
+ nIdLst( aLST.nIdLst ),
+ nStreamPos( nStreamPos_ ),
+ pNumRule( pNumRule_ ),
+ bSimpleList(aLST.bSimpleList),
+ bUsedInDoc( 0 )
+ {
+ memcpy( aIdSty, aLST.aIdSty, sizeof( aIdSty ));
+ memset(&aItemSet, 0, sizeof( aItemSet ));
+ memset(&aCharFmt, 0, sizeof( aCharFmt ));
+ }
+
+ sal_Bool operator==( const WW8LSTInfo& rEntry ) const
+ { return nIdLst == rEntry.nIdLst; }
+ sal_Bool operator<( const WW8LSTInfo& rEntry ) const
+ { return nIdLst < rEntry.nIdLst; }
+};
+
+SV_IMPL_OP_PTRARR_SORT(WW8LSTInfos, WW8LSTInfo_Ptr)
+
+
+// in den ListenFormatOverrideInfos zu speichernde Daten /////////////////////
+//
+struct WW8LFOInfo // unsortiert, d.h. Reihenfolge genau wie im WW8 Stream
+{
+ SwNumRule* pNumRule; // Zeiger auf entsprechende Listenvorlage im Writer
+ // entweder: Liste in LSTInfos oder eigene Liste
+ // (im Ctor erstmal die aus den LSTInfos merken)
+
+ sal_uInt32 nIdLst; // WW8-Id der betreffenden Liste
+ sal_uInt8 nLfoLvl; // count of levels whose format is overridden
+ // Ja, ich natuerlich koennten wir nLfoLvl (mittels :4) noch in das folgende
+ // Byte mit hineinpacken, doch waere das eine ziemliche Fehlerquelle,
+ // an dem Tag, wo MS ihr Listenformat auf mehr als 15 Level aufbohren.
+
+ sal_Bool bOverride :1;// Flag, ob die NumRule nicht in pLSTInfos steht,
+ // sondern fuer pLFOInfos NEU angelegt wurde
+ sal_Bool bSimpleList:1;// Flag, ob diese NumRule nur einen Level verwendet
+ sal_Bool bUsedInDoc :1;// Flag, ob diese NumRule im Doc verwendet wird,
+ // oder beim Reader-Ende geloescht werden sollte
+ sal_Bool bLSTbUIDSet :1;// Flag, ob bUsedInDoc in pLSTInfos gesetzt wurde,
+ // und nicht nochmals gesetzt zu werden braucht
+ WW8LFOInfo( const WW8LFO& rLFO ):
+ nIdLst( rLFO.nIdLst ),
+ pNumRule( rLFO.pNumRule ),// hier bloss die Parent NumRule
+ nLfoLvl( rLFO.nLfoLvl ),
+ bOverride( rLFO.nLfoLvl ? sal_True : sal_False ),
+ bSimpleList(rLFO.bSimpleList ),
+ bUsedInDoc( 0 ),
+ bLSTbUIDSet( 0 ){}
+};
+
+SV_IMPL_PTRARR( WW8LFOInfos, WW8LFOInfo_Ptr );
+
+
+// Hilfs-Methoden ////////////////////////////////////////////////////////////
+//
+
+// finden der Sprm-Parameter-Daten, falls Sprm im Grpprl enthalten
+sal_uInt8* WW8ListManager::GrpprlHasSprm(sal_uInt16 nId, sal_uInt8& rSprms, sal_uInt8 nLen)
+{
+ sal_uInt8* pSprms = &rSprms;
+ for(sal_uInt8 i=0; i<nLen; )
+ {
+ sal_uInt8 nDelta;
+ sal_uInt16 nAktId = WW8GetSprmId(rFib.nVersion, pSprms, &nDelta );
+ if( nAktId == nId ) // Sprm gefunden
+ return pSprms + 1 + nDelta + WW8SprmDataOfs( nId );
+ // gib Zeiger auf Daten
+ short x = WW8GetSprmSizeBrutto(rFib.nVersion, pSprms, &nAktId );
+ i += x;
+ pSprms += x;
+ }
+ return 0; // Sprm nicht gefunden
+}
+
+// Zugriff ueber die List-Id des LST Eintrags
+WW8LSTInfo* WW8ListManager::GetLSTByListId( sal_uInt32 nIdLst ) const
+{
+ WW8LSTInfo aEntry( nIdLst );
+ sal_uInt16 nPos;
+ if( !pLSTInfos->Seek_Entry( &aEntry, &nPos ) ) return 0;
+ return pLSTInfos->GetObject( nPos );
+}
+
+// Zugriff ueber Reihenfolge der LST Eintraege im PLCF LST (Null basiert)
+WW8LSTInfo* WW8ListManager::GetLSTByStreamPos( sal_uInt16 nStreamPos ) const
+{
+ if( !pLSTInfos ) return 0;
+ WW8LSTInfo* pEntry;
+ for(sal_uInt16 nPos = nLSTInfos; nPos; )
+ {
+ pEntry = pLSTInfos->GetObject( --nPos );
+ if( pEntry && ( pEntry->nStreamPos == nStreamPos )) return pEntry;
+ }
+ return 0;
+}
+
+sal_Bool WW8ListManager::ReadLVL( sal_uInt8 nLevel,
+ SwNumFmt& rNumFmt,
+ SfxItemSet*& rpItemSet,
+ sal_uInt16 nLevelStyle,
+ sal_Bool bSetStartNo )
+{
+ sal_uInt8 aBits1;
+ sal_uInt8 nUpperLevel = 0; // akt. Anzeigetiefe fuer den Writer
+ sal_uInt16 nStartNo = 0; // Start-Nr. fuer den Writer
+ SvxExtNumType eType; // Writer-Num-Typ
+ SvxAdjust eAdj; // Ausrichtung (Links/rechts/zent.)
+ sal_Unicode cBullet;
+ String aPrefix;
+ String aPostfix;
+ WW8LVL aLVL;
+ //
+ // 1. LVLF einlesen
+ //
+ memset(&aLVL, 0, sizeof( aLVL ));
+ rSt >> aLVL.nStartAt;
+ rSt >> aLVL.nNFC;
+ rSt >> aBits1;
+ if( 0 != rSt.GetError() ) return sal_False;
+ aLVL.nAlign = (aBits1 & 0x03);
+ if( aBits1 & 0x10 ) aLVL.bV6Prev = sal_True;
+ if( aBits1 & 0x20 ) aLVL.bV6PrSp = sal_True;
+ if( aBits1 & 0x40 ) aLVL.bV6 = sal_True;
+ sal_Bool bLVLOkB = sal_True;
+ for(sal_uInt8 nLevelB = 0; nLevelB < nWW8MaxListLevel; nLevelB++)
+ {
+ rSt >> aLVL.aOfsNumsXCH[ nLevelB ];
+ if( 0 != rSt.GetError() )
+ {
+ bLVLOkB = sal_False;
+ break;
+ }
+ if( !nUpperLevel && !aLVL.aOfsNumsXCH[ nLevelB ] )
+ {
+ nUpperLevel = nLevelB;
+ }
+ }
+ if( !bLVLOkB ) return sal_False;
+
+ // falls kein NULL als Terminierungs-Char kam,
+ // ist die Liste voller Indices, d.h. alle Plaetze sind besetzt,
+ // also sind alle Level anzuzeigen
+ if( !nUpperLevel )
+ nUpperLevel = nWW8MaxListLevel;
+
+
+ rSt.SeekRel( 1 );
+ rSt >> aLVL.nV6DxaSpace;
+ rSt >> aLVL.nV6Indent;
+ rSt >> aLVL.nLenGrpprlChpx;
+ rSt >> aLVL.nLenGrpprlPapx;
+ rSt.SeekRel( 2 );
+ if( 0 != rSt.GetError()) return sal_False;
+
+ //
+ // 2. ggfs. PAPx einlesen und nach Einzug-Werten suchen
+ //
+ if( aLVL.nLenGrpprlPapx )
+ {
+ sal_uInt8 aGrpprlPapx[ 255 ];
+ if(aLVL.nLenGrpprlPapx != rSt.Read(&aGrpprlPapx,
+ aLVL.nLenGrpprlPapx )) return sal_False;
+ // "sprmPDxaLeft" pap.dxaLeft;dxa;word;
+ sal_uInt8* pSprm;
+ if( (pSprm = GrpprlHasSprm(0x840F,aGrpprlPapx[0],
+ aLVL.nLenGrpprlPapx)) )
+ {
+ short nDxaLeft = SVBT16ToShort( pSprm );
+ aLVL.nDxaLeft = (0 < nDxaLeft)
+ ? (sal_uInt16)nDxaLeft
+ : (sal_uInt16)(-nDxaLeft);
+ }
+ // "sprmPDxaLeft1" pap.dxaLeft1;dxa;word;
+ if( (pSprm = GrpprlHasSprm(0x8411,aGrpprlPapx[0],
+ aLVL.nLenGrpprlPapx)) )
+ aLVL.nDxaLeft1 = SVBT16ToShort( pSprm );
+ }
+ //
+ // 3. ggfs. CHPx einlesen und
+ //
+ if( aLVL.nLenGrpprlChpx )
+ {
+ sal_uInt8 aGrpprlChpx[ 255 ];
+ memset(&aGrpprlChpx, 0, sizeof( aGrpprlChpx ));
+ if(aLVL.nLenGrpprlChpx != rSt.Read(&aGrpprlChpx,
+ aLVL.nLenGrpprlChpx)) return sal_False;
+ // neues ItemSet fuer die Zeichenattribute anlegen
+ rpItemSet = new SfxItemSet( rDoc.GetAttrPool(), RES_CHRATR_BEGIN,
+ RES_CHRATR_END - 1 );
+ // Reader-ItemSet-Pointer darauf zeigen lassen
+ rReader.SetAktItemSet( rpItemSet );
+ // Reader-Style auf den Style dieses Levels setzen
+ sal_uInt16 nOldColl = rReader.GetNAktColl();
+ sal_uInt16 nNewColl = nLevelStyle;
+ if( nIStDNil == nNewColl )
+ nNewColl = 0;
+ rReader.SetNAktColl( nNewColl );
+
+ // Nun den GrpprlChpx einfach durchnudeln: die Read_xy() Methoden
+ // in WW8PAR6.CXX rufen ganz normal ihr NewAttr() oder GetFmtAttr()
+ // und diese merken am besetzten Reader-ItemSet-Pointer, dass dieser
+ // spezielle ItemSet relevant ist - und nicht ein Stack oder Style!
+ short nLen = aLVL.nLenGrpprlChpx;
+ sal_uInt8* pSprms1 = &aGrpprlChpx[0];
+ while( 0 < nLen )
+ {
+ sal_uInt16 nL1 = rReader.ImportSprm( pSprms1, nLen );
+ nLen -= nL1;
+ pSprms1 += nL1;
+ }
+ // Reader-ItemSet-Pointer und Reader-Style zuruecksetzen
+ rReader.SetAktItemSet( 0 );
+ rReader.SetNAktColl( nOldColl );
+ }
+ //
+ // 4. den Nummerierungsstring einlesen: ergibt Prefix und Postfix
+ //
+ String sNumString( WW8Read_xstz(rSt, 0, FALSE) );
+
+ //
+ // 5. gelesene Werte in Writer Syntax umwandeln
+ //
+ if( 0 <= aLVL.nStartAt )
+ nStartNo = (sal_uInt16)aLVL.nStartAt;
+
+ switch( aLVL.nNFC )
+ {
+ case 0: eType = SVX_NUM_ARABIC; break;
+ case 1: eType = SVX_NUM_ROMAN_UPPER; break;
+ case 2: eType = SVX_NUM_ROMAN_LOWER; break;
+ case 3: eType = SVX_NUM_CHARS_UPPER_LETTER_N; break;
+ case 4: eType = SVX_NUM_CHARS_LOWER_LETTER_N; break;
+ case 5: eType = SVX_NUM_ARABIC; break; // eigentlich: ORDINAL
+ case 23: eType = SVX_NUM_CHAR_SPECIAL; break;
+ case 255: eType = SVX_NUM_NUMBER_NONE; break;
+ default: // nimm default
+ eType = SVX_NUM_ARABIC; break;
+ }
+
+ if( SVX_NUM_CHAR_SPECIAL == eType )
+ {
+ cBullet = sNumString.Len() ? sNumString.GetChar( 0 ) : 0xF0B7;
+
+ if( !cBullet ) // unsave control code?
+ cBullet = 0xF0B7;
+
+ aPrefix = aEmptyStr;
+ aPostfix = aEmptyStr;
+ }
+ else
+ {
+ if( 1 >= aLVL.aOfsNumsXCH[ 0 ] )
+ aPrefix = aEmptyStr;
+ else
+ aPrefix = sNumString.Copy( 1, aLVL.aOfsNumsXCH[ 0 ]-1 );
+
+ if( nUpperLevel && ( sNumString.Len() > aLVL.aOfsNumsXCH[ nUpperLevel-1 ] ) )
+ {
+ sNumString += String::CreateFromInt32(
+ aLVL.aOfsNumsXCH[ nUpperLevel-1 ] );
+ aPostfix = sNumString.Copy( 1 );
+ }
+ else
+ aPostfix.Erase();
+ }
+
+ switch( aLVL.nAlign )
+ {
+ case 0: eAdj = SVX_ADJUST_LEFT; break;
+ case 1: eAdj = SVX_ADJUST_CENTER; break;
+ case 2: eAdj = SVX_ADJUST_RIGHT; break;
+ case 3: eAdj = SVX_ADJUST_LEFT; break;// Writer kann hier kein Block
+ default:// undefinierter Wert
+ ASSERT( !this, "Value of aLVL.nAlign is not supported" );
+ // nimm default
+ eAdj = SVX_ADJUST_LEFT;
+ break;
+ }
+ //
+ // 6. entsprechendes NumFmt konfigurieren
+ //
+ if( bSetStartNo )
+ rNumFmt.SetStartValue( nStartNo );
+ rNumFmt.eType = eType;
+ rNumFmt.SetAdjust( eAdj );
+
+ if( SVX_NUM_CHAR_SPECIAL == eType )
+ {
+ // erstes Zeichen des Prefix-Textes ist das Bullet
+ rNumFmt.SetBulletChar( cBullet );
+ // nicht vergessen: unten, nach dem Bauen eventueller Styles
+ // auch noch SetBulletFont() rufen !!!
+ }
+ else
+ {
+ if( aPrefix.Len() )
+ // erinnern: Garnix ist default Prefix
+ rNumFmt.SetPrefix( aPrefix );
+ // erinnern: Punkt ist default Postfix
+ rNumFmt.SetPostfix( aPostfix );
+ rNumFmt.SetUpperLevel( nUpperLevel );
+ }
+
+ rNumFmt.SetAbsLSpace( aLVL.nDxaLeft );
+ if( 0 < aLVL.nDxaLeft1 )
+ aLVL.nDxaLeft1 = aLVL.nDxaLeft1 * -1;
+ rNumFmt.SetFirstLineOffset( aLVL.nDxaLeft1 );
+
+ return sal_True;
+}
+
+
+
+void WW8ListManager::AdjustLVL( sal_uInt8 nLevel,
+ SwNumRule& rNumRule,
+ WW8aISet& rListItemSet,
+ WW8aCFmt& rCharFmt,
+ sal_Bool& bNewCharFmtCreated,
+ String aPrefix )
+{
+ bNewCharFmtCreated = sal_False;
+ SfxItemSet* pThisLevelItemSet;
+ SfxItemSet* pLowerLevelItemSet;
+ sal_uInt8 nIdenticalItemSetLevel;
+ const SfxPoolItem* pItem;
+
+ SwNumFmt aNumFmt = rNumRule.Get( nLevel );
+
+ pThisLevelItemSet = rListItemSet[ nLevel ];
+
+ if( pThisLevelItemSet && pThisLevelItemSet->Count())
+ {
+ nIdenticalItemSetLevel = nWW8MaxListLevel;
+ SfxItemIter aIter( *pThisLevelItemSet );
+ for( sal_uInt8 nLowerLevel = 0; nLowerLevel < nLevel; nLowerLevel++)
+ {
+ pLowerLevelItemSet = rListItemSet[ nLowerLevel ];
+ if( pLowerLevelItemSet
+ && (pLowerLevelItemSet->Count() == pThisLevelItemSet->Count()) )
+ {
+ nIdenticalItemSetLevel = nLowerLevel;
+ sal_uInt16 nWhich = aIter.GetCurItem()->Which();
+ while( sal_True )
+ {
+ if( // ggfs. passenden pItem im pLowerLevelItemSet finden
+ (SFX_ITEM_SET != pLowerLevelItemSet->GetItemState(
+ nWhich, sal_False, &pItem ) )
+ || // virtuellen "!=" Operator anwenden
+ (*pItem != *aIter.GetCurItem() ) )
+ // falls kein Item mit gleicher nWhich gefunden oder Werte
+ // der Items ungleich, Ungleichheit merken und abbrechen!
+ {
+ nIdenticalItemSetLevel = nWW8MaxListLevel;
+ break;
+ }
+ if( aIter.IsAtEnd() )
+ break;
+ nWhich = aIter.NextItem()->Which();
+ }
+
+ if( nIdenticalItemSetLevel != nWW8MaxListLevel )
+ break;
+ }
+ }
+
+ SwCharFmt* pFmt;
+ if( nWW8MaxListLevel == nIdenticalItemSetLevel )
+ {
+ // Style definieren
+ String aName( aPrefix.Len() ? aPrefix : rNumRule.GetName() );
+ (aName += 'z') += String::CreateFromInt32( nLevel );
+
+ pFmt = rDoc.MakeCharFmt( aName,
+ (SwCharFmt*)rDoc.GetDfltCharFmt() ); // const Wegcasten
+ bNewCharFmtCreated = sal_True;
+ // Attribute reinsetzen
+ pFmt->SetAttr( *pThisLevelItemSet );
+ }
+ else
+ {
+ // passenden Style hier anhaengen
+ pFmt = rCharFmt[ nIdenticalItemSetLevel ];
+ }
+
+ // merken
+ rCharFmt[ nLevel ] = pFmt;
+
+ //
+ // Style an das NumFormat haengen
+ //
+ aNumFmt.SetCharFmt( pFmt );
+ }
+ //
+ // ggfs. Bullet Font an das NumFormat haengen
+ //
+ if( SVX_NUM_CHAR_SPECIAL == aNumFmt.eType )
+ {
+ SwCharFmt* pFmt = aNumFmt.GetCharFmt();
+ Font aFont;
+ if( !pFmt )
+ aFont = SwNumRule::GetDefBulletFont();
+ else
+ {
+ const SvxFontItem& rFontItem = pFmt->GetFont();
+ aFont.SetFamily( rFontItem.GetFamily() );
+ aFont.SetName( rFontItem.GetFamilyName() );
+ aFont.SetStyleName( rFontItem.GetStyleName() );
+ aFont.SetPitch( rFontItem.GetPitch() );
+ aFont.SetCharSet( rFontItem.GetCharSet() );
+ }
+ aNumFmt.SetBulletFont( &aFont );
+ }
+ //
+ // und wieder rein in die NumRule
+ //
+ rNumRule.Set(nLevel, aNumFmt);
+}
+
+
+sal_Bool WW8ListManager::LFOequaltoLST(WW8LFOInfo& rLFOInfo)
+{
+ sal_Bool bRes = sal_False;
+ WW8LSTInfo* pLSTInfo = GetLSTByListId( rLFOInfo.nIdLst );
+ if( pLSTInfo
+ && pLSTInfo->pNumRule
+ && rLFOInfo.pNumRule
+ && (rLFOInfo.nLfoLvl <= (pLSTInfo->bSimpleList ? 1 : nWW8MaxListLevel)))
+ {
+ const SwNumRule& rLSTRule = *pLSTInfo->pNumRule;
+ const SwNumRule& rLFORule = *rLFOInfo.pNumRule;
+ bRes = sal_True;
+ for(sal_uInt16 nLevel = 0; bRes && (nLevel < rLFOInfo.nLfoLvl); ++nLevel)
+ {
+ const SwNumFmt& rLSTNumFmt = rLSTRule.Get( nLevel );
+ const SwNumFmt& rLFONumFmt = rLFORule.Get( nLevel );
+ const SwCharFmt* pLSTCharFmt = rLSTNumFmt.GetCharFmt();
+ const SwCharFmt* pLFOCharFmt = rLFONumFmt.GetCharFmt();
+ if( pLSTCharFmt && pLFOCharFmt )
+ {
+ // erst Char-Styles inhaltlich vergleichen,
+ // ( siehe: ...\svtools\source\items\itemset.cxx )
+ // falls identische Einstellungen, kurz den LFO-Style umhaengen,
+ // damit '( rLSTNumFmt == rLFONumFmt )' funktioniert
+ if( pLSTCharFmt->GetAttrSet() == pLFOCharFmt->GetAttrSet() )
+ ((SwNumFmt&)rLFONumFmt).SetCharFmt( (SwCharFmt*)pLSTCharFmt );
+ else
+ {
+ bRes = sal_False;
+ break;
+ }
+ }
+ if( ( (0 == pLSTCharFmt)
+ != (0 == pLFOCharFmt)
+ )
+ || !(rLSTNumFmt == rLFONumFmt) )
+ bRes = sal_False;
+ // vermurksten LFO-Style wieder zuruecksetzen
+ if( pLFOCharFmt )
+ ((SwNumFmt&)rLFONumFmt).SetCharFmt( (SwCharFmt*)pLFOCharFmt );
+ }
+ }
+ return bRes;
+}
+
+
+
+// oeffentliche Methoden /////////////////////////////////////////////////////
+//
+WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
+: pLSTInfos( 0 ),
+ pLFOInfos( 0 ),
+ nLSTInfos( 0 ), nLFOInfos( 0 ), rSt( rSt_ ),
+ rReader( rReader_ ),
+ rDoc( rReader.GetDoc() ),
+ rFib( rReader.GetFib() )
+{
+ if( ( 8 > rFib.nVersion ) // LST und LFO gibts erst ab WW8
+ || ( rFib.fcPlcfLst == rFib.fcPlfLfo )
+ || ( !rFib.lcbPlcfLst )
+ || ( !rFib.lcbPlfLfo ) ) return; // offensichtlich keine Listen da
+
+ // Arrays anlegen
+ pLSTInfos = new WW8LSTInfos;
+ pLFOInfos = new WW8LFOInfos;
+ sal_uInt16 nList;
+ sal_uInt16 nLfo;
+ sal_Bool bLVLOk;
+ sal_uInt8 aBits1;
+ String aPrefix; // wird erstmal zur Bildung des Style Namens genommen
+ String aPostfix;
+
+ long nOriginalPos = rSt.Tell();
+ //
+ // 1. PLCF LST auslesen und die Listen Vorlagen im Writer anlegen
+ //
+ rSt.Seek( rFib.fcPlcfLst );
+ sal_uInt16 nListCount;
+ rSt >> nListCount;
+ sal_Bool bOk = 0 < nListCount;
+ if( bOk )
+ {
+ WW8LST aLST;
+ //
+ // 1.1 alle LST einlesen
+ //
+ for(nList = 0; nList < nListCount; nList++)
+ {
+ bOk = sal_False;
+ memset(&aLST, 0, sizeof( aLST ));
+ sal_uInt16 nLevel;
+ //
+ // 1.1.1 Daten einlesen
+ //
+ rSt >> aLST.nIdLst;
+ rSt >> aLST.nTplC;
+ for(nLevel = 0; nLevel < nWW8MaxListLevel; nLevel++)
+ {
+ rSt >> aLST.aIdSty[ nLevel ];
+ }
+
+ rSt >> aBits1;
+ rSt.SeekRel( 1 );
+
+ if( 0 != rSt.GetError() ) break;
+
+ if( aBits1 & 0x01 ) aLST.bSimpleList = sal_True;
+ if( aBits1 & 0x02 ) aLST.bRestartHdn = sal_True;
+ //
+ // 1.1.2 neue NumRule ins Doc einsetzen und WW8LSTInfo vermerken
+ //
+ aPrefix = WW8_ASCII2STR( "WW8Num" );
+ aPrefix += String::CreateFromInt32( nList+1 );
+ sal_uInt16 nRul =
+ rDoc.MakeNumRule(rDoc.GetUniqueNumRuleName( &aPrefix ));
+ SwNumRule* pMyNumRule =
+ rDoc.GetNumRuleTbl()[nRul];
+ pMyNumRule->SetAutoRule( sal_False );
+
+ WW8LSTInfo* pLSTInfo = new WW8LSTInfo(pMyNumRule, aLST, nList);
+ pLSTInfos->Insert( pLSTInfo );
+ nLSTInfos++;
+ bOk = sal_True;
+ }
+ }
+
+ if( bOk )
+ {
+ //
+ // 1.2 alle LVL aller aLST einlesen
+ //
+ sal_uInt8 nLevel;
+ for(nList = 0; nList < nLSTInfos; nList++)
+ {
+ bOk = sal_False;
+ WW8LSTInfo* pListInfo = GetLSTByStreamPos( nList );
+ if( !pListInfo || !pListInfo->pNumRule ) break;
+ SwNumRule& rMyNumRule = *pListInfo->pNumRule;
+ //
+ // 1.2.1 betreffende(n) LVL(s) fuer diese aLST einlesen
+ //
+ sal_uInt16 nLvlCount = pListInfo->bSimpleList ? 1 : nWW8MaxListLevel;
+ for(nLevel = 0; nLevel < nLvlCount; nLevel++)
+ {
+ SwNumFmt aNumFmt( rMyNumRule.Get( nLevel ) );
+ // LVLF einlesen
+ bLVLOk = ReadLVL( nLevel,
+ aNumFmt,
+ pListInfo->aItemSet[ nLevel ],
+ pListInfo->aIdSty[ nLevel ],
+ sal_True );
+ if( !bLVLOk ) break;
+ // und in die rMyNumRule aufnehmen
+ rMyNumRule.Set( nLevel, aNumFmt );
+ }
+ if( !bLVLOk ) break;
+ //
+ // 1.2.2 die ItemPools mit den CHPx Einstellungen der verschiedenen
+ // Level miteinander vergleichen und ggfs. Style(s) erzeugen
+ //
+ sal_Bool bDummy;
+ for(nLevel = 0; nLevel < nLvlCount; nLevel++)
+ AdjustLVL( nLevel, rMyNumRule, pListInfo->aItemSet,
+ pListInfo->aCharFmt, bDummy );
+ //
+ // 1.2.3 ItemPools leeren und loeschen
+ //
+ for(nLevel = 0; nLevel < nLvlCount; nLevel++)
+ delete pListInfo->aItemSet[ nLevel ];
+ bOk = sal_True;
+ }
+ }
+ if( !bOk )
+ {
+ // Fehler aufgetreten - LSTInfos abraeumen !!!
+
+ ;
+ }
+ //
+ // 2. PLF LFO auslesen und speichern
+ //
+ long nLfoCount;
+ if( bOk )
+ {
+ nLfoCount = 0;
+ rSt.Seek( rFib.fcPlfLfo );
+ rSt >> nLfoCount;
+ if( 0 >= nLfoCount ) bOk = sal_False;
+ }
+ sal_uInt16 nTotalLfoLevels = 0;
+ if( bOk )
+ {
+ WW8LFO aLFO;
+ //
+ // 2.1 alle LFO einlesen
+ //
+ for(nLfo = 0; nLfo < nLfoCount; nLfo++)
+ {
+ bOk = sal_False;
+ memset(&aLFO, 0, sizeof( aLFO ));
+ rSt >> aLFO.nIdLst;
+ rSt.SeekRel( 8 );
+ rSt >> aLFO.nLfoLvl;
+ rSt.SeekRel( 3 );
+ if( (nWW8MaxListLevel < aLFO.nLfoLvl) // soviele Overrides existieren
+ && ( 0 != rSt.GetError() )
+ ) break;
+
+ // die Parent NumRule der entsprechenden Liste ermitteln
+ WW8LSTInfo* pParentListInfo = GetLSTByListId( aLFO.nIdLst );
+ if( !pParentListInfo ) break;
+ // hier, im ersten Schritt, erst mal diese NumRule festhalten
+ aLFO.pNumRule = pParentListInfo->pNumRule;
+ if( !aLFO.pNumRule ) break;
+ // hat die Liste mehrere Level ?
+ aLFO.bSimpleList = pParentListInfo->bSimpleList;
+ // und rein ins Merk-Array mit dem Teil
+ WW8LFOInfo* pLFOInfo = new WW8LFOInfo( aLFO );
+ pLFOInfos->Insert(pLFOInfo, pLFOInfos->Count());
+ nLFOInfos++;
+ bOk = sal_True;
+ }
+ }
+ if( bOk )
+ {
+ //
+ // 2.2 fuer alle LFO die zugehoerigen LFOLVL einlesen
+ //
+ WW8LFOLVL aLFOLVL;
+ for(nLfo = 0; nLfo < nLFOInfos; nLfo++)
+ {
+ bOk = sal_False;
+ WW8LFOInfo* pLFOInfo = pLFOInfos->GetObject( nLfo );
+ if( !pLFOInfo ) break;
+ if( pLFOInfo->bOverride ) // stehen hierfuer ueberhaupt LFOLVL an ?
+ {
+ WW8LSTInfo* pParentListInfo = GetLSTByListId( pLFOInfo->nIdLst );
+ if( !pParentListInfo ) break;
+ //
+ // 2.2.1 eine neue NumRule fuer diese Liste anlegen
+ //
+ SwNumRule* pParentNumRule = pLFOInfo->pNumRule;
+ if( !pParentNumRule )
+ break;
+ // Nauemsprefix aufbauen: fuer NumRule-Name (eventuell)
+ // und (falls vorhanden) fuer Style-Name (dann auf jeden Fall)
+ aPrefix.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WW8NumSt" ));
+ aPrefix += String::CreateFromInt32( nLfo + 1 );
+ // jetzt dem pNumRule seinen RICHTIGEN Wert zuweisen !!!
+ // (bis dahin war hier die Parent NumRule vermerkt )
+ //
+ // Dazu erst mal nachsehen, ob ein Style diesen LFO referenziert:
+ if( USHRT_MAX > rReader.StyleUsingLFO( nLfo ) )
+ {
+ sal_uInt16 nRul =
+ rDoc.MakeNumRule(rDoc.GetUniqueNumRuleName( &aPrefix ), pParentNumRule);
+ pLFOInfo->pNumRule = rDoc.GetNumRuleTbl()[ nRul ];
+ pLFOInfo->pNumRule->SetAutoRule( sal_False );
+ }
+ else
+ {
+ sal_uInt16 nRul = rDoc.MakeNumRule(
+ rDoc.GetUniqueNumRuleName(), pParentNumRule);
+ pLFOInfo->pNumRule = rDoc.GetNumRuleTbl()[ nRul ];
+ pLFOInfo->pNumRule->SetAutoRule( sal_True ); // = default
+ }
+ //
+ // 2.2.2 alle LFOLVL (und ggfs. LVL) fuer die neue NumRule einlesen
+ //
+ WW8aISet aItemSet; // Zeichenattribute aus GrpprlChpx
+ WW8aCFmt aCharFmt; // Zeichen Style Pointer
+ memset(&aItemSet, 0, sizeof( aItemSet ));
+ memset(&aCharFmt, 0, sizeof( aCharFmt ));
+
+ for(sal_uInt8 nLevel = 0; nLevel < pLFOInfo->nLfoLvl; nLevel++)
+ {
+ bLVLOk = sal_False;
+ memset(&aLFOLVL, 0, sizeof( aLFOLVL ));
+
+ //
+ // 2.2.2.0 fuehrende 0xFF ueberspringen
+ //
+ sal_uInt8 n1;
+ do{
+ rSt >> n1;
+ if( 0 != rSt.GetError() ) break;
+ }
+ while( 0xFF == n1 );
+ rSt.SeekRel( -1 );
+
+ //
+ // 2.2.2.1 den LFOLVL einlesen
+ //
+ rSt >> aLFOLVL.nStartAt;
+ rSt >> aBits1;
+ rSt.SeekRel( 3 );
+ if( 0 != rSt.GetError() ) break;
+
+ // beachte: Die Witzbolde bei MS quetschen die Override-Level-Nummer
+ // in vier Bits hinein, damit sie wieder einen Grund haben,
+ // ihr Dateiformat zu aendern, falls ihnen einfaellt, dass
+ // sie eigentlich doch gerne bis zu 16 Listen-Level haetten.
+ // Wir tun das *nicht* (siehe Kommentar oben bei "struct WW8LFOInfo")
+ aLFOLVL.nLevel = aBits1 & 0x0F;
+ if( (0xFF > aBits1)
+ && (0 <= aLFOLVL.nLevel)
+ && (nWW8MaxListLevel > aLFOLVL.nLevel) )
+ {
+// aLFOLVL.nLevel--;
+ if( aBits1 & 0x10 )
+ aLFOLVL.bStartAt = sal_True;
+ //
+ // 2.2.2.2 eventuell auch den zugehoerigen LVL einlesen
+ //
+ SwNumFmt aNumFmt( pLFOInfo->pNumRule->Get( aLFOLVL.nLevel ) );
+ if( aBits1 & 0x20 )
+ {
+ aLFOLVL.bFormat = sal_True;
+ // falls bStartup sal_True, hier den Startup-Level durch
+ // den im LVL vermerkten ersetzen
+ // LVLF einlesen
+ bLVLOk= ReadLVL(aLFOLVL.nLevel,
+ aNumFmt,
+ aItemSet[ nLevel ],
+ pParentListInfo->aIdSty[ nLevel ],
+ aLFOLVL.bStartAt );
+ if( !bLVLOk ) break;
+ }
+ else
+ if( aLFOLVL.bStartAt )
+ aNumFmt.SetStartValue( (sal_uInt16)aLFOLVL.nStartAt );
+ //
+ // 2.2.2.3 das NumFmt in die NumRule aufnehmen
+ //
+ pLFOInfo->pNumRule->Set( nLevel, aNumFmt );
+ }
+ bLVLOk = sal_True;
+ }
+ if( !bLVLOk ) break;
+ //
+ // 2.2.3 die LVL der neuen NumRule anpassen
+ //
+ sal_uInt16 aFlagsNewCharFmt = 0;
+ sal_Bool bNewCharFmtCreated = sal_False;
+ for(nLevel = 0; nLevel < pLFOInfo->nLfoLvl; nLevel++)
+ {
+ AdjustLVL( nLevel, *pLFOInfo->pNumRule,
+ aItemSet,
+ aCharFmt,
+ bNewCharFmtCreated,
+ aPrefix );
+ if( bNewCharFmtCreated )
+ aFlagsNewCharFmt += (1 << nLevel);
+ }
+ //
+ // 2.2.4 ItemPools leeren und loeschen
+ //
+ for(nLevel = 0; nLevel < pLFOInfo->nLfoLvl; nLevel++)
+ delete aItemSet[ nLevel ];
+ //
+ // 2.2.5 falls diese NumRule identische Einstellungen und
+ // Formatierungen hat wie ihre Parent-Rule, loeschen
+ // wir sie wieder und nehmen stattdessen die alte.
+ //
+ if( LFOequaltoLST( *pLFOInfo ) )
+ {
+ // 2.2.5.1 ggfs die an den einzelnen Leveln haengenden
+ // Char-Formate freigeben und loeschen
+ //
+ for(nLevel = 0; nLevel < pLFOInfo->nLfoLvl; nLevel++)
+ if( aFlagsNewCharFmt & (1 << nLevel) )
+ rDoc.DelCharFmt(
+ pLFOInfo->pNumRule->Get( nLevel ).GetCharFmt() );
+ //
+ // 2.2.5.2 jetzt die NumRule freigeben und die alte nehmen
+ //
+ rDoc.DelNumRule( pLFOInfo->pNumRule->GetName() );
+ pLFOInfo->pNumRule = pParentNumRule;
+ }
+ bOk = sal_True;
+ }
+ }
+ }
+ if( !bOk )
+ {
+ // Fehler aufgetreten - LSTInfos und LFOInfos abraeumen !!!
+
+ ;
+ }
+ // und schon sind wir fertig!
+ rSt.Seek( nOriginalPos );
+}
+
+
+WW8ListManager::~WW8ListManager()
+{
+/*
+ benannte Liste bleiben im Doc drin !!!
+
+ unbenannte Listen werden bei Nicht-Verwendung geloescht
+
+ pLSTInfos und pLFOInfos werden auf jeden Fall destruiert
+*/
+ sal_uInt16 nInfo;
+ if( pLSTInfos )
+ {
+ for(nInfo = pLSTInfos->Count(); nInfo; )
+ {
+ WW8LSTInfo& rActInfo = *pLSTInfos->GetObject( --nInfo );
+ if( rActInfo.pNumRule
+ && !rActInfo.bUsedInDoc
+ && rActInfo.pNumRule->IsAutoRule()
+ )
+ rDoc.DelNumRule( rActInfo.pNumRule->GetName() );
+ }
+ delete pLSTInfos;
+ }
+ if( pLFOInfos )
+ {
+ for(nInfo = pLFOInfos->Count(); nInfo; )
+ {
+ WW8LFOInfo& rActInfo = *pLFOInfos->GetObject( --nInfo );
+ if( rActInfo.bOverride
+ && rActInfo.pNumRule
+ && !rActInfo.bUsedInDoc
+ && rActInfo.pNumRule->IsAutoRule()
+ )
+ rDoc.DelNumRule( rActInfo.pNumRule->GetName() );
+ }
+ delete pLFOInfos;
+ }
+}
+
+
+
+SwNumRule* WW8ListManager::GetNumRuleForActivation(sal_uInt16 nLFOPosition) const
+{
+ if( nLFOInfos <= nLFOPosition ) return 0;
+
+ WW8LFOInfo* pLFOInfo = pLFOInfos->GetObject( nLFOPosition );
+
+ if( !pLFOInfo ) return 0;
+
+ pLFOInfo->bUsedInDoc = sal_True;
+
+ if( !pLFOInfo->pNumRule ) return 0;
+
+ if( (!pLFOInfo->bOverride) && (!pLFOInfo->bLSTbUIDSet) )
+ {
+ WW8LSTInfo* pParentListInfo = GetLSTByListId( pLFOInfo->nIdLst );
+ if( pParentListInfo )
+ pParentListInfo->bUsedInDoc = sal_True;
+ pLFOInfo->bLSTbUIDSet = sal_True;
+ }
+ return pLFOInfo->pNumRule;
+}
+
+
+
+sal_Bool WW8ListManager::IsSimpleList(sal_uInt16 nLFOPosition) const
+{
+ if( nLFOInfos <= nLFOPosition ) return sal_False;
+
+ WW8LFOInfo* pLFOInfo = pLFOInfos->GetObject( nLFOPosition );
+
+ if( !pLFOInfo ) return sal_False;
+
+ return pLFOInfo->bSimpleList;
+}
+
+
+
+
+//----------------------------------------------------------------------------
+// SwWW8ImplReader: anhaengen einer Liste an einen Style oder Absatz
+//----------------------------------------------------------------------------
+
+
+sal_Bool SwWW8ImplReader::SetTxtFmtCollAndListLevel(const SwPaM& rRg,
+ SwWW8StyInf& rStyleInfo,
+ sal_Bool bReset)
+{
+ sal_Bool bRes = sal_True;
+ if( rStyleInfo.pFmt && rStyleInfo.bColl )
+ {
+ bRes = rDoc.SetTxtFmtColl(rRg, (SwTxtFmtColl*)rStyleInfo.pFmt);
+
+ if( !rStyleInfo.pOutlineNumrule )
+ {
+ SwTxtNode* pTxtNode = pPaM->GetNode()->GetTxtNode();
+ ASSERT( pTxtNode, "Kein Text-Node an PaM-Position" );
+
+ if( !IsInvalidOrToBeMergedTabCell() )
+ pTxtNode->SwCntntNode::ResetAttr( RES_PARATR_NUMRULE );
+
+ if( (USHRT_MAX > rStyleInfo.nLFOIndex )
+ && (nWW8MaxListLevel > rStyleInfo.nListLevel) )
+ RegisterNumFmtOnTxtNode( rStyleInfo.nLFOIndex,
+ rStyleInfo.nListLevel, sal_False);
+ else
+ pTxtNode->UpdateNum( SwNodeNum(NO_NUMBERING) );
+
+ if( rStyleInfo.bHasStyNumRule && pTxtNode )
+ {
+ pTxtNode->SetNumLSpace( sal_False );
+ }
+ }
+ }
+ return bRes;
+}
+
+void SwWW8ImplReader::RegisterNumFmtOnStyle(SwWW8StyInf& rStyleInfo,
+ sal_uInt16 nActLFO,
+ sal_uInt8 nActLevel)
+{
+ if( rStyleInfo.bValid )
+ {
+ // Phase 1: Nummerierungsattribute beim Einlesen einer StyleDef
+ if( pAktColl )
+ {
+ // jetzt nur die Parameter vermerken: die tatsaechliche Liste wird
+ // spaeter drangehaengt, wenn die Listendefinitionen gelesen sind...
+ if( (USHRT_MAX > nActLFO) && (nWW8MaxListLevel > nActLevel))
+ {
+ rStyleInfo.nLFOIndex = nActLFO;
+ rStyleInfo.nListLevel = nActLevel;
+ }
+ }
+ else
+ // Phase 2: aktualisieren der StyleDef nach einlesen aller Listen
+ {
+ sal_uInt16 nLFO;
+ sal_uInt8 nLevel;
+ if( (USHRT_MAX > nActLFO) && (nWW8MaxListLevel > nActLevel))
+ {
+ // Plan A: die Werte fuer Listen- und Level-Nummer wurden uebergeben
+ nLFO = nActLFO;
+ nLevel = nActLevel;
+ }
+ else
+ {
+ // Plan B: die vorhin in Phase 1 gespeicherten Werte sind zu nehmen
+ nLFO = rStyleInfo.nLFOIndex;
+ nLevel = rStyleInfo.nListLevel;
+ }
+ if( (USHRT_MAX > nLFO) && (nWW8MaxListLevel > nLevel))
+ {
+ SwNumRule* pNumRule = pLstManager->GetNumRuleForActivation( nLFO );
+ if( pNumRule )
+ {
+ if( MAXLEVEL > rStyleInfo.nOutlineLevel )
+ {
+ rStyleInfo.pOutlineNumrule = pNumRule;
+ }
+ else
+ {
+ rStyleInfo.pFmt->SetAttr( SwNumRuleItem( pNumRule->GetName() ) );
+ rStyleInfo.bHasStyNumRule = sal_True;
+ }
+ }
+ }
+ }
+ }
+}
+
+void SwWW8ImplReader::RegisterNumFmtOnTxtNode(sal_uInt16 nActLFO,
+ sal_uInt8 nActLevel,
+ sal_Bool bSetAttr)
+{
+ // beachte: die Methode haengt die NumRule an den Text Node, falls bSetAttr
+ // (dann muessen natuerlich vorher die Listen gelesen sein)
+ // stellt sie NUR den Level ein, im Vertrauen darauf, dass am STYLE
+ // eine NumRule haengt - dies wird NICHT ueberprueft !!!
+
+ if( pLstManager ) // sind die Listendeklarationen gelesen?
+ {
+ const SwNumRule* pNumRule
+ = bSetAttr ? pLstManager->GetNumRuleForActivation( nActLFO ) : 0;
+
+ if( pNumRule || !bSetAttr )
+ {
+ SwTxtNode* pTxtNode = pPaM->GetNode()->GetTxtNode();
+ ASSERT( pTxtNode, "Kein Text-Node an PaM-Position" );
+
+ if( bSetAttr )
+ pTxtNode->SwCntntNode::SetAttr(SwNumRuleItem( pNumRule->GetName() ));
+
+ SvxLRSpaceItem aLR( *(SvxLRSpaceItem*)GetFmtAttr( RES_LR_SPACE ));
+ if( 1 < aLR.GetTxtFirstLineOfst() )
+ {
+ aLR.SetTxtFirstLineOfst( 1 );
+ NewAttr( aLR );
+ }
+
+ pTxtNode->SetNumLSpace( bSetAttr );
+
+ pTxtNode->UpdateNum( SwNodeNum( nActLevel ) );
+ }
+ }
+}
+
+void SwWW8ImplReader::RegisterNumFmt(sal_uInt16 nActLFO, sal_uInt8 nActLevel)
+{
+ // sind wir erst beim Einlesen der StyleDef ?
+ if( pAktColl )
+ RegisterNumFmtOnStyle(pCollA[ nAktColl ], nActLFO, nActLevel);
+ else
+ RegisterNumFmtOnTxtNode(nActLFO, nActLevel);
+}
+
+
+
+void SwWW8ImplReader::Read_ListLevel(sal_uInt16 nId, sal_uInt8* pData, short nLen)
+{
+ if( nLen < 0 )
+ {
+ // aktuelle Liste ist hier zu Ende, was ist zu tun ???
+ nListLevel = nWW8MaxListLevel;
+ }
+ else
+ {
+ // Sicherheitspruefung auf NIL Pointer
+ if( !pData ) return;
+ // die Streamdaten sind hier Null basiert, so wie wir es brauchen
+ nListLevel = *pData;
+ if( nWW8MaxListLevel <= nListLevel )
+ nListLevel = nWW8MaxListLevel;
+ else
+ if( (USHRT_MAX > nLFOPosition) && (nWW8MaxListLevel > nListLevel))
+ {
+ RegisterNumFmt(nLFOPosition, nListLevel);
+ nLFOPosition = USHRT_MAX;
+ nListLevel = nWW8MaxListLevel;
+ }
+ }
+}
+
+
+
+void SwWW8ImplReader::Read_LFOPosition(sal_uInt16 nId, sal_uInt8* pData, short nLen)
+{
+ if( nLen < 0 )
+ {
+ // aktueller Level ist hier zu Ende, was ist zu tun ???
+ nLFOPosition = USHRT_MAX;
+ nListLevel = nWW8MaxListLevel;
+ }
+ else
+ {
+ // Sicherheitspruefung auf NIL Pointer
+ if( !pData ) return;
+ short nData = SVBT16ToShort( pData );
+ if( 0 >= nData )
+ {
+ // expliziet die Numerierung abschalten
+ // sind wir erst beim Einlesen der StyleDef ?
+ if( pAktColl )
+ pAktColl->SetAttr( *GetDfltAttr( RES_PARATR_NUMRULE ) );
+ else
+ {
+ SwTxtNode* pTxtNode = pPaM->GetNode()->GetTxtNode();
+ if( pTxtNode )
+ {
+ pTxtNode->SwCntntNode::SetAttr(
+ *GetDfltAttr( RES_PARATR_NUMRULE ) );
+ pTxtNode->UpdateNum( SwNodeNum( NO_NUMBERING ) );
+ }
+ }
+
+ nLFOPosition = USHRT_MAX;
+ }
+ else
+ {
+ // die Streamdaten sind hier 1 basiert, wir ziehen EINS ab
+ nLFOPosition = (sal_uInt16)nData-1;
+ if( USHRT_MAX > nLFOPosition)
+ {
+ /*
+ traurig: WW8 speichert manchmal keine Level-Attribute ab, auch wenn
+ die Liste *nicht* bSimpleList hat.
+ daher: nach Auftreten von sprmPIlfo sofort die Liste anklemmen, auch
+ wenn kein sprmPIlvl vorher kam!
+
+ schoener waere gewesen:
+ if( (nWW8MaxListLevel == nListLevel)
+ && pLstManager
+ && pLstManager->IsSimpleList( nLFOPosition ) )
+ nListLevel = 0;
+ */
+ if(nWW8MaxListLevel == nListLevel)
+ nListLevel = 0;
+ if(nWW8MaxListLevel > nListLevel)
+ {
+ RegisterNumFmt(nLFOPosition, nListLevel);
+ nLFOPosition = USHRT_MAX;
+ nListLevel = nWW8MaxListLevel;
+ }
+ }
+ }
+ }
+}
+
+// -------------------------------------------------------------------
+// ------------------------- Reading Controls ------------------------
+// -------------------------------------------------------------------
+
+BOOL SwWW8ImplReader::ImportFormulaControl(WW8FormulaControl &aFormula,
+ WW8_CP nStart, SwWw8ControlType nWhich )
+{
+ BOOL bRet=FALSE;
+ /*
+ * Save the reader state and process the sprms for this anchor cp.
+ * Doing so will set the nPicLocFc to the offset to find the hypertext
+ * data in the data stream.
+ */
+ WW8_CP nEndCp = nStart+1; //Only interested in the single 0x01 character
+
+ WW8ReaderSave aSave(this,nStart);
+
+ WW8PLCFManResult aRes;
+ nStart = pPlcxMan->Where();
+ while(nStart <= nEndCp)
+ {
+ if ( pPlcxMan->Get(&aRes)
+ && aRes.pMemPos && aRes.nSprmId )
+ {
+ //only interested in sprms which would set nPicLocFc
+ if ( (68 == aRes.nSprmId) || (0x6A03 == aRes.nSprmId) )
+ {
+ Read_PicLoc( aRes.nSprmId, aRes.pMemPos+ 1+
+ (8 > pWwFib->nVersion ? 0 : 1) + WW8SprmDataOfs(aRes.nSprmId),
+ 4);
+ break;
+ }
+ }
+ (*pPlcxMan)++;
+ nStart = pPlcxMan->Where();
+ }
+ long nOffset = nPicLocFc;
+ aSave.Restore(this);
+
+ long nOldPos = pDataStream->Tell();
+ WW8_PIC aPic;
+ pDataStream->Seek( nOffset);
+#ifdef __WW8_NEEDS_COPY
+ WW8_PIC_SHADOW aPicS;
+ pDataStream->Read( &aPicS, sizeof( aPicS ) );
+ WW8PicShadowToReal( &aPicS, &aPic );
+#else
+ pDataStream->Read( &aPic, sizeof( aPic ) );
+#endif
+
+ if((aPic.lcb > 0x3A) && !pDataStream->GetError() )
+ {
+ pDataStream->Seek( nPicLocFc + aPic.cbHeader );
+ aFormula.Read(nWhich,pDataStream);
+ bRet=TRUE;
+ }
+
+ /*There is a problem with aPic, the WW8_PIC is always used even though it
+ *is too big for the WW95 files, it needs to be modified to check the
+ version C.*/
+ return(bRet);
+}
+
+BOOL SwImportControls::InsertFormula(WW8FormulaControl &rFormula,
+ uno::Reference <drawing::XShape> *pShapeRef)
+{
+ BOOL bRet=FALSE;
+
+ awt::Size aSz;
+ uno::Reference< form::XFormComponent> xFComp;
+ uno::Reference < drawing::XShape> xShape;
+
+ const uno::Reference< lang::XMultiServiceFactory > & rServiceFactory =
+ GetServiceFactory();
+
+ //const XMultiServiceFactoryRef& rServiceFactory =
+ // GetServiceFactory();
+ if(!rServiceFactory.is())
+ return(FALSE);
+ if (bRet = rFormula.Convert(rServiceFactory, xFComp, aSz))
+ {
+ xShape = InsertControl( xFComp, aSz, FALSE );
+ if (pShapeRef)
+ *pShapeRef = xShape;
+ }
+ return bRet;
+}
+
+void WW8FormulaControl::Read(SwWw8ControlType nWhich,SvStream *pDataStream)
+{
+ UINT8 nField;
+ UINT8 nTest;
+
+ int nType=0;
+ pDataStream->Read(&nTest, 1);
+ if (nTest == 0xFF) //Guesswork time, difference between 97 and 95 ?
+ {
+ pDataStream->SeekRel(4);
+ nType=1;
+ }
+ *pDataStream >> nField;
+ fToolTip = nField & 0x01;
+ fNoMark = (nField & 0x02)>>1;
+ fUseSize = (nField & 0x04)>>2;
+ fNumbersOnly= (nField & 0x08)>>3;
+ fDateOnly = (nField & 0x10)>>4;
+ fUnused = (nField & 0xE0)>>5;
+ *pDataStream >> nSize;
+
+ *pDataStream >> hpsCheckBox;
+ if (nType == 0)
+ pDataStream->SeekRel(2); //Guess
+
+ rtl_TextEncoding eEnc = rRdr.eStructCharSet;
+ sTitle = !nType ? WW8ReadPString( *pDataStream, eEnc, TRUE )
+ : WW8Read_xstz( *pDataStream, 0, TRUE );
+
+ if (nWhich == WW8_CT_CHECKBOX)
+ *pDataStream >> nChecked;
+ else
+ sDefault = !nType ? WW8ReadPString( *pDataStream, eEnc, TRUE )
+ : WW8Read_xstz( *pDataStream, 0, TRUE );
+
+ sFormatting = !nType ? WW8ReadPString( *pDataStream, eEnc, TRUE )
+ : WW8Read_xstz( *pDataStream, 0, TRUE );
+
+ sHelp = !nType ? WW8ReadPString( *pDataStream, eEnc, TRUE )
+ : WW8Read_xstz( *pDataStream, 0, TRUE );
+
+ if( fToolTip )
+ sToolTip = !nType ? WW8ReadPString( *pDataStream, eEnc, TRUE )
+ : WW8Read_xstz( *pDataStream, 0, TRUE );
+}
+
+BOOL WW8FormulaCheckBox::Convert(
+ const uno::Reference <lang::XMultiServiceFactory> &rServiceFactory,
+ uno::Reference <form::XFormComponent> &rFComp,
+ com::sun::star::awt::Size &rSz )
+{
+ String sServiceName = WW8_ASCII2STR( "com.sun.star.form.component.CheckBox" );
+ uno::Reference< uno::XInterface > xCreate = rServiceFactory->createInstance( sServiceName );
+ if( !xCreate.is() )
+ return FALSE;
+
+ rFComp = uno::Reference< form::XFormComponent >( xCreate, uno::UNO_QUERY );
+ if( !rFComp.is() )
+ return FALSE;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xCreate, uno::UNO_QUERY );
+
+ rSz.Width = 16 * hpsCheckBox;
+ rSz.Height = 16 * hpsCheckBox;
+
+ uno::Any aTmp;
+ if (sTitle.Len())
+ {
+ //UniString sTmp(pName,RTL_TEXTENCODING_ASCII_US);
+ aTmp <<= rtl::OUString(sTitle);
+ }
+ else
+ aTmp <<= rtl::OUString(sName);
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
+
+ aTmp <<= (sal_Int16)nChecked;
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "DefaultState" ), aTmp);
+
+ if( sToolTip.Len() )
+ {
+ aTmp <<= rtl::OUString( sToolTip );
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "HelpText" ), aTmp );
+ }
+
+ return TRUE;
+
+}
+
+void WW8FormulaControl::SetOthersFromDoc(uno::Reference< form::XFormComponent >& rFComp, com::sun::star::awt::Size &rSz,
+ uno::Reference< beans::XPropertySet >& rPropSet)
+{
+ const struct CtrlFontMapEntry
+ {
+ USHORT nWhichId;
+ const sal_Char* pPropNm;
+ }
+ aMapTable [] =
+ {
+ RES_CHRATR_COLOR, "TextColor",
+ RES_CHRATR_COLOR, "TextColor",
+ RES_CHRATR_FONT, "FontName",
+ RES_CHRATR_FONTSIZE, "FontHeight",
+ RES_CHRATR_WEIGHT, "FontWeight",
+ RES_CHRATR_UNDERLINE, "FontUnderline",
+ RES_CHRATR_CROSSEDOUT, "FontStrikeout",
+ RES_CHRATR_POSTURE, "FontSlant",
+ 0, 0
+ };
+
+
+ USHORT nDefSize;
+ Font aFont;
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo();
+ if (nSize)
+ nDefSize = nSize;
+ else if( sDefault.Len() )
+ nDefSize = sDefault.Len();
+ else
+ nDefSize = 18; //no chars, ms actually uses
+ //5 0x96 chars (-) as its default, but thats
+ //the default for an empty text area, which
+ //stretchs in size as text is entered so...
+
+ uno::Any aTmp;
+ for( const CtrlFontMapEntry* pMap = aMapTable; pMap->nWhichId; ++pMap )
+ {
+ BOOL bSet = TRUE;
+ const SfxPoolItem* pItem = rRdr.GetFmtAttr( pMap->nWhichId );
+
+ switch ( pMap->nWhichId )
+ {
+ case RES_CHRATR_COLOR:
+ aTmp <<= (sal_Int32)((SvxColorItem*)pItem)->GetValue().GetRGBColor();
+ aFont.SetColor( ((SvxColorItem*)pItem)->GetValue() );
+ break;
+
+ case RES_CHRATR_FONT:
+ {
+ const SvxFontItem *pFontItem = (SvxFontItem *)pItem;
+ String pNm;
+ if( xPropSetInfo->hasPropertyByName( pNm = WW8_ASCII2STR( "FontStyleName" ) ) )
+ {
+ aTmp <<= rtl::OUString( pFontItem->GetStyleName() );
+ rPropSet->setPropertyValue( pNm, aTmp );
+ }
+ if( xPropSetInfo->hasPropertyByName( pNm = WW8_ASCII2STR( "FontFamily" ) ) )
+ {
+ aTmp <<= (sal_Int16)pFontItem->GetFamily();
+ rPropSet->setPropertyValue( pNm, aTmp );
+ }
+ if( xPropSetInfo->hasPropertyByName( pNm = WW8_ASCII2STR( "FontCharset" ) ) )
+ {
+ aTmp <<= (sal_Int16)pFontItem->GetCharSet();
+ rPropSet->setPropertyValue( pNm, aTmp );
+ }
+ if( xPropSetInfo->hasPropertyByName( pNm = WW8_ASCII2STR( "FontPitch" ) ) )
+ {
+ aTmp <<= (sal_Int16)pFontItem->GetPitch();
+ rPropSet->setPropertyValue( pNm, aTmp );
+ }
+
+ aTmp <<= rtl::OUString( pFontItem->GetFamilyName());
+ aFont.SetName( pFontItem->GetFamilyName() );
+ aFont.SetStyleName( pFontItem->GetStyleName() );
+ aFont.SetFamily( pFontItem->GetFamily() );
+ aFont.SetCharSet( pFontItem->GetCharSet() );
+ aFont.SetPitch( pFontItem->GetPitch() );
+ }
+ break;
+
+ case RES_CHRATR_FONTSIZE:
+ {
+ Size aSize( aFont.GetSize().Width(),
+ ((SvxFontHeightItem*)pItem)->GetHeight() );
+ aTmp <<= ((float)aSize.Height()) / 20. ;
+
+ aFont.SetSize( OutputDevice::LogicToLogic( aSize,
+ MAP_TWIP, MAP_100TH_MM ) );
+ }
+ break;
+
+ case RES_CHRATR_WEIGHT:
+ aTmp <<= (float)VCLUnoHelper::ConvertFontWeight(
+ ((SvxWeightItem*)pItem)->GetWeight() );
+ aFont.SetWeight( ((SvxWeightItem*)pItem)->GetWeight() );
+ break;
+
+ case RES_CHRATR_UNDERLINE:
+ aTmp <<= (sal_Int16)( ((SvxUnderlineItem*)pItem)->GetUnderline() );
+ aFont.SetUnderline( ((SvxUnderlineItem*)pItem)->GetUnderline() );
+ break;
+
+ case RES_CHRATR_CROSSEDOUT:
+ aTmp <<= (sal_Int16)( ((SvxCrossedOutItem*)pItem)->GetStrikeout() );
+ aFont.SetStrikeout( ((SvxCrossedOutItem*)pItem)->GetStrikeout() );
+ break;
+
+ case RES_CHRATR_POSTURE:
+ aTmp <<= (sal_Int16)( ((SvxPostureItem*)pItem)->GetPosture() );
+ aFont.SetItalic( ((SvxPostureItem*)pItem)->GetPosture() );
+ break;
+
+ default:
+ bSet = FALSE;
+ break;
+ }
+
+ if( bSet && xPropSetInfo->hasPropertyByName(
+ WW8_ASCII2STR( pMap->pPropNm ) ) )
+ rPropSet->setPropertyValue( WW8_ASCII2STR( pMap->pPropNm ), aTmp );
+ }
+ // now calculate the size of the control
+ String sExpText;
+ sExpText.Fill( nDefSize, 'M' );
+ OutputDevice* pOut = Application::GetDefaultDevice();
+ pOut->Push( PUSH_FONT | PUSH_MAPMODE );
+ pOut->SetMapMode( MapMode( MAP_100TH_MM ));
+ pOut->SetFont( aFont );
+ rSz.Width = pOut->GetTextWidth( sExpText );
+ rSz.Height = pOut->GetTextHeight();
+
+ pOut->Pop();
+}
+
+
+BOOL WW8FormulaEditBox::Convert(const uno::Reference< lang::XMultiServiceFactory >& rServiceFactory,
+ uno::Reference< form::XFormComponent >& rFComp, com::sun::star::awt::Size &rSz)
+{
+ rtl::OUString sServiceName = WW8_ASCII2STR( "com.sun.star.form.component.TextField" );
+ uno::Reference< uno::XInterface > xCreate = rServiceFactory->createInstance( sServiceName );
+ if( !xCreate.is() )
+ return FALSE;
+
+ rFComp = uno::Reference< form::XFormComponent >( xCreate, uno::UNO_QUERY );
+ if( !rFComp.is() )
+ return FALSE;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xCreate, uno::UNO_QUERY );
+
+ uno::Any aTmp;
+ if( sTitle.Len() )
+ {
+ //UniString sTmp(pName,RTL_TEXTENCODING_ASCII_US);
+ aTmp <<= rtl::OUString( sTitle );
+ }
+ else
+ aTmp <<= rtl::OUString( sName );
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
+
+ BOOL bTemp = FALSE;
+ aTmp.setValue(&bTemp, ::getBooleanCppuType());
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "MultiLine" ), aTmp);
+
+ aTmp <<= (sal_Int16)0; //No Border
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "Border" ), aTmp);
+
+ if( sDefault.Len() )
+ {
+ aTmp <<= rtl::OUString( sDefault );
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "DefaultText" ), aTmp);
+ }
+
+ rSz.Width = 300;
+ rSz.Height = 200;
+
+ aTmp <<= (sal_Int32)(0x00C0C0C0);
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "BackgroundColor" ), aTmp);
+
+ SetOthersFromDoc(rFComp,rSz,xPropSet);
+
+ aTmp <<= (sal_Int16)nSize;
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "MaxTextLen" ), aTmp);
+
+ if( sToolTip.Len() )
+ {
+ aTmp <<= rtl::OUString( sToolTip );
+ xPropSet->setPropertyValue( WW8_ASCII2STR( "HelpText" ), aTmp );
+ }
+
+ return TRUE;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par3.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.53 2000/09/18 16:05:00 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.52 2000/08/22 17:41:01 cmc
+ #77315# 95 Formulas, bad string read
+
+ Revision 1.51 2000/07/20 14:47:21 khz
+ #75709# Remove NumRule from Node wit no/invalid LFO
+
+ Revision 1.50 2000/06/26 09:58:42 jp
+ must change: GetAppWindow->GetDefaultDevice
+
+ Revision 1.49 2000/06/23 10:29:55 khz
+ #71707# Make sure pNdNum is set to zero when no numbering on node
+
+ Revision 1.48 2000/05/25 08:06:52 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.47 2000/05/24 08:56:11 jp
+ Bugfixes for Unicode
+
+ Revision 1.46 2000/05/18 14:02:21 khz
+ UNO3 conversion: use rtl::OUString - not UString
+
+ Revision 1.45 2000/05/16 11:24:13 khz
+ Unicode code-conversion
+
+ Revision 1.44 2000/03/27 15:35:59 cmc
+ #74329# Ported WW97 Controls to uno codebase
+
+ Revision 1.43 2000/03/24 12:05:52 khz
+ Task #74368# IsInvalidOrToBeMergedTabCell() stops duplicate reset of NumRule
+
+ Revision 1.42 2000/03/21 15:04:57 os
+ UNOIII
+
+ Revision 1.41 2000/03/02 16:57:48 khz
+ Task #70716# Set AbsLSpace and FirstLineOffset *allways* on SwNumFmt
+
+ Revision 1.40 2000/02/23 17:10:46 khz
+ Task #71704# multiply negative aLVL.nDxaLeft by -1
+
+ Revision 1.39 2000/02/11 14:40:20 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.38 2000/02/09 11:29:46 khz
+ Task #70473# char_t --> sal_Unicode
+
+ Revision 1.37 1999/12/21 09:56:55 khz
+ Task #71144# ...component.Edit -> ...component.TextField
+
+ Revision 1.36 1999/12/09 14:52:33 khz
+ Task #67145# Don't set NumRule if OutlineNumrule is set on Style
+
+ Revision 1.35 1999/12/03 16:52:17 khz
+ Task #67145# Don't set NumRule if OutlineNumrule is set on Style
+
+ Revision 1.34 1999/11/29 17:50:28 khz
+ Task #70168# rNumFmt.SetFirstLineOffset() must get negative parameter
+
+ Revision 1.33 1999/11/29 11:28:25 jp
+ compiler error - missing include
+
+ Revision 1.32 1999/11/22 15:22:33 os
+ headers added
+
+ Revision 1.31 1999/11/19 16:40:21 os
+ modules renamed
+
+ Revision 1.30 1999/11/19 15:13:16 khz
+ Code Review: Replace WW8ReadByte()... by rSt >> nVari and remove rSt.GetError() calls
+
+ Revision 1.29 1999/10/08 09:26:15 khz
+ Import Redlining
+
+ Revision 1.28 1999/06/21 13:27:34 JP
+ Bug #60448#: Read_LFOPosition - set empty numrule item
+
+
+ Rev 1.27 21 Jun 1999 15:27:34 JP
+ Bug #60448#: Read_LFOPosition - set empty numrule item
+
+ Rev 1.26 21 Jun 1999 09:37:56 JP
+ AdjustLVL: break the charfmt search at first equal charfmt and save it at current level
+
+ Rev 1.25 09 Apr 1999 18:01:40 KHZ
+ Task #64348# Bei Listen-Overrides nur bei Ungleichheit neue Liste anlegen!
+
+ Rev 1.24 07 Apr 1999 16:31:40 KHZ
+ Task #64355# Nummerierungs-Postfix-String jetzt auch bei 1-stuf. Nummerierung
+
+ Rev 1.23 31 Mar 1999 20:19:20 KHZ
+ Task #61646# Falls Num. gesetzt, darf 1st-Zl-Einzuege am Abs. nur negativ sein.
+
+ Rev 1.22 30 Mar 1999 07:51:24 MIB
+ #62984#: XServiceManager -> XMultiServiceFactory
+
+ Rev 1.21 09 Mar 1999 11:07:56 MIB
+ #62980#: TF_ONE51-Umstallungen fuer Controls beendet
+
+ Rev 1.20 05 Mar 1999 20:50:44 KHZ
+ WICHTIGE UMBENENNUNG: VertOrientation_TOP (war: VerticalOrientation_TOP)
+
+ Rev 1.19 27 Feb 1999 13:35:02 KHZ
+ Task #62367# fuehrende 0xFF vor List-Format-Overrides ueberspringen
+
+ Rev 1.18 24 Feb 1999 14:28:50 KHZ
+ Bug #60733#: UpdateAll - vorm erzeugen des Textes die NumRules aktualisieren
+
+ Rev 1.17 17 Feb 1999 15:26:26 TJ
+ uno::Reference< XShapeFactory > raus
+
+ Rev 1.16 09 Feb 1999 17:01:54 HR
+ uno::Any: & eingefuegt
+
+ Rev 1.15 27 Jan 1999 09:45:06 OS
+ #56371# TF_ONE51
+
+ Rev 1.14 15 Dec 1998 11:08:46 KHZ
+ Tasks #59580# #58561# #58961# (Nachzieher aus SRV506) (2)
+
+ Rev 1.13 15 Dec 1998 10:44:18 KHZ
+ Tasks #59580# #58561# #58961# (Nachzieher aus SRV506)
+
+ Rev 1.12 03 Dec 1998 14:16:42 JP
+ Bug #58961#: Teilfix - Char.._N Format verwenden
+
+ Rev 1.11 02 Dec 1998 13:29:10 KHZ
+ Task #59837# ungueltiger Listenbasisstyle 0x0FFF auf Standardstyle gesetzt
+
+ Rev 1.10 17 Nov 1998 10:48:54 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.9 30 Oct 1998 10:29:20 KHZ
+ Task #57836# GPF, da irrtuemlich 255 gesetzt statt nWW8MaxListLevel
+
+ Rev 1.8 23 Sep 1998 09:52:00 KHZ
+ Syntaxfehler fuer OS/2
+
+ Rev 1.7 16 Sep 1998 15:56:42 MIB
+ #56513#: VC-Controls -> UNO-Controls
+
+ Rev 1.6 15 Sep 1998 12:58:36 HJS
+ '#56161#
+
+ Rev 1.5 05 Aug 1998 09:36:54 KHZ
+ Task #54382# hart attributierte L-Einzuege bei Listen
+
+ Rev 1.4 29 Jul 1998 13:55:34 KHZ
+ Task #52607# numm. Listen
+
+ Rev 1.3 28 Jul 1998 22:27:14 KHZ
+ Task #52607# nummerierte Listen (Teil 3)
+
+ Rev 1.2 28 Jul 1998 13:02:04 KHZ
+ Task #52607# nummerierte Listen (Teil 2)
+
+ Rev 1.1 28 Jul 1998 11:06:04 KHZ
+ Task #52607# nummerierte Listen (Teil 1)
+
+ Rev 1.0 16 Jun 1998 11:08:02 KHZ
+ Initial revision.
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
new file mode 100644
index 000000000000..b0b35bd2e9f3
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -0,0 +1,777 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par4.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <tools/solar.h>
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _TOOLS_TEMPFILE_HXX
+#include <tools/tempfile.hxx>
+#endif
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SVSTOR_HXX //autogen
+#include <so3/svstor.hxx>
+#endif
+#ifndef _FILTER_HXX //autogen
+#include <svtools/filter.hxx>
+#endif
+#ifndef _SVDOOLE2_HXX //autogen
+#include <svx/svdoole2.hxx>
+#endif
+#ifndef _MSDFFIMP_HXX
+#include <svx/msdffimp.hxx>
+#endif
+#ifndef _SVX_IMPGRF_HXX
+#include <svx/impgrf.hxx>
+#endif
+
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen wg. SwFmtCntnt
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen
+#include <frmfmt.hxx>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+#ifndef _NDGRF_HXX //autogen wg. SwGrfNode
+#include <ndgrf.hxx>
+#endif
+/*
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif*/
+#ifndef _DOCSH_HXX
+#include <docsh.hxx> // fuer Ole-Node
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // Progress
+#endif
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx> // __WW_NEEDS_COPY
+#endif
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx>
+#endif
+#ifndef _WW8PAR2_HXX
+#include <ww8par2.hxx> // WWFlyPara::BoxUpWidth()
+#endif
+/*
+#ifndef _REDLENUM_HXX
+#include <redlenum.hxx>
+#endif*/
+#ifndef _REDLINE_HXX
+#include <redline.hxx>
+#endif
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx>
+#endif
+#ifndef _MSOCXIMP_HXX
+#include <msocximp.hxx>
+#endif
+#ifndef _UNODRAW_HXX
+#include <unodraw.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+
+
+struct OLE_MFP
+{
+ INT16 mm; // 0x6 int
+ INT16 xExt; // 0x8 int in 1/100 mm
+ INT16 yExt; // 0xa int in 1/100 mm
+ INT16 hMF; // 0xc int
+};
+
+
+SV_IMPL_OP_PTRARR_SORT(WW8AuthorInfos, WW8AuthorInfo_Ptr)
+
+
+static BOOL SwWw8ReadScaling( INT16& rX, INT16& rY, SvStorageRef& rSrc1 )
+{
+ // Skalierungsfaktoren holen:
+ // Informationen in PIC-Stream ( durch ausprobieren )
+ // 0x0 (l)cb
+ // 0x08 .. 0x0a Flags ??
+ // 0x08 Inh: 1 / 0
+ // 0x09 Inh: 0,8,0x18
+ // 0x0a Inh: immer 8, MAP_ANISOTROPIC ???
+ // 0x0b Inh: immer 0
+ // 0x0c, 0x10 Originalgroesse x,y in 1/100 mm
+ // 0x14, 0x16 Originalgroesse x,y in tw
+ // 0x2c, 0x30 Skalierung x,y in Promille
+ // 0x34, 0x38, 0x3c, 0x40 Crop Left, Top, Right, Bot in tw
+
+ SvStorageStreamRef xSrc3 = rSrc1->OpenStream( WW8_ASCII2STR( "\3PIC" ));
+ SvStorageStream* pS = xSrc3;
+ pS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ pS->Seek( STREAM_SEEK_TO_END );
+
+ ASSERT( pS->Tell() >= 76, "+OLE-PIC-Stream is shorter than 76 Byte" );
+
+ INT32 nOrgWidth,
+ nOrgHeight,
+ nScaleX,
+ nScaleY,
+ nCropLeft,
+ nCropTop,
+ nCropRight,
+ nCropBottom;
+ pS->Seek( 0x14 );
+ *pS >> nOrgWidth // Original Size in 1/100 mm
+ >> nOrgHeight;
+ pS->Seek( 0x2c );
+ *pS >> nScaleX // Scaling in Promille
+ >> nScaleY
+ >> nCropLeft // Cropping in 1/100 mm
+ >> nCropTop
+ >> nCropRight
+ >> nCropBottom;
+
+ rX = nOrgWidth - nCropLeft - nCropRight;
+ rY = nOrgHeight - nCropTop - nCropBottom;
+ if( 10 > nScaleX
+ || 65536 < nScaleX
+ || 10 > nScaleY
+ || 65536 < nScaleY)
+ {
+ ASSERT( !pS, "+OLE-Scalinginformation in PIC-Stream wrong" );
+ return FALSE;
+ }
+ else
+ {
+ rX = (INT16)( (long)rX * nScaleX / 1000 );
+ rY = (INT16)( (long)rY * nScaleY / 1000 );
+ }
+ return TRUE;
+}
+
+static BOOL SwWw6ReadMetaStream( GDIMetaFile& rWMF, OLE_MFP* pMfp,
+ SvStorageRef& rSrc1 )
+{
+ SvStorageStreamRef xSrc2 = rSrc1->OpenStream( WW8_ASCII2STR( "\3META" ));
+ SvStorageStream* pSt = xSrc2;
+ pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ ULONG nRead = pSt->Read( pMfp, sizeof(*pMfp ) );
+ // Mini-Placable-Header lesen
+ if( nRead != sizeof( *pMfp ) )
+ return FALSE;
+
+#if defined __BIGENDIAN
+ pMfp->mm = SWAPSHORT( pMfp->mm );
+ pMfp->xExt = SWAPSHORT( pMfp->xExt );
+ pMfp->yExt = SWAPSHORT( pMfp->yExt );
+#endif // __BIGENDIAN
+
+ if( pMfp->mm == 94 || pMfp->mm == 99 )
+ {
+ ASSERT( !pSt, "+OLE: Falscher Metafile-Typ" );
+ return FALSE;
+ }
+ if( pMfp->mm != 8 )
+ {
+ ASSERT( !pSt, "+OLE: Falscher Metafile-Typ ( nicht Anisotropic )" );
+ }
+ if( !pMfp->xExt || !pMfp->yExt )
+ {
+ ASSERT( !pSt, "+OLE: Groesse von 0 ???" );
+ return FALSE;
+ }
+ BOOL bOk = ReadWindowMetafile( *pSt, rWMF ); // WMF lesen
+ // *pSt >> aWMF geht nicht ohne placable Header
+ if( !bOk || pSt->GetError() || rWMF.GetActionCount() == 0 ){
+ ASSERT( !pSt, "+OLE: Konnte Metafile nicht lesen" );
+ return FALSE;
+ }
+
+ rWMF.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
+
+
+ // MetaFile auf neue Groesse skalieren und
+ // neue Groesse am MetaFile setzen
+ Size aOldSiz( rWMF.GetPrefSize() );
+ Size aNewSiz( pMfp->xExt, pMfp->yExt );
+ Fraction aFracX( aNewSiz.Width(), aOldSiz.Width() );
+ Fraction aFracY( aNewSiz.Height(), aOldSiz.Height() );
+
+ rWMF.Scale( aFracX, aFracY );
+ rWMF.SetPrefSize( aNewSiz );
+
+ return TRUE;
+}
+
+static BOOL SwWw6ReadMacPICTStream( Graphic& rGraph, SvStorageRef& rSrc1 )
+{
+ // 03-META-Stream nicht da. Vielleicht ein 03-PICT ?
+ SvStorageStreamRef xSrc4 = rSrc1->OpenStream( WW8_ASCII2STR( "\3PICT" ));
+ SvStorageStream* pStp = xSrc4;
+ pStp->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ BYTE aTestA[10]; // Ist der 01Ole-Stream ueberhaupt vorhanden
+ ULONG nReadTst = pStp->Read( aTestA, sizeof( aTestA ) );
+ if(nReadTst != sizeof(aTestA))
+ return FALSE;
+
+ pStp->Seek( STREAM_SEEK_TO_BEGIN );
+
+ // Mac-Pict steht im 03PICT-StorageStream
+ // allerdings ohne die ersten 512 Bytes, die
+ // bei einem MAC-PICT egal sind ( werden nicht ausgewertet )
+ String sExt(WW8_ASCII2STR( "pct" ));
+ TempFile aTempFile(aEmptyStr, &sExt);
+ aTempFile.EnableKillingFile();
+ {
+ SvFileStream aOut( aTempFile.GetName(),
+ STREAM_READ|STREAM_WRITE|STREAM_TRUNC );
+
+
+ BYTE* pBuf = new BYTE[512];
+ memset( pBuf, 0, 512 );
+ aOut.Write( pBuf, 512 ); // Anfang Pict: 512 Byte Muell
+ delete( pBuf );
+ aOut << *pStp; // Storage-Stream rausschreiben
+ }
+
+ GraphicFilter& rGF = *::GetGrfFilter(); // lese ueber Filter ein
+#if SUPD<591
+ BOOL bOk = 0 == rGF.ImportGraphic( rGraph, DirEntry(aTempFile.GetName()), GRFILTER_FORMAT_DONTKNOW );
+#else
+ BOOL bOk = 0 == rGF.ImportGraphic( rGraph, INetURLObject(aTempFile.GetName()), GRFILTER_FORMAT_DONTKNOW );
+#endif
+ return bOk;
+}
+
+
+using namespace ::com::sun::star;
+
+
+SwFrmFmt* SwWW8ImplReader::ImportOle( const Graphic* pGrf,
+ const SfxItemSet* pFlySet )
+{
+ SwFrmFmt* pFmt = 0;
+ if( !(nIniFlags & WW8FL_NO_OLE ))
+ {
+ ASSERT( pStg, "ohne storage geht hier fast gar nichts!" );
+
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+ INT16 nX, nY; // nX, nY ist Ziel-Groesse
+ BOOL bOleOk = TRUE;
+ Graphic aGraph;
+
+ String aSrcStgName = '_';
+ aSrcStgName += String::CreateFromInt32( nObjLocFc ); // ergibt Name "_4711"
+
+ SvStorageRef xSrc0 = pStg->OpenStorage( WW8_ASCII2STR( "ObjectPool" ) );
+
+ if( pGrf )
+ {
+ aGraph = *pGrf;
+ const Size aSizeTwip = OutputDevice::LogicToLogic(
+ aGraph.GetPrefSize(),
+ aGraph.GetPrefMapMode(),
+ MAP_TWIP );
+ nX = (INT16) aSizeTwip.Width();
+ nY = (INT16) aSizeTwip.Height();
+ }
+ else
+ {
+ SvStorageRef xSrc1 = xSrc0->OpenStorage( aSrcStgName,
+ STREAM_READWRITE| STREAM_SHARE_DENYALL );
+ OLE_MFP aMfp;
+ GDIMetaFile aWMF;
+ if( SwWw6ReadMetaStream( aWMF, &aMfp, xSrc1 ) )
+ {
+ /* ignore size, take Size in SwWw8ReadScaling instead!
+ INT16 nXO = (INT16)( (long)aMfp.xExt * 144 / 254 );
+ INT16 nYO = (INT16)( (long)aMfp.yExt * 144 / 254 );
+ */
+ SwWw8ReadScaling( nX, nY, xSrc1 );
+ aGraph = Graphic( aWMF );
+ }
+ // 03-META-Stream nicht da. Vielleicht ein 03-PICT ?
+ else if( SwWw6ReadMacPICTStream( aGraph, xSrc1 ) )
+ {
+ const Size aSizeTwip = OutputDevice::LogicToLogic(
+ aGraph.GetPrefSize(),
+ aGraph.GetPrefMapMode(),
+ MAP_TWIP );
+ nX = (INT16) aSizeTwip.Width();
+ nY = (INT16) aSizeTwip.Height();
+ bOleOk = FALSE; // PICT: kein WMF da -> Grafik statt OLE
+ }
+#if 0
+//JP 23.06.99 - if the OLE-Storage does not contained the streams META
+// or PICT, then import the grafic from the escher.
+// But the Question is, is the OLE-Storage then a valid
+// OLE-Object and is the user be able to activate it. So it's
+// better to import it as grafic.
+
+ else
+ {
+ ULONG nOldObjLocFc = nOldObjLocFc;
+ nObjLocFc = 0;
+
+ SwFrmFmt* pGrfFmt = ImportGraf();
+ if( pGrfFmt )
+ {
+ const SwNodeIndex* pCntIdx = pGrfFmt->GetCntnt( FALSE ).
+ GetCntntIdx();
+ if( pCntIdx )
+ {
+ SwNodeIndex aIdx( *pCntIdx, 1 );
+ if( aIdx.GetNode().IsGrfNode() )
+ {
+ // get the grafic of the node and delete it
+ // then complete, because its become a OLE-Object
+ aGraph = aIdx.GetNode().GetGrfNode()->GetGrf();
+ Size aSz( aIdx.GetNode().GetGrfNode()->GetTwipSize() );
+ nX = (INT16) aSz.Width();
+ nY = (INT16) aSz.Height();
+
+ rDoc.DelLayoutFmt( pGrfFmt );
+ pGrfFmt = 0;
+ }
+ }
+ pFmt = pGrfFmt;
+ }
+ nObjLocFc = nOldObjLocFc;
+ }
+#endif
+ } // StorageStreams wieder zu
+
+//#ifdef DEBUG
+ SvStorageRef xSrc1 = xSrc0->OpenStorage( aSrcStgName,
+ STREAM_READWRITE| STREAM_SHARE_DENYALL );
+
+ if(!pFormImpl)
+ pFormImpl = new SwImportControls(rDoc.GetDocShell(),pPaM);
+ uno::Reference< drawing::XShape > xRef;
+ if (pFormImpl->ReadOCXStream(xSrc1,&xRef,bFloatingCtrl))
+ {
+ bOleOk = FALSE;
+ uno::Reference< beans::XPropertySet > xPropSet( xRef, uno::UNO_QUERY );
+ uno::Reference< lang::XUnoTunnel> xTunnel( xPropSet, uno::UNO_QUERY);
+ SwXShape *pSwShape = 0;
+ if(xTunnel.is())
+ {
+ pSwShape = (SwXShape*)xTunnel->getSomething(SwXShape::getUnoTunnelId());
+ }
+ return pSwShape ? (SwFrmFmt*)(pSwShape->GetRegisteredIn()) : 0;
+ }
+//#endif
+
+
+ if( GRAPHIC_GDIMETAFILE == aGraph.GetType() ||
+ GRAPHIC_BITMAP == aGraph.GetType() )
+ {
+ ::SetProgressState( nProgress, rDoc.GetDocShell() ); // Update
+
+ Point aTmpPoint;
+ Rectangle aRect( aTmpPoint, Size( nX, nY ) );
+ SwAttrSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN,
+ RES_FRMATR_END-1);
+ if( !pFlySet )
+ {
+ pFlySet = &aFlySet;
+
+ if( !bNew )
+ Reader::ResetFrmFmtAttrs( aFlySet ); // Abstand/Umrandung raus
+
+ SwFmtAnchor aAnchor( FLY_IN_CNTNT );
+ aAnchor.SetAnchor( pPaM->GetPoint() );
+ aFlySet.Put( aAnchor );
+
+ aFlySet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nX, nY ) );
+ aFlySet.Put( SwFmtVertOrient( 0, VERT_TOP, FRAME ));
+
+ if( pSFlyPara ) // OLE im Rahmen ?
+ { // ok, Rahmen auf Bildgroesse vergroessern
+ // ( nur wenn Auto-Breite )
+ pSFlyPara->BoxUpWidth( nX );
+ }
+ }
+ else
+ {
+ const SwFmtFrmSize* pSize = (SwFmtFrmSize*)pFlySet->GetItem(
+ RES_FRM_SIZE, FALSE );
+ if( pSize )
+ aRect.SetSize( pSize->GetSize() );
+ }
+
+
+ if( bOleOk && !( nIniFlags & WW8FL_OLE_TO_GRAF ))
+ {
+ ULONG nOldPos = pDataStream->Tell();
+
+ pDataStream->Seek(STREAM_SEEK_TO_END);
+ SvStream *pTmpData;
+ if (nObjLocFc < pDataStream->Tell())
+ {
+ pTmpData = pDataStream;
+ pTmpData->Seek( nObjLocFc );
+ }
+ else
+ pTmpData = 0;
+ SvStorageRef xDst0( rDoc.GetDocShell()->GetStorage() );
+ SdrOle2Obj* pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
+ aSrcStgName, xSrc0, xDst0,
+ aGraph, aRect, pTmpData,
+ SwMSDffManager::GetFilterFlags());
+ if( pRet ) // Ole-Object wurde eingefuegt
+ {
+ pFmt = rDoc.Insert( *pPaM, &pRet->GetObjRef(), pFlySet );
+ delete pRet; // das brauchen wir nicht mehr
+ }
+ else
+ bOleOk = FALSE;
+ pDataStream->Seek( nOldPos );
+ }
+
+ if( !bOleOk || (nIniFlags & WW8FL_OLE_TO_GRAF) )
+ pFmt = rDoc.Insert( *pPaM,
+ aEmptyStr, aEmptyStr, // Name der Grafik !!
+ &aGraph,
+ pFlySet, // Attribute fuer den FlyFrm
+ 0 ); // Attribute fuer die Grafik
+ }
+ }
+ return pFmt;
+}
+
+
+void SwWW8ImplReader::ReadRevMarkAuthorStrTabl( SvStream& rStrm,
+ INT32 nTblPos,
+ INT32 nTblSiz,
+ SwDoc& rDoc )
+{
+ SvStrings aAuthorNames( 0, 16 );
+ WW8ReadSTTBF( !bVer67, rStrm, nTblPos, nTblSiz, bVer67 ? 2 : 0,
+ eStructCharSet, aAuthorNames );
+
+ for( USHORT nAuthor = 0; nAuthor < aAuthorNames.Count(); ++nAuthor )
+ {
+ // Store author in doc
+ USHORT nSWId = rDoc.InsertRedlineAuthor( *aAuthorNames[ nAuthor ] );
+ // Store matchpair
+ if( !pAuthorInfos )
+ pAuthorInfos = new WW8AuthorInfos;
+ WW8AuthorInfo* pAutorInfo = new WW8AuthorInfo( nAuthor, nSWId );
+ if( 0 == pAuthorInfos->Insert( pAutorInfo ) )
+ delete pAutorInfo;
+ }
+ aAuthorNames.DeleteAndDestroy( 0, aAuthorNames.Count() );
+}
+
+/*
+ Revision Marks ( == Redlining )
+*/
+// insert or delete content (change char attributes resp.)
+void SwWW8ImplReader::Read_CRevisionMark(SwRedlineType eType, USHORT nId, BYTE* pData, short nLen )
+{
+ // there *must* be a SprmCIbstRMark[Del] and a SprmCDttmRMark[Del]
+ // pointing to the very same char position as our SprmCFRMark[Del]
+ if( !pPlcxMan ) return;
+ const BYTE* pSprmCIbstRMark;
+ const BYTE* pSprmCDttmRMark;
+// const BYTE* pSprmCIdslRMark;
+ if( REDLINE_FORMAT == eType )
+ {
+ pSprmCIbstRMark = pData+1;
+ pSprmCDttmRMark = pData+3;
+ }
+ else
+ {
+ BOOL bIns = (REDLINE_INSERT == eType);
+ if( bVer67 )
+ {
+ pSprmCIbstRMark = pPlcxMan->HasCharSprm( 69 );
+ pSprmCDttmRMark = pPlcxMan->HasCharSprm( 70 );
+ }
+ else
+ {
+ pSprmCIbstRMark = pPlcxMan->HasCharSprm( bIns ? 0x4804 : 0x4863 );
+ pSprmCDttmRMark = pPlcxMan->HasCharSprm( bIns ? 0x6805 : 0x6864 );
+// pSprmCIdslRMark = pPlcxMan->HasCharSprm( bIns ? 0x4807 : 0x4867 );
+ }
+ }
+ if( !pSprmCIbstRMark || !pSprmCDttmRMark ) return;
+
+ if( nLen < 0 )
+ {
+ // end of current revision mark
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_REDLINE );
+ }
+ else
+ {
+ // start of new revision mark
+ USHORT nWWAutNo = SVBT16ToShort( pSprmCIbstRMark );
+ UINT32 nWWDate = SVBT32ToLong( pSprmCDttmRMark );
+ WW8AuthorInfo aEntry( nWWAutNo );
+ USHORT nPos;
+ if( pAuthorInfos->Seek_Entry( &aEntry, &nPos ) )
+ {
+ const WW8AuthorInfo* pAuthor = pAuthorInfos->GetObject( nPos );
+ if( pAuthor )
+ {
+ USHORT nAutorNo = pAuthor->nOurId;
+ DateTime aStamp(WW8ScannerBase::WW8DTTM2DateTime(nWWDate));
+
+ SwFltRedline aNewAttr(eType, nAutorNo, aStamp);
+
+ const SwFltRedline* pOldAttr =
+ (const SwFltRedline*)pCtrlStck->GetOpenStackAttr(
+ *pPaM->GetPoint(),
+ RES_FLTR_REDLINE );
+ // 1st look if there is already another redline Attribute
+ // set on this text-region
+ // If so, we take it's data and store it as 'previous'
+ // or the other way around
+ if( pOldAttr )
+ { // Insert on top of Delete ? This is not allowed !
+ BOOL bDateWrongWayAround
+ = (REDLINE_INSERT == eType)
+ && (REDLINE_DELETE == pOldAttr->eType);
+ if( bDateWrongWayAround
+ || ( (aStamp < pOldAttr->aStamp)
+ && ! ( (REDLINE_INSERT == pOldAttr->eType)
+ && (REDLINE_DELETE == eType)
+ )
+ )
+ )
+ {
+ if( bDateWrongWayAround
+ && !(nAutorNo == pOldAttr->nAutorNo) )
+ {
+ aNewAttr.eTypePrev = eType;
+ aNewAttr.nAutorNoPrev = nAutorNo;
+ aNewAttr.aStampPrev = aStamp;
+ aNewAttr.eType = pOldAttr->eType;
+ aNewAttr.nAutorNo = pOldAttr->nAutorNo;
+ aNewAttr.aStamp = pOldAttr->aStamp;
+ }
+ // else do nothing: so only the INSERT will be stored!
+ }
+ else
+ {
+ aNewAttr.eTypePrev = pOldAttr->eType;
+ aNewAttr.nAutorNoPrev = pOldAttr->nAutorNo;
+ aNewAttr.aStampPrev = pOldAttr->aStamp;
+ }
+ }
+ NewAttr( aNewAttr );
+ }
+ }
+ }
+}
+// insert new content
+void SwWW8ImplReader::Read_CFRMark( USHORT nId, BYTE* pData, short nLen )
+{
+ Read_CRevisionMark( REDLINE_INSERT, nId, pData, nLen );
+}
+// delete old content
+void SwWW8ImplReader::Read_CFRMarkDel( USHORT nId, BYTE* pData, short nLen )
+{
+ Read_CRevisionMark( REDLINE_DELETE, nId, pData, nLen );
+}
+// change properties of content ( == char formating)
+void SwWW8ImplReader::Read_CPropRMark( USHORT nId, BYTE* pData, short nLen )
+{
+ // complex (len is always 7)
+ // 1 byte - chp.fPropRMark
+ // 2 bytes - chp.ibstPropRMark
+ // 4 bytes - chp.dttmPropRMark;
+ Read_CRevisionMark( REDLINE_FORMAT, nId, pData, nLen );
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par4.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.31 2000/09/18 16:05:01 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.30 2000/08/22 17:09:02 cmc
+ #77743# OLE Import, bad seek & bad FilterOptions
+
+ Revision 1.29 2000/06/29 20:59:11 jp
+ new MS Filteroptions - change OLE-Objects to StarOffice Objects
+
+ Revision 1.28 2000/06/13 08:24:46 os
+ using UCB
+
+ Revision 1.27 2000/05/18 11:01:01 jp
+ Changes for Unicode
+
+ Revision 1.26 2000/05/16 11:06:24 khz
+ Unicode code-conversion
+
+ Revision 1.25 2000/05/05 14:06:55 cmc
+ #75358# WW8 97Controls Import Fix
+
+ Revision 1.24 2000/04/03 15:29:02 cmc
+ #74329# Floating Form Controls
+
+ Revision 1.23 2000/03/27 11:45:31 cmc
+ #74329# Added OCX Reader to ImportOle
+
+ Revision 1.22 2000/03/22 14:35:32 khz
+ Task #74390# release pAutorInfo in case Insert() was not sucessful
+
+ Revision 1.21 2000/02/28 12:04:32 khz
+ Task #73544#: Use size and cropping from \3PIC stream rather than \3META
+
+ Revision 1.20 2000/02/21 13:08:27 jp
+ #70473# changes for unicode
+
+ Revision 1.19 2000/02/11 14:40:23 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.18 1999/10/21 15:36:41 khz
+ Import Redlining (4)
+
+ Revision 1.17 1999/10/13 21:04:34 khz
+ Import Redlining (3)
+
+ Revision 1.16 1999/10/13 13:27:45 khz
+ Import Redlining (2)
+
+ Revision 1.15 1999/10/08 09:26:19 khz
+ Import Redlining
+
+ Revision 1.14 1999/09/08 13:26:09 khz
+ Better performance by reducing use of SWAP..() and SVBT..To..() methods
+
+ Revision 1.13 1999/08/30 19:53:06 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.12 30 Aug 1999 21:53:06 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.11 09 Aug 1999 14:16:10 JP
+ read W95 format from stream
+
+ Rev 1.10 30 Jul 1999 13:59:28 JP
+ Bug #60140#: CreateSdrOLEFromStorage - read OLE1-Objects
+
+ Rev 1.9 23 Jun 1999 12:46:58 JP
+ delete unused variables
+
+ Rev 1.8 26 Apr 1999 19:22:54 JP
+ Bug #65298#: Grf/Ole bei Zeichenbindung immer Oben zu Grundline anordnen
+
+ Rev 1.7 12 Jan 1999 12:29:54 MH
+ chg: Syntax GCC
+
+ Rev 1.6 30 Nov 1998 18:18:20 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.5 30 Nov 1998 17:46:54 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.4 27 Nov 1998 09:45:22 JP
+ Task #59822#: OLE-Objecte importieren - Namen korrekt ermitteln
+
+ Rev 1.3 25 Nov 1998 11:29:14 JP
+ Task #59822#: OLE-Objecte einlesen - SetVisArea soll kein modified setzen
+
+ Rev 1.2 24 Nov 1998 20:47:50 JP
+ Task #59822#: OLE-Objecte einlesen
+
+ Rev 1.1 18 Sep 1998 13:10:10 JP
+ Bug #56310#: ImportOLE - die Zeichenbindung nicht doppelt machen
+
+ Rev 1.0 16 Jun 1998 11:08:16 KHZ
+ Initial revision.
+
+*************************************************************************/
+
+
+
+
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
new file mode 100644
index 000000000000..9685eb0f5afb
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -0,0 +1,3270 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par5.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:58 $
+ *
+ * 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 PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <ctype.h> // tolower
+#include <stdio.h> // sscanf()
+
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef SVTOOLS_URIHELPER_HXX
+#include <svtools/urihelper.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#include <tools/solar.h>
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _URLOBJ_HXX //autogen
+#include <tools/urlobj.hxx>
+#endif
+#ifndef _LINKMGR_HXX //autogen
+#include <so3/linkmgr.hxx>
+#endif
+
+#ifndef _ZFORLIST_HXX
+#include <svtools/zforlist.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX //autogen
+#include <svx/langitem.hxx>
+#endif
+#ifndef _UNOTOOLS_CHARCLASS_HXX
+#include <unotools/charclass.hxx>
+#endif
+
+#ifndef _FMTFLD_HXX //autogen
+#include <fmtfld.hxx>
+#endif
+#ifndef _FMTHBSH_HXX //autogen
+#include <fmthbsh.hxx>
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx> // fuer SwPam
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx> // class SwFmtFld
+#endif
+#ifndef _FLDDAT_HXX
+#include <flddat.hxx> // class SwDateTimeField
+#endif
+#ifndef _DOCUFLD_HXX
+#include <docufld.hxx> // class SwPageNumberField
+#endif
+#ifndef _REFFLD_HXX
+#include <reffld.hxx> // class SwGetRefField
+#endif
+#ifndef _BOOKMRK_HXX // class SwBookmark
+#include <bookmrk.hxx>
+#endif
+#ifndef _EXPFLD_HXX
+#include <expfld.hxx> // class SwSetExpField
+#endif
+#ifndef _DBFLD_HXX
+#include <dbfld.hxx> // class SwDBField
+#endif
+#ifndef _FINDER_HXX
+#include <finder.hxx> // class SwPathFinder, GetTOIName()
+#endif
+#ifndef _TOX_HXX
+#include <tox.hxx>
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx> // ReadFilterFlags
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx> // class SwSection
+#endif
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx> // WW8FieldDesc
+#endif
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx> // fuer den Attribut Stack
+#endif
+#ifndef _WW8PAR_HXX
+#include <ww8par.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _FMTINFMT_HXX
+#include <fmtinfmt.hxx>
+#endif
+#ifndef _CHPFLD_HXX
+#include <chpfld.hxx>
+#endif
+#ifndef _FTNIDX_HXX
+#include <ftnidx.hxx>
+#endif
+#ifndef _TXTFTN_HXX
+#include <txtftn.hxx>
+#endif
+#ifndef _VIEWSH_HXX
+#include <viewsh.hxx>
+#endif
+#ifndef _SHELLRES_HXX
+#include <shellres.hxx>
+#endif
+
+#define WWF_INVISIBLE 86 // Bit-Nummer fuer Invisible ( IniFlags )
+#define MAX_FIELDLEN 64000
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::uno;
+using namespace ::ucb;
+using namespace ::rtl;
+
+extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich,
+ USHORT& rSubType, ULONG &rFmt,
+ USHORT nVersion );
+
+
+
+class _ReadFieldParams
+{
+ String aData;
+ xub_StrLen nLen, nFnd, nNext, nSavPtr;
+// sal_Unicode cLastChar;
+
+public:
+ _ReadFieldParams( const String& rData );
+ ~_ReadFieldParams();
+
+ xub_StrLen GoToTokenParam();
+ long SkipToNextToken();
+ xub_StrLen GetTokenSttPtr() const { return nFnd; }
+ void SetNextPtr( xub_StrLen _nNext ) { nNext = _nNext; }
+
+ xub_StrLen FindNextStringPiece( xub_StrLen _nStart = STRING_NOTFOUND );
+ BOOL GetTokenSttFromTo(xub_StrLen* _pFrom, xub_StrLen* _pTo, xub_StrLen _nMax);
+
+ String GetResult() const;
+};
+
+
+_ReadFieldParams::_ReadFieldParams( const String& _rData )
+ : aData( _rData ), nLen( _rData.Len() ), nNext( 0 )
+{
+ /*
+ erstmal nach einer oeffnenden Klammer oder einer Leerstelle oder einem
+ Anfuehrungszeichen oder einem Backslash suchen, damit der Feldbefehl
+ (also INCLUDEPICTURE bzw EINFUeGENGRAFIK bzw ...) ueberlesen wird
+ */
+ while( (nLen > nNext) && (aData.GetChar( nNext ) == ' ') )
+ ++nNext;
+
+ sal_Unicode c;
+ while( nLen > nNext
+ && (c = aData.GetChar( nNext )) != ' '
+ && c != '"'
+ && c != '\\'
+ && c != 132 )
+ ++nNext;
+
+ nFnd = nNext;
+ nSavPtr = nNext;
+// cLastChar = aData.GetChar( nSavPtr );
+}
+
+
+_ReadFieldParams::~_ReadFieldParams()
+{
+// aData.SetChar( nSavPtr, cLastChar );
+}
+
+
+String _ReadFieldParams::GetResult() const
+{
+ return (STRING_NOTFOUND == nFnd)
+ ? aEmptyStr
+ : aData.Copy( nFnd, (nSavPtr - nFnd) );
+}
+
+
+xub_StrLen _ReadFieldParams::GoToTokenParam()
+{
+ xub_StrLen nOld = nNext;
+ if( -2 == SkipToNextToken() )
+ return GetTokenSttPtr();
+ nNext = nOld;
+ return STRING_NOTFOUND;
+}
+
+long _ReadFieldParams::SkipToNextToken() // ret: -2: NOT a '\' parameter but normal Text
+{
+ long nRet = -1; // Ende
+// aData.SetChar( nSavPtr, cLastChar );
+ if( (STRING_NOTFOUND != nNext)
+ && (nLen > nNext)
+ && STRING_NOTFOUND != ( nFnd = FindNextStringPiece( nNext ) ))
+ {
+ nSavPtr = nNext;
+// cLastChar = aData.GetChar( nSavPtr );
+
+ if( '\\' == aData.GetChar( nFnd )
+ && '\\' != aData.GetChar( nFnd + 1 ) ) // Options-Parameter gefunden
+ {
+ nRet = aData.GetChar( ++nFnd );
+ nNext = ++nFnd; // und dahinter setzen
+ }
+ else
+ {
+ nRet = -2;
+ if( (STRING_NOTFOUND != nSavPtr )
+ && ('"' == aData.GetChar( nSavPtr - 1 )) )
+ {
+ nSavPtr--;
+// cLastChar = aData.GetChar( nSavPtr );
+ }
+// aData.SetChar( nSavPtr, 0 );
+ }
+ }
+ return nRet;
+}
+
+// FindNextPara sucht naechsten Backslash-Parameter oder naechste Zeichenkette
+// bis zum Blank oder naechsten "\" oder zum schliessenden Anfuehrungszeichen
+// oder zum String-Ende von pStr.
+//
+// Ausgabe ppNext (falls ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0
+//
+// Returnwert: 0 falls String-Ende erreicht,
+// ansonsten Anfang des Paramters bzw. der Zeichenkette
+//
+xub_StrLen _ReadFieldParams::FindNextStringPiece(const xub_StrLen nStart)
+{
+ xub_StrLen n = ( STRING_NOTFOUND == nStart ) ? nFnd : nStart; // Anfang
+ xub_StrLen n2; // Ende
+
+ nNext = STRING_NOTFOUND; // Default fuer nicht gefunden
+
+ while( (nLen > n) && (aData.GetChar( n ) == ' ') )
+ ++n;
+
+ if( nLen == n )
+ return STRING_NOTFOUND; // String End reached!
+
+ if( (aData.GetChar( n ) == '"') // Anfuehrungszeichen vor Para?
+ || (aData.GetChar( n ) == 132) )
+ {
+ n++; // Anfuehrungszeichen ueberlesen
+ n2 = n; // ab hier nach Ende suchen
+ while( (nLen > n2)
+ && (aData.GetChar( n2 ) != '"')
+ && (aData.GetChar( n2 ) != 147) )
+ n2++; // Ende d. Paras suchen
+ }
+ else // keine Anfuehrungszeichen
+ {
+ n2 = n; // ab hier nach Ende suchen
+ while( (nLen > n2) && (aData.GetChar( n2 ) != ' ') ) // Ende d. Paras suchen
+ {
+ if( aData.GetChar( n2 ) == '\\' )
+ {
+ if( aData.GetChar( n2+1 ) == '\\' )
+ n2 += 2; // Doppel-Backslash -> OK
+ else
+ {
+ if( n2 > n )
+ n2--;
+ break; // einfach-Backslash -> Ende
+ }
+ }
+ else
+ n2++; // kein Backslash -> OK
+ }
+ }
+ if( nLen > n2 )
+ {
+ if(aData.GetChar( n2 ) != ' ') n2++;
+ nNext = n2;
+ }
+ return n;
+}
+
+
+
+// read parameters "1-3" or 1-3 with both values between 1 and nMax
+BOOL _ReadFieldParams::GetTokenSttFromTo(USHORT* pFrom, USHORT* pTo, USHORT nMax)
+{
+ USHORT nStart = 0;
+ USHORT nEnd = 0;
+ xub_StrLen n = GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ {
+
+ String sParams( GetResult() );
+
+ xub_StrLen nIndex = 0;
+ String sStart( sParams.GetToken(0, '-', nIndex) );
+ if( STRING_NOTFOUND != nIndex )
+ {
+ nStart = sStart.ToInt32();
+ nEnd = sParams.Copy( nIndex ).ToInt32();
+ }
+ }
+ if( pFrom ) *pFrom = nStart;
+ if( pTo ) *pTo = nEnd;
+
+ return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd);
+}
+
+
+
+
+/* */
+
+
+//----------------------------------------
+// Initialisieren der Feld-FilterFlags
+//----------------------------------------
+
+void SwWW8ImplReader::Read_FieldIniFlags()
+{
+ USHORT i;
+ nFieldFlags = ReadFilterFlags( "WWF" );
+ if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) ){
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF );
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID );
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT );
+ SwFltSetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
+ for( i = 0; i < 3; i++ ){
+ nFieldTagAlways[i] = 0; // Hypo-Default: bekannte Felder
+ } // nicht taggen
+ nFieldTagBad[0] = 0xffffffff; // unbekannte Felder taggen
+ nFieldTagBad[1] = 0xffffffff; //
+ nFieldTagBad[2] = 0xffffffef; // "EinfuegenText" nicht taggen
+ }else{
+ nFieldTagAlways[0] = ReadFilterFlags( "WWFA0" );
+ nFieldTagAlways[1] = ReadFilterFlags( "WWFA1" );
+ nFieldTagAlways[2] = ReadFilterFlags( "WWFA2" );
+ nFieldTagBad[0] = ReadFilterFlags( "WWFB0" );
+ nFieldTagBad[1] = ReadFilterFlags( "WWFB1" );
+ nFieldTagBad[2] = ReadFilterFlags( "WWFB2" );
+ }
+}
+
+//----------------------------------------
+// Bookmarks
+//----------------------------------------
+
+long SwWW8ImplReader::Read_Book( WW8PLCFManResult* pRes, BOOL bStartAttr )
+{
+ if( !bStartAttr )
+ {
+ ASSERT( bStartAttr, "Read_Book::Nanu ?" );
+ pEndStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK );
+ return 0;
+ }
+ WW8PLCFx_Book* pB = pPlcxMan->GetBook(); // muesste auch ueber pRes.nCo2OrIdx gehen
+ if( !pB ){
+ ASSERT( pB, "WW8PLCFx_Book - Pointer nicht da" );
+ return 0;
+ }
+
+ if( pB->GetIsEnd() ){
+#if 0
+ rDoc.Insert( *pPaM, 'E', CHARSET_ANSI );
+#endif
+ pEndStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK,
+ TRUE, pB->GetHandle() );
+ return 0;
+ }
+
+ eBookStatus eB = pB->GetStatus();
+ if( ( eB & BOOK_IGNORE ) != 0 )
+ return 0; // Bookmark zu ignorieren
+#if 0
+ rDoc.Insert( *pPaM, 'A', CHARSET_ANSI );
+#endif
+
+ const String* pName = pB->GetName();
+ if( !pName
+ || pName->EqualsIgnoreCaseAscii( "_Toc" ) ) // "_Toc*" ist ueberfluessig
+ return 0;
+
+//JP 16.11.98: ToUpper darf auf keinen Fall gemacht werden, weil der Bookmark-
+// name ein Hyperlink-Ziel sein kann!
+
+ // Fuer UEbersetzung Bookmark -> Variable setzen
+ long nLen = pB->GetLen();
+ if( nLen > MAX_FIELDLEN )
+ nLen = MAX_FIELDLEN;
+
+ String sTxt;
+ long nOldPos = pStrm->Tell();
+ nLen = pSBase->WW8ReadString( *pStrm, sTxt, pB->GetStartPos(), nLen,
+ eStructCharSet );
+
+ pStrm->Seek( nOldPos );
+ String aVal;
+ QuoteString( aVal, sTxt ); // Nur druckbare Zeichen !
+ // incl. Zeichensatz - UEbersetzung
+
+ pEndStck->NewAttr( *pPaM->GetPoint(), SwFltBookmark( *pName, aVal,
+ pB->GetHandle(), ( eB & BOOK_ONLY_REF ) != 0 ) );
+ return 0;
+}
+
+//----------------------------------------------------------------------
+// allgemeine Hilfsroutinen zum Auseinanderdroeseln der Parameter
+//----------------------------------------------------------------------
+
+// ConvertFFileName uebersetzt FeldParameter-Namen u. ae. in den
+// System-Zeichensatz.
+// Gleichzeitig werden doppelte Backslashes in einzelne uebersetzt.
+void SwWW8ImplReader::ConvertFFileName( String& rName, const String& rOrg )
+{
+ rName = rOrg;
+ rName.SearchAndReplaceAllAscii( "\\\\", String( '\\' ));
+
+ // ggfs. anhaengende Anfuehrungszeichen entfernen
+ if( rName.Len() && '"' == rName.GetChar( rName.Len()-1 ))
+ rName.Erase( rName.Len()-1, 1);
+}
+
+// ConvertUFNneme uebersetzt FeldParameter-Namen u. ae. in den
+// System-Zeichensatz und Upcased sie ( z.B. fuer Ref-Felder )
+void SwWW8ImplReader::ConvertUFName( String& rName )
+{
+ GetAppCharClass().toUpper( rName );
+}
+
+void lcl_ConvertSequenceName( SwWW8ImplReader& rReader, String& rSequenceName )
+{
+ rReader.ConvertUFName( rSequenceName );
+ if( '0' <= rSequenceName.GetChar( 0 )
+ && '9' >= rSequenceName.GetChar( 0 ) )
+ rSequenceName.Insert('_', 0);
+}
+/*
+// FindNextPara sucht Naechsten Parameter und setzt
+// eine 0 hinter sein Ende ( im Original-String )!
+// Bei Anfuehrungszeichen
+// ( normal oder typographisch ) wird der ganze String genommen.
+// Escape-Chars ( Backslash ) werden nicht beachtet.
+// Rueckgabe: wenn ppNext != 0 dann Suchbeginn fuer naechsten Parameter
+// Return 0 fuer nicht gefunden oder Anfang des Paramters
+static char* FindNextPara( char* pStr, char** ppNext = 0 )
+{
+ if( ppNext )
+ *ppNext = 0; // Default fuer nicht gefunden
+ char* p = pStr; // Anfang
+ char* p2; // Ende
+
+ while( *p == ' ' ) // Spaces vor Para ueberlesen
+ p++;
+ if( !*p )
+ return 0;
+ if( *p == '"' || *(BYTE*)p == 132 ){ // Anfuehrungszeichen vor Para
+ p++; // Anfuehrungszeichen ueberlesen
+ p2 = p; // ab hier nach Ende suchen
+ while( *p2 != '"' && *(BYTE*)p2 != 147 && *p2 != 0 )
+ p2++; // Ende d. Paras suchen
+ }else{ // keine Anfuehrungszeichen
+ p2 = p; // ab hier nach Ende suchen
+ while( *p2 != ' ' && *p2 != 0 ){ // Ende d. Paras suchen
+ if( *p2 == '\\' ){
+ if( *(p2 + 1) == '\\' )
+ p2 += 2; // Doppel-Backslash -> OK
+ else
+ break; // einfach-Backslash -> Ende
+ }else{
+ p2++; // kein Backslash -> OK
+ }
+ }
+ }
+ *p2 = 0; // p ist jetzt String auf Para
+ if( ppNext )
+ *ppNext = p2 + 1;
+ return p;
+}
+
+// FindNextPara2 funktioniert wie FindNextPara, jedoch wird beim
+// Weglassen von Anfuehrungszeichen bis zum Backslash gesucht
+// und nicht nur bis zum Space. Wird fuer Macro-AnzeigeTexte benutzt.
+static char* FindNextPara2( char* pStr, char** ppNext = 0 )
+{
+ if( ppNext )
+ *ppNext = 0; // Default fuer nicht gefunden
+ // #64447#
+ char* p = pStr; // Anfang
+ char* p2; // Ende
+
+ while( *p == ' ' ) // Spaces vor Para ueberlesen
+ p++;
+ if( !*p )
+ return 0;
+ if( *p == '"' || *(BYTE*)p == 132 ){ // Anfuehrungszeichen vor Para
+ p++; // Anfuehrungszeichen ueberlesen
+ p2 = p; // ab hier nach Ende suchen
+ while( *p2 != '"' && *(BYTE*)p2 != 147 && *p2 != 0 )
+ p2++; // Ende d. Paras suchen
+ }else{ // keine Anfuehrungszeichen
+ p2 = p; // ab hier nach Ende suchen
+ while( *p2 != 0 && *p2 != '\\' )
+ p2++; // Ende d. Paras suchen
+ }
+ *p2 = 0; // p ist jetzt String auf Para
+ if( ppNext )
+ *ppNext = p2 + 1;
+ return p;
+}
+
+// Find1stPara sucht 1. Parameter und setzt
+// eine 0 hinter sein Ende ( im Original-String )!
+// Dabei wird das 2. Wort des Strings gesucht. Bei Anfuehrungszeichen
+// ( normal oder typographisch ) wird der ganze String genommen.
+// Escape-Chars ( Backslash ) werden nicht beachtet.
+// Rueckgabe: wenn ppNext != 0 dann Suchbeginn fuer naechsten Parameter
+// Return 0 fuer nicht gefunden oder Anfang des Paramters
+static char* Find1stPara( char* pStr, char** ppNext = 0 )
+{
+ // Anfang
+ char* p = pStr;
+
+ while( *p == ' ' ) // evtl. Spaces vor Feldtyp ueberlesen
+ p++;
+ while( *p != ' ' && *p != 0 // FeldTyp ueberlesen
+ && *p != '"' && *(BYTE*)p != 132 )
+
+ p++;
+
+ // Ende
+ char* p2 = pStr;
+
+ while( *p == ' ' ) // Spaces vor Para ueberlesen
+ p++;
+ if( !*p )
+ return 0;
+ if( *p == '"' || *(BYTE*)p == 132 ){ // Anfuehrungszeichen vor Para
+ p++; // Anfuehrungszeichen ueberlesen
+ p2 = p; // ab hier nach Ende suchen
+ while( *p2 != '"' && *(BYTE*)p2 != 147 && *p2 != 0 )
+ p2++; // Ende d. Paras suchen
+ }else{ // keine Anfuehrungszeichen
+ p2 = p; // ab hier nach Ende suchen
+ while( *p2 != ' ' && *p2 != 0 )
+ p2++; // Ende d. Paras suchen
+ }
+ *p2 = 0; // p ist jetzt String auf Para
+ if( ppNext )
+ *ppNext = p2 + 1;
+ return p;
+}
+*/
+
+// FindParaStart() finds 1st Parameter that follows '\' and cToken
+// and returns start of this parameter or STRING_NOT_FOUND.
+xub_StrLen FindParaStart( const String& rStr, sal_Unicode cToken, sal_Unicode cToken2 )
+{
+ BOOL bStr = FALSE; // innerhalb String ignorieren
+
+ for( xub_StrLen nBuf=0; nBuf+1 < rStr.Len(); nBuf++ )
+ {
+ if( rStr.GetChar( nBuf ) == '"' )
+ bStr = !bStr;
+
+ if( !bStr
+ && rStr.GetChar( nBuf ) == '\\'
+ && ( rStr.GetChar( nBuf + 1 ) == cToken
+ || rStr.GetChar( nBuf + 1 ) == cToken2 ) )
+ {
+ nBuf += 2;
+ // skip spaces between cToken and it's parameters
+ while( nBuf < rStr.Len()
+ && rStr.GetChar( nBuf ) == ' ' )
+ nBuf++;
+ return nBuf < rStr.Len() ? nBuf : STRING_NOTFOUND; // return start of parameters
+ }
+ }
+ return STRING_NOTFOUND;
+}
+
+// FindPara() findet den ersten Parameter mit '\' und cToken. Es wird
+// ein neuer String allokiert ( der vom Aufrufer deallokiert werden muss )
+// und alles, was zum Parameter gehoert, wird in ihm zurueckgeliefert.
+String FindPara( const String& rStr, sal_Unicode cToken, sal_Unicode cToken2 )
+{
+ xub_StrLen n2; // Ende
+ xub_StrLen n = FindParaStart( rStr, cToken, cToken2 ); // Anfang
+ if( STRING_NOTFOUND == n )
+ return aEmptyStr;
+
+ if( rStr.GetChar( n ) == '"'
+ || rStr.GetChar( n ) == 132 )
+ { // Anfuehrungszeichen vor Para
+ n++; // Anfuehrungszeichen ueberlesen
+ n2 = n; // ab hier nach Ende suchen
+ while( n2 < rStr.Len()
+ && rStr.GetChar( n2 ) != 147
+ && rStr.GetChar( n2 ) != '"' )
+ n2++; // Ende d. Paras suchen
+ }
+ else
+ { // keine Anfuehrungszeichen
+ n2 = n; // ab hier nach Ende suchen
+ while( n2 < rStr.Len()
+ && rStr.GetChar( n2 ) != ' ' )
+ n2++; // Ende d. Paras suchen
+ }
+ return rStr.Copy( n, n2-n );
+}
+
+
+static SvxExtNumType GetNumTypeFromName( const String& rStr, BOOL bAllowPageDesc = FALSE )
+{
+ SvxExtNumType eTyp = bAllowPageDesc ? SVX_NUM_PAGEDESC : SVX_NUM_ARABIC;
+ if( rStr.EqualsIgnoreCaseAscii( "Arabi", 0, 5 ) ) // Arabisch, Arabic
+ eTyp = SVX_NUM_ARABIC;
+ else if( rStr.EqualsIgnoreCaseAscii( "misch", 2, 5 ) ) // r"omisch
+ eTyp = SVX_NUM_ROMAN_LOWER;
+ else if( rStr.EqualsIgnoreCaseAscii( "MISCH", 2, 5 ) ) // R"OMISCH
+ eTyp = SVX_NUM_ROMAN_UPPER;
+ else if( rStr.EqualsIgnoreCaseAscii( "alphabeti", 0, 9 ) )// alphabetisch, alphabetic
+ eTyp = ( rStr.GetChar( 0 ) == 'A' )
+ ? SVX_NUM_CHARS_UPPER_LETTER_N
+ : SVX_NUM_CHARS_LOWER_LETTER_N;
+ else if( rStr.EqualsIgnoreCaseAscii( "roman", 0, 5 ) ) // us
+ eTyp = ( rStr.GetChar( 0 ) == 'R' )
+ ? SVX_NUM_ROMAN_UPPER
+ : SVX_NUM_ROMAN_LOWER;
+ return eTyp;
+}
+
+
+static SvxExtNumType GetNumberPara( String& rStr, BOOL bAllowPageDesc = FALSE )
+{
+ String s( FindPara( rStr, '*', '*' ) ); // Ziffernart
+ SvxExtNumType aType = GetNumTypeFromName( s, bAllowPageDesc );
+ return aType;
+}
+
+
+ULONG MSDateTimeFormatToSwFormat( String& rParams, SwDoc& rDoc, USHORT nLang )
+{
+ // get Doc Numberformatter
+ SvNumberFormatter* pFormatter = rDoc.GetNumberFormatter();
+
+ // tell the Formatter about the new entry
+ UINT16 nCheckPos = 0;
+ INT16 nType = NUMBERFORMAT_DEFINED;
+ ULONG nKey = 0;
+
+// if( !
+ pFormatter->PutandConvertEntry( rParams, nCheckPos, nType, nKey,
+ nLang, LANGUAGE_SYSTEM )
+;//)
+// nKey = 0;
+
+ return nKey;
+}
+
+static short GetTimeDatePara( SwDoc& rDoc, String& rStr, ULONG& rFormat )
+{
+ String aParams( FindPara( rStr, '@', '@' ) );// Date/Time
+ if( 0 == aParams.Len() )
+ { // No Date / Time
+ rFormat = NF_DATE_SYS_NNNNDMMMMYYYY;
+ return NUMBERFORMAT_DATE;
+ }
+
+ const SvxLanguageItem& rLang = (SvxLanguageItem&)(rDoc.GetAttrPool().
+ GetDefaultItem( RES_CHRATR_LANGUAGE ));
+
+ ULONG nNumFmtIdx = MSDateTimeFormatToSwFormat( aParams, rDoc,
+ rLang.GetValue() );
+
+ short nNumFmtType = NUMBERFORMAT_UNDEFINED;
+ if( nNumFmtIdx )
+ {
+ SvNumberFormatter* pFormatter = rDoc.GetNumberFormatter();
+ nNumFmtType = pFormatter->GetType( nNumFmtIdx );
+ }
+ rFormat = nNumFmtIdx;
+
+ return nNumFmtType;
+
+}
+
+
+/*
+ Class ''WW8FldParaGuess'' removed as obsolete. (khz, 05/15/2000)
+
+ We are using class ''_ReadFieldParams'' instead.
+
+//-----------------------------------------------------------------------
+// class WW8FldParaGuess
+// Erraten von Parametern, auch bei weggelassenen oder typographischen
+// Anfuehrungszeichen. Es wird versucht, dem WW-Interpreter in allen
+// zweifelhafen Faellen moeglichst nahe zu kommen....
+//-----------------------------------------------------------------------
+
+// class WW8FldParaGuess uebernimmt die Feld-Parametererkennung,
+// z.Zt. nur fuer INHALT- und XE-PseudoFelder und fuer TOX-Felder.
+// Der Default-Parameter ( ohne "\" ) wird mit, ohne und mit typographischen
+// Anfuehrungszeichen erkannt. Andere Parameter genauso.
+// Dabei ist die Toleranz der Erkennung ( Falsche oder teilweise
+// Anfuehrungszeichen, Switches vorne oder hinten, ... ) dem WW-Interpreter
+// so weit wie moeglich angepasst.
+
+class WW8FldParaGuess{
+ unsigned char* pFld; // FeldCode
+ unsigned char* pEnd; // Ende FeldCode
+ unsigned char* pStdPara; // Pointer in pFld auf Standard-Parameter
+ unsigned char **ppSwitch; // Array von Zeigern in pFld auf Switch-Inhalte
+ BYTE nSwitches; // Anzahl der zu erkennenden Switches
+ BOOL bOk;
+ BOOL bVanish;
+
+ void InitSwitches( const char* pSwitchPara );
+
+public:
+ //WW8FldParaGuess( SvStream& rStrm, const char* pSwitchPara, WW8_FC fcMin );
+ WW8FldParaGuess( unsigned char* pCode, const char* pSwitchPara );
+ ~WW8FldParaGuess();
+ BOOL Ok() const { return bOk; };
+ const unsigned char* GetStdPara() const { return ( bOk ) ? pStdPara : 0; };
+ const unsigned char* GetSwitch( BYTE nIdx ) const
+ { return ( nIdx < nSwitches ) ? ppSwitch[nIdx] : 0; };
+ const BOOL GetSwitchRange( BYTE nIdx, USHORT* pnStart, USHORT* pnEnd )
+ const;
+};
+
+// WWIsQuote( c ) : ist c ein normales oder typographisches Anfuehrungszeichen ?
+inline static BOOL WWIsQuote( char c )
+{
+ return c == '"' || (BYTE)c == 132 || (BYTE)c == 147;
+}
+
+// WWIsQuoteEnd( c ) : ist c ein normales oder typographisches Anfuehrungszeichen
+// oder eine \0 ?
+inline static BOOL WWIsQuoteEnd( char c )
+{
+ return c == '"' || (BYTE)c == 132 || (BYTE)c == 147 || c == 0;
+}
+
+// WWIsNoQuoteEnd( c ) : ist c ein Space oder ein normales oder typographisches
+// Anfuehrungszeichen oder eine \0 ?
+inline static BOOL WWIsNoQuoteEnd( char c )
+{
+ return c == ' ' || c == '"' || (BYTE)c == 132 || (BYTE)c == 147 || c == 0;
+}
+
+void WW8FldParaGuess::InitSwitches( const char* pSwitchPara )
+{
+ pStdPara = 0;
+ ppSwitch = 0;
+
+ nSwitches = ( pSwitchPara ) ? strlen( pSwitchPara ) : 0;
+ if( nSwitches ){
+ ppSwitch = new unsigned char*[nSwitches];
+ memset( ppSwitch, 0, sizeof( unsigned char* ) * nSwitches );
+ }
+#ifdef DEBUG
+ unsigned char* (*ppSwitchD)[10]
+ = (unsigned char*(*)[10])ppSwitch; // zum Ansehen im Debugger
+ typedef unsigned char* WWCharPtr;
+ typedef WWCharPtr WW10CharPtr[10];
+ typedef WW10CharPtr* WWp10CharPtr;
+ WWp10CharPtr ppSD = (WWp10CharPtr)ppSwitch;
+#endif
+
+ unsigned char* p;
+ for( p = pFld; p < pEnd; p++ ){
+ while( *p == ' ' ) // Spaces ueberlesen
+ p++;
+ BOOL bTok = p[0] == '\\' && p[1] != '\\';
+ BYTE nSw = 0;
+ if( bTok ){
+ for( nSw = 0; nSw < nSwitches; nSw++ ){
+ unsigned char c = pSwitchPara[nSw];
+ if ( p[1] == c || p[1] == toupper(c) ) // keine Umlaute noetig
+ break; // OK, gueltiges Token
+ }
+ bTok = nSw < nSwitches; // doch kein gueltiges Token ?
+ }
+ if( bTok ){ // Token isolieren
+ unsigned char* p2 = p + 2;
+ while( *p2 == ' ' ) // Spaces vor Parameter ueberlesen
+ p2++;
+ if( WWIsQuote( *p2 ) ){ // in " eingeschlossen
+ unsigned char *p3 = p2 + 1; // Anfang gefunden
+ if( nSwitches )
+ ppSwitch[nSw] = p3; // bei mehreren gleichen gilt der letzte
+ while( !WWIsQuoteEnd( *p3 ) )// Ende suchen
+ p3++;
+ *p3 = 0; // Ende markieren
+ p = p3; // ab hier weitersuchen
+ }
+ else
+ { // nicht gequotet
+ unsigned char *p3 = p2;
+ if( nSwitches )
+ ppSwitch[nSw] = p2; // Anfang gefunden ( letzter gilt )
+ while( (p3 < pEnd) && !WWIsNoQuoteEnd( *p3 ) ) // Ende suchen
+ p3++;
+ *p3 = 0; // Ende markieren
+ p = p3; // ab hier weitersuchen
+ }
+ }else if( !pStdPara ){ // nur der erste kommt durch
+ unsigned char* p2;
+ if( WWIsQuote( *p ) ){ // in " eingeschlossen
+ p2 = pStdPara = p + 1; // Anfang gefunden
+ while( !WWIsQuoteEnd( *p2 ) )// Ende suchen
+ p2++;
+ }
+ else
+ { // nicht gequotet
+ p2 = pStdPara = p;
+ while( (p2 < pEnd) && !WWIsNoQuoteEnd( *p2 ) ) // Ende suchen
+ p2++;
+ }
+ *p2 = 0; // Ende markieren
+ p = p2; // ab hier weitersuchen
+ }
+ }
+}
+
+
+// ctor WW8FldParaGuess, Erklaerung siehe anderer ctor.
+WW8FldParaGuess::WW8FldParaGuess( unsigned char* pCode,
+ const char* pSwitchPara )
+:pStdPara( 0 ), ppSwitch( 0 ), nSwitches( 0 ), bOk( TRUE ), bVanish( FALSE )
+{
+ pFld = pEnd = pCode;
+ // search field code end
+ while( *pEnd && (0x014 != *pEnd) && (0x015 != *pEnd) )
+ ++pEnd;
+ InitSwitches( pSwitchPara );
+}
+
+WW8FldParaGuess::~WW8FldParaGuess()
+{
+ if( bVanish ) // ja -> ctor hat alloziert
+ delete[] ( pFld );
+ delete[] ( ppSwitch );
+}
+
+// GetSwitchRange() interpretiert Parameter, die zwingend ein '-' zwischen
+// 2 USHORTs haben, z.B. VERZEICHNIS \o "1-3"
+const BOOL WW8FldParaGuess::GetSwitchRange( BYTE nIdx, USHORT* pnStart,
+USHORT* pnEnd ) const
+{
+ if( nIdx >= nSwitches )
+ return FALSE;
+ unsigned char* p = ppSwitch[nIdx];
+ if( !p )
+ return FALSE;
+ unsigned char* p1 = (unsigned char*)strchr( (char*)p, '-' );
+ if( !p1 )
+ return FALSE;
+ *p1++ = 0;
+ int nVal;
+ sscanf( (char*)p, "%d", &nVal );
+ *pnStart = (USHORT)nVal;
+ sscanf( (char*)p1, "%d", &nVal );
+ *pnEnd = (USHORT)nVal;
+ return TRUE;
+}
+*/
+
+//-----------------------------------------
+// Felder
+//-----------------------------------------
+// Am Ende des Einlesens entsprechende Felder updaten ( z.Zt. die Referenzen )
+void SwWW8ImplReader::UpdateFields()
+{
+// rDoc.GetSysFldType( RES_GETREFFLD )->UpdateFlds(); // Referenzen
+// rDoc.UpdateFlds(); // SetExp-Fields
+// rDoc.UpdateFlds(); // alles ???
+// rDoc.UpdateExpFlds(); // SetExp-Fields
+ rDoc.SetUpdateExpFldStat(); // JP: neu fuer alles wichtige
+ rDoc.SetInitDBFields( TRUE ); // Datenbank-Felder auch
+}
+
+typedef eF_ResT (SwWW8ImplReader:: *FNReadField)( WW8FieldDesc*, String& );
+static FNReadField aWW8FieldTab[93] = {
+0,
+0,
+0,
+&SwWW8ImplReader::Read_F_Ref, // 3
+0,
+0,
+&SwWW8ImplReader::Read_F_Set, // 6
+0,
+&SwWW8ImplReader::Read_F_Tox, // 8
+0,
+0,
+0,
+&SwWW8ImplReader::Read_F_Seq, // 12
+&SwWW8ImplReader::Read_F_Tox, // 13
+&SwWW8ImplReader::Read_F_DocInfo, // 14
+&SwWW8ImplReader::Read_F_DocInfo, // 15
+&SwWW8ImplReader::Read_F_DocInfo, // 16
+&SwWW8ImplReader::Read_F_Author, // 17
+&SwWW8ImplReader::Read_F_DocInfo, // 18
+&SwWW8ImplReader::Read_F_DocInfo, // 19
+&SwWW8ImplReader::Read_F_DocInfo, // 20
+&SwWW8ImplReader::Read_F_DocInfo, // 21
+&SwWW8ImplReader::Read_F_DocInfo, // 22
+&SwWW8ImplReader::Read_F_DocInfo, // 23
+&SwWW8ImplReader::Read_F_DocInfo, // 24
+&SwWW8ImplReader::Read_F_DocInfo, // 25
+&SwWW8ImplReader::Read_F_Anz, // 26
+&SwWW8ImplReader::Read_F_Anz, // 27
+&SwWW8ImplReader::Read_F_Anz, // 28
+&SwWW8ImplReader::Read_F_FileName, // 29
+&SwWW8ImplReader::Read_F_TemplName, // 30
+&SwWW8ImplReader::Read_F_DateTime, // 31
+&SwWW8ImplReader::Read_F_DateTime, // 32
+&SwWW8ImplReader::Read_F_CurPage, // 33
+0,
+0,
+0,
+&SwWW8ImplReader::Read_F_PgRef, // 37
+&SwWW8ImplReader::Read_F_InputVar, // 38
+&SwWW8ImplReader::Read_F_Input, // 39
+0,
+&SwWW8ImplReader::Read_F_DBNext, // 41
+0,
+0,
+&SwWW8ImplReader::Read_F_DBNum, // 44
+0,
+0,
+0,
+0,
+0,
+0,
+&SwWW8ImplReader::Read_F_Macro, // 51
+&SwWW8ImplReader::Read_F_ANumber, // 52
+&SwWW8ImplReader::Read_F_ANumber, // 53
+&SwWW8ImplReader::Read_F_ANumber, // 54
+0,
+
+
+0, // 56: VERKNUePFUNG // fehlt noch !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+&SwWW8ImplReader::Read_F_Symbol, // 57
+&SwWW8ImplReader::Read_F_Embedd, // 58
+&SwWW8ImplReader::Read_F_DBField, // 59
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+&SwWW8ImplReader::Read_F_IncludePicture, // 67
+&SwWW8ImplReader::Read_F_IncludeText, // 68
+0,
+&SwWW8ImplReader::Read_F_FormTextBox, // 70
+&SwWW8ImplReader::Read_F_FormCheckBox, // 71
+&SwWW8ImplReader::Read_F_NoteReference, // 72
+0, /*&SwWW8ImplReader::Read_F_Tox*/
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+&SwWW8ImplReader::Read_F_FormListBox, // 83
+0, // 84
+&SwWW8ImplReader::Read_F_DocInfo, // 85
+0, // 86
+&SwWW8ImplReader::Read_F_OCX, // 87
+&SwWW8ImplReader::Read_F_Hyperlink, // 88
+0, // 89
+0, // 90
+0, // 91
+0 // 92 - Dummy leer Methode
+ }; // 92 == alle ueber 91
+
+
+
+// Read_Field liest ein Feld ein oder, wenn es nicht gelesen werden kann,
+// wird 0 zurueckgegeben, so dass das Feld vom Aufrufer textuell gelesen wird.
+// Returnwert: Gesamtlaenge des Feldes ( zum UEberlesen )
+long SwWW8ImplReader::Read_Field( WW8PLCFManResult* pRes, BOOL )
+{
+ ASSERT( ( sizeof( aWW8FieldTab ) / sizeof( *aWW8FieldTab ) == 93 ),
+ "FeldFunc-Tabelle stimmt nicht" );
+ if( nIniFlags & WW8FL_NO_FLD )
+ return 0;
+
+ WW8FieldDesc aF;
+
+ WW8PLCFx_FLD* pF = pPlcxMan->GetFld();
+ ASSERT( pF, "WW8PLCFx_FLD - Pointer nicht da" );
+ if( !pF ) return 0;
+
+ BOOL bOk = pF->GetPara( pRes->nCp2OrIdx, aF );
+
+ USHORT n = ( aF.nId <= 91 ) ? aF.nId : 92; // alle > 91 werden 92
+ USHORT nI = n / 32; // # des UINT32
+ ULONG nMask = 1 << ( n % 32 ); // Maske fuer Bits
+
+ if( nFieldTagAlways[nI] & nMask ) // Flag: Tag it
+ return Read_F_Tag( &aF ); // Resultat nicht als Text
+
+ if( !bOk || !aF.nId ) // Feld kaputt
+ return aF.nLen; // -> ignorieren
+
+ if( aF.nId > 91
+// || ( aF.nOpt & 0x40 ) // 0x40-Result Nest -> OK
+ ) // WW: Nested Field
+ if( nFieldTagBad[nI] & nMask ) // Flag: Tag it when bad
+ return Read_F_Tag( &aF ); // Resultat nicht als Text
+ else
+ return aF.nLen;
+
+ if( aWW8FieldTab[aF.nId] == 0 // keine Routine vorhanden
+ || aF.bCodeNest )
+ {
+ if( nFieldTagBad[nI] & nMask ) // Flag: Tag it when bad
+ return Read_F_Tag( &aF ); // Resultat nicht als Text
+ // Lese nur Resultat
+ if( aF.bResNest )
+ return aF.nLen; // Result nested -> nicht brauchbar
+
+ return aF.nLen - aF.nLRes - 1; // so viele ueberlesen, das Resultfeld
+ // wird wie Haupttext eingelesen
+
+ }
+ else
+ { // Lies Feld
+ long nOldPos = pStrm->Tell();
+ String aStr;
+ aF.nLCode = pSBase->WW8ReadString( *pStrm, aStr, pPlcxMan->GetCpOfs()+
+ aF.nSCode, aF.nLCode, eTextCharSet );
+
+ eF_ResT eRes = (this->*aWW8FieldTab[aF.nId])( &aF, aStr );
+ pStrm->Seek( nOldPos );
+
+ switch ( eRes )
+ {
+ case F_OK:
+ return aF.nLen; // alles OK
+
+ case F_TEXT:
+ return aF.nLen - aF.nLRes - 2; // so viele ueberlesen,
+ // das Resultfeld wird wie Haupttext eingelesen
+ //JP 15.07.99: attributes can start at char 0x14
+ // so skip one char more back == "-2"
+
+ case F_TAGTXT:
+ if( ( nFieldTagBad[nI] & nMask ) ) // Flag: Tag bad
+ return Read_F_Tag( &aF ); // Taggen
+ return aF.nLen - aF.nLRes - 2; // oder Text-Resultat
+
+ case F_TAGIGN:
+ if( ( nFieldTagBad[nI] & nMask ) ) // Flag: Tag bad
+ return Read_F_Tag( &aF ); // Taggen
+ return aF.nLen; // oder ignorieren
+
+ case F_READ_FSPA:
+ return aF.nLen - aF.nLRes - 2; // auf Char 1 positionieren
+
+ default: return aF.nLen; // ignorieren
+ }
+ }
+/*
+ if( !bOk || !aF.nId || aF.nId > 84
+ || ( aF.nOpt & 0x40 ) ) // WW sagt: Nested Field
+ return aF.nLen;
+
+
+ if( ( ( aF.nOpt & 0x08 ) ) // User Edited
+ || aF.nId > 84 // unbekannte Id
+ || aWW8FieldTab[aF.nId] == 0 // keine Routine vorhanden
+ || aF.bCodeNest ){
+
+
+ // Lese nur Resultat
+ if( aF.bResNest )
+ return aF.nLen; // Result nested -> nicht brauchbar
+ else
+ return aF.nLen - aF.nLRes - 1; // so viele ueberlesen, das Resultfeld
+ // wird wie Haupttext eingelesen
+
+ }else{ // Lese Feld
+ long nOldPos = pStrm->Tell();
+ pStrm->Seek( WW8Cp2Fc( pPlcxMan->GetCpOfs() + aF.nSCode,
+ pWwFib->fcMin ) );
+ char* p = new char[ aF.nLCode + 10 ];
+ pStrm->Read( p, aF.nLCode );
+ for( long i=aF.nLCode; i < aF.nLCode + 10; i++ )
+ p[i] = 0; // Nullen dahinter
+ (this->*aWW8FieldTab[aF.nId])( &aF, p );
+ delete[] p;
+ pStrm->Seek( nOldPos );
+ }
+ return aF.nLen;
+*/
+}
+
+//-----------------------------------------
+// Felder Taggen
+//-----------------------------------------
+
+// QuoteChar ist ohne Laengenschutz
+
+void SwWW8ImplReader::QuoteChar( String& rStr, const sal_Unicode c, BOOL bAllowCr )
+{
+ if ( c < 0x0020 || c == 0x00fe || c == 0x00ff ) // < 32, >0xfe
+ {
+ switch( c )
+ {
+ case 0x0b:
+ case 0x0c:
+ case 0x0d: if( bAllowCr )
+ {
+ rStr += '\n';
+ break;
+ }
+ // no break
+ default:{
+ // als Hex-Zahl mit \x davor
+ String sTmp( String::CreateFromInt32( c, 16 ) );
+ if( 1 == sTmp.Len() )
+ sTmp.Insert( '0', 0 );
+ rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\\x" ) );
+ rStr += sTmp;
+ }
+ }
+ }
+ else
+ rStr += c; // normaler Text
+}
+
+// QuoteString() wandelt CRs abhaengig von nFieldIniFlags in '\n' oder "\0x0d"
+void SwWW8ImplReader::QuoteString( String& rStr, const String& rOrg )
+{
+ BOOL bAllowCr = SwFltGetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
+ xub_StrLen nMax = rOrg.Len();
+ xub_StrLen i = 0;
+ while( nMax > i && ( rStr.Len() < MAX_FIELDLEN - 4 ) )
+ {
+ QuoteChar( rStr, rOrg.GetChar( i ), bAllowCr );
+ i++;
+ }
+}
+
+// MakeTagString() gibt als Returnwert die Position des ersten
+// CR / Zeilenende / Seitenumbruch in pText und wandelt auch nur bis dort
+// Wenn keins dieser Sonderzeichen enthalten ist, wird 0 zurueckgeliefert.
+void SwWW8ImplReader::MakeTagString( String& rStr, const String& rOrg )
+{
+ BOOL bAllowCr = SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT )
+ || SwFltGetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
+
+
+ xub_StrLen nMax = rOrg.Len();
+ xub_StrLen i = 0;
+ while( nMax > i && ( rStr.Len() < MAX_FIELDLEN - 4 ) )
+ {
+ sal_Unicode c = rOrg.GetChar( i );
+ switch( c )
+ {
+ case 132: // Typographische Anfuehrungszeichen
+ case 148: // gegen normale tauschen
+ case 147: rStr += '"'; break;
+ case 19: rStr += '{'; break; // 19..21 zu {|}
+ case 20: rStr += '|'; break;
+ case 21: rStr += '}'; break;
+ case '\\': // \{|} per \ Taggen
+ case '{':
+ case '|':
+ case '}': rStr += '\\'; rStr += c; break;
+ default: SwWW8ImplReader::QuoteChar( rStr, c, bAllowCr ); break;
+ }
+ i++;
+ }
+}
+
+void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText )
+{
+ String aName( WW8_ASCII2STR( "WwFieldTag" ) );
+ if( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID ) ) // Nummer?
+ aName += String::CreateFromInt32( nId ); // ausgeben ?
+
+ if( SwFltGetFlag(nFieldFlags, SwFltControlStack::TAGS_IN_TEXT))
+ {
+ aName += rTagText; // als Txt taggen
+ rDoc.Insert( *pPaM, aName, FALSE );
+ }
+ else
+ { // normal tagggen
+
+ SwFieldType* pFT = rDoc.InsertFldType(
+ SwSetExpFieldType( &rDoc, aName, GSE_STRING ) );
+ SwSetExpField aFld( (SwSetExpFieldType*)pFT, rTagText ); // SUB_INVISIBLE
+ USHORT nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : SUB_INVISIBLE;
+ aFld.SetSubType(nSubType);
+
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ }
+}
+
+long SwWW8ImplReader::Read_F_Tag( WW8FieldDesc* pF )
+{
+ long nOldPos = pStrm->Tell();
+
+ WW8_CP nStart = pF->nSCode - 1; // mit 0x19 am Anfang
+ long nL = pF->nLen; // Gesamtlaenge mit Resultat u. Nest
+ if( nL > MAX_FIELDLEN )
+ nL = MAX_FIELDLEN; // MaxLaenge, durch Quoten
+ // max. 4* so gross
+ String sFTxt;
+ nL = pSBase->WW8ReadString( *pStrm, sFTxt,
+ pPlcxMan->GetCpOfs() + nStart, nL, eStructCharSet);
+
+
+ String aTagText;
+ MakeTagString( aTagText, sFTxt );
+ InsertTagField( pF->nId, aTagText );
+
+ pStrm->Seek( nOldPos );
+ return pF->nLen;
+}
+
+
+//-----------------------------------------
+// normale Felder
+//-----------------------------------------
+
+// Read_F_Nul() dient dazu, Felder, die ein belegtes ResultatFeld haben, dieses
+// aber trotzdem keinen Text darstellt, sondern z.B. Variablen-Werte, komplett
+// zu ignorieren.
+// Noetig z.B. fuer Feld 6 "Set" == "Bestimmen".
+eF_ResT SwWW8ImplReader::Read_F_Nul( WW8FieldDesc*, String& rStr )
+{
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, String& rStr )
+{
+ String aDef;
+ String aQ;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aQ.Len() )
+ aQ = aReadParam.GetResult();
+ break;
+ case 'd':
+ case 'D':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ aDef = aReadParam.GetResult();
+ }
+ break;
+ }
+ }
+ if( !aDef.Len() )
+ aDef = GetFieldResult( pF );
+
+ SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ),
+ aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders )
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+
+ return F_OK;
+}
+
+// GetFieldResult alloziert einen String und liest das Feld-Resultat ein
+String SwWW8ImplReader::GetFieldResult( WW8FieldDesc* pF )
+{
+ long nOldPos = pStrm->Tell();
+
+ WW8_CP nStart = pF->nSRes; // Start Resultat
+ long nL = pF->nLRes; // Laenge Resultat
+ if( !nL )
+ return aEmptyStr; // kein Resultat
+
+ if( nL > MAX_FIELDLEN )
+ nL = MAX_FIELDLEN; // MaxLaenge, durch Quoten
+ // max. 4* so gross
+
+ String sRes;
+ nL = pSBase->WW8ReadString( *pStrm, sRes, pPlcxMan->GetCpOfs() + nStart,
+ nL, eStructCharSet );
+
+ pStrm->Seek( nOldPos );
+ return sRes;
+}
+
+// "FRAGE"
+eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr )
+{
+ String aVar;
+ String aQ;
+ String aDef;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aVar.Len() )
+ aVar = aReadParam.GetResult();
+ else if( !aQ.Len() )
+ aQ = aReadParam.GetResult();
+ break;
+ case 'd':
+ case 'D':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ aDef = aReadParam.GetResult();
+ }
+ break;
+ }
+ }
+ if( !aVar.Len() )
+ return F_TAGIGN; // macht ohne Textmarke keinen Sinn
+ if( !aDef.Len() )
+ aDef = GetFieldResult( pF );
+
+
+
+ SwFieldType* pFT = rDoc.InsertFldType( SwSetExpFieldType( &rDoc, aVar, GSE_STRING ) );
+ SwSetExpField aFld( (SwSetExpFieldType*)pFT, aVar );
+ aFld.SetSubType(SUB_INVISIBLE);
+ aFld.SetInputFlag( TRUE );
+ aFld.SetPromptText( aQ );
+ aFld.SetPar2( aDef );
+ pPlcxMan->GetBook()->SetStatus( pF->nSCode, pF->nSCode + pF->nLen,
+ aVar, BOOK_ONLY_REF );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+
+
+ return F_OK;
+}
+
+// "AUTONR"
+eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, String& rStr )
+{
+ if( !pNumFldType ){ // 1. Mal
+ SwSetExpFieldType aT( &rDoc, WW8_ASCII2STR("AutoNr"), GSE_SEQ );
+ pNumFldType = rDoc.InsertFldType( aT );
+ }
+ SwSetExpField aFld( (SwSetExpFieldType*)pNumFldType, aEmptyStr,
+ GetNumberPara( rStr ) );
+ aFld.SetValue( ++nFldNum );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+// "SEQ"
+eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, String& rStr )
+{
+ String aSequenceName;
+ String aBook;
+ BOOL bHidden = FALSE;
+ BOOL bFormat = FALSE;
+ BOOL bShowLast = FALSE;
+ BOOL bCountOn = TRUE;
+ String sStart, sLevel;
+ SvxExtNumType eNumFormat = SVX_NUM_ARABIC;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aSequenceName.Len() )
+ aSequenceName = aReadParam.GetResult();
+ else if( !aBook.Len() )
+ aBook = aReadParam.GetResult();
+ break;
+
+ case 'h':
+ if( !bFormat )
+ bHidden = TRUE; // Hidden-Flag aktivieren
+ break;
+
+ case '*':
+ bFormat = TRUE; // Format-Flag aktivieren
+ bHidden = FALSE; // Hidden-Flag deaktivieren
+ nRet = aReadParam.SkipToNextToken();
+ if( -2 == nRet )
+ eNumFormat = GetNumTypeFromName( aReadParam.GetResult() );
+ break;
+
+ case 'r':
+ bShowLast = FALSE; // Zaehler neu setzen
+ bCountOn = FALSE;
+ nRet = aReadParam.SkipToNextToken();
+ if( -2 == nRet )
+ sStart = aReadParam.GetResult();
+ break;
+
+ case 'c':
+ bShowLast = TRUE; // zuletzt verwendete Nummer anzeigen
+ bCountOn = FALSE;
+ break;
+
+ case 'n':
+ bCountOn = TRUE; // Nummer um eins erhoehen (default)
+ bShowLast = FALSE;
+ break;
+
+ case 's': // Outline Level
+ if( -2 == aReadParam.SkipToNextToken() )
+ sLevel = aReadParam.GetResult();
+ break;
+ }
+ }
+ if( !aSequenceName.Len()
+ || !aBook.Len() )
+ return F_TAGIGN;
+
+ SwSetExpFieldType* pFT = (SwSetExpFieldType*)rDoc.InsertFldType(
+ SwSetExpFieldType( &rDoc, aSequenceName, GSE_SEQ ) );
+ SwSetExpField aFld( pFT, aEmptyStr, eNumFormat );
+
+ if( sStart.Len() )
+ aFld.SetFormula( ( aSequenceName += '=' ) += sStart );
+
+ if( sLevel.Len() )
+ {
+ USHORT nLvl = (USHORT)sLevel.ToInt32();
+ if( nLvl )
+ {
+ if( MAXLEVEL <= --nLvl )
+ nLvl = MAXLEVEL - 1;
+ pFT->SetOutlineLvl( nLvl );
+ }
+ }
+
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+
+eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr )
+{
+ USHORT nSub;
+ USHORT nReg = DI_SUB_AUTHOR; // RegInfoFormat, DefaultFormat fuer DocInfoFelder
+ BOOL bDateTime = FALSE;
+
+ if( 85 == pF->nId )
+ {
+ /*
+ There are up to 26 fields that may be meant by 'DocumentProperty'.
+ Which of them is to be inserted here ?
+ This Problem can only be solved by implementing a name matching
+ method that compares the given Parameter String with the four
+ possible name sets (english, german, french, spanish)
+ */
+ String aStr( rStr );
+ xub_StrLen nPos1 = aStr.Search( '"' );
+ if( (STRING_NOTFOUND != nPos1) && (nPos1+1 < aStr.Len()) )
+ {
+ xub_StrLen nPos2 = aStr.SearchAndReplace( '"', '\0', nPos1+1 );
+ if( STRING_NOTFOUND != nPos2 )
+ {
+ aStr.Erase(0, nPos1+1);
+ static sal_Char __READONLY_DATA* aName10 = "\x0F"; // SW field code
+ static sal_Char __READONLY_DATA* aName11 // German
+ = "TITEL";
+ static sal_Char __READONLY_DATA* aName12 // French
+ = "TITRE";
+ static sal_Char __READONLY_DATA* aName13 // English
+ = "TITLE";
+ static sal_Char __READONLY_DATA* aName14 // Spanish
+ = "TITRO";
+ static sal_Char __READONLY_DATA* aName20 = "\x15"; // SW filed code
+ static sal_Char __READONLY_DATA* aName21 // German
+ = "ERSTELLDATUM";
+ static sal_Char __READONLY_DATA* aName22 // French
+ = "CRÉÉ";
+ static sal_Char __READONLY_DATA* aName23 // English
+ = "CREATED";
+ static sal_Char __READONLY_DATA* aName24 // Spanish
+ = "CREADO";
+ static sal_Char __READONLY_DATA* aName30 = "\x16"; // SW filed code
+ static sal_Char __READONLY_DATA* aName31 // German
+ = "ZULETZTGESPEICHERTZEIT";
+ static sal_Char __READONLY_DATA* aName32 // French
+ = "DERNIERENREGISTREMENT";
+ static sal_Char __READONLY_DATA* aName33 // English
+ = "SAVED";
+ static sal_Char __READONLY_DATA* aName34 // Spanish
+ = "MODIFICADO";
+ static sal_Char __READONLY_DATA* aName40 = "\x17"; // SW filed code
+ static sal_Char __READONLY_DATA* aName41 // German
+ = "ZULETZTGEDRUCKT";
+ static sal_Char __READONLY_DATA* aName42 // French
+ = "DERNIÈREIMPRESSION";
+ static sal_Char __READONLY_DATA* aName43 // English
+ = "LASTPRINTED";
+ static sal_Char __READONLY_DATA* aName44 // Spanish
+ = "HUPS PUPS";
+ static sal_Char __READONLY_DATA* aName50 = "\x18"; // SW filed code
+ static sal_Char __READONLY_DATA* aName51 // German
+ = "ÜBERARBEITUNGSNUMMER";
+ static sal_Char __READONLY_DATA* aName52 // French
+ = "NUMÉRODEREVISION";
+ static sal_Char __READONLY_DATA* aName53 // English
+ = "REVISIONNUMBER";
+ static sal_Char __READONLY_DATA* aName54 // Spanish
+ = "SNUBBEL BUBBEL";
+ static const USHORT nFldCnt = 5;
+
+
+
+
+ // additional fields are to be coded soon! :-)
+
+
+
+
+ static const USHORT nLangCnt = 4;
+ static const sal_Char * aNameSet_26[nFldCnt][nLangCnt+1] = {
+ {aName10, aName11, aName12, aName13, aName14},
+ {aName20, aName21, aName22, aName23, aName24},
+ {aName30, aName31, aName32, aName33, aName34},
+ {aName40, aName41, aName42, aName43, aName44},
+ {aName50, aName51, aName52, aName53, aName54}
+ };
+ BOOL bFldFound= FALSE;
+ USHORT nFIdx;
+ for(USHORT nLIdx=1; !bFldFound && (nLangCnt > nLIdx); ++nLIdx)
+ {
+ for(nFIdx = 0; !bFldFound && (nFldCnt > nFIdx); ++nFIdx)
+ {
+ if( aStr.EqualsIgnoreCaseAscii( aNameSet_26[nFIdx][nLIdx] ) )
+ {
+ bFldFound = TRUE;
+ pF->nId = aNameSet_26[nFIdx][0][0];
+ }
+ }
+ }
+ if( !bFldFound )
+ return F_TAGTXT; // Error: show field as string
+ }
+ }
+ }
+
+ switch( pF->nId )
+ {
+ case 14: nSub = DI_KEYS; /* kann alle INFO-Vars!! */ break;
+ case 15: nSub = DI_TITEL; break;
+ case 16: nSub = DI_THEMA; break;
+ case 18: nSub = DI_KEYS; break;
+ case 19: nSub = DI_COMMENT; break;
+ case 20: nSub = DI_CHANGE; nReg = DI_SUB_AUTHOR; break;
+ case 21: nSub = DI_CREATE; nReg = DI_SUB_DATE; bDateTime = TRUE; break;
+ case 23: nSub = DI_PRINT; nReg = DI_SUB_DATE; bDateTime = TRUE; break;
+ case 24: nSub = DI_DOCNO; break;
+ case 22: nSub = DI_CHANGE; nReg = DI_SUB_DATE; bDateTime = TRUE; break;
+ case 25: nSub = DI_CHANGE; nReg = DI_SUB_TIME; bDateTime = TRUE; break;
+ }
+
+ ULONG nFormat = 0;
+
+ if( bDateTime )
+ {
+ short nDT = GetTimeDatePara( rDoc, rStr, nFormat );
+ switch( nDT )
+ {
+ case NUMBERFORMAT_DATE: nReg = DI_SUB_DATE; break;
+ case NUMBERFORMAT_TIME: nReg = DI_SUB_TIME; break;
+ case NUMBERFORMAT_DATETIME: nReg = DI_SUB_DATE; break;
+ default:
+ {
+ nReg = DI_SUB_DATE;
+ }
+ }
+ }
+
+ SwDocInfoField aFld( (SwDocInfoFieldType*)
+ rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, nFormat );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, String& )
+{
+ // SH: Das SwAuthorField bezeichnet nicht den urspruenglichen
+ // Autor, sondern den aktuellen Benutzer, also besser ueber DocInfo
+ // (#56149)
+ SwDocInfoField aFld( (SwDocInfoFieldType*)
+ rDoc.GetSysFldType( RES_DOCINFOFLD ),
+ DI_CREATE|DI_SUB_AUTHOR );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, String& )
+{
+ SwTemplNameField aFld( (SwTemplNameFieldType*)
+ rDoc.GetSysFldType( RES_TEMPLNAMEFLD ), FF_NAME );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+// Sowohl das Datum- wie auch das Uhrzeit-Feld kann fuer Datum, fuer Uhrzeit
+// oder fuer beides benutzt werden.
+eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, String& rStr )
+{ // Datum/Uhrzeit - Feld
+ ULONG nFormat = 0;
+
+ short nDT = GetTimeDatePara( rDoc, rStr, nFormat );
+
+ if( NUMBERFORMAT_UNDEFINED == nDT ) // no D/T-Formatstring
+ {
+ if( 32 == pF->nId )
+ {
+ nDT = NUMBERFORMAT_TIME;
+ nFormat = rDoc.GetNumberFormatter()->GetFormatIndex(
+ NF_TIME_START, LANGUAGE_SYSTEM );
+ }
+ else
+ {
+ nDT = NUMBERFORMAT_DATE;
+ nFormat = rDoc.GetNumberFormatter()->GetFormatIndex(
+ NF_DATE_START, LANGUAGE_SYSTEM );
+ }
+ }
+
+ if( nDT & NUMBERFORMAT_DATE )
+ {
+ SwDateTimeField aFld( (SwDateTimeFieldType*)
+ rDoc.GetSysFldType( RES_DATETIMEFLD ), DATEFLD, nFormat );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ }
+ else if( nDT == NUMBERFORMAT_TIME )
+ {
+ SwDateTimeField aFld( (SwDateTimeFieldType*)
+ rDoc.GetSysFldType( RES_DATETIMEFLD ), TIMEFLD, nFormat );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ }
+
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_FileName( WW8FieldDesc*, String& )
+{
+ SwFileNameField aFld( (SwFileNameFieldType*)
+ rDoc.GetSysFldType( RES_FILENAMEFLD ) );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_Anz( WW8FieldDesc* pF, String& rStr )
+{ // SeitenZahl - Feld
+ USHORT nSub = DS_PAGE;
+ switch ( pF->nId ){
+ case 27: nSub = DS_WORD; break; // Wordzahl
+ case 28: nSub = DS_CHAR; break; // Zeichenzahl
+ }
+ SwDocStatField aFld( (SwDocStatFieldType*)
+ rDoc.GetSysFldType( RES_DOCSTATFLD ), nSub,
+ GetNumberPara( rStr ) );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr )
+{
+ // zusaetzlich mit Kapitelnummer?
+ if( bPgChpLevel )
+ {
+ SwChapterField aFld( (SwChapterFieldType*)
+ rDoc.GetSysFldType( RES_CHAPTERFLD ), CF_NUMBER );
+ aFld.SetLevel( nPgChpLevel );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+
+ static sal_Char __READONLY_DATA aDelim[] = "-.:\x97\x96";
+ BYTE nDelim = nPgChpDelim;
+ if( nDelim > 4 )
+ nDelim = 0;
+
+ sal_Unicode c = ByteString::ConvertToUnicode( aDelim[ nDelim ],
+ RTL_TEXTENCODING_MS_1252 );
+ if( '-' == c )
+ rDoc.Insert( *pPaM, CHAR_HARDHYPHEN );
+ else
+ rDoc.Insert( *pPaM, SwFmtHardBlank( c ));
+ }
+ // Seitennummer
+ SwPageNumberField aFld( (SwPageNumberFieldType*)
+ rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM,
+ GetNumberPara( rStr, TRUE ) );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr )
+{ // Symbol-Zeichensatz
+/*
+ char* p;
+ char* pQ = Find1stPara( pStr, &p ); // 1. Para ist Ascii-Wert
+ USHORT nC = String( pQ );
+ if( !nC ) // ungueltige Syntax
+ return F_TAGIGN; // -> kein 0-Zeichen in Text
+ char* pCSet = FindPara( p, 'f', 'F' ); // \f -> Zeichensatz
+ char* pSiz = FindPara( p, 's', 'S' ); // \s -> FontSize
+ if( pCSet ){ // Charset angegeben ?
+ String aName( pCSet );
+ if( eStructCharSet != eSysCharSet ) // OS2, WIN mit Mac-Doc,...
+ aName.Convert( eStructCharSet, eSysCharSet );
+ SvxFontItem aFont( FAMILY_DONTKNOW, aName, // "WingDings",
+ aEmptyStr,
+ PITCH_DONTKNOW, CHARSET_SYMBOL);
+ NewAttr( aFont ); // neuer Font
+ }
+ if( pSiz ){ // Size angegeben ?
+ ULONG nSiz = String( pSiz ); // in pt
+ SvxFontHeightItem aSz( nSiz * 20 ); // pT -> twip
+ NewAttr( aSz );
+ }
+*/
+ String aQ;
+ String aName;
+ String aSiz;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aQ.Len() )
+ aQ = aReadParam.GetResult();
+ break;
+ case 'f':
+ case 'F':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ aName = aReadParam.GetResult();
+ }
+ break;
+ case 's':
+ case 'S':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ aSiz = aReadParam.GetResult();
+ }
+ break;
+ }
+ }
+ if( !aQ.Len() )
+ return F_TAGIGN; // -> kein 0-Zeichen in Text
+
+ if( aName.Len() ) // Font Name angegeben ?
+ {
+ SvxFontItem aFont( FAMILY_DONTKNOW, aName, // "WingDings",
+ aEmptyStr,
+ PITCH_DONTKNOW, RTL_TEXTENCODING_SYMBOL );
+ NewAttr( aFont ); // neuer Font
+ }
+
+ if( aSiz.Len() ) // Size angegeben ?
+ {
+ SvxFontHeightItem aSz( aSiz.ToInt32() * 20 ); // pT -> twip
+ NewAttr( aSz );
+ }
+
+ rDoc.Insert( *pPaM, aQ.GetChar( 0 ) );
+
+ if( aSiz.Len() )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONTSIZE );
+ if( aName.Len() )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
+
+ return F_OK;
+}
+
+
+// "EINBETTEN"
+eF_ResT SwWW8ImplReader::Read_F_Embedd( WW8FieldDesc*, String& rStr )
+{
+ String sHost;
+
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ sHost = aReadParam.GetResult();
+ break;
+
+ case 's':
+ // use ObjectSize
+ break;
+ }
+ }
+
+ if( bObj && nPicLocFc )
+ nObjLocFc = nPicLocFc;
+ bEmbeddObj = TRUE;
+ return F_TEXT;
+}
+
+
+// "BESTIMMEN"
+eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr )
+{
+ String aName;
+ String aVal;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aName.Len() )
+ aName = aReadParam.GetResult();
+ else if( !aVal.Len() )
+ aVal = aReadParam.GetResult();
+ break;
+ }
+ }
+ SwFieldType* pFT = rDoc.InsertFldType(
+ SwSetExpFieldType( &rDoc, aName, GSE_STRING ) );
+ SwSetExpField aFld( (SwSetExpFieldType*)pFT, aVal );
+ aFld.SetSubType(SUB_INVISIBLE);
+ pPlcxMan->GetBook()->SetStatus( pF->nSCode, pF->nSCode + pF->nLen,
+ aName, BOOK_IGNORE );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+// "REF"
+eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
+{ // Reference - Field
+ String aBkmName;
+ BOOL bChapterNr = FALSE;
+ BOOL bObenUnten = FALSE;
+
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aBkmName.Len() ) // get name of bookmark
+ {
+ aBkmName = aReadParam.GetResult();
+ }
+ break;
+
+ case 'r':
+ bChapterNr = TRUE; // activate flag 'Chapter Number'
+ break;
+
+ case 'p':
+ bObenUnten = TRUE;
+ break;
+ case 'h':
+ break;
+ default:
+ // unimplemented switch: just do 'nix nought nothing' :-)
+ break;
+ }
+ }
+
+ if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
+ {
+ SwGetExpField aFld( (SwGetExpFieldType*)
+ rDoc.GetSysFldType( RES_GETEXPFLD ),
+ aBkmName, GSE_STRING, VVF_SYS );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ pEndStck->SetBookRef( aBkmName, FALSE );
+ }
+ else
+ {
+ SwGetRefField aFld( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ),
+ aBkmName,
+ REF_BOOKMARK,
+ 0,
+ REF_CONTENT );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ if( bObenUnten )
+ {
+ SwGetRefField aFld2( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ),
+ aBkmName,
+ REF_BOOKMARK,
+ 0,
+ REF_UPDOWN );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld2 ) );
+ }
+ }
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_NoteReference( WW8FieldDesc*, String& rStr )
+{ // Note Reference - Field
+ String aBkmName;
+ BOOL bChapterNr = FALSE;
+ BOOL bObenUnten = FALSE;
+
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aBkmName.Len() ) // get name of foot/endnote
+ {
+ aBkmName = aReadParam.GetResult();
+ }
+ break;
+
+ case 'r':
+ bChapterNr = TRUE; // activate flag 'Chapter Number'
+ break;
+
+ case 'p':
+ bObenUnten = TRUE;
+ break;
+ case 'h':
+ break;
+ default:
+ // unimplemented switch: just do 'nix nought nothing' :-)
+ break;
+ }
+ }
+
+ if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
+ {
+ SwGetExpField aFld( (SwGetExpFieldType*)
+ rDoc.GetSysFldType( RES_GETEXPFLD ),
+ aBkmName, GSE_STRING, VVF_SYS );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ pEndStck->SetBookRef( aBkmName, FALSE );
+ }
+ else
+ { // set Sequence No of corresponding Foot-/Endnote to Zero
+ // (will be corrected in
+ SwGetRefField aFld( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ),
+ aBkmName,
+ REF_FOOTNOTE,
+ 0,
+ REF_ONLYNUMBER
+ );
+ pRefFldStck->NewAttr(*pPaM->GetPoint(), SwFmtFld( aFld ));
+ if( bObenUnten )
+ {
+// rDoc.Insert( *pPaM, SwFmtHardBlank(' ') );
+ SwGetRefField aFld2( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ),
+ aBkmName,
+ REF_FOOTNOTE,
+ 0,
+ REF_UPDOWN
+ );
+ pRefFldStck->NewAttr(*pPaM->GetPoint(), SwFmtFld( aFld2 ));
+ }
+ }
+ return F_OK;
+}
+
+// "SEITENREF"
+eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr )
+{
+ String aName;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aName.Len() )
+ aName = aReadParam.GetResult();
+ break;
+ }
+ }
+ if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
+ {
+ SwGetRefField aFld( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ), aName, 0, 0,
+ REF_PAGE );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ pEndStck->SetBookRef( aName, TRUE );
+ }
+ else
+ {
+ SwGetRefField aFld( (SwGetRefFieldType*)
+ rDoc.GetSysFldType( RES_GETREFFLD ),
+ aName,
+ REF_BOOKMARK,
+ 0,
+ REF_PAGE );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ }
+ return F_OK;
+}
+
+// "MACROSCHALTFL"ACHE"
+eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, String& rStr )
+{
+ String aName;
+ String aVText;
+ long nRet;
+ BOOL bNewVText = TRUE;
+ BOOL bBracket = FALSE;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aName.Len() )
+ aName = aReadParam.GetResult();
+ else if( !aVText.Len() || bBracket )
+ {
+ if( bBracket )
+ aVText += ' ';
+ aVText += aReadParam.GetResult();
+ if( bNewVText )
+ {
+ bBracket = aVText.EqualsIgnoreCaseAscii('[', 1, 0);
+ bNewVText = FALSE;
+ }
+ else if( aVText.GetChar( aVText.Len()-1 ) == ']' )
+ bBracket = FALSE;
+ }
+ break;
+ }
+ }
+ if( !aName.Len() )
+ return F_TAGIGN; // makes no sense without Makro-Name
+
+ aName.InsertAscii( "StarOffice.Standard.Modul1.", 0 );
+
+ SwMacroField aFld( (SwMacroFieldType*)
+ rDoc.GetSysFldType( RES_MACROFLD ), aName, aVText );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+// "EINF"UGENGRAFIK"
+eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, String& rStr )
+{
+ String aGrfName;
+ BOOL bEmbedded = TRUE;
+
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aGrfName.Len() )
+ {
+ ConvertFFileName( aGrfName, aReadParam.GetResult() );
+ aGrfName = INetURLObject::RelToAbs( aGrfName );
+ }
+ break;
+
+ case 'd':
+ bEmbedded = FALSE; // Embedded-Flag deaktivieren
+ break;
+
+ case 'c':// den Converter-Namen ueberlesen
+ aReadParam.FindNextStringPiece();
+ break;
+ }
+ }
+
+ BOOL bExist = FALSE;
+ INetURLObject aGrURL(URIHelper::SmartRelToAbs(aGrfName));
+/* try
+ {
+ ::ucb::Content aTestContent(
+ aGrURL.GetMainURL(),
+ uno::Reference< XCommandEnvironment >());
+ bExist = aTestContent.isDocument();
+ }
+ catch(...){}
+*/
+ if( bExist || !bEmbedded )
+ {
+ /*
+ Besonderheit:
+
+ Wir setzen jetzt den Link ins Doc und merken uns den SwFlyFrmFmt.
+ Da wir ja unten auf jjeden Fall mit Return-Wert F_READ_FSPA enden,
+ wird der Skip-Wert so bemessen, dass das folgende Char-1 eingelesen
+ wird.
+ Wenn wir dann in SwWW8ImplReader::ImportGraf() reinlaufen, wird
+ erkannt, dass wir soeben einen Grafik-Link inserted haben und
+ das passende SwAttrSet wird ins Frame-Format eingesetzt.
+ */
+ SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
+ aFlySet.Put( SwFmtAnchor( FLY_IN_CNTNT ) );
+ aFlySet.Put( SwFmtVertOrient( 0, VERT_TOP, FRAME ));
+ pFlyFmtOfJustInsertedGraphic = rDoc.Insert( *pPaM,
+ aGrfName,
+ aEmptyStr,
+ 0, // Graphic*
+ &aFlySet,
+ 0); // SwFrmFmt*
+ String aName;
+ if(MakeUniqueGraphName(aName, aGrURL.GetBase()))
+ pFlyFmtOfJustInsertedGraphic->SetName( aName );
+ }
+ return F_READ_FSPA;
+}
+
+// "EINFUEGENTEXT"
+eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc*, String& rStr )
+{
+ String aPara;
+ String aBook;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aPara.Len() )
+ aPara = aReadParam.GetResult();
+ else if( !aBook.Len() )
+ aBook = aReadParam.GetResult();
+ break;
+ }
+ }
+ ConvertFFileName( aPara, aPara );
+ aPara = INetURLObject::RelToAbs( aPara );
+
+ if( aBook.Len() && aBook.GetChar( 0 ) != '\\' )
+ {
+ // Bereich aus Quelle ( kein Switch ) ?
+ ConvertUFName( aBook );
+ aPara += cTokenSeperator;
+ aPara += cTokenSeperator;
+ aPara += aBook;
+ }
+ String aStr(WW8_ASCII2STR( "WW" ));
+ SwSection* pSection = new SwSection( FILE_LINK_SECTION,
+ rDoc.GetUniqueSectionName( &aStr ) );
+ pSection->SetLinkFileName( aPara );
+ pSection->SetProtect( TRUE );
+ NewAttr( SwFltSection( pSection ) );
+ pEndStck->SetAttr( *pPaM->GetPoint(), RES_FLTR_SECTION );
+
+// rDoc.AppendTxtNode( *pPaM->GetPoint() );
+ return F_OK;
+}
+
+// "SERIENDRUCKFELD"
+eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc*, String& rStr )
+{
+ String aName;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aName.Len() )
+ aName = aReadParam.GetResult();
+ break;
+ }
+ }
+ SwDBFieldType aD( &rDoc, aName, aEmptyStr ); // Datenbank: Nichts
+ SwFieldType* pFT = rDoc.InsertFldType( aD );
+ SwDBField aFld( (SwDBFieldType*)pFT );
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+// "N"ACHSTER"
+eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, String& )
+{
+ SwDBNextSetFieldType aN;
+ SwFieldType* pFT = rDoc.InsertFldType( aN );
+ SwDBNextSetField aFld( (SwDBNextSetFieldType*)pFT, aEmptyStr, aEmptyStr,
+ aEmptyStr ); // Datenbank: Nichts
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+// "DATENSATZ"
+eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, String& )
+{
+ SwDBSetNumberFieldType aN;
+ SwFieldType* pFT = rDoc.InsertFldType( aN );
+ SwDBSetNumberField aFld( (SwDBSetNumberFieldType*)pFT,
+ aEmptyStr ); // Datenbank: Nichts
+ rDoc.Insert( *pPaM, SwFmtFld( aFld ) );
+ return F_OK;
+}
+
+//-----------------------------------------
+// Verzeichnis-Felder
+//-----------------------------------------
+
+void lcl_toxMatchACSwitch( SwWW8ImplReader& rReader,
+ SwDoc& rDoc,
+ SwTOXBase& rBase,
+ _ReadFieldParams& rParam,
+ SwCaptionDisplay eCaptionType)
+{
+ xub_StrLen n = rParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ {
+ SwTOXType* pType = (SwTOXType*)rDoc.GetTOXType( TOX_ILLUSTRATIONS, 0);
+ pType->Add( &rBase );
+ rBase.SetCaptionDisplay( eCaptionType );
+ // Read Sequence Name and store in TOXBase
+ String sSeqName( rParam.GetResult() );
+ lcl_ConvertSequenceName( rReader, sSeqName );
+ rBase.SetSequenceName( sSeqName );
+ }
+}
+
+
+void lcl_toxMatchTSwitch(SwWW8ImplReader& rReader,
+ SwTOXBase& rBase,
+ _ReadFieldParams& rParam)
+{
+ xub_StrLen n = rParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ {
+ String sParams( rParam.GetResult() );
+ if( sParams.Len() )
+ {
+ xub_StrLen nIndex = 0;
+
+ String sTemplate( sParams.GetToken(0, ';', nIndex) );
+ if( STRING_NOTFOUND == nIndex )
+ {
+ const SwFmt* pStyle
+ = rReader.GetStyleWithOrgWWName( sTemplate );
+ if( pStyle )
+ {
+ sTemplate = pStyle->GetName();
+ }
+ // Store Style for Level 0 into TOXBase
+ rBase.SetStyleNames( sTemplate, 0 );
+ }
+ else while( STRING_NOTFOUND != nIndex )
+ {
+ xub_StrLen nLevel = sParams.GetToken(0, ';', nIndex).ToInt32();
+
+ if( (0 < nLevel) && (MAXLEVEL >= nLevel) )
+ {
+ nLevel--;
+ // Store Style and Level into TOXBase
+ const SwFmt* pStyle
+ = rReader.GetStyleWithOrgWWName( sTemplate );
+ if( pStyle )
+ {
+ sTemplate = pStyle->GetName();
+ }
+ String sStyles( rBase.GetStyleNames( nLevel ) );
+ if( sStyles.Len() )
+ sStyles += TOX_STYLE_DELIMITER;
+ sStyles += sTemplate;
+ rBase.SetStyleNames( sStyles, nLevel );
+ }
+ // read next style name...
+ sTemplate = sParams.GetToken(0, ';', nIndex);
+ }
+ }
+ }
+}
+
+
+eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr )
+{
+ if( nIniFlags & WW8FL_NO_TOX )
+ return F_OK; // abgeschaltet -> ignorieren
+ if( ( pF->nLRes < 3 ) )
+ return F_TAGIGN; // Nur Stuss -> ignorieren
+
+ TOXTypes eTox; // Baue ToxBase zusammen
+ switch( pF->nId )
+ {
+ case 8: eTox = TOX_INDEX; break;
+ case 13: eTox = TOX_CONTENT; break;
+ default: eTox = TOX_USER; break;
+ }
+ USHORT nCreateOf = (eTox == TOX_CONTENT) ? TOX_OUTLINELEVEL
+ : TOX_MARK;
+ USHORT nIndexCols = 0;
+ const SwTOXType* pType = rDoc.GetTOXType( eTox, 0 );
+ SwForm aForm( eTox );
+ SwTOXBase* pBase = new SwTOXBase( pType, aForm, nCreateOf, aEmptyStr );
+ // Name des Verzeichnisses
+ switch( eTox ){
+ case TOX_INDEX:
+ {
+ USHORT eOptions = TOI_SAME_ENTRY | TOI_CASE_SENSITIVE;
+
+
+ // TOX_OUTLINELEVEL setzen wir genau dann, wenn
+ // die Parameter \o in 1 bis 9 liegen
+ // oder der Parameter \f existiert
+ // oder GARKEINE Switches Parameter angegeben sind.
+ USHORT eCreateFrom = 0;
+ USHORT nMaxLevel = 0;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case 'c':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ {
+ String sParams( aReadParam.GetResult() );
+ if( sParams.Len() ) // if NO String just ignore the \c
+ nIndexCols = sParams.ToInt32();
+ }
+ }
+ break;
+ case 'e':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n ) // if NO String just ignore the \e
+ {
+ String sDelimiter( aReadParam.GetResult() );
+ SwForm aForm( pBase->GetTOXForm() );
+
+ // Attention: if TOX_CONTENT brave
+ // GetFormMax() returns MAXLEVEL + 1 !!
+ USHORT nEnd = aForm.GetFormMax()-1;
+
+ for(USHORT nLevel = 1;
+ nLevel <= nEnd;
+ ++nLevel)
+ {
+ // Levels count from 1
+ // Level 0 is reserved for CAPTION
+
+ // Delimiter statt Tabstop vor der Seitenzahl einsetzen,
+ // falls es eine Seitenzahl gibt:
+ FormTokenType ePrevType = TOKEN_END;
+ FormTokenType eType;
+ SwFormTokenEnumerator aEnumer =
+ aForm.CreateTokenEnumerator( nLevel );
+ do
+ {
+ eType = aEnumer.GetNextTokenType();
+ switch( eType )
+ {
+ case TOKEN_PAGE_NUMS:
+ {
+ if( TOKEN_TAB_STOP == ePrevType )
+ {
+ // remove Tab
+ aEnumer.GetPrevTokenType();
+ aEnumer.RemoveCurToken();
+ // insert new Token
+ if( 0x09 == sDelimiter.GetChar( 0 ) )
+ {
+ SwFormToken aToken( TOKEN_TAB_STOP );
+ aToken.eTabAlign = SVX_TAB_ADJUST_END;
+ aEnumer.InsertToken( aToken );
+ }
+ else
+ {
+ SwFormToken aToken( TOKEN_TEXT );
+ aToken.sText = sDelimiter;
+ aEnumer.InsertToken( aToken );
+ }
+ aForm.SetPattern( nLevel,
+ aEnumer.GetPattern() );
+ }
+ eType = TOKEN_END;
+ break;
+ }
+ }
+ ePrevType = eType;
+ }
+ while( TOKEN_END != eType );
+ }
+ pBase->SetTOXForm( aForm );
+ }
+ }
+ break;
+ case 'h':
+ {
+ eOptions |= TOI_ALPHA_DELIMITTER;
+ }
+ break;
+ case 'r':
+ {
+ SwForm aForm( pBase->GetTOXForm() );
+ aForm.SetCommaSeparated( TRUE );
+ pBase->SetTOXForm( aForm );
+ }
+ break;
+ /*
+ // the following switches are not (yet) supported
+ // by good old StarWriter:
+ case 'b':
+ case 'd':
+ case 'f':
+ case 'g':
+ case 'I':
+ case 'p':
+ case 's':
+ break;
+ */
+ }
+ }
+ /*
+ const TOXTypes eType = pBase->GetTOXType()->GetType();
+ switch( eType )
+ {
+ case TOX_CONTENT:
+ if( eCreateFrom )
+ pBase->SetCreate( eCreateFrom );
+ break;
+ case TOX_ILLUSTRATIONS:
+ if( !eCreateFrom )
+ eCreateFrom = TOX_SEQUENCE;
+ pBase->SetCreate( eCreateFrom );
+ break;
+ }
+ */
+ pBase->SetOptions( eOptions );
+ }
+ break;
+
+
+
+
+
+ case TOX_CONTENT:
+ {
+ // TOX_OUTLINELEVEL setzen wir genau dann, wenn
+ // die Parameter \o in 1 bis 9 liegen
+ // oder der Parameter \f existiert
+ // oder GARKEINE Switches Parameter angegeben sind.
+ USHORT eCreateFrom = 0;
+ USHORT nMaxLevel = 0;
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case 'a':
+ case 'c':
+ lcl_toxMatchACSwitch(*this, rDoc, *pBase, aReadParam,
+ ('c' == nRet)
+ ? CAPTION_COMPLETE
+ : CAPTION_TEXT );
+ break;
+ case 'o':
+ {
+ USHORT nVal;
+ if( !aReadParam.GetTokenSttFromTo(0, &nVal, MAXLEVEL) )
+ {
+ nVal = aForm.GetFormMax()-1;
+ }
+ if( nMaxLevel < nVal )
+ nMaxLevel = nVal;
+ eCreateFrom |= TOX_OUTLINELEVEL;
+ }
+ break;
+ case 'f':
+ eCreateFrom |= TOX_MARK;
+ break;
+ case 'l':
+ {
+ USHORT nVal;
+ if( aReadParam.GetTokenSttFromTo(0, &nVal, MAXLEVEL) )
+ {
+ if( nMaxLevel < nVal )
+ nMaxLevel = nVal;
+ eCreateFrom |= TOX_MARK;
+ }
+ }
+ break;
+ case 't': // paragraphs using special styles shall
+ // provide the TOX's content
+ lcl_toxMatchTSwitch(*this, *pBase, aReadParam);
+ eCreateFrom |= TOX_TEMPLATE;
+ break;
+ case 'p':
+ {
+ xub_StrLen n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n ) // if NO String just ignore the \p
+ {
+ String sDelimiter( aReadParam.GetResult() );
+ SwForm aForm( pBase->GetTOXForm() );
+
+ // Attention: if TOX_CONTENT brave
+ // GetFormMax() returns MAXLEVEL + 1 !!
+ USHORT nEnd = aForm.GetFormMax()-1;
+
+ for(USHORT nLevel = 1;
+ nLevel <= nEnd;
+ ++nLevel)
+ {
+ // Levels count from 1
+ // Level 0 is reserved for CAPTION
+
+ // Delimiter statt Tabstop vor der Seitenzahl einsetzen,
+ // falls es eine Seitenzahl gibt:
+ FormTokenType ePrevType = TOKEN_END;
+ FormTokenType eType;
+ SwFormTokenEnumerator aEnumer =
+ aForm.CreateTokenEnumerator( nLevel );
+ do
+ {
+ eType = aEnumer.GetNextTokenType();
+ switch( eType )
+ {
+ case TOKEN_PAGE_NUMS:
+ {
+ if( TOKEN_TAB_STOP == ePrevType )
+ {
+ // remove Tab
+ aEnumer.GetPrevTokenType();
+ aEnumer.RemoveCurToken();
+ // insert new Token
+ SwFormToken aToken( TOKEN_TEXT );
+ aToken.sText = sDelimiter;
+
+ aEnumer.InsertToken( aToken );
+ aForm.SetPattern( nLevel,
+ aEnumer.GetPattern() );
+ }
+ eType = TOKEN_END;
+ break;
+ }
+ }
+ ePrevType = eType;
+ }
+ while( TOKEN_END != eType );
+ }
+ pBase->SetTOXForm( aForm );
+ }
+ }
+ break;
+ case 'n': // don't print page numbers
+ {
+ // read START and END param
+ USHORT nStart, nEnd;
+ if( !aReadParam.GetTokenSttFromTo( &nStart,
+ &nEnd,
+ MAXLEVEL ) )
+ {
+ nStart = 1;
+ nEnd = aForm.GetFormMax()-1;
+ }
+ // remove page numbers from this levels
+ SwForm aForm( pBase->GetTOXForm() );
+ if( aForm.GetFormMax() <= nEnd)
+ nEnd = aForm.GetFormMax()-1;
+ for(USHORT nLevel = nStart;
+ nLevel <= nEnd;
+ ++nLevel)
+ {
+ // Levels count from 1
+ // Level 0 is reserved for CAPTION
+
+ // Seitenzahl und ggfs. davorstehenden Tabstop entfernen:
+ FormTokenType eType;
+ SwFormTokenEnumerator aEnumer =
+ aForm.CreateTokenEnumerator( nLevel );
+ do
+ {
+ eType = aEnumer.GetNextTokenType();
+ switch( eType )
+ {
+ case TOKEN_PAGE_NUMS:
+ {
+ aEnumer.RemoveCurToken();
+ if( TOKEN_TAB_STOP
+ == aEnumer.GetPrevTokenType() )
+ {
+ aEnumer.RemoveCurToken();
+ aForm.SetPattern( nLevel,
+ aEnumer.GetPattern() );
+ }
+ eType = TOKEN_END;
+ break;
+ }
+ }
+ }
+ while( TOKEN_END != eType );
+ }
+ pBase->SetTOXForm( aForm );
+ }
+ break;
+
+ /*
+ // the following switches are not (yet) supported
+ // by good old StarWriter:
+ case 'b':
+ case 's':
+ case 'd':
+ break;
+ */
+ }
+ }
+ if( !nMaxLevel )
+ nMaxLevel = MAXLEVEL;
+ pBase->SetLevel( nMaxLevel );
+
+ const TOXTypes eType = pBase->GetTOXType()->GetType();
+ switch( eType )
+ {
+ case TOX_CONTENT:
+ if( eCreateFrom )
+ pBase->SetCreate( eCreateFrom );
+ break;
+ case TOX_ILLUSTRATIONS:
+ if( !eCreateFrom )
+ eCreateFrom = TOX_SEQUENCE;
+ pBase->SetCreate( eCreateFrom );
+ break;
+ }
+ }
+ break;
+ case TOX_USER:
+ break;
+ } // ToxBase fertig
+
+ // Update fuer TOX anstossen
+ rDoc.SetUpdateTOX( TRUE );
+
+ const SwPosition* pPos = pPaM->GetPoint();
+
+ SwFltTOX aFltTOX( pBase, nIndexCols );
+
+ // test if there is already a break item on this node
+ SwCntntNode* pNd = pPos->nNode.GetNode().GetCntntNode();
+ if( pNd )
+ {
+ const SfxItemSet* pSet = pNd->GetpSwAttrSet();
+ if( pSet )
+ {
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, FALSE ) )
+ aFltTOX.SetHadBreakItem( TRUE );
+ if( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, FALSE ) )
+ aFltTOX.SetHadPageDescItem( TRUE );
+ }
+ }
+
+ // Setze Anfang in Stack
+ pEndStck->NewAttr( *pPos, aFltTOX );
+ if( 1 < nIndexCols )
+ bDontCreateSep = TRUE;
+
+ // Setze Ende in Stack
+ pEndStck->SetAttr( *pPos, RES_FLTR_TOX );
+
+ return F_OK;
+}
+
+eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* pF, String& rStr )
+{
+ eF_ResT eRet = F_OK;
+ String sURL, sTarget, sMark;
+ BOOL bDataImport=FALSE;
+
+ // JP 02.12.98: es gibt Hyperlink-Felder, die am Ende eine '\x01' stehen
+ // haben. Die wollen wir aber nicht beachten
+ /*
+ if( pStr[ pF->nLCode - 1 ] < ' ' )
+ pStr[ pF->nLCode - 1 ] = 0;
+ */
+
+
+
+/*
+ //caolan
+ if( rStr.GetChar( pF->nLCode - 1 ) < ' ' )
+ {
+#if DEBUG
+ if( 0x01 == rStr.GetChar( pF->nLCode-1 ) )
+ bDataImport=ImportURL( sURL, sMark, pF->nSCode + pF->nLCode-1 );
+#endif
+ rStr.SetChar( pF->nLCode - 1, 0 );
+ }
+*/
+
+ rStr.EraseTrailingChars( 1 );
+
+
+
+ if (!bDataImport)
+ {
+ long nRet;
+ _ReadFieldParams aReadParam( rStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ switch( nRet )
+ {
+ case -2:
+ if( !sURL.Len() )
+ {
+ ConvertFFileName( sURL, aReadParam.GetResult() );
+ sURL = INetURLObject::RelToAbs( sURL );
+ }
+ break;
+
+ case 'n':
+ sTarget = WW8_ASCII2STR( "_blank" );
+ break;
+
+ case 'l':
+ nRet = aReadParam.SkipToNextToken();
+ if( -2 == nRet )
+ {
+ sMark = aReadParam.GetResult();
+ if( sMark.Len() && '"' == sMark.GetChar( sMark.Len()-1 ))
+ sMark.Erase( sMark.Len() - 1 );
+
+ }
+ break;
+
+ case 'h':
+ case 'm':
+ case 's':
+ case 't':
+ ASSERT( !this, "Auswertung fehlt noch - Daten unbekannt" );
+ break;
+ }
+ }
+
+ String sDef( GetFieldResult( pF ) ); // das Resultat uebernehmen
+ if( ( sURL.Len() || sMark.Len() ) && sDef.Len() )
+ {
+ if( sMark.Len() )
+ ( sURL += INET_MARK_TOKEN ) += sMark;
+ SwFmtINetFmt aURL( sURL, sTarget );
+// aURL.SetVisitedFmt( "??" );
+// aURL.SetINetFmt( "??" );
+ pEndStck->NewAttr( *pPaM->GetPoint(), aURL );
+
+ // das Ende als "relative" Pos auf den Stack setzen
+ pPaM->SetMark();
+ pPaM->GetMark()->nContent += sDef.Len();
+ pEndStck->SetAttr( *pPaM->GetMark(), RES_TXTATR_INETFMT, FALSE );
+ pPaM->DeleteMark();
+ eRet = F_TEXT;
+ }
+ return eRet;
+}
+
+
+void SwWW8ImplReader::ImportTox( int nFldId, String aStr )
+{
+ BOOL bIdx = ( nFldId != 9 );
+ TOXTypes eTox = ( !bIdx ) ? TOX_CONTENT : TOX_INDEX; // Default
+
+ USHORT nLevel = 1;
+
+ xub_StrLen n;
+ String sKey1;
+ long nRet;
+ _ReadFieldParams aReadParam( aStr );
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ switch( nRet )
+ {
+ case -2:
+ if( !sKey1.Len() )
+ {
+ sKey1 = aReadParam.GetResult().GetToken(0, ':');
+ if( !sKey1.Len() )
+ sKey1 = aReadParam.GetResult(); // PrimaryKey ohne ":", 2nd dahinter
+ }
+ break;
+
+ case 'f':
+ n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ {
+ String sParams( aReadParam.GetResult() );
+ if( 'C' != sParams.GetChar(0) && 'c' != sParams.GetChar(0) )
+ eTox = TOX_USER;
+ }
+ break;
+
+ case 'l':
+ n = aReadParam.GoToTokenParam();
+ if( STRING_NOTFOUND != n )
+ {
+ String sParams( aReadParam.GetResult() );
+ if( sParams.Len() // if NO String just ignore the \l
+ && sParams.GetChar( 0 ) > '0'
+ && sParams.GetChar( 0 ) <= '9' )
+ {
+ nLevel = (USHORT)sParams.ToInt32();
+ }
+ }
+ break;
+ }
+
+
+/*
+ WW8FldParaGuess aG( pStr, ( bIdx ) ? 0 : "fl" );
+ const char* pFld = (const char*)aG.GetStdPara();
+ if( !aG.Ok() || !pFld )
+ return;
+
+ char* pKey1 = (char*)strchr( pFld, ':' );
+ if( pKey1 )
+ {
+ *pKey1++ = '\0';
+ }
+
+ USHORT nLevel = 1;
+
+ if( !bIdx ){ // Inhalts- oder Abbildungsverzeichnis
+ const unsigned char* pFlg = aG.GetSwitch( 0 );// Switch 'f'
+ if( pFlg && toupper(*pFlg) != 'C' )
+ eTox = TOX_USER; // z.B. F = Abbildungsverzeichnis
+ pFlg = aG.GetSwitch( 1 ); // Switch 'l'
+ if( pFlg && *pFlg > '0' && *pFlg <= '9' )
+ nLevel = *pFlg - '0';
+ }
+*/
+ ASSERT( rDoc.GetTOXTypeCount( eTox ), "Doc.GetTOXTypeCount() == 0 :-(" );
+
+ const SwTOXType* pT = rDoc.GetTOXType( eTox, 0 );
+ SwTOXMark aM( pT );
+ if( eTox != TOX_INDEX )
+ aM.SetLevel( nLevel );
+
+ if( sKey1.Len() )
+ {
+ aM.SetAlternativeText( sKey1 ); // WW/SW: unterschiedliche Reihenfolge
+ // Text mit Key1 tauschen
+ aM.SetPrimaryKey( aStr );
+
+ }
+ else
+ aM.SetAlternativeText( aStr );
+
+ if( !aM.IsAlternativeText() )
+ {
+ pPaM->SetMark();
+ pPaM->GetMark()->nContent += aStr.Len();
+ }
+ rDoc.Insert( *pPaM, aM );
+ if( !aM.IsAlternativeText() )
+ pPaM->DeleteMark();
+}
+
+void SwWW8ImplReader::Read_FldVanish( USHORT, BYTE*, short nLen )
+{
+ // Vorsicht: Bei Feldnamen mit Umlauten geht das MEMICMP nicht!
+ const static sal_Char *aFldNames[] = { "\x06""INHALT", "\x02""XE", // dt.
+ "\x02""TC" }; // us
+ const static BYTE aFldId[] = { 9, 4, 9 };
+
+ if( nIniFlags & WW8FL_NO_FLD )
+ return;
+
+ if( nLen < 0 )
+ {
+ bIgnoreText = FALSE;
+ return;
+ }
+
+ // our methode was called from
+ // ''Skip attributes of field contents'' loop within ReadTextAttr()
+ if( bIgnoreText )
+ return;
+
+ bIgnoreText = TRUE;
+ long nOldPos = pStrm->Tell();
+ USHORT nFieldLen;
+
+ WW8_CP nStartCp = pSBase->WW8Fc2Cp( nOldPos );
+ String sFieldName;
+ nFieldLen = pSBase->WW8ReadString( *pStrm, sFieldName, nStartCp,
+ 500, eStructCharSet );
+ pStrm->Seek( nOldPos );
+
+ xub_StrLen nC = 0;
+ if( 0x13 != sFieldName.GetChar( nC )) // Field Start Mark
+ {
+ if( 0x15 == sFieldName.GetChar( nC )) // Field End Mark found
+ bIgnoreText = FALSE;
+// delete( pFieldName );
+ return; // kein Feld zu finden
+ }
+
+ nC++;
+ while( ' ' == sFieldName.GetChar( nC ))
+ nC++;
+
+ for( int i = 0; i < 2; i++ )
+ {
+ const sal_Char* pName = aFldNames[i];
+ USHORT nNameLen = *pName++;
+ if( sFieldName.EqualsIgnoreCaseAscii( pName, 0, nNameLen ) )
+ {
+ ImportTox( aFldId[i], sFieldName.Copy( nNameLen ) );
+ break; // keine Mehrfachnennungen moeglich
+ }
+ }
+ bIgnoreText = TRUE;
+ pStrm->Seek( nOldPos );
+}
+
+// Read_Invisible ist fuer das "Unsichtbar"-Zeichenattribut. Mangels
+// entsprechender Funktion im SW evtl. als Tag.
+//
+// ACHTUNG: Methode gelegentlich umstellen: unsichtbaren Text als
+// *Feld* integrieren...
+//
+void SwWW8ImplReader::Read_Invisible( USHORT, BYTE* pData, short nLen )
+{
+ USHORT n = WWF_INVISIBLE; // Bit-Nummer fuer Invisible
+ USHORT nI = n / 32; // # des UINT32
+ ULONG nMask = 1 << ( n % 32 ); // Maske fuer Bits
+
+ if( ( nFieldTagBad[ nI ] & nMask )
+ || ( nFieldTagAlways[ nI ] & nMask ) )
+ {
+ String aTag( WW8_ASCII2STR( "{INVISIBLE " ) );
+
+ if( nLen < 0 )
+ aTag.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "END}" ) );
+ else
+ aTag.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "START}" ) );
+
+ InsertTagField( n, aTag );
+ }
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par5.cxx,v 1.1.1.1 2000-09-18 17:14:58 hr Exp $
+
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.71 2000/09/18 16:05:01 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.70 2000/08/31 06:29:28 jp
+ use CharClass instead of international
+
+ Revision 1.69 2000/08/04 10:56:54 jp
+ Soft-/HardHyphens & HardBlanks changed from attribute to unicode character
+
+ Revision 1.68 2000/07/24 16:39:08 khz
+ #75701# set Break or PageDesc item BEHIND TOX if not found before the #0x0C
+
+ Revision 1.67 2000/06/26 12:59:11 os
+ INetURLObject::SmartRelToAbs removed
+
+ Revision 1.66 2000/06/15 15:57:31 khz
+ Prevent FindParaStart() from calling rStr.GetChar() behind end of string
+
+ Revision 1.65 2000/06/13 08:25:46 os
+ using UCB
+
+ Revision 1.64 2000/06/06 15:00:34 khz
+ Changes for Unicode
+
+ Revision 1.63 2000/05/18 10:59:02 jp
+ Changes for Unicode
+
+ Revision 1.62 2000/05/17 16:40:46 khz
+ Changes for unicode (2)
+
+ Revision 1.60 2000/05/16 12:03:45 jp
+ Changes for unicode
+
+ Revision 1.59 2000/05/16 11:06:28 khz
+ Unicode code-conversion
+
+ Revision 1.58 2000/05/08 09:25:49 khz
+ Task #74474# Find TRUE end of field code in WW8FldParaGuess class
+
+ Revision 1.57 2000/05/05 16:07:41 khz
+ Task #74474# don't create Sections while skipping result of multi-column index-field
+
+ Revision 1.56 2000/03/27 11:44:40 cmc
+ #74329# Added OCX Field Reader
+
+ Revision 1.55 2000/03/22 09:55:35 khz
+ Task #74378# release memory that was allocated by FindPara()
+
+ Revision 1.54 2000/02/18 09:38:12 cmc
+ #69372# Improved Hyperlink Importing for WW97
+
+ Revision 1.53 2000/02/11 14:40:28 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.52 2000/01/17 11:22:15 khz
+ Task #62941# import DateTime as single field (before 2 field separated by space)
+
+ Revision 1.51 2000/01/11 10:17:43 khz
+ Task #62941# import different formats for date- and time-fields
+
+ Revision 1.50 2000/01/04 16:48:36 khz
+ Task #70863# Indexes: parameter >> \e '0x09' << shows page-num at right col-margin
+
+ Revision 1.49 1999/12/23 17:01:22 khz
+ Task #70788# *De*activate bIgnoreText in Read_FldVanish() when 0x15 reached
+
+ Revision 1.48 1999/12/21 09:25:48 khz
+ Task #71111# Prevent from reading CONTENT when skiping field attributes
+
+ Revision 1.47 1999/12/06 09:35:05 khz
+ Task #70486# Now \t param on INDEX field may have one single NAME (without LEVEL)
+
+ Revision 1.46 1999/12/02 16:39:28 khz
+ Task #69857# Removed TOI_FF from default TOX_INDEX flags
+
+ Revision 1.45 1999/11/26 12:51:17 khz
+ Task #69898# TOC parameter \o will include *all* levels when no levels specified
+
+ Revision 1.44 1999/11/26 12:27:21 khz
+ Task #69892# TOC parameter \n will modify *all* levels when no levels specified
+
+ Revision 1.43 1999/11/02 15:59:45 khz
+ import new TOX_CONTENT and TOX_INDEX features (2)
+
+ Revision 1.42 1999/10/29 12:07:39 khz
+ import new TOX_CONTENT and TOX_INDEX features
+
+ Revision 1.41 1999/10/13 21:09:26 khz
+ Import Table Of Contents (0)
+
+ Revision 1.40 1999/08/30 19:53:08 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.39 30 Aug 1999 21:53:08 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.38 09 Aug 1999 14:16:12 JP
+ read W95 format from stream
+
+ Rev 1.37 30 Jul 1999 17:53:36 KHZ
+ Task #62955# name matching for docinfo fields (1)
+
+ Rev 1.36 27 Jul 1999 11:23:44 KHZ
+ Task #62941# find number format for date/time fields
+
+ Rev 1.35 15 Jul 1999 19:03:48 JP
+ Read_Field: if read only result then skip one char more back
+
+ Rev 1.34 07 Jul 1999 08:08:20 OS
+ extended indexes: Index names in ShellRes
+
+ Rev 1.33 21 Jun 1999 12:16:12 KHZ
+ Reference field (page, bookmark, footnote) part#2
+
+ Rev 1.32 18 Jun 1999 15:53:52 KHZ
+ Reference field (page, bookmark, footnote) part#1
+
+ Rev 1.31 03 Jun 1999 16:59:56 KHZ
+ Task #66418# UEberfluessiges ''xStrm->Seek( nOldPos );'' entfernt
+
+ Rev 1.30 02 Jun 1999 09:32:24 KHZ
+ Task #66227# a) kein Unicode bei Ver67 ;-) b) Grafik in grupp. Textbox
+
+ Rev 1.29 27 Apr 1999 14:39:10 KHZ
+ Task #65353# ueberfluessiges AppendTxtNode in Read_F_IncludeText entfernt
+
+
+ Rev 1.28 26 Apr 1999 19:22:54 JP
+ Bug #65298#: Grf/Ole bei Zeichenbindung immer Oben zu Grundline anordnen
+
+ Rev 1.27 18 Feb 1999 12:44:38 KHZ
+ Task #61675# Falsche Offsetberechnung bei ImportTox() in Read_FldVanish()
+
+ Rev 1.26 23 Dec 1998 16:15:00 KHZ
+ Task #60444# Inhaltverzeichnis jetzt auch bei fehlenden Switches
+
+ Rev 1.25 15 Dec 1998 10:50:44 KHZ
+ Tasks #59580# und #58766# (Nachzieher aus SRV506)
+
+ Rev 1.24 07 Dec 1998 11:27:28 KHZ
+ Task #58766# Unicode in benutzerdef. Verzeichnissen
+
+ Rev 1.23 02 Dec 1998 20:06:34 JP
+ Bug #60045#: Marks von Hyperlinks einlesen
+
+ Rev 1.22 02 Dec 1998 11:41:06 KHZ
+ Task #59834# ein vergessenes >>delete[]( pDef )><<
+
+ Rev 1.21 24 Nov 1998 21:11:22 JP
+ Task #59822#: OLE-Objecte einlesen
+
+ Rev 1.20 19 Nov 1998 10:37:02 TRI
+ OS2 Anpassungen
+
+ Rev 1.19 18 Nov 1998 16:29:46 HR
+ doppeltes const raus
+
+ Rev 1.18 18 Nov 1998 10:33:28 KHZ
+ Task #59078# Compilerfehler unter Unix
+
+ Rev 1.17 17 Nov 1998 20:25:12 JP
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.16 17 Nov 1998 20:05:56 JP
+ Task #59476#: Seitenumrandung / Seitennummern / Seitennummernformat lesen
+
+ Rev 1.15 17 Nov 1998 10:48:54 OS
+ #58263# NumType durch SvxExtNumType ersetzt
+
+ Rev 1.14 16 Nov 1998 18:59:18 KHZ
+ Task #59078# Feldimport SEQ (fertig)
+
+ Rev 1.13 16 Nov 1998 18:34:22 KHZ
+ Task #59078# Feldimport SEQ (Teil 1)
+
+ Rev 1.12 16 Nov 1998 13:19:52 JP
+ Task #59476#: Hyperlinks lesen, ImportGrf vereinfacht, Bookmarks kein ToUpper
+
+ Rev 1.11 05 Nov 1998 13:07:36 KHZ
+ Task #58993# Befehl INCLUDEPICTURE liefert jetzt korrekten String
+
+ Rev 1.10 30 Oct 1998 16:13:48 KHZ
+ Task #57836# Beliebige Parameterreihenfolge bei Feld INCLUDEPICTURE moeglich
+
+ Rev 1.9 30 Oct 1998 16:10:54 KHZ
+
+ Rev 1.8 29 Oct 1998 15:12:24 KHZ
+ Task #58620# GPF bei Feld EINFUEGENGRAFIK in Doc mit UNICODE
+
+ Rev 1.7 15 Sep 1998 19:35:46 JP
+ Bug #56310#: Teilfix - kein GPF mehr
+
+ Rev 1.6 13 Sep 1998 15:50:22 HJS
+ #56149# authorfield
+
+ Rev 1.5 03 Sep 1998 22:16:14 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.4 11 Aug 1998 14:39:46 KHZ
+ Task #52607# neue Numerierungstypen (siehe auch WWPAR.CXX und Bug 54796)
+
+ Rev 1.3 05 Aug 1998 09:32:08 KHZ
+ Task #52607# Kodepflege
+
+ Rev 1.2 30 Jun 1998 21:33:24 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.1 23 Jun 1998 11:15:28 KHZ
+ memicmp ersetzt durch MEMICMP
+
+ Rev 1.0 16 Jun 1998 11:08:28 KHZ
+ Initial revision.
+
+*************************************************************************/
+
+
+
+
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
new file mode 100644
index 000000000000..2c788b203972
--- /dev/null
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -0,0 +1,4883 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8par6.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+
+#ifdef PRECOMPILED
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_USHORTSSORT
+#include <svtools/svstdarr.hxx>
+#endif
+
+#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SVX_LSPCITEM_HXX //autogen
+#include <svx/lspcitem.hxx>
+#endif
+#ifndef _SVX_WRLMITEM_HXX //autogen
+#include <svx/wrlmitem.hxx>
+#endif
+#ifndef _SVX_UDLNITEM_HXX //autogen
+#include <svx/udlnitem.hxx>
+#endif
+#ifndef _SVX_KERNITEM_HXX //autogen
+#include <svx/kernitem.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX //autogen
+#include <svx/langitem.hxx>
+#endif
+#ifndef _SVX_CMAPITEM_HXX //autogen
+#include <svx/cmapitem.hxx>
+#endif
+#ifndef _SVX_SHDDITEM_HXX //autogen
+#include <svx/shdditem.hxx>
+#endif
+#ifndef _SVX_CNTRITEM_HXX //autogen
+#include <svx/cntritem.hxx>
+#endif
+#ifndef _SVX_CRSDITEM_HXX //autogen
+#include <svx/crsditem.hxx>
+#endif
+#ifndef _SVX_POSTITEM_HXX //autogen
+#include <svx/postitem.hxx>
+#endif
+#ifndef _SVX_WGHTITEM_HXX //autogen
+#include <svx/wghtitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX //autogen
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX //autogen
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_SPLTITEM_HXX //autogen
+#include <svx/spltitem.hxx>
+#endif
+#ifndef _SVX_KEEPITEM_HXX //autogen
+#include <svx/keepitem.hxx>
+#endif
+#ifndef _SVX_ORPHITEM_HXX //autogen
+#include <svx/orphitem.hxx>
+#endif
+#ifndef _SVX_WIDWITEM_HXX //autogen
+#include <svx/widwitem.hxx>
+#endif
+#ifndef _SVX_ADJITEM_HXX //autogen
+#include <svx/adjitem.hxx>
+#endif
+#ifndef _SVX_ESCPITEM_HXX //autogen
+#include <svx/escpitem.hxx>
+#endif
+#ifndef _SVX_FHGTITEM_HXX //autogen
+#include <svx/fhgtitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX //autogen
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_SHADITEM_HXX //autogen
+#include <svx/shaditem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX //autogen
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX //autogen
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX //autogen
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SVX_AKRNITEM_HXX //autogen
+#include <svx/akrnitem.hxx>
+#endif
+#ifndef _SVX_PAPERINF_HXX //autogen
+#include <svx/paperinf.hxx>
+#endif
+
+#ifndef _SVX_PBINITEM_HXX
+#include <svx/pbinitem.hxx>
+#endif
+
+#ifndef _SVX_HYZNITEM_HXX //autogen
+#include <svx/hyznitem.hxx>
+#endif
+
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+
+#ifndef _FMTPDSC_HXX //autogen
+#include <fmtpdsc.hxx>
+#endif
+#ifndef _NODE_HXX //autogen
+#include <node.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx> // SwTxtNode, siehe unten: JoinNode()
+#endif
+#ifndef _PAM_HXX
+#include <pam.hxx> // fuer SwPam
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+#ifndef _PAGEDESC_HXX
+#include <pagedesc.hxx> // class SwPageDesc
+#endif
+#ifndef _FMTANCHR_HXX //autogen
+#include <fmtanchr.hxx>
+#endif
+#ifndef _FMTCNTNT_HXX //autogen
+#include <fmtcntnt.hxx>
+#endif
+#ifndef _FCHRFMT_HXX //autogen
+#include <fchrfmt.hxx>
+#endif
+#ifndef _FMTHDFT_HXX //autogen
+#include <fmthdft.hxx>
+#endif
+#ifndef _FMTCLDS_HXX //autogen
+#include <fmtclds.hxx>
+#endif
+#ifndef _FMTFTNTX_HXX
+#include <fmtftntx.hxx>
+#endif
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+#ifndef _FLTSHELL_HXX
+#include <fltshell.hxx> // fuer den Attribut Stack
+#endif
+#ifndef _FLTINI_HXX
+#include <fltini.hxx>
+#endif
+#ifndef _SECTION_HXX
+#include <section.hxx>
+#endif
+#ifndef SW_LINEINFO_HXX
+#include <lineinfo.hxx>
+#endif
+#ifndef SW_FMTLINE_HXX
+#include <fmtline.hxx>
+#endif
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+#ifndef _WW8PAR2_HXX
+#include <ww8par2.hxx> // class WW8RStyle, class WwAnchorPara
+#endif
+
+
+#define NEW_MINHDSIZ // Definieren zum Ausnutzen der minimalen
+ // Header- und Footerhoehe
+
+
+static ColorData __FAR_DATA eSwWW8ColA[] = {
+ COL_BLACK, COL_BLACK, COL_LIGHTBLUE,
+ COL_LIGHTCYAN, COL_LIGHTGREEN, COL_LIGHTMAGENTA, COL_LIGHTRED,
+ COL_YELLOW, COL_WHITE, COL_BLUE, COL_CYAN, COL_GREEN,
+ COL_MAGENTA, COL_RED, COL_BROWN, COL_GRAY, COL_LIGHTGRAY };
+
+
+#ifdef HP9000
+#define INLINE_AUSSER_HP
+#else
+#define INLINE_AUSSER_HP inline
+#endif
+
+
+//-----------------------------------------
+// diverses
+//-----------------------------------------
+
+#define MM_250 1417 // WW-Default fuer Hor. Seitenraender: 2.5 cm
+#define MM_200 1134 // WW-Default fuer u.Seitenrand: 2.0 cm
+#define MM_125 709 // WW-Default fuer vert. K/F-Pos: 1.25 cm
+
+BOOL lcl_ReadBorders( BOOL bVer67, WW8_BRC* brc,
+ WW8PLCFx_Cp_FKP* pPap,
+ const WW8RStyle* pSty = 0,
+ const WW8PLCFx_SEPX* pSep = 0 );
+
+
+ColorData SwWW8ImplReader::GetCol( BYTE nIco )
+{
+ return eSwWW8ColA[nIco];
+}
+
+/***************************************************************************
+# Seiten - Attribute, die nicht ueber die Attribut-Verwaltung, sondern
+# ueber ...->HasSprm abgearbeitet werden
+# ( ausser OLST, dass weiterhin ein normales Attribut ist )
+#**************************************************************************/
+
+static short ReadSprm( const WW8PLCFx_SEPX* pSep, USHORT nId, short nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ short nVal = ( pS ) ? SVBT16ToShort( pS ) : nDefaultVal;
+ return nVal;
+}
+
+static USHORT ReadUSprm( const WW8PLCFx_SEPX* pSep, USHORT nId, short nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ USHORT nVal = ( pS ) ? SVBT16ToShort( pS ) : nDefaultVal;
+ return nVal;
+}
+
+static BYTE ReadBSprm( const WW8PLCFx_SEPX* pSep, USHORT nId, BYTE nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ BYTE nVal = ( pS ) ? SVBT8ToByte( pS ) : nDefaultVal;
+ return nVal;
+}
+
+// dito, aber mit Return, ob vorhanden
+static BOOL ReadBSprmRet( BYTE& rnRet, const WW8PLCFx_SEPX* pSep, USHORT nId,
+ BYTE nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ if( pS ){
+ rnRet = SVBT8ToByte( pS );
+ return TRUE;
+ }else{
+ rnRet = nDefaultVal;
+ return FALSE;
+ }
+}
+
+static short ReadULSprm( const WW8PLCFx_SEPX* pSep, USHORT nId, short nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ short nVal = ( pS ) ? SVBT16ToShort( pS ) : nDefaultVal;
+ if( nVal < 0 ) // < 0 bedeutet: nicht verschieben, wenns nicht passt
+ nVal = -nVal;
+ return nVal;
+}
+
+static short ReadLRSprm( const WW8PLCFx_SEPX* pSep, USHORT nId, short nDefaultVal )
+{
+ BYTE* pS = pSep->HasSprm( nId ); // sprm da ?
+ short nVal = ( pS ) ? SVBT16ToShort( pS ) : nDefaultVal;
+ if( nVal < 0 ) // < 0 ist beim SW nicht erlaubt
+ nVal = 0;
+ return nVal;
+}
+
+
+// WW nimmt es mit den Groessen nicht so genau. Wird dieses nicht
+// korrigiert, dann erkennt es der Writer nur als Benutzergroesse
+// statt als richtiges Papierformat
+// AdjustSize() sucht nahe Papiergroessen raus, stark abweichende
+// Werte bleiben unveraendert.
+static SwTwips AdjustSize( USHORT nPara )
+{
+ static SwTwips aSizA[] = { lA3Height, lA3Width, lA4Width, lA5Width,
+ lB4Height, lB4Width, lB5Width, lB6Width, lC4Width, lC4Height,
+ lC5Width, lC6Width, lC65Width, lDLWidth, lDLHeight,lLetterWidth,
+ lLetterHeight, lLegalHeight, lTabloidWidth, lTabloidHeight };
+
+
+ SwTwips nSi = nPara;
+ for( USHORT i = 0; i < sizeof( aSizA ) / sizeof( aSizA[0] ); i++ ){
+ if( ( nSi - aSizA[i] < 5 )
+ && ( nSi - aSizA[i] > -5 ) ){
+ nSi = aSizA[i];
+ break;
+ }
+ }
+ return nSi;
+}
+
+
+void SwWW8ImplReader::RemoveCols( SwPageDesc& rPageDesc, SwFmtCol*& rpCol )
+{
+ SwFrmFmt &rFmt0 = rPageDesc.GetMaster();
+ const SwFmtCol rCol = rFmt0.GetCol();
+ if( rCol.GetNumCols() )
+ {
+ rpCol = new SwFmtCol( rCol );
+ SwFmtCol aCol;
+ rFmt0.SetAttr( aCol );
+ rPageDesc.GetLeft().SetAttr( aCol );
+ }
+ else
+ rpCol = 0;
+}
+
+
+BOOL SwWW8ImplReader::SetCols( SwFrmFmt* pFmt,
+ const WW8PLCFx_SEPX* pSep,
+ USHORT nNettoWidth,
+ BOOL bTestOnly )
+{
+ if( nIniFlags & WW8FL_NO_COLS ) // ausgeschaltet
+ return FALSE;
+
+ //sprmSCcolumns - Anzahl der Spalten - 1
+ USHORT nCols = ReadSprm( pSep, (bVer67 ? 144 : 0x500B), 0 );
+
+ nCols ++; // Zahl der SW-Spalten
+ if( nCols < 2 )
+ return FALSE; // keine oder bloedsinnige Spalten
+
+ if( bTestOnly )
+ return TRUE;
+
+ if( !pFmt )
+ {
+ ASSERT( !this, "code error: pFmt hat Zero value!" );
+ return FALSE;
+ }
+
+ SwFmtCol aCol; // Erzeuge SwFmtCol
+
+ //sprmSDxaColumns - Default-Abstand 1.25 cm
+ USHORT nColSpace = ReadUSprm( pSep, (bVer67 ? 145 : 0x900C), 708 );
+
+ // sprmSLBetween
+ if( ReadBSprm( pSep, (bVer67 ? 158 : 0x3019), 0 ) )
+ {
+ aCol.SetLineAdj( COLADJ_TOP ); // Line
+ aCol.SetLineHeight( 100 );
+ aCol.SetLineColor( Color( COL_BLACK ));
+ aCol.SetLineWidth( 1 );
+ }
+
+ // sprmSFEvenlySpaced
+ BOOL bEven = ReadBSprm( pSep, (bVer67 ? 138 : 0x3005), 1 );
+
+ if( bEven ) // alle Spalten sind gleich
+ aCol.Init( nCols, nColSpace, nNettoWidth );
+ else
+ {
+ aCol.Init( nCols, nColSpace, USHRT_MAX );
+ // Spalten unterschiedlich breit: fein, das kann der Writer inzwischen!
+ USHORT nWishWidth = 0, nLeftDist = 0, nRightDist = 0;
+ USHORT i;
+ for( i = 0; i < nCols; i++ )
+ {
+ SwColumn* pCol = aCol.GetColumns()[ i ];
+ pCol->SetLeft( nLeftDist );
+
+ if( i < nCols-1 )
+ {
+ //sprmSDxaColSpacing
+ BYTE* pSD = pSep->HasSprm( (bVer67 ? 137 : 0xF204), BYTE( i ) );
+
+ ASSERT( pSD, "+Sprm 137 (bzw. 0xF204) (Colspacing) fehlt" );
+ if( pSD )
+ {
+ USHORT nSp = SVBT16ToShort( pSD + 1 );
+ nRightDist = nSp / 2;
+
+ pCol->SetRight( nSp - nRightDist );
+ }
+ }
+ else
+ nRightDist = 0; // letzte Spalte hat keinen Zwischenraum mehr
+
+ //sprmSDxaColWidth
+ BYTE* pSW = pSep->HasSprm( (bVer67 ? 136 : 0xF203), BYTE( i ) );
+
+ ASSERT( pSW, "+Sprm 136 (bzw. 0xF203) (ColWidth) fehlt" );
+ if( pSW )
+ pCol->SetWishWidth( SVBT16ToShort( pSW + 1 )
+ + nLeftDist
+ + pCol->GetRight() );
+ // aufsummierte Spaltenbreiten ergeben Gesamtbreite
+ nWishWidth += pCol->GetWishWidth();
+ // Halber Abstand ist an naechster Spalte noch zu setzen
+ nLeftDist = nRightDist;
+ }
+ aCol.SetWishWidth( nWishWidth );
+
+#ifdef niemalsdef
+ // beim RTF-Import:
+ aCol._SetOrtho( FALSE );
+ USHORT nWishWidth = 0, nHalfPrev = 0;
+ for( USHORT n = 0, i = 0; n < aColumns.Count(); n += 2, ++i )
+ {
+ SwColumn* pCol = aCol.GetColumns()[ i ];
+ pCol->SetLeft( nHalfPrev );
+ USHORT nSp = aColumns[ n+1 ];
+ nHalfPrev = nSp / 2;
+ pCol->SetRight( nSp - nHalfPrev );
+ pCol->SetWishWidth( aColumns[ n ] +
+ pCol->GetLeft() + pCol->GetRight() );
+ nWishWidth += pCol->GetWishWidth();
+ }
+ aCol.SetWishWidth( nWishWidth );
+#endif
+ }
+ pFmt->SetAttr( aCol );
+ return TRUE;
+}
+
+// SetPage1() setzt Orientierung, Papiergroesse, LRRaender, Spalten
+void SwWW8ImplReader::SetPage1( SwPageDesc* pPageDesc, SwFrmFmt &rFmt,
+ const WW8PLCFx_SEPX* pSep, USHORT nLIdx,
+ BOOL bIgnoreCols )
+{
+ if( nIniFlags & WW8FL_NO_LRUL ) // Abgeschaltet
+ return;
+
+ static USHORT __READONLY_DATA aVer67Ids[] = {
+/*sprmSBOrientation*/ 162,
+/*sprmSXaPage*/ 164,
+/*sprmSYaPage*/ 165,
+/*sprmSDxaLeft*/ 166,
+/*sprmSDxaRight*/ 167,
+/*sprmSDzaGutter*/ 170
+ };
+
+ static USHORT __READONLY_DATA aVer8Ids[] = {
+/*sprmSBOrientation*/ 0x301d,
+/*sprmSXaPage*/ 0xB01F,
+/*sprmSYaPage*/ 0xB020,
+/*sprmSDxaLeft*/ 0xB021,
+/*sprmSDxaRight*/ 0xB022,
+/*sprmSDzaGutter*/ 0xB025
+ };
+
+ const USHORT* pIds = bVer67 ? aVer67Ids : aVer8Ids;
+
+ // 1. Orientierung
+ pPageDesc->SetLandscape( 0 != ReadBSprm( pSep, pIds[0], 0 ) );
+
+ // 2. Papiergroesse
+ SwFmtFrmSize aSz( rFmt.GetFrmSize() );
+ aSz.SetWidth( AdjustSize( ReadUSprm( pSep, pIds[1], (USHORT)lLetterWidth )));
+
+ nPgWidth = (short)aSz.GetWidth(); // Merken fuer Tabellen u. ae.
+ aSz.SetHeight( AdjustSize( ReadUSprm( pSep, pIds[2], (USHORT)lLetterHeight )));
+
+ rFmt.SetAttr( aSz );
+
+ // 3. LR-Raender
+ // Default-Raender fuer verschiedene nationale Versionen
+ static USHORT __READONLY_DATA nLef[] = { MM_250, 1800 };
+ static USHORT __READONLY_DATA nRig[] = { MM_250, 1800 };
+
+ short nWWLe = ReadULSprm( pSep, pIds[3], nLef[nLIdx] );
+ short nWWRi = ReadULSprm( pSep, pIds[4], nRig[nLIdx] );
+ short nWWGu = ReadULSprm( pSep, pIds[5], 0 );
+
+ nWWLe += nWWGu;
+
+ // Left / Right
+ rFmt.SetAttr( SvxLRSpaceItem( nWWLe, nWWRi ) );
+
+ nPgLeft = nWWLe;
+ nPgRight = nWWRi;
+
+ if( !bIgnoreCols )
+ {
+ // 4. Spalten
+ SetCols( &rFmt, pSep, aSz.GetWidth() - nWWLe - nWWRi );
+ }
+}
+
+
+
+
+struct WW8ULSpaceData
+{
+ BOOL bHasHeader, bHasFooter;
+ short nSwHLo, nHdUL,
+ nSwFUp, nFtUL,
+ nSwUp, nSwLo;
+ WW8ULSpaceData(): bHasHeader( FALSE ), bHasFooter( FALSE ){}
+};
+
+void SwWW8ImplReader::GetPageULData( const WW8PLCFx_SEPX* pSep,
+ USHORT nLIdx,
+ BOOL bFirst,
+ WW8ULSpaceData& rData )
+{
+ if( nIniFlags & WW8FL_NO_LRUL ) // abgeschaltet
+ return;
+
+ // Default-Raender fuer verschiedene nationale Versionen
+ static USHORT __READONLY_DATA nTop[] = { MM_250, 1440 };
+ static USHORT __READONLY_DATA nBot[] = { MM_200, 1440 };
+
+ // Einlesen der WW-Einstellungen
+
+ static USHORT __READONLY_DATA aVer67Ids[] = {
+/*sprmSDyaTop*/ 168,
+/*sprmSDyaBottom*/ 169,
+/*sprmSDyaHdrTop*/ 156,
+/*sprmSDyaHdrBottom*/ 157
+ };
+ static USHORT __READONLY_DATA aVer8Ids[] = {
+/*sprmSDyaTop*/ 0x9023,
+/*sprmSDyaBottom*/ 0x9024,
+/*sprmSDyaHdrTop*/ 0xB017,
+/*sprmSDyaHdrBottom*/ 0xB018
+ };
+
+ const USHORT* pIds = bVer67 ? aVer67Ids : aVer8Ids;
+
+ short nWWUp = ReadULSprm( pSep, pIds[0], nTop[nLIdx] );
+ short nWWLo = ReadULSprm( pSep, pIds[1], nBot[nLIdx] );
+ short nWWHTop = ReadULSprm( pSep, pIds[2], MM_125 );
+ short nWWFBot = ReadULSprm( pSep, pIds[3], MM_125 );
+
+ if( bFirst )
+ rData.bHasHeader = (nCorrIhdt & WW8_HEADER_FIRST )!=0;
+ else
+ rData.bHasHeader = (nCorrIhdt & (WW8_HEADER_EVEN | WW8_HEADER_ODD))!=0;
+
+ if( rData.bHasHeader )
+ {
+ rData.nSwUp = nWWHTop; // Header -> umrechnen
+ rData.nSwHLo = nWWUp - nWWHTop;
+#ifdef NEW_MINHDSIZ
+ if( rData.nSwHLo < MINLAY )
+ rData.nSwHLo = MINLAY;
+#else // NEW_MINHDSIZ
+ if( nIniHdSiz )
+ rData.nSwHLo -= (short)nIniHdSiz;
+ else if( nHdTextHeight )
+ rData.nSwHLo -= (short)nHdTextHeight;
+ else
+ rData.nSwHLo -= 240;
+
+ if( rData.nSwHLo < 0 )
+ rData.nSwHLo = 0;
+#endif // NEW_MINHDSIZ
+ }
+ else // kein Header -> Up einfach uebernehmen
+ rData.nSwUp = nWWUp;
+
+ if( bFirst )
+ rData.bHasFooter = (nCorrIhdt & WW8_FOOTER_FIRST )!=0;
+ else
+ rData.bHasFooter = (nCorrIhdt & (WW8_FOOTER_EVEN | WW8_FOOTER_ODD))!=0;
+
+ if( rData.bHasFooter )
+ {
+ rData.nSwLo = nWWFBot; // Footer -> Umrechnen
+ rData.nSwFUp = nWWLo - nWWFBot;
+
+#if 0
+ if( rData.nSwFUp < MINLAY )
+ rData.nSwFUp = MINLAY;
+#else // 0
+ if( nIniFtSiz )
+ rData.nSwFUp -= (short)nIniFtSiz;
+ else if( nFtTextHeight )
+ rData.nSwFUp -= (short)nFtTextHeight;
+ else
+ rData.nSwFUp -= 240;
+
+ if( rData.nSwFUp < 0 )
+ rData.nSwFUp = 0;
+#endif // !0
+ }
+ else // kein Footer -> Lo einfach uebernehmen
+ rData.nSwLo = nWWLo;
+
+ nPgTop = rData.nSwUp;
+}
+
+
+void SwWW8ImplReader::SetPageULSpaceItems( SwFrmFmt &rFmt, WW8ULSpaceData& rData )
+{
+ if( nIniFlags & WW8FL_NO_LRUL ) // deactivated ?
+ return;
+
+ if( rData.bHasHeader ) // ... und Header-Lower setzen
+ {
+ SwFrmFmt* pHdFmt = (SwFrmFmt*)rFmt.GetHeader().GetHeaderFmt();
+ if( pHdFmt )
+ {
+#ifdef NEW_MINHDSIZ
+// Kopfzeilenhoehe minimal sezten
+ pHdFmt->SetAttr( SwFmtFrmSize( ATT_MIN_SIZE, 0, rData.nSwHLo ) );
+#else // NEW_MINHDSIZ
+ SvxULSpaceItem aHdUL( pHdFmt->GetULSpace() );
+ aHdUL.SetLower( rData.nSwHLo );
+ pHdFmt->SetAttr( aHdUL );
+#endif // NEW_MINHDSIZ
+ }
+ }
+
+ if( rData.bHasFooter ) // ... und Footer-Upper setzen
+ {
+ SwFrmFmt* pFtFmt = (SwFrmFmt*)rFmt.GetFooter().GetFooterFmt();
+ if( pFtFmt )
+ {
+#if 0
+// Fusszeilenhoehe minimal sezten
+ pFtFmt->SetAttr( SwFmtFrmSize( ATT_MIN_SIZE, 0, rData.nSwFUp ) );
+#else // 0
+ SvxULSpaceItem aFtUL( pFtFmt->GetULSpace() );
+ aFtUL.SetUpper( rData.nSwFUp );
+ pFtFmt->SetAttr( aFtUL );
+#endif // !0
+ }
+ }
+ SvxULSpaceItem aUL( rData.nSwUp, rData.nSwLo ); // Page-UL setzen
+ rFmt.SetAttr( aUL );
+}
+
+
+
+
+void SwWW8ImplReader::SetPageBorder( SwPageDesc* pPageDesc0,
+ SwPageDesc* pPageDesc1,
+ const WW8PLCFx_SEPX* pSep,
+ USHORT nLIdx )
+{
+ WW8_BRC brc[4];
+ if( !bVer67 && ::lcl_ReadBorders( bVer67, brc, 0, 0, pSep ) &&
+ IsBorder( brc ))
+ {
+ short nPgbProp = ReadSprm( pSep, 0x522F, 0 ); //sprmSPgbProp
+
+ // ogbProp - pgbApplyTo
+ // 0 all Pages in this Section
+ // 1 first Page in this Section
+ // 2 all Pages in this Section but first
+ // 3 whole document (all Sections)
+ if( !pPageDesc0 && pPageDesc1 &&
+ ( 2 == (nPgbProp & 0x7 ) || 1 == (nPgbProp & 0x7 )) )
+ {
+ // dann muss aber einer angelegt werden
+ SwPaM* pPageDeskPaM = 0;
+ pPageDesc0 = CreatePageDesc( 0, &pPageDeskPaM );
+
+
+
+ // if PageDesc was inserted check for cols
+ // and insert section instead
+ if( pPageDeskPaM )
+ {
+ SwFrmFmt &rFmt = pPageDesc0->GetMaster();
+ SetPage1( pPageDesc0, rFmt, pSep, nLIdx, FALSE );
+ const SwFmtCol& rCol = rFmt.GetCol();
+ // if PageDesc has been inserted and has cols
+ // insert a *section* with cols instead
+ if( rCol.GetNumCols() )
+ {
+ InsertSectionWithWithoutCols( *pPaM, &rCol );
+ // remove columns from PageDesc
+ SwFmtCol aCol;
+ rFmt.SetAttr( aCol );
+ }
+ delete pPageDeskPaM;
+ }
+
+
+
+ rDoc.CopyPageDesc( *pPageDesc1, *pPageDesc0, FALSE );
+ pPageDesc0->SetFollow( pPageDesc1 );
+ pPageDesc1->SetFollow( pPageDesc1 );
+ }
+
+ SwFrmFmt* pFmt0 = 0, *pFmt1 = 0;
+ if( 2 != (nPgbProp & 0x7 ) && pPageDesc0 )
+ pFmt0 = &pPageDesc0->GetMaster();
+
+ if( 1 != (nPgbProp & 0x7 ) && pPageDesc1 )
+ pFmt1 = &pPageDesc1->GetMaster();
+
+ SvxBoxItem aBox;
+ SetBorder( aBox, brc );
+
+ Rectangle aInnerDist;
+ GetBorderDistance( brc, aInnerDist );
+
+ if( aInnerDist.Left() || aInnerDist.Top()
+ || aInnerDist.Right() || aInnerDist.Bottom() )
+ {
+ // das muss natuerlich von den Raendern abgezogen werden!
+ SwFrmFmt* pFmt = pFmt0;
+ for( int i = 0; i < 2; ++i, pFmt = pFmt1 )
+ if( pFmt )
+ {
+ SvxLRSpaceItem aLR( pFmt->GetLRSpace() );
+ SvxULSpaceItem aUL( pFmt->GetULSpace() );
+
+ if( 0x20 == ( nPgbProp & 0xe0 )) // distance from pageborder
+ {
+ // Left
+ if( aInnerDist.Left() < aLR.GetLeft() )
+ {
+ aLR.SetLeft( (USHORT)(aLR.GetLeft()
+ - aInnerDist.Left() ) );
+ aBox.SetDistance( (USHORT)aInnerDist.Left(),
+ BOX_LINE_LEFT );
+ }
+ else
+ {
+ aBox.SetDistance( aLR.GetLeft(), BOX_LINE_LEFT );
+ aLR.SetLeft( 0 );
+ }
+ // Right
+ if( aInnerDist.Right() < aLR.GetRight() )
+ {
+ aLR.SetRight( (USHORT)(aLR.GetRight()
+ - aInnerDist.Right() ) );
+ aBox.SetDistance( (USHORT)aInnerDist.Right(),
+ BOX_LINE_RIGHT );
+ }
+ else
+ {
+ aBox.SetDistance( aLR.GetRight(), BOX_LINE_RIGHT );
+ aLR.SetRight( 0 );
+ }
+ // Top
+ if( aInnerDist.Top() < aUL.GetUpper() )
+ {
+ aUL.SetUpper( (USHORT)(aUL.GetUpper()
+ - aInnerDist.Top() ) );
+ aBox.SetDistance( (USHORT)aInnerDist.Top(),
+ BOX_LINE_TOP );
+ }
+ else
+ {
+ aBox.SetDistance( aUL.GetUpper(), BOX_LINE_TOP );
+ aUL.SetUpper( 0 );
+ }
+ // Bottom
+ if( aInnerDist.Bottom() < aUL.GetLower() )
+ {
+ aUL.SetLower( (USHORT)(aUL.GetLower()
+ - aInnerDist.Bottom() ) );
+ aBox.SetDistance( (USHORT)aInnerDist.Bottom(),
+ BOX_LINE_BOTTOM );
+ }
+ else
+ {
+ aBox.SetDistance( aUL.GetLower(), BOX_LINE_BOTTOM );
+ aUL.SetLower( 0 );
+ }
+
+ pFmt->SetAttr( aLR );
+ pFmt->SetAttr( aUL );
+ pFmt->SetAttr( aBox );
+ }
+ else // distance from text
+ {
+ // Left
+ aBox.SetDistance( (USHORT)aInnerDist.Left(),
+ BOX_LINE_LEFT );
+ aLR.SetLeft( Max((long)0, (long)(aLR.GetLeft()
+ - (USHORT)aInnerDist.Left() )));
+ // Right
+ aBox.SetDistance( (USHORT)aInnerDist.Right(),
+ BOX_LINE_RIGHT );
+ aLR.SetRight(Max((long)0, (long)(aLR.GetRight()
+ - (USHORT)aInnerDist.Right() )));
+ // Top
+ aBox.SetDistance( (USHORT)aInnerDist.Top(),
+ BOX_LINE_TOP );
+ aUL.SetUpper(Max(0, aUL.GetUpper()
+ - (USHORT)aInnerDist.Top() ));
+ // Bottom
+ aBox.SetDistance( (USHORT)aInnerDist.Bottom(),
+ BOX_LINE_BOTTOM );
+ aUL.SetLower(Max(0, aUL.GetLower()
+ - (USHORT)aInnerDist.Bottom() ));
+
+ pFmt->SetAttr( aLR );
+ pFmt->SetAttr( aUL );
+ pFmt->SetAttr( aBox );
+ }
+ }
+
+ }
+ else
+ {
+ if( pFmt0 ) pFmt0->SetAttr( aBox );
+ if( pFmt1 ) pFmt1->SetAttr( aBox );
+ }
+
+
+ SvxShadowItem aS;
+ if( SetShadow( aS, aBox, brc))
+ {
+ if( pFmt0 ) pFmt0->SetAttr( aS );
+ if( pFmt1 ) pFmt1->SetAttr( aS );
+ }
+ }
+
+// if( nSwUp > rBox.GetDistance()) nSwUp -= rBox.GetDistance(); else nSwUp = 0;
+// if( nSwLo > rBox.GetDistance()) nSwLo -= rBox.GetDistance(); else nSwLo = 0;
+}
+
+void SwWW8ImplReader::SetUseOn( SwPageDesc* pPageDesc0, SwPageDesc* pPageDesc1,
+ const WW8PLCFx_SEPX* pSep, BYTE nCorrIhdt )
+{
+ BOOL bEven = nCorrIhdt & ( WW8_HEADER_EVEN | WW8_FOOTER_EVEN );
+
+ UseOnPage eUseBase = ( pWDop->fMirrorMargins ) ? PD_MIRROR : PD_ALL;
+ UseOnPage eUse = eUseBase;
+ if( !bEven )
+ eUse = (UseOnPage)( eUse | PD_HEADERSHARE | PD_FOOTERSHARE );
+
+ if( !pPageDesc1 ){ // 1 Pagedesc reicht
+
+ pPageDesc0->WriteUseOn( eUse ); // alle Seiten
+ }else{ // 2 Pagedescs noetig
+ pPageDesc0->WriteUseOn( (UseOnPage) // 1. Seite
+ ( eUseBase | PD_HEADERSHARE | PD_FOOTERSHARE ) );
+ pPageDesc1->WriteUseOn( eUse ); // Folgeseiten
+ }
+}
+
+
+void SwWW8ImplReader::InsertSectionWithWithoutCols( SwPaM& rMyPaM, const SwFmtCol* pCol )
+{
+ // if this Node is not empty create a new Node befor inserting the Section
+ const SwPosition* pPos = rMyPaM.GetPoint();
+ const SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
+ USHORT nCntPos = pPos->nContent.GetIndex();
+ if( nCntPos && pSttNd->GetTxt().Len() )
+ {
+ if( rMyPaM.HasMark() ) // do we have a SELECTION ?
+ {
+ SwNodeIndex aMarkNd( rMyPaM.GetMark()->nNode, -1 );
+ xub_StrLen nMarkCnt = rMyPaM.GetMark()->nContent.GetIndex();
+ rDoc.SplitNode( *pPos );
+
+ rMyPaM.Move( fnMoveBackward );
+ aMarkNd++;
+ rMyPaM.GetMark()->nNode = aMarkNd;
+ rMyPaM.GetMark()->nContent.Assign( aMarkNd.GetNode().GetCntntNode(), nMarkCnt );
+ }
+ else
+ rDoc.SplitNode( *pPos );
+ }
+
+ SwSection aSection( CONTENT_SECTION, rDoc.GetUniqueSectionName() );
+
+ SfxItemSet aSet( rDoc.GetAttrPool(), aFrmFmtSetRange );
+
+ if( pCol )
+ aSet.Put( *pCol );
+
+ if( 2 == pWDop->fpc )
+ aSet.Put( SwFmtFtnAtTxtEnd( FTNEND_ATTXTEND ));
+ if( 0 == pWDop->epc )
+ aSet.Put( SwFmtEndAtTxtEnd( FTNEND_ATTXTEND ));
+
+ pNewSection = rDoc.Insert( rMyPaM, aSection, &aSet );
+ ASSERT( !pBehindSection, "pBehindSection ungleich Null! why Recursion?");
+
+
+ // set PaM into first Node of the new Section
+ const SwSectionNode* pSectionNode =
+ pNewSection->GetFmt()->GetSectionNode();
+ ASSERT( pSectionNode, "Kein Inhalt vorbereitet." );
+
+
+ pBehindSection = new SwNodeIndex( *pSectionNode->EndOfSectionNode(), 1 );
+
+
+ rMyPaM.GetPoint()->nNode =
+ pSectionNode->GetIndex()+1;
+ rMyPaM.GetPoint()->nContent.Assign(
+ rMyPaM.GetCntntNode(), 0 );
+}
+
+
+
+// Bei jedem Abschnittswechsel ( auch am Anfang eines Dokuments ) wird
+// CreateSep gerufen, dass dann den / die Pagedesc(s) erzeugt und
+// mit Attributen un KF-Texten fuellt.
+// Dieses Vorgehen ist noetig geworden, da die UEbersetzung der verschiedenen
+// Seiten-Attribute zu stark verflochten ist.
+
+void SwWW8ImplReader::CreateSep(const long nTxtPos)
+{/*static BYTE __READONLY_DATA nHdFtType[] =
+ { WW8_HEADER_EVEN, WW8_HEADER_ODD,
+ WW8_FOOTER_EVEN, WW8_FOOTER_ODD,
+ WW8_HEADER_FIRST, WW8_FOOTER_FIRST };*/
+
+ if( bTxbxFlySection || bDontCreateSep )
+ {
+ return;
+ }
+
+
+ BYTE nLastSectionCorrIhdt = nCorrIhdt;
+ BOOL bLastSectionHadATitlePage = bSectionHasATitlePage;
+
+ // Might we have to close a section first?
+ BOOL bSectionWasJustClosed = pBehindSection && nTxtPos;
+ if( bSectionWasJustClosed )
+ {
+ // remove preceeding Node
+ // if a 0x0d came immediately before
+ if( 0 == pPaM->GetPoint()->nContent.GetIndex() )
+ JoinNode( pPaM );
+ // set PaM behind section
+ pPaM->GetPoint()->nNode = *pBehindSection;
+ pPaM->GetPoint()->nContent.Assign(
+ pPaM->GetCntntNode(), 0 );
+
+ DELETEZ( pBehindSection );
+ DELETEZ( pLastPgDeskIdx );
+ }
+
+ SwPageDesc* pOldPageDesc = pPageDesc;
+ SwPageDesc* pPageDesc1 = 0;
+ WW8PLCFx_SEPX* pSep = pPlcxMan->GetSepPLCF();
+
+
+ // check if Line Numbering must be activated or resetted
+ BYTE* pSprmSNLnnMod = bNew ? pSep->HasSprm( bVer67 ? 154 : 0x5015 ) : 0;
+ if( pSprmSNLnnMod && *pSprmSNLnnMod )
+ {
+ // restart-numbering-mode: 0 per page, 1 per section, 2 never restart
+ BYTE* pSprmSLnc = pSep->HasSprm( bVer67 ? 152 : 0x3013 );
+ bRestartLnNumPerSection = pSprmSLnc && 1 == *pSprmSLnc;
+
+ if( bNoLnNumYet )
+ {
+ SwLineNumberInfo aInfo( rDoc.GetLineNumberInfo() );
+
+ aInfo.SetPaintLineNumbers( TRUE );
+
+ aInfo.SetRestartEachPage( !pSprmSLnc || 0 == *pSprmSLnc );
+
+ BYTE* pSprmSDxaLnn = pSep->HasSprm( bVer67 ? 155:0x9016 );
+ if( pSprmSDxaLnn )
+ {
+ INT16 nSDxaLnn = SVBT16ToShort( pSprmSDxaLnn );
+ aInfo.SetPosFromLeft( nSDxaLnn );
+ }
+
+ aInfo.SetCountBy( *pSprmSNLnnMod ); //Paint only for every n line
+
+
+ // to be defaulted features ( HARDCODED in MS Word 6,7,8,9 )
+ aInfo.SetCountBlankLines( TRUE );
+ aInfo.SetCountInFlys( FALSE );
+ aInfo.SetPos( LINENUMBER_POS_LEFT );
+ SwNumType aNumType; // this sets SVX_NUM_ARABIC per default
+ aInfo.SetNumType( aNumType );
+
+
+ // to be ingnored features ( NOT existing in MS Word 6,7,8,9 )
+ // aInfo.SetDividerCountBy( nDividerCountBy );
+ // aInfo.SetDivider( sDivider );
+ // aInfo.SetCharFmt( pChrFmt );
+
+ rDoc.SetLineNumberInfo( aInfo );
+ bNoLnNumYet = FALSE;
+ }
+
+ BYTE* pSprmSLnnMin = pSep->HasSprm( bVer67 ? 160:0x501B );
+ if( ( pSprmSLnnMin
+ && 0 < *pSprmSLnnMin )
+ || ( bRestartLnNumPerSection
+ && !bNoLnNumYet ) )
+ {
+ SwFmtLineNumber aLN;
+ if( pSprmSLnnMin )
+ aLN.SetStartValue( 1 + *pSprmSLnnMin );
+ else
+ aLN.SetStartValue( 1 );
+
+ NewAttr( aLN );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_LINENUMBER );
+ }
+ bNoLnNumYet = FALSE;
+ }
+
+
+ // pruefen, ob und wie umzubrechen ist break code: 0 No break
+ // 1 New column
+ BYTE* pSprmBkc = pSep->HasSprm( bVer67 ? 142 : 0x3009 );// 2 New page
+ BYTE nBreakCode = pSprmBkc ? *pSprmBkc : 2; // 3 Even page
+ BOOL bContinuousBreak=(0 == nBreakCode); // 4 Odd page
+
+ // im wievielten Abschnitt stehen wir denn eigentlich?
+ nActSectionNo = (short)( pSep->GetIdx() & 0x00007fff );
+
+
+
+ /*
+ Welche Kopf-/Fuss-Bereiche sind
+ identisch mit dem Vorgaenger-Abschnitt?
+ */ // sprmSFTitlePage
+ bSectionHasATitlePage = (0 != ReadBSprm( pSep, bVer67 ? 143 : 0x300A, 0 ));
+
+ BYTE nIPara;
+
+ BYTE nJustCopyHdFt = 0; // HdFt that are stored in previous WW section prop
+ // and were NOT USED but may be copied now
+ BYTE nSameHdFt = 0; // HdFt that WERE the same in previous WW section
+
+ short aOldSectionNo[ 6 ];
+ memset( &aOldSectionNo, 0, sizeof( aOldSectionNo ) );
+
+ if( bVer67 )
+ {
+ // sprmSGprfIhdt
+ BOOL bSameHdFt = ( !ReadBSprmRet( nIPara, pSep, 153, 0 ) );
+
+ // Leere Hd/Ft will ich nicht
+ nCorrIhdt = pHdFt ? HdFtCorrectPara( nIPara ) : 0;
+ if( bSameHdFt )
+ {
+ nSameHdFt = 0xff;
+ nJustCopyHdFt = nSameHdFt;
+ }
+ }
+ else
+ {
+ if( !pHdFt )
+ nCorrIhdt = 0;
+ else
+ {
+ // nCorrIhdt ermitteln: WELCHE Hd/Ft sind ueberhaupt zu aktivieren?
+ //
+ nCorrIhdt = WW8_HEADER_ODD | WW8_FOOTER_ODD;
+
+ if( bSectionHasATitlePage )
+ nCorrIhdt |= WW8_HEADER_FIRST | WW8_FOOTER_FIRST;
+
+ if( pWDop->fFacingPages )
+ nCorrIhdt |= WW8_HEADER_EVEN | WW8_FOOTER_EVEN;
+
+ // den PLCF analysieren:
+ //
+ // Hd/Ft ist gleich, wenn die Laenge des Eintrags NULL ist
+ // oder die Ziel-Offsets identisch sind.
+ //
+ WW8_CP nStart;
+ WW8_CP nOldStart;
+ long nLen;
+ long nOldLen;
+ BYTE nHdFtInfosStored=0;
+
+ for( BYTE nI = 0, nMask = 1; nI < 6; nI++, nMask <<= 1 )
+ {
+ // 1st find ALL Hd/Ft infos that are stored in this WW section
+ // -- or in the sections before this one --
+ // regardless whether they are used in this section or not
+ pHdFt->GetTextPosExact( nI+ (nActSectionNo+1)*6, nStart, nLen );
+ if( !nLen || nActSectionNo )
+ {
+ short nOldSectionNo = nActSectionNo;
+ do
+ {
+ --nOldSectionNo;
+ pHdFt->GetTextPosExact( nI + (nOldSectionNo+1)*6,
+ nOldStart,
+ nOldLen);
+ if( nOldLen )
+ aOldSectionNo[ nI ] = nOldSectionNo;
+ }
+ while( nOldSectionNo && !nOldLen );
+ }
+ if( nLen || nOldLen )
+ nHdFtInfosStored |= nMask;
+
+
+ if( nCorrIhdt & nMask )
+ {
+ if( nActSectionNo )
+ {
+ if( !nLen
+ || ( (nOldStart == nStart)
+ && (nOldLen == nLen ) ) )
+ {
+ // same Hd/Ft as in previous Section or NO Hd/Ft
+ if( nHdFtInfosStored & nMask )
+ {
+ // prev. sect. really DID have and USE the Hd/Ft
+ if( nLastSectionCorrIhdt & nMask )
+ nJustCopyHdFt |= nMask;
+ // Hd/Ft may be found in one of prev. sections
+ nSameHdFt |= nMask;
+ }
+ else
+ nCorrIhdt &= ~nMask;// NO prev. Hd/Ft at all
+ }
+ }
+ else
+ if( !nLen )
+ nCorrIhdt &= ~nMask;// 0 in 1.Sect.: Hd/Ft undefined
+ }
+ }
+ }
+ // Einlese-Flag auf Use-On-Flag setzen
+ nIPara = nCorrIhdt;
+ }
+
+
+ USHORT nLIdx = ( ( pWwFib->lid & 0xff ) == 0x9 ) ? 1 : 0;
+
+ // sprmSNfcPgn
+ BYTE nLastNfcPgn = nNfcPgn;
+ nNfcPgn = ReadBSprm( pSep, (bVer67 ? 147 : 0x300E), 0 );
+ if( nNfcPgn > 4 ) nNfcPgn = 0;
+
+
+ /*
+ Pruefen, ob wir uns den neuen Abschnitt schenken koennen, da kein
+ Umbruch erforderlich ist.
+ */
+ if( pSep->GetIMax() > 1 )
+ {
+ if( nActSectionNo )
+ {
+ // Index eins zurueck setzen
+ pSep->SetIdx( nActSectionNo-1 );
+ // Attribute von vorigem Abschnitt einlesen
+ WW8PLCFxDesc aOther;
+ pSep->GetSprms( &aOther );
+ long nOtherSprmsLen = aOther.nSprmsLen;
+ // Kopie der vorigen Attr. anlegen, da sie gleich ueberschrieben werden
+ BYTE* pOtherMem = new BYTE[ nOtherSprmsLen ];
+ memcpy( pOtherMem, aOther.pMemPos, nOtherSprmsLen );
+ // Index wieder richtig setzen
+ pSep->SetIdx( nActSectionNo );
+ // aktuelle Attribute einlesen
+ WW8PLCFxDesc aCur;
+ pSep->GetSprms( &aCur );
+ // zu ignorierende Attribute sammeln
+ SvUShortsSort aIgnore(9, 1);
+ if( bContinuousBreak )
+ {
+ /*
+ zu 'sprmSBkc':
+ Wir sehen zwei WW-Abschnitte auch dann als gleich an,
+ wenn sie sich lediglich im break code unterscheiden.
+ Natuerlich muessen die Kopf/Fuss-Bereiche identisch sein.
+
+ Ignoriert werden auch die folgenden,
+ spaltenbezogene Flags:
+ SCcolumns, SDxaColumns, SDxaColWidth,
+ SDxaColSpacing, SFEvenlySpaced, SLBetween
+ und: SFFacingCol (nur bei Ver8)
+
+ We will also ignore a different formatting of the page number here.
+
+ We will also ignore different line numbering settings here
+ since only the very 1st line numbering settings are taken
+ into account anyway, see: bNoLnNum
+ */
+ static USHORT __READONLY_DATA aVer67Ids[ 13 ] =
+ {136, 137, 138, 139, 142, 144, 145, 147, 152, 154, 155, 158, 160};//sortiert!
+ static USHORT __READONLY_DATA aVer8Ids[ 14] =
+ {0x3005, 0x3006, 0x3009, 0x300E, 0x3013, 0x3019, 0x3229, 0x500B, 0x5015, 0x501B,
+ 0x900C, 0x9016, 0xF203, 0xF204};//sortiert!
+ if( bVer67 )
+ aIgnore.Insert( aVer67Ids, 13);
+ else
+ aIgnore.Insert( aVer8Ids, 14);
+ }
+
+ // nachschauen, ob die nicht zu ignor. Attr. gleich sind
+ BOOL bEqual = (bSectionHasATitlePage ==bLastSectionHadATitlePage)
+ && (nCorrIhdt == nLastSectionCorrIhdt)
+ && (nCorrIhdt == (nCorrIhdt & nJustCopyHdFt))
+ && (nNfcPgn == nLastNfcPgn)
+ && pSep->CompareSprms(pOtherMem,
+ nOtherSprmsLen,
+ &aIgnore);
+ // Kopie der vorigen Attr. wieder freigeben
+ delete pOtherMem;
+
+ if( bEqual )
+ {
+ switch( nBreakCode )
+ {
+ case 0:
+ {
+ if( 0 < pPaM->GetPoint()->nContent.GetIndex() )
+ rDoc.AppendTxtNode( *pPaM->GetPoint() );
+ // Abschnittsweschsel: neuer Bereich
+ SwSection aSection( CONTENT_SECTION,
+ rDoc.GetUniqueSectionName() );
+
+ SfxItemSet aSet( rDoc.GetAttrPool(), aFrmFmtSetRange );
+ if( 2 == pWDop->fpc )
+ aSet.Put( SwFmtFtnAtTxtEnd( FTNEND_ATTXTEND ));
+ if( 3 == pWDop->epc )
+ aSet.Put( SwFmtEndAtTxtEnd( FTNEND_ATTXTEND ));
+
+ pNewSection = rDoc.Insert( *pPaM, aSection, &aSet );
+ pBehindSection = new SwNodeIndex( pPaM->GetPoint()->nNode );
+
+ // Anzahl der Spalten einstellen
+ if( pPageDesc )
+ {
+ SwFrmFmt& rFmt = pPageDesc->GetMaster();
+ const SwFmtFrmSize& rSz = rFmt.GetFrmSize();
+ const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
+ SwTwips nWidth = rSz.GetWidth();
+ USHORT nLeft = rLR.GetTxtLeft();
+ USHORT nRight = rLR.GetRight();
+ SetCols( pNewSection->GetFmt(), pSep, nWidth - nLeft - nRight );
+ }
+ // PaM in Node der Section setzen
+ const SwSectionNode* pSectionNode =
+ pNewSection->GetFmt()->GetSectionNode();
+ ASSERT( pSectionNode, "Kein Inhalt vorbereitet." );
+ pPaM->GetPoint()->nNode =
+ pSectionNode->GetIndex()+1;
+ pPaM->GetPoint()->nContent.Assign(
+ pPaM->GetCntntNode(), 0 );
+ }
+
+ break;
+ case 1: if( bNew )
+ rDoc.Insert(*pPaM,
+ SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE ));
+ break;
+ //case 2:
+ //case 3: // alle drei Faelle -> PgDesc-Format-Einfuegung
+ //case 4:
+ default: {
+ /*
+ Wir koennen den aktuellen PgDesk einsetzen,
+ da dies immer der 1st-Page Deskriptor ist,
+ nie der Follow!
+ So geht es, auch wenn der Break auf Seite 7
+ kommt, wieder mit einer ERSTEN Seite weiter.
+ */
+ if( bNew )
+ {
+ if( 0 < pPaM->GetPoint()->nContent.GetIndex() )
+ rDoc.AppendTxtNode( *pPaM->GetPoint() );
+
+ if( pPageDesc )
+ rDoc.Insert(*pPaM, SwFmtPageDesc( pPageDesc ));
+ else
+ // kein voriger PgDesc vorhanden?
+ rDoc.Insert(*pPaM,
+ SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ));
+ SetLastPgDeskIdx();
+ }
+ }break;
+ }
+ return;
+ // ======== Das war's Freunde, jetzt nichts wie weg hier!
+ }
+ }
+ if( bNew
+ && ( bSectionWasJustClosed
+ || (pPageDesc != &rDoc._GetPageDesc( 0 )) ) )
+ {
+ // Create and *insert* PageDesc
+ SwPaM* pPageDeskPaM = 0;
+ pPageDesc = CreatePageDesc( 0, &pPageDeskPaM );
+ SwFrmFmt &rFmt = pPageDesc->GetMaster();
+ SetPage1( pPageDesc, rFmt, pSep, nLIdx, FALSE );
+ // if PageDesc has been inserted and has cols
+ // insert a *section* with cols instead
+ if( pPageDeskPaM )
+ {
+ const SwFmtCol& rCol = rFmt.GetCol();
+ if( rCol.GetNumCols() )
+ {
+ InsertSectionWithWithoutCols( *pPaM, &rCol );
+ // remove columns from PageDesc
+ SwFmtCol aCol;
+ rFmt.SetAttr( aCol );
+ }
+ delete pPageDeskPaM;
+ }
+ }
+ }
+ else
+ if( bNew )
+ pPageDesc = &rDoc._GetPageDesc( 0 ); // Standard
+
+ if( !bNew )
+ return;
+
+
+ // Seitennummernformat speichern
+ {
+ static SvxExtNumType __READONLY_DATA aNumTyp[ 5 ] = {
+ SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER,
+ SVX_NUM_CHARS_UPPER_LETTER_N, SVX_NUM_CHARS_LOWER_LETTER_N };
+
+ SwNumType aType; aType.eType = aNumTyp[ nNfcPgn ];
+ pPageDesc->SetNumType( aType );
+ }
+
+ if( !bVer67 )
+ {
+ // Seitennummer neu starten - sprmSFPgnRestart
+ {
+ BYTE nfPgnRestart = ReadBSprm( pSep, 0x3011, 0 );
+ if( nfPgnRestart )
+ {
+ const SfxPoolItem* pItem;
+ const SfxItemSet* pSet;
+ if( ( 0 != (pSet = pPaM->GetCntntNode()->GetpSwAttrSet()) )
+ && ( SFX_ITEM_SET ==
+ pSet->GetItemState(RES_PAGEDESC, FALSE, &pItem) ) )
+ {
+ // read Pagination Start attribute - sprmSPgnStart
+ BYTE nPgnStart = ReadBSprm( pSep, 0x501C, 0 );
+ ((SwFmtPageDesc*)pItem)->SetNumOffset( nPgnStart );
+ }
+ else
+ if( pPageDesc == &rDoc.GetPageDesc( 0 ) )
+ {
+ // read Pagination Start attribute - sprmSPgnStart
+ BYTE nPgnStart = ReadBSprm( pSep, 0x501C, 0 );
+ SwFmtPageDesc aPgDesc( pPageDesc );
+ aPgDesc.SetNumOffset( nPgnStart );
+ rDoc.Insert( *pPaM, aPgDesc );
+ SetLastPgDeskIdx();
+ }
+ }
+ }
+
+ // Chapterlevel und Chapterdelimiter ? (sprmScnsPgn & sprmSiHeadingPgn)
+ BYTE* p = pSep->HasSprm( 0x3001 );
+ if( p && *p )
+ {
+ bPgChpLevel = TRUE;
+ nPgChpLevel = *p - 1;
+ if( MAXLEVEL <= nPgChpLevel )
+ nPgChpLevel = MAXLEVEL - 1;
+
+ if( 0 != (p = pSep->HasSprm( 0x3000 )) )
+ nPgChpDelim = *p;
+ else
+ nPgChpDelim = 0;
+ }
+ else
+ bPgChpLevel = FALSE;
+ }
+
+ // Vorsicht: gibt es ueberhaupt einen vorigen Page Descriptor?
+ if( !pOldPageDesc )
+ nSameHdFt = 0;
+
+ SwFrmFmt &rFmt0 = pPageDesc->GetMaster();
+
+ if( !bSectionHasATitlePage )
+ {
+ // Gegebenenfalls Einstellungen des vorigen PgDesc uebernehmen
+ // und das Einlese-Flag entsprechend korrigieren,
+ // damit nur noch die Eintraege gelesen werden, die NICHT
+ // vom vorigen PgDesc zu uebernehmen sind.
+ //
+ if( 0 < nSameHdFt )
+ {
+ CopyPageDescHdFt( pOldPageDesc, pPageDesc, nSameHdFt );
+ if( bVer67 )
+ nIPara = 0;
+ else
+ nIPara &= ~nSameHdFt;
+ }
+
+ WW8ULSpaceData aULData;
+ GetPageULData( pSep, nLIdx, FALSE, aULData );
+
+ // dann Header / Footer lesen, falls noch noetig
+ //
+ if( nIPara )
+ {
+ SetHdFt( pPageDesc, 0, pSep, nIPara );
+ }
+ // und uebrige Einstellungen updaten
+ //
+
+ SetPage1( pPageDesc, // Orientierung, Hoehe, Breite, Vertikale Formatierung
+ rFmt0,
+ pSep,
+ nLIdx,
+ TRUE );
+
+ SetPageULSpaceItems( rFmt0, aULData );
+ SetPageBorder( 0, pPageDesc, pSep, nLIdx );
+ }
+ else
+ {
+ // Hier beachten:
+ // ==============
+ //
+ // pPageDesc = erste Seite
+ // pPageDesc1 = Folge-Seiten
+ //
+
+
+ // erst folgende PageDesc-Werte einstellen:
+ //
+ // Orientierung, Hoehe, Breite
+ //
+ SetPage1( pPageDesc, // Orientierung, Hoehe, Breite, Vertikale Formatierung
+ rFmt0,
+ pSep,
+ nLIdx,
+ TRUE );
+
+ // dann den PageDesc1 anlegen fuer Folge-Seiten
+ //
+ pPageDesc1 = CreatePageDesc( pPageDesc );
+
+ // Gegebenenfalls Einstellungen des/der vorigen PgDesc uebernehmen
+ //
+ if( 0 < nSameHdFt )
+ {
+ // ggfs. erst den alten 1st-Seite-PgDesc suchen und dessen
+ // Einstellungen uebernehmen
+ //
+ if( nSameHdFt & (WW8_HEADER_FIRST | WW8_FOOTER_FIRST) )
+ {
+
+/*
+ // suchen
+ const SwPageDesc* pOld1stPageDesc = 0;
+
+ USHORT nSize = rDoc.GetPageDescCnt();
+ if( nSize )
+ {
+ for( USHORT n = 0; n < nSize; ++n )
+ {
+ const SwPageDesc& rPageDesc = rDoc.GetPageDesc( n );
+ if( (&rPageDesc != pOldPageDesc)
+ && (rPageDesc.GetFollow() == pOldPageDesc) )
+ {
+ pOld1stPageDesc = &rPageDesc;
+ break;
+ }
+ }
+ }
+ // uebernehmen
+ if( pOld1stPageDesc )
+ {
+ CopyPageDescHdFt( pOld1stPageDesc, pPageDesc,
+ nSameHdFt & (WW8_HEADER_FIRST | WW8_FOOTER_FIRST) );
+ }
+ else
+ {
+*/
+
+ if( pOldPageDesc == pOldPageDesc->GetFollow() )
+ {
+ // hoppla, die vorige Section hatte keine 1st Page?
+ //
+ // also: auslesen der in WW8 fuer die nicht vorhandene
+ // 1st Page gespeicherten Hd/Ft-Einstellungen...
+ //
+ // Beachte: pPageDesc1 MUSS hier mit uebergeben werden,
+ // obwohl wir dessen Werte ja eigentlich hier
+ // gar nicht einlesen wollen!
+ // Das macht aber nichts, denn wir stellen den
+ // "SetHdFt( nIPara )"-Parameter so ein, dass
+ // nur der 1.-Seite-PgDesc eingelesen wird.
+ //
+ short nSaveSectionNo = nActSectionNo;
+ if( bVer67 )
+ --nActSectionNo;
+ else
+ nActSectionNo = aOldSectionNo[ 4 ]
+ ? aOldSectionNo[ 4 ] // Hd 1st
+ : aOldSectionNo[ 5 ]; // Ft 1st
+ SetHdFt( pPageDesc, pPageDesc1, pSep,
+ nSameHdFt & (WW8_HEADER_FIRST | WW8_FOOTER_FIRST) );
+ nActSectionNo = nSaveSectionNo;
+ }
+ else
+ CopyPageDescHdFt( pOldPageDesc, pPageDesc,
+ nSameHdFt & (WW8_HEADER_FIRST | WW8_FOOTER_FIRST) );
+ }
+
+ // ggfs. Werte des vorigen PgDesc fuer Folge-Seiten uebernehmen
+ //
+ if( nSameHdFt & ( WW8_HEADER_EVEN | WW8_HEADER_ODD
+ | WW8_FOOTER_EVEN | WW8_FOOTER_ODD ) )
+ {
+ CopyPageDescHdFt( pOldPageDesc, pPageDesc1,
+ nSameHdFt & ( WW8_HEADER_EVEN | WW8_HEADER_ODD
+ | WW8_FOOTER_EVEN | WW8_FOOTER_ODD ) );
+ }
+ // das Einlese-Flag entsprechend korrigieren,
+ // damit nur noch die Eintraege gelesen werden, die NICHT
+ // von vorigem/n PgDesc(s) zu uebernehmen sind.
+ //
+ if( bVer67 )
+ nIPara = 0;
+ else
+ nIPara &= ~nSameHdFt;
+ }
+
+ SwFrmFmt &rFmt1 = pPageDesc1->GetMaster();
+
+ WW8ULSpaceData aULData0, aULData1;
+ GetPageULData( pSep, nLIdx, TRUE, aULData0 ); // Vertikale Formatierung
+ GetPageULData( pSep, nLIdx, FALSE, aULData1 ); // einzeln, da KF evtl. verschieden
+
+ // dann Header / Footer lesen, falls noch noetig
+ //
+ if( nIPara )
+ {
+ SetHdFt( pPageDesc, pPageDesc1, pSep, nIPara );
+ }
+
+ // und uebrige Einstellungen updaten
+ //
+ SetPageULSpaceItems( rFmt0, aULData0 ); // Vertikale Formatierung
+ SetPageULSpaceItems( rFmt1, aULData1 ); // einzeln, da KF evtl. verschieden
+ SetPageBorder( pPageDesc, pPageDesc1, pSep, nLIdx );
+ }
+
+
+ SetUseOn( pPageDesc, pPageDesc1, pSep, nCorrIhdt );
+
+
+ static BYTE __READONLY_DATA aPaperBinIds[ 17 ] =
+ {5,2,4,0,3,0,0,0,0,0,0,0,0,0,0,0,1};
+ // WW SW
+ // ------------------------------
+ // 0 == default 5
+ // 1 == Upper paper tray 2
+ // 2 == Lower paper tray 4
+ // 4 == Manual paper feed 3
+ // 15 == Automatically select 0
+ // 16 == First tray available 1
+
+ BYTE* pSprmSDmBinFirst = pSep->HasSprm( bVer67 ? 140 : 0x5007 );
+ BYTE* pSprmSDmBinOther = pSep->HasSprm( bVer67 ? 141 : 0x5008 );
+ if( pSprmSDmBinFirst && (17 > *pSprmSDmBinFirst) )
+ {
+ SvxPaperBinItem aItem( ITEMID_PAPERBIN, aPaperBinIds[ *pSprmSDmBinFirst ] );
+ pPageDesc->GetMaster().SetAttr( aItem );
+ }
+ if( pSprmSDmBinOther && (17 > *pSprmSDmBinOther) )
+ {
+ SvxPaperBinItem aItem( ITEMID_PAPERBIN, aPaperBinIds[ *pSprmSDmBinOther ] );
+ SwFrmFmt &rFmtOther = pPageDesc1 ? pPageDesc1->GetMaster() : pPageDesc->GetLeft();
+ rFmtOther.SetAttr( aItem );
+ }
+
+ // Kopf / Fuss - Index Updaten
+ if( pHdFt )
+ pHdFt->UpdateIndex( nCorrIhdt ); // Damit der Index auch spaeter noch stimmt
+
+ // Die Attribute OLST
+ // werden weiterhin ueber die WWSprmTab abgehandelt
+}
+
+
+void SwWW8ImplReader::CopyPageDescHdFt( const SwPageDesc* pOrgPageDesc,
+ SwPageDesc* pNewPageDesc, BYTE nCode )
+{
+ // copy first header content section
+ if( nCode & WW8_HEADER_FIRST )
+ {
+ rDoc.CopyHeader(pOrgPageDesc->GetMaster(),
+ pNewPageDesc->GetMaster());
+ }
+ // copy first footer content section
+ if( nCode & WW8_FOOTER_FIRST )
+ {
+ rDoc.CopyFooter(pOrgPageDesc->GetMaster(),
+ pNewPageDesc->GetMaster());
+ }
+ if( nCode & ( WW8_HEADER_ODD | WW8_FOOTER_ODD
+ | WW8_HEADER_EVEN | WW8_FOOTER_EVEN ) )
+ {
+ // determine PageDesc of follow pages
+ const SwPageDesc* pOrgFollowPageDesc = pOrgPageDesc->GetFollow();
+ // copy odd header content section
+ if( nCode & WW8_HEADER_ODD )
+ {
+ rDoc.CopyHeader(pOrgFollowPageDesc->GetMaster(),
+ pNewPageDesc->GetMaster() );
+ }
+ // copy odd footer content section
+ if( nCode & WW8_FOOTER_ODD )
+ {
+ rDoc.CopyFooter(pOrgFollowPageDesc->GetMaster(),
+ pNewPageDesc->GetMaster());
+ }
+ // copy even header content section
+ if( nCode & WW8_HEADER_EVEN )
+ {
+ rDoc.CopyHeader(pOrgFollowPageDesc->GetLeft(),
+ pNewPageDesc->GetLeft());
+ }
+ // copy even footer content section
+ if( nCode & WW8_FOOTER_EVEN )
+ {
+ rDoc.CopyFooter(pOrgFollowPageDesc->GetLeft(),
+ pNewPageDesc->GetLeft());
+ }
+ }
+}
+
+
+//------------------------------------------------------
+// Hilfsroutinen fuer Grafiken und Apos und Tabellen
+//------------------------------------------------------
+
+static BOOL _SetWW8_BRC( BOOL bVer67, WW8_BRC& rVar, BYTE* pS )
+{
+ if( pS )
+ if( bVer67 )
+ (WW8_BRCVer6&)rVar = *((WW8_BRCVer6*)pS);
+ else
+ rVar = *((WW8_BRC*)pS);
+ else
+ {
+ *(USHORT*)rVar.aBits1 = 0;
+ *(USHORT*)rVar.aBits2 = 0;
+ }
+
+ return 0 != pS;
+}
+
+BOOL lcl_ReadBorders( BOOL bVer67, WW8_BRC* brc,
+ WW8PLCFx_Cp_FKP* pPap,
+ const WW8RStyle* pSty,
+ const WW8PLCFx_SEPX* pSep )
+{
+// Ausgegend von diesen defines:
+// #define WW8_TOP 0
+// #define WW8_LEFT 1
+// #define WW8_BOT 2
+// #define WW8_RIGHT 3
+// #define WW8_BETW 4
+
+ BOOL bBorder = FALSE;
+ if( pSep )
+ {
+ if( !bVer67 )
+ {
+ BYTE* pSprm[4];
+
+ // sprmSBrcTop, sprmSBrcLeft, sprmSBrcBottom, sprmSBrcRight
+ if( pSep->Find4Sprms( 0x702B, 0x702C, 0x702D, 0x702E,
+ pSprm[0], pSprm[1], pSprm[2], pSprm[3] ) )
+ {
+ for( int i = 0; i < 4; ++i )
+ bBorder |= _SetWW8_BRC( bVer67, brc[ i ], pSprm[ i ] );
+ }
+ }
+ }
+ else
+ {
+
+ static USHORT __READONLY_DATA aVer67Ids[5] =
+ { 38, 39, 40, 41, 42 };
+
+ static USHORT __READONLY_DATA aVer8Ids[5] =
+ { 0x6424, 0x6425, 0x6426, 0x6427, 0x6428 };
+
+ const USHORT* pIds = bVer67 ? aVer67Ids : aVer8Ids;
+
+ if( pPap )
+ {
+ for( int i = 0; i < 5; ++i, ++pIds )
+ bBorder |= _SetWW8_BRC( bVer67, brc[ i ], pPap->HasSprm( *pIds ));
+ }
+ else if( pSty )
+ {
+ for( int i = 0; i < 5; ++i, ++pIds )
+ bBorder |= _SetWW8_BRC( bVer67, brc[ i ], pSty->HasParaSprm( *pIds ));
+ }
+ else
+ ASSERT( pSty || pPap, "WW8PLCFx_Cp_FKP and WW8RStyle "
+ "and WW8PLCFx_SEPX is 0" );
+ }
+
+ return bBorder;
+}
+
+
+
+static SvxBorderLine& Set1Border( BOOL bVer67, SvxBorderLine& rLine,
+ const WW8_BRC& rBor )
+{
+ // Deklarationen gemaess BOXITEM.HXX
+ WW8_DECL_LINETAB_ARRAY
+
+ // Match-Tabelle: verwandelt Ver67 Border Codes in Ver8-Typen
+ static USHORT __READONLY_DATA nTabBorderCode67ToCode8[] = // Aussenlinie
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 2, 2, 3, 0, 0, 0, 1, 2, 3, 4, 4, 1, 1,
+ WW8_DECL_LINETAB_OFS_DOUBLE +0,
+ WW8_DECL_LINETAB_OFS_DOUBLE +1,
+ WW8_DECL_LINETAB_OFS_DOUBLE +1,
+ WW8_DECL_LINETAB_OFS_DOUBLE +2,
+ WW8_DECL_LINETAB_OFS_DOUBLE +2,
+ WW8_DECL_LINETAB_OFS_DOUBLE +3,
+ WW8_DECL_LINETAB_OFS_DOUBLE +0,
+ WW8_DECL_LINETAB_OFS_DOUBLE +0
+ };
+
+
+ // Vor Aufruf muss sichergestellt werden, dass aBor & 0x1f != 0 ist,
+ // d.h. ueberhaupt eine Linie vorhanden ist
+
+// short nIdx = ( aBrc1 & 0x7 ) // aBor.dxpLineWidth ( Liniendicke )
+// + 8 * ( aBrc1 >> 3 & 0x3 ); // brcType, 0 = none / dotted / dashed
+ // 1 = single width, 2 = double width
+ // 3 = doppelte Linie ( = 3-fache Dicke )
+
+ BYTE nCol;
+ short nIdx;
+
+ if( bVer67 )
+ {
+ UINT16 aBrc1 = SVBT16ToShort( rBor.aBits1 );
+ nIdx = nTabBorderCode67ToCode8[ aBrc1 & 0x1f ];
+ nCol = ( (aBrc1 >> 6) & 0x1f ); // aBor.ico
+ }
+ else
+ {
+ // Sicherheitsmassnahme (Kodes ueber 25 sind undokumentiert)
+ nIdx = rBor.aBits1[1];
+ if( 25 < nIdx )
+ nIdx = 1;
+
+ // Angabe in 8tel Punkten, also mal 2.5, da 1 Punkt = 20 Twips
+ short nMSLineWidth = rBor.aBits1[ 0 ] * 20 / 8;
+ short nMSTotalWidth = nMSLineWidth;
+
+ // erst die Gesamt-Randbreite errechnen, zur weiteren Entscheidungsgrundlage
+ switch( nIdx )
+ {
+ /*
+ // Einzel-Linien sind Wurst
+ case 1:
+ case 2:
+ case 5:
+ case 6:
+ case 22:
+ case 7:
+ case 8:
+ case 9:
+ // Schraffurbalken dito
+ case 23:
+ */
+ // Mehrfach- und Spezial-Linien, die wir wie besonders behandeln
+ // (in der Reihenfolge, in der sie im Winword-97-Dialog erscheinen)
+ case 3: nMSTotalWidth = 3*nMSLineWidth;break;
+ case 10: nMSTotalWidth = 5*nMSLineWidth;break;
+ case 18:
+ case 17: nMSTotalWidth = 7*nMSLineWidth;break;
+ case 16:
+ case 19: nMSTotalWidth =12*nMSLineWidth;break;
+ case 20: nMSTotalWidth = 4*nMSLineWidth;break;
+ case 12:
+ case 11:
+ case 21: nMSTotalWidth = 6*nMSLineWidth;break;
+ case 13:
+ case 15:
+ case 14:
+ case 24:
+ case 25: nMSTotalWidth = 8*nMSLineWidth;break;
+ }
+
+ // dann auf unsere Randtypen mappen
+ switch( nIdx )
+ {
+ // zuerst die Einzel-Linien
+ case 1:
+ case 2:
+ case 5:
+ case 6:
+ case 22:
+ case 7:
+ case 8:
+ case 9:
+ // UND die Sonderfaelle, die wir durch eine Einzel-Linie
+ case 13: // bzw. notfalls durch eine Doppel-Linie darstellen
+ case 16:
+ case 19:
+ case 24:
+ case 25: if( nMSTotalWidth < 11) nIdx = 0;// 1 Twip bei uns
+ else if( nMSTotalWidth < 46) nIdx = 1;// 20 Twips
+ else if( nMSTotalWidth < 66) nIdx = 2;// 50
+ else if( nMSTotalWidth < 91) nIdx = 3;// 80
+ else if( nMSTotalWidth <126) nIdx = 4;// 100
+ // Pfusch: fuer die ganz dicken Linien muessen
+ // wir doppelte Linien malen, weil unsere
+ // Einfach-Linie nicht dicker als 5 Punkt wird
+ else if( nMSTotalWidth <166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+2;// 150
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+5;// 180
+ break;
+ // dann den Schraffurbalken, den wir durch eine doppelte Linie darstellen
+ case 23: nIdx = 6;
+ break;
+ // dann die Doppel-Linien, fuer die wir feine Entsprechungen haben :-)))
+ case 3:
+ case 10: if( nMSTotalWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nMSTotalWidth < 106) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 2;// 150
+ break;
+ case 12: if( nMSTotalWidth < 87) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 8;// 71 Twips bei uns
+ else if( nMSTotalWidth < 117) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 9;// 101
+ else if( nMSTotalWidth < 166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+10;// 131
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 5;// 180
+ break;
+ case 11: if( nMSTotalWidth < 137) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 4;// 90 Twips bei uns
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 6;// 180
+ break;
+ case 15: if( nMSTotalWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nMSTotalWidth < 106) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60
+ else if( nMSTotalWidth < 166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 2;// 150
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 5;// 180
+ break;
+ case 14: if( nMSTotalWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nMSTotalWidth < 76) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60
+ else if( nMSTotalWidth < 121) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 4;// 90
+ else if( nMSTotalWidth < 166) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 2;// 150
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 6;// 180
+ break;
+ case 18: if( nMSTotalWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nMSTotalWidth < 62) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 7;// 52
+ else if( nMSTotalWidth < 87) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 8;// 71
+ else if( nMSTotalWidth < 117) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 9;// 101
+ else if( nMSTotalWidth < 156) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+10;// 131
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 5;// 180
+ break;
+ case 17: if( nMSTotalWidth < 46) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 0;// 22 Twips bei uns
+ else if( nMSTotalWidth < 72) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 7;// 52
+ else if( nMSTotalWidth < 137) nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 4;// 90
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 6;// 180
+ break;
+ case 20: if( nMSTotalWidth < 46) nIdx = 1;// 20 Twips bei uns
+ else nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60
+ break;
+ case 21: nIdx = WW8_DECL_LINETAB_OFS_DOUBLE+ 1;// 60 Twips bei uns
+ break;
+
+ default: nIdx = 0;
+ }
+
+ nCol = rBor.aBits2[0]; // aBor.ico
+ }
+
+ const WW8_BordersSO& rBorders = nLineTabVer8[ nIdx ];
+ rLine.SetOutWidth( rBorders.Out );
+ rLine.SetInWidth ( rBorders.In );
+ rLine.SetDistance( rBorders.Dist );
+ rLine.SetColor( eSwWW8ColA[ nCol ] );
+
+ /*
+ Achtung: noch zu tun!!!
+ ========
+ eigentlich sollten wir uns jetzt die kumulierte Randbreite merken
+ ( als da waere: rBorders.Out + rBorders.In + rBorders.Dist )
+ und sie nach draussen melden, damit die aufrufenden Methoden ggfs.
+ die Objekt-Breiten entsprechend vergroessern!
+
+ Warum?
+ ======
+ Weil Winword die Raender a u s s e n drauf malt, wir hingegen sie
+ innen rein zeichnen, was bei uns zu einem kleineren Innenraum fuehrt!
+ */
+
+ return rLine;
+}
+
+
+BOOL lcl_IsBorder( BOOL bVer67, const WW8_BRC* pbrc, BOOL bChkBtwn=FALSE )
+{
+ if( bVer67 )
+ return ( pbrc[WW8_TOP ].aBits1[0] & 0x18 ) || // brcType != 0
+ ( pbrc[WW8_LEFT ].aBits1[0] & 0x18 ) ||
+ ( pbrc[WW8_BOT ].aBits1[0] & 0x18 ) ||
+ ( pbrc[WW8_RIGHT].aBits1[0] & 0x18 ) ||
+ ( bChkBtwn && ( pbrc[WW8_BETW ].aBits1[0] & 0x18 ));
+ // Abfrage auf 0x1f statt 0x18 ist noetig, da zumindest einige
+ // WW-Versionen ( 6.0 US ) bei dotted brcType auf 0 setzen
+ else
+ return pbrc[WW8_TOP ].aBits1[1] || // brcType != 0
+ pbrc[WW8_LEFT ].aBits1[1] ||
+ pbrc[WW8_BOT ].aBits1[1] ||
+ pbrc[WW8_RIGHT].aBits1[1] ||
+ (bChkBtwn && pbrc[WW8_BETW ].aBits1[1]);
+}
+
+BOOL SwWW8ImplReader::IsBorder( const WW8_BRC* pbrc, BOOL bChkBtwn )
+{
+ return lcl_IsBorder( bVer67, pbrc, bChkBtwn );
+}
+
+BOOL SwWW8ImplReader::SetBorder( SvxBoxItem& rBox, const WW8_BRC* pbrc,
+ BOOL bChkBtwn )
+{
+ SvxBorderLine aLine;
+ BOOL bChange = FALSE;
+ static USHORT __READONLY_DATA aIdArr[ 10 ] = {
+ WW8_TOP, BOX_LINE_TOP,
+ WW8_LEFT, BOX_LINE_LEFT,
+ WW8_RIGHT, BOX_LINE_RIGHT,
+ WW8_BOT, BOX_LINE_BOTTOM,
+ WW8_BETW, BOX_LINE_BOTTOM };
+
+
+ for( int i = 0, nEnd = 8; i < nEnd; i += 2 )
+ {
+ // ungueltige Borders ausfiltern
+ const WW8_BRC& rB = pbrc[ aIdArr[ i ] ];
+ if( !(( rB.aBits1[0] == 0xff && rB.aBits1[1] == 0xff ) ||
+ 0 == ( bVer67
+ ? ( rB.aBits1[0] & 0x001f ) // Version 6/7
+ : rB.aBits1[1] ) )) // Version 8
+ {
+ rBox.SetLine( &Set1Border( bVer67, aLine, rB ), aIdArr[ i+1 ] );
+ bChange = TRUE;
+ }
+ else if( 6 == i && bChkBtwn ) // wenn Botton nichts war,
+ nEnd += 2; // dann ggfs. auch Between befragen
+ }
+ return bChange;
+}
+
+
+BOOL SwWW8ImplReader::SetShadow( SvxShadowItem& rShadow,
+ const SvxBoxItem& rBox, const WW8_BRC pbrc[4] )
+{
+ BOOL bRet = ( bVer67 ? (pbrc[WW8_RIGHT].aBits1[ 1 ] & 0x20 )
+ : (pbrc[WW8_RIGHT].aBits2[ 1 ] & 0x20 ) ) &&
+ rBox.GetRight();
+ if( bRet )
+ {
+ rShadow.SetColor( Color( COL_BLACK ));
+
+// aS.SetWidth( 28 );
+// JP 19.11.98: abhaengig von der Breite der rechten Kante der Box
+ const SvxBorderLine& rLine = *rBox.GetRight();
+ rShadow.SetWidth( ( rLine.GetOutWidth() + rLine.GetInWidth() +
+ rLine.GetDistance() ) );
+
+ rShadow.SetLocation( SVX_SHADOW_BOTTOMRIGHT );
+ bRet = TRUE;
+ }
+ return bRet;
+}
+
+void SwWW8ImplReader::GetBorderDistance( WW8_BRC* pbrc, Rectangle& rInnerDist )
+{
+ //USHORT nInnerMargn = 0;
+
+ // 'dptSpace' is stored in 3 bits of 'Border Code (BRC)'
+ if( bVer67 )
+ rInnerDist = Rectangle(((pbrc[ 0 ].aBits1[1] >> 3) & 0x1f) * 20,
+ ((pbrc[ 1 ].aBits1[1] >> 3) & 0x1f) * 20,
+ ((pbrc[ 2 ].aBits1[1] >> 3) & 0x1f) * 20,
+ ((pbrc[ 3 ].aBits1[1] >> 3) & 0x1f) * 20 );
+ else
+ rInnerDist = Rectangle( (pbrc[ 0 ].aBits2[1] & 0x1f) * 20,
+ (pbrc[ 1 ].aBits2[1] & 0x1f) * 20,
+ (pbrc[ 2 ].aBits2[1] & 0x1f) * 20,
+ (pbrc[ 3 ].aBits2[1] & 0x1f) * 20 );
+
+ /*
+ for( int n = 0; n < 4; ++n )
+ nInnerMargn += ( pbrc[ n ].aBits2[1] & 0x1f); // dxpSpace
+ //return nInnerMargn * 5; // von Pt nach Twips / 4 Kanten
+ */
+}
+
+
+void SwWW8ImplReader::SetFlyBordersShadow( SfxItemSet& rFlySet,
+ const WW8_BRC pbrc[4],
+ USHORT nInnerMgn )
+{
+ if( IsBorder( pbrc ) )
+ {
+ SvxBoxItem aBox;
+ SetBorder( aBox, pbrc );
+
+ if( nInnerMgn )
+ aBox.SetDistance( nInnerMgn ); // Rand innen
+ rFlySet.Put( aBox );
+
+ // fShadow
+ SvxShadowItem aShadow;
+ if( SetShadow( aShadow, aBox, pbrc ))
+ rFlySet.Put( aShadow );
+ }
+}
+
+
+
+//-----------------------------------------
+// APOs
+//-----------------------------------------
+ // fuer Berechnung der minimalen FrameSize
+#define MAX_BORDER_SIZE 210 // so breit ist max. der Border
+#define MAX_EMPTY_BORDER 10 // fuer +-1-Fehler, mindestens 1
+
+
+static short GetLineWidth( BOOL bVer67, const WW8_BRC& rBor )
+{
+/*
+ register UINT16 nBits = SVBT16ToShort( rBor.aBits1 );
+ register short n = nBits & 0x7; // dxpLineWidth
+ if( n >= 6 )
+ n = 1;
+ return n * ( ( nBits >> 3 & 0x3 ) + 1 ) * 15; // aBor.brcType
+ // brcType Linien mit je n * 3/4 point Dicke
+*/
+
+/*
+JP 19.11.98: wenn dann muss es so richtig sein, die Version MUSS beachtet werden
+ UINT16 nIdx = bVer67 ? ((rBor.aBits1[ 0 ] & 0x18) >> 3) + 1
+ : rBor.aBits1[ 1 ];
+ UINT16 nWidth = bVer67 ? ((rBor.aBits1[ 0 ] & 0x7) * 15 ) // 3/4pt
+ : (rBor.aBits1[ 0 ] * 5 / 2); // 1/8pt
+ return nIdx * nWidth;
+*/
+
+//JP 19.11.98: aber warum werden nicht die SW-Borders zu Berechnung
+// herangezogen??
+ SvxBorderLine aLine;
+ ::Set1Border( bVer67, aLine, rBor );
+ return aLine.GetOutWidth() + aLine.GetInWidth() + aLine.GetDistance();
+}
+
+static void FlySecur1( short& rSize, const short nMgn1, const short nMgn2,
+ const BOOL bBorder )
+{
+ register short nMin = MINFLY
+ + ( bBorder ) ? MAX_BORDER_SIZE : MAX_EMPTY_BORDER;
+
+ if ( rSize < nMin )
+ rSize = nMin;
+}
+
+INLINE_AUSSER_HP BOOL SetValSprm( short* pVar, WW8PLCFx_Cp_FKP* pPap,
+ USHORT nId )
+{
+ register BYTE* pS = pPap->HasSprm( nId );
+ if( pS )
+ *pVar = (INT16)SVBT16ToShort( pS );
+ return ( pS != 0 );
+}
+
+INLINE_AUSSER_HP BOOL SetValSprm( short* pVar, const WW8RStyle* pStyle,
+ USHORT nId )
+{
+ register BYTE* pS = pStyle->HasParaSprm( nId );
+ if( pS )
+ *pVar = (INT16)SVBT16ToShort( pS );
+ return ( pS != 0 );
+}
+
+WW8FlyPara::WW8FlyPara( BOOL bIsVer67, const WW8FlyPara* pSrc /* = 0 */ )
+{
+ if ( pSrc )
+ memcpy( this, pSrc, sizeof( WW8FlyPara ) ); // Copy-Ctor
+ else
+ {
+ memset( this, 0, sizeof( WW8FlyPara ) ); // Default-Ctor
+ nSp37 = 2; // Default: Umfluss
+ }
+ bVer67 = bIsVer67;
+}
+
+
+// WW8FlyPara::operator == vergleicht alles, was in der Definition vor
+// den Borders steht!
+// dieses wird u.a. fuer TestSameApo benoetigt.
+int WW8FlyPara::operator == ( const WW8FlyPara& rSrc ) const
+{
+ ASSERT( ( (BYTE*)rSrc.brc - (BYTE*)&rSrc < sizeof( WW8FlyPara ) ),
+ "WW8FlyPara::operator == geht schief" );
+ return !memcmp( this, &rSrc, (BYTE*)rSrc.brc - (BYTE*)&rSrc );
+ // memcmp ist moeglich, da die gesamte Struktur beim Initialisieren
+ // incl. Luecken mit 0 gefuellt wird und sich damit durch die
+ // Luecken keine falschen Unterschiede ergeben koennen.
+ // Ausserdem sind alle Elemente aligned, so dass keine Luecken
+ // existieren
+}
+
+
+// Read fuer normalen Text
+
+BOOL WW8FlyPara::Read( BYTE* pSprm29, WW8PLCFx_Cp_FKP* pPap )
+{
+// WW8PLCFx_Cp_FKP* pPap = pPlcxMan->GetPapPLCF();
+
+ if( pSprm29 )
+ nSp29 = *pSprm29; // PPC ( Bindung )
+
+ BYTE* pS = 0;
+
+ if( bVer67 )
+ {
+ SetValSprm( &nSp26, pPap, 26 ); // X-Position //sprmPDxaAbs
+ SetValSprm( &nSp27, pPap, 27 ); // Y-Position //sprmPDyaAbs
+ SetValSprm( (short*)&nSp45, pPap, 45 ); // Hoehe //sprmPWHeightAbs
+ SetValSprm( (short*)&nSp28, pPap, 28 ); // Breite //sprmPDxaWidth
+ SetValSprm( &nSp49, pPap, 49 ); // L/R-Raender //sprmPDxaFromText
+ SetValSprm( &nSp48, pPap, 48 ); // U/L-Raender //sprmPDyaFromText
+
+ pS = pPap->HasSprm( 37 ); // Umfluss //sprmPWr
+ if( pS )
+ nSp37 = *pS;
+
+ pS = pPap->HasSprm( 46 ); // DropCap //sprmPDcs
+ }
+ else
+ {
+ SetValSprm( &nSp26, pPap, 0x8418 ); // X-Position
+ SetValSprm( &nSp27, pPap, 0x8419 ); // Y-Position
+ SetValSprm( (short*)&nSp45, pPap, 0x442B ); // Hoehe
+ SetValSprm( (short*)&nSp28, pPap, 0x841A ); // Breite
+ SetValSprm( &nSp49, pPap, 0x842F ); // L/R-Raender
+ SetValSprm( &nSp48, pPap, 0x842E ); // U/L-Raender
+
+ pS = pPap->HasSprm( 0x2423 ); // Umfluss
+ if( pS )
+ nSp37 = *pS;
+
+ pS = pPap->HasSprm( 0x442C ); // DropCap
+ }
+
+ bDropCap = pS != 0;
+
+ if( !nSp29 && !nSp27 && !nSp49 && !nSp37 ) // alles 0 heisst
+ return FALSE; // Apo ist nicht vorhanden
+
+ if( ::lcl_ReadBorders( bVer67, brc, pPap )) // Umrandung
+ {
+ bBorderLines = ::lcl_IsBorder( bVer67, brc );
+ bBorder = TRUE;
+ }
+ else
+ bBorderLines = bBorder = FALSE;
+ return TRUE;
+}
+
+BOOL WW8FlyPara::ReadFull( BYTE* pSprm29, SwWW8ImplReader* pIo )
+{
+ WW8PLCFMan* pPlcxMan = pIo->pPlcxMan;
+ WW8PLCFx_Cp_FKP* pPap = pPlcxMan->GetPapPLCF();
+
+ BOOL bOk = Read( pSprm29, pPap ); // Lies Apo-Parameter
+
+ do{ // Block zum rausspringen
+ if( !bOk ) // schiefgegangen
+ break;
+ if( nSp45 != 0 /* || nSp28 != 0 */ )
+ break; // bGrafApo nur bei Hoehe automatisch
+ if( pIo->pWwFib->fComplex )
+ break; // (*pPap)++ geht bei FastSave schief
+ // -> bei FastSave kein Test auf Grafik-APO
+ SvStream* pIoStrm = pIo->pStrm;
+ ULONG nPos = pIoStrm->Tell();
+ WW8PLCFxSave1 aSave;
+ pPlcxMan->GetPap()->Save( aSave );
+ bGrafApo = FALSE;
+
+ do{ // Block zum rausspringen
+
+ BYTE nTxt[2];
+
+ pIoStrm->Read( nTxt, 2 ); // lies Text
+ if( nTxt[0] != 0x01 || nTxt[1] != 0x0d )// nur Grafik + CR ?
+ break; // Nein
+
+ (*pPap)++; // Naechste Zeile
+
+ // In APO ?
+ //sprmPPc
+ BYTE* pS = pPap->HasSprm( bVer67 ? 29 : 0x261B );
+
+ // Nein -> Grafik-Apo
+ if( !pS ){
+ bGrafApo = TRUE;
+ break; // Ende des APO
+ }
+ USHORT nColl = pPap->GetIstd();
+ if( nColl >= pIo->nColls || !pIo->pCollA[nColl].pFmt
+ || !pIo->pCollA[nColl].bColl )
+ nColl = 0; // Unguelige Style-Id
+
+ BOOL bNowStyleApo = pIo->pCollA[nColl].pWWFly != 0; // Apo in StyleDef
+ // BOOL bNowApo = bNowStyleApo || ( pS != 0 ); // hier Apo
+ WW8FlyPara aF( bVer67, bNowStyleApo ? pIo->pCollA[nColl].pWWFly : 0 );
+ // Neuer FlaPara zum Vergleich
+ aF.Read( pS, pPap ); // WWPara fuer neuen Para
+ if( !( aF == *this ) ) // selber APO ? ( oder neuer ? )
+ bGrafApo = TRUE; // nein -> 1-zeiliger APO
+ // -> Grafik-APO
+ }
+ while( 0 ); // Block zum rausspringen
+
+ pPlcxMan->GetPap()->Restore( aSave );
+ pIoStrm->Seek( nPos );
+ }while( 0 ); // Block zum rausspringen
+ return bOk;
+}
+
+
+// Read fuer Apo-Defs in Styledefs
+BOOL WW8FlyPara::Read( BYTE* pSprm29, WW8RStyle* pStyle )
+{
+ if( pSprm29 )
+ nSp29 = *pSprm29; // PPC ( Bindung )
+
+ BYTE* pS = 0;
+ if( bVer67 )
+ {
+ SetValSprm( &nSp26, pStyle, 26 ); // X-Position
+ SetValSprm( &nSp27, pStyle, 27 ); // Y-Position
+ SetValSprm( (short*)&nSp45, pStyle, 45 ); // Hoehe
+ SetValSprm( (short*)&nSp28, pStyle, 28 ); // Breite
+ SetValSprm( &nSp49, pStyle, 49 ); // L/R-Raender
+ SetValSprm( &nSp48, pStyle, 48 ); // U/L-Raender
+
+ pS = pStyle->HasParaSprm( 37 ); // Umfluss
+ if( pS )
+ nSp37 = *pS;
+
+ pS = pStyle->HasParaSprm( 46 ); // DropCap
+ }
+ else
+ {
+ SetValSprm( &nSp26, pStyle, 0x8418 ); // X-Position
+ SetValSprm( &nSp27, pStyle, 0x8419 ); // Y-Position
+ SetValSprm( (short*)&nSp45, pStyle, 0x442B ); // Hoehe
+ SetValSprm( (short*)&nSp28, pStyle, 0x841A ); // Breite
+ SetValSprm( &nSp49, pStyle, 0x842F ); // L/R-Raender
+ SetValSprm( &nSp48, pStyle, 0x842E ); // U/L-Raender
+
+ pS = pStyle->HasParaSprm( 0x2423 ); // Umfluss
+ if( pS )
+ nSp37 = *pS;
+
+ pS = pStyle->HasParaSprm( 0x442C ); // DropCap
+ }
+
+ bDropCap = pS != 0;
+
+ if( !nSp29 && !nSp27 && !nSp49 && !nSp37 ) // alles 0 heisst
+ return FALSE; // Apo ist nicht vorhanden
+
+ if( ::lcl_ReadBorders( bVer67, brc, 0, pStyle ) ) // Umrandung
+ {
+ bBorderLines = ::lcl_IsBorder( bVer67, brc );
+ bBorder = TRUE;
+ }
+ else
+ bBorderLines = bBorder = FALSE;
+ return TRUE;
+}
+
+
+
+
+WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
+ SwWW8ImplReader& rIo,
+ WW8FlyPara& rWW,
+ short nPgTop,
+ short nPgLeft,
+ short nPgWidth,
+ INT32 nIniFlyDx, INT32 nIniFlyDy )
+{
+ memset( this, 0, sizeof( WW8SwFlyPara ) ); // Initialisieren
+ nNewNettoWidth = MINFLY; // Minimum
+
+ eSurround = ( rWW.nSp37 > 1 ) ? SURROUND_PARALLEL : SURROUND_NONE;
+
+ nHeight = rWW.nSp45;
+ if( nHeight & 0x8000 )
+ {
+ nHeight &= 0x7fff;
+ eHeightFix = ATT_MIN_SIZE;
+ }
+ else
+ eHeightFix = ATT_FIX_SIZE;
+
+ if( nHeight <= MINFLY )
+ { // keine Angabe oder Stuss
+ eHeightFix = ATT_MIN_SIZE;
+ nHeight = MINFLY;
+ }
+
+ nWidth = nNettoWidth = rWW.nSp28;
+ if( nWidth <= 10 ) // Auto-Breite
+ {
+ bAutoWidth = TRUE;
+ nWidth = nNettoWidth =
+ rWW.bDropCap ? MINFLY : (nPgWidth ? nPgWidth : 2268); // 4 cm
+ }
+ if( nWidth <= MINFLY )
+ nWidth = nNettoWidth = MINFLY; // Minimale Breite
+
+ eVAlign = VERT_NONE; // Defaults
+ eHAlign = HORI_NONE;
+ nYPos = 0;
+ nXPos = 0;
+
+ nRiMgn = nLeMgn = rWW.nSp49;
+ nLoMgn = nUpMgn = rWW.nSp48;
+
+ // Wenn der Fly links, rechts, oben oder unten aligned ist,
+ // wird der aeussere Textabstand ignoriert, da sonst
+ // der Fly an falscher Position landen wuerde
+ // JP 18.11.98: Problematisch wird es nur bei Innen/Aussen
+
+ switch( rWW.nSp27 ) // besondere Y-Positionen ?
+ {
+ case -4: eVAlign = VERT_TOP; nUpMgn = 0; break; // oben
+ case -8: eVAlign = VERT_CENTER; break; // zentriert
+ case -12: eVAlign = VERT_BOTTOM; nLoMgn = 0; break; // unten
+ default: nYPos = rWW.nSp27 + (short)nIniFlyDy; break; // Korrekturen per Ini-Datei
+ }
+
+ switch( rWW.nSp26 ) // besondere X-Positionen ?
+ {
+ case 0: eHAlign = HORI_LEFT; nLeMgn = 0; break; // links
+ case -4: eHAlign = HORI_CENTER; break; // zentriert
+ case -8: eHAlign = HORI_RIGHT; nRiMgn = 0; break; // rechts
+ case -12: eHAlign = HORI_LEFT; bToggelPos = TRUE; break; // innen
+ case -16: eHAlign = HORI_RIGHT; bToggelPos = TRUE;break; // aussen
+ default: nXPos = rWW.nSp26 + (short)nIniFlyDx; break; // Korrekturen per Ini-Datei
+ }
+
+ // Bindung
+ BYTE nYBind = (( rWW.nSp29 & 0x30 ) >> 4);
+ switch ( nYBind )
+ { // Y - Bindung bestimmt Sw-Bindung
+ case 0: eAnchor = FLY_PAGE; // Vert Margin
+ eVRel = REL_PG_PRTAREA;
+ break;
+ case 1: eAnchor = FLY_PAGE; // Vert Page
+ eVRel = REL_PG_FRAME;
+ break; // 2=Vert. Paragraph, 3=Use Default
+ default:eAnchor = FLY_AT_CNTNT;
+ eVRel = PRTAREA;
+ if( nYPos < 0 )
+ nYPos = 0; // koennen wir nicht
+ break;
+ }
+
+ if( (rIo.bIsHeader || rIo.bIsFooter) && (FLY_AT_CNTNT != eAnchor) )
+ {
+ eAnchor = FLY_AT_CNTNT;
+ if( rIo.bIsHeader )
+ {
+ nYPos -= nPgTop;
+ // nXPos will be decreased at the very end of this C'tor
+ }
+ else
+ {
+ nYPos = 0;
+ }
+ rIo.pNode_FLY_AT_CNTNT = &rPaM.GetPoint()->nNode.GetNode();
+ }
+
+ BYTE nXBind = ( rWW.nSp29 & 0xc0 ) >> 6;
+ switch ( nXBind ) // X - Bindung -> Koordinatentransformation
+ {
+ case 0: // Hor. Spalte
+ case 1: // Hor. Absatz
+ eHRel = (FLY_PAGE == eAnchor) ? REL_PG_PRTAREA : PRTAREA;
+ break;
+/* case 2:*/ // Hor. Seite
+/* case 3:*/ // Use Default
+ default:{
+ eHRel = (FLY_PAGE == eAnchor) ? REL_PG_FRAME : FRAME;
+
+ // important: allways set REL_PG_FRAME in sections with columns
+ if( eHRel != REL_PG_FRAME )
+ {
+ const SwSectionNode* pSectNd
+ = rPaM.GetPoint()->nNode.GetNode().FindSectionNode();
+ if( pSectNd )
+ {
+ const SwSectionFmt* pFmt
+ = pSectNd->GetSection().GetFmt();
+ if( pFmt )
+ {
+ if( 1 < pFmt->GetCol().GetNumCols() )
+ eHRel = REL_PG_FRAME;
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ INT16 nLeLMgn = 0, nRiLMgn = 0; // aus Liniendicke entstehende Raender
+
+ if( rWW.bBorder ) // Raender innerhalb der Umrandung
+ {
+ WW8_BRC5& rBrc = rWW.brc;
+
+ // dxpSpace aller 4 Borders bestimmen, zum InnerMargin aufaddieren
+ // und die linken/rechten zur Groesse dazu rechnen
+ // Die Angaben sind in Point
+ short nLeft, nRight;
+ if( rWW.bVer67 )
+ {
+ nLeft = (rBrc[WW8_LEFT ].aBits1[1] >> 3) & 0x1f; // dxpSpace
+ nRight = (rBrc[WW8_RIGHT].aBits1[1] >> 3) & 0x1f; // dxpSpace
+ // muessen obere / untere Liniendicken auch beruecksichtigt werden ???
+
+ nInnerMgn = (( rBrc[WW8_TOP].aBits1[1] ) >> 3 & 0x1f) +
+ (( rBrc[WW8_BOT].aBits1[1] ) >> 3 & 0x1f);
+ }
+ else
+ {
+ nLeft = rBrc[WW8_LEFT ].aBits2[1] & 0x1f; // dxpSpace
+ nRight = rBrc[WW8_RIGHT].aBits2[1] & 0x1f; // dxpSpace
+ // muessen obere / untere Liniendicken auch beruecksichtigt werden ???
+
+ nInnerMgn = (rBrc[WW8_TOP].aBits2[1] & 0x1f) +
+ (rBrc[WW8_BOT].aBits2[1] & 0x1f);
+ }
+
+ nLeLMgn += 20 * nLeft; // dxpSpace
+ nRiLMgn += 20 * nRight; // dxpSpace
+
+ nLeLMgn += GetLineWidth( rWW.bVer67, rBrc[WW8_LEFT] );
+ nRiLMgn += GetLineWidth( rWW.bVer67, rBrc[WW8_RIGHT] );
+
+ nInnerMgn += nLeft + nRight;
+ nInnerMgn *= 5; // Mittelwert in Twips (20 * 4 Kanten)
+ }
+ // Raender ausserhalb der Umrandung
+ nWidth += nLeLMgn + nRiLMgn;
+// nHeight += nUpLMgn + nLoLMgn;
+
+ FlySecur1( nWidth, nLeMgn, nRiMgn, rWW.bBorderLines ); // passen Raender ?
+ FlySecur1( nHeight, nUpMgn, nLoMgn, rWW.bBorderLines );
+
+ // Seitenrand-Bindung: Wenn die Position mit der jetzigen
+ // SW-Bindung nicht zu erreichen ist, dann waehle andere Bindung
+ // Absatz-Bindung: Nicht anfassen
+ if( (eAnchor == FLY_PAGE ) // Bindung: Seitenrand
+ && (eHRel == REL_PG_PRTAREA) // und abs. positioniert
+ && (eVAlign == VERT_NONE )
+ && (eHAlign == HORI_NONE ) )
+ {
+ if( nYPos < nPgTop ) // echter neg. Y-Wert
+ eHRel = eVRel = REL_PG_FRAME;
+ if( nXPos < nPgLeft ) // echter neg. X-Wert
+ eHRel = eVRel = REL_PG_FRAME;
+ }
+
+
+ // Sicherheitsabfragen, damit der der Writer nichts unverdauliches
+ // bekommt
+ if( nYPos < 0 )
+ nYPos = 0;
+
+ if( nXPos < 0 )
+ nXPos = 0;
+ /*
+ // eine Writer-Kuriositaet: auch wenn Abstaende vom Seitenrand
+ // gezaehlt werden sollen, muessen die Positionen als Abstaende vom
+ // Papierrand angegeben werden
+ // bei Absatzgebundenen Frames geht die Zaehlung immer von
+ // der Printarea aus
+ */
+ if( (FRAME == eHRel) && (FLY_AT_CNTNT == eAnchor) )
+ {
+ // hier duerfen neg. Werte bis minimal -nPgLeft entstehen
+ nXPos -= nPgLeft;
+ if( rIo.bTable )
+ nXPos -= rIo.GetTableLeft();
+ }
+}
+
+// hat ein Fly in WW eine automatische Breite, dann muss das durch
+// nachtraegliches Anpassen der ( im SW festen ) Fly-Breite simuliert werden.
+// Dabei kann die Fly-Breite groesser oder kleiner werden, da der Default-Wert
+// ohne Wissen ueber den Inhalt eingesetzt wird.
+void WW8SwFlyPara::BoxUpWidth( long nWidth )
+{
+ if( bAutoWidth && nWidth > nNewNettoWidth )
+ nNewNettoWidth = nWidth;
+};
+
+// Die Klasse WW8FlySet ist von SfxItemSet abgeleitet und stellt auch
+// im Prizip nicht mehr zur Verfuegung, ist aber fuer mich besser
+// zu handeln
+// WW8FlySet-ctor fuer Apos und Graf-Apos
+WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, /*const*/ WW8FlyPara* pFW,
+ /*const*/ WW8SwFlyPara* pFS, BOOL bGraf )
+:SfxItemSet( rReader.rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 )
+
+{
+ if( !rReader.bNew )
+ Reader::ResetFrmFmtAttrs( *this ); // Abstand/Umrandung raus
+
+ // Position
+ Put( SwFmtHoriOrient( pFS->nXPos, pFS->eHAlign, pFS->eHRel, pFS->bToggelPos ));
+ Put( SwFmtVertOrient( pFS->nYPos, pFS->eVAlign, pFS->eVRel ) );
+
+ if( pFS->nLeMgn || pFS->nRiMgn ) // Raender setzen
+ {
+ SvxLRSpaceItem aLR;
+ aLR.SetTxtLeft( pFS->nLeMgn );
+ aLR.SetRight( pFS->nRiMgn );
+ Put( aLR );
+ }
+ if( pFS->nUpMgn || pFS->nLoMgn )
+ {
+ SvxULSpaceItem aUL;
+ aUL.SetUpper( pFS->nUpMgn );
+ aUL.SetLower( pFS->nLoMgn );
+ Put( aUL );
+ }
+
+
+ SwFmtSurround aSur( pFS->eSurround ); // Umfluss
+
+// GoldCut umfliesst inzwischen nur dann auf beiden Seiten, wenn der Fly
+// schmaler als ca. 1.5cm ist. Also entspricht normales Parallel besser
+// dem WW-Verhalten.
+// aSur.SetGoldCut( pFS->eSurround == SURROUND_PARALLEL );
+
+ Put( aSur );
+
+ rReader.SetFlyBordersShadow( *this, (WW8_BRC*)pFW->brc,
+ pFS->nInnerMgn );
+ // der 5. Parameter ist immer 0, daher geht beim Cast nix verloren
+
+ if( !bGraf ){ // Textrahmen->Anker und Groesse einstellen
+ Put( SwFmtAnchor( pFS->eAnchor, 1 ) );
+ // Groesse einstellen
+ Put( SwFmtFrmSize( pFS->eHeightFix, pFS->nWidth, pFS->nHeight ));
+ }
+}
+
+// WW8FlySet-ctor fuer zeichengebundene Grafiken
+WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM,
+ const WW8_PIC& rPic, long nWidth, long nHeight )
+:SfxItemSet( rReader.rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 )
+{
+ if( !rReader.bNew )
+ Reader::ResetFrmFmtAttrs( *this ); // Abstand/Umrandung raus
+
+ SwFmtAnchor aAnchor( FLY_IN_CNTNT );
+ aAnchor.SetAnchor( pPaM->GetPoint() );
+ Put( aAnchor );
+ Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) );
+
+// Put( SwFmtHoriOrient( 0, HORI_NONE, REL_CHAR, FALSE ));
+// Put( SwFmtVertOrient( 0, VERT_NONE, REL_CHAR ) );
+ Put( SwFmtVertOrient( 0, VERT_TOP, FRAME ));
+
+ rReader.SetFlyBordersShadow( *this, rPic.rgbrc, 0 );
+}
+
+
+BOOL SwWW8ImplReader::StartApo( BYTE* pSprm29, BOOL bNowStyleApo )
+{
+ pWFlyPara = new WW8FlyPara ( bVer67, bNowStyleApo ? pCollA[nAktColl].pWWFly : 0 );
+
+ // APO-Parameter ermitteln und Test auf bGrafApo
+ if( !pWFlyPara->ReadFull( pSprm29, this ) )
+ {
+ DELETEZ( pWFlyPara );
+ return FALSE;
+ }
+
+
+ pSFlyPara = new WW8SwFlyPara( *pPaM,
+ *this,
+ *pWFlyPara,
+ nPgTop,
+ nPgLeft,
+ (nPgWidth - nPgRight - nPgLeft),
+ nIniFlyDx,
+ nIniFlyDy );
+ // nPg... nicht aus PageDesc, da bei Defaultraendern noch nicht gesetzt
+
+ if( !pWFlyPara->bGrafApo )
+ {
+
+ // Innerhalb des GrafApo muessen Textattribute
+ // ignoriert werden, da sie sonst auf den
+ // folgenden Zeilen landen.
+ // Der Rahmen wird nur eingefuegt, wenn er
+ // *nicht* nur zum Positionieren einer einzelnen
+ // Grafik dient.
+ // Ist es ein Grafik-Rahmen, dann werden
+ // pWFlyPara und pSFlyPara behalten und die
+ // daraus resultierenden Attribute beim
+ // Einfuegen der Grafik auf die Grafik angewendet.
+
+// SwAttrSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
+// SetApoCharacteristics( aFlySet, pWFlyPara, pSFlyPara );
+ WW8FlySet aFlySet( *this, pWFlyPara, pSFlyPara, FALSE );
+
+ pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,
+ pPaM->GetPoint(), &aFlySet );
+ if( FLY_IN_CNTNT != pSFlyPara->eAnchor )
+ pCtrlStck->NewAttr( *pPaM->GetPoint(), SwFltAnchor( pSFlyPara->pFlyFmt ) );
+
+ // merke Pos im Haupttext
+ pSFlyPara->pMainTextPos = new SwPosition( *pPaM->GetPoint() );
+ nLastFlyNode = pSFlyPara->pMainTextPos->nNode.GetIndex();
+
+ // Alle Attribute schliessen, da sonst
+ // Attribute entstehen koennen, die
+ // in Flys reinragen
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+
+ // Setze Pam in den FlyFrame
+ const SwFmtCntnt& rCntnt = pSFlyPara->pFlyFmt->GetCntnt();
+ ASSERT( rCntnt.GetCntntIdx(), "Kein Inhalt vorbereitet." );
+ pPaM->GetPoint()->nNode = rCntnt.GetCntntIdx()->GetIndex() + 1;
+ pPaM->GetPoint()->nContent.Assign( pPaM->GetCntntNode(), 0 );
+
+ // 1) ReadText() wird nicht wie beim W4W-Reader rekursiv aufgerufen,
+ // da die Laenge des Apo zu diesen Zeitpunkt noch nicht feststeht,
+ // ReadText() diese Angabe aber braucht.
+ // 2) Der CtrlStck wird nicht neu erzeugt.
+ // die Char-Attribute laufen weiter ( AErger mit SW-Attributen )
+ // Paraattribute muessten am Ende jeden Absatzes zurueckgesetzt
+ // sein, d.h. es duerften am Absatzende keine Paraattribute
+ // auf dem Stack liegen
+ }
+ return TRUE;
+}
+
+BOOL SwWW8ImplReader::JoinNode( SwPaM* pPam, BOOL bStealAttr )
+{
+ BOOL bRet = FALSE;
+ pPam->GetPoint()->nContent = 0; // an den Anfang der Zeile gehen
+
+ SwNodeIndex aPref( pPam->GetPoint()->nNode, -1 );
+
+ SwTxtNode* pNode = aPref.GetNode().GetTxtNode();
+ if( pNode )
+ {
+ pPaM->GetPoint()->nNode = aPref;
+ pPaM->GetPoint()->nContent.Assign( pNode, pNode->GetTxt().Len() );
+
+ if( bStealAttr )
+ pCtrlStck->StealAttr( pPam->GetPoint() );
+ pNode->JoinNext();
+ bRet = TRUE;
+ }
+ return bRet;
+}
+
+void SwWW8ImplReader::StopApo()
+{
+ if( pWFlyPara->bGrafApo ){ // Grafik-Rahmen, der *nicht* eingefuegt wurde
+ // leeren Absatz incl. Attributen entfernen
+ JoinNode( pPaM, TRUE );
+
+ }
+ else
+ { // Der Rahmen wurde nur eingefuegt, wenn er
+ // *nicht* nur zum Positionieren einer einzelnen
+ // Grafik dient.
+ JoinNode( pPaM, FALSE );// UEberfluessigen Absatz entfernen
+
+ if( !pSFlyPara->pMainTextPos || !pWFlyPara ){
+ ASSERT( pSFlyPara->pMainTextPos, "StopApo: pMainTextPos ist 0" );
+ ASSERT( pWFlyPara, "StopApo: pWFlyPara ist 0" );
+ return;
+ }
+ // Alle Attribute schliessen, da sonst
+ // Attribute entstehen koennen, die
+ // aus Flys rausragen
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+ pEndStck->SetAttr( *pPaM->GetPoint(), 0, FALSE );
+
+
+// Ist die Fly-Breite durch eine innenliegende Grafik vergroessert worden
+// ( bei automatischer Breite des Flys ), dann muss die Breite des SW-Flys
+// entsprechend umgesetzt werden, da der SW keine automatische Breite kennt.
+
+ if( pSFlyPara->nNewNettoWidth > MINFLY ) // BoxUpWidth ?
+ {
+ long nW = pSFlyPara->nNewNettoWidth;
+ nW += pSFlyPara->nWidth - pSFlyPara->nNettoWidth; // Rand dazu
+ pSFlyPara->pFlyFmt->SetAttr(
+ SwFmtFrmSize( pSFlyPara->eHeightFix, nW, pSFlyPara->nHeight ) );
+ }
+ else if( !pWFlyPara->nSp28 ) // *no* width set ->> automatic width
+ {
+ SfxItemSet aFlySet( pSFlyPara->pFlyFmt->GetAttrSet() );
+ aFlySet.ClearItem( RES_FRM_SIZE );
+ CalculateFlySize( aFlySet, pSFlyPara->pMainTextPos->nNode, nPgWidth );
+
+ pSFlyPara->pFlyFmt->SetAttr( aFlySet.Get( RES_FRM_SIZE ) );
+ }
+
+ *pPaM->GetPoint() = *pSFlyPara->pMainTextPos;
+ DELETEZ( pSFlyPara->pMainTextPos );
+
+// Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden,
+// wird in fltshell.cxx beim Setzen des FltAnchor-Attributes
+// pFlyFrm->MakeFrms() gerufen
+
+ }
+ DELETEZ( pSFlyPara );
+ DELETEZ( pWFlyPara );
+}
+
+// TestSameApo() beantwortet die Frage, ob es dasselbe APO oder ein neues ist
+BOOL SwWW8ImplReader::TestSameApo( BYTE* pSprm29, BOOL bNowStyleApo )
+{
+ if( !pWFlyPara )
+ {
+ ASSERT( pWFlyPara, " Wo ist mein pWFlyPara ? " );
+ return TRUE;
+ }
+
+ // Es muss ein kompletter Vergleich ( ausser Borders )
+ // stattfinden, um alle Kombinationen Style / Hart
+ // richtig einzuordnen. Deshalb wird ein temporaerer
+ // WW8FlyPara angelegt ( abh. ob Style oder nicht ),
+ // darauf die harten Attrs angewendet, und
+ // dann verglichen
+
+ WW8FlyPara aF( bVer67, bNowStyleApo ? pCollA[nAktColl].pWWFly : 0 ); // Zum Vergleich
+ aF.Read( pSprm29, pPlcxMan->GetPapPLCF() ); // WWPara fuer akt. Para
+ return aF == *pWFlyPara;
+}
+
+
+
+/***************************************************************************
+# Attribut - Verwaltung
+#**************************************************************************/
+
+void SwWW8ImplReader::NewAttr( const SfxPoolItem& rAttr )
+{
+ if( !bNoAttrImport ){ // zum Ignorieren von Styles beim Doc-Einfuegen
+ if( pAktColl )
+ pAktColl->SetAttr( rAttr );
+ else
+ if( pAktItemSet )
+ pAktItemSet->Put( rAttr );
+ else
+ pCtrlStck->NewAttr( *pPaM->GetPoint(), rAttr );
+ }
+}
+
+// holt Attribut aus der FmtColl / Stack / Doc
+const SfxPoolItem* SwWW8ImplReader::GetFmtAttr( USHORT nWhich )
+{
+ if( pAktColl )
+ return &pAktColl->GetAttr( nWhich );
+ else
+ if( pAktItemSet )
+ return pAktItemSet->GetItem( nWhich );
+ else
+ return pCtrlStck->GetFmtAttr( *pPaM->GetPoint(), nWhich );
+}
+
+#if 0
+// holt Attribut aus der FmtColl / Stack, return 0 wenn nicht gefunden
+const SfxPoolItem* SwWW8ImplReader::GetFmtStkAttr( USHORT nWhich )
+{
+ if( pAktColl )
+ return &pAktColl->GetAttr( nWhich );
+ else
+ return pCtrlStck->GetFmtStkAttr( *pPaM->GetPoint(), nWhich );
+}
+#endif
+
+/***************************************************************************
+# eigentliche Attribute
+#
+# Die Methoden erhalten die Token-Id und die Laenge der noch folgenden
+# Parameter gemaess Tabelle in WWScan.cxx als Parameter
+#**************************************************************************/
+
+/***************************************************************************
+# Spezial WW - Attribute
+#**************************************************************************/
+
+void SwWW8ImplReader::Read_Special( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){
+ bSpec = FALSE;
+ return;
+ }
+ bSpec = ( *pData != 0 );
+}
+
+// Read_Obj wird fuer fObj und fuer fOle2 benutzt !
+void SwWW8ImplReader::Read_Obj( USHORT nId, BYTE* pData, short nLen )
+{
+ if( nLen < 0 )
+ bObj = FALSE;
+ else
+ {
+ bObj = 0 != *pData;
+
+ if( bObj && nPicLocFc && bEmbeddObj )
+ nObjLocFc = nPicLocFc;
+ }
+}
+
+void SwWW8ImplReader::Read_PicLoc( USHORT nId, BYTE* pData, short nLen )
+{
+ if( nLen < 0 )
+ {
+ nPicLocFc = 0;
+ bSpec = FALSE; // Stimmt das immer ?
+ }
+ else
+ {
+ nPicLocFc = SVBT32ToLong( pData );
+ bSpec = TRUE;
+
+ if( bObj && nPicLocFc && bEmbeddObj )
+ nObjLocFc = nPicLocFc;
+ }
+}
+
+
+void SwWW8ImplReader::Read_POutLvl( USHORT nId, BYTE* pData, short nLen )
+{
+ if( pAktColl && (0 < nLen) )
+ {
+ SwWW8StyInf* pSI = &pCollA[nAktColl];
+ pSI->nOutlineLevel =
+ ( (1 <= pSI->GetWWStyleId()) && (9 >= pSI->GetWWStyleId()) )
+ ? pSI->GetWWStyleId()-1
+ : (pData ? *pData : 0);
+ }
+}
+
+
+void SwWW8ImplReader::Read_Symbol( USHORT nId, BYTE* pData, short nLen )
+{
+ if( !bIgnoreText )
+ {
+ if( nLen < 0 )
+ bSymbol = FALSE;
+ else
+ {
+ // neues Font-Atribut aufmachen
+ // (wird in SwWW8ImplReader::ReadChars() geschlossen)
+ if( SetNewFontAttr( SVBT16ToShort( pData ), FALSE ))
+ {
+ if( bVer67 )
+ cSymbol = ByteString::ConvertToUnicode(
+ *(sal_Char*)(pData+2), RTL_TEXTENCODING_MS_1252 );
+ else
+ cSymbol = SVBT16ToShort( pData+2 );
+ bSymbol = TRUE;
+ }
+ }
+ }
+}
+
+/***************************************************************************
+# Zeichen - Attribute
+#**************************************************************************/
+
+static USHORT __FAR_DATA nEndIds[ 8 ] = {
+ RES_CHRATR_WEIGHT, RES_CHRATR_POSTURE,
+ RES_CHRATR_CROSSEDOUT, RES_CHRATR_CONTOUR,
+ RES_CHRATR_SHADOWED, RES_CHRATR_CASEMAP,
+ RES_CHRATR_CASEMAP, RES_CHRATR_CROSSEDOUT
+ };
+
+// Read_BoldUsw fuer Italic, Bold, Kapitaelchen, Versalien, durchgestrichen,
+// Contour und Shadow
+void SwWW8ImplReader::Read_BoldUsw( USHORT nId, BYTE* pData, short nLen )
+{
+ BYTE nI;
+ // die Attribut-Nr fuer "doppelt durchgestrichen" tanzt aus der Reihe
+ if( 0x2A53 != nId )
+ nI = bVer67 ? nId - 85 : nId - 0x0835; // Index 0..6
+ else
+ nI = 7; // Index 7 (Doppelt durchgestrichen)
+
+ BYTE nMask = 1 << nI;
+
+ if( nLen < 0 )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nI ] );
+ pCtrlStck->SetToggleAttr( nI, FALSE );
+ return;
+ }
+ // Wert: 0 = Aus, 1 = An,
+ // 128 = Wie Style, 129 entgegen Style
+ BOOL bOn = *pData & 1;
+ SwWW8StyInf* pSI = &pCollA[nAktColl];
+
+ if( pAktColl ) // StyleDef -> Flags merken
+ {
+ if( pSI->nBase < nColls // Style Based on
+ && ( *pData & 0x80 ) // Bit 7 gesetzt ?
+ && ( pCollA[pSI->nBase].n81Flags & nMask ) ) // BasisMaske ?
+ bOn = !bOn; // umdrehen
+
+ if( bOn )
+ pSI->n81Flags |= nMask; // Flag setzen
+ else
+ pSI->n81Flags &= ~nMask; // Flag loeschen
+ }
+ else
+ { // im Text -> Flags abfragen
+ if( *pData & 0x80 ) // Bit 7 gesetzt ?
+ {
+ if( pSI->n81Flags & nMask ) // und in StyleDef an ?
+ bOn = !bOn; // dann invertieren
+ // am Stack vermerken, das dieses ein Toggle-Attribut ist
+ pCtrlStck->SetToggleAttr( nI, TRUE );
+ }
+ }
+
+ SetToggleAttr( nI, bOn );
+}
+
+void SwWW8ImplReader::SetToggleAttr( BYTE nAttrId, BOOL bOn )
+{
+ switch( nAttrId )
+ {
+ case 0: NewAttr( SvxWeightItem( bOn ? WEIGHT_BOLD : WEIGHT_NORMAL ) );
+ break;
+ case 1: NewAttr( SvxPostureItem( bOn ? ITALIC_NORMAL : ITALIC_NONE ) );
+ break;
+ case 2: NewAttr( SvxCrossedOutItem( bOn ? STRIKEOUT_SINGLE : STRIKEOUT_NONE ) );
+ break;
+ case 3: NewAttr( SvxContourItem( bOn ) );
+ break;
+ case 4: NewAttr( SvxShadowedItem( bOn ) );
+ break;
+ case 5: NewAttr( SvxCaseMapItem( bOn ? SVX_CASEMAP_KAPITAELCHEN
+ : SVX_CASEMAP_NOT_MAPPED ) );
+ break;
+ case 6: NewAttr( SvxCaseMapItem( bOn ? SVX_CASEMAP_VERSALIEN
+ : SVX_CASEMAP_NOT_MAPPED ) );
+ break;
+ case 7: NewAttr( SvxCrossedOutItem( bOn ? STRIKEOUT_DOUBLE
+ : STRIKEOUT_NONE ) );
+ break;
+ }
+}
+
+void SwWW8ImplReader::_ChkToggleAttr( USHORT nOldStyle81Mask,
+ USHORT nNewStyle81Mask )
+{
+ USHORT i = 1, nToggleAttrFlags = pCtrlStck->GetToggleAttrFlags();
+ BYTE n = 0;
+ for( ; n < 7; ++n, i <<= 1 )
+ if( (i & nToggleAttrFlags) &&
+ ( (i & nOldStyle81Mask) != (i & nNewStyle81Mask)))
+ {
+ SetToggleAttr( n, 0 != (i & nOldStyle81Mask ) );
+ }
+}
+
+void SwWW8ImplReader::Read_SubSuper( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_ESCAPEMENT );
+ return;
+ }
+
+ short nEs;
+ BYTE nProp;
+ switch( *pData ){
+ case 1: nEs = DFLT_ESC_AUTO_SUPER; nProp = DFLT_ESC_PROP; break;
+ case 2: nEs = DFLT_ESC_AUTO_SUB; nProp = DFLT_ESC_PROP; break;
+ default: nEs = 0; nProp = 100; break;
+ }
+ NewAttr( SvxEscapementItem( nEs, nProp ) );
+}
+
+void SwWW8ImplReader::Read_SubSuperProp( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_ESCAPEMENT );
+ return;
+ }
+
+ short nPos = SVBT16ToShort( pData ); // Font-Position in HalfPoints
+ INT32 nPos2 = nPos * ( 10 * 100 ); // HalfPoints in 100 * tw
+ SvxFontHeightItem* pF
+ = (SvxFontHeightItem*)GetFmtAttr( RES_CHRATR_FONTSIZE );
+ nPos2 /= (INT32)pF->GetHeight(); // ... nun in % ( gerundet )
+ if( nPos2 > 100 ) // zur Sicherheit
+ nPos2 = 100;
+ if( nPos2 < -100 )
+ nPos2 = -100;
+ SvxEscapementItem aEs( (short)nPos2, 100 );
+ NewAttr( aEs );
+}
+
+void SwWW8ImplReader::Read_Underline( USHORT, BYTE* pData, short nLen )
+{
+ FontUnderline eUnderline = UNDERLINE_NONE;
+ BOOL bWordLine = FALSE;
+ if( pData )
+ {
+ // Parameter: 0 = none, 1 = single, 2 = by Word,
+ // 3 = double, 4 = dotted, 5 = hidden
+ // 6 = thick, 7 = dash, 8 = dot(not used)
+ // 9 = dotdash 10 = dotdotdash 11 = wave
+
+
+ // pruefe auf Sonderfall "fett+unterstrichen"
+ BOOL bAlsoBold = /*( 6 == b )*/FALSE;
+ // erst mal ggfs. *bold* einschalten!
+ if( bAlsoBold )
+ {
+ BYTE nOn = 1;
+ Read_BoldUsw( 0x0835, &nOn, nLen );
+ eUnderline = UNDERLINE_SINGLE;
+ }
+ else
+ {
+ switch( *pData )
+ {
+ case 2: bWordLine = TRUE; // kein break;
+ case 1: eUnderline = (FontUnderline)UNDERLINE_SINGLE; break;
+ case 3: eUnderline = (FontUnderline)UNDERLINE_DOUBLE; break;
+ case 4: eUnderline = (FontUnderline)UNDERLINE_DOTTED; break;
+ case 7: eUnderline = (FontUnderline)UNDERLINE_DASH; break;
+ case 9: eUnderline = (FontUnderline)UNDERLINE_DASHDOT; break;
+ case 10:eUnderline = (FontUnderline)UNDERLINE_DASHDOTDOT; break;
+ case 6: eUnderline = (FontUnderline)UNDERLINE_BOLD; break;
+ case 11:eUnderline = (FontUnderline)UNDERLINE_WAVE; break;
+ case 20:eUnderline = (FontUnderline)UNDERLINE_BOLDDOTTED; break;
+ case 23:eUnderline = (FontUnderline)UNDERLINE_BOLDDASH; break;
+ case 39:eUnderline = (FontUnderline)UNDERLINE_LONGDASH; break;
+ case 55:eUnderline = (FontUnderline)UNDERLINE_BOLDLONGDASH; break;
+ case 25:eUnderline = (FontUnderline)UNDERLINE_BOLDDASHDOT; break;
+ case 26:eUnderline = (FontUnderline)UNDERLINE_BOLDDASHDOTDOT;break;
+ case 27:eUnderline = (FontUnderline)UNDERLINE_BOLDWAVE; break;
+ case 43:eUnderline = (FontUnderline)UNDERLINE_DOUBLEWAVE; break;
+ }
+ }
+ }
+
+ // dann Stack ggfs. verwursteln und exit!
+ if( nLen < 0 )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_UNDERLINE );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_WORDLINEMODE );
+ }
+ else
+ {
+ NewAttr( SvxUnderlineItem( eUnderline ));
+ if( bWordLine )
+ NewAttr( SvxWordLineModeItem( TRUE ));
+ }
+}
+
+void SwWW8ImplReader::Read_TxtColor( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
+ bTxtCol = FALSE;
+
+ if( bCharShdTxtCol || bShdTxtCol )
+ // dann muss die wieder eingeschaltet werden!!
+ NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
+ }
+ else
+ {
+ BYTE b = *pData; // Parameter: 0 = Auto, 1..16 Farben
+
+ if( b > 16 ) // unbekannt -> Black
+ b = 0; // Auto -> Black
+
+ NewAttr( SvxColorItem( Color( eSwWW8ColA[b] ) ) );
+ bTxtCol = TRUE; // SHD darf nicht Farbe einschalten
+ }
+}
+
+BOOL SwWW8ImplReader::GetFontParams( USHORT nFCode, FontFamily& reFamily,
+ String& rName, FontPitch& rePitch, CharSet& reCharSet )
+{
+ // Die Defines, aus denen diese Tabellen erzeugt werden, stehen in windows.h
+ static FontPitch __READONLY_DATA ePitchA[]
+ = { PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, PITCH_DONTKNOW };
+
+ static FontFamily __READONLY_DATA eFamilyA[]
+ = { FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
+ FAMILY_SCRIPT, FAMILY_DECORATIVE };
+
+
+ const WW8_FFN* pF = pFonts->GetFont( nFCode ); // Info dazu
+ if( !pF ) // FontNummer unbekannt ?
+ return FALSE; // dann ignorieren
+
+ rName = String( pF->sFontname );
+
+#if defined( OS2 )
+ if ( rName.EqualsIgnoreCaseAscii( "Helv" )
+ || rName.EqualsIgnoreCaseAscii( "Arial" ) )
+ rName.AssignAscii( "Helvetica" );
+ else if ( rName.EqualsIgnoreCaseAscii( "Tms Rmn" )
+ || rName.EqualsIgnoreCaseAscii( "Times New Roman" ) )
+ rName.AssignAscii( "Times New Roman" );
+ else if ( rName.EqualsIgnoreCaseAscii( "Courier New" ) )
+ rName.AssignAscii( "Courier" );
+ else if ( rName.EqualsIgnoreCaseAscii( "Symbol" ) )
+ rName.AssignAscii( "Symbol Set" );
+#endif // OS2
+#if defined( MAC )
+ if ( rName.EqualsIgnoreCaseAscii( "Helv" )
+ || rName.EqualsIgnoreCaseAscii( "Arial" ))
+ rName.AssignAscii( "Helvetica" );
+ else if ( rName.EqualsIgnoreCaseAscii( "Tms Rmn" )
+ || rName.EqualsIgnoreCaseAscii( "Times New Roman" ) )
+ rName.AssignAscii( "Times" );
+ else if ( rName.EqualsIgnoreCaseAscii( "Courier New" ) )
+ rName.AssignAscii( "Courier" );
+#endif // MAC
+
+ // pF->prg : Pitch
+ rePitch = ePitchA[pF->prg];
+
+ // pF->chs: Charset
+ if( 77 == pF->chs ) // Mac-Font im Mac-Charset oder
+ reCharSet = eTextCharSet; // auf ANSI-Charset uebersetzt
+ else
+ reCharSet = rtl_getTextEncodingFromWindowsCharset( pF->chs );
+
+ // pF->ff : Family
+ BYTE b = pF->ff;
+
+ // make sure Font Family Code is set correctly
+ // at least for the most important fonts
+ // ( might be set wrong when Doc was not created by
+ // Winword but by third party program like Applixware... )
+ /*
+ 0: FAMILY_DONTKNOW
+ 1: FAMILY_ROMAN
+ 2: FAMILY_SWISS
+ 3: FAMILY_MODERN
+ 4: FAMILY_SCRIPT
+ 5: FAMILY_DECORATIVE
+ */
+#define FONTNAMETAB_SZ 14
+#define MAX_FONTNAME_ROMAN 6
+ static sal_Char __READONLY_DATA
+ // first comes ROMAN
+ sFontName0[] = "\x07""Tms Rmn",
+ sFontName1[] = "\x07""Timmons",
+ sFontName2[] = "\x08""CG Times",
+ sFontName3[] = "\x08""MS Serif",
+ sFontName4[] = "\x08""Garamond",
+ sFontName5[] = "\x11""Times Roman",
+ sFontName6[] = "\x15""Times New Roman",
+ // from here SWISS --> see above: #define MAX_FONTNAME_ROMAN 6
+ sFontName7[] = "\x04""Helv",
+ sFontName8[] = "\x05""Arial",
+ sFontName9[] = "\x07""Univers",
+ sFontName10[]= "\x11""LinePrinter",
+ sFontName11[]= "\x11""Lucida Sans",
+ sFontName12[]= "\x11""Small Fonts",
+ sFontName13[]= "\x13""MS Sans Serif";
+ static const sal_Char* __READONLY_DATA aFontNameTab[ FONTNAMETAB_SZ ] =
+ {
+ sFontName0, sFontName1, sFontName2, sFontName3,
+ sFontName4, sFontName5, sFontName6, sFontName7,
+ sFontName8, sFontName9, sFontName10, sFontName11,
+ sFontName12, sFontName13
+ };
+
+ for( USHORT n = 0; n < FONTNAMETAB_SZ; n++ )
+ {
+ const sal_Char* pCmp = aFontNameTab[ n ];
+ int nLen = *pCmp++;
+ if( rName.EqualsIgnoreCaseAscii(pCmp, 0, nLen) )
+ {
+ b = n <= MAX_FONTNAME_ROMAN ? 1 : 2;
+ break;
+ }
+ }
+ if( b < sizeof( eFamilyA ) )
+ reFamily = eFamilyA[b];
+ else
+ reFamily = FAMILY_DONTKNOW;
+
+ return TRUE;
+}
+
+BOOL SwWW8ImplReader::SetNewFontAttr( USHORT nFCode, BOOL bSetEnums )
+{
+ FontFamily eFamily;
+ String aName;
+ FontPitch ePitch;
+ CharSet eSrcCharSet;
+
+ if( !GetFontParams( nFCode, eFamily, aName, ePitch, eSrcCharSet ) )
+ return FALSE;
+
+ CharSet eDstCharSet = eSrcCharSet;
+
+ SvxFontItem aFont( eFamily, aName, aEmptyStr, ePitch, eDstCharSet );
+
+ if( bSetEnums )
+ {
+ if( pAktColl )
+ { // StyleDef
+ pCollA[nAktColl].eFontSrcCharSet = eSrcCharSet;
+ }
+ else
+ {
+ eFontSrcCharSet = eSrcCharSet;
+ }
+ }
+
+ NewAttr( aFont ); // ...und 'reinsetzen
+
+
+ return TRUE;
+}
+
+void SwWW8ImplReader::ResetCharSetVars()
+{
+ if( nCharFmt >= 0 )
+ {
+ eFontSrcCharSet = pCollA[nCharFmt].eFontSrcCharSet; // aus C-Style
+ }
+ else
+ {
+ eFontSrcCharSet = RTL_TEXTENCODING_DONTKNOW;
+ }
+ if( eFontSrcCharSet == RTL_TEXTENCODING_DONTKNOW )
+ eFontSrcCharSet = pCollA[nAktColl].eFontSrcCharSet; // aus P-Style
+}
+
+/*
+ Font ein oder ausschalten:
+*/
+void SwWW8ImplReader::Read_FontCode( USHORT, BYTE* pData, short nLen )
+{
+ if( !bSymbol && !bIgnoreText ) // falls bSymbol, gilt der am Symbol
+ { // (siehe sprmCSymbol) gesetzte Font !
+ if( nLen < 0 )
+ { // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
+ ResetCharSetVars();
+ return;
+ }
+
+ USHORT nFCode = SVBT16ToShort( pData ); // Font-Nummer
+
+ if( SetNewFontAttr( nFCode ) // Lies Inhalt
+ && pAktColl && pStyles ) // Style-Def ?
+ pStyles->bFontChanged = TRUE; // merken zur Simulation Default-Font
+ }
+}
+
+
+
+
+void SwWW8ImplReader::Read_FontSize( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){ // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONTSIZE );
+ return;
+ }
+
+// USHORT nFSize = bVer67 ? SVBT16ToShort( pData ) : *pData; // Font-Groesse in halben Point
+ USHORT nFSize = SVBT16ToShort( pData ); // Font-Groesse in halben Point
+
+ // 10 = 1440 / ( 72 * 2 )
+ SvxFontHeightItem aSz( (const ULONG)( (ULONG)nFSize * 10 ) );
+ NewAttr( aSz );
+ if( pAktColl && pStyles ) // Style-Def ?
+ pStyles->bFSizeChanged = TRUE; // merken zur Simulation Default-FontSize
+}
+
+
+
+void SwWW8ImplReader::Read_CharSet( USHORT nId, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){ // Ende des Attributes
+ eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
+ return;
+ }
+ BYTE nfChsDiff = SVBT8ToByte( pData );
+
+ if( nfChsDiff )
+ eHardCharSet = rtl_getTextEncodingFromWindowsCharset( *(pData + 1) );
+ else
+ eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
+}
+
+void SwWW8ImplReader::Read_Language( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){ // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_LANGUAGE );
+ return;
+ }
+ USHORT nLang = SVBT16ToShort( pData ); // Language-Id
+
+ NewAttr( SvxLanguageItem( (const LanguageType)nLang ) );
+}
+
+
+
+/*
+ Einschalten des Zeichen-Styles:
+*/
+void SwWW8ImplReader::Read_CColl( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){ // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CHARFMT );
+ nCharFmt = -1;
+ return;
+ }
+ USHORT nId = SVBT16ToShort( pData ); // Style-Id (NICHT Sprm-Id!)
+
+ if( nId >= nColls || !pCollA[nId].pFmt // ungueltige Id ?
+ || pCollA[nId].bColl ) // oder Para-Style ?
+ return; // dann ignorieren
+
+ NewAttr( SwFmtCharFmt( (SwCharFmt*)pCollA[nId].pFmt ) );
+ nCharFmt = (short) nId;
+}
+
+
+/*
+ enger oder weiter als normal:
+*/
+void SwWW8ImplReader::Read_Kern( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ){ // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_KERNING );
+ return;
+ }
+ INT16 nKern = SVBT16ToShort( pData ); // Kerning in Twips
+ NewAttr( SvxKerningItem( nKern ) );
+}
+
+void SwWW8ImplReader::Read_FontKern( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen < 0 )
+ // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_AUTOKERN );
+ else
+ NewAttr( SvxAutoKernItem( TRUE ) );
+}
+
+void SwWW8ImplReader::Read_CharShadow( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
+ if( bCharShdTxtCol )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); // Zeichenfarbe auch
+ bCharShdTxtCol = FALSE;
+ }
+ }
+ else
+ {
+ WW8_SHD aSHD;
+ aSHD.SetWWValue( *(SVBT16*)pData );
+ SwWW8Shade aSh( bVer67, aSHD );
+
+ NewAttr( SvxBrushItem( aSh.aColor, RES_CHRATR_BACKGROUND ));
+
+ // weisse Schrift und nicht ueberattributiert
+ if( aSh.bWhiteText && !bTxtCol && !bShdTxtCol )
+ {
+ NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
+ bCharShdTxtCol = TRUE;
+ }
+ }
+}
+
+void SwWW8ImplReader::Read_CharHighlight( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
+ if( bCharShdTxtCol )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); // Zeichenfarbe auch
+ bCharShdTxtCol = FALSE;
+ }
+ }
+ else
+ {
+ BYTE b = *pData; // Parameter: 0 = Auto, 1..16 Farben
+
+ if( b > 16 ) // unbekannt -> Black
+ b = 0; // Auto -> Black
+
+ Color aCol( eSwWW8ColA[b] );
+ NewAttr( SvxBrushItem( aCol , RES_CHRATR_BACKGROUND ));
+
+ // weisse Schrift und nicht ueberattributiert
+ if( COL_BLACK == aCol.GetColor() && !bTxtCol && !bShdTxtCol )
+ {
+ NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
+ bCharShdTxtCol = TRUE;
+ }
+ }
+}
+
+
+/***************************************************************************
+# Absatz - Attribute
+#**************************************************************************/
+
+void SwWW8ImplReader::Read_NoLineNumb( USHORT nId, BYTE* pData, short nLen )
+{
+ if( nLen < 0 ) // Ende des Attributes
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_LINENUMBER );
+ return;
+ }
+ SwFmtLineNumber aLN;
+ aLN.SetCountLines( pData && (0 == *pData) );
+ NewAttr( aLN );
+}
+
+void SwWW8ImplReader::Read_LR( USHORT nId, BYTE* pData, short nLen ) // Sprm 16, 17
+{
+ if( nIniFlags & WW8FL_NO_LRUL )
+ return;
+
+ if( nLen < 0 ) // Ende des Attributes
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_LR_SPACE );
+ return;
+ }
+
+ short nPara = SVBT16ToShort( pData );
+
+ SvxLRSpaceItem aLR( *(SvxLRSpaceItem*)GetFmtAttr( RES_LR_SPACE ));
+
+ switch( nId )
+ {
+ //sprmPDxaLeft
+ case 17:
+ case 0x840F:
+ if( nPara < 0 )
+ nPara = 0;
+ if( !aLR.GetTxtFirstLineOfst() )
+ aLR.SetTxtFirstLineOfst( 1 );
+ else
+ if( aLR.GetTxtFirstLineOfst() < -nPara )
+ // Erstzeileneinzug anpassen, sonst weigert sich SetTxtLeft()
+ aLR.SetTxtFirstLineOfst( -nPara );
+
+ aLR.SetTxtLeft( nPara );
+ if( pAktColl )
+ {
+ pCollA[nAktColl].nLeftParaMgn = nPara; // fuer Tabs merken
+ pCollA[nAktColl].nTxtFirstLineOfst = aLR.GetTxtFirstLineOfst();
+ }
+ else
+ {
+ nLeftParaMgn = nPara; // fuer Tabs merken
+ nTxtFirstLineOfst = aLR.GetTxtFirstLineOfst();
+ }
+ break;
+ //sprmPDxaLeft1
+ case 19:
+ case 0x8411:
+ if( -nPara > (short)aLR.GetTxtLeft() )
+ nPara = -(short)aLR.GetTxtLeft();
+ aLR.SetTxtFirstLineOfst( nPara );
+ if( pAktColl )
+ {
+ pCollA[nAktColl].nTxtFirstLineOfst = nPara; // fuer Tabs merken
+ }
+ else
+ {
+ nTxtFirstLineOfst = nPara; // fuer Tabs merken
+ }
+ break;
+ //sprmPDxaRight
+ case 16:
+ case 0x840E:
+ if( nPara < 0 )
+ nPara = 0;
+ aLR.SetRight( nPara );
+ break;
+ default: return;
+ }
+ NewAttr( aLR );
+}
+
+void SwWW8ImplReader::Read_LineSpace( USHORT, BYTE* pData, short nLen ) // Sprm 20
+{
+// Kommentear siehe Read_UL()
+ if( bStyNormal && ( bWWBugNormal || ( nIniFlags & WW8FL_NO_STD_STY_DYA ) ) )
+ return;
+
+ if( nLen < 0 ){
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_LINESPACING );
+ if( !( nIniFlags & WW8FL_NO_IMPLPASP ) )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_UL_SPACE );
+ return;
+ }
+ short nSpace = SVBT16ToShort( pData );
+ short nMulti = SVBT16ToShort( pData + 2 );
+
+ SvxLineSpace eLnSpc;
+ if( 0 > nSpace )
+ {
+ nSpace = -nSpace;
+ eLnSpc = SVX_LINE_SPACE_FIX;
+ }
+ else
+ eLnSpc = SVX_LINE_SPACE_MIN;
+
+// WW hat einen impliziten zusaetzlichen Absatzabstand abhaengig vom
+// Zeilenabstand. Er betraegt bei "genau", 0.8*Zeilenabstand "vor" und
+// 0.2*Zeilenabstand "nach".
+// Bei "Mindestens" sind es 1*Zeilenabstand "vor" und 0*Zeilenabstand "nach".
+// Bei Mehrfach sind es 0 "vor" und min( 0cm, FontSize*(nFach-1) ) "nach".
+//
+// SW hat auch einen impliziten Zeilenabstand. er betraegt bei "mindestens"
+// 1*Zeilenabstand "vor" und 0 "nach"
+// bei proportional betraegt er min( 0cm, FontSize*(nFach-1) ) sowohl "vor"
+// wie auch "nach"
+
+ USHORT nWwPre = 0;
+ USHORT nWwPost = 0;
+ USHORT nSwPre = 0;
+ USHORT nSwPost = 0;
+ USHORT nSpaceTw = 0;
+
+ SvxLineSpacingItem aLSpc;
+
+ if( 1 == nMulti ) // MultilineSpace ( proportional )
+ {
+ long n = nSpace * 10 / 24; // WW: 240 = 100%, SW: 100 = 100%
+
+//JP 03.12.98: nach Absprache mit AMA ist die Begrenzung unsinnig
+ if( n>200 ) n = 200; // SW_UI-Maximum
+ aLSpc.SetPropLineSpace( (const BYTE)n );
+ SvxFontHeightItem* pH = (SvxFontHeightItem*)
+ GetFmtAttr( RES_CHRATR_FONTSIZE );
+ nSpaceTw = (USHORT)( n * pH->GetHeight() / 100 );
+
+ if( n > 100 )
+ nWwPost = nSwPre = nSwPost = (USHORT)( ( n - 100 )
+ * pH->GetHeight() / 100 );
+ }
+ else // Fixed / Minimum
+ {
+ // bei negativen Space ist der Abstand exakt, sonst minimum
+ nSpaceTw = (USHORT)nSpace;
+ aLSpc.SetLineHeight( nSpaceTw );
+ aLSpc.GetLineSpaceRule() = eLnSpc;
+ nSwPre = nSpace;
+
+ if( SVX_LINE_SPACE_FIX == eLnSpc ) // Genau
+ {
+ nWwPre = (USHORT)( 8L * nSpace / 10 );
+ nWwPost = (USHORT)( 2L * nSpace / 10 );
+ nSwPre = nSpace;
+ }
+ else // Minimum
+ {
+ nWwPre = (USHORT)( 129L * nSpace / 100 - 95 );// erst bei groesseren
+ // Zeilenabstaenden
+ }
+ }
+ NewAttr( aLSpc );
+ if( pSFlyPara )
+ pSFlyPara->nLineSpace = nSpaceTw; // LineSpace fuer Graf-Apos
+
+ if( ( nWwPre > nSwPre || nWwPost > nSwPost )
+ && !( nIniFlags & WW8FL_NO_IMPLPASP ) )
+ {
+ SvxULSpaceItem aUL( *(SvxULSpaceItem*)GetFmtAttr( RES_UL_SPACE ));
+ short nDU = aUL.GetUpper() + nWwPre - nSwPre;
+ short nDL = aUL.GetLower() + nWwPost - nSwPost;
+ if( nDU > 0 )
+ aUL.SetUpper( nDU );
+ else
+ nDL += nDU;
+
+ if( nDL > 0 )
+ aUL.SetLower( nDL );
+ NewAttr( aUL );
+ }
+}
+
+void SwWW8ImplReader::Read_UL( USHORT nId, BYTE* pData, short nLen ) // Sprm 21, 22
+{
+ if( nIniFlags & WW8FL_NO_LRUL )
+ return;
+
+// Nun eine Umpopelung eines WW-Fehlers: Bei nProduct == 0c03d wird
+// faelschlicherweise ein DyaAfter 240 ( delta y abstand after, amn.d.b.)
+// im Style "Normal" eingefuegt, der
+// gar nicht da ist. Ueber das IniFlag WW8FL_NO_STY_DYA laesst sich dieses
+// Verhalten auch fuer andere WW-Versionen erzwingen
+// ASSERT( !bStyNormal || bWWBugNormal, "+Dieses Doc deutet evtl. auf einen \
+//Fehler in der benutzten WW-Version hin. Wenn sich die Styles <Standard> bzw. \
+//<Normal> zwischen WW und SW im Absatz- oder Zeilenabstand unterscheiden, \
+//dann bitte dieses Doc SH zukommen lassen." );
+
+// if( bStyNormal && ( bWWBugNormal || ( nIniFlags & WW8FL_NO_STD_STY_DYA ) ) )
+// return;
+// bWWBugNormal ist kein hinreichendes Kriterium dafuer, dass der
+// angegebene Abstand falsch ist
+
+ if( bStyNormal && ( nIniFlags & WW8FL_NO_STD_STY_DYA ) )
+ return;
+
+ if( nLen < 0 ){ // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_UL_SPACE );
+ return;
+ }
+ short nPara = SVBT16ToShort( pData );
+ if( nPara < 0 )
+ nPara = -nPara;
+
+ SvxULSpaceItem aUL( *(SvxULSpaceItem*)GetFmtAttr( RES_UL_SPACE ));
+
+ switch( nId ){ // keine Versuche
+ //sprmPDyaBefore
+ case 21:
+ case 0xA413: aUL.SetUpper( nPara ); break;
+ //sprmPDyaAfter
+ case 22:
+ case 0xA414: aUL.SetLower( nPara ); break;
+ default: return;
+ };
+#if 0
+ // nIniFlags stehen in c:\winnt40\soffice.ini[user]
+ // siehe wwpar.hxx
+ // und SwWW8ImplReader::LoadDoc( SwPaM& rPaM )
+ //
+ if( nIniFlags & WW8FL_NO_IMPLPASP ){
+ switch( nId ){ // keine Versuche
+ case 21:
+ case 0xA413: aUL.SetUpper( nPara ); break;
+ case 22:
+ case 0xA414: aUL.SetLower( nPara ); break;
+ default: return;
+ };
+ }else{
+ // auf alte Werte addieren wg. implizitem Absatzabstand
+ // ( siehe Read_LineSpace() )
+ switch( nId ){
+ case 21:
+ case 0xA413: aUL.SetUpper( aUL.GetUpper() + nPara ); break;
+ case 22:
+ case 0xA414: aUL.SetLower( aUL.GetLower() + nPara ); break;
+ default: return;
+ };
+ }
+#endif
+ NewAttr( aUL );
+}
+
+void SwWW8ImplReader::Read_Justify( USHORT, BYTE* pData, short nLen )
+{
+ static SvxAdjust aAdjArr[] = { SVX_ADJUST_LEFT, SVX_ADJUST_CENTER,
+ SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK };
+
+ if( nLen < 0 ){
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_ADJUST );
+ return;
+ }
+ BYTE b = *pData;
+
+ NewAttr( SvxAdjustItem( aAdjArr[b&0x3] ) ); // "&0x3 gegen Tabellenueberlauf
+} // bei Stuss-Werten
+
+
+
+
+SwWW8Shade::SwWW8Shade( BOOL bVer67, const WW8_SHD& rSHD )
+{
+static ULONG __READONLY_DATA eMSGrayScale[] = {
+ // Nul-Brush
+ 0, // 0
+ // Solid-Brush
+ 1000, // 1
+ // promillemaessig abgestufte Schattierungen
+ 50, // 2
+ 100, // 3
+ 200, // 4
+ 250, // 5
+ 300, // 6
+ 400, // 7
+ 500, // 8
+ 600, // 9
+ 700, // 10
+ 750, // 11
+ 800, // 12
+ 900, // 13
+ 333, // 14 Dark Horizontal
+ 333, // 15 Dark Vertical
+ 333, // 16 Dark Forward Diagonal
+ 333, // 17 Dark Backward Diagonal
+ 333, // 18 Dark Cross
+ 333, // 19 Dark Diagonal Cross
+ 333, // 20 Horizontal
+ 333, // 21 Vertical
+ 333, // 22 Forward Diagonal
+ 333, // 23 Backward Diagonal
+ 333, // 24 Cross
+ 333, // 25 Diagonal Cross
+ // neun Nummern ohne Bedeutung in Ver8
+ 500, // 26
+ 500, // 27
+ 500, // 28
+ 500, // 29
+ 500, // 30
+ 500, // 31
+ 500, // 32
+ 500, // 33
+ 500, // 34
+ // und weiter gehts mit tollen Schattierungen ;-)
+ 25, // 35
+ 75, // 36
+ 125, // 37
+ 150, // 38
+ 175, // 39
+ 225, // 40
+ 275, // 41
+ 325, // 42
+ 350, // 43
+ 375, // 44
+ 425, // 45
+ 450, // 46
+ 475, // 47
+ 525, // 48
+ 550, // 49
+ 575, // 50
+ 625, // 51
+ 650, // 52
+ 675, // 53
+ 725, // 54
+ 775, // 55
+ 825, // 56
+ 850, // 57
+ 875, // 58
+ 925, // 59
+ 950, // 60
+ 975, // 61
+ // und zu guter Letzt:
+ 970};// 62
+ ColorData nFore;
+ ColorData nBack;
+ ULONG nWW8BrushStyle;
+ short b;
+
+ b = rSHD.GetFore();
+ if ( b >= 17 )
+ b = 0;
+ nFore = eSwWW8ColA[b];
+ // Vordergrund: Auto = Schwarz
+ b = rSHD.GetBack();
+ if( b >= 17 )
+ b = 0;
+ if( b == 0 )
+ b = 8; // Hintergrund: Auto = Weiss
+ nBack = eSwWW8ColA[b];
+
+ b = rSHD.GetStyle( bVer67 );
+
+ if( b >= sizeof( eMSGrayScale ) / sizeof ( eMSGrayScale[ 0 ] ) )
+ b = 0;
+
+ nWW8BrushStyle = eMSGrayScale[b];
+
+ switch( nWW8BrushStyle )
+ {
+ case 0: // Null-Brush
+ aColor.SetColor( nBack );
+ break;
+ case 1000:
+ aColor.SetColor( nFore );
+ break;
+ default:
+ {
+ Color aForeColor = Color( nFore );
+ Color aBackColor = Color( nBack );
+ ULONG nRed = aForeColor.GetRed() * nWW8BrushStyle;
+ ULONG nGreen = aForeColor.GetGreen() * nWW8BrushStyle;
+ ULONG nBlue = aForeColor.GetBlue() * nWW8BrushStyle;
+ nRed += (ULONG)(aBackColor.GetRed() *(1000-nWW8BrushStyle));
+ nGreen += (ULONG)(aBackColor.GetGreen()*(1000-nWW8BrushStyle));
+ nBlue += (ULONG)(aBackColor.GetBlue() *(1000-nWW8BrushStyle));
+
+ aColor.SetColor( RGB_COLORDATA( nRed/1000, nGreen/1000, nBlue/1000 ) );
+ }
+ break;
+ }
+ // schwarzer Hintergrund -> weisse Schrift
+ bWhiteText = (nFore == COL_BLACK) && ( 800 <= nWW8BrushStyle )
+ || (nBack == COL_BLACK) && ( 200 >= nWW8BrushStyle );
+}
+
+
+void SwWW8ImplReader::Read_Shade( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ { // Ende des Attributes
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BACKGROUND );
+ if( bShdTxtCol )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); // Zeichenfarbe auch
+ bShdTxtCol = FALSE;
+ }
+ }
+ else
+ {
+ WW8_SHD aSHD;
+ aSHD.SetWWValue( *(SVBT16*)pData );
+ SwWW8Shade aSh( bVer67, aSHD );
+
+ NewAttr( SvxBrushItem( aSh.aColor ) );
+
+ // weisse Schrift und nicht ueberattributiert
+ if( aSh.bWhiteText && !bTxtCol )
+ {
+ NewAttr( SvxColorItem( Color( COL_WHITE ) ) ); // -> weisse Schrift
+ bShdTxtCol = TRUE;
+ }
+ }
+}
+
+void SwWW8ImplReader::Read_Border( USHORT nId, BYTE* pData, short nLen )
+{
+ if( nLen < 0 )
+ {
+ if( bHasBorder )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BOX );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_SHADOW );
+ bHasBorder = FALSE;
+ }
+ }
+ else if( !bHasBorder )
+ {
+ // die Borders auf allen 4 Seiten werden gebuendelt.
+ // dieses vereinfacht die Verwaltung, d.h. die
+ // Box muss nicht 4 mal auf den CtrlStack und wieder
+ // runter
+ bHasBorder = TRUE;
+
+ WW8_BRC5 aBrcs; // Top, Left, Bottom, Right, Between
+ BOOL bBorder;
+
+ if( pAktColl )
+ bBorder = ::lcl_ReadBorders( bVer67, aBrcs, 0, pStyles );
+ else
+ bBorder = ::lcl_ReadBorders( bVer67, aBrcs, pPlcxMan->GetPapPLCF() );
+
+ if( bBorder ) // Border
+ {
+ BOOL bIsB = IsBorder( aBrcs, TRUE );
+ if( !bApo || !bIsB || ( pWFlyPara && !pWFlyPara->bBorderLines ))
+ {
+ // in Apo keine Umrandungen *ein*-schalten, da ich
+ // sonst die Flyumrandungen doppelt bekomme
+ // JP 04.12.98: aber nur wenn am Fly ein gesetzt ist, keine
+ // uebernehmen. Sonst wird gar keine gesetzt!
+ // Bug #59619#
+
+ // auch wenn kein Rand gesetzt ist, muss das Attribut gesetzt
+ // werden, sonst ist kein hartes Ausschalten von Style-Attrs
+ // moeglich
+ SvxBoxItem aBox;
+ SetBorder( aBox, aBrcs, TRUE );
+
+ Rectangle aInnerDist;
+ GetBorderDistance( aBrcs, aInnerDist );
+
+ aBox.SetDistance( (USHORT)aInnerDist.Left(), BOX_LINE_LEFT );
+ aBox.SetDistance( (USHORT)aInnerDist.Top(), BOX_LINE_TOP );
+ aBox.SetDistance( (USHORT)aInnerDist.Right(), BOX_LINE_RIGHT );
+ aBox.SetDistance( (USHORT)aInnerDist.Bottom(), BOX_LINE_BOTTOM );
+
+ NewAttr( aBox );
+
+ SvxShadowItem aS;
+ if( SetShadow( aS, aBox, aBrcs ) )
+ NewAttr( aS );
+ }
+ }
+ }
+}
+
+void SwWW8ImplReader::Read_Hyphenation( USHORT, BYTE* pData, short nLen )
+{
+ // set Hyphenation flag
+ if( nLen <= 0 )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_HYPHENZONE );
+ else
+ {
+ SvxHyphenZoneItem aAttr(
+ *(SvxHyphenZoneItem*)GetFmtAttr( RES_PARATR_HYPHENZONE ) );
+
+ aAttr.SetHyphen( 0 == *pData ); // sic !
+
+ if( !*pData )
+ {
+ aAttr.GetMinLead() = 2;
+ aAttr.GetMinTrail() = 2;
+ aAttr.GetMaxHyphens() = 0;
+ }
+
+ NewAttr( aAttr );
+ }
+}
+
+void SwWW8ImplReader::Read_WidowControl( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ {
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_WIDOWS );
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_ORPHANS );
+ }
+ else
+ {
+ BYTE nL = ( *pData & 1 ) ? 2 : 0;
+
+ NewAttr( SvxWidowsItem( nL ) ); // Aus -> nLines = 0
+ NewAttr( SvxOrphansItem( nL ) );
+
+ if( pAktColl && pStyles ) // Style-Def ?
+ pStyles->bWidowsChanged = TRUE; // merken zur Simulation
+ // Default-Widows
+ }
+}
+
+void SwWW8ImplReader::Read_KeepLines( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_SPLIT );
+ else
+ NewAttr( SvxFmtSplitItem( ( *pData & 1 ) == 0 ) );
+}
+
+void SwWW8ImplReader::Read_KeepParas( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_KEEP );
+ else
+ NewAttr( SvxFmtKeepItem( ( *pData & 1 ) != 0 ) );
+}
+
+void SwWW8ImplReader::Read_BreakBefore( USHORT, BYTE* pData, short nLen )
+{
+ if( nLen <= 0 )
+ pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BREAK );
+ else
+ NewAttr( SvxFmtBreakItem(
+ ( *pData & 1 ) ? SVX_BREAK_PAGE_BEFORE : SVX_BREAK_NONE ) );
+}
+
+void SwWW8ImplReader::Read_ApoPPC( USHORT, BYTE* pData, short nLen )
+{
+ if( pAktColl ){ // nur fuer Styledef, sonst anders geloest
+ SwWW8StyInf& rSI = pCollA[nAktColl];
+ WW8FlyPara* pFly = rSI.pWWFly;
+ if( !pFly ){
+ pFly = ( rSI.nBase >= nColls ) ?
+ new WW8FlyPara( bVer67 ) // !based on
+ : new WW8FlyPara( bVer67, pCollA[rSI.nBase].pWWFly ); // based on
+ pCollA[nAktColl].pWWFly = pFly;
+ if( !pFly->Read( pData, pStyles ) ) // Lese Style-Apo-Parameter
+ DELETEZ( pCollA[nAktColl].pWWFly );
+ }
+ }
+}
+
+/***************************************************************************
+# Seiten - Attribute werden nicht mehr als Attribute gehandhabt
+# ( ausser OLST )
+#**************************************************************************/
+
+
+/***************************************************************************
+# Arrays zum Lesen der erweiterten ( selbstdefinierten ) SPRMs
+#**************************************************************************/
+typedef long (SwWW8ImplReader:: *FNReadRecordExt)( WW8PLCFManResult*, BOOL );
+
+static FNReadRecordExt aWwSprmTab2[] = {
+/* 0 (256) */ &SwWW8ImplReader::Read_Ftn, // FootNote
+/* 1 (257) */ &SwWW8ImplReader::Read_Ftn, // EndNote
+/* 2 (258) */ &SwWW8ImplReader::Read_Field, // Feld
+/* 3 (259) */ &SwWW8ImplReader::Read_Book, // Bookmark
+/* 4 (260) */ &SwWW8ImplReader::Read_Piece, // Piece-Anfang / Ende
+/* 5 (261) */ &SwWW8ImplReader::Read_And // Annotation
+};
+
+long SwWW8ImplReader::ImportExtSprm( WW8PLCFManResult* pRes, BOOL bStart )
+{
+ if( pRes->nSprmId < 280 )
+ {
+ BYTE nIdx = pRes->nSprmId - 256;
+ if( nIdx < sizeof( aWwSprmTab2 ) / sizeof( *aWwSprmTab2 )
+ && aWwSprmTab2[nIdx] )
+ return (this->*aWwSprmTab2[nIdx])( pRes, bStart );
+ else
+ return 0;
+ }
+ else
+ return 0;
+}
+
+
+
+/***************************************************************************
+# Arrays zum Lesen der SPRMs
+#**************************************************************************/
+
+// Funktion zum Einlesen von Sprms. Par1: SprmId
+//typedef void (SwWW8ImplReader:: *FNReadRecord) ( BYTE, BYTE*, short );
+
+
+
+
+typedef void (SwWW8ImplReader:: *FNReadRecord)( USHORT, BYTE*, short );
+
+struct SprmReadInfo
+{
+ USHORT nId;
+ FNReadRecord pReadFnc;
+};
+
+SprmReadInfo& WW8GetSprmReadInfo( USHORT nId );
+
+
+
+SprmReadInfo aSprmReadTab[] = {
+ 0, (FNReadRecord)0, // "??0" Default bzw. Error wird uebersprungen! ,
+ 2, &SwWW8ImplReader::Read_StyleCode, // "sprmPIstd", // pap.istd (style code)
+
+ 3, (FNReadRecord)0, // "sprmPIstdPermute", // pap.istd permutation
+ 4, (FNReadRecord)0, // "sprmPIncLv1", // pap.istddifference
+ 5, &SwWW8ImplReader::Read_Justify, // "sprmPJc", // pap.jc (justification)
+ 6, (FNReadRecord)0, // "sprmPFSideBySide", // pap.fSideBySide
+ 7, &SwWW8ImplReader::Read_KeepLines, // "sprmPFKeep", // pap.fKeep
+ 8, &SwWW8ImplReader::Read_KeepParas, // "sprmPFKeepFollow ", // pap.fKeepFollow
+ 9, &SwWW8ImplReader::Read_BreakBefore, // "sprmPPageBreakBefore", // pap.fPageBreakBefore
+
+ 10, (FNReadRecord)0, // "sprmPBrcl", // pap.brcl
+ 11, (FNReadRecord)0, // "sprmPBrcp ", // pap.brcp
+ 12, &SwWW8ImplReader::Read_ANLevelDesc, // "sprmPAnld", // pap.anld (ANLD structure)
+ 13, &SwWW8ImplReader::Read_ANLevelNo, // "sprmPNLvlAnm", // pap.nLvlAnm nn
+ 14, &SwWW8ImplReader::Read_NoLineNumb, // "sprmPFNoLineNumb", //ap.fNoLnn
+
+//??
+ 15, &SwWW8ImplReader::Read_Tab, // "?sprmPChgTabsPapx", // pap.itbdMac, ...
+ 16, &SwWW8ImplReader::Read_LR, // "sprmPDxaRight", // pap.dxaRight
+ 17, &SwWW8ImplReader::Read_LR, // "sprmPDxaLeft", // pap.dxaLeft
+ 18, (FNReadRecord)0, // "sprmPNest", // pap.dxaLeft
+ 19, &SwWW8ImplReader::Read_LR, // "sprmPDxaLeft1", // pap.dxaLeft1
+
+ 20, &SwWW8ImplReader::Read_LineSpace, // "sprmPDyaLine", // pap.lspd an LSPD
+ 21, &SwWW8ImplReader::Read_UL, // "sprmPDyaBefore", // pap.dyaBefore
+ 22, &SwWW8ImplReader::Read_UL, // "sprmPDyaAfter", // pap.dyaAfter
+
+//??
+ 23, (FNReadRecord)0, // "?sprmPChgTabs", // pap.itbdMac, pap.rgdxaTab, ...
+ 24, (FNReadRecord)0, // "sprmPFInTable", // pap.fInTable
+ 25, &SwWW8ImplReader::Read_TabRowEnd, // "sprmPTtp", // pap.fTtp
+ 26, (FNReadRecord)0, // "sprmPDxaAbs", // pap.dxaAbs
+ 27, (FNReadRecord)0, // "sprmPDyaAbs", // pap.dyaAbs
+ 28, (FNReadRecord)0, // "sprmPDxaWidth", // pap.dxaWidth
+ 29, &SwWW8ImplReader::Read_ApoPPC, // "sprmPPc", // pap.pcHorz, pap.pcVert
+
+ 30, (FNReadRecord)0, // "sprmPBrcTop10", // pap.brcTop BRC10
+ 31, (FNReadRecord)0, // "sprmPBrcLeft10", // pap.brcLeft BRC10
+ 32, (FNReadRecord)0, // "sprmPBrcBottom10", // pap.brcBottom BRC10
+
+ 33, (FNReadRecord)0, // "sprmPBrcRight10", // pap.brcRight BRC10
+ 34, (FNReadRecord)0, // "sprmPBrcBetween10", // pap.brcBetween BRC10
+ 35, (FNReadRecord)0, // "sprmPBrcBar10", // pap.brcBar BRC10
+ 36, (FNReadRecord)0, // "sprmPFromText10", // pap.dxaFromText dxa
+ 37, (FNReadRecord)0, // "sprmPWr", // pap.wr wr
+ 38, &SwWW8ImplReader::Read_Border, // "sprmPBrcTop", // pap.brcTop BRC
+ 39, &SwWW8ImplReader::Read_Border, // "sprmPBrcLeft", // pap.brcLeft BRC
+
+ 40, &SwWW8ImplReader::Read_Border, // "sprmPBrcBottom", // pap.brcBottom BRC
+ 41, &SwWW8ImplReader::Read_Border, // "sprmPBrcRight", // pap.brcRight BRC
+ 42, &SwWW8ImplReader::Read_Border, // "sprmPBrcBetween", // pap.brcBetween BRC
+ 43, (FNReadRecord)0, // "sprmPBrcBar",//pap.brcBar BRC word
+ 44, &SwWW8ImplReader::Read_Hyphenation, // "sprmPFNoAutoHyph",//pap.fNoAutoHyph
+ 45, (FNReadRecord)0, // "sprmPWHeightAbs",//pap.wHeightAbs w
+ 46, (FNReadRecord)0, // "sprmPDcs",//pap.dcs DCS
+ 47, &SwWW8ImplReader::Read_Shade, // "sprmPShd",//pap.shd SHD
+ 48, (FNReadRecord)0, // "sprmPDyaFromText",//pap.dyaFromText dya
+ 49, (FNReadRecord)0, // "sprmPDxaFromText",//pap.dxaFromText dxa
+
+ 50, (FNReadRecord)0, // "sprmPFLocked", // pap.fLocked 0 or 1 byte
+ 51, &SwWW8ImplReader::Read_WidowControl, // "sprmPFWidowControl", // pap.fWidowControl 0 or 1 byte
+
+//??
+ 52, (FNReadRecord)0, // "?sprmPRuler 52", //???
+ 53, (FNReadRecord)0, // "??53",
+ 54, (FNReadRecord)0, // "??54",
+ 55, (FNReadRecord)0, // "??55",
+ 56, (FNReadRecord)0, // "??56",
+ 57, (FNReadRecord)0, // "??57",
+ 58, (FNReadRecord)0, // "??58",
+ 59, (FNReadRecord)0, // "??59",
+
+ 60, (FNReadRecord)0, // "??60",
+ 61, (FNReadRecord)0, // "??61",
+ 62, (FNReadRecord)0, // "??62",
+ 63, (FNReadRecord)0, // "??63",
+ 64, (FNReadRecord)0, // "??64",
+ 65, &SwWW8ImplReader::Read_CFRMarkDel, // "sprmCFStrikeRM", // chp.fRMarkDel 1 or 0 bit
+ 66, &SwWW8ImplReader::Read_CFRMark, // "sprmCFRMark", // chp.fRMark 1 or 0 bit
+ 67, &SwWW8ImplReader::Read_FldVanish, // "sprmCFFldVanish", // chp.fFldVanish 1 or 0 bit
+ 68, &SwWW8ImplReader::Read_PicLoc, // "sprmCPicLocation", // chp.fcPic and chp.fSpec
+ 69, (FNReadRecord)0, // "sprmCIbstRMark", // chp.ibstRMark index into sttbRMark
+
+ 70, (FNReadRecord)0, // "sprmCDttmRMark", // chp.dttm DTTM long
+ 71, (FNReadRecord)0, // "sprmCFData", // chp.fData 1 or 0 bit
+ 72, (FNReadRecord)0, // "sprmCRMReason", // chp.idslRMReason an index to a table
+ 73, &SwWW8ImplReader::Read_CharSet, // "sprmCChse", // chp.fChsDiff and chp.chse see below 3 bytes
+ 74, &SwWW8ImplReader::Read_Symbol, // "sprmCSymbol", // chp.fSpec, chp.chSym and chp.ftcSym
+ 75, &SwWW8ImplReader::Read_Obj, // "sprmCFOle2", // chp.fOle2 1 or 0 bit
+ 76, (FNReadRecord)0, // "??76",
+ 77, (FNReadRecord)0, // "??77",
+ 78, (FNReadRecord)0, // "??78",
+ 79, (FNReadRecord)0, // "??79",
+
+ 80, &SwWW8ImplReader::Read_CColl, // "sprmCIstd", // chp.istd istd, see stylesheet definition short
+ 81, (FNReadRecord)0, // "sprmCIstdPermute", // chp.istd permutation vector (see below)
+ 82, (FNReadRecord)0, // "sprmCDefault", // whole CHP (see below) none variable length
+ 83, (FNReadRecord)0, // "sprmCPlain", // whole CHP (see below) none 0
+ 84, (FNReadRecord)0, // "??84",
+ 85, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFBold", // chp.fBold 0,1, 128, or 129 (see below) byte
+ 86, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFItalic", // chp.fItalic 0,1, 128, or 129 (see below) byte
+ 87, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFStrike", // chp.fStrike 0,1, 128, or 129 (see below) byte
+ 88, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFOutline", // chp.fOutline 0,1, 128, or 129 (see below) byte
+ 89, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFShadow", // chp.fShadow 0,1, 128, or 129 (see below) byte
+
+ 90, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFSmallCaps", // chp.fSmallCaps 0,1, 128, or 129 (see below) byte
+ 91, &SwWW8ImplReader::Read_BoldUsw, // "sprmCFCaps", // chp.fCaps 0,1, 128, or 129 (see below) byte
+
+ 92, &SwWW8ImplReader::Read_Invisible, // "sprmCFVanish", // chp.fVanish 0,1, 128, or 129 (see below) byte
+
+ 93, &SwWW8ImplReader::Read_FontCode, // "sprmCFtc", // chp.ftc ftc word
+ 94, &SwWW8ImplReader::Read_Underline, // "sprmCKul", // chp.kul kul byte
+ 95, (FNReadRecord)0, // "sprmCSizePos", // chp.hps, chp.hpsPos (see below) 3 bytes
+ 96, &SwWW8ImplReader::Read_Kern, // "sprmCDxaSpace", // chp.dxaSpace dxa word
+ 97, &SwWW8ImplReader::Read_Language, // "sprmCLid", // chp.lid LID word
+ 98, &SwWW8ImplReader::Read_TxtColor, // "sprmCIco", // chp.ico ico byte
+ 99, &SwWW8ImplReader::Read_FontSize, // "sprmCHps", // chp.hps hps word!
+
+
+ 100, (FNReadRecord)0, // "sprmCHpsInc", // chp.hps (see below) byte
+ 101, &SwWW8ImplReader::Read_SubSuperProp, // "sprmCHpsPos", // chp.hpsPos hps byte
+ 102, (FNReadRecord)0, // "sprmCHpsPosAdj", // chp.hpsPos hps (see below) byte
+
+//??
+ 103, &SwWW8ImplReader::Read_Majority, // "?sprmCMajority", // chp.fBold, chp.fItalic, chp.fSmallCaps, ...
+ 104, &SwWW8ImplReader::Read_SubSuper, // "sprmCIss", // chp.iss iss byte
+ 105, (FNReadRecord)0, // "sprmCHpsNew50", // chp.hps hps variable width, length always recorded as 2
+ 106, (FNReadRecord)0, // "sprmCHpsInc1", // chp.hps complex (see below) variable width, length always recorded as 2
+ 107, &SwWW8ImplReader::Read_FontKern, // "sprmCHpsKern", // chp.hpsKern hps short
+ 108, &SwWW8ImplReader::Read_Majority, // "sprmCMajority50", // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, ...
+ 109, (FNReadRecord)0, // "sprmCHpsMul", // chp.hps percentage to grow hps short
+
+ 110, (FNReadRecord)0, // "sprmCCondHyhen", // chp.ysri ysri short
+ 111, (FNReadRecord)0, // "??111",
+ 112, (FNReadRecord)0, // "??112",
+ 113, (FNReadRecord)0, // "??113",
+ 114, (FNReadRecord)0, // "??114",
+ 115, (FNReadRecord)0, // "??115",
+ 116, (FNReadRecord)0, // "??116",
+ 117, &SwWW8ImplReader::Read_Special, // "sprmCFSpec", // chp.fSpec 1 or 0 bit
+ 118, &SwWW8ImplReader::Read_Obj, // "sprmCFObj", // chp.fObj 1 or 0 bit
+ 119, (FNReadRecord)0, // "sprmPicBrcl", // pic.brcl brcl (see PIC structure definition) byte
+
+ 120, (FNReadRecord)0, // "sprmPicScale", // pic.mx, pic.my, pic.dxaCropleft,
+ 121, (FNReadRecord)0, // "sprmPicBrcTop", // pic.brcTop BRC word
+ 122, (FNReadRecord)0, // "sprmPicBrcLeft", // pic.brcLeft BRC word
+ 123, (FNReadRecord)0, // "sprmPicBrcBottom", // pic.brcBottom BRC word
+ 124, (FNReadRecord)0, // "sprmPicBrcRight", // pic.brcRight BRC word
+ 125, (FNReadRecord)0, // "??125",
+ 126, (FNReadRecord)0, // "??126",
+ 127, (FNReadRecord)0, // "??127",
+ 128, (FNReadRecord)0, // "??128",
+ 129, (FNReadRecord)0, // "??129",
+
+ 130, (FNReadRecord)0, // "??130",
+ 131, (FNReadRecord)0, // "sprmSScnsPgn", // sep.cnsPgn cns byte
+ 132, (FNReadRecord)0, // "sprmSiHeadingPgn", // sep.iHeadingPgn heading number level byte
+ 133, &SwWW8ImplReader::Read_OLST, // "sprmSOlstAnm", // sep.olstAnm OLST variable length
+ 134, (FNReadRecord)0, // "??135",
+ 135, (FNReadRecord)0, // "??135",
+ 136, (FNReadRecord)0, // "sprmSDxaColWidth", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 137, (FNReadRecord)0, // "sprmSDxaColSpacing", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 138, (FNReadRecord)0, // "sprmSFEvenlySpaced", // sep.fEvenlySpaced 1 or 0 byte
+ 139, (FNReadRecord)0, // "sprmSFProtected", // sep.fUnlocked 1 or 0 byte
+ 140, (FNReadRecord)0, // "sprmSDmBinFirst", // sep.dmBinFirst word
+ 141, (FNReadRecord)0, // "sprmSDmBinOther", // sep.dmBinOther word
+ 142, (FNReadRecord)0, // "sprmSBkc", // sep.bkc bkc byte BreakCode
+ 143, (FNReadRecord)0, // "sprmSFTitlePage", // sep.fTitlePage 0 or 1 byte
+ 144, (FNReadRecord)0, // "sprmSCcolumns", // sep.ccolM1 # of cols - 1 word
+ 145, (FNReadRecord)0, // "sprmSDxaColumns", // sep.dxaColumns dxa word
+ 146, (FNReadRecord)0, // "sprmSFAutoPgn", // sep.fAutoPgn obsolete byte
+ 147, (FNReadRecord)0, // "sprmSNfcPgn", // sep.nfcPgn nfc byte
+ 148, (FNReadRecord)0, // "sprmSDyaPgn", // sep.dyaPgn dya short
+ 149, (FNReadRecord)0, // "sprmSDxaPgn", // sep.dxaPgn dya short
+
+ 150, (FNReadRecord)0, // "sprmSFPgnRestart", // sep.fPgnRestart 0 or 1 byte
+ 151, (FNReadRecord)0, // "sprmSFEndnote", // sep.fEndnote 0 or 1 byte
+ 152, (FNReadRecord)0, // "sprmSLnc", // sep.lnc lnc byte
+ 153, (FNReadRecord)0, // "sprmSGprfIhdt", // sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
+ 154, (FNReadRecord)0, // "sprmSNLnnMod", // sep.nLnnMod non-neg int. word
+
+ 155, (FNReadRecord)0, // "sprmSDxaLnn", // sep.dxaLnn dxa word
+ 156, (FNReadRecord)0, // "sprmSDyaHdrTop", // sep.dyaHdrTop dya word
+ 157, (FNReadRecord)0, // "sprmSDyaHdrBottom", // sep.dyaHdrBottom dya word
+ 158, (FNReadRecord)0, // "sprmSLBetween", // sep.fLBetween 0 or 1 byte
+ 159, (FNReadRecord)0, // "sprmSVjc", // sep.vjc vjc byte
+
+ 160, (FNReadRecord)0, // "sprmSLnnMin", // sep.lnnMin lnn word
+ 161, (FNReadRecord)0, // "sprmSPgnStart", // sep.pgnStart pgn word
+ 162, (FNReadRecord)0, // "sprmSBOrientation", // sep.dmOrientPage dm byte
+
+//??
+ 163, (FNReadRecord)0, // "?SprmSBCustomize 163", //???
+ 164, (FNReadRecord)0, // "sprmSXaPage", // sep.xaPage xa word
+ 165, (FNReadRecord)0, // "sprmSYaPage", // sep.yaPage ya word
+ 166, (FNReadRecord)0, // "sprmSDxaLeft", // sep.dxaLeft dxa word
+ 167, (FNReadRecord)0, // "sprmSDxaRight", // sep.dxaRight dxa word
+ 168, (FNReadRecord)0, // "sprmSDyaTop", // sep.dyaTop dya word
+ 169, (FNReadRecord)0, // "sprmSDyaBottom", // sep.dyaBottom dya word
+
+ 170, (FNReadRecord)0, // "sprmSDzaGutter", // sep.dzaGutter dza word
+ 171, (FNReadRecord)0, // "sprmSDMPaperReq", // sep.dmPaperReq dm word
+ 172, (FNReadRecord)0, // "??172",
+ 173, (FNReadRecord)0, // "??173",
+ 174, (FNReadRecord)0, // "??174",
+ 175, (FNReadRecord)0, // "??175",
+ 176, (FNReadRecord)0, // "??176",
+ 177, (FNReadRecord)0, // "??177",
+ 178, (FNReadRecord)0, // "??178",
+ 179, (FNReadRecord)0, // "??179",
+
+ 180, (FNReadRecord)0, // "??180",
+ 181, (FNReadRecord)0, // "??181",
+ 182, (FNReadRecord)0, // "sprmTJc", // tap.jc jc word (low order byte is significant)
+ 183, (FNReadRecord)0, // "sprmTDxaLeft", // tap.rgdxaCenter (see below) dxa word
+ 184, (FNReadRecord)0, // "sprmTDxaGapHalf", // tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
+ 185, (FNReadRecord)0, // "sprmTFCantSplit", // tap.fCantSplit 1 or 0 byte
+ 186, (FNReadRecord)0, // "sprmTTableHeader", // tap.fTableHeader 1 or 0 byte
+ 187, (FNReadRecord)0, // "sprmTTableBorders", // tap.rgbrcTable complex(see below) 12 bytes
+ 188, (FNReadRecord)0, // "sprmTDefTable10", // tap.rgdxaCenter, tap.rgtc complex (see below) variable length
+ 189, (FNReadRecord)0, // "sprmTDyaRowHeight", // tap.dyaRowHeight dya word
+
+
+//??
+ 190, (FNReadRecord)0, // "?sprmTDefTable", // tap.rgtc complex (see below)
+
+//??
+ 191, (FNReadRecord)0, // "?sprmTDefTableShd", // tap.rgshd complex (see below)
+ 192, (FNReadRecord)0, // "sprmTTlp", // tap.tlp TLP 4 bytes
+ 193, (FNReadRecord)0, // "sprmTSetBrc", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+ 194, (FNReadRecord)0, // "sprmTInsert", // tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
+ 195, (FNReadRecord)0, // "sprmTDelete", // tap.rgdxaCenter, tap.rgtc complex (see below) word
+ 196, (FNReadRecord)0, // "sprmTDxaCol", // tap.rgdxaCenter complex (see below) 4 bytes
+ 197, (FNReadRecord)0, // "sprmTMerge", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 198, (FNReadRecord)0, // "sprmTSplit", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 199, (FNReadRecord)0, // "sprmTSetBrc10", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+
+ 200, (FNReadRecord)0, // "sprmTSetShd", // tap.rgshd complex (see below) 4 bytes
+
+#if 0
+// ab hier Selbstdefinierte Ids
+
+/* 0 (256) */ &SwWW8ImplReader::Read_Ftn, // FootNote
+/* 1 (257) */ &SwWW8ImplReader::Read_Ftn, // EndNote
+/* 2 (258) */ &SwWW8ImplReader::Read_Field, // Feld
+/* 3 (259) */ &SwWW8ImplReader::Read_Book, // Bookmark
+/* 4 (260) */ &SwWW8ImplReader::Read_Piece // Piece-Anfang / Ende
+
+
+// ab hier Selbstdefinierte Ids
+
+ 256, (FnOut)0, "FootNote",
+ 257, (FnOut)0, "EndNote",
+ 258, (FnOut)0, "??258 selbstdef.",
+ 259, (FnOut)0, "??259 selbstdef.",
+ 260, (FnOut)0, "Field",
+#endif
+//- neue ab Ver8 ------------------------------------------------------------
+
+ 0x4600, &SwWW8ImplReader::Read_StyleCode, //"sprmPIstd" // pap.istd;istd (style code);short;
+ 0xC601, (FNReadRecord)0, //"sprmPIstdPermute" // pap.istd;permutation vector (see below);variable length;
+ 0x2602, (FNReadRecord)0, //"sprmPIncLvl" // pap.istd, pap.lvl;difference between istd of base PAP and istd of PAP to be produced (see below);byte;
+ 0x2403, &SwWW8ImplReader::Read_Justify, //"sprmPJc" // pap.jc;jc (justification);byte;
+ 0x2404, (FNReadRecord)0, //"sprmPFSideBySide" // pap.fSideBySide;0 or 1;byte;
+ 0x2405, &SwWW8ImplReader::Read_KeepLines, //"sprmPFKeep" // pap.fKeep;0 or 1;byte;
+ 0x2406, &SwWW8ImplReader::Read_KeepParas, //"sprmPFKeepFollow" // pap.fKeepFollow;0 or 1;byte;
+ 0x2407, &SwWW8ImplReader::Read_BreakBefore, //"sprmPFPageBreakBefore" // pap.fPageBreakBefore;0 or 1;byte;
+ 0x2408, (FNReadRecord)0, //"sprmPBrcl" // pap.brcl;brcl;byte;
+ 0x2409, (FNReadRecord)0, //"sprmPBrcp" // pap.brcp;brcp;byte;
+ 0x260A, &SwWW8ImplReader::Read_ListLevel, //"sprmPIlvl" // pap.ilvl;ilvl;byte;
+ 0x460B, &SwWW8ImplReader::Read_LFOPosition, //"sprmPIlfo" // pap.ilfo;ilfo (list index) ;short;
+ 0x240C, &SwWW8ImplReader::Read_NoLineNumb, //"sprmPFNoLineNumb" // pap.fNoLnn;0 or 1;byte;
+ 0xC60D, &SwWW8ImplReader::Read_Tab, //"sprmPChgTabsPapx" // pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length
+ 0x840E, &SwWW8ImplReader::Read_LR, //"sprmPDxaRight" // pap.dxaRight;dxa;word;
+ 0x840F, &SwWW8ImplReader::Read_LR, //"sprmPDxaLeft" // pap.dxaLeft;dxa;word;
+ 0x4610, (FNReadRecord)0, //"sprmPNest" // pap.dxaLeft;dxa-see below;word;
+ 0x8411, &SwWW8ImplReader::Read_LR, //"sprmPDxaLeft1" // pap.dxaLeft1;dxa;word;
+ 0x6412, &SwWW8ImplReader::Read_LineSpace, //"sprmPDyaLine" // pap.lspd;an LSPD, a long word structure consisting of a short of dyaLine followed by a short of fMultLinespace - see below;long;
+ 0xA413, &SwWW8ImplReader::Read_UL, //"sprmPDyaBefore" // pap.dyaBefore;dya;word;
+ 0xA414, &SwWW8ImplReader::Read_UL, //"sprmPDyaAfter" // pap.dyaAfter;dya;word;
+ 0xC615, (FNReadRecord)0, //"sprmPChgTabs" // pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length;
+ 0x2416, (FNReadRecord)0, //"sprmPFInTable" // pap.fInTable;0 or 1;byte;
+ 0x2417, &SwWW8ImplReader::Read_TabRowEnd, //"sprmPFTtp" // // pap.fTtp;0 or 1;byte;
+ 0x8418, (FNReadRecord)0, //"sprmPDxaAbs" // pap.dxaAbs;dxa;word;
+ 0x8419, (FNReadRecord)0, //"sprmPDyaAbs" // pap.dyaAbs;dya;word;
+ 0x841A, (FNReadRecord)0, //"sprmPDxaWidth" // pap.dxaWidth;dxa;word;
+ 0x261B, &SwWW8ImplReader::Read_ApoPPC, //"sprmPPc" // pap.pcHorz, pap.pcVert;complex - see below;byte;
+ 0x461C, (FNReadRecord)0, //"sprmPBrcTop10" // pap.brcTop;BRC10;word;
+ 0x461D, (FNReadRecord)0, //"sprmPBrcLeft10" // pap.brcLeft;BRC10;word;
+ 0x461E, (FNReadRecord)0, //"sprmPBrcBottom10" // pap.brcBottom;BRC10;word;
+ 0x461F, (FNReadRecord)0, //"sprmPBrcRight10" // pap.brcRight;BRC10;word;
+ 0x4620, (FNReadRecord)0, //"sprmPBrcBetween10" // pap.brcBetween;BRC10;word;
+ 0x4621, (FNReadRecord)0, //"sprmPBrcBar10" // pap.brcBar;BRC10;word;
+ 0x4622, (FNReadRecord)0, //"sprmPDxaFromText10" // pap.dxaFromText;dxa;word;
+ 0x2423, (FNReadRecord)0, //"sprmPWr" // pap.wr;wr (see description of PAP for definition;byte;
+ 0x6424, &SwWW8ImplReader::Read_Border, //"sprmPBrcTop" // pap.brcTop;BRC;long;
+ 0x6425, &SwWW8ImplReader::Read_Border, //"sprmPBrcLeft" // pap.brcLeft;BRC;long;
+ 0x6426, &SwWW8ImplReader::Read_Border, //"sprmPBrcBottom" // pap.brcBottom;BRC;long;
+ 0x6427, &SwWW8ImplReader::Read_Border, //"sprmPBrcRight" // pap.brcRight;BRC;long;
+ 0x6428, &SwWW8ImplReader::Read_Border, //"sprmPBrcBetween" // pap.brcBetween;BRC;long;
+ 0x6629, (FNReadRecord)0, //"sprmPBrcBar" // pap.brcBar;BRC;long;
+ 0x242A, &SwWW8ImplReader::Read_Hyphenation, //"sprmPFNoAutoHyph" // pap.fNoAutoHyph;0 or 1;byte;
+ 0x442B, (FNReadRecord)0, //"sprmPWHeightAbs" // pap.wHeightAbs;w;word;
+ 0x442C, (FNReadRecord)0, //"sprmPDcs" // pap.dcs;DCS;short;
+ 0x442D, &SwWW8ImplReader::Read_Shade, //"sprmPShd" // pap.shd;SHD;word;
+ 0x842E, (FNReadRecord)0, //"sprmPDyaFromText" // pap.dyaFromText;dya;word;
+ 0x842F, (FNReadRecord)0, //"sprmPDxaFromText" // pap.dxaFromText;dxa;word;
+ 0x2430, (FNReadRecord)0, //"sprmPFLocked" // pap.fLocked;0 or 1;byte;
+ 0x2431, &SwWW8ImplReader::Read_WidowControl, //"sprmPFWidowControl" // pap.fWidowControl;0 or 1;byte;
+ 0xC632, (FNReadRecord)0, //"sprmPRuler" // ;;variable length;
+ 0x2433, (FNReadRecord)0, //"sprmPFKinsoku" // pap.fKinsoku;0 or 1;byte;
+ 0x2434, (FNReadRecord)0, //"sprmPFWordWrap" // pap.fWordWrap;0 or 1;byte;
+ 0x2435, (FNReadRecord)0, //"sprmPFOverflowPunct" // pap.fOverflowPunct;0 or 1;byte;
+ 0x2436, (FNReadRecord)0, //"sprmPFTopLinePunct" // pap.fTopLinePunct;0 or 1;byte;
+ 0x2437, (FNReadRecord)0, //"sprmPFAutoSpaceDE" // pap.fAutoSpaceDE;0 or 1;byte;
+ 0x2438, (FNReadRecord)0, //"sprmPFAutoSpaceDN" // pap.fAutoSpaceDN;0 or 1;byte;
+ 0x4439, (FNReadRecord)0, //"sprmPWAlignFont" // pap.wAlignFont;iFa (see description of PAP for definition);word;
+ 0x443A, (FNReadRecord)0, //"sprmPFrameTextFlow" // pap.fVertical pap.fBackward pap.fRotateFont;complex (see description of PAP for definition);word;
+ 0x243B, (FNReadRecord)0, //"sprmPISnapBaseLine" // obsolete: not applicable in Word97 and later versions;;byte;
+ 0xC63E, &SwWW8ImplReader::Read_ANLevelDesc, //"sprmPAnld" // pap.anld;;variable length;
+ 0xC63F, (FNReadRecord)0, //"sprmPPropRMark" // pap.fPropRMark;complex (see below);variable length;
+ 0x2640, &SwWW8ImplReader::Read_POutLvl, //"sprmPOutLvl" // pap.lvl;has no effect if pap.istd is < 1 or is > 9;byte;
+ 0x2441, (FNReadRecord)0, //"sprmPFBiDi" // ;;byte;
+ 0x2443, (FNReadRecord)0, //"sprmPFNumRMIns" // pap.fNumRMIns;1 or 0;bit;
+ 0x2444, (FNReadRecord)0, //"sprmPCrLf" // ;;byte;
+ 0xC645, (FNReadRecord)0, //"sprmPNumRM" // pap.numrm;;variable length;
+ 0x6645, (FNReadRecord)0, //"sprmPHugePapx" // see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x6646, (FNReadRecord)0, //"sprmPHugePapx" // see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x2447, (FNReadRecord)0, //"sprmPFUsePgsuSettings" // pap.fUsePgsuSettings;1 or 0;byte;
+ 0x2448, (FNReadRecord)0, //"sprmPFAdjustRight" // pap.fAdjustRight;1 or 0;byte;
+ 0x0800, &SwWW8ImplReader::Read_CFRMarkDel, //"sprmCFRMarkDel" // chp.fRMarkDel;1 or 0;bit;
+ 0x0801, &SwWW8ImplReader::Read_CFRMark, //"sprmCFRMark" // chp.fRMark;1 or 0;bit;
+ 0x0802, &SwWW8ImplReader::Read_FldVanish, //"sprmCFFldVanish" // chp.fFldVanish;1 or 0;bit;
+ 0x6A03, &SwWW8ImplReader::Read_PicLoc, //"sprmCPicLocation" // chp.fcPic and chp.fSpec;see below;variable length, length recorded is always 4;
+ 0x4804, (FNReadRecord)0, //"sprmCIbstRMark" // chp.ibstRMark;index into sttbRMark;short;
+ 0x6805, (FNReadRecord)0, //"sprmCDttmRMark" // chp.dttmRMark;DTTM;long;
+ 0x0806, (FNReadRecord)0, //"sprmCFData" // chp.fData;1 or 0;bit;
+ 0x4807, (FNReadRecord)0, //"sprmCIdslRMark" // chp.idslRMReason;an index to a table of strings defined in Word 6.0 executables;short;
+ 0xEA08, &SwWW8ImplReader::Read_CharSet, //"sprmCChs" // chp.fChsDiff and chp.chse;see below;3 bytes;
+ 0x6A09, &SwWW8ImplReader::Read_Symbol, //"sprmCSymbol" // chp.fSpec, chp.xchSym and chp.ftcSym;see below;variable length, length recorded is always 4;
+ 0x080A, &SwWW8ImplReader::Read_Obj, //"sprmCFOle2" // chp.fOle2;1 or 0;bit;
+//0x480B, obsolete,"sprmCIdCharType", // obsolete: not applicable in Word97 and later versions;;;
+ 0x2A0C, &SwWW8ImplReader::Read_CharHighlight, //"sprmCHighlight" // chp.fHighlight, chp.icoHighlight;ico (fHighlight is set to 1 iff ico is not 0);byte;
+ 0x680E, &SwWW8ImplReader::Read_PicLoc, //"sprmCObjLocation" // chp.fcObj;FC;long;
+//0x2A10, ? ? ? , "sprmCFFtcAsciSymb", // ;;;
+ 0x4A30, &SwWW8ImplReader::Read_CColl, //"sprmCIstd" // chp.istd;istd, see stylesheet definition;short;
+ 0xCA31, (FNReadRecord)0, //"sprmCIstdPermute" // chp.istd;permutation vector (see below);variable length;
+ 0x2A32, (FNReadRecord)0, //"sprmCDefault" // whole CHP (see below);none;variable length;
+ 0x2A33, (FNReadRecord)0, //"sprmCPlain" // whole CHP (see below);none; Laenge: 0;
+//0x2A34, ? ? ?, "sprmCKcd", // ;;;
+
+ 0x0835, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFBold" // chp.fBold;0,1, 128, or 129 (see below);byte;
+ 0x0836, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFItalic" // chp.fItalic;0,1, 128, or 129 (see below);byte;
+ 0x0837, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFStrike" // chp.fStrike;0,1, 128, or 129 (see below);byte;
+ 0x0838, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFOutline" // chp.fOutline;0,1, 128, or 129 (see below);byte;
+ 0x0839, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFShadow" // chp.fShadow;0,1, 128, or 129 (see below);byte;
+ 0x083A, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFSmallCaps" // chp.fSmallCaps;0,1, 128, or 129 (see below);byte;
+ 0x083B, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFCaps" // chp.fCaps;0,1, 128, or 129 (see below);byte;
+
+ 0x083C, &SwWW8ImplReader::Read_Invisible, //"sprmCFVanish" // chp.fVanish;0,1, 128, or 129 (see below);byte;
+
+//0x4A3D, (FNReadRecord)0, //"sprmCFtcDefault" // ;ftc, only used internally, never stored in file;word;
+ 0x2A3E, &SwWW8ImplReader::Read_Underline, //"sprmCKul" // chp.kul;kul;byte;
+ 0xEA3F, (FNReadRecord)0, //"sprmCSizePos" // chp.hps, chp.hpsPos;(see below);3 bytes;
+ 0x8840, &SwWW8ImplReader::Read_Kern, //"sprmCDxaSpace" // chp.dxaSpace;dxa;word;
+ 0x4A41, &SwWW8ImplReader::Read_Language, //"sprmCLid" // ;only used internally never stored;word;
+ 0x2A42, &SwWW8ImplReader::Read_TxtColor, //"sprmCIco" // chp.ico;ico;byte;
+ 0x4A43, &SwWW8ImplReader::Read_FontSize, //"sprmCHps" // chp.hps;hps;byte;
+ 0x2A44, (FNReadRecord)0, //"sprmCHpsInc" // chp.hps;(see below);byte;
+ 0x4845, &SwWW8ImplReader::Read_SubSuperProp, //"sprmCHpsPos" // chp.hpsPos;hps;byte;
+ 0x2A46, (FNReadRecord)0, //"sprmCHpsPosAdj" // chp.hpsPos;hps (see below);byte;
+ 0xCA47, &SwWW8ImplReader::Read_Majority, //"sprmCMajority" // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.rgftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico, chp.rglid;complex (see below);variable length, length byte plus size of following grpprl;
+ 0x2A48, &SwWW8ImplReader::Read_SubSuper, //"sprmCIss" // chp.iss;iss;byte;
+ 0xCA49, (FNReadRecord)0, //"sprmCHpsNew50" // chp.hps;hps;variable width, length always recorded as 2;
+ 0xCA4A, (FNReadRecord)0, //"sprmCHpsInc1" // chp.hps;complex (see below);variable width, length always recorded as 2;
+ 0x484B, &SwWW8ImplReader::Read_FontKern, //"sprmCHpsKern" // chp.hpsKern;hps;short;
+ 0xCA4C, &SwWW8ImplReader::Read_Majority, //"sprmCMajority50" // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.ftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico,;complex (see below);variable length;
+ 0x4A4D, (FNReadRecord)0, //"sprmCHpsMul" // chp.hps;percentage to grow hps;short;
+ 0x484E, (FNReadRecord)0, //"sprmCYsri" // chp.ysri;ysri;short;
+ 0x4A4F, &SwWW8ImplReader::Read_FontCode, //"sprmCRgFtc0" // chp.rgftc[0];ftc for ASCII text (see below);short;
+ 0x4A50, &SwWW8ImplReader::Read_FontCode, //"sprmCRgFtc1" // chp.rgftc[1];ftc for Far East text (see below);short;
+ 0x4A51, &SwWW8ImplReader::Read_FontCode, //"sprmCRgFtc2" // chp.rgftc[2];ftc for non-Far East text (see below);short;
+//0x4852, ? ? ? , "sprmCCharScale", // ;;;
+ 0x2A53, &SwWW8ImplReader::Read_BoldUsw, //"sprmCFDStrike" // chp.fDStrike;;byte;
+ 0x0854, (FNReadRecord)0, //"sprmCFImprint" // chp.fImprint;1 or 0;bit;
+ 0x0855, &SwWW8ImplReader::Read_Special, //"sprmCFSpec" // chp.fSpec ;1 or 0;bit;
+ 0x0856, &SwWW8ImplReader::Read_Obj, //"sprmCFObj" // chp.fObj;1 or 0;bit;
+ 0xCA57, &SwWW8ImplReader::Read_CPropRMark, //"sprmCPropRMark" // chp.fPropRMark, chp.ibstPropRMark, chp.dttmPropRMark;Complex (see below);variable length always recorded as 7 bytes;
+ 0x0858, (FNReadRecord)0, //"sprmCFEmboss" // chp.fEmboss;1 or 0;bit;
+ 0x2859, (FNReadRecord)0, //"sprmCSfxText" // chp.sfxtText;text animation;byte;
+//0x085A, ? ? ? , "sprmCFBiDi", // ;;;
+//0x085B, ? ? ? , "sprmCFDiacColor", // ;;;
+//0x085C, ? ? ? , "sprmCFBoldBi", // ;;;
+//0x085D, ? ? ? , "sprmCFItalicBi", // ;;;
+//0x4A5E, ? ? ? , "sprmCFtcBi", // ;;;
+//0x485F, ? ? ? , "sprmCLidBi", // ;;;
+//0x4A60, ? ? ? , "sprmCIcoBi", // ;;;
+//0x4A61, ? ? ? , "sprmCHpsBi", // ;;;
+ 0xCA62, (FNReadRecord)0, //"sprmCDispFldRMark" // chp.fDispFldRMark, chp.ibstDispFldRMark, chp.dttmDispFldRMark ;Complex (see below);variable length always recorded as 39 bytes;
+ 0x4863, (FNReadRecord)0, //"sprmCIbstRMarkDel" // chp.ibstRMarkDel;index into sttbRMark;short;
+ 0x6864, (FNReadRecord)0, //"sprmCDttmRMarkDel" // chp.dttmRMarkDel;DTTM;long;
+ 0x6865, (FNReadRecord)0, //"sprmCBrc" // chp.brc;BRC;long;
+ 0x4866, &SwWW8ImplReader::Read_CharShadow, //"sprmCShd" // chp.shd;SHD;short;
+ 0x4867, (FNReadRecord)0, //"sprmCIdslRMarkDel" // chp.idslRMReasonDel;an index to a table of strings defined in Word 6.0 executables;short;
+ 0x0868, (FNReadRecord)0, //"sprmCFUsePgsuSettings" // chp.fUsePgsuSettings;1 or 0;bit;
+ 0x486B, (FNReadRecord)0, //"sprmCCpg" // ;;word;
+ 0x486D, &SwWW8ImplReader::Read_Language, //"sprmCRgLid0" // chp.rglid[0];LID: for non-Far East text;word;
+ 0x486E, (FNReadRecord)0, //"sprmCRgLid1" // chp.rglid[1];LID: for Far East text;word;
+ 0x286F, (FNReadRecord)0, //"sprmCIdctHint" // chp.idctHint;IDCT: (see below);byte;
+ 0x2E00, (FNReadRecord)0, //"sprmPicBrcl" // pic.brcl;brcl (see PIC structure definition);byte;
+ 0xCE01, (FNReadRecord)0, //"sprmPicScale" // pic.mx, pic.my, pic.dxaCropleft, pic.dyaCropTop pic.dxaCropRight, pic.dyaCropBottom;Complex (see below);length byte plus 12 bytes;
+ 0x6C02, (FNReadRecord)0, //"sprmPicBrcTop" // pic.brcTop;BRC;long;
+ 0x6C03, (FNReadRecord)0, //"sprmPicBrcLeft" // pic.brcLeft;BRC;long;
+ 0x6C04, (FNReadRecord)0, //"sprmPicBrcBottom" // pic.brcBottom;BRC;long;
+ 0x6C05, (FNReadRecord)0, //"sprmPicBrcRight" // pic.brcRight;BRC;long;
+ 0x3000, (FNReadRecord)0, //"sprmScnsPgn" // sep.cnsPgn;cns;byte;
+ 0x3001, (FNReadRecord)0, //"sprmSiHeadingPgn" // sep.iHeadingPgn;heading number level;byte;
+ 0xD202, &SwWW8ImplReader::Read_OLST, //"sprmSOlstAnm" // sep.olstAnm;OLST;variable length;
+ 0xF203, (FNReadRecord)0, //"sprmSDxaColWidth" // sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0xF204, (FNReadRecord)0, //"sprmSDxaColSpacing" // sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0x3005, (FNReadRecord)0, //"sprmSFEvenlySpaced" // sep.fEvenlySpaced;1 or 0;byte;
+ 0x3006, (FNReadRecord)0, //"sprmSFProtected" // sep.fUnlocked;1 or 0;byte;
+ 0x5007, (FNReadRecord)0, //"sprmSDmBinFirst" // sep.dmBinFirst;;word;
+ 0x5008, (FNReadRecord)0, //"sprmSDmBinOther" // sep.dmBinOther;;word;
+ 0x3009, (FNReadRecord)0, //"sprmSBkc" // sep.bkc;bkc;byte;
+ 0x300A, (FNReadRecord)0, //"sprmSFTitlePage" // sep.fTitlePage;0 or 1;byte;
+ 0x500B, (FNReadRecord)0, //"sprmSCcolumns" // sep.ccolM1;# of cols - 1;word;
+ 0x900C, (FNReadRecord)0, //"sprmSDxaColumns" // sep.dxaColumns;dxa;word;
+ 0x300D, (FNReadRecord)0, //"sprmSFAutoPgn" // sep.fAutoPgn;obsolete;byte;
+ 0x300E, (FNReadRecord)0, //"sprmSNfcPgn" // sep.nfcPgn;nfc;byte;
+ 0xB00F, (FNReadRecord)0, //"sprmSDyaPgn" // sep.dyaPgn;dya;short;
+ 0xB010, (FNReadRecord)0, //"sprmSDxaPgn" // sep.dxaPgn;dya;short;
+ 0x3011, (FNReadRecord)0, //"sprmSFPgnRestart" // sep.fPgnRestart;0 or 1;byte;
+ 0x3012, (FNReadRecord)0, //"sprmSFEndnote" // sep.fEndnote;0 or 1;byte;
+ 0x3013, (FNReadRecord)0, //"sprmSLnc" // sep.lnc;lnc;byte;
+ 0x3014, (FNReadRecord)0, //"sprmSGprfIhdt" // sep.grpfIhdt;grpfihdt (see Headers and Footers topic);byte;
+ 0x5015, (FNReadRecord)0, //"sprmSNLnnMod" // sep.nLnnMod;non-neg int.;word;
+ 0x9016, (FNReadRecord)0, //"sprmSDxaLnn" // sep.dxaLnn;dxa;word;
+ 0xB017, (FNReadRecord)0, //"sprmSDyaHdrTop" // sep.dyaHdrTop;dya;word;
+ 0xB018, (FNReadRecord)0, //"sprmSDyaHdrBottom" // sep.dyaHdrBottom;dya;word;
+ 0x3019, (FNReadRecord)0, //"sprmSLBetween" // sep.fLBetween;0 or 1;byte;
+ 0x301A, (FNReadRecord)0, //"sprmSVjc" // sep.vjc;vjc;byte;
+ 0x501B, (FNReadRecord)0, //"sprmSLnnMin" // sep.lnnMin;lnn;word;
+ 0x501C, (FNReadRecord)0, //"sprmSPgnStart" // sep.pgnStart;pgn;word;
+ 0x301D, (FNReadRecord)0, //"sprmSBOrientation" // sep.dmOrientPage;dm;byte;
+//0x301E, ? ? ? , "sprmSBCustomize", // ;;;
+ 0xB01F, (FNReadRecord)0, //"sprmSXaPage" // sep.xaPage;xa;word;
+ 0xB020, (FNReadRecord)0, //"sprmSYaPage" // sep.yaPage;ya;word;
+ 0x2205, (FNReadRecord)0, //"sprmSDxaLeft" // sep.dxaLeft;dxa;word;
+ 0xB022, (FNReadRecord)0, //"sprmSDxaRight" // sep.dxaRight;dxa;word;
+ 0x9023, (FNReadRecord)0, //"sprmSDyaTop" // sep.dyaTop;dya;word;
+ 0x9024, (FNReadRecord)0, //"sprmSDyaBottom" // sep.dyaBottom;dya;word;
+ 0xB025, (FNReadRecord)0, //"sprmSDzaGutter" // sep.dzaGutter;dza;word;
+ 0x5026, (FNReadRecord)0, //"sprmSDmPaperReq" // sep.dmPaperReq;dm;word;
+ 0xD227, (FNReadRecord)0, //"sprmSPropRMark" // sep.fPropRMark, sep.ibstPropRMark, sep.dttmPropRMark ;complex (see below);variable length always recorded as 7 bytes;
+//0x3228, ? ? ? , "sprmSFBiDi", // ;;;
+//0x3229, ? ? ? , "sprmSFFacingCol", // ;;;
+//0x322A, ? ? ? , "sprmSFRTLGutter", // ;;;
+ 0x702B, (FNReadRecord)0, //"sprmSBrcTop" // sep.brcTop;BRC;long;
+ 0x702C, (FNReadRecord)0, //"sprmSBrcLeft" // sep.brcLeft;BRC;long;
+ 0x702D, (FNReadRecord)0, //"sprmSBrcBottom" // sep.brcBottom;BRC;long;
+ 0x702E, (FNReadRecord)0, //"sprmSBrcRight" // sep.brcRight;BRC;long;
+ 0x522F, (FNReadRecord)0, //"sprmSPgbProp" // sep.pgbProp;;word;
+ 0x7030, (FNReadRecord)0, //"sprmSDxtCharSpace" // sep.dxtCharSpace;dxt;long;
+ 0x9031, (FNReadRecord)0, //"sprmSDyaLinePitch" // sep.dyaLinePitch;dya; WRONG:long; RIGHT:short; !!!
+//0x5032, ? ? ? , "sprmSClm", // ;;;
+ 0x5033, (FNReadRecord)0, //"sprmSTextFlow" // sep.wTextFlow;complex (see below);short;
+ 0x5400, (FNReadRecord)0, //"sprmTJc" // tap.jc;jc;word (low order byte is significant);
+ 0x9601, (FNReadRecord)0, //"sprmTDxaLeft" // tap.rgdxaCenter (see below);dxa;word;
+ 0x9602, (FNReadRecord)0, //"sprmTDxaGapHalf" // tap.dxaGapHalf, tap.rgdxaCenter (see below);dxa;word;
+ 0x3403, (FNReadRecord)0, //"sprmTFCantSplit" // tap.fCantSplit;1 or 0;byte;
+ 0x3404, (FNReadRecord)0, //"sprmTTableHeader" // tap.fTableHeader;1 or 0;byte;
+ 0xD605, (FNReadRecord)0, //"sprmTTableBorders" // tap.rgbrcTable;complex(see below);24 bytes;
+ 0xD606, (FNReadRecord)0, //"sprmTDefTable10" // tap.rgdxaCenter, tap.rgtc;complex (see below);variable length;
+ 0x9407, (FNReadRecord)0, //"sprmTDyaRowHeight" // tap.dyaRowHeight;dya;word;
+ 0xD608, (FNReadRecord)0, //"sprmTDefTable" // tap.rgtc;complex (see below);;
+ 0xD609, (FNReadRecord)0, //"sprmTDefTableShd" // tap.rgshd;complex (see below);;
+ 0x740A, (FNReadRecord)0, //"sprmTTlp" // tap.tlp;TLP;4 bytes;
+//0x560B, ? ? ? , "sprmTFBiDi", // ;;;
+//0x740C, ? ? ? , "sprmTHTMLProps", // ;;;
+ 0xD620, (FNReadRecord)0, //"sprmTSetBrc" // tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7621, &SwWW8ImplReader::Read_TabCellInsert, //"sprmTInsert" // tap.rgdxaCenter, tap.rgtc;complex (see below);4 bytes;
+ 0x5622, &SwWW8ImplReader::Read_TabCellDelete, //"sprmTDelete" // tap.rgdxaCenter, tap.rgtc;complex (see below);word;
+ 0x7623, (FNReadRecord)0, //"sprmTDxaCol" // tap.rgdxaCenter;complex (see below);4 bytes;
+ 0x5624, (FNReadRecord)0, //"sprmTMerge" // tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0x5625, (FNReadRecord)0, //"sprmTSplit" // tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0xD626, (FNReadRecord)0, //"sprmTSetBrc10" // tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7627, (FNReadRecord)0, //"sprmTSetShd" // tap.rgshd;complex (see below);4 bytes;
+ 0x7628, (FNReadRecord)0, //"sprmTSetShdOdd" // tap.rgshd;complex (see below);4 bytes;
+ 0x7629, (FNReadRecord)0, //"sprmTTextFlow" // tap.rgtc[].fVerticaltap.rgtc[].fBackwardtap.rgtc[].fRotateFont;0 or 10 or 10 or 1;word;
+//0xD62A, ? ? ? , "sprmTDiagLine", // ;;;
+ 0xD62B, (FNReadRecord)0, //"sprmTVertMerge" // tap.rgtc[].vertMerge;complex (see below);variable length always recorded as 2 bytes;
+ 0xD62C, (FNReadRecord)0, //"sprmTVertAlign" // tap.rgtc[].vertAlign;complex (see below);variable length always recorded as 3 byte;
+};
+
+//-----------------------------------------
+// Hilfsroutinen : SPRM finden
+//-----------------------------------------
+
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC )
+ _Optlink
+#endif
+ CompSprmReadId( const void *pFirst, const void *pSecond)
+{
+ return( ((SprmReadInfo*)pFirst )->nId - ((SprmReadInfo*)pSecond)->nId );
+}
+
+
+SprmReadInfo& WW8GetSprmReadInfo( USHORT nId )
+{
+ // ggfs. Tab sortieren
+ static BOOL bInit = FALSE;
+ if( !bInit )
+ {
+ qsort( (void*)aSprmReadTab,
+ sizeof( aSprmReadTab ) / sizeof (aSprmReadTab[ 0 ]),
+ sizeof( aSprmReadTab[ 0 ] ),
+ CompSprmReadId );
+ bInit = TRUE;
+ }
+ // Sprm heraussuchen
+ void* pFound;
+ SprmReadInfo aSrch;
+ aSrch.nId = nId;
+ if( 0 == ( pFound = bsearch( (BYTE *) &aSrch,
+ (void*) aSprmReadTab,
+ sizeof( aSprmReadTab ) / sizeof (aSprmReadTab[ 0 ]),
+ sizeof( aSprmReadTab[ 0 ] ),
+ CompSprmReadId )))
+ {
+ // im Fehlerfall auf Nulltes Element verweisen
+ pFound = (void*)aSprmReadTab;
+ }
+ return *(SprmReadInfo*) pFound;
+}
+
+
+
+//-----------------------------------------
+// Hilfsroutinen : SPRMs
+//-----------------------------------------
+
+void SwWW8ImplReader::EndSprm( USHORT nId )
+{
+ if( ( nId > 255 ) && ( nId < 0x0800 ) ) return;
+
+ SprmReadInfo& rSprm = WW8GetSprmReadInfo( nId );
+ /*
+ if ( aWwSprmTab[nId] == 0 )
+ return;
+
+ (this->*SprmReadInfo)( nId, 0, -1 );
+ */
+ if( rSprm.pReadFnc )
+ (this->*rSprm.pReadFnc)( nId, 0, -1 );
+}
+
+/*
+// ein bzw. zwei Byte am Anfang des Sprm sind die Id
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta )
+{
+ USHORT nId = 0;
+ switch( nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: nId = *pSp;
+ if( pDelta ) *pDelta = 0;
+ break;
+ case 8: nId = SVBT16ToShort( &pSp[ 0 ] );
+ if( pDelta ) *pDelta = 1;
+ break;
+ default:ASSERT( nId, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+ return nId;
+}
+*/
+
+short SwWW8ImplReader::ImportSprm( BYTE* pPos, short nSprmsLen, USHORT nId )
+{
+ BYTE nDelta;
+ BYTE nV = pWwFib->nVersion;
+
+ if( nId )
+ nDelta = bVer67 ? 0 : 1;
+ else
+ nId = WW8GetSprmId( nV, pPos, &nDelta );
+
+
+#ifdef DEBUG
+ ASSERT( nId != 0xff, "Sprm FF !!!!" );
+#endif //DEBUG
+
+ SprmReadInfo& rSprm = WW8GetSprmReadInfo( nId );
+
+
+ short nFixedLen = 1 + nDelta + WW8SprmDataOfs( nId );
+ short nL = WW8GetSprmSizeBrutto( nV, pPos, &nId );
+
+ if( rSprm.pReadFnc )
+ {
+ (this->*rSprm.pReadFnc)( nId, pPos + nFixedLen, nL - nFixedLen );
+ }
+ return nL;
+}
+
+
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8par6.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.104 2000/09/18 16:05:01 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.103 2000/08/24 13:20:54 kz
+ Max (long, long)
+
+ Revision 1.102 2000/08/21 15:03:09 khz
+ #77692# import page orientation
+
+ Revision 1.101 2000/08/18 09:48:33 khz
+ Import Line Numbering (restart on new section)
+
+ Revision 1.100 2000/08/18 06:47:29 khz
+ Import Line Numbering
+
+ Revision 1.99 2000/07/25 15:16:29 khz
+ #76811# read/write AutoHyphenation flag from/into Document Properties
+
+ Revision 1.98 2000/07/17 13:47:04 khz
+ #73987# check if sprmSNfcPgn should cause section change or not
+
+ Revision 1.97 2000/07/11 11:30:59 khz
+ #76673# prepare implementation of sprmTDelete and sprmTInsert
+
+ Revision 1.96 2000/06/28 08:07:48 khz
+ #70915# Insert Section if end-note with flag 'on end of section' found
+
+ Revision 1.95 2000/05/25 08:06:57 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.94 2000/05/16 12:03:50 jp
+ Changes for unicode
+
+ Revision 1.93 2000/05/16 11:23:49 khz
+ Unicode code-conversion
+
+ Revision 1.92 2000/03/21 10:37:08 khz
+ Task #74319# - do NOT close just inserted (still empty!) section in CreateSep()
+ - closing of old section may cause the creation of a new one
+ Task #66529# improve Header/Footer import
+
+ Revision 1.91 2000/03/10 14:27:15 khz
+ Task #65529# improve detection if Section is identical with previous
+
+ Revision 1.90 2000/03/03 15:20:02 os
+ StarView remainders removed
+
+ Revision 1.89 2000/02/23 17:43:03 cmc
+ #68832# Consider endnotes for header footer code
+
+ Revision 1.88 2000/02/22 14:55:19 khz
+ partial fix of #66832#
+
+ Revision 1.87 2000/02/21 13:08:30 jp
+ #70473# changes for unicode
+
+ Revision 1.86 2000/02/15 16:09:28 jp
+ #70473# changes for unicode
+
+ Revision 1.85 2000/02/09 11:43:31 khz
+ no Task Id: code cleaned for of annoying warning
+
+ Revision 1.84 2000/01/21 16:42:44 khz
+ Task #69155# set pPaM when inserting section with/without columns
+
+ Revision 1.83 2000/01/19 17:08:51 khz
+ Task #69178# never insert Fontattribute when skipping text content
+
+ Revision 1.82 2000/01/14 11:27:59 khz
+ Task #68832# -- CORRECTION: Task Number of rev below should have been: 68832 !
+
+ Revision 1.81 2000/01/14 11:11:34 khz
+ Task #71343# look for Sprm 37 (not 5) to recognize APO
+
+ Revision 1.80 2000/01/06 15:23:49 khz
+ Task #71411# Let last Section be unbalanced
+
+ Revision 1.79 1999/12/23 15:10:46 jp
+ Task #70915#: set Ftn-/End-TxtAtEnd attributes at sections
+
+ Revision 1.78 1999/12/23 14:03:42 khz
+ Task #68143# avoid attributes atached solely to Cell-End marks
+
+ Revision 1.77 1999/12/23 10:24:53 khz
+ Task #71209# avoid accessing pPageDesk if it's 0 ;-)
+
+ Revision 1.76 1999/12/22 18:03:35 khz
+ Task #70919# look if ParaStyle is different behind filed than it was before
+
+ Revision 1.75 1999/12/09 16:46:36 khz
+ Task #69180# allow Tabs if right of 1st-line-start OR right of paragraph margin
+
+ Revision 1.74 1999/12/07 14:28:56 khz
+ Task #69508# import sprmPHugePapx by reading DATA stream
+
+ Revision 1.73 1999/12/01 14:35:52 khz
+ Task #68488# Graphics in Sections with more than one Column
+
+ Revision 1.72 1999/11/25 12:28:37 khz
+ Task #68482# Store data in member *after* memset(this,0,...) in WW8FlyPara()
+
+ Revision 1.71 1999/11/24 12:33:15 khz
+ Task #66194# don't consider Sect-Properties to be unequal when one is protected
+
+ Revision 1.70 1999/11/12 15:29:25 khz
+ Task #69204#: prevent from inserting '?' when ConvertFromUnicode() fails
+
+ Revision 1.69 1999/11/12 13:05:03 jp
+ new: read sprmCHighlight
+
+ Revision 1.68 1999/11/02 15:59:49 khz
+ import new TOX_CONTENT and TOX_INDEX features (2)
+
+ Revision 1.67 1999/10/13 21:06:12 khz
+ Import Redlining (3)
+
+ Revision 1.66 1999/10/08 09:26:23 khz
+ Import Redlining
+
+ Revision 1.65 1999/09/10 15:36:35 khz
+ CharSet matching made by TENCINFO.H::rtl_getTextEncodingFromWindowsCharset()
+
+ Revision 1.64 1999/09/09 18:16:25 khz
+ CharSet matching now done in central methode WW8SCAN.HXX::WW8GetCharSet()
+
+ Revision 1.63 1999/08/10 13:16:26 KHZ
+ Task #66019# corrction of Font Family by analyzing Font Name
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
new file mode 100644
index 000000000000..a5010023a470
--- /dev/null
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -0,0 +1,6326 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8scan.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+
+
+//#define KHZ_TEST0
+
+
+
+
+
+
+#include <stdlib.h>
+
+#ifdef PCH
+#include "filt_pch.hxx"
+#endif
+
+#pragma hdrstop
+
+#include <string.h> // memset()
+
+#define _SVSTDARR_SHORTS
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_USHORTSSORT
+#define _SVSTDARR_SVSTRINGS
+#include <svtools/svstdarr.hxx>
+
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+
+#ifdef DUMP
+
+#define ERR_SWG_READ_ERROR 1234
+#include <assert.h>
+#define ASSERT( a, b )
+
+#else // dump
+
+#ifndef _SWSWERROR_H
+#include <swerror.h> // ERR_WW6_...
+#endif
+#ifndef _ERRHDL_HXX
+#include <errhdl.hxx> // ASSERT()
+#endif
+#ifndef _SWTYPES_HXX
+#include <swtypes.hxx> // DELETEZ
+#endif
+
+#endif // dump
+
+#ifndef _DEBUG_HXX //autogen
+#include <tools/debug.hxx>
+#endif
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _WW8SCAN_HXX
+#include <ww8scan.hxx>
+#endif
+
+
+
+
+#ifdef __WW8_NEEDS_PACK
+# pragma pack(2)
+#endif
+struct WW8_PCD1
+{
+ INT16 fNoParaLast; // when 1, means that piece contains no end of paragraph marks.
+ INT32 fc; // file offset of beginning of piece. The size of the
+ INT16 prm; // PRM contains either a single sprm or else an index number
+};
+#ifdef __WW8_NEEDS_PACK
+# pragma pack()
+# endif
+
+
+
+
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta );
+
+
+
+WW8SprmIter::WW8SprmIter(BYTE* pSprms_, short nLen_, BYTE nVersion_ )
+ : pSprms( pSprms_), nRemLen( nLen_), nVersion( nVersion_),
+ nDelta( ( 8 > nVersion ) ? 0 : 1 )
+{
+ UpdateMyMembers();
+}
+
+void WW8SprmIter::SetSprms(BYTE* pSprms_, short nLen_)
+{
+ pSprms = pSprms_;
+ nRemLen = nLen_;
+ UpdateMyMembers();
+}
+
+BYTE* WW8SprmIter::operator ++( int )
+{
+ if( 0 < nRemLen )
+ {
+ pSprms += nAktSizeBrutto;
+ nRemLen -= nAktSizeBrutto;
+ UpdateMyMembers();
+ }
+ return pSprms;
+}
+
+void WW8SprmIter::UpdateMyMembers()
+{
+ if( pSprms && (0 < nRemLen) )
+ {
+ nAktId = WW8GetSprmId( nVersion, pSprms );
+ pAktParams = pSprms + 1 + nDelta + WW8SprmDataOfs( nAktId );
+ nAktSizeBrutto = WW8GetSprmSizeBrutto( nVersion, pSprms, &nAktId );
+ }
+ else
+ {
+ nAktId = 0;
+ pAktParams = 0;
+ nAktSizeBrutto = 0;
+ nRemLen = 0;
+ }
+}
+
+
+
+//-----------------------------------------
+// temporaerer Test
+//-----------------------------------------
+// WW8PLCFx_PCDAttrs halten sich an WW8PLCF_Pcd fest und besitzen deshalb keine
+// eigenen Iteratoren. Alle sich auf Iteratoren beziehenden Methoden
+// sind deshalb Dummies.
+
+WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs( BYTE nVersion, WW8PLCFx_PCD* pPLCFx_PCD, WW8ScannerBase* pBase )
+: WW8PLCFx( nVersion, TRUE ),
+ pPcd( pPLCFx_PCD ),
+ pGrpprls( pBase->pPieceGrpprls ),
+ nGrpprls( pBase->nPieceGrpprls ),
+ pPcdI( pPLCFx_PCD->GetPLCFIter() )
+{
+}
+
+WW8PLCFx_PCDAttrs::~WW8PLCFx_PCDAttrs()
+{
+}
+
+ULONG WW8PLCFx_PCDAttrs::GetIdx() const
+{
+ return 0;
+}
+
+void WW8PLCFx_PCDAttrs::SetIdx( ULONG )
+{
+}
+
+BOOL WW8PLCFx_PCDAttrs::SeekPos( WW8_CP n )
+{
+ return TRUE;
+}
+
+WW8PLCFx& WW8PLCFx_PCDAttrs::operator ++( int )
+{
+ return *this;
+}
+
+WW8_CP WW8PLCFx_PCDAttrs::Where()
+{
+ return ( pPcd ) ? pPcd->Where() : LONG_MAX;
+}
+
+void WW8PLCFx_PCDAttrs::GetSprms( WW8PLCFxDesc* p )
+{
+ void* pData;
+
+ p->bRealLineEnd = FALSE;
+ if( !pPcdI
+ || !pPcdI->Get( p->nStartPos, p->nEndPos, pData ))
+ {
+ p->nStartPos = p->nEndPos = LONG_MAX; // PLCF fertig abgearbeitet
+ p->pMemPos = 0;
+ return;
+ }
+ UINT16 nPrm = SVBT16ToShort( ( (WW8_PCD*)pData )->prm );
+
+ if ( nPrm & 1 )
+ { // PRM Variante 2
+ UINT16 nSprmIdx = nPrm >> 1;
+
+ if( nSprmIdx >= nGrpprls ){
+ p->nStartPos = p->nEndPos = LONG_MAX; // Bloedsinniger Index
+ p->pMemPos = 0;
+ return;
+ }
+ BYTE* pSprms = pGrpprls[ nSprmIdx ];
+
+ p->nSprmsLen = SVBT16ToShort( pSprms ); // Laenge
+ pSprms += 2;
+ p->pMemPos = pSprms; // Position
+ }
+ else
+ { // PRM Variante 1: Sprm wird direkt in Member-Var abgelegt
+ /*
+ Dies sind die Attr, die in der Piece-Table stehen, statt im Text !
+ */
+
+ if(8 > GetVersion())
+ {
+ aShortSprm[0] = (BYTE)( ( nPrm & 0xfe) >> 1 );
+ aShortSprm[1] = (BYTE)( nPrm >> 8 );
+ p->nSprmsLen = ( nPrm ) ? 2 : 0; // Laenge
+
+ // store Postion of internal mini storage in Data Pointer
+ p->pMemPos = aShortSprm;
+ }
+ else
+ {
+ p->pMemPos = 0;
+ BYTE nSprmListIdx = (BYTE)((nPrm & 0xfe) >> 1);
+ if( nSprmListIdx )
+ {
+ // process Sprm Id Matching as explained in MS Doku
+ //
+ // ''Property Modifier(variant 1) (PRM)''
+ // see file: s62f39.htm
+ //
+ // Since isprm is 7 bits, rgsprmPrm can hold 0x80 entries.
+ static USHORT __READONLY_DATA aSprmId[0x80] = {
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0x2402,0x2403,0x2404,0x2405,// sprmPIncLvl, sprmPJc, sprmPFSideBySide, sprmPFKeep
+ 0x2406,0x2407,0x2408,0x2409,// sprmPFKeepFollow, sprmPFPageBreakBefore, sprmPBrcl, sprmPBrcp
+ 0x260A, 0,0x240C, 0,// sprmPIlvl, sprmNoop, sprmPFNoLineNumb, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0x2416,0x2417, 0, 0,// sprmPFInTable, sprmPFTtp, sprmNoop, sprmNoop
+ 0,0x261B, 0, 0,// sprmNoop, sprmPPc, sprmNoop, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0,0x2423, 0, 0,// sprmNoop, sprmPWr, sprmNoop, sprmNoop
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop
+ 0x242A, 0, 0, 0,// sprmPFNoAutoHyph, sprmNoop, sprmNoop, sprmNoop
+ 0, 0,0x2430,0x2431,// sprmNoop, sprmNoop, sprmPFLocked, sprmPFWidowControl
+ 0,0x2433,0x2434,0x2435,// sprmNoop, sprmPFKinsoku, sprmPFWordWrap, sprmPFOverflowPunct
+ 0x2436,0x2437,0x2438, 0,// sprmPFTopLinePunct, sprmPFAutoSpaceDE, sprmPFAutoSpaceDN, sprmNoop
+ 0,0x243B, 0, 0,// sprmNoop, sprmPISnapBaseLine, sprmNoop, sprmNoop
+ 0,0x0800,0x0801,0x0802,// sprmNoop, sprmCFStrikeRM, sprmCFRMark, sprmCFFldVanish
+ 0, 0, 0,0x0806,// sprmNoop, sprmNoop, sprmNoop, sprmCFData
+ 0, 0, 0,0x080A,// sprmNoop, sprmNoop, sprmNoop, sprmCFOle2
+ 0,0x2A0C,0x0858,0x2859,// sprmNoop, sprmCHighlight, sprmCFEmboss, sprmCSfxText
+ 0, 0, 0,0x2A33,// sprmNoop, sprmNoop, sprmNoop, sprmCPlain
+ 0,0x0835,0x0836,0x0837,// sprmNoop, sprmCFBold, sprmCFItalic, sprmCFStrike
+ 0x0838,0x0839,0x083a,0x083b,// sprmCFOutline, sprmCFShadow, sprmCFSmallCaps, sprmCFCaps,
+ 0x083C, 0,0x2A3E, 0,// sprmCFVanish, sprmNoop, sprmCKul, sprmNoop,
+ 0, 0,0x2A42, 0,// sprmNoop, sprmNoop, sprmCIco, sprmNoop,
+ 0x2A44, 0,0x2A46, 0,// sprmCHpsInc, sprmNoop, sprmCHpsPosAdj, sprmNoop,
+ 0x2A48, 0, 0, 0,// sprmCIss, sprmNoop, sprmNoop, sprmNoop,
+ 0, 0, 0, 0,// sprmNoop, sprmNoop, sprmNoop, sprmNoop,
+ 0, 0, 0,0x2A53,// sprmNoop, sprmNoop, sprmNoop, sprmCFDStrike,
+ 0x0854,0x0855,0x0856,0x2E00,// sprmCFImprint, sprmCFSpec, sprmCFObj, sprmPicBrcl,
+ 0x2640, 0, 0, 0,// sprmPOutLvl, sprmNoop, sprmNoop, sprmNoop,
+ 0, 0, 0, 0 // sprmNoop, sprmNoop, sprmPPnbrRMarkNot
+ }; // ^^^^^^^^^^^^^^^^^ unknown name!
+
+ // find real Sprm Id:
+ USHORT nSprmId = aSprmId[ nSprmListIdx ];
+
+ if( nSprmId )
+ {
+ // move Sprm Id and Sprm Param to internal mini storage:
+ aShortSprm[0] = (BYTE)( ( nSprmId & 0x00ff) );
+ aShortSprm[1] = (BYTE)( ( nSprmId & 0xff00) >> 8 );
+ aShortSprm[2] = (BYTE)( nPrm >> 8 );
+
+ // store Sprm Length in member:
+ p->nSprmsLen = ( nPrm ) ? 3 : 0;
+
+ // store Postion of internal mini storage in Data Pointer
+ p->pMemPos = aShortSprm;
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+WW8PLCFx_PCD::WW8PLCFx_PCD( BYTE nVersion, WW8PLCFpcd* pPLCFpcd,
+ WW8_CP nStartCp, BOOL bVer67P )
+ : WW8PLCFx( nVersion, FALSE )
+{
+ pPcdI = new WW8PLCFpcd_Iter( *pPLCFpcd, nStartCp ); // eigenen Iterator konstruieren
+ bVer67= bVer67P;
+}
+
+WW8PLCFx_PCD::~WW8PLCFx_PCD()
+{ // pPcd-Dtor wird in WW8ScannerBase gerufen
+ delete( pPcdI );
+}
+
+ULONG WW8PLCFx_PCD::GetIMax() const
+{
+ return ( pPcdI ) ? pPcdI->GetIMax() : 0;
+}
+
+ULONG WW8PLCFx_PCD::GetIdx() const
+{
+ return ( pPcdI ) ? pPcdI->GetIdx() : 0;
+}
+
+void WW8PLCFx_PCD::SetIdx( ULONG nIdx )
+{
+ if( pPcdI )
+ pPcdI->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_PCD::SeekPos( WW8_CP nCpPos )
+{
+ return ( pPcdI ) ? pPcdI->SeekPos( nCpPos ) : FALSE;
+}
+
+WW8_CP WW8PLCFx_PCD::Where()
+{
+ return ( pPcdI ) ? pPcdI->Where() : LONG_MAX;
+}
+
+long WW8PLCFx_PCD::GetNoSprms( long& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ rLen = 0;
+
+ if( !pPcdI
+ || !pPcdI->Get( rStart, rEnd, pData ) )
+ {
+ rStart = rEnd = LONG_MAX;
+ return -1;
+ }
+ return pPcdI->GetIdx();
+}
+
+WW8PLCFx& WW8PLCFx_PCD::operator ++( int )
+{
+ if( !pPcdI ){
+ ASSERT( !this, "pPcdI fehlt");
+ }else{
+ (*pPcdI)++;
+ }
+ return *this;
+}
+
+WW8_FC WW8PLCFx_PCD::AktPieceStartCp2Fc( WW8_CP nCp )
+{
+ WW8_CP nCpStart, nCpEnd;
+ void* pData;
+
+ if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) ){
+ ASSERT( !this, "AktPieceStartCp2Fc() mit falschem Cp gerufen (1)" );
+ return LONG_MAX;
+ }
+
+ ASSERT( nCp >= nCpStart && nCp < nCpEnd,
+ "AktPieceCp2Fc() mit falschem Cp gerufen (2)" );
+
+ if( nCp < nCpStart )
+ nCp = nCpStart;
+ if( nCp >= nCpEnd )
+ nCp = nCpEnd - 1;
+
+ BOOL bIsUnicode = FALSE;
+ WW8_FC nFC = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( !bVer67 )
+ nFC = WW8PLCFx_PCD::TransformPieceAddress( nFC, bIsUnicode );
+
+ return nFC + (nCp - nCpStart) * (bIsUnicode ? 2 : 1);
+}
+
+
+eCutT WW8PLCFx_PCD::AktPieceFc2Cp( long& rStartPos, long& rEndPos )
+{
+ WW8_CP nCpStart, nCpEnd;
+ void* pData;
+ eCutT eRet = CUT_NONE;
+
+ if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) ){
+ ASSERT( !this, "AktPieceFc2Cp() - Fehler" );
+ rStartPos = rEndPos = LONG_MAX;
+ return CUT_BOTH;
+ }
+
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( !bVer67 )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
+
+ INT32 nUnicodeFactor = bIsUnicode ? 2 : 1;
+
+ if( rStartPos < nFcStart )
+ {
+ rStartPos = nFcStart;
+ eRet = (eCutT)( eRet | CUT_START );
+ }
+ if( rStartPos >= nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
+ {
+ rStartPos = nFcStart + (nCpEnd - nCpStart - 1) * nUnicodeFactor;
+ eRet = (eCutT)( eRet | CUT_START );
+ }
+ // jetzt CP berechnen
+ rStartPos = nCpStart + (rStartPos - nFcStart) / nUnicodeFactor;
+
+
+ if( rEndPos < nFcStart )
+ {
+ rEndPos = nFcStart;
+ eRet = (eCutT)( eRet | CUT_END );
+ }
+ if( rEndPos > nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
+ {
+ rEndPos = nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor;
+ eRet = (eCutT)( eRet | CUT_END );
+ }
+ // jetzt CP berechnen
+ rEndPos = nCpStart + (rEndPos - nFcStart) / nUnicodeFactor;
+#ifdef DEBUG
+ if (0 > rStartPos)
+ {
+ BOOL i = 5;
+ }
+ ASSERT( (0 <= rStartPos), "AktPieceFc2Cp() - rStartPos kleiner Null!" );
+#endif
+ return eRet;
+}
+
+WW8_CP WW8PLCFx_PCD::AktPieceStartFc2Cp( WW8_FC nStartPos )
+{
+ WW8_CP nCpStart, nCpEnd;
+ void* pData;
+/*
+ if( nStartPos == LONG_MAX )
+ return LONG_MAX;
+*/
+ if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) )
+ {
+ ASSERT( !this, "AktPieceStartFc2Cp() - Fehler" );
+ return LONG_MAX;
+ }
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( !bVer67 )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
+
+
+ INT32 nUnicodeFactor = bIsUnicode ? 2 : 1;
+
+ if( nStartPos < nFcStart )
+ nStartPos = nFcStart;
+
+ if( nStartPos >= nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
+ nStartPos = nFcStart + (nCpEnd - nCpStart - 1) * nUnicodeFactor;
+
+ return nCpStart + (nStartPos - nFcStart) / nUnicodeFactor;
+}
+
+
+
+//-----------------------------------------
+// Hilfsroutinen fuer alle
+//-----------------------------------------
+
+DateTime WW8ScannerBase::WW8DTTM2DateTime(long lDTTM)
+{
+/*
+mint short :6 0000003F minutes (0-59)
+hr short :5 000007C0 hours (0-23)
+dom short :5 0000F800 days of month (1-31)
+mon short :4 000F0000 months (1-12)
+yr short :9 1FF00000 years (1900-2411)-1900
+wdy short :3 E0000000 weekday(Sunday=0
+ Monday=1
+( wdy can be ignored ) Tuesday=2
+ Wednesday=3
+ Thursday=4
+ Friday=5
+ Saturday=6)
+*/
+ DateTime aDateTime(Date( 0 ), Time( 0 ));
+ if( lDTTM )
+ {
+ USHORT lMin =(USHORT)(lDTTM & 0x0000003F);
+ lDTTM >>= 6;
+ USHORT lHour=(USHORT)(lDTTM & 0x0000001F);
+ lDTTM >>= 5;
+ USHORT lDay =(USHORT)(lDTTM & 0x0000001F);
+ lDTTM >>= 5;
+ USHORT lMon =(USHORT)(lDTTM & 0x0000000F);
+ lDTTM >>= 4;
+ USHORT lYear=(USHORT)(lDTTM & 0x000001FF) + 1900;
+ aDateTime = DateTime(Date(lDay, lMon, lYear), Time(lHour, lMin));
+ }
+ return aDateTime;
+}
+
+WW8_CP WW8ScannerBase::WW8Fc2Cp( WW8_FC nFcPos ) const
+{
+ if( nFcPos == LONG_MAX )
+ return LONG_MAX;
+
+ if( pPieceIter )
+ { // Complex File ?
+ ULONG nOldPos = pPieceIter->GetIdx();
+ pPieceIter->SetIdx( 0 );
+ while( 1 )
+ {
+ long nCpStart, nCpEnd;
+ void* pData;
+ if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
+ { // ausserhalb PLCFfpcd ?
+ ASSERT( !this, "PLCFpcd-WW8Fc2Cp() ging schief" );
+ break;
+// pPieceIter->SetIdx( nOldPos );
+// return 0;
+ }
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( 8 <= pWw8Fib->nVersion )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart,
+ bIsUnicode );
+
+ INT32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1);
+
+ if( nFcPos >= nFcStart && nFcPos < nFcStart + nLen )
+ { // gefunden
+ pPieceIter->SetIdx( nOldPos );
+
+ return nCpStart + ((nFcPos - nFcStart) / (bIsUnicode ? 2 : 1));
+ }
+ (*pPieceIter)++;
+ }
+ pPieceIter->SetIdx( nOldPos ); // nicht gefunden
+ return LONG_MAX;
+ }
+ // No complex file
+ return nFcPos - pWw8Fib->fcMin;
+}
+
+WW8_FC WW8ScannerBase::WW8Cp2Fc( WW8_CP nCpPos, BOOL* pIsUnicode,
+ WW8_CP* pNextPieceCp, BOOL* pTestFlag ) const
+{
+ if( pTestFlag )
+ *pTestFlag = TRUE;
+ if( LONG_MAX == nCpPos )
+ return LONG_MAX;
+
+ if( pPieceIter )
+ { // Complex File
+ if( pNextPieceCp )
+ *pNextPieceCp = LONG_MAX;
+
+ if( !pPieceIter->SeekPos( nCpPos ) )
+ {
+ if( pTestFlag )
+ *pTestFlag = FALSE;
+ else
+ ASSERT( !this, "Falscher CP an WW8Cp2Fc() uebergeben" );
+ return LONG_MAX;
+ }
+ long nCpStart, nCpEnd;
+ void* pData;
+ if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
+ {
+ if( pTestFlag )
+ *pTestFlag = FALSE;
+ else
+ ASSERT( !this, "PLCFfpcd-Get ging schief" );
+ return LONG_MAX;
+ }
+ if( pNextPieceCp )
+ *pNextPieceCp = nCpEnd;
+ BOOL bIsUnicode;
+ if( !pIsUnicode )
+ pIsUnicode = &bIsUnicode;
+
+ WW8_FC nRet = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( 8 > pWw8Fib->nVersion )
+ *pIsUnicode = FALSE;
+ else
+ nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode );
+
+
+ nRet += (nCpPos - nCpStart) * (*pIsUnicode ? 2 : 1);
+
+ return nRet;
+ }
+
+ // No complex file
+ if( pIsUnicode )
+ *pIsUnicode = FALSE;
+ return nCpPos + pWw8Fib->fcMin;
+}
+
+//-----------------------------------------
+// class WW8ScannerBase
+//-----------------------------------------
+
+WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, WW8Fib* pWwF )
+{
+ if( ( (8 > pWw8Fib->nVersion)
+ && !pWwF->fComplex
+ )
+ || !pWwF->lcbClx ) return 0;
+
+ WW8_FC nClxPos = pWwF->fcClx;
+ INT32 nClxLen = pWwF->lcbClx;
+ register INT32 nLeft = nClxLen;
+ INT16 nGrpprl = 0;
+ BYTE clxt;
+
+ pStr->Seek( nClxPos );
+ while( 1 ){ // Zaehle Zahl der Grpprls
+ *pStr >> clxt;
+ nLeft--;
+ if( 2 == clxt ) // PLCFfpcd ?
+ break; // PLCFfpcd gefunden
+ if( 1 == clxt ) // clxtGrpprl ?
+ nGrpprl++;
+ UINT16 nLen;
+ *pStr >> nLen;
+ nLeft -= 2 + nLen;
+ if( nLeft < 0 )
+ return 0; // schiefgegangen
+ pStr->SeekRel( nLen ); // ueberlies grpprl
+ }
+ pStr->Seek( nClxPos );
+ nLeft = nClxLen;
+ pPieceGrpprls = new BYTE*[nGrpprl + 1];
+ memset( pPieceGrpprls, 0, ( nGrpprl + 1 ) * 4 );
+ nPieceGrpprls = nGrpprl;
+ INT16 nAktGrpprl = 0; // lies Grpprls ein
+ while( 1 )
+ {
+ *pStr >> clxt;
+ nLeft--;
+ if( 2 == clxt) // PLCFfpcd ?
+ break; // PLCFfpcd gefunden
+ UINT16 nLen;
+ *pStr >> nLen;
+ nLeft -= 2 + nLen;
+ if( nLeft < 0 )
+ return 0; // schiefgegangen
+ if( 1 == clxt ) // clxtGrpprl ?
+ {
+ BYTE* p = new BYTE[nLen+2]; // alloziere
+ memcpy( p, &nLen, 2 ); // trage Laenge ein
+ pStr->Read( p+2, nLen ); // lies grpprl
+ pPieceGrpprls[nAktGrpprl++] = p; // trage in Array ein
+ }
+ else
+ pStr->SeekRel( nLen ); // ueberlies nicht-Grpprl
+ }
+ // lies Piece Table PLCF ein
+ INT32 nPLCFfLen;
+ *pStr >> nPLCFfLen;
+ ASSERT( 65536 > nPLCFfLen, "PLCFfpcd ueber 64 k" );
+ return new WW8PLCFpcd( pStr, pStr->Tell(), nPLCFfLen, 8 );
+}
+
+void WW8ScannerBase::DeletePieceTable()
+{
+ if( pPieceGrpprls )
+ {
+ for( BYTE** p = pPieceGrpprls; *p; p++ )
+ delete[]( *p );
+ delete[]( pPieceGrpprls );
+ pPieceGrpprls = 0;
+ }
+}
+
+WW8ScannerBase::WW8ScannerBase( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ WW8Fib* pWwFib )
+ : pWw8Fib( pWwFib ), pPieceGrpprls( 0 ),
+ pMainFdoa( 0 ), pHdFtFdoa( 0 ),
+ pMainTxbx( 0 ), pMainTxbxBkd( 0 ), pHdFtTxbx( 0 ), pHdFtTxbxBkd( 0 ),
+ nNoAttrScan( 0 )
+{
+ pPiecePLCF = OpenPieceTable( pTblSt, pWw8Fib ); // Complex
+ if( pPiecePLCF )
+ {
+ pPieceIter = new WW8PLCFpcd_Iter( *pPiecePLCF );
+ pPLCFx_PCD = new WW8PLCFx_PCD( pWwFib->nVersion, pPiecePLCF, 0,
+ 8 > pWw8Fib->nVersion );
+ pPLCFx_PCDAttrs = new WW8PLCFx_PCDAttrs( pWwFib->nVersion, pPLCFx_PCD, this);
+ }
+ else
+ {
+ pPieceIter = 0;
+ pPLCFx_PCD = 0;
+ pPLCFx_PCDAttrs = 0;
+ }
+
+ // pChpPLCF and pPapPLCF may NOT be created before pPLCFx_PCD !!
+ pChpPLCF = new WW8PLCFx_Cp_FKP( pSt, pTblSt, pDataSt, *this, CHP ); // CHPX
+ pPapPLCF = new WW8PLCFx_Cp_FKP( pSt, pTblSt, pDataSt, *this, PAP ); // PAPX
+
+ pSepPLCF = new WW8PLCFx_SEPX( pSt, pTblSt, *pWwFib, 0 ); // SEPX
+
+ // Footnotes
+ pFtnPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->nVersion, 0,
+ pWwFib->fcPlcffndRef, pWwFib->lcbPlcffndRef,
+ pWwFib->fcPlcffndTxt, pWwFib->lcbPlcffndTxt,
+ 2 );
+ // Endnotes
+ pEdnPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->nVersion, 0,
+ pWwFib->fcPlcfendRef, pWwFib->lcbPlcfendRef,
+ pWwFib->fcPlcfendTxt, pWwFib->lcbPlcfendTxt,
+ 2 );
+ // Anmerkungen
+ pAndPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->nVersion, 0,
+ pWwFib->fcPlcfandRef, pWwFib->lcbPlcfandRef,
+ pWwFib->fcPlcfandTxt, pWwFib->lcbPlcfandTxt,
+ (8 > pWwFib->nVersion) ? 20 : 30 );
+
+ // Fields Main Text
+ pFldPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_MAINTEXT, 0 );
+ // Fields Header / Footer
+ pFldHdFtPLCF= new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_HDFT, 0 );
+ // Fields Footnote
+ pFldFtnPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_FTN, 0 );
+ // Fields Endnote
+ pFldEdnPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_EDN, 0 );
+ // Fields Anmerkungen
+ pFldAndPLCF = new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_AND, 0 );
+ // Fields in Textboxes in Main Text
+ pFldTxbxPLCF= new WW8PLCFx_FLD( pTblSt, *pWwFib, MAN_TXBX, 0 );
+ // Fields in Textboxes in Header / Footer
+ pFldTxbxHdFtPLCF=new WW8PLCFx_FLD(pTblSt,*pWwFib,MAN_TXBX_HDFT,0 );
+
+ switch( pWw8Fib->nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: if( pWwFib->fcPlcfdoaMom && pWwFib->lcbPlcfdoaMom )
+ pMainFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfdoaMom,
+ pWwFib->lcbPlcfdoaMom, 6 );
+ if( pWwFib->fcPlcfdoaHdr && pWwFib->lcbPlcfdoaHdr )
+ pHdFtFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfdoaHdr,
+ pWwFib->lcbPlcfdoaHdr, 6 );
+ break;
+ case 8:
+ if( pWwFib->fcPlcfspaMom && pWwFib->lcbPlcfspaMom )
+ pMainFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfspaMom,
+ pWwFib->lcbPlcfspaMom, 26 );
+ if( pWwFib->fcPlcfspaHdr && pWwFib->lcbPlcfspaHdr )
+ pHdFtFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfspaHdr,
+ pWwFib->lcbPlcfspaHdr, 26 );
+ // PLCF fuer TextBox-Break-Deskriptoren im Maintext
+ if( pWwFib->fcPlcftxbxBkd && pWwFib->lcbPlcftxbxBkd )
+ pMainTxbxBkd = new WW8PLCFspecial( pTblSt,
+ pWwFib->fcPlcftxbxBkd,
+ pWwFib->lcbPlcftxbxBkd, 0);
+ // PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
+ if( pWwFib->fcPlcfHdrtxbxBkd && pWwFib->lcbPlcfHdrtxbxBkd )
+ pHdFtTxbxBkd = new WW8PLCFspecial( pTblSt,
+ pWwFib->fcPlcfHdrtxbxBkd,
+ pWwFib->lcbPlcfHdrtxbxBkd, 0);
+ break;
+
+
+ default:ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+
+ // PLCF fuer TextBox-Stories im Maintext
+ long nLenTxBxS = (8 > pWw8Fib->nVersion) ? 0 : 22;
+ if( pWwFib->fcPlcftxbxTxt && pWwFib->lcbPlcftxbxTxt )
+ pMainTxbx = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcftxbxTxt,
+ pWwFib->lcbPlcftxbxTxt, nLenTxBxS );
+
+ // PLCF fuer TextBox-Stories im Header-/Footer-Bereich
+ if( pWwFib->fcPlcfHdrtxbxTxt && pWwFib->lcbPlcfHdrtxbxTxt )
+ pHdFtTxbx = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfHdrtxbxTxt,
+ pWwFib->lcbPlcfHdrtxbxTxt, nLenTxBxS );
+
+ pBook = new WW8PLCFx_Book( pSt, pTblSt, *pWwFib, 0 );
+}
+
+WW8ScannerBase::~WW8ScannerBase()
+{
+ DeletePieceTable();
+ delete pPLCFx_PCDAttrs;
+ delete pPLCFx_PCD;
+ delete pPieceIter;
+ delete pPiecePLCF;
+ delete pBook;
+ delete pFldEdnPLCF;
+ delete pFldFtnPLCF;
+ delete pFldAndPLCF;
+ delete pFldHdFtPLCF;
+ delete pFldPLCF;
+ delete pFldTxbxPLCF;
+ delete pFldTxbxHdFtPLCF;
+ delete pEdnPLCF;
+ delete pFtnPLCF;
+ delete pAndPLCF;
+ delete pSepPLCF;
+ delete pPapPLCF;
+ delete pChpPLCF;
+ // vergessene Schaeflein
+ delete pMainFdoa;
+ delete pHdFtFdoa;
+ delete pMainTxbx;
+ delete pMainTxbxBkd;
+ delete pHdFtTxbx;
+ delete pHdFtTxbxBkd;
+}
+
+//-----------------------------------------
+// Stack fuer shorts
+//-----------------------------------------
+
+class UShortStk: private SvShorts
+{
+public:
+ UShortStk():SvShorts( 10, 10 ) {}
+ ~UShortStk() {}
+ void Push( USHORT s ) { Insert( (USHORT)s, SvShorts::Count() ); }
+ inline USHORT Top();
+ inline USHORT Pop();
+ USHORT Count() { return SvShorts::Count(); }
+};
+
+inline USHORT UShortStk::Top()
+{
+ USHORT nPos = SvShorts::Count() - 1;
+ USHORT s = (*this)[ nPos ];
+ return s;
+}
+
+inline USHORT UShortStk::Pop()
+{
+ USHORT nPos = SvShorts::Count() - 1;
+ USHORT s = (*this)[ nPos ];
+ Remove( nPos );
+ return s;
+}
+
+
+//-----------------------------------------
+// Fields
+//-----------------------------------------
+
+static BOOL WW8SkipField( WW8PLCFspecial& rPLCF )
+{
+ void* pData;
+ long nP;
+
+ if( !rPLCF.Get( nP, pData ) ) // Ende des PLCFspecial ?
+ return FALSE;
+
+ rPLCF++;
+
+ if((((BYTE*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
+ return TRUE; // Bei Fehler nicht abbrechen
+
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){ // immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Beschreibungsteil
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+ }
+
+ if((((BYTE*)pData)[0] & 0x1f ) == 0x14 ){ // Field Separator ?
+ rPLCF++;
+
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){// immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Resultatteil
+ if( !rPLCF.Get( nP, pData ) )
+ return FALSE;
+ }
+ }
+ rPLCF++;
+
+ return TRUE;
+}
+
+BOOL WW8GetFieldPara( BYTE nVersion, WW8PLCFspecial& rPLCF, WW8FieldDesc& rF )
+{
+ void* pData;
+ ULONG nOldIdx = rPLCF.GetIdx();
+
+ rF.nLen = rF.nId = rF.nOpt = rF.bCodeNest = rF.bResNest = 0;
+
+ if( !rPLCF.Get( rF.nSCode, pData ) ) // Ende des PLCFspecial ?
+ goto Err;
+
+ rPLCF++;
+
+ if((((BYTE*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
+ goto Err;
+
+ rF.nId = ((BYTE*)pData)[1];
+
+ if( !rPLCF.Get( rF.nLCode, pData ) )
+ goto Err;
+
+ rF.nSRes = rF.nLCode; // Default
+ rF.nSCode++; // ohne Marken
+ rF.nLCode -= rF.nSCode; // Pos zu Laenge
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){ // immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Beschreibungsteil
+ rF.bCodeNest = TRUE;
+ if( !rPLCF.Get( rF.nSRes, pData ) )
+ goto Err;
+ }
+
+ if((((BYTE*)pData)[0] & 0x1f ) == 0x14 ){ // Field Separator ?
+ rPLCF++;
+
+ if( !rPLCF.Get( rF.nLRes, pData ) )
+ goto Err;
+
+ while((((BYTE*)pData)[0] & 0x1f ) == 0x13 ){// immer noch neue (nested) Anfaenge ?
+ WW8SkipField( rPLCF ); // nested Field im Resultatteil
+ rF.bResNest = TRUE;
+ if( !rPLCF.Get( rF.nLRes, pData ) )
+ goto Err;
+ }
+ rF.nLen = rF.nLRes - rF.nSCode + 2; // nLRes ist noch die Endposition
+ rF.nLRes -= rF.nSRes; // nun: nLRes = Laenge
+ rF.nSRes++; // Endpos encl. Marken
+ rF.nLRes--;
+
+ }else{
+ rF.nLRes = 0; // Kein Result vorhanden
+ rF.nLen = rF.nSRes - rF.nSCode + 2; // Gesamtlaenge
+ }
+
+ rPLCF++;
+ if((((BYTE*)pData)[0] & 0x1f ) == 0x15 ){ // Field Ende ?
+ // INDEX-Fld hat Bit7 gesetzt!?!
+ rF.nOpt = ((BYTE*)pData)[1]; // Ja -> Flags uebernehmen
+ }else{
+ rF.nId = 0; // Nein -> Feld ungueltig
+ }
+
+ rPLCF.SetIdx( nOldIdx );
+ return TRUE;
+Err:
+ rPLCF.SetIdx( nOldIdx );
+ return FALSE;
+}
+
+
+//-----------------------------------------
+
+
+// WW8ReadPString liest einen Pascal-String ein und gibt ihn zurueck. Der Pascal-
+// String hat am Ende ein \0, der aber im Laengenbyte nicht mitgezaehlt wird.
+// Der Speicher fuer den Pascalstring wird alloziert.
+String WW8ReadPString( SvStream& rStrm, rtl_TextEncoding eEnc, BOOL bAtEndSeekRel1 )
+{
+ UINT8 b;
+ rStrm >> b;
+
+ ByteString aByteStr; // Alloc methode automatically sets Zero at the end
+ sal_Char* pByteData = aByteStr.AllocBuffer( b );
+
+ sal_Size nWasRead = rStrm.Read( pByteData, b );
+ if( bAtEndSeekRel1 )
+ rStrm.SeekRel( 1 ); // ueberspringe das Null-Byte am Ende.
+
+ if( nWasRead != b )
+ aByteStr.ReleaseBufferAccess( nWasRead );
+
+ return String( aByteStr, eEnc );
+}
+
+
+String WW8Read_xstz( SvStream& rStrm, USHORT nChars, BOOL bAtEndSeekRel1 )
+{
+ UINT16 b;
+
+ if( nChars )
+ b = nChars;
+ else
+ rStrm >> b;
+
+ String aStr; // Alloc methode automatically sets Zero at the end
+ sal_Unicode* pData = aStr.AllocBuffer( b );
+
+ sal_Size nWasRead = rStrm.Read( (sal_Char*)pData, b * 2 );
+ if( nWasRead != b*2 )
+ aStr.ReleaseBufferAccess( b = (nWasRead / 2) );
+
+#ifdef __BIGENDIAN
+ ULONG n;
+ sal_Unicode *pWork;
+ for( n = 0, pWork = pData; n < b; ++n, ++pWork )
+ *pWork = SWAPSHORT( *pWork );
+#endif // ifdef __BIGENDIAN
+
+// 2000/03/27 KHZ UNICODE
+// still missing: unicode-back conversion AND 0xF0.. specials
+
+ if( bAtEndSeekRel1 )
+ rStrm.SeekRel( 2 ); // ueberspringe das Null-Character am Ende.
+
+ return aStr;
+}
+
+
+USHORT WW8ScannerBase::WW8ReadString( SvStream& rStrm, String& rStr,
+ WW8_CP nAktStartCp, long nTotalLen,
+ rtl_TextEncoding eEnc ) const
+ // , unsigned -c-h-a-r-** ppStr ) const
+{
+ // Klartext einlesen, der sich ueber mehrere Pieces erstrecken kann
+ rStr.Erase();
+
+ long nTotalRead = 0;
+ WW8_CP nBehindTextCp = nAktStartCp + nTotalLen;
+ WW8_CP nNextPieceCp = nBehindTextCp; // Initialisierung wichtig fuer Ver6
+ do {
+ BOOL bIsUnicode, bPosOk;
+ WW8_FC fcAct = WW8Cp2Fc( nAktStartCp, &bIsUnicode,
+ &nNextPieceCp, &bPosOk);
+
+ if( !bPosOk ) break; // vermutlich uebers Dateiende hinaus gezielt, macht nix!
+
+ rStrm.Seek( fcAct );
+
+ long nLen = ( (nNextPieceCp < nBehindTextCp)
+ ? nNextPieceCp
+ : nBehindTextCp
+ )
+ - nAktStartCp;
+
+ if( 0 >= nLen ) break;
+
+ if( nLen > USHRT_MAX - 1 )
+ nLen = USHRT_MAX - 1;
+
+ if( bIsUnicode )
+ rStr.Append( WW8Read_xstz( rStrm, (USHORT)nLen, FALSE ) );
+ else
+ {
+ ByteString aByteStr; // Alloc methode automatically sets Zero at the end
+ sal_Char* pByteData = aByteStr.AllocBuffer( nLen );
+
+ sal_Size nWasRead = rStrm.Read( pByteData, nLen );
+ if( nWasRead != nLen )
+ aByteStr.ReleaseBufferAccess( nWasRead );
+
+ rStr += String( aByteStr, eEnc );
+ }
+ nTotalRead += nLen;
+ nAktStartCp += nLen;
+ if( nTotalRead != rStr.Len() ) break;
+ }
+ while( nTotalRead < nTotalLen );
+
+ return rStr.Len();
+}
+
+
+//-----------------------------------------
+// WW8PLCFspecial
+//-----------------------------------------
+
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCFspecial::WW8PLCFspecial( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos, BOOL bNoEnd )
+:nIdx( 0 ), nStru( nStruct )
+{
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+ pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos- u. Struct-Array
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pPLCF_PosArray, nPLCF );
+#ifdef __BIGENDIAN
+ for( nIdx = 0; nIdx <= nIMax; nIdx++ ){
+ pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] );
+ }
+ nIdx = 0;
+#endif // __BIGENDIAN
+ if( bNoEnd ) nIMax++;
+ if( nStruct )
+ pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+ else
+ pPLCF_Contents = 0; // kein Inhalt
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+
+ pSt->Seek( nOldPos );
+}
+
+// WW8PLCFspecial::SeekPos() stellt den WW8PLCFspecial auf die Stelle nPos, wobei auch noch der
+// Eintrag benutzt wird, der vor nPos beginnt und bis hinter nPos reicht.
+// geeignet fuer normale Attribute. Allerdings wird der Attributanfang nicht
+// auf die Position nPos korrigiert.
+BOOL WW8PLCFspecial::SeekPos( long nPos )
+{
+ long nP = nPos;
+
+ if( nP < pPLCF_PosArray[0] )
+ {
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+
+ // Search from beginning?
+ if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) )
+ nIdx = 1;
+
+ long nI = nIdx ? nIdx : 1;
+ long nEnd = nIMax;
+#ifndef KHZ_TEST0
+ for(int n = (1==nIdx ? 1 : 2); n; --n )
+ {
+ for( ; nI <=nEnd; ++nI)
+ { // Suchen mit um 1 erhoehtem Index
+ if( nP < pPLCF_PosArray[nI] )
+ { // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nI = 1;
+ nEnd = nIdx-1;
+ }
+#else
+ for( nI=1; nI<=nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nP < pPLCF_PosArray[nI] ){ // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+#endif
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+// WW8PLCFspecial::SeekPosExact() wie SeekPos(), aber es wird sichergestellt, dass kein
+// Attribut angeschnitten wird, d.h. das naechste gelieferte Attribut beginnt
+// auf oder hinter nPos. Wird benutzt fuer Felder + Bookmarks.
+BOOL WW8PLCFspecial::SeekPosExact( long nPos )
+{
+ long nP = nPos;
+
+ if( nP < pPLCF_PosArray[0] )
+ {
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ // Search from beginning?
+ if( nP <=pPLCF_PosArray[nIdx] )
+ nIdx = 0;
+
+ long nI = nIdx ? nIdx-1 : 0;
+ long nEnd = nIMax;
+#ifndef KHZ_TEST0
+ for(int n = (0==nIdx ? 1 : 2); n; --n )
+ {
+ for( ; nI < nEnd; ++nI)
+ {
+ if( nP <=pPLCF_PosArray[nI] )
+ { // Position gefunden
+ nIdx = nI; // nI ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nI = 0;
+ nEnd = nIdx;
+ }
+#else
+ for( nI=0; nI<nIMax; nI++){ // Suchen
+ if( nP <= pPLCF_PosArray[nI] ){ // Position gefunden
+ nIdx = nI; // nI ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+#endif
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}
+
+BOOL WW8PLCFspecial::Get( long& rPos, void*& rpValue )
+{
+ if ( nIdx >= nIMax ){
+ rPos = LONG_MAX;
+ return FALSE;
+ }
+ rPos = pPLCF_PosArray[nIdx];
+ rpValue = pPLCF_Contents ? (void*)&pPLCF_Contents[nIdx * nStru] : 0;
+ return TRUE;
+}
+
+BOOL WW8PLCFspecial::GetData( long nIdx, long& rPos, void*& rpValue )
+{
+ if ( nIdx >= nIMax ){
+ rPos = LONG_MAX;
+ return FALSE;
+ }
+ rPos = pPLCF_PosArray[nIdx];
+ rpValue = pPLCF_Contents ? (void*)&pPLCF_Contents[nIdx * nStru] : 0;
+ return TRUE;
+}
+
+//-----------------------------------------
+// WW8PLCF z.B. fuer SEPX
+//-----------------------------------------
+
+// Ctor fuer *andere* als Fkps
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCF::WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos )
+:nIdx( 0 ), nStru( nStruct )
+{
+ ASSERT( nPLCF, "WW8PLCF: nPLCF ist Null!" );
+
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+
+ ReadPLCF( pSt, nFilePos, nPLCF );
+
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+}
+
+// Ctor *nur* fuer Fkps
+// Die letzten 2 Parameter sind fuer PLCF.Chpx und PLCF.Papx noetig.
+// ist ncpN != 0, dann wird ein unvollstaendiger PLCF vervollstaendigt.
+// Das ist bei WW6 bei Resourcenmangel und bei WordPad (W95) immer noetig.
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCF::WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos, long nPN, long ncpN )
+:nIdx( 0 ), nStru( nStruct )
+{
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+
+ if( nIMax >= (long) ncpN )
+ ReadPLCF( pSt, nFilePos, nPLCF );
+ else
+ GeneratePLCF( pSt, nPN, ncpN );
+
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+
+// Damit man sich den Inhalt im Debugger ansehen kann
+#ifdef DEBUG
+ INT32 (*p1)[200] = (INT32 (*)[200])pPLCF_PosArray;
+ USHORT (*p2)[200] = (USHORT (*)[200])pPLCF_Contents;
+ p2 = p2;
+#endif
+}
+
+void WW8PLCF::ReadPLCF( SvStream* pSt, long nFilePos, long nPLCF )
+{
+ pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos-Array
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pPLCF_PosArray, nPLCF );
+#ifdef __BIGENDIAN
+ for( nIdx = 0; nIdx <= nIMax; nIdx++ ){
+ pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] );
+ }
+ nIdx = 0;
+#endif // __BIGENDIAN
+ pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+
+ pSt->Seek( nOldPos );
+}
+
+void WW8PLCF::GeneratePLCF( SvStream* pSt, long nPN,
+ long ncpN )
+{
+ ASSERT( nIMax < (long)ncpN, "Pcl.Fkp: Warum ist PLCF zu gross ?" );
+ nIMax = ncpN;
+ long nSiz = 6 * nIMax + 4;
+ pPLCF_PosArray = new INT32[ ( nSiz + 3 ) / 4 ]; // Pointer auf Pos-Array
+ memset( pPLCF_PosArray, 0, (size_t)nSiz );
+
+ INT32 nFc;
+ USHORT i;
+
+ for( i = 0; i < ncpN; i++ ){ // Baue FC-Eintraege
+ pSt->Seek( ( nPN + i ) << 9 ); // erster FC-Eintrag jedes Fkp
+ *pSt >> nFc;
+ pPLCF_PosArray[i] = nFc;
+ }
+ ULONG nLastFkpPos = ( ( nPN + nIMax - 1 ) << 9 );
+ pSt->Seek( nLastFkpPos + 511 ); // Anz. Fkp-Eintraege des letzten Fkp
+ BYTE nb;
+ *pSt >> nb;
+ pSt->Seek( nLastFkpPos + nb * 4 ); // letzer FC-Eintrag des letzten Fkp
+ *pSt >> nFc;
+ pPLCF_PosArray[nIMax] = nFc; // Ende des letzten Fkp
+
+ pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+ USHORT* p = (USHORT*)pPLCF_Contents;
+
+ for( i = 0; i < ncpN; i++ ) // Baue PNs
+ p[i] = nPN + i;
+
+#ifdef DEBUG // Damit man sich den Inhalt im Debugger ansehen kann
+ INT32 (*p1)[200] = (INT32 (*)[200])pPLCF_PosArray;
+ USHORT (*p2)[200] = (USHORT (*)[200])pPLCF_Contents;
+ p2 = p2;
+#endif
+}
+
+BOOL WW8PLCF::SeekPos( long nPos )
+{
+ long nP = nPos;
+
+ if( nP < pPLCF_PosArray[0] )
+ {
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ // Search from beginning?
+ if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) )
+ nIdx = 1;
+
+ long nI = nIdx ? nIdx : 1;
+ long nEnd = nIMax;
+#ifndef KHZ_TEST0
+ for(int n = (1==nIdx ? 1 : 2); n; --n )
+ {
+ for( ; nI <=nEnd; ++nI) // Suchen mit um 1 erhoehtem Index
+ {
+ if( nP < pPLCF_PosArray[nI] ) // Position gefunden
+ {
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nI = 1;
+ nEnd = nIdx-1;
+ }
+#else
+ for( nI=1; nI<=nIMax; nI++){
+ if( nP < pPLCF_PosArray[nI] ){
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+#endif
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}//4,11,0,11,4,0,0,0,0,0,11,11,11,11,
+
+BOOL WW8PLCF::Get( long& rStart, long& rEnd, void*& rpValue )
+{
+ if ( nIdx >= nIMax )
+ {
+ rStart = rEnd = LONG_MAX;
+ return FALSE;
+ }
+ rStart = pPLCF_PosArray[ nIdx ];
+ rEnd = pPLCF_PosArray[ nIdx + 1 ];
+ rpValue = (void*)&pPLCF_Contents[nIdx * nStru];
+ return TRUE;
+}
+
+long WW8PLCF::Where()
+{
+ if ( nIdx >= nIMax )
+ return LONG_MAX;
+
+ return pPLCF_PosArray[nIdx];
+}
+
+//-----------------------------------------
+// WW8PLCFpcd
+//-----------------------------------------
+
+WW8PLCFpcd::WW8PLCFpcd( SvStream* pSt, long nFilePos, long nPLCF, long nStruct )
+:nStru( nStruct )
+{
+ nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
+ pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos-Array
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pPLCF_PosArray, nPLCF );
+#ifdef __BIGENDIAN
+ {
+ for( long nI = 0; nI <= nIMax; nI++ )
+ pPLCF_PosArray[nI] = SWAPLONG( pPLCF_PosArray[nI] );
+ }
+#endif // __BIGENDIAN
+
+ pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; // Pointer auf Inhalts-Array
+
+ for( INT32 nI = 0; nI < nIMax; nI++ )
+ {
+ ULONG nKey = (ULONG)(0x8FFFFFFF & ((WW8_PCD1&)pPLCF_Contents[nI * nStru]).fc);
+ aFC_sort.Insert( nKey, nI );
+ }
+
+ pSt->Seek( nOldPos );
+}
+
+
+ULONG WW8PLCFpcd::FindIdx( WW8_FC nFC ) const
+{
+ ULONG nFound;
+ if( !aFC_sort.SearchKey( nFC, &nFound ) )
+ {
+ if( !nFound )
+ nFound = ULONG_MAX;
+ else
+ --nFound; // we were behind the list because nFc is greater max. list entry
+ }
+ return ULONG_MAX == nFound ? ULONG_MAX : aFC_sort.GetObject( nFound );
+}
+
+
+// Bei nStartPos < 0 wird das erste Element des PLCFs genommen
+WW8PLCFpcd_Iter::WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, long nStartPos /* = -1 */ )
+:rPLCF( rPLCFpcd ), nIdx( 0 )
+{
+ if( nStartPos >= 0 )
+ SeekPos( nStartPos );
+}
+
+BOOL WW8PLCFpcd_Iter::SeekPos( long nPos )
+{
+ long nP = nPos;
+
+ if( nP < rPLCF.pPLCF_PosArray[0] )
+ {
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ // Search from beginning?
+ if( (1 > nIdx) || (nP < rPLCF.pPLCF_PosArray[ nIdx-1 ]) )
+ nIdx = 1;
+
+ long nI = nIdx ? nIdx : 1;
+ long nEnd = rPLCF.nIMax;
+#ifndef KHZ_TEST0
+ for(int n = (1==nIdx ? 1 : 2); n; --n )
+ {
+ for( ; nI <=nEnd; ++nI)
+ { // Suchen mit um 1 erhoehtem Index
+ if( nP < rPLCF.pPLCF_PosArray[nI] )
+ { // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nI = 1;
+ nEnd = nIdx-1;
+ }
+#else
+ for( nI=1; nI<=rPLCF.nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nP < rPLCF.pPLCF_PosArray[nI] ){// Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+#endif
+ nIdx = rPLCF.nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}//0,0,...0,1,0,0,1,0,0,1,1,...1,2,1,1,2,1,1,2,2,...2,4,2,2,3,2,2,3,3,...3,5,7,8,d,10,11,
+
+/*
+BOOL WW8PLCFpcd_Iter::SeekMaxMainFC( WW8Fib& rWwF, long& rMaxPosData )
+{
+ long nCpStart, nCpEnd;
+ void* pData;
+ nIdx = rPLCF.nIMax-1;
+ if( !Get( nCpStart, nCpEnd, pData ) )
+ {
+ ASSERT( !this, "SeekMaxMainFC findet Eintrag zu nIdx nicht" );
+ return FALSE;
+ }
+ BOOL bIsUnicode;
+ WW8_FC nActPosData = WW8PLCFx_PCD::TransformPieceAddress(
+ SVBT32ToLong( ( (WW8_PCD*)pData )->fc ),
+ &bIsUnicode );
+
+// rMaxPosData = nActPosData + ((rWwF.ccpText - nCpStart) * (bIsUnicode ? 2 : 1));
+
+ rMaxPosData = nActPosData + rWwF.ccpText - nCpStart;
+
+ return (0 < rMaxPosData);
+}
+*/
+
+BOOL WW8PLCFpcd_Iter::Get( long& rStart, long& rEnd, void*& rpValue )
+{
+ if( nIdx >= rPLCF.nIMax )
+ {
+ rStart = rEnd = LONG_MAX;
+ return FALSE;
+ }
+ rStart = rPLCF.pPLCF_PosArray[nIdx];
+ rEnd = rPLCF.pPLCF_PosArray[nIdx + 1];
+ rpValue = (void*)&rPLCF.pPLCF_Contents[nIdx * rPLCF.nStru];
+#ifdef DEBUG
+ WW8_PCD1* p = (WW8_PCD1*)rpValue;
+ p = p;
+#endif
+ return TRUE;
+}
+
+long WW8PLCFpcd_Iter::Where()
+{
+ if ( nIdx >= rPLCF.nIMax )
+ return LONG_MAX;
+
+ return rPLCF.pPLCF_PosArray[nIdx];
+}
+
+//-----------------------------------------
+
+WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp( BYTE nFibVer, SvStream* pSt, SvStream* pDataSt,
+ long _nFilePos, long nItemSiz,
+ ePLCFT ePl, WW8_FC nStartFc )
+:nItemSize( nItemSiz ), nFilePos( _nFilePos ), ePLCF( ePl ), nIdx( 0 )
+{
+ nVersion = nFibVer;
+
+ pFkp = (BYTE*)new INT32[128]; // 512 Byte
+
+ long nOldPos = pSt->Tell();
+
+ pSt->Seek( nFilePos );
+ pSt->Read( pFkp, 512 );
+ nIMax = pFkp[511];
+#ifdef __BIGENDIAN
+ register UINT32* p;
+ for( nIdx = 0, p = (UINT32*)pFkp; nIdx <= nIMax; nIdx++, p++ )
+ *p = SWAPLONG( *p );
+#endif // __BIGENDIAN
+
+
+ // Pointer auf Offset-Bereich in *pFkp
+ BYTE* pOfs = pFkp + (nIMax + 1) * 4;
+
+ pGrpprl = new WW8Grpprl[nIMax];
+ memset( pGrpprl, 0, sizeof( WW8Grpprl )*nIMax );
+
+ WW8Grpprl* pTmpGrpprl = pGrpprl;
+ for( nIdx = 0; nIdx < nIMax; nIdx++, pTmpGrpprl++ )
+ {
+ USHORT nOfs = (*(pOfs + nIdx * nItemSize)) * 2;
+
+ if ( nOfs )
+ {
+ switch ( ePLCF )
+ {
+ case CHP:
+ pTmpGrpprl->nLen = (short)pFkp[ nOfs ];
+ pTmpGrpprl->pData = pFkp + nOfs + 1;
+ break;
+ case PAP:
+ BYTE nDelta = 0;//(8 > nVersion) ? 0 : 1;
+ pTmpGrpprl->nLen = pFkp[ nOfs ];
+ if( 8 <= nVersion && !pTmpGrpprl->nLen )
+ {
+ pTmpGrpprl->nLen = pFkp[ nOfs+1 ];
+ nDelta++;
+ }
+ pTmpGrpprl->nIStd = SVBT16ToShort( (BYTE*) pFkp+nOfs+1+nDelta );
+ pTmpGrpprl->pData = pFkp + nOfs + 3+nDelta ;
+ USHORT nSpId = WW8GetSprmId( nVersion, pTmpGrpprl->pData );
+ if( 0x6645 == nSpId || 0x6646 == nSpId )
+ {
+ UINT32 nPos = *(UINT32*)(pTmpGrpprl->pData + 2);
+ UINT32 nCurr = pDataSt->Tell();
+ pDataSt->Seek( nPos );
+ *pDataSt >> pTmpGrpprl->nLen;
+ pTmpGrpprl->pData = new BYTE[pTmpGrpprl->nLen];
+ pTmpGrpprl->bMustDelete = TRUE;
+ pDataSt->Read( pTmpGrpprl->pData, pTmpGrpprl->nLen );
+
+ pDataSt->Seek( nCurr );
+ }
+ else
+ {
+ pTmpGrpprl->nLen *= 2;
+ pTmpGrpprl->nLen -= 2;
+ }
+ break;
+ }
+ }
+ }
+
+ nIdx = 0;
+
+ if( nStartFc >= 0 )
+ SeekPos( nStartFc );
+
+ pSt->Seek( nOldPos );
+}
+
+WW8PLCFx_Fc_FKP::WW8Fkp::~WW8Fkp()
+{
+ WW8Grpprl* pTmpGrpprl = pGrpprl;
+ for( nIdx = 0; nIdx < nIMax; nIdx++, pTmpGrpprl++ )
+ {
+ if( pTmpGrpprl->bMustDelete )
+ delete pTmpGrpprl->pData;
+ }
+ delete pGrpprl;
+ delete pFkp;
+}
+
+BOOL WW8PLCFx_Fc_FKP::WW8Fkp::SeekPos( WW8_FC nFc )
+{
+ if( nFc < ((WW8_FC*)pFkp)[0] )
+ {
+ nIdx = 0;
+ return FALSE; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
+ }
+ // Search from beginning?
+ if( (1 > nIdx) || (nFc < ((WW8_FC*)pFkp)[ nIdx-1 ]) )
+ nIdx = 1;
+
+ long nI = nIdx ? nIdx : 1;
+ long nEnd = nIMax;
+#ifndef KHZ_TEST0
+ for(int n = (1==nIdx ? 1 : 2); n; --n )
+ {
+ for( ; nI <=nEnd; ++nI)
+ { // Suchen mit um 1 erhoehtem Index
+ if( nFc < ((WW8_FC*)pFkp)[nI] )
+ { // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+ nI = 1;
+ nEnd = nIdx-1;
+ }
+#else
+ for( nI=1; nI<=nIMax; nI++){ // Suchen mit um 1 erhoehtem Index
+ if( nFc < ((WW8_FC*)pFkp)[nI] ){ // Position gefunden
+ nIdx = nI - 1; // nI - 1 ist der richtige Index
+ return TRUE; // ... und fertig
+ }
+ }
+#endif
+ nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
+ return FALSE;
+}//32,0,1,32,0,0,1,1,2,2,3,4,5,
+
+BYTE* WW8PLCFx_Fc_FKP::WW8Fkp::Get( WW8_FC& rStart, WW8_FC& rEnd, short& rLen )
+{
+ rLen = 0;
+
+ if( nIdx >= nIMax ){
+ rStart = LONG_MAX;
+ return 0;
+ }
+
+ rStart = ((WW8_FC*)pFkp)[nIdx ];
+ rEnd = ((WW8_FC*)pFkp)[nIdx+1];
+
+ BYTE* pSprms = GetLenAndIStdAndSprms( rLen );
+ return pSprms;
+}
+
+void WW8PLCFx_Fc_FKP::WW8Fkp::SetIdx( ULONG nI )
+{
+ if( nI < nIMax) nIdx = (short)nI;
+}
+
+BYTE* WW8PLCFx_Fc_FKP::WW8Fkp::GetLenAndIStdAndSprms(short& rLen)
+{
+ WW8Grpprl* pTmpGrpprl = pGrpprl + nIdx;
+
+ rLen = pTmpGrpprl->nLen;
+
+ return pTmpGrpprl->pData;
+}
+
+
+BYTE* WW8FindSprm( USHORT nId, long nLen, BYTE* pSprms, BYTE nVersion )
+{
+ WW8SprmIter aSprmIter( pSprms, nLen, nVersion );
+
+ while( aSprmIter.GetSprms() )
+ {
+ if( aSprmIter.GetAktId() == nId )
+ return aSprmIter.GetAktParams(); // SPRM found!
+ aSprmIter++;
+ }
+
+ return 0; // SPRM _not_ found
+}
+
+
+BYTE* WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm( USHORT nId )
+{
+ if( nIdx >= nIMax )
+ return 0;
+
+ short nLen;
+ BYTE* pSprms = GetLenAndIStdAndSprms( nLen );
+
+ return WW8FindSprm( nId, nLen, pSprms, nVersion );
+}
+
+ULONG WW8PLCFx_Fc_FKP::WW8Fkp::GetParaHeight() const
+{
+ if( ePLCF != PAP ){
+ ASSERT( !this, "Fkp::GetParaHeight: Falscher Fkp" );
+ return 0;
+ }
+ if( nIdx >= nIMax )
+ return 0;
+
+ WW8_PHE_Base* pPhe = (WW8_PHE_Base*)( (pFkp + (nIMax + 1) * 4)
+ + ( nIdx * nItemSize ) + 1 );
+
+ if( pPhe->aBits1 & 0x2 ) // fUnk
+ return 0; // invalid
+
+ if( pPhe->aBits1 & 0x4 ){ // fDiffLines
+ return SVBT16ToShort( pPhe->dyl ); // Gesamthoehe
+ }else{ // nlMac gleich hohe Zeilen
+ INT32 nH = (INT16)SVBT16ToShort( pPhe->dyl ); // Zeilenhoehe
+ if( nH < 0 ) // negative Werte wollen wir
+ nH = 0; // nicht
+ nH *= (INT32)pPhe->nlMac; // Hoehe einer Zeile * Zeilen
+ return (ULONG)nH;
+ }
+}
+
+//-----------------------------------------
+
+void WW8PLCFx::GetSprms( WW8PLCFxDesc* p )
+{
+ ASSERT( !this, "Falsches GetSprms gerufen" );
+ p->nStartPos = p->nEndPos = LONG_MAX;
+ p->nSprmsLen = 0;
+ p->pMemPos = 0;
+ p->bRealLineEnd = FALSE;
+ return;
+}
+
+long WW8PLCFx::GetNoSprms( long& rStart, long& rEnd, long& rLen )
+{
+ ASSERT( !this, "Falsches GetNoSprms gerufen" );
+ rStart = rEnd = LONG_MAX;
+ rLen = 0;
+ return 0;
+}
+
+// ...Idx2: Default: ignorieren
+ULONG WW8PLCFx::GetIdx2() const
+{
+ return 0;
+}
+
+void WW8PLCFx::SetIdx2( ULONG nIdx )
+{
+}
+
+//-----------------------------------------
+BOOL WW8PLCFx_Fc_FKP::NewFkp()
+{
+ long nPLCFStart, nPLCFEnd;
+ void* pPage;
+
+ static int __READONLY_DATA WW8FkpSizeTabVer6[ PLCF_END ] = {
+ 1, 7, 0 /*, 0, 0, 0*/ };
+ static int __READONLY_DATA WW8FkpSizeTabVer8[ PLCF_END ] = {
+ 1, 13, 0 /*, 0, 0, 0*/ };
+ const int* pFkpSizeTab;
+ switch( GetVersion() )
+ {
+ case 6:
+ case 7: pFkpSizeTab = WW8FkpSizeTabVer6;
+ break;
+ case 8: pFkpSizeTab = WW8FkpSizeTabVer8;
+ break;
+ default:// Programm-Fehler!
+ ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ return FALSE;
+ }
+
+ if (!pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ))
+ {
+ DELETEZ( pFkp );
+ return FALSE; // PLCF fertig abgearbeitet
+ }
+ (*pPLCF)++;
+ long nPo = SVBT16ToShort( (unsigned char *)pPage );
+ nPo <<= 9; // shift als LONG
+
+ long nAktFkpFilePos = pFkp ? pFkp->GetFilePos() : -1;
+ if( nAktFkpFilePos != nPo )
+ {
+ DELETEZ( pFkp );
+ pFkp = new WW8Fkp( GetVersion(), pFKPStrm, pDataStrm, nPo,
+ pFkpSizeTab[ ePLCF ],
+ ePLCF, nStartFc );
+ }
+ else // khz test1 //
+ {
+ pFkp->SetIdx( 0 );
+ if( nStartFc >= 0 )
+ pFkp->SeekPos( nStartFc );
+ }
+
+ nStartFc = -1; // Nur das erste Mal
+ return TRUE;
+}
+
+WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTblSt,
+ SvStream* pDataSt, WW8Fib& rFib, ePLCFT ePl,
+ WW8_FC nStartFcL,
+ WW8PLCFx_PCDAttrs* pPLCFx_PCDAttrs_)
+ : WW8PLCFx( rFib.nVersion, TRUE ),
+ pFKPStrm( pSt ),
+ pDataStrm( pDataSt ),
+ ePLCF( ePl ),
+ pFkp( 0 ),
+ nStartFc( nStartFcL ),
+ pPCDAttrs( pPLCFx_PCDAttrs_)
+{
+ long nLenStruct = (8 > rFib.nVersion) ? 2 : 4;
+ if( ePl == CHP )
+ pPLCF = new WW8PLCF( pTblSt, rFib.fcPlcfbteChpx,
+ rFib.lcbPlcfbteChpx,
+ nLenStruct,
+ nStartFc,
+ rFib.pnChpFirst,
+ rFib.cpnBteChp );
+ else
+ pPLCF = new WW8PLCF( pTblSt, rFib.fcPlcfbtePapx,
+ rFib.lcbPlcfbtePapx,
+ nLenStruct,
+ nStartFc,
+ rFib.pnPapFirst,
+ rFib.cpnBtePap );
+}
+
+WW8PLCFx_Fc_FKP::~WW8PLCFx_Fc_FKP()
+{
+ delete pFkp;
+ delete pPLCF;
+}
+
+
+ULONG WW8PLCFx_Fc_FKP::GetIdx() const
+{
+ ULONG u = pPLCF->GetIdx() << 8;
+ if( pFkp )
+ u |= pFkp->GetIdx();
+ return u;
+}
+
+void WW8PLCFx_Fc_FKP::SetIdx( ULONG nIdx )
+{
+ if( !( nIdx & 0xffffff00L ) )
+ {
+ pPLCF->SetIdx( nIdx >> 8 );
+ DELETEZ( pFkp );
+
+ }
+ else
+ { // Es gab einen Fkp
+ // Lese PLCF um 1 Pos zurueck, um
+ pPLCF->SetIdx( ( nIdx >> 8 ) - 1 ); // die Adresse des Fkp wiederzubekommen
+ if ( NewFkp() ) // und lese Fkp wieder ein
+ pFkp->SetIdx( nIdx & 0xff ); // Dann stelle Fkp-Pos wieder ein
+ }
+}
+
+
+BOOL WW8PLCFx_Fc_FKP::SeekPos( WW8_FC nFcPos )
+{
+ // StartPos for next Where()
+ nStartFc = nFcPos;
+
+ // find StartPos for next pPLCF->Get()
+ BOOL bRet = pPLCF->SeekPos( nFcPos );
+
+ // make FKP invalid?
+ long nPLCFStart, nPLCFEnd;
+ void* pPage;
+ if( pFkp && pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ) )
+ {
+ long nPo = SVBT16ToShort( (unsigned char *)pPage );
+ nPo <<= 9; // shift als LONG
+ if( nPo != pFkp->GetFilePos() )
+ DELETEZ( pFkp );
+ else
+ pFkp->SeekPos( nFcPos );
+ }
+ return bRet;
+}
+
+WW8_FC WW8PLCFx_Fc_FKP::Where()
+{
+// if( bDontModify )
+// return pFkp ? pFkp->Where() : 0;
+
+ if( !pFkp )
+ {
+ if( !NewFkp() )
+ return LONG_MAX;
+ }
+ WW8_FC nP = pFkp->Where();
+ if( nP != LONG_MAX )
+ return nP;
+
+ DELETEZ( pFkp ); // FKP beendet -> hole neuen
+ return Where(); // am einfachsten rekursiv
+}
+
+
+
+BYTE* WW8PLCFx_Fc_FKP::GetSprms( WW8_FC& rStart, WW8_FC& rEnd, long& rLen )
+{
+ rLen = 0; // Default
+ rStart = rEnd = LONG_MAX;
+
+ if( !pFkp ){ // Fkp nicht da ?
+ if( !NewFkp() )
+ return 0;
+ }
+
+ short nLen;
+ BYTE* pPos = pFkp->Get( rStart, rEnd, nLen );
+ if( rStart == LONG_MAX )
+ { // nicht gefunden
+ return 0;
+ }
+ rLen = nLen;
+ return pPos;
+}
+
+
+
+WW8PLCFx& WW8PLCFx_Fc_FKP::operator ++( int )
+{
+ if( !pFkp ){
+// ASSERT( FALSE, "pFkp fehlt");
+// return *this;
+ if( !NewFkp() )
+ return *this;
+ }
+
+ (*pFkp)++;
+ if( pFkp->Where() == LONG_MAX ){
+ NewFkp();
+ }
+ return *this;
+}
+
+USHORT WW8PLCFx_Fc_FKP::GetIstd() const
+{
+ return (pFkp) ? pFkp->GetIstd() : 0xffff;
+}
+
+
+void WW8PLCFx_Fc_FKP::GetPCDSprms( WW8PLCFxDesc& rDesc )
+{
+ rDesc.pMemPos = 0;
+ rDesc.nSprmsLen = 0;
+ if( pPCDAttrs )
+ {
+ if( !pFkp )
+ {
+ DBG_WARNING( "+Problem: GetPCDSprms: NewFkp noetig ( kein const moeglich )" );
+ if( !NewFkp() )
+ return;
+ }
+
+ long nFcPos, nEnd; // FCs
+ short nLen;
+ pFkp->Get( nFcPos, nEnd, nLen );
+
+ WW8PLCFpcd_Iter* pIter = pPCDAttrs->GetIter();
+
+ /**************************************/
+ ULONG nSaveIdx = pIter->GetIdx();
+ for( int nLoop = 0; 2 > nLoop; ++nLoop )
+ {
+ long nCpStart, nCpEnd;
+ void* pData;
+
+ if( pIter->Get( nCpStart, nCpEnd, pData ) )
+ {
+ BOOL bIsUnicode = FALSE;
+ INT32 nFcStart = SVBT32ToLong( ((WW8_PCD*)pData)->fc );
+ if( 7 < GetVersion() )
+ nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
+
+ INT32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1);
+
+ if( nFcPos >= nFcStart && nFcPos < nFcStart + nLen )
+ {
+ // gefunden
+ pPCDAttrs->GetSprms( &rDesc );
+ break;
+ }
+ }
+ if( !nLoop )
+ {
+ ULONG nFoundIdx = pIter->FindIdx( nFcPos );
+ if( nFoundIdx > pIter->GetIMax())
+ {
+ break;
+ }
+ pIter->SetIdx( nFoundIdx );
+ }
+ }
+ pIter->SetIdx( nSaveIdx );
+ /**************************************/
+ }
+}
+
+
+BYTE* WW8PLCFx_Fc_FKP::HasSprm( USHORT nId )
+{ // const waere schoener, aber dafuer
+ // muesste NewFkp() ersetzt werden
+ // oder wegfallen
+ if( !pFkp )
+ {
+ DBG_WARNING( "+Motz: HasSprm: NewFkp noetig ( kein const moeglich )" );
+ // Passiert bei BugDoc 31722
+ if( !NewFkp() )
+ return 0;
+ }
+
+ BYTE* pRes = pFkp->HasSprm( nId );
+
+ if( !pRes )
+ {
+ WW8PLCFxDesc aDesc;
+ GetPCDSprms( aDesc );
+
+ if( aDesc.pMemPos )
+ {
+ pRes = WW8FindSprm( nId, aDesc.nSprmsLen,
+ aDesc.pMemPos, pFkp->GetVersion() );
+ }
+ }
+ return pRes;
+}
+
+
+ULONG WW8PLCFx_Fc_FKP::GetParaHeight() const
+{
+ if( !pFkp ){
+ ASSERT( !this, "GetParaHeight: pFkp nicht da" );
+ return 0;
+ }
+ return pFkp->GetParaHeight();
+}
+
+//-----------------------------------------
+
+WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ const WW8ScannerBase& rBase,
+ ePLCFT ePl )
+ : WW8PLCFx_Fc_FKP( pSt, pTblSt, pDataSt, *rBase.pWw8Fib, ePl,
+ rBase.WW8Cp2Fc( 0 ),
+ rBase.pPLCFx_PCDAttrs ),
+ rSBase( rBase ),
+// nFcMin( rBase.pWrFib.fcMin ),
+ nAttrStart( -1 ), nAttrEnd( -1 ),
+ bLineEnd( FALSE ),
+ bComplex( (7 < rBase.pWw8Fib->nVersion) || (0 != rBase.pWw8Fib->fComplex) )
+{
+ ResetAttrStartEnd();
+ pPcd = rSBase.pPiecePLCF ? new WW8PLCFx_PCD(
+ rBase.pWw8Fib->nVersion, rBase.pPiecePLCF, 0,
+ ((6 == GetVersion()) || (7 == GetVersion())) )
+ : 0;
+}
+
+WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP()
+{
+ delete pPcd;
+}
+
+void WW8PLCFx_Cp_FKP::ResetAttrStartEnd()
+{
+ nAttrStart = -1;
+ nAttrEnd = -1;
+ bLineEnd = FALSE;
+}
+
+ULONG WW8PLCFx_Cp_FKP::GetPCDIMax() const
+{
+ return pPcd ? pPcd->GetIMax() : 0;
+}
+
+ULONG WW8PLCFx_Cp_FKP::GetPCDIdx() const
+{
+ return pPcd ? pPcd->GetIdx() : 0;
+}
+
+void WW8PLCFx_Cp_FKP::SetPCDIdx( ULONG nIdx )
+{
+ if( pPcd )
+ pPcd->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_Cp_FKP::SeekPos( WW8_CP nCpPos )
+{
+/*
+ WW8_FC nTargetFc = WW8Cp2Fc( nCpPos, nFcMin );
+ return (LONG_MAX != nTargetFc)
+ && WW8PLCFx_Fc_FKP::SeekPos( nTargetFc );
+*/
+ if( pPcd ) // Complex
+ {
+ if( !pPcd->SeekPos( nCpPos ) ) // Piece setzen
+ return FALSE;
+ return WW8PLCFx_Fc_FKP::SeekPos( pPcd->AktPieceStartCp2Fc( nCpPos ) );
+ }
+ // KEINE Piece-Table !!!
+ return WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc( nCpPos /*,TRUE*/ ) );
+}
+
+WW8_CP WW8PLCFx_Cp_FKP::Where()
+{
+ WW8_FC nFc = WW8PLCFx_Fc_FKP::Where();
+/* if( LONG_MAX == nFc )
+ return LONG_MAX;*/
+ if( pPcd )
+ return pPcd->AktPieceStartFc2Cp( nFc ); // Piece ermitteln
+ return rSBase.WW8Fc2Cp( nFc/*,TRUE*/ ); // KEINE Piece-Table !!!
+}
+
+void WW8PLCFx_Cp_FKP::GetSprms( WW8PLCFxDesc* p )
+{
+ p->pMemPos = WW8PLCFx_Fc_FKP::GetSprms( p->nStartPos, p->nEndPos, p->nSprmsLen );
+
+#ifdef DEBUG
+ if( ePLCF == PAP ) // um hier einen Brechpunkt zu setzen
+ ePLCF = PAP;
+#endif
+
+ if( pPcd ) // Piece-Table vorhanden !!!
+ {
+ if( (nAttrStart > nAttrEnd)
+ || (nAttrStart == -1) ) // Init ( noch kein ++ gerufen )
+ {
+ eCutT eC = pPcd->AktPieceFc2Cp( p->nStartPos, p->nEndPos );
+ p->bRealLineEnd = !( eC & CUT_END ) && ePLCF == PAP;
+ }
+ else
+ {
+ p->nStartPos = nAttrStart;
+ p->nEndPos = nAttrEnd;
+ p->bRealLineEnd = bLineEnd;
+ }
+ }
+ else // KEINE Piece-Table !!!
+ {
+ p->nStartPos = rSBase.WW8Fc2Cp( p->nStartPos/*,TRUE*/ );
+ p->nEndPos = rSBase.WW8Fc2Cp( p->nEndPos/*,TRUE*/ );
+ p->bRealLineEnd = ePLCF == PAP;
+ }
+}
+
+
+// WW8PLCF_Cp_Fkp::SearchParaEnd kann einfacher durchgefuehrt werden, wenn das
+// Flag "Zeilenende im Piece" in der Piecetable ausgewertet wird.
+void WW8PLCFx_Cp_FKP::SearchParaEnd( long nOldEndCp )
+{
+ if( !bComplex )
+ {
+ ASSERT( !this, "SearchParaEnd fuer Non-Complex File gerufen" );
+ return;
+ }
+ if( ePLCF != PAP )
+ {
+ ASSERT( !this, "SearchParaEnd fuer Non-PAP gerufen" );
+ return;
+ }
+ long nFkpLen; // Fkp-Eintrag
+ long nPcdStart, nPcdEnd; // Piece-Grenzen
+
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen ); // Fkp-Eintrag holen
+/* if( (LONG_MAX == nAttrStart) || (LONG_MAX == nAttrEnd) )
+ {
+ return;
+ }*/
+ eCutT eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd );
+ if( eC == CUT_NONE ) // neuer Eintrag ganz im akt. Piece
+ {
+ ASSERT( !this, "Nanu?" );
+ return; // und fertig
+ }
+ WW8PLCFpcd_Iter* pIter = pPcd->GetPLCFIter();
+ void* pData;
+ do{
+ (*pPcd)++; // naechstes Piece
+
+
+ if( GetPCDIdx() >= GetPCDIMax() )
+ {
+ nAttrStart = nAttrEnd = LONG_MAX; // kein Piece mehr vorhanden
+ return;
+ }
+
+
+ if( !pIter->Get( nPcdStart, nPcdEnd, pData ) ){ // Piece-Grenzen holen
+#ifdef DEBUG
+ WW8_PCD1* p = (WW8_PCD1*)pData;
+ p = p;
+#endif
+ nAttrStart = nAttrEnd = LONG_MAX; // kein Piece mehr vorhanden
+ return;
+ }
+#ifdef DEBUG
+ WW8_PCD1* p = (WW8_PCD1*)pData;
+ p = p;
+#endif
+
+ }while( SVBT8ToByte( ( (WW8_PCD*)pData )->aBits1 ) & 0x1 );
+ // bis NL in Piece
+
+ long nPos = rSBase.WW8Cp2Fc( nPcdStart);
+ if( !WW8PLCFx_Fc_FKP::SeekPos( nPos ) )
+ {
+// ASSERT( !this, " Can't seek to Piece Start" );
+// nAttrStart = nAttrEnd = LONG_MAX; // kein Piece mehr vorhanden
+ return;
+ }
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen ); // Fkp-Eintrag holen
+ eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd ); // wird in CPs gebraucht
+
+ nAttrStart = nOldEndCp; // Aufziehen ueber ganzen Absatz, unabhaengig
+ // davon, wieviel Pieces das sind
+}
+
+WW8PLCFx& WW8PLCFx_Cp_FKP::operator ++( int )
+{
+ WW8PLCFx_Fc_FKP::operator ++( 0 );
+ if( !bComplex
+ || !pPcd ) // !pPcd: Notbremse
+ return *this;
+
+ if( GetPCDIdx() >= GetPCDIMax() ) // End of PLCF
+ {
+ nAttrStart = nAttrEnd = LONG_MAX;
+ return *this;
+ }
+
+// ohoho
+ long nFkpLen; // Fkp-Eintrag
+ long nPcdStart, nPcdEnd, nPcdLen; // Piece-Grenzen
+ long nOldEndCp = nAttrEnd;
+
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen ); // Fkp-Eintrag holen
+ eCutT eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd );
+ bLineEnd = !( eC & CUT_END ) && ePLCF == PAP;
+ if( !( eC & CUT_START ) ){ // neuer Eintrag faengt im
+ // akt. Piece an
+#ifdef DEBUG
+ if( ePLCF == PAP )
+ ePLCF = PAP; // um hier einen Brechpunkt zu setzen
+ if( ePLCF == CHP )
+ ePLCF = CHP; // um hier einen Brechpunkt zu setzen
+#endif
+ return *this; // und fertig
+ }
+ // naechster Eintrag im naechsten Piece
+
+ if( ePLCF == PAP )
+ {
+ SearchParaEnd( nOldEndCp );
+ bLineEnd = TRUE;
+ return *this;
+ }
+
+ // naechstes Piece
+ bLineEnd = FALSE;
+ (*pPcd)++;
+ pPcd->GetNoSprms( nPcdStart, nPcdEnd, nPcdLen );
+ // Piece-Grenzen holen
+ if( !WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc( nPcdStart ) ) )
+ {
+ ASSERT( nPcdStart == LONG_MAX, "Chp-SeekPos ging schief" );
+ nAttrStart = nAttrEnd = LONG_MAX;
+ goto Ret;
+ }
+ // Fkp-Eintrag holen
+ WW8PLCFx_Fc_FKP::GetSprms( nAttrStart, nAttrEnd, nFkpLen );
+ eC = pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd );
+Ret:
+ return *this;
+}
+
+//-----------------------------------------
+//-----------------------------------------
+
+WW8PLCFx_SEPX::WW8PLCFx_SEPX( SvStream* pSt, SvStream* pTblSt, WW8Fib& rFib, WW8_CP nStartCp )
+: pStrm( pSt ), WW8PLCFx( rFib.nVersion, TRUE ), nArrMax( 256 ), nSprmSiz( 0 )
+{
+ pPLCF = rFib.lcbPlcfsed
+ ? new WW8PLCF( pTblSt, rFib.fcPlcfsed,
+ rFib.lcbPlcfsed,
+ 12, nStartCp )
+ : 0;
+
+ pSprms = new BYTE[nArrMax]; // maximale Laenge
+}
+
+WW8PLCFx_SEPX::~WW8PLCFx_SEPX()
+{
+ delete pPLCF;
+ delete pSprms;
+}
+
+ULONG WW8PLCFx_SEPX::GetIdx() const
+{
+ return pPLCF ? pPLCF->GetIdx() : 0;
+}
+
+void WW8PLCFx_SEPX::SetIdx( ULONG nIdx )
+{
+ if( pPLCF ) pPLCF->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_SEPX::SeekPos( WW8_CP nCpPos )
+{
+ return pPLCF ? pPLCF->SeekPos( nCpPos ) : 0;
+}
+
+WW8_CP WW8PLCFx_SEPX::Where()
+{
+ return pPLCF ? pPLCF->Where() : 0;
+}
+
+void WW8PLCFx_SEPX::GetSprms( WW8PLCFxDesc* p )
+{
+ if( !pPLCF ) return;
+
+ void* pData;
+
+ p->bRealLineEnd = FALSE;
+ if (!pPLCF->Get( p->nStartPos, p->nEndPos, pData ))
+ {
+ p->nStartPos = p->nEndPos = LONG_MAX; // PLCF fertig abgearbeitet
+ p->pMemPos = 0;
+ }
+ else
+ {
+ long nPo = SVBT32ToLong( (BYTE*)pData+2 );
+ if ( nPo == 0xffffffffL )
+ {
+ p->nStartPos = p->nEndPos = LONG_MAX; // Sepx empty
+ p->pMemPos = 0;
+ }
+ else
+ {
+ pStrm->Seek( nPo );
+ *pStrm >> nSprmSiz; // read len
+
+ if( nSprmSiz > nArrMax )
+ { // passt nicht
+ delete( pSprms );
+ nArrMax = nSprmSiz; // Hole mehr Speicher
+ pSprms = new BYTE[nArrMax];
+ }
+ pStrm->Read( pSprms, nSprmSiz ); // read Sprms
+
+ p->nSprmsLen = nSprmSiz;
+ p->pMemPos = pSprms; // return Position
+ }
+ }
+}
+
+
+WW8PLCFx& WW8PLCFx_SEPX::operator ++( int )
+{
+ if( pPLCF )
+ (*pPLCF)++;
+ return *this;
+}
+
+
+BYTE* WW8PLCFx_SEPX::HasSprm( USHORT nId ) const
+{
+ return pPLCF ? WW8FindSprm( nId, nSprmSiz, pSprms, GetVersion() )
+ : 0;
+}
+
+
+BYTE* WW8PLCFx_SEPX::HasSprm( USHORT nId, BYTE* pOtherSprms,
+ long nOtherSprmSiz ) const
+{
+ return pPLCF ? WW8FindSprm( nId, nOtherSprmSiz, pOtherSprms, GetVersion() )
+ : 0;
+}
+
+
+
+BOOL WW8PLCFx_SEPX::Find4Sprms(USHORT nId1, USHORT nId2, USHORT nId3, USHORT nId4,
+ BYTE*& p1, BYTE*& p2, BYTE*& p3, BYTE*& p4 ) const
+{
+ if( !pPLCF ) return 0;
+
+ BOOL bFound = FALSE;
+ p1 = 0;
+ p2 = 0;
+ p3 = 0;
+ p4 = 0;
+
+ BYTE* pSp = pSprms;
+ short i;
+ BYTE nDelta = ( 8 > GetVersion()) ? 0 : 1;
+ for( i=0; i+1+nDelta < nSprmSiz; )
+ {
+ // Sprm gefunden?
+ USHORT nAktId = WW8GetSprmId( GetVersion(), pSp );
+ BOOL bOk = TRUE;
+ if( nAktId == nId1 )
+ p1 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId1 );
+ else
+ if( nAktId == nId2 )
+ p2 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId2 );
+ else
+ if( nAktId == nId3 )
+ p3 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId3 );
+ else
+ if( nAktId == nId4 )
+ p4 = pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId4 );
+ else
+ bOk = FALSE;
+ bFound |= bOk;
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ short x = WW8GetSprmSizeBrutto( GetVersion(), pSp, &nAktId );
+ i += x;
+ pSp += x;
+ }
+ return bFound;
+}
+
+BYTE* WW8PLCFx_SEPX::HasSprm( USHORT nId, BYTE n2nd ) const
+{
+ if( !pPLCF ) return 0;
+
+ BYTE* pSp = pSprms;
+ short i;
+ BYTE nDelta = ( 8 > GetVersion()) ? 0 : 1;
+
+ for( i=0; i+1+nDelta < nSprmSiz; )
+ {
+ // Sprm gefunden?
+ USHORT nAktId = WW8GetSprmId( GetVersion(), pSp );
+ if( ( nAktId == nId )
+ && ( pSp[ 1 + nDelta ] == n2nd ) )
+ return pSp
+ + 1 + nDelta
+ + WW8SprmDataOfs( nId );
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ short x = WW8GetSprmSizeBrutto( GetVersion(), pSp, &nAktId );
+ i += x;
+ pSp += x;
+ }
+ return 0; // Sprm nicht gefunden
+}
+
+//-----------------------------------------
+//-----------------------------------------
+
+WW8PLCFx_SubDoc::WW8PLCFx_SubDoc( SvStream* pSt, BYTE nVersion,
+ WW8_CP nStartCp,
+ long nFcRef, long nLenRef,
+ long nFcTxt, long nLenTxt,
+ long nStruct )
+ : WW8PLCFx( nVersion, FALSE ), pRef( 0 ), pTxt( 0 )
+{
+ if( nLenRef && nLenTxt )
+ {
+ pRef = new WW8PLCF( pSt, nFcRef, nLenRef, nStruct, nStartCp );
+ pTxt = new WW8PLCF( pSt, nFcTxt, nLenTxt, 0, nStartCp );
+ }
+}
+
+WW8PLCFx_SubDoc::~WW8PLCFx_SubDoc()
+{
+ delete pRef;
+ delete pTxt;
+}
+
+ULONG WW8PLCFx_SubDoc::GetIdx() const
+{
+ if( pRef )
+ return ( pRef->GetIdx() << 16
+ | pTxt->GetIdx() ); // Wahrscheinlich pTxt... nicht noetig
+ return 0;
+}
+
+void WW8PLCFx_SubDoc::SetIdx( ULONG nIdx )
+{
+ if( pRef )
+ {
+ pRef->SetIdx( nIdx >> 16 );
+ pTxt->SetIdx( nIdx & 0xffff ); // Wahrscheinlich pTxt... nicht noetig
+ }
+}
+
+BOOL WW8PLCFx_SubDoc::SeekPos( WW8_CP nCpPos )
+{
+ return ( pRef ) ? pRef->SeekPos( nCpPos ) : FALSE;
+}
+
+WW8_CP WW8PLCFx_SubDoc::Where()
+{
+ return ( pRef ) ? pRef->Where() : LONG_MAX;
+}
+
+long WW8PLCFx_SubDoc::GetNoSprms( WW8_CP& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ long nSt, nE;
+ rEnd = LONG_MAX;
+
+ if ( !pRef )
+ {
+ rStart = LONG_MAX; // Es gibt keine Noten
+ rLen = 0;
+ return -1;
+ }
+
+ ULONG nNr = pRef->GetIdx();
+
+ if (!pRef->Get( rStart, nE, pData ))
+ {
+ rStart = LONG_MAX; // PLCF fertig abgearbeitet
+ rLen = 0;
+ return -1;
+ }
+ pTxt->SetIdx( nNr );
+
+ if(!pTxt->Get( nSt, rLen, pData ))
+ {
+ rStart = LONG_MAX; // PLCF fertig abgearbeitet
+ rLen = 0;
+ return -1;
+ }
+
+ rLen -= nSt;
+ return nSt;
+}
+
+WW8PLCFx& WW8PLCFx_SubDoc::operator ++( int )
+{
+ if( pRef && pTxt )
+ {
+ (*pRef)++;
+ (*pTxt)++;
+ }
+ return *this;
+}
+
+
+//-----------------------------------------
+// Felder
+//-----------------------------------------
+
+WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, WW8Fib& rMyFib,
+ short nType, WW8_CP nStartCp )
+ : WW8PLCFx( rMyFib.nVersion, FALSE ), rFib( rMyFib ), pPLCF( 0 )
+{
+
+ long nFc, nLen;
+
+ switch( nType )
+ {
+ case MAN_HDFT: nFc = rFib.fcPlcffldHdr;
+ nLen = rFib.lcbPlcffldHdr;
+ break;
+ case MAN_FTN: nFc = rFib.fcPlcffldFtn;
+ nLen = rFib.lcbPlcffldFtn;
+ break;
+ case MAN_EDN: nFc = rFib.fcPlcffldEdn;
+ nLen = rFib.lcbPlcffldEdn;
+ break;
+ case MAN_AND: nFc = rFib.fcPlcffldAtn;
+ nLen = rFib.lcbPlcffldAtn;
+ break;
+ case MAN_TXBX: nFc = rFib.fcPlcffldTxbx;
+ nLen = rFib.lcbPlcffldTxbx;
+ break;
+ case MAN_TXBX_HDFT:
+ nFc = rFib.fcPlcffldHdrTxbx;
+ nLen = rFib.lcbPlcffldHdrTxbx;
+ break;
+ default: nFc = rFib.fcPlcffldMom;
+ nLen = rFib.lcbPlcffldMom;
+ break;
+ }
+
+ if( nLen )
+ pPLCF = new WW8PLCFspecial( pSt, nFc, nLen, 2 );
+}
+
+WW8PLCFx_FLD::~WW8PLCFx_FLD()
+{
+ delete pPLCF;
+}
+
+ULONG WW8PLCFx_FLD::GetIdx() const
+{
+ return ( pPLCF ) ? pPLCF->GetIdx() : 0;
+}
+
+void WW8PLCFx_FLD::SetIdx( ULONG nIdx )
+{
+ if( pPLCF )
+ pPLCF->SetIdx( nIdx );
+}
+
+BOOL WW8PLCFx_FLD::SeekPos( WW8_CP nCpPos )
+{
+ return ( pPLCF ) ? pPLCF->SeekPosExact( nCpPos ) : FALSE;
+}
+
+WW8_CP WW8PLCFx_FLD::Where()
+{
+ return ( pPLCF ) ? pPLCF->Where() : LONG_MAX;
+}
+
+long WW8PLCFx_FLD::GetNoSprms( WW8_CP& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ ULONG nIdx;
+
+ rLen = 0;
+ rEnd = LONG_MAX; // Es gibt keine Ende
+
+ if ( !pPLCF ){
+ rStart = LONG_MAX; // Es gibt keine Felder
+ return -1;
+ }
+
+ if (!pPLCF->Get( rStart, pData )){
+ rStart = LONG_MAX; // PLCF fertig abgearbeitet
+ return -1;
+ }
+
+ nIdx = pPLCF->GetIdx();
+
+ return (long)nIdx;
+}
+
+WW8PLCFx& WW8PLCFx_FLD::operator ++( int )
+{
+ WW8SkipField( *pPLCF ); // gehe zum naechsten Feld
+ return *this;
+}
+
+BOOL WW8PLCFx_FLD::GetPara( long nIdx, WW8FieldDesc& rF )
+{
+ ASSERT( pPLCF, "Aufruf ohne Feld PLCFspecial" );
+ if( !pPLCF )
+ return FALSE;
+
+ ULONG n = pPLCF->GetIdx();
+ pPLCF->SetIdx( (ULONG)nIdx );
+
+ BOOL bOk = WW8GetFieldPara( rFib.nVersion, *pPLCF, rF );
+ pPLCF->SetIdx( n );
+ return bOk;
+}
+
+//-----------------------------------------
+// class WW8PLCF_Book
+//-----------------------------------------
+
+/* to be optimized like this: */
+void WW8ReadSTTBF( BOOL bVer8, SvStream& rStrm,
+ UINT32 nStart, INT32 nLen, USHORT nSkip,
+ rtl_TextEncoding eCS,
+ SvStrings &rArray, SvStrings* pExtraArray )
+{
+ ULONG nOldPos = rStrm.Tell();
+ rStrm.Seek( nStart );
+
+ String* pWork;
+
+ UINT16 nLen2;
+ rStrm >> nLen2; // bVer67: total length of structure
+ // bVer8 : count of strings
+
+ if( bVer8 )
+ {
+ UINT16 nStrings;
+ BOOL bUnicode = (0xFFFF == nLen2);
+ if( bUnicode )
+ rStrm >> nStrings;
+ else
+ nStrings = nLen2;
+
+ UINT16 nExtraLen;
+ rStrm >> nExtraLen;
+
+ for( USHORT i=0; i < nStrings; i++ )
+ {
+ if( bUnicode )
+ pWork = new String( WW8Read_xstz( rStrm, 0, FALSE ));
+ else
+ {
+ BYTE nBChar;
+ rStrm >> nBChar;
+ ByteString aTmp;
+ BYTE nWasRead = rStrm.Read( aTmp.AllocBuffer( nBChar ), nBChar );
+ if( nWasRead != nBChar )
+ aTmp.ReleaseBufferAccess( nWasRead );
+ pWork = new String( aTmp, eCS );
+ }
+
+ rArray.Insert( pWork, rArray.Count() );
+
+ // Skip the extra data
+ if( nExtraLen )
+ {
+ if( pExtraArray )
+ {
+ ByteString aTmp;
+ BYTE nWasRead = rStrm.Read( aTmp.AllocBuffer( nExtraLen ), nExtraLen );
+ if( nWasRead != nExtraLen )
+ aTmp.ReleaseBufferAccess( nWasRead );
+ pWork = new String( aTmp, eCS );
+ pExtraArray->Insert( pWork, pExtraArray->Count() );
+ }
+ else
+ rStrm.SeekRel( nExtraLen );
+ }
+ }
+ }
+ else
+ {
+ BYTE nBChar;
+ if( nLen2 != nLen )
+ {
+ ASSERT( nLen2 == nLen, "Fib lenght and read length are different" );
+ nLen2 = nLen;
+ }
+ UINT16 nRead = 0;
+ for( nLen2 -= 2; nRead < nLen2; )
+ {
+ rStrm >> nBChar; ++nRead;
+ if( nBChar )
+ {
+ ByteString aTmp;
+ BYTE nWasRead = rStrm.Read( aTmp.AllocBuffer( nBChar ), nBChar );
+ if( nWasRead != nBChar )
+ aTmp.ReleaseBufferAccess( nWasRead );
+ pWork = new String( aTmp, eCS );
+ nRead += nWasRead;
+ }
+ else
+ pWork = new String;
+ rArray.Insert( pWork, rArray.Count() );
+ }
+ }
+ rStrm.Seek( nOldPos );
+}
+
+
+WW8PLCFx_Book::WW8PLCFx_Book( SvStream* pSt, SvStream* pTblSt, WW8Fib& rFib, WW8_CP nStartCp )
+: WW8PLCFx( rFib.nVersion, FALSE ), nIsEnd( 0 ), pStatus( 0 )
+{
+ if( !rFib.fcPlcfbkf || !rFib.lcbPlcfbkf
+ || !rFib.fcPlcfbkl || !rFib.lcbPlcfbkl
+ || !rFib.fcSttbfbkmk || !rFib.lcbSttbfbkmk )
+ {
+ pBook[0] = pBook[1] = 0;
+ nIMax = 0;
+ }
+ else
+ {
+ pBook[0] = new WW8PLCFspecial( pTblSt, rFib.fcPlcfbkf,
+ rFib.lcbPlcfbkf, 4 );
+
+ pBook[1] = new WW8PLCFspecial( pTblSt, rFib.fcPlcfbkl,
+ rFib.lcbPlcfbkl, 0, -1, TRUE );
+
+ rtl_TextEncoding eStructCharSet = 0x0100 == rFib.chseTables
+ ? RTL_TEXTENCODING_APPLE_ROMAN
+ : rtl_getTextEncodingFromWindowsCharset(
+ rFib.chseTables );
+
+ WW8ReadSTTBF( (7 < rFib.nVersion), *pTblSt,
+ rFib.fcSttbfbkmk, rFib.lcbSttbfbkmk, 0,
+ eStructCharSet, aBookNames );
+ nIMax = aBookNames.Count();
+
+ if( pBook[0]->GetIMax() < nIMax ) // Anzahl der Bookmarks
+ nIMax = pBook[0]->GetIMax();
+ if( pBook[1]->GetIMax() < nIMax )
+ nIMax = pBook[1]->GetIMax();
+ pStatus = new eBookStatus[ nIMax ];
+ memset( pStatus, 0, nIMax * sizeof( eBookStatus ) );
+ }
+}
+
+WW8PLCFx_Book::~WW8PLCFx_Book()
+{
+ delete[] ( pStatus );
+ aBookNames.DeleteAndDestroy( 0, aBookNames.Count());
+ delete( pBook[1] );
+ delete( pBook[0] );
+}
+
+ULONG WW8PLCFx_Book::GetIdx() const
+{
+ return nIMax ? pBook[0]->GetIdx() : 0;
+}
+
+void WW8PLCFx_Book::SetIdx( ULONG nI )
+{
+ if( nIMax )
+ pBook[0]->SetIdx( nI );
+}
+
+ULONG WW8PLCFx_Book::GetIdx2() const
+{
+ return ( nIMax )
+ ? ( pBook[1]->GetIdx() | ( ( nIsEnd ) ? 0x80000000 : 0 ) )
+ : 0;
+}
+
+void WW8PLCFx_Book::SetIdx2( ULONG nI )
+{
+ if( nIMax )
+ {
+ pBook[1]->SetIdx( nI & 0x7fffffff );
+ nIsEnd = (USHORT)( ( nI >> 31 ) & 1 ); // 0 oder 1
+ }
+}
+
+BOOL WW8PLCFx_Book::SeekPos( WW8_CP nCpPos )
+{
+ if( !pBook[0] )
+ return FALSE;
+ BOOL bOk = pBook[0]->SeekPosExact( nCpPos );
+ bOk &= pBook[1]->SeekPosExact( nCpPos );
+ nIsEnd = 0;
+
+ return bOk;
+}
+
+WW8_CP WW8PLCFx_Book::Where()
+{
+ return pBook[nIsEnd]->Where();
+}
+
+long WW8PLCFx_Book::GetNoSprms( long& rStart, long& rEnd, long& rLen )
+{
+ void* pData;
+ rEnd = LONG_MAX;
+ rLen = 0;
+
+ if ( !pBook[0] || !pBook[1] || !nIMax
+ || (long)(pBook[nIsEnd]->GetIdx()) >= nIMax ){
+ rStart = rEnd = LONG_MAX;
+ return -1;
+ }
+
+ pBook[nIsEnd]->Get( rStart, pData ); // Pos. abfragen
+
+ return pBook[nIsEnd]->GetIdx();
+}
+
+// Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
+// sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
+// Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
+// erst der Anfang und dann das Ende gefunden werden.
+// Der Fall: ][
+// [...]
+// ][
+// ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
+// vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
+// oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
+// noetig wird.
+WW8PLCFx& WW8PLCFx_Book::operator ++( int )
+{
+ if( pBook[0] && pBook[1] && nIMax )
+ {
+ (*pBook[nIsEnd])++;
+
+ register ULONG l0 = pBook[0]->Where();
+ register ULONG l1 = pBook[1]->Where();
+ if( l0 < l1 )
+ nIsEnd = 0;
+ else if( l1 < l0 )
+ nIsEnd = 1;
+ else
+ nIsEnd = ( nIsEnd ) ? 0 : 1;
+
+// nIsEnd = ( pBook[1]->Where() <= pBook[0]->Where() ) ? 1 : 0;
+ }
+ return *this;
+}
+
+long WW8PLCFx_Book::GetLen() const
+{
+ if( nIsEnd ){
+ ASSERT( !this, "Falscher Aufruf (1) von PLCF_Book::GetLen()" );
+ return 0;
+ }
+ void * p;
+ WW8_CP nStartPos;
+ if( !pBook[0]->Get( nStartPos, p ) ){
+ ASSERT( !this, "Falscher Aufruf (2) von PLCF_Book::GetLen()" );
+ return 0;
+ }
+ USHORT nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
+// USHORT nEndIdx = *(USHORT*)p;
+ return pBook[1]->GetPos( nEndIdx ) - nStartPos;
+}
+
+// IgnoreBook ist dafuer da, bei Feldern mit implizitem WW-Bookmark
+// die Bookmarks zwischen Anfang und Ende des Feldes zu ignorieren,
+// die den angegebenen Namen tragen.
+BOOL WW8PLCFx_Book::SetStatus( WW8_CP nStartRegion, WW8_CP nEndRegion,
+ const String& rName,
+ eBookStatus eStat )
+{
+ ASSERT( nStartRegion < LONG_MAX && nEndRegion < LONG_MAX,
+ "IgnoreBook mit falschen Parametern" );
+
+ if( !pBook[0] || !pBook[1] )
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ long i = 0;
+ WW8_CP nStartAkt, nEndAkt;
+ do{
+ void* p;
+ USHORT nEndIdx;
+
+ if( pBook[0]->GetData( i, nStartAkt, p ) && p ){
+ nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
+ }
+ else
+ {
+ ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
+ nEndIdx = (USHORT)i;
+ }
+ nEndAkt = pBook[1]->GetPos( nEndIdx );
+ if( (nStartAkt >= nStartRegion)
+ && (nEndAkt <= nEndRegion)
+ && (rName.Equals( *aBookNames[ i ] )) )
+ {
+ pStatus[nEndIdx] = (eBookStatus)( pStatus[nEndIdx] | eStat );
+ bFound = TRUE;
+ }
+ i++;
+ }
+ while( nStartAkt <= nEndRegion && i < pBook[0]->GetIMax() );
+ return bFound;
+}
+
+eBookStatus WW8PLCFx_Book::GetStatus() const
+{
+ if( !pStatus )
+ return BOOK_NORMAL;
+ long nEndIdx = GetHandle();
+ return ( nEndIdx < nIMax ) ? pStatus[nEndIdx] : BOOK_NORMAL;
+}
+
+long WW8PLCFx_Book::GetHandle() const
+{
+ if( !pBook[0] || !pBook[1] )
+ return LONG_MAX;
+
+ if( nIsEnd ){
+ return pBook[1]->GetIdx();
+ }else{
+// BOOL Get( long& rStart, void*& rpValue );
+ const void* p = pBook[0]->GetData( pBook[0]->GetIdx() );
+ if( p )
+ {
+ return SVBT16ToShort( *((SVBT16*)p) );
+// return *((USHORT*)p);
+ }
+ else
+ return LONG_MAX;
+ }
+}
+
+//-----------------------------------------
+// WW8PLCFMan
+//-----------------------------------------
+
+#ifndef DUMP
+
+// Am Ende eines Absatzes reichen bei WW6 die Attribute bis hinter das <CR>.
+// Das wird fuer die Verwendung mit dem SW um 1 Zeichen zurueckgesetzt, wenn
+// dadurch kein AErger zu erwarten ist.
+void WW8PLCFMan::AdjustEnds( WW8PLCFxDesc& rDesc )
+{
+ if ( (&rDesc == pPap) && rDesc.bRealLineEnd )
+ {
+ if ( pPap->nEndPos != LONG_MAX ) // Para adjust
+ {
+ nLineEnd = pPap->nEndPos; // nLineEnd zeigt *hinter* das <CR>
+ pPap->nEndPos--; // Absatzende um 1 Zeichen verkuerzen
+
+ if( pChp->nEndPos == nLineEnd ) // gibt es bereits ein CharAttr-Ende,
+ // das auf das jetzige Absatzende zeigt ?
+ pChp->nEndPos--; // ... dann auch um 1 Zeichen verkuerzen
+
+ if( pSep->nEndPos == nLineEnd ) // gibt es bereits ein Sep-Ende,
+ // das auf das jetzige Absatzende zeigt ?
+ pSep->nEndPos--; // ... dann auch um 1 Zeichen verkuerzen
+ }
+ }
+ else
+ if( (&rDesc == pChp)
+ || (&rDesc == pSep) )
+ { // Char Adjust oder Sep Adjust
+ if( (rDesc.nEndPos == nLineEnd) // Wenn Ende Char-Attr == Absatzende ...
+ && (rDesc.nEndPos > rDesc.nStartPos) )
+ rDesc.nEndPos--; // ... dann um 1 Zeichen verkuerzen
+ }
+
+ if( rDesc.nStartPos > rDesc.nEndPos ){ // allgemeiner Plausibilitaetstest
+
+ //if( gfhdf
+
+ ASSERT( !this, "+Anfang und Ende des WW86-Attributes stehen ueber Kreuz" );
+ rDesc.nEndPos = rDesc.nStartPos;
+ }
+}
+
+void WW8PLCFMan::GetNewSprms( WW8PLCFxDesc& rDesc )
+{
+ rDesc.pPLCFx->GetSprms( &rDesc );
+
+ //if( rDesc.nStartPos <= rDesc.nEndPos
+
+ ASSERT((LONG_MAX == rDesc.nStartPos) || (rDesc.nStartPos <= rDesc.nEndPos),
+ "Attr-Anfang und -Ende ueber Kreuz" );
+
+ if( rDesc.nStartPos != LONG_MAX ) rDesc.nStartPos -= rDesc.nCpOfs;
+ if( rDesc.nEndPos != LONG_MAX ) rDesc.nEndPos -= rDesc.nCpOfs;
+
+ rDesc.bFirstSprm = TRUE;
+
+ AdjustEnds( rDesc );
+}
+
+void WW8PLCFMan::GetNewNoSprms( WW8PLCFxDesc& rDesc )
+{
+ rDesc.nCp2OrIdx =
+ rDesc.pPLCFx->GetNoSprms(rDesc.nStartPos, rDesc.nEndPos,
+ rDesc.nSprmsLen);
+
+ ASSERT((LONG_MAX == rDesc.nStartPos) || (rDesc.nStartPos <= rDesc.nEndPos),
+ "Attr-Anfang und -Ende ueber Kreuz" );
+
+ if( rDesc.nStartPos != LONG_MAX ) rDesc.nStartPos -= rDesc.nCpOfs;
+ if( rDesc.nEndPos != LONG_MAX ) rDesc.nEndPos -= rDesc.nCpOfs;
+ rDesc.bFirstSprm = TRUE;
+}
+
+static USHORT GetId( BYTE nVersion, WW8PLCFxDesc* p )
+{
+ USHORT nId;
+
+ if( p->nSprmsLen > 0 )
+ nId = WW8GetSprmId( nVersion, p->pMemPos );
+ else
+ nId = 0; // Id = 0 fuer leeres Attribut
+ return nId;
+}
+
+WW8PLCFMan::WW8PLCFMan( WW8ScannerBase* pBase, short nType, long nStartCp )
+{
+ pWwFib = pBase->pWw8Fib;
+ pNoAttrScan = &pBase->nNoAttrScan;
+
+ nLastWhereIdxCp = 0;
+ memset( aD, 0, sizeof( aD ) );
+ nLineEnd = LONG_MAX;
+ nManType = nType;
+ USHORT i;
+
+ if( MAN_MAINTEXT == nType )
+ {
+ // Suchreihenfolge der Attribute
+ nPLCF = MAN_ANZ_PLCF;
+ pFld = &aD[0];
+ pBkm = &aD[1];
+ pEdn = &aD[2];
+ pFtn = &aD[3];
+ pAnd = &aD[4];
+ pChp = &aD[5];
+ pPap = &aD[6];
+ pSep = &aD[7];
+ pPcd = ( pBase->pPLCFx_PCD ) ? &aD[8] : 0;
+ pPcdA = ( pBase->pPLCFx_PCDAttrs ) ? &aD[9] : 0;
+ pSep->pPLCFx = pBase->pSepPLCF;
+ pFtn->pPLCFx = pBase->pFtnPLCF;
+ pEdn->pPLCFx = pBase->pEdnPLCF;
+ pBkm->pPLCFx = pBase->pBook;
+ pAnd->pPLCFx = pBase->pAndPLCF;
+ }
+ else
+ {
+ // Suchreihenfolge der Attribute
+ nPLCF = 7;
+ pFld = &aD[0];
+ pBkm = ( pBase->pBook ) ? &aD[1] : 0;
+ pChp = &aD[2];
+ pPap = &aD[3];
+ pSep = &aD[4]; // Dummy
+ pPcd = ( pBase->pPLCFx_PCD ) ? &aD[5] : 0;
+ pPcdA= ( pBase->pPLCFx_PCDAttrs ) ? &aD[6] : 0;
+ pAnd = pFtn = pEdn = 0; // unbenutzt bei SpezText
+ }
+
+ pChp->pPLCFx = pBase->pChpPLCF;
+ pPap->pPLCFx = pBase->pPapPLCF;
+ if( pPcd )
+ pPcd->pPLCFx = pBase->pPLCFx_PCD;
+ if( pPcdA )
+ pPcdA->pPLCFx= pBase->pPLCFx_PCDAttrs;
+ if( pBkm )
+ pBkm->pPLCFx = pBase->pBook;
+
+ switch( nType ) // Feld-Initialisierung
+ {
+ case MAN_HDFT: pFld->pPLCFx = pBase->pFldHdFtPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn;
+ pFdoa = pBase->pHdFtFdoa;
+ pTxbx = pBase->pHdFtTxbx;
+ pTxbxBkd = pBase->pHdFtTxbxBkd;
+ break;
+ case MAN_FTN: pFld->pPLCFx = pBase->pFldFtnPLCF;
+ nCpO = pWwFib->ccpText;
+ pFdoa = pTxbx = pTxbxBkd = 0;
+ break;
+ case MAN_EDN: pFld->pPLCFx = pBase->pFldEdnPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpAtn;
+ pFdoa = pTxbx = pTxbxBkd = 0;
+ break;
+ case MAN_AND: pFld->pPLCFx = pBase->pFldAndPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr;
+ pFdoa = pTxbx = pTxbxBkd = 0;
+ break;
+
+
+ case MAN_TXBX: pFld->pPLCFx = pBase->pFldTxbxPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpMcr
+ + pWwFib->ccpAtn + pWwFib->ccpEdn;
+ pTxbx = pBase->pMainTxbx;
+ pTxbxBkd = pBase->pMainTxbxBkd;
+ pFdoa = 0;
+ break;
+ case MAN_TXBX_HDFT:
+ pFld->pPLCFx = pBase->pFldTxbxHdFtPLCF;
+ nCpO = pWwFib->ccpText + pWwFib->ccpFtn
+ + pWwFib->ccpHdr + pWwFib->ccpMcr
+ + pWwFib->ccpAtn + pWwFib->ccpEdn
+ + pWwFib->ccpTxbx;
+ pTxbx = pBase->pHdFtTxbx;
+ pTxbxBkd = pBase->pHdFtTxbxBkd;
+ pFdoa = 0;
+ break;
+
+
+ default: pFld->pPLCFx = pBase->pFldPLCF;
+ nCpO = 0;
+ pFdoa = pBase->pMainFdoa;
+ pTxbx = pBase->pMainTxbx;
+ pTxbxBkd = pBase->pMainTxbxBkd;
+ break;
+ }
+
+ if( nStartCp || nCpO )
+ SeekPos( nStartCp ); // PLCFe auf Text-StartPos einstellen
+
+ // initialisieren der Member-Vars Low-Level
+ GetChpPLCF()->ResetAttrStartEnd();
+ GetPapPLCF()->ResetAttrStartEnd();
+ for( i=0; i<nPLCF; i++)
+ {
+ register WW8PLCFxDesc* p = &aD[i];
+
+ p->nCpOfs = ( p == pChp || p == pPap || p == pBkm ) ? nCpO : 0;
+ p->nCp2OrIdx = 0;
+ p->bFirstSprm = FALSE;
+ p->pIdStk = 0;
+ p->nStartPos = p->nEndPos = LONG_MAX;
+ }
+
+ // initialisieren der Member-Vars High-Level
+ for( i=0; i<nPLCF; i++){
+ register WW8PLCFxDesc* p = &aD[i];
+
+ if( !p->pPLCFx )
+ continue;
+
+ if( p->pPLCFx->IsSprm() )
+ {
+ p->pIdStk = new UShortStk; // Vorsicht: nEndPos muss bereits
+ GetNewSprms( *p ); // bei allen PLCFen initialisiert sein
+ }
+ else
+ {
+ if( p->pPLCFx )
+ GetNewNoSprms( *p );
+ }
+ }
+}
+
+WW8PLCFMan::~WW8PLCFMan()
+{
+ for( USHORT i=0; i<nPLCF; i++)
+ delete aD[i].pIdStk;
+}
+
+// 0. welche Attr.-Klasse,
+// 1. ob ein Attr.-Start ist,
+// 2. CP, wo ist naechste Attr.-Aenderung
+short WW8PLCFMan::WhereIdx( BOOL* pbStart, long* pPos )
+{
+ BOOL bIgnore;
+ long next = LONG_MAX; // SuchReihenfolge:
+ short nextIdx = -1; // erst Enden finden ( CHP, PAP, ( SEP ) ),
+ BOOL bStart = TRUE; // dann Anfaenge finden ( ( SEP ), PAP, CHP )
+ short i;
+ register WW8PLCFxDesc* pD;
+ for( i=0; i<(short)nPLCF; i++)
+ {
+ pD = &aD[i];
+ if( ( pD->nEndPos < next )
+ && ( pD->nStartPos == LONG_MAX ) )
+ { // sonst ist Anfang = Ende
+ next = pD->nEndPos;
+ nextIdx = i;
+ bStart = FALSE;
+ }
+ }
+ for( i=(short)nPLCF-1; i>=0; i--)
+ {
+ bIgnore = FALSE;
+ pD = &aD[i];
+ if( pD->nStartPos < next )
+ {
+ // StartPos of Attribute is inside a range of CPs to be ignored?
+ if( pD->pMemPos
+ && pNoAttrScan
+ && *pNoAttrScan
+ && pD->nStartPos == nLastWhereIdxCp )
+ {
+ // Check if the EndPos of this Attribute is BEHIND the scope
+ // of CPs to be ignored: if so shift the StartPos accordingly!
+ ULONG nOldIdx = pD->pPLCFx->GetIdx();
+ pD->pPLCFx->SetIdx( nOldIdx+1 );
+
+ const long nNASEnd = pD->nStartPos + *pNoAttrScan;
+
+ if( nNASEnd < pD->pPLCFx->Where() )
+ {
+ pD->nStartPos = nNASEnd;
+ bIgnore = TRUE;
+ }
+
+ pD->pPLCFx->SetIdx( nOldIdx );
+ }
+
+ if( !bIgnore )
+ {
+ next = pD->nStartPos;
+ nextIdx = i;
+ bStart = TRUE;
+ }
+ }
+ }
+ if( pPos )
+ *pPos = next;
+ nLastWhereIdxCp = next;
+ if( pbStart )
+ *pbStart = bStart;
+ return nextIdx;
+}
+
+WW8_CP WW8PLCFMan::Where() // gibt die CP-Pos der naechsten Attribut-Aenderung zurueck
+{
+ long l;
+ WhereIdx( 0, &l );
+ return l;
+}
+
+
+void WW8PLCFMan::SeekPos( long nNewCp )
+{
+ pChp->pPLCFx->SeekPos( nNewCp + nCpO ); // Attribute neu
+ pPap->pPLCFx->SeekPos( nNewCp + nCpO ); // aufsetzen
+ pFld->pPLCFx->SeekPos( nNewCp );
+ if( pPcd )
+ pPcd->pPLCFx->SeekPos( nNewCp + nCpO );
+ if( pBkm )
+ pBkm->pPLCFx->SeekPos( nNewCp + nCpO );
+}
+
+
+void WW8PLCFx::Save( WW8PLCFxSave1& rSave ) const
+{
+ rSave.nPLCFxPos = GetIdx();
+ rSave.nPLCFxPos2 = GetIdx2();
+ rSave.nPLCFxMemOfs = 0;
+}
+
+void WW8PLCFx::Restore( const WW8PLCFxSave1& rSave )
+{
+ SetIdx( rSave.nPLCFxPos );
+ SetIdx2( rSave.nPLCFxPos2 );
+}
+
+
+
+ULONG WW8PLCFx_Cp_FKP::GetIdx2() const
+{
+ return GetPCDIdx();
+}
+
+void WW8PLCFx_Cp_FKP::SetIdx2( ULONG nIdx )
+{
+ SetPCDIdx( nIdx );
+}
+
+
+void WW8PLCFx_Cp_FKP::Save( WW8PLCFxSave1& rSave ) const
+{
+ WW8PLCFx::Save( rSave );
+
+ rSave.nAttrStart = nAttrStart;
+ rSave.nAttrEnd = nAttrEnd;
+ rSave.bLineEnd = bLineEnd;
+}
+
+void WW8PLCFx_Cp_FKP::Restore( const WW8PLCFxSave1& rSave )
+{
+ WW8PLCFx::Restore( rSave );
+
+ nAttrStart = rSave.nAttrStart;
+ nAttrEnd = rSave.nAttrEnd;
+ bLineEnd = rSave.bLineEnd;
+}
+
+
+void WW8PLCFxDesc::Save( WW8PLCFxSave1& rSave ) const
+{
+ if( pPLCFx )
+ {
+ pPLCFx->Save( rSave );
+ if( pPLCFx->IsSprm() )
+ {
+ WW8PLCFxDesc aD;
+ pPLCFx->GetSprms( &aD );
+ rSave.nPLCFxMemOfs = pMemPos - aD.pMemPos;
+ }
+ }
+}
+
+void WW8PLCFxDesc::Restore( const WW8PLCFxSave1& rSave )
+{
+ if( pPLCFx )
+ {
+ pPLCFx->Restore( rSave );
+ if( pPLCFx->IsSprm() )
+ {
+ WW8PLCFxDesc aD;
+ pPLCFx->GetSprms( &aD );
+ pMemPos = aD.pMemPos + rSave.nPLCFxMemOfs;
+ }
+ }
+}
+/*
+void WW8PLCFMan::Save1PLCFx( WW8PLCFxDesc* p, WW8PLCFxSave1* pSave ) const
+{
+ if( !p->pPLCFx )
+ return;
+ pSave->nPLCFxPos = p->pPLCFx->GetIdx();
+ pSave->nPLCFxPos2 = p->pPLCFx->GetIdx2();
+ if( p->pPLCFx->IsSprm() )
+ {
+ WW8PLCFxDesc aD;
+ p->pPLCFx->GetSprms( &aD );
+ pSave->nPLCFxMemOfs = p->pMemPos - aD.pMemPos;
+ }
+}
+
+void WW8PLCFMan::Restore1PLCFx( WW8PLCFxDesc* p, WW8PLCFxSave1* pSave )
+{
+ if( !p->pPLCFx )
+ return;
+ p->pPLCFx->SetIdx( pSave->nPLCFxPos ); // restore PLCF-Pos
+ p->pPLCFx->SetIdx2( pSave->nPLCFxPos2 );
+ if( p->pPLCFx->IsSprm() )
+ {
+ WW8PLCFxDesc aD;
+ p->pPLCFx->GetSprms( &aD );
+ p->pMemPos = aD.pMemPos + pSave->nPLCFxMemOfs;
+ }
+}
+*/
+void WW8PLCFMan::SaveAllPLCFx( WW8PLCFxSaveAll& rSave ) const
+{
+ USHORT i, n=0;
+ if( pPcd )
+ pPcd->Save( rSave.aS[n++] );
+ if( pPcdA )
+ pPcdA->Save( rSave.aS[n++] );
+
+ for(i=0; i<nPLCF; ++i)
+ if( pPcd != &aD[i] && pPcdA != &aD[i] )
+ aD[i].Save( rSave.aS[n++] );
+}
+
+void WW8PLCFMan::RestoreAllPLCFx( const WW8PLCFxSaveAll& rSave )
+{
+ USHORT i, n=0;
+ if( pPcd )
+ pPcd->Restore( rSave.aS[n++] );
+ if( pPcdA )
+ pPcdA->Restore( rSave.aS[n++] );
+
+ for(i=0; i<nPLCF; ++i)
+ if( pPcd != &aD[i] && pPcdA != &aD[i] )
+ aD[i].Restore( rSave.aS[n++] );
+}
+
+void WW8PLCFMan::GetSprmStart( short nIdx, WW8PLCFManResult* pRes )
+{
+ memset( pRes, 0, sizeof( WW8PLCFManResult ) );
+
+ // Pruefen !!!
+
+ pRes->nMemLen = 0;
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ if( !*pNoAttrScan
+ || (*pNoAttrScan < (p->nEndPos - p->nStartPos + 1)) )
+ {
+ if( p->bFirstSprm ) // erster Sprm einer Gruppe
+ {
+ if( p == pPap ) // Anfang neuer Pap ?
+ pRes->nFlags |= MAN_MASK_NEW_PAP; // dann muss Aufrufer auf neuen
+ // Style testen
+ else if( p == pSep ) // Anfang neuer Sep ?
+ pRes->nFlags |= MAN_MASK_NEW_SEP; // dann muss Aufrufer eine neue
+ // Section / Pagedesc erzeugen
+ }
+ pRes->pMemPos = p->pMemPos;
+ pRes->nSprmId = GetId( pWwFib->nVersion, p );
+ if( p->nSprmsLen )
+ pRes->nMemLen = WW8GetSprmSizeBrutto( pWwFib->nVersion,
+ pRes->pMemPos,
+ &pRes->nSprmId ); // Laenge des akt. Sprm
+ }
+}
+
+void WW8PLCFMan::GetSprmEnd( short nIdx, WW8PLCFManResult* pRes )
+{
+ memset( pRes, 0, sizeof( WW8PLCFManResult ) );
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ if( !*pNoAttrScan
+ || (*pNoAttrScan < (p->nEndPos - p->nStartPos + 1)) )
+ {
+ if( p->pIdStk->Count() )
+ pRes->nSprmId = p->pIdStk->Top(); // hole Ende-Position
+ else
+ {
+ ASSERT( !this, "Keine Id auf dem Stack" );
+ pRes->nSprmId = 0;
+ }
+ }
+}
+
+void WW8PLCFMan::GetNoSprmStart( short nIdx, WW8PLCFManResult* pRes )
+{
+
+ // Pruefen !!!
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+// long nEnd;
+
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( pRes->nCpPos, nEnd, pRes->nMemLen );
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( p->nStartPos, p->nEndPos,
+// p->nSprmsLen );
+// GetNoSprms( nIdx );
+ pRes->nCpPos = p->nStartPos;
+ pRes->nMemLen = p->nSprmsLen;
+ pRes->nCp2OrIdx = p->nCp2OrIdx;
+
+ if( p == pFld )
+ pRes->nSprmId = 258;
+ else if( p == pFtn )
+ pRes->nSprmId = 256;
+ else if( p == pEdn )
+ pRes->nSprmId = 257;
+ else if( p == pBkm )
+ pRes->nSprmId = 259;
+ else if( p == pPcd )
+ pRes->nSprmId = 260;
+ else if( p == pAnd )
+ pRes->nSprmId = 261;
+ else
+ pRes->nSprmId = 0; // default: nicht gefunden
+}
+
+void WW8PLCFMan::GetNoSprmEnd( short nIdx, WW8PLCFManResult* pRes )
+{
+
+ // Pruefen !!!
+
+ if( &aD[nIdx] == pBkm )
+ pRes->nSprmId = 259;
+ else if( &aD[nIdx] == pPcd )
+ pRes->nSprmId = 260;
+ else
+ pRes->nSprmId = 0;
+
+ pRes->nMemLen = -1; // Ende-Kennzeichen
+}
+
+
+//
+void WW8PLCFMan::AdvSprm( short nIdx, BOOL bStart )
+{
+ register WW8PLCFxDesc* p = &aD[nIdx]; // Sprm-Klasse(!) ermitteln
+
+ p->bFirstSprm = FALSE;
+ if( bStart )
+ {
+ USHORT nLastId = GetId( pWwFib->nVersion, p );
+ p->pIdStk->Push( nLastId ); // merke Id fuer Attribut-Ende
+
+ if( p->nSprmsLen )
+ { /*
+ Pruefe, ob noch Sprm(s) abzuarbeiten sind
+ */
+ if( p->pMemPos )
+ {
+ // Laenge des letzten Sprm
+ short nSprmL = WW8GetSprmSizeBrutto( pWwFib->nVersion, p->pMemPos, &nLastId );
+
+ // Gesamtlaenge Sprms um SprmLaenge verringern
+ p->nSprmsLen -= nSprmL;
+
+ // Pos des evtl. naechsten Sprm
+ if( p->nSprmsLen <= 0 )
+ p->pMemPos = 0; // sicherheitshalber auf Null setzen, da Enden folgen!
+ else
+ p->pMemPos += nSprmL;
+ }
+ else
+ p->nSprmsLen = 0;
+ }
+ if( p->nSprmsLen <= 0 )
+ p->nStartPos = LONG_MAX; // es folgen Enden
+ }
+ else
+ {
+ if( p->pIdStk->Count() )
+ p->pIdStk->Pop();
+ if( !p->pIdStk->Count() )
+ { // Kein weiterer Sprm auf dieser Pos ?
+ (*p->pPLCFx)++; // naechste Gruppe von Sprms
+ p->pMemPos = 0; // !!!
+ GetNewSprms( *p );
+ ASSERT( p->nStartPos <= p->nEndPos, "Attribut ueber Kreuz" );
+ }
+ }
+}
+
+void WW8PLCFMan::AdvNoSprm( short nIdx, BOOL bStart )
+{
+
+ // Pruefen !!!
+
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ if( p == pPcd ){ // NoSprm mit Ende
+ if( bStart ){
+ p->nStartPos = LONG_MAX;
+ }else{ // naechster NoSprm mit Ende
+ (*p->pPLCFx)++;
+ p->pMemPos = 0; // MemPos ungueltig
+ GetNewNoSprms( *p );
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( p->nStartPos, p->nEndPos,
+// p->nSprmsLen );
+ }
+ }else{ // NoSprm ohne Ende
+ (*p->pPLCFx)++;
+ p->pMemPos = 0; // MemPos ungueltig
+ GetNewNoSprms( *p );
+// p->nCp2OrIdx = p->pPLCFx->GetNoSprms( p->nStartPos, p->nEndPos,
+// p->nSprmsLen );
+ }
+}
+
+WW8PLCFMan& WW8PLCFMan::operator ++(int)
+{
+ BOOL bStart;
+ short nIdx = WhereIdx( &bStart, 0 );
+ if( nPLCF > nIdx )
+ {
+ register WW8PLCFxDesc* p = &aD[nIdx];
+
+ p->bFirstSprm = TRUE; // Default
+
+ if( p->pPLCFx->IsSprm() )
+ AdvSprm( nIdx, bStart );
+ else // NoSprm
+ AdvNoSprm( nIdx, bStart );
+ }
+ return *this;
+}
+
+// Rueckgabe TRUE fuer Anfang eines Attributes oder Fehler,
+// FALSE fuer Ende d. Attr
+// Restliche Rueckgabewerte werden in der vom Aufrufer zu stellenden Struktur
+// WW8PclxManResults geliefert.
+BOOL WW8PLCFMan::Get( WW8PLCFManResult* pRes )
+{
+ memset( pRes, 0, sizeof( WW8PLCFManResult ) );
+ BOOL bStart;
+ short nIdx = WhereIdx( &bStart, 0 );
+
+ if( nIdx < 0 ){
+ ASSERT( !this, "Position nicht gefunden" );
+ return TRUE;
+ }
+
+ if( aD[nIdx].pPLCFx->IsSprm() )
+ {
+ if( bStart )
+ {
+ GetSprmStart( nIdx, pRes );
+ return TRUE;
+ }
+ else
+ {
+ GetSprmEnd( nIdx, pRes );
+ return FALSE;
+ }
+ }else{
+/*
+ if( &aD[nIdx] == pPcd ){ // Piece-Ende
+ pRes->nId = -4;
+ pRes->nMemLen = ( bStart ) ? 0 : -1;
+ return bStart;
+ }else
+*/
+ if( bStart ){
+ GetNoSprmStart( nIdx, pRes );
+ return TRUE;
+ }else{
+ GetNoSprmEnd( nIdx, pRes );
+ return FALSE;
+ }
+ }
+}
+
+USHORT WW8PLCFMan::GetColl() const
+{
+ if( pPap->pPLCFx ){
+ return pPap->pPLCFx->GetIstd();
+ }else{
+ ASSERT( !this, "GetColl ohne PLCF_Pap" );
+ return 0;
+ }
+}
+
+WW8PLCFx_FLD* WW8PLCFMan::GetFld() const
+{
+ return (WW8PLCFx_FLD*)pFld->pPLCFx;
+}
+
+BYTE* WW8PLCFMan::HasParaSprm( USHORT nId ) const
+{
+ return ((WW8PLCFx_Cp_FKP*)pPap->pPLCFx)->HasSprm( nId );
+}
+
+BYTE* WW8PLCFMan::HasCharSprm( USHORT nId ) const
+{
+ return ((WW8PLCFx_Cp_FKP*)pChp->pPLCFx)->HasSprm( nId );
+}
+
+#endif // !DUMP
+
+//-----------------------------------------
+
+
+WW8Fib::WW8Fib( SvStream& rSt, BYTE nWantedVersion,UINT32 nOffset ): nFibError( 0 )
+{
+ BYTE aBits1;
+ BYTE aBits2;
+ BYTE aVer8Bits1; // nur ab WinWord 8 benutzt
+ rSt.Seek( nOffset );
+ /*
+ Wunsch-Nr vermerken, File-Versionsnummer ermitteln
+ und gegen Wunsch-Nr. checken !
+ */
+ nVersion = nWantedVersion;
+ rSt >> wIdent;
+ rSt >> nFib;
+ rSt >> nProduct;
+ if( 0 != rSt.GetError() )
+ {
+ INT16 nFibMin;
+ INT16 nFibMax;
+ switch( nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6: nFibMin = 0x0065; // von 101 WinWord 6.0
+ // 102 "
+ // und 103 WinWord 6.0 fuer Macintosh
+ // 104 "
+ nFibMax = 0x0069; // bis 105 WinWord 95
+ break;
+ case 7: nFibMin = 0x0069; // von 105 WinWord 95
+ nFibMax = 0x0069; // bis 105 WinWord 95
+ break;
+ case 8: nFibMin = 0x006A; // von 106 WinWord 97
+ nFibMax = 0x00c1; // bis 193 WinWord 97 (?)
+ break;
+ default:nFibMin = 0; // Programm-Fehler!
+ nFibMax = 0;
+ nFib = 1;
+ ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+ if( ( nFib < nFibMin )
+ || ( nFib > nFibMax ) )
+ {
+ nFibError = ERR_SWG_READ_ERROR; // Error melden
+ return; // und hopp raus!
+ }
+ }
+
+ // praktische Hilfsvariablen:
+ BOOL bVer67 = ((6 == nVersion) || (7 == nVersion));
+ BOOL bVer8 = (8 == nVersion);
+
+ // Hilfs-Varis fuer Ver67:
+ INT16 pnChpFirst_Ver67;
+ INT16 pnPapFirst_Ver67;
+ INT16 cpnBteChp_Ver67;
+ INT16 cpnBtePap_Ver67;
+
+ // und auf gehts: FIB einlesen
+ rSt >> lid;
+ rSt >> pnNext;
+ rSt >> aBits1;
+ rSt >> aBits2;
+ rSt >> nFibBack;
+ rSt >> lKey1;
+ rSt >> lKey2;
+ rSt >> envr;
+ rSt >> aVer8Bits1; // unter Ver67 nur leeres Reservefeld
+ // Inhalt von aVer8Bits1
+ //
+ // BYTE fMac :1;
+ // BYTE fEmptySpecial :1;
+ // BYTE fLoadOverridePage :1;
+ // BYTE fFuturesavedUndo :1;
+ // BYTE fWord97Saved :1;
+ // BYTE :3;
+ rSt >> chse;
+ rSt >> chseTables;
+ rSt >> fcMin;
+ rSt >> fcMac;
+
+// Einschub fuer WW8 *****************************************************
+ if( !bVer67 )
+ {
+ rSt >> csw;
+
+ // Marke: "rgsw" Beginning of the array of shorts
+ rSt >> wMagicCreated;
+ rSt >> wMagicRevised;
+ rSt >> wMagicCreatedPrivate;
+ rSt >> wMagicRevisedPrivate;
+ rSt.SeekRel( 9 * sizeof( INT16 ) );
+
+ /*
+ // dies sind die 9 unused Felder:
+ && (bVer67 || WW8ReadINT16( rSt, pnFbpChpFirst_W6 )) // 1
+ && (bVer67 || WW8ReadINT16( rSt, pnChpFirst_W6 )) // 2
+ && (bVer67 || WW8ReadINT16( rSt, cpnBteChp_W6 )) // 3
+ && (bVer67 || WW8ReadINT16( rSt, pnFbpPapFirst_W6 )) // 4
+ && (bVer67 || WW8ReadINT16( rSt, pnPapFirst_W6 )) // 5
+ && (bVer67 || WW8ReadINT16( rSt, cpnBtePap_W6 )) // 6
+ && (bVer67 || WW8ReadINT16( rSt, pnFbpLvcFirst_W6 )) // 7
+ && (bVer67 || WW8ReadINT16( rSt, pnLvcFirst_W6 )) // 8
+ && (bVer67 || WW8ReadINT16( rSt, cpnBteLvc_W6 )) // 9
+ */
+ rSt >> lidFE;
+ rSt >> clw;
+ }
+
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rglw" Beginning of the array of longs
+ rSt >> cbMac;
+
+ // 2 Longs uebergehen, da unwichtiger Quatsch
+ rSt.SeekRel( 2 * sizeof( INT32) );
+
+ // weitere 2 Longs nur bei Ver67 ueberspringen
+ if( bVer67 )
+ rSt.SeekRel( 2 * sizeof( INT32) );
+
+ rSt >> ccpText;
+ rSt >> ccpFtn;
+ rSt >> ccpHdr;
+ rSt >> ccpMcr;
+ rSt >> ccpAtn;
+ rSt >> ccpEdn;
+ rSt >> ccpTxbx;
+ rSt >> ccpHdrTxbx;
+
+ // weiteres Long nur bei Ver67 ueberspringen
+ if( bVer67 )
+ rSt.SeekRel( 1 * sizeof( INT32) );
+ else
+ {
+// Einschub fuer WW8 *****************************************************
+ rSt >> pnFbpChpFirst;
+ rSt >> pnChpFirst;
+ rSt >> cpnBteChp;
+ rSt >> pnFbpPapFirst;
+ rSt >> pnPapFirst;
+ rSt >> cpnBtePap;
+ rSt >> pnFbpLvcFirst;
+ rSt >> pnLvcFirst;
+ rSt >> cpnBteLvc;
+ rSt >> fcIslandFirst;
+ rSt >> fcIslandLim;
+ rSt >> cfclcb;
+ }
+
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
+ rSt >> fcStshfOrig;
+ rSt >> lcbStshfOrig;
+ rSt >> fcStshf;
+ rSt >> lcbStshf;
+ rSt >> fcPlcffndRef;
+ rSt >> lcbPlcffndRef;
+ rSt >> fcPlcffndTxt;
+ rSt >> lcbPlcffndTxt;
+ rSt >> fcPlcfandRef;
+ rSt >> lcbPlcfandRef;
+ rSt >> fcPlcfandTxt;
+ rSt >> lcbPlcfandTxt;
+ rSt >> fcPlcfsed;
+ rSt >> lcbPlcfsed;
+ rSt >> fcPlcfpad;
+ rSt >> lcbPlcfpad;
+ rSt >> fcPlcfphe;
+ rSt >> lcbPlcfphe;
+ rSt >> fcSttbfglsy;
+ rSt >> lcbSttbfglsy;
+ rSt >> fcPlcfglsy;
+ rSt >> lcbPlcfglsy;
+ rSt >> fcPlcfhdd;
+ rSt >> lcbPlcfhdd;
+ rSt >> fcPlcfbteChpx;
+ rSt >> lcbPlcfbteChpx;
+ rSt >> fcPlcfbtePapx;
+ rSt >> lcbPlcfbtePapx;
+ rSt >> fcPlcfsea;
+ rSt >> lcbPlcfsea;
+ rSt >> fcSttbfffn;
+ rSt >> lcbSttbfffn;
+ rSt >> fcPlcffldMom;
+ rSt >> lcbPlcffldMom;
+ rSt >> fcPlcffldHdr;
+ rSt >> lcbPlcffldHdr;
+ rSt >> fcPlcffldFtn;
+ rSt >> lcbPlcffldFtn;
+ rSt >> fcPlcffldAtn;
+ rSt >> lcbPlcffldAtn;
+ rSt >> fcPlcffldMcr;
+ rSt >> lcbPlcffldMcr;
+ rSt >> fcSttbfbkmk;
+ rSt >> lcbSttbfbkmk;
+ rSt >> fcPlcfbkf;
+ rSt >> lcbPlcfbkf;
+ rSt >> fcPlcfbkl;
+ rSt >> lcbPlcfbkl;
+ rSt >> fcCmds;
+ rSt >> lcbCmds;
+ rSt >> fcPlcfmcr;
+ rSt >> lcbPlcfmcr;
+ rSt >> fcSttbfmcr;
+ rSt >> lcbSttbfmcr;
+ rSt >> fcPrDrvr;
+ rSt >> lcbPrDrvr;
+ rSt >> fcPrEnvPort;
+ rSt >> lcbPrEnvPort;
+ rSt >> fcPrEnvLand;
+ rSt >> lcbPrEnvLand;
+ rSt >> fcWss;
+ rSt >> lcbWss;
+ rSt >> fcDop;
+ rSt >> lcbDop;
+ rSt >> fcSttbfAssoc;
+ rSt >> cbSttbfAssoc;
+ rSt >> fcClx;
+ rSt >> lcbClx;
+ rSt >> fcPlcfpgdFtn;
+ rSt >> lcbPlcfpgdFtn;
+ rSt >> fcAutosaveSource;
+ rSt >> lcbAutosaveSource;
+ rSt >> fcGrpStAtnOwners;
+ rSt >> lcbGrpStAtnOwners;
+ rSt >> fcSttbfAtnbkmk;
+ rSt >> lcbSttbfAtnbkmk;
+
+ // weiteres short nur bei Ver67 ueberspringen
+ if( bVer67 )
+ {
+ rSt.SeekRel( 1*sizeof( INT16) );
+
+ // folgende 4 Shorts existieren nur bei Ver67;
+ rSt >> pnChpFirst_Ver67;
+ rSt >> pnPapFirst_Ver67;
+ rSt >> cpnBteChp_Ver67;
+ rSt >> cpnBtePap_Ver67;
+ }
+
+ rSt >> fcPlcfdoaMom;
+ rSt >> lcbPlcfdoaMom;
+ rSt >> fcPlcfdoaHdr;
+ rSt >> lcbPlcfdoaHdr;
+ rSt >> fcPlcfspaMom;
+ rSt >> lcbPlcfspaMom;
+ rSt >> fcPlcfspaHdr;
+ rSt >> lcbPlcfspaHdr;
+
+ rSt >> fcPlcfAtnbkf;
+ rSt >> lcbPlcfAtnbkf;
+ rSt >> fcPlcfAtnbkl;
+ rSt >> lcbPlcfAtnbkl;
+ rSt >> fcPms;
+ rSt >> lcbPMS;
+ rSt >> fcFormFldSttbf;
+ rSt >> lcbFormFldSttbf;
+ rSt >> fcPlcfendRef;
+ rSt >> lcbPlcfendRef;
+ rSt >> fcPlcfendTxt;
+ rSt >> lcbPlcfendTxt;
+ rSt >> fcPlcffldEdn;
+ rSt >> lcbPlcffldEdn;
+ rSt >> fcPlcfpgdEdn;
+ rSt >> lcbPlcfpgdEdn;
+ rSt >> fcDggInfo;
+ rSt >> lcbDggInfo;
+ rSt >> fcSttbfRMark;
+ rSt >> lcbSttbfRMark;
+ rSt >> fcSttbfCaption;
+ rSt >> lcbSttbfCaption;
+ rSt >> fcSttbAutoCaption;
+ rSt >> lcbSttbAutoCaption;
+ rSt >> fcPlcfwkb;
+ rSt >> lcbPlcfwkb;
+ rSt >> fcPlcfspl;
+ rSt >> lcbPlcfspl;
+ rSt >> fcPlcftxbxTxt;
+ rSt >> lcbPlcftxbxTxt;
+ rSt >> fcPlcffldTxbx;
+ rSt >> lcbPlcffldTxbx;
+ rSt >> fcPlcfHdrtxbxTxt;
+ rSt >> lcbPlcfHdrtxbxTxt;
+ rSt >> fcPlcffldHdrTxbx;
+ rSt >> lcbPlcffldHdrTxbx;
+
+ if( 0 == rSt.GetError() )
+ {
+ // Bit-Flags setzen
+ fDot = aBits1 & 0x01 ;
+ fGlsy = ( aBits1 & 0x02 ) >> 1;
+ fComplex = ( aBits1 & 0x04 ) >> 2;
+ fHasPic = ( aBits1 & 0x08 ) >> 3;
+ cQuickSaves = ( aBits1 & 0xf0 ) >> 4;
+ fEncrypted = aBits2 & 0x01 ;
+ fWhichTblStm= ( aBits2 & 0x02 ) >> 1;
+ // dummy = ( aBits2 & 0x0e ) >> 1;
+ fExtChar = ( aBits2 & 0x10 ) >> 4;
+ // dummy = ( aBits2 & 0xe0 ) >> 5;
+
+ /*
+ ggfs. Ziel-Varaiblen, aus xxx_Ver67 fuellen
+ oder Flags setzen
+ */
+ if( bVer67 )
+ {
+ pnChpFirst = pnChpFirst_Ver67;
+ pnPapFirst = pnPapFirst_Ver67;
+ cpnBteChp = cpnBteChp_Ver67;
+ cpnBtePap = cpnBtePap_Ver67;
+ }
+ else if( bVer8 )
+ {
+ fMac = aVer8Bits1 & 0x01 ;
+ fEmptySpecial = ( aVer8Bits1 & 0x02 ) >> 1;
+ fLoadOverridePage = ( aVer8Bits1 & 0x04 ) >> 2;
+ fFuturesavedUndo = ( aVer8Bits1 & 0x08 ) >> 3;
+ fWord97Saved = ( aVer8Bits1 & 0x10 ) >> 4;
+
+ /*
+ speziell fuer WW8:
+ ermittle die Werte fuer PLCF LST und PLF LFO
+ und PLCF fuer TextBox-Break-Deskriptoren
+ */
+ long nOldPos = rSt.Tell();
+ rSt.Seek( 0x02e2 );
+ rSt >> fcPlcfLst;
+ rSt >> lcbPlcfLst;
+ rSt >> fcPlfLfo;
+ rSt >> lcbPlfLfo;
+ rSt >> fcPlcftxbxBkd;
+ rSt >> lcbPlcftxbxBkd;
+ rSt >> fcPlcfHdrtxbxBkd;
+ rSt >> lcbPlcfHdrtxbxBkd;
+ if( 0 != rSt.GetError() )
+ {
+ nFibError = ERR_SWG_READ_ERROR;
+ }
+
+ rSt.Seek( 0x372 ); // fcSttbListNames
+ rSt >> fcSttbListNames;
+ rSt >> lcbSttbListNames;
+ if( 0 != rSt.GetError() )
+ nFibError = ERR_SWG_READ_ERROR;
+
+ rSt.Seek( nOldPos );
+ }
+ }
+ else
+ {
+ nFibError = ERR_SWG_READ_ERROR; // Error melden
+ }
+}
+
+
+WW8Fib::WW8Fib( BYTE nVer )
+{
+ memset( this, 0, sizeof( *this ));
+ nVersion = nVer;
+ if( 8 == nVer )
+ {
+ fcMin = 0x400;
+ wIdent = 0xa5ec;
+ nFib = nFibBack = 0xc1;
+ nProduct = 0x49;
+
+ csw = 0x0e; // muss das sein ???
+ cfclcb = 0x5d; // -""-
+ clw = 0x16; // -""-
+ pnFbpChpFirst = pnFbpPapFirst = pnFbpLvcFirst = 0x000fffff;
+ fExtChar = TRUE;
+
+// diese Flags muessen nicht gesetzt werden; koennen aber.
+// wMagicCreated = wMagicRevised = 0x6a62;
+// wMagicCreatedPrivate = wMagicRevisedPrivate = 0xb3b2;
+// fWord97Saved = TRUE;
+ }
+ else
+ {
+ fcMin = 0x300;
+ wIdent = 0xa5dc;
+ nFib = nFibBack = 0x65;
+ nProduct = 0xc02d;
+ }
+
+ lid = 0x407;
+}
+
+
+BOOL WW8Fib::Write( SvStream& rStrm )
+{
+ BYTE* pData = new BYTE[ fcMin ];
+ BYTE* pDataPtr = pData;
+ memset( pData, 0, fcMin );
+
+ BOOL bVer8 = 8 == nVersion;
+
+ ULONG nPos = rStrm.Tell();
+ cbMac = rStrm.Seek( STREAM_SEEK_TO_END );
+ rStrm.Seek( nPos );
+
+ Set_UInt16( pData, wIdent );
+ Set_UInt16( pData, nFib );
+ Set_UInt16( pData, nProduct );
+ Set_UInt16( pData, lid );
+ Set_UInt16( pData, pnNext );
+
+ UINT16 nBits16 = 0;
+ if( fDot ) nBits16 |= 0x0001;
+ if( fGlsy) nBits16 |= 0x0002;
+ if( fComplex ) nBits16 |= 0x0004;
+ if( fHasPic ) nBits16 |= 0x0008;
+ nBits16 |= (0xf0 & ( cQuickSaves << 4 ));
+ if( fEncrypted ) nBits16 |= 0x0100;
+ if( fWhichTblStm ) nBits16 |= 0x0200;
+ if( fExtChar ) nBits16 |= 0x1000;
+ Set_UInt16( pData, nBits16 );
+
+ Set_UInt16( pData, nFibBack );
+ Set_UInt16( pData, lKey1 );
+ Set_UInt16( pData, lKey2 );
+ Set_UInt8( pData, envr );
+
+ BYTE nBits8 = 0;
+ if( bVer8 )
+ {
+ if( fMac ) nBits8 |= 0x0001;
+ if( fEmptySpecial ) nBits8 |= 0x0002;
+ if( fLoadOverridePage ) nBits8 |= 0x0004;
+ if( fFuturesavedUndo ) nBits8 |= 0x0008;
+ if( fWord97Saved ) nBits8 |= 0x0010;
+ }
+ Set_UInt8( pData, nBits8 ); // unter Ver67 nur leeres Reservefeld
+
+ Set_UInt16( pData, chse );
+ Set_UInt16( pData, chseTables );
+ Set_UInt32( pData, fcMin );
+ Set_UInt32( pData, fcMac );
+
+// Einschub fuer WW8 *****************************************************
+
+ // Marke: "rgsw" Beginning of the array of shorts
+ if( bVer8 )
+ {
+ Set_UInt16( pData, csw );
+ Set_UInt16( pData, wMagicCreated );
+ Set_UInt16( pData, wMagicRevised );
+ Set_UInt16( pData, wMagicCreatedPrivate );
+ Set_UInt16( pData, wMagicRevisedPrivate );
+ pData += 9 * sizeof( INT16 );
+ Set_UInt16( pData, lidFE );
+ Set_UInt16( pData, clw );
+ }
+
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rglw" Beginning of the array of longs
+ Set_UInt32( pData, cbMac );
+
+ // 2 Longs uebergehen, da unwichtiger Quatsch
+ pData += 2 * sizeof( INT32);
+
+ // weitere 2 Longs nur bei Ver67 ueberspringen
+ if( !bVer8 ) pData += 2 * sizeof( INT32);
+
+ Set_UInt32( pData, ccpText );
+ Set_UInt32( pData, ccpFtn );
+ Set_UInt32( pData, ccpHdr );
+ Set_UInt32( pData, ccpMcr );
+ Set_UInt32( pData, ccpAtn );
+ Set_UInt32( pData, ccpEdn );
+ Set_UInt32( pData, ccpTxbx );
+ Set_UInt32( pData, ccpHdrTxbx );
+
+ // weiteres Long nur bei Ver67 ueberspringen
+ if( !bVer8 ) pData += 1 * sizeof( INT32);
+
+// Einschub fuer WW8 *****************************************************
+ if( bVer8 )
+ {
+ Set_UInt32( pData, pnFbpChpFirst );
+ Set_UInt32( pData, pnChpFirst );
+ Set_UInt32( pData, cpnBteChp );
+ Set_UInt32( pData, pnFbpPapFirst );
+ Set_UInt32( pData, pnPapFirst );
+ Set_UInt32( pData, cpnBtePap );
+ Set_UInt32( pData, pnFbpLvcFirst );
+ Set_UInt32( pData, pnLvcFirst );
+ Set_UInt32( pData, cpnBteLvc );
+ Set_UInt32( pData, fcIslandFirst );
+ Set_UInt32( pData, fcIslandLim );
+ Set_UInt16( pData, cfclcb );
+ }
+// Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
+ Set_UInt32( pData, fcStshfOrig );
+ Set_UInt32( pData, lcbStshfOrig );
+ Set_UInt32( pData, fcStshf );
+ Set_UInt32( pData, lcbStshf );
+ Set_UInt32( pData, fcPlcffndRef );
+ Set_UInt32( pData, lcbPlcffndRef );
+ Set_UInt32( pData, fcPlcffndTxt );
+ Set_UInt32( pData, lcbPlcffndTxt );
+ Set_UInt32( pData, fcPlcfandRef );
+ Set_UInt32( pData, lcbPlcfandRef );
+ Set_UInt32( pData, fcPlcfandTxt );
+ Set_UInt32( pData, lcbPlcfandTxt );
+ Set_UInt32( pData, fcPlcfsed );
+ Set_UInt32( pData, lcbPlcfsed );
+ Set_UInt32( pData, fcPlcfpad );
+ Set_UInt32( pData, lcbPlcfpad );
+ Set_UInt32( pData, fcPlcfphe );
+ Set_UInt32( pData, lcbPlcfphe );
+ Set_UInt32( pData, fcSttbfglsy );
+ Set_UInt32( pData, lcbSttbfglsy );
+ Set_UInt32( pData, fcPlcfglsy );
+ Set_UInt32( pData, lcbPlcfglsy );
+ Set_UInt32( pData, fcPlcfhdd );
+ Set_UInt32( pData, lcbPlcfhdd );
+ Set_UInt32( pData, fcPlcfbteChpx );
+ Set_UInt32( pData, lcbPlcfbteChpx );
+ Set_UInt32( pData, fcPlcfbtePapx );
+ Set_UInt32( pData, lcbPlcfbtePapx );
+ Set_UInt32( pData, fcPlcfsea );
+ Set_UInt32( pData, lcbPlcfsea );
+ Set_UInt32( pData, fcSttbfffn );
+ Set_UInt32( pData, lcbSttbfffn );
+ Set_UInt32( pData, fcPlcffldMom );
+ Set_UInt32( pData, lcbPlcffldMom );
+ Set_UInt32( pData, fcPlcffldHdr );
+ Set_UInt32( pData, lcbPlcffldHdr );
+ Set_UInt32( pData, fcPlcffldFtn );
+ Set_UInt32( pData, lcbPlcffldFtn );
+ Set_UInt32( pData, fcPlcffldAtn );
+ Set_UInt32( pData, lcbPlcffldAtn );
+ Set_UInt32( pData, fcPlcffldMcr );
+ Set_UInt32( pData, lcbPlcffldMcr );
+ Set_UInt32( pData, fcSttbfbkmk );
+ Set_UInt32( pData, lcbSttbfbkmk );
+ Set_UInt32( pData, fcPlcfbkf );
+ Set_UInt32( pData, lcbPlcfbkf );
+ Set_UInt32( pData, fcPlcfbkl );
+ Set_UInt32( pData, lcbPlcfbkl );
+ Set_UInt32( pData, fcCmds );
+ Set_UInt32( pData, lcbCmds );
+ Set_UInt32( pData, fcPlcfmcr );
+ Set_UInt32( pData, lcbPlcfmcr );
+ Set_UInt32( pData, fcSttbfmcr );
+ Set_UInt32( pData, lcbSttbfmcr );
+ Set_UInt32( pData, fcPrDrvr );
+ Set_UInt32( pData, lcbPrDrvr );
+ Set_UInt32( pData, fcPrEnvPort );
+ Set_UInt32( pData, lcbPrEnvPort );
+ Set_UInt32( pData, fcPrEnvLand );
+ Set_UInt32( pData, lcbPrEnvLand );
+ Set_UInt32( pData, fcWss );
+ Set_UInt32( pData, lcbWss );
+ Set_UInt32( pData, fcDop );
+ Set_UInt32( pData, lcbDop );
+ Set_UInt32( pData, fcSttbfAssoc );
+ Set_UInt32( pData, cbSttbfAssoc );
+ Set_UInt32( pData, fcClx );
+ Set_UInt32( pData, lcbClx );
+ Set_UInt32( pData, fcPlcfpgdFtn );
+ Set_UInt32( pData, lcbPlcfpgdFtn );
+ Set_UInt32( pData, fcAutosaveSource );
+ Set_UInt32( pData, lcbAutosaveSource );
+ Set_UInt32( pData, fcGrpStAtnOwners );
+ Set_UInt32( pData, lcbGrpStAtnOwners );
+ Set_UInt32( pData, fcSttbfAtnbkmk );
+ Set_UInt32( pData, lcbSttbfAtnbkmk );
+
+ // weiteres short nur bei Ver67 ueberspringen
+ if( !bVer8 )
+ {
+ pData += 1*sizeof( INT16);
+ Set_UInt16( pData, (UINT16)pnChpFirst );
+ Set_UInt16( pData, (UINT16)pnPapFirst );
+ Set_UInt16( pData, (UINT16)cpnBteChp );
+ Set_UInt16( pData, (UINT16)cpnBtePap );
+ }
+
+ Set_UInt32( pData, fcPlcfdoaMom ); // nur bei Ver67, in Ver8 unused
+ Set_UInt32( pData, lcbPlcfdoaMom ); // nur bei Ver67, in Ver8 unused
+ Set_UInt32( pData, fcPlcfdoaHdr ); // nur bei Ver67, in Ver8 unused
+ Set_UInt32( pData, lcbPlcfdoaHdr ); // nur bei Ver67, in Ver8 unused
+
+ Set_UInt32( pData, fcPlcfspaMom ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbPlcfspaMom ); // in Ver67 leere Reserve
+ Set_UInt32( pData, fcPlcfspaHdr ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbPlcfspaHdr ); // in Ver67 leere Reserve
+
+ Set_UInt32( pData, fcPlcfAtnbkf );
+ Set_UInt32( pData, lcbPlcfAtnbkf );
+ Set_UInt32( pData, fcPlcfAtnbkl );
+ Set_UInt32( pData, lcbPlcfAtnbkl );
+ Set_UInt32( pData, fcPms );
+ Set_UInt32( pData, lcbPMS );
+ Set_UInt32( pData, fcFormFldSttbf );
+ Set_UInt32( pData, lcbFormFldSttbf );
+ Set_UInt32( pData, fcPlcfendRef );
+ Set_UInt32( pData, lcbPlcfendRef );
+ Set_UInt32( pData, fcPlcfendTxt );
+ Set_UInt32( pData, lcbPlcfendTxt );
+ Set_UInt32( pData, fcPlcffldEdn );
+ Set_UInt32( pData, lcbPlcffldEdn );
+ Set_UInt32( pData, fcPlcfpgdEdn );
+ Set_UInt32( pData, lcbPlcfpgdEdn );
+ Set_UInt32( pData, fcDggInfo ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbDggInfo ); // in Ver67 leere Reserve
+ Set_UInt32( pData, fcSttbfRMark );
+ Set_UInt32( pData, lcbSttbfRMark );
+ Set_UInt32( pData, fcSttbfCaption );
+ Set_UInt32( pData, lcbSttbfCaption );
+ Set_UInt32( pData, fcSttbAutoCaption );
+ Set_UInt32( pData, lcbSttbAutoCaption );
+ Set_UInt32( pData, fcPlcfwkb );
+ Set_UInt32( pData, lcbPlcfwkb );
+ Set_UInt32( pData, fcPlcfspl ); // in Ver67 leere Reserve
+ Set_UInt32( pData, lcbPlcfspl ); // in Ver67 leere Reserve
+ Set_UInt32( pData, fcPlcftxbxTxt );
+ Set_UInt32( pData, lcbPlcftxbxTxt );
+ Set_UInt32( pData, fcPlcffldTxbx );
+ Set_UInt32( pData, lcbPlcffldTxbx );
+ Set_UInt32( pData, fcPlcfHdrtxbxTxt );
+ Set_UInt32( pData, lcbPlcfHdrtxbxTxt );
+ Set_UInt32( pData, fcPlcffldHdrTxbx );
+ Set_UInt32( pData, lcbPlcffldHdrTxbx );
+
+ if( bVer8 )
+ {
+ pData += 0x2e2 - 0x27a; // Pos + Offset (fcPlcfLst - fcStwUser)
+ Set_UInt32( pData, fcPlcfLst );
+ Set_UInt32( pData, lcbPlcfLst );
+ Set_UInt32( pData, fcPlfLfo );
+ Set_UInt32( pData, lcbPlfLfo );
+ Set_UInt32( pData, fcPlcftxbxBkd );
+ Set_UInt32( pData, lcbPlcftxbxBkd );
+ Set_UInt32( pData, fcPlcfHdrtxbxBkd );
+ Set_UInt32( pData, lcbPlcfHdrtxbxBkd );
+
+ pData += 0x372 - 0x302; // Pos + Offset (fcSttbListNames - fcDocUndo)
+ Set_UInt32( pData, fcSttbListNames );
+ Set_UInt32( pData, lcbSttbListNames );
+ }
+
+ rStrm.Write( pDataPtr, fcMin );
+ delete pDataPtr;
+ return 0 == rStrm.GetError();
+}
+
+WW8Style::WW8Style( SvStream& rStream, WW8Fib& rFibPara ): rSt( rStream ), rFib( rFibPara )
+{
+ nStyleStart = rFib.fcStshf;
+ nStyleLen = rFib.lcbStshf;
+
+ rSt.Seek( nStyleStart );
+
+ USHORT cbStshi = 0; // 2 bytes size of the following STSHI structure
+
+ // alte Version ?
+ if ( rFib.nFib < 67 )
+ {
+ cbStshi = 4; // -> Laengenfeld fehlt
+ }
+ else // neue Version:
+ // lies die Laenge der in der Datei gespeicherten Struktur
+ rSt >> cbStshi;
+
+ UINT16 nRead = cbStshi;
+ do
+ {
+ UINT16 a16Bit;
+
+ if( 2 > nRead ) break;
+ rSt >> cstd;
+
+ if( 4 > nRead ) break;
+ rSt >> cbSTDBaseInFile;
+
+ if( 6 > nRead ) break;
+ rSt >> a16Bit;
+ fStdStylenamesWritten = a16Bit & 0x0001;
+
+ if( 8 > nRead ) break;
+ rSt >> stiMaxWhenSaved;
+
+ if( 10 > nRead ) break;
+ rSt >> istdMaxFixedWhenSaved;
+
+ if( 12 > nRead ) break;
+ rSt >> nVerBuiltInNamesWhenSaved;
+
+ if( 14 > nRead ) break;
+ rSt >> ftcStandardChpStsh;
+
+ // ggfs. den Rest ueberlesen
+ if( 14 < nRead )
+ rSt.SeekRel( nRead-14 );
+ }
+ while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
+ // und kann vorzeitig per "break" verlassen werden.
+
+ if( 0 != rSt.GetError() )
+ {
+ // wie denn nun den Error melden?
+ }
+}
+
+
+// Read1STDFixed() liest ein Style ein. Wenn der Style vollstaendig vorhanden
+// ist, d.h. kein leerer Slot, dann wird Speicher alloziert und ein Pointer auf
+// die ( evtl. mit Nullen aufgefuellten ) STD geliefert. Ist es ein leerer
+// Slot, dann wird ein Nullpointer zurueckgeliefert.
+WW8_STD* WW8Style::Read1STDFixed( short& rSkip, short* pcbStd )
+{
+ WW8_STD* pStd = (WW8_STD*)0;
+
+ UINT16 cbStd;
+ rSt >> cbStd; // lies Laenge
+
+ UINT16 nRead = cbSTDBaseInFile;
+ if( cbStd >= cbSTDBaseInFile ){ // Fixed part vollst. vorhanden
+
+ // read fixed part of STD
+ pStd = new WW8_STD;
+ memset( pStd, 0, sizeof( *pStd ) );
+
+ do
+ {
+ UINT16 a16Bit;
+
+ if( 2 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->sti = a16Bit & 0x0fff ;
+ pStd->fScratch = 0 != ( a16Bit & 0x1000 );
+ pStd->fInvalHeight = 0 != ( a16Bit & 0x2000 );
+ pStd->fHasUpe = 0 != ( a16Bit & 0x4000 );
+ pStd->fMassCopy = 0 != ( a16Bit & 0x8000 );
+
+ if( 4 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->sgc = a16Bit & 0x000f ;
+ pStd->istdBase = ( a16Bit & 0xfff0 ) >> 4;
+
+ if( 6 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->cupx = a16Bit & 0x000f ;
+ pStd->istdNext = ( a16Bit & 0xfff0 ) >> 4;
+
+ if( 8 > nRead ) break;
+ rSt >> pStd->bchUpe;
+
+ // ab Ver8 sollten diese beiden Felder dazukommen:
+ if(10 > nRead ) break;
+ rSt >> a16Bit;
+ pStd->fAutoRedef = a16Bit & 0x0001 ;
+ pStd->fHidden = ( a16Bit & 0x0002 ) >> 2;
+
+ // man kann nie wissen: vorsichtshalber ueberlesen
+ // wir eventuelle Fuellsel, die noch zum BASE-Part gehoeren...
+ if( 10 < nRead )
+ rSt.SeekRel( nRead-10 );
+ }
+ while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
+ // und kann vorzeitig per "break" verlassen werden.
+
+ if( (0 != rSt.GetError())
+ || !nRead )
+ DELETEZ( pStd ); // per NULL den Error melden
+
+ rSkip = cbStd - cbSTDBaseInFile;
+ }
+ else
+ { // Fixed part zu kurz
+ if( cbStd )
+ rSt.SeekRel( cbStd ); // ueberlies Reste
+ rSkip = 0;
+ }
+ if( pcbStd )
+ *pcbStd = cbStd;
+ return pStd;
+}
+
+WW8_STD* WW8Style::Read1Style( short& rSkip, String* pString, short* pcbStd )
+{
+ // OS2, or WIN with Mac-Doc,...
+ // Attention: MacWord-Documents have their Stylenames
+ // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
+
+ WW8_STD* pStd;
+
+ pStd = Read1STDFixed( rSkip, pcbStd ); // lese STD
+
+ // String gewuenscht ?
+ if( pString )
+ { // echter Style ?
+ if ( pStd )
+ {
+
+ switch( rFib.nVersion ) // beachte: 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: // lies Pascal-String
+ *pString = WW8ReadPString( rSt,
+ RTL_TEXTENCODING_MS_1252 );
+ // leading len and trailing zero --> 2
+ rSkip -= 2+ pString->Len();
+ break;
+ case 8: // lies Unicode-String mit fuehrendem Laengenbyte and trailing zero
+ *pString = WW8Read_xstz( rSt, 0, TRUE );
+ rSkip -= (pString->Len() + 2) * 2;
+ break;
+ default:ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+
+ }
+ else
+ *pString = aEmptyStr; // Kann keinen Namen liefern
+ }
+ return pStd;
+}
+
+
+//-----------------------------------------
+
+
+struct WW8_FFN_Ver6 : public WW8_FFN_BASE
+{
+ // ab Ver6
+ sal_Char szFfn[65]; // 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+ // records name of font.
+ // Maximal size of szFfn is 65 characters.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the
+ // name of an alternate font to use if the first named
+ // font does not exist on this system.
+};
+struct WW8_FFN_Ver8 : public WW8_FFN_BASE
+{
+ // ab Ver8 sind folgende beiden Felder eingeschoben,
+ // werden von uns ignoriert.
+ sal_Char panose[ 10 ]; // 0x6 PANOSE
+ sal_Char fs[ 24 ]; // 0x10 FONTSIGNATURE
+
+ // ab Ver8 als Unicode
+ UINT16 szFfn[65];// 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+ // records name of font.
+ // Maximal size of szFfn is 65 characters.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the
+ // name of an alternate font to use if the first named
+ // font does not exist on this system.
+};
+
+
+WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
+{
+ // OS2, or WIN with Mac-Doc,...
+ // Attention: MacWord-Documents have their Fontnames
+ // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
+ if( rFib.lcbSttbfffn <= 2 )
+ {
+ ASSERT( !this, "Fonttabelle kaputt! (rFib.lcbSttbfffn < 2)" );
+ pFontA = 0;
+ nMax = 0;
+ return;
+ }
+
+ BOOL bVer67 = (8 > rFib.nVersion);
+
+ rSt.Seek( rFib.fcSttbfffn );
+
+ // allocate Font Array
+ BYTE* pA = new BYTE[ rFib.lcbSttbfffn - 2 ];
+ WW8_FFN* p = (WW8_FFN*)pA;
+
+ if( !bVer67 )
+ {
+ // bVer8: read the count of strings in nMax
+ rSt >> nMax;
+ }
+
+ // Ver8: skip undefined uint16
+ // Ver67: skip the herein stored total byte of structure
+ // - we already got that information in rFib.lcbSttbfffn
+ rSt.SeekRel( 2 );
+
+ // read all font information
+ rSt.Read( pA, rFib.lcbSttbfffn - 2 );
+
+ if( bVer67 )
+ {
+ // try to figure out how many fonts are defined here
+ nMax = 0;
+ long nLeft = rFib.lcbSttbfffn - 2;
+ for(;;)
+ {
+ short nNextSiz;
+
+ nNextSiz = p->cbFfnM1 + 1;
+ if( nNextSiz > nLeft )
+ break;
+ nMax++;
+ nLeft -= nNextSiz;
+ if( nLeft < 1 ) // can we read the given ammount of bytes ?
+ break;
+ // increase p by nNextSiz Bytes
+ p = (WW8_FFN *)( ( (BYTE*)p ) + nNextSiz );
+ }
+ }
+
+ if( nMax )
+ {
+ // allocate Index Array
+ pFontA = new WW8_FFN[ nMax ];
+ p = pFontA;
+
+ if( bVer67 )
+ {
+ WW8_FFN_Ver6* pVer6 = (WW8_FFN_Ver6*)pA;
+ for(USHORT i=0; i<nMax; ++i, ++p)
+ {
+ p->cbFfnM1 = pVer6->cbFfnM1;
+ p->prg = pVer6->prg;
+ p->fTrueType = pVer6->fTrueType;
+ p->ff = pVer6->ff;
+ p->wWeight = SVBT16ToShort( *(SVBT16*)&pVer6->wWeight );
+ p->chs = pVer6->chs;
+ p->ibszAlt = pVer6->ibszAlt;
+ p->sFontname = String( pVer6->szFfn, RTL_TEXTENCODING_MS_1252 );
+ pVer6 = (WW8_FFN_Ver6*)( ((BYTE*)pVer6)
+ + pVer6->cbFfnM1 + 1 );
+ }
+ }
+ else
+ {
+ WW8_FFN_Ver8* pVer8 = (WW8_FFN_Ver8*)pA;
+ BYTE c2;
+ for(USHORT i=0; i<nMax; ++i, ++p)
+ {
+ p->cbFfnM1 = pVer8->cbFfnM1;
+ c2 = *(((BYTE*)pVer8) + 1);
+
+ p->prg = c2 & 0x02;
+ p->fTrueType = (c2 & 0x04) >> 2;
+ // ein Reserve-Bit ueberspringen
+ p->ff = (c2 & 0x70) >> 4;
+
+ p->wWeight = SVBT16ToShort( *(SVBT16*)&pVer8->wWeight );
+ p->chs = pVer8->chs;
+ p->ibszAlt = pVer8->ibszAlt;
+
+#ifdef __WW8_NEEDS_COPY
+ {
+ for(UINT16* pTmp = pVer8->szFfn; *pTmp; ++pTmp )
+ *pTmp = SVBT16ToShort( *(SVBT16*)pTmp );
+ }
+#endif // defined __WW8_NEEDS_COPY
+
+ p->sFontname = pVer8->szFfn;
+
+ // Zeiger auf Ursprungsarray einen Font nach hinten setzen
+ pVer8 = (WW8_FFN_Ver8*)( ( (BYTE*)pVer8 ) + pVer8->cbFfnM1 + 1 );
+ }
+ }
+ }
+ delete pA;
+}
+
+const WW8_FFN* WW8Fonts::GetFont( USHORT nNum ) const
+{
+ if( !pFontA || nNum > nMax )
+ return 0;
+
+ return &pFontA[ nNum ];
+}
+
+
+
+//-----------------------------------------
+
+
+// Suche zu einem Header / Footer den Index in der WW-Liste von Headern / Footern
+//
+// Pferdefuesse bei WinWord6 und -7:
+// 1) Am Anfang des Einlesens muss WWPLCF_HdFt mit Fib und Dop konstruiert werden
+// 2) Der Haupttext muss sequentiell ueber alle Sections gelesen werden
+// 3) Fuer jedes vorkommende Header / Footer - Attribut des Haupttextes
+// ( Darf pro Section maximal eins sein ) muss UpdateIndex() genau einmal
+// mit dem Parameter des Attributes gerufen werden. Dieser Aufruf muss *nach*
+// dem letzten Aufruf von GetTextPos() passieren.
+// 4) GetTextPos() darf mit genau einem der obenstehen WW_... aufgerufen werden
+// ( nicht verodern ! )
+// -> dann liefert GetTextPos() vielleicht auch ein richtiges Ergebnis
+
+WW8PLCF_HdFt::WW8PLCF_HdFt( SvStream* pSt, WW8Fib& rFib, WW8Dop& rDop )
+: aPLCF( pSt, rFib.fcPlcfhdd , rFib.lcbPlcfhdd , 0 )
+{
+ nIdxOffset = 0;
+
+// for( BYTE nI = 0x80; nI >= 0x20; nI >>= 1 ) // Beschreibung stimmt nicht
+
+// for( BYTE nI = 0x1; nI <= 0x4; nI <<= 1 ) // Vorsicht: Beschreibung stimmt nicht
+
+
+ /*
+ cmc 23/02/2000: This dop.grpfIhdt has a bit set for each special
+ footnote *and endnote!!* seperator,continuation seperator, and
+ continuation notice entry, the documentation does not mention the
+ endnote seperators, the documentation also gets the index numbers
+ backwards when specifiying which bits to test. The bottom six bits
+ of this value must be tested and skipped over. Each section's
+ grpfIhdt is then tested for the existence of the appropiate headers
+ and footers, at the end of each section the nIdxOffset must be updated
+ to point to the beginning of the next section's group of headers and
+ footers in this PLCF, UpdateIndex does that task.
+ */
+ for( BYTE nI = 0x1; nI <= 0x20; nI <<= 1 )
+ if( nI & rDop.grpfIhdt ) // Bit gesetzt ?
+ nIdxOffset++;
+
+ nTextOfs = rFib.ccpText + rFib.ccpFtn; // Groesse des Haupttextes
+ // und der Fussnoten
+}
+
+BOOL WW8PLCF_HdFt::GetTextPos( BYTE grpfIhdt, BYTE nWhich, WW8_CP& rStart, long& rLen )
+{
+ BYTE nI = 0x1;
+ short nIdx = nIdxOffset;
+ while( TRUE ){
+ if( nI & nWhich )
+ break; // gefunden
+ if( grpfIhdt & nI )
+ nIdx++; // uninteressanter Header / Footer
+ nI <<= 1; // naechstes Bit testen
+ if( nI > 0x20 )
+ return FALSE; // nicht gefunden
+ }
+ // nIdx ist HdFt-Index
+ WW8_CP ende;
+ void* pData;
+
+ aPLCF.SetIdx( nIdx ); // dann suche passenden CP
+ aPLCF.Get( rStart, ende, pData );
+ rLen = ende - rStart;
+// Der letzte Header/Footer hat eine Laenge, die um 1 Zeichen zu gross ist
+// ( folgendes CR ). Um diesen passend zu kuerzen muesste man den Index
+// dieses K/F-Textes finden ( es ist nicht der letzte im PLCF ! ).
+// if( (long)aPLCF.GetIdx() == aPLCF.GetIMax() ) // Falsch!
+// rLen--; // Letztes Element ist 1 zu gross
+ aPLCF++;
+ return TRUE;
+}
+
+BOOL WW8PLCF_HdFt::GetTextPosExact( short nIdx, WW8_CP& rStart, long& rLen )
+{
+ WW8_CP ende;
+ void* pData;
+
+ aPLCF.SetIdx( nIdx ); // dann suche passenden CP
+ aPLCF.Get( rStart, ende, pData );
+ rLen = ende - rStart;
+// Der letzte Header/Footer hat eine Laenge, die um 1 Zeichen zu gross ist
+// ( folgendes CR ). Um diesen passend zu kuerzen muesste man den Index
+// dieses K/F-Textes finden ( es ist nicht der letzte im PLCF ! ).
+// if( (long)aPLCF.GetIdx() == aPLCF.GetIMax() ) // Falsch!
+// rLen--; // Letztes Element ist 1 zu gross
+ return TRUE;
+}
+
+void WW8PLCF_HdFt::UpdateIndex( BYTE grpfIhdt )
+{
+ for( BYTE nI = 0x1; nI <= 0x20; nI <<= 1 ) // Vorsicht: Beschreibung stimmt nicht
+ if( nI & grpfIhdt )
+ nIdxOffset++;
+}
+
+//-----------------------------------------
+// WW8Dop
+//-----------------------------------------
+
+
+
+WW8Dop::WW8Dop( SvStream& rSt, INT16 nFib, INT32 nPos, INT32 nSize )
+{
+ BYTE* pData = new BYTE[ 500 ];
+ BYTE* pDataPtr = pData;
+ UINT32 nRead = 500 < nSize ? 500 : nSize;
+ rSt.Seek( nPos );
+ if( 2 > nSize || nRead != rSt.Read( pData, nRead ))
+ {
+ memset( &nDataStart, 0, (&nDataEnd - &nDataStart) );
+ nDopError = ERR_SWG_READ_ERROR; // Error melden
+ }
+ else
+ {
+ if( 500 > nRead )
+ memset( pData + nRead, 0, 500 - nRead );
+
+ // dann mal die Daten auswerten
+ UINT32 a32Bit;
+ UINT16 a16Bit;
+ BYTE a8Bit;
+
+ a16Bit = Get_UShort( pData );
+ fFacingPages = 0 != ( a16Bit & 0x0001 ) ;
+ fWidowControl = 0 != ( a16Bit & 0x0002 ) ;
+ fPMHMainDoc = 0 != ( a16Bit & 0x0004 ) ;
+ grfSuppression = ( a16Bit & 0x0018 ) >> 3;
+ fpc = ( a16Bit & 0x0060 ) >> 5;
+ grpfIhdt = ( a16Bit & 0xff00 ) >> 8;
+
+ a16Bit = Get_UShort( pData );
+ rncFtn = a16Bit & 0x0003 ;
+ nFtn = ( a16Bit & ~0x0003 ) >> 2 ;
+
+ a8Bit = Get_Byte( pData );
+ fOutlineDirtySave = 0 != ( a8Bit & 0x01 );
+
+ a8Bit = Get_Byte( pData );
+ fOnlyMacPics = 0 != ( a8Bit & 0x01 );
+ fOnlyWinPics = 0 != ( a8Bit & 0x02 );
+ fLabelDoc = 0 != ( a8Bit & 0x04 );
+ fHyphCapitals = 0 != ( a8Bit & 0x08 );
+ fAutoHyphen = 0 != ( a8Bit & 0x10 );
+ fFormNoFields = 0 != ( a8Bit & 0x20 );
+ fLinkStyles = 0 != ( a8Bit & 0x40 );
+ fRevMarking = 0 != ( a8Bit & 0x80 );
+
+ a8Bit = Get_Byte( pData );
+ fBackup = 0 != ( a8Bit & 0x01 );
+ fExactCWords = 0 != ( a8Bit & 0x02 );
+ fPagHidden = 0 != ( a8Bit & 0x04 );
+ fPagResults = 0 != ( a8Bit & 0x08 );
+ fLockAtn = 0 != ( a8Bit & 0x10 );
+ fMirrorMargins = 0 != ( a8Bit & 0x20 );
+ fReadOnlyRecommended = 0 != ( a8Bit & 0x40 );
+ fDfltTrueType = 0 != ( a8Bit & 0x80 );
+
+ a8Bit = Get_Byte( pData );
+ fPagSuppressTopSpacing = 0 != ( a8Bit & 0x01 );
+ fProtEnabled = 0 != ( a8Bit & 0x02 );
+ fDispFormFldSel = 0 != ( a8Bit & 0x04 );
+ fRMView = 0 != ( a8Bit & 0x08 );
+ fRMPrint = 0 != ( a8Bit & 0x10 );
+ fWriteReservation = 0 != ( a8Bit & 0x20 );
+ fLockRev = 0 != ( a8Bit & 0x40 );
+ fEmbedFonts = 0 != ( a8Bit & 0x80 );
+
+
+ a8Bit = Get_Byte( pData );
+ copts_fNoTabForInd = 0 != ( a8Bit & 0x01 );
+ copts_fNoSpaceRaiseLower = 0 != ( a8Bit & 0x02 );
+ copts_fSupressSpbfAfterPgBrk = 0 != ( a8Bit & 0x04 );
+ copts_fWrapTrailSpaces = 0 != ( a8Bit & 0x08 );
+ copts_fMapPrintTextColor = 0 != ( a8Bit & 0x10 );
+ copts_fNoColumnBalance = 0 != ( a8Bit & 0x20 );
+ copts_fConvMailMergeEsc = 0 != ( a8Bit & 0x40 );
+ copts_fSupressTopSpacing = 0 != ( a8Bit & 0x80 );
+
+ a8Bit = Get_Byte( pData );
+ copts_fOrigWordTableRules = 0 != ( a8Bit & 0x01 );
+ copts_fTransparentMetafiles = 0 != ( a8Bit & 0x02 );
+ copts_fShowBreaksInFrames = 0 != ( a8Bit & 0x04 );
+ copts_fSwapBordersFacingPgs = 0 != ( a8Bit & 0x08 );
+
+ dxaTab = Get_Short( pData );
+ wSpare = Get_UShort( pData );
+ dxaHotZ = Get_UShort( pData );
+ cConsecHypLim = Get_UShort( pData );
+ wSpare2 = Get_UShort( pData );
+ dttmCreated = Get_Long( pData );
+ dttmRevised = Get_Long( pData );
+ dttmLastPrint = Get_Long( pData );
+ nRevision = Get_Short( pData );
+ tmEdited = Get_Long( pData );
+ cWords = Get_Long( pData );
+ cCh = Get_Long( pData );
+ cPg = Get_Short( pData );
+ cParas = Get_Long( pData );
+
+ a16Bit = Get_UShort( pData );
+ rncEdn = a16Bit & 0x0003 ;
+ nEdn = ( a16Bit & ~0x0003 ) >> 2;
+
+ a16Bit = Get_UShort( pData );
+ epc = a16Bit & 0x0003 ;
+ nfcFtnRef = ( a16Bit & 0x003c ) >> 2;
+ nfcEdnRef = ( a16Bit & 0x03c0 ) >> 6;
+ fPrintFormData = 0 != ( a16Bit & 0x0400 );
+ fSaveFormData = 0 != ( a16Bit & 0x0800 );
+ fShadeFormData = 0 != ( a16Bit & 0x1000 );
+ fWCFtnEdn = 0 != ( a16Bit & 0x8000 );
+
+ cLines = Get_Long( pData );
+ cWordsFtnEnd = Get_Long( pData );
+ cChFtnEdn = Get_Long( pData );
+ cPgFtnEdn = Get_Short( pData );
+ cParasFtnEdn = Get_Long( pData );
+ cLinesFtnEdn = Get_Long( pData );
+ lKeyProtDoc = Get_Long( pData );
+
+ a16Bit = Get_UShort( pData );
+ wvkSaved = a16Bit & 0x0007 ;
+ wScaleSaved = ( a16Bit & 0x0ff8 ) >> 3 ;
+ zkSaved = ( a16Bit & 0x3000 ) >> 12;
+
+ /*
+ bei nFib >= 103 gehts weiter:
+ */
+ if( nFib >= 103 )
+ {
+ a32Bit = Get_ULong( pData );
+ fNoTabForInd = ( a32Bit & 0x00000001 ) ;
+ fNoSpaceRaiseLower = ( a32Bit & 0x00000002 ) >> 1 ;
+ fSupressSpbfAfterPageBreak = ( a32Bit & 0x00000004 ) >> 2 ;
+ fWrapTrailSpaces = ( a32Bit & 0x00000008 ) >> 3 ;
+ fMapPrintTextColor = ( a32Bit & 0x00000010 ) >> 4 ;
+ fNoColumnBalance = ( a32Bit & 0x00000020 ) >> 5 ;
+ fConvMailMergeEsc = ( a32Bit & 0x00000040 ) >> 6 ;
+ fSupressTopSpacing = ( a32Bit & 0x00000080 ) >> 7 ;
+ fOrigWordTableRules = ( a32Bit & 0x00000100 ) >> 8 ;
+ fTransparentMetafiles = ( a32Bit & 0x00000200 ) >> 9 ;
+ fShowBreaksInFrames = ( a32Bit & 0x00000400 ) >> 10 ;
+ fSwapBordersFacingPgs = ( a32Bit & 0x00000800 ) >> 11 ;
+ fSuppressTopSpacingMac5 = ( a32Bit & 0x00010000 ) >> 16 ;
+ fTruncDxaExpand = ( a32Bit & 0x00020000 ) >> 17 ;
+ fPrintBodyBeforeHdr = ( a32Bit & 0x00040000 ) >> 18 ;
+ fNoLeading = ( a32Bit & 0x00080000 ) >> 19 ;
+ fMWSmallCaps = ( a32Bit & 0x00200000 ) >> 21 ;
+ }
+
+ /*
+ bei nFib > 105 gehts weiter:
+ */
+ if( nFib > 105 )
+ {
+ adt = Get_Short( pData );
+
+ memcpy( &doptypography, pData, sizeof( WW8_DOPTYPOGRAPHY ));
+ pData += sizeof( WW8_DOPTYPOGRAPHY );
+
+ memcpy( &dogrid, pData, sizeof( WW8_DOGRID ));
+ pData += sizeof( WW8_DOGRID );
+
+ a16Bit = Get_UShort( pData );
+ // die untersten 9 Bit sind uninteressant
+ fHtmlDoc = ( a16Bit & 0x0200 ) >> 9 ;
+ fSnapBorder = ( a16Bit & 0x0800 ) >> 11 ;
+ fIncludeHeader = ( a16Bit & 0x1000 ) >> 12 ;
+ fIncludeFooter = ( a16Bit & 0x2000 ) >> 13 ;
+ fForcePageSizePag = ( a16Bit & 0x4000 ) >> 14 ;
+ fMinFontSizePag = ( a16Bit & 0x8000 ) >> 15 ;
+
+ a16Bit = Get_UShort( pData );
+ fHaveVersions = 0 != ( a16Bit & 0x0001 );
+ fAutoVersion = 0 != ( a16Bit & 0x0002 );
+
+ pData += 12;
+
+ cChWS = Get_Long( pData );
+ cChWSFtnEdn = Get_Long( pData );
+ grfDocEvents = Get_Long( pData );
+
+ pData += 4+30+8;
+
+ cDBC = Get_Long( pData );
+ cDBCFtnEdn = Get_Long( pData );
+
+ pData += 1 * sizeof( long );
+
+ nfcFtnRef = Get_Short( pData );
+ nfcEdnRef = Get_Short( pData );
+ hpsZoonFontPag = Get_Short( pData );
+ dywDispPag = Get_Short( pData );
+ }
+ }
+ delete pDataPtr;
+}
+
+WW8Dop::WW8Dop()
+{
+ // erstmal alles auf 0 defaulten
+ memset( &nDataStart, 0, (&nDataEnd - &nDataStart) );
+
+ fWidowControl = 1;
+ fpc = 1;
+ nFtn = 1;
+ fOutlineDirtySave = 1;
+ fHyphCapitals = 1;
+ fBackup = 1;
+ fPagHidden = 1;
+ fPagResults = 1;
+ fDfltTrueType = 1;
+ fRMView = 1;
+ fRMPrint = 1;
+ dxaTab = 0x2d0;
+ dxaHotZ = 0x168;
+ dttmCreated = 0x45FBAC69;
+ dttmRevised = 0x45FBAC69;
+ nRevision = 1;
+ nEdn = 1;
+
+ epc = 3;
+ nfcEdnRef = 2;
+ fShadeFormData = 1;
+
+ wvkSaved = 2;
+ wScaleSaved = 100;
+ zkSaved = 0;
+
+ lvl = 9;
+ fIncludeHeader = 1;
+ fIncludeFooter = 1;
+
+ cChWS = /**!!**/ 0;
+ cChWSFtnEdn = /**!!**/ 0;
+
+ cDBC = /**!!**/ 0;
+ cDBCFtnEdn = /**!!**/ 0;
+}
+
+BOOL WW8Dop::Write( SvStream& rStrm, WW8Fib& rFib )
+{
+ INT32 nLen = 8 == rFib.nVersion ? 500 : 84;
+ rFib.fcDop = rStrm.Tell();
+ rFib.lcbDop = nLen;
+
+ BYTE aData[ 500 ];
+ memset( aData, 0, 500 );
+ BYTE* pData = aData;
+
+ // dann mal die Daten auswerten
+ UINT32 a32Bit;
+ UINT16 a16Bit;
+ BYTE a8Bit;
+
+ a16Bit = 0;
+ if( fFacingPages ) a16Bit |= 0x0001;
+ if( fWidowControl ) a16Bit |= 0x0002;
+ if( fPMHMainDoc ) a16Bit |= 0x0004;
+ a16Bit |= ( 0x0018 & (grfSuppression << 3));
+ a16Bit |= ( 0x0060 & (fpc << 5));
+ a16Bit |= ( 0xff00 & (grpfIhdt << 8));
+ Set_UInt16( pData, a16Bit );
+
+ a16Bit = 0;
+ a16Bit |= ( 0x0003 & rncFtn );
+ a16Bit |= ( ~0x0003 & (nFtn << 2));
+ Set_UInt16( pData, a16Bit );
+
+ a8Bit = 0;
+ if( fOutlineDirtySave ) a8Bit |= 0x01;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( fOnlyMacPics ) a8Bit |= 0x01;
+ if( fOnlyWinPics ) a8Bit |= 0x02;
+ if( fLabelDoc ) a8Bit |= 0x04;
+ if( fHyphCapitals ) a8Bit |= 0x08;
+ if( fAutoHyphen ) a8Bit |= 0x10;
+ if( fFormNoFields ) a8Bit |= 0x20;
+ if( fLinkStyles ) a8Bit |= 0x40;
+ if( fRevMarking ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( fBackup ) a8Bit |= 0x01;
+ if( fExactCWords ) a8Bit |= 0x02;
+ if( fPagHidden ) a8Bit |= 0x04;
+ if( fPagResults ) a8Bit |= 0x08;
+ if( fLockAtn ) a8Bit |= 0x10;
+ if( fMirrorMargins ) a8Bit |= 0x20;
+ if( fReadOnlyRecommended ) a8Bit |= 0x40;
+ if( fDfltTrueType ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( fPagSuppressTopSpacing ) a8Bit |= 0x01;
+ if( fProtEnabled ) a8Bit |= 0x02;
+ if( fDispFormFldSel ) a8Bit |= 0x04;
+ if( fRMView ) a8Bit |= 0x08;
+ if( fRMPrint ) a8Bit |= 0x10;
+ if( fWriteReservation ) a8Bit |= 0x20;
+ if( fLockRev ) a8Bit |= 0x40;
+ if( fEmbedFonts ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+
+ a8Bit = 0;
+ if( copts_fNoTabForInd ) a8Bit |= 0x01;
+ if( copts_fNoSpaceRaiseLower ) a8Bit |= 0x02;
+ if( copts_fSupressSpbfAfterPgBrk ) a8Bit |= 0x04;
+ if( copts_fWrapTrailSpaces ) a8Bit |= 0x08;
+ if( copts_fMapPrintTextColor ) a8Bit |= 0x10;
+ if( copts_fNoColumnBalance ) a8Bit |= 0x20;
+ if( copts_fConvMailMergeEsc ) a8Bit |= 0x40;
+ if( copts_fSupressTopSpacing ) a8Bit |= 0x80;
+ Set_UInt8( pData, a8Bit );
+
+ a8Bit = 0;
+ if( copts_fOrigWordTableRules ) a8Bit |= 0x01;
+ if( copts_fTransparentMetafiles ) a8Bit |= 0x02;
+ if( copts_fShowBreaksInFrames ) a8Bit |= 0x04;
+ if( copts_fSwapBordersFacingPgs ) a8Bit |= 0x08;
+ Set_UInt8( pData, a8Bit );
+
+ Set_UInt16( pData, dxaTab );
+ Set_UInt16( pData, wSpare );
+ Set_UInt16( pData, dxaHotZ );
+ Set_UInt16( pData, cConsecHypLim );
+ Set_UInt16( pData, wSpare2 );
+ Set_UInt32( pData, dttmCreated );
+ Set_UInt32( pData, dttmRevised );
+ Set_UInt32( pData, dttmLastPrint );
+ Set_UInt16( pData, nRevision );
+ Set_UInt32( pData, tmEdited );
+ Set_UInt32( pData, cWords );
+ Set_UInt32( pData, cCh );
+ Set_UInt16( pData, cPg );
+ Set_UInt32( pData, cParas );
+
+ a16Bit = 0;
+ a16Bit |= ( 0x0003 & rncEdn );
+ a16Bit |= (~0x0003 & ( nEdn << 2));
+ Set_UInt16( pData, a16Bit );
+
+ a16Bit = 0;
+ a16Bit |= (0x0003 & epc );
+ a16Bit |= (0x003c & (nfcFtnRef << 2));
+ a16Bit |= (0x03c0 & (nfcEdnRef << 6));
+ if( fPrintFormData ) a16Bit |= 0x0400;
+ if( fSaveFormData ) a16Bit |= 0x0800;
+ if( fShadeFormData ) a16Bit |= 0x1000;
+ if( fWCFtnEdn ) a16Bit |= 0x8000;
+ Set_UInt16( pData, a16Bit );
+
+ Set_UInt32( pData, cLines );
+ Set_UInt32( pData, cWordsFtnEnd );
+ Set_UInt32( pData, cChFtnEdn );
+ Set_UInt16( pData, cPgFtnEdn );
+ Set_UInt32( pData, cParasFtnEdn );
+ Set_UInt32( pData, cLinesFtnEdn );
+ Set_UInt32( pData, lKeyProtDoc );
+
+ a16Bit = 0;
+ if( wvkSaved ) a16Bit |= 0x0007;
+ a16Bit |= (0x0ff8 & (wScaleSaved << 3));
+ a16Bit |= (0x3000 & (zkSaved << 12));
+ Set_UInt16( pData, a16Bit );
+
+ if( 8 == rFib.nVersion )
+ {
+ a32Bit = 0;
+ if( fNoTabForInd ) a32Bit |= 0x00000001;
+ if( fNoSpaceRaiseLower ) a32Bit |= 0x00000002;
+ if( fSupressSpbfAfterPageBreak ) a32Bit |= 0x00000004;
+ if( fWrapTrailSpaces ) a32Bit |= 0x00000008;
+ if( fMapPrintTextColor ) a32Bit |= 0x00000010;
+ if( fNoColumnBalance ) a32Bit |= 0x00000020;
+ if( fConvMailMergeEsc ) a32Bit |= 0x00000040;
+ if( fSupressTopSpacing ) a32Bit |= 0x00000080;
+ if( fOrigWordTableRules ) a32Bit |= 0x00000100;
+ if( fTransparentMetafiles ) a32Bit |= 0x00000200;
+ if( fShowBreaksInFrames ) a32Bit |= 0x00000400;
+ if( fSwapBordersFacingPgs ) a32Bit |= 0x00000800;
+ if( fSuppressTopSpacingMac5 ) a32Bit |= 0x00010000;
+ if( fTruncDxaExpand ) a32Bit |= 0x00020000;
+ if( fPrintBodyBeforeHdr ) a32Bit |= 0x00040000;
+ if( fNoLeading ) a32Bit |= 0x00080000;
+ if( fMWSmallCaps ) a32Bit |= 0x00200000;
+ Set_UInt32( pData, a32Bit );
+
+ Set_UInt16( pData, adt );
+
+ memcpy( pData, &doptypography, sizeof( WW8_DOPTYPOGRAPHY ));
+ pData += sizeof( WW8_DOPTYPOGRAPHY );
+
+ memcpy( pData, &dogrid, sizeof( WW8_DOGRID ));
+ pData += sizeof( WW8_DOGRID );
+
+ a16Bit = 0x12; // lvl auf 9 setzen
+ if( fHtmlDoc ) a16Bit |= 0x0200;
+ if( fSnapBorder ) a16Bit |= 0x0800;
+ if( fIncludeHeader ) a16Bit |= 0x1000;
+ if( fIncludeFooter ) a16Bit |= 0x2000;
+ if( fForcePageSizePag ) a16Bit |= 0x4000;
+ if( fMinFontSizePag ) a16Bit |= 0x8000;
+ Set_UInt16( pData, a16Bit );
+
+ a16Bit = 0;
+ if( fHaveVersions ) a16Bit |= 0x0001;
+ if( fAutoVersion ) a16Bit |= 0x0002;
+ Set_UInt16( pData, a16Bit );
+
+ pData += 12;
+
+ Set_UInt32( pData, cChWS );
+ Set_UInt32( pData, cChWSFtnEdn );
+ Set_UInt32( pData, grfDocEvents );
+
+ pData += 4+30+8;
+
+ Set_UInt32( pData, cDBC );
+ Set_UInt32( pData, cDBCFtnEdn );
+
+ pData += 1 * sizeof( long );
+
+ Set_UInt16( pData, nfcFtnRef );
+ Set_UInt16( pData, nfcEdnRef );
+ Set_UInt16( pData, hpsZoonFontPag );
+ Set_UInt16( pData, dywDispPag );
+ }
+ rStrm.Write( aData, nLen );
+ return 0 == rStrm.GetError();
+}
+
+/***************************************************************************
+# Array zum Bestimmen der Laenge der SPRMs
+#**************************************************************************/
+
+
+/*
+ Werte fuer SprmInfo.nVari
+*/
+#define L_FIX 0
+#define L_VAR 1
+#define L_VAR2 2
+
+struct SprmInfo
+{
+ USHORT nId;
+ BYTE nLen : 6;
+ BYTE nVari: 2;
+};
+
+
+/*
+ Zweck: Laenge und Parameter-Offset eines Sprm erfahren
+*/
+static SprmInfo aWwSprmTab[] = {
+ 0, 0, L_FIX, // "Default-sprm", // wird uebersprungen
+ 2, 2, L_FIX, // "sprmPIstd", // pap.istd (style code)
+ 3, 3, L_VAR, // "sprmPIstdPermute", // pap.istd permutation
+ 4, 1, L_FIX, // "sprmPIncLv1", // pap.istddifference
+ 5, 1, L_FIX, // "sprmPJc", // pap.jc (justification)
+ 6, 1, L_FIX, // "sprmPFSideBySide", // pap.fSideBySide
+ 7, 1, L_FIX, // "sprmPFKeep", // pap.fKeep
+ 8, 1, L_FIX, // "sprmPFKeepFollow ", // pap.fKeepFollow
+ 9, 1, L_FIX, // "sprmPPageBreakBefore", // pap.fPageBreakBefore
+
+ 10, 1, L_FIX, // "sprmPBrcl", // pap.brcl
+ 11, 1, L_FIX, // "sprmPBrcp ", // pap.brcp
+ 12, 0, L_VAR, // "sprmPAnld", // pap.anld (ANLD structure)
+ 13, 1, L_FIX, // "sprmPNLvlAnm", // pap.nLvlAnm nn
+ 14, 1, L_FIX, // "sprmPFNoLineNumb", //ap.fNoLnn
+
+
+ // ???
+ 15, 0, L_VAR, // "?sprmPChgTabsPapx", // pap.itbdMac, ...
+
+
+ 16, 2, L_FIX, // "sprmPDxaRight", // pap.dxaRight
+ 17, 2, L_FIX, // "sprmPDxaLeft", // pap.dxaLeft
+ 18, 2, L_FIX, // "sprmPNest", // pap.dxaLeft
+ 19, 2, L_FIX, // "sprmPDxaLeft1", // pap.dxaLeft1
+
+ 20, 4, L_FIX, // "sprmPDyaLine", // pap.lspd an LSPD
+ 21, 2, L_FIX, // "sprmPDyaBefore", // pap.dyaBefore
+ 22, 2, L_FIX, // "sprmPDyaAfter", // pap.dyaAfter
+
+
+ // ???
+ 23, 0, L_VAR, // "?sprmPChgTabs", // pap.itbdMac, pap.rgdxaTab, ...
+
+
+ 24, 1, L_FIX, // "sprmPFInTable", // pap.fInTable
+ 25, 1, L_FIX, // "sprmPTtp", // pap.fTtp
+ 26, 2, L_FIX, // "sprmPDxaAbs", // pap.dxaAbs
+ 27, 2, L_FIX, // "sprmPDyaAbs", // pap.dyaAbs
+ 28, 2, L_FIX, // "sprmPDxaWidth", // pap.dxaWidth
+ 29, 1, L_FIX, // "sprmPPc", // pap.pcHorz, pap.pcVert
+
+ 30, 2, L_FIX, // "sprmPBrcTop10", // pap.brcTop BRC10
+ 31, 2, L_FIX, // "sprmPBrcLeft10", // pap.brcLeft BRC10
+ 32, 2, L_FIX, // "sprmPBrcBottom10", // pap.brcBottom BRC10
+ 33, 2, L_FIX, // "sprmPBrcRight10", // pap.brcRight BRC10
+ 34, 2, L_FIX, // "sprmPBrcBetween10", // pap.brcBetween BRC10
+ 35, 2, L_FIX, // "sprmPBrcBar10", // pap.brcBar BRC10
+ 36, 2, L_FIX, // "sprmPFromText10", // pap.dxaFromText dxa
+ 37, 1, L_FIX, // "sprmPWr", // pap.wr wr
+ 38, 2, L_FIX, // "sprmPBrcTop", // pap.brcTop BRC
+ 39, 2, L_FIX, // "sprmPBrcLeft", // pap.brcLeft BRC
+
+ 40, 2, L_FIX, // "sprmPBrcBottom", // pap.brcBottom BRC
+ 41, 2, L_FIX, // "sprmPBrcRight", // pap.brcRight BRC
+ 42, 2, L_FIX, // "sprmPBrcBetween", // pap.brcBetween BRC
+ 43, 2, L_FIX, // "sprmPBrcBar",//pap.brcBar BRC word
+ 44, 1, L_FIX, // "sprmPFNoAutoHyph",//pap.fNoAutoHyph
+ 45, 2, L_FIX, // "sprmPWHeightAbs",//pap.wHeightAbs w
+ 46, 2, L_FIX, // "sprmPDcs",//pap.dcs DCS
+ 47, 2, L_FIX, // "sprmPShd",//pap.shd SHD
+ 48, 2, L_FIX, // "sprmPDyaFromText",//pap.dyaFromText dya
+ 49, 2, L_FIX, // "sprmPDxaFromText",//pap.dxaFromText dxa
+
+ 50, 1, L_FIX, // "sprmPFLocked", // pap.fLocked 0 or 1 byte
+
+ 51, 1, L_FIX, // "sprmPFWidowControl", // pap.fWidowControl 0 or 1 byte
+
+
+ // ???
+ 52, 0, L_FIX, // "?sprmPRuler 52", //???
+
+
+ 65, 1, L_FIX, // "sprmCFStrikeRM", // chp.fRMarkDel 1 or 0 bit
+ 66, 1, L_FIX, // "sprmCFRMark", // chp.fRMark 1 or 0 bit
+ 67, 1, L_FIX, // "sprmCFFldVanish", // chp.fFldVanish 1 or 0 bit
+ 68, 0, L_VAR, // "sprmCPicLocation", // chp.fcPic and chp.fSpec
+ 69, 2, L_FIX, // "sprmCIbstRMark", // chp.ibstRMark index into sttbRMark
+
+ 70, 4, L_FIX, // "sprmCDttmRMark", // chp.dttm DTTM long
+ 71, 1, L_FIX, // "sprmCFData", // chp.fData 1 or 0 bit
+ 72, 2, L_FIX, // "sprmCRMReason", // chp.idslRMReason an index to a table
+ 73, 3, L_FIX, // "sprmCChse", // chp.fChsDiff and chp.chse see below 3 bytes
+ 74, 0, L_VAR, // "sprmCSymbol", // chp.fSpec, chp.chSym and chp.ftcSym
+ 75, 1, L_FIX, // "sprmCFOle2", // chp.fOle2 1 or 0 bit
+
+ 80, 2, L_FIX, // "sprmCIstd", // chp.istd istd, see stylesheet definition short
+ 81, 0, L_VAR, // "sprmCIstdPermute", // chp.istd permutation vector (see below)
+ 82, 0, L_VAR, // "sprmCDefault", // whole CHP (see below) none variable length
+ 83, 0, L_FIX, // "sprmCPlain", // whole CHP (see below) none 0
+ 85, 1, L_FIX, // "sprmCFBold", // chp.fBold 0,1, 128, or 129 (see below) byte
+ 86, 1, L_FIX, //"sprmCFItalic", // chp.fItalic 0,1, 128, or 129 (see below) byte
+ 87, 1, L_FIX, // "sprmCFStrike", // chp.fStrike 0,1, 128, or 129 (see below) byte
+ 88, 1, L_FIX, // "sprmCFOutline", // chp.fOutline 0,1, 128, or 129 (see below) byte
+ 89, 1, L_FIX, // "sprmCFShadow", // chp.fShadow 0,1, 128, or 129 (see below) byte
+
+ 90, 1, L_FIX, // "sprmCFSmallCaps", // chp.fSmallCaps 0,1, 128, or 129 (see below) byte
+ 91, 1, L_FIX, // "sprmCFCaps", // chp.fCaps 0,1, 128, or 129 (see below) byte
+ 92, 1, L_FIX, // "sprmCFVanish", // chp.fVanish 0,1, 128, or 129 (see below) byte
+ 93, 2, L_FIX, // "sprmCFtc", // chp.ftc ftc word
+ 94, 1, L_FIX, // "sprmCKul", // chp.kul kul byte
+ 95, 3, L_FIX, // "sprmCSizePos", // chp.hps, chp.hpsPos (see below) 3 bytes
+ 96, 2, L_FIX, // "sprmCDxaSpace", // chp.dxaSpace dxa word
+ 97, 2, L_FIX, // "sprmCLid", // chp.lid LID word
+ 98, 1, L_FIX, // "sprmCIco", // chp.ico ico byte
+ 99, 2, L_FIX, // "sprmCHps", // chp.hps hps !word!
+
+
+ 100, 1, L_FIX, // "sprmCHpsInc", // chp.hps (see below) byte
+ 101, 2, L_FIX, // "sprmCHpsPos", // chp.hpsPos hps !word!
+ 102, 1, L_FIX, // "sprmCHpsPosAdj", // chp.hpsPos hps (see below) byte
+
+
+ // ???
+ 103, 0, L_VAR, // "?sprmCMajority", // chp.fBold, chp.fItalic, chp.fSmallCaps, ...
+
+
+ 104, 1, L_FIX, // "sprmCIss", // chp.iss iss byte
+ 105, 0, L_VAR, // "sprmCHpsNew50", // chp.hps hps variable width, length always recorded as 2
+ 106, 0, L_VAR, // "sprmCHpsInc1", // chp.hps complex (see below) variable width, length always recorded as 2
+ 107, 2, L_FIX, // "sprmCHpsKern", // chp.hpsKern hps short
+ 108, 0, L_VAR, // "sprmCMajority50", // chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, ...
+ 109, 2, L_FIX, // "sprmCHpsMul", // chp.hps percentage to grow hps short
+
+ 110, 2, L_FIX, // "sprmCCondHyhen", // chp.ysri ysri short
+ 117, 1, L_FIX, // "sprmCFSpec", // chp.fSpec 1 or 0 bit
+ 118, 1, L_FIX, // "sprmCFObj", // chp.fObj 1 or 0 bit
+ 119, 1, L_FIX, // "sprmPicBrcl", // pic.brcl brcl (see PIC structure definition) byte
+
+ 120,12, L_VAR, // "sprmPicScale", // pic.mx, pic.my, pic.dxaCropleft,
+ 121, 2, L_FIX, // "sprmPicBrcTop", // pic.brcTop BRC word
+ 122, 2, L_FIX, // "sprmPicBrcLeft", // pic.brcLeft BRC word
+ 123, 2, L_FIX, // "sprmPicBrcBottom", // pic.brcBottom BRC word
+ 124, 2, L_FIX, // "sprmPicBrcRight", // pic.brcRight BRC word
+
+ 131, 1, L_FIX, // "sprmSScnsPgn", // sep.cnsPgn cns byte
+ 132, 1, L_FIX, // "sprmSiHeadingPgn", // sep.iHeadingPgn heading number level byte
+ 133, 0, L_VAR, // "sprmSOlstAnm", // sep.olstAnm OLST variable length
+ 136, 3, L_FIX, // "sprmSDxaColWidth", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 137, 3, L_FIX, // "sprmSDxaColSpacing", // sep.rgdxaColWidthSpacing complex (see below) 3 bytes
+ 138, 1, L_FIX, // "sprmSFEvenlySpaced", // sep.fEvenlySpaced 1 or 0 byte
+ 139, 1, L_FIX, // "sprmSFProtected", // sep.fUnlocked 1 or 0 byte
+
+ 140, 2, L_FIX, // "sprmSDmBinFirst", // sep.dmBinFirst word
+ 141, 2, L_FIX, // "sprmSDmBinOther", // sep.dmBinOther word
+ 142, 1, L_FIX, // "sprmSBkc", // sep.bkc bkc byte
+ 143, 1, L_FIX, // "sprmSFTitlePage", // sep.fTitlePage 0 or 1 byte
+ 144, 2, L_FIX, // "sprmSCcolumns", // sep.ccolM1 # of cols - 1 word
+ 145, 2, L_FIX, // "sprmSDxaColumns", // sep.dxaColumns dxa word
+ 146, 1, L_FIX, // "sprmSFAutoPgn", // sep.fAutoPgn obsolete byte
+ 147, 1, L_FIX, // "sprmSNfcPgn", // sep.nfcPgn nfc byte
+ 148, 2, L_FIX, // "sprmSDyaPgn", // sep.dyaPgn dya short
+ 149, 2, L_FIX, // "sprmSDxaPgn", // sep.dxaPgn dya short
+
+
+ 150, 1, L_FIX, // "sprmSFPgnRestart", // sep.fPgnRestart 0 or 1 byte
+ 151, 1, L_FIX, // "sprmSFEndnote", // sep.fEndnote 0 or 1 byte
+ 152, 1, L_FIX, // "sprmSLnc", // sep.lnc lnc byte
+ 153, 1, L_FIX, // "sprmSGprfIhdt", // sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
+ 154, 2, L_FIX, // "sprmSNLnnMod", // sep.nLnnMod non-neg int. word
+ 155, 2, L_FIX, // "sprmSDxaLnn", // sep.dxaLnn dxa word
+ 156, 2, L_FIX, // "sprmSDyaHdrTop", // sep.dyaHdrTop dya word
+ 157, 2, L_FIX, // "sprmSDyaHdrBottom", // sep.dyaHdrBottom dya word
+ 158, 1, L_FIX, // "sprmSLBetween", // sep.fLBetween 0 or 1 byte
+ 159, 1, L_FIX, // "sprmSVjc", // sep.vjc vjc byte
+
+ 160, 2, L_FIX, // "sprmSLnnMin", // sep.lnnMin lnn word
+ 161, 2, L_FIX, // "sprmSPgnStart", // sep.pgnStart pgn word
+ 162, 1, L_FIX, // "sprmSBOrientation", // sep.dmOrientPage dm byte
+ 163, 0, L_FIX, // "?SprmSBCustomize 163", //???
+ 164, 2, L_FIX, // "sprmSXaPage", // sep.xaPage xa word
+ 165, 2, L_FIX, // "sprmSYaPage", // sep.yaPage ya word
+ 166, 2, L_FIX, // "sprmSDxaLeft", // sep.dxaLeft dxa word
+ 167, 2, L_FIX, // "sprmSDxaRight", // sep.dxaRight dxa word
+ 168, 2, L_FIX, // "sprmSDyaTop", // sep.dyaTop dya word
+ 169, 2, L_FIX, // "sprmSDyaBottom", // sep.dyaBottom dya word
+
+ 170, 2, L_FIX, // "sprmSDzaGutter", // sep.dzaGutter dza word
+ 171, 2, L_FIX, // "sprmSDMPaperReq", // sep.dmPaperReq dm word
+
+ 182, 2, L_FIX, // "sprmTJc", // tap.jc jc word (low order byte is significant)
+ 183, 2, L_FIX, // "sprmTDxaLeft", // tap.rgdxaCenter (see below) dxa word
+ 184, 2, L_FIX, // "sprmTDxaGapHalf", // tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
+ 185, 1, L_FIX, // "sprmTFCantSplit", // tap.fCantSplit 1 or 0 byte
+ 186, 1, L_FIX, // "sprmTTableHeader", // tap.fTableHeader 1 or 0 byte
+ 187,12, L_FIX, // "sprmTTableBorders", // tap.rgbrcTable complex(see below) 12 bytes
+ 188, 0, L_VAR, // "sprmTDefTable10", // tap.rgdxaCenter, tap.rgtc complex (see below) variable length
+ 189, 2, L_FIX, // "sprmTDyaRowHeight", // tap.dyaRowHeight dya word
+
+ 190, 0, L_VAR2, // "sprmTDefTable", // tap.rgtc complex (see below)
+ 191, 1, L_VAR, // "sprmTDefTableShd", // tap.rgshd complex (see below)
+ 192, 4, L_FIX, // "sprmTTlp", // tap.tlp TLP 4 bytes
+ 193, 5, L_FIX, // "sprmTSetBrc", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+ 194, 4, L_FIX, // "sprmTInsert", // tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
+ 195, 2, L_FIX, // "sprmTDelete", // tap.rgdxaCenter, tap.rgtc complex (see below) word
+ 196, 4, L_FIX, // "sprmTDxaCol", // tap.rgdxaCenter complex (see below) 4 bytes
+ 197, 2, L_FIX, // "sprmTMerge", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 198, 2, L_FIX, // "sprmTSplit", // tap.fFirstMerged, tap.fMerged complex (see below) word
+ 199, 5, L_FIX, // "sprmTSetBrc10", // tap.rgtc[].rgbrc complex (see below) 5 bytes
+
+ 200, 4, L_FIX, // "sprmTSetShd", // tap.rgshd complex (see below) 4 bytes
+
+//- neue ab Ver8 ------------------------------------------------------------
+ /*
+ Die neuen Kodes werden einfach hier an die Liste angehaengt.
+ So kann ein und dieselbe Liste fuer Ver6 und Ver8 gemeinsam verwendet werden.
+ MS hat gluecklicherweise darauf geachtet, fuer Ver8 einen anderen Nummernkreis
+ zu nehmen als fuer Ver6-7.
+ */
+ 0x4600, 2, L_FIX, // "sprmPIstd" pap.istd;istd (style code);short;
+ 0xC601, 0, L_VAR, // "sprmPIstdPermute" pap.istd;permutation vector (see below);variable length;
+ 0x2602, 1, L_FIX, // "sprmPIncLvl" pap.istd, pap.lvl;difference between istd of base PAP and istd of PAP to be produced (see below);byte;
+ 0x2403, 1, L_FIX, // "sprmPJc" pap.jc;jc (justification);byte;
+ 0x2404, 1, L_FIX, // "sprmPFSideBySide" pap.fSideBySide;0 or 1;byte;
+ 0x2405, 1, L_FIX, // "sprmPFKeep" pap.fKeep;0 or 1;byte;
+ 0x2406, 1, L_FIX, // "sprmPFKeepFollow" pap.fKeepFollow;0 or 1;byte;
+ 0x2407, 1, L_FIX, // "sprmPFPageBreakBefore" pap.fPageBreakBefore;0 or 1;byte;
+ 0x2408, 1, L_FIX, // "sprmPBrcl" pap.brcl;brcl;byte;
+ 0x2409, 1, L_FIX, // "sprmPBrcp" pap.brcp;brcp;byte;
+ 0x260A, 1, L_FIX, // "sprmPIlvl" pap.ilvl;ilvl;byte;
+ 0x460B, 2, L_FIX, // "sprmPIlfo" pap.ilfo;ilfo (list index) ;short;
+ 0x240C, 1, L_FIX, // "sprmPFNoLineNumb" pap.fNoLnn;0 or 1;byte;
+ 0xC60D, 0, L_VAR, // "sprmPChgTabsPapx" pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length
+ 0x840E, 2, L_FIX, // "sprmPDxaRight" pap.dxaRight;dxa;word;
+ 0x840F, 2, L_FIX, // "sprmPDxaLeft" pap.dxaLeft;dxa;word;
+ 0x4610, 2, L_FIX, // "sprmPNest" pap.dxaLeft;dxa-see below;word;
+ 0x8411, 2, L_FIX, // "sprmPDxaLeft1" pap.dxaLeft1;dxa;word;
+ 0x6412, 4, L_FIX, // "sprmPDyaLine" pap.lspd;an LSPD, a long word structure consisting of a short of dyaLine followed by a short of fMultLinespace - see below;long;
+ 0xA413, 2, L_FIX, // "sprmPDyaBefore" pap.dyaBefore;dya;word;
+ 0xA414, 2, L_FIX, // "sprmPDyaAfter" pap.dyaAfter;dya;word;
+ 0xC615, 0, L_VAR, // "sprmPChgTabs" pap.itbdMac, pap.rgdxaTab, pap.rgtbd;complex - see below;variable length;
+ 0x2416, 1, L_FIX, // "sprmPFInTable" pap.fInTable;0 or 1;byte;
+ 0x2417, 1, L_FIX, // "sprmPFTtp" pap.fTtp;0 or 1;byte;
+ 0x8418, 2, L_FIX, // "sprmPDxaAbs" pap.dxaAbs;dxa;word;
+ 0x8419, 2, L_FIX, // "sprmPDyaAbs" pap.dyaAbs;dya;word;
+ 0x841A, 2, L_FIX, // "sprmPDxaWidth" pap.dxaWidth;dxa;word;
+ 0x261B, 1, L_FIX, // "sprmPPc" pap.pcHorz, pap.pcVert;complex - see below;byte;
+ 0x461C, 2, L_FIX, // "sprmPBrcTop10" pap.brcTop;BRC10;word;
+ 0x461D, 2, L_FIX, // "sprmPBrcLeft10" pap.brcLeft;BRC10;word;
+ 0x461E, 2, L_FIX, // "sprmPBrcBottom10" pap.brcBottom;BRC10;word;
+ 0x461F, 2, L_FIX, // "sprmPBrcRight10" pap.brcRight;BRC10;word;
+ 0x4620, 2, L_FIX, // "sprmPBrcBetween10" pap.brcBetween;BRC10;word;
+ 0x4621, 2, L_FIX, // "sprmPBrcBar10" pap.brcBar;BRC10;word;
+ 0x4622, 2, L_FIX, // "sprmPDxaFromText10" pap.dxaFromText;dxa;word;
+ 0x2423, 1, L_FIX, // "sprmPWr" pap.wr;wr (see description of PAP for definition;byte;
+ 0x6424, 4, L_FIX, // "sprmPBrcTop" pap.brcTop;BRC;long;
+ 0x6425, 4, L_FIX, // "sprmPBrcLeft" pap.brcLeft;BRC;long;
+ 0x6426, 4, L_FIX, // "sprmPBrcBottom" pap.brcBottom;BRC;long;
+ 0x6427, 4, L_FIX, // "sprmPBrcRight" pap.brcRight;BRC;long;
+ 0x6428, 4, L_FIX, // "sprmPBrcBetween" pap.brcBetween;BRC;long;
+ 0x6629, 4, L_FIX, // "sprmPBrcBar" pap.brcBar;BRC;long;
+ 0x242A, 1, L_FIX, // "sprmPFNoAutoHyph" pap.fNoAutoHyph;0 or 1;byte;
+ 0x442B, 2, L_FIX, // "sprmPWHeightAbs" pap.wHeightAbs;w;word;
+ 0x442C, 2, L_FIX, // "sprmPDcs" pap.dcs;DCS;short;
+ 0x442D, 2, L_FIX, // "sprmPShd" pap.shd;SHD;word;
+ 0x842E, 2, L_FIX, // "sprmPDyaFromText" pap.dyaFromText;dya;word;
+ 0x842F, 2, L_FIX, // "sprmPDxaFromText" pap.dxaFromText;dxa;word;
+ 0x2430, 1, L_FIX, // "sprmPFLocked" pap.fLocked;0 or 1;byte;
+ 0x2431, 1, L_FIX, // "sprmPFWidowControl" pap.fWidowControl;0 or 1;byte;
+ 0xC632, 0, L_VAR, // "sprmPRuler" ;;variable length;
+ 0x2433, 1, L_FIX, // "sprmPFKinsoku" pap.fKinsoku;0 or 1;byte;
+ 0x2434, 1, L_FIX, // "sprmPFWordWrap" pap.fWordWrap;0 or 1;byte;
+ 0x2435, 1, L_FIX, // "sprmPFOverflowPunct" pap.fOverflowPunct;0 or 1;byte;
+ 0x2436, 1, L_FIX, // "sprmPFTopLinePunct" pap.fTopLinePunct;0 or 1;byte;
+ 0x2437, 1, L_FIX, // "sprmPFAutoSpaceDE" pap.fAutoSpaceDE;0 or 1;byte;
+ 0x2438, 1, L_FIX, // "sprmPFAutoSpaceDN" pap.fAutoSpaceDN;0 or 1;byte;
+ 0x4439, 2, L_FIX, // "sprmPWAlignFont" pap.wAlignFont;iFa (see description of PAP for definition);word;
+ 0x443A, 2, L_FIX, // "sprmPFrameTextFlow" pap.fVertical pap.fBackward pap.fRotateFont;complex (see description of PAP for definition);word;
+ 0x243B, 1, L_FIX, // "sprmPISnapBaseLine" obsolete: not applicable in Word97 and later versions;;byte;
+ 0xC63E, 0, L_VAR, // "sprmPAnld" pap.anld;;variable length;
+ 0xC63F, 0, L_VAR, // "sprmPPropRMark" pap.fPropRMark;complex (see below);variable length;
+ 0x2640, 1, L_FIX, // "sprmPOutLvl" pap.lvl;has no effect if pap.istd is < 1 or is > 9;byte;
+ 0x2441, 1, L_FIX, // "sprmPFBiDi" ;;byte;
+ 0x2443, 1, L_FIX, // "sprmPFNumRMIns" pap.fNumRMIns;1 or 0;bit;
+ 0x2444, 1, L_FIX, // "sprmPCrLf" ;;byte;
+ 0xC645, 0, L_VAR, // "sprmPNumRM" pap.numrm;;variable length;
+ 0x6645, 4, L_FIX, // "sprmPHugePapx" see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x6646, 4, L_FIX, // "sprmPHugePapx" see below;fc in the data stream to locate the huge grpprl (see below);long;
+ 0x2447, 1, L_FIX, // "sprmPFUsePgsuSettings" pap.fUsePgsuSettings;1 or 0;byte;
+ 0x2448, 1, L_FIX, // "sprmPFAdjustRight" pap.fAdjustRight;1 or 0;byte;
+ 0x0800, 1, L_FIX, // "sprmCFRMarkDel" chp.fRMarkDel;1 or 0;bit;
+ 0x0801, 1, L_FIX, // "sprmCFRMark" chp.fRMark;1 or 0;bit;
+ 0x0802, 1, L_FIX, // "sprmCFFldVanish" chp.fFldVanish;1 or 0;bit;
+
+// wahrscheinlich falsch:
+//0x6A03, 0, L_VAR, // "sprmCPicLocation" chp.fcPic and chp.fSpec;see below;variable length, length recorded is always 4;
+
+// eher so:
+ 0x6A03, 4, L_FIX, // "sprmCPicLocation" chp.fcPic and chp.fSpec;see below;
+ // variable length,
+ // ????????
+ // length recorded is always 4;
+ // ====== =========
+
+ 0x4804, 2, L_FIX, // "sprmCIbstRMark" chp.ibstRMark;index into sttbRMark;short;
+ 0x6805, 4, L_FIX, // "sprmCDttmRMark" chp.dttmRMark;DTTM;long;
+ 0x0806, 1, L_FIX, // "sprmCFData" chp.fData;1 or 0;bit;
+ 0x4807, 2, L_FIX, // "sprmCIdslRMark" chp.idslRMReason;an index to a table of strings defined in Word 6.0 executables;short;
+ 0xEA08, 1, L_FIX, // "sprmCChs" chp.fChsDiff and chp.chse;see below;3 bytes;
+ 0x6A09, 4, L_FIX, // "sprmCSymbol" chp.fSpec, chp.xchSym and chp.ftcSym;see below;variable length, length recorded is always 4;
+ 0x080A, 1, L_FIX, // "sprmCFOle2" chp.fOle2;1 or 0;bit;
+//0x480B, 0, L_FIX, // "sprmCIdCharType" obsolete: not applicable in Word97 and later versions;;;
+ 0x2A0C, 1, L_FIX, // "sprmCHighlight" chp.fHighlight, chp.icoHighlight;ico (fHighlight is set to 1 iff ico is not 0);byte;
+ 0x680E, 4, L_FIX, // "sprmCObjLocation" chp.fcObj;FC;long;
+//0x2A10, 0, L_FIX, // "sprmCFFtcAsciSymb" ;;;
+ 0x4A30, 2, L_FIX, // "sprmCIstd" chp.istd;istd, see stylesheet definition;short;
+ 0xCA31, 0, L_VAR, // "sprmCIstdPermute" chp.istd;permutation vector (see below);variable length;
+ 0x2A32, 0, L_VAR, // "sprmCDefault" whole CHP (see below);none;variable length;
+ 0x2A33, 0, L_FIX, // "sprmCPlain" whole CHP (see below);none;0;
+//0x2A34, 0, L_FIX, // "sprmCKcd" ;;;
+ 0x0835, 1, L_FIX, // "sprmCFBold" chp.fBold;0,1, 128, or 129 (see below);byte;
+ 0x0836, 1, L_FIX, // "sprmCFItalic" chp.fItalic;0,1, 128, or 129 (see below);byte;
+ 0x0837, 1, L_FIX, // "sprmCFStrike" chp.fStrike;0,1, 128, or 129 (see below);byte;
+ 0x0838, 1, L_FIX, // "sprmCFOutline" chp.fOutline;0,1, 128, or 129 (see below);byte;
+ 0x0839, 1, L_FIX, // "sprmCFShadow" chp.fShadow;0,1, 128, or 129 (see below);byte;
+ 0x083A, 1, L_FIX, // "sprmCFSmallCaps" chp.fSmallCaps;0,1, 128, or 129 (see below);byte;
+ 0x083B, 1, L_FIX, // "sprmCFCaps" chp.fCaps;0,1, 128, or 129 (see below);byte;
+ 0x083C, 1, L_FIX, // "sprmCFVanish" chp.fVanish;0,1, 128, or 129 (see below);byte;
+ 0x4A3D, 2, L_FIX, // "sprmCFtcDefault" ;ftc, only used internally, never stored in file;word;
+ 0x2A3E, 1, L_FIX, // "sprmCKul" chp.kul;kul;byte;
+ 0xEA3F, 3, L_FIX, // "sprmCSizePos" chp.hps, chp.hpsPos;(see below);3 bytes;
+ 0x8840, 2, L_FIX, // "sprmCDxaSpace" chp.dxaSpace;dxa;word;
+ 0x4A41, 2, L_FIX, // "sprmCLid" ;only used internally never stored;word;
+ 0x2A42, 1, L_FIX, // "sprmCIco" chp.ico;ico;byte;
+ 0x4A43, 2, L_FIX, // "sprmCHps" chp.hps;hps;byte; ACHTUNG: ich nehme mal lieber ein: word;
+ 0x2A44, 1, L_FIX, // "sprmCHpsInc" chp.hps;(see below);byte;
+ 0x4845, 1, L_FIX, // "sprmCHpsPos" chp.hpsPos;hps;byte;
+ 0x2A46, 1, L_FIX, // "sprmCHpsPosAdj" chp.hpsPos;hps (see below);byte;
+ 0xCA47, 0, L_VAR, // "sprmCMajority" chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.rgftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico, chp.rglid;complex (see below);variable length, length byte plus size of following grpprl;
+ 0x2A48, 1, L_FIX, // "sprmCIss" chp.iss;iss;byte;
+ 0xCA49, 0, L_VAR, // "sprmCHpsNew50" chp.hps;hps;variable width, length always recorded as 2;
+ 0xCA4A, 0, L_VAR, // "sprmCHpsInc1" chp.hps;complex (see below);variable width, length always recorded as 2;
+ 0x484B, 2, L_FIX, // "sprmCHpsKern" chp.hpsKern;hps;short;
+ 0xCA4C, 2, L_FIX, // "sprmCMajority50" chp.fBold, chp.fItalic, chp.fSmallCaps, chp.fVanish, chp.fStrike, chp.fCaps, chp.ftc, chp.hps, chp.hpsPos, chp.kul, chp.dxaSpace, chp.ico,;complex (see below);variable length;
+ 0x4A4D, 2, L_FIX, // "sprmCHpsMul" chp.hps;percentage to grow hps;short;
+ 0x484E, 2, L_FIX, // "sprmCYsri" chp.ysri;ysri;short;
+ 0x4A4F, 2, L_FIX, // "sprmCRgFtc0" chp.rgftc[0];ftc for ASCII text (see below);short;
+ 0x4A50, 2, L_FIX, // "sprmCRgFtc1" chp.rgftc[1];ftc for Far East text (see below);short;
+ 0x4A51, 2, L_FIX, // "sprmCRgFtc2" chp.rgftc[2];ftc for non-Far East text (see below);short;
+//0x4852, 0, L_FIX, // "sprmCCharScale" ;;;
+ 0x2A53, 1, L_FIX, // "sprmCFDStrike" chp.fDStrike;;byte;
+ 0x0854, 1, L_FIX, // "sprmCFImprint" chp.fImprint;1 or 0;bit;
+ 0x0855, 1, L_FIX, // "sprmCFSpec" chp.fSpec ;1 or 0;bit;
+ 0x0856, 1, L_FIX, // "sprmCFObj" chp.fObj;1 or 0;bit;
+ 0xCA57, 0, L_VAR, // "sprmCPropRMark" chp.fPropRMark, chp.ibstPropRMark, chp.dttmPropRMark;Complex (see below);variable length always recorded as 7 bytes;
+ 0x0858, 1, L_FIX, // "sprmCFEmboss" chp.fEmboss;1 or 0;bit;
+ 0x2859, 1, L_FIX, // "sprmCSfxText" chp.sfxtText;text animation;byte;
+//0x085A, 0, L_FIX, // "sprmCFBiDi" ;;;
+//0x085B, 0, L_FIX, // "sprmCFDiacColor" ;;;
+//0x085C, 0, L_FIX, // "sprmCFBoldBi" ;;;
+//0x085D, 0, L_FIX, // "sprmCFItalicBi" ;;;
+//0x4A5E, 0, L_FIX, // "sprmCFtcBi" ;;;
+//0x485F, 0, L_FIX, // "sprmCLidBi" ;;;
+//0x4A60, 0, L_FIX, // "sprmCIcoBi" ;;;
+//0x4A61, 0, L_FIX, // "sprmCHpsBi" ;;;
+ 0xCA62, 0, L_VAR, // "sprmCDispFldRMark" chp.fDispFldRMark, chp.ibstDispFldRMark, chp.dttmDispFldRMark ;Complex (see below);variable length always recorded as 39 bytes;
+ 0x4863, 2, L_FIX, // "sprmCIbstRMarkDel" chp.ibstRMarkDel;index into sttbRMark;short;
+ 0x6864, 4, L_FIX, // "sprmCDttmRMarkDel" chp.dttmRMarkDel;DTTM;long;
+ 0x6865, 4, L_FIX, // "sprmCBrc" chp.brc;BRC;long;
+ 0x4866, 2, L_FIX, // "sprmCShd" chp.shd;SHD;short;
+ 0x4867, 2, L_FIX, // "sprmCIdslRMarkDel" chp.idslRMReasonDel;an index to a table of strings defined in Word 6.0 executables;short;
+ 0x0868, 1, L_FIX, // "sprmCFUsePgsuSettings" chp.fUsePgsuSettings;1 or 0;bit;
+ 0x486B, 2, L_FIX, // "sprmCCpg" ;;word;
+ 0x486D, 2, L_FIX, // "sprmCRgLid0" chp.rglid[0];LID: for non-Far East text;word;
+ 0x486E, 2, L_FIX, // "sprmCRgLid1" chp.rglid[1];LID: for Far East text;word;
+ 0x286F, 1, L_FIX, // "sprmCIdctHint" chp.idctHint;IDCT: (see below);byte;
+ 0x2E00, 1, L_FIX, // "sprmPicBrcl" pic.brcl;brcl (see PIC structure definition);byte;
+ 0xCE01, 0, L_VAR, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft, pic.dyaCropTop pic.dxaCropRight, pic.dyaCropBottom;Complex (see below);length byte plus 12 bytes;
+ 0x6C02, 4, L_FIX, // "sprmPicBrcTop" pic.brcTop;BRC;long;
+ 0x6C03, 4, L_FIX, // "sprmPicBrcLeft" pic.brcLeft;BRC;long;
+ 0x6C04, 4, L_FIX, // "sprmPicBrcBottom" pic.brcBottom;BRC;long;
+ 0x6C05, 4, L_FIX, // "sprmPicBrcRight" pic.brcRight;BRC;long;
+ 0x3000, 1, L_FIX, // "sprmScnsPgn" sep.cnsPgn;cns;byte;
+ 0x3001, 1, L_FIX, // "sprmSiHeadingPgn" sep.iHeadingPgn;heading number level;byte;
+ 0xD202, 0, L_VAR, // "sprmSOlstAnm" sep.olstAnm;OLST;variable length;
+ 0xF203, 3, L_FIX, // "sprmSDxaColWidth" sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0xF204, 3, L_FIX, // "sprmSDxaColSpacing" sep.rgdxaColWidthSpacing;complex (see below);3 bytes;
+ 0x3005, 1, L_FIX, // "sprmSFEvenlySpaced" sep.fEvenlySpaced;1 or 0;byte;
+ 0x3006, 1, L_FIX, // "sprmSFProtected" sep.fUnlocked;1 or 0;byte;
+ 0x5007, 2, L_FIX, // "sprmSDmBinFirst" sep.dmBinFirst;;word;
+ 0x5008, 2, L_FIX, // "sprmSDmBinOther" sep.dmBinOther;;word;
+ 0x3009, 1, L_FIX, // "sprmSBkc" sep.bkc;bkc;byte;
+ 0x300A, 1, L_FIX, // "sprmSFTitlePage" sep.fTitlePage;0 or 1;byte;
+ 0x500B, 2, L_FIX, // "sprmSCcolumns" sep.ccolM1;# of cols - 1;word;
+ 0x900C, 2, L_FIX, // "sprmSDxaColumns" sep.dxaColumns;dxa;word;
+ 0x300D, 1, L_FIX, // "sprmSFAutoPgn" sep.fAutoPgn;obsolete;byte;
+ 0x300E, 1, L_FIX, // "sprmSNfcPgn" sep.nfcPgn;nfc;byte;
+ 0xB00F, 2, L_FIX, // "sprmSDyaPgn" sep.dyaPgn;dya;short;
+ 0xB010, 2, L_FIX, // "sprmSDxaPgn" sep.dxaPgn;dya;short;
+ 0x3011, 1, L_FIX, // "sprmSFPgnRestart" sep.fPgnRestart;0 or 1;byte;
+ 0x3012, 1, L_FIX, // "sprmSFEndnote" sep.fEndnote;0 or 1;byte;
+ 0x3013, 1, L_FIX, // "sprmSLnc" sep.lnc;lnc;byte;
+ 0x3014, 1, L_FIX, // "sprmSGprfIhdt" sep.grpfIhdt;grpfihdt (see Headers and Footers topic);byte;
+ 0x5015, 2, L_FIX, // "sprmSNLnnMod" sep.nLnnMod;non-neg int.;word;
+ 0x9016, 2, L_FIX, // "sprmSDxaLnn" sep.dxaLnn;dxa;word;
+ 0xB017, 2, L_FIX, // "sprmSDyaHdrTop" sep.dyaHdrTop;dya;word;
+ 0xB018, 2, L_FIX, // "sprmSDyaHdrBottom" sep.dyaHdrBottom;dya;word;
+ 0x3019, 1, L_FIX, // "sprmSLBetween" sep.fLBetween;0 or 1;byte;
+ 0x301A, 1, L_FIX, // "sprmSVjc" sep.vjc;vjc;byte;
+ 0x501B, 2, L_FIX, // "sprmSLnnMin" sep.lnnMin;lnn;word;
+ 0x501C, 2, L_FIX, // "sprmSPgnStart" sep.pgnStart;pgn;word;
+ 0x301D, 1, L_FIX, // "sprmSBOrientation" sep.dmOrientPage;dm;byte;
+//0x301E, 0, L_FIX, // "sprmSBCustomize" ;;;
+
+ 0xB01F, 2, L_FIX, // "sprmSXaPage" sep.xaPage;xa;word;
+ 0xB020, 2, L_FIX, // "sprmSYaPage" sep.yaPage;ya;word;
+ 0xB021, 2, L_FIX, // "sprmSDxaLeft" sep.dxaLeft;dxa;word;
+ 0xB022, 2, L_FIX, // "sprmSDxaRight" sep.dxaRight;dxa;word;
+ 0x9023, 2, L_FIX, // "sprmSDyaTop" sep.dyaTop;dya;word;
+ 0x9024, 2, L_FIX, // "sprmSDyaBottom" sep.dyaBottom;dya;word;
+
+ 0xB025, 2, L_FIX, // "sprmSDzaGutter" sep.dzaGutter;dza;word;
+ 0x5026, 2, L_FIX, // "sprmSDmPaperReq" sep.dmPaperReq;dm;word;
+ 0xD227, 0, L_VAR, // "sprmSPropRMark" sep.fPropRMark, sep.ibstPropRMark, sep.dttmPropRMark ;complex (see below);variable length always recorded as 7 bytes;
+//0x3228, 0, L_FIX, // "sprmSFBiDi" ;;;
+//0x3229, 0, L_FIX, // "sprmSFFacingCol" ;;;
+//0x322A, 0, L_FIX, // "sprmSFRTLGutter" ;;;
+ 0x702B, 4, L_FIX, // "sprmSBrcTop" sep.brcTop;BRC;long;
+ 0x702C, 4, L_FIX, // "sprmSBrcLeft" sep.brcLeft;BRC;long;
+ 0x702D, 4, L_FIX, // "sprmSBrcBottom" sep.brcBottom;BRC;long;
+ 0x702E, 4, L_FIX, // "sprmSBrcRight" sep.brcRight;BRC;long;
+ 0x522F, 2, L_FIX, // "sprmSPgbProp" sep.pgbProp;;word;
+ 0x7030, 4, L_FIX, // "sprmSDxtCharSpace" sep.dxtCharSpace;dxt;long;
+ 0x9031, 2, L_FIX, // "sprmSDyaLinePitch" sep.dyaLinePitch;dya; WRONG:long; RIGHT:short; !!!
+//0x5032, 0, L_FIX, // "sprmSClm" ;;;
+ 0x5033, 2, L_FIX, // "sprmSTextFlow" sep.wTextFlow;complex (see below);short;
+ 0x5400, 2, L_FIX, // "sprmTJc" tap.jc;jc;word (low order byte is significant);
+ 0x9601, 2, L_FIX, // "sprmTDxaLeft" tap.rgdxaCenter (see below);dxa;word;
+ 0x9602, 2, L_FIX, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter (see below);dxa;word;
+ 0x3403, 1, L_FIX, // "sprmTFCantSplit" tap.fCantSplit;1 or 0;byte;
+ 0x3404, 1, L_FIX, // "sprmTTableHeader" tap.fTableHeader;1 or 0;byte;
+ 0xD605, 0, L_VAR, // "sprmTTableBorders" tap.rgbrcTable;complex(see below);24 bytes;
+ 0xD606, 0, L_VAR, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc;complex (see below);variable length;
+ 0x9407, 2, L_FIX, // "sprmTDyaRowHeight" tap.dyaRowHeight;dya;word;
+ 0xD608, 0, L_VAR, // "sprmTDefTable" tap.rgtc;complex (see below);;
+ 0xD609, 0, L_VAR, // "sprmTDefTableShd" tap.rgshd;complex (see below);;
+ 0x740A, 2, L_FIX, // "sprmTTlp" tap.tlp;TLP;4 bytes;
+//0x560B, 0, L_FIX, // "sprmTFBiDi" ;;;
+//0x740C, 0, L_FIX, // "sprmTHTMLProps" ;;;
+ 0xD620, 0, L_VAR, // "sprmTSetBrc" tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7621, 4, L_FIX, // "sprmTInsert" tap.rgdxaCenter, tap.rgtc;complex (see below);4 bytes;
+ 0x5622, 2, L_FIX, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc;complex (see below);word;
+ 0x7623, 2, L_FIX, // "sprmTDxaCol" tap.rgdxaCenter;complex (see below);4 bytes;
+ 0x5624, 0, L_VAR, // "sprmTMerge" tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0x5625, 0, L_VAR, // "sprmTSplit" tap.fFirstMerged, tap.fMerged;complex (see below);word;
+ 0xD626, 0, L_VAR, // "sprmTSetBrc10" tap.rgtc[].rgbrc;complex (see below);5 bytes;
+ 0x7627, 0, L_VAR, // "sprmTSetShd" tap.rgshd;complex (see below);4 bytes;
+ 0x7628, 0, L_VAR, // "sprmTSetShdOdd" tap.rgshd;complex (see below);4 bytes;
+ 0x7629, 0, L_VAR, // "sprmTTextFlow" tap.rgtc[].fVerticaltap.rgtc[].fBackwardtap.rgtc[].fRotateFont;0 or 10 or 10 or 1;word;
+//0xD62A, 0, L_FIX, // "sprmTDiagLine" ;;;
+ 0xD62B, 0, L_VAR, // "sprmTVertMerge" tap.rgtc[].vertMerge;complex (see below);variable length always recorded as 2 bytes;
+ 0xD62C, 0, L_VAR, // "sprmTVertAlign" tap.rgtc[].vertAlign;complex (see below);variable length always recorded as 3 byte;
+
+};
+
+
+
+static int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC )
+ _Optlink
+#endif
+ CompSprmId( const void *pFirst, const void *pSecond)
+{
+ return( ((SprmInfo*)pFirst )->nId - ((SprmInfo*)pSecond)->nId );
+}
+
+
+SprmInfo& WW8GetSprmInfo( USHORT nId )
+{
+ // ggfs. Tab sortieren
+ static BOOL bInit = FALSE;
+ if( !bInit )
+ {
+ qsort( (void*)aWwSprmTab,
+ sizeof( aWwSprmTab ) / sizeof (aWwSprmTab[ 0 ]),
+ sizeof( aWwSprmTab[ 0 ] ),
+ CompSprmId );
+ bInit = TRUE;
+ }
+ // Sprm heraussuchen
+ void* pFound;
+ SprmInfo aSrch;
+ aSrch.nId = nId;
+ if( 0 == ( pFound = bsearch( (char *) &aSrch,
+ (void*) aWwSprmTab,
+ sizeof( aWwSprmTab ) / sizeof (aWwSprmTab[ 0 ]),
+ sizeof( aWwSprmTab[ 0 ] ),
+ CompSprmId )))
+ {
+ // im Fehlerfall auf Nulltes Element verweisen
+ pFound = (void*)aWwSprmTab;
+ }
+ return *(SprmInfo*) pFound;
+}
+
+
+
+//-----------------------------------------
+// Sprms
+//-----------------------------------------
+
+static short WW8GetSprmSize0( USHORT nId, BYTE* pSprm, BYTE nDelta)
+{
+ SprmInfo& rSprm = WW8GetSprmInfo( nId );
+ short nL = 0; // soviel Bytes sind zu lesen
+
+ //sprmPChgTabs
+ switch( nId )
+ {
+ case 23:
+ case 0xC615:
+ if( SVBT16ToShort( &pSprm[1 + nDelta] ) != 255 )
+ nL = SVBT16ToShort( &pSprm[1 + nDelta] ) + rSprm.nLen - 1;
+ else
+ {
+ BYTE nDel = pSprm[2 + nDelta];
+ BYTE nIns = pSprm[3 + nDelta + 4 * nDel];
+
+ nL = 2 + 4 * nDel + 3 * nIns;
+ }
+ break;
+
+ case 0xd608:
+ nL = SVBT16ToShort( &pSprm[1 + nDelta] );
+ break;
+
+ default:
+ switch ( rSprm.nVari )
+ {
+ case L_FIX: nL = rSprm.nLen; // Excl. Token
+ break;
+ case L_VAR: nL = (short)pSprm[1 + nDelta]// Variable 1-Byte Laenge?
+ + rSprm.nLen; // Excl. Token + Var-Laengenbyte
+ break;
+ // case L_VAR2: nL = ( *(short*)&pSprm[1 + nDelta] ) // Variable 2-Byte Laenge?
+ case L_VAR2: nL = SVBT16ToShort( &pSprm[1 + nDelta] ) // Variable 2-Byte Laenge?
+ + rSprm.nLen - 1; // Excl. Token + Var-Laengenbyte
+ break;
+ }
+ break;
+ }
+ return nL;
+}
+
+
+USHORT WW8CountSprms( BYTE nVersion,
+ BYTE* pSp,
+ long nSprmSiz,
+ const SvUShortsSort* pIgnoreSprms )
+{
+ BYTE nDelta = ( 8 > nVersion ) ? 0 : 1;
+ USHORT nMySprms = 0;
+ for(short i=0; i+1+nDelta < nSprmSiz; )
+ {
+ USHORT nSpId = WW8GetSprmId( nVersion, pSp );
+
+ if( !nSpId )
+ break;
+
+ short nSpLen = WW8GetSprmSizeBrutto( nVersion, pSp, &nSpId );
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ i += nSpLen;
+ pSp += nSpLen;
+
+ if( !pIgnoreSprms || USHRT_MAX == pIgnoreSprms->Seek_Entry( nSpId ) )
+ {
+ ++nMySprms;
+ }
+ }
+ return nMySprms;
+}
+
+BOOL WW8PLCFx_SEPX::CompareSprms( BYTE* pOtherSprms,
+ long nOtherSprmSiz,
+ const SvUShortsSort* pIgnoreSprms ) const
+{
+ BOOL bRes = FALSE;
+ BYTE* pSp = pSprms;
+ short i;
+ BYTE nDelta = ( 8 > GetVersion()) ? 0 : 1;
+
+ if( WW8CountSprms(GetVersion(), pSp, nSprmSiz, pIgnoreSprms)
+ == WW8CountSprms(GetVersion(), pOtherSprms, nOtherSprmSiz, pIgnoreSprms) )
+ {
+ bRes = TRUE;
+ for( i=0; i+1+nDelta < nSprmSiz; )
+ {
+ USHORT nSpId = WW8GetSprmId( GetVersion(), pSp );
+
+ if( !nSpId )
+ break;
+
+ short nSpLen = WW8GetSprmSizeBrutto( GetVersion(), pSp, &nSpId );
+
+ if( !pIgnoreSprms || !pIgnoreSprms->Seek_Entry( nSpId ) )
+ {
+ BYTE* pOtherSp = HasSprm( nSpId, pOtherSprms, nOtherSprmSiz );
+
+ if( ( !pOtherSp )
+ || (0 != memcmp( pSp + 1 + nDelta + WW8SprmDataOfs( nSpId ),
+ pOtherSp,
+ WW8GetSprmSize0( nSpId, pSp, nDelta ) ) ) )
+ {
+ bRes = FALSE;
+ break;
+ }
+ }
+ // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
+ i += nSpLen;
+ pSp += nSpLen;
+ }
+ }
+ return bRes; // unterschiedliche Sprms ?
+}
+
+
+// ein bzw. zwei Byte am Anfang des Sprm sind die Id
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta )
+{
+ USHORT nId = 0;
+ if( pSp )
+ {
+ switch( nVersion ) // 6 steht fuer "6 ODER 7", 7 steht fuer "NUR 7"
+ {
+ case 6:
+ case 7: nId = *pSp;
+ if( 0x0100 < nId ) nId = 0;
+ if( pDelta ) *pDelta = 0;
+ break;
+ case 8: nId = SVBT16ToShort( &pSp[ 0 ] );
+ if( 0x0800 > nId )
+ nId = 0;
+ if( pDelta )
+ *pDelta = 1;
+ break;
+ default:ASSERT( nId, "Es wurde vergessen, nVersion zu kodieren!" );
+ }
+ }
+ return nId;
+}
+
+
+// ohne Token und LaengenByte
+short WW8GetSprmSizeNetto( BYTE nVersion, BYTE* pSprm, USHORT* pId )
+{
+ BYTE nDelta = ( 8 > nVersion ) ? 0 : 1;
+ USHORT nId = pId ? *pId : WW8GetSprmId( nVersion, pSprm );
+ return WW8GetSprmSize0( nId, pSprm, nDelta );
+}
+
+
+// mit Token und LaengenByte
+short WW8GetSprmSizeBrutto( BYTE nVersion, BYTE* pSprm, USHORT* pId )
+{
+ BYTE nDelta = ( 8 > nVersion ) ? 0 : 1;
+ USHORT nId = pId ? *pId : WW8GetSprmId( nVersion, pSprm );
+ return WW8GetSprmSize0( nId, pSprm, nDelta )
+ + 1 + nDelta
+ + WW8GetSprmInfo( nId ).nVari;
+}
+
+BYTE WW8SprmDataOfs( USHORT nId )
+{
+ return WW8GetSprmInfo( nId ).nVari;
+}
+
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8scan.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.106 2000/09/18 16:05:02 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.105 2000/08/24 06:42:57 khz
+ #75708# advance StartPos of attributes starting on a Table-Row-End by 1
+
+ Revision 1.104 2000/08/22 12:25:11 khz
+ #77550# prevent invalid SPRMs from setting pMemPos to 0x00000001
+
+ Revision 1.103 2000/08/21 15:03:01 khz
+ #77692# import page orientation
+
+ Revision 1.102 2000/08/18 09:49:57 khz
+ Skip trailing WORD (instead of BYTE) in WW8Read_xstz
+
+ Revision 1.101 2000/07/28 08:01:46 khz
+ #77183# avoid accessing pPcd when there is NO Piece Table
+
+ Revision 1.100 2000/07/19 10:36:50 khz
+ ##76458# wrong parameter calling WW8Read_xstz in WW8ReadSTTBF() ctor fixed
+
+ Revision 1.99 2000/07/12 12:24:27 khz
+ #76503# use WW8PLCFx_Cp_FKP::?etIdx2() to save/restore nIdx of pPcd
+
+ Revision 1.98 2000/06/07 12:43:18 khz
+ Changes for Unicode
+
+ Revision 1.97 2000/05/31 12:23:01 khz
+ Changes for Unicode
+
+ Revision 1.96 2000/05/25 09:55:51 hr
+ workaound for Solaris Workshop compiler, SWAPLONG -> SWAPSHORT
+
+ Revision 1.95 2000/05/25 08:06:31 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.94 2000/05/18 10:58:46 jp
+ Changes for Unicode
+
+ Revision 1.93 2000/05/16 12:13:09 jp
+ ASS_FALSE define removed
+
+ Revision 1.92 2000/05/16 11:07:52 khz
+ Unicode code-conversion
+
+ Revision 1.91 2000/05/04 07:39:27 khz
+ Task #75379# added Save() and Restore() to WW8PLCFx, WW8PLCFx_Cp_FKP, WW8PLCFxDesc (2)
+
+ Revision 1.90 2000/05/04 07:32:46 khz
+ Task #75379# added Save() and Restore() to WW8PLCFx, WW8PLCFx_Cp_FKP, WW8PLCFxDesc
+
+ Revision 1.89 2000/03/06 16:57:48 khz
+ Task #73790# Convert Filenames by methode regarding byte order (2)
+
+ Revision 1.88 2000/03/03 15:54:08 khz
+ Task #73790# Convert Filenames by methode regarding byte order
+
+ Revision 1.87 2000/02/29 13:33:19 cmc
+ #73671# Fix: Error in endnote seperator skip code
+
+ Revision 1.86 2000/02/23 17:42:59 cmc
+ #68832# Consider endnotes for header footer code
+
+ Revision 1.85 2000/02/23 13:33:48 khz
+ Task #70473# changes for unicode
+
+ Revision 1.83 2000/02/22 16:23:19 khz
+ Task #72987# Ignore Sprms covering ONLY a Tab-Row-End Char #7
+
+ Revision 1.82 2000/02/22 10:39:56 cmc
+ #73289# RowEnd Search failing due to lack of atributes of piece
+
+ Revision 1.81 2000/02/18 15:10:27 khz
+ #70473# changes for unicode
+
+ Revision 1.80 2000/02/15 09:12:54 khz
+ Task #71565# workaround because String::ConvertFromWChar cannot convert 0xF0..
+
+ Revision 1.79 2000/02/14 09:11:34 cmc
+ #72579# removed old glossary test code
+
+ Revision 1.77 2000/02/09 11:31:50 khz
+ Task #70473# char_t --> sal_Unicode
+
+ Revision 1.76 2000/02/09 08:57:28 khz
+ Task #72647# Read SPRMs that are stored in piece table grpprls (2)
+
+ Revision 1.75 2000/02/03 10:08:30 cmc
+ #72268# Allow create fib from offset, added data to STTBF
+
+ Revision 1.74 2000/02/02 18:07:47 khz
+ Task #69885# Read SPRMs that are stored in piece table grpprls
+
+ Revision 1.73 1999/12/21 08:02:45 khz
+ Task #68143# nIdx set to Zero caused Hd/Ft to get wrong sprms
+
+ Revision 1.72 1999/12/07 14:29:00 khz
+ Task #69508# import sprmPHugePapx by reading DATA stream
+
+ Revision 1.71 1999/12/07 09:53:04 khz
+ Task #67979# typo-error corrected (was '==' instead of '=')
+
+ Revision 1.70 1999/12/06 19:34:27 khz
+ Task #67979# Absolute Positioned Object must have SPRM 5 or SPRM 29
+
+ Revision 1.69 1999/11/19 15:09:24 khz
+ Task #69910# Use extra PLCF structure for field!
+
+ Revision 1.68 1999/11/03 17:20:04 khz
+ Task #68676# GPF when loading file under Solaris (reading FFN structures)
+
+ Revision 1.67 1999/10/21 15:36:25 khz
+ Import Redlining (4)
+
+ Revision 1.66 1999/10/13 21:06:47 khz
+ Import Redlining (3)
+
+ Revision 1.65 1999/10/08 09:25:29 khz
+ Import Redlining
+
+ Revision 1.64 1999/09/10 15:36:43 khz
+ CharSet matching made by TENCINFO.H::rtl_getTextEncodingFromWindowsCharset()
+
+ Revision 1.63 1999/09/09 18:16:17 khz
+ CharSet matching now done in central methode WW8SCAN.HXX::WW8GetCharSet()
+
+ Revision 1.62 1999/09/08 13:26:13 khz
+ Better performance by reducing use of SWAP..() and SVBT..To..() methods
+
+ Revision 1.61 1999/08/30 19:53:02 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.60 30 Aug 1999 21:53:02 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.59 09 Aug 1999 18:34:38 KHZ
+ Task #67543# Import of Property Modifier(variant 1) (PRM) in WW8 docs
+
+ Rev 1.58 18 Jun 1999 15:53:56 KHZ
+ Reference field (page, bookmark, footnote) part#1
+
+ Rev 1.57 15 Jun 1999 14:34:56 JP
+ for Export: FIB - read/write SttbListNames
+
+ Rev 1.56 14 Jun 1999 16:00:18 KHZ
+ Task #66411# allow import of document even when SEPX is missing completely
+
+ Rev 1.55 03 Jun 1999 16:58:56 KHZ
+ Task #66418# Nach C'tor WW8Fkp ein ''pSt->Seek( nOldPos );'' ausfuehren!
+
+ Rev 1.54 03 Jun 1999 11:42:46 KHZ
+ Task #66398# Variante 1 fuer PRM ist bei Ver67 Ok.
+
+ Rev 1.53 02 Jun 1999 17:07:46 KHZ
+ Task #66393# in WW8Cp2Fc ist *pIsUnicode bei bVer67 zu initialisieren
+
+ Rev 1.52 02 Jun 1999 09:32:44 KHZ
+ Task #66227# a) kein Unicode bei Ver67 ;-) b) Grafik in grupp. Textbox
+
+ Rev 1.51 28 May 1999 09:59:12 JP
+ Fib-CTOR: wichtige Flags fuer den W97-Export setzen
+
+ Rev 1.50 28 May 1999 09:19:22 KHZ
+ Task #66395# Return-Adresse kein komplexer Ausdruck mehr
+
+ Rev 1.49 26 May 1999 10:58:02 JP
+ Fib: einige Konstanten nachgetragen
+
+ Rev 1.48 21 May 1999 01:58:08 JP
+ Export von WW97 Format: DOP in TableStream
+
+ Rev 1.47 19 May 1999 11:12:54 JP
+ WinWord97-ExportFilter
+
+ Rev 1.46 11 May 1999 17:15:32 KHZ
+ Task #66019# FontFamily: andere Bitreihenfolge auf Solaris beachten
+
+ Rev 1.45 14 Apr 1999 14:20:12 KHZ
+ Task #61268# Solaris-Problem wegen drei vergessenen SVBT16-Umwandlungen
+
+ Rev 1.44 13 Apr 1999 16:02:28 KHZ
+ Task #61268# SVBT16 statt USHORT bei Bookmarks eingesetzt
+
+ Rev 1.43 10 Mar 1999 15:11:12 KHZ
+ Task #62521# Einlesen von Sonderzeichen
+
+ Rev 1.42 08 Mar 1999 11:48:48 KHZ
+ Task #57749# Writer kann jetzt spaltige Bereiche
+
+ Rev 1.41 26 Feb 1999 14:43:38 KHZ
+ Task #59715# Behandlung von Section breaks
+
+ Rev 1.40 25 Jan 1999 10:22:38 KHZ
+ Task #60715# in Textobjekt verankerte Grafik als Grafik importieren
+
+ Rev 1.39 19 Jan 1999 10:47:42 KHZ
+ Task #60878# WW8Cp2Fc setzt *pIsUniCode bei Non-Complex auf FALSE
+
+ Rev 1.38 18 Jan 1999 08:57:08 KHZ
+ Task #60878# WW8Dp2Fc nur dann Assertion, wenn kein pTestFlag
+
+ Rev 1.37 11 Dec 1998 11:12:38 JP
+ Task #59580# Unicode (3) - Bug behoben beim Read_Xstz
+
+ Rev 1.36 10 Dec 1998 21:29:00 JP
+ Bug #59643#: benutzerdefinierte Zeichen von Fuss-/EndNoten verarbeiten
+
+ Rev 1.35 07 Dec 1998 18:17:06 KHZ
+ Task #59580# falsches Feldende: WW8SkipField verglich mit 0x7f statt 0x1f
+
+ Rev 1.34 05 Dec 1998 17:10:26 KHZ
+ Task #59580# Unicode (3)
+
+ Rev 1.33 04 Dec 1998 20:19:50 KHZ
+ Task #58766# Textboxen mit Unicode-Inhalt
+
+ Rev 1.32 03 Dec 1998 19:10:02 KHZ
+ Task #58766# Unicode-Import (2)
+
+ Rev 1.31 03 Dec 1998 10:39:50 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.30 02 Dec 1998 16:57:02 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.29 30 Nov 1998 17:46:50 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.28 30 Nov 1998 17:30:36 KHZ
+ Task #54828# Unicode-Import
+
+ Rev 1.27 03 Nov 1998 18:29:54 KHZ
+ Task #57243# Performance-Gewinn durch Vermeiden ueberfluessiger WW8GetSprmId()
+
+ Rev 1.26 02 Nov 1998 17:58:32 KHZ
+ Task #57017# Textmarken-Namen als UNICODE-Strings
+
+ Rev 1.25 16 Oct 1998 16:12:34 KHZ
+ Task #53520# ueberpruefe Feld DRUCKDATUM in DocInfo anhand von WW-internem Feld
+
+ Rev 1.24 22 Sep 1998 19:37:42 KHZ
+ Bug #57018# Fontnamen wurden unrichtig importiert
+
+ Rev 1.23 22 Sep 1998 17:40:24 KHZ
+ Bug #56310# Kopf-/Fusszeilen in Unicode-Dokumenten jetzt korrekt
+
+ Rev 1.22 03 Sep 1998 22:15:40 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.21 27 Aug 1998 10:12:28 KHZ
+ Task #55189# Escher-Import fuer Draw, Calc und Writer
+
+ Rev 1.20 11 Aug 1998 12:26:16 KHZ
+ Task #52607# Optimierung in AdjustEnds(), GetNewSprms(), GetNoNewSprms()
+
+ Rev 1.19 30 Jul 1998 14:47:24 JP
+ Bug #54385#: wchar_t ist unter UNX ein long und kein UINT16
+
+ Rev 1.18 30 Jul 1998 00:02:54 KHZ
+ Task #53614# Grafiken, die NICHT ueber dem Text liegen (MSDFF-Quick-Hack)
+
+ Rev 1.17 29 Jul 1998 16:53:18 KHZ
+ Task #52607# Fehler in FKP (Teil 2)
+
+ Rev 1.16 29 Jul 1998 13:56:10 KHZ
+ Task #52607# Fehler in FKP
+
+ Rev 1.15 28 Jul 1998 22:27:28 KHZ
+ Task #52607# nummerierte Listen (Teil 3)
+
+ Rev 1.14 28 Jul 1998 11:05:46 KHZ
+ Task #52607# nummerierte Listen (Teil 1)
+
+ Rev 1.13 22 Jul 1998 15:32:56 KHZ
+ Task #52607#
+
+ Rev 1.12 21 Jul 1998 14:52:28 KHZ
+ Task #52607# (WW 97 Import)
+
+ Rev 1.11 21 Jul 1998 12:32:52 KHZ
+ als MSDrawingObject eingebettete Grafik (Teil 1)
+
+ Rev 1.10 16 Jul 1998 21:50:14 KHZ
+ Task #52607# Compilererror wg. (rLen *= 2) -= 2
+
+ Rev 1.9 15 Jul 1998 15:47:18 KHZ
+ Task #52607# Felder
+
+ Rev 1.8 14 Jul 1998 16:34:18 KHZ
+ Task #52607# Absatz- und Zeichen-Styles
+
+ Rev 1.7 13 Jul 1998 15:29:46 KHZ
+ Task #52607# Seitenvorlage fuer 1st Page, embed. Grafik (NICHT UEBER Text)
+
+ Rev 1.6 30 Jun 1998 21:33:20 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.5 26 Jun 1998 20:50:22 KHZ
+ Absatz-Attribute jetzt weitestgehend ok
+
+ Rev 1.4 23 Jun 1998 20:49:26 KHZ
+ verarbeitet jetzt auch mehrere FKPs
+
+ Rev 1.3 23 Jun 1998 11:24:28 KHZ
+ Zwischenstand: die meisten Zeichenattribute Ok!
+
+ Rev 1.2 18 Jun 1998 09:47:12 KHZ
+ Zwischenstand fur 396c
+
+ Rev 1.1 16 Jun 1998 18:35:30 KHZ
+ DaSi-Stand
+
+ Rev 1.0 16 Jun 1998 10:57:24 KHZ
+ Initial revision.
+
+ Rev 1.1 10 Jun 1998 17:22:32 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:29:02 KHZ
+ Initial revision.
+
+
+*************************************************************************/
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
new file mode 100644
index 000000000000..04c00a108b45
--- /dev/null
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -0,0 +1,1729 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8scan.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WW8SCAN_HXX
+#define _WW8SCAN_HXX
+
+
+#ifndef LONG_MAX
+#include <limits.h>
+#endif
+#ifndef _SAL_TYPES_H
+#include <sal/types.h>
+#endif
+#ifndef _SOLAR_H
+#include <tools/solar.h> // UINTXX
+#endif
+#ifndef _TABLE_HXX //autogen
+#include <tools/table.hxx>
+#endif
+#ifndef _DATETIME_HXX //autogen
+#include <tools/datetime.hxx>
+#endif
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+#ifndef _STRING_HXX //autogen
+#include <tools/string.hxx>
+#endif
+
+
+#define _SVSTDARR_STRINGS
+#include <svtools/svstdarr.hxx>
+
+#ifndef WW8STRUC_HXX
+#include <ww8struc.hxx> // FIB, STSHI, STD
+#endif
+
+#ifndef DELETEZ
+#define DELETEZ( p ) ( delete( p ), p = 0 )
+#endif
+
+
+//class SvStream;
+class UShortStk;
+class WW8Fib;
+class WW8ScannerBase;
+class WW8PLCFspecial;
+struct WW8PLCFxDesc;
+class WW8PLCFx_PCD;
+class SvUShortsSort;
+
+
+String WW8ReadPString( SvStream& rStrm, rtl_TextEncoding eEnc,
+ BOOL bAtEndSeekRel1 = TRUE );
+
+// Folgende Methode liest einen 2-byter-UNICODE-String ein:
+// - falls bAtEndSeekRel1 gesetzt ist, wird am Ende genau EIN Byte uebersprungen,
+// - falls nChars (die Zeichen-Anzahl, NICHT die Byte-Anzahl) nicht gesetzt ist,
+// wird das erste USHORT als Lannengenangabe interpretiert,
+// ansonsten als erstes String-Zeichen genommen.
+String WW8Read_xstz(SvStream& rStrm,
+ USHORT nChars,
+ BOOL bAtEndSeekRel1);
+
+
+// read array of strings (see MS documentation: STring TaBle stored in File)
+// returns NOT the original pascal strings but an array of converted char*
+//
+// attention: the *extra data* of each string are SKIPPED and ignored
+
+/* to be optimized like this: */
+void WW8ReadSTTBF( BOOL bVer8, SvStream& rStrm,
+ UINT32 nStart, INT32 nLen, USHORT nSkip,
+ rtl_TextEncoding eCS,
+ SvStrings &rArray, SvStrings* pExtraArray = 0 );
+
+
+
+USHORT WW8GetSprmId( BYTE nVersion, BYTE* pSp, BYTE* pDelta = 0 );
+short WW8GetSprmSizeNetto( BYTE nVersion, BYTE* pSprm, USHORT* pId );
+short WW8GetSprmSizeBrutto( BYTE nVersion, BYTE* pSprm, USHORT* pId );
+BYTE WW8SprmDataOfs( USHORT nId );
+
+struct WW8FieldDesc
+{
+ long nLen; // Gesamtlaenge ( zum Text ueberlesen )
+ WW8_CP nSCode; // Anfang Befehlscode
+ long nLCode; // Laenge
+ WW8_CP nSRes; // Anfang Ergebnis
+ long nLRes; // Laenge ( == 0, falls kein Ergebnis )
+ USHORT nId; // WW-Id fuer Felder
+ BYTE nOpt; // WW-Flags ( z.B.: vom User geaendert )
+ BOOL bCodeNest:1; // Befehl rekursiv verwendet
+ BOOL bResNest:1; // Befehl in Resultat eingefuegt
+};
+
+BOOL WW8GetFieldPara( BYTE nVersion, WW8PLCFspecial& rPLCF, WW8FieldDesc& rF );
+
+
+struct WW8PLCFxSave1
+{
+ ULONG nPLCFxPos;
+ ULONG nPLCFxPos2; // fuer PLCF_Cp_Fkp: PieceIter-Pos
+ long nPLCFxMemOfs;
+ WW8_CP nAttrStart;
+ WW8_CP nAttrEnd;
+ BOOL bLineEnd;
+};
+
+
+/*
+ u.a. fuer Felder, also genausoviele Attr wie Positionen,
+ falls Ctor-Param bNoEnd = false
+*/
+class WW8PLCFspecial // Iterator fuer PLCFs
+{
+ INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
+ BYTE* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array
+ long nIMax; // Anzahl der Elemente
+ long nIdx; // Merker, wo wir gerade sind
+ long nStru;
+
+public:
+ WW8PLCFspecial( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos = -1, BOOL bNoEnd = FALSE );
+ ~WW8PLCFspecial(){ delete( pPLCF_PosArray ); pPLCF_PosArray = 0; }
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI ) { nIdx = (long)nI; } // geht ueber Nummer
+ long GetIMax(){ return nIMax; }
+ BOOL SeekPos( long nPos ); // geht ueber FC- bzw. CP-Wert
+ // bzw. naechste groesseren Wert
+ BOOL SeekPosExact( long nPos );
+ long Where() { return ( nIdx >= nIMax ) ? LONG_MAX : pPLCF_PosArray[nIdx]; }
+ BOOL Get( long& rStart, void*& rpValue );
+ BOOL GetData( long nIdx, long& rPos, void*& rpValue );
+
+ const void* GetData( long nIdx ) const {
+ return ( nIdx >= nIMax ) ? 0 : (const void*)&pPLCF_Contents[nIdx * nStru]; }
+ long GetPos( long nIdx ){
+ return ( nIdx >= nIMax ) ? LONG_MAX : pPLCF_PosArray[nIdx]; }
+
+ WW8PLCFspecial& operator ++( int ) { nIdx++; return *this; }
+ WW8PLCFspecial& operator --( int ) { nIdx--; return *this; }
+};
+
+
+
+
+/*
+ simple Iterator for SPRMs
+*/
+class WW8SprmIter
+{
+ // these members will be updated
+ BYTE* pSprms; // remaining part of the SPRMs ( == start of akt. SPRM)
+ BYTE* pAktParams; // start of akt. SPRM's parameters
+ USHORT nAktId;
+ short nAktSizeBrutto;
+
+ // these members will *not* be updated by UpdateMyMembers()
+ BYTE nVersion;
+ BYTE nDelta;
+ short nRemLen; // length of remaining SPRMs (including akt. SPRM)
+
+ void UpdateMyMembers();
+public:
+ WW8SprmIter( BYTE* pSprms_, short nLen_, BYTE nVersion_ );
+ void SetSprms( BYTE* pSprms_, short nLen_ );
+ BYTE* operator ++( int );
+ BYTE* GetSprms() const { return ( pSprms && (0 < nRemLen) )
+ ? pSprms
+ : 0; }
+ BYTE* GetAktParams() const { return pAktParams; }
+ USHORT GetAktId() const { return nAktId; }
+};
+
+
+
+/*
+ u.a. fuer FKPs auf normale Attr., also ein Attr weniger als Positionen
+*/
+class WW8PLCF // Iterator fuer PLCFs
+{
+ INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
+ BYTE* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array
+ long nIMax; // Anzahl der Elemente
+ long nIdx;
+ long nStru;
+
+ void ReadPLCF( SvStream* pSt, long nFilePos, long nPLCF );
+
+ /*
+ Falls im Dok ein PLC fehlt und die FKPs solo dastehen,
+ machen wir uns hiermit einen PLC:
+ */
+ void GeneratePLCF( SvStream* pSt, long nPN, long ncpN );
+
+public:
+ WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos = -1 );
+
+ /*
+ folgender Ctor generiert ggfs. einen PLC aus nPN und ncpN
+ */
+ WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF,
+ long nStruct, long nStartPos, long nPN, long ncpN );
+
+ ~WW8PLCF(){ delete( pPLCF_PosArray ); pPLCF_PosArray = 0; }
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI ) { nIdx = (long)nI; }
+ long GetIMax(){ return nIMax; }
+ BOOL SeekPos( long nPos );
+ long Where();
+ BOOL Get( long& rStart, long& rEnd, void*& rpValue );
+ WW8PLCF& operator ++( int ) { if( nIdx < nIMax ) nIdx++; return *this; }
+
+ const void* GetData( long nIdx ) const {
+ return ( nIdx >= nIMax ) ? 0 : (const void*)&pPLCF_Contents[nIdx * nStru]; }
+};
+
+
+DECLARE_TABLE( WW8Pcd_FC_sortArr, INT32 )
+
+
+/*
+ fuer Piece Table (bei Schnellspeicherung)
+*/
+class WW8PLCFpcd
+{
+friend class WW8PLCFpcd_Iter;
+ WW8Pcd_FC_sortArr aFC_sort; // sorted PCD entries by FC
+ INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
+ BYTE* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array
+ long nIMax;
+ long nStru;
+
+public:
+ WW8PLCFpcd( SvStream* pSt, long nFilePos, long nPLCF, long nStruct );
+ ~WW8PLCFpcd(){ delete( pPLCF_PosArray ); }
+ ULONG FindIdx( WW8_FC nFC ) const;
+};
+
+/*
+ mehrere WW8PLCFpcd_Iter koennen auf die gleiche WW8PLCFpcd zeigen !!!
+*/
+class WW8PLCFpcd_Iter
+{
+ WW8PLCFpcd& rPLCF;
+ long nIdx;
+
+public:
+ WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, long nStartPos = -1 );
+// ~WW8PLCFpcd_Iter() {}
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI ) { nIdx = (long)nI; }
+ long GetIMax(){ return rPLCF.nIMax; }
+ BOOL SeekPos( long nPos );
+// BOOL SeekMaxMainFC( WW8Fib& rWwF, long& rMaxPosData );
+ long Where();
+ BOOL Get( long& rStart, long& rEnd, void*& rpValue );
+ ULONG FindIdx( WW8_FC nFC ) const { return rPLCF.FindIdx( nFC ); }
+ WW8PLCFpcd_Iter& operator ++( int ) { if( nIdx < rPLCF.nIMax ) nIdx++; return *this; }
+};
+
+// PLCF-Typ:
+enum ePLCFT{ CHP=0, PAP, SEP, /*HED, FNR, ENR,*/ PLCF_END };
+
+/*
+ pure virtual:
+*/
+class WW8PLCFx // virtueller Iterator fuer Piece Table Exceptions
+{
+ BYTE nVersion; // Versionsnummer des FIB
+ BOOL bIsSprm; // PLCF von Sprms oder von anderem ( Footnote, ... )
+
+public:
+ WW8PLCFx( BYTE nFibVersion, BOOL bSprm )
+ { bIsSprm = bSprm; nVersion = nFibVersion; }
+
+// virtual ~WW8PLCFx() {}
+ BOOL IsSprm() { return bIsSprm; }
+ virtual ULONG GetIdx() const = 0;
+ virtual void SetIdx( ULONG nIdx ) = 0;
+ virtual ULONG GetIdx2() const;
+ virtual void SetIdx2( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos ) = 0;
+ virtual long Where() = 0;
+// virtual BYTE* GetSprms( long& rStart, long& rEnd, long& rLen );
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int ) = 0;
+ virtual USHORT GetIstd() const { return 0xffff; }
+ virtual void Save( WW8PLCFxSave1& rSave ) const;
+ virtual void Restore( const WW8PLCFxSave1& rSave );
+ BYTE GetVersion() const { return nVersion; }
+};
+
+enum eCutT { CUT_NONE = 0, CUT_START, CUT_END, CUT_BOTH };
+
+class WW8PLCFx_PCDAttrs : public WW8PLCFx
+{
+ WW8PLCFpcd_Iter* pPcdI;
+ WW8PLCFx_PCD* pPcd;
+ BYTE** pGrpprls; // Attribute an Piece-Table
+ SVBT32 aShortSprm; // mini storage: can contain ONE sprm with
+ // 1 byte param
+ UINT16 nGrpprls; // Attribut Anzahl davon
+
+public:
+ WW8PLCFx_PCDAttrs( BYTE nVersion, WW8PLCFx_PCD* pPLCFx_PCD, WW8ScannerBase* pBase );
+ virtual ~WW8PLCFx_PCDAttrs();
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nI );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual WW8PLCFx& operator ++( int );
+
+ WW8PLCFpcd_Iter* GetIter() const { return pPcdI; }
+};
+
+class WW8PLCFx_PCD : public WW8PLCFx // Iterator fuer Piece Table
+{
+ WW8PLCFpcd_Iter* pPcdI;
+ BOOL bVer67;
+
+public:
+ WW8PLCFx_PCD( BYTE nVersion, WW8PLCFpcd* pPLCFpcd, WW8_CP nStartCp, BOOL bVer67P );
+ virtual ~WW8PLCFx_PCD();
+ virtual ULONG GetIMax() const;
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nI );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+// virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ WW8_CP AktPieceStartFc2Cp( WW8_FC nStartPos );
+ WW8_FC AktPieceStartCp2Fc( WW8_CP nCp );
+ eCutT AktPieceFc2Cp( long& rStartPos, long& rEndPos );
+ WW8PLCFpcd_Iter* GetPLCFIter() { return pPcdI; }
+
+ static INT32 TransformPieceAddress(long nfc, BOOL& bIsUnicodeAddress)
+ {
+ bIsUnicodeAddress = 0 == (0x40000000 & nfc);
+ return bIsUnicodeAddress
+ ? nfc
+ : (nfc & 0x3fffFFFF) / 2;
+ }
+ BOOL IsVersion67() const { return bVer67; }
+};
+
+
+class WW8PLCFx_Fc_FKP : public WW8PLCFx // Iterator fuer Piece Table Exceptions of Fkps
+ // arbeitet nur auf FCs, nicht auf CPs !
+ // ( Low-Level )
+{
+
+
+ class WW8Fkp // Iterator fuer Formatted Disk Page
+ {
+ struct WW8Grpprl
+ {
+ BYTE* pData;
+ USHORT nLen;
+ USHORT nIStd; // nur bei Fkp.Papx gueltig (aktuelle Style-Nr)
+ BOOL bMustDelete;
+ };
+
+ WW8Grpprl* pGrpprl; // Pointer of Meta Array (pointing
+
+ BYTE* pFkp; // gesamter Fkp
+
+ long nItemSize; // entweder 1 Byte oder ein komplettes BX
+ long nFilePos; // Offset in Stream where last read of 52 bytes took place
+ short nIdx; // Pos-Merker
+ ePLCFT ePLCF;
+ BYTE nIMax; // Anzahl der Eintraege
+ BYTE nVersion;
+
+ public:
+ WW8Fkp( BYTE nFibVer, SvStream* pFKPStrm, SvStream* pDataStrm,
+ long _nFilePos, long nItemSiz,
+ ePLCFT ePl, WW8_FC nStartFc = -1 );
+ ~WW8Fkp();
+ long GetFilePos() const { return nFilePos; }
+ ULONG GetIdx() const { return (ULONG)nIdx; }
+ void SetIdx( ULONG nI );
+ BOOL SeekPos( long nPos );
+ WW8_FC Where() { return ( nIdx<nIMax)
+ ? ((WW8_FC*)pFkp)[nIdx]
+ : LONG_MAX; }
+ WW8Fkp& operator ++( int ) { if( nIdx < nIMax ) nIdx++;
+ return *this; }
+ BYTE* Get( WW8_FC& rStart, WW8_FC& rEnd, short& rLen );
+ USHORT GetIstd() const { return pGrpprl[ nIdx ].nIStd; }
+
+ /*
+ liefert einen echten Pointer auf das Sprm vom Typ nId,
+ falls ein solches im Fkp drin ist.
+ */
+ BYTE* GetLenAndIStdAndSprms(short& rLen);
+
+ /*
+ ruft GetLenAndIStdAndSprms() auf...
+ */
+ BYTE* HasSprm( USHORT nId );
+
+ ULONG GetParaHeight() const; // fuer Header/Footer bei Papx-Fkps
+
+ BYTE GetVersion() const { return nVersion; }
+ };
+
+
+ WW8PLCFx_PCDAttrs* pPCDAttrs;
+ SvStream* pFKPStrm; // Input-File
+ SvStream* pDataStrm; // Input-File
+ WW8PLCF* pPLCF;
+ WW8Fkp* pFkp;
+ WW8_FC nStartFc;
+
+ BOOL NewFkp();
+
+protected:
+ ePLCFT ePLCF;
+
+public:
+ WW8PLCFx_Fc_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ WW8Fib& rFib, ePLCFT ePl, WW8_FC nStartFcL,
+ WW8PLCFx_PCDAttrs* pPLCFx_PCD );
+ virtual ~WW8PLCFx_Fc_FKP();
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_FC nFcPos );
+ virtual WW8_FC Where();
+ BYTE* GetSprms( WW8_FC& rStart, WW8_FC& rEnd, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ virtual USHORT GetIstd() const;
+ void GetPCDSprms( WW8PLCFxDesc& rDesc );
+ BYTE* HasSprm( USHORT nId );
+ ULONG GetParaHeight() const;
+ BOOL HasFkp() { return (0 != pFkp); }
+};
+
+// Iterator fuer Piece Table Exceptions of Fkps arbeitet auf CPs (High-Level)
+class WW8PLCFx_Cp_FKP : public WW8PLCFx_Fc_FKP
+{
+ const WW8ScannerBase& rSBase;
+ WW8PLCFx_PCD* pPcd;
+ WW8_CP nAttrStart, nAttrEnd;
+ BOOL bLineEnd : 1;
+ BOOL bComplex : 1;
+
+ void SearchParaEnd( long nOldEndCp );
+
+public:
+ WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt, const WW8ScannerBase&
+ rBase, ePLCFT ePl );
+ virtual ~WW8PLCFx_Cp_FKP();
+ void ResetAttrStartEnd();
+ ULONG GetPCDIMax() const;
+ ULONG GetPCDIdx() const;
+ void SetPCDIdx( ULONG nIdx );
+ virtual ULONG GetIdx2() const;
+ virtual void SetIdx2( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual WW8_CP Where();
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual WW8PLCFx& operator ++( int );
+ virtual void Save( WW8PLCFxSave1& rSave ) const;
+ virtual void Restore( const WW8PLCFxSave1& rSave );
+};
+
+
+
+class WW8PLCFx_SEPX : public WW8PLCFx // Iterator fuer Piece Table Exceptions of Sepx
+{
+ SvStream* pStrm;
+ WW8PLCF* pPLCF;
+ BYTE* pSprms;
+ USHORT nArrMax;
+ UINT16 nSprmSiz;
+
+public:
+ WW8PLCFx_SEPX( SvStream* pSt, SvStream* pTblxySt, WW8Fib& rFib, WW8_CP nStartCp );
+ virtual ~WW8PLCFx_SEPX();
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nIdx );
+ long GetIMax() const { return ( pPLCF ) ? pPLCF->GetIMax() : 0; }
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual void GetSprms( WW8PLCFxDesc* p );
+ virtual WW8PLCFx& operator ++( int );
+ BYTE* HasSprm( USHORT nId ) const;
+ BYTE* HasSprm( USHORT nId, BYTE n2nd ) const;
+ BYTE* HasSprm( USHORT nId, BYTE* pOtherSprms, long nOtherSprmSiz ) const;
+ BOOL Find4Sprms(USHORT nId1, USHORT nId2, USHORT nId3, USHORT nId4,
+ BYTE*& p1, BYTE*& p2, BYTE*& p3, BYTE*& p4 ) const;
+ BOOL CompareSprms( BYTE* pOtherSprms,
+ long nOtherSprmSiz,
+ const SvUShortsSort* pIgnoreSprms = 0 ) const;
+};
+
+// Iterator fuer Fuss-/Endnoten und Anmerkungen
+class WW8PLCFx_SubDoc : public WW8PLCFx
+{
+ WW8PLCF* pRef;
+ WW8PLCF* pTxt;
+
+public:
+ WW8PLCFx_SubDoc( SvStream* pSt, BYTE nVersion, WW8_CP nStartCp,
+ long nFcRef, long nLenRef,
+ long nFcTxt, long nLenTxt, long nStruc = 0 );
+ virtual ~WW8PLCFx_SubDoc();
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+
+ // liefert Reference Descriptoren
+ const void* GetData( long nIdx = -1 ) const
+ {
+ return pRef ? pRef->GetData( -1L == nIdx ? pRef->GetIdx()
+ : nIdx ) : 0;
+ }
+
+ /*
+ liefert Angabe, wo Kopf und Fusszeilen-Text zu finden ist
+ */
+ BOOL Get( long& rStart, void*& rpValue );
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ long Count() { return ( pRef ) ? pRef->GetIMax() : 0; }
+};
+
+class WW8PLCFx_FLD : public WW8PLCFx // Iterator fuer Fuss- und Endnoten
+{
+ WW8PLCFspecial* pPLCF;
+ WW8Fib& rFib;
+
+public:
+ WW8PLCFx_FLD( SvStream* pSt, WW8Fib& rMyFib, short nType, WW8_CP nStartCp );
+ virtual ~WW8PLCFx_FLD();
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual long GetNoSprms( long& rStart, long&, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ BOOL GetPara( long nIdx, WW8FieldDesc& rF );
+};
+
+enum eBookStatus { BOOK_NORMAL = 0, BOOK_IGNORE = 0x1, BOOK_ONLY_REF = 0x2 };
+
+class WW8PLCFx_Book : public WW8PLCFx // Iterator fuer Booknotes
+{
+ WW8PLCFspecial* pBook[2]; // Start- und EndPosition
+ SvStrings aBookNames; // Name
+ eBookStatus* pStatus;
+ long nIMax; // Anzahl der Booknotes
+ USHORT nIsEnd;
+public:
+ WW8PLCFx_Book( SvStream* pSt, SvStream* pTblSt, WW8Fib& rFib, WW8_CP nStartCp );
+ virtual ~WW8PLCFx_Book();
+ long GetIMax(){ return nIMax; }
+ virtual ULONG GetIdx() const;
+ virtual void SetIdx( ULONG nI );
+ virtual ULONG GetIdx2() const;
+ virtual void SetIdx2( ULONG nIdx );
+ virtual BOOL SeekPos( WW8_CP nCpPos );
+ virtual long Where();
+ virtual long GetNoSprms( long& rStart, long& rEnd, long& rLen );
+ virtual WW8PLCFx& operator ++( int );
+ const String* GetName() const
+ { return ( !nIsEnd && ( (long)(pBook[0]->GetIdx()) < nIMax ) )
+ ? aBookNames[ pBook[0]->GetIdx() ]
+ : 0;
+ }
+ WW8_CP GetStartPos() const
+ { return ( nIsEnd ) ? LONG_MAX : pBook[0]->Where(); }
+ long GetLen() const;
+ BOOL GetIsEnd() const { return ( nIsEnd ) ? TRUE : FALSE; }
+ long GetHandle() const;
+ BOOL SetStatus( WW8_CP nStartRegion, WW8_CP nEndRegion, const String& rName,
+ eBookStatus eStat );
+ eBookStatus GetStatus() const;
+};
+
+/*
+ hiermit arbeiten wir draussen:
+*/
+struct WW8PLCFManResult
+{
+ WW8_CP nCpPos; // Attribut-Anfangsposition
+ long nMemLen; // Laenge dazu
+ long nCp2OrIdx; // footnote-textpos oder Index in PLCF
+ WW8_CP nAktCp; // wird nur vom Aufrufer benutzt
+ BYTE* pMemPos; // Mem-Pos fuer Sprms
+ USHORT nSprmId; // Sprm-Id ( 0 = ungueltige Id -> ueberspringen! )
+ // (2..255) oder Pseudo-Sprm-Id (256..260)
+ // bzw. ab Winword-Ver8 die Sprm-Id (800..)
+ BYTE nFlags; // Absatz- oder Section-Anfang
+};
+
+#define MAN_ANZ_PLCF 12
+
+#define MAN_MASK_NEW_PAP 1 // neue Zeile
+#define MAN_MASK_NEW_SEP 2 // neue Section
+
+
+#define MAN_MAINTEXT 0 // Defines fuer PLCFMan-ctor
+#define MAN_FTN 1
+#define MAN_EDN 2
+#define MAN_HDFT 3
+#define MAN_AND 4
+#define MAN_TXBX 5
+#define MAN_TXBX_HDFT 6
+
+struct WW8PLCFxSaveAll
+{
+ WW8PLCFxSave1 aS[MAN_ANZ_PLCF];
+};
+
+/*
+ hiermit arbeitet der Manager drinnen:
+*/
+struct WW8PLCFxDesc
+{
+ WW8PLCFx* pPLCFx;
+ UShortStk* pIdStk;// Speicher fuer Attr-Id fuer Attr-Ende(n)
+ BYTE* pMemPos; // wo liegen die Sprm(s)
+ long nStartPos;
+ long nEndPos;
+ long nCp2OrIdx; // wo liegen die NoSprm(s)
+ long nSprmsLen; // wie viele Bytes fuer weitere Sprms / Laenge Fussnote
+ long nCpOfs; // fuer Offset Header .. Footnote
+ BOOL bFirstSprm; // fuer Erkennung erster Sprm einer Gruppe
+ BOOL bRealLineEnd; // FALSE bei Pap-Piece-Ende
+ void Save( WW8PLCFxSave1& rSave ) const;
+ void Restore( const WW8PLCFxSave1& rSave );
+};
+
+
+#ifndef DUMP
+
+class WW8PLCFMan
+{
+ long nCpO; // Origin Cp -- the basis for nNewCp
+
+ long nLineEnd; // zeigt *hinter* das <CR>
+ long nLastWhereIdxCp; // last result of WhereIdx()
+ USHORT nPLCF; // so viele PLCFe werden verwaltet
+ short nManType;
+
+ WW8PLCFxDesc aD[MAN_ANZ_PLCF];
+ WW8PLCFxDesc *pChp, *pPap, *pSep, *pFld, *pFldTxbx, *pFldTxbxHdft,
+ *pFtn, *pEdn,
+ *pBkm, *pPcd, *pPcdA, *pAnd;
+ WW8PLCFspecial *pFdoa, *pTxbx, *pTxbxBkd;
+
+ WW8Fib* pWwFib;
+ USHORT* pNoAttrScan; // Attribute komplett(!) ignorieren, die ueber n CPs
+ // aufgespannt sind; z.B. bei Char #7 (Zellen-/Zeilenende)
+
+ short WhereIdx( BOOL* pbStart, long* pPos );
+ void AdjustEnds( WW8PLCFxDesc& rDesc );
+ void GetNewSprms( WW8PLCFxDesc& rDesc );
+ void GetNewNoSprms( WW8PLCFxDesc& rDesc );
+ void GetSprmStart( short nIdx, WW8PLCFManResult* pRes );
+ void GetSprmEnd( short nIdx, WW8PLCFManResult* pRes );
+ void GetNoSprmStart( short nIdx, WW8PLCFManResult* pRes );
+ void GetNoSprmEnd( short nIdx, WW8PLCFManResult* pRes );
+ void AdvSprm( short nIdx, BOOL bStart );
+ void AdvNoSprm( short nIdx, BOOL bStart );
+
+public:
+ WW8PLCFMan( WW8ScannerBase* pBase, short nType, long nStartCp );
+ ~WW8PLCFMan();
+
+ /*
+ Where fragt, an welcher naechsten Position sich irgendein
+ Attr aendert...
+ */
+ long Where();
+
+ BOOL Get( WW8PLCFManResult* pResult );
+ WW8PLCFMan& operator ++( int );
+ USHORT GetColl() const; // liefert aktuellen Style
+ WW8PLCFx_FLD* GetFld() const;
+ WW8PLCFx_SubDoc* GetEdn() const { return (WW8PLCFx_SubDoc*)pEdn->pPLCFx; }
+ WW8PLCFx_SubDoc* GetFtn() const { return (WW8PLCFx_SubDoc*)pFtn->pPLCFx; }
+ WW8PLCFx_SubDoc* GetAtn() const { return (WW8PLCFx_SubDoc*)pAnd->pPLCFx; }
+ WW8PLCFx_Book* GetBook() const { return (WW8PLCFx_Book*)pBkm->pPLCFx; }
+ long GetCpOfs() const { return pChp->nCpOfs; } // fuer Header/Footer...
+
+ /*
+ fragt, ob *aktueller Absatz* einen Sprm diesen Typs hat
+ */
+ BYTE* HasParaSprm( USHORT nId ) const;
+
+ /*
+ fragt, ob *aktueller Textrun* einen Sprm diesen Typs hat
+ */
+ BYTE* HasCharSprm( USHORT nId ) const;
+
+ WW8PLCFx_Cp_FKP* GetChpPLCF(){ return (WW8PLCFx_Cp_FKP*)pChp->pPLCFx; }
+ WW8PLCFx_Cp_FKP* GetPapPLCF(){ return (WW8PLCFx_Cp_FKP*)pPap->pPLCFx; }
+ WW8PLCFx_SEPX* GetSepPLCF(){ return (WW8PLCFx_SEPX*)pSep->pPLCFx; }
+ WW8PLCFxDesc* GetPap(){ return pPap; }
+ void SeekPos( long nNewCp );
+ void SaveAllPLCFx( WW8PLCFxSaveAll& rSave ) const;
+ void RestoreAllPLCFx( const WW8PLCFxSaveAll& rSave );
+ WW8PLCFspecial* GetFdoa() { return pFdoa; }
+ WW8PLCFspecial* GetTxbx() { return pTxbx; }
+ WW8PLCFspecial* GetTxbxBkd(){ return pTxbxBkd; }
+ short GetManType() { return nManType; }
+};
+
+#endif // !DUMP
+
+class WW8ScannerBase
+{
+friend WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs( BYTE nVersion, WW8PLCFx_PCD* pPLCFx_PCD, WW8ScannerBase* pBase );
+friend WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream*, SvStream*, SvStream*,
+ const WW8ScannerBase&, ePLCFT );
+
+#ifdef DUMP
+friend static void DumpPLCFText( WW8_FC nPos, long nLen, long nOfs, sal_Char* pName,
+ WW8ScannerBase* pBase );
+friend static void DumpFtnShort( short nId, long nPos, long nFieldLen );
+#else
+friend WW8PLCFMan::WW8PLCFMan( WW8ScannerBase*, short, long );
+friend class SwWw8ImplReader;
+#endif
+
+ WW8Fib* pWw8Fib;
+ WW8PLCFx_Cp_FKP* pChpPLCF; // Character-Attrs
+ WW8PLCFx_Cp_FKP* pPapPLCF; // Para-Attrs
+ WW8PLCFx_SEPX* pSepPLCF; // Section-Attrs
+ WW8PLCFx_SubDoc* pFtnPLCF; // Footnotes
+ WW8PLCFx_SubDoc* pEdnPLCF; // EndNotes
+ WW8PLCFx_SubDoc* pAndPLCF; // Anmerkungen
+ WW8PLCFx_FLD* pFldPLCF; // Fields in Main Text
+ WW8PLCFx_FLD* pFldHdFtPLCF; // Fields in Header / Footer
+ WW8PLCFx_FLD* pFldTxbxPLCF; // Fields in Textboxes in Main Text
+ WW8PLCFx_FLD* pFldTxbxHdFtPLCF; // Fields in Textboxes in Header / Footer
+ WW8PLCFx_FLD* pFldFtnPLCF; // Fields in Footnotes
+ WW8PLCFx_FLD* pFldEdnPLCF; // Fields in Endnotes
+ WW8PLCFx_FLD* pFldAndPLCF; // Fields in Anmerkungen
+ WW8PLCFspecial* pMainFdoa; // Graphic Primitives in Main Text
+ WW8PLCFspecial* pHdFtFdoa; // Graphic Primitives in Header / Footer
+ WW8PLCFspecial* pMainTxbx; // Textboxen in Main Text
+ WW8PLCFspecial* pMainTxbxBkd; // Break-Deskriptoren fuer diese
+ WW8PLCFspecial* pHdFtTxbx; // TextBoxen in Header / Footer
+ WW8PLCFspecial* pHdFtTxbxBkd; // Break-Deskriptoren fuer diese
+ WW8PLCFx_Book* pBook; // Bookmarks
+
+ WW8PLCFpcd* pPiecePLCF; // fuer FastSave ( Basis-PLCF ohne Iterator )
+ WW8PLCFpcd_Iter* pPieceIter; // fuer FastSave ( Iterator dazu )
+ WW8PLCFx_PCD* pPLCFx_PCD; // dito
+ WW8PLCFx_PCDAttrs* pPLCFx_PCDAttrs;
+ BYTE** pPieceGrpprls; // Attribute an Piece-Table
+ UINT16 nPieceGrpprls; // Anzahl davon
+ USHORT nNoAttrScan; // Attribute komplett(!) ignorieren, die ueber n CPs
+ // aufgespannt sind; z.B. bei Char #7 (Zellen-/Zeilenende)
+
+ WW8PLCFpcd* OpenPieceTable( SvStream* pStr, WW8Fib* pWwF );
+ void DeletePieceTable();
+
+public:
+ WW8ScannerBase( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
+ WW8Fib* pWwF );
+ ~WW8ScannerBase();
+ BOOL AreThereFootnotes() { return pFtnPLCF->Count() > 0; };
+ BOOL AreThereEndnotes() { return pEdnPLCF->Count() > 0; };
+ static DateTime WW8DTTM2DateTime(long lDTTM);
+
+ WW8_CP WW8Fc2Cp( WW8_FC nFcPos ) const ;
+ WW8_FC WW8Cp2Fc( WW8_CP nCpPos, BOOL* pIsUnicode = 0,
+ WW8_CP* pNextPieceCp = 0, BOOL* pTestFlag = 0 ) const;
+ void SetNoAttrScan( USHORT nValue ) { nNoAttrScan = nValue; };
+
+ USHORT WW8ReadString( SvStream& rStrm, String& rStr,
+ WW8_CP nAktStartCp, long nTotalLen,
+ rtl_TextEncoding eEnc ) const;
+};
+
+
+
+
+class WW8Fib
+{
+public:
+ /*
+ von uns verlangte Programm-Version:
+ in Ctor wird geprueft, ob sie zu nFib passt
+ */
+ BYTE nVersion; // 6 steht fuer "WinWord 6 oder WinWord 95",
+ // 7 steht fuer "nur WinWord 95"
+ // 8 steht fuer "nur WinWord 97"
+ /*
+ Fehlerstatus
+ */
+ ULONG nFibError;
+ /*
+ vom Ctor aus dem FIB gelesene Daten
+ (entspricht nur ungefaehr der tatsaechlichen Struktur
+ des Winword-FIB)
+ */
+ UINT16 wIdent; // 0x0 int magic number
+ UINT16 nFib; // 0x2 FIB version written
+ UINT16 nProduct; // 0x4 product version written by
+ INT16 lid; // 0x6 language stamp---localized version;
+ WW8_PN pnNext; // 0x8
+
+ UINT16 fDot :1; // 0xa 0001
+ UINT16 fGlsy :1;
+ UINT16 fComplex :1; // 0004 when 1, file is in complex, fast-saved format.
+ UINT16 fHasPic :1; // 0008 file contains 1 or more pictures
+ UINT16 cQuickSaves :4; // 00F0 count of times file was quicksaved
+ UINT16 fEncrypted :1; //0100 1 if file is encrypted, 0 if not
+ UINT16 fWhichTblStm :1; //0200 When 0, this fib refers to the table stream
+ // named "0Table", when 1, this fib refers to the
+ // table stream named "1Table". Normally, a file
+ // will have only one table stream, but under unusual
+ // circumstances a file may have table streams with
+ // both names. In that case, this flag must be used
+ // to decide which table stream is valid.
+ // UINT16 u1 :2;
+ UINT16 fExtChar :1; // 1000 =1, when using extended character set in file
+ // UINT16 u2 :3;
+
+ UINT16 nFibBack; // 0xc
+ INT16 lKey1; // 0xe file encrypted key, only valid if fEncrypted.
+ INT16 lKey2; // 0x10 key in 2 Portionen wg. Misalignment
+ UINT8 envr; // 0x12 environment in which file was created
+ // 0 created by Win Word / 1 created by Mac Word
+ BYTE fMac :1; // 0x13 when 1, this file was last saved in the Mac environment
+ BYTE fEmptySpecial :1;
+ BYTE fLoadOverridePage :1;
+ BYTE fFuturesavedUndo :1;
+ BYTE fWord97Saved :1;
+ BYTE :3;
+
+ UINT16 chse; // 0x14 default extended character set id for text in document stream. (overidden by chp.chse)
+ // 0 = ANSI / 256 Macintosh character set.
+ UINT16 chseTables; // 0x16 default extended character set id for text in
+ // internal data structures: 0 = ANSI, 256 = Macintosh
+ WW8_FC fcMin; // 0x18 file offset of first character of text
+ WW8_FC fcMac; // 0x1c file offset of last character of text + 1
+
+ // Einschub fuer WW8 *****************************************************
+ UINT16 csw; // Count of fields in the array of "shorts"
+
+ // Marke: "rgsw" Beginning of the array of shorts
+ UINT16 wMagicCreated; // unique number Identifying the File's creator
+ // 0x6A62 is the creator ID for Word and is reserved.
+ // Other creators should choose a different value.
+ UINT16 wMagicRevised; // identifies the File's last modifier
+ UINT16 wMagicCreatedPrivate; // private data
+ UINT16 wMagicRevisedPrivate; // private data
+ /*
+ INT16 pnFbpChpFirst_W6; // not used
+ INT16 pnChpFirst_W6; // not used
+ INT16 cpnBteChp_W6; // not used
+ INT16 pnFbpPapFirst_W6; // not used
+ INT16 pnPapFirst_W6; // not used
+ INT16 cpnBtePap_W6; // not used
+ INT16 pnFbpLvcFirst_W6; // not used
+ INT16 pnLvcFirst_W6; // not used
+ INT16 cpnBteLvc_W6; // not used
+ */
+ INT16 lidFE; // Language id if document was written by Far East version
+ // of Word (i.e. FIB.fFarEast is on)
+ UINT16 clw; // Number of fields in the array of longs
+
+ // Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rglw" Beginning of the array of longs
+ WW8_FC cbMac; // 0x20 file offset of last byte written to file + 1.
+
+ // WW8_FC u4[4]; // 0x24
+ WW8_CP ccpText; // 0x34 length of main document text stream
+ WW8_CP ccpFtn; // 0x38 length of footnote subdocument text stream
+ WW8_CP ccpHdr; // 0x3c length of header subdocument text stream
+ WW8_CP ccpMcr; // 0x40 length of macro subdocument text stream
+ WW8_CP ccpAtn; // 0x44 length of annotation subdocument text stream
+ WW8_CP ccpEdn; // 0x48 length of endnote subdocument text stream
+ WW8_CP ccpTxbx; // 0x4c length of textbox subdocument text stream
+ WW8_CP ccpHdrTxbx; // 0x50 length of header textbox subdocument text stream
+
+ // Einschub fuer WW8 *****************************************************
+ INT32 pnFbpChpFirst; // when there was insufficient memory for Word to expand
+ // the PLCFbte at save time, the PLCFbte is written
+ // to the file in a linked list of 512-byte pieces
+ // starting with this pn.
+ /*
+ // folgende Felder existieren zwar so in der Datei,
+ // wir benutzen jedoch unten deklarierte General-Variablen
+ // fuer Ver67 und Ver8 gemeinsam.
+ INT32 pnChpFirst; // the page number of the lowest numbered page in the
+ // document that records CHPX FKP information
+ INT32 cpnBteChp; // count of CHPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbteChpx
+ // is less than this, the PLCFbteChpx is incomplete.
+ */
+ INT32 pnFbpPapFirst; // when there was insufficient memory for Word to expand
+ // the PLCFbte at save time, the PLCFbte is written to
+ // the file in a linked list of 512-byte pieces
+ // starting with this pn
+ /*
+ // folgende Felder existieren zwar so in der Datei,
+ // wir benutzen jedoch unten deklarierte General-Variablen
+ // fuer Ver67 und Ver8 gemeinsam.
+ INT32 pnPapFirst; // the page number of the lowest numbered page in the
+ // document that records PAPX FKP information
+ INT32 cpnBtePap; // count of PAPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbtePapx is
+ // less than this, the PLCFbtePapx is incomplete.
+ */
+ INT32 pnFbpLvcFirst; // when there was insufficient memory for Word to expand
+ // the PLCFbte at save time, the PLCFbte is written to
+ // the file in a linked list of 512-byte pieces
+ // starting with this pn
+ INT32 pnLvcFirst; // the page number of the lowest numbered page in the
+ // document that records LVC FKP information
+ INT32 cpnBteLvc; // count of LVC FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbtePapx is
+ // less than this, the PLCFbtePapx is incomplete.
+ INT32 fcIslandFirst; // ?
+ INT32 fcIslandLim; // ?
+ UINT16 cfclcb; // Number of fields in the array of FC/LCB pairs.
+
+ // Ende des Einschubs fuer WW8 *******************************************
+
+ // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
+ WW8_FC fcStshfOrig; // file offset of original allocation for STSH in table
+ // stream. During fast save Word will attempt to reuse
+ // this allocation if STSH is small enough to fit.
+ INT32 lcbStshfOrig; // 0x5c count of bytes of original STSH allocation
+ WW8_FC fcStshf; // 0x60 file offset of STSH in file.
+ INT32 lcbStshf; // 0x64 count of bytes of current STSH allocation
+ WW8_FC fcPlcffndRef; // 0x68 file offset of footnote reference PLCF.
+ INT32 lcbPlcffndRef; // 0x6c count of bytes of footnote reference PLCF
+ // == 0 if no footnotes defined in document.
+
+ WW8_FC fcPlcffndTxt; // 0x70 file offset of footnote text PLCF.
+ INT32 lcbPlcffndTxt; // 0x74 count of bytes of footnote text PLCF.
+ // == 0 if no footnotes defined in document
+
+ WW8_FC fcPlcfandRef; // 0x78 file offset of annotation reference PLCF.
+ INT32 lcbPlcfandRef; // 0x7c count of bytes of annotation reference PLCF.
+
+ WW8_FC fcPlcfandTxt; // 0x80 file offset of annotation text PLCF.
+ INT32 lcbPlcfandTxt; // 0x84 count of bytes of the annotation text PLCF
+
+ WW8_FC fcPlcfsed; // 8x88 file offset of section descriptor PLCF.
+ INT32 lcbPlcfsed; // 0x8c count of bytes of section descriptor PLCF.
+
+ WW8_FC fcPlcfpad; // 0x90 file offset of paragraph descriptor PLCF
+ INT32 lcbPlcfpad; // 0x94 count of bytes of paragraph descriptor PLCF.
+ // ==0 if file was never viewed in Outline view.
+ // Should not be written by third party creators
+
+ WW8_FC fcPlcfphe; // 0x98 file offset of PLCF of paragraph heights.
+ INT32 lcbPlcfphe; // 0x9c count of bytes of paragraph height PLCF.
+ // ==0 when file is non-complex.
+
+ WW8_FC fcSttbfglsy; // 0xa0 file offset of glossary string table.
+ INT32 lcbSttbfglsy; // 0xa4 count of bytes of glossary string table.
+ // == 0 for non-glossary documents.
+ // !=0 for glossary documents.
+
+ WW8_FC fcPlcfglsy; // 0xa8 file offset of glossary PLCF.
+ INT32 lcbPlcfglsy; // 0xac count of bytes of glossary PLCF.
+ // == 0 for non-glossary documents.
+ // !=0 for glossary documents.
+
+ WW8_FC fcPlcfhdd; // 0xb0 byte offset of header PLCF.
+ INT32 lcbPlcfhdd; // 0xb4 count of bytes of header PLCF.
+ // == 0 if document contains no headers
+
+ WW8_FC fcPlcfbteChpx; // 0xb8 file offset of character property bin table.PLCF.
+ INT32 lcbPlcfbteChpx;// 0xbc count of bytes of character property bin table PLCF.
+
+ WW8_FC fcPlcfbtePapx; // 0xc0 file offset of paragraph property bin table.PLCF.
+ INT32 lcbPlcfbtePapx;// 0xc4 count of bytes of paragraph property bin table PLCF.
+
+ WW8_FC fcPlcfsea; // 0xc8 file offset of PLCF reserved for private use. The SEA is 6 bytes long.
+ INT32 lcbPlcfsea; // 0xcc count of bytes of private use PLCF.
+
+ WW8_FC fcSttbfffn; // 0xd0 file offset of font information STTBF. See the FFN file structure definition.
+ INT32 lcbSttbfffn; // 0xd4 count of bytes in sttbfffn.
+
+ WW8_FC fcPlcffldMom; // 0xd8 offset in doc stream to the PLCF of field positions in the main document.
+ INT32 lcbPlcffldMom; // 0xdc
+
+ WW8_FC fcPlcffldHdr; // 0xe0 offset in doc stream to the PLCF of field positions in the header subdocument.
+ INT32 lcbPlcffldHdr; // 0xe4
+
+ WW8_FC fcPlcffldFtn; // 0xe8 offset in doc stream to the PLCF of field positions in the footnote subdocument.
+ INT32 lcbPlcffldFtn; // 0xec
+
+ WW8_FC fcPlcffldAtn; // 0xf0 offset in doc stream to the PLCF of field positions in the annotation subdocument.
+ INT32 lcbPlcffldAtn; // 0xf4
+
+ WW8_FC fcPlcffldMcr; // 0xf8 offset in doc stream to the PLCF of field positions in the macro subdocument.
+ INT32 lcbPlcffldMcr; // 9xfc
+
+ WW8_FC fcSttbfbkmk; // 0x100 offset in document stream of the STTBF that records bookmark names in the main document
+ INT32 lcbSttbfbkmk; // 0x104
+
+ WW8_FC fcPlcfbkf; // 0x108 offset in document stream of the PLCF that records the beginning CP offsets of bookmarks in the main document. See BKF
+ INT32 lcbPlcfbkf; // 0x10c
+
+ WW8_FC fcPlcfbkl; // 0x110 offset in document stream of the PLCF that records the ending CP offsets of bookmarks recorded in the main document. See the BKL structure definition.
+ INT32 lcbPlcfbkl; // 0x114 INT32
+
+ WW8_FC fcCmds; // 0x118 FC
+ INT32 lcbCmds; // 0x11c
+
+ WW8_FC fcPlcfmcr; // 0x120 FC
+ INT32 lcbPlcfmcr; // 0x124
+
+ WW8_FC fcSttbfmcr; // 0x128 FC
+ INT32 lcbSttbfmcr; // 0x12c
+
+ WW8_FC fcPrDrvr; // 0x130 file offset of the printer driver information (names of drivers, port etc...)
+ INT32 lcbPrDrvr; // 0x134 count of bytes of the printer driver information (names of drivers, port etc...)
+
+ WW8_FC fcPrEnvPort; // 0x138 file offset of the print environment in portrait mode.
+ INT32 lcbPrEnvPort; // 0x13c count of bytes of the print environment in portrait mode.
+
+ WW8_FC fcPrEnvLand; // 0x140 file offset of the print environment in landscape mode.
+ INT32 lcbPrEnvLand; // 0x144 count of bytes of the print environment in landscape mode.
+
+ WW8_FC fcWss; // 0x148 file offset of Window Save State data structure. See WSS.
+ INT32 lcbWss; // 0x14c count of bytes of WSS. ==0 if unable to store the window state.
+
+ WW8_FC fcDop; // 0x150 file offset of document property data structure.
+ INT32 lcbDop; // 0x154 count of bytes of document properties.
+ // cbDOP is 84 when nFib < 103
+
+
+ WW8_FC fcSttbfAssoc; // 0x158 offset to STTBF of associated strings. See STTBFASSOC.
+ INT32 cbSttbfAssoc; // 0x15C
+
+ WW8_FC fcClx; // 0x160 file offset of beginning of information for complex files.
+ INT32 lcbClx; // 0x164 count of bytes of complex file information. 0 if file is non-complex.
+
+ WW8_FC fcPlcfpgdFtn; // 0x168 file offset of page descriptor PLCF for footnote subdocument.
+ INT32 lcbPlcfpgdFtn; // 0x16C count of bytes of page descriptor PLCF for footnote subdocument.
+ // ==0 if document has not been paginated. The length of the PGD is 8 bytes.
+
+ WW8_FC fcAutosaveSource; // 0x170 file offset of the name of the original file.
+ INT32 lcbAutosaveSource; // 0x174 count of bytes of the name of the original file.
+
+ WW8_FC fcGrpStAtnOwners; // 0x178 group of strings recording the names of the owners of annotations
+ INT32 lcbGrpStAtnOwners; // 0x17C count of bytes of the group of strings
+
+ WW8_FC fcSttbfAtnbkmk; // 0x180 file offset of the sttbf that records names of bookmarks in the annotation subdocument
+ INT32 lcbSttbfAtnbkmk; // 0x184 length in bytes of the sttbf that records names of bookmarks in the annotation subdocument
+
+ // Einschubs fuer WW67 ***************************************************
+
+ // INT16 wSpare4Fib; // Reserve, muss hier nicht deklariert werden
+
+ /*
+ // folgende Felder existieren zwar so in der Datei,
+ // wir benutzen jedoch unten deklarierte General-Variablen
+ // fuer Ver67 und Ver8 gemeinsam.
+ WW8_PN pnChpFirst; // the page number of the lowest numbered page in
+ // the document that records CHPX FKP information
+ WW8_PN pnPapFirst; // the page number of the lowest numbered page in
+ // the document that records PAPX FKP information
+
+ WW8_PN cpnBteChp; // count of CHPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbteChpx is
+ // less than this, the PLCFbteChpx is incomplete.
+ WW8_PN cpnBtePap; // count of PAPX FKPs recorded in file. In non-complex
+ // files if the number of entries in the PLCFbtePapx is
+ // less than this, the PLCFbtePapx is incomplete.
+ */
+
+ // Ende des Einschubs fuer WW67 ******************************************
+
+ WW8_FC fcPlcfdoaMom; // 0x192 file offset of the FDOA (drawn object) PLCF for main document.
+ // ==0 if document has no drawn objects. The length of the FDOA is 6 bytes.
+ // ab Ver8 unused
+ INT32 lcbPlcfdoaMom; // 0x196 length in bytes of the FDOA PLCF of the main document
+ // ab Ver8 unused
+ WW8_FC fcPlcfdoaHdr; // 0x19A file offset of the FDOA (drawn object) PLCF for the header document.
+ // ==0 if document has no drawn objects. The length of the FDOA is 6 bytes.
+ // ab Ver8 unused
+ INT32 lcbPlcfdoaHdr; // 0x19E length in bytes of the FDOA PLCF of the header document
+ // ab Ver8 unused
+
+ WW8_FC fcPlcfspaMom; // offset in table stream of the FSPA PLCF for main document.
+ // == 0 if document has no office art objects
+ // war in Ver67 nur leere Reserve
+ INT32 lcbPlcfspaMom; // length in bytes of the FSPA PLCF of the main document
+ // war in Ver67 nur leere Reserve
+ WW8_FC fcPlcfspaHdr; // offset in table stream of the FSPA PLCF for header document.
+ // == 0 if document has no office art objects
+ // war in Ver67 nur leere Reserve
+ INT32 lcbPlcfspaHdr; // length in bytes of the FSPA PLCF of the header document
+ // war in Ver67 nur leere Reserve
+
+ WW8_FC fcPlcfAtnbkf; // 0x1B2 file offset of BKF (bookmark first) PLCF of the annotation subdocument
+ INT32 lcbPlcfAtnbkf; // 0x1B6 length in bytes of BKF (bookmark first) PLCF of the annotation subdocument
+
+ WW8_FC fcPlcfAtnbkl; // 0x1BA file offset of BKL (bookmark last) PLCF of the annotation subdocument
+ INT32 lcbPlcfAtnbkl; // 0x1BE length in bytes of BKL (bookmark first) PLCF of the annotation subdocument
+
+ WW8_FC fcPms; // 0x1C2 file offset of PMS (Print Merge State) information block
+ INT32 lcbPMS; // 0x1C6 length in bytes of PMS
+
+ WW8_FC fcFormFldSttbf; // 0x1CA file offset of form field Sttbf which contains strings used in form field dropdown controls
+ INT32 lcbFormFldSttbf; // 0x1CE length in bytes of form field Sttbf
+
+ WW8_FC fcPlcfendRef; // 0x1D2 file offset of PLCFendRef which points to endnote references in the main document stream
+ INT32 lcbPlcfendRef; // 0x1D6
+
+ WW8_FC fcPlcfendTxt; // 0x1DA file offset of PLCFendRef which points to endnote text in the endnote document
+ // stream which corresponds with the PLCFendRef
+ INT32 lcbPlcfendTxt; // 0x1DE
+
+ WW8_FC fcPlcffldEdn; // 0x1E2 offset to PLCF of field positions in the endnote subdoc
+ INT32 lcbPlcffldEdn; // 0x1E6
+
+ WW8_FC fcPlcfpgdEdn; // 0x1EA offset to PLCF of page boundaries in the endnote subdoc.
+ INT32 lcbPlcfpgdEdn; // 0x1EE
+
+
+ WW8_FC fcDggInfo; // offset in table stream of the office art object table data.
+ // The format of office art object table data is found in a separate document.
+ // war in Ver67 nur leere Reserve
+ INT32 lcbDggInfo; // length in bytes of the office art object table data
+ // war in Ver67 nur leere Reserve
+
+ WW8_FC fcSttbfRMark; // 0x1fa offset to STTBF that records the author abbreviations...
+ INT32 lcbSttbfRMark; // 0x1fe
+ WW8_FC fcSttbfCaption; // 0x202 offset to STTBF that records caption titles...
+ INT32 lcbSttbfCaption; // 0x206
+ WW8_FC fcSttbAutoCaption; // offset in table stream to the STTBF that records the object names and
+ // indices into the caption STTBF for objects which get auto captions.
+ INT32 lcbSttbAutoCaption; // 0x20e
+
+ WW8_FC fcPlcfwkb; // 0x212 offset to PLCF that describes the boundaries of contributing documents...
+ INT32 lcbPlcfwkb; // 0x216
+
+ WW8_FC fcPlcfspl; // offset in table stream of PLCF (of SPLS structures) that records spell check state
+ // war in Ver67 nur leere Reserve
+ INT32 lcbPlcfspl; // war in Ver67 nur leere Reserve
+
+ WW8_FC fcPlcftxbxTxt; // 0x222 ...PLCF of beginning CP in the text box subdoc
+ INT32 lcbPlcftxbxTxt; // 0x226
+ WW8_FC fcPlcffldTxbx; // 0x22a ...PLCF of field boundaries recorded in the textbox subdoc.
+ INT32 lcbPlcffldTxbx; // 0x22e
+ WW8_FC fcPlcfHdrtxbxTxt;// 0x232 ...PLCF of beginning CP in the header text box subdoc
+ INT32 lcbPlcfHdrtxbxTxt;// 0x236
+ WW8_FC fcPlcffldHdrTxbx;// 0x23a ...PLCF of field boundaries recorded in the header textbox subdoc.
+ INT32 lcbPlcffldHdrTxbx;// 0x23e
+
+ /*
+ spezielle Listenverwaltung fuer WW8
+ */
+ WW8_FC fcPlcfLst; // 0x02e2 offset in the table stream of list format information.
+ INT32 lcbPlcfLst; // 0x02e6 length
+ WW8_FC fcPlfLfo; // 0x02ea offset in the table stream of list format override information.
+ INT32 lcbPlfLfo; // 0x02ee length
+ /*
+ spezielle Break-Verwaltung fuer Text-Box-Stories in WW8
+ */
+ WW8_FC fcPlcftxbxBkd; // 0x02f2 PLCF fuer TextBox-Break-Deskriptoren im Maintext
+ INT32 lcbPlcftxbxBkd; // 0x02f6
+ WW8_FC fcPlcfHdrtxbxBkd;// 0x02fa PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
+ INT32 lcbPlcfHdrtxbxBkd;// 0x02fe
+
+ // 0x302 - 372 == ignore
+ /*
+ ListNames (skip to here!)
+ */
+ WW8_FC fcSttbListNames;// 0x0372 PLCF for Listname Table
+ INT32 lcbSttbListNames;// 0x0376
+ /*
+ General-Varaiblen, die fuer Ver67 und Ver8 verwendet werden,
+ obwohl sie in der jeweiligen DATEI verschiedene Groesse haben:
+ */
+ INT32 pnChpFirst;
+ INT32 pnPapFirst;
+ INT32 cpnBteChp;
+ INT32 cpnBtePap;
+ /*
+ nun wird lediglich noch ein Ctor benoetigt
+ */
+ WW8Fib( SvStream& rStrm, BYTE nWantedVersion,UINT32 nOffset=0 );
+
+ /* leider falsch, man braucht auch noch einen fuer den Export */
+ WW8Fib( BYTE nVersion = 6 );
+ BOOL Write( SvStream& rStrm );
+};
+
+
+class WW8Style
+{
+protected:
+ WW8Fib& rFib;
+ SvStream& rSt;
+ long nStyleStart;
+ long nStyleLen;
+// WW8_STSHI* pStishi;
+
+ UINT16 cstd; // Count of styles in stylesheet
+ UINT16 cbSTDBaseInFile; // Length of STD Base as stored in a file
+ UINT16 fStdStylenamesWritten : 1; // Are built-in stylenames stored?
+ UINT16 : 15; // Spare flags
+ UINT16 stiMaxWhenSaved; // Max sti known when this file was written
+ UINT16 istdMaxFixedWhenSaved; // How many fixed-index istds are there?
+ UINT16 nVerBuiltInNamesWhenSaved; // Current version of built-in stylenames
+ UINT16 ftcStandardChpStsh; // ftc used by StandardChpStsh for this document
+
+public:
+ WW8Style( SvStream& rSt, WW8Fib& rFibPara );
+// ~WW8Style(){ delete( pStishi ); pStishi = 0; }
+ WW8_STD* Read1STDFixed( short& rSkip, short* pcbStd );
+ WW8_STD* Read1Style( short& rSkip, String* pString, short* pcbStd );
+ const UINT16 GetCount() const { return cstd; }
+};
+
+
+class WW8Fonts
+{
+protected:
+ WW8_FFN* pFontA; // Array of Pointers to Font Description
+ // Hilfs-Vari
+ USHORT nMax; // Array-Groesse
+public:
+ WW8Fonts( SvStream& rSt, WW8Fib& rFib );
+ ~WW8Fonts(){ if( pFontA ) __DELETE( nMax )pFontA; }
+ const WW8_FFN* GetFont( USHORT nNum ) const;
+ USHORT GetMax() const { return nMax; }
+};
+
+
+#define WW8_HEADER_EVEN 0x1
+#define WW8_HEADER_ODD 0x2
+#define WW8_FOOTER_EVEN 0x4
+#define WW8_FOOTER_ODD 0x8
+#define WW8_HEADER_FIRST 0x10
+#define WW8_FOOTER_FIRST 0x20
+
+class WW8Dop // Document Properties
+{
+public:
+ /*
+ Fehlerstatus
+ */
+ ULONG nDopError;
+ /*
+ vom Ctor aus dem FIB gelesene Daten
+ (entspricht nur ungefaehr der tatsaechlichen Struktur
+ des Winword-FIB)
+ */
+ // Initialisier-Dummy:
+ BYTE nDataStart;
+ //-------------------------
+ UINT16 fFacingPages : 1; // 1 when facing pages should be printed
+ UINT16 fWidowControl : 1; // 1 when widow control is in effect. 0 when widow control disabled.
+ UINT16 fPMHMainDoc : 1; // 1 when doc is a main doc for Print Merge Helper, 0 when not; default=0
+ UINT16 grfSuppression : 2; // 0 Default line suppression storage; 0= form letter line suppression; 1= no line suppression; default=0
+ UINT16 fpc : 2; // 1 footnote position code: 0 as endnotes, 1 at bottom of page, 2 immediately beneath text
+ UINT16 : 1; // 0 unused
+ //-------------------------
+ UINT16 grpfIhdt : 8; // 0 specification of document headers and footers. See explanation under Headers and Footers topic.
+ //-------------------------
+ UINT16 rncFtn : 2; // 0 restart index for footnotes, 0 don't restart note numbering, 1 section, 2 page
+ UINT16 nFtn : 14; // 1 initial footnote number for document
+ UINT16 fOutlineDirtySave : 1; // when 1, indicates that information in the hPLCFpad should be refreshed since outline has been dirtied
+ UINT16 : 7; // reserved
+ UINT16 fOnlyMacPics : 1; // when 1, Word believes all pictures recorded in the document were created on a Macintosh
+ UINT16 fOnlyWinPics : 1; // when 1, Word believes all pictures recorded in the document were created in Windows
+ UINT16 fLabelDoc : 1; // when 1, document was created as a print merge labels document
+ UINT16 fHyphCapitals : 1; // when 1, Word is allowed to hyphenate words that are capitalized. When 0, capitalized may not be hyphenated
+ UINT16 fAutoHyphen : 1; // when 1, Word will hyphenate newly typed text as a background task
+ UINT16 fFormNoFields : 1;
+ UINT16 fLinkStyles : 1; // when 1, Word will merge styles from its template
+ UINT16 fRevMarking : 1; // when 1, Word will mark revisions as the document is edited
+ UINT16 fBackup : 1; // always make backup when document saved when 1.
+ UINT16 fExactCWords : 1;
+ UINT16 fPagHidden : 1; //
+ UINT16 fPagResults : 1;
+ UINT16 fLockAtn : 1; // when 1, annotations are locked for editing
+ UINT16 fMirrorMargins : 1; // swap margins on left/right pages when 1.
+ UINT16 fReadOnlyRecommended : 1;// user has recommended that this doc be opened read-only when 1
+ UINT16 fDfltTrueType : 1; // when 1, use TrueType fonts by default (flag obeyed only when doc was created by WinWord 2.x)
+ UINT16 fPagSuppressTopSpacing : 1;//when 1, file created with SUPPRESSTOPSPACING=YES in win.ini. (flag obeyed only when doc was created by WinWord 2.x).
+ UINT16 fProtEnabled : 1; // when 1, document is protected from edit operations
+ UINT16 fDispFormFldSel : 1;// when 1, restrict selections to occur only within form fields
+ UINT16 fRMView : 1; // when 1, show revision markings on screen
+ UINT16 fRMPrint : 1; // when 1, print revision marks when document is printed
+ UINT16 fWriteReservation : 1;
+ UINT16 fLockRev : 1; // when 1, the current revision marking state is locked
+ UINT16 fEmbedFonts : 1; // when 1, document contains embedded True Type fonts
+ // compatability options
+ UINT16 copts_fNoTabForInd : 1; // when 1, don’t add automatic tab stops for hanging indent
+ UINT16 copts_fNoSpaceRaiseLower : 1; // when 1, don’t add extra space for raised or lowered characters
+ UINT16 copts_fSupressSpbfAfterPgBrk : 1; // when 1, supress the paragraph Space Before and Space After options after a page break
+ UINT16 copts_fWrapTrailSpaces : 1; // when 1, wrap trailing spaces at the end of a line to the next line
+ UINT16 copts_fMapPrintTextColor : 1; // when 1, print colors as black on non-color printers
+ UINT16 copts_fNoColumnBalance : 1; // when 1, don’t balance columns for Continuous Section starts
+ UINT16 copts_fConvMailMergeEsc : 1;
+ UINT16 copts_fSupressTopSpacing : 1; // when 1, supress extra line spacing at top of page
+ UINT16 copts_fOrigWordTableRules : 1; // when 1, combine table borders like Word 5.x for the Macintosh
+ UINT16 copts_fTransparentMetafiles : 1; // when 1, don’t blank area between metafile pictures
+ UINT16 copts_fShowBreaksInFrames : 1; // when 1, show hard page or column breaks in frames
+ UINT16 copts_fSwapBordersFacingPgs : 1; // when 1, swap left and right pages on odd facing pages
+
+ INT16 dxaTab; // 720 twips default tab width
+ UINT16 wSpare; //
+ UINT16 dxaHotZ; // width of hyphenation hot zone measured in twips
+ UINT16 cConsecHypLim; // number of lines allowed to have consecutive hyphens
+ UINT16 wSpare2; // reserved
+ INT32 dttmCreated; // DTTM date and time document was created
+ INT32 dttmRevised; // DTTM date and time document was last revised
+ INT32 dttmLastPrint; // DTTM date and time document was last printed
+ INT16 nRevision; // number of times document has been revised since its creation
+ INT32 tmEdited; // time document was last edited
+ INT32 cWords; // count of words tallied by last Word Count execution
+ INT32 cCh; // count of characters tallied by last Word Count execution
+ INT16 cPg; // count of pages tallied by last Word Count execution
+ INT32 cParas; // count of paragraphs tallied by last Word Count execution
+ UINT16 rncEdn : 2; // restart endnote number code: 0 don’t restart endnote numbering, 1 section, 2 page
+ UINT16 nEdn : 14; // beginning endnote number
+ UINT16 epc : 2; // endnote position code: 0 at end of section, 3 at end of document
+ // UINT16 nfcFtnRef : 4; // number format code for auto footnotes: 0 Arabic, 1 Upper case Roman, 2 Lower case Roman
+ // 3 Upper case Letter, 4 Lower case Letter
+ // ersetzt durch gleichlautendes Feld unten
+ // UINT16 nfcEdnRef : 4; // number format code for auto endnotes: 0 Arabic, 1 Upper case Roman, 2 Lower case Roman
+ // 3 Upper case Letter, 4 Lower case Letter
+ // ersetzt durch gleichlautendes Feld unten
+ UINT16 fPrintFormData : 1; // only print data inside of form fields
+ UINT16 fSaveFormData : 1; // only save document data that is inside of a form field.
+ UINT16 fShadeFormData : 1; // shade form fields
+ UINT16 : 2; // reserved
+ UINT16 fWCFtnEdn : 1; // when 1, include footnotes and endnotes in word count
+ INT32 cLines; // count of lines tallied by last Word Count operation
+ INT32 cWordsFtnEnd; // count of words in footnotes and endnotes tallied by last Word Count operation
+ INT32 cChFtnEdn; // count of characters in footnotes and endnotes tallied by last Word Count operation
+ INT16 cPgFtnEdn; // count of pages in footnotes and endnotes tallied by last Word Count operation
+ INT32 cParasFtnEdn; // count of paragraphs in footnotes and endnotes tallied by last Word Count operation
+ INT32 cLinesFtnEdn; // count of paragraphs in footnotes and endnotes tallied by last Word Count operation
+ INT32 lKeyProtDoc; // document protection password key, only valid if dop.fProtEnabled, dop.fLockAtn or dop.fLockRev are 1.
+ UINT16 wvkSaved : 3; // document view kind: 0 Normal view, 1 Outline view, 2 Page View
+ UINT16 wScaleSaved : 9; //
+ UINT16 zkSaved : 2;
+
+ // hier sollte bei nFib < 103 Schluss sein, sonst ist Datei fehlerhaft!
+
+ /*
+ bei nFib >= 103 gehts weiter:
+ */
+ UINT32 fNoTabForInd :1; // see above in compatability options
+ UINT32 fNoSpaceRaiseLower :1; // see above
+ UINT32 fSupressSpbfAfterPageBreak :1; // see above
+ UINT32 fWrapTrailSpaces :1; // see above
+ UINT32 fMapPrintTextColor :1; // see above
+ UINT32 fNoColumnBalance :1; // see above
+ UINT32 fConvMailMergeEsc :1; // see above
+ UINT32 fSupressTopSpacing :1; // see above
+ UINT32 fOrigWordTableRules :1; // see above
+ UINT32 fTransparentMetafiles :1; // see above
+ UINT32 fShowBreaksInFrames :1; // see above
+ UINT32 fSwapBordersFacingPgs :1; // see above
+ UINT32 :4; // reserved
+ UINT32 fSuppressTopSpacingMac5 :1; // Suppress extra line spacing at top
+ // of page like MacWord 5.x
+ UINT32 fTruncDxaExpand :1; // Expand/Condense by whole number of points
+ UINT32 fPrintBodyBeforeHdr :1; // Print body text before header/footer
+ UINT32 fNoLeading :1; // Don't add extra spacebetween rows of text
+ UINT32 :1; // reserved
+ UINT32 fMWSmallCaps :1; // Use larger small caps like MacWord 5.x
+ UINT32 :10;// reserved
+
+ // hier sollte bei nFib <= 105 Schluss sein, sonst ist Datei fehlerhaft!
+
+ /*
+ bei nFib > 105 gehts weiter:
+ */
+ INT16 adt; // Autoformat Document Type:
+ // 0 for normal. 1 for letter, and 2 for email.
+ WW8_DOPTYPOGRAPHY doptypography; // siehe WW8STRUC.HXX
+ WW8_DOGRID dogrid; // siehe WW8STRUC.HXX
+ UINT16 :1; // reserved
+ UINT16 lvl :4; // Which outline levels are showing in outline view
+ UINT16 :4; // reserved
+ UINT16 fHtmlDoc :1; // This file is based upon an HTML file
+ UINT16 :1; // reserved
+ UINT16 fSnapBorder :1; // Snap table and page borders to page border
+ UINT16 fIncludeHeader :1; // Place header inside page border
+ UINT16 fIncludeFooter :1; // Place footer inside page border
+ UINT16 fForcePageSizePag :1; // Are we in online view
+ UINT16 fMinFontSizePag :1; // Are we auto-promoting
+ // fonts to >= hpsZoonFontPag?
+ UINT16 fHaveVersions :1; // versioning is turned on
+ UINT16 fAutoVersion :1; // autoversioning is enabled
+ UINT16 :14; // reserved
+ // hier 12 Byte ueberspringen: ASUMI
+ INT32 cChWS;
+ INT32 cChWSFtnEdn;
+ INT32 grfDocEvents;
+ // hier 4+30+8 Bytes ueberspringen
+ INT32 cDBC;
+ INT32 cDBCFtnEdn;
+ // hier 4 Bytes ueberspringen
+ INT16 nfcFtnRef;
+ INT16 nfcEdnRef;
+ INT16 hpsZoonFontPag;
+ INT16 dywDispPag;
+
+ // 2. Initialisier-Dummy:
+ BYTE nDataEnd;
+
+ /*
+ nun wird lediglich noch ein Ctor benoetigt,
+ dem die FIB-Nummer uebergeben werden muss
+ */
+ WW8Dop( SvStream& rSt, INT16 nFib, INT32 nPos, INT32 nSize );
+
+ /* leider falsch, man braucht auch noch einen fuer den Export */
+ WW8Dop();
+ BOOL Write( SvStream& rStrm, WW8Fib& rFib );
+};
+
+
+inline short WW8SkipOdd(SvStream* pSt )
+{
+#if defined HP9000 || defined SINIX
+ short bRet = pSt->Tell() & 0x1;
+ if (bRet) {
+ UINT8 c;
+ pSt->Read( &c, 1 );
+ }
+ return bRet;
+#else
+ if ( pSt->Tell() & 0x1 ){
+ UINT8 c;
+ pSt->Read( &c, 1 );
+ return 1;
+ }
+ return 0;
+#endif
+}
+
+
+class WW8PLCF_HdFt
+{
+ WW8PLCF aPLCF;
+ long nTextOfs;
+ short nIdxOffset;
+
+public:
+ WW8PLCF_HdFt( SvStream* pSt, WW8Fib& rFib, WW8Dop& rDop );
+// ~WW8PLCF_HdFt() {}
+ BOOL GetTextPos( BYTE grpfIhdt, BYTE nWhich, WW8_CP& rStart, long& rLen );
+ BOOL GetTextPosExact( short nIdx, WW8_CP& rStart, long& rLen );
+ void UpdateIndex( BYTE grpfIhdt );
+};
+
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8scan.hxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.58 2000/09/18 16:05:02 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.57 2000/08/24 06:43:01 khz
+ #75708# advance StartPos of attributes starting on a Table-Row-End by 1
+
+ Revision 1.56 2000/07/12 12:24:54 khz
+ #76503# use WW8PLCFx_Cp_FKP::?etIdx2() to save/restore nIdx of pPcd
+
+ Revision 1.55 2000/05/31 12:23:05 khz
+ Changes for Unicode
+
+ Revision 1.54 2000/05/25 08:06:37 khz
+ Piece Table optimization, Unicode changes, Bugfixes
+
+ Revision 1.53 2000/05/18 10:58:50 jp
+ Changes for Unicode
+
+ Revision 1.52 2000/05/16 12:13:13 jp
+ ASS_FALSE define removed
+
+ Revision 1.51 2000/05/16 11:07:47 khz
+ Unicode code-conversion
+
+ Revision 1.50 2000/05/12 08:29:03 khz
+ Changes for Unicode
+
+ Revision 1.49 2000/05/04 07:32:05 khz
+ Task #75379# added Save() and Restore() to WW8PLCFx, WW8PLCFx_Cp_FKP, WW8PLCFxDesc
+
+ Revision 1.48 2000/02/22 16:23:14 khz
+ Task #72987# Ignore Sprms covering ONLY a Tab-Row-End Char #7
+
+ Revision 1.47 2000/02/09 08:57:36 khz
+ Task #72647# Read SPRMs that are stored in piece table grpprls (2)
+
+ Revision 1.46 2000/02/03 10:08:31 cmc
+ #72268# Allow create fib from offset, added data to STTBF
+
+ Revision 1.45 2000/02/02 18:07:51 khz
+ Task #69885# Read SPRMs that are stored in piece table grpprls
+
+ Revision 1.44 1999/12/07 14:29:04 khz
+ Task #69508# import sprmPHugePapx by reading DATA stream
+
+ Revision 1.43 1999/11/19 15:09:24 khz
+ Task #69910# Use extra PLCF structure for field!
+
+ Revision 1.42 1999/11/03 17:18:02 khz
+ import new TOX_CONTENT and TOX_INDEX features (2)
+
+ Revision 1.41 1999/10/21 15:36:21 khz
+ Import Redlining (4)
+
+ Revision 1.40 1999/10/13 21:06:47 khz
+ Import Redlining (3)
+
+ Revision 1.39 1999/10/08 09:25:29 khz
+ Import Redlining
+
+ Revision 1.38 1999/09/10 15:36:39 khz
+ CharSet matching made by TENCINFO.H::rtl_getTextEncodingFromWindowsCharset()
+
+ Revision 1.37 1999/09/09 18:16:13 khz
+ CharSet matching now done in central methode WW8SCAN.HXX::WW8GetCharSet()
+
+ Revision 1.36 1999/09/08 13:26:17 khz
+ Better performance by reducing use of SWAP..() and SVBT..To..() methods
+
+ Revision 1.35 1999/08/30 19:53:04 JP
+ Bug #68219#: no static members - be reentrant
+
+
+ Rev 1.34 30 Aug 1999 21:53:04 JP
+ Bug #68219#: no static members - be reentrant
+
+ Rev 1.33 09 Aug 1999 18:35:10 KHZ
+ Task #67543# Import of Property Modifier(variant 1) (PRM) in WW8 docs
+
+ Rev 1.32 15 Jun 1999 14:34:58 JP
+ for Export: FIB - read/write SttbListNames
+
+ Rev 1.31 02 Jun 1999 09:32:44 KHZ
+ Task #66227# a) kein Unicode bei Ver67 ;-) b) Grafik in grupp. Textbox
+
+ Rev 1.30 19 May 1999 11:12:56 JP
+ WinWord97-ExportFilter
+
+ Rev 1.29 28 Apr 1999 23:03:28 KHZ
+ Task #65245# Breite eines Rahmens bei WW 'automatisch' muss PRTAREA sein
+
+ Rev 1.28 26 Feb 1999 14:43:36 KHZ
+ Task #59715# Behandlung von Section breaks
+
+ Rev 1.27 25 Jan 1999 10:22:38 KHZ
+ Task #60715# in Textobjekt verankerte Grafik als Grafik importieren
+
+ Rev 1.26 18 Jan 1999 08:53:08 KHZ
+ Task #60878# WW8Read_xstz nur dann Assertion, wenn kein pTestFlag
+
+ Rev 1.25 10 Dec 1998 21:29:02 JP
+ Bug #59643#: benutzerdefinierte Zeichen von Fuss-/EndNoten verarbeiten
+
+ Rev 1.24 05 Dec 1998 17:10:26 KHZ
+ Task #59580# Unicode (3)
+
+ Rev 1.23 04 Dec 1998 20:19:48 KHZ
+ Task #58766# Textboxen mit Unicode-Inhalt
+
+ Rev 1.22 03 Dec 1998 19:10:00 KHZ
+ Task #58766# Unicode-Import (2)
+
+ Rev 1.20 30 Nov 1998 17:46:52 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.21 02 Dec 1998 15:34:32 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.20 30 Nov 1998 17:46:52 JP
+ Task #59822#: OLE-Objecte importieren
+
+ Rev 1.19 30 Nov 1998 17:30:36 KHZ
+ Task #54828# Unicode-Import
+
+ Rev 1.18 03 Nov 1998 18:29:52 KHZ
+ Task #57243# Performance-Gewinn durch Vermeiden ueberfluessiger WW8GetSprmId()
+
+ Rev 1.17 02 Nov 1998 17:58:32 KHZ
+ Task #57017# Textmarken-Namen als UNICODE-Strings
+
+ Rev 1.16 16 Oct 1998 16:12:34 KHZ
+ Task #53520# ueberpruefe Feld DRUCKDATUM in DocInfo anhand von WW-internem Feld
+
+ Rev 1.15 22 Sep 1998 17:40:22 KHZ
+ Bug #56310# Kopf-/Fusszeilen in Unicode-Dokumenten jetzt korrekt
+
+ Rev 1.14 03 Sep 1998 22:15:40 KHZ
+ Task #55189# Textboxen
+
+ Rev 1.13 11 Aug 1998 12:25:16 KHZ
+ Task #52607# Optimierung in AdjustEnds(), GetNewSprms(), GetNoNewSprms()
+
+ Rev 1.12 30 Jul 1998 00:02:54 KHZ
+ Task #53614# Grafiken, die NICHT ueber dem Text liegen (MSDFF-Quick-Hack)
+
+ Rev 1.11 28 Jul 1998 11:05:46 KHZ
+ Task #52607# nummerierte Listen (Teil 1)
+
+ Rev 1.10 22 Jul 1998 15:39:32 KHZ
+ Task #52607#
+
+ Rev 1.9 22 Jul 1998 15:33:28 KHZ
+ Task #52607#
+
+ Rev 1.8 21 Jul 1998 14:52:30 KHZ
+ Task #52607# (WW 97 Import)
+
+ Rev 1.7 21 Jul 1998 12:32:54 KHZ
+ als MSDrawingObject eingebettete Grafik (Teil 1)
+
+ Rev 1.6 09 Jul 1998 20:14:56 KHZ
+ Tabellen: verbundene Zellen und Zellen-Hintergrundfarbe jetzt Ok.
+
+ Rev 1.5 30 Jun 1998 21:33:22 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.4 26 Jun 1998 20:50:20 KHZ
+ Absatz-Attribute jetzt weitestgehend ok
+
+ Rev 1.3 23 Jun 1998 20:49:24 KHZ
+ verarbeitet jetzt auch mehrere FKPs
+
+ Rev 1.2 23 Jun 1998 11:24:20 KHZ
+ Zwischenstand: die meisten Zeichenattribute Ok!
+
+ Rev 1.1 16 Jun 1998 18:37:14 KHZ
+ DaSi-Stand
+
+ Rev 1.0 16 Jun 1998 11:12:10 KHZ
+ Initial revision.
+
+ Rev 1.1 10 Jun 1998 17:22:34 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:29:16 KHZ
+ Initial revision.
+
+
+*************************************************************************/
+
+#endif
+
diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx
new file mode 100644
index 000000000000..37af59643f92
--- /dev/null
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -0,0 +1,930 @@
+/*************************************************************************
+ *
+ * $RCSfile: ww8struc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WW8STRUC_HXX
+#define _WW8STRUC_HXX
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+
+// max. Anzahl der Listen-Level in WW8: 1..9
+#define nWW8MaxListLevel 9
+
+
+inline BYTE Get_Byte( BYTE *& p )
+ { BYTE n = SVBT8ToByte( *(SVBT8*)p ); p += 1; return n; }
+
+inline short Get_Short( BYTE *& p )
+ { short n = SVBT16ToShort( *(SVBT16*)p ); p += 2; return n; }
+inline USHORT Get_UShort( BYTE *& p )
+ { USHORT n = SVBT16ToShort( *(SVBT16*)p ); p += 2; return n; }
+
+inline long Get_Long( BYTE *& p )
+ { long n = SVBT32ToLong( *(SVBT32*)p ); p += 4; return n; }
+inline ULONG Get_ULong( BYTE *& p )
+ { ULONG n = SVBT32ToLong( *(SVBT32*)p ); p += 4; return n; }
+
+inline void Set_UInt8( BYTE *& p, UINT8 n )
+ { ByteToSVBT8( n, *(SVBT8*)p ); p+= 1; }
+
+inline void Set_UInt16( BYTE *& p, UINT16 n )
+ { ShortToSVBT16( n, *(SVBT16*)p ); p+= 2; }
+
+inline void Set_UInt32( BYTE *& p, UINT32 n )
+ { LongToSVBT32( n, *(SVBT32*)p ); p+= 4; }
+
+
+#if defined __BIGENDIAN || __ALIGNMENT4 > 2 || defined UNX
+#define __WW8_NEEDS_COPY
+#else
+#if defined WNT || defined WIN || defined OS2
+#define __WW8_NEEDS_PACK
+#pragma pack(2)
+#endif
+#endif
+
+typedef INT16 WW8_PN;
+typedef INT32 WW8_FC;
+typedef INT32 WW8_CP;
+
+// STD: STyle Definition
+// The STD contains the entire definition of a style.
+// It has two parts, a fixed-length base (cbSTDBase bytes long)
+// and a variable length remainder holding the name, and the upx and upe
+// arrays (a upx and upe for each type stored in the style, std.cupx)
+// Note that new fields can be added to the BASE of the STD without
+// invalidating the file format, because the STSHI contains the length
+// that is stored in the file. When reading STDs from an older version,
+// new fields will be zero.
+struct WW8_STD
+{
+ // Base part of STD:
+ UINT16 sti : 12; // invariant style identifier
+ UINT16 fScratch : 1; // spare field for any temporary use,
+ // always reset back to zero!
+ UINT16 fInvalHeight : 1; // PHEs of all text with this style are wrong
+ UINT16 fHasUpe : 1; // UPEs have been generated
+ UINT16 fMassCopy : 1; // std has been mass-copied; if unused at
+ // save time, style should be deleted
+ UINT16 sgc : 4; // style type code
+ UINT16 istdBase : 12; // base style
+ UINT16 cupx : 4; // # of UPXs (and UPEs)
+ UINT16 istdNext : 12; // next style
+ UINT16 bchUpe; // offset to end of upx's, start of upe's
+ //-------- jetzt neu:
+ // ab Ver8 gibts zwei Felder mehr:
+ UINT16 fAutoRedef : 1; /* auto redefine style when appropriate */
+ UINT16 fHidden : 1; /* hidden from UI? */
+ UINT16 : 14; /* unused bits */
+
+ // Variable length part of STD:
+ // UINT8 stzName[2]; /* sub-names are separated by chDelimStyle
+ // char grupx[];
+ // the UPEs are not stored on the file; they are a cache of the based-on
+ // chain
+ // char grupe[];
+};
+
+/*
+ Basis zum Einlesen UND zum Arbeiten (wird jeweils unter
+ schiedlich beerbt)
+*/
+struct WW8_FFN_BASE // Font Descriptor
+{
+ // ab Ver6
+ BYTE cbFfnM1; // 0x0 total length of FFN - 1.
+
+ BYTE prg: 2; // 0x1:03 pitch request
+ BYTE fTrueType : 1; // 0x1:04 when 1, font is a TrueType font
+ // 0x1:08 reserved
+ BYTE ff : 3; // 0x1:70 font family id
+ // 0x1:80 reserved
+
+ short wWeight; // 0x2 base weight of font
+ BYTE chs; // 0x4 character set identifier
+ BYTE ibszAlt; // 0x5 index into ffn.szFfn to the name of the alternate font
+};
+
+/*
+ Hiermit arbeiten wir im Parser (und Dumper)
+*/
+struct WW8_FFN : public WW8_FFN_BASE
+{
+ // ab Ver8 als Unicode
+ UniString sFontname;// 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+ // records name of font.
+ // Maximal size of szFfn is 65 characters.
+ // Vorsicht: Dieses Array kann auch kleiner sein!!!
+ // Possibly followed by a second sz which records the
+ // name of an alternate font to use if the first named
+ // font does not exist on this system.
+};
+
+
+
+struct WW8_BRCVer6 // alter Border Code
+{
+ SVBT16 aBits1;
+// UINT16 dxpLineWidth : 3;// 0007 When dxpLineWidth is 0, 1, 2, 3, 4, or 5, this field is the width of
+ // a single line of border in units of 0.75 points
+ // Must be nonzero when brcType is nonzero.
+ // 6 == dotted, 7 == dashed.
+// UINT16 brcType : 2; // 0018 border type code: 0 == none, 1 == single, 2 == thick, 3 == double
+// UINT16 fShadow : 1; // 0020 when 1, border is drawn with shadow. Must be 0 when BRC is a substructure of the TC
+// UINT16 ico : 5; // 07C0 color code (see chp.ico)
+// UINT16 dxpSpace : 5; // F800 width of space to maintain between border and text within border.
+ // Must be 0 when BRC is a substructure of the TC. Stored in points for Windows.
+};
+
+struct WW8_BRC : public WW8_BRCVer6 // Border Code
+{
+ SVBT16 aBits2;
+// UINT16 dxpLineWidth : 3;// 0007 When dxpLineWidth is 0, 1, 2, 3, 4, or 5, this field is the width of
+ // a single line of border in units of 0.75 points
+ // Must be nonzero when brcType is nonzero.
+ // 6 == dotted, 7 == dashed.
+// UINT16 brcType : 2; // 0018 border type code: 0 == none, 1 == single, 2 == thick, 3 == double
+// UINT16 fShadow : 1; // 0020 when 1, border is drawn with shadow. Must be 0 when BRC is a substructure of the TC
+// UINT16 ico : 5; // 07C0 color code (see chp.ico)
+// UINT16 dxpSpace : 5; // F800 width of space to maintain between border and text within border.
+ // Must be 0 when BRC is a substructure of the TC. Stored in points for Windows.
+};
+
+typedef WW8_BRC WW8_BRC5[5]; // 5 * Border Code
+
+#define WW8_TOP 0
+#define WW8_LEFT 1
+#define WW8_BOT 2
+#define WW8_RIGHT 3
+#define WW8_BETW 4
+
+
+
+
+
+struct WW8_BordersSO // fuer StarOffice-Border Code
+{
+ USHORT Out;
+ USHORT In;
+ USHORT Dist;
+};
+
+
+/*
+// Linien-Defaults in Twips: fruehere Writer-Defaults,
+// siehe auch <svx/boxitem.hxx>
+#define DEF_LINE_WIDTH_0 1
+#define DEF_LINE_WIDTH_1 20
+#define DEF_LINE_WIDTH_2 50
+#define DEF_LINE_WIDTH_3 80
+#define DEF_LINE_WIDTH_4 100
+
+#define DEF_MAX_LINE_WIDHT DEF_LINE_WIDTH_4
+#define DEF_MAX_LINE_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE0_OUT DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE0_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE0_DIST DEF_LINE_WIDTH_1
+
+#define DEF_DOUBLE_LINE1_OUT DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE1_IN DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE1_DIST DEF_LINE_WIDTH_1
+
+#define DEF_DOUBLE_LINE2_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE2_IN DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE2_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE3_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE3_IN DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE3_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE4_OUT DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE4_IN DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE4_DIST DEF_LINE_WIDTH_1
+
+#define DEF_DOUBLE_LINE5_OUT DEF_LINE_WIDTH_3
+#define DEF_DOUBLE_LINE5_IN DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE5_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE6_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE6_IN DEF_LINE_WIDTH_3
+#define DEF_DOUBLE_LINE6_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE7_OUT DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE7_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE7_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE8_OUT DEF_LINE_WIDTH_1
+#define DEF_DOUBLE_LINE8_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE8_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE9_OUT DEF_LINE_WIDTH_2
+#define DEF_DOUBLE_LINE9_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE9_DIST DEF_LINE_WIDTH_2
+
+#define DEF_DOUBLE_LINE10_OUT DEF_LINE_WIDTH_3
+#define DEF_DOUBLE_LINE10_IN DEF_LINE_WIDTH_0
+#define DEF_DOUBLE_LINE10_DIST DEF_LINE_WIDTH_2
+*/
+// Deklarationen gemaess BOXITEM.HXX
+#define WW8_DECL_LINETAB_ARRAY \
+ static WW8_BordersSO __READONLY_DATA nLineTabVer8[] = \
+ { \
+/* 0*/ { DEF_LINE_WIDTH_0, 0, 0 }, \
+/* 1*/ { DEF_LINE_WIDTH_1, 0, 0 }, \
+/* 2*/ { DEF_LINE_WIDTH_2, 0, 0 }, \
+/* 3*/ { DEF_LINE_WIDTH_3, 0, 0 }, \
+/* 4*/ { DEF_LINE_WIDTH_4, 0, 0 }, \
+/* 5*/ { DEF_DOUBLE_LINE0_OUT, DEF_DOUBLE_LINE0_IN, DEF_DOUBLE_LINE0_DIST },\
+/* 6*/ { DEF_DOUBLE_LINE1_OUT, DEF_DOUBLE_LINE1_IN, DEF_DOUBLE_LINE1_DIST },\
+/* 7*/ { DEF_DOUBLE_LINE2_OUT, DEF_DOUBLE_LINE2_IN, DEF_DOUBLE_LINE2_DIST },\
+/* 8*/ { DEF_DOUBLE_LINE3_OUT, DEF_DOUBLE_LINE3_IN, DEF_DOUBLE_LINE3_DIST },\
+/* 9*/ { DEF_DOUBLE_LINE4_OUT, DEF_DOUBLE_LINE4_IN, DEF_DOUBLE_LINE4_DIST },\
+/*10*/ { DEF_DOUBLE_LINE5_OUT, DEF_DOUBLE_LINE5_IN, DEF_DOUBLE_LINE5_DIST },\
+/*11*/ { DEF_DOUBLE_LINE6_OUT, DEF_DOUBLE_LINE6_IN, DEF_DOUBLE_LINE6_DIST },\
+/*12*/ { DEF_DOUBLE_LINE7_OUT, DEF_DOUBLE_LINE7_IN, DEF_DOUBLE_LINE7_DIST },\
+/*13*/ { DEF_DOUBLE_LINE8_OUT, DEF_DOUBLE_LINE8_IN, DEF_DOUBLE_LINE8_DIST },\
+/*14*/ { DEF_DOUBLE_LINE9_OUT, DEF_DOUBLE_LINE9_IN, DEF_DOUBLE_LINE9_DIST },\
+/*15*/ { DEF_DOUBLE_LINE10_OUT,DEF_DOUBLE_LINE10_IN,DEF_DOUBLE_LINE10_DIST} \
+ };
+
+#define WW8_DECL_LINETAB_OFS_DOUBLE 5 // Beginn des DOUBLE_LINE Abschnitts in meiner Liste
+
+
+
+
+struct WW8_XCHAR // Hilfs-Konstrukt fuer WW8_DOPTYPOGRAPHY
+{
+ sal_Char A;
+ sal_Char B;
+};
+
+struct WW8_DOPTYPOGRAPHY
+{ /*
+ Document Typography Info (DOPTYPOGRAPHY)
+ These options are Far East only, and are accessible
+ through the Typography tab of the Tools/Options dialog.
+ */
+
+
+
+ /* a c h t u n g : es duerfen keine solchen Bitfelder ueber einen eingelesenes Byte-Array
+ gelegt werden!!
+ stattdessen ist ein aBits1 darueber zu legen, das mit & auszulesen ist
+ GRUND: Compiler auf Intel und Sparc sortieren die Bits unterschiedlich
+ */
+
+
+
+ short fKerningPunct : 1; // true if we're kerning punctuation
+ short iJustification : 2; // Kinsoku method of justification:
+ // 0 = always expand
+ // 1 = compress punctuation
+ // 2 = compress punctuation and kana.
+ short iLevelOfKinsoku: 2; // Level of Kinsoku:
+ // 0 = Level 1
+ // 1 = Level 2
+ // 2 = Custom
+ short f2on1 : 1; // 2-page-on-1 feature is turned on.
+ short :10; // reserved
+ short cchFollowingPunct; // length of rgxchFPunct
+ short cchLeadingPunct; // length of rgxchLPunct
+
+ WW8_XCHAR rgxchFPunct[101]; // array of characters that should
+ // never appear at the start of a line
+ WW8_XCHAR rgxchLPunct[51]; // array of characters that should
+ // never appear at the end of a line
+};
+
+struct WW8_DOGRID
+{
+ short xaGrid; // x-coord of the upper left-hand corner of the grid
+ short yaGrid; // y-coord of the upper left-hand corner of the grid
+ short dxaGrid; // width of each grid square
+ short dyaGrid; // height of each grid square
+
+
+
+ /* a c h t u n g : es duerfen keine solchen Bitfelder ueber einen eingelesenes Byte-Array
+ gelegt werden!!
+ stattdessen ist ein aBits1 darueber zu legen, das mit & auszulesen ist
+ GRUND: Compiler auf Intel und Sparc sortieren die Bits unterschiedlich
+ */
+
+
+
+ short dyGridDisplay:7; // the number of grid squares (in the y direction)
+ // between each gridline drawn on the screen. 0 means
+ // don't display any gridlines in the y direction.
+ short fTurnItOff :1; // suppress display of gridlines
+ short dxGridDisplay:7; // the number of grid squares (in the x direction)
+ // between each gridline drawn on the screen. 0 means
+ // don't display any gridlines in the y direction.
+ short fFollowMargins:1; // if true, the grid will start at the left and top
+ // margins and ignore xaGrid and yaGrid.
+};
+
+struct WW8_PIC
+{
+ INT32 lcb; // 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file.
+ UINT16 cbHeader; // 0x4 number of bytes in the PIC (to allow for future expansion).
+ struct {
+ INT16 mm; // 0x6 int
+ INT16 xExt; // 0x8 int
+ INT16 yExt; // 0xa int
+ INT16 hMF; // 0xc int
+ }MFP;
+// BYTE bm[14]; // 0xe BITMAP(14 bytes) Window's bitmap structure when PIC describes a BITMAP.
+ BYTE rcWinMF[14]; // 0xe rc (rectangle - 8 bytes) rect for window origin
+ // and extents when metafile is stored -- ignored if 0
+ INT16 dxaGoal; // 0x1c horizontal measurement in twips of the rectangle the picture should be imaged within.
+ INT16 dyaGoal; // 0x1e vertical measurement in twips of the rectangle the picture should be imaged within.
+ UINT16 mx; // 0x20 horizontal scaling factor supplied by user in .1% units.
+ UINT16 my; // 0x22 vertical scaling factor supplied by user in .1% units.
+ INT16 dxaCropLeft; // 0x24 the amount the picture has been cropped on the left in twips.
+ INT16 dyaCropTop; // 0x26 the amount the picture has been cropped on the top in twips.
+ INT16 dxaCropRight; // 0x28 the amount the picture has been cropped on the right in twips.
+ INT16 dyaCropBottom;// 0x2a the amount the picture has been cropped on the bottom in twips.
+ INT16 brcl : 4; // 000F Obsolete, superseded by brcTop, etc. In
+ INT16 fFrameEmpty : 1; // 0010 picture consists of a single frame
+ INT16 fBitmap : 1; // 0020 ==1, when picture is just a bitmap
+ INT16 fDrawHatch : 1; // 0040 ==1, when picture is an active OLE object
+ INT16 fError : 1; // 0080 ==1, when picture is just an error message
+ INT16 bpp : 8; // FF00 bits per pixel, 0 = unknown
+ WW8_BRC rgbrc[4];
+// BRC brcTop; // 0x2e specification for border above picture
+// BRC brcLeft; // 0x30 specification for border to the left
+// BRC brcBottom; // 0x32 specification for border below picture
+// BRC brcRight; // 0x34 specification for border to the right
+ INT16 dxaOrigin; // 0x36 horizontal offset of hand annotation origin
+ INT16 dyaOrigin; // 0x38 vertical offset of hand annotation origin
+// BYTE rgb[]; // 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename.
+};
+
+struct WW8_PIC_SHADOW
+{
+ SVBT32 lcb; // 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file.
+ SVBT16 cbHeader; // 0x4 number of bytes in the PIC (to allow for future expansion).
+ struct {
+ SVBT16 mm; // 0x6 int
+ SVBT16 xExt; // 0x8 int
+ SVBT16 yExt; // 0xa int
+ SVBT16 hMF; // 0xc int
+ }MFP;
+// SVBT8 bm[14]; // 0xe BITMAP(14 bytes) Window's bitmap structure when PIC describes a BITMAP.
+ SVBT8 rcWinMF[14]; // 0xe rc (rectangle - 8 bytes) rect for window origin
+ // and extents when metafile is stored -- ignored if 0
+ SVBT16 dxaGoal; // 0x1c horizontal measurement in twips of the rectangle the picture should be imaged within.
+ SVBT16 dyaGoal; // 0x1e vertical measurement in twips of the rectangle the picture should be imaged within.
+ SVBT16 mx; // 0x20 horizontal scaling factor supplied by user in .1% units.
+ SVBT16 my; // 0x22 vertical scaling factor supplied by user in .1% units.
+ SVBT16 dxaCropLeft; // 0x24 the amount the picture has been cropped on the left in twips.
+ SVBT16 dyaCropTop; // 0x26 the amount the picture has been cropped on the top in twips.
+ SVBT16 dxaCropRight; // 0x28 the amount the picture has been cropped on the right in twips.
+ SVBT16 dyaCropBottom;// 0x2a the amount the picture has been cropped on the bottom in twips.
+ SVBT8 aBits1; //0x2c
+ SVBT8 aBits2;
+ WW8_BRC rgbrc[4];
+// BRC brcTop; // 0x2e specification for border above picture
+// BRC brcLeft; // 0x30 specification for border to the left
+// BRC brcBottom; // 0x32 specification for border below picture
+// BRC brcRight; // 0x34 specification for border to the right
+ SVBT16 dxaOrigin; // 0x36 horizontal offset of hand annotation origin
+ SVBT16 dyaOrigin; // 0x38 vertical offset of hand annotation origin
+// SVBT8 rgb[]; // 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename.
+};
+
+
+struct WW8_TBD
+{
+ SVBT8 aBits1;
+// BYTE jc : 3; // 0x07 justification code: 0=left tab, 1=centered tab, 2=right tab, 3=decimal tab, 4=bar
+// BYTE tlc : 3; // 0x38 tab leader code: 0=no leader, 1=dotted leader,
+ // 2=hyphenated leader, 3=single line leader, 4=heavy line leader
+// * int :2 C0 reserved
+};
+
+struct WW8_TCell // hiermit wird weitergearbeitet (entspricht weitestgehend dem Ver8-Format)
+{
+ BOOL bFirstMerged : 1;// 0001 set to 1 when cell is first cell of a range of cells that have been merged.
+ BOOL bMerged : 1;// 0002 set to 1 when cell has been merged with preceding cell.
+ BOOL bVertical : 1;// set to 1 when cell has vertical text flow
+ BOOL bBackward : 1;// for a vertical table cell, text flow is bottom to top when 1 and is bottom to top when 0.
+ BOOL bRotateFont : 1;// set to 1 when cell has rotated characters (i.e. uses @font)
+ BOOL bVertMerge : 1;// set to 1 when cell is vertically merged with the cell(s) above and/or below. When cells are vertically merged, the display area of the merged cells are consolidated. The consolidated area is used to display the contents of the first vertically merged cell (the cell with fVertRestart set to 1), and all other vertically merged cells (those with fVertRestart set to 0) must be empty. Cells can only be merged vertically if their left and right boundaries are (nearly) identical (i.e. if corresponding entries in rgdxaCenter of the table rows differ by at most 3).
+ BOOL bVertRestart : 1;// set to 1 when the cell is the first of a set of vertically merged cells. The contents of a cell with fVertStart set to 1 are displayed in the consolidated area belonging to the entire set of vertically merged cells. Vertically merged cells with fVertRestart set to 0 must be empty.
+ BYTE nVertAlign : 2;// specifies the alignment of the cell contents relative to text flow (e.g. in a cell with bottom to top text flow and bottom vertical alignment, the text is shifted horizontally to match the cell's right boundary):
+ // 0 top
+ // 1 center
+ // 2 bottom
+ UINT16 fUnused : 7;// reserved - nicht loeschen: macht das UINT16 voll !!
+
+ WW8_BRC rgbrc[4]; // border codes
+//notational convenience for referring to brcTop, brcLeft, etc fields.
+// BRC brcTop; // specification of the top border of a table cell
+// BRC brcLeft; // specification of left border of table row
+// BRC brcBottom; // specification of bottom border of table row
+// BRC brcRight; // specification of right border of table row.
+};
+// cbTC (count of bytes of a TC) is 18(decimal), 12(hex).
+
+
+struct WW8_TCellVer6 // wird aus der Datei gelesen
+{
+ SVBT8 aBits1Ver6;
+ SVBT8 aBits2Ver6;
+// UINT16 fFirstMerged : 1;// 0001 set to 1 when cell is first cell of a range of cells that have been merged.
+// UINT16 fMerged : 1; // 0002 set to 1 when cell has been merged with preceding cell.
+// UINT16 fUnused : 14; // FFFC reserved
+ WW8_BRCVer6 rgbrcVer6[4];
+// notational convenience for referring to brcTop, brcLeft, etc fields:
+// BRC brcTop; // specification of the top border of a table cell
+// BRC brcLeft; // specification of left border of table row
+// BRC brcBottom; // specification of bottom border of table row
+// BRC brcRight; // specification of right border of table row.
+};
+// cbTC (count of bytes of a TC) is 10(decimal), A(hex).
+
+struct WW8_TCellVer8 // wird aus der Datei gelesen
+{
+ SVBT16 aBits1Ver8; // Dokumentation siehe oben unter WW8_TCell
+ SVBT16 aUnused; // reserve
+ WW8_BRC rgbrcVer8[4]; // Dokumentation siehe oben unter WW8_TCell
+};
+// cbTC (count of bytes of a TC) is 20(decimal), 14(hex).
+
+
+struct WW8_SHD // struct SHD fehlt in der Beschreibung
+{
+private:
+ UINT16 aBits;
+// UINT16 nFore : 5; // 0x001f ForegroundColor
+// UINT16 nBack : 5; // 0x03e0 BackgroundColor
+// UINT16 nStyle : 5; // 0x7c00 Percentage and Style
+// UINT16 nDontKnow : 1; // 0x8000 ??? ab Ver8: ebenfalls fuer Style
+
+public:
+ WW8_SHD(){ aBits = 0; }
+
+ BYTE GetFore() const { return (BYTE)( aBits & 0x1f); }
+ BYTE GetBack() const { return (BYTE)((aBits >> 5 ) & 0x1f); }
+ BYTE GetStyle(BOOL bVer67) const { return (BYTE)((aBits >> 10) & ( bVer67?0x1f:0x3f ) ); }
+
+ UINT16 GetValue() const { return aBits; }
+
+ void SetValue( UINT16 nVal ){ aBits = nVal; }
+ void SetWWValue( SVBT16 nVal ){ aBits = (UINT16)SVBT16ToShort( nVal ); }
+
+ void SetFore( BYTE nVal ){ aBits = (aBits & 0xffe0) | (nVal & 0x1f); }
+ void SetBack( BYTE nVal ){ aBits = (aBits & 0xfc1f) | ((nVal & 0x1f)<<5); }
+ void SetStyle( BOOL bVer67, BYTE nVal ){
+ aBits = (aBits & ( bVer67?0x83ff:0x03ff ) )
+ | ((nVal & ( bVer67?0x1f:0x2f ))<<10); }
+};
+
+
+struct WW8_ANLV
+{
+ SVBT8 nfc; // 0 number format code, 0=Arabic, 1=Upper case Roman, 2=Lower case Roman
+ // 3=Upper case Letter, 4=Lower case letter, 5=Ordinal
+ SVBT8 cbTextBefore; // 1 offset into anld.rgch limit of prefix text
+ SVBT8 cbTextAfter; // 2
+ SVBT8 aBits1;
+// BYTE jc : 2; // 3 : 0x03 justification code, 0=left, 1=center, 2=right, 3=left and right justify
+// BYTE fPrev : 1; // 0x04 when ==1, include previous levels
+// BYTE fHang : 1; // 0x08 when ==1, number will be displayed using a hanging indent
+// BYTE fSetBold : 1; // 0x10 when ==1, boldness of number will be determined by anld.fBold.
+// BYTE fSetItalic : 1;// 0x20 when ==1, italicness of number will be determined by anld.fItalic
+// BYTE fSetSmallCaps : 1;// 0x40 when ==1, anld.fSmallCaps will determine whether number will be displayed in small caps or not.
+// BYTE fSetCaps : 1; // 0x80 when ==1, anld.fCaps will determine whether number will be displayed capitalized or not
+ SVBT8 aBits2;
+// BYTE fSetStrike : 1;// 4 : 0x01 when ==1, anld.fStrike will determine whether the number will be displayed using strikethrough or not.
+// BYTE fSetKul : 1; // 0x02 when ==1, anld.kul will determine the underlining state of the autonumber.
+// BYTE fPrevSpace : 1;// 0x04 when ==1, autonumber will be displayed with a single prefixing space character
+// BYTE fBold : 1; // 0x08 determines boldness of autonumber when anld.fSetBold == 1.
+// BYTE fItalic : 1; // 0x10 determines italicness of autonumber when anld.fSetItalic == 1.
+// BYTE fSmallCaps : 1;// 0x20 determines whether autonumber will be displayed using small caps when anld.fSetSmallCaps == 1.
+// BYTE fCaps : 1; // 0x40 determines whether autonumber will be displayed using caps when anld.fSetCaps == 1.
+// BYTE fStrike : 1; // 0x80 determines whether autonumber will be displayed using caps when anld.fSetStrike == 1.
+ SVBT8 aBits3;
+// BYTE kul : 3; // 5 : 0x07 determines whether autonumber will be displayed with underlining when anld.fSetKul == 1.
+// BYTE ico : 5; // 0xF1 color of autonumber
+ SVBT16 ftc; // 6 font code of autonumber
+ SVBT16 hps; // 8 font half point size (or 0=auto)
+ SVBT16 iStartAt; // 0x0a starting value (0 to 65535)
+ SVBT16 dxaIndent; // 0x0c *short?* *USHORT?* width of prefix text (same as indent)
+ SVBT16 dxaSpace; // 0x0e minimum space between number and paragraph
+};
+// *cbANLV (count of bytes of ANLV) is 16 (decimal), 10(hex).
+
+struct WW8_ANLD
+{
+ WW8_ANLV eAnlv; // 0
+ SVBT8 fNumber1; // 0x10 number only 1 item per table cell
+ SVBT8 fNumberAcross; // 0x11 number across cells in table rows(instead of down)
+ SVBT8 fRestartHdn; // 0x12 restart heading number on section boundary
+ SVBT8 fSpareX; // 0x13 unused( should be 0)
+ BYTE rgchAnld[32]; // 0x14 characters displayed before/after autonumber
+};
+
+
+struct WW8_OLST
+{
+ WW8_ANLV rganlv[9]; // 0 an array of 9 ANLV structures (heading levels)
+ SVBT8 fRestartHdr; // 0x90 when ==1, restart heading on section break
+ SVBT8 fSpareOlst2; // 0x91 reserved
+ SVBT8 fSpareOlst3; // 0x92 reserved
+ SVBT8 fSpareOlst4; // 0x93 reserved
+ BYTE rgch[64]; // 0x94 array of 64 chars text before/after number
+};
+// cbOLST is 212(decimal), D4(hex).
+
+struct WW8_FDOA
+{
+ SVBT32 fc; // 0 FC pointing to drawing object data
+ SVBT16 ctxbx; // 4 count of textboxes in the drawing object
+};
+
+struct WW8_DO
+{
+ SVBT16 dok; // 0 Drawn Object Kind, currently this is always 0
+ SVBT16 cb; // 2 size (count of bytes) of the entire DO
+ SVBT8 bx; // 4 x position relative to anchor CP
+ SVBT8 by; // 5 y position relative to anchor CP
+ SVBT16 dhgt; // 6 height of DO
+ SVBT16 aBits1;
+// UINT16 fAnchorLock : 1; // 8 1 if the DO anchor is locked
+// BYTE[] rgdp; // 0xa variable length array of drawing primitives
+};
+
+struct WW8_DPHEAD
+{
+ SVBT16 dpk; // 0 Drawn Primitive Kind REVIEW davebu
+ // 0=start of grouping, 1=line, 2=textbox, 3=rectangle,
+ // 4=arc, 5=elipse, 6=polyline, 7=callout textbox,
+ // 8=end of grouping, 9=sample primitve holding default values
+ SVBT16 cb; // 2 size (count of bytes) of this DP
+ SVBT16 xa; // 4 These 2 points describe the rectangle
+ SVBT16 ya; // 6 enclosing this DP relative to the origin of
+ SVBT16 dxa; // 8 the DO
+ SVBT16 dya; // 0xa
+};
+
+
+struct WW8_DP_LINETYPE
+{
+ SVBT32 lnpc; // LiNe Property Color -- RGB color value
+ SVBT16 lnpw; // line property weight in twips
+ SVBT16 lnps; // line property style : 0=Solid, 1=Dashed
+ // 2=Dotted, 3=Dash Dot, 4=Dash Dot Dot, 5=Hollow
+};
+
+struct WW8_DP_SHADOW // Schattierung!
+{
+ SVBT16 shdwpi; // Shadow Property Intensity
+ SVBT16 xaOffset; // x offset of shadow
+ SVBT16 yaOffset; // y offset of shadow
+};
+
+struct WW8_DP_FILL
+{
+ SVBT32 dlpcFg; // FiLl Property Color ForeGround -- RGB color value
+ SVBT32 dlpcBg; // Property Color BackGround -- RGB color value
+ SVBT16 flpp; // FiLl Property Pattern REVIEW davebu
+};
+
+struct WW8_DP_LINEEND
+{
+ SVBT16 aStartBits;
+// UINT16 eppsStart : 2; // Start EndPoint Property Style
+ // 0=None, 1=Hollow, 2=Filled
+// UINT16 eppwStart : 2; // Start EndPoint Property Weight
+// UINT16 epplStart : 2; // Start EndPoint Property length
+// UINT16 dummyStart : 10; // Alignment
+ SVBT16 aEndBits;
+// UINT16 eppsEnd : 2; // End EndPoint Property Style
+// UINT16 eppwEnd : 2; // End EndPoint Property Weight
+// UINT16 epplEnd : 2; // End EndPoint Property length
+// UINT16 dummyEnd : 10; // Alignment
+};
+
+struct WW8_DP_LINE
+{
+// WW8_DPHEAD dphead; // 0 Common header for a drawing primitive
+ SVBT16 xaStart; // starting point for line
+ SVBT16 yaStart; //
+ SVBT16 xaEnd; // ending point for line
+ SVBT16 yaEnd;
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_LINEEND aEpp;
+ WW8_DP_SHADOW aShd;
+};
+
+struct WW8_DP_TXTBOX
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+ SVBT16 aBits1;
+// UINT16 fRoundCorners : 1; //0x24 0001 1 if the textbox has rounded corners
+// UINT16 zaShape : 15; // 0x24 000e REVIEW davebu
+ SVBT16 dzaInternalMargin; // 0x26 REVIEW davebu
+};
+
+struct WW8_DP_RECT
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+ SVBT16 aBits1;
+// UINT16 fRoundCorners : 1; // 0x24 0001 1 if the textbox has rounded corners
+// UINT16 zaShape : 15; // 0x24 000e REVIEW davebu
+};
+
+struct WW8_DP_ARC
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+ SVBT8 fLeft; // 0x24 00ff REVIEW davebu
+ SVBT8 fUp; // 0x24 ff00 REVIEW davebu
+// UINT16 fLeft : 8; // 0x24 00ff REVIEW davebu
+// UINT16 fUp : 8; // 0x24 ff00 REVIEW davebu
+};
+
+struct WW8_DP_ELIPSE
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_SHADOW aShd;
+};
+
+struct WW8_DP_POLYLINE
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_LINEEND aEpp;
+ WW8_DP_SHADOW aShd;
+ SVBT16 aBits1;
+// UINT16 fPolygon : 1; // 0x28 0001 1 if this is a polygon
+// UINT16 cpt : 15; // 0x28 00fe count of points
+// short xaFirst; // 0x2a These are the endpoints of the first line.
+// short yaFirst; // 0x2c
+// short xaEnd; // 0x2e
+// short yaEnd; // 0x30
+// short rgpta[]; // 0x32 An array of xa,ya pairs for the remaining points
+};
+
+struct WW8_DP_CALLOUT_TXTBOX
+{
+ SVBT16 flags; // 0x0c REVIEW davebu flags
+ SVBT16 dzaOffset; // 0x0e REVIEW davebu
+ SVBT16 dzaDescent; // 0x10 REVIEW davebu
+ SVBT16 dzaLength; // 0x12 REVIEW davebu
+ WW8_DPHEAD dpheadTxbx; // 0x14 DPHEAD for a textbox
+ WW8_DP_TXTBOX dptxbx; // 0x20 DP for a textbox
+ WW8_DPHEAD dpheadPolyLine; // 0x4c DPHEAD for a Polyline
+ WW8_DP_POLYLINE dpPolyLine; // 0x48 DP for a polyline
+};
+
+struct WW8_DP_DEFAULTS
+{
+ WW8_DP_LINETYPE aLnt;
+ WW8_DP_FILL aFill;
+ WW8_DP_LINEEND aEpp;
+ WW8_DP_SHADOW aShd;
+ SVBT16 dzaOffset; // 0x2a REVIEW davebu
+ SVBT16 dzaDescent; // 0x2c REVIEW davebu
+ SVBT16 dzaLength; // 0x2e REVIEW davebu
+
+ SVBT16 aBits3;
+// UINT16 fRoundCorners : 1; // 0x30 0001 1 if the textbox has rounded corners
+// UINT16 zaShape : 15; // 0x30 000fe REVIEW davebu
+ SVBT16 dzaInternalMargin; // 0x32 REVIEW davebu
+};
+
+
+struct WW8_PCD
+{
+ SVBT8 aBits1;
+// BYTE fNoParaLast : 1; // when 1, means that piece contains no end of paragraph marks.
+// BYTE fPaphNil : 1; // used internally by Word
+// BYTE fCopied : 1; // used internally by Word
+// * int :5
+ SVBT8 aBits2; // fn int:8, used internally by Word
+ SVBT32 fc; // file offset of beginning of piece. The size of the
+ // ithpiece can be determined by subtracting rgcp[i] of
+ // the containing plcfpcd from its rgcp[i+1].
+ SVBT16 prm; // PRM contains either a single sprm or else an index number
+ // of the grpprl which contains the sprms that modify the
+ // properties of the piece.
+};
+
+struct WW8_PHE_Base
+{
+ BYTE aBits1; //
+// 0 0 fSpare int :1 0001 reserved
+// fUnk int :1 0002 phe entry is invalid
+// when == 1
+// fDiffLines int :1 0004 when 1, total
+// height of paragraph is known but lines in
+// paragraph have different heights.
+// * int :5 00F8 reserved
+ BYTE nlMac; // when fDiffLines is 0 is number of lines in
+// // paragraph
+ SVBT16 dxaCol; // width of lines in paragraph
+ SVBT16 dyl;
+// 4 4 dylLine int when fDiffLines is 0,
+// is height of every line in paragraph.in pixels
+// 4 4 dylHeight uns when fDiffLines is 1,
+// is the total height in pixels of the paragraph
+};
+
+/*
+eigentlich muessten wir das jetzt in etwa *so* praezisieren:
+
+ struct WW8_PHE_Ver6 : public WW8_PHE_Base
+ {
+ // 6 Bytes gross
+ };
+ struct WW8_PHE_Ver6 : public WW8_PHE_Base
+ {
+ SVBT16 a;
+ SVBT16 b;
+ SVBT16 c; // 12 Byte gross
+ };
+*/
+
+// AnnoTation Refernce Descriptor (ATRD)
+struct WW8_ATRD // fuer die 8-Version
+{
+ SVBT16 xstUsrInitl[ 10 ]; // pascal-style String holding initials
+ // of annotation author
+ SVBT16 ibst; // index into GrpXstAtnOwners
+ SVBT16 ak; // not used
+ SVBT16 grfbmc; // not used
+ SVBT32 ITagBkmk; // when not -1, this tag identifies the
+ // annotation bookmark that locates the
+ // range of CPs in the main document which
+ // this annotation references.
+};
+
+struct WW67_ATRD // fuer die 6/7-Version
+{
+ sal_Char xstUsrInitl[ 10 ]; // pascal-style String holding initials
+ // of annotation author
+ SVBT16 ibst; // index into GrpXstAtnOwners
+ SVBT16 ak; // not used
+ SVBT16 grfbmc; // not used
+ SVBT32 ITagBkmk; // when not -1, this tag identifies the
+ // annotation bookmark that locates the
+ // range of CPs in the main document which
+ // this annotation references.
+};
+
+
+#ifdef __WW8_NEEDS_PACK
+#pragma pack()
+#endif
+
+/*************************************************************************
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/ww8/ww8struc.hxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.20 2000/09/18 16:05:02 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.19 2000/05/12 07:54:23 khz
+ Changes for Unicode
+
+ Revision 1.18 2000/02/11 14:40:36 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.17 1999/11/19 14:48:49 mib
+ #70009#: export Solaris
+
+ Revision 1.16 1999/06/16 17:54:56 JP
+ Change interface of base class Writer, Export of W97 NumRules
+
+
+ Rev 1.15 16 Jun 1999 19:54:56 JP
+ Change interface of base class Writer, Export of W97 NumRules
+
+ Rev 1.14 19 May 1999 11:12:56 JP
+ WinWord97-ExportFilter
+
+ Rev 1.13 11 May 1999 17:15:24 KHZ
+ Task #66019# FontFamily: andere Bitreihenfolge auf Solaris beachten
+
+ Rev 1.12 15 Feb 1999 21:36:50 KHZ
+ Task #61381# Korrektur der Korrektur: jetzt include boxitem.hxx in ww8graf.cxx
+
+ Rev 1.11 15 Feb 1999 20:54:44 KHZ
+ Task #61381# Korrektur zur -r1.10: UEbernahme der defines statt der includes
+
+ Rev 1.10 15 Feb 1999 18:19:44 HR
+ <svx/eeitem.hxx> und <svx/boxitem.hxx> includen
+
+ Rev 1.9 12 Feb 1999 16:51:38 KHZ
+ Task #61381# Ersetzen von Sdr-Text-Objekten im Writer durch Rahmen (3)
+
+ Rev 1.8 03 Dec 1998 10:39:52 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.7 02 Dec 1998 15:34:28 JP
+ Task #60063#: Kommentare als PostIts einlesen
+
+ Rev 1.6 23 Oct 1998 15:37:02 KHZ
+ Task #58199# jetzt kein GPF mehr bei nicht existenten Tabellenzellen :-)
+
+ Rev 1.5 30 Jul 1998 14:28:34 KHZ
+ Task #52607# Einrueckungen der Defines beseitigt
+
+ Rev 1.4 09 Jul 1998 20:14:58 KHZ
+ Tabellen: verbundene Zellen und Zellen-Hintergrundfarbe jetzt Ok.
+
+ Rev 1.3 03 Jul 1998 16:14:54 KHZ
+ ( Zwischenstand zur DaSi )
+
+ Rev 1.2 30 Jun 1998 21:33:18 KHZ
+ Header/Footer/Footnotes weitgehend ok
+
+ Rev 1.1 26 Jun 1998 20:50:10 KHZ
+ Absatz-Attribute jetzt weitestgehend ok
+
+ Rev 1.0 16 Jun 1998 10:57:08 KHZ
+ Initial revision.
+
+ Rev 1.1 10 Jun 1998 17:22:38 KHZ
+ Zwischenstand-Sicherung Dumper
+
+ Rev 1.0 27 May 1998 15:29:34 KHZ
+ Initial revision.
+
+*************************************************************************/
+
+#endif
diff --git a/sw/source/filter/xml/makefile.mk b/sw/source/filter/xml/makefile.mk
new file mode 100644
index 000000000000..1534f01d5af9
--- /dev/null
+++ b/sw/source/filter/xml/makefile.mk
@@ -0,0 +1,144 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=xml
+
+PROJECTPCH=filt_pch
+PROJECTPCHSOURCE=..\filt_1st\filt_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(mydebug)" != ""
+CDEFS=$(CDEFS) -Dmydebug
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ swxml.cxx \
+ xmlimp.cxx \
+ wrtxml.cxx \
+ xmlexp.cxx \
+ xmlectxt.cxx \
+ xmltext.cxx \
+ xmltbli.cxx \
+ xmltble.cxx \
+ xmlfmt.cxx \
+ xmlfmte.cxx \
+ xmlmeta.cxx \
+ xmlnum.cxx \
+ xmlitemm.cxx \
+ xmlitemi.cxx \
+ xmliteme.cxx \
+ swxmlat.cxx \
+ hintlist.cxx \
+ xmlbrsh.cxx
+
+SLOFILES = \
+ $(SLO)$/swxml.obj \
+ $(SLO)$/xmlimp.obj \
+ $(SLO)$/wrtxml.obj \
+ $(SLO)$/xmlexp.obj \
+ $(SLO)$/xmlectxt.obj \
+ $(SLO)$/xmltext.obj \
+ $(SLO)$/xmltbli.obj \
+ $(SLO)$/xmltble.obj \
+ $(SLO)$/xmlfmt.obj \
+ $(SLO)$/xmlfmte.obj \
+ $(SLO)$/xmlmeta.obj \
+ $(SLO)$/xmlnum.obj \
+ $(SLO)$/xmlitemm.obj \
+ $(SLO)$/xmlitemi.obj \
+ $(SLO)$/xmliteme.obj \
+ $(SLO)$/swxmlat.obj \
+ $(SLO)$/hintlist.obj \
+ $(SLO)$/xmlbrsh.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/swxml.obj \
+ $(SLO)$/xmlimp.obj \
+ $(SLO)$/wrtxml.obj \
+ $(SLO)$/xmlexp.obj \
+ $(SLO)$/xmlectxt.obj \
+ $(SLO)$/xmltext.obj \
+ $(SLO)$/xmltbli.obj \
+ $(SLO)$/xmltble.obj \
+ $(SLO)$/xmlfmt.obj \
+ $(SLO)$/xmlfmte.obj \
+ $(SLO)$/xmlmeta.obj \
+ $(SLO)$/xmlnum.obj \
+ $(SLO)$/xmlitemi.obj \
+ $(SLO)$/xmliteme.obj \
+ $(SLO)$/swxmlat.obj \
+ $(SLO)$/xmlbrsh.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
new file mode 100644
index 000000000000..d5f514b3ed32
--- /dev/null
+++ b/sw/source/filter/xml/swxml.cxx
@@ -0,0 +1,314 @@
+/*************************************************************************
+ *
+ * $RCSfile: swxml.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
+#include <unotools/processfactory.hxx>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
+#include <com/sun/star/xml/sax/XParser.hpp>
+#endif
+
+#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
+#include <sfx2/docfile.hxx>
+#endif
+
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _ERRHDL_HXX //autogen wg. ASSERT
+#include <errhdl.hxx>
+#endif
+#ifndef _FLTINI_HXX //autogen wg. XMLReader
+#include <fltini.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _DOCSH_HXX //autogen wg. SwDoc
+#include <docsh.hxx>
+#endif
+
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::rtl;
+
+XMLReader::XMLReader()
+{
+}
+
+sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
+{
+ Reference< lang::XMultiServiceFactory > xServiceFactory =
+ utl::getProcessServiceFactory();
+ ASSERT( xServiceFactory.is(),
+ "XMLReader::Read: got no service manager" );
+ if( !xServiceFactory.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // Get model
+ SwDocShell *pDocSh = rDoc.GetDocShell();
+ ASSERT( pDocSh, "XMLReader::Read: got no doc shell" );
+ if( !pDocSh )
+ return ERR_SWG_READ_ERROR;
+
+ Reference< frame::XModel > xModel = pDocSh->GetModel();
+ ASSERT( xModel.is(),
+ "XMLReader::Read: got no model" );
+ if( !xModel.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // Get data source ...
+ Reference< io::XActiveDataSource > xSource;
+ if( pMedium /* && pMedium->GetLoadEnvironment_Impl() */ )
+ {
+ // if there is a medium and if this medium has a load environment,
+ // we get an active data source from the medium.
+ xSource = pMedium->GetDataSource();
+ ASSERT( xSource.is(), "XMLReader:: got no data source from medium" );
+ }
+ if( !xSource.is() )
+ {
+ // If we didn't get a data source from a medium, we have to create
+ // one.
+ Reference< XInterface > xFactory = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.frame.DataSourceFactory") );
+ if( xFactory.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xMFactory( xFactory,
+ UNO_QUERY );
+ if( xMFactory.is() )
+ {
+ OUString sURL( rName );
+ Sequence< Any > aArgs(1);
+ Any* pArgs = aArgs.getArray();
+ *pArgs <<= sURL;
+
+ Reference< XInterface > xSrc =
+ xMFactory->createInstanceWithArguments( sURL, aArgs );
+ if( xSrc.is() )
+ {
+ Reference< io::XActiveDataSource > xTmp( xSrc, UNO_QUERY );
+ xSource = xTmp;
+ }
+ }
+ }
+ }
+
+ // get data source
+ ASSERT( xSource.is(), "XMLReader::Read: data source missing" );
+ if( !xSource.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // get parser
+ Reference< XInterface > xXMLParser = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Parser") );
+ ASSERT( xXMLParser.is(),
+ "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
+ if( !xXMLParser.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // get a pipe for connecting the data source to the parser
+ Reference< XInterface > xPipe = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.io.Pipe") );
+ ASSERT( xPipe.is(),
+ "XMLReader::Read: com.sun.star.io.Pipe service missing" );
+ if( !xPipe.is() )
+ return ERR_SWG_READ_ERROR;
+
+ sal_uInt16 nStyleFamilyMask = SFX_STYLE_FAMILY_ALL;
+ sal_Bool bLoadDoc;
+ sal_Bool bInsert;
+ if( aOpt.IsFmtsOnly() )
+ {
+ bLoadDoc = sal_False;
+ bInsert = aOpt.IsMerge();
+ nStyleFamilyMask = 0U;
+ if( aOpt.IsFrmFmts() )
+ nStyleFamilyMask |= SFX_STYLE_FAMILY_FRAME;
+ if( aOpt.IsPageDescs() )
+ nStyleFamilyMask |= SFX_STYLE_FAMILY_PAGE;
+ if( aOpt.IsTxtFmts() )
+ nStyleFamilyMask |= (SFX_STYLE_FAMILY_CHAR|SFX_STYLE_FAMILY_PARA);
+ if( aOpt.IsNumRules() )
+ nStyleFamilyMask |= SFX_STYLE_FAMILY_PSEUDO;
+ }
+ else
+ {
+ bLoadDoc = sal_True;
+ bInsert = bInsertMode;
+ nStyleFamilyMask = SFX_STYLE_FAMILY_ALL;
+ }
+ aOpt.ResetAllFmtsOnly();
+
+ // get filter
+ Reference< xml::sax::XDocumentHandler > xFilter =
+ new SwXMLImport( rDoc, rPaM, bLoadDoc, bInsert, nStyleFamilyMask,
+ xModel );
+
+ // connect pipe's output stream to the data source
+ Reference< io::XOutputStream > xPipeOutput( xPipe, UNO_QUERY );
+ xSource->setOutputStream( xPipeOutput );
+
+ // connect pipe's input stream to the parser
+ xml::sax::InputSource aParserInput;
+ Reference< io::XInputStream > xPipeInput( xPipe, UNO_QUERY );
+ aParserInput.aInputStream = xPipeInput;
+ aParserInput.sSystemId = rName;
+
+ // connect parser and filter
+ Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY );
+ xParser->setDocumentHandler( xFilter );
+
+ rDoc.AddLink(); // prevent deletion
+ sal_uInt32 nRet = 0;
+
+ // parse
+ Reference< io::XActiveDataControl > xSourceControl( xSource, UNO_QUERY );
+ xSourceControl->start();
+ try
+ {
+ xParser->parseStream( aParserInput );
+ }
+ catch( xml::sax::SAXParseException& )
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ catch( xml::sax::SAXException&)
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ catch( io::IOException& )
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+
+ rDoc.RemoveLink();
+
+ return nRet;
+}
+
+
+/*************************************************************************
+
+ $Log: not supported by cvs2svn $
+ Revision 1.13 2000/09/18 16:05:04 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.12 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.11 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.10 2000/03/21 15:10:56 os
+ UNOIII
+
+ Revision 1.9 2000/03/13 14:33:43 mib
+ UNO3
+
+ Revision 1.8 2000/02/11 14:40:44 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.7 1999/11/26 11:15:20 mib
+ loading of styles only and insert mode
+
+ Revision 1.6 1999/11/19 16:40:21 os
+ modules renamed
+
+ Revision 1.5 1999/11/19 15:27:05 mib
+ Opt: using OUString constructor instead of StringToOUString
+
+ Revision 1.4 1999/09/23 11:53:47 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.3 1999/08/19 14:51:30 HR
+ #65293#: fixed exception macro usage
+
+
+ Rev 1.2 19 Aug 1999 16:51:30 HR
+ #65293#: fixed exception macro usage
+
+ Rev 1.1 17 Aug 1999 16:31:26 MIB
+ import
+
+ Rev 1.0 12 Aug 1999 12:28:08 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
new file mode 100644
index 000000000000..feb0e8237350
--- /dev/null
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtxml.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _UNOTOOLS_PROCESSFACTORY_HXX_
+#include <unotools/processfactory.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _DOCSH_HXX //autogen wg. SwDoc
+#include <docsh.hxx>
+#endif
+
+#ifndef _ERRHDL_HXX //autogen wg. ASSERT
+#include <errhdl.hxx>
+#endif
+#ifndef _SWSWERROR_H
+#include <swerror.h>
+#endif
+#ifndef _WRTXML_HXX
+#include <wrtxml.hxx>
+#endif
+#ifndef _XMLEXP_HXX
+#include <xmlexp.hxx>
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+SwXMLWriter::SwXMLWriter()
+{
+}
+
+
+__EXPORT SwXMLWriter::~SwXMLWriter()
+{
+}
+
+sal_uInt32 SwXMLWriter::WriteStream()
+{
+ ASSERT( !this, "SwXMLWriter::WriteStream: use Write!" );
+
+ return ERR_SWG_WRITE_ERROR;
+}
+
+sal_uInt32 SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed,
+ const String* pFileName )
+{
+ Reference< lang::XMultiServiceFactory > xServiceFactory =
+ utl::getProcessServiceFactory();
+ ASSERT( xServiceFactory.is(),
+ "SwXMLWriter::Write: got no service manager" );
+ if( !xServiceFactory.is() )
+ return ERR_SWG_WRITE_ERROR;
+
+ Reference< XInterface > xWriter = xServiceFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Writer") );
+ ASSERT( xWriter.is(),
+ "SwXMLWriter::Write: com.sun.star.xml.sax.Writer service missing" );
+ if(!xWriter.is())
+ return ERR_SWG_WRITE_ERROR;
+
+ Reference< frame::XModel > xModel = rPaM.GetDoc()->GetDocShell()->GetModel();
+ ASSERT( xModel.is(),
+ "XMLWriter::Write: got no model" );
+ if( !xModel.is() )
+ return ERR_SWG_WRITE_ERROR;
+
+ Reference< io::XOutputStream > xOut = rMed.GetDataSink();
+ Reference< io::XActiveDataSource > xSrc( xWriter, UNO_QUERY );
+ xSrc->setOutputStream( xOut );
+
+ Reference< xml::sax::XDocumentHandler > xHandler( xWriter, UNO_QUERY );
+
+ SwXMLExport *pExp = new SwXMLExport( xModel, rPaM, *pFileName, xHandler,
+ bWriteAll, bWriteOnlyFirstTable,
+ bShowProgress );
+
+ sal_uInt32 nRet = pExp->exportDoc( sXML_text );
+
+ delete pExp;
+
+ ResetWriter();
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+void GetXMLWriter( const String&, WriterRef& xRet )
+{
+ xRet = new SwXMLWriter;
+}
+
+// -----------------------------------------------------------------------
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/wrtxml.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.17 2000/09/18 16:05:04 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.16 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.15 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.14 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.13 2000/03/21 15:10:56 os
+ UNOIII
+
+ Revision 1.12 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.11 2000/03/03 16:07:54 pl
+ #73771# workaround for c50 intel compiler
+
+ Revision 1.10 2000/02/11 14:40:52 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.9 1999/11/26 11:09:47 mib
+ progress, export-flags
+
+ Revision 1.8 1999/11/19 16:40:21 os
+ modules renamed
+
+ Revision 1.7 1999/10/26 13:34:30 mib
+ removed 'using namespace' from header files
+
+ Revision 1.6 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.5 1999/10/15 14:48:25 hr
+ export() -> exportDoc()
+
+ Revision 1.4 1999/10/15 12:36:39 mib
+ added document class attribute
+
+ Revision 1.3 1999/10/08 11:47:06 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.2 1999/09/22 11:56:36 mib
+ string -> wstring
+
+ Revision 1.1 1999/08/12 10:28:26 MIB
+ Initial revision.
+
+
+ Rev 1.0 12 Aug 1999 12:28:26 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx
new file mode 100644
index 000000000000..bdc91f054444
--- /dev/null
+++ b/sw/source/filter/xml/wrtxml.hxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * $RCSfile: wrtxml.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _WRTXML_HXX
+#define _WRTXML_HXX
+
+#ifndef _SHELLIO_HXX
+#include <shellio.hxx>
+#endif
+
+class SwDoc;
+class SwPaM;
+class SfxMedium;
+
+class SwXMLWriter : public Writer
+{
+protected:
+ virtual sal_uInt32 WriteStream();
+
+public:
+
+ SwXMLWriter();
+ virtual ~SwXMLWriter();
+
+ virtual sal_uInt32 Write( SwPaM& rPam, SfxMedium& rMed,
+ const String* pFileName );
+};
+
+
+#endif // _WRTXML_HXX
+
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
new file mode 100644
index 000000000000..e500fc83ae4e
--- /dev/null
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlbrsh.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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
+
+#include "hintids.hxx"
+#include <tools/debug.hxx>
+
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmlkywd.hxx>
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/xmltkmap.hxx>
+
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+
+#include "xmlbrshi.hxx"
+#include "xmlbrshe.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+enum SvXMLTokenMapAttrs
+{
+ XML_TOK_BGIMG_HREF,
+ XML_TOK_BGIMG_TYPE,
+ XML_TOK_BGIMG_ACTUATE,
+ XML_TOK_BGIMG_SHOW,
+ XML_TOK_BGIMG_POSITION,
+ XML_TOK_BGIMG_REPEAT,
+ XML_TOK_BGIMG_FILTER,
+ XML_TOK_NGIMG_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aBGImgAttributesAttrTokenMap[] =
+{
+ { XML_NAMESPACE_XLINK, sXML_href, XML_TOK_BGIMG_HREF },
+ { XML_NAMESPACE_XLINK, sXML_type, XML_TOK_BGIMG_TYPE },
+ { XML_NAMESPACE_XLINK, sXML_actuate, XML_TOK_BGIMG_ACTUATE },
+ { XML_NAMESPACE_XLINK, sXML_show, XML_TOK_BGIMG_SHOW },
+ { XML_NAMESPACE_STYLE, sXML_position, XML_TOK_BGIMG_POSITION },
+ { XML_NAMESPACE_STYLE, sXML_repeat, XML_TOK_BGIMG_REPEAT },
+ { XML_NAMESPACE_STYLE, sXML_filter_name,XML_TOK_BGIMG_FILTER },
+ XML_TOKEN_MAP_END
+};
+
+TYPEINIT1( SwXMLBrushItemImportContext, SvXMLImportContext );
+
+void SwXMLBrushItemImportContext::ProcessAttrs(
+ const Reference< xml::sax::XAttributeList >& xAttrList,
+ const SvXMLUnitConverter& rUnitConv )
+{
+ SvXMLTokenMap aTokenMap( aBGImgAttributesAttrTokenMap );
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+
+ switch( aTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_BGIMG_HREF:
+ pItem->importXML( rValue, MID_GRAPHIC_LINK, rUnitConv );
+ break;
+ case XML_TOK_BGIMG_TYPE:
+ case XML_TOK_BGIMG_ACTUATE:
+ case XML_TOK_BGIMG_SHOW:
+ break;
+ case XML_TOK_BGIMG_POSITION:
+ pItem->importXML( rValue, MID_GRAPHIC_POSITION, rUnitConv );
+ break;
+ case XML_TOK_BGIMG_REPEAT:
+ pItem->importXML( rValue, MID_GRAPHIC_REPEAT, rUnitConv );
+ break;
+ case XML_TOK_BGIMG_FILTER:
+ pItem->importXML( rValue, MID_GRAPHIC_FILTER, rUnitConv );
+ break;
+ }
+ }
+
+ if( !(pItem->GetGraphicLink() || pItem->GetGraphic() ) )
+ pItem->SetGraphicPos( GPOS_NONE );
+ else if( GPOS_NONE == pItem->GetGraphicPos() )
+ pItem->SetGraphicPos( GPOS_TILED );
+}
+
+SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList >& xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvxBrushItem& rItem ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pItem( new SvxBrushItem( rItem ) )
+{
+ // delete any grephic that is existing
+ pItem->SetGraphicPos( GPOS_NONE );
+
+ ProcessAttrs( xAttrList, rUnitConv );
+}
+
+SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ sal_uInt16 nWhich ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pItem( new SvxBrushItem( nWhich ) )
+{
+ ProcessAttrs( xAttrList, rUnitConv );
+}
+
+SwXMLBrushItemImportContext::~SwXMLBrushItemImportContext()
+{
+ delete pItem;
+}
+
+OUString SwXMLBrushItemExport::GetQNameByKey(
+ sal_uInt16 nKey,
+ const OUString& rLocalName ) const
+{
+ if( pNamespaceMap )
+ return pNamespaceMap->GetQNameByKey( nKey, rLocalName );
+ else
+ return rLocalName;
+}
+
+void SwXMLBrushItemExport::ClearAttrList()
+{
+ pAttrList->Clear();
+}
+
+#ifndef PRODUCT
+void SwXMLBrushItemExport::CheckAttrList()
+{
+ DBG_ASSERT( !pAttrList->getLength(),
+ "SvxXMLBrsuhItemExport::CheckAttrList: list is not empty" );
+}
+#endif
+
+void SwXMLBrushItemExport::AddAttribute( sal_uInt16 nPrefixKey,
+ const sal_Char *pName,
+ const OUString& rValue )
+{
+ OUString sName( OUString::createFromAscii( pName ) );
+
+ pAttrList->AddAttribute( GetQNameByKey( nPrefixKey, sName ),
+ sCDATA, rValue );
+}
+
+SwXMLBrushItemExport::SwXMLBrushItemExport(
+ const Reference< xml::sax::XDocumentHandler >& rHandler,
+ const SvXMLUnitConverter& rUnitConverter ) :
+ sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
+ pNamespaceMap( 0 ),
+ rUnitConv( rUnitConverter ),
+ pAttrList( new SvXMLAttributeList )
+{
+ xHandler = rHandler;
+ xAttrList = pAttrList;
+}
+
+SwXMLBrushItemExport::~SwXMLBrushItemExport()
+{
+}
+
+void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem,
+ const SvXMLNamespaceMap& rNamespaceMap )
+{
+ pNamespaceMap = &rNamespaceMap;
+
+ CheckAttrList();
+
+ OUString sValue;
+ if( rItem.exportXML( sValue, MID_GRAPHIC_LINK, rUnitConv ) )
+ {
+ AddAttribute( XML_NAMESPACE_XLINK, sXML_href, sValue );
+ AddAttribute( XML_NAMESPACE_XLINK, sXML_type,
+ OUString::createFromAscii(sXML_simple) );
+// AddAttribute( XML_NAMESPACE_XLINK, sXML_show, ACP2WS(sXML_embed) );
+ AddAttribute( XML_NAMESPACE_XLINK, sXML_actuate,
+ OUString::createFromAscii(sXML_onLoad) );
+
+ if( rItem.exportXML( sValue, MID_GRAPHIC_POSITION, rUnitConv ) )
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_position, sValue );
+
+ if( rItem.exportXML( sValue, MID_GRAPHIC_REPEAT, rUnitConv ) )
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_repeat, sValue );
+
+ if( rItem.exportXML( sValue, MID_GRAPHIC_FILTER, rUnitConv ) )
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_filter_name, sValue );
+ }
+
+ OUString sElem( GetQNameByKey( XML_NAMESPACE_STYLE,
+ OUString::createFromAscii(sXML_background_image) ) );
+ xHandler->startElement( sElem, xAttrList );
+ ClearAttrList();
+ xHandler->endElement( sElem );
+
+ pNamespaceMap = 0;
+}
+
+/*************************************************************************
+
+ Source Code Control ::com::sun::star::chaos::System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlbrsh.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control ::com::sun::star::chaos::System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.2 2000/09/18 16:05:05 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.1 2000/08/02 14:52:38 mib
+ text export continued
+
+ Revision 1.2 2000/06/26 08:29:55 mib
+ no SVX dependency any longer
+
+ Revision 1.1 2000/06/08 09:14:25 aw
+ new export classes from svx
+
+ Revision 1.5 2000/05/02 10:04:19 mib
+ unicode
+
+ Revision 1.4 2000/03/13 14:38:56 cl
+ uno3
+
+ Revision 1.3 2000/02/10 20:09:32 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.2 2000/01/06 14:59:19 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.1 1999/12/13 08:11:18 mib
+ #70271#: XML brush item import/export
+
+ Revision 1.1 1999/12/04 16:47:25 cl
+ #70271# added support for exporting tab-stop elements in xml
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlbrshe.hxx b/sw/source/filter/xml/xmlbrshe.hxx
new file mode 100644
index 000000000000..813991daf3c0
--- /dev/null
+++ b/sw/source/filter/xml/xmlbrshe.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlbrshe.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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 _XMLBRSHE_HXX
+#define _XMLBRSHE_HXX
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _XMLOFF_ATTRLIST_HXX
+#include <xmloff/attrlist.hxx>
+#endif
+
+
+class SvXMLNamespaceMap;
+class SvXMLUnitConverter;
+class SvxBrushItem;
+
+class SwXMLBrushItemExport
+{
+ const ::rtl::OUString sCDATA;
+
+ // the handler
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler > xHandler;
+
+ // a common attribute list and an interface of it
+ SvXMLAttributeList *pAttrList;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > xAttrList;
+
+ const SvXMLNamespaceMap *pNamespaceMap; // the namepspace map
+ const SvXMLUnitConverter& rUnitConv;
+
+protected:
+
+ // Check if common attribute list is empty.
+#ifdef PRODUCT
+ void CheckAttrList() {}
+#else
+ void CheckAttrList();
+#endif
+ void ClearAttrList();
+ void AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
+ const ::rtl::OUString& rValue );
+ ::rtl::OUString GetQNameByKey( sal_uInt16 nKey,
+ const ::rtl::OUString& rLocalName ) const;
+public:
+
+ SwXMLBrushItemExport(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLUnitConverter& rUnitConverter );
+ ~SwXMLBrushItemExport();
+
+ // core API
+ void exportXML( const SvxBrushItem& rItem,
+ const SvXMLNamespaceMap& rNamespMap );
+};
+
+
+#endif // _XMLBRSHE_HXX
+
diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx
new file mode 100644
index 000000000000..13c7a62f4376
--- /dev/null
+++ b/sw/source/filter/xml/xmlbrshi.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlbrshi.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _XMLBRSHI_HXX
+#define _XMLBRSHI_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include "xmlictxt.hxx"
+#endif
+
+class SvXMLImport;
+class SvXMLUnitConverter;
+class SvxBrushItem;
+
+namespace rtl { class OUString; }
+
+class SwXMLBrushItemImportContext : public SvXMLImportContext
+{
+private:
+ SvxBrushItem *pItem;
+
+ void ProcessAttrs(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv );
+
+public:
+ TYPEINFO();
+
+ SwXMLBrushItemImportContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvxBrushItem& rItem );
+
+ SwXMLBrushItemImportContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ const SvXMLUnitConverter& rUnitConv,
+ sal_uInt16 nWhich );
+
+ virtual ~SwXMLBrushItemImportContext();
+
+ const SvxBrushItem& GetItem() const { return *pItem; }
+};
+
+
+#endif // _XMLBRSHI_HXX
+
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
new file mode 100644
index 000000000000..e09dfdfb7074
--- /dev/null
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -0,0 +1,550 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlexp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _NODE_HXX //autogen wg. SwTableNode
+#include <node.hxx>
+#endif
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _MDIEXP_HXX
+#include <mdiexp.hxx> // ...Percent()
+#endif
+#ifndef _STATSTR_HRC
+#include <statstr.hrc> // ResId fuer Statusleiste
+#endif
+#ifndef _SHL_HXX //autogen wg. SHL_WRITER
+#include <tools/shl.hxx>
+#endif
+#ifndef _SWMODULE_HXX //autogen wg. SW_MOD
+#include <swmodule.hxx>
+#endif
+
+#ifndef _SWDOCSH_HXX
+#include <docsh.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTDOCUMENT_HPP_
+#include <com/sun/star/text/XTextDocument.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLCNITM_HXX
+#include <xmloff/xmlcnitm.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLASTPL_HXX
+#include <xmloff/xmlastpl.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTFLDE_HXX
+#include <xmloff/txtflde.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNUMFE_HXX
+#include <xmloff/xmlnumfe.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+
+#ifndef _XMLOFF_TXTPARAE_HXX
+#include <xmloff/txtparae.hxx>
+#endif
+#ifndef _XMLOFF_XMLASTPLP_HXX
+#include <xmloff/xmlaustp.hxx>
+#endif
+#ifndef _XMLOFF_TXTPRMAP_HXX
+#include <xmloff/txtprmap.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX_
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _XMLNUME_HXX
+#include <xmlnume.hxx>
+#endif
+#ifndef _XMLFMTE_HXX
+#include <xmlfmte.hxx>
+#endif
+#ifndef _XMLTEXTE_HXX
+#include <xmltexte.hxx>
+#endif
+#ifndef _XMLEXP_HXX
+#include <xmlexp.hxx>
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::text;
+
+#ifdef XML_CORE_API
+void SwXMLExport::SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly )
+{
+ if( !pCurPaM )
+ {
+ pCurPaM = new SwPaM( *rPaM.End(), *rPaM.Start() );
+ }
+ else
+ {
+ *pCurPaM->GetPoint() = *rPaM.Start();
+ *pCurPaM->GetMark() = *rPaM.End();
+ }
+
+ // Set PaM to table/section start node if whole doc should be exported
+ if( bWhole )
+ {
+ SwTableNode *pTblNd = pCurPaM->GetNode()->FindTableNode();
+ if( pTblNd )
+ {
+ pCurPaM->GetPoint()->nNode = *pTblNd;
+
+ if( bTabOnly )
+ pCurPaM->GetMark()->nNode = *pTblNd->EndOfSectionNode();
+ }
+
+ SwSectionNode * pSectNd = pCurPaM->GetNode()->FindSectionNode();
+ while( pSectNd )
+ {
+ pCurPaM->GetPoint()->nNode = *pSectNd;
+
+ // SwSectionNode::FindSectionNode() returns the section node itself
+ pSectNd = pSectNd->FindStartNode()->FindSectionNode();
+ }
+ }
+}
+#endif
+
+SwXMLExport::SwXMLExport( const Reference< XModel >& rModel, SwPaM& rPaM,
+ const OUString& rFileName,
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ sal_Bool bExpWholeDoc, sal_Bool bExpFirstTableOnly,
+ sal_Bool bShowProg ) :
+ SvXMLExport( rFileName, rHandler, rModel,
+ SW_MOD()->GetMetric( rPaM.GetDoc()->IsHTMLMode() ) ),
+ pDoc( rPaM.GetDoc() ),
+#ifdef XML_CORE_API
+ pCurPaM( 0 ),
+ pOrigPaM( &rPaM ),
+ pParaItemMapper( 0 ),
+#endif
+ pTableItemMapper( 0 ),
+#ifdef XML_CORE_API
+ pItemSetAutoStylePool( new SwXMLAutoStylePool ),
+ pListElements( 0 ),
+ pExportedLists( 0 ),
+#endif
+ pTableLines( 0 ),
+ bExportWholeDoc( bExpWholeDoc ),
+ bExportFirstTableOnly( bExpFirstTableOnly ),
+ bShowProgress( bShowProg )
+#ifdef XML_CORE_API
+ , pTextFieldExport( 0 ),
+ pNumberFormatExport( 0 )
+#endif
+{
+// _GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TEXT, sXML_np_text,
+// sXML_n_text, XML_NAMESPACE_TEXT );
+// _GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TABLE, sXML_np_table,
+// sXML_n_table, XML_NAMESPACE_TABLE );
+
+ const SfxPoolItem* pItem;
+ const SfxItemPool& rPool = pDoc->GetAttrPool();
+ sal_uInt16 nItems = rPool.GetItemCount( RES_UNKNOWNATR_CONTAINER );
+ sal_Bool bExtended = sal_False;
+ for( sal_uInt16 i = 0; i < nItems; ++i )
+ {
+ if( 0 != (pItem = rPool.GetItem( RES_UNKNOWNATR_CONTAINER, i ) ) )
+ {
+ const SvXMLAttrContainerItem *pUnknown =
+ (const SvXMLAttrContainerItem *)pItem;
+ if( (pUnknown->GetAttrCount() > 0) )
+ {
+ sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex();
+ while( USHRT_MAX != nIdx )
+ {
+ const OUString& rPrefix = pUnknown->GetPrefix( nIdx );
+ if( USHRT_MAX ==
+ GetNamespaceMap().GetIndexByPrefix( rPrefix ) )
+ {
+ // Add namespace declaration for unknown attributes if
+ // there aren't existing ones for the prefix used by the
+ // attibutes
+ _GetNamespaceMap().Add( rPrefix,
+ pUnknown->GetNamespace( nIdx ),
+ XML_NAMESPACE_UNKNOWN );
+ }
+ nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
+ }
+
+ bExtended = sal_True;
+ }
+ }
+ }
+
+ SetExtended( bExtended );
+
+#ifdef XML_CORE_API
+ SetCurPaM( rPaM, bExportWholeDoc, bExportFirstTableOnly );
+#endif
+
+ _InitItemExport();
+
+ if( bShowProgress )
+ ::StartProgress( STR_STATSTR_W4WWRITE, 0, pDoc->GetNodes().Count(),
+ pDoc->GetDocShell() );
+
+#ifdef XML_CORE_API
+ Reference< util::XNumberFormatsSupplier > xNumFmtSupp(
+ pDoc->GetDocShell()->GetBaseModel(), UNO_QUERY);
+ pNumberFormatExport = new SvXMLNumFmtExport( rHandler, xNumFmtSupp );
+
+ pTextFieldExport = new XMLTextFieldExport( *this );
+#endif
+
+ SfxObjectShell* pObjSh = pDoc->GetDocShell();
+ if( pObjSh )
+ pObjSh->UpdateDocInfoForSave(); // update information
+}
+
+#ifndef XML_CORE_API
+XMLTextParagraphExport* SwXMLExport::CreateTextParagraphExport()
+{
+ return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() );
+}
+#endif
+
+__EXPORT SwXMLExport::~SwXMLExport()
+{
+#ifdef XML_CORE_API
+ delete pItemSetAutoStylePool;
+#endif
+
+#ifdef XML_CORE_API
+ delete pTextFieldExport;
+ delete pNumberFormatExport;
+#endif
+
+ if( bShowProgress )
+ ::EndProgress( pDoc->GetDocShell() );
+
+#ifdef XML_CORE_API
+ if( pCurPaM )
+ {
+ while( pCurPaM->GetNext() != pCurPaM )
+ delete pCurPaM->GetNext();
+ delete pCurPaM;
+ }
+#endif
+ _FinitItemExport();
+#ifdef XML_CORE_API
+ _FinitNumRuleExport();
+#endif
+ ASSERT( !pTableLines, "there are table columns infos left" );
+}
+
+
+void SwXMLExport::_ExportContent()
+{
+#ifdef XML_CORE_API
+ // export field declarations
+// pTextFieldExport->ExportFieldDeclarations();
+
+ // export all PaMs
+ SwPaM *pPaM = pOrigPaM;
+ sal_Bool bContinue = sal_True;
+ do
+ {
+ // export PaM content
+ ExportCurPaM( bExportWholeDoc );
+
+ bContinue = pPaM->GetNext() != pOrigPaM;
+
+ if( bContinue )
+ {
+ pPaM = (SwPaM *)pPaM->GetNext();
+ SetCurPaM( *pPaM, bExportWholeDoc, bExportFirstTableOnly );
+ }
+
+ } while( bContinue );
+#else
+ GetTextParagraphExport()->exportTextDeclarations();
+ Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
+ Reference < XText > xText = xTextDoc->getText();
+
+ GetTextParagraphExport()->exportFramesBoundToPage();
+ GetTextParagraphExport()->exportText( xText );
+#endif
+}
+
+#ifdef XML_CORE_API
+void SwXMLExport::ExportCurPaM( sal_Bool bExportWholePaM )
+{
+ sal_Bool bFirstNode = sal_True;
+ sal_Bool bExportWholeNode = bExportWholePaM;
+
+ SwXMLNumRuleInfo aPrevNumInfo;
+ SwXMLNumRuleInfo aNextNumInfo;
+
+ while( pCurPaM->GetPoint()->nNode.GetIndex() <
+ pCurPaM->GetMark()->nNode.GetIndex() ||
+ ( pCurPaM->GetPoint()->nNode.GetIndex() ==
+ pCurPaM->GetMark()->nNode.GetIndex() &&
+ pCurPaM->GetPoint()->nContent.GetIndex() <=
+ pCurPaM->GetMark()->nContent.GetIndex() ) )
+ {
+ SwNode *pNd = pCurPaM->GetNode();
+
+ aNextNumInfo.Set( *pNd );
+ ExportListChange( aPrevNumInfo, aNextNumInfo );
+
+ ASSERT( !(pNd->IsGrfNode() || pNd->IsOLENode()),
+ "SwXMLExport::exportCurPaM: grf or OLE node unexpected" );
+ if( pNd->IsTxtNode() )
+ {
+ SwTxtNode* pTxtNd = pNd->GetTxtNode();
+
+ if( !bFirstNode )
+ pCurPaM->GetPoint()->nContent.Assign( pTxtNd, 0 );
+
+ ExportTxtNode( *pTxtNd, 0, STRING_LEN, bExportWholeNode );
+ }
+ else if( pNd->IsTableNode() )
+ {
+ ExportTable( *pNd->GetTableNode() );
+ }
+ else if( pNd->IsSectionNode() )
+ {
+ ExportSection( *pNd->GetSectionNode() );
+ }
+ else if( pNd == &pDoc->GetNodes().GetEndOfContent() )
+ break;
+
+ pCurPaM->GetPoint()->nNode++; // next node
+
+ sal_uInt32 nPos = pCurPaM->GetPoint()->nNode.GetIndex();
+ if( bShowProgress )
+ ::SetProgressState( nPos, pDoc->GetDocShell() );
+
+ // if not everything should be exported, the WriteAll flag must be
+ // set for all but the first and last node anyway.
+ bExportWholeNode = bExportWholePaM ||
+ nPos != pCurPaM->GetMark()->nNode.GetIndex();
+ bFirstNode = sal_False;
+
+ aPrevNumInfo = aNextNumInfo;
+ }
+ aNextNumInfo.Reset();
+ ExportListChange( aPrevNumInfo, aNextNumInfo );
+}
+#endif
+
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlexp.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.35 2000/09/18 16:05:05 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.34 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.33 2000/08/15 11:55:56 kz
+ #65293# del. 2. Parameter
+
+ Revision 1.32 2000/08/10 10:22:15 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.31 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.30 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.29 2000/07/27 08:06:33 mib
+ text import continued
+
+ Revision 1.28 2000/07/26 05:11:20 mib
+ text import/export continued
+
+ Revision 1.27 2000/07/24 12:01:21 dvo
+ - field declarations now exported at content beginning
+
+ Revision 1.26 2000/07/24 10:19:02 dvo
+ - textfield export for XML_CORE_API
+
+ Revision 1.25 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.24 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.23 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.22 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.21 2000/02/11 14:40:57 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.20 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.19 2000/01/20 10:03:15 mib
+ #70271#: Lists reworked
+
+ Revision 1.18 2000/01/12 15:00:22 mib
+ #70271#: lists
+
+ Revision 1.17 2000/01/06 15:08:27 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.16 1999/12/06 14:49:49 mib
+ #70271#: office:version attribute
+
+ Revision 1.15 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.14 1999/11/26 11:08:59 mib
+ progress, export-flags
+
+ Revision 1.13 1999/11/22 15:52:34 os
+ headers added
+
+ Revision 1.12 1999/11/17 20:07:53 nn
+ document language
+
+ Revision 1.11 1999/11/12 14:50:28 mib
+ meta import and export reactivated
+
+ Revision 1.10 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.9 1999/11/09 15:40:29 mib
+ Using XMLItemMapper for export
+
+ Revision 1.8 1999/11/05 19:43:18 nn
+ _ExportMeta
+
+ Revision 1.7 1999/10/26 13:34:30 mib
+ removed 'using namespace' from header files
+
+ Revision 1.6 1999/10/08 11:47:09 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.5 1999/09/22 11:56:47 mib
+ string -> wstring
+
+ Revision 1.4 1999/08/17 14:28:22 MIB
+ namespace map methods renamed consistently
+
+
+ Rev 1.3 17 Aug 1999 16:28:22 MIB
+ namespace map methods renamed consistently
+
+ Rev 1.2 13 Aug 1999 16:21:14 MIB
+ new base class XMLExport, styles and sections
+
+ Rev 1.1 12 Aug 1999 18:05:20 MIB
+ Export ofSvxFontItem, SvxFontHeightItem and SvxLRSpaceItem
+
+ Rev 1.0 12 Aug 1999 12:28:54 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
new file mode 100644
index 000000000000..9926723753c3
--- /dev/null
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlexp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _XMLEXP_HXX
+#define _XMLEXP_HXX
+
+#ifndef _XMLOFF_XMLEXP_HXX
+#include <xmloff/xmlexp.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+#ifndef _UNIVERSALL_REFERENCE_HXX
+#include <xmloff/uniref.hxx>
+#endif
+
+class SwDoc;
+class SwPaM;
+class SwTxtNode;
+class SwSectionNode;
+class SwFmt;
+class SwFrmFmt;
+class SvXMLUnitConverter;
+class SvXMLExportItemMapper;
+class SwXMLAutoStylePool;
+class SvXMLAutoStylePool;
+class SvXMLAutoStylePoolP;
+class SwNodeNum;
+class SfxPoolItem;
+class SfxItemSet;
+class SwXMLNumRuleInfo;
+class OUStrings_Impl;
+class OUStringsSort_Impl;
+class SwTableLine;
+class SwTableLines;
+class SwTableBox;
+class SwXMLTableColumn_Impl;
+class SwXMLTableLines_Impl;
+class SwXMLTableLinesCache_Impl;
+class SwXMLTableColumnsSortByWidth_Impl;
+class SwXMLTableFrmFmtsSort_Impl;
+class SwTableNode;
+#ifdef XML_CORE_API
+class SvXMLNumFmtExport;
+class XMLTextFieldExport;
+#endif
+class XMLPropertySetMapper;
+class SwXMLTextParagraphExport;
+
+class SwXMLExport : public SvXMLExport
+{
+ friend class SwXMLExpContext;
+
+ SwDoc *pDoc; // the current doc
+#ifdef XML_CORE_API
+ SwPaM *pCurPaM; // the current PaM
+ SwPaM *pOrigPaM; // the original PaM
+#endif
+
+ SvXMLUnitConverter *pTwipUnitConv;
+
+#ifdef XML_CORE_API
+ SvXMLExportItemMapper *pParaItemMapper;
+#endif
+ SvXMLExportItemMapper *pTableItemMapper;
+#ifdef XML_CORE_API
+ SwXMLAutoStylePool *pItemSetAutoStylePool;
+ OUStrings_Impl *pListElements;
+ OUStringsSort_Impl *pExportedLists;
+#endif
+ SwXMLTableLinesCache_Impl *pTableLines;
+#ifdef XML_CORE_API
+ SvXMLNumFmtExport *pNumberFormatExport;
+ XMLTextFieldExport *pTextFieldExport;
+#endif
+
+ SvXMLItemMapEntriesRef xTableItemMap;
+ SvXMLItemMapEntriesRef xTableRowItemMap;
+ SvXMLItemMapEntriesRef xTableCellItemMap;
+ UniReference < XMLPropertySetMapper > xParaPropMapper;
+
+ sal_Bool bExportWholeDoc : 1;// export whole document?
+ sal_Bool bExportFirstTableOnly : 1;
+ sal_Bool bShowProgress : 1;
+
+ void _InitItemExport();
+ void _FinitItemExport();
+#ifdef XML_CORE_API
+ void _FinitNumRuleExport();
+
+ void AddTextAutoStyle( const SfxPoolItem& rItem );
+ void AddParaAutoStyle( const ::rtl::OUString& rParent,
+ const SfxItemSet& rItemSet );
+ ::rtl::OUString FindTextAutoStyle( const SfxPoolItem& rItem );
+ ::rtl::OUString FindParaAutoStyle( const ::rtl::OUString& rParent,
+ const SfxItemSet& rItemSet );
+
+ void ExportCurPaMAutoStyles( sal_Bool bExportWholePaM=sal_True );
+ void ExportTxtNodeAutoStyles( const SwTxtNode& rTxtNd, xub_StrLen nStart,
+ xub_StrLen nEnd, sal_Bool bExportWholeNode );
+ void ExportSectionAutoStyles( const SwSectionNode& rSectNd );
+#endif
+ void ExportTableLinesAutoStyles( const SwTableLines& rLines,
+ sal_uInt32 nAbsWidth,
+ sal_uInt32 nBaseWidth,
+ const ::rtl::OUString& rNamePrefix,
+ SwXMLTableColumnsSortByWidth_Impl& rExpCols,
+ SwXMLTableFrmFmtsSort_Impl& rExpRows,
+ SwXMLTableFrmFmtsSort_Impl& rExpCells,
+ sal_Bool bTop=sal_False );
+
+#ifdef XML_CORE_API
+ void ExportCurPaM( sal_Bool bExportWholePaM=sal_True );
+ void ExportTxtNode( const SwTxtNode& rTxtNd, xub_StrLen nStart,
+ xub_StrLen nEnd, sal_Bool bExportWholeNode );
+ void ExportSection( const SwSectionNode& rSectNd );
+#endif
+
+ void ExportFmt( const SwFmt& rFmt, const sal_Char *pFamily = 0 );
+ void ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth );
+#ifdef XML_CORE_API
+ void ExportNumRules( sal_Bool bAuto, sal_Bool bUsed );
+ void ExportNodeNum( const SwNodeNum& rNdNum );
+ void ExportListChange( const SwXMLNumRuleInfo& rPrvInfo,
+ const SwXMLNumRuleInfo& rNextInfo );
+#endif
+
+ void ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol );
+ void ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan );
+ void ExportTableLine( const SwTableLine& rLine,
+ const SwXMLTableLines_Impl& rLines );
+ void ExportTableLines( const SwTableLines& rLines,
+ sal_Bool bHeadline=sal_False );
+
+// virtual void _ExportMeta();
+ virtual void _ExportStyles( sal_Bool bUsed );
+ virtual void _ExportAutoStyles();
+ virtual void _ExportMasterStyles();
+ virtual void _ExportContent();
+
+#ifdef XML_CORE_API
+ void SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly );
+#endif
+
+protected:
+
+#ifndef XML_CORE_API
+ virtual XMLTextParagraphExport* CreateTextParagraphExport();
+ virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
+#endif
+
+public:
+
+ SwXMLExport( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & rModel,
+ SwPaM& rPaM, const ::rtl::OUString& rFileName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
+ sal_Bool bExpWholeDoc, sal_Bool bExpFirstTableOnly,
+ sal_Bool bShowProgr );
+ virtual ~SwXMLExport();
+
+ inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
+
+ void ExportTableAutoStyles( const SwTableNode& rTblNd );
+ void ExportTable( const SwTableNode& rTblNd );
+
+#ifdef XML_CORE_API
+ SvXMLExportItemMapper& GetParaItemMapper() { return *pParaItemMapper; }
+#endif
+ SvXMLExportItemMapper& GetTableItemMapper() { return *pTableItemMapper; }
+ const UniReference < XMLPropertySetMapper >& GetParaPropMapper()
+ {
+ return xParaPropMapper;
+ }
+#ifdef XML_CORE_API
+ SwXMLAutoStylePool& GetItemSetAutoStylePool() { return *pItemSetAutoStylePool; }
+#endif
+
+#ifdef XML_CORE_API
+ SvXMLNumFmtExport& GetNumberFormatExport() { return *pNumberFormatExport; }
+ XMLTextFieldExport& GetTextFieldExport() { return *pTextFieldExport; }
+#endif
+
+ SwDoc& GetDoc() { return *pDoc; }
+};
+
+inline const SvXMLUnitConverter& SwXMLExport::GetTwipUnitConverter() const
+{
+ return *pTwipUnitConv;
+}
+
+
+#endif // _XMLEXP_HXX
+
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
new file mode 100644
index 000000000000..2a8d964c4d72
--- /dev/null
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -0,0 +1,1814 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlfmt.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+
+#ifndef _SVSTDARR_STRINGSSORT_DECL
+#define _SVSTDARR_STRINGSSORT
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _FORMAT_HXX //autogen wg. SwFmt
+#include <format.hxx>
+#endif
+#ifndef _FMTCOL_HXX //autogen wg. SwTxtFmtColl
+#include <fmtcol.hxx>
+#endif
+#ifndef _HINTS_HXX //autogen wg. SwFmtChg
+#include <hints.hxx>
+#endif
+
+#ifndef _POOLFMT_HXX //autogen wg. RES_POOL_CHRFMT_TYPE
+#include <poolfmt.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen wg. SwCharFmt
+#include <charfmt.hxx>
+#endif
+#ifndef _FRMFMT_HXX //autogen wg. SwFrmFmt
+#include <frmfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#include "docary.hxx"
+#ifndef _UNOSTYLE_HXX
+#include "unostyle.hxx"
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLITEM_HXX
+#include <xmloff/xmlitem.hxx>
+#endif
+#ifndef _XMLOFF_XMLSTYLE_HXX
+#include <xmloff/xmlstyle.hxx>
+#endif
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+#ifndef _XMLOFF_TXTSTYLI_HXX
+#include <xmloff/txtstyli.hxx>
+#endif
+#ifndef _XMLOFF_TXTIMP_HXX
+#include <xmloff/txtimp.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _NUMRULE_HXX
+#include <numrule.hxx>
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLNUM_HXX
+#include "xmlnum.hxx"
+#endif
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::rtl;
+
+class SwXMLConditionParser_Impl
+{
+ OUString sInput;
+
+ sal_uInt32 nCondition;
+ sal_uInt32 nSubCondition;
+
+ sal_Int32 nPos;
+ sal_Int32 nLength;
+
+ inline sal_Bool SkipWS();
+ inline sal_Bool MatchChar( sal_Unicode c );
+ inline sal_Bool MatchName( OUString& rName );
+ inline sal_Bool MatchNumber( sal_uInt32& rNumber );
+
+public:
+
+ SwXMLConditionParser_Impl( const OUString& rInp );
+
+ sal_Bool IsValid() const { return 0 != nCondition; }
+
+ sal_uInt32 GetCondition() const { return nCondition; }
+ sal_uInt32 GetSubCondition() const { return nSubCondition; }
+};
+
+inline sal_Bool SwXMLConditionParser_Impl::SkipWS()
+{
+ while( nPos < nLength && ' ' == sInput[nPos] )
+ nPos++;
+ return sal_True;
+}
+
+inline sal_Bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
+{
+ sal_Bool bRet = sal_False;
+ if( nPos < nLength && c == sInput[nPos] )
+ {
+ nPos++;
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+inline sal_Bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
+{
+ OUStringBuffer sBuffer( nLength );
+ while( nPos < nLength &&
+ ( ('a' <= sInput[nPos] && sInput[nPos] <= 'z') ||
+ '-' == sInput[nPos] ) )
+ {
+ sBuffer.append( sInput[nPos] );
+ nPos++;
+ }
+ rName = sBuffer.makeStringAndClear();
+ return rName.getLength() > 0;
+}
+
+inline sal_Bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
+{
+ OUStringBuffer sBuffer( nLength );
+ while( nPos < nLength && '0' <= sInput[nPos] && sInput[nPos] <= '9' )
+ {
+ sBuffer.append( sInput[nPos] );
+ nPos++;
+ }
+
+ OUString sNum( sBuffer.makeStringAndClear() );
+ if( sNum.getLength() )
+ rNumber = sNum.toInt32();
+ return sNum.getLength() > 0;
+}
+
+SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
+ sInput( rInp ),
+ nPos( 0 ),
+ nLength( rInp.getLength() ),
+ nCondition( 0 ),
+ nSubCondition( 0 )
+{
+ OUString sFunc;
+ sal_Bool bHasSub = sal_False;
+ sal_uInt32 nSub = 0;
+ sal_Bool bOK = SkipWS() && MatchName( sFunc ) && SkipWS() &&
+ MatchChar( '(' ) && SkipWS() && MatchChar( ')' ) && SkipWS();
+ if( bOK && MatchChar( '=' ) )
+ {
+ bOK = SkipWS() && MatchNumber( nSub ) && SkipWS();
+ bHasSub = sal_True;
+ }
+
+ bOK &= nPos == nLength;
+
+ if( bOK )
+ {
+ switch( sFunc[0] )
+ {
+ case 'e':
+ if( sFunc.compareToAscii( sXML_endnote ) == 0 && !bHasSub )
+ nCondition = PARA_IN_ENDNOTE;
+ break;
+
+ case 'f':
+ if( sFunc.compareToAscii( sXML_footer ) == 0 && !bHasSub )
+ nCondition = PARA_IN_FOOTER;
+ else if( sFunc.compareToAscii( sXML_table_header ) == 0 &&
+ !bHasSub )
+ nCondition = PARA_IN_FOOTENOTE;
+ break;
+
+ case 'h':
+ if( sFunc.compareToAscii( sXML_header ) == 0 && !bHasSub )
+ nCondition = PARA_IN_HEADER;
+ break;
+
+ case 'l':
+ if( sFunc.compareToAscii( sXML_list_level ) == 0 &&
+ nSub >=1 && nSub < MAXLEVEL )
+ {
+ nCondition = PARA_IN_LIST;
+ nSubCondition = nSub-1;
+ }
+ break;
+
+ case 'o':
+ if( sFunc.compareToAscii( sXML_outline_level ) == 0 &&
+ nSub >=1 && nSub < MAXLEVEL )
+ {
+ nCondition = PARA_IN_OUTLINE;
+ nSubCondition = nSub-1;
+ }
+ break;
+
+ case 's':
+ if( sFunc.compareToAscii( sXML_section ) == 0 && !bHasSub )
+ {
+ nCondition = PARA_IN_SECTION;
+ }
+ break;
+
+ case 't':
+ if( sFunc.compareToAscii( sXML_table ) == 0 && !bHasSub )
+ {
+ nCondition = PARA_IN_TABLEBODY;
+ }
+ else if( sFunc.compareToAscii( sXML_table_header ) == 0 &&
+ !bHasSub )
+ {
+ nCondition = PARA_IN_TABLEHEAD;
+ }
+ else if( sFunc.compareToAscii( sXML_text_box ) == 0 && !bHasSub )
+ {
+ nCondition = PARA_IN_FRAME;
+ }
+ break;
+ }
+ }
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLConditionContext_Impl : public SvXMLImportContext
+{
+ sal_uInt32 nCondition;
+ sal_uInt32 nSubCondition;
+
+ OUString sApplyStyle;
+
+ void ParseCondition( const OUString& rCond );
+
+public:
+
+ SwXMLConditionContext_Impl(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual ~SwXMLConditionContext_Impl();
+
+ sal_Bool IsValid() const { return 0 != nCondition; }
+
+ sal_uInt32 GetCondition() const { return nCondition; }
+ sal_uInt32 GetSubCondition() const { return nSubCondition; }
+ const OUString& GetApplyStyle() const { return sApplyStyle; }
+};
+
+SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ nCondition( 0 ),
+ nSubCondition( 0 )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+
+ // TODO: use a map here
+ if( XML_NAMESPACE_STYLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_condition ) == 0 )
+ {
+ SwXMLConditionParser_Impl aCondParser( rValue );
+ if( aCondParser.IsValid() )
+ {
+ nCondition = aCondParser.GetCondition();
+ nSubCondition = aCondParser.GetSubCondition();
+ }
+ }
+ else if( aLocalName.compareToAscii( sXML_apply_style_name ) == 0 )
+ {
+ sApplyStyle = rValue;
+ }
+ }
+ }
+}
+
+SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLConditionContext_Impl *SwXMLConditionContextPtr;
+SV_DECL_PTRARR( SwXMLConditions_Impl, SwXMLConditionContextPtr, 5, 2 );
+
+#ifndef XML_CORE_API
+
+class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
+{
+ SwXMLConditions_Impl *pConditions;
+
+protected:
+
+ virtual Reference < XStyle > Create();
+
+public:
+
+ TYPEINFO();
+
+ SwXMLTextStyleContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_uInt16 nFamily,
+ SvXMLStylesContext& rStyles );
+ virtual ~SwXMLTextStyleContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ virtual void Finish( sal_Bool bOverwrite );
+};
+
+TYPEINIT1( SwXMLTextStyleContext_Impl, XMLTextStyleContext );
+
+Reference < XStyle > SwXMLTextStyleContext_Impl::Create()
+{
+ Reference < XStyle > xNewStyle;
+
+ if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
+ {
+ Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(),
+ UNO_QUERY );
+ if( xFactory.is() )
+ {
+ OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.style.ConditionalParagraphStyle" ) );
+ Reference < XInterface > xIfc =
+ xFactory->createInstance( sServiceName );
+ if( xIfc.is() )
+ xNewStyle = Reference < XStyle >( xIfc, UNO_QUERY );
+ }
+ }
+ else
+ {
+ xNewStyle = XMLTextStyleContext::Create();
+ }
+
+ return xNewStyle;
+}
+
+SwXMLTextStyleContext_Impl::SwXMLTextStyleContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_uInt16 nFamily,
+ SvXMLStylesContext& rStyles ) :
+ XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles ),
+ pConditions( 0 )
+{
+ SetFamily( nFamily );
+}
+
+SwXMLTextStyleContext_Impl::~SwXMLTextStyleContext_Impl()
+{
+ if( pConditions )
+ {
+ while( pConditions->Count() )
+ {
+ SwXMLConditionContext_Impl *pCond = pConditions->GetObject(0);
+ pConditions->Remove( 0UL );
+ pCond->ReleaseRef();
+ }
+ delete pConditions;
+ }
+}
+
+SvXMLImportContext *SwXMLTextStyleContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_STYLE == nPrefix &&
+ rLocalName.compareToAscii( sXML_map ) == 0 )
+ {
+ SwXMLConditionContext_Impl *pCond =
+ new SwXMLConditionContext_Impl( GetImport(), nPrefix,
+ rLocalName, xAttrList );
+ if( pCond->IsValid() )
+ {
+ if( !pConditions )
+ pConditions = new SwXMLConditions_Impl;
+ pConditions->Insert( pCond, pConditions->Count() );
+ pCond->AddRef();
+ }
+ pContext = pCond;
+ }
+
+ if( !pContext )
+ pContext = XMLTextStyleContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList );
+
+ return pContext;
+}
+
+void SwXMLTextStyleContext_Impl::Finish( sal_Bool bOverwrite )
+{
+ XMLTextStyleContext::Finish( bOverwrite );
+
+ if( !pConditions || XML_STYLE_FAMILY_TEXT_PARAGRAPH != GetFamily() )
+ return;
+
+ Reference < XStyle > xStyle = GetStyle();
+ if( !xStyle.is() )
+ return;
+
+ const SwXStyle* pStyle = 0;
+ Reference<XUnoTunnel> xStyleTunnel( xStyle, UNO_QUERY);
+ if( xStyleTunnel.is() )
+ {
+ pStyle = (SwXStyle*)xStyleTunnel->getSomething(
+ SwXStyle::getUnoTunnelId() );
+ }
+ if( !pStyle )
+ return;
+
+ SwDoc& rDoc = ((SwXMLImport&)GetImport()).GetDoc();
+
+ const OUString& rName =
+ SwXStyleFamilies::GetUIName( GetName(), SFX_STYLE_FAMILY_PARA );
+ SwTxtFmtColl *pColl = rDoc.FindTxtFmtCollByName( rName );
+ ASSERT( pColl, "Text collection not found" );
+ if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() )
+ return;
+
+ sal_uInt16 nCount = pConditions->Count();
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
+ const OUString& rName =
+ SwXStyleFamilies::GetUIName( pCond->GetApplyStyle(),
+ SFX_STYLE_FAMILY_PARA );
+ SwTxtFmtColl* pCondColl = rDoc.FindTxtFmtCollByName( rName );
+ ASSERT( pCondColl,
+ "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
+ if( pCondColl )
+ {
+ SwCollCondition aCond( pCondColl, pCond->GetCondition(),
+ pCond->GetSubCondition() );
+ ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
+ }
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
+{
+#ifdef XML_CORE_API
+ OUString sListStyleName;
+ SwFmt *pFmt;
+#endif
+ SfxItemSet *pItemSet;
+
+#ifdef XML_CORE_API
+ SwXMLConditions_Impl *pConditions;
+
+ sal_uInt16 nPoolId; // PoolId
+ sal_Bool bAutoUpdate;
+#endif
+
+ SvXMLImportContext *CreateItemSetContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList);
+
+protected:
+
+#ifdef XML_CORE_API
+ virtual void SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue );
+#endif
+
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+public:
+
+ TYPEINFO();
+
+ SwXMLItemSetStyleContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList
+#ifndef XML_CORE_API
+ ,sal_uInt16 nFamily
+#endif
+ );
+ virtual ~SwXMLItemSetStyleContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+#ifdef XML_CORE_API
+ sal_uInt16 GetPoolId() const { return nPoolId; }
+ sal_Bool IsAutoUpdate() const { return bAutoUpdate; }
+#endif
+
+ // The item set may be empty!
+ SfxItemSet *GetItemSet() { return pItemSet; }
+ const SfxItemSet *GetItemSet() const { return pItemSet; }
+
+#ifdef XML_CORE_API
+ SwFmt *GetFmt() { return pFmt; }
+ void SetFmt( SwFmt *p ) { pFmt = p; }
+
+ SwTxtFmtColl* GetColl();
+
+ sal_Bool HasConditions() const { return 0 != pConditions &&
+ pConditions->Count() > 0; }
+ const OUString& GetListStyle() const { return sListStyleName; }
+
+ void ConnectParent();
+ void ConnectFollow();
+ void ConnectConditions();
+ void ConnectListStyle();
+ void ConnectAutoListStyle();
+#endif
+};
+
+#ifdef XML_CORE_API
+void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey,
+ const OUString& rLocalName,
+ const OUString& rValue )
+{
+ // TODO: use a map here
+ if( XML_NAMESPACE_STYLE == nPrefixKey )
+ {
+ if( rLocalName.compareToAscii( sXML_family ) == 0 )
+ {
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL;
+ sal_uInt16 nSubFamily = 0U;
+ if( rValue.compareToAscii( sXML_paragraph ) == 0 )
+ {
+ eFamily = SFX_STYLE_FAMILY_PARA;
+ }
+ else if( rValue.compareToAscii( sXML_text ) == 0 )
+ {
+ eFamily = SFX_STYLE_FAMILY_CHAR;
+ }
+ else if( 0 == rValue.compareToAscii( sXML_table, 5L ) )
+ {
+ eFamily = SFX_STYLE_FAMILY_FRAME;
+ if( 5L == rValue.getLength() )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE;
+ else if( rValue.compareToAscii( sXML_table_column ) == 0 )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE_COL;
+ else if( rValue.compareToAscii( sXML_table_row ) == 0 )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE_LINE;
+ else if( rValue.compareToAscii( sXML_table_cell ) == 0 )
+ nSubFamily = SW_STYLE_SUBFAMILY_TABLE_BOX;
+ else
+ eFamily = SFX_STYLE_FAMILY_ALL;
+ }
+
+ if( SFX_STYLE_FAMILY_ALL != eFamily )
+ {
+ SetFamily( eFamily );
+ SetSubFamily( nSubFamily );
+ }
+ }
+ else if( rLocalName.compareToAscii( sXML_pool_id ) == 0 )
+ {
+ sal_Int32 nTmp = rValue.toInt32();
+ nPoolId =
+ (nTmp < 0L) ? 0U : ( (nTmp > USHRT_MAX) ? USHRT_MAX
+ : (sal_uInt16)nTmp );
+ }
+ else if( rLocalName.compareToAscii( sXML_auto_update ) == 0 )
+ {
+ if( rValue.compareToAscii( sXML_true ) == 0 )
+ bAutoUpdate = sal_True;
+ }
+ else if( rLocalName.compareToAscii( sXML_list_style_name ) == 0 )
+ {
+ sListStyleName = rValue;
+ }
+ else
+ {
+ SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ }
+ }
+ else
+ {
+ SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ }
+}
+#endif
+
+SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
+ sal_uInt16 nPrefix, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ ASSERT( !pItemSet,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: item set exists" );
+
+ SvXMLImportContext *pContext = 0;
+ SfxItemPool& rItemPool = GetSwImport().GetDoc().GetAttrPool();
+
+#ifdef XML_CORE_API
+ switch( GetFamily() )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ pItemSet = new SfxItemSet( rItemPool, aTxtFmtCollSetRange );
+ pContext = GetSwImport().CreateParaItemImportContext(
+ nPrefix, rLName, xAttrList, *pItemSet );
+ break;
+
+ case SFX_STYLE_FAMILY_CHAR:
+ pItemSet = new SfxItemSet( rItemPool, aCharFmtSetRange );
+ pContext = GetSwImport().CreateParaItemImportContext(
+ nPrefix, rLName, xAttrList, *pItemSet );
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ {
+ switch( GetSubFamily() )
+ {
+ case SW_STYLE_SUBFAMILY_TABLE:
+ pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
+ break;
+ case SW_STYLE_SUBFAMILY_TABLE_COL:
+ pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE,
+ RES_FRM_SIZE, 0 );
+ break;
+ case SW_STYLE_SUBFAMILY_TABLE_LINE:
+ pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
+ break;
+ case SW_STYLE_SUBFAMILY_TABLE_BOX:
+ pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
+ break;
+ }
+ if( pItemSet )
+ pContext = GetSwImport().CreateTableItemImportContext(
+ nPrefix, rLName, xAttrList, GetSubFamily(),
+ *pItemSet );
+ ASSERT( pItemSet,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: frames are unsopprted");
+ }
+ break;
+
+ default:
+ ASSERT( !this,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
+ break;
+ }
+#else
+ switch( GetFamily() )
+ {
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
+ break;
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 );
+ break;
+ case XML_STYLE_FAMILY_TABLE_ROW:
+ pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
+ break;
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
+ break;
+ default:
+ ASSERT( !this,
+ "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
+ break;
+ }
+ if( pItemSet )
+ pContext = GetSwImport().CreateTableItemImportContext(
+ nPrefix, rLName, xAttrList, GetFamily(),
+ *pItemSet );
+#endif
+
+ if( !pContext )
+ {
+ delete pItemSet;
+ pItemSet = 0;
+ }
+
+ return pContext;
+}
+
+TYPEINIT1( SwXMLItemSetStyleContext_Impl, SvXMLStyleContext );
+
+SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList
+#ifndef XML_CORE_API
+ ,sal_uInt16 nFamily
+#endif
+ ) :
+ SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList ),
+#ifdef XML_CORE_API
+ nPoolId( USHRT_MAX ),
+ bAutoUpdate( sal_False ),
+ pFmt( 0 ),
+ pConditions( 0 ),
+#endif
+ pItemSet( 0 )
+{
+#ifndef XML_CORE_API
+ SetFamily( nFamily );
+#endif
+}
+
+SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl()
+{
+ delete pItemSet;
+#ifdef XML_CORE_API
+ if( pConditions )
+ {
+ while( pConditions->Count() )
+ {
+ SwXMLConditionContext_Impl *pCond = pConditions->GetObject(0);
+ pConditions->Remove( 0UL );
+ pCond->ReleaseRef();
+ }
+ delete pConditions;
+ }
+#endif
+}
+
+SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_STYLE == nPrefix )
+ {
+ if( rLocalName.compareToAscii( sXML_properties ) == 0 )
+ {
+ pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList );
+ }
+#ifdef XML_CORE_API
+ else if( rLocalName.compareToAscii( sXML_map ) == 0 )
+ {
+ SwXMLConditionContext_Impl *pCond =
+ new SwXMLConditionContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList );
+ if( pCond->IsValid() )
+ {
+ if( !pConditions )
+ pConditions = new SwXMLConditions_Impl;
+ pConditions->Insert( pCond, pConditions->Count() );
+ pCond->AddRef();
+ }
+ pContext = pCond;
+ }
+#endif
+ }
+
+ if( !pContext )
+ pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList );
+
+ return pContext;
+}
+
+#ifdef XML_CORE_API
+SwTxtFmtColl* SwXMLItemSetStyleContext_Impl::GetColl()
+{
+ return (GetFamily() & SFX_STYLE_FAMILY_PARA) != 0
+ ? (SwTxtFmtColl*) pFmt
+ : NULL;
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectParent()
+{
+ if( !pFmt )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( GetFamily(), GetParent() ) );
+
+// String aName( SwXStyleFamilies::GetUIName( GetParent(),
+// (SfxStyleFamily)GetFamily() ) );
+ SwFmt* pParent;
+ switch( GetFamily() )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ if( aName.Len() )
+ pParent = pDoc->FindTxtFmtCollByName( aName );
+ else
+ pParent = (*pDoc->GetTxtFmtColls())[ 0 ];
+ break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ if( aName.Len() )
+ pParent = pDoc->FindFrmFmtByName( aName );
+ else
+ pParent = (*pDoc->GetFrmFmts())[ 0 ];
+ break;
+
+ case SFX_STYLE_FAMILY_CHAR:
+ if( aName.Len() )
+ pParent = pDoc->FindCharFmtByName( aName );
+ else
+ pParent = (*pDoc->GetCharFmts())[ 0 ];
+ break;
+ }
+
+ if( pParent )
+ pFmt->SetDerivedFrom( pParent );
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectFollow()
+{
+ if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( GetFamily(), GetFollow() ) );
+// String aName( SwXStyleFamilies::GetUIName( GetFollow(), (SfxStyleFamily)GetFamily() ) );
+
+ SwTxtFmtColl* pFollow;
+ if( aName.Len() )
+ pFollow = pDoc->FindTxtFmtCollByName( aName );
+ else
+ pFollow = GetColl();
+ if( pFollow )
+ GetColl()->SetNextTxtFmtColl( *pFollow );
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectConditions()
+{
+ if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA || !pConditions ||
+ RES_CONDTXTFMTCOLL != pFmt->Which() )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ SvI18NMap& rI18NMap = ((SwXMLImport&)GetImport()).GetI18NMap();
+
+ sal_uInt16 nCount = pConditions->Count();
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
+ OUString sName( rI18NMap.Get( SFX_STYLE_FAMILY_PARA,
+ pCond->GetApplyStyle() ) );
+// OUString sName( SwXStyleFamilies::GetUIName(
+// pCond->GetApplyStyle(), SFX_STYLE_FAMILY_PARA ) );
+ SwTxtFmtColl* pCondColl = pDoc->FindTxtFmtCollByName( sName );
+ ASSERT( pCondColl,
+ "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
+ if( pCondColl )
+ {
+ SwCollCondition aCond( pCondColl, pCond->GetCondition(),
+ pCond->GetSubCondition() );
+ ((SwConditionTxtFmtColl*)pFmt)->InsertCondition( aCond );
+ }
+ }
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectListStyle()
+{
+ if( !pFmt || GetFamily() != SFX_STYLE_FAMILY_PARA ||
+ !GetListStyle().getLength() )
+ return;
+
+ SwDoc *pDoc = pFmt->GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( SFX_STYLE_FAMILY_PSEUDO,
+ GetListStyle() ) );
+// String aName( SwXStyleFamilies::GetUIName(
+// GetListStyle(), SFX_STYLE_FAMILY_PSEUDO ) );
+ // Styles must not reference automatic num rules
+ SwNumRule *pNumRule = pDoc->FindNumRulePtr( aName );
+ if( pNumRule && !pNumRule->IsAutoRule() )
+ GetColl()->SetAttr( SwNumRuleItem(aName) );
+}
+
+void SwXMLItemSetStyleContext_Impl::ConnectAutoListStyle()
+{
+ if( GetFamily() != SFX_STYLE_FAMILY_PARA || !GetListStyle().getLength() )
+ return;
+
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ String aName( GetSwImport().GetI18NMap().Get( SFX_STYLE_FAMILY_PSEUDO,
+ GetListStyle() ) );
+// String aName( SwXStyleFamilies::GetUIName(
+// GetListStyle(), SFX_STYLE_FAMILY_PSEUDO ) );
+ if( rDoc.FindNumRulePtr( aName ) )
+ {
+ if( !pItemSet )
+ {
+ SfxItemPool& rItemPool = rDoc.GetAttrPool();
+ pItemSet = new SfxItemSet( rItemPool, aTxtFmtCollSetRange );
+ }
+ pItemSet->Put( SwNumRuleItem(aName) );
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+enum SwXMLStyleStylesElemTokens
+{
+ SW_XML_TOK_STYLE_STYLE,
+ SW_XML_TOK_TEXT_LIST_STYLE,
+ SW_XML_TOK_TEXT_OUTLINE,
+ SW_XML_TOK_STYLE_STYLES_ELEM_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aStyleStylesElemTokenMap[] =
+{
+ { XML_NAMESPACE_STYLE, sXML_style, SW_XML_TOK_STYLE_STYLE },
+ { XML_NAMESPACE_TEXT, sXML_list_style, SW_XML_TOK_TEXT_LIST_STYLE},
+ { XML_NAMESPACE_TEXT, sXML_outline_style, SW_XML_TOK_TEXT_OUTLINE },
+ XML_TOKEN_MAP_END
+};
+
+const SvXMLTokenMap& SwXMLImport::GetStyleStylesElemTokenMap()
+{
+ if( !pStyleStylesElemTokenMap )
+ pStyleStylesElemTokenMap =
+ new SvXMLTokenMap( aStyleStylesElemTokenMap );
+
+ return *pStyleStylesElemTokenMap;
+}
+#endif
+
+// ---------------------------------------------------------------------
+//
+class SwXMLStylesContext_Impl : public SvXMLStylesContext
+{
+ SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const;
+#ifdef XML_CORE_API
+ SwXMLListStyleContext *GetSwListStyle( sal_uInt16 i ) const;
+
+ SwFmt *FindFmtByName( const String& rName,
+ sal_uInt16 eFamily ) const;
+ SwXMLItemSetStyleContext_Impl *FindByPoolId( sal_uInt16 nPoolId ) const;
+#endif
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+
+protected:
+
+#ifdef XML_CORE_API
+ // Create a style context.
+ virtual SvXMLStyleContext *CreateStyleChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+#else
+ virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ // HACK
+ virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
+ sal_uInt16 nFamily ) const;
+
+ virtual ::com::sun::star::uno::Reference <
+ ::com::sun::star::container::XNameContainer >
+ GetStylesContainer( sal_uInt16 nFamily ) const;
+ virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
+ // HACK
+#endif
+
+public:
+
+ TYPEINFO();
+
+ SwXMLStylesContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName ,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual ~SwXMLStylesContext_Impl();
+
+ virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
+#ifdef XML_CORE_API
+ void CopyStylesToDoc();
+ void CopyAutoStylesToDoc();
+#endif
+};
+
+TYPEINIT1( SwXMLStylesContext_Impl, SvXMLStylesContext );
+
+inline SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::GetSwStyle(
+ sal_uInt16 i ) const
+{
+ return PTR_CAST( SwXMLItemSetStyleContext_Impl, GetStyle( i ) );
+}
+
+#ifdef XML_CORE_API
+inline SwXMLListStyleContext *SwXMLStylesContext_Impl::GetSwListStyle(
+ sal_uInt16 i ) const
+{
+ return PTR_CAST( SwXMLListStyleContext, GetStyle( i ) );
+}
+
+sal_Bool lcl_xmlfmt_isValidPoolId( sal_uInt16 nPoolId, sal_uInt16 eFamily )
+{
+ sal_Bool bValid = sal_False;
+
+ // check if pool id is valid
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ {
+ bValid = (RES_POOLCHR_NORMAL_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCHR_NORMAL_END) ||
+ (RES_POOLCHR_HTML_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCHR_HTML_END);
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ {
+ bValid = RES_POOLFRM_BEGIN <= nPoolId && nPoolId < RES_POOLFRM_END;
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_PARA )
+ {
+ bValid = (RES_POOLCOLL_TEXT_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_TEXT_END) ||
+ (RES_POOLCOLL_LISTS_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_LISTS_END) ||
+ (RES_POOLCOLL_EXTRA_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_EXTRA_END) ||
+ (RES_POOLCOLL_REGISTER_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_REGISTER_END) ||
+ (RES_POOLCOLL_DOC_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_DOC_END) ||
+ (RES_POOLCOLL_HTML_BEGIN <= nPoolId &&
+ nPoolId < RES_POOLCOLL_HTML_END);
+ }
+
+ return bValid;
+}
+
+SwFmt *SwXMLStylesContext_Impl::FindFmtByName( const String& rName,
+ sal_uInt16 eFamily ) const
+{
+ const SwDoc& rDoc = GetSwImport().GetDoc();
+ SwFmt *pFmt = 0;
+ switch( eFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ pFmt = rDoc.FindTxtFmtCollByName( rName );
+ break;
+ case SFX_STYLE_FAMILY_FRAME:
+ pFmt = rDoc.FindFrmFmtByName( rName );
+ break;
+ case SFX_STYLE_FAMILY_CHAR:
+ pFmt = rDoc.FindCharFmtByName( rName );
+ break;
+ }
+
+ return pFmt;
+}
+
+SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::FindByPoolId(
+ sal_uInt16 nPoolId ) const
+{
+ SwXMLItemSetStyleContext_Impl *pStyle = 0;
+ sal_uInt16 nCount = GetStyleCount();
+ for( sal_uInt16 i=0; i < nCount && !pStyle; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pTmp = GetSwStyle( i );
+ if( pTmp && pTmp->GetPoolId() == nPoolId )
+ pStyle = pTmp;
+ }
+
+ return pStyle;
+}
+
+SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLStyleContext *pStyle = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetStyleStylesElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case SW_XML_TOK_STYLE_STYLE:
+ pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix, rLocalName,
+ xAttrList);
+ break;
+ case SW_XML_TOK_TEXT_LIST_STYLE:
+ pStyle = new SwXMLListStyleContext( GetSwImport(), nPrefix,
+ rLocalName, xAttrList );
+ break;
+ case SW_XML_TOK_TEXT_OUTLINE:
+ pStyle = new SwXMLListStyleContext( GetSwImport(), nPrefix,
+ rLocalName, xAttrList, sal_True );
+ break;
+ default:
+ pStyle = SvXMLStylesContext::CreateStyleChildContext( nPrefix,
+ rLocalName,
+ xAttrList );
+ break;
+ }
+
+ return pStyle;
+}
+#else
+SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext(
+ sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLStyleContext *pStyle = 0;
+
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
+ pStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList, nFamily, *this );
+ break;
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+ case XML_STYLE_FAMILY_TABLE_ROW:
+ case XML_STYLE_FAMILY_TABLE_CELL:
+ pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList, nFamily );
+ break;
+ case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
+ // HACK until CL is back again
+ pStyle = new XMLTextStyleContext( GetImport(), nPrefix,
+ rLocalName, xAttrList, *this );
+ break;
+ default:
+ pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily,
+ nPrefix,
+ rLocalName,
+ xAttrList );
+ break;
+ }
+
+ return pStyle;
+}
+#endif
+
+SwXMLStylesContext_Impl::SwXMLStylesContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList )
+{
+}
+
+SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl()
+{
+}
+
+#ifndef XML_CORE_API
+sal_Bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
+{
+ const SwXMLImport& rSwImport = GetSwImport();
+ sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
+
+ sal_Bool bIns = sal_True;
+ switch( nFamily )
+ {
+ case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PARA) != 0;
+ break;
+ case XML_STYLE_FAMILY_TEXT_TEXT:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_CHAR) != 0;
+ break;
+ case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_FRAME) != 0;
+ break;
+ case XML_STYLE_FAMILY_TEXT_LIST:
+ bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0;
+ break;
+ case XML_STYLE_FAMILY_TEXT_OUTLINE:
+ bIns = !(rSwImport.IsInsertMode() || rSwImport.IsStylesOnlyMode());
+ break;
+ default:
+ bIns = SvXMLStylesContext::InsertStyleFamily( nFamily );
+ break;
+ }
+
+ return bIns;
+}
+
+UniReference < SvXMLImportPropertyMapper > SwXMLStylesContext_Impl::GetImportPropertyMapper(
+ sal_uInt16 nFamily ) const
+{
+ UniReference < SvXMLImportPropertyMapper > xMapper;
+ if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
+ xMapper = ((SvXMLImport *)&GetImport())->GetTextImport()
+ ->GetFrameImportPropertySetMapper();
+ else
+ xMapper = SvXMLStylesContext::GetImportPropertyMapper( nFamily );
+
+ return xMapper;
+}
+
+Reference < XNameContainer > SwXMLStylesContext_Impl::GetStylesContainer(
+ sal_uInt16 nFamily ) const
+{
+ Reference < XNameContainer > xStyles;
+ if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
+ xStyles = ((SvXMLImport *)&GetImport())->GetTextImport()->GetFrameStyles();
+ else
+ xStyles = SvXMLStylesContext::GetStylesContainer( nFamily );
+
+ return xStyles;
+}
+
+OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const
+{
+ String sServiceName;
+ if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
+ sServiceName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle") );
+ else
+ sServiceName = SvXMLStylesContext::GetServiceName( nFamily );
+
+ return sServiceName;
+}
+#endif
+
+#ifdef XML_CORE_API
+void SwXMLStylesContext_Impl::CopyStylesToDoc()
+{
+ SwXMLImport& rSwImport = GetSwImport();
+ SwDoc& rDoc = rSwImport.GetDoc();
+ SvI18NMap& rI18NMap = rSwImport.GetI18NMap();
+ sal_Bool bInsertMode = rSwImport.IsInsertMode();
+ sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
+
+ // The following families are of interest for pass 1
+ sal_uInt16 nFamilies = nStyleFamilyMask &
+ ( SFX_STYLE_FAMILY_FRAME|SFX_STYLE_FAMILY_PARA|
+ SFX_STYLE_FAMILY_CHAR );
+
+ // pass 1: create text, paragraph and frame styles
+ sal_uInt16 nCount = GetStyleCount();
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( !pStyle )
+ {
+ continue;
+ }
+
+ sal_uInt16 eFamily = pStyle->GetFamily();
+ if( !(nFamilies & eFamily) )
+ {
+ pStyle->SetValid( sal_False );
+ continue;
+ }
+
+ const OUString& rName = pStyle->GetName();
+ if( 0 == rName.getLength() )
+ {
+ pStyle->SetValid( sal_False );
+ continue;
+ }
+ OUString sName =
+ SwXStyleFamilies::GetUIName( rName, (SfxStyleFamily)eFamily );
+
+// sal_uInt16 nPoolId = pStyle->GetPoolId();
+
+ sal_Bool bNewFmt = sal_False;
+ SwFmt *pFmt = FindFmtByName( sName, eFamily );
+ if( !pFmt )
+ {
+ // it is a new format
+ SwGetPoolIdFromName eNameType;
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ eNameType = GET_POOLID_CHRFMT;
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ eNameType = GET_POOLID_FRMFMT;
+ else
+ eNameType = GET_POOLID_TXTCOLL;
+
+ sal_uInt16 nPoolId = rDoc.GetPoolId( sName, eNameType );
+ bNewFmt = sal_True;
+// sal_Bool bIsUserDefined = (nPoolId & USER_FMT) != 0;
+ sal_Bool bIsUserDefined = nPoolId == USHRT_MAX;
+#if 0
+ if( !bIsUserDefined )
+ {
+ bIsUserDefined = !lcl_xmlfmt_isValidPoolId( nPoolId, eFamily );
+ if( bIsUserDefined )
+ {
+ // If the pool id is invalid create a user style
+ nPoolId |= (USHRT_MAX &
+ ~(COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID));
+ }
+ }
+ else
+ {
+ // The style is not a pool style, but maybe there is
+ // a pool style with this name now?
+ SwGetPoolIdFromName eNameType;
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ eNameType = GET_POOLID_CHRFMT;
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ eNameType = GET_POOLID_FRMFMT;
+ else
+ eNameType = GET_POOLID_TXTCOLL;
+ sal_uInt16 nId = rDoc.GetPoolId( rName, eNameType );
+ if( nId != USHRT_MAX )
+ {
+ if( FindByPoolId( nId ) )
+ {
+ // There is a style with the new pool id, too.
+ // This means, that the user style will be ignored.
+ continue;
+ }
+ else
+ {
+ bIsUserDefined = sal_False;
+ nPoolId = nId;
+ }
+ }
+ }
+#endif
+
+ if( bIsUserDefined )
+ {
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ {
+ pFmt = rDoc.MakeCharFmt( rName, NULL );
+ pFmt->SetAuto( sal_False );
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ {
+ pFmt = rDoc.MakeFrmFmt( rName, NULL );
+ pFmt->SetAuto( sal_False );
+ }
+ else if( pStyle->HasConditions() )
+ {
+ SwTxtFmtColl* pDer = (*rDoc.GetTxtFmtColls())[ 0 ];
+ pFmt = rDoc.MakeCondTxtFmtColl( rName, pDer );
+ }
+ else
+ {
+ SwTxtFmtColl* pDer = (*rDoc.GetTxtFmtColls())[ 0 ];
+ pFmt = rDoc.MakeTxtFmtColl( rName, pDer );
+ }
+
+// pFmt->SetPoolFmtId( nPoolId );
+// if( pStyle->GetHelpFile().getLength() )
+// pFmt->SetPoolHlpFileId
+// ( (sal_Int8) rDoc.SetDocPattern(
+// pStyle->GetHelpFile() ) );
+// pFmt->SetPoolHelpId( (sal_uInt16)pStyle->GetHelpId() );
+ }
+ else
+ {
+ if( eFamily & SFX_STYLE_FAMILY_CHAR )
+ {
+ sal_uInt16 nStyleCnt = rDoc.GetCharFmts()->Count();
+ pFmt = rDoc.GetCharFmtFromPool( nPoolId );
+ bNewFmt = nStyleCnt != rDoc.GetCharFmts()->Count();
+ }
+ else if( eFamily & SFX_STYLE_FAMILY_FRAME )
+ {
+ sal_uInt16 nStyleCnt = rDoc.GetFrmFmts()->Count();
+ pFmt = rDoc.GetFrmFmtFromPool( nPoolId );
+ bNewFmt = nStyleCnt != rDoc.GetFrmFmts()->Count();
+ }
+ else
+ {
+ sal_uInt16 nStyleCnt = rDoc.GetTxtFmtColls()->Count();
+ pFmt = rDoc.GetTxtCollFromPool( nPoolId );
+ bNewFmt = nStyleCnt != rDoc.GetTxtFmtColls()->Count();
+ }
+
+ // If the name of the pool style has been changed, add
+ // a i18n map entry.
+ if( String(rName) != pFmt->GetName() )
+ rI18NMap.Add( eFamily, pStyle->GetName(), pFmt->GetName() );
+ }
+ }
+#if 0
+ else if( (nPoolId & USER_FMT) != 0 )
+ {
+ // If a pool style has been renamed it may have the same
+ // name a a user style. If this is the case, the user style
+ // will be ignored.
+ sal_uInt16 nId = pFmt->GetPoolFmtId();
+ SwXMLItemSetStyleContext_Impl *pTmp;
+ if( nId != nPoolId && (nId & USER_FMT) == 0 &&
+ (pTmp = FindByPoolId( nPoolId )) != 0 &&
+ pTmp->GetFmt() == pFmt )
+ {
+ pStyle->SetValid( sal_False );
+ continue;
+ }
+ }
+#endif
+
+ pStyle->SetFmt( pFmt );
+
+ if( !bInsertMode || bNewFmt )
+ {
+ if( pStyle->GetItemSet() )
+ {
+ pFmt->ResetAllAttr(); // delete default attributes
+
+ ((SwAttrSet&) pFmt->GetAttrSet()).Put( *pStyle->GetItemSet() );
+ }
+ SwTxtFmtColl* pColl = pStyle->GetColl();
+ if( pColl )
+ {
+ ((SwAttrSet&) pColl->GetAttrSet()).SetModifyAtAttr( pColl );
+ }
+ pFmt->SetAutoUpdateFmt( pStyle->IsAutoUpdate() );
+ }
+ else
+ {
+ pStyle->SetValid( sal_False );
+ }
+ }
+
+ // pass 2: connect parent/next styles and create list styles
+ for( i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( !pStyle )
+ {
+ if( (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0 )
+ {
+ SwXMLListStyleContext *pListStyle = GetSwListStyle( i );
+ if( pListStyle )
+ pListStyle->InsertNumRule( sal_False );
+ }
+ continue;
+ }
+ else if( !pStyle->IsValid() )
+ continue;
+
+ sal_uInt16 eFamily = pStyle->GetFamily();
+ if( (nFamilies & eFamily) != 0 )
+ {
+ pStyle->ConnectParent();
+ pStyle->ConnectFollow();
+
+ // The format has been changed
+ SwFmtChg aHint( pStyle->GetFmt() );
+ pStyle->GetFmt()->Modify( &aHint, &aHint );
+ }
+ }
+
+ // pass 3: connect conditions and list styles
+ for( i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( pStyle && pStyle->IsValid() &&
+ (nFamilies & pStyle->GetFamily()) != 0 )
+ {
+ pStyle->ConnectListStyle();
+ if( pStyle->HasConditions() )
+ pStyle->ConnectConditions();
+ }
+ }
+}
+
+void SwXMLStylesContext_Impl::CopyAutoStylesToDoc()
+{
+ // pass 1: create list styles
+ sal_uInt16 nCount = GetStyleCount();
+ if( (GetSwImport().GetStyleFamilyMask() & SFX_STYLE_FAMILY_PSEUDO) != 0 )
+ {
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SwXMLListStyleContext *pListStyle = GetSwListStyle( i );
+ if( pListStyle && !pListStyle->IsOutline() )
+ pListStyle->InsertNumRule( sal_True );
+ }
+ }
+
+ // pass 3: connect list styles
+ if( (GetSwImport().GetStyleFamilyMask() & SFX_STYLE_FAMILY_PARA) != 0 )
+ {
+ for( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ SwXMLItemSetStyleContext_Impl *pStyle = GetSwStyle( i );
+ if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
+ {
+ pStyle->ConnectAutoListStyle();
+ }
+ }
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+SvXMLImportContext *SwXMLImport::CreateStylesContext(
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bAuto )
+{
+ SvXMLImportContext *pContext =
+ new SwXMLStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName,
+ xAttrList );
+ if( bAuto )
+ xAutoStyles = pContext;
+ else
+ xStyles = pContext;
+
+ return pContext;
+}
+
+void SwXMLImport::InsertStyles()
+{
+ sal_Bool bStylesValid = xStyles.Is();
+ bAutoStylesValid = xAutoStyles.Is();
+
+ if( bStylesValid )
+#ifdef XML_CORE_API
+ ((SwXMLStylesContext_Impl *)&xStyles)->CopyStylesToDoc();
+#else
+ ((SwXMLStylesContext_Impl *)&xStyles)->CopyStylesToDoc(
+ !IsInsertMode() );
+#endif
+ xStyles = 0;
+
+ if( bAutoStylesValid )
+#ifdef XML_CORE_API
+ ((SwXMLStylesContext_Impl *)&xAutoStyles)->CopyAutoStylesToDoc();
+#else
+ GetTextImport()->SetAutoStyles( (SwXMLStylesContext_Impl *)&xAutoStyles );
+#endif
+ else
+ xAutoStyles = 0;
+}
+
+sal_Bool SwXMLImport::FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SfxStyleFamily eFamily,
+ sal_uInt16 nSubFamily,
+#else
+ sal_uInt16 nFamily,
+#endif
+ const OUString& rName,
+ const SfxItemSet **ppItemSet,
+ OUString *pParent ) const
+{
+ const SwXMLItemSetStyleContext_Impl *pStyle = 0;
+ if( bAutoStylesValid && xAutoStyles.Is() )
+ {
+#ifdef XML_CORE_API
+ pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl,
+ ((SwXMLStylesContext_Impl *)&xAutoStyles)->
+ FindStyleChildContext( eFamily, nSubFamily, rName,
+ sal_True ) );
+#else
+ pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl,
+ ((SwXMLStylesContext_Impl *)&xAutoStyles)->
+ FindStyleChildContext( nFamily, rName,
+ sal_True ) );
+#endif
+ if( pStyle )
+ {
+ if( ppItemSet )
+ (*ppItemSet) = pStyle->GetItemSet();
+ if( pParent )
+ *pParent = pStyle->GetParent();
+ }
+ }
+
+ return pStyle != 0;
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmt.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.42 2000/09/18 16:05:05 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.41 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.40 2000/08/31 14:26:32 mib
+ conditional styles
+
+ Revision 1.39 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.38 2000/08/10 10:22:15 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.37 2000/07/27 08:06:34 mib
+ text import continued
+
+ Revision 1.36 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.35 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.34 2000/06/26 08:31:15 mib
+ removed SfxStyleFamily
+
+ Revision 1.33 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.32 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.31 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.30 2000/03/06 10:46:10 mib
+ #72585#: toInt32
+
+ Revision 1.29 2000/02/18 09:20:12 mib
+ #70271#: initialization of pContext was missing
+
+ Revision 1.28 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.26 2000/01/27 08:59:02 mib
+ #70271#: outline numbering
+
+ Revision 1.25 2000/01/20 10:03:15 mib
+ #70271#: Lists reworked
+
+ Revision 1.24 2000/01/06 15:08:27 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.23 1999/12/13 08:28:25 mib
+ #70271#: Support for element items added
+
+ Revision 1.22 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.21 1999/11/26 11:13:57 mib
+ loading of styles only and insert mode
+
+ Revision 1.20 1999/11/22 15:52:34 os
+ headers added
+
+ Revision 1.19 1999/11/17 20:08:49 nn
+ document language
+
+ Revision 1.18 1999/11/12 14:50:28 mib
+ meta import and export reactivated
+
+ Revision 1.17 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.16 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.15 1999/11/09 15:40:08 mib
+ Using XMLItemMapper for export
+
+ Revision 1.14 1999/11/05 19:44:11 nn
+ handle office:meta
+
+ Revision 1.13 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.12 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.11 1999/10/22 09:49:16 mib
+ List style export
+
+ Revision 1.10 1999/10/15 12:37:05 mib
+ integrated SvXMLStyle into SvXMLStyleContext
+
+ Revision 1.9 1999/10/08 11:47:45 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.8 1999/10/01 13:02:51 mib
+ no comparisons between OUString and char* any longer
+
+ Revision 1.7 1999/09/28 10:47:58 mib
+ char fmts again
+
+ Revision 1.6 1999/09/28 08:31:15 mib
+ char fmts, hints
+
+ Revision 1.5 1999/09/23 11:53:58 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.4 1999/09/22 11:56:57 mib
+ string -> wstring
+
+ Revision 1.3 1999/08/19 12:57:42 MIB
+ attribute import added
+
+
+ Rev 1.2 19 Aug 1999 14:57:42 MIB
+ attribute import added
+
+ Rev 1.1 18 Aug 1999 17:03:36 MIB
+ Style import
+
+ Rev 1.0 13 Aug 1999 16:18:10 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
new file mode 100644
index 000000000000..ebac28eab0ff
--- /dev/null
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -0,0 +1,1144 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlfmte.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _HINTS_HXX //autogen wg. SwFmtChg
+#include <hints.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTDOCUMENT_HPP_
+#include <com/sun/star/text/XTextDocument.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _SVSTDARR_STRINGSSORT_DECL
+#define _SVSTDARR_STRINGSSORT
+#include <svtools/svstdarr.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_ATTRLIST_HXX
+#include <xmloff/attrlist.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLASTPL_HXX
+#include <xmloff/xmlastpl.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMPR_HXX
+#include <xmloff/xmlexpit.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTSTYLE_HXX
+#include <xmloff/txtstyle.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLPROPERTYSETMAPPER_HXX
+#include <xmloff/xmlprmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLPROPMAPPINGTYPES_HXX
+#include <xmloff/maptype.hxx>
+#endif
+#ifndef _XMLOFF_XMLTYPES_HXX
+#include <xmloff/xmltypes.hxx>
+#endif
+#ifndef _XMLOFF_TXTPARAE_HXX
+#include <xmloff/txtparae.hxx>
+#endif
+#ifndef _XMLOFF_TXTPRMAP_HXX
+#include <xmloff/txtprmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLEXPPR_HXX
+#include <xmloff/xmlexppr.hxx>
+#endif
+#ifndef _XMLOFF_XMLASTPLP_HXX
+#include <xmloff/xmlaustp.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX_
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _FORMAT_HXX //autogen wg. SwFmt
+#include <format.hxx>
+#endif
+#ifndef _FMTCOL_HXX //autogen wg. SwTxtFmtColl
+#include <fmtcol.hxx>
+#endif
+#ifndef _CHARFMT_HXX //autogen wg. SwCharFmt
+#include <charfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#include "docary.hxx"
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen wg. SwSection
+#include <section.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+#ifndef _XMLECTXT_HXX
+#include "xmlectxt.hxx"
+#endif
+#ifndef _XMLFMTE_HXX
+#include "xmlfmte.hxx"
+#endif
+#ifndef _XMLTEXTE_HXX
+#include "xmltexte.hxx"
+#endif
+
+#ifndef _SWDOCSH_HXX
+#include "docsh.hxx"
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef XML_CORE_API
+#ifndef _XMLOFF_XMLTEXTLISTAUTOSTYLEPOOL_HXX
+#include <xmloff/XMLTextListAutoStylePool.hxx>
+#endif
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTFIELD_HPP_
+#include <com/sun/star/text/XTextField.hpp>
+#endif
+
+#ifndef _UNOFIELD_HXX
+#include <unofield.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTFLDE_HXX
+#include <xmloff/txtflde.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNUMFE_HXX
+#include <xmloff/xmlnumfe.hxx>
+#endif
+
+#ifndef _UNOSTYLE_HXX
+#include "unostyle.hxx"
+#endif
+
+
+using namespace rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+
+void SwXMLExport::ExportFmt( const SwFmt& rFmt, const char *pFamily )
+{
+ // <style:style ...>
+ CheckAttrList();
+
+ // style:family="..."
+ const sal_Char *pStr = pFamily;
+#ifdef XML_CORE_API
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL;
+ switch( rFmt.Which() )
+ {
+ case RES_CHRFMT:
+ if( !pStr )
+ pStr = sXML_text;
+ eFamily = SFX_STYLE_FAMILY_CHAR;
+ break;
+ case RES_FRMFMT:
+ if( !pStr )
+ pStr = sXML_frame;
+ eFamily = SFX_STYLE_FAMILY_FRAME;
+ break;
+ case RES_TXTFMTCOLL:
+ case RES_CONDTXTFMTCOLL:
+ if( !pStr )
+ pStr = sXML_paragraph;
+ eFamily = SFX_STYLE_FAMILY_PARA;
+ break;
+ case RES_FLYFRMFMT:
+ case RES_GRFFMTCOLL:
+ DBG_ASSERT( pStr, "SwXMLExport::ExportFmt: which id unexpected" );
+ break;
+ default:
+ DBG_ASSERT( pStr, "SwXMLExport::ExportFmt: which id unknown" );
+ break;
+ }
+ // style:name="..."
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_name,
+ SwXStyleFamilies::GetProgrammaticName( rFmt.GetName(), eFamily ) );
+#else
+ DBG_ASSERT( RES_FRMFMT==rFmt.Which(), "frame format expected" );
+ if( RES_FRMFMT != rFmt.Which() )
+ return;
+ DBG_ASSERT( pStr, "family must be specified" );
+ // style:name="..."
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_name, rFmt.GetName() );
+#endif
+
+ if( pStr )
+ AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_family, pStr );
+
+#ifdef XML_CORE_API
+ // register name to prevent it from beeing reused as an automtic
+ // style name
+ if( SFX_STYLE_FAMILY_ALL != eFamily )
+ pItemSetAutoStylePool->RegisterName( eFamily, rFmt.GetName() );
+#endif
+
+ // style:parent-style-name="..." (if its not the default only)
+ const SwFmt* pParent = rFmt.DerivedFrom();
+ // Parent-Namen nur uebernehmen, wenn kein Default
+ if( pParent && !pParent->IsDefault() )
+ {
+#ifdef XML_CORE_API
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_parent_style_name,
+ SwXStyleFamilies::GetProgrammaticName( pParent->GetName(),
+ eFamily ) );
+#else
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_parent_style_name,
+ pParent->GetName() );
+#endif
+ }
+
+#ifdef XML_CORE_API
+ // style:next-style-name="..."
+ // (if its not the default and not the same style only)
+ if( RES_TXTFMTCOLL == rFmt.Which() || RES_CONDTXTFMTCOLL == rFmt.Which() )
+ {
+ const SwTxtFmtColl& rFollow =
+ ((const SwTxtFmtColl&)rFmt).GetNextTxtFmtColl();
+ if( !rFollow.IsDefault() && &rFollow != &rFmt )
+ {
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_next_style_name,
+ SwXStyleFamilies::GetProgrammaticName( rFollow.GetName(),
+ eFamily ) );
+ }
+ }
+
+#if 0
+ // style:pool-id="..."
+ if( USHRT_MAX != rFmt.GetPoolFmtId() )
+ {
+ OUStringBuffer sTmp( 5L );
+ sTmp.append( (sal_Int32)rFmt.GetPoolFmtId() );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_pool_id,
+ sTmp.makeStringAndClear() );
+ }
+
+ // style:help-file-name="..." and style:help-id="..."
+ if( UCHAR_MAX != rFmt.GetPoolHlpFileId() )
+ {
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_help_file_name,
+ *pDoc->GetDocPattern( rFmt.GetPoolHlpFileId() ) );
+ OUStringBuffer sTmp( 5L );
+ sTmp.append( (sal_Int32)rFmt.GetPoolHelpId() );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_help_id,
+ sTmp.makeStringAndClear() );
+ }
+#endif
+
+ // style:auto-update="..."
+ if( rFmt.IsAutoUpdateFmt() )
+ {
+ AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_auto_update, sXML_true );
+ }
+
+ // text:list-style-name
+ if( RES_TXTFMTCOLL == rFmt.Which() || RES_CONDTXTFMTCOLL == rFmt.Which() )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState( RES_PARATR_NUMRULE,
+ sal_False, &pItem ) )
+ {
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_list_style_name,
+ SwXStyleFamilies::GetProgrammaticName(
+ ((const SwNumRuleItem *)pItem)->GetValue(),
+ SFX_STYLE_FAMILY_PSEUDO ) );
+ }
+ }
+#else
+ ASSERT( USHRT_MAX == rFmt.GetPoolFmtId(), "pool ids arent'supported" );
+ ASSERT( UCHAR_MAX == rFmt.GetPoolHlpFileId(), "help ids aren't supported" );
+#endif
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, sXML_style,
+ sal_True, sal_True );
+
+#ifdef XML_CORE_API
+ switch( rFmt.Which() )
+ {
+ case RES_TXTFMTCOLL:
+ case RES_CONDTXTFMTCOLL:
+ case RES_CHRFMT:
+ GetParaItemMapper().exportXML( GetDocHandler(),
+ rFmt.GetAttrSet(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap(),
+ XML_EXPORT_FLAG_IGN_WS );
+ break;
+ case RES_FRMFMT:
+ {
+#endif
+ SvXMLItemMapEntriesRef xItemMap;
+ if( sXML_table == pStr )
+ xItemMap = xTableItemMap;
+ else if( sXML_table_row == pStr )
+ xItemMap = xTableRowItemMap;
+ else if( sXML_table_cell == pStr )
+ xItemMap = xTableCellItemMap;
+
+ if( xItemMap.Is() )
+ {
+ SvXMLExportItemMapper& rItemMapper = GetTableItemMapper();
+ rItemMapper.setMapEntries( xItemMap );
+
+ GetTableItemMapper().exportXML( GetDocHandler(),
+ rFmt.GetAttrSet(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap(),
+ XML_EXPORT_FLAG_IGN_WS );
+ }
+#ifdef XML_CORE_API
+ }
+ break;
+ default:
+ DBG_ASSERT( !this,
+ "SwXMLExport::ExportFmt: attribute export missing" );
+ break;
+ }
+
+ if( RES_CONDTXTFMTCOLL == rFmt.Which() )
+ {
+ const SwFmtCollConditions& rConditions =
+ ((SwConditionTxtFmtColl&)rFmt). GetCondColls();
+ for( sal_uInt16 i=0; i < rConditions.Count(); i++ )
+ {
+ const SwCollCondition& rCond = *rConditions[i];
+
+ const sal_Char *pFunc = 0;
+ OUStringBuffer sBuffer( 20 );
+ switch( rCond.GetCondition() )
+ {
+ case PARA_IN_LIST:
+ pFunc = sXML_list_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_OUTLINE:
+ pFunc = sXML_outline_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_FRAME:
+ pFunc = sXML_text_box;
+ break;
+ case PARA_IN_TABLEHEAD:
+ pFunc = sXML_table_header;
+ break;
+ case PARA_IN_TABLEBODY:
+ pFunc = sXML_table;
+ break;
+ case PARA_IN_SECTION:
+ pFunc = sXML_section;
+ break;
+ case PARA_IN_FOOTENOTE:
+ pFunc = sXML_footnote;
+ break;
+ case PARA_IN_FOOTER:
+ pFunc = sXML_footer;
+ break;
+ case PARA_IN_HEADER:
+ pFunc = sXML_header;
+ break;
+ case PARA_IN_ENDNOTE:
+ pFunc = sXML_endnote;
+ break;
+ }
+ OUString sVal( sBuffer.makeStringAndClear() );
+
+ DBG_ASSERT( pFunc, "SwXMLExport::ExportFmt: unknon condition" );
+ if( pFunc )
+ {
+ sBuffer.appendAscii( pFunc );
+ sBuffer.append( (sal_Unicode)'(' );
+ sBuffer.append( (sal_Unicode)')' );
+ if( sVal.getLength() )
+ {
+ sBuffer.append( (sal_Unicode)'=' );
+ sBuffer.append( sVal );
+ }
+
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_condition,
+ sBuffer.makeStringAndClear() );
+ const String& rName =
+ SwXStyleFamilies::GetProgrammaticName(
+ rCond.GetTxtFmtColl()->GetName(),
+ SFX_STYLE_FAMILY_PARA );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_apply_style_name,
+ rName );
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE,
+ sXML_map, sal_True, sal_True );
+ }
+ }
+ }
+#endif
+ }
+}
+
+#ifndef XML_CORE_API
+
+SwXMLTextParagraphExport::SwXMLTextParagraphExport(
+ SwXMLExport& rExp,
+ SvXMLAutoStylePoolP& rAutoStylePool ) :
+ XMLTextParagraphExport( rExp, rAutoStylePool ),
+ sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) )
+{
+}
+
+SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
+{
+}
+
+void SwXMLTextParagraphExport::exportStyleContent(
+ const Reference< XStyle > & rStyle )
+{
+
+ const SwXStyle* pStyle = 0;
+ Reference<XUnoTunnel> xStyleTunnel( rStyle, UNO_QUERY);
+ if( xStyleTunnel.is() )
+ {
+ pStyle = (SwXStyle*)xStyleTunnel->getSomething(
+ SwXStyle::getUnoTunnelId() );
+ }
+ if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
+ {
+ const SwDoc& rDoc = ((SwXMLExport&)GetExport()).GetDoc();
+ const SwTxtFmtColl *pColl =
+ rDoc.FindTxtFmtCollByName( SwXStyleFamilies::GetUIName( pStyle->GetStyleName(), SFX_STYLE_FAMILY_PARA ) );
+ ASSERT( pColl, "There is the text collection?" );
+ if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
+ {
+ const SwFmtCollConditions& rConditions =
+ ((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
+ for( sal_uInt16 i=0; i < rConditions.Count(); i++ )
+ {
+ const SwCollCondition& rCond = *rConditions[i];
+
+ const sal_Char *pFunc = 0;
+ OUStringBuffer sBuffer( 20 );
+ switch( rCond.GetCondition() )
+ {
+ case PARA_IN_LIST:
+ pFunc = sXML_list_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_OUTLINE:
+ pFunc = sXML_outline_level;
+ sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
+ break;
+ case PARA_IN_FRAME:
+ pFunc = sXML_text_box;
+ break;
+ case PARA_IN_TABLEHEAD:
+ pFunc = sXML_table_header;
+ break;
+ case PARA_IN_TABLEBODY:
+ pFunc = sXML_table;
+ break;
+ case PARA_IN_SECTION:
+ pFunc = sXML_section;
+ break;
+ case PARA_IN_FOOTENOTE:
+ pFunc = sXML_footnote;
+ break;
+ case PARA_IN_FOOTER:
+ pFunc = sXML_footer;
+ break;
+ case PARA_IN_HEADER:
+ pFunc = sXML_header;
+ break;
+ case PARA_IN_ENDNOTE:
+ pFunc = sXML_endnote;
+ break;
+ }
+ OUString sVal( sBuffer.makeStringAndClear() );
+
+ DBG_ASSERT( pFunc, "SwXMLExport::ExportFmt: unknon condition" );
+ if( pFunc )
+ {
+ sBuffer.appendAscii( pFunc );
+ sBuffer.append( (sal_Unicode)'(' );
+ sBuffer.append( (sal_Unicode)')' );
+ if( sVal.getLength() )
+ {
+ sBuffer.append( (sal_Unicode)'=' );
+ sBuffer.append( sVal );
+ }
+
+ GetExport().AddAttribute( XML_NAMESPACE_STYLE,
+ sXML_condition,
+ sBuffer.makeStringAndClear() );
+ const String& rName =
+ SwXStyleFamilies::GetProgrammaticName(
+ rCond.GetTxtFmtColl()->GetName(),
+ SFX_STYLE_FAMILY_PARA );
+ GetExport().AddAttribute( XML_NAMESPACE_STYLE,
+ sXML_apply_style_name, rName );
+ SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
+ sXML_map, sal_True, sal_True );
+ }
+ }
+ }
+ }
+}
+
+#endif
+
+void SwXMLExport::_ExportStyles( sal_Bool bUsed )
+{
+#ifdef XML_CORE_API
+ // text collections
+ SvStringsSort *pCollNames = bUsed ? new SvStringsSort : 0;
+ sal_uInt16 nCount = pDoc->GetTxtFmtColls()->Count();
+ sal_uInt16 i;
+ for( i=0; i<nCount; i++ )
+ {
+ const SwTxtFmtColl *pColl = (*pDoc->GetTxtFmtColls())[i];
+ if( ( !bUsed || pDoc->IsUsed( *pColl ) ) && !pColl->IsDefault() )
+ {
+ ExportFmt( *pColl );
+ if( pCollNames )
+ pCollNames->Insert( (String *)&pColl->GetName() );
+ }
+ }
+ if( bUsed )
+ {
+ // Even if some next styles have not been used, they have to be
+ // exported.
+ for( i = 0; i < nCount; i++ )
+ {
+ const SwTxtFmtColl* pColl = (*pDoc->GetTxtFmtColls())[ i ];
+ if( pColl != &pColl->GetNextTxtFmtColl() &&
+ !pCollNames->Seek_Entry(
+ (String *)&pColl->GetNextTxtFmtColl().GetName() ) )
+ {
+ ExportFmt( pColl->GetNextTxtFmtColl() );
+ pCollNames->Insert(
+ (String *)&pColl->GetNextTxtFmtColl().GetName() );
+ }
+ }
+ delete pCollNames;
+ }
+
+ // char fmts
+ nCount = pDoc->GetCharFmts()->Count();
+ for( i=0; i<nCount; i++ )
+ {
+ const SwCharFmt *pFmt = (*pDoc->GetCharFmts())[i];
+ if( ( !bUsed || pDoc->IsUsed( *pFmt ) ) && !pFmt->IsDefault() )
+ ExportFmt( *pFmt );
+ }
+
+ // num rules
+ ExportNumRules( sal_False, bUsed );
+#else
+ GetTextParagraphExport()->exportTextStyles( bUsed );
+#endif
+}
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+void SwXMLExport::AddTextAutoStyle( const SfxPoolItem& rItem )
+{
+ SfxItemSet aItemSet( pDoc->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1, 0 );
+ aItemSet.Put( rItem );
+ pItemSetAutoStylePool->Add( SFX_STYLE_FAMILY_CHAR, aItemSet );
+}
+
+void SwXMLExport::AddParaAutoStyle( const OUString& rParent,
+ const SfxItemSet& rItemSet )
+{
+ pItemSetAutoStylePool->Add( SFX_STYLE_FAMILY_PARA,
+ SwXStyleFamilies::GetProgrammaticName(rParent, SFX_STYLE_FAMILY_PARA ),
+ rItemSet );
+}
+
+OUString SwXMLExport::FindTextAutoStyle( const SfxPoolItem& rItem )
+{
+ SfxItemSet aItemSet( pDoc->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1, 0 );
+ aItemSet.Put( rItem );
+ return pItemSetAutoStylePool->Find( SFX_STYLE_FAMILY_CHAR, aItemSet );
+}
+
+OUString SwXMLExport::FindParaAutoStyle( const OUString& rParent,
+ const SfxItemSet& rItemSet )
+{
+ return pItemSetAutoStylePool->Find(
+ SFX_STYLE_FAMILY_PARA,
+ SwXStyleFamilies::GetProgrammaticName(rParent, SFX_STYLE_FAMILY_PARA ),
+ rItemSet );
+}
+
+void SwXMLExport::ExportTxtNodeAutoStyles( const SwTxtNode& rTxtNd,
+ xub_StrLen nStart, xub_StrLen nEnd,
+ sal_Bool bExportWholeNode )
+{
+ const SfxItemSet *pItemSet = rTxtNd.GetpSwAttrSet();
+ if( pItemSet )
+ {
+ const SwFmtColl& rColl = rTxtNd.GetAnyFmtColl();
+ OUString sParent( rColl.GetName() );
+ AddParaAutoStyle( sParent, *pItemSet );
+
+ if( rTxtNd.GetCondFmtColl() &&
+ &rColl != rTxtNd.GetFmtColl() )
+ {
+ const SwFmtColl *pColl = rTxtNd.GetFmtColl();
+ sParent = pColl->GetName();
+ AddParaAutoStyle( sParent, *pItemSet );
+ }
+ }
+
+ xub_StrLen nPos = pCurPaM->GetPoint()->nContent.GetIndex();
+ xub_StrLen nEndPos = rTxtNd.GetTxt().Len();
+ if( pCurPaM->GetPoint()->nNode == pCurPaM->GetMark()->nNode )
+ nEndPos = pCurPaM->GetMark()->nContent.GetIndex();
+
+ const SwpHints *pHints = rTxtNd.GetpSwpHints();
+ sal_uInt16 nHintCount = pHints ? pHints->Count() : 0;
+ sal_uInt16 nHintPos = 0;
+ const SwTxtAttr * pTxtAttr = 0;
+
+ if( nHintCount && nPos > *( pTxtAttr = (*pHints)[0] )->GetStart() )
+ {
+ do
+ {
+ nHintPos++;
+ sal_uInt16 nWhich = pTxtAttr->Which();
+ if( pTxtAttr->GetEnd() &&
+ ( (nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END) ||
+ (nWhich >= RES_UNKNOWNATR_BEGIN &&
+ nWhich < RES_UNKNOWNATR_END) ) )
+ {
+ xub_StrLen nHtEnd = *pTxtAttr->GetEnd(),
+ nHtStt = *pTxtAttr->GetStart();
+ if( (bExportWholeNode || nHtEnd > nPos) &&
+ nHtEnd != nHtStt )
+ {
+ AddTextAutoStyle( pTxtAttr->GetAttr() );
+ }
+ }
+
+ }
+ while( nHintPos < nHintCount &&
+ nPos > *( pTxtAttr = (*pHints)[nHintPos ] )->GetStart() );
+ }
+
+ for( ; nPos < nEndPos; nPos++ )
+ {
+ if( nHintPos < nHintCount && *pTxtAttr->GetStart() == nPos
+ && nPos != nEndPos )
+ {
+ do
+ {
+ sal_uInt16 nWhich = pTxtAttr->Which();
+ if( pTxtAttr->GetEnd() && *pTxtAttr->GetEnd() != nPos &&
+ ( (nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END) ||
+ (nWhich >= RES_UNKNOWNATR_BEGIN &&
+ nWhich < RES_UNKNOWNATR_END) ) )
+ {
+ AddTextAutoStyle( pTxtAttr->GetAttr() );
+ } else if( nWhich == RES_TXTATR_FIELD ) {
+ // text field found: export AutoStyle
+#ifdef XML_CORE_API
+// Reference < text::XTextField > xFld = new SwXTextField(
+// ((const SwFmtFld&)pTxtAttr->GetAttr()), &GetDoc() );
+//
+// GetTextFieldExport().ExportFieldAutoStyle( xFld );
+#endif
+ }
+ }
+ while( ++nHintPos < nHintCount &&
+ nPos == *( pTxtAttr = (*pHints)[nHintPos] )->GetStart() );
+ }
+ }
+}
+
+void SwXMLExport::ExportSectionAutoStyles( const SwSectionNode& rSectNd )
+{
+ SwNode *pStartNd = pDoc->GetNodes()[rSectNd.GetIndex() + 1];
+ SwNode *pEndNd = pDoc->GetNodes()[rSectNd.EndOfSectionIndex() - 1];
+
+ {
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd, 0, STRING_LEN );
+ ExportCurPaMAutoStyles();
+ }
+
+ pCurPaM->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
+}
+
+void SwXMLExport::ExportCurPaMAutoStyles( sal_Bool bExportWholePaM )
+{
+ sal_Bool bFirstNode = sal_True;
+ sal_Bool bExportWholeNode = bExportWholePaM;
+
+ while( pCurPaM->GetPoint()->nNode.GetIndex() <
+ pCurPaM->GetMark()->nNode.GetIndex() ||
+ ( pCurPaM->GetPoint()->nNode.GetIndex() ==
+ pCurPaM->GetMark()->nNode.GetIndex() &&
+ pCurPaM->GetPoint()->nContent.GetIndex() <=
+ pCurPaM->GetMark()->nContent.GetIndex() ) )
+ {
+ SwNode *pNd = pCurPaM->GetNode();
+
+ ASSERT( !(pNd->IsGrfNode() || pNd->IsOLENode()),
+ "SwXMLExport::exportCurPaM: grf or OLE node unexpected" );
+ if( pNd->IsTxtNode() )
+ {
+ SwTxtNode* pTxtNd = pNd->GetTxtNode();
+
+ if( !bFirstNode )
+ pCurPaM->GetPoint()->nContent.Assign( pTxtNd, 0 );
+
+ ExportTxtNodeAutoStyles( *pTxtNd, 0, STRING_LEN, bExportWholeNode );
+ }
+ else if( pNd->IsTableNode() )
+ {
+ ExportTableAutoStyles( *pNd->GetTableNode() );
+ }
+ else if( pNd->IsSectionNode() )
+ {
+ ExportSectionAutoStyles( *pNd->GetSectionNode() );
+ }
+ else if( pNd == &pDoc->GetNodes().GetEndOfContent() )
+ break;
+
+ pCurPaM->GetPoint()->nNode++; // next node
+
+ // if not everything should be exported, the WriteAll flag must be
+ // set for all but the first and last node anyway.
+ bExportWholeNode = bExportWholePaM ||
+ pCurPaM->GetPoint()->nNode.GetIndex() !=
+ pCurPaM->GetMark()->nNode.GetIndex();
+ bFirstNode = sal_False;
+ }
+}
+#endif
+
+void SwXMLExport::_ExportAutoStyles()
+{
+#ifdef XML_CORE_API
+ // export all PaMs
+ SwPaM *pPaM = pOrigPaM;
+ sal_Bool bContinue = sal_True;
+ do
+ {
+ // export PaM content
+ ExportCurPaMAutoStyles( bExportWholeDoc );
+
+ bContinue = pPaM->GetNext() != pOrigPaM;
+
+ // the current PaM must be at the start if this loop finishes
+ pPaM = (SwPaM *)pPaM->GetNext();
+ SetCurPaM( *pPaM, bExportWholeDoc, bExportFirstTableOnly );
+
+ } while( bContinue );
+
+ // text collections
+ ((SvXMLAutoStylePool *)pItemSetAutoStylePool)->exportXML( SFX_STYLE_FAMILY_PARA,
+ GetParaItemMapper(),
+ GetDocHandler(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap() );
+
+ // char fmts
+ ((SvXMLAutoStylePool *)pItemSetAutoStylePool)->exportXML( SFX_STYLE_FAMILY_CHAR,
+ GetParaItemMapper(),
+ GetDocHandler(),
+ GetTwipUnitConverter(),
+ GetNamespaceMap() );
+
+ // num rules
+ ExportNumRules( sal_True, sal_False );
+
+ // text field styles
+// GetNumberFormatExport().Export( GetNamespaceMap() );
+
+#else
+ Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
+ Reference < XText > xText = xTextDoc->getText();
+
+ GetTextParagraphExport()->collectFrameBoundToPageAutoStyles();
+ GetTextParagraphExport()->collectTextAutoStyles( xText );
+ GetTextParagraphExport()->exportTextAutoStyles();
+ exportAutoDataStyles();
+
+#endif
+
+}
+
+void SwXMLExport::_ExportMasterStyles()
+{
+}
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+void SwXMLAutoStylePool::exportXML( SvXMLAttributeList& rAttrList,
+ SfxStyleFamily eFamily, const SfxItemSet& rItemSet,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const
+{
+ if( SFX_STYLE_FAMILY_PARA == eFamily )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_PARATR_NUMRULE, sal_False,
+ &pItem ) )
+ {
+ OUString sName( rNamespaceMap.GetQNameByKey( XML_NAMESPACE_STYLE,
+ OUString::createFromAscii(sXML_list_style_name) ) );
+ rAttrList.AddAttribute( sName,
+ OUString::createFromAscii( sXML_CDATA ),
+ ((const SwNumRuleItem *)pItem)->GetValue() );
+ }
+ }
+}
+
+SwXMLAutoStylePool::~SwXMLAutoStylePool()
+{
+}
+#else
+
+class SwXMLAutoStylePoolP : public SvXMLAutoStylePoolP
+{
+ SvXMLExport& rExport;
+ const OUString sListStyleName;
+ const OUString sCDATA;
+
+protected:
+
+ virtual void exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap) const;
+public:
+
+ SwXMLAutoStylePoolP( SvXMLExport& rExport );
+ virtual ~SwXMLAutoStylePoolP();
+};
+
+void SwXMLAutoStylePoolP::exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap) const
+{
+ if( XML_STYLE_FAMILY_TEXT_PARAGRAPH == nFamily )
+ {
+ for( ::std::vector< XMLPropertyState >::const_iterator
+ aProperty = rProperties.begin();
+ aProperty != rProperties.end();
+ aProperty++ )
+ {
+ switch( rPropExp.getPropertySetMapper()->
+ GetEntryContextId( aProperty->mnIndex ) )
+ {
+ case CTF_NUMBERINGSTYLENAME:
+ {
+ OUString sStyleName;
+ aProperty->maValue >>= sStyleName;
+ if( sStyleName.getLength() )
+ {
+ OUString sTmp = rExport.GetTextParagraphExport()->GetListAutoStylePool().Find( sStyleName );
+ if( sTmp.getLength() )
+ sStyleName = sTmp;
+ OUString sName( rNamespaceMap.GetQNameByKey(
+ XML_NAMESPACE_STYLE, sListStyleName ) );
+ rAttrList.AddAttribute( sName, sCDATA, sStyleName );
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+SwXMLAutoStylePoolP::SwXMLAutoStylePoolP(SvXMLExport& rExp ) :
+ SvXMLAutoStylePoolP(),
+ rExport( rExp ),
+ sListStyleName( RTL_CONSTASCII_USTRINGPARAM( sXML_list_style_name) ),
+ sCDATA( RTL_CONSTASCII_USTRINGPARAM( sXML_CDATA) )
+{
+}
+
+
+SwXMLAutoStylePoolP::~SwXMLAutoStylePoolP()
+{
+}
+
+SvXMLAutoStylePoolP* SwXMLExport::CreateAutoStylePool()
+{
+ return new SwXMLAutoStylePoolP( *this );
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlfmte.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.23 2000/09/18 16:05:06 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.22 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.21 2000/09/07 05:29:00 mib
+ #78555#: Search paragraph styles by programmatic name instead of UI name
+
+ Revision 1.20 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.19 2000/08/21 11:02:50 dvo
+ - fixed data style export (for textfields)
+
+ Revision 1.18 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.17 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.16 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.15 2000/07/27 08:06:34 mib
+ text import continued
+
+ Revision 1.14 2000/07/26 05:11:20 mib
+ text import/export continued
+
+ Revision 1.13 2000/07/24 10:19:02 dvo
+ - textfield export for XML_CORE_API
+
+ Revision 1.12 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.11 2000/07/10 06:58:49 mib
+ text styles
+
+ Revision 1.10 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.9 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.8 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.7 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.6 2000/03/06 10:46:11 mib
+ #72585#: toInt32
+
+ Revision 1.5 2000/02/11 14:41:57 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.4 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.3 2000/01/20 10:03:16 mib
+ #70271#: Lists reworked
+
+ Revision 1.2 2000/01/12 15:00:23 mib
+ #70271#: lists
+
+ Revision 1.1 2000/01/06 15:03:40 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.23 1999/12/13 08:28:25 mib
+ #70271#: Support for element items added
+
+ Revision 1.22 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.21 1999/11/26 11:13:57 mib
+ loading of styles only and insert mode
+
+ Revision 1.20 1999/11/22 15:52:34 os
+ headers added
+
+ Revision 1.19 1999/11/17 20:08:49 nn
+ document language
+
+ Revision 1.18 1999/11/12 14:50:28 mib
+ meta import and export reactivated
+
+ Revision 1.17 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.16 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.15 1999/11/09 15:40:08 mib
+ Using XMLItemMapper for export
+
+ Revision 1.14 1999/11/05 19:44:11 nn
+ handle office:meta
+
+ Revision 1.13 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.12 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.11 1999/10/22 09:49:16 mib
+ List style export
+
+ Revision 1.10 1999/10/15 12:37:05 mib
+ integrated SvXMLStyle into SvXMLStyleContext
+
+ Revision 1.9 1999/10/08 11:47:45 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.8 1999/10/01 13:02:51 mib
+ no comparisons between OUString and char* any longer
+
+ Revision 1.7 1999/09/28 10:47:58 mib
+ char fmts again
+
+ Revision 1.6 1999/09/28 08:31:15 mib
+ char fmts, hints
+
+ Revision 1.5 1999/09/23 11:53:58 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.4 1999/09/22 11:56:57 mib
+ string -> wstring
+
+ Revision 1.3 1999/08/19 12:57:42 MIB
+ attribute import added
+
+
+ Rev 1.2 19 Aug 1999 14:57:42 MIB
+ attribute import added
+
+ Rev 1.1 18 Aug 1999 17:03:36 MIB
+ Style import
+
+ Rev 1.0 13 Aug 1999 16:18:10 MIB
+ Initial revision.
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
new file mode 100644
index 000000000000..41743bc096b2
--- /dev/null
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -0,0 +1,570 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlimp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+#ifndef _XMLOFF_TXTIMP_HXX
+#include <xmloff/txtimp.hxx>
+#endif
+
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_
+#include <com/sun/star/text/XTextRange.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _UNOOBJ_HXX
+#include <unoobj.hxx>
+#endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+
+sal_Char __READONLY_DATA sXML_np__text[] = "text";
+sal_Char __READONLY_DATA sXML_np__table[] = "table";
+
+//----------------------------------------------------------------------------
+
+enum SwXMLDocTokens
+{
+ XML_TOK_DOC_STYLES,
+ XML_TOK_DOC_AUTOSTYLES,
+ XML_TOK_DOC_MASTERSTYLES,
+ XML_TOK_DOC_META,
+ XML_TOK_DOC_BODY,
+ XML_TOK_OFFICE_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] =
+{
+ { XML_NAMESPACE_OFFICE, sXML_styles, XML_TOK_DOC_STYLES },
+ { XML_NAMESPACE_OFFICE, sXML_automatic_styles, XML_TOK_DOC_AUTOSTYLES },
+ { XML_NAMESPACE_OFFICE, sXML_master_styles, XML_TOK_DOC_MASTERSTYLES },
+ { XML_NAMESPACE_OFFICE, sXML_meta, XML_TOK_DOC_META },
+ { XML_NAMESPACE_OFFICE, sXML_body, XML_TOK_DOC_BODY },
+ XML_TOKEN_MAP_END
+};
+
+class SwXMLDocContext_Impl : public SvXMLImportContext
+{
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+public:
+
+ SwXMLDocContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual ~SwXMLDocContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+};
+
+SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+}
+
+SwXMLDocContext_Impl::~SwXMLDocContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLDocContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_DOC_STYLES:
+ pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
+ sal_False );
+ break;
+ case XML_TOK_DOC_AUTOSTYLES:
+ pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList,
+ sal_True );
+ break;
+// case XML_TOK_DOC_USESTYLES:
+// pContext = GetSwImport().CreateUseStylesContext( rLocalName,
+// xAttrList );
+// break;
+ case XML_TOK_DOC_MASTERSTYLES:
+// pContext = GetSwImport().CreateMasterStylesContext( rLocalName,
+// xAttrList );
+ break;
+ case XML_TOK_DOC_META:
+ pContext = GetSwImport().CreateMetaContext( rLocalName );
+ break;
+ case XML_TOK_DOC_BODY:
+ pContext = GetSwImport().CreateBodyContext( rLocalName );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+
+ return pContext;
+}
+
+//----------------------------------------------------------------------------
+
+const SvXMLTokenMap& SwXMLImport::GetDocElemTokenMap()
+{
+ if( !pDocElemTokenMap )
+ pDocElemTokenMap = new SvXMLTokenMap( aDocTokenMap );
+
+ return *pDocElemTokenMap;
+}
+
+SvXMLImportContext *SwXMLImport::CreateContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_OFFICE==nPrefix &&
+ rLocalName.compareToAscii( sXML_document ) == 0 )
+ pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName,
+ xAttrList );
+ else
+ pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+
+ return pContext;
+}
+
+SwXMLImport::SwXMLImport(
+ SwDoc& rDoc, const SwPaM& rPaM,
+ sal_Bool bLDoc, sal_Bool bInsertMode, sal_uInt16 nStyleFamMask,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & rModel ) :
+ SvXMLImport( rModel ),
+ bLoadDoc( bLDoc ),
+ bInsert( bInsertMode ),
+ nStyleFamilyMask( nStyleFamMask ),
+ pDoc( &rDoc ),
+ pPaM( new SwPaM( *rPaM.GetPoint() ) ),
+#ifdef XML_CORE_API
+ pI18NMap( new SvI18NMap ),
+ pUnusedNumRules( 0 ),
+#endif
+ pDocElemTokenMap( 0 ),
+#ifdef XML_CORE_API
+ pBodyElemTokenMap( 0 ),
+ pStyleStylesElemTokenMap( 0 ),
+ pTextPElemTokenMap( 0 ),
+ pTextPAttrTokenMap( 0 ),
+ pTextListBlockAttrTokenMap( 0 ),
+ pTextListBlockElemTokenMap( 0 ),
+#endif
+ pTableElemTokenMap( 0 ),
+#ifdef XML_CORE_API
+ pParaItemMapper( 0 ),
+#endif
+ pTableItemMapper( 0 ),
+ pSttNdIdx( 0 ),
+ bAutoStylesValid( sal_False )
+{
+// GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TEXT, sXML_np__text,
+// sXML_n_text, XML_NAMESPACE_TEXT );
+// GetNamespaceMap().AddAtIndex( XML_NAMESPACE_TABLE, sXML_np__table,
+// sXML_n_table, XML_NAMESPACE_TABLE );
+
+ _InitItemImport();
+
+ if( !IsStylesOnlyMode() )
+ {
+ pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
+ if( IsInsertMode() )
+ {
+ const SwPosition* pPos = pPaM->GetPoint();
+
+ // Split once and remember the node that has been splitted.
+ pDoc->SplitNode( *pPos );
+ *pSttNdIdx = pPos->nNode.GetIndex()-1;
+
+ // Split again.
+ pDoc->SplitNode( *pPos );
+
+ // Insert all content into the new node
+ pPaM->Move( fnMoveBackward );
+ pDoc->SetTxtFmtColl( *pPaM,
+ pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD) );
+ }
+ }
+ Reference < XTextRange > xTextRange =
+ CreateTextRangeFromPosition( pDoc, *rPaM.GetPoint(), 0 );
+ Reference < XText > xText = xTextRange->getText();
+ Reference < XTextCursor > xTextCursor =
+ xText->createTextCursorByRange( xTextRange );
+ GetTextImport()->SetCursor( xTextCursor );
+}
+
+SwXMLImport::~SwXMLImport()
+{
+ GetTextImport()->ResetCursor();
+
+ if( !IsStylesOnlyMode() )
+ {
+ if( IsInsertMode() && pSttNdIdx->GetIndex() )
+ {
+ // If we are in insert mode, join the splitted node that is in front
+ // of the new content with the first new node.
+ SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
+ SwNodeIndex aNxtIdx( *pSttNdIdx );
+ if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ))
+ {
+ xub_StrLen nStt = pTxtNode->GetTxt().Len();
+
+ // If the PaM points to the first new node, move the PaM to the
+ // end of the previous node.
+ if( pPaM->GetPoint()->nNode == aNxtIdx )
+ {
+ pPaM->GetPoint()->nNode = *pSttNdIdx;
+ pPaM->GetPoint()->nContent.Assign( pTxtNode, nStt );
+ }
+
+#ifndef PRODUCT
+ // !!! This should be impossible !!!!
+ ASSERT( pSttNdIdx->GetIndex()+1 !=
+ pPaM->GetBound( sal_True ).nNode.GetIndex(),
+ "PaM.Bound1 point to new node " );
+ ASSERT( pSttNdIdx->GetIndex()+1 !=
+ pPaM->GetBound( sal_False ).nNode.GetIndex(),
+ "PaM.Bound2 points to new node" );
+
+ if( pSttNdIdx->GetIndex()+1 ==
+ pPaM->GetBound( sal_True ).nNode.GetIndex() )
+ {
+ sal_uInt16 nCntPos =
+ pPaM->GetBound( sal_True ).nContent.GetIndex();
+ pPaM->GetBound( sal_True ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+ }
+ if( pSttNdIdx->GetIndex()+1 ==
+ pPaM->GetBound( sal_False ).nNode.GetIndex() )
+ {
+ sal_uInt16 nCntPos =
+ pPaM->GetBound( sal_False ).nContent.GetIndex();
+ pPaM->GetBound( sal_False ).nContent.Assign( pTxtNode,
+ pTxtNode->GetTxt().Len() + nCntPos );
+ }
+#endif
+ // If the first new node isn't empty, convert the node's text
+ // attributes into hints. Otherwise, set the new node's paragraph
+ // style at the previous (empty) node.
+ SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
+ if( pTxtNode->GetTxt().Len() )
+ pDelNd->FmtToTxtAttr( pTxtNode );
+ else
+ pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
+ pTxtNode->JoinNext();
+ }
+ }
+
+ SwPosition* pPos = pPaM->GetPoint();
+ if( !pPos->nContent.GetIndex() )
+ {
+ SwTxtNode* pCurrNd;
+ sal_uInt32 nNodeIdx = pPos->nNode.GetIndex();
+
+ if( !IsInsertMode() )
+ {
+ if( pDoc->GetNodes()[nNodeIdx -1]->IsCntntNode() )
+ {
+ SwCntntNode* pCNd = pPaM->GetCntntNode();
+ if( pCNd && pCNd->StartOfSectionIndex()+2 <
+ pCNd->EndOfSectionIndex() )
+ {
+ pPaM->GetBound(sal_True).nContent.Assign( 0, 0 );
+ pPaM->GetBound(sal_False).nContent.Assign( 0, 0 );
+ pDoc->GetNodes().Delete( pPaM->GetPoint()->nNode );
+ }
+ }
+ }
+ else if( 0 != (pCurrNd = pDoc->GetNodes()[nNodeIdx]->GetTxtNode()) )
+ {
+ if( pCurrNd->CanJoinNext( &pPos->nNode ))
+ {
+ SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
+ pPos->nContent.Assign( pNextNd, 0 );
+ pPaM->SetMark(); pPaM->DeleteMark();
+ pNextNd->JoinPrev();
+ }
+ else if( !pCurrNd->GetTxt().Len() )
+ {
+ pPos->nContent.Assign( 0, 0 );
+ pPaM->SetMark(); pPaM->DeleteMark();
+ pDoc->GetNodes().Delete( pPos->nNode, 1 );
+ pPaM->Move( fnMoveBackward );
+ }
+ }
+ }
+ else if( IsInsertMode() )
+ {
+ pPaM->Move( fnMoveForward, fnGoNode );
+ SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
+ SwNodeIndex aPrvIdx( pPos->nNode );
+ if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) &&
+ *pSttNdIdx <= aPrvIdx )
+ {
+ // In fact, we should do an JoinNext here, but the Cursor and
+ // many other stuff is registered to the current node. That for
+ // the node should remain and we do an JoinPrev here.
+
+ // Convert paragraph attributes into hints and set paragraph
+ // style at the next node.
+ SwTxtNode* pPrev = aPrvIdx.GetNode().GetTxtNode();
+ pTxtNode->ChgFmtColl( pPrev->GetTxtColl() );
+ pTxtNode->FmtToTxtAttr( pPrev );
+ pTxtNode->SwCntntNode::ResetAllAttr();
+
+ if( pPrev->GetpSwAttrSet() )
+ pTxtNode->SwCntntNode::SetAttr( *pPrev->GetpSwAttrSet() );
+
+ if( &pPaM->GetBound(sal_True).nNode.GetNode() == pPrev )
+ pPaM->GetBound(sal_True).nContent.Assign( pTxtNode, 0 );
+ if( &pPaM->GetBound(sal_False).nNode.GetNode() == pPrev )
+ pPaM->GetBound(sal_False).nContent.Assign( pTxtNode, 0 );
+
+ pTxtNode->JoinPrev();
+ }
+ }
+ }
+
+#ifdef XML_CORE_API
+ RemoveUnusedNumRules();
+#endif
+
+ delete pSttNdIdx;
+ delete pPaM;
+ delete pDocElemTokenMap;
+#ifdef XML_CORE_API
+ delete pI18NMap;
+ delete pBodyElemTokenMap;
+ delete pTextPElemTokenMap;
+ delete pTextPAttrTokenMap;
+ delete pStyleStylesElemTokenMap;
+ delete pTextListBlockAttrTokenMap;
+ delete pTextListBlockElemTokenMap;
+#endif
+ delete pTableElemTokenMap;
+ _FinitItemImport();
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlimp.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.30 2000/09/18 16:05:06 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.29 2000/08/29 07:33:47 mib
+ text import continued
+
+ Revision 1.28 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.27 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.26 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.25 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.24 2000/07/07 13:58:36 mib
+ text styles using StarOffice API
+
+ Revision 1.23 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.22 2000/05/15 16:53:17 jp
+ Changes for Unicode
+
+ Revision 1.21 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.20 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.19 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.17 2000/01/27 08:59:02 mib
+ #70271#: outline numbering
+
+ Revision 1.16 2000/01/20 10:03:16 mib
+ #70271#: Lists reworked
+
+ Revision 1.15 2000/01/06 15:08:27 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.14 1999/11/26 11:12:51 mib
+ loading of styles only and insert mode
+
+ Revision 1.13 1999/11/22 15:53:39 mib
+ split/join nodes correctly
+
+ Revision 1.12 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.11 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.10 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.9 1999/10/15 12:39:11 mib
+ moved styles element from style to office namespace
+
+ Revision 1.8 1999/10/08 11:47:49 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.7 1999/10/05 14:31:14 hr
+ #65293#: removed redundant const
+
+ Revision 1.6 1999/09/28 10:46:58 mib
+ memory leak
+
+ Revision 1.5 1999/09/23 11:54:16 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.4 1999/09/22 11:57:14 mib
+ string -> wstring
+
+ Revision 1.3 1999/08/19 12:57:42 MIB
+ attribute import added
+
+
+ Rev 1.2 19 Aug 1999 14:57:42 MIB
+ attribute import added
+
+ Rev 1.1 18 Aug 1999 17:05:20 MIB
+ Style import
+
+ Rev 1.0 17 Aug 1999 16:32:52 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
new file mode 100644
index 000000000000..5bb684245bf7
--- /dev/null
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlimp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _XMLIMP_HXX
+#define _XMLIMP_HXX
+
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLIMP_HXX
+#include <xmloff/xmlimp.hxx>
+#endif
+
+class SwDoc;
+class SwPaM;
+class SvXMLUnitConverter;
+class SvI18NMap;
+class SvXMLTokenMap;
+class SvXMLImportItemMapper;
+class SvXMLStyleContext;
+class SwXMLListBlockContext;
+class SwXMLListItemContext;
+class SfxItemSet;
+class SwNodeIndex;
+class SwNumRule;
+class SwNumRulesSort_Impl;
+class XMLTextImportHelper;
+
+class SwXMLImport: public SvXMLImport
+{
+ SwDoc *pDoc;
+ SwPaM *pPaM; // SwPosition ??
+ SwNodeIndex *pSttNdIdx;
+
+ SvXMLUnitConverter *pTwipUnitConv;
+#ifdef XML_CORE_API
+ SvXMLImportItemMapper *pParaItemMapper;// paragraph item import
+#endif
+ SvXMLImportItemMapper *pTableItemMapper;// paragraph item import
+#ifdef XML_CORE_API
+ SvI18NMap *pI18NMap; // name mapping for I18N
+ SwNumRulesSort_Impl *pUnusedNumRules;
+#endif
+ SvXMLTokenMap *pDocElemTokenMap;
+#ifdef XML_CORE_API
+ SvXMLTokenMap *pBodyElemTokenMap;
+ SvXMLTokenMap *pTextPElemTokenMap;
+ SvXMLTokenMap *pTextPAttrTokenMap;
+ SvXMLTokenMap *pStyleStylesElemTokenMap;
+ SvXMLTokenMap *pTextListBlockAttrTokenMap;
+ SvXMLTokenMap *pTextListBlockElemTokenMap;
+#endif
+ SvXMLTokenMap *pTableElemTokenMap;
+
+ SvXMLItemMapEntriesRef xTableItemMap;
+ SvXMLItemMapEntriesRef xTableColItemMap;
+ SvXMLItemMapEntriesRef xTableRowItemMap;
+ SvXMLItemMapEntriesRef xTableCellItemMap;
+
+ SvXMLImportContextRef xStyles;
+ SvXMLImportContextRef xAutoStyles;
+#ifdef XML_CORE_API
+ SvXMLImportContextRef xListBlock;
+ SvXMLImportContextRef xListItem;
+#endif
+
+ sal_uInt16 nStyleFamilyMask;// Mask of styles to load
+ sal_Bool bLoadDoc : 1; // Load doc or styles only
+ sal_Bool bInsert : 1; // Insert mode. If styles are
+ // loaded only sal_False means that
+ // existing styles will be
+ // overwritten.
+ sal_Bool bAutoStylesValid : 1;
+
+
+ void _InitItemImport();
+ void _FinitItemImport();
+#ifdef XML_CORE_API
+ void RemoveUnusedNumRules();
+#endif
+
+ void InsertStyles();
+
+protected:
+
+ // This method is called after the namespace map has been updated, but
+ // before a context for the current element has been pushed.
+ virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual XMLTextImportHelper* CreateTextImport();
+
+public:
+
+ SwXMLImport( SwDoc& rDoc, const SwPaM& rPaM, sal_Bool bLoadDoc,
+ sal_Bool bInsertMode, sal_uInt16 nStyleFamMask,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & rModel );
+
+ ~SwXMLImport();
+
+ // namespace office
+ SvXMLImportContext *CreateMetaContext( const ::rtl::OUString& rLocalName );
+ SvXMLImportContext *CreateStylesContext(
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bAuto );
+ SvXMLImportContext *CreateBodyContext( const ::rtl::OUString& rLocalName );
+
+
+#ifdef XML_CORE_API
+ SwPaM& GetPaM() { return *pPaM; }
+#endif
+ SwDoc& GetDoc() { return *pDoc; }
+ const SwDoc& GetDoc() const { return *pDoc; }
+
+ sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; }
+ sal_Bool IsInsertMode() const { return bInsert; }
+ sal_Bool IsStylesOnlyMode() const { return !bLoadDoc; }
+
+#ifdef XML_CORE_API
+ SvI18NMap& GetI18NMap() { return *pI18NMap; }
+#endif
+
+ inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
+#ifdef XML_CORE_API
+ inline const SvXMLImportItemMapper& GetParaItemMapper() const;
+#endif
+ inline const SvXMLImportItemMapper& GetTableItemMapper() const;
+#ifdef XML_CORE_API
+ SvXMLImportContext *CreateParaItemImportContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet );
+#endif
+ SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_uInt16 nSubFamily, SfxItemSet& rItemSet );
+
+ const SvXMLTokenMap& GetDocElemTokenMap();
+#ifdef XML_CORE_API
+ const SvXMLTokenMap& GetBodyElemTokenMap();
+ const SvXMLTokenMap& GetTextPElemTokenMap();
+ const SvXMLTokenMap& GetTextPAttrTokenMap();
+ const SvXMLTokenMap& GetStyleStylesElemTokenMap();
+ const SvXMLTokenMap& GetTextListBlockAttrTokenMap();
+ const SvXMLTokenMap& GetTextListBlockElemTokenMap();
+#endif
+ const SvXMLTokenMap& GetTableElemTokenMap();
+
+#ifdef XML_CORE_API
+ inline sal_Bool FindAutomaticStyle( SfxStyleFamily eFamily,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet=0,
+ ::rtl::OUString *pParent=0 ) const;
+ sal_Bool FindAutomaticStyle( SfxStyleFamily eFamily,
+ sal_uInt16 nSubStyle,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet=0,
+ ::rtl::OUString *pParent=0 ) const;
+#else
+ sal_Bool FindAutomaticStyle( sal_uInt16 nFamily,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet=0,
+ ::rtl::OUString *pParent=0 ) const;
+#endif
+
+#ifdef XML_CORE_API
+ SwXMLListBlockContext *GetListBlock();
+ sal_Bool IsInList() const { return xListBlock.Is(); }
+ void SetListBlock( SwXMLListBlockContext *pListBlock );
+
+ SwXMLListItemContext *GetListItem();
+ sal_Bool HasListItem() const { return xListItem.Is(); }
+ void SetListItem( SwXMLListItemContext *pListItem );
+
+ void AddUnused( const SwNumRule& rNumRule );
+ void SetUsed( const SwNumRule& rNumRule );
+#endif
+};
+
+inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const
+{
+ return *pTwipUnitConv;
+}
+
+#ifdef XML_CORE_API
+inline const SvXMLImportItemMapper& SwXMLImport::GetParaItemMapper() const
+{
+ return *pParaItemMapper;
+}
+#endif
+
+inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const
+{
+ return *pTableItemMapper;
+}
+
+#ifdef XML_CORE_API
+inline sal_Bool SwXMLImport::FindAutomaticStyle( SfxStyleFamily eFamily,
+ const ::rtl::OUString& rName,
+ const SfxItemSet **ppItemSet,
+ ::rtl::OUString *pParent ) const
+{
+ return FindAutomaticStyle( eFamily, 0U, rName, ppItemSet, pParent );
+}
+#endif
+
+
+#endif // _XMLIMP_HXX
diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx
new file mode 100644
index 000000000000..e952d9fbd075
--- /dev/null
+++ b/sw/source/filter/xml/xmliteme.cxx
@@ -0,0 +1,490 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmliteme.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:14:59 $
+ *
+ * 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
+
+#include <hintids.hxx>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _SHL_HXX //autogen wg. SHL_WRITER
+#include <tools/shl.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef _XMLOFF_XMLITMPR_HXX
+#include <xmloff/xmlexpit.hxx>
+#endif
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLTABE_HXX
+#include <xmloff/xmltabe.hxx>
+#endif
+#ifndef _XMLBRSHE_HXX
+#include "xmlbrshe.hxx"
+#endif
+
+#ifndef _SVX_TSPTITEM_HXX
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+
+#ifndef _VCL_FLDUNIT_HXX
+#include <vcl/fldunit.hxx>
+#endif
+
+#ifndef _SWMODULE_HXX //autogen wg. SW_MOD
+#include <swmodule.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _FMTORNT_HXX
+#include "fmtornt.hxx"
+#endif
+#ifndef _UNOMID_H
+#include <unomid.h>
+#endif
+#ifndef _FRMFMT_HXX
+#include "frmfmt.hxx"
+#endif
+#ifndef _FMTFSIZE_HXX
+#include "fmtfsize.hxx"
+#endif
+#ifndef _SWRECT_HXX
+#include "swrect.hxx"
+#endif
+
+#ifndef _XMLDROPE_HXX
+#include "xmldrope.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#ifdef XML_CORE_API
+extern SvXMLItemMapEntry aXMLParaItemMap[];
+#endif
+extern SvXMLItemMapEntry aXMLTableItemMap[];
+extern SvXMLItemMapEntry aXMLTableRowItemMap[];
+extern SvXMLItemMapEntry aXMLTableCellItemMap[];
+
+#ifdef XML_CORE_API
+class SwXMLTextItemMapper_Impl: public SvXMLExportItemMapper
+{
+protected:
+ SvXMLUnitConverter& mrUnitConverter;
+ const Reference< xml::sax::XDocumentHandler > & mrHandler;
+ SvxXMLTabStopExport maTabStopExport;
+
+public:
+
+ SwXMLTextItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler );
+
+ virtual ~SwXMLTextItemMapper_Impl();
+
+ virtual void handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet& rSet,
+ sal_uInt16 nFlags ) const;
+};
+
+SwXMLTextItemMapper_Impl::SwXMLTextItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler ) :
+ SvXMLExportItemMapper( rMapEntries ),
+ mrUnitConverter(rUnitConverter),
+ mrHandler( rHandler ),
+ maTabStopExport( rHandler, rUnitConverter )
+{
+}
+
+SwXMLTextItemMapper_Impl::~SwXMLTextItemMapper_Impl()
+{
+}
+
+/** this method is called for every item that has the
+ MID_FLAG_ELEMENT_EXPORT flag set */
+void SwXMLTextItemMapper_Impl::handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet&,
+ sal_uInt16 ) const
+{
+ switch( rEntry.nWhichId )
+ {
+ case RES_PARATR_TABSTOP:
+ {
+ SvxXMLTabStopExport aTabStopExport( rHandler, rUnitConverter );
+
+ Any aAny;
+ rItem.QueryValue( aAny, 0 );
+ aTabStopExport.Export( aAny, rNamespaceMap );
+ }
+ break;
+ case RES_PARATR_DROP:
+ {
+ SwXMLFmtDropExport aFmtDropExport( rHandler, rUnitConverter );
+ aFmtDropExport.exportXML( (const SwFmtDrop&)rItem, rNamespaceMap );
+ }
+ break;
+ case RES_BACKGROUND:
+ {
+ SwXMLBrushItemExport aBrushItemExport( rHandler, rUnitConverter );
+ aBrushItemExport.exportXML( (const SvxBrushItem&)rItem,
+ rNamespaceMap );
+ }
+ break;
+ }
+}
+#endif
+
+// ----------------------------------------------------------------------------
+
+class SwXMLTableItemMapper_Impl: public SvXMLExportItemMapper
+{
+ const OUString sCDATA;
+
+protected:
+ SvXMLUnitConverter& mrUnitConverter;
+ const Reference< xml::sax::XDocumentHandler > & mrHandler;
+
+ sal_uInt32 nAbsWidth;
+
+ void AddAttribute( sal_uInt16 nPrefix, const sal_Char *pLName,
+ const OUString& rValue,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ SvXMLAttributeList& rAttrList ) const;
+
+public:
+
+ SwXMLTableItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler );
+
+ virtual ~SwXMLTableItemMapper_Impl();
+
+ virtual void handleSpecialItem( SvXMLAttributeList& rAttrList,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet *pSet = NULL ) const;
+
+ virtual void handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet& rSet,
+ sal_uInt16 nFlags ) const;
+
+ inline void SetAbsWidth( sal_uInt32 nAbs );
+};
+
+SwXMLTableItemMapper_Impl::SwXMLTableItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SvXMLUnitConverter& rUnitConverter,
+ const Reference< xml::sax::XDocumentHandler > & rHandler ) :
+ SvXMLExportItemMapper( rMapEntries ),
+ sCDATA( OUString::createFromAscii( sXML_CDATA ) ),
+ mrUnitConverter(rUnitConverter),
+ mrHandler( rHandler ),
+ nAbsWidth( USHRT_MAX )
+{
+}
+
+SwXMLTableItemMapper_Impl::~SwXMLTableItemMapper_Impl()
+{
+}
+
+void SwXMLTableItemMapper_Impl::AddAttribute( sal_uInt16 nPrefix,
+ const sal_Char *pLName,
+ const OUString& rValue,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ SvXMLAttributeList& rAttrList ) const
+{
+ OUString sLName( OUString::createFromAscii(pLName) );
+ OUString sName( rNamespaceMap.GetQNameByKey( nPrefix, sLName ) );
+ rAttrList.AddAttribute( sName, sCDATA, rValue );
+}
+
+void SwXMLTableItemMapper_Impl::handleSpecialItem(
+ SvXMLAttributeList& rAttrList,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet *pSet ) const
+{
+ switch( rEntry.nWhichId )
+ {
+ case RES_LR_SPACE:
+ {
+ const SfxPoolItem *pItem;
+ if( pSet &&
+ SFX_ITEM_SET == pSet->GetItemState( RES_HORI_ORIENT, sal_True,
+ &pItem ) )
+ {
+ SwHoriOrient eHoriOrient =
+ ((const SwFmtHoriOrient *)pItem)->GetHoriOrient();
+ sal_Bool bExport = sal_False;
+ sal_uInt32 nMemberId = rEntry.nMemberId & MID_FLAG_MASK;
+ switch( nMemberId )
+ {
+ case MID_L_MARGIN:
+ bExport = HORI_NONE == eHoriOrient ||
+ HORI_LEFT_AND_WIDTH == eHoriOrient;
+ break;
+ case MID_R_MARGIN:
+ bExport = HORI_NONE == eHoriOrient;
+ break;
+ }
+ OUString sValue;
+ if( bExport && rItem.exportXML( sValue, nMemberId,
+ rUnitConverter ) )
+ {
+ AddAttribute( rEntry.nNameSpace, rEntry.pLocalName, sValue,
+ rNamespaceMap, rAttrList );
+ }
+ }
+ }
+ break;
+
+ case RES_FRM_SIZE:
+ {
+ sal_uInt32 nMemberId = rEntry.nMemberId & MID_FLAG_MASK;
+ switch( nMemberId )
+ {
+ case MID_FRMSIZE_WIDTH:
+ if( nAbsWidth )
+ {
+ OUStringBuffer sBuffer;
+ rUnitConverter.convertMeasure( sBuffer, nAbsWidth );
+ AddAttribute( rEntry.nNameSpace, rEntry.pLocalName,
+ sBuffer.makeStringAndClear(),
+ rNamespaceMap, rAttrList );
+ }
+ break;
+ case MID_FRMSIZE_REL_WIDTH:
+ {
+ OUString sValue;
+ if( rItem.exportXML( sValue, nMemberId, rUnitConverter ) )
+ {
+ AddAttribute( rEntry.nNameSpace, rEntry.pLocalName,
+ sValue, rNamespaceMap, rAttrList );
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+}
+
+/** this method is called for every item that has the
+ MID_FLAG_ELEMENT_EXPORT flag set */
+void SwXMLTableItemMapper_Impl::handleElementItem(
+ const Reference< xml::sax::XDocumentHandler > & rHandler,
+ const SvXMLItemMapEntry& rEntry,
+ const SfxPoolItem& rItem,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const SfxItemSet&,
+ sal_uInt16 ) const
+{
+ switch( rEntry.nWhichId )
+ {
+ case RES_BACKGROUND:
+ {
+ SwXMLBrushItemExport aBrushItemExport( rHandler, rUnitConverter );
+ aBrushItemExport.exportXML( (const SvxBrushItem&)rItem,
+ rNamespaceMap );
+ }
+ break;
+ }
+}
+
+inline void SwXMLTableItemMapper_Impl::SetAbsWidth( sal_uInt32 nAbs )
+{
+ nAbsWidth = nAbs;
+}
+
+// ----------------------------------------------------------------------------
+
+void SwXMLExport::_InitItemExport()
+{
+ pTwipUnitConv = new SvXMLUnitConverter( MAP_TWIP,
+ GetMM100UnitConverter().getXMLMeasureUnit() );
+
+#ifdef XML_CORE_API
+ SvXMLItemMapEntriesRef xParaItemMap =
+ new SvXMLItemMapEntries( aXMLParaItemMap );
+
+ pParaItemMapper = new SwXMLTextItemMapper_Impl( xParaItemMap,
+ *pTwipUnitConv,
+ GetDocHandler() );
+#endif
+
+ xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap );
+ xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap );
+ xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap );
+
+ pTableItemMapper = new SwXMLTableItemMapper_Impl( xTableItemMap,
+ *pTwipUnitConv,
+ GetDocHandler() );
+}
+
+void SwXMLExport::_FinitItemExport()
+{
+#ifdef XML_CORE_API
+ delete pParaItemMapper;
+#endif
+ delete pTableItemMapper;
+ delete pTwipUnitConv;
+}
+
+void SwXMLExport::ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth )
+{
+ ((SwXMLTableItemMapper_Impl *)pTableItemMapper)
+ ->SetAbsWidth( nAbsWidth );
+ ExportFmt( rFmt, sXML_table );
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmliteme.cxx,v 1.1.1.1 2000-09-18 17:14:59 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.10 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.9 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.8 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.7 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.6 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.5 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.4 2000/02/11 14:41:45 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.3 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.2 2000/01/20 14:03:58 mib
+ #70271#: deletion of unit converter
+
+ Revision 1.1 1999/12/14 07:32:49 mib
+ #70271#: XML import/export of drop cap/register/language item, splitted swxmlat
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx
new file mode 100644
index 000000000000..4fae5b362f1f
--- /dev/null
+++ b/sw/source/filter/xml/xmlitemi.cxx
@@ -0,0 +1,638 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlitemi.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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
+
+#include <hintids.hxx>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLIMPIT_HXX
+#include <xmloff/xmlimpit.hxx>
+#endif
+#ifndef _XMLOFF_XMLITEM_HXX
+#include <xmloff/xmlitem.hxx>
+#endif
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+#ifndef _XMLOFF_FAMILIES_HXX
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_FONTITEM_HXX
+#include <svx/fontitem.hxx>
+#endif
+#ifndef _SVX_TSPTITEM_HXX
+#include <svx/tstpitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_LANGITEM_HXX
+#include <svx/langitem.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTABI_HXX
+//#include <xmloff/xmltabi.hxx>
+#endif
+
+#ifndef _XMLBRSHI_HXX
+#include "xmlbrshi.hxx"
+#endif
+
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _UNOMID_H
+#include <unomid.h>
+#endif
+
+#ifndef _XMDROPI_HXX
+#include "xmldropi.hxx"
+#endif
+#ifdef XML_CORE_API
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#ifdef XML_CORE_API
+extern SvXMLItemMapEntry aXMLParaItemMap[];
+#endif
+extern SvXMLItemMapEntry aXMLTableItemMap[];
+extern SvXMLItemMapEntry aXMLTableColItemMap[];
+extern SvXMLItemMapEntry aXMLTableRowItemMap[];
+extern SvXMLItemMapEntry aXMLTableCellItemMap[];
+
+#ifdef XML_CORE_API
+class SwXMLImportTextItemMapper_Impl: public SvXMLImportItemMapper
+{
+ SvI18NMap& rI18NMap;
+ SwDoc& rDoc;
+
+public:
+
+ SwXMLImportTextItemMapper_Impl( SvXMLItemMapEntriesRef rMapEntries,
+ SwDoc& rD, SvI18NMap& rI18NMap );
+ virtual ~SwXMLImportTextItemMapper_Impl();
+
+ virtual sal_Bool handleSpecialItem( const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const;
+
+ virtual void finished( SfxItemSet& rSet ) const;
+};
+
+SwXMLImportTextItemMapper_Impl::SwXMLImportTextItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries,
+ SwDoc& rD, SvI18NMap& rI18NM ) :
+ SvXMLImportItemMapper( rMapEntries, RES_UNKNOWNATR_CONTAINER),
+ rDoc( rD ),
+ rI18NMap( rI18NM )
+{
+}
+
+SwXMLImportTextItemMapper_Impl::~SwXMLImportTextItemMapper_Impl()
+{
+}
+
+sal_Bool SwXMLImportTextItemMapper_Impl::handleSpecialItem(
+ const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rItemSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvXMLNamespaceMap& ) const
+{
+ sal_Bool bRet = sal_False;
+ switch( rItem.Which() )
+ {
+ case RES_TXTATR_CHARFMT:
+ DBG_ASSERT( !this,
+ "SwXMLImportTextItemMapper_Impl::handleSpecialItem: char fmt unexpected" );
+ break;
+
+ case RES_PARATR_NUMRULE:
+ if( rValue.getLength() )
+ {
+ OUString sName( rI18NMap.Get( SFX_STYLE_FAMILY_PSEUDO, rValue ) );
+ ((SwNumRuleItem&)rItem).SetValue( sName );
+ bRet = sal_True;
+ }
+ break;
+
+ case RES_CHRATR_LANGUAGE:
+ // If the item is not contained in the item set, its the default
+ // value. To set language and contry individually, we have to clear
+ // its value.
+ if( SFX_ITEM_SET != rItemSet.GetItemState( RES_CHRATR_LANGUAGE,
+ sal_False ) )
+ {
+ ((SvxLanguageItem &)rItem).SetLanguage( LANGUAGE_NONE );
+ }
+ bRet = rItem.importXML( rValue, rEntry.nMemberId, rUnitConv );
+ break;
+ }
+
+ return bRet;
+}
+
+void SwXMLImportTextItemMapper_Impl::finished( SfxItemSet& rSet ) const
+{
+ const SfxPoolItem *pItem;
+
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_FONT, sal_False,
+ &pItem ) )
+ {
+ const SvxFontItem *pFont = (const SvxFontItem *)pItem;
+ // delete font items that have no family name
+ if( 0 == pFont->GetFamilyName().Len() )
+ rSet.ClearItem( RES_CHRATR_FONT );
+ else if( RTL_TEXTENCODING_DONTKNOW == pFont->GetCharSet() )
+ {
+ SvxFontItem aFont( *pFont );
+ aFont.GetCharSet() = gsl_getSystemTextEncoding();
+ rSet.Put( aFont );
+ }
+ }
+
+ // ensure that box item have a distance to a border.
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ {
+ const SvxBoxItem *pBox = (const SvxBoxItem *)pItem;
+ sal_uInt16 aLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM,
+ BOX_LINE_LEFT, BOX_LINE_RIGHT };
+ sal_uInt16 i;
+ for( i=0; i<4; i++ )
+ {
+ if( pBox->GetLine( aLines[i] ) &&
+ pBox->GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ break;
+ }
+ if( i < 4 )
+ {
+ SvxBoxItem aBox( *pBox );
+ for( /*i=0*/; i<4; i++ ) // i points to the mod. line
+ {
+ if( aBox.GetLine( aLines[i] ) &&
+ aBox.GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ aBox.SetDistance( MIN_BORDER_DIST, aLines[i] );
+ }
+ rSet.Put( aBox );
+ }
+ }
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+class SwXMLImportTableItemMapper_Impl: public SvXMLImportItemMapper
+{
+
+public:
+
+ SwXMLImportTableItemMapper_Impl( SvXMLItemMapEntriesRef rMapEntries );
+ virtual ~SwXMLImportTableItemMapper_Impl();
+
+ virtual sal_Bool handleSpecialItem( const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const;
+ virtual void finished( SfxItemSet& rSet ) const;
+};
+
+SwXMLImportTableItemMapper_Impl::SwXMLImportTableItemMapper_Impl(
+ SvXMLItemMapEntriesRef rMapEntries ) :
+ SvXMLImportItemMapper( rMapEntries, RES_UNKNOWNATR_CONTAINER)
+{
+}
+
+SwXMLImportTableItemMapper_Impl::~SwXMLImportTableItemMapper_Impl()
+{
+}
+
+sal_Bool SwXMLImportTableItemMapper_Impl::handleSpecialItem(
+ const SvXMLItemMapEntry& rEntry,
+ SfxPoolItem& rItem,
+ SfxItemSet& rItemSet,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConv,
+ const SvXMLNamespaceMap& ) const
+{
+ sal_Bool bRet = sal_False;
+ sal_uInt16 nMemberId = rEntry.nMemberId & MID_FLAG_MASK;
+ switch( rItem.Which() )
+ {
+ case RES_FRM_SIZE:
+ switch( nMemberId )
+ {
+ case MID_FRMSIZE_COL_WIDTH:
+ // If the item is existing already, a relative value has been set
+ // already that must be preserved.
+ if( SFX_ITEM_SET != rItemSet.GetItemState( RES_FRM_SIZE,
+ sal_False ) )
+ bRet = rItem.importXML( rValue, nMemberId, rUnitConv );
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+void SwXMLImportTableItemMapper_Impl::finished( SfxItemSet& rSet ) const
+{
+#if 0
+ const SfxPoolItem *pItem;
+
+ // ensure that box item have a distance to a border.
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ {
+ const SvxBoxItem *pBox = (const SvxBoxItem *)pItem;
+ sal_uInt16 aLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM,
+ BOX_LINE_LEFT, BOX_LINE_RIGHT };
+ sal_uInt16 i;
+ for( i=0; i<4; i++ )
+ {
+ if( pBox->GetLine( aLines[i] ) &&
+ pBox->GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ break;
+ }
+ if( i < 4 )
+ {
+ SvxBoxItem aBox( *pBox );
+ for( /*i=0*/; i<4; i++ ) // i points to the mod. line
+ {
+ if( aBox.GetLine( aLines[i] ) &&
+ aBox.GetDistance( aLines[i] ) < MIN_BORDER_DIST )
+ aBox.SetDistance( MIN_BORDER_DIST, aLines[i] );
+ }
+ rSet.Put( aBox );
+ }
+ }
+#endif
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLItemSetContext_Impl : public SvXMLItemSetContext
+{
+ SvXMLImportContextRef xBackground;
+#ifdef XML_CORE_API
+ SvXMLImportContextRef xTabStop;
+ SvXMLImportContextRef xDropCap;
+#endif
+
+public:
+ SwXMLItemSetContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLImportItemMapper& rIMapper,
+ const SvXMLUnitConverter& rUnitConv );
+ virtual ~SwXMLItemSetContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLItemMapEntry& rEntry,
+ const SvXMLUnitConverter& rUnitConv );
+};
+
+SwXMLItemSetContext_Impl::SwXMLItemSetContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLImportItemMapper& rIMapper,
+ const SvXMLUnitConverter& rUnitConv ) :
+ SvXMLItemSetContext( rImport, nPrfx, rLName, xAttrList,
+ rItemSet, rIMapper, rUnitConv )
+{
+}
+
+SwXMLItemSetContext_Impl::~SwXMLItemSetContext_Impl()
+{
+#ifdef XML_CORE_API
+ if( xTabStop.Is() )
+ {
+ Any aAny;
+ ((SvxXMLTabStopImportContext*)&xTabStop)->fillTabStops( aAny );
+ SvxTabStopItem aTabStop( RES_PARATR_TABSTOP );
+ ((SfxPoolItem *)&aTabStop)->PutValue( aAny, 0 );
+ rItemSet.Put( aTabStop );
+ }
+ if( xDropCap.Is() )
+ {
+ const SwFmtDrop& rItem =
+ ((SwXMLFmtDropImportContext*)&xDropCap)->GetItem();
+ rItemSet.Put( rItem );
+ }
+#endif
+ if( xBackground.Is() )
+ {
+ const SvxBrushItem& rItem =
+ ((SwXMLBrushItemImportContext*)&xBackground)->GetItem();
+ rItemSet.Put( rItem );
+ }
+}
+
+SvXMLImportContext *SwXMLItemSetContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet,
+ const SvXMLItemMapEntry& rEntry,
+ const SvXMLUnitConverter& rUnitConv )
+{
+ SvXMLImportContext *pContext = 0;
+
+ switch( rEntry.nWhichId )
+ {
+#ifdef XML_CORE_API
+ case RES_PARATR_TABSTOP:
+ pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
+ rLocalName, rUnitConv );
+ xTabStop = pContext;
+ break;
+
+ case RES_PARATR_DROP:
+ pContext = new SwXMLFmtDropImportContext( (SwXMLImport&)GetImport(),
+ nPrefix, rLocalName,
+ xAttrList, rUnitConv,
+ RES_PARATR_DROP );
+ xDropCap = pContext;
+ break;
+#endif
+
+ case RES_BACKGROUND:
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND,
+ sal_False, &pItem ) )
+ {
+ pContext = new SwXMLBrushItemImportContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ rUnitConv, *(const SvxBrushItem *)pItem );
+ }
+ else
+ {
+ pContext = new SwXMLBrushItemImportContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ rUnitConv, RES_BACKGROUND );
+ }
+ xBackground = pContext;
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = SvXMLItemSetContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList, rItemSet,
+ rEntry, rUnitConv );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+void SwXMLImport::_InitItemImport()
+{
+ pTwipUnitConv = new SvXMLUnitConverter( MAP_TWIP, MAP_TWIP );
+
+#ifdef XML_CORE_API
+ SvXMLItemMapEntriesRef xParaItemMapEntries =
+ new SvXMLItemMapEntries( aXMLParaItemMap );
+
+ pParaItemMapper = new SwXMLImportTextItemMapper_Impl( xParaItemMapEntries,
+ GetDoc(), GetI18NMap() );
+#endif
+
+ xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap );
+ xTableColItemMap = new SvXMLItemMapEntries( aXMLTableColItemMap );
+ xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap );
+ xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap );
+
+ pTableItemMapper = new SwXMLImportTableItemMapper_Impl( xTableItemMap );
+}
+
+void SwXMLImport::_FinitItemImport()
+{
+#ifdef XML_CORE_API
+ delete pParaItemMapper;
+#endif
+ delete pTableItemMapper;
+ delete pTwipUnitConv;
+}
+
+#ifdef XML_CORE_API
+SvXMLImportContext *SwXMLImport::CreateParaItemImportContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SfxItemSet& rItemSet )
+{
+ return new SwXMLItemSetContext_Impl( *this, nPrefix, rLocalName,
+ xAttrList, rItemSet,
+ GetParaItemMapper(),
+ GetTwipUnitConverter() );
+}
+#endif
+
+SvXMLImportContext *SwXMLImport::CreateTableItemImportContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+#ifdef XML_CORE_API
+ sal_uInt16 nSubFamily,
+#else
+ sal_uInt16 nFamily,
+#endif
+ SfxItemSet& rItemSet )
+{
+ SvXMLItemMapEntriesRef xItemMap;
+
+#ifdef XML_CORE_API
+ switch( nSubFamily )
+#else
+ switch( nFamily )
+#endif
+ {
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE:
+#else
+ case XML_STYLE_FAMILY_TABLE_TABLE:
+#endif
+ xItemMap = xTableItemMap;
+ break;
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE_COL:
+#else
+ case XML_STYLE_FAMILY_TABLE_COLUMN:
+#endif
+ xItemMap = xTableColItemMap;
+ break;
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE_LINE:
+#else
+ case XML_STYLE_FAMILY_TABLE_ROW:
+#endif
+ xItemMap = xTableRowItemMap;
+ break;
+#ifdef XML_CORE_API
+ case SW_STYLE_SUBFAMILY_TABLE_BOX:
+#else
+ case XML_STYLE_FAMILY_TABLE_CELL:
+#endif
+ xItemMap = xTableCellItemMap;
+ break;
+ }
+
+ pTableItemMapper->setMapEntries( xItemMap );
+
+ return new SwXMLItemSetContext_Impl( *this, nPrefix, rLocalName,
+ xAttrList, rItemSet,
+ GetTableItemMapper(),
+ GetTwipUnitConverter() );
+}
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlitemi.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.9 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.8 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.7 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.6 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.5 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.3 2000/01/20 14:03:57 mib
+ #70271#: deletion of unit converter
+
+ Revision 1.2 2000/01/06 15:08:28 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.1 1999/12/14 07:32:58 mib
+ #70271#: XML import/export of drop cap/register/language item, splitted swxmlat
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlitemm.cxx b/sw/source/filter/xml/xmlitemm.cxx
new file mode 100644
index 000000000000..a8f210f815d4
--- /dev/null
+++ b/sw/source/filter/xml/xmlitemm.cxx
@@ -0,0 +1,548 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlitemm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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
+
+#include <hintids.hxx>
+
+#ifndef _SVX_UNOMID_HXX
+#include <svx/unomid.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+#ifndef _XMLOFF_XMLITMAP_HXX
+#include <xmloff/xmlitmap.hxx>
+#endif
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _UNOMID_H
+#include <unomid.h>
+#endif
+
+#define M_E( p, l, w, m ) \
+ { XML_NAMESPACE_##p, sXML_##l, w, m }
+#define M_E_SI( p, l, w, m ) \
+ { XML_NAMESPACE_##p, sXML_##l, w, MID_FLAG_SPECIAL_ITEM_IMPORT|m }
+#define M_E_SE( p, l, w, m ) \
+ { XML_NAMESPACE_##p, sXML_##l, w, MID_FLAG_SPECIAL_ITEM_EXPORT|m }
+
+#ifdef XML_CORE_API
+SvXMLItemMapEntry aXMLParaItemMap[] =
+{
+ // RES_CHRATR_CASEMAP
+ M_E( FO, font_variant, RES_CHRATR_CASEMAP, MID_CASEMAP_VARIANT ),
+ M_E( FO, text_transform, RES_CHRATR_CASEMAP, MID_CASEMAP_TRANS ),
+ // RES_CHRATR_COLOR
+ M_E( FO, color, RES_CHRATR_COLOR, 0 ),
+ // RES_CHRATR_CONTOUR
+ M_E( STYLE, text_outline, RES_CHRATR_CONTOUR, 0 ),
+ // RES_CHRATR_CROSSEDOUT
+ M_E( STYLE, text_crossing_out, RES_CHRATR_CROSSEDOUT, 0 ),
+ // RES_CHRATR_ESCAPEMENT
+ M_E( STYLE, text_position, RES_CHRATR_ESCAPEMENT, 0 ),
+ // RES_CHRATR_FONT
+ M_E( FO, font_family, RES_CHRATR_FONT, MID_FONT_FAMILY_NAME ),
+ M_E( STYLE, font_style_name, RES_CHRATR_FONT, MID_FONT_STYLE_NAME ),
+ M_E( STYLE, font_family_generic,RES_CHRATR_FONT, MID_FONT_FAMILY ),
+ M_E( STYLE, font_pitch, RES_CHRATR_FONT, MID_FONT_PITCH ),
+ M_E( STYLE, font_charset, RES_CHRATR_FONT, MID_FONT_CHAR_SET ),
+ // RES_CHRATR_FONTSIZE
+ M_E( FO, font_size, RES_CHRATR_FONTSIZE, 0 ),
+ // RES_CHRATR_KERNING
+ M_E( FO, letter_spacing, RES_CHRATR_KERNING, 0 ),
+ // RES_CHRATR_LANGUAGE
+ M_E_SI( FO, language, RES_CHRATR_LANGUAGE, MID_LANGUAGE ),
+ M_E_SI( FO, country, RES_CHRATR_LANGUAGE, MID_COUNTRY ),
+ // RES_CHRATR_POSTURE
+ M_E( FO, font_style, RES_CHRATR_POSTURE, 0 ),
+ // RES_CHRATR_PROPORTIONALFONTSIZE
+ // TODO: not used?
+ // RES_CHRATR_SHADOWED
+ M_E( FO, text_shadow, RES_CHRATR_SHADOWED, 0 ),
+ // RES_CHRATR_UNDERLINE
+ M_E( STYLE, text_underline, RES_CHRATR_UNDERLINE, 0 ),
+ // RES_CHRATR_WEIGHT
+ M_E( FO, font_weight, RES_CHRATR_WEIGHT, 0 ),
+ // RES_CHRATR_WORDLINEMODE
+ M_E( FO, score_spaces, RES_CHRATR_WORDLINEMODE, 0 ),
+ // RES_CHRATR_AUTOKERN
+ M_E( STYLE, letter_kerning, RES_CHRATR_AUTOKERN, 0 ),
+ // RES_CHRATR_BLINK
+ M_E( STYLE, text_blinking, RES_CHRATR_BLINK, 0 ),
+ // RES_CHRATR_NOHYPHEN
+ // TODO: not used?
+ // RES_CHRATR_NOLINEBREAK
+ // TODO: not used?
+ // RES_CHRATR_BACKGROUND
+ M_E( FO, text_background_color, RES_CHRATR_BACKGROUND, MID_BACK_COLOR ),
+ // RES_TXTATR_INETFMT
+ // TODO
+ // RES_TXTATR_REFMARK
+ // TODO
+ // RES_TXTATR_TOXMARK
+ // TODO
+ // RES_TXTATR_CHARFMT
+ M_E_SI( TEXT, style_name, RES_TXTATR_CHARFMT, 0 ),
+ // RES_TXTATR_FIELD
+ // TODO
+ // RES_TXTATR_FLYCNT
+ // TODO
+ // RES_TXTATR_FTN
+ // TODO
+ // RES_TXTATR_SOFTHYPH
+ // TODO
+ // RES_TXTATR_HARDBLANK
+ // TODO
+
+ // RES_PARATR_LINESPACING
+ M_E( FO, line_height, RES_PARATR_LINESPACING, MID_LS_FIXED ),
+ M_E( STYLE, line_height_at_least, RES_PARATR_LINESPACING, MID_LS_MINIMUM ),
+ M_E( STYLE, line_spacing, RES_PARATR_LINESPACING, MID_LS_DISTANCE ),
+ // RES_PARATR_ADJUST
+ M_E( FO, text_align, RES_PARATR_ADJUST, MID_PARA_ADJUST ),
+ M_E( FO, text_align_last, RES_PARATR_ADJUST, MID_LAST_LINE_ADJUST ),
+ M_E( STYLE, justify_single_word,RES_PARATR_ADJUST, MID_EXPAND_SINGLE ),
+ // RES_PARATR_SPLIT
+ M_E( STYLE, break_inside, RES_PARATR_SPLIT, 0 ),
+ // RES_PARATR_ORPHANS
+ M_E( FO, orphans, RES_PARATR_ORPHANS, 0 ),
+ // RES_PARATR_WIDOWS
+ M_E( FO, widows, RES_PARATR_WIDOWS, 0 ),
+ // RES_PARATR_TABSTOP
+ M_E( STYLE, tabstop_tab_stops, RES_PARATR_TABSTOP, MID_FLAG_ELEMENT_ITEM ),
+ // RES_PARATR_HYPHENZONE
+ M_E( FO, hyphenate, RES_PARATR_HYPHENZONE,
+ MID_IS_HYPHEN ),
+ M_E( FO, hyphenation_remain_char_count, RES_PARATR_HYPHENZONE,
+ MID_HYPHEN_MIN_LEAD ),
+ M_E( FO, hyphenation_push_char_count, RES_PARATR_HYPHENZONE,
+ MID_HYPHEN_MIN_TRAIL ),
+ M_E( FO, hyphenation_ladder_count, RES_PARATR_HYPHENZONE,
+ MID_HYPHEN_MAX_HYPHENS ),
+ // RES_PARATR_DROP
+ M_E( STYLE, drop_cap, RES_PARATR_DROP, MID_FLAG_ELEMENT_ITEM ),
+ // RES_PARATR_REGISTER
+ M_E( STYLE, register_true, RES_PARATR_REGISTER, 0 ),
+ // RES_PARATR_NUMRULE
+ // not required
+
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ // not required
+ // RES_PAPER_BIN
+ // not required
+ // RES_LR_SPACE
+ M_E( FO, margin_left, RES_LR_SPACE, MID_L_MARGIN ),
+ M_E( FO, margin_right, RES_LR_SPACE, MID_R_MARGIN ),
+ M_E( FO, text_indent, RES_LR_SPACE, MID_FIRST_LINE_INDENT ),
+ M_E( STYLE, auto_text_indent, RES_LR_SPACE, MID_FIRST_AUTO ),
+ // RES_UL_SPACE
+ M_E( FO, margin_top, RES_UL_SPACE, MID_UP_MARGIN ),
+ M_E( FO, margin_bottom, RES_UL_SPACE, MID_LO_MARGIN ),
+ // RES_PAGEDESC
+ // TODO
+ // RES_BREAK
+ M_E( FO, break_before, RES_BREAK, MID_BREAK_BEFORE ),
+ M_E( FO, break_after, RES_BREAK, MID_BREAK_AFTER ),
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ // not required
+ // RES_HORI_ORIENT
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ M_E( STYLE, border_line_width, RES_BOX, ALL_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_left, RES_BOX, LEFT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_right, RES_BOX, RIGHT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_top, RES_BOX, TOP_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_bottom, RES_BOX, BOTTOM_BORDER_LINE_WIDTH ),
+ M_E( FO, padding, RES_BOX, ALL_BORDER_PADDING ),
+ M_E( FO, padding_left, RES_BOX, LEFT_BORDER_PADDING ),
+ M_E( FO, padding_right, RES_BOX, RIGHT_BORDER_PADDING ),
+ M_E( FO, padding_top, RES_BOX, TOP_BORDER_PADDING ),
+ M_E( FO, padding_bottom, RES_BOX, BOTTOM_BORDER_PADDING ),
+ M_E( FO, border, RES_BOX, ALL_BORDER ),
+ M_E( FO, border_left, RES_BOX, LEFT_BORDER ),
+ M_E( FO, border_right, RES_BOX, RIGHT_BORDER ),
+ M_E( FO, border_top, RES_BOX, TOP_BORDER ),
+ M_E( FO, border_bottom, RES_BOX, BOTTOM_BORDER ),
+ // RES_SHADOW
+ M_E( STYLE, shadow, RES_SHADOW, 0 ),
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ M_E( FO, keep_with_next, RES_KEEP, 0 ),
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ // not required
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // TODO
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+#endif
+
+SvXMLItemMapEntry aXMLTableItemMap[] =
+{
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ M_E_SE( STYLE, width, RES_FRM_SIZE, MID_FRMSIZE_WIDTH ),
+ M_E_SE( STYLE, rel_width, RES_FRM_SIZE, MID_FRMSIZE_REL_WIDTH ),
+ // RES_PAPER_BIN
+ // not required
+ // TODO: RES_LR_SPACE
+ M_E_SE( FO, margin_left, RES_LR_SPACE, MID_L_MARGIN ),
+ M_E_SE( FO, margin_right, RES_LR_SPACE, MID_R_MARGIN ),
+ // RES_UL_SPACE
+ M_E( FO, margin_top, RES_UL_SPACE, MID_UP_MARGIN ),
+ M_E( FO, margin_bottom, RES_UL_SPACE, MID_LO_MARGIN ),
+ // RES_PAGEDESC
+ // TODO
+ // RES_BREAK
+ M_E( FO, break_before, RES_BREAK, MID_BREAK_BEFORE ),
+ M_E( FO, break_after, RES_BREAK, MID_BREAK_AFTER ),
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ // not required
+ // RES_HORI_ORIENT
+ M_E( TABLE, align, RES_HORI_ORIENT, 0 ),
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ // not required
+ // RES_SHADOW
+ M_E( STYLE, shadow, RES_SHADOW, 0 ),
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ M_E( FO, keep_with_next, RES_KEEP, 0 ),
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ M_E( STYLE, may_break_between_rows, RES_LAYOUT_SPLIT, 0 ),
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // not required
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+
+SvXMLItemMapEntry aXMLTableColItemMap[] =
+{
+ M_E_SI( STYLE, column_width, RES_FRM_SIZE, MID_FRMSIZE_COL_WIDTH ),
+ M_E( STYLE, rel_column_width, RES_FRM_SIZE, MID_FRMSIZE_REL_COL_WIDTH ),
+ {0,0,0,0 }
+};
+
+SvXMLItemMapEntry aXMLTableRowItemMap[] =
+{
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ M_E( STYLE, row_height, RES_FRM_SIZE, MID_FRMSIZE_FIX_HEIGHT ),
+ M_E( STYLE, min_row_height, RES_FRM_SIZE, MID_FRMSIZE_MIN_HEIGHT ),
+ // RES_PAPER_BIN
+ // not required
+ // RES_LR_SPACE
+ // not required
+ // RES_UL_SPACE
+ // not required
+ // RES_PAGEDESC
+ // not required
+ // RES_BREAK
+ // not required
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ // not required
+ // RES_HORI_ORIENT
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_SHADOW
+ // not required
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ // not required
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ // not required
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // not required
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+
+SvXMLItemMapEntry aXMLTableCellItemMap[] =
+{
+ // RES_FILL_ORDER
+ // not required
+ // RES_FRM_SIZE
+ // not required
+ // RES_PAPER_BIN
+ // not required
+ // RES_LR_SPACE
+ // not required
+ // RES_UL_SPACE
+ // not required
+ // RES_PAGEDESC
+ // not required
+ // RES_BREAK
+ // not required
+ // RES_CNTNT
+ // not required
+ // RES_HEADER
+ // not required
+ // RES_FOOTER
+ // not required
+ // RES_PRINT
+ // not required
+ // RES_OPAQUE
+ // not required
+ // RES_PROTECT
+ // not required
+ // RES_SURROUND
+ // not required
+ // RES_VERT_ORIENT
+ M_E( TABLE, vertical_align, RES_VERT_ORIENT, 0 ),
+ // RES_HORI_ORIENT
+ // not required
+ // RES_ANCHOR
+ // not required
+ // RES_BACKGROUND
+ M_E( FO, background_color, RES_BACKGROUND, MID_BACK_COLOR ),
+ M_E( STYLE, background_image, RES_BACKGROUND, MID_FLAG_ELEMENT_ITEM ),
+ // RES_BOX
+ M_E( STYLE, border_line_width, RES_BOX, ALL_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_left, RES_BOX, LEFT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_right, RES_BOX, RIGHT_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_top, RES_BOX, TOP_BORDER_LINE_WIDTH ),
+ M_E( STYLE, border_line_width_bottom, RES_BOX, BOTTOM_BORDER_LINE_WIDTH ),
+ M_E( FO, padding, RES_BOX, ALL_BORDER_PADDING ),
+ M_E( FO, padding_left, RES_BOX, LEFT_BORDER_PADDING ),
+ M_E( FO, padding_right, RES_BOX, RIGHT_BORDER_PADDING ),
+ M_E( FO, padding_top, RES_BOX, TOP_BORDER_PADDING ),
+ M_E( FO, padding_bottom, RES_BOX, BOTTOM_BORDER_PADDING ),
+ M_E( FO, border, RES_BOX, ALL_BORDER ),
+ M_E( FO, border_left, RES_BOX, LEFT_BORDER ),
+ M_E( FO, border_right, RES_BOX, RIGHT_BORDER ),
+ M_E( FO, border_top, RES_BOX, TOP_BORDER ),
+ M_E( FO, border_bottom, RES_BOX, BOTTOM_BORDER ),
+ // RES_SHADOW
+ // not required
+ // RES_FRMMACRO
+ // not required
+ // RES_COL
+ // not required
+ // RES_KEEP
+ // not required
+ // RES_URL
+ // not required
+ // RES_EDIT_IN_READONLY
+ // not required
+ // RES_LAYOUT_SPLIT
+ // not required
+ // RES_CHAIN
+ // not required
+ // RES_LINENUMBER
+ // not required
+ // RES_FTN_AT_TXTEND
+ // not required
+ // RES_END_AT_TXTEND
+ // not required
+ // RES_UNKNOWNATR_CONTAINER
+ M_E_SE( TEXT, xmlns, RES_UNKNOWNATR_CONTAINER, 0 ),
+ {0,0,0,0 }
+};
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlitemm.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.8 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.7 2000/08/24 11:16:41 mib
+ text import continued
+
+ Revision 1.6 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.5 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.4 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.3 2000/02/07 10:03:28 mib
+ #70271#: tables
+
+ Revision 1.2 2000/01/12 15:00:23 mib
+ #70271#: lists
+
+ Revision 1.1 1999/12/14 07:33:08 mib
+ #70271#: XML import/export of drop cap/register/language item, splitted swxmlat
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx
new file mode 100644
index 000000000000..9ea50332e4f9
--- /dev/null
+++ b/sw/source/filter/xml/xmlmeta.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlmeta.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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
+
+#include <hintids.hxx>
+
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTINFOSUPPLIER_HPP_
+#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLMETAI_HXX
+#include <xmloff/xmlmetai.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLMETAE_HXX
+#include <xmloff/xmlmetae.hxx>
+#endif
+
+#ifndef _SVX_LANGITEM_HXX
+#include <svx/langitem.hxx>
+#endif
+
+#ifndef _SWDOCSH_HXX
+#include "docsh.hxx"
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+// ---------------------------------------------------------------------
+
+#if 0
+class SwXMLMetaContext_Impl : public SfxXMLMetaContext
+{
+public:
+ SwXMLMetaContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< document::XDocumentInfo > & rInfo ) :
+ SfxXMLMetaContext( rImport, nPrfx, rLName, rInfo )
+ {}
+
+ virtual void SetDocLanguage( LanguageType eLang );
+};
+
+void SwXMLMetaContext_Impl::SetDocLanguage( LanguageType eLang )
+{
+ SwDoc& rDoc = ((SwXMLImport&)GetImport()).GetDoc();
+
+ rDoc.SetDefault( SvxLanguageItem( eLang, RES_CHRATR_LANGUAGE ) );
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+SvXMLImportContext *SwXMLImport::CreateMetaContext(
+ const OUString& rLocalName )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( !(IsStylesOnlyMode() || IsInsertMode()) )
+ {
+ pContext = new SfxXMLMetaContext( *this,
+ XML_NAMESPACE_OFFICE, rLocalName,
+ GetModel() );
+#if 0
+ SfxObjectShell* pObjSh = pDoc->GetDocShell();
+ if( pObjSh )
+ {
+ Reference< frame::XModel > xModel = pObjSh->GetBaseModel();
+ Reference< document::XDocumentInfoSupplier > xSupp( xModel,
+ UNO_QUERY );
+ if( xSupp.is() )
+ pContext = new SwXMLMetaContext_Impl( *this,
+ XML_NAMESPACE_OFFICE, rLocalName,
+ xSupp->getDocumentInfo() );
+ }
+#endif
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE,
+ rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+#if 0
+void SwXMLExport::_ExportMeta()
+{
+ SfxObjectShell* pObjSh = pDoc->GetDocShell();
+ if( pObjSh )
+ {
+ pObjSh->UpdateDocInfoForSave(); // update information
+
+ LanguageType eDocLang = ((const SvxLanguageItem&)
+ pDoc->GetDefault(RES_CHRATR_LANGUAGE)).GetLanguage();
+
+ Reference< frame::XModel > xModel = pObjSh->GetBaseModel();
+ Reference< document::XDocumentInfoSupplier > xSupp( xModel,
+ UNO_QUERY );
+ if( xSupp.is() )
+ {
+ SfxXMLMetaExport aMeta( GetDocHandler(), xSupp->getDocumentInfo(),
+ eDocLang );
+ aMeta.Export( GetNamespaceMap() );
+ }
+ }
+}
+#endif
+
+
+/*************************************************************************
+
+ Source Code Control chaos::System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmlmeta.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control chaos::System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.7 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.6 2000/08/02 14:52:39 mib
+ text export continued
+
+ Revision 1.5 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.4 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.3 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.2 2000/02/11 14:42:04 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.1 2000/01/06 15:03:49 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
new file mode 100644
index 000000000000..7f33e1b6ad98
--- /dev/null
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -0,0 +1,1085 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltble.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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
+
+#include <hintids.hxx>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_TEXT_XTEXTTABLE_HPP_
+#include <com/sun/star/text/XTextTable.hpp>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include <xmloff/xmluconv.hxx>
+#endif
+
+#ifndef _CNTRSRT_HXX
+#include <svtools/cntnrsrt.hxx>
+#endif
+
+#ifndef _SVX_BRSHITEM_HXX
+#include <svx/brshitem.hxx>
+#endif
+#ifndef _SVX_BOXITEM_HXX
+#include <svx/boxitem.hxx>
+#endif
+
+#ifndef _SWTABLE_HXX
+#include "swtable.hxx"
+#endif
+#ifndef _DOC_HXX
+#include "doc.hxx"
+#endif
+#ifndef _PAM_HXX
+#include "pam.hxx"
+#endif
+#ifndef _FRMFMT_HXX
+#include "frmfmt.hxx"
+#endif
+#ifndef _WRTSWTBL_HXX
+#include "wrtswtbl.hxx"
+#endif
+#ifndef _FMTFSIZE_HXX
+#include "fmtfsize.hxx"
+#endif
+#ifndef _FMTORNT_HXX
+#include "fmtornt.hxx"
+#endif
+
+#ifndef _UNOOBJ_HXX
+#include "unoobj.hxx"
+#endif
+#ifndef _UNOTBL_HXX
+#include "unotbl.hxx"
+#endif
+
+#ifndef _XMLTEXTE_HXX
+#include "xmltexte.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+#ifndef _XMLECTXT_HXX
+#include "xmlectxt.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+#ifndef XML_CORE_API
+Reference < XText > lcl_xml_CreateTableBoxText(
+ const SwStartNode& rBoxSttNd )
+{
+ SwPaM aPaM( *rBoxSttNd.EndOfSectionNode() );
+ aPaM.Move( fnMoveBackward, fnGoNode );
+ aPaM.SetMark();
+ aPaM.GetPoint()->nNode.Assign( rBoxSttNd );
+ aPaM.Move( fnMoveForward, fnGoNode );
+
+ Reference < XTextRange > xTextRange =
+ CreateTextRangeFromPosition( aPaM.GetDoc(), *aPaM.GetPoint(),
+ aPaM.GetMark() );
+ return xTextRange->getText();
+}
+#endif
+
+class SwXMLTableColumn_Impl : public SwWriteTableCol
+{
+ OUString sStyleName;
+ sal_uInt32 nRelWidth;
+
+public:
+
+
+ SwXMLTableColumn_Impl( sal_uInt16 nPosition ) :
+ SwWriteTableCol( nPosition ),
+ nRelWidth( 0UL )
+ {};
+
+ void SetStyleName( const OUString& rName ) { sStyleName = rName; }
+ const OUString& GetStyleName() const { return sStyleName; }
+
+ void SetRelWidth( sal_uInt32 nSet ) { nRelWidth = nSet; }
+ sal_uInt32 GetRelWidth() const { return nRelWidth; }
+};
+
+sal_Int32 SwXMLTableColumnCmpWidth_Impl( const SwXMLTableColumn_Impl& r1,
+ const SwXMLTableColumn_Impl& r2 )
+{
+ sal_Int32 n = (sal_Int32)r1.GetWidthOpt() - (sal_Int32)r2.GetWidthOpt();
+ if( !n )
+ n = (sal_Int32)r1.GetRelWidth() - (sal_Int32)r2.GetRelWidth();
+ return n;
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLTableColumn_Impl *SwXMLTableColumnPtr;
+SV_DECL_PTRARR_SORT_DEL( SwXMLTableColumns_Impl, SwXMLTableColumnPtr, 5, 5 )
+SV_IMPL_OP_PTRARR_SORT( SwXMLTableColumns_Impl, SwXMLTableColumnPtr )
+
+DECLARE_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl,
+ SwXMLTableColumn_Impl )
+IMPL_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl, SwXMLTableColumn_Impl,
+ SwXMLTableColumnCmpWidth_Impl )
+
+class SwXMLTableLines_Impl
+{
+ SwXMLTableColumns_Impl aCols;
+ const SwTableLines *pLines;
+ sal_uInt32 nWidth;
+
+public:
+
+ SwXMLTableLines_Impl( const SwTableLines& rLines );
+
+ ~SwXMLTableLines_Impl() {}
+
+ sal_uInt32 GetWidth() const { return nWidth; }
+ const SwTableLines *GetLines() const { return pLines; }
+
+ const SwXMLTableColumns_Impl& GetColumns() const { return aCols; }
+};
+
+SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
+ pLines( &rLines ),
+ nWidth( 0UL )
+{
+#ifndef PRODUCT
+ sal_uInt16 nEndCPos = 0U;
+#endif
+ sal_uInt16 nLines = rLines.Count();
+ sal_uInt16 nLine;
+ for( nLine=0U; nLine<nLines; nLine++ )
+ {
+ const SwTableLine *pLine = rLines[nLine];
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ sal_uInt16 nBoxes = rBoxes.Count();
+
+ sal_uInt16 nCPos = 0U;
+ for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ sal_uInt16 nOldCPos = nCPos;
+
+ if( nBox < nBoxes-1U || nWidth==0UL )
+ {
+ nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ SwXMLTableColumn_Impl *pCol =
+ new SwXMLTableColumn_Impl( nCPos );
+
+ if( !aCols.Insert( pCol ) )
+ delete pCol;
+
+ if( nBox==nBoxes-1U )
+ {
+ ASSERT( nLine==0U && nWidth==0UL,
+ "parent width will be lost" );
+ nWidth = nCPos;
+ }
+ }
+ else
+ {
+#ifndef PRODUCT
+ sal_uInt16 nCheckPos =
+ nCPos + (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ if( !nEndCPos )
+ {
+ nEndCPos = nCheckPos;
+ }
+ else
+ {
+ /*
+ ASSERT( SwXMLTableColumn_impl(nCheckPos) ==
+ SwXMLTableColumn_Impl(nEndCPos),
+ "rows have different total widths" );
+ */
+ }
+#endif
+ nCPos = nWidth;
+#ifndef PRODUCT
+ SwXMLTableColumn_Impl aCol( nWidth );
+ ASSERT( aCols.Seek_Entry(&aCol), "couldn't find last column" );
+ ASSERT( SwXMLTableColumn_Impl(nCheckPos) ==
+ SwXMLTableColumn_Impl(nCPos),
+ "rows have different total widths" );
+#endif
+ }
+ }
+ }
+}
+
+typedef SwXMLTableLines_Impl *SwXMLTableLinesPtr;
+DECLARE_LIST( SwXMLTableLinesCache_Impl, SwXMLTableLinesPtr )
+
+// ---------------------------------------------------------------------
+
+typedef SwFrmFmt *SwFrmFmtPtr;
+DECLARE_LIST( SwXMLFrmFmts_Impl, SwFrmFmtPtr )
+
+class SwXMLTableFrmFmtsSort_Impl : public SwXMLFrmFmts_Impl
+{
+public:
+ SwXMLTableFrmFmtsSort_Impl ( sal_uInt16 nInit, sal_uInt16 nGrow ) :
+ SwXMLFrmFmts_Impl( nInit, nGrow )
+ {}
+
+ sal_Bool AddRow( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix, sal_uInt32 nLine );
+ sal_Bool AddCell( SwFrmFmt& rFrmFmt, const OUString& rNamePrefix,
+ sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop );
+};
+
+sal_Bool SwXMLTableFrmFmtsSort_Impl::AddRow( SwFrmFmt& rFrmFmt,
+ const OUString& rNamePrefix,
+ sal_uInt32 nLine )
+{
+ const SwFmtFrmSize *pFrmSize = 0;
+ const SvxBrushItem *pBrush = 0;
+
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_FRM_SIZE, sal_False, &pItem ) )
+ pFrmSize = (const SwFmtFrmSize *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
+ pBrush = (const SvxBrushItem *)pItem;
+
+ // empty styles have not to be exported
+ if( !pFrmSize && !pBrush )
+ return sal_False;
+
+ // order is: -/brush, size/-, size/brush
+ sal_uInt32 nCount = Count();
+ sal_Bool bInsert = sal_True;
+ sal_uInt32 i;
+ for( i=0; i<nCount; i++ )
+ {
+ const SwFmtFrmSize *pTestFrmSize = 0;
+ const SvxBrushItem *pTestBrush = 0;
+ const SwFrmFmt *pTestFmt = GetObject(i);
+ const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_FRM_SIZE, sal_False,
+ &pItem ) )
+ {
+ if( !pFrmSize )
+ break;
+
+ pTestFrmSize = (const SwFmtFrmSize *)pItem;
+ }
+ else
+ {
+ if( pFrmSize )
+ continue;
+ }
+
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ if( !pBrush )
+ break;
+
+ pTestBrush = (const SvxBrushItem *)pItem;
+ }
+ else
+ {
+ if( pBrush )
+ continue;
+ }
+
+ if( pFrmSize &&
+ ( pFrmSize->GetSizeType() != pTestFrmSize->GetSizeType() ||
+ pFrmSize->GetHeight() != pTestFrmSize->GetHeight() ) )
+ continue;
+
+ if( pBrush && !pBrush->equalsXML( *pTestBrush ) )
+ continue;
+
+ // found!
+ const String& rFmtName = pTestFmt->GetName();
+ rFrmFmt.SetName( rFmtName );
+ bInsert = sal_False;
+ break;
+ }
+
+ if( bInsert )
+ {
+ OUStringBuffer sBuffer( rNamePrefix.getLength() + 4UL );
+ sBuffer.append( rNamePrefix );
+ sBuffer.append( (sal_Unicode)'.' );
+ sBuffer.append( (sal_Int32)(nLine+1UL) );
+
+ rFrmFmt.SetName( sBuffer.makeStringAndClear() );
+ Insert( &rFrmFmt, i );
+ }
+
+ return bInsert;
+}
+
+void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm );
+void lcl_xmltble_appendBoxPrefix( OUStringBuffer& rBuffer,
+ const OUString& rNamePrefix,
+ sal_uInt16 nCol, sal_uInt16 nRow, sal_Bool bTop )
+{
+ rBuffer.append( rNamePrefix );
+ rBuffer.append( (sal_Unicode)'.' );
+ if( bTop )
+ {
+ String sTmp;
+ lcl_GetTblBoxColStr( nCol, sTmp );
+ rBuffer.append( sTmp );
+ }
+ else
+ {
+ rBuffer.append( (sal_Int32)(nCol + 1));
+ rBuffer.append( (sal_Unicode)'.' );
+ }
+ rBuffer.append( (sal_Int32)(nRow + 1));
+}
+
+sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt,
+ const OUString& rNamePrefix,
+ sal_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop )
+{
+ const SwFmtVertOrient *pVertOrient = 0;
+ const SvxBrushItem *pBrush = 0;
+ const SvxBoxItem *pBox = 0;
+
+ const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, sal_False,
+ &pItem ) )
+ pVertOrient = (const SwFmtVertOrient *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
+ pBrush = (const SvxBrushItem *)pItem;
+
+ if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ pBox = (const SvxBoxItem *)pItem;
+
+ // empty styles have not to be exported
+ if( !pVertOrient && !pBrush && !pBox )
+ return sal_False;
+
+ // order is: -/-/box, -/brush/-, -/brush/box,
+ // vert/-/-, vert/-/box, vert/brush/-, vert/brush/box
+ sal_uInt32 nCount = Count();
+ sal_Bool bInsert = sal_True;
+ sal_uInt32 i;
+ for( i=0; i<nCount; i++ )
+ {
+ const SwFmtVertOrient *pTestVertOrient = 0;
+ const SvxBrushItem *pTestBrush = 0;
+ const SvxBoxItem *pTestBox = 0;
+ const SwFrmFmt *pTestFmt = GetObject(i);
+ const SfxItemSet& rTestSet = pTestFmt->GetAttrSet();
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_VERT_ORIENT, sal_False,
+ &pItem ) )
+ {
+ if( !pVertOrient )
+ break;
+
+ pTestVertOrient = (const SwFmtVertOrient *)pItem;
+ }
+ else
+ {
+ if( pVertOrient )
+ continue;
+ }
+
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BACKGROUND, sal_False,
+ &pItem ) )
+ {
+ if( !pBrush )
+ break;
+
+ pTestBrush = (const SvxBrushItem *)pItem;
+ }
+ else
+ {
+ if( pBrush )
+ continue;
+ }
+
+ if( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOX, sal_False, &pItem ) )
+ {
+ if( !pBox )
+ break;
+
+ pTestBox = (const SvxBoxItem *)pItem;
+ }
+ else
+ {
+ if( pBox )
+ continue;
+ }
+
+ if( pVertOrient &&
+ pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() )
+ continue;
+
+ if( pBrush && !pBrush->equalsXML( *pTestBrush ) )
+ continue;
+
+ if( pBox && !pBox->equalsXML( *pTestBox ) )
+ continue;
+
+ // found!
+ const String& rFmtName = pTestFmt->GetName();
+ rFrmFmt.SetName( rFmtName );
+ bInsert = sal_False;
+ break;
+ }
+
+ if( bInsert )
+ {
+ OUStringBuffer sBuffer( rNamePrefix.getLength() + 8UL );
+ lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nCol, nRow, bTop );
+ rFrmFmt.SetName( sBuffer.makeStringAndClear() );
+ Insert( &rFrmFmt, i );
+ }
+
+ return bInsert;
+}
+// ---------------------------------------------------------------------
+
+
+void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol )
+{
+ // <style:style ...>
+ CheckAttrList();
+
+ // style:name="..."
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_name, rCol.GetStyleName() );
+
+ // style:family="table-column"
+ AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_family, sXML_table_column );
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, sXML_style, sal_True,
+ sal_True );
+ OUStringBuffer sValue;
+ if( rCol.GetWidthOpt() )
+ {
+ GetTwipUnitConverter().convertMeasure( sValue, rCol.GetWidthOpt() );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_column_width,
+ sValue.makeStringAndClear() );
+ }
+ if( rCol.GetRelWidth() )
+ {
+ sValue.append( (sal_Int32)rCol.GetRelWidth() );
+ sValue.append( (sal_Unicode)'*' );
+ AddAttribute( XML_NAMESPACE_STYLE, sXML_rel_column_width,
+ sValue.makeStringAndClear() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE,
+ sXML_properties, sal_True, sal_True );
+ }
+ }
+}
+
+void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
+ sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
+ const OUString& rNamePrefix,
+ SwXMLTableColumnsSortByWidth_Impl& rExpCols,
+ SwXMLTableFrmFmtsSort_Impl& rExpRows,
+ SwXMLTableFrmFmtsSort_Impl& rExpCells,
+ sal_Bool bTop )
+{
+ // pass 1: calculate columns
+ SwXMLTableLines_Impl *pLines =
+ new SwXMLTableLines_Impl( rLines );
+ if( !pTableLines )
+ pTableLines = new SwXMLTableLinesCache_Impl( 5, 5 );
+ pTableLines->Insert( pLines, pTableLines->Count() );
+
+ OUStringBuffer sBuffer( rNamePrefix.getLength() + 8L );
+
+ // pass 2: export column styles
+ {
+ const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
+ sal_uInt16 nCPos = 0U;
+ sal_uInt16 nColumns = rCols.Count();
+ for( sal_uInt16 nColumn=0U; nColumn<nColumns; nColumn++ )
+ {
+ SwXMLTableColumn_Impl *pColumn = rCols[nColumn];
+
+ sal_uInt16 nOldCPos = nCPos;
+ nCPos = pColumn->GetPos();
+
+ sal_uInt32 nWidth = nCPos - nOldCPos;
+
+ // If a base width is given, the table has either an automatic
+ // or margin alignment, or an percentage width. In either case,
+ // relative widths should be exported.
+ if( nBaseWidth )
+ {
+ pColumn->SetRelWidth( nWidth );
+ }
+
+ // If an absolute width is given, the table either has a fixed
+ // width, or the current width is known from the layout. In the
+ // later case, a base width is set in addition and must be used
+ // to "absoultize" the relative column width.
+ if( nAbsWidth )
+ {
+ sal_uInt32 nColAbsWidth = nWidth;
+ if( nBaseWidth )
+ {
+ nColAbsWidth *= nAbsWidth;
+ nColAbsWidth += (nBaseWidth/2UL);
+ nColAbsWidth /= nBaseWidth;
+ }
+ pColumn->SetWidthOpt( nColAbsWidth, sal_False );
+ }
+
+ sal_uInt32 nExpPos = 0;
+ if( rExpCols.Seek_Entry( pColumn, &nExpPos ) )
+ {
+ pColumn->SetStyleName(
+ rExpCols.GetObject(nExpPos)->GetStyleName() );
+ }
+ else
+ {
+ sBuffer.append( rNamePrefix );
+ sBuffer.append( (sal_Unicode)'.' );
+ if( bTop )
+ {
+ String sTmp;
+ lcl_GetTblBoxColStr( nColumn, sTmp );
+ sBuffer.append( sTmp );
+ }
+ else
+ {
+ sBuffer.append( (sal_Int32)(nColumn + 1U) );
+ }
+
+ pColumn->SetStyleName( sBuffer.makeStringAndClear() );
+ ExportTableColumnStyle( *pColumn );
+ rExpCols.Insert( pColumn );
+ }
+ }
+ }
+
+ // pass 3: export line/rows
+ sal_uInt16 nLines = rLines.Count();
+ for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
+ {
+ SwTableLine *pLine = rLines[nLine];
+
+ SwFrmFmt *pFrmFmt = pLine->GetFrmFmt();
+ if( rExpRows.AddRow( *pFrmFmt, rNamePrefix, nLine ) )
+ ExportFmt( *pFrmFmt, sXML_table_row );
+
+ const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ sal_uInt16 nBoxes = rBoxes.Count();
+
+ sal_uInt16 nCPos = 0U;
+ sal_uInt16 nCol = 0U;
+ for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ sal_uInt16 nOldCPos = nCPos;
+ if( nBox < nBoxes-1U )
+ nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ else
+ nCPos = pLines->GetWidth();
+
+
+ // Und ihren Index
+ sal_uInt16 nOldCol = nCol;
+ SwXMLTableColumn_Impl aCol( nCPos );
+ sal_Bool bFound = pLines->GetColumns().Seek_Entry( &aCol, &nCol );
+ ASSERT( bFound, "couldn't find column" );
+
+ const SwStartNode *pBoxSttNd = pBox->GetSttNd();
+ if( pBoxSttNd )
+ {
+#ifdef XML_CORE_API
+ SwNode *pStartNd = pDoc->GetNodes()[pBoxSttNd->GetIndex()+1];
+ SwNode *pEndNd =
+ pDoc->GetNodes()[pBoxSttNd->EndOfSectionIndex()-1];
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd,
+ 0, STRING_LEN );
+#endif
+
+ SwFrmFmt *pFrmFmt = pBox->GetFrmFmt();
+ if( rExpCells.AddCell( *pFrmFmt, rNamePrefix, nOldCol, nLine,
+ bTop) )
+ ExportFmt( *pFrmFmt, sXML_table_cell );
+
+#ifdef XML_CORE_API
+ ExportCurPaMAutoStyles();
+#else
+ GetTextParagraphExport()->collectTextAutoStyles(
+ lcl_xml_CreateTableBoxText( *pBoxSttNd ) );
+#endif
+ }
+ else
+ {
+ lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nOldCol,
+ nLine, bTop );
+
+ ExportTableLinesAutoStyles( pBox->GetTabLines(),
+ nAbsWidth, nBaseWidth,
+ sBuffer.makeStringAndClear(),
+ rExpCols, rExpRows, rExpCells );
+ }
+
+ nCol++;
+ }
+ }
+}
+
+void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
+{
+ const SwTable& rTbl = rTblNd.GetTable();
+ const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
+
+ if( pTblFmt )
+ {
+ SwHoriOrient eTabHoriOri = pTblFmt->GetHoriOrient().GetHoriOrient();
+ const SwFmtFrmSize& rFrmSize = pTblFmt->GetFrmSize();
+
+ sal_uInt32 nAbsWidth = rFrmSize.GetSize().Width();
+ sal_uInt32 nBaseWidth = 0UL;
+ sal_Int8 nPrcWidth = rFrmSize.GetWidthPercent();
+
+ sal_Bool bFixAbsWidth = nPrcWidth != 0 || HORI_NONE == eTabHoriOri
+ || HORI_FULL == eTabHoriOri;
+ if( bFixAbsWidth )
+ {
+ nBaseWidth = nAbsWidth;
+ nAbsWidth = pTblFmt->FindLayoutRect(sal_True).Width();
+ if( !nAbsWidth )
+ {
+ // TODO???
+ }
+ }
+ ExportTableFmt( *pTblFmt, nAbsWidth );
+
+ OUString sName( pTblFmt->GetName() );
+ SwXMLTableColumnsSortByWidth_Impl aExpCols( 10, 10 );
+ SwXMLTableFrmFmtsSort_Impl aExpRows( 10, 10 );
+ SwXMLTableFrmFmtsSort_Impl aExpCells( 10, 10 );
+ ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
+ sName, aExpCols, aExpRows, aExpCells,
+ sal_True );
+ }
+
+#ifdef XML_CORE_API
+ pCurPaM->GetPoint()->nNode = *rTblNd.EndOfSectionNode();
+#endif
+}
+
+// ---------------------------------------------------------------------
+
+void SwXMLExport::ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan )
+{
+ const SwStartNode *pBoxSttNd = rBox.GetSttNd();
+ if( pBoxSttNd )
+ {
+ const SwFrmFmt *pFrmFmt = rBox.GetFrmFmt();
+ if( pFrmFmt )
+ {
+ const String& rName = pFrmFmt->GetName();
+ if( rName.Len() )
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name, rName );
+ }
+ }
+ }
+
+ if( nColSpan != 1 )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( (sal_Int32)nColSpan );
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_number_columns_spanned,
+ sTmp.makeStringAndClear() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_cell, sal_True, sal_True );
+ if( pBoxSttNd )
+ {
+#ifdef XML_CORE_API
+ SwNode *pStartNd = pDoc->GetNodes()[pBoxSttNd->GetIndex()+1];
+ SwNode *pEndNd = pDoc->GetNodes()[pBoxSttNd->EndOfSectionIndex()-1];
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd,
+ 0, STRING_LEN );
+ ExportCurPaM();
+#else
+ GetTextParagraphExport()->exportText(
+ lcl_xml_CreateTableBoxText( *pBoxSttNd ) );
+#endif
+ }
+ else
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_sub_table, sal_True, sal_True );
+ ExportTableLines( rBox.GetTabLines() );
+ }
+ }
+}
+
+void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
+ const SwXMLTableLines_Impl& rLines )
+{
+ const SwFrmFmt *pFrmFmt = rLine.GetFrmFmt();
+ if( pFrmFmt )
+ {
+ const String& rName = pFrmFmt->GetName();
+ if( rName.Len() )
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name, rName );
+ }
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_row, sal_True, sal_True );
+ const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
+ sal_uInt16 nBoxes = rBoxes.Count();
+
+ sal_uInt16 nCPos = 0U;
+ sal_uInt16 nCol = 0U;
+ for( sal_uInt16 nBox=0U; nBox<nBoxes; nBox++ )
+ {
+ const SwTableBox *pBox = rBoxes[nBox];
+
+ sal_uInt16 nOldCPos = nCPos;
+ if( nBox < nBoxes-1U )
+ nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox );
+ else
+ nCPos = rLines.GetWidth();
+
+ // Und ihren Index
+ sal_uInt16 nOldCol = nCol;
+ SwXMLTableColumn_Impl aCol( nCPos );
+ sal_Bool bFound = rLines.GetColumns().Seek_Entry( &aCol, &nCol );
+ ASSERT( bFound, "couldn't find column" );
+
+ sal_uInt16 nColSpan = nCol - nOldCol + 1U;
+ ExportTableBox( *pBox, nColSpan );
+ for( sal_uInt16 i=nOldCol; i<nCol; i++ )
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_covered_table_cell, sal_True,
+ sal_False );
+ }
+
+ nCol++;
+ }
+ }
+}
+
+void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
+ sal_Bool bHeadline )
+{
+ ASSERT( pTableLines && pTableLines->Count(),
+ "SwXMLExport::ExportTableLines: table columns infos missing" );
+ if( !pTableLines || 0 == pTableLines->Count() )
+ return;
+
+ SwXMLTableLines_Impl *pLines = 0;
+ sal_uInt16 nInfoPos;
+ for( nInfoPos=0; nInfoPos < pTableLines->Count(); nInfoPos++ )
+ {
+ if( pTableLines->GetObject( nInfoPos )->GetLines() == &rLines )
+ {
+ pLines = pTableLines->GetObject( nInfoPos );
+ break;
+ }
+ }
+ ASSERT( pLines,
+ "SwXMLExport::ExportTableLines: table columns info missing" );
+ ASSERT( 0==nInfoPos,
+ "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
+ if( !pLines )
+ return;
+
+ // pass 2: export columns
+ const SwXMLTableColumns_Impl& rCols = pLines->GetColumns();
+ sal_uInt16 nColumn = 0U;
+ sal_uInt16 nColumns = rCols.Count();
+ sal_uInt16 nColRep = 1U;
+ SwXMLTableColumn_Impl *pColumn = (nColumns > 0) ? rCols[0U] : 0;
+ while( pColumn )
+ {
+ nColumn++;
+ SwXMLTableColumn_Impl *pNextColumn =
+ (nColumn < nColumns) ? rCols[nColumn] : 0;
+ if( pNextColumn &&
+ pNextColumn->GetStyleName() == pColumn->GetStyleName() )
+ {
+ nColRep++;
+ }
+ else
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name,
+ pColumn->GetStyleName() );
+
+ if( nColRep > 1U )
+ {
+ OUStringBuffer sTmp(4);
+ sTmp.append( (sal_Int32)nColRep );
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_number_columns_repeated,
+ sTmp.makeStringAndClear() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_column, sal_True, sal_True );
+ }
+
+ nColRep = 1U;
+ }
+ pColumn = pNextColumn;
+ }
+
+ // pass 3: export line/rows
+ sal_uInt16 nLines = rLines.Count();
+ for( sal_uInt16 nLine=0U; nLine<nLines; nLine++ )
+ {
+ const SwTableLine *pLine = rLines[nLine];
+ if( bHeadline && 0U==nLine )
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+ sXML_table_header_rows, sal_True, sal_True );
+ ExportTableLine( *pLine, *pLines );
+ }
+ else
+ {
+ ExportTableLine( *pLine, *pLines );
+ }
+ }
+
+ pTableLines->Remove( nInfoPos );
+ if( 0 == pTableLines->Count() )
+ {
+ delete pTableLines ;
+ pTableLines = 0;
+ }
+ delete pLines;
+}
+
+sal_Bool lcl_xmltble_ClearName_Line( const SwTableLine*& rpLine, void* );
+
+sal_Bool lcl_xmltble_ClearName_Box( const SwTableBox*& rpBox, void* )
+{
+ if( !rpBox->GetSttNd() )
+ {
+ ((SwTableBox *)rpBox)->GetTabLines().ForEach(
+ &lcl_xmltble_ClearName_Line, 0 );
+ }
+ else
+ {
+ SwFrmFmt *pFrmFmt = ((SwTableBox *)rpBox)->GetFrmFmt();
+ if( pFrmFmt && pFrmFmt->GetName().Len() )
+ pFrmFmt->SetName( aEmptyStr );
+ }
+
+ return sal_True;
+}
+
+sal_Bool lcl_xmltble_ClearName_Line( const SwTableLine*& rpLine, void* )
+{
+ ((SwTableLine *)rpLine)->GetTabBoxes().ForEach(
+ &lcl_xmltble_ClearName_Box, 0 );
+
+ return sal_True;
+}
+
+void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
+{
+ const SwTable& rTbl = rTblNd.GetTable();
+ const SwFrmFmt *pTblFmt = rTbl.GetFrmFmt();
+ if( pTblFmt && pTblFmt->GetName().Len() )
+ {
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_name, pTblFmt->GetName() );
+ AddAttribute( XML_NAMESPACE_TABLE, sXML_style_name,
+ pTblFmt->GetName() );
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, sXML_table,
+ sal_True, sal_True );
+ ExportTableLines( rTbl.GetTabLines(), rTbl.IsHeadlineRepeat() );
+
+ ((SwTable &)rTbl).GetTabLines().ForEach( &lcl_xmltble_ClearName_Line,
+ 0 );
+ }
+
+#ifdef XML_CORE_API
+ pCurPaM->GetPoint()->nNode = *rTblNd.EndOfSectionNode();
+#endif
+}
+
+#ifndef XML_CORE_API
+void SwXMLTextParagraphExport::exportTable(
+ const Reference < XTextContent > & rTextContent,
+ sal_Bool bAutoStyles )
+{
+// Reference < XPropertySet > xPropSet( rTextContent, UNO_QUERY );
+// Any aAny = xPropSet->getPropertyValue( sTextTable );
+
+ Reference < XTextTable > xTxtTbl( rTextContent, UNO_QUERY );
+// aAny >>= xTxtTbl;
+ DBG_ASSERT( xTxtTbl.is(), "text table missing" );
+ if( xTxtTbl.is() )
+ {
+ const SwXTextTable *pXTable = 0;
+ Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
+ if( xTableTunnel.is() )
+ {
+ pXTable = (SwXTextTable*)xTableTunnel->getSomething(
+ SwXTextTable::getUnoTunnelId() );
+ ASSERT( pXTable, "SwXTextTable missing" );
+ }
+ if( pXTable )
+ {
+ SwFrmFmt *pFmt = pXTable->GetFrmFmt();
+ ASSERT( pFmt, "table format missing" );
+ const SwTable *pTbl = SwTable::FindTable( pFmt );
+ ASSERT( pTbl, "table missing" );
+ const SwTableNode *pTblNd = pTbl->GetTableNode();
+ ASSERT( pTblNd, "table node missing" );
+ if( bAutoStyles )
+ {
+ ((SwXMLExport&)GetExport()).ExportTableAutoStyles( *pTblNd );
+ }
+ else
+ {
+ ((SwXMLExport&)GetExport()).ExportTable( *pTblNd );
+ }
+ }
+ }
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltble.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/09/05 09:51:10 mib
+ #78063#: table lines cache is sorted now
+
+ Revision 1.9 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.8 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.7 2000/06/08 09:45:54 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.6 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.5 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.4 2000/02/11 17:08:37 kz
+ #65293# cast Syntax
+
+ Revision 1.3 2000/02/11 14:42:15 hr
+ #70473# changes for unicode ( patched by automated patchtool )
+
+ Revision 1.2 2000/02/08 06:47:09 mib
+ #70271#: remove temporary table cell format names
+
+ Revision 1.1 2000/02/07 10:02:55 mib
+ #70271#: table export
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
new file mode 100644
index 000000000000..a9205eef3ef8
--- /dev/null
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -0,0 +1,2229 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltbli.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#include <limits.h>
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_XTEXTTABLE_HPP_
+#include <com/sun/star/text/XTextTable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_TABLE_XCELLRANGE_HPP_
+#include <com/sun/star/table/XCellRange.hpp>
+#endif
+
+#ifndef _SFXITEMSET_HXX
+#include <svtools/itemset.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_FAMILIES_HXX
+#include <xmloff/families.hxx>
+#endif
+
+#ifndef _POOLFMT_HXX
+#include "poolfmt.hxx"
+#endif
+#ifndef _FMTFSIZE_HXX
+#include "fmtfsize.hxx"
+#endif
+#ifndef _FMTORNT_HXX
+#include "fmtornt.hxx"
+#endif
+#ifndef _FMTFORDR_HXX
+#include "fmtfordr.hxx"
+#endif
+#ifndef _DOC_HXX
+#include "doc.hxx"
+#endif
+#ifndef _SWTABLE_HXX
+#include "swtable.hxx"
+#endif
+#ifndef _SWTBLFMT_HXX
+#include "swtblfmt.hxx"
+#endif
+#ifndef _PAM_HXX
+#include "pam.hxx"
+#endif
+#ifndef _UNOTBL_HXX
+#include "unotbl.hxx"
+#endif
+#ifndef _UNOCRSR_HXX
+#include "unocrsr.hxx"
+#endif
+
+#ifndef _XMLTEXTI_HXX
+#include "xmltexti.hxx"
+#endif
+#ifndef _XMLNUM_HXX
+#include "xmlnum.hxx"
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::xml::sax;
+
+enum SwXMLTableElemTokens
+{
+ XML_TOK_TABLE_HEADER_COLS,
+ XML_TOK_TABLE_COLS,
+ XML_TOK_TABLE_COL,
+ XML_TOK_TABLE_HEADER_ROWS,
+ XML_TOK_TABLE_ROWS,
+ XML_TOK_TABLE_ROW,
+ XML_TOK_TABLE_ELEM_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] =
+{
+ { XML_NAMESPACE_TABLE, sXML_table_header_columns,
+ XML_TOK_TABLE_HEADER_COLS },
+ { XML_NAMESPACE_TABLE, sXML_table_columns, XML_TOK_TABLE_COLS },
+ { XML_NAMESPACE_TABLE, sXML_table_column, XML_TOK_TABLE_COL },
+ { XML_NAMESPACE_TABLE, sXML_table_header_rows,
+ XML_TOK_TABLE_HEADER_ROWS },
+ { XML_NAMESPACE_TABLE, sXML_table_rows, XML_TOK_TABLE_ROWS },
+ { XML_NAMESPACE_TABLE, sXML_table_row, XML_TOK_TABLE_ROW },
+ XML_TOKEN_MAP_END
+};
+
+const SvXMLTokenMap& SwXMLImport::GetTableElemTokenMap()
+{
+ if( !pTableElemTokenMap )
+ pTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap );
+
+ return *pTableElemTokenMap;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableCell_Impl
+{
+ OUString aStyleName;
+
+ SvXMLImportContextRef xSubTable;
+
+ const SwStartNode *pStartNode;
+ sal_uInt32 nRowSpan;
+ sal_uInt32 nColSpan;
+
+ sal_Bool bProtected : 1;
+
+public:
+
+ SwXMLTableCell_Impl( sal_uInt32 nRSpan=1UL, sal_uInt32 nCSpan=1UL ) :
+ nRowSpan( nRSpan ),
+ nColSpan( nCSpan ),
+ pStartNode( 0 ),
+ bProtected( sal_False )
+ {}
+
+ inline void Set( const OUString& rStyleName,
+ sal_uInt32 nRSpan, sal_uInt32 nCSpan,
+ const SwStartNode *pStNd, SwXMLTableContext *pTable );
+
+ sal_Bool IsUsed() const { return pStartNode!=0 ||
+ xSubTable.Is() || bProtected;}
+
+ sal_uInt32 GetRowSpan() const { return nRowSpan; }
+ void SetRowSpan( sal_uInt32 nSet ) { nRowSpan = nSet; }
+ sal_uInt32 GetColSpan() const { return nColSpan; }
+ const OUString& GetStyleName() const { return aStyleName; }
+
+ const SwStartNode *GetStartNode() const { return pStartNode; }
+ inline void SetStartNode( const SwStartNode *pSttNd );
+
+ inline SwXMLTableContext *GetSubTable() const;
+
+ inline void Dispose();
+};
+
+inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName,
+ sal_uInt32 nRSpan, sal_uInt32 nCSpan,
+ const SwStartNode *pStNd,
+ SwXMLTableContext *pTable )
+{
+ aStyleName = rStyleName;
+ nRowSpan = nRSpan;
+ nColSpan = nCSpan;
+ pStartNode = pStNd;
+ xSubTable = pTable;
+}
+
+inline void SwXMLTableCell_Impl::SetStartNode( const SwStartNode *pSttNd )
+{
+ pStartNode = pSttNd;
+ xSubTable = 0;
+}
+
+inline SwXMLTableContext *SwXMLTableCell_Impl::GetSubTable() const
+{
+ return (SwXMLTableContext *)&xSubTable;
+}
+
+inline void SwXMLTableCell_Impl::Dispose()
+{
+ if( xSubTable.Is() )
+ xSubTable = 0;
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLTableCell_Impl* SwXMLTableCellPtr;
+SV_DECL_PTRARR_DEL(SwXMLTableCells_Impl,SwXMLTableCellPtr,5,5)
+SV_IMPL_PTRARR(SwXMLTableCells_Impl,SwXMLTableCellPtr)
+
+class SwXMLTableRow_Impl
+{
+ OUString aStyleName;
+
+ SwXMLTableCells_Impl aCells;
+
+ sal_Bool bSplitable;
+
+public:
+
+ SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells );
+ ~SwXMLTableRow_Impl() {}
+
+ inline SwXMLTableCell_Impl *GetCell( sal_uInt32 nCol ) const;
+
+ inline void Set( const OUString& rStyleName );
+
+ void Expand( sal_uInt32 nCells, sal_Bool bOneCell );
+
+ void SetSplitable( sal_Bool bSet ) { bSplitable = bSet; }
+ sal_Bool IsSplitable() const { return bSplitable; }
+
+
+ const OUString& GetStyleName() const { return aStyleName; }
+
+ void Dispose();
+};
+
+SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName,
+ sal_uInt32 nCells ) :
+ aStyleName( rStyleName ),
+ bSplitable( sal_False )
+{
+ ASSERT( nCells <= USHRT_MAX,
+ "SwXMLTableRow_Impl::SwXMLTableRow_Impl: too many cells" );
+ if( nCells > USHRT_MAX )
+ nCells = USHRT_MAX;
+
+ for( sal_uInt16 i=0U; i<nCells; i++ )
+ {
+ aCells.Insert( new SwXMLTableCell_Impl, aCells.Count() );
+ }
+}
+
+inline SwXMLTableCell_Impl *SwXMLTableRow_Impl::GetCell( sal_uInt32 nCol ) const
+{
+ ASSERT( nCol < USHRT_MAX,
+ "SwXMLTableRow_Impl::GetCell: column number is to big" );
+ return aCells[(sal_uInt16)nCol];
+}
+
+void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, sal_Bool bOneCell )
+{
+ ASSERT( nCells <= USHRT_MAX,
+ "SwXMLTableRow_Impl::Expand: too many cells" );
+ if( nCells > USHRT_MAX )
+ nCells = USHRT_MAX;
+
+ sal_uInt32 nColSpan = nCells - aCells.Count();
+ for( sal_uInt16 i=aCells.Count(); i<nCells; i++ )
+ {
+ aCells.Insert( new SwXMLTableCell_Impl( 1UL,
+ bOneCell ? nColSpan : 1UL ),
+ aCells.Count() );
+ nColSpan--;
+ }
+
+ ASSERT( nCells<=aCells.Count(),
+ "SwXMLTableRow_Impl::Expand: wrong number of cells" );
+}
+
+inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName )
+{
+ aStyleName = rStyleName;
+}
+
+void SwXMLTableRow_Impl::Dispose()
+{
+ for( sal_uInt16 i=0; i < aCells.Count(); i++ )
+ aCells[i]->Dispose();
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableCellContext_Impl : public SvXMLImportContext
+{
+ OUString aStyleName;
+
+ SvXMLImportContextRef xMyTable;
+
+ sal_uInt32 nRowSpan;
+ sal_uInt32 nColSpan;
+
+ sal_Bool bHasContent;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+ sal_Bool HasContent() const { return bHasContent; }
+ inline void InsertContentIfNotThere();
+ inline void InsertContent( SwXMLTableContext *pTable );
+
+public:
+
+ SwXMLTableCellContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable );
+
+ virtual ~SwXMLTableCellContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+ virtual void EndElement();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable ),
+ nRowSpan( 1UL ),
+ nColSpan( 1UL ),
+ bHasContent( sal_False )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = rValue;
+ else if( aLocalName.compareToAscii(
+ sXML_number_columns_spanned ) == 0 )
+ {
+ nColSpan = (sal_uInt32)rValue.toInt32();
+ if( nColSpan < 1UL )
+ nColSpan = 1UL;
+ }
+ else if( aLocalName.compareToAscii(
+ sXML_number_rows_spanned ) == 0 )
+ {
+ nRowSpan = (sal_uInt32)rValue.toInt32();
+ if( nRowSpan < 1UL )
+ nRowSpan = 1UL;
+ }
+ }
+ }
+}
+
+SwXMLTableCellContext_Impl::~SwXMLTableCellContext_Impl()
+{
+}
+
+inline void SwXMLTableCellContext_Impl::InsertContentIfNotThere()
+{
+ if( !bHasContent )
+ {
+ GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan,
+ GetTable()->InsertTableSection() );
+ bHasContent = sal_True;
+ }
+}
+
+inline void SwXMLTableCellContext_Impl::InsertContent(
+ SwXMLTableContext *pTable )
+{
+ GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, pTable );
+ bHasContent = sal_True;
+}
+
+SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+#ifdef XML_CORE_API
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetBodyElemTokenMap();
+ sal_Bool bOrdered = sal_False;
+ sal_Bool bHeading = sal_False;
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_H:
+ bHeading = sal_True;
+ case XML_TOK_SW_P:
+ InsertContentIfNotThere();
+ pContext = new SwXMLParaContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bHeading );
+ break;
+ case XML_TOK_SW_ORDERED_LIST:
+ bOrdered = sal_True;
+ case XML_TOK_SW_UNORDERED_LIST:
+ InsertContentIfNotThere();
+ pContext = new SwXMLListBlockContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bOrdered );
+ break;
+
+ case XML_TOK_TABLE_SUBTABLE:
+ if( !HasContent() )
+ {
+ SwXMLTableContext *pTblContext =
+ new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName,
+ xAttrList, GetTable() );
+ pContext = pTblContext;
+ InsertContent( pTblContext );
+ }
+ break;
+ }
+#else
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ 0 == rLocalName.compareToAscii( sXML_sub_table ) )
+ {
+ if( !HasContent() )
+ {
+ SwXMLTableContext *pTblContext =
+ new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName,
+ xAttrList, GetTable() );
+ pContext = pTblContext;
+ InsertContent( pTblContext );
+ }
+ }
+ else
+ {
+ InsertContentIfNotThere();
+ pContext = GetImport().GetTextImport()->CreateTextChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ XML_TEXT_TYPE_CELL );
+ }
+#endif
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+void SwXMLTableCellContext_Impl::EndElement()
+{
+ if( bHasContent )
+ {
+#ifdef XML_CORE_API
+ SwPaM& rPaM = GetSwImport().GetPaM();
+ SwCntntNode* pCNd = rPaM.GetCntntNode();
+ if( pCNd && pCNd->StartOfSectionIndex() + 2UL <
+ pCNd->EndOfSectionIndex() )
+ {
+ rPaM.GetPoint()->nContent.Assign( 0, 0U );
+ rPaM.SetMark();
+ rPaM.DeleteMark();
+ GetSwImport().GetDoc().GetNodes().Delete( rPaM.GetPoint()->nNode );
+ rPaM.Move( fnMoveBackward, fnGoNode );
+ }
+#else
+ if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) )
+ {
+ OUString sEmpty;
+ GetImport().GetTextImport()->GetText()->insertString(
+ GetImport().GetTextImport()->GetCursorAsRange(), sEmpty,
+ sal_True );
+ }
+#endif
+ }
+ else
+ {
+ InsertContentIfNotThere();
+ }
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableColContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableColContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable );
+
+ virtual ~SwXMLTableColContext_Impl();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableColContext_Impl::SwXMLTableColContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable )
+{
+ sal_uInt32 nColRep = 1UL;
+ OUString aStyleName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = rValue;
+ else if( aLocalName.compareToAscii(
+ sXML_number_columns_repeated ) == 0 )
+ nColRep = (sal_uInt32)rValue.toInt32();
+ }
+ }
+
+ sal_Int32 nWidth = MINLAY;
+ sal_Bool bRelWidth = sal_True;
+ if( aStyleName.getLength() )
+ {
+ const SfxPoolItem *pItem;
+ const SfxItemSet *pAutoItemSet = 0;
+ if( GetSwImport().FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE_COL,
+#else
+ XML_STYLE_FAMILY_TABLE_COLUMN,
+#endif
+ aStyleName, &pAutoItemSet ) &&
+ pAutoItemSet &&
+ SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, sal_False,
+ &pItem ) )
+ {
+ const SwFmtFrmSize *pSize = ((const SwFmtFrmSize *)pItem);
+ nWidth = pSize->GetWidth();
+ bRelWidth = ATT_VAR_SIZE == pSize->GetSizeType();
+ }
+ }
+
+ if( nWidth )
+ {
+ while( nColRep-- && GetTable()->IsInsertColPossible() )
+ GetTable()->InsertColumn( nWidth, bRelWidth );
+ }
+}
+
+SwXMLTableColContext_Impl::~SwXMLTableColContext_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableColsContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+ sal_Bool bHeader;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableColsContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bHead );
+
+ virtual ~SwXMLTableColsContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableColsContext_Impl::SwXMLTableColsContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable, sal_Bool bHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable ),
+ bHeader( bHead )
+{
+}
+
+SwXMLTableColsContext_Impl::~SwXMLTableColsContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLTableColsContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ rLocalName.compareToAscii( sXML_table_column ) == 0 &&
+ GetTable()->IsInsertColPossible() )
+ pContext = new SwXMLTableColContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ GetTable() );
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableRowContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableRowContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable, sal_Bool bInHead=sal_False );
+
+ virtual ~SwXMLTableRowContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ virtual void EndElement();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bInHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable )
+{
+ OUString aStyleName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ {
+ aStyleName = rValue;
+ }
+ }
+ GetTable()->InsertRow( aStyleName, bInHead );
+}
+
+void SwXMLTableRowContext_Impl::EndElement()
+{
+ GetTable()->FinishRow();
+}
+
+SwXMLTableRowContext_Impl::~SwXMLTableRowContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLTableRowContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( rLocalName.compareToAscii( sXML_table_cell ) == 0 )
+ {
+ if( GetTable()->IsInsertCellPossible() )
+ pContext = new SwXMLTableCellContext_Impl( GetSwImport(),
+ nPrefix,
+ rLocalName,
+ xAttrList,
+ GetTable() );
+ }
+ else if( rLocalName.compareToAscii( sXML_covered_table_cell ) == 0 )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix,
+ rLocalName );
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLTableRowsContext_Impl : public SvXMLImportContext
+{
+ SvXMLImportContextRef xMyTable;
+
+ sal_Bool bHeader;
+
+ SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; }
+
+public:
+
+ SwXMLTableRowsContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bHead );
+
+ virtual ~SwXMLTableRowsContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLTableRowsContext_Impl::SwXMLTableRowsContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable,
+ sal_Bool bHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xMyTable( pTable ),
+ bHeader( bHead )
+{
+}
+
+SwXMLTableRowsContext_Impl::~SwXMLTableRowsContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLTableRowsContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ if( XML_NAMESPACE_TABLE == nPrefix &&
+ rLocalName.compareToAscii( sXML_table_row ) == 0 &&
+ GetTable()->IsInsertRowPossible() )
+ pContext = new SwXMLTableRowContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ GetTable(),
+ bHeader );
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+typedef SwXMLTableRow_Impl* SwXMLTableRowPtr;
+SV_DECL_PTRARR_DEL(SwXMLTableRows_Impl,SwXMLTableRowPtr,5,5)
+SV_IMPL_PTRARR(SwXMLTableRows_Impl,SwXMLTableRowPtr)
+
+SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
+ sal_uInt32 nCol ) const
+{
+ return (*pRows)[nRow]->GetCell( nCol );
+}
+
+SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pRows( new SwXMLTableRows_Impl ),
+ pTableNode( 0 ),
+ pBox1( 0 ),
+ pSttNd1( 0 ),
+ pBoxFmt( 0 ),
+ pLineFmt( 0 ),
+ nCurRow( 0UL ),
+ nCurCol( 0UL ),
+ nWidth( 0UL ),
+ bFirstSection( sal_True ),
+ bRelWidth( sal_True ),
+ bHasHeading( sal_False )
+{
+ OUString aName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+ if( XML_NAMESPACE_TABLE == nPrefix )
+ {
+ if( aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = rValue;
+ else if( aLocalName.compareToAscii( sXML_name ) == 0 )
+ aName = rValue;
+ }
+ }
+
+ SwXMLImport& rSwImport = GetSwImport();
+ SwDoc& rDoc = rSwImport.GetDoc();
+
+ String sTblName;
+ if( aName.getLength() )
+ {
+ const SwTableFmt *pTblFmt = rDoc.FindTblFmtByName( aName );
+ if( !pTblFmt )
+ sTblName = aName;
+ }
+ if( !sTblName.Len() )
+ sTblName = rDoc.GetUniqueTblName();
+
+#ifdef XML_CORE_API
+ const SwTable* pSwTable = rDoc.InsertTable( *rSwImport.GetPaM().GetPoint(),
+ 1U, 1U, HORI_LEFT );
+ pTableNode = pSwTable->GetTableNode();
+
+ SwFrmFmt *pTblFrmFmt = pSwTable->GetFrmFmt();
+ pTblFrmFmt->SetName( sTblName );
+
+ rSwImport.GetPaM().Move( fnMoveBackward );
+#else
+ Reference< XTextTable > xTable;
+
+ const SwXTextTable *pXTable = 0;
+ Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
+ UNO_QUERY );
+ ASSERT( xFactory.is(), "factory missing" );
+ if( xFactory.is() )
+ {
+ OUString sService(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextTable" ) );
+ Reference<XInterface> xIfc = xFactory->createInstance( sService );
+ ASSERT( xIfc.is(), "Couldn't create a table" );
+
+ if( xIfc.is() )
+ xTable = Reference< XTextTable > ( xIfc, UNO_QUERY );
+ }
+
+ if( xTable.is() )
+ {
+ xTable->initialize( 1, 1 );
+
+ Reference< XTextContent > xTxtCnt( xTable, UNO_QUERY );
+ GetImport().GetTextImport()->InsertTextContent( xTxtCnt );
+
+ Reference<XUnoTunnel> xTableTunnel( xTable, UNO_QUERY);
+ if( xTableTunnel.is() )
+ {
+ pXTable = (SwXTextTable*)xTableTunnel->getSomething(
+ SwXTextTable::getUnoTunnelId() );
+ ASSERT( pXTable, "SwXTextTable missing" );
+ }
+
+ Reference < XCellRange > xCellRange( xTable, UNO_QUERY );
+ Reference < XCell > xCell = xCellRange->getCellByPosition( 0, 0 );
+ Reference < XText> xText( xCell, UNO_QUERY );
+ xOldCursor = GetImport().GetTextImport()->GetCursor();
+ GetImport().GetTextImport()->SetCursor( xText->createTextCursor() );
+
+ }
+ if( pXTable )
+ {
+ SwFrmFmt *pTblFrmFmt = pXTable->GetFrmFmt();
+ ASSERT( pTblFrmFmt, "table format missing" );
+ SwTable *pTbl = SwTable::FindTable( pTblFrmFmt );
+ ASSERT( pTbl, "table missing" );
+ pTableNode = pTbl->GetTableNode();
+ ASSERT( pTableNode, "table node missing" );
+
+ pTblFrmFmt->SetName( sTblName );
+
+ SwTableLine *pLine1 = pTableNode->GetTable().GetTabLines()[0U];
+ pBox1 = pLine1->GetTabBoxes()[0U];
+ pSttNd1 = pBox1->GetSttNd();
+ }
+#endif
+}
+
+SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ xParentTable( pTable ),
+ pRows( new SwXMLTableRows_Impl ),
+ pTableNode( pTable->pTableNode ),
+ pBox1( 0 ),
+ pSttNd1( 0 ),
+ pBoxFmt( 0 ),
+ pLineFmt( 0 ),
+ nCurRow( 0UL ),
+ nCurCol( 0UL ),
+ nWidth( 0UL ),
+ bFirstSection( sal_False ),
+ bRelWidth( sal_True ),
+ bHasHeading( sal_False )
+{
+}
+
+SwXMLTableContext::~SwXMLTableContext()
+{
+}
+
+SvXMLImportContext *SwXMLTableContext::CreateChildContext( sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTableElemTokenMap();
+ sal_Bool bHeader = sal_False;
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_TABLE_HEADER_COLS:
+ bHeader = sal_True;
+ case XML_TOK_TABLE_COLS:
+ pContext = new SwXMLTableColsContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this, bHeader );
+ break;
+ case XML_TOK_TABLE_COL:
+ if( IsInsertColPossible() )
+ pContext = new SwXMLTableColContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this );
+ break;
+ case XML_TOK_TABLE_HEADER_ROWS:
+ bHeader = sal_True;
+ case XML_TOK_TABLE_ROWS:
+ pContext = new SwXMLTableRowsContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this, bHeader );
+ break;
+ case XML_TOK_TABLE_ROW:
+ if( IsInsertRowPossible() )
+ pContext = new SwXMLTableRowContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ this );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+void SwXMLTableContext::InsertColumn( sal_Int32 nWidth, sal_Bool bRelWidth )
+{
+ ASSERT( nCurCol < USHRT_MAX,
+ "SwXMLTableContext::InsertColumn: no space left" );
+ if( nCurCol >= USHRT_MAX )
+ return;
+
+ if( nWidth < MINLAY )
+ nWidth = MINLAY;
+ else if( nWidth > USHRT_MAX )
+ nWidth = USHRT_MAX;
+ aColumnWidths.Insert( (sal_uInt16)nWidth, aColumnWidths.Count() );
+ aColumnRelWidths.Insert( bRelWidth, aColumnRelWidths.Count() );
+}
+
+sal_Int32 SwXMLTableContext::GetColumnWidth( sal_uInt32 nCol,
+ sal_uInt32 nColSpan ) const
+{
+ sal_uInt32 nLast = nCol+nColSpan;
+ if( nLast > aColumnWidths.Count() )
+ nLast = aColumnWidths.Count();
+
+ sal_Int32 nWidth = 0L;
+ for( sal_uInt16 i=nCol; i < nLast; i++ )
+ nWidth += aColumnWidths[i];
+
+ return nWidth;
+}
+
+void SwXMLTableContext::InsertCell( const OUString& rStyleName,
+ sal_uInt32 nRowSpan, sal_uInt32 nColSpan,
+ const SwStartNode *pStartNode,
+ SwXMLTableContext *pTable )
+{
+ ASSERT( nCurCol < GetColumnCount(),
+ "SwXMLTableContext::InsertCell: row is full" );
+ ASSERT( nCurRow < USHRT_MAX,
+ "SwXMLTableContext::InsertCell: table is full" );
+ if( nCurCol >= USHRT_MAX || nCurRow > USHRT_MAX )
+ return;
+
+ ASSERT( nRowSpan >=1UL, "SwXMLTableContext::InsertCell: row span is 0" );
+ if( 0UL == nRowSpan )
+ nRowSpan = 1UL;
+ ASSERT( nColSpan >=1UL, "SwXMLTableContext::InsertCell: col span is 0" );
+ if( 0UL == nColSpan )
+ nColSpan = 1UL;
+
+ sal_uInt32 i, j;
+
+ // Until it is possible to add columns here, fix the column span.
+ sal_uInt32 nColsReq = nCurCol + nColSpan;
+ if( nColsReq > GetColumnCount() )
+ {
+ nColSpan = GetColumnCount() - nCurCol;
+ nColsReq = GetColumnCount();
+ }
+
+ // Check whether there are cells from a previous line already that reach
+ // into the current row.
+ if( nCurRow > 0UL && nColSpan > 1UL )
+ {
+ SwXMLTableRow_Impl *pCurRow = (*pRows)[(sal_uInt16)nCurRow];
+ sal_uInt32 nLastCol = GetColumnCount() < nColsReq ? GetColumnCount()
+ : nColsReq;
+ for( i=nCurCol+1UL; i<nLastCol; i++ )
+ {
+ if( pCurRow->GetCell(i)->IsUsed() )
+ {
+ // If this cell is used, the column span is truncated
+ nColSpan = i - nCurCol;
+ nColsReq = i;
+ break;
+ }
+ }
+ }
+
+ sal_uInt32 nRowsReq = nCurRow + nRowSpan;
+ if( nRowsReq > USHRT_MAX )
+ {
+ nRowSpan = USHRT_MAX - nCurRow;
+ nRowsReq = USHRT_MAX;
+ }
+
+ // Add columns: TODO: This should never happen, since we require
+ // column definitions!
+ for( i=GetColumnCount(); i<nColsReq; i++ )
+ {
+ aColumnWidths.Insert( MINLAY, aColumnWidths.Count() );
+ aColumnRelWidths.Insert( sal_True, aColumnRelWidths.Count() );
+ }
+ for( i=0; i<pRows->Count(); i++ )
+ (*pRows)[(sal_uInt16)i]->Expand( nColsReq, i<nCurRow );
+
+ // Add rows
+ if( pRows->Count() < nRowsReq )
+ {
+ OUString aStyleName;
+ for( i=pRows->Count(); i<nRowsReq; i++ )
+ pRows->Insert( new SwXMLTableRow_Impl(aStyleName,GetColumnCount()),
+ pRows->Count() );
+ }
+
+ // Fill the cells
+ for( i=nColSpan; i>0UL; i-- )
+ for( j=nRowSpan; j>0UL; j-- )
+ GetCell( nRowsReq-j, nColsReq-i )
+ ->Set( rStyleName, j, i, pStartNode, pTable );
+
+ // Set current col to the next (free) column
+ nCurCol = nColsReq;
+ while( nCurCol<GetColumnCount() && GetCell(nCurRow,nCurCol)->IsUsed() )
+ nCurCol++;
+}
+
+void SwXMLTableContext::InsertRow( const OUString& rStyleName,
+ sal_Bool bInHead )
+{
+ ASSERT( nCurRow < USHRT_MAX,
+ "SwXMLTableContext::InsertRow: no space left" );
+ if( nCurRow >= USHRT_MAX )
+ return;
+
+ if( nCurRow < pRows->Count() )
+ {
+ // The current row has already been inserted because of a row span
+ // of a previous row.
+ (*pRows)[nCurRow]->Set( rStyleName );
+ }
+ else
+ {
+ // add a new row
+ pRows->Insert( new SwXMLTableRow_Impl( rStyleName, GetColumnCount()),
+ pRows->Count() );
+ }
+
+ // We start at the first column ...
+ nCurCol=0UL;
+
+ // ... but this cell may be occupied already.
+ while( nCurCol<GetColumnCount() && GetCell(nCurRow,nCurCol)->IsUsed() )
+ nCurCol++;
+
+ if( 0UL == nCurRow )
+ bHasHeading = bInHead;
+}
+
+void SwXMLTableContext::FinishRow()
+{
+ // Insert an empty cell at the end of the line if the row is not complete
+ if( nCurCol < GetColumnCount() )
+ {
+ OUString aStyleName;
+ InsertCell( aStyleName, 1U, GetColumnCount() - nCurCol,
+ InsertTableSection() );
+ }
+
+ // Move to the next row.
+ nCurRow++;
+}
+
+const SwStartNode *SwXMLTableContext::GetPrevStartNode( sal_uInt32 nRow,
+ sal_uInt32 nCol ) const
+{
+ const SwXMLTableCell_Impl *pPrevCell = 0;
+ if( GetColumnCount() == nCol )
+ {
+ // The last cell is the right one here.
+ pPrevCell = GetCell( pRows->Count()-1U, GetColumnCount()-1UL );
+ }
+ else if( 0UL == nRow )
+ {
+ // There are no vertically merged cells within the first row, so the
+ // previous cell is the right one always.
+ if( nCol > 0UL )
+ pPrevCell = GetCell( nRow, nCol-1UL );
+ }
+ else
+ {
+ // If there is a previous cell in the current row that is not spanned
+ // from the previous row, its the right one.
+ const SwXMLTableRow_Impl *pPrevRow = (*pRows)[(sal_uInt16)nRow-1U];
+ sal_uInt32 i = nCol;
+ while( !pPrevCell && i > 0UL )
+ {
+ i--;
+ if( 1UL == pPrevRow->GetCell( i )->GetRowSpan() )
+ pPrevCell = GetCell( nRow, i );
+ }
+
+ // Otherwise, the last cell from the previous row is the right one.
+ if( !pPrevCell )
+ pPrevCell = pPrevRow->GetCell( GetColumnCount()-1UL );
+ }
+
+ const SwStartNode *pSttNd;
+ if( pPrevCell )
+ {
+ if( pPrevCell->GetStartNode() )
+ pSttNd = pPrevCell->GetStartNode();
+ else
+ pSttNd = pPrevCell->GetSubTable()->GetLastStartNode();
+ }
+
+ return pSttNd;
+}
+
+void SwXMLTableContext::FixRowSpan( sal_uInt32 nRow, sal_uInt32 nCol,
+ sal_uInt32 nColSpan )
+{
+ sal_uInt32 nLastCol = nCol + nColSpan;
+ for( sal_uInt16 i = nCol; i < nLastCol; i++ )
+ {
+ sal_uInt32 j = nRow;
+ sal_uInt32 nRowSpan = 1UL;
+ SwXMLTableCell_Impl *pCell = GetCell( j, i );
+ while( pCell && pCell->GetRowSpan() > 1UL )
+ {
+ pCell->SetRowSpan( nRowSpan++ );
+ pCell = j > 0UL ? GetCell( --j, i ) : 0;
+ }
+ }
+}
+
+void SwXMLTableContext::ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol )
+{
+ const SwStartNode *pPrevSttNd = GetPrevStartNode( nRow, nCol );
+ const SwStartNode *pSttNd = InsertTableSection( pPrevSttNd );
+
+ const SwXMLTableCell_Impl *pCell = GetCell( nRow, nCol );
+ sal_uInt32 nLastRow = nRow + pCell->GetRowSpan();
+ sal_uInt32 nLastCol = nCol + pCell->GetColSpan();
+
+ for( sal_uInt32 i=nRow; i<nLastRow; i++ )
+ {
+ SwXMLTableRow_Impl *pRow = (*pRows)[i];
+ for( sal_uInt32 j=nCol; j<nLastCol; j++ )
+ pRow->GetCell( j )->SetStartNode( pSttNd );
+ }
+}
+
+SwTableBox *SwXMLTableContext::NewTableBox( const SwStartNode *pStNd,
+ SwTableLine *pUpper )
+{
+ SwTableBox *pBox;
+
+ if( pBox1 &&
+ pBox1->GetSttNd() == pStNd )
+ {
+ // wenn der StartNode dem StartNode der initial angelegten Box
+ // entspricht nehmen wir diese Box
+ pBox = pBox1;
+ pBox->SetUpper( pUpper );
+ pBox1 = 0;
+ }
+ else
+ pBox = new SwTableBox( pBoxFmt, *pStNd, pUpper );
+
+ return pBox;
+}
+
+SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
+ sal_uInt32 nTopRow,
+ sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow,
+ sal_uInt32 nRightCol )
+{
+ SwTableBox *pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+
+ // TODO: Share formats!
+ SwFrmFmt *pFrmFmt = pBox->ClaimFrmFmt();
+ SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() );
+ pFrmFmt->ResetAllAttr();
+ pFrmFmt->SetAttr( aFillOrder );
+
+ SwTableLines& rLines = pBox->GetTabLines();
+ sal_Bool bSplitted = sal_False;
+
+ while( !bSplitted )
+ {
+ sal_uInt32 nStartRow = nTopRow;
+ for( sal_uInt32 i=nTopRow; i<nBottomRow; i++ )
+ {
+ // Could the table be splitted behind the current row?
+ sal_Bool bSplit = sal_True;
+ SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i];
+ for( sal_uInt32 j=nLeftCol; j<nRightCol; j++ )
+ {
+ bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
+ if( !bSplit )
+ break;
+ }
+ if( bSplit && (nStartRow>nTopRow || i+1UL<nBottomRow) )
+ {
+ SwTableLine *pLine =
+ MakeTableLine( pBox, nStartRow, nLeftCol, i+1UL,
+ nRightCol );
+
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+
+ nStartRow = i+1UL;
+ bSplitted = sal_True;
+ }
+ }
+ if( !bSplitted )
+ {
+ // No splitting was possible. That for, we have to force it.
+ // Ruthless!
+
+ nStartRow = nTopRow;
+ while( nStartRow < nBottomRow )
+ {
+ sal_uInt32 nMaxRowSpan = 0UL;
+ SwXMLTableRow_Impl *pStartRow = (*pRows)[(sal_uInt16)nStartRow];
+ SwXMLTableCell_Impl *pCell;
+ for( i=nLeftCol; i<nRightCol; i++ )
+ if( ( pCell=pStartRow->GetCell(i),
+ pCell->GetRowSpan() > nMaxRowSpan ) )
+ nMaxRowSpan = pCell->GetRowSpan();
+
+ nStartRow += nMaxRowSpan;
+ if( nStartRow<nBottomRow )
+ {
+ SwXMLTableRow_Impl *pPrevRow =
+ (*pRows)[(sal_uInt16)nStartRow-1U];
+ i = nLeftCol;
+ while( i < nRightCol )
+ {
+ if( pPrevRow->GetCell(i)->GetRowSpan() > 1UL )
+ {
+ const SwXMLTableCell_Impl *pCell =
+ GetCell( nStartRow, i );
+ sal_uInt32 nColSpan = pCell->GetColSpan();
+ FixRowSpan( nStartRow-1UL, i, nColSpan );
+ ReplaceWithEmptyCell( nStartRow, i );
+ i += nColSpan;
+ }
+ else
+ {
+ i++;
+ }
+ }
+ }
+ }
+ // und jetzt nochmal von vorne ...
+ }
+ }
+
+ return pBox;
+}
+
+SwTableBox *SwXMLTableContext::MakeTableBox(
+ SwTableLine *pUpper, const SwXMLTableCell_Impl *pCell,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol, sal_uInt32 nBottomRow,
+ sal_uInt32 nRightCol )
+{
+ SwTableBox *pBox;
+ sal_uInt32 nColSpan = nRightCol - nLeftCol;
+ sal_uInt32 nRowSpan = nBottomRow - nTopRow;
+ sal_Int32 nColWidth = GetColumnWidth( nLeftCol, nColSpan );
+
+ if( pCell->GetStartNode() )
+ {
+ pBox = NewTableBox( pCell->GetStartNode(), pUpper );
+ }
+ else
+ {
+ // und die ist eine Tabelle: dann bauen wir eine neue
+ // Box und fuegen die Zeilen der Tabelle in die Zeilen
+ // der Box ein
+ pBox = new SwTableBox( pBoxFmt, 0, pUpper );
+ pCell->GetSubTable()->MakeTable( pBox, nColWidth );
+ }
+
+ // TODO: Share formats!
+ SwFrmFmt *pFrmFmt = pBox->ClaimFrmFmt();
+ SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() );
+ pFrmFmt->ResetAllAttr();
+ pFrmFmt->SetAttr( aFillOrder );
+
+ const SfxItemSet *pAutoItemSet = 0;
+ const OUString& rStyleName = pCell->GetStyleName();
+ if( pCell->GetStartNode() && rStyleName &&
+ GetSwImport().FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE_BOX,
+#else
+ XML_STYLE_FAMILY_TABLE_CELL,
+#endif
+ pCell->GetStyleName(),
+ &pAutoItemSet ) )
+ {
+ if( pAutoItemSet )
+ pFrmFmt->SetAttr( *pAutoItemSet );
+ }
+
+ pFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nColWidth ) );
+
+ return pBox;
+}
+
+SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
+ sal_uInt32 nTopRow,
+ sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow,
+ sal_uInt32 nRightCol )
+{
+ SwTableLine *pLine;
+ if( !pUpper && 0UL==nTopRow )
+ {
+ pLine = pTableNode->GetTable().GetTabLines()[0U];
+ }
+ else
+ {
+ pLine = new SwTableLine( pLineFmt, 0, pUpper );
+ }
+
+ // TODO: Share formats!
+ SwFrmFmt *pFrmFmt = pLine->ClaimFrmFmt();
+ SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() );
+ pFrmFmt->ResetAllAttr();
+ pFrmFmt->SetAttr( aFillOrder );
+
+ const SfxItemSet *pAutoItemSet = 0;
+ const OUString& rStyleName = (*pRows)[nTopRow]->GetStyleName();
+ if( 1UL == (nBottomRow - nTopRow) &&
+ rStyleName.getLength() &&
+ GetSwImport().FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE_LINE,
+#else
+ XML_STYLE_FAMILY_TABLE_ROW,
+#endif
+ rStyleName, &pAutoItemSet ) )
+ {
+ if( pAutoItemSet )
+ pFrmFmt->SetAttr( *pAutoItemSet );
+ }
+
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+
+ sal_uInt32 nStartCol = nLeftCol;
+ while( nStartCol < nRightCol )
+ {
+ for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ )
+ (*pRows)[(sal_uInt16)nRow]->SetSplitable( sal_True );
+
+ sal_uInt32 nCol = nStartCol;
+ sal_uInt32 nSplitCol = nRightCol;
+ sal_Bool bSplitted = sal_False;
+ while( !bSplitted )
+ {
+ ASSERT( nCol < nRightCol, "Zu weit gelaufen" );
+
+ // Kann hinter der aktuellen HTML-Tabellen-Spalte gesplittet
+ // werden? Wenn ja, koennte der enstehende Bereich auch noch
+ // in Zeilen zerlegt werden, wenn man die naechste Spalte
+ // hinzunimmt?
+ sal_Bool bSplit = sal_True;
+ sal_Bool bHoriSplitMayContinue = sal_False;
+ sal_Bool bHoriSplitPossible = sal_False;
+ for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ )
+ {
+ SwXMLTableCell_Impl *pCell = GetCell(nRow,nCol);
+ // Could the table fragment be splitted horizontally behind
+ // the current line?
+ sal_Bool bHoriSplit = (*pRows)[(sal_uInt16)nRow]->IsSplitable() &&
+ nRow+1UL < nBottomRow &&
+ 1UL == pCell->GetRowSpan();
+ (*pRows)[(sal_uInt16)nRow]->SetSplitable( bHoriSplit );
+
+ // Could the table fragment be splitted vertically behind the
+ // current column (uptp the current line?
+ bSplit &= ( 1UL == pCell->GetColSpan() );
+ if( bSplit )
+ {
+ bHoriSplitPossible |= bHoriSplit;
+
+ // Could the current table fragment be splitted
+ // horizontally behind the next collumn, too?
+ bHoriSplit &= (nCol+1UL < nRightCol &&
+ 1UL == GetCell(nRow,nCol+1UL)->GetRowSpan());
+ bHoriSplitMayContinue |= bHoriSplit;
+ }
+ }
+
+#ifndef PRODUCT
+ if( nCol == nRightCol-1UL )
+ {
+ ASSERT( bSplit, "Split-Flag falsch" );
+ ASSERT( !bHoriSplitMayContinue,
+ "HoriSplitMayContinue-Flag falsch" );
+ SwXMLTableCell_Impl *pCell = GetCell( nTopRow, nStartCol );
+ ASSERT( pCell->GetRowSpan() != (nBottomRow-nTopRow) ||
+ !bHoriSplitPossible, "HoriSplitPossible-Flag falsch" );
+ }
+#endif
+ ASSERT( !bHoriSplitMayContinue || bHoriSplitPossible,
+ "bHoriSplitMayContinue, aber nicht bHoriSplitPossible" );
+
+ if( bSplit )
+ {
+ SwTableBox* pBox = 0;
+ SwXMLTableCell_Impl *pCell = GetCell( nTopRow, nStartCol );
+ if( pCell->GetRowSpan() == (nBottomRow-nTopRow) &&
+ pCell->GetColSpan() == (nCol+1UL-nStartCol) )
+ {
+ // The remaining box neither contains lines nor rows (i.e.
+ // is a content box
+ nSplitCol = nCol + 1UL;
+
+#if 0
+ // eventuell ist die Zelle noch leer
+ if( !pCell->GetContents() )
+ {
+ ASSERT( 1UL==pCell->GetRowSpan(),
+ "leere Box ist nicht 1 Zeile hoch" );
+ const SwStartNode* pPrevStNd =
+ GetPrevBoxStartNode( nTopRow, nStartCol );
+ HTMLTableCnts *pCnts = new HTMLTableCnts(
+ pParser->InsertTableSection(pPrevStNd) );
+ SwHTMLTableLayoutCnts *pCntsLayoutInfo =
+ pCnts->CreateLayoutInfo();
+
+ pCell->SetContents( pCnts );
+ pLayoutInfo->GetCell( nTopRow, nStartCol )
+ ->SetContents( pCntsLayoutInfo );
+
+ // ggf. COLSPAN beachten
+ for( sal_uInt16 j=nStartCol+1; j<nSplitCol; j++ )
+ {
+ GetCell(nTopRow,j)->SetContents( pCnts );
+ pLayoutInfo->GetCell( nTopRow, j )
+ ->SetContents( pCntsLayoutInfo );
+ }
+ }
+#endif
+ pBox = MakeTableBox( pLine, pCell,
+ nTopRow, nStartCol,
+ nBottomRow, nSplitCol );
+ bSplitted = sal_True;
+ }
+ else if( bHoriSplitPossible && bHoriSplitMayContinue )
+ {
+ // The table fragment could be splitted behind the current
+ // column, and the remaining fragment could be divided
+ // into lines. Anyway, it could be that this applies to
+ // the next column, too. That for, we check the next
+ // column but rememeber the current one as a good place to
+ // split.
+ nSplitCol = nCol + 1UL;
+ }
+ else
+ {
+ // If the table resulting table fragment could be divided
+ // into lines if spllitting behind the current column, but
+ // this doesn't apply for thr next column, we split begind
+ // the current column. This applies for the last column,
+ // too.
+ // If the resulting box cannot be splitted into rows,
+ // the split at the last split position we remembered.
+ if( bHoriSplitPossible || nSplitCol > nCol+1 )
+ {
+ ASSERT( !bHoriSplitMayContinue,
+ "bHoriSplitMayContinue==sal_True" );
+ ASSERT( bHoriSplitPossible || nSplitCol == nRightCol,
+ "bHoriSplitPossible-Flag sollte gesetzt sein" );
+
+ nSplitCol = nCol + 1UL;
+ }
+
+ pBox = MakeTableBox( pLine, nTopRow, nStartCol,
+ nBottomRow, nSplitCol );
+ bSplitted = sal_True;
+ }
+ if( pBox )
+ rBoxes.C40_INSERT( SwTableBox, pBox, rBoxes.Count() );
+ }
+ nCol++;
+ }
+ nStartCol = nSplitCol;
+ }
+
+ return pLine;
+}
+
+void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
+{
+ // fix column widths
+ sal_uInt32 i;
+ sal_uInt32 nCols = GetColumnCount();
+
+ // If there are empty rows (because of some row span of previous rows)
+ // the have to be deleted. The previous rows have to be truncated.
+
+ if( pRows->Count() > nCurRow )
+ {
+ SwXMLTableRow_Impl *pPrevRow = (*pRows)[(sal_uInt16)nCurRow-1U];
+ SwXMLTableCell_Impl *pCell;
+ for( i=0UL; i<nCols; i++ )
+ {
+ if( ( pCell=pPrevRow->GetCell(i), pCell->GetRowSpan() > 1UL ) )
+ {
+ FixRowSpan( nCurRow-1UL, i, 1UL );
+ }
+ }
+ for( i=(sal_uInt32)pRows->Count()-1UL; i>=nCurRow; i-- )
+ pRows->DeleteAndDestroy( i );
+ }
+
+ // Make sure there is at least one column.
+ if( 0UL == nCols )
+ {
+ InsertColumn( USHRT_MAX, sal_True );
+ nCols = 1UL;
+ }
+ if( 0UL == pRows->Count() )
+ {
+ OUString aStyleName;
+ InsertCell( aStyleName, 1U, nCols, InsertTableSection() );
+ }
+
+ // TODO: Do we have to keep both values, the realtive and the absolute
+ // width?
+ sal_Int32 nAbsWidth = 0L;
+ sal_Int32 nMinAbsColWidth = 0L;
+ sal_Int32 nRelWidth = 0L;
+ sal_Int32 nMinRelColWidth = 0L;
+ sal_uInt32 nRelCols = 0UL;
+ for( i=0U; i < nCols; i++ )
+ {
+ sal_Int32 nColWidth = aColumnWidths[i];
+ if( aColumnRelWidths[i] )
+ {
+ nRelWidth += nColWidth;
+ if( 0L == nMinRelColWidth || nColWidth < nMinRelColWidth )
+ nMinRelColWidth = nColWidth;
+ nRelCols++;
+ }
+ else
+ {
+ nAbsWidth += nColWidth;
+ if( 0L == nMinAbsColWidth || nColWidth < nMinAbsColWidth )
+ nMinAbsColWidth = nColWidth;
+ }
+ }
+ sal_uInt32 nAbsCols = nCols - nRelCols;
+
+ if( bRelWidth )
+ {
+ // If there a columns that have an absolute width, we have to
+ // calculate a relative one for them.
+ if( nAbsCols > 0UL )
+ {
+ // All column that have absolute widths get relative widths;
+ // these widths relate to each over like the original absolute
+ // widths. The smallest column gets a width that hat the same
+ // value as the smallest column that has an relative width
+ // already.
+ if( 0L == nMinRelColWidth )
+ nMinRelColWidth = MINLAY;
+
+ for( i=0UL; nAbsCols > 0UL && i < nCols; i++ )
+ {
+ if( !aColumnRelWidths[(sal_uInt16)i] )
+ {
+ sal_Int32 nRelCol = (aColumnWidths[i] * nMinRelColWidth) /
+ nMinAbsColWidth;
+ aColumnWidths.Replace( (sal_uInt16)nRelCol, (sal_uInt16)i );
+ nRelWidth += nRelCol;
+ nAbsCols--;
+ }
+ }
+ }
+
+ if( !nWidth )
+ {
+ // If no width has been specified by now, we may use any value
+ nWidth = nRelWidth > USHRT_MAX ? USHRT_MAX : nRelWidth;
+ }
+ if( nRelWidth != nWidth )
+ {
+ double n = (double)nWidth / (double)nRelWidth;
+ nRelWidth = 0L;
+ for( i=0U; i < nCols-1UL; i++ )
+ {
+ sal_Int32 nW = (sal_Int32)(aColumnWidths[i] * n);
+ aColumnWidths.Replace( (sal_uInt16)nW, i );
+ nRelWidth += nW;
+ }
+ aColumnWidths.Replace( (sal_uInt16)(nWidth-nRelWidth),
+ (sal_uInt16)nCols-1UL );
+ }
+ }
+ else
+ {
+ // If there are columns that have relative widths, we have to
+ // calculate a absolute widths for them.
+ if( nRelCols > 0UL )
+ {
+ // The absolute space that is available for all columns with a
+ // relative width.
+ sal_Int32 nAbsForRelWidth =
+ nWidth > nAbsWidth ? nWidth - nAbsWidth : 0L;
+
+ // The relative width that has to be distributed in addition to
+ // equally widthed columns.
+ sal_Int32 nExtraRel = nRelWidth - (nRelCols * nMinRelColWidth);
+
+ // The absolute space that may be distributed in addition to
+ // minumum widthed columns.
+ sal_Int32 nMinAbs = nRelCols * MINLAY;
+ sal_Int32 nExtraAbs =
+ nAbsForRelWidth > nMinAbs ? nAbsForRelWidth - nMinAbs : 0L;
+
+ sal_Bool bMin = sal_False; // Do all columns get the mininum width?
+ sal_Bool bMinExtra = sal_False; // Do all columns get the minimum width plus
+ // some extra space?
+
+ if( nAbsForRelWidth <= nMinAbs )
+ {
+ // If there is not enough space left for all columns to
+ // get the minimum width, they get the minimum width, anyway.
+ nAbsForRelWidth = nMinAbs;
+ bMin = sal_True;
+ }
+ else if( nAbsForRelWidth <= (nRelWidth * MINLAY) /
+ nMinRelColWidth )
+ {
+ // If there is enougth space for all columns to get the
+ // minimum width, but not to get a width that takes the
+ // relative width into account, each column gets the minimum
+ // width plus some extra space that is based on the additional
+ // space that is available.
+ bMinExtra = sal_True;
+ }
+ // Otherwise, if there is enouth space for every column, every
+ // column gets this space.
+
+ for( i=0UL; nRelCols > 0UL && i < nCols; i++ )
+ {
+ if( aColumnRelWidths[(sal_uInt16)i] )
+ {
+ sal_Int32 nAbsCol;
+ if( 1UL == nRelCols )
+ {
+ // The last column that has a relative width gets
+ // all absolute space that is left.
+ nAbsCol = nAbsForRelWidth;
+ }
+ else
+ {
+ if( bMin )
+ {
+ nAbsCol = MINLAY;
+ }
+ else if( bMinExtra )
+ {
+ sal_Int32 nExtraRelCol =
+ aColumnWidths[i] - nMinRelColWidth;
+ nAbsCol = MINLAY + (nExtraRelCol * nExtraAbs) /
+ nExtraRel;
+ }
+ else
+ {
+ nAbsCol = (aColumnWidths[i] * nAbsForRelWidth) /
+ nRelWidth;
+ }
+ }
+ aColumnWidths.Replace( (sal_uInt16)nAbsCol, (sal_uInt16)i );
+ nAbsForRelWidth -= nAbsCol;
+ nAbsWidth += nAbsCol;
+ nRelCols--;
+ }
+ }
+ }
+
+ if( nAbsWidth < nWidth )
+ {
+ // If the table's width is larger than the absolute column widths,
+ // every column get some extra width.
+ sal_Int32 nExtraAbs = nWidth - nAbsWidth;
+ sal_Int32 nAbsLastCol =
+ aColumnWidths[(sal_uInt16)nCols-1U] + nExtraAbs;
+ for( i=0UL; i < nCols-1UL; i++ )
+ {
+ sal_Int32 nAbsCol = aColumnWidths[i];
+ sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) /
+ nAbsWidth;
+ nAbsCol += nExtraAbsCol;
+ aColumnWidths.Replace( (sal_uInt16)nAbsCol, i );
+ nAbsLastCol -= nExtraAbsCol;
+ }
+ aColumnWidths.Replace( (sal_uInt16)nAbsLastCol, (sal_uInt16)nCols-1U );
+ }
+ else if( nAbsWidth > nWidth )
+ {
+ // If the table's width is smaller than the absolute column
+ // widths, every column gets the minimum width plus some extra
+ // width.
+ sal_Int32 nExtraAbs = nWidth - (nCols * MINLAY);
+ sal_Int32 nAbsLastCol = MINLAY + nExtraAbs;
+ for( i=0UL; i < nCols-1UL; i++ )
+ {
+ sal_Int32 nAbsCol = aColumnWidths[i];
+ sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) /
+ nAbsWidth;
+ nAbsCol = MINLAY + nExtraAbsCol;
+ aColumnWidths.Replace( (sal_uInt16)nAbsCol, i );
+ nAbsLastCol -= nExtraAbsCol;
+ }
+ aColumnWidths.Replace( (sal_uInt16)nAbsLastCol, (sal_uInt16)nCols-1U );
+ }
+ }
+
+ SwTableLines& rLines =
+ pBox ? pBox->GetTabLines()
+ : pTableNode->GetTable().GetTabLines();
+
+ sal_uInt32 nStartRow = 0UL;
+ sal_uInt32 nRows = pRows->Count();
+ for( i=0UL; i<nRows; i++ )
+ {
+ // Could we split the table behind the current line?
+ sal_Bool bSplit = sal_True;
+ SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i];
+ for( sal_uInt32 j=0UL; j<nCols; j++ )
+ {
+ bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
+ if( !bSplit )
+ break;
+ }
+
+ if( bSplit )
+ {
+ SwTableLine *pLine =
+ MakeTableLine( pBox, nStartRow, 0UL, i+1UL, nCols );
+ if( pBox || nStartRow>0UL )
+ rLines.C40_INSERT( SwTableLine, pLine, rLines.Count() );
+ nStartRow = i+1UL;
+ }
+ }
+}
+
+void SwXMLTableContext::MakeTable()
+{
+ SwXMLImport& rSwImport = GetSwImport();
+
+ SwFrmFmt *pFrmFmt = pTableNode->GetTable().GetFrmFmt();
+
+ SwHoriOrient eHoriOrient = HORI_FULL;
+ sal_Bool bSetHoriOrient = sal_False;
+
+ sal_uInt16 nPrcWidth = 0U;
+ sal_Bool bCalcWidth = sal_False;
+ sal_Bool bSetWidth = sal_False;
+
+ pTableNode->GetTable().SetHeadlineRepeat( bHasHeading );
+
+ const SfxItemSet *pAutoItemSet = 0;
+ if( aStyleName.getLength() &&
+ rSwImport.FindAutomaticStyle(
+#ifdef XML_CORE_API
+ SFX_STYLE_FAMILY_FRAME, SW_STYLE_SUBFAMILY_TABLE,
+#else
+ XML_STYLE_FAMILY_TABLE_TABLE,
+#endif
+ aStyleName, &pAutoItemSet ) &&
+ pAutoItemSet )
+ {
+ const SfxPoolItem *pItem;
+ const SvxLRSpaceItem *pLRSpace = 0;
+ if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_LR_SPACE, sal_False,
+ &pItem ) )
+ pLRSpace = (const SvxLRSpaceItem *)pItem;
+
+ if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_HORI_ORIENT, sal_False,
+ &pItem ) )
+ {
+ eHoriOrient = ((const SwFmtHoriOrient *)pItem)->GetHoriOrient();
+ switch( eHoriOrient )
+ {
+ case HORI_FULL:
+ if( pLRSpace )
+ {
+ eHoriOrient = HORI_NONE;
+ bSetHoriOrient = sal_True;
+ }
+ break;
+ case HORI_LEFT:
+ if( pLRSpace )
+ {
+ eHoriOrient = HORI_LEFT_AND_WIDTH;
+ bSetHoriOrient = sal_True;
+ }
+ break;
+ }
+ }
+ else
+ {
+ bSetHoriOrient = sal_True;
+ }
+
+ if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, sal_False,
+ &pItem ) )
+ {
+ const SwFmtFrmSize *pSize = (const SwFmtFrmSize *)pItem;
+ switch( eHoriOrient )
+ {
+ case HORI_FULL:
+ nWidth = USHRT_MAX;
+ break;
+ case HORI_NONE:
+ // The width will be set in _MakeTable
+ break;
+ default:
+ if( pSize->GetWidthPercent() )
+ {
+ // The width will be set in _MakeTable
+ nPrcWidth = pSize->GetWidthPercent();
+ }
+ else
+ {
+ nWidth = pSize->GetWidth();
+ if( nWidth < GetColumnCount() * MINLAY )
+ {
+ nWidth = GetColumnCount() * MINLAY;
+ }
+ else if( nWidth > USHRT_MAX )
+ {
+ nWidth = USHRT_MAX;
+ }
+ bRelWidth = sal_False;
+ }
+ break;
+ }
+ }
+ else
+ {
+ eHoriOrient = HORI_FULL;
+ bSetHoriOrient = sal_True;
+ nWidth = USHRT_MAX;
+ }
+
+ pFrmFmt->SetAttr( *pAutoItemSet );
+ }
+ else
+ {
+ bSetHoriOrient = sal_True;
+ nWidth = USHRT_MAX;
+ }
+
+ SwTableLine *pLine1 = pTableNode->GetTable().GetTabLines()[0U];
+#ifdef XML_CORE_API
+ pBox1 = pLine1->GetTabBoxes()[0U];
+#else
+ DBG_ASSERT( pBox1 == pLine1->GetTabBoxes()[0U],
+ "Why is box 1 change?" );
+ pBox1->pSttNd = pSttNd1;
+#endif
+ pLine1->GetTabBoxes().Remove(0U);
+
+ pLineFmt = (SwTableLineFmt*)pLine1->GetFrmFmt();
+ pBoxFmt = (SwTableBoxFmt*)pBox1->GetFrmFmt();
+
+ _MakeTable();
+
+ if( bSetHoriOrient )
+ pFrmFmt->SetAttr( SwFmtHoriOrient( 0, eHoriOrient ) );
+
+ // This must be bahind the call to _MakeTable, because nWidth might be
+ // changed there.
+ pFrmFmt->LockModify();
+ SwFmtFrmSize aSize( ATT_VAR_SIZE, nWidth );
+ aSize.SetWidthPercent( (sal_Int8)nPrcWidth );
+ pFrmFmt->SetAttr( aSize );
+ pFrmFmt->UnlockModify();
+
+
+ for( sal_uInt16 i=0; i<pRows->Count(); i++ )
+ (*pRows)[i]->Dispose();
+
+ if( rSwImport.GetDoc().GetRootFrm() )
+ {
+ pTableNode->DelFrms();
+ SwNodeIndex aIdx( *pTableNode->EndOfSectionNode(), 1 );
+ pTableNode->MakeFrms( &aIdx );
+ }
+}
+
+void SwXMLTableContext::MakeTable( SwTableBox *pBox, sal_Int32 nW )
+{
+ pLineFmt = GetParentTable()->pLineFmt;
+ pBoxFmt = GetParentTable()->pBoxFmt;
+ nWidth = nW;
+ bRelWidth = GetParentTable()->bRelWidth;
+
+ _MakeTable( pBox );
+}
+
+const SwStartNode *SwXMLTableContext::InsertTableSection(
+ const SwStartNode *pPrevSttNd )
+{
+ const SwStartNode *pStNd;
+#ifdef XML_CORE_API
+ SwPaM& rPaM = GetSwImport().GetPaM();
+ if( bFirstSection )
+ {
+ // The PaM already is in the first section
+ pStNd = rPaM.GetNode()->FindTableBoxStartNode();
+ bFirstSection = sal_False;
+ }
+ else
+ {
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ const SwEndNode *pEndNd = pPrevSttNd ? pPrevSttNd->EndOfSectionNode()
+ : pTableNode->EndOfSectionNode();
+ sal_uInt32 nOffset = pPrevSttNd ? 1UL : 0UL;
+ SwNodeIndex aIdx( *pEndNd, nOffset );
+ SwTxtFmtColl *pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pStNd = rDoc.GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pColl );
+ if( !pPrevSttNd )
+ {
+ rPaM.GetPoint()->nNode.Assign( *pStNd, 1UL );
+ rPaM.GetPoint()->nContent.Assign( rPaM.GetCntntNode(), 0U );
+ }
+ }
+#else
+ Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(),
+ UNO_QUERY);
+ ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" );
+ SwXTextCursor *pTxtCrsr =
+ (SwXTextCursor*)xCrsrTunnel->getSomething(
+ SwXTextCursor::getUnoTunnelId() );
+ ASSERT( pTxtCrsr, "SwXTextCursor missing" );
+
+ if( bFirstSection )
+ {
+ // The Cursor already is in the first section
+ pStNd = pTxtCrsr->GetCrsr()->GetNode()->FindTableBoxStartNode();
+ bFirstSection = sal_False;
+ }
+ else
+ {
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ const SwEndNode *pEndNd = pPrevSttNd ? pPrevSttNd->EndOfSectionNode()
+ : pTableNode->EndOfSectionNode();
+ sal_uInt32 nOffset = pPrevSttNd ? 1UL : 0UL;
+ SwNodeIndex aIdx( *pEndNd, nOffset );
+ SwTxtFmtColl *pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
+ pStNd = rDoc.GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode,
+ pColl );
+ if( !pPrevSttNd )
+ {
+ pBox1->pSttNd = pStNd;
+ SwCntntNode *pCNd = rDoc.GetNodes()[ pStNd->GetIndex() + 1 ]
+ ->GetCntntNode();
+ SwPosition aPos( *pCNd );
+ aPos.nContent.Assign( pCNd, 0U );
+
+ Reference < XTextRange > xTextRange =
+ CreateTextRangeFromPosition( &rDoc, aPos, 0 );
+ Reference < XText > xText = xTextRange->getText();
+ Reference < XTextCursor > xTextCursor =
+ xText->createTextCursorByRange( xTextRange );
+ GetImport().GetTextImport()->SetCursor( xTextCursor );
+ }
+ }
+
+#endif
+
+ return pStNd;
+}
+
+void SwXMLTableContext::EndElement()
+{
+ if( !xParentTable.Is() )
+ {
+ MakeTable();
+#ifdef XML_CORE_API
+ GetSwImport().GetPaM().Move( fnMoveForward );
+#else
+ GetImport().GetTextImport()->SetCursor( xOldCursor );
+#endif
+ }
+}
+
+#ifndef XML_CORE_API
+class SwXMLTextImportHelper : public XMLTextImportHelper
+{
+protected:
+ virtual SvXMLImportContext *CreateTableChildContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList );
+
+public:
+ SwXMLTextImportHelper(
+ const Reference < XModel>& rModel,
+ sal_Bool bInsertM, sal_Bool bStylesOnlyM );
+ ~SwXMLTextImportHelper();
+};
+
+SwXMLTextImportHelper::SwXMLTextImportHelper(
+ const Reference < XModel>& rModel,
+ sal_Bool bInsertM, sal_Bool bStylesOnlyM ) :
+ XMLTextImportHelper( rModel, bInsertM, bStylesOnlyM )
+{
+}
+
+SwXMLTextImportHelper::~SwXMLTextImportHelper()
+{
+}
+
+SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< XAttributeList > & xAttrList )
+{
+ return new SwXMLTableContext(
+ (SwXMLImport&)rImport, nPrefix, rLocalName, xAttrList );
+}
+
+XMLTextImportHelper* SwXMLImport::CreateTextImport()
+{
+ return new SwXMLTextImportHelper( GetModel(), IsInsertMode(),
+ IsStylesOnlyMode() );
+}
+
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltbli.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.11 2000/09/18 16:05:07 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.10 2000/09/18 11:58:02 mib
+ text frames/graphics import and export continued
+
+ Revision 1.9 2000/08/24 11:16:42 mib
+ text import continued
+
+ Revision 1.8 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.7 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.6 2000/06/08 09:45:55 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.5 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.4 2000/03/13 14:33:44 mib
+ UNO3
+
+ Revision 1.3 2000/03/10 11:15:04 mib
+ #72721#: Made table import much more robust, rowspan
+
+ Revision 1.2 2000/02/17 15:17:57 mib
+ #70271#: headline repeat
+
+ Revision 1.1 2000/02/17 14:40:01 mib
+ #70271#: XML table import
+
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx
new file mode 100644
index 000000000000..fae90ba3cac8
--- /dev/null
+++ b/sw/source/filter/xml/xmltbli.hxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltbli.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _XMLTBLI_HXX
+#define _XMLTBLI_HXX
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+#if !defined(_SVSTDARR_USHORTS_DECL) || !defined(_SVSTDARR_BOOLS_DECL)
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_BOOLS
+#include <svtools/svstdarr.hxx>
+#endif
+
+class SwXMLImport;
+class SwTableNode;
+class SwTableBox;
+class SwTableLine;
+class SwStartNode;
+class SwTableBoxFmt;
+class SwTableLineFmt;
+class SwXMLTableCell_Impl;
+class SwXMLTableRows_Impl;
+
+
+#ifdef XML_CORE_API
+enum SwXMLStyleSubFamily
+{
+ SW_STYLE_SUBFAMILY_TABLE = 0x0001,
+ SW_STYLE_SUBFAMILY_TABLE_LINE = 0x0002,
+ SW_STYLE_SUBFAMILY_TABLE_BOX = 0x0004,
+ SW_STYLE_SUBFAMILY_TABLE_COL = 0x0008
+};
+#endif
+
+
+class SwXMLTableContext : public SvXMLImportContext
+{
+ ::rtl::OUString aStyleName;
+
+ SvUShorts aColumnWidths;
+ SvBools aColumnRelWidths;
+
+#ifndef XML_CORE_API
+ ::com::sun::star::uno::Reference <
+ ::com::sun::star::text::XTextCursor > xOldCursor;
+#endif
+ SwXMLTableRows_Impl *pRows;
+
+ SwTableNode *pTableNode;
+ SwTableBox *pBox1;
+ const SwStartNode *pSttNd1;
+
+ SwTableBoxFmt *pBoxFmt;
+ SwTableLineFmt *pLineFmt;
+
+ SvXMLImportContextRef xParentTable; // if table ia a sub table
+
+ sal_Bool bFirstSection : 1;
+ sal_Bool bRelWidth : 1;
+ sal_Bool bHasHeading : 1;
+
+ sal_uInt32 nCurRow;
+ sal_uInt32 nCurCol;
+ sal_Int32 nWidth;
+
+ SwTableBox *NewTableBox( const SwStartNode *pStNd,
+ SwTableLine *pUpper );
+ SwTableBox *MakeTableBox( SwTableLine *pUpper,
+ const SwXMLTableCell_Impl *pStartNode,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
+ SwTableBox *MakeTableBox( SwTableLine *pUpper,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
+ SwTableLine *MakeTableLine( SwTableBox *pUpper,
+ sal_uInt32 nTopRow, sal_uInt32 nLeftCol,
+ sal_uInt32 nBottomRow, sal_uInt32 nRightCol );
+
+ void _MakeTable( SwTableBox *pBox=0 );
+ void MakeTable( SwTableBox *pBox, sal_Int32 nWidth );
+ void MakeTable();
+
+ inline SwXMLTableContext *GetParentTable() const;
+
+ const SwStartNode *GetPrevStartNode( sal_uInt32 nRow,
+ sal_uInt32 nCol ) const;
+ inline const SwStartNode *GetLastStartNode() const;
+ void FixRowSpan( sal_uInt32 nRow, sal_uInt32 nCol, sal_uInt32 nColSpan );
+ void ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol );
+
+public:
+
+ SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+ SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ SwXMLTableContext *pTable );
+
+ virtual ~SwXMLTableContext();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+ void InsertColumn( sal_Int32 nWidth, sal_Bool bRelWidth );
+ sal_Int32 GetColumnWidth( sal_uInt32 nCol, sal_uInt32 nColSpan=1UL ) const;
+ inline sal_uInt32 GetColumnCount() const;
+
+ sal_Bool IsInsertCellPossible() const { return nCurCol < GetColumnCount(); }
+ sal_Bool IsInsertColPossible() const { return nCurCol < USHRT_MAX; }
+ sal_Bool IsInsertRowPossible() const { return nCurRow < USHRT_MAX; }
+
+
+ void InsertCell( const ::rtl::OUString& rStyleName,
+ sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U,
+ const SwStartNode *pStNd=0,
+ SwXMLTableContext *pTable=0 );
+ void InsertRow( const ::rtl::OUString& rStyleName,
+ sal_Bool bInHead );
+ void FinishRow();
+ SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol ) const;
+ const SwStartNode *InsertTableSection( const SwStartNode *pPrevSttNd=0 );
+
+ virtual void EndElement();
+};
+
+inline SwXMLTableContext *SwXMLTableContext::GetParentTable() const
+{
+ return (SwXMLTableContext *)&xParentTable;
+}
+
+inline sal_uInt32 SwXMLTableContext::GetColumnCount() const
+{
+ return aColumnWidths.Count();
+}
+
+inline const SwStartNode *SwXMLTableContext::GetLastStartNode() const
+{
+ return GetPrevStartNode( 0UL, GetColumnCount() );
+}
+
+
+#endif
diff --git a/sw/source/filter/xml/xmltext.cxx b/sw/source/filter/xml/xmltext.cxx
new file mode 100644
index 000000000000..ff2578915dab
--- /dev/null
+++ b/sw/source/filter/xml/xmltext.cxx
@@ -0,0 +1,1647 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltext.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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
+
+#include "hintids.hxx"
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _RSCSFX_HXX
+#include <rsc/rscsfx.hxx>
+#endif
+
+#ifndef _XMLOFF_NMSPMAP_HXX
+#include <xmloff/nmspmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLNMSPE_HXX
+#include <xmloff/xmlnmspe.hxx>
+#endif
+
+#ifndef _XMLOFF_I18NMAP_HXX
+#include <xmloff/i18nmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITEM_HXX
+#include <xmloff/xmlitem.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLIMPIT_HXX
+#include <xmloff/xmlimpit.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLITMPR_HXX
+#include <xmloff/xmlexpit.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLKYWD_HXX
+#include <xmloff/xmlkywd.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLASTPL_HXX
+#include <xmloff/xmlastpl.hxx>
+#endif
+#ifndef _XMLOFF_TXTIMP_HXX
+#include <xmloff/txtimp.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTFLDE_HXX
+#include <xmloff/txtflde.hxx>
+#endif
+
+#ifndef _XMLOFF_TXTVFLDI_HXX
+//#include <xmloff/txtvfldi.hxx>
+#endif
+
+#ifndef _UNOFIELD_HXX
+#include <unofield.hxx>
+#endif
+
+#ifndef _SVX_FONTITEM_HXX //autogen wg. SvxFontItem
+#include <svx/fontitem.hxx>
+#endif
+
+#ifndef _NDTXT_HXX //autogen wg. SwTxtNode
+#include <ndtxt.hxx>
+#endif
+#ifndef _SECTION_HXX //autogen wg. SwSection
+#include <section.hxx>
+#endif
+#ifndef _DOC_HXX //autogen wg. SwDoc
+#include <doc.hxx>
+#endif
+#ifndef _PAM_HXX //autogen wg. SwPaM
+#include <pam.hxx>
+#endif
+#ifndef _TXATBASE_HXX
+#include <txatbase.hxx>
+#endif
+#ifndef _CHARATR_HXX
+#include <charatr.hxx>
+#endif
+#ifndef _CHARFMT_HXX
+#include <charfmt.hxx>
+#endif
+#ifndef _PARATR_HXX
+#include <paratr.hxx>
+#endif
+#ifndef _FLDBAS_HXX
+#include <fldbas.hxx>
+#endif
+#ifndef _FMTFLD_HXX
+#include <fmtfld.hxx>
+#endif
+#ifndef _FCHRFMT_HXX
+#include <fchrfmt.hxx>
+#endif
+#ifndef _UNOSTYLE_HXX
+#include "unostyle.hxx"
+#endif
+
+#ifndef _XMLECTXT_HXX
+#include "xmlectxt.hxx"
+#endif
+#ifndef _HINTLIST_HXX
+#include "hintlist.hxx"
+#endif
+#ifndef _XMLIMP_HXX
+#include "xmlimp.hxx"
+#endif
+#ifndef _XMLEXP_HXX
+#include "xmlexp.hxx"
+#endif
+#ifndef _XMLNUM_HXX
+#include "xmlnum.hxx"
+#endif
+#ifndef _XMLTBLI_HXX
+#include "xmltbli.hxx"
+#endif
+#ifndef _XMLFMTE_HXX
+#include "xmlfmte.hxx"
+#endif
+#ifndef _XMLTEXTI_HXX
+#include "xmltexti.hxx"
+#endif
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+
+#ifdef XML_CORE_API
+enum SwXMLTextPElemTokens
+{
+ XML_TOK_SW_SPAN,
+ XML_TOK_SW_TAB_STOP,
+ XML_TOK_SW_LINE_BREAK,
+ XML_TOK_SW_S,
+ XML_TOK_SW_P_ELEM_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] =
+{
+ { XML_NAMESPACE_TEXT, sXML_span, XML_TOK_SW_SPAN },
+ { XML_NAMESPACE_TEXT, sXML_tab_stop, XML_TOK_SW_TAB_STOP },
+ { XML_NAMESPACE_TEXT, sXML_line_break, XML_TOK_SW_LINE_BREAK },
+ { XML_NAMESPACE_TEXT, sXML_s, XML_TOK_SW_S },
+ XML_TOKEN_MAP_END
+};
+
+const SvXMLTokenMap& SwXMLImport::GetTextPElemTokenMap()
+{
+ if( !pTextPElemTokenMap )
+ pTextPElemTokenMap = new SvXMLTokenMap( aTextPElemTokenMap );
+
+ return *pTextPElemTokenMap;
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLHint_Impl
+{
+ SfxItemSet aItemSet;
+ xub_StrLen nStart;
+ xub_StrLen nEnd;
+
+public:
+
+ SwXMLHint_Impl( SfxItemPool& rPool, xub_StrLen nPos ) :
+ aItemSet( rPool, RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_TXTATR_BEGIN, RES_TXTATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1, 0 ),
+ nStart( nPos ),
+ nEnd( nPos )
+ {}
+
+ SfxItemSet& GetItemSet() { return aItemSet; }
+ xub_StrLen GetStart() const { return nStart; }
+ xub_StrLen GetEnd() const { return nEnd; }
+ void SetEnd( xub_StrLen nPos ) { nEnd = nPos; }
+};
+
+typedef SwXMLHint_Impl *SwXMLHint_ImplPtr;
+SV_DECL_PTRARR_DEL( SwXMLHints_Impl, SwXMLHint_ImplPtr, 5, 5 )
+SV_IMPL_PTRARR( SwXMLHints_Impl, SwXMLHint_ImplPtr )
+
+// ---------------------------------------------------------------------
+
+class SwXMLImpCharContext_Impl : public SvXMLImportContext
+{
+public:
+
+ SwXMLImpCharContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Unicode c,
+ sal_Bool bCount );
+
+ virtual ~SwXMLImpCharContext_Impl();
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLImpCharContext_Impl::SwXMLImpCharContext_Impl(
+ SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Unicode c,
+ sal_Bool bCount ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ sal_uInt16 nCount = 1;
+
+ if( bCount )
+ {
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ if( XML_NAMESPACE_TEXT == nPrefix &&
+ aLocalName.compareToAscii( sXML_c ) == 0 )
+ {
+ sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32();
+ if( nTmp > 0L )
+ {
+ if( nTmp > USHRT_MAX )
+ nCount = USHRT_MAX;
+ else
+ nCount = (sal_uInt16)nTmp;
+ }
+ }
+ }
+ }
+
+ if( 1U == nCount )
+ {
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(), c );
+ }
+ else
+ {
+ OUStringBuffer sBuff( nCount );
+ while( nCount-- )
+ sBuff.append( c );
+
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(),
+ sBuff.makeStringAndClear() );
+ }
+}
+
+SwXMLImpCharContext_Impl::~SwXMLImpCharContext_Impl()
+{
+}
+
+// ---------------------------------------------------------------------
+
+class SwXMLImpSpanContext_Impl : public SvXMLImportContext
+{
+ SwXMLHints_Impl& rHints;
+ SwXMLHint_Impl *pHint;
+
+ sal_Bool& rIgnoreLeadingSpace;
+
+public:
+
+ SwXMLImpSpanContext_Impl(
+ SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLHints_Impl& rHnts,
+ sal_Bool& rIgnLeadSpace );
+
+ virtual ~SwXMLImpSpanContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+
+ virtual void Characters( const OUString& rChars );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+
+SwXMLImpSpanContext_Impl::SwXMLImpSpanContext_Impl(
+ SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ SwXMLHints_Impl& rHnts,
+ sal_Bool& rIgnLeadSpace ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ rHints( rHnts ),
+ rIgnoreLeadingSpace( rIgnLeadSpace ),
+ pHint( 0 )
+{
+ OUString aStyleName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ if( XML_NAMESPACE_TEXT == nPrefix &&
+ aLocalName.compareToAscii( sXML_style_name ) == 0 )
+ aStyleName = xAttrList->getValueByIndex( i );
+ }
+
+ if( aStyleName.getLength() )
+ {
+ SwDoc& rDoc = GetSwImport().GetDoc();
+
+ // try to find a matching automatic style
+ const SfxItemSet *pAutoItemSet = 0;
+ OUString sParentStyle;
+ if( GetSwImport().FindAutomaticStyle( SFX_STYLE_FAMILY_CHAR,
+ aStyleName, &pAutoItemSet,
+ &sParentStyle ) )
+ {
+ aStyleName = sParentStyle;
+ }
+
+ // if an automatic style has not been found or has been found and
+ // has a parent style, try to find this one.
+ SwCharFmt *pCharFmt = 0;
+ if( aStyleName.getLength() )
+ {
+ const SvI18NMap& rI18NMap = GetSwImport().GetI18NMap();
+ String sName( rI18NMap.Get( SFX_STYLE_FAMILY_CHAR,
+ aStyleName) );
+ pCharFmt = rDoc.FindCharFmtByName( sName );
+ }
+
+ if( pAutoItemSet || pCharFmt )
+ {
+ xub_StrLen nPos =
+ GetSwImport().GetPaM().GetPoint()->nContent.GetIndex();
+ pHint = new SwXMLHint_Impl( rDoc.GetAttrPool(), nPos );
+ rHints.Insert( pHint, rHints.Count() );
+ if( pAutoItemSet )
+ pHint->GetItemSet().Put( *pAutoItemSet );
+ if( pCharFmt )
+ {
+ SwFmtCharFmt aCharFmt( pCharFmt );
+ pHint->GetItemSet().Put( aCharFmt );
+ }
+ }
+ }
+}
+
+SwXMLImpSpanContext_Impl::~SwXMLImpSpanContext_Impl()
+{
+ if( pHint )
+ {
+ xub_StrLen nPos =
+ GetSwImport().GetPaM().GetPoint()->nContent.GetIndex();
+ pHint->SetEnd( nPos );
+ }
+}
+
+SvXMLImportContext *SwXMLImpSpanContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTextPElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_SPAN:
+ pContext = new SwXMLImpSpanContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ rHints,
+ rIgnoreLeadingSpace );
+ break;
+
+ case XML_TOK_SW_TAB_STOP:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0009, sal_False );
+ rIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_LINE_BREAK:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x000A, sal_False );
+ rIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_S:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0020, sal_True );
+ break;
+
+ default:
+ // ignore unknown content
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ break;
+ }
+
+ return pContext;
+}
+
+void SwXMLImpSpanContext_Impl::Characters( const OUString& rChars )
+{
+ sal_Int32 nLen = rChars.getLength();
+ OUStringBuffer sChars( nLen );
+
+ for( sal_Int32 i=0; i < nLen; i++ )
+ {
+ sal_Unicode c = rChars[i];
+ switch( c )
+ {
+ case 0x20:
+ case 0x09:
+ case 0x0a:
+ case 0x0d:
+ if( !rIgnoreLeadingSpace )
+ sChars.append( (sal_Unicode)0x20 );
+ rIgnoreLeadingSpace = sal_True;
+ break;
+ default:
+ rIgnoreLeadingSpace = sal_False;
+ sChars.append( c );
+ break;
+ }
+ }
+
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(),
+ sChars.makeStringAndClear() );
+}
+
+// ---------------------------------------------------------------------
+
+enum SwXMLTextPAttrTokens
+{
+ XML_TOK_SW_P_STYLE_NAME,
+ XML_TOK_SW_P_COND_STYLE_NAME,
+ XML_TOK_SW_P_LEVEL,
+ XML_TOK_SW_P_END=XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] =
+{
+ { XML_NAMESPACE_TEXT, sXML_style_name, XML_TOK_SW_P_STYLE_NAME },
+ { XML_NAMESPACE_TEXT, sXML_cond_style_name,
+ XML_TOK_SW_P_COND_STYLE_NAME },
+ { XML_NAMESPACE_TEXT, sXML_level, XML_TOK_SW_P_LEVEL },
+ XML_TOKEN_MAP_END
+};
+
+SwXMLParaContext::SwXMLParaContext(
+ SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bHead ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pItemSet( 0 ),
+ pHints( 0 ),
+ bIgnoreLeadingSpace( sal_True ),
+ bHeading( bHead )
+{
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTextPAttrTokenMap();
+
+ OUString aStyleName, aCondStyleName;
+ sal_uInt8 nOutlineLevel = NO_NUMBERING;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ const OUString& rValue = xAttrList->getValueByIndex( i );
+
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ switch( rTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_SW_P_STYLE_NAME:
+ aStyleName = rValue;
+ break;
+ case XML_TOK_SW_P_COND_STYLE_NAME:
+ aCondStyleName = rValue;
+ break;
+ case XML_TOK_SW_P_LEVEL:
+ {
+ sal_Int32 nTmp = rValue.toInt32() - 1L;
+ if( nTmp >= 0L )
+ {
+ if( nTmp > MAXLEVEL )
+ nTmp = MAXLEVEL;
+ nOutlineLevel = (sal_uInt8)nTmp;
+ }
+ }
+
+ }
+ }
+
+ if( aCondStyleName.getLength() )
+ {
+ OUString sTmp( aStyleName );
+ aStyleName = aCondStyleName;
+ aCondStyleName = sTmp;
+ }
+
+ if( aStyleName.getLength() )
+ {
+ const SfxItemSet *pAutoItemSet = 0;
+ OUString sParentStyle;
+ if( GetSwImport().FindAutomaticStyle( SFX_STYLE_FAMILY_PARA,
+ aStyleName, &pAutoItemSet,
+ &sParentStyle ) )
+ {
+ aStyleName = sParentStyle;
+ }
+
+ if( pAutoItemSet )
+ {
+ if( !pItemSet )
+ pItemSet = new SfxItemSet( GetSwImport().GetDoc().GetAttrPool(),
+ aTxtNodeSetRange );
+ pItemSet->Put( *pAutoItemSet );
+ }
+
+ if( aStyleName.getLength() )
+ {
+ const SvI18NMap& rI18NMap = GetSwImport().GetI18NMap();
+ String sName( rI18NMap.Get( SFX_STYLE_FAMILY_PARA, aStyleName ) );
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ SwTxtFmtColl *pColl = rDoc.FindTxtFmtCollByName( sName );
+ if( pColl )
+ {
+ sal_uInt8 nCollOutlineLevel = pColl->GetOutlineLevel();
+ if( bHeading && !( GetSwImport().IsInsertMode() ||
+ GetSwImport().IsStylesOnlyMode() ) &&
+ NO_NUMBERING != nOutlineLevel &&
+ ( NO_NUMBERING == nCollOutlineLevel ||
+ GetRealLevel(nCollOutlineLevel) != nOutlineLevel ) )
+ {
+ sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count();
+ for( sal_uInt16 i=0; i<nArrLen; i++ )
+ {
+ SwTxtFmtColl* pCur = (*rDoc.GetTxtFmtColls())[i];
+ sal_uInt8 nCurLevel = pCur->GetOutlineLevel();
+ if( nCurLevel != NO_NUMBERING &&
+ GetRealLevel(nCurLevel) == nOutlineLevel )
+ {
+ if( pColl != pCur )
+ pCur->SetOutlineLevel( NO_NUMBERING );
+ break;
+ }
+ }
+ pColl->SetOutlineLevel( nOutlineLevel );
+ }
+ rDoc.SetTxtFmtColl( GetSwImport().GetPaM(), pColl );
+ }
+ }
+ }
+}
+
+SwXMLParaContext::~SwXMLParaContext()
+{
+#ifndef PRODUCT
+ SwCntntNode *pTTTNd = GetSwImport().GetPaM().GetNode()->GetCntntNode();
+#endif
+
+ // Start a new node.
+ SwDoc& rDoc = GetSwImport().GetDoc();
+ rDoc.AppendTxtNode( *GetSwImport().GetPaM().GetPoint() );
+
+ // Create a "attribute" PaM and move it to the previous node.
+ SwPaM aPaM( GetSwImport().GetPaM() );
+ aPaM.Move( fnMoveBackward, fnGoCntnt );
+ aPaM.SetMark();
+ SwCntntNode *pCNd = aPaM.GetNode()->GetCntntNode();
+ ASSERT( pCNd,
+ "SwXMLParaContext::~SwXMLParaContext: no content node" );
+#ifndef PRODUCT
+ ASSERT( pTTTNd == pCNd,
+ "SwXMLParaContext::~SwXMLParaContext: wrong content node" );
+ ASSERT( (const SwIndexReg*)pTTTNd == aPaM.GetPoint()->nContent.GetIdxReg(),
+ "SwXMLParaContext::~SwXMLParaContext: wrong content node" );
+#endif
+
+ aPaM.GetPoint()->nContent.Assign( pCNd, 0 );
+
+ // Set paragraph attributes.
+ if( pItemSet )
+ rDoc.Insert( aPaM, *pItemSet );
+ delete pItemSet;
+
+ // Set numbering rules
+ SwTxtNode *pTxtNd = pCNd->GetTxtNode();
+ const SwNumRule *pNumRule = pTxtNd->GetNumRule();
+ if( GetSwImport().IsInList() )
+ {
+ SwXMLListBlockContext *pListBlock = GetSwImport().GetListBlock();
+ String sStyleName( GetSwImport().GetI18NMap().Get(
+ SFX_STYLE_FAMILY_PSEUDO,pListBlock->GetStyleName()) );
+ if( !pNumRule ||
+ ( !pListBlock->HasGeneratedStyle() &&
+ pNumRule->GetName() != sStyleName ) )
+ {
+ rDoc.Insert( aPaM, SwNumRuleItem( sStyleName ) );
+ pNumRule = pTxtNd->GetNumRule();
+ }
+
+ ASSERT( pNumRule, "SwXMLParaContext::~SwXMLParaContext: no num rule" );
+ GetSwImport().SetUsed( *pNumRule );
+
+ SwXMLListItemContext *pListItem = GetSwImport().GetListItem();
+
+ sal_uInt8 nLevel = pListBlock->GetLevel() > MAXLEVEL
+ ? MAXLEVEL
+ : (sal_uInt8)pListBlock->GetLevel();
+ if( !pListItem )
+ nLevel |= NO_NUMLEVEL;
+
+ SwNodeNum aNodeNum( nLevel );
+ if( pListBlock->IsRestartNumbering() )
+ {
+ aNodeNum.SetStart();
+ pListBlock->ResetRestartNumbering();
+ }
+ if( pListItem && pListItem->HasStartValue() )
+ {
+ aNodeNum.SetSetValue( pListItem->GetStartValue() );
+ }
+
+ pTxtNd->UpdateNum( aNodeNum );
+
+ GetSwImport().SetListItem( 0 );
+ }
+ else
+ {
+ // If the paragraph is not in a list but its style, remove it from
+ // the list.
+ if( pNumRule )
+ rDoc.Insert( aPaM, SwNumRuleItem() );
+ }
+
+ if( pHints && pHints->Count() )
+ {
+ for( sal_uInt16 i=0; i<pHints->Count(); i++ )
+ {
+ SwXMLHint_Impl *pHint = (*pHints)[i];
+ xub_StrLen nStt = pHint->GetStart();
+ xub_StrLen nEnd = pHint->GetEnd();
+ if( nStt != nEnd )
+ {
+ aPaM.GetPoint()->nContent.Assign( pCNd, nEnd );
+ aPaM.SetMark();
+ aPaM.GetPoint()->nContent.Assign( pCNd, nStt );
+ rDoc.Insert( aPaM, pHint->GetItemSet() );
+ }
+ }
+ }
+ delete pHints;
+}
+
+SvXMLImportContext *SwXMLParaContext::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetTextPElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_SPAN:
+ if( !pHints )
+ pHints = new SwXMLHints_Impl;
+ pContext = new SwXMLImpSpanContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ *pHints, bIgnoreLeadingSpace );
+ break;
+
+ case XML_TOK_SW_TAB_STOP:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0009, sal_False );
+ bIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_LINE_BREAK:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x000A, sal_False );
+ bIgnoreLeadingSpace = sal_False;
+ break;
+
+ case XML_TOK_SW_S:
+ pContext = new SwXMLImpCharContext_Impl( GetSwImport(), nPrefix,
+ rLocalName, xAttrList,
+ 0x0020, sal_True );
+ break;
+
+ default:
+ // ignore unknown content
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ break;
+ }
+
+ return pContext;
+}
+
+void SwXMLParaContext::Characters( const OUString& rChars )
+{
+ sal_Int32 nLen = rChars.getLength();
+ OUStringBuffer sChars( nLen );
+
+ for( sal_Int32 i=0; i < nLen; i++ )
+ {
+ sal_Unicode c = rChars[ i ];
+ switch( c )
+ {
+ case 0x20:
+ case 0x09:
+ case 0x0a:
+ case 0x0d:
+ if( !bIgnoreLeadingSpace )
+ sChars.append( (sal_Unicode)0x20 );
+ bIgnoreLeadingSpace = sal_True;
+ break;
+ default:
+ bIgnoreLeadingSpace = sal_False;
+ sChars.append( c );
+ break;
+ }
+ }
+
+ GetSwImport().GetDoc().Insert( GetSwImport().GetPaM(),
+ sChars.makeStringAndClear() );
+}
+
+const SvXMLTokenMap& SwXMLImport::GetTextPAttrTokenMap()
+{
+ if( !pTextPAttrTokenMap )
+ pTextPAttrTokenMap = new SvXMLTokenMap( aTextPAttrTokenMap );
+
+ return *pTextPAttrTokenMap;
+}
+#endif
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+static __FAR_DATA SvXMLTokenMapEntry aBodyElemTokenMap[] =
+{
+ { XML_NAMESPACE_TEXT, sXML_p, XML_TOK_SW_P },
+ { XML_NAMESPACE_TEXT, sXML_h, XML_TOK_SW_H },
+ { XML_NAMESPACE_TEXT, sXML_ordered_list, XML_TOK_SW_ORDERED_LIST },
+ { XML_NAMESPACE_TEXT, sXML_unordered_list, XML_TOK_SW_UNORDERED_LIST },
+ { XML_NAMESPACE_TABLE,sXML_table, XML_TOK_TABLE_TABLE },
+ { XML_NAMESPACE_TABLE,sXML_sub_table, XML_TOK_TABLE_SUBTABLE },
+ XML_TOKEN_MAP_END
+};
+#endif
+
+class SwXMLBodyContext_Impl : public SvXMLImportContext
+{
+#ifdef XML_CORE_API
+ const SwXMLImport& GetSwImport() const
+ { return (const SwXMLImport&)GetImport(); }
+#endif
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+
+public:
+
+ SwXMLBodyContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName );
+ virtual ~SwXMLBodyContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList );
+};
+
+SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+}
+
+SwXMLBodyContext_Impl::~SwXMLBodyContext_Impl()
+{
+}
+
+SvXMLImportContext *SwXMLBodyContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+#ifndef XML_CORE_API
+ pContext = GetSwImport().GetTextImport()->CreateTextChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList,
+ XML_TEXT_TYPE_BODY );
+#else
+ const SvXMLTokenMap& rTokenMap = GetSwImport().GetBodyElemTokenMap();
+ sal_Bool bOrdered = sal_False;
+ sal_Bool bHeading = sal_False;
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ {
+ case XML_TOK_SW_H:
+ bHeading = sal_True;
+ case XML_TOK_SW_P:
+ pContext = new SwXMLParaContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bHeading );
+ break;
+ case XML_TOK_SW_ORDERED_LIST:
+ bOrdered = sal_True;
+ case XML_TOK_SW_UNORDERED_LIST:
+ pContext = new SwXMLListBlockContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList, bOrdered );
+ break;
+ case XML_TOK_TABLE_TABLE:
+ if( !GetSwImport().GetPaM().GetNode()->FindTableNode() )
+ pContext = new SwXMLTableContext( GetSwImport(),nPrefix, rLocalName,
+ xAttrList );
+ break;
+ }
+#endif
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+#ifdef XML_CORE_API
+const SvXMLTokenMap& SwXMLImport::GetBodyElemTokenMap()
+{
+ if( !pBodyElemTokenMap )
+ pBodyElemTokenMap = new SvXMLTokenMap( aBodyElemTokenMap );
+
+ return *pBodyElemTokenMap;
+}
+#endif
+
+SvXMLImportContext *SwXMLImport::CreateBodyContext(
+ const OUString& rLocalName )
+{
+ // styles nun einfuegen!
+ InsertStyles();
+
+ SvXMLImportContext *pContext = 0;
+
+ if( !IsStylesOnlyMode() )
+ pContext = new SwXMLBodyContext_Impl( *this, XML_NAMESPACE_OFFICE,
+ rLocalName );
+ else
+ pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE,
+ rLocalName );
+
+ return pContext;
+}
+
+// ---------------------------------------------------------------------
+
+#ifdef XML_CORE_API
+class SwXMLHintEndPosList : public SwHintEndPosList
+{
+ OUString sQSpan;
+ SwXMLExport& rExport;
+
+public:
+
+ SwXMLHintEndPosList( SwXMLExport& rExp );
+ ~SwXMLHintEndPosList();
+
+ void Insert( const SfxPoolItem& rItem, xub_StrLen nStart, xub_StrLen nEnd );
+
+ sal_Bool HasStartingOrEndingHints( xub_StrLen nPos );
+
+ sal_Bool ExportStartingHints( xub_StrLen nPos );
+ sal_Bool ExportEndingHints( xub_StrLen nPos );
+};
+
+SwXMLHintEndPosList::SwXMLHintEndPosList( SwXMLExport& rExp ) :
+ rExport( rExp )
+{
+ OUString sLName( OUString::createFromAscii( sXML_span ) );
+ sQSpan = rExp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT, sLName );
+}
+
+SwXMLHintEndPosList::~SwXMLHintEndPosList()
+{
+}
+
+void SwXMLHintEndPosList::Insert( const SfxPoolItem& rItem,
+ xub_StrLen nStart, xub_StrLen nEnd )
+{
+ // empty hints will be ignored
+ if( nStart != nEnd )
+ {
+ InsertHint( rItem, nStart, nEnd );
+ }
+}
+
+sal_Bool SwXMLHintEndPosList::ExportStartingHints( xub_StrLen nPos )
+{
+ sal_Bool bRet = sal_False;
+
+ // Hints in the start list are sorted ascending.
+
+ sal_uInt16 nCount = GetStartingCount();
+ for( sal_uInt16 i=0; i< nCount; i++ )
+ {
+ SwHintSttEndPos *pPos = GetStartingHint( i );
+ xub_StrLen nStart = pPos->GetStart();
+ if( nStart > nPos )
+ {
+ // This and all following hint will be started later
+ break;
+ }
+ else if( nStart == nPos )
+ {
+ // export hint's start
+// if( bIWSOutside )
+// rExport.GetDocHandler()->ignorableWhitespace( rExport.sWS );
+ const SfxPoolItem& rItem = pPos->GetItem();
+ if( (rItem.Which() >= RES_CHRATR_BEGIN &&
+ rItem.Which() < RES_CHRATR_END) ||
+ (rItem.Which() >= RES_UNKNOWNATR_BEGIN &&
+ rItem.Which() < RES_UNKNOWNATR_END) )
+ {
+ SfxItemSet aItemSet( rExport.GetDoc().GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END - 1,
+ 0 );
+ aItemSet.Put( rItem );
+ OUString sName( rExport.GetItemSetAutoStylePool().Find(
+ SFX_STYLE_FAMILY_CHAR, aItemSet ) );
+ ASSERT( sName.getLength(), "no automatic style found" );
+ if( sName.getLength() )
+ rExport.AddAttribute( XML_NAMESPACE_TEXT, sXML_style_name,
+ sName );
+ }
+ else
+ {
+ rExport.GetParaItemMapper().exportXML(
+ rExport.GetAttrList(), rItem,
+ rExport.GetTwipUnitConverter(),
+ rExport.GetNamespaceMap() );
+ }
+
+ rExport.GetDocHandler()->startElement( sQSpan,
+ rExport.GetXAttrList() );
+ rExport.ClearAttrList();
+
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool SwXMLHintEndPosList::ExportEndingHints( xub_StrLen nPos )
+{
+ sal_Bool bRet = sal_False;
+
+ // Hints in the end list are sorted ascending
+ sal_uInt16 i=0;
+ while( i < GetEndingCount() )
+ {
+ SwHintSttEndPos *pPos = GetEndingHint( i );
+ xub_StrLen nEnd = pPos->GetEnd();
+
+ if( STRING_LEN==nPos || nEnd == nPos )
+ {
+// if( bIgnWS )
+// rExport.GetDocHandler()->ignorableWhitespace( rExport.sWS );
+ rExport.GetDocHandler()->endElement( sQSpan );
+ _RemoveHint( i );
+
+ bRet = sal_True;
+ }
+ else if( nEnd > nPos )
+ {
+ // This and all hints that are following will be closed later
+ break;
+ }
+ else
+ {
+ // This hint should have been exported already!
+ ASSERT( nEnd >= nPos,
+ "SwXMLHintEndPosLst::OutEndAttrs: hint overseen" );
+ i++;
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool SwXMLHintEndPosList::HasStartingOrEndingHints( xub_StrLen nPos )
+{
+ sal_Bool bRet = sal_False;
+
+ // Hints in the start list are sorted ascending.
+
+ sal_uInt16 nCount = GetStartingCount();
+ for( sal_uInt16 i=0; i< nCount; i++ )
+ {
+ SwHintSttEndPos *pPos = GetStartingHint( i );
+ xub_StrLen nStart = pPos->GetStart();
+ if( nStart == nPos )
+ {
+ bRet = sal_True;
+ break;
+ }
+ else if( nStart > nPos )
+ {
+ // This and all following hint will be started later
+ break;
+ }
+ }
+
+ if( !bRet )
+ {
+ nCount = GetEndingCount();
+ for( i=0; i < nCount; i++ )
+ {
+ SwHintSttEndPos *pPos = GetEndingHint( i );
+ xub_StrLen nEnd = pPos->GetEnd();
+
+ if( nEnd == nPos )
+ {
+ bRet = sal_True;
+ break;
+ }
+ else if( nEnd > nPos )
+ {
+ // This and all hints that are following will be closed later
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void SwXMLExport::ExportTxtNode( const SwTxtNode& rTxtNd, xub_StrLen nStart,
+ xub_StrLen nEnd, sal_Bool bExportWholeNode )
+{
+ // <text:p ...>
+ CheckAttrList();
+
+ const SfxItemSet *pItemSet = rTxtNd.GetpSwAttrSet();
+
+ // text:style-name="..."
+ // If the text collection is a conditional style, the current style
+ // is written as style-name rather than the master style.
+ const SwFmtColl& rColl = rTxtNd.GetAnyFmtColl();
+ OUString sStyleName( rColl.GetName() );
+ if( pItemSet )
+ sStyleName = FindParaAutoStyle( sStyleName, *pItemSet );
+ else
+ sStyleName = SwXStyleFamilies::GetProgrammaticName( sStyleName,
+ SFX_STYLE_FAMILY_PARA );
+ ASSERT( sStyleName.getLength(), "auto para style not found" );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_style_name, sStyleName );
+
+ sal_uInt8 nOutlineLevel = ((const SwTxtFmtColl&)rColl).GetOutlineLevel();
+
+ // text:cond-style-name="..."
+ if( rTxtNd.GetCondFmtColl() )
+ {
+ // master style
+ const SwFmtColl *pColl = rTxtNd.GetFmtColl();
+ OUString sCondStyleName;
+ if( &rColl == pColl )
+ {
+ sCondStyleName = sStyleName;
+ }
+ else
+ {
+ sCondStyleName = pColl->GetName();
+ if( pItemSet )
+ sCondStyleName = FindParaAutoStyle( sCondStyleName, *pItemSet );
+ else
+ sCondStyleName = SwXStyleFamilies::GetProgrammaticName(
+ sCondStyleName,
+ SFX_STYLE_FAMILY_PARA );
+ ASSERT( sCondStyleName.getLength(), "auto para style not found" );
+ nOutlineLevel = ((const SwTxtFmtColl *)pColl)->GetOutlineLevel();
+ }
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_cond_style_name,
+ sCondStyleName );
+ }
+
+ if( NO_NUMBERING != nOutlineLevel )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( GetRealLevel(nOutlineLevel)+1L );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_level,
+ sTmp.makeStringAndClear() );
+ }
+
+ {
+ const sal_Char *pElem =
+ NO_NUMBERING == nOutlineLevel ? sXML_p : sXML_h;
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, pElem, sal_True,
+ sal_False );
+ xub_StrLen nOffset = 0;
+
+ const String& rText = rTxtNd.GetTxt();
+ xub_StrLen nPos = pCurPaM->GetPoint()->nContent.GetIndex();
+ xub_StrLen nEndPos = rText.Len();
+ if( pCurPaM->GetPoint()->nNode == pCurPaM->GetMark()->nNode )
+ nEndPos = pCurPaM->GetMark()->nContent.GetIndex();
+
+ const SwpHints *pHints = rTxtNd.GetpSwpHints();
+ sal_uInt16 nHintCount = pHints ? pHints->Count() : 0;
+ sal_uInt16 nHintPos = 0;
+ SwXMLHintEndPosList aHintLst( *this );
+
+ // export all hints before the current text position
+ const SwTxtAttr * pTxtAttr = 0;
+ if( nHintCount && nPos > *( pTxtAttr = (*pHints)[0] )->GetStart() )
+ {
+ do
+ {
+ nHintPos++;
+
+ if( pTxtAttr->GetEnd() )
+ {
+ DBG_ASSERT( RES_TXTATR_FIELD == pTxtAttr->Which(),
+ "ignore fields" );
+ xub_StrLen nHtEnd = *pTxtAttr->GetEnd(),
+ nHtStt = *pTxtAttr->GetStart();
+ if( (!bExportWholeNode && nHtEnd <= nPos) ||
+ nHtEnd == nHtStt )
+ continue;
+
+ // add hint to hint list
+ if( bExportWholeNode )
+ {
+ aHintLst.Insert( pTxtAttr->GetAttr(), nHtStt + nOffset,
+ nHtEnd + nOffset );
+ }
+ else
+ {
+ xub_StrLen nTmpStt = nHtStt < nPos ? nPos : nHtStt;
+ xub_StrLen nTmpEnd = nHtEnd < nEndPos ? nHtEnd : nEndPos;
+ aHintLst.Insert( pTxtAttr->GetAttr(), nTmpStt + nOffset,
+ nTmpEnd + nOffset );
+ }
+ }
+
+ }
+ while( nHintPos < nHintCount &&
+ nPos > *( pTxtAttr = (*pHints)[nHintPos ] )->GetStart() );
+ }
+
+ xub_StrLen nExpStartPos = nPos;
+ sal_Bool bCurrCharIsSpace = sal_False;
+ xub_StrLen nSpaceChars = 0;
+ for( ; nPos < nEndPos; nPos++ )
+ {
+ sal_Bool bExpCharAsText = sal_True;
+ const SwTxtAttr * pTxtAttrWOEnd = 0;
+ if( nHintPos < nHintCount && *pTxtAttr->GetStart() == nPos
+ && nPos != nEndPos )
+ {
+ do
+ {
+ if( pTxtAttr->GetEnd() )
+ {
+ if( *pTxtAttr->GetEnd() != nPos )
+ {
+ // insert hint into the hint list if its not
+ // empty
+ aHintLst.Insert( pTxtAttr->GetAttr(),
+ nPos + nOffset,
+ *pTxtAttr->GetEnd() + nOffset );
+ }
+ }
+ else
+ {
+ // hints without end must be exported after all
+ // other hints that start at this position
+ ASSERT( !pTxtAttrWOEnd,
+ "SwXMLExport::ExportTxtNode: There is a hint already" );
+ pTxtAttrWOEnd = pTxtAttr;
+ bExpCharAsText = sal_False; // ignore 0xff
+ }
+ }
+ while( ++nHintPos < nHintCount &&
+ nPos == *( pTxtAttr = (*pHints)[nHintPos] )->GetStart() );
+ }
+
+ // Some characters require some extra work ...
+ sal_Bool bExpCharAsElement = sal_False;
+ sal_Bool bPrevCharIsSpace = bCurrCharIsSpace;
+ bCurrCharIsSpace = sal_False;
+ if( bExpCharAsText )
+ {
+ switch( rText.GetChar(nPos) )
+ {
+ case 0x0009: // Tab
+ case 0x000A: // LF
+ // These characters are exported as text.
+ bExpCharAsElement = sal_True;
+ bExpCharAsText = sal_False;
+ break;
+ case 0x0020: // Blank
+ if( bPrevCharIsSpace )
+ {
+ // If the previous character is a space character,
+ // too, export a special space element.
+ bExpCharAsText = sal_False;
+ }
+ bCurrCharIsSpace = sal_True;
+ break;
+ }
+ }
+
+ // If the current character is not exported as text or if there
+ // are hints starting or ending before the current position,
+ // the text that has not been exported by now has to be exported
+ // now.
+ if( nPos > nExpStartPos &&
+ ( !bExpCharAsText ||
+ aHintLst.HasStartingOrEndingHints( nPos+nOffset ) ) )
+ {
+ ASSERT( 0==nSpaceChars,
+ "SwXMLExport::ExportTxtNode: pending spaces" );
+ String sExp( rText.Copy( nExpStartPos,
+ nPos - nExpStartPos ) );
+ GetDocHandler()->characters( sExp );
+ nExpStartPos = nPos;
+ }
+
+ // If there are spaces left that have not been exported and the
+ // current chracter is either not a space or there are some
+ // hints starting or ending, the pending spaces have to be
+ // exported now.
+ if( nSpaceChars > 0 &&
+ ( !bCurrCharIsSpace ||
+ aHintLst.HasStartingOrEndingHints( nPos+nOffset ) ) )
+ {
+ ASSERT( nExpStartPos == nPos,
+ "SwXMLExport::ExportTxtNode: pending characters" );
+
+ if( nSpaceChars > 1 )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( (sal_Int32)nSpaceChars );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_c,
+ sTmp.makeStringAndClear() );
+ }
+
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
+ sXML_s, sal_False, sal_False );
+
+ nSpaceChars = 0;
+ }
+
+ // Before the text or tag of the current element, ending and
+ // starting hints have to be exported.
+ aHintLst.ExportEndingHints( nPos + nOffset );
+ aHintLst.ExportStartingHints( nPos + nOffset );
+
+ // If the current character has to be exported as a special
+ // element, the elemnt will be exported now.
+ if( bExpCharAsElement )
+ {
+ switch( rText.GetChar(nPos) )
+ {
+ case 0x0009: // Tab
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
+ sXML_tab_stop, sal_False,
+ sal_False );
+ }
+ break;
+ case 0x000A: // LF
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT,
+ sXML_line_break, sal_False,
+ sal_False );
+ }
+ break;
+ }
+ }
+ if( pTxtAttrWOEnd )
+ {
+ // TODO: This is a hack as long as if there is no field
+ // export.
+ if( RES_TXTATR_FIELD == pTxtAttrWOEnd->Which() )
+ {
+ const SwField *pFld =
+ ((const SwFmtFld&)pTxtAttrWOEnd->GetAttr()).GetFld();
+ if( pFld )
+ {
+ GetDocHandler()->characters( pFld->Expand() );
+ }
+#ifdef XML_CORE_API
+// Reference < XTextField > xFld = new SwXTextField(
+// ((const SwFmtFld&)pTxtAttrWOEnd->GetAttr()),
+// &GetDoc() );
+//
+// GetTextFieldExport().ExportField( xFld );
+#endif
+ }
+ }
+
+ // If the current character is a space, and the previous one
+ // is a space, too, the number of pending spaces is incremented
+ // only.
+ if( bCurrCharIsSpace && bPrevCharIsSpace )
+ nSpaceChars++;
+
+ // If the currect character is not exported as text, the start
+ // position for text is the position behind the current position.
+ if( !bExpCharAsText )
+ {
+ ASSERT( nExpStartPos == nPos, "wrong export start pos" );
+ nExpStartPos = nPos+1;
+ }
+ }
+
+ // If there is some text left, it has to be exported now.
+ if( nExpStartPos < nEndPos )
+ {
+ ASSERT( 0==nSpaceChars,
+ "SwXMLExport::ExportTxtNode: pending spaces " );
+ String sExp( rText.Copy( nExpStartPos, nEndPos - nExpStartPos ) );
+ GetDocHandler()->characters( sExp );
+ }
+
+ // If there are some spaces left, they have to be exported now.
+ if( nSpaceChars > 0 )
+ {
+ if( nSpaceChars > 1 )
+ {
+ OUStringBuffer sTmp;
+ sTmp.append( (sal_Int32)nSpaceChars );
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_c,
+ sTmp.makeStringAndClear() );
+ }
+
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, sXML_s,
+ sal_False, sal_False );
+ }
+
+ // The same applies to all hints that are currently open.
+ aHintLst.ExportEndingHints( STRING_LEN );
+ }
+}
+
+void SwXMLExport::ExportSection( const SwSectionNode& rSectNd )
+{
+#if 0
+ const SwSection& rSection = rSectNd.GetSection();
+ const SwSectionFmt *pSectFmt = rSection.GetFmt();
+ ASSERT( pSectFmt, "SwXMLExport::ExportSection: section without a format?" );
+
+ // <text:section-desc ...>
+ CheckAttrList();
+
+ // text:name="..."
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_name, S2WS(rSection.GetName()) );
+
+ // text:hidden="..."
+ if( rSection.IsHidden() )
+ {
+ AddAttributeASCII( XML_NAMESPACE_TEXT, sXML_hidden, sXML_true );
+
+ // text:condition="..."
+ if( rSection.IsCondHidden() )
+ {
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_condition,
+ S2WS(rSection.GetCondition()) );
+ }
+ }
+
+ {
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, sXML_section_desc,
+ sal_True, sal_True );
+// TODO
+// pSectionItemExport->Export( pSectFmt->GetAttrSet(), XML_ITEM_IGN_WS );
+ }
+
+ // <text:section ...>
+ CheckAttrList();
+
+ // text:name="..."
+ AddAttribute( XML_NAMESPACE_TEXT, sXML_section_name,
+ S2WS(rSection.GetName()) );
+#endif
+
+ SwNode *pStartNd = pDoc->GetNodes()[rSectNd.GetIndex() + 1];
+ SwNode *pEndNd = pDoc->GetNodes()[rSectNd.EndOfSectionIndex() - 1];
+
+ {
+#if 0
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, sXML_section,
+ sal_True, sal_True );
+#endif
+ SwXMLExpContext aContext( *this, *pStartNd, *pEndNd, 0, STRING_LEN );
+ ExportCurPaM();
+ }
+
+ pCurPaM->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
+}
+#endif
+
+/*************************************************************************
+
+ Source Code Control System - Header
+
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/xmltext.cxx,v 1.1.1.1 2000-09-18 17:15:00 hr Exp $
+
+ Source Code Control System - Update
+
+ $Log: not supported by cvs2svn $
+ Revision 1.48 2000/09/18 16:05:08 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.47 2000/09/18 11:58:03 mib
+ text frames/graphics import and export continued
+
+ Revision 1.46 2000/08/24 11:16:42 mib
+ text import continued
+
+ Revision 1.45 2000/08/10 10:22:16 mib
+ #74404#: Adeptions to new XSL/XLink working draft
+
+ Revision 1.44 2000/08/04 11:39:54 dvo
+ - field declarations import removed from CORE API import
+
+ Revision 1.43 2000/08/03 18:03:58 dvo
+ - variable field declarations import added
+
+ Revision 1.42 2000/07/31 09:42:35 mib
+ text export continued
+
+ Revision 1.41 2000/07/24 10:19:02 dvo
+ - textfield export for XML_CORE_API
+
+ Revision 1.40 2000/07/21 12:55:15 mib
+ text import/export using StarOffice API
+
+ Revision 1.39 2000/07/11 11:17:59 dvo
+ text field export added
+
+ Revision 1.38 2000/06/08 09:45:55 aw
+ changed to use functionality from xmloff project now
+
+ Revision 1.37 2000/05/24 12:08:11 mib
+ unicode bug fix
+
+ Revision 1.36 2000/05/03 12:08:05 mib
+ unicode
+
+ Revision 1.35 2000/03/13 14:33:45 mib
+ UNO3
+
+ Revision 1.34 2000/03/06 10:46:11 mib
+ #72585#: toInt32
+
+ Revision 1.33 2000/02/21 12:51:07 mib
+ #70271#: Export of section element removed
+
+ Revision 1.32 2000/02/17 14:40:30 mib
+ #70271#: XML table import
+
+ Revision 1.30 2000/01/27 08:59:02 mib
+ #70271#: outline numbering
+
+ Revision 1.29 2000/01/20 10:03:16 mib
+ #70271#: Lists reworked
+
+ Revision 1.28 2000/01/12 15:00:23 mib
+ #70271#: lists
+
+ Revision 1.27 2000/01/06 15:08:28 mib
+ #70271#:separation of text/layout, cond. styles, adaptions to wd-xlink-19991229
+
+ Revision 1.26 1999/12/14 09:47:51 mib
+ #70271#: Export field content as text
+
+ Revision 1.25 1999/12/13 08:29:07 mib
+ #70271#: Support for element items added, background and brush item
+
+ Revision 1.24 1999/12/08 10:44:21 cl
+ #70271# added first support for importing tab-stops
+
+ Revision 1.23 1999/12/06 11:41:33 mib
+ #70258#: Container item for unkown attributes
+
+ Revision 1.22 1999/11/26 11:11:49 mib
+ export-flags, loading of styles only
+
+ Revision 1.21 1999/11/19 15:27:59 mib
+ Opt: using C++ arrays instead of string buffers
+
+ Revision 1.20 1999/11/12 11:43:03 mib
+ using item mapper, part iii
+
+ Revision 1.19 1999/11/10 15:08:09 mib
+ Import now uses XMLItemMapper
+
+ Revision 1.18 1999/11/09 15:40:08 mib
+ Using XMLItemMapper for export
+
+ Revision 1.17 1999/11/03 11:13:50 mib
+ list style import continued
+
+ Revision 1.16 1999/11/01 11:38:50 mib
+ List style import
+
+ Revision 1.15 1999/10/26 13:33:50 mib
+ list styles continued
+
+ Revision 1.14 1999/10/25 10:41:48 mib
+ Using new OUString ASCII methods
+
+ Revision 1.13 1999/10/15 12:38:01 mib
+ XML_TOK_SW_LINE_FEED -> XML_TOK_SW_LINE_BREAK
+
+ Revision 1.12 1999/10/08 11:47:56 mib
+ moved some file to SVTOOLS/SVX
+
+ Revision 1.11 1999/10/06 06:48:06 mib
+ WS stripping
+
+ Revision 1.10 1999/10/01 14:12:02 mib
+ tab, line break and space
+
+ Revision 1.9 1999/09/28 10:47:05 mib
+ memory leak
+
+ Revision 1.8 1999/09/28 08:31:47 mib
+ char fmts, hints
+
+ Revision 1.7 1999/09/23 11:54:28 mib
+ i18n, token maps and hard paragraph attributes
+
+ Revision 1.6 1999/09/22 11:57:46 mib
+ string -> wstring
+
+ Revision 1.5 1999/08/18 15:03:38 MIB
+ Style import
+
+
+ Rev 1.4 18 Aug 1999 17:03:38 MIB
+ Style import
+
+ Rev 1.3 17 Aug 1999 16:29:24 MIB
+ import of text nodes started
+
+ Rev 1.2 13 Aug 1999 16:19:42 MIB
+ styles and sections
+
+ Rev 1.1 12 Aug 1999 18:06:22 MIB
+ Export ofSvxFontItem, SvxFontHeightItem and SvxLRSpaceItem
+
+ Rev 1.0 12 Aug 1999 12:29:28 MIB
+ Initial revision.
+
+*************************************************************************/
+
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
new file mode 100644
index 000000000000..0c22b3eaaa70
--- /dev/null
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltexte.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _XMLTEXTE_HXX
+#define _XMLTEXTE_HXX
+
+#ifndef XML_CORE_API
+
+#ifndef _XMLOFF_TEXTPARAE_HXX_
+#include <xmloff/txtparae.hxx>
+#endif
+
+class SwXMLExport;
+class SvXMLAutoStylePoolP;
+
+namespace com { namespace sun { namespace star { namespace style {
+ class XStyle; } } } }
+
+class SwXMLTextParagraphExport : public XMLTextParagraphExport
+{
+ const ::rtl::OUString sTextTable;
+
+protected:
+ virtual void exportStyleContent(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::style::XStyle > & rStyle );
+
+ virtual void exportTable(
+ const ::com::sun::star::uno::Reference <
+ ::com::sun::star::text::XTextContent > & rTextContent,
+ sal_Bool bAutoStyles );
+
+public:
+ SwXMLTextParagraphExport(
+ SwXMLExport& rExp,
+ SvXMLAutoStylePoolP& rAutoStylePool );
+ ~SwXMLTextParagraphExport();
+};
+#endif
+
+
+#endif // _XMLTEXTE_HXX
diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx
new file mode 100644
index 000000000000..f11faf0e4a77
--- /dev/null
+++ b/sw/source/filter/xml/xmltexti.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmltexti.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 17:15:00 $
+ *
+ * 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 _XMLTEXTI_HXX
+#define _XMLTEXTI_HXX
+
+#ifndef _RTL_USTRING_HXX
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLTKMAP_HXX
+#include <xmloff/xmltkmap.hxx>
+#endif
+
+#ifndef _XMLOFF_XMLICTXT_HXX
+#include <xmloff/xmlictxt.hxx>
+#endif
+
+#ifdef XML_CORE_API
+class SfxItemSet;
+class SwXMLHints_Impl;
+class SwXMLImport;
+namespace com { namespace sun { namespace star { namespace xml {
+ namespace sax { class XAttributeList; } } } } }
+
+
+enum SwXMLBodyElemTokens
+{
+ XML_TOK_SW_P,
+ XML_TOK_SW_H,
+ XML_TOK_SW_ORDERED_LIST,
+ XML_TOK_SW_UNORDERED_LIST,
+ XML_TOK_TABLE_TABLE,
+ XML_TOK_TABLE_SUBTABLE,
+ XML_TOK_SW_ELEM_END=XML_TOK_UNKNOWN
+};
+
+class SwXMLParaContext : public SvXMLImportContext
+{
+ SfxItemSet *pItemSet;
+ SwXMLHints_Impl *pHints;
+ sal_Bool bIgnoreLeadingSpace;
+ sal_Bool bHeading;
+
+public:
+
+ SwXMLParaContext( SwXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_Bool bHeading );
+
+ virtual ~SwXMLParaContext();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+
+ virtual void Characters( const ::rtl::OUString& rChars );
+
+ SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
+};
+#endif
+
+
+#endif // _XMLTEXTI_HXX